summaryrefslogtreecommitdiff
path: root/modules/gallery
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery')
-rw-r--r--modules/gallery/controllers/movies.php2
-rw-r--r--modules/gallery/controllers/photos.php2
-rw-r--r--modules/gallery/libraries/ORM_MPTT.php8
-rw-r--r--modules/gallery/models/item.php16
4 files changed, 15 insertions, 13 deletions
diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php
index 7ceeefdf..157c388f 100644
--- a/modules/gallery/controllers/movies.php
+++ b/modules/gallery/controllers/movies.php
@@ -21,7 +21,7 @@ class Movies_Controller extends Items_Controller {
public function _show($movie) {
access::required("view", $movie);
- $where = array("type != " => "album");
+ $where = array(array("type", "!=", "album"));
$position = $movie->parent()->get_position($movie, $where);
if ($position > 1) {
list ($previous_item, $ignore, $next_item) =
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index 0d7daac4..478447b1 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -21,7 +21,7 @@ class Photos_Controller extends Items_Controller {
public function _show($photo) {
access::required("view", $photo);
- $where = array("type != " => "album");
+ $where = array(array("type", "!=", "album"));
$position = $photo->parent()->get_position($photo, $where);
if ($position > 1) {
list ($previous_item, $ignore, $next_item) =
diff --git a/modules/gallery/libraries/ORM_MPTT.php b/modules/gallery/libraries/ORM_MPTT.php
index 01b2d7b7..90b9d38a 100644
--- a/modules/gallery/libraries/ORM_MPTT.php
+++ b/modules/gallery/libraries/ORM_MPTT.php
@@ -152,7 +152,7 @@ class ORM_MPTT_Core extends ORM {
*/
function children($limit=null, $offset=0, $where=null, $order_by=array("id" => "ASC")) {
if ($where) {
- $this->where($where);
+ $this->merge_where($where);
}
return $this
@@ -170,7 +170,7 @@ class ORM_MPTT_Core extends ORM {
*/
function children_count($where=null) {
if ($where) {
- $this->where($where);
+ $this->merge_where($where);
}
return $this
@@ -189,7 +189,7 @@ class ORM_MPTT_Core extends ORM {
*/
function descendants($limit=null, $offset=0, $where=null, $order_by=array("id" => "ASC")) {
if ($where) {
- $this->where($where);
+ $this->merge_where($where);
}
return $this
@@ -207,7 +207,7 @@ class ORM_MPTT_Core extends ORM {
*/
function descendants_count($where=null) {
if ($where) {
- $this->where($where);
+ $this->merge_where($where);
}
return $this
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index c8d25cc5..acc4e96f 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -428,14 +428,14 @@ class Item_Model extends ORM_MPTT {
} else {
$comp = "<";
}
- $db = Database::instance();
+ $db = db::build();
// If the comparison column has NULLs in it, we can't use comparators on it and will have to
// deal with it the hard way.
$count = $db->from("items")
->where("parent_id", "=", $this->id)
->where($this->sort_column, "=", NULL)
- ->where($where)
+ ->merge_where($where)
->count_records();
if (empty($count)) {
@@ -445,7 +445,7 @@ class Item_Model extends ORM_MPTT {
$position = $db->from("items")
->where("parent_id", "=", $this->id)
->where($sort_column, $comp, $child->$sort_column)
- ->where($where)
+ ->merge_where($where)
->count_records();
// We stopped short of our target value in the sort (notice that we're using a < comparator
@@ -456,12 +456,14 @@ class Item_Model extends ORM_MPTT {
//
// Fix this by doing a 2nd query where we iterate over the equivalent columns and add them to
// our base value.
- foreach ($db->from("items")
+ foreach ($db
+ ->select("id")
+ ->from("items")
->where("parent_id", "=", $this->id)
->where($sort_column, "=", $child->$sort_column)
- ->where($where)
+ ->merge_where($where)
->order_by(array("id" => "ASC"))
- ->get() as $row) {
+ ->execute() as $row) {
$position++;
if ($row->id == $child->id) {
break;
@@ -485,7 +487,7 @@ class Item_Model extends ORM_MPTT {
foreach ($db->select("id")
->from("items")
->where("parent_id", "=", $this->id)
- ->where($where)
+ ->merge_where($where)
->order_by($order_by)
->get() as $row) {
$position++;