Browse Source

Bring back admin permissions to change system tag permissions

remotes/origin/throw-loginexception-failed-login
Vincent Petry 10 years ago
parent
commit
bede872dbc
No known key found for this signature in database GPG Key ID: AF8F9EFC56562186
  1. 16
      apps/dav/lib/SystemTag/SystemTagNode.php
  2. 2
      apps/dav/lib/SystemTag/SystemTagsByIdCollection.php

16
apps/dav/lib/SystemTag/SystemTagNode.php

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

2
apps/dav/lib/SystemTag/SystemTagsByIdCollection.php

@ -174,6 +174,6 @@ class SystemTagsByIdCollection implements ICollection {
* @return SystemTagNode * @return SystemTagNode
*/ */
private function makeNode(ISystemTag $tag) { 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);
} }
} }
Loading…
Cancel
Save