Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
cron_job_send_submission_log_edit_fns.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/system/cron/cron_job/cron_job_edit_fns.inc';
19 
32 {
33 
34 
40  function __construct()
41  {
42  parent::__construct();
43 
44  }//end constructor
45 
46 
57  function paintScheduleInterface(&$asset, &$o, $prefix)
58  {
59  // Null asset means, we are painting the interface to create a new asset
60  if (!is_null($asset)) {
61  echo $asset->readableWhen();
62  }
63 
64  if (is_null($asset) || $asset->writeAccess('attributes')) {
65  $cron_mgr = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('cron_manager');
66 
67  // paint the start time using a one off job's edit fns
68  $cron_job = new Cron_Job();
69  $edit_fns = $cron_job->getEditFns();
70  echo '<br />';
71  echo '<br />'.translate('cron_job_send_submission_log_at').' ';
72  $edit_fns->_paintWhenBox($cron_job, $o, $prefix, is_null($asset) ? '' : $asset->attr('first_run'));
73 
74  // paint the repeat frequency using repeating time interval job's edit fns
75  $cron_job_repeat = new Cron_Job();
76  $cron_job_repeat->setAttrValue('type', 'repeating');
77  echo '<br />'.translate('cron_job_regenerate_report_repeat');
78  $this->_paintWhenBox($cron_job_repeat, $o, $prefix, is_null($asset) ? '' : $asset->attr('when'));
79 
80  require_once SQ_FUDGE_PATH.'/general/datetime.inc';
81  echo '<br/>';
82  echo translate('cron_manager_next_run', $cron_mgr->readableRefreshTime(), readable_datetime($cron_mgr->timeOfNextRun()));
83  }
84 
85  return TRUE;
86 
87  }// paintScheduleInterface()
88 
89 
100  function processScheduleInterface(&$asset, &$o, $prefix)
101  {
102  $cron_job = new Cron_Job();
103  $edit_fns = $cron_job->getEditFns();
104 
105  $when_oo = $edit_fns->_processWhenBox($cron_job, $o, $prefix);
106 
107  if (!$when_oo) {
108  trigger_localised_error('CMS0122', E_USER_WARNING);
109  return FALSE;
110  }
111 
112  if ($_REQUEST[$prefix.'_when_interval_mins'] == '--'
113  && $_REQUEST[$prefix.'_when_interval_hours'] == '--'
114  && $_REQUEST[$prefix.'_when_interval_days'] == '-') {
115 
116  trigger_localised_error('CMS0119', E_USER_WARNING);
117 
118  return FALSE;
119  } else {
120  // repeat frequency is set, but start time not specified, error
121  if (!$when_oo) {
122  trigger_localised_error('CRON0050', E_USER_WARNING, $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($asset->type(), 'name'));
123  return FALSE;
124  }
125 
126  // work out the period/duration start time (one off job code reuse)
127  // mute warning as we are only using this bit to working out the start time
128  if (!@$cron_job->setAttrValue('when', $when_oo)) {
129  $cron_mgr = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('cron_manager');
130  trigger_localised_error('CRON0048', E_USER_WARNING, $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($asset->type(), 'name'), easy_datetime($cron_mgr->timeOfNextRun()));
131  return FALSE;
132  }
133  $when_oo_str = $cron_job->attr('when');
134  // Save job's first run time set by the user
135  // NOTE: First run time is not necessarily the time for job's very first run
136  $asset->setAttrValue('first_run', $when_oo_str);
137 
138  // This is actual first run time
139  $start_time = $cron_job->getNextRun($when_oo_str);
140 
141  // Ass
142 
143  // update the start time of this repeating time interval job
144  $cron_job_repeat = new Cron_Job();
145  $cron_job_repeat->setAttrValue('type', 'repeating');
146  $when_ti = $this->_processWhenBox($cron_job_repeat, $o, $prefix);
147  $when_ti_arr = explode(',', $when_ti);
148  $when_ti_arr[0] = 'TI='.$start_time;
149  $when_ti_str = implode(',', $when_ti_arr);
150  $asset->setAttrValue('when', $when_ti_str);
151 
152  return TRUE;
153  }
154 
155  return FALSE;
156 
157  }// processScheduleInterface()
158 
159 
160 }//end Cron_Job_Send_Submission_Log_Edit_Fns()
161 
162 ?>