本文整理汇总了PHP中UserController类的典型用法代码示例。如果您正苦于以下问题:PHP UserController类的具体用法?PHP UserController怎么用?PHP UserController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserController类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reopen
function reopen()
{
//update user table to set submit_date to $current_datetime
$myuserController = new UserController();
$myuserController->unSealUser();
$this->f3->reroute('@home');
}
示例2: actionProfile
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)));
}
示例3: showAuditorProjects
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');
}
示例4: process
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);
}
示例5: __invoke
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;
}
示例6: testUserLoginContainsEmailField
/**
* 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);
}
示例7: run
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();
}
}
示例8: update
/**
* 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;
}
示例9: setNewPassword
/**
* @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);
}
示例10: run
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);
}
}
示例11: enroll
/**
* 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;
}
示例12: testLogin
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());
}
示例13: run
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
}
示例14: testUserUpdate
/**
* 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"]));
}
示例15: run
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
}