history.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * ownCloud - History page of the Versions App
  4. *
  5. * @author Frank Karlitschek
  6. * @copyright 2011 Frank Karlitschek karlitschek@kde.org
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. OCP\User::checkLoggedIn( );
  23. OCP\Util::addStyle('files_versions','versions');
  24. $tmpl = new OCP\Template( 'files_versions', 'history', 'user' );
  25. if ( isset( $_GET['path'] ) ) {
  26. $path = $_GET['path'];
  27. $path = strip_tags( $path );
  28. $tmpl->assign( 'path', $path );
  29. // roll back to old version if button clicked
  30. if( isset( $_GET['revert'] ) ) {
  31. if( \OCA_Versions\Storage::rollback( $path, $_GET['revert'] ) ) {
  32. $tmpl->assign( 'outcome_stat', 'success' );
  33. $tmpl->assign( 'outcome_msg', "File {$_GET['path']} was reverted to version ".OCP\Util::formatDate( $_GET['revert'] ) );
  34. } else {
  35. $tmpl->assign( 'outcome_stat', 'failure' );
  36. $tmpl->assign( 'outcome_msg', "File {$_GET['path']} could not be reverted to version ".OCP\Util::formatDate( $_GET['revert'] ) );
  37. }
  38. }
  39. // show the history only if there is something to show
  40. if( OCA_Versions\Storage::isversioned( $path ) ) {
  41. $count = 999; //show the newest revisions
  42. $versions = OCA_Versions\Storage::getversions( $path, $count );
  43. $tmpl->assign( 'versions', array_reverse( $versions ) );
  44. }else{
  45. $tmpl->assign( 'message', 'No old versions available' );
  46. }
  47. }else{
  48. $tmpl->assign( 'message', 'No path specified' );
  49. }
  50. $tmpl->printPage( );
  51. ?>