本文整理汇总了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');
}
}