Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

polledit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: polledit.php 6304 2001-07-29 23:31:17Z kaid $
5 //
6 // Created on: <21-Sep-2000 10:39:19 ce>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27
28 // include_once( "classes/INIFile.php" );
29 // include_once( "classes/eztemplate.php" );
30 // include_once( "classes/ezhttptool.php" );
31
32 $ini =& eZINI::instance( 'site.ini' );
33
34 $Language = $ini->variable( "eZPollMain", "Language" );
35 $errorIni = new eZINI( "kernel/ezpoll/admin/intl/" . $Language . "/polledit.php.ini", false );
36
37 // include_once( "ezpoll/classes/ezpoll.php" );
38 // include_once( "ezpoll/classes/ezpollchoice.php" );
39 // include_once( "ezpoll/classes/ezvote.php" );
40
41 require( "kernel/ezuser/admin/admincheck.php" );
42
43 if ( isset( $Back ) )
44 {
45 eZHTTPTool::header( "Location: /poll/pollist/" );
46 exit();
47 }
48
49 // Insert
50 if ( isset( $Action ) && $Action == "New" )
51 {
52 $PollID = false;
53 $ShowResult = false;
54 }
55 // Insert
56 if ( isset( $Action ) && $Action == "Insert" )
57 {
58 if ( $Name )
59 {
60 $poll = new eZPoll();
61 if ( $IsEnabled == "on" )
62 {
63 $poll->setIsEnabled ( true );
64 }
65 else
66 {
67 $poll->setIsEnabled ( false );
68 }
69
70 if ( isset( $IsClosed ) && $IsClosed == "on" )
71 {
72 $poll->setIsClosed ( true );
73 }
74 else
75 {
76 $poll->setIsClosed ( false );
77 }
78
79 if ( $ShowResult == "on" )
80 {
81 $poll->setShowResult ( true );
82 }
83 else
84 {
85 $poll->setShowResult ( false );
86 }
87
88 if ( isset( $Anonymous ) && $Anonymous == "on" )
89 {
90 $poll->setAnonymous ( true );
91 }
92 else
93 {
94 $poll->setAnonymous ( false );
95 }
96
97 if ( !$Description )
98 {
99 $languageIni = new eZINI( "kernel/ezpoll/admin/" . "intl/" . $Language . "/polledit.php.ini", false );
100 $Description = $languageIni->variable( "strings", "description_default" );
101 }
102
103 $poll->setName( $Name );
104 $poll->setDescription( $Description );
105 $poll->store();
106
107 $PollID = $poll->id();
108
109 // clear the menu cache
110 if ( file_exists("ezpoll/cache/menubox.cache" ) )
111 eZPBFile::unlink( "ezpoll/cache/menubox.cache" );
112
113 if ( isset( $Choice ) == true )
114 {
115 $Action = "Edit";
116 }
117 else
118 {
119 eZHTTPTool::header( "Location: /poll/pollist/" );
120 exit();
121 }
122 }
123 else
124 {
125 $errorMsg = $errorIni->variable( "strings", "noname" );
126 }
127 }
128
129 if ( isset ( $Choice ) )
130 {
131 $item = new eZPollChoice();
132 $item->setName( $errorIni->variable( "strings", "newitem") );
133 $item->setPollID( $PollID );
134 $item->store();
135
136 }
137
138 if ( isset( $DeleteChoice ) )
139 {
140 if( count( $PollArrayID ) > 0 )
141 {
142 foreach( $PollArrayID as $itemIndex )
143 {
144 $item = new eZPollChoice( $PollChoiceID[$itemIndex] );
145 $item->delete();
146 }
147 }
148 }
149
150
151 // Update
152 if ( isset( $Action ) && $Action == "Update" )
153 {
154 $poll = new eZPoll();
155 $poll->get( $PollID );
156
157 if ( $IsEnabled== "on" )
158 {
159 $poll->setIsEnabled ( true );
160 }
161 else
162 {
163 $poll->setIsEnabled ( false );
164 }
165
166 if ( $IsClosed == "on" )
167 {
168 $poll->setIsClosed ( true );
169 }
170 else
171 {
172 $poll->setIsClosed ( false );
173 }
174
175 if ( $ShowResult == "on" )
176 {
177 $poll->setShowResult ( true );
178 }
179 else
180 {
181 $poll->setShowResult ( false );
182 }
183
184 if ( $Anonymous == "on" )
185 {
186 $poll->setAnonymous ( true );
187 }
188 else
189 {
190 $poll->setAnonymous ( false );
191 }
192
193 $poll->setName( $Name );
194 $poll->setDescription( $Description );
195 $poll->store();
196
197 if( count( $PollChoiceID ) > 0 )
198 {
199 $i = 0;
200 foreach( $PollChoiceID as $itemID )
201 {
202 $item = new eZPollChoice( $itemID );
203 $item->setName( $PollChoiceName[$i] );
204 $item->store();
205 $i++;
206 }
207 }
208 // clear the menu cache
209 if ( file_exists("ezpoll/cache/menubox.cache" ) )
210 eZPBFile::unlink( "ezpoll/cache/menubox.cache" );
211
212 if( isset( $Ok ) )
213 {
214 eZHTTPTool::header( "Location: /poll/pollist/" );
215 exit();
216 }
217
218 eZHTTPTool::header( "Location: /poll/polledit/edit/$PollID" );
219 exit();
220 }
221
222 // Delete
223 if ( isset( $Action ) && $Action == "Delete" )
224 {
225 $poll = new eZPoll();
226 $poll->get( $PollID );
227 $poll->delete();
228
229 // clear the menu cache
230 if ( file_exists("ezpoll/cache/menubox.cache" ) )
231 eZPBFile::unlink( "ezpoll/cache/menubox.cache" );
232
233 eZHTTPTool::header( "Location: /poll/pollist/" );
234 exit();
235 }
236
237 $t = new eZTemplate( "kernel/ezpoll/admin/" . $ini->variable( "eZPollMain", "AdminTemplateDir" ),
238 "kernel/ezpoll/admin/intl/", $Language, "polledit.php" );
239
240 $t->setAllStrings();
241
242 $t->set_file( array( "poll_edit_page" => "polledit.tpl"
243 ) );
244
245 $t->set_block( "poll_edit_page", "poll_choice_tpl", "poll_choice" );
246
247 $t->set_var( "site_style", $SiteDesign );
248
249 $Action_value = "insert";
250 $Name = "";
251 $Description = "";
252 $IsEnabled = "";
253 $IsClosed = "";
254 $Anonymous = "";
255 $nopolls = "";
256 // Edit
257 if ( isset( $Action ) && $Action == "Edit" )
258 {
259 $poll = new eZPoll();
260 $poll->get( $PollID );
261
262 $Name = $poll->name();
263 $Description = $poll->description();
264
265 if ( $poll->isEnabled() == true )
266 {
267 $IsEnabled = "checked";
268 }
269
270 if ( $poll->isClosed() == true )
271 {
272 $IsClosed = "checked";
273 }
274
275 if ( $poll->showResult() == true )
276 {
277 $ShowResult = "checked";
278 }
279
280 if ( $poll->anonymous() == true )
281 {
282 $Anonymous = "checked";
283 }
284
285 $Action_value = "update";
286 $languageIni = new eZINI( "kernel/ezpoll/admin/" . "intl/" . $Language . "/polledit.php.ini", false );
287 $headline = $languageIni->variable( "strings", "head_line_edit" );
288 }
289
290 // Poll choice list
291 $pollChoice = new eZPollChoice();
292
293 $pollChoiceList = $pollChoice->getAll( $PollID );
294
295 if ( !$pollChoiceList )
296 {
297 $languageIni = new eZINI( "kernel/ezpoll/admin/" . "intl/" . $Language . "/polledit.php.ini", false );
298 $nopolls = $languageIni->variable( "strings", "nopolls" );
299 $t->set_var( "poll_choice", "" );
300
301 }
302
303 $i=0;
304 foreach( $pollChoiceList as $pollChoiceItem )
305 {
306 if ( ( $i %2 ) == 0 )
307 $t->set_var( "td_class", "bglight" );
308 else
309 $t->set_var( "td_class", "bgdark" );
310
311 $t->set_var( "choice_id", $pollChoiceItem->id() );
312 $t->set_var( "poll_choice_name", $pollChoiceItem->name() );
313 $vote = new eZVote();
314 $t->set_var( "poll_number", $pollChoiceItem->voteCount() );
315 $t->set_var( "index_nr", $i );
316
317 $t->parse( "poll_choice", "poll_choice_tpl", true );
318 $i++;
319 }
320
321 $t->set_var( "poll_id", $PollID );
322 $t->set_var( "name_value", $Name );
323 $t->set_var( "description_value", $Description );
324 $t->set_var( "is_enabled", $IsEnabled );
325 $t->set_var( "is_closed", $IsClosed );
326 $t->set_var( "show_result", $ShowResult );
327 $t->set_var( "anonymous", $Anonymous );
328
329 $t->set_var( "action_value", $Action_value );
330 $t->set_var( "nopolls", $nopolls );
331
332
333 if ( !isset ( $headline ) )
334 {
335 $languageIni = new eZINI( "kernel/ezpoll/admin/" . "intl/" . $Language . "/polledit.php.ini", false );
336 $headline = $languageIni->variable( "strings", "head_line_insert" );
337 }
338 $t->set_var( "head_line", $headline );
339 $t->set_var( "error_msg", isset( $errorMsg ) ? $errorMsg : false );
340
341 $t->pparse( "output", "poll_edit_page" );
342
343 ?>
$poll
$poll
Definition: admin/pollist.php:114
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZINI
Reads and writes .ini style configuration files.
eZPBFile\unlink
static unlink( $filename)
Definition: ezpbfile.php:352
eZPollChoice
Definition: ezpollchoice.php:45
eZPoll
Definition: ezpoll.php:64
eZTemplate
Definition: eztemplate.php:107
eZVote
Definition: ezvote.php:46
$item
$item
Definition: classes/admin/linklist.php:228
$Action
$Action
Definition: companysearch.php:80
file_exists
static file_exists( $inifilename)
Definition: eZPBINIFile.php:195
$SiteDesign
$SiteDesign
Definition: ezbulkmail/user/datasupplier.php:31
$headline
$headline
Definition: ezforum/admin/categoryedit.php:225
exit
exit
Definition: folder.php:81
$languageIni
$languageIni
Definition: pendinglist.php:43
$Anonymous
$Anonymous
Definition: polledit.php:254
$Description
$Description
Definition: polledit.php:251
$pollChoiceList
$pollChoiceList
Definition: polledit.php:293
$errorIni
$errorIni
Definition: polledit.php:35
$i
if(! $pollChoiceList) $i
Definition: polledit.php:303
$Language
$Language
Definition: polledit.php:34
$Action_value
$Action_value
Definition: polledit.php:249
$ini
$ini
Definition: polledit.php:32
$Name
$Name
Definition: polledit.php:250
$pollChoice
if(isset( $Action) && $Action=="Edit") $pollChoice
Definition: polledit.php:291
$IsClosed
$IsClosed
Definition: polledit.php:253
$IsEnabled
$IsEnabled
Definition: polledit.php:252
$t
if(isset( $Back)) if(isset( $Action) && $Action=="New") if(isset( $Action) && $Action=="Insert") if(isset( $Choice)) if(isset( $DeleteChoice)) if(isset( $Action) && $Action=="Update") if(isset( $Action) && $Action=="Delete") $t
Definition: polledit.php:237
$nopolls
$nopolls
Definition: polledit.php:255
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.