-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenter.php
More file actions
198 lines (171 loc) · 8.5 KB
/
enter.php
File metadata and controls
198 lines (171 loc) · 8.5 KB
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?php
/*
Copyright (C) 2008-2009 Gilles Dubuc (www.kouiskas.com - gilles@dubuc.fr)
Page where users send their contributions to open competitions
*/
require_once(dirname(__FILE__).'/entities/community.php');
require_once(dirname(__FILE__).'/entities/competition.php');
require_once(dirname(__FILE__).'/entities/entry.php');
require_once(dirname(__FILE__).'/entities/entrylist.php');
require_once(dirname(__FILE__).'/entities/pointsvalue.php');
require_once(dirname(__FILE__).'/entities/theme.php');
require_once(dirname(__FILE__).'/entities/user.php');
require_once(dirname(__FILE__).'/entities/userlevellist.php');
require_once(dirname(__FILE__).'/utilities/page.php');
require_once(dirname(__FILE__).'/utilities/persistenttoken.php');
require_once(dirname(__FILE__).'/utilities/string.php');
require_once(dirname(__FILE__).'/utilities/ui.php');
require_once(dirname(__FILE__).'/constants.php');
require_once(dirname(__FILE__).'/settings.php');
$user = User::getSessionUser();
$levels = UserLevelList::getByUid($user->getUid());
$ispremium = in_array($USER_LEVEL['PREMIUM'], $levels);
$hideads = ($ispremium && $user->getHideAds());
$page = new Page('COMPETE', 'COMPETITIONS', $user);
$page->addStyle('EDITABLE_PICTURE');
$page->addJavascript('EDITABLE_PICTURE');
$persistenttoken = new PersistentToken($user->getUid());
$page->addJavascriptVariable('persistenttoken', $persistenttoken->getHash());
$cid = isset($_REQUEST['cid'])?$_REQUEST['cid']:null;
if ($cid == null) {
header('Location: ' . $PAGE['COMPETE'].'?lid='.$user->getLid());
exit(0);
}
$competition = Competition::get($cid);
if ($competition->getStatus() != $COMPETITION_STATUS['OPEN']) {
header('Location: ' . $PAGE['COMPETE'].'?lid='.$user->getLid());
exit(0);
}
$page->startHTML();
$community = Community::get($competition->getXid());
$theme = Theme::get($competition->getTid());
$page->setTitle('<translate id="ENTER_PAGE_TITLE">Enter the "<string value="'.String::fromaform($theme->getTitle()).'"/>" competition of the <string value="'.String::fromaform($community->getName()).'"/> community on inspi.re</translate>');
echo '<div id="competition_description">';
echo '<div class="listing_item nomargin">';
echo '<picture href="'.$PAGE['COMMUNITY'].'?lid='.$user->getLid().'&xid='.$competition->getXid().'" category="community" class="listing_thumbnail" size="small" '.($community->getPid() === null?'':'pid="'.$community->getPid().'"').' />';
echo '<div class="listing_header">';
if ($community->getXid() == 267) {
echo '<translate id="PRIZE_COMMUNITY_THEME_TITLE'.$competition->getTid().'">'.$theme->getTitle().'</translate>';
} else {
echo '<theme_title tid="'.$competition->getTid().'"/>';
}
echo '</div> <!-- listing_header -->';
echo '<div class="listing_subheader">';
echo '<translate id="COMPETE_LIST_SUBHEADER">';
echo 'Suggested by <user_name uid="'.$theme->getUid().'"/> for <community_name link="true" xid="'.$competition->getXid().'"/>. <span class="time_left"><duration value="'.($competition->getVoteTime() - gmmktime()).'"/> left to enter this competition</span>.';
echo '</translate>';
echo '</div> <!-- listing_subheader -->';
echo '<div class="listing_content">';
if ($community->getXid() == 267) {
echo '<translate id="PRIZE_COMMUNITY_THEME_DESCRIPTION'.$competition->getTid().'">'.$theme->getDescription().'</translate>';
} else {
echo String::fromaform($theme->getDescription());
}
echo '</div>';
echo '</div> <!-- listing_item -->';
echo '</div> <!-- competition_description -->';
$rules = $community->getRules();
if (strcmp(trim($rules), '') !=0) {
echo '<div class="warning hintmargin">';
echo '<div class="warning_title">';
echo '<translate id="ENTER_WARNING_RULES">';
echo '<community_name link="true" xid="'.$competition->getXid().'"/> has specific rules';
echo '</translate>';
echo '</div> <!-- warning_title -->';
echo '</div> <!-- warning -->';
echo '<div id="rules">';
echo String::fromaform($rules);
echo '</div> <!-- rules -->';
}
$pid = null;
switch ($user->getStatus()) {
case $USER_STATUS['UNREGISTERED']:
$status = $ENTRY_STATUS['ANONYMOUS'];
break;
case $USER_STATUS['BANNED']:
$status = $ENTRY_STATUS['BANNED'];
break;
default:
$status = $ENTRY_STATUS['POSTED'];
}
$entrylist = EntryList::getByUidAndCidAndStatus($user->getUid(), $cid, $status);
if (empty($entrylist))
$entrylist = EntryList::getByUidAndCidAndStatus($user->getUid(), $cid, $ENTRY_STATUS['DISQUALIFIED']);
if (!empty($entrylist)) {
try {
$eid = array_shift($entrylist);
$entry = Entry::get($eid);
$pid = $entry->getPid();
} catch (EntryException $e) {
$pid = null;
}
}
$pointsvalue = PointsValue::get($POINTS_VALUE_ID['ENTRY_POSTING']);
$points_entry_posting = -$pointsvalue->getValue();
echo '<ad ad_id="LEADERBOARD"/>';
$artworkcount = count(EntryList::getByUidAndStatus($user->getUid(), $ENTRY_STATUS['POSTED']));
if ($pid === null && $user->getPoints() < $points_entry_posting) {
echo '<div class="warning '.($hideads?'abovemargin':'').'">';
echo '<div class="warning_title">';
echo '<translate id="ENTER_LACK_OF_FUNDS_TITLE">';
echo 'You do not have enough points to enter a competition';
echo '</translate>';
echo '</div> <!-- warning_title -->';
echo '<translate id="LACK_OF_FUNDS">';
echo '<integer value="'.$points_entry_posting.'"/> points are needed and you only have <integer value="'.$user->getPoints().'"/>. We suggest that you <a href="'.$PAGE['VOTE'].'?lid='.$user->getLid().'">vote and critique entries</a> in order to earn points.';
echo '</translate>';
echo '</div> <!-- warning -->';
} elseif ($artworkcount > 70 && !$ispremium) {
echo '<div class="hint hintmargin '.($hideads?'abovemargin':'').'">';
echo '<div class="hint_title">';
echo '<translate id="ENTER_HINT_TITLE">';
echo 'Enter this competition or replace your existing entry';
echo '</translate>';
echo '</div> <!-- hint_title -->';
echo '<translate id="ENTER_HINT_BODY">';
echo 'Use the button and the links below the image to enter, delete or replace your entry for this competition. <b>Please note that the picture\'s cropping settings only affect the thumbnails. Your entry will always be displayed without any cropping during the competition.</b>';
echo '</translate>';
echo ' <span id="points_warning">';
echo '<translate id="ENTER_POINTS_COST">';
echo 'Entering a competition costs <integer value="'.$points_entry_posting.'"/> points.';
echo '</translate>';
echo '</span>';
echo '</div> <!-- hint -->';
echo '<div class="warning '.($hideads?'abovemargin':'').'">';
echo '<div class="warning_title">';
echo '<translate id="ENTER_STANDARD_MEMBERSHIP_MAX_TITLE">';
echo 'You\'ve reached the storage limit that your standard membership allows';
echo '</translate>';
echo '</div> <!-- warning_title -->';
echo '<translate id="ENTER_STANDARD_MEMBERSHIP_MAX">';
echo 'Standard members can only store a maximum of <integer value="70"/> artworks on their account. You currently have <integer value="'.$artworkcount.'"/> artworks stored on your account. In order to enter a new competition, you need to either <a href="'.$PAGE['PREMIUM'].'?lid='.$user->getLid().'">upgrade to premium membership</a> or to delete older entries.';
echo '</translate>';
echo '</div> <!-- warning -->';
} else {
echo '<div class="hint hintmargin '.($hideads?'abovemargin':'').'">';
echo '<div class="hint_title">';
echo '<translate id="ENTER_HINT_TITLE">';
echo 'Enter this competition or replace your existing entry';
echo '</translate>';
echo '</div> <!-- hint_title -->';
echo '<translate id="ENTER_HINT_BODY">';
echo 'Use the button and the links below the image to enter, delete or replace your entry for this competition. <b>Please note that the picture\'s cropping settings only affect the thumbnails. Your entry will always be displayed without any cropping during the competition.</b>';
echo '</translate>';
echo ' <span id="points_warning">';
echo '<translate id="ENTER_POINTS_COST">';
echo 'Entering a competition costs <integer value="'.$points_entry_posting.'"/> points.';
echo '</translate>';
echo '</span>';
echo '</div> <!-- hint -->';
echo '<div id="entry_picture">';
echo UI::RenderEditablePicture($page, $pid, $PICTURE_CATEGORY['ENTRY'], true, $REQUEST['ENTRY_UPLOAD'].'?cid='.$cid, $REQUEST['ENTRY_RESET'].'?cid='.$cid, $PAGE['EDIT_CROPPING'].'?cid='.$cid, $persistenttoken->getHash());
echo '</div> <!-- entry_picture -->';
echo '<div id="picture_huge_container">';
if ($pid != null) {
echo '<picture id="picture_huge" pid="'.$pid.'" size="huge"/>';
} else echo '<img id="picture_huge" src="'.$GRAPHICS_PATH.'invisible.gif">';
echo '</div> <!-- picture_huge_container -->';
}
$page->endHTML();
$page->render();
?>