? auto_expire.patch
Index: auto_expire.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/auto_expire/auto_expire.module,v
retrieving revision 1.14
diff -u -p -r1.14 auto_expire.module
--- auto_expire.module	28 Jun 2009 22:55:18 -0000	1.14
+++ auto_expire.module	22 Feb 2010 23:16:22 -0000
@@ -24,7 +24,6 @@ function auto_expire_help($path, $arg) {
     case 'admin/help#auto_expire':
     case 'admin/modules#description':
       return t('Expires nodes automatically.');
-      break;
   }
 }
 
@@ -43,7 +42,7 @@ function auto_expire_menu() {
     'type' => MENU_NORMAL_ITEM,
   );
     
-  $items['node/%/expiry'] = array(
+  $items['node/%node/expiry'] = array(
     'title' => 'Extend',
     'description' => 'See and extend the expiry period.',
     'page callback' => 'drupal_get_form',
@@ -61,11 +60,9 @@ function _auto_expire_is_expiring_node($
   return variable_get(AUTO_EXPIRE_NODE_TYPE . $node->type .'_e', 0);
 }
 
-function _auto_expire_can_user_extend($nid) {
+function _auto_expire_can_user_extend($node) {
   global $user;
   
-  $node = node_load($nid);
-  
   $will_expire = _auto_expire_is_expiring_node($node);
   
   if ($will_expire) {
@@ -76,32 +73,39 @@ function _auto_expire_can_user_extend($n
   }
 }
 
-function _auto_expire_expiry(&$form_state, $nid) {
-  $node = node_load($nid);
-  
+function _auto_expire_expiry(&$form_state, $node) {
   drupal_set_title(check_plain($node->title));
-  
   $expire = _auto_expire_get_expire($node->nid);
   $code = AUTO_EXPIRE_NODE_TYPE . $node->type;
   $warn = variable_get($code .'_w', AUTO_EXPIRE_WARN);
   
-  $form['nid'] = array(
+  $form['node'] = array(
     '#type' => 'value',
-    '#value' => $nid
+    '#value' => $node,
   );
   
   $form['expire'] = array(
     '#type' => 'value',
     '#value' => $expire
   );
-  
-  if (time() < $expire) {
+
+  if (empty($expire)) {
+    $form['expireson'] = array(
+      '#value' => '<p>'.
+                  t('@title has no expiry setting - please run cron.', array(
+                    '@title' => $node->title)
+                  ) .
+                  '</p>',
+    );
+    return $form;
+  }
+  elseif (time() < $expire) {
     $form['expireson'] = array(
       '#value' => '<p>'.
-                  t('!title will expire on !date<br />that is in !daysleft.', array(
-                    '!title' => $node->title,
-                    '!date' => format_date($expire),
-                    '!daysleft' => format_interval($expire - time()))
+                  t('@title will expire on @date<br />that is in @daysleft.', array(
+                    '@title' => $node->title,
+                    '@date' => format_date($expire),
+                    '@daysleft' => format_interval($expire - time()))
                   ) .
                   '</p>',
     );
@@ -109,9 +113,9 @@ function _auto_expire_expiry(&$form_stat
   else {
     $form['expireson'] = array(
       '#value' => '<p>'.
-                  t('!title has expired on !date.', array(
-                    '!title' => $node->title,
-                    '!date' => format_date($expire))
+                  t('@title has expired on @date.', array(
+                    '@title' => $node->title,
+                    '@date' => format_date($expire))
                   ) .
                   '</p>',
     );
@@ -145,16 +149,16 @@ function _auto_expire_expiry(&$form_stat
 }
 
 function _auto_expire_expiry_submit($form, &$form_state) {
-  $node = node_load($form_state['values']['nid']);
+  $node = $form_state['values']['node'];
   $expire = $form_state['values']['expire'];
-  
+
   $days = variable_get(AUTO_EXPIRE_NODE_TYPE . $node->type .'_d', AUTO_EXPIRE_DAYS);
   $newexpire = max(time(), $expire) + $days * 24 * 60 * 60;
   db_query('UPDATE {auto_expire} SET expire = %d, extended = extended + 1, warned = 0 WHERE nid = %d', $newexpire, $node->nid);
   db_query('UPDATE {node} SET status = 1 WHERE nid = %d', $node->nid);
   
   watchdog('auto_expire', "Extended node %node by @days days", array('%node' => $node->nid, '@days' => $days), WATCHDOG_NOTICE, l(t('view'), 'node/'.$node->nid));
-  drupal_set_message(t('Extended for !days more days', array('!days' => $days)));
+  drupal_set_message(t('Extended for @days more days', array('@days' => $days)));
   
   $form_state['redirect'] = "node/$node->nid/expiry";
 }
@@ -212,7 +216,7 @@ function _auto_expire_admin_settings() {
     '#title' => t('Expiration Warning Notification Email'),
     '#collapsible' => TRUE,
     '#collapsed' => FALSE,
-    '#description' => t("Template of email sent when content is about to expire. You can use the following variables: !type - content type, !title - title of content, !url - URL of content, !days - number of days before items expire, !date - the expiration date of the item, !daysleft - time left until the expiration date, !site - site name, !siteurl - site URL"),
+    '#description' => t("Template of email sent when content is about to expire. You can use the following variables: %type - content type, %title - title of content, %url - URL of content, %days - number of days before items expire, %date - the expiration date of the item, %daysleft - time left until the expiration date, %site - site name, %siteurl - site URL"),
   );
   
   $form['email']['warn'][AUTO_EXPIRE_EMAIL .'warn_subject'] = array(
@@ -220,14 +224,14 @@ function _auto_expire_admin_settings() {
     '#title' => t('Email Subject'),
     '#description' => t('Leave empty to disable Expiration Warning Notifications.'),
     '#return_value' => 1,
-    '#default_value' => variable_get(AUTO_EXPIRE_EMAIL .'warn_subject', t('!type about to expire')),
+    '#default_value' => variable_get(AUTO_EXPIRE_EMAIL .'warn_subject', t('%type about to expire')),
   );
   
   $form['email']['warn'][AUTO_EXPIRE_EMAIL .'warn_body'] = array(
     '#type' => 'textarea',
     '#title' => t('Email Body'),
     '#return_value' => 1,
-    '#default_value' => variable_get(AUTO_EXPIRE_EMAIL .'warn_body', t("Your !type listing '!title' will expire in !daysleft.\n\nPlease visit !site if you want to renew:\n!url")),
+    '#default_value' => variable_get(AUTO_EXPIRE_EMAIL .'warn_body', t("Your %type listing '%title' will expire in %daysleft.\n\nPlease visit %site if you want to renew:\n%url")),
   );
   
   $form['email']['expired'] = array(
@@ -235,7 +239,7 @@ function _auto_expire_admin_settings() {
     '#title' => t('Expired Notification Email'),
     '#collapsible' => TRUE,
     '#collapsed' => FALSE,
-    '#description' => t("Template of email sent right after the content has expired. You can use the following variables: !type - content type, !title - title of content, !url - URL of content, !days - number of days before items expire, !date - the expiration date of the item, !site - site name, !siteurl - site URL"),
+    '#description' => t("Template of email sent right after the content has expired. You can use the following variables: %type - content type, %title - title of content, %url - URL of content, %days - number of days before items expire, %date - the expiration date of the item, %site - site name, %siteurl - site URL"),
   );
   
   $form['email']['expired'][AUTO_EXPIRE_EMAIL .'expired_subject'] = array(
@@ -243,14 +247,14 @@ function _auto_expire_admin_settings() {
     '#title' => t('Email Subject'),
     '#description' => t('Leave empty to disable Expired Notifications.'),
     '#return_value' => 1,
-    '#default_value' => variable_get(AUTO_EXPIRE_EMAIL .'expired_subject', t('!type has expired')),
+    '#default_value' => variable_get(AUTO_EXPIRE_EMAIL .'expired_subject', t('%type has expired')),
   );
   
   $form['email']['expired'][AUTO_EXPIRE_EMAIL .'expired_body'] = array(
     '#type' => 'textarea',
     '#title' => t('Email Body'),
     '#return_value' => 1,
-    '#default_value' => variable_get(AUTO_EXPIRE_EMAIL .'expired_body', t("Your !type listing '!title' has expired.\n\nPlease visit !site to add new content:\n!siteurl")),
+    '#default_value' => variable_get(AUTO_EXPIRE_EMAIL .'expired_body', t("Your %type listing '%title' has expired.\n\nPlease visit !site to add new content:\n%siteurl")),
   );
   
   $form['email']['cc'][AUTO_EXPIRE_EMAIL .'bcc'] = array(
@@ -430,14 +434,14 @@ function auto_expire_node_type($op, $inf
 
 function _auto_expire_notify_warning($nid, $title, $type, $days, $subject, $body) {
   $args = array(
-    '!type' => $type,
-    '!title' => $title,
-    '!url' => url('node/'. $nid, array('absolute' => TRUE)),
-    '!days' => $days,
-    '!date' => format_date(_auto_expire_get_expire($nid)),
-    '!daysleft' => format_interval(_auto_expire_get_expire($nid) - time()),
-    '!site' => variable_get('site_name', ''),
-    '!siteurl' => url('<front>', array('absolute' => TRUE)),
+    '%type' => $type,
+    '%title' => $title,
+    '%url' => url('node/'. $nid, array('absolute' => TRUE)),
+    '%days' => $days,
+    '%date' => format_date(_auto_expire_get_expire($nid)),
+    '%daysleft' => format_interval(_auto_expire_get_expire($nid) - time()),
+    '%site' => variable_get('site_name', ''),
+    '%siteurl' => url('<front>', array('absolute' => TRUE)),
   );
   
   _auto_expire_notify($nid, 'auto_expire_warning', $subject, $body, $args);
@@ -445,13 +449,13 @@ function _auto_expire_notify_warning($ni
 
 function _auto_expire_notify_expired($nid, $title, $type, $days, $subject, $body) {
   $args = array(
-    '!type' => $type,
-    '!title' => $title,
-    '!url' => url('node/'. $nid, array('absolute' => TRUE)),
-    '!days' => $days,
-    '!date' => format_date(_auto_expire_get_expire($nid)),
-    '!site' => variable_get('site_name', ''),
-    '!siteurl' => url('<front>', array('absolute' => TRUE)),
+    '%type' => $type,
+    '%title' => $title,
+    '%url' => url('node/'. $nid, array('absolute' => TRUE)),
+    '%days' => $days,
+    '%date' => format_date(_auto_expire_get_expire($nid)),
+    '%site' => variable_get('site_name', ''),
+    '%siteurl' => url('<front>', array('absolute' => TRUE)),
   );
   
   _auto_expire_notify($nid, 'auto_expire_expired', $subject, $body, $args);
