Changeset 29 for trunk/calendar/inc/class.bocalendar.inc.php
- Timestamp:
- 05/29/07 14:06:42 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/calendar/inc/class.bocalendar.inc.php
r2 r29 2495 2495 } 2496 2496 2497 function create_vcard($event) 2498 { 2499 // It translates int to string 2500 if ( $event[end][month] < 10 ) 2501 $end_event_month="0".$event[end][month]; 2502 else 2503 $end_event_month=$event[end][month]; 2504 if ( $event[start][month] < 10 ) 2505 $start_event_month="0".$event[start][month]; 2506 else 2507 $start_event_month=$event[start][month]; 2508 if ( $event[end][mday] < 10 ) 2509 $end_event_day="0".$event[end][mday]; 2510 else 2511 $end_event_day=$event[end][mday]; 2512 if ( $event[start][mday] < 10 ) 2513 $start_event_day="0".$event[start][mday]; 2514 else 2515 $start_event_day=$event[start][mday]; 2516 if ( $event[start][hour] < 10) 2517 $start_event_hour="0".$event[start][hour]; 2518 else 2519 $start_event_hour=$event[start][hour]; 2520 if ( $event[end][hour] < 10) 2521 $end_event_hour="0".$event[end][hour]; 2522 else 2523 $end_event_hour=$event[end][hour]; 2524 2525 if ( $event[start][min] < 10) 2526 $start_event_min="0".$event[start][min]; 2527 else 2528 $start_event_min=$event[start][min]; 2529 if ( $event[end][min] < 10) 2530 $end_event_min="0".$event[end][min]; 2531 else 2532 $end_event_min=$event[end][min]; 2533 2534 $tmpattach="BEGIN:VCALENDAR\n" 2535 ."PRODID:-//Expresso Livre//Calendar//EN\n" 2536 ."VERSION:1.0\n" 2537 ."BEGIN:VEVENT\n" 2538 ."DTSTART:".$event[start][year].$start_event_month.$start_event_day."T".$start_event_hour.$start_event_min."00Z\n" 2539 ."DTEND:".$event[end][year].$end_event_month.$end_event_day."T".$end_event_hour.$end_event_min."00Z\n" 2540 ."UID:Expresso-".$event[id].$event[uid]."\n" 2541 ."LAST-MODIFIED:".time()."\n" 2542 ."DESCRIPTION:".$event[description]."\n" 2543 ."SUMMARY:".$event[title]."\n" 2544 ."LOCATION:".$event[location]."\n" 2545 ."END:VEVENT"."\n" 2546 ."END:VCALENDAR\n"; 2547 return $tmpattach; 2548 } 2549 2497 2550 /*! 2498 2551 @function send_update … … 2520 2573 2521 2574 $GLOBALS['phpgw_info']['user']['preferences'] = $GLOBALS['phpgw']->preferences->create_email_preferences(); 2522 $sender = $GLOBALS['phpgw_info']['user'][' preferences']['email']['address'];2575 $sender = $GLOBALS['phpgw_info']['user']['email']; 2523 2576 2524 2577 $temp_tz_offset = $this->prefs['common']['tz_offset']; … … 2638 2691 $GLOBALS['phpgw']->send = CreateObject('phpgwapi.send'); 2639 2692 } 2640 $send = &$GLOBALS['phpgw']->send; 2693 // $send = &$GLOBALS['phpgw']->send; 2694 2695 //Seta o email usando phpmailer 2696 define('PHPGW_INCLUDE_ROOT','../'); 2697 define('PHPGW_API_INC','../phpgwapi/inc'); 2698 include_once(PHPGW_API_INC.'/class.phpmailer.inc.php'); 2699 $mail = new PHPMailer(); 2700 $mail->IsSMTP(); 2701 $mail->Host = $_SESSION['phpgw_info']['expressomail']['email_server']['smtpServer']; 2702 $mail->Port = $_SESSION['phpgw_info']['expressomail']['email_server']['smtpPort']; 2703 $mail->From = $_SESSION['phpgw_info']['expressomail']['user']['email']; 2704 $mail->FromName = $_SESSION['phpgw_info']['expressomail']['user']['fullname']; 2705 $mail->IsHTML(true); 2706 2641 2707 // Aqui é enviado o email 2642 2643 2708 foreach($to_notify as $userid => $statusid) 2644 2709 { … … 2688 2753 2689 2754 list($subject,$body1) = split("\n",$GLOBALS['phpgw']->preferences->parse_notify($notify_msg,$details),2); 2690 $subject = $send->encode_subject($subject);2691 2755 2692 2756 switch($part_prefs['calendar']['update_format']) … … 2861 2925 $body->set_var($var); 2862 2926 $tmpbody = $body->fp('out','list'); 2863 2927 2864 2928 break; 2865 2929 2866 2930 case 'ical': 2867 2931 $content_type = "calendar; method=$method; name=calendar.ics"; 2868 /* would be nice, need to get it working 2869 if ($body != '') 2932 /* if ($body != '') 2870 2933 { 2871 2934 $boundary = '----Message-Boundary'; … … 2882 2945 break; 2883 2946 } 2947 $mail->AddAddress(implode(",",$to)); 2948 $mail->Body = $tmpbody; 2949 $mail->From = $sender; 2950 $mail->FromName = $GLOBALS['phpgw_info']['user']['fullname']; 2951 $mail->Sender = $mail->From; 2952 $mail->SenderName = $mail->FromName; 2953 $mail->Subject = $subject; 2954 2884 2955 2885 2956 //It sends email for the participants ( Envia email para os participantes) 2886 2887 $returncode = $send->msg('email',$to,$subject,$tmpbody,''/*$msgtype*/,'','','',$sender, $content_type/*,$boundary*/); 2957 if(!$mail->Send()) 2958 { 2959 $returncode=false; 2960 } 2961 else 2962 { 2963 $returncode=true; 2964 } 2965 2966 //$returncode = $send->msg('email',$to,$subject,$tmpbody,''/*$msgtype*/,'','','',$sender, $content_type/*,$boundary*/); 2888 2967 2889 2968 2890 2969 unset($vardata5); 2891 2970 unset($vardata6); 2892 //echo "<b><p>send(to='$to', sender='$sender'<br>subject='$subject') returncode=$returncode<br>".nl2br($body)."</p></b>\n";2893 2971 if (!$returncode) // not nice, but better than failing silently 2894 2972 { 2895 2973 echo '<p><b>bocalendar::send_update</b>: '.lang("Failed sending message to '%1' #%2 subject='%3', sender='%4' !!!",$to,$userid,htmlspecialchars($subject), $sender)."<br>\n"; 2896 echo '<i>'.$ send->err['desc']."</i><br>\n";2974 echo '<i>'.$mail->ErrorInfo."</i><br>\n"; 2897 2975 echo lang('This is mostly caused by a not or wrongly configured SMTP server. Notify your administrator.')."</p>\n"; 2898 2976 echo '<p>'.lang('Click %1here%2 to return to the calendar.','<a href="'.$GLOBALS['phpgw']->link('/calendar/').'">','</a>')."</p>\n"; … … 2907 2985 $details['enddate'] = $GLOBALS['phpgw']->common->show_date($endtime); 2908 2986 list($subject,$body1) = split("\n",$GLOBALS['phpgw']->preferences->parse_notify($notify_msg,$details),2); 2909 $subject = $send->encode_subject($subject);2910 2987 } 2911 2988 foreach($var as $index => $ex_participant){ … … 2915 2992 $to[] = $ex_participant; 2916 2993 } 2917 $ to = implode(",",$to);2994 $mail->AddAddress(implode(",",$to)); 2918 2995 $_body = explode("<hr size='1' width='100%'>",$tmpbody); 2919 2996 $tmpbody = $_body[0]; 2920 2997 $tmpbody.= "<b>".lang("external participants").":: </b> ".htmlentities($this->ex_participants); 2998 $tmpbody.= "<br>".lang("Summary").": ".$this->so->cal->event[title]."<br>"; 2999 $tmpbody.= "<br>".lang("Start date").": ".$GLOBALS['phpgw']->common->show_date($starttime)."<br>".lang("End date").": ".$GLOBALS['phpgw']->common->show_date($endtime)."<br>"; 2921 3000 $tmpbody.= "<br><br><hr size='1' width='100%'><font color='red'>".lang("This message was sent by server. You must send a message to sender to confirm this event")."</font>"; 2922 $returncode = $send->msg('email', '', $subject, $tmpbody, '', '', $to, '', $sender, $content_type); 2923 } 2924 2925 unset($send); 3001 3002 //attach extern vcard 3003 // define('context','$GLOBALS.bocalendar.so.cal.event'); 3004 $tmpattach = $this->create_vcard($GLOBALS['bocalendar']->so->cal->event); 3005 $tempdir = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; 3006 srand((double)microtime()*1000000); 3007 $random_number = rand(100000000,999999999); 3008 $newfilename = md5(time() . getenv("REMOTE_ADDR") . $random_number ); 3009 $filename = $tempdir . $newfilename; 3010 $attach_fd = fopen($filename,"w+"); 3011 fwrite($attach_fd,$tmpattach); 3012 $mail->AddAttachment($filename, "extern.vcard", "base64", "text/plain"); // "application/octet-stream" 3013 fclose($attach_fd); 3014 $mail->From = $sender; 3015 $mail->FromName = lang("Expresso external user").": ".$GLOBALS['phpgw_info']['user']['fullname']; 3016 $mail->Sender = $mail->From; 3017 $mail->SenderName = $mail->FromName; 3018 $mail->Subject = lang("External event from Expresso"); 3019 $mail->Body = $tmpbody; 3020 3021 if(!$mail->Send()) 3022 { 3023 $returncode=false; 3024 } 3025 else 3026 { 3027 $returncode=true; 3028 } 3029 } 3030 2926 3031 2927 3032 if((is_int($this->user) && $this->user != $temp_user['account_id']) ||
Note: See TracChangeset
for help on using the changeset viewer.