23 error_reporting(E_ALL);
24 if ((php_sapi_name() !=
'cli')) {
25 trigger_error(
"You can only run this script from the command line\n", E_USER_ERROR);
28 $SYSTEM_ROOT = (isset($_SERVER[
'argv'][1])) ? $_SERVER[
'argv'][1] :
'';
29 if (empty($SYSTEM_ROOT)) {
30 echo
"ERROR: You need to supply the path to the System Root as the first argument\n";
34 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.
'/core/include/init.inc')) {
35 echo
"ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
39 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
41 $root_user = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_user');
44 if (!$GLOBALS[
'SQ_SYSTEM']->setCurrentUser($root_user)) {
45 echo
"ERROR: Failed logging in as root user\n";
49 $am = $GLOBALS[
'SQ_SYSTEM']->am;
53 echo
'Upgrading Future Trigger Actions...';
56 $tm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'trigger_manager');
57 $triggers = $tm->getTriggerList();
59 foreach ($triggers as $trigger_id => $trigger) {
60 $trigger_asset = $am->getAsset($tm->id.
':'.$trigger[
'id']);
61 upgradeTrigger($trigger_asset);
77 function upgradeTrigger(
Trigger &$trigger)
79 $trigger_actions = $trigger->
attr(
'actions');
80 $trigger_modified = FALSE;
82 foreach ($trigger_actions as $key => &$trigger_action) {
83 $trigger_action_data =& $trigger_action[
'data'];
86 if ((($trigger_action[
'type'] ==
'trigger_action_set_future_permissions') ||
87 ($trigger_action[
'type'] ==
'trigger_action_set_future_status')) &&
88 (!isset($trigger_action_data[
'offset_used']))) {
93 $trigger_action_data[
'offset_used'] = FALSE;
96 if (($trigger_action_data[
'when_type'] ==
'attr_interval') || ($trigger_action_data[
'when_type'] ==
'attr_exact')) {
97 $trigger_action_data[
'when_type'] =
'by_attr_value';
98 $trigger_action_data[
'offset_used'] = ($trigger_action_data[
'when_type'] ==
'attr_interval');
102 if ($trigger_action_data[
'when_type'] ==
'explicit_interval') {
103 $trigger_action_data[
'when_type'] =
'explicit_exact';
104 $trigger_action_data[
'offset_used'] = TRUE;
108 $trigger_actions[$key] = $trigger_action;
109 $trigger_modified = TRUE;
113 if ($trigger_modified) {
115 echo
"\n- Upgrading Trigger ".$trigger->id.
'... ';
118 $GLOBALS[
'SQ_SYSTEM']->acquireLock($trigger->id,
'attributes');
123 $GLOBALS[
'SQ_SYSTEM']->releaseLock($trigger->id,
'attributes');