Bring back admin permissions to change system tag permissions

This commit is contained in:
Vincent Petry 2016-05-11 14:11:12 +02:00
parent b5eb3d9e5a
commit bede872dbc
No known key found for this signature in database
GPG Key ID: AF8F9EFC56562186
2 changed files with 19 additions and 9 deletions

View File

@ -56,16 +56,25 @@ class SystemTagNode implements \Sabre\DAV\INode {
*/
protected $user;
/**
* Whether to allow permissions for admins
*
* @var bool
*/
protected $isAdmin;
/**
* Sets up the node, expects a full path name
*
* @param ISystemTag $tag system tag
* @param IUser $user user
* @param bool $isAdmin whether to allow operations for admins
* @param ISystemTagManager $tagManager tag manager
*/
public function __construct(ISystemTag $tag, IUser $user, ISystemTagManager $tagManager) {
public function __construct(ISystemTag $tag, IUser $user, $isAdmin, ISystemTagManager $tagManager) {
$this->tag = $tag;
$this->user = $user;
$this->isAdmin = $isAdmin;
$this->tagManager = $tagManager;
}
@ -117,13 +126,14 @@ class SystemTagNode implements \Sabre\DAV\INode {
throw new Forbidden('No permission to update tag ' . $this->tag->getId());
}
// FIXME: admin should be able to change permissions still
// only renaming is allowed for regular users
if ($userVisible !== $this->tag->isUserVisible()
|| $userAssignable !== $this->tag->isUserAssignable()
) {
throw new Forbidden('No permission to update permissions for tag ' . $this->tag->getId());
// only admin is able to change permissions, regular users can only rename
if (!$this->isAdmin) {
// only renaming is allowed for regular users
if ($userVisible !== $this->tag->isUserVisible()
|| $userAssignable !== $this->tag->isUserAssignable()
) {
throw new Forbidden('No permission to update permissions for tag ' . $this->tag->getId());
}
}
$this->tagManager->updateTag($this->tag->getId(), $name, $userVisible, $userAssignable);

View File

@ -174,6 +174,6 @@ class SystemTagsByIdCollection implements ICollection {
* @return SystemTagNode
*/
private function makeNode(ISystemTag $tag) {
return new SystemTagNode($tag, $this->userSession->getUser(), $this->tagManager);
return new SystemTagNode($tag, $this->userSession->getUser(), $this->isAdmin(), $this->tagManager);
}
}