Merged in qronald/processmaker/PM-3671 (pull request #2844)

PM-3671
This commit is contained in:
Julio Cesar Laura Avendaño
2015-09-28 12:07:45 -03:00
4 changed files with 25 additions and 17 deletions

View File

@@ -17,7 +17,6 @@ class ProcessPermissions extends Api
/**
* @param string $prj_uid {@min 1} {@max 32}
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
@@ -40,7 +39,6 @@ class ProcessPermissions extends Api
* @param string $prj_uid {@min 1} {@max 32}
* @param string $ob_uid {@min 1} {@max 32}
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
@@ -75,7 +73,6 @@ class ProcessPermissions extends Api
* @param string $inputs {@from body}
* @param string $outputs {@from body}
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
@@ -134,7 +131,6 @@ class ProcessPermissions extends Api
* @param string $inputs {@from body}
* @param string $outputs {@from body}
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
@@ -172,7 +168,6 @@ class ProcessPermissions extends Api
* @param string $prj_uid {@min 1} {@max 32}
* @param string $ob_uid {@min 1} {@max 32}
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*

View File

@@ -296,14 +296,5 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
return array_merge($a, array_change_key_case($a, $case));
}
public function loadPostEnvironment($request = null)
{
if (!defined('SYS_LANG')) {
$acceptLanguage =$request->headers('ACCEPT_LANGUAGE');
$lang = (!is_null($acceptLanguage) && strlen($acceptLanguage)<=2)?$acceptLanguage:'en';
define("SYS_LANG", $lang);
}
return true;
}
}

View File

@@ -285,8 +285,6 @@ class Server implements iAuthenticate
$request = \OAuth2\Request::createFromGlobals();
}
$this->storage->loadPostEnvironment($request);
$response = $this->server->handleTokenRequest($request); //Set/Get token //PmPdo->setAccessToken()
$token = $response->getParameters();
@@ -334,7 +332,6 @@ class Server implements iAuthenticate
public function __isAllowed()
{
$request = \OAuth2\Request::createFromGlobals();
$this->storage->loadPostEnvironment($request);
$allowed = $this->server->verifyResourceRequest($request);
$token = $this->server->getAccessTokenData($request);
self::$userId = $token['user_id'];
@@ -394,5 +391,29 @@ class Server implements iAuthenticate
{
return "";
}
public static function loadPostEnvironment($request = null)
{
$acceptLanguage = 'en';
if ($request == null) {
$request = \OAuth2\Request::createFromGlobals();
$acceptLanguage = $request->headers('ACCEPT_LANGUAGE');
}
if (!defined('SYS_LANG')) {
$Translations = new \Translation;
$translationsTable = $Translations->getTranslationEnvironments();
$inLang = false;
foreach ($translationsTable as $locale) {
if ($locale['LOCALE'] == $acceptLanguage){
$inLang = true;
break;
}
}
$lang = $inLang?$acceptLanguage:'en';
define("SYS_LANG", $lang);
}
}
}