From d59c6ed4f149c201542c8b38f9ad9d61b4daabf4 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 21 Jan 2010 12:57:45 -0800 Subject: The admin module controller allows modules to provide a check_environment method which is called prior to installation. The method allows the module to provide an error message or warnings if the module can not be installed or activated without issues. The admin module controller also will fire a pre_deactivate event, which allows modules to indicate issues that may arise be deactivating the specified module. These messages are displayed in a dialog box prior to installation in order to allow the gallery administrator to determine the appropriate action before proceeding. Lays the foundation for implementing a fix for ticket #937 --- modules/gallery/helpers/module.php | 65 +++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 12 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index 6c7078a3..2ae83f0d 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -119,6 +119,36 @@ class module_Core { return self::$active; } + /** + * Check that the module can be installed. (i.e. all the prerequistes exist) + * @param string $module_name + */ + static function check_environment($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")); + } + + // Now the module is installed but inactive, so don't leave it in the active path + module::_remove_from_path($module_name); + return $messages; + } + + /** + * Check that the module can be installed. (i.e. all the prerequistes exist) + * @param string $module_name + */ + static function can_deactivate($module_name) { + $data = (object)array("module" => $module_name, "messages" => array()); + + module::event("pre_deactivate", $data); + + return $data->messages; + } + /** * Install a module. This will call _installer::install(), which is responsible for * creating database tables, setting module variables and calling module::set_version(). @@ -126,13 +156,8 @@ class module_Core { * @param string $module_name */ static function install($module_name) { - $config = Kohana_Config::instance(); - $kohana_modules = $config->get("core.modules"); - array_unshift($kohana_modules, MODPATH . $module_name); - $config->set("core.modules", $kohana_modules); + module::_add_to_path($module_name); - // Rebuild the include path so the module installer can benefit from auto loading - Kohana::include_paths(true); $installer_class = "{$module_name}_installer"; if (method_exists($installer_class, "install")) { call_user_func_array(array($installer_class, "install"), array()); @@ -142,13 +167,32 @@ class module_Core { module::load_modules(); // Now the module is installed but inactive, so don't leave it in the active path - array_shift($kohana_modules); - $config->set("core.modules", $kohana_modules); + module::_remove_from_path($module_name); log::success( "module", t("Installed module %module_name", array("module_name" => $module_name))); } + private static function _add_to_path($module_name) { + $config = Kohana_Config::instance(); + $kohana_modules = $config->get("core.modules"); + array_unshift($kohana_modules, MODPATH . $module_name); + $config->set("core.modules", $kohana_modules); + // Rebuild the include path so the module installer can benefit from auto loading + Kohana::include_paths(true); + } + + private static function _remove_from_path($module_name) { + $config = Kohana_Config::instance(); + $kohana_modules = $config->get("core.modules"); + if (($key = array_search(MODPATH . $module_name, $kohana_modules)) !== false) { + unset($kohana_modules[$key]); + $kohana_modules = array_values($kohana_modules); // reindex + } + $config->set("core.modules", $kohana_modules); + Kohana::include_paths(true); + } + /** * Upgrade a module. This will call _installer::upgrade(), which is responsible for * modifying database tables, changing module variables and calling module::set_version(). @@ -194,10 +238,7 @@ class module_Core { * @param string $module_name */ static function activate($module_name) { - $config = Kohana_Config::instance(); - $kohana_modules = $config->get("core.modules"); - array_unshift($kohana_modules, MODPATH . $module_name); - $config->set("core.modules", $kohana_modules); + module::_add_to_path($module_name); $installer_class = "{$module_name}_installer"; if (method_exists($installer_class, "activate")) { -- cgit v1.2.3 From 0da5d9e606fba5b6dc6137812df32cd1d0f5750f Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 21 Jan 2010 20:33:26 -0800 Subject: Internationalize all strings in admin_modules.hmtl and corrected comments. --- modules/gallery/helpers/module.php | 6 ++++-- modules/gallery/views/admin_modules.html.php | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index 2ae83f0d..595f600b 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -122,6 +122,7 @@ class module_Core { /** * Check that the module can be installed. (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) { module::_add_to_path($module_name); @@ -132,14 +133,15 @@ class module_Core { $messages = call_user_func(array($installer_class, "check_environment")); } - // Now the module is installed but inactive, so don't leave it in the active path + // Remove it from the active path module::_remove_from_path($module_name); return $messages; } /** - * Check that the module can be installed. (i.e. all the prerequistes exist) + * Allow modules to indicate the impact of deactivating the specifeid module * @param string $module_name + * @return array an array of warning or error messages to be displayed */ static function can_deactivate($module_name) { $data = (object)array("module" => $module_name, "messages" => array()); diff --git a/modules/gallery/views/admin_modules.html.php b/modules/gallery/views/admin_modules.html.php index 7f572411..704e7beb 100644 --- a/modules/gallery/views/admin_modules.html.php +++ b/modules/gallery/views/admin_modules.html.php @@ -18,12 +18,12 @@ height: 400, width: 500, position: "center", - title: "Confirm Module Activation", + title: for_js() ?>, buttons: { - "Continue": function() { + for_js() ?>: function() { $("form", this).submit(); }, - Cancel: function() { + for_js() ?>: function() { $(this).dialog("destroy").remove(); } } -- cgit v1.2.3 From 07ba5fe43aaa53be840b1842fe2eb4fc63ee7686 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Thu, 21 Jan 2010 23:53:21 -0800 Subject: Use Unicode instead of HTML entity (since the l10n server normalizes this way and rejects submissions that change under the normalization step) --- modules/gallery/helpers/gallery_event.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 679d65c2..b39be169 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -305,7 +305,7 @@ class gallery_event_Core { ->append( Menu::factory("ajax_link") ->id("rotate_ccw") - ->label(t("Rotate 90° counter clockwise")) + ->label(t("Rotate 90° counter clockwise")) ->css_class("ui-icon-rotate-ccw") ->ajax_handler("function(data) { " . "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }") @@ -313,7 +313,7 @@ class gallery_event_Core { ->append( Menu::factory("ajax_link") ->id("rotate_cw") - ->label(t("Rotate 90° clockwise")) + ->label(t("Rotate 90° clockwise")) ->css_class("ui-icon-rotate-cw") ->ajax_handler("function(data) { " . "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }") -- cgit v1.2.3 From 120c9c749e175cc6c67ae628ee1a8a967a8ddbcc Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Fri, 22 Jan 2010 01:16:16 -0800 Subject: Change "fetch translations" task to fetch them in batches. The request limit was in place already, but the client didn't respect it before, leading to unhappy users in case they had lots of 3rd party modules installed, or more than 2-3 locales enabled. This is all taken care of now. --- modules/gallery/helpers/gallery_task.php | 31 +++++++++++++-------- modules/gallery/helpers/l10n_client.php | 47 +++++++++++++++++++++++++------- 2 files changed, 56 insertions(+), 22 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php index 3a705027..b3b79e06 100644 --- a/modules/gallery/helpers/gallery_task.php +++ b/modules/gallery/helpers/gallery_task.php @@ -122,7 +122,7 @@ class gallery_task_Core { $start = microtime(true); $data = Cache::instance()->get("update_l10n_cache:{$task->id}"); if ($data) { - list($dirs, $files, $cache) = unserialize($data); + list($dirs, $files, $cache, $num_fetched) = unserialize($data); } $i = 0; @@ -130,6 +130,7 @@ class gallery_task_Core { case "init": // 0% $dirs = array("gallery", "modules", "themes", "installer"); $files = $cache = array(); + $num_fetched = 0; $task->set("mode", "find_files"); $task->status = t("Finding files"); break; @@ -161,7 +162,7 @@ class gallery_task_Core { } break; - case "scan_files": // 10% - 90% + case "scan_files": // 10% - 70% while (($file = array_pop($files)) && microtime(true) - $start < 0.5) { $file = DOCROOT . $file; switch (pathinfo($file, PATHINFO_EXTENSION)) { @@ -179,25 +180,31 @@ class gallery_task_Core { $task->status = t2("Scanning files: scanned 1 file", "Scanning files: scanned %count files", $total_files - count($files)); - $task->percent_complete = 10 + 80 * ($total_files - count($files)) / $total_files; + $task->percent_complete = 10 + 60 * ($total_files - count($files)) / $total_files; if (empty($files)) { $task->set("mode", "fetch_updates"); $task->status = t("Fetching updates"); - $task->percent_complete = 90; + $task->percent_complete = 70; } break; - case "fetch_updates": // 90% - 100% - l10n_client::fetch_updates(); - $task->done = true; - $task->state = "success"; - $task->status = t("Translations installed/updated"); - $task->percent_complete = 100; + case "fetch_updates": // 70% - 100% + // Send fetch requests in batches until we're done + $num_remaining = l10n_client::fetch_updates($num_fetched); + if ($num_remaining) { + $total = $num_fetched + $num_remaining; + $task->percent_complete = 70 + 30 * ((float) $num_fetched / $total); + } else { + $task->done = true; + $task->state = "success"; + $task->status = t("Translations installed/updated"); + $task->percent_complete = 100; + } } - if ($task->percent_complete < 100) { + if (!$task->done) { Cache::instance()->set("update_l10n_cache:{$task->id}", - serialize(array($dirs, $files, $cache))); + serialize(array($dirs, $files, $cache, $num_fetched))); } else { Cache::instance()->delete("update_l10n_cache:{$task->id}"); } diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php index fe70933d..086245e8 100644 --- a/modules/gallery/helpers/l10n_client.php +++ b/modules/gallery/helpers/l10n_client.php @@ -68,9 +68,15 @@ class l10n_client_Core { } /** - * @return an array of messages that will be written to the task log + * Fetches translations for l10n messages. Must be called repeatedly + * until 0 is returned (which is a countdown indicating progress). + * + * @param $num_fetched in/out parameter to specify which batch of + * messages to fetch translations for. + * @return The number of messages for which we didn't fetch + * translations for. */ - static function fetch_updates() { + static function fetch_updates(&$num_fetched) { $request->locales = array(); $request->messages = new stdClass(); @@ -79,23 +85,42 @@ class l10n_client_Core { $request->locales[] = $locale; } - // @todo Batch requests (max request size) - foreach (db::build() - ->select("key", "locale", "revision", "translation") - ->from("incoming_translations") - ->execute() as $row) { + // See the server side code for how we arrive at this + // number as a good limit for #locales * #messages. + $max_messages = 2000 / count($locales); + $num_messages = 0; + $rows = db::build() + ->select("key", "locale", "revision", "translation") + ->from("incoming_translations") + ->order_by("key") + ->limit(1000000) // ignore, just there to satisfy SQL syntax + ->offset($num_fetched) + ->execute(); + $num_remaining = $rows->count(); + foreach ($rows as $row) { if (!isset($request->messages->{$row->key})) { + if ($num_messages >= $max_messages) { + break; + } $request->messages->{$row->key} = 1; + $num_messages++; } - if (!empty($row->revision) && !empty($row->translation)) { + if (!empty($row->revision) && !empty($row->translation) && + isset($locales[$row->locale])) { if (!is_object($request->messages->{$row->key})) { $request->messages->{$row->key} = new stdClass(); } - $request->messages->{$row->key}->{$row->locale} = $row->revision; + $request->messages->{$row->key}->{$row->locale} = (int) $row->revision; } + $num_fetched++; + $num_remaining--; } // @todo Include messages from outgoing_translations? + if (!$num_messages) { + return $num_remaining; + } + $request_data = json_encode($request); $url = self::_server_url() . "?q=translations/fetch"; list ($response_data, $response_status) = remote::post($url, array("data" => $request_data)); @@ -103,7 +128,7 @@ class l10n_client_Core { throw new Exception("@todo TRANSLATIONS_FETCH_REQUEST_FAILED " . $response_status); } if (empty($response_data)) { - return array(t("Translations fetch request resulted in an empty response")); + return $num_remaining; } $response = json_decode($response_data); @@ -150,6 +175,8 @@ class l10n_client_Core { $entry->translation = $translation; $entry->save(); } + + return $num_remaining; } static function submit_translations() { -- cgit v1.2.3 From 603c3049a1ce7249c55ff8338fc3ea69323f0cb3 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 22 Jan 2010 09:39:29 -0800 Subject: Treat identity providers just like other modules and use the admin_module to install and switch to a different identity provider. --- modules/comment/helpers/comment_event.php | 18 +++++++++-------- modules/gallery/helpers/gallery_event.php | 32 ++++++++++++++++--------------- modules/user/helpers/user_installer.php | 24 +++++++++++------------ modules/user/module.info | 2 -- 4 files changed, 38 insertions(+), 38 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/comment/helpers/comment_event.php b/modules/comment/helpers/comment_event.php index 43a30d70..bd336cda 100644 --- a/modules/comment/helpers/comment_event.php +++ b/modules/comment/helpers/comment_event.php @@ -27,14 +27,16 @@ class comment_event_Core { static function user_deleted($user) { $guest = identity::guest(); - db::build() - ->update("comments") - ->set("author_id", $guest->id) - ->set("guest_email", null) - ->set("guest_name", "guest") - ->set("guest_url", null) - ->where("author_id", "=", $user->id) - ->execute(); + if (!empty($guest)) { // could be empty if there is not identity provider + db::build() + ->update("comments") + ->set("author_id", $guest->id) + ->set("guest_email", null) + ->set("guest_name", "guest") + ->set("guest_url", null) + ->where("author_id", "=", $user->id) + ->execute(); + } } static function identity_provider_changed($old_provider, $new_provider) { diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 679d65c2..1d8e3581 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) { diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php index 0cba502f..dd21c93c 100644 --- a/modules/user/helpers/user_installer.php +++ b/modules/user/helpers/user_installer.php @@ -20,6 +20,13 @@ class user_installer { static function install() { $db = Database::instance(); + $current_provider = module::get_var("gallery", "identity_provider"); + if (!empty($current_provider)) { + module::uninstall($current_provider); + } + IdentityProvider::reset(); + module::set_var("gallery", "identity_provider", "user"); + $db->query("CREATE TABLE IF NOT EXISTS {users} ( `id` int(9) NOT NULL auto_increment, `name` varchar(32) NOT NULL, @@ -70,19 +77,6 @@ class user_installer { $admin->admin = true; $admin->save(); - $current_provider = module::get_var("gallery", "identity_provider"); - if (empty($current_provider)) { - // If there is no provider defined then we are doing an initial install - // so we need to set the provider and make the administrator own everything - // If the installer is called and there is an identity provider, then we - // are switching identity providers and and the event handlers will do the - // right things - module::set_var("gallery", "identity_provider", "user"); - - // Let the admin own everything - $db->query("update {items} set owner_id = {$admin->id}"); - } - $root = ORM::factory("item", 1); access::allow($everybody, "view", $root); access::allow($everybody, "view_full", $root); @@ -93,6 +87,10 @@ class user_installer { module::set_var("user", "mininum_password_length", 5); module::set_version("user", 2); + module::event("identity_provider_changed", $current_provider, "user"); + + auth::login(IdentityProvider::instance()->admin_user()); + Session::instance()->regenerate(); } static function upgrade($version) { diff --git a/modules/user/module.info b/modules/user/module.info index 7178f108..d1e02382 100644 --- a/modules/user/module.info +++ b/modules/user/module.info @@ -2,5 +2,3 @@ name = "Users and Groups" description = "Gallery 3 user and group management" version = 2 -; Don't show this module on the module administration screen -no_module_admin = 1 -- cgit v1.2.3 From dabd5b84b21c711592a1f3bcd2ca298dd6d7fde2 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 22 Jan 2010 12:22:31 -0800 Subject: Remove the identity manager screens and controller as alterntive identity providers are installed in the admin module screen. --- modules/gallery/controllers/admin_identity.php | 76 ---------------------- modules/gallery/helpers/gallery_event.php | 6 +- modules/gallery/views/admin_identity.html.php | 59 ----------------- .../gallery/views/admin_identity_confirm.html.php | 10 --- 4 files changed, 1 insertion(+), 150 deletions(-) delete mode 100644 modules/gallery/controllers/admin_identity.php delete mode 100644 modules/gallery/views/admin_identity.html.php delete mode 100644 modules/gallery/views/admin_identity_confirm.html.php (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/controllers/admin_identity.php b/modules/gallery/controllers/admin_identity.php deleted file mode 100644 index 354e6c0c..00000000 --- a/modules/gallery/controllers/admin_identity.php +++ /dev/null @@ -1,76 +0,0 @@ -content = new View("admin_identity.html"); - $view->content->available = identity::providers(); - $view->content->active = module::get_var("gallery", "identity_provider", "user"); - print $view; - } - - public function confirm() { - access::verify_csrf(); - - $v = new View("admin_identity_confirm.html"); - $v->new_provider = Input::instance()->post("provider"); - - print $v; - } - - public function change() { - access::verify_csrf(); - - $active_provider = module::get_var("gallery", "identity_provider", "user"); - $providers = identity::providers(); - $new_provider = Input::instance()->post("provider"); - - if ($new_provider != $active_provider) { - - module::deactivate($active_provider); - - // Switch authentication - identity::reset(); - module::set_var("gallery", "identity_provider", $new_provider); - - module::install($new_provider); - module::activate($new_provider); - - module::event("identity_provider_changed", $active_provider, $new_provider); - - module::uninstall($active_provider); - - message::success(t("Changed to %description", - array("description" => $providers->$new_provider))); - - try { - Session::instance()->destroy(); - } catch (Exception $e) { - // We don't care if there was a problem destroying the session. - } - url::redirect(item::root()->abs_url()); - } - - message::info(t("The selected provider \"%description\" is already active.", - array("description" => $providers->$new_provider))); - url::redirect("admin/identity"); - } -} - diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 1d8e3581..6c7c2ea4 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -230,11 +230,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/views/admin_identity.html.php b/modules/gallery/views/admin_identity.html.php deleted file mode 100644 index 51eaa58a..00000000 --- a/modules/gallery/views/admin_identity.html.php +++ /dev/null @@ -1,59 +0,0 @@ - - -
-

