Ejemplo n.º 1
0
 public function remove()
 {
     // init vars
     $tags = YRequest::getArray('cid', array(), 'string');
     if (count($tags) < 1) {
         JError::raiseError(500, JText::_('Select a tag to delete'));
     }
     try {
         $app = Zoo::getApplication();
         // delete tags
         YTable::getInstance('tag')->delete($app->id, $tags);
         // set redirect message
         $msg = JText::_('Tag Deleted');
     } catch (YException $e) {
         // raise notice on exception
         JError::raiseWarning(0, JText::_('Error Deleting Tag') . ' (' . $e . ')');
         $msg = null;
     }
     $this->setRedirect($this->baseurl, $msg);
 }
Ejemplo n.º 2
0
 public function saveElements()
 {
     // check for request forgeries
     YRequest::checkToken() or jexit('Invalid Token');
     // init vars
     $post = YRequest::get('post');
     $cid = YRequest::getArray('cid.0', '', 'string');
     try {
         // get type
         $type = $this->application->getType($cid);
         // save elements
         ElementHelper::saveElements($post, $type);
         // save type
         $type->save();
         // reset related item search data
         $table = YTable::getInstance('item');
         $items = $table->getByType($type->id, $this->application->id);
         foreach ($items as $item) {
             $table->save($item);
         }
         $msg = JText::_('Elements Saved');
     } catch (YException $e) {
         JError::raiseNotice(0, JText::_('Error Saving Elements') . ' (' . $e . ')');
         $this->_task = 'applyelements';
         $msg = null;
     }
     switch ($this->getTask()) {
         case 'applyelements':
             $link = $this->baseurl . '&task=editelements&cid[]=' . $type->id;
             break;
         case 'saveelements':
         default:
             $link = $this->baseurl . '&task=types';
             break;
     }
     $this->setRedirect($link, $msg);
 }
Ejemplo n.º 3
0
 protected function _editTrustedMode($enabled)
 {
     // check for request forgeries
     YRequest::checkToken() or jexit('Invalid Token');
     // init vars
     $cid = YRequest::getArray('cid', array(), 'int');
     if (count($cid) < 1) {
         JError::raiseError(500, JText::_('Select a submission to enable/disable Trusted Mode'));
     }
     try {
         // get item table
         $table = YTable::getInstance('submission');
         // update item state
         foreach ($cid as $id) {
             $submission = $table->get($id);
             $submission->params = $submission->getParams()->set('trusted_mode', $enabled)->toString();
             $table->save($submission);
         }
     } catch (YException $e) {
         // raise notice on exception
         JError::raiseNotice(0, JText::_('Error enabling/disabling Submission Trusted Mode') . ' (' . $e . ')');
     }
     $this->setRedirect($this->baseurl);
 }
Ejemplo n.º 4
0
 protected function _editState($state)
 {
     // check for request forgeries
     YRequest::checkToken() or jexit('Invalid Token');
     // init vars
     $cid = YRequest::getArray('cid', array(), 'int');
     if (count($cid) < 1) {
         JError::raiseError(500, JText::_('Select a comment to edit state'));
     }
     try {
         // get comment table
         $table = YTable::getInstance('comment');
         // update comment state
         foreach ($cid as $id) {
             $comment = $table->get($id);
             $comment->state = $state;
             $table->save($comment);
         }
     } catch (YException $e) {
         // raise notice on exception
         JError::raiseNotice(0, JText::_('Error editing Comment State') . ' (' . $e . ')');
     }
     $this->setRedirect($this->baseurl);
 }
