quick tidy up
This commit is contained in:
@@ -1301,19 +1301,16 @@ function booking_studygroups_update_form($node, &$form_state, $sid) {
|
||||
//now calculate the updates for the database
|
||||
foreach($working_list as $person)
|
||||
{
|
||||
//watchdog('booking', "<pre>Working list role person:\n@info</pre>", array('@info' => print_r( $person, true)));
|
||||
|
||||
//check to update existing records rather than inserting new one
|
||||
// if already in $group_mapping then just run an update query here
|
||||
|
||||
$found = FALSE;
|
||||
$message = "";
|
||||
|
||||
//iterate all the groups for each person
|
||||
foreach ($group_mapping as $mapping)
|
||||
{
|
||||
//check if we can find a study group session already for this user and this study group (eg Monday Tuesday or Wednesday)
|
||||
if ($person->nid == $mapping->booking_node_id && $group->sid == $mapping->booking_studygroup_id)
|
||||
{
|
||||
//keep track of our success to avoid doing an insert
|
||||
$found = TRUE;
|
||||
|
||||
//if the existing session is not the same as our newly calculated session, run an update query
|
||||
@@ -1330,17 +1327,6 @@ function booking_studygroups_update_form($node, &$form_state, $sid) {
|
||||
|
||||
$updates_to_confirm[] = array('sid' => $mapping->sid, 'fields' => $update);
|
||||
|
||||
//update the entry
|
||||
/*
|
||||
db_update('booking_studygroup_mapping')
|
||||
->fields(array(
|
||||
'booking_session_id' => $person->session,
|
||||
'booking_studygroup_role' => $person->booking_studygroup_role,
|
||||
))
|
||||
->condition('sid', $mapping->sid)
|
||||
->execute();
|
||||
*/
|
||||
|
||||
}
|
||||
elseif ($mapping->booking_session_id !== $person->session && $group->sid == $reading_group_id)
|
||||
{
|
||||
@@ -1356,7 +1342,7 @@ function booking_studygroups_update_form($node, &$form_state, $sid) {
|
||||
$updates_to_confirm[] = array('sid' => $mapping->sid, 'fields' => $update);
|
||||
|
||||
}
|
||||
//stop looping through the list
|
||||
//stop looping through the list since we found a match
|
||||
break;
|
||||
|
||||
} //end checking for existing group session
|
||||
@@ -1475,7 +1461,7 @@ function booking_studygroups_update_form_submit($form, &$form_state) {
|
||||
//watchdog('booking', "Updated sid !sid affecting !rows rows.", array('!sid' => $update['sid'], '!rows' => $rows));
|
||||
}
|
||||
|
||||
//handle the database inserts using the multi-insert query type at https://drupal.org/node/310079
|
||||
//process the inserts using the multi-insert query type at https://drupal.org/node/310079
|
||||
$insert_query = db_insert('booking_studygroup_mapping')->fields(array('booking_eventid', 'booking_node_id',
|
||||
'booking_studygroup_id', 'booking_session_id', 'booking_studygroup_role'));
|
||||
|
||||
|
Reference in New Issue
Block a user