Merge branch 'testing' of gitorious.org:statusnet/mainline into 0.9.x

This commit is contained in:
Brion Vibber
2010-02-12 11:18:35 -08:00
45 changed files with 3007 additions and 581 deletions

View File

@@ -22,4 +22,19 @@ class Nonce extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
/**
* Compatibility hack for PHP 5.3
*
* The statusnet.links.ini entry cannot be read because "," is no longer
* allowed in key names when read by parse_ini_file().
*
* @return array
* @access public
*/
function links()
{
return array('consumer_key,token' => 'token:consumer_key,token');
}
}

View File

@@ -783,7 +783,7 @@ class Notice extends Memcached_DataObject
$result = $gi->insert();
if (!result) {
if (!$result) {
common_log_db_error($gi, 'INSERT', __FILE__);
throw new ServerException(_('Problem saving group inbox.'));
}
@@ -917,7 +917,7 @@ class Notice extends Memcached_DataObject
/**
* Same calculation as saveGroups but without the saving
* @fixme merge the functions
* @return array of Group objects
* @return array of Group_inbox objects
*/
function getGroups()
{
@@ -957,7 +957,10 @@ class Notice extends Memcached_DataObject
if ($namespace) {
$attrs = array('xmlns' => 'http://www.w3.org/2005/Atom',
'xmlns:thr' => 'http://purl.org/syndication/thread/1.0');
'xmlns:thr' => 'http://purl.org/syndication/thread/1.0',
'xmlns:georss' => 'http://www.georss.org/georss',
'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/',
'xmlns:ostatus' => 'http://ostatus.org/schema/1.0');
} else {
$attrs = array();
}
@@ -983,11 +986,6 @@ class Notice extends Memcached_DataObject
$xs->element('icon', null, $profile->avatarUrl(AVATAR_PROFILE_SIZE));
}
$xs->elementStart('author');
$xs->element('name', null, $profile->nickname);
$xs->element('uri', null, $profile->profileurl);
$xs->elementEnd('author');
if ($source) {
$xs->elementEnd('source');
}
@@ -995,6 +993,9 @@ class Notice extends Memcached_DataObject
$xs->element('title', null, $this->content);
$xs->element('summary', null, $this->content);
$xs->raw($profile->asAtomAuthor());
$xs->raw($profile->asActivityActor());
$xs->element('link', array('rel' => 'alternate',
'href' => $this->bestUrl()));
@@ -1014,6 +1015,43 @@ class Notice extends Memcached_DataObject
}
}
if (!empty($this->conversation)
&& $this->conversation != $this->notice->id) {
$xs->element(
'link', array(
'rel' => 'ostatus:conversation',
'href' => common_local_url(
'conversation',
array('id' => $this->conversation)
)
)
);
}
$reply_ids = $this->getReplies();
foreach ($reply_ids as $id) {
$profile = Profile::staticGet('id', $id);
if (!empty($profile)) {
$xs->element(
'link', array(
'rel' => 'ostatus:attention',
'href' => $profile->getAcctUri()
)
);
}
}
if (!empty($this->repeat_of)) {
$repeat = Notice::staticGet('id', $this->repeat_of);
if (!empty($repeat)) {
$xs->element(
'ostatus:forward',
array('ref' => $repeat->uri, 'href' => $repeat->bestUrl())
);
}
}
$xs->element('content', array('type' => 'html'), $this->rendered);
$tag = new Notice_tag();
@@ -1041,9 +1079,7 @@ class Notice extends Memcached_DataObject
}
if (!empty($this->lat) && !empty($this->lon)) {
$xs->elementStart('geo', array('xmlns:georss' => 'http://www.georss.org/georss'));
$xs->element('georss:point', null, $this->lat . ' ' . $this->lon);
$xs->elementEnd('geo');
}
$xs->elementEnd('entry');

View File

@@ -754,4 +754,89 @@ class Profile extends Memcached_DataObject
return !empty($notice);
}
/**
* Returns an XML string fragment with limited profile information
* as an Atom <author> element.
*
* Assumes that Atom has been previously set up as the base namespace.
*
* @return string
*/
function asAtomAuthor()
{
$xs = new XMLStringer(true);
$xs->elementStart('author');
$xs->element('name', null, $this->nickname);
$xs->element('uri', null, $this->profileurl);
$xs->elementEnd('author');
return $xs->getString();
}
/**
* Returns an XML string fragment with profile information as an
* Activity Streams <activity:actor> element.
*
* Assumes that 'activity' namespace has been previously defined.
*
* @return string
*/
function asActivityActor()
{
return $this->asActivityNoun('actor');
}
/**
* Returns an XML string fragment with profile information as an
* Activity Streams noun object with the given element type.
*
* Assumes that 'activity' namespace has been previously defined.
*
* @param string $element one of 'actor', 'subject', 'object', 'target'
* @return string
*/
function asActivityNoun($element)
{
$xs = new XMLStringer(true);
$xs->elementStart('activity:' . $element);
$xs->element(
'activity:object-type',
null,
'http://activitystrea.ms/schema/1.0/person'
);
$xs->element(
'id',
null,
common_local_url(
'userbyid',
array('id' => $this->id)
)
);
$xs->element('title', null, $this->getBestName());
$avatar = $this->getAvatar(AVATAR_PROFILE_SIZE);
$xs->element(
'link', array(
'type' => empty($avatar) ? 'image/png' : $avatar->mediatype,
'href' => empty($avatar)
? Avatar::defaultImage(AVATAR_PROFILE_SIZE)
: $avatar->displayUrl()
),
''
);
$xs->elementEnd('activity:' . $element);
return $xs->getString();
}
function getAcctUri()
{
return $this->nickname . '@' . common_config('site', 'server');
}
}

View File

@@ -49,12 +49,12 @@ class User_group extends Memcached_DataObject
array('id' => $this->id));
}
function getNotices($offset, $limit)
function getNotices($offset, $limit, $since_id=null, $max_id=null)
{
$ids = Notice::stream(array($this, '_streamDirect'),
array(),
'user_group:notice_ids:' . $this->id,
$offset, $limit);
$offset, $limit, $since_id, $max_id);
return Notice::getStreamByIds($ids);
}

View File

@@ -19,8 +19,11 @@ profile_id = profile:id
[token]
consumer_key = consumer:consumer_key
[nonce]
consumer_key,token = token:consumer_key,token
; Compatibility hack for PHP 5.3
; This entry has been moved to the class definition, as commas are no longer
; considered valid in keys, causing parse_ini_file() to reject the whole file.
;[nonce]
;consumer_key,token = token:consumer_key,token
[confirm_address]
user_id = user:id