Commit bb3e8f0d authored by jvandyk's avatar jvandyk
Browse files

simple names

parent ca788465
<?php
<?php
function workflow_workflow_ng_event_info() {
$events = array(
'workflow_transition_post' => array(
'#label' => t('Workflow has been updated'),
......@@ -23,19 +23,19 @@ function workflow_workflow_ng_events_workflow_arguments() {
);
}
function workflow_ng_events_argument_workflow_state($node){
return $node;
function workflow_ng_events_argument_workflow_state($node){
return $node;
}
function workflow_workflow_ng_workflow($op, $old_state, $new_state, $node) {
function workflow_workflow_ng_workflow($op, $old_state, $new_state, $node) {
if(!module_exists('workflow_ng')) {
return;
}
if (in_array($op, array('transition pre', 'transition post'))) {
if (in_array($op, array('transition pre', 'transition post'))) {
$op = str_replace(" ","_",$op);
workflow_ng_invoke_event('workflow_'. $op, $node);
}
}
}
......@@ -66,14 +66,14 @@ function workflow_ng_condition_workflow_transition_is($node, $settings) {
workflow_node_current_state($node);
$from_state = $settings['from_state'];
$to_state = $settings['to_state'];
$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);
if ($row = db_fetch_object($result)) {
if ( ( in_array($row->old_sid,$from_state) || isset($from_state['ALL']) ) &&
( in_array($row->sid,$to_state) || isset($to_state['ALL']) ) ) {
return true;
}
}
return false;
}
......@@ -81,15 +81,15 @@ function workflow_ng_condition_workflow_transition_is($node, $settings) {
* Check for content types - Configuration form
*/
function workflow_ng_condition_workflow_transition_is_form($settings = array()) {
$options = array();
$options['ANY'] = 'Any State';
foreach(workflow_get_all() as $wid => $workflow) {
foreach(workflow_get_all() as $wid => $workflow) {
foreach (workflow_get_states($wid) as $sid => $state) {
$options[$sid] = $workflow .': '.$state;
$options[$sid] = check_plain(t($workflow)) .': '. check_plain(t($state));
}
}
$form['from_state'] = array(
'#type' => 'select',
'#title' => t('From State'),
......@@ -98,7 +98,7 @@ function workflow_ng_condition_workflow_transition_is_form($settings = array())
'#default_value' => isset($settings['from_state']) ? $settings['from_state'] : array(),
'#required' => TRUE,
);
$form['to_state'] = array(
'#type' => 'select',
'#title' => t('To State'),
......@@ -107,12 +107,12 @@ function workflow_ng_condition_workflow_transition_is_form($settings = array())
'#default_value' => isset($settings['to_state']) ? $settings['to_state'] : array(),
'#required' => TRUE,
);
return $form;
}
function workflow_ng_condition_workflow_transition_is_submit($form_id, $form_values) {
return array(
'from_state' => $form_values['from_state'],
'to_state' => $form_values['to_state']
......@@ -122,8 +122,8 @@ function workflow_ng_condition_workflow_transition_is_submit($form_id, $form_val
function workflow_workflow_ng_configuration() {
$conf['email_author_when_state_changes'] =
$conf['email_author_when_state_changes'] =
array (
'#type' => 'configuration',
'#altered' => false,
......@@ -131,20 +131,20 @@ function workflow_workflow_ng_configuration() {
'#label' => 'Email Author when workflow state changes',
'#active' => 0,
'#module' => 'workflow-ng',
0 =>
0 =>
array (
'#type' => 'condition',
'#name' => 'workflow_ng_condition_token_compare',
'#negate' => 1,
'#settings' =>
'#settings' =>
array (
'text1' => '[state:workflow-current-state-name]',
'text1_args' =>
'text1_args' =>
array (
0 => 'state',
),
'text2' => '[state:workflow-old-state-name]',
'text2_args' =>
'text2_args' =>
array (
0 => 'state',
),
......@@ -152,42 +152,42 @@ function workflow_workflow_ng_configuration() {
),
'#label' => 'Current State Name == Old state Name',
),
1 =>
1 =>
array (
'#type' => 'action',
'#name' => 'workflow_ng_action_mail_to_user',
'#argument map' =>
'#argument map' =>
array (
'author' => 'user',
),
'#settings' =>
'#settings' =>
array (
'from' => '[node:site-mail]',
'from_args' =>
'from_args' =>
array (
0 => 'node',
),
'subject' => 'State of [node:title] Changed',
'subject_args' =>
'subject_args' =>
array (
0 => 'node',
),
'message' => 'It is now [state:workflow-current-state-name]',
'message_args' =>
'message_args' =>
array (
0 => 'state',
),
),
'#label' => 'Send Notification to Author',
),
2 =>
2 =>
array (
'#type' => 'action',
'#name' => 'workflow_ng_action_drupal_message',
'#settings' =>
'#settings' =>
array (
'message' => 'Mail has been sent to the author, notifying them of their ownership of [node:title]',
'message_args' =>
'message_args' =>
array (
0 => 'node',
1 => 'state',
......@@ -198,7 +198,7 @@ function workflow_workflow_ng_configuration() {
'#name' => 'cfg_2',
)
;
return $conf;
}
?>
\ No newline at end of file
......@@ -157,7 +157,7 @@ function workflow_tab_page($nid) {
$deleted_states[$data->sid] = $data->state;
}
$current = workflow_node_current_state($node);
// theme_workflow_current_state() must run state through check_plain().
$output = '<p>'. t('Current state: !state', array('!state' => theme('workflow_current_state', $states[$current]))) . "</p>\n";
$output .= drupal_get_form('workflow_tab_form', $node, $wid, $states, $current);
......@@ -179,7 +179,7 @@ function workflow_tab_page($nid) {
}
else {
// Regular state.
$state_name = check_plain($states[$history->sid]);
$state_name = $states[$history->sid];
}
if (isset($deleted_states[$history->old_sid])) {
......@@ -187,11 +187,11 @@ function workflow_tab_page($nid) {
$footer_needed = TRUE;
}
else {
$old_state_name = check_plain($states[$history->old_sid]);
$old_state_name = $states[$history->old_sid];
}
$rows[] = theme('workflow_history_table_row', $history, $old_state_name, $state_name);
}
$output .= theme('workflow_history_table', $rows, !empty($footer_needed));
$output .= theme('workflow_history_table', $rows, !empty($footer_needed));
$output .= theme('pager', $states_per_page);
return $output;
}
......@@ -202,8 +202,8 @@ function workflow_tab_page($nid) {
function theme_workflow_history_table_row($history, $old_state_name, $state_name) {
return array(
format_date($history->stamp),
$old_state_name,
$state_name,
check_plain(t($old_state_name)),
check_plain(t($state_name)),
theme('username', $history),
filter_xss($history->comment, array('a', 'em', 'strong')),
);
......@@ -224,14 +224,14 @@ function theme_workflow_history_table($rows, $footer) {
* Theme the current state in the workflow history table.
*/
function theme_workflow_current_state($state_name) {
return '<strong>'. check_plain($state_name) .'</strong>';
return '<strong>'. check_plain(t($state_name)) .'</strong>';
}
/**
* Theme a deleted state in the workflow history table.
*/
function theme_workflow_deleted_state($state_name) {
return check_plain($state_name) .'*';
return check_plain(t($state_name)) .'*';
}
/**
......@@ -256,7 +256,7 @@ function workflow_tab_form(&$node, $wid, $states, $current) {
// Only build form if user has possible target state(s).
if (count($choices) >= $min) {
$wid = workflow_get_workflow_for_type($node->type);
$name = check_plain(workflow_get_name($wid));
$name = check_plain(t(workflow_get_name($wid)));
// See if scheduling information is present.
if ($node->_workflow_scheduled_timestamp && $node->_workflow_scheduled_sid) {
global $user;
......@@ -532,7 +532,7 @@ function workflow_form_alter($form_id, &$form) {
return;
}
$name = check_plain(workflow_get_name($wid));
$name = check_plain(t(workflow_get_name($wid)));
// If the current node state is not one of the choices, autoselect first choice.
// We know all states in $choices are states that user has permission to
......@@ -714,7 +714,7 @@ function workflow_select_given_state_action_form($context) {
$previous_workflow = '';
$options = array();
while ($data = db_fetch_object($result)) {
$options[$data->name][$data->sid] = $data->state;
$options[$data->name][$data->sid] = check_plain(t($data->state));
}
$form['target_sid'] = array(
'#type' => 'select',
......@@ -742,7 +742,7 @@ function workflow_select_given_state_action_submit($form_id, $form_values) {
$state_name = db_result(db_query("SELECT state FROM {workflow_states} WHERE sid = %d", $form_values['target_sid']));
return array(
'target_sid' => $form_values['target_sid'],
'state_name' => $state_name,
'state_name' => check_plain(t($state_name)),
'force' => $form_values['force'],
'workflow_comment' => $form_values['workflow_comment'],
);
......@@ -963,7 +963,7 @@ function workflow_permissions($wid) {
$wid);
while ($data = db_fetch_object($result)) {
foreach (explode(',', $data->roles) as $role) {
$all[$role]['transitions'][] = array($data->state_name, WORKFLOW_ARROW, $data->target_state_name);
$all[$role]['transitions'][] = array(check_plain(t($data->state_name)), WORKFLOW_ARROW, check_plain(t($data->target_state_name)));
}
}
......@@ -1007,7 +1007,7 @@ function workflow_edit_form($wid) {
);
$form['basic']['wf_name'] = array(
'#type' => 'textfield',
'#default_value' => $workflow->name,
'#default_value' => check_plain(t($workflow->name)),
'#title' => t('Workflow Name'),
'#size' => '16',
'#maxlength' => '254',
......@@ -1388,21 +1388,21 @@ function workflow_overview() {
'title' => t('Delete'),
'href' => "admin/build/workflow/delete/$wid"),
);
// Allow modules to insert their own workflow operations.
$links = array_merge($links, module_invoke_all('workflow_operations', 'workflow', $wid));
$states = workflow_get_states($wid);
if (!module_exists('actions')) {
unset($links['workflow_overview_actions']);
}
$row[] = array($name, theme('links', $links));
$row[] = array(check_plain(t($name)), theme('links', $links));
$subrows = array();
foreach ($states as $sid => $state_name) {
$state_links = array();
if (!workflow_is_system_state(t($state_name))) {
if (!workflow_is_system_state(check_plain(t($state_name)))) {
$state_links = array(
'workflow_overview_edit_state' => array(
'title' => t('Edit'),
......@@ -1416,7 +1416,7 @@ function workflow_overview() {
}
// Allow modules to insert state operations.
$state_links = array_merge($state_links, module_invoke_all('workflow_operations', 'state', $wid, $sid));
$subrows[] = array(t($state_name), theme('links', $state_links));
$subrows[] = array(check_plain(t($state_name)), theme('links', $state_links));
unset($state_links);
}
......@@ -1633,7 +1633,7 @@ function workflow_get_all() {
$workflows = array();
$result = db_query("SELECT wid, name FROM {workflows} ORDER BY name ASC");
while ($data = db_fetch_object($result)) {
$workflows[$data->wid] = $data->name;
$workflows[$data->wid] = check_plain(t($data->name));
}
return $workflows;
......@@ -1715,7 +1715,7 @@ function workflow_get_states($wid = NULL) {
$result = db_query("SELECT sid, state FROM {workflow_states} WHERE status = 1 ORDER BY sid");
}
while ($data = db_fetch_object($result)) {
$states[$data->sid] = $data->state;
$states[$data->sid] = check_plain(t($data->state));
}
return $states;
......@@ -1893,7 +1893,7 @@ function workflow_allowable_transitions($sid, $dir = 'to', $roles = 'ALL') {
if ($roles == 'ALL'
|| $sid == $t->state_id // Include current state for same-state transitions.
|| workflow_transition_allowed($t->tid, $roles)) {
$transitions[$t->state_id] = $t->state_name;
$transitions[$t->state_id] = check_plain(t($t->state_name));
}
}
......@@ -1991,7 +1991,7 @@ function workflow_get_roles() {
$result = db_query('SELECT * FROM {role} ORDER BY name');
$roles = array('author' => 'author');
while ($data = db_fetch_object($result)) {
$roles[$data->rid] = $data->name;
$roles[$data->rid] = check_plain($data->name);
}
}
return $roles;
......@@ -2103,7 +2103,7 @@ function workflow_views_arguments() {
function workflow_handler_filter_sid() {
$result = db_query("SELECT sid, state FROM {workflow_states} ORDER BY weight, state");
while ($data = db_fetch_object($result)) {
$states[$data->sid] = $data->state;
$states[$data->sid] = check_plain(t($data->state));
}
return $states;
......@@ -2135,7 +2135,7 @@ function workflow_handler_arg_sid($op, &$query, $argtype, $arg = '') {
return l($query->state, "$arg/$query->sid");
case 'title':
$state = db_fetch_object(db_query("SELECT state FROM {workflow_states} WHERE sid = %d", $query));
return $state->state;
return check_plain(t($state->state));
}
}
......
......@@ -2,7 +2,7 @@
// $Id$
/**
* @file
* @file
* Provides node access permissions based on workflow states.
*/
......@@ -18,7 +18,7 @@ function workflow_access_enable() {
/**
* Implementation of hook_disable().
*
* Force a rebuild of the node access table when disabled to ensure
* Force a rebuild of the node access table when disabled to ensure
* that our entries are removed from the table.
*/
function workflow_access_disable() {
......@@ -73,7 +73,7 @@ function workflow_access_node_access_records($node) {
'grant_view' => $grant->grant_view,
'grant_update' => $grant->grant_update,
'grant_delete' => $grant->grant_delete
);
);
}
}
......@@ -83,7 +83,7 @@ function workflow_access_node_access_records($node) {
/**
* Implementation of hook_form_alter().
*
* Add a "three dimensional" (state, role, permission type) configuration
* Add a "three dimensional" (state, role, permission type) configuration
* interface to the workflow edit form.
*/
function workflow_access_form_alter($form_id, &$form) {
......@@ -92,16 +92,16 @@ function workflow_access_form_alter($form_id, &$form) {
return;
}
// A list of roles available on the site and our
// A list of roles available on the site and our
// special -1 role used to represent the node author.
// TODO i think there is an API call for this -- user_roles() perhaps?
$rids = array('-1' => t('author'));
$result = db_query("SELECT r.rid, r.name FROM {role} r ORDER BY r.name");
while ($obj = db_fetch_object($result)) {
$rids[$obj->rid] = $obj->name;
$rids[$obj->rid] = check_plain($obj->name);
}
$form['workflow_access'] = array('#type' => 'fieldset',
$form['workflow_access'] = array('#type' => 'fieldset',
'#title' => t('Access control'),
'#collapsible' => TRUE,
'#tree' => TRUE,
......@@ -110,16 +110,16 @@ function workflow_access_form_alter($form_id, &$form) {
// Add a table for every workflow state.
$states = workflow_get_states($form['wid']['#value']);
foreach ($states as $sid => $state) {
if (workflow_is_system_state($state)) {
continue; // no need to set perms on creation
}
$view = $update = $delete = array();
$result = db_query("SELECT * from {workflow_access} where sid = %d", $sid);
// Allow view grants by default for anonymous and authenticated users,
// Allow view grants by default for anonymous and authenticated users,
// if no grants were set up earlier.
if (db_num_rows($result) == 0) {
$view = array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID);
......@@ -136,11 +136,11 @@ function workflow_access_form_alter($form_id, &$form) {
$delete[] = $access->rid;
}
}
// TODO better tables using a #theme function instead of direct #prefixing
$form['workflow_access'][$sid] = array(
'#type' => 'fieldset',
'#title' => $state,
'#type' => 'fieldset',
'#title' => check_plain(t($state)),
'#collapsible' => TRUE,
'#tree' => TRUE,
);
......@@ -179,7 +179,7 @@ function workflow_access_form_submit($form_id, $form_values) {
foreach ($form_values['workflow_access'] as $sid => $access) {
// Ignore irrelevant keys.
if (!is_numeric($sid)) {
continue;
continue;
}
$grants = array();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment