Completed
Pull Request — master (#1128)
by René
04:27
created

UserGroupClass::setDisplayName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <[email protected]>
4
 *
5
 * @author René Gieling <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 *  This program is free software: you can redistribute it and/or modify
10
 *  it under the terms of the GNU Affero General Public License as
11
 *  published by the Free Software Foundation, either version 3 of the
12
 *  License, or (at your option) any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU Affero General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU Affero General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
24
namespace OCA\Polls\Model;
25
26
class UserGroupClass implements \JsonSerializable {
27
	public const TYPE = 'generic';
28
	public const TYPE_PUBLIC = 'public';
29
	public const TYPE_EXTERNAL = 'external';
30
31
	private $l10n;
32
33
	/** @var string */
34
	protected $id;
35
36
	/** @var string */
37
	protected $type;
38
39
	/** @var string */
40
	protected $displayName = '';
41
42
	/** @var string */
43
	protected $description = '';
44
45
	/** @var string */
46
	protected $emailAddress = '';
47
48
	/** @var string */
49
	protected $language = '';
50
51
	/** @var string */
52
	protected $organisation = '';
53
54
	/** @var string */
55
	protected $icon = '';
56
57
	/** @var boolean */
58
	protected $isNoUser = true;
59
60
	/** @var string[] */
61
	protected $categories = [];
62
63
	/**
64
	 * User constructor.
65
	 * @param $id
66
	 * @param $displayName
67
	 */
68
	public function __construct(
69
		$id,
70
		$type,
71
		$displayName = '',
72
		$emailAddress = '',
73
		$language = ''
74
	) {
75
		$this->id = $id;
76
		$this->type = $type;
77
		$this->displayName = $displayName;
78
		$this->emailAddress = $emailAddress;
79
		$this->language = $language;
80
		$this->icon = 'icon-share';
81
		$this->l10n = \OC::$server->getL10N('polls');
82
	}
83
84
	/**
85
	 * getId
86
	 * @NoAdminRequired
87
	 * @return String
88
	 */
89
	public function getId() {
90
		return $this->id;
91
	}
92
93
	/**
94
	 * getUser
95
	 * @NoAdminRequired
96
	 * @return String
97
	 */
98
	public function getUser() {
99
		return $this->id;
100
	}
101
102
	/**
103
	 * getType
104
	 * @NoAdminRequired
105
	 * @return String
106
	 */
107
	public function getType() {
108
		return $this->type;
109
	}
110
111
	/**
112
	 * getLanguage
113
	 * @NoAdminRequired
114
	 * @return String
115
	 */
116
	public function getLanguage() {
117
		return $this->language;
118
	}
119
120
	/**
121
	 * getDisplayName
122
	 * @NoAdminRequired
123
	 * @return String
124
	 */
125
	public function getDisplayName() {
126
		if ($this->displayName) {
127
			return $this->displayName;
128
		}
129
		return $this->id;
130
	}
131
132
	/**
133
	 * getDescription
134
	 * @NoAdminRequired
135
	 * @return String
136
	 */
137
	public function getDescription() {
138
		return $this->description;
139
	}
140
141
	/**
142
	 * getIcon
143
	 * @NoAdminRequired
144
	 * @return String
145
	 */
146
	public function getIcon() {
147
		return $this->icon;
148
	}
149
150
	/**
151
	 * getEmailAddress
152
	 * @NoAdminRequired
153
	 * @return String
154
	 */
155
	public function getEmailAddress() {
156
		return $this->emailAddress;
157
	}
158
159
	/**
160
	 * getOrganisation
161
	 * @NoAdminRequired
162
	 * @return String
163
	 */
164
	public function getOrganisation() {
165
		return $this->organisation;
166
	}
167
168
	/**
169
	 * getCategories
170
	 * @NoAdminRequired
171
	 * @return Array
172
	 */
173
	public function getCategories() {
174
		return $this->categories;
175
	}
176
177
	/**
178
	 * getOrganisation
179
	 * @NoAdminRequired
180
	 * @return String
181
	 */
182
	public function getIsNoUser() {
183
		return $this->isNoUser;
184
	}
185
186
	/**
187
	 * setType
188
	 * @NoAdminRequired
189
	 * @param string $type
190
	 * @return String
191
	 */
192
	public function setType($type) {
193
		$this->type = $type;
194
		return $this->type;
195
	}
196
197
	/**
198
	 * setDisplayName
199
	 * @NoAdminRequired
200
	 * @param string $displayName
201
	 * @return String
202
	 */
203
	public function setDisplayName($displayName) {
204
		$this->displayName = $displayName;
205
		return $this->displayName;
206
	}
207
208
	/**
209
	 * setDescription
210
	 * @NoAdminRequired
211
	 * @param string $description
212
	 * @return String
213
	 */
214
	public function setDescription($description) {
215
		$this->description = $description;
216
		return $this->description;
217
	}
218
219
	/**
220
	 * setEmailAddress
221
	 * @NoAdminRequired
222
	 * @param string $emailAddress
223
	 * @return String
224
	 */
225
	public function setEmailAddress($emailAddress) {
226
		$this->emailAddress = $emailAddress;
227
		return $this->emailAddress;
228
	}
229
230
	/**
231
	 * setLanguage
232
	 * @NoAdminRequired
233
	 * @param string $language
234
	 * @return String
235
	 */
236
	public function setLanguage($language) {
237
		$this->language = $language;
238
		return $this->language;
239
	}
240
241
	/**
242
	 * setOrganisation
243
	 * @NoAdminRequired
244
	 * @param string $organisation
245
	 * @return String
246
	 */
247
	public function setOrganisation($organisation) {
248
		$this->organisation = $organisation;
249
		return $this->organisation;
250
	}
251
252
	/**
253
	 * search
254
	 * @NoAdminRequired
255
	 * @return Array
256
	 */
257
	public static function search() {
258
		return [];
259
	}
260
261
	/**
262
	 * @return array
263
	 */
264
	public function jsonSerialize(): array {
265
		return	[
266
			'id'        	=> $this->getId(),
267
			'user'          => $this->getId(),
268
			'type'       	=> $this->getType(),
269
			'displayName'	=> $this->getDisplayName(),
270
			'organisation'	=> $this->getOrganisation(),
271
			'emailAddress'	=> $this->getEmailAddress(),
272
			'language'		=> $this->getLanguage(),
273
			'desc' 			=> $this->getDescription(),
274
			'icon'			=> $this->getIcon(),
275
			'categories'	=> $this->getCategories(),
276
			'isNoUser'		=> $this->getIsNoUser(),
277
		];
278
	}
279
}
280