, Suchi & Berg GmbH * @access public * @modulegroup extern * @module extern * @package studip_extern */ // +---------------------------------------------------------------------------+ // This file is part of Stud.IP // admin_extern.inc.php // // Copyright (C) 2003 Peter Thienel , // Suchi & Berg GmbH // +---------------------------------------------------------------------------+ // 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 any later version. // +---------------------------------------------------------------------------+ // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // +---------------------------------------------------------------------------+ use Studip\Button, Studip\LinkButton; include('lib/seminar_open.php'); // initialise Stud.IP-Session // -- here you have to put initialisations for the current page if (Request::option('view') == 'extern_global') { $range_id = 'studip'; URLHelper::addLinkParam('view', 'extern_global'); } else { $range_id = Context::getId(); URLHelper::addLinkParam('view', 'extern_inst'); } URLHelper::addLinkParam('cid', $range_id); $config_id = Request::option('config_id'); // when downloading a config, do it here and stop afterwards if (Request::get('com') == 'download_config') { if ($range_id) { download_config($range_id, $config_id, Request::quoted('module')); page_close(); exit; } } PageLayout::setTitle(_("Verwaltung externer Seiten")); if ($range_id != 'studip') { Navigation::activateItem('/admin/institute/external'); require_once 'lib/admin_search.inc.php'; } else { Navigation::activateItem('/admin/locations/external'); } $mod=Request::quoted('mod');//Change header_line if open object if (Context::getId()) { PageLayout::setTitle(Context::getHeaderLine()." - ".PageLayout::getTitle()); foreach ($GLOBALS['EXTERN_MODULE_TYPES'] as $key => $type) { if ($type["module"] == $mod) { PageLayout::setTitle(PageLayout::getTitle() . " ({$GLOBALS['EXTERN_MODULE_TYPES'][$key]['name']})"); break; } } } // upload of configuration if (Request::option('com') == "do_upload_config") { $file_content = file_get_contents($_FILES['the_file']['tmp_name']); // revert the changes done by indentJson $file_content_wo_tabs = str_replace("\t", '', str_replace("\n", '', $file_content)); $jsonconfig = json_decode($file_content_wo_tabs, true); if (!check_config($jsonconfig, Request::quoted('check_module'))) { PageLayout::postError(_('Die Konfigurationsdatei hat den falschen Modultyp!')); } else if (!store_config($range_id, $config_id, $jsonconfig)) { PageLayout::postError(_('Die Konfigurationsdatei konnte nicht hochgeladen werden!')); } else { PageLayout::postSuccess(_('Die Datei wurde erfolgreich übertragen!')); } } //Output starts here ob_start(); // copy existing configuration if (Request::option('com') == 'copyconfig') { if (Request::option('copyinstid') && Request::option('copyconfigid')) { $config = ExternConfig::GetInstance(Request::option('copyinstid'), '', Request::option('copyconfigid')); $config_copy = $config->copy($range_id); echo MessageBox::success(sprintf(_("Die Konfiguration wurde als \"%s\" nach Modul \"%s\" kopiert."), htmlReady($config_copy->getConfigName()), htmlReady($GLOBALS['EXTERN_MODULE_TYPES'][$config_copy->getTypeName()]['name']))); } else { Request::set('com',''); } } if (Request::option('com') == 'delete') { $config = ExternConfig::GetInstance($range_id, '', $config_id); if ($config->deleteConfiguration()) { echo MessageBox::success(sprintf(_("Konfiguration \"%s\" für Modul \"%s\" gelöscht!"), htmlReady($config->getConfigName()), htmlReady($GLOBALS['EXTERN_MODULE_TYPES'][$config->getTypeName()]['name']))); } else { echo MessageBox::error(_("Konfiguration konnte nicht gelöscht werden")); } } if (Request::option('com') == 'delete_sec') { $config = ExternConfig::GetConfigurationMetaData($range_id, $config_id); $message = sprintf(_("Wollen Sie die Konfiguration "%s" des Moduls %s wirklich löschen?"), $config["name"], $GLOBALS["EXTERN_MODULE_TYPES"][$config["type"]]["name"]); $message .= '