-

- -

- -
"> - - - - - - - $description): ?> - "> - "provider"); ?> - - - - -
- for_html_attr() ?>" /> -
-
diff --git a/modules/gallery/views/admin_identity_confirm.html.php b/modules/gallery/views/admin_identity_confirm.html.php deleted file mode 100644 index 54aae9c8..00000000 --- a/modules/gallery/views/admin_identity_confirm.html.php +++ /dev/null @@ -1,10 +0,0 @@ - -
"> - - - -

- -

-
- -- cgit v1.2.3 From df313cac567bee77f5a73308381fe67dcac9b92c Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 22 Jan 2010 12:30:17 -0800 Subject: Change the check_environment method in the module helper and the module installers to can_activate to reflect that it is doing more than just checking the environment. --- modules/gallery/controllers/admin_modules.php | 2 +- modules/gallery/helpers/module.php | 8 ++++---- modules/slideshow/helpers/slideshow_installer.php | 2 +- modules/user/helpers/user_installer.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/controllers/admin_modules.php b/modules/gallery/controllers/admin_modules.php index 46defbef..a2168280 100644 --- a/modules/gallery/controllers/admin_modules.php +++ b/modules/gallery/controllers/admin_modules.php @@ -42,7 +42,7 @@ class Admin_Modules_Controller extends Admin_Controller { if ($info->active && !$desired && module::is_active($module_name)) { $messages = array_merge($messages, module::can_deactivate($module_name)); } else if (!$info->active && $desired && !module::is_active($module_name)) { - $messages = array_merge($messages, module::check_environment($module_name)); + $messages = array_merge($messages, module::can_activate($module_name)); } } 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/slideshow/helpers/slideshow_installer.php b/modules/slideshow/helpers/slideshow_installer.php index 319e2e79..8d612f3e 100644 --- a/modules/slideshow/helpers/slideshow_installer.php +++ b/modules/slideshow/helpers/slideshow_installer.php @@ -34,7 +34,7 @@ class slideshow_installer { site_status::clear("slideshow_needs_rss"); } - static function check_environment() { + static function can_activate() { $messages = array(); if (!module::is_active("rss")) { $messages["warn"][] = t("The Slideshow module requires the RSS module."); diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php index 3882f5f2..38f8020b 100644 --- a/modules/user/helpers/user_installer.php +++ b/modules/user/helpers/user_installer.php @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class user_installer { - static function check_environment() { + static function can_activate() { return array("warn" => array(IdentityProvider::confirmation_message())); } -- cgit v1.2.3 From abdeb21ccbb25aee564335dbbfca4a8afaf49384 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 23 Jan 2010 13:29:49 -0800 Subject: Add a user_menu method to the Admin_View and then use this method to get the user menu. Since the information displayed is identical in both admin and theme views, it makes sense to combine the generation to it is done in a common location. --- modules/gallery/helpers/gallery_event.php | 3 +-- modules/gallery/libraries/Admin_View.php | 10 ++++++++++ themes/admin_wind/css/screen.css | 5 +++++ themes/admin_wind/views/admin.html.php | 15 +-------------- 4 files changed, 17 insertions(+), 16 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 982bf094..6175e049 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -111,12 +111,11 @@ class gallery_event_Core { ->label(t("Login"))); } else { $csrf = access::csrf_token(); - $item = $theme->item(); $menu->append(Menu::factory("dialog") ->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(url::site("form/edit/user/{$user->id}")) ->label($user->display_name())); $menu->append(Menu::factory("link") ->id("user_menu_logout") diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php index a990e4ca..e3f9dff0 100644 --- a/modules/gallery/libraries/Admin_View.php +++ b/modules/gallery/libraries/Admin_View.php @@ -36,6 +36,8 @@ class Admin_View_Core extends Gallery_View { $this->sidebar = ""; $this->set_global("theme", $this); $this->set_global("user", identity::active_user()); + $this->set_global("page_type", "admin"); + $this->set_global("page_subtype", $name); } public function admin_menu() { @@ -44,6 +46,14 @@ class Admin_View_Core extends Gallery_View { return $menu->render(); } + public function user_menu() { + $menu = Menu::factory("root") + ->css_id("g-login-menu") + ->css_class("g-inline ui-helper-clear-fix"); + module::event("user_menu", $menu, $this); + return $menu->render(); + } + /** * Print out any site wide status information. */ diff --git a/themes/admin_wind/css/screen.css b/themes/admin_wind/css/screen.css index 73ec8ac5..ac47a3db 100644 --- a/themes/admin_wind/css/screen.css +++ b/themes/admin_wind/css/screen.css @@ -229,6 +229,7 @@ th { #g-header #g-login-menu { margin-top: 1em; + float: right; } /* View container ~~~~~~~~~~~~~~~~~~~~~~~~ */ @@ -473,6 +474,10 @@ th { right: 150px; } +.rtl #g-header #g-login-menu { + float: left; +} + .rtl #g-header #g-login-menu li { margin-left: 0; padding-left: 0; diff --git a/themes/admin_wind/views/admin.html.php b/themes/admin_wind/views/admin.html.php index 25ba1c97..fa79119a 100644 --- a/themes/admin_wind/views/admin.html.php +++ b/themes/admin_wind/views/admin.html.php @@ -43,23 +43,10 @@ site_status() ?>
admin_header_top() ?> - + user_menu() ?>
admin_menu() ?>
-- cgit v1.2.3