<?php
include '../env.php';
require_once(LIB.'common.inc.php');
if (! can_action('admin') || empty($_POST['src']) || empty($_POST['dist']) || !is_array($_POST['dist'])) {
	_a_log_fail('layout', 'copy', 'invalid auth', array(
		'target_key' => @$_POST['src'].','.serialize($_POST['dist'])
	));
	echo json_encode(FALSE);
	die;
}
require_once(LIB.'Box.class.php');
$box = new Box();
$log_ret = _a_log2('layout', 'modify', array(
	'target_key' => @$_POST['src'].','.serialize(@$_POST['dist']),
	'detail' => serialize($_POST)
));
if ($log_ret) {
	$ret = $box->copyLayouts($_POST['src'], $_POST['dist']);
	_a_log_write($log_ret, array('success' => $ret === FALSE ? '0' : '1'));
	$box->updateLayoutCache();
	echo json_encode($ret);
} else {
	echo json_encode(FALSE);
}
?>