Changeset 6754 for branches/2.4/prototype/modules/calendar/interceptors
- Timestamp:
- 07/11/12 11:45:10 (12 years ago)
- Location:
- branches/2.4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.4
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/trunk merged eligible /sandbox/2.4.1-3 6237-6527
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/2.4/prototype/modules/calendar/interceptors/DAViCalAdapter.php
r6010 r6754 1 1 <?php 2 2 require_once ROOTPATH.'/modules/calendar/constants.php'; 3 use prototype\api\Config as Config; 3 4 4 5 class DAViCalAdapter { -
branches/2.4/prototype/modules/calendar/interceptors/DBMapping.php
r6588 r6754 5 5 6 6 require_once ROOTPATH . '/modules/calendar/interceptors/Helpers.php'; 7 8 use prototype\api\Config as Config; 7 9 8 10 class DBMapping extends Helpers { … … 147 149 .'(range_start >= \'' . $start[1] . '\' AND range_start <= \'' . $end[1] . '\') OR ' 148 150 .'(range_start <= \'' . $start[2] . '\' AND range_end >= \'' . $end[2] . '\')) ' 149 .(!empty($ids) ? ' ' .'AND calendar_object.id NOT IN (\'' . implode('\',\'', $ids) . '\') ' : ' ') 150 .'AND calendar_object.dtstart NOT IN (SELECT calendar_repeat_occurrence.occurrence from calendar_repeat_occurrence, ' 151 .'calendar_repeat where (calendar_repeat_occurrence.repeat_id = calendar_repeat.id) ' 152 151 .(!empty($ids) ? ' ' .'AND calendar_object.id NOT IN (\'' . implode('\',\'', $ids) . '\') ' : ' ') 152 .'AND calendar_object.dtstart NOT IN (SELECT calendar_repeat_occurrence.occurrence from calendar_repeat_occurrence, ' 153 .'calendar_repeat where (calendar_repeat_occurrence.repeat_id = calendar_repeat.id) ' 154 .'AND (calendar_repeat.object_id = calendar_object.id))'; 153 155 154 156 $params = Controller::service('PostgreSQL')->execResultSql($sql.$where); … … 206 208 //Recurepa as execeções anteriores caso exista 207 209 if (isset($lastExceptions) && count($lastExceptions) && $lastExceptions) 208 foreach ($lastExceptions as $value) 209 210 foreach ($lastExceptions as $value) 211 array_push($exceptions, $value['occurrence']); 210 212 211 213 $params = array_diff(self::decodeRepeat($repeat, $ranges[0]['rangeStart'], $ranges[0]['rangeEnd']), $exceptions); … … 215 217 if (!empty($params)) 216 218 Controller::service('PostgreSQL')->execResultSql("INSERT INTO calendar_repeat_occurrence(repeat_id,exception,occurrence)VALUES('" . $id . "','0','" . implode("'),('" . $id . "','0','", $params) . "')" . ( empty($exceptions) ? "" : ",('" . $id . "','1','" . implode("'),('" . $id . "','1','", $exceptions) . "')" )); 217 else if(!empty($exceptions)) 218 Controller::service('PostgreSQL')->execResultSql("INSERT INTO calendar_repeat_occurrence(repeat_id,exception,occurrence)VALUES ('" . $id . "','1','" . implode("'),('" . $id . "','1','", $exceptions) . "')" ); 219 }219 else if(!empty($exceptions)) 220 Controller::service('PostgreSQL')->execResultSql("INSERT INTO calendar_repeat_occurrence(repeat_id,exception,occurrence)VALUES ('" . $id . "','1','" . implode("'),('" . $id . "','1','", $exceptions) . "')" ); 221 } 220 222 221 223 public function checkOccurrences($start, $end, $calendarIds) { … … 543 545 544 546 if (isset($v['id'])) { 545 $data = self::decodeParticipantsEvent($uri, $v, $criteria, $original);546 547 $result[$i]['statusAttendees'] = isset($data['statusAttendees']) ? $data['statusAttendees'] : false; 548 $result[$i]['sizeAttendees'] = isset($data['sizeAttendees']) ? $data['sizeAttendees'] : false; 549 $result[$i]['participants'] = $data['attendees']; 550 547 $data = self::decodeParticipantsEvent($uri, $v, $criteria, $original); 548 549 $result[$i]['statusAttendees'] = isset($data['statusAttendees']) ? $data['statusAttendees'] : false; 550 $result[$i]['sizeAttendees'] = isset($data['sizeAttendees']) ? $data['sizeAttendees'] : false; 551 $result[$i]['participants'] = $data['attendees']; 552 551 553 $attachmentRelation = Controller::find(array('concept' => 'schedulableToAttachment'), false, array('filter' => array('=', 'schedulable', $v['id']))); 552 554 if (is_array($attachmentRelation)) { … … 571 573 return $result; 572 574 } 573 575 574 576 575 577 //TODO: Remover apos suporte a deepness na api … … 698 700 ///////////////////////////////////////////////////////////////////////// 699 701 700 static function decodeParticipantsEvent( &$uri, $result, &$criteria, $original) { 701 $participants = Controller::find( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('=', 'schedulable' , $result['id']) )); 702 703 if($participants && ($size = count($participants)) < 100){ 704 if(isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0){ 705 self::deepnessFindParticipant($uri, $participants, $criteria, $original); 706 $participants['attendees'] = $participants; 707 } 708 709 }else if($participants && ($size = count($participants)) > 100){ 710 $owner = Controller::read( array( 'concept' => 'calendarSignature' ) , false ,array( 'filter' => array('AND', array('=', 'calendar' , $result['calendar']), array('=', 'isOwner', '1')))); 711 $owner = Controller::read( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('AND', array('=', 'schedulable' , $result['id']), array('=', 'user', $owner[0]['user'])), 'deepness' => 2)); 712 713 if(is_array($owner)) 714 $owner = $owner[0]; 715 716 $reference = array_slice($participants, 0, 100); 717 $organizer = false; 718 $asOwner = false; 719 720 foreach($reference as $r => &$v){ 721 if($v['id'] == $owner['id']){ 722 $v = $owner; 723 $asOwner = true; 724 continue; 725 } 726 727 self::deepnessReadParticipant($uri, $v, $criteria, $original); 728 729 if($v['isOrganizer'] == "1" ) 730 $organizer = $v; 731 } 732 733 if(!$organizer){ 734 $organizer = Controller::find( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('AND', array('=', 'schedulable' , $result['id']), array('=', 'isOrganizer', '1')), 'deepness' => 2)); 735 736 array_push($reference, $organizer[0]); 737 738 }else if($organizer && ($organizer['id'] != $owner['id'])) 739 array_merge($reference, $organizer); 740 741 if(!$asOwner) 742 array_push($reference, $owner); 743 744 $statusAttendees = array( 'default' => 0, 'accepted' => 0, 'tentative' => 0, 'cancelled' => 0, 'unanswered' => 0, 'delegated' => 0 ); 745 $statusLabels = array( 'default', 'accepted', 'tentative', 'cancelled', 'unanswered', 'delegated' ); 746 747 foreach($participants as $k => &$p){ 748 if(!$organizer && $p['isOrganizer'] == "1"){ 749 self::deepnessReadParticipant($uri, $p, $criteria, $original); 750 $reference = array_merge($reference, array($p)); 751 } 752 753 $statusAttendees[$statusLabels[$p['status']]]++; 754 } 755 756 $participants['statusAttendees'] = $statusAttendees; 757 $participants['sizeAttendees'] = $size; 758 $participants['attendees'] = $reference; 759 } 760 761 return $participants; 762 } 763 764 static function dayAlarm( &$uri , &$params , &$criteria , $original ) { 702 static function decodeParticipantsEvent( &$uri, $result, &$criteria, $original) { 703 $participants = Controller::find( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('=', 'schedulable' , $result['id']) )); 704 705 if($participants && ($size = count($participants)) < 100){ 706 if(isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0){ 707 self::deepnessFindParticipant($uri, $participants, $criteria, $original); 708 $participants['attendees'] = $participants; 709 } 710 711 }else if($participants && ($size = count($participants)) > 100){ 712 $owner = Controller::read( array( 'concept' => 'calendarSignature' ) , false ,array( 'filter' => array('AND', array('=', 'calendar' , $result['calendar']), array('=', 'isOwner', '1')))); 713 $owner = Controller::read( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('AND', array('=', 'schedulable' , $result['id']), array('=', 'user', $owner[0]['user'])), 'deepness' => 2)); 714 715 if(is_array($owner)) 716 $owner = $owner[0]; 717 718 $reference = array_slice($participants, 0, 100); 719 $organizer = false; 720 $asOwner = false; 721 722 foreach($reference as $r => &$v){ 723 if($v['id'] == $owner['id']){ 724 $v = $owner; 725 $asOwner = true; 726 continue; 727 } 728 729 self::deepnessReadParticipant($uri, $v, $criteria, $original); 730 731 if($v['isOrganizer'] == "1" ) 732 $organizer = $v; 733 } 734 735 if(!$organizer){ 736 $organizer = Controller::find( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('AND', array('=', 'schedulable' , $result['id']), array('=', 'isOrganizer', '1')), 'deepness' => 2)); 737 738 array_push($reference, $organizer[0]); 739 740 }else if($organizer && ($organizer['id'] != $owner['id'])) 741 array_merge($reference, $organizer); 742 743 if(!$asOwner) 744 array_push($reference, $owner); 745 746 $statusAttendees = array( 'default' => 0, 'accepted' => 0, 'tentative' => 0, 'cancelled' => 0, 'unanswered' => 0, 'delegated' => 0 ); 747 $statusLabels = array( 'default', 'accepted', 'tentative', 'cancelled', 'unanswered', 'delegated' ); 748 749 foreach($participants as $k => &$p){ 750 if(!$organizer && $p['isOrganizer'] == "1"){ 751 self::deepnessReadParticipant($uri, $p, $criteria, $original); 752 $reference = array_merge($reference, array($p)); 753 } 754 755 $statusAttendees[$statusLabels[$p['status']]]++; 756 } 757 758 $participants['statusAttendees'] = $statusAttendees; 759 $participants['sizeAttendees'] = $size; 760 $participants['attendees'] = $reference; 761 } 762 763 return $participants; 764 } 765 766 static function dayAlarm( &$uri , &$params , &$criteria , $original ) { 765 767 if(isset($criteria['filter'][1]) && $criteria['filter'][1] == 'date') 766 768 { … … 898 900 Controller::delete(array('concept' => 'attachment', 'id' => $original['URI']['id'])); 899 901 } 900 901 public function decodeDeleteCalendarSignatureAlarm(&$uri, &$params, &$criteria, $original) { 902 if ($original['URI']['id'] == '' && isset($original['criteria']['filter'])){ 903 Controller::deleteAll(array('concept' => 'calendarSignatureAlarm'), null,$original['criteria']); 904 return false; 905 } 906 } 902 903 public function decodeDeleteCalendarSignatureAlarm(&$uri, &$params, &$criteria, $original) { 904 if ($original['URI']['id'] == '' && isset($original['criteria']['filter'])){ 905 Controller::deleteAll(array('concept' => 'calendarSignatureAlarm'), null,$original['criteria']); 906 return false; 907 } 908 } 909 907 910 public function createDefaultSignature(&$uri, &$result, &$criteria, $original) { 908 911 … … 963 966 //Criaremos uma agenda padrão 964 967 $cal = array('name' => 'Calendario', 965 'description' => 'Calendario Padrão',968 'description' => 'Calendario Padrão', 966 969 'timezone' => (date_default_timezone_get()) ? date_default_timezone_get() : 'America/Sao_Paulo', 967 970 'dtstamp' => time() . '000' -
branches/2.4/prototype/modules/calendar/interceptors/Notifications.php
r6331 r6754 5 5 require_once ROOTPATH . '/plugins/icalcreator/iCalcreator.class.php'; 6 6 require_once ROOTPATH . '/api/parseTPL.php'; 7 8 use prototype\api\Config as Config; 7 9 8 10 class Notifications extends Helpers {
Note: See TracChangeset
for help on using the changeset viewer.