Changeset 5132 for trunk


Ignore:
Timestamp:
11/03/11 13:21:19 (12 years ago)
Author:
wmerlotto
Message:

Ticket #2305 - Enviando alteracoes, desenvolvidas internamente na Prognus, do modulo calendar.

Location:
trunk/calendar
Files:
46 edited

Legend:

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

    r4935 r5132  
    9797                ); 
    9898 
    99                 var $wdays; 
    100  
    10199                var $debug = False; 
    102100//              var $debug = True; 
     
    111109                var $year; 
    112110                var $prefs; 
    113  
     111                var $wdays;  
    114112                var $owner; 
    115113                var $holiday_color; 
    116114                var $printer_friendly = False; 
    117  
     115                var $repetido; 
    118116                var $cached_holidays; 
    119117 
     
    142140        var $async = false; 
    143141 
     142                var $alreadyNotifieds; 
     143                var $alreadyExtNotifieds = array(); 
     144                 
     145                var $extAdded; 
     146                var $extDeleted; 
     147                 
    144148                function bocalendar($session=0) 
    145149                { 
     
    300304                                MCAL_RECUR_DAILY        => 'Daily', 
    301305                                MCAL_RECUR_WEEKLY       => 'Weekly', 
    302             //MCAL_RECUR_MONTHLY_WDAY   => 'Monthly (by day)', 
     306                                MCAL_RECUR_MONTHLY_WDAY => 'Monthly (by day)', 
    303307                                MCAL_RECUR_MONTHLY_MDAY => 'Monthly (by date)', 
    304308                                MCAL_RECUR_YEARLY       => 'Yearly' 
     
    382386                        $this->wdays = Array(MCAL_M_SUNDAY,MCAL_M_MONDAY,MCAL_M_TUESDAY,MCAL_M_WEDNESDAY, 
    383387                            MCAL_M_THURSDAY,MCAL_M_FRIDAY,MCAL_M_SATURDAY); 
    384                 } 
    385  
    386                 function delegar($idDelegador,$idDelegado,$idEvento) { 
    387  
    388                         $this->so->cal->stream->lock(array("phpgw_cal_user")); 
    389                          
    390                         if(substr($idDelegado,-1) == 'U') { 
    391                             $idDelegado = substr($idDelegado,0,-1); 
    392                         } 
    393  
    394                         $sql = "SELECT * FROM phpgw_cal_user where cal_id=$idEvento and cal_login=$idDelegado"; 
    395  
    396                         if($idDelegado != '') 
    397                         { 
    398                                 $this->so->cal->stream->query($sql,__LINE__,__FILE__); 
    399                                 if($this->so->cal->stream->next_record()) 
    400                                 { 
    401                                         throw new Exception("The selected User is already included in this event"); 
    402                                 }else{ 
    403                                         $sql = "update phpgw_cal_user set cal_login = $idDelegado,cal_status='U' where cal_id=$idEvento  
    404                                                 and cal_login=$idDelegador"; 
    405  
    406                                         $this->so->cal->stream->query($sql,__LINE__,__FILE__,0,-1,true); 
    407                                  
    408                                         $event = $this->so->read_entry($idEvento); 
    409  
    410                                         $this->send_update(MSG_ADDED,array($idDelegado => 'U'),$event,$event); 
    411                                 } 
    412                         }else { 
    413                                 throw new Exception('999'); 
    414                         } 
    415  
    416                         $this->so->cal->stream->unlock(); 
    417388                } 
    418389 
     
    656627//                              print_debug('exception time',$event['recur_exception'][count($event['recur_exception']) -1]); 
    657628//                              print_debug('count event exceptions',count($event['recur_exception'])); 
    658                                 $this->so->add_entry($event); 
     629                                $this->so->add_entry($event,true,$event['owner']); 
    659630                                $cd = 16; 
    660631 
     
    756727                                if($this->check_perms(PHPGW_ACL_DELETE,$event)) 
    757728                                { 
    758                                         $this->send_update(MSG_DELETED,$event['participants'],$event); 
     729                                        $this->send_update(MSG_DELETED,$event['participants'],$event,false,$event['owner']); 
    759730                                } 
    760731                                else 
     
    815786                    $participants = $event['participants']; 
    816787 
    817             //        $new_event = Array(); 
    818             //        $new_event['owner'] = $owner; 
    819             //        $new_event['participants'] = $participants; 
    820             //        $new_event['start'] = $event['start']; 
    821             //        $new_event['end'] = $event['end']; 
    822             // 
    823             //        $return[] = $new_event; 
    824788 
    825789                    switch($event['recur_type']) { 
     
    998962                function update($params='') 
    999963                { 
     964                        $prefix = ( $params['from_mobile'] ? "mobile.ui_mobile" : "calendar.ui" ) . "calendar"; 
    1000965                         
    1001                         if($params['from_mobile']) { 
    1002                                 $ui_return = "mobile.ui_mobilecalendar.edit"; 
    1003                                 $ui_index = "mobile.ui_mobilecalendar.index"; 
    1004                                 $ui_overlap = "mobile.ui_mobilecalendar.overlap"; 
    1005                         } 
    1006                         else { 
    1007                                 $ui_return = "calendar.uicalendar.edit"; 
    1008                                 $ui_index = "calendar.uicalendar.index";                 
    1009                                 $ui_overlap = "calendar.uicalendar.overlap"; 
    1010                         } 
     966                        $ui_return = "$prefix.edit"; 
     967                        $ui_index = "$prefix.index"; 
    1011968                         
    1012969                        if(!is_object($GLOBALS['phpgw']->datetime)) 
     
    1014971                                $GLOBALS['phpgw']->datetime = createobject('phpgwapi.date_time'); 
    1015972                        } 
    1016  
    1017973                        $l_cal = (@isset($params['cal']) && $params['cal']?$params['cal']:$_POST['cal']); 
    1018  
    1019                         $post_max_size = ini_get('post_max_size'); 
    1020                         $mul = substr($post_max_size, -1); 
    1021                         $mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1))); 
    1022                         if ($_SERVER['CONTENT_LENGTH'] > $mul*(int)$post_max_size && $post_max_size) 
    1023                              $l_cal['attachment'] = 'ERROR'; 
    1024  
    1025                         if(count($_FILES['cal']) > 0){ 
    1026  
    1027                             if($l_cal['attachment'] != '') 
    1028                                $attachments = unserialize($l_cal['attachment']); 
    1029                             else 
    1030                                $attachments = Array(); 
    1031  
    1032                             foreach ($_FILES['cal']['error']['attachment'] as $key => $error) { 
    1033  
    1034                                 if ($error == UPLOAD_ERR_OK) { 
    1035  
    1036                                     $new_file= $GLOBALS['phpgw_info']['server']['temp_dir'].'/'.$_SESSION[ 'phpgw_session' ][ 'session_id' ].md5($attachment['name'].microtime()); 
    1037                                     move_uploaded_file($_FILES['cal']['tmp_name']['attachment'][$key], $new_file); 
    1038                                     $attach = Array('tmp_name' => $new_file, 'name' => $_FILES['cal']['name']['attachment'][$key], 'type' =>  $_FILES['cal']['type']['attachment'][$key]); 
    1039  
    1040                                     $attachments[] = $attach; 
    1041  
    1042                                 }elseif($error == UPLOAD_ERR_INI_SIZE){ 
    1043                                     $attachments = 'ERROR'; 
    1044                                     break; 
    1045  
    1046                                 } 
    1047                             } 
    1048                             $l_cal['attachment'] = $attachments; 
    1049  
    1050                         } 
    1051974                        $l_participants = (@$params['participants']?$params['participants']:$_POST['participants']); 
    1052                         $this->ex_participants = (@$params['ex_participants']?$params['ex_participants']:$_POST['ex_participants']); 
     975 
     976                        require_once($_SESSION['rootPath'].'/calendar/inc/class.ex_participants.inc.php'); 
     977                        $this->ex_participants = new exParticipants(); 
     978                        $this->ex_participants->setParticipantsByString(@$params['ex_participants']?$params['ex_participants']:$_POST['ex_participants']); 
     979 
     980                        if(@$params['h_exParticipants']?$params['h_exParticipants']:$_POST['h_exParticipants']) 
     981                             $this->ex_participants->updateAttribBySerializable(@$params['h_exParticipants']?$params['h_exParticipants']:$_POST['h_exParticipants']); 
     982 
    1053983                        $l_categories = (@$params['categories']?$params['categories']:$_POST['categories']); 
    1054984                        $l_start = (@isset($params['start']) && $params['start']?$params['start']:$_POST['start']); 
     
    10831013                                        } 
    10841014                                } 
    1085                                 unset($l_cal['participants']); 
     1015 
    10861016 
    10871017                                if (!is_object($GLOBALS['phpgw']->categories)) 
     
    11201050                                $event['title'] = stripslashes($event['title']); 
    11211051                                $event['description'] = stripslashes($event['description']); 
    1122                                 $event['observations'] = stripslashes($event['observations']); 
    11231052                                $event['ex_participants'] = stripslashes($event['ex_participants']); 
    11241053                                $datetime_check = $this->validate_update($event); 
     
    11361065                                                return; 
    11371066                                } 
    1138                                 $overlapping_events = False; 
     1067                                //$overlapping_events = False; 
    11391068                        } 
    11401069                        else 
     
    11631092                                if(!isset($l_cal['ex_participants'])) 
    11641093                                { 
    1165                                         $l_cal['ex_participants'] = $this->ex_participants; 
     1094                                        $l_cal['ex_participants'] = $this->ex_participants->getParticipantsSerializable(); 
    11661095                                } 
    11671096 
     
    11731102                                $is_public = ($l_cal['type'] != 'private' && $l_cal['type'] != 'privateHiddenFields'); 
    11741103                                $this->so->event_init(); 
     1104 
     1105                                if($l_cal['uid']) 
    11751106                                $this->add_attribute('uid',$l_cal['uid']); 
     1107                                else 
     1108                                $this->add_attribute('uid',time().'@Expresso'); 
     1109                                 
     1110 
    11761111                                $this->add_attribute('type',$l_cal['type']); 
    11771112                                if($l_cal['ex_participants']) { 
     
    11881123                                $this->so->set_title($l_cal['title']); 
    11891124                                $this->so->set_description($l_cal['description']); 
    1190                                 $this->so->set_observations($l_cal['observations']); 
    1191                                 $this->so->set_notifications_owner($l_cal['notifications_owner']); 
    1192                                 $this->so->set_attachment($l_cal['attachment']); 
    11931125                                $this->so->set_ex_participants($l_cal['ex_participants']); 
    11941126                                $this->so->set_start($l_start['year'],$l_start['month'],$l_start['mday'],$l_start['hour'],$l_start['min'],0); 
     
    11971129                                $this->so->add_attribute('reference',(@isset($l_cal['reference']) && $l_cal['reference']?$l_cal['reference']:0)); 
    11981130                                $this->so->add_attribute('location',(@isset($l_cal['location']) && $l_cal['location']?$l_cal['location']:'')); 
    1199                                 $this->so->add_attribute('repeat',(@isset($l_cal['recur_type']) && $l_cal['recur_type']?$l_cal['recur_type']:'')); 
    1200                                 $this->so->add_attribute('alarmd',(@isset($l_cal['alarmdays'])?$l_cal['alarmdays']:0)); 
    1201                                 $this->so->add_attribute('alarmh',(@isset($l_cal['alarmhours'])?$l_cal['alarmhours']:0)); 
    1202                                 $this->so->add_attribute('alarmm',(@isset($l_cal['alarmminutes'])?$l_cal['alarmminutes']:0)); 
    12031131                                if($l_cal['id']) 
    12041132                                { 
     
    12221150                                                $this->so->set_recur_none(); 
    12231151 
    1224                                                 $repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao; 
    1225                                                 $this->so->add_attribute('recur_type',(@isset($repetido) && $repetido?$repetido:0)); 
    1226                                                 $this->so->add_attribute('rpt_end_use',(@isset($l_cal['rpt_use_end']) && $l_cal['rpt_use_end']?$l_cal['rpt_use_end']:'')); 
     1152                                                $this->repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao; 
    12271153 
    12281154                                                break; 
     
    12301156                                                $this->so->set_recur_daily((int)$l_recur_enddate['year'],(int)$l_recur_enddate['month'],(int)$l_recur_enddate['mday'],(int)$l_cal['recur_interval']); 
    12311157 
    1232                                                 $repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao; 
    1233                                                 $this->so->add_attribute('recur_type',(@isset($repetido) && $repetido?$repetido:0)); 
     1158                                                $this->repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao; 
    12341159 
    12351160                                                $tmp_init = explode("/",$_POST['start']['str']); // recebe a data inicial da repeticao; 
     
    12381163                                                if($l_cal['rpt_use_end'] == 'y') // verifica se foi indicada data final da repeticao, se sim: 
    12391164                                                { 
    1240                                                         $this->so->add_attribute('rpt_end_use',(@isset($l_cal['rpt_use_end']) && $l_cal['rpt_use_end']?$l_cal['rpt_use_end']:'')); 
    12411165                                                         
    12421166                                                        $tmp_end = explode("/",$_POST['recur_enddate']['str']); // recebe data final da repeticao; 
     
    12501174                                        case MCAL_RECUR_WEEKLY: 
    12511175 
    1252                                                 $repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao; 
    1253                                                 $this->so->add_attribute('recur_type',(@isset($repetido) && $repetido?$repetido:0)); 
     1176                                                $this->repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao; 
    12541177 
    12551178                                                $tmp_init = explode("/",$_POST['start']['str']); // recebe a data inicial da repeticao; 
     
    12591182                                                { 
    12601183 
    1261                                                         $this->so->add_attribute('rpt_end_use',(@isset($l_cal['rpt_use_end']) && $l_cal['rpt_use_end']?$l_cal['rpt_use_end']:'')); 
    12621184                                                        $tmp_end = explode("/",$_POST['recur_enddate']['str']); // recebe data final da repeticao; 
    12631185                                                        $end_rept = mktime($_POST['start']['hour'],$_POST['start']['min'],0,intval($tmp_end[1]),$tmp_end[0],$tmp_end[2]); // transforma a data inicial + hora e minuto de inicio da repeticao em UNIX timestamp; 
     
    12801202                                                        } 
    12811203                                                } 
    1282                                                 $this->so->add_attribute('rpt_wdays',(@isset($rpt_wdays) && $rpt_wdays?$rpt_wdays:'')); 
    12831204                                                $this->so->set_recur_weekly((int)$l_recur_enddate['year'],(int)$l_recur_enddate['month'],(int)$l_recur_enddate['mday'],(int)$l_cal['recur_interval'],$l_cal['recur_data']); 
    12841205                                                break; 
     
    12861207                                                $this->so->set_recur_monthly_mday((int)$l_recur_enddate['year'],(int)$l_recur_enddate['month'],(int)$l_recur_enddate['mday'],(int)$l_cal['recur_interval']); 
    12871208 
    1288                                                 $repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao; 
    1289                                                 $this->so->add_attribute('recur_type',(@isset($repetido) && $repetido?$repetido:0)); 
     1209                                                $this->repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao; 
    12901210 
    12911211                                                $tmp_init = explode("/",$_POST['start']['str']); // recebe a data inicial da repeticao; 
     
    12941214                                                if($l_cal['rpt_use_end'] == 'y') // verifica se foi indicada data final da repeticao, se sim: 
    12951215                                                { 
    1296                                                         $this->so->add_attribute('rpt_end_use',(@isset($l_cal['rpt_use_end']) && $l_cal['rpt_use_end']?$l_cal['rpt_use_end']:'')); 
     1216 
    12971217                                                        $tmp_end = explode("/",$_POST['recur_enddate']['str']); // recebe data final da repeticao; 
    12981218                                                        $end_rept = mktime($_POST['start']['hour'],$_POST['start']['min'],0,intval($tmp_end[1]),$tmp_end[0],$tmp_end[2]); // transforma a data inicial + hora e minuto de inicio da repeticao em UNIX timestamp; 
     
    13091229                                                $this->so->set_recur_yearly((int)$l_recur_enddate['year'],(int)$l_recur_enddate['month'],(int)$l_recur_enddate['mday'],(int)$l_cal['recur_interval']); 
    13101230 
    1311                                                 $repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao; 
    1312                                                 $this->so->add_attribute('recur_type',(@isset($repetido) && $repetido?$repetido:0)); 
     1231                                                $this->repetido = (int)$l_cal['recur_type']; // recebe o tipo de repeticao; 
    13131232 
    13141233                                                $tmp_init = explode("/",$_POST['start']['str']); // recebe a data inicial da repeticao; 
     
    13171236                                                if($l_cal['rpt_use_end'] == 'y') // verifica se foi indicada data final da repeticao, se sim: 
    13181237                                                { 
    1319                                                         $this->so->add_attribute('rpt_end_use',(@isset($l_cal['rpt_use_end']) && $l_cal['rpt_use_end']?$l_cal['rpt_use_end']:'')); 
     1238 
    13201239                                                        $tmp_end = explode("/",$_POST['recur_enddate']['str']); // recebe data final da repeticao; 
    13211240                                                        $end_rept = mktime($_POST['start']['hour'],$_POST['start']['min'],0,intval($tmp_end[1]),$tmp_end[0],$tmp_end[2]); // transforma a data inicial + hora e minuto de inicio da repeticao em UNIX timestamp; 
     
    13401259                                                } 
    13411260                                                $acct_type = $GLOBALS['phpgw']->accounts->get_type((int)$parts[$i]); 
    1342                                                 if($acct_type == 'u') 
     1261                                                if($acct_type == 'u' || $acct_type == 's') 
    13431262                                                { 
    13441263                                                        $part[(int)$parts[$i]] = $accept_type; 
     
    14221341                                $event = $this->get_cached_event(); 
    14231342 
    1424                                 if ($l_cal['alarmdays'] > 0 || $l_cal['alarmhours'] > 0 || 
    1425                                                 $l_cal['alarmminutes'] > 0) 
     1343                                if ($l_cal['alarmdays'] > 0 || $l_cal['alarmhours'] > 0 ||$l_cal['alarmminutes'] > 0) 
    14261344                                { 
    14271345                                        $offset = ($l_cal['alarmdays'] * 24 * 3600) + 
     
    14351353                                                'owner'   => $this->owner, 
    14361354                                                'enabled' => 1, 
    1437                                                 'repeat'  => $repetido, // para repetir alarme; 
     1355                                                'repeat'  => $this->repetido, // para repetir alarme; 
    14381356                                                'init_rept' => $init_rept, // inicio repeticao; 
    14391357                                                'end_rept' => $end_rept, // fim repeticao; 
     
    14631381                                } 
    14641382 
     1383                            $overlapping_events = $this->event_overlap( $event, $send_to_ui, $prefix ); 
     1384 
     1385                            if( $overlapping_events ) 
     1386                                return( $overlapping_events ); 
     1387                        } 
     1388 
     1389                                $event['ex_participants'] = $this->ex_participants->getParticipantsSerializable(); 
     1390                         
     1391                        if($event['owner'] != $GLOBALS['phpgw_info']['user']['account_id']) $userSend = $event['owner']; 
     1392                        else $userSend = false; 
     1393        
     1394                        if(!$event['id']) 
     1395                        { 
     1396                                /** Whenever a recurrent event is edit in a way that a new   
     1397                                 * exception is created, an exception must be added to  
     1398                                 * the old event. This is necessary to keep consistency  
     1399                                 * with synchornization solutions in accordancy to  
     1400                                 * the iCalendar RFC.  
     1401                                 */  
     1402                                $old_event = $this->so->read_entry($_POST['cal']['reference']);  
     1403 
     1404                                $date = $_POST['cal']['date'];  
     1405                                $year  = substr($date,0,4);  
     1406                                $month = substr($date,4,2);  
     1407                                $day   = substr($date,6,2);  
     1408 
     1409                                $exception_time = mktime($old_event['start']['hour'],$old_event['start']['min'],0,$month,$day,$year) - $GLOBALS['phpgw']->datetime->tz_offset;  
     1410                                $old_event['recur_exception'][] = (int)$exception_time;  
     1411                                $this->so->add_entry($old_event,false);  
     1412                             
     1413                             
     1414                                $this->so->add_entry($event,false); 
     1415                                print_debug('New Event ID',$event['id']); 
     1416                                $send_type = MSG_ADDED; 
     1417                        } 
     1418                        else 
     1419                        { 
     1420                                print_debug('Updating Event ID',$event['id']); 
     1421                                $new_event = $event; 
     1422                                $old_event = $this->read_entry($event['id']); 
     1423                                // if old event has alarm and the start-time changed => update them 
     1424                                //echo "<p>checking ".count($old_event['alarm'])." alarms of event #$event[id] start moved from ".print_r($old_event['start'],True)." to ".print_r($event['start'],True)."</p>\n"; 
     1425                                if ($old_event['alarm'] && 
     1426                                        $this->maketime($old_event['start']) != $this->maketime($event['start'])) 
     1427                                { 
     1428                                        $this->so->delete_alarms($old_event['id']); 
     1429                                        foreach($old_event['alarm'] as $id => $alarm) 
     1430                                        { 
     1431                                                $alarm['time'] = $this->maketime($event['start']) - $alarm['offset']; 
     1432                                                $event['alarm'][] = $alarm; 
     1433                                        } 
     1434                                        //echo "updated alarms<pre>".print_r($event['alarm'],True)."</pre>\n"; 
     1435                                } 
     1436                                $this->so->cal->event = $event; 
     1437                                $this->so->add_entry($event,false); 
     1438                                $this->prepare_recipients($new_event,$old_event,$userSend); 
     1439                                $send_type = MSG_MODIFIED; 
     1440                        } 
     1441                      
     1442                        //Retira da lista usuarios ja notificados 
     1443                        $to_notify = $event['participants']; 
     1444                        foreach ($this->alreadyNotifieds as $key => $value)  
     1445                            if(array_key_exists($value,$to_notify)) 
     1446                                unset ($to_notify[$value]); 
     1447                        //------------------------------------------------// 
     1448                            
     1449                        if(count($to_notify) > 0 && $userSend !== -2)     
     1450                            $this->send_update( $send_type,$to_notify,'',$this->get_cached_event(),$userSend); 
     1451 
     1452                        $date = sprintf("%04d%02d%02d",$event['start']['year'],$event['start']['month'],$event['start']['mday']); 
     1453                        if($send_to_ui) 
     1454                        { 
     1455                                $this->read_sessiondata(); 
     1456                                if ($this->return_to) 
     1457                                { 
     1458                                        $GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->return_to); 
     1459                                        $GLOBALS['phpgw']->common->phpgw_exit(); 
     1460                                } 
     1461                                Execmethod($ui_index); 
     1462                        } 
     1463                        else 
     1464                        { 
     1465                                return (int)$event['id']; 
     1466                        } 
     1467 
     1468                        return True; 
     1469                } 
     1470 
     1471                function event_overlap( $event, $send_to_ui = false, $prefix = "calendar.uicalendar" ,$user = false) 
     1472                { 
     1473                    $event_ids = array(); 
     1474 
    14651475                                if($event['id']) 
    14661476                                { 
     
    14721482                                } 
    14731483 
    1474                                 if (isset($repetido) and $repetido > 0){ 
     1484                    if (isset($this->repetido) and $this->repetido > 0) 
     1485                    {  
    14751486                                    $events = $this->expand_repetition($event); 
    14761487                                    $overlapping_events = False; 
     
    14921503                                    } 
    14931504                                } 
    1494                                 else { 
     1505                    else  
     1506                    {  
    14951507                                    $overlapping_events = $this->overlap( 
    14961508                                        $this->maketime($event['start']), 
     
    15011513                                    ); 
    15021514                                } 
    1503                         } 
    1504                         if(!$this->ex_participants) 
    1505                                 $this->ex_participants = $event['ex_participants'];                      
     1515                                       
    15061516                        if($overlapping_events) 
    15071517                        { 
     1518                            $this->store_to_appsession( $event ); 
    15081519                                if($send_to_ui) 
    15091520                                { 
    1510                                         $event['ex_participants'] = $this->ex_participants; 
    15111521                                        unset($GLOBALS['phpgw_info']['flags']['noheader']); 
    15121522                                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']); 
    1513                                         ExecMethod($ui_overlap, 
     1523                                    ExecMethod("$prefix.overlap", 
    15141524                                                Array( 
    15151525                                                        'o_events'      => $overlapping_events, 
    1516                                                         'this_event'    => $event 
     1526                                                    'this_event'        => $event, 
     1527                                                    'this_account' => $user 
    15171528                                                ) 
    15181529                                        ); 
    1519                                         if(!$params['from_mobile']) 
     1530 
     1531                                    if( $prefix === "calendar.uicalendar" ) 
    15201532                                                $GLOBALS['phpgw']->common->phpgw_exit(True); 
    1521                                         else 
    1522                                                 return; 
    1523                                 } 
    1524                                 else 
    1525                                 { 
    1526                                         return $overlapping_events; 
    1527                                 } 
    1528                         } 
    1529                         else 
    1530                         { 
    1531                                 if(!$event['id']) 
    1532                                 { 
    1533                                         $this->so->add_entry($event); 
    1534                                         $this->send_update(MSG_ADDED,$event['participants'],'',$this->get_cached_event()); 
    1535                                         print_debug('New Event ID',$event['id']); 
    1536                                 } 
    1537                                 else 
    1538                                 { 
    1539                                         print_debug('Updating Event ID',$event['id']); 
    1540                                         $new_event = $event; 
    1541                                         $old_event = $this->read_entry($event['id']); 
    1542                                         // if old event has alarm and the start-time changed => update them 
    1543                                         //echo "<p>checking ".count($old_event['alarm'])." alarms of event #$event[id] start moved from ".print_r($old_event['start'],True)." to ".print_r($event['start'],True)."</p>\n"; 
    1544                                         if ($old_event['alarm'] && 
    1545                                                 $this->maketime($old_event['start']) != $this->maketime($event['start'])) 
    1546                                         { 
    1547                                                 $this->so->delete_alarms($old_event['id']); 
    1548                                                 foreach($old_event['alarm'] as $id => $alarm) 
    1549                                                 { 
    1550                                                         $alarm['time'] = $this->maketime($event['start']) - $alarm['offset']; 
    1551                                                         $event['alarm'][] = $alarm; 
    1552                                                 } 
    1553                                                 //echo "updated alarms<pre>".print_r($event['alarm'],True)."</pre>\n"; 
    1554                                         } 
    1555                                         $this->so->cal->event = $event; 
    1556                                         $this->so->add_entry($event); 
    1557                                         $this->prepare_recipients($new_event,$old_event); 
    1558                                 } 
    1559  
    1560                                 $date = sprintf("%04d%02d%02d",$event['start']['year'],$event['start']['month'],$event['start']['mday']); 
    1561                                 if($send_to_ui) 
    1562                                 { 
    1563                                         $this->read_sessiondata(); 
    1564                                         if ($this->return_to) 
    1565                                         { 
    1566                                                 $GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->return_to); 
    1567                                                 $GLOBALS['phpgw']->common->phpgw_exit(); 
    1568                                         } 
    1569                                         Execmethod($ui_index); 
    1570                                 } 
    1571                                 else 
    1572                                 { 
    1573                                         return (int)$event['id']; 
    1574                                 } 
    1575                         } 
    1576                         return True; 
     1533                                } 
     1534 
     1535                            return( $overlapping_events ); 
     1536                        } 
     1537 
     1538                    return( false ); 
    15771539                } 
    15781540 
     
    17001662                                $error = 43; 
    17011663                        } 
    1702                         elseif ($event['type'] != 'hourAppointment' && $event['title'] == '') 
     1664                        elseif ($event['title'] == '') 
    17031665                        { 
    17041666                                $error = 40; 
    17051667                        } 
    1706                         elseif ($event['repeat'] != 0) 
    1707                         { 
    1708                                 if( $event['rpt_end_use'] != 'y') 
    1709                                 { 
    1710                                         $error = 46; 
    1711                                 } 
    1712                         //} 
    1713                           if ($event['repeat'] == 2) 
    1714                           { 
    1715                                 if($event['rpt_wdays'] == '') { 
    1716                                         $error = 44; 
    1717                                 } 
    1718                                 if( $event['rpt_end_use'] != 'y') 
    1719                                 { 
    1720                                         $error = 46; 
    1721                                 } 
    1722  
    1723                                 if (  ( isset($event['alarmd'])  && ($event['alarmd'] != 0) ) || ( isset($event['alarmh'])  && ($event['alarmh'] != 0) ) || ( isset($event['alarmm'])  && ($event['alarmm'] != 0) ) ) 
    1724                                 { 
    1725                                         if( isset($event['recur_type']) && ($event['recur_type'] != 0) ) 
    1726                                         { 
    1727                                                 if( $event['rpt_end_use'] != 'y') 
    1728                                                 { 
    1729                                                         $error = 45; 
    1730                                                 } 
    1731                                         } 
    1732                                 } 
    1733                            } 
    1734  
    1735                         //} 
    1736                   if (  ( isset($event['alarmd'])  && ($event['alarmd'] != 0) ) || ( isset($event['alarmh'])  && ($event['alarmh'] != 0) ) || ( isset($event['alarmm'])  && ($event['alarmm'] != 0) ) ) 
    1737                   { 
    1738                         if( isset($event['recur_type']) && ($event['recur_type'] != 0) ) 
    1739                         { 
    1740                                 if( $event['rpt_end_use'] != 'y') 
    1741                                 { 
    1742                                         $error = 45; 
    1743                                 } 
    1744                         } 
    1745                   } 
    1746                 } 
    17471668                        elseif (($GLOBALS['phpgw']->datetime->time_valid($event['start']['hour'],$event['start']['min'],0) == False) || ($GLOBALS['phpgw']->datetime->time_valid($event['end']['hour'],$event['end']['min'],0) == False)) 
    17481669                        { 
    17491670                                $error = 41; 
    17501671                        } 
    1751                         elseif (($GLOBALS['phpgw']->datetime->date_valid($event['start']['year'],$event['start']['month'],$event['start']['mday']) == False)  
    1752                                 || ($GLOBALS['phpgw']->datetime->date_valid($event['end']['year'],$event['end']['month'],$event['end']['mday']) == False) 
    1753                                 || ($GLOBALS['phpgw']->datetime->date_compare($event['start']['year'],$event['start']['month'],$event['start']['mday'],$event['end']['year'],$event['end']['month'],$event['end']['mday']) == 1) 
    1754                                 || $event['start']['year'] > 2037 || $event['end']['year'] > 2037) 
     1672                        elseif (($GLOBALS['phpgw']->datetime->date_valid($event['start']['year'],$event['start']['month'],$event['start']['mday']) == False) || ($GLOBALS['phpgw']->datetime->date_valid($event['end']['year'],$event['end']['month'],$event['end']['mday']) == False) || ($GLOBALS['phpgw']->datetime->date_compare($event['start']['year'],$event['start']['month'],$event['start']['mday'],$event['end']['year'],$event['end']['month'],$event['end']['mday']) == 1)) 
    17551673                        { 
    17561674                                $error = 42; 
     
    17581676                        elseif ($GLOBALS['phpgw']->datetime->date_compare($event['start']['year'],$event['start']['month'],$event['start']['mday'],$event['end']['year'],$event['end']['month'],$event['end']['mday']) == 0) 
    17591677                        { 
    1760                                 if ( ($GLOBALS['phpgw']->datetime->time_compare($event['start']['hour'],$event['start']['min'],0,$event['end']['hour'],$event['end']['min'],0) == 1) 
    1761                                    ||($GLOBALS['phpgw']->datetime->time_compare($event['start']['hour'],$event['start']['min'],0,$event['end']['hour'],$event['end']['min'],0) == 0) ) 
    1762                                 { 
    1763                                         $error = 47; 
    1764                                 } 
    1765                         } 
    1766                         if($event['attachment'] == 'ERROR') 
    1767                             $error = 99; 
     1678                                if ($GLOBALS['phpgw']->datetime->time_compare($event['start']['hour'],$event['start']['min'],0,$event['end']['hour'],$event['end']['min'],0) == 1) 
     1679                                { 
     1680                                        $error = 42; 
     1681                                } 
     1682                        } 
    17681683                         
    17691684                        return $error; 
     
    17891704                } 
    17901705                 
    1791                 function participants_unanswered($participants,$event) 
    1792                 { 
    1793                         foreach($participants as $uid => $status) 
    1794                         {                                
    1795                                 if (isset($event['participants'][$uid]) && $event['participants'][$uid] == 'U' && $status == 'U') 
    1796                                 { 
    1797                                         return False; 
    1798                                 } 
    1799                         } 
    1800                         return True; 
    1801                 } 
    1802  
    18031706                function overlap($starttime,$endtime,$participants,$owner=0,$id=0,$restore_cache=False) 
    18041707                { 
     
    19091812                                                                $temp_start_time >= $temp_event_start && 
    19101813                                                                $temp_end_time <= $temp_event_end) && 
    1911                                                                 $this->participants_not_rejected($participants,$event) && $this->participants_unanswered($participants,$event)) 
     1814                                                                $this->participants_not_rejected($participants,$event)) 
    19121815                                                        { 
    19131816                                                                if($this->debug) 
     
    20801983                function get_short_field($event,$is_private=True,$field='') 
    20811984                { 
    2082                         if($is_private) 
     1985                        if($is_private && $event['type'] == 'E') 
     1986                        { 
     1987                                return lang('Restrict'); 
     1988                        } 
     1989                        else if($is_private && $event['type'] == 'P') 
    20831990                        { 
    20841991                                return lang('private'); 
     
    23422249                        $search_date_day = date('d',$datetime); 
    23432250                        $search_date_dow = date('w',$datetime); 
    2344                         $search_beg_day = mktime(12,0,0,$search_date_month,$search_date_day,$search_date_year); 
     2251                        $search_beg_day = mktime(0,0,0,$search_date_month,$search_date_day,$search_date_year); 
    23452252                        if($this->debug) 
    23462253                        { 
     
    24092316                                                        break; 
    24102317                                                case MCAL_RECUR_WEEKLY: 
    2411                                                         if (floor(($search_beg_day - $event_beg_day)/604800)  % ($freq ? $freq : 1)) 
     2318                                                        if ((floor($search_beg_day / 604800) - floor($event_beg_day / 604800)) % $freq) 
    24122319                                                        { 
    24132320                                                                continue; 
     
    29342841                @abstract set the participant response $status for event $cal_id and notifies the owner of the event 
    29352842                */ 
    2936                 function set_status($cal_id,$status) 
     2843                function set_status($cal_id,$status,$user = false) 
    29372844                { 
    29382845                        $status2msg = array( 
     
    29462853                        } 
    29472854                        $event = $this->so->read_entry($cal_id); 
    2948                         $account_id = $GLOBALS['phpgw_info']['user']['account_id']; 
     2855                        if($user) $account_id = $user; 
     2856                        else $account_id = $GLOBALS['phpgw_info']['user']['account_id']; 
    29492857                        if(($status2msg[$status] == "5" && $event['participants'][$account_id] == "A") || 
    29502858                         ($status2msg[$status] == "3" && $event['participants'][$account_id] == "R")) { 
    29512859                                return True; 
    29522860                        } 
    2953                         $this->so->set_status($cal_id,$status); 
     2861                        $this->so->set_status($cal_id,$status,$account_id); 
    29542862                        $event = $this->so->read_entry($cal_id); 
    2955                         $this->send_update($status2msg[$status],$event['participants'],$event); 
    2956  
     2863                        $this->send_update($status2msg[$status],$event['participants'],$event,false,$account_id); 
     2864 
     2865                        $sts = array_values( $event['participants'] ); 
     2866 
     2867                        //verifica se todos os participantes rejeitaram o evento 
     2868                        while( $sts[0] && $sts[0] === 'R' ) array_pop( $sts ); 
     2869 
     2870                        if( empty( $sts ) ) 
     2871                        { 
     2872                                $this->so->delete_entry( $cal_id ); 
     2873                                $this->so->expunge(); 
     2874                        } 
    29572875                } 
    29582876 
     
    30152933                } 
    30162934 
    3017                 function create_vcard($event_arrays) 
    3018                 { 
     2935 
     2936                function create_vcard($event_arrays , $metodo = 'PUBLISH', $externo = false,$importAccount = false) 
     2937                { 
     2938                    if(!$importAccount) 
     2939                        $importAccount['mail'] = $GLOBALS['phpgw_info']['user']['email']; 
     2940 
    30192941            if(!is_array($event_arrays)) 
    30202942                                return null; 
    30212943 
    3022                         $sender = $GLOBALS['phpgw_info']['user']['email']; 
    3023                         $uid_dono = $GLOBALS['phpgw_info']['user']['account_lid']; 
    3024                         $tmpattach="BEGIN:VCALENDAR\n" 
    3025                         ."PRODID:-//Expresso Livre//Calendar//EN\n" 
    3026                         ."VERSION:1.0\n"; 
    3027             foreach ($event_arrays as $event) 
    3028             { 
    3029                                 // It translates int to string 
    3030                                 if (!is_object($event) && !is_array($event) || !array_key_exists  ('end', $event)) 
    3031                                         $event = $event_arrays; 
    3032  
    3033                                 //set to GMT 
    3034                                 //Aqui estou pegando o horário do evento e setando para GMT de acordo com o fuso horário estabelecido nas configurações do expresso. 
    3035                                 $start_time = mktime($event['start']['hour'],$event['start']['min'],$event['start']['sec'],$event['start']['month'],$event['start']['mday'],$event['start']['year']) - $GLOBALS['phpgw']->datetime->tz_offset; 
    3036                                 $end_time = mktime($event['end']['hour'],$event['end']['min'],$event['end']['sec'],$event['end']['month'],$event['end']['mday'],$event['end']['year']) - $GLOBALS['phpgw']->datetime->tz_offset; 
    3037                                  
    3038                                 $start_time = date("Ymd\THis\Z", $start_time); 
    3039                                 $end_time = date("Ymd\THis\Z", $end_time); 
     2944                    $tmpattach="BEGIN:VCALENDAR\r\n" 
     2945                        ."PRODID:-//Expresso Livre//Calendar//EN\r\n" 
     2946                        ."VERSION:2.0\r\n" 
     2947                        ."CALSCALE:GREGORIAN\r\n" 
     2948                        ."METHOD:".$metodo."\r\n"; 
     2949 
     2950                    //$offset = ((int)substr(date('O',$GLOBALS['phpgw']->datetime->users_localtime), 0, 3)); 
     2951                    $offset = (($GLOBALS['phpgw']->datetime->tz_offset)/60)/60; 
    30402952         
    3041                                 // Necessário espaços após quebra-de-linha, na descrição, caso contrário  
    3042                                 // ocorrerá erro ao importar o agendamento no Outlook (erro lunar). 
    3043                                 $description = str_replace("\n","\n ", $event['description']); 
    3044                                  
    3045                                 $tmpattach.="BEGIN:VEVENT\r\n" 
    3046                                 ."DTSTART:".$start_time."\r\n" 
    3047                                 ."DTEND:".$end_time."\r\n" 
     2953                        foreach ($event_arrays as $event_array) 
     2954                        { 
     2955                            $sy = $event_array['start']['year']; 
     2956                            $sm = $event_array['start']['month']; 
     2957                            $sd = $event_array['start']['mday']; 
     2958                            $sh = $event_array['start']['hour'] -= $offset; 
     2959                            $sn = $event_array['start']['min']; 
     2960                            $dtstart = sprintf("%04d%02d%02dT%02d%02d00Z", $sy, $sm, $sd, $sh, $sn); 
     2961 
     2962                            $ey = $event_array['end']['year']; 
     2963                            $em = $event_array['end']['month']; 
     2964                            $ed = $event_array['end']['mday']; 
     2965                            $eh = $event_array['end']['hour'] -= $offset; 
     2966                            $en = $event_array['end']['min']; 
     2967                            $dtend = sprintf("%04d%02d%02dT%02d%02d00Z", $ey, $em, $ed, $eh, $en); 
     2968 
     2969                            // Necessário espaços após quebra-de-linha, na descrição, caso contrário 
     2970                            // ocorrerá erro ao importar o agendamento no Outlook (erro lunar). 
     2971                            $description = str_replace("\n","\n ",$event_array['description']); 
     2972                            $tmpattach.="BEGIN:VEVENT\r\n"; 
     2973                                                         
     2974                                                        if(isset($event_array['organizer']) && $event_array['owner'] != -2) 
     2975                                                        { 
     2976                                $ldap = $this->getLdap();   
     2977                                $justthese = array("mail","cn"); 
     2978                                $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=l)(phpgwAccountType=s)(phpgwAccountType=i))(uidNumber=".$event_array['owner']."))"; 
     2979                                $search = ldap_search($ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); 
     2980                                $entry = ldap_get_entries($ldap, $search);                                         
     2981                                                                $organizer = 'ORGANIZER;CN='.$entry[0]['cn'][0].':mailto:'.$entry[0]['mail'][0]."\r\n"; 
     2982                                                        }    
     2983                                                        else{    
     2984                                                                $email = explode('&lt;', $event_array['organizer']); 
     2985                                                                $email2 = explode('&gt;', $email[1]); 
     2986                                $organizer = 'ORGANIZER;CN='.rtrim($email[0]).':mailto:'.$email2[0]."\r\n"; 
     2987                                                        } 
     2988                                                                  
     2989                            if(!$externo) 
     2990                            { 
     2991                                                            $tmpattach.= 
     2992                                "DTSTART:".$dtstart."\r\n" 
     2993                                ."DTEND:".$dtend."\r\n" 
    30482994                                ."LAST-MODIFIED:".gmdate("Ymd\THis\Z")."\r\n" //Hora no formato UTC 
    3049                                 //."UID:Expresso-".$event['id'].$event['uid']."\r\n" 
    3050                                 ."UID:Expresso-".$event[id]."@".$uid_dono."\n" 
     2995                                                                .$organizer 
     2996                                ."UID:".$event_array['uid']."\r\n" 
     2997                                                                .$this->mb_wordwrap($this->getvCalendarParticipants($event_array['participants'],$event_array['id']),74,"\r\n ") 
     2998                                                                .$this->mb_wordwrap($this->getvCalendarExternalParticipants($event_array['id']),74,"\r\n ") 
    30512999                                ."DESCRIPTION:".$description."\r\n" 
    3052                                 ."SUMMARY:".$event['title']."\r\n" 
    3053                                 ."LOCATION:".$event['location']."\r\n" 
    3054                                 ."ORGANIZER:mailto:".$sender."\n"; 
    3055                                 $expart=preg_split('/,/', $event['ex_participants']); 
    3056  
    3057                                 foreach ($expart as $mail) 
     3000                                ."SUMMARY:".$event_array['title']."\r\n" 
     3001                                ."LOCATION:".$event_array['location']."\r\n" 
     3002                                ."END:VEVENT\r\n"; 
     3003                            } 
     3004                             else 
     3005                            { 
     3006                                                                $tmpattach.= 
     3007                                "DTSTART:".$dtstart."\r\n" 
     3008                                ."DTEND:".$dtend."\r\n" 
     3009                                ."DTSTAMP:".gmdate("Ymd\THis\Z")."\r\n" //Hora no formato UTC 
     3010                                .$organizer 
     3011                                .$this->mb_wordwrap("UID:".$event_array['uid']."\r\n",74,"\r\n "); 
     3012 
     3013                                switch ($metodo) { 
     3014                                    case 'PUBLISH': 
     3015                                          $tmpattach.= 
     3016                                             $this->mb_wordwrap($this->getvCalendarParticipants($event_array['participants'],$event_array['id']),74,"\r\n ") 
     3017                                                                                        .$this->mb_wordwrap($this->getvCalendarExternalParticipants($event_array['id']),74,"\r\n ") 
     3018                                            .$this->mb_wordwrap("DESCRIPTION:".$description."\r\n",74,"\r\n ") 
     3019                                            .$this->mb_wordwrap("SUMMARY:".$event_array['title']."\r\n",74,"\r\n ") 
     3020                                            .$this->mb_wordwrap("LOCATION:".$event_array['location']."\r\n",74,"\r\n "); 
     3021                                        break; 
     3022                                    case 'REPLY': 
     3023                                            $tmpattach.= 
     3024                                             $this->mb_wordwrap("ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;X-NUM-GUESTS=0:mailto:".$importAccount['mail']."\r\n",74,"\r\n ") 
     3025                                            .'DESCRIPTION:\n'."\r\n" 
     3026                                            .$this->mb_wordwrap("LAST-MODIFIED:".gmdate("Ymd\THis\Z")."\r\n",74,"\r\n ") //Hora no formato UTC 
     3027                                            .$this->mb_wordwrap("LOCATION:".$event_array['location']."\r\n",74,"\r\n ") 
     3028                                            ."SEQUENCE:0\r\n" 
     3029                                            ."STATUS:CONFIRMED\r\n" 
     3030                                            .$this->mb_wordwrap("SUMMARY:".$event_array['title']."\r\n",74,"\r\n ") 
     3031                                            ."TRANSP:OPAQUE\r\n"; 
     3032                                        break; 
     3033                                    default: 
     3034                                           $tmpattach.= 
     3035                                             "DESCRIPTION:".$description."\r\n" 
     3036                                            ."SUMMARY:".$event_array['title']."\r\n" 
     3037                                            ."LOCATION:".$event_array['location']."\r\n"; 
     3038                                        break; 
     3039                                } 
     3040                                  $tmpattach.= "END:VEVENT\r\n"; 
     3041                            } 
     3042                             
     3043                        } 
     3044                    $tmpattach.="END:VCALENDAR\r\n\r\n\r\n"; 
     3045                    return $tmpattach; 
     3046                } 
     3047 
     3048                function mb_wordwrap($str, $width=74, $break="\r\n") 
     3049                { 
     3050                    // Return short or empty strings untouched 
     3051                    if(empty($str) || mb_strlen($str, 'ISSO-8859-1') <= $width) 
     3052                        return $str; 
     3053 
     3054                    $br_width  = mb_strlen($break, 'ISSO-8859-1'); 
     3055                    $str_width = mb_strlen($str, 'ISSO-8859-1'); 
     3056                    $return = ''; 
     3057                    $last_space = false; 
     3058 
     3059                    for($i=0, $count=0; $i < $str_width; $i++, $count++) 
     3060                    { 
     3061                        // If we're at a break 
     3062                        if (mb_substr($str, $i, $br_width, 'ISSO-8859-1') == $break) 
     3063                        { 
     3064                            $count = 0; 
     3065                            $return .= mb_substr($str, $i, $br_width, 'ISSO-8859-1'); 
     3066                            $i += $br_width - 1; 
     3067                            continue; 
     3068                        } 
     3069 
     3070                        // Keep a track of the most recent possible break point 
     3071                        if(mb_substr($str, $i, 1, 'ISSO-8859-1') == " ") 
     3072                        { 
     3073                            $last_space = $i; 
     3074                        } 
     3075 
     3076                        // It's time to wrap 
     3077                        if ($count > $width) 
    30583078                                { 
    3059                                     if($mail != "") 
     3079                            // There are no spaces to break on!  Going to truncate :( 
     3080                            if(!$last_space) 
    30603081                                    { 
    3061                                         $tmpattach.="ATTENDEE;RSVP=TRUE;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:mailto:".$mail."\n"; 
     3082                                $return .= $break; 
     3083                                $count = 0; 
     3084                            } 
     3085                            else 
     3086                            { 
     3087                                // Work out how far back the last space was 
     3088                                $drop = $i - $last_space; 
     3089 
     3090                                // Cutting zero chars results in an empty string, so don't do that 
     3091                                if($drop > 0) 
     3092                                { 
     3093                                    $return = mb_substr($return, 0, -$drop); 
     3094                                } 
     3095 
     3096                                // Add a break 
     3097                                $return .= $break; 
     3098 
     3099                                // Update pointers 
     3100                                $i = $last_space + ($br_width - 1); 
     3101                                $last_space = false; 
     3102                                $count = 0; 
    30623103                                    } 
    30633104                                } 
    30643105                                 
    3065                                 while (list($id,$status) = each($event['participants'])) 
     3106                        // Add character from the input string to the output 
     3107                        $return .= mb_substr($str, $i, 1, 'ISSO-8859-1'); 
     3108                    } 
     3109                    return $return; 
     3110                } 
     3111 
     3112                function getvCalendarParticipants($pExtParticipants,$pCalId) 
    30663113                                { 
    3067  
    3068                                       $preferences = CreateObject('phpgwapi.preferences',$id); 
    3069                                       $mail = $preferences->email_address($id); 
    3070                                       if ( $sender != $mail) 
     3114                    $participants = explode(',', $pExtParticipants); 
     3115                    $return = ''; 
     3116 
     3117                    foreach ($participants as $participant) 
    30713118                                      { 
    3072                                          if($status == 'U' ){ 
    3073                                                   $tmpattach.="ATTENDEE;RSVP=TRUE;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:mailto:".$mail."\n"; 
     3119                        $array = explode('"', $participant); 
     3120                        $mail = str_replace('<','', str_replace('>','',$array['2'])); 
     3121                        if($mail && $array['1']) 
     3122                             $return .= 'ATTENDEE;CN='.$array['1'].';RSVP=TRUE:mailto:'.$mail."\r\n"; 
     3123                    } 
     3124                    $db = $this->getDb(); 
     3125                    $db->query('SELECT cal_login FROM phpgw_cal_user WHERE cal_id = '.$pCalId); 
     3126                    $parts = array(); 
     3127                    while($db->next_record()) 
     3128                        array_push($parts, $db->row()); 
     3129 
     3130                    $ldap = $this->getLdap(); 
     3131                    foreach ($parts as $part) 
     3132                    { 
     3133                        $justthese = array('mail','cn'); 
     3134                        $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=l))(uidNumber=".$part['cal_login']."))"; 
     3135                        $search = ldap_search($ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); 
     3136                        $entry = ldap_get_entries($ldap, $search); 
     3137                        $return .= 'ATTENDEE;CN='.$entry[0]['cn'][0].';RSVP=TRUE:mailto:'.$entry[0]['mail'][0]."\r\n"; 
    30743138                                                        } 
    3075                                          elseif($status == 'A' ){ 
    3076                                                  $tmpattach.="ATTENDEE;RSVP=TRUE;PARTSTAT=ACCEPTED;ROLE=REQ-PARTICIPANT:mailto:".$mail."\n"; 
     3139 
     3140                    return $return; 
    30773141                                                        } 
    3078                                          elseif($status == 'T' ){ 
    3079                                                  $tmpattach.="ATTENDEE;RSVP=TRUE;PARTSTAT=TENTATIVE;ROLE=REQ-PARTICIPANT:mailto:".$mail."\n"; 
     3142                                 
     3143                function getCalendarParticipantsArray($pCalId) 
     3144                { 
     3145                    $db = $this->getDb(); 
     3146                    $db->query('SELECT cal_login FROM phpgw_cal_user WHERE cal_id = '.$pCalId); 
     3147                    $parts = array(); 
     3148                    while($db->next_record()) 
     3149                        array_push($parts, $db->row()); 
     3150 
     3151                    $ldap = $this->getLdap(); 
     3152                    foreach ($parts as $part) 
     3153                    { 
     3154                        $justthese = array('mail','cn'); 
     3155                        $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=l))(uidNumber=".$part['cal_login']."))"; 
     3156                        $search = ldap_search($ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); 
     3157                        $entry = ldap_get_entries($ldap, $search); 
     3158                        $return [$entry[0]['mail'][0]] = array( 'CN'=> $entry[0]['cn'][0],'RSVP'=> 'TRUE' ,'ROLE' => 'REQ-PARTICIPANT'); 
     3159                    } 
     3160                    return $return; 
     3161                } 
     3162 
     3163                function getvCalendarExternalParticipants($pCalId) 
     3164                { 
     3165 
     3166                    $db = $this->getDb(); 
     3167                    $sql = "SELECT ex_participants FROM phpgw_cal WHERE cal_id = '$pCalId'"; 
     3168                                $db->query($sql); 
     3169                                 
     3170                    $parts = array(); 
     3171                    while($db->next_record()) 
     3172                        array_push($parts, $db->row()); 
     3173 
     3174                                        $participants = explode(',', $parts[0]['ex_participants']); 
     3175                    $return = ''; 
     3176                                         
     3177                                        $participants = unserialize(base64_decode($parts[0]['ex_participants'])); 
     3178 
     3179                    foreach ($participants as $participant) 
     3180                    {    
     3181                           $part = array(); 
     3182 
     3183                           if(preg_match("(\"[^\"]*\"[ ]*<[^>]*@[^>]*>)", $participant['mail'])) 
     3184                           { 
     3185                              $cn = null; 
     3186                              $mail = null; 
     3187                              preg_match ("(\"([^\"]*)\")", $participant['mail'], $cn); 
     3188                              preg_match ('(<([^>]*@[^>]*)>)', $participant['mail'], $mail); 
     3189 
     3190                              if($mail[1]) 
     3191                              $part['mail'] =  $mail[1]; 
     3192 
     3193                              if($cn[1]) 
     3194                                $part['cn'] =  $cn[1]; 
     3195 
    30803196                                                         } 
    30813197                                         else 
     3198                           if(preg_match("(<[^>]*@[^>]*>)", $participant['mail'])) 
    30823199                                                  { 
    3083                                                      $tmpattach.="ATTENDEE;RSVP=TRUE;PARTSTAT=DECLINED;ROLE=REQ-PARTICIPANT:mailto:".$mail."\n"; 
     3200                              $mail = null; 
     3201                              preg_match ('(<([^>]*@[^>]*)>)', $participant['mail'], $mail); 
     3202                              if($mail[1]) 
     3203                                $part['mail'] =  $mail[1]; 
     3204 
    30843205                                                   } 
     3206                           else 
     3207                           if(preg_match("([^ ]*@[^ ]*)", $participant['mail'])) 
     3208                           { 
     3209                              $mail = null; 
     3210                              preg_match ('([^ ]*@[^ ]*)', $participant['mail'], $mail); 
     3211                              if($mail[0]) 
     3212                                $part['mail'] =  $mail[0]; 
     3213 
     3214                           } 
     3215 
     3216                          if(count($part) > 0) 
     3217                          { 
     3218                              if($part['cn'])  
     3219                                                                $return .= 'ATTENDEE;CN='.$part['cn'].';RSVP=TRUE:mailto:'.$part['mail']."\r\n"; 
     3220                              else  
     3221                                                                $return .= 'ATTENDEE;RSVP=TRUE:mailto:'.$part['mail']."\r\n";   
     3222                              
    30853223                                      } 
    30863224                                } 
    3087                                 $tmpattach.="END:VEVENT"."\n"; 
    3088                                 //."END:VEVENT\r\n"; 
    3089                         } 
    3090                     $tmpattach.="END:VCALENDAR\r\n"; 
    3091                     return $tmpattach; 
     3225 
     3226                    return $return; 
     3227                        } 
     3228 
     3229 
     3230                function getDb() 
     3231                { 
     3232                    include_once('../phpgwapi/inc/class.db.inc.php'); 
     3233                    // Conecta ao banco de dados 
     3234                    if (is_array($_SESSION['phpgw_info']['expresso']['server'])) 
     3235                        $GLOBALS['phpgw_info']['server'] = $_SESSION['phpgw_info']['expresso']['server']; 
     3236                    else 
     3237                        $_SESSION['phpgw_info']['expresso']['server'] = $GLOBALS['phpgw_info']['server']; 
     3238 
     3239                    $db = new db(); 
     3240                    $db->Halt_On_Error = 'no'; 
     3241                    $db->connect( 
     3242                                $_SESSION['phpgw_info']['expresso']['server']['db_name'], 
     3243                                $_SESSION['phpgw_info']['expresso']['server']['db_host'], 
     3244                                $_SESSION['phpgw_info']['expresso']['server']['db_port'], 
     3245                                $_SESSION['phpgw_info']['expresso']['server']['db_user'], 
     3246                                $_SESSION['phpgw_info']['expresso']['server']['db_pass'], 
     3247                                $_SESSION['phpgw_info']['expresso']['server']['db_type'] 
     3248                                ); 
     3249                                // Fim Conecta Banco de dados 
     3250                    return $db; 
     3251                } 
     3252 
     3253                function getLdap() 
     3254                { 
     3255                    require_once($_SESSION['rootPath'].'/header.inc.php'); 
     3256                    require_once($_SESSION['rootPath'].'/phpgwapi/inc/class.common.inc.php'); 
     3257    
     3258                    $common = new common(); 
     3259                                 
     3260                    if ( (!empty($GLOBALS['phpgw_info']['server']['ldap_master_host'])) && 
     3261                        (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_dn'])) && 
     3262                        (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_pw'])) ) 
     3263                        { 
     3264                            $ldap = $common->ldapConnect($GLOBALS['phpgw_info']['server']['ldap_master_host'], 
     3265                                                         $GLOBALS['phpgw_info']['server']['ldap_master_root_dn'], 
     3266                                                         $GLOBALS['phpgw_info']['server']['ldap_master_root_pw']); 
     3267                        } 
     3268                        else 
     3269                        { 
     3270                            $ldap = $common->ldapConnect(); 
     3271                        } 
     3272                        
     3273                    return $ldap; 
     3274                } 
     3275 
     3276                function getvCalendarOrganizer($pOrganizer) 
     3277                { 
     3278 
     3279                     
     3280                       $organizer = array(); 
     3281        
     3282                       if(preg_match("(\"[^\"]*\"[ ]*<[^>]*@[^>]*>)", $pOrganizer)) 
     3283                       { 
     3284                          $cn = null; 
     3285                          $mail = null; 
     3286                          preg_match ("(\"([^\"]*)\")", $pOrganizer, $cn); 
     3287                          preg_match ('(<([^>]*@[^>]*)>)', $pOrganizer, $mail); 
     3288 
     3289                          if($mail[1]) 
     3290                          $organizer['mail'] =  $mail[1]; 
     3291 
     3292                          if($cn[1]) 
     3293                            $organizer['cn'] =  $cn[1]; 
     3294 
     3295                       } 
     3296                       else 
     3297                       if(preg_match("(<[^>]*@[^>]*>)", $pOrganizer)) 
     3298                       { 
     3299                          $mail = null; 
     3300                          preg_match ('(<([^>]*@[^>]*)>)', $pOrganizer, $mail); 
     3301                          if($mail[1]) 
     3302                            $organizer['mail'] =  $mail[1]; 
     3303 
     3304                       } 
     3305                       else 
     3306                       if(preg_match("([^ ]*@[^ ]*)", $pOrganizer)) 
     3307                       { 
     3308                          $mail = null; 
     3309                          preg_match ('([^ ]*@[^ ]*)', $pOrganizer, $mail); 
     3310                          if($mail[0]) 
     3311                            $organizer['mail'] =  $mail[0]; 
     3312 
     3313                       } 
     3314                        
     3315                       if($organizer['cn']) $return = 'ORGANIZER;CN="'.$organizer['cn'].'":MAILTO:'.$organizer['mail']."\r\n"; 
     3316                       else $return = 'ORGANIZER;MAILTO:'.$organizer['mail']."\r\n"; 
     3317                        
     3318                    return $return; 
    30923319                } 
    30933320 
     
    31013328                @param $new_event Event after the change 
    31023329                */ 
    3103                 function send_update($msg_type,$to_notify,$old_event,$new_event=False,$user=False) 
    3104                 {                        
    3105                         if (!is_array($to_notify)) 
    3106                         { 
    3107                                 $to_notify = array(); 
    3108                         } 
     3330                function send_update($msg_type,$to_notify,$old_event,$new_event = False, $user = False) 
     3331                        { 
     3332           
     3333                        if (!is_array($to_notify)) $to_notify = array(); 
    31093334                        $owner = $old_event ? $old_event['owner'] : $new_event['owner']; 
    3110                         if ($owner && !isset($to_notify[$owner]) && $msg_type != MSG_ALARM) 
    3111                         { 
    3112                                 $to_notify[$owner] = 'owner';   // always include the event-owner 
    3113                         } 
     3335 
     3336                        if($owner === -2) 
     3337                            $to_notify[-2] = 'A';  
     3338 
    31143339                        $version = $GLOBALS['phpgw_info']['apps']['calendar']['version']; 
    3115  
    31163340                        $GLOBALS['phpgw_info']['user']['preferences'] = $GLOBALS['phpgw']->preferences->create_email_preferences(); 
    3117  
    3118                     $preferences = CreateObject('phpgwapi.preferences',(int)$this->owner);  
    3119                     $GLOBALS['phpgw']->accounts->get_account_name((int)$owner,$lid,$fname,$lname);  
    31203341                  
    3121                         if($new_event['notifications_owner'] == '1'){  
    3122                         $sender = $preferences->email_address((int)$owner);  
    3123                         $sender_name = $fname.' '.$lname;  
    3124                     }else{  
    3125                         $sender = $GLOBALS['phpgw_info']['user']['email'];  
    3126                         $sender_name = $GLOBALS['phpgw_info']['user']['fullname'];  
     3342                        /* 
     3343                         * Caso o evento seja de uma conta compartilha busca obusca o cn e o email da conta 
     3344                         */  
     3345                        if($user) 
     3346                        { 
     3347                            $ldap = $this->getLdap();   
     3348                            $justthese = array("mail","cn"); 
     3349                            $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=l)(phpgwAccountType=s)(phpgwAccountType=i))(uidNumber=".$user."))"; 
     3350                            $search = ldap_search($ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); 
     3351                            $entry = ldap_get_entries($ldap, $search); 
     3352                            $sMail = $entry[0]['mail'][0]; 
     3353                            $sCN = $entry[0]['cn'][0]; 
     3354                            $sUN = $user; 
    31273355                        }  
     3356                        else 
     3357                        { 
     3358                            $sMail = $GLOBALS['phpgw_info']['user']['email']; 
     3359                            $sCN = $GLOBALS['phpgw_info']['user']['fullname']; 
     3360                            $sUN = $GLOBALS['phpgw_info']['user']['account_id']; 
     3361                        } 
     3362                        //------------------------------------------------------------------------------------// 
    31283363                  
    31293364                    $temp_tz_offset = $this->prefs['common']['tz_offset']; 
    3130                          
    31313365                        $temp_timeformat = $this->prefs['common']['timeformat']; 
    31323366                        $temp_dateformat = $this->prefs['common']['dateformat']; 
    3133  
    31343367                        $tz_offset = ((60 * 60) * (int)$temp_tz_offset); 
    31353368 
     
    31383371                                $t_old_start_time = $this->maketime($old_event['start']); 
    31393372                                if($t_old_start_time < (time() - 86400)) 
    3140                                 { 
    31413373                                        return False; 
    31423374                                } 
    3143                         } 
    31443375 
    31453376                        $temp_user = $GLOBALS['phpgw_info']['user']; 
    3146  
    3147                         if (!$user) 
    3148                         { 
    3149                                 $user = $this->owner; 
    3150                         } 
     3377                        if (!$user) $user = $this->owner; 
    31513378                        $GLOBALS['phpgw_info']['user']['preferences'] = $GLOBALS['phpgw']->preferences->create_email_preferences($user); 
     3379                        $this->prefs = $GLOBALS['phpgw_info']['user']['preferences']; 
    31523380 
    31533381                        $event = $msg_type == MSG_ADDED || $msg_type == MSG_MODIFIED ? $new_event : $old_event; 
     
    32163444                        $notify_msg = $this->prefs['calendar']['notify'.$msg]; 
    32173445                        if (empty($notify_msg)) 
    3218                         { 
    32193446                                $notify_msg = $this->prefs['calendar']['notifyAdded'];  // use a default 
    3220                         } 
     3447                         
    32213448                        $details = array(                       // event-details for the notify-msg 
    32223449                                'id'          => $msg_type == MSG_ADDED ? $new_event['id'] : $old_event['id'], 
     
    32523479                        $mail->Host = $emailadmin['smtpServer']; 
    32533480                        $mail->Port = $emailadmin['smtpPort']; 
    3254                         $mail->From = $GLOBALS['phpgw']->preferences->values['email']; 
    3255                         $mail->FromName = $GLOBALS['phpgw_info']['user']['fullname']; 
    3256                         //$mail->IsHTML(true); 
    3257                         $mail->IsCalendar(true); 
    3258  
     3481                        $mail->From = $sMail; 
     3482                        $mail->FromName = $sCN; 
     3483                        $mail->IsHTML(true); 
     3484                        //Inicializa vari?vel de retorno. 
     3485                        $returncode=true;                
    32593486                        // Aqui e enviado o email 
    32603487                        foreach($to_notify as $userid => $statusid)  
     
    32643491                                $userid = (int)$userid; 
    32653492 
    3266                                 if ($statusid == 'R' || $GLOBALS['phpgw']->accounts->get_type($userid) == 'g') 
    3267                                 { 
    3268                                         continue;       // dont notify rejected participants 
    3269                                 } 
    3270                                 if($userid != $GLOBALS['phpgw_info']['user']['account_id'] || ($msg_type == MSG_ADDED && $userid != $owner) || $msg_type == MSG_ALARM || isset($new_event['attachment'])) 
    3271                                 //if($userid != $owner ||  $msg_type == MSG_ALARM || isset($new_event['attachment'])) 
     3493                                if ($statusid == 'R' || $GLOBALS['phpgw']->accounts->get_type($userid) == 'g' || ($sUN == $userid &&  $msg_type != MSG_ALARM)) 
     3494                                    continue;   // dont notify rejected participants or to == send 
     3495                                 
     3496                                if($userid != $sUN  ||  $msg_type == MSG_ALARM) 
    32723497                                { 
    32733498                                        print_debug('Msg Type',$msg_type); 
     3499                                         
    32743500                                        print_debug('UserID',$userid); 
    32753501 
     
    32853511 
    32863512                                        $to = $preferences->email_address($userid); 
     3513                                         
     3514                                         
     3515                                        if( $userid === -2 ) 
     3516                                        { 
     3517                                                $to = htmlspecialchars_decode( $event['organizer'] ); 
     3518                                        } 
    32873519                                         
    32883520                                        if (empty($to) || $to[0] == '@' || $to[0] == '$')       // we have no valid email-address 
     
    34033635                                                                                        if( trim($tmpmail) == trim($to) & trim($tmpuid) == trim($NewKey)) 
    34043636                                                                                        { 
    3405                                                                                                         if( ( $typesend == 3 ) || ( $typesend == 2 ) ) 
     3637                                                                                                        if($typesend == 3) 
    34063638                                                                                                        { 
    3407                                                                                                                 $question = ""; 
    3408                                                                                                                  
    3409                                                                                                                 if( $typesend == 2 ) 
    3410                                                                                                                         $question = lang("Do you wish to change your participation in this event?"); 
    34113639 
    34123640                                                                                                                $lang1 = lang("To See Commitment"); 
     
    34153643                                                                                                                                                                   </form>"; 
    34163644                                                                                                                $lang2 = lang("To accept"); 
    3417                                                                                                                 $varbuttom1 ="<input type='submit' value='$lang2' onClick='javascript:window.open(\"".$GLOBALS['phpgw_info']['server']['webserver_url']."/index.php?menuaction=calendar.uicalendar.set_action&cal_id=$event[id]&action=3&response=1&user_id=$userid\",\"frontpage\",\"height=200,width=450,statusbar=no,toolbar=no,scrollbars=no,menubar=no,left=300,top=200\")'>"; 
     3645                                                                                                                $varbuttom1 ="<input type='submit' value='$lang2' onClick='javascript:window.open(\"".$GLOBALS['phpgw_info']['server']['webserver_url']."/index.php?menuaction=calendar.uicalendar.set_action&cal_id=$event[id]&action=3&response=1&user=".$tmpuid."\",\"frontpage\",\"height=100,width=500,statusbar=no,toolbar=no,scrollbars=no,menubar=no,left=300,top=200\")'>"; 
     3646                                                                                                                 
     3647                                                                                                                $lang6 = lang("Tentative"); 
     3648                                                                                                                $varbuttom5 ="<input type='submit' value='$lang6' onClick='javascript:window.open(\"".$GLOBALS['phpgw_info']['server']['webserver_url']."/index.php?menuaction=calendar.uicalendar.set_action&cal_id=$event[id]&action=2&response=3&user=".$tmpuid."\",\"frontpage\",\"height=100,width=500,statusbar=no,toolbar=no,scrollbars=no,menubar=no,left=300,top=200\")'>"; 
     3649                                                                                                                 
    34183650 
    34193651                                                                                                                $lang3 = lang("To reject"); 
    3420                                                                                                                 $varbuttom2 ="<input type='submit' value='$lang3' onClick='javascript:window.open(\"".$GLOBALS['phpgw_info']['server']['webserver_url']."/index.php?menuaction=calendar.uicalendar.set_action&cal_id=$event[id]&action=0&response=0\",\"frontpage\",\"height=100,width=400,statusbar=no,toolbar=no,scrollbars=no,menubar=no,left=300,top=200\")'>"; 
     3652                                                                                                                $varbuttom2 ="<input type='submit' value='$lang3' onClick='javascript:window.open(\"".$GLOBALS['phpgw_info']['server']['webserver_url']."/index.php?menuaction=calendar.uicalendar.set_action&cal_id=$event[id]&action=0&response=2&user=".$tmpuid."\",\"frontpage\",\"height=100,width=500,statusbar=no,toolbar=no,scrollbars=no,menubar=no,left=300,top=200\")'>"; 
    34213653                                                                                                                 
    34223654                                                                                                                $lang4 = lang("Alarm"); 
     
    34263658                                                                                                                                                                   </form>"; 
    34273659                                                                                                                                                                    
    3428                                                                                                                 $lang5 = lang("Delegate"); 
    3429                                                                                                                 $varbuttom4 = "<form action='".$GLOBALS['phpgw_info']['server']['webserver_url']."/index.php?menuaction=calendar.uicalendar.screen_delegate_event&id_event=$event[id]&date=$newall3&delegator=$tmpuid' method='POST'> 
     3660                                                                                                                $lang5 = lang("Suggest new hour");  
     3661                                                                                                                $varbuttom4 = "<form action=".$GLOBALS['phpgw_info']['server']['webserver_url']."/index.php?menuaction=calendar.uicalendar.view&cal_id=$event[id]&date=$newall3&type=1' method='POST'> 
    34303662                                                                                                                                                                  <input type='submit' value='$lang5'> 
    34313663                                                                                                                                                                   </form>"; 
    3432                                                                                                                  
    3433                                                                                                                 $lang6 = lang("Tentative"); 
    3434                                                                                                                 $varbuttom5 ="<input type='submit' value='$lang6' onClick='javascript:window.open(\"".$GLOBALS['phpgw_info']['server']['webserver_url']."/index.php?menuaction=calendar.uicalendar.set_action&cal_id=$event[id]&action=2&response=1&user_id=$userid\",\"frontpage\",\"height=200,width=450,statusbar=no,toolbar=no,scrollbars=no,menubar=no,left=300,top=200\")'>";                                                                                                              
    34353664                                                                                                        } 
    34363665                                                                                                        else 
     
    34663695                                                         
    34673696                                                        // A constante PHPGW_APP_TPL nao existe para envio de alarmes (cront, asyncservice). 
    3468                                                         define ("PHPGW_APP_TPL",PHPGW_API_INC . "/../../calendar/templates/".$GLOBALS['phpgw_info']['user']['preferences']['common']['template_dir'].""); 
     3697                                                        if(!PHPGW_APP_TPL) 
     3698                                                         define ("PHPGW_APP_TPL",PHPGW_INCLUDE_ROOT . "/calendar/templates/".$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].""); 
    34693699                                                         
    3470                                                         $body = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); 
     3700                                                                $body = CreateObject('phpgwapi.Template',PHPGW_INCLUDE_ROOT . "/calendar/templates/".$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].""); 
    34713701                                                        $body->set_file(Array('calendar' => 'body_email.tpl')); 
    34723702                                                        $body->set_block('calendar','list'); 
     
    34863716                                                                'var8'                          => $var8, 
    34873717                                                                'vardata8'                      => $vardata8, 
    3488                                                                 'question'                      => $question,                                                                                                                    
    34893718                                                                'varbuttom'                     => $varbuttom, 
    34903719                                                                'varbuttom1'            => $varbuttom1, 
     
    35163745                                                        break; 
    35173746                                        } 
     3747                                        
    35183748                                        $mail->AddAddress($to); 
    3519                                         //$mail->Body = $tmpbody; 
    3520                                         $tmpattach_n = $this->create_vcard($GLOBALS['bocalendar']->so->cal->event); 
    3521                                         $tmpattach = str_replace("Expresso-","",$tmpattach_n); 
    3522                                         $mail->Body = "This is a multi-part message in MIME format."; 
    3523                                         $mail->Body .= "\n--01BD3665.3AF0D360\n"; 
    3524                                         $mail->Body .= "Content-Type: text/html; charset=\"iso-8859-1\"\nContent-Transfer-Encoding: 8bit\n"; 
    3525                                         $mail->Body .= $tmpbody; 
    3526                                         $mail->Body .= "\n--01BD3665.3AF0D360\n"; 
    3527                                         $mail->Body .="Content-Type:text/calendar; method=REQUEST; charset=US-ASCII\nContent-Transfer-Encoding:7bit\n\n"; 
    3528                                         $mail->Body .= $tmpattach; 
    3529                                         $mail->Body .= "\n--01BD3665.3AF0D360--\n"; 
    3530                                         $mail->From = $sender; 
    3531                                         $mail->FromName = $sender_name; 
     3749                                        $mail->Body = $tmpbody;       
     3750                                        $mail->From = $sMail; 
     3751                                        $mail->FromName = $sCN; 
    35323752                                        $mail->Sender = $mail->From; 
    35333753                                        $mail->SenderName = $mail->FromName; 
     
    35353755                                        unset($vardata5); 
    35363756                                        unset($vardata6); 
    3537                                 } 
    3538                         } 
    3539  
    3540                         //Inicializa variï¿œvel de retorno. 
    3541                         $returncode=true;                        
    3542                         if(count($mail->to)) { 
    3543  
    3544                             if(isset($new_event['attachment'])){ 
    3545                                 foreach($new_event['attachment'] as $attach){ 
    3546                                     $mail->AddAttachment($attach['tmp_name'], $attach['name'], "base64", $attach['type']); 
     3757                                         
     3758                                        // Envia aviso ao participante. 
     3759                                        if(!$mail->Send()) {                             
     3760                                                $returncode = false; 
     3761                                                $errorInfo['participants'] = $mail->ErrorInfo; 
     3762                        } 
     3763 
     3764                                        $mail->ClearAddresses();     
     3765 
    35473766                                } 
    35483767                            } 
    3549                                 // Envia aviso a todos os participantes. 
    3550                                 if(!$mail->Send()) {                             
    3551                                         $returncode = false; 
    3552                                         $errorInfo['participants'] = $mail->ErrorInfo; 
     3768 
     3769                        if(!is_object($this->ex_participants)) 
     3770                        { 
     3771                            include_once($_SESSION['rootPath'].'/calendar/inc/class.ex_participants.inc.php'); 
     3772                            $objexP = new exParticipants(); 
     3773                            $objexP->setParticipantsBySerializable($this->ex_participants); 
    35533774                                } 
    35543775                                else 
    3555                                         $returncode =  true; 
    3556                         } 
     3776                            $objexP = $this->ex_participants; 
     3777 
    35573778                         
    3558                         if(count($to_notify) && $this->ex_participants){ 
     3779                        if($msg_type === MSG_ADDED && count($this->extAdded) > 0) 
     3780                               $extMails = $this->extAdded;   
     3781                        else if($msg_type === MSG_DELETED && count($this->extDeleted) > 0) 
     3782                                $extMails = $this->extDeleted;   
     3783                        else  
     3784                            $extMails = array_diff($objexP->getParticipantsMailsArray(), $this->alreadyExtNotifieds); 
     3785                                
     3786                        if(count($extMails) > 0){ 
    35593787                                $mail->ClearAllRecipients(); 
    3560                                 $var = explode(",",trim($this->ex_participants)); 
    3561                                 $mail->IsHTML(true); 
     3788                               
    35623789                                $to = array(); 
    35633790                                if(!$subject) { 
     
    35673794                                } 
    35683795                                 
    3569                                 foreach($var as $index => $ex_participant){ 
     3796                                foreach($extMails as $index => $ex_participant){ 
    35703797                                        $ex_participant = trim($ex_participant); 
    35713798                                        $ex_participant = preg_replace('#"(.*)" <(.*)\@(.*)\.(.*)>#','\\2@\\3.\\4',$ex_participant); 
     
    35793806                                $_body = explode("<hr size='1' width='100%'>",$tmpbody); 
    35803807                                $tmpbody = $_body[0] ? $_body[0] : $subject ; 
    3581                                 $tmpbody.= "<br><b>".lang("external participants").":: </b> ".htmlentities($this->ex_participants); 
    3582                                 $tmpbody.= "<br>".lang("Summary").": ".$this->so->cal->event[title]."<br>"; 
     3808                                $tmpbody.= "<br><b>".lang("external participants").":: </b> ".htmlentities($objexP->getParticipantsMailsString()); 
     3809                                $tmpbody.= "<br>".lang("Summary").": ".$this->so->cal->event[description]."<br>"; 
    35833810                                $tmpbody.= "<br>".lang("Start time").": ".$GLOBALS['phpgw']->common->show_date($starttime)."<br>".lang("End date").": ".$GLOBALS['phpgw']->common->show_date($endtime)."<br>"; 
    35843811                                $tmpbody.= "<br><br><hr size='1' width='100%'><font color='red'>" 
     
    35923819                                //attach extern vcalendar/icalendar (ics)                        
    35933820                                // define('context','$GLOBALS.bocalendar.so.cal.event'); 
    3594                                 $tmpattach = $this->create_vcard($GLOBALS['bocalendar']->so->cal->event); 
     3821                                 
     3822                                $evt = $GLOBALS['bocalendar']->so->cal->event; 
     3823                                                                  
     3824                                /* 
     3825                                 * Cria Arqvuio ICS 
     3826                                 */ 
     3827                                require_once $_SESSION['rootPath'].'/API/class.servicelocator.php'; 
     3828                                $icalService = ServiceLocator::getService('ical'); 
     3829 
     3830                                if($msg_type == MSG_DELETED) 
     3831                                { 
     3832                                        $icalService->createICal(strtoupper($method)); 
     3833                                        $icalService->addEvent( 
     3834                                            $old_event['start']['year'].'-'.$old_event['start']['month'].'-'.$old_event['start']['mday'].' '.$old_event['start']['hour'].':'.$old_event['start']['min'].':00', 
     3835                                            $old_event['end']['year'].'-'.$old_event['end']['month'].'-'.$old_event['end']['mday'].' '.$old_event['end']['hour'].':'.$old_event['end']['min'].':00', 
     3836                                            array($sMail => array('CN'=> $sCN)), 
     3837                                            $old_event['title'], 
     3838                                            $old_event['description'], 
     3839                                            $old_event['location'], 
     3840                                            false, 
     3841                                            false, 
     3842                                            false, 
     3843                                            $old_event['uid'] 
     3844                                            ); 
     3845                                } 
     3846                                else 
     3847                                { 
     3848                                        $attendee = array(); 
     3849                                        foreach($to as $value) 
     3850                                            $attendee[$value] = array('RSVP' => 'TRUE','ROLE' => 'REQ-PARTICIPANT'); 
     3851 
     3852                                        $attendee =  array_merge($attendee,$this->getCalendarParticipantsArray($evt['id'])); 
     3853                                        $icalService->createICal(strtoupper($method)); 
     3854                                        $icalService->addEvent( 
     3855                                            $evt['start']['year'].'-'.$evt['start']['month'].'-'.$evt['start']['mday'].' '.$evt['start']['hour'].':'.$evt['start']['min'].':00', 
     3856                                            $evt['end']['year'].'-'.$evt['end']['month'].'-'.$evt['end']['mday'].' '.$evt['end']['hour'].':'.$evt['end']['min'].':00', 
     3857                                            array($sMail => array('CN'=> $sCN)), 
     3858                                            $evt['title'], 
     3859                                            $evt['description'], 
     3860                                            $evt['location'], 
     3861                                            $attendee, 
     3862                                            false, 
     3863                                            false, 
     3864                                            $evt['uid'] 
     3865                                            ); 
     3866 
     3867                                } 
     3868 
     3869 
     3870                                $tmpattach = $icalService->getICal(); 
     3871                                //-------------------------------------------------// 
     3872                                 
    35953873                                if($tmpattach){                                  
    3596                                         $tmpbody .="<a href='../index.php?menuaction=calendar.uicalendar.add&date=" 
    3597                                         .$GLOBALS['bocalendar']->so->cal->event[start][year] 
    3598                                 .$event_month 
    3599                                 .$GLOBALS['bocalendar']->so->cal->event[start][mday] 
    3600                                         ."&hour=".$GLOBALS['bocalendar']->so->cal->event[start][hour] 
    3601                                         ."&minute=".$GLOBALS['bocalendar']->so->cal->event[start][min] 
    3602                                         ."&title=".$GLOBALS['bocalendar']->so->cal->event['title'] 
    3603                                         ."&description=".$GLOBALS['bocalendar']->so->cal->event['description'] 
    3604                                         ."&location=".$GLOBALS['bocalendar']->so->cal->event['location']."'>" 
    3605                                         ."<h2>".lang("Add to my expresso")."</h2>"; 
    36063874                                        $tempdir = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; 
    36073875                                        srand((double)microtime()*1000000); 
     
    36143882                                        fclose($attach_fd); 
    36153883                                } 
    3616  
    3617                                 if(isset($new_event['attachment'])){ 
    3618                                     foreach($new_event['attachment'] as $attach){ 
    3619                                         $mail->AddAttachment($attach['tmp_name'], $attach['name'], "base64", $attach['type']); 
    3620                                     } 
    3621                                 } 
    3622                                  
    3623                                 $mail->From = $sender; 
    3624                                 $mail->FromName = $sender_name; 
     3884                                $mail->From = $sMail; 
     3885                                $mail->FromName = $sCN; 
    36253886                                $mail->Sender = $mail->From; 
    36263887                                $mail->SenderName = $mail->FromName; 
     
    36513912                        $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'] = $temp_dateformat; 
    36523913                         
    3653                         // Notifica por email o criador do compromisso, com as possï¿œveis falhas.                                               
     3914                        // Notifica por email o criador do compromisso, com as poss?veis falhas.                                                 
    36543915                        if($errorInfo) { 
    36553916                                $tmpbody = "<font color='red'>".lang("The following commitment had problems for DELIVERING the NOTIFICATION messages.").".</font><br>"; 
     
    36783939                                $mail->Host = $emailadmin['smtpServer']; 
    36793940                                $mail->Port = $emailadmin['smtpPort']; 
    3680                                 $mail->From = $sender; 
    3681                                 $mail->FromName = $sender_name; 
     3941                                $mail->From = $sMail; 
     3942                                $mail->FromName = $sCN; 
    36823943                                $mail->Sender = $mail->From; 
    36833944                                $mail->SenderName = $mail->FromName; 
     
    36853946                                $mail->Subject = lang("calendar event")." - ".lang("email notification");                                                        
    36863947                                $mail->Body = $tmpbody;                                  
    3687                                 $mail->AddAddress($sender); 
     3948                                $mail->AddAddress($sMail); 
    36883949                                if(!$mail->Send())                       
    36893950                                        $returncode = false; 
     
    36933954                        return $returncode; 
    36943955                } 
     3956                 
     3957                 
     3958                 
     3959                /** 
     3960                 * @license http://www.gnu.org/copyleft/gpl.html GPL 
     3961                 * @author Prognus Software Livre (http://www.prognus.com.br) 
     3962                 */ 
     3963                function send_suggestion_external_owner($cal_id, $uid, $to, $time_suggest, $array_data_inicio, $array_data_final, $title, $description, $location, $ex_participants,$user = false) 
     3964                { 
     3965 
     3966                    if($cal_id) 
     3967                        $event =  $this->so->read_entry($cal_id); 
     3968                    else 
     3969                    { 
     3970                        $event = $this->restore_from_appsession(); 
     3971                        $this->so->add_entry( $event , false); 
     3972                    } 
     3973                     
     3974                    $this->so->cal->set_status($event['id'],$user,2); 
     3975 
     3976 
     3977                    if($user && $user != $GLOBALS['phpgw_info']['user']['account_id']) 
     3978                    { 
     3979                        $ldap = $this->getLdap(); 
     3980                        $justthese = array("mail","cn"); 
     3981                        $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=l)(phpgwAccountType=s)(phpgwAccountType=i))(uidNumber=".$user."))"; 
     3982                        $search = ldap_search($ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); 
     3983                        $entry = ldap_get_entries($ldap, $search); 
     3984                        $ownerMail = $entry[0]['mail'][0]; 
     3985                        $ownerCN = $entry[0]['cn'][0]; 
     3986                     } 
     3987                     else 
     3988                     { 
     3989                        $ownerMail = $GLOBALS['phpgw_info']['user']['email']; 
     3990                        $ownerCN = $GLOBALS['phpgw_info']['user']['fullname']; 
     3991                     } 
     3992                      
     3993                    require_once $_SESSION['rootPath'] . '/API/class.servicelocator.php'; 
     3994                    $icalService = ServiceLocator::getService('ical'); 
     3995                    $dia_inicio = $array_data_inicio[0]; 
     3996                    $mes_inicio = $array_data_inicio[1]; 
     3997                    $ano_inicio = $array_data_inicio[2]; 
     3998                    $hora_inicio = $time_suggest['hora_inicio']; 
     3999                    $minuto_inicio = $time_suggest['minuto_inicio']; 
     4000                    $dia_final = $array_data_final[0]; 
     4001                    $mes_final = $array_data_final[1]; 
     4002                    $ano_final = $array_data_final[2]; 
     4003                    $hora_final = $time_suggest['hora_final']; 
     4004                    $minuto_final = $time_suggest['minuto_final']; 
     4005 
     4006                    $dtStart = $array_data_inicio[2] . '/' . 
     4007                               $array_data_inicio[1] . '/' . 
     4008                               $array_data_inicio[0] . ' ' . 
     4009                               $time_suggest['hora_inicio'] . ':' . 
     4010                               $time_suggest['minuto_inicio'] . ':00'; 
     4011 
     4012                    $dtEnd = $array_data_final[2] . '/' . 
     4013                             $array_data_final[1] . '/' . 
     4014                             $array_data_final[0] . ' ' . 
     4015                             $time_suggest['hora_final'] . ':' . 
     4016                             $time_suggest['minuto_final'] . ':00'; 
     4017 
     4018                    $icalService->createICal('REPLY'); 
     4019 
     4020                    $other = array( 'X-MICROSOFT-CDO-IMPORTANCE' => '1', 
     4021                                    'X-EXPRESSO-SUGGESTION-HOUR' => '1', 
     4022                                    'CLASS' => 'PUBLIC', 
     4023                                    'PRIORITY' => '5', 
     4024                                    'SEQIENCE' => '0', 
     4025                                    'TRANSP' => 'OPAQUE'); 
     4026 
     4027                    /* Corpo do email */ 
     4028                    $tmpbody2 = lang("The sender suggested a new hours for the appointment"); 
     4029                    $tmpbody2.= " <br /> <b>" . lang("Title") . ":</b> $title"; 
     4030                    $tmpbody2.= " <br /> <b>" . lang("Details") . ":</b> <br /> <br /> <b>" . lang("Start") . "  </b>" . $dia_inicio . "/" . $mes_inicio . "/" . $ano_inicio . " - " . $hora_inicio . ":" . $minuto_inicio; 
     4031                    $tmpbody2.= " <br /> <b>" . lang("End") . " </b>" . $dia_final . "/" . $mes_final . "/" . $ano_final . " - " . $hora_final . ":" . $minuto_final . "<br><br><br><br>"; 
     4032                    $tmpbody = lang("The sender suggested a new hours for the appointment"); 
     4033                    $tmpbody.= " \r\n " . lang("Title") . ": $title"; 
     4034                    $tmpbody.= " \r\n " . lang("Suggestion") . ": \r\n \r\n " . lang("Start") . "  " . $dia_inicio . "/" . $mes_inicio . "/" . $ano_inicio . " - " . $hora_inicio . ":" . $minuto_inicio; 
     4035                    $tmpbody.= " \r\n " . lang("End") . " " . $dia_final . "/" . $mes_final . "/" . $ano_final . " - " . $hora_final . ":" . $minuto_final . ""; 
     4036 
     4037                    $icalService->addEvent($dtStart, 
     4038                            $dtEnd, 
     4039                            $to, 
     4040                            $title, 
     4041                            utf8_encode($tmpbody), 
     4042                            $location, 
     4043                            array($ownerMail => array('CN' => $ownerCN, 'PARTSTAT' => 'TENTATIVE')), 
     4044                            $other, 
     4045                            false, 
     4046                            $uid 
     4047                    ); 
     4048                    
     4049                    $tmpattach =  $icalService->getICal();                    
     4050                     
     4051                    $mailService = ServiceLocator::getService('mail'); 
     4052                    $mailService->addStringAttachment($tmpattach, 'suggestion.ics', 'application/ics'); 
     4053                    $mailService->addStringAttachment($tmpattach, 'vcalendar.ics', 'text/calendar; charset=utf-8; method=REPLY;', '7bit', 'inline'); 
     4054                    $mailService->sendMail($to, $ownerMail, $title, $tmpbody2); 
     4055                      
     4056                    return $event['id'];                     
     4057                }                
    36954058                 
    36964059                function send_alarm($alarm) 
     
    37644127                } 
    37654128 
    3766                 function prepare_recipients(&$new_event,$old_event) 
    3767                 { 
    3768                                                  
    3769                         // Find modified and deleted users..... 
    3770                         while(list($old_userid,$old_status) = each($old_event['participants'])) 
    3771                         { 
    3772                                 if(isset($new_event['participants'][$old_userid])) 
    3773                                 { 
    3774                                         print_debug('Modifying event for user',$old_userid); 
    3775                                         $this->modified[(int)$old_userid] = $new_status; 
    3776                                 } 
    3777                                 else 
    3778                                 { 
    3779                                         print_debug('Deleting user from the event',$old_userid); 
    3780                                         $this->deleted[(int)$old_userid] = $old_status; 
    3781                                 } 
    3782                         } 
    3783                         // Find new users..... 
    3784                         while(list($new_userid,$new_status) = each($new_event['participants'])) 
    3785                         { 
    3786                                 if(!isset($old_event['participants'][$new_userid])) 
    3787                                 { 
    3788                                         print_debug('Adding event for user',$new_userid); 
    3789                                         $this->added[$new_userid] = 'U'; 
    3790                                         $new_event['participants'][$new_userid] = 'U'; 
    3791                                 } 
     4129                function prepare_recipients(&$new_event,$old_event,$userSend) 
     4130                { 
     4131                        //Verifica se ouve alguem deletado 
     4132                        foreach($old_event['participants'] as $key => $value) 
     4133                           if(!array_key_exists($key, $new_event['participants'])) 
     4134                                { 
     4135                               $this->deleted[$key] = $value; 
     4136                               $this->alreadyNotifieds[] = $key; //Adiciona a variavel de ja notificados para não serem notificados 2 vezes; 
     4137                                } 
     4138                        //Verifica se ouve alguem adicionado 
     4139                        foreach($new_event['participants'] as $key => $value) 
     4140                           if(!array_key_exists($key, $old_event['participants'])) 
     4141                                { 
     4142                               $this->added[$key] = $value; 
     4143                               $this->alreadyNotifieds[] = $key; //Adiciona a variavel de ja notificados para não serem notificados 2 vezes; 
    37924144                        } 
    37934145                         
    3794                         if(count($this->added) > 0 || count($this->modified) > 0 || count($this->deleted) > 0) 
    3795                         { 
    3796                                 if(count($this->added) > 0) 
    3797                                 { 
    3798                                         $this->ex_participants = ''; 
    3799                                         $this->send_update(MSG_ADDED,$this->added,'',$new_event); 
    3800                                 } 
    3801                                 if(count($this->modified) > 0) 
    3802                                 { 
    3803                                         $this->send_update(MSG_MODIFIED,$this->modified,$old_event,$new_event); 
    3804                                 } 
    3805                                 if(count($this->deleted) > 0) 
    3806                                 { 
    3807                                         $this->ex_participants = ''; 
    3808                                         $this->send_update(MSG_DELETED,$this->deleted,$old_event); 
    3809                                 } 
    3810                         } 
     4146                        //Verifica se ouve alguem modificado 
     4147                        foreach($new_event['participants'] as $key => $value) 
     4148                        { 
     4149                            if(array_key_exists($key, $old_event['participants']))                        
     4150                                { 
     4151                                if($old_event['participants'][$key] != $value) 
     4152                                { 
     4153                                    $this->modified[$key] = $value;   
     4154                                    $this->alreadyNotifieds[] = $key; //Adiciona a variavel de ja notificados para não serem notificados 2 vezes; 
     4155                                } 
     4156                                } 
     4157                        } 
     4158                         //Verificando alterações em usuarios externos 
     4159                         include_once($_SESSION['rootPath'].'/calendar/inc/class.ex_participants.inc.php'); 
     4160                         $extOld = new exParticipants(); 
     4161                         $extNew = new exParticipants(); 
     4162                          
     4163                         $extOld->setParticipantsBySerializable($old_event['ex_participants']); 
     4164                         $extNew->setParticipantsBySerializable($new_event['ex_participants']); 
     4165                         
     4166                         $oldArray = $extOld->getParticipantsMailsArray(); 
     4167                         $newArray = $extNew->getParticipantsMailsArray(); 
     4168                          
     4169                        //Verifica se ouve alguem deletado 
     4170                        $this->extDeleted = array_diff($oldArray, $newArray); 
     4171                         
     4172                        //Verifica se ouve alguem adicionado 
     4173                        $this->extAdded = array_diff($newArray, $oldArray); 
     4174                         
     4175                        $this->alreadyExtNotifieds = array_merge($this->alreadyExtNotifieds, $this->extDeleted); 
     4176                        $this->alreadyExtNotifieds = array_merge($this->alreadyExtNotifieds, $this->extAdded); 
     4177                        //---------------------------------------------------------------------------------// 
     4178                         
     4179                        if(count($this->added) > 0 || count($this->extAdded)) 
     4180                                $this->send_update(MSG_ADDED,$this->added,'',$new_event,$userSend); 
     4181                         
     4182                        if(count($this->modified) > 0) 
     4183                                $this->send_update(MSG_MODIFIED,$this->modified,$old_event,$new_event,$userSend); 
     4184                         
     4185                        if(count($this->deleted) > 0 || count($this->extDeleted)) 
     4186                                $this->send_update(MSG_DELETED,$this->deleted,$old_event,false,$userSend); 
     4187                                                 
    38114188                } 
    38124189 
     
    40214398                        ); 
    40224399 
     4400                        $owner = $event['owner']; 
     4401 
     4402                        $owner_name = ( $owner === -2 )? $event['organizer'] : $GLOBALS['phpgw']->common->grab_owner_name( $owner ); 
     4403 
    40234404                        $var['owner'] = Array( 
    40244405                                'field' => lang('Created By'), 
    4025                                 'data'  => $GLOBALS['phpgw']->common->grab_owner_name($event['owner']) 
     4406                                'data'  => $owner_name 
    40264407                        ); 
    40274408 
     
    40314412                        ); 
    40324413 
    4033                         $var['observations'] = Array( 
    4034                                 'field' => $this->translate('Observations'), 
    4035                                 'data'  => $event['observations'] 
    4036                         ); 
    4037                          
    4038                         $var['attachment'] = Array( 
    4039                                 'field' => $this->translate('Attachment'), 
    4040                                 'data'  => $event['attachment'] 
    4041                         ); 
    4042  
    4043                         $var['alter_by'] = Array( 
    4044                                 'field' => $this->translate('Alter by'), 
    4045                                 'data'  => $event['alter_by'] 
    4046                         ); 
     4414                        if($event['public']){ 
     4415                                $type = lang('Public'); 
     4416                        }else if (!$event['public'] && $event['type'] == 'E'){ 
     4417                                $type = lang('Restrict'); 
     4418                        }else{ 
     4419                                $type = lang('Private'); 
     4420                        } 
    40474421 
    40484422                        $var['access'] = Array( 
    40494423                                'field' => lang('Access'), 
    4050                                 'data'  => $event['public'] ? lang('Public') : lang('Private') 
     4424                                'data'  => $type 
    40514425                        ); 
    40524426 
  • trunk/calendar/inc/class.bocustom_fields.inc.php

    r4316 r5132  
    3131                        'updated'     => 'Updated', 
    3232                        'alarm'       => 'Alarm', 
    33                         'recure_type' => 'Repetition', 
    34                         'observations' => 'Observations', 
    35                         'alter_by'   =>  'Alter by', 
    36             'attachment' => 'attachment', 
    37                         'notifications_owner' => 'notifications_owner' 
     33                        'recure_type' => 'Repetition' 
    3834                ); 
    3935 
  • trunk/calendar/inc/class.bogroup_access.inc.php

    r580 r5132  
    2222        } 
    2323 
    24         public final function search_user($params){                      
    25                 $objLdap = new ldap_functions(); 
    26                 $objLdap -> ldapRootConnect(); 
    27                 $ldap = $objLdap -> ds;          
    28                 $search = $params['search']; 
    29                 $accounttype = $params['type']; 
    30                 $justthese = array("cn","uid", "uidNumber","gidNumber"); 
    31         $users_list=ldap_search($ldap, $_SESSION['phpgw_info']['expressomail']['server']['ldap_context'], "(&(phpgwAccountType=$accounttype) (|(cn=*$search*)(mail=$search*)) )", $justthese);           
    32         if (ldap_count_entries($ldap, $users_list) == 0) 
     24        public final function search_user($params) 
    3325        { 
    34                 $return['status'] = 'false'; 
    35                 $return['msg'] = 'Nenhum resultado encontrado.'; 
    36                 return $return; 
    37         }        
    38         ldap_sort($ldap, $users_list, "cn");             
    39         $entries = ldap_get_entries($ldap, $users_list);                 
     26            $server = $_SESSION['phpgw_info']['expressomail']['server']; 
     27 
     28            $t = $params['type']; 
     29 
     30            $ldapService = ServiceLocator::getService('ldap'); 
     31 
     32            $ldapService->connect( $server['ldap_host'], $server['ldap_root_dn'], $server['ldap_root_pw'] ); 
     33 
     34            $entries = $ldapService->accountSearch($params['search'], array('cn', $t.'idNumber', $t.'id' ), $server['ldap_context'], $t, 'cn'); 
     35 
    4036                $options = ''; 
    41                 for ($i=0; $i<$entries['count']; $i++) 
     37 
     38            foreach( $entries as $value ) 
    4239                { 
    43                         $value = $entries[$i][$accounttype == "u" ? 'uidnumber' : 'gidnumber'][0];               
    44                         if($entries[$i]['mail'][0]) 
    45                                 $mail = "(".$entries[$i]['mail'][0].")"; 
    46                         $options .= "<option value=" . $value. ">" . $entries[$i]['cn'][0] . " $mail" . "</option>"; 
     40                $id = $value[$t.'id'] ? $value[$t.'id'] : $value[$t.'idnumber']; 
     41 
     42                $options .= '<option value='.$value[ $t.'idnumber' ].'>'.$value['cn'].'('.$id.')</option>'; 
    4743                }        
     44 
    4845        return $options;                 
    4946        }  
  • trunk/calendar/inc/class.boholiday.inc.php

    r3914 r5132  
    256256                                } 
    257257//                              echo 'Loading from: '.$load_from.'/holidays.'.strtoupper($locale).'.csv'."<br>\n"; 
    258                                 if(isset($GLOBALS['phpgw_info']['server']['holidays_url_path']) && $GLOBALS['phpgw_info']['server']['holidays_url_path'] != 'localhost') 
    259                                 { 
    260258                                    $lines = $network->gethttpsocketfile($load_from.'/holidays.'.strtoupper($locale).'.csv'); 
    261                                 } 
    262                                 else 
    263                                 { 
    264                                     $lines = explode(chr(0x0A),file_get_contents($load_from.'/holidays.'.strtoupper($locale).'.csv')); 
    265                                 } 
    266259                                if (!$lines) 
    267260                                { 
     
    296289                function add() 
    297290                { 
    298                         if(@$_POST['submit']) 
    299                         { 
    300291                                $holiday = $_POST['holiday']; 
     292 
     293 
    301294 
    302295                                if(empty($holiday['mday'])) 
     
    349342                                } 
    350343                        } 
    351                 } 
    352344 
    353345                function sort_holidays_by_date($holidays) 
  • trunk/calendar/inc/class.boicalendar.inc.php

    r3736 r5132  
    11<?php 
    2   /**************************************************************************\ 
    3   * eGroupWare - iCalendar Parser                                            * 
    4   * http://www.egroupware.org                                                * 
    5   * Written by Mark Peters <skeeter@phpgroupware.org>                        * 
    6   * --------------------------------------------                             * 
    7   *  This program is free software; you can redistribute it and/or modify it * 
    8   *  under the terms of the GNU General Public License as published by the   * 
    9   *  Free Software Foundation; either version 2 of the License, or (at your  * 
    10   *  option) any later version.                                              * 
    11   \**************************************************************************/ 
    12  
    13  
    14         define('FOLD_LENGTH',75); 
    15  
    16         define('VEVENT',1); 
    17         define('VTODO',2); 
    18  
    19         define('NONE',0); 
    20         define('CHAIR',1); 
    21         define('REQ_PARTICIPANT',2); 
    22         define('OPT_PARTICIPANT',3); 
    23         define('NON_PARTICIPANT',4); 
    24  
    25         define('INDIVIDUAL',1); 
    26         define('GROUP',2); 
    27         define('RESOURCE',4); 
    28         define('ROOM',8); 
    29         define('UNKNOWN',16); 
    30  
    31         define('NEEDS_ACTION',0); 
    32         define('ACCEPTED',1); 
    33         define('DECLINED',2); 
    34         define('TENTATIVE',3); 
    35         define('DELEGATED',4); 
    36         define('COMPLETED',5); 
    37         define('IN_PROCESS',6); 
    38  
    39         /* 
    40         * Class 
    41         */ 
    42         define('_PRIVATE',0); 
    43         define('_PUBLIC',1); 
    44         define('_CONFIDENTIAL',3); 
    45  
    46         /* 
    47         * Transparency 
    48         */ 
    49         define('TRANSPARENT',0); 
    50         define('OPAQUE',1); 
    51  
    52         /* 
    53         * Frequency 
    54         */ 
    55         define('SECONDLY',1); 
    56         define('MINUTELY',2); 
    57         define('HOURLY',3); 
    58         define('DAILY',4); 
    59         define('WEEKLY',5); 
    60         define('MONTHLY',6); 
    61         define('YEARLY',7); 
    62  
    63         define('FREE',0); 
    64         define('BUSY',1); 
    65         define('BUSY_UNAVAILABLE',2); 
    66         define('BUSY_TENTATIVE',3); 
    67  
    68         define('THISANDPRIOR',0); 
    69         define('THISANDFUTURE',1); 
    70  
    71         define('START',0); 
    72         define('END',1); 
    73  
    74         define('_8BIT',0); 
    75         define('_BASE64',1); 
    76  
    77         define('OTHER',99); 
    78  
    79         class boicalendar 
    80         { 
    81                 var $public_functions = array( 
     2 
     3/**************************************************************************\ 
     4* eGroupWare - iCalendar Parser                                            * 
     5* http://www.egroupware.org                                                * 
     6* Written by Mark Peters <skeeter@phpgroupware.org>                        * 
     7* --------------------------------------------                             * 
     8*  This program is free software; you can redistribute it and/or modify it * 
     9*  under the terms of the GNU General Public License as published by the   * 
     10*  Free Software Foundation; either version 2 of the License, or (at your  * 
     11*  option) any later version.                                              * 
     12\**************************************************************************/ 
     13 
     14define('FOLD_LENGTH', 75); 
     15 
     16define('VEVENT', 1); 
     17define('VTODO', 2); 
     18 
     19define('NONE', 0); 
     20define('CHAIR', 1); 
     21define('REQ_PARTICIPANT', 2); 
     22define('OPT_PARTICIPANT', 3); 
     23define('NON_PARTICIPANT', 4); 
     24 
     25define('INDIVIDUAL', 1); 
     26define('GROUP', 2); 
     27define('RESOURCE', 4); 
     28define('ROOM', 8); 
     29define('UNKNOWN', 16); 
     30 
     31define('NEEDS_ACTION', 0); 
     32define('ACCEPTED', 1); 
     33define('DECLINED', 2); 
     34define('TENTATIVE', 3); 
     35define('DELEGATED', 4); 
     36define('COMPLETED', 5); 
     37define('IN_PROCESS', 6); 
     38 
     39/* 
     40* Class 
     41*/ 
     42define('_PRIVATE', 0); 
     43define('_PUBLIC', 1); 
     44define('_CONFIDENTIAL', 3); 
     45 
     46/* 
     47* Transparency 
     48*/ 
     49define('TRANSPARENT', 0); 
     50define('OPAQUE', 1); 
     51 
     52/* 
     53* Frequency 
     54*/ 
     55define('SECONDLY', 1); 
     56define('MINUTELY', 2); 
     57define('HOURLY', 3); 
     58define('DAILY', 4); 
     59define('WEEKLY', 5); 
     60define('MONTHLY', 6); 
     61define('YEARLY', 7); 
     62 
     63define('FREE', 0); 
     64define('BUSY', 1); 
     65define('BUSY_UNAVAILABLE', 2); 
     66define('BUSY_TENTATIVE', 3); 
     67 
     68define('THISANDPRIOR', 0); 
     69define('THISANDFUTURE', 1); 
     70 
     71define('START', 0); 
     72define('END', 1); 
     73 
     74define('_8BIT', 0); 
     75define('_BASE64', 1); 
     76 
     77define('OTHER', 99); 
     78 
     79class boicalendar { 
     80        var $public_functions = array ( 
    8281                        'import' => True, 
    8382                        'export' => True, 
     
    8786                var $ical; 
    8887                var $line = 0; 
    89                 var $event = Array(); 
    90                 var $todo = Array(); 
    91                 var $journal = Array(); 
    92                 var $freebusy = Array(); 
    93                 var $timezone = Array(); 
    94                 var $property = Array(); 
    95                 var $parameter = Array(); 
     88        var $event = Array (); 
     89        var $todo = Array (); 
     90        var $journal = Array (); 
     91        var $freebusy = Array (); 
     92        var $timezone = Array (); 
     93        var $property = Array (); 
     94        var $parameter = Array (); 
    9695                var $debug_str = False; 
    9796                var $api = True; 
     
    102101                */ 
    103102 
    104                 function boicalendar() 
    105                 { 
    106                         $this->property = Array( 
    107                                 'action'                => Array( 
     103        function boicalendar() { 
     104                $this->property = Array ( 
     105                        'action' => Array ( 
    108106                                        'type'          => 'text', 
    109107                                        'to_text'       => True, 
    110                                         'valarm'                => Array( 
     108                                'valarm' => Array ( 
    111109                                                'state'         => 'required', 
    112110                                                'multiples'     => False 
    113111                                        ) 
    114112                                ), 
    115                                 'attach'                => Array( 
     113                        'attach' => Array ( 
    116114                                        'type'          => 'uri', 
    117115                                        'to_text'       => True, 
    118                                         'vevent'        => Array( 
    119                                                 'state'         => 'optional', 
    120                                                 'multiples'     => True 
    121                                         ), 
    122                                         'vtodo'         => Array( 
    123                                                 'state'         => 'optional', 
    124                                                 'multiples'     => True 
    125                                         ), 
    126                                         'vjournal'              => Array( 
    127                                                 'state'         => 'optional', 
    128                                                 'multiples'     => True 
    129                                         ), 
    130                                         'valarm'                => Array( 
    131                                                 'state'         => 'optional', 
    132                                                 'multiples'     => True 
    133                                         ) 
    134                                 ), 
    135                                 'attendee'              => Array( 
     116                                'vevent' => Array ( 
     117                                                'state'         => 'optional', 
     118                                                'multiples'     => True 
     119                                        ), 
     120                                'vtodo' => Array ( 
     121                                                'state'         => 'optional', 
     122                                                'multiples'     => True 
     123                                        ), 
     124                                'vjournal' => Array ( 
     125                                                'state'         => 'optional', 
     126                                                'multiples'     => True 
     127                                        ), 
     128                                'valarm' => Array ( 
     129                                                'state'         => 'optional', 
     130                                                'multiples'     => True 
     131                                        ) 
     132                                ), 
     133                        'attendee' => Array ( 
    136134                                        'type'          => 'cal-address', 
    137135                                        'to_text'       => False, 
    138                                         'vevent'        => Array( 
    139                                                 'state'         => 'optional', 
    140                                                 'multiples'     => True 
    141                                         ), 
    142                                         'vtodo'         => Array( 
    143                                                 'state'         => 'optional', 
    144                                                 'multiples'     => True 
    145                                         ), 
    146                                         'vjournal'              => Array( 
    147                                                 'state'         => 'optional', 
    148                                                 'multiples'     => True 
    149                                         ), 
    150                                         'valarm'                => Array( 
    151                                                 'state'         => 'optional', 
    152                                                 'multiples'     => True 
    153                                         ), 
    154                                         'vfreebusy'             => Array( 
    155                                                 'state'         => 'optional', 
    156                                                 'multiples'     => True 
    157                                         ) 
    158                                 ), 
    159                                 'categories'            => Array( 
     136                                'vevent' => Array ( 
     137                                                'state'         => 'optional', 
     138                                                'multiples'     => True 
     139                                        ), 
     140                                'vtodo' => Array ( 
     141                                                'state'         => 'optional', 
     142                                                'multiples'     => True 
     143                                        ), 
     144                                'vjournal' => Array ( 
     145                                                'state'         => 'optional', 
     146                                                'multiples'     => True 
     147                                        ), 
     148                                'valarm' => Array ( 
     149                                                'state'         => 'optional', 
     150                                                'multiples'     => True 
     151                                        ), 
     152                                'vfreebusy' => Array ( 
     153                                                'state'         => 'optional', 
     154                                                'multiples'     => True 
     155                                        ) 
     156                                ), 
     157                        'categories' => Array ( 
    160158                                        'type'          => 'text', 
    161159                                        'to_text'       => True, 
    162                                         'vevent'        => Array( 
    163                                                 'state'         => 'optional', 
    164                                                 'multiples'     => True 
    165                                         ), 
    166                                         'vtodo'         => Array( 
    167                                                 'state'         => 'optional', 
    168                                                 'multiples'     => False 
    169                                         ), 
    170                                         'vjournal'              => Array( 
    171                                                 'state'         => 'optional', 
    172                                                 'multiples'     => True 
    173                                         ) 
    174                                 ), 
    175                                 'class'                 => Array( 
     160                                'vevent' => Array ( 
     161                                                'state'         => 'optional', 
     162                                                'multiples'     => True 
     163                                        ), 
     164                                'vtodo' => Array ( 
     165                                                'state'         => 'optional', 
     166                                                'multiples'     => False 
     167                                        ), 
     168                                'vjournal' => Array ( 
     169                                                'state'         => 'optional', 
     170                                                'multiples'     => True 
     171                                        ) 
     172                                ), 
     173                        'class' => Array ( 
    176174                                        'type'          => 'text', 
    177175                                        'to_text'       => True, 
    178                                         'vevent'                => Array( 
    179                                                 'state'         => 'optional', 
    180                                                 'multiples'     => False 
    181                                         ), 
    182                                         'vtodo'         => Array( 
    183                                                 'state'         => 'optional', 
    184                                                 'multiples'     => False 
    185                                         ), 
    186                                         'vjournal'              => Array( 
    187                                                 'state'         => 'optional', 
    188                                                 'multiples'     => False 
    189                                         ) 
    190                                 ), 
    191                                 'comment'               => Array( 
     176                                'vevent' => Array ( 
     177                                                'state'         => 'optional', 
     178                                                'multiples'     => False 
     179                                        ), 
     180                                'vtodo' => Array ( 
     181                                                'state'         => 'optional', 
     182                                                'multiples'     => False 
     183                                        ), 
     184                                'vjournal' => Array ( 
     185                                                'state'         => 'optional', 
     186                                                'multiples'     => False 
     187                                        ) 
     188                                ), 
     189                        'comment' => Array ( 
    192190                                        'type'          => 'text', 
    193191                                        'to_text'       => True, 
    194                                         'daylight'      => Array( 
    195                                                 'state'         => 'optional', 
    196                                                 'multiples'     => True 
    197                                         ), 
    198                                         'standard'      => Array( 
    199                                                 'state'         => 'optional', 
    200                                                 'multiples'     => True 
    201                                         ), 
    202                                         'valarm'                => Array( 
    203                                                 'state'         => 'optional', 
    204                                                 'multiples'     => True 
    205                                         ), 
    206                                         'vevent'        => Array( 
    207                                                 'state'         => 'optional', 
    208                                                 'multiples'     => True 
    209                                         ), 
    210                                         'vfreebusy'             => Array( 
    211                                                 'state'         => 'optional', 
    212                                                 'multiples'     => True 
    213                                         ), 
    214                                         'vjournal'              => Array( 
    215                                                 'state'         => 'optional', 
    216                                                 'multiples'     => True 
    217                                         ), 
    218                                         'vtodo'         => Array( 
    219                                                 'state'         => 'optional', 
    220                                                 'multiples'     => True 
    221                                         ) 
    222                                 ), 
    223                                 'completed'             => Array( 
     192                                'daylight' => Array ( 
     193                                                'state'         => 'optional', 
     194                                                'multiples'     => True 
     195                                        ), 
     196                                'standard' => Array ( 
     197                                                'state'         => 'optional', 
     198                                                'multiples'     => True 
     199                                        ), 
     200                                'valarm' => Array ( 
     201                                                'state'         => 'optional', 
     202                                                'multiples'     => True 
     203                                        ), 
     204                                'vevent' => Array ( 
     205                                                'state'         => 'optional', 
     206                                                'multiples'     => True 
     207                                        ), 
     208                                'vfreebusy' => Array ( 
     209                                                'state'         => 'optional', 
     210                                                'multiples'     => True 
     211                                        ), 
     212                                'vjournal' => Array ( 
     213                                                'state'         => 'optional', 
     214                                                'multiples'     => True 
     215                                        ), 
     216                                'vtodo' => Array ( 
     217                                                'state'         => 'optional', 
     218                                                'multiples'     => True 
     219                                        ) 
     220                                ), 
     221                        'completed' => Array ( 
    224222                                        'type'          => 'date-time', 
    225223                                        'to_text'       => False, 
    226                                         'vtodo'         => Array( 
    227                                                 'state'         => 'optional', 
    228                                                 'multiples'     => False 
    229                                         ) 
    230                                 ), 
    231                                 'contact'               => Array( 
     224                                'vtodo' => Array ( 
     225                                                'state'         => 'optional', 
     226                                                'multiples'     => False 
     227                                        ) 
     228                                ), 
     229                        'contact' => Array ( 
    232230                                        'type'          => 'text', 
    233231                                        'to_text'       => True, 
    234                                         'vevent'                => Array( 
    235                                                 'state'         => 'optional', 
    236                                                 'multiples'     => True 
    237                                         ), 
    238                                         'vfreebusy'             => Array( 
    239                                                 'state'         => 'optional', 
    240                                                 'multiples'     => False 
    241                                         ), 
    242                                         'vjournal'              => Array( 
    243                                                 'state'         => 'optional', 
    244                                                 'multiples'     => True 
    245                                         ) 
    246                                 ), 
    247                                 'created'               => Array( 
     232                                'vevent' => Array ( 
     233                                                'state'         => 'optional', 
     234                                                'multiples'     => True 
     235                                        ), 
     236                                'vfreebusy' => Array ( 
     237                                                'state'         => 'optional', 
     238                                                'multiples'     => False 
     239                                        ), 
     240                                'vjournal' => Array ( 
     241                                                'state'         => 'optional', 
     242                                                'multiples'     => True 
     243                                        ) 
     244                                ), 
     245                        'created' => Array ( 
    248246                                        'type'          => 'date-time', 
    249247                                        'to_text'       => False, 
    250                                         'vevent'        => Array( 
    251                                                 'state'         => 'optional', 
    252                                                 'multiples'     => False 
    253                                         ), 
    254                                         'vtodo'         => Array( 
    255                                                 'state'         => 'optional', 
    256                                                 'multiples'     => False 
    257                                         ), 
    258                                         'vjournal'              => Array( 
    259                                                 'state'         => 'optional', 
    260                                                 'multiples'     => False 
    261                                         ) 
    262                                 ), 
    263                                 'description'           => Array( 
     248                                'vevent' => Array ( 
     249                                                'state'         => 'optional', 
     250                                                'multiples'     => False 
     251                                        ), 
     252                                'vtodo' => Array ( 
     253                                                'state'         => 'optional', 
     254                                                'multiples'     => False 
     255                                        ), 
     256                                'vjournal' => Array ( 
     257                                                'state'         => 'optional', 
     258                                                'multiples'     => False 
     259                                        ) 
     260                                ), 
     261                        'description' => Array ( 
    264262                                        'type'          => 'text', 
    265263                                        'to_text'       => True, 
    266                                         'vevent'        => Array( 
    267                                                 'state'         => 'optional', 
    268                                                 'multiples'     => False 
    269                                         ), 
    270                                         'vtodo'         => Array( 
    271                                                 'state'         => 'optional', 
    272                                                 'multiples'     => False 
    273                                         ), 
    274                                         'vjournal'              => Array( 
    275                                                 'state'         => 'optional', 
    276                                                 'multiples'     => True 
    277                                         ), 
    278                                         'valarm'                => Array( 
    279                                                 'state'         => 'optional', 
    280                                                 'multiples'     => False 
    281                                         ) 
    282                                 ), 
    283                                 'dtend'                 => Array( 
     264                                'vevent' => Array ( 
     265                                                'state'         => 'optional', 
     266                                                'multiples'     => False 
     267                                        ), 
     268                                'vtodo' => Array ( 
     269                                                'state'         => 'optional', 
     270                                                'multiples'     => False 
     271                                        ), 
     272                                'vjournal' => Array ( 
     273                                                'state'         => 'optional', 
     274                                                'multiples'     => True 
     275                                        ), 
     276                                'valarm' => Array ( 
     277                                                'state'         => 'optional', 
     278                                                'multiples'     => False 
     279                                        ) 
     280                                ), 
     281                        'dtend' => Array ( 
    284282                                        'type'          => 'date-time', 
    285283                                        'to_text'       => False, 
    286                                         'vevent'        => Array( 
    287                                                 'state'         => 'optional', 
    288                                                 'multiples'     => False 
    289                                         ), 
    290                                         'vfreebusy'             => Array( 
    291                                                 'state'         => 'optional', 
    292                                                 'multiples'     => False 
    293                                         ) 
    294                                 ), 
    295                                 'dtstamp'               => Array( 
     284                                'vevent' => Array ( 
     285                                                'state'         => 'optional', 
     286                                                'multiples'     => False 
     287                                        ), 
     288                                'vfreebusy' => Array ( 
     289                                                'state'         => 'optional', 
     290                                                'multiples'     => False 
     291                                        ) 
     292                                ), 
     293                        'dtstamp' => Array ( 
    296294                                        'type'          => 'date-time', 
    297295                                        'to_text'       => False, 
    298                                         'vevent'        => Array( 
    299                                                 'state'         => 'optional', 
    300                                                 'multiples'     => False 
    301                                         ), 
    302                                         'vtodo'         => Array( 
    303                                                 'state'         => 'optional', 
    304                                                 'multiples'     => False 
    305                                         ), 
    306                                         'vjournal'              => Array( 
    307                                                 'state'         => 'optional', 
    308                                                 'multiples'     => True 
    309                                         ), 
    310                                         'vfreebusy'             => Array( 
    311                                                 'state'         => 'optional', 
    312                                                 'multiples'     => False 
    313                                         ) 
    314                                 ), 
    315                                 'dtstart'               => Array( 
     296                                'vevent' => Array ( 
     297                                                'state'         => 'optional', 
     298                                                'multiples'     => False 
     299                                        ), 
     300                                'vtodo' => Array ( 
     301                                                'state'         => 'optional', 
     302                                                'multiples'     => False 
     303                                        ), 
     304                                'vjournal' => Array ( 
     305                                                'state'         => 'optional', 
     306                                                'multiples'     => True 
     307                                        ), 
     308                                'vfreebusy' => Array ( 
     309                                                'state'         => 'optional', 
     310                                                'multiples'     => False 
     311                                        ) 
     312                                ), 
     313                        'dtstart' => Array ( 
    316314                                        'type'          => 'date-time', 
    317315                                        'to_text'       => False, 
    318                                         'daylight'      => Array( 
     316                                'daylight' => Array ( 
    319317                                                'state'         => 'required', 
    320318                                                'multiples'     => False 
    321319                                        ), 
    322                                         'standard'      => Array( 
     320                                'standard' => Array ( 
    323321                                                'state'         => 'required', 
    324322                                                'multiples'     => False 
    325323                                        ), 
    326                                         'vevent'        => Array( 
    327                                                 'state'         => 'optional', 
    328                                                 'multiples'     => False 
    329                                         ), 
    330                                         'vfreebusy'             => Array( 
    331                                                 'state'         => 'optional', 
    332                                                 'multiples'     => False 
    333                                         ), 
    334                                         'vjournal'              => Array( 
    335                                                 'state'         => 'optional', 
    336                                                 'multiples'     => False 
    337                                         ), 
    338                                         'vtodo'         => Array( 
    339                                                 'state'         => 'optional', 
    340                                                 'multiples'     => False 
    341                                         ) 
    342                                 ), 
    343                                 'due'                   => Array( 
     324                                'vevent' => Array ( 
     325                                                'state'         => 'optional', 
     326                                                'multiples'     => False 
     327                                        ), 
     328                                'vfreebusy' => Array ( 
     329                                                'state'         => 'optional', 
     330                                                'multiples'     => False 
     331                                        ), 
     332                                'vjournal' => Array ( 
     333                                                'state'         => 'optional', 
     334                                                'multiples'     => False 
     335                                        ), 
     336                                'vtodo' => Array ( 
     337                                                'state'         => 'optional', 
     338                                                'multiples'     => False 
     339                                        ) 
     340                                ), 
     341                        'due' => Array ( 
    344342                                        'type'          => 'date-time', 
    345343                                        'to_text'       => False, 
    346                                         'vtodo'         => Array( 
    347                                                 'state'         => 'optional', 
    348                                                 'multiples'     => False 
    349                                         ) 
    350                                 ), 
    351                                 'duration'              => Array( 
     344                                'vtodo' => Array ( 
     345                                                'state'         => 'optional', 
     346                                                'multiples'     => False 
     347                                        ) 
     348                                ), 
     349                        'duration' => Array ( 
    352350                                        'type'          => 'duration', 
    353351                                        'to_text'       => False, 
    354                                         'valarm'                => Array( 
    355                                                 'state'         => 'optional', 
    356                                                 'multiples'     => False 
    357                                         ), 
    358                                         'vevent'        => Array( 
    359                                                 'state'         => 'optional', 
    360                                                 'multiples'     => False 
    361                                         ), 
    362                                         'vfreebusy'             => Array( 
    363                                                 'state'         => 'optional', 
    364                                                 'multiples'     => False 
    365                                         ), 
    366                                         'vtodo'         => Array( 
    367                                                 'state'         => 'optional', 
    368                                                 'multiples'     => False 
    369                                         ) 
    370                                 ), 
    371                                 'exdate'                => Array( 
     352                                'valarm' => Array ( 
     353                                                'state'         => 'optional', 
     354                                                'multiples'     => False 
     355                                        ), 
     356                                'vevent' => Array ( 
     357                                                'state'         => 'optional', 
     358                                                'multiples'     => False 
     359                                        ), 
     360                                'vfreebusy' => Array ( 
     361                                                'state'         => 'optional', 
     362                                                'multiples'     => False 
     363                                        ), 
     364                                'vtodo' => Array ( 
     365                                                'state'         => 'optional', 
     366                                                'multiples'     => False 
     367                                        ) 
     368                                ), 
     369                        'exdate' => Array ( 
    372370                                        'type'          => 'date-time', 
    373371                                        'to_text'       => False, 
    374                                         'vevent'                => Array( 
    375                                                 'state'         => 'optional', 
    376                                                 'multiples'     => True 
    377                                         ), 
    378                                         'vjournal'              => Array( 
    379                                                 'state'         => 'optional', 
    380                                                 'multiples'     => True 
    381                                         ), 
    382                                         'vtodo'         => Array( 
    383                                                 'state'         => 'optional', 
    384                                                 'multiples'     => True 
    385                                         ) 
    386                                 ), 
    387                                 'exrule'                => Array( 
     372                                'vevent' => Array ( 
     373                                                'state'         => 'optional', 
     374                                                'multiples'     => True 
     375                                        ), 
     376                                'vjournal' => Array ( 
     377                                                'state'         => 'optional', 
     378                                                'multiples'     => True 
     379                                        ), 
     380                                'vtodo' => Array ( 
     381                                                'state'         => 'optional', 
     382                                                'multiples'     => True 
     383                                        ) 
     384                                ), 
     385                        'exrule' => Array ( 
    388386                                        'type'          => 'recur', 
    389387                                        'to_text'       => False, 
    390                                         'vevent'                => Array( 
    391                                                 'state'         => 'optional', 
    392                                                 'multiples'     => True 
    393                                         ), 
    394                                         'vjournal'              => Array( 
    395                                                 'state'         => 'optional', 
    396                                                 'multiples'     => True 
    397                                         ), 
    398                                         'vtodo'         => Array( 
    399                                                 'state'         => 'optional', 
    400                                                 'multiples'     => True 
    401                                         ) 
    402                                 ), 
    403                                 'freebusy'              => Array( 
     388                                'vevent' => Array ( 
     389                                                'state'         => 'optional', 
     390                                                'multiples'     => True 
     391                                        ), 
     392                                'vjournal' => Array ( 
     393                                                'state'         => 'optional', 
     394                                                'multiples'     => True 
     395                                        ), 
     396                                'vtodo' => Array ( 
     397                                                'state'         => 'optional', 
     398                                                'multiples'     => True 
     399                                        ) 
     400                                ), 
     401                        'freebusy' => Array ( 
    404402                                        'type'          => 'freebusy', 
    405403                                        'to_text'       => False, 
    406                                         'vfreebusy'             => Array( 
    407                                                 'state'         => 'optional', 
    408                                                 'multiples'     => True 
    409                                         ) 
    410                                 ), 
    411                                 'geo'                   => Array( 
     404                                'vfreebusy' => Array ( 
     405                                                'state'         => 'optional', 
     406                                                'multiples'     => True 
     407                                        ) 
     408                                ), 
     409                        'geo' => Array ( 
    412410                                        'type'          => 'float', 
    413411                                        'to_text'       => True, 
    414                                         'vevent'        => Array( 
    415                                                 'state'         => 'optional', 
    416                                                 'multiples'     => False 
    417                                         ), 
    418                                         'vtodo'         => Array( 
    419                                                 'state'         => 'optional', 
    420                                                 'multiples'     => False 
    421                                         ) 
    422                                 ), 
    423                                 'last_modified'         => Array( 
     412                                'vevent' => Array ( 
     413                                                'state'         => 'optional', 
     414                                                'multiples'     => False 
     415                                        ), 
     416                                'vtodo' => Array ( 
     417                                                'state'         => 'optional', 
     418                                                'multiples'     => False 
     419                                        ) 
     420                                ), 
     421                        'last_modified' => Array ( 
    424422                                        'type'          => 'date-time', 
    425423                                        'to_text'       => False, 
    426                                         'vevent'        => Array( 
    427                                                 'state'         => 'optional', 
    428                                                 'multiples'     => False 
    429                                         ), 
    430                                         'vtodo'         => Array( 
    431                                                 'state'         => 'optional', 
    432                                                 'multiples'     => False 
    433                                         ), 
    434                                         'vjournal'              => Array( 
    435                                                 'state'         => 'optional', 
    436                                                 'multiples'     => False 
    437                                         ), 
    438                                         'vtimezone'             => Array( 
    439                                                 'state'         => 'optional', 
    440                                                 'multiples'     => False 
    441                                         ) 
    442                                 ), 
    443                                 'location'              => Array( 
     424                                'vevent' => Array ( 
     425                                                'state'         => 'optional', 
     426                                                'multiples'     => False 
     427                                        ), 
     428                                'vtodo' => Array ( 
     429                                                'state'         => 'optional', 
     430                                                'multiples'     => False 
     431                                        ), 
     432                                'vjournal' => Array ( 
     433                                                'state'         => 'optional', 
     434                                                'multiples'     => False 
     435                                        ), 
     436                                'vtimezone' => Array ( 
     437                                                'state'         => 'optional', 
     438                                                'multiples'     => False 
     439                                        ) 
     440                                ), 
     441                        'location' => Array ( 
    444442                                        'type'          => 'text', 
    445443                                        'to_text'       => True, 
    446                                         'vevent'        => Array( 
    447                                                 'state'         => 'optional', 
    448                                                 'multiples'     => False 
    449                                         ), 
    450                                         'vtodo'         => Array( 
    451                                                 'state'         => 'optional', 
    452                                                 'multiples'     => False 
    453                                         ) 
    454                                 ), 
    455                                 'method'                        => Array( 
     444                                'vevent' => Array ( 
     445                                                'state'         => 'optional', 
     446                                                'multiples'     => False 
     447                                        ), 
     448                                'vtodo' => Array ( 
     449                                                'state'         => 'optional', 
     450                                                'multiples'     => False 
     451                                        ) 
     452                                ), 
     453                        'method' => Array ( 
    456454                                        'type'          => 'text', 
    457455                                        'to_text'       => True, 
    458                                         'ical'  => Array( 
     456                                'ical' => Array ( 
    459457                                                'state'         => 'required', 
    460458                                                'multiples'     => False 
    461459                                        ) 
    462460                                ), 
    463                                 'organizer'             => Array( 
     461                        'organizer' => Array ( 
    464462                                        'type'          => 'cal-address', 
    465463                                        'to_text'       => False, 
    466                                         'vevent'        => Array( 
    467                                                 'state'         => 'optional', 
    468                                                 'multiples'     => False 
    469                                         ), 
    470                                         'vtodo'         => Array( 
    471                                                 'state'         => 'optional', 
    472                                                 'multiples'     => False 
    473                                         ), 
    474                                         'vjournal'              => Array( 
    475                                                 'state'         => 'optional', 
    476                                                 'multiples'     => False 
    477                                         ), 
    478                                         'vfreebusy'             => Array( 
    479                                                 'state'         => 'optional', 
    480                                                 'multiples'     => False 
    481                                         ) 
    482                                 ), 
    483                                 'percent_complete'      => Array( 
     464                                'vevent' => Array ( 
     465                                                'state'         => 'optional', 
     466                                                'multiples'     => False 
     467                                        ), 
     468                                'vtodo' => Array ( 
     469                                                'state'         => 'optional', 
     470                                                'multiples'     => False 
     471                                        ), 
     472                                'vjournal' => Array ( 
     473                                                'state'         => 'optional', 
     474                                                'multiples'     => False 
     475                                        ), 
     476                                'vfreebusy' => Array ( 
     477                                                'state'         => 'optional', 
     478                                                'multiples'     => False 
     479                                        ) 
     480                                ), 
     481                        'percent_complete' => Array ( 
    484482                                        'type'          => 'integer', 
    485483                                        'to_text'       => False, 
    486                                         'vtodo'         => Array( 
    487                                                 'state'         => 'optional', 
    488                                                 'multiples'     => False 
    489                                         ) 
    490                                 ), 
    491                                 'priority'              => Array( 
     484                                'vtodo' => Array ( 
     485                                                'state'         => 'optional', 
     486                                                'multiples'     => False 
     487                                        ) 
     488                                ), 
     489                        'priority' => Array ( 
    492490                                        'type'          => 'integer', 
    493491                                        'to_text'       => True, 
    494                                         'vevent'        => Array( 
    495                                                 'state'         => 'optional', 
    496                                                 'multiples'     => False 
    497                                         ), 
    498                                         'vtodo'         => Array( 
    499                                                 'state'         => 'optional', 
    500                                                 'multiples'     => False 
    501                                         ) 
    502                                 ), 
    503                                 'prodid'                        => Array( 
     492                                'vevent' => Array ( 
     493                                                'state'         => 'optional', 
     494                                                'multiples'     => False 
     495                                        ), 
     496                                'vtodo' => Array ( 
     497                                                'state'         => 'optional', 
     498                                                'multiples'     => False 
     499                                        ) 
     500                                ), 
     501                        'prodid' => Array ( 
    504502                                        'type'          => 'text', 
    505503                                        'to_text'       => True, 
    506                                         'ical'  => Array( 
     504                                'ical' => Array ( 
    507505                                                'state'         => 'required', 
    508506                                                'multiples'     => False 
    509507                                        ) 
    510508                                ), 
    511                                 'rdate'                 => Array( 
     509                        'rdate' => Array ( 
    512510                                        'type'          => 'date-time', 
    513511                                        'to_text'       => False, 
    514                                         'daylight'      => Array( 
    515                                                 'state'         => 'optional', 
    516                                                 'multiples'     => True 
    517                                         ), 
    518                                         'standard'      => Array( 
    519                                                 'state'         => 'optional', 
    520                                                 'multiples'     => True 
    521                                         ), 
    522                                         'vevent'        => Array( 
    523                                                 'state'         => 'optional', 
    524                                                 'multiples'     => True 
    525                                         ), 
    526                                         'vtodo'         => Array( 
    527                                                 'state'         => 'optional', 
    528                                                 'multiples'     => True 
    529                                         ), 
    530                                         'vjournal'              => Array( 
    531                                                 'state'         => 'optional', 
    532                                                 'multiples'     => True 
    533                                         ) 
    534                                 ), 
    535                                 'recurrence_id'         => Array( 
     512                                'daylight' => Array ( 
     513                                                'state'         => 'optional', 
     514                                                'multiples'     => True 
     515                                        ), 
     516                                'standard' => Array ( 
     517                                                'state'         => 'optional', 
     518                                                'multiples'     => True 
     519                                        ), 
     520                                'vevent' => Array ( 
     521                                                'state'         => 'optional', 
     522                                                'multiples'     => True 
     523                                        ), 
     524                                'vtodo' => Array ( 
     525                                                'state'         => 'optional', 
     526                                                'multiples'     => True 
     527                                        ), 
     528                                'vjournal' => Array ( 
     529                                                'state'         => 'optional', 
     530                                                'multiples'     => True 
     531                                        ) 
     532                                ), 
     533                        'recurrence_id' => Array ( 
    536534                                        'type'          => 'date-time', 
    537535                                        'to_text'       => False, 
    538                                         'vevent'        => Array( 
    539                                                 'state'         => 'optional', 
    540                                                 'multiples'     => False 
    541                                         ), 
    542                                         'vjournal'              => Array( 
    543                                                 'state'         => 'optional', 
    544                                                 'multiples'     => False 
    545                                         ), 
    546                                         'vtodo' => Array( 
    547                                                 'state'         => 'optional', 
    548                                                 'multiples'     => False 
    549                                         ) 
    550                                 ), 
    551                                 'related_to'            => Array( 
     536                                'vevent' => Array ( 
     537                                                'state'         => 'optional', 
     538                                                'multiples'     => False 
     539                                        ), 
     540                                'vjournal' => Array ( 
     541                                                'state'         => 'optional', 
     542                                                'multiples'     => False 
     543                                        ), 
     544                                'vtodo' => Array ( 
     545                                                'state'         => 'optional', 
     546                                                'multiples'     => False 
     547                                        ) 
     548                                ), 
     549                        'related_to' => Array ( 
    552550                                        'type'          => 'text', 
    553551                                        'to_text'       => False, 
    554                                         'vevent'        => Array( 
    555                                                 'state'         => 'optional', 
    556                                                 'multiples'     => False 
    557                                         ), 
    558                                         'vjournal'              => Array( 
    559                                                 'state'         => 'optional', 
    560                                                 'multiples'     => True 
    561                                         ), 
    562                                         'vtodo'         => Array( 
    563                                                 'state'         => 'optional', 
    564                                                 'multiples'     => True 
    565                                         ) 
    566                                 ), 
    567                                 'request_status'        => Array( 
     552                                'vevent' => Array ( 
     553                                                'state'         => 'optional', 
     554                                                'multiples'     => False 
     555                                        ), 
     556                                'vjournal' => Array ( 
     557                                                'state'         => 'optional', 
     558                                                'multiples'     => True 
     559                                        ), 
     560                                'vtodo' => Array ( 
     561                                                'state'         => 'optional', 
     562                                                'multiples'     => True 
     563                                        ) 
     564                                ), 
     565                        'request_status' => Array ( 
    568566                                        'type'          => 'text', 
    569567                                        'to_text'       => True, 
    570                                         'vevent'        => Array( 
    571                                                 'state'         => 'optional', 
    572                                                 'multiples'     => False 
    573                                         ), 
    574                                         'vtodo'         => Array( 
    575                                                 'state'         => 'optional', 
    576                                                 'multiples'     => False 
    577                                         ), 
    578                                         'vjournal'              => Array( 
    579                                                 'state'         => 'optional', 
    580                                                 'multiples'     => True 
    581                                         ), 
    582                                         'vfreebusy'             => Array( 
    583                                                 'state'         => 'optional', 
    584                                                 'multiples'     => True 
    585                                         ) 
    586                                 ), 
    587                                 'resources'             => Array( 
     568                                'vevent' => Array ( 
     569                                                'state'         => 'optional', 
     570                                                'multiples'     => False 
     571                                        ), 
     572                                'vtodo' => Array ( 
     573                                                'state'         => 'optional', 
     574                                                'multiples'     => False 
     575                                        ), 
     576                                'vjournal' => Array ( 
     577                                                'state'         => 'optional', 
     578                                                'multiples'     => True 
     579                                        ), 
     580                                'vfreebusy' => Array ( 
     581                                                'state'         => 'optional', 
     582                                                'multiples'     => True 
     583                                        ) 
     584                                ), 
     585                        'resources' => Array ( 
    588586                                        'type'          => 'text', 
    589587                                        'to_text'       => False, 
    590                                         'vevent'        => Array( 
    591                                                 'state'         => 'optional', 
    592                                                 'multiples'     => False 
    593                                         ), 
    594                                         'vtodo'         => Array( 
    595                                                 'state'         => 'optional', 
    596                                                 'multiples'     => False 
    597                                         ) 
    598                                 ), 
    599                                 'rrule'                 => Array( 
     588                                'vevent' => Array ( 
     589                                                'state'         => 'optional', 
     590                                                'multiples'     => False 
     591                                        ), 
     592                                'vtodo' => Array ( 
     593                                                'state'         => 'optional', 
     594                                                'multiples'     => False 
     595                                        ) 
     596                                ), 
     597                        'rrule' => Array ( 
    600598                                        'type'          => 'recur', 
    601599                                        'to_text'       => False, 
    602                                         'daylight'      => Array( 
    603                                                 'state'         => 'optional', 
    604                                                 'multiples'     => True 
    605                                         ), 
    606                                         'standard'      => Array( 
    607                                                 'state'         => 'optional', 
    608                                                 'multiples'     => True 
    609                                         ), 
    610                                         'vevent'        => Array( 
    611                                                 'state'         => 'optional', 
    612                                                 'multiples'     => True 
    613                                         ), 
    614                                         'vtodo'         => Array( 
    615                                                 'state'         => 'optional', 
    616                                                 'multiples'     => True 
    617                                         ), 
    618                                         'vjournal'              => Array( 
    619                                                 'state'         => 'optional', 
    620                                                 'multiples'     => True 
    621                                         ) 
    622                                 ), 
    623                                 'sequence'              => Array( 
     600                                'daylight' => Array ( 
     601                                                'state'         => 'optional', 
     602                                                'multiples'     => True 
     603                                        ), 
     604                                'standard' => Array ( 
     605                                                'state'         => 'optional', 
     606                                                'multiples'     => True 
     607                                        ), 
     608                                'vevent' => Array ( 
     609                                                'state'         => 'optional', 
     610                                                'multiples'     => True 
     611                                        ), 
     612                                'vtodo' => Array ( 
     613                                                'state'         => 'optional', 
     614                                                'multiples'     => True 
     615                                        ), 
     616                                'vjournal' => Array ( 
     617                                                'state'         => 'optional', 
     618                                                'multiples'     => True 
     619                                        ) 
     620                                ), 
     621                        'sequence' => Array ( 
    624622                                        'type'          => 'integer', 
    625623                                        'to_text'       => True, 
    626                                         'vevent'        => Array( 
    627                                                 'state'         => 'optional', 
    628                                                 'multiples'     => False 
    629                                         ), 
    630                                         'vjournal'              => Array( 
    631                                                 'state'         => 'optional', 
    632                                                 'multiples'     => False 
    633                                         ), 
    634                                         'vtodo'         => Array( 
    635                                                 'state'         => 'optional', 
    636                                                 'multiples'     => False 
    637                                         ) 
    638                                 ), 
    639                                 'status'                => Array( 
     624                                'vevent' => Array ( 
     625                                                'state'         => 'optional', 
     626                                                'multiples'     => False 
     627                                        ), 
     628                                'vjournal' => Array ( 
     629                                                'state'         => 'optional', 
     630                                                'multiples'     => False 
     631                                        ), 
     632                                'vtodo' => Array ( 
     633                                                'state'         => 'optional', 
     634                                                'multiples'     => False 
     635                                        ) 
     636                                ), 
     637                        'status' => Array ( 
    640638                                        'type'          => 'text', 
    641639                                        'to_text'       => True, 
    642                                         'vevent'        => Array( 
    643                                                 'state'         => 'optional', 
    644                                                 'multiples'     => False 
    645                                         ), 
    646                                         'vjournal'              => Array( 
    647                                                 'state'         => 'optional', 
    648                                                 'multiples'     => False 
    649                                         ), 
    650                                         'vtodo'         => Array( 
    651                                                 'state'         => 'optional', 
    652                                                 'multiples'     => False 
    653                                         ) 
    654                                 ), 
    655                                 'summary'               => Array( 
     640                                'vevent' => Array ( 
     641                                                'state'         => 'optional', 
     642                                                'multiples'     => False 
     643                                        ), 
     644                                'vjournal' => Array ( 
     645                                                'state'         => 'optional', 
     646                                                'multiples'     => False 
     647                                        ), 
     648                                'vtodo' => Array ( 
     649                                                'state'         => 'optional', 
     650                                                'multiples'     => False 
     651                                        ) 
     652                                ), 
     653                        'summary' => Array ( 
    656654                                        'type'          => 'text', 
    657655                                        'to_text'       => True, 
    658                                         'vevent'        => Array( 
    659                                                 'state'         => 'optional', 
    660                                                 'multiples'     => False 
    661                                         ), 
    662                                         'vtodo'         => Array( 
    663                                                 'state'         => 'optional', 
    664                                                 'multiples'     => False 
    665                                         ), 
    666                                         'vjournal'              => Array( 
    667                                                 'state'         => 'optional', 
    668                                                 'multiples'     => False 
    669                                         ), 
    670                                         'valarm'                => Array( 
    671                                                 'state'         => 'optional', 
    672                                                 'multiples'     => False 
    673                                         ) 
    674                                 ), 
    675                                 'transp'                => Array( 
     656                                'vevent' => Array ( 
     657                                                'state'         => 'optional', 
     658                                                'multiples'     => False 
     659                                        ), 
     660                                'vtodo' => Array ( 
     661                                                'state'         => 'optional', 
     662                                                'multiples'     => False 
     663                                        ), 
     664                                'vjournal' => Array ( 
     665                                                'state'         => 'optional', 
     666                                                'multiples'     => False 
     667                                        ), 
     668                                'valarm' => Array ( 
     669                                                'state'         => 'optional', 
     670                                                'multiples'     => False 
     671                                        ) 
     672                                ), 
     673                        'transp' => Array ( 
    676674                                        'type'          => 'text', 
    677675                                        'to_text'       => True, 
    678                                         'vevent'        => Array( 
    679                                                 'state'         => 'optional', 
    680                                                 'multiples'     => False 
    681                                         ) 
    682                                 ), 
    683                                 'trigger'               => Array( 
     676                                'vevent' => Array ( 
     677                                                'state'         => 'optional', 
     678                                                'multiples'     => False 
     679                                        ) 
     680                                ), 
     681                        'trigger' => Array ( 
    684682                                        'type'          => 'text', 
    685683                                        'to_text'       => True, 
    686                                         'valarm'        => Array( 
    687                                                 'state'         => 'optional', 
    688                                                 'multiples'     => False 
    689                                         ) 
    690                                 ), 
    691                                 'tzid'                  => Array( 
     684                                'valarm' => Array ( 
     685                                                'state'         => 'optional', 
     686                                                'multiples'     => False 
     687                                        ) 
     688                                ), 
     689                        'tzid' => Array ( 
    692690                                        'type'          => 'text', 
    693691                                        'to_text'       => True, 
    694                                         'vtimezone'             => Array( 
     692                                'vtimezone' => Array ( 
    695693                                                'state'         => 'required', 
    696694                                                'multiples'     => False 
    697695                                        ) 
    698696                                ), 
    699                                 'tzname'                => Array( 
     697                        'tzname' => Array ( 
    700698                                        'type'          => 'text', 
    701699                                        'to_text'       => True, 
    702                                         'daylight'      => Array( 
    703                                                 'state'         => 'optional', 
    704                                                 'multiples'     => True 
    705                                         ), 
    706                                         'standard'      => Array( 
    707                                                 'state'         => 'optional', 
    708                                                 'multiples'     => True 
    709                                         ) 
    710                                 ), 
    711                                 'tzoffsetfrom'          => Array( 
     700                                'daylight' => Array ( 
     701                                                'state'         => 'optional', 
     702                                                'multiples'     => True 
     703                                        ), 
     704                                'standard' => Array ( 
     705                                                'state'         => 'optional', 
     706                                                'multiples'     => True 
     707                                        ) 
     708                                ), 
     709                        'tzoffsetfrom' => Array ( 
    712710                                        'type'          => 'utc-offset', 
    713711                                        'to_text'       => True, 
    714                                         'daylight'              => Array( 
     712                                'daylight' => Array ( 
    715713                                                'state'         => 'required', 
    716714                                                'multiples'     => False 
    717715                                        ), 
    718                                         'standard'              => Array( 
     716                                'standard' => Array ( 
    719717                                                'state'         => 'required', 
    720718                                                'multiples'     => False 
    721719                                        ) 
    722720                                ), 
    723                                 'tzoffsetto'            => Array( 
     721                        'tzoffsetto' => Array ( 
    724722                                        'type'          => 'utc-offset', 
    725723                                        'to_text'       => True, 
    726                                         'daylight'              => Array( 
     724                                'daylight' => Array ( 
    727725                                                'state'         => 'required', 
    728726                                                'multiples'     => False 
    729727                                        ), 
    730                                         'standard'              => Array( 
     728                                'standard' => Array ( 
    731729                                                'state'         => 'required', 
    732730                                                'multiples'     => False 
    733731                                        ) 
    734732                                ), 
    735                                 'tzurl'                 => Array( 
     733                        'tzurl' => Array ( 
    736734                                        'type'          => 'uri', 
    737735                                        'to_text'       => True, 
    738                                         'vtimezone'             => Array( 
    739                                                 'state'         => 'optional', 
    740                                                 'multiples'     => False 
    741                                         ) 
    742                                 ), 
    743                                 'uid'                   => Array( 
     736                                'vtimezone' => Array ( 
     737                                                'state'         => 'optional', 
     738                                                'multiples'     => False 
     739                                        ) 
     740                                ), 
     741                        'uid' => Array ( 
    744742                                        'type'          => 'text', 
    745743                                        'to_text'       => True, 
    746                                         'vevent'        => Array( 
     744                                'vevent' => Array ( 
    747745                                                'state'         => 'required', 
    748746                                                'multiples'     => False 
    749747                                        ), 
    750                                         'vfreebusy'             => Array( 
     748                                'vfreebusy' => Array ( 
    751749                                                'state'         => 'required', 
    752750                                                'multiples'     => False 
    753751                                        ), 
    754                                         'vjournal'              => Array( 
     752                                'vjournal' => Array ( 
    755753                                                'state'         => 'required', 
    756754                                                'multiples'     => False 
    757755                                        ), 
    758                                         'vtodo'         => Array( 
     756                                'vtodo' => Array ( 
    759757                                                'state'         => 'required', 
    760758                                                'multiples'     => False 
    761759                                        ) 
    762760                                ), 
    763                                 'url'                   => Array( 
     761                        'url' => Array ( 
    764762                                        'type'          => 'text', 
    765763                                        'to_text'       => True, 
    766                                         'vevent'        => Array( 
     764                                'vevent' => Array ( 
    767765                                                'state'         => 'required', 
    768766                                                'multiples'     => False 
    769767                                        ), 
    770                                         'vfreebusy'             => Array( 
     768                                'vfreebusy' => Array ( 
    771769                                                'state'         => 'required', 
    772770                                                'multiples'     => False 
    773771                                        ), 
    774                                         'vjournal'              => Array( 
    775                                                 'state'         => 'optional', 
    776                                                 'multiples'     => False 
    777                                         ), 
    778                                         'vtodo' => Array( 
     772                                'vjournal' => Array ( 
     773                                                'state'         => 'optional', 
     774                                                'multiples'     => False 
     775                                        ), 
     776                                'vtodo' => Array ( 
    779777                                                'state'         => 'required', 
    780778                                                'multiples'     => False 
    781779                                        ) 
    782780                                ), 
    783                                 'version'                       => Array( 
     781                        'version' => Array ( 
    784782                                        'type'          => 'text', 
    785783                                        'to_text'       => True, 
    786                                         'ical'  => Array( 
     784                                'ical' => Array ( 
    787785                                                'state'         => 'required', 
    788786                                                'multiples'     => False 
     
    790788                                ) 
    791789                        ); 
    792                         $this->parameter = Array( 
    793                                 'altrep'                => Array( 
     790                $this->parameter = Array ( 
     791                        'altrep' => Array ( 
    794792                                        'type'          => 'uri', 
    795793                                        'quoted'                => True, 
    796794                                        'to_text'       => True, 
    797                                         'properties'    => Array( 
     795                                'properties' => Array ( 
    798796                                                'comment'               => True, 
    799797                                                'description'   => True, 
     
    805803                                        ) 
    806804                                ), 
    807                                 'byday'         => Array( 
     805                        'byday' => Array ( 
    808806                                        'type'          => 'text', 
    809807                                        'quoted'                => False, 
    810808                                        'to_text'       => False, 
    811                                         'properties'    => Array( 
     809                                'properties' => Array ( 
    812810                                                'rrule'         => True 
    813811                                        ) 
    814812                                ), 
    815                                 'byhour'                => Array( 
     813                        'byhour' => Array ( 
    816814                                        'type'          => 'text', 
    817815                                        'quoted'                => False, 
    818816                                        'to_text'       => False, 
    819                                         'properties'    => Array( 
     817                                'properties' => Array ( 
    820818                                                'rrule'         => True 
    821819                                        ) 
    822820                                ), 
    823                                 'byminute'              => Array( 
     821                        'byminute' => Array ( 
    824822                                        'type'          => 'text', 
    825823                                        'quoted'                => False, 
    826824                                        'to_text'       => False, 
    827                                         'properties'    => Array( 
     825                                'properties' => Array ( 
    828826                                                'rrule'         => True 
    829827                                        ) 
    830828                                ), 
    831                                 'bymonth'               => Array( 
     829                        'bymonth' => Array ( 
    832830                                        'type'          => 'text', 
    833831                                        'quoted'                => False, 
    834832                                        'to_text'       => False, 
    835                                         'properties'    => Array( 
     833                                'properties' => Array ( 
    836834                                                'rrule'         => True 
    837835                                        ) 
    838836                                ), 
    839                                 'bymonthday'    => Array( 
     837                        'bymonthday' => Array ( 
    840838                                        'type'          => 'text', 
    841839                                        'quoted'                => False, 
    842840                                        'to_text'       => False, 
    843                                         'properties'    => Array( 
     841                                'properties' => Array ( 
    844842                                                'rrule'         => True 
    845843                                        ) 
    846844                                ), 
    847                                 'bysecond'              => Array( 
     845                        'bysecond' => Array ( 
    848846                                        'type'          => 'text', 
    849847                                        'quoted'                => False, 
    850848                                        'to_text'       => False, 
    851                                         'properties'    => Array( 
     849                                'properties' => Array ( 
    852850                                                'rrule'         => True 
    853851                                        ) 
    854852                                ), 
    855                                 'bysetpos'              => Array( 
     853                        'bysetpos' => Array ( 
    856854                                        'type'          => 'text', 
    857855                                        'quoted'                => False, 
    858856                                        'to_text'       => False, 
    859                                         'properties'    => Array( 
     857                                'properties' => Array ( 
    860858                                                'rrule'         => True 
    861859                                        ) 
    862860                                ), 
    863                                 'byweekno'              => Array( 
     861                        'byweekno' => Array ( 
    864862                                        'type'          => 'text', 
    865863                                        'quoted'                => False, 
    866864                                        'to_text'       => False, 
    867                                         'properties'    => Array( 
     865                                'properties' => Array ( 
    868866                                                'rrule'         => True 
    869867                                        ) 
    870868                                ), 
    871                                 'byyearday'             => Array( 
     869                        'byyearday' => Array ( 
    872870                                        'type'          => 'text', 
    873871                                        'quoted'                => False, 
    874872                                        'to_text'       => False, 
    875                                         'properties'    => Array( 
     873                                'properties' => Array ( 
    876874                                                'rrule'         => True 
    877875                                        ) 
    878876                                ), 
    879                                 'class'                 => Array( 
     877                        'class' => Array ( 
    880878                                        'type'          => 'function', 
    881879                                        'function'      => 'switch_class', 
    882880                                        'quoted'                => False, 
    883881                                        'to_text'       => False, 
    884                                         'properties'    => Array( 
     882                                'properties' => Array ( 
    885883                                                'class'                 => True 
    886884                                        ) 
    887885                                ), 
    888                                 'cn'                    => Array( 
     886                        'cn' => Array ( 
    889887                                        'type'          => 'text', 
    890888                                        'quoted'                => True, 
    891889                                        'to_text'       => False, 
    892                                         'properties'    => Array( 
     890                                'properties' => Array ( 
    893891                                                'attendee'              => True, 
    894892                                                'organizer'             => True 
    895893                                        ) 
    896894                                ), 
    897                                 'count'         => Array( 
     895                        'count' => Array ( 
    898896                                        'type'          => 'integer', 
    899897                                        'quoted'                => False, 
    900898                                        'to_text'       => False, 
    901                                         'properties'    => Array( 
     899                                'properties' => Array ( 
    902900                                                'rrule'                 => True 
    903901                                        ) 
    904902                                ), 
    905                                 'cu'                    => Array( 
     903                        'cu' => Array ( 
    906904                                        'type'          => 'function', 
    907905                                        'function'      => 'switch_cu', 
    908906                                        'quoted'                => False, 
    909907                                        'to_text'       => False, 
    910                                         'properties'    => Array( 
     908                                'properties' => Array ( 
    911909                                                'attendee'              => True 
    912910                                        ) 
    913911                                ), 
    914                                 'delegated_from'        => Array( 
     912                        'delegated_from' => Array ( 
    915913                                        'type'          => 'function', 
    916914                                        'function'      => 'switch_mailto', 
    917915                                        'quoted'                => True, 
    918916                                        'to_text'       => False, 
    919                                         'properties'    => Array( 
     917                                'properties' => Array ( 
    920918                                                'attendee'              => True 
    921919                                        ) 
    922920                                ), 
    923                                 'delegated_to'  => Array( 
     921                        'delegated_to' => Array ( 
    924922                                        'type'          => 'function', 
    925923                                        'function'      => 'switch_mailto', 
    926924                                        'quoted'                => True, 
    927925                                        'to_text'       => False, 
    928                                         'properties'    => Array( 
     926                                'properties' => Array ( 
    929927                                                'attendee'              => True 
    930928                                        ) 
    931929                                ), 
    932                                 'dir'                   => Array( 
     930                        'dir' => Array ( 
    933931                                        'type'          => 'dir', 
    934932                                        'quoted'                => True, 
    935933                                        'to_text'       => True, 
    936                                         'properties'    => Array( 
     934                                'properties' => Array ( 
    937935                                                'attendee'              => True, 
    938936                                                'organizer'             => True 
    939937                                        ) 
    940938                                ), 
    941                                 'dtend'         => Array( 
     939                        'dtend' => Array ( 
    942940                                        'type'          => 'function', 
    943941                                        'function'      => 'switch_date', 
    944942                                        'quoted'                => False, 
    945943                                        'to_text'       => False, 
    946                                         'properties'    => Array( 
     944                                'properties' => Array ( 
    947945                                                'dtend'         => True 
    948946                                        ) 
    949947                                ), 
    950                                 'dtstamp'               => Array( 
     948                        'dtstamp' => Array ( 
    951949                                        'type'          => 'function', 
    952950                                        'function'      => 'switch_date', 
    953951                                        'quoted'                => False, 
    954952                                        'to_text'       => False, 
    955                                         'properties'    => Array( 
     953                                'properties' => Array ( 
    956954                                                'dtstamp'               => True 
    957955                                        ) 
    958956                                ), 
    959                                 'dtstart'               => Array( 
     957                        'dtstart' => Array ( 
    960958                                        'type'          => 'function', 
    961959                                        'function'      => 'switch_date', 
    962960                                        'quoted'                => False, 
    963961                                        'to_text'       => False, 
    964                                         'properties'    => Array( 
     962                                'properties' => Array ( 
    965963                                                'dtstart'               => True 
    966964                                        ) 
    967965                                ), 
    968                                 'encoding'      => Array( // was enocding ??? 
     966                        'encoding' => Array (// was enocding ??? 
    969967                                        'type'          => 'function', 
    970968                                        'function'      => 'switch_encoding', 
    971969                                        'quoted'                => False, 
    972970                                        'to_text'       => False, 
    973                                         'properties'    => Array( 
     971                                'properties' => Array ( 
    974972                                                'attach'                        => True 
    975973                                        ) 
    976974                                ), 
    977                                 'fmttype'       => Array( 
     975                        'fmttype' => Array ( 
    978976                                        'type'          => 'text', 
    979977                                        'quoted'                => False, 
    980978                                        'to_text'       => False, 
    981                                         'properties'    => Array( 
     979                                'properties' => Array ( 
    982980                                                'attach'                        => True 
    983981                                        ) 
    984982                                ), 
    985                                 'fbtype'                => Array( 
     983                        'fbtype' => Array ( 
    986984                                        'type'          => 'function', 
    987985                                        'function'      => 'switch_fbtype', 
    988986                                        'quoted'                => False, 
    989987                                        'to_text'       => False, 
    990                                         'properties'    => Array( 
     988                                'properties' => Array ( 
    991989                                                'attach'                        => True 
    992990                                        ) 
    993991                                ), 
    994                                 'freq'          => Array( 
     992                        'freq' => Array ( 
    995993                                        'type'          => 'function', 
    996994                                        'function'      => 'switch_freq', 
    997995                                        'quoted'                => False, 
    998996                                        'to_text'       => False, 
    999                                         'properties'    => Array( 
     997                                'properties' => Array ( 
    1000998                                                'rrule'                 => True 
    1001999                                        ) 
    10021000                                ), 
    1003                                 'interval'              => Array( 
     1001                        'interval' => Array ( 
    10041002                                        'type'          => 'integer', 
    10051003                                        'quoted'                => False, 
    10061004                                        'to_text'       => False, 
    1007                                         'properties'    => Array( 
     1005                                'properties' => Array ( 
    10081006                                                'rrule'         => True 
    10091007                                        ) 
    10101008                                ), 
    1011                                 'language'              => Array( 
     1009                        'language' => Array ( 
    10121010                                        'type'          => 'text', 
    10131011                                        'quoted'                => False, 
    10141012                                        'to_text'       => False, 
    1015                                         'properties'    => Array( 
     1013                                'properties' => Array ( 
    10161014                                                'categories'    => True, 
    10171015                                                'comment'               => True, 
     
    10271025                                        ) 
    10281026                                ), 
    1029                                 'last_modified'         => Array( 
     1027                        'last_modified' => Array ( 
    10301028                                        'type'          => 'function', 
    10311029                                        'function'      => 'switch_date', 
    10321030                                        'quoted'                => False, 
    10331031                                        'to_text'       => False, 
    1034                                         'properties'    => Array( 
     1032                                'properties' => Array ( 
    10351033                                                'last_modified' => True 
    10361034                                        ) 
    10371035                                ), 
    1038                                 'mailto'                => Array( 
     1036                        'mailto' => Array ( 
    10391037                                        'type'          => 'function', 
    10401038                                        'function'      => 'switch_mailto', 
    10411039                                        'quoted'                => False, 
    10421040                                        'to_text'       => False, 
    1043                                         'properties'    => Array( 
     1041                                'properties' => Array ( 
    10441042                                                'attendee'              => True, 
    10451043                                                'organizer'             => True 
    10461044                                        ) 
    10471045                                ), 
    1048                                 'member'                => Array( 
     1046                        'member' => Array ( 
    10491047                                        'type'          => 'function', 
    10501048                                        'function'      => 'switch_mailto', 
    10511049                                        'quoted'                => True, 
    10521050                                        'to_text'       => False, 
    1053                                         'properties'    => Array( 
     1051                                'properties' => Array ( 
    10541052                                                'attendee'              => True 
    10551053                                        ) 
    10561054                                ), 
    1057                                 'partstat'              => Array( 
     1055                        'partstat' => Array ( 
    10581056                                        'type'          => 'function', 
    10591057                                        'function'      => 'switch_partstat', 
    10601058                                        'quoted'                => False, 
    10611059                                        'to_text'       => False, 
    1062                                         'properties'    => Array( 
     1060                                'properties' => Array ( 
    10631061                                                'attendee'              => True, 
    10641062                                                'organizer'             => True 
    10651063                                        ) 
    10661064                                ), 
    1067                                 'range'         => Array( 
     1065                        'range' => Array ( 
    10681066                                        'type'          => 'function', 
    10691067                                        'function'      => 'switch_range', 
    10701068                                        'quoted'                => False, 
    10711069                                        'to_text'       => False, 
    1072                                         'properties'    => Array( 
     1070                                'properties' => Array ( 
    10731071                                                'recurrence_id' => True 
    10741072                                        ) 
    10751073                                ), 
    1076                                 'related'               => Array( 
     1074                        'related' => Array ( 
    10771075                                        'type'          => 'function', 
    10781076                                        'function'      => 'switch_related', 
    10791077                                        'quoted'                => False, 
    10801078                                        'to_text'       => False, 
    1081                                         'properties'    => Array( 
     1079                                'properties' => Array ( 
    10821080                                                'related_to'    => True 
    10831081                                        ) 
    10841082                                ), 
    1085                                 'role'          => Array( 
     1083                        'role' => Array ( 
    10861084                                        'type'          => 'function', 
    10871085                                        'function'      => 'switch_role', 
    10881086                                        'quoted'                => False, 
    10891087                                        'to_text'       => False, 
    1090                                         'properties'    => Array( 
     1088                                'properties' => Array ( 
    10911089                                                'attendee'              => True, 
    10921090                                                'organizer'             => True 
    10931091                                        ) 
    10941092                                ), 
    1095                                 'rsvp'          => Array( 
     1093                        'rsvp' => Array ( 
    10961094                                        'type'          => 'function', 
    10971095                                        'function'      => 'switch_rsvp', 
    10981096                                        'quoted'                => False, 
    10991097                                        'to_text'       => False, 
    1100                                         'properties'    => Array( 
     1098                                'properties' => Array ( 
    11011099                                                'attendee'              => True 
    11021100                                        ) 
    11031101                                ), 
    1104                                 'sent_by'               => Array( 
     1102                        'sent_by' => Array ( 
    11051103                                        'type'          => 'function', 
    11061104                                        'function'      => 'parse_user_host', 
    11071105                                        'quoted'                => True, 
    11081106                                        'to_text'       => False, 
    1109                                         'properties'    => Array( 
     1107                                'properties' => Array ( 
    11101108                                                'attendee'              => True, 
    11111109                                                'organizer'             => True 
    11121110                                        ) 
    11131111                                ), 
    1114                                 'tzid'          => Array( 
     1112                        'tzid' => Array ( 
    11151113                                        'type'          => 'text', 
    11161114                                        'quoted'                => False, 
    11171115                                        'to_text'       => False, 
    1118                                         'properties'    => Array( 
     1116                                'properties' => Array ( 
    11191117                                                'dtend'         => True, 
    11201118                                                'due'                   => True, 
     
    11251123                                        ) 
    11261124                                ), 
    1127                                 'until'         => Array( 
     1125                        'until' => Array ( 
    11281126                                        'type'          => 'function', 
    11291127                                        'function'      => 'switch_date', 
    11301128                                        'quoted'                => False, 
    11311129                                        'to_text'       => False, 
    1132                                         'properties'    => Array( 
     1130                                'properties' => Array ( 
    11331131                                                'rrule'         => True 
    11341132                                        ) 
    11351133                                ), 
    1136                                 'value'         => Array( 
     1134                        'value' => Array ( 
    11371135                                        'type'          => 'value', 
    11381136                                        'quoted'                => False, 
    11391137                                        'to_text'       => False, 
    1140                                         'properties'    => Array( 
     1138                                'properties' => Array ( 
    11411139                                                'calscale'      => True, 
    11421140                                                'prodid'                => True, 
     
    11881186                                        ) 
    11891187                                ), 
    1190                                 'wkst'          => Array( 
     1188                        'wkst' => Array ( 
    11911189                                        'type'          => 'string', 
    11921190                                        'quoted'                => False, 
    11931191                                        'to_text'       => False, 
    1194                                         'properties'    => Array( 
     1192                                'properties' => Array ( 
    11951193                                                'rrule'         => True 
    11961194                                        ) 
    11971195                                ), 
    1198                                 'x_type'                => Array( 
     1196                        'x_type' => Array ( 
    11991197                                        'type'          => 'x_type', 
    12001198                                        'quoted'                => False, 
    12011199                                        'to_text'       => False, 
    1202                                         'properties'    => Array( 
     1200                                'properties' => Array ( 
    12031201                                                'calscale'      => True, 
    12041202                                                'method'                => True, 
     
    12511249                                ) 
    12521250                        ); 
    1253                         if(!is_object($GLOBALS['phpgw']->datetime)) 
    1254                         { 
     1251                if (!is_object($GLOBALS['phpgw']->datetime)) { 
    12551252                                $GLOBALS['phpgw']->datetime = createobject('phpgwapi.date_time'); 
    12561253                        } 
    12571254                } 
    12581255 
    1259                 function set_var(&$event,$type,$value) 
    1260                 { 
    1261                         $type = strtolower(str_replace('-','_',$type)); 
     1256        function set_var(& $event, $type, $value) { 
     1257                $type = strtolower(str_replace('-', '_', $type)); 
    12621258                        $event[$type] = $value; 
    12631259                        /* 
     
    12731269                } 
    12741270 
    1275                 function read_line_unfold($ical_text) 
    1276                 { 
    1277                         if($this->line < count($ical_text)) 
    1278                         { 
    1279                                 $str = str_replace(array("\r\n","\r","\n"), '', $ical_text[$this->line]); 
     1271        function read_line_unfold($ical_text) { 
     1272                if ($this->line < count($ical_text)) { 
     1273                        $str = str_replace(array ( 
     1274                                "\r\n", 
     1275                                "\r", 
     1276                                "\n" 
     1277                        ), '', $ical_text[$this->line]); 
    12801278 
    12811279                                $this->line = $this->line + 1; 
    1282                                 while(ereg("^[[:space:]]",$ical_text[$this->line])) 
    1283                                 { 
    1284                                         $str .= substr(str_replace("\r\n",'',$ical_text[$this->line]),1); 
     1280                        while (ereg("^[[:space:]]", $ical_text[$this->line])) { 
     1281                                $str .= substr(str_replace("\r\n", '', $ical_text[$this->line]), 1); 
    12851282                                        $this->line = $this->line + 1; 
    12861283                                } 
    12871284                                 
    1288                                 // Corrige a codificacao dos caracteres 
    1289                                 $str = trim ($str); 
    1290                                 if ( mb_detect_encoding($str, 'auto') == 'UTF-8' ) 
    1291                                         $str = preg_replace("/([\xC2\xC3])([\x80-\xBF])/e","chr(ord('\\1')<<6&0xC0|ord('\\2')&0x3F)",$str); 
     1285                        // Corrige a codificacao dos caracteres, caso haja suporte a mesma. 
     1286                        $str = trim($str); 
     1287                        if (mb_detect_encoding($str, 'auto') == 'UTF-8') 
     1288                                if ($conv = preg_replace("/([\xC2\xC3])([\x80-\xBF])/e", "chr(ord('\\1')<<6&0xC0|ord('\\2')&0x3F)", $str)) 
     1289                                        $str = $conv; 
    12921290 
    12931291                                //$this->debug("LINE : ".$str); 
    12941292                                return $str; 
    1295                         } 
    1296                         else 
    1297                         { 
     1293                } else { 
    12981294                                return False; 
    12991295                        } 
    13001296                } 
    13011297 
    1302                 function fold($str) 
    1303                 { 
    1304                         return $this->chunk_split==True ? chunk_split($str,FOLD_LENGTH,"\r\n") : $str."\r\n"; 
    1305                 } 
    1306  
    1307                 function strip_quotes($str) 
    1308                 { 
    1309                         return str_replace('"','',$str); 
    1310                 } 
    1311  
    1312                 function from_text($str) 
    1313                 { 
    1314                         $str = str_replace("\\,",",",$str); 
    1315                         $str = str_replace("\\;",";",$str); 
    1316                         $str = str_replace("\\N","\n",$str); 
    1317                         $str = str_replace("\\n","\n",$str); 
    1318                         $str = str_replace("\\\\","\\",$str); 
     1298        function fold($str) { 
     1299                return $this->chunk_split == True ? chunk_split($str, FOLD_LENGTH, "\r\n") : $str . "\r\n"; 
     1300                } 
     1301 
     1302        function strip_quotes($str) { 
     1303                return str_replace('"', '', $str); 
     1304                } 
     1305 
     1306        function from_text($str) { 
     1307                $str = str_replace("\\,", ",", $str); 
     1308                $str = str_replace("\\;", ";", $str); 
     1309                $str = str_replace("\\N", "\n", $str); 
     1310                $str = str_replace("\\n", "\n", $str); 
     1311                $str = str_replace("\\\\", "\\", $str); 
    13191312                        return "$str"; 
    13201313                } 
    13211314 
    1322                 function to_text($str) 
    1323                 { 
    1324                         $str = str_replace("\\","\\\\",$str); 
    1325                         $str = str_replace(",","\\,",$str); 
    1326                         $str = str_replace(";","\\;",$str); 
    1327                         $str = str_replace("\n","\\n",$str); 
     1315        function to_text($str) { 
     1316                $str = str_replace("\\", "\\\\", $str); 
     1317                $str = str_replace(",", "\\,", $str); 
     1318                $str = str_replace(";", "\\;", $str); 
     1319                $str = str_replace("\n", "\\n", $str); 
    13281320                        return "$str"; 
    13291321                } 
    13301322 
    1331                 function from_dir($str) 
    1332                 { 
    1333                         return str_replace('=3D','=',str_replace('%20',' ',$str)); 
    1334                 } 
    1335  
    1336                 function to_dir($str) 
    1337                 { 
    1338                         return str_replace('=','=3D',str_replace(' ','%20',$str)); 
    1339                 } 
    1340  
    1341                 function find_parameters($property) 
    1342                 { 
     1323        function from_dir($str) { 
     1324                return str_replace('=3D', '=', str_replace('%20', ' ', $str)); 
     1325                } 
     1326 
     1327        function to_dir($str) { 
     1328                return str_replace('=', '=3D', str_replace(' ', '%20', $str)); 
     1329                } 
     1330 
     1331        function find_parameters($property) { 
    13431332                        static  $cached_returns; 
    13441333 
    1345                         if(isset($cached_returns[$property])) 
    1346                         { 
     1334                if (isset ($cached_returns[$property])) { 
    13471335                                reset($cached_returns[$property]); 
    13481336                                return $cached_returns[$property]; 
     
    13501338 
    13511339                        reset($this->parameter); 
    1352                         while(list($key,$param_array) = each($this->parameter)) 
    1353                         { 
    1354                                 if($param_array['properties'][$property]) 
    1355                                 { 
     1340                while (list ($key, $param_array) = each($this->parameter)) { 
     1341                        if ($param_array['properties'][$property]) { 
    13561342                                        $param[] = $key; 
    1357                                         $this->debug('Property : '.$property.' = Parameter : '.$key); 
     1343                                $this->debug('Property : ' . $property . ' = Parameter : ' . $key); 
    13581344                                } 
    13591345                        } 
     
    13631349                } 
    13641350 
    1365                 function find_properties($ical_type) 
    1366                 { 
     1351        function find_properties($ical_type) { 
    13671352                        static  $cached_returns; 
    13681353 
    1369                         if(isset($cached_returns[$ical_type])) 
    1370                         { 
     1354                if (isset ($cached_returns[$ical_type])) { 
    13711355                                reset($cached_returns[$ical_type]); 
    13721356                                return $cached_returns[$ical_type]; 
     
    13741358 
    13751359                        reset($this->property); 
    1376                         while(list($key,$param_array) = each($this->property)) 
    1377                         { 
    1378                                 if($param_array[$ical_type]) 
    1379                                 { 
     1360                while (list ($key, $param_array) = each($this->property)) { 
     1361                        if ($param_array[$ical_type]) { 
    13801362                                        $prop[] = $key; 
    13811363                                } 
     
    13861368                } 
    13871369 
    1388                 function new_ical() 
    1389                 { 
    1390                         return Array(); 
     1370        function new_ical() { 
     1371                return Array (); 
    13911372                } 
    13921373 
     
    13951376                */ 
    13961377 
    1397                 function parse_geo(&$event,$value) 
    1398                 { 
     1378        function parse_geo(& $event, $value) { 
    13991379                        //              $return_value = $this->explode_param($value,True); 
    1400                         if(count($return_value) == 2) 
    1401                         { 
     1380                if (count($return_value) == 2) { 
    14021381                                $event['lat'] = $return_value[0]; 
    14031382                                $event['lon'] = $return_value[1]; 
     
    14051384                } 
    14061385 
    1407                 function parse_xtype(&$event,$majortype,$value) 
    1408                 { 
    1409                         $temp_x_type['name'] = strtoupper(substr($majortype,2)); 
     1386        function parse_xtype(& $event, $majortype, $value) { 
     1387                $temp_x_type['name'] = strtoupper(substr($majortype, 2)); 
    14101388                        $temp_x_type['value'] = $value; 
    14111389                        $event['x_type'][] = $temp_x_type; 
    14121390                } 
    14131391 
    1414                 function parse_parameters(&$event,$majortype,$value) 
    1415                 { 
     1392        function parse_parameters(& $event, $majortype, $value) { 
    14161393                        //$this->debug ('value: '.$value); 
    1417                         if(!ereg('[\=\;]',$value)) 
    1418                         { 
    1419                                 $return_value[] = Array( 
     1394                if (!ereg('[\=\;]', $value)) { 
     1395                        $return_value[] = Array ( 
    14201396                                        'param' => $majortype, 
    14211397                                        'value' => $value 
     
    14231399                                $value = ''; 
    14241400                        } 
    1425                         elseif(ereg('(.*(\:\\\\)?.*):(.*)',$value,$temp)) 
    1426                         { 
     1401                elseif (ereg('(.*(\:\\\\)?.*):(.*)', $value, $temp)) { 
    14271402                                //$this->debug('Value : '._debug_array($temp,False)); 
    14281403                                //$this->debug('Param '.$majortype.' Value : '.$temp[3]); 
    1429                                 if($temp[3]) 
    1430                                 { 
    1431                                         $return_value[] = Array( 
     1404                        if ($temp[3]) { 
     1405                                $return_value[] = Array ( 
    14321406                                                'param' => $majortype, 
    14331407                                                'value' => $temp[3] 
    14341408                                        ); 
    1435                                         $value = str_replace(':MAILTO','',$temp[1]); 
    1436                                 } 
    1437                                 while(ereg('(([A-Z\-]*)[=]([[:alnum:] \_\)\(\/\$\.\,\:\\\|\*\&\^\%\#\!\~\"\?\&\@\<\>\-]*))([\;]?)(.*)',$value,$temp)) 
    1438                                 { 
     1409                                $value = str_replace(':MAILTO', '', $temp[1]); 
     1410                                } 
     1411                        while (ereg('(([A-Z\-]*)[=]([[:alnum:] \_\)\(\/\$\.\,\:\\\|\*\&\^\%\#\!\~\"\?\&\@\<\>\-]*))([\;]?)(.*)', $value, $temp)) { 
    14391412                                        //$this->debug('Value : '._debug_array($temp,False)); 
    14401413                                        //$this->debug('Param '.$temp[2].' Value : '.$temp[3]); 
    1441                                         $return_value[] = Array( 
     1414                                $return_value[] = Array ( 
    14421415                                                'param' => $temp[2], 
    14431416                                                'value' => $temp[3] 
     
    14461419                                        //$this->debug('Value would be = '.$value); 
    14471420                                } 
    1448                         } 
    1449                         else 
    1450                         { 
    1451                                 while(ereg('(([A-Z\-]*)[=]([[:alnum:] \_\)\(\/\$\.\,\:\\\|\*\&\^\%\#\!\~\"\?\&\@\<\>\-]*))([\;]?)(.*)',$value,$temp)) 
    1452                                 { 
    1453                                         $this->debug('Value : '._debug_array($temp,False)); 
    1454                                         $this->debug('Param '.$temp[2].' Value : '.$temp[3]); 
    1455                                         $return_value[] = Array( 
     1421                } else { 
     1422                        while (ereg('(([A-Z\-]*)[=]([[:alnum:] \_\)\(\/\$\.\,\:\\\|\*\&\^\%\#\!\~\"\?\&\@\<\>\-]*))([\;]?)(.*)', $value, $temp)) { 
     1423                                $this->debug('Value : ' . _debug_array($temp, False)); 
     1424                                $this->debug('Param ' . $temp[2] . ' Value : ' . $temp[3]); 
     1425                                $return_value[] = Array ( 
    14561426                                                'param' => $temp[2], 
    14571427                                                'value' => $temp[3] 
    14581428                                        ); 
    14591429                                        $value = chop($temp[5]); 
    1460                                         $this->debug('Value would be = '.$value); 
     1430                                $this->debug('Value would be = ' . $value); 
    14611431                                } 
    14621432                        } 
     
    14641434                        //$this->debug('parse_parameters array return_value: '._debug_array($return_value,False)); 
    14651435 
    1466                         for($i=0;$i<count($return_value);$i++) 
    1467                         { 
     1436                for ($i = 0; $i < count($return_value); $i++) { 
    14681437                                $name = strtolower($return_value[$i]['param']); 
    14691438                                $value = $this->strip_quotes($return_value[$i]['value']); 
    1470                                 if(substr($name,0,2) == 'x-') 
    1471                                 { 
     1439                        if (substr($name, 0, 2) == 'x-') { 
    14721440                                        $param = 'x_type'; 
    1473                                         $name = str_replace('-','_',$return_value[$i]['param']); 
    1474                                 } 
    1475                                 else 
    1476                                 { 
    1477                                         $param = str_replace('-','_',strtolower($name)); 
    1478                                         if(!isset($this->parameter[$param]) || $majortype == 'tzid') 
    1479                                         { 
    1480                                                 if($majortype == 'attendee' || $majortype == 'organizer') 
    1481                                                 { 
     1441                                $name = str_replace('-', '_', $return_value[$i]['param']); 
     1442                        } else { 
     1443                                $param = str_replace('-', '_', strtolower($name)); 
     1444                                if (!isset ($this->parameter[$param]) || $majortype == 'tzid') { 
     1445                                        if ($majortype == 'attendee' || $majortype == 'organizer') { 
    14821446                                                        $param = 'mailto'; 
    14831447                                                        $name = $param; 
    1484                                                 } 
    1485                                                 else 
    1486                                                 { 
     1448                                        } else { 
    14871449                                                        $param = 'value'; 
    14881450                                                } 
     
    14901452                                } 
    14911453                                //$this->debug('name : '.$name.' : Param = '.$param); 
    1492                                 if(@$this->parameter[$param]['properties'][$majortype]) 
    1493                                 { 
    1494                                         switch(@$this->parameter[$param]['type']) 
    1495                                         { 
    1496                                                 case 'dir': 
    1497                                                         $this->set_var($event,$name,$this->from_dir($value)); 
     1454                        if (@ $this->parameter[$param]['properties'][$majortype]) { 
     1455                                switch (@ $this->parameter[$param]['type']) { 
     1456                                        case 'dir' : 
     1457                                                $this->set_var($event, $name, $this->from_dir($value)); 
    14981458                                                        break; 
    1499                                                 case 'text': 
    1500                                                         $this->set_var($event,$name,$value); 
     1459                                        case 'text' : 
     1460                                                $this->set_var($event, $name, $value); 
    15011461                                                        break; 
    1502                                                 case 'x_type': 
    1503                                                         $this->parse_xtype($event,$name,$value); 
     1462                                        case 'x_type' : 
     1463                                                $this->parse_xtype($event, $name, $value); 
    15041464                                                        break; 
    1505                                                 case 'function': 
     1465                                        case 'function' : 
    15061466                                                        $function = $this->parameter[$param]['function']; 
    1507                                                         $this->set_var($event,$name,$this->$function($value)); 
     1467                                                $this->set_var($event, $name, $this-> $function ($value)); 
    15081468                                                        break; 
    1509                                                 case 'uri': 
    1510                                                         if(@$this->parameter[$param]['to_text']) 
    1511                                                         { 
     1469                                        case 'uri' : 
     1470                                                if (@ $this->parameter[$param]['to_text']) { 
    15121471                                                                $value = $this->to_text($value); 
    15131472                                                        } 
    1514                                                         $this->set_var($event,$name,$value); 
     1473                                                $this->set_var($event, $name, $value); 
    15151474                                                        break; 
    1516                                                 case 'integer': 
    1517                                                         $this->set_var($event,$name,(int)$value); 
     1475                                        case 'integer' : 
     1476                                                $this->set_var($event, $name, (int) $value); 
    15181477                                                        break; 
    1519                                                 case 'value': 
    1520                                                         if(@$this->property[$majortype]['type'] == 'date-time') 
    1521                                                         { 
    1522                                                                 $this->set_var($event,$param,$this->switch_date($name)); 
     1478                                        case 'value' : 
     1479                                                if (@ $this->property[$majortype]['type'] == 'date-time') { 
     1480                                                        $this->set_var($event, $param, $this->switch_date($name)); 
    15231481                                                        } 
    1524                                                         elseif($value <> "\\n" && $value) 
    1525                                                         { 
    1526                                                                 $this->set_var($event[$majortype],$param,$value); 
     1482                                                elseif ($value <> "\\n" && $value) { 
     1483                                                        $this->set_var($event[$majortype], $param, $value); 
    15271484                                                        } 
    1528                                                         $this->debug('Event : '._debug_array($event,False)); 
     1485                                                $this->debug('Event : ' . _debug_array($event, False)); 
    15291486                                                        break; 
    15301487                                        } 
     
    15331490                } 
    15341491 
    1535                 function parse_value(&$event,$majortype,$value,$mode) 
    1536                 { 
    1537                         $var = Array(); 
     1492        function parse_value(& $event, $majortype, $value, $mode) { 
     1493                $var = Array (); 
    15381494                        //$this->debug('Mode : '.$mode.' Majortype : '.$majortype); 
    1539                         $this->parse_parameters($var,$majortype,$value); 
    1540                         if($this->property[$majortype][$mode]['multiples']) 
    1541                         { 
     1495                $this->parse_parameters($var, $majortype, $value); 
     1496                if ($this->property[$majortype][$mode]['multiples']) { 
    15421497                                //$this->debug('parse_value var array: '._debug_array($var,False)); 
    15431498                                $event[$majortype][] = $var; 
    1544                         } 
    1545                         else 
    1546                         { 
     1499                } else { 
    15471500                                //$this->debug('Majortype : '.$majortype); 
    15481501                                //$this->debug('Property : '.$this->property[$majortype]['type']); 
    1549                                 if($this->property[$majortype]['type'] == 'date-time') 
    1550                                 { 
     1502                        if ($this->property[$majortype]['type'] == 'date-time') { 
    15511503                                        //$this->debug('Got a DATE-TIME type!'); 
    15521504                                        $t_var = $var[$majortype]; 
    1553                                         unset($var[$majortype]); 
    1554                                         if ( $t_var ) 
    1555                                         { 
     1505                                unset ($var[$majortype]); 
     1506                                if ($t_var) { 
    15561507                                                reset($t_var); 
    1557                                                 while(list($key,$val) = each($t_var)) 
    1558                                                 { 
     1508                                        while (list ($key, $val) = each($t_var)) { 
    15591509                                                        $var[$key] = $val; 
    15601510                                                } 
     
    15621512                                        } 
    15631513                                } 
    1564                                 $this->set_var($event,$majortype,$var); 
     1514                        $this->set_var($event, $majortype, $var); 
    15651515                        } 
    15661516                } 
     
    15701520                 */ 
    15711521 
    1572                 function build_xtype($x_type,$seperator='=') 
    1573                 { 
     1522        function build_xtype($x_type, $seperator = '=') { 
    15741523                        $quote = ''; 
    1575                         if($seperator == '=') 
    1576                         { 
     1524                if ($seperator == '=') { 
    15771525                                $quote = '"'; 
    15781526                        } 
    15791527 
    1580                         $return_value = $this->fold('X-'.$x_type['name'].$seperator.$quote.$x_type['value'].$quote); 
    1581                         if($seperator == '=') 
    1582                         { 
    1583                                 return str_replace("\r\n",'',$return_value); 
    1584                         } 
    1585                         else 
    1586                         { 
     1528                $return_value = $this->fold('X-' . $x_type['name'] . $seperator . $quote . $x_type['value'] . $quote); 
     1529                if ($seperator == '=') { 
     1530                        return str_replace("\r\n", '', $return_value); 
     1531                } else { 
    15871532                                return $return_value; 
    15881533                        } 
    15891534                } 
    15901535 
    1591                 function build_parameters($event,$property) 
    1592                 { 
     1536        function build_parameters($event, $property) { 
    15931537                        $str = ''; 
    15941538                        $include_mailto = False; 
     
    15961540                        $param = $this->find_parameters($property); 
    15971541 
    1598                         if($property == 'exdate') 
    1599                         { 
    1600                                 while(list($key,$value) = each($event)) 
    1601                                 { 
     1542                if ($property == 'exdate') { 
     1543                        while (list ($key, $value) = each($event)) { 
    16021544                                        $exdates[] = $this->switch_date($value); 
    16031545                                } 
    1604                                 return ':'.implode($exdates,','); 
    1605                         } 
    1606                         else 
    1607                         { 
    1608                                 while(list($dumb_key,$key) = each($param)) 
    1609                                 { 
    1610                                         if($key == 'value') 
    1611                                         { 
     1546                        return ':' . implode($exdates, ','); 
     1547                } else { 
     1548                        while (list ($dumb_key, $key) = each($param)) { 
     1549                                if ($key == 'value') { 
    16121550                                                continue; 
    16131551                                        } 
    1614                                         if($key == 'mailto') 
    1615                                         { 
     1552                                if ($key == 'mailto') { 
    16161553                                                $include_mailto = True; 
    16171554                                                continue; 
    16181555                                        } 
    1619                                         $param_array = @$this->parameter[$key]; 
    1620                                         $type = @$this->parameter[$key]['type']; 
    1621                                         if($type == 'date-time') 
    1622                                         { 
     1556                                $param_array = @ $this->parameter[$key]; 
     1557                                $type = @ $this->parameter[$key]['type']; 
     1558                                if ($type == 'date-time') { 
    16231559                                                $include_datetime = True; 
    16241560                                                continue; 
    16251561                                        } 
    1626                                         $quote = (@$this->parameter[$key]['quoted']?'"':''); 
    1627                                         if(isset($event[$key]) && @$this->parameter[$key]['properties'][$property]) 
    1628                                         { 
    1629                                                 $change_text = @$this->parameter[$key]['to_text']; 
     1562                                $quote = (@ $this->parameter[$key]['quoted'] ? '"' : ''); 
     1563                                if (isset ($event[$key]) && @ $this->parameter[$key]['properties'][$property]) { 
     1564                                        $change_text = @ $this->parameter[$key]['to_text']; 
    16301565                                                $value = $event[$key]; 
    1631                                                 if($change_text && $type == 'text') 
    1632                                                 { 
     1566                                        if ($change_text && $type == 'text') { 
    16331567                                                        $value = $this->to_text($value); 
    16341568                                                } 
    1635                                                 switch($type) 
    1636                                                 { 
    1637                                                         case 'dir': 
    1638                                                                 $str .= ';'.str_replace('_','-',strtoupper($key)).'='.$quote.$this->to_dir($value).$quote; 
     1569                                        switch ($type) { 
     1570                                                case 'dir' : 
     1571                                                        $str .= ';' . str_replace('_', '-', strtoupper($key)) . '=' . $quote . $this->to_dir($value) . $quote; 
    16391572                                                                break; 
    1640                                                         case 'function': 
    1641                                                                 $str .= ';'.str_replace('_','-',strtoupper($key)).'='; 
     1573                                                case 'function' : 
     1574                                                        $str .= ';' . str_replace('_', '-', strtoupper($key)) . '='; 
    16421575                                                                $function = $this->parameter[$key]['function']; 
    1643                                                                 $this->debug($key.' Function Param : '.$value); 
    1644                                                                 $str .= $quote.$this->$function($value).$quote; 
     1576                                                        $this->debug($key . ' Function Param : ' . $value); 
     1577                                                        $str .= $quote . $this-> $function ($value) . $quote; 
    16451578                                                                break; 
    1646                                                         case 'text': 
    1647                                                         case 'string': 
    1648                                                                 $str .= ';'.strtoupper($key).'='.$quote.$value.$quote; 
     1579                                                case 'text' : 
     1580                                                case 'string' : 
     1581                                                        $str .= ';' . strtoupper($key) . '=' . $quote . $value . $quote; 
    16491582                                                                break; 
    1650                                                         case 'date-time': 
    1651                                                                 $str .= ($key=='until'?':':';UNTIL=').date('Ymd\THis',mktime($event['hour'],$event['min'],$event['sec'],$event['month'],$event['mday'],$event['year'])).(!@isset($event['tzid'])?'Z':''); 
     1583                                                case 'date-time' : 
     1584                                                        $str .= ($key == 'until' ? ':' : ';UNTIL=') . date('Ymd\THis', mktime($event['hour'], $event['min'], $event['sec'], $event['month'], $event['mday'], $event['year'])) . (!@ isset ($event['tzid']) ? 'Z' : ''); 
    16521585                                                                break; 
    16531586                                                } 
    1654                                                 unset($value); 
    1655                                         } 
    1656                                 } 
    1657  
    1658                                 if(!empty($event['x_type'])) 
    1659                                 { 
     1587                                        unset ($value); 
     1588                                        } 
     1589                                } 
     1590 
     1591                        if (!empty ($event['x_type'])) { 
    16601592                                        $c_x_type = count($event['x_type']); 
    1661                                         for($j=0;$j<$c_x_type;$j++) 
    1662                                         { 
    1663                                                 $str .= ';'.$this->build_xtype($event['x_type'][$j],'='); 
    1664                                         } 
    1665                                 } 
    1666                                 if(!empty($event['value'])) 
    1667                                 { 
    1668                                         if($property == 'trigger') 
    1669                                         { 
     1593                                for ($j = 0; $j < $c_x_type; $j++) { 
     1594                                        $str .= ';' . $this->build_xtype($event['x_type'][$j], '='); 
     1595                                        } 
     1596                                } 
     1597                        if (!empty ($event['value'])) { 
     1598                                if ($property == 'trigger') { 
    16701599                                                $seperator = ';'; 
    1671                                         } 
    1672                                         else 
    1673                                         { 
     1600                                } else { 
    16741601                                                $seperator = ':'; 
    16751602                                        } 
    1676                                         $str .= $seperator.($this->parameter['value']['to_text']?$this->to_text($event['value']):$event['value']); 
    1677                                 } 
    1678                                 if($include_mailto == True) 
    1679                                 { 
     1603                                $str .= $seperator . ($this->parameter['value']['to_text'] ? $this->to_text($event['value']) : $event['value']); 
     1604                                } 
     1605                        if ($include_mailto == True) { 
    16801606                                        $key = 'mailto'; 
    16811607                                        $function = $this->parameter[$key]['function']; 
    1682                                         $ret_value = $this->$function($event[$key]); 
    1683                                         $str .= ($ret_value?':'.$ret_value:''); 
    1684                                 } 
    1685                                 if($include_datetime == True || @$this->property[$property]['type'] == 'date-time') 
    1686                                 { 
    1687                                         $str .= ':'.date('Ymd\THis',mktime($event['hour'],$event['min'],$event['sec'],$event['month'],$event['mday'],$event['year'])).(!@isset($event['tzid'])?'Z':''); 
    1688                                 } 
    1689                                 return ($property=='rrule'?':'.substr($str,1):$str); 
    1690                         } 
    1691                 } 
    1692  
    1693                 function build_text($event,$property) 
    1694                 { 
     1608                                $ret_value = $this-> $function ($event[$key]); 
     1609                                $str .= ($ret_value ? ':' . $ret_value : ''); 
     1610                                } 
     1611                        if ($include_datetime == True || @ $this->property[$property]['type'] == 'date-time') { 
     1612                                $str .= ':' . date('Ymd\THis', mktime($event['hour'], $event['min'], $event['sec'], $event['month'], $event['mday'], $event['year'])) . (!@ isset ($event['tzid']) ? 'Z' : ''); 
     1613                                } 
     1614                        return ($property == 'rrule' ? ':' . substr($str, 1) : $str); 
     1615                        } 
     1616                } 
     1617 
     1618        function build_text($event, $property) { 
    16951619                        $str = ''; 
    16961620                        $param = $this->find_parameters($property); 
    1697                         while(list($dumb_key,$key) = each($param)) 
    1698                         { 
    1699                                 if(!empty($event[$key]) && $key != 'value') 
    1700                                 { 
    1701                                         $type = @$this->parameter[$key]['type']; 
    1702                                         $quote = @$this->parameter[$key]['quote']; 
    1703                                         if(@$this->parameter[$key]['to_text'] == True) 
    1704                                         { 
     1621                while (list ($dumb_key, $key) = each($param)) { 
     1622                        if (!empty ($event[$key]) && $key != 'value') { 
     1623                                $type = @ $this->parameter[$key]['type']; 
     1624                                $quote = @ $this->parameter[$key]['quote']; 
     1625                                if (@ $this->parameter[$key]['to_text'] == True) { 
    17051626                                                $value = $this->to_text($event[$key]); 
    1706                                         } 
    1707                                         else 
    1708                                         { 
     1627                                } else { 
    17091628                                                $value = $event[$key]; 
    17101629                                        } 
    1711                                         switch($type) 
    1712                                         { 
    1713                                                 case 'text': 
    1714                                                 $str .= ';'.strtoupper($key).'='.$quote.$value.$quote; 
    1715                                                 break; 
    1716                                         } 
    1717                                 } 
    1718                         } 
    1719                         if(!empty($event['x_type'])) 
    1720                         { 
     1630                                switch ($type) { 
     1631                                        case 'text' : 
     1632                                                $str .= ';' . strtoupper($key) . '=' . $quote . $value . $quote; 
     1633                                                break; 
     1634                                        } 
     1635                                } 
     1636                        } 
     1637                if (!empty ($event['x_type'])) { 
    17211638                                $c_x_type = count($event['x_type']); 
    1722                                 for($j=0;$j<$c_x_type;$j++) 
    1723                                 { 
    1724                                         $str .= ';'.$this->build_xtype($event['x_type'][$j],'='); 
    1725                                 } 
    1726                         } 
    1727                         if(!empty($event['value'])) 
    1728                         { 
    1729                                 $str .= ':'.($this->parameter['value']['to_text']?$this->to_text($event['value']):$event['value']); 
     1639                        for ($j = 0; $j < $c_x_type; $j++) { 
     1640                                $str .= ';' . $this->build_xtype($event['x_type'][$j], '='); 
     1641                                } 
     1642                        } 
     1643                if (!empty ($event['value'])) { 
     1644                        $str .= ':' . ($this->parameter['value']['to_text'] ? $this->to_text($event['value']) : $event['value']); 
    17301645                        } 
    17311646                        return $str; 
    17321647                } 
    17331648 
    1734                 function build_card_internals($ical_item,$event) 
    1735                 { 
     1649        function build_card_internals($ical_item, $event) { 
    17361650                        $prop = $this->find_properties($ical_item); 
    17371651                        reset($prop); 
    1738                         while(list($dumb_key,$key) = each($prop)) 
    1739                         { 
     1652                while (list ($dumb_key, $key) = each($prop)) { 
    17401653                                $value  = $key; 
    17411654                                $varray = $this->property[$key]; 
    17421655                                $type   = $varray['type']; 
    17431656                                $to_text = $varray['to_text']; 
    1744                                 $state  = @$varray[$ical_item]['state']; 
    1745                                 $multiples  = @$varray[$ical_item]['multiples']; 
    1746                                 switch($type) 
    1747                                 { 
    1748                                         case 'date-time': 
    1749                                                 if(!empty($event[$value])) 
    1750                                                 { 
    1751                                                         if($multiples && $value != 'exdate') 
    1752                                                         { 
    1753                                                                 for($i=0;$i<count($event[$value]);$i++) 
    1754                                                                 { 
    1755                                                                         $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value][$i],$value)); 
     1657                        $state = @ $varray[$ical_item]['state']; 
     1658                        $multiples = @ $varray[$ical_item]['multiples']; 
     1659                        switch ($type) { 
     1660                                case 'date-time' : 
     1661                                        if (!empty ($event[$value])) { 
     1662                                                if ($multiples && $value != 'exdate') { 
     1663                                                        for ($i = 0; $i < count($event[$value]); $i++) { 
     1664                                                                $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . $this->build_parameters($event[$value][$i], $value)); 
     1665                                                                } 
     1666                                                } else { 
     1667                                                        $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . $this->build_parameters($event[$value], $value)); 
     1668                                                        } 
     1669                                                } 
     1670                                        elseif ($value == 'dtstamp' || $value == 'created') { 
     1671                                                $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . ':' . gmdate('Ymd\THis\Z')); 
     1672                                                } 
     1673                                                break; 
     1674                                case 'uri' : 
     1675                                        if (!empty ($event[$value])) { 
     1676                                                for ($i = 0; $i < count($event[$value]); $i++) { 
     1677                                                        $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . $this->build_parameters($event[$value][$i], $to_text)); 
     1678                                                        } 
     1679                                                } 
     1680                                                break; 
     1681                                case 'recur' : 
     1682                                        if (!empty ($event[$value])) { 
     1683                                                if ($multiples) { 
     1684                                                        for ($i = 0; $i < count($event[$value]); $i++) { 
     1685                                                                $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . $this->build_parameters($event[$value][$i], $value)); 
     1686                                                        } 
     1687                                                } else { 
     1688                                                        $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . $this->build_parameters($event[$value], $value)); 
     1689                                                        } 
     1690                                                } 
     1691                                                break; 
     1692                                case 'integer' : 
     1693                                        if (!empty ($event[$value])) { 
     1694                                                $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . ':' . $event[$value]); 
     1695                                                } 
     1696                                        elseif ($value == 'sequence' || $value == 'percent_complete') { 
     1697                                                $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . ':0'); 
     1698                                                } 
     1699                                                break; 
     1700                                case 'function' : 
     1701                                        $str .= ';' . str_replace('_', '-', strtoupper($value)) . '='; 
     1702                                        $function = @ $this->parameter[$key]['function']; 
     1703                                        $str .= (@ $this->parameter[$key]['quoted'] ? '"' : '') . $this-> $function ($event[$key]) . (@ $this->parameter[$key]['quoted'] ? '"' : ''); 
     1704                                                break; 
     1705                                case 'float' : 
     1706                                        if (!empty ($event[$value])) { 
     1707                                                $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . ':' . $event[$value]['lat'] . ';' . $event[$value]['lon']); 
     1708                                                } 
     1709                                                break; 
     1710                                case 'text' : 
     1711                                        if (isset ($event[$value])) { 
     1712                                                if (@ $this->parameter[$key]['type'] != 'function') { 
     1713                                                        if ($multiples && count($event[$value]) > 1) { 
     1714                                                                for ($i = 0; $i < count($event[$value]); $i++) { 
     1715                                                                        $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . $this->build_parameters($event[$value][$i], $value)); 
     1716                                                                } 
     1717                                                        } else { 
     1718                                                                $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . $this->build_parameters($event[$value], $value)); 
     1719                                                        } 
     1720                                                } else { 
     1721                                                                $function = $this->parameter[$value]['function']; 
     1722                                                        if ($multiples) { 
     1723                                                                for ($i = 0; $i < count($event[$value]); $i++) { 
     1724                                                                        $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . ':' . $this-> $function ($event[$value][$i])); 
     1725                                                                } 
     1726                                                        } else { 
     1727                                                                $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . ':' . $this-> $function ($event[$value])); 
    17561728                                                                } 
    17571729                                                        } 
    1758                                                         else 
    1759                                                         { 
    1760                                                                 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value],$value)); 
     1730                                                } 
     1731                                                break; 
     1732                                case 'cal-address' : 
     1733                                        if (is_array($event[$value][0])) { 
     1734                                                for ($j = 0; $j < count($event[$value]); $j++) { 
     1735                                                        $temp_output = $this->build_parameters($event[$value][$j], $value); 
     1736                                                        if ($temp_output) { 
     1737                                                                $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . $temp_output); 
    17611738                                                        } 
    17621739                                                } 
    1763                                                 elseif($value == 'dtstamp' || $value == 'created') 
    1764                                                 { 
    1765                                                         $str .= $this->fold(strtoupper(str_replace('_','-',$value)).':'.gmdate('Ymd\THis\Z')); 
    1766                                                 } 
    1767                                                 break; 
    1768                                         case 'uri': 
    1769                                                 if(!empty($event[$value])) 
    1770                                                 { 
    1771                                                         for($i=0;$i<count($event[$value]);$i++) 
    1772                                                         { 
    1773                                                                 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value][$i],$to_text)); 
     1740                                        } else { 
     1741                                                $temp_output = $this->build_parameters($event[$value], $value); 
     1742                                                if ($temp_output) { 
     1743                                                        $str .= $this->fold(strtoupper(str_replace('_', '-', $value)) . $temp_output); 
    17741744                                                        } 
    17751745                                                } 
    17761746                                                break; 
    1777                                         case 'recur': 
    1778                                                 if(!empty($event[$value])) 
    1779                                                 { 
    1780                                                         if($multiples) 
    1781                                                         { 
    1782                                                                 for($i=0;$i<count($event[$value]);$i++) 
    1783                                                                 { 
    1784                                                                         $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value][$i],$value)); 
    1785                                                                 } 
    1786                                                         } 
    1787                                                         else 
    1788                                                         { 
    1789                                                                 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value],$value)); 
    1790                                                         } 
    1791                                                 } 
    1792                                                 break; 
    1793                                         case 'integer': 
    1794                                                 if(!empty($event[$value])) 
    1795                                                 { 
    1796                                                         $str .= $this->fold(strtoupper(str_replace('_','-',$value)).':'.$event[$value]); 
    1797                                                 } 
    1798                                                 elseif($value == 'sequence' || $value == 'percent_complete') 
    1799                                                 { 
    1800                                                         $str .= $this->fold(strtoupper(str_replace('_','-',$value)).':0'); 
    1801                                                 } 
    1802                                                 break; 
    1803                                         case 'function': 
    1804                                                 $str .= ';'.str_replace('_','-',strtoupper($value)).'='; 
    1805                                                 $function = @$this->parameter[$key]['function']; 
    1806                                                 $str .= (@$this->parameter[$key]['quoted']?'"':'').$this->$function($event[$key]).(@$this->parameter[$key]['quoted']?'"':''); 
    1807                                                 break; 
    1808                                         case 'float': 
    1809                                                 if(!empty($event[$value])) 
    1810                                                 { 
    1811                                                         $str .= $this->fold(strtoupper(str_replace('_','-',$value)).':'.$event[$value]['lat'].';'.$event[$value]['lon']); 
    1812                                                 } 
    1813                                                 break; 
    1814                                         case 'text': 
    1815                                                 if(isset($event[$value])) 
    1816                                                 { 
    1817                                                         if(@$this->parameter[$key]['type'] != 'function') 
    1818                                                         { 
    1819                                                                 if($multiples && count($event[$value]) > 1) 
    1820                                                                 { 
    1821                                                                         for($i=0;$i<count($event[$value]);$i++) 
    1822                                                                         { 
    1823                                                                                 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value][$i],$value)); 
    1824                                                                         } 
    1825                                                                 } 
    1826                                                                 else 
    1827                                                                 { 
    1828                                                                         $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value],$value)); 
    1829                                                                 } 
    1830                                                         } 
    1831                                                         else 
    1832                                                         { 
    1833                                                                 $function = $this->parameter[$value]['function']; 
    1834                                                                 if($multiples) 
    1835                                                                 { 
    1836                                                                         for($i=0;$i<count($event[$value]);$i++) 
    1837                                                                         { 
    1838                                                                                 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).':'.$this->$function($event[$value][$i])); 
    1839                                                                         } 
    1840                                                                 } 
    1841                                                                 else 
    1842                                                                 { 
    1843                                                                         $str .= $this->fold(strtoupper(str_replace('_','-',$value)).':'.$this->$function($event[$value])); 
    1844                                                                 } 
    1845                                                         } 
    1846                                                 } 
    1847                                                 break; 
    1848                                         case 'cal-address': 
    1849                                                 if(is_array($event[$value][0])) 
    1850                                                 { 
    1851                                                         for($j=0;$j<count($event[$value]);$j++) 
    1852                                                         { 
    1853                                                                 $temp_output = $this->build_parameters($event[$value][$j],$value); 
    1854                                                                 if($temp_output) 
    1855                                                                 { 
    1856                                                                         $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$temp_output); 
    1857                                                                 } 
    1858                                                         } 
    1859                                                 } 
    1860                                                 else 
    1861                                                 { 
    1862                                                         $temp_output = $this->build_parameters($event[$value],$value); 
    1863                                                         if($temp_output) 
    1864                                                         { 
    1865                                                                 $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$temp_output); 
    1866                                                         } 
    1867                                                 } 
    1868                                                 break; 
    1869                                 } 
    1870                         } 
    1871                         if(!empty($event['x_type'])) 
    1872                         { 
    1873                                 for($i=0;$i<count($event['x_type']);$i++) 
    1874                                 { 
    1875                                         $str .= $this->build_xtype($event['x_type'][$i],':'); 
    1876                                 } 
    1877                         } 
    1878  
    1879                         if($ical_item == 'vtimezone') 
    1880                         { 
    1881                                 if($event['tzdata']) 
    1882                                 { 
    1883                                         for($k=0;$k<count($event['tzdata']);$k++) 
    1884                                         { 
    1885                                                 $str .= 'BEGIN:'.strtoupper($event['tzdata'][$k]['type'])."\r\n"; 
    1886                                                 $str .= $this->build_card_internals(strtolower($event['tzdata'][$k]['type']),$event['tzdata'][$k]); 
    1887                                                 $str .= 'END:'.strtoupper($event['tzdata'][$k]['type'])."\r\n"; 
    1888                                         } 
    1889                                 } 
    1890                         } 
    1891                         elseif($event['alarm']) 
    1892                         { 
    1893                                 for($k=0;$k<count($event['alarm']);$k++) 
    1894                                 { 
    1895                                         $str .= 'BEGIN:VALARM'."\r\n"; 
    1896                                         $str .= $this->build_card_internals('valarm',$event['alarm'][$k]); 
    1897                                         $str .= 'END:VALARM'."\r\n"; 
     1747                                } 
     1748                        } 
     1749                if (!empty ($event['x_type'])) { 
     1750                        for ($i = 0; $i < count($event['x_type']); $i++) { 
     1751                                $str .= $this->build_xtype($event['x_type'][$i], ':'); 
     1752                                } 
     1753                        } 
     1754 
     1755                if ($ical_item == 'vtimezone') { 
     1756                        if ($event['tzdata']) { 
     1757                                for ($k = 0; $k < count($event['tzdata']); $k++) { 
     1758                                        $str .= 'BEGIN:' . strtoupper($event['tzdata'][$k]['type']) . "\r\n"; 
     1759                                        $str .= $this->build_card_internals(strtolower($event['tzdata'][$k]['type']), $event['tzdata'][$k]); 
     1760                                        $str .= 'END:' . strtoupper($event['tzdata'][$k]['type']) . "\r\n"; 
     1761                                        } 
     1762                                } 
     1763                        } 
     1764                elseif ($event['alarm']) { 
     1765                        for ($k = 0; $k < count($event['alarm']); $k++) { 
     1766                                $str .= 'BEGIN:VALARM' . "\r\n"; 
     1767                                $str .= $this->build_card_internals('valarm', $event['alarm'][$k]); 
     1768                                $str .= 'END:VALARM' . "\r\n"; 
    18981769                                } 
    18991770                        } 
     
    19051776                */ 
    19061777                 
    1907                 function parse_user_host ($var) 
    1908                 { 
     1778        function parse_user_host($var) { 
    19091779                        return $this->switch_mailto($var);       
    19101780                } 
    19111781 
    1912                 function switch_class($var) 
    1913                 { 
    1914                         if(is_string($var)) 
    1915                         { 
    1916                                 switch($var) 
    1917                                 { 
    1918                                         case '_PRIVATE': 
     1782        function switch_class($var) { 
     1783                if (is_string($var)) { 
     1784                        switch ($var) { 
     1785                                case '_PRIVATE' : 
    19191786                                                $var = _PRIVATE; 
    19201787                                                break; 
    1921                                         case '_PUBLIC': 
     1788                                case '_PUBLIC' : 
    19221789                                                $var = _PUBLIC; 
    19231790                                                break; 
    1924                                         case '_CONFIDENTIAL': 
     1791                                case '_CONFIDENTIAL' : 
    19251792                                                $var = _CONFIDENTIAL; 
    19261793                                                break; 
    19271794                                } 
    19281795                        } 
    1929                         elseif(is_int($var)) 
    1930                         { 
    1931                                 switch((int)$var) 
    1932                                 { 
    1933                                         case _PRIVATE: 
     1796                elseif (is_int($var)) { 
     1797                        switch ((int) $var) { 
     1798                                case _PRIVATE : 
    19341799                                                $var = '_PRIVATE'; 
    19351800                                                break; 
    1936                                         case _PUBLIC: 
     1801                                case _PUBLIC : 
    19371802                                                $var = '_PUBLIC'; 
    19381803                                                break; 
    1939                                         case _CONFIDENTIAL: 
     1804                                case _CONFIDENTIAL : 
    19401805                                                $var = '_CONFIDENTIAL'; 
    19411806                                                break; 
     
    19451810                } 
    19461811 
    1947                 function switch_cu($var) 
    1948                 { 
    1949                         if(gettype($var) == 'string') 
    1950                         { 
    1951                                 switch($var) 
    1952                                 { 
    1953                                         case 'INDIVIDUAL': 
     1812        function switch_cu($var) { 
     1813                if (gettype($var) == 'string') { 
     1814                        switch ($var) { 
     1815                                case 'INDIVIDUAL' : 
    19541816                                                return INDIVIDUAL; 
    19551817                                                break; 
    1956                                         case 'GROUP': 
     1818                                case 'GROUP' : 
    19571819                                                return GROUP; 
    19581820                                                break; 
    1959                                         case 'RESOURCE': 
     1821                                case 'RESOURCE' : 
    19601822                                                return RESOURCE; 
    19611823                                                break; 
    1962                                         case 'ROOM': 
     1824                                case 'ROOM' : 
    19631825                                                return ROOM; 
    19641826                                                break; 
    1965                                         case 'UNKNOWN': 
     1827                                case 'UNKNOWN' : 
    19661828                                                return UNKNOWN; 
    19671829                                                break; 
    1968                                         default: 
     1830                                default : 
    19691831                                                return OTHER; 
    19701832                                                break; 
    19711833                                } 
    19721834                        } 
    1973                         elseif(gettype($var) == 'integer') 
    1974                         { 
    1975                                 switch($var) 
    1976                                 { 
    1977                                         case INDIVIDUAL: 
     1835                elseif (gettype($var) == 'integer') { 
     1836                        switch ($var) { 
     1837                                case INDIVIDUAL : 
    19781838                                                return 'INDIVIDUAL'; 
    19791839                                                break; 
    1980                                         case GROUP: 
     1840                                case GROUP : 
    19811841                                                return 'GROUP'; 
    19821842                                                break; 
    1983                                         case RESOURCE: 
     1843                                case RESOURCE : 
    19841844                                                return 'RESOURCE'; 
    19851845                                                break; 
    1986                                         case ROOM: 
     1846                                case ROOM : 
    19871847                                                return 'ROOM'; 
    19881848                                                break; 
    1989                                         case UNKNOWN: 
     1849                                case UNKNOWN : 
    19901850                                                return 'UNKNOWN'; 
    19911851                                                break; 
    1992                                         default: 
     1852                                default : 
    19931853                                                return 'X-OTHER'; 
    19941854                                                break; 
    19951855                                } 
    1996                         } 
    1997                         else 
    1998                         { 
     1856                } else { 
    19991857                                return $var; 
    20001858                        } 
    20011859                } 
    20021860 
    2003                 function switch_date($var) 
    2004                 { 
    2005                 $this->debug('SWITCH_DATE: gettype = '.gettype($var)); 
    2006                         if(is_string($var)) 
    2007                         { 
    2008                                 $dtime = Array(); 
    2009                                 if(strpos($var,':')) 
    2010                                 { 
    2011                                         $pos = explode(':',$var); 
     1861        function switch_date($var) { 
     1862                $this->debug('SWITCH_DATE: gettype = ' . gettype($var)); 
     1863                if (is_string($var)) { 
     1864                        $dtime = Array (); 
     1865                        if (strpos($var, ':')) { 
     1866                                $pos = explode(':', $var); 
    20121867                                        $var = $pos[1]; 
    20131868                                } 
    2014                                 $this->set_var($dtime,'year',(int)(substr($var,0,4))); 
    2015                                 $this->set_var($dtime,'month',(int)(substr($var,4,2))); 
    2016                                 $this->set_var($dtime,'mday',(int)(substr($var,6,2))); 
    2017                                 if(substr($var,8,1) == 'T') 
    2018                                 { 
    2019                                         $this->set_var($dtime,'hour',(int)(substr($var,9,2))); 
    2020                                         $this->set_var($dtime,'min',(int)(substr($var,11,2))); 
    2021                                         $this->set_var($dtime,'sec',(int)(substr($var,13,2))); 
    2022                                         if(strlen($var) > 14) 
    2023                                         { 
    2024                                                 if(substr($var,14,1) != 'Z') 
    2025                                                 { 
    2026                                                         if($this->api) 
    2027                                                         { 
     1869                        $this->set_var($dtime, 'year', (int) (substr($var, 0, 4))); 
     1870                        $this->set_var($dtime, 'month', (int) (substr($var, 4, 2))); 
     1871                        $this->set_var($dtime, 'mday', (int) (substr($var, 6, 2))); 
     1872                        if (substr($var, 8, 1) == 'T') { 
     1873                                $this->set_var($dtime, 'hour', (int) (substr($var, 9, 2))); 
     1874                                $this->set_var($dtime, 'min', (int) (substr($var, 11, 2))); 
     1875                                $this->set_var($dtime, 'sec', (int) (substr($var, 13, 2))); 
     1876                                if (strlen($var) > 14) { 
     1877                                        if (substr($var, 14, 1) != 'Z') { 
     1878                                                if ($this->api) { 
    20281879                                                                $dtime['hour'] -= $GLOBALS['phpgw_info']['users']['common']['tz_offset']; 
    2029                                                                 if($dtime['hour'] < 0) 
    2030                                                                 { 
     1880                                                        if ($dtime['hour'] < 0) { 
    20311881                                                                        $dtime['mday'] -= 1; 
    20321882                                                                        $dtime['hour'] = 24 - $dtime['hour']; 
    20331883                                                                } 
    2034                                                                 elseif($dtime['hour'] >= 24) 
    2035                                                                 { 
     1884                                                        elseif ($dtime['hour'] >= 24) { 
    20361885                                                                        $dtime['mday'] += 1; 
    20371886                                                                        $dtime['hour'] = $dtime['hour'] - 24; 
     
    20391888                                                        } 
    20401889                                                } 
    2041                                         } 
    2042                                         else 
    2043                                         { 
     1890                                } else { 
    20441891                                                /* 
    20451892                                                * The time provided by the iCal is considered local time. 
     
    20621909                                                //                                      } 
    20631910                                        } 
    2064                                 } 
    2065                                 else 
    2066                                 { 
    2067                                         $this->set_var($dtime,'hour',0); 
    2068                                         $this->set_var($dtime,'min',0); 
    2069                                         $this->set_var($dtime,'sec',0); 
    2070                                         if($this->api) 
    2071                                         { 
     1911                        } else { 
     1912                                $this->set_var($dtime, 'hour', 0); 
     1913                                $this->set_var($dtime, 'min', 0); 
     1914                                $this->set_var($dtime, 'sec', 0); 
     1915                                if ($this->api) { 
    20721916                                                $dtime['hour'] -= $GLOBALS['phpgw_info']['users']['common']['tz_offset']; 
    2073                                                 if($dtime['hour'] < 0) 
    2074                                                 { 
     1917                                        if ($dtime['hour'] < 0) { 
    20751918                                                        $dtime['mday'] -= 1; 
    20761919                                                        $dtime['hour'] = 24 - $dtime['hour']; 
    20771920                                                } 
    2078                                                 elseif($dtime['hour'] >= 24) 
    2079                                                 { 
     1921                                        elseif ($dtime['hour'] >= 24) { 
    20801922                                                        $dtime['mday'] += 1; 
    20811923                                                        $dtime['hour'] = $dtime['hour'] - 24; 
     
    20831925                                        } 
    20841926                                } 
    2085                                 $this->debug('DATETIME : '._debug_array($dtime,False)); 
     1927                        $this->debug('DATETIME : ' . _debug_array($dtime, False)); 
    20861928                                return $dtime; 
    20871929                        } 
    2088                         elseif(is_array($var)) 
    2089                         { 
    2090                                 return date('Ymd\THis\Z',mktime($var['hour'],$var['min'],$var['sec'],$var['month'],$var['mday'],$var['year'])); 
    2091                         } 
    2092                         else 
    2093                         { 
     1930                elseif (is_array($var)) { 
     1931                        return date('Ymd\THis\Z', mktime($var['hour'], $var['min'], $var['sec'], $var['month'], $var['mday'], $var['year'])); 
     1932                } else { 
    20941933                                return $var; 
    20951934                        } 
    20961935                } 
    20971936 
    2098                 function switch_encoding($var) 
    2099                 { 
    2100                         if(is_string($var)) 
    2101                         { 
    2102                                 switch($var) 
    2103                                 { 
    2104                                         case '8BIT': 
     1937        function switch_encoding($var) { 
     1938                if (is_string($var)) { 
     1939                        switch ($var) { 
     1940                                case '8BIT' : 
    21051941                                                return _8BIT; 
    21061942                                                break; 
    2107                                         case 'BASE64': 
     1943                                case 'BASE64' : 
    21081944                                                return _BASE64; 
    21091945                                                break; 
    2110                                         default: 
     1946                                default : 
    21111947                                                return OTHER; 
    21121948                                                break; 
    21131949                                } 
    21141950                        } 
    2115                         elseif(is_int($var)) 
    2116                         { 
    2117                                 switch($var) 
    2118                                 { 
    2119                                         case _8BIT: 
     1951                elseif (is_int($var)) { 
     1952                        switch ($var) { 
     1953                                case _8BIT : 
    21201954                                                return '8BIT'; 
    21211955                                                break; 
    2122                                         case _BASE64: 
     1956                                case _BASE64 : 
    21231957                                                return 'BASE64'; 
    21241958                                                break; 
    2125                                         case OTHER: 
     1959                                case OTHER : 
    21261960                                                return 'OTHER'; 
    21271961                                                break; 
    21281962                                } 
    2129                         } 
    2130                         else 
    2131                         { 
     1963                } else { 
    21321964                                return $var; 
    21331965                        } 
    21341966                } 
    21351967 
    2136                 function switch_fbtype($var) 
    2137                 { 
    2138                         if(is_string($var)) 
    2139                         { 
    2140                                 switch($var) 
    2141                                 { 
    2142                                         case 'FREE': 
     1968        function switch_fbtype($var) { 
     1969                if (is_string($var)) { 
     1970                        switch ($var) { 
     1971                                case 'FREE' : 
    21431972                                                return FREE; 
    21441973                                                break; 
    2145                                         case 'BUSY': 
     1974                                case 'BUSY' : 
    21461975                                                return BUSY; 
    21471976                                                break; 
    2148                                         case 'BUSY-UNAVAILABLE': 
     1977                                case 'BUSY-UNAVAILABLE' : 
    21491978                                                return BUSY_UNAVAILABLE; 
    21501979                                                break; 
    2151                                         case 'BUSY-TENTATIVE': 
     1980                                case 'BUSY-TENTATIVE' : 
    21521981                                                return BUSY_TENTATIVE; 
    21531982                                                break; 
    2154                                         default: 
     1983                                default : 
    21551984                                                return OTHER; 
    21561985                                                break; 
    21571986                                } 
    21581987                        } 
    2159                         elseif(is_int($var)) 
    2160                         { 
    2161                                 switch($var) 
    2162                                 { 
    2163                                         case FREE: 
     1988                elseif (is_int($var)) { 
     1989                        switch ($var) { 
     1990                                case FREE : 
    21641991                                                return 'FREE'; 
    21651992                                                break; 
    2166                                         case BUSY: 
     1993                                case BUSY : 
    21671994                                                return 'BUSY'; 
    21681995                                                break; 
    2169                                         case BUSY_UNAVAILABLE: 
     1996                                case BUSY_UNAVAILABLE : 
    21701997                                                return 'BUSY-UNAVAILABLE'; 
    21711998                                                break; 
    2172                                         case BUSY_TENTATIVE: 
     1999                                case BUSY_TENTATIVE : 
    21732000                                                return 'BUSY-TENTATIVE'; 
    21742001                                                break; 
    2175                                         default: 
     2002                                default : 
    21762003                                                return 'OTHER'; 
    21772004                                                break; 
    21782005                                } 
    2179                         } 
    2180                         else 
    2181                         { 
     2006                } else { 
    21822007                                return $var; 
    21832008                        } 
    21842009                } 
    21852010 
    2186                 function switch_freq($var) 
    2187                 { 
    2188                         if(is_string($var)) 
    2189                         { 
    2190                                 switch($var) 
    2191                                 { 
    2192                                         case 'SECONDLY': 
     2011        function switch_freq($var) { 
     2012                if (is_string($var)) { 
     2013                        switch ($var) { 
     2014                                case 'SECONDLY' : 
    21932015                                                return SECONDLY; 
    21942016                                                break; 
    2195                                         case 'MINUTELY': 
     2017                                case 'MINUTELY' : 
    21962018                                                return MINUTELY; 
    21972019                                                break; 
    2198                                         case 'HOURLY': 
     2020                                case 'HOURLY' : 
    21992021                                                return HOURLY; 
    22002022                                                break; 
    2201                                         case 'DAILY': 
     2023                                case 'DAILY' : 
    22022024                                                return DAILY; 
    22032025                                                break; 
    2204                                         case 'WEEKLY': 
     2026                                case 'WEEKLY' : 
    22052027                                                return WEEKLY; 
    22062028                                                break; 
    2207                                         case 'MONTHLY': 
     2029                                case 'MONTHLY' : 
    22082030                                                return MONTHLY; 
    22092031                                                break; 
    2210                                         case 'YEARLY': 
     2032                                case 'YEARLY' : 
    22112033                                                return YEARLY; 
    22122034                                                break; 
    22132035                                } 
    22142036                        } 
    2215                         elseif(is_int($var)) 
    2216                         { 
    2217                                 switch($var) 
    2218                                 { 
    2219                                         case SECONDLY: 
     2037                elseif (is_int($var)) { 
     2038                        switch ($var) { 
     2039                                case SECONDLY : 
    22202040                                                return 'SECONDLY'; 
    22212041                                                break; 
    2222                                         case MINUTELY: 
     2042                                case MINUTELY : 
    22232043                                                return 'MINUTELY'; 
    22242044                                                break; 
    2225                                         case HOURLY: 
     2045                                case HOURLY : 
    22262046                                                return 'HOURLY'; 
    22272047                                                break; 
    2228                                         case DAILY: 
     2048                                case DAILY : 
    22292049                                                return 'DAILY'; 
    22302050                                                break; 
    2231                                         case WEEKLY: 
     2051                                case WEEKLY : 
    22322052                                                return 'WEEKLY'; 
    22332053                                                break; 
    2234                                         case MONTHLY: 
     2054                                case MONTHLY : 
    22352055                                                return 'MONTHLY'; 
    22362056                                                break; 
    2237                                         case YEARLY: 
     2057                                case YEARLY : 
    22382058                                                return 'YEARLY'; 
    22392059                                                break; 
    22402060                                } 
    2241                         } 
    2242                         else 
    2243                         { 
     2061                } else { 
    22442062                                return $var; 
    22452063                        } 
    22462064                } 
    22472065 
    2248                 function switch_mailto($var) 
    2249                 { 
    2250                         if(is_string($var)) 
    2251                         { 
    2252                                 $var = str_replace(array("\r\n", "\n", "\r"), "", $var); 
    2253                                 if(strpos(' '.$var,':')) 
    2254                                 { 
    2255                                         $parts = explode(':',$var); 
     2066        function switch_mailto($var) { 
     2067                if (is_string($var)) { 
     2068                        $var = str_replace(array ( 
     2069                                "\r\n", 
     2070                                "\n", 
     2071                                "\r" 
     2072                        ), "", $var); 
     2073                        if (strpos(' ' . $var, ':')) { 
     2074                                $parts = explode(':', $var); 
    22562075                                        $var = $parts[1]; 
    22572076                                } 
    22582077 
    2259                                 $parts = explode('@',$var); 
     2078                        $parts = explode('@', $var); 
    22602079                                //$this->debug("Count of mailto parts : ".count($parts)); 
    2261                                 if(count($parts) == 2) 
    2262                                 { 
     2080                        if (count($parts) == 2) { 
    22632081                                        //$this->debug("Splitting ".$parts[0]." @ ".$parts[1]); 
    2264                                         $temp_address = Array(); 
     2082                                $temp_address = Array (); 
    22652083                                        $temp_address['user'] = $parts[0]; 
    22662084                                        $temp_address['host'] = $parts[1]; 
    22672085                                        return $temp_address; 
    2268                                 } 
    2269                                 else 
    2270                                 { 
     2086                        } else { 
    22712087                                        return False; 
    22722088                                } 
    22732089                        } 
    2274                         elseif(is_array($var)) 
    2275                         { 
    2276 //                              return 'MAILTO:'.$var['user'].'@'.$var['host']; 
    2277                                 return $var['user'].'@'.$var['host']; 
    2278                         } 
    2279                 } 
    2280  
    2281                 function switch_partstat($var) 
    2282                 { 
    2283                         $this->debug('PARTSTAT = '.$var); 
    2284                         if(is_string($var)) 
    2285                         { 
    2286                                 switch($var) 
    2287                                 { 
    2288                                         case 'NEEDS-ACTION': 
     2090                elseif (is_array($var)) { 
     2091                        //                              return 'MAILTO:'.$var['user'].'@'.$var['host']; 
     2092                        return $var['user'] . '@' . $var['host']; 
     2093                        } 
     2094                } 
     2095 
     2096        function switch_partstat($var) { 
     2097                $this->debug('PARTSTAT = ' . $var); 
     2098                if (is_string($var)) { 
     2099                        switch ($var) { 
     2100                                case 'NEEDS-ACTION' : 
    22892101                                                return 0; // NEEDS_ACTION; 
    22902102                                                break; 
    2291                                         case 'ACCEPTED': 
     2103                                case 'ACCEPTED' : 
    22922104                                                return 1; // ACCEPTED; 
    22932105                                                break; 
    2294                                         case 'DECLINED': 
     2106                                case 'DECLINED' : 
    22952107                                                return 2; // DECLINED; 
    22962108                                                break; 
    2297                                         case 'TENTATIVE': 
     2109                                case 'TENTATIVE' : 
    22982110                                                return 3; // TENTATIVE; 
    22992111                                                break; 
    2300                                         case 'DELEGATED': 
     2112                                case 'DELEGATED' : 
    23012113                                                return 4; // DELEGATED; 
    23022114                                                break; 
    2303                                         case 'COMPLETED': 
     2115                                case 'COMPLETED' : 
    23042116                                                return 5; // COMPLETED; 
    23052117                                                break; 
    2306                                         case 'IN-PROCESS': 
     2118                                case 'IN-PROCESS' : 
    23072119                                                return 6; // IN_PROCESS; 
    23082120                                                break; 
    2309                                         default: 
     2121                                default : 
    23102122                                                return 99; // OTHER; 
    23112123                                                break; 
    23122124                                } 
    23132125                        } 
    2314                         elseif(is_int($var)) 
    2315                         { 
    2316                                 switch((int)$var) 
    2317                                 { 
    2318                                         case 0: // NEEDS_ACTION: 
     2126                elseif (is_int($var)) { 
     2127                        switch ((int) $var) { 
     2128                                case 0 : // NEEDS_ACTION: 
    23192129                                                return 'NEEDS-ACTION'; 
    23202130                                                break; 
    2321                                         case 1: //  ACCEPTED: 
     2131                                case 1 : //  ACCEPTED: 
    23222132                                                return 'ACCEPTED'; 
    23232133                                                break; 
    2324                                         case 2: // DECLINED: 
     2134                                case 2 : // DECLINED: 
    23252135                                                return 'DECLINED'; 
    23262136                                                break; 
    2327                                         case 3: // TENTATIVE: 
     2137                                case 3 : // TENTATIVE: 
    23282138                                                return 'TENTATIVE'; 
    23292139                                                break; 
    2330                                         case 4: // DELEGATED: 
     2140                                case 4 : // DELEGATED: 
    23312141                                                return 'DELEGATED'; 
    23322142                                                break; 
    2333                                         case 5: // COMPLETED: 
     2143                                case 5 : // COMPLETED: 
    23342144                                                return 'COMPLETED'; 
    23352145                                                break; 
    2336                                         case 6: // IN_PROCESS: 
     2146                                case 6 : // IN_PROCESS: 
    23372147                                                return 'IN-PROCESS'; 
    23382148                                                break; 
    2339                                         default: 
     2149                                default : 
    23402150                                                return 'X-OTHER'; 
    23412151                                                break; 
    23422152                                } 
    2343                         } 
    2344                         else 
    2345                         { 
     2153                } else { 
    23462154                                return $var; 
    23472155                        } 
    23482156                } 
    23492157 
    2350                 function switch_range($var) 
    2351                 { 
    2352                         if(is_string($var)) 
    2353                         { 
    2354                                 switch($var) 
    2355                                 { 
    2356                                         case 'THISANDPRIOR': 
     2158        function switch_range($var) { 
     2159                if (is_string($var)) { 
     2160                        switch ($var) { 
     2161                                case 'THISANDPRIOR' : 
    23572162                                                return THISANDPRIOR; 
    23582163                                                break; 
    2359                                         case 'THISANDFUTURE': 
     2164                                case 'THISANDFUTURE' : 
    23602165                                                return THISANDFUTURE; 
    23612166                                                break; 
    23622167                                } 
    23632168                        } 
    2364                         elseif(is_int($var)) 
    2365                         { 
    2366                                 switch($var) 
    2367                                 { 
    2368                                         case THISANDPRIOR: 
     2169                elseif (is_int($var)) { 
     2170                        switch ($var) { 
     2171                                case THISANDPRIOR : 
    23692172                                                return 'THISANDPRIOR'; 
    23702173                                                break; 
    2371                                         case THISANDFUTURE: 
     2174                                case THISANDFUTURE : 
    23722175                                                return 'THISANDFUTURE'; 
    23732176                                                break; 
    23742177                                } 
    2375                         } 
    2376                         else 
    2377                         { 
     2178                } else { 
    23782179                                return $var; 
    23792180                        } 
    23802181                } 
    23812182 
    2382                 function switch_related($var) 
    2383                 { 
    2384                         if(is_string($var)) 
    2385                         { 
    2386                                 switch($var) 
    2387                                 { 
    2388                                         case 'START': 
     2183        function switch_related($var) { 
     2184                if (is_string($var)) { 
     2185                        switch ($var) { 
     2186                                case 'START' : 
    23892187                                                return START; 
    23902188                                                break; 
    2391                                         case 'END': 
     2189                                case 'END' : 
    23922190                                                return END; 
    23932191                                                break; 
    23942192                                } 
    23952193                        } 
    2396                         elseif(is_int($var)) 
    2397                         { 
    2398                                 switch($var) 
    2399                                 { 
    2400                                         case START: 
     2194                elseif (is_int($var)) { 
     2195                        switch ($var) { 
     2196                                case START : 
    24012197                                                return 'START'; 
    24022198                                                break; 
    2403                                         case END: 
     2199                                case END : 
    24042200                                                return 'END'; 
    24052201                                                break; 
    24062202                                } 
    2407                         } 
    2408                         else 
    2409                         { 
     2203                } else { 
    24102204                                return $var; 
    24112205                        } 
    24122206                } 
    24132207 
    2414                 function switch_reltype($var) 
    2415                 { 
    2416                         if(is_string($var)) 
    2417                         { 
    2418                                 switch($var) 
    2419                                 { 
    2420                                         case 'PARENT': 
     2208        function switch_reltype($var) { 
     2209                if (is_string($var)) { 
     2210                        switch ($var) { 
     2211                                case 'PARENT' : 
    24212212                                                return PARENT; 
    24222213                                                break; 
    2423                                         case 'CHILD': 
     2214                                case 'CHILD' : 
    24242215                                                return CHILD; 
    24252216                                                break; 
    2426                                         case 'SIBLING': 
     2217                                case 'SIBLING' : 
    24272218                                                return SIBLING; 
    24282219                                                break; 
    24292220                                } 
    24302221                        } 
    2431                         elseif(is_int($var)) 
    2432                         { 
    2433                                 switch($var) 
    2434                                 { 
    2435                                         case PARENT: 
     2222                elseif (is_int($var)) { 
     2223                        switch ($var) { 
     2224                                case PARENT : 
    24362225                                                return 'PARENT'; 
    24372226                                                break; 
    2438                                         case CHILD: 
     2227                                case CHILD : 
    24392228                                                return 'CHILD'; 
    24402229                                                break; 
    2441                                         case SIBLING: 
     2230                                case SIBLING : 
    24422231                                                return 'SIBLING'; 
    24432232                                                break; 
    24442233                                } 
    2445                         } 
    2446                         else 
    2447                         { 
     2234                } else { 
     2235                        return $var; 
     2236                        } 
     2237                } 
     2238 
     2239        function switch_role($var) { 
     2240                if (is_string($var)) { 
     2241                        switch ($var) { 
     2242                                case 'NONE' : 
     2243                                                return NONE; 
     2244                                                break; 
     2245                                case 'CHAIR' : 
     2246                                                return CHAIR; 
     2247                                                break; 
     2248                                case 'REQ-PARTICIPANT' : 
     2249                                                return REQ_PARTICIPANT; 
     2250                                                break; 
     2251                                case 'OPT-PARTICIPANT' : 
     2252                                                return OPT_PARTICIPANT; 
     2253                                                break; 
     2254                                case 'NON-PARTICIPANT' : 
     2255                                                return NON_PARTICIPANT; 
     2256                                                break; 
     2257                                } 
     2258                        } 
     2259                elseif (is_int($var)) { 
     2260                        switch ($var) { 
     2261                                case NONE : 
     2262                                                return 'NONE'; 
     2263                                                break; 
     2264                                case CHAIR : 
     2265                                                return 'CHAIR'; 
     2266                                                break; 
     2267                                case REQ_PARTICIPANT : 
     2268                                                return 'REQ-PARTICIPANT'; 
     2269                                                break; 
     2270                                case OPT_PARTICIPANT : 
     2271                                                return 'OPT-PARTICIPANT'; 
     2272                                                break; 
     2273                                case NON_PARTICIPANT : 
     2274                                                return 'NON-PARTICIPANT'; 
     2275                                                break; 
     2276                                } 
     2277                } else { 
    24482278                                return $var; 
    24492279                        } 
    24502280                } 
    24512281 
    2452                 function switch_role($var) 
    2453                 { 
    2454                         if(is_string($var)) 
    2455                         { 
    2456                                 switch($var) 
    2457                                 { 
    2458                                         case 'NONE': 
    2459                                                 return NONE; 
    2460                                                 break; 
    2461                                         case 'CHAIR': 
    2462                                                 return CHAIR; 
    2463                                                 break; 
    2464                                         case 'REQ-PARTICIPANT': 
    2465                                                 return REQ_PARTICIPANT; 
    2466                                                 break; 
    2467                                         case 'OPT-PARTICIPANT': 
    2468                                                 return OPT_PARTICIPANT; 
    2469                                                 break; 
    2470                                         case 'NON-PARTICIPANT': 
    2471                                                 return NON_PARTICIPANT; 
    2472                                                 break; 
    2473                                 } 
    2474                         } 
    2475                         elseif(is_int($var)) 
    2476                         { 
    2477                                 switch($var) 
    2478                                 { 
    2479                                         case NONE: 
    2480                                                 return 'NONE'; 
    2481                                                 break; 
    2482                                         case CHAIR: 
    2483                                                 return 'CHAIR'; 
    2484                                                 break; 
    2485                                         case REQ_PARTICIPANT: 
    2486                                                 return 'REQ-PARTICIPANT'; 
    2487                                                 break; 
    2488                                         case OPT_PARTICIPANT: 
    2489                                                 return 'OPT-PARTICIPANT'; 
    2490                                                 break; 
    2491                                         case NON_PARTICIPANT: 
    2492                                                 return 'NON-PARTICIPANT'; 
    2493                                                 break; 
    2494                                 } 
    2495                         } 
    2496                         else 
    2497                         { 
     2282        function switch_rsvp($var) { 
     2283                if (is_string($var)) { 
     2284                        if ($var == 'TRUE') { 
     2285                                        return 1; 
     2286                                } 
     2287                        elseif ($var == 'FALSE') { 
     2288                                        return 0; 
     2289                                } 
     2290                        } 
     2291                elseif (is_int($var) || $var == False) { 
     2292                        if ($var == 1) { 
     2293                                        return 'TRUE'; 
     2294                                } 
     2295                        elseif ($var == 0) { 
     2296                                        return 'FALSE'; 
     2297                                } 
     2298                } else { 
    24982299                                return $var; 
    24992300                        } 
    25002301                } 
    25012302 
    2502                 function switch_rsvp($var) 
    2503                 { 
    2504                         if(is_string($var)) 
    2505                         { 
    2506                                 if($var == 'TRUE') 
    2507                                 { 
    2508                                         return 1; 
    2509                                 } 
    2510                                 elseif($var == 'FALSE') 
    2511                                 { 
    2512                                         return 0; 
    2513                                 } 
    2514                         } 
    2515                         elseif(is_int($var) || $var == False) 
    2516                         { 
    2517                                 if($var == 1) 
    2518                                 { 
    2519                                         return 'TRUE'; 
    2520                                 } 
    2521                                 elseif($var == 0) 
    2522                                 { 
    2523                                         return 'FALSE'; 
    2524                                 } 
    2525                         } 
    2526                         else 
    2527                         { 
    2528                                 return $var; 
    2529                         } 
    2530                 } 
    2531  
    2532                 function switch_transp($var) 
    2533                 { 
    2534                         if(is_string($var)) 
    2535                         { 
    2536                                 switch($var) 
    2537                                 { 
    2538                                         case 'TRANSPARENT': 
     2303        function switch_transp($var) { 
     2304                if (is_string($var)) { 
     2305                        switch ($var) { 
     2306                                case 'TRANSPARENT' : 
    25392307                                                return TRANSPARENT; 
    25402308                                                break; 
    2541                                         case 'OPAQUE': 
     2309                                case 'OPAQUE' : 
    25422310                                                return OPAQUE; 
    25432311                                                break; 
    25442312                                } 
    25452313                        } 
    2546                         elseif(is_int($var)) 
    2547                         { 
    2548                                 switch($var) 
    2549                                 { 
    2550                                         case TRANSPARENT: 
     2314                elseif (is_int($var)) { 
     2315                        switch ($var) { 
     2316                                case TRANSPARENT : 
    25512317                                                return 'TRANSPARENT'; 
    25522318                                                break; 
    2553                                         case OPAQUE: 
     2319                                case OPAQUE : 
    25542320                                                return 'OPAQUE'; 
    25552321                                                break; 
    25562322                                } 
    2557                         } 
    2558                         else 
    2559                         { 
     2323                } else { 
    25602324                                return $var; 
    25612325                        } 
     
    25662330                 */ 
    25672331 
    2568                 function parse($ical_text) 
    2569                 { 
     2332        function parse($ical_text) { 
    25702333                        $begin_regexp = '^'; 
    25712334                        $semi_colon_regexp = '[\;\:]'; 
     
    25732336                        $catch_all_regexp = '(.*)'; 
    25742337                        $end_regexp = '$'; 
    2575                         $property_regexp = $begin_regexp.'([A-Z\-]*)'.$semi_colon_regexp.$catch_all_regexp.$end_regexp; 
    2576                         $param_regexp = $begin_regexp.$catch_all_regexp.':'.$catch_all_regexp.$end_regexp; 
     2338                $property_regexp = $begin_regexp . '([A-Z\-]*)' . $semi_colon_regexp . $catch_all_regexp . $end_regexp; 
     2339                $param_regexp = $begin_regexp . $catch_all_regexp . ':' . $catch_all_regexp . $end_regexp; 
    25772340 
    25782341                        $mode = 'none'; 
    25792342                        $text = $this->read_line_unfold($ical_text); 
    2580                         while($text) 
    2581                         { 
    2582 //                              if(strlen($ical_text[$i]) > 75) 
    2583 //                              { 
    2584 //                                      continue; 
    2585 //                              } 
    2586  
    2587                                 ereg($property_regexp,$text,$temp); 
     2343                while ($text) { 
     2344                        //                              if(strlen($ical_text[$i]) > 75) 
     2345                        //                              { 
     2346                        //                                      continue; 
     2347                        //                              } 
     2348 
     2349                        ereg($property_regexp, $text, $temp); 
    25882350                                //$this->debug ('Majortype dump: '._debug_array($temp, false) ); 
    2589                                 $majortype = str_replace('-','_',strtolower($temp[1])); 
     2351                        $majortype = str_replace('-', '_', strtolower($temp[1])); 
    25902352                                $value = chop($temp[2]); 
    2591  
    2592                                 if($mode != 'none' && ($majortype != 'begin' && $majortype != 'end')) 
    2593                                 { 
     2353                        if ($mode != 'none' && ($majortype != 'begin' && $majortype != 'end')) { 
    25942354                                        //$this->debug('PARSE:MAJORTYPE : '.$majortype); 
    2595                                         if(isset($this->property[$majortype])) 
    2596                                         { 
    2597                                                 $state = @$this->property[$majortype]["$mode"]['state']; 
    2598                                                 $type = @$this->property[$majortype]['type']; 
    2599                                                 $multiples = @$this->property[$majortype]["$mode"]['multiples']; 
    2600                                                 $do_to_text = @$this->property[$majortype]['to_text']; 
    2601                                         } 
    2602                                         elseif(substr($majortype,0,2) == 'x_') 
    2603                                         { 
     2355                                if (isset ($this->property[$majortype])) { 
     2356                                        $state = @ $this->property[$majortype]["$mode"]['state']; 
     2357                                        $type = @ $this->property[$majortype]['type']; 
     2358                                        $multiples = @ $this->property[$majortype]["$mode"]['multiples']; 
     2359                                        $do_to_text = @ $this->property[$majortype]['to_text']; 
     2360                                        } 
     2361                                elseif (substr($majortype, 0, 2) == 'x_') { 
    26042362                                                $state = 'optional'; 
    26052363                                                $type = 'xtype'; 
    26062364                                                $multiples = True; 
    26072365                                                $do_to_test = True; 
    2608                                         } 
    2609                                         else 
    2610                                         { 
     2366                                } else { 
    26112367                                                $state = ''; 
    26122368                                        } 
    2613                                 } 
    2614                                 else 
    2615                                 { 
     2369                        } else { 
    26162370                                        $state = 'required'; 
    26172371                                } 
    26182372 
    2619                                 if($majortype == 'duration') 
    2620                                 { 
     2373                        if ($majortype == 'duration') { 
    26212374                                        // Unset dur var 
    2622                                         unset($dur); 
     2375                                unset ($dur); 
    26232376 
    26242377                                        // Split DURATION 
    2625                                         list($_f_['day_raw'], $_f_['time_raw']) = split('T', substr($value, 1, strlen($value)-1)); 
     2378                                list ($_f_['day_raw'], $_f_['time_raw']) = split('T', substr($value, 1, strlen($value) - 1)); 
    26262379 
    26272380                                        /* Datecode */ 
    2628                                         if(isset($_f_['day_raw']) OR $_f_['day_raw']) 
    2629                                         { 
     2381                                if (isset ($_f_['day_raw']) OR $_f_['day_raw']) { 
    26302382                                                // Days 
    2631 //                                              if(ereg('D', $_f_['day_raw'])) 
    2632                                                 if(strstr($_f_['day_raw'],'D')) 
    2633                                                 { 
     2383                                        //                                              if(ereg('D', $_f_['day_raw'])) 
     2384                                        if (strstr($_f_['day_raw'], 'D')) { 
    26342385                                                        $dur['days'] = eregi_replace("([0-9]+)D(.*)", "\\1", $_f_['day_raw']); 
    26352386                                                } 
    26362387 
    26372388                                                // Weeks 
    2638 //                                              if(ereg("W", $_f_["day_raw"])) 
    2639                                                 if(strstr($_f_['day_raw'],'W')) 
    2640                                                 { 
     2389                                        //                                              if(ereg("W", $_f_["day_raw"])) 
     2390                                        if (strstr($_f_['day_raw'], 'W')) { 
    26412391                                                        $dur['weeks'] = eregi_replace("([^|.*]+D)?([0-9]+)W", "\\2", $_f_['day_raw']); 
    26422392                                                } 
     
    26442394 
    26452395                                        /* Timecode */ 
    2646                                         if(isset($_f_['time_raw']) OR $_f_['time_raw']) 
    2647                                         { 
     2396                                if (isset ($_f_['time_raw']) OR $_f_['time_raw']) { 
    26482397                                                // Hours 
    2649 //                                              if(ereg("H", $_f_["time_raw"])) 
    2650                                                 if(strstr($_f_['time_raw'],'H')) 
    2651                                                 { 
     2398                                        //                                              if(ereg("H", $_f_["time_raw"])) 
     2399                                        if (strstr($_f_['time_raw'], 'H')) { 
    26522400                                                        $dur['hours'] = eregi_replace("([0-9]+)H(.*)", "\\1", $_f_['time_raw']); 
    26532401                                                } 
     
    26552403                                                // Minutes 
    26562404                                                /* If you find better, contact me very quickly :) */ 
    2657 //                                              if(ereg("M", $_f_["time_raw"])) 
    2658                                                 if(strstr($_f_['time_raw'],'M')) 
    2659                                                 { 
     2405                                        //                                              if(ereg("M", $_f_["time_raw"])) 
     2406                                        if (strstr($_f_['time_raw'], 'M')) { 
    26602407                                                        $dur['minutes'] = eregi_replace("([^|.*]+H)?([0-9]+)M(.*)", "\\2", $_f_['time_raw']); 
    26612408                                                } 
     
    26632410                                                // Seconds 
    26642411                                                /* Same comment :) */ 
    2665 //                                              if(ereg("S", $_f_["time_raw"]) ) 
    2666                                                 if(strstr($_f_['time_raw'],'S')) 
    2667                                                 { 
     2412                                        //                                              if(ereg("S", $_f_["time_raw"]) ) 
     2413                                        if (strstr($_f_['time_raw'], 'S')) { 
    26682414                                                        $dur['seconds'] = eregi_replace("([^|.*]+M)?([0-9]+)S(.*)", "\\2", $_f_['time_raw']); 
    26692415                                                } 
    26702416                                        } 
    26712417 
    2672                                         $dur['raw'] = Array( 
     2418                                $dur['raw'] = Array ( 
    26732419                                                'timecode' => $_f_['time_raw'], 
    26742420                                                'datecode' => $_f_['day_raw'], 
     
    26792425                                } 
    26802426 
    2681                                 if($majortype == 'begin') 
    2682                                 { 
     2427                        if ($majortype == 'begin') { 
    26832428                                        $tmode = $mode; 
    26842429                                        $mode = strtolower($value); 
    2685                                         switch(strtolower($value)) 
    2686                                         { 
    2687                                                 case 'daylight': 
    2688                                                 case 'standard': 
    2689                                                         $t_event = Array(); 
     2430                                switch (strtolower($value)) { 
     2431                                        case 'daylight' : 
     2432                                        case 'standard' : 
     2433                                                $t_event = Array (); 
    26902434                                                        $t_event = $event; 
    2691                                                         $event = Array(); 
     2435                                                $event = Array (); 
    26922436                                                        break; 
    2693                                                 case 'valarm': 
    2694                                                         if($tmode == 'vevent' || $tmode == 'vtodo') 
    2695                                                         { 
     2437                                        case 'valarm' : 
     2438                                                if ($tmode == 'vevent' || $tmode == 'vtodo') { 
    26962439                                                                $t_event = $event; 
    2697                                                                 unset($event); 
    2698                                                                 $event = Array(); 
    2699                                                         } 
    2700                                                         else 
    2701                                                         { 
     2440                                                        unset ($event); 
     2441                                                        $event = Array (); 
     2442                                                } else { 
    27022443                                                                $mode = $tmode; 
    27032444                                                        } 
    27042445                                                        break; 
    2705                                                 case 'vcalendar': 
     2446                                        case 'vcalendar' : 
    27062447                                                        $ical = $this->new_ical(); 
    27072448                                                        break; 
    2708                                                 case 'vevent': 
    2709                                                 case 'vfreebusy': 
    2710                                                 case 'vjournal': 
    2711                                                 case 'vtimezone': 
    2712                                                 case 'vtodo': 
    2713                                                         $event = Array(); 
     2449                                        case 'vevent' : 
     2450                                        case 'vfreebusy' : 
     2451                                        case 'vjournal' : 
     2452                                        case 'vtimezone' : 
     2453                                        case 'vtodo' : 
     2454                                                $event = Array (); 
    27142455                                                        break; 
    27152456                                        } 
    27162457                                        $event['type'] = strtolower($value); 
    27172458                                } 
    2718                                 elseif($majortype == 'end') 
    2719                                 { 
     2459                        elseif ($majortype == 'end') { 
    27202460                                        $mode = 'none'; 
    2721                                         switch(strtolower($value)) 
    2722                                         { 
    2723                                                 case 'daylight': 
    2724                                                 case 'standard': 
     2461                                switch (strtolower($value)) { 
     2462                                        case 'daylight' : 
     2463                                        case 'standard' : 
    27252464                                                        $tzdata[] = $event; 
    2726                                                         unset($event); 
     2465                                                unset ($event); 
    27272466                                                        $event = $t_event; 
    2728                                                         unset($t_event); 
     2467                                                unset ($t_event); 
    27292468                                                        $mode = 'vtimezone'; 
    27302469                                                        break; 
    2731                                                 case 'valarm': 
     2470                                        case 'valarm' : 
    27322471                                                        $alarm[] = $event; 
    2733                                                         unset($event); 
     2472                                                unset ($event); 
    27342473                                                        $event = $t_event; 
    2735                                                         unset($t_event); 
     2474                                                unset ($t_event); 
    27362475                                                        $mode = $tmode; 
    27372476                                                        break; 
    2738                                                 case 'vevent': 
    2739                                                         if(!empty($alarm)) 
    2740                                                         { 
     2477                                        case 'vevent' : 
     2478                                                if (!empty ($alarm)) { 
    27412479                                                                $event['alarm'] = $alarm; 
    2742                                                                 unset($alarm); 
     2480                                                        unset ($alarm); 
    27432481                                                        } 
    27442482                                                        $this->event[] = $event; 
    2745                                                         unset($event); 
     2483                                                unset ($event); 
    27462484                                                        break; 
    2747                                                 case 'vfreebusy': 
     2485                                        case 'vfreebusy' : 
    27482486                                                        $this->freebusy[] = $event; 
    2749                                                         unset($event); 
     2487                                                unset ($event); 
    27502488                                                        break; 
    2751                                                 case 'vjournal': 
     2489                                        case 'vjournal' : 
    27522490                                                        $this->journal[] = $event; 
    2753                                                         unset($event); 
     2491                                                unset ($event); 
    27542492                                                        break; 
    2755                                                 case 'vtimezone': 
    2756                                                         if(!empty($tzdata)) 
    2757                                                         { 
     2493                                        case 'vtimezone' : 
     2494                                                if (!empty ($tzdata)) { 
    27582495                                                                $event['tzdata'] = $tzdata; 
    2759                                                                 unset($tzdata); 
     2496                                                        unset ($tzdata); 
    27602497                                                        } 
    27612498                                                        $this->timezone[] = $event; 
    2762                                                         unset($event); 
     2499                                                unset ($event); 
    27632500                                                        break; 
    2764                                                 case 'vtodo': 
    2765                                                         if(!empty($alarm)) 
    2766                                                         { 
     2501                                        case 'vtodo' : 
     2502                                                if (!empty ($alarm)) { 
    27672503                                                                $event['alarm'] = $alarm; 
    2768                                                                 unset($alarm); 
     2504                                                        unset ($alarm); 
    27692505                                                        } 
    27702506                                                        $this->todo[] = $event['alarm']; 
    2771                                                         unset($event); 
     2507                                                unset ($event); 
    27722508                                                        break; 
    2773                                                 case 'vcalendar': 
     2509                                        case 'vcalendar' : 
    27742510                                                        $this->ical = $ical; 
    27752511                                                        $this->ical['event'] = $this->event; 
     
    27812517                                        } 
    27822518                                } 
    2783                                 elseif($majortype == 'prodid' || $majortype == 'version' || $majortype == 'method' || $majortype == 'calscale') 
    2784                                 { 
    2785                                         $this->parse_parameters($ical,$majortype,$this->from_text($value)); 
    2786                                 } 
    2787                                 elseif($state == 'optional' || $state == 'required') 
    2788                                 { 
     2519                        elseif ($majortype == 'prodid' || $majortype == 'version' || $majortype == 'method' || $majortype == 'calscale') { 
     2520                                $this->parse_parameters($ical, $majortype, $this->from_text($value)); 
     2521                                } 
     2522                        elseif ($state == 'optional' || $state == 'required') { 
    27892523                                        //$this->debug('Mode : '.$mode.' Majortype : '.$majortype . ' Type : '.$type); 
    2790                                         if($do_to_text) 
    2791                                         { 
     2524                                if ($do_to_text) { 
    27922525                                                $value = $this->from_text($value); 
    27932526                                        } 
    2794                                         switch($type) 
    2795                                         { 
    2796                                                 case 'text': 
    2797                                                         $this->parse_parameters($event,$majortype,$value); 
    2798                                                         break; 
    2799                                                 case 'recur': 
    2800                                                 case 'date-time': 
    2801                                                 case 'cal-address': 
    2802                                                         $this->parse_value($event,$majortype,$value,$mode); 
    2803                                                         break; 
    2804                                                 case 'integer': 
    2805                                                         if($multiples) 
    2806                                                         { 
    2807                                                                 $event[$majortype][] = (int)$value; 
    2808                                                         } 
    2809                                                         else 
    2810                                                         { 
    2811                                                                 $this->set_var($event,$majortype,(int)$value); 
    2812                                                         } 
    2813                                                         break; 
    2814                                                 case 'float': 
    2815                                                         $event->$majortype = new class_geo; 
    2816                                                         $this->parse_geo($event->$majortype,$value); 
    2817                                                         break; 
    2818                                                 case 'utc-offset': 
    2819                                                         $this->set_var($event,$majortype,(int)$value); 
    2820                                                         break; 
    2821                                                 case 'uri': 
    2822                                                         $new_var = Array(); 
    2823                                                         $this->parse_parameters($new_var,$majortype,$value); 
    2824                                                         if($multiples) 
    2825                                                         { 
    2826                                                                 switch($mode) 
    2827                                                                 { 
    2828                                                                         case 'valarm': 
     2527                                switch ($type) { 
     2528                                        case 'text' : 
     2529                                                $this->parse_parameters($event, $majortype, $value); 
     2530                                                break; 
     2531                                        case 'recur' : 
     2532                                        case 'date-time' : 
     2533                                        case 'cal-address' : 
     2534                                                $this->parse_value($event, $majortype, $value, $mode); 
     2535                                                break; 
     2536                                        case 'integer' : 
     2537                                                if ($multiples) { 
     2538                                                        $event[$majortype][] = (int) $value; 
     2539                                                } else { 
     2540                                                        $this->set_var($event, $majortype, (int) $value); 
     2541                                                } 
     2542                                                break; 
     2543                                        case 'float' : 
     2544                                                $event-> $majortype = new class_geo; 
     2545                                                $this->parse_geo($event-> $majortype, $value); 
     2546                                                break; 
     2547                                        case 'utc-offset' : 
     2548                                                $this->set_var($event, $majortype, (int) $value); 
     2549                                                break; 
     2550                                        case 'uri' : 
     2551                                                $new_var = Array (); 
     2552                                                $this->parse_parameters($new_var, $majortype, $value); 
     2553                                                if ($multiples) { 
     2554                                                        switch ($mode) { 
     2555                                                                case 'valarm' : 
    28292556                                                                                $alarm['attach'][] = $new_var; 
    28302557                                                                                break; 
    2831                                                                         default: 
     2558                                                                default : 
    28322559                                                                                $event[$majortype][] = $new_var; 
    28332560                                                                                break; 
    28342561                                                                } 
    2835                                                         } 
    2836                                                         else 
    2837                                                         { 
     2562                                                } else { 
    28382563                                                                $event[$majortype] = $new_var; 
    28392564                                                        } 
    2840                                                         unset($new_var); 
     2565                                                unset ($new_var); 
    28412566                                                        break; 
    2842                                                 case 'xtype': 
    2843                                                         $this->parse_xtype($event,$majortype,$value); 
     2567                                        case 'xtype' : 
     2568                                                $this->parse_xtype($event, $majortype, $value); 
    28442569                                                        break; 
    28452570                                        } 
     
    28502575                } 
    28512576 
    2852  
    2853                 function switch_to_phpgw_status($partstat) 
    2854                 { 
    2855                         switch($partstat) 
    2856                         { 
    2857                                 case 0: 
     2577        function switch_to_phpgw_status($partstat) { 
     2578                switch ($partstat) { 
     2579                        case 0 : 
    28582580                                        return 'U'; 
    28592581                                        break; 
    2860                                 case 1: 
     2582                        case 1 : 
    28612583                                        return 'A'; 
    28622584                                        break; 
    2863                                 case 2: 
     2585                        case 2 : 
    28642586                                        return 'R'; 
    28652587                                        break; 
    2866                                 case 3: 
     2588                        case 3 : 
    28672589                                        return 'T'; 
    28682590                                        break; 
    2869                                 default: 
     2591                        default : 
    28702592                                        return 'U'; 
    28712593                                        break; 
     
    28732595                } 
    28742596 
    2875                 function switch_phpgw_status($status) 
    2876                 { 
    2877                         switch($status) 
    2878                         { 
    2879                                 case 'U': 
     2597        function switch_phpgw_status($status) { 
     2598                switch ($status) { 
     2599                        case 'U' : 
    28802600                                        return 0; 
    28812601                                        break; 
    2882                                 case 'A': 
     2602                        case 'A' : 
    28832603                                        return 1; 
    28842604                                        break; 
    2885                                 case 'R': 
     2605                        case 'R' : 
    28862606                                        return 2; 
    28872607                                        break; 
    2888                                 case 'T': 
     2608                        case 'T' : 
    28892609                                        return 3; 
    28902610                                        break; 
     
    28922612                } 
    28932613 
    2894                 function is_owner($part_record) 
    2895                 { 
    2896                         if(($part_record['user'].'@'.$part_record['host'] == $GLOBALS['phpgw_info']['user']['preferences']['email']['address']) || 
    2897                                 ($part_record['cn'] == $GLOBALS['phpgw_info']['user']['account_lid'])) 
    2898                         { 
     2614        function is_owner($part_record) { 
     2615                if (($part_record['user'] . '@' . $part_record['host'] == $GLOBALS['phpgw_info']['user']['preferences']['email']['address']) || ($part_record['cn'] == $GLOBALS['phpgw_info']['user']['account_lid']) || 
     2616                        ($part_record['mailto']['user'] == $GLOBALS['phpgw_info']['user']['account_lid'])) { 
    28992617                                return True; 
    2900                         } 
    2901                         else 
    2902                         { 
     2618                } else { 
    29032619                                return False; 
    29042620                        } 
    29052621                } 
    29062622 
    2907                 function check_owner(&$event,$ical,$so_event) 
    2908                 { 
    2909                         if(!isset($event['participant'][$GLOBALS['phpgw_info']['user']['account_id']])) 
    2910                         { 
    2911                                 if(isset($ical['organizer'])) 
    2912                                 { 
    2913                                         if($this->is_owner($ical['organizer'])) 
    2914                                         { 
    2915                                                 $so_event->add_attribute('owner',$GLOBALS['phpgw_info']['user']['account_id']); 
    2916                                                 $so_event->add_attribute('participants',$this->switch_to_phpgw_status($ical['organizer']['partstat']),$GLOBALS['phpgw_info']['user']['account_id']); 
    2917                                         } 
    2918                                 } 
    2919                                 elseif(isset($ical['attendee'])) 
    2920                                 { 
     2623        function check_owner(& $event, $ical, $so_event) { 
     2624                if (!isset ($event['participant'][$GLOBALS['phpgw_info']['user']['account_id']])) { 
     2625                        if (isset ($ical['organizer'])) { 
     2626                                if ($this->is_owner($ical['organizer'])) { 
     2627                                        $so_event->add_attribute('owner', $GLOBALS['phpgw_info']['user']['account_id']); 
     2628                                        $so_event->add_attribute('participants', $this->switch_to_phpgw_status($ical['organizer']['partstat']), $GLOBALS['phpgw_info']['user']['account_id']); 
     2629                                        } 
     2630                                } 
     2631                        elseif (isset ($ical['attendee'])) { 
    29212632                                        $attendee_count = count($ical['attendee']); 
    29222633 
    2923                                         for($j=0;$j<$attendee_count;$j++) 
    2924                                         { 
    2925                                                 if($this->is_owner($ical['attendee'][$j])) 
    2926                                                 { 
    2927                                                         $so_event->add_attribute('participants',$this->switch_to_phpgw_status($ical['attendee'][$j]['partstat']),(int)$GLOBALS['phpgw_info']['user']['account_id']); 
    2928                                                 } 
    2929                                         } 
    2930                                 } 
    2931                                 else 
    2932                                 { 
    2933                                         $so_event->add_attribute('owner',$GLOBALS['phpgw_info']['user']['account_id']); 
    2934                                         $so_event->add_attribute('participants','A',$GLOBALS['phpgw_info']['user']['account_id']); 
    2935                                 } 
    2936                         } 
    2937                 } 
    2938  
    2939                 function import_file() 
    2940                 { 
    2941                         if($_FILES['uploadedfile']['tmp_name'] == 'none' || $_FILES['uploadedfile']['tmp_name'] == '') 
    2942                         { 
    2943                                 Header('Location: ' . $GLOBALS['phpgw']->link('/index.php', 
    2944                                                 Array( 
     2634                                for ($j = 0; $j < $attendee_count; $j++) { 
     2635                                        if ($this->is_owner($ical['attendee'][$j])) { 
     2636                                                $so_event->add_attribute('participants', $this->switch_to_phpgw_status($ical['attendee'][$j]['partstat']), (int) $GLOBALS['phpgw_info']['user']['account_id']); 
     2637                                                } 
     2638                                        } 
     2639                        } else { 
     2640                                $so_event->add_attribute('owner', $GLOBALS['phpgw_info']['user']['account_id']); 
     2641                                $so_event->add_attribute('participants', 'A', $GLOBALS['phpgw_info']['user']['account_id']); 
     2642                                } 
     2643                        } 
     2644                } 
     2645 
     2646        function import_file() { 
     2647                if ($_FILES['uploadedfile']['tmp_name'] == 'none' || $_FILES['uploadedfile']['tmp_name'] == '') { 
     2648                        Header('Location: ' . $GLOBALS['phpgw']->link('/index.php', Array ( 
    29452649                                                        'menuaction'    => 'calendar.uiicalendar.import', 
    29462650                                                        'action'        => 'GetFile' 
    2947                                                 ) 
    2948                                         ) 
    2949                                 ); 
     2651                        ))); 
    29502652                                $GLOBALS['phpwg']->common->phpgw_exit(); 
    29512653                        } 
    29522654                        $uploaddir = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; 
    29532655 
    2954                         srand((double)microtime()*1000000); 
    2955                         $random_number = rand(100000000,999999999); 
    2956                         $newfilename = md5($_FILES['uploadedfile']['tmp_name'].", ".$uploadedfile_name.", " 
    2957                                 . time() . getenv("REMOTE_ADDR") . $random_number ); 
     2656                srand((double) microtime() * 1000000); 
     2657                $random_number = rand(100000000, 999999999); 
     2658                $newfilename = md5($_FILES['uploadedfile']['tmp_name'] . ", " . $uploadedfile_name . ", " . time() . getenv("REMOTE_ADDR") . $random_number); 
    29582659 
    29592660                        $filename = $uploaddir . $newfilename; 
    29602661 
    29612662                        move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $filename); 
    2962 //                      $ftp = fopen($uploaddir . $newfilename . '.info','wb'); 
    2963 //                      fputs($ftp,$uploadedfile_type."\n".$uploadedfile_name."\n"); 
    2964 //                      fclose($ftp); 
     2663                //                      $ftp = fopen($uploaddir . $newfilename . '.info','wb'); 
     2664                //                      fputs($ftp,$uploadedfile_type."\n".$uploadedfile_name."\n"); 
     2665                //                      fclose($ftp); 
    29652666                        return $filename; 
    29662667                } 
    29672668 
    2968                 function import($mime_msg='', $from_ajax = false) 
    2969                 { 
    2970                         if($_FILES['uploadedfile']['tmp_name'] != 'none' && $_FILES['uploadedfile']['tmp_name'] != '') 
    2971                         { 
     2669        function safeBitCheck($number, $comparison) { 
     2670                $binNumber = base_convert($number, 10, 2); 
     2671                $binComparison = strrev(base_convert($comparison, 10, 2)); 
     2672                $str = strlen($binNumber); 
     2673 
     2674                if (($str <= strlen($binComparison)) && ($binComparison { 
     2675                        $str -1 } 
     2676                === "1")) 
     2677                return '1'; 
     2678else 
     2679        return '0'; 
     2680} 
     2681 
     2682function import($mime_msg = '', $from_ajax = false, $importAccount = false) { 
     2683        /* 
     2684         * Caso seja uma importação para conta compartilhada carrega as acls do usuario 
     2685         */ 
     2686        if ($importAccount != false) { 
     2687                $colunas = array ( 
     2688                        'acl_appname', 
     2689                        'acl_location', 
     2690                        'acl_account', 
     2691                        'acl_rights' 
     2692                ); 
     2693                $where = array ( 
     2694                        'acl_appname' => 'calendar', 
     2695                        'acl_account' => $importAccount['uidnumber'], 
     2696                        'acl_location' => $GLOBALS['phpgw_info']['user']['account_id'] 
     2697                ); 
     2698                $db = $GLOBALS['phpgw']->db; 
     2699                $db->select('phpgw_acl', $colunas, $where, null, null); 
     2700                $row = $db->row(true); 
     2701 
     2702                if (!$this->safeBitCheck(2, $row['acl_rights'])) //Se o usuario não tem permisão de adicionar eventos 
     2703                        return 'You do not have permission to add events'; 
     2704        } 
     2705 
     2706        if ($_FILES['uploadedfile']['tmp_name'] != 'none' && $_FILES['uploadedfile']['tmp_name'] != '') { 
    29722707                                $filename = $this->import_file(); 
    2973                                 $fp=fopen($filename,'rt'); 
    2974                                 $mime_msg = explode("\n",fread($fp, filesize($filename))); 
     2708                $fp = fopen($filename, 'rt'); 
     2709                $mime_msg = explode("\n", fread($fp, filesize($filename))); 
    29752710                                fclose($fp); 
    29762711                                unlink($filename); 
    29772712                        } 
    2978                         elseif(!$mime_msg) 
    2979                         { 
    2980                                 Header('Location: ' . $GLOBALS['phpgw']->link('/index.php', 
    2981                                                 Array( 
     2713        elseif (!$mime_msg) { 
     2714                Header('Location: ' . $GLOBALS['phpgw']->link('/index.php', Array ( 
    29822715                                                        'menuaction'    => 'calendar.uiicalendar.import', 
    29832716                                                        'action'        => 'GetFile' 
    2984                                                 ) 
    2985                                         ) 
    2986                                 ); 
     2717                ))); 
    29872718                                $GLOBALS['phpwg']->common->phpgw_exit(); 
    29882719                        } 
    29892720 
    2990                         if(!is_object($GLOBALS['uicalendar'])) 
    2991                         { 
    2992                                 $so_event = createobject('calendar.socalendar', 
    2993                                         Array( 
     2721        if (!is_object($GLOBALS['uicalendar'])) { 
     2722                $so_event = createobject('calendar.socalendar', Array ( 
    29942723                                                'owner' => 0, 
    29952724                                                'filter'        => '', 
    29962725                                                'category'      => '' 
    2997                                         ) 
    2998                                 ); 
    2999                         } 
    3000                         else 
    3001                         { 
     2726                )); 
     2727        } else { 
    30022728                                $so_event = $GLOBALS['uicalendar']->bo->so; 
    30032729                        } 
    30042730 
    3005                         $datetime_vars = Array( 
     2731        $datetime_vars = Array ( 
    30062732                                'start' => 'dtstart', 
    30072733                                'end'   => 'dtend', 
     
    30102736                        ); 
    30112737 
    3012                         $date_array = Array( 
     2738        $date_array = Array ( 
    30132739                                'Y'     => 'year', 
    30142740                                'm'     => 'month', 
     
    30202746 
    30212747                        // time limit should be controlled elsewhere 
    3022                         @set_time_limit(0); 
    3023  
     2748        @ set_time_limit(0); 
    30242749                        $GLOBALS['phpgw_info']['user']['preferences'] = $GLOBALS['phpgw']->preferences->create_email_preferences(); 
    30252750                        $users_email = $GLOBALS['phpgw_info']['user']['preferences']['email']['address']; 
    30262751                        $cats = CreateObject('phpgwapi.categories'); 
    30272752                        $ical = $this->parse($mime_msg); 
    3028                         switch($ical['version']['value']) 
    3029                         { 
    3030                                 case '1.0': 
     2753        switch ($ical['version']['value']) { 
     2754                case '1.0' : 
    30312755                                        $cat_sep = ';'; 
    30322756                                        break; 
    3033                                 case '2.0': 
    3034                                 default: 
     2757                case '2.0' : 
     2758                default : 
    30352759                                        $cat_sep = ','; 
    30362760                                        break;                   
    30372761                        } 
    30382762                                         
    3039                         $c_events = count($ical['event']); 
    3040                         for($i=0; $i<$c_events; $i++) 
    3041                         { 
    3042                                 if($ical['event'][$i]['uid']['value']) 
     2763        /* 
     2764         * Caso seja um Reply. 
     2765         */ 
     2766        if (strtoupper($ical['method']['value']) == 'REPLY') { 
     2767                //atualiza evento caso seja evento externo 
     2768                if (isset ($ical['event']['0']['x_type'])) 
     2769                        foreach ($ical['event']['0']['x_type'] as $property) 
     2770                                if ($property['name'] === 'MICROSOFT_CDO_IMPORTANCE') 
     2771                                        return $this->updateHour($ical); 
     2772 
     2773                //Ignora respostas externas 
     2774                return 'The import was executed successfully.'; 
     2775                                } 
     2776 
     2777        /*-------------------------------------------------------------*/ 
     2778 
     2779        /* 
     2780         * Ativa a flag de cancelamento caso o ical for do method CANCEL 
     2781         */ 
     2782        $cancelEvent = false; 
     2783        if (strtoupper($ical['method']['value']) == 'CANCEL') 
     2784                $cancelEvent = true; 
     2785        /*-------------------------------------------------------------*/ 
     2786 
     2787        require_once ($_SESSION['rootPath'] . '/calendar/inc/class.ex_participants.inc.php'); 
     2788 
     2789        $c_events = count($ical['event']); 
     2790        for ($i = 0; $i < $c_events; $i++) { 
     2791                $ex_participants = new exParticipants(); 
     2792 
     2793                if ($ical['event'][$i]['uid']['value']) 
     2794                        $uid_exists = $so_event->find_cal_id($ical['event'][$i]['uid']['value']); 
     2795                                else 
     2796                                        $uid_exists = False; 
     2797 
     2798                if ($cancelEvent) // If cancelamento 
    30432799                                { 
    3044                                         $uid_exists = $so_event->find_uid($ical['event'][$i]['uid']['value']); 
    3045                                 } 
    3046                                 else 
    3047                                 { 
    3048                                         $uid_exists = False; 
    3049                                 } 
    3050                                 if($uid_exists) 
    3051                                 { 
    3052                                         // $event = $so_event->read_entry($uid_exists); 
    3053                                         // $this->check_owner($event,$ical['event'][$i],$so_event); 
    3054                                         // $event = $so_event->get_cached_event(); 
    3055                                         // $so_event->add_entry($event); 
    3056                                         Header('Location: ' . $GLOBALS['phpgw']->link('/index.php', 
    3057                                                         Array( 
    3058                                                                 'menuaction'    => 'calendar.uiicalendar.import', 
    3059                                                                 'error_number'  => 1 
    3060                                                         ) 
    3061                                                 ) 
    3062                                         ); 
    3063                                         $GLOBALS['phpwg']->common->phpgw_exit(); 
    3064  
    3065                                 } 
    3066                                 else 
    3067                                 { 
     2800                        if ($importAccount != false && !$this->safeBitCheck(8, $row['acl_rights'])) // se for em uma conta compartilhada e se tem permisão de deletar 
     2801                                return 'You do not have permission to delete events'; 
     2802 
     2803                        if ($uid_exists) // If o evento existe na agenda 
     2804                                $so_event->delete_entry($uid_exists); // Adicona o id a lista de eventos a deletar 
     2805 
     2806                        continue; // Continua o for nenhum processamento mais é nescessario 
     2807                                } 
     2808 
     2809                if ($uid_exists) { 
     2810                        $event = $so_event->read_entry($uid_exists); 
     2811                        $this->check_owner($event, $ical['event'][$i], $so_event); 
     2812                } else { 
    30682813                                        $so_event->event_init(); 
    3069                                         $so_event->add_attribute('id',0); 
    3070                                         $so_event->add_attribute('reference',0); 
    3071                                         if($ical['event'][$i]['uid']['value']) 
    3072                                         { 
    3073                                                 $so_event->add_attribute('uid',$ical['event'][$i]['uid']['value']); 
    3074                                         } 
    3075                                         if($ical['event'][$i]['summary']['value']) 
    3076                                         { 
     2814                        $so_event->add_attribute('id', 0); 
     2815                        $so_event->add_attribute('reference', 0); 
     2816                                        } 
     2817 
     2818                if ($ical['event'][$i]['uid']['value']) { 
     2819                        $so_event->add_attribute('uid', $ical['event'][$i]['uid']['value']); 
     2820                } 
     2821                if ($ical['event'][$i]['summary']['value']) { 
    30772822                                                $so_event->set_title($ical['event'][$i]['summary']['value']); 
    30782823                                        } 
    3079                                         if($ical['event'][$i]['description']['value']) 
    3080                                         { 
     2824                if ($ical['event'][$i]['description']['value']) { 
    30812825                                                $so_event->set_description($ical['event'][$i]['description']['value']); 
    30822826                                        } 
    3083                                         if($ical['event'][$i]['ex_participants']['value']) 
    3084                                         { 
    3085                                                 $so_event->set_ex_participants($ical['event'][$i]['ex_participants']['value']); 
     2827                if ($ical['event'][$i]['ex_participants']['value']) { 
     2828                        $ex_participants->setParticipantsByString($ical['event'][$i]['ex_participants']['value']); 
    30862829                                        } 
    30872830                                        // Compatibilidade com agendamentos vindos do outlook/exchange 
    3088                                         if ( isset ($ical['event'][$i]['attendee']) ) 
    3089                                         { 
     2831                if (isset ($ical['event'][$i]['attendee'])) { 
    30902832                                                $c_attendees = count($ical['event'][$i]['attendee']); 
    30912833                                                $all_attendees = ''; 
    3092                                                 for ( $a=0; $a < $c_attendees; $a++ ) 
    3093                                                 { 
    3094                                                         $cname = '"'. $ical['event'][$i]['attendee'][$a]['cn'] .'"'; 
     2834                        for ($a = 0; $a < $c_attendees; $a++) { 
     2835                                $cname = '"' . $ical['event'][$i]['attendee'][$a]['cn'] . '"'; 
    30952836                                                        $email = $ical['event'][$i]['attendee'][$a]['mailto']['user']; 
    3096                                                         if ( $email ) 
    3097                                                         { 
     2837                                if ($email) { 
    30982838                                                                // Remove os espaços, tabs e quebra-de-linha no dominio 
    30992839                                                                //$email_domain = preg_replace('/\s*/m', '', $ical['event'][$i]['attendee'][$a]['mailto']['host']); 
    31002840                                                                $email_domain = $ical['event'][$i]['attendee'][$a]['mailto']['host']; 
    3101                                                                 $email = '<'. $email .'@'. $email_domain .'>'; 
    3102                                                         } 
    3103                                                         else 
     2841                                        $email = '<' . $email . '@' . $email_domain . '>'; 
     2842                                } else 
    31042843                                                                $email = ''; 
    31052844                                                         
    3106                                                         $all_attendees .= $cname . $email .', '; 
    3107                                                 } 
    3108                                                 $this->debug ('All attendees: ' . $all_attendees); 
    3109                                                 $so_event->set_ex_participants($all_attendees); 
    3110                                         } 
    3111  
    3112                                         if($ical['event'][$i]['location']['value']) 
    3113                                         { 
    3114                                                 $so_event->add_attribute('location',$ical['event'][$i]['location']['value']); 
    3115                                         } 
    3116                                         if(isset($ical['event'][$i]['priority'])) 
    3117                                         { 
    3118                                                 $so_event->add_attribute('priority',$ical['event'][$i]['priority']); 
    3119                                         } 
    3120                                         else 
    3121                                         { 
    3122                                                 $so_event->add_attribute('priority',2); 
    3123                                         } 
    3124                                         if(!isset($ical['event'][$i]['class'])) 
    3125                                         { 
     2845                                $all_attendees .= $cname . $email . ', '; 
     2846                                        } 
     2847                        $this->debug('All attendees: ' . $all_attendees); 
     2848 
     2849                        $ex_participants->setParticipantsByString($all_attendees); 
     2850 
     2851                                        } 
     2852 
     2853                if ($ical['event'][$i]['location']['value']) { 
     2854                        $so_event->add_attribute('location', $ical['event'][$i]['location']['value']); 
     2855                                        } 
     2856                if (isset ($ical['event'][$i]['priority'])) { 
     2857                        $so_event->add_attribute('priority', $ical['event'][$i]['priority']); 
     2858                } else { 
     2859                        $so_event->add_attribute('priority', 2); 
     2860                                        } 
     2861                if (!isset ($ical['event'][$i]['class'])) { 
    31262862                                                $ical['event'][$i]['class'] = 1; 
    31272863                                        } 
    31282864                                        $so_event->set_class($ical['event'][$i]['class']); 
    31292865 
    3130                                         @reset($datetime_vars); 
    3131                                         while(list($e_datevar,$i_datevar) = each($datetime_vars)) 
    3132                                         { 
    3133                                                 if(isset($ical['event'][$i][$i_datevar])) 
    3134                                                 { 
     2866                @ reset($datetime_vars); 
     2867                while (list ($e_datevar, $i_datevar) = each($datetime_vars)) { 
     2868                        if (isset ($ical['event'][$i][$i_datevar])) { 
    31352869                                                        $temp_time = $so_event->maketime($ical['event'][$i][$i_datevar]) + $GLOBALS['phpgw']->datetime->tz_offset; 
    3136                                                          
    3137                                                         //verifica se o vcard importado tem a referência do timezone 
    3138                                                         if($ical['event'][$i][$i_datevar]['tzid']) { 
    3139                                                                 $dateTimeZone = new DateTimeZone( $ical['event'][$i][$i_datevar]['tzid'] ); 
    3140                                                                 $dateTime = new DateTime("now", $dateTimeZone); 
    3141                                                                 $timeOffset = $dateTimeZone->getOffset($dateTime);       
    3142                                                                  
    3143                                                                 //tira o time zone do vcard para só ficar o time zone do sistema 
    3144                                                                 $temp_time = $temp_time - $timeOffset; 
     2870                                @ reset($date_array); 
     2871                                while (list ($key, $var) = each($date_array)) { 
     2872                                        $event[$e_datevar][$var] = (int) (date($key, $temp_time)); 
    31452873                                                        } 
    3146                                                          
    3147                                                         @reset($date_array); 
    3148                                                         while(list($key,$var) = each($date_array)) 
    3149                                                         { 
    3150                                                                 $event[$e_datevar][$var] = (int)(date($key,$temp_time)); 
    3151                                                         } 
    3152                                                         $so_event->set_date($e_datevar,$event[$e_datevar]['year'],$event[$e_datevar]['month'],$event[$e_datevar]['mday'],$event[$e_datevar]['hour'],$event[$e_datevar]['min'],$event[$e_datevar]['sec']); 
    3153                                                 } 
    3154                                         } 
    3155                                         if(!isset($ical['event'][$i]['categories']['value']) || !$ical['event'][$i]['categories']['value']) 
    3156                                         { 
     2874                                $so_event->set_date($e_datevar, $event[$e_datevar]['year'], $event[$e_datevar]['month'], $event[$e_datevar]['mday'], $event[$e_datevar]['hour'], $event[$e_datevar]['min'], $event[$e_datevar]['sec']); 
     2875                                                } 
     2876                                        } 
     2877                if (!isset ($ical['event'][$i]['categories']['value']) || !$ical['event'][$i]['categories']['value']) { 
    31572878                                                $so_event->set_category(0); 
    3158                                         } 
    3159                                         else 
    3160                                         { 
    3161                                                 $ical_cats = Array(); 
    3162                                                 if(strpos($ical['event'][$i]['categories']['value'],$cat_sep)) 
    3163                                                 { 
    3164                                                         $ical_cats = explode($cat_sep,$ical['event'][$i]['categories']['value']); 
    3165                                                 } 
    3166                                                 else 
    3167                                                 { 
     2879                } else { 
     2880                        $ical_cats = Array (); 
     2881                        if (strpos($ical['event'][$i]['categories']['value'], $cat_sep)) { 
     2882                                $ical_cats = explode($cat_sep, $ical['event'][$i]['categories']['value']); 
     2883                        } else { 
    31682884                                                        $ical_cats[] = $ical['event'][$i]['categories']['value']; 
    31692885                                                } 
    31702886 
    3171                                                 @reset($ical_cats); 
    3172                                                 $cat_id_nums = Array(); 
    3173                                                 while(list($key,$cat) = each($ical_cats)) 
    3174                                                 { 
    3175                                                         if(!$cats->exists('appandmains',$cat)) 
    3176                                                         { 
    3177                                                                 $cats->add( 
    3178                                                                         Array( 
     2887                        @ reset($ical_cats); 
     2888                        $cat_id_nums = Array (); 
     2889                        while (list ($key, $cat) = each($ical_cats)) { 
     2890                                if (!$cats->exists('appandmains', $cat)) { 
     2891                                        $cats->add(Array ( 
    31792892                                                                                'name'  => $cat, 
    31802893                                                                                'descr' => $cat, 
     
    31822895                                                                                'access'        => 'private', 
    31832896                                                                                'data'  => '' 
    3184                                                                         ) 
    3185                                                                 ); 
     2897                                        )); 
    31862898                                                        } 
    3187 //                                                      $temp_id = $cats->name2id($cat); 
    3188 //                                                      echo 'Category Name : '.$cat.' : Category ID :'.$temp_id."<br>\n"; 
    3189 //                                                      $cat_id_nums[] = $temp_id; 
     2899                                //                                                      $temp_id = $cats->name2id($cat); 
     2900                                //                                                      echo 'Category Name : '.$cat.' : Category ID :'.$temp_id."<br>\n"; 
     2901                                //                                                      $cat_id_nums[] = $temp_id; 
    31902902                                                        $cat_id_nums[] = $cats->name2id($cat); 
    31912903                                                } 
    3192                                                 @reset($cat_id_nums); 
    3193                                                 if(count($cat_id_nums) > 1) 
    3194                                                 { 
    3195                                                         $so_event->set_category(implode($cat_id_nums,',')); 
    3196                                                 } 
    3197                                                 else 
    3198                                                 { 
     2904                        @ reset($cat_id_nums); 
     2905                        if (count($cat_id_nums) > 1) { 
     2906                                $so_event->set_category(implode($cat_id_nums, ',')); 
     2907                        } else { 
    31992908                                                        $so_event->set_category($cat_id_nums[0]); 
    32002909                                                } 
    32012910                                        } 
    32022911 
    3203 //rrule 
    3204                                         if(isset($ical['event'][$i]['rrule'])  OR isset($ical['event'][$i]['duration']) ) 
    3205                                         { 
    3206 // recur_enddate 
    3207                                                 if(isset($ical['event'][$i]['rrule']['until'])) 
    3208                                                 { 
    3209                                                         $recur_enddate['year']  = (int)($ical['event'][$i]['rrule']['until']['year']); 
    3210                                                         $recur_enddate['month'] = (int)($ical['event'][$i]['rrule']['until']['month']); 
    3211                                                         $recur_enddate['mday']  = (int)($ical['event'][$i]['rrule']['until']['mday']); 
    3212                                                 } 
    3213                                                 elseif( isset($ical['event'][$i]['duration']) ) 
    3214                                                 { 
     2912                //rrule 
     2913                if (isset ($ical['event'][$i]['rrule']) OR isset ($ical['event'][$i]['duration'])) { 
     2914                        // recur_enddate 
     2915                        if (isset ($ical['event'][$i]['rrule']['until'])) { 
     2916                                $recur_enddate['year'] = (int) ($ical['event'][$i]['rrule']['until']['year']); 
     2917                                $recur_enddate['month'] = (int) ($ical['event'][$i]['rrule']['until']['month']); 
     2918                                $recur_enddate['mday'] = (int) ($ical['event'][$i]['rrule']['until']['mday']); 
     2919                                                } 
     2920                        elseif (isset ($ical['event'][$i]['duration'])) { 
    32152921                                                        // Create timecode for strtotime 
    3216                                                         $ptimer = mktime($ical['event'][$i]['dtstart']['hour'], 
    3217                                                         $ical['event'][$i]['dtstart']['min'], 
    3218                                                         $ical['event'][$i]['dtstart']['sec'], 
    3219                                                         $ical['event'][$i]['dtstart']['month'], 
    3220                                                         $ical['event'][$i]['dtstart']['mday'], 
    3221                                                         $ical['event'][$i]['dtstart']['year'] 
    3222                                                 ); 
     2922                                $ptimer = mktime($ical['event'][$i]['dtstart']['hour'], $ical['event'][$i]['dtstart']['min'], $ical['event'][$i]['dtstart']['sec'], $ical['event'][$i]['dtstart']['month'], $ical['event'][$i]['dtstart']['mday'], $ical['event'][$i]['dtstart']['year']); 
    32232923 
    32242924                                                /*  -- Fixbug -- 
     
    32302930 
    32312931                                                        // Weeks::Day-- 
    3232                                                         if( $ical['event'][$i]['duration']['weeks'] 
    3233                                                         AND 
    3234                                                         ( $ical['event'][$i]['duration']['hours'] == 0 ) 
    3235                                                         AND 
    3236                                                         ( $ical['event'][$i]['duration']['minutes'] == 0 ) 
    3237                                                 ) 
    3238                                                 { 
    3239                                                         $ical['event'][$i]['duration']['days'] = ( 
    3240                                                                 $ical['event'][$i]['duration']['days'] + 
    3241                                                                 ($ical['event'][$i]['duration']['weeks']*7))-1; 
    3242                                                                 unset($ical['event'][$i]['duration']['weeks']); 
     2932                                if ($ical['event'][$i]['duration']['weeks'] AND ($ical['event'][$i]['duration']['hours'] == 0) AND ($ical['event'][$i]['duration']['minutes'] == 0)) { 
     2933                                        $ical['event'][$i]['duration']['days'] = ($ical['event'][$i]['duration']['days'] + ($ical['event'][$i]['duration']['weeks'] * 7)) - 1; 
     2934                                        unset ($ical['event'][$i]['duration']['weeks']); 
    32432935                                                                $ical['event'][$i]['duration']['hours'] = "23"; 
    32442936                                                                $ical['event'][$i]['duration']['minutes'] = "59"; 
     
    32462938                                                        } 
    32472939                                                        // Days::Day-- 
    3248                                                         if( 
    3249                                                                 $ical['event'][$i]['duration']['days'] 
    3250                                                                 AND 
    3251                                                                 ( $ical['event'][$i]['duration']['hours'] == 0 ) 
    3252                                                                 AND 
    3253                                                                 ( $ical['event'][$i]['duration']['minutes'] == 0 ) 
    3254                                                         ) 
    3255                                                         { 
     2940                                if ($ical['event'][$i]['duration']['days'] AND ($ical['event'][$i]['duration']['hours'] == 0) AND ($ical['event'][$i]['duration']['minutes'] == 0)) { 
    32562941                                                                $ical['event'][$i]['duration']['days']--; 
    32572942                                                                $ical['event'][$i]['duration']['hours'] = "23"; 
     
    32622947                                                        // Create string contains datetime for strtotime 
    32632948                                                        $pdate = "+"; 
    3264                                                         if( isset($ical['event'][$i]['duration']['weeks']) ) 
     2949                                if (isset ($ical['event'][$i]['duration']['weeks'])) 
    32652950                                                        $pdate .= $ical['event'][$i]['duration']['weeks'] . " weeks "; 
    3266                                                         if( isset($ical['event'][$i]['duration']['days']) ) 
     2951                                if (isset ($ical['event'][$i]['duration']['days'])) 
    32672952                                                        $pdate .= $ical['event'][$i]['duration']['days'] . " days "; 
    3268                                                         if( isset($ical['event'][$i]['duration']['hours']) ) 
     2953                                if (isset ($ical['event'][$i]['duration']['hours'])) 
    32692954                                                        $pdate .= $ical['event'][$i]['duration']['hours'] . " hours "; 
    3270                                                         if( isset($ical['event'][$i]['duration']['minutes']) ) 
     2955                                if (isset ($ical['event'][$i]['duration']['minutes'])) 
    32712956                                                        $pdate .= $ical['event'][$i]['duration']['minutes'] . " minutes "; 
    3272                                                         if( isset($ical['event'][$i]['duration']['seconds']) ) 
     2957                                if (isset ($ical['event'][$i]['duration']['seconds'])) 
    32732958                                                        $pdate .= $ical['event'][$i]['duration']['seconds'] . " seconds "; 
    32742959 
    32752960                                                        // What is datetime in 2192 ? 
    32762961                                                        $enddate = strtotime($pdate, $ptimer); 
    3277                                                         list(   $recur_enddate['year'], 
    3278                                                         $recur_enddate['month'], 
    3279                                                         $recur_enddate['mday'], 
    3280                                                         $recur_enddate['hour'], 
    3281                                                         $recur_enddate['min'], 
    3282                                                         $recur_enddate['sec'] ) = split(":", date("Y:m:d:H:i:s", $enddate)); 
     2962                                list ($recur_enddate['year'], $recur_enddate['month'], $recur_enddate['mday'], $recur_enddate['hour'], $recur_enddate['min'], $recur_enddate['sec']) = split(":", date("Y:m:d:H:i:s", $enddate)); 
    32832963 
    32842964                                                        // Set End of event 
    3285                                                         $so_event->set_end(     $recur_enddate['year'], 
    3286                                                         $recur_enddate['month'], 
    3287                                                         $recur_enddate['mday'], 
    3288                                                         $recur_enddate['hour'], 
    3289                                                         $recur_enddate['min'], 
    3290                                                         $recur_enddate['sec']); 
    3291  
    3292                                                 } 
    3293                                                 else 
    3294                                                 { 
     2965                                $so_event->set_end($recur_enddate['year'], $recur_enddate['month'], $recur_enddate['mday'], $recur_enddate['hour'], $recur_enddate['min'], $recur_enddate['sec']); 
     2966 
     2967                        } else { 
    32952968                                                        $recur_enddate['year'] = 0; 
    32962969                                                        $recur_enddate['month'] = 0; 
     
    32982971                                                } 
    32992972 
    3300 // recur_data 
     2973                        // recur_data 
    33012974                                                $recur_data = 0; 
    3302                                                 if(isset($ical['event'][$i]['rrule']['byday'])) 
    3303                                                 { 
    3304                                                         $week_days = Array( 
     2975                        if (isset ($ical['event'][$i]['rrule']['byday'])) { 
     2976                                $week_days = Array ( 
    33052977                                                                MCAL_M_SUNDAY   => 'SU', 
    33062978                                                                MCAL_M_MONDAY   => 'MO', 
     
    33112983                                                                MCAL_M_SATURDAY => 'SA' 
    33122984                                                        ); 
    3313                                                         @reset($week_days); 
    3314                                                         while(list($key,$val) = each($week_days)) 
    3315                                                         { 
    3316                                                                 if(strpos(' '.$ical['event'][$i]['rrule']['byday'],$val)) 
    3317                                                                 { 
     2985                                @ reset($week_days); 
     2986                                while (list ($key, $val) = each($week_days)) { 
     2987                                        if (strpos(' ' . $ical['event'][$i]['rrule']['byday'], $val)) { 
    33182988                                                                        $recur_data += $key; 
    33192989                                                                } 
     
    33212991                                                } 
    33222992 
    3323 // interval 
    3324                                                 if(!isset($ical['event'][$i]['rrule']['interval'])) 
    3325                                                 { 
     2993                        // interval 
     2994                        if (!isset ($ical['event'][$i]['rrule']['interval'])) { 
    33262995                                                        $interval = 1; 
    3327                                                 } 
    3328                                                 else 
    3329                                                 { 
    3330                                                         $interval = (int)$ical['event'][$i]['rrule']['interval']; 
    3331                                                 } 
    3332 // recur_type 
    3333                                                 switch($ical['event'][$i]['rrule']['freq']) 
    3334                                                 { 
    3335                                                         case DAILY: 
     2996                        } else { 
     2997                                $interval = (int) $ical['event'][$i]['rrule']['interval']; 
     2998                                                } 
     2999                        // recur_type 
     3000                        switch ($ical['event'][$i]['rrule']['freq']) { 
     3001                                case DAILY : 
    33363002                                                                $recur_type = MCAL_RECUR_DAILY; 
    33373003                                                                break; 
    3338                                                         case WEEKLY: 
    3339                                                                 $so_event->set_recur_weekly($recur_enddate['year'],$recur_enddate['month'],$recur_enddate['mday'],$interval,$recur_data); 
     3004                                case WEEKLY : 
     3005                                        $so_event->set_recur_weekly($recur_enddate['year'], $recur_enddate['month'], $recur_enddate['mday'], $interval, $recur_data); 
    33403006                                                                break; 
    3341                                                         case MONTHLY: 
    3342 // Still need to determine if this is by day or by week for the month.. 
    3343 //                                                              $recur_type = MCAL_RECUR_M??????; 
     3007                                case MONTHLY : 
     3008                                        // Still need to determine if this is by day or by week for the month.. 
     3009                                        //                                                              $recur_type = MCAL_RECUR_M??????; 
    33443010                                                                break; 
    3345                                                         case YEARLY: 
    3346                                                                 $so_event->set_recur_yearly($recur_enddate['year'],$recur_enddate['month'],$recur_enddate['mday'],$interval); 
     3011                                case YEARLY : 
     3012                                        $so_event->set_recur_yearly($recur_enddate['year'], $recur_enddate['month'], $recur_enddate['mday'], $interval); 
    33473013                                                                break; 
    33483014                                                } 
    3349                                         } 
    3350                                         else 
     3015                } else { 
     3016                                                $so_event->set_recur_none(); 
     3017                                        } 
     3018 
     3019                // Owner 
     3020                $organizer = $ical['event'][$i]['organizer']; 
     3021 
     3022                if (isset ($organizer)) { 
     3023                        if ($this->is_owner($organizer) || $organizer == -2) { 
     3024                                $so_event->add_attribute('owner', $GLOBALS['phpgw_info']['user']['account_id']); 
     3025                        } else { 
     3026                                $so_event->add_attribute('owner', -2); 
     3027                                $aux = explode(':', $organizer['cn']); 
     3028                                $so_event->add_attribute('organizer', '' . $aux[0] . ' <' . $organizer['mailto']['user'] . '@'. $organizer['mailto']['host'].'>'); 
     3029                                        } 
     3030                                        } 
     3031 
     3032                // se for importação para conta compartilhada 
     3033                $user = (int) ($importAccount ? $importAccount['uidnumber'] : $GLOBALS['phpgw_info']['user']['account_id']); 
     3034                $userMail = $importAccount['mail'] ? $importAccount['mail'] : $GLOBALS['phpgw_info']['user']['email']; 
     3035 
     3036                $so_event->add_attribute('participants', 'A', $user); 
     3037                                        $event = $so_event->get_cached_event(); 
     3038 
     3039                /* 
     3040                 * Remove Email do participantes externos 
     3041                 */ 
     3042                $usersToRemove = array (); 
     3043                $usersToRemove[] = $user; 
     3044                foreach ($event['participants'] as $auxi=> $v) 
     3045                        $usersToRemove[] = $auxi; 
     3046 
     3047                $ldapService = ServiceLocator :: getService('ldap'); 
     3048                foreach ($usersToRemove as $v) { 
     3049                        $ex_participants->removeParticipant($ldapService->getMailByUidNumber($v)); 
     3050                        $alternates = $ldapService->getMailAlternateByUidNumber($v); 
     3051                        foreach ($alternates as $ii => $vv) 
     3052                                $ex_participants->removeParticipant($vv); 
     3053                } 
     3054                $ex_participants->removeParticipant($event['organizer']); 
     3055                /// -------------------------------------------------------- /// 
     3056 
     3057                $event['ex_participants'] = $ex_participants->getParticipantsSerializable(); 
     3058 
     3059                if (!isset ($this->bo)) { 
     3060                        require_once ($_SESSION['rootPath'] . '/calendar/inc/class.bocalendar.inc.php'); 
     3061                        $this->bo = new bocalendar(); 
     3062                } 
     3063 
     3064                if ($c_events < 2) //Ignora verificação de conflito quando o ical é de varios eventos 
     3065                { 
     3066                        if ($overlapping_events = $this->bo->event_overlap($event, (!$from_ajax), null, $user)) { 
     3067                                if ($_GET['calendarImport'] == 1) //caso venha do modulo calendar 
    33513068                                        { 
    3352                                                 $so_event->set_recur_none(); 
    3353                                         } 
    3354  
    3355 // Owner 
    3356                                         if(!isset($ical['event'][$i]['organizer']) || (isset($ical['event'][$i]['organizer']) && $this->is_owner($ical['event'][$i]['organizer']))) 
    3357                                         { 
    3358                                                 $so_event->add_attribute('owner',$GLOBALS['phpgw_info']['user']['account_id']); 
    3359                                                 $so_event->add_attribute('participants','A',(int)$GLOBALS['phpgw_info']['user']['account_id']); 
    3360                                         } 
    3361                                         else 
    3362                                         { 
    3363                                                 $so_event->add_attribute('participants','A',(int)$GLOBALS['phpgw_info']['user']['account_id']); 
    3364                                         } 
    3365  
    3366                                         $event = $so_event->get_cached_event(); 
    3367                                         $so_event->add_entry($event); 
    3368 //                                      $event = $so_event->get_cached_event(); 
    3369                                 } 
    3370                         } 
    3371                         if(!$from_ajax) { 
    3372                                 Header('Location: '.$GLOBALS['phpgw']->link('/index.php', 
    3373                                         Array( 
     3069                                        $url = 'expressoMail1_2/controller.php?action=' . implode("&", array ( 
     3070                                                'calendar.uicalendar.overlap', 
     3071                                                'o_events=' . implode(';', $overlapping_events), 
     3072                                                'this_event=' . $event['id'], 
     3073                                                'this_account=' . $user 
     3074                                        )); 
     3075 
     3076                                        echo "<script>document.location='" . $url . "'</script>"; 
     3077                                        exit; 
     3078                                } else 
     3079                                        return array ( 
     3080                                                'url' => implode("&", array ( 
     3081                                                        'calendar.uicalendar.overlap', 
     3082                                                        'o_events=' . implode(';', $overlapping_events), 
     3083                                                        'this_event=' . $event['id'], 
     3084                                                        'this_account=' . $user 
     3085                                                )) 
     3086                                        ); 
     3087                        } 
     3088                                } 
     3089 
     3090                if ($importAccount) 
     3091                        $so_event->add_entry($event, true, $importAccount); 
     3092                else 
     3093                        $so_event->add_entry($event); 
     3094 
     3095                        } 
     3096 
     3097        /* 
     3098         * Exclue os eventos que estão na lista para serem deletados 
     3099         */ 
     3100        if ($cancelEvent) 
     3101                $so_event->expunge(); 
     3102        /*----------------------------------------------------------*/ 
     3103 
     3104        if (!$from_ajax) { 
     3105                Header('Location: ' . $GLOBALS['phpgw']->link('/index.php', Array ( 
    33743106                                                'menuaction'    => 'calendar.uicalendar.view', 
    33753107                                                'cal_id'        => $event['id'] 
    3376                                                 ) 
    3377                                         ) 
    3378                                 ); 
     3108                ))); 
    33793109                                $GLOBALS['phpgw']->common->phpgw_exit(); 
    3380                         } 
    3381                         else  
     3110        } else // checando se o icalendar veio no formato esperado, ou seja, foi parseado corretamente 
     3111                if (!empty ($ical)) 
    33823112                                return true; 
    3383                 } 
    3384  
    3385                 function export($params) 
    3386                 { 
     3113                else 
     3114                        return 'Cannot import target event. Please check if the format is right.'; 
     3115 
     3116} 
     3117 
     3118function updateHour($ical) { 
     3119 
     3120        if (!is_object($GLOBALS['uicalendar'])) { 
     3121                $so_event = createobject('calendar.socalendar', Array ( 
     3122                        'owner' => 0, 
     3123                        'filter' => '', 
     3124                        'category' => '' 
     3125                )); 
     3126        } else 
     3127                $so_event = $GLOBALS['uicalendar']->bo->so; 
     3128 
     3129        $cal_id = $so_event->find_cal_id($ical['event'][0]['uid']['value']); 
     3130 
     3131        //Agendamento nao ecnontrado 
     3132        if (!$cal_id) 
     3133                return 'The event was not found in your calendar'; 
     3134 
     3135        $event = $so_event->read_entry($cal_id); 
     3136 
     3137        $datetime_vars = Array ( 
     3138                'start' => 'dtstart', 
     3139                'end' => 'dtend', 
     3140                'modtime' => 'dtstamp', 
     3141                'modtime' => 'last_modified' 
     3142        ); 
     3143 
     3144        $date_array = Array ( 
     3145                'Y' => 'year', 
     3146                'm' => 'month', 
     3147                'd' => 'mday', 
     3148                'H' => 'hour', 
     3149                'i' => 'min', 
     3150                's' => 'sec' 
     3151        ); 
     3152 
     3153        @ reset($datetime_vars); 
     3154        while (list ($e_datevar, $i_datevar) = each($datetime_vars)) { 
     3155                if (isset ($ical['event'][0][$i_datevar])) { 
     3156                        $temp_time = $so_event->maketime($ical['event'][0][$i_datevar]); 
     3157                        @ reset($date_array); 
     3158                        while (list ($key, $var) = each($date_array)) 
     3159                                $event[$e_datevar][$var] = (int) (date($key, $temp_time)); 
     3160 
     3161                        $so_event->set_date($e_datevar, $event[$e_datevar]['year'], $event[$e_datevar]['month'], $event[$e_datevar]['mday'], $event[$e_datevar]['hour'], $event[$e_datevar]['min'], $event[$e_datevar]['sec']); 
     3162                } 
     3163                } 
     3164 
     3165        $so_event->add_entry($event, false); 
     3166        $bo_event = createobject('calendar.bocalendar'); 
     3167        $bo_event->send_update(MSG_MODIFIED, $event['participants'], $event, $event); 
     3168 
     3169        return 'Event successfully updated'; 
     3170} 
     3171 
     3172function export($params) { 
    33873173                        $event_id = $params['l_event_id'] ? $params['l_event_id'] : $_GET['cal_id']; 
    33883174                        $this->chunk_split = $params['chunk_split']; 
     
    33903176                        $vtype = $params['vtype'] ? $params['vtype'] : 'event'; 
    33913177 
    3392                         $string_array = Array( 
     3178        $string_array = Array ( 
    33933179                                'summary'               => 'description', 
    33943180                                'location'              => 'location', 
     
    33993185                        $cats = CreateObject('phpgwapi.categories'); 
    34003186 
    3401                         include(PHPGW_SERVER_ROOT.'/calendar/setup/setup.inc.php'); 
    3402                         if(!is_array($event_id)) 
    3403                         { 
     3187        include (PHPGW_SERVER_ROOT . '/calendar/setup/setup.inc.php'); 
     3188        if (!is_array($event_id)) { 
    34043189                                $ids[] = $event_id; 
    3405                         } 
    3406                         else 
    3407                         { 
     3190        } else { 
    34083191                                $ids = $event_id; 
    34093192                        } 
     
    34113194                        $ical = $this->new_ical(); 
    34123195 
    3413                         $this->set_var($ical['prodid'],'value','-//eGroupWare//eGroupWare '.$setup_info['calendar']['version'].' MIMEDIR//'.strtoupper($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'])); 
    3414                         $this->set_var($ical['version'],'value','2.0'); 
    3415                         $this->set_var($ical['method'],'value',strtoupper($method)); 
    3416  
    3417                         if(!$GLOBALS['phpgw_info']['flags']['included_classes']['uicalendar']) 
    3418                         { 
    3419                                 if(!$GLOBALS['phpgw_info']['flags']['included_classes']['bocalendar']) 
    3420                                 { 
    3421                                         $so_event = createobject('calendar.socalendar', 
    3422                                                 Array( 
     3196        $this->set_var($ical['prodid'], 'value', '-//eGroupWare//eGroupWare ' . $setup_info['calendar']['version'] . ' MIMEDIR//' . strtoupper($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'])); 
     3197        $this->set_var($ical['version'], 'value', '2.0'); 
     3198        $this->set_var($ical['method'], 'value', strtoupper($method)); 
     3199 
     3200        if (!$GLOBALS['phpgw_info']['flags']['included_classes']['uicalendar']) { 
     3201                if (!$GLOBALS['phpgw_info']['flags']['included_classes']['bocalendar']) { 
     3202                        $so_event = createobject('calendar.socalendar', Array ( 
    34233203                                                        'owner' => 0, 
    34243204                                                        'filter'        => '', 
    34253205                                                        'category'      => '' 
    3426                                                 ) 
    3427                                         ); 
    3428                                 } 
    3429                                 else 
    3430                                 { 
     3206                        )); 
     3207                } else { 
    34313208                                        $so_event = $GLOBALS['bocalendar']->so; 
    34323209                                } 
    3433                         } 
    3434                         else 
    3435                         { 
     3210        } else { 
    34363211                                $so_event = $GLOBALS['uicalendar']->bo->so; 
    34373212                        } 
    34383213 
    3439                         foreach($ids as $event) 
    3440                         { 
    3441                                 $ical_event = Array(); 
    3442                                 if (!is_array($event)) 
    3443                                 { 
     3214        foreach ($ids as $event) { 
     3215                $ical_event = Array (); 
     3216                if (!is_array($event)) { 
    34443217                                        $event = $so_event->read_entry($event); 
    34453218                                } 
    3446                                 if($event['alarm']) 
    3447                                 { 
    3448                                         foreach($event['alarm'] as $alarm) 
    3449                                         { 
    3450                                                 $ical_temp = Array(); 
     3219                if ($event['alarm']) { 
     3220                        foreach ($event['alarm'] as $alarm) { 
     3221                                $ical_temp = Array (); 
    34513222                                                $ical_temp['action']['value'] = 'DISPLAY'; 
    34523223                                                $ical_temp['description']['value'] = $alarm['text']; 
    3453                                                 $this->set_var($ical_temp['trigger'],'value','VALUE=DATE-TIME:'.date('Ymd\THis\Z',$alarm['time']),'valarm'); 
     3224                                $this->set_var($ical_temp['trigger'], 'value', 'VALUE=DATE-TIME:' . date('Ymd\THis\Z', $alarm['time']), 'valarm'); 
    34543225                                                $ical_event['alarm'][] = $ical_temp; 
    34553226                                        } 
     
    34583229                                // use system's date info for caluculating local timezone's offset in minutes 
    34593230                                // 
    3460                                 $gmt_offset = date('O',$GLOBALS['phpgw']->datetime->users_localtime); // offset to GMT 
    3461                                 $offset = (int)(substr($gmt_offset, 0, 3)) * 60 + (int)(substr($gmt_offset, 3, 2)); 
     3231                $gmt_offset = date('O', $GLOBALS['phpgw']->datetime->users_localtime); // offset to GMT 
     3232                $offset = (int) (substr($gmt_offset, 0, 3)) * 60 + (int) (substr($gmt_offset, 3, 2)); 
    34623233                                $event['start']['min']   -= $offset; 
    34633234                                $event['end']['min']     -= $offset; 
     
    34653236 
    34663237                                $ical_event['priority'] = $event['priority']; 
    3467                                 $ical_event['class'] = (int)$event['public']; 
     3238                $ical_event['class'] = (int) $event['public']; 
    34683239                                $dtstart_mktime = $so_event->maketime($event['start']); 
    3469                                 $this->parse_value($ical_event,'dtstart',date('Ymd\THis\Z',$dtstart_mktime),'vevent'); 
     3240                $this->parse_value($ical_event, 'dtstart', date('Ymd\THis\Z', $dtstart_mktime), 'vevent'); 
    34703241                                $dtend_mktime = $so_event->maketime($event['end']); 
    3471                                 $this->parse_value($ical_event,'dtend',date('Ymd\THis\Z',$dtend_mktime),'vevent'); 
     3242                $this->parse_value($ical_event, 'dtend', date('Ymd\THis\Z', $dtend_mktime), 'vevent'); 
    34723243                                $mod_mktime = $so_event->maketime($event['modtime']); 
    3473                                 $this->parse_value($ical_event,'last_modified',date('Ymd\THis\Z',$mod_mktime),'vevent'); 
    3474                                 foreach($string_array as $ical_value => $event_value) 
    3475                                 { 
    3476                                         if($event[$event_value]) 
    3477                                         { 
    3478                                                 $this->set_var($ical_event[$ical_value],'value',$event[$event_value]); 
    3479                                         } 
    3480                                 } 
    3481  
    3482                                 if ($event['category']) 
    3483                                 { 
    3484                                         $cats->categories(0,'calendar'); 
    3485                                         foreach(explode(',',$event['category']) as $cat) 
    3486                                         { 
     3244                $this->parse_value($ical_event, 'last_modified', date('Ymd\THis\Z', $mod_mktime), 'vevent'); 
     3245                foreach ($string_array as $ical_value => $event_value) { 
     3246                        if ($event[$event_value]) { 
     3247                                $this->set_var($ical_event[$ical_value], 'value', $event[$event_value]); 
     3248                                        } 
     3249                                } 
     3250 
     3251                if ($event['category']) { 
     3252                        $cats->categories(0, 'calendar'); 
     3253                        foreach (explode(',', $event['category']) as $cat) { 
    34873254                                                $_cat = $cats->return_single($cat); 
    34883255                                                $cat_string[] = $_cat[0]['name']; 
    34893256                                        } 
    3490                                         @reset($cat_string); 
    3491                                         $this->set_var($ical_event['categories'],'value',implode($cat_string,',')); 
    3492                                 } 
    3493  
    3494                                 if(count($event['participants']) > 1) 
    3495                                 { 
    3496                                         if(!is_object($db)) 
    3497                                         { 
     3257                        @ reset($cat_string); 
     3258                        $this->set_var($ical_event['categories'], 'value', implode($cat_string, ',')); 
     3259                                } 
     3260 
     3261                if (count($event['participants']) > 1) { 
     3262                        if (!is_object($db)) { 
    34983263                                                $db = $GLOBALS['phpgw']->db; 
    34993264                                        } 
    3500                                         foreach($event['participants'] as $part => $status) 
    3501                                         { 
    3502                                                 $GLOBALS['phpgw']->accounts->get_account_name($part,$lid,$fname,$lname); 
    3503                                                 $name = $fname.' '.$lname; 
    3504  
    3505                                                 $owner_status = $this->switch_partstat((int)$this->switch_phpgw_status($event['participants'][$part])); 
     3265                        foreach ($event['participants'] as $part => $status) { 
     3266                                $GLOBALS['phpgw']->accounts->get_account_name($part, $lid, $fname, $lname); 
     3267                                $name = $fname . ' ' . $lname; 
     3268 
     3269                                $owner_status = $this->switch_partstat((int) $this->switch_phpgw_status($event['participants'][$part])); 
    35063270 
    35073271                                                $mail_prefs = $GLOBALS['phpgw']->preferences->create_email_preferences($part); 
    35083272                                                $mailto = $mail_prefs['email']['address']; 
    35093273 
    3510                                                 $str = 'CN="'.$name.'";PARTSTAT='.$owner_status.':'.$mailto; 
    3511                                                 if($part == $event['owner']) 
    3512                                                 { 
    3513                                                         $str = 'ROLE=CHAIR;'.$str; 
    3514                                                 } 
    3515                                                 else 
    3516                                                 { 
    3517                                                         $str = 'ROLE=REQ-PARTICIPANT;'.$str; 
    3518                                                 } 
    3519                                                 if ($method != 'reply' || $part == $GLOBALS['phpgw_info']['user']['account_id']) 
    3520                                                 { 
    3521                                                         $this->parse_value($ical_event,'attendee',$str,'vevent'); 
    3522                                                 } 
    3523                                                 if($part == $event['owner']) 
    3524                                                 { 
    3525                                                         $this->parse_value($ical_event,'organizer',$str,'vevent'); 
    3526                                                 } 
    3527                                         } 
    3528                                 } 
    3529                                 if($event['recur_type']) 
    3530                                 { 
     3274                                $str = 'CN="' . $name . '";PARTSTAT=' . $owner_status . ':' . $mailto; 
     3275                                if ($part == $event['owner']) { 
     3276                                        $str = 'ROLE=CHAIR;' . $str; 
     3277                                } else { 
     3278                                        $str = 'ROLE=REQ-PARTICIPANT;' . $str; 
     3279                                                } 
     3280                                if ($method != 'reply' || $part == $GLOBALS['phpgw_info']['user']['account_id']) { 
     3281                                        $this->parse_value($ical_event, 'attendee', $str, 'vevent'); 
     3282                                                } 
     3283                                if ($part == $event['owner']) { 
     3284                                        $this->parse_value($ical_event, 'organizer', $str, 'vevent'); 
     3285                                                } 
     3286                                        } 
     3287                                } 
     3288                if ($event['recur_type']) { 
    35313289                                        $str = ''; 
    3532                                         switch($event['recur_type']) 
    3533                                         { 
    3534                                                 case MCAL_RECUR_DAILY: 
     3290                        switch ($event['recur_type']) { 
     3291                                case MCAL_RECUR_DAILY : 
    35353292                                                        $str .= 'FREQ=DAILY'; 
    35363293                                                        break; 
    3537                                                 case MCAL_RECUR_WEEKLY: 
     3294                                case MCAL_RECUR_WEEKLY : 
    35383295                                                        $str .= 'FREQ=WEEKLY'; 
    3539                                                         if($event['recur_data']) 
    3540                                                         { 
     3296                                        if ($event['recur_data']) { 
    35413297                                                                $str .= ';BYDAY='; 
    3542                                                                 for($i=1;$i<MCAL_M_ALLDAYS;$i=$i*2) 
    3543                                                                 { 
    3544                                                                         if($i & $event['recur_data']) 
    3545                                                                         { 
    3546                                                                                 switch($i) 
    3547                                                                                 { 
    3548                                                                                         case MCAL_M_SUNDAY: 
     3298                                                for ($i = 1; $i < MCAL_M_ALLDAYS; $i = $i * 2) { 
     3299                                                        if ($i & $event['recur_data']) { 
     3300                                                                switch ($i) { 
     3301                                                                        case MCAL_M_SUNDAY : 
    35493302                                                                                                $day[] = 'SU'; 
    35503303                                                                                                break; 
    3551                                                                                         case MCAL_M_MONDAY: 
     3304                                                                        case MCAL_M_MONDAY : 
    35523305                                                                                                $day[] = 'MO'; 
    35533306                                                                                                break; 
    3554                                                                                         CASE MCAL_M_TUESDAY: 
     3307                                                                        CASE MCAL_M_TUESDAY : 
    35553308                                                                                                $day[] = 'TU'; 
    35563309                                                                                                break; 
    3557                                                                                         case MCAL_M_WEDNESDAY: 
     3310                                                                        case MCAL_M_WEDNESDAY : 
    35583311                                                                                                $day[] = 'WE'; 
    35593312                                                                                                break; 
    3560                                                                                         case MCAL_M_THURSDAY: 
     3313                                                                        case MCAL_M_THURSDAY : 
    35613314                                                                                                $day[] = 'TH'; 
    35623315                                                                                                break; 
    3563                                                                                         case MCAL_M_FRIDAY: 
     3316                                                                        case MCAL_M_FRIDAY : 
    35643317                                                                                                $day[] = 'FR'; 
    35653318                                                                                                break; 
    3566                                                                                         case MCAL_M_SATURDAY: 
     3319                                                                        case MCAL_M_SATURDAY : 
    35673320                                                                                                $day[] = 'SA'; 
    35683321                                                                                                break; 
     
    35703323                                                                        } 
    35713324                                                                } 
    3572                                                                 $str .= implode(',',$day); 
     3325                                                $str .= implode(',', $day); 
    35733326                                                        } 
    35743327                                                        break; 
    3575                                                 case MCAL_RECUR_MONTHLY_MDAY: 
     3328                                case MCAL_RECUR_MONTHLY_MDAY : 
    35763329                                                        break; 
    3577                                                 case MCAL_RECUR_MONTHLY_WDAY: 
     3330                                case MCAL_RECUR_MONTHLY_WDAY : 
    35783331                                                        break; 
    3579                                                 case MCAL_RECUR_YEARLY: 
     3332                                case MCAL_RECUR_YEARLY : 
    35803333                                                        $str .= 'FREQ=YEARLY'; 
    35813334                                                        break; 
    35823335                                        } 
    3583                                         if($event['recur_interval']) 
    3584                                         { 
    3585                                                 $str .= ';INTERVAL='.$event['recur_interval']; 
    3586                                         } 
    3587                                         if($event['recur_enddate']['month'] != 0 && $event['recur_enddate']['mday'] != 0 && $event['recur_enddate']['year'] != 0) 
    3588                                         { 
     3336                        if ($event['recur_interval']) { 
     3337                                $str .= ';INTERVAL=' . $event['recur_interval']; 
     3338                                        } 
     3339                        if ($event['recur_enddate']['month'] != 0 && $event['recur_enddate']['mday'] != 0 && $event['recur_enddate']['year'] != 0) { 
    35893340                                                $recur_mktime = $so_event->maketime($event['recur_enddate']) - $GLOBALS['phpgw']->datetime->tz_offset; 
    3590                                                 $str .= ';UNTIL='.date('Ymd\THis\Z',$recur_mktime); 
    3591                                         } 
    3592                                         $this->parse_value($ical_event,'rrule',$str,'vevent'); 
     3341                                $str .= ';UNTIL=' . date('Ymd\THis\Z', $recur_mktime); 
     3342                                        } 
     3343                        $this->parse_value($ical_event, 'rrule', $str, 'vevent'); 
    35933344 
    35943345                                        $exceptions = $event['recur_exception']; 
    3595                                         if(is_array($exceptions)) 
    3596                                         { 
    3597                                                 foreach($exceptions as $except_datetime) 
    3598                                                 { 
    3599                                                         $ical_event['exdate'][] = $this->switch_date(date('Ymd\THis\Z',$except_datetime)); 
     3346                        if (is_array($exceptions)) { 
     3347                                foreach ($exceptions as $except_datetime) { 
     3348                                        $ical_event['exdate'][] = $this->switch_date(date('Ymd\THis\Z', $except_datetime)); 
    36003349                                                } 
    36013350                                        } 
     
    36073356 
    36083357                        // iCals are by default utf-8 
    3609                         return $GLOBALS['phpgw']->translation->convert($this->build_ical($ical),$GLOBALS['phpgw']->translation->charset(),'utf-8'); 
    3610                 } 
    3611  
    3612                 function freebusy($params=False) 
    3613                 { 
    3614                         if (!$params) $params = $_GET; 
     3358        return $GLOBALS['phpgw']->translation->convert($this->build_ical($ical), $GLOBALS['phpgw']->translation->charset(), 'utf-8'); 
     3359} 
     3360 
     3361function freebusy($params = False) { 
     3362        if (!$params) 
     3363                $params = $_GET; 
    36153364                        $user  = is_numeric($params['user']) ? (int) $params['user'] : $GLOBALS['phpgw']->accounts->name2id($params['user']); 
    3616                         $start = isset($params['start']) ? $params['start'] : date('Ymd'); 
    3617                         $end   = isset($params['end']) ? $params['end'] : (date('Y')+1).date('md'); 
     3365        $start = isset ($params['start']) ? $params['start'] : date('Ymd'); 
     3366        $end = isset ($params['end']) ? $params['end'] : (date('Y') + 1) . date('md'); 
    36183367 
    36193368                        $this->bo = CreateObject('calendar.bocalendar'); 
    3620                         $events_per_day = $this->bo->store_to_cache(array( 
     3369        $events_per_day = $this->bo->store_to_cache(array ( 
    36213370                                'owner'  => $user, 
    3622                                 'syear'  => (int) substr($start,0,4), 
    3623                                 'smonth' => (int) substr($start,4,2), 
    3624                                 'sday'   => (int) substr($start,6,2), 
    3625                                 'eyear'  => (int) substr($end,0,4), 
    3626                                 'emonth' => (int) substr($end,4,2), 
    3627                                 'eday'   => (int) substr($end,6,2), 
     3371                'syear' => (int) substr($start, 0, 4), 
     3372                'smonth' => (int) substr($start, 4, 2), 
     3373                'sday' => (int) substr($start, 6, 2), 
     3374                'eyear' => (int) substr($end, 0, 4), 
     3375                'emonth' => (int) substr($end, 4, 2), 
     3376                'eday' => (int) substr($end, 6, 2), 
    36283377                                'no_doubles' => True,   // report events only on the startday 
     3378         
    36293379                        )); 
    3630                         if (!is_array($events_per_day)) $events_per_day = array(); 
    3631                         $ids = array(); 
    3632                         foreach($events_per_day as $day => $events) 
    3633                         { 
    3634                                 foreach($events as $event) 
    3635                                 { 
     3380        if (!is_array($events_per_day)) 
     3381                $events_per_day = array (); 
     3382        $ids = array (); 
     3383        foreach ($events_per_day as $day => $events) { 
     3384                foreach ($events as $event) { 
    36363385                                        $ids[] = $event; 
    36373386                                } 
    36383387                        } 
    36393388                        $browser = CreateObject('phpgwapi.browser'); 
    3640                         $browser->content_header($GLOBALS['phpgw']->accounts->id2name($user).'.ifb','text/calendar'); 
    3641  
    3642                         echo $this->export(array( 
     3389        $browser->content_header($GLOBALS['phpgw']->accounts->id2name($user) . '.ifb', 'text/calendar'); 
     3390 
     3391        echo $this->export(array ( 
    36433392                                'vtype'      => 'freebusy', 
    36443393                                'l_event_id' => $ids, 
     3394                 
    36453395                        )); 
    3646                 } 
    3647  
    3648                 function debug($str='') 
    3649                 { 
    3650                         if($this->debug_str) 
    3651                         { 
     3396} 
     3397 
     3398function debug($str = '') { 
     3399        if ($this->debug_str) { 
    36523400                                //echo $str."<br>\n"; 
    36533401                                $log = fopen('/tmp/calendar.log', 'a') or die("nao foi possivel abrir o arquivo /tmp/calendar.log"); 
     
    36553403                                fclose($log); 
    36563404                        } 
    3657                 } 
    3658         } 
     3405} 
     3406 
     3407function updateExParticipantState($cal_uid, $mail, $situation, $cn = false) { 
     3408        $db = $GLOBALS['phpgw']->db; 
     3409        $query = 'SELECT ex_participants FROM phpgw_cal WHERE uid = \'' . trim($cal_uid) . '\''; 
     3410        if (!$db->query($query)) 
     3411                return false; 
     3412        $row = $db->row(true); 
     3413 
     3414        if (!$row) 
     3415                return false; 
     3416 
     3417        include_once ($_SESSION['rootPath'] . '/calendar/inc/class.ex_participants.inc.php'); 
     3418        $exParticipants = new exParticipants(); 
     3419        $exParticipants->setParticipantsBySerializable($row['ex_participants']); 
     3420        $exParticipants->updateParticipant($mail, $situation, $cn); 
     3421        $query = 'UPDATE phpgw_cal SET ex_participants = \'' . $exParticipants->getParticipantsSerializable() . '\' WHERE uid = \'' . trim($cal_uid) . '\''; 
     3422        if (!$db->query($query)) 
     3423                return false; 
     3424 
     3425        return true; 
     3426} 
     3427} 
    36593428?> 
  • trunk/calendar/inc/class.socalendar.inc.php

    r4316 r5132  
    193193                function find_uid($uid) 
    194194                { 
    195                         $sql = " AND (phpgw_cal.uid = '".$uid."') "; 
     195                        $uid_ = substr($uid, strpos($uid,"-")+1);                                
     196                        $uid_ = substr($uid_, 0, strpos($uid_,"-"));                             
     197                         
     198                        $sql = " AND (phpgw_cal.cal_id = '". (int)$uid_."') "; 
    196199 
    197200                        $found = $this->cal->get_event_ids(False,$sql); 
     
    210213                } 
    211214 
    212                 function add_entry(&$event) 
    213                 { 
    214                         return $this->cal->save_event($event); 
     215                 
     216                /* 
     217                 * @abstract: Retorna o email do organizer do evento.  
     218                 */ 
     219                function get_mail_organizer($cal_id) 
     220                { 
     221                        $sql = 'SELECT organizer FROM phpgw_cal WHERE cal_id =' . $cal_id;       
     222                        $this->cal->stream->query($sql,__LINE__,__FILE__); 
     223                         
     224                        while($this->cal->stream->next_record()) 
     225                        { 
     226                                $ret[0] = $this->cal->stream->f('organizer'); 
     227                        } 
     228                         
     229                        $return = $ret[0]; 
     230                        $pos = strpos($return, "<"); 
     231                        $return = substr($return, $pos); 
     232                        $return = str_replace('"','',$return); 
     233                        $return = str_replace('>','',$return); 
     234                        $return = str_replace('<','',$return); 
     235                         
     236                        return $return; 
     237                } 
     238                 
     239                 
     240                /* 
     241                 * @abstract: Retorna os emails dos participantes do evento. 
     242                 */ 
     243                function get_mail_participants($cal_id) 
     244                { 
     245                 
     246                } 
     247                 
     248                 
     249                /* 
     250                 * @abstract: busca no banco pra verificar se já existe um compromisso com o mesmo cal_id 
     251                 */ 
     252                function find_cal_id($cal_id) 
     253                { 
     254 
     255                        $uid_ = substr($cal_id, strpos($cal_id,"-")+1); 
     256                        $uid_ = substr($uid_, 0, strpos($uid_,"-")); 
     257 
     258                        $sql = " AND phpgw_cal.cal_id = '". (int)$uid_."' OR phpgw_cal.uid = '". $cal_id."' "; 
     259 
     260                        $found = $this->cal->get_event_ids(False,$sql); 
     261                        if(!$found) 
     262                        { 
     263                                $found = $this->cal->get_event_ids(True,$sql); 
     264                        } 
     265                        if(is_array($found)) 
     266                        { 
     267                                return $found[0];  
     268                        } 
     269                        else 
     270                        { 
     271                                return False; 
     272                        } 
     273                } 
     274                 
     275 
     276                function add_entry(&$event , $sendMail = true, $importAccount = false) 
     277                { 
     278                        return $this->cal->save_event($event,$sendMail,$importAccount); 
    215279                } 
    216280 
     
    269333                } 
    270334 
    271                 function set_status($id,$status) 
    272                 { 
    273                         $this->cal->set_status($id,$this->owner,$status); 
     335                function set_status($id,$status,$user = false) 
     336                { 
     337                    if($user) $this->cal->set_status($id,$user,$status); 
     338                    else $this->cal->set_status($id,$this->owner,$status); 
    274339                } 
    275340 
     
    369434                        $this->cal->set_description($description); 
    370435                } 
    371  
    372                 function set_observations($observations='') 
    373                 { 
    374                     $this->cal->set_observations($observations); 
    375                 } 
    376  
    377                 function set_attachment($attachment='') 
    378                 { 
    379                         $this->cal->set_attachment($attachment); 
    380                 } 
    381  
    382                 function set_notifications_owner($notifications_owner='')  
    383                 {  
    384                 $this->cal->set_notifications_owner($notifications_owner);  
    385             } 
    386                  
    387436                function set_ex_participants($ex_participants='') 
    388437                { 
  • trunk/calendar/inc/class.socalendar__.inc.php

    r4321 r5132  
    102102                } 
    103103 
    104                 function set_observations($observations='') 
    105                 { 
    106                     $this->add_attribute('observations',$observations); 
    107                 } 
    108  
    109                 function set_notifications_owner($notifications_owner='')  
    110                 {  
    111                 $this->add_attribute('notifications_owner',$notifications_owner);  
    112             }  
    113                  
    114                 function set_alter_by($alter_by='') 
    115                 { 
    116                     $this->add_attribute('alter_by',$alter_by); 
    117                 } 
    118  
    119                 function set_attachment($attachment='') 
    120                 { 
    121                         $this->add_attribute('attachment',$attachment); 
    122                 } 
    123  
    124104                function set_ex_participants($ex_participants='') 
    125105                { 
  • trunk/calendar/inc/class.socalendar_sql.inc.php

    r4316 r5132  
    1313  *  option) any later version.                                              * 
    1414  \**************************************************************************/ 
    15  
     15if($_SESSION['isCrun']){ 
     16        $_SESSION['isCrun'] = false; 
     17        $_SESSION['rootPath'] = PHPGW_INCLUDE_ROOT; 
     18        require_once $_SESSION['rootPath'].'/API/class.servicelocator.php'; 
     19}else{ 
     20        require_once $_SESSION['rootPath'].'/API/class.servicelocator.php'; 
     21} 
    1622 
    1723        if (@$GLOBALS['phpgw_info']['flags']['included_classes']['socalendar_']) 
     
    569575                                $this->set_title(stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('title')))); 
    570576                                $this->set_description(stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('description')))); 
    571                                 $this->set_observations(stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('observations')))); 
    572                                 $this->set_notifications_owner(stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('notifications_owner')))); 
    573                                 $this->set_alter_by(stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('alter_by')))); 
    574                                 $this->set_attachment(stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('attachment')))); 
    575577                                $this->set_ex_participants(stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('ex_participants')))); 
    576578                                $this->add_attribute('uid',$GLOBALS['phpgw']->strip_html($this->stream->f('uid'))); 
    577579                                $this->add_attribute('location',stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('location')))); 
     580                                $this->add_attribute('organizer',stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('organizer')))); 
    578581                                $this->add_attribute('reference',(int)$this->stream->f('reference')); 
    579582 
     
    737740                        else 
    738741                        { 
    739                                 //$user_where .= $this->user; 
    740742                                $user_where .= $this->user . ') OR (phpgw_cal.owner=' . $this->user; 
    741743                        } 
     
    902904                } 
    903905 
    904                 function save_event(&$event) 
     906                function save_event(&$event,$sendMail = true, $importAccount = false) 
    905907                { 
    906908 
     
    954956                        $enddate = $this->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; 
    955957                        $today = time() - $GLOBALS['phpgw']->datetime->tz_offset; 
    956 // 
    957 //                      if($event['recur_type'] != MCAL_RECUR_NONE) 
    958 //                      { 
    959 //                              $type = 'M'; 
    960 //                      } 
    961 //                      else 
    962 //                      { 
     958 
     959 
    963960                                if ($event['type'] == 'hourAppointment') 
    964961                                        $type = 'H'; 
     
    967964                                }else 
    968965                                        $type = 'E'; 
    969 //                      } 
    970                         if(is_array($event['attachment'])) 
    971                             $sattach=serialize($event['attachment']); 
    972                         else if(is_array(unserialize($event['attachment']))) 
    973                             $sattach=$event['attachment']; 
    974                         else 
    975                             $sattach=''; 
     966                         
    976967 
    977968                        $sql = 'UPDATE phpgw_cal SET ' 
     
    986977                                        . "title='".$this->stream->db_addslashes($event['title'])."', " 
    987978                                        . "description='".$this->stream->db_addslashes($event['description'])."', " 
    988                                         . "observations='".$this->stream->db_addslashes($event['observations'])."', " 
    989                     . 'notifications_owner='.(int)$event['notifications_owner'].',' 
    990                                         . "attachment='".$this->stream->db_addslashes($sattach)."', " 
    991                                         . "alter_by='".$this->stream->db_addslashes($GLOBALS['phpgw_info']['user']['fullname'])."', " 
    992979                                        . "ex_participants='".$this->stream->db_addslashes($event['ex_participants'])."', " 
     980                                        . "organizer='".$this->stream->db_addslashes($event['organizer'])."', " 
    993981                                        . "location='".$this->stream->db_addslashes($event['location'])."', " 
    994982                                        . ($event['groups']?"groups='".(count($event['groups'])>1?implode(',',$event['groups']):','.$event['groups'][0].',')."', ":'') 
     
    10951083                        $GLOBALS['phpgw_info']['cal_new_event_id'] = $event['id']; 
    10961084                        $this->event = $event; 
     1085 
     1086                        if($sendMail) 
     1087                        { 
     1088                            if($importAccount) 
     1089                                $this->sendEmailEvendAccepted($event,$importAccount); 
     1090                            else 
     1091                                $this->sendEmailEvendAccepted($event); 
     1092                        } 
     1093         
    10971094                        return True; 
    10981095                } 
     1096 
     1097                function sendEmailEvendAccepted($event,$importAccount = false) 
     1098                { 
     1099 
     1100                    if(!$importAccount) 
     1101                        $importAccount['mail'] = $GLOBALS['phpgw_info']['user']['email']; 
     1102 
     1103                    //verifica se eh um evento externo se sim envia o vcard de aceitação em anexo 
     1104                    if($event['owner'] == '-2') 
     1105                    { 
     1106                        $mailService = ServiceLocator::getService('mail'); 
     1107 
     1108                        $tmpbody.= "<b>".lang("Event Accepted")."</b> "; 
     1109                        $tmpbody.= "<br><br>".lang("name").": ".$event['title']."<br>"; 
     1110                        $tmpbody.= "<br>".lang("description").": ".$event['description']."<br>"; 
     1111 
     1112                        $ev[0] = $event; 
     1113 
     1114                        $tmpattach=  $GLOBALS['calendar']->bocalendar->create_vcard($ev,'REPLY',true,$importAccount); 
     1115                         
     1116                        $mailService->addStringAttachment($tmpattach, 'suggestion.ics', 'application/ics'); 
     1117                        $mailService->addStringAttachment($tmpattach, 'vcalendar.ics', 'utf-8', 'text/calendar; charset=utf-8; method=REPLY;', '7bit', ''); 
     1118                  
     1119                        if(strchr($event['organizer'],'@') && strchr($event['organizer'],'<') && strchr($event['organizer'],'>')) 
     1120                        { 
     1121                            $mail = substr($event['organizer'], strpos($event['organizer'],'<'), strpos($event['organizer'],'>')); 
     1122                            $mail = str_replace('<','', str_replace('>','',$mail)); 
     1123                        } 
     1124 
     1125                        if($mail) 
     1126                            $mailService->sendMail($mail,$importAccount['mail'],$event['title'],$tmpbody); 
     1127 
     1128                    } 
     1129                    else 
     1130                        $GLOBALS['calendar']->bocalendar->send_update(MSG_ACCEPTED, $event['participants'],$event); 
     1131 
     1132                    return; 
     1133                } 
    10991134 
    11001135                function get_alarm($cal_id) 
  • trunk/calendar/inc/class.uialarm.inc.php

    r204 r5132  
    136136                                if ($alarm_time <= time()) 
    137137                                { 
    138                                         echo lang('Alarm is older than now!!!'); 
     138                                        echo    '<center>'.lang('Alarm is older than now!!!').'</center><center>'. 
     139                                                        '<form method="POST" action="'.$GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uialarm.manager')).'">'. 
     140                                                        '<input type="hidden" value="'.$this->bo->cal_id.'" name="cal_id">'. 
     141                                                        '<input type="hidden" value="'.$_POST['return_to'].'" name="return_to">'. 
     142                                                        '<center><input type="submit" value="'.lang("Back").'"/></center></form></center>' ; 
    139143                                        $GLOBALS['phpgw']->common->phpgw_exit(True); 
    140144                                } 
     
    143147                                        if ($object['time'] == $alarm_time) 
    144148                                        { 
    145                                                 echo '<center>'.lang('Alarm already added!!!').'</center>'; 
     149                                                echo '<center>'.lang("Alarm already added!!!").'</center><center>'. 
     150                                                         '<form method="POST" action="'.$GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uialarm.manager')).'">'. 
     151                                                         '<input type="hidden" value="'.$this->bo->cal_id.'" name="cal_id">'. 
     152                                                         '<input type="hidden" value="'.$_POST['return_to'].'" name="return_to">'. 
     153                                                         '<center><input type="submit" value="'.lang("Back").'"/></center></form></center>' ; 
    146154                                                $GLOBALS['phpgw']->common->phpgw_exit(True); 
    147155                                        } 
     
    151159                                { 
    152160                                        echo '<center>'.lang('You do not have permission to add alarms to this event !!!').'</center>'; 
     161                                        $GLOBALS['phpgw']->common->phpgw_exit(True); 
     162                                } 
     163                                 
     164                                if ($time == 0) 
     165                                { 
     166                                        echo '<center>'.lang("Invalid Alarm!!!").'</center><center>'. 
     167                                                         '<form method="POST" action="'.$GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uialarm.manager')).'">'. 
     168                                                         '<input type="hidden" value="'.$this->bo->cal_id.'" name="cal_id">'. 
     169                                                         '<input type="hidden" value="'.$_POST['return_to'].'" name="return_to">'. 
     170                                                         '<center><input type="submit" value="'.lang("Back").'"/></center></form></center>' ; 
    153171                                        $GLOBALS['phpgw']->common->phpgw_exit(True); 
    154172                                } 
     
    189207                                                'data'     => lang('Email Notification'), 
    190208                                                'owner'    => $GLOBALS['phpgw']->common->grab_owner_name($alarm['owner']), 
    191                                                 'enabled'  => $this->html->image('calendar',$alarm['enabled']?'enabled':'disabled',$alarm['enabled']?'enabled':'disabled','width="13" height="13"'), 
    192209                                                'select'   => $this->html->checkbox("alarm[$alarm[id]]") 
    193210                                        ); 
     
    198215                                        $this->output_template_array('rows','list',$var); 
    199216                                } 
    200                                 $this->template->set_var('enable_button',$this->html->submit_button('enable','Enable')); 
    201                                 $this->template->set_var('disable_button',$this->html->submit_button('disable','Disable')); 
     217 
    202218                                if ($to_delete) 
    203219                                { 
     
    222238                                        'return_to' => $_POST['return_to'] 
    223239                                )), 
    224                                 'lang_enable'   => lang('Enable'), 
    225                                 'lang_disable'  => lang('Disable'), 
    226240                                'input_cancel'  => $this->html->submit_button('cancel','Cancel') 
    227241                        )); 
  • trunk/calendar/inc/class.uicalendar.inc.php

    r4844 r5132  
    5757 
    5858                var $public_functions = array( 
    59                         'screen_delegate_event' => True, 
    60                         'delegate_event' => True, 
    6159                        'mini_calendar' => True, 
    6260                        'index' => True, 
     
    6765                        'year' => True, 
    6866                        'view' => True, 
     67                        //'suggest' => True, 
     68                        'send_suggest_owner' => True, 
    6969                        'edit' => True, 
    7070                        'export'        => True, 
     
    9292                function uicalendar() 
    9393                { 
     94                    $GLOBALS['phpgw_info']['flags']['noappheader'] = True; 
     95                        $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; 
     96                        $GLOBALS['phpgw_info']['flags']['currentapp'] = 'calendar'; 
     97                        include_once( $_SESSION['rootPath'].'/header.inc.php' ); 
     98 
    9499                        $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs'); 
    95100                        $GLOBALS['phpgw']->browser    = CreateObject('phpgwapi.browser'); 
     
    163168                        } 
    164169                        $this->html = &$GLOBALS['phpgw']->html; 
    165                 } 
    166  
    167                 function screen_delegate_event($params=NULL) { 
    168                         $module_name = 'expressoMail'.(str_replace("1.","1_",$GLOBALS['phpgw_info']['server']['cal_expressoMail'])); 
    169  
    170                         $sb = CreateObject('phpgwapi.sbox2'); 
    171                         $jscal = CreateObject('phpgwapi.jscalendar');   // before phpgw_header() !!! 
    172                         unset($GLOBALS['phpgw_info']['flags']['noheader']); 
    173                         unset($GLOBALS['phpgw_info']['flags']['nonavbar']); 
    174                         $GLOBALS['phpgw_info']['flags']['noappheader'] = True; 
    175                         $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; 
    176                         $GLOBALS['phpgw_info']['flags']['app_header'] = $event['id'] ? lang('Calendar - Edit') : lang('Calendar - Delegate Event');  
    177                         $GLOBALS['phpgw']->common->phpgw_header(); 
    178  
    179                         $ldap_manager = CreateObject('contactcenter.bo_ldap_manager'); 
    180                         $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user']; 
    181                         $_SESSION['phpgw_info']['expressomail']['user']['owner'] = $event['owner']; 
    182                         $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server']; 
    183                         $_SESSION['phpgw_info']['expressomail']['ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; 
    184                         $context = $GLOBALS['phpgw_info']['server']['ldap_context']; 
    185                         $user_context = array(); 
    186                         foreach(explode(",",$GLOBALS['phpgw_info']['user']['account_dn']) as $i => $dn_part){ 
    187                                 if($i) 
    188                                         $user_context[] = $dn_part; 
    189                         } 
    190                         // Prepara o contexto do usuario com sua OU raiz, pois ele pode pertencer a uma OU de nivel N. 
    191                         $user_ou = explode(",",str_replace($context,"",implode(",",$user_context))); 
    192                         $user_context = trim(strtolower($user_ou[count($user_ou) - 2].",".$context)); 
    193                         // Fim 
    194                         // Verifica o tipo da visualização da árvore LDAP, configurado no admin da Agenda 
    195                         $recursive = $GLOBALS['phpgw_info']['server']['cal_type_tree_participants'] == '1' ? true : false; 
    196                         $combo_org = $this->get_organizations(trim(strtolower($context)),$user_context, $recursive); 
    197  
    198                         $var = array( 
    199                                 "module_name"           => $module_name, 
    200                                 "lang_loading"          => lang("Loading"), 
    201                                 "lang_searching"        => lang("Searching"), 
    202                                 "lang_users"            => lang("Users"), 
    203                                 "lang_groups"           => lang("Groups"), 
    204                                 "recursive"             => ($recursive)?"":"search", 
    205                                 "options"               => $combo_org, 
    206                                 "id_event"              => $_REQUEST["id_event"], 
    207                                 "eventArray"            => $_REQUEST["eventArray"], 
    208                                 "delegator"             => $_REQUEST["delegator"], 
    209                                 "lang_avaliable_users"  => lang("Available Users and Groups"), 
    210                                 "lang_search_for"       => lang("Search for"), 
    211                                 "lang_ou"               => lang("Organization"), 
    212                                 "min_num_characters"    => $GLOBALS['phpgw_info']['server']['min_num_characters'], 
    213                                 "date"                  => $_REQUEST["date"], 
    214                                 "eventDelegation"       => 1, 
    215                                 "Delegate"              => lang("Delegate"), 
    216                                 'url_template'          => 'calendar/templates/'.$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set'] 
    217                         ); 
    218  
    219                         if(isset($_REQUEST["error"])) 
    220                         { 
    221                                 if($_REQUEST["error"] == 999){ 
    222                                         $var['error_msg'] = lang("Problems delegating. Make sure you have selected a user to delegate the appointment."); 
    223                                 }else { 
    224                                         $var['error_msg'] = lang("Problems delegating. Make sure you haven't delegated to a person that was also invited to the meeting"); 
    225                                 } 
    226                         } 
    227  
    228                         $template = CreateObject('phpgwapi.Template',$this->template_dir); 
    229                         $template->set_file( 
    230                                         array( 
    231                                                 "screen"=>"delegate.tpl" 
    232                                         ) 
    233                                 ); 
    234                         $template->set_var($var); 
    235                         print $template->fp('out','screen'); 
    236                 } 
    237  
    238  
    239                 function delegate_event($params=NULL) { 
    240                         //$ldap = CreateObject('expressoMail1_2.ldap_functions'); 
    241                         //$delegated = $ldap->uid2uidnumber($_REQUEST['delegated']); 
    242  
    243                         try { 
    244                                 $this->bo->delegar($_REQUEST['delegator'],$_REQUEST['delegated']/*$delegated*/,$_REQUEST['event']); 
    245                                 header("Location: index.php?menuaction=calendar.uicalendar.day&date=".$_REQUEST['date']); 
    246                         }catch(Exception $e) { 
    247                                 if($e->getMessage() == '999') { 
    248                                         header("Location: index.php?menuaction=calendar.uicalendar.screen_delegate_event&id_event=". $_REQUEST["event"]."&delegator=".$_REQUEST["delegator"]."&date=".$_REQUEST["date"]."&error=999"); 
    249                                 }else { 
    250                                         header("Location: index.php?menuaction=calendar.uicalendar.screen_delegate_event&id_event=". $_REQUEST["event"]."&delegator=".$_REQUEST["delegator"]."&date=".$_REQUEST["date"]."&error=1"); 
    251                                 } 
    252                         } 
    253170                } 
    254171 
     
    392309                                                { 
    393310//NDEE: class def what for? 
    394                                                     $dayToday = (int)(substr($today,6,2)); 
    395                                                     $seleDay = (int)(substr($_GET['date'],6,2)); 
    396                                                     if($day == $dayToday) 
    397                                                     { 
    398                                                         if($dayToday == $seleDay) 
    399                                                         { 
    400                                                             $day_params['class'] = 'minicaltodaysel'; 
    401                                                         } 
    402                                                         else 
    403                                                         { 
    404                                                             $day_params['class'] = 'minicaltoday'; 
    405                                                         } 
    406                                                     } 
    407  
    408                                                     if( isset($params['control']) && $params['control'] ) 
    409                                                     { 
    410                                                         if($day == $seleDay && $dayToday != $seleDay) 
    411                                                         { 
    412                                                             $day_params['class'] = 'minicalnottoday'; 
    413                                                         } 
    414                                                     } 
    415  
    416                                                         $str = '<a href="'.$this->page($params['link'],'&date='.$date).'" class="'.$day_params['class'].'" ' . ($day_params['class']=='bminicalhol' || $day_params['class']=='minicalhol'?' title="' . $day_params['holidays'][0] . '" ' :'') . ' >'.$day.'</a>'; 
     311                                                        $str = '<a href="'.$this->page($params['link'],'&date='.$date).'" class="'.$day_params['class'].'">'.$day.'</a>'; 
    417312                                                } 
    418313                                                else 
     
    473368                        $_SESSION['calendar']['categories'] = $this->cat->formated_list('select','all',$this->bo->cat_id,'True'); 
    474369                        if((!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && count($this->bo->grants) > 0) 
     370                        {        
    475371                                $_SESSION['calendar']['cals'] = $this->bo->list_cals(); 
     372                        } 
    476373 
    477374                        if($this->bo->printer_friendly || $_GET['plain'] == 'True') 
    478375                        {        
    479                                 $app_css_path = $_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set']; 
    480                                 $app_print_css_path = $app_css_path; 
    481                                 if (!file_exists($GLOBALS['phpgw_info']['server']['webserver_url'].'/calendar/templates/'.$app_css_path.'/app.css')) 
    482                                         $app_css_path = 'default'; 
    483                                 if (!file_exists($GLOBALS['phpgw_info']['server']['webserver_url'].'/calendar/templates/'.$app_print_css_path.'/app_print.css')) 
    484                                         $app_print_css_path = 'default'; 
    485  
    486376                                $new_body = '<html>'."\n" 
    487377                                        .'<head>'."\n" 
    488                                         .'<LINK href="'.$GLOBALS['phpgw_info']['server']['webserver_url'].'/calendar/templates/'.$app_css_path.'/app.css" type=text/css rel=StyleSheet>'."\n" 
    489                                         .'<LINK href="'.$GLOBALS['phpgw_info']['server']['webserver_url'].'/calendar/templates/'.$app_print_css_path.'/app_print.css" type=text/css rel=StyleSheet media="print">'."\n" 
     378                                        .'<SCRIPT type="text/javascript"> 
     379                                                window.onbeforeunload = function() { 
     380                                                        return \'Gostaria realmente de fechar essa janela ?\'; 
     381                                                }                                        
     382                                        </SCRIPT>' 
     383                                        .'<LINK href="'.$GLOBALS['phpgw_info']['server']['webserver_url'].'/calendar/templates/'.$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set'].'/app.css" type=text/css rel=StyleSheet>'."\n" 
     384                                        .'<LINK href="'.$GLOBALS['phpgw_info']['server']['webserver_url'].'/calendar/templates/'.$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set'].'/app_print.css" type=text/css rel=StyleSheet media="print">'."\n" 
    490385                                        .'</head> 
    491386                                        <table id="calendar_print_main" class="calendar_print_main">                                             
     
    493388                                                        <td id="calendar_print_content" class="calendar_print_content">'.$body.'</td> 
    494389                                                </tr> 
     390                                                 
    495391                                                <tr> 
    496392                                                  <td> 
     393                                                        <br/> 
     394                                                        <br/> 
    497395                                                        <div> 
    498396                                                                <input class=button type="button" onClick="javascript:this.style.visibility=\'hidden\';window.print();window.close();" value="Imprimir esta p&aacute;gina"> 
     
    516414                                 
    517415                                $GLOBALS['phpgw']->common->phpgw_header(); 
    518                                 $new_body = $this->bo->debug_string.$body;                               
    519416                                 
    520                         } 
     417                                $new_body = $this->bo->debug_string.$body;                                                               
     418                } 
     419 
     420 
     421 
     422                         
    521423                        return $new_body; 
    522                 } 
     424                        } 
    523425 
    524426                function month() 
    525                 { 
    526                         if($_GET['month']||$_POST['month']){ 
    527                             $params['month'] = $_GET['month']?(int)$_GET['month']:(int)$_POST['month']; 
    528                             $params['year'] = $_GET['year']?(int)$_GET['year']:(int)$_POST['year']; 
    529                             $params['day'] = 1; 
    530  
    531                         }else{ 
    532                             $params['day'] = $_POST['date']?(int)substr($_POST['date'] , 6, 2):(int)substr($_GET['date'] , 6, 2); 
    533                             $params['month'] = $_POST['date']?(int)substr($_POST['date'] , 4, 2):(int)substr($_GET['date'] , 4, 2); 
    534                             $params['year'] = $_POST['date']?(int)substr($_POST['date'] , 0, 4):(int)substr($_GET['date'] , 0, 4); 
    535  
    536                         } 
    537  
    538                         if($_GET['friendly']==1) 
    539427                        { 
    540428                            echo $this->printer_friendly($this->get_month(),lang('Monthview')); 
    541                         } 
    542                         else 
    543                         { 
    544                             echo $this->printer_friendly($this->print_month_new($params),lang('Monthview')); 
    545                         } 
    546  
    547429                        $GLOBALS['phpgw']->common->phpgw_footer(); 
    548430                } 
     
    550432                function get_month() 
    551433                { 
     434                        $this->bo->read_holidays(); 
     435                         
    552436                        $m = mktime(0,0,0,$this->bo->month,1,$this->bo->year); 
    553437 
     
    594478                                $minical_next = ''; 
    595479                        } 
    596                         $this->bo->read_holidays($params['year']); 
     480 
    597481                        if($_POST['year']) {                     
    598482         
    599483                        } 
    600484 
     485                        $hoje = date('Ymd',$GLOBALS['phpgw']->datetime->gmtnow); 
     486                        $mes_hoje = (int)substr($hoje,4,2); 
     487                        $sday = 1; 
     488                        if($_POST['day']) { 
     489                                $day_ini = (int)$_POST['day']; 
     490                        }  
     491                        elseif($_GET['sday']){ 
     492                                if($_GET['month'] == $mes_hoje) 
     493                        { 
     494                                        $day_ini = $this->bo->day; 
     495                                }  
     496 
     497                                else 
     498                                { 
     499                                        $day_ini = (int)$_GET['sday']; 
     500                                } 
     501                        }  
     502                        elseif( ($_POST['dia_ini']) && ($_POST['dia_ini'] == $this->bo->day) ) 
     503                        { 
     504                                $day_ini = (int)substr($hoje,6,2); 
     505                        } 
     506                        else 
     507                        { 
     508                                $day_ini = $this->bo->day; 
     509                        } 
     510                        if($_POST['qtd_dias']) 
     511                        { 
     512                                $num_dias = (int)$_POST['qtd_dias']; 
     513                        }  
     514                        else 
     515                        { 
     516                                $num_dias = 0; 
     517                        } 
     518 
    601519                        if (!$this->bo->printer_friendly) 
    602520                        { 
    603                             $account_name = $_POST['user'] ? $_POST['user'] : ($_GET['account_name'] ? $_GET['account_name'] : ''); 
    604  
    605                             $accounts = CreateObject('phpgwapi.accounts'); 
    606                             $accountId = $accounts->name2id($account_name); 
    607  
    608                             $prefs = CreateObject('phpgwapi.preferences', $accountId); 
    609                             $account_prefs = $prefs->read(); 
    610  
    611521                            $printer = ''; 
    612522                            $prev_month_link = '<a href="'.$this->page('month','&year='.$prevyear.'&month='.$prev.'&sday='.$sday).'">&lt;&lt;</a>'; 
     
    614524                            $param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'.'&day_ini='.$day_ini.'&num_dias='.$num_dias; 
    615525                            //$param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'; 
    616                             /*if($account_prefs['calendar']['type_month_print'] == '0') 
    617                             { 
    618526                            $print = "<a href='javascript:void(0)' onClick=\"javascript:window.open('".$this->page('month'.$param). 
    619527                                            "','','width=600,height=600,toolbar=no,scrollbars=yes,resizable=no');\" onMouseOver=\"window.status = '". 
    620528                                            lang('Generate printer-friendly version')."'\">[".lang('Printer Friendly').']</a>'; 
    621                             } 
    622                             else 
    623                             { 
    624                             $print =  '<a href="javascript:void(0)" onclick="scheduler.toPDF('."'calendar/js/dhtmlx/server/generate.php'".')">['.lang('Printer Friendly').']</a>'; 
    625                             }*/ 
    626  
    627529                            //linha abaixo foi adicionada para exibir a pagina do mes em tela 
    628                             //$month,$year,$showyear,$owner=0; 
    629                             $params = Array( 
    630                                 'month' => $this->bo->month, 
    631                                 'year'  => $this->bo->year, 
    632                                 'showyear'      => True, 
    633                                 'owner' => $this->bo->owner 
    634                             ); 
    635                             $large_month = $this->display_month($params); 
     530                                $large_month = $this->display_month($this->bo->month,$this->bo->year,True,$this->bo->owner);                             
    636531                        } 
    637532                        else 
     
    643538                            $GLOBALS['phpgw_info']['flags']['nofooter'] = True; 
    644539                            //linha abaixo foi adicionada para exibir a pagina do mes para impressao 
    645  
    646                             //if($_GET['classic_print']==1) 
    647                             //  $large_month = $this->display_month($this->bo->month,$this->bo->year,True,$this->bo->owner); 
    648                             //else 
    649540                            $large_month = $this->display_month_print($this->bo->month,$this->bo->year,True,$this->bo->owner); 
    650541                        } 
    651542 
    652543                        $this->bo->read_holidays(); 
    653  
    654                         $aux_month_identifier = lang(strftime("%B",$m)).' '.$this->bo->year; 
    655                         if(isset($_GET['friendly']) && $_GET['friendly'] ==1) 
    656                         { 
    657                             if( isset($_GET['num_dias']) && ($_GET['num_dias'] == 1) ) 
    658                             { 
    659                                 $year = $_GET['year']; 
    660                                 $month = $_GET['month']; 
    661                                 $day = $_GET['day_ini']; 
    662                                 $aux_month_identifier = $this->month_day_of_week($year,$month,$day).', '.$day.' de '.lang(strftime("%B",$m)).' de '.$this->bo->year; 
    663                             } 
    664                         } 
    665544 
    666545                        $var = Array( 
     
    669548                                'small_calendar_prev'       => $minical_prev, 
    670549                                'prev_month_link'           => $prev_month_link, 
    671                                 'month_identifier'          => $aux_month_identifier, 
     550                                'month_identifier'              =>      lang(strftime("%B",$m)).' '.$this->bo->year, 
    672551                                'username'                  => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner), 
    673552                                'next_month_link'           => $next_month_link, 
    674553                                'small_calendar_next'       => $minical_next, 
     554                                //'large_month'                         =>      $this->display_month($this->bo->month,$this->bo->year,True,$this->bo->owner), 
    675555                                'large_month'               => $large_month, 
    676556                                'print'                     => $print 
     
    700580                function week() 
    701581                { 
    702  
    703                         if($_GET['month']||$_POST['month']){ 
    704                             $params['month'] = $_GET['month']?(int)$_GET['month']:(int)$_POST['month']; 
    705                             $params['year'] = $_GET['year']?(int)$_GET['year']:(int)$_POST['year']; 
    706                             $params['day'] = $_GET['day']?(int)$_GET['day']:(int)$_POST['day']; 
    707  
    708                         }else{ 
    709                             $params['day'] = $_POST['date']?(int)substr($_POST['date'] , 6, 2):(int)substr($_GET['date'] , 6, 2); 
    710                             $params['month'] = $_POST['date']?(int)substr($_POST['date'] , 4, 2):(int)substr($_GET['date'] , 4, 2); 
    711                             $params['year'] = $_POST['date']?(int)substr($_POST['date'] , 0, 4):(int)substr($_GET['date'] , 0, 4); 
    712  
    713                         } 
    714  
    715                         echo $this->printer_friendly($this->print_week_new($params),lang('Weekview')); 
    716                          
     582                        echo $this->printer_friendly($this->get_week(),lang('Weekview')); 
    717583                        $GLOBALS['phpgw']->common->phpgw_footer(); 
    718584                } 
     
    727593                        if (isset($this->bo->prefs['calendar']['display_minicals']) && $this->bo->prefs['calendar']['display_minicals'] == "1" && !$this->bo->printer_friendly) 
    728594                        { 
     595                                $minical_this = $this->mini_calendar( 
     596                                        Array( 
     597                                                'day'   => $this->bo->day, 
     598                                                'month' => $this->bo->month, 
     599                                                'year'  => $this->bo->year, 
     600                                                'link'  => 'day', 
     601                                                'butons'        => 'none', 
     602                                                'outside_month' => False 
     603                                        ) 
     604                                ); 
    729605                                $minical_prev = $this->mini_calendar( 
    730606                                        Array( 
     
    747623                                        ) 
    748624                                ); 
    749                                 $minical_this = $this->mini_calendar( 
    750                                         Array( 
    751                                                 'day'   => $this->bo->day, 
    752                                                 'month' => $this->bo->month, 
    753                                                 'year'  => $this->bo->year, 
    754                                                 'link'  => 'day', 
    755                                                 'butons'        => 'none', 
    756                                                 'outside_month' => False 
    757                                         ) 
    758                                 ); 
    759625                        } 
    760626                        else 
    761627                        { 
    762628 
    763                         //NDEE: printer-friendly what? 
     629//NDEE: printer-friendly what? 
    764630                                $minical_this = ''; 
    765631                                $minical_prev = ''; 
     
    773639                                $prev_week_link = '<a href="'.$this->page('week','&date='.$prev['full']).'">&lt;&lt;</a>'; 
    774640                                $next_week_link = '<a href="'.$this->page('week','&date='.$next['full']).'">&gt;&gt;</a>'; 
    775                                 $print = '<a href="javascript:void(0);" onclick="scheduler.toPDF('."'calendar/js/dhtmlx/server/generate.php'".')">['.lang('Printer Friendly').']</a>'; 
    776                                  
    777                                 //$print = '<a href="'.$this->page('week','&friendly=1&date='.sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day))."\" TARGET=\"cal_printer_friendly\" onMouseOver=\"window.status = '".lang('Generate printer-friendly version')."' \">[".lang('Printer Friendly').']</a>'; 
     641                                $print = '<a href="'.$this->page('week','&friendly=1&date='.sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day))."\" TARGET=\"cal_printer_friendly\" onMouseOver=\"window.status = '".lang('Generate printer-friendly version')."'\">[".lang('Printer Friendly').']</a>'; 
    778642                        } 
    779643                        else 
    780644                        { 
    781645 
    782                                 //NDEE: printer-friendly (weekly-view) 
     646//NDEE: printer-friendly (weekly-view) 
    783647                                $printer = '<body bgcolor="'.$this->theme['bg_color'].'">'; 
    784648                                $prev_week_link = ''; 
     
    807671                                'print'                 =>      $print 
    808672                        ); 
    809                         //todo 
     673//todo 
    810674                        $p = CreateObject('phpgwapi.Template',$this->template_dir); 
    811675                        $p->set_file( 
     
    968832                        ); 
    969833 
    970                         $button_left = $button_center = $button_right = ''; 
     834                        $p->set_file(Array('form_button'                        => 'form_button_script.tpl'     )); 
     835 
     836                        $button_left = $button_center = $button_right = $button_right_suggestion = ''; 
    971837 
    972838                        if($this->bo->check_perms(PHPGW_ACL_EDIT,$event)) 
     
    976842                                        $var = Array( 
    977843                                                'action_url_button'     => $this->page('edit','&cal_id='.$cal_id), 
     844                                                // added date to the action parameteres so we can add an exception to an edited event  
     845                                                'action_url_button'     => $this->page('edit','&cal_id='.$cal_id.'&date='.$date),  
    978846                                                'action_text_button'    => lang('Edit Single'), 
    979847                                                'action_confirm_button' => '', 
     
    1027895                                                'action_url_button'     => $this->page('delete','&cal_id='.$cal_id), 
    1028896                                                'action_text_button'    => lang('Delete Single'), 
    1029                                                 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this single occurence?').'\\n'.lang('This will delete this entry for all users.')."')\"", 
     897                                                'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this single occurence?\\nThis will delete this entry for all users.')."')\"", 
    1030898                                                'action_extra_field'    => $this->html->input_hidden(array( 
    1031899                                                        'delete_type' => 'single', 
     
    1092960                                } 
    1093961                        } 
     962                        $uid             = $event['uid']; 
     963                        $owner           = $event['owner']; 
     964                        $title           = $event['title']; 
     965                        $description     = rtrim(utf8_encode($event['description']));  
     966                        $location        = $event['location']; 
     967                        $start                   = $event['start']; 
     968                        $end                 = $event['end']; 
     969                        
     970                        $p->set_var( 'suggestion', $this->build_suggestion( $event , $GLOBALS['phpgw_info']['user']['account_id']) ); 
    1094971 
    1095972                        $var = Array( 
     
    1113990                                $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; 
    1114991                        } 
     992                         
     993                        $label_suggest = lang('Suggest new hour');  
     994                        $button_right_suggestion = "<td><input type=\"button\" style=\"height: 16px; width: 110px; font-size: 10px;\" value=\"" . $label_suggest . "\"onclick=\"show_suggestion()\";</td>";  
     995                         
    1115996                        $p->set_var(array( 
    1116997                                'button_left'   => $button_left, 
    1117998                                'button_center' => $button_center, 
    1118                                 'button_right'  => $button_right 
     999                                'button_right'  => $button_right, 
     1000                                'button_right_suggestion' => $button_right_suggestion 
    11191001                        )); 
    11201002                        $p->pfp('phpgw_body','view_event'); 
     
    11281010                } 
    11291011 
     1012                function build_suggestion( $event , $user = false ) 
     1013                { 
     1014                    $p = $GLOBALS['phpgw']->template; 
     1015 
     1016                    $p->set_file( 
     1017                            Array( 
     1018                                'suggestion'    => 'suggestion.tpl' 
     1019                            ) 
     1020                    ); 
     1021 
     1022                   include_once($_SESSION['rootPath'].'/calendar/inc/class.ex_participants.inc.php'); 
     1023                   $exParticipants = new exParticipants(); 
     1024                   $exParticipants->setParticipantsBySerializable($event['ex_participants']); 
     1025 
     1026                    $cal_id              = $event['id']; 
     1027                    $uid                 = $event['uid']; 
     1028                    $owner               = $event['owner']; 
     1029                    $title               = $event['title']; 
     1030                    $description         = rtrim(utf8_encode($event['description']));  
     1031                    $location            = $event['location']; 
     1032                    $start                       = $event['start']; 
     1033                    $end                     = $event['end']; 
     1034 
     1035                    if( $owner == -2 ) 
     1036                    { 
     1037                        $to = $event['organizer']; 
     1038                        $mail = array(); 
     1039 
     1040                        if( preg_match ('(<([^>]*@[^>]*)>)', $to, $mail ) ) 
     1041                            $to =  $mail[1]; 
     1042                    } 
     1043                    else 
     1044                    { 
     1045                        $preferences = CreateObject('phpgwapi.preferences',$owner); 
     1046                        $to = $preferences->email_address($owner); 
     1047                    } 
     1048       
     1049 
     1050                    if(((int)$start['month']) < 10 && strlen($start['month']) == 1) 
     1051                            $mes = "0" . $start['month']; 
     1052                    else 
     1053                            $mes = $start['month'];      
     1054 
     1055                    if(((int)$start['mday']) < 10 && strlen($start['mday']) == 1) 
     1056                            $dia = "0" . $start['mday']; 
     1057                    else 
     1058                            $dia = $start['mday'];               
     1059                     
     1060                    if(((int)$start['hour']) < 10 && strlen($start['hour']) == 1) 
     1061                            $hor = "0" . $start['hour']; 
     1062                    else 
     1063                            $hor = $start['hour']; 
     1064                     
     1065                    if(((int)$start['min']) < 10 && strlen($start['min']) == 1) 
     1066                            $min = "0" . $start['min']; 
     1067                    else 
     1068                            $min = $start['min']; 
     1069                     
     1070                    if(((int)$end['month']) < 10 && strlen($end['month']) == 1) 
     1071                            $end['month'] = "0" . $end['month']; 
     1072                     
     1073                    if(((int)$end['mday']) < 10 && strlen($end['mday']) == 1) 
     1074                            $end['mday'] = "0" . $end['mday']; 
     1075                     
     1076                    if(((int)$end['hour']) < 10 && strlen($end['hour']) == 1) 
     1077                            $end['hour'] = "0" . $end['hour']; 
     1078                             
     1079                    if(((int)$end['min']) < 10 && strlen($end['min']) == 1) 
     1080                            $end['min'] = "0" . $end['min']; 
     1081 
     1082                    $start_date  = $dia . "/" . $mes . "/" . $start['year'];  
     1083                    $start_hour  = $hor . ":" . $min;                            
     1084                    $end_date    =  $end['mday'] . "/" . $mes . "/" . $start['year']; 
     1085                    $end_hour    =  $end['hour'] . ":" . $end['min']; 
     1086 
     1087                    $notify_message = lang('suggest new hour'); 
     1088                    $start_h = substr($start_hour, 0, strpos($start_hour, ":")); 
     1089                    $start_m = substr($start_hour, strpos($start_hour, ":")+1); 
     1090                    $end_h   = substr($end_hour, 0, strpos($end_hour, ":")); 
     1091                    $end_m   = substr($end_hour, strpos($end_hour, ":")+1); 
     1092 
     1093                    $p->set_var('notify_message', $notify_message); 
     1094                    $p->set_var('action_form', $this->page('send_suggest_owner')); 
     1095                    $p->set_var('lang_start_hour', lang('Start hour')); 
     1096                    $p->set_var('lang_end_hour', lang('End hour')); 
     1097                    $p->set_var('lang_start_date', lang('Start date')); 
     1098                    $p->set_var('lang_end_date', lang('End date')); 
     1099                    $p->set_var('lang_suggest_new_hour', lang('Suggest new hour')); 
     1100                    $p->set_var('cal_id', $cal_id); 
     1101                    $p->set_var('to', $to); 
     1102                    $p->set_var('title', $title); 
     1103                    $p->set_var('description', $description); 
     1104                    $p->set_var('uid', $uid); 
     1105                    $p->set_var('location', $location); 
     1106                    $p->set_var('ex_participants', $exParticipants->getParticipantsMailsString()); 
     1107                    $p->set_var('start_date', $start_date); 
     1108                    $p->set_var('start_hour', $start_h); 
     1109                    $p->set_var('start_minute', $start_m); 
     1110                    $p->set_var('end_date', $end_date); 
     1111                    $p->set_var('end_hour', $end_h); 
     1112                    $p->set_var('end_minute', $end_m); 
     1113                    $p->set_var('url', $GLOBALS['phpgw_info']['server']['webserver_url']); 
     1114                    $p->set_var('user', $user); 
     1115 
     1116                    return $p->fp( 'suggestion', 'suggestion' ); 
     1117                } 
     1118 
     1119                /** 
     1120                 * @license http://www.gnu.org/copyleft/gpl.html GPL 
     1121                 * @abstract: método que envia a sugestão para o criador do compromisso. 
     1122                 * @author Prognus Software Livre (http://www.prognus.com.br) 
     1123                 */ 
     1124                function send_suggest_owner() 
     1125                {                                
     1126                        $array_data_inicio = explode('/',$_POST['data_inicio']); 
     1127                        $array_data_final  = explode('/',$_POST['data_final']); 
     1128                        $hora_inicio       = $_POST['hora_inicio']; 
     1129                        $minuto_inicio     = $_POST['minuto_inicio'];                                    
     1130                        $hora_final        = $_POST['hora_final']; 
     1131                        $minuto_final      = $_POST['minuto_final']; 
     1132                         
     1133                        $vars = $_GET['cal_id']; 
     1134                        $array_vars = explode(";", $vars); 
     1135                        $cal_id          = $array_vars[0]; 
     1136                        $to              = $array_vars[1]; 
     1137                        $title_          = $array_vars[2]; 
     1138                        $description_    = $array_vars[3]; 
     1139                        $uid             = $array_vars[4]; 
     1140                        $location        = $array_vars[5]; 
     1141                        $ex_participants = $array_vars[6]; 
     1142                        $user            = $array_vars[7];                       
     1143                        $time_suggest      = array('hora_inicio' => $hora_inicio, 'hora_final' => $hora_final, 'minuto_inicio' => $minuto_inicio, 'minuto_final' => $minuto_final); 
     1144 
     1145                        $cal_id = $this->bo->send_suggestion_external_owner($cal_id, $uid, $to, $time_suggest, $array_data_inicio, $array_data_final, $title_, $description_, $location, $ex_participants,$user); 
     1146 
     1147                        Header('Location: '.$this->page('view','&cal_id='.$cal_id)); 
     1148 
     1149                } 
     1150         
     1151                 
    11301152                function edit($params='') 
    11311153                { 
     
    11861208                                                'event' => $event, 
    11871209                                                'cd'    => $cd, 
    1188                                                 'plain' => $plain 
     1210                                                'plain' => $plain, 
     1211                                                'date'  =>  $_GET['date']  
    11891212                                        ) 
    11901213                                ); 
     
    12191242                function export($vcal_id=0) 
    12201243                { 
     1244                        $extern = true; 
     1245                        $method = 'PUBLISH'; 
    12211246                        $temp_path = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; 
    12221247                        srand((double)microtime()*1000000); 
     
    12271252                        $cal_id = get_var('cal_id',array('GET','POST'),$vcal_id); 
    12281253                        $event[0] = $this->bo->read_entry($cal_id); 
     1254                         
    12291255                        include_once('class.bocalendar.inc.php'); 
    12301256                        $cal = new bocalendar; 
    1231                         $tmpattach=$cal->create_vcard($event); 
     1257                        $tmpattach=$cal->create_vcard($event, $method, $extern); 
    12321258                        fwrite($attach_fd,$tmpattach); 
    12331259                        header ("Content-Type: text/plain");  
     
    14221448                                } 
    14231449                                // Add participants 
    1424                                 //$participants = explode(";", $GLOBALS['phpgw']->session->appsession("participants") ); 
    1425                                 //for($_f_part=0; $_f_part<count($participants); $_f_part++) 
    1426                                 //{ 
    1427                                 //      $this->bo->add_attribute('participants','A',$participants[$_f_part]); 
    1428                                 //} 
     1450                                $participants = explode(";", $GLOBALS['phpgw']->session->appsession("participants") ); 
     1451                                for($_f_part=0; $_f_part<count($participants); $_f_part++) 
     1452                                { 
     1453                                        $this->bo->add_attribute('participants','A',$participants[$_f_part]); 
     1454                                } 
    14291455                                // Add misc 
    14301456                                $this->bo->add_attribute('participants','A',$this->bo->owner); 
     
    14871513                } 
    14881514 
     1515                 
     1516                 
     1517                function getLdap() 
     1518                { 
     1519                        include_once('../phpgwapi/inc/class.common.inc.php'); 
     1520                        $GLOBALS['phpgw_info']['server'] = $_SESSION['phpgw_info']['expresso']['server']; 
     1521                        $common = new common(); 
     1522         
     1523                        if ( (!empty($GLOBALS['phpgw_info']['server']['ldap_master_host'])) && 
     1524                                (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_dn'])) && 
     1525                                (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_pw'])) ) 
     1526                                { 
     1527                                        $ldap = $common->ldapConnect($GLOBALS['phpgw_info']['server']['ldap_master_host'], 
     1528                                                                                                $GLOBALS['phpgw_info']['server']['ldap_master_root_dn'], 
     1529                                                                                                $GLOBALS['phpgw_info']['server']['ldap_master_root_pw']); 
     1530                                } 
     1531                                else 
     1532                                { 
     1533                                        $ldap = $common->ldapConnect(); 
     1534                                } 
     1535 
     1536                        return $ldap; 
     1537                }        
     1538                 
     1539                 
     1540                 
    14891541                function disponibility($params) { 
    14901542 
     
    15051557                        $str_participants = substr($_GET['participants'],0,strlen($_GET['participants'])-1); //remove the last comma 
    15061558                        $participants= array(); 
    1507  
    15081559                        $participants_splited = explode(",",$str_participants); 
    1509                         foreach($participants_splited as $participant) { 
     1560                         
     1561                                         
     1562                        $ldap = $this->getLdap(); 
     1563                        foreach ($participants_splited as $participant) 
     1564            { 
    15101565                                $participant = substr($participant,0,strlen($participant)-1); 
     1566 
     1567                $entry = array(); 
     1568                                $extern_contact = false; 
     1569                                 
     1570                                $justthese = array('accountStatus'); 
     1571                $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=l))(uidNumber=".(int)$participant."))"; 
     1572                $search = ldap_search($ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); 
     1573                $entry = ldap_get_entries($ldap, $search); 
     1574         
     1575                                if($entry[0]['accountstatus'][0] == "false") 
     1576                                        $extern_contact = true; 
     1577                         
     1578                                 
    15111579                                $acct_type = $GLOBALS['phpgw']->accounts->get_type((int)$participant); 
     1580                         
    15121581                                if($acct_type=='g') { 
    15131582                                        $bo_groups = CreateObject('expressoAdmin1_2.group'); 
    1514                                         $users = $bo_groups->get_info($participant,true); 
     1583                                        $users = $bo_groups->get_info($participant); 
    15151584                                        foreach($users['memberuid_info'] as $user) { 
    1516                                                 if($user['type']==u) 
     1585                                                if($user['type']==u){ 
     1586                                                        if (!$user['uidnumber']){ 
     1587                                                                continue; 
     1588                                                        } 
    15171589                                                        $participants[$user['uidnumber']] = 'U'; 
    15181590                                        } 
    15191591                                } 
    1520                                 else { 
     1592                                } 
     1593                                else  
     1594                                { 
     1595                                        if($extern_contact) 
     1596                                        { 
     1597                                                $participants[$participant] = 'I'; 
     1598                                                continue; 
     1599                                        } 
     1600                                         
     1601                                        if (!$participant) 
     1602                                                continue; 
     1603                                                 
    15211604                                        $participants[$participant] = 'U'; 
    15221605                                } 
     
    16651748                        "; 
    16661749 
     1750                        $extra_ = ""; 
     1751                         
    16671752                        $str.= "<table border=\'1\' bgcolor=\"#FFFFFF\" width=\"100%\" height=\"100%\"><tr><td>"; 
    16681753 
     
    16791764                        foreach($participants as $part => $nul) 
    16801765                        { 
     1766                                $extra_ = ""; 
     1767                                 
     1768                                if($nul == 'I') 
     1769                                        $extra_ = "(externalI)"; 
     1770                                 
    16811771                                $participants[$part] = $GLOBALS['phpgw']->common->grab_owner_name($part); 
     1772                                $participants[$part].= $extra_; 
    16821773                                // Much better for processor  :) 
    16831774                                $participants_id[]  .= $part; 
     
    16911782                                $GLOBALS['phpgw']->preferences->save_repository(); 
    16921783                        } 
    1693                         if($this->bo->prefs['calendar']['interval'] == '42') 
    1694                         { 
    1695                             $increment = 30; 
    1696                         } 
    1697                         elseif($this->bo->prefs['calendar']['interval'] == '84') 
    1698                         { 
    1699                             $increment = 15; 
    1700                         } 
     1784                        $increment = $this->bo->prefs['calendar']['interval']; 
    17011785                        $interval = (int)(60 / $increment); 
    17021786 
     
    17271811                        foreach($participants as $part => $fullname) 
    17281812                        { 
     1813                                $external = false; 
     1814                                if(strpos($fullname,"(externalI)"))  
     1815                                { 
     1816                                        $tmp_name = str_replace("(externalI)","",$fullname); 
     1817                                        $fullname = $tmp_name; 
     1818                                        $external = true; 
     1819                                } 
     1820                                 
    17291821                                $str .= '<tr align="center">' 
    17301822                                        . '<td width="15%" align="left"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.$fullname.'</font></td>'; 
     
    17431835                                        ) 
    17441836                                ); 
     1837 
     1838                                if($external)  
     1839                                { 
     1840                                        $str .= '<td height="1" align="center" colspan="22" bgcolor="'.$this->theme['bg_color'].'" color="#999999">' .lang('Agenda not available') .'</td>'; 
     1841                                        $str .= '</tr>' 
     1842                                        . '<tr><td height="1" colspan="'.((11 * $interval) + 1).'" bgcolor="#999999"><img src="'.$pix.'"></td></tr>'; 
     1843                                        continue; 
     1844                                } 
    17451845 
    17461846                                if(!$this->bo->cached_events[$date['full']]) 
     
    17721872                                                                        break; 
    17731873                                                                case '-': 
     1874                                                                        $time_slice[$index]['marker'] = "#"; 
    17741875                                                                        $time_slice[$index]['color'] = $this->theme['bg11']; 
    17751876                                                                        $link = $this->page('view','&cal_id='.$time_slice[$index]['id'].'&date='.$date['full']); 
     
    17971898                { 
    17981899 
    1799                         $next = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day + 1,$this->bo->year); 
    1800                         $prev = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day - 1,$this->bo->year); 
    1801  
    18021900                        $this->bo->read_holidays(); 
    18031901 
    1804                         $legend_holiday = $this->bo->cached_holidays[$_GET['date']][0]['name']?'('.$this->bo->cached_holidays[$_GET['date']][0]['name'].')':''; 
    18051902                        if (!$this->bo->printer_friendly || ($this->bo->printer_friendly && @$this->bo->prefs['calendar']['display_minicals'])) 
    18061903                        { 
    18071904                                $minical = $this->mini_calendar( 
    18081905                                        Array( 
    1809                                                 'day'           => 1, 
     1906                                                'day'   => $this->bo->day, 
    18101907                                                'month'         => $this->bo->month, 
    18111908                                                'year'          => $this->bo->year, 
    1812                                                 'link'          => 'day', 
    1813                                                 'control'       => True, 
    1814                                                 'outside_month' => False 
     1909                                                'link'  => 'day' 
    18151910                                        ) 
    18161911                                ); 
    1817                                 $minical1 = $this->mini_calendar( 
    1818                                         Array( 
    1819                                                 'day'           => 1, 
    1820                                                 'month'         => $this->bo->month+1, 
    1821                                                 'year'          => $this->bo->year, 
    1822                                                 'link'          => 'day', 
    1823                                                 'control'       => False, 
    1824                                                 'outside_month' => False 
    1825                                         ) 
    1826                                 ); 
    1827                                 $minical2 = $this->mini_calendar( 
    1828                                         Array( 
    1829                                                 'day'           => 1, 
    1830                                                 'month'         => $this->bo->month+2, 
    1831                                                 'year'          => $this->bo->year, 
    1832                                                 'link'          => 'day', 
    1833                                                 'control'       => False, 
    1834                                                 'outside_month' => False 
    1835                                         ) 
    1836                                 ); 
    18371912                        } 
    18381913                        else 
    18391914                        { 
    18401915 
    1841                                 //NDEE: printer-friendly (what?) 
     1916//NDEE: printer-friendly (what?) 
    18421917                                $minical = ''; 
    18431918                        } 
    18441919 
    1845                         if(isset($_GET['date'])) 
    1846                         { 
    1847                             $dia = substr($_GET['date'],-2); 
     1920                        if (!$this->bo->printer_friendly) 
     1921                        { 
     1922                                $printer = ''; 
     1923                                $param = '&date='.sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day).'&friendly=1'; 
     1924                        //      $print = '<a href="'.$this->page('day'.$param)."\" TARGET=\"cal_printer_friendly\" onMouseOver=\"window.status = '".lang('Generate printer-friendly version')."'\">[".lang('Printer Friendly').']</a>'; 
     1925                         
     1926                                //Adiciona modo que o mesmo abra uma nova janela nos navegadores IE e FF 
     1927                                $print = "<a href='javascript:void(0)' onClick=\"javascript:window.open('".$this->page('day'.$param). 
     1928                                                "','','width=600,height=600,toolbar=no,scrollbars=yes,resizable=no');\" onMouseOver=\"window.status = '". 
     1929                                                lang('Generate printer-friendly version')."'\">[".lang('Printer Friendly').']</a>'; 
     1930                         
    18481931                        } 
    18491932                        else 
    18501933                        { 
    1851                             $dia = $_POST['day']; 
    1852                         } 
    1853  
    1854                         if (!$this->bo->printer_friendly) 
    1855                         { 
    1856                                 $printer = ''; 
    1857                                 $prev_day_link = '<a href="'.$this->page('day','&date='.$prev['full']).'">&lt;&lt;</a>'; 
    1858                                 $next_day_link = '<a href="'.$this->page('day','&date='.$next['full']).'">&gt;&gt;</a>'; 
    1859                                 //$param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'.'&day_ini='.$dia.'&num_dias=1'.'&d=1'; 
    1860                                 //$print = "<a href='javascript:void(0)' onClick=\"javascript:window.open('".$this->page('month'.$param). 
    1861                                 //              "','','width=600,height=600,toolbar=no,scrollbars=yes,resizable=no');\" onMouseOver=\"window.status = '". 
    1862                                 //              lang('Generate printer-friendly version')."'\">[".lang('Printer Friendly').']</a>'; 
    1863                         } 
    1864                         else 
    1865                         { 
    1866  
    1867                                 //NDEE: printer-friendly (daily-view) 
     1934 
     1935//NDEE: printer-friendly (daily-view) 
    18681936                                $GLOBALS['phpgw_info']['flags']['nofooter'] = True; 
    18691937                                $printer = '<body bgcolor="'.$this->theme['bg_color'].'">'; 
    1870                                 //$print =      ''; 
    1871                         } 
    1872                         $print =  '<a href="javascript:void(0)" id="printFriendly">['.lang('Printer Friendly').']</a>'; 
    1873  
    1874                         $param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'.'&day_ini='.$dia.'&num_dias=1'.'&d=1'; 
     1938                                $print =        ''; 
     1939                        } 
    18751940 
    18761941                        $now    = $GLOBALS['phpgw']->datetime->makegmttime(0, 0, 0, $this->bo->month, $this->bo->day, $this->bo->year); 
    18771942                        $now['raw'] += $GLOBALS['phpgw']->datetime->tz_offset; 
    1878  
    1879                         $week_days = array(lang('Sunday'), 
    1880                                                                 lang('Monday'), 
    1881                                                                 lang('Tuesday'), 
    1882                                                                 lang('Wednesday'), 
    1883                                                                 lang('Thursday'), 
    1884                                                                 lang('Friday'), 
    1885                                                                 lang('Saturday')); 
    18861943 
    18871944                        $p = $GLOBALS['phpgw']->template; 
     
    18981955                                'printer_friendly'          => $printer, 
    18991956                                'bg_text'                   => $this->theme['bg_text'], 
    1900                                 'daily_events'              => $this->print_day_new( 
     1957                                'daily_events'          => $this->print_day( 
    19011958                                        Array( 
    19021959                                                'year'      => $this->bo->year, 
     
    19051962                                        ) 
    19061963                                ), 
    1907                                 'small_calendar'            => $minical.'<br/>'.$minical1.'<br/>'.$minical2, 
    1908                                 'date'                      => $this->bo->long_date($now) . $legend_holiday, 
    1909                                 'day_of_week'           => $week_days[$now['dow']], 
     1964                                'small_calendar'        => $minical, 
     1965                                'date'                          => $this->bo->long_date($now), 
    19101966                                'username'                  => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner), 
    1911                                 'prev_day_link'             => $prev_day_link, 
    1912                                 'next_day_link'             => $next_day_link, 
    1913                                 'iprint'                    => $print, 
    1914                                 'param'                     => $param, 
     1967                                'print'                         => $print, 
    19151968                                'lang_todos'                => $todo_label, 
    19161969                                'todos'                     => $this->bo->printer_friendly ? $todos : 
    19171970 
    1918                                         //NDEE: todo's layout 
     1971//NDEE: todo's layout 
    19191972                                        "<div style=\"overflow: auto; max-height: 200px\">\n$todos</div>\n" 
    19201973                        ); 
     
    19221975                        $p->set_var($var); 
    19231976                        $p->parse('day_events','day_event'); 
    1924                         echo $this->printer_friendly($p->fp('out','day'),lang('Dayview')); 
     1977                        print $this->printer_friendly($p->fp('out','day'),lang('Dayview')); 
    19251978                        $GLOBALS['phpgw']->common->phpgw_footer(); 
    19261979                } 
     
    20422095                                                $notify_message = lang('This commitment has already been accepted!'); 
    20432096                                }        
    2044                                 else 
     2097                                else if($_GET['response'] == 2) 
    20452098                                {                                        
    20462099                                        if(!$duplicated_action)                                          
     
    20482101                                        else 
    20492102                                                $notify_message = lang('This commitment has already been rejected!'); 
     2103                                } 
     2104                                else if($_GET['response'] == 3) 
     2105                                {                                        
     2106                                        if(!$duplicated_action)                                          
     2107                                                $notify_message = lang('The commitment was tentatived successfully!'); 
     2108                                        else 
     2109                                                $notify_message = lang('This commitment has already been tentatived!'); 
    20502110                                } 
    20512111                                 
     
    20572117                                $tmpbody1 = $body1->pfp('out','list'); 
    20582118                } 
    2059                  
    2060                 function confirm_conflict($user_id,$event,$overlapping_events) 
    2061                 { 
    2062                         if(!$overlapping_events){                                        
    2063                                 $notify_message = lang('This event conflicts with your other event.'); 
    2064          
    2065                                 $action_ignore = $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 3, 'response' => 1,'user_id' => $user_id, 'ignore_conflict' => 1)); 
    2066                                 $action_reject = $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 0, 'response' => 0)); 
    2067          
    2068                                 $body1 = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); 
    2069                                 $body1->set_file(Array('calendar' => 'conflict.tpl')); 
    2070                                 $body1->set_block('calendar','list'); 
    2071                                 $var = Array( 'notify_message'  => $notify_message, 
    2072                                                         'action_url' => $action_url, 
    2073                                                         'ignore_conflict' => 'Ignorar Conflito', 
    2074                                                         'reject_event' => 'Rejeitar Evento', 
    2075                                                         'action_reject' => $action_reject, 
    2076                                                         'action_ignore' => $action_ignore); 
    2077                                 $body1->set_var($var); 
    2078                                 $tmpbody1 = $body1->pfp('out','list'); 
    2079                         } 
    2080                         else 
    2081                         {                                
    2082                                 $month = $event['start']['month']; 
    2083                                 $mday = $event['start']['mday']; 
    2084                                 $year = $event['start']['year']; 
    2085          
    2086                                 $start = mktime($event['start']['hour'],$event['start']['min'],$event['start']['sec'],$month,$mday,$year) - $GLOBALS['phpgw']->datetime->tz_offset; 
    2087                                 $end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; 
    2088          
    2089                                 $overlap = ''; 
    2090                                 for($i=0;$i<count($overlapping_events);$i++) 
    2091                                 { 
    2092                                         $overlapped_event = $this->bo->read_entry($overlapping_events[$i],True); 
    2093                                         foreach($overlapped_event['participants'] as $id => $status) 
    2094                                         { 
    2095                                                 $conflict = isset($event['participants'][$user_id]); 
    2096                                                 $overlap .= '<li>'.($conflict?'<b>':''). 
    2097                                                         $GLOBALS['phpgw']->common->grab_owner_name($id). 
    2098                                                         ($conflict?'</b> - '.lang('Scheduling conflict'):'')."</li>"; 
    2099                                         } 
    2100                                  if ($this->bo->prefs['calendar']['hide_event_conflict']) 
    2101                                          $overlap .= '<ul><font size="1"><span>'. 
    2102                                                  $this->normDec($overlapped_event['start']['hour']).":". 
    2103                                                  $this->normDec($overlapped_event['start']['min'])."-". 
    2104                                                  $this->normDec($overlapped_event['end']['hour']).":". 
    2105                                                  $this->normDec($overlapped_event['end']['min']). 
    2106                                                  '<br><b>'.lang('title').": ".lang("Hidden"). 
    2107                                                  '</b><br>'.lang('description').": ".lang("Hidden").'<br></span></ul><br>'; 
    2108                                  else 
    2109                                          $overlap .= '<ul>'.$this->link_to_entry($overlapped_event,$month,$mday,$year)."</ul><br>";      
    2110                                 } 
    2111          
    2112                                 unset($GLOBALS['phpgw_info']['flags']['noheader']); 
    2113                                 unset($GLOBALS['phpgw_info']['flags']['nonavbar']); 
    2114                                 $GLOBALS['phpgw_info']['flags']['noappheader'] = True; 
    2115                                 $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; 
    2116                                 $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Scheduling Conflict'); 
    2117                                 $GLOBALS['phpgw']->common->phpgw_header(); 
    2118          
    2119                                 $p = $GLOBALS['phpgw']->template; 
    2120                                 $p->set_file( 
    2121                                         Array( 
    2122                                                 'overlap'       => 'overlap.tpl', 
    2123                                                 'form_button'   => 'form_button_script.tpl' 
    2124                                         ) 
    2125                                 ); 
    2126          
    2127                                 $var = Array( 
    2128                                         'color'         => $this->theme['bg_text'], 
    2129                                         'overlap_title' => lang('Scheduling Conflict'), 
    2130                                         'overlap_text'  => lang('Your suggested time of <B> %1 - %2 </B> conflicts with the following existing calendar entries:',$GLOBALS['phpgw']->common->show_date($start),$GLOBALS['phpgw']->common->show_date($end)), 
    2131                                         'overlap_list'  => $overlap 
    2132                                 ); 
    2133                                 $p->set_var($var); 
    2134          
    2135                                 $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->mday); 
    2136                                 $var = Array( 
    2137                                         'action_url_button'     => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 3, 'user_id' => $user_id, 'ignore_conflict' => 1)), 
    2138                                         'action_text_button'    => lang('Ignore Conflict'), 
    2139                                         'action_confirm_button' => '', 
    2140                                         'action_extra_field'    => '', 
    2141                                         'button_id'             => 'ignore_button' 
    2142                                 );                               
    2143                                 $action_reject = $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 0, 'response' => 0)); 
    2144          
    2145                                 $this->output_template_array($p,'resubmit_button','form_button',$var); 
    2146          
    2147                                 $var = Array( 
    2148                                         'action_url_button'     => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 0)), 
    2149                                         'action_text_button'    => lang('Reject'), 
    2150                                         'action_confirm_button' => '', 
    2151                                         'action_extra_field'    => '', 
    2152                                         'button_id'             => 'redit_button' 
    2153                                 ); 
    2154                                 $this->output_template_array($p,'reedit_button','form_button',$var); 
    2155                                 $p->pparse('out','overlap'); 
    2156                         } 
    2157                 } 
    2158                  
    21592119                function set_action() 
    21602120                { 
     
    21652125                        } 
    21662126                         
    2167                         $overlapping_events = false; 
    2168                         $event = $this->bo->read_entry((int)$_GET['cal_id']); 
    2169                         if((!$_GET['response'] == 0 && !$_GET['ignore_conflict'] == 1) ||  
    2170                                 (!isset($_GET['response']) && $_GET['action'] == 3 && !$_GET['ignore_conflict'] == 1)) 
    2171                         { 
    2172                                 if($event['id']) 
    2173                                 { 
    2174                                         $event_ids[] = $event['id']; 
    2175                                 } 
    2176                                 if($event['reference']) 
    2177                                 { 
    2178                                         $event_ids[] = $event['reference']; 
    2179                                 } 
    2180                                  
    2181                                 $event['participants'] = Array($_SESSION['phpgw_info']['expressomail']['user']['account_id'] => $event['participants'][$_SESSION['phpgw_info']['expressomail']['user']['account_id']]); 
    2182  
    2183                                 $overlapping_events = $this->bo->overlap( 
    2184                                         $this->bo->maketime($event['start']), 
    2185                                         $this->bo->maketime($event['end']), 
    2186                                         $event['participants'], 
    2187                                         $event['owner'], 
    2188                                         $event_ids 
    2189                                 ); 
    2190                         } 
     2127                        $confirm_status = $this->bo->set_status((int)$_GET['cal_id'],(int)$_GET['action'],(int)$_GET['user']); 
    21912128 
    21922129                        if(isset($_GET['response'])) 
    21932130                        { 
    2194                                 if($overlapping_events) 
    2195                                 { 
    2196                                         $this->confirm_conflict($_GET['user_id'],$event); 
    2197                                 }else 
    2198                                 { 
    2199                                         $confirm_status = $this->bo->set_status((int)$_GET['cal_id'],(int)$_GET['action']); 
    22002131                                        $this->confirm_action($confirm_status); 
    22012132                                        $GLOBALS['phpgw']->common->phpgw_exit(False); 
    22022133                                } 
    2203                         }else 
    2204                         { 
    2205                                 if($overlapping_events) 
    2206                                 {                                        
    2207                                         $this->confirm_conflict($_GET['user_id'],$event,$overlapping_events); 
    2208                                 }else 
    2209                                 { 
    2210                                 $confirm_status = $this->bo->set_status((int)$_GET['cal_id'],(int)$_GET['action']); 
     2134                        else 
     2135                                { 
    22112136                                        if ($this->bo->return_to) 
    22122137                                        { 
     
    22192144                                        $GLOBALS['phpgw']->common->phpgw_exit(); 
    22202145                                } 
    2221                         } 
    2222                          
    22232146                         
    22242147                } 
     
    22932216                                if ($this->always_app_header) $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Group Planner'); 
    22942217                                $GLOBALS['phpgw']->common->phpgw_header(); 
     2218                                $this->header(); 
    22952219                        } 
    22962220 
     
    25642488                        if (!$is_private) 
    25652489                        { 
    2566                                 $opt .= ' title="'.lang('Title').": ".$event['title']; 
     2490                                $opt .= ' title="'.lang('Title').": ".$event['title']."&nbsp| "; 
    25672491                                if ($event['description']) 
    25682492                                { 
    2569                                         $opt .= "\n".lang('Description').": ".$event['description']; 
     2493                                        $opt .= "\n".lang('Description').": ".$event['description']."&nbsp| "; 
    25702494                                } 
    25712495                        } 
     
    25772501                        $start = $GLOBALS['phpgw']->common->show_date($this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset); 
    25782502                        $end = $GLOBALS['phpgw']->common->show_date($this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset); 
    2579                         $opt .= "\n".lang('Start Date/Time').": ".$start."\n".lang('End Date/Time').": ".$end; 
     2503                        $opt .= "\n".lang('Start Date/Time').": ".$start."&nbsp| ".lang('End Date/Time').": ".$end."&nbsp| "; 
    25802504 
    25812505                        if ($event['location'] && !$is_private) 
     
    30532977                                        } 
    30542978                                } 
    3055                                 $GLOBALS['phpgw']->redirect_link('/index.php',$vars); 
     2979 
     2980                                unset($GLOBALS['phpgw_info']['flags']['noheader']); 
     2981                                unset($GLOBALS['phpgw_info']['flags']['nonavbar']); 
     2982                                $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Search Results'); 
     2983                                $GLOBALS['phpgw']->common->phpgw_header(); 
     2984 
     2985                                echo '<b>'.lang('Error').':</b>'.lang('no matches found'); 
     2986                                return; 
     2987                                //$GLOBALS['phpgw']->redirect_link('/index.php',$vars); 
    30562988                        } 
    30572989 
     
    32523184                                        'footer'        => 'footer.tpl', 
    32533185                                        'form_button'   => 'form_button_script.tpl' 
    3254                                         //'new_component'       => 'new_component.tpl' 
    32553186                                ) 
    32563187                        ); 
     
    32943225                                $str_ini .= '<option value="'.$i.'"'.($i == $day?' selected':'').'>'.$i.'</option>'."\n"; 
    32953226                        } 
    3296                         $str_qtd = '<option value="'.''.'"'.(!$_POST['qtd_dias']?' selected':'').'>'.''.'</option>'."\n"; 
     3227                        $str_qtd = '<option value="'.''.'"'.($i == $_POST['qtd_dias']?' selected':'').'>'.''.'</option>'."\n"; 
    32973228                        for ($i = 1; $i <= 45; $i++) 
    32983229                        { 
     
    33013232                        $display = ''; 
    33023233                        $display_view = ''; 
    3303 //                        if ($menuaction == 'calendar.uicalendar.month') 
    3304 //                      { 
    3305 //                            $accounts = CreateObject('phpgwapi.accounts'); 
    3306 //                            $accountId = $accounts->name2id($account_name); 
    3307 //                            $prefs = CreateObject('phpgwapi.preferences', $accountId); 
    3308 //                            $account_prefs = $prefs->read(); 
    3309 //                        } 
    3310                         if ( ($menuaction == 'calendar.uicalendar.week') || ($menuaction == 'calendar.uicalendar.day') || ($menuaction == 'calendar.uicalendar.year') || ($menuaction == 'calendar.uicalendar.planner')) 
     3234                        if ( ($menuaction == 'calendar.uicalendar.week') || ($menuaction == 'calendar.uicalendar.day') ) 
    33113235                        { 
    33123236                                $display = 'none'; 
     
    33213245                                'formname'              => 'SelectDay', 
    33223246                                'formonchange'          => 'document.SelectDay.submit()', 
    3323                                 'day_ini_label'         => lang('print start day'), 
     3247                                'day_ini_label'         => lang('print starting in'), 
    33243248                                'num_dias_label'        => lang('quantity of days'), 
    3325                                 'tip'                   => lang('empty prints from the start day chosen to the end of the current month'), 
    3326 //                              'day_ini_name'          => 'day', 
    3327 //                              'num_dias_name'         => 'qtd_dias', 
     3249                                'tip'                   => lang('empty prints from the day chosen below to the end of the current month'), 
     3250                                'day_ini_name'          => 'day', 
     3251                                'num_dias_name'         => 'qtd_dias', 
    33283252                                'row_ini'               => $str_ini, 
    33293253                                'row_qtd'               => $str_qtd, 
     
    33603284                                'form_onchange' => 'document.SelectMonth.submit()', 
    33613285                                'row'           => $str, 
    3362 //                              'dia_ini'       => $dia_ini, 
     3286                                'dia_ini'       => $dia_ini, 
    33633287                                'go'            => lang('Go!') 
    33643288                        ); 
     
    34643388                        $this->output_template_array($p,'b_row2','form_button',$var); 
    34653389 
    3466                         //$p->set_var('place_component',''); 
    34673390                        $p->parse('table_row','blank_row',True); 
     3391 
    34683392                        $p->pparse('out','footer_table'); 
    34693393                        unset($p); 
     
    35223446                        $viewable = !$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_READ,$event); 
    35233447 
     3448                        if(!$viewable && $event['type'] == 'E' && !$event['public']){ 
     3449                                return ""; 
     3450                        }  
     3451                         
    35243452                        $starttime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; 
    35253453                        $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; 
     
    35463474                                } 
    35473475 
    3548                                 if($endtime >= ($rawdate_offset + 86400)) 
    3549                                 { 
    3550                                         $end_time = $GLOBALS['phpgw']->common->show_date(mktime(23,59,59,$month,$day,$year) - $GLOBALS['phpgw']->datetime->tz_offset,$this->bo->users_timeformat); 
    3551                                 } 
    3552                                 else 
    3553                                 { 
     3476                               
     3477//                              if($endtime >= ($rawdate_offset + 86400 )) 
     3478//                              { 
     3479//                                    $end_time = $GLOBALS['phpgw']->common->show_date(mktime(23,59,59,$month,$day,$year) - $GLOBALS['phpgw']->datetime->tz_offset,$this->bo->users_timeformat); 
     3480//                              } 
     3481//                              else 
     3482//                              { 
    35543483                                        $end_time = $GLOBALS['phpgw']->common->show_date($endtime,$this->bo->users_timeformat); 
    3555                                 } 
     3484//                              } 
    35563485                                $time = $start_time.'-'.$end_time; 
    35573486                        } 
     
    35823511                        $texttime=$time; 
    35833512                        $texttitle=$this->bo->get_short_field($event,$is_private,'title'); 
    3584  
    3585                         $account_name = $_POST['user'] ? 
    3586                                                         $_POST['user'] : 
    3587                                                         ($_GET['account_name'] ? 
    3588                                                          $_GET['account_name'] : ''); 
    3589  
    3590                         $accounts = CreateObject('phpgwapi.accounts'); 
    3591                         $accountId = $accounts->name2id($account_name); 
    3592  
    3593                         $prefs = CreateObject('phpgwapi.preferences', $accountId); 
    3594                         $account_prefs = $prefs->read(); 
    3595  
    3596                         $titleView = $account_prefs['calendar']['title_view']; 
    3597                         if($titleView == "1") 
    3598                         { 
    3599                             $textdesc = ''; 
    3600                         } 
    3601                         else 
    3602                         { 
    3603                             $textdesc = (!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):''); 
    3604                             $textdesc=nl2br($textdesc); 
    3605                         } 
    3606  
     3513                        $textdesc=(!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):''); 
    36073514                        // added $textlocation but this must be activated in the actual pict_link.tpl file of the used template set 
    3608                         $textlocation= $event['location']?"<br/><b>Local:</b> ".$this->bo->get_short_field($event,$is_private,'location'):''; 
     3515                        $textlocation=$this->bo->get_short_field($event,$is_private,'location'); 
    36093516 
    36103517                        if ($viewable) 
     
    36583565                        } 
    36593566                        else 
    3660                         {if ($texttitle) 
     3567                        { 
    36613568                                $picture[] = Array( 
    36623569                                        'pict'  =>  $GLOBALS['phpgw']->common->image('calendar','single'), 
     
    36903597                                } 
    36913598                        } 
    3692  
    3693                         if($event['attachment'] != '') 
    3694                                 { 
    3695                                         $picture[] = Array( 
    3696                                                 'pict'  => $GLOBALS['phpgw']->common->image('calendar','clip'), 
    3697                                                 'width' => 9, 
    3698                                                 'height'=> 9, 
    3699                                                 'title' => lang('Notification with attachments sent.') 
    3700                                         ); 
    3701                                 } 
    37023599 
    37033600                        $description = $this->bo->get_short_field($event,$is_private,'description'); 
     
    37123609                                $this->output_template_array($this->link_tpl,'picture','pict',$var); 
    37133610                        } 
    3714                         if ($event['type'] == 'H' || $texttitle) 
     3611                        if ($texttitle) 
    37153612                        { 
    37163613                                $var = Array( 
     
    37203617                                        'users_status'=>$textstatus, 
    37213618                                        'desc'=> $textdesc, 
    3722                                         'location'=> $textlocation 
     3619                                        'location'=> "<br><b>Local:</b> ".$textlocation 
    37233620                                ); 
    37243621                                $this->output_template_array($this->link_tpl,'picture','link_text',$var); 
     
    37853682                        } 
    37863683                         
    3787                         $textTitlePrint = $textTimePrint = $textDescPrint = $textLocationPrint = $textObservationsPrint = $textstatus = ''; 
     3684                        $texttitle = $texttime = $textdesc = $textlocation = $textstatus = ''; 
     3685 
     3686                         
    37883687 
    37893688                        if(!$is_private) 
    37903689                        { 
     3690                                //$text .= $this->bo->display_status($event['users_status']); 
     3691                                 
    37913692                                // split text for better display by templates, also see $texttime $texttitle $textdesc $textlocation     
    37923693                                $textstatus=$this->bo->display_status($event['users_status']);  
     
    37943695                        } 
    37953696 
    3796                         $account_name = $_POST['user'] ? 
    3797                                                         $_POST['user'] : 
    3798                                                         ($_GET['account_name'] ? 
    3799                                                          $_GET['account_name'] : ''); 
    3800                          
    3801                         $accounts = CreateObject('phpgwapi.accounts'); 
    3802                         $accountId = $accounts->name2id($account_name); 
    3803  
    3804                         $prefs = CreateObject('phpgwapi.preferences', $accountId); 
    3805                         $account_prefs = $prefs->read(); 
    3806  
    3807  
    3808                         $textTimePrint = $time; 
    3809                         $textTitlePrint = $is_private ? lang('Private event. You are not allowed to print it.') : ( $event['type'] == 'H' ? 'Apontamento de horas' : $this->bo->get_short_field($event,$is_private,'title' ) ); 
    3810  
    3811                         $fieldsToPrint = $account_prefs['calendar']['fields_to_print']; 
    3812                         if($fieldsToPrint == "0") 
    3813                         { 
    3814                             $textDescPrint = ''; 
    3815                         } 
    3816                         elseif($fieldsToPrint == "1") 
    3817                         { 
    3818                             $textDescPrint = (!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):''); 
    3819                         } 
    3820                         else 
    3821                         { 
    3822                             $textDescPrint = (!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):''); 
    3823                             $textObservationsPrint = $event['observations']?"<br /><b>Observações:</b> ".$this->bo->get_short_field($event,$is_private,'observations'):''; 
    3824                         } 
    3825  
     3697                        $text = '<nobr>&nbsp;'.$time.'&nbsp;</nobr> '.$this->bo->get_short_field($event,$is_private,'title').$text. 
     3698 
     3699                        $texttime=$time; 
     3700                        $texttitle=$this->bo->get_short_field($event,$is_private,'title'); 
     3701                        $textdesc=(!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):''); 
    38263702                        // added $textlocation but this must be activated in the actual pict_link.tpl file of the used template set 
    3827                         $textLocationPrint = $event['location']?"<br /><b>Local:</b> ".$this->bo->get_short_field($event,$is_private,'location'):''; 
     3703                        $textlocation=$this->bo->get_short_field($event,$is_private,'location'); 
    38283704 
    38293705                        if ($viewable) 
     
    38323708                                $this->event_tpl->set_var('link_link',$this->page('view','&cal_id='.$event['id'].'&date='.$date)); 
    38333709                                $this->event_tpl->set_var('lang_view',lang('View this entry')); 
    3834                                 $this->event_tpl->set_var('desc', $textDescPrint); 
    3835                                 $this->event_tpl->set_var('location', $textLocationPrint); 
    3836                                 $this->event_tpl->set_var('observations', $textObservationsPrint); 
     3710                                $this->event_tpl->set_var('desc', $textdesc); 
     3711                                $this->event_tpl->set_var('location', $textlocation); 
    38373712                                $this->event_tpl->parse('picture','link_event_open',True); 
    38383713                        } 
    3839  
    38403714                        if (!$is_private) 
    38413715                        { 
     
    39253799                                $this->output_template_array($this->event_tpl,'picture','event_pict',$var); 
    39263800                        } 
    3927  
    3928                         if ($textTitlePrint) 
     3801                        if ($texttitle) 
    39293802                        { 
    39303803                                $var = Array( 
    39313804                        //              'text' => $text, 
    3932                                         'time'=> $textTimePrint, 
    3933                                         'title'=> $textTitlePrint, 
     3805                                        'time'=> $texttime, 
     3806                                        'title'=> $texttitle, 
    39343807                                        'users_status'=>$textstatus, 
    3935                                         'desc'=> $textDescPrint, 
    3936                                         'location'=> $textLocationPrint, 
    3937                                         'observations'=> $textObservationsPrint 
     3808                                        'desc'=> $textdesc, 
     3809                                        'location'=> "<br><b>Local:</b> ".$textlocation 
    39383810                                ); 
    39393811                                $this->output_template_array($this->event_tpl,'picture','link_event_text',$var); 
     
    39673839                        { 
    39683840                                $overlapping_events = $params['o_events']; 
     3841 
     3842                                if( is_string( $overlapping_events )) 
     3843                                    $overlapping_events = explode( ';', $overlapping_events ); 
     3844 
    39693845                                $event = $params['this_event']; 
     3846 
     3847                                if( is_string( $event ) ) 
     3848                                    $event = $this->bo->read_entry( $event ); 
     3849 
     3850                                if( !$event ) 
     3851                                    $event = $this->bo->restore_from_appsession(); 
    39703852                        } 
    39713853 
     
    39863868                                        $overlap .= '<li>'.($conflict?'<b>':''). 
    39873869                                                $GLOBALS['phpgw']->common->grab_owner_name($id). 
    3988                                                 ($conflict?'</b> - '.lang('Scheduling conflict'):'')."</li>"; 
     3870                                                ($conflict?'</b> - '.lang('Scheduling conflict'):'').'</li>'; 
    39893871                                } 
    39903872                         if ($this->bo->prefs['calendar']['hide_event_conflict']) 
     
    39973879                                         '</b><br>'.lang('description').": ".lang("Hidden").'<br></span></ul><br>'; 
    39983880                         else 
    3999                                  $overlap .= '<ul>'.$this->link_to_entry($overlapped_event,$month,$mday,$year)."</ul><br>";      
     3881                                 $overlap .= '<ul>'.$this->link_to_entry($overlapped_event,$month,$mday,$year).'"</ul><br>';                   
    40003882                        } 
    40013883 
     
    40073889                        $GLOBALS['phpgw']->common->phpgw_header(); 
    40083890 
     3891                        $porig = $GLOBALS['phpgw']->template; 
     3892 
     3893                        $GLOBALS['phpgw']->template->root = $_SESSION['rootPath'].'/calendar/templates/'.$GLOBALS['phpgw_info']['server']['template_set'].'/'; 
     3894 
    40093895                        $p = $GLOBALS['phpgw']->template; 
    40103896                        $p->set_file( 
     
    40243910 
    40253911                        $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->mday); 
     3912 
     3913                        $var = Array( 
     3914                                'action_url_button'     => $GLOBALS['phpgw']->link('/index.php',array('menuaction' => 'calendar.uicalendar.index')), 
     3915                                'action_text_button'    => lang('Cancel'), 
     3916                                'action_confirm_button' => '', 
     3917                                'action_extra_field'    => '', 
     3918                                'button_id'             => 'cancel_button' 
     3919                        ); 
     3920                        $this->output_template_array($p,'cancel_button','form_button',$var); 
     3921 
    40263922                        $var = Array( 
    40273923                                'action_url_button'     => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update','readsess'=>1)), 
     
    40333929                        $this->output_template_array($p,'resubmit_button','form_button',$var); 
    40343930 
     3931                        if( $event['owner'] == -2 || $event['id'] != 0 ) 
     3932                        { 
     3933                            $p->set_var( 'suggestion', $this->build_suggestion( $event , $params['this_account']) ); 
     3934 
     3935                            $var = Array( 
     3936                                'action_url_button'     => '', 
     3937                                'action_text_button'    => lang('Suggest new hour'), 
     3938                                'action_confirm_button' => 'onsubmit="javascript: return false;" onclick="javascript: return show_suggestion();"', 
     3939                                'action_extra_field'    => '', 
     3940                                'button_id'             => 'redit_button' 
     3941                            ); 
     3942                        } 
     3943                        else 
     3944                        { 
     3945                            $p->set_var( 'suggestion', '' ); 
     3946 
    40353947                        $var = Array( 
    40363948                                'action_url_button'     => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.edit','readsess'=>1,'date'=>$date)), 
     
    40403952                                'button_id'             => 'redit_button' 
    40413953                        ); 
     3954                        } 
    40423955                        $this->output_template_array($p,'reedit_button','form_button',$var); 
    40433956                        $p->pparse('out','overlap'); 
     3957                        //return 'OLA'; 
    40443958                } 
    40453959 
     
    43574271                                $month = (int)substr($date,4,2); 
    43584272                                $day   = (int)substr($date,6,2); 
    4359  
     4273                                $var   = Array( 
     4274                                        'column_data' => '', 
     4275                                        'extra' => '' 
     4276                                ); 
    43604277                                $p->set_var($var); 
    43614278                                if ($weekly || ($date >= $monthstart && $date <= $monthend)) 
     
    43664283                                        $id_aux = mktime(0,0,0,$month,$day,$year); 
    43674284                                        $month_identifier = substr(lang(strftime("%B",$id_aux)),0,3); 
    4368                                         $day_number = $dia_semana . ",  " . $day_num; 
     4285                                        $day_number = $month_identifier . " - " . $dia_semana . ",  " . $day_num; 
    43694286 
    43704287                                        $var = Array( 
    43714288                                                'extra'         => $day_params['extra'], 
    43724289                                                'new_event_link'=> $new_event_link, 
    4373                                                 'day_number'    => (isset($_GET['num_dias']) && ($_GET['num_dias'] > 1 || $_GET['num_dias'] == "")?$day_number:'') 
     4290                                                'day_number'    => $day_number 
    43744291                                        ); 
    43754292 
     
    43834300                                                ); 
    43844301                                                $p->set_var($var); 
    4385                                                 $eventsCached = $this->bo->cached_events[$date]; 
    4386  
    4387                                                 if($_GET['d'] == '1') 
    4388                                                 { 
    4389  
    4390                                                     for($i_events = 0; $i_events < count($eventsCached) ; $i_events++) 
     4302                                                $events = $this->bo->cached_events[$date]; 
     4303                                                foreach($events as $event) 
    43914304                                                        { 
    4392                                                         if ($eventsCached[$i_events]['users_status'] == 'R') 
    4393                                                         { 
    4394                                                                 continue;       // user does not want to see rejected events 
    4395                                                         } 
    4396                                                         $events[] = $eventsCached[$i_events]; 
    4397                                                     } 
    4398                                                     /*echo "<pre>"; 
    4399                                                         print_r($events1); 
    4400  
    4401                                                     echo "</pre>"; 
    4402                                                     exit();*/ 
    4403  
    4404                                                     $newEvents = Array(); 
    4405                                                     $eventAux = Array 
    4406                                                                 ( 
    4407                                                                     'owner' => '', 
    4408                                                                     'id' => '', 
    4409                                                                     'type' => '', 
    4410                                                                     'public' => '', 
    4411                                                                     'category' => '', 
    4412                                                                     'title' => '', 
    4413                                                                     'description' => '', 
    4414                                                                     'alter_by' => '', 
    4415                                                                     'observations' => '', 
    4416                                                                     'attachment' => '', 
    4417                                                                     'ex_participants' => '', 
    4418                                                                     'uid' => '', 
    4419                                                                     'location' => '', 
    4420                                                                     'reference' => '', 
    4421                                                                     'start' => Array 
    4422                                                                         ( 
    4423                                                                             'year' => '', 
    4424                                                                             'month' => '', 
    4425                                                                             'mday' => '', 
    4426                                                                             'hour' => '', 
    4427                                                                             'min' => '', 
    4428                                                                             'sec' => '', 
    4429                                                                             'alarm' => '', 
    4430                                                                         ), 
    4431  
    4432                                                                     'modtime' => Array 
    4433                                                                         ( 
    4434                                                                         ), 
    4435  
    4436                                                                     'end' => Array 
    4437                                                                         ( 
    4438                                                                             'year' => '', 
    4439                                                                             'month' => '', 
    4440                                                                             'mday' => '', 
    4441                                                                             'hour' => '', 
    4442                                                                             'min' => '', 
    4443                                                                             'sec' => '', 
    4444                                                                             'alarm' => '', 
    4445                                                                         ), 
    4446  
    4447                                                                     'priority' => '', 
    4448                                                                     'users_status' => '', 
    4449                                                                     'participants' => Array 
    4450                                                                         ( 
    4451                                                                         ), 
    4452  
    4453                                                                     'alarm' => Array 
    4454                                                                         ( 
    4455                                                                         ), 
    4456  
    4457                                                                 ); 
    4458  
    4459                                                     $delta = 60; //em segundos 
    4460                                                     for($i_events = 0; $i_events < count($events) ; $i_events++) 
    4461                                                     { 
    4462  
    4463                                                         $newEvents[] = $events[$i_events]; 
    4464  
    4465                                                         $hf_current = mktime($events[$i_events]['end']['hour'], 0, 0, $month, $day, $year); 
    4466                                                         $hi_prox = mktime($events[$i_events+1]['start']['hour'], 0, 0, $month, $day, $year); 
    4467  
    4468                                                         if($events[$i_events]['end']['min'] > 0) 
    4469                                                         { 
    4470                                                             $hf_current += 60*$delta; 
    4471                                                         } 
    4472  
    4473                                                         while($hi_prox > $hf_current) 
    4474                                                         { 
    4475  
    4476                                                             $aux1 = date('Y:m:d:H:i:s',$hf_current); 
    4477                                                             $aux2 = explode(':',$aux1); 
    4478                                                             $eventAux['start']['year'] = $aux2[0]; 
    4479                                                             $eventAux['start']['month'] = $aux2[1]; 
    4480                                                             $eventAux['start']['mday'] = $aux2[2]; 
    4481                                                             $eventAux['start']['hour'] = $aux2[3]; 
    4482                                                             $eventAux['start']['min'] = $aux2[4]; 
    4483                                                             $eventAux['start']['sec'] = $aux2[5]; 
    4484  
    4485                                                             //$aux3 = date('Y:m:d:H:i:s',$hf_current); 
    4486                                                             //$aux4 = explode(':',$aux3); 
    4487                                                             $eventAux['end']['year'] = $aux2[0]; 
    4488                                                             $eventAux['end']['month'] = $aux2[1]; 
    4489                                                             $eventAux['end']['mday'] = $aux2[2]; 
    4490                                                             $eventAux['end']['hour'] = $aux2[3]; 
    4491                                                             $eventAux['end']['min'] = $aux2[4]; 
    4492                                                             $eventAux['end']['sec'] = $aux2[5]; 
    4493  
    4494                                                             $eventAux['owner'] = $GLOBALS['phpgw_info']['user']['account_id']; 
    4495                                                             $eventAux['title'] = "\n\n\n"; 
    4496                                                             $eventAux['description'] = ''; 
    4497                                                             $eventAux['observations'] = ''; 
    4498                                                             $eventAux['location'] = ''; 
    4499  
    4500                                                             $newEvents[] = $eventAux; 
    4501                                                             $hf_current += 60*$delta; 
    4502  
    4503                                                         } 
    4504                                                     } 
    4505  
    4506                                                     foreach($newEvents as $event) 
    4507                                                     { 
    4508                                                         $p->set_var('day_events',$this->link_to_month_entry($event,$month,$day,$year)); 
    4509                                                         $p->parse('events','event',True); 
    4510                                                         $p->set_var('day_events',''); 
    4511                                                 } 
    4512                                         } 
    4513                                                 else 
    4514                                                 { 
    4515                                                     foreach($eventsCached as $event) 
    4516                                                     { 
    4517                                                         if ($this->bo->rejected_no_show($event) || $event['users_status'] == 'R') 
     4305                                                        if ($this->bo->rejected_no_show($event)) 
    45184306                                                        { 
    45194307                                                                continue;       // user does not want to see rejected events 
     
    45224310                                                        $p->parse('events','event',True); 
    45234311                                                        $p->set_var('day_events',''); 
    4524                                                     } 
    45254312                                                } 
    4526  
    4527                                                 /*echo "<pre>"; 
    4528                                                     print_r($newEvents); 
    4529  
    4530                                                 echo "</pre>"; 
    4531                                                 exit();*/ 
    45324313                                        } 
    45334314                                        $p->parse('daily_events','day_event',True); 
     
    45524333                        } 
    45534334 
     4335/*                      $this->bo->store_to_cache( 
     4336                                Array( 
     4337                                        'syear' => $year, 
     4338                                        'smonth'=> $month, 
     4339                                        'sday'  => 1 
     4340                                ) 
     4341                        ); 
     4342*/ 
    45544343                        $day_ini = $_GET['day_ini'];// dia do inicio da impressao; o padrao e o dia atual; 
    45554344                        $num_dias = $_GET['num_dias'];// quantidade de dias a partir do dia inicial; 
     
    45584347//                      $monthend   = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year))); 
    45594348 
    4560                         if($num_dias != '') 
     4349                        if($num_dias != 0) 
    45614350                        { 
    45624351                                //se a qtde de dias for informada, a data final para impressao considera a soma $day_ini+$num_dias; 
     
    46094398 
    46104399                        $var = Array( 
    4611                                 'cols'      => 1 
    4612                                 //'day_events'=> '' 
    4613                         ); 
     4400                                'cols'      => 1, 
     4401                                'day_events'=> '' //$this->month_week_header($month,$year,False) 
     4402                        ); 
     4403//                      $this->output_template_array($p,'row','event',$var); 
    46144404 
    46154405                        $cellcolor = $this->theme['row_on']; 
     
    46294419/***************************************************************************************/ 
    46304420 
    4631                 function display_month($params) //($month,$year,$showyear,$owner=0) 
    4632                 { 
    4633                         $month = $params['month']; 
    4634                         $year = $params['year']; 
    4635                         $showyear = $params['showyear']; 
    4636                         $owner = $params['owner']; 
    4637  
     4421                function display_month($month,$year,$showyear,$owner=0) 
     4422                { 
    46384423                        if($this->debug) 
    46394424                        { 
     
    46784463 
    46794464                        $cellcolor = $this->theme['row_on']; 
    4680  
    4681                         $result_events_json = $this->print_events_to_show_json($params); 
    4682                         $p->set_var('date','Date(2011,1,1)'); 
    4683                         $p->set_var('hora_final',$result_events_json['hora_final']); 
    4684                         $p->set_var('events_json',json_encode($result_events_json['events_to_show_json'])?json_encode($result_events_json['events_to_show_json']):'null'); 
    4685  
    46864465 
    46874466                        for($i = (int)($start + $GLOBALS['phpgw']->datetime->tz_offset);(int)(date('Ymd',$i)) <= $monthend;$i += 604800) 
     
    47894568                        $p->set_block('view','hr','hr'); 
    47904569 
     4570                        include_once($_SESSION['rootPath'].'/calendar/inc/class.ex_participants.inc.php'); 
     4571                        $langp = array(); 
     4572                        $langp['ACCEPTED'] = lang('Accepted'); 
     4573                        $langp['DECLINED'] = lang('Declined'); 
     4574                        $langp['TENTATIVE'] = lang('Tentative'); 
     4575                        $langp['DELEGATED'] = lang('Delegated'); 
     4576                        $langp['NO ANSWER'] = lang('No answer'); 
     4577                        $exParticipants = new exParticipants($langp); 
     4578                        $exParticipants->setParticipantsBySerializable($event['ex_participants']); 
     4579                        $event['ex_participants'] = $exParticipants->getParticipantsView(); 
     4580 
    47914581                        $vars = $this->bo->event2array($event); 
    4792  
    4793                         if($vars['attachment']['data'] == "") 
    4794                             $vars['attachment']['data'] = lang('No Attachment'); 
    4795                         else{ 
    4796                             $vars['attachment']['data'] = lang('Has attachment(s)'); 
    4797                         } 
    47984582                         
    47994583                        $vars['title']['tr_color'] = $this->theme['th_bg']; 
     
    48044588                                { 
    48054589                                        $vars['participants']['data'][$user] = $parts[1].' (<a href="'.$this->page('edit_status','&cal_id='.$event['id'].'&owner='.$user).'">'.$parts[2].'</a>)'; 
    4806                                         $vars['participants']['data'][$user].='&nbsp;(<a href=\'index.php?menuaction=calendar.uicalendar.screen_delegate_event&id_event='.$event['id'].'&delegator='.$user.'&date='.$_REQUEST["date"].'&eventArray='.$event.'\'>'.lang("Delegate event").'</a>)'; 
    4807 //system('echo "event: '.$event['start'].'" >>/tmp/controle'); 
    48084590                                } 
    48094591                        } 
     
    50514833                        return $p->fp('out','day'); 
    50524834                }       // end function 
    5053  
    5054                 //função para exibição do calendário novo. 
    5055  
    5056                 function print_day_new($params){ 
    5057                         $this->bo->store_to_cache( 
    5058                         Array( 
    5059                                         'syear'  => $params['year'], 
    5060                                         'smonth' => $params['month'], 
    5061                                         'sday'   => $params['day'], 
    5062                                         'eyear'  => $params['year'], 
    5063                                         'emonth' => $params['month'], 
    5064                                         'eday'   => $params['day'] 
    5065                                 ) 
    5066                         ); 
    5067  
    5068                         $p = CreateObject('phpgwapi.Template',$this->template_dir); 
    5069                         $p->set_unknowns('keep'); 
    5070  
    5071                         $tpl = 'day_cal.tpl'; 
    5072                         //$new_component_tpl = 'new_component.tpl'; 
    5073  
    5074                         if((int)($GLOBALS['phpgw_info']['user']['preferences']['calendar']['mainscreen_showevents'])==2 && 
    5075                                 $GLOBALS['phpgw_info']['flags']['currentapp'] == 'home') 
    5076                         { 
    5077                                 $tpl = 'day_list.tpl'; 
    5078                         } 
    5079  
    5080                         $templates = Array( 
    5081                                 'day_cal'   => $tpl 
    5082                                 //'new_component_tpl' => $new_component_tpl 
    5083                         ); 
    5084  
    5085                         $templateSet = $GLOBALS['phpgw_info']['server']['template_set']; 
    5086  
    5087                         if(isset($_GET['date'])) 
    5088                         { 
    5089                             $dia = substr($_GET['date'],-2); 
    5090                         } 
    5091                         elseif(isset($_POST['day'])) 
    5092                         { 
    5093                             $dia = $_POST['day']; 
    5094                         } 
    5095                         else 
    5096                         { 
    5097                             $dia = $params['day']; 
    5098                         } 
    5099                          
    5100                         $print =  '<a href="javascript:void(0)" id="printFriendly">['.lang('Printer Friendly').']</a>'; 
    5101                         $param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'.'&day_ini='.$dia.'&num_dias=1'.'&d=1'; 
    5102  
    5103                         $p->set_file($templates); 
    5104                         $p->set_block('day_cal','day','day'); 
    5105                         //$p->set_block('new_component_tpl','new_component','new_component'); 
    5106                         $params['period'] = 1; 
    5107                         $result_events_json = $this->print_events_to_show_json($params); 
    5108                         $p->set_var('date',$result_events_json['date_events_json']); 
    5109                         $p->set_var('templateSet',$templateSet); 
    5110                         $p->set_var('iprint',$print); 
    5111                         $p->set_var('param',$param); 
    5112                         $p->set_var('hora_final',$result_events_json['hora_final']); 
    5113                         $p->set_var('hora_inicial',$result_events_json['hora_inicial']); 
    5114                         $p->set_var('hour_size_px',$result_events_json['hour_size_px']); 
    5115  
    5116                         $p->set_var('events_json',json_encode($result_events_json['events_to_show_json'])?json_encode($result_events_json['events_to_show_json']):'null'); 
    5117                         return $p->fp('out','day'); 
    5118                 } 
    5119  
    5120                 function print_week_new($params){ 
    5121  
    5122                     $p = CreateObject('phpgwapi.Template',$this->template_dir); 
    5123                     $p->set_unknowns('keep'); 
    5124  
    5125                     $tpl = 'new_week.tpl'; 
    5126  
    5127                     if((int)($GLOBALS['phpgw_info']['user']['preferences']['calendar']['mainscreen_showevents'])==2 && 
    5128                     $GLOBALS['phpgw_info']['flags']['currentapp'] == 'home') 
    5129                     { 
    5130                         $tpl = 'day_list.tpl'; 
    5131                     } 
    5132  
    5133                     $minical_prev = $this->mini_calendar( 
    5134                         Array( 
    5135                             'day'               => 1, 
    5136                             'month'             => $this->bo->month, 
    5137                             'year'              => $this->bo->year, 
    5138                             'link'              => 'week', 
    5139                             'control'           => False, 
    5140                             'outside_month'     => False 
    5141                             ) 
    5142                     ); 
    5143  
    5144                     $minical_next1 = $this->mini_calendar( 
    5145                         Array( 
    5146                             'day'               => 1, 
    5147                             'month'             => $this->bo->month+2, 
    5148                             'year'              => $this->bo->year, 
    5149                             'link'              => 'week', 
    5150                             'control'           => False, 
    5151                             'outside_month'     => False 
    5152                         ) 
    5153                     ); 
    5154  
    5155                     $minical_next = $this->mini_calendar( 
    5156                         Array( 
    5157                             'day'               => 1, 
    5158                             'month'             => $this->bo->month+1, 
    5159                             'year'              => $this->bo->year, 
    5160                             'link'              => 'week', 
    5161                             'control'           => False, 
    5162                             'outside_month'     => False 
    5163                         ) 
    5164                     ); 
    5165                     $this->bo->read_holidays($params['year']); 
    5166                     $next = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day + 7,$this->bo->year); 
    5167                     $prev = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day - 7,$this->bo->year); 
    5168                     $prev_week_link = '<a href="'.$this->page('week','&date='.$prev['full']).'">&lt;&lt;</a>'; 
    5169                     $next_week_link = '<a href="'.$this->page('week','&date='.$next['full']).'">&gt;&gt;</a>'; 
    5170  
    5171                     $daily = $this->set_week_array($GLOBALS['phpgw']->datetime->get_weekday_start($params['year'],$params['month'],$params['day']),$this->theme['row_on'],True); 
    5172                     foreach($daily as $key => $value) 
    5173                     { 
    5174                         $dates[] = $key; 
    5175                     } 
    5176  
    5177                     $day_ini = (int)substr($dates[0],6,2); 
    5178  
    5179                     $print =  '<a href="javascript:void(0)" id="printFriendly">['.lang('Printer Friendly').']</a>'; 
    5180  
    5181                     $param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'.'&day_ini='.$day_ini.'&num_dias=7'; 
    5182  
    5183                     $m = mktime(0,0,0,$this->bo->month,1,$this->bo->year); 
    5184  
    5185                     $templates = Array( 
    5186                         'new_week'   => $tpl, 
    5187                     ); 
    5188                     $feriados_do_ano = Array(); 
    5189                     foreach ($this->bo->cached_holidays as $key => $value) 
    5190                         { 
    5191                             $feriados_do_ano[$key] = utf8_encode($this->bo->cached_holidays[$key][0]['name']); 
    5192                         } 
    5193                     $p->set_file($templates); 
    5194                     $p->set_block('new_week','day','day'); 
    5195                     $params['period'] = 2; 
    5196                     $result_events_json = $this->print_events_to_show_json($params); 
    5197                     $p->set_var('date',$result_events_json['date_events_json']); 
    5198                     $p->set_var('hora_final',$result_events_json['hora_final']); 
    5199                     $p->set_var('hora_inicial',$result_events_json['hora_inicial']); 
    5200                     $p->set_var('minical',$minical_prev.'<br>'.$minical_next.'<br>'.$minical_next1); 
    5201                     $p->set_var('iprint',$print); 
    5202                     $p->set_var('param',$param); 
    5203                     $p->set_var('title',$prev_week_link.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;::'.$this->bo->get_week_label().'::&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$next_week_link); 
    5204                     $p->set_var('user',$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner)); 
    5205                     $p->set_var('events_json',json_encode($result_events_json['events_to_show_json'])?json_encode($result_events_json['events_to_show_json']):'null'); 
    5206                     $p->set_var('holidays_json',json_encode($feriados_do_ano)?json_encode($feriados_do_ano):null); 
    5207                     return $p->fp('out','day'); 
    5208  
    5209                 } 
    5210  
    5211                 function print_month_new($params){ 
    5212  
    5213                         $p = CreateObject('phpgwapi.Template',$this->template_dir); 
    5214                         $p->set_unknowns('keep'); 
    5215                         $tpl = 'new_month.tpl'; 
    5216  
    5217                         if((int)($GLOBALS['phpgw_info']['user']['preferences']['calendar']['mainscreen_showevents'])==2 && 
    5218                                 $GLOBALS['phpgw_info']['flags']['currentapp'] == 'home') 
    5219                         { 
    5220                                 $tpl = 'day_list.tpl'; 
    5221                         } 
    5222  
    5223  
    5224  
    5225                         $templates = Array( 
    5226                                 'new_month'   => $tpl, 
    5227                         ); 
    5228  
    5229                         $minical_prev = $this->mini_calendar( 
    5230                                         Array( 
    5231                                                 'day'           => 1, 
    5232                                                 'month'         => $this->bo->month -1, 
    5233                                                 'year'          => $this->bo->year, 
    5234                                                 'link'          => 'day', 
    5235                                                 'control'       => False, 
    5236                                                 'outside_month' => False 
    5237                                         ) 
    5238                                 ); 
    5239  
    5240                         $minical_next1 = $this->mini_calendar( 
    5241                                         Array( 
    5242                                                 'day'           => 1, 
    5243                                                 'month'         => $this->bo->month + 2, 
    5244                                                 'year'          => $this->bo->year, 
    5245                                                 'link'          => 'day', 
    5246                                                 'control'       => False, 
    5247                                                 'outside_month' => False 
    5248                                         ) 
    5249                                 ); 
    5250  
    5251                         $minical_next = $this->mini_calendar( 
    5252                                         Array( 
    5253                                                 'day'           => 1, 
    5254                                                 'month'         => $this->bo->month + 1, 
    5255                                                 'year'          => $this->bo->year, 
    5256                                                 'link'          => 'day', 
    5257                                                 'control'       => False, 
    5258                                                 'outside_month' => False 
    5259                                         ) 
    5260                                 ); 
    5261                         $this->bo->read_holidays($params['year']); 
    5262                         $print =  '<a href="javascript:void(0)" id="printFriendly">['.lang('Printer Friendly').']</a>'; 
    5263  
    5264                         $param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'; 
    5265  
    5266                         $next = $this->bo->month + 1; 
    5267                         $prev = $this->bo->month - 1; 
    5268                         $nextyear = $this->bo->year; 
    5269                         $prevyear = $this->bo->year; 
    5270                         if ($this->bo->month == 12) 
    5271                         { 
    5272                                 $next = 1; 
    5273                                 $nextyear = $nextyear + 1; 
    5274                         } 
    5275                         elseif ($this->bo->month == 1) 
    5276                         { 
    5277                                 $prev = 12; 
    5278                                 $prevyear = $prevyear - 1; 
    5279                         } 
    5280  
    5281                         $feriados_do_ano = Array(); 
    5282                         foreach ($this->bo->cached_holidays as $key => $value) 
    5283                         { 
    5284                             $feriados_do_ano[$key] = utf8_encode($this->bo->cached_holidays[$key][0]['name']); 
    5285                         } 
    5286                         $m = mktime(0,0,0,$this->bo->month,1,$this->bo->year); 
    5287                         $p->set_file($templates); 
    5288                         $p->set_block('new_month','day','day'); 
    5289                         $params['period'] = 3; 
    5290                         $result_events_json = $this->print_events_to_show_json($params); 
    5291                         $prev_month_link = '<a href="'.$this->page('month','&year='.$prevyear.'&month='.$prev.'&sday='.$sday).'">&lt;&lt;</a>'; 
    5292                         $next_month_link = '<a href="'.$this->page('month','&year='.$nextyear.'&month='.$next.'&sday='.$sday).'">&gt;&gt;</a>'; 
    5293                         $p->set_var('date',$result_events_json['date_events_json']); 
    5294                         $p->set_var('hora_final',$result_events_json['hora_final']); 
    5295                         $p->set_var('hora_inicial',$result_events_json['hora_inicial']); 
    5296                         $p->set_var('minical',$minical_prev.'<br>'.$minical_next.'<br>'.$minical_next1); 
    5297                         $p->set_var('iprint',$print); 
    5298                         $p->set_var('param',$param); 
    5299                         $p->set_var('title',$prev_month_link."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;::".lang(strftime("%B",$m)).' '.$this->bo->year.'::&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$next_month_link); 
    5300                         $p->set_var('user',$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner)); 
    5301                         $p->set_var('events_json',json_encode($result_events_json['events_to_show_json'])?json_encode($result_events_json['events_to_show_json']):'null'); 
    5302                         $p->set_var('holidays_json',json_encode($feriados_do_ano)?json_encode($feriados_do_ano):null); 
    5303                         return $p->fp('out','day'); 
    5304                 } 
    5305  
    5306                 //função vai devolver os eventos do mês atual para exibição no novo componente da Agenda 
    5307                 function print_events_to_show_json($params) 
    5308                 { 
    5309  
    5310                         if( (!isset($this->bo->prefs['calendar']['interval'])) || ( (isset($this->bo->prefs['calendar']['interval'])) && ( ($this->bo->prefs['calendar']['interval'] != 42) && ($this->bo->prefs['calendar']['interval'] != 84) ) ) ) 
    5311                         { 
    5312                                 $this->bo->prefs['calendar']['interval'] = 42; 
    5313                                 $GLOBALS['phpgw']->preferences->add('calendar','interval',42); 
    5314                                 $GLOBALS['phpgw']->preferences->save_repository(); 
    5315                         } 
    5316  
    5317                         if(!is_array($params)) 
    5318                         { 
    5319                                 $this->index(); 
    5320                         } 
    5321  
    5322                         // $params['period'] pode ser 1 pra dia, 2 pra semana e 3 pra mes 
    5323  
    5324                         if(!$params['period'] || $params['period'] == '') 
    5325                             $period = 3; 
    5326                         else 
    5327                             $period = $params['period']; 
    5328                         $accounts = CreateObject('phpgwapi.accounts'); 
    5329                         $accountId = $accounts->name2id($account_name); 
    5330                         $date_to_eval = sprintf("%04d%02d%02d",$params['year'],$params['month'],$params['day']); 
    5331                         $dates = array(); 
    5332                         if($period == 1){ 
    5333                             $dates[] = $date_to_eval; 
    5334                             $this->bo->store_to_cache( 
    5335                                 Array( 
    5336                                         'smonth'=> $params['month'], 
    5337                                         'sday'  => $params['day'], 
    5338                                         'syear' => $params['year'] 
    5339                                 ) 
    5340                             ); 
    5341                         }else if($period == 2){ 
    5342                             $daily = $this->set_week_array($GLOBALS['phpgw']->datetime->get_weekday_start($params['year'],$params['month'],$params['day']),$this->theme['row_on'],True); 
    5343  
    5344                             foreach($daily as $key => $value) 
    5345                                 $dates[] = $key; 
    5346  
    5347                              $this->bo->store_to_cache( 
    5348                                 Array( 
    5349                                         'smonth'=> (int)substr($dates[0],4,2), 
    5350                                         'sday'  => (int)substr($dates[0],6), 
    5351                                         'syear' => (int)substr($dates[0],0,4), 
    5352                                         'eyear' => 0, 
    5353                                         'emonth'=> 0, 
    5354                                         'eday'  => ((int)substr($dates[0],6))+6, 
    5355                                 ) 
    5356                             ); 
    5357                         }else{ 
    5358                              $month_tmp = substr($date_to_eval, 0, 6); 
    5359  
    5360                              $this->bo->store_to_cache( 
    5361                                 Array( 
    5362                                         'smonth'=> (int)substr($date_to_eval,4,2), 
    5363                                         'sday'  => 1, 
    5364                                         'syear' => (int)substr($date_to_eval,0,4), 
    5365                                         'eyear' => 0, 
    5366                                         'emonth'=> 0, 
    5367                                         'eday'  => ((int)substr($date_to_eval,6))+30, 
    5368                                 ) 
    5369                             ); 
    5370                              for( $i=1 ; $i<=31; $i++){ 
    5371                                  if($i<10) 
    5372                                      $day= $month_tmp."0".(string)$i; 
    5373                                  else 
    5374                                      $day=$month_tmp.(string)$i; 
    5375                                  $dates[] = $day; 
    5376  
    5377                              } 
    5378  
    5379                         } 
    5380  
    5381                         $prefs = CreateObject('phpgwapi.preferences', $accountId); 
    5382                         $account_prefs = $prefs->read(); 
    5383                         //print_debug('in print_day()'); 
    5384  
    5385                         $month = (string)((Int)$params['month']-1); 
    5386                         $date_events_json = 'Date('.$params['year'].','.$month.','.$params['day'].')'; 
    5387  
    5388                         print_debug('Date to Eval',$date_to_eval); 
    5389  
    5390                         $hora_inicial = $account_prefs['calendar']['workdaystarts']; 
    5391                         $hora_final = $account_prefs['calendar']['workdayends']; //18; 
    5392  
    5393                         $hour_size_px = $account_prefs['calendar']['interval'] ? $account_prefs['calendar']['interval'] : 42; 
    5394  
    5395                         $title_view = $account_prefs['calendar']['title_view']; 
    5396  
    5397                         $events_to_show_json = array(); 
    5398                         $templateSet = $GLOBALS['phpgw_info']['server']['template_set']; 
    5399                         foreach($dates as $day) 
    5400                         { 
    5401  
    5402                             $events = $this->bo->cached_events[$day]; 
    5403  
    5404                             foreach($events as $event) 
    5405                             { 
    5406                                 //$is_private = !$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event); 
    5407                                 if($event['users_status'] == 'R' && $this->bo->prefs['calendar']['show_rejected'] == 0 && $event['owner']  != $GLOBALS['phpgw_info']['user']['account_id']) 
    5408                                         continue; 
    5409  
    5410                                 if($event['recur_type']){ 
    5411                                     $recur = $day; 
    5412                                     $event['start']['year'] = (int)substr($day,0,4); 
    5413                                     $event['start']['month'] = (int)substr($day,4,2); 
    5414                                     $event['start']['mday'] = (int)substr($day,6,2); 
    5415                                     $event['end']['year'] =  (int)substr($day,0,4); 
    5416                                     $event['end']['month'] = (int)substr($day,4,2); 
    5417                                     $event['end']['mday'] = (int)substr($day,6,2); 
    5418                                     $event['id'] = $event['id'].'rc'.$day; 
    5419                                 }else{ 
    5420                                     $recur = false; 
    5421                                 } 
    5422  
    5423                                 $isPublic = 1; 
    5424                                 if(($event['type'] == E && $event['public'] == 0)) 
    5425                                 { 
    5426                                     $isPublic = 0; 
    5427                                     $isPublicTitle = lang('restrict'); 
    5428                                 } 
    5429  
    5430                                 if(($event['type'] == P && $event['public'] == 0)) 
    5431                                 { 
    5432                                     $isPublic = 0; 
    5433                                     $isPublicTitle = lang('private'); 
    5434                                 } 
    5435  
    5436                                 $eventTime = ( (mktime($event['end']['hour'], $event['end']['min'], 0, $event['end']['month'], $event['end']['mday'], $event['end']['year'])-mktime($event['start']['hour'], $event['start']['min'], 0, $event['start']['month'], $event['start']['mday'], $event['start']['year']) )/60 ); 
    5437  
    5438                                 $participants = $this->planner_participants($event['participants']); 
    5439                                 $intersection = FALSE; 
    5440  
    5441                                 foreach($events as $ev) 
    5442                                 { 
    5443                                     if($ev['id'] == $event['id']) continue; 
    5444                                       if($ev['users_status'] == 'R') continue; 
    5445                                       $event_start = 60*$event['start']['hour']+$event['start']['min']; 
    5446                                       $event_end = 60*$event['end']['hour']+$event['end']['min']; 
    5447                                       $event_i_start = 60*$ev['start']['hour']+$ev['start']['min']; 
    5448                                       $event_i_end = 60*$ev['end']['hour']+$ev['end']['min']; 
    5449                                     if((($event_start >= $event_i_start) && ($event_start < $event_i_end))||(($event_start < $event_i_start) && ($event_i_start < $event_end))) 
    5450                                     { 
    5451                                         $intersection = TRUE; 
    5452                                         break; 
    5453                                     } 
    5454                                 } 
    5455                                 if($event['users_status'] == 'R') 
    5456                                 { 
    5457                                     $rejected = TRUE; 
    5458                                 } 
    5459                                 else 
    5460                                 { 
    5461                                     $rejected = FALSE; 
    5462                                 } 
    5463  
    5464                                 $evDescription = ''; 
    5465                                 if($title_view == 0) 
    5466                                 { 
    5467                                     $evDescription = " - ".$event['description']; 
    5468                                 } 
    5469  
    5470                                 if($_GET['menuaction'] ==  'calendar.uicalendar.day') 
    5471                                 { 
    5472                                     $text = $event['description']; 
    5473                                 } 
    5474                                 elseif($_GET['menuaction'] ==  'calendar.uicalendar.week') 
    5475                                 { 
    5476                                      
    5477                                     $text = ' - '.$event['end']['hour'].':'.$event['end']['min']; 
    5478  
    5479                                     //is recurrent? 
    5480                                     $text .= (isset($recur) && $recur != false) ? ' ' . '<img width="10px" height="10px" border="0" title="'.lang('recurring event').'" src="calendar/templates/'.$templateSet.'/images/recur.png"/>' : '' ; 
    5481  
    5482                                     //participants? 
    5483                                     if(count($event['participants']) > 1) 
    5484                                     { 
    5485                                         $text .= " " . '<img width="11px" height="10px" border="0" title="'.$participants.'" src="calendar/templates/'.$templateSet.'/images/multi_3.png"/>'; 
    5486                                     } 
    5487                                     else 
    5488                                     { 
    5489                                         $text .= " " . '<img width="11px" height="10px" border="0" title="'.$participants.'" src="calendar/templates/'.$templateSet.'/images/single.png"/>'; 
    5490                                     } 
    5491  
    5492                                     //has attachments? 
    5493                                     $text .= (isset($event['attachment']) && $event['attachment'] != '') ? ' ' . '<img width="10px" height="10px" border="0" title="'.lang('email notifications with attachments has been sent').'" src="calendar/templates/'.$templateSet.'/images/clip.png"/>' : '' ; 
    5494  
    5495                                     //is public? 
    5496                                     $text .= $isPublic == 0 ? ' ' . '<img width="11px" height="10px" border="0" title="'.$isPublicTitle.'" src="calendar/templates/'.$templateSet.'/images/private.png"/>' : '' ; 
    5497  
    5498                                     //has alarm? 
    5499                                     $text .= (isset($event['alarm']) && count($event['alarm']) >= 1) ? ' ' . '<img width="11px" height="10px" border="0" title="'.lang('alarm').'" src="calendar/templates/'.$templateSet.'/images/alarm.png"/>' : '' ; 
    5500  
    5501                                     $text .= ' - ' . $event['title'].$evDescription; 
    5502                                 } 
    5503                                 else 
    5504                                 { 
    5505                                     $text = ' - '.$event['end']['hour'].':'.$event['end']['min'] . ' - '. $event['title'].$evDescription; 
    5506                                 } 
    5507  
    5508                                 $events_to_show_json[] = array( 
    5509                                     start_date              => $event['start']['year'].'-'.$event['start']['month'].'-'.$event['start']['mday'].' '.$event['start']['hour'].':'.$event['start']['min'], 
    5510                                     end_date                => $event['end']['year'].'-'.$event['end']['month'].'-'.$event['end']['mday'].' '.$event['end']['hour'].':'.$event['end']['min'] . ' - ' . utf8_encode($event['title']), 
    5511                                     text                    => utf8_encode($text), 
    5512                                     textTitle               => utf8_encode($event['description']), //week and month tooltip 
    5513                                     descOnTitle             => ($eventTime <= 57) ? 1 : 0, 
    5514                                     title                   => utf8_encode($event['title']), 
    5515                                     observation             => utf8_encode($event['observations']), 
    5516                                     location                => utf8_encode($event['location']), 
    5517                                     id                      => $event['id'], 
    5518                                     participants            => (count($event['participants']) > 1) ? 1 : 0, 
    5519                                     participants_title      => $participants, 
    5520                                     attachments             => $event['attachment'] ? 1 : 0 , 
    5521                                     attachmentsTitle        => utf8_encode(lang('email notifications with attachments has been sent')), 
    5522                                     isPublic                => $isPublic, 
    5523                                     isPublicTitle           => utf8_encode($isPublicTitle), 
    5524                                     alarm                   => (isset($event['alarm']) && count($event['alarm']) >= 1) ? 1 : 0, 
    5525                                     alarmTitle              => utf8_encode(lang('alarm')), 
    5526                                     recur                   => $recur, 
    5527                                     recurTitle              => utf8_encode(lang('recurring event')), 
    5528                                     intersection            => $intersection, 
    5529                                     rejected                => $rejected, 
    5530                                     title_view              => $title_view 
    5531                                 ); 
    5532  
    5533                                 if($event['start']['hour'] < $hora_inicial) 
    5534                                 { 
    5535                                     $hora_inicial = $event['start']['hour']; 
    5536                                 } 
    5537  
    5538                                 if($event['end']['hour'] >= $hora_final) 
    5539                                 { 
    5540                                     $hora_final = $event['end']['hour'] + 1; 
    5541                                 } 
    5542                             } 
    5543                         } 
    5544  
    5545                         $result = Array( 
    5546                             'hora_inicial'          => $hora_inicial, 
    5547                             'hora_final'            => $hora_final, 
    5548                             'hour_size_px'          => $hour_size_px, 
    5549                             'date_events_json'      => $date_events_json, 
    5550                             'events_to_show_json'   => $events_to_show_json 
    5551                         ); 
    5552  
    5553                         return $result; 
    5554                 }       // end function 
    5555  
    5556  
    55574835 
    55584836                function timematrix($param) 
     
    56934971                        { 
    56944972                                $var = Array( 
    5695                                         'action_url_button'     => $this->page('set_action','&cal_id='.$cal_id.'&action='.$param.'&user_id='.$this->bo->owner), 
     4973                                        'action_url_button'     => $this->page('set_action','&cal_id='.$cal_id.'&action='.$param.'&user='.$this->bo->owner), 
    56964974                                        'action_text_button'    => '  '.$text.'  ', 
    56974975                                        'action_confirm_button' => '', 
     
    57255003                function edit_form($param) 
    57265004                { 
     5005                        $sHValue = '<option></option> 
     5006                                    <option value="07:00">07:00</option> 
     5007                                    <option value="07:30">07:30</option> 
     5008                                    <option value="08:00">08:00</option> 
     5009                                    <option value="08:30">08:30</option> 
     5010                                    <option value="09:00">09:00</option> 
     5011                                    <option value="09:30">09:30</option> 
     5012                                    <option value="10:00">10:00</option> 
     5013                                    <option value="10:30">10:30</option> 
     5014                                    <option value="11:00">11:00</option> 
     5015                                    <option value="11:30">11:30</option> 
     5016                                    <option value="12:00">12:00</option> 
     5017                                    <option value="12:30">12:30</option> 
     5018                                    <option value="13:00">13:00</option> 
     5019                                    <option value="13:30">13:30</option> 
     5020                                    <option value="14:00">14:00</option> 
     5021                                    <option value="14:30">14:30</option> 
     5022                                    <option value="15:00">15:00</option> 
     5023                                    <option value="15:30">15:30</option> 
     5024                                    <option value="16:00">16:00</option> 
     5025                                    <option value="16:30">16:30</option> 
     5026                                    <option value="17:00">17:00</option> 
     5027                                    <option value="17:30">17:30</option> 
     5028                                    <option value="18:00">18:00</option> 
     5029                                    <option value="18:30">18:30</option> 
     5030                                    <option value="19:00">19:00</option> 
     5031                                    <option value="19:30">19:30</option> 
     5032                                    <option value="20:00">20:00</option> 
     5033                                    <option value="20:30">20:30</option> 
     5034                                    <option value="21:00">21:00</option> 
     5035                                    <option value="21:30">21:30</option> 
     5036                                    <option value="22:00">22:00</option>'; 
     5037                     
    57275038                        if(!is_array($param)) 
    57285039                        { 
     
    57355046                        } 
    57365047                         
     5048                        include_once($_SESSION['rootPath'].'/calendar/inc/class.ex_participants.inc.php'); 
     5049                        $langp = array(); 
     5050                        $langp['ACCEPTED'] = lang('Accepted'); 
     5051                        $langp['DECLINED'] = lang('Declined'); 
     5052                        $langp['TENTATIVE'] = lang('Tentative'); 
     5053                        $langp['DELEGATED'] = lang('Delegated'); 
     5054                        $langp['NO ANSWER'] = lang('No answer'); 
     5055                        $exParticipants = new exParticipants($langp); 
     5056                        $exParticipants->setParticipantsBySerializable($event['ex_participants']); 
     5057                        $event['ex_participants'] = $exParticipants->getParticipantsMailsString(); 
    57375058                        $hourformat = substr($this->bo->users_timeformat,0,1); 
    5738                          
    57395059                        // $sb = CreateObject('phpgwapi.sbox'); 
    57405060                        $sb = CreateObject('phpgwapi.sbox2'); 
     
    57645084                        $p->set_block('edit','list','list'); 
    57655085                        $p->set_block('edit','hr','hr'); 
    5766                          
     5086                        $p->set_var('lang_set_participants', lang('set the participants')); 
    57675087                        $vars = Array( 
    57685088                                'font'                  => $this->theme['font'], 
     
    57715091                                'accounts_link'         => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.accounts_popup'), 
    57725092                                'common_hidden' => '<input type="hidden" name="cal[id]" value="'.$event['id'].'">'."\n" 
     5093                                        . '<input type="hidden" name="cal[date]" value="'.$param['date'].'">'."\n" 
    57735094                                        . '<input type="hidden" name="cal[owner]" value="'.$event['owner'].'">'."\n" 
    57745095                                        . '<input type="hidden" name="cal[uid]" value="'.$event['uid'].'">'."\n" 
     
    57865107                                'tr_color' => $this->theme['th_bg'], 
    57875108                                'field' => lang('Title'), 
    5788                                 'data'  => '<input name="cal[title]" size="103" maxlength="300" value="'.$event['title'].'">' 
     5109                                'data'  => '<input name="cal[title]" size="45" maxlength="80" value="'.$event['title'].'">' 
    57895110                        ); 
    57905111 
     
    57925113                        $var['description'] = Array( 
    57935114                                'field' => lang('Full Description'), 
    5794                                 'data'  => '<textarea name="cal[description]" rows="5" cols="88" wrap="virtual" maxlength="2048">'.$event['description'].'</textarea>' 
     5115                                'data'  => '<textarea name="cal[description]" rows="5" cols="40" wrap="virtual" maxlength="2048">'.$event['description'].'</textarea>' 
    57955116                        ); 
    57965117 
     
    58475168                        $var['starttime'] = Array( 
    58485169                                'field' => lang('Start Time'), 
    5849                                 'data'  => '<input name="start[hour]" id="start_hour" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($start,$hourformat).'" maxlength="2">:<input name="start[min]" id="start_minute" size="2" value="'.$GLOBALS['phpgw']->common->show_date($start,'i').'" maxlength="2">'."\n".$str 
     5170                                'data'  => '<input name="start[hour]" id="start_hour" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($start,$hourformat).'" maxlength="2">:<input name="start[min]" id="start_minute" size="2" value="'.$GLOBALS['phpgw']->common->show_date($start,'i').'" maxlength="2">&nbsp;<select name="sStartHour" onchange="javascript:sChangeHour(this);">'.$sHValue.'</select>'."\n".$str      
    58505171                        ); 
    58515172 
     
    58725193                        $var['endtime'] = Array( 
    58735194                                'field' => lang('End Time'), 
    5874                                 'data'  => '<input name="end[hour]" id="end_hour" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($end,$hourformat).'" maxlength="2">:<input name="end[min]" id="end_minute" size="2" value="'.$GLOBALS['phpgw']->common->show_date($end,'i').'" maxlength="2">'."\n".$str 
     5195                                'data'  => '<input name="end[hour]" id="end_hour" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($end,$hourformat).'" maxlength="2">:<input name="end[min]" id="end_minute" size="2" value="'.$GLOBALS['phpgw']->common->show_date($end,'i').'" maxlength="2">&nbsp;<select name="sEndHour" onchange="javascript:sChangeHour(this);">'.$sHValue.'</select>'."\n".$str 
    58755196                        ); 
    58765197 
     
    58845205                        $var['access'] = Array( 
    58855206                        'field' => lang('Type'), 
    5886                         'data'  => '<select onchange="javascript:changeViewMode(this.value);" id="cal[type]" name="cal[type]" '.'><option value="normal" '.(($event['public'] && $event['type'] == 'E')?'SELECTED':'').' >'.lang('Normal').'</option><option value="private" '.((!$event['public'] && $event['type'] == 'E')?'SELECTED':'').' >'. lang('Restrict').'</option><option value="privateHiddenFields" '.($event['type']=='P'?'SELECTED':'').' >'. lang('Private').'</option><option value="hourAppointment" '.($event['type'] == 'H'?'SELECTED':'').' >'.lang('Hours Appointment').'</option></select>' 
     5207                        'data'  => '<select onchange="javascript:changeViewMode(this.value);" id="cal[type]" name="cal[type]" '.($event['type'] == 'H'?'DISABLED':'').'><option value="normal" '.(($event['public'] && $event['type'] == 'E')?'SELECTED':'').' >'.lang('Normal').'</option><option value="private" '.((!$event['public'] && $event['type'] == 'E')?'SELECTED':'').' >'. lang('Restrict').'</option><option value="privateHiddenFields" '.($event['type']=='P'?'SELECTED':'').' >'. lang('Private').'</option><option value="hourAppointment" '.($event['type'] == 'H'?'SELECTED':'').' >'.lang('Hours Appointment').'</option></select>' 
    58875208                        ); //event['public'] 
    58885209 
     
    58985219                                                        { 
    58995220                                                                $str .= '<option value="' . $id.$event['participants'][$id] . '"'.($event['participants'][$id]?' selected':'').'>('.$GLOBALS['phpgw']->accounts->get_type($id) 
    5900                                                                                 .') ' . $GLOBALS['phpgw']->common->grab_owner_name($id) . '</option>' . "\n"; 
     5221                                                                                .') ' . $GLOBALS['phpgw']->common->grab_owner_name($id) . ' ('. $id.')</option>' . "\n"; 
    59015222                                                        } 
    59025223                                                } 
     
    59595280                                                                                </tr> 
    59605281                                                                                </table> 
    5961                                                                                 <script src='calendar/js/edit.js' type='text/javascript'></script> 
    59625282                                                                        " 
    59635283                                                ); 
     
    59925312 
    59935313                                                                if ($GLOBALS['phpgw_info']['server']['cal_type_tree_participants'] == '3'){ 
     5314                                                                        $context = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$context); 
     5315                                                                        $context = utf8_decode($context); 
    59945316                                                                        $combo_org = '<option value='.$context.'>'.strtoupper($context).'</option>'; 
    59955317                                                                }else{ 
    59965318                                                                        $combo_org = $this->get_organizations(trim(strtolower($context)),$user_context, $recursive); 
     5319                                                                        $combo_org = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$combo_org); 
     5320                                                                        $combo_org = utf8_decode($combo_org); 
    59975321                                                                } 
    59985322 
     
    60075331                                                                } 
    60085332 
    6009                                                                 $edit_js_path = 'calendar/templates/'.$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set']; 
    6010                                                                 if (!file_exists($GLOBALS['phpgw_info']['server']['webserver_url'].$edit_js_path.'/js/edit.js')) 
    6011                                                                         $edit_js_path = 'calendar'; 
    6012  
    60135333                                                                $var['participants'] = array 
    60145334                                                                ( 
    60155335                                                                        'field' => ' 
    6016                                                                         <script src="'.$edit_js_path.'/js/edit.js" type="text/javascript"></script><div id=\'disponibility\' style=\'display:none;position:absolute\' bgcolor=\'#FFFFFF\'> 
     5336                                                                        <script src="calendar/templates/'.$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set'].'/js/edit.js" type="text/javascript"></script><div id=\'disponibility\' style=\'display:none;position:absolute\' bgcolor=\'#FFFFFF\'> 
    60175337        <iframe src=\'#\' id=\'frame_disponibility\' width=\'500\' marginHeight=\'0\' marginWidth=\'0\' height=\'200px\'></iframe> 
    6018 </div> 
     5338                                                                        </div> 
    60195339                                                                        '.lang('Participants'), 
    6020                                                                         'data'  => ' 
    6021                                                                                         <input type="hidden" id="txt_loading" value="'.lang("Loading").'">' . 
     5340                                                                        'data'  =>  
     5341                                                                                '<input type="hidden" id="txt_loading" value="'.lang("Loading").'">' .  
    60225342                                                                                        '<input type="hidden" id="txt_searching" value="'.lang("Searching").'">' . 
    60235343                                                                                        '<input type="hidden" id="txt_users" value="'.lang("Users").'">' .                                                       
    60245344                                                                                        '<input type="hidden" id="txt_groups" value="'.lang("Groups").'">' . 
     5345                                                                                        '<input type="hidden" id="txt_shared_accounts" value="'.lang("shared accounts").'">' . 
     5346                                                                                        '<input type="hidden" id="txt_min_search" value="'.lang("Your search argument must be longer than 4 characters.").'">' . 
     5347                                                                                        '<input type="hidden" id="txt_none_result" value="'.lang("None result was found.").'">' . 
     5348                                                                                        '<input type="hidden" id="txt_Select_a_name" value="'.lang("Select a name").'">' . 
     5349                                                                                        '<input type="hidden" id="txt_Close" value="'.lang("Close").'">' . 
     5350                                                                                        '<input type="hidden" id="txt_More_than_%1_results._Please,_try_to_refine_your_search" value="'.lang("More than %1 results. Please, try to refine your search",'%1').'">' . 
     5351                                                                                        '<input type="hidden" id="txt_The_results_were_found_in_the_Global_Catalog" value="'.lang("The results were found in the Global Catalog").'">' .  
    60255352                                                                                        '<table width="100%" border="0">'. 
    60265353                                                                                        '<tr>'. 
    6027                                                                                         '<td width="25%"><br><br>'. 
     5354                                                                                        '<td width="25%"><br>'.  
     5355                                                                                        '<button type="button" onClick="javascript:add_user();"><img src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/add.png" style="vertical-align: middle;" >&nbsp;'.lang("Add").'</button>'. 
     5356                                                                                        '&nbsp;&nbsp;<button type="button" onClick="javascript:remove_user();"><img src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/rem.png" style="vertical-align: middle;" >&nbsp;'.lang("Remove").'</button>'. 
    60285357                                                                                        '<br><br>&nbsp;&nbsp;<b>'.lang("Event's participants").'</b><br>'. 
    60295358                                                                                        '       <select id="user_list" name="participants[]" style="width: 300px" multiple size="13">'.$str.'</select>'. 
     
    60335362                                                                                        '<td valign="bottom">'. 
    60345363                                                                                        '       '.lang("Organization").': '. 
    6035                                                                                         '       <select name="org_context" id="combo_org" onchange="javascript:get_available_users(\''.$module_name.'\',this.value,\''.($recursive ? "" : "search").'\',\''.$GLOBALS['phpgw_info']['server']['auto_search'].'\');">'.$combo_org.'</select>'. 
     5364                                                                                        '       <select name="org_context" id="combo_org">'.$combo_org.'</select>'. 
    60365365                                                                                        '       <br>'. 
    60375366                                                                                        '       <font color="red"><span id="cal_span_searching">&nbsp;</span></font>'.                                                                   
    60385367                                                                                        '       <br>'.lang("Search for").':'. 
    6039                                                                                         '       <input value="" id="cal_input_searchUser" size="35" autocomplete="off" onkeyup="javascript:optionFinderTimeout(this,'.$GLOBALS['phpgw_info']['server']['min_num_characters'].',\''.($recursive ? "" : "search").'\',\''.$GLOBALS['phpgw_info']['server']['auto_search'].'\')"><br>'. 
     5368                                                                                        '       <input value="" id="cal_input_searchUser" size="35" autocomplete="off" onkeypress="return optionFinderTimeout(this,'.$GLOBALS['phpgw_info']['server']['min_num_characters'].',\''.($recursive ? "" : "search").'\',\''.$GLOBALS['phpgw_info']['server']['auto_search'].'\', event);"><br>'. 
    60405369                                                                                        '       <b>'.lang("Available users and groups").'</b><br>'. 
    60415370                                                                                        '       <select id="user_list_in" style="width: 300px" multiple size="13"></select>'. 
    60425371                                                                                        '</td>'. 
    60435372                                                                                        '</tr>'. 
    6044                                             '<tr>'. 
    6045                                             '<td width="25%">'. 
    6046                                             '<button type="button" id="time_map" onClick="javascript:show_disponibility();">'.lang("Disponibility map").'</button>'. 
    6047                                             '</td>'. 
    6048                                             '<td width="30px" valign="middle" align="center">&nbsp;'. 
    6049                                                                                         '</td>'. 
    6050                                             '<td valign="bottom">'. 
    6051                                             '<button type="button" onClick="javascript:add_user();"><img src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/add.png" style="vertical-align: middle;" >&nbsp;'.lang("Add").'</button>'. 
    6052                                                                                         '&nbsp;&nbsp;<button type="button" onClick="javascript:remove_user();"><img src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/rem.png" style="vertical-align: middle;" >&nbsp;'.lang("Remove").'</button>'. 
    6053                                             '</td>'. 
    6054                                                                                         '</tr>'. 
     5373                                                                                        '<tr>' . 
     5374                                                                                        '<td>' . 
     5375                                                                                        '<button onclick="javascript:show_disponibility();" id="time_map" type="button">Mapa de disponibilidade</button><br>' . 
     5376                                                                                        '<b>'.lang("Can have users and groups that doesn't appears on the map").'</b><br>' . 
     5377                                                                                        '<td>' . 
     5378                                                                                        '</tr>' . 
    60555379                                                                                        '</table>'.  
    60565380                                                                                        '<script type="text/javascript" src="phpgwapi/js/wz_dragdrop/wz_dragdrop.js"></script>'. 
    60575381                                                                                        '<script type="text/javascript" src="phpgwapi/js/dJSWin/dJSWin.js"></script>'.           
    6058                                                                                         "<script src='calendar/js/edit_exmail.js' type='text/javascript'></script>" . 
     5382                                                                                        "<script src='calendar/templates/".$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set']."/js/finder.js' type='text/javascript'></script>" . 
     5383                                                                                        "<script src='calendar/templates/".$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set']."/js/edit_exmail.js' type='text/javascript'></script>" . 
    60595384                                                                                        $load_lang_vars.                                                                                                                                                         
    60605385                                                                                        "<script src='".$module_name."/js/connector.js' type='text/javascript'></script>". 
     
    60675392                                                }                                                
    60685393                                                 
    6069                                                 $var['participants']['data'] .= '<br /><a id="a_ext_participants" title="'.lang("It types below the email addresses, if you want to invite other people out" . 
     5394                                                $var['participants']['data'] .= '<a id="a_ext_participants" title="'.lang("It types below the email addresses, if you want to invite other people out" . 
    60705395                                                        " of this system").'" name="a_ext_participants" onClick="javascript:showExParticipants(this,\''.$module_name.'\')" href="#a_ext_participants"><b>'.lang("Inform").' '.lang("external participants").'</b>&nbsp;<img align="top" ' . 
    60715396                                                        'src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/sent.gif"></a><table id="tbl_ext_participants" width="100%" border="0" style="display:none">'. 
     
    60795404                                                        '<td>'.  
    60805405                                                        '&nbsp;&nbsp;>> '.lang("It types below the email addresses, if you want to invite other people out of this system").':'. 
    6081                                                         '&nbsp;&nbsp;<br><textarea name="ex_participants" id="ex_participants" cols="70" rows="2">'.$event['ex_participants'].'</textarea><br>&nbsp;&nbsp;'. 
    6082                                                         //$footer_ext_participantes. 
     5406                                                        '&nbsp;&nbsp;<br> <input type="hidden" name="h_exParticipants" id="h_exParticipants" value="'.$exParticipants->getParticipantsSerializable().'" /> 
     5407                                                        <textarea name="ex_participants" id="ex_participants" cols="70" rows="2">'.$event['ex_participants'].'</textarea><br>&nbsp;&nbsp;'. 
     5408                                                        $footer_ext_participantes. 
    60835409                                                        '</tr>'.                                                         
    60845410                                                        '</table>'; 
     
    61005426                        } 
    61015427 
    6102                         // Reminder 
     5428// Reminder 
    61035429                        // The user must use "Alarm Management" to change/modify an alarm 
    61045430                        // so only display the email reminder fields if this is a new event 
     
    61825508                                'data'  => '<select name="cal[recur_type]">'."\n".$str.'</select>'."\n" 
    61835509                        ); 
    6184  
    6185  
    6186                         $preferences = CreateObject('phpgwapi.preferences',(int)$this->owner); 
    6187                        $selected_creator = $selected_owner = ''; 
    6188                        if($event['notifications_owner'] == 1) 
    6189                            $selected_owner = ' selected'; 
    6190                        else 
    6191                            $selected_creator = ' selected'; 
    6192                        
    6193                        $option = '<option value="0" '.$selected_creator.' >'.$GLOBALS['phpgw']->common->grab_owner_name((int)$_SESSION['phpgw_session']['account_id']).'</option>'; 
    6194                        if($_SESSION['phpgw_session']['account_id'] != $event['owner']){ 
    6195                            $option .= '<option value="1" '.$selected_owner.' >'.$GLOBALS['phpgw']->common->grab_owner_name((int)$event['owner']).'</option>'; 
    6196                        } 
    6197  
    6198  
    6199                        $var['notifications_owner'] = Array( 
    6200                                 'field' => lang('Send notificatios as'), 
    6201                                 'data'  => '<select name="cal[notifications_owner]" >'.$option.'</select>' 
    6202                         ); 
    6203  
    62045510 
    62055511                        if($event['recur_enddate']['year'] != 0 && $event['recur_enddate']['month'] != 0 && $event['recur_enddate']['mday'] != 0) 
     
    62435549                        ); 
    62445550//                      $this->output_template_array($p,'row','list',Array('data' => '<script src="simple_show_hide.js" type="text/javascript"></script>')); 
    6245  
    6246 // Observations 
    6247                         $var['observations'] = Array( 
    6248                                 'field' => lang('Observations'), 
    6249                                 'data'  => '<textarea name="cal[observations]" rows="5" cols="88" wrap="virtual" maxlength="2048">'.$event['observations'].'</textarea>' 
    6250                         ); 
    6251  
    6252                         if ($event['attachment'] == '' || $event['attachment'] == 'ERROR' || is_array($event['attachment'])) 
    6253                             $data =  '<a onClick="javascript:addAttach()" href="#divFiles" >Anexos: adicionar+</a><div id="divFiles"></div>'; 
    6254                         else 
    6255                             $data = '<input type="hidden" name="cal[attachment]" value='.$event["attachment"].'>'.lang('Notification with attachments sent.').'<br><a onClick="javascript:addAttach()" href="#divFiles" >Anexos: adicionar+</a><div id="divFiles"</div>'; 
    6256  
    6257                         $var['attachment'] = Array( 
    6258                                 'field' => lang('Attachment'), 
    6259                                 //'data' => '<input  type="file" name="cal[attachment]" />' 
    6260                                 'data' => $data 
    6261                         ); 
    62625551 
    62635552                        if (!isset($this->fields)) 
  • trunk/calendar/inc/class.uigroup_access.inc.php

    r1684 r5132  
    7171                                $scripts =      "<script src='".$module_name."/js/connector.js' type='text/javascript'></script>". 
    7272                                                        "<script type='text/javascript'>var DEFAULT_URL = '".$module_name."/controller.php?action=';</script> ".                                                                                         
    73                                                         "<script src='calendar/js/search.js' type='text/javascript'></script>";                          
     73                                                        "<script src='".$this->template_dir."/js/finder.js' type='text/javascript'></script>". 
     74                                                        "<script src='".$this->template_dir."/js/search.js' type='text/javascript'></script>";                           
    7475                                // Fim                           
    7576                                 
  • trunk/calendar/inc/class.uiicalendar.inc.php

    r3736 r5132  
    1717        { 
    1818                var $bo; 
     19//              var $ui; 
    1920                var $template; 
    2021 
     
    3031                { 
    3132                        $this->bo = CreateObject('calendar.boicalendar'); 
     33//                      $this->ui = CreateObject('calendar.uicalendar'); 
     34 
    3235                        $this->template = $GLOBALS['phpgw']->template; 
    3336                        $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Calendar - [iv]Cal Importer'); 
     
    7780                } 
    7881 
    79                 function import_from_mail($calendar) { 
    80                         return $this->bo->import(explode("\n",$calendar),true); 
     82                function import_from_mail($calendar, $from_ajax, $importAccount = false) { 
     83                        return $this->bo->import(explode("\n",$calendar),$from_ajax,$importAccount); 
    8184                } 
    8285                 
    83                 function get_error_message($error_number) { 
    84                         switch ($error_number) { 
    85                                 case 1: 
    86                                         return lang('event already exists'); 
    87                         } 
    88                 } 
    8986 
    9087                function import() 
     
    108105                        } 
    109106 
    110                         $this->template->set_file(array('vcalimport' => 'vcal_import.tpl')); 
    111                         $this->template->set_block('vcalimport','page_block'); 
    112                         $this->template->set_block('vcalimport','error_block'); 
    113                          
    114                         if($GLOBALS['HTTP_GET_VARS']['error_number']) { 
    115                                 $this->template->set_var('error_message',$this->get_error_message( $GLOBALS['HTTP_GET_VARS']['error_number'] ) ); 
    116                                 $this->template->parse('error_box','error_block',true); 
    117                         } 
     107                        $this->template->set_file( 
     108                                Array( 
     109                                        'vcalimport' => 'vcal_import.tpl' 
     110                                ) 
     111                        ); 
    118112                         
    119113                        $var = Array( 
    120114                                'vcal_header'   => '<p>', 
    121115                                'ical_lang'             => lang('(i/v)Cal'), 
    122                                 'action_url'    => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.boicalendar.import'), 
     116                                'action_url'    => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.boicalendar.import&calendarImport=1'), 
    123117                                'lang_access'   => lang('Access'), 
    124118                                'lang_groups'   => lang('Which groups'), 
     
    128122                        ); 
    129123                        $this->template->set_var($var); 
    130                         $this->template->pfp('out', 'page_block'); 
    131                         // $this->template->pparse('out','page_block'); 
     124                        $this->template->pparse('out','vcalimport'); 
    132125                } 
    133126        } 
  • trunk/calendar/inc/class.uipublicview.inc.php

    r3966 r5132  
    466466                                        ); 
    467467                                } 
    468                                 if($event['attachment'] != '') 
    469                                 { 
    470                                         $picture[] = Array( 
    471                                                 'pict'  => $GLOBALS['phpgw']->common->image('calendar','circle'), 
    472                                                 'width' => 9, 
    473                                                 'height'=> 9, 
    474                                                 'title' => lang('Has Attachment') 
    475                                         ); 
    476                                 } 
    477468                                else 
    478469                                { 
     
    529520                        } 
    530521 
    531                         if($event['attachment'] != '') 
    532                         { 
    533                             $picture[] = Array( 
    534                                     'pict'      => $GLOBALS['phpgw']->common->image('calendar','circle'), 
    535                                     'width'     => 9, 
    536                                     'height'=> 9, 
    537                                     'title' => lang('Has Attachment') 
    538                             ); 
    539                         } 
    540522                        $description = $this->bo->get_short_field($event,$is_private,'description'); 
    541523                        for($i=0;$i<count($picture);$i++) 
  • trunk/calendar/inc/hook_home_day.inc.php

    r4322 r5132  
    3232                ).'</td><td align="center"><table border="0" width="100%" cellspacing="0" cellpadding="0">' 
    3333                . '<tr><td align="center">'.ExecMethod('calendar.bocalendar.long_date',time()) 
    34                 .'</td></tr><tr><td valign="top">'.ExecMethod('calendar.uicalendar.print_day_new', 
     34                .'</td></tr><tr><td bgcolor="'.$GLOBALS['phpgw_info']['theme']['bg_text'] 
     35                .'" valign="top">'.ExecMethod('calendar.uicalendar.print_day', 
    3536                        Array( 
    3637                                'year'  => $GLOBALS['g_year'], 
  • trunk/calendar/inc/hook_settings.inc.php

    r4565 r5132  
    125125                'This defines the end of your dayview. Events after this time, are shown below the dayview.'); 
    126126        $intervals = array( 
    127                 84      => '15 ' . lang('minutes'), 
    128                 42      => '30 ' . lang('minutes') 
     127                5       => '5', 
     128                10      => '10', 
     129                15      => '15', 
     130                20      => '20', 
     131                30      => '30', 
     132                45      => '45', 
     133                60      => '60' 
    129134        ); 
    130135        create_select_box('Intervals in day view','interval',$intervals, 
     
    189194        create_check_box('Leave my calendar public','public_view', 
    190195                'This option allow everybody to view your calendar in readmode.'); 
    191         create_select_box('Default view of your calendar','title_view',array( 
    192                         '0' => lang('Title and Description'), 
    193                         '1' => lang('Only Title') 
    194                 ),'This option enable or disable the meeting description view your calendar in readmode.'); 
    195         create_select_box('Choose fields to print','fields_to_print',array( 
    196                         '0' => lang('Only Title'), 
    197                         '1' => lang('Title and Description'), 
    198                         '2' => lang('Title, description and observations') 
    199                 ),'This option enables the choice of fields to print.'); 
    200          
  • trunk/calendar/inc/hook_sidebox_menu.inc.php

    r4474 r5132  
    2424 
    2525        $menu_title = $GLOBALS['phpgw_info']['apps'][$appname]['title'] . ' '. lang('Menu'); 
    26          
    27         $publicview_php_template_path = $GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'];  
    28         if (!file_exists($GLOBALS['phpgw_info']['server']['webserver_url'].'/calendar/templates/'.$publicview_php_template_path.'/publicView.php'))  
    29             $publicview_php_template_path = 'default'; 
    30          
    3126        $file = Array( 
    3227                'New Entry'   => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.add'), 
     
    4136                'Import'=>$GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uiicalendar.import'), 
    4237                'Report of hours'=>$GLOBALS['phpgw']->link('/calendar/inc/hourReport.php',''), 
    43                 'Public Calendars'=> "javascript:openwindow('calendar/templates/".$publicview_php_template_path."/publicView.php')" 
     38                'Public Calendars'=> "javascript:openwindow('calendar/templates/".$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set']."/publicView.php')" 
    4439        ); 
    4540        display_sidebox($appname,$menu_title,$file); 
  • trunk/calendar/inc/hourReport.php

    r4931 r5132  
    9595        $_SESSION['calendar']['server']['db_type'] 
    9696); 
    97 if (IsSet($_POST['CAT']) && IsSet($_POST['CAL'])){ 
     97if (IsSet($_POST['CAT'])){ 
    9898        if (!preg_match("/[a-zA-Z0-9]+/i",$_POST['CAT'][0])){ 
    9999                echo "Invalid entry:".$_POST['CAT'][0]; 
     
    125125                $query = "select cal_id,title,description,datetime,edatetime from phpgw_cal where ".(!$_POST['NORM']?"cal_type = 'H' and":" is_public = 1 and ")." owner = ".$user_id." and (category like '%,".$catid.",%' or category like '%,".$catid."' or category like '".$catid.",%' or category = '".$catid."')".(IsSet($initDate)?" and datetime > ".$initDate:""); 
    126126                if(!$db->query($query)){ 
    127                         print("<br>Query failed.<br>"); 
     127                        print("<br>Query failed at host:<br>".$_SESSION['calendar']['server']['db_user']."@".$_SESSION['calendar']['server']['db_host'].":".$_SESSION['calendar']['server']['db_port']."<br>"); 
    128128                        return; 
    129129                } 
  • trunk/calendar/setup/default_records.inc.php

    r3557 r5132  
    1010        \**************************************************************************/ 
    1111 
    12     // Alterando dois campos da tabela phpgw_cal e phpgw_cal_holidays 
    13         $oProc->query("ALTER TABLE phpgw_cal ALTER COLUMN cal_id set default nextval(('seq_phpgw_cal'::text)::regclass);"); 
    14         $oProc->query("ALTER TABLE phpgw_cal_holidays ALTER COLUMN hol_id set default nextval(('seq_phpgw_cal_holidays'::text)::regclass);"); 
    1512         
    16         $oProc->query("SELECT pg_catalog.setval('seq_phpgw_cal', 1, false);"); 
    17         $oProc->query("SELECT pg_catalog.setval('seq_phpgw_cal_holidays', 1, false);"); 
    18  
    19         // Adicionando dois campos a tabela phpgw_cal 
    20         $oProc->query("ALTER TABLE phpgw_cal ADD COLUMN last_status char(1) DEFAULT 'N'::bpchar;"); 
    21         $oProc->query("ALTER TABLE phpgw_cal ADD COLUMN last_update bigint DEFAULT (date_part('epoch'::text, ('now'::text)::timestamp(3) with time zone) * (1000)::double precision);"); 
     13        // enable auto-loading of holidays from localhost by default 
     14        $oProc->query("INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES ('phpgwapi','auto_load_holidays','True')"); 
     15        $oProc->query("INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES ('phpgwapi','holidays_url_path','localhost')"); 
  • trunk/calendar/setup/phpgw_alarm_es-es.lang

    r3531 r5132  
    22Description     calendar        es-es   descripción 
    33External Participants   calendar        es-es   Participantes Externos 
    4 Category        calendar        es-es   Categoría 
     4Category        calendar        es-es   Categoria 
    55Location        calendar        es-es   Lugar 
    66Start Date/Time calendar        es-es   Fecha/Hora Inicio 
    77End Date/Time   calendar        es-es   La fecha/hora de finalización 
    8 Low     calendar        es-es   Baja 
     8Low     calendar        es-es   Baixa 
    99Normal  calendar        es-es   Normal 
    1010High    calendar        es-es   Alta 
     
    1212Created By      calendar        es-es   Creado por 
    1313Updated calendar        es-es   Actualizado 
    14 Access  calendar        es-es   Acceso 
     14Access  calendar        es-es   Acesso 
    1515Groups  calendar        es-es   Grupos 
    1616Participants    calendar        es-es   Participantes 
    17 Alarm for %1 at %2 in %3        calendar        es-es   Alarma para %1 a %2 en el %3 
    18 Here is your requested alarm.   calendar        es-es   Aquí está la alarma solicitada. 
    19 You have a meeting scheduled for %1     calendar        es-es   Usted posee un compromiso agendado para %1. 
    20 Your meeting scheduled for %1 has been canceled calendar        es-es   Su compromiso agendado para %1 fue cancelado. 
    21 Your meeting that had been scheduled for %1 has been rescheduled to %2  calendar        es-es   Su compromiso que habia sido agendado para %1 fue reagendado para %2 
     17here is your requested alarm.   calendar        es-es   Aquí está la alarma solicitada. 
     18Alarm for %1 at %2 in %3        calendar        es-es   Alarma para %1 en %2 in %3 
  • trunk/calendar/setup/setup.inc.php

    r4186 r5132  
    1212 
    1313        $setup_info['calendar']['name']    = 'calendar'; 
    14         $setup_info['calendar']['title']    = 'Calendar'; 
    15         $setup_info['calendar']['version'] = '2.2.1'; 
     14        $setup_info['calendar']['version'] = '2.0.008'; 
    1615        $setup_info['calendar']['app_order'] = 3; 
    1716        $setup_info['calendar']['enable']  = 1; 
     
    5352        $setup_info['calendar']['depends'][] = array( 
    5453                 'appname' => 'phpgwapi', 
    55                  'versions' => Array('2.2') 
     54                 'versions' => Array('2.4.0') 
    5655        ); 
  • trunk/calendar/setup/tables_current.inc.php

    r4316 r5132  
    2525                                'cal_type' => array('type' => 'varchar','precision' => '10','nullable' => True), 
    2626                                'is_public' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '1'), 
    27                                 'title' => array('type' => 'varchar','precision' => '300','nullable' => False,'default' => '1'), 
     27                                'title' => array('type' => 'varchar','precision' => '80','nullable' => False,'default' => '1'), 
    2828                                'description' => array('type' => 'text','nullable' => True), 
    29                                 'notifications_owner' => array('type' => 'int','precision' => '1','nullable' => False,'default' => '0'), 
    30                                 'observations' => array('type' => 'text','nullable' => True), 
    31                                 'attachment' => array('type' => 'text','nullable' => True), 
    3229                                'location' => array('type' => 'varchar','precision' => '255','nullable' => True), 
    3330                                'reference' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), 
    34                                 'alter_by' => array('type'=> 'varchar','precision' => '160','nullable' => True), 
    3531                                'ex_participants' => array('type' => 'text','nullable' => True), 
    3632                        ), 
     
    6460                                'recur_interval' => array('type' => 'int','precision' => '8','nullable' => True,'default' => '1'), 
    6561                                'recur_data' => array('type' => 'int','precision' => '8','nullable' => True,'default' => '1'), 
    66                                 'recur_exception' => array('type' => 'varchar','nullable' => True,'default' => '') 
     62                                'recur_exception' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => '') 
    6763                        ), 
    6864                        'pk' => array(), 
  • trunk/calendar/setup/tables_update.inc.php

    r4318 r5132  
    1919                $GLOBALS['phpgw_setup']->db->query("ALTER TABLE ".$table." ADD COLUMN ".$column." ".$attrs); 
    2020        }   
    21 /// Since Expresso 1.2 using Calendar 0.9.3  
     21        $test[] = '0.9.2'; 
     22        function calendar_upgrade0_9_2() 
     23        { 
     24                $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.17'; 
     25                return $GLOBALS['setup_info']['calendar']['currentver']; 
     26        } 
     27        $test[] = '0.9.17'; 
     28        function calendar_upgrade0_9_17() 
     29        { 
     30                $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.21'; 
     31                return $GLOBALS['setup_info']['calendar']['currentver']; 
     32        } 
     33        $test[] = '0.9.20'; 
     34        function calendar_upgrade0_9_20() 
     35        { 
     36                $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.21'; 
     37                return $GLOBALS['setup_info']['calendar']['currentver']; 
     38        }        
     39        $test[] = '0.9.21'; 
     40        function calendar_upgrade0_9_21() 
     41        { 
     42                addSpecialColumn("phpgw_cal","last_status","char(1) DEFAULT 'N'::bpchar"); 
     43                addSpecialColumn("phpgw_cal","last_update","int8 DEFAULT (date_part('epoch'::text, ('now'::text)::timestamp(3) with time zone) * (1000)::double precision)"); 
     44                $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.22'; 
     45                return $GLOBALS['setup_info']['calendar']['currentver']; 
     46        }        
     47        $test[] = '0.9.22'; 
     48        function calendar_upgrade0_9_22() 
     49        { 
     50                $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.23'; 
     51                return $GLOBALS['setup_info']['calendar']['currentver']; 
     52        } 
     53        $test[] = '0.9.23'; 
     54        function calendar_upgrade0_9_23() 
     55        { 
     56                $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.3'; 
     57                return $GLOBALS['setup_info']['calendar']['currentver']; 
     58        }        
    2259        $test[] = '0.9.3'; 
    2360        function calendar_upgrade0_9_3() 
     
    63100        }        
    64101        $test[] = '2.0.006'; 
    65         function calendar_upgrade2_0_006() 
    66         { 
     102        function calendar_upgrade2_0_006() { 
    67103                $GLOBALS['setup_info']['calendar']['currentver'] = '2.0.007'; 
     104                $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cal ALTER COLUMN title TYPE character varying(1024);"); 
    68105                return $GLOBALS['setup_info']['calendar']['currentver']; 
    69106        }                
    70107        $test[] = '2.0.007'; 
    71         function calendar_upgrade2_0_007() 
    72         { 
    73                 $GLOBALS['setup_info']['calendar']['currentver'] = '2.1.000'; 
    74                 return $GLOBALS['setup_info']['calendar']['currentver']; 
    75         } 
    76         $test[] = '2.1.000'; 
    77         function calendar_upgrade2_1_000() 
    78         { 
    79                 $GLOBALS['setup_info']['calendar']['currentver'] = '2.2.000'; 
    80                 return $GLOBALS['setup_info']['calendar']['currentver']; 
    81         } 
    82         $test[] = '2.2.000'; 
    83         function calendar_upgrade2_2_000() 
    84         { 
    85                 $GLOBALS['setup_info']['calendar']['currentver'] = '2.2.003';  
    86             return $GLOBALS['setup_info']['calendar']['currentver'];  
    87         }  
    88         $test[] = '2.2.003';  
    89         function calendar_upgrade2_2_003()  
    90         {  
    91             $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cal ADD COLUMN notifications_owner INT NOT NULL default '0'"); 
    92                 $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cal ADD COLUMN observations text"); 
    93             $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cal ADD COLUMN alter_by varchar(160)"); 
    94             $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cal ADD COLUMN attachment text"); 
    95             $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cal ALTER title TYPE varchar(300)"); 
    96             $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cal_repeats ALTER recur_exception TYPE varchar"); 
    97             $GLOBALS['setup_info']['calendar']['currentver'] = '2.2.1'; 
     108        function calendar_upgrade2_0_007() { 
     109                $GLOBALS['setup_info']['calendar']['currentver'] = '2.0.008'; 
     110                $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cal ADD COLUMN organizer character varying(255);");  
    98111            return $GLOBALS['setup_info']['calendar']['currentver']; 
    99112        } 
  • trunk/calendar/templates/classic/body_email.tpl

    r3300 r5132  
    2525<td width='2%' align='left' valign='top'>{varbuttom1}</td> 
    2626<td width='2%' align='left' valign='top'>{varbuttom2}</td> 
    27 <td width='2%' align='left' valign='top'>{varbuttom5}</td> 
    28 <td width='2%' align='left' valign='top'>{varbuttom4}</td> 
    2927<td width='94%' align='left' valign='top'>{varbuttom3}</td> 
    3028</tr> 
  • trunk/calendar/templates/classic/edit.tpl

    r3254 r5132  
    1515                Window1=window.open('{accounts_link}',"Search","width=800,height=600,toolbar=no,scrollbars=yes,resizable=yes"); 
    1616        } 
    17  
    18         function show_disponibility() { 
    19                 participants = ""; 
    20                 combo = document.getElementById('user_list'); 
    21                 if(combo.length==0) { 
    22                         alert('Selecione os participantes'); 
    23                         return; 
    24                 } 
    25  
    26                 for (i=0;i<combo.length;i++) { 
    27                         participants+=combo[i].value+","; 
    28                 } 
    29                 url = 'index.php?menuaction=calendar.uicalendar.disponibility&participants='+participants+'&date='+document.getElementById('start[str]').value; 
    30  
    31                 //alert(url); 
    32                 document.getElementById('frame_disponibility').src = url; 
    33                 document.getElementById('disponibility').style.display=''; 
    34                 //window.open(url); 
    35         } 
    3617</script> 
    3718<center> 
     
    4021<form action="{action_url}" method="post" name="app_form"> 
    4122{common_hidden} 
    42 <table id="editFormTable" border="0" width="90%"   class="prefTable"> 
     23<table id="editFormTable" border="0" width="90%"> 
    4324 <tr> 
    4425  <td colspan="2"> 
  • trunk/calendar/templates/classic/listUsers.php

    r1645 r5132  
    2222        $t->set_file(array('addUser_t' => '../../../calendar/templates/classic/listUsers.tpl')); 
    2323         
    24         $obj_account = CreateObject('phpgwapi.accounts',$owner); 
     24        $obj_account = CreateObject('phpgwapi.accounts',$this->bo->owner); 
    2525 
    2626        $post_select_organization = $_POST['select_organization']; 
  • trunk/calendar/templates/classic/listUsers.tpl

    r1645 r5132  
    4848        </body> 
    4949</html> 
    50 <script src="../../js/edit.js" type="text/javascript"></script> 
     50<script src="js/edit.js" type="text/javascript"></script> 
  • trunk/calendar/templates/default/alarm.tpl

    r3930 r5132  
    1818<!-- BEGIN alarm_headers --> 
    1919        <tr bgcolor="{tr_color}"> 
    20                 <th align="left" width="25%">{lang_time}</th> 
     20                <th align="left" width="30%">{lang_time}</th> 
    2121                <th align="left" width="30%">{lang_text}</th> 
    22                 <th align="left" width="25%">{lang_owner}</th> 
    23                 <th width="10%">{lang_enabled}</th> 
    24                 <th width="10%">{lang_select}</th> 
     22                <th align="left" width="30%">{lang_owner}</th> 
     23                <th width="20%" colspan="2">{lang_select}</th> 
    2524        </tr> 
    2625<!-- END alarm_headers --> 
     
    3736                        {owner} 
    3837                </td> 
    39                 <td align="center"> 
    40                         {enabled} 
    41                 </td> 
    42                 <td align="center"> 
     38                <td align="center" colspan="2"> 
    4339                        {select} 
    4440                </td> 
  • trunk/calendar/templates/default/app.css

    r4184 r5132  
    66        color: #000066; 
    77        background-color: #F7F7F7; 
    8         /*border: 1px solid #CCCCCC;*/ 
    9         margin: 1px; 
     8        border: 1px solid #CCCCCC; 
     9        margin: 5px; 
    1010        padding: 5px; 
    1111        height: 156px; 
    12         width: 600px; 
     12        width: 480px; 
    1313} 
    1414 
     
    5454        font-style: italic;  
    5555        font-size:10px;  
    56 } 
    57  
    58 A.minicaltoday 
    59 { 
    60         padding-left:3px; 
    61         padding-right:3px; 
    62         background: #B3DAFF; 
    63         color: black; 
    64         font-size: 10px;  
    65 } 
    66  
    67 A.minicaltodaysel 
    68 { 
    69         padding-left:3px; 
    70         padding-right:3px; 
    71         background: #42A1FF; 
    72         color: white; 
    73         font-size: 10px; 
    74 } 
    75  
    76 A.minicalnottoday 
    77 { 
    78         padding-left:3px; 
    79         padding-right:3px; 
    80         background: #FFAD5C; 
    81         color: black; 
    82         font-size: 10px; 
    8356} 
    8457 
  • trunk/calendar/templates/default/app_print.css

    r4030 r5132  
    33 
    44.calendar_print_main { 
    5         text-align:left; 
     5        text-align:center; 
    66        font-family: Verdana, Arial, Helvetica, sans-serif; 
    7         font-size: 11px; 
     7        font-size: 8px; 
    88        color: #000066; 
    99        background-color: #F7F7F7; 
    10         margin: 0px; 
    11         padding: 0px; 
    12         width: 98%; 
    13         position:absolute; 
    14         top: 10px; 
    15         bottom: 10px; 
    16         left: 15px; 
    17         right: 10px; 
     10        border: 1px solid #CCCCCC; 
     11        margin: 5px; 
     12        padding: 5px; 
     13        height: 700px; 
     14        width: 600px; 
    1815} 
    1916.button { 
     
    142139} 
    143140 
    144 /*Mini Calendar*/ 
     141//Mini Calendar 
    145142 
    146143.calendar_minical_table 
     
    270267.calendar_month_identifier 
    271268{ 
    272         font-size:14px; 
     269        font-size:18px; 
    273270        font-weight: bold; 
    274271} 
     
    276273.calendar_user_identifier 
    277274{ 
    278         font-size:10px; 
    279         color: #778899; 
     275        font-size:12px; 
     276        color: #009999; 
    280277        font-weight: bold; 
    281278} 
  • trunk/calendar/templates/default/body_email.tpl

    r3350 r5132  
    2121<hr size='1' width='100%'> 
    2222<table border='0' cellpadding='4' cellspacing='4' width='100%'> 
    23 <tr><td colspan='4'><b>{question}</b></td></tr> 
    2423<tr> 
    2524<td width='2%' align='left'>{varbuttom}</td> 
     
    2726<td width='2%' align='left' valign='top'>{varbuttom2}</td> 
    2827<td width='2%' align='left' valign='top'>{varbuttom5}</td> 
    29 <td width='2%' align='left' valign='top'>{varbuttom4}</td> 
    30 <td width='94%' align='left' valign='top'>{varbuttom3}</td> 
     28<td width='2%' align='left' valign='top'>{varbuttom3}</td> 
     29<td width='92%' align='left' valign='top'>{varbuttom4}</td> 
    3130</tr> 
    3231</table> 
  • trunk/calendar/templates/default/day.tpl

    r4119 r5132  
    77                                <tr> 
    88                                        <td class="calendar_dayview_table_header"> 
    9                                         <b>{prev_day_link}</b> :: {day_of_week}, {date}&nbsp;<span class="calendar_user_identifier">:&nbsp;{username}&nbsp;:</span> :: <b>{next_day_link}</b> 
     9                                        {date}&nbsp;<span class="calendar_user_identifier">:&nbsp;{username}&nbsp;:</span> 
    1010                                                <br /> 
    1111                                </td> 
  • trunk/calendar/templates/default/day_cal.tpl

    r4707 r5132  
    11<!-- BEGIN day --> 
    2  
    3  
    4 <script src="calendar/js/dhtmlx/codebase/dhtmlxscheduler_debug.js" type="text/javascript" charset="utf-8"></script> 
    5 <script src="calendar/js/dhtmlx/codebase/ext/dhtmlxscheduler_pdf.js"></script> 
    6 <script src="calendar/js/dhtmlx/sources/locale_pt.js"></script> 
    7 <script src="calendar/js/dhtmlx/sources/ext/ext_new_week.js"></script> 
    8 <link rel="stylesheet" href="calendar/js/dhtmlx/codebase/dhtmlxscheduler.css" type="text/css" charset="utf-8"> 
    9  
    10 <div class="th" style='width:1000px; height:470px;'> 
    11  
    12     <div  id="scheduler_here" class="dhx_cal_container" style='width:100%; height:100%;'> 
    13         <div class="dhx_cal_navline" style="display: none;"> 
    14             <div class="dhx_cal_prev_button" style="display: none;">&nbsp;</div> 
    15             <div class="dhx_cal_next_button" style="display: none;">&nbsp;</div> 
    16             <div class="dhx_cal_today_button" style="display: none;" ></div> 
    17             <div class="dhx_cal_date" style="display:none;"></div> 
    18             <div class="dhx_cal_tab" name="day_tab" style="right:204px; display: none;"></div> 
    19             <div class="dhx_cal_tab" name="week_tab" style="right:140px; display: none;"></div> 
    20             <div class="dhx_cal_tab" name="month_tab" style="right:76px; display: none;"></div> 
    21  </div> 
    22         <div class="dhx_cal_header" style="visibility: hidden;"> 
    23         </div> 
    24         <div class="dhx_cal_data"> 
    25         </div> 
     2<div class="th"> 
     3 <table class="calendar_dayview_maintable" width="100%" cellpadding="0"> 
     4{row} 
     5</table> 
    266    </div> 
    27 </div> 
    28  
    29 <div style='clear:left;margin-left:50px;margin-right:50px;text-align:center'> 
    30 <br /> 
    31     {iprint} 
    32     <input type="radio" name="group1" id="list" value="list" onclick="printMode(this.value);" checked> Lista 
    33     <input type="radio" name="group1" id="grid" value="grid" onclick="printMode(this.value);" > Grade 
    34  
    35 </div> 
    36  
    37 <body onload="loadScheduler()"></body> 
    38  
    39 <script> 
    40  
    41     function printMode(printType) 
    42     { 
    43         if(printType == "grid") 
    44         { 
    45             //document.getElementById("listPrint").style.visibility = 'hidden'; 
    46             document.getElementById("printFriendly").onclick = function(){ 
    47                                                                             scheduler.toPDF('calendar/js/dhtmlx/server/generate.php'); 
    48                                                                          }; 
    49         } 
    50         else if(printType =="list") 
    51         { 
    52             //document.getElementById("listPrint").style.visibility = ''; 
    53             document.getElementById("printFriendly").onclick = function(){ 
    54                                                                             window.open("index.php?menuaction=calendar.uicalendar.month"+"{param}","","width=600,height=600,toolbar=no,scrollbars=yes,resizable=no"); 
    55                                                                          }; 
    56         } 
    57     } 
    58  
    59     function loadScheduler() 
    60     { 
    61  
    62         //document.getElementById("listPrint").style.visibility = 'hidden'; 
    63         document.getElementById("printFriendly").onclick = function(){ 
    64                                                                         if(document.getElementById("grid").checked == true) 
    65                                                                         { 
    66                                                                             //document.getElementById("listPrint").style.visibility = 'hidden'; 
    67                                                                             scheduler.toPDF('calendar/js/dhtmlx/server/generate.php'); 
    68                                                                         } 
    69                                                                         else 
    70                                                                         { 
    71                                                                             window.open("index.php?menuaction=calendar.uicalendar.month"+"{param}","","width=600,height=600,toolbar=no,scrollbars=yes,resizable=no"); 
    72                                                                         } 
    73                                                                      }; 
    74  
    75         //inicializa o calendário 
    76         scheduler.showLightbox = function(id) 
    77         { 
    78  
    79             var ev = scheduler.getEvent(id); 
    80  
    81             var bgYea = ev.start_date.getFullYear().toString(); 
    82             var bgMon = (ev.start_date.getMonth() + 1).toString(); 
    83  
    84             if (bgMon.length < 2) 
    85             { 
    86                 bgMon = '0' + bgMon; 
    87             } 
    88  
    89             var bgDay = ev.start_date.getDate().toString(); 
    90  
    91             if (bgDay.length < 2) 
    92             { 
    93                 bgDay = '0' + bgDay; 
    94             } 
    95  
    96             var bgHou = ev.start_date.getHours(); 
    97             var bgMin = ev.start_date.getMinutes(); 
    98  
    99             window.location="index.php?menuaction=calendar.uicalendar.add&date=" + bgYea + bgMon + bgDay + "&hour=" + bgHou + "&minute=" + bgMin; 
    100  
    101         } 
    102  
    103         scheduler.templates.event_class=function(start,end,event){ 
    104                   if (event.rejected) 
    105                     return "rejected"; 
    106                   if (event.intersection) 
    107                      return "intersection"; 
    108  
    109         } 
    110  
    111         scheduler.templates.event_header=function(start,end,event){ 
    112  
    113             var imgs = ''; 
    114             if(event.recur && event.recur != false) 
    115             { 
    116                 imgs += '<img width="10px" height="10px" border="0" title="'+event.recurTitle+'" src="calendar/templates/{templateSet}/images/recur.png"/>'; 
    117             } 
    118  
    119             if(event.participants == 1) 
    120             { 
    121                 imgs += " " + '<img width="11px" height="10px" border="0" title="'+event.participants_title+'" src="calendar/templates/{templateSet}/images/multi_3.png"/>'; 
    122             } 
    123             else 
    124             { 
    125                 imgs += " " + '<img width="11px" height="10px" border="0" title="'+event.participants_title+'" src="calendar/templates/{templateSet}/images/single.png"/>'; 
    126             } 
    127  
    128             if(event.attachments == 1) 
    129             { 
    130                 imgs += " " + '<img width="10px" height="10px" border="0" title="'+event.attachmentsTitle+'" src="calendar/templates/{templateSet}/images/clip.png"/>'; 
    131             } 
    132  
    133             if(event.isPublic == 0) 
    134             { 
    135                 imgs += " " + '<img width="11px" height="10px" border="0" title="'+event.isPublicTitle+'" src="calendar/templates/{templateSet}/images/private.png"/>'; 
    136             } 
    137  
    138             if(event.alarm == 1) 
    139             { 
    140                 imgs += " " + '<img width="11px" height="10px" border="0" title="'+event.alarmTitle+'" src="calendar/templates/{templateSet}/images/alarm.png"/>'; 
    141             } 
    142  
    143             if(event.title) 
    144             { 
    145                 var eventTitle = (" - ") + event.title; 
    146             } 
    147             else 
    148             { 
    149                 var eventTitle = ""; 
    150             } 
    151  
    152             //hide/show event description according to the preference title_view 
    153             if(event.title_view == 0) 
    154             { 
    155                 if(event.descOnTitle == 1) //to show, or not, description beside the title 
    156                 { 
    157                     var eventDescOnTitle = (" - ") + event.text; 
    158                 } 
    159                 else 
    160                 { 
    161                     var eventDescOnTitle = ''; 
    162                 } 
    163             } 
    164             else 
    165             { 
    166                 var eventDescOnTitle = ''; 
    167             } 
    168  
    169             return imgs + " " + scheduler.templates.hour_scale(start) + " " + scheduler.templates.hour_scale(end) + eventTitle + eventDescOnTitle; 
    170         } 
    171  
    172         scheduler.xy.scale_height=0; 
    173         scheduler.xy.nav_height=0; 
    174         scheduler.config.hour_size_px = {hour_size_px} ; 
    175         scheduler.config.scroll_hour = 8; 
    176         scheduler.config.time_step = 30; //- {numeric} minimal date size step in minutes; 
    177         scheduler.config.start_on_monday = true; //{boolean} if true week starts from Monday ( if false, week start from Sunday); 
    178         scheduler.config.first_hour = {hora_inicial}; 
    179         scheduler.config.last_hour = {hora_final}; 
    180         scheduler.config.drag_resize = false;//- {boolean} allows resizing events by dnd; 
    181         scheduler.config.drag_move = false;//- {boolean} allows moving events by dnd; 
    182         scheduler.config.drag_create = false;// - {boolean} allows creating new events by dnd; 
    183         scheduler.config.dblclick_create = true;//- {boolean} allows creating new events by double click; 
    184         scheduler.config.edit_on_create = true;//- {boolean} shows form on new event creation; 
    185         scheduler.config.details_on_create = true;//- {boolean} uses extended form on new event creation by drag or by dbl-click (option doesn't affect monthly view - where details form is the only way to change data); 
    186         scheduler.config.details_on_dblclick = true;// - {boolean} uses extended form on event double-click (double-click on existing event). 
    187         scheduler.attachEvent("onClick",function(){ return false;}); 
    188         scheduler.attachEvent("onDblClick",function(id){ 
    189                                 var ev = scheduler.getEvent(id); 
    190                                 var id_mod = ev.id; 
    191                                 if(ev.recur!=false) id_mod = ev.id.split('rc',1)[0]+"&date="+ev.recur; 
    192                                 window.location="index.php?menuaction=calendar.uicalendar.view&cal_id="+id_mod;}); 
    193  
    194         scheduler.config.xml_date="%Y-%m-%d %H:%i"; 
    195         scheduler.init('scheduler_here',new {date},"day"); 
    196         scheduler.parse({events_json},"json"); 
    197  
    198     } 
    199  
    200     function callViewEvent(id) //double click on events title bar 
    201     { 
    202         var ev = scheduler.getEvent(id); 
    203         var id_mod = ev.id; 
    204         if(ev.recur!=false) id_mod = ev.id.split('rc',1)[0]+"&date="+ev.recur; 
    205         window.location="index.php?menuaction=calendar.uicalendar.view&cal_id="+id_mod; 
    206     } 
    207  
    208 </script> 
    209  
    2107<!-- END day --> 
    211 <!-- BEGIN day_event_off --> 
    212         <!--<font class="event-on">{event}</font>--> 
    213 <!-- END day_event_off --> 
    214 <!-- BEGIN day_time --> 
    215         <!--{time}--> 
    216      <!--<td class="time" nowrap>{open_link}{time}{close_link}</td>--> 
    217 <!-- END day_time --> 
    2188<!-- BEGIN day_row --> 
    219     <!--<font style="font-size: 8pt;">{event}</font>--> 
     9    <tr>{time}{event} 
     10    </tr> 
    22011<!-- END day_row --> 
    22112<!-- BEGIN day_event_on --> 
    222         <!--<font class="event-on">{event}</font>--> 
     13     <td class="event-on"{extras}>&nbsp;{event}</td> 
    22314<!-- END day_event_on --> 
     15<!-- BEGIN day_event_off --> 
     16     <td class="event-off"{extras}>&nbsp;{event}</td> 
     17<!-- END day_event_off --> 
    22418<!-- BEGIN day_event_holiday --> 
    225         <!--{event}--> 
     19     <td class="event-holiday"{extras}>&nbsp;{event}</td> 
    22620<!-- END day_event_holiday --> 
     21<!-- BEGIN day_time --> 
     22     <td class="time" nowrap>{open_link}{time}{close_link}</td> 
     23<!-- END day_time --> 
     24 
  • trunk/calendar/templates/default/edit.tpl

    r4473 r5132  
    1010</style> 
    1111<script language="JavaScript"> 
    12  
    13         function addAttach(){ 
    14             var divFiles = document.getElementById("divFiles"); 
    15             if (! divFiles) 
    16                     return false; 
    17  
    18             if (divFiles.lastChild) 
    19                     var countDivFiles = parseInt(divFiles.lastChild.id.split('_')[1]) + 1; 
    20  
    21             if (! countDivFiles) 
    22                     var countDivFiles = 1; 
    23  
    24             divFile = document.createElement('DIV'); 
    25  
    26  
    27             divFile.innerHTML = "<input type='file' size='50' maxLength='255' id='"+"inputFile_"+countDivFiles+"' name='cal[attachment][]'>"; 
    28  
    29  
    30             var linkFile = document.createElement("A"); 
    31             linkFile.id = "linkFile_"+countDivFiles; 
    32             linkFile.href='javascript:void(0)'; 
    33             linkFile.onclick=function () {removeFile(this.id.replace("link","div")); return false;}; 
    34             linkFile.innerHTML="Remove"; 
    35             //divFile.innerHTML += "&nbsp;&nbsp;"; 
    36             divFile.appendChild(linkFile); 
    37             divFile.id = "divFile_"+countDivFiles; 
    38             divFiles.appendChild(divFile); 
    39  
    40  
    41  
    42             return document.getElementById("inputFile_"+countDivFiles); 
    43         } 
    44  
    45         function removeFile(id){ 
    46             var border_id = id.substr(8,1); 
    47             var el = Element(id); 
    48             el.parentNode.removeChild(el); 
    49         } 
    50  
    5112        self.name="first_Window"; 
    5213        function accounts_popup() 
     
    5415                Window1=window.open('{accounts_link}',"Search","width=800,height=600,toolbar=no,scrollbars=yes,resizable=yes"); 
    5516        } 
    56  
    57         function show_disponibility() { 
    58                 participants = ""; 
    59                 combo = document.getElementById('user_list'); 
    60                 if(combo.length==0) { 
    61                         alert('Selecione os participantes'); 
    62                         return; 
    63                 } 
    64  
    65                 for (i=0;i<combo.length;i++) { 
    66                         participants+=combo[i].value+","; 
    67                 } 
    68                 url = 'index.php?menuaction=calendar.uicalendar.disponibility&participants='+participants+'&date='+document.getElementById('start[str]').value; 
    69  
    70                 //alert(url); 
    71                 document.getElementById('frame_disponibility').src = url; 
    72                 document.getElementById('disponibility').style.display=''; 
    73                 //window.open(url); 
    74         } 
    7517</script> 
    7618<center> 
    7719<font color="#000000" face="{font}"> 
    78  
    79 <form action="{action_url}" method="post" name="app_form" enctype="multipart/form-data"> 
     20<form action="{action_url}" method="post" name="app_form" id="formEvent"> 
    8021{common_hidden} 
    8122<table id="editFormTable" border="0" width="90%"   class="prefTable"> 
     23<input id="set_participants" style="visibility: hidden;" value="{lang_set_participants}"></input> 
    8224 <tr> 
    8325  <td colspan="2"> 
     
    9436                var alert_field = '{alert_msg}'; 
    9537        </script> 
    96         <input id="submit_button" style="font-size:10px" type="submit" value="{submit_button}" onClick="return submitValues(alert_field);"></div></form> 
     38        <input id="submit_button" style="font-size:10px" type="button" value="{submit_button}"  onclick="javascript:submitValues(this);" ></div></form> 
    9739  </td> 
    9840  <td>{cancel_button}</td> 
  • trunk/calendar/templates/default/event_link.tpl

    r4001 r5132  
    2020 
    2121<!-- BEGIN link_event_text --> 
    22         <tr style="font-size: 12px;background: #dddddd;"> 
    23                 <td valign="top" style="color: black;"> 
     22        <tr style="font-size: 10px;background: #dddddd;"> 
     23                <td valign="top" style="color: black; font-size: 11px;"> 
    2424                        <span> 
    2525                                {time} 
    2626                        </span> 
    2727                </td> 
    28                 <td valign="top" style=" border: #b3b3b3 1px solid;" colspan="5"> 
     28                <td style="font-size: 11px; border: #E8F0F0 1px solid;" colspan="3"> 
    2929                        <span><b>{title}</b></span> 
    3030                        <br /> 
     
    3232                        <span>{location}</span> 
    3333                        <br /> 
    34                         <span>{observations}</span> 
    3534                </td> 
    3635        </tr> 
  • trunk/calendar/templates/default/footer.tpl

    r4114 r5132  
    3737<td valign="top" width="30%"> 
    3838 <font size="-1"> 
    39     <form id="listPrint" action="{acao}" method="post" name="{formname}"> 
    40  
    41         <span style="display: {display}"> 
    42             <b>{day_ini_label}:</b> 
    43             <select id="dayIni" name="{day_ini_name}" > 
    44                 {row_ini} 
    45             </select> 
    46         </span> 
    47  
    48         <br /> <br /> 
    49  
     39    <form action="{acao}" method="post" name="{formname}"> 
    5040        <span style="display: {display}" > 
     41  
    5142            <label> 
    5243                <b>{num_dias_label}:</b> 
    5344            </label> 
    54             <select id="numDays" name="{num_dias_name}" > 
     45        <select name="{num_dias_name}" onchange="{formonchange}"/> 
    5546                {row_qtd} 
    5647            </select> 
     
    5950                {tip} 
    6051            </span> 
     52        <br /> <br /> 
    6153        </span> 
    62         <input type="hidden" name="user" value="{user}"> 
     54<span style="display: {display}"> 
     55        <b>{day_ini_label}:</b> 
     56        <select name="{day_ini_name}" onchange="{formonchange}"> 
     57        {row_ini} 
     58        </select> 
     59        </span> 
     60<input type="hidden" name="user" value="{user}"> 
    6361        <noscript><input type="submit" value="{go}"></noscript> 
    6462     </form> 
  • trunk/calendar/templates/default/grant_group_access.tpl

    r1487 r5132  
    1616<td align='center' valign="bottom"><br><b>{lang_User_to_grant_access}</b><br> 
    1717        <font color="red"><span id="cal_span_searching1">&nbsp;</span></font> 
    18         <br>{lang_Search_for}: <input type="text" id="cal_input_searchUser1" name="cal_input_searchUser1" value="" size=30 autocomplete="off" onkeyup="javascript:search_object(this,'cal_span_searching1','user','u')"/> 
     18        <br>{lang_Search_for}: <input type="text" id="cal_input_searchUser1" name="cal_input_searchUser1" value="" size=30 autocomplete="off" onkeyup="javascript:search_object(this,'cal_span_searching1','user','u', event)"/> 
    1919        <br><br> 
    2020        <select id="user" style="width: 300px" size="13"></select> 
     
    3131<td align='center' valign="bottom"><br><b>{lang_Group_to_share_calendar}</b><br> 
    3232        <font color="red"><span id="cal_span_searching2">&nbsp;</span></font> 
    33         <br>{lang_Search_for}:  <input type="text" id="cal_input_searchUser2" name="cal_input_searchUser2" value="" size=30 autocomplete="off" onkeyup="javascript:search_object(this,'cal_span_searching2','group','g')"/><br><br> 
     33        <br>{lang_Search_for}:  <input type="text" id="cal_input_searchUser2" name="cal_input_searchUser2" value="" size=30 autocomplete="off" onkeyup="javascript:search_object(this,'cal_span_searching2','group','g', event)"/><br><br> 
    3434        <select id="group" style="width: 300px" size="13"></select> 
    3535</td> 
  • trunk/calendar/templates/default/holiday.tpl

    r2 r5132  
    11<!-- BEGIN form --> 
     2 
     3 
     4<script type="text/javascript">  
     5        function valida(){ 
     6                if (document.getElementsByName("holiday[locale]")[0].selectedIndex == 0){ 
     7                         alert("Por favor, selecione um país para inclusão deste feríado."); 
     8                         return false; 
     9                } 
     10                if( (document.getElementsByName("holiday[mday]")[0].selectedIndex == 0) ||  
     11                   (document.getElementsByName("holiday[month_num]")[0].selectedIndex == 0) ||  
     12                   (document.getElementsByName("holiday[year]")[0].selectedIndex == 0) ){ 
     13                         alert("Por favor, informe uma data."); 
     14                         return false; 
     15                }else{ 
     16                        document.forms["form"].submit(); 
     17                } 
     18        } 
     19</script> 
     20 
    221<center> 
    322{message}<br> 
     
    1130    <tr> 
    1231     <td> 
    13       <input type="submit" name="submit" value="{lang_add}"></form> 
     32      <input type="button" onclick="javascript:valida();" value="{lang_add}"></form> 
    1433     </td> 
    1534     <td> 
  • trunk/calendar/templates/default/month_print.tpl

    r4001 r5132  
    22<table class="calendar_index_table" id="calendar_index_table"  width="100%" cols="5"> 
    33        <tr> 
    4                 <td align="left" width="27%"> 
     4                <td align="left" width="33%"> 
    55                        <span class="calendar_user_identifier"> 
    66                                        {username} 
    77                        </span> 
    88                </td> 
    9                 <td align="center" width="45%"> 
     9                <td align="center" width="33%"> 
    1010                        <span class="calendar_month_identifier"> 
    1111                                {month_identifier} 
    1212                        </span> 
    1313                </td> 
    14                 <td align="right" style="width: 27%; font-size: 14px;"> 
     14                <td align="right" style="width: 33%; font-size: 14px;"> 
    1515                        <span class="calendar_user_identifier"> 
    1616                                <p>Agenda de Eventos</p> 
  • trunk/calendar/templates/default/overlap.tpl

    r2 r5132  
    1717                                <tr> 
    1818                                        <td> 
     19                                                {cancel_button} 
     20                                        </td> 
     21                                        <td> 
    1922                                                {resubmit_button} 
    2023                                        </td> 
     
    2831</table> 
    2932</center> 
     33{suggestion} 
     34<style> 
     35        .even { background-color: #f4f8fb} 
     36        .odd { background-color: #fff} 
     37        .fields { 
     38                list-style-type: none; 
     39                list-style-image: none; 
     40                margin: 0; 
     41                padding: 0; 
     42        } 
     43         
     44        .fields li{ 
     45                text-align:center; 
     46                display: block; 
     47                width:100%; 
     48                margin: 0; 
     49                padding: 0; 
     50        } 
     51 
     52        .fields li div{ 
     53                text-align:left; 
     54                display: inline-block; 
     55                float:center; 
     56                width:220px; 
     57        }        
     58         
     59        label { 
     60                margin: 0 3px 0 3px; 
     61                width: 100px; 
     62                display: inline-block; 
     63        } 
     64</style> 
    3065<!-- END overlap --> 
  • trunk/calendar/templates/default/vcal_import.tpl

    r3736 r5132  
    1 <!-- BEGIN page_block --> 
    21<!-- vcardin form --> 
    32{vcal_header} 
    4                 {error_box} 
    53    <form ENCTYPE="multipart/form-data" method="POST" action="{action_url}"> 
    64      <table border=0> 
     
    119      </table> 
    1210     </form> 
    13 <!-- END page_block --> 
    14 <!-- BEGIN error_block --> 
    15 <b><center>{error_message}</b></center><br><br> 
    16 <!-- END error_block --> 
  • trunk/calendar/templates/default/view.tpl

    r2 r5132  
    11 
    22<!-- BEGIN view_event --> 
     3<!-- <script src="./calendar/templates/default/js/suggestion.js" type="text/javascript" language="JavaScript1.2"></script> --> 
    34<center> 
    45<table id="calendar_view_event" border="0" width="90%"> 
     
    2324                                <tr> 
    2425                                        {button_right} 
    25                                 </tr> 
     26                                        {button_right_suggestion} 
    2627                        </table> 
    2728                </td> 
    2829        </tr> 
    2930</table> 
     31 
     32{suggestion} 
     33 
    3034</center> 
    3135<!-- END view_event --> 
  • trunk/calendar/templates/default/week.tpl

    r3193 r5132  
    1 <table id="calendar_index_table" border="0" width="100%" cols="5"> 
    2         <tr> 
    3                 <td align="left" valign="top" width="20%"> 
    4                 </td> 
    5                 <td align="center" valign="middle" width="15%"> 
    6                         <b>{prev_week_link}</b> 
    7                 </td> 
    8                 <td align="center" width="30%"> 
    9                         <span class="calendar_month_identifier"> 
    10                                 {week_identifier} 
    11                         </span> 
    12                                 <br /> 
    13                         <span class="calendar_user_identifier"> 
    14                                 :&nbsp;{username}&nbsp;: 
    15                         </span> 
    16                 </td> 
    17                 <td align="center" valign="middle" width="15%"> 
    18                         {next_week_link} 
    19                 </td> 
    20                 <td align="right" valign="top" width="20%"> 
    21                 </td> 
    22         </tr> 
    23 </table> 
    241{week_display} 
    252<!-- from month_day.tpl --> 
Note: See TracChangeset for help on using the changeset viewer.