Ejemplo n.º 5
0
 public function element()
 {
     $this->_loadGeneralCSS();
     jimport('joomla.html.pagination');
     // get database
     $this->db = JFactory::getDBO();
     // get request vars
     $this->filter_item = YRequest::getInt('item_filter', 0);
     $this->type_filter = YRequest::getArray('type_filter', array());
     $state_prefix = $this->option . '_' . $this->application->id . '.' . ($this->getTask() == 'element' ? 'element' : 'item') . '.';
     $filter_order = $this->joomla->getUserStateFromRequest($state_prefix . 'filter_order', 'filter_order', 'a.created', 'cmd');
     $filter_order_Dir = $this->joomla->getUserStateFromRequest($state_prefix . 'filter_order_Dir', 'filter_order_Dir', 'desc', 'word');
     $filter_category_id = $this->joomla->getUserStateFromRequest($state_prefix . 'filter_category_id', 'filter_category_id', '0', 'string');
     $limit = $this->joomla->getUserStateFromRequest('global.list.limit', 'limit', $this->joomla->getCfg('list_limit'), 'int');
     $limitstart = $this->joomla->getUserStateFromRequest($state_prefix . 'limitstart', 'limitstart', 0, 'int');
     $filter_type = $this->joomla->getUserStateFromRequest($state_prefix . 'filter_type', 'filter_type', '', 'string');
     $filter_author_id = $this->joomla->getUserStateFromRequest($state_prefix . 'filter_author_id', 'filter_author_id', 0, 'int');
     $search = $this->joomla->getUserStateFromRequest($state_prefix . 'search', 'search', '', 'string');
     $search = JString::strtolower($search);
     // is filtered ?
     $this->is_filtered = $filter_category_id != '0' || !empty($filter_type) || !empty($filter_author_id) || !empty($search);
     // in case limit has been changed, adjust limitstart accordingly
     $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
     $table = YTable::getInstance('item');
     $this->users = $table->getUsers($this->application->id);
     $this->groups = ZooHelper::getGroups();
     // get data from the table
     $where = array();
     // application filter
     $where[] = 'a.application_id = ' . (int) $this->application->id;
     // category filter
     if ($filter_category_id > 0) {
         $where[] = 'ci.category_id = ' . (int) $filter_category_id;
     } else {
         if ($filter_category_id === '') {
             $where[] = 'ci.item_id IS NULL';
         }
     }
     // type filter
     if (!empty($this->type_filter)) {
         $where[] = 'a.type IN ("' . implode('", "', $this->type_filter) . '")';
     } else {
         if (!empty($filter_type)) {
             $where[] = 'a.type = "' . (string) $filter_type . '"';
         }
     }
     // item filter
     if ($this->filter_item > 0) {
         $where[] = 'a.id != ' . (int) $this->filter_item;
     }
     // author filter
     if ($filter_author_id > 0) {
         $where[] = 'a.created_by = ' . (int) $filter_author_id;
     }
     if ($search) {
         $where[] = 'LOWER(a.name) LIKE ' . $this->db->Quote('%' . $this->db->getEscaped($search, true) . '%', false);
     }
     // access filter
     $where[] = 'a.access <= ' . (int) $this->user->get('aid', 0);
     // state filter
     $where[] = 'a.state = 1';
     $options = array('select' => 'DISTINCT a.*', 'from' => $table->getTableName() . ' AS a LEFT JOIN ' . ZOO_TABLE_CATEGORY_ITEM . ' AS ci ON a.id = ci.item_id', 'conditions' => array(implode(' AND ', $where)), 'order' => $filter_order . ' ' . $filter_order_Dir);
     $this->items = $table->all($limit > 0 ? array_merge($options, array('offset' => $limitstart, 'limit' => $limit)) : $options);
     $this->items = array_merge($this->items);
     $this->pagination = new JPagination($table->count($options), $limitstart, $limit);
     // category select
     $options = array();
     $options[] = JHTML::_('select.option', '0:0', '- ' . JText::_('Select Category') . ' -');
     $options[] = JHTML::_('select.option', '', '- ' . JText::_('uncategorized') . ' -');
     $this->lists['select_category'] = JHTML::_('zoo.categorylist', $this->application, $options, 'filter_category_id', 'class="inputbox auto-submit"', 'value', 'text', $filter_category_id);
     // type select
     $options = array(JHTML::_('select.option', '0', '- ' . JText::_('Select Type') . ' -'));
     $this->lists['select_type'] = JHTML::_('zoo.typelist', $options, 'filter_type', 'class="inputbox auto-submit"', 'value', 'text', $filter_type, false, false, $this->type_filter);
     // author select
     $options = array(JHTML::_('select.option', '0', '- ' . JText::_('Select Author') . ' -'));
     $this->lists['select_author'] = JHTML::_('zoo.itemauthorlist', $options, 'filter_author_id', 'class="inputbox auto-submit"', 'value', 'text', $filter_author_id);
     // table ordering and search filter
     $this->lists['order_Dir'] = $filter_order_Dir;
     $this->lists['order'] = $filter_order;
     $this->lists['search'] = $search;
     $this->addViewPath(ZOO_ADMIN_PATH . '/views/item/');
     $view = $this->getView('', '', '', array('base_path' => ZOO_ADMIN_PATH));
     $view->setLayout('element')->display();
 }
Ejemplo n.º 6
0
 protected function _editComments($enabled)
 {
     // check for request forgeries
     YRequest::checkToken() or jexit('Invalid Token');
     // init vars
     $cid = YRequest::getArray('cid', array(), 'int');
     if (count($cid) < 1) {
         JError::raiseError(500, JText::_('Select a item to enable/disable comments'));
     }
     try {
         // get item table
         $table = YTable::getInstance('item');
         // update item state
         foreach ($cid as $id) {
             $item = $table->get($id);
             $item->params = $item->getParams()->set('config.enable_comments', $enabled)->toString();
             $table->save($item);
         }
     } catch (YException $e) {
         // raise notice on exception
         JError::raiseNotice(0, JText::_('Error enabling/disabling Item Comments') . ' (' . $e . ')');
     }
     $this->setRedirect($this->baseurl);
 }
Ejemplo n.º 7
0
 public function _editPublished($published, $msg)
 {
     // check for request forgeries
     YRequest::checkToken() or jexit('Invalid Token');
     // init vars
     $cid = YRequest::getArray('cid', array(), 'int');
     if (count($cid) < 1) {
         JError::raiseError(500, $msg);
     }
     try {
         // get category table
         $table = YTable::getInstance('category');
         // update published state
         foreach ($cid as $id) {
             $category = $table->get($id);
             $category->setPublished($published);
             $table->save($category);
         }
     } catch (YException $e) {
         // raise notice on exception
         JError::raiseNotice(0, JText::_('Error editing Item Published State') . ' (' . $e . ')');
         $msg = null;
     }
     $this->setRedirect($this->baseurl);
 }