<commit_before><?php
/**
 * revisions.php
 *
 * @author <NAME> <<EMAIL>>
 * @copyright 2012 <NAME>
 * @see http://www.elabftw.net Official website
 * @license AGPL-3.0
 * @package elabftw
 */
namespace Elabftw\Elabftw;

use \Exception;

/**
 * Show history of body of experiment or db item
 *
 */
require_once 'app/common.inc.php';
$page_title = _('Revisions');
$selected_menu = null;
$errflag = false;
require_once 'app/head.inc.php';


try {
    if ($_GET['type'] === 'experiments') {

        // only experiment owner can change or see revisions
        if (!is_owned_by_user($_GET['item_id'], 'experiments', $_SESSION['userid'])) {
            throw new Exception(_('This section is out of your reach.'));
        }
        $location = 'experiments';

    } elseif ($_GET['type'] === 'items') {

        // check if item is in team
        $Database = new Database($_SESSION['team_id'], $_GET['item_id']);
        if (!$Database->isInTeam()) {
            throw new Exception(_('This section is out of your reach.'));
        }
        $location = 'database';

    } else {
        throw new Exception('Bad type!');
    }

    $Revisions = new Revisions($_GET['type'], $_GET['item_id'], $_SESSION['userid']);

    // THE RESTORE ACTION
    if (isset($_GET['action']) && $_GET['action'] === 'restore') {
        $revId = Tools::checkId($_GET['revId']);
        if ($revId === false) {
            throw new Exception(_('The id parameter is not valid!'));
        }

        $Revisions->restore($revId);<commit_msg>fix revisions<commit_after><?php
/**
 * revisions.php
 *
 * @author <NAME> <<EMAIL>>
 * @copyright 2012 <NAME>
 * @see http://www.elabftw.net Official website
 * @license AGPL-3.0
 * @package elabftw
 */
namespace Elabftw\Elabftw;

use \Exception;

/**
 * Show history of body of experiment or db item
 *
 */
require_once 'app/common.inc.php';
$page_title = _('Revisions');
$selected_menu = null;
$errflag = false;
require_once 'app/head.inc.php';


try {
    if ($_GET['type'] === 'experiments') {

        // only experiment owner can change or see revisions
        if (!is_owned_by_user($_GET['item_id'], 'experiments', $_SESSION['userid'])) {
            throw new Exception(_('This section is out of your reach.'));
        }
        $location = 'experiments';

    } elseif ($_GET['type'] === 'items') {

        // check if item is in team
        $Database = new Database($_SESSION['team_id'], $_GET['item_id']);
        if (!$Database->isInTeam()) {
            throw new Exception(_('This section is out of your reach.'));
        }
        $location = 'database';

    } else {
        throw new Exception('Bad type!');
    }

    $Revisions = new Revisions($_GET['type'], $_GET['item_id'], $_SESSION['userid']);

    // THE RESTORE ACTION
    if (isset($_GET['action']) && $_GET['action'] === 'restore') {
        $revId = Tools::checkId($_GET['rev_id']);
        if ($revId === false) {
            throw new Exception(_('The id parameter is not valid!'));
        }

        $Revisions->restore($revId);
{'fraction_non_alphanumeric': 0.17726523887973641, 'fraction_numerical': 0.003953871499176277, 'mean_word_length': 2.8625954198473282, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5344156', 'n_tokens_mistral': 957, 'n_tokens_neox': 926, 'n_words': 246}