pluginified most of hasFave, getFaves and related calls

The code is now more event-driven when it comes to rendering notices
and their related HTML elements, since we can't have direct calls from
core to a plugin.

lib/activitymover.php has a function to move a Favorite activity which
will not happen now. The move must be pluginified and performed as an
event which plugins can catch on to.
This commit is contained in:
Mikael Nordfeldth
2014-06-27 13:58:35 +02:00
parent 29730b6ca7
commit fcdd061b4f
29 changed files with 580 additions and 421 deletions

View File

@@ -295,13 +295,18 @@ class ApiAction extends Action
function twitterStatusArray($notice, $include_user=true)
{
// The event call to handle NoticeSimpleStatusArray lets plugins add data to the output array
$base = $this->twitterSimpleStatusArray($notice, $include_user);
Event::handle('NoticeSimpleStatusArray', array($notice, &$base, $this->scoped,
array('include_user'=>$include_user)));
if (!empty($notice->repeat_of)) {
$original = Notice::getKV('id', $notice->repeat_of);
if (!empty($original)) {
$original_array = $this->twitterSimpleStatusArray($original, $include_user);
$base['retweeted_status'] = $original_array;
if ($original instanceof Notice) {
$orig_array = $this->twitterSimpleStatusArray($original, $include_user);
Event::handle('NoticeSimpleStatusArray', array($original, &$orig_array, $this->scoped,
array('include_user'=>$include_user)));
$base['retweeted_status'] = $orig_array;
}
}
@@ -369,10 +374,8 @@ class ApiAction extends Action
}
if (!is_null($this->scoped)) {
$twitter_status['favorited'] = $this->scoped->hasFave($notice);
$twitter_status['repeated'] = $this->scoped->hasRepeated($notice);
} else {
$twitter_status['favorited'] = false;
$twitter_status['repeated'] = false;
}