function og_subgroups_context_condition_has_parent::execute in Subgroups for Organic groups 6
Execute the plugin
File
- modules/
og_subgroups_context/ plugins/ og_subgroups_context_condition_has_parent.inc, line 44
Class
- og_subgroups_context_condition_has_parent
- Enable OG Subgroups to trigger a condition based on whether or not the current group has a parent
Code
function execute() {
if ($this
->condition_used()) {
// Determine the group we're in
if ($group = og_subgroups_context_current_group()) {
foreach ($this
->get_contexts($value) as $context) {
og_subgroups_include('tree');
// Extract the chosen setting
$setting = array_shift($context->conditions['og_subgroups_context_condition_has_parent']['values']);
// Evaluate the setting
switch ($setting) {
case OG_SUBGROUPS_CONTEXT_NO_PARENT:
if (!og_subgroups_get_group_parent($group)) {
$this
->condition_met($context, $value);
}
break;
case OG_SUBGROUPS_CONTEXT_HAS_PARENT:
if (og_subgroups_get_group_parent($group)) {
$this
->condition_met($context, $value);
}
break;
}
}
}
}
}