2012-04-26 19:48:43 +04:00
|
|
|
<?php
|
2015-03-26 13:44:34 +03:00
|
|
|
/**
|
|
|
|
* @author Bart Visscher <bartv@thisnet.nl>
|
|
|
|
* @author Björn Schießle <schiessle@owncloud.com>
|
|
|
|
* @author Frank Karlitschek <frank@owncloud.org>
|
|
|
|
* @author Lukas Reschke <lukas@owncloud.com>
|
|
|
|
* @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
|
|
|
*
|
2016-01-12 17:02:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
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/>
|
|
|
|
*
|
|
|
|
*/
|
2015-01-09 13:50:17 +03:00
|
|
|
OCP\JSON::checkLoggedIn();
|
|
|
|
OCP\JSON::callCheck();
|
2012-05-03 14:23:29 +04:00
|
|
|
OCP\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']);
|
|
|
|
}
|
|
|
|
|
2013-07-25 12:35:19 +04:00
|
|
|
\OCP\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
|
|
|
|
2015-09-01 20:29:55 +03:00
|
|
|
\OCP\JSON::success(array('data' => array('versions' => [], 'endReached' => true)));
|
2012-08-29 10:42:49 +04:00
|
|
|
|
2012-04-26 19:48:43 +04:00
|
|
|
}
|