/[drupal]/contributions/modules/office_hours/office_hours.module
ViewVC logotype

Diff of /contributions/modules/office_hours/office_hours.module

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

revision 1.1.2.1.2.8, Sat May 2 09:51:28 2009 UTC revision 1.1.2.1.2.9, Sat Jun 27 17:48:58 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: office_hours.module,v 1.1.2.1.2.2 2008/08/08 16:08:50 ozeuss Exp $  // $Id: office_hours.module,v 1.1.2.1.2.8 2009/05/02 09:51:28 ozeuss Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 59  if ($form_id == 'content_field_edit_form Line 59  if ($form_id == 'content_field_edit_form
59   */   */
60  function office_hours_init () {  function office_hours_init () {
61      drupal_add_css(drupal_get_path('module', 'office_hours') .'/office_hours.css');      drupal_add_css(drupal_get_path('module', 'office_hours') .'/office_hours.css');
62        /*drupal_add_js(drupal_get_path('module', 'office_hours') .'/office_hours.js','theme');*/
63  }  }
64    
65  /**  /**
66   * Implementation of hook_content_is_empty().   * Implementation of hook_content_is_empty().
67   */   */
68  function office_hours_content_is_empty($item, $field) {  function office_hours_content_is_empty($item, $field) {
69    if ( $item['starthours'] == 0 || $item['endhours'] == 0 || !isset($item['day']) )  {    if ( $item['starthours'] == '' || $item['endhours'] == '' || !isset($item['day']) )  {
70      return TRUE;      return TRUE;
71    }    }
72    return FALSE;    return FALSE;
# Line 100  function office_hours_field_settings($op Line 101  function office_hours_field_settings($op
101    switch ($op) {    switch ($op) {
102      case 'form':      case 'form':
103      $options = _office_hours_create_hours_arr($field, FALSE);      $options = _office_hours_create_hours_arr($field, FALSE);
     $optlim =  _office_hours_create_hours_arr($field);  
104        $form = array();        $form = array();
105        $form['hoursformat'] = array(        $form['hoursformat'] = array(
106          '#type' => 'select',          '#type' => 'select',
# Line 118  function office_hours_field_settings($op Line 118  function office_hours_field_settings($op
118          '#required' => FALSE,          '#required' => FALSE,
119          '#description' => t('Allow inserting quarter hours, half hours, or only hours of the day'),          '#description' => t('Allow inserting quarter hours, half hours, or only hours of the day'),
120        );        );
121         $form['limitstart'] = array(        $form['limitstart'] = array (
122            '#type' => 'office_hours_select',
123            '#title' => t('Limit widget start hours'),
124            '#default_value' => '',//$field['limitstart']? $field['limitstart'] : '',
125            '#granularity' => $field['granularity'],
126            '#hoursformat' => $field['hoursformat'],
127            '#prefix' => '<div class="office-hours-block" style="display:inline">',
128          );
129           $form['limitend'] = array(
130            '#type' => 'office_hours_select',
131            '#title' => t('Limit widget end hours'),
132            '#default_hours' => '',//$field['limitend']? $field['limitend'] : '',
133            '#granularity' => $field['granularity'],
134            '#hoursformat' => $field['hoursformat'],
135            '#suffix' => '</div>',
136          );
137    
138      /*     $form['limitstart'] = array(
139          '#type' => 'select',          '#type' => 'select',
140          '#title' => t('Limit widget start hours'),          '#title' => t('Limit widget start hours'),
141          '#options' => $options,          '#options' => $options,
# Line 133  function office_hours_field_settings($op Line 150  function office_hours_field_settings($op
150          '#default_value' => $field['limitend'] ? $field['limitend'] : FALSE,          '#default_value' => $field['limitend'] ? $field['limitend'] : FALSE,
151          '#required' => FALSE,          '#required' => FALSE,
152          '#description' => t('Set the allowed end hours. Note: if you just changed the clock format, please submit before changing this'),          '#description' => t('Set the allowed end hours. Note: if you just changed the clock format, please submit before changing this'),
       );  
        /* $form['defaultstart'] = array(  
         '#type' => 'select',  
         '#title' => t('Start hours default'),  
         '#options' => $optlim,  
         '#default_value' => $field['defaultstart']? $field['defaultstart'] : FALSE,  
         '#required' => FALSE,  
         '#description' => t('Use this field if you want for specific hours to show by default. Set this AFTER submitting hour limits.'),  
       );  
        $form['defaultend'] = array(  
         '#type' => 'select',  
         '#title' => t('End hours default'),  
         '#options' => $optlim,  
         '#default_value' => $field['defaultend'] ? $field['defaultend'] : FALSE,  
         '#required' => FALSE,  
         '#description' => t('Use this field if you want for specific hours to show by default Set this AFTER submitting hour limits.'),  
153        );*/        );*/
154        $form['valhrs'] = array(        $form['valhrs'] = array(
155          '#type' => 'checkbox',          '#type' => 'checkbox',
# Line 160  function office_hours_field_settings($op Line 161  function office_hours_field_settings($op
161        return $form;        return $form;
162    
163    case 'validate':    case 'validate':
164          /*if ($field['defaultend']<= $field['defaultstart'] && $field['defaultend'] !='none' && $field['defaultstart'] !='none') {         /* if ( $field['limitend'] <= $field['limitstart'] && $field['limitend'] != 'none'  && $field['limitstart'] !='none') {
           form_set_error('defaultend','Default ending hours are earlier than start hours');  
         }*/  
         if ( $field['limitend'] <= $field['limitstart'] && $field['limitend'] != 'none'  && $field['limitstart'] !='none') {  
165              form_set_error('limitend','Limit ending hours are earlier than start hours');              form_set_error('limitend','Limit ending hours are earlier than start hours');
166          }          }*/
167       break;       break;
168    
169      case 'save':      case 'save':
# Line 216  function office_hours_field_settings($op Line 214  function office_hours_field_settings($op
214      break;      break;
215      case 'insert':      case 'insert':
216      case 'update':      case 'update':
  //   dpm($items);  
217      $items = _office_hours_set_weight($items);      $items = _office_hours_set_weight($items);
218      break;      break;
219    }    }
# Line 342  function _office_hours_tf_to_mil($hour) Line 339  function _office_hours_tf_to_mil($hour)
339    return $hr;    return $hr;
340  }  }
341    
342  function _office_hours_mil_to_tf($time){  function _office_hours_mil_to_tf ($time = ''){
343  $hour = (substr($time,0,-2)) ? substr($time,0,-2): '0';  $hour = (substr($time,0,-2)) ? substr($time,0,-2): '0';
344  $min = (substr($time,-2)) ? substr($time,-2): '00';  $min = (substr($time,-2)) ? substr($time,-2): '00';
345  return $hour.":".$min;  return $hour.":".$min;

Legend:
Removed from v.1.1.2.1.2.8  
changed lines
  Added in v.1.1.2.1.2.9

  ViewVC Help
Powered by ViewVC 1.1.2