Changeset 363


Ignore:
Timestamp:
07/21/08 11:02:51 (16 years ago)
Author:
niltonneto
Message:

Vide changelog, versão 0.9.23.

Location:
trunk/calendar
Files:
2 edited

Legend:

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

    r313 r363  
    709709                        { 
    710710                                $event = $this->so->read_entry($event_id); 
     711                                if(!$this->ex_participants) 
     712                                        $this->ex_participants = html_entity_decode($event['ex_participants']);                  
    711713                                if($this->check_perms(PHPGW_ACL_DELETE,$event)) 
    712714                                { 
     
    10871089                                ); 
    10881090                        } 
     1091                        if(!$this->ex_participants) 
     1092                                $this->ex_participants = $event['ex_participants'];                      
    10891093                        if($overlapping_events) 
    10901094                        { 
     
    11111115                                if(!$event['id']) 
    11121116                                { 
    1113                                         if(!$this->ex_participants) 
    1114                                                 $this->ex_participants = $event['ex_participants']; 
    11151117                                        $this->so->add_entry($event); 
    11161118                                        $this->send_update(MSG_ADDED,$event['participants'],'',$this->get_cached_event()); 
     
    25262528        function create_vcard($event_array) 
    25272529        { 
     2530        if(!$event_array) 
     2531                return null; 
    25282532        $tmpattach="BEGIN:VCALENDAR\n" 
    25292533        ."PRODID:-//Expresso Livre//Calendar//EN\n" 
     
    25322536                { 
    25332537                        // It translates int to string 
    2534                         if (! array_key_exists  ('end', $event)) 
     2538                        if (!is_object($event)  || !is_array($event) || !array_key_exists  ('end', $event)) 
    25352539                                $event = $event_array; 
    25362540                        if ( $event['end']['month'] < 10 ) 
     
    27212725                                        $details['link']; 
    27222726                        } 
    2723  
    2724                         /*if(!is_object($GLOBALS['phpgw']->send)) 
    2725                         { 
    2726                                 $GLOBALS['phpgw']->send = CreateObject('phpgwapi.send'); 
    2727                         }*/ 
    2728                 //      $send = &$GLOBALS['phpgw']->send; 
    27292727                         
    27302728                        //Seta o email usando phpmailer 
     
    27342732                        $mail = new PHPMailer(); 
    27352733                        $mail->IsSMTP(); 
    2736                         /* 
    2737                         $mail->Host = $_SESSION['phpgw_info']['expressomail']['email_server']['smtpServer']; 
    2738                         $mail->Port = $_SESSION['phpgw_info']['expressomail']['email_server']['smtpPort']; 
    2739                         $mail->From = $_SESSION['phpgw_info']['expressomail']['user']['email']; 
    2740                         $mail->FromName = $_SESSION['phpgw_info']['expressomail']['user']['fullname']; 
    2741                         $mail->IsHTML(true); 
    2742                         */ 
    27432734                        $boemailadmin = CreateObject('emailadmin.bo'); 
    27442735                        $emailadmin_profile = $boemailadmin->getProfileList(); 
    27452736                        $emailadmin = $boemailadmin->getProfile($emailadmin_profile[0]['profileID']); 
     2737                 
    27462738                        $mail->Host = $emailadmin['smtpServer']; 
    27472739                        $mail->Port = $emailadmin['smtpPort']; 
    27482740                        $mail->From = $GLOBALS['phpgw']->preferences->values['email']; 
    2749                         $mail->FromName = $GLOBALS['phpgw_info']['user']; 
     2741                        $mail->FromName = $GLOBALS['phpgw_info']['user']['fullname']; 
    27502742                        $mail->IsHTML(true); 
    27512743 
     
    27532745                        foreach($to_notify as $userid => $statusid)  
    27542746                        { 
    2755                                 $mail->ClearAllRecipients(); 
    27562747                                $mail->ClearAttachments(); 
    27572748                                 
     
    30002991                                        $mail->SenderName = $mail->FromName; 
    30012992                                        $mail->Subject = $subject; 
    3002                                          
    3003                                          
    3004                                         //It sends email for the participants ( Envia email para os participantes) 
    3005                                         if(!$mail->Send()) 
    3006                                         { 
    3007                                                  
    3008                                                 $returncode=false; 
    3009                                         } 
    3010                                         else 
    3011                                         { 
    3012                                                 $returncode=true; 
    3013                                         } 
    3014                                                                  
    3015                                         //$returncode = $send->msg('email',$to,$subject,$tmpbody,''/*$msgtype*/,'','','',$sender, $content_type/*,$boundary*/); 
    3016  
    3017                                  
    30182993                                        unset($vardata5); 
    30192994                                        unset($vardata6); 
    3020                                         if (!$returncode)       // not nice, but better than failing silently 
    3021                                         { 
    3022                                                 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"; 
    3023                                                 echo '<i>'.$mail->ErrorInfo."</i><br>\n"; 
    3024                                                 echo lang('This is mostly caused by a not or wrongly configured SMTP server. Notify your administrator.')."</p>\n"; 
    3025                                                 echo '<p>'.lang('Click %1here%2 to return to the calendar.','<a href="'.$GLOBALS['phpgw']->link('/calendar/').'">','</a>')."</p>\n"; 
    3026                                         } 
    3027                                 } 
    3028                         } 
     2995                                } 
     2996                        } 
     2997 
     2998                        //Inicializa variável de retorno. 
     2999                        $returncode=true;                        
     3000                        if(count($mail->to)) {                           
     3001                                // Envia aviso a todos os participantes. 
     3002                                if(!$mail->Send()) {                             
     3003                                        $returncode = false; 
     3004                                        $errorInfo['participants'] = $mail->ErrorInfo; 
     3005                                } 
     3006                                else 
     3007                                        $returncode =  true; 
     3008                        } 
     3009                         
    30293010                        if(count($to_notify) && $this->ex_participants){ 
     3011                                $mail->ClearAllRecipients(); 
    30303012                                $var = explode(",",trim($this->ex_participants)); 
    30313013                                $to = array(); 
     
    30353017                                        list($subject,$body1) = split("\n",$GLOBALS['phpgw']->preferences->parse_notify($notify_msg,$details),2); 
    30363018                                } 
     3019                                 
    30373020                                foreach($var as $index => $ex_participant){ 
    30383021                                        $ex_participant = trim($ex_participant); 
     
    30413024                                                        $to[] = $ex_participant; 
    30423025                                }                
     3026                                 
    30433027                                foreach($to as $i => $to_array) 
    30443028                                        $mail->AddAddress($to_array); 
     3029                                 
    30453030                                $_body = explode("<hr size='1' width='100%'>",$tmpbody); 
    3046                                 $tmpbody = $_body[0]; 
    3047                                 $tmpbody.= "<b>".lang("external participants").":: </b> ".htmlentities($this->ex_participants); 
     3031                                $tmpbody = $_body[0] ? $_body[0] : $subject ; 
     3032                                $tmpbody.= "<br><b>".lang("external participants").":: </b> ".htmlentities($this->ex_participants); 
    30483033                                $tmpbody.= "<br>".lang("Summary").": ".$this->so->cal->event[title]."<br>"; 
    30493034                                $tmpbody.= "<br>".lang("Start time").": ".$GLOBALS['phpgw']->common->show_date($starttime)."<br>".lang("End date").": ".$GLOBALS['phpgw']->common->show_date($endtime)."<br>"; 
     
    30563041                                else 
    30573042                                        $event_month="0".$GLOBALS['bocalendar']->so->cal->event[start][month]; 
    3058                                 $tmpbody .="<a href='../index.php?menuaction=calendar.uicalendar.add&date=" 
    3059                                 .$GLOBALS['bocalendar']->so->cal->event[start][year] 
    3060                                 .$event_month 
    3061                                 .$GLOBALS['bocalendar']->so->cal->event[start][mday] 
    3062                                 ."&hour=".$GLOBALS['bocalendar']->so->cal->event[start][hour] 
    3063                                 ."&minute=".$GLOBALS['bocalendar']->so->cal->event[start][min] 
    3064                                 ."&title=".$GLOBALS['bocalendar']->so->cal->event['title'] 
    3065                                 ."&description=".$GLOBALS['bocalendar']->so->cal->event['description'] 
    3066                                 ."&location=".$GLOBALS['bocalendar']->so->cal->event['location']."'>" 
    3067                                 ."<h2>".lang("Add to my expresso")."</h2>"; 
    3068                                  
    30693043                                //attach extern vcard                    
    30703044                                // define('context','$GLOBALS.bocalendar.so.cal.event'); 
    30713045                                $tmpattach = $this->create_vcard($GLOBALS['bocalendar']->so->cal->event); 
    3072                                 $tempdir = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; 
    3073                                 srand((double)microtime()*1000000); 
    3074                                 $random_number = rand(100000000,999999999); 
    3075                                 $newfilename = md5(time() . getenv("REMOTE_ADDR") . $random_number ); 
    3076                                 $filename = $tempdir . $newfilename; 
    3077                                 $attach_fd = fopen($filename,"w+"); 
    3078                                 fwrite($attach_fd,$tmpattach); 
    3079                                 $mail->AddAttachment($filename, "extern.vcard", "base64", "text/plain"); // "application/octet-stream" 
    3080                                 fclose($attach_fd); 
     3046                                if($tmpattach){                                  
     3047                                        $tmpbody .="<a href='../index.php?menuaction=calendar.uicalendar.add&date=" 
     3048                                        .$GLOBALS['bocalendar']->so->cal->event[start][year] 
     3049                                .$event_month 
     3050                                .$GLOBALS['bocalendar']->so->cal->event[start][mday] 
     3051                                        ."&hour=".$GLOBALS['bocalendar']->so->cal->event[start][hour] 
     3052                                        ."&minute=".$GLOBALS['bocalendar']->so->cal->event[start][min] 
     3053                                        ."&title=".$GLOBALS['bocalendar']->so->cal->event['title'] 
     3054                                        ."&description=".$GLOBALS['bocalendar']->so->cal->event['description'] 
     3055                                        ."&location=".$GLOBALS['bocalendar']->so->cal->event['location']."'>" 
     3056                                        ."<h2>".lang("Add to my expresso")."</h2>"; 
     3057                                        $tempdir = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; 
     3058                                        srand((double)microtime()*1000000); 
     3059                                        $random_number = rand(100000000,999999999); 
     3060                                        $newfilename = md5(time() . getenv("REMOTE_ADDR") . $random_number ); 
     3061                                        $filename = $tempdir . $newfilename; 
     3062                                        $attach_fd = fopen($filename,"w+"); 
     3063                                        fwrite($attach_fd,$tmpattach); 
     3064                                        $mail->AddAttachment($filename, "extern.vcard", "base64", "text/plain"); // "application/octet-stream" 
     3065                                        fclose($attach_fd); 
     3066                                } 
    30813067                                $mail->From = $sender; 
    30823068                                $mail->FromName = $GLOBALS['phpgw_info']['user']['fullname']; 
     
    30853071                                $mail->Subject = lang("External event from Expresso"); 
    30863072                                $mail->Body = $tmpbody; 
    3087                                  
    3088                                 if(!$mail->Send()) 
    3089                                 { 
    3090                                         $returncode=false; 
     3073                                                                                                                                                 
     3074                                if(!$mail->Send())  
     3075                                { 
     3076                                        $returncode=false; 
     3077                                        $errorInfo['ex_participants'] = $mail->ErrorInfo; 
    30913078                                } 
    30923079                                else 
     
    31013088                        { 
    31023089                                $GLOBALS['phpgw_info']['user'] = $temp_user; 
    3103                         } 
     3090                        }        
    31043091 
    31053092                        $GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'] = $temp_tz_offset; 
     
    31073094                        $GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat'] = $temp_timeformat; 
    31083095                        $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'] = $temp_dateformat; 
    3109  
     3096                         
     3097                        // Notifica por email o criador do compromisso, com as possíveis falhas.                                                 
     3098                        if($errorInfo) { 
     3099                                $tmpbody = "<font color='red'>".lang("The following commitment had problems for DELIVERING the NOTIFICATION messages.").".</font><br>"; 
     3100                                $tmpbody.= "<br>".lang("Summary").": ".$this->so->cal->event[title]."<br>"; 
     3101                                $tmpbody.= "<br>".lang("Start time").": ".$GLOBALS['phpgw']->common->show_date($starttime)."<br>".lang("End date").": ".$GLOBALS['phpgw']->common->show_date($endtime)."<br>";                           
     3102                                $tmpbody.= "<br><u>".lang("Failed to delivery")."</u><br>"; 
     3103                                $failed = false;                                 
     3104                                if(strstr($errorInfo['participants'],"recipients_failed")){ 
     3105                                        $failed = explode("recipients_failed",$errorInfo['participants']); 
     3106                                        $tmpbody.= lang("to").": ".$failed[1]; 
     3107                                } 
     3108                                if(strstr($errorInfo['ex_participants'],"recipients_failed")){ 
     3109                                        $failed = explode("recipients_failed",$errorInfo['ex_participants']); 
     3110                                        $tmpbody.= lang("to").": ".$failed[1]; 
     3111                                }                        
     3112                                if(!$failed) { 
     3113                                        $tmpbody.= lang("Description").":<br>"; 
     3114                                        $tmpbody.= $errorInfo['participants']; 
     3115                                        $tmpbody.= "<br>".$errorInfo['ex_participants']; 
     3116                                } 
     3117                                $tmpbody.= "<br>".lang("Subject").": ".$subject; 
     3118                                // Reinicializa o objeto, devido ao erro anterior na entrega. 
     3119                                 
     3120                                $mail = new PHPMailer(); 
     3121                                $mail->IsSMTP(); 
     3122                                $mail->Host = $emailadmin['smtpServer']; 
     3123                                $mail->Port = $emailadmin['smtpPort']; 
     3124                                $mail->From = $sender; 
     3125                                $mail->FromName = $GLOBALS['phpgw_info']['user']['fullname']; 
     3126                                $mail->Sender = $mail->From; 
     3127                                $mail->SenderName = $mail->FromName; 
     3128                                $mail->IsHTML(True); 
     3129                                $mail->Subject = lang("calendar event")." - ".lang("email notification");                                                        
     3130                                $mail->Body = $tmpbody;                                  
     3131                                $mail->AddAddress($sender); 
     3132                                if(!$mail->Send())                       
     3133                                        $returncode = false; 
     3134                                else 
     3135                                        $returncode =  true; 
     3136                        } 
    31103137                        return $returncode; 
    31113138                } 
    3112  
     3139                 
    31133140                function send_alarm($alarm) 
    31143141                { 
     
    31823209                function prepare_recipients(&$new_event,$old_event) 
    31833210                { 
     3211                                                 
    31843212                        // Find modified and deleted users..... 
    31853213                        while(list($old_userid,$old_status) = each($old_event['participants'])) 
     
    32063234                                } 
    32073235                        } 
    3208  
     3236                         
    32093237                        if(count($this->added) > 0 || count($this->modified) > 0 || count($this->deleted) > 0) 
    32103238                        { 
    32113239                                if(count($this->added) > 0) 
    32123240                                { 
     3241                                        $this->ex_participants = ''; 
    32133242                                        $this->send_update(MSG_ADDED,$this->added,'',$new_event); 
    32143243                                } 
     
    32193248                                if(count($this->deleted) > 0) 
    32203249                                { 
     3250                                        $this->ex_participants = ''; 
    32213251                                        $this->send_update(MSG_DELETED,$this->deleted,$old_event); 
    32223252                                } 
     
    33703400                function event2array($event) 
    33713401                { 
     3402                         
     3403                         
    33723404                  $var['title'] = Array( 
    33733405                                'field'         => $this->translate('Title'), 
     
    33863418                                'data'  => $event['ex_participants'] 
    33873419                        ); 
    3388  
     3420                         
    33893421                        $cats = Array(); 
    33903422                        $this->cat->categories($this->bo->owner,'calendar'); 
Note: See TracChangeset for help on using the changeset viewer.