Merge pull request #2940 from GPCsolutions/restapireview

Fixed some coding style issues
This commit is contained in:
Laurent Destailleur 2015-06-05 15:55:15 +02:00
commit eebb93f435
2 changed files with 23 additions and 25 deletions

View File

@ -18,7 +18,7 @@
use \Luracast\Restler\iAuthenticate; use \Luracast\Restler\iAuthenticate;
use \Luracast\Restler\Resources; use \Luracast\Restler\Resources;
use \Luracast\Restler\Defaults; use \Luracast\Restler\Defaults;
use Luracast\Restler\RestException; use \Luracast\Restler\RestException;
/** /**
@ -44,24 +44,14 @@ class DolibarrApiAccess implements iAuthenticate
*/ */
public static $user = ''; public static $user = '';
// @codingStandardsIgnoreStart
/**
* @return string string to be used with WWW-Authenticate header
* @example Basic
* @example Digest
* @example OAuth
*/
public function __getWWWAuthenticateString();
/** /**
* Check access * Check access
* *
* @return boolean * @return bool
* @throws RestException
*/ */
public function _isAllowed() public function __isAllowed()
{ {
// @codingStandardsIgnoreEnd
global $db; global $db;
$stored_key = ''; $stored_key = '';
@ -74,7 +64,8 @@ class DolibarrApiAccess implements iAuthenticate
$sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE u.api_key = '".$db->escape($_GET['api_key'])."'"; $sql.= " WHERE u.api_key = '".$db->escape($_GET['api_key'])."'";
if ($db->query($sql)) $result = $db->query($sql);
if ($result)
{ {
if ($db->num_rows($result)) if ($db->num_rows($result))
{ {
@ -116,6 +107,12 @@ class DolibarrApiAccess implements iAuthenticate
} }
// @codingStandardsIgnoreStart // @codingStandardsIgnoreStart
/**
* @return string string to be used with WWW-Authenticate header
* @example Basic
* @example Digest
* @example OAuth
*/
public function __getWWWAuthenticateString() public function __getWWWAuthenticateString()
{ {
return ''; return '';
@ -123,12 +120,13 @@ class DolibarrApiAccess implements iAuthenticate
// @codingStandardsIgnoreEnd // @codingStandardsIgnoreEnd
/** /**
* Verify access * Verify access
* *
* @param array $m Properties of method * @param array $m Properties of method
* *
* @access private * @access private
*/ * @return bool
*/
public static function verifyAccess(array $m) public static function verifyAccess(array $m)
{ {
$requires = isset($m['class']['DolibarrApiAccess']['properties']['requires']) $requires = isset($m['class']['DolibarrApiAccess']['properties']['requires'])

View File

@ -47,8 +47,8 @@ if (empty($conf->global->MAIN_MODULE_API))
exit; exit;
} }
use Luracast\Restler\Defaults; use \Luracast\Restler\Defaults;
Defaults::setProperty('authenticationMethod','_isAllowed'); Defaults::setProperty('authenticationMethod','__isAllowed');
$api = new DolibarrApi($db); $api = new DolibarrApi($db);