function spaces_user in Spaces 5
Same name and namespace in other branches
- 5.2 spaces.module \spaces_user()
- 6 spaces.module \spaces_user()
- 6.2 spaces.module \spaces_user()
Implementation of hook_user
File
- ./
spaces.module, line 488
Code
function spaces_user($op, &$edit, &$account, $category = NULL) {
// user profile silo'ing
if ($op == 'view') {
global $user;
if (spaces_router('user view', $account) === false) {
drupal_access_denied();
exit;
}
if ($user->uid == $account->uid) {
$links['user']['title'] = t('Edit my account');
$links['user']['href'] = 'user/' . $account->uid . '/edit';
$links['user']['custom'] = true;
context_set('spaces', 'links', $links);
}
}
// user form mods
if ($op == 'form' && $category == 'account') {
// Add the groups selector to the user form.
$form = og_user('register', $edit, $account, $category = NULL);
$form['og_register']['#weight'] = 5;
$form['og_register']['og_register']['#default_value'] = array_keys($account->og_groups);
return $form;
}
elseif ($op == 'update') {
if (is_array($edit['og_register'])) {
// Process groups selections.
$active_groups = array_keys(array_filter($edit['og_register']));
foreach (array_diff($active_groups, array_keys($account->og_groups)) as $gid) {
$return = og_subscribe_user($gid, $account);
if (!empty($return['message'])) {
drupal_set_message($return['message']);
}
}
foreach (array_diff(array_keys($edit['og_register']), $active_groups) as $gid) {
og_delete_subscription($gid, $account->uid);
}
}
}
}