<?php

$cms_root_path = '../../../';
require_once $cms_root_path . 'includes/compatibility_includer.php';

if (
    empty($_REQUEST['page_id'])
    || !is_numeric($_REQUEST['page_id'])
    || $adminuser->user['id'] != MTCADMIN_USERID
    || !isset($_REQUEST['pagedataTree'])
) {
    exit('false');
}

$new_pagedata = unserialize(stripslashes($_REQUEST['pagedataTree']));

$pagedata = new Pagedata();
if ($_POST['merge_pagedata'] === "1") {
    $pagedata->get($_REQUEST['page_id']); // retrieve existing
    $pagedata->merge($new_pagedata, false);
} else {
    $pagedata->page_id = $_REQUEST['page_id'];
    $pagedata->pagedata = $new_pagedata;
}
$pagedata->save();

echo 'true';
