- Timestamp:
- 07/21/08 11:02:51 (16 years ago)
- Location:
- trunk/calendar
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/calendar/inc/class.bocalendar.inc.php
r313 r363 709 709 { 710 710 $event = $this->so->read_entry($event_id); 711 if(!$this->ex_participants) 712 $this->ex_participants = html_entity_decode($event['ex_participants']); 711 713 if($this->check_perms(PHPGW_ACL_DELETE,$event)) 712 714 { … … 1087 1089 ); 1088 1090 } 1091 if(!$this->ex_participants) 1092 $this->ex_participants = $event['ex_participants']; 1089 1093 if($overlapping_events) 1090 1094 { … … 1111 1115 if(!$event['id']) 1112 1116 { 1113 if(!$this->ex_participants)1114 $this->ex_participants = $event['ex_participants'];1115 1117 $this->so->add_entry($event); 1116 1118 $this->send_update(MSG_ADDED,$event['participants'],'',$this->get_cached_event()); … … 2526 2528 function create_vcard($event_array) 2527 2529 { 2530 if(!$event_array) 2531 return null; 2528 2532 $tmpattach="BEGIN:VCALENDAR\n" 2529 2533 ."PRODID:-//Expresso Livre//Calendar//EN\n" … … 2532 2536 { 2533 2537 // It translates int to string 2534 if (! 2538 if (!is_object($event) || !is_array($event) || !array_key_exists ('end', $event)) 2535 2539 $event = $event_array; 2536 2540 if ( $event['end']['month'] < 10 ) … … 2721 2725 $details['link']; 2722 2726 } 2723 2724 /*if(!is_object($GLOBALS['phpgw']->send))2725 {2726 $GLOBALS['phpgw']->send = CreateObject('phpgwapi.send');2727 }*/2728 // $send = &$GLOBALS['phpgw']->send;2729 2727 2730 2728 //Seta o email usando phpmailer … … 2734 2732 $mail = new PHPMailer(); 2735 2733 $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 */2743 2734 $boemailadmin = CreateObject('emailadmin.bo'); 2744 2735 $emailadmin_profile = $boemailadmin->getProfileList(); 2745 2736 $emailadmin = $boemailadmin->getProfile($emailadmin_profile[0]['profileID']); 2737 2746 2738 $mail->Host = $emailadmin['smtpServer']; 2747 2739 $mail->Port = $emailadmin['smtpPort']; 2748 2740 $mail->From = $GLOBALS['phpgw']->preferences->values['email']; 2749 $mail->FromName = $GLOBALS['phpgw_info']['user'] ;2741 $mail->FromName = $GLOBALS['phpgw_info']['user']['fullname']; 2750 2742 $mail->IsHTML(true); 2751 2743 … … 2753 2745 foreach($to_notify as $userid => $statusid) 2754 2746 { 2755 $mail->ClearAllRecipients();2756 2747 $mail->ClearAttachments(); 2757 2748 … … 3000 2991 $mail->SenderName = $mail->FromName; 3001 2992 $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 else3011 {3012 $returncode=true;3013 }3014 3015 //$returncode = $send->msg('email',$to,$subject,$tmpbody,''/*$msgtype*/,'','','',$sender, $content_type/*,$boundary*/);3016 3017 3018 2993 unset($vardata5); 3019 2994 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 3029 3010 if(count($to_notify) && $this->ex_participants){ 3011 $mail->ClearAllRecipients(); 3030 3012 $var = explode(",",trim($this->ex_participants)); 3031 3013 $to = array(); … … 3035 3017 list($subject,$body1) = split("\n",$GLOBALS['phpgw']->preferences->parse_notify($notify_msg,$details),2); 3036 3018 } 3019 3037 3020 foreach($var as $index => $ex_participant){ 3038 3021 $ex_participant = trim($ex_participant); … … 3041 3024 $to[] = $ex_participant; 3042 3025 } 3026 3043 3027 foreach($to as $i => $to_array) 3044 3028 $mail->AddAddress($to_array); 3029 3045 3030 $_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); 3048 3033 $tmpbody.= "<br>".lang("Summary").": ".$this->so->cal->event[title]."<br>"; 3049 3034 $tmpbody.= "<br>".lang("Start time").": ".$GLOBALS['phpgw']->common->show_date($starttime)."<br>".lang("End date").": ".$GLOBALS['phpgw']->common->show_date($endtime)."<br>"; … … 3056 3041 else 3057 3042 $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_month3061 .$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 3069 3043 //attach extern vcard 3070 3044 // define('context','$GLOBALS.bocalendar.so.cal.event'); 3071 3045 $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 } 3081 3067 $mail->From = $sender; 3082 3068 $mail->FromName = $GLOBALS['phpgw_info']['user']['fullname']; … … 3085 3071 $mail->Subject = lang("External event from Expresso"); 3086 3072 $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; 3091 3078 } 3092 3079 else … … 3101 3088 { 3102 3089 $GLOBALS['phpgw_info']['user'] = $temp_user; 3103 } 3090 } 3104 3091 3105 3092 $GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'] = $temp_tz_offset; … … 3107 3094 $GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat'] = $temp_timeformat; 3108 3095 $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 } 3110 3137 return $returncode; 3111 3138 } 3112 3139 3113 3140 function send_alarm($alarm) 3114 3141 { … … 3182 3209 function prepare_recipients(&$new_event,$old_event) 3183 3210 { 3211 3184 3212 // Find modified and deleted users..... 3185 3213 while(list($old_userid,$old_status) = each($old_event['participants'])) … … 3206 3234 } 3207 3235 } 3208 3236 3209 3237 if(count($this->added) > 0 || count($this->modified) > 0 || count($this->deleted) > 0) 3210 3238 { 3211 3239 if(count($this->added) > 0) 3212 3240 { 3241 $this->ex_participants = ''; 3213 3242 $this->send_update(MSG_ADDED,$this->added,'',$new_event); 3214 3243 } … … 3219 3248 if(count($this->deleted) > 0) 3220 3249 { 3250 $this->ex_participants = ''; 3221 3251 $this->send_update(MSG_DELETED,$this->deleted,$old_event); 3222 3252 } … … 3370 3400 function event2array($event) 3371 3401 { 3402 3403 3372 3404 $var['title'] = Array( 3373 3405 'field' => $this->translate('Title'), … … 3386 3418 'data' => $event['ex_participants'] 3387 3419 ); 3388 3420 3389 3421 $cats = Array(); 3390 3422 $this->cat->categories($this->bo->owner,'calendar');
Note: See TracChangeset
for help on using the changeset viewer.