ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjLinkResourceGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once "./classes/class.ilObjectGUI.php";
6 include_once('./Modules/WebResource/classes/class.ilParameterAppender.php');
7 require_once 'Services/LinkChecker/interfaces/interface.ilLinkCheckerGUIRowHandling.php';
8 
22 {
23  const VIEW_MODE_VIEW = 1;
24  const VIEW_MODE_MANAGE = 2;
25  const VIEW_MODE_SORT = 3;
26 
27  const LINK_MOD_CREATE = 1;
28  const LINK_MOD_EDIT = 2;
29  const LINK_MOD_ADD = 3;
30 
35  function __construct()
36  {
37  global $ilCtrl;
38 
39  $this->type = "webr";
40  parent::__construct('',(int) $_GET['ref_id'],true,false);
41 
42  // CONTROL OPTIONS
43  $this->ctrl = $ilCtrl;
44  $this->ctrl->saveParameter($this,array("ref_id","cmdClass"));
45 
46  $this->lng->loadLanguageModule('webr');
47  }
48 
49  public function executeCommand()
50  {
51  global $ilCtrl, $ilTabs, $ilAccess, $ilErr;
52 
53 
54  //if($this->ctrl->getTargetScript() == 'link_resources.php')
55  if($_GET["baseClass"] == 'ilLinkResourceHandlerGUI')
56  {
57  $_GET['view_mode'] = isset($_GET['switch_mode']) ? $_GET['switch_mode'] : $_GET['view_mode'];
58  $ilCtrl->saveParameter($this, 'view_mode');
59  $this->__prepareOutput();
60  }
61 
62  if (strtolower($_GET["baseClass"]) == "iladministrationgui" ||
63  $this->getCreationMode() == true)
64  {
65  $this->prepareOutput();
66  }
67 
68 
69  $next_class = $this->ctrl->getNextClass($this);
70  $cmd = $this->ctrl->getCmd();
71 
72  switch($next_class)
73  {
74  case "ilinfoscreengui":
75  $this->infoScreen(); // forwards command
76  break;
77 
78  case 'ilmdeditorgui':
79  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
80  {
81  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
82  }
83 
84  $ilTabs->activateTab('id_meta_data');
85  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
86  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
87  $md_gui->addObserver($this->object,'MDUpdateListener','General');
88  $this->ctrl->forwardCommand($md_gui);
89  break;
90 
91  case 'ilpermissiongui':
92  $ilTabs->activateTab('id_permissions');
93  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
94  $perm_gui =& new ilPermissionGUI($this);
95  $ret =& $this->ctrl->forwardCommand($perm_gui);
96  break;
97 
98  case 'ilobjectcopygui':
99  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
100  $cp = new ilObjectCopyGUI($this);
101  $cp->setType('webr');
102  $this->ctrl->forwardCommand($cp);
103  break;
104 
105  case 'ilexportgui':
106  $this->tabs_gui->setTabActive('export');
107  include_once './Services/Export/classes/class.ilExportGUI.php';
108  $exp = new ilExportGUI($this);
109  $exp->addFormat('xml');
110  $this->ctrl->forwardCommand($exp);
111  break;
112 
113  default:
114 
115  if(!$cmd)
116  {
117  $cmd = "view";
118  }
119  $cmd .= "Object";
120  $this->$cmd();
121 
122  break;
123  }
124 
125  if(!$this->getCreationMode())
126  {
127  // Fill meta header tags
128  include_once('Services/MetaData/classes/class.ilMDUtils.php');
129  ilMDUtils::_fillHTMLMetaTags($this->object->getId(),$this->object->getId(),'webr');
130  }
131  return true;
132  }
133 
141  public function createObject()
142  {
143  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.webr_create.html','Modules/WebResource');
144  $this->initFormLink(self::LINK_MOD_CREATE);
145  $this->tpl->setVariable('LINK_FORM',$this->form->getHTML());
146 
147  $this->fillCloneTemplate('CLONE_WIZARD',$_REQUEST['new_type']);
148 
149  $this->initImportForm("webr");
150  $this->tpl->setVariable("IMPORT_FORM", $this->form->getHTML());
151  }
152 
158  public function initImportForm($a_new_type = "")
159  {
160  global $lng, $ilCtrl;
161 
162  $lng->loadLanguageModule("webr");
163 
164  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
165  $this->form = new ilPropertyFormGUI();
166  $this->form->setTableWidth('600px');
167  $this->form->setTarget("_top");
168 
169  // Import file
170  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
171  $fi = new ilFileInputGUI($lng->txt("import_file"), "importfile");
172  $fi->setSuffixes(array("zip"));
173  $fi->setRequired(true);
174  $this->form->addItem($fi);
175 
176  $this->form->addCommandButton("importFile", $lng->txt("import"));
177  $this->form->addCommandButton("cancel", $lng->txt("cancel"));
178  $this->form->setTitle($lng->txt($a_new_type."_import"));
179 
180  $this->form->setFormAction($ilCtrl->getFormAction($this));
181  }
182 
188  protected function importFileObject()
189  {
190  global $rbacsystem, $objDefinition, $tpl, $lng, $ilErr;
191 
192  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
193 
194  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
195  if (!$rbacsystem->checkAccess("create", $this->object->getRefId(), $new_type))
196  {
197  $ilErr->raiseError($this->lng->txt('no_create_permission'),$ilErr->MESSAGE);
198  }
199  $this->ctrl->setParameter($this, "new_type", $new_type);
200  $this->initImportForm($new_type);
201  if ($this->form->checkInput())
202  {
203  include_once './Services/Export/classes/class.ilImport.php';
204  $imp = new ilImport((int) $_GET['ref_id']);
205  $new_id = $imp->importObject(null, $_FILES["importfile"]["tmp_name"],$_FILES["importfile"]["name"], $new_type);
206 
207  // put new object id into tree
208  if ($new_id > 0)
209  {
210  $newObj = ilObjectFactory::getInstanceByObjId($new_id);
211  $newObj->createReference();
212  $newObj->putInTree($_GET["ref_id"]);
213  $newObj->setPermissions($_GET["ref_id"]);
214  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
215  $this->ctrl->returnToParent($this);
216  }
217  return;
218  }
219 
220  $this->form->setValuesByPost();
221  $tpl->setContent($this->form->getHtml());
222  }
223 
224 
229  public function saveObject()
230  {
231  global $ilCtrl;
232 
233  $this->initFormLink(self::LINK_MOD_CREATE);
234  if($this->checkLinkInput(self::LINK_MOD_CREATE,0,0))
235  {
236  // Save new object
237  $_POST['Fobject']['title'] = $_POST['tit'];
238  $_POST['Fobject']['desc'] = $_POST['des'];
239  $link_list = parent::saveObject();
240 
241  // Save link
242  $this->link->setLinkResourceId($link_list->getId());
243  $link_id = $this->link->add();
244 
245  // Dynamic params
246  if(ilParameterAppender::_isEnabled() and is_object($this->dynamic))
247  {
248  $this->dynamic->setObjId($link_list->getId());
249  $this->dynamic->add($link_id);
250  }
251 
252  ilUtil::sendSuccess($this->lng->txt('webr_link_added'));
253  ilUtil::redirect("ilias.php?baseClass=ilLinkResourceHandlerGUI&ref_id=".
254  $link_list->getRefId()."&cmd=view");
255  return true;
256  }
257  // Data incomplete or invalid
258  ilUtil::sendFailure($this->lng->txt('err_check_input'));
259  $this->form->setValuesByPost();
260 
261  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.webr_create.html','Modules/WebResource');
262  $this->tpl->setVariable('LINK_FORM',$this->form->getHTML());
263 
264  $this->fillCloneTemplate('CLONE_WIZARD',$_REQUEST['new_type']);
265  return false;
266 
267 
268  if ($_POST["Fobject"]["title"] == "")
269  {
270  ilUtil::sendFailure($this->lng->txt('please_enter_title'));
271  $this->createObject();
272  return false;
273  }
274  }
275 
281  protected function settingsObject()
282  {
283  global $ilTabs;
284 
285  $this->checkPermission('write');
286  $ilTabs->activateTab('id_settings');
287 
288  $this->initFormSettings();
289  $this->tpl->setContent($this->form->getHTML());
290  }
291 
296  protected function saveSettingsObject()
297  {
298  global $ilTabs;
299 
300  $this->checkPermission('write');
301  $ilTabs->activateTab('id_settings');
302 
303  $this->initFormSettings();
304  if($this->form->checkInput())
305  {
306  $this->object->setTitle($this->form->getInput('tit'));
307  $this->object->setDescription($this->form->getInput('des'));
308  $this->object->update();
309 
310  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
311  $sort = new ilContainerSortingSettings($this->object->getId());
312  $sort->setSortMode($this->form->getInput('sor'));
313  $sort->update();
314 
315  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
316  $this->ctrl->redirect($this,'settings');
317  }
318 
319  $this->form->setValuesByPost();
320  ilUtil::sendFailure($this->lng->txt('err_check_input'));
321  $this->tpl->setContent($this->form->getHTML());
322  }
323 
324 
329  protected function initFormSettings()
330  {
331  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
332  $this->form = new ilPropertyFormGUI();
333  $this->form->setFormAction($this->ctrl->getFormAction($this,'saveSettings'));
334  $this->form->setTitle($this->lng->txt('webr_edit_settings'));
335 
336  // Title
337  $tit = new ilTextInputGUI($this->lng->txt('webr_list_title'),'tit');
338  $tit->setValue($this->object->getTitle());
339  $tit->setRequired(true);
340  $tit->setSize(40);
341  $tit->setMaxLength(127);
342  $this->form->addItem($tit);
343 
344  // Description
345  $des = new ilTextAreaInputGUI($this->lng->txt('webr_list_desc'),'des');
346  $des->setValue($this->object->getDescription());
347  $des->setCols(40);
348  $des->setRows(3);
349  $this->form->addItem($des);
350 
351  // Sorting
352  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
353  include_once './Services/Container/classes/class.ilContainer.php';
354 
355  $sor = new ilRadioGroupInputGUI($this->lng->txt('webr_sorting'),'sor');
356  $sor->setRequired(true);
357  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
358  $sor->setValue(ilContainerSortingSettings::_lookupSortMode($this->object->getId()));
359 
360  $opt = new ilRadioOption(
361  $this->lng->txt('webr_sort_title'),
363  );
364  $sor->addOption($opt);
365 
366  $opm = new ilRadioOption(
367  $this->lng->txt('webr_sort_manual'),
369  );
370  $sor->addOption($opm);
371  $this->form->addItem($sor);
372 
373  $this->form->addCommandButton('saveSettings', $this->lng->txt('save'));
374  $this->form->addCommandButton('view', $this->lng->txt('cancel'));
375  }
376 
377 
382  public function editLinkObject()
383  {
384  global $ilCtrl;
385 
386  $this->checkPermission('write');
387  $this->activateTabs('content','id_content_view');
388 
389  if(!(int) $_GET['link_id'])
390  {
391  ilUtil::sendFailure($this->lng->txt('select_one'),true);
392  $ilCtrl->redirect($this,'view');
393  }
394 
395  $this->initFormLink(self::LINK_MOD_EDIT);
396  $this->setValuesFromLink((int) $_GET['link_id']);
397  $this->tpl->setContent($this->form->getHTML());
398  }
399 
404  public function updateLinkObject()
405  {
406  global $ilCtrl;
407 
408  $this->initFormLink(self::LINK_MOD_EDIT);
409  if($this->checkLinkInput(self::LINK_MOD_EDIT,$this->object->getId(),(int) $_REQUEST['link_id']))
410  {
411  $this->link->setLinkId((int) $_REQUEST['link_id']);
412  $this->link->update();
413  if(ilParameterAppender::_isEnabled() and is_object($this->dynamic))
414  {
415  $this->dynamic->add((int) $_REQUEST['link_id']);
416  }
417 
418  if($this->isContainerMetaDataRequired())
419  {
420  $this->object->setTitle($this->form->getInput('tit'));
421  $this->object->setDescription($this->form->getInput('des'));
422  $this->object->update();
423  }
424 
425  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
426  $ilCtrl->redirect($this,'view');
427  }
428  ilUtil::sendFailure($this->lng->txt('err_check_input'));
429  $this->form->setValuesByPost();
430  $this->tpl->setContent($this->form->getHTML());
431  }
432 
437  public function addLinkObject()
438  {
439  $this->checkPermission('write');
440  $this->activateTabs('content','id_content_view');
441 
442  $this->initFormLink(self::LINK_MOD_ADD);
443  $this->tpl->setContent($this->form->getHTML());
444  }
445 
450  public function saveAddLinkObject()
451  {
452  global $ilCtrl;
453 
454  $this->checkPermission('write');
455 
456  $this->initFormLink(self::LINK_MOD_ADD);
457  if($this->checkLinkInput(self::LINK_MOD_ADD,$this->object->getId(),0))
458  {
459  if($this->isContainerMetaDataRequired())
460  {
461  // Save list data
462  $this->object->setTitle($this->form->getInput('lti'));
463  $this->object->setDescription($this->form->getInput('lde'));
464  $this->object->update();
465  }
466 
467  // Save Link
468  $link_id = $this->link->add();
469 
470  // Dynamic parameters
471  if(ilParameterAppender::_isEnabled() and is_object($this->dynamic))
472  {
473  $this->dynamic->add($link_id);
474  }
475  ilUtil::sendSuccess($this->lng->txt('webr_link_added'),true);
476  $ilCtrl->redirect($this,'view');
477  }
478  // Error handling
479  ilUtil::sendFailure($this->lng->txt('err_check_input'));
480  $this->form->setValuesByPost();
481 
482  $this->activateTabs('content','id_content_view');
483  $this->tpl->setContent($this->form->getHTML());
484  }
485 
490  protected function deleteParameterObject()
491  {
492  global $ilCtrl;
493 
494  $this->checkPermission('write');
495 
496  $this->ctrl->setParameter($this,'link_id',(int) $_GET['link_id']);
497 
498  if(!isset($_GET['param_id']))
499  {
500  ilUtil::sendFailure($this->lng->txt('select_one'),TRUE);
501  $ilCtrl->redirect($this,'view');
502  }
503 
504  include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
505  $param = new ilParameterAppender($this->object->getId());
506  $param->delete((int) $_GET['param_id']);
507 
508  ilUtil::sendSuccess($this->lng->txt('links_parameter_deleted'),true);
509  $ilCtrl->redirect($this,'editLink');
510  }
511 
512  protected function deleteParameterFormObject()
513  {
514  global $ilCtrl;
515 
516  $this->checkPermission('write');
517 
518  if(!isset($_GET['param_id']))
519  {
520  ilUtil::sendFailure($this->lng->txt('select_one'),TRUE);
521  $ilCtrl->redirect($this,'view');
522  }
523 
524  include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
525  $param = new ilParameterAppender($this->object->getId());
526  $param->delete((int) $_GET['param_id']);
527 
528  ilUtil::sendSuccess($this->lng->txt('links_parameter_deleted'),true);
529  $ilCtrl->redirect($this,'view');
530 
531  }
532 
533 
538  protected function updateLinksObject()
539  {
540  global $ilCtrl;
541 
542  $this->checkPermission('write');
543  $this->activateTabs('content','');
544 
545  if(!is_array($_POST['ids']))
546  {
547  ilUtil::sendFailure($this->lng->txt('select_one'),TRUE);
548  $ilCtrl->redirect($this,'view');
549  }
550 
551  // Validate
552  $invalid = array();
553  foreach($_POST['ids'] as $link_id)
554  {
555  $data = $_POST['links'][$link_id];
556 
557  if(!strlen($data['tit']))
558  {
559  $invalid[] = $link_id;
560  continue;
561  }
562  if(!strlen($data['tar']))
563  {
564  $invalid[] = $link_id;
565  continue;
566  }
567  if($data['nam'] and !$data['val'])
568  {
569  $invalid[] = $link_id;
570  continue;
571  }
572  if(!$data['nam'] and $data['val'])
573  {
574  $invalid[] = $link_id;
575  continue;
576  }
577  }
578 
579  if(count($invalid))
580  {
581  ilUtil::sendFailure($this->lng->txt('err_check_input'));
582  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.webr_manage.html','Modules/WebResource');
583 
584  include_once './Modules/WebResource/classes/class.ilWebResourceEditableLinkTableGUI.php';
585  $table = new ilWebResourceEditableLinkTableGUI($this,'view');
586  $table->setInvalidLinks($invalid);
587  $table->parseSelectedLinks($_POST['ids']);
588  $table->updateFromPost();
589  $this->tpl->setVariable('TABLE_LINKS',$table->getHTML());
590  return false;
591  }
592 
593  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
594  $links = new ilLinkResourceItems($this->object->getId());
595 
596  // Save Settings
597  foreach($_POST['ids'] as $link_id)
598  {
599  $data = $_POST['links'][$link_id];
600 
601  $links->setLinkId($link_id);
602  $links->setTitle(ilUtil::stripSlashes($data['tit']));
603  $links->setDescription(ilUtil::stripSlashes($data['des']));
604  $links->setTarget(ilUtil::stripSlashes($data['tar']));
605  $links->setActiveStatus((int) $data['act']);
606  $links->setDisableCheckStatus((int) $data['che']);
607  $links->setValidStatus((int) $data['vali']);
608  $links->update();
609 
610  if(strlen($data['nam']) and $data['val'])
611  {
612  $param = new ilParameterAppender($this->object->getId());
613  $param->setName(ilUtil::stripSlashes($data['nam']));
614  $param->setValue((int) $data['val']);
615  $param->add($link_id);
616  }
617 
618  if($this->isContainerMetaDataRequired())
619  {
620  $this->object->setTitle(ilUtil::stripSlashes($data['tit']));
621  $this->object->setDescription(ilUtil::stripSlashes($data['des']));
622  $this->object->update();
623  }
624 
625  // TODO: Dynamic parameters
626  }
627 
628  ilUtil::sendSuccess($this->lng->txt('settings_saved'),TRUE);
629  $ilCtrl->redirect($this,'view');
630  }
631 
637  protected function setValuesFromLink($a_link_id)
638  {
639  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
640  $link = new ilLinkResourceItems($this->object->getId());
641 
642  $values = $link->getItem($a_link_id);
643 
645  {
646  }
647 
648  $this->form->setValuesByArray(
649  array(
650  'tit' => $values['title'],
651  'tar' => $values['target'],
652  'des' => $values['description'],
653  'act' => (int) $values['active'],
654  'che' => (int) $values['disable_check'],
655  'vali' => (int) $values['valid']
656  )
657  );
658  }
659 
660 
668  protected function checkLinkInput($a_mode,$a_webr_id = 0,$a_link_id = 0)
669  {
670  $valid = $this->form->checkInput();
671 
672  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
673  $this->link = new ilLinkResourceItems($a_webr_id);
674  $this->link->setTarget($this->form->getInput('tar'));
675  $this->link->setTitle($this->form->getInput('tit'));
676  $this->link->setDescription($this->form->getInput('des'));
677  $this->link->setDisableCheckStatus($this->form->getInput('che'));
678  $this->link->setActiveStatus($this->form->getInput('act'));
679 
680  if($a_mode == self::LINK_MOD_EDIT)
681  {
682  $this->link->setValidStatus($this->form->getInput('val'));
683  }
684 
686  {
687  return $valid;
688  }
689 
690  $this->dynamic = new ilParameterAppender($a_webr_id);
691  $this->dynamic->setName($this->form->getInput('nam'));
692  $this->dynamic->setValue($this->form->getInput('val'));
693  if(!$this->dynamic->validate())
694  {
695  switch($this->dynamic->getErrorCode())
696  {
697  case LINKS_ERR_NO_NAME:
698  $this->form->getItemByPostVar('nam')->setAlert($this->lng->txt('links_no_name_given'));
699  return false;
700 
701  case LINKS_ERR_NO_VALUE:
702  $this->form->getItemByPostVar('val')->setAlert($this->lng->txt('links_no_value_given'));
703  return false;
704 
706  // Nothing entered => no error
707  return $valid;
708  }
709  $this->dynamic = null;
710  }
711  return $valid;
712  }
713 
714 
720  protected function initFormLink($a_mode)
721  {
722  global $ilTabs;
723 
724  $ilTabs->activateTab("id_content");
725 
726  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
727  $this->form = new ilPropertyFormGUI();
728 
729  switch($a_mode)
730  {
731  case self::LINK_MOD_CREATE:
732  // Header
733  $this->ctrl->setParameter($this,'new_type','webr');
734  $this->form->setTitle($this->lng->txt('webr_new_link'));
735  $this->form->setTableWidth('600px');
736 
737  // Buttons
738  $this->form->addCommandButton('save', $this->lng->txt('webr_add'));
739  $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
740  break;
741 
742  case self::LINK_MOD_ADD:
743  // Header
744  $this->form->setTitle($this->lng->txt('webr_new_link'));
745 
746  // Buttons
747  $this->form->addCommandButton('saveAddLink', $this->lng->txt('webr_add'));
748  $this->form->addCommandButton('view', $this->lng->txt('cancel'));
749  break;
750 
751  case self::LINK_MOD_EDIT:
752  // Header
753  $this->ctrl->setParameter($this,'link_id',(int) $_REQUEST['link_id']);
754  $this->form->setTitle($this->lng->txt('webr_edit'));
755 
756  // Buttons
757  $this->form->addCommandButton('updateLink', $this->lng->txt('save'));
758  $this->form->addCommandButton('view', $this->lng->txt('cancel'));
759  break;
760  }
761 
762 
763  $this->form->setFormAction($this->ctrl->getFormAction($this));
764 
765  if($a_mode == self::LINK_MOD_ADD and $this->isContainerMetaDataRequired())
766  {
767  ilUtil::sendInfo($this->lng->txt('webr_container_info'));
768 
769 
770  $this->form->setTitle($this->lng->txt('webr_edit_list'));
771 
772  // List Title
773  $title = new ilTextInputGUI($this->lng->txt('webr_list_title'),'lti');
774  $title->setRequired(true);
775  $title->setSize(40);
776  $title->setMaxLength(127);
777  $this->form->addItem($title);
778 
779  // List Description
780  $desc = new ilTextAreaInputGUI($this->lng->txt('webr_list_desc'),'tde');
781  $desc->setRows(3);
782  $desc->setCols(40);
783  $this->form->addItem($desc);
784 
785  // Addtional section
786  $sect = new ilFormSectionHeaderGUI();
787  $sect->setTitle($this->lng->txt('webr_add'));
788  $this->form->addItem($sect);
789  }
790 
791  // Target
792  $tar = new ilTextInputGUI($this->lng->txt('webr_link_target'),'tar');
793  $tar->setValue("http://");
794  $tar->setRequired(true);
795  $tar->setSize(40);
796  $tar->setMaxLength(500);
797  $this->form->addItem($tar);
798 
799  // Title
800  $tit = new ilTextInputGUI($this->lng->txt('webr_link_title'),'tit');
801  $tit->setRequired(true);
802  $tit->setSize(40);
803  $tit->setMaxLength(127);
804  $this->form->addItem($tit);
805 
806  // Description
807  $des = new ilTextAreaInputGUI($this->lng->txt('description'),'des');
808  $des->setRows(3);
809  $des->setCols(40);
810  $this->form->addItem($des);
811 
812  // Active
813  $act = new ilCheckboxInputGUI($this->lng->txt('active'),'act');
814  $act->setChecked(true);
815  $act->setValue(1);
816  $this->form->addItem($act);
817 
818  // Check
819  $che = new ilCheckboxInputGUI($this->lng->txt('webr_disable_check'),'che');
820  $che->setValue(1);
821  $this->form->addItem($che);
822 
823  // Valid
824  if($a_mode == self::LINK_MOD_EDIT)
825  {
826  $val = new ilCheckboxInputGUI($this->lng->txt('valid'),'vali');
827  $this->form->addItem($val);
828  }
829 
831  {
832  $dyn = new ilNonEditableValueGUI($this->lng->txt('links_dyn_parameter'));
833  $dyn->setInfo($this->lng->txt('links_dynamic_info'));
834 
835 
836  if(count($links = ilParameterAppender::_getParams((int) $_GET['link_id'])))
837  {
838  $ex = new ilCustomInputGUI($this->lng->txt('links_existing_params'),'ex');
839  $dyn->addSubItem($ex);
840 
841  foreach($links as $id => $link)
842  {
843  $p = new ilCustomInputGUI();
844 
845  $ptpl = new ilTemplate('tpl.link_dyn_param_edit.html',true,true,'Modules/WebResource');
846  $ptpl->setVariable('INFO_TXT',ilParameterAppender::parameterToInfo($link['name'], $link['value']));
847  $this->ctrl->setParameter($this,'param_id',$id);
848  $ptpl->setVariable('LINK_DEL',$this->ctrl->getLinkTarget($this,'deleteParameterForm'));
849  $ptpl->setVariable('LINK_TXT',$this->lng->txt('delete'));
850  $p->setHtml($ptpl->get());
851  $dyn->addSubItem($p);
852  }
853  }
854 
855  // Existing parameters
856 
857  // New parameter
858  if($a_mode == self::LINK_MOD_EDIT)
859  {
860  #$new = new ilCustomInputGUI($this->lng->txt('links_add_param'),'');
861  #$dyn->addSubItem($new);
862  }
863 
864  // Dynyamic name
865  $nam = new ilTextInputGUI($this->lng->txt('links_name'),'nam');
866  $nam->setSize(12);
867  $nam->setMaxLength(128);
868  $dyn->addSubItem($nam);
869 
870  // Dynamic value
871  $val = new ilSelectInputGUI($this->lng->txt('links_value'),'val');
873  $val->setValue(0);
874  $dyn->addSubItem($val);
875 
876  $this->form->addItem($dyn);
877  }
878  }
879 
885  protected function isContainerMetaDataRequired()
886  {
887  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
888  return ilLinkResourceItems::lookupNumberOfLinks($this->object->getId()) == 1;
889  }
890 
895  protected function switchViewModeObject()
896  {
897  global $ilCtrl;
898 
899  $_REQUEST['view_mode'] = $_GET['view_mode'] = (int) $_GET['switch_mode'];
900  $this->viewObject();
901  }
902 
907  protected function editLinksObject()
908  {
909  $_GET['switch_mode'] = self::VIEW_MODE_MANAGE;
910  $this->switchViewModeObject();
911  }
912 
913 
918  public function viewObject()
919  {
920  global $ilAccess, $ilErr, $ilTabs;
921 
922  $ilTabs->activateTab("id_content");
923 
924  $this->checkPermission('read');
925 
926  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
927  {
929  return true;
930  }
931  else
932  {
933  switch((int) $_REQUEST['view_mode'])
934  {
935  case self::VIEW_MODE_MANAGE:
936  $this->manageObject();
937  break;
938 
939  case self::VIEW_MODE_SORT:
940  $this->sortObject();
941  break;
942 
943  default:
944  $this->showLinksObject();
945  break;
946  }
947  }
948  return true;
949  }
950 
955  protected function manageObject()
956  {
957  $this->checkPermission('write');
958  $this->activateTabs('content','id_content_manage');
959 
960  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.webr_manage.html','Modules/WebResource');
961  $this->showToolbar('ACTION_BUTTONS');
962 
963  include_once './Modules/WebResource/classes/class.ilWebResourceEditableLinkTableGUI.php';
964  $table = new ilWebResourceEditableLinkTableGUI($this,'view');
965  $table->parse();
966 
967  $this->tpl->setVariable('TABLE_LINKS',$table->getHTML());
968  }
969 
974  protected function showLinksObject()
975  {
976  $this->checkPermission('read');
977  $this->activateTabs('content','id_content_view');
978 
979  include_once './Modules/WebResource/classes/class.ilWebResourceLinkTableGUI.php';
980  $table = new ilWebResourceLinkTableGUI($this,'showLinks');
981  $table->parse();
982 
983  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.webr_view.html','Modules/WebResource');
984  $this->showToolbar('ACTION_BUTTONS');
985  $this->tpl->setVariable('LINK_TABLE',$table->getHTML());
986  }
987 
992  protected function sortObject()
993  {
994  $this->checkPermission('write');
995  $this->activateTabs('content','id_content_ordering');
996 
997  include_once './Modules/WebResource/classes/class.ilWebResourceLinkTableGUI.php';
998  $table = new ilWebResourceLinkTableGUI($this,'sort',true);
999  $table->parse();
1000 
1001  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.webr_view.html','Modules/WebResource');
1002  $this->showToolbar('ACTION_BUTTONS');
1003  $this->tpl->setVariable('LINK_TABLE',$table->getHTML());
1004  }
1005 
1010  protected function saveSortingObject()
1011  {
1012  $this->checkPermission('write');
1013 
1014  include_once './Services/Container/classes/class.ilContainerSorting.php';
1015  $sort = ilContainerSorting::_getInstance($this->object->getId());
1016  $sort->savePost((array) $_POST['position']);
1017 
1018  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
1019  $this->viewObject();
1020  }
1021 
1022 
1028  protected function showToolbar($a_tpl_var)
1029  {
1030  global $ilAccess;
1031 
1032  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
1033  {
1034  return;
1035  }
1036 
1037  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
1038  $tool = new ilToolbarGUI();
1039  $tool->setFormAction($this->ctrl->getFormAction($this));
1040  $tool->addButton(
1041  $this->lng->txt('webr_add'),
1042  $this->ctrl->getLinkTarget($this,'addLink')
1043  );
1044 
1045  $this->tpl->setVariable($a_tpl_var,$tool->getHTML());
1046  return;
1047  }
1048 
1053  protected function confirmDeleteLinkObject()
1054  {
1055  $this->checkPermission('write');
1056  $this->activateTabs('content','id_content_view');
1057 
1058  $link_ids = is_array($_POST['link_ids']) ?
1059  $_POST['link_ids'] :
1060  array($_GET['link_id']);
1061 
1062  if(!$link_ids)
1063  {
1064  ilUtil::sendFailure($this->lng->txt('select_one'));
1065  $this->viewObject();
1066  return false;
1067  }
1068 
1069  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1070  $links = new ilLinkResourceItems($this->object->getId());
1071 
1072  include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
1073  $confirm = new ilConfirmationGUI();
1074  $confirm->setFormAction($this->ctrl->getFormAction($this,'view'));
1075  $confirm->setHeaderText($this->lng->txt('webr_sure_delete_items'));
1076  $confirm->setConfirm($this->lng->txt('delete'), 'deleteLinks');
1077  $confirm->setCancel($this->lng->txt('cancel'), 'view');
1078 
1079  foreach($link_ids as $link_id)
1080  {
1081  $link = $links->getItem($link_id);
1082  $confirm->addItem('link_ids[]', $link_id,$link['title']);
1083  }
1084  $this->tpl->setContent($confirm->getHTML());
1085  }
1086 
1091  protected function deleteLinksObject()
1092  {
1093  global $ilCtrl;
1094 
1095  $this->checkPermission('write');
1096 
1097  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1098  $links = new ilLinkResourceItems($this->object->getId());
1099 
1100  foreach($_POST['link_ids'] as $link_id)
1101  {
1102  $links->delete($link_id);
1103  }
1104  ilUtil::sendSuccess($this->lng->txt('webr_deleted_items'),true);
1105  $ilCtrl->redirect($this,'view');
1106  }
1107 
1112  protected function deactivateLinkObject()
1113  {
1114  global $ilCtrl;
1115 
1116  $this->checkPermission('write');
1117 
1118  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1119  $links = new ilLinkResourceItems($this->object->getId());
1120 
1121  if(!$_GET['link_id'])
1122  {
1123  ilUtil::sendFailure($this->lng->txt('select_one'),true);
1124  $ilCtrl->redirect($this,'view');
1125  }
1126 
1127  $links->setLinkId((int) $_GET['link_id']);
1128  $links->updateActive(false);
1129 
1130  ilUtil::sendSuccess($this->lng->txt('webr_inactive_success'),true);
1131  $ilCtrl->redirect($this,'view');
1132  }
1133 
1134 
1140  function infoScreenObject()
1141  {
1142  $this->ctrl->setCmd("showSummary");
1143  $this->ctrl->setCmdClass("ilinfoscreengui");
1144  $this->infoScreen();
1145  }
1146 
1150  function infoScreen()
1151  {
1152  global $ilAccess, $ilTabs;
1153 
1154  $this->checkPermission('visible');
1155  $ilTabs->activateTab('id_info');
1156 
1157  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1158  $info = new ilInfoScreenGUI($this);
1159 
1160  $info->enablePrivateNotes();
1161 
1162  // standard meta data
1163  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
1164 
1165  // forward the command
1166  $this->ctrl->forwardCommand($info);
1167  }
1168 
1169 
1170  function historyObject()
1171  {
1172  global $ilTabs;
1173 
1174  $this->checkPermission('write');
1175  $ilTabs->activateTab('id_history');
1176 
1177  include_once("classes/class.ilHistoryGUI.php");
1178 
1179  $hist_gui =& new ilHistoryGUI($this->object->getId());
1180 
1181  $hist_html = $hist_gui->getHistoryTable(array("ref_id" => $_GET["ref_id"],
1182  "cmd" => "history",
1183  "cmdClass" =>$_GET["cmdClass"],
1184  "cmdNode" =>$_GET["cmdNode"]));
1185 
1186  $this->tpl->setVariable("ADM_CONTENT", $hist_html);
1187  }
1188 
1197  public function formatInvalidLinkArray(Array $row)
1198  {
1199  $this->object->items_obj->readItem($row['page_id']);
1200  $row['title'] = $this->object->items_obj->getTitle();
1201 
1202  require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
1204  $actions->setSelectionHeaderClass('small');
1205  $actions->setItemLinkClass('xsmall');
1206  $actions->setListTitle($this->lng->txt('actions'));
1207  $actions->setId($row['page_id']);
1208  $this->ctrl->setParameter($this, 'link_id', $row['page_id']);
1209  $actions->addItem(
1210  $this->lng->txt('edit'),
1211  '',
1212  $this->ctrl->getLinkTarget($this, 'editLink')
1213  );
1214  $this->ctrl->clearParameters($this);
1215  $row['action_html'] = $actions->getHTML();
1216 
1217  return $row;
1218  }
1219 
1224  protected function linkCheckerObject()
1225  {
1226  global $ilias, $ilUser, $tpl, $ilTabs;
1227 
1228  $this->checkPermission('write');
1229  $ilTabs->activateTab('id_link_check');
1230 
1231  $this->__initLinkChecker();
1232  $this->object->initLinkResourceItemsObject();
1233 
1234  require_once 'Services/LinkChecker/classes/class.ilLinkCheckerTableGUI.php';
1235 
1236  $toolbar = new ilToolbarGUI();
1237 
1238  if((bool)$ilias->getSetting('cron_web_resource_check'))
1239  {
1240  include_once 'classes/class.ilLinkCheckNotify.php';
1241  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
1242 
1243  $chb = new ilCheckboxInputGUI($this->lng->txt('link_check_message_a'), 'link_check_message');
1244  $chb->setValue(1);
1245  $chb->setChecked((bool)ilLinkCheckNotify::_getNotifyStatus($ilUser->getId(), $this->object->getId()));
1246  $chb->setOptionTitle($this->lng->txt('link_check_message_b'));
1247 
1248  $toolbar->addInputItem($chb);
1249  $toolbar->addFormButton($this->lng->txt('save'), 'saveLinkCheck');
1250  $toolbar->setFormAction($this->ctrl->getLinkTarget($this, 'saveLinkCheck'));
1251  }
1252 
1253  $tgui = new ilLinkCheckerTableGUI($this, 'linkChecker');
1254  $tgui->setLinkChecker($this->link_checker_obj)
1255  ->setRowHandler($this)
1256  ->setRefreshButton($this->lng->txt('refresh'), 'refreshLinkCheck');
1257 
1258  return $tpl->setContent($tgui->prepareHTML()->getHTML().$toolbar->getHTML());
1259  }
1260 
1262  {
1263  global $ilDB,$ilUser;
1264 
1265  include_once './classes/class.ilLinkCheckNotify.php';
1266 
1267  $link_check_notify =& new ilLinkCheckNotify($ilDB);
1268  $link_check_notify->setUserId($ilUser->getId());
1269  $link_check_notify->setObjId($this->object->getId());
1270 
1271  if($_POST['link_check_message'])
1272  {
1273  ilUtil::sendSuccess($this->lng->txt('link_check_message_enabled'));
1274  $link_check_notify->addNotifier();
1275  }
1276  else
1277  {
1278  ilUtil::sendSuccess($this->lng->txt('link_check_message_disabled'));
1279  $link_check_notify->deleteNotifier();
1280  }
1281  $this->linkCheckerObject();
1282 
1283  return true;
1284  }
1285 
1286 
1287 
1289  {
1290  $this->__initLinkChecker();
1291 
1292  if(!$this->link_checker_obj->checkPear())
1293  {
1294  ilUtil::sendFailure($this->lng->txt('missing_pear_library'));
1295  $this->linkCheckerObject();
1296 
1297  return false;
1298  }
1299 
1300 
1301  $this->object->initLinkResourceItemsObject();
1302 
1303  // Set all link to valid. After check invalid links will be set to invalid
1304  $this->object->items_obj->updateValidByCheck();
1305 
1306  foreach($this->link_checker_obj->checkWebResourceLinks() as $invalid)
1307  {
1308  $this->object->items_obj->readItem($invalid['page_id']);
1309  $this->object->items_obj->setActiveStatus(false);
1310  $this->object->items_obj->setValidStatus(false);
1311  $this->object->items_obj->update(false);
1312  }
1313 
1314  $this->object->items_obj->updateLastCheck();
1315  ilUtil::sendSuccess($this->lng->txt('link_checker_refreshed'));
1316 
1317  $this->linkCheckerObject();
1318 
1319  return true;
1320  }
1321 
1323  {
1324  global $ilDB;
1325 
1326  include_once './classes/class.ilLinkChecker.php';
1327 
1328  $this->link_checker_obj =& new ilLinkChecker($ilDB,false);
1329  $this->link_checker_obj->setObjId($this->object->getId());
1330 
1331  return true;
1332  }
1333 
1334 
1341  protected function activateTabs($a_active_tab,$a_active_subtab = '')
1342  {
1343  global $ilAccess, $ilCtrl, $ilTabs, $lng;
1344 
1345  switch($a_active_tab)
1346  {
1347  case 'content':
1348  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
1349  {
1350  $this->lng->loadLanguageModule('cntr');
1351 
1352  $this->ctrl->setParameter($this,'switch_mode',self::VIEW_MODE_VIEW);
1353  $ilTabs->addSubTab('id_content_view',
1354  $lng->txt('view'),
1355  $this->ctrl->getLinkTarget($this,'switchViewMode')
1356  );
1357  $this->ctrl->setParameter($this,'switch_mode',self::VIEW_MODE_MANAGE);
1358  $ilTabs->addSubTab('id_content_manage',
1359  $lng->txt('cntr_manage'),
1360  $this->ctrl->getLinkTarget($this,'switchViewMode')
1361  );
1362  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1363  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
1364  include_once './Services/Container/classes/class.ilContainer.php';
1365  if((ilLinkResourceItems::lookupNumberOfLinks($this->object->getId()) > 1)
1367  {
1368  $this->ctrl->setParameter($this,'switch_mode',self::VIEW_MODE_SORT);
1369  $ilTabs->addSubTab('id_content_ordering',
1370  $this->lng->txt('cntr_ordering'),
1371  $this->ctrl->getLinkTarget($this,'switchViewMode')
1372  );
1373  }
1374 
1375  $ilCtrl->clearParameters($this);
1376  $ilTabs->activateSubTab($a_active_subtab);
1377  }
1378  }
1379 
1380  $ilTabs->activateTab('id_content');
1381  }
1382 
1383 
1388  function setTabs()
1389  {
1390  global $ilAccess, $ilTabs, $lng;
1391 
1392  if ($ilAccess->checkAccess('read','',$this->object->getRefId()))
1393  {
1394  $ilTabs->addTab("id_content",
1395  $lng->txt("content"),
1396  $this->ctrl->getLinkTarget($this, "view"));
1397  }
1398 
1399  if ($ilAccess->checkAccess('visible','',$this->ref_id))
1400  {
1401  $ilTabs->addTab("id_info",
1402  $lng->txt("info_short"),
1403  $this->ctrl->getLinkTarget($this, "infoScreen"));
1404  }
1405 
1406  if($ilAccess->checkAccess('write','',$this->object->getRefId()) and !$this->getCreationMode())
1407  {
1408  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1409  if(ilLinkResourceItems::lookupNumberOfLinks($this->object->getId()) > 1)
1410  {
1411  $ilTabs->addTab("id_settings",
1412  $lng->txt("settings"),
1413  $this->ctrl->getLinkTarget($this, "settings"));
1414  }
1415 
1416  }
1417 
1418  if ($ilAccess->checkAccess('write','',$this->object->getRefId()))
1419  {
1420  $ilTabs->addTab("id_history",
1421  $lng->txt("history"),
1422  $this->ctrl->getLinkTarget($this, "history"));
1423  }
1424 
1425  if ($ilAccess->checkAccess('write','',$this->object->getRefId()))
1426  {
1427  // Check if pear library is available
1428  if(@include_once('HTTP/Request.php'))
1429  {
1430  $ilTabs->addTab("id_link_check",
1431  $lng->txt("link_check"),
1432  $this->ctrl->getLinkTarget($this, "linkChecker"));
1433  }
1434  }
1435 
1436  if ($ilAccess->checkAccess('write','',$this->object->getRefId()))
1437  {
1438  $ilTabs->addTab("id_meta_data",
1439  $lng->txt("meta_data"),
1440  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'));
1441  }
1442 
1443  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
1444  {
1445  $ilTabs->addTab(
1446  'export',
1447  $this->lng->txt('export'),
1448  $this->ctrl->getLinkTargetByClass('ilexportgui','')
1449  );
1450  }
1451 
1452  if ($ilAccess->checkAccess('edit_permission','',$this->object->getRefId()))
1453  {
1454  $ilTabs->addTab("id_permissions",
1455  $lng->txt("perm_settings"),
1456  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"));
1457  }
1458 
1459  }
1460 
1461  // PRIVATE
1462  function __prepareOutput()
1463  {
1464  // output objects
1465  $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
1466  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
1467 
1468  // output locator
1469  $this->__setLocator();
1470 
1471  // output message
1472  if ($this->message)
1473  {
1474  ilUtil::sendInfo($this->message);
1475  }
1476 
1477  // display infopanel if something happened
1479 
1480  // set header
1481  $this->__setHeader();
1482  }
1483 
1484  function __setHeader()
1485  {
1486  include_once './classes/class.ilTabsGUI.php';
1487 
1488  $this->tpl->setCurrentBlock("header_image");
1489  $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_webr_b.gif"));
1490  $this->tpl->parseCurrentBlock();
1491  $this->tpl->setVariable("HEADER",$this->object->getTitle());
1492  $this->tpl->setVariable("H_DESCRIPTION",$this->object->getDescription());
1493 
1494  $this->setTabs();
1495  }
1496 
1497  function __setLocator()
1498  {
1499  global $tree;
1500  global $ilias_locator, $lng;
1501 
1502  $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html", "Services/Locator");
1503 
1504  $counter = 0;
1505 
1506  //$this->tpl->touchBlock('locator_separator');
1507  //$this->tpl->touchBlock('locator_item');
1508 
1509  foreach ($tree->getPathFull($this->object->getRefId()) as $key => $row)
1510  {
1511 
1512  //if ($row["child"] == $tree->getRootId())
1513  //{
1514  // continue;
1515  //}
1516 
1517  if($counter++)
1518  {
1519  $this->tpl->touchBlock('locator_separator_prefix');
1520  }
1521 
1522  if ($row["child"] > 0)
1523  {
1524  $this->tpl->setCurrentBlock("locator_img");
1525  $this->tpl->setVariable("IMG_SRC",
1526  ilUtil::getImagePath("icon_".$row["type"]."_s.gif"));
1527  $this->tpl->setVariable("IMG_ALT",
1528  $lng->txt("obj_".$type));
1529  $this->tpl->parseCurrentBlock();
1530  }
1531 
1532  $this->tpl->setCurrentBlock("locator_item");
1533 
1534  if($row["type"] == 'webr')
1535  {
1536  $this->tpl->setVariable("ITEM",$this->object->getTitle());
1537  $this->tpl->setVariable("LINK_ITEM",$this->ctrl->getLinkTarget($this));
1538  }
1539  elseif ($row["child"] != $tree->getRootId())
1540  {
1541  $this->tpl->setVariable("ITEM", $row["title"]);
1542  $this->tpl->setVariable("LINK_ITEM","./repository.php?ref_id=".$row["child"]);
1543  }
1544  else
1545  {
1546  $this->tpl->setVariable("ITEM", $this->lng->txt("repository"));
1547  $this->tpl->setVariable("LINK_ITEM","./repository.php?ref_id=".$row["child"]);
1548  }
1549 
1550  $this->tpl->parseCurrentBlock();
1551  }
1552 
1553  $this->tpl->setVariable("TXT_LOCATOR",$this->lng->txt("locator"));
1554  $this->tpl->parseCurrentBlock();
1555  }
1556 
1557  function _goto($a_target)
1558  {
1559  global $ilAccess, $ilErr, $lng;
1560 
1561  // Will be replaced in future releases by ilAccess::checkAccess()
1562  if ($ilAccess->checkAccess("read", "", $a_target))
1563  {
1564  ilUtil::redirect("ilias.php?baseClass=ilLinkResourceHandlerGUI&ref_id=$a_target");
1565  }
1566  else
1567  {
1568  // to do: force flat view
1569  if ($ilAccess->checkAccess("visible", "", $a_target))
1570  {
1571  ilUtil::redirect("ilias.php?baseClass=ilLinkResourceHandlerGUI&ref_id=".$a_target."&cmd=infoScreen");
1572  }
1573  else
1574  {
1575  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1576  {
1577  $_GET["cmd"] = "frameset";
1578  $_GET["target"] = "";
1579  $_GET["ref_id"] = ROOT_FOLDER_ID;
1580  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
1581  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1582  include("repository.php");
1583  exit;
1584  }
1585  }
1586  }
1587 
1588  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1589  }
1590 } // END class.ilObjLinkResource
1591 ?>