| 1 |
<?php |
<?php |
| 2 |
function workflow_workflow_ng_event_info() { |
function workflow_workflow_ng_event_info() { |
| 3 |
|
|
| 4 |
$events = array( |
$events = array( |
| 5 |
'workflow_transition_post' => array( |
'workflow_transition_post' => array( |
| 6 |
'#label' => t('Workflow has been updated'), |
'#label' => t('Workflow has been updated'), |
| 23 |
); |
); |
| 24 |
} |
} |
| 25 |
|
|
| 26 |
function workflow_ng_events_argument_workflow_state($node){ |
function workflow_ng_events_argument_workflow_state($node){ |
| 27 |
return $node; |
return $node; |
| 28 |
} |
} |
| 29 |
|
|
| 30 |
|
|
| 31 |
function workflow_workflow_ng_workflow($op, $old_state, $new_state, $node) { |
function workflow_workflow_ng_workflow($op, $old_state, $new_state, $node) { |
| 32 |
if(!module_exists('workflow_ng')) { |
if(!module_exists('workflow_ng')) { |
| 33 |
return; |
return; |
| 34 |
} |
} |
| 35 |
if (in_array($op, array('transition pre', 'transition post'))) { |
if (in_array($op, array('transition pre', 'transition post'))) { |
| 36 |
$op = str_replace(" ","_",$op); |
$op = str_replace(" ","_",$op); |
| 37 |
workflow_ng_invoke_event('workflow_'. $op, $node); |
workflow_ng_invoke_event('workflow_'. $op, $node); |
| 38 |
} |
} |
| 39 |
} |
} |
| 40 |
|
|
| 41 |
|
|
| 66 |
workflow_node_current_state($node); |
workflow_node_current_state($node); |
| 67 |
$from_state = $settings['from_state']; |
$from_state = $settings['from_state']; |
| 68 |
$to_state = $settings['to_state']; |
$to_state = $settings['to_state']; |
| 69 |
$result = db_query_range("SELECT h.* FROM {workflow_node_history} h WHERE nid = %d ORDER BY stamp DESC",$node->nid,0,1); |
$result = db_query_range("SELECT h.* FROM {workflow_node_history} h WHERE nid = %d ORDER BY stamp DESC",$node->nid,0,1); |
| 70 |
if ($row = db_fetch_object($result)) { |
if ($row = db_fetch_object($result)) { |
| 71 |
if ( ( in_array($row->old_sid,$from_state) || isset($from_state['ALL']) ) && |
if ( ( in_array($row->old_sid,$from_state) || isset($from_state['ALL']) ) && |
| 72 |
( in_array($row->sid,$to_state) || isset($to_state['ALL']) ) ) { |
( in_array($row->sid,$to_state) || isset($to_state['ALL']) ) ) { |
| 73 |
return true; |
return true; |
| 74 |
} |
} |
| 75 |
} |
} |
| 76 |
|
|
| 77 |
return false; |
return false; |
| 78 |
} |
} |
| 79 |
|
|
| 81 |
* Check for content types - Configuration form |
* Check for content types - Configuration form |
| 82 |
*/ |
*/ |
| 83 |
function workflow_ng_condition_workflow_transition_is_form($settings = array()) { |
function workflow_ng_condition_workflow_transition_is_form($settings = array()) { |
| 84 |
|
|
| 85 |
$options = array(); |
$options = array(); |
| 86 |
$options['ANY'] = 'Any State'; |
$options['ANY'] = 'Any State'; |
| 87 |
foreach(workflow_get_all() as $wid => $workflow) { |
foreach(workflow_get_all() as $wid => $workflow) { |
| 88 |
foreach (workflow_get_states($wid) as $sid => $state) { |
foreach (workflow_get_states($wid) as $sid => $state) { |
| 89 |
$options[$sid] = $workflow .': '.$state; |
$options[$sid] = check_plain(t($workflow)) .': '. check_plain(t($state)); |
| 90 |
} |
} |
| 91 |
} |
} |
| 92 |
|
|
| 93 |
$form['from_state'] = array( |
$form['from_state'] = array( |
| 94 |
'#type' => 'select', |
'#type' => 'select', |
| 95 |
'#title' => t('From State'), |
'#title' => t('From State'), |
| 98 |
'#default_value' => isset($settings['from_state']) ? $settings['from_state'] : array(), |
'#default_value' => isset($settings['from_state']) ? $settings['from_state'] : array(), |
| 99 |
'#required' => TRUE, |
'#required' => TRUE, |
| 100 |
); |
); |
| 101 |
|
|
| 102 |
$form['to_state'] = array( |
$form['to_state'] = array( |
| 103 |
'#type' => 'select', |
'#type' => 'select', |
| 104 |
'#title' => t('To State'), |
'#title' => t('To State'), |
| 107 |
'#default_value' => isset($settings['to_state']) ? $settings['to_state'] : array(), |
'#default_value' => isset($settings['to_state']) ? $settings['to_state'] : array(), |
| 108 |
'#required' => TRUE, |
'#required' => TRUE, |
| 109 |
); |
); |
| 110 |
|
|
| 111 |
return $form; |
return $form; |
| 112 |
} |
} |
| 113 |
|
|
| 114 |
function workflow_ng_condition_workflow_transition_is_submit($form_id, $form_values) { |
function workflow_ng_condition_workflow_transition_is_submit($form_id, $form_values) { |
| 115 |
|
|
| 116 |
return array( |
return array( |
| 117 |
'from_state' => $form_values['from_state'], |
'from_state' => $form_values['from_state'], |
| 118 |
'to_state' => $form_values['to_state'] |
'to_state' => $form_values['to_state'] |
| 122 |
|
|
| 123 |
|
|
| 124 |
function workflow_workflow_ng_configuration() { |
function workflow_workflow_ng_configuration() { |
| 125 |
|
|
| 126 |
$conf['email_author_when_state_changes'] = |
$conf['email_author_when_state_changes'] = |
| 127 |
array ( |
array ( |
| 128 |
'#type' => 'configuration', |
'#type' => 'configuration', |
| 129 |
'#altered' => false, |
'#altered' => false, |
| 131 |
'#label' => 'Email Author when workflow state changes', |
'#label' => 'Email Author when workflow state changes', |
| 132 |
'#active' => 0, |
'#active' => 0, |
| 133 |
'#module' => 'workflow-ng', |
'#module' => 'workflow-ng', |
| 134 |
0 => |
0 => |
| 135 |
array ( |
array ( |
| 136 |
'#type' => 'condition', |
'#type' => 'condition', |
| 137 |
'#name' => 'workflow_ng_condition_token_compare', |
'#name' => 'workflow_ng_condition_token_compare', |
| 138 |
'#negate' => 1, |
'#negate' => 1, |
| 139 |
'#settings' => |
'#settings' => |
| 140 |
array ( |
array ( |
| 141 |
'text1' => '[state:workflow-current-state-name]', |
'text1' => '[state:workflow-current-state-name]', |
| 142 |
'text1_args' => |
'text1_args' => |
| 143 |
array ( |
array ( |
| 144 |
0 => 'state', |
0 => 'state', |
| 145 |
), |
), |
| 146 |
'text2' => '[state:workflow-old-state-name]', |
'text2' => '[state:workflow-old-state-name]', |
| 147 |
'text2_args' => |
'text2_args' => |
| 148 |
array ( |
array ( |
| 149 |
0 => 'state', |
0 => 'state', |
| 150 |
), |
), |
| 152 |
), |
), |
| 153 |
'#label' => 'Current State Name == Old state Name', |
'#label' => 'Current State Name == Old state Name', |
| 154 |
), |
), |
| 155 |
1 => |
1 => |
| 156 |
array ( |
array ( |
| 157 |
'#type' => 'action', |
'#type' => 'action', |
| 158 |
'#name' => 'workflow_ng_action_mail_to_user', |
'#name' => 'workflow_ng_action_mail_to_user', |
| 159 |
'#argument map' => |
'#argument map' => |
| 160 |
array ( |
array ( |
| 161 |
'author' => 'user', |
'author' => 'user', |
| 162 |
), |
), |
| 163 |
'#settings' => |
'#settings' => |
| 164 |
array ( |
array ( |
| 165 |
'from' => '[node:site-mail]', |
'from' => '[node:site-mail]', |
| 166 |
'from_args' => |
'from_args' => |
| 167 |
array ( |
array ( |
| 168 |
0 => 'node', |
0 => 'node', |
| 169 |
), |
), |
| 170 |
'subject' => 'State of [node:title] Changed', |
'subject' => 'State of [node:title] Changed', |
| 171 |
'subject_args' => |
'subject_args' => |
| 172 |
array ( |
array ( |
| 173 |
0 => 'node', |
0 => 'node', |
| 174 |
), |
), |
| 175 |
'message' => 'It is now [state:workflow-current-state-name]', |
'message' => 'It is now [state:workflow-current-state-name]', |
| 176 |
'message_args' => |
'message_args' => |
| 177 |
array ( |
array ( |
| 178 |
0 => 'state', |
0 => 'state', |
| 179 |
), |
), |
| 180 |
), |
), |
| 181 |
'#label' => 'Send Notification to Author', |
'#label' => 'Send Notification to Author', |
| 182 |
), |
), |
| 183 |
2 => |
2 => |
| 184 |
array ( |
array ( |
| 185 |
'#type' => 'action', |
'#type' => 'action', |
| 186 |
'#name' => 'workflow_ng_action_drupal_message', |
'#name' => 'workflow_ng_action_drupal_message', |
| 187 |
'#settings' => |
'#settings' => |
| 188 |
array ( |
array ( |
| 189 |
'message' => 'Mail has been sent to the author, notifying them of their ownership of [node:title]', |
'message' => 'Mail has been sent to the author, notifying them of their ownership of [node:title]', |
| 190 |
'message_args' => |
'message_args' => |
| 191 |
array ( |
array ( |
| 192 |
0 => 'node', |
0 => 'node', |
| 193 |
1 => 'state', |
1 => 'state', |
| 198 |
'#name' => 'cfg_2', |
'#name' => 'cfg_2', |
| 199 |
) |
) |
| 200 |
; |
; |
| 201 |
|
|
| 202 |
return $conf; |
return $conf; |
| 203 |
} |
} |
| 204 |
?> |
?> |