1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Nextcloud - NextNote |
4
|
|
|
* |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (c) 2017, Sander Brand ([email protected]) |
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\NextNote\Db; |
25
|
|
|
use \OCP\AppFramework\Db\Entity; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @method integer getId() |
29
|
|
|
* @method void setId(int $value) |
30
|
|
|
* @method void setGuid(string $value) |
31
|
|
|
* @method string getGuid() |
32
|
|
|
* @method void setShareFrom(string $value) |
33
|
|
|
* @method string getShareFrom() |
34
|
|
|
* @method void setShareTo(string $value) |
35
|
|
|
* @method string getShareTo() |
36
|
|
|
* @method void setShareType(string $value) |
37
|
|
|
* @method string getShareType() |
38
|
|
|
* @method void setShareTarget(string $value) |
39
|
|
|
* @method string getShareTarget() |
40
|
|
|
* @method void setPermissions(string $value) |
41
|
|
|
* @method string getPermissions() |
42
|
|
|
* @method void setExpireTime(string $value) |
43
|
|
|
* @method string getExpireTime() |
44
|
|
|
|
45
|
|
|
*/ |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
class Share extends Entity implements \JsonSerializable{ |
49
|
|
|
|
50
|
|
|
use EntityJSONSerializer; |
51
|
|
|
|
52
|
|
|
protected $guid; |
53
|
|
|
protected $shareFrom; //User from |
54
|
|
|
protected $shareTo; // Share to User / group |
55
|
|
|
protected $shareType; // Note (1) or Notebook(2) |
56
|
|
|
protected $shareTarget; //id of the entity |
57
|
|
|
protected $permissions; // int permissions |
58
|
|
|
protected $expireTime; // Expire time of share. 0 to disable |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
public function __construct() { |
62
|
|
|
// add types in constructor |
63
|
|
|
$this->addType('permissions', 'integer'); |
64
|
|
|
$this->addType('shareTarget', 'integer'); |
65
|
|
|
$this->addType('shareType', 'integer'); |
66
|
|
|
} |
67
|
|
|
/** |
68
|
|
|
* Turns entity attributes into an array |
69
|
|
|
*/ |
70
|
|
|
public function jsonSerialize() { |
71
|
|
|
return [ |
72
|
|
|
'id' => $this->getId(), |
73
|
|
|
'guid' => $this->getGuid(), |
74
|
|
|
'share_from' => $this->getShareFrom(), |
75
|
|
|
'share_to' => $this->getShareTo(), |
76
|
|
|
'share_type' => $this->getShareType(), |
77
|
|
|
'share_target' => $this->getShareTarget(), |
78
|
|
|
'permissions' => $this->getPermissions(), |
79
|
|
|
'expire_time' => $this->getExpireTime(), |
80
|
|
|
]; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|