|
|
@ -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) { |
|
|
|