|
1
|
|
|
<?php
|
|
2
|
|
|
/**
|
|
3
|
|
|
* OpenFireRestAPI is based entirely on official documentation of the REST API
|
|
4
|
|
|
* Plugin and you can extend it by following the directives of the documentation
|
|
5
|
|
|
*
|
|
6
|
|
|
* For the full copyright and license information, please read the LICENSE
|
|
7
|
|
|
* file that was distributed with this source code. For the full list of
|
|
8
|
|
|
* contributors, visit https://github.com/gnello/PHPOpenFireRestAPI/contributors
|
|
9
|
|
|
*
|
|
10
|
|
|
* @author Luca Agnello <[email protected]>
|
|
11
|
|
|
* @link https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html
|
|
12
|
|
|
*/
|
|
13
|
|
|
|
|
14
|
|
|
namespace Gnello\OpenFireRestAPI\Payloads;
|
|
15
|
|
|
|
|
16
|
|
|
use Gnello\OpenFireRestAPI\Settings\Settings;
|
|
17
|
|
|
use Gnello\OpenFireRestAPI\Settings\SubscriptionType;
|
|
18
|
|
|
|
|
19
|
|
|
/**
|
|
20
|
|
|
* Payload of RosterItem related REST Endpoint
|
|
21
|
|
|
* Class RosterItemPayload
|
|
22
|
|
|
* @package Gnello\OpenFireRestAPI\Payloads
|
|
23
|
|
|
* @link http://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#rosteritem
|
|
24
|
|
|
*/
|
|
25
|
|
|
class RosterItemPayload extends AbstractPayload
|
|
26
|
|
|
{
|
|
27
|
|
|
/**
|
|
28
|
|
|
* The JID of the roster item
|
|
29
|
|
|
* Optional No
|
|
30
|
|
|
* @var string
|
|
31
|
|
|
*/
|
|
32
|
|
|
private $jid;
|
|
33
|
|
|
|
|
34
|
|
|
/**
|
|
35
|
|
|
* The nickname for the user when used in this roster
|
|
36
|
|
|
* Optional Yes
|
|
37
|
|
|
* @var string
|
|
38
|
|
|
*/
|
|
39
|
|
|
private $nickname;
|
|
40
|
|
|
|
|
41
|
|
|
/**
|
|
42
|
|
|
* The subscription type
|
|
43
|
|
|
* Possible numeric values are: -1 (remove), 0 (none), 1 (to), 2 (from), 3 (both)
|
|
44
|
|
|
* Optional Yes
|
|
45
|
|
|
* @var integer
|
|
46
|
|
|
*/
|
|
47
|
|
|
private $subscriptionType;
|
|
48
|
|
|
|
|
49
|
|
|
/**
|
|
50
|
|
|
* A list of groups to organize roster entries under (e.g. friends, co-workers, etc.)
|
|
51
|
|
|
* Optional No
|
|
52
|
|
|
* @var array
|
|
53
|
|
|
*/
|
|
54
|
|
|
private $groups;
|
|
55
|
|
|
|
|
56
|
|
|
/**
|
|
57
|
|
|
* Returns always the correct jid
|
|
58
|
|
|
* @param $jid
|
|
59
|
|
|
*/
|
|
60
|
|
|
public function setJid($jid)
|
|
61
|
|
|
{
|
|
62
|
|
|
$settings = Settings::getInstance();
|
|
63
|
|
|
$server_name = $settings->getServerName();
|
|
64
|
|
|
|
|
65
|
|
|
if (strpos('@' . $server_name, $jid) === false) {
|
|
66
|
|
|
$jid .= '@' . $server_name;
|
|
67
|
|
|
}
|
|
68
|
|
|
$this->jid = $jid;;
|
|
69
|
|
|
}
|
|
70
|
|
|
|
|
71
|
|
|
/**
|
|
72
|
|
|
* @param $nickname
|
|
73
|
|
|
*/
|
|
74
|
|
|
public function setNickname($nickname) {
|
|
75
|
|
|
$this->nickname = $nickname;
|
|
76
|
|
|
}
|
|
77
|
|
|
|
|
78
|
|
|
/**
|
|
79
|
|
|
* @param $subscriptionType
|
|
80
|
|
|
* @throws \Exception
|
|
81
|
|
|
*/
|
|
82
|
|
|
public function setSubscriptionType($subscriptionType)
|
|
83
|
|
|
{
|
|
84
|
|
|
if (SubscriptionType::isValid($subscriptionType) === false) {
|
|
85
|
|
|
throw new \Exception("SubscriptionType not valid!");
|
|
86
|
|
|
}
|
|
87
|
|
|
$this->subscriptionType = $subscriptionType;
|
|
88
|
|
|
}
|
|
89
|
|
|
|
|
90
|
|
|
/**
|
|
91
|
|
|
* @param array $groups
|
|
92
|
|
|
*/
|
|
93
|
|
|
public function setGroups(array $groups) {
|
|
94
|
|
|
$this->groups['group'] = $groups;
|
|
95
|
|
|
}
|
|
96
|
|
|
|
|
97
|
|
|
/**
|
|
98
|
|
|
* Returns always the correct jid
|
|
99
|
|
|
* @return string
|
|
100
|
|
|
*/
|
|
101
|
|
|
public function getJid() {
|
|
102
|
|
|
return $this->jid;
|
|
103
|
|
|
}
|
|
104
|
|
|
|
|
105
|
|
|
/**
|
|
106
|
|
|
* @return string
|
|
107
|
|
|
*/
|
|
108
|
|
|
public function getNickname() {
|
|
109
|
|
|
return $this->nickname;
|
|
110
|
|
|
}
|
|
111
|
|
|
|
|
112
|
|
|
/**
|
|
113
|
|
|
* @return string
|
|
114
|
|
|
*/
|
|
115
|
|
|
public function getSubscriptionType() {
|
|
116
|
|
|
return $this->subscriptionType;
|
|
117
|
|
|
}
|
|
118
|
|
|
|
|
119
|
|
|
/**
|
|
120
|
|
|
* @return array
|
|
121
|
|
|
*/
|
|
122
|
|
|
public function getGroups() {
|
|
123
|
|
|
return $this->groups;
|
|
124
|
|
|
}
|
|
125
|
|
|
}
|
|
126
|
|
|
|