|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright Copyright (c) 2017 Vinzenz Rosenkranz <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* @author Vinzenz Rosenkranz <[email protected]> |
|
6
|
|
|
* @author Kai Schröer <[email protected]> |
|
7
|
|
|
* @author René Gieling <[email protected]> |
|
8
|
|
|
* |
|
9
|
|
|
* @license GNU AGPL version 3 or any later version |
|
10
|
|
|
* |
|
11
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
12
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
13
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
14
|
|
|
* License, or (at your option) any later version. |
|
15
|
|
|
* |
|
16
|
|
|
* This program is distributed in the hope that it will be useful, |
|
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19
|
|
|
* GNU Affero General Public License for more details. |
|
20
|
|
|
* |
|
21
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
22
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
23
|
|
|
* |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
namespace OCA\Polls\Db; |
|
27
|
|
|
|
|
28
|
|
|
use JsonSerializable; |
|
29
|
|
|
|
|
30
|
|
|
use OCP\IUser; |
|
31
|
|
|
use OCP\AppFramework\Db\Entity; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @method string getType() |
|
35
|
|
|
* @method void setType(string $value) |
|
36
|
|
|
* @method string getTitle() |
|
37
|
|
|
* @method void setTitle(string $value) |
|
38
|
|
|
* @method string getDescription() |
|
39
|
|
|
* @method void setDescription(string $value) |
|
40
|
|
|
* @method string getOwner() |
|
41
|
|
|
* @method void setOwner(string $value) |
|
42
|
|
|
* @method int getCreated() |
|
43
|
|
|
* @method void setCreated(integer $value) |
|
44
|
|
|
* @method int getExpire() |
|
45
|
|
|
* @method void setExpire(integer $value) |
|
46
|
|
|
* @method int getDeleted() |
|
47
|
|
|
* @method void setDeleted(integer $value) |
|
48
|
|
|
* @method string getAccess() |
|
49
|
|
|
* @method void setAccess(string $value) |
|
50
|
|
|
* @method int getAnonymous() |
|
51
|
|
|
* @method void setAnonymous(integer $value) |
|
52
|
|
|
* @method int getFullAnonymous() |
|
53
|
|
|
* @method void setFullAnonymous(integer $value) |
|
54
|
|
|
* @method int getAllowMaybe() |
|
55
|
|
|
* @method void setAllowMaybe(integer $value) |
|
56
|
|
|
* @method string getOptions() |
|
57
|
|
|
* @method void setOptions(string $value) |
|
58
|
|
|
* @method string getSettings() |
|
59
|
|
|
* @method void setSettings(string $value) |
|
60
|
|
|
* @method int getVoteLimit() |
|
61
|
|
|
* @method void setVoteLimit(integer $value) |
|
62
|
|
|
* @method string getShowResults() |
|
63
|
|
|
* @method void setShowResults(string $value) |
|
64
|
|
|
* @method int getAdminAccess() |
|
65
|
|
|
* @method void setAdminAccess(integer $value) |
|
66
|
|
|
*/ |
|
67
|
|
|
class Poll extends Entity implements JsonSerializable { |
|
68
|
|
|
|
|
69
|
|
|
/** @var string $type */ |
|
70
|
|
|
protected $type; |
|
71
|
|
|
|
|
72
|
|
|
/** @var string $title */ |
|
73
|
|
|
protected $title; |
|
74
|
|
|
|
|
75
|
|
|
/** @var string $description */ |
|
76
|
|
|
protected $description; |
|
77
|
|
|
|
|
78
|
|
|
/** @var string $owner */ |
|
79
|
|
|
protected $owner; |
|
80
|
|
|
|
|
81
|
|
|
/** @var int $created */ |
|
82
|
|
|
protected $created; |
|
83
|
|
|
|
|
84
|
|
|
/** @var int $expire */ |
|
85
|
|
|
protected $expire; |
|
86
|
|
|
|
|
87
|
|
|
/** @var int $deleted */ |
|
88
|
|
|
protected $deleted; |
|
89
|
|
|
|
|
90
|
|
|
/** @var string $access */ |
|
91
|
|
|
protected $access; |
|
92
|
|
|
|
|
93
|
|
|
/** @var int $anonymous */ |
|
94
|
|
|
protected $anonymous; |
|
95
|
|
|
|
|
96
|
|
|
/** @var int $fullAnonymous */ |
|
97
|
|
|
protected $fullAnonymous; |
|
98
|
|
|
|
|
99
|
|
|
/** @var int $allowMaybe */ |
|
100
|
|
|
protected $allowMaybe; |
|
101
|
|
|
|
|
102
|
|
|
/** @var string $options */ |
|
103
|
|
|
protected $options; |
|
104
|
|
|
|
|
105
|
|
|
/** @var string $settings*/ |
|
106
|
|
|
protected $settings; |
|
107
|
|
|
|
|
108
|
|
|
/** @var int $voteLimit*/ |
|
109
|
|
|
protected $voteLimit; |
|
110
|
|
|
|
|
111
|
|
|
/** @var string $showResults */ |
|
112
|
|
|
protected $showResults; |
|
113
|
|
|
|
|
114
|
|
|
/** @var int $adminAccess*/ |
|
115
|
|
|
protected $adminAccess; |
|
116
|
|
|
|
|
117
|
|
|
public function jsonSerialize() { |
|
118
|
|
|
return [ |
|
119
|
|
|
'id' => intval($this->id), |
|
120
|
|
|
'type' => $this->type, |
|
121
|
|
|
'title' => $this->title, |
|
122
|
|
|
'description' => $this->description, |
|
123
|
|
|
'owner' => $this->owner, |
|
124
|
|
|
'created' => intval($this->created), |
|
125
|
|
|
'expire' => intval($this->expire), |
|
126
|
|
|
'deleted' => intval($this->deleted), |
|
127
|
|
|
'access' => $this->access, |
|
128
|
|
|
'anonymous' => intval($this->anonymous), |
|
129
|
|
|
'allowMaybe' => intval($this->allowMaybe), |
|
130
|
|
|
'settings' => $this->settings, |
|
131
|
|
|
'voteLimit' => intval($this->voteLimit), |
|
132
|
|
|
'showResults' => $this->showResults, |
|
133
|
|
|
'adminAccess' => intVal($this->adminAccess), |
|
134
|
|
|
'ownerDisplayName' => $this->getDisplayName() |
|
135
|
|
|
]; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
private function getDisplayName() { |
|
139
|
|
|
|
|
140
|
|
|
if (\OC::$server->getUserManager()->get($this->owner) instanceof IUser) { |
|
141
|
|
|
return \OC::$server->getUserManager()->get($this->owner)->getDisplayName(); |
|
142
|
|
|
} else { |
|
143
|
|
|
return $this->owner; |
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
|
} |
|
147
|
|
|
|