diff -urp path_redirect.old\path_redirect.install path_redirect.new\path_redirect.install --- path_redirect.old\path_redirect.install Tue Apr 15 22:49:36 2008 +++ path_redirect.new\path_redirect.install Sun Jan 03 20:04:24 2010 @@ -11,6 +11,7 @@ function path_redirect_install() { redirect varchar(255) NOT NULL, query varchar(255) NOT NULL, fragment varchar(50) NOT NULL, + counter int(10) NOT NULL, type int(10) NOT NULL, PRIMARY KEY (rid), UNIQUE KEY path (path) @@ -23,6 +24,7 @@ function path_redirect_install() { redirect varchar(255) NOT NULL, query varchar(255) NOT NULL, fragment varchar(50) NOT NULL, + counter int(10) NOT NULL, type smallint NOT NULL );"); break; @@ -104,6 +106,15 @@ function path_redirect_update_4() { $ret[] = update_sql("ALTER TABLE {path_redirect} ADD UNIQUE (path)"); break; } + drupal_set_message(t('Database tables for the Path Redirect module have been updated.')); + return $ret; +} + +/** +* Includes redirect counter column. +*/ +function path_redirect_update_5() { + $ret[] = update_sql("ALTER TABLE {path_redirect} ADD counter int(10) NOT NULL"); drupal_set_message(t('Database tables for the Path Redirect module have been updated.')); return $ret; } diff -urp path_redirect.old\path_redirect.module path_redirect.new\path_redirect.module --- path_redirect.old\path_redirect.module Tue May 13 20:55:34 2008 +++ path_redirect.new\path_redirect.module Sun Jan 03 20:05:43 2010 @@ -49,6 +49,10 @@ function path_redirect_init() { if (function_exists('drupal_goto')) { // if there's a result found, do the redirect unset($_REQUEST['destination']); + + // Increment redirect counter. + db_query("UPDATE {path_redirect} SET counter = counter + 1 WHERE rid = %d", $r->rid); + drupal_goto($r->redirect, ($r->query ? $r->query: NULL), ($r->fragment ? $r->fragment : NULL), $r->type); } else { @@ -140,10 +144,11 @@ function path_redirect_admin($rid = FALS array('data' => t('From'), 'field' => 'path', 'sort' => 'asc'), array('data' => t('To'), 'field' => 'redirect'), array('data' => t('Type'), 'field' => 'type'), + array('data' => t('Counter'), 'field' => 'counter'), array('data' => t('Operations'), 'colspan' => '3') ); - $result = pager_query('SELECT rid, path, redirect, query, fragment, type FROM {path_redirect}'. tablesort_sql($header), 50); + $result = pager_query('SELECT rid, path, redirect, query, fragment, type, counter FROM {path_redirect}'. tablesort_sql($header), 50); $count = db_num_rows($result); $types = path_redirect_status_codes(); while ($r = db_fetch_object($result)) { @@ -155,6 +160,7 @@ function path_redirect_admin($rid = FALS htmlspecialchars(urldecode($path)), htmlspecialchars($redirect . $query . $fragment), $types[$r->type]['title'], + $r->counter, array('data' => l(t('test'), preg_replace('/\?.*/', '', urldecode($path)), NULL, strstr($path, '?') ? preg_replace('/.*\?/', '', $path) : NULL)), array('data' => l(t('edit'), 'admin/build/path-redirect/edit/'. $r->rid)), array('data' => l(t('delete'), 'admin/build/path-redirect/delete/'. $r->rid)), @@ -194,7 +200,7 @@ function path_redirect_edit($rid = FALSE return $output; } -function path_redirect_edit_form($edit = array('path' => '', 'redirect' => '', 'query' => '', 'fragment' => '', 'type' => PATH_REDIRECT_DEFAULT_TYPE, 'rid' => NULL)) { +function path_redirect_edit_form($edit = array('path' => '', 'redirect' => '', 'query' => '', 'fragment' => '', 'counter' => 0, 'type' => PATH_REDIRECT_DEFAULT_TYPE, 'rid' => NULL)) { $form['path'] = array( '#type' => 'textfield', '#title' => t('From'), @@ -242,6 +248,15 @@ function path_redirect_edit_form($edit = '#default_value' => $edit['fragment'], ); + $form['counter'] = array( + '#type' => 'textfield', + '#title' => t('Counter'), + '#description' => t('Enter redirect counter.'), + '#size' => 12, + '#maxlength' => 255, + '#default_value' => $edit['counter'], + ); + $form[] = array( '#value' => "
", // little bit of extra space ); @@ -360,10 +375,10 @@ function path_redirect_save($edit) { */ function path_redirect_load($rid = NULL, $from = NULL) { if (!empty($rid)) { - $result = db_fetch_array(db_query("SELECT rid, path, redirect, query, fragment, type FROM {path_redirect} WHERE rid = %d", $rid)); + $result = db_fetch_array(db_query("SELECT rid, path, redirect, query, fragment, counter, type FROM {path_redirect} WHERE rid = %d", $rid)); } else if (!empty($from)) { - $result = db_fetch_array(db_query("SELECT rid, path, redirect, query, fragment, type FROM {path_redirect} WHERE path = '%s'", $from)); + $result = db_fetch_array(db_query("SELECT rid, path, redirect, query, fragment, counter, type FROM {path_redirect} WHERE path = '%s'", $from)); } if ($result) {