You are here

function editor_note_access_crud_operations in Editor Notes 7

Defines access callback for CRUD operations.

Parameters

int|string $note_id: The unique ID of the note entry.

Return value

bool Boolean indicating whether the user may perform operations on notes or not.

1 call to editor_note_access_crud_operations()
editor_note_get_formatted_notes in ./editor_note.module
Returns formatted notes table.
1 string reference to 'editor_note_access_crud_operations'
editor_note_menu in ./editor_note.module
Implements hook_menu().

File

./editor_note.module, line 1343
Main functionality for Editor Notes module.

Code

function editor_note_access_crud_operations($field_name, $note_id) {
  $field = field_info_field($field_name);
  if (!$field) {
    return FALSE;
  }
  global $user;
  $create_only_permission = isset($field['settings']['notes_permissions']) && $field['settings']['notes_permissions'] == 'create_only';
  if ($create_only_permission && $user->uid != 1) {
    return FALSE;
  }
  $note_uid = db_query('SELECT en.uid FROM {editor_note} en WHERE id = :id', array(
    ':id' => $note_id,
  ))
    ->fetchField();
  return user_access('administer any editor note') || $user->uid == $note_uid;
}