Add page to process reading group colours
This commit is contained in:
@@ -390,6 +390,15 @@ function booking_menu() {
|
|||||||
'access arguments' => array('edit study groups'),
|
'access arguments' => array('edit study groups'),
|
||||||
'type' => MENU_LOCAL_ACTION,
|
'type' => MENU_LOCAL_ACTION,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$items['admin/booking/studygroups/colours'] = array(
|
||||||
|
'title' => 'Process Reading Group Colours',
|
||||||
|
'description' => 'Update the reading group colour based on the studygroup id',
|
||||||
|
'page callback' => 'drupal_get_form',
|
||||||
|
'page arguments' => array('booking_studygroups_process_colours'),
|
||||||
|
'access arguments' => array('edit study groups'),
|
||||||
|
'type' => MENU_LOCAL_ACTION,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//configure rooms
|
//configure rooms
|
||||||
|
@@ -13,7 +13,7 @@ function booking_studygroups_view_summary() {
|
|||||||
global $event;
|
global $event;
|
||||||
$output = "";
|
$output = "";
|
||||||
$header = array('Link','Study Group', 'Session Count', 'Select Leaders');
|
$header = array('Link','Study Group', 'Session Count', 'Select Leaders');
|
||||||
$attributes = array('style' => 'max-width:30%');
|
$attributes = array('style' => 'max-width:40%');
|
||||||
|
|
||||||
//get study groups
|
//get study groups
|
||||||
$query = db_select('booking_studygroup_list', 's')
|
$query = db_select('booking_studygroup_list', 's')
|
||||||
@@ -1529,8 +1529,37 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) {
|
|||||||
),
|
),
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function for updating the reading group colour based on the id automatically generated for them
|
||||||
|
*/
|
||||||
|
function booking_studygroups_process_colours() {
|
||||||
|
global $event;
|
||||||
|
|
||||||
|
//hard code this value for now - it's the id of the special study group that is actually the reading group
|
||||||
|
$readinggroup_studygroup_id = 7;
|
||||||
|
|
||||||
|
//query for the mappings relating to $readinggroup_studygroup_id
|
||||||
|
$group_mapping_query = db_query("SELECT * FROM {booking_studygroup_mapping} WHERE booking_eventid = :eid AND booking_studygroup_id = :sid",
|
||||||
|
array(':eid' => $event->eid, ':sid' => $readinggroup_studygroup_id));
|
||||||
|
$group_mapping = $group_mapping_query->fetchAll();
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($group_mapping as $mapping)
|
||||||
|
{
|
||||||
|
$colour = _booking_readinggroup_colour_lookup($mapping->booking_session_id);
|
||||||
|
|
||||||
|
drupal_set_message(t('Updating user !id to be in team !colour.',
|
||||||
|
array('!id' => $mapping->booking_node_id, '!colour' => $colour)));
|
||||||
|
|
||||||
|
//run an update query
|
||||||
|
db_update('booking_person')
|
||||||
|
->fields(array (
|
||||||
|
'booking_readinggroup' => $colour,
|
||||||
|
))
|
||||||
|
->condition('nid', $mapping->booking_node_id)
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user