]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/ActivityVerb/lib/activityverbhandlerplugin.php
Endless loop nesting on ensureHub failure now fixed
[quix0rs-gnu-social.git] / plugins / ActivityVerb / lib / activityverbhandlerplugin.php
1 <?php
2 /*
3  * GNU Social - a federating social network
4  * Copyright (C) 2014, Free Software Foundation, Inc.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 if (!defined('GNUSOCIAL')) { exit(1); }
21
22 /**
23  * @package     Activity
24  * @maintainer  Mikael Nordfeldth <mmn@hethane.se>
25  */
26 abstract class ActivityVerbHandlerPlugin extends ActivityHandlerPlugin
27 {
28     public function onActivityVerbTitle(ManagedAction $action, $verb, Notice $target, Profile $scoped, &$title)
29     {
30         if (!$this->isMyVerb($verb)) {
31             return true;
32         }
33
34         $title = $this->getActionTitle($action, $verb, $target, $scoped);
35         return false;
36     }
37     abstract protected function getActionTitle(ManagedAction $action, $verb, Notice $target, Profile $scoped);
38
39     public function onActivityVerbShowContent(ManagedAction $action, $verb, Notice $target, Profile $scoped)
40     {
41         if (!$this->isMyVerb($verb)) {
42             return true;
43         }
44
45         return $this->showActionContent($action, $verb, $target, $scoped);
46     }
47     protected function showActionContent(ManagedAction $action, $verb, Notice $target, Profile $scoped)
48     {
49         if (!GNUsocial::isAjax()) {
50             $nl = new NoticeListItem($target, $action, array('options'=>false, 'attachments'=>false,
51                                                              'item_tag'=>'div', 'id_prefix'=>'fave'));
52             $nl->show();
53         }
54
55         $form = $this->getActivityForm($action, $verb, $target, $scoped);
56         $form->show();
57
58         return false;
59     }
60
61     public function onActivityVerbDoPreparation(ManagedAction $action, $verb, Notice $target, Profile $scoped)
62     {
63         if (!$this->isMyVerb($verb)) {
64             return true;
65         }
66
67         return $this->doActionPreparation($action, $verb, $target, $scoped);
68     }
69     abstract protected function doActionPreparation(ManagedAction $action, $verb, Notice $target, Profile $scoped);
70
71     public function onActivityVerbDoPost(ManagedAction $action, $verb, Notice $target, Profile $scoped)
72     {
73         if (!$this->isMyVerb($verb)) {
74             return true;
75         }
76
77         return $this->doActionPost($action, $verb, $target, $scoped);
78     }
79     abstract protected function doActionPost(ManagedAction $action, $verb, Notice $target, Profile $scoped);
80
81     abstract protected function getActivityForm(ManagedAction $action, $verb, Notice $target, Profile $scoped);
82 }