/**
  * Generates a list of JSON items.
  *
  * @return    void
  */
 public function display($tpl = null)
 {
     $user = JFactory::getUser();
     $access = JRequest::getUInt('filter_access');
     // No access if not logged in
     if ($user->id == 0) {
         JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
         return false;
     }
     // Check Access for non-admins
     if (!$user->authorise('core.admin')) {
         $allowed = PFAccessHelper::getGroupsByAccessLevel($access, true);
         $groups = $user->getAuthorisedGroups();
         $can_access = false;
         foreach ($groups as $group) {
             if (in_array($group, $allowed)) {
                 $can_access = true;
                 break;
             }
         }
         if (!$can_access) {
             JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
             return false;
         }
     }
     $this->items = $this->get('Items');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     parent::display($tpl);
 }
 /**
  * Displays the current view
  *
  * @param     boolean        $cachable     If true, the view output will be cached  (Not Used!)
  * @param     array          $urlparams    An array of safe url parameters and their variable types (Not Used!)
  *
  * @return    jcontroller                  A JController object to support chaining.
  */
 public function display($cachable = false, $urlparams = false)
 {
     // Load CSS and JS assets
     JHtml::_('pfhtml.style.bootstrap');
     JHtml::_('pfhtml.style.projectfork');
     JHtml::_('pfhtml.script.jQuery');
     JHtml::_('pfhtml.script.bootstrap');
     JHtml::_('pfhtml.script.projectfork');
     JHtml::_('behavior.tooltip');
     $view = JRequest::getCmd('view');
     $id = JRequest::getUInt('id');
     $urlparams = array('id' => 'INT', 'cid' => 'ARRAY', 'limit' => 'INT', 'limitstart' => 'INT', 'showall' => 'INT', 'return' => 'BASE64', 'filter' => 'STRING', 'filter_order' => 'CMD', 'filter_order_Dir' => 'CMD', 'filter_search' => 'STRING', 'filter_published' => 'CMD');
     // Inject default view if not set
     if (empty($view)) {
         JRequest::setVar('view', $this->default_view);
     }
     // Check for edit form.
     if ($view == 'form' && !$this->checkEditId('com_pftime.edit.form', $id)) {
         // Somehow the person just went to the form - we don't allow that.
         return JError::raiseError(403, JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
     }
     // Display the view
     parent::display($cachable, $urlparams);
     // Return own instance for chaining
     return $this;
 }
Example #3
0
 /**
  * State
  */
 protected function populateState($ordering = null, $direction = null)
 {
     parent::populateState($ordering, $direction);
     // start and limit
     $start = JRequest::getUInt('start', 0);
     $this->setState('list.start', $start);
 }
Example #4
0
 function populateState($ordering = null, $direction = null)
 {
     parent::populateState($ordering, $direction);
     $app = JFactory::getApplication('site');
     $user = JFactory::getUser();
     $pk = JRequest::getInt('id');
     $this->setState('tags.id', $pk);
     $offset = JRequest::getUInt('limitstart', 0);
     $this->setState('offset', $offset);
     $this->setState('list.start', JRequest::getVar('limitstart', 0, '', 'int'));
     $this->setState('tags.catid', null);
     $params = $app->getParams();
     // Set value again for option tz_portfolio_redirect
     if ($params->get('tz_portfolio_redirect') == 'default') {
         $params->set('tz_portfolio_redirect', 'article');
     }
     if ($params->get('show_limit_box', 0)) {
         $limit = $app->getUserStateFromRequest('com_tz_portfolio.users.limit', 'limit', 10);
     } else {
         $limit = $params->get('tz_article_limit');
     }
     if (!$user->authorise('core.edit.state', 'com_tz_portfolio') && !$user->authorise('core.edit', 'com_tz_portfolio')) {
         // limit to published for people who can't edit or edit.state.
         $this->setState('filter.published', 1);
     } else {
         $this->setState('filter.published', array(0, 1, 2));
     }
     $this->setState('filter.language', $app->getLanguageFilter());
     $params->set('access-view', true);
     $this->setState('list.limit', $limit);
     $this->setState('params', $params);
     $this->setState('char', JRequest::getString('char', null));
 }
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return  void
  */
 protected function populateState($ordering = 'ordering', $direction = 'ASC')
 {
     $app = JFactory::getApplication();
     // List state information
     $value = JRequest::getUInt('limit', $app->getCfg('list_limit', 0));
     $this->setState('list.limit', $value);
     $value = JRequest::getUInt('limitstart', 0);
     $this->setState('list.start', $value);
     $orderCol = JRequest::getCmd('order_field', $ordering);
     if (!in_array($orderCol, $this->filter_fields)) {
         $orderCol = 'ordering';
     }
     $this->setState('list.ordering', $orderCol);
     $country_code = $this->getUserStateFromRequest($this->context . '.filter.country_code', 'country_code');
     $this->setState('filter.country_code', $country_code);
     $city = $this->getUserStateFromRequest($this->context . '.filter.access', 'city');
     $this->setState('filter.city', $city);
     $featured = $app->getUserStateFromRequest($this->context . '.filter.featured', 'filter_featured');
     $this->setState('filter.featured', $featured);
     $tourismTypeId = $this->getUserStateFromRequest($this->context . '.filter.tourismtype_id', 'tourismtype_id', '');
     $this->setState('filter.tourismtype_id', $tourismTypeId);
     $categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'category_id');
     $this->setState('filter.category_id', $categoryId);
     // List state information.
     //parent::populateState($ordering, 'ASC');
 }
