Changeset 5947
- Timestamp:
- 04/13/12 17:25:00 (12 years ago)
- Location:
- trunk/prototype
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/prototype/modules/calendar/interceptors/DBMapping.php
r5907 r5947 659 659 } 660 660 //TODO - Padronizar retorno do deepness 661 //if(isset($v['user']))662 //$result[$i]['user'] = Controller::read( array( 'concept' => 'user' , 'id' => $v['user']), false, false);661 if(isset($v['user'])) 662 $result[$i]['user'] = Controller::read( array( 'concept' => 'user' , 'id' => $v['user']), false, false); 663 663 } 664 664 } … … 815 815 //Caso uma busca não retorne nenhum resultado e foi buscado pelas assinaturas do usuario logado apenas 816 816 $isValidSignature = false; 817 817 818 818 //Veirifica pois o usuário pode ter varias assinaturas mas não ser dona de nenhuma 819 819 if(count($result) > 0){ … … 849 849 'timezone' => isset($v->timezone) ? $v->timezone : (date_default_timezone_get()) ? date_default_timezone_get() : 'America/Sao_Paulo', 850 850 'dtstamp' => time().'000', 851 'location' => $urlA[ (count($urlA)- 2) ]851 'location' => $urlA[ (count($urlA)-3) ].'/'.$urlA[ (count($urlA)-2) ] 852 852 ); 853 853 -
trunk/prototype/modules/calendar/interceptors/Notifications.php
r5804 r5947 9 9 10 10 public function formatNotification(&$uri , &$params , &$data , $original){ 11 12 13 14 15 16 17 18 11 switch ($params['type']) { 12 case 'suggestion': 13 self::formatSuggestion($params); 14 break; 15 case 'suggestionResponse': 16 self::formatSuggestionResponse($params); 17 break; 18 } 19 19 } 20 20 … … 78 78 $organizer = isset( $organizers[$pCreated['schedulable']] ) ? $organizers[ $pCreated['schedulable'] ] : self::getOrganizer( $pCreated['schedulable'] ); 79 79 80 81 82 83 80 if($pCreated['delegatedFrom'] != 0){ 81 self::participantDelegated( $pCreated , $schedulable , $organizer); 82 continue; 83 } 84 84 85 85 switch ($pCreated['status']) … … 89 89 break; 90 90 case STATUS_UNANSWERED: 91 self::participantCreated( $pCreated['id'] , $schedulable );91 self::participantCreated( $pCreated['id'] , $schedulable, false, false, $organizer ); 92 92 break; 93 93 } … … 108 108 109 109 if($pUpdated['delegatedFrom'] != 0){ 110 110 self::participantDelegatedStatusChange( $pUpdated , $schedulable , $organizer , $pUpdated['status'] ); 111 111 }else if( $pUpdated['status'] != STATUS_UNANSWERED && $pUpdated['status'] != STATUS_DELEGATED) 112 112 self::participantStatusChange( $pUpdated['id'] , $schedulable , $organizer , $pUpdated['status'] ); 113 113 } 114 114 } … … 117 117 public function formatSuggestion(&$params){ 118 118 119 120 121 119 $schedulable = Controller::read( array( 'concept' => 'schedulable' , 'id' => $params['schedulable'] ) , null , array('deepness' => '2') ) ; 120 121 foreach ($schedulable['participants'] as $i => $v) //salva em $organizer as informações do organizador 122 122 if(($v['isOrganizer'] === '1') && ($organizer = $v) ) break; 123 123 … … 227 227 } 228 228 229 229 /** 230 230 * Monta o email de resposta que sera enviado ao delegatedFrom 231 231 * … … 239 239 public static function participantDelegatedStatusChange( &$partID , &$schedulable, $organizer, &$type = false){ 240 240 241 242 243 244 245 246 241 $delegatedParams = array(); 242 243 $delegated = self::_getAttendeeById($partID['id'], $schedulable); 244 $delegatedParams['delegated'] = $delegated['user']['uid']; 245 246 switch($partID['status']){ 247 247 case STATUS_ACCEPTED: 248 248 $delegatedParams['status'] = 'aceitou'; … … 254 254 $delegatedParams['status'] = 'rejeitou'; 255 255 break; 256 257 256 case STATUS_DELEGATED: 257 $delegatedParams['status'] = 'delegou para um novo participante'; 258 258 break; 259 259 } 260 261 262 263 264 265 266 267 268 260 //notifica o organizador a resposta do delegado 261 self::participantStatusChange( $partID['delegatedFrom'] , $schedulable , $organizer , $type, $delegatedParams ); 262 263 $method = 'REQUEST'; 264 $notificationType = 'Resposta Delegação'; 265 $part = 'attendees'; 266 self::mountStruture($partID['delegatedFrom'], $schedulable, $type , $data, $subject, $ical, $part, $method, $notificationType ); 267 268 $data = array_merge($data, $delegatedParams); 269 269 270 270 self::sendMail($data, $ical , $part['user']['mail'] , $subject , 'notify_response_delegated_status_body'); … … 305 305 $temp = $part; 306 306 $part = false; 307 307 308 switch($temp){ 308 309 case 'attendees': … … 352 353 * @access public 353 354 */ 354 public static function participantCreated( &$partID , &$schedulable, $type = false, $delegatedParams = false )355 public static function participantCreated( &$partID , &$schedulable, $type = false, $delegatedParams = false, $organizer = false) 355 356 { 356 357 358 359 360 361 362 363 364 self::sendMail($data, $ical , $part['user']['mail'] , $subject , !$delegatedParams ? 'notify_create_body' : 'notify_create_delegated_body');357 $method = 'REQUEST'; 358 $notificationType = 'Convite de Calendario'; 359 $part = 'attendees'; 360 self::mountStruture($partID, $schedulable, $type , $data, $subject, $ical, $part, $method, $notificationType, true); 361 362 if($delegatedParams) 363 $data = array_merge($data, $delegatedParams); 364 365 self::sendMail($data, $ical , $part['user']['mail'] , $subject , !$delegatedParams ? 'notify_create_body' : 'notify_create_delegated_body', $organizer ); 365 366 366 367 } … … 379 380 { 380 381 $method = 'REPLY'; 381 382 383 384 385 386 387 388 389 382 $notificationType = 'Convite Aceito'; 383 $part = 'me'; 384 385 self::mountStruture($partID, $schedulable, $type , $data, $subject, $ical, $part, $method, $notificationType, true ); 386 387 if($delegatedParams){ 388 $data = array_merge($data, $delegatedParams); 389 $tplDelegated = 'notify_delegated_status_body'; 390 } 390 391 391 392 switch($type) … … 403 404 $subject['notificationType'] = 'Convite rejeitado'; 404 405 break; 405 406 407 406 case STATUS_DELEGATED: 407 if($delegatedParams) 408 $data = array_merge($data, $delegatedParams); 408 409 $tpl = 'notify_delegated_body'; 409 410 $subject['notificationType'] = 'Convite delegado'; … … 412 413 } 413 414 414 self::sendMail($data, $ical , $organizer['user']['mail'] , $subject , $tpl );415 self::sendMail($data, $ical , $organizer['user']['mail'] , $subject , $tpl, false); 415 416 } 416 417 … … 425 426 * @access public 426 427 */ 427 private static function sendMail(&$data , &$ical , $to , &$subject , $template )428 private static function sendMail(&$data , &$ical , $to , &$subject , $template, $from = false ) 428 429 { 429 430 $ical2 = $ical; … … 435 436 $mail['body'] = parseTPL::load_tpl( $data ,ROOTPATH.'/modules/calendar/templates/'.$template.'.tpl'); 436 437 $mail['subject'] = parseTPL::load_tpl( $subject ,ROOTPATH.'/modules/calendar/templates/notify_subject.tpl');; 437 $mail['from'] = '"'.Config::me('cn').'" <'.Config::me('mail').'>';438 $mail['from'] = $from ? ('"'.$from['user']['name'].'" <'.$from['user']['mail'].'>') : ('"'.Config::me('cn').'" <'.Config::me('mail').'>'); 438 439 $mail['to'] = $to; 439 440 Controller::create( array( 'service' => 'SMTP' ), $mail ); … … 456 457 if((Config::regGet('noAlarm') === false) && (self::futureEvent( $schedulable['startTime'] , $schedulable['rangeEnd']))) 457 458 { 458 459 460 461 459 $method = 'CANCEL'; 460 $notificationType = 'Cancelamento de Calendario'; 461 $part = 'othersAttendees'; 462 self::mountStruture($uri['id'], $schedulable, false , $data, $subject, $ical, $part, $method, $notificationType ); 462 463 463 464 464 if(count($part) > 0) 465 self::sendMail($data, $ical , implode(',' , $part) ,$subject, 'notify_cancel_body'); 465 466 } 466 467 } … … 484 485 if((Config::regGet('noAlarm') === false) && (self::futureEvent( $schedulable['startTime'] , $schedulable['rangeEnd']))) 485 486 { 486 487 488 489 490 491 487 $method = 'CANCEL'; 488 $notificationType = 'Cancelamento de Calendario'; 489 $part = 'others'; 490 self::mountStruture(false, $schedulable, false , $data, $subject, $ical, $part, $method, $notificationType ); 491 492 self::sendMail($data, $ical , $participant['user']['mail'] , $subject , 'notify_cancel_body'); 492 493 } 493 494 } … … 518 519 if ( ($alt === true) && (Config::regGet('noAlarm') === false) && (self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'])) ) 519 520 { 520 521 522 523 521 $method = 'REQUEST'; 522 $notificationType = 'Modificação de Calendario'; 523 $part = 'othersAttendees'; 524 self::mountStruture($partID, $schedulable, $type , $data, $subject, $ical, $part, $method, $notificationType); 524 525 525 526 if ( isset($part) && count($part) > 0) -
trunk/prototype/modules/calendar/js/calendar.codecs.js
r5938 r5947 468 468 469 469 var pref = User.preferences; 470 471 var Owner = decodeOwnerCalendar(evtObj.calendar); 470 472 471 473 var res = $.map(evtObj, function( form ){ … … 476 478 participants : $.map(form.attendee, function( attendee, i ){ 477 479 if(isNaN(attendee)){ 478 479 480 481 482 483 484 485 480 return{ 481 id: attendee, 482 acl: form.attendeeAcl[i], 483 delegatedFrom: !!form.delegatedFrom[i] ? form.delegatedFrom[i] : 0, 484 isOrganizer: (form.attendee_organizer == attendee ? 1 : 0 ), 485 isExternal: !!parseInt(form.attendeeType[i]) ? 1 : 0, 486 acl: form.attendeeAcl[i].replace('o', '') 487 }; 486 488 }else{ 487 if(DataLayer.get('participant', attendee).user == User.me.id){489 if(DataLayer.get('participant', attendee).user == Owner.id){ 488 490 var me = { 489 user: User.me.id,490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 491 user: User.id, 492 status: form.status, 493 id: attendee, 494 isOrganizer: 0, 495 receiveNotification : (!!form.receiveNotification ? 1 : 0), 496 alarms: typeof(form.alarmTime) != 'undefined' ? 497 $.map( form.alarmTime || [], function( alarmTime, i ){ 498 499 if( alarmTime === "" ) 500 return( null ); 501 502 return !!form.alarmId[i] ? 503 { type: form.alarmType[i], unit: form.alarmUnit[i], time: form.alarmTime[i], id: form.alarmId[i] } : 504 { type: form.alarmType[i],unit: form.alarmUnit[i], time: form.alarmTime[i] }; 505 }) : [] 506 }; 505 507 506 508 if(form.startDate){ … … 509 511 510 512 DataLayer.put('notification', { 511 512 513 514 515 516 513 participant: me.id, 514 type: 'suggestion', 515 startTime: Date.parseExact(form.startDate + (!!form.allDay ? " 00:00": " "+$.trim(form.startHour)) , formatString ).toString('yyyy-MM-dd HH:mm:00'), 516 endTime: Date.parseExact(form.endDate + ( !!form.allDay ? " 00:00": " "+$.trim(form.endHour)), formatString ).toString('yyyy-MM-dd HH:mm:00'), 517 allDay: ( !!form.allDay ? 1 : 0 ), 518 schedulable: form.idEvent 517 519 }); 518 520 … … 547 549 if(!(typeof(objEvent) == 'object')) 548 550 return (null); 549 550 var participantInfo = {}, delegatedFrom = {}, me = DataLayer.copy(User.me); 551 552 var Owner = decodeOwnerCalendar(objEvent.calendar); 553 554 var participantInfo = {}, delegatedFrom = {}, me = DataLayer.copy( Owner ); 551 555 552 556 var constantAcl = function(acl){ 553 554 555 556 557 557 var returns = {}; 558 for (var i in constantsParticipant){ 559 returns[constantsParticipant[i]] = acl.indexOf(i) >= 0 ? true : false 560 } 561 return returns; 558 562 }; 559 563 560 564 return { 561 565 "class": objEvent["class"], … … 575 579 endHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date(parseInt(objEvent.endTime)), objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'endTime'), User.preferences.hourFormat), 576 580 allDay: !!parseInt( objEvent.allDay ), 577 581 attachments: $.map(objEvent.attachments || [], function( attachment, i ){ 578 582 var attach = DataLayer.get('schedulableToAttachment', attachment, false); 579 583 var ext = attach.name.split('.'); … … 583 587 }), 584 588 attendee: $.map(objEvent.participants || [], function( participant, i ){ 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 589 590 if(delegateAttendee[participant]) 591 return(null); 592 593 var attend = DataLayer.get('participant', (participant.id || participant)); 594 attend.user = DataLayer.get('user', attend.user); 595 596 statusParticipants[ statusLabels[attend.status] ]++; 597 598 if( attend.user.id === me.id ){ 599 participantInfo.user = { 600 id: attend.id, 601 status : attend.status, 602 delegatedFrom: attend.delegatedFrom || '0', 603 acl: attend.acl, 604 receiveNotification : attend.receiveNotification, 605 alarms : $.map(attend.alarms || [], function( alarm ){ 606 var alarm = DataLayer.get('alarm', alarm); 607 return (alarm == "" ? (null) : alarm); 608 }) 609 }; 610 me.id = attend.id; 611 return(null); 612 }; 613 614 var person = { 615 id: attend.id, 616 name: attend.user.name != 'false' ? attend.user.name : '', 617 mail: attend.user.mail, 618 status : attend.status, 619 isExternal: attend.isExternal, 620 acl: attend.acl, 621 delegatedFrom: attend.delegatedFrom 622 }; 623 624 if(!!parseInt(attend.delegatedFrom)){ 625 delegatedFrom[attend.delegatedFrom] = DataLayer.copy(person); 626 return(null); 627 } 628 629 if( !!parseInt(attend.isOrganizer )){ 630 participantInfo.organizer = DataLayer.copy(person); 631 return(null); 632 }; 633 634 return (person); 635 }), 632 636 organizer: participantInfo.organizer || me, 633 637 alarms: !!participantInfo.user ? participantInfo.user.alarms : [], … … 640 644 statusParticipants: statusParticipants 641 645 }; 642 }); 643 return notArray ? res[0] : res;646 }); 647 return (notArray ? res[0] : res); 644 648 } 645 649 }); 650 651 652 function decodeOwnerCalendar(calendar){ 653 if(calendar && !parseInt(Calendar.signatureOf[calendar].isOwner)){ 654 var Owner = DataLayer.get('calendarSignature', {filter: ['AND', ['=','calendar', calendar], ['=','isOwner','1']], criteria: {deepness: 2}}); 655 656 if($.isArray(Owner)) 657 Owner = Owner[0]; 658 659 return Owner.user; 660 } 661 return User.me; 662 663 664 } 646 665 647 666 function decodeRepeat ( form ) { … … 744 763 var tzId = form.timezone || Calendar.signatureOf[form.calendar].calendar.timezone || User.preferences.timezone, 745 764 746 formatString = ( typeof form.allDay !== "undefined" && !!form.allDay )? pref.dateFormat+" HH:mm" : pref.dateFormat + " " + pref.hourFormat, 747 748 participants = []; 765 formatString = ( typeof form.allDay !== "undefined" && !!form.allDay )? pref.dateFormat+" HH:mm" : pref.dateFormat + " " + pref.hourForma; 766 767 var Owner = decodeOwnerCalendar(form.calendar); 768 749 769 return { 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 if( participant.user === User.me.id ){774 775 776 777 778 779 780 781 782 783 784 785 }, form.delegatedFrom[i] != '0' ? {delegatedFrom: form.delegatedFrom[i]} : {});786 787 788 789 790 791 792 793 }, form.delegatedFrom[i] != '0' ? {delegatedFrom: form.delegatedFrom[i]} : {});794 795 796 770 "class": form["class"], 771 startTime: Date.parseExact(form.startDate + (!!form.allDay ? " 00:00": " "+$.trim(form.startHour)) , formatString ).toString('yyyy-MM-dd HH:mm:00'), 772 endTime: Date.parseExact(form.endDate + ( !!form.allDay ? " 00:00": " "+$.trim(form.endHour)), formatString ).toString('yyyy-MM-dd HH:mm:00'), //+ (!!form.allDay ? 86400000 : 0) , 773 allDay: ( !!form.allDay ? 1 : 0 ), 774 id: form.idEvent, 775 location: form.location, 776 category: form.category, 777 calendar: form.calendar, 778 summary: form.summary, 779 description: form.description, 780 timezone: tzId, 781 attachments: $.map(form.attachment || [], function( attachment, i ){ 782 return {attachment: attachment} 783 }), 784 repeat: this.decodeRepeat( form ), 785 participants: $.map( form.attendee || [], function( attendee, i ){ 786 787 if( !attendee || attendee === "" ) 788 return( null ); 789 790 var participant = {}; 791 participant.user = (attendee!= User.me.id) ? DataLayer.get('participant', attendee).user : attendee ; 792 793 if( participant.user === Owner.id ){ 794 return DataLayer.merge({ 795 id: attendee, 796 isOrganizer: (form.attendee_organizer == attendee ? 1 : 0 ), 797 acl: form.attendee_organizer == attendee ? (form.attendeeAcl[i].indexOf('o') < 0 ? form.attendeeAcl[i]+'o' : form.attendeeAcl[i]) : form.attendeeAcl[i].replace('o', ''), 798 alarms: participant.alarms = $.map( form.alarmTime || [], function( alarmTime, i ){ 799 if( alarmTime === "" ) 800 return( null ); 801 return !!form.alarmId[i] ? { type: form.alarmType[i], unit: form.alarmUnit[i], time: form.alarmTime[i], id: form.alarmId[i] }: 802 { type: form.alarmType[i],unit: form.alarmUnit[i], time: form.alarmTime[i] }; 803 }), 804 status: !!form.status ? form.status : 3 805 }, form.delegatedFrom[i] != '0' ? {delegatedFrom: form.delegatedFrom[i]} : {}); 806 }else{ 807 return DataLayer.merge({ 808 id: attendee, 809 acl: form.attendeeAcl[i], 810 isOrganizer: (form.attendee_organizer == attendee ? 1 : 0 ), 811 isExternal: !!parseInt(form.attendeeType[i]) ? 1 : 0, 812 acl: form.attendee_organizer == attendee ? (form.attendeeAcl[i].indexOf('o') < 0 ? form.attendeeAcl[i]+'o' : form.attendeeAcl[i]) : form.attendeeAcl[i].replace('o', '') 813 }, form.delegatedFrom[i] != '0' ? {delegatedFrom: form.delegatedFrom[i]} : {}); 814 }; 815 }) 816 }; 797 817 }); 798 818 … … 923 943 924 944 encoder: function( evtObj, filter ){ 925 945 926 946 if( !evtObj ) 927 947 return( false ); … … 993 1013 allDay: parseInt( evt.allDay ), 994 1014 isRepeat: isRepeat, 995 occurrence: i }, eventEditable(evt.id, isRepeat, i ) ) ); 1015 occurrence: i, 1016 calendar: evt.calendar}, eventEditable(evt.id, isRepeat, i ) ) ); 996 1017 }); 997 1018 -
trunk/prototype/modules/calendar/js/helpers.js
r5937 r5947 76 76 77 77 if(!isMail) 78 objEvent = DataLayer.encode( "schedulable:preview", objEvent );78 objEvent = DataLayer.encode( "schedulable:preview", objEvent ); 79 79 80 80 if(typeof(objEvent.id) == 'undefined'){ 81 82 81 objEvent.alarms = Calendar.signatureOf[User.preferences.defaultCalendar || Calendar.calendarIds[0]].defaultAlarms || false; 82 objEvent.useAlarmDefault = 1; 83 83 } 84 84 … … 564 564 } 565 565 } 566 567 var participant = UI.dialogs.addEvent.find('dd.me input[name="attendee[]"]').val(); 568 if( !parseInt(Calendar.signatureOf[$(this).val()].isOwner) ){ 569 var signature = Calendar.signatureOf[$(this).val()]; 570 var organizer = DataLayer.get('calendarSignature', {filter: ['AND', ['=','calendar',signature.calendar.id], ['=','isOwner','1']], criteria: {deepness: 2}}); 571 572 if($.isArray(organizer)) 573 organizer = organizer[0]; 574 DataLayer.put('participant', {id: participant, user: organizer.user.id, mail: organizer.user.mail}); 575 576 UI.dialogs.addEvent.find('dt.me').html(organizer.user.name); 577 UI.dialogs.addEvent.find('li.organizer input[name="attendee_organizer"]').val(participant); 578 UI.dialogs.addEvent.find('li.organizer label').filter('.name').html(organizer.user.name).end() 579 .filter('.mail').html(organizer.user.mail).attr('title',organizer.user.mail); 580 581 }else{ 582 UI.dialogs.addEvent.find('dt.me').html(User.me.name); 583 DataLayer.put('participant', {id: participant, user: User.me.id, mail: User.me.mail}); 584 UI.dialogs.addEvent.find('li.organizer input[name="attendee_organizer"]').val(participant); 585 UI.dialogs.addEvent.find('li.organizer label').filter('.name').html(User.me.name).end() 586 .filter('.mail').html(User.me.mail).attr('title',User.me.mail); 587 } 588 589 590 591 566 592 }); 567 593 -
trunk/prototype/modules/calendar/js/init.js
r5943 r5947 320 320 }); 321 321 322 }else 323 eventDetails( DataLayer.get( "schedulable", evt.id), true); 322 }else{ 323 var schedulable = DataLayer.get( "schedulable", evt.id); 324 schedulable.calendar = evt.calendar; 325 eventDetails( schedulable, true); 326 327 } 324 328 325 329 } -
trunk/prototype/services/iCal.php
r5916 r5947 512 512 if($schedulable ) //Caso o evento exista 513 513 { 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 514 $isOrganizer = false; 515 $isParticipant = false; 516 517 foreach($schedulable['participants'] as $value) 518 if($value['user']['id'] == Config::me('uidNumber')){ 519 $isParticipant = true; 520 if($value['isOrganizer']) 521 $isOrganizer = true; 522 523 if(!self::_existInMyCalendars($schedulable['id'])){ 524 $interation = ICAL_ACTION_UPDATE; 525 $interation = ( strrpos($value['acl'], ATTENDEE_ACL_PARTICIPATION_REQUIRED) ) ? ICAL_ACTION_IMPORT_REQUIRED : ICAL_ACTION_IMPORT; 526 break; 527 } 528 }else 529 529 { 530 530 if( self::_getTime($component , 'dtstamp') > $schedulable['dtstamp'] || $component->getProperty( 'sequence' , false , false ) > $schedulable['sequence']) //Organizador esta requisitando que você atualize o evento … … 989 989 static private function _existInMyCalendars( $id ) 990 990 { 991 $sig = Controller::find(array('concept' => 'calendarSignature'), array('user','calendar' ), array('filter' => array( '=' , 'user' , Config::me('uidNumber'))));991 $sig = Controller::find(array('concept' => 'calendarSignature'), array('user','calendar', 'isOwner'), array('filter' => array('AND', array( '=' , 'user' , Config::me('uidNumber') ) , array('=' , 'isOwner' , '1' )))); 992 992 $calendars = array(); 993 993 foreach ($sig as $val)
Note: See TracChangeset
for help on using the changeset viewer.