function og_set_theme in Organic groups 5.3
Same name and namespace in other branches
- 5.8 og.module \og_set_theme()
- 5 og.module \og_set_theme()
- 5.2 og.module \og_set_theme()
- 5.7 og.module \og_set_theme()
- 6.2 og.module \og_set_theme()
- 6 og.module \og_set_theme()
1 call to og_set_theme()
File
- ./
og.module, line 264
Code
function og_set_theme($nid) {
global $custom_theme, $user;
$node = node_load(intval($nid));
if (og_is_group_type($node->type)) {
$custom_theme = $node->og_theme;
return $node;
}
else {
switch (count($node->og_groups)) {
case 0:
return NULL;
case 1:
$group_node = node_load($node->og_groups[0]);
$custom_theme = $group_node->og_theme;
break;
default:
// node is in multiple groups. preference goes to the group we showed on the prior page view (if any),
// then to a group the current user is a member of
if (in_array($_SESSION['og_last'], $node->og_groups)) {
$group_node = node_load($_SESSION['og_last']);
$custom_theme = $group_node->og_theme;
}
else {
$groups = array();
// intersect the node's groups with the user's groups
if ($user->uid) {
$groups = array_intersect($node->og_groups, array_keys($user->og_groups));
}
// no user is logged in, or none of the node's groups are the user's groups
if (empty($groups)) {
$groups = $node->og_groups;
}
// use array_shift and not [0] because array_intersect preserves keys
$group_node = node_load(array_shift($groups));
$custom_theme = $group_node->og_theme;
}
}
return $group_node;
}
}