quick tidy up
This commit is contained in:
@@ -1300,20 +1300,17 @@ function booking_studygroups_update_form($node, &$form_state, $sid) {
|
|||||||
|
|
||||||
//now calculate the updates for the database
|
//now calculate the updates for the database
|
||||||
foreach($working_list as $person)
|
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;
|
$found = FALSE;
|
||||||
$message = "";
|
$message = "";
|
||||||
|
|
||||||
|
//iterate all the groups for each person
|
||||||
foreach ($group_mapping as $mapping)
|
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)
|
//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)
|
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;
|
$found = TRUE;
|
||||||
|
|
||||||
//if the existing session is not the same as our newly calculated session, run an update query
|
//if the existing session is not the same as our newly calculated session, run an update query
|
||||||
@@ -1329,18 +1326,7 @@ function booking_studygroups_update_form($node, &$form_state, $sid) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$updates_to_confirm[] = array('sid' => $mapping->sid, 'fields' => $update);
|
$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)
|
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);
|
$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;
|
break;
|
||||||
|
|
||||||
} //end checking for existing group session
|
} //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));
|
//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',
|
$insert_query = db_insert('booking_studygroup_mapping')->fields(array('booking_eventid', 'booking_node_id',
|
||||||
'booking_studygroup_id', 'booking_session_id', 'booking_studygroup_role'));
|
'booking_studygroup_id', 'booking_session_id', 'booking_studygroup_role'));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user