public function checkexists($attribute, $params) { if (!$this->hasErrors()) { $value = (string) $this->login_or_email; if (strpos($this->login_or_email, "@")) { // $user = User::model()->findByAttributes(array('email' => $this->login_or_email)); $user = User::model()->find(array('condition' => 'LOWER(email)=:email', 'params' => array(':email' => MHelper::String()->toLower($value)))); if ($user) { $this->user_id = $user->id; } } else { // $user = User::model()->findByAttributes(array('username' => $this->login_or_email)); $user = User::model()->find(array('condition' => 'LOWER(username)=:username', 'params' => array(':username' => MHelper::String()->toLower($value)))); if ($user) { $this->user_id = $user->id; } } if ($user === null) { if (strpos($value, "@")) { $this->addError("login_or_email", UsersModule::t("Email is incorrect.")); } else { $this->addError("login_or_email", UsersModule::t("Username is incorrect.")); } } } }
/** * Registration user */ public function actionRegistration() { $this->layout = '//layouts/login'; $model = new RegistrationForm(); // ajax validator if (isset($_POST['ajax']) && $_POST['ajax'] === 'signup-form_id') { /* echo UActiveForm::validate($model); Yii::app()->end(); */ $errors = CActiveForm::validate($model); echo $errors; Yii::app()->end(); } if (Yii::app()->user->id) { $this->redirect('/'); } else { $this->redirect('/login'); if (isset($_POST['RegistrationForm'])) { $model->attributes = $_POST['RegistrationForm']; $model->verifyPassword = $model->password; if ($model->validate()) { $soucePassword = $model->password; $model->activkey = UsersModule::encrypting(microtime() . $model->password); $model->password = UsersModule::encrypting($model->password); $model->verifyPassword = UsersModule::encrypting($model->verifyPassword); $model->status = Yii::app()->getModule('users')->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE; if ($model->save()) { Yii::app()->queue->subscribe($model->id, null, "User.{$model->id}"); if (Yii::app()->getModule('users')->sendActivationMail) { $activation_url = $this->createAbsoluteUrl('/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email)); UsersModule::sendMail($model->email, UsersModule::t("You registered from {site_name}", array('{site_name}' => Yii::app()->name)), UsersModule::t("Please activate you account go to {activation_url}", array('{activation_url}' => $activation_url))); } // wellcome email $subject = Yii::t('email', 'Welcome'); $message = Yii::t('email', 'Welcome to <a href="{url}">{catalog}</a>.', array('{url}' => $this->createAbsoluteUrl('/'), '{catalog}' => Yii::app()->name)); SendMail::send($model->email, $subject, $message, true); if ((Yii::app()->getModule('users')->loginNotActiv || Yii::app()->getModule('users')->activeAfterRegister && Yii::app()->getModule('users')->sendActivationMail == false) && Yii::app()->getModule('users')->autoLogin) { $identity = new UserIdentity($model->username, $soucePassword); $identity->authenticate(); Yii::app()->user->login($identity, 0); $this->redirect(Yii::app()->getModule('users')->returnUrl); } else { if (!Yii::app()->getModule('users')->activeAfterRegister && !Yii::app()->getModule('users')->sendActivationMail) { Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Contact Admin to activate your account.")); } elseif (Yii::app()->getModule('users')->activeAfterRegister && Yii::app()->getModule('users')->sendActivationMail == false) { Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Please {{login}}.", array('{{login}}' => CHtml::link(UsersModule::t('Login'), Yii::app()->getModule('users')->loginUrl)))); } elseif (Yii::app()->getModule('users')->loginNotActiv) { Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Please check your email or login.")); } else { Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Please check your email.")); } $this->refresh(); } } } else { // var_dump($model->errors);die(); } } $this->render('/user/registration', array('model' => $model)); } }
/** * 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()->getModule('users')->rememberMeTime : 0; Yii::app()->user->login($identity, $duration); break; case UserIdentity::ERROR_EMAIL_INVALID: $this->addError("username", UsersModule::t("Email is incorrect.")); break; case UserIdentity::ERROR_USERNAME_INVALID: $this->addError("username", UsersModule::t("Username is incorrect.")); break; case UserIdentity::ERROR_STATUS_NOTACTIV: $this->addError("status", UsersModule::t("Your account is not activated.")); break; case UserIdentity::ERROR_PASSWORD_INVALID: $this->addError("password", UsersModule::t("Password is incorrect.")); break; } } }
/** * @param $value * @return string */ public function editAttribute($model, $field, $params = array()) { if (!isset($params['options'])) { $params['options'] = array(); } $options = $params['options']; unset($params['options']); return CHtml::activeFileField($model, $field->varname, $params) . ($model->getAttribute($field->varname) ? '<br/>' . CHtml::activeCheckBox($model, '[uwfdel]' . $field->varname, $params) . ' ' . CHtml::activeLabelEx($model, '[uwfdel]' . $field->varname, array('label' => UsersModule::t('Delete file'), 'style' => 'display:inline;')) : ''); }
public function __RuleChecker($RuleID) { $this->__LoadModules('/Modules/class.UsersModule.php'); $Users = new UsersModule(); $UserID = $Users->Session('UserID'); if (!$UserID) { if (!$this->Config['NotLoginIsAlertMessage']) { header('Location: ' . $this->Config['NotAccessURL'] . '&RedirectURL=' . urlencode($_SERVER['REQUEST_URI'])); } else { return false; } } else { if ($RuleID) { return $Users->CheckRole($RuleID, $UserID); } else { return true; } } }
public function filters() { $filters = parent::filters(); foreach ($filters as $key => $filter) { if (is_array($filter) && isset($filter[0]) && $filter[0] == self::getRightsFilterPath() && isset($filter['moduleClassName']) && $filter['moduleClassName'] == 'UsersModule' && isset($filter['rightName']) && $filter['rightName'] == UsersModule::getAccessRight()) { $filters[$key][0] = $filters[$key][0] . ' - getAuthenticatedUser, searchUsersByEmails'; } } return $filters; }
/** * Specifies the access control rules. * This method is used by the 'accessControl' filter. * @return array access control rules */ public function accessRules() { return array( array('allow', // allow admin user to perform 'admin' and 'delete' actions 'actions'=>array('admin','delete','create','update','view'), 'users'=>UsersModule::getAdmins(), ), array('deny', // deny all users 'users'=>array('*'), ), ); }
public function rules() { $rules = array( array('username, password, verifyPassword, email', 'required'), array('username', 'length', 'max'=>20, 'min' => 3,'message' => Users::t("Incorrect username (length between 2 and 20 characters).")), array('password', 'length', 'max'=>128, 'min' => 4,'message' => Users::t("Incorrect password (minimal length 4 symbols).")), array('email', 'email'), array('username', 'unique', 'message' => Users::t("This user's name already exists.")), array('email', 'unique', 'message' => Users::t("This user's email address already exists.")), array('verifyPassword', 'compare', 'compareAttribute'=>'password', 'message' => Users::t("Retype Password is incorrect.")), array('username', 'match', 'pattern' => '/^[A-Za-z0-9_]+$/u','message' => Users::t("Incorrect symbols (A-z0-9).")), ); if (isset($_POST['ajax']) && $_POST['ajax']==='registration-form') return $rules; else array_push($rules,array('verifyCode', 'captcha', 'allowEmpty'=>!UsersModule::doCaptcha('registration'))); return $rules; }
/** * 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->render('/user/message', array('title' => UsersModule::t("User activation"), 'content' => UsersModule::t("Your account is active."))); } elseif (isset($find->activkey) && $find->activkey == $activkey) { $find->activkey = UsersModule::encrypting(microtime()); $find->status = 1; $find->save(); $this->render('/user/message', array('title' => UsersModule::t("User activation"), 'content' => UsersModule::t("Your account is activated."))); } else { $this->render('/user/message', array('title' => UsersModule::t("User activation"), 'content' => UsersModule::t("Incorrect activation URL."))); } } else { $this->render('/user/message', array('title' => UsersModule::t("User activation"), 'content' => UsersModule::t("Incorrect activation URL."))); } }
/** * Widget initialization * @return array */ public function init() { return array('name' => __CLASS__, 'label' => UsersModule::t('jQueryUI autocomplete', array(), __CLASS__), 'fieldType' => array('INTEGER'), 'params' => $this->params, 'paramsLabels' => array('modelName' => UsersModule::t('Model Name', array(), __CLASS__), 'optionName' => UsersModule::t('Lable field name', array(), __CLASS__), 'emptyFieldLabel' => UsersModule::t('Empty item name', array(), __CLASS__), 'emptyFieldValue' => UsersModule::t('Empty item value', array(), __CLASS__), 'relationName' => UsersModule::t('Profile model relation name', array(), __CLASS__), 'minLength' => UsersModule::t('minimal start research length', array(), __CLASS__))); }
<?php /** @var BootActiveForm $form */ $form2 = $this->beginWidget('CActiveForm', array('id' => 'recovery-form')); ?> <?php echo $form2->errorSummary($form); ?> <?php echo $form2->textField($form, 'login_or_email', array('hint' => UsersModule::t("Please enter your login or email addres."))); ?> <div class="control-group"> <div class="controls"> <?php echo CHtml::submitButton(UsersModule::t("Restore"), array('class' => 'btn')); ?> </div> </div> <?php $this->endWidget(); ?> </div><!-- form --> <?php } ?>
public function testPolicyComparisons() { $this->assertEquals(Policy::NO, UsersModule::getStrongerPolicy(UsersModule::POLICY_ENFORCE_STRONG_PASSWORDS, array(Policy::NO, Policy::NO))); $this->assertEquals(Policy::YES, UsersModule::getStrongerPolicy(UsersModule::POLICY_ENFORCE_STRONG_PASSWORDS, array(Policy::YES, Policy::NO))); $this->assertEquals(Policy::YES, UsersModule::getStrongerPolicy(UsersModule::POLICY_ENFORCE_STRONG_PASSWORDS, array(Policy::NO, Policy::YES))); $this->assertEquals(Policy::YES, UsersModule::getStrongerPolicy(UsersModule::POLICY_ENFORCE_STRONG_PASSWORDS, array(Policy::YES, Policy::YES))); $this->assertEquals(10, UsersModule::getStrongerPolicy(UsersModule::POLICY_MINIMUM_PASSWORD_LENGTH, array(10, 10))); $this->assertEquals(20, UsersModule::getStrongerPolicy(UsersModule::POLICY_MINIMUM_PASSWORD_LENGTH, array(10, 20))); $this->assertEquals(20, UsersModule::getStrongerPolicy(UsersModule::POLICY_MINIMUM_PASSWORD_LENGTH, array(20, 10))); $this->assertEquals(10, UsersModule::getStrongerPolicy(UsersModule::POLICY_MINIMUM_USERNAME_LENGTH, array(10, 10))); $this->assertEquals(20, UsersModule::getStrongerPolicy(UsersModule::POLICY_MINIMUM_USERNAME_LENGTH, array(10, 20))); $this->assertEquals(20, UsersModule::getStrongerPolicy(UsersModule::POLICY_MINIMUM_USERNAME_LENGTH, array(20, 10))); $this->assertEquals(10, UsersModule::getStrongerPolicy(UsersModule::POLICY_PASSWORD_EXPIRY_DAYS, array(10, 10))); $this->assertEquals(10, UsersModule::getStrongerPolicy(UsersModule::POLICY_PASSWORD_EXPIRY_DAYS, array(10, 20))); $this->assertEquals(10, UsersModule::getStrongerPolicy(UsersModule::POLICY_PASSWORD_EXPIRY_DAYS, array(20, 10))); }
/** * 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 = UsersModule::encrypting($model->password); $new_password->activkey = UsersModule::encrypting(microtime() . $model->password); $new_password->save(); Yii::app()->user->setFlash('profileMessage', UsersModule::t("New password is saved.")); $this->redirect(array("profile")); } } $this->render('changepassword', array('model' => $model)); } }
/** * @depends testListUsers */ public function testUnprivilegedUserViewUpdateDeleteUsers() { Yii::app()->user->userModel = User::getByUsername('super'); $notAllowedUser = UserTestHelper::createBasicUser('Steven'); $notAllowedUser->setRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API); $saved = $notAllowedUser->save(); $authenticationData = $this->login('steven', 'steven'); $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST'); $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME); $this->assertTrue($everyoneGroup->save()); $user = User::getByUsername('diggy011'); $data['firstName'] = "Sam"; // Test with unprivileged user to view, edit and delete account. $authenticationData = $this->login('steven', 'steven'); $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST'); $response = $this->createApiCallWithRelativeUrl('read/' . $user->id, 'GET', $headers); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); $this->assertEquals('You do not have rights to perform this action.', $response['message']); $response = $this->createApiCallWithRelativeUrl('update/' . $user->id, 'PUT', $headers, array('data' => $data)); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); $this->assertEquals('You do not have rights to perform this action.', $response['message']); $response = $this->createApiCallWithRelativeUrl('delete/' . $user->id, 'DELETE', $headers); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); $this->assertEquals('You do not have rights to perform this action.', $response['message']); //now check if user have rights, but no permissions. $notAllowedUser->setRight('UsersModule', UsersModule::getAccessRight()); $notAllowedUser->setRight('UsersModule', UsersModule::getCreateRight()); $saved = $notAllowedUser->save(); $this->assertTrue($saved); $response = $this->createApiCallWithRelativeUrl('read/' . $user->id, 'GET', $headers); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']); $response = $this->createApiCallWithRelativeUrl('update/' . $user->id, 'PUT', $headers, array('data' => $data)); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']); $this->assertEquals('Sam', $response['data']['firstName']); $response = $this->createApiCallWithRelativeUrl('delete/' . $user->id, 'DELETE', $headers); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']); $response = $this->createApiCallWithRelativeUrl('read/' . $user->id, 'GET', $headers); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); }
/** * Action called in the event that the mass edit quantity is larger than the pageSize. * This action is called after the pageSize quantity has been updated and continues to be * called until the mass edit action is complete. For example, if there are 20 records to update * and the pageSize is 5, then this action will be called 3 times. The first 5 are updated when * the actionMassEdit is called upon the initial form submission. */ public function actionMassEditProgressSave() { $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('massEditProgressPageSize'); $user = new User(false); $dataProvider = $this->getDataProviderByResolvingSelectAllFromGet(new UsersSearchForm($user), $pageSize, Yii::app()->user->userModel->id, null, 'UsersSearchView'); $this->processMassEditProgressSave('User', $pageSize, UsersModule::getModuleLabelByTypeAndLanguage('Plural'), $dataProvider); }
public function actionUpdate($id) { $user = $this->_loadUser($id); // if($user->id == Yii::app()->user->id) // $this->redirect('/settings'); // форма изменения пароля $changePassword = new UserChangePassword(); if (isset($_POST['User'])) { $this->performAjaxValidation($user, 'form-fullname'); $this->performAjaxValidation($user, 'form-about'); $this->performAjaxValidation($user, 'form-social'); if (isset($_POST['ajax']) && $_POST['ajax'] === 'form-account-username') { $errors = CActiveForm::validate($user); if ($errors !== '[]') { // echo CJSON::encode($errors); //echo CJSON::encode(false); echo 'false'; Yii::app()->end(); } } if (isset($_POST['ajax']) && $_POST['ajax'] === 'form-account-email') { $errors = CActiveForm::validate($user); if ($errors !== '[]') { //echo CJSON::encode($errors); //echo CJSON::encode(false); echo 'false'; Yii::app()->end(); } } $data = Yii::app()->request->getPost('User'); if ($data) { $user->attributes = $data; } if (!$user->save()) { VarDumper::dump($user->errors); } } if (isset($_POST['UserChangePassword'])) { $this->performAjaxValidation($changePassword, 'form-changepassword'); $data = Yii::app()->request->getPost('UserChangePassword'); $changePassword->attributes = $data; if ($changePassword->validate()) { $new_password = User::model()->notsafe()->findbyPk($user->id); $new_password->password = UsersModule::encrypting($changePassword->password); $new_password->activkey = UsersModule::encrypting(microtime() . $changePassword->password); if ($new_password->save(false)) { echo 'done'; } else { // VarDumper::dump($new_password->errors); } } } if (Yii::app()->request->isAjaxRequest) { Yii::app()->end(); } else { $this->render('view', array('user' => $user, 'changePassword' => $changePassword)); } }
/** * Initialization * @return array */ public function init() { return array('name' => __CLASS__, 'label' => UsersModule::t('jQueryUI datepicker'), 'fieldType' => array('DATE', 'VARCHAR'), 'params' => $this->params, 'paramsLabels' => array('dateFormat' => UsersModule::t('Date format'))); }
/** * Recovery password */ public function actionRecovery() { // $this->layout = '//layouts/login'; $model = new UserLogin(); $modelRecovery = new UserRecoveryForm(); $this->performAjaxValidation($modelRecovery, 'form-reminder'); if (Yii::app()->user->id) { $this->redirect('/'); } else { $email = Yii::app()->request->getParam('email'); $activkey = Yii::app()->request->getParam('activkey'); $email = !empty($email) ? $email : ''; $activkey = !empty($activkey) ? $activkey : ''; if ($email && $activkey) { $form2 = new UserChangePassword(); $this->performAjaxValidation($form2, 'change_password'); $find = User::model()->notsafe()->findByAttributes(array('email' => $email)); if (isset($find) && $find->activkey == $activkey) { if (isset($_POST['UserChangePassword'])) { $form2->attributes = $_POST['UserChangePassword']; if ($form2->validate()) { $find->password = Yii::app()->getModule('users')->encrypting($form2->password); $find->activkey = Yii::app()->getModule('users')->encrypting(microtime() . $form2->password); if ($find->status == 0) { $find->status = 1; } $find->save(); $message = Yii::t('site', 'New password is saved.'); if (Yii::app()->request->isAjaxRequest) { echo CJSON::encode(array('flag' => true, 'message' => $message)); Yii::app()->end(); } else { Yii::app()->user->setFlash('recoveryMessage', $message); $this->redirect(Yii::app()->getModule('users')->recoveryUrl); } } } $this->render('changepasswordnew', array('model' => $form2)); } else { Yii::app()->user->setFlash('recoveryMessage', UsersModule::t("Incorrect recovery link.")); // $this->redirect(Yii::app()->getModule('users')->recoveryUrl); $this->redirect('/'); } } else { if (isset($_POST['UserRecoveryForm'])) { $modelRecovery->attributes = $_POST['UserRecoveryForm']; if ($modelRecovery->validate()) { $user = User::model()->notsafe()->findbyPk($modelRecovery->user_id); $activation_url = $this->createAbsoluteUrl(implode(Yii::app()->getModule('users')->recoveryUrl) . '?activkey=' . $user->activkey . '&email=' . $user->email); $subject = UsersModule::t("Request for password recovery in {site_name}", array('{site_name}' => Yii::app()->name)); $message = UsersModule::t("You have requested the password recovery for access to {site_name}.<br> To get the password and to set the new one follow the link: {activation_url}", array('{site_name}' => Yii::app()->name, '{activation_url}' => $activation_url)); // UsersModule::sendMail($user->email, $subject, $message); SendMail::send($user->email, $subject, $message, true); $message = Yii::t('site', "Please check your e-mail.<br> Instruction was sent to your e-mail address."); if (Yii::app()->request->isAjaxRequest) { echo CJSON::encode(array('flag' => true, 'message' => $message)); Yii::app()->end(); } else { Yii::app()->user->setFlash('recoveryMessage', $message); $this->refresh(); } } } $this->render('recovery', array('model' => $model, 'modelRecovery' => $modelRecovery)); } } }
/** * Returns an array of initial characters from the source. * Source can be a CActiveRecord, or an array of data or data objects. * By default, characters are returned in uppercase; set preserveCase true to * return characters in their original case. * Used in ApPagination * @param mixed string: table name; array: the data or data objects * @param string Attribute name. The attribute can be a relative attribute if * source is a, or an array of, CActiveRecord; e.g. relation.attribute. * If empty, source must be an array; the values of which are used. */ public function activeChars($source, $attribute = '', $preserveCase = false) { if (is_array($source)) { $chars = array(); if ($attribute) { if ($preserveCase) { foreach ($source as $datum) { $chars[] = substr(CHtml::value($datum, $attribute), 0, 1); } } else { foreach ($source as $datum) { $chars[] = strtoupper(substr(CHtml::value($datum, $attribute), 0, 1)); } } } else { if ($preserveCase) { foreach ($source as $datum) { $chars[] = substr($datum, 0, 1); } } else { foreach ($source as $datum) { $chars[] = strtoupper(substr($datum, 0, 1)); } } } return array_unique($chars); } elseif ($source instanceof CActiveRecord) { if (empty($attribute)) { throw new CException(UsersModule::t('core', 'Attribute cannot be empty when using a model')); } $connection = $source->getDbConnection(); if (($pos = strpos($attribute, '.')) !== false) { $name = substr($attribute, 0, $pos); $md = $source->getMetaData(); if (!isset($md->relations[$name])) { throw new CDbException(Yii::t('yii', '{class} does not have relation "{name}".', array('{class}' => get_class($this), '{name}' => $name))); } $source = CActiveRecord::model($md->relations[$name]->className); $attribute = substr($attribute, $pos + 1); } $sql = $preserveCase ? 'SELECT DISTINCT(SUBSTR(' . $connection->quoteColumnName($attribute) . ',1,1)) AS ' . $connection->quoteColumnName('c') . ' FROM ' . $connection->quoteTableName($source->tableName()) : 'SELECT DISTINCT(UPPER(SUBSTR(' . $connection->quoteColumnName($attribute) . ',1,1))) AS ' . $connection->quoteColumnName('c') . ' FROM ' . $connection->quoteTableName($source->tableName()); return Yii::app()->db->createCommand($sql)->queryColumn(); } }
public static function itemAlias($type, $code = NULL) { $_items = array('UserStatus' => array(self::STATUS_NOACTIVE => UsersModule::t('Not active'), self::STATUS_ACTIVE => UsersModule::t('Active'), self::STATUS_BANNED => UsersModule::t('Banned')), 'AdminStatus' => array('0' => UsersModule::t('No'), '1' => UsersModule::t('Yes'))); if (isset($code)) { return isset($_items[$type][$code]) ? $_items[$type][$code] : false; } else { return isset($_items[$type]) ? $_items[$type] : false; } }
public function testGetModelClassNames() { $modelClassNames = UsersModule::getModelClassNames(); $this->assertEquals(3, count($modelClassNames)); $this->assertEquals('User', $modelClassNames[0]); $this->assertEquals('UserSearch', $modelClassNames[1]); }
/** * Verify Old Password */ public function verifyOldPassword($attribute, $params) { if (User::model()->notsafe()->findByPk(Yii::app()->user->id)->password != Yii::app()->getModule('users')->encrypting($this->$attribute)) $this->addError($attribute, UsersModule::t("Old Password is incorrect.")); }
protected function init() { if (RightsUtil::doesUserHaveAllowByRightName('UsersModule', UsersModule::getAccessRight(), Yii::app()->user->userModel)) { $this->currentUserCanAccessUsers = true; } }
public function testLogAuditEventChangingUsersPassword() { Yii::app()->user->userModel = User::getByUsername('jimmy'); $beforeCount = AuditEvent::getCount(); $user = new User(); $user->username = '******'; $user->firstName = 'Ed'; $user->lastName = 'Gein'; $this->assertTrue($user->save()); $this->assertEquals($beforeCount + 2, AuditEvent::getCount()); $user->setPassword('waggles'); $this->assertTrue($user->save()); $this->assertEquals($beforeCount + 3, AuditEvent::getCount()); $user->setPassword('bibbler'); $this->assertTrue($user->save()); $this->assertEquals($beforeCount + 4, AuditEvent::getCount()); $AuditEventsList = AuditEvent::getTailEvents(2); $this->assertRegExp('/[0-9]+\\/[0-9]+\\/[0-9]+ [0-9]+:[0-9]+ [AP]M, ' . 'James Boondog, User Password Changed/', UsersModule::stringifyAuditEvent($AuditEventsList[0])); $this->assertRegExp('/[0-9]+\\/[0-9]+\\/[0-9]+ [0-9]+:[0-9]+ [AP]M, ' . 'James Boondog, User Password Changed/', UsersModule::stringifyAuditEvent($AuditEventsList[0])); }
public function Edit() { if ($this->_POST) { //提交修改 $CustomersID = _intval($this->_POST['CustomersID']); $Data['CompanyName'] = trim($this->_POST['CompanyName']); $Data['DomainName'] = trim($this->_POST['DomainName']); $Data['CustomersName'] = trim($this->_POST['CustomersName']); $Data['Area'] = trim($this->_POST['Area']); $Data['Tel'] = trim($this->_POST['Tel']); $Data['Fax'] = trim($this->_POST['Fax']); $Data['Email'] = trim($this->_POST['Email']); $Data['Address'] = trim($this->_POST['Address']); $Data['ServiceName'] = trim($this->_POST['ServiceName']); $Data['UserGroupID'] = trim($this->_POST['UserGroupID']); $Data['Remark'] = addslashes($this->_POST['Remark']); $Data['UpdateTime'] = date("Y-m-d H:i:s"); $Page = _intval($this->_POST['Page']); if ($Data['CompanyName'] == '' || $Data['CustomersName'] == '' || $Data['Tel'] == '') { $this->__Message('信息填写不完整!'); } $CustomersModule = new CustomersModule(); if ($CustomersModule->UpdateArrayByKeyID($Data, $CustomersID)) { $this->__Message('修改客户成功!', UrlRewriteSimple('Customers', 'Lists', true) . '&Page=' . $Page, '继续操作'); } else { $this->__Message('修改客户失败,请再一次尝试!'); } } if ($this->_GET) { //获取用户信息 $CustomersID = _intval($this->_GET['CustomersID']); $CustomersModule = new CustomersModule(); $CustomersInfo = $CustomersModule->GetOneInfoByKeyID($CustomersID); $this->CustomersInfo = $CustomersInfo; //获取管理组信息 $UsersModule = new UsersModule(); $UserGroups = $UsersModule->GetAllUserGroups(); $this->UserGroups = $UserGroups; } }
return false; } $arrPath = explode('/', $path); foreach ($arrPath as $dirname) { if ($dirname && $dirname != '.' && $dirname != '..') { $newPath .= '/' . $dirname; if (!file_exists(DocumentRoot . $newPath) || !is_dir(DocumentRoot . $newPath)) { if (!@mkdir(DocumentRoot . $newPath, 0777)) { return false; } } } } return $newPath; } $Users = new UsersModule(); $UserID = $Users->Session('UserID'); $UploadSavePath = '/Data/Uploads'; $PicturesModule = new PicturesModule(); if ($system_config['timezone_set'] && function_exists('date_default_timezone_set')) { date_default_timezone_set($system_config['timezone_set']); } $CurrentDate = date('Y-m-d', time()); if ($UserID) { if (!file_exists(DocumentRoot . $UploadSavePath . '/' . $CurrentDate)) { if (!_x_mkdir($UploadSavePath . '/' . $CurrentDate)) { $ResultMessage = '创建储存目录失败!'; } } if (!$ResultMessage) { $CurrentSavePath = $UploadSavePath . '/' . $CurrentDate;
<?php $this->breadcrumbs=array( Users::t("Users"), ); ?> <h1><?php echo Users::t("List User"); ?></h1> <?php if(UsersModule::isAdmin()) { ?><ul class="actions"> <li><?php echo CHtml::link(Users::t('Manage User'),Users::url('admin')); ?></li> <li><?php echo CHtml::link(Users::t('Manage Profile Field'),Users::url('profileField/admin')); ?></li> </ul><!-- actions --><?php } ?> <?php $this->widget('zii.components.grid.CGridView', array( 'dataProvider'=>$dataProvider, 'columns'=>array( array( 'name' => 'username', 'type'=>'raw', 'value' => 'CHtml::link(CHtml::encode($data->username),Users::url("admin/view",array("id"=>$data->id)))', ), array( 'name' => 'createtime', 'value' => 'date("d.m.Y H:i:s",$data->createtime)', ), array( 'name' => 'lastvisit', 'value' => '(($data->lastvisit)?date("d.m.Y H:i:s",$data->lastvisit):Users::t("Not visited"))', ), ), )); ?>
/** * Widget initialization * @return array */ public function init() { return array('name' => __CLASS__, 'label' => UsersModule::t('Relation Belongs To', array(), __CLASS__), 'fieldType' => array('INTEGER'), 'params' => $this->params, 'paramsLabels' => array('modelName' => UsersModule::t('Model Name', array(), __CLASS__), 'optionName' => UsersModule::t('Lable field name', array(), __CLASS__), 'emptyField' => UsersModule::t('Empty item name', array(), __CLASS__), 'relationName' => UsersModule::t('Profile model relation name', array(), __CLASS__))); }
public static function activeDateField($model, $attribute, $htmlOptions = array()) { // SET UP ARRAYS OF OPTIONS FOR DAY, MONTH, YEAR $x = 1; $dayOptions = array('00' => ' - '); while ($x < 31) { $dayOptions[($x < 10 ? '0' : '') . $x] = $x; $x++; } $monthOptions = array('00' => ' - ', '01' => UsersModule::t('January'), '02' => UsersModule::t('February'), '03' => UsersModule::t('March'), '04' => UsersModule::t('April'), '05' => UsersModule::t('May'), '06' => UsersModule::t('June'), '07' => UsersModule::t('July'), '08' => UsersModule::t('August'), '09' => UsersModule::t('September'), '10' => UsersModule::t('October'), '11' => UsersModule::t('November'), '12' => UsersModule::t('December')); $yearOptions = array('0000' => ' - '); $x = 1901; while ($x < 2030) { $yearOptions[$x] = $x; $x++; } parent::resolveNameID($model, $attribute, $htmlOptions); if ($model->{$attribute} != '0000-00-00' && isset($model->{$attribute})) { if (is_array($model->{$attribute})) { $new = $model->{$attribute}; $day = $new['day']; $month = $new['month']; $year = $new['year']; } else { $new = explode('-', $model->{$attribute}); // intval removes leading zero $day = $new[2]; $month = $new[1]; $year = $new[0]; } } else { // DEFAULT TO 0 IF THERE IS NO DATE SET $day = '00'; $month = '00'; $year = '0000'; } //echo "<pre>"; print_r(array($day,$month,$year)); die(); $return = parent::dropDownList($htmlOptions['name'] . '[day]', $day, $dayOptions); $return .= parent::dropDownList($htmlOptions['name'] . '[month]', $month, $monthOptions); $return .= parent::dropDownList($htmlOptions['name'] . '[year]', $year, $yearOptions); return $return; }
?> <?php echo CHtml::activePasswordField($form, 'password'); ?> <p class="hint"> <?php echo UsersModule::t("Minimal password length 5 symbols."); ?> </p> </div> <div class="row"> <?php echo CHtml::activeLabelEx($form, 'verifyPassword'); ?> <?php echo CHtml::activePasswordField($form, 'verifyPassword'); ?> </div> <div class="row submit"> <?php echo CHtml::submitButton(UsersModule::t("Save")); ?> </div> <?php echo CHtml::endForm(); ?> </div><!-- form -->