/** * Registration user */ public static function register($model, $post, $role = 'Customer') { $model->attributes = $post; if (isset($_COOKIE['partner'])) { $model->pid = intval($_COOKIE['partner']); } if ($model->validate()) { $soucePassword = UserModule::generate_password(8); $model->password = UserModule::encrypting($soucePassword); $model->superuser = 0; $model->status = 1; if ($model->save()) { $AuthAssignment = new AuthAssignment(); $AuthAssignment->attributes = array('itemname' => $role, 'userid' => $model->id); $AuthAssignment->save(); if ($role == 'Author') { if ($model->profile == null) { $profile = new Profile(); $profile->user_id = $model->id; $profile->mailing_for_executors = 1; $profile->save(); } } $webmasterlog = new WebmasterLog(); $webmasterlog->pid = $model->pid; $webmasterlog->uid = $model->id; $webmasterlog->date = date("Y-m-d"); $webmasterlog->action = WebmasterLog::REG; $webmasterlog->save(); // новая служба системных сообщений $type_id = Emails::TYPE_11; $email = new Emails(); $criteria = new CDbCriteria(); $criteria->order = 'id DESC'; $criteria->limit = 1; $user = User::model()->findAll($criteria); $user = $user[0]; $email->from_id = 1; $email->to_id = $user->id; $rec = Templates::model()->findAll("`type_id`='{$type_id}'"); $id = Company::getId(); $email->company = Company::getName(); $email->name = $model->full_name; $email->login = $model->email; $email->password = $soucePassword; $email->page_cabinet = 'http://' . $_SERVER['SERVER_NAME'] . '/user/profile/edit'; $email->sendTo($user->email, $rec[0]->title, $rec[0]->text, $type_id); $identity = new UserIdentity($model->email, $soucePassword); $identity->authenticate(); Yii::app()->user->login($identity, 0); //$this->redirect(Yii::app()->controller->module->returnUrl[0]); return true; //Yii::app()->end(); } else { //Yii::app()->user->setFlash('reg_failed',UserModule::t("Sorry, something wrong... :(")); //$this->refresh(); echo 'Cant save'; Yii::app()->end(); } } else { return false; } }