b2evolution PHP Cross Reference Blogging Systems

Source: /inc/cron/views/_cronjob_list.view.php - 181 lines - 6008 bytes - Summary - Text - Print

Description: This file implements the UI view for the general settings. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file implements the UI view for the general settings.
   4   *
   5   * This file is part of the evoCore framework - {@link http://evocore.net/}
   6   * See also {@link http://sourceforge.net/projects/evocms/}.
   7   *
   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
   9   *
  10   * {@internal License choice
  11   * - If you have received this file as part of a package, please find the license.txt file in
  12   *   the same folder or the closest folder above for complete license terms.
  13   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  14   *   then you must choose one of the following licenses before using the file:
  15   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  16   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  17   * }}
  18   *
  19   * {@internal Open Source relicensing agreement:
  20   * }}
  21   *
  22   * @package admin
  23   *
  24   * @version $Id: _cronjob_list.view.php 6136 2014-03-08 07:59:48Z manuel $
  25   */
  26  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  27  
  28  
  29  // Get filters:
  30  global $ctst_pending, $ctst_started, $ctst_timeout, $ctst_error, $ctst_finished;
  31  if( !$ctst_pending && !$ctst_started && !$ctst_timeout && !$ctst_error && !$ctst_finished )
  32  {    // Set default status filters:
  33      $ctst_pending = 1;
  34      $ctst_started = 1;
  35      $ctst_timeout = 1;
  36      $ctst_error = 1;
  37  }
  38  
  39  /*
  40   * Create result set :
  41   */
  42  $SQL = new SQL();
  43  $SQL->SELECT( 'ctsk_ID, ctsk_start_datetime, ctsk_name, ctsk_controller, ctsk_repeat_after, IFNULL( clog_status, "pending" ) as status' );
  44  $SQL->FROM( 'T_cron__task LEFT JOIN T_cron__log ON ctsk_ID = clog_ctsk_ID' );
  45  if( $ctst_pending )
  46  {
  47      $SQL->WHERE_or( 'clog_status IS NULL' );
  48  }
  49  if( $ctst_started )
  50  {
  51      $SQL->WHERE_or( 'clog_status = "started"' );
  52  }
  53  if( $ctst_timeout )
  54  {
  55      $SQL->WHERE_or( 'clog_status = "timeout"' );
  56  }
  57  if( $ctst_error )
  58  {
  59      $SQL->WHERE_or( 'clog_status = "error"' );
  60  }
  61  if( $ctst_finished )
  62  {
  63      $SQL->WHERE_or( 'clog_status = "finished"' );
  64  }
  65  $SQL->ORDER_BY( '*, ctsk_ID' );
  66  
  67  $Results = new Results( $SQL->get(), 'crontab_', '-D' );
  68  
  69  $Results->title = T_('Scheduled jobs').get_manual_link('scheduler');
  70  
  71  
  72  $Results->global_icon( T_('Refresh'), 'refresh', regenerate_url(), T_('Refresh'), 3, 4 );
  73  if( $current_User->check_perm( 'options', 'edit', false, NULL ) )
  74  {    // Permission to edit settings:
  75      $Results->global_icon( T_('Create a new scheduled job...'), 'new', regenerate_url( 'action,cjob_ID', 'action=new' ), T_('New job').' &raquo;', 3, 4 );
  76  }
  77  
  78  /**
  79   * Callback to add filters on top of the result set
  80   *
  81   * @param Form
  82   */
  83  function filter_crontab( & $Form )
  84  {
  85      global $ctst_pending, $ctst_started, $ctst_timeout, $ctst_error, $ctst_finished;
  86  
  87      $Form->checkbox( 'ctst_pending', $ctst_pending, T_('Pending') );
  88      $Form->checkbox( 'ctst_started', $ctst_started, T_('Started') );
  89      $Form->checkbox( 'ctst_timeout', $ctst_timeout, T_('Timed out') );
  90      $Form->checkbox( 'ctst_error', $ctst_error, T_('Error') );
  91      $Form->checkbox( 'ctst_finished', $ctst_finished, T_('Finished') );
  92  }
  93  $Results->filter_area = array(
  94      'callback' => 'filter_crontab',
  95      'url_ignore' => 'results_crontab_page,ctst_pending,ctst_started,ctst_timeout,ctst_error,ctst_finished',    // ignor epage param and checkboxes
  96      'presets' => array(
  97              'schedule' => array( T_('Schedule'), '?ctrl=crontab&amp;ctst_pending=1&amp;ctst_started=1&amp;ctst_timeout=1&amp;ctst_error=1' ),
  98              'attention' => array( T_('Attention'), '?ctrl=crontab&amp;ctst_timeout=1&amp;ctst_error=1' ),
  99              'all' => array( T_('All'), '?ctrl=crontab&amp;ctst_pending=1&amp;ctst_started=1&amp;ctst_timeout=1&amp;ctst_error=1&amp;ctst_finished=1' ),
 100          )
 101      );
 102  
 103  
 104  $Results->cols[] = array(
 105                          'th' => T_('ID'),
 106                          'order' => 'ctsk_ID',
 107                          'th_class' => 'shrinkwrap',
 108                          'td_class' => 'shrinkwrap',
 109                          'td' => '$ctsk_ID$'
 110                      );
 111  
 112  $Results->cols[] = array(
 113                          'th' => T_('Planned at'),
 114                          'order' => 'ctsk_start_datetime',
 115                          'td_class' => 'shrinkwrap',
 116                          'td' => '$ctsk_start_datetime$',
 117                      );
 118  
 119  $Results->cols[] = array(
 120                          'th' => T_('Name'),
 121                          'order' => 'ctsk_name',
 122                          'td' => '<a href="%regenerate_url(\'action,cjob_ID\',\'action=view&amp;cjob_ID=$ctsk_ID$\')%">$ctsk_name$</a>%cron_job_manual_link( #ctsk_controller# )%',
 123                      );
 124  
 125  $Results->cols[] = array(
 126                          'th' => T_('Status'),
 127                          'order' => 'status',
 128                          'td_class' => 'shrinkwrap cron_$status$',
 129                          'td' => '$status$',
 130                          'extra' => array ( 'style' => 'background-color: %cron_status_color( "#status#" )%;', 'format_to_output' => false )
 131                      );
 132  
 133  $Results->cols[] = array(
 134                          'th' => T_('Repeat'),
 135                          'order' => 'ctsk_repeat_after',
 136                          'td_class' => 'shrinkwrap',
 137                          'td' => '%seconds_to_period( #ctsk_repeat_after# )%',
 138                      );
 139  
 140  function crontab_actions( $ctsk_ID, $status )
 141  {
 142      global $current_User, $admin_url;
 143  
 144      $col = '';
 145  
 146      if( $current_User->check_perm( 'options', 'edit', false, NULL ) )
 147      {    // User can edit options:
 148          if( $status == 'pending' )
 149          {    // Icon for edit action
 150              $col .= action_icon( T_('Edit this job'), 'edit', $admin_url.'?ctrl=crontab&amp;action=edit&amp;ctsk_ID='.$ctsk_ID );
 151          }
 152          elseif( $status == 'error' )
 153          {    // Icon for copy action
 154              $col .= action_icon( T_('Duplicate this job'), 'copy', $admin_url.'?ctrl=crontab&amp;action=copy&amp;ctsk_ID='.$ctsk_ID );
 155          }
 156  
 157          if( $status != 'started' )
 158          {    // Icon for delete action
 159              $col .= action_icon( T_('Delete this job!'), 'delete',
 160                                                      regenerate_url( 'action', 'ctsk_ID='.$ctsk_ID.'&amp;action=delete&amp;'.url_crumb('crontask') ) );
 161          }
 162      }
 163  
 164      return $col;
 165  }
 166  $Results->cols[] = array(
 167                      'th' => T_('Actions'),
 168                      'td_class' => 'shrinkwrap',
 169                      'td' => '%crontab_actions( #ctsk_ID#, #status# )%',
 170                  );
 171  
 172  
 173  
 174  // Display results :
 175  $Results->display();
 176  
 177  
 178  global $cron_url;
 179  echo '<p>[<a href="'.$cron_url.'cron_exec.php" onclick="return pop_up_window( \''.$cron_url.'cron_exec.php\', \'evo_cron\' )" target="evo_cron">'.T_('Execute pending jobs in a popup window now!').'</a>]</p>';
 180  
 181  ?>

title

Description

title

Description

title

Description

title

title

Body