summaryrefslogtreecommitdiff
path: root/actions/newnotice.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-12-28 15:13:15 -0800
committerEvan Prodromou <evan@status.net>2009-12-28 15:59:24 -0800
commite3789be03f9e2d20aa74da1a10c4090b260d3359 (patch)
treeb19e12abeb1515a260e7e5b0a6635dda6ce24d10 /actions/newnotice.php
parentd96d1775d5e8613443d2e07d253b3269832c36c5 (diff)
Move location-argument-handling code into a single function
Moved the important parts of the location-argument-handling stuff to a single function. Handles defaults and overrides correctly, and easy to use. Changed Web and API channels to use it.
Diffstat (limited to 'actions/newnotice.php')
-rw-r--r--actions/newnotice.php22
1 files changed, 6 insertions, 16 deletions
diff --git a/actions/newnotice.php b/actions/newnotice.php
index 8591522dc..2d9f0ff79 100644
--- a/actions/newnotice.php
+++ b/actions/newnotice.php
@@ -186,23 +186,13 @@ class NewnoticeAction extends Action
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;
- }
- }
+ $locOptions = Notice::locationOptions($this->trimmed('lat'),
+ $this->trimmed('lon'),
+ $this->trimmed('location_id'),
+ $this->trimmed('location_ns'),
+ $user->getProfile());
- $options['lat'] = $lat;
- $options['lon'] = $lon;
- $options['location_id'] = $location_id;
- $options['location_ns'] = $location_ns;
+ $options = array_merge($options, $locOptions);
}
$notice = Notice::saveNew($user->id, $content_shortened, 'web', $options);