ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilConditionHandlerGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 
16 {
17  var $ctrl = null;
18 
19  var $lng;
20  var $tpl;
21  var $tree;
22 
23  var $ch_obj;
30 
32 
42  public function __construct($gui_obj,$a_ref_id = null)
43  {
44  global $lng,$tpl,$tree,$ilCtrl;
45 
46  include_once "./Services/AccessControl/classes/class.ilConditionHandler.php";
47 
48  $this->ch_obj =& new ilConditionHandler();
49 
50  $this->ctrl =& $ilCtrl;
51  $this->gui_obj =& $gui_obj;
52  $this->lng =& $lng;
53  $this->lng->loadLanguageModule('rbac');
54  $this->tpl =& $tpl;
55  $this->tree =& $tree;
56 
57  if($a_ref_id)
58  {
59  $this->target_obj =& ilObjectFactory::getInstanceByRefId($a_ref_id);
60  }
61  else
62  {
63  $this->target_obj =& $this->gui_obj->object;
64  }
65 
66  // this only works for ilObject derived objects (other objects
67  // should call set() methods manually
68  if (is_object($this->target_obj))
69  {
70  $this->setTargetId($this->target_obj->getId());
71  $this->setTargetRefId($this->target_obj->getRefId());
72  $this->setTargetType($this->target_obj->getType());
73  $this->setTargetTitle($this->target_obj->getTitle());
74  }
75  }
76 
81  public static function translateOperator($a_obj_id, $a_operator)
82  {
83  switch($a_operator)
84  {
86  $GLOBALS['lng']->loadLanguageModule('trac');
87  include_once './Services/Tracking/classes/class.ilLPObjSettings.php';
88  $obj_settings = new ilLPObjSettings($a_obj_id);
89  return ilLPObjSettings::_mode2Text($obj_settings->getMode());
90 
91  default:
92  $GLOBALS['lng']->loadLanguageModule('rbac');
93  return $GLOBALS['lng']->txt('condition_'.$a_operator);
94  }
95  }
96 
101  protected function getConditionHandler()
102  {
103  return $this->ch_obj;
104  }
105 
106  function setBackButtons($a_btn_arr)
107  {
108  $_SESSION['precon_btn'] = $a_btn_arr;
109  }
110  function getBackButtons()
111  {
112  return $_SESSION['precon_btn'] ? $_SESSION['precon_btn'] : array();
113  }
114 
115  public function executeCommand()
116  {
117  global $ilErr, $ilAccess, $lng;
118 
119  if(!$ilAccess->checkAccess('write','',$this->getTargetRefId()))
120  {
121  $ilErr->raiseError($lng->txt('permission_denied'),$ilErr->WARNING);
122  }
123 
124  $next_class = $this->ctrl->getNextClass($this);
125  $cmd = $this->ctrl->getCmd();
126 
127  switch ($next_class)
128  {
129  default:
130  if (empty($cmd))
131  {
132  $cmd = "view";
133  }
134  $this->$cmd();
135  break;
136  }
137  }
138 
139  function setAutomaticValidation($a_status)
140  {
141  $this->automatic_validation = $a_status;
142  }
144  {
146  }
147 
148 
152  function setTargetId($a_target_id)
153  {
154  $this->target_id = $a_target_id;
155  }
156 
160  function getTargetId()
161  {
162  return $this->target_id;
163  }
164 
168  function setTargetRefId($a_target_ref_id)
169  {
170  $this->target_ref_id = $a_target_ref_id;
171  }
172 
176  function getTargetRefId()
177  {
178  return $this->target_ref_id;
179  }
180 
184  function setTargetType($a_target_type)
185  {
186  $this->target_type = $a_target_type;
187  }
188 
192  function getTargetType()
193  {
194  return $this->target_type;
195  }
196 
200  function setTargetTitle($a_target_title)
201  {
202  $this->target_title = $a_target_title;
203  }
204 
209  public function isTargetReferenced()
210  {
211  return $this->getTargetRefId() ? true : false;
212  }
213 
217  function getTargetTitle()
218  {
219  return $this->target_title;
220  }
221 
222  function chi_init(&$chi_target_obj,$a_ref_id = null)
223  {
224  echo 'deprecated';
225 
226  include_once "./Services/AccessControl/classes/class.ilConditionHandler.php";
227 
228  $this->ch_obj =& new ilConditionHandler();
229 
230  if($a_ref_id)
231  {
232  $this->target_obj =& ilObjectFactory::getInstanceByRefId($a_ref_id);
233  }
234  else
235  {
236  $this->target_obj =& $this->object;
237  }
238 
239  return true;
240  }
241 
246  protected function listConditions()
247  {
248  global $ilToolbar;
249 
250  $ilToolbar->addButton($this->lng->txt('add_condition'),$this->ctrl->getLinkTarget($this,'selector'));
251 
252  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.list_conditions.html','Services/AccessControl');
253 
255  $this->getTargetRefId(),
256  $this->getTargetId(),
257  $this->getTargetType()
258  );
259  if(count($optional_conditions))
260  {
261  if(!$_REQUEST["list_mode"])
262  {
263  $_REQUEST["list_mode"] = "subset";
264  }
265  }
266  else if(!$_REQUEST["list_mode"])
267  {
268  $_REQUEST["list_mode"] = "all";
269  }
270 
271  // Show form only if conditions are availabe
273  $this->getTargetRefId(),
274  $this->getTargetId(),
275  $this->getTargetType()))
276  )
277  {
278  $form = $this->showObligatoryForm($optional_conditions);
279  $this->tpl->setVariable('TABLE_SETTINGS',$form->getHTML());
280  }
281 
282  include_once './Services/AccessControl/classes/class.ilConditionHandlerTableGUI.php';
283  $table = new ilConditionHandlerTableGUI($this,'listConditions', ($_REQUEST["list_mode"] != "all"));
284  $table->setConditions(
286  $this->getTargetRefId(),
287  $this->getTargetId(),
288  $this->getTargetType()
289  )
290  );
291 
292  $this->tpl->setVariable('TABLE_CONDITIONS',$table->getHTML());
293  $this->tpl->setContent($table->getHTML());
294  }
295 
299  protected function saveObligatorySettings()
300  {
301  $form = $this->showObligatoryForm();
302  if($form->checkInput())
303  {
304  $old_mode = $form->getInput("old_list_mode");
305  switch($form->getInput("list_mode"))
306  {
307  case "all":
308  if($old_mode != "all")
309  {
310  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
312  $this->getTargetRefId(),
313  $this->getTargetId(),
314  $this->getTargetType()
315  );
316  // Set all optional conditions to obligatory
317  foreach((array) $optional_conditions as $item)
318  {
319  ilConditionHandler::updateObligatory($item["condition_id"], true);
320  }
321  }
322  break;
323 
324  case "subset":
325  $num_req = $form->getInput('required');
326  if($old_mode != "subset")
327  {
329  $this->getTargetRefId(),
330  $this->getTargetId(),
331  $this->getTargetType()
332  );
333  foreach($all_conditions as $item)
334  {
335  ilConditionHandler::updateObligatory($item["condition_id"], false);
336  }
337  $num_req = 1;
338  }
340  $this->getTargetRefId(),
341  $this->getTargetId(),
342  $num_req
343  );
344  break;
345  }
346 
347  $cond = new ilConditionHandler();
348  $cond->setTargetRefId($this->getTargetRefId());
349  $cond->updateHiddenStatus((int) $form->getInput('hidden'));
350 
351  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
352  $this->ctrl->redirect($this,'listConditions');
353  }
354 
355  $form->setValuesByPost();
356  ilUtil::sendFailure($this->lng->txt('err_check_input'));
357  $this->tpl->setContent($form->getHTML());
358  }
359 
363  protected function saveObligatoryList()
364  {
366  $this->getTargetRefId(),
367  $this->getTargetId(),
368  $this->getTargetType()
369  );
370 
371  if($_POST["obl"] && sizeof($_POST["obl"]) > sizeof($all_conditions)-2)
372  {
373  ilUtil::sendFailure($this->lng->txt("rbac_precondition_minimum_optional"), true);
374  $this->ctrl->redirect($this,'listConditions');
375  }
376 
377  foreach($all_conditions as $item)
378  {
379  $status = false;
380  if($_POST["obl"] && in_array($item["condition_id"], $_POST["obl"]))
381  {
382  $status = true;
383  }
384  ilConditionHandler::updateObligatory($item["condition_id"], $status);
385  }
386 
387  // re-calculate
389  $this->getTargetRefId(),
390  $this->getTargetId(),
391  $this->getTargetType(),
392  true
393  );
394 
395  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
396  $this->ctrl->redirect($this,'listConditions');
397  }
398 
403  protected function showObligatoryForm($opt = array())
404  {
405  if(!$opt)
406  {
408  $this->getTargetRefId(),
409  $this->getTargetId(),
410  $this->getTargetType()
411  );
412  }
413 
415 
416  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
417  $form = new ilPropertyFormGUI();
418  $form->setFormAction($this->ctrl->getFormAction($this),'listConditions');
419  $form->setTitle($this->lng->txt('precondition_obligatory_settings'));
420  $form->addCommandButton('saveObligatorySettings', $this->lng->txt('save'));
421 
422  $hide = new ilCheckboxInputGUI($this->lng->txt('rbac_precondition_hide'),'hidden');
424  $hide->setValue(1);
425  $hide->setInfo($this->lng->txt('rbac_precondition_hide_info'));
426  $form->addItem($hide);
427 
428  $mode = new ilRadioGroupInputGUI($this->lng->txt("rbac_precondition_mode"), "list_mode");
429  $form->addItem($mode);
430  $mode->setValue($_REQUEST["list_mode"]);
431 
432  $mall = new ilRadioOption($this->lng->txt("rbac_precondition_mode_all"), "all");
433  $mall->setInfo($this->lng->txt("rbac_precondition_mode_all_info"));
434  $mode->addOption($mall);
435 
436  $msubset = new ilRadioOption($this->lng->txt("rbac_precondition_mode_subset"), "subset");
437  $msubset->setInfo($this->lng->txt("rbac_precondition_mode_subset_info"));
438  $mode->addOption($msubset);
439 
440  $obl = new ilNumberInputGUI($this->lng->txt('precondition_num_obligatory'), 'required');
441  $obl->setInfo($this->lng->txt('precondition_num_optional_info'));
442  if(count($opt))
443  {
445  $this->getTargetRefId(),
446  $this->getTargetId(),
447  $this->getTargetType()
448  );
449  $min = count($all) - count($opt) + 1;
450  $max = count($all) - 1;
451  }
452  else
453  {
454  $obligatory = $min = $max = 1;
455  }
456  $obl->setValue($obligatory);
457  $obl->setRequired(true);
458  $obl->setSize(1);
459  $obl->setMinValue($min);
460  $obl->setMaxValue($max);
461  $msubset->addSubItem($obl);
462 
463  $old_mode = new ilHiddenInputGUI("old_list_mode");
464  $old_mode->setValue($_REQUEST["list_mode"]);
465  $form->addItem($old_mode);
466 
467  return $form;
468  }
469 
470 
471  function edit()
472  {
473  global $ilObjDataCache;
474 
475  if(!$_GET['condition_id'])
476  {
477  ilUtil::sendFailure("Missing id: condition_id");
478  $this->listConditions();
479  return false;
480  }
481  $condition = ilConditionHandler::_getCondition((int) $_GET['condition_id']);
482 
483  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.condition_handler_edit_condition.html',
484  "Services/AccessControl");
485  $this->ctrl->setParameter($this,'condition_id',(int) $_GET['condition_id']);
486 
487  $this->initFormCondition($condition['trigger_ref_id'],(int) $_GET['condition_id'],'edit');
488  $this->tpl->setVariable('CONDITION_TABLE',$this->form->getHTML());
489  }
490 
491  function updateCondition()
492  {
493  global $ilObjDataCache;
494 
495  if(!$_GET['condition_id'])
496  {
497  ilUtil::sendFailure("Missing id: condition_id");
498  $this->listConditions();
499  return false;
500  }
501 
502  // Update condition
503  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
504  $condition_handler = new ilConditionHandler();
505 
506  $condition = ilConditionHandler::_getCondition((int) $_GET['condition_id']);
507  $condition_handler->setOperator($_POST['operator']);
508  $condition_handler->setObligatory((int) $_POST['obligatory']);
509  $condition_handler->setTargetRefId($this->getTargetRefId());
510  $condition_handler->setValue('');
511  switch($this->getTargetType())
512  {
513  case 'st':
514  $condition_handler->setReferenceHandlingType($_POST['ref_handling']);
515  break;
516 
517  default:
518  $condition_handler->setReferenceHandlingType(ilConditionHandler::UNIQUE_CONDITIONS);
519  break;
520  }
521  $condition_handler->updateCondition($condition['id']);
522 
523  // Update relevant sco's
524  if($condition['trigger_type'] == 'sahs')
525  {
526  include_once 'Services/Object/classes/class.ilObjectLP.php';
527  $olp = ilObjectLP::getInstance($condition['trigger_obj_id']);
528  $collection = $olp->getCollectionInstance();
529  if($collection)
530  {
531  $collection->delete();
532  }
533 
534  if(is_array($_POST['item_ids'])) // #12901
535  {
536  $collection->activateEntries($_POST['item_ids']);
537  }
538 
539  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
540  ilLPStatusWrapper::_refreshStatus($condition['trigger_obj_id']);
541  }
542 
543  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
544  $this->ctrl->redirect($this,'listConditions');
545  }
546 
547  function askDelete()
548  {
549  global $tpl;
550 
551  if(!count($_POST['conditions']))
552  {
553  ilUtil::sendFailure($this->lng->txt('no_condition_selected'));
554  $this->listConditions();
555  return true;
556  }
557 
558  // display confirmation message
559  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
560  $cgui = new ilConfirmationGUI();
561  $cgui->setFormAction($this->ctrl->getFormAction($this, "listConditions"));
562  $cgui->setHeaderText($this->lng->txt("rbac_condition_delete_sure"));
563  $cgui->setCancel($this->lng->txt("cancel"), "listConditions");
564  $cgui->setConfirm($this->lng->txt("delete"), "delete");
565 
566  // list conditions that should be deleted
567  foreach($_POST['conditions'] as $condition_id)
568  {
569  $condition = ilConditionHandler::_getCondition($condition_id);
570 
571  $title = ilObject::_lookupTitle($condition['trigger_obj_id']).
572  " (".$this->lng->txt("condition").": ".
573  $this->lng->txt('condition_'.$condition['operator']).")";
574  $icon = ilUtil::getImagePath('icon_'.$condition['trigger_type'].'.svg');
575  $alt = $this->lng->txt('obj_'.$condition['trigger_type']);
576 
577  $cgui->addItem("conditions[]", $condition_id, $title, $icon, $alt);
578  }
579 
580  $tpl->setContent($cgui->getHTML());
581  }
582 
583  function delete()
584  {
585  if(!count($_POST['conditions']))
586  {
587  ilUtil::sendFailure($this->lng->txt('no_condition_selected'));
588  $this->listConditions();
589  return true;
590  }
591 
592  foreach($_POST['conditions'] as $condition_id)
593  {
594  $this->ch_obj->deleteCondition($condition_id);
595  }
596  ilUtil::sendSuccess($this->lng->txt('condition_deleted'),true);
597  $this->ctrl->redirect($this,'listConditions');
598 
599  return true;
600  }
601 
602  function selector()
603  {
604  include_once ("./Services/AccessControl/classes/class.ilConditionSelector.php");
605 
606  ilUtil::sendInfo($this->lng->txt("condition_select_object"));
607 
608  $exp = new ilConditionSelector($this, "selector");
609  $exp->setTypeWhiteList(array_merge($this->getConditionHandler()->getTriggerTypes(),
610  array("root", "cat", "grp", "fold", "crs")
611  ));
612  //setRefId have to be after setTypeWhiteList!
613  $exp->setRefId($this->getTargetRefId());
614  $exp->setClickableTypes($this->getConditionHandler()->getTriggerTypes());
615 
616  if (!$exp->handleCommand())
617  {
618  $this->tpl->setContent($exp->getHTML());
619  }
620  }
621 
622  function add()
623  {
624  global $ilObjDataCache;
625 
626  if(!$_GET['source_id'])
627  {
628  ilUtil::sendFailure("Missing id: condition_id");
629  $this->selector();
630  return false;
631  }
632 
633  $this->initFormCondition((int) $_GET['source_id'],0,'add');
634  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.condition_handler_add.html',
635  "Services/AccessControl");
636  $this->tpl->setVariable('CONDITION_TABLE',$this->form->getHTML());
637  }
638 
639 
643  function assign()
644  {
645  if(!isset($_GET['source_id']))
646  {
647  echo "class.ilConditionHandlerGUI: no source_id given";
648 
649  return false;
650  }
651  if(!$_POST['operator'])
652  {
653  ilUtil::sendFailure($this->lng->txt('err_check_input'));
654  $this->add();
655  return false;
656  }
657 
658  $this->ch_obj->setTargetRefId($this->getTargetRefId());
659  $this->ch_obj->setTargetObjId($this->getTargetId());
660  $this->ch_obj->setTargetType($this->getTargetType());
661 
662  switch($this->getTargetType())
663  {
664  case 'st':
665  $this->ch_obj->setReferenceHandlingType($_POST['ref_handling']);
666  break;
667 
668  default:
669  $this->ch_obj->setReferenceHandlingType(ilConditionHandler::UNIQUE_CONDITIONS);
670  break;
671  }
672  // this has to be changed, if non referenced trigger are implemted
673  if(!$trigger_obj =& ilObjectFactory::getInstanceByRefId((int) $_GET['source_id'],false))
674  {
675  echo 'ilConditionHandler: Trigger object does not exist';
676  }
677  $this->ch_obj->setTriggerRefId($trigger_obj->getRefId());
678  $this->ch_obj->setTriggerObjId($trigger_obj->getId());
679  $this->ch_obj->setTriggerType($trigger_obj->getType());
680  $this->ch_obj->setOperator($_POST['operator']);
681  $this->ch_obj->setObligatory((int) $_POST['obligatory']);
682  $this->ch_obj->setHiddenStatus(ilConditionHandler::lookupHiddenStatusByTarget($this->getTargetRefId()));
683  $this->ch_obj->setValue('');
684 
685  // Save assigned sco's
686  if($this->ch_obj->getTriggerType() == 'sahs')
687  {
688  include_once 'Services/Object/classes/class.ilObjectLP.php';
689  $olp = ilObjectLP::getInstance($this->ch_obj->getTriggerObjId());
690  $collection = $olp->getCollectionInstance();
691  if($collection)
692  {
693  $collection->delete();
694  }
695 
696  if(is_array($_POST['item_ids'])) // #12901
697  {
698  $collection->activateEntries($_POST['item_ids']);
699  }
700  }
701 
702  $this->ch_obj->enableAutomaticValidation($this->getAutomaticValidation());
703  if(!$this->ch_obj->storeCondition())
704  {
705  ilUtil::sendFailure($this->ch_obj->getErrorMessage(),true);
706  }
707  else
708  {
709  ilUtil::sendSuccess($this->lng->txt('added_new_condition'),true);
710  }
711 
712  $this->ctrl->redirect($this,'listConditions');
713 
714  return true;
715  }
716 
717  function chi_update()
718  {
719  #if(in_array('',$_POST['operator']))
720  #{
721  # ilUtil::sendInfo($this->lng->txt('select_one_operator'));
722 
723  # return false;
724  #}
725  foreach($this->__getConditionsOfTarget() as $condition)
726  {
727  $this->ch_obj->setOperator($_POST['operator'][$condition["id"]]);
728  $this->ch_obj->setValue($_POST['value'][$condition["id"]]);
729  $this->ch_obj->updateCondition($condition['id']);
730 
731  }
732  ilUtil::sendSuccess($this->lng->txt('conditions_updated'));
733 
734  $this->ctrl->returnToParent($this);
735 
736  return true;
737  }
739  {
740  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
741 
742  foreach(ilConditionHandler::_getConditionsOfTarget($this->getTargetRefId(),$this->getTargetId(), $this->getTargetType()) as $condition)
743  {
744  if($condition['operator'] == 'not_member')
745  {
746  continue;
747  }
748  else
749  {
750  $cond[] = $condition;
751  }
752  }
753  return $cond ? $cond : array();
754  }
755 
763  private function initFormCondition($a_source_id,$a_condition_id = 0,$a_mode = 'add')
764  {
765  $trigger_obj_id = ilObject::_lookupObjId($a_source_id);
766  $trigger_type = ilObject::_lookupType($trigger_obj_id);
767 
768  $condition = ilConditionHandler::_getCondition($a_condition_id);
769 
770  if(is_object($this->form))
771  {
772  return true;
773  }
774  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
775  $this->form = new ilPropertyFormGUI();
776  $this->ctrl->setParameter($this,'source_id',$a_source_id);
777  $this->form->setFormAction($this->ctrl->getFormAction($this));
778 
779  $info_source = new ilNonEditableValueGUI($this->lng->txt("rbac_precondition_source"));
780  $info_source->setValue(ilObject::_lookupTitle(ilObject::_lookupObjId($a_source_id)));
781  $this->form->addItem($info_source);
782 
783  $info_target = new ilNonEditableValueGUI($this->lng->txt("rbac_precondition_target"));
784  $info_target->setValue($this->getTargetTitle());
785  $this->form->addItem($info_target);
786 
787  /* moved to list
788  $obl = new ilCheckboxInputGUI($this->lng->txt('precondition_obligatory'), 'obligatory');
789  $obl->setInfo($this->lng->txt('precondition_obligatory_info'));
790  $obl->setValue(1);
791  if($a_condition_id)
792  {
793  $obl->setChecked($condition['obligatory']);
794  }
795  else
796  {
797  $obl->setChecked(true);
798  }
799  $this->form->addItem($obl);
800  */
801  $obl = new ilHiddenInputGUI('obligatory');
802  if($a_condition_id)
803  {
804  $obl->setValue($condition['obligatory']);
805  }
806  else
807  {
808  $obl->setValue(1);
809  }
810  $this->form->addItem($obl);
811 
812  $sel = new ilSelectInputGUI($this->lng->txt('condition'),'operator');
813  include_once "./Services/AccessControl/classes/class.ilConditionHandler.php";
814  $ch_obj = new ilConditionHandler();
815  if($a_mode == 'add')
816  {
817  $operators[0] = $this->lng->txt('select_one');
818  }
819  foreach($ch_obj->getOperatorsByTargetType($trigger_type) as $operator)
820  {
821  $operators[$operator] = $this->lng->txt('condition_'.$operator);
822  }
823  $sel->setValue(isset($condition['operator']) ? $condition['operator'] : 0);
824  $sel->setOptions($operators);
825  $sel->setRequired(true);
826  $this->form->addItem($sel);
827 
829  {
830  $rad_opt = new ilRadioGroupInputGUI($this->lng->txt('cond_ref_handling'),'ref_handling');
831  $rad_opt->setValue(isset($condition['ref_handling']) ? $condition['ref_handling'] : ilConditionHandler::SHARED_CONDITIONS);
832 
833  $opt2 = new ilRadioOption($this->lng->txt('cond_ref_shared'),ilConditionHandler::SHARED_CONDITIONS);
834  $rad_opt->addOption($opt2);
835 
836  $opt1 = new ilRadioOption($this->lng->txt('cond_ref_unique'),ilConditionHandler::UNIQUE_CONDITIONS);
837  $rad_opt->addOption($opt1);
838 
839  $this->form->addItem($rad_opt);
840  }
841 
842  // Additional settings for SCO's
843  if($trigger_type == 'sahs')
844  {
845  $this->lng->loadLanguageModule('trac');
846 
847  $cus = new ilCustomInputGUI($this->lng->txt('trac_sahs_relevant_items'),'item_ids[]');
848  $cus->setRequired(true);
849 
850  $tpl = new ilTemplate('tpl.condition_handler_sco_row.html',true,true,
851  "Services/AccessControl");
852  $counter = 0;
853 
854  include_once 'Services/Object/classes/class.ilObjectLP.php';
855  $olp = ilObjectLP::getInstance($trigger_obj_id);
856  $collection = $olp->getCollectionInstance();
857  if($collection)
858  {
859  foreach($collection->getPossibleItems() as $item_id => $sahs_item)
860  {
861  $tpl->setCurrentBlock("sco_row");
862  $tpl->setVariable('SCO_ID',$item_id);
863  $tpl->setVariable('SCO_TITLE',$sahs_item['title']);
864  $tpl->setVariable('CHECKED',$collection->isAssignedEntry($item_id) ? 'checked="checked"' : '');
865  $tpl->parseCurrentBlock();
866  $counter++;
867  }
868  }
869  $tpl->setVariable('INFO_SEL',$this->lng->txt('trac_lp_determination_info_sco'));
870  $cus->setHTML($tpl->get());
871  $this->form->addItem($cus);
872  }
873  switch($a_mode)
874  {
875  case 'edit':
876  $this->form->setTitleIcon(ilUtil::getImagePath('icon_'.$this->getTargetType().'.svg'));
877  $this->form->setTitle($this->lng->txt('rbac_edit_condition'));
878  $this->form->addCommandButton('updateCondition',$this->lng->txt('save'));
879  $this->form->addCommandButton('listConditions',$this->lng->txt('cancel'));
880  break;
881 
882 
883  case 'add':
884  $this->form->setTitleIcon(ilUtil::getImagePath('icon_'.$this->getTargetType().'.svg'));
885  $this->form->setTitle($this->lng->txt('add_condition'));
886  $this->form->addCommandButton('assign',$this->lng->txt('save'));
887  $this->form->addCommandButton('selector',$this->lng->txt('back'));
888  break;
889  }
890  return true;
891  }
892 }
893 ?>