Example #6
0
 function populateState($ordering = null, $direction = null)
 {
     parent::populateState($ordering, $direction);
     $app = JFactory::getApplication();
     $params = $app->getParams();
     if ($params->get('tz_portfolio_redirect') == 'default') {
         $params->set('tz_portfolio_redirect', 'article');
     }
     $user = JFactory::getUser();
     $this->params = $params;
     if ($params->get('show_limit_box', 0) && $params->get('tz_timeline_layout', 'default') == 'classic') {
         $limit = $app->getUserStateFromRequest('com_tz_portfolio.timeline.limit', 'limit', $params->get('tz_article_limit', 10));
     } else {
         $limit = $params->get('tz_article_limit', 10);
     }
     if (!$user->authorise('core.edit.state', 'com_tz_portfolio') && !$user->authorise('core.edit', 'com_tz_portfolio')) {
         // limit to published for people who can't edit or edit.state.
         $this->setState('filter.published', 1);
     } else {
         $this->setState('filter.published', array(0, 1, 2));
     }
     $this->setState('filter.language', $app->getLanguageFilter());
     $params->set('useCloudZoom', 0);
     $this->setState('list.start', JRequest::getUInt('limitstart', 0));
     $this->setState('list.limit', $limit);
     $this->setState('params', $this->params);
     $this->setState('char', JRequest::getString('char', null));
 }
 /**
  * Constructor
  *
  * @since 1.5
  */
 function __construct()
 {
     parent::__construct();
     //Get configuration
     $app = JFactory::getApplication();
     $config = JFactory::getConfig();
     // Get the pagination request variables
     $this->setState('limit', $app->getUserStateFromRequest('com_search.limit', 'limit', $config->get('list_limit'), 'uint'));
     $this->setState('limitstart', JRequest::getUInt('limitstart', 0));
     // Get parameters.
     $params = $app->getParams();
     if ($params->get('searchphrase') == 1) {
         $searchphrase = 'any';
     } elseif ($params->get('searchphrase') == 2) {
         $searchphrase = 'exact';
     } else {
         $searchphrase = 'all';
     }
     // Set the search parameters
     $keyword = urldecode(JRequest::getString('searchword'));
     $match = JRequest::getWord('searchphrase', $searchphrase);
     $ordering = JRequest::getWord('ordering', $params->get('ordering', 'newest'));
     $this->setSearch($keyword, $match, $ordering);
     //Set the search areas
     $areas = JRequest::getVar('areas');
     $this->setAreas($areas);
 }
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return	void
  * @since	1.6
  */
 protected function populateState($ordering = 'ordering', $direction = 'ASC')
 {
     $app = JFactory::getApplication();
     // List state information
     $value = JRequest::getUInt('limit', $app->getCfg('list_limit', 0));
     $this->setState('list.limit', $value);
     $value = JRequest::getUInt('limitstart', 0);
     $this->setState('list.start', $value);
     $orderCol = JRequest::getCmd('filter_order', 'a.ordering');
     if (!in_array($orderCol, $this->filter_fields)) {
         $orderCol = 'a.ordering';
     }
     $this->setState('list.ordering', $orderCol);
     $listOrder = JRequest::getCmd('filter_order_Dir', 'ASC');
     if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) {
         $listOrder = 'ASC';
     }
     $this->setState('list.direction', $listOrder);
     $params = $app->getParams();
     $this->setState('params', $params);
     $user = JFactory::getUser();
     if (!$user->authorise('core.edit.state', 'com_content') && !$user->authorise('core.edit', 'com_content')) {
         // filter on published for those who do not have edit or edit.state rights.
         $this->setState('filter.published', 1);
     }
     $this->setState('filter.language', $app->getLanguageFilter());
     // process show_noauth parameter
     if (!$params->get('show_noauth')) {
         $this->setState('filter.access', true);
     } else {
         $this->setState('filter.access', false);
     }
     $this->setState('layout', JRequest::getCmd('layout'));
 }
 /**
  * Generates a list of JSON items.
  *
  * @return    void
  */
 function display($tpl = null)
 {
     $ta = (int) JRequest::getUInt('typeahead');
     $s2 = (int) JRequest::getUInt('select2');
     $resp = array();
     // Get model data
     $rows = $this->get('Items');
     if ($ta) {
         $tmp_rows = array();
         foreach ($rows as &$row) {
             $id = (int) $row->id;
             $tmp_rows[$id] = $this->escape($row->title);
         }
         $rows = $tmp_rows;
     } elseif ($s2) {
         $tmp_rows = array();
         foreach ($rows as &$row) {
             $id = (int) $row->id;
             $item = new stdClass();
             $item->id = $id;
             $item->text = $this->escape($row->title);
             $tmp_rows[] = $item;
         }
         $rows = $tmp_rows;
         $total = (int) $this->get('Total');
         $rows = array('total' => $total, 'items' => $rows);
     }
     // Set the MIME type for JSON output.
     JFactory::getDocument()->setMimeEncoding('application/json');
     // Change the suggested filename.
     JResponse::setHeader('Content-Disposition', 'attachment;filename="' . $this->getName() . '.json"');
     // Output the JSON data.
     echo json_encode($rows);
     jexit();
 }
