You are here

function fieldable_panels_panes_check_access_update in Fieldable Panels Panes (FPP) 7

Check if the user has 'update' access for an FPP object.

Parameters

mixed $argument: Should contain an array element "entity_id" with the ID of an FPP object.

Return value

bool Whether or not the user has access to update an FPP object.

4 calls to fieldable_panels_panes_check_access_update()
fieldable_panels_panes_ctools_access_clear in ./fieldable_panels_panes.module
Implement CTools access form caching callback: get.
fieldable_panels_panes_ctools_access_get in ./fieldable_panels_panes.module
Implement CTools access form caching callback: get.
fieldable_panels_panes_ctools_access_set in ./fieldable_panels_panes.module
Implement CTools access form caching callback: set.
fieldable_panels_pane_content_type_edit_form_access in plugins/content_types/fieldable_panels_pane.inc
Callback for the 'edit' permission.

File

./fieldable_panels_panes.module, line 733
Maintains an entity that appears as panel pane content.

Code

function fieldable_panels_panes_check_access_update($argument) {

  // If the argument is empty, either an empty string or an empty array, then
  // CTools is most likely processing a deleted FPP.
  if (empty($argument)) {
    return FALSE;
  }

  // If the argument passed in as an array, try looking for an 'entity_id'
  // element, it should contain the ID of the item that's needed.
  $id = '';
  if (is_array($argument)) {
    if (isset($argument['entity_id'])) {
      $id = $argument['entity_id'];
    }
    else {
      $id = '';
    }
  }
  else {
    $id = $argument;
  }

  // The id should be in the format 'fpid:123', 'vid:123' or 'vuuid:123'.
  if (empty($id) || strpos($id, ':') === FALSE) {
    return FALSE;
  }

  // Try loading the FPP via the ID.
  $entity = fieldable_panels_panes_load_from_subtype_force($id);

  // If either the FPP couldn't be loaded, or the user does not have 'update'
  // access to the FPP, then the visitor does not have access.
  if (empty($entity) || !fieldable_panels_panes_access('update', $entity)) {
    return FALSE;
  }

  // Getting to this point means that the visitor does have access to edit the
  // FPP.
  return TRUE;
}