public function add(User $user) { $sp = "sp_user_add"; $params = new SDMDBParameters(); $params->add($user->getType()); $params->add($user->getName()); $params->add($user->getPassword()); // var_dump($params); $result = $this->handler->execute_stored_procedure($sp, $params, 'array'); // var_dump($result); $ret = false; if ($result && $result['response']['system']['errorNo'] == 0) { if (isset($result['response']['resultSet'])) { if (isset($result['response']['resultSet'][0]['result'])) { $ret = $result['response']['resultSet'][0]['result']; if (strcmp($ret, "-1") == 0) { throw new SSSException(ErrorFactory::ERR_RECORD_IS_EXIST); } } else { $ret = false; } } else { $ret = false; } } else { throw new SSSException(ErrorFactory::ERR_DB_EXECUTE); } return $ret; }
public function addUser(User $user) { if (!($user->getType() == 'P' || $user->getType() == 'O')) { throw new SSSException(ErrorFactory::ERR_WRONG_USER_TYPE); } $userMod = new UserModel(); try { $userFound = $userMod->add($user); if ($userFound === FALSE) { throw new SSSException(ErrorFactory::ERR_DB_INVALID_RESULT); } $ret['result'] = "success"; $ret['data']['user_id'] = $userFound; return $ret; } catch (SSSException $e) { return $e->getError(); } }
public function checkWebAdminLogin(User $user) { if ($user->getType() != 'A') { return ErrorFactory::getError(ErrorFactory::LOGIN_FAIL_INVALID_USER); } //Check User Login $userMod = new UserModel(); $userFound = $userMod->login($user); //Login Fail if (!$userFound) { return ErrorFactory::getError(ErrorFactory::LOGIN_FAIL_INVALID_USER); } $user->setId($userFound); $ret['result'] = "success"; $ret['data']['user_id'] = $user->getId(); session_start(); $_SESSION['userId'] = $userFound; $_SESSION['userName'] = $user->getName(); $_SESSION['loginDt'] = new \DateTime(); return $ret; }