Ignore:
Timestamp:
02/14/12 16:52:04 (12 years ago)
Author:
acoutinho
Message:

Ticket #2434 - Implementacao anexos, acls e delegacao de participantes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/api/controller.php

    r5437 r5514  
    11<?php 
     2 
    23 
    34if( !defined( 'ROOTPATH' ) ) 
     
    2526        static $includes = array(); 
    2627        static $tx = array(); 
     28        static $isConcept = array(); 
    2729        static $txID = 0; 
    2830        static $wallet; 
     
    150152 
    151153        //TODO: Compatibilizar as configs relativas aos modulos, adicionando os mesmo nos parametros passados 
    152         public static function links( $concept = false ) 
    153         { 
     154        public static function links( $concept = false, $linkage = false ) 
     155        { 
     156             
     157 
    154158            if( !isset(self::$config[ $concept ]) ) 
    155159              self::$config[ $concept ] = self::loadConfig( $concept ); 
    156160 
    157             return( isset(self::$config[ $concept ]['links']) ?  
    158                           self::$config[ $concept ]['links'] : array() ); 
    159         } 
    160  
    161         public static function isConcept( $concept ) 
     161            $links = array(); 
     162            self::$isConcept[ $concept ] = array(); 
     163 
     164            if( isset(self::$config[ $concept ][ 'model.hasOne' ]) ) 
     165                foreach( self::$config[ $concept ][ 'model.hasOne' ] as $linkName => $linkTarget ) 
     166                { 
     167                    list( $target, $link ) = explode( '.', $linkTarget ); 
     168 
     169                    if( $linkage === $linkName ) 
     170                        $return = $link; 
     171 
     172                    $links[$linkName] = $target; 
     173                    self::$isConcept[ $concept ][ $linkName ] = true; 
     174                } 
     175            if( isset(self::$config[ $concept ][ 'model.depends' ]) ) 
     176                foreach( self::$config[ $concept ][ 'model.depends' ] as $linkName => $linkTarget ) 
     177                { 
     178                    list( $target, $link ) = explode( '.', $linkTarget ); 
     179 
     180                     if( $linkage === $linkName ) 
     181                        $return = $link; 
     182 
     183                    $links[$linkName] = $target; 
     184                    self::$isConcept[ $concept ][ $linkName ] = true; 
     185                } 
     186            if( isset(self::$config[ $concept ][ 'model.hasMany' ]) ) 
     187                foreach( self::$config[ $concept ][ 'model.hasMany' ] as $linkName => $linkTarget ) 
     188                { 
     189                    list( $target, $link ) = explode( '.', $linkTarget ); 
     190 
     191                     if( $linkage === $linkName ) 
     192                        $return = $link; 
     193 
     194                    $links[$linkName] = $target; 
     195                } 
     196 
     197            return( isset($return) ? $return : $links ); 
     198        } 
     199 
     200        public static function isConcept( $concept, $linkName ) 
    162201        {  
    163             if( isset( self::$config[ $concept ] ) &&  
    164                 self::$config[ $concept ] ) 
    165                 return( true ); 
    166                 else 
    167                 return file_exists( ROOTPATH."/config/$concept.ini" ); 
     202            if( !isset( self::$isConcept[ $concept ] ) ) 
     203                self::links( $concept ); 
     204 
     205            return( isset(self::$isConcept[ $concept ][ $linkName ]) ); 
    168206        } 
    169207 
     
    576614 
    577615                $postpone = array(); 
     616                $linkNames = array(); 
    578617 
    579618                if( $data ) 
     
    585624                        if( isset( $data[$linkName] ) && is_array( $data[$linkName] ) ) 
    586625                        { 
    587                             if( self::isConcept( $linkName ) ) 
     626                                if( self::isConcept( $URI['concept'], $linkName ) ) 
    588627                                    $data[$linkName] = self::put( array( 'concept' => $linkTarget ), $data[$linkName], &$txIds ); 
    589628                            else 
    590                                     $postpone[$linkTarget] = $data[$linkName]; 
     629                            { 
     630                                    $postpone[ $linkTarget ] =  $data[$linkName]; 
     631                                    $linkNames[ $linkTarget ] = $linkName; 
     632                            } 
    591633                        } 
    592634                    } 
     
    609651                            $value = array( 'id' => $value ); 
    610652 
    611                           $value[ $URI['concept'] ] = $URI['id']; 
    612  
     653                          $value[ self::links( $URI['concept'], $linkNames[ $linkTarget ] ) ] = $URI['id']; 
     654   
    613655                          self::put( array( 'concept' => $linkTarget ), $value, &$txIds ); 
    614656                      } 
     
    658700 
    659701Controller::$cache = Controller::loadCache(); 
    660 ?> 
     702// ?> 
Note: See TracChangeset for help on using the changeset viewer.