include 'functions.php';
// =================
// ! Get the page id
// =================
$page_id = $val->sanitizePost('page_id', 'numeric');
if (!$page_id) {
    $ajax = array('message' => $backend->lang()->translate('You sent an invalid value.'), 'success' => false);
    print json_encode($ajax);
    exit;
}
// check perms and page dir
backend_pages_prechecks('pages_settings');
// get form data
$options = backend_pages_getoptions();
// check titles
if (CAT_Helper_Page::sanitizeTitles($options) === false) {
    $ajax = array('message' => $backend->lang()->translate('Please enter a menu title'), 'success' => false);
    print json_encode($ajax);
    exit;
}
// ========================
// ! Get existing page data
// ========================
$page = CAT_Helper_Page::getPage($page_id);
$old_parent = $page['parent'];
$old_link = $page['link'];
$old_position = $page['position'];
$old_admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
$old_admin_users = explode(',', str_replace('_', '', $page['admin_users']));
$in_old_group = false;
// check if user is in old group, so he's allowed to modify this page