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:
@@ -124,8 +124,8 @@ class AnonymousFavePlugin extends Plugin
|
||||
if (!common_logged_in() && $this->hasAnonFaving($item)) {
|
||||
|
||||
$profile = AnonymousFavePlugin::getAnonProfile();
|
||||
if (!empty($profile)) {
|
||||
if ($profile->hasFave($item->notice)) {
|
||||
if ($profile instanceof Profile) {
|
||||
if (Fave::existsForProfile($item->notice, $profile)) {
|
||||
$disfavor = new AnonDisFavorForm($item->out, $item->notice);
|
||||
$disfavor->show();
|
||||
} else {
|
||||
|
@@ -62,9 +62,9 @@ class AnonFavorAction extends RedirectingAction
|
||||
$notice = Notice::getKV($id);
|
||||
$token = $this->checkSessionToken();
|
||||
|
||||
if ($profile->hasFave($notice)) {
|
||||
if (Fave::existsForProfile($notice, $profile)) {
|
||||
// TRANS: Client error.
|
||||
$this->clientError(_m('This notice is already a favorite!'));
|
||||
throw new AlreadyFulfilledException(_m('This notice is already a favorite!'));
|
||||
}
|
||||
$fave = Fave::addNew($profile, $notice);
|
||||
|
||||
|
Reference in New Issue
Block a user