Newer
Older
/**
* Implementation of hook_install().
*/
function gmap_location_install() {
// Gmap no longer provides the location table.
}
Brandon Bergren
committed
/**
* Implementation of hook_uninstall().
*/
function gmap_location_uninstall() {
variable_del('gmap_user_map');
variable_del('gmap_node_map');
variable_del('gmap_node_markers');
variable_del('gmap_role_markers');
variable_del('gmap_location_block_macro');
variable_del('gmap_location_author_block_macro');
variable_del('gmap_location_author_block_types');
variable_del('gmap_location_author_block_marker');
$result = db_query("SELECT name FROM {variable} WHERE name LIKE 'gmap_location_block_macro_%%'");
foreach ($result as $row) {
variable_del($row->name);
}
Brandon Bergren
committed
}
function gmap_location_update_1() {
drupal_set_message(t('WARNING! Obsolete gmap_location update #@num was triggered! Please verify the schema of your location table manually!', array('@num' => '1')));
}
function gmap_location_update_2() {
drupal_set_message(t('WARNING! Obsolete gmap_location update #@num was triggered! Please verify the schema of your location table manually!', array('@num' => '2')));
}
// 5.x-0.8 first update
function gmap_location_update_5080() {
// Convert role markers to single variable.
$result = db_query("SELECT name FROM {variable} WHERE name LIKE 'gmap_role_map_marker_%%'");
$markers = array();
while ($row = db_fetch_object($result)) {
$num = (int) substr($row->name, 21);
$markers[$num] = variable_get($row->name, 'drupal');
variable_del($row->name);
}
variable_set('gmap_role_markers', $markers);
// It's pointless to have a default when the roles will take effect in all cases.
variable_del('gmap_user_map_marker');
// Convert node type markers to single variable.
$result = db_query("SELECT name FROM {variable} WHERE name LIKE 'gmap_node_marker_%%'");
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
$markers = array();
while ($row = db_fetch_object($result)) {
$type = substr($row->name, 17);
$markers[$type] = variable_get($row->name, 'drupal');
variable_del($row->name);
}
variable_set('gmap_node_markers', $markers);
// User location setting functionality is moving to location.module.
//variable_del('gmap_user');
//variable_del('gmap_user_profile_category');
// gmap_user_map is a single variable now.
$temp = array(
'macro' => variable_get('gmap_user_map', '[gmap |id=usermap|center=40,0|zoom=3|width=100%|height=400px]'),
'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.'),
'footer' => '',
);
variable_set('gmap_user_map', $temp);
variable_del('gmap_user_map_header');
// gmap_node_map is a single variable now.
$temp = array(
'macro' => variable_get('gmap_node_map', '[gmap |id=nodemap|center=40,0|zoom=3|width=100%|height=400px]'),
'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.'),
'footer' => '',
);
variable_set('gmap_node_map', $temp);
variable_del('gmap_node_map_header');
return array();
}
/**
Brandon Bergren
committed
* 5.x-1.0 update 1.
Brandon Bergren
committed
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
function gmap_location_update_5100() {
$ret = array();
// Convert author block variables into a single variable.
$result = db_query("SELECT name FROM {variable} WHERE name LIKE 'gmap_location_author_block_%'");
$types = array();
$delete = array();
while ($row = db_fetch_object($result)) {
if ($row->name == 'gmap_location_author_block_macro' || $row->name == 'gmap_location_author_block_types') {
continue;
}
$delete[] = $row->name;
if (variable_get($row->name, FALSE)) {
$types[] = substr($row->name, 27);
}
}
variable_set('gmap_location_author_block_types', $types);
foreach ($delete as $row) {
variable_del($row);
}
// Normalize node block macro.
$var = variable_get('gmap_location_block_macro', FALSE);
if ($var) {
$var = trim($var);
switch ($var) {
// Record of all historical defaults
case '[gmap |id=block0 |zoom=10 |width=100% |height=200px |control=Small |type=Map]':
case '[gmap |id=block0|zoom=10 |width=100% |height=200px |control=Small |type=Map]':
case '[gmap |zoom=10 |width=100% |height=200px |control=Small |type=Map]':
case '[gmap |id=block0 |zoom=10 |width=100% |height=200px |control=Small |type=Map |behavior=+autozoom,+notype]':
case '[gmap |id=block0 |zoom=10 |width=100% |height=200px |control=Small |type=Map |behavior=+notype]':
// Fall back to new default.
variable_del('gmap_location_block_macro');
break;
default:
// User has customized macro.
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/structure/block/manage/gmap_location/0/configure')
)));
Brandon Bergren
committed
}
}
// Normalize author block macro.
$var = variable_get('gmap_location_author_block_macro', FALSE);
if ($var) {
$var = trim($var);
switch ($var) {
// Record of all historical defaults
case '[gmap |zoom=10 |width=100% |height=200px |control=Small |type=Map |behavior=+notype]':
case '[gmap |id=block0|zoom=10 |width=100% |height=200px |control=Small |type=Map]':
case '[gmap |id=block0 |zoom=10 |width=100% |height=200px |control=Small |type=Map]':
case '[gmap |zoom=10 |width=100% |height=200px |control=Small |type=Map]':
// Fall back to new default.
variable_del('gmap_location_author_block_macro');
break;
default:
// User has customized macro.
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/structure/block/manage/gmap_location/1/configure')
)));
Brandon Bergren
committed
}
}
return $ret;
/**
* 5.x-1.0 update 2. (Post-release)
* Delete unneeded variable.
*/
function gmap_location_update_5101() {
$ret = array();
variable_del('gmap_geocode');
return $ret;
}
/**
* 5.x-1.1 update 1 (Still haven't diverged for 6.x.)
* #392130: Use better permission names.
*/
function gmap_location_update_5102() {
$ret = array();
drupal_set_message(t('You are upgrading from an ancient GMap version. Please see <a href="@url">this issue</a>.', array('@url' => 'http://drupal.org/node/392130')));