public function indexActionDB()
 {
     $objectManager = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
     $user = new \Application\Entity\User();
     $user->setFirstName('Marco');
     $user->setLastName('Pivetta');
     $objectManager->persist($user);
     $objectManager->flush();
     // die(var_dump($user->getId())); // yes, I'm lazy
 }
Beispiel #2
0
 public function indexAction()
 {
     $objectManager = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
     $user = new \Application\Entity\User();
     $user->setFullName('Henry Grech-Cini');
     $objectManager->persist($user);
     $objectManager->flush();
     $view = new ViewModel(array('content' => $user->getId()));
     return $view;
 }
Beispiel #3
0
 protected function socialAuthUlogin()
 {
     if (!empty($_POST) && isset($_POST['token'])) {
         //            $s    = file_get_contents('http://ulogin.ru/token.php?token='.$_POST['token'].'&host='.$_SERVER['HTTP_HOST']);
         //            $user = json_decode($s, true);
         $authService = $this->getAuthService();
         $authStorage = $authService->getStorage();
         $authStorage->clear();
         //var_dump ( $authStorage );
         $user = new \Application\Entity\User();
         $user->setName('testName');
         //var_dump($user);
         $authStorage->write($user);
         var_dump($authStorage->read());
         //            var_dump($user);
         //$user['network'] - соц. сеть, через которую авторизовался пользователь
         //$user['identity'] - уникальная строка определяющая конкретного пользователя соц. сети
         //$user['first_name'] - имя пользователя
         //$user['last_name'] - фамилия пользователя
     }
 }
Beispiel #4
0
 public function addAction()
 {
     $user = new \Application\Entity\User();
     $form = new UserForm();
     $form->setInputFilter($user->getInputFilter())->setData($this->getRequest()->getPost())->get('submit')->setValue('Add');
     if ($this->getRequest()->isPost() && $form->isValid()) {
         $user->setOptions($form->getData());
         // set the data
         $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
         // entity manager
         $em->persist($user);
         // set data
         $em->flush();
         // save
         // set messages
         //$this->flashMessenger()->addMessage('You must do something.');
         //$this->flashMessenger()->addMessage(array('alert-info'=>'Soon this changes.'));
         $this->flashMessenger()->addMessage(array('alert-success' => 'Added!'));
         //$this->flashMessenger()->addMessage(array('alert-error'=>'Sorry, Error.'));
         // Redirect to list of users
         return $this->redirect()->toRoute('admin/user');
     }
     return array('form' => $form);
 }
Beispiel #5
0
 public function registerUser($formdata)
 {
     $entity = new \Application\Entity\User();
     $roleid = $this->em->getRepository('\\Application\\Entity\\Role')->find($formdata['User']['fkRoleid']);
     //Initialize fields
     $entity->setUsername($formdata['User']['username']);
     $entity->setFirstname($formdata['User']['basicdetails']['firstname']);
     $entity->setSurname($formdata['User']['basicdetails']['surname']);
     $entity->setOthernames($formdata['User']['basicdetails']['othernames']);
     $entity->setGender($formdata['User']['basicdetails']['gender']);
     $entity->setPassword($this->cs->_hashing($formdata['password']));
     $entity->setTitle($formdata['User']['basicdetails']['title']);
     $entity->setAccounttype("STAFF");
     $entity->setEmailaddress($formdata['User']['emailaddress']);
     $entity->setFkRoleid($roleid);
     $fkUserid = $this->saveUser($entity);
     //Save user in user table
     if ($fkUserid) {
         //Set staff entity
         $staffentity = new \Application\Entity\Staff();
         $fkDeptid = $this->em->getRepository('\\Application\\Entity\\Department')->find($formdata['Staff']['fkDeptid']);
         $staffentity->setFkDeptid($fkDeptid);
         $staffentity->setFkUserid($fkUserid);
         $staffentity->setWorkmode($formdata['Staff']['workmode']);
         //Save in staff table
         $staffid = $this->saveStaff($staffentity);
         //Assign to department as head
         if ($formdata['ishead']) {
             $departmentModel = new \Application\Model\Preferences($this->em);
             // Update is head
             $deptEntity = $fkDeptid->setFkStaffid($staffid);
             $departmentModel->saveDepartment($deptEntity);
         }
     }
     return $fkUserid;
 }
Beispiel #6
0
 /**
  * Create a new user
  *
  * @param $request
  * @return \Application\Entity\User
  */
 public function register($request)
 {
     $messages = $this->validateRegisterRequest($request);
     if (empty($messages)) {
         $salt = md5(time());
         $password_md5 = md5($salt . $request['password']);
         $user = new \Application\Entity\User();
         $user->setEmail($request['email']);
         $user->setSalt($salt);
         $user->setPassword($password_md5);
         $this->em()->persist($user);
         $this->em()->flush();
         $status = true;
         $entity = $user;
     } else {
         $status = false;
         $entity = null;
     }
     return array("status" => $status, "messages" => $messages, "entity" => $entity);
 }