Example #10
0
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return	void
  * @since	1.6
  */
 protected function populateState($ordering = 'ordering', $direction = 'ASC')
 {
     $app = JFactory::getApplication();
     // List state information
     //$value = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'));
     $value = JRequest::getUInt('limit', $app->getCfg('list_limit', 0));
     $this->setState('list.limit', $value);
     //$value = $app->getUserStateFromRequest($this->context.'.limitstart', 'limitstart', 0);
     $value = JRequest::getUInt('limitstart', 0);
     $this->setState('list.start', $value);
     $orderCol = JRequest::getCmd('filter_order', 'a.ordering');
     if (!in_array($orderCol, $this->filter_fields)) {
         $orderCol = 'a.ordering';
     }
     $this->setState('list.ordering', $orderCol);
     $listOrder = JRequest::getCmd('filter_order_Dir', 'ASC');
     if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) {
         $listOrder = 'ASC';
     }
     $this->setState('list.direction', $listOrder);
     $params = $app->getParams();
     $this->setState('params', $params);
     $user = JFactory::getUser();
     $this->setState('layout', JRequest::getCmd('layout'));
 }
 /**
  * Method to publish a list of items
  *
  * @return  void
  */
 public function publish()
 {
     parent::publish();
     $project = JRequest::getUInt('filter_project');
     $topic = JRequest::getUInt('filter_topic');
     $link = 'index.php?option=' . $this->option . '&view=' . $this->view_list . '&filter_project=' . $project . '&filter_topic=' . $topic;
     $this->setRedirect(JRoute::_($link, false));
 }
