/[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.10, Sat Aug 29 07:49:16 2009 UTC revision 1.1.2.1.2.11, Sun Nov 1 14:49:36 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: office_hours.module,v 1.1.2.1.2.9 2009/06/27 17:48:58 ozeuss Exp $  // $Id: office_hours.module,v 1.1.2.1.2.10 2009/08/29 07:49:16 mikl Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 34  function office_hours_theme() { Line 34  function office_hours_theme() {
34   * Implementation of hook_form_alter().   * Implementation of hook_form_alter().
35   */   */
36  function office_hours_form_alter(&$form, &$form_state, $form_id) {  function office_hours_form_alter(&$form, &$form_state, $form_id) {
37  if ($form_id == 'content_field_edit_form') {    if ($form_id == 'content_field_edit_form') {
38      if($form['#field']['type'] == 'office_hours') {      if($form['#field']['type'] == 'office_hours') {
39        $description = t('Number of field that will show.');        $description = t('14 hours blocks is the current default. see below for limiting it');
40        $description .= '<br/><strong>'. t('Warning! Changing this setting after data has been created could result in the loss of data!') .'</strong>';        $description .= '<br/><strong>'. t('Warning! Changing this setting after data has been created could result in the loss of data!') .'</strong>';
41          $form['field']['multiple'] = array(          $form['field']['multiple'] = array(
42            '#type' => 'select',            '#type' => 'select',
43            '#title' => t('Number of values'),            '#title' => t('Number of values'),
44            '#options' => drupal_map_assoc(array(7,14)),            '#options' => drupal_map_assoc(array(14)),
45            '#default_value' => isset($form['field']['multiple']) ? $form['field']['multiple'] : 7,            '#default_value' => 14,
46            '#description' => $description,            '#description' => $description,
47          );          );
48      }      }
49    }    }
50    if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {    if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
# Line 62  if ($form_id == 'content_field_edit_form Line 62  if ($form_id == 'content_field_edit_form
62   */   */
63  function office_hours_init () {  function office_hours_init () {
64      drupal_add_css(drupal_get_path('module', 'office_hours') .'/office_hours.css');      drupal_add_css(drupal_get_path('module', 'office_hours') .'/office_hours.css');
65      /*drupal_add_js(drupal_get_path('module', 'office_hours') .'/office_hours.js','theme');*/      //drupal_add_js(drupal_get_path('module', 'office_hours') .'/office_hours.js','theme');
66  }  }
67    
68  /**  /**
# Line 117  function office_hours_field_settings($op Line 117  function office_hours_field_settings($op
117        $form['granularity'] = array(        $form['granularity'] = array(
118          '#type' => 'select',          '#type' => 'select',
119          '#title' => t('granularity of time'),          '#title' => t('granularity of time'),
120          '#options' => array ( '0' => t('Hours'), '30' => t('Half hours'), '15' => t('Quarter hours') ),          '#options' => array ( '60' => t('Hours'), '30' => t('Half hours'), '15' => t('Quarter hours') ),
121          '#default_value' => $field['granularity'] ? $field['granularity'] : 0,          '#default_value' => $field['granularity'] ? $field['granularity'] : 0,
122          '#required' => FALSE,          '#required' => FALSE,
123          '#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'),
# Line 138  function office_hours_field_settings($op Line 138  function office_hours_field_settings($op
138          '#hoursformat' => $field['hoursformat'],          '#hoursformat' => $field['hoursformat'],
139          '#suffix' => '</div>',          '#suffix' => '</div>',
140        );        );
   
   /*     $form['limitstart'] = array(  
         '#type' => 'select',  
         '#title' => t('Limit widget start hours'),  
         '#options' => $options,  
         '#default_value' => $field['limitstart']? $field['limitstart'] : FALSE,  
         '#required' => FALSE,  
         '#description' => t('Set the allowed start hours. Note: if you just changed the clock format, please submit before changing this.'),  
       );  
        $form['limitend'] = array(  
         '#type' => 'select',  
         '#title' => t('Limit widget end hours'),  
         '#options' => $options,  
         '#default_value' => $field['limitend'] ? $field['limitend'] : FALSE,  
         '#required' => FALSE,  
         '#description' => t('Set the allowed end hours. Note: if you just changed the clock format, please submit before changing this'),  
       );*/  
141        $form['valhrs'] = array(        $form['valhrs'] = array(
142          '#type' => 'checkbox',          '#type' => 'checkbox',
143          '#title' => t('Validate hours'),          '#title' => t('Validate hours'),
# Line 162  function office_hours_field_settings($op Line 145  function office_hours_field_settings($op
145          '#default_value' => isset($field['valhrs']) ? $field['valhrs'] : 0,          '#default_value' => isset($field['valhrs']) ? $field['valhrs'] : 0,
146          '#description' => t('Please note that this will work as long as the opening hours are not through midnight.'),          '#description' => t('Please note that this will work as long as the opening hours are not through midnight.'),
147        );        );
148           $form['addhrs'] = array(
149            '#type' => 'checkbox',
150            '#title' => t('Display the "Add more hours" link'),
151            '#required' => FALSE,
152            '#default_value' => isset($field['addhrs']) ? $field['addhrs'] : 1,
153            '#description' => t('Make it possible to use 2 hour block for each day instead of one'),
154          );
155        return $form;        return $form;
156    
157    case 'validate':    case 'validate':
# Line 171  function office_hours_field_settings($op Line 161  function office_hours_field_settings($op
161       break;       break;
162    
163      case 'save':      case 'save':
164        return array('hoursformat', 'granularity', 'limitstart', 'limitend', 'valhrs');        return array('hoursformat', 'granularity', 'limitstart', 'limitend', 'valhrs','addhrs');
165    
166      case 'database columns':      case 'database columns':
167        $columns = array(        $columns = array(
# Line 298  function _office_hours_arrange_day ($ite Line 288  function _office_hours_arrange_day ($ite
288  /**  /**
289   * helper function to create hours array.   * helper function to create hours array.
290   * items are saved in 24 hours string format (i.e '18:00').   * items are saved in 24 hours string format (i.e '18:00').
291   */   *//* we're using date_api now
292   function _office_hours_create_hours_arr($field = array(), $limit = TRUE) {   function _office_hours_create_hours_arr($field = array(), $limit = TRUE) {
293    $ophours['none'] = t('None');    $ophours['none'] = t('None');
294    $start = ($field['limitstart'] != 'none') ? $field['limitstart']: 0;    $start = ($field['limitstart'] != 'none') ? $field['limitstart']: 0;
# Line 311  function _office_hours_arrange_day ($ite Line 301  function _office_hours_arrange_day ($ite
301      $ophours[$i] = ($field['hoursformat']) ? _office_hours_mil_to_tf($i) :  _office_hours_convert_to_ampm($i);      $ophours[$i] = ($field['hoursformat']) ? _office_hours_mil_to_tf($i) :  _office_hours_convert_to_ampm($i);
302    }    }
303    return $ophours;    return $ophours;
304  }  }*/
305    
306  /**  /**
307   * Helper function for conversion of clock format.   * Helper function for conversion of clock format.
# Line 348  function _office_hours_tf_to_mil($hour) Line 338  function _office_hours_tf_to_mil($hour)
338    return $hr;    return $hr;
339  }  }
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';

Legend:
Removed from v.1.1.2.1.2.10  
changed lines
  Added in v.1.1.2.1.2.11

  ViewVC Help
Powered by ViewVC 1.1.2