function search_api_saved_search_access in Search API Saved Searches 7
Access callback for saved search entities.
Parameters
string $op: The operation being performed. One of "view", "update", "create" or "delete".
SearchApiSavedSearch|null $search: (optional) The entity to check access for. If NULL is given, it will be determined whether access is allowed for all searches.
object|null $account: The user to check for. NULL to check for the global user.
Return value
bool Whether access is allowed or not.
See also
entity_access
1 string reference to 'search_api_saved_search_access'
File
- ./
search_api_saved_searches.module, line 265 - Offers the ability to save searches and be notified of new results.
Code
function search_api_saved_search_access($op, SearchApiSavedSearch $search = NULL, $account = NULL) {
if (user_access('administer search_api_saved_searches', $account)) {
return TRUE;
}
if (!$account) {
global $user;
$account = $user;
}
switch ($op) {
case 'create':
return user_access('use search_api_saved_searches', $account);
default:
// If the search was created by an anonymous user, there's no way we can
// correctly determine access here.
if (!$search || !$search->uid) {
return FALSE;
}
return $search->uid == $account->uid;
}
}