Example #12
0
 protected function populateState($ordering = null, $direction = null)
 {
     $id = JRequest::getInt('id');
     $this->setState('filter.category_id', $id);
     $this->setState('list.start', JRequest::getUInt('limitstart', 0));
     $limit = 10;
     $this->setState('list.limit', $limit);
 }
 function display($tpl = null)
 {
     $user = JFactory::getUser();
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // Check access
     if ($this->item->params->get('access-view') != true) {
         JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
         return false;
     }
     $rev = JRequest::getUInt('rev');
     if ($rev) {
         $rev_model = JModelLegacy::getInstance('FileRevision', 'PFrepoModel', $c = array('ignore_request' => true));
         $file_rev = $rev_model->getItem($rev);
         if (!$file_rev || empty($file_rev->id)) {
             JError::raiseError(404, JText::_('COM_PROJECTFORK_ERROR_FILE_NOT_FOUND'));
             return false;
         }
         // Check access
         if ($file_rev->parent_id != $this->item->id) {
             JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
             return false;
         }
         $filepath = PFrepoHelper::getBasePath($this->item->project_id) . '/_revs/file_' . $this->item->id;
         $filename = $file_rev->file_name;
     } else {
         $filepath = $this->item->physical_path;
         $filename = $this->item->file_name;
     }
     // Check if the file exists
     if (empty($filepath) || !JFile::exists($filepath . '/' . $filename)) {
         JError::raiseError(404, JText::_('COM_PROJECTFORK_ERROR_FILE_NOT_FOUND'));
         return false;
     }
     if (headers_sent($file, $line)) {
         JError::raiseError(500, JText::sprintf('COM_PROJECTFORK_WARNING_FILE_DL_ERROR_HEADERS_SENT', $file, $line));
         return false;
     }
     while (ob_get_level()) {
         ob_end_clean();
     }
     header("Content-Type: APPLICATION/OCTET-STREAM");
     header("Content-Length: " . filesize($filepath . '/' . $filename));
     header("Content-Disposition: attachment; filename=\"" . $filename . "\";");
     header("Content-Transfer-Encoding: Binary");
     if (function_exists('readfile')) {
         readfile($filepath . '/' . $filename);
     } else {
         echo file_get_contents($filepath . '/' . $filename);
     }
     jexit();
 }
Example #14
0
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return	void
  * @since	1.6
  */
 protected function populateState($ordering = 'ordering', $direction = 'ASC')
 {
     $app = JFactory::getApplication();
     // List state information
     $value = JRequest::getUInt('limit', CFG_LIST_USER_CONTENT);
     $this->setState('list.limit', $value);
     $value = JRequest::getUInt('limitstart', 0);
     $this->setState('list.start', $value);
 }
Example #15
0
 /**
  * Method to check if you can add a new record.
  *
  * @param     array      $data    An array of input data.
  *
  * @return    boolean
  */
 protected function allowAdd($data = array())
 {
     $topic = isset($data['topic_id']) ? (int) $data['topic_id'] : JRequest::getUInt('filter_topic');
     $access = PFforumHelper::getActions($topic);
     if (!$topic) {
         $this->setError(JText::_('COM_PROJECTFORK_WARNING_TOPIC_NOT_FOUND'));
         return false;
     }
     $access = PFforumHelper::getReplyActions();
     return $access->get('core.create');
 }
Example #16
0
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @since	1.6
  */
 protected function populateState()
 {
     $app = JFactory::getApplication('site');
     // Load state from the request.
     $pk = JRequest::getInt('id');
     $this->setState('jfoobar.id', $pk);
     $offset = JRequest::getUInt('limitstart');
     $this->setState('list.offset', $offset);
     // Load the parameters.
     $params = $app->getParams();
     $this->setState('params', $params);
 }
