Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Public Attributes | List of all members
RegistrationController Class Reference
Inheritance diagram for RegistrationController:
Controller BaseController

Public Member Functions

 actions ()
 actionRegistration ()
 onRegisterNewUser ($form, $profile)

Public Attributes

 $defaultAction = 'registration'
- Public Attributes inherited from Controller
 $menu = array()
 $breadcrumbs = array()
- Public Attributes inherited from BaseController
 $layout = '//layouts/gportal'
 $mailLayout = '//layouts/mail'

Additional Inherited Members

- Protected Member Functions inherited from BaseController
 beforeAction ($action)

Detailed Description

Definition at line 3 of file RegistrationController.php.

Member Function Documentation

RegistrationController::actionRegistration ( )

Registration user

Definition at line 25 of file RegistrationController.php.

References UserModule\encrypting(), and UserModule\t().

{
if (Yii::app()->user->id) {
$this->redirect(Yii::app()->controller->module->homePageUrl);
} else {
$registrationForm = new RegistrationForm;
$profile = new Profile;
$profile->regMode = true;
// ajax validator
if (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') {
echo CActiveForm::validate(array($registrationForm, $profile));
Yii::app()->end();
}
if (isset($_POST['RegistrationForm'])) {
$registrationForm->attributes = $_POST['RegistrationForm'];
$profile->attributes = @$_POST['Profile'];
$rv = $registrationForm->validate();
$pv = $profile->validate();
if ($rv && $pv) {
$sourcePassword = $registrationForm->password;
$registrationForm->activkey = UserModule::encrypting(microtime() . $registrationForm->password);
$registrationForm->password = UserModule::encrypting($registrationForm->password);
$registrationForm->verifyPassword = UserModule::encrypting($registrationForm->verifyPassword);
$registrationForm->lastvisit =
((Yii::app()->controller->module->loginNotActiv || (Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false)) && Yii::app()->controller->module->autoLogin) ?
time() :
null;
// $model->superuser = 0;
$registrationForm->status = ((Yii::app()->controller->module->activeAfterRegister) ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE);
if ($registrationForm->save()) {
$profile->user_id = $registrationForm->id;
$profile->save();
if(Yii::app()->getModule('user')->registrationNotifyAdminEmail !== NULL){
$this->onRegisterNewUser($registrationForm, $profile);
}
Yii::app()->user->setState('RegistrationForm', null);
Yii::app()->user->setState('Profile', null);
if (Yii::app()->controller->module->sendActivationMail) {
if (isset($_GET['return_url'])) {
$activation_url = $this->createAbsoluteUrl(
AppHelper::addParamsToUrl($_GET['return_url'], array("activkey" => $registrationForm->activkey, "email" => $registrationForm->email))
);
} else {
$activation_url = $this->createAbsoluteUrl(
'/user/activation/activation',
array("activkey" => $registrationForm->activkey, "email" => $registrationForm->email)
);
}
$subject = UserModule::t(Yii::app()->controller->module->activationMailSubject, array('{site_name}' => Yii::app()->name));
$message = $this->renderMail('/mail_templates/activation_mail', $subject, array('activation_url' => $activation_url));
$notification = new Notification(
$subject,
$message,
array(new EmailRecipient($registrationForm->email, Yii::app()->getModule('user')->activationEmail, '', true))
);
Yii::app()->notificationManager->notifyAbout($notification);
}
if ((Yii::app()->controller->module->loginNotActiv || (Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false)) && Yii::app()->controller->module->autoLogin) {
$identity = new UserIdentity($registrationForm->username, $sourcePassword);
$identity->authenticate();
Yii::app()->user->login($identity, 0);
$this->redirect(Yii::app()->controller->module->returnUrl);
} else {
if (!Yii::app()->controller->module->activeAfterRegister && !Yii::app()->controller->module->sendActivationMail) {
Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Contact Admin to activate your account."));
} elseif (Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) {
Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please {{login}}.", array('{{login}}' => CHtml::link(UserModule::t('Login'), Yii::app()->controller->module->loginUrl))));
} elseif (Yii::app()->controller->module->loginNotActiv) {
Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please check your email or login."));
} else {
Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please check your email."));
}
if (isset($_GET['return_url'])) {
$this->redirect($_GET['return_url']);
} else {
$this->refresh();
}
}
}
} elseif (!isset($_POST['ajax'])) {
$registrationForm->password = null;
$registrationForm->verifyPassword = null;
Yii::app()->user->setState('RegistrationForm', array('attributes' => $registrationForm->attributes, 'errors' => $registrationForm->getErrors()));
Yii::app()->user->setState('Profile', array('attributes' => $profile->attributes, 'errors' => $profile->getErrors()));
}
}
if (isset($_GET['return_url'])) {
$this->redirect($_GET['return_url']);
} else {
$this->render('/user/registration', array('model' => $registrationForm, 'profile' => $profile));
}
}
}
RegistrationController::actions ( )

Declares class-based actions.

Definition at line 11 of file RegistrationController.php.

{
return (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') ? array() : array(
'captcha' => array(
'class' => 'CCaptchaAction',
'backColor' => 0xFFFFFF,
'fixedVerifyCode' => YII_DEBUG ? 'polomo' : null
),
);
}

The documentation for this class was generated from the following file: