Esempio n. 1
0
 public static function updateUser($user_id, $data = null)
 {
     $user = User::findOne($user_id);
     $user->scenario = 'settings';
     $profile = $user->profile;
     $oldEmail = $user->email;
     if ($user->load(['User' => $data]) && $user->validate()) {
         if ($user->email != $oldEmail) {
             $user->unconfirmed_email = $user->email;
             $user->email = $oldEmail;
             $token = \Yii::createObject(['class' => Token::className(), 'user_id' => $user->id, 'type' => Token::TYPE_CONFIRM_NEW_EMAIL]);
             $token->save(false);
             $mailer = Yii::createObject(['class' => Mailer::className(), 'reconfirmationSubject' => 'Mail confirmation']);
             $mailer->sendReconfirmationMessage($user, $token);
         }
         if (!$profile) {
             $profile = Yii::createObject(['class' => Profile::className(), 'user_id' => $user->id]);
             $profile->save();
         }
         $profile->load(['Profile' => $data]);
         $profile->save();
         $user->save();
     } else {
         self::error($user);
     }
     return self::clearUserData($user);
 }
 public function search($params)
 {
     $query = Profile::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['id', 'first_name', 'last_name', 'birthdate', 'genderName' => ['asc' => ['gender.gender_name' => SORT_ASC], 'desc' => ['gender.gender_name' => SORT_DESC], 'label' => 'Gender'], 'profileIdLink' => ['asc' => ['profile.id' => SORT_ASC], 'desc' => ['profile.id' => SORT_DESC], 'label' => 'ID'], 'userLink' => ['asc' => ['user.username' => SORT_ASC], 'desc' => ['user.username' => SORT_DESC], 'label' => 'User']]]);
     if (!($this->load($params) && $this->validate())) {
         $query->joinWith(['gender'])->joinWith(['user']);
         return $dataProvider;
     }
     $this->addSearchParameter($query, 'id');
     $this->addSearchParameter($query, 'first_name', true);
     $this->addSearchParameter($query, 'last_name', true);
     $this->addSearchParameter($query, 'birthdate');
     $this->addSearchParameter($query, 'gender_id');
     $this->addSearchParameter($query, 'created_at');
     $this->addSearchParameter($query, 'updated_at');
     $this->addSearchParameter($query, 'user_id');
     // filter by gender name
     $query->joinWith(['gender' => function ($q) {
         $q->andFilterWhere(['=', 'gender.gender_name', $this->genderName]);
     }])->joinWith(['user' => function ($q) {
         $q->andFilterWhere(['=', 'user.id', $this->user]);
     }]);
     return $dataProvider;
 }
Esempio n. 3
0
 protected function findModel($id)
 {
     if (($model = Profile::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 4
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();
         if ($user->save()) {
             $image = new Image();
             $image->url = "/uploads/none-avatar.png";
             $image->save();
             $profile = new Profile();
             $profile->link('user', $user);
             $profile->link('image', $image);
             $profile->save();
             return $user;
         }
     }
     return null;
 }
Esempio n. 5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Profile::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['like', '_id', $this->_id])->andFilterWhere(['like', 'firstName', $this->firstName])->andFilterWhere(['like', 'lastName', $this->lastName])->andFilterWhere(['like', 'dob', $this->dob])->andFilterWhere(['like', 'age', $this->age])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['like', 'country', $this->country])->andFilterWhere(['like', 'state', $this->state])->andFilterWhere(['like', 'addressLine1', $this->addressLine1])->andFilterWhere(['like', 'addressLine2', $this->addressLine2])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'zipCode', $this->zipCode])->andFilterWhere(['like', 'telNumber', $this->telNumber])->andFilterWhere(['like', 'faxNumber', $this->faxNumber])->andFilterWhere(['like', 'mobileNumber', $this->mobileNumber])->andFilterWhere(['like', 'profilePics', $this->profilePics])->andFilterWhere(['like', 'drRegNo', $this->drRegNo])->andFilterWhere(['like', 'drSpecialist', $this->drSpecialist])->andFilterWhere(['like', 'drHospital', $this->drHospital])->andFilterWhere(['like', 'drDesignation', $this->drDesignation])->andFilterWhere(['like', 'workLocation', $this->workLocation])->andFilterWhere(['like', 'qualification', $this->qualification])->andFilterWhere(['like', 'university', $this->university])->andFilterWhere(['like', 'totExp', $this->totExp])->andFilterWhere(['like', 'profileSummary', $this->profileSummary])->andFilterWhere(['like', 'paDisease', $this->paDisease])->andFilterWhere(['like', 'paSubDisease', $this->paSubDisease])->andFilterWhere(['like', 'repProdName', $this->repProdName])->andFilterWhere(['like', 'repCompName', $this->repCompName])->andFilterWhere(['like', 'repTot', $this->repTot])->andFilterWhere(['like', 'userId', $this->userId]);
     return $dataProvider;
 }
