Пример #1
0
 /**
  * Action to ask for extra information and to send the error report
  * @return null
  */
 public function indexAction()
 {
     $zibo = Zibo::getInstance();
     $session = Session::getInstance();
     $recipient = $zibo->getConfigValue(Module::CONFIG_MAIL_RECIPIENT);
     $subject = $zibo->getConfigValue(Module::CONFIG_MAIL_SUBJECT);
     $report = $session->get(Module::SESSION_REPORT);
     if (!$report || !$recipient) {
         $this->response->setRedirect($this->request->getBaseUrl());
         return;
     }
     $form = new ReportForm($this->request->getBasePath());
     if ($form->isSubmitted()) {
         $comment = $form->getComment();
         if ($comment) {
             $report .= "\n\nComment:\n" . $comment;
         }
         if (!$subject) {
             list($subject, $null) = explode("\n", $report, 2);
         }
         $mail = new Message();
         $mail->setTo($recipient);
         $mail->setSubject($subject);
         $mail->setMessage($report);
         $mail->send();
         $session->set(Module::SESSION_REPORT);
         $this->addInformation(self::TRANSLATION_MAIL_SENT);
         $this->response->setRedirect($this->request->getBaseUrl());
         return;
     }
     $view = new ReportView($form, $report);
     $this->response->setView($view);
 }
 /**
  * Constructs a new authenticator
  * @return null
  */
 public function __construct()
 {
     parent::__construct();
     $this->session = Session::getInstance();
     $this->numVisitors = false;
     $this->numUsers = false;
     $this->currentUsers = false;
 }
 /**
  * Checks if the provided node is collapsed in the tree
  * @param integer $nodeId Id of the node
  * @return boolean True if the node is collapsed, false if the node is expanded
  */
 public static function isNodeCollapsed($nodeId)
 {
     $session = Session::getInstance();
     $nodes = $session->get(self::SESSION_HIDDEN_NODES, array());
     if (array_key_exists($nodeId, $nodes)) {
         return true;
     }
     return false;
 }
 /**
  * Clears the authentification in the storage. When there is a user switch, only the authentication of the switched user should be cleared.
  * If there is no user switch, all authentication data should be cleared
  * @return null
  */
 protected function clearAuthentification()
 {
     if ($this->getSwitchedUsername()) {
         $this->session->set(self::SESSION_SWITCHED_USERNAME, null);
     } else {
         $this->session->set(self::SESSION_USERNAME, null);
         $this->session->set(self::SESSION_AUTHENTICATION_STRING, null);
     }
 }
Пример #5
0
 /**
  * Authenticate a user's session by it's id
  * @param string id of the user's session
  * @throws UnauthorizedException if the token is no longer valid
  */
 public function authenticateSession($id)
 {
     $session = Session::getInstance();
     if ($session->getId() != $id) {
         $session->load($id);
     }
     if (!$session->get(self::SESSION_AUTHENTICATED)) {
         throw new UnauthorizedException('You are no longer authorized because your session id or your session itself has become invalid.');
     }
 }
Пример #6
0
 public function testReset()
 {
     $session = Session::getInstance();
     $session->set('key1', 'value1');
     $session->set('key2', 'value2');
     $sessionKey = Session::SESSION_NAME;
     $this->assertTrue(count($_SESSION[$sessionKey]) >= 2, 'session array has not at least the added elements');
     $session->reset();
     $this->assertTrue(isset($_SESSION[$sessionKey]), 'session array does not exist');
     $this->assertTrue(count($_SESSION[$sessionKey]) == 0, 'session array is not empty');
 }
Пример #7
0
 /**
  * Stores the current site and node to the session
  * @return null
  */
 public function postAction()
 {
     if ($this->site) {
         $this->session->set(self::SESSION_SITE, $this->site->id);
     } else {
         $this->session->set(self::SESSION_SITE);
     }
     if ($this->node) {
         $this->session->set(self::SESSION_NODE, $this->node->id);
     } else {
         $this->session->set(self::SESSION_NODE);
     }
 }
Пример #8
0
 /**
  * Handle a exception, redirect to the error report form
  * @param Exception $exception
  * @return null
  */
 public function handleException(Exception $exception)
 {
     if ($exception instanceof UnauthorizedException) {
         return;
     }
     $zibo = Zibo::getInstance();
     $request = $zibo->getRequest();
     $title = $this->getTitle($exception);
     $report = $this->getReport($exception, $request);
     $zibo->runEvent(Zibo::EVENT_LOG, $title, $report, 1, self::LOG_NAME);
     if (!$zibo->getConfigValue(self::CONFIG_MAIL_RECIPIENT)) {
         return;
     }
     Session::getInstance()->set(self::SESSION_REPORT, $title . "\n" . $report);
     $response = Zibo::getInstance()->getResponse();
     $response->setView(null);
     $response->setRedirect($request->getBaseUrl() . '/report/error');
 }
 /**
  * This is the method that is called whenever an authentication is requested. If a token
  * exists, it will be used for all operations of the client. If it does not exist, the
  * authentication will be triggered
  * @return string|null The authentication token if set, null otherwise
  */
 public function retrieve()
 {
     return Session::getInstance()->get($this->variableName);
 }
Пример #10
0
 /**
  * Gets the locale of the localized content
  * @return string Code of the locale
  */
 public static function isSidebarVisible()
 {
     return !Session::getInstance()->get(self::SESSION_SIDEBAR_HIDDEN, false);
 }
Пример #11
0
 /**
  * Resets this wizard
  * @return null
  */
 public function reset()
 {
     $this->session->set($this->name, array());
 }
Пример #12
0
 /**
  * Construct a new wizard form
  * @param string $action URL where the form will point to
  * @param string $name Name of the form
  * @return null
  */
 public function __construct($action, $name)
 {
     parent::__construct($action, $name);
     $this->appendToClass(self::STYLE_WIZARD);
     $fieldFactory = FieldFactory::getInstance();
     $previousButton = $fieldFactory->createSubmitField(self::BUTTON_PREVIOUS, self::TRANSLATION_PREVIOUS);
     $nextButton = $fieldFactory->createSubmitField(self::BUTTON_NEXT, self::TRANSLATION_NEXT);
     $cancelButton = $fieldFactory->createSubmitField(self::BUTTON_CANCEL, self::TRANSLATION_CANCEL);
     $finishButton = $fieldFactory->createSubmitField(self::BUTTON_FINISH, self::TRANSLATION_FINISH);
     $this->addField($previousButton);
     $this->addField($nextButton);
     $this->addField($cancelButton);
     $this->addField($finishButton);
     $this->steps = array();
     $this->session = Session::getInstance();
 }
Пример #13
0
 /**
  * Creates a new nounce
  * @return null
  */
 private function refreshNonce()
 {
     $this->nonce = uniqid();
     Session::getInstance()->set(self::SESSION_NONCE, $this->nonce);
 }
Пример #14
0
 /**
  * Stores the full URL of the current request as referer to the session
  * @return null
  */
 private function setReferer()
 {
     $request = Zibo::getInstance()->getRequest();
     $referer = $request->getBasePath() . $request->getParametersAsString();
     Session::getInstance()->set(self::SESSION_REFERER, $referer);
 }
Пример #15
0
 /**
  * Gets the locale of the localized content
  * @return string Code of the locale
  */
 public static function getLocale()
 {
     $locale = I18n::getInstance()->getLocale();
     return Session::getInstance()->get(self::SESSION_LOCALE, $locale->getCode());
 }