summaryrefslogtreecommitdiff
path: root/actions/profilesettings.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-12-28 15:49:27 -0800
committerEvan Prodromou <evan@status.net>2009-12-28 15:49:27 -0800
commite119362fde9eabb27d48c94a98624aeae68e436c (patch)
tree04d2e1fb5e1b2a5b64c4d0ef12b532397ec0a331 /actions/profilesettings.php
parent98a579fedf36ff795e255a4b345651df0ee230bc (diff)
parentca6669538a16f36f92df918d679671b95b1859ac (diff)
Merge branch 'locshunt' into 0.9.x
Diffstat (limited to 'actions/profilesettings.php')
-rw-r--r--actions/profilesettings.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/actions/profilesettings.php b/actions/profilesettings.php
index acfcbcd00..ee236fe62 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'),
@@ -318,6 +325,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__);