summaryrefslogtreecommitdiff
path: root/classes/Notice.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/Notice.php')
-rw-r--r--classes/Notice.php67
1 files changed, 50 insertions, 17 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index c2ff7fd09..9bda47827 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -63,7 +63,7 @@ class Notice extends Memcached_DataObject
public $created; // datetime multiple_key not_null default_0000-00-00%2000%3A00%3A00
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
public $reply_to; // int(4)
- public $is_local; // tinyint(1)
+ public $is_local; // int(4)
public $source; // varchar(32)
public $conversation; // int(4)
public $lat; // decimal(10,7)
@@ -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))) {
@@ -1217,7 +1207,7 @@ class Notice extends Memcached_DataObject
$idstr = $cache->get($idkey);
- if (!empty($idstr)) {
+ if ($idstr !== false) {
// Cache hit! Woohoo!
$window = explode(',', $idstr);
$ids = array_slice($window, $offset, $limit);
@@ -1226,7 +1216,7 @@ class Notice extends Memcached_DataObject
$laststr = $cache->get($idkey.';last');
- if (!empty($laststr)) {
+ if ($laststr !== false) {
$window = explode(',', $laststr);
$last_id = $window[0];
$new_ids = call_user_func_array($fn, array_merge($args, array(0, NOTICE_CACHE_WINDOW,
@@ -1395,7 +1385,7 @@ class Notice extends Memcached_DataObject
$ids = $this->_repeatStreamDirect($limit);
} else {
$idstr = $cache->get(common_cache_key('notice:repeats:'.$this->id));
- if (!empty($idstr)) {
+ if ($idstr !== false) {
$ids = explode(',', $idstr);
} else {
$ids = $this->_repeatStreamDirect(100);
@@ -1438,4 +1428,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;
+ }
}