17 require_once SQ_CORE_PACKAGE_PATH.
'/system/triggers/trigger_action/trigger_action.inc';
54 public static function execute($settings, &$state)
56 $am =& $GLOBALS[
'SQ_SYSTEM']->am;
57 $wfm = $GLOBALS[
'SQ_SYSTEM']->getWorkflowManager();
60 if (empty($settings[
'schemaid']))
return FALSE;
62 if (empty($state[
'asset'])) {
64 if (empty($state[
'assetid'])) {
67 $state[
'asset'] = $am->getAsset($state[
'assetid']);
71 if (is_null($state[
'asset']))
return FALSE;
73 $granted = array_get_index($settings,
'granted', TRUE);
74 $cascade_to_dependents = array_get_index($settings,
'cascade_to_dependents', FALSE);
75 $cascade = array_get_index($settings,
'cascade', FALSE);
76 $cascade_to_new = array_get_index($settings,
'cascade_to_new', TRUE);
78 $schema = $am->getAsset($settings[
'schemaid']);
79 if (is_null($schema))
return FALSE;
80 if ($schema->type() !=
'workflow_schema')
return FALSE;
82 if (!$cascade_to_dependents && !$cascade) {
83 $result = $wfm->setSchema($state[
'asset']->
id, $schema->id, $granted, $cascade_to_new);
85 $schema_vars[] = Array(
86 'assetids' => Array($state[
'asset']->
id),
87 'granted' => $granted,
88 'schemaid' => $settings[
'schemaid'],
89 'cascades' => $cascade_to_new,
90 'previous_access' => NULL,
91 'dependants_only' => $cascade_to_dependents,
94 'schema_changes' => $schema_vars,
97 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
98 $errors = $hh->freestyleHIPO(
'hipo_job_edit_workflow_schemas', $vars);
99 $result = empty($errors);
107 'assetid' => $state[
'asset']->
id,
108 'schemaid' => $settings[
'schemaid'],
109 'granted' => $granted,
110 'cascade' => $cascade,
111 'cascade_to_dependents' => $cascade_to_dependents,
112 'cascade_to_new' => $cascade_to_new,
129 public static function getInterface($settings, $prefix, $write_access=FALSE)
131 $current_schemaid = array_get_index($settings,
'schemaid', 0);
132 $granted = array_get_index($settings,
'granted', 1);
133 $cascade = array_get_index($settings,
'cascade', FALSE);
134 $cascade_to_dependents = array_get_index($settings,
'cascade_to_dependents', FALSE);
135 $cascade_to_new = array_get_index($settings,
'cascade_to_new', TRUE);
138 TRUE => translate(
'apply'),
139 FALSE => translate(
'deny'),
145 combo_box($prefix.
'[granted]', $options, FALSE, $granted);
146 $combo_box = ob_get_clean();
147 echo translate(
'trigger_schema_apply-deny_the_following_schema', $combo_box).
' ';
148 asset_finder($prefix.
'[schemaid]', $current_schemaid, Array(
'workflow_schema' =>
'I'));
150 check_box($prefix.
'[cascade]',
'1', $cascade);
151 label(translate(
'cascade_schema_changes'), $prefix.
'[cascade]');
154 check_box($prefix.
'[cascade_to_dependents]',
'1', $cascade_to_dependents);
155 label(translate(
'cascade_schema_changes_to_dependents'), $prefix.
'[cascade_to_dependents]');
158 check_box($prefix.
'[cascade_to_new]',
'1', $cascade_to_new);
159 label(translate(
'cascade_schema_changes_to_new_children'), $prefix.
'[cascade_to_new]');
161 if (!empty($current_schemaid)) {
162 $schema_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($current_schemaid));
163 echo translate(
'trigger_schema_apply-deny_the_following_schema', $options[$granted]).
' ';
164 echo
'<b>'.$schema_info[$current_schemaid][
'name'].
' (#'.$current_schemaid.
')</b>';
166 echo translate(
'trigger_schema_apply-deny_the_following_schema', $options[$granted]).
' ';
167 echo
'<b>'.translate(
'trigger_schema_no_schema_specified').
'</b>';
171 echo
'<img src="'.sq_web_path(
'lib').
'/web/images/'.($cascade ?
'tick' :
'cross').
'.gif" alt="'.($cascade ? translate(
'yes') : translate(
'no')).
'" /> ';
172 echo translate(
'cascade_schema_changes');
175 echo
'<img src="'.sq_web_path(
'lib').
'/web/images/'.($cascade_to_dependents ?
'tick' :
'cross').
'.gif" alt="'.($cascade_to_dependents ? translate(
'yes') : translate(
'no')).
'" /> ';
176 echo translate(
'cascade_schema_changes_to_dependents');
179 echo
'<img src="'.sq_web_path(
'lib').
'/web/images/'.($cascade_to_new ?
'tick' :
'cross').
'.gif" alt="'.($cascade_to_new ? translate(
'yes') : translate(
'no')).
'" /> ';
180 echo translate(
'cascade_schema_changes_to_new_children');
183 $output = ob_get_contents();
204 $schema_info = array_get_index($request_data,
'schemaid', Array(
'assetid' => 0));
205 $settings[
'schemaid'] = array_get_index($schema_info,
'assetid', 0);
206 $settings[
'granted'] = array_get_index($request_data,
'granted', TRUE);
207 $settings[
'cascade'] = array_get_index($request_data,
'cascade', FALSE);
208 if ($settings[
'cascade']) {
209 $settings[
'cascade_to_dependents'] = TRUE;
211 $settings[
'cascade_to_dependents'] = array_get_index($request_data,
'cascade_to_dependents', FALSE);
213 $settings[
'cascade_to_new'] = array_get_index($request_data,
'cascade_to_new', FALSE);
228 public static function getLocks($settings, &$state)
230 return Array($state[
'assetid'] => Array(
'workflow'));