summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-10-18 18:16:19 -0700
committerTim Almdal <tnalmdal@shaw.ca>2009-10-18 18:16:19 -0700
commit301754db7365262804a40a59d4cbf277d7d1085e (patch)
tree647357b6a7939211673c094b88b7ecae2d22f21e
parent090c4d016baec6376d6d26c347c3e1ca11a929d5 (diff)
Create a administration page that allows the administrator to change the the Identity provider if more than two are Identity providers are installed
-rw-r--r--modules/gallery/controllers/admin_identity.php57
-rw-r--r--modules/gallery/views/admin_identity.html.php61
-rw-r--r--modules/gallery/views/admin_identity_confirm.html.php10
3 files changed, 128 insertions, 0 deletions
diff --git a/modules/gallery/controllers/admin_identity.php b/modules/gallery/controllers/admin_identity.php
new file mode 100644
index 00000000..dd1cfb4b
--- /dev/null
+++ b/modules/gallery/controllers/admin_identity.php
@@ -0,0 +1,57 @@
+<?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::active();
+ $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 = $this->input->post("provider");
+
+ print $v;
+ }
+
+ public function change() {
+ access::verify_csrf();
+
+ $active_provider = module::get_var("gallery", "identity_provider", "user");
+ $providers = Identity::active();
+
+ $new_provider = $this->input->post("provider");
+
+ if ($new_provider != $active_provider) {
+ module::event("identity_change", $new_provider);
+
+ // @todo this type of collation is questionable from an i18n perspective
+ message::success(t("Changed to %description",
+ array("description" => $providers->$new_provider)));
+ }
+
+ url::redirect("admin/identity");
+ }
+}
+
diff --git a/modules/gallery/views/admin_identity.html.php b/modules/gallery/views/admin_identity.html.php
new file mode 100644
index 00000000..dcf1dbc1
--- /dev/null
+++ b/modules/gallery/views/admin_identity.html.php
@@ -0,0 +1,61 @@
+<?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 Change Identity Provider") ?>",
+ resizable: false,
+ height:165,
+ modal: true,
+ overlay: {
+ backgroundColor: '#000',
+ opacity: 0.5
+ },
+ buttons: {
+ "Continue": function() {
+ $("##g-dialog form").submit();
+ },
+ Cancel: function() {
+ $(this).dialog('close');
+ }
+ }
+ });
+ });
+ return false;
+ });
+ });
+
+</script>
+<div id="g-modules">
+ <h1> <?= t("Gallery Identity Management") ?> </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>
+ <? $i = 0 ?>
+ <? foreach ($available as $module_name => $description): ?>
+ <tr class="<?= ($i % 2 == 0) ? "g-odd" : "g-even" ?>">
+ <? $data = array("name" => "provider"); ?>
+ <td> <?= form::radio($data, $module_name, $module_name == $active) ?> </td>
+ <td> <?= t($description) ?> </td>
+ </tr>
+ <? $i++ ?>
+ <? 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
new file mode 100644
index 00000000..e14525b5
--- /dev/null
+++ b/modules/gallery/views/admin_identity_confirm.html.php
@@ -0,0 +1,10 @@
+<?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("Do you really want to switch Identity providers? Continuing will delete all existing users.") ?>
+ </p>
+</form>
+