예제 #1
0
    /**
     * Sets the model state using module parameters
     *
     * @param KModelInterface $model
     * @return $this
     */
    protected function _setModelState(KModelInterface $model)
    {
        $params = $this->getParameters();
        $user   = $this->getObject('user');

        // Set all parameters in the state to allow easy extension of the module
        $state = $params->toArray();
        $state['category_children'] = $params->include_child_categories;
        $state['page'] = !empty($params->page) ? $params->page : 'all';

        if (substr($params->sort, 0, 8) === 'reverse_')
        {
            $state['sort'] = substr($params->sort, 8);
            $state['direction'] = 'desc';
        }

        // Force created_by for user module
        if ($params->own) {
            $state['created_by'] = $user->getId();
        }

        $model->setState($state);

        // Force certain states
        $model->access($user->getRoles())
            ->enabled(1)
            ->status('published')
            ->current_user($user->getId());

        return $this;
    }
예제 #2
0
 /**
  * Sets the model state using module parameters
  *
  * @param KModelInterface $model
  * @return $this
  */
 protected function _setModelState(KModelInterface $model)
 {
     $params = $this->module->params;
     // Set all parameters in the state to allow easy extension of the module
     $state = $params->toArray();
     if (substr($params->sort, 0, 8) === 'reverse_') {
         $state['sort'] = substr($params->sort, 8);
         $state['direction'] = 'desc';
     }
     $model->setState($state);
     if ($this->getObject('user')->authorise('core.manage', 'com_todo') !== true) {
         $model->enabled(1);
     }
     $model->limit($params->limit);
     return $this;
 }
예제 #3
0
    /**
     * Sets the model state using module parameters
     *
     * @param KModelInterface $model
     * @return $this
     */
    protected function _setModelState(KModelInterface $model)
    {
        $params = $this->getParameters();
        $user   = $this->getObject('user');

        $parent_id = $params->parent;

        // Active DOCman page
        if ($params->page == -1)
        {
            $menu = JFactory::getApplication()->getMenu()->getActive();
            $params->page = $menu ? $menu->id : 0;

            // Get the current category if available
            $slug = $this->getObject('request')->query->slug;

            if ($slug)
            {
                $parent_id = $model->slug($slug)->fetch()->id;
                $model->getState()->reset();
            }
        }

        // Set all parameters in the state to allow easy extension of the module
        $state = $params->toArray();
        $state['parent_id'] = $parent_id;
        $state['page'] = !empty($params->page) ? $params->page : 'all';

        if ($params->level) {
            $state['level'] = range(0, $params->level);
        }

        // Force created_by for user module
        if ($params->own) {
            $state['created_by'] = $user->getId();
        }

        $model->setState($state);

        // Force certain states
        $model->access($user->getRoles())
            ->enabled(1)
            ->current_user($user->getId());

        return $this;
    }