<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('files_versions');
OCP\JSON::callCheck();
$file = $_GET['file'];
$revision = (int) $_GET['revision'];
if (OCA\Files_Versions\Storage::rollback($file, $revision)) {
    OCP\JSON::success(array("data" => array("revision" => $revision, "file" => $file)));
} else {
    $l = \OC::$server->getL10N('files_versions');
    OCP\JSON::error(array("data" => array("message" => $l->t("Could not revert: %s", array($file)))));
}
Example #2
0
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
OCP\User::checkLoggedIn();
OCP\Util::addStyle('files_versions', 'versions');
$tmpl = new OCP\Template('files_versions', 'history', 'user');
$l = OC_L10N::get('files_versions');
if (isset($_GET['path'])) {
    $path = $_GET['path'];
    $tmpl->assign('path', $path);
    $versions = new OCA\Files_Versions\Storage();
    // roll back to old version if button clicked
    if (isset($_GET['revert'])) {
        if ($versions->rollback($path, $_GET['revert'])) {
            $tmpl->assign('outcome_stat', $l->t('success'));
            $message = $l->t('File %s was reverted to version %s', array($_GET['path'], OCP\Util::formatDate(doubleval($_GET['revert']))));
            $tmpl->assign('outcome_msg', $message);
        } else {
            $tmpl->assign('outcome_stat', $l->t('failure'));
            $message = $l->t('File %s could not be reverted to version %s', array($_GET['path'], OCP\Util::formatDate(doubleval($_GET['revert']))));
            $tmpl->assign('outcome_msg', $message);
        }
    }
    // show the history only if there is something to show
    $count = 999;
    //show the newest revisions
    list($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($path);
    if ($versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $count)) {
        $tmpl->assign('versions', array_reverse($versions));