Code Duplication    Length = 13-13 lines in 2 locations

lib/Service/OwnNoteService.php 1 location

@@ 442-454 (lines=13) @@
439
		return $farray;
440
	}
441
442
	private function checkPermissions($permission, $nid) {
443
		// gather information
444
		$uid = \OC::$server->getUserSession()->getUser()->getUID();
445
		$note = $this->find($nid);
446
		// owner is allowed to change everything
447
		if ($uid === $note->getUid()) {
448
			return true;
449
		}
450
451
		// check share permissions
452
		$shared_note = \OCP\Share::getItemSharedWith('ownnote', $nid, 'populated_shares')[0];
453
		return $shared_note['permissions'] & $permission;
454
	}
455
}
456

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
?>