- Timestamp:
- 08/06/12 18:17:24 (12 years ago)
- Location:
- sandbox/2.4.2-expresso1/prototype
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.4.2-expresso1/prototype/modules/calendar/export.php
r5863 r6951 46 46 { 47 47 $event = Controller::read(array('concept' => 'schedulable' , 'id' => $params['event'])); 48 49 50 51 52 53 54 55 56 48 $attachmentRelation = Controller::find( array( 'concept' => 'schedulableToAttachment' ) , false ,array( 'filter' => array('=', 'schedulable' , $event['id']) )); 49 if(is_array($attachmentRelation)){ 50 $attachments = array(); 51 foreach($attachmentRelation as $key => $value) 52 if(isset($value['attachment']) || !!$value['attachment']) 53 $attachments[$key] = $value['attachment']; 54 //Pega os anexos sem source 55 $event['attachments'] = Controller::find( array( 'concept' => 'attachment' ) , false ,array( 'filter' => array('IN', 'id' , $attachments) )); 56 } 57 57 58 58 $repeat = Controller::find( array( 'concept' => 'repeat' ) , false ,array( 'filter' => array('=', 'schedulable' , $event['id']) )); -
sandbox/2.4.2-expresso1/prototype/modules/calendar/js/activity.helpers.js
r6945 r6951 138 138 } ) ), 139 139 title: { 140 text:'Informa ções',140 text:'Informações', 141 141 button: '<a class="button close" href="#">close</a>' 142 142 } … … 206 206 207 207 /** 208 * canDiscard EventDialog deve ser true se não houver alterações no evento208 * canDiscardActivityDialog deve ser true se não houver alterações no evento 209 209 */ 210 canDiscard EventDialog = true;210 canDiscardActivityDialog = true; 211 211 /** 212 * zebraDiscard EventDialog é uma flag indicando que uma janela de confirmação (Zebra_Dialog)213 * j á está aberta na tela, uma vez que não é possivel acessar o evento ESC utilizado para fechá-la212 * zebraDiscardActivityDialog é uma flag indicando que uma janela de confirmação (Zebra_Dialog) 213 * já está aberta na tela, uma vez que não é possivel acessar o evento ESC utilizado para fechá-la 214 214 */ 215 zebraDiscard EventDialog = false;215 zebraDiscardActivityDialog = false; 216 216 217 217 var html = DataLayer.render( path+'templates/activity_add.ejs', { … … 238 238 beforeClose: function(event, ui) { 239 239 240 if (!canDiscard EventDialog && !zebraDiscardEventDialog) {241 zebraDiscard EventDialog = true;240 if (!canDiscardActivityDialog && !zebraDiscardActivityDialog) { 241 zebraDiscardActivityDialog = true; 242 242 window.setTimeout(function() { 243 $.Zebra_Dialog('Suas altera ções na atividade não foram salvas. Deseja descartar as alterações?', {243 $.Zebra_Dialog('Suas alterações na atividade não foram salvas. Deseja descartar as alterações?', { 244 244 'type': 'question', 245 245 'overlay_opacity': '0.5', 246 'buttons': ['Descartar altera ções', 'Continuar editando'],246 'buttons': ['Descartar alterações', 'Continuar editando'], 247 247 'onClose': function(clicked) { 248 if(clicked == 'Descartar altera ções') {249 canDiscard EventDialog = true;248 if(clicked == 'Descartar alterações') { 249 canDiscardActivityDialog = true; 250 250 /** 251 *Remo ção dos anexos do eventos caso seja cancelado a edição251 *Remoção dos anexos do eventos caso seja cancelado a edição 252 252 */ 253 253 DataLayer.rollback(); … … 264 264 UI.dialogs.addActivity.dialog('close'); 265 265 }else{ 266 zebraDiscard EventDialog = false;266 zebraDiscardActivityDialog = false; 267 267 } 268 268 269 269 /** 270 * Uma vez aberta uma janela de confirma ção (Zebra_Dialog), ao fechá-la271 * com ESC, para que o evento ESC n ão seja propagado para fechamento da272 * janela de edi ção de eventos, deve ser setada uma flag indicando que273 * j á existe uma janela de confirmação aberta.270 * Uma vez aberta uma janela de confirmação (Zebra_Dialog), ao fechá-la 271 * com ESC, para que o evento ESC não seja propagado para fechamento da 272 * janela de edição de eventos, deve ser setada uma flag indicando que 273 * já existe uma janela de confirmação aberta. 274 274 */ 275 275 if (!clicked) { 276 276 window.setTimeout(function() { 277 zebraDiscard EventDialog = false;277 zebraDiscardActivityDialog = false; 278 278 }, 200); 279 279 } … … 284 284 } 285 285 //DataLayer.rollback(); 286 return canDiscard EventDialog;286 return canDiscardActivityDialog; 287 287 }, 288 288 dragStart: function(event, ui) { … … 353 353 }); 354 354 355 /*Seleciona a agenda padr ão para visualização/edição de um evento*/355 /*Seleciona a agenda padrão para visualização/edição de um evento*/ 356 356 if(objActivity.id) 357 357 UI.dialogs.addActivity.find('option[value="'+objActivity.group+'"]').attr('selected','selected').trigger('change'); … … 387 387 'type': 'question', 388 388 'overlay_opacity': '0.5', 389 'buttons': ['Sim', 'N ão'],389 'buttons': ['Sim', 'Não'], 390 390 'onClose': function(clicked) { 391 391 if(clicked == 'Sim'){ 392 canDiscard EventDialog = true;392 canDiscardActivityDialog = true; 393 393 /* Remove por filtro */ 394 394 DataLayer.removeFilter('schedulable', {filter: ['AND', ['=', 'id', objActivity.id], ['=', 'group', objActivity.group], ['=','user',(objActivity.me.user ? objActivity.me.user.id : objActivity.me.id)]]}); … … 406 406 407 407 .children(".save").click(function(){ 408 /* Valida ção408 /* Validação 409 409 var msg = false; 410 410 if(msg = validDateEvent()){ … … 413 413 } 414 414 */ 415 canDiscard EventDialog = true;415 canDiscardActivityDialog = true; 416 416 417 417 UI.dialogs.addActivity.children().find('form.form-addactivity').submit(); … … 463 463 var result = DataLayer.get('schedulable:taskSearch', filter, true) 464 464 /** 465 466 465 * TODO: trocar por template 466 */ 467 467 blkAddTask.find('ul.search-result-list').empty().css('overflow', 'hidden'); 468 468 if (!result) { … … 487 487 dueTime: old_item.find('[name="taskDueTime"]').val(), 488 488 allDay: old_item.find('[name="taskAllDay"]').val(), 489 percentage: old_item.find('[name="taskPercentage"]').val() ,489 percentage: old_item.find('[name="taskPercentage"]').val() 490 490 }; 491 491 492 492 tasks.length += 1; 493 494 /*495 newTaskToActivity = DataLayer.put('taskToActivity', {496 owner: User.me.id,497 task: old_item.find('.id').html(),498 activity: 'VER ISSO AQUI'499 });500 */501 //attendees[old_item.find('.id').html()] = old_item.find('.name').html();502 493 503 504 505 494 blkAddTask.find('dd.task-activity-list ul.task-activity-list') 495 .append(DataLayer.render(path+'templates/task_add_itemlist.ejs', [{ 496 idTask: old_item.find('[name="id"]').val(), 506 497 description: old_item.find('.description').html() 507 498 }])) 508 499 .scrollTo('max'); 509 510 callbackTask(); 500 callbackTask(); 511 501 registerStatus(); 512 502 blkAddTask.find('.not-activity').addClass('hidden'); … … 514 504 } 515 505 }); 516 517 } 518 event.preventDefault(); 519 } 520 }); 521 522 /*Carrega as tarefas já existentes em uma atividade*/ 506 } 507 event.preventDefault(); 508 } 509 }); 510 511 /*Carrega as tarefas já existentes em uma atividade*/ 523 512 if(objActivity.tasks.length){ 524 513 tasks = objActivity.tasks; … … 549 538 'type': 'question', 550 539 'overlay_opacity': '0.5', 551 'buttons': ['Sim', 'N ão'],540 'buttons': ['Sim', 'Não'], 552 541 'onClose': function(clicked) { 553 542 if(clicked == 'Sim'){ … … 706 695 }); 707 696 697 UI.dialogs.addActivity.find(':input').change(function(event){ 698 if (event.keyCode != '27' && event.keyCode != '13') 699 canDiscardActivityDialog = false; 700 }).keydown(function(event){ 701 if (event.keyCode != '27' && event.keyCode != '13') 702 canDiscardActivityDialog = false; 703 }); 704 708 705 UI.dialogs.addActivity.dialog('open'); 709 706 } -
sandbox/2.4.2-expresso1/prototype/modules/calendar/js/calendar.codecs.js
r6945 r6951 946 946 startHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date( parseInt(task.startTime)), task.timezone, task.calendar, obj.DayLigth, 'startTime'), User.preferences.hourFormat), 947 947 endDate: new Date( parseInt(task.endTime) - (!!parseInt(task.allDay) ? 86400000 : 0) ).setTimezoneOffset( Timezone.timezone( task.timezone ) ).toString( User.preferences.dateFormat ), 948 endHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date(parseInt(task.endTime)), task.timezone, obj.calendar, obj.DayLigth, 'endTime'), User.preferences.hourFormat) ,948 endHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date(parseInt(task.endTime)), task.timezone, obj.calendar, obj.DayLigth, 'endTime'), User.preferences.hourFormat) 949 949 } 950 950 … … 1005 1005 }) 1006 1006 }; 1007 }) ,1007 }) 1008 1008 1009 1009 }; -
sandbox/2.4.2-expresso1/prototype/modules/calendar/js/helpers.js
r6945 r6951 2741 2741 } 2742 2742 2743 function show_modal_import_export(tab, calendarId ){2743 function show_modal_import_export(tab, calendarId, typeView){ 2744 2744 $('.qtip.qtip-blue').remove(); 2745 2745 DataLayer.render( 'templates/import_export.ejs', { 2746 calendars: Calendar.calendars,2746 calendars: typeView == 0 ? Calendar.calendars : Calendar.groups, 2747 2747 owner: User.me.id 2748 2748 }, function( html ){ … … 2750 2750 if (!UI.dialogs.importCalendar) { 2751 2751 UI.dialogs.importCalendar = jQuery('#div-import-export-calendar') 2752 .append('<div title="Importar e Exportar Eventos" class="import-export import-export-win active"> <div>')2752 .append('<div title="Importar e Exportar "' + (typeView == 0 ? 'Eventos' : 'Tarefas') + '" class="import-export import-export-win active"> <div>') 2753 2753 .find('.import-export-win.active').html(html).dialog({ 2754 2754 resizable: false, -
sandbox/2.4.2-expresso1/prototype/modules/calendar/js/init.js
r6945 r6951 239 239 startTime: new Date().toString('yyyy-MM-dd 00:00:00'), 240 240 endTime: new Date().toString('yyyy-MM-dd 00:00:00'), 241 allDay: '1' 241 allDay: '1', 242 participants: 243 [{ 244 user: User.me.id, 245 isOrganizer: 1, 246 acl: 'row' 247 }] 242 248 }); 243 249 -
sandbox/2.4.2-expresso1/prototype/modules/calendar/js/task.helpers.js
r6946 r6951 804 804 }); 805 805 806 UI.dialogs.addTask.find(':input').change(function(event){ 807 if (event.keyCode != '27' && event.keyCode != '13') 808 canDiscardTaskDialog = false; 809 }).keydown(function(event){ 810 if (event.keyCode != '27' && event.keyCode != '13') 811 canDiscardTaskDialog = false; 812 }); 806 813 807 814 UI.dialogs.addTask.dialog('open'); -
sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/calendar_list.ejs
r6820 r6951 34 34 <ul> 35 35 <li><a href="#" onclick="add_tab_configure_calendar(<%= signatures['taskGroup'][i].calendar.id%>, 1);">Configurações</a></li> 36 <li><a href="#" onclick="remove_calendar(1);">Remover Grupo</a></li> 36 <li><a href="#" onclick="show_modal_import_export(0,<%= signatures['taskGroup'][i].calendar.id%>, 1);">Importar</a></li> 37 <li><a href="#" onclick="show_modal_import_export(1,<%= signatures['taskGroup'][i].calendar.id%>, 1);">Exportar</a></li> 38 <%if(signatures['taskGroup'][i].type == '0'){%> 39 <li><a href="#" onclick="remove_calendar(1);">Remover Grupo</a></li> 40 <%}%> 37 41 </ul> 38 42 … … 65 69 <ul> 66 70 <li><a href="#" onclick="add_tab_configure_calendar(<%= signatures['calendar'][i].calendar.id%>, 0);">Configurações</a></li> 67 <li><a href="#" onclick="show_modal_import_export(0, <%= signatures['calendar'][i].calendar.id%> );">Importar</a></li>68 <li><a href="#" onclick="show_modal_import_export(1, <%= signatures['calendar'][i].calendar.id%> );">Exportar</a></li>71 <li><a href="#" onclick="show_modal_import_export(0, <%= signatures['calendar'][i].calendar.id%>, 0);">Importar</a></li> 72 <li><a href="#" onclick="show_modal_import_export(1, <%= signatures['calendar'][i].calendar.id%>, 0);">Exportar</a></li> 69 73 <li><a href="#" onclick="show_modal_shared(<%= signatures['calendar'][i].calendar.id%>);">Compartilhar agenda</a></li> 70 74 <li><a href="#" onclick="remove_calendar(0);">Remover agenda</a></li> … … 95 99 <ul> 96 100 <li><a href="#" onclick="add_tab_configure_calendar(<%= signatures['sharedCalendar'][i].calendar.id %>, 0);">Configurações</a></li> 97 <li><a href="#" onclick="show_modal_import_export(0, <%= signatures['sharedCalendar'][i].calendar.id %>);">Importar</a></li>98 <li><a href="#" onclick="show_modal_import_export(1, <%= signatures['sharedCalendar'][i].calendar.id %>);">Exportar</a></li>101 <li><a href="#" onclick="show_modal_import_export(0, <%= signatures['sharedCalendar'][i].calendar.id%>, 0);">Importar</a></li> 102 <li><a href="#" onclick="show_modal_import_export(1, <%= signatures['sharedCalendar'][i].calendar.id%>, 0);">Exportar</a></li> 99 103 <%if(!signatures['sharedCalendar'][i].permission.acl['required']){%> 100 104 <li><a href="#" onclick="cancel_signatures['sharedCalendar'](<%= signatures['sharedCalendar'][i].id %>);">Cancelar assinatura</a></li> -
sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/task_add.ejs
r6946 r6951 237 237 </div> 238 238 <form action="../prototype/modules/calendar/export.php" method="GET" class="form-export content"> 239 <input type="hidden" class="id-task" name=" task" value="<%= data.task.id %>"/>239 <input type="hidden" class="id-task" name="event" value="<%= data.task.id %>"/> 240 240 </form> 241 241 <!-- <div id="calendar_addtask_addattendee"></div>--> -
sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/task_add_itemlist.ejs
r6945 r6951 1 <%console.log(data)%>2 1 <li class="task"> 3 4 5 <a class="button info activity-options-button-edit new ui-icon-notice">Informações</a>6 7 8 2 <div style="overflow:hidden; width:100%; display:table;"> 3 <div class="activity-options" style="float: right; margin: 0 10px 0 0;"> 4 <a class="button info activity-options-button-edit new ui-icon-notice">Informaçõess</a> 5 <a class="button close new">Remover</a> 6 </div> 7 <input class="new" type="checkbox" value="<%= data[0].idTask %>"> 9 8 <input type="hidden" name="idtask[]" value="<%= data[0].idTask %>"> 10 11 9 <input type="hidden" name="idTaskToActivity[]" value="<%= data[0].idTaskToActivity %>"> 10 <label title="<%= data[0].description %>" class="name"><%= data[0].description %></label> 12 11 </li> -
sandbox/2.4.2-expresso1/prototype/services/iCal.php
r6891 r6951 184 184 185 185 } 186 187 186 188 187 if (isset($v['participants']) && is_array($v['participants']) && count($v['participants']) > 0) … … 617 616 switch ($method) { 618 617 case 'PUBLISH': 619 //Caso a tarefa n ão exista o mesmo cria um novo evento, se jáexistir o mesmo referencia o evento com agenda618 //Caso a tarefa não exista o mesmo cria um novo evento, se já existir o mesmo referencia o evento com agenda 620 619 if (!$schedulable = self::_getSchedulable($uid)) 621 $interation = self::_makeV EVENT($schedulable, $component, $params);620 $interation = self::_makeVTODO($schedulable, $component, $params); 622 621 else{ 623 622 $links = Controller::read(array('concept' => 'calendarToSchedulable'), array('id'), array('filter' => … … 1291 1290 } 1292 1291 1293 static private function _makeVEVENT($schedulable, $component, $params) {1292 static private function _makeVEVENT($schedulable, $component, $params) { 1294 1293 $interation = array(); 1295 1294 $eventID = isset($schedulable['id']) ? $schedulable['id'] : mt_rand() . '(Formatter)'; … … 1312 1311 $schedulable['allDay'] = 1; 1313 1312 $schedulable['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $schedulable['timezone'], '@' . self::date2timestamp($startTime['value'])) . '000'; 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 */1313 } 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 */ 1315 1314 $schedulable['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $tzid, '@' . self::date2timestamp($startTime['value'])) . '000'; 1316 1315 $schedulable['allDay'] = 0; … … 1392 1391 $participantsInEvent = array(); 1393 1392 1394 //TODO: Participants com delegated n ão estao sendo levados em conta1393 //TODO: Participants com delegated nao estao sendo levados em conta 1395 1394 while ($property = $component->getProperty('attendee', FALSE, TRUE)) { 1396 1395 $participant = array(); … … 1570 1569 1571 1570 $interation['schedulable://' . $eventID] = $schedulable; 1571 1572 return $interation; 1573 } 1574 1575 static private function _makeVTODO($schedulable, $component, $params) { 1576 $interation = array(); 1577 $todoID = isset($schedulable['id']) ? $schedulable['id'] : mt_rand() . '(Formatter)'; 1578 1579 /* Data de Inicio */ 1580 $startTime = $component->getProperty('dtstart', false, true); 1581 1582 $tzid = (isset($startTime['params']['TZID']) ? $startTime['params']['TZID'] : $params['X-WR-TIMEZONE']); 1583 1584 /* Tiem zone do evento */ 1585 if ($tzid){ 1586 $tzid = self::nomalizeTZID($tzid); 1587 $schedulable['timezone'] = $tzid; 1588 }else 1589 $schedulable['timezone'] = isset($params['calendar_timezone']) ? $params['calendar_timezone'] : 'America/Sao_Paulo'; 1590 1591 $objTimezone = new DateTimeZone($schedulable['timezone']); 1592 1593 if (isset($startTime['params']['VALUE']) && $startTime['params']['VALUE'] === 'DATE' && isset($params['calendar_timezone'])) { 1594 $schedulable['allDay'] = 1; 1595 $schedulable['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $schedulable['timezone'], '@' . self::date2timestamp($startTime['value'])) . '000'; 1596 } 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 */ 1597 $schedulable['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $tzid, '@' . self::date2timestamp($startTime['value'])) . '000'; 1598 $schedulable['allDay'] = 0; 1599 } else { 1600 $schedulable['startTime'] = self::date2timestamp($startTime['value']) . '000'; 1601 if (strpos($params['prodid'], 'Outlook') !== false) { 1602 //Se o ics veio em utc não aplicar horario de verão 1603 $sTime = new DateTime('@' . (int) ($schedulable['startTime'] / 1000), new DateTimeZone('UTC')); 1604 $sTime->setTimezone($objTimezone); 1605 if ($sTime->format('I')) //Se o ics veio em utc não aplicar horario de verão 1606 $schedulable['startTime'] = $schedulable['startTime'] - 3600000; 1607 } 1608 } 1609 1610 /* Data de Termino */ 1611 $endTime = $component->getProperty('dtend', false, true); 1612 1613 $tzid = isset($endTime['params']['TZID']) ? $endTime['params']['TZID'] : $params['X-WR-TIMEZONE']; 1614 1615 if($tzid) 1616 $tzid = self::nomalizeTZID($tzid); 1617 1618 if (isset($endTime['params']['VALUE']) && $endTime['params']['VALUE'] === 'DATE') 1619 $schedulable['endTime'] = self::date2timestamp($endTime['value']) - self::_getTzOffset('UTC', $schedulable['timezone'], '@' . self::date2timestamp($endTime['value'])) . '000'; 1620 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 */ 1621 $schedulable['endTime'] = self::date2timestamp($endTime['value']) - self::_getTzOffset('UTC', $tzid, '@' . self::date2timestamp($endTime['value'])) . '000'; 1622 else { 1623 $schedulable['endTime'] = self::date2timestamp($endTime['value']) . '000'; 1624 if (strpos($params['prodid'], 'Outlook') !== false) { 1625 //Se o ics veio em utc não aplicar horario de verão 1626 $eTime = new DateTime('@' . (int) ($schedulable['endTime'] / 1000), new DateTimeZone('UTC')); 1627 $eTime->setTimezone($objTimezone); 1628 if ($eTime->format('I')) 1629 $schedulable['endTime'] = $schedulable['endTime'] - 3600000; 1630 } 1631 } 1632 1633 $schedulable['type'] = '2'; //type schedulable 1634 $schedulable['summary'] = mb_convert_encoding($component->getProperty('summary', false, false), 'ISO-8859-1', 'UTF-8,ISO-8859-1'); 1635 1636 /* Definindo Description */ 1637 if ($desc = $component->getProperty('description', false, false)) 1638 $schedulable['description'] = mb_convert_encoding(str_ireplace(array('\n', '\t'), array("\n", "\t"), $desc), 'ISO-8859-1', 'UTF-8,ISO-8859-1'); 1639 1640 /* Definindo Class */ 1641 $class = $component->getProperty('class', false, false); 1642 if ($class && defined(constant(strtoupper('CLASS_' . $class)))) 1643 $schedulable['class'] = constant(strtoupper('CLASS_' . $class)); 1644 else if (!isset($schedulable['class'])) 1645 $schedulable['class'] = CLASS_PRIVATE; // padrão classe private 1646 1647 $schedulable['calendar'] = $params['calendar']; 1648 1649 $participantsInTodo = array(); 1650 1651 //TODO: Participants com delegated nao estao sendo levados em conta 1652 while ($property = $component->getProperty('attendee', FALSE, TRUE)) { 1653 $participant = array(); 1654 1655 $mailUser = trim(str_replace('MAILTO:', '', $property['value'])); 1656 1657 $participantID = ($tpID = self::_getParticipantByMail($mailUser, $schedulable['participants'])) ? $tpID : mt_rand() . '2(Formatter)'; 1658 $participant['schedulable'] = $eventID; 1659 1660 if (isset($params['status']) && $mailUser == Config::me('mail')) 1661 $participant['status'] = $params['status']; 1662 else 1663 $participant['status'] = (isset($property['params']['PARTSTAT']) && constant('STATUS_' . $property['params']['PARTSTAT']) !== null ) ? constant('STATUS_' . $property['params']['PARTSTAT']) : STATUS_UNANSWERED; 1664 1665 1666 $participant['isOrganizer'] = '0'; 1667 1668 /* Verifica se este usuario é um usuario interno do ldap */ 1669 $intUser = Controller::find(array('concept' => 'user'), array('id', 'isExternal'), array('filter' => array('OR', array('=', 'mail', $mailUser), array('=', 'mailAlternateAddress', $mailUser)))); 1670 1671 $user = null; 1672 if ($intUser && count($intUser) > 0) { 1673 $participant['isExternal'] = isset($intUser[0]['isExternal']) ? $intUser[0]['isExternal'] : 0; 1674 $participant['user'] = $intUser[0]['id']; 1675 } else { 1676 $participant['isExternal'] = 1; 1677 /* Gera um randon id para o contexto formater */ 1678 $userID = mt_rand() . '4(Formatter)'; 1679 1680 $user['mail'] = $mailUser; 1681 $user['isExternal'] = '1'; 1682 $user['name'] = ( isset($property['params']['CN']) ) ? $property['params']['CN'] : ''; 1683 $user['participants'] = array($participantID); 1684 $participant['user'] = $userID; 1685 $interation['user://' . $userID] = $user; 1686 } 1687 1688 $interation['participant://' . $participantID] = $participant; 1689 $schedulable['participants'][] = $participantID; 1690 }; 1691 1692 if ($property = $component->getProperty('organizer', FALSE, TRUE)) { 1693 $participant = array(); 1694 $mailUser = trim(str_replace('MAILTO:', '', $property['value'])); 1695 1696 $participantID = mt_rand() . '2(Formatter)'; 1697 1698 $participant['schedulable'] = $eventID; 1699 $participant['status'] = (isset($property['params']['PARTSTAT']) && constant('STATUS_' . $property['params']['PARTSTAT']) !== null ) ? constant('STATUS_' . $property['params']['PARTSTAT']) : STATUS_UNANSWERED; 1700 $participant['isOrganizer'] = '1'; 1701 $participant['acl'] = 'rowi'; 1702 1703 /* Verifica se este usuario é um usuario interno do ldap */ 1704 $intUser = Controller::find(array('concept' => 'user'), array('id', 'isExternal'), array('filter' => array('OR', array('=', 'mail', $mailUser), array('=', 'mailAlternateAddress', $mailUser)))); 1705 1706 $user = null; 1707 if ($intUser && count($intUser) > 0) { 1708 $participant['isExternal'] = isset($intUser[0]['isExternal']) ? $intUser[0]['isExternal'] : 0; 1709 $participant['user'] = $intUser[0]['id']; 1710 } else { 1711 $participant['isExternal'] = 1; 1712 /* Gera um randon id para o contexto formater */ 1713 $userID = mt_rand() . '4(Formatter)'; 1714 1715 $user['mail'] = $mailUser; 1716 $user['name'] = ( isset($property['params']['CN']) ) ? $property['params']['CN'] : ''; 1717 $user['participants'] = array($participantID); 1718 $user['isExternal'] = '1'; 1719 $participant['user'] = $userID; 1720 $interation['user://' . $userID] = $user; 1721 } 1722 1723 $interation['participant://' . $participantID] = $participant; 1724 $schedulable['participants'][] = $participantID; 1725 } else if (!isset($schedulable['participants']) || !is_array($schedulable['participants']) || count($schedulable['participants']) < 1) {//caso não tenha organizador o usuario se torna organizador 1726 $user = Controller::read(array('concept' => 'user', 'id' => $params['owner']), array('mail')); 1727 1728 if (!self::_getParticipantByMail($user['mail'], $schedulable['participants'])) { 1729 $participantID = mt_rand() . '2(Formatter)'; 1730 1731 $participant['schedulable'] = $todoID; 1732 $participant['status'] = STATUS_CONFIRMED; 1733 $participant['isOrganizer'] = '1'; 1734 $participant['acl'] = 'rowi'; 1735 $participant['isExternal'] = 0; 1736 $participant['user'] = $params['owner']; 1737 $interation['participant://' . $participantID] = $participant; 1738 $schedulable['participants'][] = $participantID; 1739 } 1740 } 1741 1742 $alarms = array(); 1743 1744 /* Definindo ALARMES */ 1745 while ($alarmComp = $component->getComponent('valarm')) 1746 { 1747 $alarm = array(); 1748 $alarmID = mt_rand() . '6(Formatter)'; 1749 $action = $alarmComp->getProperty('action', false, true); 1750 $trygger = $alarmComp->getProperty('trigger', false, true); 1751 $alarm['type'] = self::decodeAlarmAction($action['value']); 1752 1753 if(isset($trygger['value']['day'])) 1754 { 1755 $alarm['time'] = $trygger['value']['day']; 1756 $alarm['unit'] = 'd'; 1757 } 1758 else if(isset($trygger['value']['hour'])) 1759 { 1760 $alarm['time'] = $trygger['value']['hour']; 1761 $alarm['unit'] = 'h'; 1762 } 1763 else if(isset($trygger['value']['min'])) 1764 { 1765 $alarm['time'] = $trygger['value']['min']; 1766 $alarm['unit'] = 'm'; 1767 } 1768 1769 foreach ($interation as $iint => &$vint) 1770 { 1771 if(isset($vint['user']) && $vint['user'] == Config::me('uidNumber')) 1772 { 1773 $alarm['participant'] = str_replace('participant://', '', $iint); 1774 $vint['alarms'][] = $alarmID; 1775 } 1776 } 1777 $alarm['schedulable'] = $eventID; 1778 1779 $interation['alarm://' . $alarmID ] = $alarm; 1780 1781 } 1782 1783 1784 /* Definindo DTSTAMP */ 1785 if ($dtstamp = self::_getTime($component, 'dtstamp')) 1786 $schedulable['dtstamp'] = $dtstamp; 1787 1788 /* Definindo TRANSP */ 1789 if (($tranp = $component->getProperty('transp', false, true)) && $tranp && is_string($tranp) && strtoupper($tranp) == 'OPAQUE') 1790 $schedulable['transparent'] = 1; 1791 1792 /* Definindo last_update */ 1793 if ($lastUpdate = self::_getTime($component, 'LAST-MODIFIED')) 1794 $schedulable['lastUpdate'] = $lastUpdate; 1795 1796 1797 if ($sequence = $component->getProperty('SEQUENCE', false, false)) 1798 $schedulable['sequence'] = $sequence; 1799 1800 if ($uid = $component->getProperty('uid', false, false)) 1801 ; 1802 $schedulable['uid'] = $uid; 1803 1804 while ($attach = $component->getProperty('ATTACH', FALSE, TRUE)) { 1805 1806 $attachCurrent = array('name' => $attach['params']['X-FILENAME'], 1807 'size' => strlen($attach['value']), 1808 'type' => self::_getContentType($attach['params']['X-FILENAME']) 1809 ); 1810 1811 $ids = Controller::find(array('concept' => 'attachment'), array('id'), array('filter' => array('AND', array('=', 'name', $attachCurrent['name']), array('=', 'size', $attachCurrent['size']), array('=', 'type', $attachCurrent['type'])))); 1812 1813 if (!is_array($ids)) { 1814 $attachCurrent['source'] = $attach['value']; 1815 //insere o anexo no banco e pega id para colcar no relacionamento 1816 $idAttachment = Controller::create(array('concept' => 'attachment'), $attachCurrent); 1817 }else 1818 $idAttachment = array('id' => $ids[0]['id']); 1819 1820 $calendarToAttachmentId = mt_rand() . '2(Formatter)'; 1821 $calendarToAttachment['attachment'] = $idAttachment['id']; 1822 $calendarToAttachment['schedulable'] = $eventID; 1823 $interation['schedulableToAttachment://' . $calendarToAttachmentId] = $calendarToAttachment; 1824 1825 $schedulable['attachments'][] = $calendarToAttachmentId; 1826 } 1827 1828 $interation['schedulable://' . $todoID] = $schedulable; 1572 1829 1573 1830 return $interation;
Note: See TracChangeset
for help on using the changeset viewer.