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


PHP UserProfile::setMiles方法代码示例

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


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

示例1: 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


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