diff content_moderation\content_moderation.admin.inc content_moderation_ui\content_moderation.admin.inc
1c1,169
< <?php
\ No newline at end of file
---
> <?php
> // $Id$
> 
> /**
>  * Form builder function for module settings.
>  */
> function content_moderation_admin_settings() {
> 	$form['content_moderation_pending_count'] = array(
>     '#type' => 'textfield',
> 		'#size' => 3,
> 		'#maxlength' => 3,
>     '#description' => t('Define how many pending revisions shall be visible in content_moderation block.'),
> 		'#default_value' => variable_get('content_moderation_pending_count', 5),
>   );
> 	
> 	return system_settings_form($form); 
> }
> 
> 
> /**
>  * Form builder function for module settings.
>  * Defining states
>  */
> function content_moderation_admin_settings_states() {
> 
> 	$form['content_moderation_states'] = array(
>     '#type' => 'fieldset',
>     '#title' => t('Content moderation states'),
>     '#description' => t('Use to define new states or to delete existing ones. States have to be defined before corresponding transitions can be set up.')
>   );
>   
>   $form['content_moderation_states']['delete_states'] = array(
>     '#type' => 'checkboxes',
>     '#title' => t('Delete existing states'),
>     '#default_value' => array(),
>     '#options' => _content_moderation_admin_states(),
>     '#description' => t('Please note: when deleting an existing state all transitions involving this state will also be deleted.')
>   );
>   
>   $form['content_moderation_states']['new_state_name'] = array(
>     '#type' => 'textfield',
>     '#title' => t('Create new state'),
>     '#size' => 60,
>     '#maxlength' => 255,
>     '#description' => t('Enter name of new state.')
>   );
>   
>   $form['content_moderation_states']['new_state_desc'] = array(
>     '#type' => 'textarea',
>     '#description' => t('Enter an optional description of new state.')
>   );
>   
>   $form['content_moderation_states']['submit_states'] = array(
>     '#type' => 'submit', 
>     '#value' => t('Save States')
>   );
> 	
> 	return $form;
> }
> 
> 
> /**
>  * Form builder function for module settings.
>  * Defining transitions
>  */
> function content_moderation_admin_settings_transitions() {
>   $form['content_moderation_transitions'] = array(
>     '#type' => 'fieldset',
>     '#title' => t('Content moderation transitions'),
>     '#description' => t('Use to define new transitions or to delete existing ones. Transitions may be set up with existing states only.')
>   );
>   
>   $form['content_moderation_transitions']['delete_transitions'] = array(
>     '#type' => 'checkboxes',
>     '#title' => t('Delete existing transitions'),
>     '#default_value' => array(),
>     '#options' => _content_moderation_admin_transitions(),
>     '#description' => t('Please note: deleting an existing transition will not have any impact on states involved.')
>   );
>   
>   $form['content_moderation_transitions']['new_transition_from'] = array(
>     '#type' => 'select',
>     '#title' => t('New transition from'),
>     '#default_value' => array(),
>     '#options' => array_merge(array(0 => t('Choose a state')),_content_moderation_admin_states()),
>   );
>   
>   $form['content_moderation_transitions']['new_transition_to'] = array(
>     '#type' => 'select',
>     '#title' => t('to'),
>     '#default_value' => array(),
>     '#options' => array_merge(array(0 => t('Choose a state')),_content_moderation_admin_states()),
>   );
>   
>   $form['content_moderation_transitions']['submit_transitions'] = array(
>     '#type' => 'submit', 
>     '#value' => t('Save Transitions')
>   );
> 
>   return $form;
> }
> 
> /*
>  * Get all states possible
>  */
> function _content_moderation_admin_states() {
>   $result = db_query('select * from {content_moderation_states}');
>   //TODO: cache this
>   $states = array();
>   while ($state = db_fetch_object($result)) {
>     $states[$state->name] = $state->descr ? $state->descr : $state->name;
>   }
>   return $states;
> }
> 
> /*
>  * Get all transitions possible
>  */
> function _content_moderation_admin_transitions() {
>   $result = db_query('select * from {content_moderation_transition}');
>   //TODO: cache this
>   $transitions = array();
>   while ($transition = db_fetch_object($result)) {
>     $transinfo = $transition->from_name.'---'.$transition->to_name;
>     $transitions[$transinfo] = $transition->from_name . ' -> ' . $transition->to_name;
>   }
>   return $transitions;
> }
> 
> function content_moderation_admin_settings_states_submit($form, &$form_state)
> {
>   $form_values = $form_state['values'];
> 	foreach ( $form_values['delete_states'] AS $state => $action ) {
> 		if ( is_string($action) ) {
> 			$q = ' DELETE FROM {content_moderation_states} WHERE name = "%s" ';
> 			$r = db_query($q, array($state));
> 			$q = ' DELETE FROM {content_moderation_transition} WHERE from_name = "%s" OR from_name = "%s" ';
> 			$r = db_query($q, array($state, $state));
> 		}
> 	}
> 	if ( isset($form_values['new_state_name']) && strlen($form_values['new_state_name']) > 0 ) {
> 		if ( isset($form_values['new_state_desc']) && strlen($form_values['new_state_desc']) > 0 ) {
> 			$q = ' INSERT INTO {content_moderation_states} VALUES ( "%s", "%s" ) ';
> 			$r = db_query($q, array($form_values['new_state_name'],$form_values['new_state_desc']));
> 		}
> 		else {
> 			$q = ' INSERT INTO {content_moderation_states} VALUES ( "%s", NULL ) ';
> 			$r = db_query($q, array($form_values['new_state_name']));
> 		}
> 	}
> 	drupal_set_message(t('Your settings have been saved.'));
> }
> 
> function content_moderation_admin_settings_transitions_submit($form, &$form_state)
> {
> 	$form_values = $form_state['values'];
> 	foreach ( $form_values['delete_transitions'] AS $transition => $action ) {
> 		if ( is_string($action) ) {
> 			$transinfo = explode('---', $transition);
> 			$q = ' DELETE FROM {content_moderation_transition} WHERE from_name = "%s" AND to_name = "%s" ';
> 			$r = db_query($q, array($transinfo[0], $transinfo[1]));
> 		}
> 	}
> 	if ( is_string($form_values['new_transition_from']) && is_string($form_values['new_transition_to']) ) {
> 		$q = ' INSERT INTO {content_moderation_transition} VALUES ( "%s", "%s", "%s" ) ';
> 		$r = db_query($q, array($form_values['new_transition_from'],$form_values['new_transition_to'], 'all'));
> 	}
>   drupal_set_message(t('Your settings have been saved.'));
> }
\ No newline at end of file
diff content_moderation\content_moderation.module content_moderation_ui\content_moderation.module
20c20
<       'page arguments' => array('content_moderation_change_state_form',2),
---
>       'page arguments' => array('content_moderation_change_state_form', 2),
32a33,62
>   // Module settings.
>   $items["admin/settings/content_moderation"] = array(
>       'title' => 'Content moderation',
>       'description' => t('Configure content moderation.'),
>       'page callback' => 'drupal_get_form',
>       'page arguments' => array('content_moderation_admin_settings'),
>       'access arguments' => array('administer site configuration'),
>       'file' => 'content_moderation.admin.inc',
>   );
> 	$items['admin/settings/content_moderation/general'] = array(
> 		'title' => 'General',
> 		'type' => MENU_DEFAULT_LOCAL_TASK,
> 		'weight' => -1,
> 	);
> 	$items['admin/settings/content_moderation/states'] = array(
> 		'title' => 'States',
> 		'type' => MENU_LOCAL_TASK,
> 		'page callback' => 'drupal_get_form',
> 		'page arguments' => array('content_moderation_admin_settings_states'),
> 		'access arguments' => array('administer site configuration'),
> 		'file' => 'content_moderation.admin.inc',
> 	);
> 	$items['admin/settings/content_moderation/transitions'] = array(
> 		'title' => 'Transitions',
> 		'type' => MENU_LOCAL_TASK,
> 		'page callback' => 'drupal_get_form',
> 		'page arguments' => array('content_moderation_admin_settings_transitions'),
> 		'access arguments' => array('administer site configuration'),
> 		'file' => 'content_moderation.admin.inc',
> 	);
69c99
<           $latest = _content_moderation_get_latest_revisions($node->nid,5,NULL,array($node->vid));
---
>           $latest = _content_moderation_get_latest_revisions($node->nid, variable_get('content_moderation_pending_count', 5), NULL, array($node->vid));
83c113
<           $block['content'] = theme('content_moderation_info_block',$node, $links, $state, $live_link, $live,$revisions_list);
---
>           $block['content'] = theme('content_moderation_info_block', $node, $links, $state, $live_link, $live, $revisions_list);
142c172
<         _content_moderation_get_modfiy_for_first_revision($node);
---
>         _content_moderation_get_modify_for_first_revision($node);
179c209
<         db_query('UPDATE {node_revisions} SET timestamp = %d WHERE vid = %d',time() + 1, $node->vid);
---
>         db_query('UPDATE {node_revisions} SET timestamp = %d WHERE vid = %d', time() + 1, $node->vid);
200,207c230,240
<       if ($node->vid != $live_vid) {
<         // Get username for the revision rather than the original node.
<         $revision_author = user_load($node->revision_uid);
<         drupal_set_message(
<           t('The revision of this node has been created on @date by !author.',
<             array(
<              '@date'=> format_date($node->revision_timestamp, 'small'),
<              '!author'=> theme('username', $revision_author)
---
>       global $user;
>       if ( $user->uid == 1 ) {
>         if ($node->vid != $live_vid) {
>           // Get username for the revision rather than the original node.
>           $revision_author = user_load($node->revision_uid);
>           drupal_set_message(
>             t('The revision of this node has been created on @date by !author.',
>               array(
>                '@date'=> format_date($node->revision_timestamp, 'small'),
>                '!author'=> theme('username', $revision_author)
>               )
209,217c242,250
<           )
<         );
<       }
<       else {
<         $count = db_result(db_query('select count(vid) from {node_revisions} where vid>%d and nid=%d',$node->vid,$node->nid));
<         if($count == 1)
<           drupal_set_message(t('This document has 1 pending revision',array('@count' => $count)));
<         else if($count > 1) {
<           drupal_set_message(t('This document has @count pending revisions',array('@count' => $count)));
---
>           );
>         }
>         else {
>           $count = db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE vid > %d AND nid = %d', $node->vid, $node->nid));
>           if($count == 1)
>             drupal_set_message(t('This document has 1 pending revision', array('@count' => $count)));
>           else if($count > 1) {
>             drupal_set_message(t('This document has @count pending revisions', array('@count' => $count)));
>           }
234c267
<   $rigths = array();
---
>   $rights = array();
237c270
<         $to_states = _content_moderation_next_states($from_state,$type);
---
>         $to_states = _content_moderation_next_states($from_state, $type);
241c274
<           $rigths[] = "content moderation $type state $from_state to $to_state";
---
>           $rights[] = "content moderation $type state $from_state to $to_state";
244c277
<     $rigths[] = "content moderation view $type moderation history";
---
>     $rights[] = "content moderation view $type moderation history";
247c280
<   return $rigths;
---
>   return $rights;
259c292
<   db_query('DELETE from {content_moderation} WHERE nid = %d', $nid);
---
>   db_query('DELETE FROM {content_moderation} WHERE nid = %d', $nid);
294,297c327,330
<       $form['options']['status']['#disabled'] = true;
<       $form['options']['status']['#default_value'] = true;
<       $form['options']['status']['#prefix'] = $descr;
<       $form['options']['status']['#value'] = true;
---
>       #$form['options']['status']['#disabled'] = true;
>       #$form['options']['status']['#default_value'] = true;
>       #$form['options']['status']['#prefix'] = $descr;
>       #$form['options']['status']['#value'] = true;
354,355c387,388
<       $node = node_load($node->nid,$vid);
<       drupal_set_message(t('You are now editing the most recent pending revision (@revision) and not the live version!',array('@revision' => $vid)),'warning');
---
>       $node = node_load($node->nid, $vid);
>       drupal_set_message(t('You are now editing the most recent pending revision (@revision) and not the live version!', array('@revision' => $vid)), 'warning');
366c399
<   $result = db_query('SELECT * FROM {node_revisions} WHERE vid=%d',$vid);
---
>   $result = db_query('SELECT * FROM {node_revisions} WHERE vid = %d', $vid);
374c407
<   return db_result(db_query('SELECT MAX(vid) FROM {node_revisions} WHERE nid=%d',$nid));
---
>   return db_result(db_query('SELECT MAX(vid) FROM {node_revisions} WHERE nid = %d', $nid));
391c424
< function _content_moderation_get_modfiy_for_first_revision(&$node) {
---
> function _content_moderation_get_modify_for_first_revision(&$node) {
425c458
<   $node->changed = db_result(db_query("SELECT timestamp from {node_revisions} WHERE vid=%d", $node->vid));
---
>   $node->changed = db_result(db_query("SELECT timestamp FROM {node_revisions} WHERE vid = %d", $node->vid));
450c483
<     // Is this content even in moderatation?
---
>     // Is this content even in moderation?
463c496
<   return db_result(db_query('select nid from {node_revisions} where vid=%d',$vid));
---
>   return db_result(db_query('SELECT nid FROM {node_revisions} WHERE vid = %d', $vid));
469c502
< function _content_moderation_change_state_link($vid,$nid) {
---
> function _content_moderation_change_state_link($vid, $nid) {
477c510
< function _content_moderation_state_allowed($user,$from_state,$to_state,$node_type) {
---
> function _content_moderation_state_allowed($user, $from_state, $to_state, $node_type) {
496c529
< function _content_moderation_access($op,$node) {
---
> function _content_moderation_access($op, $node, $account = NULL) {
508c541,543
<       return _content_moderation_moderate_node_type($node->type) && user_access("content moderation view {$node->type} moderation history",$account);
---
>        $type = $node->type;
>        $right = "content moderation view $type moderation history";
>        return user_access($right, $account);
516c551
< function _content_moderation_get_latest_revisions($nid,$count = 5,$vid =NULL, $exclude = array()) {
---
> function _content_moderation_get_latest_revisions($nid, $count = 5, $vid = NULL, $exclude = array()) {
524c559
<     $filter[] = "nr.vid<>$v";
---
>     $filter[] = "nr.vid <> $v";
535c570
<   $result = db_query("select nr.*,cmrs.state from {node_revisions} as nr LEFT JOIN {content_moderation_revision_state} as cmrs on nr.vid=cmrs.vid where nr.nid=%d AND nr.vid>%d {$filter} order by nr.vid DESC limit %d",$nid,$vid,$count);
---
>   $result = db_query("SELECT nr.*, cmrs.state FROM {node_revisions} AS nr LEFT JOIN {content_moderation_revision_state} AS cmrs ON nr.vid = cmrs.vid WHERE nr.nid = %d AND nr.vid > %d {$filter} ORDER BY nr.vid DESC LIMIT %d", $nid, $vid, $count);
559c594
<     $node = node_load($node->nid,$vid);
---
>     $node = node_load($node->nid, $vid);
diff content_moderation\content_moderation.workflow.inc content_moderation_ui\content_moderation.workflow.inc
11c11
< function content_moderation_change_state_form(&$form_state,$vid) {
---
> function content_moderation_change_state_form(&$form_state, $vid) {
22c22
<   $form['#attributes'] = array('enctype'=>"multipart/form-data");
---
>   $form['#attributes'] = array('enctype' => "multipart/form-data");
45c45
<     '#prefix' => t('Current state: @curstate',array('@curstate' => $curstate)),
---
>     '#prefix' => t('Current state: @curstate', array('@curstate' => $curstate)),
73c73
<       form_set_error('nextstate',t('You are not allowed to change to that state!'));
---
>       form_set_error('nextstate', t('You are not allowed to change to that state!'));
89c89
<   _content_moderation_update_revision_state($node->vid,$node->nid,$nextstate);
---
>   _content_moderation_update_revision_state($node->vid, $node->nid, $nextstate);
94c94
<     _content_moderation_set_live($node->vid,$node->nid);
---
>     _content_moderation_set_live($node->vid, $node->nid);
99,100c99,100
<   _content_moderation_save_history($node,$curstate,$nextstate,$user->uid,$comment);
<   drupal_set_message(t('The revisions state has been successfully updated to @state',array('@state' => $nextstate)));
---
>   _content_moderation_save_history($node, $curstate, $nextstate, $user->uid, $comment);
>   drupal_set_message(t('The revisions state has been successfully updated to @state', array('@state' => $nextstate)));
113c113
< function _content_moderation_update_revision_state($vid,$nid,$state) {
---
> function _content_moderation_update_revision_state($vid, $nid, $state) {
121c121
<   $result = db_fetch_object( db_query("select vid from {content_moderation_revision_state} where vid=%d", $vid) );
---
>   $result = db_fetch_object( db_query("SELECT vid FROM {content_moderation_revision_state} WHERE vid = %d", $vid) );
132c132
< function _content_moderation_set_live($vid,$nid) {
---
> function _content_moderation_set_live($vid, $nid) {
134c134
<   db_query('UPDATE {node} SET vid = %d WHERE nid = %d', $vid, $nid);
---
>   db_query('UPDATE {node} SET vid = %d, status = 1 WHERE nid = %d', $vid, $nid);
145c145
< function _content_moderation_save_history($node,$curstate,$nextstate,$uid,$comment) {
---
> function _content_moderation_save_history($node, $curstate, $nextstate, $uid, $comment) {
170c170
<   $result = db_query('select * from {content_moderation_node_history} where '.$key['name'].'=%d order by stamp DESC' ,$key['value']);
---
>   $result = db_query('SELECT * FROM {content_moderation_node_history} WHERE '.$key['name'].'=%d ORDER BY stamp DESC', $key['value']);
189c189
<   if($curstate == "")
---
>   if($curstate == "") {
191c191,192
<   $result = db_query('select to_name as state from {content_moderation_transition} where from_name="%s" and (ntype="%s" OR ntype="all")',$curstate, $node_type);
---
> 	}
>   $result = db_query('SELECT to_name AS state FROM {content_moderation_transition} WHERE from_name="%s" AND (ntype="%s" OR ntype="all")', $curstate, $node_type);
225c226
< function _content_moderation_statechange_allowed($vid,$state = NULL) {
---
> function _content_moderation_statechange_allowed($vid, $state = NULL) {
232c233
<     drupal_set_message(t('this content type (!type) is not under moderation', array('!type' => $node->type)),'error');
---
>     drupal_set_message(t('this content type (!type) is not under moderation', array('!type' => $node->type)), 'error');
264c265
<   $result = db_query('select state from {content_moderation_revision_state} where vid=%d',$vid);
---
>   $result = db_query('SELECT state FROM {content_moderation_revision_state} WHERE vid = %d', $vid);
diff content_moderation\content_moderation_info_block.tpl.php content_moderation_ui\content_moderation_info_block.tpl.php
41c41
<   <h4><?php print t('Live')?></h4>
---
>   <h4><?php print $node->status ? t('Live') : t('Draft'); ?></h4>
Common subdirectories: content_moderation\css and content_moderation_ui\css
Common subdirectories: content_moderation\translations and content_moderation_ui\translations
