Backend: assign/remove user impelementation

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2017-10-01 16:03:14 +02:00
committed by Julius Härtl
parent 01f11d1be9
commit 447cb80573
6 changed files with 56 additions and 9 deletions

View File

@@ -25,7 +25,6 @@
namespace OCA\Deck\Db;
use OCP\AppFramework\Db\Entity;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\IUserManager;
@@ -58,7 +57,24 @@ class AssignedUsersMapper extends DeckMapper implements IPermissionMapper {
public function findBoardId($cardId) {
return $this->cardMapper->findBoardId($cardId);
}
/**
* Check if user exists before assigning it to a card
*
* @param Entity $entity
* @return null|Entity
*/
public function insert(Entity $entity) {
$user = $this->userManager->get($entity->getParticipant());
if ($user !== null) {
/** @var AssignedUsers $assignment */
$assignment = parent::insert($entity);
$this->mapParticipant($assignment);
return $assignment;
} else {
return null;
}
}
public function mapParticipant(AssignedUsers &$assignment) {

View File

@@ -34,6 +34,7 @@ class Card extends RelationalEntity {
protected $lastModified;
protected $createdAt;
protected $labels;
protected $assignedUsers;
protected $owner;
protected $order;
protected $archived = false;
@@ -56,6 +57,7 @@ class Card extends RelationalEntity {
$this->addType('archived', 'boolean');
$this->addType('notified', 'boolean');
$this->addRelation('labels');
$this->addRelation('assignedUsers');
$this->addRelation('participants');
$this->addResolvable('owner');
}

View File

@@ -24,7 +24,6 @@
namespace OCA\Deck\Db;
use OCP\AppFramework\Db\Entity;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\IUserManager;
use OCP\Notification\IManager;
@@ -104,7 +103,6 @@ class CardMapper extends DeckMapper implements IPermissionMapper {
$card = $this->findEntity($sql, [$id]);
$labels = $this->labelMapper->findAssignedLabelsForCard($card->id);
$card->setLabels($labels);
$this->mapOwner($card);
return $card;
}