Ignore:
Timestamp:
04/05/12 17:00:04 (12 years ago)
Author:
cristiano
Message:

Ticket #2598 - implementação base REST + oauth

Location:
sandbox/2.4-expresso-api
Files:
237 added
10 edited
4 copied

Legend:

Unmodified
Added
Removed
  • sandbox/2.4-expresso-api

    • Property svn:ignore
      •  

        old new  
        22header.inc.php 
        33._header.inc.php 
         4.htaccess.swp 
  • sandbox/2.4-expresso-api/prototype/api

    • Property svn:ignore set to
      .datalayer.js.kate-swp
  • sandbox/2.4-expresso-api/prototype/api/config.php

    r5764 r5888  
    2020     
    2121    static function me($config) 
    22     { 
    23          
     22    {    
    2423        return isset($_SESSION['wallet']['user'][$config]) ? $_SESSION['wallet']['user'][$config] : false; 
    2524    } 
  • sandbox/2.4-expresso-api/prototype/api/datalayer.js

    r5724 r5888  
    221221       
    222222          return( result ); 
     223    }, 
     224     
     225    /** 
     226    * This method is used to read resources from the server. 
     227    *  
     228    * @param uri Uri of the resource that gonna be readed. 
     229    * @param callback A function that is called when the resource is loaded successfully. When the parameter is ignored the request is made synchrounsly. 
     230    * @param accept The attribute accept that is used to ask the target format to the server 
     231    * @return The target resource when the callback is ommitted ( made it synchronous ) 
     232    */ 
     233 
     234    read: function( uri, callback, accept ){ 
     235        //return this.send( this.dispatchPath + 'rest' + uri, [ 'get', accept || 'json' ], false, callback ); 
     236        //http://expressodev.prognus.com.br/cristiano/expresso-api/rest/maillast 
     237         
     238        return this.send( ('rest' + uri), [ 'get', accept || 'json' ], true, callback, !!!callback,  
     239        {'beforeSend' : function (xhr){  
     240            xhr.setRequestHeader('Authorization', "OAUTH Bearer " + DataLayer.me.token)}  
     241        }); 
     242       
     243    }, 
     244 
     245    /** 
     246    * This method is used to create resources from the server. 
     247    *  
     248    * @param uri Uri of the resource that gonna be readed. 
     249    * @param callback A function that is called when the resource is created on the server successfully. When the parameter is ignored the request is made synchrounsly. 
     250    * @param accept The attribute accept that is used to ask the target format to the server. 
     251    * @return The result response of the create from the server when the callback is ommitted ( made it synchronous ) 
     252    */ 
     253     
     254    create: function( uri, data, callback, accept ){ 
     255       
     256        return this.send( this.dispatchPath + 'rest' + uri, [ 'post', accept || 'json' ], data, callback, !!!callback,  
     257        {'beforeSend' : function (xhr){  
     258            xhr.setRequestHeader('Authorization', "OAUTH Bearer " + DataLayer.me.token)}  
     259        }); 
     260       
     261    }, 
     262 
     263    /** 
     264    * This method is used to update resources from the server. 
     265    *  
     266    * @param uri Uri of the resource that gonna be readed. 
     267    * @param callback A function that is called when the resource is update on the server successfully. When the parameter is ignored the request is made synchrounsly. 
     268    * @param accept The attribute accept that is used to ask the target format to the server 
     269    * @return The result response of the update from the server when the callback is ommitted ( made it synchronous ) 
     270    */ 
     271 
     272    update: function( uri, data, callback, accept ){ 
     273       
     274        return this.send( this.dispatchPath + 'rest' + uri, [ 'put', accept || 'json' ], data, callback, !!!callback,  
     275        {'beforeSend' : function (xhr){  
     276            xhr.setRequestHeader('Authorization', "OAUTH Bearer " + DataLayer.me.token)}  
     277        }); 
     278       
     279    }, 
     280 
     281    /** 
     282    * This method is used to delete resources from the server. 
     283    *  
     284    * @param uri Uri of the resource that gonna be readed. 
     285    * @param callback A function that is called when the resource is deleted successfully in the server. When the parameter is ignored the request is made synchrounsly. 
     286    * @param accept The attribute accept that is used to ask the target format to the server 
     287    * @return The result response of the delete from the server when the callback is ommitted ( made it synchronous ) 
     288    */ 
     289 
     290    "delete": function( uri, callback, accept ){ 
     291       
     292        return this.send( this.dispatchPath + 'rest' + uri, [ 'delete', accept || 'json' ], false, callback, !!!callback,  
     293        {'beforeSend' : function (xhr){  
     294            xhr.setRequestHeader('Authorization', "OAUTH Bearer " + DataLayer.me.token)}  
     295        }); 
     296       
    223297    }, 
    224298     
     
    19912065 
    19922066        if( !this.dispatchPath ) 
    1993             this.dispatchPath = "../../"; 
     2067            this.dispatchPath = "prototype/"; 
    19942068 
    19952069        if( !this.templatePath ) 
     
    20062080 
    20072081        this.start(); 
     2082        this.me = this.dispatch( "me" ); 
    20082083    } 
    20092084} 
  • sandbox/2.4-expresso-api/prototype/config/OpenLDAP.srv

    r5534 r5888  
    55host = 127.0.0.1 
    66 
    7 ;context = dc=exemplo.com 
    8 ;user =  
    9 ;password =  
     7context = "dc=prognus" 
     8user = "cn=admin,dc=prognus" 
     9password = "prognus" 
  • sandbox/2.4-expresso-api/prototype/config/PostgreSQL.srv

    r5534 r5888  
    33[config] 
    44port = 5432 
    5 dbname= expresso 
     5dbname= expresso24cristianoAPI 
    66user=postgres 
    7 host = /var/run/postgresql 
    8 ;conexão via tcp 
     7host = /tmp 
    98;host = 127.0.0.1 
    109 
  • sandbox/2.4-expresso-api/prototype/config/oauthCliente.ini

    r5514 r5888  
    1 ; [service] 
    2 ; OpenLDAP = '' 
    3 ; PostgreSQL = external 
    4 ;  
    5 ; [service.conflict] 
    6 ; checkExternal = modules/calendar/interceptors/DBMapping.php 
    7  
    8 service = OpenLDAP 
    9 PostgreSQL.concept = calendar_ex_participant 
    10  
    11 [model.hasMany] 
    12 participants = participant.user 
    13  
    14 [PostgreSQL.before.create] 
    15 insertOwnerLink = modules/calendar/interceptors/DBMapping.php 
    16  
    17 [OpenLDAP.before.create] 
    18 encodeURIUser = modules/calendar/interceptors/DBMapping.php 
    19 encodeCreateConcept = modules/calendar/interceptors/DBMapping.php 
    20  
    21 [OpenLDAP.before.find] 
    22 encodeFindUser = modules/calendar/interceptors/LDAPMapping.php 
    23  
    24 [OpenLDAP.after.find] 
    25 findExternalPaticipants = modules/calendar/interceptors/DBMapping.php 
    26  
    27 [before.update] 
    28 encodeServiceUser = modules/calendar/interceptors/DBMapping.php 
    29  
    30 [before.create] 
    31 encodeServiceUser = modules/calendar/interceptors/DBMapping.php 
     1service = PostgreSQL 
     2PostgreSQL.concept = clients 
    323 
    334[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 
     5client_id = client_id 
     6client_secret = client_secret 
     7redirect_uri = redirect_uri 
  • sandbox/2.4-expresso-api/prototype/config/oauthCode.ini

    r5514 r5888  
    1 ; [service] 
    2 ; OpenLDAP = '' 
    3 ; PostgreSQL = external 
    4 ;  
    5 ; [service.conflict] 
    6 ; checkExternal = modules/calendar/interceptors/DBMapping.php 
    7  
    8 service = OpenLDAP 
    9 PostgreSQL.concept = calendar_ex_participant 
    10  
    11 [model.hasMany] 
    12 participants = participant.user 
    13  
    14 [PostgreSQL.before.create] 
    15 insertOwnerLink = modules/calendar/interceptors/DBMapping.php 
    16  
    17 [OpenLDAP.before.create] 
    18 encodeURIUser = modules/calendar/interceptors/DBMapping.php 
    19 encodeCreateConcept = modules/calendar/interceptors/DBMapping.php 
    20  
    21 [OpenLDAP.before.find] 
    22 encodeFindUser = modules/calendar/interceptors/LDAPMapping.php 
    23  
    24 [OpenLDAP.after.find] 
    25 findExternalPaticipants = modules/calendar/interceptors/DBMapping.php 
    26  
    27 [before.update] 
    28 encodeServiceUser = modules/calendar/interceptors/DBMapping.php 
    29  
    30 [before.create] 
    31 encodeServiceUser = modules/calendar/interceptors/DBMapping.php 
     1service = PostgreSQL 
     2PostgreSQL.concept = auth_codes 
    323 
    334[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 
     5redirect_uri = redirect_uri 
     6scope = scope 
     7expires = expires 
     8code = code 
     9client_id = client_id 
     10user_id = user_id 
  • sandbox/2.4-expresso-api/prototype/config/oauthRefreshToken.ini

    r5514 r5888  
    1 ; [service] 
    2 ; OpenLDAP = '' 
    3 ; PostgreSQL = external 
    4 ;  
    5 ; [service.conflict] 
    6 ; checkExternal = modules/calendar/interceptors/DBMapping.php 
    7  
    8 service = OpenLDAP 
    9 PostgreSQL.concept = calendar_ex_participant 
    10  
    11 [model.hasMany] 
    12 participants = participant.user 
    13  
    14 [PostgreSQL.before.create] 
    15 insertOwnerLink = modules/calendar/interceptors/DBMapping.php 
    16  
    17 [OpenLDAP.before.create] 
    18 encodeURIUser = modules/calendar/interceptors/DBMapping.php 
    19 encodeCreateConcept = modules/calendar/interceptors/DBMapping.php 
    20  
    21 [OpenLDAP.before.find] 
    22 encodeFindUser = modules/calendar/interceptors/LDAPMapping.php 
    23  
    24 [OpenLDAP.after.find] 
    25 findExternalPaticipants = modules/calendar/interceptors/DBMapping.php 
    26  
    27 [before.update] 
    28 encodeServiceUser = modules/calendar/interceptors/DBMapping.php 
    29  
    30 [before.create] 
    31 encodeServiceUser = modules/calendar/interceptors/DBMapping.php 
     1service = PostgreSQL 
     2PostgreSQL.concept = refresh_tokens 
    323 
    334[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 
     5refresh_token = refresh_token 
     6client_id = client_id 
     7user_id = user_id 
     8expires = expires 
     9scope = scope 
     10refresh_token = refresh_token 
  • sandbox/2.4-expresso-api/prototype/config/oauthToken.ini

    r5514 r5888  
    1 ; [service] 
    2 ; OpenLDAP = '' 
    3 ; PostgreSQL = external 
    4 ;  
    5 ; [service.conflict] 
    6 ; checkExternal = modules/calendar/interceptors/DBMapping.php 
    7  
    8 service = OpenLDAP 
    9 PostgreSQL.concept = calendar_ex_participant 
    10  
    11 [model.hasMany] 
    12 participants = participant.user 
    13  
    14 [PostgreSQL.before.create] 
    15 insertOwnerLink = modules/calendar/interceptors/DBMapping.php 
    16  
    17 [OpenLDAP.before.create] 
    18 encodeURIUser = modules/calendar/interceptors/DBMapping.php 
    19 encodeCreateConcept = modules/calendar/interceptors/DBMapping.php 
    20  
    21 [OpenLDAP.before.find] 
    22 encodeFindUser = modules/calendar/interceptors/LDAPMapping.php 
    23  
    24 [OpenLDAP.after.find] 
    25 findExternalPaticipants = modules/calendar/interceptors/DBMapping.php 
    26  
    27 [before.update] 
    28 encodeServiceUser = modules/calendar/interceptors/DBMapping.php 
    29  
    30 [before.create] 
    31 encodeServiceUser = modules/calendar/interceptors/DBMapping.php 
     1service = PostgreSQL 
     2PostgreSQL.concept = access_tokens 
    323 
    334[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 
     5oauth_token = oauth_token 
     6client_id = client_id 
     7user_id = user_id 
     8expires = expires 
     9scope = scope 
     10refresh_token = refresh_token 
  • sandbox/2.4-expresso-api/prototype/config/user.ini

    r5514 r5888  
    2323 
    2424[OpenLDAP.after.find] 
    25 findExternalPaticipants = modules/calendar/interceptors/DBMapping.php 
     25;findExternalPaticipants = modules/calendar/interceptors/DBMapping.php 
    2626 
    2727[before.update] 
     
    5151phpgwAccountType = phpgwAccountType 
    5252phpgwAccountVisible = phpgwAccountVisible 
     53password = userPassword 
  • sandbox/2.4-expresso-api/prototype/me.php

    r5399 r5888  
    44 
    55$me = Controller::read(array('concept' => 'user', 'service' => 'OpenLDAP'  , 'id' => Config::me('uidNumber'))); 
    6  
     6$me['token'] = $_SESSION['oauth']['access_token'];   
    77echo json_encode( $me ); 
    88 
  • sandbox/2.4-expresso-api/prototype/modules/calendar/interceptors/DBMapping.php

    r5752 r5888  
    175175        $lastExceptions = Controller::find( array( 'concept' => 'repeatOccurrence' ), array("occurrence") , array( 'filter' => array('AND', array( '=', 'repeat', $id ) , array( '=', 'exception', 1 ) ) )); 
    176176 
    177         //Recurepa as execeções anteriores caso exista 
     177        //Recurepa as execeᅵᅵes anteriores caso exista 
    178178        if(isset($lastExceptions) && count($lastExceptions)) 
    179179            foreach($lastExceptions as $key => $value) 
     
    236236        if( $start || $end ) 
    237237        { 
    238             Controller::begin( array( 'service' => 'PostgreSQL') ); 
     238            //Controller::begin( array( 'service' => 'PostgreSQL') ); 
    239239 
    240240            foreach( $result as $id => $res ) 
     
    334334       $u = $result->format('U') * 1000; 
    335335 
    336        if( $u  > $end ) //data da repetição atual maior que a data final da busca do usuario ? 
     336       if( $u  > $end ) //data da repetiᅵᅵo atual maior que a data final da busca do usuario ? 
    337337           break; 
    338338 
     
    632632                    $result[$i]['calendar'] = Controller::read( array( 'concept' => 'calendar' , 'id' => $v['calendar']), false, false);  
    633633                                        $result[$i]['defaultAlarms'] = Controller::find( array( 'concept' => 'calendarSignatureAlarm' ) , false ,array( 'filter' => array('=', 'calendarSignature'  ,  $v['id']) ));     
    634                                         //Caso não seja o dono da agenda retorna o objeto permission com as acls 
     634                                        //Caso nï¿œo seja o dono da agenda retorna o objeto permission com as acls 
    635635                                        if($result[$i]['isOwner'] == 0){ 
    636636                                                $permission = Controller::find( array( 'concept' => 'calendarToPermission'), false ,array( 'filter' => array('AND', array('=', 'calendar' ,  $v['calendar']), array('=', 'user', Config::me('uidNumber') ) ) ) );  
     
    749749                     ))); 
    750750             
    751             return false; /* Mata o restante da execução */ 
     751            return false; /* Mata o restante da execuᅵᅵo */ 
    752752        }  
    753753         
     
    786786    public function createDefaultSignature( &$uri , &$result , &$criteria , $original ){ 
    787787                      
    788     //Caso uma busca não retorne nenhum resultado e foi buscado pelas assinaturas do usuario logado apenas 
     788    //Caso uma busca nï¿œo retorne nenhum resultado e foi buscado pelas assinaturas do usuario logado apenas 
    789789    if(count($result) <= 0 &&  
    790790            ( $original['criteria']['filter'][0] == '=' && 
     
    837837        else 
    838838        { 
    839          //Criaremos uma agenda padrão 
     839         //Criaremos uma agenda padrï¿œo 
    840840          $cal = array('name' => 'Calendario', 
    841                          'description' => 'Calendario Padrão', 
     841                         'description' => 'Calendario Padrï¿œo', 
    842842                         'timezone' =>  (date_default_timezone_get()) ? date_default_timezone_get() : 'America/Sao_Paulo', 
    843843                         'dtstamp' => time().'000' 
  • sandbox/2.4-expresso-api/prototype/services/OpenLDAP.php

    r5441 r5888  
    1919        if( isset($criteria["order"]) ) 
    2020            ldap_sort( $this->con, $sr, $criteria["order"] );  
    21          
     21                 
    2222        return  self::_formatEntries( ldap_get_entries( $this->con, $sr ) , $map); 
    2323    } 
Note: See TracChangeset for help on using the changeset viewer.