/[drupal]/contributions/modules/gmap/gmap_location.install
ViewVC logotype

Contents of /contributions/modules/gmap/gmap_location.install

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


Revision 1.8 - (show annotations) (download) (as text)
Fri Mar 13 17:10:45 2009 UTC (8 months, 2 weeks ago) by bdragon
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +19 -1 lines
File MIME type: text/x-php
The remainder of #392130, reported by gaele:
Rename permissions:
"show node map" -> "view node map"
"show user map" -> "view user map"
"user locations" -> "view user location details"
1 <?php
2 // $Id: gmap_location.install,v 1.7 2009/02/05 21:44:22 bdragon Exp $
3
4 /**
5 * @file
6 * gmap_location install routines.
7 */
8
9 /**
10 * Implementation of hook_install().
11 */
12 function gmap_location_install() {
13 // Gmap no longer provides the location table.
14 }
15
16 /**
17 * Implementation of hook_uninstall().
18 */
19 function gmap_location_uninstall() {
20 variable_del('gmap_user_map');
21 variable_del('gmap_node_map');
22 variable_del('gmap_node_markers');
23 variable_del('gmap_role_markers');
24 variable_del('gmap_location_block_macro');
25 variable_del('gmap_location_author_block_macro');
26 variable_del('gmap_location_author_block_types');
27 variable_del('gmap_location_author_block_marker');
28 $result = db_query("SELECT name FROM {variable} WHERE name LIKE 'gmap_location_block_macro_%%'");
29 while ($row = db_fetch_object($result)) {
30 variable_del($row->name);
31 }
32 }
33
34 function gmap_location_update_1() {
35 drupal_set_message(t('WARNING! Obsolete gmap_location update #@num was triggered! Please verify the schema of your location table manually!', array('@num' => '1')));
36 }
37
38 function gmap_location_update_2() {
39 drupal_set_message(t('WARNING! Obsolete gmap_location update #@num was triggered! Please verify the schema of your location table manually!', array('@num' => '2')));
40 }
41
42 // 5.x-0.8 first update
43 function gmap_location_update_5080() {
44 // Convert role markers to single variable.
45 $result = db_query("SELECT name FROM {variable} WHERE name LIKE 'gmap_role_map_marker_%%'");
46 $markers = array();
47 while ($row = db_fetch_object($result)) {
48 $num = (int)substr($row->name, 21);
49 $markers[$num] = variable_get($row->name, 'drupal');
50 variable_del($row->name);
51 }
52 variable_set('gmap_role_markers', $markers);
53 // It's pointless to have a default when the roles will take effect in all cases.
54 variable_del('gmap_user_map_marker');
55
56 // Convert node type markers to single variable.
57 $result = db_query("SELECT name FROM {variable} WHERE name LIKE 'gmap_node_marker_%%'");
58 $markers = array();
59 while ($row = db_fetch_object($result)) {
60 $type = substr($row->name, 17);
61 $markers[$type] = variable_get($row->name, 'drupal');
62 variable_del($row->name);
63 }
64 variable_set('gmap_node_markers', $markers);
65
66 // User location setting functionality is moving to location.module.
67 //variable_del('gmap_user');
68 //variable_del('gmap_user_profile_category');
69
70 // gmap_user_map is a single variable now.
71 $temp = array(
72 'macro' => variable_get('gmap_user_map', '[gmap |id=usermap|center=40,0|zoom=3|width=100%|height=400px]'),
73 'header' => variable_get('gmap_user_map_header', 'This map illustrates the extent of users of this website. Each marker indicates a user that has entered their locations.'),
74 'footer' => '',
75 );
76 variable_set('gmap_user_map', $temp);
77 variable_del('gmap_user_map_header');
78
79 // gmap_node_map is a single variable now.
80 $temp = array(
81 'macro' => variable_get('gmap_node_map', '[gmap |id=nodemap|center=40,0|zoom=3|width=100%|height=400px]'),
82 'header' => variable_get('gmap_node_map_header', 'This map illustrates the locations of the nodes on this website. Each marker indicates a node associated with a specific location.'),
83 'footer' => '',
84 );
85 variable_set('gmap_node_map', $temp);
86 variable_del('gmap_node_map_header');
87
88 return array();
89 }
90
91 /**
92 * 5.x-1.0 update 1.
93 */
94 function gmap_location_update_5100() {
95 $ret = array();
96
97 // Convert author block variables into a single variable.
98 $result = db_query("SELECT name FROM {variable} WHERE name LIKE 'gmap_location_author_block_%'");
99 $types = array();
100 $delete = array();
101 while ($row = db_fetch_object($result)) {
102 if ($row->name == 'gmap_location_author_block_macro' || $row->name == 'gmap_location_author_block_types') {
103 continue;
104 }
105 $delete[] = $row->name;
106 if (variable_get($row->name, FALSE)) {
107 $types[] = substr($row->name, 27);
108 }
109 }
110 variable_set('gmap_location_author_block_types', $types);
111 foreach ($delete as $row) {
112 variable_del($row);
113 }
114
115 // Normalize node block macro.
116 $var = variable_get('gmap_location_block_macro', FALSE);
117 if ($var) {
118 $var = trim($var);
119 switch ($var) {
120 // Record of all historical defaults
121 case '[gmap |id=block0 |zoom=10 |width=100% |height=200px |control=Small |type=Map]':
122 case '[gmap |id=block0|zoom=10 |width=100% |height=200px |control=Small |type=Map]':
123 case '[gmap |zoom=10 |width=100% |height=200px |control=Small |type=Map]':
124 case '[gmap |id=block0 |zoom=10 |width=100% |height=200px |control=Small |type=Map |behavior=+autozoom,+notype]':
125 case '[gmap |id=block0 |zoom=10 |width=100% |height=200px |control=Small |type=Map |behavior=+notype]':
126 // Fall back to new default.
127 variable_del('gmap_location_block_macro');
128 break;
129 default:
130 // User has customized macro.
131 drupal_set_message(t('You have customized the !type macro. Be advised that the new default macro is %macro. Please check your macro on the <a href="@url">block configuration page</a>.', array('!type' => t('Location block'), '%macro' => '[gmap |width=100% |height=200px |control=None |behavior=+autozoom +notype]', '@url' => url('admin/build/block/configure/gmap_location/0'))));
132 }
133 }
134
135 // Normalize author block macro.
136 $var = variable_get('gmap_location_author_block_macro', FALSE);
137 if ($var) {
138 $var = trim($var);
139 switch ($var) {
140 // Record of all historical defaults
141 case '[gmap |zoom=10 |width=100% |height=200px |control=Small |type=Map |behavior=+notype]':
142 case '[gmap |id=block0|zoom=10 |width=100% |height=200px |control=Small |type=Map]':
143 case '[gmap |id=block0 |zoom=10 |width=100% |height=200px |control=Small |type=Map]':
144 case '[gmap |zoom=10 |width=100% |height=200px |control=Small |type=Map]':
145 // Fall back to new default.
146 variable_del('gmap_location_author_block_macro');
147 break;
148 default:
149 // User has customized macro.
150 drupal_set_message(t('You have customized the !type macro. Be advised that the new default macro is %macro. Please check your macro on the <a href="@url">block configuration page</a>.', array('!type' => t('Author block'), '%macro' => '[gmap |width=100% |height=200px |control=None |behavior=+autozoom +notype]', '@url' => url('admin/build/block/configure/gmap_location/1'))));
151 }
152 }
153
154 return $ret;
155 }
156
157 /**
158 * 5.x-1.0 update 2. (Post-release)
159 * Delete unneeded variable.
160 */
161 function gmap_location_update_5101() {
162 $ret = array();
163 variable_del('gmap_geocode');
164 return $ret;
165 }
166
167 /**
168 * 5.x-1.1 update 1 (Still haven't diverged for 6.x.)
169 * #392130: Use better permission names.
170 */
171 function gmap_location_update_5102() {
172 $ret = array();
173 $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid");
174 while ($role = db_fetch_object($result)) {
175 $renamed_permission = preg_replace('/(?<=^|,\ )user\ locations(?=,|$)/', 'view user location details', $role->perm);
176 $renamed_permission = preg_replace('/(?<=^|,\ )show\ user\ map(?=,|$)/', 'view user map', $renamed_permission);
177 $renamed_permission = preg_replace('/(?<=^|,\ )show\ node\ map(?=,|$)/', 'view node map', $renamed_permission);
178 if ($renamed_permission != $role->perm) {
179 $ret[] = update_sql("UPDATE {permission} SET perm = '$renamed_permission' WHERE rid = $role->rid");
180 }
181 }
182 return $ret;
183 }

  ViewVC Help
Powered by ViewVC 1.1.2