Changeset 5437


Ignore:
Timestamp:
01/27/12 15:37:21 (12 years ago)
Author:
cristiano
Message:

Ticket #2434 - Atualização modulo agenda e API

Location:
trunk/prototype
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/Sync.php

    r5399 r5437  
    133133          foreach( $result as $ii => $tx ) 
    134134          { 
     135              if( !isset($tx['order']) ) 
     136                    continue; 
     137               
    135138                  $oldId = $oldIds[ $tx['order'] ]; 
    136139 
     
    156159 
    157160Controller::closeAll(); 
    158  
    159 //              ob_start(); 
    160 //              print "\n"; 
    161 //              print $data[$linkName] . ": "; 
    162 //              print_r( $synced ); 
    163 //              $output = ob_get_clean(); 
    164 //              file_put_contents( "/tmp/prototype.log", $output , FILE_APPEND ); 
     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  
    3131        
    3232        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; 
    3342    } 
    3443     
  • trunk/prototype/api/controller.php

    r5415 r5437  
    6363            return self::$cache->put( $id, $data, $expires, $compressed ); 
    6464        } 
    65  
    66         public static function put( $URI, $data, $txIds = false ) 
    67         { 
    68             try 
    69             { 
    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                                         else 
    101                                                 $postpone[$linkTarget] = $data[$linkName]; 
    102                                 } 
    103         } 
    104                 } 
    105                 else 
    106                   $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             } 
    16765 
    16866        public static function find( $URI, $params = false, $criteria = false ) 
     
    462360            $result = array( $eventType => array() ); 
    463361         
    464         if( is_array( $commitList ) ) 
     362            if( is_array( $commitList ) ) 
    465363                foreach( $commitList as $i => $tx ) 
    466364                { 
     
    536434 
    537435        //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 ) 
    539437        { 
    540438            try 
     
    550448                    return( empty($params['properties']) ? false : $params['properties'] ); 
    551449 
     450                 
     451 
    552452                if( $params && !$params['service'] ) 
    553453                { 
     
    559459                if( isset($params['URI']['service']) ) 
    560460                { 
    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' ) 
    564462                    { 
    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(); 
    567469                    } 
    568470 
     
    573475                if( $params['service'] ) 
    574476                    switch( $method ) 
    575             {  
     477                    {  
    576478                        case 'find': $return = $params['service']->find( $params['URI'], $params['properties'], $params['criteria'] ); break; 
    577479 
     
    596498                        case 'parse': $return = $params['service']->parse( $params['properties'], $params['criteria'] ); break; 
    597499 
     500                        case 'analize': $return = $params['service']->analize( $params['properties'], $params['criteria'] ); break; 
     501 
    598502                        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                    } 
    602506 
    603507                if( isset($return) && $return !== false ) 
     
    605509 
    606510                if( isset($params['URI']['service']) ) 
    607                 { 
    608511                    if( !self::fire( 'after', $method, $params, $original, true ) ) 
    609512                        return( empty($params['properties']) ? false : $params['properties'] ); 
    610513 
    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 ) 
    612530                    { 
    613531                        if( !self::call( 'commit', $params['URI'], false, self::$tx[ $params['URI']['service'] ] ) ) 
     
    617535                    } 
    618536                } 
    619  
    620                 if( isset($URI['concept']) && !self::fire( 'after', $method, $params, $original ) ) 
    621                     return( empty($params['properties']) ? false : $params['properties'] ); 
    622537            } 
    623538            catch( Exception $e ) 
     
    629544            } 
    630545 
    631             return( empty($params['properties']) ? false : $params['properties'] ); 
     546            return( $params['properties'] );  
    632547        } 
    633548 
     
    637552            return( true ); 
    638553        } 
     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        } 
    639657} 
    640658 
  • trunk/prototype/api/datalayer.js

    r5399 r5437  
    544544    clearQ: function( concept, ids ){ 
    545545       
    546 //              var current = this.check( ':current', concept || false ); 
     546        var current = this.check( ':current', concept || false ); 
    547547        var diffs = this.check( ':diff', concept || false ); 
    548548 
    549549        if( !ids ) 
    550            /* current =*/ diffs = {}; 
     550            current = diffs = {}; 
    551551        else 
    552552        { 
     
    556556            for( var i = 0; i < ids.length; i++ ) 
    557557            { 
    558 //              delete current[ ids[i] ]; 
     558                delete current[ ids[i] ]; 
    559559                delete diffs[ ids[i] ]; 
    560560            } 
    561561        } 
    562562 
    563 //      this.store( ':current', concept, current ); 
     563        this.store( ':current', concept, current ); 
    564564        this.store( ':diff', concept, diffs ); 
    565565    }, 
  • trunk/prototype/api/newcontroller.php

    r5341 r5437  
    112112        public static function create( $concept, $params, $filter = false, $options = false ) 
    113113        { 
    114             return self::call( 'create', $concept, $params, $filter, $options ) 
     114            return self::call( 'create', $concept, $params, $filter, $options ); 
    115115        } 
    116116 
  • trunk/prototype/config/alarm.ini

    r5399 r5437  
    11service = PostgreSQL 
     2PostgreSQL.concept = calendar_alarm 
    23 
    34[links] 
     
    67[before.find] 
    78dayAlarm = modules/calendar/interceptors/DBMapping.php 
    8 encodeURIAlarm = modules/calendar/interceptors/DBMapping.php 
    9 encodeFindConcept = modules/calendar/interceptors/DBMapping.php 
    109 
    1110[after.find] 
    12 decodeFindConcept = modules/calendar/interceptors/DBMapping.php 
    1311decodeSignatureAlarmType = modules/calendar/interceptors/DBMapping.php 
    1412 
    1513[before.create] 
    16 encodeURIAlarm = modules/calendar/interceptors/DBMapping.php 
    1714encodeCreateAlarm = modules/calendar/interceptors/DBMapping.php 
    1815 
    1916[PostgreSQL.before.update] 
    20 encodeURIAlarm = modules/calendar/interceptors/DBMapping.php 
    2117encodeUpdateAlarm = modules/calendar/interceptors/DBMapping.php 
    22 encodeUpdateConcept = modules/calendar/interceptors/DBMapping.php 
    2318 
    24  
    25 [before.delete] 
    26 encodeURIAlarm = modules/calendar/interceptors/DBMapping.php 
     19[PostgreSQL.mapping] 
     20id = "id" 
     21type = "action_id" 
     22time = "time" 
     23sent = "sent" 
     24rangeStart = "range_start" 
     25rangeEnd = "range_end" 
     26unit = "unit" 
     27participant = "participant_id" 
     28schedulable = "object_id"    
  • trunk/prototype/config/calendar.ini

    r5399 r5437  
    11service = PostgreSQL 
     2PostgreSQL.concept = calendar 
    23 
    34[links] 
     
    56 
    67[before.create] 
    7 encodeURICalendar = modules/calendar/interceptors/DBMapping.php 
    8 encodeCreateConcept = modules/calendar/interceptors/DBMapping.php 
    98verifyCalendarLocation = modules/calendar/interceptors/DBMapping.php 
    109davcalCreateCollection = modules/calendar/interceptors/DBMapping.php 
    1110 
    1211[before.update] 
    13 encodeURICalendar = modules/calendar/interceptors/DBMapping.php 
    14 encodeUpdateConcept = modules/calendar/interceptors/DBMapping.php 
    15 setCalendarLocation = modules/calendar/interceptors/DBMapping.php 
    1612davcalUpdateCollection = modules/calendar/interceptors/DBMapping.php 
    1713 
    18  
    1914[before.delete] 
    20 encodeURICalendar = modules/calendar/interceptors/DBMapping.php 
    2115davcalDeleteCollection = modules/calendar/interceptors/DBMapping.php 
    2216 
    23 [before.find] 
    24 encodeURICalendar = modules/calendar/interceptors/DBMapping.php 
    25 encodeFindConcept = modules/calendar/interceptors/DBMapping.php 
    2617 
    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] 
     19id = "id" 
     20name = "name" 
     21location = "location" 
     22timezone = "tzid" 
     23defaultDuration = "duration" 
     24description = "description" 
     25dtstamp = "dtstamp" 
  • trunk/prototype/config/calendarSignature.ini

    r5399 r5437  
    11service = PostgreSQL 
     2PostgreSQL.concept = calendar_signature 
    23 
    34[links] 
     
    56calendarSignatureAlarms = calendarSignatureAlarm 
    67 
    7 [PostgreSQL.before.create] 
    8 encodeURICalendarSignature = modules/calendar/interceptors/DBMapping.php 
    9 encodeCreateConcept = modules/calendar/interceptors/DBMapping.php 
    10  
    11 [before.update] 
    12 encodeURICalendarSignature = modules/calendar/interceptors/DBMapping.php 
    13 encodeUpdateConcept = modules/calendar/interceptors/DBMapping.php 
    14  
    158[before.delete] 
    169deleteCalendarSignatureDependences = modules/calendar/interceptors/DBMapping.php 
    17 encodeURICalendarSignature = modules/calendar/interceptors/DBMapping.php 
    18  
    19 [before.find] 
    20 encodeURICalendarSignature = modules/calendar/interceptors/DBMapping.php 
    21 encodeFindConcept = modules/calendar/interceptors/DBMapping.php 
    2210 
    2311[after.find] 
    24 decodeFindConcept = modules/calendar/interceptors/DBMapping.php 
    2512createDefaultSignature = modules/calendar/interceptors/DBMapping.php 
    2613deepnessFindCalendarSignature = modules/calendar/interceptors/DBMapping.php 
    2714 
    28 [before.deleteAll] 
    29 encodeURICalendarSignature = modules/calendar/interceptors/DBMapping.php 
    30 encodeDeleteAllConcept = modules/calendar/interceptors/DBMapping.php 
     15[after.read] 
     16deepnessReadCalendarSignature = modules/calendar/interceptors/DBMapping.php 
    3117 
    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] 
     19id  = id 
     20user = user_uidnumber 
     21calendar = calendar_id 
     22isOwner = is_owner 
     23msgAdd = msg_add 
     24msgCancel = msg_cancel 
     25msgUpdate = msg_update 
     26msgReply = msg_reply 
     27msgAlarm = msg_alarms 
     28dtstamp = dtstamp 
     29fontColor = font_color 
     30backgroundColor = background_color 
     31borderColor = border_color 
  • trunk/prototype/config/calendarSignatureAlarm.ini

    r5399 r5437  
    11service = PostgreSQL 
     2PostgreSQL.concept = calendar_signature_alarm 
    23 
    34[links] 
    45calendarSignature = calendarSignature 
    56 
    6 [before.find] 
    7 encodeURICalendarSignatureAlarm = modules/calendar/interceptors/DBMapping.php 
    8 encodeFindConcept = modules/calendar/interceptors/DBMapping.php 
    9  
    107[after.find] 
    11 decodeFindConcept = modules/calendar/interceptors/DBMapping.php 
    128decodeSignatureAlarmType = modules/calendar/interceptors/DBMapping.php 
    139 
    1410[before.update] 
    15 encodeURICalendarSignatureAlarm = modules/calendar/interceptors/DBMapping.php 
    1611encodeSignatureAlarmType = modules/calendar/interceptors/DBMapping.php 
    1712encodeUpdateConcept = modules/calendar/interceptors/DBMapping.php 
    1813 
    19 [before.read] 
    20 encodeURICalendarSignatureAlarm = modules/calendar/interceptors/DBMapping.php 
    21 encodeReadConcept = modules/calendar/interceptors/DBMapping.php 
    22  
    23 [after.read] 
    24 decodeReadConcept = modules/calendar/interceptors/DBMapping.php 
    25  
    2614[before.create] 
    27 encodeURICalendarSignatureAlarm = modules/calendar/interceptors/DBMapping.php 
    2815encodeSignatureAlarmType = modules/calendar/interceptors/DBMapping.php 
    2916encodeCreateConcept = modules/calendar/interceptors/DBMapping.php 
     
    3118[before.delete] 
    3219encodeURICalendarSignatureAlarm = modules/calendar/interceptors/DBMapping.php 
     20 
     21[PostgreSQL.mapping] 
     22id = id 
     23type = action_id 
     24time = time 
     25unit = unit 
     26calendarSignature = calendar_signature_id 
  • trunk/prototype/config/calendarToSchedulable.ini

    r5399 r5437  
    11service = PostgreSQL 
     2PostgreSQL.concept = calendar_to_calendar_object 
    23 
    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] 
    85createCalendarToSchedulable = modules/calendar/interceptors/DAViCalAdapter.php 
    96 
    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] 
     8id = id 
     9calendar = calendar_id 
     10schedulable = calendar_object_id 
  • trunk/prototype/config/expressoCalendar.ini

    r5413 r5437  
    11folder = "calendar" 
    2  
    3 useCaldav = false 
     2useCaldav = true 
    43 
    54;Utilizar ou não caldav {TRUE or FALSE} 
  • trunk/prototype/config/modulePreference.ini

    r5384 r5437  
    11service = PostgreSQL 
     2PostgreSQL.concept = module_preference 
    23 
    3 [before.read] 
    4 encodeURImodulePreference = modules/calendar/interceptors/DBMapping.php 
    5 encodeReadConcept = modules/calendar/interceptors/DBMapping.php 
    64 
    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] 
     6id = id 
     7user = user_uidnumber 
     8value = value 
     9name = name 
     10module = module 
  • trunk/prototype/config/participant.ini

    r5399 r5437  
    11service = PostgreSQL 
     2PostgreSQL.concept = calendar_participant 
    23 
    34[links] 
     
    67alarms = alarm 
    78 
    8 [before.read] 
    9 encodeURIParticipant = modules/calendar/interceptors/DBMapping.php 
    10 encodeReadConcept = modules/calendar/interceptors/DBMapping.php 
    11  
    12 [after.read] 
    13 decodeReadConcept = modules/calendar/interceptors/DBMapping.php 
    14 deepnessReadParticipant = modules/calendar/interceptors/DBMapping.php 
    15  
    16 [before.create] 
    17 encodeURIParticipant = modules/calendar/interceptors/DBMapping.php 
    18 encodeCreateConcept = modules/calendar/interceptors/DBMapping.php 
    19  
    20 [before.find] 
    21 encodeURIParticipant = modules/calendar/interceptors/DBMapping.php 
    22 encodeFindParticipant = modules/calendar/interceptors/DBMapping.php 
    23  
    24 [after.find] 
    25 decodeFindConcept = modules/calendar/interceptors/DBMapping.php 
    26 deepnessFindParticipant = modules/calendar/interceptors/DBMapping.php 
    27  
    28 [before.update] 
    29 encodeURIParticipant = modules/calendar/interceptors/DBMapping.php 
    30 encodeUpdateConcept = modules/calendar/interceptors/DBMapping.php 
    31  
    32 [before.replace] 
    33 encodeURIParticipant = modules/calendar/interceptors/DBMapping.php 
    34 encodeReplaceConcept = modules/calendar/interceptors/DBMapping.php 
    35  
    36 [before.delete] 
    37 encodeURIParticipant = modules/calendar/interceptors/DBMapping.php 
    38 deleteParticipant = modules/calendar/interceptors/Notifications.php 
    39  
    409[after.commit] 
    4110commitParticipant = modules/calendar/interceptors/Notifications.php 
     11 
     12[PostgreSQL.mapping] 
     13id = id 
     14delegatedTo = delegated_to 
     15isOrganizer = is_organizer 
     16isExternal = is_external 
     17status = participant_status_id 
     18schedulable = object_id 
     19user = user_info_id 
  • trunk/prototype/config/preference.ini

    r5341 r5437  
    11service = PostgreSQL 
    2  
    3 [before.read] 
    4  
    5 [after.read] 
    6  
    7 [before.create] 
    8 encodeCreatePreference = modules/core/interceptors/DBMapping.php 
    9  
    10  
    11 [before.find] 
    12  
    13 [after.find] 
  • trunk/prototype/config/repeat.ini

    r5399 r5437  
    44schedulable = schedulable 
    55 
    6 [before.read] 
    7 encodeURIRepeat = modules/calendar/interceptors/DBMapping.php 
    8  
    9 [after.read] 
    10 decodeReadConcept = modules/calendar/interceptors/DBMapping.php 
    11  
    12 [before.create] 
    13 encodeURIRepeat = modules/calendar/interceptors/DBMapping.php 
    14 encodeCreateConcept = modules/calendar/interceptors/DBMapping.php 
    15  
    16 [before.update] 
    17 encodeURIRepeat = modules/calendar/interceptors/DBMapping.php 
    18 encodeUpdateConcept = modules/calendar/interceptors/DBMapping.php 
  • trunk/prototype/config/schedulable.ini

    r5399 r5437  
    11service = PostgreSQL 
     2PostgreSQL.concept = calendar_object 
    23 
    34[links] 
     
    67 
    78[before.create] 
    8 encodeURISchedulable = modules/calendar/interceptors/DBMapping.php 
    99encodeCreateSchedulable = modules/calendar/interceptors/DBMapping.php 
    1010 
     
    1313 
    1414[before.find] 
    15 encodeURISchedulable = modules/calendar/interceptors/DBMapping.php 
    16 encodeFindSchedulable = modules/calendar/interceptors/DBMapping.php 
     15findSchedulable = modules/calendar/interceptors/DBMapping.php 
    1716 
    1817[after.find] 
    19 encodeURISchedulable = modules/calendar/interceptors/DBMapping.php 
    20 decodeFindSchedulable = modules/calendar/interceptors/DBMapping.php 
    2118deepnessFindEvent = modules/calendar/interceptors/DBMapping.php 
    2219 
    2320[before.update] 
    24 encodeURISchedulable = modules/calendar/interceptors/DBMapping.php 
    2521updateCalendar = modules/calendar/interceptors/DBMapping.php 
    2622updateEvent = modules/calendar/interceptors/Notifications.php 
     
    3026putEvent = modules/calendar/interceptors/DBMapping.php 
    3127 
    32 [before.read] 
    33 encodeURISchedulable = modules/calendar/interceptors/DBMapping.php 
    34 encodeReadConcept = modules/calendar/interceptors/DBMapping.php 
    35  
    36  
    3728[after.read] 
    38 decodeReadConcept = modules/calendar/interceptors/DBMapping.php 
    3929deepnessReadEvent = modules/calendar/interceptors/DBMapping.php 
    4030 
    4131[before.delete] 
    42 encodeURISchedulable = modules/calendar/interceptors/DBMapping.php 
    4332deleteSchedulable = modules/calendar/interceptors/DBMapping.php 
    4433deleteEvent = modules/calendar/interceptors/Notifications.php 
    4534 
    46 [before.deleteAll] 
    47 encodeURISchedulable = modules/calendar/interceptors/DBMapping.php 
    48 encodeDeleteAllConcept = modules/calendar/interceptors/DBMapping.php 
     35[PostgreSQL.mapping] 
     36id = id 
     37uid = cal_uid 
     38type = type_id 
     39startTime = dtstart 
     40summary = summary 
     41description = description 
     42endTime = dtend 
     43location = location 
     44allDay = allday 
     45transparent = transp 
     46class = class_id 
     47repeat = repeat 
     48rangeStart = range_start 
     49rangeEnd = range_end 
     50lastUpdate = last_update 
     51dtstamp = dtstamp 
     52sequence = sequence 
     53timezone = tzid 
  • trunk/prototype/config/user.ini

    r5399 r5437  
    77 
    88service = OpenLDAP 
     9PostgreSQL.concept = calendar_ex_participant 
    910 
    1011[links] 
    1112participants = participant 
    1213 
    13 [OpenLDAP.after.read] 
    14 decodeReadUser = modules/calendar/interceptors/LDAPMapping.php 
    15  
    16 [PostgreSQL.before.read] 
    17 encodeURIUser = modules/calendar/interceptors/DBMapping.php 
    18  
    1914[PostgreSQL.before.create] 
    20 encodeURIUser = modules/calendar/interceptors/DBMapping.php 
    21 encodeCreateConcept = modules/calendar/interceptors/DBMapping.php 
    2215insertOwnerLink = modules/calendar/interceptors/DBMapping.php 
    23  
    24 [PostgreSQL.before.update] 
    25 encodeURIUser = modules/calendar/interceptors/DBMapping.php 
    26 encodeUpdateConcept = modules/calendar/interceptors/DBMapping.php 
    27  
    28 [PostgreSQL.before.find] 
    29 encodeURIUser = modules/calendar/interceptors/DBMapping.php 
    30 encodeFindConcept = modules/calendar/interceptors/DBMapping.php 
    31  
    32 [PostgreSQL.after.find] 
    33 decodeFindConcept = modules/calendar/interceptors/DBMapping.php 
    3416 
    3517[OpenLDAP.before.create] 
     
    4123 
    4224[OpenLDAP.after.find] 
    43 decodeFindUser = modules/calendar/interceptors/LDAPMapping.php 
    4425findExternalPaticipants = modules/calendar/interceptors/DBMapping.php 
    4526 
     
    4930[before.create] 
    5031encodeServiceUser = modules/calendar/interceptors/DBMapping.php 
     32 
     33[PostgreSQL.mapping] 
     34id = id 
     35name = name 
     36mail = mail 
     37owner = owner 
     38 
     39[OpenLDAP.mapping] 
     40id = uidNumber 
     41name = cn 
     42mail = mail 
     43uid = uid 
     44givenName = givenName 
     45sn = sn 
     46displayName = displayName 
     47mailAlternateAddress = mailAlternateAddress 
     48phpgwAccountStatus = phpgwAccountStatus 
     49accountStatus = accountStatus 
     50objectClass = objectClass 
     51phpgwAccountType = phpgwAccountType 
     52phpgwAccountVisible = phpgwAccountVisible 
  • trunk/prototype/modules/calendar/interceptors/DAViCalAdapter.php

    r5399 r5437  
    2222    * @return     void 
    2323    * @access     public 
    24     */ 
    25     public function createCalendarToSchedulable(&$uri , &$result , &$criteria , $original) 
     24    */   
     25    public function createCalendarToSchedulable(&$uri , &$result , &$data , $original) 
    2626    {                   
    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             
    3646        } 
    3747    }  
     
    171181    { 
    172182       ob_start(); 
    173        require_once ROOTPATH.'/plugins/davicalCliente/caldav-client-v2.php'; 
     183       require_once ROOTPATH.'/plugins/davicalCliente/caldav-client-v2.php';        
    174184       $cal = new CalDAVClient( Config::service( 'CalDAV' , 'url' ).'/'.Config::me( 'uid' ).'/', Config::me( 'uid' ), $_SESSION['wallet']['user']['password']); 
    175185       $cal->DoDELETERequest(Config::service( 'CalDAV' , 'url' ).'/'.Config::me( 'uid' ).'/'.$data.'/'); 
  • trunk/prototype/modules/calendar/interceptors/DBMapping.php

    r5415 r5437  
    66 
    77class DBMapping extends Helpers {        
    8          
    9       //Schedulable 
    10       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           //Alarm 
    35           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           //calendarSignatureAlarm 
    46           static $calendar_signature_alarmMap = array(   'id' => 'id', 
    47                                                          'type' => 'action_id', 
    48                                                          'time' => 'time', 
    49                                                          'unit' => 'unit', 
    50                                                          'calendarSignature' => 'calendar_signature_id'); 
    51            
    52           //modulePrefence 
    53           static $module_preferenceMap = array(  'id' => 'id', 
    54                                                  'user' => 'user_uidnumber', 
    55                                                  'value' => 'value', 
    56                                                  'name' => 'name', 
    57                                                  'module' => 'module'); 
    58            
    59           //Participant 
    60           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           //User 
    69           static $calendar_ex_participantMap = array(   'id'   => 'id', 
    70                                                         'name' => 'name', 
    71                                                         'mail' => 'mail', 
    72                                                         'owner' => 'owner'); 
    73  
    74           //Repeat 
    75           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           //Calendar 
    92           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           //Signature 
    101           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'); 
    1208            
    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) ); 
    13913 
    14014    //        if( !isset( $new['repeat'] )) 
    14115    //            $new['range_end'] = '7287926400'; // 12/12/2200 
    14216    //        else 
    143             $new['range_end'] = gmdate( 'd-m-Y' , (int)($params['endTime'] / 1000) ); 
     17            $params['rangeEnd'] = gmdate( 'd-m-Y' , (int)($params['endTime'] / 1000) ); 
    14418            /////////////////////////////////////////////////////////////////// 
    14519 
    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(); 
    15124             
    15225        }        
     
    16336        } 
    16437         
    165         $params = self::parseConcept($params , self::$calendar_alarmMap);        
    166         $params['action_id']    = self::codeAlarmType($params['action_id']); 
     38        $params['type'] = self::codeAlarmType($params['type']); 
    16739         
    16840        }   
     
    17547    public function encodeCreateAttachment( &$uri , &$params , &$criteria , $original ){ 
    17648        $params['source'] = base64_encode( $params['source'] ); 
    177                 $params = self::parseConcept($params , self::$attachmentMap);            
    17849        } 
    17950/////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    18051         
    18152    public function encodeSignatureAlarmType( &$uri , &$params , &$criteria , $original ){ 
    182                 $params['type'] = self::codeAlarmType($params['type']); 
     53        $params['type'] = self::codeAlarmType($params['type']); 
    18354    }   
    18455         
    185 ////Encode URI      
    186     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 ///////////////////////////////////////////////////////////// 
    21756 
    21857    public function insertOwnerLink (&$uri , &$params , &$criteria , $original ){ 
     
    22564    }   
    22665       
    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    
    26778/////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    26879 
     
    28394      
    28495//Encode Update 
    285     public function encodeUpdateConcept( &$uri , &$params , &$criteria , $original ){ 
    286         $params = self::parseConcept( $params , self::${$uri['concept'].'Map'} );                        
    287     }     
    28896 
    28997    public function encodeUpdateSchedulable( &$uri , &$params , &$criteria , $original ){        
     
    292100        if(isset($params['endTime'])) 
    293101                $params['rangeEnd'] = gmdate( 'd-m-Y' , (int)($params['endTime'] / 1000) );        
    294          
    295        $params = self::parseConcept( $params , self::${$uri['concept'].'Map'} );                         
     102                 
    296103                 
    297104     }         
     
    328135    }  
    329136/////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    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     }     
    337137     
    338138    public function verifyCalendarLocation( &$uri , &$params , &$criteria , $original ){ 
     
    341141    }  
    342142     
    343     public function setCalendarLocation( &$uri , &$params , &$criteria , $original ){ 
    344         if(isset($params['name'])) 
    345             $params['location'] = $params['name']; 
    346     }  
    347143       
    348144    //TODO: Remover apos suporte a ManytoMany na api  
     
    381177       } 
    382178        
     179       return $result; 
     180        
    383181   }  
    384182    
     
    406204                } 
    407205       } 
    408  
    409206   }  
    410207    
     
    514311                      array( '='  , 'sent' , '0') ,   
    515312                      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]) );  
    518315 
    519316            //Busca os Alarmes no Range 
     
    680477        $newCriteria = $original['criteria']; 
    681478        $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')) );         
    686481            $externalUsers = Controller::find( $newuri , $original['properties'] ? $original['properties'] : null , $newCriteria ); 
    687482 
     
    698493 
    699494            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 
    710499    public function createSchedulableMails( &$uri , &$result , &$criteria , $original ){ 
    711500         
     
    948737        return ( isset( $isOwner[0]['id'] ) ) ? true : false;  
    949738    } 
    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 
    1001740    private static function schedulable2calendarToObject($Schedulable) 
    1002741    { 
  • trunk/prototype/modules/calendar/interceptors/Helpers.php

    r5341 r5437  
    11<?php 
    22 
    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       
     3class Helpers {     
    824 
    835    public static function futureEvent( $startTime , $rangeEnd ) 
  • trunk/prototype/modules/calendar/interceptors/LDAPMapping.php

    r5341 r5437  
    44 
    55class LDAPMapping extends Helpers { 
    6          
    7        //externalUser 
    8           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     } 
    176 
    187   public function encodeFindUser( &$uri , &$params , &$criteria , $original ){ 
     
    3726                                                                    ), 
    3827                                                                array('OR',  
    39                                                                         array('*','cn',$criteria['filter'][2]), 
     28                                                                        array('*','name',$criteria['filter'][2]), 
    4029                                                                        array('*','givenName',$criteria['filter'][2]), 
    4130                                                                        array('*','uid',$criteria['filter'][2]), 
     
    4736                                                          ) 
    4837                                                ); 
    49                 else 
    50                     $criteria['filter'] = self::parseFilter($criteria['filter'], self::$usertMap); 
    5138            } 
    5239           
    5340    }   
    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    
    7242} 
    7343 
  • trunk/prototype/modules/calendar/interceptors/Notifications.php

    r5399 r5437  
    2121    {     
    2222        if(Config::regGet('noAlarm') !== false) return; //Escapa notificações caso a flag de noAlarm esteja ativa. 
    23          
     23               
    2424        $organizers = array(); //Cache Organizadores 
    2525        $schedulables = array(); //Cache Schedulables 
  • trunk/prototype/modules/calendar/js/calendar.codecs.js

    r5415 r5437  
    9191 
    9292                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]; 
    9494                } 
    9595 
     
    272272                                user: User.me.id,        
    273273                                calendar: { 
    274                                         id: Calendar.signatureOf[form.signature].calendar.id, 
     274                                        id: Calendar.calendarOf[form.signature].id, 
    275275                                        name: Encoder.htmlEncode(form.name), 
    276276                                        description: Encoder.htmlEncode(form.description), 
     
    351351                                        user: User.me.id, 
    352352                                        status: form.status, 
    353                                         id: form.attendee_organizer[0], 
     353                                        id: form.meId, 
    354354                                        isOrganizer: 0, 
    355355                                        alarms: typeof(form.alarmTime) != 'undefined' ?  
     
    468468        var res = $.map(evtObj, function( form ){ 
    469469     
    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, 
    471471 
    472472                    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  
    4848        dayOfWeek: 
    4949                { 
    50                         'SAN': 0, 
     50                        'SUN': 0, 
    5151                        'MON': 1, 
    5252                        'TUE': 2, 
  • trunk/prototype/modules/calendar/js/helpers.js

    r5409 r5437  
    153153                 
    154154                /*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'); 
    156156                 
    157157                /*Adicionar alarms padrões, quando alterado a agenda do usuário*/                
     
    12491249 
    12501250function mountCriteriaList(view, page_index, calerdars_selecteds){ 
    1251         var criteria = {deepness: 2, order: 'startTime'} 
     1251        var rangeStart , rangeEnd; 
    12521252        switch (view){ 
    12531253                case 'basicDay': 
    12541254                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; 
    12561258                case 'agendaWeek': 
    12571259                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; 
    12611265                case 'month': 
    12621266                        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; 
    12641270                case 'year': 
    12651271                        var dateStart = new Date().add({years: page_index});     
     
    12691275                        if(dateEnd.getMonth() != 11) 
    12701276                                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 
    12731283} 
    12741284 
  • trunk/prototype/modules/calendar/templates/attendee_add.ejs

    r5422 r5437  
    88<!--                            <option value="another">Outra pessoa vai</option>--> 
    99                        </select> 
     10                        <%if(data.event.organizer.id != data.event.me.id){%> 
     11                            <input type="hidden" name="meId" value="<%=data.event.me.id%>"> 
     12                        <%}%> 
    1013                        <fieldset class="add-attendee-search search-field ui-corner-all hidden"> 
    1114                                <span class="ui-icon ui-icon-search"></span> 
  • trunk/prototype/plugins/davicalCliente/caldav-client-v2.php

    r5399 r5437  
    446446      $this->SetMatch( true, $etag ); 
    447447    } 
    448     $this->DoRequest($url); 
    449     return $this->resultcode; 
     448    return $this->DoRequest($url); 
    450449  } 
    451450 
  • trunk/prototype/services/OpenLDAP.php

    r5341 r5437  
    99    public function find  ( $uri, $justthese = false, $criteria = false ) 
    1010    { 
    11         if($justthese === false || $justthese === null) 
    12                 $justthese = array('*'); 
     11        $map = Config::get($uri['concept'], 'OpenLDAP.mapping');  
    1312         
    1413        if( !isset($criteria["limit"]) ) 
    1514                $criteria["limit"] = $this->limit; 
    1615         
    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"]);  
    1917        if(!$sr) return false;  
    2018 
     
    2220            ldap_sort( $this->con, $sr, $criteria["order"] );  
    2321         
    24         return  self::_formatEntries( ldap_get_entries( $this->con, $sr ) ); 
     22        return  self::_formatEntries( ldap_get_entries( $this->con, $sr ) , $map); 
    2523    } 
    2624 
    2725    public function read ( $uri, $justthese = false ) 
    2826    { 
     27        $map = Config::get($uri['concept'], 'OpenLDAP.mapping');  
     28         
    2929        if( $justthese === false || $justthese === null ) 
    3030                $sr =  ldap_search( $this->con, $this->config['context'], '('.$this->config['idAtribute'].'='.$uri['id'].')' ); 
    3131        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) ); 
    3333 
    3434        if(!$sr) return false;  
    3535 
    36         $return =  self::_formatEntries( ldap_get_entries( $this->con, $sr ) ); 
     36        $return =  self::_formatEntries( ldap_get_entries( $this->con, $sr ) , $map ); 
    3737         
    3838        return isset($return[0]) ? $return[0] : array(); 
     
    8787    } 
    8888 
    89     private static function _formatEntries ( $pEntries )  
     89    private static function _formatEntries ( $pEntries , &$map )  
    9090    {            
    9191        if( !$pEntries ) return( false );   
    92  
     92             
     93        $newMap = array(); 
     94        foreach ($map as $i => &$v) 
     95            $newMap[strtolower($v)] = $i; 
     96          
    9397        $return = array(); 
    94  
    9598        for ($i=0; $i < $pEntries["count"]; $i++) 
    9699        { 
     
    98101              foreach ($pEntries[$i] as $index => $value) 
    99102              { 
    100                   if(!is_numeric($index) && $index != 'count') 
     103                  if(isset($newMap[$index])) 
    101104                  { 
    102105                      if(is_array($value)) 
    103106                      { 
    104107                          if(count($value) == 2) 
    105                               $entrieTmp[$index] = $value['0']; 
     108                              $entrieTmp[$newMap[$index]] = $value['0']; 
    106109                          else 
    107110                          { 
    108111                              foreach ($value as $index2 =>$value2) 
    109112                              { 
    110                                   if($index != 'count') 
    111                                       $entrieTmp[$index][$index2] = $value2; 
     113                                  if($index2 != 'count') 
     114                                      $entrieTmp[$newMap[$index]][$index2] = $value2; 
    112115                              } 
    113116                          } 
    114117                      } 
    115118                      else 
    116                           $entrieTmp[$index] = $value; 
     119                          $entrieTmp[$newMap[$index]] = $value; 
    117120                  } 
    118121              } 
     
    124127    } 
    125128 
    126     private static function parseCriteria( $criteria ) 
     129    private static function parseCriteria( $criteria  , &$map) 
    127130    {   
    128131        $result = ""; 
     
    142145 
    143146 
    144                 $result .= self::parseFilter( $criteria['filter'] ); 
     147                $result .= self::parseFilter( $criteria['filter'] , $map); 
    145148        } 
    146149         
     
    148151    } 
    149152 
    150     private static function parseFilter( $filter ) 
     153    private static function parseFilter( $filter , &$map) 
    151154    { 
    152155        $result = ''; 
     
    159162 
    160163            foreach( $filter as $i => $f ) 
    161                 $nested .= self::parseFilter($f); 
     164                $nested .= self::parseFilter($f , $map); 
    162165 
    163166            $fil =  $op.$nested; 
    164167        } 
    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 
    168173        return '('.$fil.')'; 
    169174    } 
     
    182187        } 
    183188    } 
     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    } 
    184203} 
    185204 
  • trunk/prototype/services/PostgreSQL.php

    r5399 r5437  
    88     
    99    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 ); 
    1618    } 
    1719 
    1820   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) ); 
    2833    } 
    2934 
    3035    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'])); 
    3237    } 
    3338 
    3439    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'])); 
    3642    } 
    3743                 
    3844    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']) .'\''); 
    4046    } 
    4147 
    4248    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 ); 
    4450    } 
    4551 
     
    122128    public function teardown(){} 
    123129 
    124     private static function parseInsertData( $data ){ 
    125              
     130    private static function parseInsertData( $data , $concept){ 
     131          
     132            $map = Config::get($concept, 'PostgreSQL.mapping'); 
     133         
    126134            $ind = array(); 
    127135            $val = array(); 
    128136             
    129137            foreach ($data as $i => $v){ 
    130                     $ind[] = $i; 
     138                    if(!isset($map[$i])) continue; 
     139                 
     140                    $ind[] = $map[$i]; 
    131141                    $val[] = '\''.addslashes($v).'\''; 
    132142            } 
     
    135145    } 
    136146         
    137     private static function parseUpdateData( $data ){ 
    138              
     147    private static function parseUpdateData( $data , $concept){ 
     148             
     149            $map = Config::get($concept, 'PostgreSQL.mapping'); 
     150                         
    139151            $d = array(); 
    140  
    141152            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            } 
    143158             
    144159            return 'SET '.implode(',', $d); 
     
    160175    } 
    161176         
    162     private static function parseCriteria( $criteria ){                
     177    private static function parseCriteria( $criteria  , &$map ){                
    163178             
    164179            $result = ''; 
     
    177192                */ 
    178193 
    179                     $result .= 'WHERE '.self::parseFilter( $criteria['filter'] ); 
     194                    $result .= 'WHERE '.self::parseFilter( $criteria['filter'] , $map); 
    180195            } 
    181196            /* 
     
    210225    } 
    211226     
    212     private static function parseFilter( $filter ){ 
     227    private static function parseFilter( $filter ,&$map){ 
    213228     
    214229        if( !is_array( $filter ) || count($filter) <= 0) return null; 
    215  
     230                 
    216231        $op = self::parseOperator( array_shift( $filter ) ); 
    217  
     232         
    218233        if( is_array($filter[0]) ) 
    219234        { 
     
    221236 
    222237            foreach( $filter as $i => $f ) 
    223                 $nested[] = self::parseFilter( $f ); 
     238                $nested[] = self::parseFilter( $f , $map); 
    224239 
    225240            return( '('.implode( ' '.$op.' ', $nested ).')' ); 
    226241        } 
    227242 
     243         
     244        if(isset($map[$filter[0]])) 
     245            $filter[0] = $map[$filter[0]]; 
     246         
    228247        $igSuffix = $igPrefix = ''; 
    229  
     248                 
    230249        if( strpos( $op[0], 'i' ) === 0 ) 
    231250        { 
     
    258277        } 
    259278    } 
    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    
    261302} 
    262303 
  • trunk/prototype/services/iCal.php

    r5415 r5437  
    143143                                        $interation['participant://'.$pID]['status'] = $params['status']; 
    144144                                      } 
     145                                       
     146                                       Config::regSet('noAlarm', FALSE); //reativa notificação 
    145147                                } 
    146148                                else 
  • trunk/prototype/upload.php

    r5399 r5437  
    1313    $result[$name] = Controller::create( $URI, $file ); 
    1414 
    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 ); 
    1915 
    2016    unset( $file['source'] ); 
Note: See TracChangeset for help on using the changeset viewer.