Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

user/message.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: message.php 9518 2002-05-08 11:51:36Z vl $
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 $Language = $ini->variable( "eZForumMain", "Language" );
31 $NewMessageLimit = $ini->variable( "eZForumMain", "NewMessageLimit" );
32 $AllowHTML = $ini->variable( "eZForumMain", "AllowHTML" );
33
34 // include_once( "classes/ezlocale.php" );
35 // include_once( "classes/eztexttool.php" );
36 // include_once( "classes/eztemplate.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 $locale = new eZLocale( $Language );
43
44 $t = new eZTemplate( "kernel/ezforum/user/" . $ini->variable( "eZForumMain", "TemplateDir" ),
45 "kernel/ezforum/user/intl", $Language, "message.php" );
46 $t->setAllStrings();
47
48 $t->set_file( "message_tpl", "message.tpl" );
49
50 $t->set_block( "message_tpl", "message_body_tpl", "message_body" );
51 $t->set_block( "message_tpl", "message_error_tpl", "message_error" );
52 $t->set_block( "message_body_tpl", "header_list_tpl", "header_list" );
53 $t->set_block( "message_body_tpl", "message_item_tpl", "message_item" );
54 $t->set_block( "message_body_tpl", "edit_current_message_item_tpl", "edit_current_message_item" );
55 $t->set_block( "message_body_tpl", "private_message_tpl", "private_message" );
56 $t->set_block( "message_item_tpl", "edit_message_item_tpl", "edit_message_item" );
57
58 $t->set_block( "message_item_tpl", "new_icon_tpl", "new_icon" );
59 $t->set_block( "message_item_tpl", "old_icon_tpl", "old_icon" );
60 $t->set_block( "message_item_tpl", "item_private_message_tpl", "item_private_message" );
61
62 $t->set_var( "private_message", "" );
63 $t->set_var( "header_list", "" );
64 $t->set_var( "edit_current_message_item", "" );
65
66 $message = new eZForumMessage( $MessageID );
67
68 $forum = new eZForum( $message->forumID() );
69
70 $group =& $forum->group();
71 $viewer = $user;
72 if ( ( is_a( $group, "eZUserGroup" ) ) && ( $group->id() != 0 ) )
73 {
74 if ( is_a( $viewer, "eZUser" ) )
75 {
76 $groupList =& $viewer->groups();
77
78 foreach ( $groupList as $userGroup )
79 {
80 if ( $userGroup->id() == $group->id() )
81 {
82 $readPermission = true;
83 break;
84 }
85 }
86 }
87 }
88 else
89 {
90 $readPermission = true;
91 }
92
93 $categories = $forum->categories();
94
95 if ( count( $categories ) > 0 )
96 {
97 $category = new eZForumCategory( $categories[0]->id() );
98
99 $t->set_var( "category_id", $category->id() );
100 $t->set_var( "category_name", $category->name() );
101
102 $t->parse( "header_list", "header_list_tpl" );
103
104 // sections
105 // include_once( "ezsitemanager/classes/ezsection.php" );
106
107 $GlobalSectionID = eZForumCategory::sectionIDStatic( $category->id( ) );
108
109 // init the section
110 $sectionObject =& eZSection::globalSectionObject( $GlobalSectionID );
111 $sectionObject->setOverrideVariables();
112 }
113
114 $t->set_var( "forum_id", $forum->id() );
115 $t->set_var( "forum_name", $forum->name() );
116
117 $t->set_var( "message_id", $message->id() );
118 $t->set_var( "message_topic", $message->topic() );
119
120 $t->set_var( "topic", $message->topic() );
121
122 $author = $message->user();
123
124 if ( $message->userName() )
125 $anonymous = $message->userName();
126 else
127 $anonymous = $ini->variable( "eZForumMain", "AnonymousPoster" );
128
129 if ( $author->id() == 0 )
130 {
131 $MessageAuthor = $anonymous;
132 }
133 else
134 {
135 $MessageAuthor = $author->firstName() . " " . $author->lastName();
136 }
137
138 if ( $author->firstName()== "" && $author->lastName()=="" )
139 $MessageAuthor = $anonymous;
140
141 $t->set_var( "main-user", $MessageAuthor );
142
143
144 $user =& eZUser::currentUser();
145 if ( ( $MessageAuthor != $anonymous) and ($user) )
146 {
147 // $user = new eZUser();
148 // $user->get( $author->id() );
149 $t->set_var( "username", $author->login() );
150 $t->set_var( "PM_topic", urlencode (": ".$message->topic() ) );
151 $t->set_var( "topic", $message->topic() );
152 $t->parse( "private_message", "private_message_tpl" );
153 }
154
155
156 $time = $message->postingTime();
157 $t->set_var( "main-postingtime", $locale->format( $time ) );
158 $t->set_var( "body", eZTextTool::nl2br( $message->body() ) );
159
160 $t->set_var( "reply_id", $message->id() );
161 $t->set_var( "forum_id", $forum->id() );
162
163 if ( is_a( $viewer, "eZUser" ) )
164 {
165 if ( $viewer->id() == $message->userId() && eZForumMessage::countReplies( $message->id() ) == 0 )
166 {
167 $t->parse( "edit_current_message_item", "edit_current_message_item_tpl" );
168 }
169 }
170
171 $topMessage = $message->threadTop( $message );
172
173 // print out the replies tree
174
175 $messages = $forum->messageThreadTree( $message->threadID() );
176
177 // $messages = $forum->messages();
178
179 $level = 0;
180
181 $i = 0;
182
183 foreach ( $messages as $threadmessage )
184 {
185 $t->set_var( "edit_message_item", "" );
186 if ( ( $i % 2 ) == 0 )
187 {
188 $t->set_var( "td_class", "bglight" );
189 $t->set_var( "td_alt", "1" );
190 }
191 else
192 {
193 $t->set_var( "td_class", "bgdark" );
194 $t->set_var( "td_alt", "2" );
195 }
196
197 $level = $threadmessage->depth();
198
199 if ( $threadmessage->id() == $MessageID )
200 {
201 $t->set_var( "link_color", "linkselect" );
202 $t->set_var( "td_class", "bgselect" );
203 }
204 else
205 {
206 $t->set_var( "link_color", "linknormal" );
207 }
208
209 if ( $level > 0 )
210 $t->set_var( "spacer", str_repeat( "&nbsp;", $level ) );
211 else
212 $t->set_var( "spacer", "" );
213
214 $t->set_var( "reply_id", $threadmessage->id() );
215 $t->set_var( "reply_topic", $threadmessage->topic() );
216
217 if ( $AllowHTML == "enabled" )
218 $t->set_var( "reply_body", eZTextTool::nl2br( $threadmessage->body( true ) ) );
219 else
220 $t->set_var( "reply_body", eZTextTool::nl2br( $threadmessage->body( false ) ) );
221
222 $messageAge = round( $threadmessage->age() / 86400 );
223 if ( $messageAge <= $NewMessageLimit )
224 {
225 $t->parse( "new_icon", "new_icon_tpl" );
226 $t->set_var( "old_icon", "" );
227 }
228 else
229 {
230 $t->parse( "old_icon", "old_icon_tpl" );
231 $t->set_var( "new_icon", "" );
232 }
233
234 $time = $threadmessage->postingTime();
235
236 $t->set_var( "postingtime", $locale->format( $time ) );
237 $t->set_var( "message_id", $threadmessage->id() );
238
239 $author = $threadmessage->user();
240
241 if ( $author->id() == 0 )
242 {
243 if ( $threadmessage->userName() )
244 $MessageAuthor = $threadmessage->userName();
245 else
246 $MessageAuthor = $anonymous;
247 }
248 else
249 {
250 $MessageAuthor = $author->firstName() . " " . $author->lastName();
251 }
252
253 if ( $author->firstName()== "" && $author->lastName()=="" )
254 $MessageAuthor = $anonymous;
255
256 $t->set_var( "user", $MessageAuthor );
257
258 // $currentUser =& eZUser::currentUser();
259 if ( ( $MessageAuthor != $anonymous) and ($user) )
260 {
261 // $user = new eZUser();
262 // $user->get( $author->id() );
263 $t->set_var( "username", $author->login() );
264 $t->set_var( "PM_topic", urlencode (": ".$message->topic() ) );
265 $t->parse( "item_private_message", "item_private_message_tpl" );
266 }
267 else
268 {
269 $t->set_var( "item_private_message", "" );
270 }
271
272 // unset( $user );
273
274 /*
275 if ( get_class( $viewer ) == "ezuser" )
276 {
277 if ( ( $viewer->id() == $threadmessage->userId() ) && ( eZForumMessage::countReplies( $threadmessage->id() ) == 0 ) )
278 {
279 $t->parse( "edit_message_item", "edit_message_item_tpl" );
280 }
281 }
282 */
283
284 $t->parse( "message_item", "message_item_tpl", true );
285 $i++;
286 }
287
288 if ( !isset( $RedirectURL ) )
289 $RedirectURL = "";
290
291 $t->set_var( "redirect_url", eZTextTool::htmlspecialchars( $RedirectURL ) );
292 if ( $message->id() > 0 && !$message->isTemporary() && $message->isApproved() )
293 {
294 $t->parse( "message_body", "message_body_tpl" );
295 $t->set_var( "message_error", "" );
296 }
297 else
298 {
299 $t->set_var( "message_body", "" );
300 $t->parse( "message_error", "message_error_tpl" );
301 }
302
303 if ( $readPermission )
304 $t->pparse( "output", "message_tpl" );
305
306 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$groupList
$groupList
Definition: admin/articleedit.php:800
$sectionObject
$sectionObject
Definition: articleheaderlist.php:49
eZForumCategory
Definition: ezforumcategory.php:44
eZForumCategory\sectionIDStatic
static sectionIDStatic( $categoryID)
Definition: ezforumcategory.php:320
eZForumMessage
Definition: ezforummessage.php:42
eZForumMessage\countReplies
static countReplies( $ID)
Definition: ezforummessage.php:799
eZForum
Definition: ezforum.php:44
eZLocale
Definition: ezlocale.php:119
eZSection\globalSectionObject
static & globalSectionObject( $sectionID)
Definition: ezsection.php:366
eZTemplate
Definition: eztemplate.php:107
eZTextTool\htmlspecialchars
static htmlspecialchars( $string)
Definition: eztexttool.php:144
eZTextTool\nl2br
static nl2br( $string, $xhtml=true)
Definition: eztexttool.php:65
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$GlobalSectionID
$GlobalSectionID
Definition: ezad/user/datasupplier.php:28
$RedirectURL
$RedirectURL
Definition: ezforum/user/userlogin.php:91
$AllowHTML
$AllowHTML
Definition: user/message.php:32
$viewer
$viewer
Definition: user/message.php:71
$messages
$messages
Definition: user/message.php:175
$locale
$locale
Definition: user/message.php:42
$t
$t
Definition: user/message.php:44
$NewMessageLimit
$NewMessageLimit
Definition: user/message.php:31
$forum
$forum
Definition: user/message.php:68
$user
$user
Definition: user/message.php:144
$time
if(( $MessageAuthor !=$anonymous) and($user)) $time
Definition: user/message.php:156
$i
$i
Definition: user/message.php:181
$Language
$Language
Definition: user/message.php:30
$ini
$ini
Definition: user/message.php:29
$level
$level
Definition: user/message.php:179
$message
$message
Definition: user/message.php:66
$author
$author
Definition: user/message.php:122
$anonymous
else $anonymous
Definition: user/message.php:127
$group
$group
Definition: user/message.php:70
$topMessage
if(is_a( $viewer, "eZUser")) $topMessage
Definition: user/message.php:171
$categories
$categories
Definition: user/message.php:93
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.