history.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * ownCloud - History page of the Versions App
  4. *
  5. * @author Frank Karlitschek
  6. * @copyright 2012 Frank Karlitschek frank@owncloud.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 = $path;
  28. $tmpl->assign( 'path', $path );
  29. $versions = new OCA_Versions\Storage();
  30. // roll back to old version if button clicked
  31. if( isset( $_GET['revert'] ) ) {
  32. if( $versions->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( doubleval($_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( doubleval($_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( );