/** * Activate user data using user id. * * @access public * @param int $userId [User id] * @return bool */ public function activate($userId) { $this->_errorStack = Noobh_ErrorStackSingleton::getInstance(); try { if (!empty($userId)) { $userModel = new Models_User(); $result = $userModel->getUserBy($email = null, $userId); if (!empty($result)) { $status = $userModel->activate($userId); return $status; } else { throw new Exception($this->_errorList[602], 602); } } else { throw new Exception($this->_errorList[604], 604); } } 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 activateAction() { $response = array(); try { $request = $this->getRequest(); $params = $request->getParams(); if ($request->isPOST()) { if (!isset($params['email'])) { $response['error_code'] = 803; $response['error_message'] = $this->_errorList[803]; } else { $email = htmlspecialchars($params['email']); $user = new Models_User($email); if ($user->activate($user->getHash())) { $response['status'] = 'OK'; $response['error_code'] = 0; } else { $response['error_code'] = 820; $response['error_message'] = $this->_errorList[820]; } } } else { $response['error_code'] = 400; $response['error_message'] = 'Bad Request'; } } catch (Exception $ex) { $response['error_code'] = 820; $response['error_message'] = $this->_errorList[820]; } echo json_encode($response); exit; }