Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezforumcategory.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezforumcategory.php 7428 2001-09-24 14:03:59Z jhe $
5 //
6 // Definition of eZForumCategory class
7 //
8 // Created on: <11-Sep-2000 22:10:06 bf>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
31
40 // include_once( "classes/ezdb.php" );
41 // include_once( "ezforum/classes/ezforum.php" );
42
43 class eZForumCategory
44 {
48 function __construct( $id = "" )
49 {
50 if ( $id != "" )
51 {
52 $this->get( $id );
53 }
54 }
55
59 function store()
60 {
61 $db =& eZDB::globalDatabase();
62
63 $db->begin();
64
65 $name = $db->escapeString( $this->Name );
66 $description = $db->escapeString( $this->Description );
67
68 if ( !isset( $this->ID ) )
69 {
70 $db->lock( "eZForum_Category" );
71 $nextID = $db->nextID( "eZForum_Category", "ID" );
72
73 $res = $db->query( "INSERT INTO eZForum_Category
74 ( ID, Name, Description, IsPrivate, SectionID )
75 VALUES
76 ( '$nextID',
77 '$name',
78 '$description',
79 '$this->IsPrivate',
80 '$this->SectionID')" );
81
82 $this->ID = $nextID;
83 }
84 else
85 {
86 $res = $db->query( "UPDATE eZForum_Category SET
87 Name='$name',
88 Description='$description',
89 IsPrivate='$this->IsPrivate',
90 SectionID='$this->SectionID'
91 WHERE ID='$this->ID'
92 " );
93 }
94
95 $db->unlock();
96
97 if ( $res == false )
98 $db->rollback( );
99 else
100 $db->commit();
101
102 return true;
103 }
104
108 function delete()
109 {
110 $db =& eZDB::globalDatabase();
111
112 $forumList = $this->forums();
113
114 foreach ( $forumList as $forum )
115 {
116 $forum->delete();
117 }
118
119 $db->query( "DELETE FROM eZForum_ForumCategoryLink WHERE CategoryID='$this->ID'" );
120 $db->query( "DELETE FROM eZForum_Category WHERE ID='$this->ID'" );
121
122 return true;
123 }
124
125
129 function get( $id="" )
130 {
131 $db =& eZDB::globalDatabase();
132 $ret = false;
133 $category_array = array();
134
135 if ( $id != "" )
136 {
137 $db->array_query( $category_array, "SELECT * FROM eZForum_Category WHERE ID='$id'" );
138 if ( count( $category_array ) > 1 )
139 {
140 die( "Error: Category's with the same ID was found in the database. This shouldent happen." );
141 }
142 else if ( count( $category_array ) == 1 )
143 {
144 $this->ID = $category_array[0][$db->fieldName( "ID" )];
145 $this->Name = $category_array[0][$db->fieldName( "Name" )];
146 $this->Description = $category_array[0][$db->fieldName( "Description" )];
147 $this->SectionID = $category_array[0][$db->fieldName( "SectionID" )];
148
149 $ret = true;
150 }
151 else if ( count( $category_array ) == 0 )
152 {
153 $this->ID = 0;
154 }
155 }
156 return $ret;
157 }
158
162 public static function getAll()
163 {
164 $ret = array();
165
166 $db =& eZDB::globalDatabase();
167 $db->array_query( $category_array, "SELECT ID FROM eZForum_Category" );
168
169 $ret = array();
170 foreach ( $category_array as $category )
171 {
172 $ret[] = new eZForumCategory( $category[$db->fieldName( "ID" )] );
173 }
174
175 return $ret;
176 }
177
181 function forums( $offset = 0, $limit = -1 )
182 {
183 $db =& eZDB::globalDatabase();
184 $forum_array = array();
185 $ret = array();
186
187 // Site specific code feature here rediscovered
188 // if ( $this->ID == 1 || $this->ID == 3 ) {
189 if( !is_null( $this->ID ) )
190 {
191 $forumQuery = "SELECT ForumID FROM eZForum_ForumCategoryLink WHERE CategoryID='$this->ID'";
192 } else {
193 $forumQuery = "SELECT * FROM ( SELECT eZForum_ForumCategoryLink.ForumID as ForumID, eZForum_ForumCategoryLink.CategoryID FROM eZForum_ForumCategoryLink, eZForum_Forum, eZForum_Message WHERE eZForum_ForumCategoryLink.CategoryID='$this->ID' AND eZForum_Forum.ID = eZForum_ForumCategoryLink.ForumID AND eZForum_Message.ForumID = eZForum_Forum.ID GROUP BY eZForum_ForumCategoryLink.ForumID ) as tmpForumTable ORDER BY ForumID asc";
194 }
195
196 $db->array_query( $forum_array, $forumQuery, array( "Limit" => $limit, "Offset" => $offset ) );
197
198 foreach ( $forum_array as $forum )
199 {
200 $ret[] = new eZForum( $forum[$db->fieldName( "ForumID" )] );
201 }
202
203 return $ret;
204 }
205
209 function forumCount( )
210 {
211 $db =& eZDB::globalDatabase();
212
213 if ( $this->ID == 1 && $this->ID == 3 ) {
214 $forumQuery = "SELECT ForumID FROM eZForum_ForumCategoryLink WHERE CategoryID='$this->ID'";
215 } else {
216 $forumQuery = "SELECT * FROM ( SELECT eZForum_ForumCategoryLink.ForumID as ForumID, eZForum_ForumCategoryLink.CategoryID FROM eZForum_ForumCategoryLink, eZForum_Forum, eZForum_Message WHERE eZForum_ForumCategoryLink.CategoryID='$this->ID' AND eZForum_Forum.ID = eZForum_ForumCategoryLink.ForumID AND eZForum_Message.ForumID = eZForum_Forum.ID GROUP BY eZForum_ForumCategoryLink.ForumID ) as tmpForumTable ORDER BY ForumID asc";
217 }
218
219 $db->array_query( $forum_array, "$forumQuery" );
220
221 $ret = count($forum_array);
222 return $ret;
223 }
224
228 function addForum( $forum )
229 {
230 if ( is_a( $forum, "eZForum" ) )
231 {
232 $db =& eZDB::globalDatabase();
233
234 $forumID = $forum->id();
235 $db->begin( );
236
237 $db->lock( "eZForum_ForumCategoryLink" );
238 $nextID = $db->nextID( "eZForum_ForumCategoryLink", "ID" );
239
240 $res = $db->query( "INSERT INTO
241 eZForum_ForumCategoryLink
242 ( ID, CategoryID, ForumID )
243 VALUES
244 ( '$nextID', '$this->ID', '$forumID' )" );
245 $db->unlock();
246
247 if ( $res == false )
248 $db->rollback( );
249 else
250 $db->commit();
251
252 $ret = array();
253 }
254 }
255
256
260 function getAllCategories()
261 {
262 $db =& eZDB::globalDatabase();
263 $ini = eZINI::instance( 'site.ini' );
264 $ExcludeFeatureForums = $ini->variable( "eZForumMain", "ExcludeFeatureForums" );
265 // $ExcludeFeatureForums = $ini->variable( "eZForumMain", "ExcludeFeatureForums" );
266 // consider : (Array of IDS to loop over to exclude instead of static code
267
268 if ( $ExcludeFeatureForums == "enabled" ) {
269 // $exclude = "WHERE ID != 1000 AND ID != 6 AND ID !=5;";
270 $exclude = "WHERE ID != 1000 AND ID != 6";
271 } else {
272 $exclude = "";
273 }
274
275 $db->array_query( $category_array, "SELECT ID FROM eZForum_Category $exclude" );
276 $ret = array();
277 foreach ( $category_array as $category )
278 {
279 $ret[] = new eZForumCategory( $category[$db->fieldName("ID")] );
280 }
281 return $ret;
282 }
283
284 /*
285 Returns the object id.
286 */
287 function id()
288 {
289 return $this->ID;
290 }
291
295 function setName( $newName )
296 {
297 $this->Name = $newName;
298 }
299
303 function setSectionID( $value )
304 {
305 $this->SectionID = $value;
306 }
307
311 function sectionID()
312 {
313 return $this->SectionID;
314 }
315
320 static public function sectionIDStatic( $categoryID )
321 {
322 $db =& eZDB::globalDatabase();
323 $db->query_single( $res, "SELECT SectionID from eZForum_Category WHERE ID='$categoryID'");
324
325 if( is_array( $res ) && count( $res ) > 0 )
326 $sectionID = $res[ (int) $db->fieldName("SectionID")];
327 else
328 $sectionID = 0;
329
330 if ( $sectionID > 0 )
331 return $sectionID;
332 else
333 return false;
334 }
335
339 function name()
340 {
341 if ( isset( $this->Name ) )
342 {
343 $this->Name = htmlspecialchars($this->Name);
344 return stripslashes ( $this->Name );
345 }
346 return $this->Name;
347 }
348
352 function setDescription( $newDescription )
353 {
354 $this->Description = $newDescription;
355 }
356
360 function description()
361 {
362 return htmlspecialchars( $this->Description );
363 }
364
365 var $ID;
366 var $Name;
367 var $Description;
368 var $IsPrivate;
369 var $SectionID;
370
371 }
372
373 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$forum
$forum
Definition: admin/forumlist.php:50
$forumList
$forumList
Definition: admin/forumlist.php:54
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZForumCategory
Definition: ezforumcategory.php:44
eZForumCategory\getAllCategories
getAllCategories()
Definition: ezforumcategory.php:260
eZForumCategory\__construct
__construct( $id="")
Definition: ezforumcategory.php:48
eZForumCategory\$IsPrivate
$IsPrivate
Definition: ezforumcategory.php:368
eZForumCategory\getAll
static getAll()
Definition: ezforumcategory.php:162
eZForumCategory\description
description()
Definition: ezforumcategory.php:360
eZForumCategory\store
store()
Definition: ezforumcategory.php:59
eZForumCategory\name
name()
Definition: ezforumcategory.php:339
eZForumCategory\forumCount
forumCount()
Definition: ezforumcategory.php:209
eZForumCategory\$Name
$Name
Definition: ezforumcategory.php:366
eZForumCategory\sectionIDStatic
static sectionIDStatic( $categoryID)
Definition: ezforumcategory.php:320
eZForumCategory\setDescription
setDescription( $newDescription)
Definition: ezforumcategory.php:352
eZForumCategory\$SectionID
$SectionID
Definition: ezforumcategory.php:369
eZForumCategory\sectionID
sectionID()
Definition: ezforumcategory.php:311
eZForumCategory\setSectionID
setSectionID( $value)
Definition: ezforumcategory.php:303
eZForumCategory\$Description
$Description
Definition: ezforumcategory.php:367
eZForumCategory\$ID
$ID
Definition: ezforumcategory.php:365
eZForumCategory\forums
forums( $offset=0, $limit=-1)
Definition: ezforumcategory.php:181
eZForumCategory\id
id()
Definition: ezforumcategory.php:287
eZForumCategory\addForum
addForum( $forum)
Definition: ezforumcategory.php:228
eZForumCategory\setName
setName( $newName)
Definition: ezforumcategory.php:295
eZForum
Definition: ezforum.php:44
$ini
$ini
Definition: classes/admin/linklist.php:64
$name
$name
Definition: companytypelist.php:194
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$limit
$limit
Definition: ezimagecatalogue/admin/imagelist.php:312
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
$offset
$offset
Definition: ezstats/admin/cron.php:51
$categoryID
else $categoryID
Definition: productview.php:66
Name
if($user) if(isset( $next) && $next)<?=isset($all_fields_error) &&$all_fields_error ?><?=isset($password_error) &&$password_error ?></p ><? endif;?>< form method="post">< table border="0" cellspacing="2" cellpadding="2" class="boxtext" style="font-size=13;">< tr >< td style="color:<?= isset( $error['first_name'] ) ?> First Name
Definition: step1.php:127
$category_array
$category_array
Definition: todoedit.php:604
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.