88use GlpiPlugin \Wikitsemanticschat \Config ;
99use GlpiPlugin \Wikitsemanticschat \Profile ;
1010
11- define ('PLUGIN_WIKITSEMANTICSCHAT_VERSION ' , '1.0.0 ' );
11+ define ('PLUGIN_WIKITSEMANTICSCHAT_VERSION ' , '1.0.1 ' );
1212// Minimal GLPI version, inclusive
1313define ('PLUGIN_WIKITSEMANTICSCHAT_MIN_GLPI_VERSION ' , '10.0.0 ' );
1414// Maximum GLPI version, exclusive
@@ -33,25 +33,26 @@ function plugin_init_wikitsemanticschat(): void {
3333 return ;
3434 }
3535
36- // Add JavaScript on all pages for logged-in users only
36+ // Register plugin classes (always needed for profile management)
3737 if (Session::getLoginUserID ()) {
38- // Load plugin configuration and main script
39- $ PLUGIN_HOOKS [Hooks::ADD_JAVASCRIPT ]['wikitsemanticschat ' ] = [
40- 'public/js/config.js.php ' ,
41- 'public/js/wikitsemanticschat.js '
42- ];
43-
44- // Register plugin classes
4538 Plugin::registerClass (Config::class);
4639 Plugin::registerClass (
4740 Profile::class,
4841 ['addtabon ' => 'Profile ' ]
4942 );
5043
5144 // Configuration page in Setup > Plugins
52- if (Session::haveRight ('config ' , UPDATE )) {
53- $ PLUGIN_HOOKS ['config_page ' ]['wikitsemanticschat ' ] = 'front/config.form.php ' ;
54- }
45+ if (Session::haveRight ('config ' , UPDATE )) {
46+ $ PLUGIN_HOOKS ['config_page ' ]['wikitsemanticschat ' ] = 'front/config.form.php ' ;
47+ }
48+
49+ // Add JavaScript only for users with READ right
50+ if (Session::haveRight ('plugin_wikitsemanticschat_config ' , READ )) {
51+ $ PLUGIN_HOOKS [Hooks::ADD_JAVASCRIPT ]['wikitsemanticschat ' ] = [
52+ 'public/js/config.js.php ' ,
53+ 'public/js/wikitsemanticschat.js '
54+ ];
55+ }
5556 }
5657}
5758
0 commit comments