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_assetless_attempt_safe_trash');
95 }
else if ($short_name) {
96 return translate(
'cron_safe_trash_for', translate(
'asset_format', $asset->short_name, $asset->id));
98 return translate(
'cron_attempt_safe_trash_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;
143 if (!is_null($asset))
return $asset->adminAccess(
'');
162 trigger_localised_error(
'CRON0038', E_USER_NOTICE);
167 return parent::setAttrValue($name, $value);
182 if (!($asset instanceof
Asset)) {
183 trigger_localised_error(
'CRON0030', E_USER_WARNING);
188 $existing_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_NOTICE,
'', TRUE,
'major', $value=
'updating');
189 $link_exists = FALSE;
190 foreach ($existing_links as $old_link) {
191 if ($old_link[
'minorid'] == $asset->id) {
194 $GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($old_link[
'linkid']);
200 return (
bool) $this->
createLink($asset, SQ_LINK_NOTICE,
'updating');
203 if (!isset($this->_tmp[
'asset_in_link'])) {
204 $this->_tmp[
'asset_in_link'] = Array();
206 $this->_tmp[
'asset_in_link'] = Array(
'minorid' => $asset->id,
'minor_type_code' => $asset->
type());
225 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, SQ_LINK_NOTICE,
'asset', FALSE,
'updating');
227 $link = (isset($this->_tmp[
'asset_in_link'])) ? $this->_tmp[
'asset_in_link'] : Array();
229 if (empty($link))
return $null;
231 return $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
250 if (!is_null($asset)) {
253 $safe_trash_enabled = $GLOBALS[
'SQ_SYSTEM']->getUserPrefs(
'user',
'SQ_USER_SAFE_TYPE3_TRASH');
254 $safe_trash_errors = $GLOBALS[
'SQ_SYSTEM']->am->canSafeTrashAsset($asset->id);
256 if ($safe_trash_enabled && !empty($safe_trash_errors)) {
257 $msg =
'Cannot trash '.$asset->id;
259 return SQ_CRON_JOB_COMPLETED;
261 $GLOBALS[
'SQ_SYSTEM']->am->trashAsset($asset->id);
262 $msg =
'Successfully trashed '.$asset->id;
264 return SQ_CRON_JOB_COMPLETED | SQ_CRON_JOB_REMOVE;
269 trigger_localised_error(
'CRON0020', E_USER_WARNING);
273 return SQ_CRON_JOB_ERROR | SQ_CRON_JOB_REMOVE;