phpDocumentor pond
[ class tree: pond ] [ index: pond ] [ all elements ]

Source for file _cronjob_list.view.php

Documentation is available at _cronjob_list.view.php

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