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

Contents of /contributions/modules/gallery/gallery.install

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


Revision 1.3 - (show annotations) (download) (as text)
Fri Nov 23 11:20:33 2007 UTC (2 years ago) by profix898
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
Changes since 1.2: +41 -49 lines
File MIME type: text/x-php
- very early D6 version (Oct-01, 2007)
1 <?php
2 // $Id: gallery.install,v 1.1.4.8 2007/09/10 18:04:08 profix898 Exp $
3
4 /**
5 * gallery.module : gallery.install
6 * Install/Uninstall functions
7 */
8
9 /**
10 * Implementation of hook_install().
11 */
12 function gallery_install() {
13 drupal_set_message(t(''));
14 }
15
16 /**
17 * Implementation of hook_update_N().
18 * (migrate settings from the 5.x-1.x to 5.x-2.x (or 6.x-1.x) series)
19 */
20 function gallery_update_1() {
21 $ret = array();
22
23 $variables = array();
24 // Fetch all gallery-related variables
25 $result = db_query("SELECT * FROM {variable} WHERE name LIKE 'gallery_%'");
26 while ($var = db_fetch_object($result)) {
27 $variables[$var->name] = $var->value;
28 }
29 // Remove old variables
30 db_query("DELETE FROM {variable} WHERE name LIKE 'gallery_%'");
31
32 // Array containing 'old name' => 'new name' map
33 $variable_map = array(
34 // Image block settings
35 'gallery_album_frame' => 'gallery_block_image_0_album_frame',
36 'gallery_block_block' => 'gallery_block_image_0_block_block',
37 'gallery_block_show' => 'gallery_block_image_0_block_show',
38 'gallery_item_frame' => 'gallery_block_image_0_item_frame',
39 'gallery_item_id' => 'gallery_block_image_0_item_id',
40 'gallery_link_target' => 'gallery_block_image_0_link_target',
41 'gallery_block_num_images' => 'gallery_block_image_0_num_images',
42 'gallery_maxsize' => 'gallery_block_image_0_size',
43 // Grid block settings
44 'gallery_grid_album_frame' => 'gallery_block_grid_0_album_frame',
45 'gallery_grid_block_block' => 'gallery_block_grid_0_block_block',
46 'gallery_grid_block_show' => 'gallery_block_grid_0_block_show',
47 'gallery_grid_item_frame' => 'gallery_block_grid_0_item_frame',
48 'gallery_grid_item_id' => 'gallery_block_grid_0_item_id',
49 'gallery_grid_link_target' => 'gallery_block_grid_0_link_target',
50 'gallery_grid_maxsize' => 'gallery_block_grid_0_size',
51 'gallery_grid_num_cols' => 'gallery_block_grid_0_num_cols',
52 'gallery_grid_num_rows' => 'gallery_block_grid_0_num_rows',
53 // G2 filter settings
54 'gallery_filter_default_size' => 'gallery_filter_default_maxsize',
55 // Search settings
56 'gallery_search_max_rows_per_pager' => 'gallery_search_rows_per_pager',
57 'gallery_search_maxsize' => 'gallery_search_size',
58 // Fullname support
59 'gallery_use_full_name' => 'gallery_use_fullname',
60 'gallery_profile_full_name_field' => 'gallery_profile_fullname_field'
61 );
62 // Migrate old variables
63 foreach ($variable_map as $old => $new) {
64 if (isset($variables[$old])) {
65 $variables[$new] = $variables[$old];
66 unset($variables[$old]);
67 $ret[] = array('success' => TRUE, 'query' => 'Migrating variable ['. $old .' => '. $new .']');
68 }
69 }
70
71 // Unset obsolete variables
72 $obsolete = array('gallery_search_max_items', 'gallery_autodetect_dir', 'gallery_uri', 'gallery_dir');
73 foreach ($obsolete as $var) {
74 if (isset($variables[$var])) {
75 unset($variables[$var]);
76 $ret[] = array('success' => TRUE, 'query' => 'Removing variable ['. $var .']');
77 }
78 }
79
80 // Mark gallery configuration invalid. This does NOT reset the configuration, but
81 // forces the user to run the install wizard to (re)set and verify critical settings.
82 $variables['gallery_valid'] = FALSE;
83 drupal_set_message('You were updating from gallery module 5.x-1.x (or earlier) to the 6.x-1.x
84 of the module. All your settings were migrated automatically (see below),
85 but you will need to re-configure some basic options. Please visit the
86 Gallery settings page (admin/settings/gallery) to complete the update.',
87 'error');
88 // Save resulting variables array
89 // (all variables not migrated or unset are taken over directly)
90 foreach ($variables as $name => $value) {
91 // We dont use variable_set() to reduce overhead
92 // (i.e. unserialize => serialize and cache_clear_all() for each variable)
93 db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, $value);
94 }
95 cache_clear_all('variables', 'cache');
96 menu_rebuild();
97
98 return $ret;
99 }
100
101 /**
102 * Implementation of hook_update_N().
103 * (initial update to Drupal 6)
104 */
105 function gallery_update_6001() {
106 $ret = array();
107 $ret[] = array('success' => TRUE, 'query' => 'Removing variable [gallery_page_callback]');
108 variable_del('gallery_page_callback');
109
110 return $ret;
111 }
112
113 /**
114 * Implementation of hook_uninstall().
115 */
116 function gallery_uninstall() {
117 // Remove all gallery related variables and blocks
118 db_query("DELETE FROM {variable} WHERE name LIKE 'gallery_%'");
119 db_query("DELETE FROM {blocks} WHERE module = 'gallery'");
120 cache_clear_all('variables', 'cache');
121 }

  ViewVC Help
Powered by ViewVC 1.1.2