office_hours.install in Office Hours 6
File
office_hours.install
View source
<?php
function office_hours_install() {
drupal_load('module', 'content');
content_notify('install', 'office_hours');
}
function office_hours_uninstall() {
drupal_load('module', 'content');
content_notify('uninstall', 'office_hours');
}
function office_hours_enable() {
drupal_load('module', 'content');
content_notify('enable', 'office_hours');
}
function office_hours_disable() {
drupal_load('module', 'content');
content_notify('disable', 'office_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;
}