Beispiel #1
0
 /**
  * Add the page title and toolbar.
  *
  */
 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 = PFcommentsHelper::getActions($this->item->id);
     JToolBarHelper::title(JText::_('COM_PROJECTFORK_PAGE_' . ($checked_out ? 'VIEW_COMMENT' : ($is_new ? 'ADD_COMMENT' : 'EDIT_COMMENT'))), 'article-add.png');
     // Built the actions for new and existing records.
     // For new records, check the create permission.
     if ($is_new) {
         JToolBarHelper::apply('comment.apply');
         JToolBarHelper::save('comment.save');
         JToolBarHelper::save2new('comment.save2new');
         JToolBarHelper::cancel('comment.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('comment.apply');
                 JToolBarHelper::save('comment.save');
                 JToolBarHelper::save2new('comment.save2new');
             }
         }
         // JToolBarHelper::save2copy('comment.save2copy');
         JToolBarHelper::cancel('comment.cancel', 'JTOOLBAR_CLOSE');
     }
 }
 /**
  * Method to get the record form.
  *
  * @param     array      Data for the form.
  * @param     boolean    True if the form is to load its own data (default case), false if not.
  *
  * @return    mixed      A JForm object on success, false on failure
  */
 public function getForm($data = array(), $loadData = true)
 {
     // Get the form.
     $form = $this->loadForm('com_pfcomments.comment' . 'comment', 'comment', array('control' => 'jform', 'load_data' => $loadData));
     if (empty($form)) {
         return false;
     }
     $jinput = JFactory::getApplication()->input;
     $id = $jinput->get('id', 0);
     $item_access = PFcommentsHelper::getActions($id);
     $access = PFcommentsHelper::getActions();
     // Check for existing item.
     // Modify the form based on Edit State access controls.
     if ($id != 0 && !$item_access->get('core.edit.state') || $id == 0 && !$access->get('core.edit.state')) {
         // Disable fields for display.
         $form->setFieldAttribute('state', 'disabled', 'true');
         $form->setFieldAttribute('state', 'filter', 'unset');
     }
     // Check if the project, context and context item are given
     $project_id = (int) $form->getValue('project_id');
     $item_id = $form->getValue('item_id');
     $context = $form->getValue('context');
     if (!$project_id) {
         $form->setValue('project_id', null, $this->getState($this->getName() . '.project'));
     }
     if (!$item_id) {
         $form->setValue('item_id', null, $this->getState($this->getName() . '.item_id'));
     }
     if (!$context) {
         $form->setValue('context', null, $this->getState($this->getName() . '.context'));
     }
     return $form;
 }
Beispiel #3
0
 /**
  * Method to get item data.
  *
  * @param     integer    $id       The id of the item.
  * @return    mixed      $value    Item data object on success, false on failure.
  */
 public function getItem($id = null)
 {
     // Initialise variables.
     $id = (int) (!empty($id)) ? $id : $this->getState($this->getName() . '.id');
     // Get a row instance.
     $table = $this->getTable();
     // Attempt to load the row.
     $return = $table->load($id);
     // Check for a table object error.
     if ($return === false && $table->getError()) {
         $this->setError($table->getError());
         return false;
     }
     $properties = $table->getProperties(1);
     $value = JArrayHelper::toObject($properties, 'JObject');
     // Convert attrib field to Registry.
     $value->params = new JRegistry();
     $value->params->loadString($value->attribs);
     // Count parent replies
     $value->parent_replies = $this->countReplies($value->parent_id);
     // Count replies of this item
     $value->replies = $this->countReplies($value->id);
     // Compute selected asset permissions.
     $uid = JFactory::getUser()->get('id');
     $access = PFcommentsHelper::getActions($value->id);
     // Check general edit permission first.
     if ($access->get('core.edit')) {
         $value->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 == $value->created_by) {
             $value->params->set('access-edit', true);
         }
     }
     // Check edit state permission.
     if ($id) {
         // Existing item
         $value->params->set('access-change', $access->get('core.edit.state'));
     } else {
         // New item
         $access = PFcommentsHelper::getActions();
         $value->params->set('access-change', $access->get('core.edit.state'));
     }
     return $value;
 }
 /**
  * Display the view
  *
  * @return void
  */
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $active = $app->getMenu()->getActive();
     $this->items = $this->get('Items');
     $this->state = $this->get('State');
     $this->params = $this->state->params;
     // Try to find the asset
     $asset = null;
     $context = $this->state->get('filter.context');
     $item_id = (int) $this->state->get('filter.item_id');
     if ($context) {
         $context_parts = explode('.', $context);
         $asset = end($context_parts);
         if ($asset == 'user') {
             $asset = null;
         }
     } else {
         $item_id = 0;
     }
     $this->access = PFcommentsHelper::getActions();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // Check for layout override
     if (isset($active->query['layout']) && JRequest::getCmd('layout') == '') {
         $this->setLayout($active->query['layout']);
     }
     // Display the view
     parent::display($tpl);
     if (JRequest::getVar('tmpl') == 'component') {
         jexit();
     }
 }
 public function display($cachable = false, $urlparams = false)
 {
     PFcommentsHelper::addSubmenu(JFactory::getApplication()->input->get('view', $this->default_view));
     parent::display();
     return $this;
 }
                <th width="10%" class="nowrap hidden-phone">
                    <?php 
echo JHtml::_('grid.sort', 'JDATE', 'a.created', $list_dir, $list_order);
?>
                </th>
                <th width="1%" class="nowrap hidden-phone">
                    <?php 
echo JHtml::_('grid.sort', 'JGRID_HEADING_ID', 'a.id', $list_dir, $list_order);
?>
                </th>
            </tr>
        </thead>
        <tbody>
        <?php 
foreach ($this->items as $i => $item) {
    $access = PFcommentsHelper::getActions($item->id);
    $context = str_replace('.', '_', strtoupper($item->context)) . '_TITLE';
    if ($item->level == 0) {
        $item->level = 1;
    }
    $can_create = $access->get('core.create');
    $can_edit = $access->get('core.edit');
    $can_checkin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $uid || $item->checked_out == 0;
    $can_edit_own = $access->get('core.edit.own') && $item->created_by == $uid;
    $can_change = $access->get('core.edit.state') && $can_checkin;
    // Prepare subtitles
    $subtitles = array();
    if (!$filter_context) {
        $subtitles[] = $txt_context . ': ' . JText::_($context);
    }
    $subtitles[] = $txt_title . ': ' . $this->escape($item->title);