public function preDispatch()
 {
     parent::preDispatch();
     // do something before the action is called //-> see Zend Framework
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         // We have a login session (user is logged in)
         $this->view->person = $this->person = $auth->getIdentity();
         $this->view->societe = $this->societe = \Object\Societe::getById($this->person->getSociete()->getId());
     } else {
         $this->forward("form-login", "login");
     }
 }
 public function preDispatch()
 {
     parent::preDispatch();
     // do something before the action is called //-> see Zend Framework
     \Pimcore\Tool\Authentication::authenticateSession();
     $adminSession = new \Zend_Session_Namespace("pimcore_admin");
     if (!$adminSession->user instanceof \User) {
         $auth = Zend_Auth::getInstance();
         if ($auth->hasIdentity()) {
             // We have a login session (user is logged in)
             $this->view->person = $this->person = $auth->getIdentity();
             $this->view->societe = $this->societe = \Object\Societe::getById($this->person->getSociete()->getId());
         } else {
             $this->forward("form-login", "login");
         }
     } else {
         $this->view->person = $this->person = \Object\Person::getById(248);
         $this->view->societe = $this->societe = \Object\Societe::getById($this->person->getSociete()->getId());
     }
 }
Example #3
0
 public function registerAction()
 {
     $array = array();
     if ($this->getRequest()->isPost() or $this->getRequest()->isGet()) {
         $field = array('firstname', 'lastname', 'gender', 'address', 'email', 'password', 'city', 'phone');
         foreach ($field as $f) {
             $array[$f] = $this->getParam($f);
         }
         $societe = \Object\Societe::getByReference($this->getParam('reference'), 1);
         if (!$societe instanceof \Object\Societe) {
             throw new \Exception("TXT_REFERENCE_NOT_VALID");
         } else {
             $person = Object\Person::getByEmail($email, 1);
             if (count($person) > 0) {
                 throw new \Exception('TXT_EMAIL_EXIST_ALREADY');
             }
             $societe->createPerson($array);
         }
         //         $person =  Object\Person::create($array);
         //         $person->setKey(\Pimcore\File::getValidFilename($person->getEmail()));
         //         $person->setPublished(true);
         //         $person->setParent(Object\Folder::getByPath("/"));
         //         $person->save();
         $this->forward("login", "login", null, array("email" => $email, "password" => $password));
     }
 }