PM-3671 Process Permission>AL configurar un permiso y querer guardar nos visualiza un error

This commit is contained in:
Ronald Quenta
2015-09-25 16:34:54 -04:00
parent 9fa3c2d2bf
commit 3a73a96f51
4 changed files with 25 additions and 17 deletions

View File

@@ -378,6 +378,7 @@ class WebApplication
}
Services\OAuth2\Server::setWorkspace(SYS_SYS);
Services\OAuth2\Server::loadPostEnvironment();
$this->rest->addAPIClass('\ProcessMaker\\Services\\OAuth2\\Server', 'oauth2');
return $uri;

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);
}
}
}