Add BoardControllerTest
This commit is contained in:
@@ -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\Controller;
|
||||
@@ -34,40 +34,43 @@ use OCP\IUserManager;
|
||||
use OCP\IGroupManager;
|
||||
|
||||
class BoardController extends Controller {
|
||||
private $userId;
|
||||
private $boardService;
|
||||
protected $userManager;
|
||||
protected $groupManager;
|
||||
private $userId;
|
||||
private $boardService;
|
||||
private $userManager;
|
||||
private $groupManager;
|
||||
private $userInfo;
|
||||
public function __construct($appName,
|
||||
IRequest $request,
|
||||
IUserManager $userManager,
|
||||
IGroupManager $groupManager,
|
||||
BoardService $cardService,
|
||||
$userId) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->userId = $userId;
|
||||
$this->userManager = $userManager;
|
||||
$this->groupManager = $groupManager;
|
||||
$this->boardService = $cardService;
|
||||
$this->userInfo = $this->getBoardPrerequisites();
|
||||
}
|
||||
|
||||
private function getBoardPrerequisites() {
|
||||
$groups = $this->groupManager->getUserGroupIds($this->userManager->get($this->userId));
|
||||
return [
|
||||
'user' => $this->userId,
|
||||
'groups' => $groups
|
||||
];
|
||||
}
|
||||
public function __construct($appName,
|
||||
IRequest $request,
|
||||
IUserManager $userManager,
|
||||
IGroupManager $groupManager,
|
||||
BoardService $boardService,
|
||||
$userId) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->userId = $userId;
|
||||
$this->userManager = $userManager;
|
||||
$this->groupManager = $groupManager;
|
||||
$this->boardService = $boardService;
|
||||
$this->userInfo = $this->getBoardPrerequisites();
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
private function getBoardPrerequisites() {
|
||||
$groups = $this->groupManager->getUserGroupIds(
|
||||
$this->userManager->get($this->userId)
|
||||
);
|
||||
return [
|
||||
'user' => $this->userId,
|
||||
'groups' => $groups
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @RequireNoPermission
|
||||
*/
|
||||
public function index() {
|
||||
return $this->boardService->findAll($this->userInfo);
|
||||
}
|
||||
*/
|
||||
public function index() {
|
||||
return $this->boardService->findAll($this->userInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
@@ -75,9 +78,9 @@ class BoardController extends Controller {
|
||||
* @param $boardId
|
||||
* @return \OCP\AppFramework\Db\Entity
|
||||
*/
|
||||
public function read($boardId) {
|
||||
return $this->boardService->find($boardId);
|
||||
}
|
||||
public function read($boardId) {
|
||||
return $this->boardService->find($boardId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
@@ -86,9 +89,9 @@ class BoardController extends Controller {
|
||||
* @param $color
|
||||
* @return \OCP\AppFramework\Db\Entity
|
||||
*/
|
||||
public function create($title, $color) {
|
||||
return $this->boardService->create($title, $this->userId, $color);
|
||||
}
|
||||
public function create($title, $color) {
|
||||
return $this->boardService->create($title, $this->userId, $color);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
@@ -98,9 +101,9 @@ class BoardController extends Controller {
|
||||
* @param $color
|
||||
* @return \OCP\AppFramework\Db\Entity
|
||||
*/
|
||||
public function update($id, $title, $color) {
|
||||
return $this->boardService->update($id, $title, $color);
|
||||
}
|
||||
public function update($id, $title, $color) {
|
||||
return $this->boardService->update($id, $title, $color);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
@@ -108,19 +111,9 @@ class BoardController extends Controller {
|
||||
* @param $boardId
|
||||
* @return \OCP\AppFramework\Db\Entity
|
||||
*/
|
||||
public function delete($boardId) {
|
||||
return $this->boardService->delete($boardId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @RequireReadPermission
|
||||
* @param $boardId
|
||||
* @return
|
||||
*/
|
||||
public function labels($boardId) {
|
||||
return $this->boardService->labels($boardId);
|
||||
}
|
||||
public function delete($boardId) {
|
||||
return $this->boardService->delete($boardId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
@@ -131,7 +124,7 @@ class BoardController extends Controller {
|
||||
*/
|
||||
public function getUserPermissions($boardId) {
|
||||
$board = $this->boardService->find($boardId);
|
||||
if($this->userId === $board->getOwner()) {
|
||||
if ($this->userId === $board->getOwner()) {
|
||||
return [
|
||||
'PERMISSION_READ' => true,
|
||||
'PERMISSION_EDIT' => true,
|
||||
@@ -160,9 +153,9 @@ class BoardController extends Controller {
|
||||
* @param $manage
|
||||
* @return \OCP\AppFramework\Db\Entity
|
||||
*/
|
||||
public function addAcl($boardId, $type, $participant, $write, $invite, $manage) {
|
||||
return $this->boardService->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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
@@ -173,9 +166,9 @@ class BoardController extends Controller {
|
||||
* @param $permissionManage
|
||||
* @return \OCP\AppFramework\Db\Entity
|
||||
*/
|
||||
public function updateAcl($id, $permissionWrite, $permissionInvite, $permissionManage) {
|
||||
return $this->boardService->updateAcl($id, $permissionWrite, $permissionInvite, $permissionManage);
|
||||
}
|
||||
public function updateAcl($id, $permissionWrite, $permissionInvite, $permissionManage) {
|
||||
return $this->boardService->updateAcl($id, $permissionWrite, $permissionInvite, $permissionManage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
@@ -183,8 +176,8 @@ class BoardController extends Controller {
|
||||
* @param $aclId
|
||||
* @return \OCP\AppFramework\Db\Entity
|
||||
*/
|
||||
public function deleteAcl($aclId) {
|
||||
return $this->boardService->deleteAcl($aclId);
|
||||
}
|
||||
public function deleteAcl($aclId) {
|
||||
return $this->boardService->deleteAcl($aclId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user