当前位置: 首页>>代码示例>>PHP>>正文


PHP Form::setVal方法代码示例

本文整理汇总了PHP中PH7\Form::setVal方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::setVal方法的具体用法?PHP Form::setVal怎么用?PHP Form::setVal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PH7\Form的用法示例。


在下文中一共展示了Form::setVal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 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!'));
 }
开发者ID:huangciyin,项目名称:pH7-Social-Dating-CMS,代码行数:51,代码来源:EditFormProcess.php

示例2: step2

 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'));
     }
 }
开发者ID:joswilson,项目名称:NotJustOK,代码行数:16,代码来源:JoinFormProcess.php

示例3: add

 /**
  * 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();
 }
开发者ID:joswilson,项目名称:NotJustOK,代码行数:33,代码来源:UserCoreModel.php


注:本文中的PH7\Form::setVal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。