public function run()
 {
     $request = Yii::$app->request;
     $ident = Yii::$app->user->getIdentity();
     $form = new ProfileForm();
     if ($request->isPost) {
         $form->load($request->bodyParams);
         if ($form->validate()) {
             $transaction = Yii::$app->db->beginTransaction();
             try {
                 $ident->attributes = $form->attributes;
                 $ident->env_id = $this->findOrCreateEnvironmentId($form->env);
                 $ident->is_black_out_others = $form->is_black_out_others == '1';
                 if ($ident->save()) {
                     $transaction->commit();
                     $this->controller->redirect(['user/profile']);
                     return;
                 }
             } catch (\Exception $e) {
             }
             $transaction->rollback();
         }
     } else {
         $form->attributes = $ident->attributes;
         if ($ident->env) {
             $form->env = $ident->env->text;
         }
         $form->is_black_out_others = $ident->is_black_out_others ? '1' : '0';
     }
     return $this->controller->render('edit-profile.tpl', ['user' => $ident, 'form' => $form]);
 }
Esempio n. 2
0
 public function actionProfile()
 {
     if (!is_null($user = $this->getLoggedUser())) {
         $profile = new ProfileForm($user);
         if (Yii::$app->request->isPost && $profile->load(Yii::$app->request->post()) && $profile->validate() && $profile->update($user)) {
         }
         return $this->render('profile', ['model' => $profile, 'user' => $user]);
     } else {
         return $this->redirect(['site/register']);
     }
 }
Esempio n. 3
0
 /**
  * Add a new user to the database
  * @param SignupForm
  * return Boolean: true if insertion succeed, otherwise, false.
  */
 public function addUser($model)
 {
     $this->id = '';
     $this->username = $model->username;
     $this->password = $model->password;
     $this->auth_key = Yii::$app->getSecurity()->generateRandomString();
     $this->access_token = Yii::$app->getSecurity()->generateRandomString();
     $profile = new ProfileForm();
     if ($profile->addUserProfile($this, $model)) {
         return $this->save();
     }
     return false;
 }
Esempio n. 4
0
 public function actionUpdate()
 {
     $user = $this->findModel();
     $model = new ProfileForm($user);
     if ($model->load(Yii::$app->request->post()) && $model->update()) {
         return $this->redirect(['profile']);
     } else {
         echo 'F**K! Update() does not work!';
         if ($model->status == User::SCENARIO_PERSON) {
             return $this->render('update-person', ['model' => $model]);
         } elseif ($model->status == User::SCENARIO_COMPANY) {
             return $this->render('update-company', ['model' => $model]);
         } else {
             false;
         }
     }
 }
Esempio n. 5
0
 public function actionIndex()
 {
     $request = \Yii::$app->request;
     $session = \Yii::$app->session;
     $profileForm = new ProfileForm();
     $user = \Yii::$app->user->identity;
     $accountId = $user->getId();
     if (!$this->checkForProfile($accountId)) {
         if ($profileForm->load($request->post())) {
             $session->set('newProfile', $request->post('ProfileForm'));
             return $this->redirect('@web/index.php/profile/add-profile');
         } else {
             return $this->render('setup-profile', ["ProfileForm" => $profileForm]);
         }
     }
     return $this->redirect('@web/index.php/profile/view-profile');
 }
 public function run()
 {
     $request = Yii::$app->request;
     $ident = Yii::$app->user->getIdentity();
     $form = new ProfileForm();
     if ($request->isPost) {
         $form->load($request->bodyParams);
         if ($form->validate()) {
             $ident->attributes = $form->attributes;
             if ($ident->save()) {
                 $this->controller->redirect(['user/profile']);
                 return;
             }
         }
     } else {
         $form->attributes = $ident->attributes;
     }
     return $this->controller->render('edit-profile.tpl', ['user' => $ident, 'form' => $form]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProfileForm::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, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'birth_date' => $this->birth_date, 'phone' => $this->phone, 'mobile' => $this->mobile]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'account_activation_token', $this->account_activation_token])->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'middle_name', $this->middle_name])->andFilterWhere(['like', 'last_name', $this->last_name])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'notes', $this->notes]);
     return $dataProvider;
 }
