Exemplo n.º 1
0
 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         $user->status = User::STATUS_NOTACTIVATED;
         $b = $user->save();
         $activationToken = new UserTokens();
         $activationToken->user_id = $user->id;
         $activationToken->token_type = ETokenType::ACCOUNT_ACTIVATION;
         $activationToken->token = sha1(mt_rand(10000, 99999) . time() . $user->email);
         $activationToken->save();
         $auth = Yii::$app->authManager;
         $userRole = $auth->getRole('user');
         $auth->assign($userRole, $user->id);
         if ($b) {
             $x = new UserInfo();
             $x->user_id = $user->id;
             $x->save();
             EventService::createEvent(EEvent::ACCOUNT_CREATE(), new UserId($user->id));
             $this->sendActivationMail($user, $activationToken->token);
             return $user;
         }
     }
     return null;
 }
Exemplo n.º 2
0
echo (new DateTime())->format("d-m-Y");
?>
                                </span>
								</li>
								<!-- /.timeline-label -->
								<?php 
$lastDate = (new DateTime())->format("Y-m-d");
foreach ($timeline as $event) {
    $dateChanged = $event->getEventDate("Y-m-d") != $lastDate;
    $userConnected = $event->getEventOwner();
    $userConnectedDefault = true;
    $content = "Unknown Event Type";
    $icon = "fa-exclamation-triangle";
    $color = "bg-red";
    switch ($event->getEventType()) {
        case \common\components\EEvent::ACCOUNT_CREATE():
            $icon = "fa-user-plus";
            $color = "bg-green";
            $content = "<a href='/user/" . $userConnected->getUsername() . "'>" . Yii::t('app', 'You') . "</a>&nbsp\n\t\t\t\t\t\t\t\t                " . Yii::t('app', 'have created an account');
            break;
        case \common\components\EEvent::ACCOUNT_INFO_CHANGED():
            $icon = "fa-user";
            $color = "bg-aqua";
            $content = "<a href='/user/ " . $userConnected->getUsername() . "'>" . Yii::t('app', 'You') . "</a>&nbsp" . Yii::t('app', 'have changed your account details');
            break;
        case \common\components\EEvent::ACCOUNT_PASSWORD_CHANGED():
            $icon = "fa-user-secret";
            $color = "bg-yellow";
            $content = "<a href='/user/" . $userConnected->getUsername() . "'>" . Yii::t('app', 'You') . "</a>&nbsp" . Yii::t('app', 'have changed your password');
            break;
        case \common\components\EEvent::ACCOUNT_PASSWORD_RESET():