summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-01-27 22:34:11 -0800
committerBharat Mediratta <bharat@menalto.com>2010-01-27 22:34:11 -0800
commit4b32a71afc7650fe7bdd02ba384c8914f60538f3 (patch)
tree66fea701b9324c1de79c31c548b643f331566223 /modules
parentcfbbf9ef606094868ccbd25ccf65e1a6f610528b (diff)
Convert back to using ORM::factory(..., $id) instead of calling where().
Diffstat (limited to 'modules')
-rw-r--r--modules/comment/models/comment.php2
-rw-r--r--modules/comment/tests/Comment_Event_Test.php2
-rw-r--r--modules/g2_import/controllers/g2.php2
-rw-r--r--modules/g2_import/helpers/g2_import.php11
-rw-r--r--modules/gallery/helpers/gallery_installer.php2
-rw-r--r--modules/gallery/helpers/item_rest.php2
-rw-r--r--modules/gallery/libraries/ORM_MPTT.php2
-rw-r--r--modules/gallery/models/item.php4
-rw-r--r--modules/server_add/controllers/server_add.php13
-rw-r--r--modules/tag/helpers/item_tags_rest.php2
-rw-r--r--modules/tag/helpers/tag_item_rest.php4
-rw-r--r--modules/tag/helpers/tag_items_rest.php2
-rw-r--r--modules/tag/helpers/tag_rest.php2
-rw-r--r--modules/user/models/group.php2
-rw-r--r--modules/user/models/user.php2
15 files changed, 26 insertions, 28 deletions
diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php
index 43c4148f..8be022b5 100644
--- a/modules/comment/models/comment.php
+++ b/modules/comment/models/comment.php
@@ -108,7 +108,7 @@ class Comment_Model extends ORM {
module::event("comment_created", $this);
} else {
// Updated comment
- $original = ORM::factory("comment")->where("id", "=", $this->id)->find();
+ $original = ORM::factory("comment", $this->id);
$visible_change = $original->state == "published" || $this->state == "published";
parent::save();
module::event("comment_updated", $original, $this);
diff --git a/modules/comment/tests/Comment_Event_Test.php b/modules/comment/tests/Comment_Event_Test.php
index 27272055..08f55b3f 100644
--- a/modules/comment/tests/Comment_Event_Test.php
+++ b/modules/comment/tests/Comment_Event_Test.php
@@ -30,6 +30,6 @@ class Comment_Event_Test extends Gallery_Unit_Test_Case {
$album->delete();
- $this->assert_false(ORM::factory("comment")->where("id", "=", $comment->id)->find()->loaded());
+ $this->assert_false(ORM::factory("comment", $comment->id)->loaded());
}
}
diff --git a/modules/g2_import/controllers/g2.php b/modules/g2_import/controllers/g2.php
index 3e002758..5fd4400c 100644
--- a/modules/g2_import/controllers/g2.php
+++ b/modules/g2_import/controllers/g2.php
@@ -50,7 +50,7 @@ class G2_Controller extends Admin_Controller {
throw new Kohana_404_Exception();
}
- $item = ORM::factory("item")->where("id", "=", $g2_map->g3_id)->find();
+ $item = ORM::factory("item", $g2_map->g3_id);
if (!$item->loaded() || !access::can("view", $item)) {
throw new Kohana_404_Exception();
}
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index 74164305..fa95e547 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -358,8 +358,7 @@ class g2_import_Core {
if ($g2_album->getParentId() == null) {
return t("Skipping Gallery 2 root album");
}
- $parent_album =
- ORM::factory("item")->where("id", "=", self::map($g2_album->getParentId()))->find();
+ $parent_album = ORM::factory("item", self::map($g2_album->getParentId()));
$album = ORM::factory("item");
$album->type = "album";
@@ -423,8 +422,8 @@ class g2_import_Core {
}
$item_id = self::map($g2_source->getId());
if ($item_id) {
- $item = ORM::factory("item")->where("id", "=", $item_id)->find();
- $g2_album = ORM::factory("item")->where("id", "=", $g3_album_id)->find();
+ $item = ORM::factory("item", $item_id);
+ $g2_album = ORM::factory("item", $g3_album_id);
$g2_album->album_cover_item_id = $item->id;
$g2_album->thumb_dirty = 1;
$g2_album->view_count = g2(GalleryCoreApi::fetchItemViewCount($g2_album_id));
@@ -452,7 +451,7 @@ class g2_import_Core {
array("id" => $g2_item_id, "exception" => (string)$e));
}
- $parent = ORM::factory("item")->where("id", "=", self::map($g2_item->getParentId()))->find();
+ $parent = ORM::factory("item", self::map($g2_item->getParentId()));
$g2_type = $g2_item->getEntityType();
$corrupt = 0;
@@ -633,7 +632,7 @@ class g2_import_Core {
GalleryCoreApi::requireOnce("modules/tags/classes/TagsHelper.class");
$g2_item_id = array_shift($queue);
- $g3_item = ORM::factory("item")->where("id", "=", self::map($g2_item_id))->find();
+ $g3_item = ORM::factory("item", self::map($g2_item_id));
if (!$g3_item->loaded()) {
return;
}
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index aa297236..bfab4645 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -228,7 +228,7 @@ class gallery_installer {
"updated" => $now,
"weight" => 1))
->execute();
- $root = ORM::factory("item")->where("id", "=", 1)->find();
+ $root = ORM::factory("item", 1);
access::add_item($root);
module::set_var("gallery", "active_site_theme", "wind");
diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php
index 2236fbbb..d5ca1456 100644
--- a/modules/gallery/helpers/item_rest.php
+++ b/modules/gallery/helpers/item_rest.php
@@ -145,7 +145,7 @@ class item_rest_Core {
}
static function resolve($id) {
- $item = ORM::factory("item")->where("id", "=", $id)->find();
+ $item = ORM::factory("item", $id);
if (!access::can("view", $item)) {
throw new Kohana_404_Exception();
}
diff --git a/modules/gallery/libraries/ORM_MPTT.php b/modules/gallery/libraries/ORM_MPTT.php
index a7bb24ea..83f9b51e 100644
--- a/modules/gallery/libraries/ORM_MPTT.php
+++ b/modules/gallery/libraries/ORM_MPTT.php
@@ -48,7 +48,7 @@ class ORM_MPTT_Core extends ORM {
function save() {
if (!$this->loaded()) {
$this->lock();
- $parent = ORM::factory("item")->where("id", "=", $this->parent_id)->find();
+ $parent = ORM::factory("item", $this->parent_id);
try {
// Make a hole in the parent for this new item
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 9706d61f..ae1b6608 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -423,7 +423,7 @@ class Item_Model extends ORM_MPTT {
// If any significant fields have changed, load up a copy of the original item and
// keep it around.
- $original = ORM::factory("item")->where("id", "=", $this->id)->find();
+ $original = ORM::factory("item", $this->id);
if (array_intersect($this->changed, array("parent_id", "name", "slug"))) {
$original->_build_relative_caches();
$this->relative_path_cache = null;
@@ -787,7 +787,7 @@ class Item_Model extends ORM_MPTT {
if ($this->is_movie() || $this->is_photo()) {
if ($this->loaded()) {
// Existing items can't change their extension
- $original = ORM::factory("item")->where("id", "=", $this->id)->find();
+ $original = ORM::factory("item", $this->id);
$new_ext = pathinfo($this->name, PATHINFO_EXTENSION);
$old_ext = pathinfo($original->name, PATHINFO_EXTENSION);
if (strcasecmp($new_ext, $old_ext)) {
diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php
index 4d6d5dfe..287855b6 100644
--- a/modules/server_add/controllers/server_add.php
+++ b/modules/server_add/controllers/server_add.php
@@ -24,7 +24,7 @@ class Server_Add_Controller extends Admin_Controller {
$files[] = $path;
}
- $item = ORM::factory("item")->where("id", "=", $id)->find();
+ $item = ORM::factory("item", $id);
$view = new View("server_add_tree_dialog.html");
$view->item = $item;
$view->tree = new View("server_add_tree.html");
@@ -78,7 +78,7 @@ class Server_Add_Controller extends Admin_Controller {
*/
public function start() {
access::verify_csrf();
- $item = ORM::factory("item")->where("id", "=", Input::instance()->get("item_id"))->find();
+ $item = ORM::factory("item", Input::instance()->get("item_id"));
foreach (Input::instance()->post("paths") as $path) {
if (server_add::is_valid_path($path)) {
@@ -104,7 +104,7 @@ class Server_Add_Controller extends Admin_Controller {
function run($task_id) {
access::verify_csrf();
- $task = ORM::factory("task")->where("id", "=", $task_id)->find();
+ $task = ORM::factory("task", $task_id);
if (!$task->loaded() || $task->owner_id != identity::active_user()->id) {
access::forbidden();
}
@@ -216,12 +216,11 @@ class Server_Add_Controller extends Admin_Controller {
// Look up the parent item for this entry. By now it should exist, but if none was
// specified, then this belongs as a child of the current item.
- $parent_entry =
- ORM::factory("server_add_file")->where("id", "=", $entry->parent_id)->find();
+ $parent_entry = ORM::factory("server_add_file", $entry->parent_id);
if (!$parent_entry->loaded()) {
- $parent = ORM::factory("item")->where("id", "=", $task->get("item_id"))->find();
+ $parent = ORM::factory("item", $task->get("item_id"));
} else {
- $parent = ORM::factory("item")->where("id", "=", $parent_entry->item_id)->find();
+ $parent = ORM::factory("item", $parent_entry->item_id);
}
$name = basename($entry->file);
diff --git a/modules/tag/helpers/item_tags_rest.php b/modules/tag/helpers/item_tags_rest.php
index ce814f77..43e2cef0 100644
--- a/modules/tag/helpers/item_tags_rest.php
+++ b/modules/tag/helpers/item_tags_rest.php
@@ -50,7 +50,7 @@ class item_tags_rest_Core {
}
static function resolve($id) {
- $item = ORM::factory("item")->where("id", "=", $id)->find();
+ $item = ORM::factory("item", $id);
if (!access::can("view", $item)) {
throw new Kohana_404_Exception();
}
diff --git a/modules/tag/helpers/tag_item_rest.php b/modules/tag/helpers/tag_item_rest.php
index cd9bb6fe..60d37437 100644
--- a/modules/tag/helpers/tag_item_rest.php
+++ b/modules/tag/helpers/tag_item_rest.php
@@ -35,8 +35,8 @@ class tag_item_rest_Core {
static function resolve($tuple) {
list ($tag_id, $item_id) = split(",", $tuple);
- $tag = ORM::factory("tag")->where("id", "=", $tag_id)->find();
- $item = ORM::factory("item")->where("id", "=", $item_id)->find();
+ $tag = ORM::factory("tag", $tag_id);
+ $item = ORM::factory("item", $item_id);
if (!$tag->loaded() || !$item->loaded() || !$tag->has($item)) {
throw new Kohana_404_Exception();
}
diff --git a/modules/tag/helpers/tag_items_rest.php b/modules/tag/helpers/tag_items_rest.php
index 369a8d83..ef563ac6 100644
--- a/modules/tag/helpers/tag_items_rest.php
+++ b/modules/tag/helpers/tag_items_rest.php
@@ -52,7 +52,7 @@ class tag_items_rest_Core {
}
static function resolve($id) {
- return ORM::factory("tag")->where("id", "=", $id)->find();
+ return ORM::factory("tag", $id);
}
static function url($tag) {
diff --git a/modules/tag/helpers/tag_rest.php b/modules/tag/helpers/tag_rest.php
index 7143daa9..4879cf63 100644
--- a/modules/tag/helpers/tag_rest.php
+++ b/modules/tag/helpers/tag_rest.php
@@ -77,7 +77,7 @@ class tag_rest_Core {
}
static function resolve($id) {
- $tag = ORM::factory("tag")->where("id", "=", $id)->find();
+ $tag = ORM::factory("tag", $id);
if (!$tag->loaded()) {
throw new Kohana_404_Exception();
}
diff --git a/modules/user/models/group.php b/modules/user/models/group.php
index 85114ede..851e72e6 100644
--- a/modules/user/models/group.php
+++ b/modules/user/models/group.php
@@ -55,7 +55,7 @@ class Group_Model extends ORM implements Group_Definition {
module::event("group_created", $this);
} else {
// Updated group
- $original = ORM::factory("group")->where("id", "=", $this->id)->find();
+ $original = ORM::factory("group", $this->id);
parent::save();
module::event("group_updated", $original, $this);
}
diff --git a/modules/user/models/user.php b/modules/user/models/user.php
index 7c97bae7..78c31047 100644
--- a/modules/user/models/user.php
+++ b/modules/user/models/user.php
@@ -99,7 +99,7 @@ class User_Model extends ORM implements User_Definition {
module::event("user_created", $this);
} else {
// Updated user
- $original = ORM::factory("user")->where("id", "=", $this->id)->find();
+ $original = ORM::factory("user", $this->id);
parent::save();
module::event("user_updated", $original, $this);
}