]> git.mxchange.org Git - friendica.git/blob - src/Contact/LocalRelationship/Entity/LocalRelationship.php
Replace $_GET references with $request in Update classes
[friendica.git] / src / Contact / LocalRelationship / Entity / LocalRelationship.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2023, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Contact\LocalRelationship\Entity;
23
24 use Friendica\Core\Protocol;
25 use Friendica\Model\Contact;
26
27 /**
28  * @property-read int    $userId
29  * @property-read int    $contactId
30  * @property-read int    $uriId
31  * @property-read bool   $blocked
32  * @property-read bool   $ignored
33  * @property-read bool   $collapsed
34  * @property-read bool   $hidden
35  * @property-read bool   $pending
36  * @property-read int    $rel
37  * @property-read string $info
38  * @property-read bool   $notifyNewPosts
39  * @property-read bool   $isRemoteSelf
40  * @property-read int    $fetchFurtherInformation
41  * @property-read string $ffiKeywordDenylist
42  * @property-read bool   $subhub
43  * @property-read string $hubVerify
44  * @property-read string $protocol
45  * @property-read int    $rating
46  * @property-read int    $priority
47  */
48 class LocalRelationship extends \Friendica\BaseEntity
49 {
50         /** @var int */
51         protected $userId;
52         /** @var int */
53         protected $contactId;
54         /** @var bool */
55         protected $blocked;
56         /** @var bool */
57         protected $ignored;
58         /** @var bool */
59         protected $collapsed;
60         /** @var bool */
61         protected $hidden;
62         /** @var bool */
63         protected $pending;
64         /** @var int */
65         protected $rel;
66         /** @var string */
67         protected $info;
68         /** @var bool */
69         protected $notifyNewPosts;
70         /** @var bool */
71         protected $isRemoteSelf;
72         /** @var int */
73         protected $fetchFurtherInformation;
74         /** @var string */
75         protected $ffiKeywordDenylist;
76         /** @var bool */
77         protected $subhub;
78         /** @var string */
79         protected $hubVerify;
80         /** @var string */
81         protected $protocol;
82         /** @var int */
83         protected $rating;
84         /** @var int */
85         protected $priority;
86
87         public function __construct(int $userId, int $contactId, bool $blocked = false, bool $ignored = false, bool $collapsed = false, bool $hidden = false, bool $pending = false, int $rel = Contact::NOTHING, string $info = '', bool $notifyNewPosts = false, bool $isRemoteSelf = false, int $fetchFurtherInformation = 0, string $ffiKeywordDenylist = '', bool $subhub = false, string $hubVerify = '', string $protocol = Protocol::PHANTOM, ?int $rating = null, ?int $priority = null)
88         {
89                 $this->userId                  = $userId;
90                 $this->contactId               = $contactId;
91                 $this->blocked                 = $blocked;
92                 $this->ignored                 = $ignored;
93                 $this->collapsed               = $collapsed;
94                 $this->hidden                  = $hidden;
95                 $this->pending                 = $pending;
96                 $this->rel                     = $rel;
97                 $this->info                    = $info;
98                 $this->notifyNewPosts          = $notifyNewPosts;
99                 $this->isRemoteSelf            = $isRemoteSelf;
100                 $this->fetchFurtherInformation = $fetchFurtherInformation;
101                 $this->ffiKeywordDenylist      = $ffiKeywordDenylist;
102                 $this->subhub                  = $subhub;
103                 $this->hubVerify               = $hubVerify;
104                 $this->protocol                = $protocol;
105                 $this->rating                  = $rating;
106                 $this->priority                = $priority;
107         }
108
109         public function addFollow()
110         {
111                 $this->rel = in_array($this->rel, [Contact::FOLLOWER, Contact::FRIEND]) ? Contact::FRIEND : Contact::SHARING;
112         }
113
114         public function removeFollow()
115         {
116                 $this->rel = in_array($this->rel, [Contact::FOLLOWER, Contact::FRIEND]) ? Contact::FOLLOWER : Contact::NOTHING;
117         }
118
119         public function addFollower()
120         {
121                 $this->rel = in_array($this->rel, [Contact::SHARING, Contact::FRIEND]) ? Contact::FRIEND : Contact::FOLLOWER;
122         }
123
124         public function removeFollower()
125         {
126                 $this->rel = in_array($this->rel, [Contact::SHARING, Contact::FRIEND]) ? Contact::SHARING : Contact::NOTHING;
127         }
128 }