start implementing stored waiting list position
This commit is contained in:
@@ -612,6 +612,9 @@ function booking_update($node) {
|
||||
else {
|
||||
watchdog('booking', 'Still no room on the booked in list though.');
|
||||
}
|
||||
|
||||
// Update waiting list positions
|
||||
_booking_waitinglist_update_trigger();
|
||||
}
|
||||
//check if someone has moved to booked-in list from waiting-list
|
||||
elseif ($previous_status->booking_status == 2 && $node->booking_status == 1) {
|
||||
@@ -637,6 +640,8 @@ function booking_update($node) {
|
||||
$waitinglist_nid = _booking_get_waitinglist_top();
|
||||
}
|
||||
|
||||
// Update waiting list positions
|
||||
_booking_waitinglist_update_trigger();
|
||||
}
|
||||
//check if someone has been demoted to the "missed payment deadline" status from being booked-in
|
||||
elseif ($previous_status->booking_status == 1 && $node->booking_status == 4) {
|
||||
@@ -660,7 +665,7 @@ function booking_update($node) {
|
||||
//-1 means there was no one on the waiting list
|
||||
if ($temp_nid != -1) {
|
||||
//update their registration status
|
||||
_booking_change_status($temp_nid,1);
|
||||
_booking_change_status($temp_nid, 1);
|
||||
//send them an email
|
||||
_booking_promoted_from_waitinglist_email($temp_nid);
|
||||
}
|
||||
@@ -783,6 +788,26 @@ function booking_delete($node) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to update the waiting list position for everyone on the waiting list
|
||||
*/
|
||||
function _booking_waitinglist_update_trigger()
|
||||
{
|
||||
global $event;
|
||||
$waiting_list = _booking_get_waitinglist();
|
||||
$counter = 1;
|
||||
|
||||
foreach ($waiting_list as $person) {
|
||||
db_update('booking_person')
|
||||
->fields(array(
|
||||
'booking_waitlist_pos' => $counter++,
|
||||
))
|
||||
->condition('nid', $person->nid)
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function booking_view($node, $view_mode) {
|
||||
global $event;
|
||||
|
Reference in New Issue
Block a user