|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright 2018, Roeland Jago Douma <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* @author Roeland Jago Douma <[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
|
|
|
namespace OCA\Richdocuments\Db; |
|
24
|
|
|
|
|
25
|
|
|
use OCP\AppFramework\Db\Entity; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Class WopiEntity |
|
29
|
|
|
* |
|
30
|
|
|
* @package OCA\Richdocuments\Db |
|
31
|
|
|
* |
|
32
|
|
|
* @method void setOwnerUid(string $uid) |
|
33
|
|
|
* @method string getOwnerUid() |
|
34
|
|
|
* @method void setEditorUid(string $uid) |
|
35
|
|
|
* @method string getEditorUid() |
|
36
|
|
|
* @method void setFileid(int $fileid) |
|
37
|
|
|
* @method int getFileid() |
|
38
|
|
|
* @method void setVersion(int $version) |
|
39
|
|
|
* @method int getVersion() |
|
40
|
|
|
* @method void setCanwrite(bool $canwrite) |
|
41
|
|
|
* @method bool getCanwrite() |
|
42
|
|
|
* @method void setServerHost(string $host) |
|
43
|
|
|
* @method string getServerHost() |
|
44
|
|
|
* @method void setToken(string $token) |
|
45
|
|
|
* @method string getToken() |
|
46
|
|
|
* @method void setExpiry(int $expiry) |
|
47
|
|
|
* @method int getExpiry() |
|
48
|
|
|
* @method void setGuestDisplayname(string $token) |
|
49
|
|
|
* @method string getGuestDisplayname() |
|
50
|
|
|
* @method void setTemplateDestination(int $fileId) |
|
51
|
|
|
* @method int getTemplateDestination() |
|
52
|
|
|
* @method void setTemplateId(int $fileId) |
|
53
|
|
|
* @method int getTemplateId() |
|
54
|
|
|
*/ |
|
55
|
|
|
class Wopi extends Entity { |
|
56
|
|
|
/** @var string */ |
|
57
|
|
|
protected $ownerUid; |
|
58
|
|
|
|
|
59
|
|
|
/** @var string */ |
|
60
|
|
|
protected $editorUid; |
|
61
|
|
|
|
|
62
|
|
|
/** @var int */ |
|
63
|
|
|
protected $fileid; |
|
64
|
|
|
|
|
65
|
|
|
/** @var int */ |
|
66
|
|
|
protected $version; |
|
67
|
|
|
|
|
68
|
|
|
/** @var bool */ |
|
69
|
|
|
protected $canwrite; |
|
70
|
|
|
|
|
71
|
|
|
/** @var string */ |
|
72
|
|
|
protected $serverHost; |
|
73
|
|
|
|
|
74
|
|
|
/** @var string */ |
|
75
|
|
|
protected $token; |
|
76
|
|
|
|
|
77
|
|
|
/** @var int */ |
|
78
|
|
|
protected $expiry; |
|
79
|
|
|
|
|
80
|
|
|
/** @var string */ |
|
81
|
|
|
protected $guestDisplayname; |
|
82
|
|
|
|
|
83
|
|
|
/** @var int */ |
|
84
|
|
|
protected $templateDestination; |
|
85
|
|
|
|
|
86
|
|
|
/** @var int */ |
|
87
|
|
|
protected $templateId; |
|
88
|
|
|
|
|
89
|
|
|
/** @var bool */ |
|
90
|
|
|
protected $hideDownload; |
|
91
|
|
|
|
|
92
|
|
|
/** @var bool */ |
|
93
|
|
|
protected $direct; |
|
94
|
|
|
|
|
95
|
|
|
/** @var bool */ |
|
96
|
|
|
protected $isRemoteToken; |
|
97
|
|
|
|
|
98
|
|
|
/** @var string */ |
|
99
|
|
|
protected $remoteServer; |
|
100
|
|
|
|
|
101
|
|
|
/** @var string */ |
|
102
|
|
|
protected $remoteServerToken; |
|
103
|
|
|
|
|
104
|
|
|
/** @var string */ |
|
105
|
|
|
protected $share; |
|
106
|
|
|
|
|
107
|
|
|
public function __construct() { |
|
108
|
|
|
$this->addType('owner_uid', 'string'); |
|
109
|
|
|
$this->addType('editor_uid', 'string'); |
|
110
|
|
|
$this->addType('fileid', 'int'); |
|
111
|
|
|
$this->addType('version', 'int'); |
|
112
|
|
|
$this->addType('canwrite', 'bool'); |
|
113
|
|
|
$this->addType('server_host', 'string'); |
|
114
|
|
|
$this->addType('token', 'string'); |
|
115
|
|
|
$this->addType('expiry', 'int'); |
|
116
|
|
|
$this->addType('guest_displayname', 'string'); |
|
117
|
|
|
$this->addType('templateDestination', 'int'); |
|
118
|
|
|
$this->addType('templateId', 'int'); |
|
119
|
|
|
$this->addType('hide_download', 'bool'); |
|
120
|
|
|
$this->addType('direct', 'bool'); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
public function isTemplateToken() { |
|
124
|
|
|
return $this->getTemplateDestination() !== 0 && $this->getTemplateDestination() !== null; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
public function hasTemplateId() { |
|
128
|
|
|
return $this->getTemplateId() !== 0 && $this->getTemplateId() !== null; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
public function isGuest() { |
|
132
|
|
|
return $this->getGuestDisplayname() !== null; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
public function getUserForFileAccess() { |
|
136
|
|
|
if ($this->share !== null) { |
|
137
|
|
|
return $this->getOwnerUid(); |
|
138
|
|
|
} |
|
139
|
|
|
return $this->isGuest() ? $this->getOwnerUid() : $this->getEditorUid(); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
public function getCanwrite() { |
|
143
|
|
|
return (bool)$this->canwrite; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
public function getHideDownload() { |
|
147
|
|
|
return (bool)$this->hideDownload; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
public function getDirect() { |
|
151
|
|
|
return (bool)$this->direct; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
} |
|
155
|
|
|
|