Skip to content
Snippets Groups Projects
Commit 4432ec04 authored by André Noack's avatar André Noack Committed by Jan-Hendrik Willms
Browse files

closes #37

parent 4deaf4e5
No related branches found
No related tags found
No related merge requests found
......@@ -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()];
}
......
......@@ -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));
}
}
......
......@@ -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.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment