forked from pouetnet/pouet2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_party_edition_edit.php
118 lines (94 loc) · 3.15 KB
/
admin_party_edition_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
<?php
require_once("bootstrap.inc.php");
require_once("include_pouet/box-modalmessage.php");
require_once("include_pouet/box-party-edition-submit.php");
if ($currentUser && !$currentUser->CanEditItems())
{
redirect("party.php?which=".(int)$_GET["which"]."&when=".(int)$_GET["when"]);
exit();
}
class PouetBoxAdminEditPartyEdition extends PouetBoxSubmitPartyEdition
{
public $id;
public $party;
public $year;
public $links;
function __construct( $id, $year )
{
parent::__construct();
$this->id = $id;
$this->year = $year;
$this->party = PouetParty::Spawn( $this->id );
$this->title = "edit this party: ". $this->party->PrintLinked( $this->year );
}
use PouetForm;
function Commit($data)
{
global $partyID;
$sql = array();
$sql["download"] = $data["download"];
$sql["csdb"] = (int)$data["csdbID"];
$sql["slengpung"] = (int)$data["slengpungID"];
//$sql["zxdemo"] = $data["zxdemoID"];
$sql["demozoo"] = (int)$data["demozooID"];
$sql["artcity"] = $data["artcity"];
$links = SQLLib::selectRow(sprintf_esc("select * from partylinks where party = %d and year = %d",$this->id,$this->year));
if ($links)
{
SQLLib::UpdateRow("partylinks",$sql,sprintf_esc("party = %d and year = %d",$this->id,$this->year));
}
else
{
$sql["party"] = $this->id;
$sql["year"] = $this->year;
SQLLib::InsertRow("partylinks",$sql);
}
if (is_uploaded_file($_FILES["results"]["tmp_name"]))
{
move_uploaded_file_fake($_FILES["results"]["tmp_name"],get_local_partyresult_path($this->id,$this->year));
}
gloperator_log( "party", (int)$this->id, "party_edit_links", array("year"=>$this->year) );
return array();
}
function LoadFromDB()
{
parent::LoadFromDB();
$this->links = SQLLib::selectRow(sprintf_esc("select * from partylinks where party = %d and year = %d",$this->id,$this->year));
if ($this->links)
{
$this->fields["download"]["value"] = $this->links->download;
$this->fields["csdbID"]["value"] = $this->links->csdb;
$this->fields["slengpungID"]["value"] = $this->links->slengpung;
//$this->fields["zxdemoID"]["value"] = $this->links->zxdemo;
$this->fields["demozooID"]["value"] = $this->links->demozoo;
$this->fields["artcity"]["value"] = $this->links->artcity;
}
foreach($_POST as $k=>$v)
if ($this->fields[$k])
$this->fields[$k]["value"] = $v;
}
}
$form = new PouetFormProcessor();
$form->SetSuccessURL( "party.php?which=".(int)$_GET["which"]."&when=".(int)$_GET["when"], true );
$box = new PouetBoxAdminEditPartyEdition( $_GET["which"],$_GET["when"] );
$form->Add( "partyyear", $box );
if ($currentUser && $currentUser->CanEditItems())
$form->Process();
$TITLE = sprintf("edit a party edition: %s %04d",$box->party->name,$box->year);
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");
?>