1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Nextcloud - NextNote |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright (c) 2015, Ben Curtis <[email protected]> |
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 setName(string $value) |
31
|
|
|
* @method void setGuid(string $value) |
32
|
|
|
* @method string getGuid() |
33
|
|
|
* @method string getName() |
34
|
|
|
* @method void setGrouping(string $value) |
35
|
|
|
* @method string getGrouping() |
36
|
|
|
* @method void setNotebook($value) |
37
|
|
|
* @method getNotebook() |
38
|
|
|
* @method void setUid(string $value) |
39
|
|
|
* @method string getNote() |
40
|
|
|
* @method void setNote(string $value) |
41
|
|
|
* @method string getUid() |
42
|
|
|
* @method bool setShared(bool $value) |
43
|
|
|
* @method bool getShared() |
44
|
|
|
* @method void setMtime(integer $value) |
45
|
|
|
* @method integer getMtime() |
46
|
|
|
* @method void setDeleted(integer $value) |
47
|
|
|
* @method integer getDeleted() |
48
|
|
|
*/ |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
class Note extends Entity implements \JsonSerializable{ |
52
|
|
|
|
53
|
|
|
use EntityJSONSerializer; |
54
|
|
|
|
55
|
|
|
protected $name; |
56
|
|
|
protected $grouping; |
57
|
|
|
protected $notebook; |
58
|
|
|
protected $uid; |
59
|
|
|
protected $guid; |
60
|
|
|
protected $mtime; |
61
|
|
|
protected $deleted = 0; |
62
|
|
|
protected $note; |
63
|
|
|
protected $shared; |
64
|
|
|
public function __construct() { |
65
|
|
|
// add types in constructor |
66
|
|
|
$this->addType('mtime', 'integer'); |
67
|
|
|
$this->addType('deleted', 'integer'); |
68
|
|
|
} |
69
|
|
|
/** |
70
|
|
|
* Turns entity attributes into an array |
71
|
|
|
*/ |
72
|
|
|
public function jsonSerialize() { |
73
|
|
|
$now = new \DateTime(); |
74
|
|
|
return [ |
75
|
|
|
'id' => $this->getId(), |
76
|
|
|
'guid' => $this->getGuid(), |
77
|
|
|
'mtime' => $this->getMtime(), |
78
|
|
|
'timediff' => $now->getTimestamp() - $this->getMtime(), |
79
|
|
|
'title' => $this->getName(), |
80
|
|
|
'uid' => $this->getUid(), |
81
|
|
|
'notebook' => $this->getNotebook(), |
82
|
|
|
'content' => $this->getNote(), |
83
|
|
|
'content_plain' => html_entity_decode(strip_tags($this->getNote())), |
84
|
|
|
'deleted' => $this->getDeleted(), |
85
|
|
|
'permissions' => 31 |
86
|
|
|
]; |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|