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(); }
/** * Returns the user data based on the parameter passed through * the function and initialize the error stack. * * @access public * @param string $email [User email address] * @param int $id [User id] * @param null $hashId [User hashId] * @return $this */ public function __construct($email = null, $id = null, $hashId = null, $isActive = false) { $this->_errorStack = Noobh_ErrorStackSingleton::getInstance(); if (!is_null($hashId) || !is_null($email) || !is_null($id)) { return $this->getUserBy($email, $id, $hashId, $isActive); } return $this; }
/** * 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); } }
public function _initLoadSetup() { Noobh_Registry::set('errorStack', Noobh_ErrorStackSingleton::getInstance()); session_start(); }
/** * Returns the user address based on the user id or id * and initialize the error stack. * * @param Models_user $userId [Models_User Id] * @param int $id [Models_Address Id] * @return array */ public function __construct($userId = null, $id = null) { $this->_errorStack = Noobh_ErrorStackSingleton::getInstance(); if (!is_null($userId) || !is_null($id)) { return $this->getAddressBy($userId, $id); } return $this; }