diff options
author | Bharat Mediratta <bharat@menalto.com> | 2008-12-22 06:50:20 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2008-12-22 06:50:20 +0000 |
commit | bdc0876fa86e29ee439e69024f6f476c49886b99 (patch) | |
tree | ee1b629c7b241322f966eaf287549c8c1aefdc1d /core | |
parent | f6381c534e92e230349f5633eb280a22421d9050 (diff) |
Add messaging system for reporting actions back to the user. Make
module install/uninstall work and tie it into the messaging system.
Diffstat (limited to 'core')
-rw-r--r-- | core/controllers/admin_modules.php | 16 | ||||
-rw-r--r-- | core/helpers/log.php | 4 | ||||
-rw-r--r-- | core/helpers/message.php | 36 | ||||
-rw-r--r-- | core/helpers/module.php | 2 | ||||
-rw-r--r-- | core/libraries/Admin_View.php | 7 | ||||
-rw-r--r-- | core/libraries/Theme_View.php | 7 | ||||
-rw-r--r-- | core/views/admin_modules.html.php | 2 |
7 files changed, 71 insertions, 3 deletions
diff --git a/core/controllers/admin_modules.php b/core/controllers/admin_modules.php index a9769ba6..ada7dcfd 100644 --- a/core/controllers/admin_modules.php +++ b/core/controllers/admin_modules.php @@ -25,7 +25,21 @@ class Admin_Modules_Controller extends Admin_Controller { } public function save() { - // Nothing yet + foreach (module::available() as $module_name => $info) { + if ($info->locked) { + continue; + } + + $desired = $this->input->post($module_name) == 1; + if ($info->installed && !$desired) { + module::uninstall($module_name); + message::add(sprintf(_("Uninstalled %s module"), $info->name)); + } else if (!$info->installed && $desired) { + module::install($module_name); + message::add(sprintf(_("Installed %s module"), $info->name)); + } + } + url::redirect("admin/modules"); } } diff --git a/core/helpers/log.php b/core/helpers/log.php index a5a0a079..43e2b8f8 100644 --- a/core/helpers/log.php +++ b/core/helpers/log.php @@ -39,7 +39,9 @@ class log_Core { $log->url = url::abs_current(true); $log->referer = request::referrer(null); $log->timestamp = time(); - $log->user_id = user::active()->id; + if (module::is_installed("user")) { + $log->user_id = user::active()->id; + } $log->save(); } } diff --git a/core/helpers/message.php b/core/helpers/message.php new file mode 100644 index 00000000..ff9e4c82 --- /dev/null +++ b/core/helpers/message.php @@ -0,0 +1,36 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2008 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 message_Core { + public function add($msg) { + $session = Session::instance(); + $status = $session->get("messages"); + $status[] = $msg; + $session->set("messages", $status); + } + + public function get() { + $messages = Session::instance()->get_once("messages", array()); + if ($messages) { + return "<ul id=\"gMessages\"><li>" . + join("</li><li>", $messages) . + "</li>"; + } + } +} diff --git a/core/helpers/module.php b/core/helpers/module.php index fc7d7042..0e1f9d44 100644 --- a/core/helpers/module.php +++ b/core/helpers/module.php @@ -126,6 +126,7 @@ class module_Core { } self::load_modules(); + log::add("module", sprintf(_("Installed module %s"), $module_name)); } /** @@ -135,6 +136,7 @@ class module_Core { $installer_class = "{$module_name}_installer"; Kohana::log("debug", "$installer_class uninstall"); call_user_func(array($installer_class, "uninstall")); + log::add("module", sprintf(_("Uninstalled module %s"), $module_name)); } /** diff --git a/core/libraries/Admin_View.php b/core/libraries/Admin_View.php index c172b76b..e9ff9791 100644 --- a/core/libraries/Admin_View.php +++ b/core/libraries/Admin_View.php @@ -60,6 +60,13 @@ class Admin_View_Core extends View { print $menu; } + /** + * Print out any messages waiting for this user. + */ + public function messages() { + return message::get(); + } + /** * Handle all theme functions that insert module content. */ diff --git a/core/libraries/Theme_View.php b/core/libraries/Theme_View.php index 3144ca2a..030e564d 100644 --- a/core/libraries/Theme_View.php +++ b/core/libraries/Theme_View.php @@ -85,6 +85,13 @@ class Theme_View_Core extends View { } /** + * Print out any messages waiting for this user. + */ + public function messages() { + return message::get(); + } + + /** * Handle all theme functions that insert module content. */ public function __call($function, $args) { diff --git a/core/views/admin_modules.html.php b/core/views/admin_modules.html.php index 8d7f3c4f..93d8caf4 100644 --- a/core/views/admin_modules.html.php +++ b/core/views/admin_modules.html.php @@ -13,7 +13,7 @@ <tr> <? $data = array("name" => $module_name); ?> <? if ($module_info->locked) $data["disabled"] = 1; ?> - <td> <?= form::checkbox($data, '', module::is_installed($module_name)) ?> </td> + <td> <?= form::checkbox($data, '1', module::is_installed($module_name)) ?> </td> <td> <?= _($module_info->name) ?> </td> <td> <?= $module_info->version ?> </td> <td> <?= _($module_info->description) ?> </td> |