Changeset 5437
- Timestamp:
- 01/27/12 15:37:21 (12 years ago)
- Location:
- trunk/prototype
- Files:
-
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/prototype/Sync.php
r5399 r5437 133 133 foreach( $result as $ii => $tx ) 134 134 { 135 if( !isset($tx['order']) ) 136 continue; 137 135 138 $oldId = $oldIds[ $tx['order'] ]; 136 139 … … 156 159 157 160 Controller::closeAll(); 158 159 // 160 // 161 // print $data[$linkName] . ": ";162 // print_r( $synced);163 // 164 // 161 162 // ob_start(); 163 // print "\n"; 164 // print "result: "; 165 // print_r( $result ); 166 // $output = ob_get_clean(); 167 // file_put_contents( "/tmp/prototype.log", $output , FILE_APPEND ); -
trunk/prototype/api/config.php
r5415 r5437 31 31 32 32 return (isset($_SESSION['wallet'][$service][$config])) ? $_SESSION['wallet'][$service][$config] : false; 33 } 34 35 static function get( $concept , $config = false , $module = false ) 36 { 37 $load = parse_ini_file( ROOTPATH."/config/$concept.ini", true ); 38 39 if($config === false) return $load; 40 41 return (isset($load[$config])) ? $load[$config] : false; 33 42 } 34 43 -
trunk/prototype/api/controller.php
r5415 r5437 63 63 return self::$cache->put( $id, $data, $expires, $compressed ); 64 64 } 65 66 public static function put( $URI, $data, $txIds = false )67 {68 try69 {70 $URI = self::serviceName( $URI );71 72 if( $commit = !$txIds )73 $txIds = array();74 75 if( !isset( self::$tx[ $URI['service'] ] ) )76 {77 self::call( 'begin', $URI );78 self::$tx[ $txIds[] = $URI['service'] ] = array();79 }80 81 $method = $data ? isset( $data['id'] ) ?82 'update' : 'create' : 'delete';83 84 $links = self::links( $URI['concept'] );85 86 $Tx = array( 'order' => self::$txID++ );87 88 $postpone = array();89 90 if( $data )91 {92 $URI['id'] = isset( $data['id'] ) ? $data['id'] : false;93 94 foreach( $links as $linkName => $linkTarget )95 {96 if( isset( $data[$linkName] ) && is_array( $data[$linkName] ) )97 {98 if( self::isConcept( $linkName ) )99 $data[$linkName] = self::put( array( 'concept' => $linkTarget ), $data[$linkName], &$txIds );100 else101 $postpone[$linkTarget] = $data[$linkName];102 }103 }104 }105 else106 $URI['id'] = isset( $data['id'] ) ? $data['id'] : $URI['id'];107 108 $result = Controller::call( $method, $URI, $data, false, false, true );109 110 if( !is_bool( $result ) && !is_string( $result ) && isset( $result['id'] ) )111 $URI['id'] = $result['id'];112 113 self::$tx[ $URI['service'] ][] = array_merge( $Tx, array( 'id' => $URI['id'], 'concept' => $URI['concept'], 'method' => $method, 'service' => $URI['service'], 'rollback' => !!!$result ) );114 115 foreach( $postpone as $linkTarget => $dt )116 foreach( $dt as $ii => $value )117 {118 if( !is_array( $value ) )119 $value = array( 'id' => $value );120 121 $value[ $URI['concept'] ] = $URI['id'];122 123 self::put( array( 'concept' => $linkTarget ), $value, &$txIds );124 }125 126 if( $commit )127 {128 $result = array();129 130 for( $i = count( $txIds ) - 1; $i >= 0; $i-- )131 {132 $currentTx = self::$tx[ $txIds[$i] ];133 unset( self::$tx[ $txIds[$i] ] );134 135 if( !self::commit( array( 'service' => $txIds[$i] ), $currentTx ) )136 {137 self::rollback( array( 'service' => $txIds[$i] ), $currentTx );138 139 foreach( $currentTx as $i => $st )140 $currentTx[$i][ 'rollback' ] = true;141 }142 143 $result = array_merge( $result, $currentTx );144 }145 146 self::$txID = 0;147 148 return( $result );149 }150 151 }152 catch( Exception $e )153 {154 if( !self::fallback( $e ) )155 self::closeAll();156 157 return( false );158 }159 160 return( $URI['id'] );161 }162 163 public static function get()164 {165 166 }167 65 168 66 public static function find( $URI, $params = false, $criteria = false ) … … 462 360 $result = array( $eventType => array() ); 463 361 464 362 if( is_array( $commitList ) ) 465 363 foreach( $commitList as $i => $tx ) 466 364 { … … 536 434 537 435 //TODO: Compatibilizar as configs relativas aos modulos, adicionando os mesmos nas options passadas 538 public static function call( $method, $URI, $properties = false, $options = false, $service = false , $noTX = false)436 public static function call( $method, $URI, $properties = false, $options = false, $service = false ) 539 437 { 540 438 try … … 550 448 return( empty($params['properties']) ? false : $params['properties'] ); 551 449 450 451 552 452 if( $params && !$params['service'] ) 553 453 { … … 559 459 if( isset($params['URI']['service']) ) 560 460 { 561 if( $commit = (!isset(self::$tx[ $params['URI']['service'] ]) && ( $method === 'create' || 562 $method === 'update' || 563 $method === 'delete' )) ) 461 if( $method === 'create' || $method === 'update' || $method === 'delete' ) 564 462 { 565 self::call( 'begin', $params['URI'] ); 566 self::$tx[ $params['URI']['service'] ] = true; 463 if( $commit = !isset(self::$tx[ $params['URI']['service'] ]) ) 464 { 465 self::call( 'begin', $params['URI'] ); 466 } 467 468 $TX = array(); 567 469 } 568 470 … … 573 475 if( $params['service'] ) 574 476 switch( $method ) 575 {477 { 576 478 case 'find': $return = $params['service']->find( $params['URI'], $params['properties'], $params['criteria'] ); break; 577 479 … … 596 498 case 'parse': $return = $params['service']->parse( $params['properties'], $params['criteria'] ); break; 597 499 500 case 'analize': $return = $params['service']->analize( $params['properties'], $params['criteria'] ); break; 501 598 502 case 'format': $return = $params['service']->format( $params['properties'], $params['criteria'] ); break; 599 600 default: $return = $params['service']->$method( $params['properties'], $params['criteria'] ); break;601 }503 504 default : $return = $params['service']->$method( $params['properties'], $params['criteria'] ); 505 } 602 506 603 507 if( isset($return) && $return !== false ) … … 605 509 606 510 if( isset($params['URI']['service']) ) 607 {608 511 if( !self::fire( 'after', $method, $params, $original, true ) ) 609 512 return( empty($params['properties']) ? false : $params['properties'] ); 610 513 611 if( $commit ) 514 if( isset($URI['concept']) ) 515 self::fire( 'after', $method, $params, $original ); 516 517 if( empty($params['properties']) ) 518 $params['properties'] = false; 519 520 if( isset( $TX ) ) 521 { 522 $TX['rollback'] = !!!$params['properties']; 523 524 if( $params['properties'] && isset($params['properties']['id']) ) 525 $TX['id'] = $params['properties']['id']; 526 527 self::$tx[ $params['URI']['service'] ][] = array_merge( $TX, $original['URI'], array( 'service' => $params['URI']['service'], 'method' => $method ) ); 528 529 if( isset($commit) && $commit ) 612 530 { 613 531 if( !self::call( 'commit', $params['URI'], false, self::$tx[ $params['URI']['service'] ] ) ) … … 617 535 } 618 536 } 619 620 if( isset($URI['concept']) && !self::fire( 'after', $method, $params, $original ) )621 return( empty($params['properties']) ? false : $params['properties'] );622 537 } 623 538 catch( Exception $e ) … … 629 544 } 630 545 631 return( empty($params['properties']) ? false : $params['properties'] );546 return( $params['properties'] ); 632 547 } 633 548 … … 637 552 return( true ); 638 553 } 554 555 public static function put( $URI, $data, $txIds = false ) 556 { 557 try 558 { 559 $URI = self::serviceName( $URI ); 560 561 if( $commit = !$txIds ) 562 $txIds = array(); 563 564 if( !isset( self::$tx[ $URI['service'] ] ) ) 565 { 566 self::call( 'begin', $URI ); 567 self::$tx[ $txIds[] = $URI['service'] ] = array(); 568 } 569 570 $method = $data ? isset( $data['id'] ) ? 571 'update' : 'create' : 'delete'; 572 573 $links = self::links( $URI['concept'] ); 574 575 $order = self::$txID++; 576 577 $postpone = array(); 578 579 if( $data ) 580 { 581 $URI['id'] = isset( $data['id'] ) ? $data['id'] : false; 582 583 foreach( $links as $linkName => $linkTarget ) 584 { 585 if( isset( $data[$linkName] ) && is_array( $data[$linkName] ) ) 586 { 587 if( self::isConcept( $linkName ) ) 588 $data[$linkName] = self::put( array( 'concept' => $linkTarget ), $data[$linkName], &$txIds ); 589 else 590 $postpone[$linkTarget] = $data[$linkName]; 591 } 592 } 593 } 594 else 595 $URI['id'] = isset( $data['id'] ) ? $data['id'] : $URI['id']; 596 597 $result = Controller::call( $method, $URI, $data, false, false, true ); 598 599 if( !is_bool( $result ) && !is_string( $result ) && isset( $result['id'] ) ) 600 $URI['id'] = $result['id']; 601 602 self::$tx[ $URI['service'] ][ count(self::$tx[ $URI['service'] ]) - 1 ]['order'] = $order; 603 self::$tx[ $URI['service'] ][ count(self::$tx[ $URI['service'] ]) - 1 ]['id'] = $URI['id']; 604 605 foreach( $postpone as $linkTarget => $dt ) 606 foreach( $dt as $ii => $value ) 607 { 608 if( !is_array( $value ) ) 609 $value = array( 'id' => $value ); 610 611 $value[ $URI['concept'] ] = $URI['id']; 612 613 self::put( array( 'concept' => $linkTarget ), $value, &$txIds ); 614 } 615 616 if( $commit ) 617 { 618 $result = array(); 619 620 for( $i = count( $txIds ) - 1; $i >= 0; $i-- ) 621 { 622 $currentTx = self::$tx[ $txIds[$i] ]; 623 unset( self::$tx[ $txIds[$i] ] ); 624 625 if( !self::commit( array( 'service' => $txIds[$i] ), $currentTx ) ) 626 { 627 self::rollback( array( 'service' => $txIds[$i] ), $currentTx ); 628 629 foreach( $currentTx as $i => $st ) 630 $currentTx[$i][ 'rollback' ] = true; 631 } 632 633 $result = array_merge( $result, $currentTx ); 634 } 635 636 self::$txID = 0; 637 638 return( $result ); 639 } 640 641 } 642 catch( Exception $e ) 643 { 644 if( !self::fallback( $e ) ) 645 self::closeAll(); 646 647 return( false ); 648 } 649 650 return( $URI['id'] ); 651 } 652 653 public static function get() 654 { 655 656 } 639 657 } 640 658 -
trunk/prototype/api/datalayer.js
r5399 r5437 544 544 clearQ: function( concept, ids ){ 545 545 546 //var current = this.check( ':current', concept || false );546 var current = this.check( ':current', concept || false ); 547 547 var diffs = this.check( ':diff', concept || false ); 548 548 549 549 if( !ids ) 550 /* current =*/diffs = {};550 current = diffs = {}; 551 551 else 552 552 { … … 556 556 for( var i = 0; i < ids.length; i++ ) 557 557 { 558 //delete current[ ids[i] ];558 delete current[ ids[i] ]; 559 559 delete diffs[ ids[i] ]; 560 560 } 561 561 } 562 562 563 //this.store( ':current', concept, current );563 this.store( ':current', concept, current ); 564 564 this.store( ':diff', concept, diffs ); 565 565 }, -
trunk/prototype/api/newcontroller.php
r5341 r5437 112 112 public static function create( $concept, $params, $filter = false, $options = false ) 113 113 { 114 return self::call( 'create', $concept, $params, $filter, $options ) 114 return self::call( 'create', $concept, $params, $filter, $options ); 115 115 } 116 116 -
trunk/prototype/config/alarm.ini
r5399 r5437 1 1 service = PostgreSQL 2 PostgreSQL.concept = calendar_alarm 2 3 3 4 [links] … … 6 7 [before.find] 7 8 dayAlarm = modules/calendar/interceptors/DBMapping.php 8 encodeURIAlarm = modules/calendar/interceptors/DBMapping.php9 encodeFindConcept = modules/calendar/interceptors/DBMapping.php10 9 11 10 [after.find] 12 decodeFindConcept = modules/calendar/interceptors/DBMapping.php13 11 decodeSignatureAlarmType = modules/calendar/interceptors/DBMapping.php 14 12 15 13 [before.create] 16 encodeURIAlarm = modules/calendar/interceptors/DBMapping.php17 14 encodeCreateAlarm = modules/calendar/interceptors/DBMapping.php 18 15 19 16 [PostgreSQL.before.update] 20 encodeURIAlarm = modules/calendar/interceptors/DBMapping.php21 17 encodeUpdateAlarm = modules/calendar/interceptors/DBMapping.php 22 encodeUpdateConcept = modules/calendar/interceptors/DBMapping.php23 18 24 25 [before.delete] 26 encodeURIAlarm = modules/calendar/interceptors/DBMapping.php 19 [PostgreSQL.mapping] 20 id = "id" 21 type = "action_id" 22 time = "time" 23 sent = "sent" 24 rangeStart = "range_start" 25 rangeEnd = "range_end" 26 unit = "unit" 27 participant = "participant_id" 28 schedulable = "object_id" -
trunk/prototype/config/calendar.ini
r5399 r5437 1 1 service = PostgreSQL 2 PostgreSQL.concept = calendar 2 3 3 4 [links] … … 5 6 6 7 [before.create] 7 encodeURICalendar = modules/calendar/interceptors/DBMapping.php8 encodeCreateConcept = modules/calendar/interceptors/DBMapping.php9 8 verifyCalendarLocation = modules/calendar/interceptors/DBMapping.php 10 9 davcalCreateCollection = modules/calendar/interceptors/DBMapping.php 11 10 12 11 [before.update] 13 encodeURICalendar = modules/calendar/interceptors/DBMapping.php14 encodeUpdateConcept = modules/calendar/interceptors/DBMapping.php15 setCalendarLocation = modules/calendar/interceptors/DBMapping.php16 12 davcalUpdateCollection = modules/calendar/interceptors/DBMapping.php 17 13 18 19 14 [before.delete] 20 encodeURICalendar = modules/calendar/interceptors/DBMapping.php21 15 davcalDeleteCollection = modules/calendar/interceptors/DBMapping.php 22 16 23 [before.find]24 encodeURICalendar = modules/calendar/interceptors/DBMapping.php25 encodeFindConcept = modules/calendar/interceptors/DBMapping.php26 17 27 [after.find] 28 decodeFindConcept = modules/calendar/interceptors/DBMapping.php 29 30 31 [before.read] 32 encodeURICalendar = modules/calendar/interceptors/DBMapping.php 33 encodeReadConcept = modules/calendar/interceptors/DBMapping.php 34 35 [after.read] 36 decodeReadConcept = modules/calendar/interceptors/DBMapping.php 18 [PostgreSQL.mapping] 19 id = "id" 20 name = "name" 21 location = "location" 22 timezone = "tzid" 23 defaultDuration = "duration" 24 description = "description" 25 dtstamp = "dtstamp" -
trunk/prototype/config/calendarSignature.ini
r5399 r5437 1 1 service = PostgreSQL 2 PostgreSQL.concept = calendar_signature 2 3 3 4 [links] … … 5 6 calendarSignatureAlarms = calendarSignatureAlarm 6 7 7 [PostgreSQL.before.create]8 encodeURICalendarSignature = modules/calendar/interceptors/DBMapping.php9 encodeCreateConcept = modules/calendar/interceptors/DBMapping.php10 11 [before.update]12 encodeURICalendarSignature = modules/calendar/interceptors/DBMapping.php13 encodeUpdateConcept = modules/calendar/interceptors/DBMapping.php14 15 8 [before.delete] 16 9 deleteCalendarSignatureDependences = modules/calendar/interceptors/DBMapping.php 17 encodeURICalendarSignature = modules/calendar/interceptors/DBMapping.php18 19 [before.find]20 encodeURICalendarSignature = modules/calendar/interceptors/DBMapping.php21 encodeFindConcept = modules/calendar/interceptors/DBMapping.php22 10 23 11 [after.find] 24 decodeFindConcept = modules/calendar/interceptors/DBMapping.php25 12 createDefaultSignature = modules/calendar/interceptors/DBMapping.php 26 13 deepnessFindCalendarSignature = modules/calendar/interceptors/DBMapping.php 27 14 28 [before.deleteAll] 29 encodeURICalendarSignature = modules/calendar/interceptors/DBMapping.php 30 encodeDeleteAllConcept = modules/calendar/interceptors/DBMapping.php 15 [after.read] 16 deepnessReadCalendarSignature = modules/calendar/interceptors/DBMapping.php 31 17 32 [before.read] 33 encodeURICalendarSignature = modules/calendar/interceptors/DBMapping.php 34 encodeReadConcept = modules/calendar/interceptors/DBMapping.php 35 36 [after.read] 37 decodeReadConcept = modules/calendar/interceptors/DBMapping.php 38 deepnessReadCalendarSignature = modules/calendar/interceptors/DBMapping.php 18 [PostgreSQL.mapping] 19 id = id 20 user = user_uidnumber 21 calendar = calendar_id 22 isOwner = is_owner 23 msgAdd = msg_add 24 msgCancel = msg_cancel 25 msgUpdate = msg_update 26 msgReply = msg_reply 27 msgAlarm = msg_alarms 28 dtstamp = dtstamp 29 fontColor = font_color 30 backgroundColor = background_color 31 borderColor = border_color -
trunk/prototype/config/calendarSignatureAlarm.ini
r5399 r5437 1 1 service = PostgreSQL 2 PostgreSQL.concept = calendar_signature_alarm 2 3 3 4 [links] 4 5 calendarSignature = calendarSignature 5 6 6 [before.find]7 encodeURICalendarSignatureAlarm = modules/calendar/interceptors/DBMapping.php8 encodeFindConcept = modules/calendar/interceptors/DBMapping.php9 10 7 [after.find] 11 decodeFindConcept = modules/calendar/interceptors/DBMapping.php12 8 decodeSignatureAlarmType = modules/calendar/interceptors/DBMapping.php 13 9 14 10 [before.update] 15 encodeURICalendarSignatureAlarm = modules/calendar/interceptors/DBMapping.php16 11 encodeSignatureAlarmType = modules/calendar/interceptors/DBMapping.php 17 12 encodeUpdateConcept = modules/calendar/interceptors/DBMapping.php 18 13 19 [before.read]20 encodeURICalendarSignatureAlarm = modules/calendar/interceptors/DBMapping.php21 encodeReadConcept = modules/calendar/interceptors/DBMapping.php22 23 [after.read]24 decodeReadConcept = modules/calendar/interceptors/DBMapping.php25 26 14 [before.create] 27 encodeURICalendarSignatureAlarm = modules/calendar/interceptors/DBMapping.php28 15 encodeSignatureAlarmType = modules/calendar/interceptors/DBMapping.php 29 16 encodeCreateConcept = modules/calendar/interceptors/DBMapping.php … … 31 18 [before.delete] 32 19 encodeURICalendarSignatureAlarm = modules/calendar/interceptors/DBMapping.php 20 21 [PostgreSQL.mapping] 22 id = id 23 type = action_id 24 time = time 25 unit = unit 26 calendarSignature = calendar_signature_id -
trunk/prototype/config/calendarToSchedulable.ini
r5399 r5437 1 1 service = PostgreSQL 2 PostgreSQL.concept = calendar_to_calendar_object 2 3 3 [before.create] 4 encodeURICalendarToSchedulable = modules/calendar/interceptors/DBMapping.php 5 encodeCreateConcept = modules/calendar/interceptors/DBMapping.php 6 7 [after.create] 4 [PostgreSQL.after.commit] 8 5 createCalendarToSchedulable = modules/calendar/interceptors/DAViCalAdapter.php 9 6 10 [before.update] 11 encodeURICalendarToSchedulable = modules/calendar/interceptors/DBMapping.php 12 encodeUpdateConcept = modules/calendar/interceptors/DBMapping.php 13 14 [before.delete] 15 encodeURICalendarToSchedulable = modules/calendar/interceptors/DBMapping.php 16 17 [before.find] 18 encodeURICalendarToSchedulable = modules/calendar/interceptors/DBMapping.php 19 encodeFindConcept = modules/calendar/interceptors/DBMapping.php 20 21 [after.find] 22 decodeFindConcept = modules/calendar/interceptors/DBMapping.php 23 24 [before.deleteAll] 25 encodeURICalendarToSchedulable = modules/calendar/interceptors/DBMapping.php 26 encodeDeleteAllConcept = modules/calendar/interceptors/DBMapping.php 7 [PostgreSQL.mapping] 8 id = id 9 calendar = calendar_id 10 schedulable = calendar_object_id -
trunk/prototype/config/expressoCalendar.ini
r5413 r5437 1 1 folder = "calendar" 2 3 useCaldav = false 2 useCaldav = true 4 3 5 4 ;Utilizar ou não caldav {TRUE or FALSE} -
trunk/prototype/config/modulePreference.ini
r5384 r5437 1 1 service = PostgreSQL 2 PostgreSQL.concept = module_preference 2 3 3 [before.read]4 encodeURImodulePreference = modules/calendar/interceptors/DBMapping.php5 encodeReadConcept = modules/calendar/interceptors/DBMapping.php6 4 7 [after.read] 8 decodeReadConcept = modules/calendar/interceptors/DBMapping.php 9 10 [before.create] 11 encodeURImodulePreference = modules/calendar/interceptors/DBMapping.php 12 encodeCreateConcept = modules/calendar/interceptors/DBMapping.php 13 14 [before.delete] 15 encodeURImodulePreference = modules/calendar/interceptors/DBMapping.php 16 17 [before.find] 18 encodeURImodulePreference = modules/calendar/interceptors/DBMapping.php 19 encodeFindConcept = modules/calendar/interceptors/DBMapping.php 20 21 [after.find] 22 decodeFindConcept = modules/calendar/interceptors/DBMapping.php 23 24 [before.update] 25 encodeURImodulePreference = modules/calendar/interceptors/DBMapping.php 26 encodeUpdateConcept = modules/calendar/interceptors/DBMapping.php 27 28 [before.replace] 29 encodeURImodulePreference = modules/calendar/interceptors/DBMapping.php 30 encodeReplaceConcept = modules/calendar/interceptors/DBMapping.php 5 [PostgreSQL.mapping] 6 id = id 7 user = user_uidnumber 8 value = value 9 name = name 10 module = module -
trunk/prototype/config/participant.ini
r5399 r5437 1 1 service = PostgreSQL 2 PostgreSQL.concept = calendar_participant 2 3 3 4 [links] … … 6 7 alarms = alarm 7 8 8 [before.read]9 encodeURIParticipant = modules/calendar/interceptors/DBMapping.php10 encodeReadConcept = modules/calendar/interceptors/DBMapping.php11 12 [after.read]13 decodeReadConcept = modules/calendar/interceptors/DBMapping.php14 deepnessReadParticipant = modules/calendar/interceptors/DBMapping.php15 16 [before.create]17 encodeURIParticipant = modules/calendar/interceptors/DBMapping.php18 encodeCreateConcept = modules/calendar/interceptors/DBMapping.php19 20 [before.find]21 encodeURIParticipant = modules/calendar/interceptors/DBMapping.php22 encodeFindParticipant = modules/calendar/interceptors/DBMapping.php23 24 [after.find]25 decodeFindConcept = modules/calendar/interceptors/DBMapping.php26 deepnessFindParticipant = modules/calendar/interceptors/DBMapping.php27 28 [before.update]29 encodeURIParticipant = modules/calendar/interceptors/DBMapping.php30 encodeUpdateConcept = modules/calendar/interceptors/DBMapping.php31 32 [before.replace]33 encodeURIParticipant = modules/calendar/interceptors/DBMapping.php34 encodeReplaceConcept = modules/calendar/interceptors/DBMapping.php35 36 [before.delete]37 encodeURIParticipant = modules/calendar/interceptors/DBMapping.php38 deleteParticipant = modules/calendar/interceptors/Notifications.php39 40 9 [after.commit] 41 10 commitParticipant = modules/calendar/interceptors/Notifications.php 11 12 [PostgreSQL.mapping] 13 id = id 14 delegatedTo = delegated_to 15 isOrganizer = is_organizer 16 isExternal = is_external 17 status = participant_status_id 18 schedulable = object_id 19 user = user_info_id -
trunk/prototype/config/preference.ini
r5341 r5437 1 1 service = PostgreSQL 2 3 [before.read]4 5 [after.read]6 7 [before.create]8 encodeCreatePreference = modules/core/interceptors/DBMapping.php9 10 11 [before.find]12 13 [after.find] -
trunk/prototype/config/repeat.ini
r5399 r5437 4 4 schedulable = schedulable 5 5 6 [before.read]7 encodeURIRepeat = modules/calendar/interceptors/DBMapping.php8 9 [after.read]10 decodeReadConcept = modules/calendar/interceptors/DBMapping.php11 12 [before.create]13 encodeURIRepeat = modules/calendar/interceptors/DBMapping.php14 encodeCreateConcept = modules/calendar/interceptors/DBMapping.php15 16 [before.update]17 encodeURIRepeat = modules/calendar/interceptors/DBMapping.php18 encodeUpdateConcept = modules/calendar/interceptors/DBMapping.php -
trunk/prototype/config/schedulable.ini
r5399 r5437 1 1 service = PostgreSQL 2 PostgreSQL.concept = calendar_object 2 3 3 4 [links] … … 6 7 7 8 [before.create] 8 encodeURISchedulable = modules/calendar/interceptors/DBMapping.php9 9 encodeCreateSchedulable = modules/calendar/interceptors/DBMapping.php 10 10 … … 13 13 14 14 [before.find] 15 encodeURISchedulable = modules/calendar/interceptors/DBMapping.php 16 encodeFindSchedulable = modules/calendar/interceptors/DBMapping.php 15 findSchedulable = modules/calendar/interceptors/DBMapping.php 17 16 18 17 [after.find] 19 encodeURISchedulable = modules/calendar/interceptors/DBMapping.php20 decodeFindSchedulable = modules/calendar/interceptors/DBMapping.php21 18 deepnessFindEvent = modules/calendar/interceptors/DBMapping.php 22 19 23 20 [before.update] 24 encodeURISchedulable = modules/calendar/interceptors/DBMapping.php25 21 updateCalendar = modules/calendar/interceptors/DBMapping.php 26 22 updateEvent = modules/calendar/interceptors/Notifications.php … … 30 26 putEvent = modules/calendar/interceptors/DBMapping.php 31 27 32 [before.read]33 encodeURISchedulable = modules/calendar/interceptors/DBMapping.php34 encodeReadConcept = modules/calendar/interceptors/DBMapping.php35 36 37 28 [after.read] 38 decodeReadConcept = modules/calendar/interceptors/DBMapping.php39 29 deepnessReadEvent = modules/calendar/interceptors/DBMapping.php 40 30 41 31 [before.delete] 42 encodeURISchedulable = modules/calendar/interceptors/DBMapping.php43 32 deleteSchedulable = modules/calendar/interceptors/DBMapping.php 44 33 deleteEvent = modules/calendar/interceptors/Notifications.php 45 34 46 [before.deleteAll] 47 encodeURISchedulable = modules/calendar/interceptors/DBMapping.php 48 encodeDeleteAllConcept = modules/calendar/interceptors/DBMapping.php 35 [PostgreSQL.mapping] 36 id = id 37 uid = cal_uid 38 type = type_id 39 startTime = dtstart 40 summary = summary 41 description = description 42 endTime = dtend 43 location = location 44 allDay = allday 45 transparent = transp 46 class = class_id 47 repeat = repeat 48 rangeStart = range_start 49 rangeEnd = range_end 50 lastUpdate = last_update 51 dtstamp = dtstamp 52 sequence = sequence 53 timezone = tzid -
trunk/prototype/config/user.ini
r5399 r5437 7 7 8 8 service = OpenLDAP 9 PostgreSQL.concept = calendar_ex_participant 9 10 10 11 [links] 11 12 participants = participant 12 13 13 [OpenLDAP.after.read]14 decodeReadUser = modules/calendar/interceptors/LDAPMapping.php15 16 [PostgreSQL.before.read]17 encodeURIUser = modules/calendar/interceptors/DBMapping.php18 19 14 [PostgreSQL.before.create] 20 encodeURIUser = modules/calendar/interceptors/DBMapping.php21 encodeCreateConcept = modules/calendar/interceptors/DBMapping.php22 15 insertOwnerLink = modules/calendar/interceptors/DBMapping.php 23 24 [PostgreSQL.before.update]25 encodeURIUser = modules/calendar/interceptors/DBMapping.php26 encodeUpdateConcept = modules/calendar/interceptors/DBMapping.php27 28 [PostgreSQL.before.find]29 encodeURIUser = modules/calendar/interceptors/DBMapping.php30 encodeFindConcept = modules/calendar/interceptors/DBMapping.php31 32 [PostgreSQL.after.find]33 decodeFindConcept = modules/calendar/interceptors/DBMapping.php34 16 35 17 [OpenLDAP.before.create] … … 41 23 42 24 [OpenLDAP.after.find] 43 decodeFindUser = modules/calendar/interceptors/LDAPMapping.php44 25 findExternalPaticipants = modules/calendar/interceptors/DBMapping.php 45 26 … … 49 30 [before.create] 50 31 encodeServiceUser = modules/calendar/interceptors/DBMapping.php 32 33 [PostgreSQL.mapping] 34 id = id 35 name = name 36 mail = mail 37 owner = owner 38 39 [OpenLDAP.mapping] 40 id = uidNumber 41 name = cn 42 mail = mail 43 uid = uid 44 givenName = givenName 45 sn = sn 46 displayName = displayName 47 mailAlternateAddress = mailAlternateAddress 48 phpgwAccountStatus = phpgwAccountStatus 49 accountStatus = accountStatus 50 objectClass = objectClass 51 phpgwAccountType = phpgwAccountType 52 phpgwAccountVisible = phpgwAccountVisible -
trunk/prototype/modules/calendar/interceptors/DAViCalAdapter.php
r5399 r5437 22 22 * @return void 23 23 * @access public 24 */ 25 public function createCalendarToSchedulable(&$uri , &$result , &$ criteria , $original)24 */ 25 public function createCalendarToSchedulable(&$uri , &$result , &$data , $original) 26 26 { 27 if(Config::module('useCaldav')) 28 { 29 ob_start(); 30 $schedulable = Controller::read( array( 'concept' => 'schedulable' , 'id' => $original['properties']['schedulable'] ) , null , array('deepness' => '2') ); 31 $schedulable['URI']['concept'] = 'schedulable'; 32 $calendar = Controller::read( array( 'concept' => 'calendar' , 'id' => $original['properties']['calendar'] ),array('timezone','name','location')); 33 $ical = Controller::format( array( 'service' => 'iCal' ) , array($schedulable) , array('defaultTZI' => $calendar['timezone'])); 34 DAViCalAdapter::putIcal($ical , array('uid' => $schedulable['uid'] , 'collection' => $calendar['location'] )); 35 ob_end_clean(); 27 foreach ($data as $i => $concept) 28 { 29 if($concept['concept'] === 'calendarToSchedulable') 30 { 31 if(Config::module('useCaldav')) 32 { 33 ob_start(); 34 $calendarToschedulable = Controller::read( array( 'concept' => 'calendarToSchedulable' , 'id' => $concept['id'] )); 35 if($calendarToschedulable) 36 { 37 $schedulable = Controller::read( array( 'concept' => 'schedulable' , 'id' => $calendarToschedulable['schedulable'] ) , null , array('deepness' => '2') ); 38 $calendar = Controller::read( array( 'concept' => 'calendar' , 'id' => $calendarToschedulable['calendar'] ),array('timezone','name','location')); 39 $ical = Controller::format( array( 'service' => 'iCal' ) , array($schedulable) , array('defaultTZI' => $calendar['timezone'])); 40 DAViCalAdapter::putIcal($ical , array('uid' => $schedulable['uid'] , 'collection' => $calendar['location'] )); 41 } 42 ob_end_clean(); 43 } 44 } 45 36 46 } 37 47 } … … 171 181 { 172 182 ob_start(); 173 require_once ROOTPATH.'/plugins/davicalCliente/caldav-client-v2.php'; 183 require_once ROOTPATH.'/plugins/davicalCliente/caldav-client-v2.php'; 174 184 $cal = new CalDAVClient( Config::service( 'CalDAV' , 'url' ).'/'.Config::me( 'uid' ).'/', Config::me( 'uid' ), $_SESSION['wallet']['user']['password']); 175 185 $cal->DoDELETERequest(Config::service( 'CalDAV' , 'url' ).'/'.Config::me( 'uid' ).'/'.$data.'/'); -
trunk/prototype/modules/calendar/interceptors/DBMapping.php
r5415 r5437 6 6 7 7 class DBMapping extends Helpers { 8 9 //Schedulable10 static $calendar_objectMap = array('id' => 'id',11 'uid' => 'cal_uid',12 'type' => 'type_id',13 'startTime' => 'dtstart',14 'summary' => 'summary',15 'description' => 'description',16 'endTime' => 'dtend',17 'location' => 'location',18 'allDay' => 'allday',19 'tranp' => 'tranparent',20 'class' => 'class_id',21 'repeat' => 'repeat',22 'rangeStart' => 'range_start',23 'rangeEnd' => 'range_end',24 'lastUpdate' => 'last_update',25 'dtstamp' => 'dtstamp',26 'sequence' => 'sequence',27 'timezone' => 'tzid');28 29 static $calendar_to_calendar_objectMap = array('id' => 'id',30 'calendar' => 'calendar_id',31 'schedulable' => 'calendar_object_id');32 33 34 //Alarm35 static $calendar_alarmMap = array( 'id' => 'id',36 'type' => 'action_id',37 'time' => 'time',38 'sent' => 'sent',39 'rangeStart' => 'range_start',40 'rangeEnd' => 'range_end',41 'unit' => 'unit',42 'participant' => 'participant_id',43 'schedulable' => 'object_id');44 45 //calendarSignatureAlarm46 static $calendar_signature_alarmMap = array( 'id' => 'id',47 'type' => 'action_id',48 'time' => 'time',49 'unit' => 'unit',50 'calendarSignature' => 'calendar_signature_id');51 52 //modulePrefence53 static $module_preferenceMap = array( 'id' => 'id',54 'user' => 'user_uidnumber',55 'value' => 'value',56 'name' => 'name',57 'module' => 'module');58 59 //Participant60 static $calendar_participantMap = array( 'id' => 'id',61 'delegatedTo' => 'delegated_to',62 'isOrganizer' => 'is_organizer',63 'isExternal' => 'is_external',64 'status' => 'participant_status_id',65 'schedulable' => 'object_id',66 'user' => 'user_info_id' );67 68 //User69 static $calendar_ex_participantMap = array( 'id' => 'id',70 'name' => 'name',71 'mail' => 'mail',72 'owner' => 'owner');73 74 //Repeat75 static $calendar_repeatMap = array( 'id' => 'id',76 'freq' => 'frequency',77 'endTime' => 'until',78 'count' => 'count',79 'schedulable' => 'object_id',80 'bysecond' => 'bysecond',81 'byminute' => 'byminute',82 'byhour' => 'byhour',83 'byday' => 'byday',84 'bymonthday' => 'bymonthday',85 'byweekno' => 'byweekno',86 'bymonth' => 'bymonth',87 'bysetpos' => 'bysetpos',88 'wkst' => 'wkst',89 'interval' => 'interval');90 91 //Calendar92 static $calendarMap = array( 'id' => 'id',93 'name' => 'name',94 'location' => 'location',95 'description' => 'description',96 'timezone' => 'tzid',97 'defaultDuration' => 'duration',98 'dtstamp' => 'dtstamp');99 100 //Signature101 static $calendar_signatureMap = array( 'id' => 'id',102 'user' => 'user_uidnumber',103 'calendar' => 'calendar_id',104 'isOwner' => 'is_owner',105 'msgAdd' => 'msg_add',106 'msgCancel' => 'msg_cancel',107 'msgUpdate' => 'msg_update',108 'msgReply' => 'msg_reply',109 'msgAlarm' => 'msg_alarms',110 'dtstamp' => 'dtstamp',111 'fontColor' => 'font_color',112 'backgroundColor' => 'background_color',113 'borderColor' => 'border_color');114 115 static $attachmentMap = array('id' => 'id',116 'name' => 'name',117 'type' => 'type',118 'source' => 'source',119 'size' => 'size');120 8 121 122 123 ////Encode Create 124 public function encodeCreateConcept( &$uri , &$params , &$criteria , $original ){ 125 $params = self::parseConcept($params , self::${$uri['concept'].'Map'}); 126 } 127 public function encodeCreateSchedulable( &$uri , &$params , &$criteria , $original ){ 128 $uri['concept'] = 'calendar_object'; 129 $new['type_id'] = EVENT_ID; 130 131 if(!array_key_exists('startTime', $params)) 132 { 133 $params['startTime'] = $params['endTime']; 134 } 135 136 $new = self::parseConcept($params , self::$calendar_objectMap); 137 138 $new['range_start'] = gmdate( 'd-m-Y' , (int)($params['startTime'] / 1000) ); 9 public function encodeCreateSchedulable( &$uri , &$params , &$criteria , $original ){ 10 $params['type_id'] = EVENT_ID; 11 12 $params['rangeStart'] = gmdate( 'd-m-Y' , (int)($params['startTime'] / 1000) ); 139 13 140 14 // if( !isset( $new['repeat'] )) 141 15 // $new['range_end'] = '7287926400'; // 12/12/2200 142 16 // else 143 $ new['range_end'] = gmdate( 'd-m-Y' , (int)($params['endTime'] / 1000) );17 $params['rangeEnd'] = gmdate( 'd-m-Y' , (int)($params['endTime'] / 1000) ); 144 18 /////////////////////////////////////////////////////////////////// 145 19 146 $new['dtstamp'] = (isset($new['dtstamp'])) ? $new['dtstamp'] :time().'000'; 147 $new['last_update'] = (isset($new['last_update'])) ? $new['last_update'] :time().'000'; 148 $new['type_id'] = EVENT_ID; 149 $new['cal_uid'] = isset($new['cal_uid']) ? $new['cal_uid'] : $this->_makeUid(); 150 $params = $new; 20 $params['dtstamp'] = (isset($params['dtstamp'])) ? $params['dtstamp'] :time().'000'; 21 $params['lastUpdate'] = (isset($params['lastUpdate'])) ? $params['lastUpdate'] :time().'000'; 22 $params['type'] = EVENT_ID; 23 $params['uid'] = isset($params['uid']) ? $params['uid'] : $this->_makeUid(); 151 24 152 25 } … … 163 36 } 164 37 165 $params = self::parseConcept($params , self::$calendar_alarmMap); 166 $params['action_id'] = self::codeAlarmType($params['action_id']); 38 $params['type'] = self::codeAlarmType($params['type']); 167 39 168 40 } … … 175 47 public function encodeCreateAttachment( &$uri , &$params , &$criteria , $original ){ 176 48 $params['source'] = base64_encode( $params['source'] ); 177 $params = self::parseConcept($params , self::$attachmentMap);178 49 } 179 50 /////////////////////////////////////////////////////////////////////////////////////////////////////////////// 180 51 181 52 public function encodeSignatureAlarmType( &$uri , &$params , &$criteria , $original ){ 182 53 $params['type'] = self::codeAlarmType($params['type']); 183 54 } 184 55 185 ////Encode URI186 public function encodeURICalendarToSchedulable( &$uri , &$params , &$criteria , $original ){187 $uri['concept'] = 'calendar_to_calendar_object';188 }189 public function encodeURICalendarSignatureAlarm( &$uri , &$params , &$criteria , $original ){190 $uri['concept'] = 'calendar_signature_alarm';191 }192 public function encodeURISchedulable( &$uri , &$params , &$criteria , $original ){193 $uri['concept'] = 'calendar_object';194 }195 public function encodeURIAlarm( &$uri , &$params , &$criteria , $original ){196 $uri['concept'] = 'calendar_alarm';197 }198 public function encodeURIParticipant (&$uri , &$params , &$criteria , $original ){199 $uri['concept'] = 'calendar_participant';200 }201 public function encodeURIUser (&$uri , &$params , &$criteria , $original ){202 $uri['concept'] = 'calendar_ex_participant';203 }204 public function encodeURIRepeat (&$uri , &$params , &$criteria , $original ){205 $uri['concept'] = 'calendar_repeat';206 }207 public function encodeURICalendar (&$uri , &$params , &$criteria , $original ){208 $uri['concept'] = 'calendar';209 }210 public function encodeURImodulePreference (&$uri , &$params , &$criteria , $original ){211 $uri['concept'] = 'module_preference';212 }213 public function encodeURICalendarSignature (&$uri , &$params , &$criteria , $original ){214 $uri['concept'] = 'calendar_signature';215 }216 /////////////////////////////////////////////////////////////217 56 218 57 public function insertOwnerLink (&$uri , &$params , &$criteria , $original ){ … … 225 64 } 226 65 227 ////Encode Read 228 public function encodeReadConcept(&$uri , &$params , &$criteria , $original ){ 229 $params = self::parsejustthese($params , self::${$uri['concept'].'Map'}); 230 } 231 //////////////////////////////////////////////////////////////////////////////////////////////// 232 233 //Encode Find 234 public function encodeFindParticipant( &$uri , &$params , &$criteria , $original ){ 235 236 $criteria = self::parserCristeria($criteria, self::$calendar_participantMap); 237 238 } 239 240 public function encodeFindConcept( &$uri , &$params , &$criteria , $original ){ 241 $params = self::parsejustthese($params, self::${$uri['concept'].'Map'}); 242 243 $criteria = self::parserCristeria($criteria, self::${$uri['concept'].'Map'}); 244 245 } 246 247 public function encodeDeleteAllConcept( &$uri , &$params , &$criteria , $original ){ 248 249 $criteria = self::parserCristeria($criteria, self::${$uri['concept'].'Map'}); 250 251 } 252 253 public function encodeFindSchedulable( &$uri , &$params , &$criteria , $original ){ 254 255 $criteria = self::parserCristeria($criteria, self::$calendar_objectMap); 256 $findCalendar = false; 257 if(isset($criteria['filter'] )) 258 $criteria['filter'] = self::parseFilterSchedulable($criteria['filter'], self::$calendar_objectMap,$findCalendar); 259 260 if($findCalendar){ 261 $uri['concept'] = 'calendar_to_calendar_object , calendar_object'; 262 $criteria['join'] = array( 'calendar_to_calendar_object.calendar_object_id' => 'calendar_object.id'); 263 } 264 265 } 266 66 public function findSchedulable( &$uri , &$params , &$criteria , $original ) 67 { 68 if(isset($criteria['filter'][3][1]) && $criteria['filter'][3][1] == 'calendar') 69 { 70 $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'; 71 $sql = " SELECT $select FROM calendar_to_calendar_object , calendar_object WHERE (range_start >= '".$criteria['filter'][1][2]."' AND range_end <= '".$criteria['filter'][2][2]."' AND calendar_to_calendar_object.calendar_id IN ('". implode('\',\'', $criteria['filter'][3][2])."')) AND calendar_to_calendar_object.calendar_object_id = calendar_object.id"; 72 $params = Controller::service('PostgreSQL')->execResultSql($sql); 73 $params = self::deepnessFindEvent( &$uri , &$params , &$criteria , $original); 74 return false; 75 } 76 } 77 267 78 /////////////////////////////////////////////////////////////////////////////////////////////////////////////// 268 79 … … 283 94 284 95 //Encode Update 285 public function encodeUpdateConcept( &$uri , &$params , &$criteria , $original ){286 $params = self::parseConcept( $params , self::${$uri['concept'].'Map'} );287 }288 96 289 97 public function encodeUpdateSchedulable( &$uri , &$params , &$criteria , $original ){ … … 292 100 if(isset($params['endTime'])) 293 101 $params['rangeEnd'] = gmdate( 'd-m-Y' , (int)($params['endTime'] / 1000) ); 294 295 $params = self::parseConcept( $params , self::${$uri['concept'].'Map'} ); 102 296 103 297 104 } … … 328 135 } 329 136 /////////////////////////////////////////////////////////////////////////////////////////////////////////////// 330 331 public function encodeReplaceConcept( &$uri , &$params , &$criteria , $original ){332 $params = self::parseConcept( $params , self::${$uri['concept'].'Map'} );333 334 $criteria = self::parserCristeria($criteria, self::${$uri['concept'].'Map'});335 336 }337 137 338 138 public function verifyCalendarLocation( &$uri , &$params , &$criteria , $original ){ … … 341 141 } 342 142 343 public function setCalendarLocation( &$uri , &$params , &$criteria , $original ){344 if(isset($params['name']))345 $params['location'] = $params['name'];346 }347 143 348 144 //TODO: Remover apos suporte a ManytoMany na api … … 381 177 } 382 178 179 return $result; 180 383 181 } 384 182 … … 406 204 } 407 205 } 408 409 206 } 410 207 … … 514 311 array( '=' , 'sent' , '0') , 515 312 array( '=' , 'type' , ALARM_ALERT) , 516 array( '>=' , 'range _start' , $criteria['filter'][2]) ,517 array( '<=' , 'range _end' , $criteria['filter'][2]) );313 array( '>=' , 'rangeStart' , $criteria['filter'][2]) , 314 array( '<=' , 'rangeEnd' , $criteria['filter'][2]) ); 518 315 519 316 //Busca os Alarmes no Range … … 680 477 $newCriteria = $original['criteria']; 681 478 $valid = true; 682 self::validExternalUserCriteria($newCriteria['filter'], self::$calendar_ex_participantMap, $valid); 683 if($valid == true) 684 { 685 $newCriteria['filter'] = array('AND',$newCriteria['filter'] , array('=' , 'owner', Config::me('uidNumber')) ); 479 480 $newCriteria['filter'] = array('AND',$newCriteria['filter'] , array('=' , 'owner', Config::me('uidNumber')) ); 686 481 $externalUsers = Controller::find( $newuri , $original['properties'] ? $original['properties'] : null , $newCriteria ); 687 482 … … 698 493 699 494 return array_merge($result, $externalUsers); 700 } 701 702 } 703 704 //Decode Read 705 public function decodeReadConcept( &$uri , &$result , &$criteria , $original ){ 706 return self::parseConcept($result, self::${$uri['concept'].'Map'} , true); 707 } 708 ///////////////////////////////////////////////////////////////////////// 709 495 496 497 } 498 710 499 public function createSchedulableMails( &$uri , &$result , &$criteria , $original ){ 711 500 … … 948 737 return ( isset( $isOwner[0]['id'] ) ) ? true : false; 949 738 } 950 951 //TODO: Remover apos suporte a ManytoMany na api 952 protected static function parseFilterSchedulable($filter, $map ,&$findCalendar) { 953 if (!is_array($filter) || count($filter) <= 0) 954 return null; 955 956 $op = array_shift($filter); 957 958 if (is_array($filter[0])) { 959 foreach ($filter as $i => $f) 960 $filter[$i] = self::parseFilterSchedulable($f, $map ,$findCalendar ); 961 } 962 else 963 { 964 if($filter[0] == 'calendar') 965 { 966 $findCalendar = true; 967 $filter[0] = 'calendar_to_calendar_object.calendar_id'; 968 } 969 else 970 $filter[0] = isset($map[$filter[0]]) ? $map[$filter[0]] : $filter[0]; 971 } 972 973 array_unshift($filter, $op); 974 975 return( $filter ); 976 } 977 978 private static function validExternalUserCriteria( $filter, $map , &$ref ) 979 { 980 if (!is_array($filter) || count($filter) <= 0) 981 return null; 982 983 $op = array_shift($filter); 984 985 if (isset($filter[0]) && is_array($filter[0])) { 986 foreach ($filter as $i => $f) 987 $filter[$i] = self::validExternalUserCriteria($f, $map ,$findCalendar ); 988 } 989 else 990 { 991 if( isset($filter[0]) && !in_array($filter[0] , self::$calendar_ex_participantMap)) 992 $ref = false; 993 994 else 995 $filter[0] = isset($map[$filter[0]]) ? $map[$filter[0]] : $filter[0]; 996 } 997 998 return( $filter ); 999 } 1000 739 1001 740 private static function schedulable2calendarToObject($Schedulable) 1002 741 { -
trunk/prototype/modules/calendar/interceptors/Helpers.php
r5341 r5437 1 1 <?php 2 2 3 class Helpers { 4 5 protected static function parseFilter($filter, $map) { 6 if (!is_array($filter) || count($filter) <= 0) 7 return null; 8 9 $op = array_shift($filter); 10 11 if (is_array($filter[0])) { 12 foreach ($filter as $i => $f) 13 $filter[$i] = self::parseFilter($f, $map); 14 } 15 else 16 $filter[0] = isset($map[$filter[0]]) ? $map[$filter[0]] : $filter[0]; 17 18 array_unshift($filter, $op); 19 20 return( $filter ); 21 } 22 23 protected static function parseConcept($data, $map, $flip = false) { 24 if (!is_array($data) || count($data) <= 0) 25 return false; 26 27 if ($flip === true) 28 $map = array_flip($map); 29 30 $new = array(); 31 foreach ($data as $i => $v) 32 if (array_key_exists($i, $map)) 33 $new[$map[$i]] = $v; 34 return $new; 35 } 36 37 38 protected static function parseOrder($data, $map) { 39 $new = array(); 40 41 if (!is_array($data)) 42 $data = array($data); 43 44 foreach ($data as $v) 45 if (array_key_exists($v, $map)) 46 $new[] = $map[$v]; 47 48 return $new; 49 } 50 51 52 protected static function parsejustthese($data, $map, $flip = false) { 53 54 if (!is_array($data) || count($data) <= 0) 55 return false; 56 57 if ($flip === true) 58 $map = array_flip($map); 59 60 $new = array(); 61 foreach ($data as $v) 62 if (array_key_exists($v, $map)) 63 $new[] = $map[$v]; 64 return $new; 65 } 66 67 protected static function parserCristeria($criteria, $map) { 68 if (isset($criteria['filter'])) 69 $criteria['filter'] = self::parseFilter($criteria['filter'], $map); 70 71 if (isset($criteria['order'])) { 72 $ord = self::parseOrder($criteria['order'], $map); 73 if (count($ord) > 0) 74 $criteria['order'] = $ord; 75 else 76 unset($criteria['order']); 77 } 78 79 return $criteria; 80 } 81 3 class Helpers { 82 4 83 5 public static function futureEvent( $startTime , $rangeEnd ) -
trunk/prototype/modules/calendar/interceptors/LDAPMapping.php
r5341 r5437 4 4 5 5 class LDAPMapping extends Helpers { 6 7 //externalUser8 static $usertMap = array( 'id' => 'uidnumber',9 'name' => 'cn',10 'mail' => 'mail',11 'mailAlternateAddress' => 'mailalternateaddress');12 13 14 public function decodeReadUser( &$uri , &$result , &$criteria , $original ){15 $result = self::parseConcept( $result , self::$usertMap , true );16 }17 6 18 7 public function encodeFindUser( &$uri , &$params , &$criteria , $original ){ … … 37 26 ), 38 27 array('OR', 39 array('*',' cn',$criteria['filter'][2]),28 array('*','name',$criteria['filter'][2]), 40 29 array('*','givenName',$criteria['filter'][2]), 41 30 array('*','uid',$criteria['filter'][2]), … … 47 36 ) 48 37 ); 49 else50 $criteria['filter'] = self::parseFilter($criteria['filter'], self::$usertMap);51 38 } 52 39 53 40 } 54 55 /* 56 * ex: array ( 57 * [0] 'OR', 58 * [1] array( 'OR', array( array( '=', 'campo', 'valor' ) ), 59 * [2] array( '=', 'campo' , 'valor' ), 60 * [3] array( 'IN', 'campo', array( '1' , '2' , '3' ) ) 61 * ) 62 * OR 63 * array( '=' , 'campo' , 'valor' ) 64 */ 65 66 public function decodeFindUser( &$uri , &$result , &$criteria , $original ){ 67 foreach ($result as $i => $v) 68 $result[$i] = self::parseConcept( $v , self::$usertMap , true ); 69 70 } 71 41 72 42 } 73 43 -
trunk/prototype/modules/calendar/interceptors/Notifications.php
r5399 r5437 21 21 { 22 22 if(Config::regGet('noAlarm') !== false) return; //Escapa notificações caso a flag de noAlarm esteja ativa. 23 23 24 24 $organizers = array(); //Cache Organizadores 25 25 $schedulables = array(); //Cache Schedulables -
trunk/prototype/modules/calendar/js/calendar.codecs.js
r5415 r5437 91 91 92 92 for( var i = 0; i < this.signatures.length; i++ ){ 93 this.signatureOf[ ( this.calendarOf[ this.calendarIds[i] = ( this.calendars[ this.calendars.length ] = this.signatures[i].calendar ).id ] = this.signatures[i].calendar ).id ] = this.signatures[i];93 this.signatureOf[ this.calendarIds[i] = ( this.calendars[ this.calendars.length ] = this.calendarOf[ this.signatures[i].id ] = this.signatures[i].calendar ).id ] = this.signatures[i]; 94 94 } 95 95 … … 272 272 user: User.me.id, 273 273 calendar: { 274 id: Calendar. signatureOf[form.signature].calendar.id,274 id: Calendar.calendarOf[form.signature].id, 275 275 name: Encoder.htmlEncode(form.name), 276 276 description: Encoder.htmlEncode(form.description), … … 351 351 user: User.me.id, 352 352 status: form.status, 353 id: form. attendee_organizer[0],353 id: form.meId, 354 354 isOrganizer: 0, 355 355 alarms: typeof(form.alarmTime) != 'undefined' ? … … 468 468 var res = $.map(evtObj, function( form ){ 469 469 470 var tzId = form.timezone || Calendar. calendarOf[form.calendar].timezone || User.preferences.timezone,470 var tzId = form.timezone || Calendar.signatureOf[form.calendar].calendar.timezone || User.preferences.timezone, 471 471 472 472 formatString = ( typeof form.allDay !== "undefined" && !!form.allDay )? pref.dateFormat+" HH:mm" : pref.dateFormat + " " + pref.hourFormat, -
trunk/prototype/modules/calendar/js/calendar.date.js
r5409 r5437 48 48 dayOfWeek: 49 49 { 50 'S AN': 0,50 'SUN': 0, 51 51 'MON': 1, 52 52 'TUE': 2, -
trunk/prototype/modules/calendar/js/helpers.js
r5409 r5437 153 153 154 154 /*Seleciona a agenda padrão para criação de um evento*/ 155 UI.dialogs.addEvent.find('option[value="'+ User.preferences.defaultCalendar+'"]').attr('selected','selected').trigger('change');155 UI.dialogs.addEvent.find('option[value="'+objEvent.calendar || User.preferences.defaultCalendar+'"]').attr('selected','selected').trigger('change'); 156 156 157 157 /*Adicionar alarms padrões, quando alterado a agenda do usuário*/ … … 1249 1249 1250 1250 function mountCriteriaList(view, page_index, calerdars_selecteds){ 1251 var criteria = {deepness: 2, order: 'startTime'} 1251 var rangeStart , rangeEnd; 1252 1252 switch (view){ 1253 1253 case 'basicDay': 1254 1254 case 'day': 1255 return {filter: ['AND', ['IN', 'calendar', calerdars_selecteds], ['=', 'rangeEnd', new Date().add({days: page_index}).toString("yyyy-MM-dd")]], criteria: criteria}; 1255 rangeStart = new Date().add({days: page_index}).toString("yyyy-MM-dd"); 1256 rangeEnd = rangeStart; 1257 break; 1256 1258 case 'agendaWeek': 1257 1259 case 'week': 1258 var dateStart = new Date().moveToDayOfWeek(dateCalendar.dayOfWeek[User.preferences.weekDefault]); 1259 var dateEnd = new Date().moveToDayOfWeek(dateCalendar.dayOfWeek[User.preferences.weekDefault]); 1260 return {filter: ['AND', ['IN', 'calendar', calerdars_selecteds], ['AND',['>=', 'rangeEnd', dateStart.add({days: (7 * page_index)}).toString("yyyy-MM-dd")], ['<=', 'rangeEnd', dateEnd.add({days: (7 * page_index)+7}).toString("yyyy-MM-dd")]]], criteria: criteria}; 1260 var dateStart = new Date().moveToDayOfWeek(dateCalendar.dayOfWeek[User.preferences.weekStart]); 1261 var dateEnd = new Date().moveToDayOfWeek(dateCalendar.dayOfWeek[User.preferences.weekStart]); 1262 rangeStart = dateStart.add({days: (7 * page_index)}).toString("yyyy-MM-dd"); 1263 rangeEnd = dateEnd.add({days: (7 * page_index)+7}).toString("yyyy-MM-dd"); 1264 break; 1261 1265 case 'month': 1262 1266 var date = new Date().add({months: page_index}) 1263 return {filter: ['AND',['IN', 'calendar', calerdars_selecteds], ['AND',['>=', 'rangeEnd', date.moveToFirstDayOfMonth().toString("yyyy-MM-dd")], ['<=', 'rangeEnd', date.moveToLastDayOfMonth().toString("yyyy-MM-dd")]]], criteria: criteria}; 1267 rangeStart = date.moveToFirstDayOfMonth().toString("yyyy-MM-dd"); 1268 rangeEnd = date.moveToLastDayOfMonth().toString("yyyy-MM-dd"); 1269 break; 1264 1270 case 'year': 1265 1271 var dateStart = new Date().add({years: page_index}); … … 1269 1275 if(dateEnd.getMonth() != 11) 1270 1276 dateEnd.moveToMonth(11) 1271 return {filter: ['AND', ['IN', 'calendar', calerdars_selecteds], ['AND',['>=', 'rangeEnd', dateStart.moveToFirstDayOfMonth().toString("yyyy-MM-dd")], ['<=', 'rangeEnd', dateEnd.moveToLastDayOfMonth().toString("yyyy-MM-dd")]]], criteria: criteria}; 1272 } 1277 rangeStart = dateStart.moveToFirstDayOfMonth().toString("yyyy-MM-dd"); 1278 rangeEnd = dateEnd.moveToLastDayOfMonth().toString("yyyy-MM-dd"); 1279 break; 1280 } 1281 return {filter: ['AND', ['>=', 'rangeStart', rangeStart], ['<=', 'rangeEnd', rangeEnd] , ['IN', 'calendar', calerdars_selecteds]], criteria: {deepness: 2, order: 'startTime'}}; 1282 1273 1283 } 1274 1284 -
trunk/prototype/modules/calendar/templates/attendee_add.ejs
r5422 r5437 8 8 <!-- <option value="another">Outra pessoa vai</option>--> 9 9 </select> 10 <%if(data.event.organizer.id != data.event.me.id){%> 11 <input type="hidden" name="meId" value="<%=data.event.me.id%>"> 12 <%}%> 10 13 <fieldset class="add-attendee-search search-field ui-corner-all hidden"> 11 14 <span class="ui-icon ui-icon-search"></span> -
trunk/prototype/plugins/davicalCliente/caldav-client-v2.php
r5399 r5437 446 446 $this->SetMatch( true, $etag ); 447 447 } 448 $this->DoRequest($url); 449 return $this->resultcode; 448 return $this->DoRequest($url); 450 449 } 451 450 -
trunk/prototype/services/OpenLDAP.php
r5341 r5437 9 9 public function find ( $uri, $justthese = false, $criteria = false ) 10 10 { 11 if($justthese === false || $justthese === null) 12 $justthese = array('*'); 11 $map = Config::get($uri['concept'], 'OpenLDAP.mapping'); 13 12 14 13 if( !isset($criteria["limit"]) ) 15 14 $criteria["limit"] = $this->limit; 16 15 17 18 $sr = ldap_search( $this->con , $this->config['context'] , self::parseCriteria($criteria) , $justthese , 0 , $criteria["limit"]); 16 $sr = ldap_search( $this->con , $this->config['context'] , self::parseCriteria($criteria , $map) , self::parseJustthese($justthese, $map) , 0 , $criteria["limit"]); 19 17 if(!$sr) return false; 20 18 … … 22 20 ldap_sort( $this->con, $sr, $criteria["order"] ); 23 21 24 return self::_formatEntries( ldap_get_entries( $this->con, $sr ) );22 return self::_formatEntries( ldap_get_entries( $this->con, $sr ) , $map); 25 23 } 26 24 27 25 public function read ( $uri, $justthese = false ) 28 26 { 27 $map = Config::get($uri['concept'], 'OpenLDAP.mapping'); 28 29 29 if( $justthese === false || $justthese === null ) 30 30 $sr = ldap_search( $this->con, $this->config['context'], '('.$this->config['idAtribute'].'='.$uri['id'].')' ); 31 31 else 32 $sr = ldap_search( $this->con, $this->config['context'], '('.$this->config['idAtribute'].'='.$uri['id'].')', $justthese);32 $sr = ldap_search( $this->con, $this->config['context'], '('.$this->config['idAtribute'].'='.$uri['id'].')', self::parseJustthese($justthese, $map) ); 33 33 34 34 if(!$sr) return false; 35 35 36 $return = self::_formatEntries( ldap_get_entries( $this->con, $sr ) );36 $return = self::_formatEntries( ldap_get_entries( $this->con, $sr ) , $map ); 37 37 38 38 return isset($return[0]) ? $return[0] : array(); … … 87 87 } 88 88 89 private static function _formatEntries ( $pEntries )89 private static function _formatEntries ( $pEntries , &$map ) 90 90 { 91 91 if( !$pEntries ) return( false ); 92 92 93 $newMap = array(); 94 foreach ($map as $i => &$v) 95 $newMap[strtolower($v)] = $i; 96 93 97 $return = array(); 94 95 98 for ($i=0; $i < $pEntries["count"]; $i++) 96 99 { … … 98 101 foreach ($pEntries[$i] as $index => $value) 99 102 { 100 if(!is_numeric($index) && $index != 'count')103 if(isset($newMap[$index])) 101 104 { 102 105 if(is_array($value)) 103 106 { 104 107 if(count($value) == 2) 105 $entrieTmp[$ index] = $value['0'];108 $entrieTmp[$newMap[$index]] = $value['0']; 106 109 else 107 110 { 108 111 foreach ($value as $index2 =>$value2) 109 112 { 110 if($index != 'count')111 $entrieTmp[$ index][$index2] = $value2;113 if($index2 != 'count') 114 $entrieTmp[$newMap[$index]][$index2] = $value2; 112 115 } 113 116 } 114 117 } 115 118 else 116 $entrieTmp[$ index] = $value;119 $entrieTmp[$newMap[$index]] = $value; 117 120 } 118 121 } … … 124 127 } 125 128 126 private static function parseCriteria( $criteria )129 private static function parseCriteria( $criteria , &$map) 127 130 { 128 131 $result = ""; … … 142 145 143 146 144 $result .= self::parseFilter( $criteria['filter'] );147 $result .= self::parseFilter( $criteria['filter'] , $map); 145 148 } 146 149 … … 148 151 } 149 152 150 private static function parseFilter( $filter )153 private static function parseFilter( $filter , &$map) 151 154 { 152 155 $result = ''; … … 159 162 160 163 foreach( $filter as $i => $f ) 161 $nested .= self::parseFilter($f );164 $nested .= self::parseFilter($f , $map); 162 165 163 166 $fil = $op.$nested; 164 167 } 165 else 166 $fil = $op[0].$filter[0].$op[1].$filter[1].$op[2]; 167 168 else if( isset($map[$filter[0]]) ) 169 $fil = $op[0].$map[$filter[0]].$op[1].$filter[1].$op[2]; 170 else 171 return ''; 172 168 173 return '('.$fil.')'; 169 174 } … … 182 187 } 183 188 } 189 190 private static function parseJustthese($justthese , &$map) 191 { 192 if(!is_array($justthese)) //Caso seja um full select pegar todas as keys 193 $justthese = array_keys($map); 194 195 $return = array(); 196 197 foreach ($justthese as &$value) 198 if(isset($map[$value])) 199 $return[] = $map[$value]; 200 201 return $return; 202 } 184 203 } 185 204 -
trunk/prototype/services/PostgreSQL.php
r5399 r5437 8 8 9 9 public function find ( $uri, $justthese = false, $criteria = false ){ 10 11 $criteria = ($criteria !== false) ? $this->parseCriteria ( $criteria ) : ''; 12 13 $justthese = $justthese ? '"'.implode('", "', $justthese).'"' : '*'; 14 15 return $this->execResultSql( 'SELECT '.$justthese.' FROM '.$uri['concept'].' '.$criteria ); 10 11 $map = Config::get($uri['concept'], 'PostgreSQL.mapping'); 12 13 $criteria = ($criteria !== false) ? $this->parseCriteria ( $criteria , $map) : ''; 14 15 $justthese = self::parseJustthese($justthese, $map); 16 17 return $this->execResultSql( 'SELECT '.$justthese['select'].' FROM '. (Config::get($uri['concept'],'PostgreSQL.concept')) .' '.$criteria ); 16 18 } 17 19 18 20 public function read ( $uri, $justthese = false ){ 19 20 $justthese = $justthese ? '"'.implode('", "', $justthese).'"' : '*'; 21 22 return $this->execResultSql( 'SELECT '.$justthese.' FROM '.$uri['concept'].' WHERE id = \''.addslashes( $uri['id'] ).'\'', true ); 23 } 24 25 public function deleteAll ( $uri, $justthese = false, $criteria = false ){ 26 if(!self::parseCriteria ( $criteria )) return false; //Validador para não apagar tabela inteira 27 return $this->execSql( 'DELETE FROM '.$uri['concept'].' '.self::parseCriteria ( $criteria ) ); 21 22 $map = Config::get($uri['concept'], 'PostgreSQL.mapping'); 23 24 $justthese = self::parseJustthese($justthese, $map); 25 26 return $this->execResultSql( 'SELECT '.$justthese['select'].' FROM '. (Config::get($uri['concept'],'PostgreSQL.concept')) .' WHERE id = \''.addslashes( $uri['id'] ).'\'', true ); 27 } 28 29 public function deleteAll ( $uri, $justthese = false, $criteria = false ){ 30 $map = Config::get($uri['concept'], 'PostgreSQL.mapping'); 31 if(!self::parseCriteria ( $criteria , $map)) return false; //Validador para não apagar tabela inteira 32 return $this->execSql( 'DELETE FROM '.(Config::get($uri['concept'],'PostgreSQL.concept')).' '.self::parseCriteria ( $criteria ,$map) ); 28 33 } 29 34 30 35 public function delete ( $uri, $justthese = false ){ 31 return $this->execSql('DELETE FROM '. $uri['concept'].' WHERE id = '.addslashes($uri['id']));36 return $this->execSql('DELETE FROM '.(Config::get($uri['concept'],'PostgreSQL.concept')).' WHERE id = '.addslashes($uri['id'])); 32 37 } 33 38 34 39 public function replace ( $uri, $data, $criteria = false ){ 35 return $this->execSql('UPDATE '.$uri['concept'].' '. self::parseUpdateData( $data ).' '.self::parseCriteria($criteria)); 40 41 return $this->execSql('UPDATE '.(Config::get($uri['concept'],'PostgreSQL.concept')).' '. self::parseUpdateData( $data ,$uri['concept']).' '.self::parseCriteria($criteria , $uri['concept'])); 36 42 } 37 43 38 44 public function update ( $uri, $data ){ 39 return $this->execSql('UPDATE '. $uri['concept'].' '. self::parseUpdateData( $data).' WHERE id = \''. addslashes( $uri['id']) .'\'');45 return $this->execSql('UPDATE '.(Config::get($uri['concept'],'PostgreSQL.concept')).' '. self::parseUpdateData( $data ,$uri['concept']).' WHERE id = \''. addslashes( $uri['id']) .'\''); 40 46 } 41 47 42 48 public function create ( $uri, $data ){ 43 return $this->execResultSql( 'INSERT INTO '. $uri['concept'].' '.self::parseInsertData( $data), true );49 return $this->execResultSql( 'INSERT INTO '.(Config::get($uri['concept'],'PostgreSQL.concept')).' '.self::parseInsertData( $data , $uri['concept'] ), true ); 44 50 } 45 51 … … 122 128 public function teardown(){} 123 129 124 private static function parseInsertData( $data ){ 125 130 private static function parseInsertData( $data , $concept){ 131 132 $map = Config::get($concept, 'PostgreSQL.mapping'); 133 126 134 $ind = array(); 127 135 $val = array(); 128 136 129 137 foreach ($data as $i => $v){ 130 $ind[] = $i; 138 if(!isset($map[$i])) continue; 139 140 $ind[] = $map[$i]; 131 141 $val[] = '\''.addslashes($v).'\''; 132 142 } … … 135 145 } 136 146 137 private static function parseUpdateData( $data ){ 138 147 private static function parseUpdateData( $data , $concept){ 148 149 $map = Config::get($concept, 'PostgreSQL.mapping'); 150 139 151 $d = array(); 140 141 152 foreach ($data as $i => $v) 142 $d[] = $i.' = \''.addslashes ($v).'\''; 153 { 154 if(!isset($map[$i])) continue; 155 156 $d[] = $map[$i].' = \''.addslashes ($v).'\''; 157 } 143 158 144 159 return 'SET '.implode(',', $d); … … 160 175 } 161 176 162 private static function parseCriteria( $criteria ){177 private static function parseCriteria( $criteria , &$map ){ 163 178 164 179 $result = ''; … … 177 192 */ 178 193 179 $result .= 'WHERE '.self::parseFilter( $criteria['filter'] );194 $result .= 'WHERE '.self::parseFilter( $criteria['filter'] , $map); 180 195 } 181 196 /* … … 210 225 } 211 226 212 private static function parseFilter( $filter ){227 private static function parseFilter( $filter ,&$map){ 213 228 214 229 if( !is_array( $filter ) || count($filter) <= 0) return null; 215 230 216 231 $op = self::parseOperator( array_shift( $filter ) ); 217 232 218 233 if( is_array($filter[0]) ) 219 234 { … … 221 236 222 237 foreach( $filter as $i => $f ) 223 $nested[] = self::parseFilter( $f );238 $nested[] = self::parseFilter( $f , $map); 224 239 225 240 return( '('.implode( ' '.$op.' ', $nested ).')' ); 226 241 } 227 242 243 244 if(isset($map[$filter[0]])) 245 $filter[0] = $map[$filter[0]]; 246 228 247 $igSuffix = $igPrefix = ''; 229 248 230 249 if( strpos( $op[0], 'i' ) === 0 ) 231 250 { … … 258 277 } 259 278 } 260 279 280 private static function parseJustthese($justthese , &$map) 281 { 282 283 if(!is_array($justthese)) //Caso seja um full select pegar todas as keys 284 $justthese = array_keys($map); 285 286 $return = array(); 287 288 foreach ($justthese as &$value) 289 { 290 if(!isset($map[$value])) continue; //Escapa itens não existentes no mapa 291 292 if(is_array($map[$value])) 293 $return['deepness'][$value] = $map[$value]; 294 else 295 $return['select'][] = $map[$value] .' as "'. $value. '"'; 296 } 297 298 $return['select'] = implode(', ', $return['select']); 299 return $return; 300 } 301 261 302 } 262 303 -
trunk/prototype/services/iCal.php
r5415 r5437 143 143 $interation['participant://'.$pID]['status'] = $params['status']; 144 144 } 145 146 Config::regSet('noAlarm', FALSE); //reativa notificação 145 147 } 146 148 else -
trunk/prototype/upload.php
r5399 r5437 13 13 $result[$name] = Controller::create( $URI, $file ); 14 14 15 ob_start();16 print_r( $result );17 $output = ob_get_clean();18 file_put_contents( "/tmp/prototype.log", file_get_contents( "/tmp/prototype.log" ) . $output );19 15 20 16 unset( $file['source'] );
Note: See TracChangeset
for help on using the changeset viewer.