@@ -184,7 +184,7 @@ |
||
| 184 | 184 | if (static::$clearOpcache) { |
| 185 | 185 | return false; |
| 186 | 186 | } |
| 187 | - register_shutdown_function(function () { |
|
| 187 | + register_shutdown_function(function() { |
|
| 188 | 188 | static::resetOpcache(); |
| 189 | 189 | }); |
| 190 | 190 | static::$clearOpcache = true; |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | public static function init() |
| 35 | 35 | { |
| 36 | - register_shutdown_function(function () { |
|
| 36 | + register_shutdown_function(function() { |
|
| 37 | 37 | static::flush(); |
| 38 | 38 | }); |
| 39 | 39 | } |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | { |
| 18 | 18 | //Override the default expire time of token |
| 19 | 19 | \CsrfMagic\Csrf::$expires = 259200; |
| 20 | - \CsrfMagic\Csrf::$callback = function ($tokens) { |
|
| 20 | + \CsrfMagic\Csrf::$callback = function($tokens) { |
|
| 21 | 21 | throw new \App\Exceptions\BadRequest('Invalid request - Response For Illegal Access'); |
| 22 | 22 | }; |
| 23 | 23 | $js = PUBLIC_DIRECTORY . 'vendor/yetiforce/csrf-magic/src/Csrf.min.js'; |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | if (empty($response['secretKey'])) { |
| 59 | 59 | $this->authMethods = $response['authMethods']; |
| 60 | 60 | } else { |
| 61 | - ['authMethods' => $this->authMethods , 'secretKey' => $this->secretKey] = $response; |
|
| 61 | + ['authMethods' => $this->authMethods, 'secretKey' => $this->secretKey] = $response; |
|
| 62 | 62 | $this->viewer->assign('QR_CODE_HTML', $this->createQrCodeForUser()); |
| 63 | 63 | } |
| 64 | 64 | $this->viewer->assign('SECRET_KEY', $this->secretKey); |
@@ -227,7 +227,7 @@ |
||
| 227 | 227 | if (Config::$apiAllLogs || (Config::$apiErrorLogs && (isset($responseBody['error']) || empty($responseBody) || 200 !== $response->getStatusCode()))) { |
| 228 | 228 | \App\Log::info([ |
| 229 | 229 | 'request' => ['date' => date('Y-m-d H:i:s', $startTime), 'requestType' => strtoupper($requestType), 'method' => $method, 'headers' => $headers, 'rawBody' => $this->dataBody, 'body' => $data], |
| 230 | - 'response' => ['time' => round(microtime(true) - $startTime, 2), 'status' => $response->getStatusCode(), 'reasonPhrase' => $response->getReasonPhrase(), 'headers' => $response->getHeaders(), 'rawBody' => $rawResponse, 'body' => $responseBody], |
|
| 230 | + 'response' => ['time' => round(microtime(true) - $startTime, 2), 'status' => $response->getStatusCode(), 'reasonPhrase' => $response->getReasonPhrase(), 'headers' => $response->getHeaders(), 'rawBody' => $rawResponse, 'body' => $responseBody], |
|
| 231 | 231 | ], 'Api'); |
| 232 | 232 | } |
| 233 | 233 | if (isset($responseBody['error'])) { |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | protected $defaultOperator = 'a'; |
| 31 | 31 | |
| 32 | 32 | /** @var string[] Not supported field types. */ |
| 33 | - protected $notSupportedToEdit = ['multiCurrency', 'serverAccess', 'multiReference', 'barcode', 'changesJson', 'iban', 'token', 'currencyInventory', 'twitter', 'multiReferenceValue', 'taxes', 'recurrence', 'meetingUrl', 'reminder', 'totalTime', 'multiowner', 'userReference', 'currencyList', 'modules', 'inventoryLimit', 'multiEmail', 'multiDependField', 'smtp', 'multiDomain', 'magentoServer']; |
|
| 33 | + protected $notSupportedToEdit = ['multiCurrency', 'serverAccess', 'multiReference', 'barcode', 'changesJson', 'iban', 'token', 'currencyInventory', 'twitter', 'multiReferenceValue', 'taxes', 'recurrence', 'meetingUrl', 'reminder', 'totalTime', 'multiowner', 'userReference', 'currencyList', 'modules', 'inventoryLimit', 'multiEmail', 'multiDependField', 'smtp', 'multiDomain', 'magentoServer']; |
|
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * Function to set the name of the module to which the record belongs. |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class CartView extends ListViewModel |
| 24 | 24 | { |
| 25 | - const ADDRESS_FIELDS = ['addresslevel1', 'addresslevel2', 'addresslevel3', 'addresslevel4', 'addresslevel5', 'addresslevel6', 'addresslevel7', 'addresslevel8', 'buildingnumber', 'localnumber', 'pobox']; |
|
| 25 | + const ADDRESS_FIELDS = ['addresslevel1', 'addresslevel2', 'addresslevel3', 'addresslevel4', 'addresslevel5', 'addresslevel6', 'addresslevel7', 'addresslevel8', 'buildingnumber', 'localnumber', 'pobox']; |
|
| 26 | 26 | |
| 27 | 27 | /** @var Shopping cart */ |
| 28 | 28 | private $cart; |
@@ -18,375 +18,375 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | abstract class View extends Base |
| 20 | 20 | { |
| 21 | - /** @var \App\Viewer Viewer object. */ |
|
| 22 | - protected $viewer; |
|
| 21 | + /** @var \App\Viewer Viewer object. */ |
|
| 22 | + protected $viewer; |
|
| 23 | 23 | |
| 24 | - /** {@inheritdoc} */ |
|
| 25 | - public function __construct(\App\Request $request) |
|
| 26 | - { |
|
| 27 | - parent::__construct($request); |
|
| 28 | - $this->loadJsConfig($request); |
|
| 29 | - $this->viewer = new \App\Viewer(); |
|
| 30 | - $this->viewer->assign('MODULE_NAME', $this->getModuleNameFromRequest($this->request)); |
|
| 31 | - $this->viewer->assign('VIEW', $this->request->getByType('view', \App\Purifier::ALNUM)); |
|
| 32 | - $this->viewer->assign('NONCE', \App\Session::get('CSP_TOKEN')); |
|
| 33 | - $this->viewer->assign('LANGUAGE', \App\Language::getLanguage()); |
|
| 34 | - $this->viewer->assign('LANG', \App\Language::getShortLanguageName()); |
|
| 35 | - $this->viewer->assign('USER', \App\User::getUser()); |
|
| 36 | - $this->viewer->assign('ACTION_NAME', $this->request->getAction()); |
|
| 37 | - } |
|
| 24 | + /** {@inheritdoc} */ |
|
| 25 | + public function __construct(\App\Request $request) |
|
| 26 | + { |
|
| 27 | + parent::__construct($request); |
|
| 28 | + $this->loadJsConfig($request); |
|
| 29 | + $this->viewer = new \App\Viewer(); |
|
| 30 | + $this->viewer->assign('MODULE_NAME', $this->getModuleNameFromRequest($this->request)); |
|
| 31 | + $this->viewer->assign('VIEW', $this->request->getByType('view', \App\Purifier::ALNUM)); |
|
| 32 | + $this->viewer->assign('NONCE', \App\Session::get('CSP_TOKEN')); |
|
| 33 | + $this->viewer->assign('LANGUAGE', \App\Language::getLanguage()); |
|
| 34 | + $this->viewer->assign('LANG', \App\Language::getShortLanguageName()); |
|
| 35 | + $this->viewer->assign('USER', \App\User::getUser()); |
|
| 36 | + $this->viewer->assign('ACTION_NAME', $this->request->getAction()); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Check permission. |
|
| 41 | - * |
|
| 42 | - * @throws \App\Exceptions\NoPermitted |
|
| 43 | - * |
|
| 44 | - * @return void |
|
| 45 | - */ |
|
| 46 | - public function checkPermission(): void |
|
| 47 | - { |
|
| 48 | - $this->getModuleNameFromRequest($this->request); |
|
| 49 | - if (!\App\User::getUser()->isPermitted($this->moduleName)) { |
|
| 50 | - throw new \App\Exceptions\AppException('ERR_MODULE_PERMISSION_DENIED'); |
|
| 51 | - } |
|
| 52 | - } |
|
| 39 | + /** |
|
| 40 | + * Check permission. |
|
| 41 | + * |
|
| 42 | + * @throws \App\Exceptions\NoPermitted |
|
| 43 | + * |
|
| 44 | + * @return void |
|
| 45 | + */ |
|
| 46 | + public function checkPermission(): void |
|
| 47 | + { |
|
| 48 | + $this->getModuleNameFromRequest($this->request); |
|
| 49 | + if (!\App\User::getUser()->isPermitted($this->moduleName)) { |
|
| 50 | + throw new \App\Exceptions\AppException('ERR_MODULE_PERMISSION_DENIED'); |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** {@inheritdoc} */ |
|
| 55 | - public function preProcess($display = true): void |
|
| 56 | - { |
|
| 57 | - if ($this->loginRequired()) { |
|
| 58 | - $this->viewer->assign('MENU', \YF\Modules\Base\Model\Menu::getInstance($this->viewer->getTemplateVars('MODULE_NAME'))->getMenu()); |
|
| 59 | - } |
|
| 60 | - $this->viewer->assign('PAGE_TITLE', (\Conf\Config::$siteName ?: \App\Language::translate('LBL_CUSTOMER_PORTAL')) . ' ' . $this->getPageTitle()); |
|
| 61 | - $this->viewer->assign('CSS_FILE', $this->getHeaderCss()); |
|
| 62 | - $this->viewer->assign('USER_QUICK_MENU', $this->getUserQuickMenuLinks()); |
|
| 63 | - if ($display) { |
|
| 64 | - $this->preProcessDisplay(); |
|
| 65 | - } |
|
| 66 | - } |
|
| 54 | + /** {@inheritdoc} */ |
|
| 55 | + public function preProcess($display = true): void |
|
| 56 | + { |
|
| 57 | + if ($this->loginRequired()) { |
|
| 58 | + $this->viewer->assign('MENU', \YF\Modules\Base\Model\Menu::getInstance($this->viewer->getTemplateVars('MODULE_NAME'))->getMenu()); |
|
| 59 | + } |
|
| 60 | + $this->viewer->assign('PAGE_TITLE', (\Conf\Config::$siteName ?: \App\Language::translate('LBL_CUSTOMER_PORTAL')) . ' ' . $this->getPageTitle()); |
|
| 61 | + $this->viewer->assign('CSS_FILE', $this->getHeaderCss()); |
|
| 62 | + $this->viewer->assign('USER_QUICK_MENU', $this->getUserQuickMenuLinks()); |
|
| 63 | + if ($display) { |
|
| 64 | + $this->preProcessDisplay(); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Get page title. |
|
| 70 | - * |
|
| 71 | - * @return string |
|
| 72 | - */ |
|
| 73 | - public function getPageTitle(): string |
|
| 74 | - { |
|
| 75 | - $title = \App\Language::translateModule($this->moduleName); |
|
| 76 | - $pageTitle = $this->getBreadcrumbTitle(); |
|
| 77 | - if (isset($this->pageTitle)) { |
|
| 78 | - $pageTitle = \App\Language::translate($this->pageTitle); |
|
| 79 | - } |
|
| 80 | - if ($pageTitle) { |
|
| 81 | - $title .= ' - ' . $pageTitle; |
|
| 82 | - } |
|
| 83 | - return $title; |
|
| 84 | - } |
|
| 68 | + /** |
|
| 69 | + * Get page title. |
|
| 70 | + * |
|
| 71 | + * @return string |
|
| 72 | + */ |
|
| 73 | + public function getPageTitle(): string |
|
| 74 | + { |
|
| 75 | + $title = \App\Language::translateModule($this->moduleName); |
|
| 76 | + $pageTitle = $this->getBreadcrumbTitle(); |
|
| 77 | + if (isset($this->pageTitle)) { |
|
| 78 | + $pageTitle = \App\Language::translate($this->pageTitle); |
|
| 79 | + } |
|
| 80 | + if ($pageTitle) { |
|
| 81 | + $title .= ' - ' . $pageTitle; |
|
| 82 | + } |
|
| 83 | + return $title; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Get breadcrumb title. |
|
| 88 | - * |
|
| 89 | - * @return string |
|
| 90 | - */ |
|
| 91 | - public function getBreadcrumbTitle(): string |
|
| 92 | - { |
|
| 93 | - if (!empty($this->pageTitle)) { |
|
| 94 | - return $this->pageTitle; |
|
| 95 | - } |
|
| 96 | - return ''; |
|
| 97 | - } |
|
| 86 | + /** |
|
| 87 | + * Get breadcrumb title. |
|
| 88 | + * |
|
| 89 | + * @return string |
|
| 90 | + */ |
|
| 91 | + public function getBreadcrumbTitle(): string |
|
| 92 | + { |
|
| 93 | + if (!empty($this->pageTitle)) { |
|
| 94 | + return $this->pageTitle; |
|
| 95 | + } |
|
| 96 | + return ''; |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * Convert scripts path. |
|
| 101 | - * |
|
| 102 | - * @param array $files |
|
| 103 | - * @param string $fileExtension |
|
| 104 | - * |
|
| 105 | - * @return array |
|
| 106 | - */ |
|
| 107 | - public function convertScripts(array $files, string $fileExtension): array |
|
| 108 | - { |
|
| 109 | - $scriptsInstances = []; |
|
| 110 | - foreach ($files as $file) { |
|
| 111 | - [$fileName, $isOptional] = array_pad($file, 2, false); |
|
| 112 | - $path = ROOT_DIRECTORY . "/public_html/$fileName"; |
|
| 113 | - $script = new \App\Script(); |
|
| 114 | - $script->set('type', $fileExtension); |
|
| 115 | - $minFilePath = str_replace('.' . $fileExtension, '.min.' . $fileExtension, $fileName); |
|
| 116 | - if (\App\Config::$minScripts && file_exists(ROOT_DIRECTORY . "/public_html/$minFilePath")) { |
|
| 117 | - $scriptsInstances[] = $script->set('src', PUBLIC_DIRECTORY . $minFilePath . self::getTime($path)); |
|
| 118 | - } elseif (file_exists($path)) { |
|
| 119 | - $scriptsInstances[] = $script->set('src', PUBLIC_DIRECTORY . $fileName . self::getTime($path)); |
|
| 120 | - } elseif (!$isOptional) { |
|
| 121 | - \App\Log::warning('File not found: ' . $path); |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - return $scriptsInstances; |
|
| 125 | - } |
|
| 99 | + /** |
|
| 100 | + * Convert scripts path. |
|
| 101 | + * |
|
| 102 | + * @param array $files |
|
| 103 | + * @param string $fileExtension |
|
| 104 | + * |
|
| 105 | + * @return array |
|
| 106 | + */ |
|
| 107 | + public function convertScripts(array $files, string $fileExtension): array |
|
| 108 | + { |
|
| 109 | + $scriptsInstances = []; |
|
| 110 | + foreach ($files as $file) { |
|
| 111 | + [$fileName, $isOptional] = array_pad($file, 2, false); |
|
| 112 | + $path = ROOT_DIRECTORY . "/public_html/$fileName"; |
|
| 113 | + $script = new \App\Script(); |
|
| 114 | + $script->set('type', $fileExtension); |
|
| 115 | + $minFilePath = str_replace('.' . $fileExtension, '.min.' . $fileExtension, $fileName); |
|
| 116 | + if (\App\Config::$minScripts && file_exists(ROOT_DIRECTORY . "/public_html/$minFilePath")) { |
|
| 117 | + $scriptsInstances[] = $script->set('src', PUBLIC_DIRECTORY . $minFilePath . self::getTime($path)); |
|
| 118 | + } elseif (file_exists($path)) { |
|
| 119 | + $scriptsInstances[] = $script->set('src', PUBLIC_DIRECTORY . $fileName . self::getTime($path)); |
|
| 120 | + } elseif (!$isOptional) { |
|
| 121 | + \App\Log::warning('File not found: ' . $path); |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + return $scriptsInstances; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - /** |
|
| 128 | - * Gets file modification time. |
|
| 129 | - * |
|
| 130 | - * @param string $path |
|
| 131 | - * |
|
| 132 | - * @return string |
|
| 133 | - */ |
|
| 134 | - public static function getTime(string $path): string |
|
| 135 | - { |
|
| 136 | - $url = ''; |
|
| 137 | - if ($fs = filemtime($path)) { |
|
| 138 | - $url = '?s=' . $fs; |
|
| 139 | - } |
|
| 140 | - return $url; |
|
| 141 | - } |
|
| 127 | + /** |
|
| 128 | + * Gets file modification time. |
|
| 129 | + * |
|
| 130 | + * @param string $path |
|
| 131 | + * |
|
| 132 | + * @return string |
|
| 133 | + */ |
|
| 134 | + public static function getTime(string $path): string |
|
| 135 | + { |
|
| 136 | + $url = ''; |
|
| 137 | + if ($fs = filemtime($path)) { |
|
| 138 | + $url = '?s=' . $fs; |
|
| 139 | + } |
|
| 140 | + return $url; |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - /** |
|
| 144 | - * Retrieves css styles that need to loaded in the page. |
|
| 145 | - * |
|
| 146 | - * @return \App\Script[] |
|
| 147 | - */ |
|
| 148 | - public function getHeaderCss(): array |
|
| 149 | - { |
|
| 150 | - return $this->convertScripts([ |
|
| 151 | - ['libraries/@fortawesome/fontawesome-free/css/all.css'], |
|
| 152 | - ['libraries/@mdi/font/css/materialdesignicons.css'], |
|
| 153 | - ['libraries/chosen-js/chosen.css'], |
|
| 154 | - ['libraries/bootstrap-chosen/bootstrap-chosen.css'], |
|
| 155 | - ['libraries/jQuery-Validation-Engine/css/validationEngine.jquery.css'], |
|
| 156 | - ['libraries/bootstrap-tabdrop/css/tabdrop.css'], |
|
| 157 | - ['libraries/select2/dist/css/select2.css'], |
|
| 158 | - ['libraries/datatables.net-bs4/css/dataTables.bootstrap4.css'], |
|
| 159 | - ['libraries/datatables.net-responsive-bs4/css/responsive.bootstrap4.css'], |
|
| 160 | - ['libraries/bootstrap-datepicker/dist/css/bootstrap-datepicker3.css'], |
|
| 161 | - ['libraries/bootstrap-daterangepicker/daterangepicker.css'], |
|
| 162 | - ['libraries/clockpicker/dist/bootstrap4-clockpicker.css'], |
|
| 163 | - ['libraries/jstree-bootstrap-theme/dist/themes/proton/style.css'], |
|
| 164 | - ['libraries/jstree/dist/themes/default/style.css'], |
|
| 165 | - ['libraries/@pnotify/core/dist/PNotify.css'], |
|
| 166 | - ['libraries/@pnotify/confirm/dist/PNotifyConfirm.css'], |
|
| 167 | - ['libraries/@pnotify/bootstrap4/dist/PNotifyBootstrap4.css'], |
|
| 168 | - ['libraries/@pnotify/mobile/dist/PNotifyMobile.css'], |
|
| 169 | - ['libraries/@pnotify/desktop/dist/PNotifyDesktop.css'], |
|
| 170 | - ['libraries/jquery-ui-dist/jquery-ui.css'], |
|
| 171 | - ['libraries/perfect-scrollbar/css/perfect-scrollbar.css'], |
|
| 172 | - ['layouts/resources/icons/additionalIcons.css'], |
|
| 173 | - ['layouts/resources/icons/yfm.css'], |
|
| 174 | - ['layouts/resources/icons/yfi.css'], |
|
| 175 | - ['layouts/' . \App\Viewer::getLayoutName() . '/skins/basic/Main.css'], |
|
| 143 | + /** |
|
| 144 | + * Retrieves css styles that need to loaded in the page. |
|
| 145 | + * |
|
| 146 | + * @return \App\Script[] |
|
| 147 | + */ |
|
| 148 | + public function getHeaderCss(): array |
|
| 149 | + { |
|
| 150 | + return $this->convertScripts([ |
|
| 151 | + ['libraries/@fortawesome/fontawesome-free/css/all.css'], |
|
| 152 | + ['libraries/@mdi/font/css/materialdesignicons.css'], |
|
| 153 | + ['libraries/chosen-js/chosen.css'], |
|
| 154 | + ['libraries/bootstrap-chosen/bootstrap-chosen.css'], |
|
| 155 | + ['libraries/jQuery-Validation-Engine/css/validationEngine.jquery.css'], |
|
| 156 | + ['libraries/bootstrap-tabdrop/css/tabdrop.css'], |
|
| 157 | + ['libraries/select2/dist/css/select2.css'], |
|
| 158 | + ['libraries/datatables.net-bs4/css/dataTables.bootstrap4.css'], |
|
| 159 | + ['libraries/datatables.net-responsive-bs4/css/responsive.bootstrap4.css'], |
|
| 160 | + ['libraries/bootstrap-datepicker/dist/css/bootstrap-datepicker3.css'], |
|
| 161 | + ['libraries/bootstrap-daterangepicker/daterangepicker.css'], |
|
| 162 | + ['libraries/clockpicker/dist/bootstrap4-clockpicker.css'], |
|
| 163 | + ['libraries/jstree-bootstrap-theme/dist/themes/proton/style.css'], |
|
| 164 | + ['libraries/jstree/dist/themes/default/style.css'], |
|
| 165 | + ['libraries/@pnotify/core/dist/PNotify.css'], |
|
| 166 | + ['libraries/@pnotify/confirm/dist/PNotifyConfirm.css'], |
|
| 167 | + ['libraries/@pnotify/bootstrap4/dist/PNotifyBootstrap4.css'], |
|
| 168 | + ['libraries/@pnotify/mobile/dist/PNotifyMobile.css'], |
|
| 169 | + ['libraries/@pnotify/desktop/dist/PNotifyDesktop.css'], |
|
| 170 | + ['libraries/jquery-ui-dist/jquery-ui.css'], |
|
| 171 | + ['libraries/perfect-scrollbar/css/perfect-scrollbar.css'], |
|
| 172 | + ['layouts/resources/icons/additionalIcons.css'], |
|
| 173 | + ['layouts/resources/icons/yfm.css'], |
|
| 174 | + ['layouts/resources/icons/yfi.css'], |
|
| 175 | + ['layouts/' . \App\Viewer::getLayoutName() . '/skins/basic/Main.css'], |
|
| 176 | 176 | ['layouts/Custom.css', true], |
| 177 | - ], 'css'); |
|
| 178 | - } |
|
| 177 | + ], 'css'); |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - /** |
|
| 181 | - * Pre process display. |
|
| 182 | - * |
|
| 183 | - * @return void |
|
| 184 | - */ |
|
| 185 | - protected function preProcessDisplay(): void |
|
| 186 | - { |
|
| 187 | - if (\App\Session::has('systemError')) { |
|
| 188 | - $this->viewer->assign('ERRORS', \App\Session::get('systemError')); |
|
| 189 | - \App\Session::unset('systemError'); |
|
| 190 | - } |
|
| 191 | - $this->viewer->view($this->preProcessTplName(), $this->moduleName); |
|
| 192 | - } |
|
| 180 | + /** |
|
| 181 | + * Pre process display. |
|
| 182 | + * |
|
| 183 | + * @return void |
|
| 184 | + */ |
|
| 185 | + protected function preProcessDisplay(): void |
|
| 186 | + { |
|
| 187 | + if (\App\Session::has('systemError')) { |
|
| 188 | + $this->viewer->assign('ERRORS', \App\Session::get('systemError')); |
|
| 189 | + \App\Session::unset('systemError'); |
|
| 190 | + } |
|
| 191 | + $this->viewer->view($this->preProcessTplName(), $this->moduleName); |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | - /** |
|
| 195 | - * Get preprocess tpl name. |
|
| 196 | - * |
|
| 197 | - * @return string |
|
| 198 | - */ |
|
| 199 | - protected function preProcessTplName(): string |
|
| 200 | - { |
|
| 201 | - return 'Header.tpl'; |
|
| 202 | - } |
|
| 194 | + /** |
|
| 195 | + * Get preprocess tpl name. |
|
| 196 | + * |
|
| 197 | + * @return string |
|
| 198 | + */ |
|
| 199 | + protected function preProcessTplName(): string |
|
| 200 | + { |
|
| 201 | + return 'Header.tpl'; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - /** |
|
| 205 | - * Get process tpl name. |
|
| 206 | - * |
|
| 207 | - * @return string |
|
| 208 | - */ |
|
| 209 | - protected function processTplName(): string |
|
| 210 | - { |
|
| 211 | - return $this->request->getAction() . '/Index.tpl'; |
|
| 212 | - } |
|
| 204 | + /** |
|
| 205 | + * Get process tpl name. |
|
| 206 | + * |
|
| 207 | + * @return string |
|
| 208 | + */ |
|
| 209 | + protected function processTplName(): string |
|
| 210 | + { |
|
| 211 | + return $this->request->getAction() . '/Index.tpl'; |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - /** {@inheritdoc} */ |
|
| 215 | - protected function postProcessTplName(): string |
|
| 216 | - { |
|
| 217 | - return 'Footer.tpl'; |
|
| 218 | - } |
|
| 214 | + /** {@inheritdoc} */ |
|
| 215 | + protected function postProcessTplName(): string |
|
| 216 | + { |
|
| 217 | + return 'Footer.tpl'; |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | - /** {@inheritdoc} */ |
|
| 221 | - public function postProcess(): void |
|
| 222 | - { |
|
| 223 | - if (null === $this->viewer->getTemplateVars('SHOW_FOOTER_BAR')) { |
|
| 224 | - $this->viewer->assign('SHOW_FOOTER_BAR', true); |
|
| 225 | - } |
|
| 226 | - $this->viewer->assign('JS_FILE', $this->getFooterScripts()); |
|
| 227 | - if (\App\Config::$debugApi && \App\Session::has('debugApi') && \App\Session::get('debugApi')) { |
|
| 228 | - $this->viewer->assign('DEBUG_API', \App\Session::get('debugApi')); |
|
| 229 | - $this->viewer->view('DebugApi.tpl', $this->moduleName); |
|
| 230 | - \App\Session::set('debugApi', false); |
|
| 231 | - } |
|
| 232 | - $this->viewer->view($this->postProcessTplName(), $this->moduleName); |
|
| 233 | - } |
|
| 220 | + /** {@inheritdoc} */ |
|
| 221 | + public function postProcess(): void |
|
| 222 | + { |
|
| 223 | + if (null === $this->viewer->getTemplateVars('SHOW_FOOTER_BAR')) { |
|
| 224 | + $this->viewer->assign('SHOW_FOOTER_BAR', true); |
|
| 225 | + } |
|
| 226 | + $this->viewer->assign('JS_FILE', $this->getFooterScripts()); |
|
| 227 | + if (\App\Config::$debugApi && \App\Session::has('debugApi') && \App\Session::get('debugApi')) { |
|
| 228 | + $this->viewer->assign('DEBUG_API', \App\Session::get('debugApi')); |
|
| 229 | + $this->viewer->view('DebugApi.tpl', $this->moduleName); |
|
| 230 | + \App\Session::set('debugApi', false); |
|
| 231 | + } |
|
| 232 | + $this->viewer->view($this->postProcessTplName(), $this->moduleName); |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - /** |
|
| 236 | - * Scripts. |
|
| 237 | - * |
|
| 238 | - * @param bool $loadForModule |
|
| 239 | - * |
|
| 240 | - * @return \App\Script[] |
|
| 241 | - */ |
|
| 242 | - public function getFooterScripts(bool $loadForModule = true): array |
|
| 243 | - { |
|
| 244 | - $action = $this->request->getAction(); |
|
| 245 | - $languageHandlerShortName = \App\Language::getShortLanguageName(); |
|
| 246 | - $fileName = ["libraries/jQuery-Validation-Engine/js/languages/jquery.validationEngine-$languageHandlerShortName.js"]; |
|
| 247 | - if (!file_exists(ROOT_DIRECTORY . "/public_html/{$fileName[0]}")) { |
|
| 248 | - $fileName = ['libraries/jQuery-Validation-Engine/js/languages/jquery.validationEngine-en.js']; |
|
| 249 | - } |
|
| 250 | - $files = [ |
|
| 251 | - ['libraries/jquery/dist/jquery.js'], |
|
| 252 | - ['libraries/jquery.class.js/jquery.class.js'], |
|
| 253 | - ['libraries/block-ui/jquery.blockUI.js'], |
|
| 254 | - ['libraries/@pnotify/core/dist/PNotify.js'], |
|
| 255 | - ['libraries/@pnotify/mobile/dist/PNotifyMobile.js'], |
|
| 256 | - ['libraries/@pnotify/desktop/dist/PNotifyDesktop.js'], |
|
| 257 | - ['libraries/@pnotify/confirm/dist/PNotifyConfirm.js'], |
|
| 258 | - ['libraries/@pnotify/bootstrap4/dist/PNotifyBootstrap4.js'], |
|
| 259 | - ['libraries/@pnotify/font-awesome5/dist/PNotifyFontAwesome5.js'], |
|
| 260 | - ['libraries/perfect-scrollbar/dist/perfect-scrollbar.js'], |
|
| 261 | - ['libraries/jquery-ui-dist/jquery-ui.js'], |
|
| 262 | - ['libraries/popper.js/dist/umd/popper.js'], |
|
| 263 | - ['vendor/ckeditor/ckeditor/ckeditor.js'], |
|
| 264 | - ['vendor/ckeditor/ckeditor/adapters/jquery.js'], |
|
| 265 | - ['libraries/bootstrap/dist/js/bootstrap.js'], |
|
| 266 | - ['libraries/bootstrap-tabdrop/js/bootstrap-tabdrop.js'], |
|
| 267 | - ['libraries/bootstrap-datepicker/dist/js/bootstrap-datepicker.js'], |
|
| 268 | - ['libraries/moment/min/moment.min.js'], |
|
| 269 | - ['libraries/bootstrap-daterangepicker/daterangepicker.js'], |
|
| 270 | - ['libraries/chosen-js/chosen.jquery.js'], |
|
| 271 | - ['libraries/select2/dist/js/select2.full.js'], |
|
| 272 | - ['libraries/inputmask/dist/jquery.inputmask.js'], |
|
| 273 | - ['libraries/datatables.net/js/jquery.dataTables.js'], |
|
| 274 | - ['libraries/datatables.net-bs4/js/dataTables.bootstrap4.js'], |
|
| 275 | - ['libraries/datatables.net-responsive/js/dataTables.responsive.js'], |
|
| 276 | - ['libraries/datatables.net-responsive-bs4/js/responsive.bootstrap4.js'], |
|
| 277 | - ['libraries/jQuery-Validation-Engine/js/jquery.validationEngine.js'], |
|
| 278 | - $fileName, |
|
| 279 | - ['libraries/jstree/dist/jstree.js'], |
|
| 280 | - ['libraries/clockpicker/dist/bootstrap4-clockpicker.js'], |
|
| 281 | - ['libraries/blueimp-file-upload/js/jquery.fileupload.js'], |
|
| 282 | - ['layouts/resources/validator/BaseValidator.js'], |
|
| 283 | - ['layouts/resources/validator/FieldValidator.js'], |
|
| 284 | - ['layouts/resources/helper.js'], |
|
| 285 | - ['layouts/resources/Field.js'], |
|
| 286 | - ['layouts/resources/Connector.js'], |
|
| 287 | - ['layouts/resources/app.js'], |
|
| 288 | - ['layouts/resources/MultiImage.js'], |
|
| 289 | - ['layouts/resources/Fields.js'], |
|
| 290 | - ['layouts/resources/ProgressIndicator.js'], |
|
| 291 | - ['layouts/' . \App\Viewer::getLayoutName() . '/modules/Base/resources/Header.js'], |
|
| 292 | - ['layouts/' . \App\Viewer::getLayoutName() . "/modules/Base/resources/{$action}.js"], |
|
| 293 | - ]; |
|
| 294 | - if ($loadForModule) { |
|
| 295 | - $moduleName = $this->getModuleNameFromRequest(); |
|
| 296 | - $files[] = ['layouts/' . \App\Viewer::getLayoutName() . "/modules/{$moduleName}/resources/{$action}.js", true]; |
|
| 297 | - } |
|
| 298 | - return $this->convertScripts($files, 'js'); |
|
| 299 | - } |
|
| 235 | + /** |
|
| 236 | + * Scripts. |
|
| 237 | + * |
|
| 238 | + * @param bool $loadForModule |
|
| 239 | + * |
|
| 240 | + * @return \App\Script[] |
|
| 241 | + */ |
|
| 242 | + public function getFooterScripts(bool $loadForModule = true): array |
|
| 243 | + { |
|
| 244 | + $action = $this->request->getAction(); |
|
| 245 | + $languageHandlerShortName = \App\Language::getShortLanguageName(); |
|
| 246 | + $fileName = ["libraries/jQuery-Validation-Engine/js/languages/jquery.validationEngine-$languageHandlerShortName.js"]; |
|
| 247 | + if (!file_exists(ROOT_DIRECTORY . "/public_html/{$fileName[0]}")) { |
|
| 248 | + $fileName = ['libraries/jQuery-Validation-Engine/js/languages/jquery.validationEngine-en.js']; |
|
| 249 | + } |
|
| 250 | + $files = [ |
|
| 251 | + ['libraries/jquery/dist/jquery.js'], |
|
| 252 | + ['libraries/jquery.class.js/jquery.class.js'], |
|
| 253 | + ['libraries/block-ui/jquery.blockUI.js'], |
|
| 254 | + ['libraries/@pnotify/core/dist/PNotify.js'], |
|
| 255 | + ['libraries/@pnotify/mobile/dist/PNotifyMobile.js'], |
|
| 256 | + ['libraries/@pnotify/desktop/dist/PNotifyDesktop.js'], |
|
| 257 | + ['libraries/@pnotify/confirm/dist/PNotifyConfirm.js'], |
|
| 258 | + ['libraries/@pnotify/bootstrap4/dist/PNotifyBootstrap4.js'], |
|
| 259 | + ['libraries/@pnotify/font-awesome5/dist/PNotifyFontAwesome5.js'], |
|
| 260 | + ['libraries/perfect-scrollbar/dist/perfect-scrollbar.js'], |
|
| 261 | + ['libraries/jquery-ui-dist/jquery-ui.js'], |
|
| 262 | + ['libraries/popper.js/dist/umd/popper.js'], |
|
| 263 | + ['vendor/ckeditor/ckeditor/ckeditor.js'], |
|
| 264 | + ['vendor/ckeditor/ckeditor/adapters/jquery.js'], |
|
| 265 | + ['libraries/bootstrap/dist/js/bootstrap.js'], |
|
| 266 | + ['libraries/bootstrap-tabdrop/js/bootstrap-tabdrop.js'], |
|
| 267 | + ['libraries/bootstrap-datepicker/dist/js/bootstrap-datepicker.js'], |
|
| 268 | + ['libraries/moment/min/moment.min.js'], |
|
| 269 | + ['libraries/bootstrap-daterangepicker/daterangepicker.js'], |
|
| 270 | + ['libraries/chosen-js/chosen.jquery.js'], |
|
| 271 | + ['libraries/select2/dist/js/select2.full.js'], |
|
| 272 | + ['libraries/inputmask/dist/jquery.inputmask.js'], |
|
| 273 | + ['libraries/datatables.net/js/jquery.dataTables.js'], |
|
| 274 | + ['libraries/datatables.net-bs4/js/dataTables.bootstrap4.js'], |
|
| 275 | + ['libraries/datatables.net-responsive/js/dataTables.responsive.js'], |
|
| 276 | + ['libraries/datatables.net-responsive-bs4/js/responsive.bootstrap4.js'], |
|
| 277 | + ['libraries/jQuery-Validation-Engine/js/jquery.validationEngine.js'], |
|
| 278 | + $fileName, |
|
| 279 | + ['libraries/jstree/dist/jstree.js'], |
|
| 280 | + ['libraries/clockpicker/dist/bootstrap4-clockpicker.js'], |
|
| 281 | + ['libraries/blueimp-file-upload/js/jquery.fileupload.js'], |
|
| 282 | + ['layouts/resources/validator/BaseValidator.js'], |
|
| 283 | + ['layouts/resources/validator/FieldValidator.js'], |
|
| 284 | + ['layouts/resources/helper.js'], |
|
| 285 | + ['layouts/resources/Field.js'], |
|
| 286 | + ['layouts/resources/Connector.js'], |
|
| 287 | + ['layouts/resources/app.js'], |
|
| 288 | + ['layouts/resources/MultiImage.js'], |
|
| 289 | + ['layouts/resources/Fields.js'], |
|
| 290 | + ['layouts/resources/ProgressIndicator.js'], |
|
| 291 | + ['layouts/' . \App\Viewer::getLayoutName() . '/modules/Base/resources/Header.js'], |
|
| 292 | + ['layouts/' . \App\Viewer::getLayoutName() . "/modules/Base/resources/{$action}.js"], |
|
| 293 | + ]; |
|
| 294 | + if ($loadForModule) { |
|
| 295 | + $moduleName = $this->getModuleNameFromRequest(); |
|
| 296 | + $files[] = ['layouts/' . \App\Viewer::getLayoutName() . "/modules/{$moduleName}/resources/{$action}.js", true]; |
|
| 297 | + } |
|
| 298 | + return $this->convertScripts($files, 'js'); |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - /** {@inheritdoc} */ |
|
| 302 | - public function validateRequest() |
|
| 303 | - { |
|
| 304 | - $this->request->validateReadAccess(); |
|
| 305 | - } |
|
| 301 | + /** {@inheritdoc} */ |
|
| 302 | + public function validateRequest() |
|
| 303 | + { |
|
| 304 | + $this->request->validateReadAccess(); |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | - /** {@inheritdoc} */ |
|
| 308 | - public function postProcessAjax() |
|
| 309 | - { |
|
| 310 | - } |
|
| 307 | + /** {@inheritdoc} */ |
|
| 308 | + public function postProcessAjax() |
|
| 309 | + { |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | - /** {@inheritdoc} */ |
|
| 313 | - public function preProcessAjax() |
|
| 314 | - { |
|
| 315 | - } |
|
| 312 | + /** {@inheritdoc} */ |
|
| 313 | + public function preProcessAjax() |
|
| 314 | + { |
|
| 315 | + } |
|
| 316 | 316 | |
| 317 | - /** |
|
| 318 | - * Get module name from request. |
|
| 319 | - * |
|
| 320 | - * @return string |
|
| 321 | - */ |
|
| 322 | - protected function getModuleNameFromRequest(): string |
|
| 323 | - { |
|
| 324 | - if (empty($this->moduleName)) { |
|
| 325 | - $this->moduleName = $this->request->getModule(); |
|
| 326 | - } |
|
| 327 | - return $this->moduleName; |
|
| 328 | - } |
|
| 317 | + /** |
|
| 318 | + * Get module name from request. |
|
| 319 | + * |
|
| 320 | + * @return string |
|
| 321 | + */ |
|
| 322 | + protected function getModuleNameFromRequest(): string |
|
| 323 | + { |
|
| 324 | + if (empty($this->moduleName)) { |
|
| 325 | + $this->moduleName = $this->request->getModule(); |
|
| 326 | + } |
|
| 327 | + return $this->moduleName; |
|
| 328 | + } |
|
| 329 | 329 | |
| 330 | - /** |
|
| 331 | - * Load js config. |
|
| 332 | - * |
|
| 333 | - * @param \App\Request $request |
|
| 334 | - */ |
|
| 335 | - public function loadJsConfig(\App\Request $request): void |
|
| 336 | - { |
|
| 337 | - $jsEnv = [ |
|
| 338 | - 'siteUrl' => \App\Utils::getPublicUrl('', true), |
|
| 339 | - 'langPrefix' => \App\Language::getLanguage(), |
|
| 340 | - 'langKey' => \App\Language::getShortLanguageName(), |
|
| 341 | - 'parentModule' => $request->getByType('parent', 2), |
|
| 342 | - ]; |
|
| 343 | - foreach ($jsEnv as $key => $value) { |
|
| 344 | - \App\Config::setJsEnv($key, $value); |
|
| 345 | - } |
|
| 346 | - } |
|
| 330 | + /** |
|
| 331 | + * Load js config. |
|
| 332 | + * |
|
| 333 | + * @param \App\Request $request |
|
| 334 | + */ |
|
| 335 | + public function loadJsConfig(\App\Request $request): void |
|
| 336 | + { |
|
| 337 | + $jsEnv = [ |
|
| 338 | + 'siteUrl' => \App\Utils::getPublicUrl('', true), |
|
| 339 | + 'langPrefix' => \App\Language::getLanguage(), |
|
| 340 | + 'langKey' => \App\Language::getShortLanguageName(), |
|
| 341 | + 'parentModule' => $request->getByType('parent', 2), |
|
| 342 | + ]; |
|
| 343 | + foreach ($jsEnv as $key => $value) { |
|
| 344 | + \App\Config::setJsEnv($key, $value); |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | 347 | |
| 348 | - /** |
|
| 349 | - * Get the list of user quick menu links. |
|
| 350 | - * |
|
| 351 | - * @return array |
|
| 352 | - */ |
|
| 353 | - protected function getUserQuickMenuLinks(): array |
|
| 354 | - { |
|
| 355 | - $user = \App\User::getUser(); |
|
| 356 | - $links = [ |
|
| 357 | - [ |
|
| 358 | - 'label' => 'LBL_CHANGE_PASSWORD', |
|
| 359 | - 'moduleName' => 'Users', |
|
| 360 | - 'data' => ['url' => 'index.php?module=Users&view=PasswordChangeModal'], |
|
| 361 | - 'icon' => 'yfi yfi-change-passowrd', |
|
| 362 | - 'class' => 'text-decoration-none u-fs-sm text-secondary js-show-modal d-block', |
|
| 363 | - 'btnClass' => ' ', |
|
| 364 | - 'href' => '#', |
|
| 365 | - 'showLabel' => true, |
|
| 366 | - ], |
|
| 367 | - [ |
|
| 368 | - 'label' => 'BTN_YOUR_ACCOUNT_ACCESS_HISTORY', |
|
| 369 | - 'moduleName' => 'Users', |
|
| 370 | - 'data' => ['url' => 'index.php?module=Users&view=AccessActivityHistoryModal'], |
|
| 371 | - 'icon' => 'yfi yfi-login-history', |
|
| 372 | - 'class' => 'text-decoration-none u-fs-sm text-secondary js-show-modal d-block', |
|
| 373 | - 'btnClass' => ' ', |
|
| 374 | - 'href' => '#', |
|
| 375 | - 'showLabel' => true, |
|
| 376 | - ], |
|
| 377 | - ]; |
|
| 378 | - if ('PLL_PASSWORD_2FA' === $user->get('login_method') && !$user->isEmpty('authy_methods')) { |
|
| 379 | - $links[] = [ |
|
| 380 | - 'label' => 'BTN_2FA_TOTP_QR_CODE', |
|
| 381 | - 'moduleName' => 'Users', |
|
| 382 | - 'data' => ['url' => 'index.php?module=Users&view=TwoFactorAuthenticationModal'], |
|
| 383 | - 'icon' => 'fas fa-key', |
|
| 384 | - 'class' => 'text-decoration-none u-fs-sm text-secondary js-show-modal d-block', |
|
| 385 | - 'btnClass' => ' ', |
|
| 386 | - 'href' => '#', |
|
| 387 | - 'showLabel' => true, |
|
| 388 | - ]; |
|
| 389 | - } |
|
| 390 | - return $links; |
|
| 391 | - } |
|
| 348 | + /** |
|
| 349 | + * Get the list of user quick menu links. |
|
| 350 | + * |
|
| 351 | + * @return array |
|
| 352 | + */ |
|
| 353 | + protected function getUserQuickMenuLinks(): array |
|
| 354 | + { |
|
| 355 | + $user = \App\User::getUser(); |
|
| 356 | + $links = [ |
|
| 357 | + [ |
|
| 358 | + 'label' => 'LBL_CHANGE_PASSWORD', |
|
| 359 | + 'moduleName' => 'Users', |
|
| 360 | + 'data' => ['url' => 'index.php?module=Users&view=PasswordChangeModal'], |
|
| 361 | + 'icon' => 'yfi yfi-change-passowrd', |
|
| 362 | + 'class' => 'text-decoration-none u-fs-sm text-secondary js-show-modal d-block', |
|
| 363 | + 'btnClass' => ' ', |
|
| 364 | + 'href' => '#', |
|
| 365 | + 'showLabel' => true, |
|
| 366 | + ], |
|
| 367 | + [ |
|
| 368 | + 'label' => 'BTN_YOUR_ACCOUNT_ACCESS_HISTORY', |
|
| 369 | + 'moduleName' => 'Users', |
|
| 370 | + 'data' => ['url' => 'index.php?module=Users&view=AccessActivityHistoryModal'], |
|
| 371 | + 'icon' => 'yfi yfi-login-history', |
|
| 372 | + 'class' => 'text-decoration-none u-fs-sm text-secondary js-show-modal d-block', |
|
| 373 | + 'btnClass' => ' ', |
|
| 374 | + 'href' => '#', |
|
| 375 | + 'showLabel' => true, |
|
| 376 | + ], |
|
| 377 | + ]; |
|
| 378 | + if ('PLL_PASSWORD_2FA' === $user->get('login_method') && !$user->isEmpty('authy_methods')) { |
|
| 379 | + $links[] = [ |
|
| 380 | + 'label' => 'BTN_2FA_TOTP_QR_CODE', |
|
| 381 | + 'moduleName' => 'Users', |
|
| 382 | + 'data' => ['url' => 'index.php?module=Users&view=TwoFactorAuthenticationModal'], |
|
| 383 | + 'icon' => 'fas fa-key', |
|
| 384 | + 'class' => 'text-decoration-none u-fs-sm text-secondary js-show-modal d-block', |
|
| 385 | + 'btnClass' => ' ', |
|
| 386 | + 'href' => '#', |
|
| 387 | + 'showLabel' => true, |
|
| 388 | + ]; |
|
| 389 | + } |
|
| 390 | + return $links; |
|
| 391 | + } |
|
| 392 | 392 | } |