Tweaks for study/reading groups
This commit is contained in:
@@ -248,6 +248,7 @@ function booking_admin() {
|
||||
'#options' => array (0 => t('No'), t('Yes')),
|
||||
'#default_value' => variable_get('booking_enable_studygroups', 0),
|
||||
);
|
||||
/*
|
||||
$form['misc']['booking_studygroup_count'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Number of study groups'),
|
||||
@@ -256,6 +257,7 @@ function booking_admin() {
|
||||
'#maxlength' => 3,
|
||||
'#default_value' => variable_get('booking_studygroup_count','0'),
|
||||
);
|
||||
*/
|
||||
$form['misc']['booking_readinggroup_id'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Studygroup ID for the reading group'),
|
||||
|
@@ -1311,7 +1311,9 @@ function _booking_leader_helper_email_summary($node) {
|
||||
for ($i = 1; $i <= variable_get('booking_studygroup_count','0'); $i++)
|
||||
{
|
||||
//don't print info about the readings groups
|
||||
if ($i == variable_get('booking_readinggroup_id','7'))
|
||||
//if ($i == variable_get('booking_readinggroup_id','7'))
|
||||
// continue;
|
||||
if ($studygroups[$i]->booking_is_readinggroup == 'Y')
|
||||
continue;
|
||||
|
||||
//calculate the session references
|
||||
|
@@ -353,7 +353,43 @@ function booking_menu() {
|
||||
//configure study groups
|
||||
if (variable_get('booking_enable_studygroups', 0) == 1)
|
||||
{
|
||||
//the config pages for study groups
|
||||
$items['admin/config/booking/studygroups'] = array(
|
||||
'title' => 'Booking Module Study Group Configuration',
|
||||
'description' => 'Define and configure Study Groups for the Booking module',
|
||||
'page callback' => 'booking_studygroups_admin',
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
);
|
||||
|
||||
$items['admin/config/booking/studygroups/add'] = array(
|
||||
'title' => 'Add Study Group Definition',
|
||||
'description' => 'Add Study Group Definition',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_studygroups_define_form', true),
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'type' => MENU_LOCAL_ACTION,
|
||||
);
|
||||
|
||||
$items['admin/config/booking/studygroups/%/edit'] = array(
|
||||
'title' => 'Edit Study Group Definition',
|
||||
'description' => 'Edit Study Group Definition',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_studygroups_define_form', false, 4),
|
||||
'access arguments' => array('edit study groups'),
|
||||
//'type' => MENU_NORMAL_ITEM,
|
||||
);
|
||||
|
||||
$items['admin/config/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('administer site configuration'),
|
||||
'type' => MENU_LOCAL_ACTION,
|
||||
);
|
||||
|
||||
//pages for using the study group functionality
|
||||
$items['admin/booking/studygroups'] = array(
|
||||
'title' => 'View Study Groups',
|
||||
'description' => 'View Study Group memberships',
|
||||
@@ -362,23 +398,7 @@ function booking_menu() {
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
);
|
||||
|
||||
$items['admin/booking/studygroups/add'] = array(
|
||||
'title' => 'Add Study Group Definition',
|
||||
'description' => 'Add Study Group Definition',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_studygroups_define_form', true),
|
||||
'access arguments' => array("edit study groups"),
|
||||
'type' => MENU_LOCAL_ACTION,
|
||||
);
|
||||
|
||||
$items['admin/booking/studygroups/%/edit'] = array(
|
||||
'title' => 'Edit Study Group Definition',
|
||||
'description' => 'Edit Study Group Definition',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_studygroups_define_form', false, 3),
|
||||
'access arguments' => array('edit study groups'),
|
||||
//'type' => MENU_NORMAL_ITEM,
|
||||
);
|
||||
|
||||
$items['admin/booking/studygroups/%/view'] = array(
|
||||
'title' => 'View Study Group',
|
||||
@@ -425,16 +445,6 @@ function booking_menu() {
|
||||
//'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,
|
||||
);
|
||||
|
||||
|
||||
$items['admin/booking/%/edit-studygroup-membership'] = array(
|
||||
'title' => 'Edit Study Group Allocation',
|
||||
'description' => 'Manually Update Study Group memberships',
|
||||
|
@@ -1991,7 +1991,7 @@ function booking_view($node, $view_mode) {
|
||||
if (variable_get('booking_enable_studygroups', 0) == 1)
|
||||
{
|
||||
$studygroup_heading = t("<h2>Study Groups</h2><p>!link</p>",
|
||||
array('!link' => l(t('Edit Groups'), t('admin/booking/!id/edit-studygroup', array('!id' => $node->nid)))
|
||||
array('!link' => l(t('Edit Groups'), t('admin/booking/!id/edit-studygroup-membership', array('!id' => $node->nid)))
|
||||
));
|
||||
|
||||
//look up the titles of the study groups
|
||||
|
@@ -137,7 +137,7 @@ function booking_report_summary() {
|
||||
|
||||
if (variable_get('booking_enable_studygroups', 0) == 1)
|
||||
{
|
||||
$this_row[] = l(t('Groups'), t('admin/booking/!id/edit-studygroup', array('!id' => $person->nid)));
|
||||
$this_row[] = l(t('Groups'), t('admin/booking/!id/edit-studygroup-membership', array('!id' => $person->nid)));
|
||||
}
|
||||
if (variable_get('booking_enable_roomallocations', 0) == 1)
|
||||
{
|
||||
|
@@ -165,7 +165,7 @@ function booking_available_leadhelp_select_form($node, &$form_state, $group_id)
|
||||
)
|
||||
),
|
||||
'booking_currently_leadhelp' => $role_listing,
|
||||
'booking_group_edit' => l(t('Edit'), t('admin/booking/!id/edit-studygroup', array('!id' => $data->nid))),
|
||||
'booking_group_edit' => l(t('Edit'), t('admin/booking/!id/edit-studygroup-membership', array('!id' => $data->nid))),
|
||||
'#attributes' => array('id' => array($class))
|
||||
);
|
||||
}
|
||||
@@ -1707,7 +1707,7 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) {
|
||||
'data' => array(
|
||||
$session,
|
||||
l(t('!first !last', array('!first' => $data->booking_firstname, '!last' => $data->booking_lastname)),
|
||||
t('admin/booking/!id/edit-studygroup', array('!id' => $data->nid))),
|
||||
t('admin/booking/!id/edit-studygroup-membership', array('!id' => $data->nid))),
|
||||
//_booking_status_generate($data->booking_status),
|
||||
$data->booking_gender == 'M' ? 'Male' : 'Female',
|
||||
_booking_get_age_years($data->booking_dob),
|
||||
|
@@ -5,6 +5,41 @@
|
||||
* Admin pages for defining study groups
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Function for listing the study groups and the ability to edit the group definitions
|
||||
*/
|
||||
function booking_studygroups_admin() {
|
||||
|
||||
global $event;
|
||||
$output = "";
|
||||
$header = array('Study Group', 'Session Count', 'Reading Group?', 'Edit Definition');
|
||||
$attributes = array('style' => 'max-width:60%');
|
||||
//$attributes = array();
|
||||
|
||||
//get study groups
|
||||
$query = db_select('booking_studygroup_list', 's')
|
||||
->fields('s')
|
||||
->condition('s.booking_eventid', $event->eid, '=');
|
||||
$result = $query->execute();
|
||||
|
||||
foreach ($result as $group) {
|
||||
$rows[] = array(
|
||||
$group->booking_studygroup_descrip,
|
||||
$group->booking_num_group_sessions,
|
||||
$group->booking_is_readinggroup == 'Y' ? 'Yes' : 'No',
|
||||
l(t('Edit Group Definition', array('!id' => $group->sid)), t('admin/config/booking/studygroups/!id/edit', array('!id' => $group->sid))),
|
||||
);
|
||||
}
|
||||
|
||||
//output everything
|
||||
$output .= t("<h3>!event Study Groups</h3>", array('!event' => $event->booking_eventname));
|
||||
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes));
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for listing the study groups and links to view each one
|
||||
*/
|
||||
@@ -12,7 +47,7 @@ function booking_studygroups_view_summary() {
|
||||
|
||||
global $event;
|
||||
$output = "";
|
||||
$header = array('Study Group', 'Session Count', 'View Membership', 'Compute Membership', 'Select Leaders', 'Edit Definition');
|
||||
$header = array('Study Group', 'Session Count', 'Reading Group?', 'View Membership', 'Compute Membership', 'Select Leaders');
|
||||
//$attributes = array('style' => 'max-width:50%');
|
||||
$attributes = array();
|
||||
|
||||
@@ -26,11 +61,10 @@ function booking_studygroups_view_summary() {
|
||||
$rows[] = array(
|
||||
$group->booking_studygroup_descrip,
|
||||
$group->booking_num_group_sessions,
|
||||
$group->booking_is_readinggroup == 'Y' ? 'Yes' : 'No',
|
||||
l(t('Current Membership', array('!id' => $group->sid)), t('admin/booking/studygroups/!id/view', array('!id' => $group->sid))),
|
||||
l(t('Compute Membership Update', array('!id' => $group->sid)), t('admin/booking/studygroups/!id/update', array('!id' => $group->sid))),
|
||||
l(t('Edit Leaders/Helpers', array('!id' => $group->sid)), t('admin/booking/studygroups/!id/selectleaders', array('!id' => $group->sid))),
|
||||
l(t('Edit Group Definition', array('!id' => $group->sid)), t('admin/booking/studygroups/!id/edit', array('!id' => $group->sid))),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
@@ -62,7 +96,7 @@ function booking_studygroups_define_form($node, &$form_state, $create, $editid =
|
||||
//verify that $editid is a number
|
||||
if (! preg_match('/^[0-9]+$/', $editid)) {
|
||||
drupal_set_message("Error: Invalid study group ID supplied. Unable to edit study group definition.", 'error', FALSE);
|
||||
drupal_goto('admin/booking/studygroups');
|
||||
drupal_goto('admin/booking/config/studygroups');
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -105,7 +139,7 @@ function booking_studygroups_define_form($node, &$form_state, $create, $editid =
|
||||
'#title' => t('Reading group?'),
|
||||
'#description' => t('Select whether this study group definition is for a reading group. Leave as No unless you want team colours associated with this group'),
|
||||
'#options' => array (0 => t('No'), t('Yes')),
|
||||
'#default_value' => !empty($data->booking_is_readinggroup) ? $data->booking_is_readinggroup : NULL,
|
||||
'#default_value' => !empty($data->booking_is_readinggroup) ? ($data->booking_is_readinggroup == 'Y' ? 1 : 0) : 0,
|
||||
);
|
||||
|
||||
if ($create == true)
|
||||
@@ -150,7 +184,13 @@ function booking_studygroups_define_form_submit($form, &$form_state) {
|
||||
|
||||
global $event;
|
||||
$values = $form_state['input'];
|
||||
$redirect_path = array('admin/booking/studygroups');
|
||||
$redirect_path = array('admin/config/booking/studygroups');
|
||||
$new_count = 0;
|
||||
|
||||
//get the number of study groups before making this update
|
||||
$count = db_query("SELECT count(*) as num FROM {booking_studygroup_list} WHERE booking_eventid = :eid",
|
||||
array(':eid' => $event->eid))->fetchObject();
|
||||
|
||||
|
||||
//watchdog('booking', 'Checkboxes when setting buttons: @info', array ('@info' => var_export($checkboxes, TRUE)));
|
||||
if ($form_state['values']['op'] == 'Create Study Group')
|
||||
@@ -163,6 +203,8 @@ function booking_studygroups_define_form_submit($form, &$form_state) {
|
||||
'booking_is_readinggroup' => $values['booking_is_readinggroup'] == 1 ? 'Y' : 'N',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$new_count = $count->num + 1;
|
||||
}
|
||||
//if we're deleting, add the confirmation to the form if it hasn't been defined yet
|
||||
elseif($form_state['values']['op'] == "Delete Study Group Definition" && (!isset($form_state['storage']['confirm'])))
|
||||
@@ -170,6 +212,8 @@ function booking_studygroups_define_form_submit($form, &$form_state) {
|
||||
watchdog('booking', "<pre>Studygroup deletion confirmation being set:\n@info</pre>", array('@info' => print_r( $form_state, true)));
|
||||
$form_state['storage']['confirm'] = TRUE;
|
||||
$form_state['rebuild'] = TRUE;
|
||||
|
||||
$new_count = $count->num;
|
||||
}
|
||||
elseif ($form_state['values']['op'] == 'Delete Study Group Definition')
|
||||
{
|
||||
@@ -185,6 +229,8 @@ function booking_studygroups_define_form_submit($form, &$form_state) {
|
||||
$num_deleted = db_delete('booking_studygroup_list')
|
||||
->condition('sid', $values['booking_sid'])
|
||||
->execute();
|
||||
|
||||
$new_count = $count->num - 1;
|
||||
}
|
||||
elseif ($form_state['values']['op'] == 'Update Study Group')
|
||||
{
|
||||
@@ -205,7 +251,12 @@ function booking_studygroups_define_form_submit($form, &$form_state) {
|
||||
))
|
||||
->condition('sid', $values['booking_sid'])
|
||||
->execute();
|
||||
|
||||
$new_count = $count->num;
|
||||
}
|
||||
|
||||
//update the number of study groups now defined
|
||||
variable_set('booking_studygroup_count', $new_count);
|
||||
|
||||
$form_state['redirect'] = $redirect_path;
|
||||
}
|
Reference in New Issue
Block a user