-
Notifications
You must be signed in to change notification settings - Fork 28
/
admin_party_edit.php
147 lines (118 loc) · 3.38 KB
/
admin_party_edit.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
<?php
require_once("bootstrap.inc.php");
require_once("include_pouet/box-modalmessage.php");
require_once("include_pouet/box-party-submit.php");
if ($currentUser && !$currentUser->CanEditItems())
{
redirect("party.php?which=".(int)$_GET["which"]);
exit();
}
class PouetBoxAdminEditParty extends PouetBoxSubmitParty
{
public $id;
public $party;
function __construct( $id )
{
parent::__construct();
$this->id = (int)$id;
$this->party = PouetParty::Spawn( $this->id );
$this->title = "edit this party: ". $this->party->PrintLinked();
}
use PouetForm;
function Commit($data)
{
global $partyID;
$a = array();
$a["name"] = trim($data["name"]);
$a["web"] = $data["website"];
SQLLib::UpdateRow("parties",$a,"id=".$this->id);
gloperator_log( "party", $this->id, "party_edit" );
return array();
}
function LoadFromDB()
{
parent::LoadFromDB();
$this->fields["name"]["value"] = $this->party->name;
$this->fields["website"]["value"] = $this->party->web;
}
}
class PouetBoxAdminDeleteParty extends PouetBox
{
public $party;
public $checkString;
function __construct( $party )
{
parent::__construct();
$this->uniqueID = "pouetbox_partydelete";
$this->classes[] = "errorbox";
$this->party = $party;
global $verificationStrings;
$this->checkString = $verificationStrings[ array_rand($verificationStrings) ];
$this->title = "delete this party: ".$party->PrintLinked();
}
use PouetForm;
function Validate($data)
{
if ($data["check"] != $data["checkOrig"])
return array("wrong verification string !");
return array();
}
function Commit($data)
{
$this->party->Delete();
gloperator_log( "party", (int)$this->party->id, "party_delete", get_object_vars($this->party) );
return array();
}
function RenderBody()
{
echo "<div class='content'/>";
echo " <p>To make sure you want to delete <b>this</b> party, type \"".$this->checkString."\" here:</p>";
echo " <input name='checkOrig' type='hidden' value='"._html($this->checkString)."'/>";
echo " <input id='check' name='check' autocomplete='no'/>";
echo "</div>";
echo "<div class='foot'/>";
echo " <input type='submit' value='Submit' />";
echo "</div>";
?>
<script>
document.observe("dom:loaded",function(){
$("pouetbox_partydelete").up("form").observe("submit",function(e){
if ($F("check") != "<?=_js($this->checkString)?>")
{
alert("Enter the verification string!");
e.stop();
return;
}
if (!confirm("ARE YOU REALLY SURE YOU WANT TO DELETE \"<?=_js($this->party->name)?>\"?!"))
e.stop();
});
});
</script>
<?php
}
}
$form = new PouetFormProcessor();
$form->SetSuccessURL( "party.php?which=".(int)$_GET["which"], true );
$box = new PouetBoxAdminEditParty( $_GET["which"] );
$form->Add( "party", $box );
$form->Add( "partydelete", new PouetBoxAdminDeleteParty( $box->party ) );
if ($currentUser && $currentUser->CanEditItems())
$form->Process();
$TITLE = "edit a party: ".$box->party->name;
require_once("include_pouet/header.php");
require("include_pouet/menu.inc.php");
echo "<div id='content'>\n";
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");
?>