add call to _booking_node_create_mysqlview() in studygroup modification admin form
This commit is contained in:
@@ -87,14 +87,12 @@ function booking_studygroups_define_form($node, &$form_state, $create, $editid =
|
||||
$form = array ();
|
||||
$prefix = "<p>Add a new study group definition</p>";
|
||||
|
||||
if ($create == true)
|
||||
{
|
||||
if ($create == true) {
|
||||
drupal_set_title('Add Study Group');
|
||||
$data = $node;
|
||||
watchdog('booking', 'Creating new study group: @info', array ('@info' => var_export($node, TRUE)));
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
drupal_set_title('Edit Study Group');
|
||||
//verify that $editid is a number
|
||||
if (! preg_match('/^[0-9]+$/', $editid)) {
|
||||
@@ -104,21 +102,17 @@ function booking_studygroups_define_form($node, &$form_state, $create, $editid =
|
||||
}
|
||||
|
||||
$data = db_query("SELECT * FROM {booking_studygroup_list} WHERE sid = :id",
|
||||
array(':id' => $editid))
|
||||
->fetchObject();
|
||||
array(':id' => $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)));
|
||||
watchdog('booking', 'Editing study group definition: @info', array ('@info' => var_export($data, TRUE)));
|
||||
}
|
||||
|
||||
|
||||
if(!isset($form_state['storage']['confirm']))
|
||||
{
|
||||
if(!isset($form_state['storage']['confirm'])) {
|
||||
$form['booking_studygroup_descrip'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Description of this study group (eg Monday)'),
|
||||
@@ -144,15 +138,15 @@ function booking_studygroups_define_form($node, &$form_state, $create, $editid =
|
||||
'#options' => array (0 => t('No'), t('Yes')),
|
||||
'#default_value' => !empty($data->booking_is_readinggroup) ? ($data->booking_is_readinggroup == 'Y' ? 1 : 0) : 0,
|
||||
);
|
||||
|
||||
if ($create == true)
|
||||
{
|
||||
//create the buttons
|
||||
if ($create == true) {
|
||||
$form['submit'] = array
|
||||
(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Create Study Group'),
|
||||
);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$form['Update'] = array
|
||||
(
|
||||
'#type' => 'submit',
|
||||
@@ -164,7 +158,7 @@ function booking_studygroups_define_form($node, &$form_state, $create, $editid =
|
||||
'#value' => t("Delete Study Group Definition"),
|
||||
);
|
||||
}
|
||||
|
||||
//return the render array
|
||||
return array (
|
||||
'first_para' => array (
|
||||
'#type' => 'markup',
|
||||
@@ -174,8 +168,7 @@ function booking_studygroups_define_form($node, &$form_state, $create, $editid =
|
||||
);
|
||||
}
|
||||
//confirm delete
|
||||
else
|
||||
{
|
||||
else {
|
||||
return confirm_form($form, "Are you sure you wish to delete studygroup definition with id " . $editid . "?",
|
||||
current_path(), NULL, "Delete Study Group Definition");
|
||||
}
|
||||
@@ -195,8 +188,7 @@ function booking_studygroups_define_form_submit($form, &$form_state) {
|
||||
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')
|
||||
{
|
||||
if ($form_state['values']['op'] == 'Create Study Group') {
|
||||
db_insert('booking_studygroup_list')
|
||||
->fields(array(
|
||||
'booking_eventid' => $event->eid,
|
||||
@@ -209,16 +201,14 @@ function booking_studygroups_define_form_submit($form, &$form_state) {
|
||||
$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'])))
|
||||
{
|
||||
elseif($form_state['values']['op'] == "Delete Study Group Definition" && (!isset($form_state['storage']['confirm']))) {
|
||||
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')
|
||||
{
|
||||
}
|
||||
elseif ($form_state['values']['op'] == 'Delete Study Group Definition') {
|
||||
//verify that booking_pid is a number
|
||||
if (! preg_match('/^[0-9]+$/', $values['booking_sid'])) {
|
||||
drupal_set_message("Error: Invalid studygroup ID supplied. Unable to delete entry.", 'error', FALSE);
|
||||
@@ -234,8 +224,7 @@ function booking_studygroups_define_form_submit($form, &$form_state) {
|
||||
|
||||
$new_count = $count->num - 1;
|
||||
}
|
||||
elseif ($form_state['values']['op'] == 'Update Study Group')
|
||||
{
|
||||
elseif ($form_state['values']['op'] == 'Update Study Group') {
|
||||
|
||||
//verify that booking_sid is a number
|
||||
if (! preg_match('/^[0-9]+$/', $values['booking_sid'])) {
|
||||
@@ -259,6 +248,8 @@ function booking_studygroups_define_form_submit($form, &$form_state) {
|
||||
|
||||
//update the number of study groups now defined
|
||||
variable_set('booking_studygroup_count', $new_count);
|
||||
|
||||
//call the mysql view update function so that the view matches the new number of study groups
|
||||
_booking_node_create_mysqlview();
|
||||
//redirect to the specified path now that the form has been processed
|
||||
$form_state['redirect'] = $redirect_path;
|
||||
}
|
Reference in New Issue
Block a user