function reopen() { //update user table to set submit_date to $current_datetime $myuserController = new UserController(); $myuserController->unSealUser(); $this->f3->reroute('@home'); }
public function actionProfile() { $id = Yii::app()->user->id; if (!isset($_SESSION['filemanager'])) { $_SESSION['filemanager'] = true; } $_SESSION['currentFolder'] = 'user/'; $model = $this->loadModel($id); $modelProfile = UserProfile::model()->exists('userid=' . $id) ? UserProfile::model()->findByPk($id) : new UserProfile(); $role = Yii::app()->request->getPost('role'); $postUser = Yii::app()->request->getPost('User'); $postProfile = Yii::app()->request->getPost('UserProfile'); if (isset($postUser) && isset($postProfile)) { Yii::import('application.modules.backend.controllers.UserController'); //do hàm contruct của UserController(extends controllers) lỗi ko cho phép null iduser nên thêm vào để ko xảy ra lỗi này //mục đích là dùng dc hàm saveUserInfo trong UserController nên ko ảnh hưởng gì $UserControllerTemp = new UserController(2); if ($UserControllerTemp->saveUserInfo($model, $modelProfile, $postUser, $postProfile, $role, false)) { Yii::app()->user->setFlash('success', Yii::t('user', 'Update user\'s info successfully.')); } else { Yii::app()->user->setFlash('error', Yii::t('user', 'Update user\'s info fail. Please try it later.')); } } $this->render('profile', array('model' => $model, 'modelProfile' => $modelProfile, 'role' => User::model()->getRoleUser($model->id))); }
function showAuditorProjects($info = "") { $userId = isLoggedIn(); if (isAdmin()) { $sql = "select ap.*,w.name,u.username from websites w,users u,auditorprojects ap where ap.website_id=w.id and u.id=w.user_id"; $sql .= empty($info['userid']) ? "" : " and w.user_id=" . $info['userid']; $sql .= " order by ap.score DESC,ap.id"; $this->set('isAdmin', 1); $userCtrler = new UserController(); $userList = $userCtrler->__getAllUsers(); $this->set('userList', $userList); } else { $sql = "select w.name,ap.* from websites w, auditorprojects ap where ap.website_id=w.id and user_id={$userId} order by ap.id"; } $this->set('userId', empty($info['userid']) ? 0 : $info['userid']); # pagination setup $this->db->query($sql, true); $this->paging->setDivClass('pagingdiv'); $this->paging->loadPaging($this->db->noRows, SP_PAGINGNO); $pagingDiv = $this->paging->printPages('siteauditor.php?userid=' . $info['userid']); $this->set('pagingDiv', $pagingDiv); $sql .= " limit " . $this->paging->start . "," . $this->paging->per_page; $projectList = $this->db->select($sql); foreach ($projectList as $i => $projectInfo) { $projectList[$i]['total_links'] = $this->getCountcrawledLinks($projectInfo['id']); $projectList[$i]['crawled_links'] = $this->getCountcrawledLinks($projectInfo['id'], true); $projectList[$i]['last_updated'] = $this->getProjectLastUpdate($projectInfo['id']); } $this->set('pageNo', $info['pageno']); $this->set('list', $projectList); $this->render('siteauditor/list'); }
function process() { if ($this->_input->post("Login")) { $userName = $this->_input->post('user_name'); $passwd = md5($this->_input->post('passwd')); $this->_template->set_var("user_name", $userName); $checkArray = array('user_name' => 'Username', 'passwd' => 'Password'); if ($this->_jScript->checkFilds($checkArray)) { $userCtrl = new UserController(); $userEnt = $userCtrl->loginUser($userName, $passwd); if (is_object($userEnt)) { $userObj = $userCtrl->createUser($userEnt); $_SESSION['REGI_userObject'] = serialize($userObj); $sessionObj = unserialize($_SESSION['REGI_userObject']); if (is_object($sessionObj)) { if ($sessionObj->getActive() == 0) { $this->redirect('UserActivate'); } else { $this->redirect('Radio'); } } } else { $this->_jScript->alert("Ingevoerde gebruikersnaam en/of wachtwoord is/zijn niet correct!"); } } } $this->_template->parse($this->_outputName, $this->_mainBlock); }
public function __invoke($controller_services) { $services = $controller_services->getServiceLocator(); $authentication = $services->get('session_authentication'); $loginForm = $services->get('DotUser\\Form\\LoginForm'); $controller = new UserController($authentication); $controller->setLoginForm($loginForm); return $controller; }
/** * Tests if the user Login page is OK * * @return void */ public function testUserLoginContainsEmailField() { $UserController = new UserController(); $login_form = $UserController->show_login(); $contains_email_field = false; if (strpos($login_form, '<input type="text" name="email" class="form-control" placeholder="E-Mail"/>') !== false) { $contains_email_field == true; } $this->assertTrue($contains_email_field); }
static function run() { $r = new Request(); $r->parse(); $controller = $r->controller . 'Controller'; $action = $r->action; if (class_exists($controller)) { $obj = new $controller($r); $obj->render(); } else { // do default stuff; $obj = new UserController(new Request()); $obj->render(); } }
/** * Updates password in database * @return ErrorResponse|Response */ protected function update() { $missing_fields = UserController::validateJSONFormat($this->body, User::REQUIRED_PASSWORD_PUT_FIELD); // Check that required fields are not missing if (!$missing_fields) { $mapper = new UserDBMapper(); $json = $this->body; $user = User::fromResetPasswordQuery($this->id, $json); // If user is set if ($user) { $db_response = $mapper->resetPassword($user); if ($db_response instanceof DBError) { $response = new ErrorResponse($db_response); } else { $user = $mapper->getById($this->id); if ($user) { $response = new Response(json_encode($user->toArray(), JSON_PRETTY_PRINT), Response::STATUS_CODE_CREATED); } else { $response = new ErrorResponse(new NotFoundError()); } return $response; } } else { $response = new ErrorResponse(new ApplicationError("Reset password error", "There was a problem with the password")); } } else { $response = new ErrorResponse(new MalformedJSONFormatError($missing_fields)); } return $response; }
/** * @param $json * @param $email_type * @return ErrorResponse|null|Response */ public static function setNewPassword($json, $email_type) { $response = null; $missing_fields = UserController::validateJSONFormat($json, User::REQUIRED_PASSWORD_RESET_FIELD); // Check that required fields are not missing if (!$missing_fields) { $user_mapper = new UserDBMapper(); $email = $json['email']; $user = User::fromDBArray($user_mapper->getByEmail($email)); // Set random password $password = ResetPasswordController::getRandomString(ResetPasswordController::PASSWORD_LENGTH); $json['password'] = $password; $id = $user->getId(); $reset_password_user = User::fromResetPasswordQuery($id, $json); if ($reset_password_user) { $db_response = $user_mapper->resetPassword($reset_password_user); if ($db_response instanceof DBError) { $response = new ErrorResponse($db_response); } else { $reset_password_user = $user_mapper->getById($id); if ($reset_password_user) { EmailSender::sendEmail($email, $password, $email_type); // Sending Email notification $response = new Response(json_encode(array('message' => ResetPasswordController::RESET_PASSWORD_ACCEPTED_MESSAGE), JSON_PRETTY_PRINT), Response::STATUS_CODE_ACCEPTED); } else { $response = new ErrorResponse(new NotFoundError()); } } } return $response; } return new Response($response); }
public function init() { parent::init(); $this->addModel = "CatalogFirmsAdd"; $this->tableName = "catalog_firms"; $this->name = Yii::t("user", "фирмы"); }
public static function run() { if ($_SERVER["REQUEST_METHOD"] == "POST") { $webuser = new WebUser($_POST); if ($webuser->getErrorCount() == 0) { if (!empty(WebUserDB::getUsersBy('hockName', $webuser->getHockName()))) { $webuser->setError('hockName', 'HOCKUSER_NAMECLAIMED'); SignupView::show($webuser); } else { //create a webuser in db $id = WebUserDB::addUser($webuser); if ($id != 0) { $base = array_key_exists('base', $_SESSION) ? $_SESSION['base'] : ""; //find the hockuser related to this dude //$hockusers = HockUserDB::getUsersBy('name', $webuser->getHockName()); header("Location: /" . $base . "/user/show/" . $webuser->getHockName()); UserController::show(); //ProfileView::show($webuser, $hockusers[0]);//HomeView::show(); } else { $webuser->setError('userName', 'DBERROR_ADDWEBUSER'); SignupView::show($webuser); } } } else { SignupView::show($webuser); } } else { // Initial link SignupView::show(null); } }
public function init() { parent::init(); $this->addModel = "CatalogHotelsAdd"; $this->tableName = "catalog_hotels"; $this->name = Yii::t("user", "отели"); }
/** * Create a new Enrollment instance. * * @param int $idCourse * @param int $idUser * @return int $idEnrollment */ public static function enroll($idCourse, $idUser, $end_at = Null) { $app = \Slim\Slim::getInstance(); $user = UserController::findUser($idUser); $course = CourseController::getCourseDetails($idCourse); if ($end_at && date('Y-m-d H:i:s') > $end_at) { $app->halt("400", json_encode("Enrollment already expired. Please check the end date.")); } $data = array('user_id' => $idUser, 'course_id' => $idCourse); $enrollment = Enrollment::firstOrNew($data); // if there is scorm cloud id then enroll in scorm cloud if (isset($course->scorm_id)) { $scormRegistrationId = ScormCloudAPIController::register($idCourse, $idUser); if (isset($scormRegistrationId)) { $enrollment->scorm_registration_id = $scormRegistrationId; $enrollment->scorm_status = "enrolled"; } } if (!$enrollment->id) { $enrollment->isSafety = $course->safety; $enrollment->end_at = $end_at; $enrollment->save(); } else { $enrollment->end_at = $end_at; //echo $enrollment->end_at; $enrollment->save(); } return $enrollment->id; }
public function testLogin() { // Turn off sending email on usere creation UserController::$sendEmailOnVerify = false; // Create a user $contestant = UserFactory::createUserWithoutVerify(); // Open index $this->open('/'); // Click in Iniciar Sesion $this->clickAndWait('link=Inicia sesion'); // Type login data $this->type('user', $contestant->getUsername()); $this->type('pass', $contestant->getPassword()); // Click inicia sesion $this->clickAndWait("//input[@value='Inicia sesion']"); // Wait for message $this->waitForElementPresent('//*[@id="content"]/div[2]/div'); $this->assertElementContainsText('//*[@id="content"]/div[2]/div', 'Your email is not verified yet. Please check your e-mail.'); // Go to verification page and wait for redirection to login page $this->open('/api/user/verifyemail/id/' . $contestant->getVerificationId()); $this->waitForElementPresent('//*[@id="content"]/div[2]/div[1]/h1'); // Type login data $this->type('user', $contestant->getUsername()); $this->type('pass', $contestant->getPassword()); // Click inicia sesion $this->clickAndWait("//input[@value='Inicia sesion']"); // Sanity check that we are logged in $this->waitForElementPresent('//*[@id="wrapper"]/div[1]/a'); $this->assertElementContainsText('//*[@id="wrapper"]/div[1]/a', $contestant->getUsername()); }
/** * Verifies that the user exists in the LDAP directory. */ public function load($ids = array(), $conditions = array()) { $users = parent::load($ids, $conditions); // Validate users against LDAP directory. foreach ($users as $uid => $drupal_user) { // Do not validate user/1, anonymous users, or blocked users. if ($uid == 1 || $uid == 0 || $drupal_user->status == 0) { continue; } // Try to load the user from LDAP. $ldap_user = SimpleLdapUser::singleton($drupal_user->name); // Check to see if the user should be kept. $result = array_filter(module_invoke_all('simple_ldap_user_should_delete_user', $drupal_user, $ldap_user)); foreach ($result as $res) { if ($res === TRUE) { $this->delete_single($drupal_user); $users[$uid] = NULL; continue; } } if (!$ldap_user->exists) { // Block the user if it does not exist in LDAP. $this->blockUser($drupal_user); } // Active Directory uses a bitmask to specify certain flags on an account, // including whether it is enabled. http://support.microsoft.com/kb/305144 if ($ldap_user->server->type == 'Active Directory') { if (isset($ldap_user->useraccountcontrol[0]) && (int) $ldap_user->useraccountcontrol[0] & 2) { $this->blockUser($drupal_user); } } } return $users; }
public function actionDescription($gallError = "") { $this->firmId = (int) Yii::app()->request->getParam("fid", 0); $id = (int) Yii::app()->request->getParam("id", 0); // Если не указан ID фирмы, то берем ID из описания тура if ($id > 0 && $this->firmId == 0) { $tourModel = CatalogTours::fetch($id); if ($tourModel->id > 0 && $tourModel->firm_id && $tourModel->firm_id->id > 0) { $this->firmId = $tourModel->firm_id->id; } } if ($this->firmId == 0) { die("id==0"); $this->redirect(SiteHelper::createUrl("/user/firms")); } $firmModel = CatalogFirms::fetch($this->firmId); if ($firmModel->id == 0) { die("id==not correct"); $this->redirect(SiteHelper::createUrl("/user/firms")); } parent::init(); $this->addModel = "CatalogToursAdd"; $this->tableName = "catalog_tours"; $this->name = Yii::t("user", "туры"); $_POST["CatalogToursAdd"]["firm_id"] = $this->firmId; $_POST["CatalogToursAdd"]["user_id"] = Yii::app()->user->getId(); parent::actionDescription(); }
public function run() { $form = new AjaxRegisterAction_RegisterForm(); $form->name = $_REQUEST['popup_username']; $form->email = $_REQUEST['popup_email']; if ($form->validate()) { $user = new User(); $user->name = $form->name; $user->mail = $form->email; $user->type = User::TYPE_INDIVIDUAL; $user->created = time(); $user->status = User::STATUS_NOT_CONFIRMED; // Change password to a new one Yii::import('webroot.controllers.UserController'); $generatedPass = UserController::generatePassword(); $user->pass = md5($generatedPass); $user->save(false); // Mail the user if (Mailer::mailFastRegister($user, $generatedPass, $form->email)) { $result = array("result" => 0, "message" => Yii::t('amo', 'Email sent!!')); } else { $result = array("result" => -1, "message" => Yii::t('amo', 'Error sending email')); } } else { $errors = $form->getErrors('email'); $result = array("result" => -1, "message" => implode(", ", $errors)); } echo CJSON::encode($result); exit(0); // To avoid loggers append things to request }
/** * Basic update test */ public function testUserUpdate() { // Create the user to edit $user = UserFactory::createUser(); $r = new Request(); // Login $r["auth_token"] = $this->login($user); // Change values $r["name"] = Utils::CreateRandomString(); $r["country_id"] = 'MX'; $r["state_id"] = 3; $r["scholar_degree"] = 'Maestría'; $r["birth_date"] = strtotime('1988-01-01'); $r["graduation_date"] = strtotime('2016-02-02'); // Call api $response = UserController::apiUpdate($r); // Check user from db $user_db = AuthTokensDAO::getUserByToken($r["auth_token"]); $this->assertEquals($user_db->getName(), $r["name"]); $this->assertEquals($user_db->getCountryId(), $r["country_id"]); $this->assertEquals($user_db->getStateId(), $r["state_id"]); $this->assertEquals($user_db->getScholarDegree(), $r["scholar_degree"]); $this->assertEquals($user_db->getBirthDate(), gmdate('Y-m-d', $r["birth_date"])); $this->assertEquals($user_db->getGraduationDate(), gmdate('Y-m-d', $r["graduation_date"])); }
public function init() { parent::init(); $this->addModel = "CatalogKurortsAdd"; $this->tableName = "catalog_kurorts"; $this->name = Yii::t("user", "зоны отдыха/дачи"); }
public function run() { $form = new AjaxForgotAction_ForgotForm(); $form->email = $_REQUEST['popup_email']; if ($form->validate()) { $user = User::model()->find('mail=:mail', array(':mail' => $form->email)); if (isset($user)) { // Change password to a new one Yii::import('webroot.controllers.UserController'); $generatedPass = UserController::generatePassword(); $user->pass = md5($generatedPass); if ($user->save(false)) { // Mail the user if (Mailer::mailForgotPassword($generatedPass, $form->email)) { $result = array("result" => 0, "message" => Yii::t('amo', 'Email sent!!')); } else { $result = array("result" => -1, "message" => Yii::t('amo', 'Error sending email')); } } else { $result = array("result" => -1, "message" => Yii::t('amo', 'Could not save to database')); } } else { $result = array("result" => -1, "message" => Yii::t('amo', 'There is no user with such email')); } } else { $errors = $form->getErrors('email'); $result = array("result" => -1, "message" => implode(", ", $errors)); } echo CJSON::encode($result); exit(0); // To avoid loggers append things to request }
public function init() { parent::init(); $this->addModel = "CatalogFirmsItemsAdd2"; $this->tableName = "catalog_firms_items"; $this->name = Yii::t("user", "скидки и акции"); }
public function display_view($message) { // Grabs the URI and breaks it apart in case we have querystring stuff $request_uri = explode('?', $_SERVER['REQUEST_URI'], 2); //Root if ($request_uri[0] === '/public_html/') { if ($_SERVER['REQUEST_METHOD'] == 'GET') { require '../App/Views/goals.php'; } if ($_SERVER['REQUEST_METHOD'] == 'POST') { GoalController::add_goal(); } } //Goals if ($request_uri[0] === '/public_html/goals') { if ($_SERVER['REQUEST_METHOD'] == 'GET') { require '../App/Views/goals.php'; } if ($_SERVER['REQUEST_METHOD'] == 'POST') { GoalController::add_goal(); } } if ($request_uri[0] === '/public_html/goals/json') { if ($_SERVER['REQUEST_METHOD'] == 'GET') { header('Location: /public_html/json_goals.php'); } } if ($request_uri[0] === '/public_html/goal') { if ($_SERVER['REQUEST_METHOD'] == 'GET') { require '../App/Views/goal.php'; } if ($_SERVER['REQUEST_METHOD'] == 'POST') { GoalController::update_goal_by_id(); } } //Register if ($request_uri[0] === '/public_html/register') { if ($_SERVER['REQUEST_METHOD'] == 'GET') { require '../App/Views/register.php'; } if ($_SERVER['REQUEST_METHOD'] == 'POST') { UserController::add_user(); } } //Login if ($request_uri[0] === '/public_html/login') { if ($_SERVER['REQUEST_METHOD'] == 'GET') { require '../App/Views/login.php'; } if ($_SERVER['REQUEST_METHOD'] == 'POST') { AuthController::login_user(); } } if ($request_uri[0] === '/public_html/logout') { if ($_SERVER['REQUEST_METHOD'] == 'GET') { AuthController::logout_user(); } } }
public function testCoderOfTheMonthList() { $user = UserFactory::createUser(); $auth_token = $this->login($user); $r = new Request(array('auth_token' => $auth_token)); $response = UserController::apiCoderOfTheMonthList($r); $this->assertEquals(1, count($response['coders'])); }
public function testExistentUserWithInstance() { $builders = $this->buildData(); $this->simulateLogin('*****@*****.**'); $_GET['u'] = 'someuser1'; $_GET['n'] = 'twitter'; $_GET['i'] = 'instancetestuser'; $controller = new UserController(true); $this->assertTrue(isset($controller)); $results = $controller->control(); $this->assertPattern("/someuser1/", $results); //test if view variables were set correctly $v_mgr = $controller->getViewManager(); $this->assertEqual($v_mgr->getTemplateDataItem('controller_title'), 'User Details: someuser1'); $this->assertEqual($v_mgr->getTemplateDataItem('logo_link'), 'index.php'); $this->assertEqual($controller->getCacheKeyString(), 'user.index.tpl-me@example.com-someuser1-twitter-instancetestuser'); }
public function actionSignup() { if (isset($_POST['register'])) { if (trim($_POST['compName']) == "") { $_SESSION['compName'] = $_POST['compName']; $_SESSION['error'] = "Please provide your company or individual name"; header("location: {$_SERVER['HTTP_REFERER']}"); exit; } if (trim($_POST['password']) == "") { $_SESSION['error'] = "Password field cannot be blank!"; header("location: {$_SERVER['HTTP_REFERER']}"); exit; } if ($_POST['location'] == "") { $_SESSION['error'] = "Specify your location"; header("location: {$_SERVER['HTTP_REFERER']}"); exit; } if (trim($_POST['email']) == "" || filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) == false) { $_SESSION['email'] = $_POST['email']; $_SESSION['error'] = "The email you provided was invalid"; header("location: {$_SERVER['HTTP_REFERER']}"); exit; } if (!ctype_alnum($_POST['location'])) { $_SESSION['error'] = "Location is NOT sensible!"; header("location: {$_SERVER['HTTP_REFERER']}"); exit; } if (User::checker($_POST['email']) != 0) { $_SESSION['error'] = "Sorry, a user already exists with the email you provided. Forgot your password? <a href='#'>Get a new one</a>"; header("location: {$_SERVER['HTTP_REFERER']}"); exit; } if (trim($_POST['tel']) != "") { if (!isPhoneNumber($_POST['tel'])) { $_SESSION['tel'] = $_POST['tel']; $_SESSION['error'] = "Invalid phone number"; header("location: {$_SERVER['HTTP_REFERER']}"); exit; } } $x = new Employer($_POST); $x->utype = $this->user_type; if (!$x->create()) { //Log the next line and simply show an error message $_SESSION['error'] = "Oops! Something went wrong!"; } else { UserController::redirectToLogin("Account has been created. Please login to continue"); exit; } } $type = $this->user_type; //passed to the view for toggling include __VIEWPATH__ . "employer/signup.php"; }
public function testNoProblems() { $author = UserFactory::createUser(); // Call API // Call api $r = new Request(array("auth_token" => self::login($author))); $response = UserController::apiProblems($r); $this->assertEquals(0, count($response["problems"])); }
/** * @return RequestValidator */ public static function createUserFormValidator(StoreManagementController $controller, $user = false) { $inst = new UserController(ActiveRecordModel::getApplication()); $validator = $inst->getValidator("UserForm", $controller->getRequest()); $validator->addCheck('email', new IsNotEmptyCheck($controller->translate('_err_email_empty'))); $validator->addCheck('email', new IsValidEmailCheck($controller->translate('_err_invalid_email'))); $validator->addCheck('firstName', new IsNotEmptyCheck($controller->translate('_err_first_name_empty'))); $validator->addCheck('lastName', new IsNotEmptyCheck($controller->translate('_err_last_name_empty'))); $passwordLengthStart = 6; $passwordLengthEnd = 30; $allowEmpty = $user; $validator->addCheck('password', new IsLengthBetweenCheck(sprintf($controller->translate('_err_password_lenght_should_be_in_interval'), $passwordLengthStart, $passwordLengthEnd), $passwordLengthStart, $passwordLengthEnd, $allowEmpty)); $validator->addCheck('userGroupID', new IsNumericCheck($controller->translate('_err_invalid_group'))); if (!$user) { $user = ActiveRecordModel::getNewInstance('User'); } return $validator; }
/** * Tests apiRankByProblemsSolved for a specific user with no runs */ public function testUserRankByProblemsSolvedWith0Runs() { // Create a user and sumbit a run with him $contestant = UserFactory::createUser(); // Call API $response = UserController::apiRankByProblemsSolved(new Request(array('username' => $contestant->getUsername()))); $this->assertEquals($response['name'], $contestant->getName()); $this->assertEquals($response['problems_solved'], 0); $this->assertEquals($response['rank'], 0); }
private static function runApi() { try { //Reviews if (preg_match("/api\\/reviews\\/create/", self::$uri, $matches)) { $controller = new RestaurantController(); //TODO validate user //throw new FoodoException("Bad user key"); if (count($_POST) > 0 and isset($_POST['user_id']) and isset($_POST['restaurant_id']) and isset($_POST['review'])) { $controller->createReview($_POST['restaurant_id'], $_POST['user_id'], $_POST['review']); } else { throw new FoodoException("Data missing for review"); } } elseif (preg_match("/api\\/restaurant\\/id\\/([0-9]+)\\/reviews/", self::$uri, $matches)) { $controller = new RestaurantController(); $controller->showReviewsFromId($matches[1]); } elseif (preg_match("/api\\/restaurant\\/id\\/([0-9]+)\\/rate\\/([0-9].[0-9]|[0-9])\\/user_id\\/([0-9]+)/", self::$uri, $matches)) { $controller = new RestaurantController(); $controller->rateRestaurant($matches[1], number_format($matches[2], 1), $matches[3]); } elseif (preg_match("/api\\/restaurant\\/id\\/([0-9]+)/", self::$uri, $matches)) { $controller = new RestaurantController(); $controller->showFromId($matches[1]); } elseif (preg_match("/api\\/restaurant/", self::$uri, $matches)) { $controller = new RestaurantController(); $controller->showAll(); } elseif (preg_match("/api\\/user\\/login\\/(.*)\\/(.*)/", self::$uri, $matches)) { $controller = new UserController(); $controller->login($matches[1], $matches[2]); } elseif (preg_match("/api\\/user\\/signup\\/(.*)\\/(.*)\\/(.*)\\/(.*)/", self::$uri, $matches)) { $controller = new UserController(); $controller->signup($matches[1], $matches[2], $matches[3], $matches[4]); } elseif (preg_match("/api\\/types/", self::$uri, $matches)) { $controller = new RestaurantController(); $controller->showAllTypes(); } else { echo json_encode(array("responseData" => '', "responseDetails" => "Bad request", "responseCode" => 404)); } } catch (FoodoException $e) { echo json_encode(array("responseData" => "FoodoException", "responseDetails" => $e->getMessage(), "responseCode" => 500)); } catch (Exception $e) { echo json_encode(array("responseData" => 'Exception', "responseDetails" => $e->getMessage(), "responseCode" => 500)); } }
/** * @expectedException InvalidDatabaseOperationException */ public function testBadUserUpdate() { $user = UserFactory::createUser(); $r = new Request(); $r['auth_token'] = $this->login($user); $r['name'] = Utils::CreateRandomString(); // Invalid state_id $r['state_id'] = -1; UserController::apiUpdate($r); }