/[drupal]/contributions/modules/publicbookings/publicbookings.admin.inc
ViewVC logotype

Diff of /contributions/modules/publicbookings/publicbookings.admin.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.10, Mon Aug 18 19:57:49 2008 UTC revision 1.11, Wed Oct 1 02:44:18 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: publicbookings.admin.inc,v 1.9 2008/08/18 10:01:03 carson Exp $  // $Id: publicbookings.admin.inc,v 1.10 2008/08/18 19:57:49 carson Exp $
3  /**  /**
4   * @file   * @file
5   * Administrative forms and callbacks.   * Administrative forms and callbacks.
# Line 13  function publicbookings_overview_page() Line 13  function publicbookings_overview_page()
13    include_once('publicbookings.views_default.inc');    include_once('publicbookings.views_default.inc');
14    $text = '<h3>'.t('Awaiting approval').'</h3>';    $text = '<h3>'.t('Awaiting approval').'</h3>';
15    $view = publicbookings_view_schedules_admin();    $view = publicbookings_view_schedules_admin();
16      //echo '<pre>';
17      //print_r($view);
18      //echo '</pre>';
19    $text .= $view->preview(NULL, array(1)); // first argument is the status code    $text .= $view->preview(NULL, array(1)); // first argument is the status code
20    $text .= '<h3>'.t('Finalized').'</h3>';    $text .= '<h3>'.t('Finalized').'</h3>';
21    $view = publicbookings_view_schedules_admin();    $view = publicbookings_view_schedules_admin();
# Line 103  function publicbookings_booking_form(&$f Line 106  function publicbookings_booking_form(&$f
106   * @param array $form_state   * @param array $form_state
107   */   */
108  function publicbookings_booking_form_validate($form, &$form_state) {  function publicbookings_booking_form_validate($form, &$form_state) {
109    if(!empty($form_state['values']['ical_rrule'])) {    // If we're deleting, conflicts and validity don't matter.
110      if ($form_state['values']['op'] == t('Delete')) return;
111    
112      if (!empty($form_state['values']['ical_rrule'])) {
113      $form_state['values']['ical_rrule_until'] = bookingsapi_rrule_until_as_dt($form_state['values']['ical_rrule']);      $form_state['values']['ical_rrule_until'] = bookingsapi_rrule_until_as_dt($form_state['values']['ical_rrule']);
114      if(empty($form_state['values']['ical_rrule_until'])) {      if(empty($form_state['values']['ical_rrule_until'])) {
115        form_set_error('ical_rrule', t('Recurrences must have an end date.'));        form_set_error('ical_rrule', t('Recurrences must have an end date.'));
116      }      }
117    }    }
118    publicbookings_conflict_check($form_state['values']);    publicbookings_conflict_check($form_state['values']);
119    if($form_state['values']['count_certain_conflicts'] > 0) {    if ($form_state['values']['count_certain_conflicts'] > 0) {
120      form_set_error('basic', $form_state['values']['html_certain_conflicts']);      form_set_error('basic', $form_state['values']['html_certain_conflicts']);
121    }    }
122  }  }
123    
124  function publicbookings_booking_form_submit($form, &$form_state) {  function publicbookings_booking_form_submit($form, &$form_state) {
125      // If we're deleting, redirect to the deletion page immediately.
126      if ($form_state['values']['op'] == t('Delete')) {
127        $form_state['redirect'] = array('admin/content/publicbookings/booking/'.$form_state['values']['record_id'].'/delete');
128        return;
129      }
130    
131    $save_result = publicbookings_booking_save($form_state['values']);    $save_result = publicbookings_booking_save($form_state['values']);
132    $t_args = array('%name' => $form_state['values']['name']);    $t_args = array('%name' => $form_state['values']['name']);
133    // no message for BOOKINGSAPI_TIME_CONFLICT, as we should have prevented it before we got here    // no message for BOOKINGSAPI_TIME_CONFLICT, as we should have prevented it before we got here
# Line 220  function publicbookings_resource_delete_ Line 232  function publicbookings_resource_delete_
232  function publicbookings_resource_form(&$form_state, $resource = array()) {  function publicbookings_resource_form(&$form_state, $resource = array()) {
233    include_once('./'. drupal_get_path('module', 'bookingsapi') .'/bookingsapi.forms.inc');    include_once('./'. drupal_get_path('module', 'bookingsapi') .'/bookingsapi.forms.inc');
234    $form = bookingsapi_resource_form($resource);    $form = bookingsapi_resource_form($resource);
235    if(!empty($resource)) $form['delete']['#submit'] = array('publicbookings_resource_delete');    if (!empty($resource)) $form['delete']['#submit'] = array('publicbookings_resource_delete');
236    $form['#submit'] = array('publicbookings_resource_form_submit');    $form['#submit'] = array('publicbookings_resource_form_submit');
237    $form['#validate'] = array('publicbookings_resource_form_validate');    $form['#validate'] = array('publicbookings_resource_form_validate');
238    return $form;    return $form;
# Line 337  function publicbookings_availability_for Line 349  function publicbookings_availability_for
349    
350  // temporarily identical to booking equivalent  // temporarily identical to booking equivalent
351  function publicbookings_availability_form_validate($form, &$form_state) {  function publicbookings_availability_form_validate($form, &$form_state) {
352  if(!empty($form_state['values']['ical_rrule'])) {    // If we're deleting, conflicts and validity don't matter.
353      if ($form_state['values']['op'] == t('Delete')) return;
354    
355      if (!empty($form_state['values']['ical_rrule'])) {
356      $form_state['values']['ical_rrule_until'] = bookingsapi_rrule_until_as_dt($form_state['values']['ical_rrule']);      $form_state['values']['ical_rrule_until'] = bookingsapi_rrule_until_as_dt($form_state['values']['ical_rrule']);
357      if(empty($form_state['values']['ical_rrule_until'])) {      if(empty($form_state['values']['ical_rrule_until'])) {
358        form_set_error('ical_rrule', t('Recurrences must have an end date.'));        form_set_error('ical_rrule', t('Recurrences must have an end date.'));
359      }      }
360    }    }
361    if($form_state['values']['type'] == BOOKINGSAPI_UNA_R) {    if ($form_state['values']['type'] == BOOKINGSAPI_UNA_R) {
362      $fields = '{bookings_records}.name, {bookings_schedules}.type, {bookings_schedules}.`start`, {bookings_schedules}.`end`';      $fields = '{bookings_records}.name, {bookings_schedules}.type, {bookings_schedules}.`start`, {bookings_schedules}.`end`';
363      $conflicts = bookingsapi_conflict_check($form_state['values'], $fields, 10);      $conflicts = bookingsapi_conflict_check($form_state['values'], $fields, 10);
364      if (count($conflicts) > 0) {      if (count($conflicts) > 0) {
# Line 362  if(!empty($form_state['values']['ical_rr Line 377  if(!empty($form_state['values']['ical_rr
377    
378  // temporarily identical to booking equivalent  // temporarily identical to booking equivalent
379  function publicbookings_availability_form_submit($form, &$form_state) {  function publicbookings_availability_form_submit($form, &$form_state) {
380      // If we're deleting, redirect to the deletion page immediately.
381      if ($form_state['values']['op'] == t('Delete')) {
382        $form_state['redirect'] = array('admin/content/publicbookings/availability/'.$form_state['values']['record_id'].'/delete');
383        return;
384      }
385    
386    $save_result = bookingsapi_availability_save($form_state['values']);    $save_result = bookingsapi_availability_save($form_state['values']);
387    $t_args = array('%name' => $form_state['values']['name']);    $t_args = array('%name' => $form_state['values']['name']);
388    // no message for BOOKINGSAPI_TIME_CONFLICT, as we should have prevented it before we got here    // no message for BOOKINGSAPI_TIME_CONFLICT, as we should have prevented it before we got here

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.2