summaryrefslogtreecommitdiff
path: root/modules/comment
diff options
context:
space:
mode:
Diffstat (limited to 'modules/comment')
-rw-r--r--modules/comment/controllers/admin_comments.php26
-rw-r--r--modules/comment/helpers/comment_block.php2
-rw-r--r--modules/comment/helpers/comment_event.php11
-rw-r--r--modules/comment/helpers/comment_rss.php6
-rw-r--r--modules/comment/helpers/comment_theme.php6
-rw-r--r--modules/comment/models/comment.php2
-rw-r--r--modules/comment/tests/Comment_Event_Test.php2
-rw-r--r--modules/comment/tests/Comment_Model_Test.php4
8 files changed, 30 insertions, 29 deletions
diff --git a/modules/comment/controllers/admin_comments.php b/modules/comment/controllers/admin_comments.php
index 13532c4e..880c33a7 100644
--- a/modules/comment/controllers/admin_comments.php
+++ b/modules/comment/controllers/admin_comments.php
@@ -22,10 +22,11 @@ class Admin_Comments_Controller extends Admin_Controller {
public function index() {
// Get rid of old deleted/spam comments once in a while
- Database::instance()->query(
- "DELETE FROM {comments} " .
- "WHERE state IN ('deleted', 'spam') " .
- "AND unix_timestamp(now()) - updated > 86400 * 7");
+ db::build()
+ ->delete("comments")
+ ->where("state", "IN", array("deleted", "spam"))
+ ->where("updated", "<", "UNIX_TIMESTAMP() - 86400 * 7")
+ ->execute();
// Redirect to the appropriate queue
url::redirect("admin/comments/queue/unpublished");
@@ -48,8 +49,8 @@ class Admin_Comments_Controller extends Admin_Controller {
$view->content->menu = $this->_menu($view->content->counts);
$view->content->state = $state;
$view->content->comments = ORM::factory("comment")
- ->orderby("created", "DESC")
- ->where("state", $state)
+ ->order_by("created", "DESC")
+ ->where("state", "=", $state)
->limit(self::$items_per_page, ($page - 1) * self::$items_per_page)
->find_all();
$view->content->pager = new Pagination();
@@ -95,11 +96,12 @@ class Admin_Comments_Controller extends Admin_Controller {
$counts->published = 0;
$counts->spam = 0;
$counts->deleted = 0;
- foreach (Database::instance()
- ->select("state", "count(*) as c")
+ foreach (db::build()
+ ->select("state")
+ ->select(array("c" => 'COUNT("*")'))
->from("comments")
- ->groupby("state")
- ->get() as $row) {
+ ->group_by("state")
+ ->execute() as $row) {
$counts->{$row->state} = $row->c;
}
return $counts;
@@ -110,7 +112,7 @@ class Admin_Comments_Controller extends Admin_Controller {
$comment = ORM::factory("comment", $id);
$orig = clone $comment;
- if ($comment->loaded) {
+ if ($comment->loaded()) {
$comment->state = $state;
$comment->save();
}
@@ -120,7 +122,7 @@ class Admin_Comments_Controller extends Admin_Controller {
access::verify_csrf();
ORM::factory("comment")
- ->where("state", "spam")
+ ->where("state", "=", "spam")
->delete_all();
url::redirect("admin/comments/queue/spam");
}
diff --git a/modules/comment/helpers/comment_block.php b/modules/comment/helpers/comment_block.php
index 7cd5d429..ab86b90a 100644
--- a/modules/comment/helpers/comment_block.php
+++ b/modules/comment/helpers/comment_block.php
@@ -30,7 +30,7 @@ class comment_block_Core {
$block->title = t("Recent comments");
$block->content = new View("admin_block_recent_comments.html");
$block->content->comments =
- ORM::factory("comment")->orderby("created", "DESC")->limit(5)->find_all();
+ ORM::factory("comment")->order_by("created", "DESC")->limit(5)->find_all();
break;
}
diff --git a/modules/comment/helpers/comment_event.php b/modules/comment/helpers/comment_event.php
index a72102b9..c90f7663 100644
--- a/modules/comment/helpers/comment_event.php
+++ b/modules/comment/helpers/comment_event.php
@@ -29,7 +29,7 @@ class comment_event_Core {
"guest_email" => null,
"guest_name" => "guest",
"guest_url" => null))
- ->where(array("author_id" => $user->id))
+ ->where("author_id", "=", $user->id)
->update();
}
@@ -40,7 +40,7 @@ class comment_event_Core {
"guest_email" => null,
"guest_name" => "guest",
"guest_url" => null))
- ->where("1 = 1")
+ ->where("1", "=", "1") // @todo: why do we do this?
->update();
}
@@ -62,12 +62,11 @@ class comment_event_Core {
}
static function item_index_data($item, $data) {
- foreach (Database::instance()
+ foreach (db::build()
->select("text")
->from("comments")
- ->where("item_id", $item->id)
- ->get()
- ->as_array() as $row) {
+ ->where("item_id", "=", $item->id)
+ ->execute() as $row) {
$data[] = $row->text;
}
}
diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php
index 3692a30d..77044884 100644
--- a/modules/comment/helpers/comment_rss.php
+++ b/modules/comment/helpers/comment_rss.php
@@ -35,11 +35,11 @@ class comment_rss_Core {
$comments = ORM::factory("comment")
->viewable()
- ->where("state", "published")
- ->orderby("created", "DESC");
+ ->where("state", "=", "published")
+ ->order_by("created", "DESC");
if ($feed_id == "item") {
- $comments->where("item_id", $id);
+ $comments->where("item_id", "=", $id);
}
$feed->view = "comment.mrss";
diff --git a/modules/comment/helpers/comment_theme.php b/modules/comment/helpers/comment_theme.php
index af0e1ca4..ebcc1c42 100644
--- a/modules/comment/helpers/comment_theme.php
+++ b/modules/comment/helpers/comment_theme.php
@@ -37,9 +37,9 @@ class comment_theme_Core {
$view = new View("comments.html");
$view->comments = ORM::factory("comment")
- ->where("item_id", $theme->item()->id)
- ->where("state", "published")
- ->orderby("created", "ASC")
+ ->where("item_id", "=", $theme->item()->id)
+ ->where("state", "=", "published")
+ ->order_by("created", "ASC")
->find_all();
$block->content = $view;
diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php
index bb9b8833..59b85233 100644
--- a/modules/comment/models/comment.php
+++ b/modules/comment/models/comment.php
@@ -59,7 +59,7 @@ class Comment_Model extends ORM {
public function save() {
if (!empty($this->changed)) {
$this->updated = time();
- if (!$this->loaded && empty($this->created)) {
+ if (!$this->loaded() && empty($this->created)) {
$this->created = $this->updated;
$created = true;
}
diff --git a/modules/comment/tests/Comment_Event_Test.php b/modules/comment/tests/Comment_Event_Test.php
index f650cabf..ff7f1c26 100644
--- a/modules/comment/tests/Comment_Event_Test.php
+++ b/modules/comment/tests/Comment_Event_Test.php
@@ -27,6 +27,6 @@ class Comment_Event_Test extends Unit_Test_Case {
$album->delete();
$deleted_comment = ORM::factory("comment", $comment->id);
- $this->assert_false($deleted_comment->loaded);
+ $this->assert_false($deleted_comment->loaded());
}
}
diff --git a/modules/comment/tests/Comment_Model_Test.php b/modules/comment/tests/Comment_Model_Test.php
index de19648d..aa91d6f2 100644
--- a/modules/comment/tests/Comment_Model_Test.php
+++ b/modules/comment/tests/Comment_Model_Test.php
@@ -29,12 +29,12 @@ class Comment_Model_Test extends Unit_Test_Case {
access::allow(identity::everybody(), "view", $album);
$this->assert_equal(
1,
- ORM::factory("comment")->viewable()->where("comments.id", $comment->id)->count_all());
+ ORM::factory("comment")->viewable()->where("comments.id", "=", $comment->id)->count_all());
// We can't see the comment when permissions are denied on the album
access::deny(identity::everybody(), "view", $album);
$this->assert_equal(
0,
- ORM::factory("comment")->viewable()->where("comments.id", $comment->id)->count_all());
+ ORM::factory("comment")->viewable()->where("comments.id", "=", $comment->id)->count_all());
}
}