history.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. require_once( '../../lib/base.php' );
  23. OCP\User::checkLoggedIn( );
  24. OCP\Util::addStyle('files_versions','versions');
  25. $tmpl = new OCP\Template( 'files_versions', 'history', 'user' );
  26. if ( isset( $_GET['path'] ) ) {
  27. $path = $_GET['path'];
  28. $path = strip_tags( $path );
  29. $tmpl->assign( 'path', $path );
  30. // roll back to old version if button clicked
  31. if( isset( $_GET['revert'] ) ) {
  32. if( \OCA_Versions\Storage::rollback( $path, $_GET['revert'] ) ) {
  33. $tmpl->assign( 'outcome_stat', 'success' );
  34. $tmpl->assign( 'outcome_msg', "File {$_GET['path']} was reverted to version ".OCP\Util::formatDate( $_GET['revert'] ) );
  35. } else {
  36. $tmpl->assign( 'outcome_stat', 'failure' );
  37. $tmpl->assign( 'outcome_msg', "File {$_GET['path']} could not be reverted to version ".OCP\Util::formatDate( $_GET['revert'] ) );
  38. }
  39. }
  40. // show the history only if there is something to show
  41. if( OCA_Versions\Storage::isversioned( $path ) ) {
  42. $count=999; //show the newest revisions
  43. $versions=OCA_Versions\Storage::getversions( $path, $count);
  44. $tmpl->assign( 'versions', array_reverse( $versions ) );
  45. }else{
  46. $tmpl->assign( 'message', 'No old versions available' );
  47. }
  48. }else{
  49. $tmpl->assign( 'message', 'No path specified' );
  50. }
  51. $tmpl->printPage( );
  52. ?>