function revision_scheduler_operation_create_access in Revision scheduler 7
Load a single entity with an optional revision ID.
Parameters
string $entity_type: An entity type.
int $entity_id: An entity ID to load.
int $revision_id: (optional) An entity revision ID to use when loading the entity rather than the latest revision.
Return value
object An entity objected from entity_load().
See also
1 call to revision_scheduler_operation_create_access()
- revision_scheduler_field_attach_form in ./
revision_scheduler.module - Implements hook_field_attach_form().
1 string reference to 'revision_scheduler_operation_create_access'
- revision_scheduler_menu in ./
revision_scheduler.module - Implements hook_menu().
File
- ./
revision_scheduler.module, line 671
Code
function revision_scheduler_operation_create_access($entity_type, $entity = NULL, $account = NULL, $check_all_revisions = FALSE) {
if (!revision_scheduler_entity_type_has_revisions($entity_type)) {
return FALSE;
}
if (!isset($account)) {
$account = $GLOBALS['user'];
}
if (!user_access('schedule revisions', $account)) {
return FALSE;
}
$access =& drupal_static(__FUNCTION__, array());
$cid = md5(serialize(array(
$entity_type,
$entity,
$account,
$check_all_revisions,
)));
if (!isset($access[$cid])) {
$access[$cid] = (bool) revision_scheduler_entity_revision_operation_get_options($entity_type, $entity, $account);
// Fallback check if any of the other entity's revisions are schedulable.
if ($check_all_revisions && !$access[$cid] && !empty($entity)) {
list($entity_id, $entity_vid) = entity_extract_ids($entity_type, $entity);
if (!empty($entity_id)) {
// Check to ensure one of the revisions can have a scheduled operation.
$revision_ids = revision_scheduler_get_all_entity_revision_ids($entity_type, $entity_id);
foreach ($revision_ids as $revision_id) {
if ($revision_id != $entity_vid && ($revision = revision_scheduler_entity_revision_load($entity_type, $entity_id, $revision_id))) {
if (revision_scheduler_entity_revision_operation_get_options($entity_type, $revision, $account)) {
$access[$cid] = TRUE;
break;
}
}
}
}
}
}
return $access[$cid];
}