Esempio n. 6
0
 public function save()
 {
     if ($this->validate()) {
         $isValid = false;
         $this->imageFile = UploadedFile::getInstance($this, 'imageFile');
         $user = User::findOne(Yii::$app->user->getId());
         if (isset($user->profile)) {
             $profile = Profile::findOne($user->profile->id);
         } else {
             $profile = new Profile();
         }
         if (isset($this->imageFile)) {
             $imagePath = '/uploads/' . $this->imageFile->baseName . '.' . $this->imageFile->extension;
             $this->imageFile->saveAs(Yii::getAlias('@webroot') . $imagePath);
             $m_image = new Image();
             $m_image->url = $imagePath;
             if ($m_image->save()) {
                 $image = Image::findOne($m_image->getPrimaryKey());
                 $profile->link('image', $image);
                 $isValid = true;
             } else {
                 $isValid = false;
             }
         }
         $profile->firstname = $this->firstname;
         $profile->lastname = $this->lastname;
         $profile->aboutme = $this->aboutme;
         $profile->link('user', $user);
         if ($profile->save()) {
             $isValid = true;
         } else {
             $isValid = false;
         }
         return $isValid;
     } else {
         return false;
     }
 }
Esempio n. 7
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Profile::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['profileID' => $this->profileID, 'userID' => $this->userID]);
     $query->andFilterWhere(['like', 'firstName', $this->firstName])->andFilterWhere(['like', 'middleName', $this->middleName])->andFilterWhere(['like', 'lastName', $this->lastName])->andFilterWhere(['like', 'gender', $this->gender]);
     return $dataProvider;
 }
Esempio n. 8
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Profile::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'birthdate' => $this->birthdate, 'gender_id' => $this->gender_id, 'created_at' => $this->created_at, 'updatead_at' => $this->updatead_at]);
     $query->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'last_name', $this->last_name]);
     return $dataProvider;
 }
