Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

eztopic.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: eztopic.php 9475 2002-04-25 11:42:50Z bf $
5 //
6 // Definition of eZTopic class
7 //
8 // Created on: <01-Jun-2001 12:03:53 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
36 // include_once( "classes/ezdb.php" );
37 // include_once( "ezarticle/classes/ezarticle.php" );
38
39
40 class eZTopic
41 {
45 function __construct( $id=-1 )
46 {
47 if ( $id != -1 )
48 {
49 $this->ID = $id;
50 $this->get( $this->ID );
51 }
52 }
53
57 function store()
58 {
59 $db =& eZDB::globalDatabase();
60
61 $db->begin( );
62
63 $name = $db->escapeString( $this->Name );
64 $description = $db->escapeString( $this->Description );
65
66 if ( !isset( $this->ID ) )
67 {
68 $db->lock( "eZArticle_Topic" );
69 $nextID = $db->nextID( "eZArticle_Topic", "ID" );
70
71 $timeStamp =& (new eZDateTime())->timeStamp( true );
72
73 $res = $db->query( "INSERT INTO eZArticle_Topic
74 ( ID, Name, Created, Description )
75 VALUES
76 ( '$nextID',
77 '$name',
78 '$timeStamp',
79 '$description' )
80 " );
81
82 $this->ID = $nextID;
83 }
84 else
85 {
86 $res = $db->query( "UPDATE eZArticle_Topic SET
87 Name='$name',
88 Created=Created,
89 Description='$description'
90 WHERE ID='$this->ID'" );
91 }
92
93 $db->unlock();
94
95 if ( $res == false )
96 $db->rollback( );
97 else
98 $db->commit();
99
100 return true;
101 }
102
106 function delete()
107 {
108 $db =& eZDB::globalDatabase();
109
110 if ( isset( $this->ID ) )
111 {
112 $db->query( "UPDATE eZArticle_Article SET TopicID=0 WHERE TopicID='$this->ID'" );
113 $db->query( "DELETE FROM eZArticle_Topic WHERE ID='$this->ID'" );
114
115 }
116
117 return true;
118 }
119
125 function get( $id=-1 )
126 {
127 $db =& eZDB::globalDatabase();
128
129 $ret = false;
130 if ( $id != "" )
131 {
132 $db->array_query( $author_array, "SELECT * FROM eZArticle_Topic WHERE ID='$id'" );
133 if( count( $author_array ) == 1 )
134 {
135 $this->ID =& $author_array[0][$db->fieldName("ID")];
136 $this->Name =& $author_array[0][$db->fieldName("Name")];
137 $this->Description =& $author_array[0][$db->fieldName("Description")];
138 $ret = true;
139 }
140 elseif( count( $author_array ) == 1 )
141 {
142 $this->ID = 0;
143 }
144 }
145 return $ret;
146 }
147
148
156 function &getByName( $name )
157 {
158 $db =& eZDB::globalDatabase();
159
160 $topic = new eZTopic();
161
162 $name = $db->fieldName( $name );
163
164 if( $name != "" )
165 {
166 $db->array_query( $author_array, "SELECT * FROM eZArticle_Topic WHERE Name='$name'" );
167
168 if( count( $author_array ) == 1 )
169 {
170 $topic = new eZTopic( $author_array[0][$db->fieldName("ID")] );
171 }
172 }
173
174 return $topic;
175 }
176
180 function &getAll( )
181 {
182 $db =& eZDB::globalDatabase();
183
184 $return_array = array();
185 $topic_array = array();
186
187
188 $db->array_query( $topic_array, "SELECT ID, Name FROM eZArticle_Topic
189 ORDER By Name" );
190
191 foreach ( $topic_array as $topic )
192 {
193 $return_array[] = new eZTopic( $topic[$db->fieldName("ID")] );
194 }
195 return $return_array;
196 }
197
201 function &articles( )
202 {
203 $db =& eZDB::globalDatabase();
204
205 $return_array = array();
206 $article_array = array();
207
208
209 $ExcludeCategories = "";
210
211 $return_array = array();
212 $article_array = array();
213
214 $user =& eZUser::currentUser();
215 $currentUserSQL = "";
216 $groupSQL = "";
217 $usePermission = true;
218 if ( $user )
219 {
220 $groups =& $user->groups( false );
221
222 foreach ( $groups as $group )
223 {
224 $groupSQL .= " ( Permission.GroupID='$group' AND CategoryPermission.GroupID='$group' ) OR
225 ( Permission.GroupID='$group' AND CategoryPermission.GroupID='-1' ) OR
226 ( Permission.GroupID='-1' AND CategoryPermission.GroupID='$group' ) OR
227 ";
228 }
229 $currentUserID = $user->id();
230 $currentUserSQL = "Article.AuthorID=$currentUserID OR";
231
232 if ( $user->hasRootAccess() )
233 $usePermission = false;
234 }
235 $loggedInSQL = "( $currentUserSQL ( ( $groupSQL Permission.GroupID='-1' AND CategoryPermission.GroupID='-1' ) AND Permission.ReadPermission='1' AND CategoryPermission.ReadPermission='1' ) ) ";
236
237 if ( $usePermission )
238 $permissionSQL = $loggedInSQL;
239 else
240 $permissionSQL = "";
241
242 $excludeSQL = " AND Category.ExcludeFromSearch = '0'";
243
244 // fetch only published articles
245 if ( $fetchNonPublished == true )
246 {
247 $excludeSQL = "";
248 if ( $permissionSQL == "" )
249 $publishedSQL = " Article.IsPublished = '0' AND ";
250 else
251 $publishedSQL = " AND Article.IsPublished = '0' AND ";
252 }
253 // fetch only non-published articles
254 else
255 {
256 if ( $permissionSQL == "" )
257 $publishedSQL = " Article.IsPublished = '1' AND ";
258 else
259 $publishedSQL = " AND Article.IsPublished = '1' AND ";
260 }
261
262 // fetch only published articles
263 if ( $fetchNonPublished == "pending" )
264 {
265 if ( $permissionSQL == "" )
266 $publishedSQL = " Article.IsPublished = '2' AND ";
267 else
268 $publishedSQL = " AND Article.IsPublished = '2' AND ";
269 }
270
271
272 if ($ExcludeCategories && $ExcludeCategories<>"") $excludeSQL .= " AND Category.ID NOT IN (".$ExcludeCategories.")";
273
274 $query = "SELECT Article.ID as ID
275 FROM eZArticle_ArticleCategoryDefinition as Definition,
276 eZArticle_Article AS Article,
277 eZArticle_ArticleCategoryLink as Link,
278 eZArticle_ArticlePermission AS Permission,
279 eZArticle_CategoryPermission as CategoryPermission,
280 eZArticle_Category AS Category
281 WHERE TopicID='$this->ID' AND
282 $permissionSQL
283 $publishedSQL
284 Permission.ObjectID=Article.ID
285 AND Link.ArticleID=Article.ID
286 AND Category.ID=Link.CategoryID
287 $excludeSQL
288 AND Definition.ArticleID=Article.ID
289 AND CategoryPermission.ObjectID=Definition.CategoryID
290 GROUP BY Article.ID, Article.IsPublished ORDER BY Article.Name";
291
292 $db->array_query( $article_array, $query );
293
294 foreach ( $article_array as $article )
295 {
296 $return_array[] = new eZArticle( $article[$db->fieldName("ID")] );
297 }
298 return $return_array;
299 }
300
304 function id()
305 {
306 return $this->ID;
307 }
308
312 function name( $html = true )
313 {
314 if( $html && isset( $this->Name ) )
315 return htmlspecialchars( $this->Name );
316 return $this->Name;
317 }
318
319
323 function description( )
324 {
325 return $this->Description;
326 }
327
331 function setName( $value )
332 {
333 $this->Name = $value;
334 }
335
339 function setDescription( $value )
340 {
341 $this->Description = $value;
342 }
343
344 var $ID;
345 var $Name;
346 var $Description;
347 }
348
349 ?>
$topic
foreach( $authorArray as $author) $topic
Definition: admin/articleedit.php:852
$group
$group
Definition: admin/articleedit.php:799
$article
$article
Definition: articlelog.php:45
eZArticle
Definition: ezarticle.php:82
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZDateTime
Definition: ezdatetime.php:55
eZTopic
Definition: eztopic.php:41
eZTopic\store
store()
Definition: eztopic.php:57
eZTopic\name
name( $html=true)
Definition: eztopic.php:312
eZTopic\$Description
$Description
Definition: eztopic.php:346
eZTopic\getAll
& getAll()
Definition: eztopic.php:180
eZTopic\getByName
& getByName( $name)
Definition: eztopic.php:156
eZTopic\articles
& articles()
Definition: eztopic.php:201
eZTopic\$Name
$Name
Definition: eztopic.php:345
eZTopic\setDescription
setDescription( $value)
Definition: eztopic.php:339
eZTopic\__construct
__construct( $id=-1)
Definition: eztopic.php:45
eZTopic\description
description()
Definition: eztopic.php:323
eZTopic\setName
setName( $value)
Definition: eztopic.php:331
eZTopic\id
id()
Definition: eztopic.php:304
eZTopic\$ID
$ID
Definition: eztopic.php:344
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$name
$name
Definition: companytypelist.php:194
$id
$id
Definition: companytypelist.php:193
$query
if(isset( $Year) &&!is_numeric( $Year)||isset( $Month) &&!is_numeric( $Month)) $query
Definition: entryexitpages.php:65
$db
$db
Definition: ezarticle/user/authorlist.php:53
$groups
if( $CategoryID !=0) $groups
Definition: ezbulkmail/admin/categoryedit.php:108
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
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
$currentUserID
$currentUserID
Definition: todolist.php:128
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.