Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

bugreport.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: bugreport.php 9512 2002-05-08 09:16:58Z vl $
5 //
6 // Created on: <27-Nov-2000 20:31:00 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( "ezmail/classes/ezmail.php" );
28
29 // include_once( "classes/INIFile.php" );
30 // include_once( "classes/eztemplate.php" );
31 // include_once( "classes/ezlog.php" );
32 // include_once( "classes/ezhttptool.php" );
33 // include_once( "classes/eztexttool.php" );
34
35 // include_once( "ezimagecatalogue/classes/ezimage.php" );
36 // include_once( "ezfilemanager/classes/ezvirtualfile.php" );
37
38 $ini =& eZINI::instance( 'site.ini' );
39
40 $Language = $ini->variable( "eZBugMain", "Language" );
41
42 // include_once( "ezbug/classes/ezbug.php" );
43 // include_once( "ezbug/classes/ezbugcategory.php" );
44 // include_once( "ezbug/classes/ezbugmodule.php" );
45
46 $t = new eZTemplate( "kernel/ezbug/user/" . $ini->variable( "eZBugMain", "TemplateDir" ),
47 "kernel/ezbug/user/intl", $Language, "bugreport.php" );
48 $t->setAllStrings();
49 $t->set_var( "sitedesign", $GlobalSiteDesign );
50
51 $t->set_file( "bug_report_tpl", "bugreport.tpl" );
52
53 $t->set_block( "bug_report_tpl", "module_item_tpl", "module_item" );
54 $t->set_block( "bug_report_tpl", "category_item_tpl", "category_item" );
55 $t->set_block( "bug_report_tpl", "email_address_tpl", "email_address" );
56 $t->set_block( "bug_report_tpl", "all_fields_error_tpl", "all_fields_error" );
57 $t->set_block( "bug_report_tpl", "email_error_tpl", "email_error" );
58
59 $t->set_block( "bug_report_tpl", "delete_items_tpl", "delete_items" );
60 $t->set_var( "delete_items", "" );
61 $t->set_block( "bug_report_tpl", "inserted_files_tpl", "inserted_files" );
62 $t->set_block( "bug_report_tpl", "inserted_images_tpl", "inserted_images" );
63 $t->set_block( "inserted_files_tpl", "file_tpl", "file" );
64 $t->set_block( "inserted_images_tpl", "image_tpl", "image" );
65 $t->set_var( "inserted_files", "" );
66 $t->set_var( "inserted_images", "" );
67
68
69 // new inserts new bug
70 // update, updates the bug with new values.
71 // when updating and inserting values must be checked.
72 // you must save the bug before you can add images/files.
73 $successfull = 0;
74 $actionValue = "new";
75 if ( $Action == "New" )
76 {
77 $bug = new eZBug();
78 $bug->setName( $Name );
79 $bug->setDescription( $Description );
80 $bug->store();
81
82 $category = new eZBugCategory( $BugCategoryID );
83 $module = new eZBugModule( $ModuleID );
84 $bug->removeFromCategories();
85 $bug->removeFromModules();
86
87 $category->addBug( $bug );
88 $module->addBug( $bug );
89
90 $user =& eZUser::currentUser();
91 if ( $user )
92 $bug->setUser( $user );
93 else
94 $bug->setUserEmail( $Email );
95
96 if ( $IsPrivate == "true" )
97 $bug->setIsPrivate( true );
98
99 $bug->setVersion( $Version );
100 $bug->setIsHandled( false );
101 $bug->store();
102
103 $actionValue = "update";
104 $BugID = $bug->id();
105 }
106
107 if ( $Action == "Update" )
108 {
109 $bug = new eZBug( $BugID );
110 $bug->setName( $Name );
111 $bug->setDescription( $Description );
112
113 $category = new eZBugCategory( $BugCategoryID );
114 $module = new eZBugModule( $ModuleID );
115 $bug->removeFromCategories();
116 $bug->removeFromModules();
117
118 $category->addBug( $bug );
119 $module->addBug( $bug );
120
121 $user =& eZUser::currentUser();
122 if ( $user )
123 $bug->setUser( $user );
124 else
125 $bug->setUserEmail( $Email );
126
127 if ( $IsPrivate == "true" )
128 $bug->setIsPrivate( true );
129
130 $bug->setVersion( $Version );
131 $bug->setIsHandled( false );
132 $bug->store();
133
134 $actionValue = "update";
135 $BugID = $bug->id();
136 $Action = "Edit";
137 }
138
139
140 /* bug is now allways saved... lets check what the user really wanted to do..*/
141 if ( isset( $Ok ) ) // here check for errors. and display them if nescacary
142 {
143 $user =& eZUser::currentUser();
144 if ( ( $Name != "" ) && ( $Description != "" ) )
145 {
146 if ( $user )
147 {
148 $successfull = 1;
149 send_email( $bug, $ini, $Language );
150 eZHTTPTool::header( "Location: /bug/reportsuccess/" );
151 exit();
152 }
153 else
154 {
155 if ( $Email != "" )
156 {
157 $successfull = 2;
158 send_email( $bug, $ini, $Language );
159 eZHTTPTool::header( "Location: /bug/reportsuccess/" );
160 exit();
161 }
162 else
163 {
164 $EmailError = true;
165 }
166 }
167 }
168 else
169 {
170 $AllFieldsError = true;
171 }
172 }
173
174 if ( isset( $InsertFile ) )
175 {
176 $session->setVariable( "CurrentBugEdit", $BugID );
177 eZHTTPTool::header( "Location: /bug/report/fileedit/new/" . $BugID . "/" );
178 exit();
179 }
180
181 if ( isset( $InsertImage ) )
182 {
183 $session->setVariable( "CurrentBugEdit", $BugID );
184 eZHTTPTool::header( "Location: /bug/report/imageedit/new/" . $BugID . "/" );
185 exit();
186 }
187
188 if ( isset( $DeleteSelected ) )
189 {
190 if ( count( $ImageArrayID ) > 0 )
191 {
192 foreach ( $ImageArrayID as $imageID )
193 {
194 $image = new eZImage( $imageID );
195 $bug->deleteImage( $image );
196 }
197 }
198
199 if ( isset( $FileArrayID ) && count( $FileArrayID ) > 0 )
200 {
201 foreach ( $FileArrayID as $fileID )
202 {
203 $file = new eZVirtualFile( $fileID );
204 $bug->deleteFile( $file );
205 }
206 }
207 }
208
209 /* user didn't press any buttons.. lets set up the view correctly then..*/
210 $catName = "";
211 $modName = "";
212
213 if( isset( $Description ) )
214 {
215 $t->set_var( "description_value", $Description );
216 }
217 else
218 {
219 $t->set_var( "description_value", '' );
220 }
221
222 if( isset( $Name ) )
223 {
224 $t->set_var( "title_value", eZTextTool::htmlspecialchars( $Name ) );
225 }
226 else
227 {
228 $t->set_var( "title_value", '' );
229 }
230
231 $t->set_var( "file", "" );
232 $t->set_var( "image", "" );
233 $t->set_var( "private_checked", "" );
234 $t->set_var( "version_value", "" );
235
236 if ( isset( $IsPrivate ) && $IsPrivate == "On" )
237 $t->set_var( "private_checked", "checked" );
238
239 $user =& eZUser::currentUser();
240 if ( $user )
241 $t->set_var( "usr_email", $user->email() );
242 else
243 $t->set_var( "usr_email", '' );
244
245 if( $Action == "Edit" ) // load values from database
246 {
247 $bug = new eZBug( $BugID );
248 $module = $bug->module();
249 if ( $module )
250 $modName = $module->name();
251
252 $category = $bug->category();
253 if ( $category )
254 $catName = $category->name();
255
256 $user =& eZUser::currentUser();
257 if ( !$user )
258 $t->set_var( "usr_email", $bug->userEmail() );
259
260
261 $t->set_var( "description_value", $bug->description() );
262 $t->set_var( "title_value", $bug->name() );
263 $t->set_var( "version_value", $bug->version() );
264
265 if ( is_object( $bug ) && $bug->isPrivate() )
266 $t->set_var( "private_checked", "checked" );
267
268 // get the files
269 $files = $bug->files();
270 $i = 0;
271 foreach ( $files as $file )
272 {
273 if ( ( $i % 2 ) == 0 )
274 {
275 $t->set_var( "td_class", "bglight" );
276 }
277 else
278 {
279 $t->set_var( "td_class", "bgdark" );
280 }
281
282 $t->set_var( "file_number", $i + 1 );
283 $t->set_var( "file_id", $file->id() );
284
285 $t->set_var( "file_name", "<a href=\"".$GlobalSiteIni->WWWDir.$GlobalSiteIni->Index."/filemanager/download/" . $file->id() . "/" . $file->originalFileName() . "\">" . $file->name() . "</a>" );
286
287 $t->parse( "file", "file_tpl", true );
288
289 $i++;
290 }
291 $anyDeleteItems = false;
292 if ( count( $files ) > 0 )
293 {
294 $t->parse( "inserted_files", "inserted_files_tpl", false );
295 $anyDeleteItems = true;
296 }
297
298 // get the images
299 $images = $bug->images();
300 $i = 0;
301 foreach ( $images as $image )
302 {
303 if ( ( $i % 2 ) == 0 )
304 {
305 $t->set_var( "td_class", "bglight" );
306 }
307 else
308 {
309 $t->set_var( "td_class", "bgdark" );
310 }
311 $t->set_var( "image_number", $i + 1 );
312 $t->set_var( "image_id", $image->id() );
313
314 $tmp = $image->caption();
315 $t->set_var( "image_name", $image->caption() );
316
317 $variation =& $image->requestImageVariation( 150, 150 );
318 $t->set_var( "image_url", "/" .$variation->imagePath() );
319 $t->set_var( "image_width", $variation->width() );
320 $t->set_var( "image_height",$variation->height() );
321
322 $t->parse( "image", "image_tpl", true );
323
324 $i++;
325 }
326 $actionValue = "update";
327 }
328
329 if ( isset( $images ) && count( $images ) > 0 )
330 {
331 $anyDeleteItems = true;
332 $t->parse( "inserted_images", "inserted_images_tpl", false );
333 }
334
335 if (isset( $anyDeleteItems ) && $anyDeleteItems )
336 $t->parse( "delete_items", "delete_items_tpl", false );
337
338 // if any errors are set, lets display them to the user.
339 if ( isset( $AllFieldsError ) && $AllFieldsError == true )
340 {
341 $t->parse( "all_fields_error", "all_fields_error_tpl" );
342 }
343 else
344 {
345 $t->set_var( "all_fields_error", "" );
346 }
347
348 if ( isset( $EmailError ) && $EmailError == true )
349 {
350 $t->parse( "email_error", "email_error_tpl" );
351 }
352 else
353 {
354 $t->set_var( "email_error", "" );
355 }
356
357
358 // insert values into fields.
359 $category = new eZBugCategory();
360 $module = new eZBugModule();
361
362 // show email address field if the user is not logged in
363 $user =& eZUser::currentUser();
364
365 if ( $user )
366 {
367 $t->set_var( "email_address", "" );
368 }
369 else
370 {
371 $t->parse( "email_address", "email_address_tpl" );
372 }
373
374 // list the categories
375 $categories = $category->getAll();
376 foreach ( $categories as $category )
377 {
378 $t->set_var( "category_id", $category->id() );
379 $t->set_var( "category_name", $category->name() );
380
381 if ( $category->name() == $catName )
382 $t->set_var( "selected", "selected" );
383 else
384 $t->set_var( "selected", "" );
385
386 $t->parse( "category_item", "category_item_tpl", true );
387 }
388
389 // list the modules
390 $modules = $module->getAll();
391 foreach ( $modules as $module )
392 {
393 $t->set_var( "module_id", $module->id() );
394 $t->set_var( "module_name", $module->name() );
395
396 if ( $module->name() == $modName )
397 $t->set_var( "selected", "selected" );
398 else
399 $t->set_var( "selected", "" );
400
401 $t->parse( "module_item", "module_item_tpl", true );
402 }
403
404 $t->set_var( "action_value", $actionValue );
405
406 $t->set_var( "bug_id", $BugID );
407
408 $t->pparse( "output", "bug_report_tpl" );
409
410
411 function send_email( $bug, $ini, $Language )
412 {
413 // set up some values that we need
414 $module = $bug->module();
415 // find the owners of the group, if their is now owner group, no need to send mail.
416 $ownerGroup = $module->ownerGroup();
417 if ( !is_a( $ownerGroup, "eZUserGroup" ) )
418 {
419 eZHTTPTool::header( "Location: /bug/reportsuccess/" );
420 exit();
421 }
422 $users = $ownerGroup->users();
423 $userEmail = "";
424 foreach ( $users as $userItem )
425 {
426 if ( $userEmail = "" )
427 $userEmail = $userItem->email();
428 else
429 $userEmail = $userEmail . ", " . $userItem->email();
430 }
431
432 $mail = new eZMail();
433 if ( $succesfull == 1 )
434 $mail->setFrom( $user->email() );
435 else
436 $mail->setFrom( $bug->userEmail() );
437
438 $mailTemplate = new eZTemplate( "kernel/ezbug/user/" . $ini->variable( "eZBugMain", "TemplateDir" ),
439 "kernel/ezbug/user/intl", $Language, "mailnewbug.php" );
440 $headerInfo = getallheaders();
441
442 $mailTemplate->set_file( "mailnewbug", "mailnewbug.tpl" );
443 $mailTemplate->setAllStrings();
444
445 $host = preg_replace( "/^admin\./", "", $headerInfo["Host"] );
446
447 $mailTemplate->set_var( "bug_url", "http://" . $host . "/bug/bugview/" . $bug->id() );
448 $mailTemplate->set_var( "bug_id", $bug->id() );
449 $mailTemplate->set_var( "bug_title", $bug->name( false ) );
450 $mailTemplate->set_var( "bug_module", $module->name( false ) );
451 if ( $user )
452 $mailTemplate->set_var( "bug_reporter", $user->namedEmail() );
453 else
454 $mailTemplate->set_var( "bug_reporter", $Email );
455 $mailTemplate->set_var( "bug_description", $bug->description( false ) );
456
457 $mail->setSubject( "[Bug][" . $bug->id() ."] " . $bug->name( false ) );
458 $bodyText = ( $mailTemplate->parse( "dummy", "mailnewbug" ) );
459 $mail->setBody( $bodyText );
460
461 if ( $userEmail != "" )
462 {
463 $mail->setTo( $userEmail );
464 print( $userEmail );
465 $mail->send();
466 }
467 }
468
469 ?>
$i
$i
Definition: admin/adlist.php:91
$session
$session
Definition: admin/articlelist.php:44
$Email
$Email
Definition: admin/useredit.php:414
$Description
$Description
Definition: articlelistrss.php:38
$headerInfo
$headerInfo
Definition: articlelistrss.php:45
$files
$files
Definition: articlepreview.php:91
$images
$images
Definition: articlepreview.php:146
$ownerGroup
foreach( $statuses as $status) $ownerGroup
Definition: bugedit.php:553
$bug
$bug
Definition: bugpreview.php:59
$category
$category
Definition: bugreport.php:359
send_email
send_email( $bug, $ini, $Language)
Definition: bugreport.php:411
$modName
$modName
Definition: bugreport.php:211
$t
$t
Definition: bugreport.php:46
$actionValue
$actionValue
Definition: bugreport.php:74
$user
$user
Definition: bugreport.php:239
$Language
$Language
Definition: bugreport.php:40
$ini
$ini
Definition: bugreport.php:38
$successfull
$successfull
Definition: bugreport.php:73
$module
$module
Definition: bugreport.php:360
$modules
foreach( $categories as $category) $modules
Definition: bugreport.php:390
$catName
if( $Action=="New") if( $Action=="Update") if(isset( $Ok)) if(isset( $InsertFile)) if(isset( $InsertImage)) if(isset( $DeleteSelected)) $catName
Definition: bugreport.php:210
$categories
$categories
Definition: bugreport.php:375
$tmp
$tmp
Definition: bugview.php:99
eZBugCategory
Definition: ezbugcategory.php:55
eZBugModule
Definition: ezbugmodule.php:56
eZBug
Definition: ezbug.php:80
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZImage
Definition: ezimage.php:95
eZMail
Definition: ezmail.php:57
eZTemplate
Definition: eztemplate.php:107
eZTextTool\htmlspecialchars
static htmlspecialchars( $string)
Definition: eztexttool.php:144
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
eZVirtualFile
Definition: ezvirtualfile.php:42
$Action
$Action
Definition: companysearch.php:80
$GlobalSiteIni
$GlobalSiteIni
Definition: ezarticle/xmlrpc/xmlrpcserver.php:33
$mail
$mail
Definition: ezbulkmail/admin/maillist.php:61
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
$users
$users
Definition: ezmessage/admin/messageedit.php:138
exit
exit
Definition: folder.php:81
$GlobalSiteDesign
global $GlobalSiteDesign
Definition: latestmessages.php:52
$Name
$Name
Definition: polledit.php:250
$image
$image
Definition: user/articlelist.php:242
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.