diff options
author | Andy Staudacher <andy.st@gmail.com> | 2009-07-27 11:27:50 -0700 |
---|---|---|
committer | Andy Staudacher <andy.st@gmail.com> | 2009-07-27 11:27:50 -0700 |
commit | e68599f6d7dd2e18beaf48d9ba635ae93670101f (patch) | |
tree | a1876c3005f5abc239d92ce18ea630f4dbf5bf6d /modules/gallery/models | |
parent | d18f31ab218c8d79d97b19079ac0078e6155bc39 (diff) | |
parent | 4edf86f0ebfedbbdfda3daf71ed55a461edf9c6c (diff) |
Merge branch 'master' of git@github.com:gallery/gallery3
Diffstat (limited to 'modules/gallery/models')
-rw-r--r-- | modules/gallery/models/item.php | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index c1d11a96..038e11fb 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -38,17 +38,31 @@ class Item_Model extends ORM_MPTT { if (user::active()->admin) { $this->view_restrictions = array(); } else { - $this->view_restrictions["owner_id"] = user::active()->id; foreach (user::group_ids() as $id) { - $this->view_restrictions["view_$id"] = access::ALLOW; + // Separate the first restriction from the rest to make it easier for us to formulate + // our where clause below + if (empty($this->view_restrictions)) { + $this->view_restrictions[0] = "view_$id"; + } else { + $this->view_restrictions[1]["view_$id"] = access::ALLOW; + } } } } + switch (count($this->view_restrictions)) { + case 0: + break; - if (!empty($this->view_restrictions)) { + case 1: + $this->where($this->view_restrictions[0], access::ALLOW); + break; + + default: $this->open_paren(); - $this->orwhere($this->view_restrictions); + $this->where($this->view_restrictions[0], access::ALLOW); + $this->orwhere($this->view_restrictions[1]); $this->close_paren(); + break; } return $this; |