getVersions.php 668 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. OCP\JSON::checkAppEnabled('files_versions');
  3. require_once('apps/files_versions/versions.php');
  4. $userDirectory = "/".OCP\USER::getUser()."/files";
  5. $source = $_GET['source'];
  6. $source = strip_tags( $source );
  7. if( OCA_Versions\Storage::isversioned( $source ) ) {
  8. $count=5; //show the newest revisions
  9. $versions = OCA_Versions\Storage::getVersions( $source, $count);
  10. $versionsFormatted = array();
  11. foreach ( $versions AS $version ) {
  12. $versionsFormatted[] = OCP\Util::formatDate( $version );
  13. }
  14. $versionsSorted = array_reverse( $versions );
  15. if ( !empty( $versionsSorted ) ) {
  16. OCP\JSON::encodedPrint($versionsSorted);
  17. }
  18. } else {
  19. return;
  20. }