X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fprofilesettings.php;h=0d6777879193af2e9d66e662a3737ebd396fc062;hb=bd6571c2e17939b21e01afd3772acb5cebbbadfe;hp=acfcbcd00747e38832124cc9e78139786f1700bd;hpb=71b7bdbcbee1529822a4e981ab9add240cc88113;p=quix0rs-gnu-social.git diff --git a/actions/profilesettings.php b/actions/profilesettings.php index acfcbcd007..0d67778791 100644 --- a/actions/profilesettings.php +++ b/actions/profilesettings.php @@ -133,6 +133,13 @@ class ProfilesettingsAction extends AccountSettingsAction ($this->arg('location')) ? $this->arg('location') : $profile->location, _('Where you are, like "City, State (or Region), Country"')); $this->elementEnd('li'); + if (common_config('location', 'share') == 'user') { + $this->elementStart('li'); + $this->checkbox('sharelocation', _('Share my current location when posting notices'), + ($this->arg('sharelocation')) ? + $this->arg('sharelocation') : $user->shareLocation()); + $this->elementEnd('li'); + } Event::handle('EndProfileFormData', array($this)); $this->elementStart('li'); $this->input('tags', _('Tags'), @@ -309,7 +316,12 @@ class ProfilesettingsAction extends AccountSettingsAction $loc = Location::fromName($location); - if (!empty($loc)) { + if (empty($loc)) { + $profile->lat = null; + $profile->lon = null; + $profile->location_id = null; + $profile->location_ns = null; + } else { $profile->lat = $loc->lat; $profile->lon = $loc->lon; $profile->location_id = $loc->location_id; @@ -318,6 +330,37 @@ class ProfilesettingsAction extends AccountSettingsAction $profile->profileurl = common_profile_url($nickname); + if (common_config('location', 'share') == 'user') { + + $exists = false; + + $prefs = User_location_prefs::staticGet('user_id', $user->id); + + if (empty($prefs)) { + $prefs = new User_location_prefs(); + + $prefs->user_id = $user->id; + $prefs->created = common_sql_now(); + } else { + $exists = true; + $orig = clone($prefs); + } + + $prefs->share_location = $this->boolean('sharelocation'); + + if ($exists) { + $result = $prefs->update($orig); + } else { + $result = $prefs->insert(); + } + + if ($result === false) { + common_log_db_error($prefs, ($exists) ? 'UPDATE' : 'INSERT', __FILE__); + $this->serverError(_('Couldn\'t save location prefs.')); + return; + } + } + common_debug('Old profile: ' . common_log_objstring($orig_profile), __FILE__); common_debug('New profile: ' . common_log_objstring($profile), __FILE__);