public function createAction()
 {
     $this->_errorStack = Noobh_ErrorStackSingleton::getInstance();
     $request = $this->getRequest();
     $params = $request->getParams();
     $firstName = htmlspecialchars($params['firstName']);
     $lastName = htmlspecialchars($params['lastName']);
     $username = htmlspecialchars($params['userName']);
     $password = htmlspecialchars($params['password']);
     $email = htmlspecialchars($params['email']);
     $password = md5($password);
     $response = array();
     try {
         $user = new Models_User();
         $user->setFirstName($firstName);
         $user->setLastName($lastName);
         $user->setEmail($email);
         $user->setUsername($username);
         $user->setPassword($password);
         if (!empty($this->_errorStack)) {
             $user->save();
             $response['error_code'] = 0;
             $response['user'] = $user->getHash();
         } else {
             $response['errors'] = $this->_errorStack->getErrorList();
         }
     } catch (Exception $ex) {
         $response['error_code'] = $ex->getCode();
         $response['error_message'] = $ex->getMessage();
     }
     echo json_encode($response);
     exit;
 }
 public function init()
 {
     $this->_disableLayout();
     $this->_disableView();
     if ($this->getRequest()->getAction() == "index") {
         $this->getRequest()->redirectUrl('/get');
     }
     $this->_errorStack = Noobh_ErrorStackSingleton::getInstance();
 }
Пример #3
0
 /**
  * Search user address data using userId or  id.
  *
  * @access public
  * @param int $userId [user id]
  * @param int $id     [addtress id]
  * @return string
  */
 public function searchAddress($userId, $id)
 {
     $this->_errorStack = Noobh_ErrorStackSingleton::getInstance();
     try {
         $addressModel = new Models_Address();
         $result = $addressModel->getAddressBy($userId, $id);
         if (!empty($result)) {
             $addressInfo = array('address1' => $result->getAddress1(), 'address2' => $result->getAddress2(), 'country' => $result->getCountry(), 'zipCode' => $result->getZipCode(), 'mobileNumber' => $result->getMobileNumber(), 'phoneNumber' => $result->getHomeNumber());
             return $addressInfo;
         } else {
             throw new Exception($this->_errorList[601], 601);
         }
     } catch (Exception $ex) {
         $code = $ex->getCode();
         $message = $ex->getMessage();
         $this->_errorStack->push(self::VALIDATION_TYPE, $code, $message);
         Noobh_Log::error($message);
         throw new Exception($message);
     }
 }
Пример #4
0
 /**
  * Validates the password for min,max length, special characters,
  * Upper characters, Lower characters and numeric value.
  *
  * @access private
  * @param string $password [Passowrd]
  * @return bool
  */
 private function _isValidPassword($password)
 {
     if (strlen($password) < 8) {
         $this->_errorStack->push(self::VALIDATION_TYPE, 907, $this->_errorList[907]);
     }
     if (strlen($password) > 20) {
         $this->_errorStack->push(self::VALIDATION_TYPE, 908, $this->_errorList[908]);
     }
     if (!preg_match('/[0-9]/', $password)) {
         $this->_errorStack->push(self::VALIDATION_TYPE, 915, $this->_errorList[915]);
     }
     if (!preg_match('/[A-Z]/', $password)) {
         $this->_errorStack->push(self::VALIDATION_TYPE, 916, $this->_errorList[916]);
     }
     if (!preg_match('/[a-z]/', $password)) {
         $this->_errorStack->push(self::VALIDATION_TYPE, 917, $this->_errorList[917]);
     }
     if (!preg_match('/[\\^£$&*()}{@#~?><>,|=_+¬-]/', $password)) {
         $this->_errorStack->push(self::VALIDATION_TYPE, 918, $this->_errorList[918]);
     }
 }
Пример #5
0
 public function _initLoadSetup()
 {
     Noobh_Registry::set('errorStack', Noobh_ErrorStackSingleton::getInstance());
     session_start();
 }
Пример #6
0
 /**
  * Update user address by address id.
  *
  * @access private
  * @param void
  * @return bool
  */
 private function _update()
 {
     try {
         $bind = array($this->_address1, $this->_address2, $this->_zipCode, $this->_country, $this->_mobileNumber, $this->_homeNumber);
         //update based on id
         $sql = 'UPDATE um_address SET address1 = ?, address2 = ?,zip = ?, country = ?, mobile_phone = ?, home_phone = ?' . " WHERE id = {$this->_id}";
         $this->_dbAdapter->query($sql, $bind);
         //Log debug message
         Noobh_Log::debug(__CLASS__ . '::' . __FUNCTION__ . 'Completed executing Sql Query - ' . $sql);
         //Log info
         Noobh_Log::info(__CLASS__ . '::' . __FUNCTION__ . 'Updated user address with id : ' . $this->_id);
     } catch (Exception $ex) {
         $this->_errorStack->push(self::VALIDATION_TYPE, 911, $this->_errorList[911]);
         //Log fatal error
         Noobh_Log::fatal(__CLASS__ . '::' . __FUNCTION__ . ' User address update failed for id: ' . $this->_id . ' , Error code ' . $ex->getCode() . ' , Error Message ' . $ex->getMessage());
     }
 }