This repository has been archived by the owner on Feb 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
admin.php
executable file
·97 lines (84 loc) · 3.39 KB
/
admin.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
<?php
/**
* Admin Plugin: View and Delete Submissions in Admin Area
*
* @license GPL 3 (http://www.gnu.org/licenses/gpl.html)
* @author Masoud Sadrnezhaad <masoud@sadrnezhaad.ir>
*/
class admin_plugin_judge extends DokuWiki_Admin_Plugin
{
/**
* handle user request
*/
function handle()
{
if (!isset($_REQUEST['cmd'])) {
return; // first time - nothing to do
}
if (!checkSecurityToken()) {
return;
}
if (!is_array($_REQUEST['cmd'])) {
return;
}
$crud = plugin_load('helper', 'judge_crud', true);
// verify valid values
switch (key($_REQUEST['cmd'])) {
case 'get' :
$this->output = '<div class="table sectionedit1">
<table class="inline">';
$table = $crud->tableRender(array('problem_name' => $_REQUEST['problem_name'], 'type' => $_REQUEST['type'], 'user' => $_REQUEST['user']), "html", 1, "timestamp");
if ($table["count"] == 0) {
$this->output .= '<p>' . $this->getLang("empty_result") . '</p>';
break;
} else {
$this->output .= $table["submissions_table"];
}
$this->output .= "</table></div>";
break;
case 'delete' :
$this->output = $crud->delSubmissions(array('problem_name' => $_REQUEST['problem_name'], 'type' => $_REQUEST['type'], 'user' => $_REQUEST['user']));
break;
}
}
/**
* output appropriate html
*/
function html()
{
global $ID, $auth;
$filter['grps'] = "user";
if ($auth->canDo('getUsers')) { // is this feature available?
$users = $auth->retrieveUsers(0, 0);
}
$html = '<p>' . $this->getLang("intro_message") . '</p>
<form class="admin-form" action="' . wl($ID) . '" method="post">
<label class="block">' . $this->getLang("question_name") . ': <input name="problem_name" type="text" /></label>
<label class="block">' . $this->getLang("sender") . ':
<select name="user">
<option value="">' . $this->getLang("all_users") . '</option>';
while ($user = current($users)) {
$html .= '<option value="' . key($users) . '">' . $user["name"] . '</option>';
next($users);
}
$html .= '
</select>
</label>
<label class="block">
<input type="radio" name="type" value="test-case"> ' . $this->getLang('programming_questions') . '<br />
<input type="radio" name="type" value="output-only"> ' . $this->getLang('outputonly_questions') . '
</label>';
// output hidden values to ensure dokuwiki will return back to this plugin
$html .= '<input type="hidden" name="do" value="admin" />'
. '<input type="hidden" name="page" value="' . $this->getPluginName() . '" />';
ptln($html);
formSecurityToken();
$html = '
<input type="submit" name="cmd[get]" value="' . $this->getLang('btn_get_submissions') . '" />
<input type="submit" name="cmd[delete]" value="' . $this->getLang('btn_delete_submissions') . '" />
</form><h1 class="sectionedit1"></h1>
';
$html .= $this->output;
ptln($html);
}
}