PHPdoc and small fixes
This commit is contained in:
@@ -28,7 +28,7 @@ class CardArchivedException extends \Exception {
|
|||||||
* Constructor
|
* Constructor
|
||||||
* @param string $msg the error message
|
* @param string $msg the error message
|
||||||
*/
|
*/
|
||||||
public function __construct($msg){
|
public function __construct($msg=""){
|
||||||
parent::__construct($msg);
|
parent::__construct($msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,10 +49,10 @@ class BoardController extends Controller {
|
|||||||
$this->userManager = $userManager;
|
$this->userManager = $userManager;
|
||||||
$this->groupManager = $groupManager;
|
$this->groupManager = $groupManager;
|
||||||
$this->boardService = $cardService;
|
$this->boardService = $cardService;
|
||||||
$this->userInfo = $this->getBoardPrequisites();
|
$this->userInfo = $this->getBoardPrerequisites();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getBoardPrequisites() {
|
private function getBoardPrerequisites() {
|
||||||
$groups = $this->groupManager->getUserGroupIds($this->userManager->get($this->userId));
|
$groups = $this->groupManager->getUserGroupIds($this->userManager->get($this->userId));
|
||||||
return [
|
return [
|
||||||
'user' => $this->userId,
|
'user' => $this->userId,
|
||||||
@@ -71,6 +71,8 @@ class BoardController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireReadPermission
|
* @RequireReadPermission
|
||||||
|
* @param $boardId
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function read($boardId) {
|
public function read($boardId) {
|
||||||
return $this->boardService->find($this->userId, $boardId);
|
return $this->boardService->find($this->userId, $boardId);
|
||||||
@@ -79,6 +81,9 @@ class BoardController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireNoPermission
|
* @RequireNoPermission
|
||||||
|
* @param $title
|
||||||
|
* @param $color
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function create($title, $color) {
|
public function create($title, $color) {
|
||||||
return $this->boardService->create($title, $this->userId, $color);
|
return $this->boardService->create($title, $this->userId, $color);
|
||||||
@@ -87,6 +92,10 @@ class BoardController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireManagePermission
|
* @RequireManagePermission
|
||||||
|
* @param $id
|
||||||
|
* @param $title
|
||||||
|
* @param $color
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function update($id, $title, $color) {
|
public function update($id, $title, $color) {
|
||||||
return $this->boardService->update($id, $title, $this->userId, $color);
|
return $this->boardService->update($id, $title, $this->userId, $color);
|
||||||
@@ -95,6 +104,8 @@ class BoardController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireManagePermission
|
* @RequireManagePermission
|
||||||
|
* @param $boardId
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function delete($boardId) {
|
public function delete($boardId) {
|
||||||
return $this->boardService->delete($this->userId, $boardId);
|
return $this->boardService->delete($this->userId, $boardId);
|
||||||
@@ -103,6 +114,8 @@ class BoardController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireReadPermission
|
* @RequireReadPermission
|
||||||
|
* @param $boardId
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public function labels($boardId) {
|
public function labels($boardId) {
|
||||||
return $this->boardService->labels($boardId);
|
return $this->boardService->labels($boardId);
|
||||||
@@ -111,6 +124,13 @@ class BoardController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireManagePermission
|
* @RequireManagePermission
|
||||||
|
* @param $boardId
|
||||||
|
* @param $type
|
||||||
|
* @param $participant
|
||||||
|
* @param $write
|
||||||
|
* @param $invite
|
||||||
|
* @param $manage
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function addAcl($boardId, $type, $participant, $write, $invite, $manage) {
|
public function addAcl($boardId, $type, $participant, $write, $invite, $manage) {
|
||||||
return $this->boardService->addAcl($boardId, $type, $participant, $write, $invite, $manage);
|
return $this->boardService->addAcl($boardId, $type, $participant, $write, $invite, $manage);
|
||||||
@@ -119,6 +139,11 @@ class BoardController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireManagePermission
|
* @RequireManagePermission
|
||||||
|
* @param $id
|
||||||
|
* @param $permissionWrite
|
||||||
|
* @param $permissionInvite
|
||||||
|
* @param $permissionManage
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function updateAcl($id, $permissionWrite, $permissionInvite, $permissionManage) {
|
public function updateAcl($id, $permissionWrite, $permissionInvite, $permissionManage) {
|
||||||
return $this->boardService->updateAcl($id, $permissionWrite, $permissionInvite, $permissionManage);
|
return $this->boardService->updateAcl($id, $permissionWrite, $permissionInvite, $permissionManage);
|
||||||
@@ -127,6 +152,8 @@ class BoardController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireManagePermission
|
* @RequireManagePermission
|
||||||
|
* @param $aclId
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function deleteAcl($aclId) {
|
public function deleteAcl($aclId) {
|
||||||
return $this->boardService->deleteAcl($aclId);
|
return $this->boardService->deleteAcl($aclId);
|
||||||
|
|||||||
@@ -39,44 +39,73 @@ class CardController extends Controller {
|
|||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
$this->cardService = $cardService;
|
$this->cardService = $cardService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireReadPermission
|
* @RequireReadPermission
|
||||||
|
* @param $cardId
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function read($cardId) {
|
public function read($cardId) {
|
||||||
return $this->cardService->find($this->userId, $cardId);
|
return $this->cardService->find($this->userId, $cardId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireEditPermission
|
* @RequireEditPermission
|
||||||
|
* @param $cardId
|
||||||
|
* @param $stackId
|
||||||
|
* @param $order
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function reorder($cardId, $stackId, $order) {
|
public function reorder($cardId, $stackId, $order) {
|
||||||
return $this->cardService->reorder($cardId, $stackId, $order);
|
return $this->cardService->reorder($cardId, $stackId, $order);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireEditPermission
|
* @RequireEditPermission
|
||||||
|
* @param $cardId
|
||||||
|
* @param $title
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function rename($cardId, $title) {
|
public function rename($cardId, $title) {
|
||||||
return $this->cardService->rename($cardId, $title);
|
return $this->cardService->rename($cardId, $title);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireEditPermission
|
* @RequireEditPermission
|
||||||
|
* @param $title
|
||||||
|
* @param $stackId
|
||||||
|
* @param $type
|
||||||
|
* @param int $order
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function create($title, $stackId, $type, $order=999) {
|
public function create($title, $stackId, $type, $order=999) {
|
||||||
return $this->cardService->create($title, $stackId, $type, $order, $this->userId);
|
return $this->cardService->create($title, $stackId, $type, $order, $this->userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireEditPermission
|
* @RequireEditPermission
|
||||||
|
* @param $id
|
||||||
|
* @param $title
|
||||||
|
* @param $stackId
|
||||||
|
* @param $type
|
||||||
|
* @param $order
|
||||||
|
* @param $description
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function update($id, $title, $stackId, $type, $order, $description) {
|
public function update($id, $title, $stackId, $type, $order, $description) {
|
||||||
return $this->cardService->update($id, $title, $stackId, $type, $order, $description, $this->userId);
|
return $this->cardService->update($id, $title, $stackId, $type, $order, $description, $this->userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireEditPermission
|
* @RequireEditPermission
|
||||||
|
* @param $cardId
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function delete($cardId) {
|
public function delete($cardId) {
|
||||||
return $this->cardService->delete($this->userId, $cardId);
|
return $this->cardService->delete($this->userId, $cardId);
|
||||||
@@ -85,27 +114,38 @@ class CardController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireEditPermission
|
* @RequireEditPermission
|
||||||
|
* @param $cardId
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function archive($cardId) {
|
public function archive($cardId) {
|
||||||
return $this->cardService->archive($cardId);
|
return $this->cardService->archive($cardId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireEditPermission
|
* @RequireEditPermission
|
||||||
|
* @param $cardId
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function unarchive($cardId) {
|
public function unarchive($cardId) {
|
||||||
return $this->cardService->unarchive($cardId);
|
return $this->cardService->unarchive($cardId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireEditPermission
|
* @RequireEditPermission
|
||||||
|
* @param $cardId
|
||||||
|
* @param $labelId
|
||||||
*/
|
*/
|
||||||
public function assignLabel($cardId, $labelId) {
|
public function assignLabel($cardId, $labelId) {
|
||||||
return $this->cardService->assignLabel($this->userId, $cardId, $labelId);
|
return $this->cardService->assignLabel($this->userId, $cardId, $labelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireEditPermission
|
* @RequireEditPermission
|
||||||
|
* @param $cardId
|
||||||
|
* @param $labelId
|
||||||
*/
|
*/
|
||||||
public function removeLabel($cardId, $labelId) {
|
public function removeLabel($cardId, $labelId) {
|
||||||
return $this->cardService->removeLabel($this->userId, $cardId, $labelId);
|
return $this->cardService->removeLabel($this->userId, $cardId, $labelId);
|
||||||
|
|||||||
@@ -45,20 +45,32 @@ class LabelController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireManagePermission
|
* @RequireManagePermission
|
||||||
|
* @param $title
|
||||||
|
* @param $color
|
||||||
|
* @param $boardId
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function create($title, $color, $boardId) {
|
public function create($title, $color, $boardId) {
|
||||||
return $this->labelService->create($title, $this->userId, $color, $boardId);
|
return $this->labelService->create($title, $this->userId, $color, $boardId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireManagePermission
|
* @RequireManagePermission
|
||||||
|
* @param $id
|
||||||
|
* @param $title
|
||||||
|
* @param $color
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function update($id, $title, $color) {
|
public function update($id, $title, $color) {
|
||||||
return $this->labelService->update($id, $title, $this->userId, $color);
|
return $this->labelService->update($id, $title, $this->userId, $color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireManagePermission
|
* @RequireManagePermission
|
||||||
|
* @param $labelId
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function delete($labelId) {
|
public function delete($labelId) {
|
||||||
return $this->labelService->delete($this->userId, $labelId);
|
return $this->labelService->delete($this->userId, $labelId);
|
||||||
|
|||||||
@@ -47,9 +47,12 @@ class ShareController extends Controller {
|
|||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireNoPermission
|
* @RequireNoPermission
|
||||||
|
* @param $search
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function searchUser($search) {
|
public function searchUser($search) {
|
||||||
$limit = 3;
|
$limit = 3;
|
||||||
|
|||||||
@@ -41,44 +41,67 @@ class StackController extends Controller {
|
|||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
$this->stackService = $cardService;
|
$this->stackService = $cardService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireReadPermission
|
* @RequireReadPermission
|
||||||
|
* @param $boardId
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function index($boardId) {
|
public function index($boardId) {
|
||||||
return $this->stackService->findAll($boardId);
|
return $this->stackService->findAll($boardId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireReadPermission
|
* @RequireReadPermission
|
||||||
|
* @param $boardId
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function archived($boardId) {
|
public function archived($boardId) {
|
||||||
return $this->stackService->findAllArchived($boardId);
|
return $this->stackService->findAllArchived($boardId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireReadPermission
|
* @RequireReadPermission
|
||||||
|
* @param $boardId
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public function read($boardId) {
|
public function read($boardId) {
|
||||||
return $this->stackService->find($this->userId, $boardId);
|
return $this->stackService->find($this->userId, $boardId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireManagePermission
|
* @RequireManagePermission
|
||||||
|
* @param $title
|
||||||
|
* @param $boardId
|
||||||
|
* @param int $order
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function create($title, $boardId, $order=999) {
|
public function create($title, $boardId, $order=999) {
|
||||||
return $this->stackService->create($title, $boardId, $order);
|
return $this->stackService->create($title, $boardId, $order);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireManagePermission
|
* @RequireManagePermission
|
||||||
|
* @param $id
|
||||||
|
* @param $title
|
||||||
|
* @param $boardId
|
||||||
|
* @param $order
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function update($id, $title, $boardId, $order) {
|
public function update($id, $title, $boardId, $order) {
|
||||||
return $this->stackService->update($id, $title, $boardId, $order);
|
return $this->stackService->update($id, $title, $boardId, $order);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @RequireManagePermission
|
* @RequireManagePermission
|
||||||
|
* @param $stackId
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function delete($stackId) {
|
public function delete($stackId) {
|
||||||
return $this->stackService->delete($this->userId, $stackId);
|
return $this->stackService->delete($this->userId, $stackId);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OCA\Deck\Db;
|
|||||||
|
|
||||||
use JsonSerializable;
|
use JsonSerializable;
|
||||||
|
|
||||||
class Board extends \OCA\Deck\Db\Entity implements JsonSerializable {
|
class Board extends Entity implements JsonSerializable {
|
||||||
|
|
||||||
public $id;
|
public $id;
|
||||||
protected $title;
|
protected $title;
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
|
* @param $id
|
||||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
|
* @return \OCP\AppFramework\Db\Entity if not found
|
||||||
*/
|
*/
|
||||||
public function find($id) {
|
public function find($id) {
|
||||||
$sql = 'SELECT id, title, owner, color, archived FROM `*PREFIX*deck_boards` ' .
|
$sql = 'SELECT id, title, owner, color, archived FROM `*PREFIX*deck_boards` ' .
|
||||||
@@ -79,8 +79,11 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
|||||||
}
|
}
|
||||||
return $entries;
|
return $entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find all boards for a given user
|
* Find all boards for a given user
|
||||||
|
*
|
||||||
|
* @param $userId
|
||||||
* @param $groups
|
* @param $groups
|
||||||
* @param null $limit
|
* @param null $limit
|
||||||
* @param null $offset
|
* @param null $offset
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ class CardMapper extends Mapper implements IPermissionMapper {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
|
* @param $id
|
||||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
|
* @return Entity if not found
|
||||||
*/
|
*/
|
||||||
public function find($id) {
|
public function find($id) {
|
||||||
$sql = 'SELECT * FROM `*PREFIX*deck_cards` ' .
|
$sql = 'SELECT * FROM `*PREFIX*deck_cards` ' .
|
||||||
@@ -68,7 +68,6 @@ class CardMapper extends Mapper implements IPermissionMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function findAll($stackId, $limit=null, $offset=null) {
|
public function findAll($stackId, $limit=null, $offset=null) {
|
||||||
// TODO: Exclude fields like text
|
|
||||||
$sql = 'SELECT * FROM `*PREFIX*deck_cards`
|
$sql = 'SELECT * FROM `*PREFIX*deck_cards`
|
||||||
WHERE `stack_id` = ? AND NOT archived ORDER BY `order`';
|
WHERE `stack_id` = ? AND NOT archived ORDER BY `order`';
|
||||||
$entities = $this->findEntities($sql, [$stackId], $limit, $offset);
|
$entities = $this->findEntities($sql, [$stackId], $limit, $offset);
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ use OCP\AppFramework\Db\Mapper;
|
|||||||
abstract class DeckMapper extends Mapper {
|
abstract class DeckMapper extends Mapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
|
* @param $id
|
||||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
|
* @return \OCP\AppFramework\Db\Entity if not found
|
||||||
*/
|
*/
|
||||||
public function find($id) {
|
public function find($id) {
|
||||||
$sql = 'SELECT * FROM `' . $this->tableName . '` ' . 'WHERE `id` = ?';
|
$sql = 'SELECT * FROM `' . $this->tableName . '` ' . 'WHERE `id` = ?';
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ namespace OCA\Deck\Db;
|
|||||||
|
|
||||||
interface IPermissionMapper {
|
interface IPermissionMapper {
|
||||||
|
|
||||||
// FIXME: Optimize implementations as e.g. BoardMapper::isOwner doesn't need to select all fields
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if $userId is owner of Entity with $id
|
* Check if $userId is owner of Entity with $id
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class LabelMapper extends DeckMapper implements IPermissionMapper {
|
|||||||
$labels = $this->findAssignedLabelsForBoard($boardId);
|
$labels = $this->findAssignedLabelsForBoard($boardId);
|
||||||
$result = array();
|
$result = array();
|
||||||
foreach ($labels as $label) {
|
foreach ($labels as $label) {
|
||||||
if(!is_array($result[$label->getCardId()])) {
|
if(!array_key_exists($label->getCardId(), $result)) {
|
||||||
$result[$label->getCardId()] = array();
|
$result[$label->getCardId()] = array();
|
||||||
}
|
}
|
||||||
$result[$label->getCardId()][] = $label;
|
$result[$label->getCardId()][] = $label;
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ class StackMapper extends Mapper implements IPermissionMapper {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
|
* @param $id
|
||||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
|
* @return Entity if not found
|
||||||
*/
|
*/
|
||||||
public function find($id) {
|
public function find($id) {
|
||||||
$sql = 'SELECT * FROM `*PREFIX*deck_stacks` ' .
|
$sql = 'SELECT * FROM `*PREFIX*deck_stacks` ' .
|
||||||
|
|||||||
@@ -191,6 +191,7 @@ class SharingMiddleware extends Middleware {
|
|||||||
* @param $mapper
|
* @param $mapper
|
||||||
* @param $id
|
* @param $id
|
||||||
* @return bool
|
* @return bool
|
||||||
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
public function checkMapperPermission($permission, $userId, $mapper, $id) {
|
public function checkMapperPermission($permission, $userId, $mapper, $id) {
|
||||||
// check if current user is owner
|
// check if current user is owner
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OCA\Deck;
|
|||||||
|
|
||||||
class NotFoundException extends \Exception {
|
class NotFoundException extends \Exception {
|
||||||
|
|
||||||
public function __construct($message) {
|
public function __construct($message="") {
|
||||||
parent::__construct($message);
|
parent::__construct($message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,6 @@ use OCA\Deck\Db\Label;
|
|||||||
use OCP\ILogger;
|
use OCP\ILogger;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
|
|
||||||
use OCP\AppFramework\Utility\ITimeFactory;
|
|
||||||
|
|
||||||
use \OCA\Deck\Db\Board;
|
use \OCA\Deck\Db\Board;
|
||||||
use \OCA\Deck\Db\BoardMapper;
|
use \OCA\Deck\Db\BoardMapper;
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ use OCA\Deck\Db\Label;
|
|||||||
use OCP\ILogger;
|
use OCP\ILogger;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
|
|
||||||
use OCP\AppFramework\Utility\ITimeFactory;
|
|
||||||
|
|
||||||
|
|
||||||
use \OCA\Deck\Db\LabelMapper;
|
use \OCA\Deck\Db\LabelMapper;
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @copyright Copyright (c) 2016 Julius Härtl <jus@bitgrid.net>
|
|
||||||
*
|
|
||||||
* @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\Service;
|
|
||||||
|
|
||||||
class ServicePermissionException extends \Exception {
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* @param string $msg the error message
|
|
||||||
*/
|
|
||||||
public function __construct($msg){
|
|
||||||
parent::__construct($msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -54,13 +54,14 @@ class StackService {
|
|||||||
public function findAll($boardId) {
|
public function findAll($boardId) {
|
||||||
$stacks = $this->stackMapper->findAll($boardId);
|
$stacks = $this->stackMapper->findAll($boardId);
|
||||||
$labels = $this->labelMapper->getAssignedLabelsForBoard($boardId);
|
$labels = $this->labelMapper->getAssignedLabelsForBoard($boardId);
|
||||||
|
foreach ($stacks as $stackIndex => $stack) {
|
||||||
foreach ($stacks as $idx => $s) {
|
$cards = $this->cardMapper->findAll($stack->id);
|
||||||
$cards = $this->cardMapper->findAll($s->id);
|
foreach ($cards as $cardIndex => $card) {
|
||||||
foreach ($cards as $idxc => $card) {
|
if(array_key_exists($card->id, $labels)) {
|
||||||
$cards[$idxc]->setLabels($labels[$card->id]);
|
$cards[$cardIndex]->setLabels($labels[$card->id]);
|
||||||
}
|
}
|
||||||
$stacks[$idx]->setCards($cards);
|
}
|
||||||
|
$stacks[$stackIndex]->setCards($cards);
|
||||||
}
|
}
|
||||||
return $stacks;
|
return $stacks;
|
||||||
}
|
}
|
||||||
@@ -68,12 +69,14 @@ class StackService {
|
|||||||
public function findAllArchived($boardId) {
|
public function findAllArchived($boardId) {
|
||||||
$stacks = $this->stackMapper->findAll($boardId);
|
$stacks = $this->stackMapper->findAll($boardId);
|
||||||
$labels = $this->labelMapper->getAssignedLabelsForBoard($boardId);
|
$labels = $this->labelMapper->getAssignedLabelsForBoard($boardId);
|
||||||
foreach ($stacks as $idx => $s) {
|
foreach ($stacks as $stackIndex => $stack) {
|
||||||
$cards = $this->cardMapper->findAllArchived($s->id);
|
$cards = $this->cardMapper->findAllArchived($stack->id);
|
||||||
foreach ($cards as $idxc => $card) {
|
foreach ($cards as $cardIndex => $card) {
|
||||||
$cards[$idxc]->setLabels($labels[$card->id]);
|
if(array_key_exists($card->id, $labels)) {
|
||||||
|
$cards[$cardIndex]->setLabels($labels[$card->id]);
|
||||||
}
|
}
|
||||||
$stacks[$idx]->setCards($cards);
|
}
|
||||||
|
$stacks[$stackIndex]->setCards($cards);
|
||||||
}
|
}
|
||||||
return $stacks;
|
return $stacks;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user