Exemplo n.º 1
0
 /**
  * Add a tag to an item
  *
  * @return  void
  */
 public function addTask()
 {
     $this->requiresAuthentication();
     $name = Request::getWord('tag', '');
     $id = Request::getInt('id', 0);
     $id = $id ? $id : $name;
     $tag = new Tag($id);
     if (!$tag->exists()) {
         throw new Exception(Lang::txt('Specified tag does not exist.'), 404);
     }
     $scope = Request::getWord('scope', '');
     $scope_id = Request::getInt('scope_id', 0);
     $tagger = Request::getInt('tagger', 0);
     if (!$scope || !$scope_id) {
         throw new Exception(Lang::txt('Invalid scope and/or scope_id.'), 500);
     }
     if (!$tag->addTo($scope, $scope_id, $tagger)) {
         throw new Exception(Lang::txt('Failed to add tag to object.'), 500);
     }
     $this->send(null, 202);
 }