'; $message .= LinkButton::createAccept("JA", URLHelper::getURL('?com=delete&config_id='.$config_id)); $message .= LinkButton::createCancel("NEIN", URLHelper::getURL('?list=TRUE&view=extern_inst')); echo MessageBox::info($message); $template = $GLOBALS['template_factory']->open('layouts/base.php'); $template->content_for_layout = ob_get_clean(); echo $template->render(); page_close(); die; } if (Request::option('com') == 'info') { include 'lib/extern/views/extern_info_module.inc.php'; $template = $GLOBALS['template_factory']->open('layouts/base.php'); $template->content_for_layout = ob_get_clean(); echo $template->render(); page_close(); die; } if (Request::option('com') == 'new' || Request::option('com') == 'edit' || Request::option('com') == 'open' || Request::option('com') == 'close' || Request::option('com') == 'store') { require_once "lib/extern/views/extern_edit_module.inc.php"; $template = $GLOBALS['template_factory']->open('layouts/base.php'); $template->content_for_layout = ob_get_clean(); echo $template->render(); page_close(); die; } // Some browsers don't reload the site by clicking the same link twice again. // So it's better to use different commands to do the same job. if (Request::option('com') == 'set_default' || Request::option('com') == 'unset_default') { if (!ExternConfig::SetStandardConfiguration($range_id, $config_id)) { page_close(); exit; } } if (Config::get()->EXTERN_SRI_ENABLE_BY_ROOT && Request::option('com') == 'enable_sri' && $GLOBALS['perm']->have_perm('root')) { enable_sri($range_id, Request::quoted('sri_enable')); } if (Config::get()->EXTERN_SRI_ENABLE_BY_ROOT && $GLOBALS['perm']->have_perm('root')) { echo '
'; echo CSRFProtection::tokenTag(); echo '
'; echo _("SRI-Schnittstelle freigeben"); echo ' '; echo Button::createAccept(); echo "
"; } $configurations = ExternConfig::GetAllConfigurations($range_id); $module_types_ordered = ExternModule::GetOrderedModuleTypes(); $choose_module_form = ''; foreach ($module_types_ordered as $i) { if (isset($configurations[$GLOBALS['EXTERN_MODULE_TYPES'][$i]['module']])) { $count = count($configurations[$GLOBALS['EXTERN_MODULE_TYPES'][$i]['module']]); $have_config = TRUE; } else { $count = 0; } if ($i && $count < $EXTERN_MAX_CONFIGURATIONS && ExternModule::HaveAccessModuleType(Request::option('view'), $i)) { $choose_module_form .= "\n"; } } $sidebar = Sidebar::get(); $widget = new ActionsWidget(); $widget->addLink( _('Neue globale Konfiguration'), URLHelper::getURL('?com=new&mod=Global'), Icon::create('link-intern', 'clickable') ); $sidebar->addWidget($widget); // cho LinkButton::create(_(" anlegen"), URLHelper::getURL('?com=new&mod=Global')); if ($choose_module_form != '') { if (Request::option('com') != 'copychoose') { echo '
'; echo CSRFProtection::tokenTag(); echo "
" ._("Neue Konfiguration für Modul") . "\n"; echo "\n"; echo "
\n"; echo "
" . Button::create(_("Anlegen")) . "
\n"; echo "

\n"; $conf_institutes = ExternConfig::GetInstitutesWithConfigurations(($GLOBALS['perm']->have_perm('root') && Request::option('view') == 'extern_global') ? 'global' : ['inst', 'fak']); if (is_array($conf_institutes) && count($conf_institutes)) { echo '
'; echo CSRFProtection::tokenTag(); echo "
"; echo "" . _("Konfiguration kopieren") . ""; $choose_institute_copy = "\n"; echo ''; echo "
\n"; echo "
" . Button::create(_("Weiter") . " >>", 'continue') . "
\n"; echo "

