17 require_once SQ_INCLUDE_PATH.
'/asset_edit/asset_edit_fns.inc';
45 $this->static_screens = Array();
48 $this->static_screens[
'details'][
'name'] = translate(
'details');
49 $this->static_screens[
'details'][
'force_unlock'] = FALSE;
68 $write_access = $tm->writeAccess(
'attributes');
72 $o->sectionNote(translate(
'trigger_subscreen_add_or_edit'));
97 return $tm->writeAccess(
'attributes');
116 $list = $tm->_getTriggerInfoList();
118 $o->openSection(translate(
'trigger_list'));
121 <script type=
"text/javascript">
123 var deleteCheckedCount = 0;
125 function confirmDelete()
129 if (deleteCheckedCount > 0) {
130 result = confirm (js_translate(
'confirm_delete_trigger', deleteCheckedCount));
136 function checkDelete(checked)
139 deleteCheckedCount++;
141 deleteCheckedCount--;
146 <table
class=
"sq-backend-table">
148 <td width=
"50" class=
"sq-backend-table-header" style=
"font-weight: bold;"><?php echo translate(
'id'); ?></td>
149 <td
class=
"sq-backend-table-header" style=
"font-weight: bold;"><?php echo translate(
'name'); ?></td>
150 <td
class=
"sq-backend-table-header" style=
"font-weight: bold;"><?php echo translate(
'description'); ?></td>
151 <td width=
"50" class=
"sq-backend-table-header" style=
"font-weight: bold;"><?php echo translate(
'status'); ?></td>
156 foreach ($list as $trigger) {
157 $trigger_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset(implode(
':', Array($tm->id, $trigger[
'id'])));
158 if (is_null($trigger_asset))
continue;
160 $trigger_url = $trigger_asset->getBackendHref(
'details');
161 $active_text = $trigger[
'active'] ?
'<strong>'.translate(
'active').
'</strong>' :
'<span style="color: red">'.translate(
'inactive').
'</span>';
164 <td
class=
"sq-backend-table-cell"><?php echo $trigger[
'id']; ?></td>
165 <td
class=
"sq-backend-table-cell"><a href=
"<?php echo $trigger_url; ?>"><?php echo $trigger[
'name']; ?></a></td>
166 <td
class=
"sq-backend-table-cell"><?php echo $trigger[
'description']; ?></td>
167 <td
class=
"sq-backend-table-cell"><strong><?php echo $active_text; ?></strong></td>
176 $o->addOnsubmit(
'return confirmDelete();');
195 $write_access = $tm->writeAccess(
'attributes');
197 $o->openField(translate(
'trigger_ids'));
198 multiple_asset_finder($prefix.
'[trigger_ids]', array_get_index($this->_tmp,
'trigger_ids', Array()), Array(
'trigger' =>
'I'));
199 $o->note(translate(
'trigger_ids_note'));
201 $o->openField(translate(
'target_node'));
202 asset_finder($prefix.
'[target_node]', array_get_index($this->_tmp,
'target_id'));
204 $o->openField(translate(
'children'));
205 check_box($prefix.
'[include_children]',
'yes', array_get_index($this->_tmp,
'include_children', TRUE));
206 label(translate(
'include_children_question'), $prefix.
'[include_children]');
208 $o->openField(translate(
'events'));
209 $event_type_list = $tm->_getEventList();
210 $events = array_get_index($this->_tmp,
'selected_events');
212 $event_prefix = $prefix.
'[selected_events]';
213 foreach ($event_type_list as $e_type => $e_name) {
214 if (isset($events[$e_type])) {
219 check_box($event_prefix.
'['.$e_type.
']', $e_type, $checked);
220 label($e_name, $event_prefix.
'['.$e_type.
']');
247 $request_data = array_get_index($_REQUEST, $prefix, Array());
249 $target_node = array_get_index($request_data,
'target_node');
250 $target_id = array_get_index($target_node,
'assetid');
252 $triggers = array_get_index($request_data,
'trigger_ids');
253 $trigger_ids = Array();
254 foreach ($triggers as $trigger_id) {
255 if ($trigger_id[
'assetid']) {
256 $trigger_ids[] = substr($trigger_id[
'assetid'], strpos($trigger_id[
'assetid'],
':') + 1);
260 $events = array_get_index($request_data,
'selected_events', Array());
261 $propagate = isset($request_data[
'include_children']);
263 $this->_tmp[
'target_id'] = $target_id;
264 $this->_tmp[
'trigger_ids'] = $trigger_ids;
265 $this->_tmp[
'selected_events'] = $events;
266 $this->_tmp[
'include_children'] = $propagate;
268 if (empty($target_id)) {
269 trigger_localised_error(
'CORE0132', E_USER_WARNING);
273 if (empty($events)) {
274 trigger_localised_error(
'CORE0126', E_USER_WARNING);
278 if ($error)
return FALSE;
281 $all_targets = Array();
283 $all_targets = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($target_id);
285 $target_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($target_id);
286 $all_targets[$target_id] = $target_asset->type();
289 $all_targets = array_keys($all_targets);
292 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
294 'assets' => $all_targets,
296 'event_parameters' => Array(
'specified_trigger_ids' => $trigger_ids),
297 'codename_target' => $target_id,
298 'codename_propagate' => ($propagate ?
'1' :
'0'),
300 $hh->queueHipo(
'hipo_job_trigger_batch_events', $vars);