Changeset 7579 for trunk/prototype/modules/calendar
- Timestamp:
- 11/29/12 17:12:33 (12 years ago)
- Location:
- trunk/prototype/modules/calendar
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/prototype/modules/calendar/interceptors/DBMapping.php
r7519 r7579 93 93 94 94 static function parseTimeDate($time, $timezone) { 95 return strtotime($time . ' ' . $timezone) . '000';95 return strtotime($time . ' ' . $timezone) . '000'; 96 96 } 97 97 … … 822 822 //TODO: Remover apos suporte a deepness na api 823 823 public function deepnessFindEvent(&$uri, &$result, &$criteria, $original) { 824 if (isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) { 825 $Time = new DateTime('now', new DateTimeZone('UTC')); 826 $DayLigth = array(); 827 foreach ($result as $i => $v) { 828 829 if ( isset($v['calendar']) && (!isset($currentTimezone) || $currentTimezone != $original['criteria']['timezones'][$v['calendar']])) { 830 $currentTimezone = isset($original['criteria']['timezones'][$v['calendar']]) ? $original['criteria']['timezones'][$v['calendar']] : $v['timezone']; 831 $Time->setTimezone(new DateTimeZone($currentTimezone)); 832 } 833 834 $Time->setTimestamp((int) ($v['startTime'] / 1000)); 835 $DayLigth['calendar']['startTime'] = $Time->format('I') ? 1 : 0; 836 837 $Time->setTimestamp((int) ($v['endTime'] / 1000)); 838 $DayLigth['calendar']['endTime'] = $Time->format('I') ? 1 : 0; 839 840 if (!isset($currentTimezone) || ($currentTimezone != $v['timezone'])) { 841 $currentTimezone = $v['timezone']; 842 $Time->setTimezone(new DateTimeZone($v['timezone'])); 843 844 $Time->setTimestamp((int) ($v['startTime'] / 1000)); 845 $DayLigth['event']['startTime'] = $Time->format('I') ? 1 : 0; 846 847 $Time->setTimestamp((int) ($v['endTime'] / 1000)); 848 $DayLigth['event']['endTime'] = $Time->format('I') ? 1 : 0; 849 }else 850 $DayLigth['event'] = $DayLigth['calendar']; 851 852 853 $result[$i]['DayLigth'] = $DayLigth; 854 855 if(((int)$v['type']) == 2){ 856 857 $taskToActivity = Controller::find(array('concept' => 'taskToActivity'), false, array('filter' => array('AND', array('=', 'activity', $v['id']), array('=','owner', Config::me('uidNumber'))) , 'deepness' => 2)); 858 859 if($taskToActivity) 860 $result[$i]['taskToActivity'] = $taskToActivity; 861 862 $result[$i]['historic'] = Controller::find(array('concept' => 'calendarHistoric'), false, array('filter' => array('=', 'schedulable', $v['id']) , 'deepness' => 2)); 863 824 if (isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) { 825 826 $date = new DateTime('now', new DateTimeZone('UTC')); 827 $DayLigth = array(); 828 829 foreach ($result as $i => $v) { 830 831 $currentTimezone = isset($original['criteria']['timezones'][$v['calendar']]) ? $original['criteria']['timezones'][$v['calendar']] : $v['timezone']; 832 833 $date->setTimestamp((int) ($v['startTime'] / 1000)); 834 $date->setTimezone( new DateTimeZone( $v['timezone'] )); 835 $DayLigth['event']['startTime'] = ($date->getTimestamp() + $date->getOffset()).'000'; 836 837 $date->setTimezone( new DateTimeZone($currentTimezone)); 838 $DayLigth['calendar']['startTime'] = ($date->getTimestamp() + $date->getOffset()).'000'; 839 840 $date->setTimestamp((int) ($v['endTime'] / 1000)); 841 $date->setTimezone( new DateTimeZone($currentTimezone)); 842 $DayLigth['event']['endTime'] = ($date->getTimestamp() + $date->getOffset()).'000'; 843 844 $date->setTimezone( new DateTimeZone($currentTimezone)); 845 $DayLigth['calendar']['endTime'] = ($date->getTimestamp() + $date->getOffset()).'000'; 846 847 848 $result[$i]['DayLigth'] = $DayLigth; 849 850 if(((int)$v['type']) == 2){ 851 852 $taskToActivity = Controller::find(array('concept' => 'taskToActivity'), false, array('filter' => array('AND', array('=', 'activity', $v['id']), array('=','owner', Config::me('uidNumber'))) , 'deepness' => 2)); 853 854 if($taskToActivity) 855 $result[$i]['taskToActivity'] = $taskToActivity; 856 857 $result[$i]['historic'] = Controller::find(array('concept' => 'calendarHistoric'), false, array('filter' => array('=', 'schedulable', $v['id']) , 'deepness' => 2)); 858 859 } 860 861 if (isset($v['id'])) { 862 $data = self::decodeParticipantsEvent($uri, $v, $criteria, $original); 863 864 $result[$i]['statusAttendees'] = isset($data['statusAttendees']) ? $data['statusAttendees'] : false; 865 $result[$i]['sizeAttendees'] = isset($data['sizeAttendees']) ? $data['sizeAttendees'] : false; 866 $result[$i]['participants'] = $data['attendees']; 867 868 $attachmentRelation = Controller::find(array('concept' => 'schedulableToAttachment'), false, array('filter' => array('=', 'schedulable', $v['id']))); 869 if (is_array($attachmentRelation)) { 870 $attachments = array(); 871 foreach ($attachmentRelation as $key => $value) 872 if (isset($value['attachment']) || !!$value['attachment']) 873 $attachments[$key] = $value['attachment']; 874 //Pega os anexos sem source 875 $result[$i]['attachments'] = Controller::find(array('concept' => 'attachment'), array('id', 'name', 'type', 'size'), array('filter' => array('IN', 'id', $attachments))); 876 } 877 878 $repeat = Controller::find(array('concept' => 'repeat'), false, array('filter' => array('=', 'schedulable', $v['id']))); 879 880 unset($result[$i]['repeat']); 881 882 if (is_array($repeat)) 883 $result[$i]['repeat'] = $repeat[0]; 884 } 885 } 864 886 } 865 887 866 if (isset($v['id'])) { 867 $data = self::decodeParticipantsEvent($uri, $v, $criteria, $original); 868 869 $result[$i]['statusAttendees'] = isset($data['statusAttendees']) ? $data['statusAttendees'] : false; 870 $result[$i]['sizeAttendees'] = isset($data['sizeAttendees']) ? $data['sizeAttendees'] : false; 871 $result[$i]['participants'] = $data['attendees']; 872 873 $attachmentRelation = Controller::find(array('concept' => 'schedulableToAttachment'), false, array('filter' => array('=', 'schedulable', $v['id']))); 874 if (is_array($attachmentRelation)) { 875 $attachments = array(); 876 foreach ($attachmentRelation as $key => $value) 877 if (isset($value['attachment']) || !!$value['attachment']) 878 $attachments[$key] = $value['attachment']; 879 //Pega os anexos sem source 880 $result[$i]['attachments'] = Controller::find(array('concept' => 'attachment'), array('id', 'name', 'type', 'size'), array('filter' => array('IN', 'id', $attachments))); 881 } 882 883 $repeat = Controller::find(array('concept' => 'repeat'), false, array('filter' => array('=', 'schedulable', $v['id']))); 884 885 unset($result[$i]['repeat']); 886 887 if (is_array($repeat)) 888 $result[$i]['repeat'] = $repeat[0]; 889 } 890 } 891 } 892 893 return $result; 888 return $result; 889 } 890 891 public function diffOffset( $from, $to ){ 892 893 if(($from < 0 && $to < 0) || ($from > 0 && $to > 0) ){ 894 895 return ($from - $to); 896 897 }else{ 898 return ( $from > 0 ? ($to - $from) : ($from - $to)); 899 } 900 894 901 } 895 902 … … 1175 1182 $uri['id'] = $idSchedulable; 1176 1183 1177 1178 1184 if(isset($criteria['type']) && $criteria['type'] == '2'){ 1179 1185 -
trunk/prototype/modules/calendar/js/calendar.codecs.js
r7397 r7579 605 605 timezone: objEvent.timezone, 606 606 timezones: Timezone.timezones, 607 startDate: new Date( parseInt(objEvent.startTime) ).setTimezoneOffset( Timezone.timezone( objEvent.timezone ) ).toString( User.preferences.dateFormat),608 startHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date( parseInt(objEvent.startTime)), objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'startTime'), User.preferences.hourFormat),609 endDate: new Date( parseInt(objEvent.endTime) - (!!parseInt(objEvent.allDay) ? 86400000 : 0) ).setTimezoneOffset( Timezone.timezone( objEvent.timezone ) ).toString( User.preferences.dateFormat),610 endHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date(parseInt(objEvent.endTime)), objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'endTime'), User.preferences.hourFormat),607 startDate: Timezone.getDate( (objEvent.DayLigth ? objEvent.DayLigth.event.startTime : objEvent.startTime), 'start', objEvent.allDay ), 608 startHour: objEvent.DayLigth ? Timezone.getHour( objEvent.DayLigth.event.startTime) : Timezone.formateHour( objEvent.startTime ), 609 endDate: Timezone.getDate( (objEvent.DayLigth ? objEvent.DayLigth.event.endTime : objEvent.endTime), 'end', objEvent.allDay ), 610 endHour: objEvent.DayLigth ? Timezone.getHour( objEvent.DayLigth.event.endTime) : Timezone.formateHour( objEvent.endTime ), 611 611 allDay: !!parseInt( objEvent.allDay ), 612 612 dueDate: objEvent.dueDate, … … 1407 1407 isExternal: !!parseInt(form.attendeeType[i]) ? 1 : 0, 1408 1408 acl: form.attendee_organizer == attendee ? (form.attendeeAcl[i].indexOf('o') < 0 ? form.attendeeAcl[i]+'o' : form.attendeeAcl[i]) : form.attendeeAcl[i].replace('o', '') 1409 }, form.delegatedFrom[i] != '0'? {1409 }, (form.delegatedFrom[i] != '0' && form.delegatedFrom[i] != '') ? { 1410 1410 delegatedFrom: form.delegatedFrom[i] 1411 1411 } : {}); … … 1747 1747 } 1748 1748 1749 var duration = parseInt( evt. endTime ) - parseInt( evt.startTime ), isRepeat = false;1749 var duration = parseInt( evt.DayLigth.calendar.endTime ) - parseInt( evt.DayLigth.calendar.startTime ), isRepeat = false; 1750 1750 1751 1751 var occurrences = []; … … 1756 1756 occurrences = evt.occurrences; 1757 1757 }else 1758 occurrences[ occurrences.length ] = evt. startTime;1758 occurrences[ occurrences.length ] = evt.DayLigth.calendar.startTime; 1759 1759 1760 1760 //occurrences = DataLayer.unique( occurrences ).sort(); … … 1767 1767 id: evt.URI || evt.id+ '-' + i, 1768 1768 title: Encoder.htmlDecode(evt.summary), 1769 start: Timezone.getDate Calendar(new Date( parseInt( occurrences[i] ) ), calendar.timezone, !!evt.DayLigth ? evt.DayLigth.calendar.startTime : Timezone.daylightSaving),1770 end: Timezone.getDateCalendar(new Date( parseInt( occurrences[i] ) + duration - (!!parseInt(evt.allDay) ? 86400000 : 0)), calendar.timezone, !!evt.DayLigth ? evt.DayLigth.calendar.startTime : Timezone.daylightSaving),1769 start: Timezone.getDateObjCalendar( occurrences[i], 'start', evt.allDay), 1770 end: Timezone.getDateObjCalendar( (parseInt( occurrences[i] ) + duration), 'end', evt.allDay), 1771 1771 allDay: parseInt( evt.allDay ), 1772 1772 isRepeat: isRepeat, -
trunk/prototype/modules/calendar/js/init.js
r7524 r7579 349 349 }, 350 350 351 eventRender: function( event, element, view ){ 351 352 eventRender: function( event, element, view ){ 352 353 $('#calendar td.fc-year-have-event').removeClass('fc-year-have-event'); 353 354 … … 363 364 element.find(".fc-event-inner.fc-event-skin").prepend($('<img style="width: 11px; height: 13px;" class="" src="../prototype/modules/calendar/img/' + img_icon + '"></img>')); 364 365 }, 365 366 366 367 select: function( start, end, allDay, event, view ){ 367 368 if (view.name == "month") { … … 502 503 503 504 eventAfterRender: function(event, element, view){ 505 504 506 contentMenu(); 507 505 508 } 506 509 }, dateCalendar)); -
trunk/prototype/modules/calendar/js/timezone.js
r6069 r7579 5 5 */ 6 6 7 var objTime = DataLayer.dispatch( "timezones" );7 var objTime = DataLayer.dispatch( "timezones", {teste:'123'} ); 8 8 9 9 Timezone = { … … 11 11 daylightSaving: isNaN(parseInt( objTime.isDaylightSaving )) ? 0 : parseInt( objTime.isDaylightSaving ), 12 12 13 start:false, 14 end:false, 15 13 16 timezones: objTime.timezones, 14 timezone: function( tzId ){ 17 18 timezone: function( tzId ){ 15 19 16 20 return this.timezones[ tzId || User.preferences.timezone ]; … … 18 22 }, 19 23 20 getDateCalendar: function(date, tzId, isDay){ 21 var timezone = this.timezone( tzId ); 24 getDateCalendar: function( date, tzId, isDayLigth ){ 22 25 23 if(!timezone) 24 return date; 26 return date; 25 27 26 date = this.normalizeDate(date, false, true);27 28 return date.add({hours: parseInt(timezone.charAt(0) + timezone.charAt(2)) + parseInt(isDay) });29 28 }, 30 29 31 getDateEvent: function(date, tzId, i dCalendar, isDay, type){32 var timezone = this.timezone( tzId ); 33 var timezoneCurrent = this.timezone(DataLayer.get('calendar', idCalendar).timezone);30 getDateEvent: function(date, tzId, isDayLigth){ 31 if(!tzId) 32 return date; 34 33 35 if(timezone == timezoneCurrent) 36 return date; 37 38 var to = parseInt(timezone.charAt(0) + timezone.charAt(2)) + parseInt(isDay.event[type]); 39 var current = parseInt(timezoneCurrent.charAt(0) + timezoneCurrent.charAt(2)) + parseInt(isDay.calendar[type]); 40 41 if(timezone.charAt(0) == timezoneCurrent.charAt(0)) 42 hours = ( to + (current * - 1)) ; 43 else 44 hours = to + (( current ) * (timezone.charAt(0) == '+' ? -1 : 1)) ; 45 46 return date.add({hours: hours}); 34 var timezone = this.timezone( tzId ); 35 36 if(!timezone) 37 return date; 38 39 date = this.normalizeDate(date, false, true); 40 41 return date.add({hours: (parseInt(timezone.charAt(0) + timezone.charAt(2)) + Timezone.diff( isDayLigth )) }); 47 42 }, 48 43 44 diff: function(isDayLigth){ 45 46 if( !parseInt( isDayLigth ) ){ 47 return 0; 48 }else{ 49 50 return (parseInt( isDayLigth ) == 1 ? 1 : -1); 51 } 52 53 }, 54 49 55 normalizeDate: function(date, current, inverse){ 56 50 57 var offsetDate = !!current ? this.currentOffset : date.getUTCOffset(); 51 58 return date.add({hours: (parseInt(offsetDate.charAt(0) + offsetDate.charAt(2)) * (!!inverse ? -1 : 1) )}); 59 52 60 }, 53 61 54 62 getDateMapDisponibility: function(date){ 63 55 64 return this.normalizeDate(date, false, true); 56 } 65 66 }, 67 68 getHour: function(time){ 69 70 return dateCalendar.formatDate( Timezone.normalizeDate( new Date( parseInt( time ) ), false, true) , User.preferences.hourFormat); 71 72 }, 73 74 formateHour: function(time){ 75 76 return dateCalendar.formatDate( new Date( parseInt( time ) ) , User.preferences.hourFormat); 77 78 }, 79 80 getDate: function( time, rang, isAllDay){ 81 82 return (new Date( parseInt( time ) - ((rang == 'end' && isAllDay && parseInt(isAllDay) == 1) ? 86400000 : 0) )).toString( User.preferences.dateFormat ); 83 84 }, 85 86 getDateObj: function( time, rang, isAllDay){ 87 88 return Timezone.normalizeDate(new Date( parseInt( time ) - ((rang == 'end' && isAllDay && parseInt(isAllDay) == 1) ? 86400000 : 0) ), false, true); 89 90 }, 91 92 getDateObjCalendar: function( time, rang, isAllDay){ 93 94 return Timezone.normalizeDate(new Date( parseInt( time ) - ((rang == 'end' && isAllDay && parseInt(isAllDay) == 1) ? 86400000 : 0)), false, true); 95 96 } 97 98 57 99 }
Note: See TracChangeset
for help on using the changeset viewer.