From fbf35fd43ad43096a62e2b0692f988cd6983b277 Mon Sep 17 00:00:00 2001 From: jcopado Date: Tue, 19 Sep 2023 15:57:12 +0200 Subject: [PATCH] 2.0.7 - dic::user errors --- classes/Participant/class.xdhtParticipant.php | 2 +- classes/Recommender/RecommenderCurl.php | 3 +- classes/Start/class.xdhtStartGUI.php | 30 +++++++++++-------- plugin.php | 2 +- .../MultiLineInputGUI/MultiLineInputGUI.php | 7 +++-- .../MultiSelectSearchInputGUI.php | 4 ++- .../MultiSelectSearchNewInputGUI.php | 4 ++- 7 files changed, 32 insertions(+), 20 deletions(-) diff --git a/classes/Participant/class.xdhtParticipant.php b/classes/Participant/class.xdhtParticipant.php index 66cd36a..d908b17 100644 --- a/classes/Participant/class.xdhtParticipant.php +++ b/classes/Participant/class.xdhtParticipant.php @@ -144,7 +144,7 @@ public function update() if ($this->hasStatusChanged()) { ilLPStatusWrapper::_updateStatus($this->training_obj_id, $this->usr_id); - ilChangeEvent::_recordReadEvent(ilDhbwTrainingPlugin::PLUGIN_PREFIX, intval(filter_input(INPUT_GET, 'ref_id')), $this->training_obj_id, self::dic()->user()->getId()); + ilChangeEvent::_recordReadEvent(ilDhbwTrainingPlugin::PLUGIN_PREFIX, intval(filter_input(INPUT_GET, 'ref_id')), $this->training_obj_id, $ilUser->getId()); } } diff --git a/classes/Recommender/RecommenderCurl.php b/classes/Recommender/RecommenderCurl.php index fd83440..1dfd9e1 100644 --- a/classes/Recommender/RecommenderCurl.php +++ b/classes/Recommender/RecommenderCurl.php @@ -74,11 +74,12 @@ public function start()/*:void*/ */ protected function getAnonymizedUserHash() : string { + global $ilUser; $alg = 'sha256'; // put new desired hashing algo here if (array_search($alg,hash_algos()) === false) { $alg = 'md5'; // Fallback to md5 if $alg not included in php } - return hash($alg,Config::getField(Config::KEY_SALT) . self::dic()->user()->getId()); + return hash($alg,Config::getField(Config::KEY_SALT) . $ilUser->getId()); } diff --git a/classes/Start/class.xdhtStartGUI.php b/classes/Start/class.xdhtStartGUI.php index 3336ac6..5a3a3ad 100644 --- a/classes/Start/class.xdhtStartGUI.php +++ b/classes/Start/class.xdhtStartGUI.php @@ -112,11 +112,12 @@ public function start() */ public function proceedWithReturnOfRecommender() { + global $ilUser; $output = ""; if ($this->facade->settings()->getLearningProgress() && $this->response->getLearningProgressStatus() !== null) { $this->facade->xdhtParticipantFactory()->updateStatus($this->facade->xdhtParticipantFactory() - ->findOrCreateParticipantByUsrAndTrainingObjectId(self::dic()->user() + ->findOrCreateParticipantByUsrAndTrainingObjectId($ilUser ->getId(), $this->facade->objectId()), $this->response->getLearningProgressStatus()); } @@ -127,10 +128,10 @@ public function proceedWithReturnOfRecommender() $set = $ilDB->query($sql); $row = $ilDB->fetchAssoc($set); - ilPersonalSkill::addPersonalSkill(self::dic()->user()->getId(), $competence_id); + ilPersonalSkill::addPersonalSkill($ilUser->getId(), $competence_id); ilBasicSkill::writeUserSkillLevelStatus( $row['id'], - self::dic()->user()->getId(), + $ilUser->getId(), $this->facade->refId(), $competence_id, ilBasicSkill::ACHIEVED, @@ -208,6 +209,8 @@ public function proceedWithReturnOfRecommender() */ protected function initAnsweredQuestionForm($question) : ilTemplate { + global $ilUser; + $tpl = new ilTemplate('tpl.questions_answered_form.html', true, true, 'Customizing/global/plugins/Services/Repository/RepositoryObject/DhbwTraining'); $tpl->setVariable("ACTION", self::dic()->ctrl()->getLinkTarget($this, self::CMD_SENDRATING)); $q_gui = assQuestionGUI::_getQuestionGUI("", $question['question_id']); @@ -217,14 +220,14 @@ protected function initAnsweredQuestionForm($question) : ilTemplate return $tpl; } - $previewSession = new ilAssQuestionPreviewSession(self::dic()->user()->getId(), $question['question_id']); + $previewSession = new ilAssQuestionPreviewSession($ilUser->getId(), $question['question_id']); $q_gui->setPreviewSession($previewSession); /** * shuffle like before */ $shuffler = new ilArrayElementShuffler(); - $shuffler->setSeed($q_gui->object->getId() + self::dic()->user()->getId()); + $shuffler->setSeed($q_gui->object->getId() + $ilUser->getId()); $q_gui->object->setShuffle(1); $q_gui->object->setShuffler($shuffler); @@ -260,6 +263,8 @@ protected function initAnsweredQuestionForm($question) : ilTemplate */ protected function initQuestionForm($question) : ilTemplate { + global $ilUser; + $tpl = new ilTemplate('tpl.questions_form.html', true, true, 'Customizing/global/plugins/Services/Repository/RepositoryObject/DhbwTraining'); $tpl->setVariable("ACTION", self::dic()->ctrl()->getLinkTarget($this, self::CMD_ANSWER)); @@ -271,7 +276,7 @@ protected function initQuestionForm($question) : ilTemplate return $tpl; } - $previewSession = new ilAssQuestionPreviewSession(self::dic()->user()->getId(), $question['question_id']); + $previewSession = new ilAssQuestionPreviewSession($ilUser->getId(), $question['question_id']); $previewSession->init(); $q_gui->setPreviewSession($previewSession); @@ -280,7 +285,7 @@ protected function initQuestionForm($question) : ilTemplate * Shuffle! */ $shuffler = new ilArrayElementShuffler(); - $shuffler->setSeed($q_gui->object->getId() + self::dic()->user()->getId()); + $shuffler->setSeed($q_gui->object->getId() + $ilUser->getId()); $q_gui->object->setShuffle(1); $q_gui->object->setShuffler($shuffler); @@ -406,8 +411,8 @@ public function answer() */ public function setAnsweredForPreviewSession($question) : bool { - - $previewSession = new ilAssQuestionPreviewSession(self::dic()->user()->getId(), $question['question_id']); + global $ilUser; + $previewSession = new ilAssQuestionPreviewSession($ilUser->getId(), $question['question_id']); $q_gui = assQuestionGUI::_getQuestionGUI("", $question['question_id']); if(is_object($q_gui )) { @@ -448,11 +453,12 @@ public function proceed() */ protected function renderCompetences()/*:void*/ { + self::dic()->ui()->mainTemplate()->setRightContent(self::output()->getHTML(self::dic()->ui()->factory()->listing()->descriptive(array_reduce(ilPersonalSkill::getSelectedUserSkills(self::dic() ->user() ->getId()), function (array $items, array $competence) : array { - - $level_id = ilPersonalSkill::getSelfEvaluation(self::dic()->user()->getId(), $competence["skill_node_id"], 0, $competence["skill_node_id"]); + global $ilUser; + $level_id = ilPersonalSkill::getSelfEvaluation($ilUser->getId(), $competence["skill_node_id"], 0, $competence["skill_node_id"]); if ($level_id === null) { return []; @@ -464,7 +470,7 @@ protected function renderCompetences()/*:void*/ return []; } - $items[$competence["title"]] = (new ilBasicSkill($competence["skill_node_id"]))->getLevelData(ilPersonalSkill::getSelfEvaluation(self::dic()->user()->getId(), $competence["skill_node_id"], + $items[$competence["title"]] = (new ilBasicSkill($competence["skill_node_id"]))->getLevelData(ilPersonalSkill::getSelfEvaluation($ilUser->getId(), $competence["skill_node_id"], 0, $competence["skill_node_id"]))["title"]; return $items; diff --git a/plugin.php b/plugin.php index 81c218c..ee47d39 100644 --- a/plugin.php +++ b/plugin.php @@ -3,7 +3,7 @@ require_once __DIR__ . "/vendor/srag/dic/src/PHPVersionChecker.php"; $id = "xdht"; -$version = "2.0.6"; +$version = "2.0.7"; $ilias_min_version = "6.0"; $ilias_max_version = "7.999"; $responsible = "fluxlabs ag"; diff --git a/vendor/srag/custominputguis/src/MultiLineInputGUI/MultiLineInputGUI.php b/vendor/srag/custominputguis/src/MultiLineInputGUI/MultiLineInputGUI.php index 65fd8c6..1b6b4db 100755 --- a/vendor/srag/custominputguis/src/MultiLineInputGUI/MultiLineInputGUI.php +++ b/vendor/srag/custominputguis/src/MultiLineInputGUI/MultiLineInputGUI.php @@ -399,10 +399,11 @@ public function initCSSandJS()/*: void*/ */ public function insert(ilTemplate $tpl)/*: void*/ { + global $ilUser; $options = [ // Services/Calendar/classes/class.ilCalendarUtil.php::addDateTimePicker "date_config" => [ - 'locale' => self::dic()->user()->getLanguage(), + 'locale' => $ilUser->getLanguage(), 'stepping' => 5, 'useCurrent' => false, 'calendarWeeks' => true, @@ -413,8 +414,8 @@ public function insert(ilTemplate $tpl)/*: void*/ 'keepInvalid' => true, 'sideBySide' => true, //'collapse' => false, - 'format' => !empty(self::dic()->user()->getId()) - && intval(self::dic()->user()->getId()) !== ANONYMOUS_USER_ID ? ilCalendarUtil::getUserDateFormat(false) : "DD.MM.YYYY" + 'format' => !empty($ilUser->getId()) + && intval($ilUser->getId()) !== ANONYMOUS_USER_ID ? ilCalendarUtil::getUserDateFormat(false) : "DD.MM.YYYY" ] ]; diff --git a/vendor/srag/custominputguis/src/MultiSelectSearchInputGUI/MultiSelectSearchInputGUI.php b/vendor/srag/custominputguis/src/MultiSelectSearchInputGUI/MultiSelectSearchInputGUI.php index 8516116..15b015d 100644 --- a/vendor/srag/custominputguis/src/MultiSelectSearchInputGUI/MultiSelectSearchInputGUI.php +++ b/vendor/srag/custominputguis/src/MultiSelectSearchInputGUI/MultiSelectSearchInputGUI.php @@ -70,6 +70,8 @@ class MultiSelectSearchInputGUI extends ilMultiSelectInputGUI implements ilTable */ public function __construct(string $title = "", string $post_var = "") { + global $ilUser; + if (substr($post_var, -2) != "[]") { $post_var = $post_var . "[]"; } @@ -79,7 +81,7 @@ public function __construct(string $title = "", string $post_var = "") $dir = "./" . substr($dir, strpos($dir, "/Customizing/") + 1); self::dic()->ui()->mainTemplate()->addJavaScript($dir . "/../../node_modules/select2/dist/js/select2.full.min.js"); - self::dic()->ui()->mainTemplate()->addJavaScript($dir . "/../../node_modules/select2/dist/js/i18n/" . self::dic()->user()->getCurrentLanguage() + self::dic()->ui()->mainTemplate()->addJavaScript($dir . "/../../node_modules/select2/dist/js/i18n/" . $ilUser->getCurrentLanguage() . ".js"); self::dic()->ui()->mainTemplate()->addCss($dir . "/../../node_modules/select2/dist/css/select2.min.css"); self::dic()->ui()->mainTemplate()->addCss($dir . "/css/multiselectsearchinputgui.css"); diff --git a/vendor/srag/custominputguis/src/MultiSelectSearchNewInputGUI/MultiSelectSearchNewInputGUI.php b/vendor/srag/custominputguis/src/MultiSelectSearchNewInputGUI/MultiSelectSearchNewInputGUI.php index 55fcc08..785e946 100644 --- a/vendor/srag/custominputguis/src/MultiSelectSearchNewInputGUI/MultiSelectSearchNewInputGUI.php +++ b/vendor/srag/custominputguis/src/MultiSelectSearchNewInputGUI/MultiSelectSearchNewInputGUI.php @@ -91,13 +91,15 @@ public static function init(/*?*/ PluginInterface $plugin = null)/*: void*/ $dir = __DIR__; $dir = "./" . substr($dir, strpos($dir, "/Customizing/") + 1); + global $ilUser; + self::dic()->ui()->mainTemplate()->addCss($version_parameter->appendToUrl($dir . "/../../node_modules/select2/dist/css/select2.min.css")); self::dic()->ui()->mainTemplate()->addCss($version_parameter->appendToUrl($dir . "/css/multi_select_search_new_input_gui.css")); self::dic()->ui()->mainTemplate()->addJavaScript($version_parameter->appendToUrl($dir . "/../../node_modules/select2/dist/js/select2.full.min.js")); - self::dic()->ui()->mainTemplate()->addJavaScript($version_parameter->appendToUrl($dir . "/../../node_modules/select2/dist/js/i18n/" . self::dic()->user()->getCurrentLanguage() + self::dic()->ui()->mainTemplate()->addJavaScript($version_parameter->appendToUrl($dir . "/../../node_modules/select2/dist/js/i18n/" . $ilUser->getCurrentLanguage() . ".js")); } }