/[drupal]/contributions/modules/admintools/cron.module
ViewVC logotype

Diff of /contributions/modules/admintools/cron.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.7, Mon Jun 15 10:43:17 2009 UTC revision 1.8, Mon Jun 15 11:18:03 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: cron.module,v 1.6 2009/06/08 13:41:07 denraf Exp $  // $Id: cron.module,v 1.7 2009/06/15 10:43:17 denraf Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 56  function cron_menu() { Line 56  function cron_menu() {
56      'access arguments' => array('admin tools'),      'access arguments' => array('admin tools'),
57      'type' => MENU_CALLBACK      'type' => MENU_CALLBACK
58    );    );
59      $items['admin/settings/tools/cron/settings'] = array(
60        'title' => 'Settings',
61        'description' => 'Basic settings',
62        'page callback' => 'drupal_get_form',
63        'page arguments' => array('cron_settings_form'),
64        'access arguments' => array('admin tools'),
65        'weight' => 2,
66        'type' => MENU_LOCAL_TASK
67      );
68    return $items;    return $items;
69  }  }
70    
71  function cron_list_form() {  function cron_list_form() {
72    
73      if (($end = variable_get('cron_interval_end', 0)) && ($start = variable_get('cron_interval_start', 0))) {
74        $form['interval'] = array(
75          '#value' => t('The cron of this site runs every '.format_interval($end - $start)),
76        );
77      }
78    
79    $header = array(    $header = array(
80      t('Site'),      t('Site'),
81      t('Cron key (Drupal 7)'),      t('Cron key (Drupal 7)'),
# Line 286  function cron_delete($sid = 0) { Line 302  function cron_delete($sid = 0) {
302    drupal_goto('admin/settings/tools/cron');    drupal_goto('admin/settings/tools/cron');
303  }  }
304    
305    function cron_settings_form($form, $form_state) {
306    
307      $form['reset'] = array(
308        '#type' => 'fieldset',
309        '#description' => t('Reset cron interval timer'),
310        '#title' => 'Reset',
311        '#collapsible' => FALSE,
312        '#collapsed' => FALSE,
313      );
314      $form['reset']['button'] = array(
315        '#type' => 'submit',
316        '#description' => t('Reset cron interval timer'),
317        '#value' => t('Reset'),
318        '#submit' => 'cron_interval_reset'
319      );
320    
321      $form['fault_level'] = array(
322        '#type' => 'textfield',
323        '#size' => 3,
324        '#default_value' => variable_get('fault_level', 0)
325      )
326    
327      return system_settings_form($form);
328    }
329    
330    function cron_interval_reset($form, $form_state) {
331      variable_set('cron_interval_start', 0);
332      variable_set('cron_interval_end', 0);
333    }
334    
335  /**  /**
336   * Implementation of hook_theme().   * Implementation of hook_theme().
337   */   */
# Line 420  function theme_cron_edit_form($form) { Line 466  function theme_cron_edit_form($form) {
466   */   */
467  function cron_cron() {  function cron_cron() {
468    
469      if (variable_get('cron_interval_start', 0) == 0) {
470        variable_set('cron_interval_start', time());
471      }
472      else {
473        if (variable_get('cron_interval_end', 0) == 0) {
474          variable_set('cron_interval_end', time());
475        }
476      }
477    
478    $sql = db_query("SELECT sid, url, cron_key, checks, errors, last_check, last_error, interval, count FROM {cron} WHERE disabled = '%d'", FALSE);    $sql = db_query("SELECT sid, url, cron_key, checks, errors, last_check, last_error, interval, count FROM {cron} WHERE disabled = '%d'", FALSE);
479    while ($row = db_fetch_object($sql)) {    while ($row = db_fetch_object($sql)) {
480      if ($row->count == 0) {      if ($row->count == 0) {
# Line 495  function cron_cron() { Line 550  function cron_cron() {
550        }        }
551    
552        $disable = FALSE;        $disable = FALSE;
553        if (($last_error > $row->last_error) && ($candidate == TRUE) && ( $errors > (0.9 * $checks) )) {        $level = variable_get('fault_level', 0) / 100.0;
554          if (($last_error > $row->last_error) && ($candidate == TRUE) && ( $errors > ($level * $checks) )) {
555          // when 2 last checks failed and 90% of all checks failed, disable this site          // when 2 last checks failed and 90% of all checks failed, disable this site
556          $disable = TRUE;          $disable = TRUE;
557        }        }

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.2