function og_subgroups_prop_confirm_unsubscribe_submit in Subgroups for Organic groups 6
Submit handler
See also
og_subgroups_prop_confirm_unsubscribe
1 string reference to 'og_subgroups_prop_confirm_unsubscribe_submit'
- og_subgroups_prop_confirm_unsubscribe in modules/
og_subgroups_prop/ includes/ pages.inc - Menu callback function. Override OG's unsubscribe confirm form
File
- modules/
og_subgroups_prop/ includes/ pages.inc, line 85
Code
function og_subgroups_prop_confirm_unsubscribe_submit($form, &$form_state) {
global $user;
// Extract needed form elements
$account = $form_state['values']['account'];
$group = $form_state['values']['group'];
$groups = $form_state['values']['groups'];
// Unsubscribe the user from the primary group
// The propagation functions will take care of the rest
og_delete_subscription($group->nid, $account->uid);
// Add the primary group to the list of groups
$groups[$group->nid] = l($group->title, "node/{$group->nid}");
// See if the user being removed is the current user
if ($user->uid == $account->uid) {
// Message varies depending on the amount of groups left
if (count($groups) > 1) {
drupal_set_message(t('You have left from the following groups: !groups', array(
'!groups' => theme_item_list($groups),
)));
}
else {
drupal_set_message(t('You have left the group !group', array(
'!group' => $groups[$group->nid],
)));
}
}
else {
// Message varies depending on the amount of groups left
if (count($groups) > 1) {
drupal_set_message(t('!user has been removed from the following groups: !groups', array(
'!user' => theme('username', $account),
'!groups' => theme_item_list($groups),
)));
}
else {
drupal_set_message(t('!user has been removed from the group !group', array(
'!user' => theme('username', $account),
'!group' => $groups[$group->nid],
)));
}
}
// Determine where to go next. GHP if accessible, or else site front page.
$form_state['redirect'] = node_access('view', $group) ? "node/{$group->nid}" : '<front>';
}