18 require_once SQ_CORE_PACKAGE_PATH.
'/system/cron/cron_job/cron_job.inc';
43 $this->_ser_attrs = TRUE;
44 parent::__construct($assetid);
59 if (!parent::_createAdditional($link))
return FALSE;
61 if (!empty($this->_tmp[
'asset_in_link'])) {
62 if (!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($this->id,
'links')) {
63 trigger_localised_error(
'CRON0059', E_USER_WARNING);
67 $link = $this->_tmp[
'asset_in_link'];
68 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
70 trigger_localised_error(
'CRON0060', E_USER_WARNING);
74 unset($this->_tmp[
'asset_in_link']);
75 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($this->
id,
'links');
94 if (is_null($asset)) {
95 return translate(
'cron_job_asset_less_future_permission');
96 }
else if ($short_name) {
97 return translate(
'cron_fp_for', translate(
'asset_format', $asset->short_name, $asset->id));
99 return translate(
'cron_future_permission_for', translate(
'asset_format', $asset->name, $asset->id));
114 $links = parent::_getAllowedLinks();
117 if (empty($links[SQ_LINK_NOTICE][
'asset'])) {
118 $links[SQ_LINK_NOTICE][
'asset'] = Array(
'card' => 1);
137 if (parent::canDelete())
return TRUE;
140 if ($this->
attr(
'read_only'))
return FALSE;
143 if (!is_null($asset))
return $asset->adminAccess(
'');
162 $value = (int) $value;
164 trigger_localised_error(
'CRON0061', E_USER_NOTICE);
170 trigger_localised_error(
'CRON0062', E_USER_NOTICE);
175 return parent::setAttrValue($name, $value);
190 return Array(
'read' => SQ_PERMISSION_READ,
'write' => SQ_PERMISSION_WRITE,
'admin' => SQ_PERMISSION_ADMIN);
206 static $descs = Array();
209 $permissions = self::_getAllPermissions();
210 foreach ($permissions as $name => $value) {
211 $descs[$value] = ucfirst($name);
228 $descs = self::getAllPermissionDescs();
229 return $descs[$this->
attr(
'permission')];
244 $grant_int = $grant? 1 : 0;
245 $userid_grant_list = $this->
attr(
'userids');
247 foreach ($userid_grant_list as $userid => $user_grant) {
248 if ($user_grant == $grant_int) {
249 $userids[] = $userid;
265 return ($this->
attr(
'add')? translate(
'add') : translate(
'remove'));
280 $existing_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_NOTICE,
'', TRUE,
'major', $value=
'updating');
281 $link_exists = FALSE;
282 foreach ($existing_links as $old_link) {
283 if ($old_link[
'minorid'] == $asset->id) {
286 $GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($old_link[
'linkid']);
292 return (
bool) $this->
createLink($asset, SQ_LINK_NOTICE,
'updating');
295 if (!isset($this->_tmp[
'asset_in_link'])) {
296 $this->_tmp[
'asset_in_link'] = Array();
298 $this->_tmp[
'asset_in_link'] = Array(
'minorid' => $asset->id,
'minor_type_code' => $asset->
type());
317 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, SQ_LINK_NOTICE,
'asset', FALSE,
'updating');
319 $link = (isset($this->_tmp[
'asset_in_link'])) ? $this->_tmp[
'asset_in_link'] : Array();
321 if (empty($link))
return $null;
323 return $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
342 if (!is_null($asset)) {
343 $add_permissions = $this->
attr(
'add');
344 $permission = $this->
attr(
'permission');
345 $userid_grant_list = $this->
attr(
'userids');
346 $cascade_to_new = $this->
attr(
'cascade_to_new');
347 $previous_access = NULL;
348 $dependants_only = $this->
attr(
'dependants_only');
349 $permission_vars = Array();
350 foreach ($userid_grant_list as $userid => $user_grant) {
351 $granted = $add_permissions? $user_grant : -1;
352 if (!$add_permissions) {
353 $previous_access = $user_grant;
355 $permission_vars[] = Array(
356 'permission' => $permission,
357 'assetids' => Array($asset->id),
358 'granted' => $granted,
360 'cascades' => $cascade_to_new,
361 'previous_access' => $previous_access,
362 'dependants_only' => !(!$dependants_only && $cascade_to_new),
366 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
368 'permission_changes' => $permission_vars,
370 $errors = $hh->freestyleHipo(
'hipo_job_edit_permissions', $vars);
371 if (empty($errors)) {
373 return SQ_CRON_JOB_COMPLETED | SQ_CRON_JOB_REMOVE;
376 trigger_localised_error(
'CRON0063', E_USER_WARNING, $asset->name, $asset->id);
381 trigger_localised_error(
'CRON0064', E_USER_WARNING);
385 return SQ_CRON_JOB_ERROR | SQ_CRON_JOB_REMOVE;
402 $links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE,
'cron_job_future_permission', TRUE,
'minor',
'updating');
404 foreach ($links as $link) {
405 $assetids[] = $link[
'majorid'];
411 foreach ($assetids as $assetid) {
412 $fp_jobs[] = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid,
'cron_job_future_permission');