You are here

function fieldable_panels_panes_services_access in Fieldable Panels Panes (FPP) 7

Access callback for the fieldable panels pane resource.

Parameters

string $op: The operation that's going to be performed.

array $args: The arguments that will be passed to the callback.

Return value

bool Whether access is given or not.

1 string reference to 'fieldable_panels_panes_services_access'
fieldable_panels_panes_services_resources in ./fieldable_panels_panes.services.inc
Implements hook_services_resources().

File

./fieldable_panels_panes.services.inc, line 185
Contains callbacks for service resource manipulation.

Code

function fieldable_panels_panes_services_access($op, array $args) {

  // Make sure we have an object or this all fails, some servers can
  // mess up the types.
  if (is_array($args[0])) {
    $args[0] = (object) $args[0];
  }
  elseif (!is_array($args[0]) && !is_object($args[0])) {
    $args[0] = (object) array(
      'fpid' => $args[0],
    );
  }
  if ($op != 'create' && !empty($args)) {
    $fpp = fieldable_panels_panes_load($args[0]->fpid);
  }
  elseif ($op == 'create') {
    if (isset($args[0]->bundle)) {
      $fpp = $args[0]->bundle;
      return fieldable_panels_panes_access($op, $fpp);
    }
    else {
      return services_error(t('Fieldable panels pane bundle is required'), 406);
    }
  }
  if (isset($fpp->fpid) && $fpp->fpid) {
    return fieldable_panels_panes_access($op, $fpp);
  }
  else {
    return services_error(t('Fieldable panel pane @fpid could not be found', array(
      '@fpid' => $args[0]->fpid,
    )), 404);
  }
}