Ejemplo n.º 1
0
 /**
  * Initialize the controller.
  *
  * This will set up default model and view classes.
  *
  * @return  $this  Method allows chaining
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function initialize()
 {
     parent::initialize();
     $this->getContainer()->get('app')->getUser()->authorize('admin');
     $this->view->setAlias($this->getContainer()->get('app')->input->get('project_alias'));
     return $this;
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
 /**
  * Initialize the controller.
  *
  * @return  $this  Method allows chaining
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function initialize()
 {
     parent::initialize();
     $this->getContainer()->get('app')->getUser()->authorize('admin');
     $this->view->setProject($this->getContainer()->get('app')->getProject());
     return $this;
 }
Ejemplo n.º 4
0
 /**
  * Initialize the controller.
  *
  * This will set up default model and view classes.
  *
  * @return  $this  Method allows chaining
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function initialize()
 {
     // Reload the project.
     $this->getContainer()->get('app')->getProject(true);
     parent::initialize();
     $this->view->setAlias($this->getContainer()->get('app')->input->get('project_alias'));
     return $this;
 }
Ejemplo n.º 5
0
 /**
  * Initialize the controller.
  *
  * @return  $this  Method allows chaining
  *
  * @since   1.0
  */
 public function initialize()
 {
     parent::initialize();
     $this->getContainer()->get('app')->getUser()->authorize('admin');
     $this->view->setLogType($this->getContainer()->get('app')->input->get('log_type'));
     $this->view->setDebugger(new TrackerDebugger($this->getContainer()));
     return $this;
 }
Ejemplo n.º 6
0
 /**
  * Initialize the controller.
  *
  * This will set up default model and view classes.
  *
  * @return  $this  Method allows chaining
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function initialize()
 {
     parent::initialize();
     $this->getContainer()->get('app')->getUser()->authorize('manage');
     $this->model->setProject($this->getContainer()->get('app')->getProject());
     $this->model->setGroupId($this->getContainer()->get('app')->input->getInt('group_id'));
     $this->view->setProject($this->getContainer()->get('app')->getProject());
     return $this;
 }
Ejemplo n.º 7
0
 /**
  * Initialize the controller.
  *
  * @return  $this  Method supports chaining
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function initialize()
 {
     parent::initialize();
     /* @type $input \Joomla\Input\Input */
     $input = $this->getContainer()->get('app')->input;
     $path = $input->getPath('path');
     $page = $input->getCmd('page');
     if ($page) {
         $fullPath = 'page=' . $page . ($path ? '&path=' . $path : '');
         $this->view->setFullPath($fullPath);
     }
 }
Ejemplo n.º 8
0
 /**
  * Initialize the controller.
  *
  * This will set up default model and view classes.
  *
  * @return  $this  Method allows chaining
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function initialize()
 {
     parent::initialize();
     $id = $this->getContainer()->get('app')->input->getUint('id');
     if (!$id) {
         // If no ID is given, use the ID of the current user.
         $id = $this->getContainer()->get('app')->getUser()->id;
         if (!$id) {
             throw new \UnexpectedValueException('No logged in user.');
         }
     }
     $this->view->id = (int) $id;
     $this->model->setProject($this->getContainer()->get('app')->getProject());
 }
Ejemplo n.º 9
0
 /**
  * Initialize the controller.
  *
  * @return  $this  Method allows chaining
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function initialize()
 {
     parent::initialize();
     $alias = $this->getContainer()->get('app')->input->get('project_alias');
     if ($alias) {
         $project = (new ProjectModel($this->getContainer()->get('db')))->getByAlias($alias);
     } else {
         $project = $this->getContainer()->get('app')->getProject();
     }
     $data = (new Github())->repositories->statistics->getListContributors($project->gh_user, $project->gh_project);
     $data = array_reverse($data);
     $this->view->setProject($project);
     $this->view->setData($data);
     return $this;
 }
 /**
  * Initialize the controller.
  *
  * @return  $this  Method allows chaining
  *
  * @since   1.0
  */
 public function initialize()
 {
     parent::initialize();
     /* @type Application $application */
     $application = $this->getContainer()->get('app');
     $limit = $application->getUserStateFromRequest('list.limit', 'list_limit', 20, 'int');
     $page = $application->input->getInt('page');
     $value = $page ? ($page - 1) * $limit : 0;
     $limitStart = $limit != 0 ? floor($value / $limit) * $limit : 0;
     $state = $this->model->getState();
     $state->set('list.start', $limitStart);
     $state->set('list.limit', $limit);
     $this->model->setState($state);
     $this->model->setPagination(new TrackerPagination(new Uri($this->getContainer()->get('app')->get('uri.request'))));
     return $this;
 }
Ejemplo n.º 11
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;
 }
Ejemplo n.º 12
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);
 }
Ejemplo n.º 13
0
 /**
  * Initialize the controller.
  *
  * This will set up default model and view classes.
  *
  * @return  $this  Method allows chaining
  *
  * @since   1.0
  * @throws  \UnexpectedValueException
  */
 public function initialize()
 {
     parent::initialize();
     /* @type \JTracker\Application $application */
     $application = $this->getContainer()->get('app');
     $id = $application->input->getUint('id');
     if (!$id) {
         throw new \UnexpectedValueException('No id given');
     }
     if (!$application->getUser()->check('admin')) {
         if ($application->getUser()->id != $id) {
             $application->enqueueMessage(g11n3t('You are not authorized to edit this user.'), 'error');
             $application->redirect($application->get('uri.base.path') . 'users');
         }
     }
     $this->view->id = $id;
     $this->model->setProject($this->getContainer()->get('app')->getProject());
 }
Ejemplo n.º 14
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;
 }
Ejemplo n.º 15
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->view->setAlias($this->getContainer()->get('app')->input->getCmd('alias'));
 }
Ejemplo n.º 16
0
 /**
  * Initialize the controller.
  *
  * @return  $this
  *
  * @since   1.0
  */
 public function initialize()
 {
     parent::initialize();
     $this->getContainer()->get('app')->getUser()->authorize('admin');
     $this->view->setItem($this->model->getItem($this->getContainer()->get('app')->input->getInt('id')));
 }
Ejemplo n.º 17
0
 /**
  * Initialize the controller.
  *
  * This will set up default model and view classes.
  *
  * @return  $this  Method allows chaining
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function initialize()
 {
     parent::initialize();
     $this->model->setUser($this->getContainer()->get('app')->getUser());
     return $this;
 }
Ejemplo n.º 18
0
 /**
  * Initialize the controller.
  *
  * This will set up default model and view classes.
  *
  * @return  $this  Method allows chaining
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function initialize()
 {
     parent::initialize();
     $this->getContainer()->get('app')->getUser()->authorize('admin');
     $this->model->setUser($this->getContainer()->get('app')->getUser());
 }
Ejemplo n.º 19
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->view->setItem(new ArticlesTable($this->getContainer()->get('db')));
 }