Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezgroupeventcategory.php
Go to the documentation of this file.
1 <?
3 //
4 // Definition of eZGroupEventCategory class
5 //
6 // Graham Brookins <info@brookinsconsulting.com>
7 // Created on: <3-Oct-2001 14:36:00>
8 // By: Adam Fallert <FallertA@umsystem.edu>
9 //
10 //
11 // This program is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU General Public License
13 // as published by the Free Software Foundation; either version 2
14 // of the License, or (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
24 //
25
28
36 // include_once( "classes/ezdb.php" );
37
38 class eZGroupEventCategory
39 {
46 function __construct( $id=-1, $fetch=true )
47 {
48 $this->IsConnected = false;
49
50 if ( $id != -1 )
51 {
52 $this->ID = $id;
53 $this->get( $this->ID );
54 $this->State_ = "Coherent";
55 }
56 else
57 {
58 $this->State_ = "New";
59 }
60 }
61
65 function store()
66 {
67 $this->dbInit();
68
69 if ( !isset( $this->ID ) )
70 {
71 $this->Database->query( "INSERT INTO eZGroupEventCalendar_EventCategory SET
72 Name='$this->Name',
73 Description='$this->Description',
74 ParentID='$this->ParentID'" );
75 $this->ID = mysql_insert_id();
76 }
77 else
78 {
79 $this->Database->query( "UPDATE eZGroupEventCalendar_EventCategory SET
80 Name='$this->Name',
81 Description='$this->Description',
82 ParentID='$this->ParentID' WHERE ID='$this->ID'" );
83 }
84
85 return true;
86 }
87
92 function delete()
93 {
94 $this->dbInit();
95
96 if ( isset( $this->ID ) )
97 {
98 $this->Database->query( "DELETE FROM eZGroupEventCalendar_EventCategory WHERE ID='$this->ID'" );
99 }
100
101 return true;
102 }
103
107 function get( $id=-1 )
108 {
109 $this->dbInit();
110
111 if ( $id != "" )
112 {
113 $this->Database->array_query( $EventCategory_array, "SELECT * FROM eZGroupEventCalendar_EventCategory WHERE ID='$id'" );
114 if ( count( $EventCategory_array ) > 1 )
115 {
116 die( "Error: EventCategory's with the same ID was found in the database. This shouldent happen." );
117 }
118 else if( count( $EventCategory_array ) == 1 )
119 {
120 $this->ID = $EventCategory_array[0][ "ID" ];
121 $this->Name = $EventCategory_array[0][ "Name" ];
122 $this->Description = $EventCategory_array[0][ "Description" ];
123 $this->ParentID = $EventCategory_array[0][ "ParentID" ];
124 $this->ExcludeFromSearch = $EventCategory_array[0][ "ExcludeFromSearch" ];
125 }
126
127 $this->State_ = "Coherent";
128 }
129 else
130 {
131 $this->State_ = "Dirty";
132 }
133 }
134
140 function &getAll()
141 {
142 $this->dbInit();
143
144 $return_array = array();
145 $EventCategory_array = array();
146
147 $this->Database->array_query( $EventCategory_array, "SELECT ID FROM eZGroupEventCalendar_EventCategory ORDER BY Name" );
148
149 for ( $i=0; $i<count($EventCategory_array); $i++ )
150 {
151 $return_array[$i] = new eZGroupEventCategory( $EventCategory_array[$i]["ID"], 0 );
152 }
153
154 return $return_array;
155 }
156
165 function &getByParent( $parent, $showAll=false, $sortby="name" )
166 {
167 if ( is_a( $parent, "eZGroupEventCategory" ) )
168 {
169 $this->dbInit();
170
171 $return_array = array();
172 $eventcategory_array = array();
173
174 $parentID = $parent->id();
175
176
177 if ( $showAll == true )
178 {
179 $this->Database->array_query( $eventcategory_array, "SELECT ID, Name FROM eZGroupEventCalendar_EventCategory
180 WHERE ParentID='$parentID'
181 ORDER BY Name" );
182 }
183 else
184 {
185 $this->Database->array_query( $eventcategory_array, "SELECT ID, Name FROM eZGroupEventCalendar_EventCategory
186 WHERE ParentID='$parentID' AND ExcludeFromSearch='1'
187 ORDER BY Name" );
188 }
189
190 for ( $i=0; $i<count($eventcategory_array); $i++ )
191 {
192 $return_array[$i] = new eZGroupEventCategory( $eventcategory_array[$i]["ID"], 0 );
193 }
194
195 return $return_array;
196 }
197 else
198 {
199 return 0;
200 }
201 }
202
210 function path( $EventCategoryID=0 )
211 {
212 if ( $EventCategoryID == 0 )
213 {
214 $EventCategoryID = $this->ID;
215 }
216
217 $EventCategory = new eZGroupEventCategory( $EventCategoryID );
218
219 $path = array();
220
221 $parent = $EventCategory->parent();
222
223 if ( $parent != 0 )
224 {
225 $path = array_merge( $path, $this->path( $parent->id() ) );
226 }
227 else
228 {
229 // array_push( $path, $EventCategory->name() );
230 }
231
232 if ( $EventCategoryID != 0 )
233 array_push( $path, array( $EventCategory->id(), $EventCategory->name() ) );
234
235 return $path;
236 }
237
241 function &getTree( $parentID=0, $level=0 )
242 {
243
244 $EventCategory = new eZGroupEventCategory( $parentID );
245
246 $EventCategoryList =& $EventCategory->getByParent( $EventCategory, true );
247
248 $tree = array();
249 $level++;
250 foreach ( $EventCategoryList as $EventCategory )
251 {
252 array_push( $tree, array( $return_array[] = new eZGroupEventCategory( $EventCategory->id() ), $level ) );
253
254 if ( $EventCategory != 0 )
255 {
256 $tree = array_merge( $tree, $this->getTree( $EventCategory->id(), $level ) );
257 }
258 }
259
260 return $tree;
261 }
262
266 function id()
267 {
268 return $this->ID;
269 }
270
274 function name( $htmlchars=true )
275 {
276 if ( $htmlchars == true && !is_null( $this->Name ) )
277 {
278 return htmlspecialchars( $this->Name );
279 }
280 else
281 {
282 return $this->Name;
283 }
284 }
285
289 function description( $htmlchars=true )
290 {
291 if ( $htmlchars == true )
292 {
293 return htmlspecialchars( $this->Description );
294 }
295 else
296 {
297 return $this->Description;
298 }
299 }
300
304 function parentID()
305 {
306 return $this->ParentID;
307 }
308
312 function parent()
313 {
314 if ( $this->ParentID != 0 )
315 {
316 return new eZGroupEventCategory( $this->ParentID );
317 }
318 else
319 {
320 return 0;
321 }
322 }
323
327 function setName( $value )
328 {
329 if ( $this->State_ == "Dirty" )
330 $this->get( $this->ID );
331
332 $this->Name = $value;
333 }
334
338 function setDescription( $value )
339 {
340 $this->Description = $value;
341 }
342
346 function setParent( $value )
347 {
348 if ( get_class( $value ) == "ezgroupeventcategory" )
349 {
350 $this->ParentID = $value->id();
351 }
352 }
353
358 function dbInit()
359 {
360 if ( $this->IsConnected == false )
361 {
362 $this->Database = eZDB::globalDatabase();
363 $this->IsConnected = true;
364 }
365 }
366
367 var $ID;
368 var $Name;
369 var $ParentID;
370 var $Description;
371
373 var $Database;
374
376 var $State_;
378 var $IsConnected;
379 var $ExcludeFromSearch; // 0 = false, 1 = true, default is false
380 }
381
382 ?>
383
$i
$i
Definition: admin/adlist.php:91
$level
$level
Definition: admin/message.php:106
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZGroupEventCategory
Definition: ezgroupeventcategory.php:39
eZGroupEventCategory\$ID
$ID
Definition: ezgroupeventcategory.php:367
eZGroupEventCategory\$Database
$Database
Variable for keeping the database connection.
Definition: ezgroupeventcategory.php:373
eZGroupEventCategory\setParent
setParent( $value)
Definition: ezgroupeventcategory.php:346
eZGroupEventCategory\__construct
__construct( $id=-1, $fetch=true)
Definition: ezgroupeventcategory.php:46
eZGroupEventCategory\$ExcludeFromSearch
$ExcludeFromSearch
Definition: ezgroupeventcategory.php:379
eZGroupEventCategory\name
name( $htmlchars=true)
Definition: ezgroupeventcategory.php:274
eZGroupEventCategory\setDescription
setDescription( $value)
Definition: ezgroupeventcategory.php:338
eZGroupEventCategory\description
description( $htmlchars=true)
Definition: ezgroupeventcategory.php:289
eZGroupEventCategory\path
path( $EventCategoryID=0)
Definition: ezgroupeventcategory.php:210
eZGroupEventCategory\getByParent
& getByParent( $parent, $showAll=false, $sortby="name")
Definition: ezgroupeventcategory.php:165
eZGroupEventCategory\getAll
& getAll()
Definition: ezgroupeventcategory.php:140
eZGroupEventCategory\parentID
parentID()
Definition: ezgroupeventcategory.php:304
eZGroupEventCategory\store
store()
Definition: ezgroupeventcategory.php:65
eZGroupEventCategory\parent
parent()
Definition: ezgroupeventcategory.php:312
eZGroupEventCategory\setName
setName( $value)
Definition: ezgroupeventcategory.php:327
eZGroupEventCategory\$Description
$Description
Definition: ezgroupeventcategory.php:370
eZGroupEventCategory\$Name
$Name
Definition: ezgroupeventcategory.php:368
eZGroupEventCategory\id
id()
Definition: ezgroupeventcategory.php:266
eZGroupEventCategory\$State_
$State_
Indicates the state of the object. In regard to database information.
Definition: ezgroupeventcategory.php:376
eZGroupEventCategory\getTree
& getTree( $parentID=0, $level=0)
Definition: ezgroupeventcategory.php:241
eZGroupEventCategory\$ParentID
$ParentID
Definition: ezgroupeventcategory.php:369
eZGroupEventCategory\$IsConnected
$IsConnected
Is true if the object has database connection, false if not.
Definition: ezgroupeventcategory.php:378
eZGroupEventCategory\dbInit
dbInit()
Definition: ezgroupeventcategory.php:358
$id
$id
Definition: companytypelist.php:193
$tree
$tree
Definition: ezad/admin/categoryedit.php:172
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
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.