/**
  * Creates user
  *
  * @param array $array Array of parameters
  * @throws ModelException
  */
 public function create(array $array)
 {
     $user = new User();
     $this->convertDates($array, ['birth_date']);
     $user->populate($array);
     $existingUser = $this->dao->getUserByLogin($user->login);
     if (!is_null($existingUser)) {
         throw new ModelException('This login already exists');
     }
     $passwordManager = new PasswordManager();
     $salt = $passwordManager->getRandomSalt();
     $password = $passwordManager->getHash($array['password'], $salt);
     $user->password = $password;
     $user->salt = $salt;
     $this->dao->save($user);
 }
示例#2
0
 /**
  * Return an array of all IXP names where the array key is the IXP id.
  *
  * NOTE: Super user can see all IXPs and customer user can see only those which
  *         is assigned to the users customer.
  *
  * @param  \Entities\User $user User to limit IXP names
  * @return array An array of all IXP names with the IXP id as the key.
  */
 public function getNames($user)
 {
     $dql = "SELECT i.id AS id, i.name AS name FROM Entities\\IXP i";
     if ($user->getPrivs() != \Entities\User::AUTH_SUPERUSER) {
         $dql .= " WHERE ?1 MEMBER OF i.Customers";
     }
     $dql .= " ORDER BY name ASC";
     $query = $this->getEntityManager()->createQuery($dql);
     if ($user->getPrivs() != \Entities\User::AUTH_SUPERUSER) {
         $query->setParameter(1, $user->getCustomer()->getId());
     }
     $aixps = $query->getResult();
     $ixps = [];
     foreach ($aixps as $i) {
         $ixps[$i['id']] = $i['name'];
     }
     return $ixps;
 }
示例#3
0
 public function setReporter(User $reporter)
 {
     $reporter->addReportedBug($this);
     $this->reporter = $reporter;
 }
<?php

$database = true;
$app = 'frontend';
$fixtures = true;
require_once dirname(__FILE__) . '/../bootstrap/unit.php';
$t = new lime_test(1, new lime_output_color());
$user = \Entities\User::findOneByUsername('jwage');
$t->is($user->username, 'jwage');
 /**
  * Gets user by login
  *
  * @param string $login Login
  * @return User|null User entity or null
  * @throws \db\DatabaseException
  */
 public function getUserByLogin($login)
 {
     $array = $this->db->getRow('select * from ' . DB_TABLE_USERS_VIEW . ' where login = ?', [$login]);
     if (!is_null($array)) {
         $entity = new User();
         $entity->populate($array);
         return $entity;
     }
     return null;
 }
 public function __toString()
 {
     $this->_load();
     return parent::__toString();
 }
 public function _getPreferences()
 {
     $this->__load();
     return parent::_getPreferences();
 }
示例#8
0
 /**
  * Send a welcome email to a new user
  *
  * @param \Entities\User $user The recipient of the email
  * @return bool True if the mail was sent successfully
  */
 private function sendWelcomeEmail($user)
 {
     try {
         $mail = $this->getMailer();
         $mail->setFrom($this->_options['identity']['email'], $this->_options['identity']['name'])->setSubject($this->_options['identity']['sitename'] . ' - ' . _('Your Access Details'))->addTo($user->getEmail(), $user->getUsername())->setBodyHtml($this->view->render('user/email/html/welcome.phtml'))->send();
     } catch (Zend_Mail_Exception $e) {
         $this->getLogger()->alert("Could not send welcome email for new user!\n\n" . $e->toString());
         return false;
     }
     return true;
 }
 public function getAdmin()
 {
     $this->__load();
     return parent::getAdmin();
 }
示例#10
0
 /**
  * Generate the user hash in a secure format for storage in a client side 'remember cookie' cookie
  *
  * @param \Entities\User $user The user entitiy to generate the hash for
  * @return string The `sha1()` hash
  */
 protected function _generateCookieUserhash($user)
 {
     return sha1($user->getId() . '+' . $user->getUsername() . '/' . $this->_options['resources']['auth']['oss']['rememberme']['salt']);
 }
 public function getAssignedBugs()
 {
     $this->__load();
     return parent::getAssignedBugs();
 }
示例#12
0
 /**
  * A simple function to reauthenticate to a given user **Ignores password**.
  *
  * @param \Entities\User $nuser The user to reauthenticate as
  * @return Zend_Auth_Result
  */
 protected function _reauthenticate($nuser)
 {
     $auth = Zend_Auth::getInstance();
     $authAdapter = $this->_getAuthAdapter($nuser->getUsername(), $nuser->getPassword());
     // trick the adapter into ignoring the password
     $authAdapter->haveCookie(true);
     return $auth->authenticate($authAdapter);
 }
 /**
  *
  * @param IXP_Form_User $form The form object
  * @param \Entities\User $object The Doctrine2 entity (being edited or blank for add)
  * @param bool $isEdit True of we are editing an object, false otherwise
  * @return void
  */
 protected function addPostFlush($form, $object, $isEdit)
 {
     if (isset($this->_feParams->userStatus) && $this->_feParams->userStatus == "created") {
         $this->view->newuser = $object->getUser();
         $this->sendWelcomeEmail($object);
     }
     return $this->postFlush($object);
 }
示例#14
0
 /**
  * This function is called just before `switchUserBackAction()` actually switches
  * the user back.
  *
  * @param \Entities\User $subUser The current user we have switched to (substituted to)
  * @param \Entities\User $origUser The original user that we switched from
  * @return bool|array False if you want the switch back to fail.
  */
 protected function _switchUserBackCheck($subUser, $origUser)
 {
     // record current user customer ID
     $custid = $this->getUser()->custid;
     $params['url'] = 'customer/overview/tab/users/id/' . $subUser->getCustomer()->getId();
     return $params;
 }