Added confirmation to study group auto updates
This commit is contained in:
@@ -394,7 +394,7 @@ function booking_menu() {
|
||||
'title' => 'Update Study Groups',
|
||||
'description' => 'Calculate updated Study Group memberships',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_studygroups_update', 3),
|
||||
'page arguments' => array('booking_studygroups_update_form', 3),
|
||||
'access arguments' => array('edit study groups'),
|
||||
//'type' => MENU_LOCAL_ACTION,
|
||||
);
|
||||
@@ -742,3 +742,44 @@ function booking_node_presave($node) {
|
||||
//watchdog('booking', 'Presave of person: @info', array('@info' => var_export($node, TRUE)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function for generating the "lucky number" to be used on the lanyard
|
||||
*/
|
||||
function booking_generate_luckynumbers() {
|
||||
global $event;
|
||||
|
||||
$i = 0;
|
||||
|
||||
//query for the mappings relating to $readinggroup_studygroup_id
|
||||
$attendee_query = db_query("SELECT * FROM {booking_person} WHERE booking_event_id = :eid",
|
||||
array(':eid' => $event->eid));
|
||||
$attendees = $attendee_query->fetchAll();
|
||||
|
||||
//assuming there's less than 900 people, generate numbers within that range and shuffle the order
|
||||
$numbers = range(100,999);
|
||||
shuffle($numbers);
|
||||
|
||||
foreach ($attendees as $attendee)
|
||||
{
|
||||
$luckynum = $numbers[$i++];
|
||||
|
||||
drupal_set_message(t('Updating user !id to have lucky number !num.',
|
||||
array('!id' => $attendee->nid, '!num' => $luckynum)));
|
||||
|
||||
//run an update query
|
||||
|
||||
db_update('booking_person')
|
||||
->fields(array (
|
||||
'booking_luckynum' => $luckynum,
|
||||
))
|
||||
->condition('nid', $attendee->nid)
|
||||
->execute();
|
||||
|
||||
}
|
||||
drupal_set_message(t('Finished.'));
|
||||
|
||||
return t("<h3>Generate Lucky Numbers</h3>");
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user