diff options
author | Nathan Kinkade <nkinkade@nkinka.de> | 2010-01-23 22:21:37 +0000 |
---|---|---|
committer | Nathan Kinkade <nkinkade@nkinka.de> | 2010-01-23 22:21:37 +0000 |
commit | b21e7be11a0abe57790ec2a2fcca1874632fed8c (patch) | |
tree | 63cca83318d4f80914b6b90bbd9063ff5dabc6ea /modules | |
parent | e47505081f2c1017a68f763e1170b44fddd1e722 (diff) | |
parent | abdeb21ccbb25aee564335dbbfca4a8afaf49384 (diff) |
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules')
22 files changed, 384 insertions, 275 deletions
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/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 @@ -<?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 Admin_Identity_Controller extends Admin_Controller { - public function index() { - $view = new Admin_View("admin.html"); - $view->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/controllers/admin_maintenance.php b/modules/gallery/controllers/admin_maintenance.php index 213e4fe2..aa4fb29f 100644 --- a/modules/gallery/controllers/admin_maintenance.php +++ b/modules/gallery/controllers/admin_maintenance.php @@ -216,7 +216,7 @@ class Admin_Maintenance_Controller extends Admin_Controller { "task" => array( "percent_complete" => $task->percent_complete, "status" => $task->status, - "done" => $task->done), + "done" => (bool) $task->done), "location" => url::site("admin/maintenance"))); } else { @@ -224,7 +224,7 @@ class Admin_Maintenance_Controller extends Admin_Controller { "task" => array( "percent_complete" => $task->percent_complete, "status" => $task->status, - "done" => $task->done))); + "done" => (bool) $task->done))); } } } diff --git a/modules/gallery/controllers/admin_modules.php b/modules/gallery/controllers/admin_modules.php index 549718e7..84fee25d 100644 --- a/modules/gallery/controllers/admin_modules.php +++ b/modules/gallery/controllers/admin_modules.php @@ -25,9 +25,48 @@ class Admin_Modules_Controller extends Admin_Controller { print $view; } + + public function confirm() { + access::verify_csrf(); + + $messages = array("error" => array(), "warn" => array()); + $desired_list = array(); + foreach (module::available() as $module_name => $info) { + if ($info->locked) { + continue; + } + + if ($desired = Input::instance()->post($module_name) == 1) { + $desired_list[] = $module_name; + } + 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::can_activate($module_name)); + } + } + + if (empty($messages["error"]) && empty($messages["warn"])) { + $this->_do_save(); + $result["reload"] = 1; + } else { + $v = new View("admin_modules_confirm.html"); + $v->messages = $messages; + $v->modules = $desired_list; + $result["dialog"] = (string)$v; + $result["allow_continue"] = empty($messages["error"]); + } + print json_encode($result); + } + public function save() { access::verify_csrf(); + $this->_do_save(); + url::redirect("admin/modules"); + } + + private function _do_save() { $changes->activate = array(); $changes->deactivate = array(); $activated_names = array(); @@ -37,20 +76,24 @@ class Admin_Modules_Controller extends Admin_Controller { continue; } - $desired = Input::instance()->post($module_name) == 1; - if ($info->active && !$desired && module::is_active($module_name)) { - $changes->deactivate[] = $module_name; - $deactivated_names[] = t($info->name); - module::deactivate($module_name); - } else if (!$info->active && $desired && !module::is_active($module_name)) { - $changes->activate[] = $module_name; - $activated_names[] = t($info->name); - if (module::is_installed($module_name)) { - module::upgrade($module_name); - } else { - module::install($module_name); + try { + $desired = Input::instance()->post($module_name) == 1; + if ($info->active && !$desired && module::is_active($module_name)) { + module::deactivate($module_name); + $changes->deactivate[] = $module_name; + $deactivated_names[] = t($info->name); + } else if (!$info->active && $desired && !module::is_active($module_name)) { + if (module::is_installed($module_name)) { + module::upgrade($module_name); + } else { + module::install($module_name); + } + module::activate($module_name); + $changes->activate[] = $module_name; + $activated_names[] = t($info->name); } - module::activate($module_name); + } catch (Exception $e) { + Kohana_Log::add("error", (string)$e); } } @@ -63,7 +106,6 @@ class Admin_Modules_Controller extends Admin_Controller { if ($deactivated_names) { message::success(t("Deactivated: %names", array("names" => join(", ", $deactivated_names)))); } - url::redirect("admin/modules"); } } diff --git a/modules/gallery/controllers/login.php b/modules/gallery/controllers/login.php index 75ee6b9c..cfccaf17 100644 --- a/modules/gallery/controllers/login.php +++ b/modules/gallery/controllers/login.php @@ -50,7 +50,11 @@ class Login_Controller extends Controller { if ($valid) { url::redirect(item::root()->abs_url()); } else { - print $form; + $view = new Theme_View("page.html", "other", "login"); + $view->page_title = t("Log in to Gallery"); + $view->content = new View("login_ajax.html"); + $view->content->form = $form; + print $view; } } diff --git a/modules/gallery/css/l10n_client.css b/modules/gallery/css/l10n_client.css index 3771c049..053b4432 100644 --- a/modules/gallery/css/l10n_client.css +++ b/modules/gallery/css/l10n_client.css @@ -184,7 +184,9 @@ } #l10n-client-string-editor .translation { - overflow:hidden; + overflow-y:auto; + overflow-x: hidden; + height: 20em; width:49%; float: right; } diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 679d65c2..6175e049 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) { @@ -109,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") @@ -228,11 +229,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")) @@ -305,7 +302,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 +310,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')) }") 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() { diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index 6c7078a3..f680ff6a 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -120,19 +120,46 @@ class module_Core { } /** + * 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 can_activate($module_name) { + module::_add_to_path($module_name); + $messages = array(); + + $installer_class = "{$module_name}_installer"; + if (method_exists($installer_class, "can_activate")) { + $messages = call_user_func(array($installer_class, "can_activate")); + } + + // Remove it from the active path + module::_remove_from_path($module_name); + return $messages; + } + + /** + * 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()); + + module::event("pre_deactivate", $data); + + return $data->messages; + } + + /** * Install a module. This will call <module>_installer::install(), which is responsible for * creating database tables, setting module variables and calling module::set_version(). * Note that after installing, the module must be activated before it is available for use. * @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 +169,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 <module>_installer::upgrade(), which is responsible for * modifying database tables, changing module variables and calling module::set_version(). @@ -194,10 +240,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")) { 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/modules/gallery/libraries/IdentityProvider.php b/modules/gallery/libraries/IdentityProvider.php index bcb3056a..e07838d1 100644 --- a/modules/gallery/libraries/IdentityProvider.php +++ b/modules/gallery/libraries/IdentityProvider.php @@ -58,6 +58,51 @@ class IdentityProvider_Core { } /** + * Return a commen confirmation message + */ + static function confirmation_message() { + return t("Are you sure you want to change your Identity Provider? " . + "Continuing will delete all existing users."); + } + + static function change_provider($new_provider) { + $current_provider = module::get_var("gallery", "identity_provider"); + if (!empty($current_provider)) { + module::uninstall($current_provider); + } + + try { + IdentityProvider::reset(); + $provider = new IdentityProvider($new_provider); + + module::set_var("gallery", "identity_provider", $new_provider); + + if (method_exists("{$new_provider}_installer", "initialize")) { + call_user_func("{$new_provider}_installer::initialize"); + } + + module::event("identity_provider_changed", $current_provider, $new_provider); + + auth::login($provider->admin_user()); + Session::instance()->regenerate(); + } catch (Exception $e) { + // Make sure new provider is not in the database + module::uninstall($new_provider); + + // Lets reset to the current provider so that the gallery installation is still + // working. + module::set_var("gallery", "identity_provider", null); + IdentityProvider::change_provider($current_provider); + module::activate($current_provider); + message::error( + t("Error attempting to enable \"%new_provider\" identity provider, " . + "reverted to \"%old_provider\" identity provider", + array("new_provider" => $new_provider, "old_provider" => $current_provider))); + throw $e; + } + } + + /** * Loads the configured driver and validates it. * * @return void 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 @@ -<?php defined("SYSPATH") or die("No direct script access.") ?> -<script type="text/javascript"> - $(document).ready(function() { - $("#g-modules form").submit(function() { - var eDialog = '<div id="g-dialog"></div>'; - var params = $(this).serialize(); - var url = $(this).attr("action"); - $("body").append(eDialog); - $.post($(this).attr("action"), $(this).serialize(), function(data, textStatus) { - $("#g-dialog").html(data); - $("#g-dialog").dialog({ - bgiframe: true, - title: <?= t("Confirm identity provider change")->for_js() ?>, - resizable: false, - height:180, - modal: true, - overlay: { - backgroundColor: '#000', - opacity: 0.5 - }, - buttons: { - "Continue": function() { - $("#g-dialog form").submit(); - }, - Cancel: function() { - $(this).dialog('destroy').remove(); - } - } - }); - }); - return false; - }); - }); - -</script> -<div id="g-modules"> - <h1> <?= t("Manage identity providers") ?> </h1> - <p> - <?= t("Choose a different user/group management provider.") ?> - </p> - - <form method="post" action="<?= url::site("admin/identity/confirm") ?>"> - <?= access::csrf_form_field() ?> - <table> - <tr> - <th> <?= t("Active") ?> </th> - <th> <?= t("Description") ?> </th> - </tr> - <? foreach ($available as $module_name => $description): ?> - <tr class="<?= text::alternate("g-odd", "g-even") ?>"> - <? $data = array("name" => "provider"); ?> - <td> <?= form::radio($data, $module_name, $module_name == $active) ?> </td> - <td> <?= t($description) ?> </td> - </tr> - <? endforeach ?> - </table> - <input type="submit" value="<?= t("Change")->for_html_attr() ?>" /> - </form> -</div> 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 @@ -<?php defined("SYSPATH") or die("No direct script access.") ?> -<form method="post" action="<?= url::site("admin/identity/change") ?>"> - <?= access::csrf_form_field() ?> - <?= form::hidden("provider", $new_provider) ?> - - <p><span class="ui-icon ui-icon-alert" style="float: left; margin:0 7px 20px 0;"></span> - <?= t("Are you sure you want to change your Identity Provider? Continuing will delete all existing users.") ?> - </p> -</form> - diff --git a/modules/gallery/views/admin_modules.html.php b/modules/gallery/views/admin_modules.html.php index aebedf09..a021d969 100644 --- a/modules/gallery/views/admin_modules.html.php +++ b/modules/gallery/views/admin_modules.html.php @@ -1,12 +1,53 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> <div class="g-block ui-helper-clearfix"> + <script type="text/javascript"> + $("#g-module-update-form").ready(function() { + $("#g-module-update-form").ajaxForm({ + dataType: "json", + success: function(data) { + if (data.reload) { + window.location.reload(); + } else { + $("body").append('<div id="g-dialog">' + data.dialog + '</div>'); + $("#g-dialog").dialog({ + bgiframe: true, + autoOpen: true, + autoResize: true, + modal: true, + resizable: false, + height: 400, + width: 500, + position: "center", + title: <?= t("Confirm Module Activation")->for_js() ?>, + buttons: { + <?= t("Continue")->for_js() ?>: function() { + $("form", this).submit(); + $(".ui-dialog-buttonpane button:contains(Continue)") + .attr("disabled", "disabled") + .addClass("ui-state-disabled"); + }, + <?= t("Cancel")->for_js() ?>: function() { + $(this).dialog("destroy").remove(); + } + } + }); + if (!data.allow_continue) { + $(".ui-dialog-buttonpane button:contains(Continue)") + .attr("disabled", "disabled") + .addClass("ui-state-disabled"); + } + } + } + }); + }); + </script> <h1> <?= t("Gallery Modules") ?> </h1> <p> <?= t("Power up your Gallery by adding more modules! Each module provides new cool features.") ?> </p> <div class="g-block-content"> - <form method="post" action="<?= url::site("admin/modules/save") ?>"> + <form id="g-module-update-form" method="post" action="<?= url::site("admin/modules/confirm") ?>"> <?= access::csrf_form_field() ?> <table> <tr> diff --git a/modules/gallery/views/admin_modules_confirm.html.php b/modules/gallery/views/admin_modules_confirm.html.php new file mode 100644 index 00000000..59592505 --- /dev/null +++ b/modules/gallery/views/admin_modules_confirm.html.php @@ -0,0 +1,22 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<div class="ui-helper-clearfix"> + <p> + <?= t("The following issue(s) have been identified:") ?> + </p> + + <div id="g-admin-modules-messages" class="g-block-content"> + <ul> + <? foreach (array("error" => "g-error", "warn" => "g-warning") as $type => $class): ?> + <? foreach ($messages[$type] as $message): ?> + <li class="<?= $class ?>" style="padding-bottom: 0"><?= $message ?></li> + <? endforeach ?> + <? endforeach ?> + </ul> + <form method="post" action="<?= url::site("admin/modules/save") ?>"> + <?= access::csrf_form_field() ?> + <? foreach ($modules as $module): ?> + <?= form::hidden($module, 1) ?> + <? endforeach ?> + </form> + </div> +</div> diff --git a/modules/gallery/views/form_uploadify.html.php b/modules/gallery/views/form_uploadify.html.php index f3b9c883..b3b81ecb 100644 --- a/modules/gallery/views/form_uploadify.html.php +++ b/modules/gallery/views/form_uploadify.html.php @@ -2,17 +2,21 @@ <style> #g-add-photos-canvas object { height: 33px; - left: -60px; + left: -80px; position: relative; z-index: 100; } +#g-add-photos-canvas span { + height: 33px; + width: 150px; +} #g-add-photos-button { float: left; - left: 175px; + left: 155px; padding-bottom: .5em; padding-top: .5em; position: relative; - width: 110px; + width: 150px; z-index: 1; } </style> @@ -21,6 +25,8 @@ <script type="text/javascript"> $("#g-add-photos-canvas").ready(function () { $("#g-uploadify").uploadify({ + width: 150, + height: 33, uploader: "<?= url::file("lib/uploadify/uploadify.swf") ?>", script: "<?= url::site("simple_uploader/add_photo/{$album->id}") ?>", scriptData: <?= json_encode($script_data) ?>, diff --git a/modules/slideshow/helpers/slideshow_event.php b/modules/slideshow/helpers/slideshow_event.php index c4d7c56d..137ec313 100644 --- a/modules/slideshow/helpers/slideshow_event.php +++ b/modules/slideshow/helpers/slideshow_event.php @@ -18,6 +18,12 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class slideshow_event_Core { + static function pre_deactivate($data) { + if ($data->module == "rss") { + $data->messages["warn"][] = t("The Slideshow module requires the RSS module."); + } + } + static function module_change($changes) { if (!module::is_active("rss") || in_array("rss", $changes->deactivate)) { site_status::warning( diff --git a/modules/slideshow/helpers/slideshow_installer.php b/modules/slideshow/helpers/slideshow_installer.php index 03f3332c..8d612f3e 100644 --- a/modules/slideshow/helpers/slideshow_installer.php +++ b/modules/slideshow/helpers/slideshow_installer.php @@ -33,4 +33,12 @@ class slideshow_installer { static function deactivate() { site_status::clear("slideshow_needs_rss"); } + + static function can_activate() { + $messages = array(); + if (!module::is_active("rss")) { + $messages["warn"][] = t("The Slideshow module requires the RSS module."); + } + return $messages; + } } diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php index 0cba502f..38f8020b 100644 --- a/modules/user/helpers/user_installer.php +++ b/modules/user/helpers/user_installer.php @@ -18,7 +18,39 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class user_installer { + static function can_activate() { + return array("warn" => array(IdentityProvider::confirmation_message())); + } + static function install() { + IdentityProvider::change_provider("user"); + } + + static function upgrade($version) { + if ($version == 1) { + module::set_var("user", "mininum_password_length", 5); + + module::set_version("user", $version = 2); + } + } + + static function uninstall() { + // Delete all users and groups so that we give other modules an opportunity to clean up + foreach (ORM::factory("user")->find_all() as $user) { + $user->delete(); + } + + foreach (ORM::factory("group")->find_all() as $group) { + $group->delete(); + } + + $db = Database::instance(); + $db->query("DROP TABLE IF EXISTS {users};"); + $db->query("DROP TABLE IF EXISTS {groups};"); + $db->query("DROP TABLE IF EXISTS {groups_users};"); + } + + static function initialize() { $db = Database::instance(); $db->query("CREATE TABLE IF NOT EXISTS {users} ( `id` int(9) NOT NULL auto_increment, @@ -70,19 +102,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); @@ -90,32 +109,7 @@ class user_installer { access::allow($registered, "view", $root); access::allow($registered, "view_full", $root); - module::set_var("user", "mininum_password_length", 5); - module::set_version("user", 2); - } - - static function upgrade($version) { - if ($version == 1) { - module::set_var("user", "mininum_password_length", 5); - - module::set_version("user", $version = 2); - } - } - - static function uninstall() { - // Delete all users and groups so that we give other modules an opportunity to clean up - foreach (ORM::factory("user")->find_all() as $user) { - $user->delete(); - } - - foreach (ORM::factory("group")->find_all() as $group) { - $group->delete(); - } - - $db = Database::instance(); - $db->query("DROP TABLE IF EXISTS {users};"); - $db->query("DROP TABLE IF EXISTS {groups};"); - $db->query("DROP TABLE IF EXISTS {groups_users};"); + module::set_var("user", "mininum_password_length", 5); } }
\ No newline at end of file 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 diff --git a/modules/user/views/admin_users.html.php b/modules/user/views/admin_users.html.php index 45d04916..270a7207 100644 --- a/modules/user/views/admin_users.html.php +++ b/modules/user/views/admin_users.html.php @@ -107,7 +107,7 @@ </div> </div> - <div id="g-group-admin" class="g-block g-right ui-helper-clearfix"> + <div id="g-group-admin" class="g-block ui-helper-clearfix"> <a href="<?= url::site("admin/users/add_group_form") ?>" class="g-dialog-link g-button g-right ui-icon-left ui-state-default ui-corner-all" title="<?= t("Create a new group")->for_html_attr() ?>"> |