/** * List all tagged objects * * @return void */ public function displayTask() { // Incoming $filters = array('tagid' => Request::getState($this->_option . '.' . $this->_controller . '.tag', 'tag', 0, 'int'), 'tbl' => Request::getState($this->_option . '.' . $this->_controller . '.tbl', 'tbl', ''), 'sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'raw_tag'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC')); $modelt = Object::all()->select('DISTINCT(tbl)'); $model = Object::all(); if ($filters['tagid']) { $model->whereEquals('tagid', $filters['tagid']); $modelt->whereEquals('tagid', $filters['tagid']); } if ($filters['tbl']) { $model->whereEquals('tbl', $filters['tbl']); } // Get records $rows = $model->ordered('filter_order', 'filter_order_Dir')->paginated('limitstart', 'limit')->rows(); $types = $modelt->ordered()->rows(); // Output the HTML $this->view->set('filters', $filters)->set('rows', $rows)->set('types', $types)->display(); }
/** * Remove all tags from an item * Option User ID to remove tags added by just that user. * * @param string $tagger User ID to remove tags for * @return mixed False if errors, integer on success */ public function removeAll($tagger = 0) { if (!$this->_scope_id) { $this->setError('Unable to remove tags: No objct ID provided.'); return false; } $to = Object::all()->whereEquals('tbl', $this->_scope)->whereEquals('objectid', $this->_scope_id); if ($tagger) { $to->whereEquals('taggerid', $tagger); } $tags = array(); foreach ($to->rows() as $row) { $tags[] = $row->get('tagid'); if (!$row->destroy()) { $this->setError($row->getError()); return false; } } foreach ($tags as $tag_id) { $tag = Tag::oneOrFail($tag_id); $tag->set('objects', $tag->objects()->total())->save(); } return true; }