name); } } 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_%%'"); $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(); } /** * 5.x-1.0 update 1. */ 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 block configuration page.', 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') ))); } } // 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 block configuration page.', 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') ))); } } 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(); $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid"); while ($role = db_fetch_object($result)) { $renamed_permission = preg_replace('/(?<=^|,\ )user\ locations(?=,|$)/', 'view user location details', $role->perm); $renamed_permission = preg_replace('/(?<=^|,\ )show\ user\ map(?=,|$)/', 'view user map', $renamed_permission); $renamed_permission = preg_replace('/(?<=^|,\ )show\ node\ map(?=,|$)/', 'view node map', $renamed_permission); if ($renamed_permission != $role->perm) { $ret[] = update_sql("UPDATE {permission} SET perm = '$renamed_permission' WHERE rid = $role->rid"); } } return $ret; }