]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
remove namespace setting from location; it's unused
authorEvan Prodromou <evan@status.net>
Mon, 28 Dec 2009 22:21:07 +0000 (14:21 -0800)
committerEvan Prodromou <evan@status.net>
Mon, 28 Dec 2009 22:21:07 +0000 (14:21 -0800)
actions/newnotice.php
actions/profilesettings.php
classes/User.php
lib/default.php

index c014f1781cd9b380b46a160e3113bc846057327f..8591522dc55e9c8f9476a42aab52a0cc3e672989 100644 (file)
@@ -164,19 +164,6 @@ class NewnoticeAction extends Action
             $replyto = 'false';
         }
 
-        $lat = $this->trimmed('lat');
-        $lon = $this->trimmed('lon');
-        $location_id = $this->trimmed('location_id');
-        $location_ns = $this->trimmed('location_ns');
-
-        if (!empty($lat) && !empty($lon) && empty($location_id)) {
-            $location = Location::fromLatLon($lat, $lon);
-            if (!empty($location)) {
-                $location_id = $location->location_id;
-                $location_ns = $location->location_ns;
-            }
-        }
-
         $upload = null;
         $upload = MediaFile::fromUpload('attach');
 
@@ -195,12 +182,30 @@ class NewnoticeAction extends Action
             }
         }
 
-        $notice = Notice::saveNew($user->id, $content_shortened, 'web',
-                                  array('reply_to' => ($replyto == 'false') ? null : $replyto,
-                                        'lat' => $lat,
-                                        'lon' => $lon,
-                                        'location_id' => $location_id,
-                                        'location_ns' => $location_ns));
+        $options = array('reply_to' => ($replyto == 'false') ? null : $replyto);
+
+        if ($user->shareLocation()) {
+
+            $lat = $this->trimmed('lat');
+            $lon = $this->trimmed('lon');
+            $location_id = $this->trimmed('location_id');
+            $location_ns = $this->trimmed('location_ns');
+
+            if (!empty($lat) && !empty($lon) && empty($location_id)) {
+                $location = Location::fromLatLon($lat, $lon);
+                if (!empty($location)) {
+                    $location_id = $location->location_id;
+                    $location_ns = $location->location_ns;
+                }
+            }
+
+            $options['lat'] = $lat;
+            $options['lon'] = $lon;
+            $options['location_id'] = $location_id;
+            $options['location_ns'] = $location_ns;
+        }
+
+        $notice = Notice::saveNew($user->id, $content_shortened, 'web', $options);
 
         if (isset($upload)) {
             $upload->attachToNotice($notice);
index 359664096ee8a3a715ae02b703902922bf617790..58bf838d76b550309c6b60cfc999354605d2e32f 100644 (file)
@@ -133,6 +133,11 @@ class ProfilesettingsAction extends AccountSettingsAction
                          ($this->arg('location')) ? $this->arg('location') : $profile->location,
                          _('Where you are, like "City, State (or Region), Country"'));
             $this->elementEnd('li');
+            $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'),
index 6708d95b6a52fea1dd6ba52abe79783ff5f7e545..2bcb7c2a0a1336918b2f30e0e461ef8da9f9c071 100644 (file)
@@ -996,4 +996,20 @@ class User extends Memcached_DataObject
 
         return $ids;
     }
+
+    function shareLocation()
+    {
+        $share = true;
+
+        $prefs = User_location_prefs::staticGet('user_id', $this->id);
+
+        if (empty($prefs)) {
+            $share = common_config('location', 'share');
+        } else {
+            $share = $prefs->share_location;
+            $prefs->free();
+        }
+
+        return $share;
+    }
 }
index 42d4623b1ef9ea9558eca9f30213a459c801a1bd..b5eda7b2cf2650d16da116e902a4184a44fb217c 100644 (file)
@@ -226,7 +226,7 @@ $default =
         'message' =>
         array('contentlimit' => null),
         'location' =>
-        array('namespace' => 1), // 1 = geonames, 2 = Yahoo Where on Earth
+        array(),
         'omb' =>
         array('timeout' => 5), // HTTP request timeout in seconds when contacting remote hosts for OMB updates
         'logincommand' =>