Exemplo n.º 1
0
 /**
  * Initialize the controller.
  *
  * This will set up default model and view classes.
  *
  * @throws \Exception
  * @throws AuthenticationException
  *
  * @return  $this  Method supports chaining
  *
  * @since   1.0
  */
 public function initialize()
 {
     parent::initialize();
     /* @type \JTracker\Application $application */
     $application = $this->getContainer()->get('app');
     $project = $application->getProject();
     $user = $application->getUser();
     $this->model->setProject($project);
     $item = $this->model->getItem($application->input->getUint('id'));
     $item->categoryids = array();
     foreach ($item->categories as $category) {
         $item->categoryids[] = $category->id;
     }
     try {
         // Check if the user has full "edit" permission
         $user->authorize('edit');
     } catch (AuthenticationException $e) {
         // Check if the user has "edit own" permission
         if (false == $user->canEditOwn($item->opened_by)) {
             throw $e;
         }
     }
     $this->view->setItem($item)->setProject($project);
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Initialize the controller.
  *
  * This will set up default model and view classes.
  *
  * @return  $this  Method supports chaining
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function initialize()
 {
     parent::initialize();
     /* @type \JTracker\Application $application */
     $application = $this->getContainer()->get('app');
     $project = $application->getProject();
     $user = $application->getUser();
     $user->authorize('view');
     $this->model->setProject($project);
     $item = $this->model->getItem($application->input->getUint('id'));
     $item->userTest = $this->model->getUserTest($item->id, $user->username);
     $this->view->setItem($item);
     $this->view->setEditOwn($user->canEditOwn($item->opened_by));
     $this->view->setProject($project);
     return $this;
 }
Exemplo n.º 3
0
 /**
  * Initialize the controller.
  *
  * This will set up default model and view classes.
  *
  * @return  $this  Method supports chaining
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function initialize()
 {
     parent::initialize();
     $this->getContainer()->get('app')->getUser()->authorize('create');
     // New item
     $path = JPATH_ROOT . '/src/App/Tracker/tpl/new-issue-template.md';
     if (!file_exists($path)) {
         throw new \RuntimeException('New issue template not found.');
     }
     // Set some defaults
     $item = new \stdClass();
     $item->issue_number = 0;
     $item->priority = 3;
     $item->description_raw = file_get_contents($path);
     $this->view->setProject($this->getContainer()->get('app')->getProject());
     $this->view->setItem($item);
 }
Exemplo n.º 4
0
 /**
  * Initialize the controller.
  *
  * This will set up default model and view classes.
  *
  * @return  $this  Method supports chaining
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function initialize()
 {
     parent::initialize();
     /* @type \JTracker\Application $application */
     $application = $this->getContainer()->get('app');
     $project = $application->getProject();
     $user = $application->getUser();
     $user->authorize('view');
     $this->model->setProject($project);
     $item = $this->model->getItem($application->input->getUint('id'));
     if ($item->commits) {
         $commits = json_decode($item->commits);
         $lastCommit = end($commits);
         $sha = $lastCommit->sha;
     } else {
         $sha = false;
     }
     $item->userTest = $this->model->getUserTest($item->id, $user->username, $sha);
     $this->view->setItem($item);
     $this->view->setEditOwn($user->canEditOwn($item->opened_by));
     $this->view->setProject($project);
     return $this;
 }