17 require_once SQ_INCLUDE_PATH.
'/asset_management.inc';
44 'description' =>
'The name of the trigger',
46 'description' => Array(
50 'description' =>
'A description of the trigger',
51 'parameters' => Array(
59 'description' =>
'Category of the trigger',
60 'parameters' => Array(
66 'type' =>
'serialise',
68 'description' =>
'Events when trigger will be executed',
70 'conditions' => Array(
72 'type' =>
'serialise',
74 'description' =>
'Conditions that must be met for trigger to execute',
78 'type' =>
'serialise',
80 'description' =>
'Actions that will be performed when the trigger executes',
86 'parameters' => Array(
87 'allow_empty' => FALSE,
89 'description' =>
'If this trigger is active or not',
95 'parameters' => Array(
96 'allow_empty' => FALSE,
98 'description' =>
'If this trigger will prevent further trigger execution upon error',
116 if (!parent::_upgrade($current_version))
return FALSE;
118 if (version_compare($current_version,
'0.3',
'<')) {
119 pre_echo(
'UPGRADING TRIGGER ASSETS - FROM VERSION '.$current_version);
120 $trigger_manager = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'trigger_manager');
121 $children = $trigger_manager->getTriggerList();
122 foreach ($children as $trigger_data) {
123 $trigger = $trigger_manager->getAsset($trigger_data[
'id']);
124 $conditions = $trigger->attr(
'conditions');
125 foreach ($conditions as &$condition) {
126 if (!isset($condition[
'inverse_condition'])) {
127 $condition[
'inverse_condition'] = FALSE;
130 $trigger->setAttrValue(
'conditions', $conditions);
131 $trigger->saveAttributes();
135 if (version_compare($current_version,
'0.4',
'<')) {
136 pre_echo(
'UPGRADING TRIGGER ASSETS - FROM VERSION '.$current_version);
137 $trigger_manager = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'trigger_manager');
138 $children = $trigger_manager->getTriggerList();
139 foreach ($children as $trigger_data) {
140 $trigger = $trigger_manager->getAsset($trigger_data[
'id']);
141 $actions = $trigger->attr(
'actions');
142 foreach ($actions as $index => $action) {
143 if (isset($action[
'type']) && $action[
'type'] ==
'trigger_action_set_thumbnail') {
144 $data = array_get_index($action,
'data', Array());
145 if (isset($data[
'index'])) {
146 $parameter_map = Array(
'thumbnail' => Array( Array(
'source' =>
'GLOBALS',
'index' =>
'thumbnail') ) );
147 $data[
'thumbnail'] = serialize($parameter_map);
148 unset($data[
'index']);
149 $actions[$index][
'data'] = $data;
153 $trigger->setAttrValue(
'actions', $actions);
154 $trigger->saveAttributes();