summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-08-24 16:55:49 -0400
committerEvan Prodromou <evan@controlyourself.ca>2009-08-24 16:55:49 -0400
commitff87732053bae38879988ba7d002a294998ccb4e (patch)
treeccccfe7fc8976baf1f0cd4438a57bf817dc4052c /classes
parent27aeba01dd366f15f7847267b7518fb873987ddb (diff)
parentf3cdc7f272e409d391979d3e6c58dd63573530c0 (diff)
Merge branch '0.8.x' into testing
Conflicts: actions/twitterauthorization.php lib/oauthclient.php lib/twitter.php lib/twitterapi.php lib/twitteroauthclient.php scripts/twitterstatusfetcher.php
Diffstat (limited to 'classes')
-rw-r--r--classes/Design.php5
-rw-r--r--classes/File.php3
-rw-r--r--classes/Foreign_link.php34
-rw-r--r--classes/Notice.php23
-rw-r--r--classes/User_group.php41
5 files changed, 78 insertions, 28 deletions
diff --git a/classes/Design.php b/classes/Design.php
index 9354bfcda..19c9e0292 100644
--- a/classes/Design.php
+++ b/classes/Design.php
@@ -204,7 +204,10 @@ class Design extends Memcached_DataObject
'disposition');
foreach ($attrs as $attr) {
- $siteDesign->$attr = common_config('design', $attr);
+ $val = common_config('design', $attr);
+ if ($val !== false) {
+ $siteDesign->$attr = $val;
+ }
}
}
diff --git a/classes/File.php b/classes/File.php
index 959301eda..b2c510340 100644
--- a/classes/File.php
+++ b/classes/File.php
@@ -95,7 +95,8 @@ class File extends Memcached_DataObject
if (empty($file_redir)) {
$redir_data = File_redirection::where($given_url);
$redir_url = $redir_data['url'];
- if ($redir_url === $given_url) {
+ // TODO: max field length
+ if ($redir_url === $given_url || strlen($redir_url) > 255) {
$x = File::saveNew($redir_data, $given_url);
$file_id = $x->id;
} else {
diff --git a/classes/Foreign_link.php b/classes/Foreign_link.php
index a3a159eb5..bc3ab006d 100644
--- a/classes/Foreign_link.php
+++ b/classes/Foreign_link.php
@@ -30,34 +30,38 @@ class Foreign_link extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
- // XXX: This only returns a 1->1 single obj mapping. Change? Or make
- // a getForeignUsers() that returns more than one? --Zach
static function getByUserID($user_id, $service)
{
+ if (empty($user_id) || empty($service)) {
+ return null;
+ }
+
$flink = new Foreign_link();
+
$flink->service = $service;
$flink->user_id = $user_id;
$flink->limit(1);
- if ($flink->find(true)) {
- return $flink;
- }
+ $result = $flink->find(true);
+
+ return empty($result) ? null : $flink;
- return null;
}
static function getByForeignID($foreign_id, $service)
{
- $flink = new Foreign_link();
- $flink->service = $service;
- $flink->foreign_id = $foreign_id;
- $flink->limit(1);
+ if (empty($foreign_id) || empty($service)) {
+ return null;
+ } else {
+ $flink = new Foreign_link();
+ $flink->service = $service;
+ $flink->foreign_id = $foreign_id;
+ $flink->limit(1);
- if ($flink->find(true)) {
- return $flink;
- }
+ $result = $flink->find(true);
- return null;
+ return empty($result) ? null : $flink;
+ }
}
function set_flags($noticesend, $noticerecv, $replysync, $friendsync)
@@ -67,7 +71,7 @@ class Foreign_link extends Memcached_DataObject
} else {
$this->noticesync &= ~FOREIGN_NOTICE_SEND;
}
-
+
if ($noticerecv) {
$this->noticesync |= FOREIGN_NOTICE_RECV;
} else {
diff --git a/classes/Notice.php b/classes/Notice.php
index ebd5e1efd..442eb00fd 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -29,10 +29,6 @@ require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
define('NOTICE_CACHE_WINDOW', 61);
-define('NOTICE_LOCAL_PUBLIC', 1);
-define('NOTICE_REMOTE_OMB', 0);
-define('NOTICE_LOCAL_NONPUBLIC', -1);
-
define('MAX_BOXCARS', 128);
class Notice extends Memcached_DataObject
@@ -62,7 +58,11 @@ class Notice extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
- const GATEWAY = -2;
+ /* Notice types */
+ const LOCAL_PUBLIC = 1;
+ const REMOTE_OMB = 0;
+ const LOCAL_NONPUBLIC = -1;
+ const GATEWAY = -2;
function getProfile()
{
@@ -134,7 +134,7 @@ class Notice extends Memcached_DataObject
}
static function saveNew($profile_id, $content, $source=null,
- $is_local=1, $reply_to=null, $uri=null, $created=null) {
+ $is_local=Notice::LOCAL_PUBLIC, $reply_to=null, $uri=null, $created=null) {
$profile = Profile::staticGet($profile_id);
@@ -177,7 +177,7 @@ class Notice extends Memcached_DataObject
if (($blacklist && in_array($profile_id, $blacklist)) ||
($source && $autosource && in_array($source, $autosource))) {
- $notice->is_local = -1;
+ $notice->is_local = Notice::LOCAL_NONPUBLIC;
} else {
$notice->is_local = $is_local;
}
@@ -509,7 +509,7 @@ class Notice extends Memcached_DataObject
function blowPublicCache($blowLast=false)
{
- if ($this->is_local == 1) {
+ if ($this->is_local == Notice::LOCAL_PUBLIC) {
$cache = common_memcache();
if ($cache) {
$cache->delete(common_cache_key('public'));
@@ -775,10 +775,11 @@ class Notice extends Memcached_DataObject
}
if (common_config('public', 'localonly')) {
- $notice->whereAdd('is_local = 1');
+ $notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC);
} else {
- # -1 == blacklisted
- $notice->whereAdd('is_local != -1');
+ # -1 == blacklisted, -2 == gateway (i.e. Twitter)
+ $notice->whereAdd('is_local !='. Notice::LOCAL_NONPUBLIC);
+ $notice->whereAdd('is_local !='. Notice::GATEWAY);
}
if ($since_id != 0) {
diff --git a/classes/User_group.php b/classes/User_group.php
index b1ab1c2d3..ea19cbb97 100644
--- a/classes/User_group.php
+++ b/classes/User_group.php
@@ -297,4 +297,45 @@ class User_group extends Memcached_DataObject
return $ids;
}
+
+ function asAtomEntry($namespace=false, $source=false)
+ {
+ $xs = new XMLStringer(true);
+
+ if ($namespace) {
+ $attrs = array('xmlns' => 'http://www.w3.org/2005/Atom',
+ 'xmlns:thr' => 'http://purl.org/syndication/thread/1.0');
+ } else {
+ $attrs = array();
+ }
+
+ $xs->elementStart('entry', $attrs);
+
+ if ($source) {
+ $xs->elementStart('source');
+ $xs->element('title', null, $profile->nickname . " - " . common_config('site', 'name'));
+ $xs->element('link', array('href' => $this->permalink()));
+ }
+
+ if ($source) {
+ $xs->elementEnd('source');
+ }
+
+ $xs->element('title', null, $this->nickname);
+ $xs->element('summary', null, $this->description);
+
+ $xs->element('link', array('rel' => 'alternate',
+ 'href' => $this->permalink()));
+
+ $xs->element('id', null, $this->permalink());
+
+ $xs->element('published', null, common_date_w3dtf($this->created));
+ $xs->element('updated', null, common_date_w3dtf($this->modified));
+
+ $xs->element('content', array('type' => 'html'), $this->description);
+
+ $xs->elementEnd('entry');
+
+ return $xs->getString();
+ }
}