Пример #1
0
 /**
  * Method to get item data.
  *
  * @param     integer    $pk       The id of the item.
  *
  * @return    mixed      $item     Item data object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     // Get the record from the parent class method
     $item = parent::getItem($pk);
     if ($item === false) {
         return false;
     }
     // Compute selected asset permissions.
     $user = JFactory::getUser();
     $uid = $user->get('id');
     $access = PFforumHelper::getReplyActions($item->id);
     $view_access = true;
     if ($item->access && !$user->authorise('core.admin')) {
         $view_access = in_array($item->access, $user->getAuthorisedViewLevels());
     }
     $item->params->set('access-view', $view_access);
     if (!$view_access) {
         $item->params->set('access-edit', false);
         $item->params->set('access-change', false);
     } else {
         // Check general edit permission first.
         if ($access->get('core.edit')) {
             $item->params->set('access-edit', true);
         } elseif (!empty($uid) && $access->get('core.edit.own')) {
             // Check for a valid user and that they are the owner.
             if ($uid == $item->created_by) {
                 $item->params->set('access-edit', true);
             }
         }
         // Check edit state permission.
         $item->params->set('access-change', $access->get('core.edit.state'));
     }
     return $item;
 }
Пример #2
0
 /**
  * Add the page title and toolbar.
  *
  * @return    void
  */
 protected function addToolbar()
 {
     JRequest::setVar('hidemainmenu', true);
     $uid = JFactory::getUser()->get('id');
     $is_new = $this->item->id == 0;
     $checked_out = !($this->item->checked_out == 0 || $this->item->checked_out == $uid);
     $access = PFforumHelper::getReplyActions($this->item->id, $this->state->get('topic_id'));
     JToolBarHelper::title(JText::_('COM_PROJECTFORK_PAGE_' . ($checked_out ? 'VIEW_REPLY' : ($is_new ? 'ADD_REPLY' : 'EDIT_REPLY'))), 'article-add.png');
     // Build the actions for new and existing records.
     // For new records, check the create permission.
     if ($is_new && $this->state->get('topic_id')) {
         JToolBarHelper::apply('reply.apply');
         JToolBarHelper::save('reply.save');
         JToolBarHelper::save2new('reply.save2new');
         JToolBarHelper::cancel('reply.cancel');
     } else {
         // Can't save the record if it's checked out.
         if (!$checked_out) {
             if ($access->get('core.edit') || $access->get('core.edit.own') && $this->item->created_by == $uid) {
                 JToolBarHelper::apply('reply.apply');
                 JToolBarHelper::save('reply.save');
                 JToolBarHelper::save2new('reply.save2new');
             }
         }
         // JToolBarHelper::save2copy('reply.save2copy');
         JToolBarHelper::cancel('reply.cancel', 'JTOOLBAR_CLOSE');
     }
 }
Пример #3
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');
 }
Пример #4
0
 public function display($tpl = null)
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     // Get model data.
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     $this->form = $this->get('Form');
     $this->return_page = $this->get('ReturnPage');
     $this->toolbar = $this->getToolbar();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     // Permission check.
     if ($this->item->id <= 0) {
         $access = PFforumHelper::getActions();
         $authorised = $access->get('core.create');
     } else {
         $authorised = $this->item->params->get('access-edit');
     }
     if ($authorised !== true) {
         JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
         return false;
     }
     //Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($this->state->params->get('pageclass_sfx'));
     $this->params = $this->state->params;
     $this->user = $user;
     // Prepare the document
     $this->_prepareDocument();
     // Display the view
     parent::display($tpl);
 }
