public function loadAttributes(User $user)
 {
     $user->setAttributes($this->attributes);
     $profile = \Yii::createObject(Profile::className());
     $profile->setAttributes(['name' => $this->name]);
     $user->setProfile($profile);
 }
Esempio n. 2
0
 public function rules()
 {
     $parentRules = parent::rules();
     $childRules = [['nickname', 'string', 'max' => '255'], ['gender', 'integer'], ['identity_num', 'string', 'length' => [15, 18]], ['qq', 'match', 'pattern' => "/^[1-9]*[1-9][0-9]*\$/i"], ['qq', 'string', 'max' => '11'], ['birthday', 'filter', 'filter' => 'strtotime', 'skipOnEmpty' => true]];
     $rules = ArrayHelper::merge($parentRules, $childRules);
     return $rules;
 }
Esempio n. 3
0
 protected function findModel($id)
 {
     if (($model = \dektrium\user\models\Profile::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 4
0
 public function rules()
 {
     $rules = parent::rules();
     $rules['firstnameLength'] = ['firstname', 'string', 'max' => 100];
     $rules['lastnameLength'] = ['lastname', 'string', 'max' => 100];
     $rules['phoneLength'] = ['phone', 'string', 'max' => 10];
     $rules['idcardLength'] = ['idcard', 'string', 'length' => 13];
     $rules['title_idIngeger'] = ['title_id', 'integer'];
     return $rules;
 }
Esempio n. 5
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         // if ($this->isAttributeChanged('gravatar_email')) {
         //     $this->setAttribute('gravatar_id', md5(strtolower($this->getAttribute('gravatar_email'))));
         // }
         return true;
     }
     return false;
 }
Esempio n. 6
0
 /** @inheritdoc */
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     if ($insert) {
         if ($this->_profile == null) {
             $this->_profile = Yii::createObject(Profile::className());
         }
         $this->_profile->link('user', $this);
     }
 }
Esempio n. 7
0
 public function rules()
 {
     $rules = parent::rules();
     // add firstname rules
     $rules['firstnameRequired'] = ['firstname', 'required'];
     $rules['firstnameLength'] = ['firstname', 'string', 'max' => 255];
     // add lastname rules
     $rules['lastnameRequired'] = ['lastname', 'required'];
     $rules['lastnameLength'] = ['lastname', 'string', 'max' => 255];
     // add birthday rules
     $rules['birthdayRequired'] = ['birthday', 'required'];
     $rules['birthdayLength'] = ['birthday', 'date', 'format' => 'yyyy-mm-dd'];
     // add terms checkbox
     $rules['termsRequired'] = ['terms', 'required', 'requiredValue' => true, 'message' => 'You must agree to the terms and conditions'];
     $rules['termsLength'] = ['terms', 'integer'];
     return $rules;
 }
Esempio n. 8
0
 /** @inheritdoc */
 public function attributeLabels()
 {
     $labels = parent::attributeLabels();
     $labels['avatar'] = \Yii::t('user', 'Avatar');
     return $labels;
 }
 public function attributeLabels()
 {
     return array_replace_recursive(parent::attributeLabels(), ['location' => Yii::t('user', 'City'), 'image_url' => Yii::t('user', 'Profile image')]);
 }
Esempio n. 10
0
 /**
  * Updates an existing profile.
  *
  * @param int $id
  *
  * @return mixed
  */
 public function actionUpdateProfile($id)
 {
     Url::remember('', 'actions-redirect');
     $user = $this->findModel($id);
     $profile = $user->profile;
     $event = $this->getProfileEvent($profile);
     if ($profile == null) {
         $profile = Yii::createObject(Profile::className());
         $profile->link('user', $user);
     }
     $this->performAjaxValidation($profile);
     $this->trigger(self::EVENT_BEFORE_PROFILE_UPDATE, $event);
     if ($profile->load(Yii::$app->request->post()) && $profile->save()) {
         Yii::$app->getSession()->setFlash('success', Yii::t('user', 'Profile details have been updated'));
         $this->trigger(self::EVENT_AFTER_PROFILE_UPDATE, $event);
         return $this->refresh();
     }
     return $this->render('_profile', ['user' => $user, 'profile' => $profile]);
 }
Esempio n. 11
0
 public function getStaff()
 {
     return $this->hasOne(Profile::className(), ['user_id' => 'mod']);
 }