Esempio n. 8
0
 public function actionProfile()
 {
     if (YII_DEBUG) {
         error_log("[Site::Profile]");
     }
     if (YII_DEBUG) {
         error_log("[Site::Profile] POST vars : " . json_encode(Yii::$app->request->post()));
     }
     if (\Yii::$app->user->isGuest && !Yii::$app->request->get('id')) {
         return $this->goHome();
     }
     $model = new ProfileForm();
     if (Yii::$app->request->isPost && Yii::$app->request->post('ProfileForm')) {
         $model->saveProfile();
     }
     if (!$model->isEditable) {
         $this->layout = 'unsigned';
     }
     return $this->render('profile', ['model' => $model]);
 }
 /**
  * Finds the ProfileForm model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ProfileForm the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ProfileForm::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 10
0
<?php

use app\models\Options;
use yii\helpers\Html;
use app\models\ProfileForm;
$profile = ProfileForm::find()->where(['id' => $model->teacher_id])->one();
$this->title = implode(' ', [$model->teacher->first_name, $model->teacher->middle_name, $model->teacher->last_name]);
?>
<p></p>
<div class="ui two column stackable grid">  
    <div class="four wide column">
        <div class="column">
            <?php 
echo $this->render('_card', ['model' => $model]);
?>
        </div>
    </div>
    <div class="nine wide column">
        <div class="column">
            <?php 
echo $this->render('_detail', ['model' => $model, 'profile' => $profile]);
?>
        </div>
    </div>
    <div class="three wide column">
        <div class="column">
            <?php 
echo Options::render(['scenario' => Yii::$app->controller->action->id, 'id' => $model->id]);
?>
        </div>
    </div>
Esempio n. 11
0
 /**
  * render Profile.php with $model as ProfileForm if found profile;
  * render Say.php with array.key = title, message
  * 
  * @return $this->render('JoinGroup', array) or $this->render('Say', array)
  */
 public function actionProfile()
 {
     $id = \Yii::$app->user->getId();
     $user = User::findOne($id);
     //$profile = new ProfileForm();
     $profile = ProfileForm::findOne($user->username);
     if ($profile->load(Yii::$app->request->post()) && $profile->validate()) {
         if ($profile->save()) {
             return $this->render('say', ['title' => 'successfully', 'message' => '<3>You submited your profile successfully!</h3>']);
         }
     }
     return $this->render('profile', ['model' => $profile]);
 }
Esempio n. 12
0
 public function processFileField($formAttribute, $dbObject)
 {
     if (YII_DEBUG) {
         error_log("[ProfileForm::processFileField] formAttribute : {$formAttribute}");
     }
     if (YII_DEBUG) {
         error_log("[ProfileForm::processFileField] for object : " . get_class($dbObject));
     }
     $file = UploadedFile::getInstance($this, $formAttribute);
     if ($file && $this->validateFile($file, $formAttribute)) {
         $filename = ProfileForm::getUniqueFileName("{$formAttribute}_", $file->extension);
         if (YII_DEBUG) {
             error_log("[ProfileForm::processFileField] name for new file : {$filename}");
         }
         if (!$file->saveAs(Yii::getAlias('@app/web/uploads/') . $filename)) {
             Yii::$app->session->setFlash($formAttribute, 'Problems due file uploading.. Try another one.');
         } else {
             if (0 < strlen($dbObject->{$formAttribute}) && file_exists(Yii::getAlias('@app/web/uploads/') . $dbObject->{$formAttribute})) {
                 if (YII_DEBUG) {
                     error_log("[ProfileForm::processFileField] unlinking old file : " . $dbObject->{$formAttribute});
                 }
                 unlink(Yii::getAlias('@app/web/uploads/') . $dbObject->{$formAttribute});
             }
             if (YII_DEBUG) {
                 error_log("[ProfileForm::processFileField] set new filename for user : {$filename}");
             }
             $dbObject->{$formAttribute} = $filename;
             if (YII_DEBUG) {
                 error_log("[ProfileForm::processFileField] user {$formAttribute} : {$dbObject->{$formAttribute}}");
             }
         }
     } else {
         if (YII_DEBUG) {
             error_log("[ProfileForm::processFileField] file was not uploaded or not valid");
         }
     }
 }
Esempio n. 13
0
/* @var $form yii\widgets\ActiveForm */
$avatar = Yii::$app->request->baseUrl . Yii::$app->params['avatar'];
?>

<div class="data-request-form">

    <?php 
$form = ActiveForm::begin();
?>
        <div class="ui three column stackable grid">
            <div class="four wide rounded column">
                <div class="ui center aligned stackable cards">
                    <div class="card">
                        <div class="image">
                            <?php 
$userRequest = ProfileForm::findOne($model->user_id);
?>
                            <?php 
if (!empty(DataHelper::profileImage($model->user_id))) {
    ?>
                                <?php 
    echo Html::img(['/file', 'id' => DataHelper::profileImage($model->user_id)]);
    ?>
                            <?php 
} else {
    ?>
                                <?php 
    echo Html::img([Yii::$app->params['avatar'], ['alt' => 'user', 'class' => 'tiny image']]);
    ?>
                            <?php 
}