Changeset 5947 for trunk/prototype/modules/calendar/js/calendar.codecs.js
- Timestamp:
- 04/13/12 17:25:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.