Ignore:
Timestamp:
05/29/07 14:06:42 (17 years ago)
Author:
niltonneto
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/calendar/inc/class.bocalendar.inc.php

    r2 r29  
    24952495                } 
    24962496 
     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 
    24972550                /*! 
    24982551                @function send_update 
     
    25202573 
    25212574                        $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']; 
    25232576 
    25242577                        $temp_tz_offset = $this->prefs['common']['tz_offset']; 
     
    26382691                                $GLOBALS['phpgw']->send = CreateObject('phpgwapi.send'); 
    26392692                        } 
    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                         
    26412707                        // Aqui é enviado o email 
    2642  
    26432708                        foreach($to_notify as $userid => $statusid)  
    26442709                        { 
     
    26882753                                         
    26892754                                        list($subject,$body1) = split("\n",$GLOBALS['phpgw']->preferences->parse_notify($notify_msg,$details),2); 
    2690                                         $subject = $send->encode_subject($subject); 
    26912755                                         
    26922756                                        switch($part_prefs['calendar']['update_format']) 
     
    28612925                                                        $body->set_var($var); 
    28622926                                                        $tmpbody = $body->fp('out','list'); 
    2863                                                          
     2927                                                                                                                 
    28642928                                                        break; 
    28652929 
    28662930                                                case 'ical': 
    28672931                                                        $content_type = "calendar; method=$method; name=calendar.ics"; 
    2868 /* would be nice, need to get it working 
    2869                                                         if ($body != '') 
     2932/*                                                      if ($body != '') 
    28702933                                                        { 
    28712934                                                                $boundary = '----Message-Boundary'; 
     
    28822945                                                        break; 
    28832946                                        } 
     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                                         
    28842955                                         
    28852956                                        //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*/); 
    28882967 
    28892968                                 
    28902969                                        unset($vardata5); 
    28912970                                        unset($vardata6); 
    2892                                         //echo "<b><p>send(to='$to', sender='$sender'<br>subject='$subject') returncode=$returncode<br>".nl2br($body)."</p></b>\n"; 
    28932971                                        if (!$returncode)       // not nice, but better than failing silently 
    28942972                                        { 
    28952973                                                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"; 
    28972975                                                echo lang('This is mostly caused by a not or wrongly configured SMTP server. Notify your administrator.')."</p>\n"; 
    28982976                                                echo '<p>'.lang('Click %1here%2 to return to the calendar.','<a href="'.$GLOBALS['phpgw']->link('/calendar/').'">','</a>')."</p>\n"; 
     
    29072985                                        $details['enddate']   = $GLOBALS['phpgw']->common->show_date($endtime); 
    29082986                                        list($subject,$body1) = split("\n",$GLOBALS['phpgw']->preferences->parse_notify($notify_msg,$details),2); 
    2909                                         $subject = $send->encode_subject($subject); 
    29102987                                } 
    29112988                                foreach($var as $index => $ex_participant){ 
     
    29152992                                                        $to[] = $ex_participant; 
    29162993                                } 
    2917                                 $to = implode(",",$to); 
     2994                                $mail->AddAddress(implode(",",$to)); 
    29182995                                $_body = explode("<hr size='1' width='100%'>",$tmpbody); 
    29192996                                $tmpbody = $_body[0]; 
    29202997                                $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>"; 
    29213000                                $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 
    29263031 
    29273032                        if((is_int($this->user) && $this->user != $temp_user['account_id']) || 
Note: See TracChangeset for help on using the changeset viewer.