本文整理汇总了PHP中UserModule类的典型用法代码示例。如果您正苦于以下问题:PHP UserModule类的具体用法?PHP UserModule怎么用?PHP UserModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
public function login()
{
//前端传来的参数用quickInput()获取,不管是GET还是POST的,框架会自动过滤数据
//$param = quickInput('userName');
//因为暂时没有前台和数据库,这里模拟一下就好了
$param = 'hello world';
$server = new UserModule();
echo $server->login($param);
}
示例2: actionSave
public function actionSave()
{
$id = $_POST['id'];
$ha = UserModule::model()->deleteAllByAttributes(array("user_level_id" => $id));
$q = $_POST['q'];
$arr = explode(";;", $q);
$num = 1;
foreach ($arr as $elem) {
$ha = new UserModule();
$ha->user_level_id = $id;
$ha->module_id = $elem;
$ha->save();
$num++;
}
}
示例3: actionConfirm
public function actionConfirm()
{
if (!isset($_GET['email']) && !isset($_GET['key'])) {
$this->redirect(array('index/index'));
}
switch (EmailVerification::model()->confirm($_GET['email'], $_GET['key'])) {
case EmailVerification::CONFIRM_ALREADY_ACTIVE:
echo UserModule::t('This email address has already been verified. Thank you!');
break;
case EmailVerification::CONFIRM_INVALID_KEY:
echo UserModule::t('The confirmation key is invalid!');
break;
case EmailVerification::CONFIRM_KEY_NOT_ACTIVE:
echo UserModule::t('This key is no longer active');
break;
case EmailVerification::CONFIRM_USER_BLOCKED:
echo UserModule::t('This account is currently blocked');
break;
case EmailVerification::CONFIRM_SUCCESS:
echo UserModule::t('This email is now verified. You can log in your account using this email. Thank you!');
break;
case EmailVerification::CONFIRM_ERROR:
default:
echo UserModule::t('Oops, an error has occurred! Please try again.');
}
}
示例4: authenticate
/**
* Authenticates the password.
* This is the 'authenticate' validator as declared in rules().
*/
public function authenticate($attribute, $params)
{
if (!$this->hasErrors()) {
$identity = new UserIdentity($this->username, $this->password);
$identity->authenticate();
switch ($identity->errorCode) {
case UserIdentity::ERROR_NONE:
$duration = $this->rememberMe ? 3600 * 24 * 30 : 0;
// 30 days
Yii::app()->user->login($identity, $duration);
break;
case UserIdentity::ERROR_EMAIL_INVALID:
$this->addError("username", UserModule::t("Email is incorrect."));
break;
case UserIdentity::ERROR_USERNAME_INVALID:
$this->addError("username", UserModule::t("Username is incorrect. Please make sure you are using the secondary login details provided in your email"));
break;
case UserIdentity::ERROR_STATUS_NOTACTIV:
$this->addError("status", UserModule::t("You account is not activated."));
break;
case UserIdentity::ERROR_STATUS_BAN:
$this->addError("status", UserModule::t("You account is blocked."));
break;
case UserIdentity::ERROR_PASSWORD_INVALID:
$this->addError("password", UserModule::t("Password is incorrect."));
break;
case UserIdentity::ERROR_SERVER_ERROR:
$this->addError("status", UserModule::t("There is a server error. Please contact support"));
break;
default:
$this->addError("status", UserModule::t("KUCH TO GADABAD HAI"));
break;
}
}
}
示例5: actionIndex
public function actionIndex()
{
// Kiểm tra nếu đăng nhập rồi chuyển trang
if (!Yii::app()->user->isGuest) {
if (strpos(Yii::app()->user->returnUrl, '/index.php') !== false) {
$this->redirect("/user/profile");
} else {
$this->redirect(Yii::app()->user->returnUrl);
}
}
$model = new LoginForm();
// if it is ajax validation request
if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
// collect user input data
if (isset($_POST['LoginForm'])) {
$model->attributes = $_POST['LoginForm'];
// validate user input and redirect to the previous page if valid
if ($model->validate() && $model->login()) {
$this->setRedirectOptions(array("title" => UserModule::t('Login Success'), "message" => UserModule::t('The login was successful!')));
if (strpos(Yii::app()->user->returnUrl, '/index.php') !== false) {
$this->redirect("/user/profile");
} else {
$this->redirect(Yii::app()->user->returnUrl);
}
}
}
$this->render('index', array('model' => $model));
}
示例6: actionChangepassword
/**
* Change password
*/
public function actionChangepassword()
{
$model = new UserChangePassword();
if (Yii::app()->user->id) {
// ajax validator
if (isset($_POST['ajax']) && $_POST['ajax'] === 'changepassword-form') {
echo UActiveForm::validate($model);
Yii::app()->end();
}
if (isset($_POST['UserChangePassword'])) {
$model->attributes = $_POST['UserChangePassword'];
if ($model->validate()) {
$new_password = User::model()->notsafe()->findbyPk(Yii::app()->user->id);
$new_password->password = UserModule::encrypting($model->password);
$new_password->activkey = UserModule::encrypting(microtime() . $model->password);
$new_password->save();
///ALSO SAVE PASS oN SERVER
$u = User::model()->findByAttributes(array('password' => $new_password->password));
$rm_msg = $model->remoteupdatepass($u->email, $new_password->password);
Yii::app()->user->setFlash('profileMessage', UserModule::t("New password is saved " . $rm_msg));
$this->redirect(array("profile"));
}
}
$this->render('changepassword', array('model' => $model));
}
}
示例7: authenticate
/**
* Authenticates the password.
* This is the 'authenticate' validator as declared in rules().
* returning true false does not stops proceeding to action. to stop add error to attribute.
*/
public function authenticate($attribute, $params)
{
if (!$this->hasErrors()) {
$this->_identity = new UserIdentity($this->username, $this->password);
$this->_identity->authenticate();
switch ($this->_identity->errorCode) {
case UserIdentity::ERROR_NONE:
$duration = $this->rememberMe ? Yii::app()->controller->module->rememberMeTime : 0;
Yii::app()->user->login($this->_identity, $duration);
AppCommon::mergeCookieAndDbCart();
//on login merge the db and cookie carts
break;
case UserIdentity::ERROR_EMAIL_INVALID:
$this->addError("username", UserModule::t("Email is incorrect."));
break;
case UserIdentity::ERROR_STATUS_NOTACTIV:
$this->addError("username", UserModule::t("You account is not activated."));
break;
case UserIdentity::ERROR_STATUS_BAN:
$this->addError("username", UserModule::t("You account is blocked."));
break;
case UserIdentity::ERROR_PASSWORD_INVALID:
$this->addError("password", UserModule::t("Password is incorrect."));
break;
}
if ($this->_identity->errorCode === UserIdentity::ERROR_NONE) {
return true;
} else {
return false;
}
}
}
示例8: actionActivation
/**
* Activation user account
*/
public function actionActivation()
{
$email = $_GET['email'];
$activkey = $_GET['activkey'];
if ($email && $activkey) {
$find = User::model()->notsafe()->findByAttributes(array('email' => $email));
if (isset($find) && $find->status) {
$this->autoLogin($find->username);
// update user_id in invite table
Invite::model()->updateNewUser($find);
// account already active
Yii::app()->user->setFlash('success', 'Congratulations! Your account is now active. Please follow the directions below to set up your location.');
$this->redirect('/userlocation/locate');
// $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("Your account is active.")));
} elseif (isset($find->activkey) && $find->activkey == $activkey) {
$find->activkey = UserModule::encrypting(microtime());
$find->status = 1;
$find->save();
$this->autoLogin($find->username);
// direct to autolocate with activation message
Yii::app()->user->setFlash('success', 'Congratulations! Your account is now active. Please follow the directions below to set up your location.');
$this->redirect('/userlocation/locate');
// $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("Your account is activated.")));
} else {
$this->render('/user/message', array('title' => UserModule::t("User activation"), 'content' => UserModule::t("Incorrect activation URL. Please email support@geogram.com if you need assistance.")));
}
} else {
$this->render('/user/message', array('title' => UserModule::t("User activation"), 'content' => UserModule::t("Incorrect activation URL. Please email support@geogram.com if you need assistance.")));
}
}
示例9: authenticate
/**
* Authenticates the password.
* This is the 'authenticate' validator as declared in rules().
*/
public function authenticate($attribute, $params)
{
if (!$this->hasErrors()) {
$identity = new UserIdentity($this->username, $this->password);
$identity->authenticate();
switch ($identity->errorCode) {
case UserIdentity::ERROR_NONE:
$duration = $this->rememberMe ? Yii::app()->controller->module->rememberMeTime : 0;
Yii::app()->user->login($identity, $duration);
break;
case UserIdentity::ERROR_EMAIL_INVALID:
$this->addError("username", UserModule::t("Correo incorrecto"));
break;
case UserIdentity::ERROR_USERNAME_INVALID:
$this->addError("username", UserModule::t("Nombre de usuario incorrecto"));
break;
case UserIdentity::ERROR_STATUS_NOTACTIV:
$this->addError("status", UserModule::t("Su cuenta no está activada"));
break;
case UserIdentity::ERROR_STATUS_BAN:
$this->addError("status", UserModule::t("Su cuenta ha sido blockeada"));
break;
case UserIdentity::ERROR_PASSWORD_INVALID:
$this->addError("password", UserModule::t("Contraseña incorrecta"));
break;
}
}
}
示例10: getDefaultPicture
/**
* Gets the default profile picture for a specifc user.
* @param string $userId The Id of the user to get profile picture. If this is empty, the current user's avatar will be returned.
* @param string $type The type of picture to return (original, thumb.profile, thumb.feed, thumb.icon)
* @return array The picture info (path, alt, title, width, height)
*/
public static function getDefaultPicture($userId = '', $type = 'original')
{
if (empty($userId)) {
$userId = Yii::app()->user->getId();
if (empty($userId)) {
return null;
}
}
// Detect user's gender to decide which avatar should be chosen
$gender = Profile::model()->getFieldInfo($userId, User::PREFIX, 'gender');
if ($gender['value'] === 'male') {
$info['path'] = Yii::app()->getBaseUrl(true) . '/files/images/default-avatar-male.jpg';
} else {
$info['path'] = Yii::app()->getBaseUrl(true) . '/files/images/default-avatar-female.jpg';
}
// Alt and title
$info['alt'] = $info['title'] = UserModule::t('Default Avatar');
// Get size
//Yii::app()->getModule('system'); // Get module 'system'
$photoTypes = Setting::model()->get('photo_types', array('value'));
/*var_dump($photoTypes->value);
var_dump($photoTypes['value']); die;*/
$photoTypes = json_decode($photoTypes['value'], true);
// true indicates that the object will be converted to associative arrays
if (!isset($photoTypes[$type])) {
$info['width'] = 160;
$info['height'] = 160;
} else {
$info['width'] = $photoTypes[$type]['width'];
$info['height'] = $photoTypes[$type]['height'];
}
return $info;
}
示例11: authenticate
/**
* Authenticates the user's credentials.
* @return true|false
*/
public function authenticate($attribute, $params)
{
// Ensure the input to be authenticated is valid.
if (!$this->hasErrors()) {
$identity = new UserIdentity($this->username, $this->password);
$identity->authenticate();
switch ($identity->errorCode) {
case UserIdentity::ERROR_NONE:
//$duration = $this->rememberMe ? 3600 * 24 * 30 : 0;
$duration = 0;
Yii::app()->user->login($identity, $duration);
return true;
case UserIdentity::ERROR_EMAIL_INVALID:
case UserIdentity::ERROR_USERNAME_INVALID:
case UserIdentity::ERROR_PASSWORD_INVALID:
Yii::trace('Error codeeee: ' . $identity->errorCode, 'system.db.ar.CActiveRecord');
$this->addError('username', UserModule::t('Incorrect username or password.'));
return false;
case UserIdentity::ERROR_STATUS_NOTACTIVE:
$this->addError('active', UserModule::t('Your account is not activated yet. Make sure you confirm your email address before logging in.'));
return false;
case UserIdentity::ERROR_STATUS_BLOCKED:
$this->addError('blocked', UserModule::t('Your account is blocked.'));
return false;
}
}
}
示例12: actionChangepassword
/**
* Change password
*/
public function actionChangepassword() {
$model = new UserChangePassword;
if (Yii::app()->user->id) {
// ajax validator
if(isset($_POST['ajax']) && $_POST['ajax']==='changepassword-form')
{
echo UActiveForm::validate($model);
Yii::app()->end();
}
if(isset($_POST['UserChangePassword'])) {
$model->attributes=$_POST['UserChangePassword'];
if($model->validate()) {
$new_password = User::model()->notsafe()->findbyPk(Yii::app()->user->id);
$new_password->password = UserModule::encrypting($model->password);
$new_password->activkey=UserModule::encrypting(microtime().$model->password);
$new_password->save();
Yii::app()->user->setFlash('success',UserModule::t("New password is saved."));
$this->redirect(array("profile"));
}
}
$this->render('changepassword',array('model'=>$model));
}
}
示例13: actionActivation
/**
* Activation user account
*/
public function actionActivation()
{
$email = $_GET['email'];
$activkey = $_GET['activkey'];
$view = '/user/message';
if (isset($this->location)) {
$view = 'frontend.views.user.message';
}
if ($email && $activkey) {
$find = User::model()->notsafe()->findByAttributes(array('email' => $email));
if (isset($find) && $find->status) {
$this->render($view, array('title' => UserModule::t("User activation"), 'content' => UserModule::t("Your account is active.")));
} elseif (isset($find->activkey) && $find->activkey == $activkey) {
$find->activkey = PasswordHelper::hashPassword(microtime());
$find->status = 1;
$find->save();
//$this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("You account is activated.")));
Yii::app()->user->setFlash('activateMessage', UserModule::t("Your account has been activated."));
$this->redirect(Yii::app()->controller->module->loginUrl);
} else {
$this->render($view, array('title' => UserModule::t("User activation"), 'content' => UserModule::t("Incorrect activation URL.")));
}
} else {
$this->render($view, array('title' => UserModule::t("User activation"), 'content' => UserModule::t("Incorrect activation URL.")));
}
}
示例14: actionChangepassword
/**
* Change password
*/
public function actionChangepassword()
{
$model = new UserChangePassword();
if (Yii::app()->user->id) {
//$phis = new PasswordHistory();
//$passes = $phis->getHistory(Yii::app()->user->id);
//CVarDumper::dump($passes);
// ajax validator
if (isset($_POST['ajax']) && $_POST['ajax'] === 'changepassword-form') {
echo UActiveForm::validate($model);
Yii::app()->end();
}
if (isset($_POST['UserChangePassword'])) {
$model->attributes = $_POST['UserChangePassword'];
if ($model->validate()) {
$new_password = User::model()->notsafe()->findbyPk(Yii::app()->user->id);
$new_password->password = PasswordHelper::hashPassword($model->password);
$new_password->activkey = PasswordHelper::hashPassword(microtime() . $model->password);
$new_password->password_update_time = date('Y-m-d H:i:s');
$new_password->save();
$passwordHistory = new PasswordHistory();
$passwordHistory->profile_id = $new_password->id;
$passwordHistory->password = $new_password->password;
$passwordHistory->save();
Yii::app()->user->setFlash('profileMessage', UserModule::t("New password is saved."));
$this->redirect(array("profile"));
}
}
if (isset($this->location)) {
$this->render('frontend.views.profile.changepassword', array('model' => $model));
} else {
$this->render('changepassword', array('model' => $model));
}
}
}
示例15: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new User();
$profile = new Profile();
$this->performAjaxValidation(array($model, $profile));
if (isset($_POST['User'])) {
$model->attributes = $_POST['User'];
$password = $_POST['User']['password'];
$model->activkey = Yii::app()->controller->module->encrypting(microtime() . $model->password);
$profile->attributes = $_POST['Profile'];
$profile->user_id = 0;
if ($model->validate() && $profile->validate()) {
$model->password = Yii::app()->controller->module->encrypting($model->password);
if ($model->save()) {
//send mail
UserModule::sendMail($model->email, UserModule::t("You are registered from {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("Please login to your account with your email id as username and password {password}", array('{password}' => $password)));
$profile->user_id = $model->id;
$profile->save();
}
$this->redirect(array('/rights/assignment/user', 'id' => $model->id));
} else {
$profile->validate();
}
}
$this->render('create', array('model' => $model, 'profile' => $profile));
}