| 1 |
<?php |
<?php |
| 2 |
include_once('./'. drupal_get_path('module', 'content') .'/content.module'); |
// $Id$ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Implementation of hook_install(). |
* Implementation of hook_install(). |
| 6 |
*/ |
*/ |
| 7 |
function office_hours_install() { |
function office_hours_install() { |
| 8 |
content_notify('install', 'office_hours'); |
drupal_load('module', 'content'); |
| 9 |
|
content_notify('install', 'office_hours'); |
| 10 |
} |
} |
| 11 |
|
|
| 12 |
/** |
/** |
| 13 |
* Implementation of hook_uninstall(). |
* Implementation of hook_uninstall(). |
| 14 |
*/ |
*/ |
| 15 |
function office_hours_uninstall() { |
function office_hours_uninstall() { |
| 16 |
content_notify('uninstall', 'office_hours'); |
drupal_load('module', 'content'); |
| 17 |
|
content_notify('uninstall', 'office_hours'); |
| 18 |
} |
} |
| 19 |
|
|
| 20 |
/** |
/** |
| 21 |
* Implementation of hook_enable(). |
* Implementation of hook_enable(). |
| 22 |
*/ |
*/ |
| 23 |
function office_hours_enable() { |
function office_hours_enable() { |
| 24 |
content_notify('enable', 'office_hours'); |
drupal_load('module', 'content'); |
| 25 |
|
content_notify('enable', 'office_hours'); |
| 26 |
} |
} |
| 27 |
|
|
| 28 |
/** |
/** |
| 29 |
* Implementation of hook_disable(). |
* Implementation of hook_disable(). |
| 30 |
*/ |
*/ |
| 31 |
function office_hours_disable() { |
function office_hours_disable() { |
| 32 |
|
drupal_load('module', 'content'); |
| 33 |
content_notify('disable', 'office_hours'); |
content_notify('disable', 'office_hours'); |
| 34 |
} |
} |
| 35 |
|
|
| 36 |
/* We want to use integers on hours*/ |
/* We want to use integers on hours*/ |
| 37 |
function office_hours_update_6000() { |
function office_hours_update_6000() { |
| 38 |
|
drupal_load('module', 'content'); |
| 39 |
$ret = array(); |
$ret = array(); |
| 40 |
|
|
|
drupal_load('module', 'content'); |
|
| 41 |
$result = db_query("SELECT * FROM {". content_instance_tablename() ."} WHERE widget_type = 'office_hours'"); |
$result = db_query("SELECT * FROM {". content_instance_tablename() ."} WHERE widget_type = 'office_hours'"); |
| 42 |
while ($field_instance = db_fetch_object($result)) { |
while ($field_instance = db_fetch_object($result)) { |
| 43 |
$name = $field_instance->field_name; |
$name = $field_instance->field_name; |
| 44 |
$old = db_query("SELECT * FROM {content_".$name."}"); |
$old = db_query("SELECT * FROM {content_" . $name . "}"); |
| 45 |
while ($field = db_fetch_array($old)) { |
|
| 46 |
list($hr, $min) = explode(":",$field->$name."_starthours"); |
while ($field = db_fetch_array($old)) { |
| 47 |
$start = $hr*60+$min; |
list($hr, $min) = explode(":", $field->$name . "_starthours"); |
| 48 |
list($hr, $min) = explode(":",$field->$name."_endhours"); |
$start = $hr * 60 + $min; |
| 49 |
$end = $hr*60+$min; |
list($hr, $min) = explode(":", $field->$name . "_endhours"); |
| 50 |
$ret[] = update_sql("UPDATE {content_".$name."} SET ".$name."_starthours = ".$start.",".$name."_endhours = ".$end." WHERE nid = %d AND delta = %d", $field->nid, $field->data); |
$end = $hr * 60 + $min; |
| 51 |
} |
$ret[] = update_sql("UPDATE {content_" . $name . "} SET " . $name . "_starthours = " . $start . "," . $name . "_endhours = " . $end . " WHERE nid = %d AND delta = %d", $field->nid, $field->data); |
| 52 |
$ret[] = update_sql("ALTER TABLE {content_".$name."} CHANGE `".$name."_starthours` `".$name."_starthours` INT( 4 ) NULL DEFAULT NULL"); |
} |
| 53 |
$ret[] = update_sql("ALTER TABLE {content_".$name."} CHANGE `".$name."_endhours` `".$name."_endhours` INT( 4 ) NULL DEFAULT NULL"); |
|
| 54 |
|
$ret[] = update_sql("ALTER TABLE {content_" . $name . "} CHANGE `" . $name . "_starthours` `" . $name . "_starthours` INT( 4 ) NULL DEFAULT NULL"); |
| 55 |
|
|
| 56 |
|
$ret[] = update_sql("ALTER TABLE {content_" . $name . "} CHANGE `" . $name . "_endhours` `" . $name . "_endhours` INT( 4 ) NULL DEFAULT NULL"); |
| 57 |
|
|
| 58 |
} |
} |
| 59 |
content_clear_type_cache(); |
content_clear_type_cache(); |
| 60 |
return $ret; |
return $ret; |
| 61 |
} |
} |
| 62 |
|
|