studygroup code cleanup
This commit is contained in:
@@ -627,11 +627,44 @@ function _booking_rooms_cleanup($nid)
|
||||
} //end function
|
||||
|
||||
/**
|
||||
* Function for cleaning up study groups for people that have withdrawn their registration
|
||||
* Function for cleaning up study groups by removing people that have withdrawn their registration
|
||||
* @param $sid - the study group id to clean up
|
||||
* @return nothing
|
||||
*/
|
||||
function _booking_person_studygroups_cleanup($sid)
|
||||
{
|
||||
global $event;
|
||||
|
||||
//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');
|
||||
|
||||
//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();
|
||||
|
||||
//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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for cleaning up study groups for a person that is no longer coming
|
||||
* @param $nid - the node id for the person who has withdrawn their registration
|
||||
* @return nothing
|
||||
*/
|
||||
function _booking_studygroups_cleanup($nid)
|
||||
function _booking_person_studygroups_cleanup($nid)
|
||||
{
|
||||
global $event;
|
||||
|
||||
|
@@ -1555,7 +1555,7 @@ function _booking_update($node) {
|
||||
array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname, '!refund' => $refund)));
|
||||
|
||||
//Remove from any study groups
|
||||
_booking_studygroups_cleanup($node->nid);
|
||||
_booking_person_studygroups_cleanup($node->nid);
|
||||
|
||||
//Remove from any rooms allocated
|
||||
_booking_rooms_cleanup($node->nid);
|
||||
@@ -1614,7 +1614,7 @@ function _booking_update($node) {
|
||||
_booking_missedpayment_email($node->nid);
|
||||
|
||||
//Remove from any study groups
|
||||
_booking_studygroups_cleanup($node->nid);
|
||||
_booking_person_studygroups_cleanup($node->nid);
|
||||
|
||||
//Remove from any rooms allocated
|
||||
_booking_rooms_cleanup($node->nid);
|
||||
@@ -1653,7 +1653,7 @@ function _booking_update($node) {
|
||||
array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname, '!refund' => $refund)));
|
||||
|
||||
//Remove from any study groups
|
||||
_booking_studygroups_cleanup($node->nid);
|
||||
_booking_person_studygroups_cleanup($node->nid);
|
||||
}
|
||||
//if we're not automatically sending emails on registration
|
||||
//and someone moved from not-paid to booked-in (ie, manual payment process)
|
||||
|
Reference in New Issue
Block a user