@@ -36,70 +36,70 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | class ExpireSharesJob extends TimedJob { |
| 38 | 38 | |
| 39 | - /** @var IManager */ |
|
| 40 | - private $shareManager; |
|
| 39 | + /** @var IManager */ |
|
| 40 | + private $shareManager; |
|
| 41 | 41 | |
| 42 | - /** @var IDBConnection */ |
|
| 43 | - private $db; |
|
| 42 | + /** @var IDBConnection */ |
|
| 43 | + private $db; |
|
| 44 | 44 | |
| 45 | - public function __construct(ITimeFactory $time, IManager $shareManager, IDBConnection $db) { |
|
| 46 | - $this->shareManager = $shareManager; |
|
| 47 | - $this->db = $db; |
|
| 45 | + public function __construct(ITimeFactory $time, IManager $shareManager, IDBConnection $db) { |
|
| 46 | + $this->shareManager = $shareManager; |
|
| 47 | + $this->db = $db; |
|
| 48 | 48 | |
| 49 | - parent::__construct($time); |
|
| 49 | + parent::__construct($time); |
|
| 50 | 50 | |
| 51 | - // Run once a day |
|
| 52 | - $this->setInterval(24 * 60 * 60); |
|
| 53 | - } |
|
| 51 | + // Run once a day |
|
| 52 | + $this->setInterval(24 * 60 * 60); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Makes the background job do its work |
|
| 58 | - * |
|
| 59 | - * @param array $argument unused argument |
|
| 60 | - */ |
|
| 61 | - public function run($argument) { |
|
| 62 | - //Current time |
|
| 63 | - $now = new \DateTime(); |
|
| 64 | - $now = $now->format('Y-m-d H:i:s'); |
|
| 56 | + /** |
|
| 57 | + * Makes the background job do its work |
|
| 58 | + * |
|
| 59 | + * @param array $argument unused argument |
|
| 60 | + */ |
|
| 61 | + public function run($argument) { |
|
| 62 | + //Current time |
|
| 63 | + $now = new \DateTime(); |
|
| 64 | + $now = $now->format('Y-m-d H:i:s'); |
|
| 65 | 65 | |
| 66 | - /* |
|
| 66 | + /* |
|
| 67 | 67 | * Expire file link shares only (for now) |
| 68 | 68 | */ |
| 69 | - $qb = $this->db->getQueryBuilder(); |
|
| 70 | - $qb->select('id', 'share_type') |
|
| 71 | - ->from('share') |
|
| 72 | - ->where( |
|
| 73 | - $qb->expr()->andX( |
|
| 74 | - $qb->expr()->orX( |
|
| 75 | - $qb->expr()->eq('share_type', $qb->expr()->literal(IShare::TYPE_LINK)), |
|
| 76 | - $qb->expr()->eq('share_type', $qb->expr()->literal(IShare::TYPE_EMAIL)) |
|
| 77 | - ), |
|
| 78 | - $qb->expr()->lte('expiration', $qb->expr()->literal($now)), |
|
| 79 | - $qb->expr()->orX( |
|
| 80 | - $qb->expr()->eq('item_type', $qb->expr()->literal('file')), |
|
| 81 | - $qb->expr()->eq('item_type', $qb->expr()->literal('folder')) |
|
| 82 | - ) |
|
| 83 | - ) |
|
| 84 | - ); |
|
| 69 | + $qb = $this->db->getQueryBuilder(); |
|
| 70 | + $qb->select('id', 'share_type') |
|
| 71 | + ->from('share') |
|
| 72 | + ->where( |
|
| 73 | + $qb->expr()->andX( |
|
| 74 | + $qb->expr()->orX( |
|
| 75 | + $qb->expr()->eq('share_type', $qb->expr()->literal(IShare::TYPE_LINK)), |
|
| 76 | + $qb->expr()->eq('share_type', $qb->expr()->literal(IShare::TYPE_EMAIL)) |
|
| 77 | + ), |
|
| 78 | + $qb->expr()->lte('expiration', $qb->expr()->literal($now)), |
|
| 79 | + $qb->expr()->orX( |
|
| 80 | + $qb->expr()->eq('item_type', $qb->expr()->literal('file')), |
|
| 81 | + $qb->expr()->eq('item_type', $qb->expr()->literal('folder')) |
|
| 82 | + ) |
|
| 83 | + ) |
|
| 84 | + ); |
|
| 85 | 85 | |
| 86 | - $shares = $qb->execute(); |
|
| 87 | - while ($share = $shares->fetch()) { |
|
| 88 | - if ((int)$share['share_type'] === IShare::TYPE_LINK) { |
|
| 89 | - $id = 'ocinternal'; |
|
| 90 | - } elseif ((int)$share['share_type'] === IShare::TYPE_EMAIL) { |
|
| 91 | - $id = 'ocMailShare'; |
|
| 92 | - } |
|
| 86 | + $shares = $qb->execute(); |
|
| 87 | + while ($share = $shares->fetch()) { |
|
| 88 | + if ((int)$share['share_type'] === IShare::TYPE_LINK) { |
|
| 89 | + $id = 'ocinternal'; |
|
| 90 | + } elseif ((int)$share['share_type'] === IShare::TYPE_EMAIL) { |
|
| 91 | + $id = 'ocMailShare'; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - $id .= ':' . $share['id']; |
|
| 94 | + $id .= ':' . $share['id']; |
|
| 95 | 95 | |
| 96 | - try { |
|
| 97 | - $share = $this->shareManager->getShareById($id); |
|
| 98 | - $this->shareManager->deleteShare($share); |
|
| 99 | - } catch (ShareNotFound $e) { |
|
| 100 | - // Normally the share gets automatically expired on fetching it |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - $shares->closeCursor(); |
|
| 104 | - } |
|
| 96 | + try { |
|
| 97 | + $share = $this->shareManager->getShareById($id); |
|
| 98 | + $this->shareManager->deleteShare($share); |
|
| 99 | + } catch (ShareNotFound $e) { |
|
| 100 | + // Normally the share gets automatically expired on fetching it |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + $shares->closeCursor(); |
|
| 104 | + } |
|
| 105 | 105 | } |
@@ -85,13 +85,13 @@ |
||
| 85 | 85 | |
| 86 | 86 | $shares = $qb->execute(); |
| 87 | 87 | while ($share = $shares->fetch()) { |
| 88 | - if ((int)$share['share_type'] === IShare::TYPE_LINK) { |
|
| 88 | + if ((int) $share['share_type'] === IShare::TYPE_LINK) { |
|
| 89 | 89 | $id = 'ocinternal'; |
| 90 | - } elseif ((int)$share['share_type'] === IShare::TYPE_EMAIL) { |
|
| 90 | + } elseif ((int) $share['share_type'] === IShare::TYPE_EMAIL) { |
|
| 91 | 91 | $id = 'ocMailShare'; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - $id .= ':' . $share['id']; |
|
| 94 | + $id .= ':'.$share['id']; |
|
| 95 | 95 | |
| 96 | 96 | try { |
| 97 | 97 | $share = $this->shareManager->getShareById($id); |