forked from pouetnet/pouet2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
submit_modification_request.php
215 lines (178 loc) · 4.97 KB
/
submit_modification_request.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<?
require_once("bootstrap.inc.php");
require_once("include_pouet/box-modalmessage.php");
class PouetBoxModificationRequest extends PouetBox
{
function PouetBoxModificationRequest()
{
parent::__construct();
$this->uniqueID = "pouetbox_modificationrequest";
$this->title = "submit a change request";
$this->formifier = new Formifier();
$this->fields = array();
}
use PouetForm;
function Validate( $data )
{
global $currentUser;
$errormessage = array();
if (!$currentUser)
{
$errormessage[]="you need to be logged in first.";
return $errormessage;
}
return array();
}
function Commit($data)
{
$post = array();
global $REQUESTTYPES;
if ($REQUESTTYPES[ $_POST["requestType"] ])
{
$error = $REQUESTTYPES[ $_POST["requestType"] ]::ValidateRequest($data,$post);
if ($error) return $error;
}
else
{
return array("no such request type!");
}
$a = array();
$a["requestType"] = $data["requestType"];
if($_REQUEST["prod"])
{
$a["itemID"] = (int)$_REQUEST["prod"];
$a["itemType"] = "prod";
}
$a["requestDate"] = date("Y-m-d H:i:s");
$a["userID"] = get_login_id();
$a["requestBlob"] = serialize($post);
global $reqID;
$reqID = SQLLib::InsertRow("modification_requests",$a);
return array();
}
function LoadFromDB()
{
$this->fields = array(
"requestType"=>array(
"type"=>"select",
"name"=>"whatchu want",
"assoc"=>true,
),
);
global $REQUESTTYPES;
foreach($REQUESTTYPES as $k=>$v)
{
if ($_REQUEST["prod"] && $v::GetItemType()=="prod") $this->fields["requestType"]["fields"][$k] = $v::Describe();
}
$this->fields["requestType"]["fields"]["other"] = "other request...";
foreach($_POST as $k=>$v)
if ($this->fields[$k])
$this->fields[$k]["value"] = $v;
}
function Render()
{
$error = "";
echo "\n\n";
echo "<div class='pouettbl' id='".$this->uniqueID."'>\n";
echo " <h2>".$this->title.": ";
if ($_REQUEST["prod"])
{
$prod = PouetProd::Spawn($_REQUEST["prod"]);
if (!$prod) die("no such prod!");
echo $prod->RenderSingleRowShort();
}
echo "</h2>\n";
$error = "";
if(!$_POST["requestType"])
{
echo " <div class='content'>\n";
if(count($this->fields["requestType"]["fields"]))
$this->formifier->RenderForm( $this->fields );
else
{
echo "you need to select something to request about first !";
$error = " ";
}
echo " </div>\n";
}
else
{
$this->fields["requestType"]["type"] = "statichidden";
echo " <div class='content'>\n";
$this->formifier->RenderForm( $this->fields );
echo " </div>\n";
echo " <h2>more data</h2>\n";
echo " <div class='content'>\n";
$fields = array();
$js = "";
global $REQUESTTYPES;
if ($REQUESTTYPES[ $_POST["requestType"] ])
{
$error = $REQUESTTYPES[ $_POST["requestType"] ]::GetFields($_REQUEST,$fields,$js);
}
else
{
$error = "no such request type !";
}
if ($fields && !$error)
{
foreach($_POST as $k=>$v)
if ($fields[$k])
$fields[$k]["value"] = $v;
$this->formifier->RenderForm($fields);
}
if ($error)
echo $error;
echo " </div>\n";
}
if ($js)
{
echo "<script type='text/javascript'>\n";
echo "<!--\n";
echo $js;
echo "//-->\n";
echo "</script>\n";
}
if (!$error)
echo " <div class='foot'><input type='submit' value='Submit' /></div>";
echo "</div>\n";
}
};
$TITLE = "submit a modification request";
if ($_POST["requestType"] == "other")
{
redirect("topic.php?which=".(int)FIXMETHREAD_ID."&from=".(int)$_REQUEST["prod"]."#pouetbox_bbspost");
exit();
}
if (!$_POST["requestType"] && $_GET["requestType"])
$_POST["requestType"] = $_GET["requestType"];
require_once("include_pouet/header.php");
require("include_pouet/menu.inc.php");
echo "<div id='content'>\n";
$form = new PouetFormProcessor();
$form->successMessage =
"your request was recorded and will be processed by a glöperator eventually !</a> <br/>". // l33t h4x
"you can keep track of the status of your requests <a href='account.php#pouetbox_accountreq'>on your accounts page !";
if ($_REQUEST["prod"])
$form->SetSuccessURL( "prod.php?which=".(int)$_REQUEST["prod"], false );
else
$form->SetSuccessURL( "", false );
$form->Add( "logo", new PouetBoxModificationRequest() );
if ($currentUser && $currentUser->CanSubmitItems() && (int)$_POST["finalStep"]==1)
$form->Process();
else
unset( $_POST[ PouetFormProcessor::fieldName ] );
if (get_login_id())
{
$form->Display();
}
else
{
require_once("include_pouet/box-login.php");
$box = new PouetBoxLogin();
$box->Render();
}
echo "</div>\n";
require("include_pouet/menu.inc.php");
require_once("include_pouet/footer.php");
?>