Esempio n. 9
0
 public function actionLogin()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         $currentUserId = (string) Yii::$app->user->identity->_id;
         $currProfile = Profile::find()->where(['userId' => new \MongoId($currentUserId)])->asArray()->all();
         $session = Yii::$app->session;
         $session['profile'] = $currProfile;
         return $this->goBack();
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
Esempio n. 10
0
 public function actionProfile()
 {
     $model_profile = new Profile();
     $model_pass = new ChangePassword();
     $user = new User();
     $info = $user->getUserInfo(Yii::$app->user->getId());
     $message = "";
     if ($model_profile->load(Yii::$app->request->post()) && $model_profile->validate()) {
         foreach ($model_profile as $key => $value) {
             if ($model_profile->{$key}) {
                 $info->setAttribute($key, Html::encode($model_profile->{$key}));
             }
         }
         $info->update();
         $message = "Changes saved";
     }
     if ($model_pass->load(Yii::$app->request->post()) && $model_pass->validate()) {
         if ($model_pass->new_password == $model_pass->new_password_rep) {
             $info->setAttribute('password_hash', Yii::$app->security->generatePasswordHash(Html::encode($model_pass->new_password)));
             $info->update();
             $message = "Changes saved";
         }
     }
     $model = new Job();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['../job/view', 'id' => (string) $model->_id]);
     }
     return $this->render('profile', ['model_profile' => $model_profile, 'model_pass' => $model_pass, 'info' => $info, 'message' => $message, 'model' => $model]);
 }
 /**
  * Finds the Profile model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Profile the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Profile::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('Запрашиваемая страница не найдена.');
     }
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProfile()
 {
     return $this->hasOne(Profile::className(), ['customer_user_name' => 'customer_user_name']);
 }
Esempio n. 13
0
 public function actionIndex()
 {
     $name = Profile::find()->where(['user_id' => Yii::$app->user->identity->id])->one();
     return $this->render('index', ['name' => $name]);
 }
    $todisplay1 = 'false';
    $todisplay2 = 'false';
    $todisplay3 = 'false';
    if ($i < sizeof($designers)) {
        $todisplay1 = 'true';
        $imgpath1 = Profile::findBySql('select profile_picture from profile where user_name ="' . $designers[$i]->designer_user_name . '"')->one();
        $name1 = DesignerSocialLogin::findBySql('select designer_first_name, designer_last_name, designer_revenue from designer where designer_user_name ="' . $designers[$i]->designer_user_name . '"')->one();
    }
    if ($i + 1 < sizeof($designers)) {
        $todisplay2 = 'true';
        $imgpath2 = Profile::findBySql('select profile_picture from profile where user_name ="' . $designers[$i + 1]->designer_user_name . '"')->one();
        $name2 = DesignerSocialLogin::findBySql('select designer_first_name, designer_last_name, designer_revenue from designer where designer_user_name ="' . $designers[$i + 1]->designer_user_name . '"')->one();
    }
    if ($i + 2 < sizeof($designers)) {
        $todisplay3 = 'true';
        $imgpath3 = Profile::findBySql('select profile_picture from profile where user_name ="' . $designers[$i + 2]->designer_user_name . '"')->one();
        $name3 = DesignerSocialLogin::findBySql('select designer_first_name, designer_last_name, designer_revenue from designer where designer_user_name ="' . $designers[$i + 2]->designer_user_name . '"')->one();
    }
    ?>
			
			<div class="row row-list">
			<?php 
    if ($todisplay1 == 'true') {
        ?>
			<div class="col-xs-3">
			<?php 
        echo Html::img($imgpath1->profile_picture, ['width' => 100, 'height' => 100]);
        echo "<br/>";
        ?>
			<a href="index.php?r=site/viewprofile&username=<?php 
        echo $designers[$i]->designer_user_name;
Esempio n. 15
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProfiles()
 {
     return $this->hasMany(Profile::className(), ['gender_id' => 'id']);
 }
 public function getProfileInfo($username)
 {
     $prof_info = Profile::findBySql('select profile_about, profile_picture, user_lives_in_city, user_lives_in_state, user_from_city, user_from_state, publish_data_scope from profile where user_name ="' . $username . '"')->one();
     return $prof_info;
 }
Esempio n. 17
0
 /**
  * Signs user up.
  *
  * @return mixed
  */
 public function actionSignup()
 {
     $model = new SignupForm();
     $Compnay_model = new CompnayDetails();
     //echo '<pre>';print_r(Yii::$app->request->post());
     //$Compnay_model->load(Yii::$app->request->post());
     //print_r($Compnay_model);
     ////die;
     $Profile_model = new Profile();
     if ($model->load(Yii::$app->request->post())) {
         if ($user = $model->signup()) {
             if ($Compnay_model->load(Yii::$app->request->post())) {
                 $Compnay_model->user_id = $user->id;
                 //echo '<pre>';					print_r($Compnay_model); die;
                 if ($Compnay_model->save()) {
                     $Profile_model->user_id = $user->id;
                     $Profile_model->save();
                     if (Yii::$app->getUser()->login($user)) {
                         return $this->goHome();
                     } else {
                         Yii::$app->getSession()->setFlash('msg', '<div class="alert alert-info">profile not updated</div>');
                     }
                 } else {
                     Yii::$app->getSession()->setFlash('msg', '<div class="alert alert-info">CompnayDetails not updated</div>');
                 }
             } else {
                 Yii::$app->getSession()->setFlash('msg', '<div class="alert alert-info">CompnayDetails not loaded</div>');
             }
         }
     } else {
         Yii::$app->getSession()->setFlash('msg', '<div class="alert alert-info">Signup data not loaded</div>');
     }
     return $this->render('signup', ['model' => $model, 'Compnay_model' => $Compnay_model, 'Profile_model' => $Profile_model]);
 }
