forked from OpenCorpora/opencorpora
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pools.php
96 lines (92 loc) · 3.59 KB
/
pools.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
<?php
require('lib/header.php');
require_once('lib/lib_xml.php');
require_once('lib/lib_annot.php');
$action = isset($_GET['act']) ? $_GET['act'] : '';
if ($action && !in_array($action, array('samples', 'candidates')) && !user_has_permission('perm_check_morph')) {
show_error($config['msg']['notadmin']);
return;
}
switch ($action) {
case 'add':
add_morph_pool();
header("Location:pools.php?added&type=0");
break;
case 'delete':
delete_morph_pool($_GET['pool_id']);
header("Location:pools.php");
break;
case 'candidates':
$smarty->assign('pool', get_pool_candidates_page($_GET['pool_id']));
$smarty->display('qa/pool_candidates.tpl');
break;
case 'types':
$smarty->assign('data', get_morph_pool_types(true));
$smarty->display('qa/pool_types.tpl');
break;
case 'save_types':
save_morph_pool_types($_POST);
header("Location:pools.php?act=types");
break;
case 'samples':
if (isset($_GET['tabs'])) {
$smarty->assign('pool', get_morph_samples_page($_GET['pool_id'], true, 100));
header("Content-type: application/csv; charset=utf-8");
header("Content-disposition: attachment; filename=pool_".(int)$_GET['pool_id'].".tab");
$smarty->display('qa/pool_tabs.tpl');
}
else {
$filter = isset($_GET['filter']) ? $_GET['filter'] : false;
$matches = NULL;
if ($filter && !user_has_permission('perm_check_morph') && preg_match('/^user:(\d+)$/', $filter, $matches)) {
if ($matches[1] != $_SESSION['user_id']) {
show_error("Можно просматривать только свои ответы.");
return;
}
}
$smarty->assign('pool', get_morph_samples_page(
$_GET['pool_id'],
isset($_GET['ext']),
$config['misc']['morph_annot_moder_context_size'],
isset($_GET['skip']) ? $_GET['skip'] : 0,
$filter,
(!user_has_permission('perm_check_morph') || $_SESSION['options'][4] == 1) ? $config['misc']['morph_annot_moder_page_size'] : 0
));
$smarty->display('qa/pool.tpl');
}
break;
case 'promote':
promote_samples((int)$_GET['pool_id'], $_POST['type']);
header("Location:pools.php?act=samples&pool_id=".$_GET['pool_id']);
break;
case 'publish':
publish_pool($_GET['pool_id']);
header("Location:pools.php?act=samples&pool_id=".$_GET['pool_id']);
break;
case 'unpublish':
unpublish_pool($_GET['pool_id']);
header("Location:pools.php?act=samples&pool_id=".$_GET['pool_id']);
break;
case 'begin_moder':
moderate_pool($_GET['pool_id']);
header("Location:pools.php?act=samples&pool_id=".$_GET['pool_id']);
break;
case 'agree':
moder_agree_with_all($_GET['pool_id']);
header("Location:pools.php?act=samples&pool_id=".$_GET['pool_id']);
break;
case 'finish_moder':
finish_moderate_pool($_GET['pool_id']);
header("Location:index.php?page=pool_charts");
break;
case 'begin_merge':
begin_pool_merge($_GET['pool_id']);
header("Location:index.php?page=pool_charts");
break;
default:
$smarty->assign('statuses', array(
));
$smarty->assign('pools', get_morph_pools_page((int)$_GET['type'], (int)$_GET['moder_id'], $_GET['filter']));
$smarty->display('qa/pools.tpl');
}
log_timing();