Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add merge_or_where() to MY_Datatabase_Builder and use that instead of

or_where() for compatibility and convenience.  Caught by failing unit
tests.
  • Loading branch information...
commit 0650109d4bb5442cd77fcda61745dab67a632836 1 parent 7118f84
@bharat bharat authored
View
4 modules/gallery/helpers/item.php
@@ -155,12 +155,12 @@ static function viewable($model) {
$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;
View
11 modules/kohana23_compat/libraries/MY_Database_Builder.php
@@ -29,6 +29,17 @@ public function merge_where($tuples) {
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();
}
Please sign in to comment.
Something went wrong with that request. Please try again.