Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezmail.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezmail.php 9884 2003-08-21 10:12:50Z vl $
5 //
6 // Definition of eZMail class
7 //
8 // Created on: <15-Mar-2001 20:40:06 fh>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
31
45 // include_once( "ezmail/classes/ezmailfolder.php" );
46 // include_once( "ezfilemanager/classes/ezvirtualfile.php" );
47 // include_once( "ezimagecatalogue/classes/ezimage.php" );
48
49 /* DEFINES */
50 define( "UNREAD", 0 );
51 define( "READ", 1 );
52 define( "REPLIED", 2 );
53 define( "FORWARDED", 3 );
54 define( "MAIL_SENT", 4 );
55
56 class eZMail
57 {
64 function __construct( $id = "" )
65 {
66 $this->FilesAttached = false;
67
68 // array used when sending mail.. do not alter!!!
69 $this->parts = array();
70 if ( $id != "" )
71 {
72
73 $this->ID = $id;
74 $this->get( $this->ID );
75 }
76 else
77 {
78 // default values
79 $this->IsPublished = 0;
80 $this->UDate = time();
81 }
82 }
83
87 function delete( $id = -1 )
88 {
89 $db =& eZDB::globalDatabase();
90 $db->begin();
91 if ( $id == -1 )
92 $id = $this->ID;
93
94 // DELETE ALL ATTACHMENTS
95 $res[] = $db->query( "DELETE FROM eZMail_Mail WHERE ID='$id'" );
96 $res[] = $db->query( "DELETE FROM eZMail_MailFolderLink WHERE MailID='$id'" );
97
98 eZDB::finish( $res, $db );
99 return true;
100 }
101
105 function store()
106 {
107 $db =& eZDB::globalDatabase();
108
109 $to = $db->escapeString( $this->To );
110 $from = $db->escapeString( $this->From );
111 $cc = $db->escapeString( $this->Cc );
112 $bcc = $db->escapeString( $this->Bcc );
113 $references = $db->escapeString( $this->References );
114 $replyto = $db->escapeString( $this->ReplyTo );
115 $subject = $db->escapeString( $this->Subject );
116 $body = $db->escapeString( $this->BodyText );
117 $db->begin();
118 if ( !isset( $this->ID ) )
119 {
120 $db->lock( "eZMail_Mail" );
121 $nextID = $db->nextID( "eZMail_Mail", "ID" );
122 $result = $db->query( "INSERT INTO eZMail_Mail ( ID, UserID, ToField, FromField, Cc, Bcc,
123 MessageID, Reference, ReplyTo, Subject, BodyText, Status, Size, UDate )
124 VALUES (
125 '$nextID',
126 '$this->UserID',
127 '$to',
128 '$from',
129 '$cc',
130 '$bcc',
131 '$this->MessageID',
132 '$references',
133 '$replyto',
134 '$subject',
135 '$body',
136 '$this->Status',
137 '$this->Size',
138 '$this->UDate'
139 )
140 " );
141 $db->unlock();
142 $this->ID = $nextID;
143 }
144 else
145 {
146 $result = $db->query( "UPDATE eZMail_Mail SET
147 UserID='$this->UserID',
148 ToField='$to',
149 FromField='$from',
150 Cc='$cc',
151 Bcc='$bcc',
152 MessageID='$this->MessageID',
153 Reference='$references',
154 ReplyTo='$replyto',
155 Subject='$subject',
156 BodyText='$body',
157 Status='$this->Status',
158 Size='$this->Size',
159 UDate='$this->UDate'
160 WHERE ID='$this->ID'
161 " );
162 }
163 if ( $result == false )
164 $db->rollback( );
165 else
166 $db->commit();
167
168 return true;
169 }
170
171 function removeContacts( $mailID )
172 {
173 $db =& eZDB::globalDatabase();
174 $db->begin();
175 $res[] = $db->query( "DELETE FROM eZMail_MailContactLink WHERE MailID='$mailID'" );
176 eZDB::finish( $res, $db );
177 }
178
179 function addContact( $mailID, $contactID, $companyEdit = true )
180 {
181 if ( $companyEdit )
182 $contact = "CompanyID";
183 else
184 $contact = "PersonID";
185 $db =& eZDB::globalDatabase();
186 $db->begin();
187 $db->lock( "eZMail_MailContactLink" );
188 $nextID = $db->nextID( "eZMail_MailContactLink", "ID" );
189 $res[] = $db->query( "INSERT INTO eZMail_MailContactLink
190 (ID, MailID, $contact)
191 VALUES
192 ('$nextID', '$mailID', '$contactID')" );
193 $db->unlock();
194 eZDB::finish( $res, $db );
195 }
196
200 function get( $id = "" )
201 {
202 $db =& eZDB::globalDatabase();
203 $ret = false;
204
205 if ( $id != "" )
206 {
207 $db->array_query( $mail_array, "SELECT * FROM eZMail_Mail WHERE ID='$id'" );
208 if ( count( $mail_array ) > 1 )
209 {
210 die( "Error: Mails with the same ID was found in the database. This should not happen." );
211 }
212 else if ( count( $mail_array ) == 1 )
213 {
214 $this->ID = $mail_array[0][ $db->fieldName("ID") ];
215 $this->UserID = $mail_array[0][ $db->fieldName("UserID") ];
216 $this->To = $mail_array[0][ $db->fieldName("ToField") ];
217 $this->From = $mail_array[0][ $db->fieldName("FromField") ];
218 $this->FromName = $mail_array[0][ $db->fieldName("FromName") ];
219 $this->Cc = $mail_array[0][ $db->fieldName("Cc") ];
220 $this->Bcc = $mail_array[0][ $db->fieldName("Bcc") ];
221 $this->MessageID = $mail_array[0][ $db->fieldName("MessageID") ];
222 $this->References = $mail_array[0][ $db->fieldName("Reference") ];
223 $this->ReplyTo = $mail_array[0][ $db->fieldName("ReplyTo") ];
224 $this->Subject = $mail_array[0][ $db->fieldName("Subject") ];
225 $this->BodyText = $mail_array[0][ $db->fieldName("BodyText") ];
226 $this->Status = $mail_array[0][ $db->fieldName("Status") ];
227 $this->Size = $mail_array[0][ $db->fieldName("Size") ];
228 $this->UDate = $mail_array[0][ $db->fieldName("UDate") ];
229
230 $ret = true;
231 $this->FilesAttached = true;
232 }
233 }
234 return $ret;
235 }
236
240 function id()
241 {
242 return $this->ID;
243 }
244
248 function to()
249 {
250 return $this->To;
251 }
252
256 function setTo( $newTo )
257 {
258 $this->To = $newTo;
259 }
260
261
265 function replyTo()
266 {
267 return $this->ReplyTo;
268 }
269
273 function setReplyTo( $newReplyTo )
274 {
275 $this->ReplyTo = $newReplyTo;
276 }
277
278
282 function receiver()
283 {
284 return $this->To;
285 }
286
290 function setReceiver( $newReceiver )
291 {
292 $this->To = $newReceiver;
293 }
294
295
299 function from()
300 {
301 return $this->From;
302 }
303
304
308 function setFrom( $newFrom )
309 {
310 $this->From = $newFrom;
311 }
312
316 function cc()
317 {
318 return $this->Cc;
319 }
320
324 function setCc( $newCc )
325 {
326 $this->Cc = $newCc;
327 }
328
332 function bcc()
333 {
334 return $this->Bcc;
335 }
336
340 function setBcc( $newBcc )
341 {
342 $this->Bcc = $newBcc;
343 }
344
349 function messageID()
350 {
351 return $this->MessageID;
352 }
353
357 function setMessageID( $newMessageID )
358 {
359 $this->MessageID = $newMessageID;
360 }
361
365 function references()
366 {
367 return $this->References;
368 }
369
373 function setReferences( $newReference )
374 {
375 $this->References = $newReference;
376 }
377
381 function fromName()
382 {
383 return $this->FromName;
384 }
385
389 function setFromName( $newFrom )
390 {
391 $this->FromName = $newFrom;
392 }
393
397 function sender()
398 {
399 return $this->From;
400 }
401
405 function setSender( $newSender )
406 {
407 $this->From = $newSender;
408 }
409
413 function subject()
414 {
415 return $this->Subject;
416 }
417
421 function setSubject( $newSubject )
422 {
423 $this->Subject = trim( $newSubject );
424 }
425
429 function body()
430 {
431 return $this->BodyText;
432 }
433
437 function setBody( $newBody )
438 {
439 $this->BodyText = $newBody;
440 }
441
442
446 function setBodyText( $newBody )
447 {
448 $this->BodyText = $newBody;
449 }
450
454 function owner()
455 {
456 return $this->UserID;;
457 }
458
462 function setOwner( $newOwner )
463 {
464
465 if ( is_a( $newOwner, "eZUser" ) )
466 $this->UserID = $newOwner->id();
467 else
468 $this->UserID = $newOwner;
469 }
470
474 function size()
475 {
476 return $this->Size;
477 }
478
486 function siSize()
487 {
488
489 $units = array( "GB" => 10737741824,
490 "MB" => 1048576,
491 "KB" => 1024,
492 "B" => 0 );
493 $decimals = 0;
494 $size = $this->Size;
495 $shortsize = $this->Size;
496 foreach( $units as $unit_key => $val )
497 {
498 if ( $size >= $val )
499 {
500 $unit = $unit_key;
501 if ( $val > 0 )
502 {
503 $decimals = 2;
504 $shortsize = $size / $val;
505 }
506 break;
507 }
508 }
509 $shortsize = number_format( ( $shortsize ), $decimals);
510 $size = array( "size" => $size,
511 "size-string" => $shortsize,
512 "unit" => $unit );
513 return $size;
514 }
515
519 function setSize( $value )
520 {
521 $this->Size = $value;
522 }
523
527 function uDate()
528 {
529 return $this->UDate;
530 }
531
535 function setUDate( $value )
536 {
537 $this->UDate = $value;
538 }
539
540 /*
541 Returns the status of this mail.
542 0 - UNREAD
543 1 - READ
544 2 - REPLIED
545 3 - FORWARDED
546 4 - MAIL_SENT
547 */
548 function status()
549 {
550 return $this->Status;
551 }
552
563 function setStatus( $status, $directWrite = false )
564 {
565 $this->Status = $status;
566 $db =& eZDB::globalDatabase();
567 if ( $directWrite == true )
568 $db->query( "UPDATE eZMail_Mail SET Status='$status' where ID='$this->ID'" );
569 }
570
575 static public function &splitList( $emails )
576 {
577 $emails =& preg_split( "/[,;]/", $emails );
578 return $emails;
579 }
580
585 static public function &mergeList( $emails )
586 {
587 if ( !is_array( $emails ) )
588 return false;
589 $emails =& implode( ",", $emails );
590 return $emails;
591 }
592
599 static public function validate( $address )
600 {
601 $pos = ( preg_match('/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $address) );
602
603 return $pos;
604 }
605
612 static public function stripEmail( $address )
613 {
614 $res = preg_match( '/[\/0-9A-Za-z\.\?\-\_]+' . '@' .
615 '[\/0-9A-Za-z\.\?\-\_]+/', $address, $email );
616 if ( $res )
617 return $email[0];
618 else
619 return 0;
620 }
621
628 static public function isDownloaded( $mailident, $userID )
629 {
630 $db =& eZDB::globalDatabase();
631 $db->query_single( $res, "SELECT count(*) as Count FROM eZMail_FetchedMail WHERE UserID='$userID' AND MessageID='$mailident'" );
632
633 $ret = true;
634 if ( $res[$db->fieldName( "Count" )] == 0 )
635 $ret = false;
636
637 return $ret;
638 }
639
643 function markAsDownloaded()
644 {
645 $db =& eZDB::globalDatabase();
646 $db->begin();
647 $result = $db->query( "INSERT INTO eZMail_FetchedMail
648 (UserID, MessageID)
649 VALUES
650 ('$this->UserID', '$this->MessageID')" );
651 if ( $result == false )
652 $db->rollback( );
653 else
654 $db->commit();
655 }
656
657 /*
658 Returns the first folder that this mail is a member of.
659 */
660 function folder( $as_object = true )
661 {
662 $res = array();
663 $db =& eZDB::globalDatabase();
664 $db->array_query( $res, "SELECT FolderID FROM eZMail_MailFolderLink WHERE MailID='$this->ID'" );
665
666 if ( count( $res ) > 0 )
667 {
668 if ( $as_object )
669 return new eZMailFolder( $res[0][$db->fieldName( "FolderID" )] );
670 else
671 return $res[0][$db->fieldName( "FolderID" )];
672 }
673
674 return false;
675 }
676
681 static public function getByUser( $user = false, $onlyUnread = false )
682 {
683 if ( !is_a( $user, "eZUser" ) )
684 $user =& eZUser::currentUser();
685
686 $unreadOnlySQL = "";
687 if ( $onlyUnread == false )
688 {
689 $unreadOnlySQL = "AND Status='0'";
690 }
691
692 $return_array = array();
693 $res = array();
694 $userid = $user->id();
695 $database =& eZDB::globalDatabase();
696 $query = "SELECT ID FROM eZMail_Mail WHERE UserID='$userid' $unreadOnlySQL";
697 $database->array_query( $res, $query );
698
699 for ( $i = 0; $i < count( $res ); $i++ )
700 {
701 $return_array[$i] = new eZMail( $res[$i][$db->fieldName( "ID" )] );
702 }
703
704 return $return_array;
705 }
706
711 static public function getByContact( $ContactID, $CompanyEdit, $Offset, $Limit, $user = false )
712 {
713 if ( !is_a( $user, "eZUser" ) )
714 $user =& eZUser::currentUser();
715 if ( $CompanyEdit )
716 $field = "CompanyID";
717 else
718 $field = "PersonID";
719
720 $db =& eZDB::globalDatabase();
721 $db->array_query( $res, "SELECT MailID FROM eZMail_MailContactLink
722 WHERE $field='$ContactID'" );
723
724 $return_array = array();
725 for ( $i = 0; $i < count( $res ); $i++ )
726 {
727 $mail = new eZMail( $res[$i][$db->fieldName( "MailID" )] );
728 if ( $mail->owner() == $user->id() )
729 $return_array[] = $mail;
730 }
731 return $return_array;
732 }
733
734 function getContacts( $mailID = false )
735 {
736 if ( !$mailID )
737 $mailID = $this->ID;
738
739 $return_array = array();
740 $return_array["PersonID"] = array();
741 $return_array["CompanyID"] = array();
742 $db =& eZDB::globalDatabase();
743 $db->array_query( $res, "SELECT * FROM eZMail_MailContactLink WHERE MailID='$mailID'" );
744 foreach ( $res as $resItem )
745 {
746 if ( $resItem[$db->fieldName( "PersonID" )] > 0 )
747 $return_array["PersonID"][] = $resItem[$db->fieldName( "PersonID" )];
748 else
749 $return_array["CompanyID"][] = $resItem[$db->fieldName( "CompanyID" )];
750 }
751 return $return_array;
752 }
753
754 /*
755 Adds an attachment to this mail
756 Recalculates the size of the mail.
757 */
758 function addFile( $file )
759 {
760 $this->FilesAttached = true;
761 $db =& eZDB::globalDatabase();
762
763 if ( is_a( $file, "eZVirtualFile" ) )
764 {
765 $db->begin();
766 $fileID = $file->id();
767
768 $db->query( "INSERT INTO eZMail_MailAttachmentLink (MailID, FileID)
769 VALUES ('$this->ID', '$fileID')" );
770
771 $this->calculateSize();
772 }
773 }
774
779 function deleteFile( $file )
780 {
781 if ( is_a( $file, "eZVirtualFile" ) )
782 {
783 $fileID = $file->id();
784 $file->delete();
785 $db =& eZDB::globalDatabase();
786 $db->query( "DELETE FROM eZMail_MailAttachmentLink WHERE MailID='$this->ID' AND FileID='$fileID'" );
787 $this->calculateSize();
788 }
789 }
790
794 function files()
795 {
796 $return_array = array();
797
798 if( !isset( $this->ID ) )
799 return $return_array;
800
801 $file_array = array();
802 $db =& eZDB::globalDatabase();
803 $db->array_query( $file_array, "SELECT FileID FROM eZMail_MailAttachmentLink WHERE MailID='$this->ID'" );
804
805 for ( $i = 0; $i < count( $file_array ); $i++ )
806 {
807 $return_array[$i] = new eZVirtualFile( $file_array[$i][$db->fieldName( "FileID" )], false );
808 }
809
810 return $return_array;
811 }
812
813 /*
814 Adds an image attachment.
815 */
816 function addImage( $image )
817 {
818 if ( is_a( $image, "eZImage" ) )
819 {
820 $imageID = $image->id();
821 $db =& eZDB::globalDatabase();
822 $db->begin();
823 $res[] = $db->query( "INSERT INTO eZMail_MailImageLink (MailID, ImageID ) VALUES ('$this->ID', '$imageID')" );
824 eZDB::finish( $res, $db );
825 }
826 }
827
831 function deleteImage( $image )
832 {
833 if ( is_a( $image, "eZImage" ) )
834 {
835 $imageID = $image->id();
836 $image->delete();
837 $db =& eZDB::globalDatabase();
838 $db->begin();
839 $res[] = $db->query( "DELETE FROM eZMail_MailImageLink WHERE MailID='$this->ID' AND ImageID='$imageID'" );
840 eZDB::finish( $res, $db );
841 }
842 }
843
847 function images()
848 {
849 $return_array = array();
850 $image_array = array();
851
852 $db =& eZDB::globalDatabase();
853 $db->array_query( $image_array, "SELECT ImageID FROM eZMail_MailImageLink WHERE MailID='$this->ID'" );
854
855 for ( $i = 0; $i < count( $image_array ); $i++ )
856 {
857 $return_array[$i] = new eZImage( $image_array[$i][$db->fieldName( "ImageID" )], false );
858 }
859 return $return_array;
860 }
861
867 static public function isOwner( $user, $mailID )
868 {
869 if ( is_a( $user, "eZUser" ) )
870 $user = $user->id();
871
872 $db =& eZDB::globalDatabase();
873 $db->query_single( $res, "SELECT UserID from eZMail_Mail WHERE ID='$mailID'" );
874 if ( $res[$db->fieldName( "UserID" )] == $user )
875 return true;
876
877 return false;
878 }
879
887 function &copyMail( $copyType = "normal", $attachments = false )
888 {
889 $ini =& eZINI::instance( 'site.ini' );
890 $copy = new eZMail();
891 $copy->UserID = $this->UserID;
892
893 if ( $copyType == "normal" || $copyType == "forward" )
894 {
895 if ( $copyType == "normal" )
896 {
897 $copy->To = $this->To;
898 $copy->From = $this->From;
899 $copy->FromName = $this->FromName;
900 $copy->Cc = $this->Cc;
901 $copy->Bcc = $this->Bcc;
902 $copy->ReplyTo = $this->ReplyTo;
903 }
904 else
905 {
906 $copy->From = $this->To;
907 }
908 $copy->Subject = $this->Subject;
909 $copy->BodyText = $this->BodyText;
910 $copy->MessageID = $this->MessageID;
911 $copy->References = $this->References;
912 $attachments = $this->files();
913 $copy->store();
914 foreach ( $attachments as $attachment )
915 {
916 $copy->addFile( $attachment );
917 }
918 }
919 else if ( $copyType == "reply" || $copyType == "replyall" )
920 {
921 $copy->To = $this->From;
922 $copy->Subject = $ini->variable( "eZMailMain", "ReplyPrefix" ) . $this->Subject;
923 $copy->References = $this->MessageID;
924 $copy->ReplyTo = $this->To;
925
926 if ( $copyType == "replyall" )
927 $copy->Cc = $this->Cc;
928
929 $sentnsArray = explode( "\n", $this->BodyText );
930 $resultArray = array();
931
932 foreach ( $sentnsArray as $sentence )
933 $resultArray[] = "> " . $sentence . "\n";
934
935 $copy->BodyText = implode( "", $resultArray );
936 }
937
938 $copy->store();
939 return $copy;
940 }
941
945 function calculateSize()
946 {
947 $size = strlen( $this->To );
948 $size += strlen( $this->From );
949 $size += strlen( $this->FromName );
950 $size += strlen( $this->Cc );
951 $size += strlen( $this->Bcc );
952 $size += strlen( $this->References );
953 $size += strlen( $this->ReplyTo );
954 $size += strlen( $this->Subject );
955 $size += strlen( $this->BodyText );
956
957 $files = $this->files();
958 foreach ( $files as $file )
959 $size += $file->fileSize();
960
961 $this->Size = $size;
962 }
963
967 function send()
968 {
969 if ( $this->FilesAttached == true )
970 {
971 $files = $this->files();
972 if( count( $files ) )
973 {
974 foreach ( $files as $file )
975 {
976 echo "Added attachment";
977 $filename = "ezfilemanager/files/" . $file->fileName();
978 $attachment = fread( eZPBFile::fopen( $filename, "r" ), eZPBFile::filesize( $filename ) );
979 // get the correct mime type.
980 $suffix = strtolower( preg_replace( "/^.+\.(.+)$/", "\\1", $file->originalFileName() ) );
981 $mimeType = "";
982 switch ( $suffix )
983 {
984 case "doc":
985 $mimeType = "application/msword";
986 break;
987 case "ppt":
988 $mimeType = "application/vnd.ms-powerpoint";
989 break;
990 case "xls":
991 $mimeType = "application/vnd.ms-excel";
992 break;
993 case "pdf":
994 $mimeType = "application/pdf";
995 break;
996
997 case "jpg":
998 case "jpeg":
999 $mimeType = "image/jpeg";
1000 break;
1001
1002 case "bz2":
1003 $mimeType = "application/x-bzip2";
1004 break;
1005
1006 case "html":
1007 case "htm":
1008 $mimeType = "text/html";
1009 break;
1010
1011 case "txt":
1012 $mimeType = "text/plain";
1013 break;
1014
1015 case "gif":
1016 $mimeType = "image/gif";
1017 break;
1018
1019 case "png":
1020 $mimeType = "image/png";
1021 break;
1022
1023 case "zip":
1024 $mimeType = "application/zip";
1025 break;
1026
1027 default:
1028 $mimeType = "application/octet-stream";
1029 }
1030
1031 $this->add_attachment( $attachment, $file->originalFileName(), $mimeType );
1032 }
1033 }
1034 }
1035
1036 $mime = "";
1037 if ( !empty( $this->From ) )
1038 {
1039 $envelope = "-f " . $this->From;
1040 }
1041 /*
1042 if ( !empty( $this->FromName ) )
1043 $mime .= "From: " . $this->FromName . " <" . $this->From . ">";
1044 else
1045 $mime .= "From: " . $this->From . "";
1046 }
1047 if ( !empty( $this->Cc ) )
1048 $mime .= "Cc: " . $this->Cc . "";
1049 if ( !empty( $this->Bcc ) )
1050 $mime .= "Bcc: " . $this->Bcc . "";
1051 if ( !empty( $this->ReplyTo ) )
1052 $mime .= "Reply-To: " . $this->ReplyTo . "";
1053
1054 */
1055 if ( !empty( $this->BodyText ) )
1056 {
1057 $body = $this->BodyText; //preg_replace( "/(?<![\r])\n(?![\r])/", "\r\n", $this->BodyText );
1058 $this->add_attachment( $body, "", "text/plain");
1059 }
1060
1061 // Temporary issue avoidance
1062 // $mime .= "MIME-Version: 1.0" . $this->build_multipart();
1063
1064 if ( isset ( $envelope ) )
1065 {
1066 //mail( $this->To, $this->Subject, "", $mime, $envelope );
1067 } else
1068 {
1069 mail( $this->To, $this->Subject, "", $mime );
1070 }
1071
1072
1073 $this->parts = array();
1074 }
1075
1082 function add_attachment( $message, $name = "", $ctype = "application/octet-stream", $encode = '' )
1083 {
1084 $this->parts[] = array (
1085 "ctype" => $ctype,
1086 "message" => $message,
1087 "encode" => $encode,
1088 "name" => $name
1089 );
1090 }
1091
1098 function build_message( $part )
1099 {
1100 $message = $part["message"];
1101 $message = chunk_split( base64_encode( $message ) );
1102 $encoding = "base64";
1103
1104 //EP - different charsets for the MIME mail ---------------
1105 // global $GlobalSectionID;
1106 //
1107 // // include_once("ezsitemanager/classes/ezsection.php");
1108 // $sectionObject =& eZSection::globalSectionObject( $GlobalSectionID );
1109 // $Locale = new eZLocale( $sectionObject->language() );
1110 // $iso =& $Locale->languageISO();
1111
1112 // $subj = $this->subject();
1113 // $subj = "=?$iso?B?" . trim( chunk_split( base64_encode( $subj ))) . "?=";
1114 // $this->setSubject ( $subj );
1115
1116 // return "Content-Type: " . $part["ctype"] . ";\n\tcharset=\"$iso\"" .
1117 // ( $part["name"] ? "; name = \"" . $part["name"] . "\"" : "" ) .
1118 // "\nContent-Transfer-Encoding: $encoding\n\n$message\n";
1119
1120 //EP ---------------------------------------------------
1121
1122 return "Content-Type: " . $part["ctype"] .
1123 ( $part["name"] ? "; name = \"" . $part["name"] . "\"" : "" ) .
1124 "\nContent-Transfer-Encoding: $encoding\n\n$message\n";
1125 }
1126
1133 function build_multipart()
1134 {
1135 $boundary = "b" . md5( uniqid( time() ) );
1136 $multipart = "Content-Type: multipart/mixed;\n boundary=$boundary\n\nThis is a MIME encoded message.\n\n--$boundary";
1137
1138 for ( $i = count( $this->parts ) - 1; $i >= 0; $i-- )
1139 {
1140 $multipart .= "\n" . $this->build_message( $this->parts[$i] ) . "--$boundary";
1141 }
1142 return $multipart .= "--\n";
1143 }
1144
1150 static public function search( $text, $user = -1 )
1151 {
1152 $db =& eZDB::globalDatabase();
1153 $return_array = array();
1154 if ( $user == -1 )
1155 $user =& eZUser::currentUser();
1156
1157 $db->array_query( $id_array, "SELECT ID FROM eZMail_Mail WHERE
1158 (ToField LIKE '%$text%' OR
1159 FromField LIKE '%$text%' OR
1160 CC LIKE '%$text%' OR
1161 Subject LIKE '%$text%' OR
1162 BodyText LIKE '%$text%') AND
1163 UserID='" . $user->ID() . "'
1164 ORDER BY Subject" );
1165 foreach ( $id_array as $id )
1166 {
1167 $return_array[] = new eZMail( $id[$db->fieldName( "ID" )] );
1168 }
1169 return $return_array;
1170 }
1171
1173 var $parts;
1174
1175 /* Mail specific variables */
1176 var $To;
1178 var $From;
1180 var $FromName;
1181 var $Cc;
1182 var $Bcc;
1184 var $MessageID;
1186 var $References;
1187 var $ReplyTo;
1188
1189 var $Subject;
1190 var $BodyText;
1191
1192 var $Size;
1193 var $UDate;
1194
1195 var $Status;
1196
1197 // variable to check if files are attached ( no need to use database if not)
1198 var $FilesAttached;
1199
1200 /* database specific variables */
1201 var $ID;
1202 var $UserID;
1203
1204 var $IsPublished;
1205 }
1206
1207 ?>
$i
$i
Definition: admin/adlist.php:91
$message
$message
Definition: admin/message.php:51
$userID
else $userID
Definition: appointmentedit.php:121
$files
$files
Definition: articlepreview.php:91
$status
$status
Definition: bugedit.php:473
$address
$address
Definition: checkout.php:588
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZImage
Definition: ezimage.php:95
eZMailFolder
Definition: ezmailfolder.php:49
eZMail
Definition: ezmail.php:57
eZMail\getByUser
static getByUser( $user=false, $onlyUnread=false)
Definition: ezmail.php:681
eZMail\setFrom
setFrom( $newFrom)
Definition: ezmail.php:308
eZMail\setBcc
setBcc( $newBcc)
Definition: ezmail.php:340
eZMail\$Bcc
$Bcc
Definition: ezmail.php:1182
eZMail\calculateSize
calculateSize()
Definition: ezmail.php:945
eZMail\addImage
addImage( $image)
Definition: ezmail.php:816
eZMail\to
to()
Definition: ezmail.php:248
eZMail\folder
folder( $as_object=true)
Definition: ezmail.php:660
eZMail\setSize
setSize( $value)
Definition: ezmail.php:519
eZMail\replyTo
replyTo()
Definition: ezmail.php:265
eZMail\setSubject
setSubject( $newSubject)
Definition: ezmail.php:421
eZMail\subject
subject()
Definition: ezmail.php:413
eZMail\setSender
setSender( $newSender)
Definition: ezmail.php:405
eZMail\status
status()
Definition: ezmail.php:548
eZMail\images
images()
Definition: ezmail.php:847
eZMail\$FromName
$FromName
users name
Definition: ezmail.php:1180
eZMail\add_attachment
add_attachment( $message, $name="", $ctype="application/octet-stream", $encode='')
Definition: ezmail.php:1082
eZMail\owner
owner()
Definition: ezmail.php:454
eZMail\build_multipart
build_multipart()
Definition: ezmail.php:1133
eZMail\addFile
addFile( $file)
Definition: ezmail.php:758
eZMail\setUDate
setUDate( $value)
Definition: ezmail.php:535
eZMail\setMessageID
setMessageID( $newMessageID)
Definition: ezmail.php:357
eZMail\messageID
messageID()
Definition: ezmail.php:349
eZMail\$To
$To
Definition: ezmail.php:1176
eZMail\bcc
bcc()
Definition: ezmail.php:332
eZMail\send
send()
Definition: ezmail.php:967
eZMail\$Status
$Status
Definition: ezmail.php:1195
eZMail\setReplyTo
setReplyTo( $newReplyTo)
Definition: ezmail.php:273
eZMail\uDate
uDate()
Definition: ezmail.php:527
eZMail\build_message
build_message( $part)
Definition: ezmail.php:1098
eZMail\splitList
static & splitList( $emails)
Definition: ezmail.php:575
eZMail\receiver
receiver()
Definition: ezmail.php:282
eZMail\from
from()
Definition: ezmail.php:299
eZMail\isOwner
static isOwner( $user, $mailID)
Definition: ezmail.php:867
eZMail\$Subject
$Subject
Definition: ezmail.php:1189
eZMail\$From
$From
email adress
Definition: ezmail.php:1178
eZMail\setFromName
setFromName( $newFrom)
Definition: ezmail.php:389
eZMail\files
files()
Definition: ezmail.php:794
eZMail\$FilesAttached
$FilesAttached
Definition: ezmail.php:1198
eZMail\deleteImage
deleteImage( $image)
Definition: ezmail.php:831
eZMail\isDownloaded
static isDownloaded( $mailident, $userID)
Definition: ezmail.php:628
eZMail\setStatus
setStatus( $status, $directWrite=false)
Definition: ezmail.php:563
eZMail\$MessageID
$MessageID
used with the reference.
Definition: ezmail.php:1184
eZMail\setCc
setCc( $newCc)
Definition: ezmail.php:324
eZMail\id
id()
Definition: ezmail.php:240
eZMail\store
store()
Definition: ezmail.php:105
eZMail\setBodyText
setBodyText( $newBody)
Definition: ezmail.php:446
eZMail\$BodyText
$BodyText
Definition: ezmail.php:1190
eZMail\removeContacts
removeContacts( $mailID)
Definition: ezmail.php:171
eZMail\mergeList
static & mergeList( $emails)
Definition: ezmail.php:585
eZMail\__construct
__construct( $id="")
Definition: ezmail.php:64
eZMail\$parts
$parts
this variable is only used during the buildup of a mail that is beeing sent. NEVER access directly!...
Definition: ezmail.php:1173
eZMail\$UserID
$UserID
Definition: ezmail.php:1202
eZMail\$IsPublished
$IsPublished
Definition: ezmail.php:1204
eZMail\setBody
setBody( $newBody)
Definition: ezmail.php:437
eZMail\addContact
addContact( $mailID, $contactID, $companyEdit=true)
Definition: ezmail.php:179
eZMail\$ID
$ID
Definition: ezmail.php:1201
eZMail\cc
cc()
Definition: ezmail.php:316
eZMail\body
body()
Definition: ezmail.php:429
eZMail\setReferences
setReferences( $newReference)
Definition: ezmail.php:373
eZMail\sender
sender()
Definition: ezmail.php:397
eZMail\$Cc
$Cc
Definition: ezmail.php:1181
eZMail\setOwner
setOwner( $newOwner)
Definition: ezmail.php:462
eZMail\$References
$References
used to thread mail, originally from News
Definition: ezmail.php:1186
eZMail\stripEmail
static stripEmail( $address)
Definition: ezmail.php:612
eZMail\siSize
siSize()
Definition: ezmail.php:486
eZMail\validate
static validate( $address)
Definition: ezmail.php:599
eZMail\$ReplyTo
$ReplyTo
Definition: ezmail.php:1187
eZMail\$UDate
$UDate
Definition: ezmail.php:1193
eZMail\getContacts
getContacts( $mailID=false)
Definition: ezmail.php:734
eZMail\markAsDownloaded
markAsDownloaded()
Definition: ezmail.php:643
eZMail\size
size()
Definition: ezmail.php:474
eZMail\search
static search( $text, $user=-1)
Definition: ezmail.php:1150
eZMail\setReceiver
setReceiver( $newReceiver)
Definition: ezmail.php:290
eZMail\references
references()
Definition: ezmail.php:365
eZMail\deleteFile
deleteFile( $file)
Definition: ezmail.php:779
eZMail\$Size
$Size
Definition: ezmail.php:1192
eZMail\fromName
fromName()
Definition: ezmail.php:381
eZMail\getByContact
static getByContact( $ContactID, $CompanyEdit, $Offset, $Limit, $user=false)
Definition: ezmail.php:711
eZMail\copyMail
& copyMail( $copyType="normal", $attachments=false)
Definition: ezmail.php:887
eZMail\setTo
setTo( $newTo)
Definition: ezmail.php:256
eZPBFile\fopen
static fopen( $filename, $options)
Definition: ezpbfile.php:326
eZPBFile\filesize
static filesize( $filename)
Definition: ezpbfile.php:339
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
eZVirtualFile
Definition: ezvirtualfile.php:42
$ini
$ini
Definition: classes/admin/linklist.php:64
$CompanyEdit
$CompanyEdit
Definition: companyedit.php:32
$result
$result
Definition: companysearch.php:94
$name
$name
Definition: companytypelist.php:194
$id
$id
Definition: companytypelist.php:193
$emails
$emails
Definition: companyview.php:525
$query
if(isset( $Year) &&!is_numeric( $Year)||isset( $Month) &&!is_numeric( $Month)) $query
Definition: entryexitpages.php:65
$Limit
$Limit
Definition: ezarticle/admin/categorylist.php:66
$db
$db
Definition: ezarticle/user/authorlist.php:53
$Offset
$Offset
Definition: ezarticle/user/search.php:110
$mail_array
$mail_array
Definition: ezbug/admin/cron.php:42
$mail
$mail
Definition: ezbulkmail/admin/maillist.php:61
$size
if($file_debug) $size
Definition: ezfilemanager/user/filedownload.php:165
$suffix
$suffix
Definition: ezfilemanager/user/filedownload.php:168
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
$field
$field
Definition: listtable.php:41
$part
$part
Definition: tag.php:46
$user
$user
Definition: user/adlist.php:39
$image
$image
Definition: user/articlelist.php:242
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.