1 | <?php |
||
25 | class NotesService { |
||
26 | private $l10n; |
||
27 | private $root; |
||
28 | |||
29 | /** |
||
30 | * @param IRootFolder $root |
||
31 | * @param IL10N $l10n |
||
32 | */ |
||
33 | public function __construct(IRootFolder $root, IL10N $l10n) { |
||
37 | 11 | ||
38 | /** |
||
39 | * @param string $userId |
||
40 | * @return array with all notes in the current directory |
||
41 | */ |
||
42 | public function getAll($userId) { |
||
65 | 1 | ||
66 | /** |
||
67 | * Used to get a single note by id |
||
68 | * @param int $id the id of the note to get |
||
69 | * @param string $userId |
||
70 | * @throws NoteDoesNotExistException if note does not exist |
||
71 | * @return Note |
||
72 | */ |
||
73 | public function get($id, $userId) { |
||
77 | 3 | ||
78 | 3 | private function getTags($id) { |
|
87 | |||
88 | 3 | /** |
|
89 | * Creates a note and returns the empty note |
||
90 | * @param string $userId |
||
91 | * @see update for setting note content |
||
92 | * @return Note the newly created note |
||
93 | */ |
||
94 | public function create($userId) { |
||
106 | |||
107 | 2 | /** |
|
108 | * Updates a note. Be sure to check the returned note since the title is |
||
109 | * dynamically generated and filename conflicts are resolved |
||
110 | * @param int $id the id of the note used to update |
||
111 | * @param string $content the content which will be written into the note |
||
112 | * the title is generated from the first line of the content |
||
113 | * @throws NoteDoesNotExistException if note does not exist |
||
114 | * @return \OCA\Notes\Db\Note the updated note |
||
115 | */ |
||
116 | public function update($id, $content, $userId) { |
||
151 | 2 | ||
152 | /** |
||
153 | 2 | * Set or unset a note as favorite. |
|
154 | * @param int $id the id of the note used to update |
||
155 | * @param boolean $favorite whether the note should be a favorite or not |
||
156 | * @throws NoteDoesNotExistException if note does not exist |
||
157 | * @return boolean the new favorite state of the note |
||
158 | */ |
||
159 | public function favorite($id, $favorite, $userId) { |
||
175 | |||
176 | /** |
||
177 | * Deletes a note |
||
178 | * @param int $id the id of the note which should be deleted |
||
179 | * @param string $userId |
||
180 | * @throws NoteDoesNotExistException if note does not |
||
181 | * exist |
||
182 | */ |
||
183 | public function delete($id, $userId) { |
||
188 | 3 | ||
189 | 3 | /** |
|
190 | 3 | * @param Folder $folder |
|
191 | 1 | * @param int $id |
|
192 | 1 | * @throws NoteDoesNotExistException |
|
193 | * @return \OCP\Files\File |
||
194 | */ |
||
195 | private function getFileById($folder, $id) { |
||
203 | |||
204 | 8 | /** |
|
205 | 4 | * @param string $userId the user id |
|
206 | * @return Folder |
||
207 | 4 | */ |
|
208 | private function getFolderForUser($userId) { |
||
217 | 11 | ||
218 | 11 | /** |
|
219 | 11 | * get path of file and the title.txt and check if they are the same |
|
220 | * file. If not the title needs to be renamed |
||
221 | * |
||
222 | 11 | * @param Folder $folder a folder to the notes directory |
|
223 | * @param string $title the filename which should be used |
||
224 | * @param string $extension the extension which should be used |
||
225 | * @param int $id the id of the note for which the title should be generated |
||
226 | * used to see if the file itself has the title and not a different file for |
||
227 | * checking for filename collisions |
||
228 | * @return string the resolved filename to prevent overwriting different |
||
229 | * files with the same title |
||
230 | */ |
||
231 | private function generateFileName(Folder $folder, $title, $extension, $id) { |
||
251 | 3 | ||
252 | 3 | /** |
|
253 | 3 | * test if file is a note |
|
254 | 3 | * |
|
255 | * @param \OCP\Files\File $file |
||
256 | 3 | * @return bool |
|
257 | */ |
||
258 | private function isNote($file) { |
||
273 | } |
||
274 |