summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-01-23 16:29:10 -0800
committerBharat Mediratta <bharat@menalto.com>2010-01-23 16:29:10 -0800
commitfecac4a8596a69088270e48a90868e845fc8f4ca (patch)
treea4683906d481d1091e218c9b6662a1997cb11086 /modules/gallery/helpers
parent8849594aa17768f564e45370a62f01e440570dcf (diff)
parent3b16d0662b8a4b06f4be72165c858a1231e9bd67 (diff)
Merge branch 'master' of git@github.com:gallery/gallery3 into bharat_dev
Conflicts: modules/gallery/tests/xss_data.txt
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/gallery_event.php43
-rw-r--r--modules/gallery/helpers/locales.php4
-rw-r--r--modules/gallery/helpers/module.php8
-rw-r--r--modules/gallery/helpers/user_profile.php55
4 files changed, 81 insertions, 29 deletions
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index 4d208893..255176c4 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -30,21 +30,23 @@ class gallery_event_Core {
static function user_deleted($user) {
$admin = identity::admin_user();
- db::build()
- ->update("tasks")
- ->set("owner_id", $admin->id)
- ->where("owner_id", "=", $user->id)
- ->execute();
- db::build()
- ->update("items")
- ->set("owner_id", $admin->id)
- ->where("owner_id", "=", $user->id)
- ->execute();
- db::build()
- ->update("logs")
- ->set("user_id", $admin->id)
- ->where("user_id", "=", $user->id)
- ->execute();
+ if (!empty($admin)) { // could be empty if there is not identity provider
+ db::build()
+ ->update("tasks")
+ ->set("owner_id", $admin->id)
+ ->where("owner_id", "=", $user->id)
+ ->execute();
+ db::build()
+ ->update("items")
+ ->set("owner_id", $admin->id)
+ ->where("owner_id", "=", $user->id)
+ ->execute();
+ db::build()
+ ->update("logs")
+ ->set("user_id", $admin->id)
+ ->where("user_id", "=", $user->id)
+ ->execute();
+ }
}
static function identity_provider_changed($old_provider, $new_provider) {
@@ -127,12 +129,11 @@ class gallery_event_Core {
->label(t("Login")));
} else {
$csrf = access::csrf_token();
- $item = $theme->item();
- $menu->append(Menu::factory("dialog")
+ $menu->append(Menu::factory("link")
->id("user_menu_edit_profile")
->css_id("g-user-profile-link")
->view("login_current_user.html")
- ->url(url::site("form/edit/users/{$user->id}"))
+ ->url(user_profile::url($user->id))
->label($user->display_name()));
$menu->append(Menu::factory("link")
->id("user_menu_logout")
@@ -246,11 +247,7 @@ class gallery_event_Core {
->append(Menu::factory("link")
->id("advanced")
->label(t("Advanced"))
- ->url(url::site("admin/advanced_settings")))
- ->append(Menu::factory("link")
- ->id("authentication")
- ->label(t("Authentication"))
- ->url(url::site("admin/identity"))))
+ ->url(url::site("admin/advanced_settings"))))
->append(Menu::factory("link")
->id("modules")
->label(t("Modules"))
diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php
index 8d76e333..5c8c227a 100644
--- a/modules/gallery/helpers/locales.php
+++ b/modules/gallery/helpers/locales.php
@@ -41,7 +41,7 @@ class locales_Core {
$default = module::get_var("gallery", "default_locale");
$codes = explode("|", module::get_var("gallery", "installed_locales", $default));
foreach ($codes as $code) {
- if (isset($available->$code)) {
+ if (isset($available[$code])) {
$installed[$code] = $available[$code];
}
}
@@ -127,7 +127,7 @@ class locales_Core {
}
$locale or $locale = Gallery_I18n::instance()->locale();
- return self::$locales["$locale"];
+ return self::$locales[$locale];
}
static function is_rtl($locale=null) {
diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php
index 595f600b..f680ff6a 100644
--- a/modules/gallery/helpers/module.php
+++ b/modules/gallery/helpers/module.php
@@ -120,17 +120,17 @@ class module_Core {
}
/**
- * Check that the module can be installed. (i.e. all the prerequistes exist)
+ * Check that the module can be activated. (i.e. all the prerequistes exist)
* @param string $module_name
* @return array an array of warning or error messages to be displayed
*/
- static function check_environment($module_name) {
+ static function can_activate($module_name) {
module::_add_to_path($module_name);
$messages = array();
$installer_class = "{$module_name}_installer";
- if (method_exists($installer_class, "check_environment")) {
- $messages = call_user_func(array($installer_class, "check_environment"));
+ if (method_exists($installer_class, "can_activate")) {
+ $messages = call_user_func(array($installer_class, "can_activate"));
}
// Remove it from the active path
diff --git a/modules/gallery/helpers/user_profile.php b/modules/gallery/helpers/user_profile.php
new file mode 100644
index 00000000..018e1bd1
--- /dev/null
+++ b/modules/gallery/helpers/user_profile.php
@@ -0,0 +1,55 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+class user_profile_Core {
+ /**
+ * Generate the url to display the profile
+ * @return url for the profile display
+ */
+ static function url($user_id) {
+ $return_url = urlencode(url::abs_current());
+ return url::site("user_profile/show/{$user_id}?return=$return_url");
+ }
+
+ static function get_contact_form($user) {
+ $form = new Forge("user_profile/send/{$user->id}", "", "post",
+ array("id" => "g-user-profile-contact-form"));
+ $group = $form->group("message")
+ ->label(t("Compose message to %name", array("name" => $user->display_name())));
+ $group->input("reply_to")
+ ->label(t("From:"))
+ ->rules("required|length[1, 256]|valid_email")
+ ->error_messages("required", t("Field is required"))
+ ->error_messages("max_length", t("Field exceeds 256 bytes"))
+ ->error_messages("valid_email", t("Field is not a valid email address"));
+ $group->input("subject")
+ ->label(t("Subject:"))
+ ->rules("required|length[1, 256]")
+ ->error_messages("required", t("Field is required"))
+ ->error_messages("max_length", t("Field exceeds 256 bytes"));
+ $group->textarea("message")
+ ->label(t("Message:"))
+ ->rules("required")
+ ->error_messages("required", t("Field is required"));
+ module::event("user_profile_contact_form", $form);
+ $group->submit("")->value(t("Send"));
+ return $form;
+ }
+}