Exemplo 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();
     $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());
 }
Exemplo n.º 2
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());
 }
Exemplo n.º 3
0
 /**
  * Method to render the view.
  *
  * @return  string  The rendered view.
  *
  * @since   1.0
  */
 public function render()
 {
     $item = $this->model->getItem($this->id);
     $this->renderer->set('item', $item)->set('tz_offset', (new \DateTimeZone($item->params->get('timezone', 'UTC')))->getOffset(new \DateTime()) / 3600);
     return parent::render();
 }