From fbe794e44d235d2f66ef418796f87947631afb6a Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 3 Mar 2009 16:12:05 +0100 Subject: 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) --- lib/profilelist.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/profilelist.php') diff --git a/lib/profilelist.php b/lib/profilelist.php index c2040fbc2..75053b7a4 100644 --- a/lib/profilelist.php +++ b/lib/profilelist.php @@ -102,13 +102,13 @@ class ProfileList extends Widget 'alt' => ($this->profile->fullname) ? $this->profile->fullname : $this->profile->nickname)); - $hasFN = ($this->profile->fullname) ? 'nickname' : 'fn nickname'; + $hasFN = ($this->profile->fullname !== '') ? 'nickname' : 'fn nickname'; $this->out->elementStart('span', $hasFN); $this->out->raw($this->highlight($this->profile->nickname)); $this->out->elementEnd('span'); $this->out->elementEnd('a'); - if ($this->profile->fullname) { + if ($this->profile->fullname !== '') { $this->out->elementStart('dl', 'entity_fn'); $this->out->element('dt', null, 'Full name'); $this->out->elementStart('dd'); @@ -118,7 +118,7 @@ class ProfileList extends Widget $this->out->elementEnd('dd'); $this->out->elementEnd('dl'); } - if ($this->profile->location) { + if ($this->profile->location !== '') { $this->out->elementStart('dl', 'entity_location'); $this->out->element('dt', null, _('Location')); $this->out->elementStart('dd', 'label'); @@ -126,7 +126,7 @@ class ProfileList extends Widget $this->out->elementEnd('dd'); $this->out->elementEnd('dl'); } - if ($this->profile->homepage) { + if ($this->profile->homepage !== '') { $this->out->elementStart('dl', 'entity_url'); $this->out->element('dt', null, _('URL')); $this->out->elementStart('dd'); @@ -137,7 +137,7 @@ class ProfileList extends Widget $this->out->elementEnd('dd'); $this->out->elementEnd('dl'); } - if ($this->profile->bio) { + if ($this->profile->bio !== '') { $this->out->elementStart('dl', 'entity_note'); $this->out->element('dt', null, _('Note')); $this->out->elementStart('dd', 'note'); -- cgit v1.2.3-54-g00ecf From 00c14d22ded3868939f4999daa0a3c3e4203c20e Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 7 Mar 2009 01:43:55 +0100 Subject: Remove comparison with member variable of null variable, cleaned code a bit. --- lib/profilelist.php | 12 +++++------- lib/subgroupnav.php | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'lib/profilelist.php') diff --git a/lib/profilelist.php b/lib/profilelist.php index 75053b7a4..898200d2d 100644 --- a/lib/profilelist.php +++ b/lib/profilelist.php @@ -89,6 +89,7 @@ class ProfileList extends Widget 'id' => 'profile-' . $this->profile->id)); $user = common_current_user(); + $is_own = !is_null($user) && ($user->id === $this->user->id); $this->out->elementStart('div', 'entity_profile vcard'); @@ -154,7 +155,7 @@ class ProfileList extends Widget $this->out->elementStart('dl', 'entity_tags'); $this->out->elementStart('dt'); - if ($user->id == $this->owner->id) { + if ($is_own) { $this->out->element('a', array('href' => common_local_url('tagother', array('id' => $this->profile->id))), _('Tags')); @@ -183,7 +184,7 @@ class ProfileList extends Widget $this->out->elementEnd('dl'); } - if ($user && $user->id == $this->owner->id) { + if ($is_own) { $this->showOwnerControls($this->profile); } @@ -193,11 +194,11 @@ class ProfileList extends Widget $this->out->elementStart('ul'); - if ($user && $user->id != $this->profile->id) { + if (!$is_own) { # XXX: special-case for user looking at own # subscriptions page $this->out->elementStart('li', 'entity_subscribe'); - if ($user->isSubscribed($this->profile)) { + if (!is_null($user) && $user->isSubscribed($this->profile)) { $usf = new UnsubscribeForm($this->out, $this->profile); $usf->show(); } else { @@ -206,9 +207,6 @@ class ProfileList extends Widget } $this->out->elementEnd('li'); $this->out->elementStart('li', 'entity_block'); - if ($user && $user->id == $this->owner->id) { - $this->showBlockForm(); - } $this->out->elementEnd('li'); } diff --git a/lib/subgroupnav.php b/lib/subgroupnav.php index 5fd8a72a2..31c3ea0b5 100644 --- a/lib/subgroupnav.php +++ b/lib/subgroupnav.php @@ -98,7 +98,7 @@ class SubGroupNav extends Widget $this->user->nickname), $action == 'usergroups', 'nav_usergroups'); - if ($this->user->id == $cur->id) { + if (!is_null($cur) && $this->user->id === $cur->id) { $this->out->menuItem(common_local_url('invite'), _('Invite'), sprintf(_('Invite friends and colleagues to join you on %s'), -- cgit v1.2.3-54-g00ecf From c0db74dcfbff431970ae1d829e776f466f1c4091 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 7 Mar 2009 02:03:45 +0100 Subject: Another undefined object member. --- lib/profilelist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/profilelist.php') diff --git a/lib/profilelist.php b/lib/profilelist.php index 898200d2d..766189ab4 100644 --- a/lib/profilelist.php +++ b/lib/profilelist.php @@ -89,7 +89,7 @@ class ProfileList extends Widget 'id' => 'profile-' . $this->profile->id)); $user = common_current_user(); - $is_own = !is_null($user) && ($user->id === $this->user->id); + $is_own = !is_null($user) && isset($this->user) && ($user->id === $this->user->id); $this->out->elementStart('div', 'entity_profile vcard'); -- cgit v1.2.3-54-g00ecf