<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

/**
 * Journal — historical direct URL, kept as a thin redirect so no bookmark
 * ever 404s: the Journal is now the last tab of Administration
 * (pages/admin.php, 'journal' case), reusing {@see \local_kid\output\journal_page}
 * unchanged. Every original query parameter (filters/sort/dir/page) is
 * forwarded as-is, only `tab=journal` is added.
 *
 * Note: the target is built as an absolute `$CFG->wwwroot`-prefixed string
 * on purpose, not a root-relative `/local/kid/...` path — redirect()'s own
 * string-to-absolute-URL logic only prepends the scheme+host of wwwroot
 * (stripping any subdirectory, e.g. Moodle installed under `/docs`), so a
 * root-relative path here would silently escape the Moodle install path.
 *
 * @package local_kid
 */

require(__DIR__ . '/../../../config.php');
require_once($CFG->dirroot . '/local/kid/lib.php');

require_login();

$querystring = $_SERVER['QUERY_STRING'] ?? '';
$target = $CFG->wwwroot . '/local/kid/pages/admin.php?tab=journal' . ($querystring !== '' ? '&' . $querystring : '');
redirect($target);
