Skip to content
Snippets Groups Projects
Commit 3b662756 authored by Moritz Strohm's avatar Moritz Strohm
Browse files

made plugin navigation path configurable, fixes #6

parent 343eae08
No related branches found
No related tags found
No related merge requests found
...@@ -95,12 +95,20 @@ class TandemPlugin extends StudIPPlugin implements SystemPlugin, PortalPlugin ...@@ -95,12 +95,20 @@ class TandemPlugin extends StudIPPlugin implements SystemPlugin, PortalPlugin
PluginEngine::getURL('tandemplugin/admin/pairs') PluginEngine::getURL('tandemplugin/admin/pairs')
); );
$top_navigation = null;
$navigation_name = 'admin';
if (Config::get()->TANDEMPLUGIN_USE_TOOLS_NAVIGATION) {
if (Navigation::hasItem('/tools')) {
$top_navigation = Navigation::getItem('/tools');
$navigation_name = 'tandemplugin';
}
} else {
$top_navigation = clone $navigation; $top_navigation = clone $navigation;
$top_navigation->setImage( $top_navigation->setImage(
Icon::create("roles", "navigation") Icon::create("roles", "navigation")
); );
Navigation::addItem("/tandemplugin", $top_navigation); Navigation::addItem("/tandemplugin", $top_navigation);
}
$sub_navigation = new Navigation( $sub_navigation = new Navigation(
dgettext('TandemPlugin', 'Etablierte Tandems'), dgettext('TandemPlugin', 'Etablierte Tandems'),
...@@ -138,7 +146,12 @@ class TandemPlugin extends StudIPPlugin implements SystemPlugin, PortalPlugin ...@@ -138,7 +146,12 @@ class TandemPlugin extends StudIPPlugin implements SystemPlugin, PortalPlugin
); );
$navigation->addSubNavigation('config', $sub_navigation); $navigation->addSubNavigation('config', $sub_navigation);
$top_navigation->addSubNavigation('admin', $navigation); if ($top_navigation) {
$top_navigation->addSubNavigation(
$navigation_name,
$navigation
);
}
} }
} }
......
...@@ -30,6 +30,11 @@ class AdminController extends PluginController ...@@ -30,6 +30,11 @@ class AdminController extends PluginController
if(!RolePersistence::isAssignedRole(User::findCurrent()->id, 'TandemAdmin') and !$perm->have_perm('root')) { if(!RolePersistence::isAssignedRole(User::findCurrent()->id, 'TandemAdmin') and !$perm->have_perm('root')) {
throw new AccessDeniedException(); throw new AccessDeniedException();
} }
$this->admin_nav_path = '/tandemplugin/admin';
if (Config::get()->TANDEMPLUGIN_USE_TOOLS_NAVIGATION) {
$this->admin_nav_path = '/tools/tandemplugin';
}
} }
...@@ -61,18 +66,16 @@ class AdminController extends PluginController ...@@ -61,18 +66,16 @@ class AdminController extends PluginController
} }
if($this->status == -1) { if($this->status == -1) {
if(Navigation::hasItem('/tandemplugin/admin/rejected')) { if(Navigation::hasItem($this->admin_nav_path . '/rejected')) {
Navigation::activateItem('/tandemplugin/admin/rejected'); Navigation::activateItem($this->admin_nav_path . '/rejected');
} }
} elseif($this->status == 0) { } elseif($this->status == 0) {
if(Navigation::hasItem('/tandemplugin/admin/requested')) { if(Navigation::hasItem($this->admin_nav_path . '/requested')) {
Navigation::activateItem('/tandemplugin/admin/requested'); Navigation::activateItem($this->admin_nav_path . '/requested');
} }
} elseif($this->status == 1) { } elseif($this->status == 1) {
if(Navigation::hasItem('/tandemplugin/admin/established')) { if(Navigation::hasItem($this->admin_nav_path . '/established')) {
Navigation::activateItem('/tandemplugin/admin/established'); Navigation::activateItem($this->admin_nav_path . '/established');
} }
} }
...@@ -236,8 +239,8 @@ class AdminController extends PluginController ...@@ -236,8 +239,8 @@ class AdminController extends PluginController
$sidebar->addWidget($actions); $sidebar->addWidget($actions);
if(Navigation::hasItem('/tandemplugin/admin/terminated')) { if(Navigation::hasItem($this->admin_nav_path . '/terminated')) {
Navigation::activateItem('/tandemplugin/admin/terminated'); Navigation::activateItem($this->admin_nav_path . '/terminated');
} }
$this->terminated_pairs = []; $this->terminated_pairs = [];
...@@ -324,8 +327,8 @@ class AdminController extends PluginController ...@@ -324,8 +327,8 @@ class AdminController extends PluginController
public function search_action() public function search_action()
{ {
if(Navigation::hasItem('/tandemplugin/admin/search')) { if(Navigation::hasItem($this->admin_nav_path . '/search')) {
Navigation::activateItem('/tandemplugin/admin/search'); Navigation::activateItem($this->admin_nav_path . '/search');
} }
$this->age_of_request = 0; $this->age_of_request = 0;
...@@ -487,8 +490,8 @@ class AdminController extends PluginController ...@@ -487,8 +490,8 @@ class AdminController extends PluginController
public function config_action() public function config_action()
{ {
if(Navigation::hasItem('/tandemplugin/admin/config')) { if(Navigation::hasItem($this->admin_nav_path . '/config')) {
Navigation::activateItem('/tandemplugin/admin/config'); Navigation::activateItem($this->admin_nav_path . '/config');
} }
if(Navigation::hasItem('/profile/tandem_administration/config')) { if(Navigation::hasItem('/profile/tandem_administration/config')) {
...@@ -502,6 +505,7 @@ class AdminController extends PluginController ...@@ -502,6 +505,7 @@ class AdminController extends PluginController
$this->gender_search_enabled = (bool)Request::get('gender_search_enabled', false); $this->gender_search_enabled = (bool)Request::get('gender_search_enabled', false);
$this->delete_old_period = (int)Request::int('delete_old_period', 6); $this->delete_old_period = (int)Request::int('delete_old_period', 6);
$this->proof_fields_enabled = (bool)Request::get('proof_fields_enabled', false); $this->proof_fields_enabled = (bool)Request::get('proof_fields_enabled', false);
$this->use_tools_navigation = Request::int('use_tools_navigation', 0);
if(($this->delete_old_period < 1) or ($this->delete_old_period > 24)) { if(($this->delete_old_period < 1) or ($this->delete_old_period > 24)) {
PageLayout::postError( PageLayout::postError(
...@@ -530,10 +534,20 @@ class AdminController extends PluginController ...@@ -530,10 +534,20 @@ class AdminController extends PluginController
$delete_old_period->store(); $delete_old_period->store();
} }
$config->store(
'TANDEMPLUGIN_USE_TOOLS_NAVIGATION',
(int)$this->use_tools_navigation
);
PageLayout::postSuccess( PageLayout::postSuccess(
dgettext('TandemPlugin', 'Die Konfiguration wurde gespeichert!') dgettext('TandemPlugin', 'Die Konfiguration wurde gespeichert!')
); );
//Reload page to avoid POST requests in browser history
//and to avoid the obsolet navigation path to be shown,
//if the navigation path for the tandem administration
//has been changed.
$this->redirect('admin/config');
} else { } else {
$this->proof_fields_enabled = (bool) $this->proof_fields_enabled = (bool)
($config->TANDEMPLUGIN_PROOF_FIELDS_ENABLED ? ($config->TANDEMPLUGIN_PROOF_FIELDS_ENABLED ?
...@@ -546,6 +560,12 @@ class AdminController extends PluginController ...@@ -546,6 +560,12 @@ class AdminController extends PluginController
$this->delete_old_period = (int) $this->delete_old_period = (int)
($config->TANDEMPLUGIN_DELETE_OLD_PERIOD ? ($config->TANDEMPLUGIN_DELETE_OLD_PERIOD ?
$config->TANDEMPLUGIN_DELETE_OLD_PERIOD : 6); $config->TANDEMPLUGIN_DELETE_OLD_PERIOD : 6);
$this->use_tools_navigation = (int) (
$config->TANDEMPLUGIN_USE_TOOLS_NAVIGATION
? $config->TANDEMPLUGIN_USE_TOOLS_NAVIGATION
: 0
);
} }
} }
} }
...@@ -16,23 +16,12 @@ ...@@ -16,23 +16,12 @@
class AddRole extends Migration class AddRole extends Migration
{ {
public function up() public function up()
{ {
$db = DBManager::get();
//Create TandemAdmin role: //Create TandemAdmin role:
$role = new Role();
$db->exec( $role->rolename = 'TandemAdmin';
"INSERT INTO roles (rolename, system) RolePersistence::saveRole($role);
VALUES ('TandemAdmin', 'n');"
);
//close DB connection:
$db = null;
} }
......
<?php
/**
* This file is part of the TandemPlugin for Stud.IP
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @author Elmar Ludwig <elmar.ludwig@uos.de>
* @author Moritz Strohm <strohm@data-quest.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Plugin
*/
class AddConfigTandempluginUseToolsNavigation extends Migration
{
public function up()
{
Config::get()->create(
'TANDEMPLUGIN_USE_TOOLS_NAVIGATION',
[
'type' => 'boolean',
'value' => 0,
'section' => 'tandemplugin',
'description' => 'Soll die Tandem-Verwaltung unter dem Navigationpunkt "Tools" angezeigt werden (true) oder nicht (false)?'
]
);
}
public function down()
{
Config::get()->delete('TANDEMPLUGIN_USE_TOOLS_NAVIGATION');
}
}
...@@ -65,6 +65,26 @@ ...@@ -65,6 +65,26 @@
value="1"> value="1">
</label> </label>
</fieldset> </fieldset>
<fieldset>
<legend>
<?= dgettext('TandemPlugin', 'Anzeige der Tandem-Verwaltung') ?>
</legend>
<p>
<?= dgettext(
'TandemPlugin',
'Die Verwaltung der Tandem-Funktionen kann entweder als eigener Punkt in der Hauptnavigation angezeigt werden (Voreinstellung) oder als Reiter im Bereich "Tools".'
) ?>
</p>
<label>
<?= dgettext(
'TandemPlugin',
'Tandem-Verwaltung im Bereich "Tools" anzeigen'
) ?>
<input type="checkbox" name="use_tools_navigation"
<?= $use_tools_navigation ? 'checked="checked"' : '' ?>
value="1">
</label>
</fieldset>
<div> <div>
<?= \Studip\Button::create( <?= \Studip\Button::create(
dgettext('TandemPlugin', 'Speichern'), dgettext('TandemPlugin', 'Speichern'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment