public function __construct()
 {
     parent::__construct();
     $oUserModel = new UserModel();
     $iProfileId = AdminCore::auth() && !User::auth() && $this->httpRequest->getExists('profile_id') ? $this->httpRequest->get('profile_id', 'int') : $this->session->get('member_id');
     $oUser = $oUserModel->readProfile($iProfileId);
     // For Admins only!
     if (AdminCore::auth() && !User::auth() && $this->httpRequest->getExists('profile_id')) {
         if (!$this->str->equals($this->httpRequest->post('group_id'), $oUser->groupId)) {
             $oUserModel->updateMembership($this->httpRequest->post('group_id'), $iProfileId);
         }
     }
     if (!$this->str->equals($this->httpRequest->post('first_name'), $oUser->firstName)) {
         $oUserModel->updateProfile('firstName', $this->httpRequest->post('first_name'), $iProfileId);
         $this->session->set('member_first_name', $this->httpRequest->post('first_name'));
         (new Framework\Cache\Cache())->start(UserCoreModel::CACHE_GROUP, 'firstName' . $iProfileId . 'Members', null)->clear();
     }
     if (!$this->str->equals($this->httpRequest->post('last_name'), $oUser->lastName)) {
         $oUserModel->updateProfile('lastName', $this->httpRequest->post('last_name'), $iProfileId);
     }
     if (!$this->str->equals($this->httpRequest->post('sex'), $oUser->sex)) {
         $oUserModel->updateProfile('sex', $this->httpRequest->post('sex'), $iProfileId);
         $this->session->set('member_sex', $this->httpRequest->post('sex'));
         (new Framework\Cache\Cache())->start(UserCoreModel::CACHE_GROUP, 'sex' . $iProfileId . 'Members', null)->clear();
     }
     // WARNING: Be careful, you should use the \PH7\Framework\Mvc\Request\Http::ONLY_XSS_CLEAN constant, otherwise the Request\Http::post() method removes the special tags
     // and damages the SET function SQL for entry into the database.
     if (!$this->str->equals($this->httpRequest->post('match_sex', Http::ONLY_XSS_CLEAN), $oUser->matchSex)) {
         $oUserModel->updateProfile('matchSex', Form::setVal($this->httpRequest->post('match_sex', Http::ONLY_XSS_CLEAN)), $iProfileId);
     }
     if (!$this->str->equals($this->dateTime->get($this->httpRequest->post('birth_date'))->date('Y-m-d'), $oUser->birthDate)) {
         $oUserModel->updateProfile('birthDate', $this->dateTime->get($this->httpRequest->post('birth_date'))->date('Y-m-d'), $iProfileId);
     }
     // Update dynamic fields.
     $oFields = $oUserModel->getInfoFields($iProfileId);
     foreach ($oFields as $sColumn => $sValue) {
         $sHRParam = $sColumn == 'description' ? Http::ONLY_XSS_CLEAN : null;
         if (!$this->str->equals($this->httpRequest->post($sColumn, $sHRParam), $sValue)) {
             $oUserModel->updateProfile($sColumn, $this->httpRequest->post($sColumn, $sHRParam), $iProfileId, 'MembersInfo');
         }
     }
     unset($oFields);
     $oUserModel->setLastEdit($iProfileId);
     /*** Clear caches ***/
     $oUserCache = new User();
     $oUserCache->clearReadProfileCache($iProfileId);
     $oUserCache->clearInfoFieldCache($iProfileId);
     // Destroy objects
     unset($oUserModel, $oUser, $oUserCache);
     \PFBC\Form::setSuccess('form_user_edit_account', t('Your profile has been saved successfully!'));
 }
Пример #2
0
 public function step2()
 {
     $iProfileId = $this->oUserModel->getId($this->session->get('mail_step1'));
     $sBirthDate = $this->dateTime->get($this->httpRequest->post('birth_date'))->date('Y-m-d');
     // WARNING FOT "matchSex" FIELD: Be careful, you should use the \PH7\Framework\Mvc\Request\Http::ONLY_XSS_CLEAN constant otherwise the post method of the HttpRequest class removes the tags special
     // and damages the SET function SQL for entry into the database
     $aData1 = ['sex' => $this->httpRequest->post('sex'), 'match_sex' => Form::setVal($this->httpRequest->post('match_sex', Http::ONLY_XSS_CLEAN)), 'birth_date' => $sBirthDate, 'profile_id' => $iProfileId];
     $aData2 = ['country' => $this->httpRequest->post('country'), 'city' => $this->httpRequest->post('city'), 'state' => $this->httpRequest->post('state'), 'zip_code' => $this->httpRequest->post('zip_code'), 'profile_id' => $iProfileId];
     if (!$this->oUserModel->exe($aData1, '2_1') || !$this->oUserModel->exe($aData2, '2_2')) {
         \PFBC\Form::setError('form_join_user2', t('An error occurred during registration!<br /> Please try again with other information in the form fields or come back later.'));
     } else {
         // Register successfully in database for step 2!
         $this->session->set('mail_step2', $this->session->get('mail_step1'));
         HeaderUrl::redirect(Uri::get('user', 'signup', 'step3'));
     }
 }
Пример #3
0
 /**
  * Adding a User.
  *
  * @param array $aData
  * @return integer The ID of the User.
  */
 public function add(array $aData)
 {
     $rStmt = Db::getInstance()->prepare('INSERT INTO' . Db::prefix('Members') . '(email, username, password, firstName, lastName, sex, matchSex, birthDate, active, ip, hashValidation, joinDate, lastActivity, groupId)
         VALUES (:email, :username, :password, :firstName, :lastName, :sex, :matchSex, :birthDate, :active, :ip, :hashValidation, :joinDate, :lastActivity, :groupId)');
     $rStmt->bindValue(':email', trim($aData['email']), \PDO::PARAM_STR);
     $rStmt->bindValue(':username', trim($aData['username']), \PDO::PARAM_STR);
     $rStmt->bindValue(':password', Security::hashPwd($aData['password']), \PDO::PARAM_STR);
     $rStmt->bindValue(':firstName', $aData['first_name'], \PDO::PARAM_STR);
     $rStmt->bindValue(':lastName', $aData['last_name'], \PDO::PARAM_STR);
     $rStmt->bindValue(':sex', $aData['sex'], \PDO::PARAM_STR);
     $rStmt->bindValue(':matchSex', Form::setVal($aData['match_sex']), \PDO::PARAM_STR);
     $rStmt->bindValue(':birthDate', $aData['birth_date'], \PDO::PARAM_STR);
     $rStmt->bindValue(':active', !empty($aData['is_active']) ? $aData['is_active'] : 1, \PDO::PARAM_INT);
     $rStmt->bindValue(':ip', $aData['ip'], \PDO::PARAM_STR);
     $rStmt->bindParam(':hashValidation', !empty($aData['hash_validation']) ? $aData['hash_validation'] : null, \PDO::PARAM_STR, 40);
     $rStmt->bindValue(':joinDate', $this->sCurrentDate, \PDO::PARAM_STR);
     $rStmt->bindValue(':lastActivity', $this->sCurrentDate, \PDO::PARAM_STR);
     $rStmt->bindValue(':groupId', (int) DbConfig::getSetting('defaultMembershipGroupId'), \PDO::PARAM_INT);
     $rStmt->execute();
     $this->setKeyId(Db::getInstance()->lastInsertId());
     // Set the user's ID
     Db::free($rStmt);
     $this->setInfoFields($aData);
     $this->setDefaultPrivacySetting();
     $this->setDefaultNotification();
     return $this->getKeyId();
 }