-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.write.php
35 lines (32 loc) · 1.16 KB
/
action.write.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
/** @var InlineEditor $this */
if (!isset($gCms)) exit;
if (!$this->CheckPermission('InlineEditor')) exit;
$ret = true;
if ($_POST['site'] != $this->GetSiteId()) {
// Shouldn't happen
$ret = false;
} elseif (array_key_exists('map', $_POST) && array_key_exists('mid', $_POST) && array_key_exists('prp', $_POST)) {
// Update a Map
$map = $_POST['map'];
$mid = $_POST['mid'];
$prp = $_POST['prp'];
$val = $_POST['value'];
/** @var MapBase $object */
$object = new $map($mid);
$object->$prp = $val;
$ret = $object->commit();
} else {
// Simple editing
$table = $this->GetTable();
$value = $_POST['value'];
if (is_array($value)) $value = serialize($value);
unset($_POST['value']);
$this->db->Execute("REPLACE INTO `$table` VALUES (?, ?, ?, ?, ?)", array($_POST['site'], $_POST['page'], $_POST['name'], serialize($_POST), $value));
$ret = ($this->db->ErrorNo() == 0);
if (array_key_exists('reload', $_POST)) {
$_SESSION['InlineEditor'] = array('url' => $_POST['reload'], 'name' => $_POST['name']);
}
}
header('Content-Type: application/json');
echo json_encode($ret);