Changeset 6151
- Timestamp:
- 05/09/12 17:50:59 (12 years ago)
- Location:
- trunk/prototype/modules/calendar
- Files:
-
- 3 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 } -
trunk/prototype/modules/calendar/js/calendar.codecs.js
r6097 r6151 222 222 load: function(){ 223 223 var eventsDay = DataLayer.get('alarm:schedulable',['=', 'date', Date.today().getTime()]); 224 if(eventsDay) 224 225 for(var i = 0; i < eventsDay.length; i++){ 225 226 this.addAlarm( eventsDay[i] ); … … 405 406 406 407 }); 407 408 408 return notArray ? res[0] : res; 409 409 }, … … 417 417 418 418 encoder: function (evtObjt){ 419 420 if(notArray = typeof(evtObjt) == 'array' ) 419 if(evtObjt == '') return false; 420 421 if((notArray = typeof(evtObjt) !== 'array') && (!evtObjt.length)) 421 422 evtObjt = [evtObjt]; 422 423 … … 426 427 427 428 return{ 428 id: objEvent. id,429 id: objEvent.schedulable.id, 429 430 event_start: new Date( time ).setTimezoneOffset(Timezone.timezones[objEvent.schedulable.timezone]).toString( User.preferences.dateFormat), 430 sendTime: objEvent.sendTime,431 sendTime: parseInt(objEvent.schedulable.sendTime) / 1000, 431 432 schedulable: { 432 433 startTime: dateCalendar.formatDate(Timezone.getDateEvent(new Date(time), objEvent.schedulable.timezone, objEvent.schedulable.DayLigth, 'startTime'), User.preferences.hourFormat), 433 434 id: objEvent.schedulable.id, 434 435 summary: objEvent.schedulable.summary, 435 time: objEvent. time,436 unit: dateCalendar.timeunit[objEvent.unit.toLowerCase()] + ( parseInt(objEvent.time) > 1 ? 's' : '' )436 time: objEvent.schedulable.time, 437 unit: (dateCalendar.timeunit[objEvent.schedulable.unit.toLowerCase()]) + ( parseInt(objEvent.schedulable.time) > 1 ? 's' : '' ) 437 438 } 438 439 } 439 440 }); 440 return notArray ? res[0] :res;441 return res; 441 442 } 442 443 }); … … 1145 1146 for(var i in Calendar.signatureOf) 1146 1147 timezone[i] = Calendar.signatureOf[i].calendar.timezone; 1147 1148 1148 1149 return { 1149 filter: ["AND", 1150 1151 [ ">=", "rangeStart", filter.start.getTime() ], 1152 [ "<=", "rangeEnd", filter.end.getTime() ], 1153 [ "IN", "calendar", Calendar.calendarIds ] 1154 1155 ], 1150 filter: ['AND', 1151 ['OR', 1152 ['AND', 1153 ['>=', 'rangeEnd', filter.start.getTime()], 1154 ['<=', 'rangeEnd', filter.end.getTime()] , 1155 ], 1156 ['AND', 1157 ['>=', 'rangeStart', filter.start.getTime()], 1158 ['<=', 'rangeStart', filter.end.getTime()] , 1159 ], 1160 ['AND', 1161 ['<=', 'rangeStart', filter.start.getTime()], 1162 ['>=', 'rangeEnd', filter.end.getTime()] , 1163 ] 1164 ], 1165 ['IN', 'calendar', Calendar.calendarIds] 1166 ], 1156 1167 criteria: { 1157 1168 deepness: 2, -
trunk/prototype/modules/calendar/js/helpers.js
r6103 r6151 62 62 if (!eventInterval.length) 63 63 return 'Por favor, informe o intervalo'; 64 else if (parseInt(eventInterval,10) < =0 || parseInt(eventInterval,10).toString() == "NaN")64 else if (parseInt(eventInterval,10) < 0 || parseInt(eventInterval,10).toString() == "NaN") 65 65 return 'Por favor informe um valor válido para o intervalo'; 66 66 } … … 2396 2396 2397 2397 return { 2398 filter: ['AND', ['>=', 'rangeStart', rangeStart], ['<=', 'rangeEnd', rangeEnd] , ['IN', 'calendar', calerdars_selecteds]], 2398 filter: ['AND', 2399 ['OR', 2400 ['AND', 2401 ['>=', 'rangeEnd', rangeStart], 2402 ['<=', 'rangeEnd', rangeEnd] , 2403 ], 2404 ['AND', 2405 ['>=', 'rangeStart', rangeStart], 2406 ['<=', 'rangeStart', rangeEnd] , 2407 ], 2408 ['AND', 2409 ['<=', 'rangeStart', rangeStart], 2410 ['>=', 'rangeEnd', rangeEnd] , 2411 ] 2412 ], 2413 ['IN', 'calendar', calerdars_selecteds] 2414 ], 2399 2415 criteria: { 2400 2416 deepness: 2,
Note: See TracChangeset
for help on using the changeset viewer.