Index: /sandbox/2.4.1-3/prototype/api/controller.php
===================================================================
--- /sandbox/2.4.1-3/prototype/api/controller.php	(revision 6357)
+++ /sandbox/2.4.1-3/prototype/api/controller.php	(revision 6526)
@@ -45,5 +45,4 @@
 require_once(ROOTPATH.'/api/config.php');
 use prototype\api\Config as Config;
-
 /**
 TODO list:
@@ -181,4 +180,9 @@
 	public static function rollback( $URI, $criteria = false )
 	{
+	    if( isset( $URI['service'] ) )
+		unset( self::$tx[ $URI['service'] ] );
+
+	    self::$txID--;
+
 	    return self::call( 'rollback', $URI, false, $criteria );
 	}
@@ -485,5 +489,5 @@
 
 		    if( $return === false )
-		return( false );
+			return( false );
 
 		    if( isset($return) )
@@ -530,4 +534,19 @@
 	    return( $URI );
 	}
+	
+	public static function finalizeCommit( $method, $params, $original, $TX = array() )
+	{
+	    if( $TX !== false )
+	    {
+		$TX['rollback'] = !!!$params['properties'];
+
+		if( $params['properties'] && is_array($params['properties']) && isset($params['properties']['id']) )
+		    $TX['id'] = $params['properties']['id'];
+
+		self::$tx[ $params['URI']['service'] ][] = array_merge( $TX, $original['URI'], array( 'service' => $params['URI']['service'], 'method' => $method ) );
+	    }
+
+	    return( empty($params['properties']) ? false : $params['properties'] );
+	}
 
 	//TODO: Compatibilizar as configs relativas aos modulos, adicionando os mesmos nas options passadas
@@ -544,7 +563,5 @@
 
 		if( isset($params['URI']['concept'])  && !self::fire( 'before', $method, $params, $original ) )
-		    return( empty($params['properties']) ? false : $params['properties'] );
-
-		
+		   return( self::finalizeCommit( $method, $params, $original ) );
 
 		if( $params && !$params['service'] )
@@ -568,5 +585,5 @@
 
 		    if( !self::fire( 'before', $method, $params, $original, true ) )
-			return( empty($params['properties']) ? false : $params['properties'] );
+			return( self::finalizeCommit( $method, $params, $original, isset($TX) ? $TX : false ) );
 		}
 
@@ -608,5 +625,5 @@
 		if( isset($params['URI']['service']) )
 		    if( !self::fire( 'after', $method, $params, $original, true ) )
-			return( empty($params['properties']) ? false : $params['properties'] );
+			return( self::finalizeCommit( $method, $params, $original, isset($TX) ? $TX : false ) );
 
 		if( isset($URI['concept']) )
@@ -618,11 +635,6 @@
 		if( isset( $TX ) )
 		{
-		    $TX['rollback'] = !!!$params['properties'];
-
-		    if( $params['properties'] && is_array($params['properties']) && isset($params['properties']['id']) )
-			$TX['id'] = $params['properties']['id'];
-
-		    self::$tx[ $params['URI']['service'] ][] = array_merge( $TX, $original['URI'], array( 'service' => $params['URI']['service'], 'method' => $method ) );
-
+		    //self::finalizeCommit( $params, $original, $method, $TX );
+		    self::finalizeCommit( $method, $params, $original, $TX );
 		    if( isset($commit) && $commit )
 		    {
@@ -636,5 +648,5 @@
 	    catch( Exception $e )
 	    {
-		if( !self::fallback( $e ) )
+		if( !self::fallback( $e, $URI ) )
 		    self::closeAll();
 
@@ -645,5 +657,5 @@
 	}
 
-	public static function fallback( $exception )
+	public static function fallback( $exception, $URI )
 	{
 	    $code = $exception->getCode();
@@ -652,5 +664,5 @@
 		{
 			$fn = self::$fallbackHandlers[ $code ];
-			return $fn( $exception );
+			return $fn( $exception, $URI );
 		}
 
@@ -717,6 +729,11 @@
 		      $URI['id'] = $result['id'];
 
-		self::$tx[ $URI['service'] ][ count(self::$tx[ $URI['service'] ]) - 1 ]['order'] = $order;
-		self::$tx[ $URI['service'] ][ count(self::$tx[ $URI['service'] ]) - 1 ]['id'] = $URI['id'];
+		$index =  count(self::$tx[ $URI['service'] ]) - 1;
+
+		self::$tx[ $URI['service'] ][ $index ]['order'] = $order;
+		self::$tx[ $URI['service'] ][ $index ]['id'] = $URI['id'];
+
+		if( !isset(self::$tx[ $URI['service'] ][ $index ]['concept']) )
+		    self::$tx[ $URI['service'] ][ $index ]['concept'] = $URI['concept'];
 
 		foreach( $postpone as $linkTarget => $dt )
@@ -763,5 +780,5 @@
 	    catch( Exception $e )
 	    {
-		if( !self::fallback( $e ) )
+		if( !self::fallback( $e, $URI ) )
 		    self::closeAll();
 
Index: /sandbox/2.4.1-3/prototype/rest/catalog/ContactResource.php
===================================================================
--- /sandbox/2.4.1-3/prototype/rest/catalog/ContactResource.php	(revision 6512)
+++ /sandbox/2.4.1-3/prototype/rest/catalog/ContactResource.php	(revision 6526)
@@ -30,5 +30,5 @@
 
 	try {
-	    //$this->secured();
+	    $this->secured();
 
             $contact = Controller::find( array( 'concept' => 'contact' ), false, array( 'filter' => array( 'AND', array('=', 'user',  Config::me("uidNumber") ), array('=', 'id', $id) )  ) );
Index: /sandbox/2.4.1-3/prototype/rest/catalog/GroupResource.php
===================================================================
--- /sandbox/2.4.1-3/prototype/rest/catalog/GroupResource.php	(revision 6512)
+++ /sandbox/2.4.1-3/prototype/rest/catalog/GroupResource.php	(revision 6526)
@@ -30,5 +30,5 @@
 
 	try {
-	    //$this->secured();
+	    $this->secured();
 
             $group = Controller::find( array( 'concept' => 'contactGroup' ), false, array( 'filter' => array( 'AND', array('=', 'user',  Config::me("uidNumber") ), array('=', 'id', $id) )  ) );
Index: /sandbox/2.4.1-3/prototype/rest/catalog/ContactsResource.php
===================================================================
--- /sandbox/2.4.1-3/prototype/rest/catalog/ContactsResource.php	(revision 6512)
+++ /sandbox/2.4.1-3/prototype/rest/catalog/ContactsResource.php	(revision 6526)
@@ -30,5 +30,5 @@
 
 	try {
-	    //$this->secured();
+	    $this->secured();
 
             $contacts = Controller::find( array( 'concept' => 'contact' ), false, array( 'filter' => array( '=', 'user',  Config::me("uidNumber") ) ) );
Index: /sandbox/2.4.1-3/prototype/rest/catalog/GroupsResource.php
===================================================================
--- /sandbox/2.4.1-3/prototype/rest/catalog/GroupsResource.php	(revision 6519)
+++ /sandbox/2.4.1-3/prototype/rest/catalog/GroupsResource.php	(revision 6526)
@@ -30,5 +30,5 @@
 	
 	try {
-	    //$this->secured();
+	    $this->secured();
 
         $groups = Controller::find( array( 'concept' => 'contactGroup' ), false, array( 'filter' => array('=', 'user',  Config::me("uidNumber") ), 'order' => array('name') ) );			
@@ -51,5 +51,5 @@
 		foreach($groups as $value){
 	
-				$i = new Item($request->resources, 'GroupsResource');
+				$i = new Item($request->resources, 'GroupsResource', $value['id']);
 				
 				$d = new Data();
Index: /sandbox/2.4.1-3/prototype/rest/user/UsersResource.php
===================================================================
--- /sandbox/2.4.1-3/prototype/rest/user/UsersResource.php	(revision 6512)
+++ /sandbox/2.4.1-3/prototype/rest/user/UsersResource.php	(revision 6526)
@@ -30,5 +30,5 @@
 
 	try {
-	    //$this->secured();
+	    $this->secured();
 
 	    //Executa uma consulta de usuários do LDAP a partir de um determinado atributo e valor
Index: /sandbox/2.4.1-3/prototype/rest/user/UserResource.php
===================================================================
--- /sandbox/2.4.1-3/prototype/rest/user/UserResource.php	(revision 6512)
+++ /sandbox/2.4.1-3/prototype/rest/user/UserResource.php	(revision 6526)
@@ -29,5 +29,5 @@
 	try {
 
-	    //$this->secured();
+	    $this->secured();
 
 	    $user = Controller::find(array('concept' => 'user','service'=>'OpenLDAP'), false, array('filter' => array('=', 'uid', $id )));
Index: /sandbox/2.4.1-3/prototype/request.php
===================================================================
--- /sandbox/2.4.1-3/prototype/request.php	(revision 6111)
+++ /sandbox/2.4.1-3/prototype/request.php	(revision 6526)
@@ -1,16 +1,16 @@
 <?php
 
-// $properties = $_GET['properties'];
-// $limit = $_GET['limit'];
-// $offset = $_GET['offset'];
-// $group = $_GET['group'];
-// $order = $_GET['join'];
-// $filter = $_GET['filter'];
-// $URI = $_GET['URI'];
+// $properties = $_REQUEST['properties'];
+// $limit = $_REQUEST['limit'];
+// $offset = $_REQUEST['offset'];
+// $group = $_REQUEST['group'];
+// $order = $_REQUEST['join'];
+// $filter = $_REQUEST['filter'];
+// $URI = $_REQUEST['URI'];
 
-$concept = isset( $_GET['concept'] ) ? $_GET['concept'] : false;
-$id = isset( $_GET['id'] ) ? $_GET['id'] : false;
-$filter = isset( $_GET['filter'] ) ? $_GET['filter'] : false;
-$criteria =  isset( $_GET['criteria'] ) ? $_GET['criteria'] : false;
+$concept = isset( $_REQUEST['concept'] ) ? $_REQUEST['concept'] : false;
+$id = isset( $_REQUEST['id'] ) ? $_REQUEST['id'] : false;
+$filter = isset( $_REQUEST['filter'] ) ? $_REQUEST['filter'] : false;
+$criteria =  isset( $_REQUEST['criteria'] ) ? $_REQUEST['criteria'] : false;
 
 $criteria = $filter ? $criteria ?
Index: /sandbox/2.4.1-3/expressoMail1_2/index.php
===================================================================
--- /sandbox/2.4.1-3/expressoMail1_2/index.php	(revision 6512)
+++ /sandbox/2.4.1-3/expressoMail1_2/index.php	(revision 6526)
@@ -39,6 +39,11 @@
 		<script src="../prototype/plugins/farbtastic/farbtastic.js" language="javascript"></script>
 		<script src="../prototype/api/datalayer.js" language="javascript"></script>					
+		<script src="../prototype/api/rest.js" language="javascript"></script>					
 		<script type="text/javascript" src="../prototype/plugins/scrollto/jquery.scrollTo.js"></script>
-		<script language="javascript">DataLayer.dispatchPath = "../prototype/";</script>					
+		<script language="javascript">
+			DataLayer.dispatchPath = "../prototype/";
+			REST.dispatchPath = "../prototype/";
+			REST.load("");
+		</script>					
 		<script src="../library/ckeditor/ckeditor.js" language="javascript" charset="utf-8"></script> 
 		<script src="../library/ckeditor/adapters/jquery.js" language="javascript"></script> 
@@ -73,5 +78,5 @@
 		<script type="text/javascript" src="../prototype/modules/calendar/js/calendar.date.js"></script>
 		<script type="text/javascript" src="../prototype/modules/calendar/js/calendar.codecs.js"></script>
-		
+
 
 		<script src="js/rich_text_editor.js" type="text/javascript"></script>
Index: /sandbox/2.4.1-3/expressoMail1_2/js/main.js
===================================================================
--- /sandbox/2.4.1-3/expressoMail1_2/js/main.js	(revision 6522)
+++ /sandbox/2.4.1-3/expressoMail1_2/js/main.js	(revision 6526)
@@ -35,5 +35,5 @@
 function updateDynamicContact(){
 	dynamicContacts = new Array();
-	var dynamicData = DataLayer.read("/dynamiccontacts").collection.itens;
+	var dynamicData = REST.get("/dynamiccontacts").collection.itens;
 	if(dynamicData){
 		$.each(dynamicData, function(index, value){
@@ -56,5 +56,5 @@
 function updateDynamicPersonalGroups(){
 	dynamicPersonalGroups = new Array();
-	var groupsData = DataLayer.read("/groups").collection.itens;
+	var groupsData = REST.get("/groups").collection.itens;
 	if(groupsData){
 		$.each(groupsData, function(index, value){
@@ -73,5 +73,5 @@
 function updateDynamicPersonalContacts(){
 	dynamicPersonalContacts = new Array();
-	var contactsData = DataLayer.read("/contacts").collection.itens;
+	var contactsData = REST.get("/contacts").collection.itens;
 	if(contactsData){
 		$.each(contactsData, function(index, value){
@@ -99,12 +99,13 @@
 
 	}*/