Esempio n. 18
0
 public function getprofile()
 {
     return $this->hasOne(Profile::className(), ['userId' => '_id']);
 }
 /**
  * Finds the Profile model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Profile the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Profile::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('Запрошенной страницы не существует.');
     }
 }
    $todisplay1 = 'false';
    $todisplay2 = 'false';
    $todisplay3 = 'false';
    if ($i < sizeof($myfriends)) {
        $todisplay1 = 'true';
        $imgpath1 = Profile::findBySql('select profile_picture from profile where user_name ="' . $myfriends[$i]->customer_user_name2 . '"')->one();
        $name1 = CustomerSocialLogin::findBySql('select customer_first_name, customer_last_name from customer where customer_user_name ="' . $myfriends[$i]->customer_user_name2 . '"')->one();
    }
    if ($i + 1 < sizeof($myfriends)) {
        $todisplay2 = 'true';
        $imgpath2 = Profile::findBySql('select profile_picture from profile where user_name ="' . $myfriends[$i + 1]->customer_user_name2 . '"')->one();
        $name2 = CustomerSocialLogin::findBySql('select customer_first_name, customer_last_name from customer where customer_user_name ="' . $myfriends[$i + 1]->customer_user_name2 . '"')->one();
    }
    if ($i + 2 < sizeof($myfriends)) {
        $todisplay3 = 'true';
        $imgpath3 = Profile::findBySql('select profile_picture from profile where user_name ="' . $myfriends[$i + 2]->customer_user_name2 . '"')->one();
        $name3 = CustomerSocialLogin::findBySql('select customer_first_name, customer_last_name from customer where customer_user_name ="' . $myfriends[$i + 2]->customer_user_name2 . '"')->one();
    }
    ?>
			
			<div class="row row-list">
			<?php 
    if ($todisplay1 == 'true') {
        ?>
			<div class="col-xs-3">
			<?php 
        echo Html::img($imgpath1->profile_picture, ['width' => 100, 'height' => 100]);
        echo "<br/>";
        ?>
			<a href="index.php?r=site/viewprofile&username=<?php 
        echo $myfriends[$i]->customer_user_name2;
Esempio n. 21
0
								<li><a data-toggle="tab" href="#avata">头像</a></li>
								<li><a data-toggle="tab" href="#notifications">其他</a></li>
							</ul>
							<div class="tab-content">
								<div id="profile" class="profile-edit tab-pane fade in active">
									<h2 class="heading-md">设置您账号的一些基本信息.</h2>
									<?php 
$form = ActiveForm::begin(['id' => 'profile-form', 'action' => ['/user/settings/profile'], 'options' => ['class' => 'form-horizontal'], 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-9\">{input}</div>\n<div class=\"col-sm-offset-3 col-lg-9\">{error}\n{hint}</div>", 'labelOptions' => ['class' => 'col-lg-3 control-label']], 'enableAjaxValidation' => true, 'enableClientValidation' => false, 'validateOnBlur' => false]);
?>

									<?php 
echo $form->field($model, 'nickname');
?>

									<?php 
echo $form->field($model, 'gender')->radioList(Profile::getGenderList());
?>

									<?php 
echo $form->field($model, 'public_email');
?>

									<?php 
echo $form->field($model, 'location');
?>

									<?php 
echo $form->field($model, 'qq');
?>

									<?php 
Esempio n. 22
0
 public function getImage()
 {
     return $this->hasOne(Image::className(), ['id' => 'image_id'])->viaTable(Profile::tableName(), ['user_id' => 'id']);
 }
Esempio n. 23
0
?>
<div class="profile-search">
    <?php 
$form = ActiveForm::begin(['action' => ['index'], 'method' => 'get']);
?>
    <?php 
echo $form->field($model, 'first_name');
?>
    <?php 
echo $form->field($model, 'last_name');
?>
    <?php 
echo $form->field($model, 'birthdate');
?>
    <?php 
echo $form->field($model, 'gender_id')->dropDownList(Profile::getgenderList(), ['prompt' => 'Please Choose One']);
?>
    <?php 
// echo $form->field($model, 'created_at')
?>
    <?php 
// echo $form->field($model, 'updated_at')
?>
    <?php 
// echo $form->field($model, 'user_id')
?>
    <div class="form-group">
        <?php 
echo Html::submitButton('Search', ['class' => 'btn btn-primary']);
?>
        <?php 
Esempio n. 24
0
 /**
  * Get Person.
  * @return Person
  */
 public function getProfile()
 {
     return $this->hasOne(Profile::className(), ['id' => 'id_profile']);
 }
