2012-04-26 15:48:43 +00:00
|
|
|
<?php
|
2015-03-26 10:44:34 +00:00
|
|
|
/**
|
2016-07-21 14:49:16 +00:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2015-03-26 10:44:34 +00:00
|
|
|
* @author Bart Visscher <bartv@thisnet.nl>
|
2016-05-26 17:56:05 +00:00
|
|
|
* @author Björn Schießle <bjoern@schiessle.org>
|
|
|
|
* @author Frank Karlitschek <frank@karlitschek.de>
|
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
2015-03-26 10:44:34 +00:00
|
|
|
* @author Sam Tuke <mail@samtuke.com>
|
2015-10-05 18:54:56 +00:00
|
|
|
* @author Vincent Petry <pvince81@owncloud.com>
|
2015-03-26 10:44:34 +00: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/>
|
|
|
|
*
|
|
|
|
*/
|
2015-01-09 10:50:17 +00:00
|
|
|
OCP\JSON::checkLoggedIn();
|
|
|
|
OCP\JSON::callCheck();
|
2012-05-03 10:23:29 +00:00
|
|
|
OCP\JSON::checkAppEnabled('files_versions');
|
2012-05-11 12:17:37 +00:00
|
|
|
|
2015-02-13 12:33:20 +00:00
|
|
|
$source = (string)$_GET['source'];
|
2015-02-16 11:01:05 +00:00
|
|
|
$start = (int)$_GET['start'];
|
2013-02-21 13:40:16 +00:00
|
|
|
list ($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($source);
|
2013-01-11 13:23:28 +00:00
|
|
|
$count = 5; //show the newest revisions
|
2014-01-22 10:10:32 +00:00
|
|
|
$versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $source);
|
|
|
|
if( $versions ) {
|
2012-04-26 15:48:43 +00:00
|
|
|
|
2013-07-25 08:35:19 +00:00
|
|
|
$endReached = false;
|
|
|
|
if (count($versions) <= $start+$count) {
|
|
|
|
$endReached = true;
|
2012-04-26 17:45:17 +00:00
|
|
|
}
|
2012-04-26 15:48:43 +00:00
|
|
|
|
2013-07-25 08:35:19 +00:00
|
|
|
$versions = array_slice($versions, $start, $count);
|
2012-08-29 06:42:49 +00:00
|
|
|
|
2016-02-10 12:38:38 +00:00
|
|
|
// remove owner path from request to not disclose it to the recipient
|
|
|
|
foreach ($versions as $version) {
|
|
|
|
unset($version['path']);
|
|
|
|
}
|
|
|
|
|
2013-07-25 08:35:19 +00:00
|
|
|
\OCP\JSON::success(array('data' => array('versions' => $versions, 'endReached' => $endReached)));
|
2012-08-29 06:42:49 +00:00
|
|
|
|
2012-05-11 12:17:37 +00:00
|
|
|
} else {
|
2012-04-26 15:48:43 +00:00
|
|
|
|
2015-09-01 17:29:55 +00:00
|
|
|
\OCP\JSON::success(array('data' => array('versions' => [], 'endReached' => true)));
|
2012-08-29 06:42:49 +00:00
|
|
|
|
2012-04-26 15:48:43 +00:00
|
|
|
}
|