Example #17
0
 protected function populateState()
 {
     $app = JFactory::getApplication('site');
     // Load state from the request.
     $pk = JRequest::getInt('hotel_id');
     $this->setState('hotel.id', $pk);
     $tabId = JRequest::getInt('tabId', 1);
     $this->setState('hotel.tabId', $tabId);
     $offset = JRequest::getUInt('limitstart');
     $this->setState('list.offset', $offset);
     UserDataService::updateUserData();
 }
 public function checkAssets()
 {
     $limitstart = JRequest::getUInt('chk_assets_limitstart');
     $model = $this->getModel('CheckAsset');
     $model->setState('limitstart', $limitstart);
     $rsp = array('success' => $model->check());
     // Set the MIME type for JSON output.
     JFactory::getDocument()->setMimeEncoding('application/json');
     // Change the suggested filename.
     JResponse::setHeader('Content-Disposition', 'attachment;filename="dashboard.json"');
     // Output the JSON data.
     echo json_encode($rsp);
     jexit();
 }
 /**
  * Method to display a view.
  *
  * @param     boolean        If true, the view output will be cached
  * @param     array          An array of safe url parameters
  *
  * @return    jcontroller    This object to support chaining.
  */
 public function display($cachable = false, $urlparams = false)
 {
     $view = JRequest::getCmd('view', $this->default_view);
     $layout = JRequest::getCmd('layout');
     $id = JRequest::getUint('id');
     // Inject default view if not set
     if (empty($view)) {
         JRequest::setVar('view', $this->default_view);
         $view = $this->default_view;
     }
     if ($view == $this->default_view) {
         $parent_id = JRequest::getUInt('filter_parent_id');
         $project = PFApplicationHelper::getActiveProjectId('filter_project');
         if ($parent_id && $project === "") {
             $this->setRedirect('index.php?option=com_pfrepo&view=' . $this->default_view);
             return $this;
         } elseif ($parent_id > 1 && $project > 0) {
             // Check if the folder belongs to the project
             $db = JFactory::getDbo();
             $query = $db->getQuery(true);
             $query->select('project_id')->from('#__pf_repo_dirs')->where('id = ' . (int) $parent_id);
             $db->setQuery($query);
             $pid = $db->loadResult();
             if ($pid != $project) {
                 // No match, redirect to the project root dir
                 $query->clear();
                 $query->select('id, path')->from('#__pf_repo_dirs')->where('parent_id = 1')->where('project_id = ' . (int) $project);
                 $db->setQuery($query, 0, 1);
                 $dir = $db->loadObject();
                 if ($dir) {
                     $this->setRedirect('index.php?option=com_pfrepo&view=' . $this->default_view . '&filter_project=' . $project . '&filter_parent_id=' . $dir->id);
                     return $this;
                 }
             }
         }
     }
     // Check form edit access
     if ($layout == 'edit' && !$this->checkEditId('com_pfrepo.edit.' . $view, $id)) {
         $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
         $this->setMessage($this->getError(), 'error');
         $this->setRedirect(JRoute::_('index.php?option=com_pfrepo&view=' . $this->default_view, false));
         return false;
     }
     // Add the sub-menu
     PFrepoHelper::addSubmenu($view);
     // Display the view
     parent::display($cachable, $urlparams);
     return $this;
 }
 protected function populateState()
 {
     $app = JFactory::getApplication('site');
     // Load state from the request.
     $pk = JRequest::getInt('hotel_id');
     $this->setState('hotel.id', $pk);
     $tabId = JRequest::getInt('tabId', 1);
     $this->setState('hotel.tabId', $tabId);
     $offset = JRequest::getUInt('limitstart');
     $this->setState('list.offset', $offset);
     UserDataService::updateUserData();
     $redirect = JRequest::getVar("excursionRedirect", 0);
     if ($redirect == 0) {
         UserDataService::initializeExcursions();
     }
 }
