| 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')) { |
| 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) { |
| 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 |
/** |
/** |
| 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 |
/** |
/** |
| 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 |
| 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 |