class FacetapiDependencyRole in Facet API 6.3
Same name and namespace in other branches
- 7.2 plugins/facetapi/dependency_role.inc \FacetapiDependencyRole
- 7 plugins/facetapi/dependency_role.inc \FacetapiDependencyRole
Adds a dependency on content type.
Hierarchy
- class \FacetapiDependency
- class \FacetapiDependencyRole
Expanded class hierarchy of FacetapiDependencyRole
1 string reference to 'FacetapiDependencyRole'
- facetapi_facetapi_dependencies in ./
facetapi.facetapi.inc - Implements hook_facetapi_dependencies().
File
- plugins/
facetapi/ dependency_role.inc, line 11 - Performs a dependency check against the passed content type.
View source
class FacetapiDependencyRole extends FacetapiDependency {
/**
* Executes the dependency check.
*/
public function execute() {
global $user;
if (1 != $user->uid) {
$roles = array_filter($this->settings['roles']);
if ($roles && !array_intersect_key($user->roles, $roles)) {
return FALSE;
}
}
}
/**
* Adds dependency settings to the form.
*/
public function settingsForm(&$form, &$form_state) {
$form[$this->id]['roles'] = array(
'#type' => 'checkboxes',
'#title' => t('Show facet for specific roles'),
'#default_value' => $this->settings['roles'],
'#options' => array_map('check_plain', user_roles()),
'#description' => t('Show this facet only for the selected role(s). If you select no roles, the facet will be visible to all users.'),
);
}
/**
* Returns defaults for settings.
*/
public function getDefaultSettings() {
return array(
'roles' => array(),
);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FacetapiDependency:: |
protected | property | An array of active items. | |
FacetapiDependency:: |
protected | property | The adapter object. | |
FacetapiDependency:: |
protected | property | The facet definition. | |
FacetapiDependency:: |
protected | property | An array of facet settings. | |
FacetapiDependency:: |
public | function | Gets the facet definition. | |
FacetapiDependency:: |
public | function | Gets the id of the plugin. | |
FacetapiDependency:: |
public | function | ||
FacetapiDependencyRole:: |
public | function |
Executes the dependency check. Overrides FacetapiDependency:: |
|
FacetapiDependencyRole:: |
public | function |
Returns defaults for settings. Overrides FacetapiDependency:: |
|
FacetapiDependencyRole:: |
public | function |
Adds dependency settings to the form. Overrides FacetapiDependency:: |