function search_api_saved_search_create_access in Search API Saved Searches 7
Determine whether the current user can create a saved search for specific settings.
Parameters
SearchApiSavedSearchesSettings $settings: The settings to check for. May be NULL, if $manual is TRUE, to check if any saved searches can be created manually.
boolean $manual: (optional) If TRUE, check access for creating a saved search manually.
Return value
boolean TRUE iff the current user is allowed to create a new saved search.
2 calls to search_api_saved_search_create_access()
- search_api_saved_searches_block_view in ./
search_api_saved_searches.module - Implements hook_block_view().
- search_api_saved_search_create_personal_access in ./
search_api_saved_searches.module - Access callback: Checks access for the user-specific "add search" page.
1 string reference to 'search_api_saved_search_create_access'
- search_api_saved_searches_menu in ./
search_api_saved_searches.module - Implements hook_menu().
File
- ./
search_api_saved_searches.module, line 553 - Offers the ability to save searches and be notified of new results.
Code
function search_api_saved_search_create_access(SearchApiSavedSearchesSettings $settings = NULL, $manual = FALSE) {
if ($manual) {
if (isset($settings)) {
if (!$settings->enabled || empty($settings->options['manual']['allow'])) {
return FALSE;
}
}
else {
foreach (search_api_saved_searches_settings_load_multiple(FALSE, array(
'enabled' => TRUE,
)) as $settings) {
if (!empty($settings->options['manual']['allow'])) {
$found = TRUE;
break;
}
}
if (empty($found)) {
return FALSE;
}
}
}
elseif (!$settings->enabled) {
return FALSE;
}
if (user_access('administer search_api_saved_searches')) {
return TRUE;
}
if (!user_access('use search_api_saved_searches')) {
return FALSE;
}
if (!isset($settings)) {
return TRUE;
}
// @todo Check settings-specific access rules, when there are any.
return TRUE;
}