Esempio n. 25
0
 /**
  * get profile
  */
 public function getProfile()
 {
     return $this->hasOne(Profile::className(), ['user_id', 'id']);
 }
Esempio n. 26
0
 public function actionSearchdoc()
 {
     $model = new SearchdocForm();
     $user_ids = array();
     $prof = new Profile();
     if (Yii::$app->request->post()) {
         $location = $_POST['SearchdocForm']['location'];
         $drSpecialist = $_POST['SearchdocForm']['drSpecialist'];
         $model->location = $location;
         $model->drSpecialist = $drSpecialist;
         if ($location != "" && $drSpecialist != "") {
             $matched_id = ArrayHelper::map(Profile::find()->where(['drSpecialist' => new \MongoId($drSpecialist), 'city' => (string) $location])->all(), function ($prof) {
                 return $prof->userId->{'$id'};
             }, 'city');
             foreach ($matched_id as $key => $value) {
                 array_push($user_ids, $key);
             }
         } elseif ($location != "") {
             $matched_id = ArrayHelper::map(Profile::find()->where(['city' => (string) $location])->all(), function ($prof) {
                 return $prof->userId->{'$id'};
             }, 'city');
             foreach ($matched_id as $key => $value) {
                 array_push($user_ids, $key);
             }
         } elseif ($drSpecialist != "") {
             $matched_id = ArrayHelper::map(Profile::find()->where(['drSpecialist' => new \MongoId($drSpecialist)])->all(), function ($prof) {
                 return $prof->userId->{'$id'};
             }, 'city');
             foreach ($matched_id as $key => $value) {
                 array_push($user_ids, $key);
             }
         } else {
         }
         $doctors = User::find()->where(['_id' => $user_ids, "user_role" => '1'])->with('profile')->all();
     } else {
         $currentUserId = Yii::$app->user->identity->_id;
         $session = Yii::$app->session;
         $location = Yii::$app->session['profile'][0]['city'];
         $model->location = $location;
         $matched_id = ArrayHelper::map(Profile::find()->where(['city' => (string) $location])->all(), function ($prof) {
             return $prof->userId->{'$id'};
         }, 'city');
         foreach ($matched_id as $key => $value) {
             array_push($user_ids, $key);
         }
         $doctors = User::find()->where(['_id' => $user_ids, "user_role" => '1'])->with('profile')->all();
     }
     return $this->render('searchdoc', ['model' => $model, 'doctors' => $doctors]);
 }