You are here

public function ButtonController::access in Command Buttons 7

File

includes/ButtonController.class.php, line 14
Contains the controller class for the OA Button entity.

Class

ButtonController
Entity controller class.

Code

public function access($op, $entity = NULL, $account = NULL) {
  if ($op !== 'create' && !$entity) {
    return FALSE;
  }

  // The administer permission is a blanket override.
  if (user_access('administer command buttons')) {
    return TRUE;
  }
  switch ($op) {
    case 'create':
      return user_access('create button ' . $entity);
    case 'view':
      return TRUE;
    case 'update':
      ctools_include('context');
      return user_access('edit button ' . $entity->bundle);
    case 'delete':
      ctools_include('context');
      return user_access('delete button ' . $entity->bundle);
  }
  return FALSE;
}