Index: /sandbox/webservice/rest/setup/default_records.inc.php
===================================================================
--- /sandbox/webservice/rest/setup/default_records.inc.php	(revision 7466)
+++ /sandbox/webservice/rest/setup/default_records.inc.php	(revision 7466)
@@ -0,0 +1,48 @@
+<?php
+
+	/*
+	Cria e configura o arquivo REST.ini 
+	*/
+
+	$webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url'];
+	$webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/';
+	
+	if(strrpos($webserver_url,'/') === false || strrpos($webserver_url,'/') != (strlen($webserver_url)-1))
+	{
+		$webserver_url .= '/';
+	}
+	
+	$config = array();
+	$config['baseUri'] = 'http://'.$_SERVER['HTTP_HOST'].$webserver_url."rest/";
+	
+	/* Conf REST */
+	$serverID = "001";
+	$config['ServersRest-'.$serverID]['serverID'] = $serverID;
+	$config['ServersRest-'.$serverID]['serverName'] = $_SERVER['HTTP_HOST'];
+	$config['ServersRest-'.$serverID]['serverDescription'] = 'Expresso - ' . $_SERVER['HTTP_HOST'];
+	$config['ServersRest-'.$serverID]['serverUrl'] = 'http://' . $_SERVER['HTTP_HOST'];
+	$config['ServersRest-'.$serverID]['serverContext'] = $webserver_url .'rest/';
+	$config['ServersRest-'.$serverID]['serverStatus'] = 'true';
+	
+	$path = __DIR__ . '/../../prototype/config/REST.ini';
+
+	$content = "";
+
+	foreach( $config as $key => $value )
+	{
+		if(is_array($value))
+		{
+			$content .= "[".$key."]\n";
+			
+			foreach( $value as $ikey => $ivalue )
+				$content .= $ikey ."=". $ivalue . "\n";
+		}
+		else
+		{
+			$content .= $key . "=" . $value . "\n";				
+		}
+	}
+
+	file_put_contents($path, $content);
+
+?>
Index: /sandbox/webservice/rest/setup/phpgw_pt-br.lang
===================================================================
--- /sandbox/webservice/rest/setup/phpgw_pt-br.lang	(revision 7466)
+++ /sandbox/webservice/rest/setup/phpgw_pt-br.lang	(revision 7466)
@@ -0,0 +1,13 @@
+API Rest	rest	pt-br	API Rest
+Back	rest	pt-br	Voltar
+Configuring the REST API	rest	pt-br	Configuração da API Rest
+Description	rest	pt-br	Descrição
+Delete	rest	pt-br	Excluir
+Disabled	rest	pt-br	Desabilitado
+Edit	rest	pt-br	Editar
+Enabled	rest	pt-br	Habilitado
+rest	common	pt-br	Expresso REST
+Save	rest	pt-br	Salvar
+Server Name	rest	pt-br	Nome do Servidor
+Server Status	rest	pt-br	Status do Servidor
+URL	rest	pt-br	URL
Index: /sandbox/webservice/rest/setup/setup.inc.php
===================================================================
--- /sandbox/webservice/rest/setup/setup.inc.php	(revision 7466)
+++ /sandbox/webservice/rest/setup/setup.inc.php	(revision 7466)
@@ -0,0 +1,33 @@
+<?php
+
+	/**************************************************************************\
+	* Expresso - Seu Novo Modulo                                               *
+	* http://www.expressolivre.org                                             *
+	* --------------------------------------------                             *
+	*  This program is free software; you can redistribute it and/or modify it *
+	*  under the terms of the GNU General Public License as published by the   *
+	*  Free Software Foundation; either version 2 of the License, or (at your  *
+	*  option) any later version.                                              *
+	\**************************************************************************/
+
+	$setup_info['rest']['name']    		= 'rest';
+	$setup_info['rest']['version']		= '1.000';
+	$setup_info['rest']['app_order']	= 3;
+	$setup_info['rest']['enable']		= 1;
+	$setup_info['rest']['author'] 		= 'Expresso Livre';
+
+	/* The hooks this app includes, needed for hooks registration */
+	$setup_info['rest']['hooks'][] = 'admin';
+	
+	/* Dependencies for this app to work */
+	$setup_info['rest']['depends']['appname'] = array(
+		 'appname' => 'phpgwapi',
+		 'versions' => Array('2.2')
+	);
+	
+	if( !file_exists( '../../prototype/config/REST.ini') )
+	{
+		require_once "default_records.inc.php";
+	}
+
+?>
Index: /sandbox/webservice/rest/inc/class.uiconfig.inc.php
===================================================================
--- /sandbox/webservice/rest/inc/class.uiconfig.inc.php	(revision 7466)
+++ /sandbox/webservice/rest/inc/class.uiconfig.inc.php	(revision 7466)
@@ -0,0 +1,218 @@
+<?php
+
+class uiconfig
+{
+	public $public_functions = array(
+		'config' 		=> true,
+		'deleteServer'	=> true,
+		'editServer'	=> true
+	);
+
+	public function config( $params = false )
+	{
+		$GLOBALS['phpgw']->common->phpgw_header();
+
+		echo parse_navbar();
+
+		if( !$GLOBALS['phpgw']->acl->check('run',1,'admin') )
+		{
+			$GLOBALS['phpgw']->redirect_link('/admin/index.php');
+		}
+
+		$table_servers = "";
+		
+		if( $_POST['back'] )
+		{
+			$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/admin/index.php'));
+		}
+		else
+		{
+			if( $_POST && $params == false )
+			{
+				$this->save($_POST);
+			}
+			
+			$servers = $this->readFile();
+			
+			if( count($servers) > 0 )
+			{
+				$serversTable = "";
+				
+				foreach( $servers as $key => $value )
+				{
+					if( substr($key, 0, 11) == "ServersRest")
+					{
+						$table_servers .= "<tr>";
+						$table_servers .= "	<td>".$value['serverName']."</td>";
+						$table_servers .= "	<td>".$value['serverDescription']."</td>";
+						$table_servers .= "	<td>".$value['serverUrl']."</td>";
+						$table_servers .= "	<td>".$value['serverContext']."</td>";
+						$table_servers .= "	<td>".( ($value['serverStatus'] == 1 ) ? "Habilitado" : "Desabilitado" )."</td>";
+						$table_servers .= " <td><a href='".$GLOBALS['phpgw']->link('/index.php','menuaction=rest.uiconfig.editServer&serverID='.$value['serverID'].'')."'>Editar</a></td>";
+						$table_servers .= " <td><a href='".$GLOBALS['phpgw']->link('/index.php','menuaction=rest.uiconfig.deleteServer&serverID='.$value['serverID'].'')."'>Excluir</a></td>";
+						$table_servers .= "</tr>";
+					}
+				}	
+			}
+	
+			$GLOBALS['phpgw']->template->set_file(array('rest'=>'config.tpl'));
+			$GLOBALS['phpgw']->template->set_block('rest','pagina');	
+			$GLOBALS['phpgw']->template->set_var( array(
+															'lang_Server_Name' => lang('Server Name'),
+															'lang_Description' => lang('Description'),
+															'lang_URL' => lang('URL'),
+															'lang_API_Rest' => lang('API REST'),
+															'lang_Server_Status' => lang('Server Status'),
+															'lang_Enabled' => lang('Enabled'),
+															'lang_Disabled' => lang('Disabled'),
+															'lang_Save'	=> lang('Save'),
+															'lang_Back' => lang('Back'),
+															'lang_Configuring_the_REST_API' => lang('Configuring the REST API'),
+															'lang_Edit' => lang('Edit'),
+															'lang_Delete'	=> lang('Delete'),
+															'table_servers'	=> $table_servers,
+															'server_id'		=> (($params && is_array($params) ) ? $params['serverID'] : ""),
+															'server_name'	=> (($params && is_array($params) ) ? $params['serverName'] : ""),
+															'server_description'	=> (($params && is_array($params) ) ? $params['serverDescription'] : ""),
+															'server_url'	=> (($params && is_array($params) ) ? $params['serverUrl'] : ""),
+															'server_rest'	=> (($params && is_array($params) ) ? $params['serverContext'] : ""),
+															'selected_statusServer_true' => (($params && is_array($params) ) ? (($params['serverStatus'] == "0" ) ? "selected=true" : "") : ""),
+															'selected_statusServer_false' => (($params && is_array($params) ) ? (($params['serverStatus'] == "0" ) ? "selected=true" : "") : "")
+														));
+		
+			$GLOBALS['phpgw']->template->pparse('out','pagina');
+		}
+	}
+
+	public function deleteServer()
+	{
+		if( $_GET['serverID'] )
+		{
+			$serverID = $_GET['serverID'];
+			
+			$servers = $this->readFile();
+			
+			foreach( $servers as $key => $value )
+			{
+				if( substr($key, 0, 11) == "ServersRest")
+				{
+					if( $value['serverID'] == $serverID )
+					{
+						unset( $servers[$key] );
+					}
+				}
+			}
+			
+			if( !$this->writeFile($servers) )
+				echo "Error : Permission failure when trying to write in the file ";
+			else
+				$this->config();
+		}
+	}
+	
+	public function editServer()
+	{
+		if($_GET['serverID'] )
+		{
+			$serverID = $_GET['serverID'];
+			
+			$servers = $this->readFile();
+			
+			foreach( $servers as $key => $value )
+			{
+				if( substr($key, 0, 11) == "ServersRest")
+				{
+					if( $value['serverID'] == $serverID )
+					{
+						$server = $servers[$key];
+					}
+				}
+			}
+			
+		}
+		
+		$this->config($server);
+	}
+
+	private function save($params)
+	{
+		$fileConfig = parse_ini_file( __DIR__ . '/../../api/config/REST.ini', true );
+
+		if( $params['server_id'] )
+		{
+			$serverID = $params['server_id'];
+			
+			$fileConfig['ServersRest-'.$serverID]['serverID'] = $serverID;
+			$fileConfig['ServersRest-'.$serverID]['serverName'] = $params['server_name'];
+			$fileConfig['ServersRest-'.$serverID]['serverDescription'] = $params['server_description'];
+			$fileConfig['ServersRest-'.$serverID]['serverUrl'] = $params['server_url'];
+			$fileConfig['ServersRest-'.$serverID]['serverContext'] = $params['server_rest'];
+			$fileConfig['ServersRest-'.$serverID]['serverStatus'] = ( $params['server_status'] == 'true' ) ? "1" : "0";
+		}
+		else
+		{
+			$keys = array_keys($fileConfig);
+			
+			foreach($keys as $k => $v)
+			{
+				if( substr($v, 0, 11) == "ServersRest")
+					$ID = $fileConfig[$v]['serverID'];
+			}				
+			
+			$serverID = ((int)$ID + 1);
+			if( strlen($serverID) <= 2 )
+				$serverID = ( strlen($serverID) > 1 ) ? "0".$serverID : "00".$serverID;
+			$fileConfig['ServersRest-'.$serverID]['serverID'] = $serverID;
+			$fileConfig['ServersRest-'.$serverID]['serverName'] = $params['server_name'];
+			$fileConfig['ServersRest-'.$serverID]['serverDescription'] = $params['server_description'];
+			$fileConfig['ServersRest-'.$serverID]['serverUrl'] = $params['server_url'];
+			$fileConfig['ServersRest-'.$serverID]['serverContext'] = $params['server_rest'];
+			$fileConfig['ServersRest-'.$serverID]['serverStatus'] = ( $params['server_status'] == 'true' ) ? "1" : "0";
+		}
+		
+		$this->writeFile($fileConfig);
+	}
+
+	private function readFile()
+	{
+		$fileConfig = array();
+		
+		if( file_exists(__DIR__ . '/../../api/config/REST.ini') )
+		{
+			$fileConfig = parse_ini_file( __DIR__ . '/../../api/config/REST.ini', true );
+		}
+
+		return $fileConfig;
+	}
+	
+	private function writeFile($config)
+	{
+		$path = __DIR__ . '/../../api/config/REST.ini';
+
+		$content = "";
+
+		foreach( $config as $key => $value )
+		{
+			if(is_array($value))
+			{
+				$content .= "[".$key."]\n";
+				
+				foreach( $value as $ikey => $ivalue )
+					$content .= $ikey ."=". $ivalue . "\n";
+			}
+			else
+			{
+				$content .= $key . "=" . $value . "\n";				
+			}
+		}
+
+		if( file_put_contents($path, $content) === false)
+		{
+			return false;
+		}
+		
+		return true;
+	}
+}
+
+?>
Index: /sandbox/webservice/rest/inc/hook_admin.inc.php
===================================================================
--- /sandbox/webservice/rest/inc/hook_admin.inc.php	(revision 7466)
+++ /sandbox/webservice/rest/inc/hook_admin.inc.php	(revision 7466)
@@ -0,0 +1,22 @@
+<?php
+
+if( !isset($GLOBALS['phpgw_info']) )
+{
+	$GLOBALS['phpgw_info']['flags'] = array(
+		'currentapp' => "rest",
+		'nonavbar'   => true,
+		'noheader'   => true
+	);
+}
+
+// Only Modify the $file and $title variables.....
+	$title = $GLOBALS['phpgw_info']['flags']['currentapp'];
+	
+	$file = array(
+		'Site Configuration' 	=> $GLOBALS['phpgw']->link('/index.php','menuaction=rest.uiconfig.config')
+	);
+
+//Do not modify below this line
+	display_section($appname,$title,$file);
+
+?>
Index: /sandbox/webservice/rest/index.php
===================================================================
--- /sandbox/webservice/rest/index.php	(revision 7466)
+++ /sandbox/webservice/rest/index.php	(revision 7466)
@@ -0,0 +1,7 @@
+<?php
+	
+	$phpgw_flags['currentapp'] = 'rest';
+	$GLOBALS['phpgw_info']['flags'] = $phpgw_flags;
+	
+	include('../header.inc.php');
+?>
Index: /sandbox/webservice/rest/templates/default/config.tpl
===================================================================
--- /sandbox/webservice/rest/templates/default/config.tpl	(revision 7466)
+++ /sandbox/webservice/rest/templates/default/config.tpl	(revision 7466)
@@ -0,0 +1,75 @@
+<!-- BEGIN pagina -->
+<link rel='stylesheet' type='text/css' href='/rest/templates/css/style.css'>
+
+<div id="globalDiv">
+	<div id="contentDiv">
+		
+		<div>
+			<p>
+				<img src="/rest/templates/default/images/navbar.png">
+				<span style="font-size:9pt; font-weight:bold;margin-left:10px;">{lang_Configuring_the_REST_API}</span>
+			</p>
+		</div>
+		
+		<fieldset>
+			<form method="POST" action="index.php?menuaction=rest.uiconfig.config">
+				<!-- Server Name -->
+				<label for="server_name">{lang_Server_Name} .:</label>
+				<input type="hidden" name="server_id" value="{server_id}">
+				<input type="text" name="server_name" value="{server_name}" size="50" maxlength="50">
+				<br>
+				
+				<!-- Server Description -->
+				<label for="server_description">{lang_Description} .:</label>
+				<input type="text" name="server_description" value="{server_description}" size="30" maxlength="50">
+				<br>
+				
+				<!-- Server URL -->
+				<label for="server_url">{lang_URL} .:</label>
+				<input type="text" name="server_url" value="{server_url}" size="50" maxlength="50">
+				<br>
+	
+				<!-- Server Rest -->
+				<label for="server_rest">{lang_API_Rest} .:</label>
+				<input type="text" name="server_rest" value="{server_rest}" size="50" maxlength="50">
+				<br>
+				
+				<!-- Server Status -->
+				<label for="server_status">{lang_Server_Status} .:</label>
+				<select name="server_status">
+					<option value="true" {selected_statusServer_true}>{lang_Enabled}</option>
+					<option value="false" {selected_statusServer_false}>{lang_Disabled}</option>
+				</select>
+				<br>
+				
+				<div style="float:left;">
+					<input type="submit" name="save" value="{lang_Save}"/>
+				</div>
+				
+				<div style="float:right;">
+					<input type="submit" name="back" value="{lang_Back}"/>
+				</div>	
+			</form>
+		</fieldset>		
+		
+		<br clear="all"/>
+		
+		<div style="margin-top:10px;">
+			<table style="border:1px solid #000; width:100%">
+				<tr align="left">
+					<th>{lang_Server_Name}</th>
+					<th>{lang_Description}</th>
+					<th>{lang_URL}</th>
+					<th>{lang_API_Rest}</th>
+					<th>{lang_Server_Status}</th>
+					<th>{lang_Edit}</th>
+					<th>{lang_Delete}</th>
+				</tr>
+				{table_servers}
+			</table>
+		</div>
+	
+	</div>
+</div>
+
+<!-- END pagina -->
Index: /sandbox/webservice/rest/templates/css/style.css
===================================================================
--- /sandbox/webservice/rest/templates/css/style.css	(revision 7466)
+++ /sandbox/webservice/rest/templates/css/style.css	(revision 7466)
@@ -0,0 +1,39 @@
+label, input
+{
+	font-size: 9pt;
+	display: block;
+	float: left;
+}
+
+label
+{	
+	text-align: left;
+	width: 120px;
+	padding-right: 10px;
+	padding-bottom: 8px;
+}
+
+fieldset {
+	border: solid 1px #000;
+}
+
+br {
+	clear: left;
+}
+
+th
+{
+	font-size: 9pt;
+}
+
+#globalDiv
+{
+	width: 800px;
+	margin:0 auto;         
+}
+
+#contentDiv
+{
+	padding: 5px;
+	background-color: #eee;
+}
