Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
UserRegistrationWidget.php
1 <?php
2 /**
3  *
4  */
6 {
7  public $registrationForm;
8  public $profile;
9 
10  /**
11  * Show registration form
12  *
13  * @return void
14  */
15  public function run()
16  {
17  if (isset($_GET['activkey'], $_GET['email'])) {
18  Yii::app()->getRequest()->redirect(Yii::app()->createUrl('/user/activation', array(
19  'activkey' => $_GET['activkey'],
20  'email' => $_GET['email'],
21  'return_url' => Yii::app()->request->getRequestUri()
22  )));
23  }
24 
25  if (Yii::app()->user->isGuest) {
26  $this->registrationForm = new RegistrationForm();
27  $this->profile = new Profile();
28  $this->profile->regMode = true;
29  if (($registrationFormData = Yii::app()->user->getState('RegistrationForm')) !== null) {
30  $this->registrationForm->attributes = $registrationFormData['attributes'];
31  foreach ($registrationFormData['errors'] as $attribute => $errors) {
32  foreach ($errors as $e) {
33  $this->registrationForm->addError($attribute, $e);
34  }
35  }
36  Yii::app()->user->setState('RegistrationForm', null);
37  }
38  if (($profileData = Yii::app()->user->getState('Profile')) !== null) {
39  $this->profile->attributes = $profileData['attributes'];
40  foreach ($profileData['errors'] as $attribute => $errors) {
41  foreach ($errors as $e) {
42  $this->profile->addError($attribute, $e);
43  }
44  }
45  Yii::app()->user->setState('Profile', null);
46  }
47  $this->render('UserRegistrationWidget', array('model' => $this->registrationForm, 'profile' => $this->profile));
48  } else {
49  $this->render('UserRegistrationWidget_hide');
50  }
51  }
52 }