diff --git a/3.0/modules/tagsmap/controllers/admin_tagsmap.php b/3.0/modules/tagsmap/controllers/admin_tagsmap.php index bc71fb04..0b676957 100644 --- a/3.0/modules/tagsmap/controllers/admin_tagsmap.php +++ b/3.0/modules/tagsmap/controllers/admin_tagsmap.php @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ - class Admin_TagsMap_Controller extends Admin_Controller { public function index() { // Generate a new admin page. @@ -185,9 +184,8 @@ class Admin_TagsMap_Controller extends Admin_Controller { // Input box for the Maps API Key $googlemap_group = $form->group("GoogleMapsKey"); $googlemap_group->input("google_api_key") - ->label(t("Google Maps API Key")) - ->value(module::get_var("tagsmap", "googlemap_api_key")) - ->rules("required"); + ->label(t("Google APIs Console key (optional):")) + ->value(module::get_var("tagsmap", "googlemap_api_key")); // Input boxes for the Maps starting location map type and zoom. $startingmap_group = $form->group("GoogleMapsPos"); @@ -212,6 +210,8 @@ class Admin_TagsMap_Controller extends Admin_Controller { "G_PHYSICAL_MAP" => "Physical", "G_SATELLITE_3D_MAP" => "Google Earth")) ->selected(module::get_var("tagsmap", "googlemap_type")); + $startingmap_group->checkbox("restrict_maps")->label(t("Restrict maps to registered users?")) + ->checked(module::get_var("tagsmap", "restrict_maps", false)); // Add a save button to the form. $form->submit("SaveSettings")->value(t("Save")); @@ -234,6 +234,7 @@ class Admin_TagsMap_Controller extends Admin_Controller { module::set_var("tagsmap", "googlemap_longitude", $form->GoogleMapsPos->google_starting_longitude->value); module::set_var("tagsmap", "googlemap_zoom", $form->GoogleMapsPos->google_default_zoom->value); module::set_var("tagsmap", "googlemap_type", $form->GoogleMapsPos->google_default_type->value); + module::set_var("tagsmap", "restrict_maps", $form->GoogleMapsPos->restrict_maps->value); // Display a success message and redirect back to the TagsMap admin page. message::success(t("Your settings have been saved.")); @@ -247,4 +248,4 @@ class Admin_TagsMap_Controller extends Admin_Controller { $view->content->tags = ORM::factory("tag")->order_by("name", "ASC")->find_all(); print $view; } -} \ No newline at end of file +} diff --git a/3.0/modules/tagsmap/controllers/tagsmap.php b/3.0/modules/tagsmap/controllers/tagsmap.php index 6c8ea1ac..8e01f5b5 100644 --- a/3.0/modules/tagsmap/controllers/tagsmap.php +++ b/3.0/modules/tagsmap/controllers/tagsmap.php @@ -20,17 +20,22 @@ class TagsMap_Controller extends Controller { public function googlemap($fullsize) { // Display all tags with GPS coordinates on a google map. - + + // If the user can't view maps, throw a 404 error. + if ((module::get_var("tagsmap", "restrict_maps") == true) && (identity::active_user()->guest)) { + throw new Kohana_404_Exception(); + } + // Generate a list of GPS coordinates. $tagsGPS = ORM::factory("tags_gps")->find_all(); - + // Set up and display the actual page. // If fullsize is true, allow the map to take up the entire browser window, // if not, then display the map in the gallery theme. if ($fullsize == true) { $view = new View("tagsmap_googlemap.html"); $view->map_fullsize = true; - + // Load in module preferences. $view->tags_gps = $tagsGPS; $view->google_map_key = module::get_var("tagsmap", "googlemap_api_key"); @@ -38,21 +43,28 @@ class TagsMap_Controller extends Controller { $view->google_map_longitude = module::get_var("tagsmap", "googlemap_longitude"); $view->google_map_zoom = module::get_var("tagsmap", "googlemap_zoom"); $view->google_map_type = module::get_var("tagsmap", "googlemap_type"); - + print $view; } else { - $template = new Theme_View("page.html", "other", "TagsMap"); + // Set up breadcrumbs. + $breadcrumbs = array(); + $root = item::root(); + $breadcrumbs[] = Breadcrumb::instance($root->title, $root->url())->set_first(); + $breadcrumbs[] = Breadcrumb::instance(t("Tag Map"), url::site("tagsmap/googlemap/"))->set_last(); + + $template = new Theme_View("page.html", "other", "tag"); $template->page_title = t("Gallery :: Map"); + $template->set_global(array("breadcrumbs" => $breadcrumbs)); $template->content = new View("tagsmap_googlemap.html"); - // Load in module preferences. + // Load in module preferences. $template->content->tags_gps = $tagsGPS; $template->content->google_map_key = module::get_var("tagsmap", "googlemap_api_key"); $template->content->google_map_latitude = module::get_var("tagsmap", "googlemap_latitude"); $template->content->google_map_longitude = module::get_var("tagsmap", "googlemap_longitude"); $template->content->google_map_zoom = module::get_var("tagsmap", "googlemap_zoom"); $template->content->google_map_type = module::get_var("tagsmap", "googlemap_type"); - + print $template; } } diff --git a/3.0/modules/tagsmap/css/tagsmap_menu.css b/3.0/modules/tagsmap/css/tagsmap_menu.css index 119cf7d0..9d89d015 100644 --- a/3.0/modules/tagsmap/css/tagsmap_menu.css +++ b/3.0/modules/tagsmap/css/tagsmap_menu.css @@ -4,4 +4,4 @@ #g-tagsmap-dialog { color: black; } -#g-tagsmap-dialog a { color: blue !important; } \ No newline at end of file +#g-tagsmap-dialog a { color: blue !important; } diff --git a/3.0/modules/tagsmap/helpers/tagsmap_event.php b/3.0/modules/tagsmap/helpers/tagsmap_event.php index 22edf82d..81d14736 100644 --- a/3.0/modules/tagsmap/helpers/tagsmap_event.php +++ b/3.0/modules/tagsmap/helpers/tagsmap_event.php @@ -48,6 +48,10 @@ class tagsmap_event_Core { } static function photo_menu($menu, $theme) { + // Make sure the user can view maps before displaying one. + if ((module::get_var("tagsmap", "restrict_maps") == true) && (identity::active_user()->guest)) { + return; + } $menu->append(Menu::factory("link") ->id("tagsmap") ->label(t("View Map")) @@ -56,18 +60,38 @@ class tagsmap_event_Core { } static function movie_menu($menu, $theme) { + // Make sure the user can view maps before displaying one. + if ((module::get_var("tagsmap", "restrict_maps") == true) && (identity::active_user()->guest)) { + return; + } $menu->append(Menu::factory("link") ->id("tagsmap") ->label(t("View Map")) ->url(url::site("tagsmap/googlemap/")) ->css_id("g-tagsmap-link")); } - + + static function tag_menu($menu, $theme) { + // Make sure the user can view maps before displaying one. + if ((module::get_var("tagsmap", "restrict_maps") == true) && (identity::active_user()->guest)) { + return; + } + $menu->append(Menu::factory("link") + ->id("tagsmap") + ->label(t("View Map")) + ->url(url::site("tagsmap/googlemap/")) + ->css_id("g-tagsmap-link")); + } + static function album_menu($menu, $theme) { + // Make sure the user can view maps before displaying one. + if ((module::get_var("tagsmap", "restrict_maps") == true) && (identity::active_user()->guest)) { + return; + } $menu->append(Menu::factory("link") ->id("tagsmap") ->label(t("View Map")) ->url(url::site("tagsmap/googlemap/")) ->css_id("g-tagsmap-link")); } -} \ No newline at end of file +} diff --git a/3.0/modules/tagsmap/helpers/tagsmap_installer.php b/3.0/modules/tagsmap/helpers/tagsmap_installer.php index dac0d9bb..ca404509 100644 --- a/3.0/modules/tagsmap/helpers/tagsmap_installer.php +++ b/3.0/modules/tagsmap/helpers/tagsmap_installer.php @@ -36,7 +36,15 @@ class tagsmap_installer { module::set_var("tagsmap", "googlemap_longitude", 134); module::set_var("tagsmap", "googlemap_zoom", 5); module::set_var("tagsmap", "googlemap_type", "G_NORMAL_MAP"); - module::set_version("tagsmap", 2); + module::set_var("tagsmap", "restrict_maps", "0"); + module::set_version("tagsmap", 3); + } + + static function upgrade($version) { + if ($version == 2) { + module::set_var("tagsmap", "restrict_maps", "0"); + module::set_version("tagsmap", 3); + } } static function deactivate() { diff --git a/3.0/modules/tagsmap/helpers/tagsmap_theme.php b/3.0/modules/tagsmap/helpers/tagsmap_theme.php index 8e074d2d..fc7f829f 100644 --- a/3.0/modules/tagsmap/helpers/tagsmap_theme.php +++ b/3.0/modules/tagsmap/helpers/tagsmap_theme.php @@ -18,7 +18,6 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class tagsmap_theme_Core { - static function head($theme) { return $theme->css("tagsmap_menu.css"); } diff --git a/3.0/modules/tagsmap/models/tags_gps.php b/3.0/modules/tagsmap/models/tags_gps.php index df6370f9..669cbc05 100644 --- a/3.0/modules/tagsmap/models/tags_gps.php +++ b/3.0/modules/tagsmap/models/tags_gps.php @@ -18,4 +18,4 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Tags_GPS_Model extends ORM { -} \ No newline at end of file +} diff --git a/3.0/modules/tagsmap/module.info b/3.0/modules/tagsmap/module.info index 827de3eb..323c7d2c 100644 --- a/3.0/modules/tagsmap/module.info +++ b/3.0/modules/tagsmap/module.info @@ -1,6 +1,6 @@ name = "TagsMap" description = "Assign GPS coordinates to existing tags and display them on a map." -version = 2 +version = 3 author_name = "rWatcher" author_url = "http://codex.gallery2.org/User:RWatcher" info_url = "http://codex.gallery2.org/Gallery3:Modules:tagsmap" diff --git a/3.0/modules/tagsmap/views/admin_tagsmap.html.php b/3.0/modules/tagsmap/views/admin_tagsmap.html.php index 231a57db..d92567a5 100644 --- a/3.0/modules/tagsmap/views/admin_tagsmap.html.php +++ b/3.0/modules/tagsmap/views/admin_tagsmap.html.php @@ -6,7 +6,8 @@

-
You may sign up for a Google Maps API key here.

+
+ here.

diff --git a/3.0/modules/tagsmap/views/admin_tagsmap_delete.html.php b/3.0/modules/tagsmap/views/admin_tagsmap_delete.html.php index 8b6c0e95..dd4704a6 100644 --- a/3.0/modules/tagsmap/views/admin_tagsmap_delete.html.php +++ b/3.0/modules/tagsmap/views/admin_tagsmap_delete.html.php @@ -6,4 +6,3 @@ ">Cancel - diff --git a/3.0/modules/tagsmap/views/admin_tagsmap_edit.html.php b/3.0/modules/tagsmap/views/admin_tagsmap_edit.html.php index e01f2b29..ff08cbbc 100644 --- a/3.0/modules/tagsmap/views/admin_tagsmap_edit.html.php +++ b/3.0/modules/tagsmap/views/admin_tagsmap_edit.html.php @@ -9,7 +9,13 @@ - +\n"; +} else { + print "\n"; +} +?> + - diff --git a/3.0/modules/tagsmap/views/tagsmap_googlemap.html.php b/3.0/modules/tagsmap/views/tagsmap_googlemap.html.php index 2fd6151e..aee5a028 100644 --- a/3.0/modules/tagsmap/views/tagsmap_googlemap.html.php +++ b/3.0/modules/tagsmap/views/tagsmap_googlemap.html.php @@ -9,7 +9,12 @@ - +\n"; +} else { + print "\n"; +} +?>