17 require_once SQ_CORE_PACKAGE_PATH.
'/system/triggers/trigger_action/trigger_action.inc';
18 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
19 require_once SQ_ATTRIBUTES_PATH.
'/parameter_map/parameter_map.inc';
54 public static function execute($settings, &$state)
56 if (empty($state[
'asset'])) {
58 if (empty($state[
'assetid'])) {
62 $state[
'asset'] = &$GLOBALS[
'SQ_SYSTEM']->am->getAsset($state[
'assetid']);
66 if (isset($settings[
'imageid']) && !empty($settings[
'imageid'])) {
67 $thumbnail = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($settings[
'imageid']);
69 $parameter_map_value = array_get_index($settings,
'thumbnail', serialize(Array()));
71 $assetid = $atr_parameter_map->getParameterValue(
'thumbnail');
72 if (!empty($assetid)) {
73 $thumbnail = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
81 if (!is_a($thumbnail,
'image'))
return TRUE;
85 $grab_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($state[
'assetid'], SQ_LINK_NOTICE,
'', FALSE,
'thumbnail');
87 if (is_array($grab_link) && isset($grab_link[
'linkid'])) {
88 $GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($grab_link[
'linkid']);
92 $tmblink = $GLOBALS[
'SQ_SYSTEM']->am->createAssetLink($state[
'asset'], $thumbnail, SQ_LINK_NOTICE,
'thumbnail');
111 public static function getInterface($settings, $prefix, $write_access=FALSE)
114 $settings[
'thumbnail'] = array_get_index($settings,
'thumbnail', Array());
117 $pmap->setParameter(
'thumbnail',
'Set new Thumbnail');
118 $pmap->setValue($settings[
'thumbnail']);
123 $new_prefix = str_replace(array(
'[',
']'),
'_', $prefix);
124 hidden_field($prefix.
'[new_prefix]', $new_prefix);
126 echo $pmap->paint($new_prefix, !$write_access);
127 $basic_part_1 = ob_get_contents();
130 return translate(
'trigger_set_thumbnail', $basic_part_1);
148 if (empty($request_data)) {
149 return translate(
'trigger_input_data_missing');
153 $new_prefix = str_replace(array(
'[',
']'),
'_', array_get_index($request_data,
'new_prefix',
''));
157 $pmap->process($new_prefix);
158 $settings[
'thumbnail'] = $pmap->value;
174 public static function getLocks($settings, &$state)
176 return Array($state[
'assetid'] => Array(
'all'));