more module updates
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
Search API Saved Searches 1.x, dev (xx/xx/xxxx):
|
||||
------------------------------------------------
|
||||
Search API Saved Searches 1.3 (05/24/2014):
|
||||
-------------------------------------------
|
||||
- #2082325 by balajidharma, drunken monkey: Added classes to edit and delete
|
||||
links.
|
||||
- #2088045 by leeomara, drunken monkey: Added hook to override generated names.
|
||||
- #2042299 by drunken monkey: Added access callbacks for both entity types.
|
||||
|
||||
Search API Saved Searches 1.2 (07/21/2013):
|
||||
-------------------------------------------
|
||||
|
@@ -230,6 +230,26 @@ function hook_search_api_saved_searches_new_results_alter(array &$results, Searc
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Alters the name assigned to a newly created saved search.
|
||||
*
|
||||
* @param string $name
|
||||
* The suggested name of the saved search. Likely the search term, or
|
||||
* the translated string "Saved search".
|
||||
* @param array $query
|
||||
* An associative array with the following keys:
|
||||
* - index_id: The machine name of the index the search was run on.
|
||||
* - keys: The parsed search keys.
|
||||
* - original_keys: The keys as entered by the user.
|
||||
* - fields: The fulltext fields searched by the query.
|
||||
* - filters: An array of filters set for the query, as returned by
|
||||
* SearchApiQueryFilterInterface::getFilters().
|
||||
* - options: All options set on the query.
|
||||
*/
|
||||
function hook_search_api_saved_search_create_name_alter(&$name, array $query) {
|
||||
$name = 'foo';
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup hooks".
|
||||
*/
|
||||
|
@@ -10,9 +10,9 @@ files[] = views/handler_field_saved_search_interval.inc
|
||||
files[] = views/handler_field_saved_search_link.inc
|
||||
files[] = views/handler_field_saved_search_name.inc
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-07-21
|
||||
version = "7.x-1.2"
|
||||
; Information added by Drupal.org packaging script on 2014-05-24
|
||||
version = "7.x-1.3"
|
||||
core = "7.x"
|
||||
project = "search_api_saved_searches"
|
||||
datestamp = "1374443489"
|
||||
datestamp = "1400922530"
|
||||
|
||||
|
@@ -113,6 +113,7 @@ function search_api_saved_searches_entity_info() {
|
||||
'entity class' => 'SearchApiSavedSearchesSettings',
|
||||
'base table' => 'search_api_saved_searches_settings',
|
||||
'uri callback' => 'search_api_saved_searches_settings_url',
|
||||
'access callback' => 'search_api_saved_searches_settings_access',
|
||||
'module' => 'search_api_saved_searches',
|
||||
'exportable' => TRUE,
|
||||
'entity keys' => array(
|
||||
@@ -126,6 +127,7 @@ function search_api_saved_searches_entity_info() {
|
||||
'controller class' => 'EntityAPIController',
|
||||
'entity class' => 'SearchApiSavedSearch',
|
||||
'base table' => 'search_api_saved_search',
|
||||
'access callback' => 'search_api_saved_search_access',
|
||||
'module' => 'search_api_saved_searches',
|
||||
'exportable' => FALSE,
|
||||
'entity keys' => array(
|
||||
@@ -203,6 +205,66 @@ function search_api_saved_searches_settings_url(SearchApiSavedSearchesSettings $
|
||||
return array('path' => 'admin/config/search/search_api/index/' . $settings->index_id . '/saved_searches');
|
||||
}
|
||||
|
||||
/**
|
||||
* Access callback for settings entities.
|
||||
*
|
||||
* @param string $op
|
||||
* The operation being performed. One of "view", "update", "create" or
|
||||
* "delete".
|
||||
* @param SearchApiSavedSearchesSettings|null $settings
|
||||
* (optional) The entity to check access for. If NULL is given, it will be
|
||||
* determined whether access is allowed for all settings.
|
||||
* @param object|null $account
|
||||
* The user to check for. NULL to check for the global user.
|
||||
*
|
||||
* @return bool
|
||||
* Whether access is allowed or not.
|
||||
*
|
||||
* @see entity_access
|
||||
*/
|
||||
function search_api_saved_searches_settings_access($op, SearchApiSavedSearchesSettings $settings = NULL, $account = NULL) {
|
||||
return user_access('administer search_api_saved_searches', $account);
|
||||
}
|
||||
|
||||
/**
|
||||
* Access callback for saved search entities.
|
||||
*
|
||||
* @param string $op
|
||||
* The operation being performed. One of "view", "update", "create" or
|
||||
* "delete".
|
||||
* @param 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.
|
||||
* @param object|null $account
|
||||
* The user to check for. NULL to check for the global user.
|
||||
*
|
||||
* @return bool
|
||||
* Whether access is allowed or not.
|
||||
*
|
||||
* @see entity_access
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_user_insert().
|
||||
*
|
||||
@@ -949,13 +1011,12 @@ function search_api_saved_searches_save_form_submit(array $form, array &$form_st
|
||||
* Helper function for creating a name for a saved search with the given query.
|
||||
*/
|
||||
function _search_api_saved_searches_create_name(array $query) {
|
||||
if (!empty($query['original_keys'])) {
|
||||
// @todo This could be an array under some circumstances.
|
||||
if (!empty($query['original_keys']) && is_scalar($query['original_keys'])) {
|
||||
$ret[] = $query['original_keys'];
|
||||
}
|
||||
// @todo File through filters, looking for things that could go in a name.
|
||||
|
||||
return isset($ret) ? implode(' / ', $ret) : t('Saved search');
|
||||
$name = isset($ret) ? implode(' / ', $ret) : t('Saved search');
|
||||
drupal_alter('search_api_saved_search_create_name', $name, $query);
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -45,13 +45,16 @@ function search_api_saved_searches_user_listing($account) {
|
||||
$interval = format_interval($search->notify_interval, 1);
|
||||
}
|
||||
|
||||
$edit_options['attributes']['class'][] = 'saved-search-edit';
|
||||
$delete_options['attributes']['class'][] = 'saved-search-delete';
|
||||
|
||||
$path = $base_path . $search->id;
|
||||
$rows[] = array(
|
||||
$name,
|
||||
$created,
|
||||
$last_execute,
|
||||
$interval,
|
||||
l(t('edit'), $path . '/edit') . ' | ' . l(t('delete'), $path . '/delete'),
|
||||
l(t('edit'), $path . '/edit', $edit_options) . ' | ' . l(t('delete'), $path . '/delete', $delete_options),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -8,9 +8,9 @@ package = Multilingual - Internationalization
|
||||
files[] = search_api_saved_searches_i18n.controller.inc
|
||||
files[] = search_api_saved_searches_i18n.string_wrapper.inc
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-07-21
|
||||
version = "7.x-1.2"
|
||||
; Information added by Drupal.org packaging script on 2014-05-24
|
||||
version = "7.x-1.3"
|
||||
core = "7.x"
|
||||
project = "search_api_saved_searches"
|
||||
datestamp = "1374443489"
|
||||
datestamp = "1400922530"
|
||||
|
||||
|
Reference in New Issue
Block a user