ILIAS  release_7 Revision v7.30-3-g800a261c036
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
42 protected $dic;
46 protected $error;
50 protected $rbacsystem;
56 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
57 {
58 global $DIC;
59 $this->dic = $DIC;
60 $this->error = $DIC['ilErr'];
61 $this->rbacsystem = $this->dic->rbac()->system();
62
63 $this->type = 'mds';
64 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
65
66 $this->lng = $this->dic->language();
67 $this->lng->loadLanguageModule("meta");
68 }
69
76 public function executeCommand()
77 {
78 $next_class = $this->ctrl->getNextClass($this);
79 $cmd = $this->ctrl->getCmd();
80
81 $this->prepareOutput();
82
83 if (!$this->rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
84 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
85 }
86
87 switch ($next_class) {
88 case 'iladvancedmdsettingsgui':
89 $this->tabs_gui->setTabActive('md_advanced');
90 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDSettingsGUI.php');
91 $adv_md = new ilAdvancedMDSettingsGUI();
92 $ret = $this->ctrl->forwardCommand($adv_md);
93 break;
94
95 case 'ilpermissiongui':
96 $this->tabs_gui->setTabActive('perm_settings');
97 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
98 $perm_gui = new ilPermissionGUI($this);
99 $ret = &$this->ctrl->forwardCommand($perm_gui);
100 break;
101
102 case 'ilmdcopyrightusagegui':
103 // this command is used if copyrightUsageGUI calls getParentReturn (see ...UsageGUI->setTabs)
104 $this->ctrl->setReturn($this, 'showCopyrightSettings');
105 $copyright_id = $_GET['entry_id'];
106 $gui = new ilMDCopyrightUsageGUI((int) $copyright_id);
107 $this->ctrl->forwardCommand($gui);
108 break;
109
110 default:
111 $this->initMDSettings();
112 if (!$cmd || $cmd == 'view') {
113 $cmd = "showGeneralSettings";
114 }
115
116 $this->$cmd();
117 break;
118 }
119 return true;
120 }
121
125 protected function getType()
126 {
127 return $this->type;
128 }
129
133 protected function getParentObjType()
134 {
135 return 'meta';
136 }
137
138
142 protected function getAdministrationFormId()
143 {
145 }
146
147
154 public function getAdminTabs()
155 {
156 global $DIC;
157
158 $rbacsystem = $DIC['rbacsystem'];
159 $ilAccess = $DIC['ilAccess'];
160
161 if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
162 $this->tabs_gui->addTarget(
163 "md_general_settings",
164 $this->ctrl->getLinkTarget($this, "showGeneralSettings"),
165 array("showGeneralSettings", "view")
166 );
167
168 $this->tabs_gui->addTarget(
169 "md_copyright",
170 $this->ctrl->getLinkTarget($this, "showCopyrightSettings"),
171 array("showCopyrightSettings")
172 );
173
174 $this->tabs_gui->addTarget(
175 "md_advanced",
176 $this->ctrl->getLinkTargetByClass('iladvancedmdsettingsgui', ""),
177 '',
178 'iladvancedmdsettingsgui'
179 );
180 }
181
182 if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
183 $this->tabs_gui->addTarget(
184 "perm_settings",
185 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
186 array(),
187 'ilpermissiongui'
188 );
189 }
190 }
191
195 public function showGeneralSettings()
196 {
197 global $DIC;
198
199 $tpl = $DIC['tpl'];
200
202 $tpl->setContent($this->form->getHTML());
203 }
204
210 public function initGeneralSettingsForm($a_mode = "edit")
211 {
212 global $DIC;
213
214 $lng = $DIC['lng'];
215 $ilAccess = $DIC['ilAccess'];
216
217 $this->tabs_gui->setTabActive('md_general_settings');
218
219 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
220 $this->form = new ilPropertyFormGUI();
221
222 $ti = new ilTextInputGUI($this->lng->txt("md_delimiter"), "delimiter");
223 $ti->setInfo($this->lng->txt("md_delimiter_info"));
224 $ti->setMaxLength(1);
225 $ti->setSize(1);
226 $ti->setValue($this->md_settings->getDelimiter());
227 $this->form->addItem($ti);
228
229 if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
230 $this->form->addCommandButton("saveGeneralSettings", $lng->txt("save"));
231 $this->form->addCommandButton("showGeneralSettings", $lng->txt("cancel"));
232 }
233
234 $this->form->setTitle($lng->txt("md_general_settings"));
235 $this->form->setFormAction($this->ctrl->getFormAction($this));
236 }
237
241 public function saveGeneralSettings()
242 {
243 global $DIC;
244
245 $ilCtrl = $DIC['ilCtrl'];
246 $ilAccess = $DIC['ilAccess'];
247
248 if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
249 $ilCtrl->redirect($this, "showGeneralSettings");
250 }
251
252 $delim = (trim($_POST['delimiter']) == "")
253 ? ","
254 : trim($_POST['delimiter']);
255 $this->md_settings->setDelimiter($delim);
256 $this->md_settings->save();
257 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
258
259 $ilCtrl->redirect($this, "showGeneralSettings");
260 }
261
262
266 public function showCopyrightSettings()
267 {
268 global $DIC;
269
270 $ilAccess = $DIC['ilAccess'];
271
272 $this->tabs_gui->setTabActive('md_copyright');
273 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.settings.html', 'Services/MetaData');
274
275 $this->initSettingsForm();
276 $this->tpl->setVariable('SETTINGS_TABLE', $this->form->getHTML());
277
278 $has_write = $ilAccess->checkAccess('write', '', $this->object->getRefId());
279
280 include_once("./Services/MetaData/classes/class.ilMDCopyrightTableGUI.php");
281 $table_gui = new ilMDCopyrightTableGUI($this, 'showCopyrightSettings', $has_write);
282 $table_gui->setTitle($this->lng->txt("md_copyright_selection"));
283 $table_gui->parseSelections();
284
285 if ($has_write) {
286 // $table_gui->addCommandButton("updateCopyrightSelection", $this->lng->txt("save"));
287 $table_gui->addCommandButton('addEntry', $this->lng->txt('add'));
288 $table_gui->addMultiCommand("confirmDeleteEntries", $this->lng->txt("delete"));
289 $table_gui->setSelectAllCheckbox("entry_id");
290 }
291
292 $this->tpl->setVariable('COPYRIGHT_TABLE', $table_gui->getHTML());
293 }
294
298 public function saveCopyrightSettings()
299 {
300 global $DIC;
301
302 $ilAccess = $DIC['ilAccess'];
303
304 if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
305 $this->ctrl->redirect($this, "showCopyrightSettings");
306 }
307
308 $this->md_settings->activateCopyrightSelection((int) $_POST['active']);
309 $this->md_settings->save();
310 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
311 $this->showCopyrightSettings();
312 }
313
314 public function showCopyrightUsages()
315 {
316 $this->ctrl->setParameterByClass('ilmdcopyrightusagegui', 'entry_id', $_GET['entry_id']);
317 $this->ctrl->redirectByClass('ilmdcopyrightusagegui', "showUsageTable");
318 }
319
326 public function editEntry()
327 {
328 $this->ctrl->saveParameter($this, 'entry_id');
329 $this->initCopyrightEditForm();
330 $this->tpl->setContent($this->form->getHTML());
331 }
332
340 public function addEntry()
341 {
342 $this->initCopyrightEditForm('add');
343 $this->tpl->setContent($this->form->getHTML());
344 }
345
346
353 public function saveEntry()
354 {
355 global $DIC;
356
357 $ilErr = $DIC['ilErr'];
358
359 include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
360 $this->entry = new ilMDCopyrightSelectionEntry(0);
361
362 $this->entry->setTitle(ilUtil::stripSlashes($_POST['title']));
363 $this->entry->setDescription(ilUtil::stripSlashes($_POST['description']));
364 $this->entry->setCopyright($this->stripSlashes($_POST['copyright']));
365 $this->entry->setLanguage('en');
366 $this->entry->setCopyrightAndOtherRestrictions(true);
367 $this->entry->setCosts(false);
368 $this->entry->setOutdated((int) $_POST['outdated']);
369
370 if (!$this->entry->validate()) {
371 ilUtil::sendInfo($this->lng->txt('fill_out_all_required_fields'));
372 $this->addEntry();
373 return false;
374 }
375 $this->entry->add();
376 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
377 $this->showCopyrightSettings();
378 return true;
379 }
380
387 public function confirmDeleteEntries()
388 {
389 if (!is_array($_POST['entry_id']) or !count($_POST['entry_id'])) {
390 ilUtil::sendInfo($this->lng->txt('select_one'));
391 $this->showCopyrightSettings();
392 return true;
393 }
394
395 include_once('Services/Utilities/classes/class.ilConfirmationGUI.php');
396 $c_gui = new ilConfirmationGUI();
397
398 // set confirm/cancel commands
399 $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteEntries"));
400 $c_gui->setHeaderText($this->lng->txt("md_delete_cp_sure"));
401 $c_gui->setCancel($this->lng->txt("cancel"), "showCopyrightSettings");
402 $c_gui->setConfirm($this->lng->txt("confirm"), "deleteEntries");
403
404 include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
405
406 // add items to delete
407 foreach ($_POST["entry_id"] as $entry_id) {
408 $entry = new ilMDCopyrightSelectionEntry($entry_id);
409 $c_gui->addItem('entry_id[]', $entry_id, $entry->getTitle());
410 }
411 $this->tpl->setContent($c_gui->getHTML());
412 }
413
420 public function deleteEntries()
421 {
422 if (!is_array($_POST['entry_id']) or !count($_POST['entry_id'])) {
423 ilUtil::sendInfo($this->lng->txt('select_one'));
424 $this->showCopyrightSettings();
425 return true;
426 }
427
428 include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
429 foreach ($_POST["entry_id"] as $entry_id) {
430 $entry = new ilMDCopyrightSelectionEntry($entry_id);
431 $entry->delete();
432 }
433 ilUtil::sendSuccess($this->lng->txt('md_copyrights_deleted'));
434 $this->showCopyrightSettings();
435 return true;
436 }
437
444 public function updateEntry()
445 {
446 global $DIC;
447
448 $ilErr = $DIC['ilErr'];
449
450 include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
451 $this->entry = new ilMDCopyrightSelectionEntry((int) $_REQUEST['entry_id']);
452
453 $this->entry->setTitle(ilUtil::stripSlashes($_POST['title']));
454 $this->entry->setDescription(ilUtil::stripSlashes($_POST['description']));
455 $this->entry->setCopyright($this->stripSlashes($_POST['copyright']));
456 $this->entry->setOutdated((int) $_POST['outdated']);
457
458 if (!$this->entry->validate()) {
459 ilUtil::sendInfo($this->lng->txt('fill_out_all_required_fields'));
460 $this->editEntry();
461 return false;
462 }
463 $this->entry->update();
464 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
465 $this->showCopyrightSettings();
466 return true;
467 }
468
469
475 protected function initSettingsForm()
476 {
477 global $DIC;
478
479 $ilAccess = $DIC['ilAccess'];
480
481 if (is_object($this->form)) {
482 return true;
483 }
484 include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
485 $this->form = new ilPropertyFormGUI();
486 $this->form->setFormAction($this->ctrl->getFormAction($this));
487 $this->form->setTitle($this->lng->txt('md_copyright_settings'));
488
489
490 if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
491 $this->form->addCommandButton('saveCopyrightSettings', $this->lng->txt('save'));
492 $this->form->addCommandButton('showCopyrightSettings', $this->lng->txt('cancel'));
493 }
494
495 $check = new ilCheckboxInputGUI($this->lng->txt('md_copyright_enabled'), 'active');
496 $check->setChecked($this->md_settings->isCopyrightSelectionActive());
497 $check->setValue(1);
498 $check->setInfo($this->lng->txt('md_copyright_enable_info'));
499 $this->form->addItem($check);
500
503 $this->form,
504 $this
505 );
506 }
507
515 public function initCopyrightEditForm($a_mode = 'edit')
516 {
517 if (is_object($this->form)) {
518 return true;
519 }
520 if (!is_object($this->entry)) {
521 include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
522 $this->entry = new ilMDCopyrightSelectionEntry((int) $_REQUEST['entry_id']);
523 }
524
525 include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
526 $this->form = new ilPropertyFormGUI();
527 $this->form->setFormAction($this->ctrl->getFormAction($this));
528
529 $tit = new ilTextInputGUI($this->lng->txt('title'), 'title');
530 $tit->setValue($this->entry->getTitle());
531 $tit->setRequired(true);
532 $tit->setSize(40);
533 $tit->setMaxLength(255);
534 $this->form->addItem($tit);
535
536 $des = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
537 $des->setValue($this->entry->getDescription());
538 $des->setRows(3);
539 $this->form->addItem($des);
540
541 $cop = new ilTextAreaInputGUI($this->lng->txt('md_copyright_value'), 'copyright');
542 $cop->setValue($this->entry->getCopyright());
543 $cop->setRows(5);
544 $this->form->addItem($cop);
545
546 $usage = new ilRadioGroupInputGUI($this->lng->txt('meta_copyright_usage'), 'outdated');
547 $use = new ilRadioOption($this->lng->txt('meta_copyright_in_use'), 0);
548 $out = new ilRadioOption($this->lng->txt('meta_copyright_outdated'), 1);
549 $usage->addOption($use);
550 $usage->addOption($out);
551 $usage->setValue($this->entry->getOutdated());
552 $this->form->addItem($usage);
553
554 switch ($a_mode) {
555 case 'edit':
556 $this->form->setTitle($this->lng->txt('md_copyright_edit'));
557 $this->form->addCommandButton('updateEntry', $this->lng->txt('save'));
558 $this->form->addCommandButton('showCopyrightSettings', $this->lng->txt('cancel'));
559 break;
560
561 case 'add':
562 $this->form->setTitle($this->lng->txt('md_copyright_add'));
563 $this->form->addCommandButton('saveEntry', $this->lng->txt('save'));
564 $this->form->addCommandButton('showCopyrightSettings', $this->lng->txt('cancel'));
565 break;
566 }
567 }
568
574 protected function initMDSettings()
575 {
576 include_once('Services/MetaData/classes/class.ilMDSettings.php');
577 $this->md_settings = ilMDSettings::_getInstance();
578 }
579
585 protected function stripSlashes($a_str)
586 {
587 if (ini_get("magic_quotes_gpc")) {
588 $a_str = stripslashes($a_str);
589 }
590 return $a_str;
591 }
592
596 public function saveCopyrightPosition()
597 {
598 if (!isset($_POST['order'])) {
599 $this->ctrl->redirect($this, 'showCopyrightSettings');
600 return false;
601 }
602
603 $positions = $_POST['order'];
604 asort($positions);
605 $position = 0;
606 foreach ($positions as $entry_id => $position_ignored) {
607 $copyright = new ilMDCopyrightSelectionEntry($entry_id);
608 $copyright->setOrderPosition($position++);
609 $copyright->update();
610 }
611 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
612 $this->ctrl->redirect($this, 'showCopyrightSettings');
613 return false;
614 }
615}
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
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 $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6
$type