summaryrefslogtreecommitdiff
path: root/core/controllers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-12-01 08:50:00 +0000
committerBharat Mediratta <bharat@menalto.com>2008-12-01 08:50:00 +0000
commit91c4bda1ec6640abb8b1a585e1fd1f8955d53fd1 (patch)
tree42f8f79c6d356a04d0e8365a0921d7257f12c64d /core/controllers
parentab0fcb7453db7d93c9dc1dfd38e6d6f84a5b16b5 (diff)
Prototype access control model. There's much left to do, but it's a
working implementation.
Diffstat (limited to 'core/controllers')
-rw-r--r--core/controllers/items.php3
-rw-r--r--core/controllers/welcome.php38
2 files changed, 33 insertions, 8 deletions
diff --git a/core/controllers/items.php b/core/controllers/items.php
index 26b55492..6cf27fbf 100644
--- a/core/controllers/items.php
+++ b/core/controllers/items.php
@@ -99,11 +99,10 @@ class Items_Controller extends REST_Controller {
// 1) Add security checks
$parent = $item->parent();
if ($parent->id) {
+ module::event("{$item->type}_before_delete", $item);
$item->delete();
}
- module::event("{$item->type}_deleted", $item);
-
url::redirect("{$parent->type}s/{$parent->id}");
}
diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php
index c29a5aaf..cabaf0a9 100644
--- a/core/controllers/welcome.php
+++ b/core/controllers/welcome.php
@@ -71,16 +71,33 @@ class Welcome_Controller extends Template_Controller {
}
function uninstall($module_name) {
+ $clean = true;
if ($module_name == "core") {
// We have to uninstall all other modules first, else their tables, etc don't
// get cleaned up.
- foreach (ORM::factory("module")->find_all() as $module) {
- if ($module->name != "core" && $module->version) {
- call_user_func(array("{$module->name}_installer", "uninstall"));
+ try {
+ foreach (ORM::factory("module")->find_all() as $module) {
+ if ($module->name != "core" && $module->version) {
+ try {
+ call_user_func(array("{$module->name}_installer", "uninstall"));
+ } catch (Exception $e) {
+ $clean = false;
+ }
+ }
}
- }
+ } catch (Exception $e) { }
}
call_user_func(array("{$module_name}_installer", "uninstall"));
+
+ $clean = false;
+ if (!$clean) {
+ // Since we're in a state of flux, it's possible that other stuff went wrong with the
+ // uninstall, so back off and nuke things from orbit.
+ $db = Database::instance();
+ foreach ($db->list_tables() as $table) {
+ $db->query("DROP TABLE `$table`");
+ }
+ }
url::redirect("welcome");
}
@@ -442,7 +459,7 @@ class Welcome_Controller extends Template_Controller {
url::redirect("welcome");
}
- public function _load_album_tree() {
+ private function _load_album_tree() {
$tree = array();
foreach (ORM::factory("item")->where("type", "album")->find_all() as $album) {
if ($album->parent_id) {
@@ -451,7 +468,16 @@ class Welcome_Controller extends Template_Controller {
$tree[$album->id]->album = $album;
$tree[$album->id]->children = array();
}
-
return $tree;
}
+
+ public function add_perm($group_id, $perm, $item_id) {
+ access::allow($group_id, $perm, $item_id);
+ url::redirect("welcome");
+ }
+
+ public function deny_perm($group_id, $perm, $item_id) {
+ access::deny($group_id, $perm, $item_id);
+ url::redirect("welcome");
+ }
}