Changeset 6151 for trunk/prototype/modules/calendar/interceptors
- Timestamp:
- 05/09/12 17:50:59 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/prototype/modules/calendar/interceptors/DBMapping.php
r6137 r6151 111 111 112 112 public function findSchedulable(&$uri, &$params, &$criteria, $original) { 113 if (isset($criteria['filter'][ 3][1]) && $criteria['filter'][3][1] == 'calendar') {114 $start = $criteria['filter'][1][2];115 $end = $criteria['filter'][2][2];113 if (isset($criteria['filter'][2][1]) && $criteria['filter'][2][1] == 'calendar') { 114 $start = array( $criteria['filter'][1][1][1][2] , $criteria['filter'][1][2][1][2], $criteria['filter'][1][3][1][2] ); 115 $end = array( $criteria['filter'][1][1][2][2] , $criteria['filter'][1][2][2][2], $criteria['filter'][1][3][2][2] ); 116 116 117 117 $ids = array(); 118 118 $occ = array(); 119 119 120 if ($occurrences = self::checkOccurrences($start , $end))120 if ($occurrences = self::checkOccurrences($start[0], $end[0])) 121 121 foreach ($occurrences as $id => $occurrence) { 122 122 $ids[] = $id; 123 123 $occ[] = $occurrence; 124 } 125 126 $sql = ' SELECT calendar_object.id as id ,calendar_object.cal_uid as "uid", calendar_object.type_id as "type", calendar_object.dtstart as "startTime", calendar_object.summary as "summary", calendar_object.description as "description", calendar_object.dtend as "endTime" , calendar_object.location as "location", calendar_object.allday as "allDay", calendar_object.transp as "transparent", calendar_object.class_id as "class", calendar_object.repeat as "repeat", calendar_object.range_start as "rangeStart",calendar_object.range_end as "rangeEnd", calendar_object.last_update as "lastUpdate", calendar_object.dtstamp as "dtstamp", calendar_object.sequence as "sequence", calendar_object.tzid as "timezone" ,calendar_to_calendar_object.calendar_id as calendar FROM calendar_to_calendar_object , calendar_object WHERE (range_start >= \'' . $start . '\' AND range_end <= \'' . $end . '\' AND calendar_to_calendar_object.calendar_id IN (\'' . implode('\',\'', $criteria['filter'][3][2]) . '\')) AND calendar_to_calendar_object.calendar_object_id = calendar_object.id' . (!empty($ids) ? ' AND calendar_object.id NOT IN (\'' . implode('\',\'', $ids) . '\')' : ''); 124 } 125 126 $queryRange = '((range_end >= \'' . $start[0] . '\' AND range_end <= \'' . $end[0] . '\') OR ' 127 .'(range_start >= \'' . $start[1] . '\' AND range_start <= \'' . $end[1] . '\') OR ' 128 .'(range_start <= \'' . $start[2] . '\' AND range_end >= \'' . $end[2] . '\')) '; 129 130 $sql = ' SELECT calendar_object.id as id ,calendar_object.cal_uid as "uid", calendar_object.type_id as "type", ' 131 .'calendar_object.dtstart as "startTime", calendar_object.summary as "summary", ' 132 .'calendar_object.description as "description", calendar_object.dtend as "endTime" , ' 133 .'calendar_object.location as "location", calendar_object.allday as "allDay", ' 134 .'calendar_object.transp as "transparent", calendar_object.class_id as "class", ' 135 .'calendar_object.repeat as "repeat", calendar_object.range_start as "rangeStart", ' 136 .'calendar_object.range_end as "rangeEnd", calendar_object.last_update as "lastUpdate", ' 137 .'calendar_object.dtstamp as "dtstamp", calendar_object.sequence as "sequence", ' 138 .'calendar_object.tzid as "timezone" ,calendar_to_calendar_object.calendar_id as ' 139 .'calendar FROM calendar_to_calendar_object , calendar_object ' 140 .'WHERE ( '. $queryRange .' ' 141 .'AND calendar_to_calendar_object.calendar_id IN (\'' . implode('\',\'', $criteria['filter'][2][2]) . '\')) ' 142 .'AND calendar_to_calendar_object.calendar_object_id = calendar_object.id' . (!empty($ids) ? ' ' 143 .'AND calendar_object.id NOT IN (\'' . implode('\',\'', $ids) . '\')' : ''); 127 144 128 145 $params = Controller::service('PostgreSQL')->execResultSql($sql); … … 479 496 public function deepnessFindEvent(&$uri, &$result, &$criteria, $original) { 480 497 if (isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) { 481 482 498 $Time = new DateTime('now', new DateTimeZone('UTC')); 483 499 $DayLigth = array(); … … 511 527 512 528 if (isset($v['id'])) { 513 $result[$i]['participants'] = Controller::find( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('=', 'schedulable' , $v['id']), 'criteria' => array( 'deepness' => $original['criteria']['deepness'] - 1 )));529 $result[$i]['participants'] = Controller::find( array( 'concept' => 'participant' ) , false ,array( 'filter' => array('=', 'schedulable' , $v['id']),'deepness' => $original['criteria']['deepness'] - 1 )); 514 530 515 531 $attachmentRelation = Controller::find(array('concept' => 'schedulableToAttachment'), false, array('filter' => array('=', 'schedulable', $v['id']))); … … 537 553 538 554 //TODO: Remover apos suporte a deepness na api 539 public function deepnessReadParticipant( &$uri , &$result , &$criteria , $original ){ 540 555 public function deepnessReadParticipant( &$uri , &$result , &$criteria , $original ){ 556 541 557 if(isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) 542 558 { … … 570 586 571 587 //TODO: Remover apos suporte a deepness na api 572 public function deepnessFindParticipant( &$uri , &$result , &$criteria , $original ){ 573 588 public function deepnessFindParticipant( &$uri , &$result , &$criteria , $original ){ 589 574 590 if(isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) 575 591 { … … 665 681 666 682 $params = array(); 667 668 $al = Controller::service('PostgreSQL')->execSql( "SELECT distinct co.id as \"id\", co.cal_uid as \"uid\", co.type_id as \"type\", co.dtstart as \"startTime\", co.summary as \"summary\", co.description as \"description\", co.dtend as \"endTime\", co.location as \"location\", co.allday as \"allDay\", co.transp as transparent, co.class_id as class, ". 669 "co.range_start as \"rangeStart\", co.range_end as \"rangeEnd\", co.last_update as \"lastUpdate\", co.dtstamp as \"dtstamp\", co.sequence as \"sequence\", co.tzid as \"timezone\", CASE WHEN rep.object_id = co.id THEN occ.occurrence - al.alarm_offset ELSE co.dtstart - al.alarm_offset END as \"sendTime\" ". 670 "FROM calendar_alarm as al, calendar_object as co, calendar_repeat as rep, calendar_repeat_occurrence as occ, calendar_participant as part WHERE ". 671 "al.action_id = '".ALARM_ALERT."' AND al.sent = '0' AND al.participant_id = part.id AND part.object_id = co.id AND ". 672 "CASE WHEN rep.object_id = co.id ". 673 "THEN rep.id = occ.repeat_id AND occ.occurrence - al.alarm_offset >= '$target' AND occ.occurrence - al.alarm_offset <= '".( $target + 86400000)."' ". 674 "ELSE co.range_start - al.alarm_offset >= '$target' AND co.range_start - al.alarm_offset <= '".( $target + 86400000)."' END"); 675 683 $notC = array(); 684 685 $al = Controller::service('PostgreSQL')->execSql("SELECT distinct co.id as \"id\", co.cal_uid as \"uid\", co.type_id as \"type\", co.dtstart as \"startTime\", co.summary as \"summary\", co.description as \"description\", co.dtend as \"endTime\", co.location as \"location\", co.allday as \"allDay\", co.transp as transparent, co.class_id as class, ". 686 "co.range_start as \"rangeStart\", co.range_end as \"rangeEnd\", co.last_update as \"lastUpdate\", co.dtstamp as \"dtstamp\", co.sequence as \"sequence\", co.tzid as \"timezone\", CASE WHEN rep.object_id = co.id THEN occ.occurrence - al.alarm_offset ELSE co.dtstart - al.alarm_offset END as \"sendTime\", ". 687 "al.unit as \"unit\", al.time as \"time\" FROM calendar_alarm as al, calendar_object as co, calendar_repeat as rep, calendar_repeat_occurrence as occ, calendar_participant as part WHERE ". 688 "al.action_id = '".ALARM_ALERT."' AND al.sent = '0' AND ( (al.participant_id = part.id) AND (part.user_info_id = '". Config::me('uidNumber') ."') ) AND part.object_id = co.id AND ". 689 "CASE WHEN rep.object_id = co.id ". 690 "THEN rep.id = occ.repeat_id AND occ.occurrence - al.alarm_offset >= '$target' AND occ.occurrence - al.alarm_offset <= '".( $target + 86400000)."' ". 691 "ELSE (co.range_start - al.alarm_offset) >= '$target' AND (co.range_start - al.alarm_offset) <= '".( $target + 86400000)."' END"); 692 676 693 if(is_array($al)) 677 foreach( $al as $v ) 678 { 679 $params['sendTime'] = $v['sendTime']; 680 681 unset( $v['sendTime'] ); 682 683 $params['schedulable'] = $v; 694 foreach( $al as $v ){ 695 if($notC[$v['id']]) 696 continue; 697 698 $notC[$v['id']] = true; 699 $params[] = array('schedulable' => $v); 684 700 } 685 701 else 686 702 $params = false; 687 703 688 704 return false; 689 705 }
Note: See TracChangeset
for help on using the changeset viewer.