/[drupal]/contributions/modules/resource_conflict/resource_conflict.install
ViewVC logotype

Contents of /contributions/modules/resource_conflict/resource_conflict.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Wed Dec 10 17:29:50 2008 UTC (11 months, 2 weeks ago) by deviantintegral
Branch: MAIN
CVS Tags: DRUPAL-6--2-0-RC1, DRUPAL-6--2-0, HEAD
Changes since 1.1: +51 -0 lines
File MIME type: text/x-php
Merging DRUPAL-5--2 back to HEAD for Drupal 6 branch.
1 <?php
2 // $Id
3
4 /**
5 * Implementation of hook_uninstall
6 */
7 function resource_conflict_uninstall() {
8 _resource_conflict_variable_delete_like('rc_type_%');
9 _resource_conflict_variable_delete_like('rc_date_field_%');
10 _resource_conflict_variable_delete_like('rc_reference_fields_%');
11
12 variable_del('rc_types');
13 }
14
15 /**
16 * Update from version 1.x to version 2.x.
17 */
18 function resource_conflict_update_5200() {
19 $ret = array();
20
21 // Rename all resource_conflict_$type variables to rc_type_$type
22 $q = "SELECT name FROM {variable} WHERE name LIKE 'resource_conflict_%' AND name NOT LIKE 'resource_conflict_fields_%'";
23 $result = db_query($q);
24 while($row = db_fetch_array($result)) {
25 $type = str_replace('resource_conflict_', '', $row['name']);
26 $q = "UPDATE {variable} SET name = 'rc_type_" . $type . "' WHERE name = 'resource_conflict_" . $type . "'";
27 $ret[] = update_sql($q);
28
29 // Also set the type to be event
30 variable_set('rc_date_field_' . $type, 'event');
31
32 // Finally, rename the enabled fields for the type
33 $q = "UPDATE {variable} SET name = 'rc_reference_fields_" . $type . "' WHERE name = 'resource_conflict_fields_" . $type . "'";
34 $ret[] = update_sql($q);
35 }
36
37 return $ret;
38 }
39
40 /**
41 * Delete all variables matching a pattern using SQL 'LIKE' syntax.
42 * @param $pattern
43 * The pattern of variables to delete.
44 */
45 function _resource_conflict_variable_delete_like($pattern) {
46 $q = "SELECT name FROM {variable} WHERE name LIKE '%s'";
47 $result = db_query($q, $pattern);
48 while ($row = db_fetch_array($result)) {
49 variable_del($row['name']);
50 }
51 }

  ViewVC Help
Powered by ViewVC 1.1.2