This repository has been archived by the owner on Jul 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
clovek.edit.exec.inc
153 lines (135 loc) · 3.59 KB
/
clovek.edit.exec.inc
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
<?php
/*
* greybox
* $Id: clovek.edit.exec.inc,v 1.13 2005/04/15 09:08:14 che0 Exp $
*/
include_once("lib/points.inc");
$clovek_id = $_REQUEST["clovek_id"];
$klub_id = $_REQUEST["klub_id"];
$jmeno = $_REQUEST["jmeno"];
$nick = $_REQUEST["nick"];
$prijmeni = $_REQUEST["prijmeni"];
$komentar = filter_comment($_REQUEST["komentar"]);
$narozen = $_REQUEST["narozen"];
$debater = $_REQUEST["debater"];
$clen = $_REQUEST["clen"];
cpdb_fetch_one_row("select klub_ID, clen from clovek where clovek_ID = :clovek_id", array(":clovek_id"=>$clovek_id), $cur);
if (!($GLOBALS["cps_lidi"] >= 2
|| ($GLOBALS["cps_lidi"] == 1 && (
($klub_id == $_SESSION["user_klub_ID"])
|| ($cur["klub_ID"] == $_SESSION["user_klub_ID"])
)))) {
pg_achtung($lang["access denied"]);
return;
}
if ($jmeno . $prijmeni == "" && !isset($_REQUEST["delete"]) && !isset($_REQUEST["access"])) {
pg_achtung($lang["a person has to have at least a name"]);
return;
}
if ($klub_id == 0) $klub_id = NULL;
if (isset($_REQUEST["add"])) {
// add new
if (cpdb_exec(
"insert into
clovek (klub_ID, jmeno, prijmeni, nick, narozen, debater, komentar, clen)
values
(:klub_id, :jmeno, :prijmeni, :nick, :narozen, :debater, :komentar, :clen)
",
array(
":klub_id"=>$GLOBALS["cps_lidi"] >= 2 ? $klub_id : $_SESSION["user_klub_ID"],
":jmeno"=>$jmeno,
":prijmeni"=>$prijmeni,
":nick"=>$nick,
":narozen"=>deformat_date($narozen),
":debater"=>$debater,
":clen"=> $GLOBALS["cps_lidi"] >= 3 ? $clen : 0,
":komentar"=>$komentar
)
)) {
pg_achtung($lang["person insert ok"]);
if ($klub_id) {
include("klub.inc");
} else {
$_REQUEST["clovek_id"] = cpdb_insert_id();
include("clovek.inc");
}
}
} elseif (isset($_REQUEST["save"])) {
// update
if (cpdb_exec(
"update clovek set
klub_ID = :klub_id,
jmeno = :jmeno,
prijmeni = :prijmeni,
nick = :nick,
narozen = :narozen,
debater = :debater,
clen = :clen,
komentar = :komentar
where
clovek_ID = :clovek_id
" . ($GLOBALS["cps_lidi"] < 2 ? "and klub_ID = :user_klub_id" : ""),
array(
":clovek_id"=>$clovek_id,
":klub_id"=>$GLOBALS["cps_lidi"] >= 2 ? $klub_id : $cur["klub_ID"],
":jmeno"=>$jmeno,
":prijmeni"=>$prijmeni,
":nick"=>$nick,
":narozen"=>deformat_date($narozen),
":debater"=>$debater,
":clen"=>$GLOBALS["cps_lidi"] >= 3 ? $clen : $cur["clen"],
":komentar"=>$komentar,
":user_klub_id"=>$_SESSION["user_klub_ID"]
)
)) {
pg_achtung($lang["person update ok"]);
if ($klub_id != $cur["klub_ID"]) {
// recount ipoints if club changed
ipts_recount_clovek($clovek_id);
}
include("clovek.inc");
}
} elseif (isset($_REQUEST["delete"])) {
// delete
if (cpdb_exec("
delete from
clovek
where
clovek_ID = :clovek_id
" . ($GLOBALS["cps_lidi"] < 2 ? "and klub_ID = :user_klub_id" : ""),
array(
":clovek_id"=>$clovek_id,
":user_klub_id"=>$_SESSION["user_klub_ID"]
)
)) {
pg_achtung($lang["person delete ok"]);
include("klub.inc");
}
} elseif (isset($_REQUEST["access"])) {
// update permissions
if ($GLOBALS["cps_lidi"] < 3) {
pg_achtung($lang["access denied"]);
return;
}
if (cpdb_exec(
"update clovek set
prava_lidi = :prava_lidi,
prava_kluby = :prava_kluby,
prava_souteze = :prava_souteze,
prava_debaty = :prava_debaty
where
clovek_ID = :clovek_id
",
array(
":clovek_id"=>$clovek_id,
":prava_lidi"=>$_REQUEST["prava_lidi"],
":prava_kluby"=>$_REQUEST["prava_kluby"],
":prava_souteze"=>$_REQUEST["prava_souteze"],
":prava_debaty"=>$_REQUEST["prava_debaty"]
)
)) {
pg_achtung($lang["permissions update ok"]);
include("clovek.inc");
}
}
?>