getVersions.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. require_once('../../../lib/base.php');
  3. OCP\JSON::checkAppEnabled('files_versions');
  4. require_once('../versions.php');
  5. $userDirectory = "/".OCP\USER::getUser()."/files";
  6. $source = $_GET['source'];
  7. $source = strip_tags( $source );
  8. if( OCA_Versions\Storage::isversioned( $source ) ) {
  9. $count=5; //show the newest revisions
  10. $versions = OCA_Versions\Storage::getversions( $source, $count);
  11. $versionsFormatted = array();
  12. foreach ( $versions AS $version ) {
  13. $versionsFormatted[] = OCP\Util::formatDate( $version );
  14. }
  15. $versionsSorted = array_reverse( $versionsFormatted );
  16. if ( !empty( $versionsSorted ) ) {
  17. OCP\JSON::encodedPrint($versionsSorted);
  18. }
  19. }else{
  20. return;
  21. }
  22. // $path = $source;
  23. // $users = array();
  24. // if ($users = OC_Share::getMySharedItem($source)) {
  25. // for ($i = 0; $i < count($users); $i++) {
  26. // if ($users[$i]['uid_shared_with'] == OC_Share::PUBLICLINK) {
  27. // $users[$i]['token'] = OC_Share::getTokenFromSource($source);
  28. // }
  29. // }
  30. // }
  31. // $source = dirname($source);
  32. // while ($source != "" && $source != "/" && $source != "." && $source != $userDirectory) {
  33. // if ($values = OC_Share::getMySharedItem($source)) {
  34. // $values = array_values($values);
  35. // $parentUsers = array();
  36. // for ($i = 0; $i < count($values); $i++) {
  37. // if ($values[$i]['uid_shared_with'] == OC_Share::PUBLICLINK) {
  38. // $values[$i]['token'] = OC_Share::getTokenFromSource($source)."&path=".substr($path, strlen($source));
  39. // }
  40. // $parentUsers[basename($source)."-".$i] = $values[$i];
  41. // }
  42. // $users = array_merge($users, $parentUsers);
  43. // }
  44. // $source = dirname($source);
  45. // }
  46. // if (!empty($users)) {
  47. // OCP\JSON::encodedPrint($users);
  48. // }