Example #21
0
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return	void
  * @since	1.6
  */
 protected function populateState()
 {
     $app = JFactory::getApplication('site');
     // Load state from the request.
     $pk = JRequest::getInt('id');
     $this->setState('newsfeed.id', $pk);
     $offset = JRequest::getUInt('limitstart', 0);
     $this->setState('list.offset', $offset);
     // Load the parameters.
     $params = $app->getParams();
     $this->setState('params', $params);
     $user = JFactory::getUser();
     if (!$user->authorise('core.edit.state', 'com_newsfeeds') && !$user->authorise('core.edit', 'com_newsfeeds')) {
         $this->setState('filter.published', 1);
         $this->setState('filter.archived', 2);
     }
 }
Example #22
0
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @since	1.6
  */
 protected function populateState()
 {
     $app = JFactory::getApplication('site');
     // Load state from the request.
     $pk = JRequest::getInt('id');
     $this->setState('article.id', $pk);
     $offset = JRequest::getUInt('limitstart');
     $this->setState('list.offset', $offset);
     // Load the parameters.
     $params = $app->getParams();
     $this->setState('params', $params);
     // TODO: Tune these values based on other permissions.
     $user = JFactory::getUser();
     if (!$user->authorise('core.edit.state', 'com_content') && !$user->authorise('core.edit', 'com_content')) {
         $this->setState('filter.published', 1);
         $this->setState('filter.archived', 2);
     }
 }
Example #23
0
 protected function populateState($ordering = null, $direction = null)
 {
     parent::populateState($ordering, $direction);
     // List state information
     $value = JRequest::getUInt('limitstart', 0);
     $this->setState('list.start', $value);
     $id = JRequest::getInt('id', 0);
     $this->setState('filter.category_id', $id);
     $userId = JRequest::getInt('user', 0);
     $this->setState('filter.user_id', $userId);
     if (empty($userId)) {
         $defaultValue = 40;
     } else {
         $defaultValue = 8;
     }
     $value = JRequest::getUInt('limit', $defaultValue);
     $this->setState('list.limit', $value);
 }
Example #24
0
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return	void
  * @since	1.6
  */
 protected function populateState($ordering = 'ordering', $direction = 'ASC')
 {
     $app = JFactory::getApplication();
     // List state information
     //$value = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'));
     $value = JRequest::getUInt('limit', $app->getCfg('list_limit', 0));
     $this->setState('list.limit', $value);
     //$value = $app->getUserStateFromRequest($this->context.'.limitstart', 'limitstart', 0);
     $value = JRequest::getUInt('limitstart', 0);
     $this->setState('list.start', $value);
     $orderCol = JRequest::getCmd('filter_order', 'a.ordering');
     if (!in_array($orderCol, $this->filter_fields)) {
         $orderCol = 'a.ordering';
     }
     $this->setState('list.ordering', $orderCol);
     $listOrder = JRequest::getCmd('filter_order_Dir', 'ASC');
     if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) {
         $listOrder = 'ASC';
     }
     $this->setState('list.direction', $listOrder);
     $params = $app->getParams();
     // Set value again for option tz_portfolio_redirect
     if ($params->get('tz_portfolio_redirect') == 'default') {
         $params->set('tz_portfolio_redirect', 'article');
     }
     $this->setState('params', $params);
     $user = JFactory::getUser();
     if (!$user->authorise('core.edit.state', 'com_tz_portfolio') && !$user->authorise('core.edit', 'com_tz_portfolio')) {
         // filter on published for those who do not have edit or edit.state rights.
         $this->setState('filter.published', 1);
     }
     $this->setState('filter.language', $app->getLanguageFilter());
     // process show_noauth parameter
     if (!$params->get('show_noauth')) {
         $this->setState('filter.access', true);
     } else {
         $this->setState('filter.access', false);
     }
     //filter with first letter of title
     $this->setState('filter.tz_use_filter_letter', $params->get('use_filter_first_letter', 0));
     $this->setState('filter.char', JRequest::getString('char', null));
     $this->setState('layout', JRequest::getCmd('layout'));
 }
