Update docs

Signed-off-by: Sergey Shliakhov <husband.sergey@gmail.com>

fix: conflicts
This commit is contained in:
Sergey Shliakhov
2020-05-25 09:46:57 +02:00
committed by Julius Härtl
parent eb8a321637
commit fc9fa5dc25
7 changed files with 107 additions and 33 deletions

View File

@@ -14,6 +14,7 @@ Overall, Deck is easy to use. You can create boards, add users, share the Deck,
3. [Handle cards options](#3-handle-cards-options) 3. [Handle cards options](#3-handle-cards-options)
4. [Archive old tasks](#4-archive-old-tasks) 4. [Archive old tasks](#4-archive-old-tasks)
5. [Manage your board](#5-manage-your-board) 5. [Manage your board](#5-manage-your-board)
6. [New owner for the deck entities](#8-new-owner-for-the-deck-entities)
### 1. Create my first board ### 1. Create my first board
In this example, we're going to create a board and share it with an other nextcloud user. In this example, we're going to create a board and share it with an other nextcloud user.
@@ -91,3 +92,7 @@ For example the search `project tag:ToDo assigned:alice assigned:bob` will retur
Other text tokens will be used to perform a case-insensitive search on the card title and description Other text tokens will be used to perform a case-insensitive search on the card title and description
In addition wuotes can be used to pass a query with spaces, e.g. `"Exact match with spaces"` or `title:"My card"`. In addition wuotes can be used to pass a query with spaces, e.g. `"Exact match with spaces"` or `title:"My card"`.
### 8. New owner for the deck entities
You can transfer ownership of boards, cards, etc to a new user, using `occ` command `deck:transfer-ownership`
`$ php occ deck:transfer-ownership owner newOwner`

View File

@@ -1,8 +1,8 @@
<?php <?php
declare(strict_types=1);
namespace OCA\Deck\Command; namespace OCA\Deck\Command;
use OCA\Deck\Service\BoardService;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
@@ -10,6 +10,15 @@ use Symfony\Component\Console\Output\OutputInterface;
final class TransferOwnership extends Command { final class TransferOwnership extends Command {
protected $boardService;
public function __construct(BoardService $boardService)
{
parent::__construct();
$this->boardService = $boardService;
}
protected function configure() { protected function configure() {
$this $this
->setName('deck:transfer-ownership') ->setName('deck:transfer-ownership')
@@ -29,33 +38,10 @@ final class TransferOwnership extends Command {
protected function execute(InputInterface $input, OutputInterface $output) { protected function execute(InputInterface $input, OutputInterface $output) {
$owner = $input->getArgument('owner'); $owner = $input->getArgument('owner');
$newOwner = $input->getArgument('newOwner'); $newOwner = $input->getArgument('newOwner');
$db = \OC::$server->getDatabaseConnection();
$output->writeln("Transfer deck entities from $owner to $newOwner"); $output->writeln("Transfer deck entities from $owner to $newOwner");
$params = [
'owner' => $owner,
'newOwner' => $newOwner
];
$output->writeln('update oc_deck_assigned_users'); $this->boardService->transferOwnership($owner, $newOwner);
$stmt = $db->prepare('UPDATE `oc_deck_assigned_users` SET `participant` = :newOwner WHERE `participant` = :owner');
$stmt->execute($params);
$output->writeln('update oc_deck_attachment');
$stmt = $db->prepare('UPDATE `oc_deck_attachment` SET `created_by` = :newOwner WHERE `created_by` = :owner');
$stmt->execute($params);
$output->writeln('update oc_deck_boards');
$stmt = $db->prepare('UPDATE `oc_deck_boards` SET `owner` = :newOwner WHERE `owner` = :owner');
$stmt->execute($params);
$output->writeln('update oc_deck_board_acl');
$stmt = $db->prepare('UPDATE `oc_deck_board_acl` SET `participant` = :newOwner WHERE `participant` = :owner');
$stmt->execute($params);
$output->writeln('update oc_deck_cards');
$stmt = $db->prepare('UPDATE `oc_deck_cards` SET `owner` = :newOwner WHERE `owner` = :owner');
$stmt->execute($params);
$output->writeln("Transfer deck entities from $owner to $newOwner completed"); $output->writeln("Transfer deck entities from $owner to $newOwner completed");
} }

View File

@@ -57,4 +57,21 @@ class AclMapper extends DeckMapper implements IPermissionMapper {
$sql = 'SELECT * from *PREFIX*deck_board_acl WHERE type = ? AND participant = ?'; $sql = 'SELECT * from *PREFIX*deck_board_acl WHERE type = ? AND participant = ?';
return $this->findEntities($sql, [$type, $participant]); return $this->findEntities($sql, [$type, $participant]);
} }
/**
* @param $ownerId
* @param $newOwnerId
* @return void
*/
public function transferOwnership($ownerId, $newOwnerId)
{
$params = [
'owner' => $ownerId,
'newOwner' => $newOwnerId,
'type' => Acl::PERMISSION_TYPE_USER
];
$sql = "UPDATE `{$this->tableName}` SET `participant` = :newOwner WHERE `participant` = :owner AND `type` = :type";
$stmt = $this->execute($sql, $params);
$stmt->closeCursor();
}
} }

View File

@@ -146,4 +146,20 @@ class AssignmentMapper extends QBMapper implements IPermissionMapper {
} }
return null; return null;
} }
/**
* @param $ownerId
* @param $newOwnerId
* @return void
*/
public function transferOwnership($ownerId, $newOwnerId)
{
$params = [
'owner' => $ownerId,
'newOwner' => $newOwnerId
];
$sql = "UPDATE `{$this->tableName}` SET `participant` = :newOwner WHERE `participant` = :owner";
$stmt = $this->execute($sql, $params);
$stmt->closeCursor();
}
} }

View File

@@ -475,4 +475,20 @@ class BoardMapper extends QBMapper implements IPermissionMapper {
return null; return null;
}); });
} }
/**
* @param $ownerId
* @param $newOwnerId
* @return void
*/
public function transferOwnership($ownerId, $newOwnerId)
{
$params = [
'owner' => $ownerId,
'newOwner' => $newOwnerId
];
$sql = "UPDATE `{$this->tableName}` SET `owner` = :newOwner WHERE `owner` = :owner";
$stmt = $this->execute($sql, $params);
$stmt->closeCursor();
}
} }

