class context_og_condition_member_role in Context OG 7.2
Expose organic groups member status as a context condition..
Hierarchy
- class \context_condition
Expanded class hierarchy of context_og_condition_member_role
3 string references to 'context_og_condition_member_role'
- context_og_context_page_reaction in ./
context_og.module - context_og_context_plugins in ./
context_og.module - context_og_context_registry in ./
context_og.module - Implementation of hook_context_registry().
File
- plugins/
context_og_condition_member_role.inc, line 6
View source
class context_og_condition_member_role extends context_condition {
function condition_values() {
// we want to expose all roles so og_roles doesn't quite suffice.
$query = db_select('og_role', 'ogr')
->fields('ogr', array(
'rid',
'name',
'group_type',
'group_bundle',
))
->condition('gid', 0, '=')
->orderBy('group_type, group_bundle, name', 'ASC');
$rids = $query
->execute()
->fetchAll();
$roles = array();
foreach ($rids as $rid => $fields) {
$roles[$rid] = $fields->group_type . '-' . $fields->group_bundle . ': ' . $fields->name;
}
return $roles;
}
function condition_form($context) {
$form = parent::condition_form($context);
$form['#type'] = 'select';
$form['#multiple'] = TRUE;
return $form;
}
function options_form($context) {
$defaults = $this
->fetch_from_context($context, 'options');
return array(
'node_form' => array(
'#title' => t('Set on node form'),
'#type' => 'checkbox',
'#description' => t('Set this context on node forms'),
'#default_value' => isset($defaults['node_form']) ? $defaults['node_form'] : TRUE,
),
);
}
function execute($group) {
global $user;
$node_form = arg(0) == 'node' && (is_numeric(arg(1)) && arg(2) == 'edit' || arg(1) == 'add');
// load the current roles for the user.
$roles = og_get_user_roles($group['group_type'], $group['gid'], $user->uid);
if (!empty($roles)) {
// Load all contexts that trigger on this context.
foreach ($roles as $rid => $name) {
$contexts = $this
->get_contexts($rid);
foreach ($contexts as $context) {
$options = $this
->fetch_from_context($context, 'options');
// Check node_Form status and trigger context accordingly.
if (!$node_form || !empty($options['node_form'])) {
$this
->condition_met($context, $rid);
}
}
}
}
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
context_condition:: |
property | |||
context_condition:: |
property | |||
context_condition:: |
property | |||
context_condition:: |
property | |||
context_condition:: |
function | Condition form submit handler. | 2 | |
context_condition:: |
function | Marks a context as having met this particular condition. | ||
context_condition:: |
function | Check whether this condition is used by any contexts. Can be used to prevent expensive condition checks from being triggered when no contexts use this condition. | ||
context_condition:: |
function | Context editor form for conditions. | 2 | |
context_condition:: |
function | Context editor form submit handler. | ||
context_condition:: |
function | Retrieve options from the context provided. | ||
context_condition:: |
function | Retrieve all contexts with the condition value provided. | 2 | |
context_condition:: |
function | Options form submit handler. | ||
context_condition:: |
function | Settings form. Provide variable settings for your condition. | ||
context_condition:: |
function | Clone our references when we're being cloned. | ||
context_condition:: |
function | Constructor. Do not override. | ||
context_og_condition_member_role:: |
function |
Condition form. Overrides context_condition:: |
||
context_og_condition_member_role:: |
function |
Condition values. Overrides context_condition:: |
||
context_og_condition_member_role:: |
function | |||
context_og_condition_member_role:: |
function |
Options form. Provide additional options for your condition. Overrides context_condition:: |