ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjMDSettingsGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23include_once("./Services/Object/classes/class.ilObjectGUI.php");
24
25
37{
38
44 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
45 {
46 global $DIC;
47
48 $lng = $DIC['lng'];
49
50 $this->type = 'mds';
51 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
52
53 $this->lng = $lng;
54 $this->lng->loadLanguageModule("meta");
55 }
56
63 public function executeCommand()
64 {
65 global $DIC;
66
67 $rbacsystem = $DIC['rbacsystem'];
68 $ilErr = $DIC['ilErr'];
69 $ilAccess = $DIC['ilAccess'];
70
71 $next_class = $this->ctrl->getNextClass($this);
72 $cmd = $this->ctrl->getCmd();
73
74 $this->prepareOutput();
75
76 if (!$ilAccess->checkAccess('read', '', $this->object->getRefId())) {
77 $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
78 }
79
80 switch ($next_class) {
81 case 'iladvancedmdsettingsgui':
82 $this->tabs_gui->setTabActive('md_advanced');
83 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDSettingsGUI.php');
84 $adv_md = new ilAdvancedMDSettingsGUI();
85 $ret = $this->ctrl->forwardCommand($adv_md);
86 break;
87
88 case 'ilpermissiongui':
89 $this->tabs_gui->setTabActive('perm_settings');
90 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
91 $perm_gui = new ilPermissionGUI($this);
92 $ret = &$this->ctrl->forwardCommand($perm_gui);
93 break;
94
95 case 'ilmdcopyrightusagegui':
96 // this command is used if copyrightUsageGUI calls getParentReturn (see ...UsageGUI->setTabs)
97 $this->ctrl->setReturn($this, 'showCopyrightSettings');
98 $copyright_id = $_GET['entry_id'];
99 $gui = new ilMDCopyrightUsageGUI((int) $copyright_id);
100 $this->ctrl->forwardCommand($gui);
101 break;
102
103 default:
104 $this->initMDSettings();
105 if (!$cmd || $cmd == 'view') {
106 $cmd = "showGeneralSettings";
107 }
108
109 $this->$cmd();
110 break;
111 }
112 return true;
113 }
114
118 protected function getType()
119 {
120 return $this->type;
121 }
122
126 protected function getParentObjType()
127 {
128 return 'meta';
129 }
130
131
135 protected function getAdministrationFormId()
136 {
138 }
139
140
147 public function getAdminTabs()
148 {
149 global $DIC;
150
151 $rbacsystem = $DIC['rbacsystem'];
152 $ilAccess = $DIC['ilAccess'];
153
154 if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
155 $this->tabs_gui->addTarget(
156 "md_general_settings",
157 $this->ctrl->getLinkTarget($this, "showGeneralSettings"),
158 array("showGeneralSettings", "view")
159 );
160
161 $this->tabs_gui->addTarget(
162 "md_copyright",
163 $this->ctrl->getLinkTarget($this, "showCopyrightSettings"),
164 array("showCopyrightSettings")
165 );
166
167 $this->tabs_gui->addTarget(
168 "md_advanced",
169 $this->ctrl->getLinkTargetByClass('iladvancedmdsettingsgui', ""),
170 '',
171 'iladvancedmdsettingsgui'
172 );
173 }
174
175 if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
176 $this->tabs_gui->addTarget(
177 "perm_settings",
178 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
179 array(),
180 'ilpermissiongui'
181 );
182 }
183 }
184
188 public function showGeneralSettings()
189 {
190 global $DIC;
191
192 $tpl = $DIC['tpl'];
193
195 $tpl->setContent($this->form->getHTML());
196 }
197
203 public function initGeneralSettingsForm($a_mode = "edit")
204 {
205 global $DIC;
206
207 $lng = $DIC['lng'];
208 $ilAccess = $DIC['ilAccess'];
209
210 $this->tabs_gui->setTabActive('md_general_settings');
211
212 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
213 $this->form = new ilPropertyFormGUI();
214
215 $ti = new ilTextInputGUI($this->lng->txt("md_delimiter"), "delimiter");
216 $ti->setInfo($this->lng->txt("md_delimiter_info"));
217 $ti->setMaxLength(1);
218 $ti->setSize(1);
219 $ti->setValue($this->md_settings->getDelimiter());
220 $this->form->addItem($ti);
221
222 if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
223 $this->form->addCommandButton("saveGeneralSettings", $lng->txt("save"));
224 $this->form->addCommandButton("showGeneralSettings", $lng->txt("cancel"));
225 }
226
227 $this->form->setTitle($lng->txt("md_general_settings"));
228 $this->form->setFormAction($this->ctrl->getFormAction($this));
229 }
230
234 public function saveGeneralSettings()
235 {
236 global $DIC;
237
238 $ilCtrl = $DIC['ilCtrl'];
239 $ilAccess = $DIC['ilAccess'];
240
241 if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
242 $ilCtrl->redirect($this, "showGeneralSettings");
243 }
244
245 $delim = (trim($_POST['delimiter']) == "")
246 ? ","
247 : trim($_POST['delimiter']);
248 $this->md_settings->setDelimiter($delim);
249 $this->md_settings->save();
250 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
251
252 $ilCtrl->redirect($this, "showGeneralSettings");
253 }
254
255
259 public function showCopyrightSettings()
260 {
261 global $DIC;
262
263 $ilAccess = $DIC['ilAccess'];
264
265 $this->tabs_gui->setTabActive('md_copyright');
266 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.settings.html', 'Services/MetaData');
267
268 $this->initSettingsForm();
269 $this->tpl->setVariable('SETTINGS_TABLE', $this->form->getHTML());
270
271 $has_write = $ilAccess->checkAccess('write', '', $this->object->getRefId());
272
273 include_once("./Services/MetaData/classes/class.ilMDCopyrightTableGUI.php");
274 $table_gui = new ilMDCopyrightTableGUI($this, 'showCopyrightSettings', $has_write);
275 $table_gui->setTitle($this->lng->txt("md_copyright_selection"));
276 $table_gui->parseSelections();
277
278 if ($has_write) {
279 // $table_gui->addCommandButton("updateCopyrightSelection", $this->lng->txt("save"));
280 $table_gui->addCommandButton('addEntry', $this->lng->txt('add'));
281 $table_gui->addMultiCommand("confirmDeleteEntries", $this->lng->txt("delete"));
282 $table_gui->setSelectAllCheckbox("entry_id");
283 }
284
285 $this->tpl->setVariable('COPYRIGHT_TABLE', $table_gui->getHTML());
286 }
287
291 public function saveCopyrightSettings()
292 {
293 global $DIC;
294
295 $ilAccess = $DIC['ilAccess'];
296
297 if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
298 $this->ctrl->redirect($this, "showCopyrightSettings");
299 }
300
301 $this->md_settings->activateCopyrightSelection((int) $_POST['active']);
302 $this->md_settings->save();
303 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
304 $this->showCopyrightSettings();
305 }
306
307 public function showCopyrightUsages()
308 {
309 $this->ctrl->setParameterByClass('ilmdcopyrightusagegui', 'entry_id', $_GET['entry_id']);
310 $this->ctrl->redirectByClass('ilmdcopyrightusagegui', "showUsageTable");
311 }
312
319 public function editEntry()
320 {
321 $this->ctrl->saveParameter($this, 'entry_id');
322 $this->initCopyrightEditForm();
323 $this->tpl->setContent($this->form->getHTML());
324 }
325
333 public function addEntry()
334 {
335 $this->initCopyrightEditForm('add');
336 $this->tpl->setContent($this->form->getHTML());
337 }
338
339
346 public function saveEntry()
347 {
348 global $DIC;
349
350 $ilErr = $DIC['ilErr'];
351
352 include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
353 $this->entry = new ilMDCopyrightSelectionEntry(0);
354
355 $this->entry->setTitle(ilUtil::stripSlashes($_POST['title']));
356 $this->entry->setDescription(ilUtil::stripSlashes($_POST['description']));
357 $this->entry->setCopyright($this->stripSlashes($_POST['copyright']));
358 $this->entry->setLanguage('en');
359 $this->entry->setCopyrightAndOtherRestrictions(true);
360 $this->entry->setCosts(false);
361 $this->entry->setOutdated((int) $_POST['outdated']);
362
363 if (!$this->entry->validate()) {
364 ilUtil::sendInfo($this->lng->txt('fill_out_all_required_fields'));
365 $this->addEntry();
366 return false;
367 }
368 $this->entry->add();
369 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
370 $this->showCopyrightSettings();
371 return true;
372 }
373
380 public function confirmDeleteEntries()
381 {
382 if (!is_array($_POST['entry_id']) or !count($_POST['entry_id'])) {
383 ilUtil::sendInfo($this->lng->txt('select_one'));
384 $this->showCopyrightSettings();
385 return true;
386 }
387
388 include_once('Services/Utilities/classes/class.ilConfirmationGUI.php');
389 $c_gui = new ilConfirmationGUI();
390
391 // set confirm/cancel commands
392 $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteEntries"));
393 $c_gui->setHeaderText($this->lng->txt("md_delete_cp_sure"));
394 $c_gui->setCancel($this->lng->txt("cancel"), "showCopyrightSettings");
395 $c_gui->setConfirm($this->lng->txt("confirm"), "deleteEntries");
396
397 include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
398
399 // add items to delete
400 foreach ($_POST["entry_id"] as $entry_id) {
401 $entry = new ilMDCopyrightSelectionEntry($entry_id);
402 $c_gui->addItem('entry_id[]', $entry_id, $entry->getTitle());
403 }
404 $this->tpl->setContent($c_gui->getHTML());
405 }
406
413 public function deleteEntries()
414 {
415 if (!is_array($_POST['entry_id']) or !count($_POST['entry_id'])) {
416 ilUtil::sendInfo($this->lng->txt('select_one'));
417 $this->showCopyrightSettings();
418 return true;
419 }
420
421 include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
422 foreach ($_POST["entry_id"] as $entry_id) {
423 $entry = new ilMDCopyrightSelectionEntry($entry_id);
424 $entry->delete();
425 }
426 ilUtil::sendSuccess($this->lng->txt('md_copyrights_deleted'));
427 $this->showCopyrightSettings();
428 return true;
429 }
430
437 public function updateEntry()
438 {
439 global $DIC;
440
441 $ilErr = $DIC['ilErr'];
442
443 include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
444 $this->entry = new ilMDCopyrightSelectionEntry((int) $_REQUEST['entry_id']);
445
446 $this->entry->setTitle(ilUtil::stripSlashes($_POST['title']));
447 $this->entry->setDescription(ilUtil::stripSlashes($_POST['description']));
448 $this->entry->setCopyright($this->stripSlashes($_POST['copyright']));
449 $this->entry->setOutdated((int) $_POST['outdated']);
450
451 if (!$this->entry->validate()) {
452 ilUtil::sendInfo($this->lng->txt('fill_out_all_required_fields'));
453 $this->editEntry();
454 return false;
455 }
456 $this->entry->update();
457 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
458 $this->showCopyrightSettings();
459 return true;
460 }
461
462
468 protected function initSettingsForm()
469 {
470 global $DIC;
471
472 $ilAccess = $DIC['ilAccess'];
473
474 if (is_object($this->form)) {
475 return true;
476 }
477 include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
478 $this->form = new ilPropertyFormGUI();
479 $this->form->setFormAction($this->ctrl->getFormAction($this));
480 $this->form->setTitle($this->lng->txt('md_copyright_settings'));
481
482
483 if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
484 $this->form->addCommandButton('saveCopyrightSettings', $this->lng->txt('save'));
485 $this->form->addCommandButton('showCopyrightSettings', $this->lng->txt('cancel'));
486 }
487
488 $check = new ilCheckboxInputGUI($this->lng->txt('md_copyright_enabled'), 'active');
489 $check->setChecked($this->md_settings->isCopyrightSelectionActive());
490 $check->setValue(1);
491 $check->setInfo($this->lng->txt('md_copyright_enable_info'));
492 $this->form->addItem($check);
493
496 $this->form,
497 $this
498 );
499 }
500
508 public function initCopyrightEditForm($a_mode = 'edit')
509 {
510 if (is_object($this->form)) {
511 return true;
512 }
513 if (!is_object($this->entry)) {
514 include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
515 $this->entry = new ilMDCopyrightSelectionEntry((int) $_REQUEST['entry_id']);
516 }
517
518 include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
519 $this->form = new ilPropertyFormGUI();
520 $this->form->setFormAction($this->ctrl->getFormAction($this));
521
522 $tit = new ilTextInputGUI($this->lng->txt('title'), 'title');
523 $tit->setValue($this->entry->getTitle());
524 $tit->setRequired(true);
525 $tit->setSize(40);
526 $tit->setMaxLength(255);
527 $this->form->addItem($tit);
528
529 $des = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
530 $des->setValue($this->entry->getDescription());
531 $des->setRows(3);
532 $this->form->addItem($des);
533
534 $cop = new ilTextAreaInputGUI($this->lng->txt('md_copyright_value'), 'copyright');
535 $cop->setValue($this->entry->getCopyright());
536 $cop->setRows(5);
537 $this->form->addItem($cop);
538
539 $usage = new ilRadioGroupInputGUI($this->lng->txt('meta_copyright_usage'), 'outdated');
540 $use = new ilRadioOption($this->lng->txt('meta_copyright_in_use'), 0);
541 $out = new ilRadioOption($this->lng->txt('meta_copyright_outdated'), 1);
542 $usage->addOption($use);
543 $usage->addOption($out);
544 $usage->setValue($this->entry->getOutdated());
545 $this->form->addItem($usage);
546
547 switch ($a_mode) {
548 case 'edit':
549 $this->form->setTitle($this->lng->txt('md_copyright_edit'));
550 $this->form->addCommandButton('updateEntry', $this->lng->txt('save'));
551 $this->form->addCommandButton('showCopyrightSettings', $this->lng->txt('cancel'));
552 break;
553
554 case 'add':
555 $this->form->setTitle($this->lng->txt('md_copyright_add'));
556 $this->form->addCommandButton('saveEntry', $this->lng->txt('save'));
557 $this->form->addCommandButton('showCopyrightSettings', $this->lng->txt('cancel'));
558 break;
559 }
560 }
561
567 protected function initMDSettings()
568 {
569 include_once('Services/MetaData/classes/class.ilMDSettings.php');
570 $this->md_settings = ilMDSettings::_getInstance();
571 }
572
578 protected function stripSlashes($a_str)
579 {
580 if (ini_get("magic_quotes_gpc")) {
581 $a_str = stripslashes($a_str);
582 }
583 return $a_str;
584 }
585
589 public function saveCopyrightPosition()
590 {
591 if (!isset($_POST['order'])) {
592 $this->ctrl->redirect($this, 'showCopyrightSettings');
593 return false;
594 }
595
596 $positions = $_POST['order'];
597 asort($positions);
598 $position = 0;
599 foreach ($positions as $entry_id => $position_ignored) {
600 $copyright = new ilMDCopyrightSelectionEntry($entry_id);
601 $copyright->setOrderPosition($position++);
602 $copyright->update();
603 }
604 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
605 $this->ctrl->redirect($this, 'showCopyrightSettings');
606 return false;
607 }
608}
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static addFieldsToForm($a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
This class represents a checkbox property in a property form.
Confirmation screen class.
static _getInstance()
get instance
initMDSettings()
init Md settings
executeCommand()
Execute command.
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Contructor.
saveCopyrightPosition()
Save the order position to display the copyrights in the GUI table.
editEntry()
edit one selection
showGeneralSettings()
Edit general settings.
stripSlashes($a_str)
Special function to strip slashes for copyright fields.
initCopyrightEditForm($a_mode='edit')
@access public
initSettingsForm()
@access protected
saveGeneralSettings()
Save general settings.
showCopyrightSettings()
Edit copyright settings.
confirmDeleteEntries()
confirm deletion of entries
initGeneralSettingsForm($a_mode="edit")
Init general settings form.
saveCopyrightSettings()
Save news and external webfeeds settings.
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput($a_show_subobjects=true)
prepare output
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a text area property in a property form.
This class represents a text property in a property form.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
$type
global $DIC
Definition: saml.php:7