OpenXE/phpwf/class.player.php

346 lines
14 KiB
PHP
Raw Normal View History

2021-05-21 08:49:41 +02:00
<?php
2023-03-30 10:54:18 +02:00
/*
* SPDX-FileCopyrightText: 2019 Xentral ERP Software GmbH, Fuggerstrasse 11, D-86150 Augsburg
2024-04-18 12:48:03 +02:00
* SPDX-FileCopyrightText: 2023-2024 Andreas Palm
2023-03-30 10:54:18 +02:00
*
* SPDX-License-Identifier: LicenseRef-EGPL-3.1
*/
2022-06-29 11:26:50 +02:00
/*
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
*
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
*
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
*
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
* to obtain the text of the corresponding license version.
*
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
2021-05-21 08:49:41 +02:00
*/
?>
2022-06-29 11:26:50 +02:00
<?php
/* Author: Benedikt Sauter, sauter@ibat.de, 2007
* Player for PHP Applications
*/
class Player {
public $DefautTemplates;
public $DefautTheme;
/** @var erpooSystem $app the application object */
public $app;
function __construct()
{
$this->DefautTemplates="defaulttemplates";
$this->DefautTheme="default";
}
function SetDefaultTemplates($path)
{
}
function SetDefaultTheme($path)
{
}
public function BuildNavigation()
{
if(!WithGUI() || !method_exists($this->app->Page,'CreateNavigation') || !method_exists('erpAPI','Navigation')) {
return;
}
$this->app->Page->CreateNavigation($this->app->erp->Navigation());
}
public function Run($sessionObj)
{
$this->app = $sessionObj->app;
// play application only when layer 2 said that its ok
if(!$sessionObj->GetCheck()) {
if($sessionObj->reason=='PLEASE_LOGIN')
{
$module = 'welcome';
$action = 'login';
$this->app->Secure->GET['module']='welcome';
$this->app->Secure->GET['action']='login';
}
} else {
$hasModuleAndAction = !empty($this->app->Secure->GET['module']) && !empty($this->app->Secure->GET['action']);
if($hasModuleAndAction &&
$this->app->Secure->GET['module'] === 'artikel' && $this->app->Secure->GET['action'] === 'thumbnail') {
/** @var Artikel $obj */
$obj = $this->app->loadModule('artikel');
if(!empty($obj) && method_exists($obj, 'ArtikelThumbnailCache')) {
$obj->ArtikelThumbnailCache();
}
}
elseif($hasModuleAndAction &&
$this->app->Secure->GET['module'] === 'wiki' && $this->app->Secure->GET['action'] === 'getfile') {
/** @var Wiki $obj */
$obj = $this->app->loadModule('wiki');
if(!empty($obj) && method_exists($obj, 'WikiGetFileCache')) {
$obj->WikiGetFileCache();
}
}
if (!empty($this->app->Secure->GET['module']) && !empty($this->app->Secure->GET['action']) &&
in_array($this->app->Secure->GET['module'],['backup', 'systemtemplates']) && $this->app->Secure->GET['action'] === 'readstatus'){
$sessionFile = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR . 'session.txt';
if(file_exists($sessionFile) && ((string) $bckSession = file_get_contents($sessionFile)) && trim($bckSession) === session_id()){
$obj = $this->app->loadModule($this->app->Secure->GET['module']);
$obj->ReadStatus();
}
}
// Get actual commands from URL
$module = $this->app->Secure->GetGET('module','module');
$action = $this->app->Secure->GetGET('action','module');
if($module =='') {
$module = 'welcome';
$action = 'main';
}
2024-04-18 12:48:03 +02:00
}
2022-06-29 11:26:50 +02:00
if($action!="list" && $action!="css" && $action!="logo" && $action!="poll" && $module!="ajax" && $module!="protokoll" && $action!="thumbnail"){
$this->app->erp->Protokoll();
}
$id = $this->app->Secure->GetGET('id');
$lid = $this->app->Secure->GetGET('lid');
if($module !== 'welcome' && $action !== 'poll' && $module !== 'ajax'){
if(($module !== 'artikel' || $action !== 'thumbnail')
&& ($module !== 'wiki' || $action !== 'getfile')
&& $action !== 'editable' && $action !== 'positionen'){
$this->app->Laender($module, $action, $id, $lid);
}
}
// plugin instanzieren
// start module
if(file_exists(dirname(__DIR__).'/www/pages/'.$module.'.php')){
if(file_exists(dirname(__DIR__).'/www/pages/'.$module.'_custom.php')){
include_once dirname(__DIR__).'/www/pages/'.$module.'.php';
include_once dirname(__DIR__).'/www/pages/'.$module.'_custom.php';
//create dynamical an object
$constr = strtoupper($module[0]) . substr($module, 1) . 'Custom';
if(class_exists($constr))
{
$myApp = new $constr($this->app);
}else{
$constr = strtoupper($module[0]) . substr($module, 1);
if(class_exists($constr))
{
$myApp = new $constr($this->app);
}
elseif(file_exists(dirname(__DIR__).'/www/pages/'.$module.'.php')){
include dirname(__DIR__).'/www/pages/'.$module.'.php';
if(class_exists($constr)){
$myApp = new $constr($this->app);
}
}
}
if(method_exists($constr, 'AllowedVersion') && isset($this->app->User) && $this->app->User && method_exists($this->app->User, 'GetType') && $this->app->User->GetType() == 'admin')
{
$r2 = new ReflectionMethod($constr, 'AllowedVersion');
if($r2->isStatic())
{
$allowed = $constr::AllowedVersion();
include(dirname(__DIR__) . '/version.php');
if((isset($allowed['max']) && ((float)$allowed['max'] < (float)$version_revision))
||
(isset($allowed['versionen']) && (
(is_array($allowed['versionen']) && !in_array($version_revision, $allowed['versionen']))
|| (!is_array($allowed['versionen']) && $allowed['versionen'] != $version_revision)
))
)
{
$title = 'Inkompatibilität festgestellt';
$message = 'Die Datei '.$module."_custom.php".' auf Ihrem System, ist nicht für Ihre Version geeignet';
/** @var \Xentral\Modules\SystemNotification\Gateway\NotificationGateway $notifyGateway */
$notifyGateway = $this->app->Container->get('NotificationGateway');
if (!$notifyGateway->hasDuplicatedMessage($this->app->User->GetID(), $title, $message)) {
/** @var \Xentral\Modules\SystemNotification\Service\NotificationServiceInterface $notifyService */
$notifyService = $this->app->Container->get('NotificationService');
$notifyService->create($this->app->User->GetID(), 'warning', $title, $message);
}
}
}
}
} else {
include_once(dirname(__DIR__)."/www/pages/".$module.".php");
//create dynamical an object
$constr = strtoupper($module[0]) . substr($module, 1);
if(class_exists($constr))$myApp = new $constr($this->app);
}
}
else {
if(file_exists(dirname(__DIR__)."/www/pages/_gen/".$module.".php")){
include_once(dirname(__DIR__)."/www/pages/_gen/".$module.".php");
//create dynamical an object
$constr = "Gen" . strtoupper($module[0]) . substr($module, 1);
$myApp = new $constr($this->app);
}
else {
if(file_exists(dirname(__DIR__)."/www/pages/_gen/".$module.".php")){
include_once(dirname(__DIR__)."/www/pages/_gen/".$module.".php");
//create dynamical an object
$constr = "Gen" . strtoupper($module[0]) . substr($module, 1);
$myApp = new $constr($this->app);
}
}
}
$this->app->erp->RunHook('player_run_before_include_js_css');
/** @deprecated-block-start Wird später über den Installer eingebunden */
if (class_exists('Xentral\Modules\SystemNotification\Bootstrap', true)) {
$javascript = forward_static_call(['Xentral\\Modules\\SystemNotification\\Bootstrap', 'registerJavascript']);
foreach ($javascript as $cacheName => $jsFiles) {
$this->app->ModuleScriptCache->IncludeJavascriptFiles($cacheName, $jsFiles);
}
$stylesheets = forward_static_call(['Xentral\\Modules\\SystemNotification\\Bootstrap', 'registerStylesheets']);
foreach ($stylesheets as $cacheName => $cssFiles) {
$this->app->ModuleScriptCache->IncludeStylesheetFiles($cacheName, $cssFiles);
}
}
if (class_exists('Xentral\Modules\Wizard\Bootstrap', true)) {
$javascript = forward_static_call(['Xentral\\Modules\\Wizard\\Bootstrap', 'registerJavascript']);
foreach ($javascript as $cacheName => $jsFiles) {
$this->app->ModuleScriptCache->IncludeJavascriptFiles($cacheName, $jsFiles);
}
$stylesheets = forward_static_call(['Xentral\\Modules\\Wizard\\Bootstrap', 'registerStylesheets']);
foreach ($stylesheets as $cacheName => $cssFiles) {
$this->app->ModuleScriptCache->IncludeStylesheetFiles($cacheName, $cssFiles);
}
}
if (class_exists('Xentral\\Widgets\\ClickByClickAssistant\\Bootstrap', true)) {
$this->app->ModuleScriptCache->IncludeWidgetNew('ClickByClickAssistant');
}
if (class_exists('Xentral\\Widgets\\SuperSearch\\Bootstrap', true)) {
$this->app->ModuleScriptCache->IncludeWidgetNew('SuperSearch');
}
/** @deprecated-block-end */
$moduleClassName = strtoupper($module[0]) . substr($module, 1);
$this->app->ModuleScriptCache->IncludeModule($moduleClassName);
2023-03-30 10:54:18 +02:00
$this->app->ModuleScriptCache->IncludeJavascriptModules('_theme_', ['www/themes/new/js/main.js']);
2022-06-29 11:26:50 +02:00
$this->app->Tpl->Add('MODULESTYLESHEET', $this->app->ModuleScriptCache->GetStylesheetHtmlTags());
$this->app->Tpl->Add('MODULEJAVASCRIPTHEAD', $this->app->ModuleScriptCache->GetJavascriptHtmlTags('head'));
$this->app->Tpl->Add('MODULEJAVASCRIPTBODY', $this->app->ModuleScriptCache->GetJavascriptHtmlTags('body'));
2023-03-30 10:54:18 +02:00
$this->app->Tpl->Set('JAVASCRIPTMODULES', $this->app->ModuleScriptCache->GetJavascriptModulesHtmlTags());
2023-12-11 22:13:37 +01:00
if (defined('VITE_DEV_SERVER')) {
$this->app->Tpl->Add('ADDITIONALCSPHEADER', VITE_DEV_SERVER.' ');
}
2022-06-29 11:26:50 +02:00
$permission = true;
if(isset($myApp) && method_exists($myApp,'CheckRights'))$permission = $myApp->CheckRights();
if(!$permission)
{
if($this->app->User->GetID()<=0)
{
$this->app->erp->Systemlog("Keine gueltige Benutzer ID erhalten",1);
@session_destroy();
echo str_replace('BACK',"index.php?module=welcome&action=login",$this->app->Tpl->FinalParse("permissiondenied.tpl"));
}
else {
$this->app->erp->Systemlog("Fehlendes Recht",1);
echo str_replace('BACK',isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:'',$this->app->Tpl->FinalParse("permissiondenied.tpl"));
}
exit;
}
$this->app->calledWhenAuth($this->app->User->GetType());
if($this->app->BuildNavigation==true)
$this->BuildNavigation();
$this->app->endtime = microtime();
$right = $this->app->Secure->GetGET("right");
$tmpfirmendatenfkt = 'Firmendaten';
if(method_exists($this->app->erp,'TplFirmendaten'))$tmpfirmendatenfkt = 'TplFirmendaten';
$firmenfarbehell = $this->app->erp->$tmpfirmendatenfkt("firmenfarbehell");
if($firmenfarbehell =="")
$firmenfarbehell = "#3fbac9";
$this->app->Tpl->Set('COLOR1',$firmenfarbehell);
$this->app->calledBeforeFinish();
$this->app->Tpl->Set('JQUERYMIGRATESRC', './js/jquery/jquery-migrate-3.2.0.min.js');
$this->app->Tpl->Set('TESTLIZENZABLAUF', '');
if($this->app->BuildNavigation==true)
{
if($right==1)
echo $this->app->Tpl->FinalParse('right.tpl');
else
{
if($module==='welcome' && $action==='login'){
if(is_file(dirname(__DIR__).'/www/themes/new/templates/loginslider.tpl')) {
$this->app->Tpl->Set(
'LOGINSLIDER',
file_get_contents(dirname(__DIR__).'/www/themes/new/templates/loginslider.tpl')
);
}
else{
$this->app->Tpl->Set(
'LOGINSLIDER',
'<div class="slide" style="background-image: url(\'./themes/new/images/login_screen_picture.jpg\');">
</div>'
);
}
$this->app->erp->RunHook('loginpage');
echo $this->app->Tpl->FinalParse('loginpage.tpl');
}
elseif($module==='welcome' && $action==='passwortvergessen'){
echo $this->app->Tpl->FinalParse('passwortvergessenpage.tpl');
}
else {
$this->app->erp->addFav();
$this->app->erp->HelpIconAndTooltip();
if(
($module !== 'welcome'
|| ($action !== 'settings' && $action !== 'logout' && $action !== 'login'
&& $action !== 'start'&& $action !== 'startseite' && $action !== 'main'
)
)
&& ($isadminadmin = $this->app->acl->IsAdminadmin()))
{
header('Location: index.php?module=welcome&action=start');
exit;
}
$this->app->HeaderBoxen();
if($this->app->erp->UserDevice()==='smartphone'){
echo $this->app->Tpl->FinalParse('page_smartphone.tpl');
}
else{
$this->app->Tpl->Set('VUEJS', 'vue.min.js');
2023-03-30 10:54:18 +02:00
$this->app->erp->RunHook('before_final_parse_page');
2022-06-29 11:26:50 +02:00
echo $this->app->Tpl->FinalParse('page.tpl');
}
}
}
}
else {
if($this->app->PopupJS){
echo $this->app->Tpl->FinalParse('popup_js.tpl');
}
else{
echo $this->app->Tpl->FinalParse('popup.tpl');
}
}
}
}