Disable ui elements if permissions are not sufficient
This commit is contained in:
@@ -42,9 +42,11 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param bool $withLabels
|
||||
* @param bool $withAcl
|
||||
* @return \OCP\AppFramework\Db\Entity if not found
|
||||
*/
|
||||
public function find($id) {
|
||||
public function find($id, $withLabels=false, $withAcl=false) {
|
||||
$sql = 'SELECT id, title, owner, color, archived FROM `*PREFIX*deck_boards` ' .
|
||||
'WHERE `id` = ?';
|
||||
$board = $this->findEntity($sql, [$id]);
|
||||
@@ -95,13 +97,12 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
}
|
||||
$sql = 'SELECT boards.id, title, owner, color, archived, 2 as shared FROM oc_deck_boards as boards ' .
|
||||
'INNER JOIN oc_deck_board_acl as acl ON boards.id=acl.board_id WHERE owner != ? AND type=\'group\' AND (';
|
||||
$countGroups = 0;
|
||||
// FIXME: group unused?
|
||||
foreach ($groups as $group) {
|
||||
$sql .= 'acl.participant = ? ';
|
||||
if(count($groups)>1 && $countGroups++<count($groups)-1)
|
||||
$sql .= ' OR ';
|
||||
}
|
||||
for($i=0;$i<count($groups);$i++) {
|
||||
$sql .= 'acl.participant = ? ';
|
||||
if(count($groups)>1 && $i<count($groups)-1) {
|
||||
$sql .= ' OR ';
|
||||
}
|
||||
}
|
||||
$sql .= ');';
|
||||
$entries = $this->findEntities($sql, array_merge([$userId], $groups), $limit, $offset);
|
||||
/* @var Board $entry */
|
||||
@@ -112,7 +113,8 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
return $entries;
|
||||
}
|
||||
|
||||
public function delete(\OCP\AppFramework\Db\Entity $entity) {
|
||||
public function delete(/** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
|
||||
\OCP\AppFramework\Db\Entity $entity) {
|
||||
// delete acl
|
||||
$acl = $this->aclMapper->findAll($entity->getId());
|
||||
foreach ($acl as $item) {
|
||||
|
||||
@@ -25,8 +25,6 @@ namespace OCA\Deck\Db;
|
||||
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
use OCP\IDb;
|
||||
use OCP\AppFramework\Db\Mapper;
|
||||
|
||||
|
||||
|
||||
class CardMapper extends DeckMapper implements IPermissionMapper {
|
||||
|
||||
@@ -51,6 +51,8 @@ abstract class DeckMapper extends Mapper {
|
||||
|
||||
protected function execute($sql, array $params = [], $limit = null, $offset = null) {
|
||||
// FIXME: remove on release
|
||||
/** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
|
||||
/** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
|
||||
\OCP\Util::writeLog('deck', "DeckMapper SQL: " . $sql . " with " . implode("|", $params), \OCP\Util::DEBUG);
|
||||
return parent::execute($sql, $params, $limit, $offset);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ namespace OCA\Deck\Db;
|
||||
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
use OCP\IDb;
|
||||
use OCP\AppFramework\Db\Mapper;
|
||||
|
||||
|
||||
class StackMapper extends DeckMapper implements IPermissionMapper {
|
||||
|
||||
Reference in New Issue
Block a user