Example #25
0
 protected function populateState($ordering = null, $direction = null)
 {
     // Initialise variables.
     $app = JFactory::getApplication('administrator');
     $context = $this->context;
     // List state information
     $value = JRequest::getUInt('limit', $app->getCfg('list_limit', 0));
     $this->setState('list.limit', $value);
     $value = JRequest::getUInt('limitstart', 0);
     $this->setState('list.start', $value);
     $search = $this->getUserStateFromRequest($context . '.search', 'filter_search');
     $this->setState('filter.search', $search);
     $state = $this->getUserStateFromRequest($context . '.filter.state', 'filter_state', '');
     $this->setState('filter.state', $state);
     $category = $this->getUserStateFromRequest($context . '.filter.category', 'filter_category');
     $this->setState('filter.category', $category);
     // List state information.
     parent::populateState('a.fid', 'desc');
 }
Example #26
0
 /**
  * Display the view
  */
 function display($tpl = null)
 {
     // load app
     $app = JFactory::getApplication();
     // get the items
     $this->items = $this->get('Items');
     $this->tags = $this->get('Tags');
     $this->pagination = $this->get('Pagination');
     // params
     $this->params = JComponentHelper::getParams('com_jkit');
     $app_params = $app->getParams();
     $this->params->merge($app_params);
     // lists
     $this->lists = new stdClass();
     // layout
     $layout = $this->params->get('jkitlayout');
     if ($layout) {
         $this->setLayout($layout);
     }
     // list views
     $this->tag = $this->get('Tag');
     $this->archive = $this->get('Archive');
     $this->author = $this->get('Author');
     // prepare document
     $this->prepareDocument();
     // jkit views
     if ($this->tag || $this->archive || $this->author || JRequest::getUInt('start', 0)) {
         $title = '';
         if ($this->tag) {
             $title = JText::sprintf('COM_JKIT_ITEMS_TITLE_TAG', $this->tag->title);
         } elseif ($this->archive) {
             $title = JText::sprintf('COM_JKIT_ITEMS_TITLE_ARCHIVE', $this->archive->title);
         } elseif ($this->author) {
             $title = JText::sprintf('COM_JKIT_ITEMS_TITLE_AUTHOR', $this->author->title);
         }
         $tpl = 'list';
         $this->document->setTitle($this->lists->title . ' | ' . $title);
         $this->lists->title .= '<br>' . $title;
     }
     // display the view
     parent::display($tpl);
 }
Example #27
0
 function populateState($ordering = null, $direction = null)
 {
     parent::populateState($ordering, $direction);
     $app = JFactory::getApplication();
     $params = $app->getParams();
     if ($params->get('tz_portfolio_redirect') == 'default') {
         $params->set('tz_portfolio_redirect', 'article');
     }
     $user = JFactory::getUser();
     $offset = JRequest::getUInt('limitstart', 0);
     if ($params->get('show_limit_box', 0) && $params->get('tz_portfolio_layout') == 'default') {
         $limit = $app->getUserStateFromRequest('com_tz_portfolio.portfolio.limit', 'limit', $params->get('tz_article_limit', 10));
     } else {
         $limit = (int) $params->get('tz_article_limit', 10);
     }
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     if (!$user->authorise('core.edit.state', 'com_tz_portfolio') && !$user->authorise('core.edit', 'com_tz_portfolio')) {
         // limit to published for people who can't edit or edit.state.
         $this->setState('filter.published', 1);
         // Filter by start and end dates.
         $nullDate = $db->Quote($db->getNullDate());
         $nowDate = $db->Quote(JFactory::getDate()->toSQL());
         $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')');
         $query->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
     } else {
         $this->setState('filter.published', array(0, 1, 2));
     }
     $this->setState('filter.language', $app->getLanguageFilter());
     $this->setState('params', $params);
     $this->setState('list.start', $offset);
     $this->setState('Itemid', $params->get('id'));
     $this->setState('list.limit', $limit);
     $this->setState('tz_catid', $params->get('tz_catid'));
     $this->setState('char', JRequest::getString('char', null));
     $this->setState('filter.tagId', null);
     $this->setState('filter.userId', null);
     $this->setState('filter.featured', null);
     $this->setState('filter.year', null);
     $this->setState('filter.month', null);
 }
