summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rw-r--r--classes/Avatar.php2
-rw-r--r--classes/Config.php4
-rw-r--r--classes/Fave.php2
-rw-r--r--classes/File.php33
-rw-r--r--classes/File_to_post.php2
-rw-r--r--classes/Group_block.php2
-rw-r--r--classes/Group_inbox.php2
-rw-r--r--classes/Group_member.php2
-rw-r--r--classes/Notice.php67
-rw-r--r--classes/Notice_inbox.php2
-rw-r--r--classes/Notice_tag.php2
-rw-r--r--classes/Profile.php1
-rw-r--r--classes/Profile_role.php2
-rw-r--r--classes/Queue_item.php2
-rw-r--r--classes/Subscription.php2
-rw-r--r--classes/User.php24
-rw-r--r--classes/User_location_prefs.php53
-rw-r--r--classes/User_username.php61
-rw-r--r--classes/statusnet.ini14
19 files changed, 234 insertions, 45 deletions
diff --git a/classes/Avatar.php b/classes/Avatar.php
index 8d6424e8b..91bde0f04 100644
--- a/classes/Avatar.php
+++ b/classes/Avatar.php
@@ -37,7 +37,7 @@ class Avatar extends Memcached_DataObject
}
}
- function &pkeyGet($kv)
+ function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Avatar', $kv);
}
diff --git a/classes/Config.php b/classes/Config.php
index 390d75381..43b99587f 100644
--- a/classes/Config.php
+++ b/classes/Config.php
@@ -59,7 +59,7 @@ class Config extends Memcached_DataObject
if (!empty($c)) {
$settings = $c->get(common_cache_key(self::settingsKey));
- if (!empty($settings)) {
+ if ($settings !== false) {
return $settings;
}
}
@@ -120,7 +120,7 @@ class Config extends Memcached_DataObject
return $result;
}
- function &pkeyGet($kv)
+ function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Config', $kv);
}
diff --git a/classes/Fave.php b/classes/Fave.php
index 11e876ff1..8113c8e16 100644
--- a/classes/Fave.php
+++ b/classes/Fave.php
@@ -32,7 +32,7 @@ class Fave extends Memcached_DataObject
return $fave;
}
- function &pkeyGet($kv)
+ function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Fave', $kv);
}
diff --git a/classes/File.php b/classes/File.php
index 03d9ca6f0..c527c4ffe 100644
--- a/classes/File.php
+++ b/classes/File.php
@@ -189,25 +189,32 @@ class File extends Memcached_DataObject
static function url($filename)
{
- $path = common_config('attachments', 'path');
+ if(common_config('site','private')) {
- if ($path[strlen($path)-1] != '/') {
- $path .= '/';
- }
+ return common_local_url('getfile',
+ array('filename' => $filename));
- if ($path[0] != '/') {
- $path = '/'.$path;
- }
+ } else {
+ $path = common_config('attachments', 'path');
- $server = common_config('attachments', 'server');
+ if ($path[strlen($path)-1] != '/') {
+ $path .= '/';
+ }
- if (empty($server)) {
- $server = common_config('site', 'server');
- }
+ if ($path[0] != '/') {
+ $path = '/'.$path;
+ }
+
+ $server = common_config('attachments', 'server');
- // XXX: protocol
+ if (empty($server)) {
+ $server = common_config('site', 'server');
+ }
- return 'http://'.$server.$path.$filename;
+ // XXX: protocol
+
+ return 'http://'.$server.$path.$filename;
+ }
}
function getEnclosure(){
diff --git a/classes/File_to_post.php b/classes/File_to_post.php
index e3db91b20..72a42b088 100644
--- a/classes/File_to_post.php
+++ b/classes/File_to_post.php
@@ -62,7 +62,7 @@ class File_to_post extends Memcached_DataObject
}
}
- function &pkeyGet($kv)
+ function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('File_to_post', $kv);
}
diff --git a/classes/Group_block.php b/classes/Group_block.php
index de2cf5f6e..9f4d59295 100644
--- a/classes/Group_block.php
+++ b/classes/Group_block.php
@@ -40,7 +40,7 @@ class Group_block extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
- function &pkeyGet($kv)
+ function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Group_block', $kv);
}
diff --git a/classes/Group_inbox.php b/classes/Group_inbox.php
index 1af7439f7..2a0787e38 100644
--- a/classes/Group_inbox.php
+++ b/classes/Group_inbox.php
@@ -20,7 +20,7 @@ class Group_inbox extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
- function &pkeyGet($kv)
+ function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Group_inbox', $kv);
}
diff --git a/classes/Group_member.php b/classes/Group_member.php
index 3c23a991f..069b2c7a1 100644
--- a/classes/Group_member.php
+++ b/classes/Group_member.php
@@ -21,7 +21,7 @@ class Group_member extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
- function &pkeyGet($kv)
+ function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Group_member', $kv);
}
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;
+ }
}
diff --git a/classes/Notice_inbox.php b/classes/Notice_inbox.php
index d3ddad656..e350e6e2f 100644
--- a/classes/Notice_inbox.php
+++ b/classes/Notice_inbox.php
@@ -101,7 +101,7 @@ class Notice_inbox extends Memcached_DataObject
return $ids;
}
- function &pkeyGet($kv)
+ function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Notice_inbox', $kv);
}
diff --git a/classes/Notice_tag.php b/classes/Notice_tag.php
index 02740280f..79231f0b0 100644
--- a/classes/Notice_tag.php
+++ b/classes/Notice_tag.php
@@ -96,7 +96,7 @@ class Notice_tag extends Memcached_DataObject
}
}
- function &pkeyGet($kv)
+ function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Notice_tag', $kv);
}
diff --git a/classes/Profile.php b/classes/Profile.php
index 03196447b..25d908dbf 100644
--- a/classes/Profile.php
+++ b/classes/Profile.php
@@ -504,6 +504,7 @@ class Profile extends Memcached_DataObject
'Reply',
'Group_member',
);
+ Event::handle('ProfileDeleteRelated', array($this, &$related));
foreach ($related as $cls) {
$inst = new $cls();
diff --git a/classes/Profile_role.php b/classes/Profile_role.php
index afa7fb74e..74aca3730 100644
--- a/classes/Profile_role.php
+++ b/classes/Profile_role.php
@@ -43,7 +43,7 @@ class Profile_role extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
- function &pkeyGet($kv)
+ function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Profile_role', $kv);
}
diff --git a/classes/Queue_item.php b/classes/Queue_item.php
index 295c321b5..9c673540d 100644
--- a/classes/Queue_item.php
+++ b/classes/Queue_item.php
@@ -55,7 +55,7 @@ class Queue_item extends Memcached_DataObject
return null;
}
- function &pkeyGet($kv)
+ function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Queue_item', $kv);
}
diff --git a/classes/Subscription.php b/classes/Subscription.php
index fedfd5f19..faf1331cd 100644
--- a/classes/Subscription.php
+++ b/classes/Subscription.php
@@ -46,7 +46,7 @@ class Subscription extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
- function &pkeyGet($kv)
+ function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Subscription', $kv);
}
diff --git a/classes/User.php b/classes/User.php
index 6708d95b6..34151778c 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -996,4 +996,28 @@ class User extends Memcached_DataObject
return $ids;
}
+
+ function shareLocation()
+ {
+ $cfg = common_config('location', 'share');
+
+ if ($cfg == 'always') {
+ return true;
+ } else if ($cfg == 'never') {
+ return false;
+ } else { // user
+ $share = true;
+
+ $prefs = User_location_prefs::staticGet('user_id', $this->id);
+
+ if (empty($prefs)) {
+ $share = common_config('location', 'sharedefault');
+ } else {
+ $share = $prefs->share_location;
+ $prefs->free();
+ }
+
+ return $share;
+ }
+ }
}
diff --git a/classes/User_location_prefs.php b/classes/User_location_prefs.php
new file mode 100644
index 000000000..bd6029f97
--- /dev/null
+++ b/classes/User_location_prefs.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Data class for user location preferences
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Data
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @copyright 2009 StatusNet Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
+
+class User_location_prefs extends Memcached_DataObject
+{
+ ###START_AUTOCODE
+ /* the code below is auto generated do not remove the above tag */
+
+ public $__table = 'user_location_prefs'; // table name
+ public $user_id; // int(4) primary_key not_null
+ public $share_location; // tinyint(1) default_1
+ public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
+ public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
+
+ /* Static get */
+ function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('User_location_prefs',$k,$v); }
+
+ /* the code above is auto generated do not remove the tag below */
+ ###END_AUTOCODE
+
+ function sequenceKey()
+ {
+ return array(false, false, false);
+ }
+}
diff --git a/classes/User_username.php b/classes/User_username.php
new file mode 100644
index 000000000..853fd5cb8
--- /dev/null
+++ b/classes/User_username.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ * Table Definition for user_username
+ */
+require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
+
+class User_username extends Memcached_DataObject
+{
+ ###START_AUTOCODE
+ /* the code below is auto generated do not remove the above tag */
+
+ public $__table = 'user_username'; // table name
+ public $user_id; // int(4) not_null
+ public $provider_name; // varchar(255) primary_key not_null
+ public $username; // varchar(255) primary_key not_null
+ public $created; // datetime() not_null
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
+
+ /* Static get */
+ function staticGet($k,$v=null)
+ { return Memcached_DataObject::staticGet('User_username',$k,$v); }
+
+ /* the code above is auto generated do not remove the tag below */
+ ###END_AUTOCODE
+
+ /**
+ * Register a user with a username on a given provider
+ * @param User User object
+ * @param string username on the given provider
+ * @param provider_name string name of the provider
+ * @return mixed User_username instance if the registration succeeded, false if it did not
+ */
+ static function register($user, $username, $provider_name)
+ {
+ $user_username = new User_username();
+ $user_username->user_id = $user->id;
+ $user_username->provider_name = $provider_name;
+ $user_username->username = $username;
+ $user_username->created = DB_DataObject_Cast::dateTime();
+ if($user_username->insert()){
+ return $user_username;
+ }else{
+ return false;
+ }
+ }
+
+ function table() {
+ return array(
+ 'user_id' => DB_DATAOBJECT_INT,
+ 'username' => DB_DATAOBJECT_STR,
+ 'provider_name' => DB_DATAOBJECT_STR ,
+ 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME
+ );
+ }
+
+ // now define the keys.
+ function keys() {
+ return array('provider_name', 'username');
+ }
+
+}
diff --git a/classes/statusnet.ini b/classes/statusnet.ini
index 2cc37dbfe..0db2c5d6e 100644
--- a/classes/statusnet.ini
+++ b/classes/statusnet.ini
@@ -1,4 +1,3 @@
-
[avatar]
profile_id = 129
original = 17
@@ -93,6 +92,7 @@ modified = 384
[file__keys]
id = N
+url = U
[file_oembed]
file_id = 129
@@ -564,4 +564,14 @@ modified = 384
[user_openid__keys]
trustroot = K
-user_id = K \ No newline at end of file
+user_id = K
+
+[user_location_prefs]
+user_id = 129
+share_location = 17
+created = 142
+modified = 384
+
+[user_location_prefs__keys]
+user_id = K
+