-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdpobjdbop.php
89 lines (79 loc) · 1.9 KB
/
dpobjdbop.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
require_once 'DP_settings.php';
require_once 'mmsession.php';
require_once 'mmexchdl.php';
require_once 'drupalTableObj.php';
if (isset($_SESSION['mmToken'])) {
$ulo = new MMUserLogin;
$ulo->readToken($_SESSION['mmToken']);
$user = new MMUSer;
$user->read($ulo->user_id);
$currEnvId = $user->currentEnvironmentId;
$currEnvDesc = $user->currentEnvironment->description;
$user->setSessionContext(array( 'user' => $ulo->user_id,
'environment' => $ulo->environment_id,
'client' => $ulo->client_id,));
}
else {
header("Location: index.php"); die;
}
if (!isset($_POST['obj']))
die("Missing parameter.");
$objName = $_POST['obj'];
$obj = new drupalTableObj($objName);
// delete object
if($_POST['mmaction'] == 'Del') {
$primaryKey = $_POST['primaryKey'];
$obj->read(base64_decode($primaryKey));
$ret = $obj->delete();
header("Location: $_POST[referer]");
die;
}
$colDets = $obj->getColumnProperties();
// add object
if($_POST['mmaction'] == 'Add') {
foreach ($colDets as $a => $b) {
switch ($b[type]) {
case 'boolean':
$obj->$a = $_POST[$a];
if (is_null($obj->$a) or $obj->$a == 0)
$obj->$a = 0;
else
$obj->$a = 1;
break;
default:
if (isset($_POST[$a]) ) {
$obj->$a = stripslashes($_POST[$a]);
}
}
}
// try {
$ret = $obj->create();
header("Location: $_POST[referer]");
die;
}
if (!isset($_POST['obj']) or !isset($_POST['primaryKey']))
die("<br /><br />Missing parameter.");
else {
$primaryKey = $_POST['primaryKey'];
$obj->read(base64_decode($primaryKey));
foreach ($colDets as $a => $b) {
switch ($b[type]) {
case 'boolean':
$obj->$a = $_POST[$a];
if (is_null($obj->$a) or $obj->$a == 0)
$obj->$a = 0;
else
$obj->$a = 1;
break;
default:
if (isset($_POST[$a]) ) {
$obj->$a = stripslashes($_POST[$a]);
}
}
}
// try {
$ret = $obj->update();
header("Location: $_POST[referer]");
die;
}