Completely redo study group update function
This commit is contained in:
@@ -389,11 +389,49 @@ function _booking_shuffle_assoc($list) {
|
||||
return $random;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to cycle through a list without getting in an endless loop
|
||||
* Used for calculating study groups and maybe readings groups
|
||||
*
|
||||
* Each iteration through the list the maximum permitted size for a given entry will be increased by one
|
||||
* until we find an available entry or we run out of cycle counts
|
||||
*/
|
||||
function _booking_loop_carefully(&$list, $field, &$i, $maximum, $list_size, $max_cycle_count, &$log_array)
|
||||
{
|
||||
$cycle = 0;
|
||||
while ($list[$i][$field] >= $maximum)
|
||||
{
|
||||
$log_array[] = t("Field !field is !value for entry !index, which larger than maximum allowed size, !max. Moving to next entry in list.",
|
||||
array('!field' => $field, '!value' => $list[$i][$field], '!max' => $maximum, '!index' => $i));
|
||||
|
||||
$i++;
|
||||
//reset the counter if we go past the end
|
||||
if ($i > $list_size)
|
||||
{
|
||||
$i = 1;
|
||||
//make sure we don't get stuck in an infinite loop - only go past the end once
|
||||
if ($cycle >= $max_cycle_count)
|
||||
{
|
||||
$log_array[] = t("Reached the end of !field list. Unable to find satisfactory entry after !num cycles.",
|
||||
array('!field' => $field, '!num' => $cycle));
|
||||
return;
|
||||
}
|
||||
elseif ($cycle > 0)
|
||||
{
|
||||
//temporarily increase the maximum size of our groups by one
|
||||
$maximum++;
|
||||
}
|
||||
//always increment the cycle counter if we've reached the end
|
||||
$cycle++;;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to mark an attendee as processed for group calculations
|
||||
* @param $input string containing passport number to be verified
|
||||
*/
|
||||
function _booking_assign_attendee_group($nid, $session_id, $gender, $age, &$attendee_list, &$session_count)
|
||||
function _booking_assign_attendee_group($nid, $session_id, $gender, $age, &$attendee_list, &$session_count, &$log_array)
|
||||
{
|
||||
$previous_session = 0;
|
||||
|
||||
@@ -407,9 +445,9 @@ function _booking_assign_attendee_group($nid, $session_id, $gender, $age, &$atte
|
||||
//check if this person had already been processsed
|
||||
if ($attendee_list[$nid]->processed == 1 && $attendee_list[$nid]->session > 0)
|
||||
{
|
||||
drupal_set_message(t('Detected re-assignment of id !id previously assigned to session !session.',
|
||||
$log_array[] = t('Detected re-assignment of id !id previously assigned to session !session.',
|
||||
array('!id' => $nid, '!session' => $attendee_list[$nid]->session)
|
||||
));
|
||||
);
|
||||
|
||||
$previous_session = $attendee_list[$nid]->session;
|
||||
|
||||
@@ -497,8 +535,8 @@ function _booking_studygroups_cleanup($nid)
|
||||
|
||||
foreach ($to_remove as $group)
|
||||
{
|
||||
$message = t("Removing id !nid from group id !group with role !role",
|
||||
array('!nid' => $nid, '!group' => $group->booking_studygroup_id,
|
||||
$message = t("Removing id !nid from group id !group, session !session with role !role",
|
||||
array('!nid' => $nid, '!group' => $group->booking_studygroup_id, '!session' => $group->booking_session_id,
|
||||
'!role' => _booking_studygroup_role_lookup($group->booking_studygroup_role)
|
||||
)
|
||||
);
|
||||
@@ -531,8 +569,8 @@ function _booking_generate_statistics($booking_list)
|
||||
|
||||
foreach ($booking_list as $person)
|
||||
{
|
||||
//ignore people that havent paid or are no longer coming
|
||||
if ($person->booking_status == 0 || $person->booking_status == 3)
|
||||
//ignore people that havent paid or are no longer coming or missed the payment deadline
|
||||
if ($person->booking_status == 0 || $person->booking_status == 3 || $person->booking_status == 4)
|
||||
continue;
|
||||
|
||||
if ($person->booking_gender == 'M')
|
||||
@@ -899,44 +937,6 @@ function _booking_process_refund($person)
|
||||
return $refund;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to cycle through a list without getting in an endless loop
|
||||
* Used for calculating study groups and maybe readings groups
|
||||
*
|
||||
* Each iteration through the list the maximum permitted size for a given entry will be increased by one
|
||||
* until we find an available entry or we run out of cycle counts
|
||||
*/
|
||||
function _booking_loop_carefully(&$list, $field, &$i, $maximum, $list_size, $max_cycle_count)
|
||||
{
|
||||
$cycle = 0;
|
||||
while ($list[$i][$field] >= $maximum)
|
||||
{
|
||||
drupal_set_message(t("Field !field is !value for entry !index, which larger than maximum allowed size, !max. Moving to next entry in list.",
|
||||
array('!field' => $field, '!value' => $list[$i][$field], '!max' => $maximum, '!index' => $i)));
|
||||
|
||||
$i++;
|
||||
//reset the counter if we go past the end
|
||||
if ($i > $list_size)
|
||||
{
|
||||
$i = 1;
|
||||
//make sure we don't get stuck in an infinite loop - only go past the end once
|
||||
if ($cycle >= $max_cycle_count)
|
||||
{
|
||||
drupal_set_message(t("Reached the end of !field list. Unable to find satisfactory entry after !num cycles.",
|
||||
array('!field' => $field, '!num' => $cycle)));
|
||||
return;
|
||||
}
|
||||
elseif ($cycle > 0)
|
||||
{
|
||||
//temporarily increase the maximum size of our groups by one
|
||||
$maximum++;
|
||||
}
|
||||
//always increment the cycle counter if we've reached the end
|
||||
$cycle++;;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function to generate paypal form for payments
|
||||
|
Reference in New Issue
Block a user