Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
cron_job_regenerate_report_edit_fns.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/system/cron/cron_job/cron_job_edit_fns.inc';
19 
38 {
39 
40 
46  function __construct()
47  {
48  parent::__construct();
49 
50  }//end constructor
51 
52 
64  {
65  if ($asset->writeAccess('')) {
66  // paint the start time using a one off job's edit fns
67  $cron_job = new Cron_Job();
68  $edit_fns = $cron_job->getEditFns();
69  echo translate('cron_job_regenerate_report_at');
70  $edit_fns->_paintWhenBox($cron_job, $o, $prefix);
71 
72  // paint the repeat frequency using repeating time interval job's edit fns
73  echo '<br />'.translate('cron_job_regenerate_report_repeat');
74  $this->_paintWhenBox($asset, $o, $prefix);
75  }
76 
77  return TRUE;
78 
79  }//end paintInLineBackend()
80 
81 
93  {
94  $cron_job = new Cron_Job();
95  $edit_fns = $cron_job->getEditFns();
96 
97  $when_oo = $edit_fns->_processWhenBox($cron_job, $o, $prefix);
98  if (!$when_oo) {
99  // nothing has been set, do not add a job
100  return FALSE;
101  }
102 
103  if ( $_REQUEST[$prefix.'_when_interval_mins'] == '--'
104  && $_REQUEST[$prefix.'_when_interval_hours'] == '--'
105  && $_REQUEST[$prefix.'_when_interval_days'] == '-') {
106 
107  // if repeat frequency is not set, this is a one off job
108  $asset->setAttrValue('type', 'one_off');
109  if (!$asset->setAttrValue('when', $when_oo)) {
110  return FALSE;
111  }
112  return TRUE;
113  } else {
114 
115  // repeat frequency is set, but start time not specified, error
116  if (!$when_oo) {
117  trigger_localised_error('CRON0050', E_USER_WARNING, $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($asset->type(), 'name'));
118  return FALSE;
119  }
120 
121  // work out the period/duration start time (one off job code reuse)
122  // mute warning as we are only using this bit to working out the start time
123  if (!@$cron_job->setAttrValue('when', $when_oo)) {
124  $cron_mgr = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('cron_manager');
125  trigger_localised_error('CRON0048', E_USER_WARNING, $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($asset->type(), 'name'), easy_datetime($cron_mgr->timeOfNextRun()));
126  return FALSE;
127  }
128  $when_oo_str = $cron_job->attr('when');
129  $start_time = $cron_job->getNextRun($when_oo_str);
130 
131  // update the start time of this repeating time interval job
132  $when_ti = $this->_processWhenBox($asset, $o, $prefix);
133  $when_ti_arr = explode(',', $when_ti);
134  $when_ti_arr[0] = 'TI='.$start_time;
135  $when_ti_str = implode(',', $when_ti_arr);
136  $asset->setAttrValue('when', $when_ti_str);
137  $asset->setAttrValue('long', TRUE);
138 
139  return TRUE;
140  }
141  return FALSE;
142 
143  }//end processInLineBackend()
144 
145 
146 }//end class
147 
148 ?>