Index: /trunk/prototype/me.php
===================================================================
--- /trunk/prototype/me.php	(revision 6528)
+++ /trunk/prototype/me.php	(revision 6572)
@@ -5,44 +5,46 @@
 $me = Controller::read(array('concept' => 'user', 'service' => 'OpenLDAP'  , 'id' => Config::me('uidNumber')));
 
-if(isset($_POST['refreshToken'])){
-    
-    $ch = curl_init();
+//
+//if(isset($_POST['refreshToken'])){
+//    
+//    $ch = curl_init();
+//
+//    $restConf = parse_ini_file( __DIR__ . '/config/REST.ini', true );
+//
+//    $param  = 'grant_type=refresh_token';
+//    $param .= '&client_id=' . $restConf['oauth']['client_id'];
+//    $param .= '&client_secret=' . $restConf['oauth']['client_secret'];
+//    $param .= '&refresh_token=' . $_SESSION['oauth']['refresh_token'];
+//
+//    // set URL and other appropriate options
+//    curl_setopt($ch, CURLOPT_URL, $restConf['oauth']['url_token']);
+//    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: */*'));
+//    curl_setopt($ch, CURLOPT_POST, TRUE);
+//    curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
+//    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);  //configura para nao imprimir a saida na tela
+//    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);//Passe um número long como parâmetro que contêm o limite de tempo, em segundos, que você permite as funções CURL levar. 
+//
+//    // grab URL and pass it to the browser
+//    $res = curl_exec($ch);
+//
+//    // close cURL resource, and free up system resources
+//    curl_close($ch);
+//    $a = json_decode($res);
+//
+//    if ( isset($a->access_token) ) {
+//	$_SESSION['oauth']['access_token'] = $a->access_token;
+//	$_SESSION['oauth']['expires_in'] = $a->expires_in;
+//	$_SESSION['oauth']['token_type'] = $a->token_type;
+//	$_SESSION['oauth']['scope'] = $a->scope;
+//	$_SESSION['oauth']['refresh_token'] = $a->refresh_token;
+//	$_SESSION['oauth']['client_secret'] = $restConf['oauth']['client_secret'];
+//    }  else {
+//	echo json_encode(null);
+//	return;
+//    }
+//}
 
-    $restConf = parse_ini_file( __DIR__ . '/config/REST.ini', true );
 
-    $param  = 'grant_type=refresh_token';
-    $param .= '&client_id=' . $restConf['oauth']['client_id'];
-    $param .= '&client_secret=' . $restConf['oauth']['client_secret'];
-    $param .= '&refresh_token=' . $_SESSION['oauth']['refresh_token'];
-
-    // set URL and other appropriate options
-    curl_setopt($ch, CURLOPT_URL, $restConf['oauth']['url_token']);
-    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: */*'));
-    curl_setopt($ch, CURLOPT_POST, TRUE);
-    curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
-    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);  //configura para nao imprimir a saida na tela
-    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);//Passe um número long como parâmetro que contêm o limite de tempo, em segundos, que você permite as funções CURL levar. 
-
-    // grab URL and pass it to the browser
-    $res = curl_exec($ch);
-
-    // close cURL resource, and free up system resources
-    curl_close($ch);
-    $a = json_decode($res);
-
-    if ( isset($a->access_token) ) {
-	$_SESSION['oauth']['access_token'] = $a->access_token;
-	$_SESSION['oauth']['expires_in'] = $a->expires_in;
-	$_SESSION['oauth']['token_type'] = $a->token_type;
-	$_SESSION['oauth']['scope'] = $a->scope;
-	$_SESSION['oauth']['refresh_token'] = $a->refresh_token;
-	$_SESSION['oauth']['client_secret'] = $restConf['oauth']['client_secret'];
-    }  else {
-	echo json_encode(null);
-	return;
-    }
-}
-
-$me['token'] = $_SESSION['oauth']['access_token'];
+$me['token'] = 'asdf1as5d1f56a1sdf1qw5e1q2we5qfq8ew';//$_SESSION['oauth']['access_token'];
 echo json_encode( $me );
 
Index: /trunk/prototype/library/tonic/lib/tonic.php
===================================================================
--- /trunk/prototype/library/tonic/lib/tonic.php	(revision 6528)
+++ /trunk/prototype/library/tonic/lib/tonic.php	(revision 6572)
@@ -655,8 +655,9 @@
 	try 
 	{
-	    $oauth = new OAuth2(new OAuth2StorageUserCredential());
-	    $token = $oauth->getBearerToken();
-	    $oauth->verifyAccessToken($token);
-
+	    /* 
+		$oauth = new OAuth2(new OAuth2StorageUserCredential());
+		$token = $oauth->getBearerToken();
+		$oauth->verifyAccessToken($token);
+	    */
 	    if(!Config::me('uidNumber'))
 		throw new ResponseException('Session experired.', Response::UNAUTHORIZED);
Index: /trunk/prototype/rest/catalog/UserContactsResource.php
===================================================================
--- /trunk/prototype/rest/catalog/UserContactsResource.php	(revision 6559)
+++ /trunk/prototype/rest/catalog/UserContactsResource.php	(revision 6572)
@@ -45,5 +45,5 @@
 	    $c->addData($d);
 
-	    //Recupera os contatos dinâmicos do usuario
+//Recupera os contatos dinâmicos do usuario
 	    $dynamicContacts = Controller::find(
 			    array('concept' => 'dynamicContact'), false, array('filter' => array('=', 'owner', Config::me("uidNumber")),
@@ -80,5 +80,5 @@
 		    $d = new Data();
 		    $d->setName('number_of_messages');
-		    $d->setValue($value['number_of_messages']);
+		    $d->setValue((int)$value['number_of_messages']);
 		    $d->setPrompt('Quantidade de mensagens enviadas');
 		    $d->setDataType('integer');
@@ -134,5 +134,5 @@
 	    $acl = array();
 
-	    //Recupera o uidNumber de todos os usuários que compartilham suas agendas com o usuário logado
+//Recupera o uidNumber de todos os usuários que compartilham suas agendas com o usuário logado
 	    $shareds = Controller::service('PostgreSQL')->execResultSql('select acl_account as "uidNumber", acl_rights as "acl" from phpgw_acl where (acl_location =   \'' . Config::me("uidNumber") . '\' AND acl_appname =  \'contactcenter\' )');
 
@@ -148,122 +148,122 @@
 	    if ($groups) {
 		foreach ($groups as $value) {
-
-		    $i = new Item($request->resources, ($value['user'] == Config::me("uidNumber") ? 'GroupsResource' : 'SharedGroupsResource'), $value['id']);
-
-		    $d = new Data();
-		    $d->setName('id');
-		    $d->setValue($value['id']);
-		    $d->setPrompt('Id do Grupo');
-		    $d->setDataType('string');
-		    $d->setMaxLength('100');
-		    $d->setMinLength(null);
-		    $d->setRequired(true);
-		    $i->addData($d);
-
-		    $d = new Data();
-		    $d->setName('owner');
-		    $d->setValue($value['user']);
-		    $d->setPrompt('Id Dono do Grupo');
-		    $d->setDataType('string');
-		    $d->setMaxLength('100');
-		    $d->setMinLength(null);
-		    $d->setRequired(true);
-		    $i->addData($d);
-
-		    $d = new Data();
-		    $d->setName('name');
-		    $d->setValue($value['name']);
-		    $d->setPrompt('Nome do Grupo');
-		    $d->setDataType('string');
-		    $d->setMaxLength('100');
-		    $d->setMinLength(null);
-		    $d->setRequired(true);
-		    $i->addData($d);
-
-		    $d = new Data();
-		    $d->setName('email');
-		    $d->setValue($value['email']);
-		    $d->setPrompt('Email do Grupo');
-		    $d->setDataType('string');
-		    $d->setMaxLength('100');
-		    $d->setMinLength(null);
-		    $d->setRequired(true);
-		    $i->addData($d);
-
-		    if (Config::me("uidNumber") != $value['user']) {
-			/* Descomentar ao implementar os métodos
-			  if ($acl[$value['user']]['delete']) {
-			  $l = new Link();
-			  $l->setHref('');
-			  $l->setRel('delete');
-			  $l->setAlt('Remover');
-			  $l->setPrompt('Remover');
-			  $l->setRender('link');
-			  $i->addLink($l);
-			  }
-
-			  if ($acl[$value['user']]['update']) {
-			  $l = new Link();
-			  $l->setHref('');
-			  $l->setRel('put');
-			  $l->setAlt('Atualizar');
-			  $l->setPrompt('Atualizar');
-			  $l->setRender('link');
-			  $i->addLink($l);
-			  }
-
-			  if ($acl[$value['user']]['write']) {
-			  $l = new Link();
-			  $l->setHref('');
-			  $l->setRel('post');
-			  $l->setAlt('Criar');
-			  $l->setPrompt('Criar novo');
-			  $l->setRender('link');
-			  $i->addLink($l);
-			  }
-
-			  if ($acl[$value['user']]['read']) {
-			  $l = new Link();
-			  $l->setHref('/sharedgroup/' . $value['user'] . '/' . $value['id']);
-			  $l->setRel('get');
-			  $l->setAlt('Buscar');
-			  $l->setPrompt('Buscar');
-			  $l->setRender('link');
-			  $i->addLink($l);
-			  }
-			 */
-		    } else {
-			/* Descomentar ao implementar métodos no recurso
-			  $l = new Link();
-			  $l->setHref('');
-			  $l->setRel('delete');
-			  $l->setAlt('Remover');
-			  $l->setPrompt('Remover');
-			  $l->setRender('link');
-			  $i->addLink($l);
-
-			  $l = new Link();
-			  $l->setHref('');
-			  $l->setRel('put');
-			  $l->setAlt('Atualizar');
-			  $l->setPrompt('Atualizar');
-			  $l->setRender('link');
-			  $i->addLink($l);
-			 */
-
-			$l = new Link();
-			$l->setHref('/group/' . $value['id']);
-			$l->setRel('get');
-			$l->setAlt('Buscar');
-			$l->setPrompt('Buscar');
-			$l->setRender('link');
-
-			$i->addLink($l);
+		    if (($value['user'] == Config::me("uidNumber")) || ($acl[$value['user']]['read'])) {
+
+			$i = new Item($request->resources, ($value['user'] == Config::me("uidNumber") ? 'GroupsResource' : 'SharedGroupsResource'), $value['id']);
+
+			$d = new Data();
+			$d->setName('id');
+			$d->setValue($value['id']);
+			$d->setPrompt('Id do Grupo');
+			$d->setDataType('string');
+			$d->setMaxLength('100');
+			$d->setMinLength(null);
+			$d->setRequired(true);
+			$i->addData($d);
+
+			$d = new Data();
+			$d->setName('owner');
+			$d->setValue($value['user']);
+			$d->setPrompt('Id Dono do Grupo');
+			$d->setDataType('string');
+			$d->setMaxLength('100');
+			$d->setMinLength(null);
+			$d->setRequired(true);
+			$i->addData($d);
+
+			$d = new Data();
+			$d->setName('name');
+			$d->setValue($value['name']);
+			$d->setPrompt('Nome do Grupo');
+			$d->setDataType('string');
+			$d->setMaxLength('100');
+			$d->setMinLength(null);
+			$d->setRequired(true);
+			$i->addData($d);
+
+			$d = new Data();
+			$d->setName('email');
+			$d->setValue($value['email']);
+			$d->setPrompt('Email do Grupo');
+			$d->setDataType('string');
+			$d->setMaxLength('100');
+			$d->setMinLength(null);
+			$d->setRequired(true);
+			$i->addData($d);
+
+			if (Config::me("uidNumber") != $value['user']) {
+			    /* Descomentar ao implementar os métodos
+			      if ($acl[$value['user']]['delete']) {
+			      $l = new Link();
+			      $l->setHref('');
+			      $l->setRel('delete');
+			      $l->setAlt('Remover');
+			      $l->setPrompt('Remover');
+			      $l->setRender('link');
+			      $i->addLink($l);
+			      }
+
+			      if ($acl[$value['user']]['update']) {
+			      $l = new Link();
+			      $l->setHref('');
+			      $l->setRel('put');
+			      $l->setAlt('Atualizar');
+			      $l->setPrompt('Atualizar');
+			      $l->setRender('link');
+			      $i->addLink($l);
+			      }
+
+			      if ($acl[$value['user']]['write']) {
+			      $l = new Link();
+			      $l->setHref('');
+			      $l->setRel('post');
+			      $l->setAlt('Criar');
+			      $l->setPrompt('Criar novo');
+			      $l->setRender('link');
+			      $i->addLink($l);
+			      }
+			     */
+
+			    $l = new Link();
+			    $l->setHref('/sharedgroup/' . $value['id']);
+			    $l->setRel('get');
+			    $l->setAlt('Buscar');
+			    $l->setPrompt('Buscar');
+			    $l->setRender('link');
+			    $i->addLink($l);
+			} else {
+			    /* Descomentar ao implementar métodos no recurso
+			      $l = new Link();
+			      $l->setHref('');
+			      $l->setRel('delete');
+			      $l->setAlt('Remover');
+			      $l->setPrompt('Remover');
+			      $l->setRender('link');
+			      $i->addLink($l);
+
+			      $l = new Link();
+			      $l->setHref('');
+			      $l->setRel('put');
+			      $l->setAlt('Atualizar');
+			      $l->setPrompt('Atualizar');
+			      $l->setRender('link');
+			      $i->addLink($l);
+			     */
+
+			    $l = new Link();
+			    $l->setHref('/group/' . $value['id']);
+			    $l->setRel('get');
+			    $l->setAlt('Buscar');
+			    $l->setPrompt('Buscar');
+			    $l->setRender('link');
+
+			    $i->addLink($l);
+			}
+			$c->addItem($i);
 		    }
-		    $c->addItem($i);
 		}
 	    }
 
-	    //Recupera os contatos pessoais do usuario
+//Recupera os contatos pessoais do usuario
 	    $contacts = Controller::find(array('concept' => 'contact'), false, array('filter' => array('IN', 'user', $idS)));
 
@@ -271,123 +271,126 @@
 
 		foreach ($contacts as $value) {
-		    $d = new Data();
-		    $i = new Item($request->resources, (($value['user'] == Config::me("uidNumber")) ? 'ContactsResource' : 'SharedContactsResource'), $value['id']);
-		    $d->setName('id');
-		    $d->setValue($value['id']);
-		    $d->setPrompt('Id do Contato');
-		    $d->setDataType('string');
-		    $d->setMaxLength('100');
-		    $d->setMinLength(null);
-		    $d->setRequired(true);
-
-		    $i->addData($d);
-
-		    $d = new Data();
-		    $d->setName('owner');
-		    $d->setValue($value['user']);
-		    $d->setPrompt('Id Dono do Contato');
-		    $d->setDataType('string');
-		    $d->setMaxLength('100');
-		    $d->setMinLength(null);
-		    $d->setRequired(true);
-
-		    $i->addData($d);
-
-		    $d = new Data();
-		    $d->setName('name');
-		    $d->setValue($value['name']);
-		    $d->setPrompt('Nome do Contato');
-		    $d->setDataType('string');
-		    $d->setMaxLength('100');
-		    $d->setMinLength(null);
-		    $d->setRequired(true);
-
-		    $i->addData($d);
-
-		    $d = new Data();
-		    $d->setName('email');
-		    $d->setValue(isset($value['email']) ? $value['email'] : null);
-		    $d->setPrompt('Email do Contato');
-		    $d->setDataType('string');
-		    $d->setMaxLength('100');
-		    $d->setMinLength(null);
-		    $d->setRequired(true);
-
-		    $i->addData($d);
-
-		    $d = new Data();
-		    $d->setName('telephone');
-		    $d->setValue(isset($value['telephone']) ? $value['telephone'] : null);
-		    $d->setPrompt('Telefone do Contato');
-		    $d->setDataType('string');
-		    $d->setMaxLength('100');
-		    $d->setMinLength(null);
-		    $d->setRequired(true);
-
-		    $i->addData($d);
-
-		    if (Config::me("uidNumber") != $value['user']) {
-			/* Descomentar ao criar recursos
-			  if ($acl[$value['user']]['read']) {
-			  $l = new Link();
-			  $l->setHref('/sharedcontact/' . $value['id']);
-			  $l->setRel('get');
-			  $l->setAlt('Buscar');
-			  $l->setPrompt('Buscar');
-			  $l->setRender('link');
-			  $i->addLink($l);
-			  }
-
-			  if ($acl[$value['user']]['delete']) {
-			  $l = new Link();
-			  $l->setHref('');
-			  $l->setRel('delete');
-			  $l->setAlt('Remover');
-			  $l->setPrompt('Remover');
-			  $l->setRender('link');
-			  $i->addLink($l);
-			  }
-
-			  if ($acl[$value['user']]['put']) {
-			  $l = new Link();
-			  $l->setHref('');
-			  $l->setRel('put');
-			  $l->setAlt('Atualizar');
-			  $l->setPrompt('Atualizar');
-			  $l->setRender('link');
-			  $i->addLink($l);
-			  }
-			 */
-		    } else {
-			/* Descomentar ao criar recursos
-			  $l = new Link();
-
-			  $l->setHref('');
-			  $l->setRel('delete');
-			  $l->setAlt('Remover');
-			  $l->setPrompt('Remover');
-			  $l->setRender('link');
-
-			  $i->addLink($l);
-
-			  $l = new Link();
-			  $l->setHref('');
-			  $l->setRel('put');
-			  $l->setAlt('Atualizar');
-			  $l->setPrompt('Atualizar');
-			  $l->setRender('link');
-
-			  $i->addLink($l);
-			 */
-			$l = new Link();
-			$l->setHref('/contact/' . $value['id']);
-			$l->setRel('get');
-			$l->setAlt('Buscar');
-			$l->setPrompt('Buscar');
-			$l->setRender('link');
-
-			$i->addLink($l);
+
+		    if (($value['user'] == Config::me("uidNumber")) || ($acl[$value['user']]['read'])) {
+
+			$d = new Data();
+			$i = new Item($request->resources, (($value['user'] == Config::me("uidNumber")) ? 'ContactsResource' : 'SharedContactsResource'), $value['id']);
+			$d->setName('id');
+			$d->setValue($value['id']);
+			$d->setPrompt('Id do Contato');
+			$d->setDataType('string');
+			$d->setMaxLength('100');
+			$d->setMinLength(null);
+			$d->setRequired(true);
+
+			$i->addData($d);
+
+			$d = new Data();
+			$d->setName('owner');
+			$d->setValue($value['user']);
+			$d->setPrompt('Id Dono do Contato');
+			$d->setDataType('string');
+			$d->setMaxLength('100');
+			$d->setMinLength(null);
+			$d->setRequired(true);
+
+			$i->addData($d);
+
+			$d = new Data();
+			$d->setName('name');
+			$d->setValue($value['name']);
+			$d->setPrompt('Nome do Contato');
+			$d->setDataType('string');
+			$d->setMaxLength('100');
+			$d->setMinLength(null);
+			$d->setRequired(true);
+
+			$i->addData($d);
+
+			$d = new Data();
+			$d->setName('email');
+			$d->setValue(isset($value['email']) ? $value['email'] : null);
+			$d->setPrompt('Email do Contato');
+			$d->setDataType('string');
+			$d->setMaxLength('100');
+			$d->setMinLength(null);
+			$d->setRequired(true);
+
+			$i->addData($d);
+
+			$d = new Data();
+			$d->setName('telephone');
+			$d->setValue(isset($value['telephone']) ? $value['telephone'] : null);
+			$d->setPrompt('Telefone do Contato');
+			$d->setDataType('string');
+			$d->setMaxLength('100');
+			$d->setMinLength(null);
+			$d->setRequired(true);
+
+			$i->addData($d);
+
+			if (Config::me("uidNumber") != $value['user']) {
+
+			    $l = new Link();
+			    $l->setHref('/sharedcontact/' . $value['id']);
+			    $l->setRel('get');
+			    $l->setAlt('Buscar');
+			    $l->setPrompt('Buscar');
+			    $l->setRender('link');
+			    $i->addLink($l);
+
+			    /* Descomentar ao criar recursos
+			      if ($acl[$value['user']]['delete']) {
+			      $l = new Link();
+			      $l->setHref('');
+			      $l->setRel('delete');
+			      $l->setAlt('Remover');
+			      $l->setPrompt('Remover');
+			      $l->setRender('link');
+			      $i->addLink($l);
+			      }
+
+			      if ($acl[$value['user']]['put']) {
+			      $l = new Link();
+			      $l->setHref('');
+			      $l->setRel('put');
+			      $l->setAlt('Atualizar');
+			      $l->setPrompt('Atualizar');
+			      $l->setRender('link');
+			      $i->addLink($l);
+			      }
+			     */
+			} else {
+			    /* Descomentar ao criar recursos
+			      $l = new Link();
+
+			      $l->setHref('');
+			      $l->setRel('delete');
+			      $l->setAlt('Remover');
+			      $l->setPrompt('Remover');
+			      $l->setRender('link');
+
+			      $i->addLink($l);
+
+			      $l = new Link();
+			      $l->setHref('');
+			      $l->setRel('put');
+			      $l->setAlt('Atualizar');
+			      $l->setPrompt('Atualizar');
+			      $l->setRender('link');
+
+			      $i->addLink($l);
+			     */
+			    $l = new Link();
+			    $l->setHref('/contact/' . $value['id']);
+			    $l->setRel('get');
+			    $l->setAlt('Buscar');
+			    $l->setPrompt('Buscar');
+			    $l->setRender('link');
+
+			    $i->addLink($l);
+			}
+			$c->addItem($i);
 		    }
-		    $c->addItem($i);
 		}
 	    }
