From d51d83434da53c0f30416e9b17cd25d61f554a68 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 21 Aug 2009 07:48:30 -0400 Subject: check and show max bio length in profilesettings --- actions/profilesettings.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'actions/profilesettings.php') diff --git a/actions/profilesettings.php b/actions/profilesettings.php index fb847680b..961e15ae7 100644 --- a/actions/profilesettings.php +++ b/actions/profilesettings.php @@ -109,9 +109,16 @@ class ProfilesettingsAction extends AccountSettingsAction _('URL of your homepage, blog, or profile on another site')); $this->elementEnd('li'); $this->elementStart('li'); + $maxBio = Profile::maxBio(); + if ($maxBio > 0) { + $bioInstr = sprintf(_('Describe yourself and your interests in %d chars'), + $maxBio); + } else { + $bioInstr = _('Describe yourself and your interests'); + } $this->textarea('bio', _('Bio'), ($this->arg('bio')) ? $this->arg('bio') : $profile->bio, - _('Describe yourself and your interests in 140 chars')); + $bioInstr); $this->elementEnd('li'); $this->elementStart('li'); $this->input('location', _('Location'), @@ -202,8 +209,9 @@ class ProfilesettingsAction extends AccountSettingsAction } else if (!is_null($fullname) && mb_strlen($fullname) > 255) { $this->showForm(_('Full name is too long (max 255 chars).')); return; - } else if (!is_null($bio) && mb_strlen($bio) > 140) { - $this->showForm(_('Bio is too long (max 140 chars).')); + } else if (Profile::bioTooLong($bio)) { + $this->showForm(sprintf(_('Bio is too long (max %d chars).'), + Profile::maxBio())); return; } else if (!is_null($location) && mb_strlen($location) > 255) { $this->showForm(_('Location is too long (max 255 chars).')); -- cgit v1.2.3-54-g00ecf From 967de946654e96793d11413a46067ac95b356a64 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 23 Oct 2009 11:47:00 -0400 Subject: update location while saving new profile --- actions/profilesettings.php | 10 ++++++++++ classes/Notice.php | 23 ++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) (limited to 'actions/profilesettings.php') diff --git a/actions/profilesettings.php b/actions/profilesettings.php index 5445d9bb2..0a0cc5997 100644 --- a/actions/profilesettings.php +++ b/actions/profilesettings.php @@ -306,6 +306,16 @@ class ProfilesettingsAction extends AccountSettingsAction $profile->homepage = $homepage; $profile->bio = $bio; $profile->location = $location; + + $loc = Location::fromName($location); + + if (!empty($loc)) { + $profile->lat = $loc->lat; + $profile->lon = $loc->lon; + $profile->location_id = $loc->location_id; + $profile->location_ns = $loc->location_ns; + } + $profile->profileurl = common_profile_url($nickname); common_debug('Old profile: ' . common_log_objstring($orig_profile), __FILE__); diff --git a/classes/Notice.php b/classes/Notice.php index 592f64426..7478f945d 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -168,7 +168,8 @@ class Notice extends Memcached_DataObject } static function saveNew($profile_id, $content, $source=null, - $is_local=Notice::LOCAL_PUBLIC, $reply_to=null, $uri=null, $created=null) { + $is_local=Notice::LOCAL_PUBLIC, $reply_to=null, $uri=null, $created=null, + $lat=null, $lon=null, $location_id=null, $location_ns=null) { $profile = Profile::staticGet($profile_id); @@ -234,6 +235,26 @@ class Notice extends Memcached_DataObject $notice->conversation = $reply->conversation; } + if (!empty($lat) && !empty($lon)) { + $notice->lat = $lat; + $notice->lon = $lon; + $notice->location_id = $location_id; + $notice->location_ns = $location_ns; + } else if (!empty($location_ns) && !empty($location_id)) { + $location = Location::fromId($location_id, $location_ns); + if (!empty($location)) { + $notice->lat = $location->lat; + $notice->lon = $location->lon; + $notice->location_id = $location_id; + $notice->location_ns = $location_ns; + } + } else { + $notice->lat = $profile->lat; + $notice->lon = $profile->lon; + $notice->location_id = $profile->location_id; + $notice->location_ns = $profile->location_ns; + } + if (Event::handle('StartNoticeSave', array(&$notice))) { // XXX: some of these functions write to the DB -- cgit v1.2.3-54-g00ecf From f7a3e508ba8d0f8f9487724f3e417554d1d0b4d8 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 18 Nov 2009 17:36:55 -0800 Subject: Check profile->update() result against false exactly; we may legitimately get 0 back if no rows were changed. DB objects normally would return true, but the comparisons aren't 100% reliable when we've got numbers which could be ints or strings or floats. Caused failures saving profile settings with Geonames plugin enabled; the lat/lon/id fields would get re-set with freshly looked up values which no longer matched the previous values as far as the data object could tell, but which saved as the same ol' numbers. --- actions/profilesettings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actions/profilesettings.php') diff --git a/actions/profilesettings.php b/actions/profilesettings.php index 0a0cc5997..359664096 100644 --- a/actions/profilesettings.php +++ b/actions/profilesettings.php @@ -323,7 +323,7 @@ class ProfilesettingsAction extends AccountSettingsAction $result = $profile->update($orig_profile); - if (!$result) { + if ($result === false) { common_log_db_error($profile, 'UPDATE', __FILE__); $this->serverError(_('Couldn\'t save profile.')); return; -- cgit v1.2.3-54-g00ecf