Exemplo n.º 1
0
 /**
  * Remove one or more entries
  *
  * @return     void
  */
 public function removeTask()
 {
     // Check for request forgeries
     Request::checkToken();
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     // Make sure we have an ID
     if (empty($ids)) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_TAGS_ERROR_NO_ITEMS_SELECTED'), 'error');
         return;
     }
     foreach ($ids as $id) {
         $id = intval($id);
         // Remove references to the tag
         Event::trigger('tags.onTagDelete', array($id));
         // Remove the tag
         $tag = new Tag($id);
         $tag->delete();
     }
     $this->cleancacheTask(false);
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_TAGS_TAG_REMOVED'));
 }
Exemplo n.º 2
0
 /**
  * Delete one or more tags
  *
  * @return  void
  */
 public function deleteTask()
 {
     // Check that the user is authorized
     if (!$this->config->get('access-delete-tag')) {
         throw new Exception(Lang::txt('ALERTNOTAUTH'), 403);
     }
     // Incoming
     $ids = Request::getVar('id', array());
     if (!is_array($ids)) {
         $ids = array();
     }
     // Make sure we have an ID
     if (empty($ids)) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&task=browse'));
         return;
     }
     foreach ($ids as $id) {
         $id = intval($id);
         // Remove references to the tag
         Event::trigger('tags.onTagDelete', array($id));
         // Remove the tag
         $tag = new Tag($id);
         $tag->delete();
     }
     $this->cleancacheTask(false);
     // Get the browse filters so we can go back to previous view
     $search = Request::getVar('search', '');
     $sortby = Request::getVar('sortby', '');
     $limit = Request::getInt('limit', 25);
     $start = Request::getInt('limitstart', 0);
     $count = Request::getInt('count', 1);
     // Redirect back to browse mode
     App::redirect(Route::url('index.php?option=' . $this->_option . '&task=browse&search=' . $search . '&sortby=' . $sortby . '&limit=' . $limit . '&limitstart=' . $start . '#count' . $count));
 }
Exemplo n.º 3
0
 /**
  * Remove tag from an item
  *
  * @return  void
  */
 public function deleteTask()
 {
     $this->requiresAuthentication();
     $name = Request::getWord('tag', '');
     $id = Request::getInt('id', 0);
     $id = $id ? $id : $tag;
     $tag = new Tag($id);
     if (!$tag->exists()) {
         throw new Exception(Lang::txt('Specified tag does not exist.'), 404);
     }
     if (!$tag->delete()) {
         throw new Exception(Lang::txt('Failed to delete tag.'), 500);
     }
     $this->send(null, 202);
 }