studygroup code cleanup
This commit is contained in:
@@ -1025,31 +1025,8 @@ function booking_studygroups_update_form($node, &$form_state, $sid) {
|
||||
'over25' => ceil(($statistics['over25'] / $limit) * ($max_people - $fudge_factor)),
|
||||
);
|
||||
|
||||
//select any entries already in the mapping table
|
||||
$group_mapping_query = db_query("SELECT * FROM {booking_studygroup_mapping} WHERE booking_eventid = :eid AND booking_studygroup_id = :sid", array(':eid' => $event->eid, ':sid' => $sid));
|
||||
$group_mapping = $group_mapping_query->fetchAllAssoc('sid');
|
||||
|
||||
//TODO: Move this to a helper function
|
||||
//search for entries already in the mapping table that have a booking_status of 3 (not coming)
|
||||
$to_remove_query = db_query("SELECT m.* FROM {booking_studygroup_mapping} m
|
||||
inner join {booking_person} p on p.nid = m.booking_node_id
|
||||
WHERE booking_eventid = :eid AND p.booking_status = 3",
|
||||
array(':eid' => $event->eid));
|
||||
$to_remove = $to_remove_query->fetchAll();
|
||||
|
||||
//watchdog('booking', "<pre>Study group mappings to remove:\n@info</pre>", array('@info' => print_r( $to_remove, true)));
|
||||
|
||||
//remove the mappings for these people no longer coming
|
||||
foreach ($to_remove as $person)
|
||||
{
|
||||
$num_deleted = db_delete('booking_studygroup_mapping')
|
||||
->condition('booking_eventid', $event->eid)
|
||||
->condition('booking_node_id', $person->booking_node_id)
|
||||
->condition('booking_studygroup_id', $person->booking_studygroup_id)
|
||||
->execute();
|
||||
watchdog('booking', 'Removed person !nid from study group !sid, affected !num rows.',
|
||||
array ('!nid' => $person->booking_node_id, '!sid' => $person->booking_studygroup_id, '!num' => $num_deleted));
|
||||
}
|
||||
_booking_person_studygroups_cleanup($sid);
|
||||
|
||||
//iterate over the attendee associative array and add some fields
|
||||
foreach ($attendees as $person)
|
||||
@@ -1072,7 +1049,6 @@ function booking_studygroups_update_form($node, &$form_state, $sid) {
|
||||
//process each study group (eg Monday Tuesday Wednesday etc)
|
||||
foreach ($studygroups as $group)
|
||||
{
|
||||
|
||||
$prefix .= t('<h2>Processing study group !group with !sessions sessions</h2>',
|
||||
array('!group' => $group->booking_studygroup_descrip, '!sessions' => $group->booking_num_group_sessions));
|
||||
$prefix .= t('<p>Aiming for !males males, !females females in group. Made up of !20s under 20, !low20s between 20 and 25, and !high20s over 25. Total count in group is !max.</p>',
|
||||
@@ -1083,6 +1059,7 @@ function booking_studygroups_update_form($node, &$form_state, $sid) {
|
||||
//create a temporary copy of the attendee list to work with for this study group
|
||||
$working_list = array();
|
||||
$working_list = _booking_shuffle_assoc(_booking_clone_array($attendees));
|
||||
|
||||
//set up the iterator
|
||||
$obj = new ArrayObject( $working_list );
|
||||
$it = $obj->getIterator();
|
||||
@@ -1150,7 +1127,6 @@ function booking_studygroups_update_form($node, &$form_state, $sid) {
|
||||
$bfgf_gender = $working_list[$bf_gf_id]->booking_gender == 'M' ? 'male' : 'female';
|
||||
_booking_assign_attendee_group($bf_gf_id, $session_id, $bfgf_gender, $age, $working_list, $session_count, $calculation_messages);
|
||||
}
|
||||
|
||||
}
|
||||
//anyone else already assigned to this group previously
|
||||
elseif ($person->booking_studygroup_id == $group->sid && $working_list[$person->booking_node_id]->processed == 0)
|
||||
|
Reference in New Issue
Block a user