Пример #5
0
 /**
  * Method to auto-populate the model state.
  * Note. Calling getState in this method will result in recursion.
  *
  * @return    void
  */
 protected function populateState($ordering = 'last_activity', $direction = 'DESC')
 {
     $app = JFactory::getApplication();
     $access = PFforumHelper::getActions();
     // Adjust the context to support modal layouts.
     $layout = JRequest::getCmd('layout');
     // View Layout
     $this->setState('layout', $layout);
     if ($layout) {
         $this->context .= '.' . $layout;
     }
     // Params
     $value = $app->getParams();
     $this->setState('params', $value);
     // State
     $state = $app->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', '');
     $this->setState('filter.published', $state);
     // Filter on published for those who do not have edit or edit.state rights.
     if (!$access->get('core.edit.state') && !$access->get('core.edit')) {
         $this->setState('filter.published', 1);
         $state = '';
     }
     // Filter - Search
     $value = JRequest::getString('filter_search', '');
     $this->setState('filter.search', $value);
     // Filter - Project
     $project = PFApplicationHelper::getActiveProjectId('filter_project');
     $this->setState('filter.project', $project);
     // Filter - Author
     $author = $app->getUserStateFromRequest($this->context . '.filter.author', 'filter_author', '');
     $this->setState('filter.author', $author);
     // Filter - Labels
     $labels = JRequest::getVar('filter_label', array());
     $this->setState('filter.labels', $labels);
     // Do not allow to filter by author if no project is selected
     if (intval($project) == 0) {
         $this->setState('filter.author', '');
         $this->setState('filter.labels', array());
         $author = '';
         $labels = array();
     }
     if (!is_array($labels)) {
         $labels = array();
     }
     // Filter - Is set
     $this->setState('filter.isset', is_numeric($state) || !empty($search) || is_numeric($author) || count($labels));
     // Call parent method
     parent::populateState($ordering, $direction);
 }
Пример #6
0
 /**
  * Generates the toolbar for the top of the view
  *
  * @return    string    Toolbar with buttons
  */
 protected function getToolbar()
 {
     $access = PFforumHelper::getActions();
     $state = $this->get('State');
     PFToolbar::button('COM_PROJECTFORK_ACTION_NEW', 'topicform.add', false, array('access' => $access->get('core.create')));
     $options = array();
     if ($access->get('core.edit.state')) {
         $options[] = array('text' => 'COM_PROJECTFORK_ACTION_PUBLISH', 'task' => $this->getName() . '.publish');
         $options[] = array('text' => 'COM_PROJECTFORK_ACTION_UNPUBLISH', 'task' => $this->getName() . '.unpublish');
         $options[] = array('text' => 'COM_PROJECTFORK_ACTION_ARCHIVE', 'task' => $this->getName() . '.archive');
         $options[] = array('text' => 'COM_PROJECTFORK_ACTION_CHECKIN', 'task' => $this->getName() . '.checkin');
     }
     if ($state->get('filter.published') == -2 && $access->get('core.delete')) {
         $options[] = array('text' => 'COM_PROJECTFORK_ACTION_DELETE', 'task' => $this->getName() . '.delete');
     } elseif ($access->get('core.edit.state')) {
         $options[] = array('text' => 'COM_PROJECTFORK_ACTION_TRASH', 'task' => $this->getName() . '.trash');
     }
     if (count($options)) {
         PFToolbar::listButton($options);
     }
     PFToolbar::filterButton($this->state->get('filter.isset'));
     return PFToolbar::render();
 }
Пример #7
0
                                    </a>
                                </div>
                            <?php 
}
?>
                        </div>
    				</div>
    			</div>
			<!-- End Topic -->

            <!-- Start Replies -->

            <?php 
