/[drupal]/contributions/modules/revisioning/revisioning.module
ViewVC logotype

Diff of /contributions/modules/revisioning/revisioning.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.23, Mon Jun 1 01:17:51 2009 UTC revision 1.24, Mon Jun 1 03:37:33 2009 UTC
# Line 175  function revisioning_menu_alter(&$items) Line 175  function revisioning_menu_alter(&$items)
175  //$items['node/%node/revisions/%/view']['page arguments'] = array(1);  //$items['node/%node/revisions/%/view']['page arguments'] = array(1);
176    
177    // Override existing callback so that we can insert trigger pulled upon reverting    // Override existing callback so that we can insert trigger pulled upon reverting
178    $items['node/%node/revisions/%/revert']['page callback'] = 'drupal_get_form';    //$items['node/%node/revisions/%/revert']['page callback'] = 'drupal_get_form';
179    $items['node/%node/revisions/%/revert']['page arguments'] = array('revisioning_revert_confirm', 1);    //$items['node/%node/revisions/%/revert']['page arguments'] = array('revisioning_revert_confirm', 1);
180    
181    // If Diff module is enabled, make sure it uses correct access callback    // If Diff module is enabled, make sure it uses correct access callback
182    if (module_exists('diff')) {    if (module_exists('diff')) {
# Line 193  function revisioning_menu_alter(&$items) Line 193  function revisioning_menu_alter(&$items)
193   *   Operation, one of 'view', 'update' or 'delete'.   *   Operation, one of 'view', 'update' or 'delete'.
194   * @param $user_filter   * @param $user_filter
195   *   One of NO_FILTER, I_CREATED or I_LAST_MODIFIED.   *   One of NO_FILTER, I_CREATED or I_LAST_MODIFIED.
196   * @return   * @return
197   *   themed HTML   *   themed HTML
198   */   */
199  function _show_pending_nodes($op = 'view', $user_filter = -1) {  function _show_pending_nodes($op = 'view', $user_filter = -1) {
# Line 409  function revisioning_publish_confirm($fo Line 409  function revisioning_publish_confirm($fo
409    $form['title']    = array('#type' => 'value', '#value' => $node->title);    $form['title']    = array('#type' => 'value', '#value' => $node->title);
410    $form['revision'] = array('#type' => 'value', '#value' => $node->vid);    $form['revision'] = array('#type' => 'value', '#value' => $node->vid);
411    $form['type']     = array('#type' => 'value', '#value' => $node->type);    $form['type']     = array('#type' => 'value', '#value' => $node->type);
412    return confirm_form($form, t('Are you sure you want to publish this revision of %title?', array('%title' => $node->title)),    return confirm_form($form,
413                               'node/'. $node->nid .'/revisions',      t('Are you sure you want to publish this revision of %title?', array('%title' => $node->title)),
414                               t('Publishing this revision will make it visible to the public.'),      'node/'. $node->nid .'/revisions',
415                               t('Publish'), t('Cancel'));      t('Publishing this revision will make it visible to the public.'),
416        t('Publish'), t('Cancel'));
417  }  }
418    
419  /**  /**
# Line 432  function revisioning_publish_confirm_sub Line 433  function revisioning_publish_confirm_sub
433   * Return a confirmation page for unpublishing the node.   * Return a confirmation page for unpublishing the node.
434   */   */
435  function revisioning_unpublish_confirm($form_state, $node) {  function revisioning_unpublish_confirm($form_state, $node) {
436    $form['node_id']  = array('#type' => 'value', '#value' => $node->nid);    $form['node_id'] = array('#type' => 'value', '#value' => $node->nid);
437    $form['title']    = array('#type' => 'value', '#value' => $node->title);    $form['title']   = array('#type' => 'value', '#value' => $node->title);
438    $form['type']     = array('#type' => 'value', '#value' => $node->type);    $form['type']    = array('#type' => 'value', '#value' => $node->type);
439    return confirm_form($form, t('Are you sure you want to unpublish %title?', array('%title' => $node->title)),    return confirm_form($form,
440                               "node/$node->nid/revisions",      t('Are you sure you want to unpublish %title?', array('%title' => $node->title)),
441                               t('Unpublishing will remove this content from public view.'),      "node/$node->nid/revisions",
442                               t('Unpublish'), t('Cancel'));      t('Unpublishing will remove this content from public view.'),
443        t('Unpublish'), t('Cancel'));
444  }  }
445    
446  /**  /**
# Line 459  function revisioning_unpublish_confirm_s Line 461  function revisioning_unpublish_confirm_s
461  }  }
462    
463  /**  /**
464     * Implementation of hook_form_FORM_ID_alter(), see node_revision_revert_confirm()
465     */
466    function revisioning_form_node_revision_revert_confirm_alter(&$form_state, &$form_state) {
467      $node = $form['#node_revision'];
468      if (_number_of_pending_revisions($node->nid) > 0) {
469        drupal_set_message(t('There is a pending revision. Are you sure you want to revert to an archived revision?'), 'warning');
470      }
471      $form['#submit'][] = 'revision_revert_confirm_submit';
472    }
473    
474    /**
475     * Submission handler for the revert_confirm form.
476     *
477     * Forward on to the existing revert function in node.pages.inc, then triggers
478     * a 'revert' event that may be actioned upon.
479     *
480     * Note:
481     * It would be nice if publish and revert were symmetrical operations and that
482     * node_revision_revert_cofirm_submit didn't save a copy of the revision (under
483     * a new vid), as this has the side-effect of making all "pending" revisions
484     * "old". This is because the definition of "pending" is:
485     * "node_vid > current_vid".
486     * It would be better if "pending" relied on a separate flag rather than a field
487     * such as vid (or a timestamp) that changes everytime a piece of code executes
488     * a node_save.
489     */
490    function revisioning_revert_confirm_submit($form, &$form_state) {
491      $node = $form['#node_revision'];
492      // Make sure the node gets published, i.e. has its status flag set
493      db_query("UPDATE {node} SET status=1 WHERE nid=%d", $node->nid);
494      cache_clear_all();
495      // Invoke the revisioning trigger passing 'revert' as the operation
496      module_invoke_all('revisioning', 'revert');
497    }
498    
499    
500    /**
501   * Make the supplied revision of the node current and publish it.   * Make the supplied revision of the node current and publish it.
502   *   *
503   * @param $nid   * @param $nid
# Line 504  function revisioning_publish_latest_revi Line 543  function revisioning_publish_latest_revi
543  }  }
544    
545  /**  /**
  * Return a confirmation page prior to reverting to an archived revision.  
  *  
  * Forward to the existing revert function in node.pages.inc  
  */  
 function revisioning_revert_confirm($form_state, $node) {  
   if (_number_of_pending_revisions($node->nid) > 0) {  
     drupal_set_message(t('There is a pending revision. Are you sure you want to revert to an archived revision?'), 'warning');  
   }  
   return node_revision_revert_confirm($form_state, $node);  
 }  
   
 /**  
  * Submission handler for the revert_confirm form.  
  *  
  * Forward on to the existing revert function in node.pages.inc, then triggers  
  * a 'revert' event that may be actioned upon.  
  *  
  * Note:  
  * It would be nice if publish and revert were symmetrical operations and that  
  * node_revision_revert_cofirm_submit didn't save a copy of the revision (under  
  * a new vid), as this has the side-effect of making all "pending" revisions  
  * "old". This is because the definition of "pending" is:  
  * "node_vid > current_vid".  
  * It would be better if "pending" relied on a separate flag rather than a field  
  * such as vid (or a timestamp) that changes everytime a piece of code executes  
  * a node_save.  
  */  
 function revisioning_revert_confirm_submit($form, &$form_state) {  
   $node = $form['#node_revision'];  
   // Next call redirects to node/%/revisions  
   node_revision_revert_confirm_submit($form, $form_state);  
   // Make sure node gets published, i.e. has its status flag set  
   db_query("UPDATE {node} SET status=1 WHERE nid=%d", $node->nid);  
   cache_clear_all();  
   // Invoke the revisioning trigger passing 'revert' as the operation  
   module_invoke_all('revisioning', 'revert');  
 }  
   
 /**  
546   * Return a count of the number of revisions newer than the supplied vid.   * Return a count of the number of revisions newer than the supplied vid.
547   *   *
548   * @param $vid   * @param $vid

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

  ViewVC Help
Powered by ViewVC 1.1.2