Skip to content

Commit

Permalink
The user must have some edit permission somewhere to create a tag
Browse files Browse the repository at this point in the history
  • Loading branch information
bharat committed Jan 30, 2010
1 parent 43cb6d9 commit 923a515
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions modules/tag/helpers/tags_rest.php
Expand Up @@ -28,10 +28,18 @@ static function get($request) {
}

static function post($request) {
// @todo: what permission should be required to create a tag here?
// for now, require edit at the top level. Perhaps later, just require any edit perms,
// anywhere in the gallery?
access::required("edit", item::root());
// The user must have some edit permission somewhere to create a tag.
if (!identity::active_user()->admin) {
$query = db::build()->from("access_caches")->and_open();
foreach (identity::active_user()->groups() as $group) {
$query->or_where("edit_{$group->id}", "=", access::ALLOW);
}
$has_any_edit_perm = $query->close()->count_records();

if (!$has_any_edit_perm) {
access::forbidden();
}
}

if (empty($request->params->name)) {
throw new Rest_Exception("Bad Request", 400);
Expand Down

0 comments on commit 923a515

Please sign in to comment.