Skip to content

Commit

Permalink
fix: loading resources for anonymous forms
Browse files Browse the repository at this point in the history
if no GLPI cookie is set then JS may not load

fix #1535

Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Oct 15, 2019
1 parent 023a60e commit 58b7141
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,19 +196,6 @@ function plugin_init_formcreator() {
];
}

// Load JS and CSS files if we are on a page which need them
if (strpos($_SERVER['REQUEST_URI'], 'plugins/formcreator') !== false
|| strpos($_SERVER['REQUEST_URI'], 'central.php') !== false
|| isset($_SESSION['glpiactiveprofile']) &&
$_SESSION['glpiactiveprofile']['interface'] == 'helpdesk') {

$PLUGIN_HOOKS['add_css']['formcreator'][] = 'lib/pqselect/pqselect.min.css';
$PLUGIN_HOOKS['add_javascript']['formcreator'][] = 'lib/pqselect/pqselect.min.js';

// Add specific JavaScript
$PLUGIN_HOOKS['add_javascript']['formcreator'][] = 'js/scripts.js.php';
}

if (strpos($_SERVER['REQUEST_URI'], 'plugins/formcreator/front/targetticket.form.php') !== false) {
if (version_compare(PluginFormcreatorCommon::getGlpiVersion(), 9.4) >= 0 || $CFG_GLPI['use_rich_text']) {
Html::requireJs('tinymce');
Expand All @@ -234,6 +221,19 @@ function plugin_init_formcreator() {

Plugin::registerClass(PluginFormcreatorEntityconfig::class, ['addtabon' => Entity::class]);
}

// Load JS and CSS files if we are on a page which need them
if (strpos($_SERVER['REQUEST_URI'], 'plugins/formcreator') !== false
|| strpos($_SERVER['REQUEST_URI'], 'central.php') !== false
|| isset($_SESSION['glpiactiveprofile']) &&
$_SESSION['glpiactiveprofile']['interface'] == 'helpdesk') {

$PLUGIN_HOOKS['add_css']['formcreator'][] = 'lib/pqselect/pqselect.min.css';
$PLUGIN_HOOKS['add_javascript']['formcreator'][] = 'lib/pqselect/pqselect.min.js';

// Add specific JavaScript
$PLUGIN_HOOKS['add_javascript']['formcreator'][] = 'js/scripts.js.php';
}
}
}

Expand Down

0 comments on commit 58b7141

Please sign in to comment.