fix case where changing leader from one group to another removed them completely

This commit is contained in:
Nathan Coad
2016-06-23 11:30:25 +10:00
parent 7c8f325954
commit 4ae6c21ad4

View File

@@ -384,14 +384,15 @@ function booking_studygroup_leadhelp_edit_form_submit($form, &$form_state) {
//compare it against $person
//if $person is now empty, set the person's role to zero
if (empty($person) && $previous_value != 0) {
$update_messages[] = t("Clearing leader/helper role for nid @id and group @group. Used to have role @role.",
array('@id' => $previous_value, '@group' => $group_id, '@role' => $type_id));
$update_messages[] = t("Clearing leader/helper role for nid @id and session @session in group @group. Used to have role @role.",
array('@id' => $previous_value, '@group' => $group_id, '@role' => $type_id, '@session' => $session_id));
db_update('booking_studygroup_mapping')
->fields(array(
'booking_studygroup_role' => 0,
))
->condition('booking_studygroup_id', $group_id)
->condition('booking_node_id', $previous_value)
->condition('booking_session_id', $session_id)
->execute();
$counter++;
}
@@ -410,7 +411,6 @@ function booking_studygroup_leadhelp_edit_form_submit($form, &$form_state) {
))
->condition('booking_studygroup_id', $group_id)
->condition('booking_node_id', $person_nid)
//->condition('booking_session_id', $session_id)
->execute();
$counter++;
//remove the role from the old person if there was someone else there before