Changeset 6891
- Timestamp:
- 07/27/12 14:47:35 (11 years ago)
- Location:
- sandbox/2.4.2-expresso1
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.4.2-expresso1/expressoMail1_2/js/main.js
r6788 r6891 3907 3907 wfolders.makeWindow('null','import'); 3908 3908 } 3909 function import_calendar(data){ 3910 var import_url = '$this.db_functions.import_vcard&msg_folder='+data; 3911 var logUser; 3912 var up; 3913 var owner; 3909 3910 function import_calendar(data){ 3911 var import_url = '$this.db_functions.import_vcard&msg_folder='+data; 3912 var logUser; 3913 var up; 3914 var owner; 3915 3916 //Verifica o contexto de importação 3917 var decodeOwner = function(){ 3918 3919 owner = User.me.id; 3920 var imapBox = openTab.imapBox[currentTab].split(cyrus_delimiter); 3921 if(imapBox.length > 1){ 3922 var user = DataLayer.get('user', {filter: ['=','uid',imapBox[1]]}); 3923 owner = $.isArray(user) ? user[0].id : user.id; 3924 } 3925 3926 return owner; 3927 } 3928 3929 function handler_import_calendar(data){ 3930 if(data === true){ 3931 write_msg(get_lang("The event was imported successfully.")); 3932 } 3933 else if( data['url'] ) 3934 { 3935 var form = document.createElement( "form" ); 3914 3936 3915 //Verifica o contexto de importação 3916 var decodeOwner = function(){ 3917 3918 owner = User.me.id; 3919 var imapBox = openTab.imapBox[currentTab].split(cyrus_delimiter); 3920 if(imapBox.length > 1){ 3921 var user = DataLayer.get('user', {filter: ['=','uid',imapBox[1]]}); 3922 owner = $.isArray(user) ? user[0].id : user.id; 3923 } 3924 3925 return owner; 3937 form.setAttribute( "action", DEFAULT_URL + data['url'] + '&isPost=true' ); 3938 form.setAttribute( "method", "POST" ); 3939 3940 document.body.appendChild( form ); 3941 3942 form.submit(); 3943 } 3944 else 3945 write_msg(get_lang(data)); 3946 } 3947 if(defaultCalendar == "expressoCalendar" && $("#expressoCalendarid")[0]){ 3948 import_implements_calendar(); 3949 $( "#import-dialog" ).dialog({ 3950 autoOpen: false, 3951 height: 220, 3952 modal: true, 3953 resizable : false, 3954 close: function(event) { 3955 event.stopPropagation(); 3956 }, 3957 closeOnEscape: true 3958 }); 3959 3960 $.ajax({ 3961 url: "controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&readable=true&cirus_delimiter='+cyrus_delimiter+'&analize=true&uidAccount='+decodeOwner(), 3962 async: false, 3963 success: function(data){ 3964 data = connector.unserialize(data); 3965 3966 3967 var createDialog = function(typeImport, propaget){ 3968 3969 if(typeof(typeImport) == "object"){ 3970 var calendarPermission = typeImport.calendar; 3971 typeImport = typeImport.action; 3972 } 3973 3974 switch(parseInt(typeImport)){ 3975 case 1: 3976 case 7: 3977 case 10: 3978 $("#select-agenda").html(''); 3979 3980 var options = ''; 3981 3982 if(typeImport == 10){ 3983 for(var i = 0; i < calendarPermission.length; i++) 3984 options += '<option value="'+calendarPermission[i]+'">'+Calendar.signatureOf[calendarPermission[i]].calendar.name+'</option>' 3985 }else{ 3986 for(var id in Calendar.signatures) 3987 options += parseInt(Calendar.signatures[id].isOwner) ? '<option value="'+Calendar.signatures[id].calendar.id+'">'+Calendar.signatures[id].calendar.name+'</option>' : ''; 3988 } 3989 3990 $("#select-agenda").append(options); 3991 $("#select-agenda").css("display", "block"); 3992 3993 $("#import-dialog" ).dialog({ 3994 buttons: { 3995 Cancel: function() { 3996 $( this ).dialog( "close" ); 3997 }, 3998 "Importar" : function(){ 3999 $.ajax({ 4000 url: "controller.php?action="+import_url+'&from_ajax=true&selected='+$("#select-agenda option:selected").val()+'&status='+$("#select-status option:selected").val()+'&uidAccount='+decodeOwner(), 4001 success: function(msg){ 4002 var alt = ( (msg = connector.unserialize(msg)) == "ok") ? "Importado com sucesso para " : "Ocorreu um erro ao importar o evento para a agenda "; 4003 alert( alt + $("#select-agenda option:selected").text() ); 4004 } 4005 }); 4006 $( this ).dialog( "close" ); 4007 } 4008 } 4009 }); 4010 4011 if(typeImport == 7){ 4012 $("#import-dialog").find('#select-status option[value=1]').attr('selected','selected').trigger('change'); 4013 $("#import-dialog").find('#select-status').attr('disabled','disabled'); 4014 } 4015 break; 4016 case 3: 4017 $.ajax({ 4018 url: "controller.php?action="+import_url+'&from_ajax=true&selected=true', 4019 success: function(msg){ 4020 alert( ( ( connector.unserialize(msg)) == "ok") ? "Seu evento foi removido " : "Ocorreu um erro ao remover o evento" ); 4021 } 4022 }); 4023 return; 4024 break; 4025 case 5: 4026 $.ajax({ 4027 url: "controller.php?action="+import_url+'&from_ajax=true&selected=true', 4028 success: function(msg){ 4029 alert( ( ( connector.unserialize(msg)) == "ok") ? "Seu evento foi Atualizado com sucesso" : "Ocorreu um erro ao atualizar evento" ); 4030 } 4031 }); 4032 return; 4033 break; 4034 case 6: 4035 var acceptedSuggestion = confirm("Deseja atualizar o evento de acordo com a sugestão ?"); 4036 $.ajax({ 4037 url: "controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&selected=true&cirus_delimiter='+cyrus_delimiter+'&acceptedSuggestion='+acceptedSuggestion+"&from="+document.getElementById('from_values_'+currentTab).value+'&uidAccount='+decodeOwner(), 4038 success: function(msg){ 4039 if(acceptedSuggestion) 4040 alert( ( ( connector.unserialize(msg)) == "ok") ? "Evento atualizado com sucesso " : "Ocorreu um erro ao atualizar o evento" ); 4041 } 4042 }); 4043 return; 4044 break; 4045 case 9: 4046 alert('Seu evento não possui alterações!'); 4047 return; 4048 break; 4049 case 11: 4050 alert('Este evento já fora importando por algum dos particpantes e já se encontra disponível em sua agenda compartilhada!'); 4051 return; 4052 break; 4053 default: 4054 up = true; 4055 $("#select-agenda").css("display", "none"); 4056 $("#import-dialog" ).children("p:first-child").css("display", "none"); 4057 $("#import-dialog" ).dialog({ 4058 height: 160, 4059 title: 'Atualizar Evento', 4060 buttons: { 4061 Cancel: function() { 4062 $( this ).dialog( "close" ); 4063 }, 4064 "Atualizar": function() { 4065 4066 $.ajax({ 4067 url: "controller.php?action="+import_url+'&from_ajax=true&cirus_delimiter='+cyrus_delimiter+'&selected='+ (parseInt(typeImport) == 2 || parseInt(typeImport) == 4 ? 'true' : $("#select-agenda option:selected").val()) +'&status='+$("#select-status option:selected").val()+'&uidAccount='+decodeOwner(), 4068 success: function(msg){ 4069 alert( ( (msg = connector.unserialize(msg)) == "ok") ? "Atualizado com sucesso" : "Ocorreu um erro ao atualizar o evento" ); 4070 } 4071 }); 4072 $( this ).dialog( "close" ); 4073 } 4074 } 4075 }); 4076 $(".ui-dialog-buttonpane").find(".ui-button:last").children().html("Atualizar"); 4077 } 4078 $( "#import-dialog" ).dialog( "open" ); 4079 4080 }; 4081 createDialog(data, true); 4082 4083 }, 4084 beforeSend: function( jqXHR, settings ){ 4085 connector.showProgressBar(); 4086 }, 4087 complete: function( jqXHR, settings ){ 4088 connector.hideProgressBar(); 4089 } 4090 }); 4091 4092 } 4093 else 4094 { 4095 if(confirm(get_lang("Do you confirm this import to your Calendar?"))){ 4096 cExecute( import_url + "&from_ajax=true", handler_import_calendar); 4097 } 4098 } 3926 4099 } 3927 3928 function handler_import_calendar(data){ 3929 if(data === true){ 3930 write_msg(get_lang("The event was imported successfully.")); 3931 } 3932 else if( data['url'] ) 3933 { 3934 var form = document.createElement( "form" ); 3935 3936 form.setAttribute( "action", DEFAULT_URL + data['url'] + '&isPost=true' ); 3937 form.setAttribute( "method", "POST" ); 3938 3939 document.body.appendChild( form ); 3940 3941 form.submit(); 3942 } 3943 else 3944 write_msg(get_lang(data)); 3945 } 3946 if(defaultCalendar == "expressoCalendar" && $("#expressoCalendarid")[0]){ 3947 import_implements_calendar(); 3948 $( "#import-dialog" ).dialog({ 3949 autoOpen: false, 3950 height: 220, 3951 modal: true, 3952 resizable : false, 3953 close: function(event) { 3954 event.stopPropagation(); 3955 }, 3956 closeOnEscape: true 3957 }); 3958 3959 $.ajax({ 3960 url: "controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&readable=true&cirus_delimiter='+cyrus_delimiter+'&analize=true&uidAccount='+decodeOwner(), 3961 async: false, 3962 success: function(data){ 3963 data = connector.unserialize(data); 3964 3965 3966 var createDialog = function(typeImport, propaget){ 3967 3968 if(typeof(typeImport) == "object"){ 3969 var calendarPermission = typeImport.calendar; 3970 typeImport = typeImport.action; 3971 } 3972 3973 switch(parseInt(typeImport)){ 3974 case 1: 3975 case 7: 3976 case 10: 3977 $("#select-agenda").html(''); 3978 3979 var options = ''; 3980 3981 if(typeImport == 10){ 3982 for(var i = 0; i < calendarPermission.length; i++) 3983 options += '<option value="'+calendarPermission[i]+'">'+Calendar.signatureOf[calendarPermission[i]].calendar.name+'</option>' 3984 }else{ 3985 for(var id in Calendar.signatures) 3986 options += parseInt(Calendar.signatures[id].isOwner) ? '<option value="'+Calendar.signatures[id].calendar.id+'">'+Calendar.signatures[id].calendar.name+'</option>' : ''; 3987 } 3988 3989 $("#select-agenda").append(options); 3990 $("#select-agenda").css("display", "block"); 3991 3992 $("#import-dialog" ).dialog({ 3993 buttons: { 3994 Cancel: function() { 3995 $( this ).dialog( "close" ); 3996 }, 3997 "Importar" : function(){ 3998 $.ajax({ 3999 url: "controller.php?action="+import_url+'&from_ajax=true&selected='+$("#select-agenda option:selected").val()+'&status='+$("#select-status option:selected").val()+'&uidAccount='+decodeOwner(), 4000 success: function(msg){ 4001 var alt = ( (msg = connector.unserialize(msg)) == "ok") ? "Importado com sucesso para " : "Ocorreu um erro ao importar o evento para a agenda "; 4002 alert( alt + $("#select-agenda option:selected").text() ); 4003 } 4004 }); 4005 $( this ).dialog( "close" ); 4006 } 4007 } 4008 }); 4009 4010 if(typeImport == 7){ 4011 $("#import-dialog").find('#select-status option[value=1]').attr('selected','selected').trigger('change'); 4012 $("#import-dialog").find('#select-status').attr('disabled','disabled'); 4013 } 4014 break; 4015 case 3: 4016 $.ajax({ 4017 url: "controller.php?action="+import_url+'&from_ajax=true&selected=true', 4018 success: function(msg){ 4019 alert( ( ( connector.unserialize(msg)) == "ok") ? "Seu evento foi removido " : "Ocorreu um erro ao remover o evento" ); 4020 } 4021 }); 4022 return; 4023 break; 4024 case 5: 4025 $.ajax({ 4026 url: "controller.php?action="+import_url+'&from_ajax=true&selected=true', 4027 success: function(msg){ 4028 alert( ( ( connector.unserialize(msg)) == "ok") ? "Seu evento foi Atualizado com sucesso" : "Ocorreu um erro ao atualizar evento" ); 4029 } 4030 }); 4031 return; 4032 break; 4033 case 6: 4034 var acceptedSuggestion = confirm("Deseja atualizar o evento de acordo com a sugestão ?"); 4035 $.ajax({ 4036 url: "controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&selected=true&cirus_delimiter='+cyrus_delimiter+'&acceptedSuggestion='+acceptedSuggestion+"&from="+document.getElementById('from_values_'+currentTab).value, 4037 success: function(msg){ 4038 if(acceptedSuggestion) 4039 alert( ( ( connector.unserialize(msg)) == "ok") ? "Evento atualizado com sucesso " : "Ocorreu um erro ao atualizar o evento" ); 4040 } 4041 }); 4042 return; 4043 break; 4044 case 9: 4045 alert('Seu evento não possui alterações!'); 4046 return; 4047 break; 4048 case 11: 4049 alert('Este evento já fora importando por algum dos particpantes e já se encontra disponível em sua agenda compartilhada!'); 4050 return; 4051 break; 4052 default: 4053 up = true; 4054 $("#select-agenda").css("display", "none"); 4055 $("#import-dialog" ).children("p:first-child").css("display", "none"); 4056 $("#import-dialog" ).dialog({ 4057 height: 160, 4058 title: 'Atualizar Evento', 4059 buttons: { 4060 Cancel: function() { 4061 $( this ).dialog( "close" ); 4062 }, 4063 "Atualizar": function() { 4064 4065 $.ajax({ 4066 url: "controller.php?action="+import_url+'&from_ajax=true&selected='+ (parseInt(typeImport) == 2 || parseInt(typeImport) == 4 ? 'true' : $("#select-agenda option:selected").val()) +'&status='+$("#select-status option:selected").val(), 4067 success: function(msg){ 4068 alert( ( (msg = connector.unserialize(msg)) == "ok") ? "Atualizado com sucesso para " : "Ocorreu um erro ao atualizar o evento" ); 4069 } 4070 }); 4071 $( this ).dialog( "close" ); 4072 } 4073 } 4074 }); 4075 $(".ui-dialog-buttonpane").find(".ui-button:last").children().html("Atualizar"); 4076 } 4077 $( "#import-dialog" ).dialog( "open" ); 4078 4079 }; 4080 createDialog(data, true); 4081 4082 }, 4083 beforeSend: function( jqXHR, settings ){ 4084 connector.showProgressBar(); 4085 }, 4086 complete: function( jqXHR, settings ){ 4087 connector.hideProgressBar(); 4088 } 4089 }); 4090 4091 } 4092 else 4093 { 4094 if(confirm(get_lang("Do you confirm this import to your Calendar?"))){ 4095 cExecute( import_url + "&from_ajax=true", handler_import_calendar); 4096 } 4097 } 4098 } 4100 4099 4101 function open_msg_part(data){ 4100 4102 var handler_open_msg_part = function (data) -
sandbox/2.4.2-expresso1/prototype/modules/calendar/interceptors/DBMapping.php
r6876 r6891 820 820 821 821 static private function countMyCalendarsEvent($id, $owner) { 822 $sig = Controller::find(array('concept' => 'calendarSignature'), array('user', 'calendar', 'isOwner'), array('filter' => array('AND', array('=', ' user', $owner), array('=', 'isOwner', '1'))));822 $sig = Controller::find(array('concept' => 'calendarSignature'), array('user', 'calendar', 'isOwner'), array('filter' => array('AND', array('=', 'isOwner', '1'), array('=', 'user', $owner)))); 823 823 $calendars = array(); 824 824 foreach ($sig as $val) … … 939 939 940 940 public function createDefaultGroup(&$uri, &$result, &$criteria, $original) { 941 $existDefaultGroup = false; 942 943 foreach($result as $v){ 944 if($v['type'] == 1 && $v['calendar']['type'] == 1) 945 $existDefaultGroup = true; 946 } 947 948 if(!$existDefaultGroup){ 949 950 $cal = array('name' => 'Sem grupo', 951 'description' => 'Sem grupo', 952 'timezone' => (date_default_timezone_get()) ? date_default_timezone_get() : 'America/Sao_Paulo', 953 'dtstamp' => time() . '000', 954 'type' => '1' 955 ); 956 957 $calCreated = Controller::create(array('concept' => 'calendar'), $cal); 958 959 $sig = array('user' => $_SESSION['wallet']['user']['uidNumber'], 960 'calendar' => $calCreated['id'], 961 'isOwner' => '1', 962 'dtstamp' => time() . '000', 963 'fontColor' => 'FFFFFF', 964 'backgroundColor' => '3366CC', 965 'borderColor' => '3366CC', 966 'type' => '1' 967 ); 968 969 $sigCreated = Controller::create(array('concept' => 'calendarSignature'), $sig); 970 $sigCreated = Controller::read(array('concept' => 'calendarSignature', 'id' => $sigCreated['id']), false, array('deepness' => 2 )); 971 972 array_push($result, $sigCreated); 973 941 if( $original['criteria']['filter'][1][0] == '=' && 942 $original['criteria']['filter'][1][1] == 'user' && 943 $original['criteria']['filter'][1][2] == $_SESSION['phpgw_session']['account_id']){ 944 945 $existDefaultGroup = false; 946 947 foreach($result as $v){ 948 if($v['type'] == 1 && $v['calendar']['type'] == 1) 949 $existDefaultGroup = true; 950 } 951 952 if(!$existDefaultGroup){ 953 954 $cal = array('name' => 'Sem grupo', 955 'description' => 'Sem grupo', 956 'timezone' => (date_default_timezone_get()) ? date_default_timezone_get() : 'America/Sao_Paulo', 957 'dtstamp' => time() . '000', 958 'type' => '1' 959 ); 960 961 $calCreated = Controller::create(array('concept' => 'calendar'), $cal); 962 963 $sig = array('user' => $_SESSION['wallet']['user']['uidNumber'], 964 'calendar' => $calCreated['id'], 965 'isOwner' => '1', 966 'dtstamp' => time() . '000', 967 'fontColor' => 'FFFFFF', 968 'backgroundColor' => '3366CC', 969 'borderColor' => '3366CC', 970 'type' => '1' 971 ); 972 973 $sigCreated = Controller::create(array('concept' => 'calendarSignature'), $sig); 974 $sigCreated = Controller::read(array('concept' => 'calendarSignature', 'id' => $sigCreated['id']), false, array('deepness' => 2 )); 975 976 array_push($result, $sigCreated); 977 } 974 978 975 979 } -
sandbox/2.4.2-expresso1/prototype/modules/calendar/js/calendar.codecs.js
r6885 r6891 1074 1074 1075 1075 return notArray ? res[0] : res; 1076 } 1077 1078 }); 1079 1080 1081 DataLayer.codec( "schedulable", "print", { 1082 1083 decoder: function( evtObj ){ 1084 1085 }, 1086 1087 1088 encoder: function( evtObj ){ 1089 1090 if(!(!!evtObj)) 1091 return undefined; 1092 1093 var notArray = false; 1094 1095 if( notArray = $.type(evtObj) !== "array" ) 1096 evtObj = [ evtObj ]; 1097 1098 var pref = User.preferences; 1099 var res = []; 1100 1101 for(var i = 0; i < evtObj.length; i++){ 1102 res.push(DataLayer.encode('schedulable:' + (evtObj[i].type == '1' ? 'preview' : 'task'), evtObj[i])); 1103 } 1104 1105 if( !notArray ){ 1106 var dates = {}; 1107 1108 var typeRepeat = { 1109 'none': false, 1110 'daily': 'Repetição diária', 1111 'weekly': 'Repetição semanal', 1112 'monthly': 'Repetição mensal', 1113 'yearly': 'repetição anual' 1114 } 1115 1116 for (var i=0; i < res.length; i++) { 1117 var startDate = Date.parseExact( res[i]['startDate'], User.preferences.dateFormat ); 1118 var endDate = Date.parseExact( res[i]['endDate'], User.preferences.dateFormat ); 1119 1120 var duration = parseInt( endDate.getTime() ) - parseInt( startDate.getTime() ); 1121 1122 var occurrences = [ startDate.getTime() ]; 1123 1124 if( res[i].occurrences ) 1125 { 1126 occurrences = res[i].occurrences; 1127 } 1128 1129 for( var ii = 0; ii < occurrences.length; ii++ ) 1130 { 1131 var currentDate = new Date( occurrences[ii] ); 1132 var counter = currentDate.clone(); 1133 1134 var res2 = $.extend( {}, res[i], { 1135 'startDate': currentDate.toString( User.preferences.dateFormat ), 1136 'endDate': new Date( occurrences[ii] + duration ).toString( User.preferences.dateFormat ) 1137 }); 1138 1139 if(res[i].repeat) 1140 res2.repeat = typeRepeat[res[i].repeat.frequency]; 1141 1142 var index = dateCalendar.dayNames[counter.getDay()] +' '+counter.toString('dd/MM'); 1143 1144 if(!dates[index] || !$.isArray(dates[index].events)) 1145 dates[index] = {events: []}; 1146 1147 dates[index].events.push(res2); 1148 1149 } 1150 } 1151 1152 var calendarView = $('#calendar').fullCalendar('getView'); 1153 var start = calendarView.visStart.getTime(); 1154 var end = calendarView.visEnd.getTime(); 1155 var next = start; 1156 var response = []; 1157 1158 while (next){ 1159 var index = dateCalendar.dayNames[new Date(next).getDay()] +' '+ new Date(next).toString('dd/MM'); 1160 1161 var event = {}; 1162 event[index] = {events: dates[index] ? dates[index].events : false}; 1163 1164 response[response.length] = event; 1165 next = (next + 86400000) > end ? false : (next + 86400000); 1166 } 1167 1168 1169 res = {events: response}; 1170 } 1171 1172 return notArray ? res[0] : res; 1076 1173 } 1077 1174 -
sandbox/2.4.2-expresso1/prototype/services/iCal.php
r6528 r6891 122 122 break; 123 123 124 case TASK_ID: 125 126 $todo = $ical->newComponent('todo'); 127 128 $todo->setProperty('summary', $v['summary']); 129 $todo->setProperty('description', isset($v['description']) ? $v['description'] : ''); 130 $todo->setProperty('priority', $v['priority']); 131 $todo->setProperty('percent-complete', $v['percentage']); 132 $todo->setProperty('status', $this->_getStatusTodo($v['status'])); 133 134 $timezone = new DateTimeZone('UTC'); 135 $apTimezone = self::nomalizeTZID(( isset($v['timezone']) && $v['timezone'] != 'null' ) ? $v['timezone'] : $params['defaultTZI']); 136 $apTimezoneOBJ = new DateTimeZone($apTimezone); 137 138 $sTime = new DateTime('@' . (int) ($v['startTime'] / 1000), $timezone); 139 $sTime->setTimezone($apTimezoneOBJ); 140 $eTime = new DateTime('@' . (int) ($v['endTime'] / 1000), $timezone); 141 $eTime->setTimezone($apTimezoneOBJ); 142 143 if (isset($v['allDay']) && $v['allDay'] == 1) { 144 $todo->setProperty('dtstart', $sTime->format(DATE_RFC822), array("VALUE" => "DATE")); 145 $todo->setProperty('dtend', $eTime->format(DATE_RFC822), array("VALUE" => "DATE")); 146 //$todo->setProperty('X-MICROSOFT-CDO-ALLDAYEVENT', 'TRUE'); 147 } else { 148 $todo->setProperty('dtstart', $sTime->format(DATE_RFC822), array('TZID' => $apTimezone)); 149 $todo->setProperty('dtend', $eTime->format(DATE_RFC822), array('TZID' => $apTimezone)); 150 //$todo->setProperty('X-MICROSOFT-CDO-ALLDAYEVENT', 'FALSE'); 151 } 152 153 if(isset($v['due']) && $v['due'] != ''){ 154 $dueTime = new DateTime('@' . (int) ($v['due'] / 1000), $timezone); 155 $dueTime->setTimezone($apTimezoneOBJ); 156 157 $todo->setProperty('due', $dueTime->format(DATE_RFC822), array('TZID' => $apTimezone)); 158 } 159 160 $todo->setProperty('due', $dueTime->format(DATE_RFC822), array('TZID' => $apTimezone)); 161 162 if (isset($v['participants']) && is_array($v['participants']) && count($v['participants']) > 0) 163 $participants = $v['participants']; 164 else 165 $participants = Controller::find(array('concept' => 'participant'), false, array('filter' => array('=', 'schedulable', $v['id']))); 166 167 if (is_array($participants) && count($participants) > 0) 168 foreach ($participants as $ii => $vv) { 169 170 if(isset($participants[$ii]['user']) && !is_array($participants[$ii]['user'])) 171 { 172 if ($vv['isExternal'] == 1) 173 $participants[$ii]['user'] = Controller::read(array('concept' => 'user', 'id' => $vv['user'], 'service' => 'PostgreSQL')); 174 else 175 $participants[$ii]['user'] = Controller::read(array('concept' => 'user', 'id' => $vv['user'])); 176 } 177 178 if ($participants[$ii]['user']['id'] == Config::me('uidNumber')) 179 { 180 $alarms = (isset($participants[$ii]['alarms'])) ? $participants[$ii]['alarms'] : Controller::find(array('concept' => 'alarm'), null, array('filter' => array('AND', array('=', 'participant', $vv['id']), array('=', 'schedulable', $v['id'])))); 181 if(is_array($alarms)) 182 self::createAlarms($alarms, $todo); 183 } 184 185 } 186 187 188 if (isset($v['participants']) && is_array($v['participants']) && count($v['participants']) > 0) 189 $this->createAttendee($v['participants'], $todo); 190 191 if (isset($v['attachments']) && is_array($v['attachments']) && count($v['attachments']) > 0) 192 $this->createAttachment($v['attachments'], $todo); 193 194 $todo->setProperty('uid', $v['uid']); 195 196 break; 197 124 198 default: 125 199 break; … … 219 293 220 294 public function parse($data, $params = false) { 221 Config::regSet('noAlarm', TRUE); //Evita o envio de notifica ção295 Config::regSet('noAlarm', TRUE); //Evita o envio de notificação 222 296 $vcalendar = new icalCreator( ); 223 297 $vcalendar->parse(trim($data)); … … 232 306 $interation = array(); 233 307 $uid = $component->getProperty('uid', false, false); //Resgata o uid do componente 308 309 ob_start(); 310 print_r(strtoupper($component->objName)); 311 $output = ob_get_clean(); 312 file_put_contents( "/tmp/acoutinho.log", $output , FILE_APPEND); 313 234 314 235 315 switch (strtoupper($component->objName)) { … … 238 318 switch ($method) { 239 319 case 'PUBLISH': 240 //Caso o evento n ão exista o mesmo cria um novo evento, se jáexistir o mesmo referencia o evento com agenda320 //Caso o evento não exista o mesmo cria um novo evento, se já existir o mesmo referencia o evento com agenda 241 321 if (!$schedulable = self::_getSchedulable($uid)) 242 322 $interation = self::_makeVEVENT($schedulable, $component, $params); … … 273 353 } 274 354 275 Config::regSet('noAlarm', FALSE); //reativa notifica ção355 Config::regSet('noAlarm', FALSE); //reativa notificação 276 356 } else { 277 357 278 if (self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] || $component->getProperty('sequence', false, false) > $schedulable['sequence']) //Organizador esta requisitando que voc êatualize o evento358 if (self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] || $component->getProperty('sequence', false, false) > $schedulable['sequence']) //Organizador esta requisitando que você atualize o evento 279 359 $interation = self::_makeVEVENT($schedulable, $component, $params); 280 360 else if ($component->getProperty('sequence', false, false) === $schedulable['sequence']) { 281 361 //Ler melhor rfc sobre isto 3.2.2.2 282 //Aparentemente épara retornar um ical com o evento atualizado para o attende362 //Aparentemente é para retornar um ical com o evento atualizado para o attende 283 363 } 284 364 … … 289 369 }else 290 370 $pID = self::_getParticipantByMail(Config::me('mail'), $schedulable['participants']); 291 //Verifica a importa ção de eventos em que não participo371 //Verifica a importação de eventos em que não participo 292 372 if ($pID) { 293 373 $interation['participant://' . $pID]['status'] = $params['status']; … … 298 378 $interation = self::_makeVEVENT(array(), $component, $params); 299 379 300 if (strpos($params['prodid'], 'kigkonsult.se') !== false) { //envia notifica ção para fora380 if (strpos($params['prodid'], 'kigkonsult.se') !== false) { //envia notificação para fora 301 381 302 382 /* Data de Inicio */ … … 316 396 $sc['allDay'] = 1; 317 397 $sc['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $sc['timezone']) . '000'; 318 } elseif (isset($startTime['params']['TZID']) && !isset($startTime['value']['tz']))/* Caso n ão tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */398 } elseif (isset($startTime['params']['TZID']) && !isset($startTime['value']['tz']))/* Caso não tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */ 319 399 $sc['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $startTime['params']['TZID']) . '000'; 320 400 else { 321 401 $sc['startTime'] = self::date2timestamp($startTime['value']) . '000'; 322 402 if (strpos($params['prodid'], 'Outlook') !== false) { 323 //Se o ics veio em utc n ão aplicar horario de verão403 //Se o ics veio em utc não aplicar horario de verão 324 404 $sTime = new DateTime('@' . (int) ($sc['startTime'] / 1000), new DateTimeZone('UTC')); 325 405 $sTime->setTimezone($objTimezone); 326 if ($sTime->format('I')) //Se o ics veio em utc n ão aplicar horario de verão406 if ($sTime->format('I')) //Se o ics veio em utc não aplicar horario de verão 327 407 $sc['startTime'] = $sc['startTime'] - 3600000; 328 408 } … … 335 415 if (isset($endTime['params']['VALUE']) && $endTime['params']['VALUE'] === 'DATE') 336 416 $sc['endTime'] = self::date2timestamp($endTime['value']) - self::_getTzOffset('UTC', $sc['timezone']) . '000'; 337 else if (isset($endTime['params']['TZID']) && !isset($endTime['value']['tz'])) /* Caso n ão tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */417 else if (isset($endTime['params']['TZID']) && !isset($endTime['value']['tz'])) /* Caso não tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */ 338 418 $sc['endTime'] = self::date2timestamp($endTime['value']) - self::_getTzOffset('UTC', $endTime['params']['TZID']) . '000'; 339 419 else { 340 420 $sc['endTime'] = self::date2timestamp($endTime['value']) . '000'; 341 421 if (strpos($params['prodid'], 'Outlook') !== false) { 342 //Se o ics veio em utc n ão aplicar horario de verão422 //Se o ics veio em utc não aplicar horario de verão 343 423 $eTime = new DateTime('@' . (int) ($sc['endTime'] / 1000), new DateTimeZone('UTC')); 344 424 $eTime->setTimezone($objTimezone); … … 527 607 else // Importar evento 528 608 $interation = self::_makeVEVENT(array(), $component, $params); 529 530 531 532 609 break; 533 610 } … … 536 613 $return[] = $interation; 537 614 break; 538 case 'VTIMEZONE': 539 540 541 break; 615 /***********************************************************************TODO*******************************************************************************/ 616 case 'VTODO': 617 switch ($method) { 618 case 'PUBLISH': 619 //Caso a tarefa não exista o mesmo cria um novo evento, se já existir o mesmo referencia o evento com agenda 620 if (!$schedulable = self::_getSchedulable($uid)) 621 $interation = self::_makeVEVENT($schedulable, $component, $params); 622 else{ 623 $links = Controller::read(array('concept' => 'calendarToSchedulable'), array('id'), array('filter' => 624 array('AND', 625 array('=', 'calendar', $params['calendar']), 626 array('=', 'schedulable', $schedulable['id']) 627 ))); 628 629 if(!$links && !isset($links[0])) 630 Controller::create(array('concept' => 'calendarToSchedulable'), array('calendar' => $params['calendar'], 'schedulable' => $schedulable['id'])); 631 } 632 break; 633 634 case 'REQUEST': 635 $schedulable = self::_getSchedulable($uid); 636 637 if ($schedulable) { //Caso tarefa exista 638 if (!self::_existInMyCalendars($schedulable['id'], $params['owner'])) { 639 640 $calendarToSchedulable = array(); 641 $calendarToSchedulable['calendar'] = $params['calendar']; 642 $calendarToSchedulable['schedulable'] = $schedulable['id']; 643 $interation['calendarToSchedulable://' . mt_rand() . '(Formatter)'] = $calendarToSchedulable; 644 645 if (isset($params['status'])) { 646 if($params['owner'] != Config::me("uidNumber")){ 647 $user = Controller::Read(array('concept' => 'user'), false, array('filter' => array('=', 'id', $params['owner'])) ); 648 $pID = self::_getParticipantByMail($user[0]['mail'], $schedulable['participants']); 649 }else 650 $pID = self::_getParticipantByMail(Config::me('mail'), $schedulable['participants']); 651 $interation['participant://' . $pID]['status'] = $params['status']; 652 } 653 Config::regSet('noAlarm', FALSE); //reativa notificação 654 } else { 655 656 if (self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] || $component->getProperty('sequence', false, false) > $schedulable['sequence']) //Organizador esta requisitando que você atualize o evento 657 $interation = self::_makeVEVENT($schedulable, $component, $params); 658 else if ($component->getProperty('sequence', false, false) === $schedulable['sequence']) { 659 //Ler melhor rfc sobre isto 3.2.2.2 660 //Aparentemente é para retornar um ical com o evento atualizado para o attende 661 } 662 663 if (isset($params['status'])) { 664 if($params['owner'] != Config::me("uidNumber")){ 665 $user = Controller::Read(array('concept' => 'user'), false, array('filter' => array('=', 'id', $params['owner'])) ); 666 $pID = self::_getParticipantByMail($user[0]['mail'], $schedulable['participants']); 667 }else 668 $pID = self::_getParticipantByMail(Config::me('mail'), $schedulable['participants']); 669 //Verifica a importação de eventos em que não participo 670 if ($pID) { 671 $interation['participant://' . $pID]['status'] = $params['status']; 672 } 673 } 674 } 675 } else { // Importar tarefa 676 $interation = self::_makeVEVENT(array(), $component, $params); 677 678 if (strpos($params['prodid'], 'kigkonsult.se') !== false) { //envia notificação para fora 679 680 /* Data de Inicio */ 681 $startTime = $component->getProperty('dtstart', false, true); 682 $tzid = isset($startTime['params']['TZID']) ? $startTime['params']['TZID'] : $params['X-WR-TIMEZONE']; 683 684 /* Tiem zone do evento */ 685 if ($tzid) 686 $sc['timezone'] = self::nomalizeTZID($tzid); 687 else 688 $sc['timezone'] = isset($params['calendar_timezone']) ? $params['calendar_timezone'] : 'America/Sao_Paulo'; 689 690 $objTimezone = new DateTimeZone($sc['timezone']); 691 692 if (isset($startTime['params']['VALUE']) && $startTime['params']['VALUE'] === 'DATE' && isset($params['calendar_timezone'])) { 693 $sc['allDay'] = 1; 694 $sc['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $sc['timezone']) . '000'; 695 } elseif (isset($startTime['params']['TZID']) && !isset($startTime['value']['tz']))/* Caso não tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */ 696 $sc['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $startTime['params']['TZID']) . '000'; 697 else { 698 $sc['startTime'] = self::date2timestamp($startTime['value']) . '000'; 699 if (strpos($params['prodid'], 'Outlook') !== false) { 700 //Se o ics veio em utc não aplicar horario de verão 701 $sTime = new DateTime('@' . (int) ($sc['startTime'] / 1000), new DateTimeZone('UTC')); 702 $sTime->setTimezone($objTimezone); 703 if ($sTime->format('I')) //Se o ics veio em utc não aplicar horario de verão 704 $sc['startTime'] = $sc['startTime'] - 3600000; 705 } 706 } 707 708 /* Data de Termino */ 709 $endTime = $component->getProperty('dtend', false, true); 710 711 if (isset($endTime['params']['VALUE']) && $endTime['params']['VALUE'] === 'DATE') 712 $sc['endTime'] = self::date2timestamp($endTime['value']) - self::_getTzOffset('UTC', $sc['timezone']) . '000'; 713 else if (isset($endTime['params']['TZID']) && !isset($endTime['value']['tz'])) /* Caso não tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */ 714 $sc['endTime'] = self::date2timestamp($endTime['value']) - self::_getTzOffset('UTC', $endTime['params']['TZID']) . '000'; 715 else { 716 $sc['endTime'] = self::date2timestamp($endTime['value']) . '000'; 717 if (strpos($params['prodid'], 'Outlook') !== false) { 718 //Se o ics veio em utc não aplicar horario de verão 719 $eTime = new DateTime('@' . (int) ($sc['endTime'] / 1000), new DateTimeZone('UTC')); 720 $eTime->setTimezone($objTimezone); 721 if ($eTime->format('I')) 722 $sc['endTime'] = $sc['endTime'] - 3600000; 723 } 724 } 725 726 727 if ($uid = $component->getProperty('uid', false, false)) 728 $sc['uid'] = $uid; 729 730 $sc['summary'] = mb_convert_encoding($component->getProperty('summary', false, false), 'UTF-8', 'UTF-8,ISO-8859-1'); 731 732 /* Definindo Description */ 733 if ($desc = $component->getProperty('description', false, false)) 734 $sc['description'] = mb_convert_encoding(str_ireplace(array('\n', '\t'), array("\n", "\t"), $desc), 'UTF-8', 'UTF-8,ISO-8859-1'); 735 736 if ($priority = $component->getProperty('priority', false, false)) 737 $sc['priority'] = mb_convert_encoding(str_ireplace(array('\n', '\t'), array("\n", "\t"), $priority), 'UTF-8', 'UTF-8,ISO-8859-1'); 738 739 if ($status = $component->getProperty('status', false, false)) 740 $sc['status'] = $this->decodeStatusTodo(mb_convert_encoding(str_ireplace(array('\n', '\t'), array("\n", "\t"), $status), 'UTF-8', 'UTF-8,ISO-8859-1')); 741 742 if ($percentage = $component->getProperty('percent-complete', false, false)) 743 $sc['percentage'] = mb_convert_encoding(str_ireplace(array('\n', '\t'), array("\n", "\t"), $percentage), 'UTF-8', 'UTF-8,ISO-8859-1'); 744 745 $todo->setProperty('priority', $v['priority']); 746 $todo->setProperty('percent-complete', $v['percentage']); 747 $todo->setProperty('status', $this->_getStatusTodo($v['status'])); 748 749 /* Definindo location */ 750 if ($location = $component->getProperty('location', false, false)) 751 $sc['location'] = mb_convert_encoding($location, 'UTF-8', 'UTF-8,ISO-8859-1'); 752 753 754 755 if ($property = $component->getProperty('organizer', FALSE, TRUE)) { 756 $participant = array(); 757 $mailUser = trim(str_replace('MAILTO:', '', $property['value'])); 758 759 $participantID = mt_rand() . '2(Formatter)'; 760 761 $participant['isOrganizer'] = '1'; 762 763 $user = null; 764 765 $participant['isExternal'] = 1; 766 /* Gera um randon id para o contexto formater */ 767 $userID = mt_rand() . '4(Formatter)'; 768 769 $user['mail'] = $mailUser; 770 $organizerMail = $mailUser; 771 772 $user['name'] = ( isset($property['params']['CN']) ) ? $property['params']['CN'] : ''; 773 $user['isExternal'] = '1'; 774 $participant['user'] = $user; 775 776 $sc['participants'][] = $participant; 777 } 778 779 780 $participant['status'] = isset($params['status']) ? $params['status'] : STATUS_ACCEPTED; 781 $participant['isOrganizer'] = '0'; 782 $participant['isExternal'] = 0; 783 $participant['user'] = array('mail' => Config::me('mail'), 'name' => Config::me('cn')); 784 $sc['participants'][] = $participant; 785 $sc['type'] = TODO_ID; 786 787 788 $ical['source'] = Controller::format(array('service' => 'iCal'), array($sc), array('method' => 'REPLY')); 789 $ical['type'] = 'application/ics'; 790 $ical['name'] = 'outlook.ics'; 791 792 $ical2['source'] = $ical['source']; 793 $ical2['type'] = 'text/calendar; method=REPLY'; 794 $ical2['name'] = 'thunderbird.ics'; 795 796 $timezone = new DateTimeZone('UTC'); 797 $sTime = new DateTime('@' . (int) ($sc['startTime'] / 1000), $timezone); 798 $eTime = new DateTime('@' . (int) ($sc['endTime'] / 1000), $timezone); 799 800 if (isset($sc['timezone'])) { 801 $sTime->setTimezone(new DateTimeZone($sc['timezone'])); 802 $eTime->setTimezone(new DateTimeZone($sc['timezone'])); 803 } 804 805 $data = array('startDate' => date_format($sTime, 'd/m/Y'), 806 'startTime' => (isset($sc['allDay']) && $sc['allDay'] ) ? '' : date_format($sTime, 'H:i'), 807 'endDate' => date_format($eTime, 'd/m/Y'), 808 'endTime' => isset($sc['allDay']) ? '' : date_format($eTime, 'H:i'), 809 'eventTitle' => $sc['summary'], 810 'eventLocation' => isset($sc['location']) ? $sc['location'] : '', 811 'timezone' => ($sc['timezone']) ? $sc['timezone'] : 'UTC', 812 'participant' => (isset($part['user']['name']) ? $part['user']['name'] : $part['user']['mail'])); 813 814 $subject['notificationType'] = 'Convite Aceito'; 815 $subject['eventTitle'] = mb_convert_encoding($sc['summary'], 'ISO-8859-1', 'ISO-8859-1,UTF-8'); 816 $subject['startDate'] = date_format($sTime, 'd/m/Y'); 817 $subject['startTime'] = ($sc['allDay']) ? '' : date_format($sTime, 'H:i'); 818 $subject['endDate'] = date_format($eTime, 'd/m/Y'); 819 $subject['endTime'] = ($sc['allDay']) ? '' : date_format($eTime, 'H:i'); 820 $subject['participant'] = Config::me('uid'); 821 822 $params['status'] = isset($params['status']) ? $params['status'] : STATUS_ACCEPTED; 823 824 switch ($params['status']) { 825 case STATUS_ACCEPTED: 826 $tpl = 'notify_accept_body'; 827 $subject['notificationType'] = 'Convite Aceito'; 828 break; 829 case STATUS_TENTATIVE: 830 $tpl = 'notify_attempt_body'; 831 $subject['notificationType'] = 'Convite aceito provisoriamente'; 832 break; 833 case STATUS_CANCELLED: 834 $tpl = 'notify_reject_body'; 835 $subject['notificationType'] = 'Convite rejeitado'; 836 break; 837 } 838 839 require_once ROOTPATH . '/api/parseTPL.php'; 840 841 $mail = array(); 842 $mail['attachments'][] = $ical; 843 $mail['attachments'][] = $ical2; 844 845 $mail['isHtml'] = true; 846 $mail['body'] = parseTPL::load_tpl($data, ROOTPATH . '/modules/calendar/templates/' . $tpl . '.tpl'); 847 $mail['subject'] = parseTPL::load_tpl($subject, ROOTPATH . '/modules/calendar/templates/notify_subject.tpl'); 848 849 $mail['from'] = '"' . Config::me('cn') . '" <' . Config::me('mail') . '>'; 850 $mail['to'] = $organizerMail; 851 852 853 Controller::create(array('service' => 'SMTP'), $mail); 854 } 855 } 856 break; 857 858 case 'REFRESH': 859 break; 860 861 case 'CANCEL': 862 if ($schedulable = self::_getSchedulable($uid)) 863 $interation['schedulable://' . $schedulable['id']] = false; 864 break; 865 866 case 'ADD': 867 break; 868 869 case 'REPLY': 870 if ($schedulable = self::_getSchedulable($uid)) { 871 while ($property = $component->getProperty('attendee', FALSE, TRUE)) 872 if ($pID = self::_getParticipantByMail(str_replace('MAILTO:', '', $property['value']), $schedulable['participants'])) 873 $interation['participant://' . $pID] = array('id' => $pID, 'status' => constant('STATUS_' . strtoupper($property['params']['PARTSTAT']))); 874 875 $interation['schedulable://' . $schedulable['id']]['sequence'] = $schedulable['sequence'] + 1; 876 } 877 break; 878 879 case 'COUNTER': 880 if ($params['acceptedSuggestion'] !== 'false') { 881 882 $schedulable = self::_getSchedulable($uid); 883 $params['calendar'] = self::_existInMyCalendars($schedulable['id'], $params['owner']); 884 885 $interation = self::_makeCOUNTER($schedulable, $component, $params); 886 Config::regSet('noAlarm', FALSE); 887 } else { 888 $response = array(); 889 $response['from'] = $params['from']; 890 $response['type'] = 'suggestionResponse'; 891 $response['status'] = 'DECLINECOUNTER'; 892 $response['schedulable'] = self::_getSchedulable($uid); 893 894 Controller::create(array('concept' => 'notification'), $response); 895 } 896 break; 897 898 case 'DECLINECOUNTER': 899 break; 900 901 default: 902 903 $schedulable = self::_getSchedulable($uid); 904 905 if ($schedulable && ( self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] || $component->getProperty('sequence', false, false) > $schedulable['sequence'])) { //Caso o evento exista 906 $interation = self::_makeVEVENT($schedulable, $component, $params); 907 908 if (!self::_existInMyCalendars($schedulable['id'], $params['owner'])) { 909 $calendarToSchedulable = array(); 910 $calendarToSchedulable['calendar'] = $params['calendar']; 911 $calendarToSchedulable['schedulable'] = $schedulable['id']; 912 $interation['calendarToSchedulable://' . mt_rand() . '(Formatter)'] = $calendarToSchedulable; 913 } 914 } 915 else // Importar evento 916 $interation = self::_makeVEVENT(array(), $component, $params); 917 918 break; 919 } 920 921 $return[] = $interation; 922 break; 923 /***********************************************************************TODO*******************************************************************************/ 924 case 'VTIMEZONE': 925 break; 542 926 } 543 927 } … … 556 940 $interation = array(); 557 941 $uid = $component->getProperty('uid', false, false); //Resgata o uid do componente 558 559 942 switch (strtoupper($component->objName)) { 560 943 case 'VEVENT': … … 583 966 } 584 967 } else { 585 if (self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] || $component->getProperty('sequence', false, false) > $schedulable['sequence']) //Organizador esta requisitando que voc êatualize o evento968 if (self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] || $component->getProperty('sequence', false, false) > $schedulable['sequence']) //Organizador esta requisitando que você atualize o evento 586 969 $interation = ($isOrganizer) ? ICAL_ACTION_ORGANIZER_UPDATE : ICAL_ACTION_UPDATE; 587 970 else … … 649 1032 $return[$uid] = $interation; 650 1033 break; 1034 case 'VTODO': 1035 switch ($method) { 1036 case 'PUBLISH': 1037 $interation = ICAL_ACTION_IMPORT; 1038 break; 1039 1040 case 'REQUEST': 1041 $schedulable = self::_getSchedulable($uid); 1042 1043 if ($schedulable) { //Caso o evento exista 1044 $isOrganizer = false; 1045 $isParticipant = false; 1046 1047 foreach ($schedulable['participants'] as $value) 1048 if ($value['user']['id'] == $params['owner']) { 1049 $isParticipant = true; 1050 if ($value['isOrganizer']) 1051 $isOrganizer = true; 1052 1053 if (!self::_existInMyCalendars($schedulable['id'], $params['owner'])) { 1054 1055 ob_start(); 1056 print_r($schedulable['id']); 1057 print_r( $params['owner']); 1058 $output = ob_get_clean(); 1059 file_put_contents( "/tmp/acoutinho.log", $output , FILE_APPEND); 1060 1061 $interation = ICAL_ACTION_IMPORT; 1062 break; 1063 } 1064 } else { 1065 if (self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] || $component->getProperty('sequence', false, false) > $schedulable['sequence']) //Organizador esta requisitando que você atualize o evento 1066 $interation = ($isOrganizer) ? ICAL_ACTION_ORGANIZER_UPDATE : ICAL_ACTION_UPDATE; 1067 else 1068 $interation = ($isOrganizer) ? ICAL_ACTION_ORGANIZER_NONE : ICAL_ACTION_NONE; 1069 } 1070 if (!$isParticipant){ 1071 $interation = self::_checkParticipantByPermissions($schedulable); 1072 } 1073 }else 1074 $interation = ICAL_ACTION_IMPORT; 1075 break; 1076 1077 case 'REFRESH': 1078 break; 1079 1080 case 'CANCEL': 1081 $interation = ICAL_ACTION_DELETE; 1082 break; 1083 1084 case 'ADD': 1085 break; 1086 1087 case 'REPLY': 1088 $interation = ICAL_ACTION_REPLY; 1089 break; 1090 1091 case 'COUNTER': 1092 $interation = ICAL_ACTION_SUGGESTION; 1093 break; 1094 1095 case 'DECLINECOUNTER': 1096 $interation = ICAL_ACTION_NONE; 1097 break; 1098 1099 default: 1100 $schedulable = self::_getSchedulable($uid); 1101 1102 if ($schedulable && ( self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] || $component->getProperty('sequence', false, false) > $schedulable['sequence'])) //Caso o evento exista 1103 $interation = ICAL_ACTION_UPDATE; 1104 else if ($schedulable) 1105 $interation = ICAL_ACTION_NONE; 1106 else // Importar evento 1107 $interation = ICAL_ACTION_IMPORT; 1108 1109 break; 1110 } 1111 1112 $return[$uid] = $interation; 1113 break; 651 1114 case 'VTIMEZONE': 652 653 654 break; 1115 break; 655 1116 } 656 1117 } … … 690 1151 } 691 1152 1153 public function decodeStatusTodo( $action ) 1154 { 1155 $a = array( 1156 'NEED_ACTION' => STATUS_TODO_NEED_ACTION, 1157 'IN_PROGRESS' => STATUS_TODO_IN_PROGRESS , 1158 'COMPLETED' => STATUS_TODO_COMPLETED , 1159 'CANCELLED' => STATUS_TODO_CANCELLED 1160 ); 1161 1162 return isset($a[$id]) ? $a[$id] : 'STATUS_TODO_NEED_ACTION'; 1163 1164 } 1165 1166 1167 private function _getStatusTodo($id) { 1168 $a = array( 1169 STATUS_TODO_NEED_ACTION => 'NEED_ACTION', 1170 STATUS_TODO_IN_PROGRESS => 'IN_PROGRESS', 1171 STATUS_TODO_COMPLETED => 'COMPLETED', 1172 STATUS_TODO_CANCELLED => 'CANCELLED' 1173 ); 1174 1175 return isset($a[$id]) ? $a[$id] : 'NEED_ACTION'; 1176 } 1177 692 1178 private static function _checkParticipantByPermissions($schedulable) { 693 1179 … … 768 1254 $schedulable['allDay'] = 1; 769 1255 $schedulable['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $schedulable['timezone'], '@' . self::date2timestamp($startTime['value'])) . '000'; 770 } elseif (isset($startTime['params']['TZID']) && !isset($startTime['value']['tz'])) {/* Caso n ão tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */1256 } elseif (isset($startTime['params']['TZID']) && !isset($startTime['value']['tz'])) {/* Caso não tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */ 771 1257 $schedulable['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $startTime['params']['TZID'], '@' . self::date2timestamp($startTime['value'])) . '000'; 772 1258 $schedulable['allDay'] = 0; … … 774 1260 $schedulable['startTime'] = self::date2timestamp($startTime['value']) . '000'; 775 1261 if (strpos($params['prodid'], 'Outlook') !== false) { 776 //Se o ics veio em utc n ão aplicar horario de verão1262 //Se o ics veio em utc não aplicar horario de verão 777 1263 $sTime = new DateTime('@' . (int) ($schedulable['startTime'] / 1000), new DateTimeZone('UTC')); 778 1264 $sTime->setTimezone($objTimezone); 779 if ($sTime->format('I')) //Se o ics veio em utc n ão aplicar horario de verão1265 if ($sTime->format('I')) //Se o ics veio em utc não aplicar horario de verão 780 1266 $schedulable['startTime'] = $schedulable['startTime'] - 3600000; 781 1267 } … … 787 1273 if ($endTime['params']['VALUE'] === 'DATE') 788 1274 $schedulable['endTime'] = self::date2timestamp($endTime['value']) - self::_getTzOffset('UTC', $schedulable['timezone'], '@' . self::date2timestamp($endTime['value'])) . '000'; 789 else if (isset($endTime['params']['TZID']) && !isset($endTime['value']['tz'])) /* Caso n ão tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */1275 else if (isset($endTime['params']['TZID']) && !isset($endTime['value']['tz'])) /* Caso não tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */ 790 1276 $schedulable['endTime'] = self::date2timestamp($endTime['value']) - self::_getTzOffset('UTC', $endTime['params']['TZID'], '@' . self::date2timestamp($endTime['value'])) . '000'; 791 1277 else { 792 1278 $schedulable['endTime'] = self::date2timestamp($endTime['value']) . '000'; 793 1279 if (strpos($params['prodid'], 'Outlook') !== false) { 794 //Se o ics veio em utc n ão aplicar horario de verão1280 //Se o ics veio em utc não aplicar horario de verão 795 1281 $eTime = new DateTime('@' . (int) ($schedulable['endTime'] / 1000), new DateTimeZone('UTC')); 796 1282 $eTime->setTimezone($objTimezone); … … 826 1312 $schedulable['allDay'] = 1; 827 1313 $schedulable['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $schedulable['timezone'], '@' . self::date2timestamp($startTime['value'])) . '000'; 828 } elseif ($tzid && !isset($startTime['value']['tz'])) {/* Caso n ão tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */1314 } elseif ($tzid && !isset($startTime['value']['tz'])) {/* Caso não tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */ 829 1315 $schedulable['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $tzid, '@' . self::date2timestamp($startTime['value'])) . '000'; 830 1316 $schedulable['allDay'] = 0; … … 832 1318 $schedulable['startTime'] = self::date2timestamp($startTime['value']) . '000'; 833 1319 if (strpos($params['prodid'], 'Outlook') !== false) { 834 //Se o ics veio em utc n ão aplicar horario de verão1320 //Se o ics veio em utc não aplicar horario de verão 835 1321 $sTime = new DateTime('@' . (int) ($schedulable['startTime'] / 1000), new DateTimeZone('UTC')); 836 1322 $sTime->setTimezone($objTimezone); 837 if ($sTime->format('I')) //Se o ics veio em utc n ão aplicar horario de verão1323 if ($sTime->format('I')) //Se o ics veio em utc não aplicar horario de verão 838 1324 $schedulable['startTime'] = $schedulable['startTime'] - 3600000; 839 1325 } … … 850 1336 if (isset($endTime['params']['VALUE']) && $endTime['params']['VALUE'] === 'DATE') 851 1337 $schedulable['endTime'] = self::date2timestamp($endTime['value']) - self::_getTzOffset('UTC', $schedulable['timezone'], '@' . self::date2timestamp($endTime['value'])) . '000'; 852 else if ($tzid && !isset($endTime['value']['tz'])) /* Caso n ão tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */1338 else if ($tzid && !isset($endTime['value']['tz'])) /* Caso não tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */ 853 1339 $schedulable['endTime'] = self::date2timestamp($endTime['value']) - self::_getTzOffset('UTC', $tzid, '@' . self::date2timestamp($endTime['value'])) . '000'; 854 1340 else { 855 1341 $schedulable['endTime'] = self::date2timestamp($endTime['value']) . '000'; 856 1342 if (strpos($params['prodid'], 'Outlook') !== false) { 857 //Se o ics veio em utc n ão aplicar horario de verão1343 //Se o ics veio em utc não aplicar horario de verão 858 1344 $eTime = new DateTime('@' . (int) ($schedulable['endTime'] / 1000), new DateTimeZone('UTC')); 859 1345 $eTime->setTimezone($objTimezone); … … 880 1366 $schedulable['class'] = constant(strtoupper('CLASS_' . $class)); 881 1367 else if (!isset($schedulable['class'])) 882 $schedulable['class'] = CLASS_PRIVATE; // padr ão classe private1368 $schedulable['class'] = CLASS_PRIVATE; // padrão classe private 883 1369 884 1370 /* Definindo RRULE */ … … 906 1392 $participantsInEvent = array(); 907 1393 908 //TODO: Participants com delegated n ão estao sendo levados em conta1394 //TODO: Participants com delegated não estao sendo levados em conta 909 1395 while ($property = $component->getProperty('attendee', FALSE, TRUE)) { 910 1396 $participant = array(); … … 923 1409 $participant['isOrganizer'] = '0'; 924 1410 925 /* Verifica se este usuario éum usuario interno do ldap */1411 /* Verifica se este usuario é um usuario interno do ldap */ 926 1412 $intUser = Controller::find(array('concept' => 'user'), array('id', 'isExternal'), array('filter' => array('OR', array('=', 'mail', $mailUser), array('=', 'mailAlternateAddress', $mailUser)))); 927 1413 … … 958 1444 $participant['acl'] = 'rowi'; 959 1445 960 /* Verifica se este usuario éum usuario interno do ldap */1446 /* Verifica se este usuario é um usuario interno do ldap */ 961 1447 $intUser = Controller::find(array('concept' => 'user'), array('id', 'isExternal'), array('filter' => array('OR', array('=', 'mail', $mailUser), array('=', 'mailAlternateAddress', $mailUser)))); 962 1448 … … 980 1466 $interation['participant://' . $participantID] = $participant; 981 1467 $schedulable['participants'][] = $participantID; 982 } else if (!is_array($schedulable['participants']) || count($schedulable['participants']) < 1) {//caso n ão tenha organizador o usuario se torna organizador1468 } else if (!is_array($schedulable['participants']) || count($schedulable['participants']) < 1) {//caso não tenha organizador o usuario se torna organizador 983 1469 $user = Controller::read(array('concept' => 'user', 'id' => $params['owner']), array('mail')); 984 1470 … … 1094 1580 1095 1581 static private function _existInMyCalendars($id, $owner) { 1096 $sig = Controller::find(array('concept' => 'calendarSignature'), array('user', 'calendar', 'isOwner'), array('filter' => array('AND', array('=', ' user', $owner), array('=', 'isOwner', '1'))));1582 $sig = Controller::find(array('concept' => 'calendarSignature'), array('user', 'calendar', 'isOwner'), array('filter' => array('AND', array('=', 'isOwner', '1'), array('=', 'user', $owner)))); 1097 1583 $calendars = array(); 1098 1584 foreach ($sig as $val)
Note: See TracChangeset
for help on using the changeset viewer.