16 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
17 require_once SQ_CORE_PACKAGE_PATH.
'/system/triggers/trigger_action/trigger_action.inc';
18 require_once SQ_SYSTEM_ROOT.
'/core/attributes/parameter_map/parameter_map.inc';
19 require_once SQ_FUDGE_PATH.
'/general/www.inc';
53 public static function execute($settings, &$state)
56 if (!isset($settings[
'emails']))
return FALSE;
58 $parameter_map_value = array_get_index($settings,
'parameter_map_target_asset', serialize(Array()));
60 $map_assetid = $attr_parameter_map->getParameterValue(
'asset');
61 $map_emails = $attr_parameter_map->getParameterValue(
'emails');
62 $map_link_assetid = $attr_parameter_map->getParameterValue(
'link_asset');
64 if (empty($settings[
'assetid']) && empty($map_assetid)) {
68 if (empty($settings[
'emails']) && empty($map_emails)) {
72 if (!$GLOBALS[
'SQ_SYSTEM']->am->assetExists($settings[
'assetid'])) {
76 if (!is_null($map_assetid) && !$GLOBALS[
'SQ_SYSTEM']->am->assetExists($map_assetid)) {
81 $assetid = is_null($map_assetid) ? $settings[
'assetid'] : $map_assetid;
82 $emails = is_null($map_emails) ? $settings[
'emails'] : $map_emails;
83 $link_assetid = is_null($map_link_assetid) ? $settings[
'link_assetid'] : $map_link_assetid;
86 $emails = explode(
",",$emails);
87 foreach ($emails as $key => $value) {
88 if (!valid_email(trim($value))) unset($emails[$key]);
92 if (empty($emails))
return FALSE;
95 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
96 if (!empty($link_assetid)) {
98 'root_nodes' => Array($assetid),
99 'email_list' => $emails,
100 'link_asset' => Array(
101 'assetid' => $link_assetid,
102 'link_type' => $settings[
'link_type'],
105 $link_errors = $hh->freestyleHipo(
'hipo_job_tool_delete_bmail_users', $vars, SQ_PACKAGES_PATH.
'/bulkmail/hipo_jobs');
106 if (!empty($link_errors))
return FALSE;
109 'root_nodes' => Array($assetid),
110 'email_list' => $emails,
112 $delete_errors = $hh->freestyleHipo(
'hipo_job_tool_delete_bmail_users', $vars, SQ_PACKAGES_PATH.
'/bulkmail/hipo_jobs');
113 if (!empty($delete_errors))
return FALSE;
130 public static function getInterface($settings, $prefix, $write_access=FALSE)
133 $selected_assetid = array_get_index($settings,
'assetid', 0);
134 $emails = array_get_index($settings,
'emails',
'');
135 $selected_link_assetid = array_get_index($settings,
'link_assetid', 0);
136 $selected_link_type = array_get_index($settings,
'link_type', SQ_LINK_TYPE_1);
138 if (!$write_access) {
139 $form_element_extras =
'disabled="disabled"';
141 $form_element_extras =
'';
146 asset_finder($prefix.
'[assetid]', $selected_assetid);
148 if ($selected_assetid) {
149 $selected_assetname = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($selected_assetid), Array(), TRUE,
'name');
150 text_box($prefix.
'[assetid]', $selected_assetname[$selected_assetid].
' (#'.$selected_assetid.
')',
'',
'', FALSE, $form_element_extras);
152 text_box($prefix.
'[assetid]',
'',
'',
'', FALSE, $form_element_extras);
155 $basic_part_1 = ob_get_contents();
159 text_box($prefix.
'[emails]', $emails, 100,
'',
'', $form_element_extras);
160 $basic_part_2 = ob_get_contents();
165 asset_finder($prefix.
'[link_assetid]', $selected_link_assetid);
167 if ($selected_link_assetid) {
168 $selected_assetname = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($selected_link_assetid), Array(), TRUE,
'name');
169 text_box($prefix.
'[link_assetid]', $selected_assetname[$selected_link_assetid].
' (#'.$selected_link_assetid.
')',
'',
'', FALSE, $form_element_extras);
171 text_box($prefix.
'[link_assetid]',
'',
'',
'', FALSE, $form_element_extras);
174 $basic_part_3 = ob_get_contents();
177 $link_type_list = get_link_type_names();
180 combo_box($prefix.
'[link_type]', $link_type_list, FALSE, $selected_link_type, NULL, $form_element_extras);
181 $basic_part_4 = ob_get_contents();
185 $new_prefix = str_replace(array(
'[',
']'),
'_', $prefix);
186 hidden_field($prefix.
'[new_prefix]', $new_prefix);
190 $parameter_map_value = array_get_index($settings,
'parameter_map_target_asset', serialize(Array()));
192 $attr_parameter_map->setParameter(
'asset',
'Root node');
193 $attr_parameter_map->setParameter(
'emails',
'Emails');
194 $attr_parameter_map->setParameter(
'link_asset',
'Link under node');
195 echo $attr_parameter_map->paint($new_prefix.
'_parameter_map', !$write_access);
196 $basic_part_5 = ob_get_contents();
199 $contents = translate(
'trigger_delete_bmail_user_asset', $basic_part_1).
'<br />'.translate(
'trigger_delete_bmail_user_email', $basic_part_2).
200 '<br />'.translate(
'trigger_delete_bmail_user_link', $basic_part_3, $basic_part_4).
'<br />'.$basic_part_5;
221 if (empty($request_data[
'assetid'][
'assetid'])) {
222 return 'Asset ID not specified';
225 $new_prefix = str_replace(array(
'[',
']'),
'_', array_get_index($request_data,
'new_prefix',
''));
227 $attr_parameter_map->process($new_prefix.
'_parameter_map');
228 $settings[
'parameter_map_target_asset'] = $attr_parameter_map->value;
230 $settings[
'assetid'] = $request_data[
'assetid'][
'assetid'];
231 $settings[
'emails'] = array_get_index($request_data,
'emails',
'');
232 $settings[
'link_assetid'] = array_get_index($request_data[
'link_assetid'],
'assetid',
'');
233 $settings[
'link_type'] = array_get_index($request_data,
'link_type', SQ_LINK_TYPE_1);
249 public static function getLocks($settings, &$state)
251 return Array($state[
'assetid'] => Array(
'lookups'));