You are here

office_hours.install in Office Hours 6

Same filename and directory in other branches
  1. 8 office_hours.install
  2. 6.2 office_hours.install
  3. 7 office_hours.install

File

office_hours.install
View source
<?php

/**
 * Implementation of hook_install().
 */
function office_hours_install() {
  drupal_load('module', 'content');
  content_notify('install', 'office_hours');
}

/**
 * Implementation of hook_uninstall().
 */
function office_hours_uninstall() {
  drupal_load('module', 'content');
  content_notify('uninstall', 'office_hours');
}

/**
 * Implementation of hook_enable().
 */
function office_hours_enable() {
  drupal_load('module', 'content');
  content_notify('enable', 'office_hours');
}

/**
 * Implementation of hook_disable().
 */
function office_hours_disable() {
  drupal_load('module', 'content');
  content_notify('disable', 'office_hours');
}

/* We want to use integers on hours*/
function office_hours_update_6000() {
  drupal_load('module', 'content');
  $ret = array();
  $result = db_query("SELECT * FROM {" . content_instance_tablename() . "} WHERE widget_type = 'office_hours'");
  while ($field_instance = db_fetch_object($result)) {
    $name = $field_instance->field_name;
    $old = db_query("SELECT * FROM {content_" . $name . "}");
    while ($field = db_fetch_array($old)) {
      list($hr, $min) = explode(":", $field->{$name} . "_starthours");
      $start = $hr . $min;
      list($hr, $min) = explode(":", $field->{$name} . "_endhours");
      $end = $hr . $min;
      $ret[] = update_sql("UPDATE {content_" . $name . "} SET " . $name . "_starthours = " . $start . "," . $name . "_endhours = " . $end . " WHERE nid = %d AND delta = %d", $field->nid, $field->data);
    }
    $ret[] = update_sql("ALTER TABLE {content_" . $name . "} CHANGE `" . $name . "_starthours` `" . $name . "_starthours` INT( 4 ) NULL DEFAULT NULL");
    $ret[] = update_sql("ALTER TABLE {content_" . $name . "} CHANGE `" . $name . "_endhours` `" . $name . "_endhours` INT( 4 ) NULL DEFAULT NULL");
  }
  content_clear_type_cache();
  return $ret;
}

Functions

Namesort descending Description
office_hours_disable Implementation of hook_disable().
office_hours_enable Implementation of hook_enable().
office_hours_install Implementation of hook_install().
office_hours_uninstall Implementation of hook_uninstall().
office_hours_update_6000