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


PHP UserProfile::setUserId方法代码示例

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


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

示例1: configure

 public function configure()
 {
     //get profile object
     $user = $this->getObject();
     if (!$user->getUserProfile()) {
         $profile = UserProfilePeer::retrieveByPK($user->getUserId());
         if (!$profile) {
             $profile = new UserProfile();
             $profile->setUserId($user->getUserId());
         }
         $user->setUserProfile($profile);
     }
     // build state criteria
     // echo $profile->getCountry().'&';
     $stateC = new Criteria();
     $stateC->add(CpStatesPeer::COUNTRY_ID, $user->getUserProfile()->getCountry());
     // build city criteria
     $cityC = new Criteria();
     $cityC->add(CpCitiesPeer::STATE_ID, $user->getUserProfile()->getState());
     $this->setWidgets(array('country_id' => new sfWidgetFormPropelSelect(array('model' => 'CpCountries', 'add_empty' => '-- Country --', 'order_by' => array('Name', 'asc'))), 'state_id' => new sfWidgetFormPropelSelect(array('model' => 'CpStates', 'add_empty' => '-- State/Province --', 'order_by' => array('Name', 'asc'), 'criteria' => $stateC)), 'city_id' => new sfWidgetFormPropelSelect(array('model' => 'CpCities', 'add_empty' => '-- City --', 'order_by' => array('Name', 'asc'), 'criteria' => $cityC)), 'id' => new sfWidgetFormInputHidden()));
     $this->setValidators(array('country_id' => new sfValidatorPropelChoice(array('model' => 'CpCountries', 'column' => 'id'), array('required' => '- Please choose country', 'invalid' => '- Invalid country')), 'state_id' => new sfValidatorPropelChoice(array('model' => 'CpStates', 'column' => 'id', 'criteria' => clone $stateC), array('required' => '- Please choose state', 'invalid' => '- Invalid state')), 'city_id' => new sfValidatorPropelChoice(array('model' => 'CpCities', 'column' => 'id', 'criteria' => clone $cityC), array('required' => '- Please choose city', 'invalid' => '- Invalid city')), 'id' => new sfValidatorNumber(array('required' => false))));
     //$this->widgetSchema->setLabels(array(
     //	'name'	=> 'Name',
     //));
     $this->widgetSchema->setNameFormat('user[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
 }
开发者ID:broschb,项目名称:cyclebrain,代码行数:27,代码来源:UserProfileForm.php

示例2: executeEdit

 public function executeEdit($request)
 {
     $userId = sfContext::getInstance()->getUser()->getAttribute('subscriber_id', null, 'subscriber');
     $this->miles = true;
     $this->kilo = false;
     if ($userId) {
         $this->user = UsersPeer::retrieveByPK($userId);
     }
     $this->forward404Unless($this->user);
     if ($this->user) {
         $profile = UserProfilePeer::retrieveByPK($this->user->getUserId());
         if ($profile->getMiles() == 1) {
             $this->miles = true;
             $this->kilo = false;
         } else {
             $this->miles = false;
             $this->kilo = true;
         }
     }
     if (!$profile) {
         $profile = new UserProfile();
         $profile->setUserId($this->user->getUserId());
         $profile->setMiles(1);
     }
     $this->user->setUserProfile($profile);
     if ($request->isMethod('post')) {
         $userName = $this->getRequestParameter('userName');
         $fname = $this->getRequestParameter('fname');
         $lname = $this->getRequestParameter('lname');
         $email = $this->getRequestParameter('email');
         $bday = join("/", $this->getRequestParameter('bday'));
         $weight = $this->getRequestParameter('weight');
         $height = $this->getRequestParameter('height');
         $zip = $this->getRequestParameter('zip');
         $units = $this->getRequestParameter('units');
         $country = $this->getRequestParameter('country');
         $city = $this->getRequestParameter('city');
         $state = $this->getRequestParameter('state');
         //        sfContext::getInstance()->getLogger()->info($message);
         //make sure have profile
         if (!$this->user->getUserProfile()) {
             $profile = UserProfilePeer::retrieveByPK($user->getUserId());
             if ($profile) {
                 $this->user->setUserProfile($profile);
             } else {
                 $profile = new UserProfile();
                 $profile->setUserId($user->getUserId());
                 $profile->setMiles(1);
                 $profile->save();
                 $this->user->setUserProfile($profile);
             }
         }
         // pre-populate country, state and city in order to filter select boxes
         $profile = $this->user->getUserProfile();
         //set up profile data
         $profile->setBirthdate($bday);
         $profile->setWeight($weight);
         $profile->setHeight($height);
         $profile->setZip($zip);
         $profile->setCountry($country);
         $profile->setState($state);
         $profile->setCity($city);
         if ($units && count($units) > 0) {
             $u = $units[0];
             if ($u == "kilo") {
                 $profile->setMiles(0);
             } else {
                 $profile->setMiles(1);
             }
         } else {
             $profile->setMiles(1);
         }
         //set up user
         $this->user->setUsername($userName);
         $this->user->setFname($fname);
         $this->user->setLname($lname);
         $this->user->setEmail($email);
         $this->user->setUserProfile($profile);
         $this->user->save();
         $profile->save();
         //set mileage preference
         $this->getUser()->setAttribute('mileage', $profile->getMiles(), 'subscriber');
         return $this->redirect('users/profile');
     }
 }
开发者ID:broschb,项目名称:cyclebrain,代码行数:85,代码来源:actions.class.php

示例3: createUserAndProfile

 protected function createUserAndProfile($username, $con = null)
 {
     // no user with this username
     if (null === $con) {
         $con = Propel::getConnection(sfGuardUserPeer::DATABASE_NAME);
     }
     try {
         $con->begin();
         // create a new user object
         $user = new sfGuardUser();
         $user->setUsername($username);
         $user->setIsActive(1);
         $user->setAlgorithm('');
         $user->save($con);
         // do we have a profile in the system with this net_id?
         // this could happen if the profile was added manually by an admin
         $userProfile = UserProfilePeer::selectByNetIdWithNoUserId($username);
         if ($userProfile) {
             // there is already a dangling user profile with this net id, link the user with the profile
             $userProfile->setUserId($user->getId());
             $userProfile->save($con);
         } else {
             // make a new user profile
             $userProfile = new UserProfile();
             $userProfile->setUserId($user->getId());
             $userProfile->setNetId($user->getUsername());
             $userProfile->save($con);
         }
         $con->commit();
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
     return $user;
 }
开发者ID:stereoscott,项目名称:stKerberosPlugin,代码行数:35,代码来源:stKerberosValidator.php


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