Example #28
0
 function search()
 {
     // slashes cause errors, <> get stripped anyway later on. # causes problems.
     $badchars = array('#', '>', '<', '\\');
     $searchword = trim(str_replace($badchars, '', JRequest::getString('searchword', null, 'post')));
     // if searchword enclosed in double quotes, strip quotes and do exact match
     if (substr($searchword, 0, 1) == '"' && substr($searchword, -1) == '"') {
         $post['searchword'] = substr($searchword, 1, -1);
         JRequest::setVar('searchphrase', 'exact');
     } else {
         $post['searchword'] = $searchword;
     }
     $post['ordering'] = JRequest::getWord('ordering', null, 'post');
     $post['searchphrase'] = JRequest::getWord('searchphrase', 'all', 'post');
     $post['limit'] = JRequest::getUInt('limit', null, 'post');
     if ($post['limit'] === null) {
         unset($post['limit']);
     }
     $areas = JRequest::getVar('areas', null, 'post', 'array');
     if ($areas) {
         foreach ($areas as $area) {
             $post['areas'][] = JFilterInput::getInstance()->clean($area, 'cmd');
         }
     }
     // set Itemid id for links from menu
     $app = JFactory::getApplication();
     $menu = $app->getMenu();
     $items = $menu->getItems('link', 'index.php?option=com_search&view=search');
     if (isset($items[0])) {
         $post['Itemid'] = $items[0]->id;
     } elseif (JRequest::getInt('Itemid') > 0) {
         //use Itemid from requesting page only if there is no existing menu
         $post['Itemid'] = JRequest::getInt('Itemid');
     }
     unset($post['task']);
     unset($post['submit']);
     $uri = JURI::getInstance();
     $uri->setQuery($post);
     $uri->setVar('option', 'com_search');
     $this->setRedirect(JRoute::_('index.php' . $uri->toString(array('query', 'fragment')), false));
 }
 /**
  * Method to auto-populate the model state.
  * Note. Calling getState in this method will result in recursion.
  *
  * @return    void
  */
 protected function populateState()
 {
     $app = JFactory::getApplication();
     $pk = JRequest::getUInt('id');
     $parent = JRequest::getUInt('filter_parent_id');
     $option = JRequest::getVar('option');
     $return = JRequest::getVar('return', null, 'default', 'base64');
     $project = PFApplicationHelper::getActiveProjectId();
     // Set primary key
     $this->setState($this->getName() . '.id', $pk);
     // Set return page
     $this->setState('return_page', base64_decode($return));
     // Set params
     $params = $app->getParams();
     $this->setState('params', $params);
     // Set layout
     $this->setState('layout', JRequest::getCmd('layout'));
     // Set parent id
     $this->setState($this->getName() . '.parent_id', $parent);
     // Set project
     $this->setState($this->getName() . '.project', $project);
 }
 /**
  * Method to check if you can add a new record.
  *
  * @param     array      $data    An array of input data.
  *
  * @return    boolean
  */
 protected function allowAdd($data = array())
 {
     // Get form input
     $topic = isset($data['topic_id']) ? (int) $data['topic_id'] : JRequest::getUInt('filter_topic');
     $user = JFactory::getUser();
     $asset = 'com_pfforum.topic.' . $topic;
     $access = true;
     // Topic is required
     if (!$topic) {
         $this->setError(JText::_('COM_PROJECTFORK_WARNING_TOPIC_NOT_FOUND'));
         return false;
     }
     // Check if the user has viewing access when not a super admin
     if (!$user->authorise('core.admin')) {
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('access')->from('#__pf_topics')->where('id = ' . (int) $topic);
         $db->setQuery($query);
         $lvl = $db->loadResult();
         $access = in_array($lvl, $user->getAuthorisedViewLevels());
     }
     return $user->authorise('core.create', $asset) && $access;
 }