96 lines
2.7 KiB
PHP
96 lines
2.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @file
|
|
* Admin pages for defining study groups
|
|
*/
|
|
|
|
/**
|
|
* Form to view or add a studygroup definition
|
|
*/
|
|
function booking_studygroups_define_form($node, &$form_state, $create, $editid = 0)
|
|
{
|
|
$form = array ();
|
|
$prefix = "<p>Add a new study group definition</p>";
|
|
|
|
if ($create == true)
|
|
{
|
|
$data = $node;
|
|
watchdog('booking', 'Creating new study group: @info', array ('@info' => var_export($node, TRUE)));
|
|
}
|
|
else
|
|
{
|
|
//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');
|
|
return "";
|
|
}
|
|
|
|
$data = db_query("SELECT * FROM {booking_studygroup_list} WHERE sid = :id",
|
|
array(':sid' => $editid))
|
|
->fetchObject();
|
|
$prefix = t("<p>Update the "!event " study group definition.</p>", array('!event' => $data->booking_studygroup_descrip));
|
|
//add this to the form in a hidden field so we can update the right price
|
|
$form['booking_sid'] = array (
|
|
'#type' => 'hidden',
|
|
'#value' => $editid,
|
|
);
|
|
watchdog('booking', 'Editing study group definition: @info',
|
|
array ('@info' => var_export($data, TRUE)));
|
|
}
|
|
|
|
$form['booking_studygroup_descrip'] = array (
|
|
'#type' => 'textfield',
|
|
'#title' => t('Description of this study group (eg Monday)'),
|
|
'#size' => 60,
|
|
'#maxlength' => 150,
|
|
'#required' => TRUE,
|
|
'#default_value' => !empty($data->booking_studygroup_descrip) ? $data->booking_studygroup_descrip : '',
|
|
);
|
|
|
|
$form['booking_num_group_sessions'] = array (
|
|
'#type' => 'textfield',
|
|
'#title' => t('The number of sessions this study group will have'),
|
|
'#size' => 5,
|
|
'#maxlength' => 10,
|
|
'#required' => TRUE,
|
|
'#default_value' => !empty($data->booking_num_group_sessions) ? $data->booking_num_group_sessions : '',
|
|
);
|
|
|
|
$form['booking_is_readinggroup'] = array (
|
|
'#type' => 'radios',
|
|
'#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,
|
|
);
|
|
|
|
if ($create == true)
|
|
{
|
|
$form['submit'] = array
|
|
(
|
|
'#type' => 'submit',
|
|
'#value' => t('Create'),
|
|
);
|
|
} else {
|
|
$form['Update'] = array
|
|
(
|
|
'#type' => 'submit',
|
|
'#value' => t('Update'),
|
|
);
|
|
$form['Delete'] = array
|
|
(
|
|
'#type' => 'submit',
|
|
'#value' => t('Delete'),
|
|
);
|
|
}
|
|
|
|
return array (
|
|
'first_para' => array (
|
|
'#type' => 'markup',
|
|
'#markup' => $prefix,
|
|
),
|
|
'form' => $form,
|
|
);
|
|
} |