move to PSR-4
This commit is contained in:
114
lib/Controller/BoardController.php
Normal file
114
lib/Controller/BoardController.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?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\Controller;
|
||||
|
||||
use OCA\Deck\Service\BoardService;
|
||||
|
||||
use OCP\IRequest;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IGroupManager;
|
||||
|
||||
class BoardController extends Controller {
|
||||
private $userId;
|
||||
private $boardService;
|
||||
protected $userManager;
|
||||
protected $groupManager;
|
||||
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->getBoardPrequisites();
|
||||
}
|
||||
|
||||
private function getBoardPrequisites() {
|
||||
$groups = $this->groupManager->getUserGroupIds($this->userManager->get($this->userId));
|
||||
return [
|
||||
'user' => $this->userId,
|
||||
'groups' => $groups
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function index() {
|
||||
|
||||
return $this->boardService->findAll($this->userInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function read($boardId) {
|
||||
// FIXME: Remove as this is just for testing if loading animation works out nicely
|
||||
//usleep(2000);
|
||||
return $this->boardService->find($this->userId, $boardId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function create($title, $color) {
|
||||
return $this->boardService->create($title, $this->userId, $color);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function update($id, $title, $color) {
|
||||
return $this->boardService->update($id, $title, $this->userId, $color);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function delete($boardId) {
|
||||
return $this->boardService->delete($this->userId, $boardId);
|
||||
}
|
||||
|
||||
public function labels($boardId) {
|
||||
return $this->boardService->labels($this->boardId);
|
||||
}
|
||||
|
||||
public function addAcl($boardId, $type, $participant, $write, $invite, $manage) {
|
||||
return $this->boardService->addAcl($boardId, $type, $participant, $write, $invite, $manage);
|
||||
}
|
||||
public function updateAcl($id, $permissionWrite, $permissionInvite, $permissionManage) {
|
||||
return $this->boardService->updateAcl($id, $permissionWrite, $permissionInvite, $permissionManage);
|
||||
}
|
||||
public function deleteAcl($id) {
|
||||
return $this->boardService->deleteAcl($id);
|
||||
}
|
||||
|
||||
}
|
||||
110
lib/Controller/CardController.php
Normal file
110
lib/Controller/CardController.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?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\Controller;
|
||||
|
||||
use OCA\Deck\Service\CardService;
|
||||
|
||||
use OCP\IRequest;
|
||||
use OCP\AppFramework\Controller;
|
||||
|
||||
class CardController extends Controller {
|
||||
private $userId;
|
||||
private $cardService;
|
||||
public function __construct($appName,
|
||||
IRequest $request,
|
||||
CardService $cardService,
|
||||
$userId){
|
||||
parent::__construct($appName, $request);
|
||||
$this->userId = $userId;
|
||||
$this->cardService = $cardService;
|
||||
}
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function index($cardId) {
|
||||
return $this->cardService->findAll($boardId);
|
||||
}
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function read($cardId) {
|
||||
return $this->cardService->find($this->userId, $cardId);
|
||||
}
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function reorder($cardId, $stackId, $order) {
|
||||
return $this->cardService->reorder($cardId, $stackId, $order);
|
||||
}
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function rename($cardId, $title) {
|
||||
return $this->cardService->rename($cardId, $title);
|
||||
}
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function create($title, $stackId, $type, $order=999) {
|
||||
return $this->cardService->create($title, $stackId, $type, $order, $this->userId);
|
||||
}
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function update($id, $title, $stackId, $type, $order, $description) {
|
||||
return $this->cardService->update($id, $title, $stackId, $type, $order, $description, $this->userId);
|
||||
}
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function delete($cardId) {
|
||||
return $this->cardService->delete($this->userId, $cardId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function archive($cardId) {
|
||||
return $this->cardService->archive($cardId);
|
||||
}
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function unarchive($cardId) {
|
||||
return $this->cardService->unarchive($cardId);
|
||||
}
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function assignLabel($cardId, $labelId) {
|
||||
return $this->cardService->assignLabel($this->userId, $cardId, $labelId);
|
||||
}
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function removeLabel($cardId, $labelId) {
|
||||
return $this->cardService->removeLabel($this->userId, $cardId, $labelId);
|
||||
}
|
||||
|
||||
}
|
||||
64
lib/Controller/LabelController.php
Normal file
64
lib/Controller/LabelController.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?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\Controller;
|
||||
|
||||
use OCA\Deck\Service\LabelService;
|
||||
|
||||
use OCP\IRequest;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
|
||||
class LabelController extends Controller {
|
||||
private $userId;
|
||||
private $labelService;
|
||||
public function __construct($appName,
|
||||
IRequest $request,
|
||||
LabelService $labelService,
|
||||
$userId){
|
||||
parent::__construct($appName, $request);
|
||||
$this->userId = $userId;
|
||||
$this->labelService = $labelService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function create($title, $color, $boardId) {
|
||||
return $this->labelService->create($title, $this->userId, $color, $boardId);
|
||||
}
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function update($id, $title, $color) {
|
||||
return $this->labelService->update($id, $title, $this->userId, $color);
|
||||
}
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function delete($labelId) {
|
||||
return $this->labelService->delete($this->userId, $labelId);
|
||||
}
|
||||
|
||||
}
|
||||
58
lib/Controller/PageController.php
Normal file
58
lib/Controller/PageController.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?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\Controller;
|
||||
|
||||
use OCP\IRequest;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\IL10N;
|
||||
|
||||
class PageController extends Controller {
|
||||
|
||||
|
||||
private $userId;
|
||||
private $l10n;
|
||||
|
||||
public function __construct($AppName, IRequest $request, IL10N $l10n, $userId) {
|
||||
parent::__construct($AppName, $request);
|
||||
$this->userId = $userId;
|
||||
$this->l10n = $l10n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle main html view from templates/main.php
|
||||
* This will return the main angular application
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function index() {
|
||||
$params = [
|
||||
'user' => $this->userId,
|
||||
];
|
||||
return new TemplateResponse('deck', 'main', $params);
|
||||
}
|
||||
|
||||
}
|
||||
80
lib/Controller/ShareController.php
Normal file
80
lib/Controller/ShareController.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?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\Controller;
|
||||
|
||||
use OCA\Deck\Db\Acl;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IRequest;
|
||||
use OCP\AppFramework\ApiController as BaseApiController;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\IUserManager;
|
||||
class ShareController extends Controller {
|
||||
|
||||
protected $userManager;
|
||||
protected $groupManager;
|
||||
private $userId;
|
||||
public function __construct($appName,
|
||||
IRequest $request,
|
||||
IUserManager $userManager,
|
||||
IGroupManager $groupManager,
|
||||
$userId
|
||||
){
|
||||
parent::__construct($appName, $request);
|
||||
$this->userManager = $userManager;
|
||||
$this->groupManager = $groupManager;
|
||||
$this->userId = $userId;
|
||||
|
||||
}
|
||||
/**
|
||||
* FIXME: REMOVE, just for testing
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function searchUser($search) {
|
||||
$limit = null;
|
||||
$offset = null;
|
||||
$result = [];
|
||||
foreach ($this->groupManager->search($search, $limit, $offset) as $idx => $group) {
|
||||
$acl = new Acl();
|
||||
$acl->setType('group');
|
||||
$acl->setParticipant($group->getGID());
|
||||
$acl->setPermissionWrite(true);
|
||||
$acl->setPermissionInvite(true);
|
||||
$acl->setPermissionManage(true);
|
||||
$result[] = $acl;
|
||||
}
|
||||
foreach ($this->userManager->searchDisplayName($search, $limit, $offset) as $idx => $user) {
|
||||
if($user->getUID() === $this->userId)
|
||||
continue;
|
||||
$acl = new Acl();
|
||||
$acl->setType('user');
|
||||
$acl->setParticipant($user->getUID());
|
||||
$acl->setPermissionWrite(true);
|
||||
$acl->setPermissionInvite(true);
|
||||
$acl->setPermissionManage(true);
|
||||
$result[] = $acl;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
80
lib/Controller/StackController.php
Normal file
80
lib/Controller/StackController.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?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\Controller;
|
||||
|
||||
use OCA\Deck\Service\StackService;
|
||||
|
||||
use OCP\IRequest;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
|
||||
class StackController extends Controller {
|
||||
private $userId;
|
||||
private $stackService;
|
||||
public function __construct($appName,
|
||||
IRequest $request,
|
||||
StackService $cardService,
|
||||
$userId){
|
||||
parent::__construct($appName, $request);
|
||||
$this->userId = $userId;
|
||||
$this->stackService = $cardService;
|
||||
}
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function index($boardId) {
|
||||
return $this->stackService->findAll($boardId);
|
||||
}
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function archived($boardId) {
|
||||
return $this->stackService->findAllArchived($boardId);
|
||||
}
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function read($boardId) {
|
||||
return $this->stackService->find($this->userId, $boardId);
|
||||
}
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function create($title, $boardId, $order=999) {
|
||||
return $this->stackService->create($title, $boardId, $order);
|
||||
}
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function update($id, $title, $boardId, $order) {
|
||||
return $this->stackService->update($id, $title, $boardId, $order);
|
||||
}
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function delete($stackId) {
|
||||
return $this->stackService->delete($this->userId, $stackId);
|
||||
}
|
||||
}
|
||||
46
lib/Controller/StyleController.php
Normal file
46
lib/Controller/StyleController.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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\Controller;
|
||||
|
||||
use OCP\IRequest;
|
||||
use OCP\AppFramework\ApiController as BaseApiController;
|
||||
|
||||
class StyleController extends Controller {
|
||||
private $defaults;
|
||||
public function __construct($appName,
|
||||
IRequest $request, OC_Defaults $defaults){
|
||||
parent::__construct($appName, $request);
|
||||
$this->defaults = $defaults;
|
||||
}
|
||||
/**
|
||||
* @PublicPage
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function generateCss() {
|
||||
|
||||
$color = $this->config->getAppValue($this->appName, 'color');
|
||||
$responseCss .= '';
|
||||
$response = new Http\DataDownloadResponse($responseCss, 'style', 'text/css');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user