ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilConditionHandlerInterface.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 ilConditionHandlerInterface($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 
77  function setBackButtons($a_btn_arr)
78  {
79  $_SESSION['precon_btn'] = $a_btn_arr;
80  }
81  function getBackButtons()
82  {
83  return $_SESSION['precon_btn'] ? $_SESSION['precon_btn'] : array();
84  }
85 
86  public function executeCommand()
87  {
88  global $ilErr, $ilAccess, $lng;
89 
90  if(!$ilAccess->checkAccess('write','',$this->getTargetRefId()))
91  {
92  $ilErr->raiseError($lng->txt('permission_denied'),$ilErr->WARNING);
93  }
94 
95  $next_class = $this->ctrl->getNextClass($this);
96  $cmd = $this->ctrl->getCmd();
97 
98  switch ($next_class)
99  {
100  default:
101  if (empty($cmd))
102  {
103  $cmd = "view";
104  }
105  $this->$cmd();
106  break;
107  }
108  }
109 
110  function setAutomaticValidation($a_status)
111  {
112  $this->automatic_validation = $a_status;
113  }
115  {
117  }
118 
119 
123  function setTargetId($a_target_id)
124  {
125  $this->target_id = $a_target_id;
126  }
127 
131  function getTargetId()
132  {
133  return $this->target_id;
134  }
135 
139  function setTargetRefId($a_target_ref_id)
140  {
141  $this->target_ref_id = $a_target_ref_id;
142  }
143 
147  function getTargetRefId()
148  {
149  return $this->target_ref_id;
150  }
151 
155  function setTargetType($a_target_type)
156  {
157  $this->target_type = $a_target_type;
158  }
159 
163  function getTargetType()
164  {
165  return $this->target_type;
166  }
167 
171  function setTargetTitle($a_target_title)
172  {
173  $this->target_title = $a_target_title;
174  }
175 
180  public function isTargetReferenced()
181  {
182  return $this->getTargetRefId() ? true : false;
183  }
184 
188  function getTargetTitle()
189  {
190  return $this->target_title;
191  }
192 
193  function chi_init(&$chi_target_obj,$a_ref_id = null)
194  {
195  echo 'deprecated';
196 
197  include_once "./Services/AccessControl/classes/class.ilConditionHandler.php";
198 
199  $this->ch_obj =& new ilConditionHandler();
200 
201  if($a_ref_id)
202  {
203  $this->target_obj =& ilObjectFactory::getInstanceByRefId($a_ref_id);
204  }
205  else
206  {
207  $this->target_obj =& $this->object;
208  }
209 
210  return true;
211  }
212 
217  protected function listConditions()
218  {
219  global $ilToolbar;
220 
221  $ilToolbar->addButton($this->lng->txt('add_condition'),$this->ctrl->getLinkTarget($this,'selector'));
222 
223  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.list_conditions.html','Services/AccessControl');
224 
226  $this->getTargetRefId(),
227  $this->getTargetId(),
228  $this->getTargetType()
229  );
230  if(count($optional_conditions))
231  {
232  if(!$_REQUEST["list_mode"])
233  {
234  $_REQUEST["list_mode"] = "subset";
235  }
236  }
237  else if(!$_REQUEST["list_mode"])
238  {
239  $_REQUEST["list_mode"] = "all";
240  }
241  $form = $this->showObligatoryForm($optional_conditions);
242  $this->tpl->setVariable('TABLE_SETTINGS',$form->getHTML());
243 
244  include_once './Services/AccessControl/classes/class.ilConditionHandlerTableGUI.php';
245  $table = new ilConditionHandlerTableGUI($this,'listConditions', ($_REQUEST["list_mode"] != "all"));
246  $table->setConditions(
248  $this->getTargetRefId(),
249  $this->getTargetId(),
250  $this->getTargetType()
251  )
252  );
253 
254  $this->tpl->setVariable('TABLE_CONDITIONS',$table->getHTML());
255  $this->tpl->setContent($table->getHTML());
256  }
257 
261  protected function saveObligatorySettings()
262  {
263  $form = $this->showObligatoryForm();
264  if($form->checkInput())
265  {
266  $old_mode = $form->getInput("old_list_mode");
267  switch($form->getInput("list_mode"))
268  {
269  case "all":
270  if($old_mode != "all")
271  {
272  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
274  $this->getTargetRefId(),
275  $this->getTargetId(),
276  $this->getTargetType()
277  );
278  // Set all optional conditions to obligatory
279  foreach((array) $optional_conditions as $item)
280  {
281  ilConditionHandler::updateObligatory($item["condition_id"], true);
282  }
283  }
284  break;
285 
286  case "subset":
287  $num_req = $form->getInput('required');
288  if($old_mode != "subset")
289  {
291  $this->getTargetRefId(),
292  $this->getTargetId(),
293  $this->getTargetType()
294  );
295  foreach($all_conditions as $item)
296  {
297  ilConditionHandler::updateObligatory($item["condition_id"], false);
298  }
299  $num_req = 1;
300  }
302  $this->getTargetRefId(),
303  $this->getTargetId(),
304  $num_req
305  );
306  break;
307  }
308 
309  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
310  $this->ctrl->redirect($this,'listConditions');
311  }
312 
313  $form->setValuesByPost();
314  ilUtil::sendFailure($this->lng->txt('err_check_input'));
315  $this->tpl->setContent($form->getHTML());
316  }
317 
321  protected function saveObligatoryList()
322  {
324  $this->getTargetRefId(),
325  $this->getTargetId(),
326  $this->getTargetType()
327  );
328 
329  if($_POST["obl"] && sizeof($_POST["obl"]) > sizeof($all_conditions)-2)
330  {
331  ilUtil::sendFailure($this->lng->txt("rbac_precondition_minimum_optional"), true);
332  $this->ctrl->redirect($this,'listConditions');
333  }
334 
335  foreach($all_conditions as $item)
336  {
337  $status = false;
338  if($_POST["obl"] && in_array($item["condition_id"], $_POST["obl"]))
339  {
340  $status = true;
341  }
342  ilConditionHandler::updateObligatory($item["condition_id"], $status);
343  }
344 
345  // re-calculate
347  $this->getTargetRefId(),
348  $this->getTargetId(),
349  $this->getTargetType(),
350  true
351  );
352 
353  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
354  $this->ctrl->redirect($this,'listConditions');
355  }
356 
361  protected function showObligatoryForm($opt = array())
362  {
363  if(!$opt)
364  {
366  $this->getTargetRefId(),
367  $this->getTargetId(),
368  $this->getTargetType()
369  );
370  }
371 
373 
374  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
375  $form = new ilPropertyFormGUI();
376  $form->setFormAction($this->ctrl->getFormAction($this),'listConditions');
377  $form->setTitle($this->lng->txt('precondition_obligatory_settings'));
378  $form->addCommandButton('saveObligatorySettings', $this->lng->txt('save'));
379 
380  $mode = new ilRadioGroupInputGUI($this->lng->txt("rbac_precondition_mode"), "list_mode");
381  $form->addItem($mode);
382  $mode->setValue($_REQUEST["list_mode"]);
383 
384  $mall = new ilRadioOption($this->lng->txt("rbac_precondition_mode_all"), "all");
385  $mall->setInfo($this->lng->txt("rbac_precondition_mode_all_info"));
386  $mode->addOption($mall);
387 
388  $msubset = new ilRadioOption($this->lng->txt("rbac_precondition_mode_subset"), "subset");
389  $msubset->setInfo($this->lng->txt("rbac_precondition_mode_subset_info"));
390  $mode->addOption($msubset);
391 
392  $obl = new ilNumberInputGUI($this->lng->txt('precondition_num_obligatory'), 'required');
393  $obl->setInfo($this->lng->txt('precondition_num_optional_info'));
394  if(count($opt))
395  {
397  $this->getTargetRefId(),
398  $this->getTargetId(),
399  $this->getTargetType()
400  );
401  $min = count($all) - count($opt) + 1;
402  $max = count($all) - 1;
403  }
404  else
405  {
406  $obligatory = $min = $max = 1;
407  }
408  $obl->setValue($obligatory);
409  $obl->setRequired(true);
410  $obl->setSize(1);
411  $obl->setMinValue($min);
412  $obl->setMaxValue($max);
413  $msubset->addSubItem($obl);
414 
415  $old_mode = new ilHiddenInputGUI("old_list_mode");
416  $old_mode->setValue($_REQUEST["list_mode"]);
417  $form->addItem($old_mode);
418 
419  return $form;
420  }
421 
422 
423  function edit()
424  {
425  global $ilObjDataCache;
426 
427  if(!$_GET['condition_id'])
428  {
429  ilUtil::sendFailure("Missing id: condition_id");
430  $this->listConditions();
431  return false;
432  }
433  $condition = ilConditionHandler::_getCondition((int) $_GET['condition_id']);
434 
435  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.condition_handler_edit_condition.html',
436  "Services/AccessControl");
437  $this->ctrl->setParameter($this,'condition_id',(int) $_GET['condition_id']);
438 
439  $this->initFormCondition($condition['trigger_ref_id'],(int) $_GET['condition_id'],'edit');
440  $this->tpl->setVariable('CONDITION_TABLE',$this->form->getHTML());
441  }
442 
443  function updateCondition()
444  {
445  global $ilObjDataCache;
446 
447  if(!$_GET['condition_id'])
448  {
449  ilUtil::sendFailure("Missing id: condition_id");
450  $this->listConditions();
451  return false;
452  }
453 
454  // Update condition
455  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
456  $condition_handler = new ilConditionHandler();
457 
458  $condition = ilConditionHandler::_getCondition((int) $_GET['condition_id']);
459  $condition_handler->setOperator($_POST['operator']);
460  $condition_handler->setObligatory((int) $_POST['obligatory']);
461  $condition_handler->setTargetRefId($this->getTargetRefId());
462  $condition_handler->setValue('');
463  switch($this->getTargetType())
464  {
465  case 'st':
466  $condition_handler->setReferenceHandlingType($_POST['ref_handling']);
467  break;
468 
469  default:
470  $condition_handler->setReferenceHandlingType(ilConditionHandler::UNIQUE_CONDITIONS);
471  break;
472  }
473  $condition_handler->updateCondition($condition['id']);
474 
475  // Update relevant sco's
476  if($condition['trigger_type'] == 'sahs')
477  {
478  include_once 'Services/Object/classes/class.ilObjectLP.php';
479  $olp = ilObjectLP::getInstance($condition['trigger_obj_id']);
480  $collection = $olp->getCollectionInstance();
481  if($collection)
482  {
483  $collection->delete();
484  }
485 
486  if(is_array($_POST['item_ids'])) // #12901
487  {
488  $collection->activateEntries($_POST['item_ids']);
489  }
490 
491  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
492  ilLPStatusWrapper::_refreshStatus($condition['trigger_obj_id']);
493  }
494 
495  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
496  $this->ctrl->redirect($this,'listConditions');
497  }
498 
499  function askDelete()
500  {
501  global $tpl;
502 
503  if(!count($_POST['conditions']))
504  {
505  ilUtil::sendFailure($this->lng->txt('no_condition_selected'));
506  $this->listConditions();
507  return true;
508  }
509 
510  // display confirmation message
511  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
512  $cgui = new ilConfirmationGUI();
513  $cgui->setFormAction($this->ctrl->getFormAction($this, "listConditions"));
514  $cgui->setHeaderText($this->lng->txt("rbac_condition_delete_sure"));
515  $cgui->setCancel($this->lng->txt("cancel"), "listConditions");
516  $cgui->setConfirm($this->lng->txt("delete"), "delete");
517 
518  // list conditions that should be deleted
519  foreach($_POST['conditions'] as $condition_id)
520  {
521  $condition = ilConditionHandler::_getCondition($condition_id);
522 
523  $title = ilObject::_lookupTitle($condition['trigger_obj_id']).
524  " (".$this->lng->txt("condition").": ".
525  $this->lng->txt('condition_'.$condition['operator']).")";
526  $icon = ilUtil::getImagePath('icon_'.$condition['trigger_type'].'_s.png');
527  $alt = $this->lng->txt('obj_'.$condition['trigger_type']);
528 
529  $cgui->addItem("conditions[]", $condition_id, $title, $icon, $alt);
530  }
531 
532  $tpl->setContent($cgui->getHTML());
533  }
534 
535  function delete()
536  {
537  if(!count($_POST['conditions']))
538  {
539  ilUtil::sendFailure($this->lng->txt('no_condition_selected'));
540  $this->listConditions();
541  return true;
542  }
543 
544  foreach($_POST['conditions'] as $condition_id)
545  {
546  $this->ch_obj->deleteCondition($condition_id);
547  }
548  ilUtil::sendSuccess($this->lng->txt('condition_deleted'),true);
549  $this->ctrl->redirect($this,'listConditions');
550 
551  return true;
552  }
553 
554  function selector()
555  {
556  global $tree;
557 
558  include_once ("./Services/AccessControl/classes/class.ilConditionSelector.php");
559 
560  $this->tpl->addBlockFile('ADM_CONTENT', "adm_content", "tpl.condition_selector.html",
561  "Services/AccessControl");
562 
563  ilUtil::sendInfo($this->lng->txt("condition_select_object"));
564 
565  $exp = new ilConditionSelector($this->ctrl->getLinkTarget($this,'copySelector'));
566  $exp->setExpand($_GET["condition_selector_expand"] ? $_GET["condition_selector_expand"] : $this->tree->readRootId());
567  $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'selector'));
568  $exp->setTargetGet("ref_id");
569  $exp->setRefId($this->getTargetRefId());
570 
571  if($this->getTargetRefId())
572  {
573  $path = $tree->getPathId($this->getTargetRefId());
574  array_pop($path);
575  $exp->setForceOpenPath($path);
576  }
577 
578  $exp->addFilter('crs');
579  $exp->addFilter('tst');
580  $exp->addFilter('sahs');
581  $exp->addFilter('svy');
582 
583  $exp->setSelectableTypes($this->ch_obj->getTriggerTypes());
584  $exp->setControlClass($this);
585  // build html-output
586  $exp->setOutput(0);
587 
588  $this->tpl->setCurrentBlock("adm_content");
589  $this->tpl->setVariable("EXPLORER",$exp->getOutput());
590  $this->tpl->parseCurrentBlock();
591  }
592 
593  function add()
594  {
595  global $ilObjDataCache;
596 
597  if(!$_GET['source_id'])
598  {
599  ilUtil::sendFailure("Missing id: condition_id");
600  $this->selector();
601  return false;
602  }
603 
604  $this->initFormCondition((int) $_GET['source_id'],0,'add');
605  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.condition_handler_add.html',
606  "Services/AccessControl");
607  $this->tpl->setVariable('CONDITION_TABLE',$this->form->getHTML());
608  }
609 
610 
614  function assign()
615  {
616  if(!isset($_GET['source_id']))
617  {
618  echo "class.ilConditionHandlerInterface: no source_id given";
619 
620  return false;
621  }
622  if(!$_POST['operator'])
623  {
624  ilUtil::sendFailure($this->lng->txt('err_check_input'));
625  $this->add();
626  return false;
627  }
628 
629  $this->ch_obj->setTargetRefId($this->getTargetRefId());
630  $this->ch_obj->setTargetObjId($this->getTargetId());
631  $this->ch_obj->setTargetType($this->getTargetType());
632 
633  switch($this->getTargetType())
634  {
635  case 'st':
636  $this->ch_obj->setReferenceHandlingType($_POST['ref_handling']);
637  break;
638 
639  default:
640  $this->ch_obj->setReferenceHandlingType(ilConditionHandler::UNIQUE_CONDITIONS);
641  break;
642  }
643  // this has to be changed, if non referenced trigger are implemted
644  if(!$trigger_obj =& ilObjectFactory::getInstanceByRefId((int) $_GET['source_id'],false))
645  {
646  echo 'ilConditionHandler: Trigger object does not exist';
647  }
648  $this->ch_obj->setTriggerRefId($trigger_obj->getRefId());
649  $this->ch_obj->setTriggerObjId($trigger_obj->getId());
650  $this->ch_obj->setTriggerType($trigger_obj->getType());
651  $this->ch_obj->setOperator($_POST['operator']);
652  $this->ch_obj->setObligatory((int) $_POST['obligatory']);
653  $this->ch_obj->setValue('');
654 
655  // Save assigned sco's
656  if($this->ch_obj->getTriggerType() == 'sahs')
657  {
658  include_once 'Services/Object/classes/class.ilObjectLP.php';
659  $olp = ilObjectLP::getInstance($this->ch_obj->getTriggerObjId());
660  $collection = $olp->getCollectionInstance();
661  if($collection)
662  {
663  $collection->delete();
664  }
665 
666  if(is_array($_POST['item_ids'])) // #12901
667  {
668  $collection->activateEntries($_POST['item_ids']);
669  }
670  }
671 
672  $this->ch_obj->enableAutomaticValidation($this->getAutomaticValidation());
673  if(!$this->ch_obj->storeCondition())
674  {
675  ilUtil::sendFailure($this->ch_obj->getErrorMessage(),true);
676  }
677  else
678  {
679  ilUtil::sendSuccess($this->lng->txt('added_new_condition'),true);
680  }
681 
682  $this->ctrl->redirect($this,'listConditions');
683 
684  return true;
685  }
686 
687  function chi_update()
688  {
689  #if(in_array('',$_POST['operator']))
690  #{
691  # ilUtil::sendInfo($this->lng->txt('select_one_operator'));
692 
693  # return false;
694  #}
695  foreach($this->__getConditionsOfTarget() as $condition)
696  {
697  $this->ch_obj->setOperator($_POST['operator'][$condition["id"]]);
698  $this->ch_obj->setValue($_POST['value'][$condition["id"]]);
699  $this->ch_obj->updateCondition($condition['id']);
700 
701  }
702  ilUtil::sendSuccess($this->lng->txt('conditions_updated'));
703 
704  $this->ctrl->returnToParent($this);
705 
706  return true;
707  }
709  {
710  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
711 
712  foreach(ilConditionHandler::_getConditionsOfTarget($this->getTargetRefId(),$this->getTargetId(), $this->getTargetType()) as $condition)
713  {
714  if($condition['operator'] == 'not_member')
715  {
716  continue;
717  }
718  else
719  {
720  $cond[] = $condition;
721  }
722  }
723  return $cond ? $cond : array();
724  }
725 
726  function __showButtons()
727  {
728  if(!$this->getBackButtons())
729  {
730  return false;
731  }
732 
733  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
734  foreach($this->getBackButtons() as $name => $link)
735  {
736  $this->tpl->setCurrentBlock("btn_cell");
737  $this->tpl->setVariable("BTN_LINK",$link);
738  $this->tpl->setVariable("BTN_TXT",$this->lng->txt($name));
739  $this->tpl->parseCurrentBlock();
740  }
741  }
742 
750  private function initFormCondition($a_source_id,$a_condition_id = 0,$a_mode = 'add')
751  {
752  $trigger_obj_id = ilObject::_lookupObjId($a_source_id);
753  $trigger_type = ilObject::_lookupType($trigger_obj_id);
754 
755  $condition = ilConditionHandler::_getCondition($a_condition_id);
756 
757  if(is_object($this->form))
758  {
759  return true;
760  }
761  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
762  $this->form = new ilPropertyFormGUI();
763  $this->ctrl->setParameter($this,'source_id',$a_source_id);
764  $this->form->setFormAction($this->ctrl->getFormAction($this));
765 
766  $info_source = new ilNonEditableValueGUI($this->lng->txt("rbac_precondition_source"));
767  $info_source->setValue(ilObject::_lookupTitle(ilObject::_lookupObjId($a_source_id)));
768  $this->form->addItem($info_source);
769 
770  $info_target = new ilNonEditableValueGUI($this->lng->txt("rbac_precondition_target"));
771  $info_target->setValue($this->getTargetTitle());
772  $this->form->addItem($info_target);
773 
774  /* moved to list
775  $obl = new ilCheckboxInputGUI($this->lng->txt('precondition_obligatory'), 'obligatory');
776  $obl->setInfo($this->lng->txt('precondition_obligatory_info'));
777  $obl->setValue(1);
778  if($a_condition_id)
779  {
780  $obl->setChecked($condition['obligatory']);
781  }
782  else
783  {
784  $obl->setChecked(true);
785  }
786  $this->form->addItem($obl);
787  */
788  $obl = new ilHiddenInputGUI('obligatory');
789  if($a_condition_id)
790  {
791  $obl->setValue($condition['obligatory']);
792  }
793  else
794  {
795  $obl->setValue(1);
796  }
797  $this->form->addItem($obl);
798 
799  $sel = new ilSelectInputGUI($this->lng->txt('condition'),'operator');
800  include_once "./Services/AccessControl/classes/class.ilConditionHandler.php";
801  $ch_obj = new ilConditionHandler();
802  if($a_mode == 'add')
803  {
804  $operators[0] = $this->lng->txt('select_one');
805  }
806  foreach($ch_obj->getOperatorsByTargetType($trigger_type) as $operator)
807  {
808  $operators[$operator] = $this->lng->txt('condition_'.$operator);
809  }
810  $sel->setValue(isset($condition['operator']) ? $condition['operator'] : 0);
811  $sel->setOptions($operators);
812  $sel->setRequired(true);
813  $this->form->addItem($sel);
814 
816  {
817  $rad_opt = new ilRadioGroupInputGUI($this->lng->txt('cond_ref_handling'),'ref_handling');
818  $rad_opt->setValue(isset($condition['ref_handling']) ? $condition['ref_handling'] : ilConditionHandler::SHARED_CONDITIONS);
819 
820  $opt2 = new ilRadioOption($this->lng->txt('cond_ref_shared'),ilConditionHandler::SHARED_CONDITIONS);
821  $rad_opt->addOption($opt2);
822 
823  $opt1 = new ilRadioOption($this->lng->txt('cond_ref_unique'),ilConditionHandler::UNIQUE_CONDITIONS);
824  $rad_opt->addOption($opt1);
825 
826  $this->form->addItem($rad_opt);
827  }
828 
829  // Additional settings for SCO's
830  if($trigger_type == 'sahs')
831  {
832  $this->lng->loadLanguageModule('trac');
833 
834  $cus = new ilCustomInputGUI($this->lng->txt('trac_sahs_relevant_items'),'item_ids[]');
835  $cus->setRequired(true);
836 
837  $tpl = new ilTemplate('tpl.condition_handler_sco_row.html',true,true,
838  "Services/AccessControl");
839  $counter = 0;
840 
841  include_once 'Services/Object/classes/class.ilObjectLP.php';
842  $olp = ilObjectLP::getInstance($trigger_obj_id);
843  $collection = $olp->getCollectionInstance();
844  if($collection)
845  {
846  foreach($collection->getPossibleItems() as $item_id => $sahs_item)
847  {
848  $tpl->setCurrentBlock("sco_row");
849  $tpl->setVariable('SCO_ID',$item_id);
850  $tpl->setVariable('SCO_TITLE',$sahs_item['title']);
851  $tpl->setVariable('CHECKED',$collection->isAssignedEntry($item_id) ? 'checked="checked"' : '');
852  $tpl->parseCurrentBlock();
853  $counter++;
854  }
855  }
856  $tpl->setVariable('INFO_SEL',$this->lng->txt('trac_lp_determination_info_sco'));
857  $cus->setHTML($tpl->get());
858  $this->form->addItem($cus);
859  }
860  switch($a_mode)
861  {
862  case 'edit':
863  $this->form->setTitleIcon(ilUtil::getImagePath('icon_'.$this->getTargetType().'.png'));
864  $this->form->setTitle($this->lng->txt('rbac_edit_condition'));
865  $this->form->addCommandButton('updateCondition',$this->lng->txt('save'));
866  $this->form->addCommandButton('listConditions',$this->lng->txt('cancel'));
867  break;
868 
869 
870  case 'add':
871  $this->form->setTitleIcon(ilUtil::getImagePath('icon_'.$this->getTargetType().'.png'));
872  $this->form->setTitle($this->lng->txt('add_condition'));
873  $this->form->addCommandButton('assign',$this->lng->txt('save'));
874  $this->form->addCommandButton('selector',$this->lng->txt('back'));
875  break;
876  }
877  return true;
878  }
879 }
880 ?>