-
Notifications
You must be signed in to change notification settings - Fork 1
/
office_hours.install
52 lines (47 loc) · 1.69 KB
/
office_hours.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
include_once('./'. drupal_get_path('module', 'content') .'/content.module');
/**
* Implementation of hook_install().
*/
function office_hours_install() {
content_notify('install', 'office_hours');
}
/**
* Implementation of hook_uninstall().
*/
function office_hours_uninstall() {
content_notify('uninstall', 'office_hours');
}
/**
* Implementation of hook_enable().
*/
function office_hours_enable() {
content_notify('enable', 'office_hours');
}
/**
* Implementation of hook_disable().
*/
function office_hours_disable() {
content_notify('disable', 'office_hours');
}
/* We want to use integers on hours*/
function office_hours_update_6000() {
$ret = array();
drupal_load('module', 'content');
$result = db_query("SELECT * FROM {". content_instance_tablename() ."} WHERE widget_module = '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*60+$min;
list($hr, $min) = explode(":",$field->$name."_endhours");
$end = $hr*60+$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;
}