Changeset 6476 for trunk/prototype/modules/calendar/interceptors
- Timestamp:
- 06/13/12 13:01:49 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/prototype/modules/calendar/interceptors/DBMapping.php
r6393 r6476 539 539 540 540 if (isset($v['id'])) { 541 $result[$i]['participants'] = Controller::find( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('=', 'schedulable' , $v['id']),'deepness' => $original['criteria']['deepness'] - 1 )); 541 $data = self::decodeParticipantsEvent($uri, $v, $criteria, $original); 542 543 $result[$i]['statusAttendees'] = isset($data['statusAttendees']) ? $data['statusAttendees'] : false; 544 $result[$i]['sizeAttendees'] = isset($data['sizeAttendees']) ? $data['sizeAttendees'] : false; 545 $result[$i]['participants'] = $data['attendees']; 542 546 543 547 $attachmentRelation = Controller::find(array('concept' => 'schedulableToAttachment'), false, array('filter' => array('=', 'schedulable', $v['id']))); … … 563 567 return $result; 564 568 } 569 565 570 566 571 //TODO: Remover apos suporte a deepness na api … … 689 694 ///////////////////////////////////////////////////////////////////////// 690 695 691 static function dayAlarm( &$uri , &$params , &$criteria , $original ) { 696 static function decodeParticipantsEvent( &$uri, $result, &$criteria, $original) { 697 $participants = Controller::find( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('=', 'schedulable' , $result['id']) )); 698 699 if($participants && ($size = count($participants)) < 100){ 700 if(isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0){ 701 self::deepnessFindParticipant($uri, $participants, $criteria, $original); 702 $participants['attendees'] = $participants; 703 } 704 705 }else if($participants && ($size = count($participants)) > 100){ 706 $owner = Controller::read( array( 'concept' => 'calendarSignature' ) , false ,array( 'filter' => array('AND', array('=', 'calendar' , $result['calendar']), array('=', 'isOwner', '1')))); 707 $owner = Controller::read( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('AND', array('=', 'schedulable' , $result['id']), array('=', 'user', $owner[0]['user'])), 'deepness' => 2)); 708 709 if(is_array($owner)) 710 $owner = $owner[0]; 711 712 $reference = array_slice($participants, 0, 100); 713 $organizer = false; 714 $asOwner = false; 715 716 foreach($reference as $r => &$v){ 717 if($v['id'] == $owner['id']){ 718 $v = $owner; 719 $asOwner = true; 720 continue; 721 } 722 723 self::deepnessReadParticipant($uri, $v, $criteria, $original); 724 725 if($v['isOrganizer'] == "1" ) 726 $organizer = $v; 727 } 728 729 if(!$organizer){ 730 $organizer = Controller::find( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('AND', array('=', 'schedulable' , $result['id']), array('=', 'isOrganizer', '1')), 'deepness' => 2)); 731 732 array_push($reference, $organizer[0]); 733 734 }else if($organizer && ($organizer['id'] != $owner['id'])) 735 array_merge($reference, $organizer); 736 737 if(!$asOwner) 738 array_push($reference, $owner); 739 740 $statusAttendees = array( 'default' => 0, 'accepted' => 0, 'tentative' => 0, 'cancelled' => 0, 'unanswered' => 0, 'delegated' => 0 ); 741 $statusLabels = array( 'default', 'accepted', 'tentative', 'cancelled', 'unanswered', 'delegated' ); 742 743 foreach($participants as $k => &$p){ 744 if(!$organizer && $p['isOrganizer'] == "1"){ 745 self::deepnessReadParticipant($uri, $p, $criteria, $original); 746 $reference = array_merge($reference, array($p)); 747 } 748 749 $statusAttendees[$statusLabels[$p['status']]]++; 750 } 751 752 $participants['statusAttendees'] = $statusAttendees; 753 $participants['sizeAttendees'] = $size; 754 $participants['attendees'] = $reference; 755 } 756 757 return $participants; 758 } 759 760 static function dayAlarm( &$uri , &$params , &$criteria , $original ) { 692 761 if(isset($criteria['filter'][1]) && $criteria['filter'][1] == 'date') 693 762 { … … 884 953 //Criaremos uma agenda padrão 885 954 $cal = array('name' => 'Calendario', 886 'description' => 'Calendario Padr ï¿œo',955 'description' => 'Calendario Padrão', 887 956 'timezone' => (date_default_timezone_get()) ? date_default_timezone_get() : 'America/Sao_Paulo', 888 957 'dtstamp' => time() . '000'
Note: See TracChangeset
for help on using the changeset viewer.