| 1 |
<?php |
<?php |
| 2 |
/** |
/** |
| 3 |
* $Id: cronplus.module,v 1.8 2007/03/22 23:41:18 syscrusher Exp $ |
* $Id: cronplus.module,v 1.8.2.4 2008/12/19 09:47:18 syscrusher Exp $ |
| 4 |
* |
* |
| 5 |
* CronPlus enhances the Drupal cron feature to provide specific calls to |
* CronPlus enhances the Drupal cron feature to provide specific calls to |
| 6 |
* other modules at hourly, daily, weekly, monthly, and yearly intervals. |
* other modules at hourly, daily, weekly, monthly, and yearly intervals. |
| 22 |
/** |
/** |
| 23 |
* Implements hook_menu(). |
* Implements hook_menu(). |
| 24 |
*/ |
*/ |
| 25 |
function cronplus_menu($may_cache) { |
function cronplus_menu() { |
| 26 |
$items = array(); |
$items = array(); |
| 27 |
if ($may_cache) { |
$items['admin/settings/cronplus'] = array( |
| 28 |
$items[] = array( |
'title' => t('cronplus'), |
| 29 |
'path' => 'admin/settings/cronplus', |
'page callback' => 'cronplus_settings_main', |
| 30 |
'title' => t('cronplus'), |
'description' => 'Select which hour and on what day you would like houly and daily crons to run. Also see the status of cronplus', |
| 31 |
'callback' => 'cronplus_settings_main', |
'access callback' => 'user_access', |
| 32 |
'description' => 'Select which hour and on what day you would like houly and daily crons to run. Also see the status of cronplus', |
'access arguments' => array('administer site configuration'), |
| 33 |
'access' => user_access('administer site configuration'), |
// 'type' => MENU_LOCAL_TASK, |
| 34 |
// 'type' => MENU_LOCAL_TASK, |
); |
| 35 |
); |
$items['admin/settings/cronplus/main'] = array( |
| 36 |
$items[] = array( |
'title' => t('configuration'), |
| 37 |
'path' => 'admin/settings/cronplus/main', |
'type' => MENU_DEFAULT_LOCAL_TASK, |
| 38 |
'title' => t('configuration'), |
'access callback' => 'user_access', |
| 39 |
'type' => MENU_DEFAULT_LOCAL_TASK, |
'access arguments' => array('administer site configuration'), |
| 40 |
'weight' => -10, |
'weight' => -10, |
| 41 |
); |
); |
| 42 |
} |
$items['admin/settings/cronplus/status'] = array( |
| 43 |
else { |
'title' => t('status report'), |
| 44 |
$items[] = array( |
'page callback' => 'cronplus_settings_status', 'access' => user_access('administer site configuration'), |
| 45 |
'path' => 'admin/settings/cronplus/status', |
'access callback' => 'user_access', |
| 46 |
'title' => t('status report'), |
'access arguments' => array('administer site configuration'), |
| 47 |
'callback' => 'cronplus_settings_status', 'access' => user_access('administer site configuration'), |
'type' => MENU_LOCAL_TASK, 'weight' => 10 |
| 48 |
'type' => MENU_LOCAL_TASK, 'weight' => 10); |
); |
|
} |
|
| 49 |
return $items; |
return $items; |
| 50 |
} |
} |
| 51 |
|
|
| 104 |
'#type' => 'submit', |
'#type' => 'submit', |
| 105 |
'#value' => t('Save settings'), |
'#value' => t('Save settings'), |
| 106 |
); |
); |
| 107 |
return $form; |
return system_settings_form($form); |
| 108 |
} |
} |
| 109 |
|
|
| 110 |
/** |
/** |
| 142 |
*/ |
*/ |
| 143 |
function cronplus_logview_form_submit($form_id, $form_values) { |
function cronplus_logview_form_submit($form_id, $form_values) { |
| 144 |
$_SESSION['watchdog_overview_filter'] = 'cronplus'; |
$_SESSION['watchdog_overview_filter'] = 'cronplus'; |
| 145 |
drupal_goto('admin/logs/watchdog'); |
drupal_goto('admin/reports/dblog'); |
| 146 |
} |
} |
| 147 |
|
|
| 148 |
/** |
/** |
| 190 |
// Gather information... |
// Gather information... |
| 191 |
$last_cron = intval(variable_get('cronplus_last_cron', 0)); |
$last_cron = intval(variable_get('cronplus_last_cron', 0)); |
| 192 |
$now = time(); |
$now = time(); |
| 193 |
$now_wkdy = intval(gmdate('w'), $now); // 0=Sunday |
$now_wkdy = intval(gmdate('w', $now)); // 0=Sunday |
| 194 |
// For the $now_week, weeks start on Monday, not Sunday. This is a mismatch |
// For the $now_week, weeks start on Monday, not Sunday. This is a mismatch |
| 195 |
// against $now_wkdy, but it doesn't matter because all we are looking for |
// against $now_wkdy, but it doesn't matter because all we are looking for |
| 196 |
// in $now_week is a *change* -- we don't care about the actual value. |
// in $now_week is a *change* -- we don't care about the actual value. |
| 273 |
$function_name = 'cronplus_'. $period; |
$function_name = 'cronplus_'. $period; |
| 274 |
$last_this = variable_get($function_name .'_last', 0); |
$last_this = variable_get($function_name .'_last', 0); |
| 275 |
variable_set($function_name .'_last', $now); |
variable_set($function_name .'_last', $now); |
| 276 |
watchdog('cronplus', t('Processing %period cron for %d UTC, calling {module}_%func() for all modules', array('%d' => $now_fmt, '%period' => t($period), '%func' => $function_name)), WATCHDOG_NOTICE); |
watchdog('cronplus', 'Processing %period cron for %d UTC, calling {module}_%func() for all modules', array('%d' => $now_fmt, '%period' => t($period), '%func' => $function_name), WATCHDOG_NOTICE); |
| 277 |
@module_invoke_all($function_name, $now, $last_cron, $last_this); |
@module_invoke_all($function_name, $now, $last_cron, $last_this); |
| 278 |
@module_invoke_all('cronplus', $period, $now, $last_cron, $last_this); |
@module_invoke_all('cronplus', $period, $now, $last_cron, $last_this); |
| 279 |
} |
} |
| 295 |
} |
} |
| 296 |
return $options; |
return $options; |
| 297 |
} |
} |
|
?> |
|