Index: revision_moderation.module =================================================================== --- revision_moderation.module (revision 37) +++ revision_moderation.module (working copy) @@ -385,3 +385,11 @@ watchdog('content', '@type: published %title revision %revision', array('@type' => t($type), '%title' => $title, '%revision' => $vid), WATCHDOG_NOTICE, l(t('view'), "node/$nid/revisions/$vid/view")); $form_state['redirect'] = 'node/'. $nid; } + +function revision_moderation_views_api() { + return array( + 'api' => 2, + 'path' => drupal_get_path('module', revision_moderation) .'/views', + ); +} + Index: views/revision_moderation.views.inc =================================================================== --- views/revision_moderation.views.inc (revision 0) +++ views/revision_moderation.views.inc (revision 0) @@ -0,0 +1,70 @@ + array( + 'left_table' => 'node', // Because this is a direct link it could be left out. + 'left_field' => 'nid', + 'field' => 'nid', + 'table' => 'node_revisions', + ), + ); + + // ---------------------------------------------------------------- + // Fields + + $data['revision_moderation']['state'] = array( + 'title' => t('Revision state'), + 'help' => t('Display the state of the revision.'), + // Information for displaying a title as a field + 'real field' => 'vid', + 'field' => array( + 'field' => 'vid', //The real field name + 'handler' => 'views_handler_field_revision_moderation_state', + 'click sortable' => TRUE, + ), + 'filter' => array( + 'handler' => 'views_handler_filter_revision_moderation_state', + 'allow empty' => 'true', + ), + 'sort' => array( + 'handler' => 'views_handler_sort', + ), + ); + + return $data; +} + +function revision_moderation_views_handlers() { + return array( + 'info' => array( + 'path' => drupal_get_path('module', 'revision_moderation') .'/views', + ), + 'handlers' => array( + 'views_handler_field_revision_moderation_state' => array( + 'parent' => 'views_handler_field', + ), + 'views_handler_filter_revision_moderation_state' => array( + 'parent' => 'views_handler_filter_numeric', + ), + ), + ); +} + +?> \ No newline at end of file Index: views/views_handler_field_revision_moderation_state.inc =================================================================== --- views/views_handler_field_revision_moderation_state.inc (revision 0) +++ views/views_handler_field_revision_moderation_state.inc (revision 0) @@ -0,0 +1,32 @@ +additional_fields['node_vid'] = array('table' => 'node', 'field' => 'vid'); + $this->additional_fields['vid'] = 'vid'; + } + + function render($values) { + + $output = ''; + switch (TRUE) { + case ($values->{$this->aliases['vid']} == $values->{$this->aliases['node_vid']}): + $output = t('current'); + break; + case ($values->{$this->aliases['vid']} > $values->{$this->aliases['node_vid']}): + $output = t('under moderation'); + break; + case ($values->{$this->aliases['vid']} < $values->{$this->aliases['node_vid']}): + $output = t('old'); + break; + } + + return $output; + + } +} Index: views/views_handler_filter_revision_moderation_state.inc =================================================================== --- views/views_handler_filter_revision_moderation_state.inc (revision 0) +++ views/views_handler_filter_revision_moderation_state.inc (revision 0) @@ -0,0 +1,84 @@ + array( + 'title' => t('Current revision'), + 'short' => t('='), + 'method' => 'op_simple', + 'values' => 1, + ), + '>' => array( + 'title' => t('Under revision'), + 'short' => t('>'), + 'method' => 'op_simple', + 'values' => 1, + ), + '<' => array( + 'title' => t('Old'), + 'short' => t('<'), + 'method' => 'op_simple', + 'values' => 1, + ), + ); + return $operators; + } + + function query() { + //Add WHERE statement to the query to filter out node revisions. + $table = $this->ensure_my_table(); + $this->query->add_where($this->options['group'], "$table.$this->real_field ". $this->operator ." node.vid"); + } + + function value_form(&$form, &$form_state) { + $form['value'] = array( + '#type' => 'value', + '#value' => NULL + ); + } + + /** + * Display the filter on the administrative summary + */ + function admin_summary() { + + switch (TRUE) { + case ($this->operator == '='): + $output = t('Current'); + break; + case ($this->operator == '>'): + $output = t('Under moderation'); + break; + case ($this->operator == '<'): + $output = t('Old'); + break; + } + return $output; + } + + +} + + +/** + * @} + */