| 1 |
<?php
|
| 2 |
|
| 3 |
// $Id$
|
| 4 |
|
| 5 |
/**
|
| 6 |
* Implementation of hook_install().
|
| 7 |
*/
|
| 8 |
function volunteer_install() {
|
| 9 |
drupal_set_message('Installing volunteer');
|
| 10 |
switch ($GLOBALS['db_type']) {
|
| 11 |
case 'mysqli':
|
| 12 |
case 'mysql':
|
| 13 |
db_query("
|
| 14 |
CREATE TABLE {volunteer} (
|
| 15 |
nid int(10) unsigned NOT NULL default '0',
|
| 16 |
wanted int(3) default '2',
|
| 17 |
uid int(11) default NULL,
|
| 18 |
message_approve text,
|
| 19 |
message_deny text,
|
| 20 |
message_wait text,
|
| 21 |
message_reminder text,
|
| 22 |
message_follow_up text,
|
| 23 |
PRIMARY KEY (nid)
|
| 24 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
|
| 25 |
db_query("
|
| 26 |
CREATE TABLE {volunteer_contact_event} (
|
| 27 |
cid int(10) unsigned NOT NULL default '0',
|
| 28 |
timestamp int(10) unsigned NOT NULL default '0',
|
| 29 |
rating int(2) default NULL,
|
| 30 |
comments text,
|
| 31 |
nid int(10) unsigned NOT NULL default '0',
|
| 32 |
stage int(2) unsigned default NULL,
|
| 33 |
PRIMARY KEY (nid, cid)
|
| 34 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
|
| 35 |
|
| 36 |
$success = TRUE;
|
| 37 |
break;
|
| 38 |
case 'pgsql':
|
| 39 |
break;
|
| 40 |
default:
|
| 41 |
break;
|
| 42 |
} // End case
|
| 43 |
|
| 44 |
// Execute update 1 to fix form fields
|
| 45 |
volunteer_update_1();
|
| 46 |
|
| 47 |
if ($success) {
|
| 48 |
drupal_set_message(t('Volunteer module installed tables successfully.'));
|
| 49 |
}
|
| 50 |
else {
|
| 51 |
drupal_set_message(t('The installation of volunteer module was unsuccessful.'), 'error');
|
| 52 |
}
|
| 53 |
}
|
| 54 |
|
| 55 |
/**
|
| 56 |
* From CiviCRM 1.3 to 1.4, profile field labels get lost; put them back
|
| 57 |
*
|
| 58 |
* Table prefixes intentionally omitted, because these are CiviCRM tables
|
| 59 |
*/
|
| 60 |
function volunteer_update_1() {
|
| 61 |
db_set_active('civicrm');
|
| 62 |
db_query("UPDATE civicrm_uf_field SET label = 'First Name', field_type = 'Individual' WHERE field_name = 'first_name'");
|
| 63 |
db_query("UPDATE civicrm_uf_field SET label = 'Last Name', field_type = 'Individual' WHERE field_name = 'last_name'");
|
| 64 |
db_query("UPDATE civicrm_uf_field SET label = 'Email (Home)', field_type = 'Individual' WHERE field_name = 'email'");
|
| 65 |
db_set_active();
|
| 66 |
}
|