17 require_once SQ_INCLUDE_PATH.
'/asset.inc';
58 $this->_ser_attrs = TRUE;
62 if (!empty($tmid) && !empty($id)) {
63 $this->
load($tmid, $id);
79 if (empty($tmid))
return FALSE;
81 $tm = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($tmid,
'trigger_manager');
101 if (isset($this->tmid) && !empty($this->tmid)) {
102 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($this->tmid,
'trigger_manager');
125 $trigger_info = $tm->_loadTrigger($id);
126 if (empty($trigger_info))
return FALSE;
129 $this->
id = implode(
':', Array($tmid, $id));
131 $this->name = $trigger_info[
'name'];
132 $this->short_name = $trigger_info[
'name'];
135 $this->status = $tm->status;
138 $this->vars[
'name'][
'value'] = $trigger_info[
'name'];
139 $this->vars[
'description'][
'value'] = $trigger_info[
'description'];
140 $this->vars[
'events'][
'value'] = $trigger_info[
'data'][
'events'];
141 $this->vars[
'conditions'][
'value'] = $trigger_info[
'data'][
'conditions'];
142 $this->vars[
'actions'][
'value'] = $trigger_info[
'data'][
'actions'];
143 $this->vars[
'active'][
'value'] = $trigger_info[
'active'];
144 $this->vars[
'category'][
'value'] = $trigger_info[
'category'];
145 $this->vars[
'blocking'][
'value'] = empty($trigger_info[
'data'][
'settings'][
'blocking']) ? 0 : 1;
178 if (!$save_result)
return $save_result;
182 $this_id = explode(
':', $this->
id);
184 $load_result = $this->
load($this->tmid, $id);
186 $em = $GLOBALS[
'SQ_SYSTEM']->getEventManager();
190 $em->broadcastEvent($tm,
'CreateLink', Array(
'linkid' => $this->
id));
192 return $save_result && $load_result;
209 $trigger_info = Array();
211 if (empty($this->tmid))
return FALSE;
212 $id_parts = explode(
':', $this->
id);
216 $trigger_id = array_get_index($id_parts, 1);
217 if (!is_null($trigger_id)) {
218 $trigger_info[
'id'] = $trigger_id;
222 $trigger_info[
'name'] = $this->
attr(
'name');
223 $trigger_info[
'description'] = $this->
attr(
'description');
224 $trigger_info[
'data'][
'events'] = $this->
attr(
'events');
225 $trigger_info[
'data'][
'conditions'] = $this->
attr(
'conditions');
226 $trigger_info[
'data'][
'actions'] = $this->
attr(
'actions');
227 $trigger_info[
'active'] = $this->
attr(
'active');
228 $trigger_info[
'category'] = $this->
attr(
'category');
231 if (empty($trigger_info[
'name'])) {
232 trigger_localised_error(
'TRIG0001', E_USER_NOTICE);
237 if ($this->
attr(
'blocking')) {
238 $trigger_info[
'data'][
'settings'][
'blocking'] = TRUE;
242 if (empty($trigger_info[
'data'][
'events']) || empty($trigger_info[
'data'][
'actions']) || empty($trigger_info[
'active'])) {
243 $trigger_info[
'save_hash'] = FALSE;
247 if (is_null($tm))
return FALSE;
250 if ($id = $tm->_saveTrigger($trigger_info)) {
251 $this->
id = implode(
':', Array($this->tmid, $id));
253 $em = $GLOBALS[
'SQ_SYSTEM']->getEventManager();
254 $em->broadcastEvent($this,
'AssetUpdate', Array(
'short_name'));