View File

@@ -586,4 +586,20 @@ class CardMapper extends QBMapper implements IPermissionMapper {
return null; return null;
}); });
} }
/**
* @param $ownerId
* @param $newOwnerId
* @return void
*/
public function transferOwnership($ownerId, $newOwnerId)
{
$params = [
'owner' => $ownerId,
'newOwner' => $newOwnerId
];
$sql = "UPDATE `{$this->tableName}` SET `owner` = :newOwner WHERE `owner` = :owner";
$stmt = $this->execute($sql, $params);
$stmt->closeCursor();
}
} }

View File

@@ -30,6 +30,7 @@ use OCA\Deck\AppInfo\Application;
use OCA\Deck\Db\Acl; use OCA\Deck\Db\Acl;
use OCA\Deck\Db\AclMapper; use OCA\Deck\Db\AclMapper;
use OCA\Deck\Db\AssignmentMapper; use OCA\Deck\Db\AssignmentMapper;
use OCA\Deck\Db\CardMapper;
use OCA\Deck\Db\ChangeHelper; use OCA\Deck\Db\ChangeHelper;
use OCA\Deck\Db\IPermissionMapper; use OCA\Deck\Db\IPermissionMapper;
use OCA\Deck\Db\Label; use OCA\Deck\Db\Label;
@@ -69,6 +70,8 @@ class BoardService {
private $activityManager; private $activityManager;
private $eventDispatcher; private $eventDispatcher;
private $changeHelper; private $changeHelper;
private $cardMapper;
private $boardsCache = null; private $boardsCache = null;
private $urlGenerator; private $urlGenerator;
@@ -83,6 +86,7 @@ class BoardService {
PermissionService $permissionService, PermissionService $permissionService,
NotificationHelper $notificationHelper, NotificationHelper $notificationHelper,
AssignmentMapper $assignedUsersMapper, AssignmentMapper $assignedUsersMapper,
CardMapper $cardMapper,
IUserManager $userManager, IUserManager $userManager,
IGroupManager $groupManager, IGroupManager $groupManager,
ActivityManager $activityManager, ActivityManager $activityManager,
@@ -107,6 +111,7 @@ class BoardService {
$this->changeHelper = $changeHelper; $this->changeHelper = $changeHelper;
$this->userId = $userId; $this->userId = $userId;
$this->urlGenerator = $urlGenerator; $this->urlGenerator = $urlGenerator;
$this->cardMapper = $cardMapper;
} }
/** /**
@@ -673,6 +678,19 @@ class BoardService {
return $newBoard; return $newBoard;
} }
/**
* @param $ownerId
* @param $newOwnerId
* @return void
*/
public function transferOwnership($owner, $newOwner)
{
$this->boardMapper->transferOwnership($owner, $newOwner);
$this->assignedUsersMapper->transferOwnership($owner, $newOwner);
$this->aclMapper->transferOwnership($owner, $newOwner);
$this->cardMapper->transferOwnership($owner, $newOwner);
}
private function enrichWithStacks($board, $since = -1) { private function enrichWithStacks($board, $since = -1) {
$stacks = $this->stackMapper->findAll($board->getId(), null, null, $since); $stacks = $this->stackMapper->findAll($board->getId(), null, null, $since);