You are here

function message_ui_access_control in Message UI 7

Message module access callback.

Parameters

$operation: The operation - create, view, update, delete.

$message: The message object or message type.

stdClass $user: A user object. Optional.

Return value

bool True or false.

4 calls to message_ui_access_control()
MessageUiPermissions::testMessageUIAccessHook in ./message_ui.test
Checking the alteration flow for other modules.
message_ui_delete_button::render in views/handlers/message_ui_delete_button.inc
Render the field.
message_ui_edit_button::render in views/handlers/message_ui_edit_button.inc
Render the field.
message_ui_view_button::render in views/handlers/message_ui_view_button.inc
Render the field.
1 string reference to 'message_ui_access_control'
message_ui_menu in ./message_ui.module
Implements hook_menu().

File

./message_ui.module, line 215
Main file for the message UI module.

Code

function message_ui_access_control($operation, $message, stdClass $user = NULL) {
  if (empty($user)) {
    global $user;
    $account = user_load($user->uid);
  }
  else {
    $account = user_load($user->uid);
  }

  // Get the message type from the function argument or from the message object.
  $type = is_object($message) ? $message->type : $message;

  // The user can manage any type of message.
  if (user_access('bypass message access control', $account)) {
    return TRUE;
  }

  // Allow other modules to alter the access.
  $data = module_invoke_all('message_message_ui_access_control', $message, $operation, $account);
  foreach ($data as $info) {
    return $info === MESSAGE_UI_ALLOW;
  }

  // Verify that the user can apply the op.
  if (user_access($operation . ' any message instance', $account) || user_access($operation . ' a ' . $type . ' message instance', $account)) {
    return TRUE;
  }
}