Esempio n. 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 = PFmilestonesHelper::getActions($this->item->id);
     JToolBarHelper::title(JText::_('COM_PROJECTFORK_PAGE_' . ($checked_out ? 'VIEW_MILESTONE' : ($is_new ? 'ADD_MILESTONE' : 'EDIT_MILESTONE'))), 'article-add.png');
     // Built the actions for new and existing records.
     // For new records, check the create permission.
     if ($is_new) {
         JToolBarHelper::apply('milestone.apply');
         JToolBarHelper::save('milestone.save');
         JToolBarHelper::save2new('milestone.save2new');
         JToolBarHelper::cancel('milestone.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('milestone.apply');
                 JToolBarHelper::save('milestone.save');
                 JToolBarHelper::save2new('milestone.save2new');
             }
         }
         JToolBarHelper::save2copy('milestone.save2copy');
         JToolBarHelper::cancel('milestone.cancel', 'JTOOLBAR_CLOSE');
     }
 }
Esempio n. 2
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 = PFmilestonesHelper::getActions($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;
 }
 public function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     $this->form = $this->get('Form');
     $this->return_page = $this->get('ReturnPage');
     $this->params = $this->state->params;
     $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 = PFmilestonesHelper::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'));
     // Prepare the document
     $this->_prepareDocument();
     // Display the view
     parent::display($tpl);
 }
Esempio n. 4
0
 /**
  * Method to auto-populate the model state.
  * Note. Calling getState in this method will result in recursion.
  *
  * @return    void
  */
 protected function populateState($ordering = 'project_title, a.title', $direction = 'ASC')
 {
     $app = JFactory::getApplication();
     $access = PFmilestonesHelper::getActions();
     // Adjust the context to support modal layouts.
     $layout = JRequest::getCmd('layout');
     $params = $app->getParams();
     $itemid = $app->input->get('Itemid', 0, 'int');
     $menu = $app->getMenu()->getActive();
     // Merge app params with menu item params
     if ($menu) {
         $menu_params = new JRegistry();
         $menu_params->loadString($menu->params);
         $clone_params = clone $menu_params;
         $clone_params->merge($params);
         if (!$itemid) {
             $itemid = (int) $menu->id;
         }
     }
     // View Layout
     $this->setState('layout', $layout);
     if ($layout && $layout != 'print') {
         $this->context .= '.' . $layout;
     }
     $this->context .= '.' . $itemid;
     // Params
     $value = $app->getParams();
     $this->setState('params', $value);
     // State
     $state = $app->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', $params->get('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
     $search = JRequest::getString('filter_search', '');
     $this->setState('filter.search', $search);
     // 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 (!is_numeric($project) || 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));
     // Set list limit
     $cfg = JFactory::getConfig();
     $limit = $app->getUserStateFromRequest($this->context . '.list.limit', 'limit', $params->get('display_num', $cfg->get('list_limit')), 'uint');
     $this->setState('list.limit', $limit);
     $app->set('list_limit', $limit);
     JRequest::setVar('list_limit', $limit);
     // Set sorting order
     $ordering = $app->getUserStateFromRequest($this->context . '.list.ordering', 'filter_order', $params->get('filter_order'));
     $this->setState('list.ordering', $ordering);
     $app->set('filter_order', $ordering);
     JRequest::setVar('filter_order', $ordering);
     // Set order direction
     $direction = $app->getUserStateFromRequest($this->context . '.list.direction', 'filter_order_Dir', $params->get('filter_order_Dir'));
     $this->setState('list.direction', $direction);
     $app->set('filter_order_Dir', $direction);
     JRequest::setVar('filter_order_Dir', $direction);
     // Call parent method
     parent::populateState($ordering, $direction);
 }
Esempio n. 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 = 'project_title, a.title', $direction = 'ASC')
 {
     $app = JFactory::getApplication();
     $access = PFmilestonesHelper::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
     $search = JRequest::getString('filter_search', '');
     $this->setState('filter.search', $search);
     // 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 (!is_numeric($project) || 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);
 }
Esempio n. 6
0
                        <div class="filter-labels">
                            <?php 
    echo JHtml::_('pfhtml.label.filter', 'com_pfmilestones.milestone', $pid, $this->state->get('filter.labels'));
    ?>
                        </div>
                    <?php 
}
?>
                </div>
            </div>

            <?php 
$k = 0;
$current_project = '';
foreach ($this->items as $i => $item) {
    $access = PFmilestonesHelper::getActions($item->id);
    $can_create = $access->get('core.create');
    $can_edit = $access->get('core.edit');
    $can_edit_own = $access->get('core.edit.own') && $item->created_by == $uid;
    $can_checkin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $uid || $item->checked_out == 0;
    $can_change = $access->get('core.edit.state') && $can_checkin;
    // Calculate milestone progress
    $task_count = (int) $item->tasks;
    $completed = (int) $item->completed_tasks;
    $progress = $item->progress;
    // Repo directory
    $repo_dir = (int) $this->params->get('repo_dir');
    if ($item->progress >= 67) {
        $progress_class = 'info';
    }
    if ($item->progress == 100) {
Esempio n. 7
0
 /**
  * Generates the toolbar for the top of the view
  *
  * @return    string    Toolbar with buttons
  */
 protected function getToolbar()
 {
     $access = PFmilestonesHelper::getActions($this->item->id);
     $uid = JFactory::getUser()->get('id');
     $app = JFactory::getApplication();
     if ($this->item->id) {
         $slug = $this->item->id . ':' . $this->item->alias;
         $project_slug = $app->input->getCmd('filter_project');
         $return = base64_encode(PFmilestonesHelperRoute::getMilestoneRoute($slug, $project_slug));
         PFToolbar::button('COM_PROJECTFORK_ACTION_EDIT', '', false, array('access' => $access->get('core.edit') || $access->get('core.edit.own') && $uid == $this->item->created_by, 'href' => JRoute::_(PFmilestonesHelperRoute::getMilestonesRoute() . '&task=form.edit&id=' . $slug . '&return=' . $return)));
     }
     if (PFApplicationHelper::enabled('com_pftasks')) {
         PFToolbar::button(JText::sprintf('JGRID_HEADING_TASKLISTS_AND_TASKS', intval($this->item->lists), intval($this->item->tasks)), '', false, array('href' => JRoute::_(PFtasksHelperRoute::getTasksRoute($this->item->project_id, $this->item->id)), 'icon' => 'icon-chevron-right', 'class' => ''));
     }
     return PFToolbar::render();
 }
Esempio n. 8
0
 public function display($cachable = false, $urlparams = false)
 {
     PFmilestonesHelper::addSubmenu(JFactory::getApplication()->input->get('view', $this->default_view));
     parent::display();
     return $this;
 }
 /**
  * Generates the toolbar for the top of the view
  *
  * @return    string    Toolbar with buttons
  */
 protected function getToolbar()
 {
     $access = PFmilestonesHelper::getActions();
     $state = $this->get('State');
     PFToolbar::button('COM_PROJECTFORK_ACTION_NEW', 'form.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();
 }
Esempio n. 10
0
 /**
  * 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('site');
     // Load state from the request.
     $pk = JRequest::getInt('id');
     $this->setState('milestone.id', $pk);
     // Load the parameters.
     $params = $app->getParams();
     $this->setState('params', $params);
     // Adjust the state filter based on permissions
     $access = PFmilestonesHelper::getActions();
     if (!$access->get('core.edit.state') && !$access->get('core.edit')) {
         $this->setState('filter.published', 1);
         $this->setState('filter.archived', 2);
     }
     // Set the layout
     $this->setState('layout', JRequest::getCmd('layout'));
 }