1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
<?
# Lifter002: TODO
# Lifter007: TODO
# Lifter003: TODO
# Lifter010: TODO
/**
* extern_edit_module.inc.php
*
*
*
*
* @author Peter Thienel <pthienel@web.de>, Suchi & Berg GmbH <info@data-quest.de>
* @access public
* @modulegroup extern
* @module extern_edit_module
* @package studip_extern
*/
// +---------------------------------------------------------------------------+
// This file is part of Stud.IP
// extern_edit_module.inc.php
//
// Copyright (C) 2003 Peter Thienel <pthienel@web.de>,
// Suchi & Berg GmbH <info@data-quest.de>
// +---------------------------------------------------------------------------+
// 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;
// it's forbidden to use the command "new" with a given config_id
if (Request::option('com') == 'new') {
$config_id = '';
}
$module = FALSE;
if (Request::option('com') == 'new') {
foreach ($GLOBALS['EXTERN_MODULE_TYPES'] as $key => $type) {
if ($type['module'] == Request::quoted('mod')) {
$configurations = ExternConfig::GetAllConfigurations($range_id, $key);
if (!isset($configurations[$type['module']]) || sizeof($configurations[$type['module']]) < $GLOBALS['EXTERN_MAX_CONFIGURATIONS']) {
$module = ExternModule::GetInstance($range_id, $type['module'], '', 'NEW');
}
else {
echo MessageBox::error(sprintf(_('Es wurden bereits %s Konfigurationen angelegt. Sie können für dieses Module keine weiteren Konfigurationen anlegen.')
, $GLOBALS['EXTERN_MAX_CONFIGURATIONS']));
echo LinkButton::create("<< " . _("Zurück"), URLHelper::getURL('?list=TRUE'));
$template = $GLOBALS['template_factory']->open('layouts/base.php');
$template->content_for_layout = ob_get_clean();
echo $template->render();
page_close();
die;
}
}
}
}
else {
foreach ($GLOBALS['EXTERN_MODULE_TYPES'] as $type) {
if ($type["module"] == $mod) {
$module = ExternModule::GetInstance($range_id, $mod, $config_id);
}
}
}
if (!$module)
die("Unknown module type");
$element_command = FALSE;
$edit = Request::option('edit');
if ($edit) {
$element_commands = ['show', 'hide', 'move_left', 'move_right', 'show_group', 'hide_group', 'do_search_x'];
foreach ($element_commands as $element_command) {
$element_command_form = $edit . "_" . $element_command;
if ($_POST[$element_command_form]) {
if ($element_command == 'show_group') {
$pos = $_POST[$element_command_form];
} else if (is_array($_POST[$element_command_form])) {
$pos_tmp = array_keys($_POST[$element_command_form]);
$pos = $pos_tmp[0];
}
$module->executeCommand($edit, $element_command, $pos);
}
}
}
$elements = $module->getAllElements();
// the first parameter of printOutEdit() has to be an array, because it is
// possible to open more than one element form
$edit_open = "";
foreach ($elements as $element) {
if ($edit == $element->getName()) {
$edit_open = ["$edit" => (Request::option('com') != 'close')];
}
}
if (Request::option('com') == 'new' || Request::option('com') == 'edit' || Request::option('com') == 'open' || Request::option('com') == 'close') {
$module->printoutEdit($edit_open, $_POST, "", $edit);
}
if (Request::option('com') == 'store') {
$faulty_values = $module->checkFormValues($edit);
$fault = FALSE;
foreach ($faulty_values as $faulty) {
if (in_array(TRUE, $faulty)) {
echo MessageBox::info(_("Bitte korrigieren Sie die mit * gekennzeichneten Werte!"));
$module->printoutEdit($edit_open, $_POST,
$faulty_values, $edit);
$fault = TRUE;
break;
}
}
if (!$fault) {
// This is the right place to trigger some functions by special
// POST_VARS-values. At the moment there is only one: If the name of the
// configuration was changed, setup the extern_config table.
if ($edit == "Main" && $_POST["Main_name"] != $module->config->config_name) {
if (!ExternConfig::ChangeName($module->config->range_id, $module->getType(), $module->config->getId(),
$module->config->config_name, $_POST["Main_name"])) {
PageLayout::postError(_('Der Konfigurationsname wurde bereits für eine Konfiguration dieses Moduls vergeben. Bitte geben Sie einen anderen Namen ein.'));
$module->printoutEdit($edit_open, "$_POST", "", $edit);
}
$module->store($edit, $_POST);
PageLayout::postSuccess(_('Die eingegebenen Werte wurden übernommen und der Name der Konfiguration geändert.'));
$module->printoutEdit($edit_open, "", "", $edit);
} else {
$module->store($edit, $_POST);
PageLayout::postSuccess(_('Die eingegebenen Werte wurden übernommen.'));
$module->printoutEdit($edit_open, "", "", $edit);
}
}
}
if (!$edit_open[$edit]) {
echo LinkButton::create("<< " . _("Zurück"), URLHelper::getURL('?list=TRUE'));;
}
Helpbar::get()->addPlainText(_('Information'), _('Um die Werte eines einzelnen Elements zu ändern, klicken Sie bitte den "Übernehmen"-Button innerhalb des jeweiligen Elements.'));
// the type of this module is not Global
if ($module->getType() != 0) {
$url = sprintf("%sextern.php?module=%s&range_id=%s&preview=1&config_id=%s",
$GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP'],
$module->getName(),
$module->config->range_id,
$module->config->getId()
);
if ($global_config = ExternConfig::GetGlobalConfiguration($module->config->range_id)) {
$url .= "&global_id=$global_config";
}
$actions = new ActionsWidget();
$actions->addLink(_('Vorschau'), $url, Icon::create('question-circle', 'clickable', ['title' => _('Vorschau')]), ['target' => '_blank']);
Sidebar::get()->addWidget($actions);
}
?>
|