Skip to content

Commit

Permalink
Revert "Fix for ticket #452"
Browse files Browse the repository at this point in the history
This reverts commit 809e52d.
  • Loading branch information
Tim Almdal committed Jul 27, 2009
1 parent 5fd82a2 commit 4edf86f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion modules/gallery/helpers/access.php
Expand Up @@ -95,7 +95,7 @@ static function user_can($user, $perm_name, $item) {
return false;
}

if ($user->admin && $item->owner_id == $user->id) {
if ($user->admin) {
return true;
}

Expand Down
22 changes: 18 additions & 4 deletions modules/gallery/models/item.php
Expand Up @@ -38,17 +38,31 @@ public function viewable() {
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;
Expand Down

0 comments on commit 4edf86f

Please sign in to comment.