17 public $user_page_size = 10;
23 public $fields_page_size = 10;
35 public $sendActivationMail =
true;
38 public $activationMailSubject =
'You registered from {site_name}';
43 public $activationEmail;
49 public $loginNotActiv =
false;
55 public $activeAfterRegister =
false;
78 public $autoLogin =
true;
80 private $_registrationUrl = array(
81 'en' => array(
"/user/registration")
83 private $_recoveryUrl = array(
84 'en' =>
"/user/recovery/recovery"
86 private $_logoutUrl = array(
87 'en' =>
"/user/logout"
89 private $_profileUrl = array(
90 'en' =>
"/user/profile"
92 private $_returnUrl = array(
93 'en' =>
"/user/profile"
95 private $_returnLogoutUrl = array(
98 private $_noPermissionsUrl = array(
99 'en' =>
'/site/noPermissions'
101 private $_loginUrl = array(
102 'en' =>
"/user/login"
104 private $_homePageUrl = array(
107 private $_friendListUrl = array();
108 private $_recoveryChangePasswordUrl = array();
113 public $fieldsMessage =
'';
120 public $relations = array();
126 public $profileRelations = array();
131 public $captcha = array(
'registration' =>
true);
137 public $loggedInDuration = 0;
142 public $usernameMin = 4;
147 public $passwordForgottenEmail;
152 public $passwordMin = 4;
154 public $userLoginWidgetFlashSuccess =
'UserLoginWidget-success';
156 public $userLoginWidgetFlashError =
'UserLoginWidget-error';
161 public $registrationNotifyAdminEmail = null;
165 public $registrationNotifyAdminTemplate =
'notifyAdminAboutRegister';
169 public $profileEditUrl =
false;
174 private $_authField =
'email';
188 if (!in_array($value, array(
'username',
'email'))) {
189 throw new Exception(
'authField can have value "username" or "email"');
191 $this->_authField = $value;
201 return $this->_authField;
209 $this->_loginUrl = $value;
217 $this->_registrationUrl = $value;
225 $this->_recoveryUrl = $value;
233 $this->_returnUrl = $value;
241 $this->_returnLogoutUrl = $value;
249 $this->_homePageUrl = $value;
257 $this->_friendListUrl = $value;
260 public function setRecoveryChangePasswordUrl(array $value)
262 $this->_recoveryChangePasswordUrl = $value;
270 $this->_noPermissionsUrl = $value;
273 public function getRecoveryChangePasswordUrl($locale =
'')
275 return $this->_getUrl(
'_recoveryChangePasswordUrl', $locale);
278 public function getLoginUrl($locale =
'')
280 return $this->_getUrl(
'_loginUrl', $locale,
'/user/login');
283 public function getFriendListUrl($locale =
'')
285 return $this->_getUrl(
'_friendListUrl', $locale);
288 public function getRegistrationUrl($locale =
'')
290 return $this->_getUrl(
'_registrationUrl', $locale);
293 public function getRecoveryUrl($locale =
'')
295 return $this->_getUrl(
'_recoveryUrl', $locale);
298 public function getReturnUrl($locale =
'')
300 return $this->_getUrl(
'_returnUrl', $locale);
303 public function getReturnLogoutUrl($locale =
'')
305 return $this->_getUrl(
'_returnLogoutUrl', $locale);
308 public function getNoPermissionsUrl($locale =
'')
310 return $this->_getUrl(
'_noPermissionsUrl', $locale);
313 public function getHomePageUrl($locale =
'')
315 return $this->_getUrl(
'_homePageUrl', $locale);
327 private function _getUrl($urlField, $locale, $default =
'')
329 if (empty($locale)) {
330 $locale = Yii::app()->language;
332 if (isset($this->{$urlField}[$locale])) {
333 return $this->{$urlField}[$locale];
335 $tmp = array_values($this->$urlField);
336 return count($this->$urlField) > 0 ? array_shift($tmp) : $default;
343 public $usernameUnique =
true;
348 public $usernameRequired =
true;
355 public $tableUsers =
'{{users}}';
356 public $tableProfiles =
'{{profiles}}';
357 public $tableProfileFields =
'{{profiles_fields}}';
358 public $tableAccounts =
'{{accounts}}';
360 static private $_user;
361 static private $_admin;
362 static private $_admins;
368 public $componentBehaviors = array();
370 public function init()
376 $this->setImport(array(
383 Yii::app()->user->loginUrl = $this->getLoginUrl();
386 public function getBehaviorsFor($componentName)
388 if (isset($this->componentBehaviors[$componentName])) {
389 return $this->componentBehaviors[$componentName];
395 public function beforeControllerAction($controller, $action)
397 if (parent::beforeControllerAction($controller, $action)) {
411 public static function t($str =
'', $params = array(), $dic =
'user')
413 return Yii::t(
"UserModule." . $dic, $str, $params);
421 $hash = Yii::app()->getModule(
'user')->hash;
425 return sha1($string);
427 return hash($hash, $string);
436 if (!extension_loaded(
'gd'))
438 if (in_array($place, Yii::app()->getModule(
'user')->captcha))
439 return Yii::app()->getModule(
'user')->captcha[$place];
449 if (Yii::app()->
user->isGuest)
452 return Yii::app()->user->checkAccess(
'Admin');
461 public static function user($id = 0)
466 if (Yii::app()->
user->isGuest) {
470 self::$_user =
User::model()->active()->findbyPk(Yii::app()->
user->id);
476 public function getAssetsUrl()
478 if ($this->_assetsUrl === null) {
479 $assetsPath = Yii::getPathOfAlias(
'user.views.asset');
480 $this->_assetsUrl = Yii::app()->getAssetManager()->publish($assetsPath,
true);
483 return $this->_assetsUrl;