-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings.php
111 lines (97 loc) · 3.65 KB
/
settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
if (!defined("PHORUM_ADMIN")) return;
require_once './mods/google_maps/defaults.php';
require_once './mods/google_maps/api.php';
// Convert Google Maps module v1 settings.
$converted = FALSE;
if (!empty($PHORUM['mod_google_maps']['center'])) {
$s = $PHORUM['mod_google_maps'];
if (preg_match(
'/^\((-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)\)$/',
$s['center'], $m
)) {
$PHORUM['mod_google_maps']['latitude'] = $m[1];
$PHORUM['mod_google_maps']['longitude'] = $m[2];
unset($PHORUM['mod_google_maps']['center']);
$converted = TRUE;
}
}
if (!empty($PHORUM['mod_google_maps']['type']) &&
$PHORUM['mod_google_maps']['type'] === 'normal') {
$PHORUM['mod_google_maps']['type'] = 'roadmap';
$converted = TRUE;
}
if (!empty($PHORUM['mod_google_maps']['api_key'])) {
unset($PHORUM['mod_google_maps']['api_key']);
$converted = TRUE;
}
if ($converted) {
phorum_db_update_settings(array(
"mod_google_maps" => $PHORUM['mod_google_maps']
));
}
// save settings
if(count($_POST))
{
$settings = array(
"latitude" => $_POST["map_latitude"],
"longitude" => $_POST["map_longitude"],
"zoom" => $_POST["map_zoom"],
"type" => $_POST["map_type"],
"profile_auto_show" => isset($_POST["profile_auto_show"]) ? 1 : 0
);
if (!phorum_db_update_settings(array("mod_google_maps" => $settings))) {
phorum_admin_error("Sorry, the setting were not updated (database error)");
} else {
phorum_admin_okmsg("The settings were successfully updated");
}
$PHORUM["mod_google_maps"] = $settings;
}
require_once './include/admin/PhorumInputForm.php';
$frm = new PhorumInputForm ("", "post", "Save");
$frm->hidden("module", "modsettings");
$frm->hidden("mod", "google_maps");
$frm->addbreak("Edit settings for the Google Maps module");
$row = $frm->addrow(
"Display automatically in the user's profile",
$frm->checkbox(
"profile_auto_show", "1", "",
$PHORUM["mod_google_maps"]["profile_auto_show"]
)
);
$frm->addhelp($row,
"Display automatically in the user's profile",
"This option can be used to configure automatic displaying of the map for
the user in the user's profile. If you disable this option, you can
place the map anywhere in the profile.tpl template by hand. Place the
code {MOD_GOOGLE_MAPS} in your template at the place where you want the
map to appear. See also the README for this module for an example."
);
$frm->addmessage("");
$frm->addbreak("Configure the starting position for the map");
// Show the map editor.
$frm->addmessage(
"Using the map below, you can configure the default state for the map.
This state is shown in case a user did not yet set a position or if
he/she unsets the position. The map's center, zoom level and map type
are all stored for defining the default state."
);
// Construct the code for the map editor.
$map = mod_google_maps_build_maptool('map-editor', array(
'map_latitude' => $PHORUM['mod_google_maps']['latitude'],
'map_longitude' => $PHORUM['mod_google_maps']['longitude'],
'map_zoom' => $PHORUM['mod_google_maps']['zoom'],
'map_type' => $PHORUM['mod_google_maps']['type'],
// We need to specify these here explicitly, because otherwise
// the currently active map center, zoom and type would be used
// as the reset state by the maptool builder code.
'reset_latitude' => 40,
'reset_longitude' => -20,
'reset_zoom' => 1,
'reset_type' => 'roadmap'
));
$frm->addmessage(
"<div style=\"width:100%; height: 350px; margin-bottom: 1em\">$map</div>"
);
$frm->show();
?>