Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

personedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: personedit.php 9829 2003-06-03 05:56:24Z 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 Edit a person
29 */
30
31 // include_once( "classes/INIFile.php" );
32
33 $ini =& eZINI::instance( 'site.ini' );
34 $Language = $ini->variable( "eZContactMain", "Language" );
35
36 // include_once( "classes/eztemplate.php" );
37 // include_once( "classes/ezlog.php" );
38 // include_once( "classes/eztexttool.php" );
39
40 // include_once( "ezaddress/classes/ezcountry.php" );
41 // include_once( "ezcontact/classes/ezperson.php" );
42 // include_once( "ezcontact/classes/ezcompany.php" );
43 // include_once( "ezcontact/classes/ezprojecttype.php" );
44 // include_once( "ezmail/classes/ezmail.php" );
45 // include_once( "ezuser/classes/ezusergroup.php" );
46 // include_once( "ezuser/classes/ezpermission.php" );
47
48 // deletes the dayview cache file for a given day
49 function deleteCache( $SiteDesign )
50 {
51 unlinkWild( "./kernel/ezcalendar/user/cache/", "monthview.tpl-$SiteDesign-*" );
52 }
53
54 function unlinkWild( $dir, $rege )
55 {
56 $d = eZPBFile::dir( $dir );
57 while ( $f = $d->read() )
58 {
59 if ( preg_match( $rege, $f ) )
60 {
61 eZPBFile::unlink( $dir . $f );
62 }
63 }
64 }
65
66 $user =& eZUser::currentUser();
67
68 if ( isset( $CompanyEdit ) && $CompanyEdit )
69 {
70 $item_type = "company";
71 $item_id = $CompanyID;
72 }
73 else
74 {
75 $item_type = "person";
76 $item_id = $PersonID;
77 }
78
79 if ( !is_a( $user, "eZUser" ) )
80 {
81 // include_once( "classes/ezhttptool.php" );
82 eZHTTPTool::header( "Location: /contact/nopermission/login" );
83 exit();
84 }
85
86 if ( isset( $BuyButton ) )
87 {
88 include( "kernel/ezcontact/admin/buy.php" );
89 }
90
91 if ( isset( $OK ) )
92 {
93 if ( $CompanyEdit )
94 {
95 if ( isset( $Action ) && $Action == "edit" || isset( $Action ) && $Action == "update" )
96 {
97 if ( !eZPermission::checkPermission( $user, "eZContact", "CompanyModify" ) )
98 {
99 // include_once( "classes/ezhttptool.php" );
100 eZHTTPTool::header( "Location: /contact/nopermission/company/edit" );
101 exit();
102 }
103 }
104 else if ( isset( $Action ) && $Action == "new" || isset( $Action ) && $Action == "insert" )
105 {
106 if ( !eZPermission::checkPermission( $user, "eZContact", "CompanyAdd" ) )
107 {
108 // include_once( "classes/ezhttptool.php" );
109 eZHTTPTool::header( "Location: /contact/nopermission/company/new" );
110 exit();
111 }
112 }
113 }
114 else
115 {
116 if ( isset( $Action ) && $Action == "edit" || isset( $Action ) && $Action == "update" )
117 {
118 if ( !eZPermission::checkPermission( $user, "eZContact", "PersonModify" ) )
119 {
120 // include_once( "classes/ezhttptool.php" );
121 eZHTTPTool::header( "Location: /contact/nopermission/person/edit" );
122 exit();
123 }
124 }
125 else if ( isset( $Action ) && $Action == "new" || isset( $Action ) && $Action == "insert" )
126 {
127 if ( !eZPermission::checkPermission( $user, "eZContact", "PersonAdd" ) )
128 {
129 // include_once( "classes/ezhttptool.php" );
130 eZHTTPTool::header( "Location: /contact/nopermission/person/new" );
131 exit();
132 }
133 }
134 }
135 }
136
137 if ( isset( $ListConsultation ) )
138 {
139 // include_once( "classes/ezhttptool.php" );
140 eZHTTPTool::header( "Location: /contact/consultation/$item_type/list/$item_id" );
141 exit;
142 }
143
144 if ( isset( $NewConsultation ) )
145 {
146 // include_once( "classes/ezhttptool.php" );
147 eZHTTPTool::header( "Location: /contact/consultation/$item_type/new/$item_id" );
148 exit;
149 }
150
151 if ( isset( $FileButton ) )
152 {
153 include( "kernel/ezcontact/admin/folder.php" );
154 }
155
156 if ( isset( $Back ) )
157 {
158 if ( $CompanyEdit )
159 {
160 $company = new eZCompany( $CompanyID );
161 $categories = $company->categories( false, false );
162 $id = $categories[0];
163 }
164 // include_once( "classes/ezhttptool.php" );
165 eZHTTPTool::header( "Location: /contact/$item_type/list/$id" );
166 exit;
167 }
168
169 if ( isset( $Delete ) )
170 {
171 $Action = "delete";
172 }
173
174 if ( isset( $Action ) && $Action == "delete" )
175 {
176 if ( $CompanyEdit )
177 {
178 if ( !eZPermission::checkPermission( $user, "eZContact", "CompanyDelete" ) )
179 {
180 // include_once( "classes/ezhttptool.php" );
181 eZHTTPTool::header( "Location: /contact/nopermission/company/delete" );
182 exit();
183 }
184 }
185 else
186 {
187 if ( !eZPermission::checkPermission( $user, "eZContact", "PersonDelete" ) )
188 {
189 // include_once( "classes/ezhttptool.php" );
190 eZHTTPTool::header( "Location: /contact/nopermission/person/delete" );
191 exit();
192 }
193 }
194
195 if ( $CompanyEdit )
196 {
197 $categories =& (new eZCompany())->categories( $CompanyID, false, 1 );
198 $id =& $categories[0];
199 $item_type = "company";
200 foreach ( $ContactArrayID as $contactItem )
201 {
202 eZCompany::delete( $contactItem );
203 }
204 }
205 else
206 {
207 $item_type = "person";
208 foreach ( $ContactArrayID as $contactItem )
209 {
210 eZPerson::delete( $contactItem );
211 }
212 }
213
214 deleteCache( "default" );
215 // include_once( "classes/ezhttptool.php" );
216 eZHTTPTool::header( "Location: /contact/$item_type/list/$id" );
217 exit;
218 }
219
220 if ( isset( $OK ) )
221 {
222 if ( $Action == "new" )
223 $Action = "insert";
224 else if ( $Action == "edit" )
225 $Action = "update";
226 }
227
228 $error = false;
229
230 if ( $CompanyEdit )
231 {
232 $template_file = "companyedit.tpl";
233 $language_file = "companyedit.php";
234 }
235 else
236 {
237 $template_file = "personedit.tpl";
238 $language_file = "personedit.php";
239 }
240
241 $t = new eZTemplate( "kernel/ezcontact/admin/" . $ini->variable( "eZContactMain", "AdminTemplateDir" ),
242 "kernel/ezcontact/admin/intl", $Language, $language_file );
243 $t->setAllStrings();
244
245 $t->set_file( "person_edit", $template_file );
246
247 $t->set_block( "person_edit", "edit_tpl", "edit_item" );
248 $t->set_block( "person_edit", "confirm_tpl", "confirm_item" );
249 $t->set_block( "person_edit", "image_item_tpl", "image_item" );
250
251 if ( $CompanyEdit )
252 {
253 $t->set_block( "edit_tpl", "company_item_tpl", "company_item" );
254 $t->set_block( "company_item_tpl", "company_type_select_tpl", "company_type_select" );
255 $t->set_block( "edit_tpl", "logo_item_tpl", "logo_item" );
256 $t->set_block( "edit_tpl", "image_item_tpl", "image_item" );
257 }
258 else
259 {
260 $t->set_block( "edit_tpl", "person_item_tpl", "person_item" );
261 $t->set_block( "person_item_tpl", "day_item_tpl", "day_item" );
262 $t->set_block( "person_item_tpl", "company_select_tpl", "company_select" );
263 }
264
265 $t->set_block( "edit_tpl", "address_table_item_tpl", "address_table_item" );
266 $t->set_block( "address_table_item_tpl", "address_item_tpl", "address_item" );
267 $t->set_block( "address_item_tpl", "address_item_select_tpl", "address_item_select" );
268
269 $t->set_block( "address_item_tpl", "country_item_select_tpl", "country_item_select" );
270
271 $t->set_block( "edit_tpl", "phone_table_item_tpl", "phone_table_item" );
272 $t->set_block( "phone_table_item_tpl", "phone_item_tpl", "phone_item" );
273 $t->set_block( "phone_item_tpl", "phone_item_select_tpl", "phone_item_select" );
274
275 $t->set_block( "edit_tpl", "online_table_item_tpl", "online_table_item" );
276 $t->set_block( "online_table_item_tpl", "online_item_tpl", "online_item" );
277 $t->set_block( "online_item_tpl", "online_item_select_tpl", "online_item_select" );
278
279 $t->set_block( "edit_tpl", "project_item_tpl", "project_item" );
280 $t->set_block( "project_item_tpl", "project_contact_item_tpl", "project_contact_item" );
281 $t->set_block( "project_contact_item_tpl", "contact_group_item_select_tpl", "contact_group_item_select" );
282 $t->set_block( "project_contact_item_tpl", "contact_item_select_tpl", "contact_item_select" );
283 $t->set_block( "project_item_tpl", "project_item_select_tpl", "project_item_select" );
284
285 $t->set_block( "person_edit", "delete_item_tpl", "delete_item" );
286
287 $t->set_block( "edit_tpl", "errors_tpl", "errors_item" );
288
289 if ( $CompanyEdit )
290 {
291 $t->set_block( "errors_tpl", "error_name_item_tpl", "error_name_item" );
292 }
293 else
294 {
295 $t->set_block( "errors_tpl", "error_firstname_item_tpl", "error_firstname_item" );
296 $t->set_block( "errors_tpl", "error_lastname_item_tpl", "error_lastname_item" );
297 $t->set_block( "errors_tpl", "error_birthdate_item_tpl", "error_birthdate_item" );
298 }
299
300 $t->set_block( "errors_tpl", "error_address_item_tpl", "error_address_item" );
301 $t->set_block( "errors_tpl", "error_phone_item_tpl", "error_phone_item" );
302 $t->set_block( "errors_tpl", "error_online_item_tpl", "error_online_item" );
303 $t->set_block( "errors_tpl", "error_logo_item_tpl", "error_logo_item" );
304 $t->set_block( "errors_tpl", "error_image_item_tpl", "error_image_item" );
305
306 $confirm = false;
307
308 if( isset( $Action ) && $Action == "new" )
309 {
310 if( !isset( $BirthDay ) )
311 $BirthDay = false;
312 if( !isset( $BirthYear ) )
313 $BirthYear = false;
314 if( !isset( $BirthMonth ) )
315 $BirthMonth = false;
316 if( !isset( $Comment ) )
317 $Comment = false;
318
319 $t->set_var( "image_caption", '' );
320 }
321
322 if ( isset( $Action ) && $Action == "delete" )
323 {
324 if ( !isset( $Confirm ) )
325 {
326 $confirm = true;
327
328 if ( $CompanyEdit )
329 {
330 $t->set_var( "company_id", $CompanyID );
331 $company = new eZCompany( $CompanyID );
332 $t->set_var( "name", $company->name() );
333 }
334 else
335 {
336 $t->set_var( "person_id", $PersonID );
337 $person = new eZPerson( $PersonID );
338 $t->set_var( "firstname", $person->firstName() );
339 $t->set_var( "lastname", $person->lastName() );
340 }
341 $t->set_var( "edit_item", "" );
342 $t->set_var( "action_value", $Action );
343 $t->set_var( "delete_item", "" );
344 $t->parse( "confirm_item", "confirm_tpl" );
345 }
346 }
347
348 if ( !$confirm )
349 {
350 $t->set_var( "confirm_item", "" );
351
352 if ( $CompanyEdit )
353 {
354 $t->set_var( "name", "" );
355 $t->set_var( "companyno", "" );
356 }
357 else
358 {
359 $t->set_var( "firstname", "" );
360 $t->set_var( "lastname", "" );
361 $t->set_var( "birthdate", "" );
362 $t->set_var( "comment", "" );
363 $t->set_var( "person_id", "" );
364 }
365
366 $t->set_var( "user_id", isset( $UserID ) ? $UserID : false );
367
368 $t->set_var( "contact_group_item_select", "" );
369 $t->set_var( "contact_item_select", "" );
370
371 /* End of the pre-defined values */
372 if ( ( isset( $Action ) && $Action == "insert" || isset( $Action ) && $Action == "update" ) )
373 {
374 if ( $Action == "update" )
375 {
376 deleteCache( "default" );
377 }
378
379 if ( $CompanyEdit )
380 {
381 $t->set_var( "error_name_item", "" );
382 }
383 else
384 {
385 $t->set_var( "error_firstname_item", "" );
386 $t->set_var( "error_lastname_item", "" );
387 $t->set_var( "error_birthdate_item", "" );
388 }
389
390 $t->set_var( "error_address_item", "" );
391 $t->set_var( "error_phone_item", "" );
392 $t->set_var( "error_online_item", "" );
393 $t->set_var( "error_logo_item", "" );
394 $t->set_var( "error_image_item", "" );
395
396 if ( $CompanyEdit )
397 {
398 if ( $Name == "" )
399 {
400 $t->parse( "error_name_item", "error_name_item_tpl" );
401 $error = true;
402 }
403 }
404 else
405 {
406 if ( $FirstName == "" )
407 {
408 $t->parse( "error_firstname_item", "error_firstname_item_tpl" );
409 $error = true;
410 }
411
412 if ( $LastName == "" )
413 {
414 $t->parse( "error_lastname_item", "error_lastname_item_tpl" );
415 $error = true;
416 }
417
418 if ( $BirthYear != "" )
419 {
420 $birth = new eZDate( $BirthYear, $BirthMonth, $BirthDay );
421 if ( !$birth->isValid() )
422 {
423 $t->parse( "error_birthdate_item", "error_birthdate_item_tpl" );
424 $error = true;
425 }
426 }
427 }
428
429 if( !isset( $AddressID ) )
430 $AddressID = array();
431
432 $count = max( count( $AddressTypeID ), count( $AddressID ),
433 count( $Street1 ), count( $Street2 ),
434 count( $Zip ), count( $Place ), 1 );
435 for ( $i = 0; $i < $count; $i++ )
436 {
437 if ( $AddressTypeID[$i] != -1 )
438 {
439 if ( $Street1[$i] == "" || $Place[$i] == "" || $Country[$i] == "" )
440 {
441 $t->set_var( "error_address_position", $i + 1 );
442 $t->parse( "error_address_item", "error_address_item_tpl", true );
443 $error = true;
444 }
445 }
446 else
447 {
448 if ( $Street1[$i] != "" || $Street2[$i] != "" || $Place[$i] != "" ||
449 ( $Country[$i] != -1 and $Country[$i] != "" ) )
450 {
451 $t->set_var( "error_address_position", $i + 1 );
452 $t->parse( "error_address_item", "error_address_item_tpl", true );
453 $error = true;
454 }
455 }
456 }
457
458 $count = max( count( $PhoneTypeID ), count( $PhoneID ), count( $Phone ) );
459 for ( $i = 0; $i < $count; $i++ )
460 {
461 if ( $PhoneTypeID[$i] != -1 )
462 {
463 if ( $Phone[$i] == "" )
464 {
465 $t->set_var( "error_phone_position", $i + 1 );
466 $t->parse( "error_phone_item", "error_phone_item_tpl", true );
467 $error = true;
468 }
469 }
470 else
471 {
472 if ( $Phone[$i] != "" )
473 {
474 $t->set_var( "error_phone_position", $i + 1 );
475 $t->parse( "error_phone_item", "error_phone_item_tpl", true );
476 $error = true;
477 }
478 }
479 }
480
481 $count = max( count( $OnlineTypeID ), count( $OnlineID ), count( $Online ) );
482 for ( $i = 0; $i < $count; $i++ )
483 {
484 if ( $OnlineTypeID[$i] != -1 )
485 {
486 if ( $Online[$i] == "" )
487 {
488 $t->set_var( "error_online_position", $i + 1 );
489 $t->parse( "error_online_item", "error_online_item_tpl", true );
490 $error = true;
491 }
492 }
493 else
494 {
495 if ( $Online[$i] != "" )
496 {
497 $t->set_var( "error_online_position", $i + 1 );
498 $t->parse( "error_online_item", "error_online_item_tpl", true );
499 $error = true;
500 }
501 }
502 }
503
504 // Check uploaded logo image
505 $file = new eZPBImageFile();
506 if ( $file->getUploadedFile( "logo" ) )
507 {
508 $logo = new eZImage();
509 if ( !$logo->checkImage( $file ) )
510 {
511 $t->parse( "error_logo_item", "error_logo_item_tpl", true );
512 $error = true;
513 }
514 }
515
516 // Check uploaded image
517 $file = new eZPBImageFile();
518 if ( $file->getUploadedFile( "image" ) )
519 {
520 $image = new eZImage();
521 if ( !$image->checkImage( $file ) )
522 {
523 $t->parse( "error_image_item", "error_image_item_tpl", true );
524 $error = true;
525 }
526 }
527
528 if ( is_numeric( $CompanyID ) )
529 {
530 if ( isset( $DeleteImage ) )
531 {
532 print( "deleteimage $CompanyID" );
533 eZCompany::deleteImage( $CompanyID );
534 }
535
536 if ( isset( $DeleteLogo ) )
537 {
538 print( "deletelogo $CompanyID" );
539 eZCompany::deleteLogo( $CompanyID );
540 }
541 }
542
543 if ( $error && isset( $OK ) )
544 {
545 $t->set_var( "action_value", $Action );
546 $t->parse( "errors_item", "errors_tpl" );
547 }
548 }
549
550 if ( $error == false || isset( $RefreshUsers ) )
551 {
552 $t->set_var( "errors_item", "" );
553 }
554 else
555 {
556 $Action = "formdata";
557 }
558
559 if ( ( $Action == "insert" || $Action == "update" ) && !$error && isset( $OK ) )
560 {
561 if ( $CompanyEdit )
562 {
563 if ( $Action == "insert" )
564 $company = new eZCompany();
565 else
566 $company = new eZCompany( $CompanyID );
567
568 $company->setName( $Name );
569
570 $company->setCompanyNo( $CompanyNo );
571 if ( $ContactPersonType == "ezperson" )
572 $company->setPersonContact( $ContactID );
573 else
574 $company->setContact( $ContactID );
575 $company->setComment( $Comment );
576 $company->store();
577
578 $item_id = $company->id();
579 $CompanyID = $item_id;
580
581 // Update categories
582 $company->removeCategories();
583 $category = new eZCompanyType();
584 if ( count( $CompanyCategoryID ) > 0 )
585 {
586 for ( $i = 0; $i < count( $CompanyCategoryID ); $i++ )
587 {
588 $category->get( $CompanyCategoryID[$i] );
589 $category->addCompany( $company );
590 }
591 }
592 else
593 {
594 $category->get( 0 );
595 $category->addCompany( $company );
596 }
597 $item_cat_id = $CompanyCategoryID[0];
598
599 // Upload images
600 $file = new eZPBImageFile();
601 if ( $file->getUploadedFile( "logo" ) )
602 {
603 $logo = new eZImage();
604 $logo->setName( "Logo" );
605 if ( $logo->checkImage( $file ) and $logo->setImage( $file ) )
606 {
607 $logo->store();
608 $company->setLogoImage( $logo );
609 }
610 else
611 {
612 $company->deleteLogo();
613 }
614 }
615 else
616 {
617 print( $file->name() . " not uploaded successfully" );
618 }
619
620 // Upload images
621 $file = new eZPBImageFile();
622 if ( $file->getUploadedFile( "image" ) )
623 {
624 $image = new eZImage( );
625 $image->setName( "Image" );
626 if ( $image->checkImage( $file ) and $image->setImage( $file ) )
627 {
628 $image->store();
629 $company->setCompanyImage( $image );
630 }
631 else
632 {
633 $company->deleteImage();
634 }
635 }
636 else
637 {
638 print( $file->name() . " not uploaded successfully" );
639 }
640 $item =& $company;
641 }
642 else
643 {
644 $person = new eZPerson( $PersonID, true );
645 $person->setFirstName( $FirstName );
646 $person->setLastName( $LastName );
647
648 if ( $BirthYear != "" )
649 {
650 $Birth = new eZDate( $BirthYear, $BirthMonth, $BirthDay );
651 $person->setBirthDay( $Birth->timeStamp() );
652 }
653 else
654 {
655 $person->setNoBirthDay();
656 }
657 // $person->setContact( $ContactID );
658 $person->setComment( $Comment );
659
660 if ( $DeleteImage == "on" )
661 $person->setImage(0);
662
663 $person->store();
664
665 // Upload images
666 $file = new eZPBImageFile();
667 if ( $file->getUploadedFile( "ImageFile" ) )
668 {
669 $image = new eZImage( );
670 $image->setName( "Image" );
671 if ( $image->checkImage( $file ) and $image->setImage( $file ) )
672 {
673 $image->store();
674 $person->setImage( $image, $person->id() );
675 }
676 }
677 $person->store();
678
679 $person->removeCompanies();
680
681 if( !isset( $CompanyID ) )
682 $CompanyID = array();
683 for ( $i = 0; $i < count( $CompanyID ); $i++ )
684 {
685 (new eZCompany())->addPerson( $person->id(), $CompanyID[$i] );
686 }
687
688 $item_id = $person->id();
689 $PersonID = $item_id;
690 $item_cat_id = "";
691
692 $item =& $person;
693 //var_dump($item);
694 }
695
696 $item->setProjectState( $ProjectID, $item->id() );
697
698 // address
699 $item->removeAddresses();
700 $count = max( count( $AddressTypeID ), count( $AddressID ),
701 count( $Street1 ), count( $Street2 ),
702 count( $Zip ), count( $Place ) );
703 for ( $i = 0; $i < $count; $i++ )
704 {
705 if ( $Street1[$i] != "" && $Place[$i] != "" &&
706 $Country[$i] != "" && $AddressTypeID != -1 )
707 {
708 if ( isset( $AddressDelete ) && !in_array( $i + 1, $AddressDelete ) && $AddressTypeID[$i] != -1 )
709 {
710 $address = new eZAddress();
711 $address->setStreet1( $Street1[$i] );
712 $address->setStreet2( $Street2[$i] );
713 $address->setZip( $Zip[$i] );
714 $address->setPlace( $Place[$i] );
715 $address->setAddressType( $AddressTypeID[$i] );
716 $address->setCountry( $Country[$i] );
717 $address->store();
718
719 $item->addAddress( $address );
720 }
721 }
722 }
723
724 $item->removePhones();
725 $count = max( count( $PhoneID ), count( $Phone ) );
726 for ( $i = 0; $i < $count; $i++ )
727 {
728 if ( isset( $PhoneDelete ) && !in_array( $i + 1, $PhoneDelete ) && $Phone[$i] != "" )
729 {
730 $phone = new eZPhone( false, true );
731 $phone->setNumber( $Phone[$i] );
732 $phone->setPhoneTypeID( $PhoneTypeID[$i] );
733 $phone->store();
734
735 $item->addPhone( $phone );
736 }
737 }
738
739 $item->removeOnlines();
740 $count = max( count( $OnlineID ), count( $Online ) );
741 for ( $i = 0; $i < $count; $i++ )
742 {
743 if ( isset( $OnlineDelete ) && !in_array( $i + 1, $OnlineDelete ) && $Online[$i] != "" )
744 {
745 $online = new eZOnline( false, true );
746 $online->setURL( $Online[$i] );
747 $online->setOnlineTypeID( $OnlineTypeID[$i] );
748 $online->store();
749
750 $item->addOnline( $online );
751 }
752 }
753
754 if ( $CompanyEdit )
755 {
756 $CompanyID = $company->id();
757 $item_cat_id = $CompanyID;
758 }
759 else
760 {
761 $PersonID = $person->id();
762 $item_cat_id = $PersonID;
763 }
764
765 $t->set_var( "user_id", $UserID );
766 $t->set_var( "person_id", $PersonID );
767 $t->set_var( "company_id", $CompanyID );
768
769 // include_once( "classes/ezhttptool.php" );
770 eZHTTPTool::header( "Location: /contact/$item_type/view/$item_cat_id" );
771 }
772
773 /*
774 The user wants to edit an existing person.
775
776 We fetch the appropriate variables.
777 */
778
779 if ( $Action == "edit" )
780 {
781 if ( $CompanyEdit )
782 {
783 $company = new eZCompany( $CompanyID, true );
784 $item =& $company;
785
786 $Name = $company->name();
787 $Comment = $company->comment();
788 $CompanyNo = $company->companyNo();
789 }
790 else
791 {
792 $person = new eZPerson( $PersonID, true );
793 $item =& $person;
794
795 $FirstName = $person->firstName();
796 $LastName = $person->lastName();
797 if ( $person->hasBirthDate() )
798 {
799 $Birth = new eZDate();
800 $Birth->setTimeStamp( $person->birthDate() );
801 $BirthYear = $Birth->year();
802 $BirthMonth = $Birth->month();
803 $BirthDay = $Birth->day();
804 }
805 else
806 {
807 $BirthYear = "";
808 $BirthMonth = 1;
809 $BirthDay = 1;
810 }
811 $Comment = $person->comment();
812 $image =& $person->image( $person->id() );
813 if ( get_class( $image ) == "ezimage" && $image->id() != 0 )
814 {
815 $imageWidth =& $ini->variable( "eZContactMain", "PersonImageWidth" );
816 $imageHeight =& $ini->variable( "eZContactMain", "PersonImageHeight" );
817 $variation =& $image->requestImageVariation( $imageWidth, $imageHeight );
818 $imageURL = "/" . $variation->imagePath();
819 $imageWidth = $variation->width();
820 $imageHeight = $variation->height();
821 $imageCaption = $image->caption();
822 $t->set_var( "image_width", $imageWidth );
823 $t->set_var( "image_height", $imageHeight );
824 $t->set_var( "image_url", $imageURL );
825 $t->set_var( "image_caption", $imageCaption );
826 $t->parse( "image_item", "image_item_tpl" );
827 }
828 else
829 {
830 $t->set_var( "image_caption", '' );
831 $t->parse( "image_item", "image_item_tpl" );
832 }
833 }
834
835 $addresses = $item->addresses();
836 $i = 1;
837 foreach ( $addresses as $address )
838 {
839 $AddressTypeID[$i - 1] = $address->addressTypeID();
840 $AddressID[$i - 1] = $i;
841 $Street1[$i - 1] = $address->street1();
842 $Street2[$i - 1] = $address->street2();
843 $Zip[$i - 1] = $address->zip();
844 $Place[$i - 1] = $address->place();
845 $country = $address->country();
846 if ( $country )
847 $Country[$i - 1] = $country->id();
848 else
849 $Country[$i - 1] = -1;
850 $i++;
851 }
852
853 $phones = $item->phones();
854 $i = 1;
855 foreach ( $phones as $phone )
856 {
857 $PhoneTypeID[$i - 1] = $phone->phoneTypeID();
858 $PhoneID[$i - 1] = $i;
859 $Phone[$i - 1] = $phone->number();
860 $i++;
861 }
862
863 $onlines = $item->onlines();
864 $i = 1;
865 foreach ( $onlines as $online )
866 {
867 $OnlineTypeID[$i - 1] = $online->onlineTypeID();
868 $OnlineID[$i - 1] = $i;
869 $Online[$i - 1] = $online->url();
870 $i++;
871 }
872
873 $ContactID = $item->contact();
874 if ( is_a( $item, "eZCompany" ) )
875 $ContactType = $item->contactType();
876 else
877 $ContactType = "eZUser";
878 $ProjectID = $item->projectState();
879 }
880
881 /*
882 The user wants to create a new person/company.
883
884 We present an empty form.
885 */
886 if ( ( $Action == "new" || $Action == "formdata" || $Action == "edit" || isset( $RefreshUsers ) ) )
887 {
888 if ( isset( $OK ) )
889 {
890 if ( $Action == "edit" )
891 $Action = "update";
892 else if ( $Action == "new" )
893 $Action = "insert";
894 }
895
896 if ( $CompanyEdit )
897 {
898 $t->set_var( "company_id", $CompanyID );
899 $t->set_var( "user_id", $user->id() );
900
901 if( isset( $Name ) && isset( $CompanyNo ) && isset( $Comment ) )
902 {
903 $t->set_var( "name", eZTextTool::htmlspecialchars( $Name ) );
904 $t->set_var( "comment", eZTextTool::htmlspecialchars( $Comment ) );
905 $t->set_var( "companyno", eZTextTool::htmlspecialchars( $CompanyNo ) );
906 }
907 else
908 {
909 $t->set_var( "name", '' );
910 $t->set_var( "comment", '' );
911 $t->set_var( "companyno", '' );
912 }
913
914 // Company type selector
915 $companyTypeList = eZCompanyType::getTree();
916 $categoryList = array();
917
918 if ( $Action != "new" )
919 {
920 if ( !isset( $CompanyCategoryID ) )
921 $categoryList =& (new eZCompany())->categories( $CompanyID, false );
922 else
923 $categoryList = array( $CompanyCategoryID );
924 }
925 if ( isset( $NewCompanyCategory ) and !is_numeric( $NewCompanyCategory ) )
926 $NewCompanyCategory = 0;
927 if ( isset( $NewCompanyCategory ) and is_numeric( $NewCompanyCategory ) )
928 $categoryList =& array_unique( array_merge( array( $NewCompanyCategory ), $categoryList ) );
929 if ( isset( $CompanyCategoryID ) )
930 $categoryList =& array_unique( array_merge( array( $CompanyCategoryID ), $categoryList ) );
931 if ( isset( $categoryList ) && count( $categoryList ) > 0 )
932 $category_values = array_values( $categoryList );
933 else
934 $category_values = array();
935
936 $t->set_var( "is_top_selected", in_array( 0, $category_values ) ? "selected" : "" );
937 foreach ( $companyTypeList as $companyTypeItem )
938 {
939 $t->set_var( "company_type_name", eZTextTool::htmlspecialchars( $companyTypeItem[0]->name() ) );
940 $t->set_var( "company_type_id", $companyTypeItem[0]->id() );
941
942 if ( $companyTypeItem[1] > 0 )
943 $t->set_var( "company_type_level", str_repeat( "&nbsp;", $companyTypeItem[1] ) );
944 else
945 $t->set_var( "company_type_level", "" );
946
947 $t->set_var( "is_selected", in_array( $companyTypeItem[0]->id(), $category_values )
948 ? "selected" : "" );
949
950 $t->parse( "company_type_select", "company_type_select_tpl", true );
951 }
952
953 $t->parse( "company_item", "company_item_tpl" );
954 }
955 else
956 {
957 $t->set_var( "person_id", $PersonID );
958
959 $t->set_var( "user_id", $user->id() );
960 if ( isset( $FirstName ) )
961 $t->set_var( "firstname", eZTextTool::htmlspecialchars( $FirstName ) );
962 if ( isset( $LastName ) )
963 $t->set_var( "lastname", eZTextTool::htmlspecialchars( $LastName ) );
964
965 $top_name = $t->get_var( "intl-top_category" );
966 if ( !is_string( $top_name ) )
967 $top_name = "";
968 $companyTypeList = eZCompanyType::getTree( 0, 0, true, $top_name );
969 $categoryList = array();
970 $categoryList = eZPerson::companies( $PersonID, false );
971 $category_values = array_values( $categoryList );
972 $t->set_var( "is_top_selected", in_array( 0, $category_values ) ? "selected" : "" );
973 foreach ( $companyTypeList as $companyTypeItem )
974 {
975 $t->set_var( "company_name", "[" . eZTextTool::htmlspecialchars( $companyTypeItem[0]->name() ) . "]" );
976 $t->set_var( "company_id", "-1" );
977
978 $level = $companyTypeItem[1] > 0 ? str_repeat( "&nbsp;", $companyTypeItem[1] ) : "";
979 $t->set_var( "company_level", $level );
980 $t->set_var( "is_selected", "" );
981 $t->parse( "company_select", "company_select_tpl", true );
982
983 $level = str_repeat( "&nbsp;", $companyTypeItem[1] + 1 );
984 $t->set_var( "company_level", $level );
985
986 $companies = eZCompany::getByCategory( $companyTypeItem[0]->id() );
987 foreach ( $companies as $companyItem )
988 {
989 $t->set_var( "company_name", eZTextTool::htmlspecialchars( $companyItem->name() ) );
990 $t->set_var( "company_id", $companyItem->id() );
991 $t->set_var( "is_selected", in_array( $companyItem->id(), $category_values )
992 ? "selected" : "" );
993 $t->parse( "company_select", "company_select_tpl", true );
994 }
995 }
996
997 for ( $i = 1; $i <= 31; $i++ )
998 {
999 $t->set_var( "day_id", $i );
1000 $t->set_var( "day_value", $i );
1001 $t->set_var( "selected", "" );
1002 if ( ( $BirthDay == "" and $i == 1 ) or $BirthDay == $i )
1003 $t->set_var( "selected", "selected" );
1004 $t->parse( "day_item", "day_item_tpl", true );
1005 }
1006
1007 $birth_array = array( 1 => "select_january",
1008 2 => "select_february",
1009 3 => "select_march",
1010 4 => "select_april",
1011 5 => "select_may",
1012 6 => "select_june",
1013 7 => "select_july",
1014 8 => "select_august",
1015 9 => "select_september",
1016 10 => "select_october",
1017 11 => "select_november",
1018 12 => "select_december" );
1019
1020 foreach ( $birth_array as $month )
1021 {
1022 $t->set_var( $month, "" );
1023 }
1024
1025 $var_name =& $birth_array[$BirthMonth];
1026 if ( $var_name == "" )
1027 $var_name =& $birth_array[1];
1028
1029 $t->set_var( $var_name, "selected" );
1030 $t->set_var( "birthyear", $BirthYear );
1031 $t->set_var( "comment", $Comment );
1032
1033 $t->parse( "person_item", "person_item_tpl" );
1034 }
1035
1036 $phone_types =& eZPhoneType::getAll();
1037 $online_types =& eZOnlineType::getAll();
1038 $address_types =& eZAddressType::getAll();
1039 $countries =& eZCountry::getAllArray();
1040 if ( !isset( $PhoneDelete ) )
1041 {
1042 $PhoneDelete = array();
1043 }
1044 if ( !isset( $OnlineDelete ) )
1045 {
1046 $OnlineDelete = array();
1047 }
1048 if ( !isset( $AddressDelete ) )
1049 {
1050 $AddressDelete = array();
1051 }
1052
1053 $AddressMinimum = $ini->variable( "eZContactMain", "AddressMinimum" );
1054 $PhoneMinimum = $ini->variable( "eZContactMain", "PhoneMinimum" );
1055 $OnlineMinimum = $ini->variable( "eZContactMain", "OnlineMinimum" );
1056 $AddressWidth = $ini->variable( "eZContactMain", "AddressWidth" );
1057 $PhoneWidth = $ini->variable( "eZContactMain", "PhoneWidth" );
1058 $OnlineWidth = $ini->variable( "eZContactMain", "OnlineWidth" );
1059
1060 if ( isset( $NewAddress ) )
1061 {
1062 $AddressTypeID[] = "";
1063 $AddressID[] = count( $AddressID ) > 0 ? $AddressID[count( $AddressID ) - 1] + 1 : 1;
1064 $Street1[] = "";
1065 $Street2[] = "";
1066 $Zip[] = "";
1067 $Place[] = "";
1068 $Country[] = count( $Country ) > 0 ? $Country[count( $Country ) - 1] : "";
1069
1070 $count = max( count( $AddressTypeID ), count( $AddressID ),
1071 count( $Street1 ), count( $Street2 ),
1072 count( $Zip ), count( $Place ) );
1073 }
1074 else
1075 {
1076 $count = false;
1077 $Zip = array();
1078 }
1079 $item = 0;
1080 $AddressDeleteValues =& array_values( $AddressDelete );
1081 $last_id = 0;
1082 for ( $i = 0; $i < $count || $item < $AddressMinimum; $i++ )
1083 {
1084 if ( ( $item % $AddressWidth == 0 ) && $item > 0 )
1085 {
1086 $t->parse( "address_table_item", "address_table_item_tpl", true );
1087 $t->set_var( "address_item" );
1088 }
1089 if ( !isset( $AddressID[$i] ) or !is_numeric( $AddressID[$i] ) )
1090 $AddressID[$i] = ++$last_id;
1091 if ( !in_array( $AddressID[$i], $AddressDeleteValues ) )
1092 {
1093 $last_id = $AddressID[$i];
1094 if( isset( $Street1[$i] ) )
1095 $t->set_var( "street1", eZTextTool::htmlspecialchars( $Street1[$i] ) );
1096 else
1097 $t->set_var( "street1", '' );
1098
1099 if( isset( $Street2[$i] ) )
1100 $t->set_var( "street2", eZTextTool::htmlspecialchars( $Street2[$i] ) );
1101 else
1102 $t->set_var( "street2", '' );
1103 if( isset( $Zip[$i] ) )
1104 $t->set_var( "zip", eZTextTool::htmlspecialchars( $Zip[$i] ) );
1105 else
1106 $t->set_var( "zip", '' );
1107 if( isset( $Place[$i] ) )
1108 $t->set_var( "place", eZTextTool::htmlspecialchars( $Place[$i] ) );
1109 else
1110 $t->set_var( "place", '' );
1111 $t->set_var( "address_id", $AddressID[$i] );
1112 $t->set_var( "address_index", $AddressID[$i] );
1113 $t->set_var( "address_position", $i + 1 );
1114
1115 $t->set_var( "address_item_select", "" );
1116
1117 foreach ( $address_types as $address_type )
1118 {
1119 $t->set_var( "type_id", $address_type->id() );
1120 $t->set_var( "type_name", eZTextTool::htmlspecialchars( $address_type->name() ) );
1121 $t->set_var( "selected", "" );
1122 if ( isset( $AddressTypeID ) && $address_type->id() == $AddressTypeID[$i] )
1123 $t->set_var( "selected", "selected" );
1124 $t->parse( "address_item_select", "address_item_select_tpl", true );
1125 }
1126 $t->set_var( "country_item_select", "" );
1127 $t->set_var( "no_country_selected", "" );
1128 foreach ( $countries as $country )
1129 {
1130 $t->set_var( "type_id", $country["ID"] );
1131 $t->set_var( "type_name", eZTextTool::htmlspecialchars( $country["Name"] ) );
1132 $t->set_var( "selected", "" );
1133 if ( isset( $Country ) && $Country[$i] == -1 )
1134 $t->set_var( "no_country_selected", "selected" );
1135 else if ( isset( $Country ) && $country["ID"] == $Country[$i] )
1136 $t->set_var( "selected", "selected" );
1137 $t->parse( "country_item_select", "country_item_select_tpl", true );
1138 }
1139
1140 $t->parse( "address_item", "address_item_tpl", true );
1141 $item++;
1142 }
1143 else
1144 $AddressDeleteValues = array_diff( $AddressDeleteValues, array( $AddressID[$i] ) );
1145 }
1146 $t->parse( "address_table_item", "address_table_item_tpl", true );
1147
1148 // $t->parse( "address_item", "address_item_tpl" );
1149
1150 if ( isset( $NewPhone ) )
1151 {
1152 $PhoneTypeID[] = "";
1153 $PhoneID[] = count( $PhoneID ) > 0 ? $PhoneID[count( $PhoneID ) - 1] + 1 : 1;
1154 $Phone[] = "";
1155 $count = max( count( $PhoneTypeID ), count( $PhoneID ), count( $Phone ) );
1156 }
1157 else
1158 {
1159 $count = false;
1160 }
1161 $item = 0;
1162 $last_id = 0;
1163 $PhoneDeleteValues =& array_values( $PhoneDelete );
1164 for ( $i = 0; $i < $count || $item < $PhoneMinimum; $i++ )
1165 {
1166 if ( ( $item % $PhoneWidth == 0 ) && $item > 0 )
1167 {
1168 $t->parse( "phone_table_item", "phone_table_item_tpl", true );
1169 $t->set_var( "phone_item" );
1170 }
1171 if ( !isset( $PhoneID[$i] ) or !is_numeric( $PhoneID[$i] ) )
1172 $PhoneID[$i] = ++$last_id;
1173 if ( !in_array( $PhoneID[$i], $PhoneDeleteValues ) )
1174 {
1175 $last_id = $PhoneID[$i];
1176 if( isset( $Phone[$i] ) )
1177 {
1178 $t->set_var( "phone_number", eZTextTool::htmlspecialchars( $Phone[$i] ) );
1179 $t->set_var( "phone_id", $PhoneID[$i] );
1180 $t->set_var( "phone_index", $PhoneID[$i] );
1181 }
1182 else
1183 {
1184 $t->set_var( "phone_number", '' );
1185 $t->set_var( "phone_id", '' );
1186 $t->set_var( "phone_index", '' );
1187 }
1188 $t->set_var( "phone_position", $i + 1 );
1189
1190 $t->set_var( "phone_item_select", "" );
1191
1192 foreach ( $phone_types as $phone_type )
1193 {
1194 $t->set_var( "type_id", $phone_type->id() );
1195 $t->set_var( "type_name", eZTextTool::htmlspecialchars( $phone_type->name() ) );
1196 $t->set_var( "selected", "" );
1197 if ( isset( $PhoneTypeID ) && $phone_type->id() == $PhoneTypeID[$i] )
1198 $t->set_var( "selected", "selected" );
1199 $t->parse( "phone_item_select", "phone_item_select_tpl", true );
1200 }
1201
1202 $t->parse( "phone_item", "phone_item_tpl", true );
1203 $item++;
1204 }
1205 else
1206 $PhoneDeleteValues = array_diff( $PhoneDeleteValues, array( $PhoneID[$i] ) );
1207 }
1208 $t->parse( "phone_table_item", "phone_table_item_tpl", true );
1209
1210 if ( isset( $NewOnline ) )
1211 {
1212 $OnlineTypeID[] = "";
1213 $OnlineID[] = count( $OnlineID ) > 0 ? $OnlineID[count( $OnlineID ) - 1] + 1 : 1;
1214 $Online[] = "";
1215 $count = max( count( $OnlineTypeID ), count( $OnlineID ), count( $Online ) );
1216 }
1217 else
1218 {
1219 $count = false;
1220 }
1221 $item = 0;
1222 $last_id = 0;
1223 $OnlineDeleteValues =& array_values( $OnlineDelete );
1224 for ( $i = 0; $i < $count || $item < $OnlineMinimum; $i++ )
1225 {
1226 if ( ( $item % $OnlineWidth == 0 ) && $item > 0 )
1227 {
1228 $t->parse( "online_table_item", "online_table_item_tpl", true );
1229 $t->set_var( "online_item" );
1230 }
1231 if ( !isset( $OnlineID[$i] ) or !is_numeric( $OnlineID[$i] ) )
1232 $OnlineID[$i] = ++$last_id;
1233 if ( !in_array( $OnlineID[$i], $OnlineDeleteValues ) )
1234 {
1235 $last_id = $OnlineID[$i];
1236 if( isset( $Online[$i] ) )
1237 {
1238 $t->set_var( "online_value", eZTextTool::htmlspecialchars( $Online[$i] ) );
1239 $t->set_var( "online_id", $OnlineID[$i] );
1240 $t->set_var( "online_index", $OnlineID[$i] );
1241 }
1242 else
1243 {
1244 $t->set_var( "online_value", '' );
1245 $t->set_var( "online_id", '' );
1246 $t->set_var( "online_index", '' );
1247 }
1248 $t->set_var( "online_position", $i + 1 );
1249
1250 $t->set_var( "online_item_select", "" );
1251
1252 foreach ( $online_types as $online_type )
1253 {
1254 $t->set_var( "type_id", $online_type->id() );
1255 $t->set_var( "type_name", eZTextTool::htmlspecialchars( $online_type->name() ) );
1256 $t->set_var( "selected", "" );
1257 if ( isset( $OnlineTypeID ) && $online_type->id() == $OnlineTypeID[$i] )
1258 $t->set_var( "selected", "selected" );
1259 $t->parse( "online_item_select", "online_item_select_tpl", true );
1260 }
1261
1262 $t->parse( "online_item", "online_item_tpl", true );
1263 $item++;
1264 }
1265 else
1266 $OnlineDeleteValues = array_diff( $OnlineDeleteValues, array( $OnlineID[$i] ) );
1267 }
1268 $t->parse( "online_table_item", "online_table_item_tpl", true );
1269
1270 $groups =& eZUserGroup::getAll();
1271 foreach ( $groups as $group )
1272 {
1273 $t->set_var( "type_id", $group->id() );
1274 $t->set_var( "type_name", eZTextTool::htmlspecialchars( $group->name() ) );
1275 $t->set_var( "selected", "" );
1276 if ( isset( $ContactGroupID ) && $ContactGroupID == $group->id() )
1277 $t->set_var( "selected", "selected" );
1278 $t->parse( "contact_group_item_select", "contact_group_item_select_tpl", true );
1279 }
1280
1281 $t->set_var( "project_contact_item", "" );
1282 if ( $CompanyEdit )
1283 {
1284 if( isset( $UserSearch ) )
1285 $t->set_var( "user_search", eZTextTool::htmlspecialchars( $UserSearch ) );
1286 else
1287 $t->set_var( "user_search", '' );
1288
1289 $users = array();
1290 if ( isset( $ContactGroupID ) && $ContactGroupID == -1 )
1291 {
1292 $users =& eZUser::getAll( "name", true, $UserSearch );
1293 }
1294 else if ( isset( $ContactGroupID ) && $ContactGroupID == -3 )
1295 {
1296 $users =& eZPerson::getAll( $UserSearch, 0, -1 );
1297 }
1298 else if ( isset( $ContactGroupID ) && $ContactGroupID < 1 )
1299 {
1300 if ( is_numeric( $ContactID ) and $ContactID > 0 )
1301 {
1302 if ( $ContactType == "eZPerson" )
1303 $contact = new eZPerson( $ContactID );
1304 else
1305 $contact = new eZUser( $ContactID );
1306 $users[] = $contact;
1307 }
1308 }
1309 else
1310 {
1311 $group = new eZUserGroup();
1312 $users =& $group->users( isset( $ContactGroupID ) ? $ContactGroupID : false, "name", isset( $UserSearch ) ? $UserSearch : false );
1313 }
1314 foreach ( $users as $contact )
1315 {
1316 if ( is_a( $contact, "eZUser" ) ||
1317 is_a( $contact, "eZPerson" ) )
1318 {
1319 $t->set_var( "type_id", $contact->id() );
1320 $t->set_var( "type_firstname", eZTextTool::htmlspecialchars( $contact->firstName() ) );
1321 $t->set_var( "type_lastname", eZTextTool::htmlspecialchars( $contact->lastName() ) );
1322 $t->set_var( "selected", "" );
1323 if ( $ContactID == $contact->id() )
1324 $t->set_var( "selected", "selected" );
1325 }
1326 $t->parse( "contact_item_select", "contact_item_select_tpl", true );
1327 }
1328 if ( count( $users ) > 0 )
1329 $t->set_var( "contact_person_type", is_a( $users[0], "eZUser" )? "eZUser" : "eZPerson" );
1330 else
1331 $t->set_var( "contact_person_type", "" );
1332
1333 $t->set_var( "none_selected", "" );
1334 $t->set_var( "all_selected", "" );
1335 $t->set_var( "persons_selected", "" );
1336 if ( isset( $ContactGroupID ) && $ContactGroupID == -1 )
1337 {
1338 $t->set_var( "all_selected", "selected" );
1339 }
1340 else if ( isset( $ContactGroupID ) && $ContactGroupID == -3 )
1341 {
1342 $t->set_var( "persons_selected", "selected" );
1343 }
1344 else if ( isset( $ContactGroupID ) && $ContactGroupID < 1 )
1345 {
1346 $t->set_var( "none_selected", "selected" );
1347 }
1348
1349 $t->parse( "project_contact_item", "project_contact_item_tpl" );
1350 }
1351
1352 $t->set_var( "project_item_select", "" );
1353 $project_types =& eZProjectType::findTypes();
1354 foreach ( $project_types as $project_type )
1355 {
1356 $t->set_var( "type_id", $project_type->id() );
1357 $t->set_var( "type_name", eZTextTool::htmlspecialchars( $project_type->name() ) );
1358 $t->set_var( "selected", "" );
1359 if ( isset( $ProjectID ) && $ProjectID == $project_type->id() )
1360 $t->set_var( "selected", "selected" );
1361 $t->parse( "project_item_select", "project_item_select_tpl", true );
1362 }
1363
1364 $t->parse( "project_item", "project_item_tpl", true );
1365
1366 if ( $CompanyEdit )
1367 {
1368 // View logo.
1369 $logoImage = eZCompany::logoImage( $CompanyID );
1370 if ( isset( $LogoImageID ) && is_numeric( $LogoImageID ) )
1371 {
1372 $logoImage = new eZImage( $LogoImageID );
1373 }
1374
1375 $t->set_var( "logo_item", "&nbsp;" );
1376 if ( ( is_a( $logoImage, "eZImage" ) ) && ( $logoImage->id() != 0 ) )
1377 {
1378 $variation = $logoImage->requestImageVariation( 150, 150 );
1379 if ( is_a( $variation, "eZImageVariation" ) )
1380 {
1381 $t->set_var( "logo_image_src", "/" . $variation->imagePath() );
1382
1383 $t->set_var( "logo_image_width", $variation->width() );
1384 $t->set_var( "logo_image_height", $variation->height() );
1385 $t->set_var( "logo_image_alt", eZTextTool::htmlspecialchars( $logoImage->caption() ) );
1386 $t->set_var( "logo_name", eZTextTool::htmlspecialchars( $logoImage->name() ) );
1387 $t->set_var( "logo_id", $logoImage->id() );
1388
1389 $t->parse( "logo_item", "logo_item_tpl" );
1390 }
1391 }
1392 else
1393 {
1394 $t->set_var( "logo_id", "" );
1395 $t->set_var( "image_id", "" );
1396 }
1397
1398 // View company image.
1399 $companyImage = eZCompany::companyImage( $CompanyID );
1400 if ( isset( $CompanyImageID ) && is_numeric( $CompanyImageID ) )
1401 {
1402 $companyImage = new eZImage( $CompanyImageID );
1403 }
1404
1405 $t->set_var( "image_item", "&nbsp;" );
1406 if ( ( is_a( $companyImage, "eZImage" ) ) && ( $companyImage->id() != 0 ) )
1407 {
1408 $variation = $companyImage->requestImageVariation( 150, 150 );
1409 if ( is_a( $variation, "eZImageVariation" ) )
1410 {
1411 $t->set_var( "image_src", "/" . $variation->imagePath() );
1412 $t->set_var( "image_width", $variation->width() );
1413 $t->set_var( "image_height", $variation->height() );
1414 $t->set_var( "image_alt", eZTextTool::htmlspecialchars( $companyImage->caption() ) );
1415 $t->set_var( "image_name", eZTextTool::htmlspecialchars( $companyImage->name() ) );
1416 $t->set_var( "image_id", $companyImage->id() );
1417 $t->set_var( "image_caption", '' );
1418
1419 $t->parse( "image_item", "image_item_tpl" );
1420 }
1421 }
1422 }
1423 }
1424
1425 // Template variables.
1426
1427 if ( isset( $CompanyID ) && is_numeric( $CompanyID ) || isset( $PersonID ) && is_numeric( $PersonID ) )
1428 $t->parse( "delete_item", "delete_item_tpl" );
1429 else
1430 $t->set_var( "delete_item", "" );
1431
1432 if ( !$error )
1433 $t->set_var( "action_value", $Action );
1434
1435 $t->parse( "edit_item", "edit_tpl" );
1436 }
1437
1438 $t->pparse( "output", "person_edit" );
1439
1440 ?>
$item_type
$item_type
Definition: addresstypeedit.php:31
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$i
$i
Definition: admin/adlist.php:91
$categoryList
foreach( $pathArray as $path) $categoryList
Definition: admin/adlist.php:86
$group
$group
Definition: admin/articleedit.php:799
$companies
else $companies
Definition: admin/consultationlist.php:221
$level
$level
Definition: admin/message.php:106
$LastName
$LastName
Definition: admin/useredit.php:416
$FirstName
$FirstName
Definition: admin/useredit.php:415
$Phone
$Phone
Definition: admin/useredit.php:443
$month
else $month
Definition: appointmentedit.php:660
$address
$address
Definition: checkout.php:588
eZAddressType\getAll
static & getAll( $as_object=true)
Definition: ezaddresstype.php:163
eZAddress
Definition: ezaddress.php:42
eZCompany
Definition: ezcompany.php:54
eZCompany\delete
delete( $id=false)
Definition: ezcompany.php:134
eZCompany\getByCategory
& getByCategory( $categoryID, $offset=0, $limit=-1, $order="name")
Definition: ezcompany.php:277
eZCompany\logoImage
static logoImage( $id=false)
Definition: ezcompany.php:722
eZCompany\deleteLogo
deleteLogo( $id=false)
Definition: ezcompany.php:801
eZCompany\companyImage
static companyImage( $id=false)
Definition: ezcompany.php:856
eZCompany\deleteImage
deleteImage( $id=false)
Definition: ezcompany.php:786
eZCountry\getAllArray
static & getAllArray()
Definition: ezcountry.php:196
eZDate
Definition: ezdate.php:46
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZImage
Definition: ezimage.php:95
eZImage\caption
caption( $html=true)
Definition: ezimage.php:737
eZImage\name
& name( $html=true)
Definition: ezimage.php:715
eZImage\requestImageVariation
requestImageVariation( $width, $height, $convertToGray=false, $allow_error=false)
Definition: ezimage.php:909
eZImage\id
id()
Definition: ezimage.php:704
eZPBFile\dir
static dir( $dir, $add_sitedir=true)
Definition: ezpbfile.php:384
eZPBFile\unlink
static unlink( $filename)
Definition: ezpbfile.php:352
eZPBImageFile
Definition: ezpbimagefile.php:71
eZPermission\checkPermission
static checkPermission( $user, $moduleName, $permissionName)
Definition: ezpermission.php:430
eZPerson
Definition: ezperson.php:43
eZPerson\delete
static delete( $id=false)
Definition: ezperson.php:133
eZPerson\companies
static companies( $id=false, $as_object=true)
Definition: ezperson.php:1028
eZPerson\getAll
getAll( $search_types="", $limit_index=0, $limit=1, $cond="all")
Definition: ezperson.php:335
eZPhoneType\getAll
static getAll( $as_object=true, $offset=0, $max=-1)
Definition: ezphonetype.php:173
eZPhone
Definition: ezphone.php:39
eZProjectType\findTypes
static & findTypes( $as_object=true)
Definition: ezprojecttype.php:262
eZTemplate
Definition: eztemplate.php:107
eZTextTool\htmlspecialchars
static htmlspecialchars( $string)
Definition: eztexttool.php:144
eZUserGroup
Definition: ezusergroup.php:66
eZUserGroup\getAll
static & getAll( $as_object=true)
Definition: ezusergroup.php:197
eZUser
Definition: ezuser.php:76
eZUser\getAll
static & getAll( $order="Login", $as_object=true, $search=false, $max=-1, $index=0)
Definition: ezuser.php:330
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$item
$item
Definition: classes/admin/linklist.php:228
$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
$id
$id
Definition: companytypelist.php:193
$logoImage
$logoImage
Definition: companyview.php:168
$companyImage
if((is_a( $logoImage, "eZImage")) &&( $logoImage->id() !=0)) $companyImage
Definition: companyview.php:190
$categories
$categories
Definition: ezarticle/admin/categoryedit.php:636
$groups
if( $CategoryID !=0) $groups
Definition: ezbulkmail/admin/categoryedit.php:108
$SiteDesign
$SiteDesign
Definition: ezbulkmail/user/datasupplier.php:31
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
$users
$users
Definition: ezmessage/admin/messageedit.php:138
$dir
$dir
Definition: ezsitemanager/admin/filelist.php:87
exit
exit
Definition: folder.php:81
$category_values
$category_values
Definition: link.php:85
$companyTypeList
$companyTypeList
Definition: link.php:77
$top_name
$top_name
Definition: link.php:74
$count
$count
Definition: onlinetypelist.php:108
$Comment
$Comment
Definition: payment.php:133
$country
$country
Definition: paypal.php:46
$t
$t
Definition: personedit.php:241
$confirm
$confirm
Definition: personedit.php:306
$user
$user
Definition: personedit.php:66
$language_file
$language_file
Definition: personedit.php:238
$Language
$Language
Definition: personedit.php:34
$ini
$ini
Definition: personedit.php:33
unlinkWild
unlinkWild( $dir, $rege)
Definition: personedit.php:54
$item_id
$item_id
Definition: personedit.php:76
deleteCache
deleteCache( $SiteDesign)
Definition: personedit.php:49
$error
if(!is_a( $user, "eZUser")) if(isset( $BuyButton)) if(isset( $OK)) if(isset( $ListConsultation)) if(isset( $NewConsultation)) if(isset( $FileButton)) if(isset( $Back)) if(isset( $Delete)) if(isset( $Action) && $Action=="delete") if(isset( $OK)) $error
Definition: personedit.php:228
$person
switch( $LimitType) $person
Definition: personlist.php:137
$Name
$Name
Definition: polledit.php:250
$UserID
$UserID
Definition: todoedit.php:122
$image
$image
Definition: user/articlelist.php:242
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.