function _access_unpublished_check_hashed_link in Access unpublished 7
Helper function to determine whether to display a hashed link and if so, determine its format.
Parameters
object $node: The node being viewed or edited.
2 calls to _access_unpublished_check_hashed_link()
- access_unpublished_form_node_form_alter in ./
access_unpublished.module - Implements hook_form_BASE_FORM_ID_alter().
- access_unpublished_node_view in ./
access_unpublished.module - Implements hook_node_view().
File
- ./
access_unpublished.module, line 193 - Drupal module: Access unpublished.
Code
function _access_unpublished_check_hashed_link($node) {
if (module_exists('workbench_moderation') && workbench_moderation_node_type_moderated($node->type)) {
// Check for workbench_moderation status first, as this
// overrides the basic published/unpublished check.
$wb_unpublished = FALSE;
$wb_revision = FALSE;
$draft_path = FALSE;
if (!isset($node->workbench_moderation['published'])) {
$wb_unpublished = TRUE;
}
else {
$urlseg = explode('/', current_path());
if (isset($urlseg[2])) {
switch ($urlseg[2]) {
case 'draft':
$draft_path = true;
break;
}
}
}
if ($node->workbench_moderation['current']->is_current == 1 && $node->workbench_moderation['current']->published == '0') {
$wb_revision = TRUE;
}
if ($wb_unpublished && $wb_revision) {
// We have a node that only exists as a draft, so we can't count on the
// node/%/draft URL pattern in this case.
_access_unpublished_show_hashed_link('node/' . $node->nid, $node);
}
else {
if (!$wb_unpublished && $wb_revision && $draft_path) {
// We have a draft revision of a published node, so we use the
// node/%/draft URL pattern in this case.
_access_unpublished_show_hashed_link('node/' . $node->nid . '/draft', $node);
}
else {
if ($node->status == NODE_NOT_PUBLISHED && !$wb_unpublished) {
_access_unpublished_show_hashed_link('node/' . $node->nid, $node);
}
}
}
}
else {
if ($node->status == NODE_NOT_PUBLISHED) {
// Either workbench_moderation is not installed or we have an un-moderated
// content type.
_access_unpublished_show_hashed_link('node/' . $node->nid, $node);
}
}
}