@@ -24,15 +24,14 @@
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
class Acl extends RelationalEntity {
|
||||
public const PERMISSION_READ = 0;
|
||||
public const PERMISSION_EDIT = 1;
|
||||
public const PERMISSION_SHARE = 2;
|
||||
public const PERMISSION_MANAGE = 3;
|
||||
|
||||
const PERMISSION_READ = 0;
|
||||
const PERMISSION_EDIT = 1;
|
||||
const PERMISSION_SHARE = 2;
|
||||
const PERMISSION_MANAGE = 3;
|
||||
|
||||
const PERMISSION_TYPE_USER = 0;
|
||||
const PERMISSION_TYPE_GROUP = 1;
|
||||
const PERMISSION_TYPE_CIRCLE = 7;
|
||||
public const PERMISSION_TYPE_USER = 0;
|
||||
public const PERMISSION_TYPE_GROUP = 1;
|
||||
public const PERMISSION_TYPE_CIRCLE = 7;
|
||||
|
||||
protected $participant;
|
||||
protected $type;
|
||||
@@ -67,5 +66,4 @@ class Acl extends RelationalEntity {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,20 +5,20 @@
|
||||
* @author Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Deck\Db;
|
||||
@@ -26,7 +26,6 @@ namespace OCA\Deck\Db;
|
||||
use OCP\IDBConnection;
|
||||
|
||||
class AclMapper extends DeckMapper implements IPermissionMapper {
|
||||
|
||||
public function __construct(IDBConnection $db) {
|
||||
parent::__construct($db, 'deck_board_acl', Acl::class);
|
||||
}
|
||||
@@ -52,5 +51,4 @@ class AclMapper extends DeckMapper implements IPermissionMapper {
|
||||
$sql = 'SELECT * from *PREFIX*deck_board_acl WHERE type = ? AND participant = ?';
|
||||
return $this->findEntities($sql, [$type, $participant]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace OCA\Deck\Db;
|
||||
use JsonSerializable;
|
||||
|
||||
class AssignedUsers extends RelationalEntity implements JsonSerializable {
|
||||
|
||||
public $id;
|
||||
protected $participant;
|
||||
protected $cardId;
|
||||
@@ -42,5 +41,4 @@ class AssignedUsers extends RelationalEntity implements JsonSerializable {
|
||||
$this->addType('type', 'integer');
|
||||
$this->addResolvable('participant');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,9 +29,7 @@ use OCP\IDBConnection;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IUserManager;
|
||||
|
||||
|
||||
class AssignedUsersMapper extends DeckMapper implements IPermissionMapper {
|
||||
|
||||
private $cardMapper;
|
||||
private $userManager;
|
||||
/**
|
||||
@@ -96,7 +94,7 @@ class AssignedUsersMapper extends DeckMapper implements IPermissionMapper {
|
||||
|
||||
public function mapParticipant(AssignedUsers &$assignment) {
|
||||
$self = $this;
|
||||
$assignment->resolveRelation('participant', function() use (&$self, &$assignment) {
|
||||
$assignment->resolveRelation('participant', function () use (&$self, &$assignment) {
|
||||
return $self->getOrigin($assignment);
|
||||
});
|
||||
}
|
||||
@@ -116,5 +114,4 @@ class AssignedUsersMapper extends DeckMapper implements IPermissionMapper {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
class Attachment extends RelationalEntity {
|
||||
|
||||
protected $cardId;
|
||||
protected $type;
|
||||
protected $data;
|
||||
@@ -43,5 +42,4 @@ class Attachment extends RelationalEntity {
|
||||
$this->addResolvable('createdBy');
|
||||
$this->addRelation('extendedData');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,9 +32,7 @@ use OCP\IDBConnection;
|
||||
use OCP\IUserManager;
|
||||
use PDO;
|
||||
|
||||
|
||||
class AttachmentMapper extends DeckMapper implements IPermissionMapper {
|
||||
|
||||
private $cardMapper;
|
||||
private $userManager;
|
||||
private $qb;
|
||||
@@ -67,14 +65,14 @@ class AttachmentMapper extends DeckMapper implements IPermissionMapper {
|
||||
|
||||
$cursor = $qb->execute();
|
||||
$row = $cursor->fetch(PDO::FETCH_ASSOC);
|
||||
if($row === false) {
|
||||
if ($row === false) {
|
||||
$cursor->closeCursor();
|
||||
throw new DoesNotExistException('Did expect one result but found none when executing' . $qb);
|
||||
}
|
||||
|
||||
$row2 = $cursor->fetch();
|
||||
$cursor->closeCursor();
|
||||
if($row2 !== false ) {
|
||||
if ($row2 !== false) {
|
||||
throw new MultipleObjectsReturnedException('Did not expect more than one result when executing' . $query);
|
||||
}
|
||||
|
||||
@@ -82,19 +80,19 @@ class AttachmentMapper extends DeckMapper implements IPermissionMapper {
|
||||
}
|
||||
|
||||
public function findByData($cardId, $data) {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select('*')
|
||||
->from('deck_attachment')
|
||||
->where($qb->expr()->eq('card_id', $qb->createNamedParameter($cardId, IQueryBuilder::PARAM_INT)))
|
||||
->andWhere($qb->expr()->eq('data', $qb->createNamedParameter($data, IQueryBuilder::PARAM_STR)));
|
||||
$cursor = $qb->execute();
|
||||
$row = $cursor->fetch(PDO::FETCH_ASSOC);
|
||||
if($row === false) {
|
||||
$cursor->closeCursor();
|
||||
throw new DoesNotExistException('Did expect one result but found none when executing' . $qb);
|
||||
}
|
||||
$cursor->closeCursor();
|
||||
return $this->mapRowToEntity($row);
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select('*')
|
||||
->from('deck_attachment')
|
||||
->where($qb->expr()->eq('card_id', $qb->createNamedParameter($cardId, IQueryBuilder::PARAM_INT)))
|
||||
->andWhere($qb->expr()->eq('data', $qb->createNamedParameter($data, IQueryBuilder::PARAM_STR)));
|
||||
$cursor = $qb->execute();
|
||||
$row = $cursor->fetch(PDO::FETCH_ASSOC);
|
||||
if ($row === false) {
|
||||
$cursor->closeCursor();
|
||||
throw new DoesNotExistException('Did expect one result but found none when executing' . $qb);
|
||||
}
|
||||
$cursor->closeCursor();
|
||||
return $this->mapRowToEntity($row);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +111,7 @@ class AttachmentMapper extends DeckMapper implements IPermissionMapper {
|
||||
|
||||
$entities = [];
|
||||
$cursor = $qb->execute();
|
||||
while($row = $cursor->fetch()){
|
||||
while ($row = $cursor->fetch()) {
|
||||
$entities[] = $this->mapRowToEntity($row);
|
||||
}
|
||||
$cursor->closeCursor();
|
||||
@@ -143,7 +141,7 @@ class AttachmentMapper extends DeckMapper implements IPermissionMapper {
|
||||
|
||||
$entities = [];
|
||||
$cursor = $qb->execute();
|
||||
while($row = $cursor->fetch()){
|
||||
while ($row = $cursor->fetch()) {
|
||||
$entities[] = $this->mapRowToEntity($row);
|
||||
}
|
||||
$cursor->closeCursor();
|
||||
@@ -182,4 +180,4 @@ class AttachmentMapper extends DeckMapper implements IPermissionMapper {
|
||||
}
|
||||
return $this->cardMapper->findBoardId($attachment->getCardId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
class Board extends RelationalEntity {
|
||||
|
||||
protected $title;
|
||||
protected $owner;
|
||||
protected $color;
|
||||
|
||||
@@ -24,14 +24,12 @@
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\AppFramework\QueryException;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\ILogger;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IGroupManager;
|
||||
|
||||
class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
|
||||
private $labelMapper;
|
||||
private $aclMapper;
|
||||
private $stackMapper;
|
||||
@@ -143,7 +141,7 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
if (!$this->circlesEnabled) {
|
||||
return [];
|
||||
}
|
||||
$circles = array_map(function($circle) {
|
||||
$circles = array_map(function ($circle) {
|
||||
return $circle->getUniqueId();
|
||||
}, \OCA\Circles\Api\v1\Circles::joinedCircles('', true));
|
||||
if (count($circles) === 0) {
|
||||
@@ -215,7 +213,7 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
public function mapAcl(Acl &$acl) {
|
||||
$userManager = $this->userManager;
|
||||
$groupManager = $this->groupManager;
|
||||
$acl->resolveRelation('participant', function($participant) use (&$acl, &$userManager, &$groupManager) {
|
||||
$acl->resolveRelation('participant', function ($participant) use (&$acl, &$userManager, &$groupManager) {
|
||||
if ($acl->getType() === Acl::PERMISSION_TYPE_USER) {
|
||||
$user = $userManager->get($participant);
|
||||
if ($user !== null) {
|
||||
@@ -255,7 +253,7 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
*/
|
||||
public function mapOwner(Board &$board) {
|
||||
$userManager = $this->userManager;
|
||||
$board->resolveRelation('owner', function($owner) use (&$userManager) {
|
||||
$board->resolveRelation('owner', function ($owner) use (&$userManager) {
|
||||
$user = $userManager->get($owner);
|
||||
if ($user !== null) {
|
||||
return new User($user);
|
||||
@@ -263,6 +261,4 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace OCA\Deck\Db;
|
||||
use DateTime;
|
||||
|
||||
class Card extends RelationalEntity {
|
||||
|
||||
protected $title;
|
||||
protected $description;
|
||||
protected $descriptionPrev;
|
||||
@@ -49,10 +48,10 @@ class Card extends RelationalEntity {
|
||||
|
||||
private $databaseType = 'sqlite';
|
||||
|
||||
const DUEDATE_FUTURE = 0;
|
||||
const DUEDATE_NEXT = 1;
|
||||
const DUEDATE_NOW = 2;
|
||||
const DUEDATE_OVERDUE = 3;
|
||||
public const DUEDATE_FUTURE = 0;
|
||||
public const DUEDATE_NEXT = 1;
|
||||
public const DUEDATE_NOW = 2;
|
||||
public const DUEDATE_OVERDUE = 3;
|
||||
|
||||
public function __construct() {
|
||||
$this->addType('id', 'integer');
|
||||
@@ -118,5 +117,4 @@ class Card extends RelationalEntity {
|
||||
unset($json['descriptionPrev']);
|
||||
return $json;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ use OCP\IDBConnection;
|
||||
use OCP\IUserManager;
|
||||
use OCP\Notification\IManager;
|
||||
|
||||
|
||||
class CardMapper extends DeckMapper implements IPermissionMapper {
|
||||
|
||||
/** @var LabelMapper */
|
||||
@@ -164,7 +163,6 @@ class CardMapper extends DeckMapper implements IPermissionMapper {
|
||||
foreach ($cards as $card) {
|
||||
$this->delete($card);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function assignLabel($card, $label) {
|
||||
@@ -199,7 +197,7 @@ class CardMapper extends DeckMapper implements IPermissionMapper {
|
||||
|
||||
public function mapOwner(Card &$card) {
|
||||
$userManager = $this->userManager;
|
||||
$card->resolveRelation('owner', function($owner) use (&$userManager) {
|
||||
$card->resolveRelation('owner', function ($owner) use (&$userManager) {
|
||||
$user = $userManager->get($owner);
|
||||
if ($user !== null) {
|
||||
return new User($user);
|
||||
@@ -207,6 +205,4 @@ class CardMapper extends DeckMapper implements IPermissionMapper {
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,18 +23,13 @@
|
||||
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\ICache;
|
||||
use OCP\ICacheFactory;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IRequest;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IGroupManager;
|
||||
|
||||
class ChangeHelper {
|
||||
|
||||
const TYPE_BOARD = 'boardChanged';
|
||||
const TYPE_CARD = 'cardChanged';
|
||||
public const TYPE_BOARD = 'boardChanged';
|
||||
public const TYPE_CARD = 'cardChanged';
|
||||
|
||||
private $db;
|
||||
|
||||
@@ -100,5 +95,4 @@ class ChangeHelper {
|
||||
}
|
||||
return $entry;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
|
||||
use OCP\Share\IShare;
|
||||
|
||||
class Circle extends RelationalObject {
|
||||
|
||||
@@ -5,20 +5,20 @@
|
||||
* @author Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Deck\Db;
|
||||
@@ -48,5 +48,4 @@ abstract class DeckMapper extends Mapper {
|
||||
protected function execute($sql, array $params = [], $limit = null, $offset = null) {
|
||||
return parent::execute($sql, $params, $limit, $offset);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ use OCP\IGroup;
|
||||
use OCP\Share\IShare;
|
||||
|
||||
class Group extends RelationalObject {
|
||||
|
||||
public function __construct(IGroup $group) {
|
||||
$primaryKey = IShare::TYPE_GROUP . ':' . $group->getGID();
|
||||
parent::__construct($primaryKey, $group);
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
|
||||
interface IPermissionMapper {
|
||||
|
||||
/**
|
||||
@@ -43,6 +42,4 @@ interface IPermissionMapper {
|
||||
* @return int|null id of Board
|
||||
*/
|
||||
public function findBoardId($id);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
class Label extends RelationalEntity {
|
||||
|
||||
protected $title;
|
||||
protected $color;
|
||||
protected $boardId;
|
||||
|
||||
@@ -26,9 +26,7 @@ namespace OCA\Deck\Db;
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
use OCP\IDBConnection;
|
||||
|
||||
|
||||
class LabelMapper extends DeckMapper implements IPermissionMapper {
|
||||
|
||||
public function __construct(IDBConnection $db) {
|
||||
parent::__construct($db, 'deck_labels', Label::class);
|
||||
}
|
||||
@@ -70,10 +68,10 @@ class LabelMapper extends DeckMapper implements IPermissionMapper {
|
||||
|
||||
public function getAssignedLabelsForBoard($boardId) {
|
||||
$labels = $this->findAssignedLabelsForBoard($boardId);
|
||||
$result = array();
|
||||
$result = [];
|
||||
foreach ($labels as $label) {
|
||||
if (!array_key_exists($label->getCardId(), $result)) {
|
||||
$result[$label->getCardId()] = array();
|
||||
$result[$label->getCardId()] = [];
|
||||
}
|
||||
$result[$label->getCardId()][] = $label;
|
||||
}
|
||||
|
||||
@@ -5,20 +5,20 @@
|
||||
* @author Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Deck\Db;
|
||||
@@ -26,8 +26,7 @@ namespace OCA\Deck\Db;
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
|
||||
class RelationalEntity extends Entity implements \JsonSerializable {
|
||||
|
||||
private $_relations = array();
|
||||
private $_relations = [];
|
||||
private $_resolvedProperties = [];
|
||||
|
||||
/**
|
||||
@@ -137,5 +136,4 @@ class RelationalEntity extends Entity implements \JsonSerializable {
|
||||
}
|
||||
return parent::__call($methodName, $args);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
class RelationalObject implements \JsonSerializable {
|
||||
|
||||
protected $primaryKey;
|
||||
protected $object;
|
||||
|
||||
@@ -58,5 +57,4 @@ class RelationalObject implements \JsonSerializable {
|
||||
throw new \Exception('jsonSerialize is not implemented on ' . get_class($this));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,12 +24,11 @@
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
class Stack extends RelationalEntity {
|
||||
|
||||
protected $title;
|
||||
protected $boardId;
|
||||
protected $deletedAt = 0;
|
||||
protected $lastModified = 0;
|
||||
protected $cards = array();
|
||||
protected $cards = [];
|
||||
protected $order;
|
||||
|
||||
public function __construct() {
|
||||
|
||||
@@ -5,20 +5,20 @@
|
||||
* @author Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Deck\Db;
|
||||
@@ -26,9 +26,7 @@ namespace OCA\Deck\Db;
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
use OCP\IDBConnection;
|
||||
|
||||
|
||||
class StackMapper extends DeckMapper implements IPermissionMapper {
|
||||
|
||||
private $cardMapper;
|
||||
|
||||
public function __construct(IDBConnection $db, CardMapper $cardMapper) {
|
||||
@@ -57,9 +55,9 @@ class StackMapper extends DeckMapper implements IPermissionMapper {
|
||||
|
||||
|
||||
public function findDeleted($boardId, $limit = null, $offset = null) {
|
||||
$sql = 'SELECT * FROM `*PREFIX*deck_stacks` s
|
||||
$sql = 'SELECT * FROM `*PREFIX*deck_stacks` s
|
||||
WHERE `s`.`board_id` = ? AND NOT s.deleted_at = 0';
|
||||
return $this->findEntities($sql, [$boardId], $limit, $offset);
|
||||
return $this->findEntities($sql, [$boardId], $limit, $offset);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ use OCP\IUser;
|
||||
use OCP\Share\IShare;
|
||||
|
||||
class User extends RelationalObject {
|
||||
|
||||
public function __construct(IUser $user) {
|
||||
$primaryKey = IShare::TYPE_USER . ':' . $user->getUID();
|
||||
parent::__construct($primaryKey, $user);
|
||||
|
||||
Reference in New Issue
Block a user