<?php
 function stripClassNamespace($className) { if (!$className) { return ''; } $pos=strrpos($className, '\\'); if ($pos===false) { return $className; } else { return substr($className, $pos+1); } } function getClassNamespace($className) { if (!$className) { return ''; } $pos=strrpos($className, '\\'); if ($pos===false) { return ''; } else { return substr($className, 0, $pos); } } if (isset($S['auth']) and isset($S['auth']['idUser']) and $S['auth']['idUser']) { define ('CURRENT_ID_USER', $S['auth']['idUser']); define ('CURRENT_ID_OFFICE', $S['auth']['idOffice']); define ('CURRENT_ID_DEPT', $S['auth']['idDept']); } if (!defined('CURRENT_ID_USER') && !defined('CURRENT_ID_OFFICE') && !defined('CURRENT_ID_DEPT')) { $request = \GuzzleHttp\Psr7\ServerRequest::fromGlobals(); try { $validated = \App\OAuth2\Server::getInstance() ->getResourceServer() ->validateAuthenticatedRequest($request); } catch (\League\OAuth2\Server\Exception\OAuthServerException $e) { } catch (\Throwable $e) { } if ($validated) { $idUser = (int) $validated->getAttribute('oauth_user_id'); $user = \Entity\User::select($idUser); define ('CURRENT_ID_USER', $idUser); define ('CURRENT_ID_OFFICE', $user->getFields()['idOffice']??0); define ('CURRENT_ID_DEPT', $user->getFields()['idDepartment']??0); } } if (!defined('CURRENT_ID_USER')) { define ('CURRENT_ID_USER', 0); } if (!defined('CURRENT_ID_OFFICE')) { define ('CURRENT_ID_OFFICE', 0); } if (!defined('CURRENT_ID_DEPT')) { define ('CURRENT_ID_DEPT', 0); } 