\n"; } } else { if (Request::option('com') == 'copychoose') { $choose_module_select = "'; echo ''; echo "\n"; echo "
\n"; echo LinkButton::create("<< " . _("Zurück"), URLHelper::getURL('?list=TRUE&view=extern_inst')); echo Button::create(_("Kopieren")); echo "\n"; echo "
\n"; echo "\n"; } } } else { echo "
"; echo _("Sie haben bereits für alle Module die maximale Anzahl von Konfigurationen angelegt. Um eine neue Konfiguration anzulegen, müssen Sie erst eine bestehende im gewünschten Modul löschen."); echo "
\n"; } if (!$have_config) { echo "
\n"; echo _("Es wurden noch keine Konfigurationen angelegt."); echo "
"; } else { echo "\n"; echo "\n"; foreach ($module_types_ordered as $order) { $module_type = $GLOBALS['EXTERN_MODULE_TYPES'][$order]; if (isset($configurations[$module_type["module"]])) { echo "\n"; echo "\n\n\n"; echo "\n"; foreach ($configurations[$module_type["module"]] as $configuration) { echo "\n"; $actionMenu = ActionMenu::get(); $actionMenu->addLink( URLHelper::getURL('?com=download_config&config_id='. $configuration['id'] .'&module='. $module_type['module']), _('Konfigurationsdatei herunterladen'), Icon::create('download', 'clickable', ['title' => _('Konfigurationsdatei herunterladen')])); $actionMenu->addLink( URLHelper::getURL('?com=upload_config&config_id='. $configuration['id']), _('Konfigurationsdatei hochladen'), Icon::create('upload', 'clickable', ['title' => _('Konfigurationsdatei hochladen')])); $actionMenu->addLink( URLHelper::getURL('?com=info&config_id=' . $configuration['id']), _('weitere Informationen anzeigen'), Icon::create('infopage', 'clickable', ['title' => _('weitere Informationen anzeigen')])); // Switching for the is_default option. Read the comment above. if ($configuration["is_default"]) { $actionMenu->addLink( URLHelper::getURL('?com=unset_default&config_id=' . $configuration['id']) . '#anker', _('Standard entziehen'), Icon::create('checkbox-checked', 'clickable', ['title' => _('Standard entziehen')])); } else { $actionMenu->addLink( URLHelper::getURL('?com=set_default&config_id=' . $configuration['id']) . '#anker', _('Standard zuweisen'), Icon::create('checkbox-checked', 'clickable', ['title' => _('Standard zuweisen')])); } $actionMenu->addLink( URLHelper::getURL('?com=delete_sec&config_id=' . $configuration['id']) . '#anker', _('Konfiguration löschen'), Icon::create('trash', 'clickable', ['title' => _('Konfiguration löschen')])); $actionMenu->addLink( URLHelper::getURL('?com=edit&mod=' . $module_type['module'] . '&config_id=' . $configuration['id']), _('Konfiguration bearbeiten'), Icon::create('edit', 'clickable', ['title' => _('Konfiguration bearbeiten')])); ?> \n"; echo $actionMenu->render(); echo "\n"; if (Request::option('com') == 'upload_config' && Request::option('config_id') == $configuration['id']) { $template = $GLOBALS['template_factory']->open('extern/upload_form'); $template->set_attribute('module', $module_type['module']); $template->set_attribute('config_id', $configuration['id']); $template->set_attribute('max_filesize', 1024 * 100); // currently 100kb echo $template->render(); } } } } } echo "
\n"; echo _("Angelegte Konfigurationen"); echo "
"; if (isset($configurations[$module_type["module"]][$config_id])) { echo "\n"; } echo $module_type["name"]; echo "
"; echo $configuration["name"]; if ($configuration['is_default']) { echo ' (' . _('Standard') . ')'; } echo "
\n"; $info_max_configs = sprintf(_("Sie können pro Modul maximal %s Konfigurationen anlegen."), $EXTERN_MAX_CONFIGURATIONS); Helpbar::get()->addPlainText(_('Information'), sprintf(_("Sie können pro Modul maximal %s Konfigurationen anlegen."), $EXTERN_MAX_CONFIGURATIONS)); if (is_array($configurations) && count($configurations)) { Helpbar::get()->addPlainText(_('Standard-Konfiguration'), _('Dieses Symbol kennzeichnet die Standard-Konfiguration, die zur Formatierung herangezogen wird, wenn Sie beim Aufruf dieses Moduls keine Konfiguration angeben.'), Icon::create('checkbox-checked')); Helpbar::get()->addPlainText(_('Keine Standard-Konfiguration'), _('Wenn Sie keine Konfiguration als Standard ausgewählt haben, wird die Stud.IP-Konfiguration verwendet.'), Icon::create('info')); Helpbar::get()->addPlainText(_('Standard-Konfiguration zuweisen'), _('Klicken Sie auf diesen Button, um eine Konfiguration zur Standard-Konfiguration zu erklären.'), Icon::create('checkbox-unchecked')); Helpbar::get()->addPlainText(_('Weitere Informationen'), _('Klicken Sie auf diesen Button um weitere Informationen über diese Konfiguration zu erhalten. Hier finden Sie auch die Links, über die Sie die Module in Ihrer Website einbinden können.'), Icon::create('infopage')); } //print_footer(); $template = $GLOBALS['template_factory']->open('layouts/base.php'); $template->content_for_layout = ob_get_clean(); echo $template->render(); page_close();