-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathobjectManager.php
170 lines (141 loc) · 4.69 KB
/
objectManager.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
/**
* Code for displaying and processing objects that have object management
* methods.
*
* Required parameters
* sClass: The class that is to be handled
*
* Optional parameters
* sTitle: Set the title of the page
* iId: The object id when handling a specific entry
* bIsQueue: Whether we are handling a queue, set automatically if bIsRejected is true
* bIsRejected: Whether we are handling rejected entries, sets bIsQueue to true
* if enabled
* sAction: What to do, defaults to viewing the item if iId is given and to
* displaying a table of objects with the specified queue status otherwise
*/
require_once('path.php');
require_once(BASE.'include/incl.php');
require_once(BASE.'include/objectManager.php');
require_once(BASE.'include/application_queue.php');
require_once(BASE.'include/version_queue.php');
require_once(BASE.'include/testData_queue.php');
require_once(BASE.'include/bugs.php');
require_once(BASE.'include/db_filter_ui.php');
require_once(BASE.'include/maintainerView.php');
/* if we have no valid class name we should abort */
if(!isset($aClean['sClass']))
{
echo "No class defined.\n";
exit;
}
/* make sure the class is defined */
if(!class_exists($aClean['sClass']))
{
echo "Class ".$aClean['sClass']." doesn't exist";
exit;
}
$aClean['iId'] = isset($aClean['iId']) ? $aClean['iId'] : 0;
$oObject = new objectManager(getInput('sClass', $aClean), getInput('sTitle', $aClean), getInput('iId', $aClean));
if(getInput('sState', $aClean))
$oObject->setState($aClean['sState']);
else if(getInput('bIsRejected', $aClean) == 'true') // Compatibility with old URLs
$oObject->setState('rejected');
else if(getInput('bIsQueue', $aClean) == 'true')
$oObject->setState('queued');
else
$oObject->setState('accepted');
if(isset($aClean['sReturnToTitle']))
$oObject->setReturnToTitle($aClean['sReturnToTitle']);
if(isset($aClean['sReturnTo']))
$oObject->setReturnTo($aClean['sReturnTo']);
$oObject->getMultiPageDataFromInput($aClean);
$oObject->setSortInfo($aClean);
$oObject->getFilterInfoFromInput($aClean);
$sClass = $oObject->getClass();
$oOtherObject = new $sClass($oObject->getId());
/* Certain actions must be performed before the header is set. */
/* processForm returns TRUE on success, or a user-readable list of errors
on failure */
$sErrors = $oObject->processForm($aClean);
if(array_key_exists("sAction", $aClean))
$sAction = $aClean['sAction'];
else
$sAction = "";
/* Handle things that need to be done before showing any output */
if($sAction)
{
switch($aClean['sAction'])
{
case 'add':
$oObject->handle_anonymous_submission($aClean);
break;
case 'changeParent':
/* Provided the necessary values are present, an object may be moved
to another parent without any confirmation */
if($oObject->getId() && getInput('iNewId', $aClean))
$oObject->change_parent($aClean['iNewId']);
break;
case 'moveChildren':
/* Provided the necessary values are present, an object's children may be moved
without any confirmation */
if($oObject->getId() && $aClean['iNewId'])
$oObject->move_children($aClean['iNewId']);
break;
case 'doPurgeRejected':
/* Purge some or all rejected entries */
$oObject->purgeRejected($aClean);
break;
}
}
/* If no action is specified, use a default depending on other parameters */
if(!$sAction)
{
if($oObject->getId())
$sAction = "view";
}
apidb_header($oObject->get_title($sAction));
/* display a particular element */
if(($oObject->getId() || $oObject->IsNullIdAllowed($sAction)) && $sAction != "add")
{
switch($sAction)
{
case "cancel":
$oObject->display_table($aClean); /* go back to the queue */
break;
case "edit":
$oObject->display_entry_for_editing($aClean, $sErrors);
break;
case 'moveToNewParent':
$oObject->move_to_new_parent($aClean, $sErrors);
break;
case 'showChangeParent':
$oObject->display_change_parent();
break;
case "showMoveChildren":
$oObject->display_move_children();
break;
case "delete":
$oObject->delete_prompt();
break;
case "view":
$oObject->view($_SERVER['REQUEST_URI'], $aClean);
break;
}
} else
{
switch($sAction)
{
case 'add':
$oObject->add_entry($aClean, $sErrors);
break;
case 'purgeRejected':
$oObject->displayPurgeRejected();
break;
default:
$oObject->display_table($aClean);
}
}
apidb_footer();
?>