90 public $captcha = array(
'registration' =>
true);
102 'with' => array(
'profile'),
123 $this->setImport(array(
131 if (isset($this->componentBehaviors[$componentName])) {
132 return $this->componentBehaviors[$componentName];
140 if (parent::beforeControllerAction($controller, $action)) {
156 public static function t($str =
'', $params = array(), $dic =
'user')
158 if (Yii::t(
"UserModule", $str) == $str) {
159 return Yii::t(
"UserModule.".$dic, $str, $params);
161 return Yii::t(
"UserModule", $str, $params);
170 $hash = Yii::app()->getModule(
'user')->hash;
171 if (
$hash ==
"md5") {
174 if (
$hash ==
"sha1") {
175 return sha1($string);
177 return hash(
$hash, $string);
188 if (!extension_loaded(
'gd')) {
191 if (in_array($place, Yii::app()->getModule(
'user')->captcha)) {
192 return Yii::app()->getModule(
'user')->captcha[$place];
205 if (Yii::app()->
user->isGuest) {
208 if (!isset(self::$_admin)) {
209 if (self::user()->superuser) {
210 self::$_admin =
true;
212 self::$_admin =
false;
227 if (!self::$_admins) {
228 $admins =
User::model()->active()->superuser()->findAll();
229 $return_name = array();
230 foreach ($admins as $admin) {
231 array_push($return_name, $admin->username);
233 self::$_admins = ($return_name) ? $return_name : array(
'');
242 public static function sendMail($email, $subject, $message)
244 $adminEmail = Yii::app()->params[
'adminEmail'];
245 $headers =
"MIME-Version: 1.0\r\nFrom: $adminEmail\r\nReply-To: $adminEmail\r\nContent-Type: text/html; charset=utf-8";
246 $message = wordwrap($message, 70);
247 $message = str_replace(
"\n.",
"\n..", $message);
249 return mail($email,
'=?UTF-8?B?'.base64_encode($subject).
'?=', $message, $headers);
259 public static function user($id = 0, $clearCache =
false)
261 if (!$id && !Yii::app()->
user->isGuest) {
262 $id = Yii::app()->user->id;
265 if (!isset(self::$_users[$id]) || $clearCache) {
266 self::$_users[$id] =
User::model()->with(array(
'profile'))->findbyPk($id);
269 return self::$_users[$id];
284 if (!isset(self::$_userByName[$username])) {
310 return Yii::app()->user->isGuest;
334 return (!self::isGuest() && !self::isUserTemp());
344 return Yii::app()->user->id;
352 $sessionId = Yii::app()->getSession()->getSessionId();
353 $emailDomain =
'@temp.com';
357 $User =
User::model()->findByAttributes(array(
'username' => $sessionId));
359 $RegistrationForm->username = $sessionId;
360 $RegistrationForm->email = $sessionId.$emailDomain;
364 if (!$RegistrationForm->save(
false)) {
369 $profile->user_id = $RegistrationForm->id;
370 $profile->lastname =
'-';
371 $profile->firstname =
'-';
372 $profile->save(
false);
374 $RegistrationForm->setDefaultTempUserAssignments($RegistrationForm->id);
376 $RegistrationForm = $User;
380 $identity->authenticate();
381 Yii::app()->user->login($identity, 0);
383 $sessionId = Yii::app()->getSession()->getSessionId();
384 $RegistrationForm->username = $sessionId;
385 $RegistrationForm->email = $sessionId.$emailDomain;
386 $RegistrationForm->save(
false);