@@ -32,50 +32,50 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | class ExpireSharesJob extends TimedJob { |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * sets the correct interval for this timed job |
|
| 37 | - */ |
|
| 38 | - public function __construct() { |
|
| 39 | - // Run once a day |
|
| 40 | - $this->setInterval(24 * 60 * 60); |
|
| 41 | - } |
|
| 35 | + /** |
|
| 36 | + * sets the correct interval for this timed job |
|
| 37 | + */ |
|
| 38 | + public function __construct() { |
|
| 39 | + // Run once a day |
|
| 40 | + $this->setInterval(24 * 60 * 60); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Makes the background job do its work |
|
| 45 | - * |
|
| 46 | - * @param array $argument unused argument |
|
| 47 | - */ |
|
| 48 | - public function run($argument) { |
|
| 49 | - $connection = \OC::$server->getDatabaseConnection(); |
|
| 43 | + /** |
|
| 44 | + * Makes the background job do its work |
|
| 45 | + * |
|
| 46 | + * @param array $argument unused argument |
|
| 47 | + */ |
|
| 48 | + public function run($argument) { |
|
| 49 | + $connection = \OC::$server->getDatabaseConnection(); |
|
| 50 | 50 | |
| 51 | - //Current time |
|
| 52 | - $now = new \DateTime(); |
|
| 53 | - $now = $now->format('Y-m-d H:i:s'); |
|
| 51 | + //Current time |
|
| 52 | + $now = new \DateTime(); |
|
| 53 | + $now = $now->format('Y-m-d H:i:s'); |
|
| 54 | 54 | |
| 55 | - /* |
|
| 55 | + /* |
|
| 56 | 56 | * Expire file link shares only (for now) |
| 57 | 57 | */ |
| 58 | - $qb = $connection->getQueryBuilder(); |
|
| 59 | - $qb->select('id', 'file_source', 'uid_owner', 'item_type') |
|
| 60 | - ->from('share') |
|
| 61 | - ->where( |
|
| 62 | - $qb->expr()->andX( |
|
| 63 | - $qb->expr()->orX( |
|
| 64 | - $qb->expr()->eq('share_type', $qb->expr()->literal(IShare::TYPE_LINK)), |
|
| 65 | - $qb->expr()->eq('share_type', $qb->expr()->literal(IShare::TYPE_EMAIL)) |
|
| 66 | - ), |
|
| 67 | - $qb->expr()->lte('expiration', $qb->expr()->literal($now)), |
|
| 68 | - $qb->expr()->orX( |
|
| 69 | - $qb->expr()->eq('item_type', $qb->expr()->literal('file')), |
|
| 70 | - $qb->expr()->eq('item_type', $qb->expr()->literal('folder')) |
|
| 71 | - ) |
|
| 72 | - ) |
|
| 73 | - ); |
|
| 58 | + $qb = $connection->getQueryBuilder(); |
|
| 59 | + $qb->select('id', 'file_source', 'uid_owner', 'item_type') |
|
| 60 | + ->from('share') |
|
| 61 | + ->where( |
|
| 62 | + $qb->expr()->andX( |
|
| 63 | + $qb->expr()->orX( |
|
| 64 | + $qb->expr()->eq('share_type', $qb->expr()->literal(IShare::TYPE_LINK)), |
|
| 65 | + $qb->expr()->eq('share_type', $qb->expr()->literal(IShare::TYPE_EMAIL)) |
|
| 66 | + ), |
|
| 67 | + $qb->expr()->lte('expiration', $qb->expr()->literal($now)), |
|
| 68 | + $qb->expr()->orX( |
|
| 69 | + $qb->expr()->eq('item_type', $qb->expr()->literal('file')), |
|
| 70 | + $qb->expr()->eq('item_type', $qb->expr()->literal('folder')) |
|
| 71 | + ) |
|
| 72 | + ) |
|
| 73 | + ); |
|
| 74 | 74 | |
| 75 | - $shares = $qb->execute(); |
|
| 76 | - while ($share = $shares->fetch()) { |
|
| 77 | - \OC\Share\Share::unshare($share['item_type'], $share['file_source'], IShare::TYPE_LINK, null, $share['uid_owner']); |
|
| 78 | - } |
|
| 79 | - $shares->closeCursor(); |
|
| 80 | - } |
|
| 75 | + $shares = $qb->execute(); |
|
| 76 | + while ($share = $shares->fetch()) { |
|
| 77 | + \OC\Share\Share::unshare($share['item_type'], $share['file_source'], IShare::TYPE_LINK, null, $share['uid_owner']); |
|
| 78 | + } |
|
| 79 | + $shares->closeCursor(); |
|
| 80 | + } |
|
| 81 | 81 | } |