diff --git a/path_redirect.admin.inc b/path_redirect.admin.inc index aba0c33..76abbbf 100644 --- a/path_redirect.admin.inc +++ b/path_redirect.admin.inc @@ -23,6 +23,7 @@ function path_redirect_list_redirects($query = array(), $conditions = array(), $ 'type' => array('data' => t('Type'), 'field' => 'type'), 'language' => array('data' => t('Language'), 'field' => 'language'), 'last_used' => array('data' => t('Last used'), 'field' => 'last_used'), + 'counter' => array('data' => t('Counter'), 'field' => 'counter'), 'operations' => array('data' => t('Operations')), ); @@ -80,6 +81,9 @@ function path_redirect_list_redirects($query = array(), $conditions = array(), $ if (isset($header['last_used'])) { $row['last_used'] = format_date($redirect['last_used'], 'short'); } + if (isset($header['counter'])) { + $row['counter'] = $redirect['counter']; + } if (isset($header['operations'])) { $operations = array(); $operations['edit'] = array( diff --git a/path_redirect.install b/path_redirect.install index c94f8c3..0516f72 100644 --- a/path_redirect.install +++ b/path_redirect.install @@ -61,6 +61,12 @@ function path_redirect_schema() { 'default' => 0, 'description' => 'The timestamp of when the redirect was last used.', ), + 'counter' => array( + 'type' => 'int', + 'length' => '10', + 'not null' => FALSE, + 'description' => 'Number of times redirect has been used.', + ), ), 'primary key' => array('rid'), 'unique keys' => array('source_language' => array('source', 'language')), @@ -210,6 +216,15 @@ function path_redirect_update_6103() { } /** + * Add Counter field. + */ +function path_redirect_update_6104() { + $ret = array(); + db_add_field($ret, 'path_redirect', 'counter', array('type' => 'int', 'length' => 10, 'not null' => TRUE, 'default' => '0')); + return $ret; +} + +/** * @} End of "defgroup updates-6.x-extra" * The next series of updates should start at 7000. */ diff --git a/path_redirect.module b/path_redirect.module index e964a35..42b026d 100644 --- a/path_redirect.module +++ b/path_redirect.module @@ -134,6 +134,9 @@ function path_redirect_goto($redirect = NULL) { drupal_set_html_head(''); } else { + // Increment redirect counter. + db_query("UPDATE {path_redirect} SET counter = counter + 1 WHERE rid = %d", $redirect['rid']); + // Perform the redirect. unset($_REQUEST['destination']); drupal_goto($redirect['redirect_url'], NULL, NULL, $redirect['type']); @@ -324,6 +327,7 @@ function path_redirect_save(&$redirect) { 'language' => '', 'type' => variable_get('path_redirect_default_status', 301), 'last_used' => time(), + 'counter' => '', ); // Convert query arrays into a saveable query string.