- Timestamp:
- 10/08/13 16:20:46 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.5/zpush/backend/expresso/providers/calendarProvider.php
r8032 r8232 30 30 { 31 31 $return = array(); 32 $criteria = CALENDAR_SYNC_SIGNED_CALENDARS ? array( 'filter' => array( 'AND' , array( '=' , 'type' , '0' ) , array( '=' , 'user' , $this->_uidnumber ))) : array( 'filter' => array ( 'AND' ,array( '=' , 'isOwner' , '1' ),array( '=' , 'type' , '0' ) , array( '=' , 'user' , $this->_uidnumber ))); 33 $sigs = Controller::find(array('concept' => 'calendarSignature'), array( 'id','calendar' ), $criteria); 34 35 if(Request::GetDeviceType() == 'iPhone' || Request::GetDeviceType() == 'iPad') 36 { 37 foreach($sigs as $sig) 38 { 39 $calendar = Controller::read( array( 'concept' => 'calendar' , 'id' => $sig['calendar'] )); 40 $tmpSig = array(); 41 $tmpSig["id"] = 'calendar'.$sig['id']; 42 $tmpSig["parent"] = 0; 43 $tmpSig["mod"] = $calendar['name']; 44 $return[] = $tmpSig; 45 } 46 } 47 else 48 { 49 $defaultCalendar = Controller::find(array('concept' => 'modulePreference'), array('value','id') , array('filter' => array( 'and' , array('=' , 'name' , 'defaultCalendar') , array('=' , 'module' , 'expressoCalendar') , array('=' , 'user' , $this->_uidnumber ) )) ); 50 51 if(isset($defaultCalendar[0])) //Prioriza agenda default de importaà §Ã£o pois o android so sincroniza a primeira agenda.52 { 53 foreach($sigs as $i => $sig) 54 { 55 if($sig['calendar'] == $defaultCalendar[0]['value']) 56 { 57 $calendar = Controller::read( array( 'concept' => 'calendar' , 'id' => $sig['calendar'] )); 58 $tmpSig = array(); 59 $tmpSig["id"] = 'calendar'.$sig['id']; 60 $tmpSig["parent"] = 0; 61 $tmpSig["mod"] = $calendar['name']; 62 $return[] = $tmpSig; 63 } 64 } 65 } 66 else 67 { 68 $sig = $sigs[0]; 69 $calendar = Controller::read( array( 'concept' => 'calendar' , 'id' => $sig['calendar'] )); 70 $tmpSig = array(); 71 $tmpSig["id"] = 'calendar'.$sig['id']; 72 $tmpSig["parent"] = 0; 73 $tmpSig["mod"] = $calendar['name']; 74 $return[] = $tmpSig; 75 76 } 32 $criteria = CALENDAR_SYNC_SIGNED_CALENDARS ? array( 'filter' => array( 'AND' , array( '=' , 'type' , '0' ) , array( '=' , 'user' , $this->_uidnumber ))) : array( 'filter' => array ( 'AND' ,array( '=' , 'isOwner' , '1' ),array( '=' , 'type' , '0' ) , array( '=' , 'user' , $this->_uidnumber ))); 33 $sigs = Controller::find(array('concept' => 'calendarSignature'), array( 'id','calendar' ), $criteria); 34 35 if(Request::GetDeviceType() == 'iPhone' || Request::GetDeviceType() == 'iPad') 36 { 37 foreach($sigs as $sig) 38 { 39 $calendar = Controller::read( array( 'concept' => 'calendar' , 'id' => $sig['calendar'] )); 40 $tmpSig = array(); 41 $tmpSig["id"] = 'calendar'.$sig['id']; 42 $tmpSig["parent"] = 0; 43 $tmpSig["mod"] = $calendar['name']; 44 $return[] = $tmpSig; 45 } 46 } 47 else 48 { 49 $defaultCalendar = Controller::find(array('concept' => 'modulePreference'), array('value','id') , array('filter' => array( 'and' , array('=' , 'name' , 'defaultCalendar') , array('=' , 'module' , 'expressoCalendar') , array('=' , 'user' , $this->_uidnumber ) )) ); 50 51 if(isset($defaultCalendar[0])) //Prioriza agenda default de importação pois o android so sincroniza a primeira agenda. 52 { 53 foreach($sigs as $i => $sig) 54 { 55 if($sig['calendar'] == $defaultCalendar[0]['value']) 56 { 57 $calendar = Controller::read( array( 'concept' => 'calendar' , 'id' => $sig['calendar'] )); 58 $tmpSig = array(); 59 $tmpSig["id"] = 'calendar'.$sig['id']; 60 $tmpSig["parent"] = 0; 61 $tmpSig["mod"] = $calendar['name']; 62 $return[] = $tmpSig; 63 } 64 } 65 } 66 else 67 { 68 $sig = $sigs[0]; 69 $calendar = Controller::read( array( 'concept' => 'calendar' , 'id' => $sig['calendar'] )); 70 $tmpSig = array(); 71 $tmpSig["id"] = 'calendar'.$sig['id']; 72 $tmpSig["parent"] = 0; 73 $tmpSig["mod"] = $calendar['name']; 74 $return[] = $tmpSig; 75 76 } 77 77 } 78 78 … … 154 154 public function ChangeFolder($folderid, $oldid, $displayname, $type) 155 155 { 156 return false; 156 if($oldid) 157 { 158 $idNumber = (int)str_replace('calendar' , '' , $oldid); 159 $calendarSignature = Controller::read( array( 'concept' => 'calendarSignature' , 'id' => $idNumber )); 160 161 Controller::update( array('concept' => 'calendar' , 'id' => $calendarSignature['calendar']), array( 'name' => $displayname) ); 162 163 return $this->StatFolder($oldid); 164 } 165 else 166 { 167 $cal = array('name' => $displayname, 168 'timezone' => 'America/Sao_Paulo', 169 'type' => '0' 170 ); 171 172 $calCreated = Controller::create(array('concept' => 'calendar'), $cal); 173 174 if(!$calCreated){ 175 return false; 176 } 177 178 $sig = array('user' => $_SESSION['wallet']['user']['uidNumber'], 179 'calendar' => $calCreated['id'], 180 'isOwner' => '1', 181 'dtstamp' => time() . '000', 182 'fontColor' => 'FFFFFF', 183 'backgroundColor' => '3366CC', 184 'borderColor' => '3366CC', 185 ); 186 187 $sigCreated = Controller::create(array('concept' => 'calendarSignature'), $sig); 188 189 if(!$sigCreated){ 190 return false; 191 } 192 else 193 { 194 $return = array(); 195 $return["id"] = 'calendar'.$calCreated; 196 $return["parent"] = 0; 197 $return["mod"] = $displayname; 198 return $return; 199 } 200 } 201 202 return false; 157 203 158 204 } … … 168 214 * @throws StatusException could throw specific SYNC_FSSTATUS_* exceptions 169 215 */ 170 public function DeleteFolder($id, $parentid) 171 { 172 return false; 216 public function DeleteFolder($id, $parent) 217 { 218 $interation = array(); 219 $idNumber = (int)str_replace('calendar' , '' , $id); 220 $calendarSignature = Controller::read( array( 'concept' => 'calendarSignature' , 'id' => $idNumber )); 221 222 $interation['calendar://' . $calendarSignature['calendar']] = false; 223 ob_start(); 224 $args = $interation; 225 include EXPRESSO_PATH.'/prototype/Sync.php'; 226 ob_end_clean(); 227 228 return true; 173 229 } 174 230 … … 302 358 break; 303 359 case 'd': 304 $mult = 3600;360 $mult = 1440; 305 361 break; 306 362 default: … … 316 372 case STATUS_ACCEPTED: 317 373 $message->busystatus = 2; 318 break;374 break; 319 375 case STATUS_TENTATIVE: 320 376 $message->busystatus = 1; … … 333 389 //------------------------------------------------------------------------------------------------------------// 334 390 335 /*336 * Sincronização de Recorrência337 */391 /* 392 * Sincronização de Recorrência 393 */ 338 394 $repeats = Controller::find(array('concept' => 'repeat'), null , array( 'filter' => array( 'and' , array( '=' , 'schedulable' , $schedulable['id'] ),array( '!=' , 'frequency' , 'none' ) ) )); 339 395 if(is_array($repeats) && count($repeats) > 0) … … 359 415 360 416 if($repeat['endTime']) 361 $recur->until = (int) substr($repeat['endTime'], 0, -3);417 $recur->until = (int) substr($repeat['endTime'], 0, -3); 362 418 363 419 $recur->interval = $repeat['interval'] ? $repeat['interval'] : 1; … … 558 614 $schedulable['timezone'] = $calendar['timezone']; 559 615 560 561 $sv = new DateTime('@'.($message->starttime + $GMT_CEL), $calendarSignatureTimezone); 562 563 if($sv->format('I') == 0) 564 $schedulable['startTime'] = $schedulable['startTime'] - 3600000; 565 566 $ev = new DateTime('@'.($message->endtime + $GMT_CEL), $calendarSignatureTimezone); 567 568 if($ev->format('I') == 0) 569 $schedulable['endTime'] = $schedulable['endTime'] - 3600000; 570 616 617 $sv = new DateTime('@'.($message->starttime + $GMT_CEL), $calendarSignatureTimezone); 618 619 if($sv->format('I') == 0) 620 $schedulable['startTime'] = $schedulable['startTime'] - 3600000; 621 622 $ev = new DateTime('@'.($message->endtime + $GMT_CEL), $calendarSignatureTimezone); 623 624 if($ev->format('I') == 0) 625 $schedulable['endTime'] = $schedulable['endTime'] - 3600000; 626 571 627 $schedulable['allDay'] = $message->alldayevent; 572 628 $schedulable['description'] = $message->body; … … 741 797 if($v['user']['id'] == $this->_uidnumber ) 742 798 { 743 $schedulable['participants'][$i]['status'] = $this->formatBusy($message->busystatus);799 $schedulable['participants'][$i]['status'] = $this->formatBusy($message->busystatus); 744 800 } 745 801 } … … 779 835 $schedulable['startTime'] = (($message->starttime + $GMT_CEL) + ($calendarSignatureTimezone->getOffset(new DateTime('@'.($message->starttime + $GMT_CEL), new DateTimeZone('UTC'))) * -1) ) *1000; //$message->starttime * 1000; 780 836 $schedulable['endTime'] = (($message->endtime + $GMT_CEL) + ($calendarSignatureTimezone->getOffset(new DateTime('@'.($message->endtime + $GMT_CEL), new DateTimeZone('UTC')))* -1)) *1000;//$message->endtime * 1000; 781 782 $sv = new DateTime('@'.($message->starttime + $GMT_CEL), $calendarSignatureTimezone); 783 784 if($sv->format('I') == 0) 785 $schedulable['startTime'] = $schedulable['startTime'] - 3600000; 786 787 $ev = new DateTime('@'.($message->endtime + $GMT_CEL), $calendarSignatureTimezone); 788 789 if($ev->format('I') == 0) 790 $schedulable['endTime'] = $schedulable['endTime'] - 3600000; 791 837 838 $sv = new DateTime('@'.($message->starttime + $GMT_CEL), $calendarSignatureTimezone); 839 840 if($sv->format('I') == 0) 841 $schedulable['startTime'] = $schedulable['startTime'] - 3600000; 842 843 $ev = new DateTime('@'.($message->endtime + $GMT_CEL), $calendarSignatureTimezone); 844 845 if($ev->format('I') == 0) 846 $schedulable['endTime'] = $schedulable['endTime'] - 3600000; 847 792 848 $schedulable['timezone'] = $calendar['timezone']; 793 849 … … 803 859 $participant['isOrganizer'] = '1'; 804 860 $participant['acl'] = 'rowi'; 805 $participant['status'] = '1'; 861 $participant['status'] = '1'; 806 862 807 863 if($message->organizeremail) … … 1021 1077 if($v['user']['id'] == $this->_uidnumber && $v['user']['isOrganizer'] == '1') 1022 1078 { 1023 $delete = true;1079 $delete = true; 1024 1080 } 1025 1081 } … … 1262 1318 break; 1263 1319 case 0: 1264 return STATUS_UNANSWERED;1320 return STATUS_UNANSWERED; 1265 1321 break; 1266 1322 }
Note: See TracChangeset
for help on using the changeset viewer.