Example #1
0
 public function testHaveTagAtLeastOneMatch()
 {
     $this->assertTrue($this->tagMapper->haveTag([1], 'testtype', $this->tag1->getId(), false), 'object1 has the tag tag1');
     $this->assertTrue($this->tagMapper->haveTag([1, 2], 'testtype', $this->tag1->getId(), false), 'object 1  and object 2 both the tag tag1');
     $this->assertTrue($this->tagMapper->haveTag([1, 2], 'testtype', $this->tag2->getId(), false), 'at least object 1 has the tag tag2');
     $this->assertFalse($this->tagMapper->haveTag([2], 'testtype', $this->tag2->getId(), false), 'object 2 does not have tag2');
     $this->assertFalse($this->tagMapper->haveTag([3], 'testtype', $this->tag2->getId(), false), 'object 3 does not have tag1 due to different type');
 }
Example #2
0
 public function delete()
 {
     try {
         $this->tagManager->deleteTags($this->tag->getId());
     } catch (TagNotFoundException $e) {
         // can happen if concurrent deletion occurred
         throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e);
     }
 }
 /**
  * Delete tag to object association
  */
 public function delete()
 {
     try {
         if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) {
             throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found');
         }
         if (!$this->tagManager->canUserAssignTag($this->tag, $this->user)) {
             throw new Forbidden('No permission to unassign tag ' . $this->tag->getId());
         }
         $this->tagMapper->unassignTags($this->objectId, $this->objectType, $this->tag->getId());
     } catch (TagNotFoundException $e) {
         // can happen if concurrent deletion occurred
         throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e);
     }
 }
Example #4
0
 public function delete()
 {
     try {
         if (!$this->isAdmin) {
             if (!$this->tag->isUserVisible()) {
                 throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found');
             }
             if (!$this->tag->isUserAssignable()) {
                 throw new Forbidden('No permission to delete tag ' . $this->tag->getId());
             }
         }
         $this->tagManager->deleteTags($this->tag->getId());
     } catch (TagNotFoundException $e) {
         // can happen if concurrent deletion occurred
         throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e);
     }
 }
 /**
  * @param ISystemTag $tag1
  * @param ISystemTag $tag2
  */
 private function assertSameTag($tag1, $tag2)
 {
     $this->assertEquals($tag1->getId(), $tag2->getId());
     $this->assertEquals($tag1->getName(), $tag2->getName());
     $this->assertEquals($tag1->isUserVisible(), $tag2->isUserVisible());
     $this->assertEquals($tag1->isUserAssignable(), $tag2->isUserAssignable());
 }
 /**
  * {@inheritdoc}
  */
 public function getTagGroups(ISystemTag $tag)
 {
     $groupIds = [];
     $query = $this->connection->getQueryBuilder();
     $query->select('gid')->from(self::TAG_GROUP_TABLE)->where($query->expr()->eq('systemtagid', $query->createNamedParameter($tag->getId())))->orderBy('gid');
     $result = $query->execute();
     while ($row = $result->fetch()) {
         $groupIds[] = $row['gid'];
     }
     $result->closeCursor();
     return $groupIds;
 }
Example #7
0
 /**
  * @param ISystemTag $tag
  * @return string
  */
 protected function prepareTagAsParameter(ISystemTag $tag)
 {
     if (!$tag->isUserVisible()) {
         return '{{{' . $tag->getName() . '|||invisible}}}';
     } else {
         if (!$tag->isUserAssignable()) {
             return '{{{' . $tag->getName() . '|||not-assignable}}}';
         } else {
             return '{{{' . $tag->getName() . '|||assignable}}}';
         }
     }
 }