Index: trunk/prototype/modules/calendar/interceptors/DBMapping.php
===================================================================
--- trunk/prototype/modules/calendar/interceptors/DBMapping.php	(revision 5341)
+++ trunk/prototype/modules/calendar/interceptors/DBMapping.php	(revision 5366)
@@ -683,20 +683,25 @@
        
         $newCriteria = $original['criteria'];
-        
-        $newCriteria['filter'] = array('AND',$newCriteria['filter'] , array('=' , 'owner', $_SESSION['wallet']['user']['uidNumber']) );        
-        $externalUsers = Controller::find( $newuri , $original['properties'] ? $original['properties'] : null , $newCriteria );
-        
-        if(is_array($externalUsers))
-        {
-            foreach ($externalUsers as $i => $v)
-                $externalUsers[$i]['isExternal'] = '1';
-        }
-        else
-            $externalUsers = array();
-        
-        if(!is_array($result))
-                $result = array();
-            
-        return array_merge($result, $externalUsers);    
+        $valid = true;
+        self::validExternalUserCriteria($newCriteria, self::$calendar_ex_participantMap, $valid);
+        if($valid == true)
+        {
+             $newCriteria['filter'] = array('AND',$newCriteria['filter'] , array('=' , 'owner', $_SESSION['wallet']['user']['uidNumber']) );        
+            $externalUsers = Controller::find( $newuri , $original['properties'] ? $original['properties'] : null , $newCriteria );
+
+            if(is_array($externalUsers))
+            {
+                foreach ($externalUsers as $i => $v)
+                    $externalUsers[$i]['isExternal'] = '1';
+            }
+            else
+                $externalUsers = array();
+
+            if(!is_array($result))
+                    $result = array();
+
+            return array_merge($result, $externalUsers);    
+        }
+       
     }
 
@@ -975,4 +980,29 @@
     }  
     
+    private static function validExternalUserCriteria( $filter, $map , &$ref )
+    {
+        if (!is_array($filter) || count($filter) <= 0)
+            return null;
+
+        $op = array_shift($filter);
+
+        if (is_array($filter[0])) {
+            foreach ($filter as $i => $f)
+                $filter[$i] = self::validExternalUserCriteria($f, $map ,$findCalendar );
+        }
+        else
+        {
+           if( isset($filter[0]) && !in_array($filter[0] , self::$calendar_ex_participantMap))
+             $ref = false;
+  
+            else
+                $filter[0] = isset($map[$filter[0]]) ? $map[$filter[0]] : $filter[0];
+        }
+
+        array_unshift($filter, $op);
+
+        return( $filter );
+    }
+    
     private static function schedulable2calendarToObject($Schedulable)
     {
Index: trunk/prototype/modules/calendar/interceptors/DAViCalAdapter.php
===================================================================
--- trunk/prototype/modules/calendar/interceptors/DAViCalAdapter.php	(revision 5341)
+++ trunk/prototype/modules/calendar/interceptors/DAViCalAdapter.php	(revision 5366)
@@ -28,5 +28,4 @@
         {      
             ob_start();
-            require_once ROOTPATH.'/modules/calendar/interceptors/DAViCalAdapter.php';
             $schedulable = Controller::read( array( 'concept' => 'schedulable' , 'id' => $original['properties']['schedulable'] ) , null , array('deepness' => '2') );
             $schedulable['URI']['concept'] = 'schedulable';
@@ -40,5 +39,8 @@
     
     static function import($data , $params = false)
-    {     
+    {              
+        $user =  Controller::find(array('concept' => 'user' , 'service' => 'OpenLDAP' ),false,array('filter' => array('=','uid',$params['owner'])));  
+        $params['owner'] = $user[0]['id'];
+        
         self::initSessionVars(array('user' => array('uidNumber' => $params['owner'] )));
         
@@ -67,5 +69,8 @@
     
     static function delete($data , $params = false)
-    {    
+    {         
+        $user =  Controller::find(array('concept' => 'user' , 'service' => 'OpenLDAP' ),false,array('filter' => array('=','uid',$params['owner'])));  
+        $params['owner'] = $user[0]['id'];
+        
         self::initSessionVars(array('user' => array('uidNumber' => $params['owner'] )));
 
@@ -114,4 +119,7 @@
     static function move($origem , $destino , $owner)
     {    
+        $user =  Controller::find(array('concept' => 'user' , 'service' => 'OpenLDAP' ),false,array('filter' => array('=','uid',$owner)));  
+        $owner = $user[0]['id'];
+        
         self::initSessionVars(array('user' => array('uidNumber' => $owner)));
 
