diff options
author | Adrian Lang <mail@adrianlang.de> | 2009-03-03 16:12:05 +0100 |
---|---|---|
committer | Adrian Lang <mail@adrianlang.de> | 2009-03-09 08:06:31 +0100 |
commit | fbe794e44d235d2f66ef418796f87947631afb6a (patch) | |
tree | 0ce90398638bdb938ebab6b3b400a3aaece0cc90 /actions | |
parent | 6ab9d6b14016cf97fe1a31d89591e1a0e919c8a7 (diff) |
Improve handling of null values in profile parameters.
This commit fixes two issues:
- Allowing remote users to clear profile parameters via OMB.
- Improved handling of profile parameters which evaluate to
false ('0' for example)
Diffstat (limited to 'actions')
-rw-r--r-- | actions/finishremotesubscribe.php | 8 | ||||
-rw-r--r-- | actions/remotesubscribe.php | 8 | ||||
-rw-r--r-- | actions/updateprofile.php | 14 | ||||
-rw-r--r-- | actions/userauthorization.php | 26 |
4 files changed, 29 insertions, 27 deletions
diff --git a/actions/finishremotesubscribe.php b/actions/finishremotesubscribe.php index acfacbdc1..eaf57c2d8 100644 --- a/actions/finishremotesubscribe.php +++ b/actions/finishremotesubscribe.php @@ -136,16 +136,16 @@ class FinishremotesubscribeAction extends Action $profile->nickname = $nickname; $profile->profileurl = $profile_url; - if ($fullname) { + if (!is_null($fullname)) { $profile->fullname = $fullname; } - if ($homepage) { + if (!is_null($homepage)) { $profile->homepage = $homepage; } - if ($bio) { + if (!is_null($bio)) { $profile->bio = $bio; } - if ($location) { + if (!is_null($location)) { $profile->location = $location; } diff --git a/actions/remotesubscribe.php b/actions/remotesubscribe.php index 7ea7acd6d..a2e01bd3a 100644 --- a/actions/remotesubscribe.php +++ b/actions/remotesubscribe.php @@ -367,16 +367,16 @@ class RemotesubscribeAction extends Action return; } - if ($profile->fullname) { + if (!is_null($profile->fullname)) { $req->set_parameter('omb_listenee_fullname', $profile->fullname); } - if ($profile->homepage) { + if (!is_null($profile->homepage)) { $req->set_parameter('omb_listenee_homepage', $profile->homepage); } - if ($profile->bio) { + if (!is_null($profile->bio)) { $req->set_parameter('omb_listenee_bio', $profile->bio); } - if ($profile->location) { + if (!is_null($profile->location)) { $req->set_parameter('omb_listenee_location', $profile->location); } $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); diff --git a/actions/updateprofile.php b/actions/updateprofile.php index 2268c432f..7dc52fda9 100644 --- a/actions/updateprofile.php +++ b/actions/updateprofile.php @@ -138,22 +138,24 @@ class UpdateprofileAction extends Action $orig_profile = clone($profile); - if ($nickname) { + /* Use values even if they are an empty string. Parsing an empty string in + updateProfile is the specified way of clearing a parameter in OMB. */ + if (!is_null($nickname)) { $profile->nickname = $nickname; } - if ($profile_url) { + if (!is_null($profile_url)) { $profile->profileurl = $profile_url; } - if ($fullname) { + if (!is_null($fullname)) { $profile->fullname = $fullname; } - if ($homepage) { + if (!is_null($homepage)) { $profile->homepage = $homepage; } - if ($bio) { + if (!is_null($bio)) { $profile->bio = $bio; } - if ($location) { + if (!is_null($location)) { $profile->location = $location; } diff --git a/actions/userauthorization.php b/actions/userauthorization.php index 0566b4b70..6a76e3a4c 100644 --- a/actions/userauthorization.php +++ b/actions/userauthorization.php @@ -113,9 +113,9 @@ class UserauthorizationAction extends Action $this->element('a', array('href' => $profile, 'class' => 'external profile nickname'), $nickname); - if ($fullname) { + if (!is_null($fullname)) { $this->elementStart('div', 'fullname'); - if ($homepage) { + if (!is_null($homepage)) { $this->element('a', array('href' => $homepage), $fullname); } else { @@ -123,10 +123,10 @@ class UserauthorizationAction extends Action } $this->elementEnd('div'); } - if ($location) { + if (!is_null($location)) { $this->element('div', 'location', $location); } - if ($bio) { + if (!is_null($bio)) { $this->element('div', 'bio', $bio); } $this->elementStart('div', 'license'); @@ -179,16 +179,16 @@ class UserauthorizationAction extends Action $params['omb_listener_nickname'] = $user->nickname; $params['omb_listener_profile'] = common_local_url('showstream', array('nickname' => $user->nickname)); - if ($profile->fullname) { + if (!is_null($profile->fullname)) { $params['omb_listener_fullname'] = $profile->fullname; } - if ($profile->homepage) { + if (!is_null($profile->homepage)) { $params['omb_listener_homepage'] = $profile->homepage; } - if ($profile->bio) { + if (!is_null($profile->bio)) { $params['omb_listener_bio'] = $profile->bio; } - if ($profile->location) { + if (!is_null($profile->location)) { $params['omb_listener_location'] = $profile->location; } $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); @@ -267,16 +267,16 @@ class UserauthorizationAction extends Action $profile->nickname = $nickname; $profile->profileurl = $profile_url; - if ($fullname) { + if (!is_null($fullname)) { $profile->fullname = $fullname; } - if ($homepage) { + if (!is_null($homepage)) { $profile->homepage = $homepage; } - if ($bio) { + if (!is_null($bio)) { $profile->bio = $bio; } - if ($location) { + if (!is_null($location)) { $profile->location = $location; } @@ -409,7 +409,7 @@ class UserauthorizationAction extends Action 'omb_listenee_profile', 'omb_listenee_nickname', 'omb_listenee_license') as $param) { - if (!$req->get_parameter($param)) { + if (is_null($req->get_parameter($param))) { throw new OAuthException("Required parameter '$param' not found"); } } |