No not fail on nonexisting acl users/groups

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2017-05-03 12:05:15 +02:00
parent 8b4e7ec2bf
commit a6b6842e2b
6 changed files with 143 additions and 5 deletions

View File

@@ -48,4 +48,9 @@ class AclMapper extends DeckMapper implements IPermissionMapper {
return $entity->getBoardId();
}
public function findByParticipant($type, $participant) {
$sql = 'SELECT * from *PREFIX*deck_board_acl WHERE type = ? AND participant = ?';
return $this->findEntities($sql, [$type, $participant]);
}
}

View File

@@ -52,7 +52,6 @@ class Board extends RelationalEntity implements JsonSerializable {
if ($this->shared === -1) {
unset($json['shared']);
}
$json['owner'] = $this->resolveOwner();
return $json;
}

View File

@@ -130,6 +130,11 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
return $entries;
}
public function findAll() {
$sql = 'SELECT id from *PREFIX*deck_boards;';
return $this->findEntities($sql, []);
}
public function delete(/** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
\OCP\AppFramework\Db\Entity $entity) {
// delete acl
@@ -166,10 +171,22 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
$groupManager = $this->groupManager;
$acl->resolveRelation('participant', function($participant) use (&$acl, &$userManager, &$groupManager) {
if($acl->getType() === Acl::PERMISSION_TYPE_USER) {
return new User($userManager->get($acl->getParticipant($participant)));
$user = $userManager->get($participant);
if($user !== null) {
return new User($user);
} else {
\OC::$server->getLogger()->debug('User ' . $acl->getId() . ' not found when mapping acl ' . $acl->getParticipant());
return $participant;
}
}
if($acl->getType() === Acl::PERMISSION_TYPE_GROUP) {
return new Group($groupManager->get($acl->getParticipant($participant)));
$group = $groupManager->get($participant);
if($group !== null) {
return new Group($group);
} else {
\OC::$server->getLogger()->debug('Group ' . $acl->getId() . ' not found when mapping acl ' . $acl->getParticipant());
return $participant;
}
}
throw new \Exception('Unknown permission type for mapping Acl');
});