Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezforum/user/messagelist.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: messagelist.php 9550 2002-05-21 09:19:02Z jhe $
5 //
6 // Created on: <11-Sep-2000 22:10:06 bf>
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
29 $ini =& eZINI::instance( 'site.ini' );
30
31 // include_once( "classes/eztemplate.php" );
32 // include_once( "classes/ezlocale.php" );
33 // include_once( "classes/ezdatetime.php" );
34 // include_once( "classes/ezlist.php" );
35 // include_once( "ezsession/classes/ezpreferences.php" );
36 // include_once( "ezuser/classes/ezuser.php" );
37
38 // include_once( "ezforum/classes/ezforummessage.php" );
39 // include_once( "ezforum/classes/ezforumcategory.php" );
40 // include_once( "ezforum/classes/ezforum.php" );
41
42 $Language = $ini->variable( "eZForumMain", "Language" );
43 $NewMessageLimit = $ini->variable( "eZForumMain", "NewMessageLimit" );
44 // include_once( "ezsection/classes/ezsection.php" );
45 $t = new eZTemplate( "kernel/ezforum/user/" . $ini->variable( "eZForumMain", "TemplateDir" ),
46 "kernel/ezforum/user/intl", $Language, "messagelist.php" );
47
48 $languageIni = new eZINI( "kernel/ezforum/user/intl/" . $Language . "/messagelist.php.ini", false );
49 $t->set_file( "messagelist", "messagelist.tpl" );
50
51 $t->set_block( "messagelist", "header_list_tpl", "header_list" );
52 $t->set_block( "messagelist", "read_access_tpl", "read_access" );
53 $t->set_block( "messagelist", "no_access_tpl", "no_access" );
54
55 $t->set_block( "read_access_tpl", "message_item_tpl", "message_item" );
56 $t->set_block( "message_item_tpl", "edit_message_item_tpl", "edit_message_item" );
57 $t->set_block( "read_access_tpl", "previous_tpl", "previous" );
58
59 $t->set_block( "message_item_tpl", "new_icon_tpl", "new_icon" );
60 $t->set_block( "message_item_tpl", "old_icon_tpl", "old_icon" );
61 $t->set_block( "message_item_tpl", "private_message_tpl", "private_message" );
62
63
64 $t->set_block( "read_access_tpl", "messages_element_tpl", "messages_element" );
65 $t->set_block( "read_access_tpl", "show_threads_tpl", "show_threads" );
66 $t->set_block( "read_access_tpl", "hide_threads_tpl", "hide_threads" );
67
68 //$t->set_var( "header_list", "" );
69 $t->setAllStrings();
70
71 $session =& eZSession::globalSession();
72 $session->fetch();
73
74 $user =& eZUser::currentUser();
75
76 if ( isset( $ForumMessages ) )
77 {
78 if ( $user )
79 eZPreferences::setVariable( "eZForum_ForumMessages", $ForumMessages );
80 else
81 $session->setVariable( "eZForum_ForumMessages", $ForumMessages );
82 $UserLimit = $ForumMessages;
83 }
84 else
85 {
86 if ( $user )
87 {
88 if ( eZPreferences::variable( "eZForum_ForumMessages" ) )
89 $UserLimit = eZPreferences::variable( "eZForum_ForumMessages" );
90 else
91 $UserLimit = $ini->variable( "eZForumMain", "MessageUserLimit" );
92 }
93 else
94 {
95 if ( $session->variable( "eZForum_ForumMessages" ) )
96 $UserLimit = $session->variable( "eZForum_ForumMessages" );
97 else
98 {
99 $UserLimit = $ini->variable( "eZForumMain", "MessageUserLimit" );
100 $session->setVariable( "eZForum_ForumMessages", $UserLimit );
101 }
102 }
103 }
104 $forum = new eZForum( $ForumID );
105
106 $categories =& $forum->categories();
107
108
109 if ( $user )
110 {
111 $preferences = new eZPreferences();
112 if ( isset( $HideThreads ) )
113 $preferences->setVariable( "eZForum_Threads", "Hide" );
114
115 if ( isset( $ShowThreads ) )
116 $preferences->setVariable( "eZForum_Threads", "Show" );
117
118 $showThreads =& $preferences->variable( "eZForum_Threads" );
119 }
120 else
121 {
122 $session =& eZSession::globalSession();
123
124 if ( isset( $HideThreads ) )
125 $session->setVariable( "eZForum_Threads", "Hide" );
126
127 if ( isset( $ShowThreads ) )
128 $session->setVariable( "eZForum_Threads", "Show" );
129
130 $showThreads = $session->variable( "eZForum_Threads" );
131 }
132
133 if ( $showThreads == "" )
134 $showThreads = "Hide";
135
136 $group =& $forum->group();
137 $viewer = $user;
138
139 if ( is_a( $group, "eZUserGroup" ) )
140 {
141 if ( is_a( $viewer, "eZUser" ) )
142 {
143 $groupList =& $viewer->groups();
144 foreach ( $groupList as $userGroup )
145 {
146 if ( $userGroup->id() == $group->id() )
147 {
148 $readPermission = true;
149 break;
150 }
151 }
152 }
153 }
154 else
155 {
156 $readPermission = true;
157 }
158
159 if ( count( $categories ) > 0 )
160 {
161 $category = new eZForumCategory( $categories[0]->id() );
162
163 $t->set_var( "category_id", $category->id( ) );
164 $t->set_var( "category_name", $category->name( ) );
165
166 $t->parse( "header_list", "header_list_tpl" );
167
168 // sections
169 // include_once( "ezsitemanager/classes/ezsection.php" );
170
171 $GlobalSectionID = eZForumCategory::sectionIDStatic( $category->id() );
172
173 // init the section
174 $sectionObject =& eZSection::globalSectionObject( $GlobalSectionID );
175 $sectionObject->setOverrideVariables();
176
177 }
178
179 $locale = new eZLocale( $Language );
180
181 if ( !isset( $Offset ) or !$Offset )
182 $Offset = 0;
183
184 $limit_array = array_unique( array( 20, 30, 40, 50, 60, 80, 100, 150, 200, $UserLimit ) );
185 sort( $limit_array );
186
187 foreach ( $limit_array as $element_number )
188 {
189 $t->set_var( "messages_number", $element_number );
190 if ( $element_number == $UserLimit )
191 $t->set_var( "is_selected", "selected" );
192 else
193 $t->set_var( "is_selected", "" );
194 $t->parse( "messages_element", "messages_element_tpl", true );
195 }
196
197 $t->set_var( "offset", $Offset );
198
199 if ( $showThreads == "Hide" )
200 {
201 $t->set_var( "hide_threads", "" );
202 $t->parse( "show_threads", "show_threads_tpl" );
203 $messageList =& $forum->messageTreeArray( $Offset, $UserLimit, false, false );
204 $messageCount =& $forum->messageCount( false, false );
205 }
206 else if ( $showThreads == "Show" )
207 {
208 $t->set_var( "show_threads", "" );
209 $t->parse( "hide_threads", "hide_threads_tpl" );
210 $messageList =& $forum->messageTreeArray( $Offset, $UserLimit );
211 $messageCount =& $forum->messageCount( false, true );
212 }
213
214 if ( !$messageList )
215 {
216 $languageIni = new eZINI( "kernel/ezforum/user/intl/" . $Language . "/messagelist.php.ini", false );
217 $noitem = $languageIni->variable( "strings", "noitem" );
218
219 $t->set_var( "message_item", $noitem );
220 }
221 else
222 {
223 $db =& eZDB::globalDatabase();
224
225 $level = 0;
226 $i = 0;
227 $time = new eZDateTime();
228 foreach ( $messageList as $message )
229 {
230 unset( $author );
231 $author = new eZUser();
232 $t->set_var( "user", "" );
233 $t->set_var( "edit_message_item", "" );
234
235 if ( ( $i % 2 ) == 0 )
236 $t->set_var( "td_class", "bglight" );
237 else
238 $t->set_var( "td_class", "bgdark" );
239
240 $topic = htmlspecialchars( $message[$db->fieldName( "Topic" )]);
241 $t->set_var( "topic", stripslashes($topic) );
242
243 $time->setTimeStamp( $message[$db->fieldName( "PostingTime" )] );
244 $t->set_var( "postingtime", $locale->format( $time ) );
245
246 $t->set_var( "message_id", $message[$db->fieldName( "ID" )] );
247
248 $messageAge = round( $message[$db->fieldName( "Age" )] / 86400 );
249 if ( $messageAge <= $NewMessageLimit )
250 {
251 $t->parse( "new_icon", "new_icon_tpl" );
252 $t->set_var( "old_icon", "" );
253 }
254 else
255 {
256 $t->parse( "old_icon", "old_icon_tpl" );
257 $t->set_var( "new_icon", "" );
258 }
259
260 $userID = $message[$db->fieldName( "UserID" )];
261
262 $author->get( $userID );
263
264 if ( $showThreads == "Show" )
265 {
266 $t->set_var( "count_replies", "" );
267 $level = $message[$db->fieldName( "Depth" )];
268
269 if ( $level > 0 )
270 $t->set_var( "spacer", str_repeat( "&nbsp;", $level ) );
271 else
272 $t->set_var( "spacer", "" );
273 }
274 else if ( $showThreads == "Hide" )
275 {
276 $count = eZForumMessage::threadMessageCount( $message[$db->fieldName( "ThreadID" )] ) - 1;
277 $t->set_var( "spacer", "" );
278 $t->set_var( "count_replies", $count );
279 }
280
281 $anonymous = $ini->variable( "eZForumMain", "AnonymousPoster" );
282
283 if ( $author->id() == 0 )
284 {
285 if ( empty( $message[$db->fieldName( "UserName" )] ) ) {
286 $t->set_var( "user", $anonymous );
287 $messageAuthor = $anonymous;
288 }
289 else {
290 $t->set_var( "user", $message[$db->fieldName( "UserName" )] );
291 $messageAuthor = $message[$db->fieldName( "UserName" )];
292 }
293
294 $t->set_var( "author", $messageAuthor );
295 $t->set_var( "private_message", "" );
296 }
297 else
298 {
299 $messageAuthor = $author->firstName() . " " . $author->lastName();
300 $t->set_var( "user", $author->firstName() . " " . $author->lastName() );
301 if ( $author->firstName()== "" && $author->lastName()=="" )
302 $messageAuthor = $anonymous;
303
304 $t->set_var( "author", $messageAuthor );
305
306 $currentUser =& eZUser::currentUser();
307 $t->set_var( "private_message", "" );
308 if ( ( $messageAuthor != $anonymous) && ($currentUser) )
309 {
310 // $user = new eZUser();
311 // $user->get( $author->id() );
312 $t->set_var( "username", $author->login() );
313 $t->set_var( "PM_topic", urlencode(": ".$message[$db->fieldName( "Topic" )] ) );
314 // $t->set_var( "topic", $message->topic() );
315 $t->parse( "private_message", "private_message_tpl" );
316 }
317 }
318
319 /*
320 if ( get_class( $viewer ) == "ezuser" )
321 {
322 if ( $viewer->id() == $userID && eZForumMessage::countReplies( $message["ID"] ) == 0 && !$forum->IsModerated() )
323 {
324 $t->parse( "edit_message_item", "edit_message_item_tpl" );
325 }
326 }
327 */
328 $t->parse( "message_item", "message_item_tpl", true );
329 $i++;
330 }
331 }
332
333 unset( $user );
334
335 eZList::drawNavigator( $t, $messageCount, $UserLimit, $Offset, "read_access_tpl" );
336
337 $t->set_var( "forum_start", $Offset + 1 );
338 $t->set_var( "forum_end", min( $Offset + $UserLimit, $messageCount ) );
339 $t->set_var( "forum_total", $messageCount );
340
341 if ( !isset( $newmessage ) )
342 $newmessage = "";
343 $t->set_var( "newmessage", $newmessage );
344
345 $t->set_var( "forum_id", $forum->id() );
346 $t->set_var( "forum_name", $forum->name() );
347
348 if ( $readPermission )
349 {
350 $t->set_var( "no_access", "" );
351 $t->parse( "read_access", "read_access_tpl" );
352 }
353 else
354 {
355 $t->set_var( "read_access", "" );
356 $t->parse( "no_access", "no_access_tpl" );
357 }
358
359 $t->pparse( "output", "messagelist" );
360
361 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$topic
foreach( $authorArray as $author) $topic
Definition: admin/articleedit.php:852
$groupList
$groupList
Definition: admin/articleedit.php:800
$author
$author
Definition: admin/articleedit.php:834
$forum
$forum
Definition: admin/forumlist.php:50
$message
$message
Definition: admin/message.php:51
$anonymous
else $anonymous
Definition: admin/message.php:73
$userID
else $userID
Definition: appointmentedit.php:121
$sectionObject
$sectionObject
Definition: articleheaderlist.php:49
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZDateTime
Definition: ezdatetime.php:55
eZForumCategory
Definition: ezforumcategory.php:44
eZForumCategory\sectionIDStatic
static sectionIDStatic( $categoryID)
Definition: ezforumcategory.php:320
eZForumMessage\threadMessageCount
static threadMessageCount( $threadID)
Definition: ezforummessage.php:765
eZForum
Definition: ezforum.php:44
eZINI
Reads and writes .ini style configuration files.
eZList\drawNavigator
static drawNavigator(&$t, $total_types, $max_types, $index, $parent=false, $variables=false)
Definition: ezlist.php:401
eZLocale
Definition: ezlocale.php:119
eZPreferences
Definition: ezpreferences.php:62
eZPreferences\variable
static variable( $name, $group=false)
Definition: ezpreferences.php:95
eZPreferences\setVariable
static setVariable( $name, $value, $group=false)
Definition: ezpreferences.php:128
eZSection\globalSectionObject
static & globalSectionObject( $sectionID)
Definition: ezsection.php:366
eZSession\globalSession
static & globalSession( $id="", $fetch=true)
Definition: kernel/ezsession/classes/ezsession.php:614
eZTemplate
Definition: eztemplate.php:107
eZUser
Definition: ezuser.php:76
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$preferences
$preferences
Definition: classes/admin/linklist.php:186
$GlobalSectionID
$GlobalSectionID
Definition: ezad/user/datasupplier.php:28
$db
$db
Definition: ezarticle/user/authorlist.php:53
$Offset
$Offset
Definition: ezarticle/user/search.php:110
$UserLimit
$UserLimit
Definition: ezbug/user/search.php:41
$messageCount
$messageCount
Definition: ezforum/admin/messagelist.php:70
$viewer
$viewer
Definition: ezforum/user/messagelist.php:137
$languageIni
$languageIni
Definition: ezforum/user/messagelist.php:48
$t
$t
Definition: ezforum/user/messagelist.php:45
$NewMessageLimit
$NewMessageLimit
Definition: ezforum/user/messagelist.php:43
$showThreads
$showThreads
Definition: ezforum/user/messagelist.php:130
$limit_array
$limit_array
Definition: ezforum/user/messagelist.php:184
$user
$user
Definition: ezforum/user/messagelist.php:74
$time
$time
Definition: ezforum/user/messagelist.php:227
$locale
if(count( $categories) > 0) $locale
Definition: ezforum/user/messagelist.php:179
$i
$i
Definition: ezforum/user/messagelist.php:226
$Language
$Language
Definition: ezforum/user/messagelist.php:42
$ini
$ini
Definition: ezforum/user/messagelist.php:29
$level
$level
Definition: ezforum/user/messagelist.php:225
$session
$session
Definition: ezforum/user/messagelist.php:71
$group
$group
Definition: ezforum/user/messagelist.php:136
$categories
$categories
Definition: ezforum/user/messagelist.php:106
$messageList
$messageList
Definition: messagelistflat.php:103
$count
$count
Definition: onlinetypelist.php:108
$currentUser
$currentUser
Definition: surveyedit.php:54
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.