Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

personview.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: personview.php 9744 2002-11-21 08:54:14Z jhe $
5 //
6 // Created on: <23-Oct-2000 17:53:46 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 /*
28 View a person
29 */
30
31 // include_once( "classes/INIFile.php" );
32
33 $ini =& eZINI::instance( 'site.ini' );
34 $Language = $ini->variable( "eZContactMain", "Language" );
35 $SiteURL = $ini->variable( "Site", "SiteURL" );
36 $AdminSiteURL = $ini->variable( "Site", "AdminSiteURL" );
37
38 // include_once( "classes/eztemplate.php" );
39 // include_once( "classes/ezlocale.php" );
40 // include_once( "classes/ezdate.php" );
41 // include_once( "classes/eztexttool.php" );
42 // include_once( "classes/ezcurrency.php" );
43
44 // include_once( "ezaddress/classes/ezaddress.php" );
45 // include_once( "ezaddress/classes/ezaddresstype.php" );
46 // include_once( "ezaddress/classes/ezphone.php" );
47 // include_once( "ezaddress/classes/ezphonetype.php" );
48 // include_once( "ezaddress/classes/ezonline.php" );
49 // include_once( "ezaddress/classes/ezonlinetype.php" );
50 // include_once( "ezcontact/classes/ezprojecttype.php" );
51 // include_once( "ezcontact/classes/ezconsultation.php" );
52 // include_once( "ezcontact/classes/ezperson.php" );
53
54 // include_once( "ezmail/classes/ezmail.php" );
55 // include_once( "eztrade/classes/ezorder.php" );
56
57 // include_once( "ezuser/classes/ezusergroup.php" );
58 // include_once( "ezuser/classes/ezpermission.php" );
59
60 $user =& eZUser::currentUser();
61 if ( !is_a( $user, "eZUser" ) )
62 {
63 // include_once( "classes/ezhttptool.php" );
64 eZHTTPTool::header( "Location: /contact/nopermission/login" );
65 exit();
66 }
67
68 if ( !eZPermission::checkPermission( $user, "eZContact", "PersonView" ) )
69 {
70 // include_once( "classes/ezhttptool.php" );
71 eZHTTPTool::header( "Location: /contact/nopermission/person/view" );
72 exit();
73 }
74
75 $error = false;
76
77 $t = new eZTemplate( "kernel/ezcontact/admin/" . $ini->variable( "eZContactMain", "AdminTemplateDir" ),
78 "kernel/ezcontact/admin/intl", $Language, "personview.php" );
79 $intl = new eZINI( "kernel/ezcontact/admin/intl/$Language/personview.php.ini", false );
80 $t->setAllStrings();
81
82 $t->set_file( "person_view", "personview.tpl" );
83 $t->set_block( "person_view", "birth_item_tpl", "birth_item" );
84 $t->set_block( "person_view", "no_birth_item_tpl", "no_birth_item" );
85
86 $t->set_block( "person_view", "company_item_tpl", "company_item" );
87
88 $t->set_block( "person_view", "address_item_tpl", "address_item" );
89 $t->set_block( "address_item_tpl", "address_line_tpl", "address_line" );
90 $t->set_block( "person_view", "no_address_item_tpl", "no_address_item" );
91
92 $t->set_block( "person_view", "phone_item_tpl", "phone_item" );
93 $t->set_block( "phone_item_tpl", "phone_line_tpl", "phone_line" );
94 $t->set_block( "person_view", "no_phone_item_tpl", "no_phone_item" );
95
96 $t->set_block( "person_view", "online_item_tpl", "online_item" );
97 $t->set_block( "online_item_tpl", "online_line_tpl", "online_line" );
98 $t->set_block( "person_view", "no_online_item_tpl", "no_online_item" );
99 $t->set_block( "person_view", "image_item_tpl", "image_item" );
100
101 // $t->set_block( "person_view", "contact_person_tpl", "contact_person" );
102 // $t->set_block( "person_view", "no_contact_person_tpl", "no_contact_person" );
103 $t->set_block( "person_view", "project_status_tpl", "project_status" );
104 $t->set_block( "person_view", "no_project_status_tpl", "no_project_status" );
105
106 $t->set_block( "person_view", "consultation_table_item_tpl", "consultation_table_item" );
107 $t->set_block( "consultation_table_item_tpl", "consultation_item_tpl", "consultation_item" );
108
109 $t->set_block( "person_view", "order_table_item_tpl", "order_table_item" );
110 $t->set_block( "person_view", "mail_table_item_tpl", "mail_table_item" );
111 $t->set_block( "order_table_item_tpl", "order_item_tpl", "order_item" );
112 $t->set_block( "mail_table_item_tpl", "mail_item_tpl", "mail_item" );
113
114 $t->set_block( "person_view", "consultation_buttons_tpl", "consultation_buttons" );
115
116 $t->set_var( "consultation_item", "" );
117 $t->set_var( "consultation_table_item", "" );
118
119 $t->set_var( "firstname", "" );
120 $t->set_var( "lastname", "" );
121 $t->set_var( "birthday", "" );
122 $t->set_var( "birthmonth", "" );
123 $t->set_var( "birthyear", "" );
124 $t->set_var( "description", "" );
125
126 $t->set_var( "user_name", "" );
127 $t->set_var( "old_password", "" );
128
129 $t->set_var( "street1", "" );
130 $t->set_var( "street2", "" );
131 $t->set_var( "zip", "" );
132 $t->set_var( "place", "" );
133
134 $t->set_var( "home_phone", "" );
135 $t->set_var( "work_phone", "" );
136
137 $t->set_var( "web", "" );
138 $t->set_var( "email", "" );
139
140 /*
141 The user wants to view an existing person.
142 We present a page with the info.
143 */
144
145 if ( $Action == "view" )
146 {
147 $Action_value = "view";
148 $person = new eZPerson( $PersonID, true );
149
150 $t->set_var( "firstname", eZTextTool::htmlspecialchars( $person->firstName() ) );
151 $t->set_var( "lastname", eZTextTool::htmlspecialchars( $person->lastName() ) );
152
153 $t->set_var( "birth_item", "" );
154 $t->set_var( "no_birth_item", "" );
155 if ( $person->hasBirthDate() )
156 {
157 $Birth = new eZDate();
158 $Birth->setTimeStamp( $person->birthDate() );
159
160 $locale = new eZLocale( $Language );
161 $t->set_var( "birthdate", $locale->format( $Birth ) );
162 $t->parse( "birth_item", "birth_item_tpl" );
163 }
164 else
165 {
166 $t->parse( "no_birth_item", "no_birth_item_tpl" );
167 }
168 $t->set_var( "description", eZTextTool::htmlspecialchars( $person->comment() ) );
169
170 // Telephone list
171 $phoneList = $person->phones( $person->id() );
172
173 $count = count( $phoneList );
174 if ( $count != 0 )
175 {
176 for ( $i = 0; $i < $count; $i++ )
177 {
178 $t->set_var( "phone_id", $phoneList[$i]->id() );
179 $t->set_var( "phone", eZTextTool::htmlspecialchars( $phoneList[$i]->number() ) );
180
181 $phoneType = $phoneList[$i]->phoneType();
182
183 $t->set_var( "phone_type_id", $phoneType->id() );
184 // $t->set_var( "phone_type_name", $intl->variable( "strings", "phone_" . $phoneType->name() ) );
185 $t->set_var( "phone_type_name", eZTextTool::htmlspecialchars( $phoneType->name() ) );
186
187 $t->parse( "phone_line", "phone_line_tpl", true );
188 }
189 $t->parse( "phone_item", "phone_item_tpl" );
190 $t->set_var( "no_phone_item", "" );
191 }
192 else
193 {
194 $t->set_var( "phone_item", "" );
195 $t->parse( "no_phone_item", "no_phone_item_tpl" );
196 }
197
198 // Address list
199 $addressList = $person->addresses( $person->id() );
200 $count = count( $addressList );
201
202 if ( $count != 0 )
203 {
204 foreach ( $addressList as $addressItem )
205 {
206 $t->set_var( "address_id", $addressItem->id() );
207 $t->set_var( "street1", eZTextTool::htmlspecialchars( $addressItem->street1() ) );
208 $t->set_var( "street2", eZTextTool::htmlspecialchars( $addressItem->street2() ) );
209 $t->set_var( "zip", eZTextTool::htmlspecialchars( $addressItem->zip() ) );
210 $t->set_var( "place", eZTextTool::htmlspecialchars( $addressItem->place() ) );
211 $country = $addressItem->country();
212 if ( is_a( $country, "eZCountry" ) )
213 $t->set_var( "country", eZTextTool::htmlspecialchars( $country->name() ) );
214 else
215 $t->set_var( "country", "" );
216
217 $addressType = $addressItem->addressType();
218
219 $t->set_var( "address_type_id", $addressType->id() );
220 $t->set_var( "address_type_name", eZTextTool::htmlspecialchars( $addressType->name() ) );
221
222 $t->set_var( "script_name", "personedit.php" );
223 $t->parse( "address_line", "address_line_tpl", true );
224
225 }
226 $t->parse( "address_item", "address_item_tpl" );
227 $t->set_var( "no_address_item", "" );
228 }
229 else
230 {
231 $t->set_var( "address_item", "" );
232 $t->parse( "no_address_item", "no_address_item_tpl" );
233 }
234
235 // Online list
236 $OnlineList = $person->onlines( $person->id() );
237 $count = count( $OnlineList );
238 if ( $count != 0)
239 {
240 for ( $i = 0; $i < count( $OnlineList ); $i++ )
241 {
242 $onlineType = $OnlineList[$i]->onlineType();
243
244 $t->set_var( "online_id", $OnlineList[$i]->id() );
245 $prefix = $onlineType->URLPrefix();
246 $vis_prefix = $prefix;
247 $url = $OnlineList[$i]->URL();
248 if ( $onlineType->prefixLink() )
249 {
250 if ( strncasecmp( $url, $prefix, strlen( $prefix ) ) == 0 )
251 {
252 $prefix = "";
253 }
254 }
255 else
256 {
257 $prefix = "";
258 }
259 if ( $onlineType->prefixVisual() )
260 {
261 if ( strncasecmp( $url, $vis_prefix, strlen( $vis_prefix ) ) == 0 )
262 {
263 $vis_prefix = "";
264 }
265 }
266 else
267 {
268 $vis_prefix = "";
269 }
270 $t->set_var( "online_prefix", $prefix );
271 $t->set_var( "online_visual_prefix", $vis_prefix );
272 $t->set_var( "online", $url );
273
274 $t->set_var( "online_type_name", eZTextTool::htmlspecialchars( $onlineType->name() ) );
275
276 $t->parse( "online_line", "online_line_tpl", true );
277 }
278 $t->parse( "online_item", "online_item_tpl" );
279 $t->set_var( "no_online_item", "" );
280 }
281 else
282 {
283 $t->set_var( "online_item", "" );
284 $t->parse( "no_online_item", "no_online_item_tpl" );
285 }
286
287 // List companies this person is related to
288 $t->set_var( "company_item", "" );
289 $companies = $person->companies();
290 foreach ( $companies as $company )
291 {
292 $t->set_var( "company_id", $company->id() );
293 $t->set_var( "company_name", eZTextTool::htmlspecialchars( $company->name() ) );
294 $t->parse( "company_item", "company_item_tpl", true );
295 }
296
297 $t->set_var( "person_id", $PersonID );
298
299 // Project info
300 // $t->set_var( "contact_person", "" );
301 // $t->set_var( "no_contact_person", "" );
302
303 // $contact = $person->contact();
304 // if ( $contact )
305 // {
306 // $user = new eZUser( $contact );
307 // $t->set_var( "contact_firstname", $user->firstName() );
308 // $t->set_var( "contact_lastname", $user->lastName() );
309 // $t->parse( "contact_person", "contact_person_tpl" );
310 // }
311 // else
312 // {
313 // $t->parse( "no_contact_person", "no_contact_person_tpl" );
314 // }
315
316 $t->set_var( "project_status", "" );
317 $t->set_var( "no_project_status", "" );
318
319 $statusid = $person->projectState();
320 if ( $statusid )
321 {
322 $status = new eZProjectType( $statusid );
323 $t->set_var( "project_status", eZTextTool::htmlspecialchars( $status->name() ) );
324 $t->parse( "project_status", "project_status_tpl" );
325 }
326 else
327 {
328 $t->parse( "no_project_status", "no_project_status_tpl" );
329 }
330
331 $image =& $person->image();
332 if ( get_class( $image ) == "ezimage" && $image->id() != 0 )
333 {
334 $imageWidth =& $ini->variable( "eZContactMain", "PersonImageWidth" );
335 $imageHeight =& $ini->variable( "eZContactMain", "PersonImageHeight" );
336 $variation =& $image->requestImageVariation( $imageWidth, $imageHeight );
337 $imageURL = "/" . $variation->imagePath();
338 $imageWidth = $variation->width();
339 $imageHeight = $variation->height();
340 $imageCaption = $image->caption();
341 $t->set_var( "image_width", $imageWidth );
342 $t->set_var( "image_height", $imageHeight );
343 $t->set_var( "image_url", $imageURL );
344 $t->set_var( "image_caption", $imageCaption );
345 $t->parse( "image_item", "image_item_tpl" );
346 }
347 else
348 {
349 $t->set_var( "image_item", "" );
350 }
351
352 // Consultation list
353 $user =& eZUser::currentUser();
354 if ( eZPermission::checkPermission( $user, "eZContact", "consultation" ) )
355 {
356 $max = $ini->variable( "eZContactMain", "MaxPersonConsultationList" );
357 if ( $ini->variable( "eZContactMain", "ShowAllConsultations" ) == "enabled" )
358 {
359 if ( $ini->variable( "eZContactMain", "ShowRelatedConsultations" ) == "enabled" )
360 $consultations = eZConsultation::findConsultationsByContact( $PersonID, -1, "Date", true, 0, $max, true );
361 else
362 $consultations = eZConsultation::findConsultationsByContact( $PersonID, -1, "Date", true, 0, $max );
363 }
364 else
365 {
366 if ( $ini->variable( "eZContactMain", "ShowRelatedConsultations" ) == "enabled" )
367 $consultations = eZConsultation::findConsultationsByContact( $PersonID, $user->id(), "Date", true, 0, $max, true );
368 else
369 $consultations = eZConsultation::findConsultationsByContact( $PersonID, $user->id(), "Date", true, 0, $max );
370 }
371
372 $t->set_var( "consultation_type", "person" );
373 $t->set_var( "person_id", $PersonID );
374
375 $locale = new eZLocale( $Language );
376 $i = 0;
377
378 foreach ( $consultations as $consultation )
379 {
380 if ( ( $i % 2 ) == 0 )
381 {
382 $t->set_var( "bg_color", "bglight" );
383 }
384 else
385 {
386 $t->set_var( "bg_color", "bgdark" );
387 }
388
389 $t->set_var( "consultation_id", $consultation->id() );
390 $t->set_var( "consultation_date", $locale->format( $consultation->date() ) );
391 $t->set_var( "consultation_short_description", eZTextTool::htmlspecialchars( $consultation->shortDescription() ) );
392 $t->set_var( "consultation_status_id", $consultation->state() );
393 $t->set_var( "consultation_status", eZTextTool::htmlspecialchars( eZConsultation::stateName( $consultation->state() ) ) );
394 $t->parse( "consultation_item", "consultation_item_tpl", true );
395 $i++;
396 }
397 }
398
399 if ( eZPermission::checkPermission( $user, "eZContact", "consultation" )
400 and count( $consultations ) > 0 )
401 {
402 $t->parse( "consultation_table_item", "consultation_table_item_tpl", true );
403 }
404 else
405 {
406 $t->set_var( "consultation_table_item", "" );
407 }
408
409 if ( eZPermission::checkPermission( $user, "eZContact", "consultation" ) )
410 {
411 $t->parse( "consultation_buttons", "consultation_buttons_tpl" );
412 }
413 else
414 {
415 $t->set_var( "consultation_buttons", "" );
416 }
417 }
418
419 // Order list
420 if ( is_a( $user, "eZUser" ) and eZPermission::checkPermission( $user, "eZContact", "buy" ) )
421 {
422 $max = $ini->variable( "eZContactMain", "MaxCompanyConsultationList" );
423 if ( isset( $CompanyEdit ) && $CompanyEdit )
424 $orders = eZOrder::getByContact( $CompanyID, false, 0, $max );
425 else
426 $orders = eZOrder::getByContact( $PersonID, false, 0, $max );
427
428 $locale = new eZLocale( $Language );
429 $i = 0;
430 $currency = new eZCurrency();
431 $languageINI = new eZINI( "kernel/eztrade/admin/intl/" . $Language . "/orderlist.php.ini", false );
432 $t->set_var( "admin_dir", $AdminSiteURL );
433 foreach ( $orders as $order )
434 {
435 $t->set_var( "bg_color", ( $i % 2 ) == 0 ? "bglight" : "bgdark" );
436
437 $t->set_var( "order_id", $order->id() );
438 $t->set_var( "order_date", $locale->format( $order->date() ) );
439
440 $status = $order->initialStatus( );
441 $dateTime = $status->altered();
442
443 $status = $order->lastStatus();
444
445 $statusType = $status->type();
446 $statusName = preg_replace( "#intl-#", "", $statusType->name() );
447 $statusName = $languageINI->variable( "strings", $statusName );
448
449 $t->set_var( "order_status", $statusName );
450
451 if ( $order->isVATInc() == true )
452 $currency->setValue( $order->totalPriceIncVAT() + $order->shippingCharge());
453 else
454 $currency->setValue( $order->totalPrice() + $order->shippingCharge() );
455 $t->set_var( "order_price", $locale->format( $currency ) );
456
457 $t->parse( "order_item", "order_item_tpl", true );
458 $i++;
459 }
460 }
461
462 if ( is_a( $user, "eZUser" ) &&
463 eZPermission::checkPermission( $user, "eZContact", "buy" ) &&
464 count( $orders ) > 0 )
465 {
466 $t->parse( "order_table_item", "order_table_item_tpl", true );
467 }
468 else
469 {
470 $t->set_var( "order_table_item", "" );
471 }
472
473
474 // e-mail list
475 $emails = eZMail::getByContact( $PersonID, false, 0, $max );
476
477 $locale = new eZLocale( $Language );
478 $i = 0;
479 $currency = new eZCurrency();
480 $t->set_var( "admin_dir", $AdminSiteURL );
481 $date = new eZDateTime();
482 foreach ( $emails as $email )
483 {
484 $t->set_var( "bg_color", ( $i % 2 ) == 0 ? "bglight" : "bgdark" );
485
486 $t->set_var( "mail_id", $email->id() );
487 $date->setTimeStamp( $email->uDate() );
488 $t->set_var( "mail_date", $locale->format( $date ) );
489
490 $t->set_var( "mail_subject", $email->subject() );
491 $t->set_var( "mail_email", $email->sender() );
492
493 $t->parse( "mail_item", "mail_item_tpl", true );
494 $i++;
495 }
496 if ( is_a( $user, "eZUser" ) and count( $emails ) > 0 )
497 {
498 $t->parse( "mail_table_item", "mail_table_item_tpl", true );
499 }
500 else
501 {
502 $t->set_var( "mail_table_item", "" );
503 }
504
505
506 $t->set_var( "action_value", $Action_value );
507
508 $t->pparse( "output", "person_view" );
509
510 ?>
$companies
else $companies
Definition: admin/consultationlist.php:221
$dateTime
$dateTime
Definition: authorview.php:77
$status
$status
Definition: bugedit.php:473
eZConsultation\stateName
static stateName( $state)
Definition: ezconsultation.php:856
eZConsultation\findConsultationsByContact
static findConsultationsByContact( $contact, $user, $OrderBy="ID", $is_person=true, $index=0, $max=-1, $relations=false)
Definition: ezconsultation.php:509
eZCurrency
Definition: ezcurrency.php:46
eZDateTime
Definition: ezdatetime.php:55
eZDate
Definition: ezdate.php:46
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZINI
Reads and writes .ini style configuration files.
eZLocale
Definition: ezlocale.php:119
eZMail\getByContact
static getByContact( $ContactID, $CompanyEdit, $Offset, $Limit, $user=false)
Definition: ezmail.php:711
eZOrder\getByContact
static & getByContact( $contact, $is_person=true, $offset=0, $limit=40)
Definition: ezorder.php:402
eZPermission\checkPermission
static checkPermission( $user, $moduleName, $permissionName)
Definition: ezpermission.php:430
eZPerson
Definition: ezperson.php:43
eZProjectType
Definition: ezprojecttype.php:54
eZTemplate
Definition: eztemplate.php:107
eZTextTool\htmlspecialchars
static htmlspecialchars( $string)
Definition: eztexttool.php:144
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$CompanyEdit
$CompanyEdit
Definition: companyedit.php:32
$Action
$Action
Definition: companysearch.php:80
$company
if(!is_numeric( $Year)) if(!is_numeric( $Month)) if(!is_numeric( $Day)) $company
Definition: companystats.php:72
$OnlineList
$OnlineList
Definition: companyview.php:273
$phoneList
$phoneList
Definition: companyview.php:246
$addressList
$addressList
Definition: companyview.php:215
$Action_value
$Action_value
Definition: companyview.php:559
$orders
$orders
Definition: customerview.php:87
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
exit
exit
Definition: folder.php:81
$url
$url
Definition: messagereviewlist.php:153
$count
$count
Definition: onlinetypelist.php:108
$statusType
if(count( $usedVouchers) > 0) $statusType
Definition: orderedit.php:620
$country
$country
Definition: paypal.php:46
$person
switch( $LimitType) $person
Definition: personlist.php:137
$AdminSiteURL
$AdminSiteURL
Definition: personview.php:36
$SiteURL
$SiteURL
Definition: personview.php:35
$emails
$emails
Definition: personview.php:475
$currency
$currency
Definition: personview.php:479
$locale
$locale
Definition: personview.php:477
$t
$t
Definition: personview.php:77
$intl
$intl
Definition: personview.php:79
$date
$date
Definition: personview.php:481
$user
$user
Definition: personview.php:60
$error
if(!is_a( $user, "eZUser")) if(!eZPermission::checkPermission( $user, "eZContact", "PersonView")) $error
Definition: personview.php:75
$i
$i
Definition: personview.php:478
$Language
$Language
Definition: personview.php:34
$ini
$ini
Definition: personview.php:33
$order
$order
Definition: productreport.php:182
$languageINI
$languageINI
Definition: sectionedit.php:57
$image
$image
Definition: user/articlelist.php:242
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.