Allow to undo file deletions

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2018-06-12 15:33:06 +02:00
parent 0c711b2b0b
commit ee5a54a575
12 changed files with 152 additions and 20 deletions

View File

@@ -28,10 +28,10 @@ class Attachment extends RelationalEntity {
protected $cardId;
protected $type;
protected $data;
protected $lastModified;
protected $createdAt;
protected $lastModified = 0;
protected $createdAt = 0;
protected $createdBy;
protected $deletedAt;
protected $deletedAt = 0;
protected $extendedData = [];
public function __construct() {

View File

@@ -82,6 +82,24 @@ class AttachmentMapper extends DeckMapper implements IPermissionMapper {
return $entities;
}
public function findToDelete() {
// add buffer of 5 min
$timeLimit = time() - (60 * 5);
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from('deck_attachment')
->where($qb->expr()->gt('deleted_at', '0', IQueryBuilder::PARAM_INT))
->andWhere($qb->expr()->lt('deleted_at', (string)$timeLimit, IQueryBuilder::PARAM_INT));
$entities = [];
$cursor = $qb->execute();
while($row = $cursor->fetch()){
$entities[] = $this->mapRowToEntity($row);
}
$cursor->closeCursor();
return $entities;
}
/**
* @param Attachment $attachment
* @throws \Exception