/** * 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()); }
/** * 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()); }