diff --git a/3.0/modules/google_analytics/controllers/admin_google_analytics.php b/3.0/modules/google_analytics/controllers/admin_google_analytics.php index 6cb7b5a9..328e294a 100644 --- a/3.0/modules/google_analytics/controllers/admin_google_analytics.php +++ b/3.0/modules/google_analytics/controllers/admin_google_analytics.php @@ -1,53 +1,62 @@ -_get_view(); - } - - public function handler() { - access::verify_csrf(); - - $form = $this->_get_form(); - if ($form->validate()) { - module::set_var( - "google_analytics", "code", $form->google_analytics_code->analytics_code->value); - url::redirect("admin/google_analytics"); - } - - print $this->_get_view($form); - } - - private function _get_view($form=null) { - $v = new Admin_View("admin.html"); - $v->content = new View("admin_google_analytics.html"); - $v->content->form = empty($form) ? $this->_get_form() : $form; - return $v; - } - - private function _get_form() { - $form = new Forge("admin/google_analytics/handler", "", "post", array("id" => "g-admin-form")); - $group = $form->group("google_analytics_code"); - $group->input("analytics_code")->label(t('Enter the Web-Property-ID given by Google.'))->rules("required")->value(module::get_var("google_analytics", "code")); - $group->submit("submit")->value(t("Save")); - - return $form; - } +_get_view(); + } + + public function handler() + { + access::verify_csrf(); + + $form = $this->_get_form(); + + if ($form->validate()) + { + module::set_var("google_analytics", "code", $form->google_analytics_code->inputs["analytics_code"]->value); + module::set_var("google_analytics", "owneradmin_hidden", $form->google_analytics_code->inputs["analytics_owneradmin_hidden"]->value); + url::redirect("admin/google_analytics"); + } + + print $this->_get_view($form); + } + + private function _get_view($form=null) + { + $v = new Admin_View("admin.html"); + $v->content = new View("admin_google_analytics.html"); + $v->content->form = empty($form) ? $this->_get_form() : $form; + return $v; + } + + private function _get_form() + { + $form = new Forge("admin/google_analytics/handler", "", "post", + array("id" => "gAdminForm")); + $group = $form->group("google_analytics_code"); + $group->input("analytics_code")->label(t('Enter the Web-Property-ID given by Google.'))->rules("required")->value(module::get_var("google_analytics", "code")); + $group->checkbox("analytics_owneradmin_hidden")->label(t("Omit code for owner and admin")) + ->checked(module::get_var("google_analytics", "owneradmin_hidden", false) == 1); + $group->submit("submit")->value(t("Save")); + + return $form; + } } \ No newline at end of file diff --git a/3.0/modules/google_analytics/helpers/google_analytics_event.php b/3.0/modules/google_analytics/helpers/google_analytics_event.php index 0bab69ee..1cef1b08 100644 --- a/3.0/modules/google_analytics/helpers/google_analytics_event.php +++ b/3.0/modules/google_analytics/helpers/google_analytics_event.php @@ -1,28 +1,28 @@ -get("settings_menu") - ->append(Menu::factory("link") - ->id("google_analytics_menu") - ->label(t("Google Analytics")) - ->url(url::site("admin/google_analytics"))); - } -} +get("settings_menu") + ->append(Menu::factory("link") + ->id("google_analytics_menu") + ->label(t("Google Analytics")) + ->url(url::site("admin/google_analytics"))); + } +} diff --git a/3.0/modules/google_analytics/helpers/google_analytics_installer.php b/3.0/modules/google_analytics/helpers/google_analytics_installer.php new file mode 100644 index 00000000..0e52c059 --- /dev/null +++ b/3.0/modules/google_analytics/helpers/google_analytics_installer.php @@ -0,0 +1,45 @@ + - - - '; - - return $google_code; - } -} +item->owner_id != identity::active_user()->id) && (identity::active_user()->admin == 0) ) { + $u_o = 0; + } + + if ( $u_o == 0 || ( ($u_o == 1) && (module::get_var("google_analytics", "owneradmin_hidden") == 0) ) ) { + $google_code = ' + + + '; + + return $google_code; + } + + } + +} + + diff --git a/3.0/modules/google_analytics/module.info b/3.0/modules/google_analytics/module.info index ca5a51e3..b49b147b 100644 --- a/3.0/modules/google_analytics/module.info +++ b/3.0/modules/google_analytics/module.info @@ -1,7 +1,7 @@ -name = "Google Analytics" -description = "Renders the Google Analytics Code at the end of the page. Written by 'mcp'." -version = 2 -author_name = "" -author_url = "" -info_url = "http://codex.gallery2.org/Gallery3:Modules:google_analytics" -discuss_url = "http://gallery.menalto.com/forum_module_google_analytics" +name = Google Analytics +description = Renders the Google Analytics Code in the head of the page. +version = 4 +author_name = "" +author_url = "" +info_url = "http://codex.gallery2.org/Gallery3:Modules:google_analytics" +discuss_url = "http://gallery.menalto.com/node/88884" diff --git a/3.0/modules/google_analytics/views/admin_google_analytics.html.php b/3.0/modules/google_analytics/views/admin_google_analytics.html.php index e516f35a..9abc3c39 100644 --- a/3.0/modules/google_analytics/views/admin_google_analytics.html.php +++ b/3.0/modules/google_analytics/views/admin_google_analytics.html.php @@ -1,6 +1,6 @@ - -
-

-

- -
+ +
+

+

+ +