Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

forumedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: forumedit.php 7759 2001-10-10 13:18:29Z jhe $
5 //
6 // Created on: Created on: <14-Jul-2000 13:41:35 lw>
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 // include_once( "classes/INIFile.php" );
28 // include_once( "classes/ezhttptool.php" );
29
30 $ini =& eZINI::instance( 'site.ini' );
31
32 $Language = $ini->variable( "eZForumMain", "Language" );
33 $error = new eZINI( "kernel/ezforum/admin/intl/" . $Language . "/forumedit.php.ini", false );
34
35 // include_once( "classes/eztemplate.php" );
36 // include_once( "classes/ezlog.php" );
37
38 // include_once( "ezuser/classes/ezusergroup.php" );
39
40 // include_once( "ezforum/classes/ezforumcategory.php" );
41 // include_once( "ezforum/classes/ezforum.php" );
42
43 require( "kernel/ezuser/admin/admincheck.php" );
44
45 if ( isset( $DeleteForums ) )
46 {
47 $Action = "DeleteForums";
48 }
49
50 if ( $Action == "insert" )
51 {
52 if ( eZPermission::checkPermission( $user, "eZForum", "ForumAdd" ) )
53 {
54 if ( $Name != "" && $Description != "" && $CategorySelectID != "" )
55 {
56 $forum = new eZForum();
57 $forum->setName( $Name );
58 $forum->setDescription( $Description );
59
60 $moderatorgroup = new eZUserGroup( $ModeratorID ); //variable name?
61 $forum->setModerator( $moderatorgroup );
62
63 if ( $IsModerated == "on" )
64 {
65 $forum->setIsModerated( true );
66 }
67 else
68 {
69 $forum->setIsModerated( false );
70 }
71
72 if ( $IsAnonymous == "on" )
73 {
74 $forum->setIsAnonymous( true );
75 }
76 else
77 {
78 $forum->setIsAnonymous( false );
79 }
80
81 $group = new eZUserGroup( $GroupID );
82 $forum->setGroup( $group );
83
84 $forum->store();
85
86 $category = new eZForumCategory( $CategorySelectID );
87 $category->addForum( $forum );
88 eZPBLog::writeNotice( "Forum created: $Name from IP: $REMOTE_ADDR" );
89
90 eZHTTPTool::header( "Location: /forum/forumlist/$CategorySelectID" );
91 exit();
92 }
93 else
94 {
95 eZPBLog::writeWarning( "Forum not created: missing data from IP: $REMOTE_ADDR" );
96
97 $error_msg = $error->variable( "strings", "error_missingdata" );
98 }
99 }
100 else
101 {
102 eZHTTPTool::header( "Location: /forum/norights" );
103 exit();
104 }
105 }
106
107 if ( $Action == "update" )
108 {
109 if ( eZPermission::checkPermission( $user, "eZForum", "ForumModify" ) )
110 {
111 if ( $Name != "" && $Description != "" && $CategorySelectID != "" )
112 {
113 $forum = new eZForum();
114 $forum->get( $ForumID );
115
116 $moderatorgroup = new eZUserGroup( $ModeratorID ); //variable name?
117 $forum->setModerator( $moderatorgroup );
118
119 if ( $IsModerated == "on" )
120 {
121 $forum->setIsModerated( true );
122 }
123 else
124 {
125 $forum->setIsModerated( false );
126 }
127
128 if ( $IsAnonymous == "on" )
129 {
130 $forum->setIsAnonymous( true );
131 }
132 else
133 {
134 $forum->setIsAnonymous( false );
135 }
136
137 $forum->setName( $Name );
138 $forum->setDescription( $Description );
139
140 $group = new eZUserGroup( $GroupID );
141 $forum->setGroup( $group );
142
143 $forum->store();
144
145 // remove all category assigmnents.
146 $forum->removeFromForums();
147
148 $category = new eZForumCategory( $CategorySelectID );
149 $category->addForum( $forum );
150
151 eZPBLog::writeNotice( "Forum updated: $Name from IP: $REMOTE_ADDR" );
152
153 eZHTTPTool::header( "Location: /forum/forumlist/$CategorySelectID" );
154 exit();
155 }
156 else
157 {
158 eZPBLog::writeWarning( "Forum not updated: missing data from IP: $REMOTE_ADDR" );
159 $error_msg = $error->variable( "strings", "error_missingdata" );
160 }
161 }
162 else
163 {
164 eZHTTPTool::header( "Location: /forum/norights" );
165 exit();
166 }
167 }
168
169 if ( $Action == "delete" )
170 {
171 if ( eZPermission::checkPermission( $user, "eZForum", "ForumDelete" ) )
172 {
173 if ( $ForumID != "" )
174 {
175 $forum = new eZForum();
176 $forum->get( $ForumID );
177 $forumName = $forum->name();
178
179 $forum->delete();
180 eZPBLog::writeNotice( "Forum deleted: $forumName from IP: $REMOTE_ADDR" );
181
182 eZHTTPTool::header( "Location: /forum/forumlist/" );
183 exit();
184 }
185 else
186 {
187 eZPBLog::writeWarning( "Forum not deleted: id not found from IP: $REMOTE_ADDR" );
188 $error_msg = $error->variable( "strings", "error_missingdata" );
189 }
190 }
191 else
192 {
193 eZHTTPTool::header( "Location: /forum/norights" );
194 exit();
195 }
196 }
197
198 if ( $Action == "DeleteForums" )
199 {
200 if ( count( $ForumArrayID ) != 0 )
201 {
202 foreach ( $ForumArrayID as $ForumID )
203 {
204 $forum = new eZForum( $ForumID );
205 $forumName = $forum->name();
206 $categories = $forum->categories();
207
208 $categoryID = $categories[0]->id();
209
210 $forum->delete();
211
212 eZPBLog::writeNotice( "Forum deleted: $forumName from IP: $REMOTE_ADDR" );
213
214 }
215 eZHTTPTool::header( "Location: /forum/forumlist/$categoryID/" );
216 exit();
217 }
218 }
219
220 $t = new eZTemplate( "kernel/ezforum/admin/" . $ini->variable( "eZForumMain", "AdminTemplateDir" ),
221 "kernel/ezforum/admin/" . "/intl", $Language, "forumedit.php" );
222 $t->setAllStrings();
223
224 $t->set_file( "forum_page", "forumedit.tpl" );
225
226 $t->set_block( "forum_page", "category_item_tpl", "category_item" );
227 $t->set_block( "forum_page", "moderator_item_tpl", "moderator_item" );
228 $t->set_block( "forum_page", "group_item_tpl", "group_item" );
229
230 $languageIni = new eZINI( "kernel/ezforum/admin/" . "intl/" . $Language . "/forumedit.php.ini", false );
231 $headline = $languageIni->variable( "strings", "head_line_insert" );
232
233 $t->set_var( "forum_name", "" );
234 $t->set_var( "forum_description", "" );
235 $action_value = "update";
236
237
238 if ( $Action == "new" )
239 {
240
241 if ( !eZPermission::checkPermission( $user, "eZForum", "ForumModifyAdd" ) )
242 {
243 eZHTTPTool::header( "Location: /forum/norights" );
244 exit();
245 }
246
247 $action_value = "insert";
248 $groupUser = false;
249 $forum = false;
250 $ForumID = false;
251 }
252
253 $t->set_var( "forum_id", $ForumID );
254
255 if ( $Action == "edit" )
256 {
257 $forum = new eZForum( $ForumID );
258 $categories = $forum->categories();
259
260 $languageIni = new eZINI( "kernel/ezforum/admin/" . "intl/" . $Language . "/forumedit.php.ini", false );
261 $headline = $languageIni->variable( "strings", "head_line_edit" );
262
263 if ( !eZPermission::checkPermission( $user, "eZForum", "ForumModify" ) )
264 {
265 eZHTTPTool::header( "Location: /forum/norights" );
266 exit();
267 }
268 else
269 {
270 $forum = new eZForum();
271 $forum->get( $ForumID );
272
273 $t->set_var( "forum_name", $forum->name() );
274 $t->set_var( "forum_description", $forum->description() );
275 $t->set_var( "forum_id", $ForumID);
276
277 if ( $forum->isModerated() )
278 {
279 $t->set_var( "forum_is_moderated", "checked" );
280 }
281 else
282 {
283 $t->set_var( "forum_is_moderated", "" );
284 }
285
286 if ( $forum->isAnonymous() )
287 {
288 $t->set_var( "forum_is_anonymous", "checked" );
289 }
290 else
291 {
292 $t->set_var( "forum_is_anonymous", "" );
293 }
294
295 $groupUser =& $forum->group();
296
297 $action_value = "update";
298
299 }
300 }
301
302 $category = new eZForumCategory();
303 $categoryList = $category->getAll();
304 foreach ( $categoryList as $categoryItem )
305 {
306 $t->set_var( "category_id", $categoryItem->id() );
307 $t->set_var( "category_name", $categoryItem->name() );
308
309
310 if ( isset( $categories ) && count( $categories ) > 0 )
311 {
312 if ( $categoryItem->id() == $categories[0]->id() )
313 $t->set_var( "is_selected", "selected" );
314 else
315 $t->set_var( "is_selected", "" );
316 }
317 else
318 {
319 $t->set_var( "is_selected", "" );
320 }
321
322
323 $t->parse( "category_item", "category_item_tpl", true );
324 }
325
326 $userList = eZUser::getAll(); //remove?
327
328 $group = new eZUserGroup();
329 $groupList = $group->getAll();
330
331 $t->set_var( "user_id", 0 );
332 $t->set_var( "user_name", "testing" );
333 $noModeratorString = $t->Ini->variable( "strings", "no_moderator" );
334 $t->set_var( "user_name", $noModeratorString );
335
336 $t->set_var( "is_selected", "" );
337
338 if ( $forum )
339 {
340 $moderator = $forum->moderator();
341 }
342 else
343 {
344 $moderator = 0;
345 }
346
347 if ( $moderator == 0 )
348 {
349 $t->set_var( "is_selected", "selected" );
350 }
351
352 $t->parse( "moderator_item", "moderator_item_tpl", true );
353
354 //foreach ( $userList as $userItem )
355 foreach ( $groupList as $groupItem )
356 {
357 $t->set_var( "user_id", $groupItem->id() );
358 $t->set_var( "user_name", $groupItem->name() ); //change variable names?
359
360 if ( $Action == "edit" )
361 {
362 if ( $moderator )
363 {
364 if ( $moderator->id() == $groupItem->id() )
365 {
366 $t->set_var( "is_selected", "selected" );
367 }
368 else
369 {
370 $t->set_var( "is_selected", "" );
371 }
372 }
373 else
374 {
375 $t->set_var( "is_selected", "" );
376 }
377 }
378 else
379 {
380 $t->set_var( "is_selected", "" );
381 }
382
383 $t->parse( "moderator_item", "moderator_item_tpl", true );
384 }
385
386 $group = new eZUserGroup();
387 $groupList =& $group->getAll();
388
389 foreach ( $groupList as $group )
390 {
391 $t->set_var( "group_name", $group->name() );
392 $t->set_var( "group_id", $group->id() );
393
394 $t->set_var( "is_selected", "" );
395 if ( is_a( $group, "eZUserGroup" ) && is_a( $groupUser, "eZUserGroup" ) )
396 {
397 if ( $groupUser->id() == $group->id() )
398 $t->set_var( "is_selected", "selected" );
399 }
400
401 $t->parse( "group_item", "group_item_tpl", true );
402 }
403
404 $t->set_var( "action_value", $action_value );
405 $t->set_var( "error_msg", isset( $error_msg ) ? $error_msg : false );
406 $t->set_var( "category_id", isset( $CategoryID ) ? $CategoryID : false );
407 $t->set_var( "headline", $headline );
408
409 $t->pparse( "output", "forum_page");
410
411 ?>
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
$forum
$forum
Definition: admin/forumlist.php:50
$Description
$Description
Definition: articlelistrss.php:38
eZForumCategory
Definition: ezforumcategory.php:44
eZForum
Definition: ezforum.php:44
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZINI
Reads and writes .ini style configuration files.
eZPBLog\writeNotice
static writeNotice( $notice)
Definition: ezpblog.php:166
eZPBLog\writeWarning
static writeWarning( $warning)
Definition: ezpblog.php:177
eZPermission\checkPermission
static checkPermission( $user, $moduleName, $permissionName)
Definition: ezpermission.php:430
eZTemplate
Definition: eztemplate.php:107
eZUserGroup
Definition: ezusergroup.php:66
eZUser\getAll
static & getAll( $order="Login", $as_object=true, $search=false, $max=-1, $index=0)
Definition: ezuser.php:330
$Action
$Action
Definition: companysearch.php:80
$categories
$categories
Definition: ezarticle/admin/categoryedit.php:636
$error_msg
$error_msg
Definition: ezlink/admin/categoryedit.php:33
exit
exit
Definition: folder.php:81
$languageIni
$languageIni
Definition: forumedit.php:230
$t
if(isset( $DeleteForums)) if( $Action=="insert") if( $Action=="update") if( $Action=="delete") if( $Action=="DeleteForums") $t
Definition: forumedit.php:220
$headline
$headline
Definition: forumedit.php:231
$groupList
$groupList
Definition: forumedit.php:329
$Language
$Language
Definition: forumedit.php:32
$ini
$ini
Definition: forumedit.php:30
$noModeratorString
$noModeratorString
Definition: forumedit.php:333
$categoryList
$categoryList
Definition: forumedit.php:303
$category
if( $Action=="edit") $category
Definition: forumedit.php:302
$userList
foreach( $categoryList as $categoryItem) $userList
Definition: forumedit.php:326
$action_value
$action_value
Definition: forumedit.php:235
$group
$group
Definition: forumedit.php:328
$error
$error
Definition: forumedit.php:33
$Name
$Name
Definition: polledit.php:250
$categoryID
else $categoryID
Definition: productview.php:66
$GroupID
$GroupID
Definition: rssheadlines.php:51
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.