| 1 |
<?php
|
| 2 |
// $Id: eventrepeat.install,v 1.10 2009/05/10 00:25:38 rmiddle Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Event Repeat install file
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_install().
|
| 11 |
*
|
| 12 |
* This will automatically install the database tables for the Event Repeat module for both the MySQL and PostgreSQL databases.
|
| 13 |
*
|
| 14 |
* If you are using another database, you will have to install the tables by hand, using the queries below as a reference.
|
| 15 |
*
|
| 16 |
* Note that the curly braces around table names are a drupal-specific feature to allow for automatic database table prefixing,
|
| 17 |
* and will need to be removed.
|
| 18 |
*/
|
| 19 |
function eventrepeat_install() {
|
| 20 |
global $user;
|
| 21 |
$result = drupal_install_schema('eventrepeat');
|
| 22 |
|
| 23 |
if (count($result) > 0) {
|
| 24 |
include_once(drupal_get_path('module', 'eventrepeat') . '/eventrepeat.module');
|
| 25 |
eventrepeat_cron();
|
| 26 |
drupal_set_message(t('Event Repeat module was successfully installed with default options. To customize event repeat options and settings, please visit the <a href="!settings">event repeat settings page</a>.', array('!settings' => url('admin/settings/eventrepeat'))));
|
| 27 |
watchdog('eventrepeat', 'Event repeat module successfully installed by !user.', array('!user' => theme('username', $user)));
|
| 28 |
}
|
| 29 |
else {
|
| 30 |
drupal_set_message(t('Table installation for the Event Repeat module was unsuccessful. The tables may need to be installed by hand. See the eventrepeat.install file for a list of the installation queries.'));
|
| 31 |
watchdog('eventrepeat', 'Event repeat module isntall failed for user: !user.', array('!user' => theme('username', $user)), WATCHDOG_ERROR);
|
| 32 |
}
|
| 33 |
}
|
| 34 |
|
| 35 |
/**
|
| 36 |
* Implementation of hook_schema().
|
| 37 |
*/
|
| 38 |
function eventrepeat_schema() {
|
| 39 |
|
| 40 |
$schema['eventrepeat'] = array(
|
| 41 |
'module' => 'eventrepeat',
|
| 42 |
'description' => t('Event Repeat Table.'),
|
| 43 |
'fields' => array(
|
| 44 |
'rid' => array(
|
| 45 |
'type' => 'int',
|
| 46 |
'size' => 'normal',
|
| 47 |
'not null' => TRUE,
|
| 48 |
'defailt' => '0',
|
| 49 |
'description' => t('rid'),
|
| 50 |
),
|
| 51 |
'repeat_data' => array(
|
| 52 |
'type' => 'text',
|
| 53 |
'size' => 'big',
|
| 54 |
'not null' => TRUE,
|
| 55 |
'description' => t('repeat_data'),
|
| 56 |
),
|
| 57 |
'repeat_RRULE' => array(
|
| 58 |
'type' => 'text',
|
| 59 |
'size' => 'big',
|
| 60 |
'not null' => TRUE,
|
| 61 |
'description' => t('repeat_RRULE'),
|
| 62 |
),
|
| 63 |
'repeat_COUNT_remaining' => array(
|
| 64 |
'type' => 'int',
|
| 65 |
'size' => 'normal',
|
| 66 |
'not null' => TRUE,
|
| 67 |
'defailt' => '-1',
|
| 68 |
'description' => t('repeat_COUNT_remaining'),
|
| 69 |
),
|
| 70 |
'repeat_start' => array(
|
| 71 |
'type' => 'datetime',
|
| 72 |
'not null' => TRUE,
|
| 73 |
'description' => t('repeat_start'),
|
| 74 |
),
|
| 75 |
'repeat_end' => array(
|
| 76 |
'type' => 'datetime',
|
| 77 |
'not null' => TRUE,
|
| 78 |
'description' => t('repeat_end'),
|
| 79 |
),
|
| 80 |
'repeat_last_rendered' => array(
|
| 81 |
'type' => 'datetime',
|
| 82 |
'not null' => TRUE,
|
| 83 |
'description' => t('repeat_last_rendered'),
|
| 84 |
),
|
| 85 |
),
|
| 86 |
'indexes' => array(
|
| 87 |
'repeat_start' => array('repeat_start'),
|
| 88 |
'repeat_end' => array('repeat_end'),
|
| 89 |
'repeat_last_rendered' => array('repeat_last_rendered')
|
| 90 |
),
|
| 91 |
'primary key' => array('rid')
|
| 92 |
);
|
| 93 |
$schema['eventrepeat_nodes'] = array(
|
| 94 |
'module' => 'eventrepeat',
|
| 95 |
'description' => t('Event Repeat Nodes Table.'),
|
| 96 |
'fields' => array(
|
| 97 |
'rid' => array(
|
| 98 |
'type' => 'int',
|
| 99 |
'size' => 'normal',
|
| 100 |
'not null' => TRUE,
|
| 101 |
'defailt' => '0',
|
| 102 |
'description' => t('rid'),
|
| 103 |
),
|
| 104 |
'nid' => array(
|
| 105 |
'description' => 'Node identifier',
|
| 106 |
'type' => 'int',
|
| 107 |
'unsigned' => TRUE,
|
| 108 |
'not null' => TRUE,
|
| 109 |
'default' => 0,
|
| 110 |
'description' => t('nid'),
|
| 111 |
),
|
| 112 |
'repeat_edited' => array(
|
| 113 |
'description' => 'Node identifier',
|
| 114 |
'type' => 'tiny',
|
| 115 |
'unsigned' => TRUE,
|
| 116 |
'not null' => TRUE,
|
| 117 |
'default' => 0,
|
| 118 |
'description' => t('nid'),
|
| 119 |
),
|
| 120 |
),
|
| 121 |
'indexes' => array(
|
| 122 |
'rid' => array('rid')
|
| 123 |
),
|
| 124 |
'primary key' => array('nid'),
|
| 125 |
);
|
| 126 |
$schema['eventrepeat_calendar_map'] = array(
|
| 127 |
'module' => 'eventrepeat',
|
| 128 |
'description' => t('Event Repeat Calendar Map Table.'),
|
| 129 |
'fields' => array(
|
| 130 |
'date_stamp' => array(
|
| 131 |
'type' => 'datetime',
|
| 132 |
'not null' => TRUE,
|
| 133 |
'description' => t('Date Stamp'),
|
| 134 |
),
|
| 135 |
'day_stamp' => array(
|
| 136 |
'description' => t('Day Stamp'),
|
| 137 |
'type' => 'char',
|
| 138 |
'length' => 15,
|
| 139 |
'not null' => FALSE,
|
| 140 |
'default' => '',
|
| 141 |
),
|
| 142 |
'day_of_week' => array(
|
| 143 |
'description' => t('Day of Week'),
|
| 144 |
'type' => 'char',
|
| 145 |
'length' => 2,
|
| 146 |
'not null' => FALSE,
|
| 147 |
'default' => '',
|
| 148 |
),
|
| 149 |
'day_in_month' => array(
|
| 150 |
'description' => t('Day in Month'),
|
| 151 |
'type' => 'char',
|
| 152 |
'length' => 3,
|
| 153 |
'not null' => FALSE,
|
| 154 |
'default' => '',
|
| 155 |
),
|
| 156 |
'day_in_month_R' => array(
|
| 157 |
'description' => t('Day in Month R'),
|
| 158 |
'type' => 'char',
|
| 159 |
'length' => 4,
|
| 160 |
'not null' => FALSE,
|
| 161 |
'default' => '',
|
| 162 |
),
|
| 163 |
'month_day' => array(
|
| 164 |
'description' => t('Month Day'),
|
| 165 |
'type' => 'char',
|
| 166 |
'length' => 2,
|
| 167 |
'not null' => FALSE,
|
| 168 |
'default' => '',
|
| 169 |
),
|
| 170 |
'month_day_R' => array(
|
| 171 |
'description' => t('Month Day R'),
|
| 172 |
'type' => 'char',
|
| 173 |
'length' => 3,
|
| 174 |
'not null' => FALSE,
|
| 175 |
'default' => '',
|
| 176 |
),
|
| 177 |
'month' => array(
|
| 178 |
'description' => t('Month'),
|
| 179 |
'type' => 'char',
|
| 180 |
'length' => 2,
|
| 181 |
'not null' => FALSE,
|
| 182 |
'default' => '',
|
| 183 |
),
|
| 184 |
'year_day' => array(
|
| 185 |
'description' => t('Year Day'),
|
| 186 |
'type' => 'char',
|
| 187 |
'length' => 3,
|
| 188 |
'not null' => FALSE,
|
| 189 |
'default' => '',
|
| 190 |
),
|
| 191 |
'year_day_R' => array(
|
| 192 |
'description' => t('Year Day R'),
|
| 193 |
'type' => 'char',
|
| 194 |
'length' => 4,
|
| 195 |
'not null' => FALSE,
|
| 196 |
'default' => '',
|
| 197 |
),
|
| 198 |
'week_number' => array(
|
| 199 |
'description' => t('Week Number'),
|
| 200 |
'type' => 'char',
|
| 201 |
'length' => 2,
|
| 202 |
'not null' => FALSE,
|
| 203 |
'default' => '',
|
| 204 |
),
|
| 205 |
'week_number_R' => array(
|
| 206 |
'description' => t('Week Number R'),
|
| 207 |
'type' => 'char',
|
| 208 |
'length' => 3,
|
| 209 |
'not null' => FALSE,
|
| 210 |
'default' => '',
|
| 211 |
),
|
| 212 |
),
|
| 213 |
'indexes' => array(
|
| 214 |
'day_of_week' => array('day_of_week'),
|
| 215 |
'day_in_month' => array('day_in_month'),
|
| 216 |
'day_in_month_R' => array('day_in_month_R'),
|
| 217 |
'month_day' => array('month_day'),
|
| 218 |
'month_day_R' => array('month_day_R'),
|
| 219 |
'month' => array('month'),
|
| 220 |
'year_day' => array('year_day'),
|
| 221 |
'year_day_R' => array('year_day_R'),
|
| 222 |
'week_number' => array('week_number'),
|
| 223 |
'week_number_R' => array('week_number_R'),
|
| 224 |
),
|
| 225 |
'primary key' => array(date_stamp),
|
| 226 |
);
|
| 227 |
return $schema;
|
| 228 |
}
|
| 229 |
|
| 230 |
/**
|
| 231 |
* UTF8 table update
|
| 232 |
* Drupal 5 update.
|
| 233 |
*/
|
| 234 |
function eventrepeat_update_1() {
|
| 235 |
return _system_update_utf8(array('event_repeat', 'event_repeat_nodes', 'event_repeat_calendar_map'));
|
| 236 |
}
|
| 237 |
|
| 238 |
|
| 239 |
/**
|
| 240 |
* Implementation of hook_uninstall().
|
| 241 |
*/
|
| 242 |
function eventrepeat_uninstall() {
|
| 243 |
global $user;
|
| 244 |
|
| 245 |
drupal_uninstall_schema('eventrepeat');
|
| 246 |
|
| 247 |
variable_del('eventrepeat_title_tag');
|
| 248 |
variable_del('eventrepeat_initial_render');
|
| 249 |
variable_del('eventrepeat_render_support');
|
| 250 |
variable_del('eventrepeat_single_edit_in_sequence');
|
| 251 |
variable_del('eventrepeat_maximum_rows');
|
| 252 |
variable_del('eventrepeat_default_edit_type');
|
| 253 |
variable_del('eventrepeat_showadvanced');
|
| 254 |
variable_del('eventrepeat_dateform_order');
|
| 255 |
foreach (node_get_types() as $type => $info) {
|
| 256 |
variable_del('eventrepeat_nodeapi_'. $type);
|
| 257 |
}
|
| 258 |
|
| 259 |
drupal_set_message(t('Event Repeat module uninstalled.'));
|
| 260 |
// Add a watchdog message
|
| 261 |
watchdog('eventrepeat', 'Event repeat module successfully uninstalled by !user.', array('!user' => theme('username', $user)));
|
| 262 |
|
| 263 |
}
|