Code Duplication    Length = 13-13 lines in 2 locations

lib/backend.php 1 location

@@ 591-603 (lines=13) @@
588
	 * @param $nid
589
	 * @return bool|int
590
	 */
591
	private function checkPermissions($permission, $nid) {
592
		// gather information
593
		$uid = \OC::$server->getUserSession()->getUser()->getUID();
594
		$note = $this->getNote($nid);
595
		// owner is allowed to change everything
596
		if ($uid === $note['uid']) {
597
			return true;
598
		}
599
600
		// check share permissions
601
		$shared_note = \OCP\Share::getItemSharedWith('ownnote', $nid, 'populated_shares')[0];
602
		return $shared_note['permissions'] & $permission;
603
	}
604
}
605
606
?>

lib/Service/OwnNoteService.php 1 location

@@ 176-188 (lines=13) @@
173
		throw new \Exception('Calling a deprecated method! (Folder'. $FOLDER. '. Showdel: '. $showdel .')');
174
	}
175
176
	private function checkPermissions($permission, $nid) {
177
		// gather information
178
		$uid = \OC::$server->getUserSession()->getUser()->getUID();
179
		$note = $this->find($nid);
180
		// owner is allowed to change everything
181
		if ($uid === $note->getUid()) {
182
			return true;
183
		}
184
185
		// check share permissions
186
		$shared_note = \OCP\Share::getItemSharedWith('ownnote', $nid, 'populated_shares')[0];
187
		return $shared_note['permissions'] & $permission;
188
	}
189
}
190