summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-12-22 13:50:52 -0800
committerBharat Mediratta <bharat@menalto.com>2009-12-22 13:50:52 -0800
commit0650109d4bb5442cd77fcda61745dab67a632836 (patch)
treed2afe8cfb857dcb58764c96e467edbd68c73ee02
parent7118f84aa9ae0ece97a41aba4e4d269a1e136df6 (diff)
Add merge_or_where() to MY_Datatabase_Builder and use that instead of
or_where() for compatibility and convenience. Caught by failing unit tests.
-rw-r--r--modules/gallery/helpers/item.php4
-rw-r--r--modules/kohana23_compat/libraries/MY_Database_Builder.php11
2 files changed, 13 insertions, 2 deletions
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index b7be23cd..f6181f8a 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -155,12 +155,12 @@ class item_Core {
$view_restrictions = array();
if (!identity::active_user()->admin) {
foreach (identity::group_ids_for_active_user() as $id) {
- $view_restrictions["items.view_$id"] = access::ALLOW;
+ $view_restrictions[] = array("items.view_$id", "=", access::ALLOW);
}
}
if (count($view_restrictions)) {
- $model->and_open()->or_where($view_restrictions)->close();
+ $model->and_open()->merge_or_where($view_restrictions)->close();
}
return $model;
diff --git a/modules/kohana23_compat/libraries/MY_Database_Builder.php b/modules/kohana23_compat/libraries/MY_Database_Builder.php
index 54a10860..c82b6ac4 100644
--- a/modules/kohana23_compat/libraries/MY_Database_Builder.php
+++ b/modules/kohana23_compat/libraries/MY_Database_Builder.php
@@ -29,6 +29,17 @@ class Database_Builder extends Database_Builder_Core {
return $this;
}
+ /**
+ * Merge in a series of where clause tuples and call or_where() on each one.
+ * @chainable
+ */
+ public function merge_or_where($tuples) {
+ foreach ($tuples as $tuple) {
+ $this->or_where($tuple[0], $tuple[1], $tuple[2]);
+ }
+ return $this;
+ }
+
public function compile() {
return parent::compile();
}