Esempio n. 12
0
 public function getKursTeacher()
 {
     return $this->hasOne(Profile::className(), ['user_id' => 'user_id']);
 }
Esempio n. 13
0
 public function register()
 {
     return parent::register();
     // do your magic
 }
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ArrayHelper::merge(parent::attributeLabels(), ['public_email' => Yii::t('infoweb/user', 'Email'), 'firstname' => Yii::t('infoweb/user', 'Firstname'), 'name' => Yii::t('infoweb/user', 'Name'), 'language' => Yii::t('infoweb/user', 'Language'), 'address' => Yii::t('infoweb/user', 'Address'), 'zipcode' => Yii::t('infoweb/user', 'Zipcode'), 'city' => Yii::t('infoweb/user', 'City'), 'phone' => Yii::t('infoweb/user', 'Phone'), 'mobile' => Yii::t('infoweb/user', 'Mobile'), 'fax' => Yii::t('infoweb/user', 'Fax')]);
 }
Esempio n. 15
0
File: User.php Progetto: svd222/blog
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProfile()
 {
     return $this->hasOne(\dektrium\user\models\Profile::className(), ['user_id' => 'id']);
 }
Esempio n. 16
0
 /**
  * Shows profile settings form.
  *
  * @return string|\yii\web\Response
  */
 public function actionProfile()
 {
     $model = $this->finder->findProfileById(Yii::$app->user->identity->getId());
     if ($model == null) {
         $model = Yii::createObject(Profile::className());
         $model->link('user', Yii::$app->user->identity);
     }
     $event = $this->getProfileEvent($model);
     $this->performAjaxValidation($model);
     $this->trigger(self::EVENT_BEFORE_PROFILE_UPDATE, $event);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->getSession()->setFlash('success', Yii::t('user', 'Your profile has been updated'));
         $this->trigger(self::EVENT_AFTER_PROFILE_UPDATE, $event);
         return $this->refresh();
     }
     return $this->render('profile', ['model' => $model]);
 }
Esempio n. 17
0
use yii\helpers\Html;
?>
<div id="post-div-<?php 
echo $id;
?>
" class="pre-scrollable">
    <div class="card-panel horizontal-listing comments-section">
        <?php 
foreach ($models as $model) {
    ?>
                <div class="row hoverable">
                    <div class="col-sm-2">
                        <?php 
    //$user=\dektrium\user\models\User::findOne($model->commentedBy);
    $profile = \dektrium\user\models\Profile::findOne(['user_id' => $model->commentedBy]);
    ?>
                        <?php 
    echo Html::img('@web/images/' . $profile->name, ['class' => 'z-depth-1', 'style' => 'width:132%;height:103px;']);
    ?>
                    </div>
                    <div class="col-sm-10" style="padding-left: 32px;">
                        <a href="#">
                            <h6 class="title"><?php 
    echo \dektrium\user\models\User::findOne(['id' => $model->commentedBy])->username;
    ?>
                            </h6>
                        </a>
                        <i class="fa fa-clock-o"><?php 
    echo Yii::t('user', '{0, date}', $model->commentedAt);
    ?>
Esempio n. 18
0
 /** @inheritdoc */
 public function afterSave($insert, $changedAttributes)
 {
     if ($insert) {
         $profile = \Yii::createObject(['class' => Profile::className(), 'user_id' => $this->id, 'gravatar_email' => $this->email]);
         $profile->save(false);
     }
     parent::afterSave($insert, $changedAttributes);
 }
 public function actionAddcomment()
 {
     if (Yii::$app->request->isAjax) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         $data = Yii::$app->request->post();
         $comment = $data['comment'];
         $commentedOn = $data['commentedOn'];
         $model = new CommentsContent();
         $model->comment = $comment;
         $model->commentedOn = $commentedOn;
         $model->commentedBy = \Yii::$app->user->identity->getId();
         $model->commentedAt = time();
         if ($model->save()) {
             $profile = \dektrium\user\models\Profile::findOne(['user_id' => $model->commentedBy]);
             return ['image' => $profile->name, 'comment' => $comment, 'commentedOn' => $commentedOn, 'commentedBy' => User::findOne(['id' => \Yii::$app->user->identity->getId()])->username, 'commentedAt' => Yii::t('user', '{0, date}', time())];
         }
     }
 }