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