diff --git a/app/controllers/profilemodules.php b/app/controllers/profilemodules.php index 8f87073e7c763086e911f716bbedf5c27b39d2e7..9e558faca127a3c6f1687f195f100158aacd5b3f 100644 --- a/app/controllers/profilemodules.php +++ b/app/controllers/profilemodules.php @@ -254,7 +254,7 @@ class ProfileModulesController extends AuthenticatedController $state = (bool) $state; if ($state != $manager->isPluginActivatedForUser($item, $this->user->id) - && $manager->setPluginActivated($item, $this->user->id, $state, 'user')) + && $manager->setPluginActivatedForUser($item, $this->user->id, $state)) { return [$state, $this->plugins[$item]->getPluginName()]; } diff --git a/lib/navigation/ProfileNavigation.php b/lib/navigation/ProfileNavigation.php index c8d372eff8da8e04e240a22efdc1912318853c31..7a17683f9018843d54c95c90feb2d9d418e2ab5c 100644 --- a/lib/navigation/ProfileNavigation.php +++ b/lib/navigation/ProfileNavigation.php @@ -125,7 +125,7 @@ class ProfileNavigation extends Navigation // Add consultations if appropriate if (Config::get()->CONSULTATION_ENABLED) { $plugin = PluginEngine::getPlugin('ConsultationModule'); - if ($current_user && $plugin && $plugin->isActivated($current_user->id, 'user')) { + if ($current_user && $plugin && PluginManager::getInstance()->isPluginActivatedForUser($plugin->getPluginId(), $current_user->id)) { $this->addSubNavigation('consultation', new ConsultationNavigation($current_user)); } } diff --git a/lib/plugins/engine/PluginManager.class.php b/lib/plugins/engine/PluginManager.class.php index cd14841b2195ec2b9d4d30143d100e29a7faf059..13973592e0b4c83031249f5e17bbfb71facee4dc 100644 --- a/lib/plugins/engine/PluginManager.class.php +++ b/lib/plugins/engine/PluginManager.class.php @@ -244,9 +244,9 @@ class PluginManager /** * Sets the activation status of a plugin in the given context. * - * @param $id id of the plugin - * @param $rangeId context range id - * @param $active plugin status (true or false) + * @param $id string id of the plugin + * @param $rangeId string context range id + * @param $active bool plugin status (true or false) */ public function setPluginActivated ($id, $rangeId, $active) { @@ -269,6 +269,23 @@ class PluginManager } } + /** + * Sets the activation status of a plugin in the given context. + * + * @param $pluginid string of the plugin + * @param $user_id string user id + * @param $active bool plugin status (true or false) + */ + public function setPluginActivatedForUser($pluginid, $user_id, $active) + { + $db = DBManager::get(); + $state = $active ? 1 : 0; + unset($this->plugins_activated_cache[$user_id]); + + return $db->execute("REPLACE INTO plugins_activated (pluginid, range_type, range_id, state) + VALUES (?, 'user', ?, ?)", [$pluginid, $user_id, $state]); + } + /** * Deactivate all plugins for the given range. *