18 require_once SQ_CORE_PACKAGE_PATH.
'/system/cron/cron_job/cron_job.inc';
43 parent::__construct($assetid);
58 if (!parent::_createAdditional($link))
return FALSE;
60 if (!empty($this->_tmp[
'asset_in_link'])) {
61 if (!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($this->id,
'links')) {
62 trigger_localised_error(
'CRON0018', E_USER_WARNING);
66 $link = $this->_tmp[
'asset_in_link'];
67 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
69 trigger_localised_error(
'CRON0017', E_USER_WARNING);
73 unset($this->_tmp[
'asset_in_link']);
74 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($this->
id,
'links');
93 if (is_null($asset)) {
94 return translate(
'cron_job_asset_less_future_status');
95 }
else if ($short_name) {
96 return translate(
'cron_fs_for', translate(
'asset_format', $asset->short_name, $asset->id));
98 return translate(
'cron_future_status_for', translate(
'asset_format', $asset->name, $asset->id));
113 $links = parent::_getAllowedLinks();
116 if (empty($links[SQ_LINK_NOTICE][
'asset'])) {
117 $links[SQ_LINK_NOTICE][
'asset'] = Array(
'card' => 1);
136 if (parent::canDelete())
return TRUE;
139 if ($this->
attr(
'read_only'))
return FALSE;
142 if (!is_null($asset))
return $asset->adminAccess(
'');
161 $value = (int) $value;
163 trigger_localised_error(
'CRON0031', E_USER_NOTICE);
169 trigger_localised_error(
'CRON0038', E_USER_NOTICE);
174 return parent::setAttrValue($name, $value);
190 SQ_STATUS_ARCHIVED =>
'ARCHIVED',
191 SQ_STATUS_UNDER_CONSTRUCTION =>
'UNDER_CONSTRUCTION',
192 SQ_STATUS_LIVE =>
'LIVE',
193 SQ_STATUS_EDITING =>
'EDITING',
194 SQ_STATUS_LIVE_APPROVAL =>
'LIVE_APPROVAL',
211 static $descs = Array();
214 $descs[
''] =
'[Select Status]';
215 $statii = self::_getAllStatii();
216 foreach ($statii as $value => $code) {
217 $code = strtolower($code);
218 $status_code =
'asset_status_'.$code;
219 require_once SQ_INCLUDE_PATH.
'/asset_status/'.$status_code.
'.inc';
220 eval(
'$descs[$value] = '.$status_code.
'::getDescription();');
237 if (!$this->
attr(
'status'))
return '[ No Status Set ]';
238 $statii = self::_getAllStatii();
239 $code = strtolower($statii[$this->
attr(
'status')]);
240 $status_code =
'asset_status_'.$code;
241 require_once SQ_INCLUDE_PATH.
'/asset_status/'.$status_code.
'.inc';
242 eval(
'$desc = '.$status_code.
'::getDescription();');
259 $existing_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_NOTICE,
'', TRUE,
'major', $value=
'updating');
260 $link_exists = FALSE;
261 foreach ($existing_links as $old_link) {
262 if ($old_link[
'minorid'] == $asset->id) {
265 $GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($old_link[
'linkid']);
271 return (
bool) $this->
createLink($asset, SQ_LINK_NOTICE,
'updating');
274 if (!isset($this->_tmp[
'asset_in_link'])) {
275 $this->_tmp[
'asset_in_link'] = Array();
277 $this->_tmp[
'asset_in_link'] = Array(
'minorid' => $asset->id,
'minor_type_code' => $asset->
type());
296 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, SQ_LINK_NOTICE,
'asset', FALSE,
'updating');
298 $link = (isset($this->_tmp[
'asset_in_link'])) ? $this->_tmp[
'asset_in_link'] : Array();
300 if (empty($link))
return $null;
302 return $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
321 if (!is_null($asset)) {
323 $old_status = $asset->status;
326 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
327 $vars = Array(
'assetid' => $asset->id,
'new_status' => $this->attr(
'status'),
'dependants_only' => $this->
attr(
'dependants_only'));
329 $status_errors = $hh->freestyleHipo(
'hipo_job_edit_status', $vars);
330 if (empty($status_errors)) {
332 $msg = translate(
'cron_altered_asset_status', translate(
'asset_format', $asset->name, $asset->id), get_status_description($old_status), $this->
statusName());
333 return SQ_CRON_JOB_COMPLETED | SQ_CRON_JOB_REMOVE;
336 trigger_localised_error(
'CRON0003', E_USER_WARNING, $asset->name, $asset->id);
338 foreach ($status_errors as $error) {
340 if (is_string($error)) {
342 }
else if (is_array($error)) {
343 if (isset($error[
'time'])) $line .=
'Time : '.$error[
'time'].
'. ';
344 if (isset($error[
'message'])) $line .=
'Message : '.$error[
'message'].
'.';
346 if ($line !==
'') trigger_error($line, E_USER_WARNING);
352 trigger_localised_error(
'CRON0020', E_USER_WARNING);
356 return SQ_CRON_JOB_ERROR | SQ_CRON_JOB_REMOVE;
373 $links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE, strtolower(__CLASS__), TRUE,
'minor',
'updating');
375 $cm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'cron_manager');
376 foreach ($links as $link) {
377 $cm_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinkByAsset($cm->id, $link[
'majorid']);
378 if (!empty($cm_links)) {
380 $assetids[] = $link[
'majorid'];
383 $dates = $GLOBALS[
'SQ_SYSTEM']->am->getAttributeValuesByName(
'when',
'cron_job_future_status', $assetids);
384 asort($dates, SORT_STRING);
386 foreach ($dates as $assetid => $date) {
387 $res[] = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid, strtolower(__CLASS__));