Beispiel #1
0
 /**
  * Generates the toolbar for the top of the view
  *
  * @return    string    Toolbar with buttons
  */
 protected function getToolbar()
 {
     $config = JComponentHelper::getParams('com_pfdesigns', true);
     $uid = JFactory::getUser()->get('id');
     $slug = $this->item->id . ':' . $this->item->alias;
     $return = base64_encode(JFactory::getURI()->toString());
     $rev = $this->item->revision;
     $access = PFdesignsHelper::getActions($this->item->id);
     $access2 = $rev ? PFdesignsHelper::getRevisionActions($rev->id) : null;
     // Get the permissions
     $is_owner = $uid == $this->item->created_by;
     $can_add = $access->get('core.create');
     $can_edit = $access->get('core.edit') || $access->get('core.edit.own') && $is_owner;
     $can_dl = $access->get('core.download');
     $can_zip = class_exists('ZipArchive');
     $can_edit_state = $access->get('core.edit.state');
     $can_delete = $access->get('core.delete');
     $can_approve = $access->get('core.approve');
     $has_approved = array_key_exists($uid, $this->item->approved);
     $has_declined = array_key_exists($uid, $this->item->declined);
     $list_view = 'designs';
     // Overwrite permissions when looking at a revision
     if ($rev) {
         $is_owner = $uid == $rev->created_by;
         $can_edit = $access2->get('core.edit') || $access2->get('core.edit.own') && $is_owner;
         $can_dl = $access2->get('core.download');
         $can_edit_state = $access2->get('core.edit.state');
         $can_delete = $access2->get('core.delete');
         $can_approve = $access2->get('core.approve');
         $has_approved = array_key_exists($uid, $rev->approved);
         $has_declined = array_key_exists($uid, $rev->declined);
         $list_view = 'revisions';
     }
     $options = array();
     if ($access->get('core.create')) {
         $options[] = array('text' => 'JACTION_ADD', 'task' => 'revisionform.add', 'access' => $access->get('core.create'));
     }
     if ($can_edit) {
         $options[] = array('text' => 'COM_PROJECTFORK_ACTION_EDIT', 'task' => $rev ? 'revisionform.edit' : 'designform.edit', 'access' => $can_edit);
     }
     PFToolbar::dropdownButton($options, array('icon' => 'icon-white icon-plus'));
     // Download button
     if ($can_dl) {
         $link = PFdesignsHelperRoute::getDesignRoute($this->item->slug, $this->item->project_slug, $this->item->album_slug, $rev ? $rev->slug : '0:original');
         PFToolbar::button('JACTION_DOWNLOAD', null, false, array('access' => true, 'icon' => 'icon-download', 'href' => $link . '&tmpl=component&layout=download&format=raw'));
     }
     // Approve and Decline buttons
     if ($can_approve) {
         $behavior = $config->get('approval_behavior', 'changeable');
         $final = $behavior == 'final';
         PFToolbar::group();
         if ($final && !$has_declined || !$final) {
             PFToolbar::button($has_approved ? 'COM_PFDESIGNS_ACTION_APPROVED' : 'COM_PFDESIGNS_ACTION_APPROVE', $has_approved || $final ? '' : ($rev ? 'revisionform.approve' : 'designform.approve'), false, array('access' => true, 'icon' => 'icon-thumbs-up', 'class' => 'btn' . ($has_approved ? ' btn-success active' . ($final ? ' disabled' : '') : ''), 'href' => !$final || $has_approved ? null : "javascript:confirmApprove('approve-design');", 'id' => 'approve-design'));
         }
         if (!$has_declined && !$has_approved) {
             PFToolbar::button('COM_PFDESIGNS_UNDECIDED', '', false, array('access' => true, 'href' => '#', 'icon' => '', 'class' => 'btn active'));
         }
         if ($final && !$has_approved || !$final) {
             PFToolbar::button($has_declined ? 'COM_PFDESIGNS_ACTION_DECLINED' : 'COM_PFDESIGNS_ACTION_DECLINE', $has_declined || $final ? '' : ($rev ? 'revisionform.decline' : 'designform.decline'), false, array('access' => true, 'icon' => 'icon-thumbs-down', 'class' => 'btn' . ($has_declined ? ' btn-danger active' . ($final ? ' disabled' : '') : ''), 'href' => !$final || $has_declined ? null : "javascript:confirmDecline('decline-design');", 'id' => 'decline-design'));
         }
         PFToolbar::group();
     }
     return PFToolbar::render();
 }