|
@@ 76-90 (lines=15) @@
|
| 73 |
|
* @return NextNote |
| 74 |
|
* @throws \Exception |
| 75 |
|
*/ |
| 76 |
|
public function create($note, $userId) { |
| 77 |
|
if (is_array($note)) { |
| 78 |
|
$entity = new NextNote(); |
| 79 |
|
$entity->setName($note['title']); |
| 80 |
|
$entity->setUid($userId); |
| 81 |
|
$entity->setGrouping($note['grouping']); |
| 82 |
|
$entity->setNote($note['note'] ? $note['note'] : ''); |
| 83 |
|
$entity->setMtime(time()); |
| 84 |
|
$note = $entity; |
| 85 |
|
} |
| 86 |
|
if (!$note instanceof NextNote) { |
| 87 |
|
throw new \Exception("Expected OwnNote object!"); |
| 88 |
|
} |
| 89 |
|
return $this->noteMapper->create($note); |
| 90 |
|
} |
| 91 |
|
|
| 92 |
|
/** |
| 93 |
|
* Update vault |
|
@@ 101-122 (lines=22) @@
|
| 98 |
|
* @internal param $userId |
| 99 |
|
* @internal param $vault |
| 100 |
|
*/ |
| 101 |
|
public function update($note) { |
| 102 |
|
|
| 103 |
|
if (is_array($note)) { |
| 104 |
|
$entity = $this->find($note['id']); |
| 105 |
|
$entity->setName($note['title']); |
| 106 |
|
$entity->setGrouping($note['grouping']); |
| 107 |
|
$entity->setNote($note['note']); |
| 108 |
|
$entity->setDeleted($note['deleted']); |
| 109 |
|
$entity->setMtime(time()); |
| 110 |
|
$note = $entity; |
| 111 |
|
} |
| 112 |
|
if (!$note instanceof NextNote) { |
| 113 |
|
throw new \Exception("Expected OwnNote object!"); |
| 114 |
|
} |
| 115 |
|
|
| 116 |
|
// @TODO check if we can enable this without issues |
| 117 |
|
// if (!$this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE, $note->getId())) { |
| 118 |
|
// return false; |
| 119 |
|
// } |
| 120 |
|
|
| 121 |
|
return $this->noteMapper->updateNote($note); |
| 122 |
|
} |
| 123 |
|
|
| 124 |
|
public function renameNote($FOLDER, $id, $in_newname, $in_newgroup, $uid = null) { |
| 125 |
|
$newname = str_replace("\\", "-", str_replace("/", "-", $in_newname)); |