$k = 0;
foreach ($this->items as $i => $item) {
    $access = PFforumHelper::getReplyActions($item->id);
    $can_create = $access->get('core.create');
    $can_edit = $access->get('core.edit');
    $can_change = $access->get('core.edit.state');
    $can_edit_own = $access->get('core.edit.own') && $item->created_by == $uid;
    $date_opts = array('past-class' => '', 'past-icon' => 'calendar');
    ?>
            	<div class="row-fluid">
    				<div class="span12">
                        <img title="<?php 
    echo $this->escape($item->author_name);
    ?>
"
                             src="<?php 
    echo JHtml::_('projectfork.avatar.path', $item->created_by);
    ?>
Пример #8
0
 public function display($cachable = false, $urlparams = false)
 {
     PFforumHelper::addSubmenu(JFactory::getApplication()->input->get('view', $this->default_view));
     parent::display();
     return $this;
 }
Пример #9
0
 /**
  * Add the page title and toolbar.
  *
  * @return    void
  */
 protected function addToolbar()
 {
     $access = PFforumHelper::getReplyActions(null, (int) $this->state->get('filter.topic'));
     JToolBarHelper::title(JText::_('COM_PROJECTFORK_REPLIES_TITLE'), 'article.png');
     if ($access->get('core.create')) {
         JToolBarHelper::addNew('reply.add');
     }
     if ($access->get('core.edit')) {
         JToolBarHelper::editList('reply.edit');
     }
     if ($access->get('core.edit.state')) {
         JToolBarHelper::divider();
         JToolBarHelper::publish('replies.publish', 'JTOOLBAR_PUBLISH', true);
         JToolBarHelper::unpublish('replies.unpublish', 'JTOOLBAR_UNPUBLISH', true);
         JToolBarHelper::divider();
         JToolBarHelper::archiveList('replies.archive');
         JToolBarHelper::checkin('replies.checkin');
     }
     if ($this->state->get('filter.published') == -2 && $access->get('core.delete')) {
         JToolBarHelper::deleteList('', 'replies.delete', 'JTOOLBAR_EMPTY_TRASH');
         JToolBarHelper::divider();
     } elseif ($access->get('core.edit.state')) {
         JToolBarHelper::trash('replies.trash');
         JToolBarHelper::divider();
     }
 }
Пример #10
0
 /**
  * Method to auto-populate the model state.
  * Note. Calling getState in this method will result in recursion.
  *
  * @return    void
  */
 protected function populateState($ordering = 'a.created', $direction = 'ASC')
 {
     $app = JFactory::getApplication();
     // Adjust the context to support modal layouts.
     $layout = JRequest::getCmd('layout');
     // View Layout
     $this->setState('layout', $layout);
     if ($layout) {
         $this->context .= '.' . $layout;
     }
     // Params
     $value = $app->getParams();
     $this->setState('params', $value);
     // State
     $state = $app->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', '');
     $this->setState('filter.published', $state);
     // Filter - Topic
     $topic = JRequest::getCmd('filter_topic', '');
     $this->setState('filter.topic', $topic);
     // Filter - Project
     $project = PFApplicationHelper::getActiveProjectId('filter_project');
     if (!$project && $topic > 0) {
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('project_id')->from('#__pf_topics')->where('id = ' . $db->quote((int) $topic));
         $db->setQuery($query);
         $project = (int) $db->loadResult();
         PFApplicationHelper::setActiveProject($project);
     }
     $this->setState('filter.project', $project);
     if ($topic) {
         $access = PFforumHelper::getActions($topic);
     } else {
         $access = PFforumHelper::getReplyActions();
     }
     // Filter on published for those who do not have edit or edit.state rights.
     if (!$access->get('core.edit.state') && !$access->get('core.edit')) {
         $this->setState('filter.published', 1);
         $state = '';
     }
     // Filter - Search
     $value = JRequest::getString('filter_search', '');
     $this->setState('filter.search', $value);
     // Filter - Author
     $author = $app->getUserStateFromRequest($this->context . '.filter.author', 'filter_author', '');
     $this->setState('filter.author', $author);
     // Do not allow to filter by author if no project is selected
     if (!is_numeric($project) || intval($project) == 0) {
         $this->setState('filter.author', '');
         $author = '';
     }
     // Filter - Is set
     $this->setState('filter.isset', is_numeric($state) || !empty($search) || is_numeric($author));
     // Call parent method
     parent::populateState($ordering, $direction);
 }
Пример #11
0
 /**
  * Generates the toolbar for the top of the view
  *
  * @return    string    Toolbar with buttons
  */
 protected function getToolbar()
 {
     $options = array();
     $topic = $this->state->get($this->get('Name') . '.topic');
     $access = PFforumHelper::getReplyActions($this->item->id, $topic);
     if ($access->get('core.create')) {
         PFToolbar::button('JSAVE', $this->getName() . '.save', false, array('icon' => 'icon-white icon-ok'));
     }
     PFToolbar::button('JCANCEL', $this->getName() . '.cancel', false, array('class' => '', 'icon' => ''));
     return PFToolbar::render();
 }