Add to blacklist

Add tag name to blacklist. Must be admin to access.

@param string $name The tag value to be added to the blacklist.
@param string $sid Session ID that is provided when logged in. This is also set as a cookie.

@return array
764272
public function add($name, $sid = NULL) {
  $user = new User;
  if (!$user->isAdmin($sid)) throw new \JohnVanOrange\Core\Exception\NotAllowed('Must be an admin to access method', 401);
  if (strlen($name) < 1 OR $name == NULL) throw new \Exception('Tag name cannot be empty');
  $tag = htmlspecialchars(trim(stripslashes($name)));
  $slug = $this->text2slug($tag);
  if ($slug == '') throw new \Exception('Invalid tag name', 1030);

  $res = new \JohnVanOrange\Core\Resource('bl', $sid);
  $res->setValue($slug);
  $res->add();

  return [
   'message' => 'Tag added to blacklist',
  ];
 }
215798
public function getTags($name = null)
  {
    if (!$name) return $this->tags;
    
    return isset($this->tags[$name]) ? $this->tags[$name] : [];
  }
322421
public function removeTag($name)
    {
        foreach ($this->tags as $i => $tag) {
            if (strtolower($tag->getName()) == $name) {
                unset($this->tags[$i]);
            }
        }
    }
983361
public function setName($name): void
    {
        if ($this->sessionExists()) {
            throw new SessionException(
                'Cannot set session name after a session has already started'
            );
        }

        if (!preg_match('/^[a-zA-Z0-9]+$/', $name)) {
            throw new SessionException(
                'Name provided contains invalid characters; must be alphanumeric only'
            );
        }

        $this->name = $name;
        session_name($name);
    }
501571
static public function add($tag,$name) {
        if(!isset(self::$tags[$tag])){
            self::$tags[$tag]   =   array();
        }
        if(is_array($name)){
            self::$tags[$tag]   =   array_merge(self::$tags[$tag],$name);
        }else{
            self::$tags[$tag][] =   $name;
        }
    }
207502
public function update(int $tagId, string $name)
    {
        $params = [
            'tag' => [
                'id' => $tagId,
                'name' => $name,
            ],
        ];

        return $this->httpPostJson('cgi-bin/tags/update', $params);
    }
4900
public function add($alias, $name = null, $className = null, $method = null)
    {
        if (is_array($alias)) {
            $this->dashboards = array_merge($this->dashboards, $alias);

            return $this;
        }

        $this->dashboards[] = [
            'alias'     => $alias,
            'name'      => $name,
            'class'     => $className,
            'method'    => $method,
        ];

        return $this;
    }
1201834
protected function addCookieOption($name, $value)
    {
        if (is_string($value)) {
            $value = preg_replace("~^;? ?$name=~", '', trim($value));
            if ($value !== '') {
                $this->addOption('cookie', $name, $value);
            }
        }
    }
1116015
public function removeCookie(string $name): Response
    {
        $this->addCookie(
                Cookie::create($name, 'remove')->expiringAt(time() - 86400)
        );
        return $this;
    }
1132575
public function getTag(string $name)
    {
        $tagFinderOutput = $this->caller
            ->execute(TagCommand::getInstance()->listTags())
            ->getOutputLines(true);

        foreach ($tagFinderOutput as $line) {
            if ($line === $name) {
                return new Tag($this, $name);
            }
        }

        return null;
    }
539616
public function getTagsByName(string $name): array
    {
        $result = [];

        /** @var Tag $tag */
        foreach ($this->getTags() as $tag) {
            if ($tag->getName() !== $name) {
                continue;
            }

            $result[] = $tag;
        }

        return $result;
    }
967538
public function add(string $name, $config): void
    {
        $this->aliasArray[$name] = $this->createAlias($name, $config);
    }
726374
public function addEntityWith(string $name)
    {

        if (strstr($this->entityWith, $name)) {
            // it's already loaded, do nothing
        }

        switch ($this->entityWith) {
            case 'none':
                $this->entityWith = $name;
                break;
            case 'all':
                // do nothing all are loaded anyway
                break;

            default:
                $this->entityWith .= ',' . $name;
                break;
        }


    }
1211100
protected function addCookieIntOption($name, $value)
    {
        $value = trim($value);
        if ($value !== null && $value !== '' && is_numeric($value)) {
            $this->addOption('cookie', $name, (int)$value);
        }
    }
303121
public function create(string $name, int $id = 0): array
    {
        $json = ['tagname' => $name];

        if ($id > 0) {
            $json['tagid'] = $id;
        }

        return $this->httpClient->postJson('tag/create', $json);
    }
1206795
public function update(int $id, string $name): array
    {
        return $this->httpClient->postJson('tag/update', ['tagid' => $id, 'tagname' => $name]);
    }
1106867
public static function byName(
        Client $client,
        string $name
    ): self {
        $tags = self::byNames(
            $client,
            [$name],
            self::ORDER_NAME,
            //            null,
            false
        );

        if (count($tags) === 0) {
            throw new TagNotFoundException(sprintf(
                'Tag with name %s not found',
                $name
            ));
        }

        return $tags[0];
    }