diff options
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r-- | modules/gallery/helpers/MY_url.php | 4 | ||||
-rw-r--r-- | modules/gallery/helpers/access.php | 18 | ||||
-rw-r--r-- | modules/gallery/helpers/album.php | 2 | ||||
-rw-r--r-- | modules/gallery/helpers/auth.php | 2 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_graphics.php | 2 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_task.php | 2 | ||||
-rw-r--r-- | modules/gallery/helpers/graphics.php | 2 | ||||
-rw-r--r-- | modules/gallery/helpers/identity.php | 4 | ||||
-rw-r--r-- | modules/gallery/helpers/item.php | 18 | ||||
-rw-r--r-- | modules/gallery/helpers/l10n_client.php | 2 | ||||
-rw-r--r-- | modules/gallery/helpers/l10n_scanner.php | 2 | ||||
-rw-r--r-- | modules/gallery/helpers/model_cache.php | 4 | ||||
-rw-r--r-- | modules/gallery/helpers/module.php | 35 | ||||
-rw-r--r-- | modules/gallery/helpers/movie.php | 2 | ||||
-rw-r--r-- | modules/gallery/helpers/photo.php | 2 | ||||
-rw-r--r-- | modules/gallery/helpers/site_status.php | 4 | ||||
-rw-r--r-- | modules/gallery/helpers/task.php | 8 | ||||
-rw-r--r-- | modules/gallery/helpers/theme.php | 2 |
18 files changed, 56 insertions, 59 deletions
diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php index 368c947e..e5eefad7 100644 --- a/modules/gallery/helpers/MY_url.php +++ b/modules/gallery/helpers/MY_url.php @@ -32,7 +32,7 @@ class url extends url_Core { } $item = self::get_item_from_uri(Router::$current_uri); - if ($item && $item->loaded) { + if ($item && $item->loaded()) { Router::$controller = "{$item->type}s"; Router::$controller_path = MODPATH . "gallery/controllers/{$item->type}s.php"; Router::$method = $item->id; @@ -51,7 +51,7 @@ class url extends url_Core { // but failing that, walk down the tree until we find it. The fallback code will fix caches // as it goes, so it'll never be run frequently. $item = ORM::factory("item")->where("relative_url_cache", $current_uri)->find(); - if (!$item->loaded) { + if (!$item->loaded()) { $count = count(Router::$segments); foreach (ORM::factory("item") ->where("slug", html_entity_decode(Router::$segments[$count - 1], ENT_QUOTES)) diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php index c1c1f9d1..9d27181a 100644 --- a/modules/gallery/helpers/access.php +++ b/modules/gallery/helpers/access.php @@ -91,7 +91,7 @@ class access_Core { * @return boolean */ static function user_can($user, $perm_name, $item) { - if (!$item->loaded) { + if (!$item->loaded()) { return false; } @@ -101,7 +101,7 @@ class access_Core { $resource = $perm_name == "view" ? $item : model_cache::get("access_cache", $item->id, "item_id"); - foreach ($user->groups as $group) { + foreach ($user->groups->find_all() as $group) { if ($resource->__get("{$perm_name}_{$group->id}") === self::ALLOW) { return true; } @@ -175,7 +175,7 @@ class access_Core { ->limit(1) ->find(); - if ($lock->loaded) { + if ($lock->loaded()) { return $lock; } else { return null; @@ -201,7 +201,7 @@ class access_Core { if (!($group instanceof Group_Definition)) { throw new Exception("@todo PERMISSIONS_ONLY_WORK_ON_GROUPS"); } - if (!$album->loaded) { + if (!$album->loaded()) { throw new Exception("@todo INVALID_ALBUM $album->id"); } if (!$album->is_album()) { @@ -282,7 +282,7 @@ class access_Core { */ static function register_permission($name, $display_name) { $permission = ORM::factory("permission", $name); - if ($permission->loaded) { + if ($permission->loaded()) { throw new Exception("@todo PERMISSION_ALREADY_EXISTS $name"); } $permission->name = $name; @@ -305,7 +305,7 @@ class access_Core { self::_drop_columns($name, $group); } $permission = ORM::factory("permission")->where("name", $name)->find(); - if ($permission->loaded) { + if ($permission->loaded()) { $permission->delete(); } } @@ -342,7 +342,7 @@ class access_Core { */ static function add_item($item) { $access_intent = ORM::factory("access_intent", $item->id); - if ($access_intent->loaded) { + if ($access_intent->loaded()) { throw new Exception("@todo ITEM_ALREADY_ADDED $item->id"); } $access_intent = ORM::factory("access_intent"); @@ -497,7 +497,7 @@ class access_Core { ->orderby("left_ptr", "DESC") ->limit(1) ->find(); - if ($tmp_item->loaded) { + if ($tmp_item->loaded()) { $item = $tmp_item; } } @@ -568,7 +568,7 @@ class access_Core { ->orderby("left_ptr", "DESC") ->limit(1) ->find(); - if ($tmp_item->loaded) { + if ($tmp_item->loaded()) { $item = $tmp_item; } } diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php index 72a79a75..c82a5509 100644 --- a/modules/gallery/helpers/album.php +++ b/modules/gallery/helpers/album.php @@ -34,7 +34,7 @@ class album_Core { * @return Item_Model */ static function create($parent, $name, $title, $description=null, $owner_id=null, $slug=null) { - if (!$parent->loaded || !$parent->is_album()) { + if (!$parent->loaded() || !$parent->is_album()) { throw new Exception("@todo INVALID_PARENT"); } diff --git a/modules/gallery/helpers/auth.php b/modules/gallery/helpers/auth.php index 9c69cecd..21a39bfb 100644 --- a/modules/gallery/helpers/auth.php +++ b/modules/gallery/helpers/auth.php @@ -46,7 +46,7 @@ class auth_Core { try { Session::instance()->destroy(); } catch (Exception $e) { - Kohana::log("error", $e); + Kohana_Log::add("error", $e); } module::event("user_logout", $user); } diff --git a/modules/gallery/helpers/gallery_graphics.php b/modules/gallery/helpers/gallery_graphics.php index c24d2bde..ce08bbd7 100644 --- a/modules/gallery/helpers/gallery_graphics.php +++ b/modules/gallery/helpers/gallery_graphics.php @@ -123,7 +123,7 @@ class gallery_graphics_Core { module::event("graphics_composite_completed", $input_file, $output_file, $options); } catch (ErrorException $e) { - Kohana::log("error", $e->get_message()); + Kohana_Log::add("error", $e->get_message()); } } } diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php index e0b03682..4d6de3ba 100644 --- a/modules/gallery/helpers/gallery_task.php +++ b/modules/gallery/helpers/gallery_task.php @@ -66,7 +66,7 @@ class gallery_task_Core { } $item = ORM::factory("item", $row->id); - if ($item->loaded) { + if ($item->loaded()) { try { graphics::generate($item); $completed++; diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index d6a2f00c..a78cadd0 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -171,7 +171,7 @@ class graphics_Core { } catch (Exception $e) { // Something went wrong rebuilding the image. Leave it dirty and move on. // @todo we should handle this better. - Kohana::log("error", "Caught exception rebuilding image: {$item->title}\n" . + Kohana_Log::add("error", "Caught exception rebuilding image: {$item->title}\n" . $e->getMessage() . "\n" . $e->getTraceAsString()); throw $e; } diff --git a/modules/gallery/helpers/identity.php b/modules/gallery/helpers/identity.php index 72e3312d..05614559 100644 --- a/modules/gallery/helpers/identity.php +++ b/modules/gallery/helpers/identity.php @@ -75,14 +75,14 @@ class identity_Core { if (!$session->get("group_ids")) { $ids = array(); - foreach ($user->groups as $group) { + foreach ($user->groups->find_all() as $group) { $ids[] = $group->id; } $session->set("group_ids", $ids); } } catch (Exception $e) { // Log it, so we at least have so notification that we swallowed the exception. - Kohana::log("error", "Load_user Exception: " . $e->__toString()); + Kohana_Log::add("error", "Load_user Exception: " . $e->__toString()); try { Session::instance()->destroy(); } catch (Exception $e) { diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index 8f96c3d9..109fa6f8 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -156,13 +156,7 @@ class item_Core { $view_restrictions = array(); if (!identity::active_user()->admin) { foreach (identity::group_ids_for_active_user() as $id) { - // Separate the first restriction from the rest to make it easier for us to formulate - // our where clause below - if (empty($view_restrictions)) { - $view_restrictions[0] = "items.view_$id"; - } else { - $view_restrictions[1]["items.view_$id"] = access::ALLOW; - } + $view_restrictions[] = "items.view_$id"; } } switch (count($view_restrictions)) { @@ -170,14 +164,14 @@ class item_Core { break; case 1: - $model->where($view_restrictions[0], access::ALLOW); + $model->where($view_restrictions[0], "=", access::ALLOW); break; default: - $model->open_paren(); - $model->where($view_restrictions[0], access::ALLOW); - $model->orwhere($view_restrictions[1]); - $model->close_paren(); + $model + ->and_open() + ->or_where($view_restrictions, "=", access::ALLOW) + ->close(); break; } diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php index 3460cc65..aaf6ff46 100644 --- a/modules/gallery/helpers/l10n_client.php +++ b/modules/gallery/helpers/l10n_client.php @@ -136,7 +136,7 @@ class l10n_client_Core { $entry = ORM::factory("incoming_translation") ->where(array("key" => $key, "locale" => $locale)) ->find(); - if (!$entry->loaded) { + if (!$entry->loaded()) { // @todo Load a message key -> message (text) dict into memory outside of this loop $root_entry = ORM::factory("incoming_translation") ->where(array("key" => $key, "locale" => "root")) diff --git a/modules/gallery/helpers/l10n_scanner.php b/modules/gallery/helpers/l10n_scanner.php index e36d419d..6c09a686 100644 --- a/modules/gallery/helpers/l10n_scanner.php +++ b/modules/gallery/helpers/l10n_scanner.php @@ -43,7 +43,7 @@ class l10n_scanner_Core { } $entry = ORM::factory("incoming_translation", array("key" => $key)); - if (!$entry->loaded) { + if (!$entry->loaded()) { $entry->key = $key; $entry->message = serialize($message); $entry->locale = "root"; diff --git a/modules/gallery/helpers/model_cache.php b/modules/gallery/helpers/model_cache.php index a3e09862..302e42d9 100644 --- a/modules/gallery/helpers/model_cache.php +++ b/modules/gallery/helpers/model_cache.php @@ -22,8 +22,8 @@ class model_cache_Core { static function get($model_name, $id, $field_name="id") { if (TEST_MODE || empty(self::$cache->$model_name->$field_name->$id)) { - $model = ORM::factory($model_name)->where($field_name, $id)->find(); - if (!$model->loaded) { + $model = ORM::factory($model_name)->where($field_name, "=", $id)->find(); + if (!$model->loaded()) { throw new Exception("@todo MISSING_MODEL $model_name:$id"); } self::$cache->$model_name->$field_name->$id = $model; diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index e6c196ce..e54a4352 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -36,13 +36,13 @@ class module_Core { */ static function set_version($module_name, $version) { $module = self::get($module_name); - if (!$module->loaded) { + if (!$module->loaded()) { $module->name = $module_name; $module->active = $module_name == "gallery"; // only gallery is active by default } $module->version = $version; $module->save(); - Kohana::log("debug", "$module_name: version is now $version"); + Kohana_Log::add("debug", "$module_name: version is now $version"); } /** @@ -126,9 +126,10 @@ class module_Core { * @param string $module_name */ static function install($module_name) { - $kohana_modules = Kohana::config("core.modules"); + $config = Kohana_Config::instance(); + $kohana_modules = $config->get("core.modules"); array_unshift($kohana_modules, MODPATH . $module_name); - Kohana::config_set("core.modules", $kohana_modules); + $config->set("core.modules", $kohana_modules); // Rebuild the include path so the module installer can benefit from auto loading Kohana::include_paths(true); @@ -142,7 +143,7 @@ class module_Core { // Now the module is installed but inactive, so don't leave it in the active path array_shift($kohana_modules); - Kohana::config_set("core.modules", $kohana_modules); + $config->set("core.modules", $kohana_modules); log::success( "module", t("Installed module %module_name", array("module_name" => $module_name))); @@ -193,9 +194,10 @@ class module_Core { * @param string $module_name */ static function activate($module_name) { - $kohana_modules = Kohana::config("core.modules"); + $config = Kohana_Config::instance(); + $kohana_modules = $config->get("core.modules"); array_unshift($kohana_modules, MODPATH . $module_name); - Kohana::config_set("core.modules", $kohana_modules); + $config->set("core.modules", $kohana_modules); $installer_class = "{$module_name}_installer"; if (method_exists($installer_class, "activate")) { @@ -203,7 +205,7 @@ class module_Core { } $module = self::get($module_name); - if ($module->loaded) { + if ($module->loaded()) { $module->active = true; $module->save(); } @@ -230,7 +232,7 @@ class module_Core { } $module = self::get($module_name); - if ($module->loaded) { + if ($module->loaded()) { $module->active = false; $module->save(); } @@ -257,7 +259,7 @@ class module_Core { graphics::remove_rules($module_name); $module = self::get($module_name); - if ($module->loaded) { + if ($module->loaded()) { $module->delete(); } module::load_modules(); @@ -290,8 +292,9 @@ class module_Core { } } self::$active[] = $gallery; // put gallery last in the module list to match core.modules - Kohana::config_set( - "core.modules", array_merge($kohana_modules, Kohana::config("core.modules"))); + $config = Kohana_Config::instance(); + $config->set( + "core.modules", array_merge($kohana_modules, $config->get("core.modules"))); } /** @@ -348,11 +351,11 @@ class module_Core { // We cache all vars in gallery._cache so that we can load all vars at once for // performance. if (empty(self::$var_cache)) { - $row = Database::instance() + $row = db::build() ->select("value") ->from("vars") ->where(array("module_name" => "gallery", "name" => "_cache")) - ->get() + ->execute() ->current(); if ($row) { self::$var_cache = unserialize($row->value); @@ -395,7 +398,7 @@ class module_Core { ->where("module_name", $module_name) ->where("name", $name) ->find(); - if (!$var->loaded) { + if (!$var->loaded()) { $var->module_name = $module_name; $var->name = $name; } @@ -432,7 +435,7 @@ class module_Core { ->where("module_name", $module_name) ->where("name", $name) ->find(); - if ($var->loaded) { + if ($var->loaded()) { $var->delete(); } diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php index e84e8ea6..a319471d 100644 --- a/modules/gallery/helpers/movie.php +++ b/modules/gallery/helpers/movie.php @@ -36,7 +36,7 @@ class movie_Core { */ static function create($parent, $filename, $name, $title, $description=null, $owner_id=null, $slug=null) { - if (!$parent->loaded || !$parent->is_album()) { + if (!$parent->loaded() || !$parent->is_album()) { throw new Exception("@todo INVALID_PARENT"); } diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php index 01cf5278..90cb108f 100644 --- a/modules/gallery/helpers/photo.php +++ b/modules/gallery/helpers/photo.php @@ -36,7 +36,7 @@ class photo_Core { */ static function create($parent, $filename, $name, $title, $description=null, $owner_id=null, $slug=null) { - if (!$parent->loaded || !$parent->is_album()) { + if (!$parent->loaded() || !$parent->is_album()) { throw new Exception("@todo INVALID_PARENT"); } diff --git a/modules/gallery/helpers/site_status.php b/modules/gallery/helpers/site_status.php index 2b090776..d58b935d 100644 --- a/modules/gallery/helpers/site_status.php +++ b/modules/gallery/helpers/site_status.php @@ -69,7 +69,7 @@ class site_status_Core { $message = ORM::factory("message") ->where("key", $permanent_key) ->find(); - if (!$message->loaded) { + if (!$message->loaded()) { $message->key = $permanent_key; } $message->severity = $severity; @@ -83,7 +83,7 @@ class site_status_Core { */ static function clear($permanent_key) { $message = ORM::factory("message")->where("key", $permanent_key)->find(); - if ($message->loaded) { + if ($message->loaded()) { $message->delete(); } } diff --git a/modules/gallery/helpers/task.php b/modules/gallery/helpers/task.php index dac5f9d3..4aa95f33 100644 --- a/modules/gallery/helpers/task.php +++ b/modules/gallery/helpers/task.php @@ -51,7 +51,7 @@ class task_Core { static function cancel($task_id) { $task = ORM::factory("task", $task_id); - if (!$task->loaded) { + if (!$task->loaded()) { throw new Exception("@todo MISSING_TASK"); } $task->done = 1; @@ -65,14 +65,14 @@ class task_Core { static function remove($task_id) { $task = ORM::factory("task", $task_id); - if ($task->loaded) { + if ($task->loaded()) { $task->delete(); } } static function run($task_id) { $task = ORM::factory("task", $task_id); - if (!$task->loaded) { + if (!$task->loaded()) { throw new Exception("@todo MISSING_TASK"); } @@ -84,7 +84,7 @@ class task_Core { } $task->save(); } catch (Exception $e) { - Kohana::log("error", $e->__toString()); + Kohana_Log::add("error", $e->__toString()); $task->log($e->__toString()); $task->state = "error"; $task->done = true; diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index 16ed104e..c7a9b49a 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -43,7 +43,7 @@ class theme_Core { } $modules = Kohana::config("core.modules"); array_unshift($modules, THEMEPATH . $theme_name); - Kohana::config_set("core.modules", $modules); + Kohana_Config::instance()->set("core.modules", $modules); } static function get_edit_form_admin() { |