-	var load_dynamics = function(){
-		updateDynamicContact();
-		updateDynamicPersonalGroups();
-		updateDynamicPersonalContacts();
-		updateDynamicContactList();
-	};
-	load_dynamics();
-	
+	if(parseInt(preferences.use_dynamic_contacts)){
+		var load_dynamics = function(){
+			updateDynamicContact();
+			updateDynamicPersonalGroups();
+			updateDynamicPersonalContacts();
+			updateDynamicContactList();
+		};
+		load_dynamics();
+	}
 	var save_preferences = function(data){
 
@@ -2289,29 +2290,31 @@
 		var array = content.find(".to-tr").find(".box").clone();
 		delete_border(ID,'true'); 
-		$.each(array, function(i, value){
-			var stop = false;
-			$.each(dynamicPersonalContacts, function(x, valuex){
-				if(valuex.email == $(value).find("input").val().match(reComplexEmail)[1]){
-					stop = true;
-					return false;
-				}
-			});
-			if(!stop){
-				var exist = 0;
-				$.each(dynamicContacts, function(x, valuex){
+		if(parseInt(preferences.use_dynamic_contacts)){
+			$.each(array, function(i, value){
+				var stop = false;
+				$.each(dynamicPersonalContacts, function(x, valuex){
 					if(valuex.email == $(value).find("input").val().match(reComplexEmail)[1]){
-						exist = valuex.id;
+						stop = true;
 						return false;
 					}
 				});
-				if(exist){
-					DataLayer.update("/dynamiccontact/"+exist, {name: $(value).find("input").val().split('"')[1], mail:$(value).find("input").val().match(reComplexEmail)[1]});
-				}else{
-					DataLayer.create("/dynamiccontacts", {name: $(value).find("input").val().split('"')[1], mail:$(value).find("input").val().match(reComplexEmail)[1]});
+				if(!stop){
+					var exist = 0;
+					$.each(dynamicContacts, function(x, valuex){
+						if(valuex.email == $(value).find("input").val().match(reComplexEmail)[1]){
+							exist = valuex.id;
+							return false;
+						}
+					});
+					if(exist){
+						REST.put("/dynamiccontact/"+exist, {name: $(value).find("input").val().split('"')[1], mail:$(value).find("input").val().match(reComplexEmail)[1]});
+					}else{
+						REST.post("/dynamiccontacts", {name: $(value).find("input").val().split('"')[1], mail:$(value).find("input").val().match(reComplexEmail)[1]});
+					}
 				}
-			}
-		});
-		updateDynamicContact();
-		updateDynamicContactList();
+			});
+			updateDynamicContact();
+			updateDynamicContactList();
+		}
  	}
 	else{
