Changeset 5358 for trunk/prototype/modules/calendar/js/calendar.codecs.js
- Timestamp:
- 01/11/12 13:28:21 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/prototype/modules/calendar/js/calendar.codecs.js
r5343 r5358 437 437 }; 438 438 439 var isOrganizer = !!evtObj[0].id ? 0 : 1; 440 439 441 var res = $.map(evtObj, function( objEvent ){ 440 442 … … 460 462 } 461 463 var temp = []; 462 464 var tempAlarm = []; 465 463 466 var typeAlarm = function(obj){ 467 var alarm = []; 464 468 for(var i = 0; i < obj.length; i++){ 469 if(tempAlarm[obj[i].id]) 470 continue; 471 tempAlarm[obj[i].id] = true; 472 465 473 if(obj[i].type == "1"){ 466 474 obj[i].type = 'alert'; … … 470 478 obj[i].type = 'sms'; 471 479 } 480 alarm.push(obj[i]); 472 481 } 473 return obj;482 return alarm; 474 483 } 475 484 return { … … 490 499 allDay: !!parseInt( objEvent.allDay ), 491 500 // attachments: this.decode( "attachment:detail", form ), 492 attendee: $.map(objEvent.participants || [], function( participant ){ 493 if(participant.indexOf('java') >= 0) 494 return (null); 495 if(temp[participant]) 496 return (null); 497 temp[participant] = true; 501 attendee: $.map(objEvent.participants || [], function( participant, i ){ 502 if(participant.indexOf('java') >= 0) 503 return (null); 504 if(temp[participant]) 505 return (null); 506 temp[participant] = true; 507 508 var attend = DataLayer.get('participant', participant); 509 attend.user = DataLayer.get('user', attend.user) 498 510 499 participant = DataLayer.get( "participant", participant); 500 501 statusParticipants[participant.status]++; 502 var user = DataLayer.get( "user", participant.user.id || participant.user ); 503 var getIdUser = function(user){ 504 if(user.owner) 505 return 'external:'+user.id; 506 else if(user.id == User.me.id) 507 return user.id; 508 else return 'internal:'+user.id; 509 }; 511 statusParticipants[attend.status]++; 510 512 511 var person = { uid: getIdUser(user), 512 name: user.name, 513 mail: user.mail 514 }; 515 516 if( person.uid === me.uid ) 513 var person = { uid: attend.id, 514 name: attend.user.name, 515 mail: attend.user.mail, 516 isExternal: attend.isExternal 517 }; 518 519 if( attend.user.id === me.uid ) 517 520 { 518 participantInfo.status = participant.status;521 participantInfo.status = attend.status; 519 522 participantInfo.alarms = typeAlarm(objEvent.alarms); 520 523 } 521 if( parseInt( participant.isOrganizer ) )524 if( parseInt( attend.isOrganizer ) ) 522 525 { 526 isOrganizer = ((attend.user.id == User.me.id) || (!!!attend.user)) ? 1 : 0; 523 527 participantInfo.organizer = person; 524 return( null);528 return(null); 525 529 } 526 530 … … 534 538 }; 535 539 }); 536 res[0].isOrganizer = res[0].organizer.uid == User.me.id ? 1 : 0;540 res[0].isOrganizer = isOrganizer; 537 541 res[0].statusParticipants = statusObject(statusParticipants); 538 542 if( !notArray ) … … 594 598 participants = []; 595 599 596 if( form.idEvent )597 participants = DataLayer.get( "participant:detail", [ "=", "schedulable", form.idEvent ] );600 //if( form.idEvent ) 601 // participants = DataLayer.get( "participant:detail", [ "=", "schedulable", form.idEvent ] ); 598 602 599 603 var spaces = function(hours){ … … 620 624 participants: $.map( form.attendee || [], function( attendee, i ){ 621 625 622 if( !attendee || attendee === "" )623 return( null );626 if( !attendee || attendee === "" ) 627 return( null ); 624 628 625 629 var participant = {}; 626 var isCurrentParticipant = function(user, event){ 627 var participant = DataLayer.get('participant', ['AND',['=', 'user', user],['=', 'schedulable', event]]); 628 if(participant != '') 629 return participant[0].id; 630 else 631 return false; 632 }; 630 participant.user = (attendee!= User.me.id) ? DataLayer.get('participant', attendee).user : attendee ; 633 631 634 if((attendee.indexOf('internal') >= 0) || (attendee.indexOf('external') >= 0)){ 635 participant.user = attendee.replace(/[a-z:]/g, ""), 632 if( participant.user === User.me.id ){ 633 if(!!form.idEvent ) 634 participant.id = attendee; 636 635 participant.isOrganizer = ( !i ? 1 : 0 ); 637 if(attendee.indexOf('external') >= 0)638 participant.isExternal = 1;639 var id = '';640 if(participant.user == User.me.id)641 participant.status = form.status;642 if((form.idEvent) && (id = isCurrentParticipant(participant.user, form.idEvent)))643 participant.id = id;644 return participant;645 }else if(attendee.indexOf('java') >= 0){646 participant.user = attendee;647 participant.isOrganizer = ( !i ? 1 : 0 );648 participant.isExternal= 1;649 }else{650 participant.user = attendee;651 participant.isOrganizer = ( !i ? 1 : 0 );652 }653 654 if( attendee === User.me.id ){655 636 var obj = form.alarmTime ? form : pref; 656 637 participant.alarms = $.map( obj.alarmTime || [], function( alarmTime, i ){ … … 659 640 return( null ); 660 641 661 662 642 if(obj.alarmId[i] === "") 663 643 return { type: obj.alarmType[i],unit: obj.alarmUnit[i], time: obj.alarmTime[i] }; … … 665 645 return { type: obj.alarmType[i], unit: obj.alarmUnit[i], time: obj.alarmTime[i], id: obj.alarmId[i] }; 666 646 }); 667 668 if( participants[ attendee ] ){669 participant.id = participants[ attendee ].id;670 }671 647 participant.status = form.status; 672 } 673 674 return( participant ); 648 }else{ 649 participant.id = attendee; 650 participant.isOrganizer = ( !i ? 1 : 0 ); 651 if(!!parseInt(form.attendeeType[i])) 652 participant.isExternal= 1; 653 } 654 if( participants[ attendee ] ){ 655 participant.id = participants[ attendee ].id; 656 } 657 return( participant ); 675 658 }) 676 659 }; … … 742 725 { 743 726 participantInfo.organizer = person; 744 return( null);727 return(null); 745 728 } 746 729
Note: See TracChangeset
for help on using the changeset viewer.