function og_subgroups_prop_confirm_unsubscribe in Subgroups for Organic groups 6
Menu callback function. Override OG's unsubscribe confirm form
1 string reference to 'og_subgroups_prop_confirm_unsubscribe'
- og_subgroups_prop_menu_alter in modules/
og_subgroups_prop/ og_subgroups_prop.module - Implementation of hook_menu_alter()
File
- modules/
og_subgroups_prop/ includes/ pages.inc, line 6
Code
function og_subgroups_prop_confirm_unsubscribe($form_state, $group, $account) {
global $user;
og_subgroups_include('tree');
$form = array();
$groups = array();
// Determine the unsubscribe propagation directions
$directions = array_filter(variable_get('og_subgroups_propagate_members_unsubscribe', array()));
// Add all the groups in the direction specified
foreach ($directions as $direction) {
if ($direction) {
foreach (_og_subgroups_prop_groups_by_direction($group, $direction) as $member) {
// Check that the user is a member of this group
if (isset($account->og_groups[$member->nid])) {
// Make sure the user can unsubscribe from this group
if (og_subgroups_prop_can_unsubscribe($member, $account)) {
$groups[$member->nid] = l($member->title, "node/{$member->nid}");
}
}
}
}
}
// If the user being unsubscribed is the current user, we need to
// change the wording of the messages
if ($account->uid == $user->uid) {
if (!empty($groups)) {
$sub_message = t('By leaving the group !title, you will also be removed from the following groups: !groups', array(
'!title' => l($group->title, "node/{$group->nid}"),
'!groups' => theme_item_list($groups),
));
}
$message = t('Are you sure you want to leave the group %title?', array(
'%title' => $group->title,
));
$confirm_text = t('Leave');
}
else {
if (!empty($groups)) {
$sub_message = t('By removing !name from the group !title, !name will also be removed from !groups', array(
'!name' => theme('username', $account),
'!title' => l($group->title, "node/{$group->nid}"),
'!groups' => theme_item_list($groups),
));
}
$message = t('Are you sure you want to remove !name from the group %title?', array(
'!name' => theme('username', $account),
'%title' => $group->title,
));
$confirm_text = t('Remove');
}
// Set the page title to the confirmation message
drupal_set_title($message);
$form['group'] = array(
'#type' => 'value',
'#value' => $group,
);
$form['groups'] = array(
'#type' => 'value',
'#value' => $groups,
);
$form['account'] = array(
'#type' => 'value',
'#value' => $account,
);
$form['sub_message'] = array(
'#prefix' => '<div class="container-inline">',
'#value' => $sub_message,
'#suffix' => '</div>',
'#type' => 'item',
'#access' => !empty($groups),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => $confirm_text,
);
$form['cancel'] = array(
'#type' => 'markup',
'#value' => l(t('Cancel'), "node/{$group->nid}"),
);
$form['#submit'] = array(
'og_subgroups_prop_confirm_unsubscribe_submit',
);
return $form;
}