2012-04-26 19:48:43 +04:00
|
|
|
<?php
|
2015-03-26 13:44:34 +03:00
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* @author Bart Visscher <bartv@thisnet.nl>
|
2016-05-26 20:56:05 +03:00
|
|
|
* @author Björn Schießle <bjoern@schiessle.org>
|
|
|
|
* @author Frank Karlitschek <frank@karlitschek.de>
|
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
2015-03-26 13:44:34 +03:00
|
|
|
* @author Sam Tuke <mail@samtuke.com>
|
2015-10-05 21:54:56 +03:00
|
|
|
* @author Vincent Petry <pvince81@owncloud.com>
|
2015-03-26 13:44:34 +03:00
|
|
|
*
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
|
|
|
*/
|
2018-03-22 15:19:29 +03:00
|
|
|
\OC_JSON::checkLoggedIn();
|
|
|
|
\OC_JSON::callCheck();
|
|
|
|
\OC_JSON::checkAppEnabled('files_versions');
|
2012-05-11 16:17:37 +04:00
|
|
|
|
2015-02-13 15:33:20 +03:00
|
|
|
$source = (string)$_GET['source'];
|
2015-02-16 14:01:05 +03:00
|
|
|
$start = (int)$_GET['start'];
|
2013-02-21 17:40:16 +04:00
|
|
|
list ($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($source);
|
2013-01-11 17:23:28 +04:00
|
|
|
$count = 5; //show the newest revisions
|
2014-01-22 14:10:32 +04:00
|
|
|
$versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $source);
|
|
|
|
if( $versions ) {
|
2012-04-26 19:48:43 +04:00
|
|
|
|
2013-07-25 12:35:19 +04:00
|
|
|
$endReached = false;
|
|
|
|
if (count($versions) <= $start+$count) {
|
|
|
|
$endReached = true;
|
2012-04-26 21:45:17 +04:00
|
|
|
}
|
2012-04-26 19:48:43 +04:00
|
|
|
|
2013-07-25 12:35:19 +04:00
|
|
|
$versions = array_slice($versions, $start, $count);
|
2012-08-29 10:42:49 +04:00
|
|
|
|
2016-02-10 15:38:38 +03:00
|
|
|
// remove owner path from request to not disclose it to the recipient
|
|
|
|
foreach ($versions as $version) {
|
|
|
|
unset($version['path']);
|
|
|
|
}
|
|
|
|
|
2018-03-22 15:20:03 +03:00
|
|
|
\OC_JSON::success(array('data' => array('versions' => $versions, 'endReached' => $endReached)));
|
2012-08-29 10:42:49 +04:00
|
|
|
|
2012-05-11 16:17:37 +04:00
|
|
|
} else {
|
2012-04-26 19:48:43 +04:00
|
|
|
|
2018-03-22 15:20:03 +03:00
|
|
|
\OC_JSON::success(array('data' => array('versions' => [], 'endReached' => true)));
|
2012-08-29 10:42:49 +04:00
|
|
|
|
2012-04-26 19:48:43 +04:00
|
|
|
}
|