studygroup code cleanup

This commit is contained in:
2014-11-18 17:40:18 +11:00
parent 66c859f2af
commit 772b05f9cf
2 changed files with 38 additions and 5 deletions

View File

@@ -627,11 +627,44 @@ function _booking_rooms_cleanup($nid)
} //end function } //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 * @param $nid - the node id for the person who has withdrawn their registration
* @return nothing * @return nothing
*/ */
function _booking_studygroups_cleanup($nid) function _booking_person_studygroups_cleanup($nid)
{ {
global $event; global $event;

View File

@@ -1555,7 +1555,7 @@ function _booking_update($node) {
array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname, '!refund' => $refund))); array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname, '!refund' => $refund)));
//Remove from any study groups //Remove from any study groups
_booking_studygroups_cleanup($node->nid); _booking_person_studygroups_cleanup($node->nid);
//Remove from any rooms allocated //Remove from any rooms allocated
_booking_rooms_cleanup($node->nid); _booking_rooms_cleanup($node->nid);
@@ -1614,7 +1614,7 @@ function _booking_update($node) {
_booking_missedpayment_email($node->nid); _booking_missedpayment_email($node->nid);
//Remove from any study groups //Remove from any study groups
_booking_studygroups_cleanup($node->nid); _booking_person_studygroups_cleanup($node->nid);
//Remove from any rooms allocated //Remove from any rooms allocated
_booking_rooms_cleanup($node->nid); _booking_rooms_cleanup($node->nid);
@@ -1653,7 +1653,7 @@ function _booking_update($node) {
array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname, '!refund' => $refund))); array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname, '!refund' => $refund)));
//Remove from any study groups //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 //if we're not automatically sending emails on registration
//and someone moved from not-paid to booked-in (ie, manual payment process) //and someone moved from not-paid to booked-in (ie, manual payment process)