class SearchApiAlterUserDomainAccess in Domain Integration (Drupal 7) 7
Same name and namespace in other branches
- 8 modules/domain_integration_search_api/includes/callback_user_domain_access.inc \SearchApiAlterUserDomainAccess
Adds user domain access information to user indexes.
Hierarchy
- class \SearchApiAbstractAlterCallback implements SearchApiAlterCallbackInterface
Expanded class hierarchy of SearchApiAlterUserDomainAccess
1 string reference to 'SearchApiAlterUserDomainAccess'
- domain_integration_search_api_search_api_alter_callback_info in modules/
domain_integration_search_api/ domain_integration_search_api.module - Implements hook_search_api_alter_callback_info().
File
- modules/
domain_integration_search_api/ includes/ callback_user_domain_access.inc, line 10 - Contains the SearchApiAlterUserDomainAccess class.
View source
class SearchApiAlterUserDomainAccess extends SearchApiAbstractAlterCallback {
/**
* Overrides SearchApiAbstractAlterCallback::supportsIndex().
*
* This plugin only supports indexes containing users.
*/
public function supportsIndex(SearchApiIndex $index) {
return $index
->getEntityType() == 'user';
}
/**
* {@inheritdoc}
*/
public function alterItems(array &$items) {
}
/**
* Overrides SearchApiAbstractAlterCallback::configurationFormSubmit().
*
* If the data alteration is being enabled, set "Published" and "Author" to
* "indexed", because both are needed for the node access filter.
*/
public function configurationFormSubmit(array $form, array &$values, array &$form_state) {
// Ensure the relevant domain properties are added to the index:
// - domain_domain_id (list of ID's the User has access to).
$old_status = !empty($form_state['index']->options['data_alter_callbacks']['search_api_alter_userdomain_access']['status']);
$new_status = !empty($form_state['values']['callbacks']['search_api_alter_user_domain_access']['status']);
if (!$old_status && $new_status) {
$form_state['index']->options['fields']['domain_domain_id']['type'] = 'integer';
}
return parent::configurationFormSubmit($form, $values, $form_state);
}
}