X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FNotice.php;h=3e55bd6fa5b1c6e0294730883ed551b77ad8142f;hb=90a2563a90e1bf2239d177a564bbe3e838d93dc4;hp=93e94230d9c5e45a640db78fa82cf5b85ef0578c;hpb=d32fb7c7c40e3d5fa67496d5df0574fc9c2e0151;p=quix0rs-gnu-social.git diff --git a/classes/Notice.php b/classes/Notice.php index 93e94230d9..3e55bd6fa5 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -289,21 +289,11 @@ class Notice extends Memcached_DataObject if (!empty($lat) && !empty($lon)) { $notice->lat = $lat; $notice->lon = $lon; + } + + if (!empty($location_ns) && !empty($location_id)) { $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))) { @@ -1429,4 +1419,47 @@ class Notice extends Memcached_DataObject return $ids; } + + function locationOptions($lat, $lon, $location_id, $location_ns, $profile = null) + { + $options = array(); + + if (!empty($location_id) && !empty($location_ns)) { + + $options['location_id'] = $location_id; + $options['location_ns'] = $location_ns; + + $location = Location::fromId($location_id, $location_ns); + + if (!empty($location)) { + $options['lat'] = $location->lat; + $options['lon'] = $location->lon; + } + + } else if (!empty($lat) && !empty($lon)) { + + $options['lat'] = $lat; + $options['lon'] = $lon; + + $location = Location::fromLatLon($lat, $lon); + + if (!empty($location)) { + $options['location_id'] = $location->location_id; + $options['location_ns'] = $location->location_ns; + } + } else if (!empty($profile)) { + + if (isset($profile->lat) && isset($profile->lon)) { + $options['lat'] = $profile->lat; + $options['lon'] = $profile->lon; + } + + if (isset($profile->location_id) && isset($profile->location_ns)) { + $options['location_id'] = $profile->location_id; + $options['location_ns'] = $profile->location_ns; + } + } + + return $options; + } }