ILIAS  release_4-3 Revision
 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  if(sizeof($optional_conditions) > 1)
279  {
280  // Set all optional conditions to obligatory
281  foreach($optional_conditions as $item)
282  {
283  ilConditionHandler::updateObligatory($item["condition_id"], true);
284  }
285  }
286  }
287  break;
288 
289  case "subset":
290  $num_req = $form->getInput('required');
291  if($old_mode != "subset")
292  {
294  $this->getTargetRefId(),
295  $this->getTargetId(),
296  $this->getTargetType()
297  );
298  foreach($all_conditions as $item)
299  {
300  ilConditionHandler::updateObligatory($item["condition_id"], false);
301  }
302  $num_req = 1;
303  }
305  $this->getTargetRefId(),
306  $this->getTargetId(),
307  $num_req
308  );
309  break;
310  }
311 
312  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
313  $this->ctrl->redirect($this,'listConditions');
314  }
315 
316  $form->setValuesByPost();
317  ilUtil::sendFailure($this->lng->txt('err_check_input'));
318  $this->tpl->setContent($form->getHTML());
319  }
320 
324  protected function saveObligatoryList()
325  {
327  $this->getTargetRefId(),
328  $this->getTargetId(),
329  $this->getTargetType()
330  );
331 
332  if($_POST["obl"] && sizeof($_POST["obl"]) > sizeof($all_conditions)-2)
333  {
334  ilUtil::sendFailure($this->lng->txt("rbac_precondition_minimum_optional"), true);
335  $this->ctrl->redirect($this,'listConditions');
336  }
337 
338  foreach($all_conditions as $item)
339  {
340  $status = false;
341  if($_POST["obl"] && in_array($item["condition_id"], $_POST["obl"]))
342  {
343  $status = true;
344  }
345  ilConditionHandler::updateObligatory($item["condition_id"], $status);
346  }
347 
348  // re-calculate
350  $this->getTargetRefId(),
351  $this->getTargetId(),
352  $this->getTargetType(),
353  true
354  );
355 
356  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
357  $this->ctrl->redirect($this,'listConditions');
358  }
359 
364  protected function showObligatoryForm($opt = array())
365  {
366  if(!$opt)
367  {
369  $this->getTargetRefId(),
370  $this->getTargetId(),
371  $this->getTargetType()
372  );
373  }
374 
376 
377  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
378  $form = new ilPropertyFormGUI();
379  $form->setFormAction($this->ctrl->getFormAction($this),'listConditions');
380  $form->setTitle($this->lng->txt('precondition_obligatory_settings'));
381  $form->addCommandButton('saveObligatorySettings', $this->lng->txt('save'));
382 
383  $mode = new ilRadioGroupInputGUI($this->lng->txt("rbac_precondition_mode"), "list_mode");
384  $form->addItem($mode);
385  $mode->setValue($_REQUEST["list_mode"]);
386 
387  $mall = new ilRadioOption($this->lng->txt("rbac_precondition_mode_all"), "all");
388  $mall->setInfo($this->lng->txt("rbac_precondition_mode_all_info"));
389  $mode->addOption($mall);
390 
391  $msubset = new ilRadioOption($this->lng->txt("rbac_precondition_mode_subset"), "subset");
392  $msubset->setInfo($this->lng->txt("rbac_precondition_mode_subset_info"));
393  $mode->addOption($msubset);
394 
395  $obl = new ilNumberInputGUI($this->lng->txt('precondition_num_obligatory'), 'required');
396  $obl->setInfo($this->lng->txt('precondition_num_optional_info'));
397  if(count($opt))
398  {
400  $this->getTargetRefId(),
401  $this->getTargetId(),
402  $this->getTargetType()
403  );
404  $min = count($all) - count($opt) + 1;
405  $max = count($all) - 1;
406  }
407  else
408  {
409  $obligatory = $min = $max = 1;
410  }
411  $obl->setValue($obligatory);
412  $obl->setRequired(true);
413  $obl->setSize(1);
414  $obl->setMinValue($min);
415  $obl->setMaxValue($max);
416  $msubset->addSubItem($obl);
417 
418  $old_mode = new ilHiddenInputGUI("old_list_mode");
419  $old_mode->setValue($_REQUEST["list_mode"]);
420  $form->addItem($old_mode);
421 
422  return $form;
423  }
424 
425 
426  function edit()
427  {
428  global $ilObjDataCache;
429 
430  if(!$_GET['condition_id'])
431  {
432  ilUtil::sendFailure("Missing id: condition_id");
433  $this->listConditions();
434  return false;
435  }
436  $condition = ilConditionHandler::_getCondition((int) $_GET['condition_id']);
437 
438  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.condition_handler_edit_condition.html',
439  "Services/AccessControl");
440  $this->ctrl->setParameter($this,'condition_id',(int) $_GET['condition_id']);
441 
442  $this->initFormCondition($condition['trigger_ref_id'],(int) $_GET['condition_id'],'edit');
443  $this->tpl->setVariable('CONDITION_TABLE',$this->form->getHTML());
444  }
445 
446  function updateCondition()
447  {
448  global $ilObjDataCache;
449 
450  if(!$_GET['condition_id'])
451  {
452  ilUtil::sendFailure("Missing id: condition_id");
453  $this->listConditions();
454  return false;
455  }
456 
457  // Update condition
458  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
459  $condition_handler = new ilConditionHandler();
460 
461  $condition = ilConditionHandler::_getCondition((int) $_GET['condition_id']);
462  $condition_handler->setOperator($_POST['operator']);
463  $condition_handler->setObligatory((int) $_POST['obligatory']);
464  $condition_handler->setTargetRefId($this->getTargetRefId());
465  $condition_handler->setValue('');
466  switch($this->getTargetType())
467  {
468  case 'st':
469  $condition_handler->setReferenceHandlingType($_POST['ref_handling']);
470  break;
471 
472  default:
473  $condition_handler->setReferenceHandlingType(ilConditionHandler::UNIQUE_CONDITIONS);
474  break;
475  }
476  $condition_handler->updateCondition($condition['id']);
477 
478  // Update relevant sco's
479  if($condition['trigger_type'] == 'sahs')
480  {
481  include_once 'Services/Tracking/classes/class.ilLPCollections.php';
482  $lp_collection = new ilLPCollections($condition['trigger_obj_id']);
483  $lp_collection->deleteAll();
484 
485  $items = is_array($_POST['item_ids']) ? $_POST['item_ids'] : array();
486  foreach($items as $item_id)
487  {
488  $lp_collection->add($item_id);
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/Tracking/classes/class.ilLPCollections.php';
659  $lp_collection = new ilLPCollections($this->ch_obj->getTriggerObjId());
660  $lp_collection->deleteAll();
661 
662  $items = is_array($_POST['item_ids']) ? $_POST['item_ids'] : array();
663  foreach($items as $item_id)
664  {
665  $lp_collection->add($item_id);
666  }
667  }
668 
669  $this->ch_obj->enableAutomaticValidation($this->getAutomaticValidation());
670  if(!$this->ch_obj->storeCondition())
671  {
672  ilUtil::sendFailure($this->ch_obj->getErrorMessage(),true);
673  }
674  else
675  {
676  ilUtil::sendSuccess($this->lng->txt('added_new_condition'),true);
677  }
678 
679  $this->ctrl->redirect($this,'listConditions');
680 
681  return true;
682  }
683 
684  function chi_update()
685  {
686  #if(in_array('',$_POST['operator']))
687  #{
688  # ilUtil::sendInfo($this->lng->txt('select_one_operator'));
689 
690  # return false;
691  #}
692  foreach($this->__getConditionsOfTarget() as $condition)
693  {
694  $this->ch_obj->setOperator($_POST['operator'][$condition["id"]]);
695  $this->ch_obj->setValue($_POST['value'][$condition["id"]]);
696  $this->ch_obj->updateCondition($condition['id']);
697 
698  }
699  ilUtil::sendSuccess($this->lng->txt('conditions_updated'));
700 
701  $this->ctrl->returnToParent($this);
702 
703  return true;
704  }
706  {
707  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
708 
709  foreach(ilConditionHandler::_getConditionsOfTarget($this->getTargetRefId(),$this->getTargetId(), $this->getTargetType()) as $condition)
710  {
711  if($condition['operator'] == 'not_member')
712  {
713  continue;
714  }
715  else
716  {
717  $cond[] = $condition;
718  }
719  }
720  return $cond ? $cond : array();
721  }
722 
723  function __showButtons()
724  {
725  if(!$this->getBackButtons())
726  {
727  return false;
728  }
729 
730  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
731  foreach($this->getBackButtons() as $name => $link)
732  {
733  $this->tpl->setCurrentBlock("btn_cell");
734  $this->tpl->setVariable("BTN_LINK",$link);
735  $this->tpl->setVariable("BTN_TXT",$this->lng->txt($name));
736  $this->tpl->parseCurrentBlock();
737  }
738  }
739 
747  private function initFormCondition($a_source_id,$a_condition_id = 0,$a_mode = 'add')
748  {
749  $trigger_obj_id = ilObject::_lookupObjId($a_source_id);
750  $trigger_type = ilObject::_lookupType($trigger_obj_id);
751 
752  $condition = ilConditionHandler::_getCondition($a_condition_id);
753 
754  if(is_object($this->form))
755  {
756  return true;
757  }
758  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
759  $this->form = new ilPropertyFormGUI();
760  $this->ctrl->setParameter($this,'source_id',$a_source_id);
761  $this->form->setFormAction($this->ctrl->getFormAction($this));
762 
763  $info_source = new ilNonEditableValueGUI($this->lng->txt("rbac_precondition_source"));
764  $info_source->setValue(ilObject::_lookupTitle(ilObject::_lookupObjId($a_source_id)));
765  $this->form->addItem($info_source);
766 
767  $info_target = new ilNonEditableValueGUI($this->lng->txt("rbac_precondition_target"));
768  $info_target->setValue($this->getTargetTitle());
769  $this->form->addItem($info_target);
770 
771  /* moved to list
772  $obl = new ilCheckboxInputGUI($this->lng->txt('precondition_obligatory'), 'obligatory');
773  $obl->setInfo($this->lng->txt('precondition_obligatory_info'));
774  $obl->setValue(1);
775  if($a_condition_id)
776  {
777  $obl->setChecked($condition['obligatory']);
778  }
779  else
780  {
781  $obl->setChecked(true);
782  }
783  $this->form->addItem($obl);
784  */
785  $obl = new ilHiddenInputGUI('obligatory');
786  if($a_condition_id)
787  {
788  $obl->setValue($condition['obligatory']);
789  }
790  else
791  {
792  $obl->setValue(1);
793  }
794  $this->form->addItem($obl);
795 
796  $sel = new ilSelectInputGUI($this->lng->txt('condition'),'operator');
797  include_once "./Services/AccessControl/classes/class.ilConditionHandler.php";
798  $ch_obj = new ilConditionHandler();
799  if($a_mode == 'add')
800  {
801  $operators[0] = $this->lng->txt('select_one');
802  }
803  foreach($ch_obj->getOperatorsByTargetType($trigger_type) as $operator)
804  {
805  $operators[$operator] = $this->lng->txt('condition_'.$operator);
806  }
807  $sel->setValue(isset($condition['operator']) ? $condition['operator'] : 0);
808  $sel->setOptions($operators);
809  $sel->setRequired(true);
810  $this->form->addItem($sel);
811 
813  {
814  $rad_opt = new ilRadioGroupInputGUI($this->lng->txt('cond_ref_handling'),'ref_handling');
815  $rad_opt->setValue(isset($condition['ref_handling']) ? $condition['ref_handling'] : ilConditionHandler::SHARED_CONDITIONS);
816 
817  $opt2 = new ilRadioOption($this->lng->txt('cond_ref_shared'),ilConditionHandler::SHARED_CONDITIONS);
818  $rad_opt->addOption($opt2);
819 
820  $opt1 = new ilRadioOption($this->lng->txt('cond_ref_unique'),ilConditionHandler::UNIQUE_CONDITIONS);
821  $rad_opt->addOption($opt1);
822 
823  $this->form->addItem($rad_opt);
824  }
825 
826  // Additional settings for SCO's
827  if($trigger_type == 'sahs')
828  {
829  $this->lng->loadLanguageModule('trac');
830  include_once 'Services/Tracking/classes/class.ilLPCollections.php';
831  $lp_collections = new ilLPCollections($trigger_obj_id);
832 
833  $cus = new ilCustomInputGUI($this->lng->txt('trac_sahs_relevant_items'),'item_ids[]');
834  $cus->setRequired(true);
835 
836  $tpl = new ilTemplate('tpl.condition_handler_sco_row.html',true,true,
837  "Services/AccessControl");
838  $counter = 0;
839 
840  foreach(ilLPCollections::_getPossibleSAHSItems($trigger_obj_id) as $item_id => $sahs_item)
841  {
842  $tpl->setCurrentBlock("sco_row");
843  $tpl->setVariable('SCO_ID',$item_id);
844  $tpl->setVariable('SCO_TITLE',$sahs_item['title']);
845  $tpl->setVariable('CHECKED',$lp_collections->isAssigned($item_id) ? 'checked="checked"' : '');
846  $tpl->parseCurrentBlock();
847  $counter++;
848  }
849  $tpl->setVariable('INFO_SEL',$this->lng->txt('trac_lp_determination_info_sco'));
850  $cus->setHTML($tpl->get());
851  $this->form->addItem($cus);
852  }
853  switch($a_mode)
854  {
855  case 'edit':
856  $this->form->setTitleIcon(ilUtil::getImagePath('icon_'.$this->getTargetType().'.png'));
857  $this->form->setTitle($this->lng->txt('rbac_edit_condition'));
858  $this->form->addCommandButton('updateCondition',$this->lng->txt('save'));
859  $this->form->addCommandButton('listConditions',$this->lng->txt('cancel'));
860  break;
861 
862 
863  case 'add':
864  $this->form->setTitleIcon(ilUtil::getImagePath('icon_'.$this->getTargetType().'.png'));
865  $this->form->setTitle($this->lng->txt('add_condition'));
866  $this->form->addCommandButton('assign',$this->lng->txt('save'));
867  $this->form->addCommandButton('selector',$this->lng->txt('back'));
868  break;
869  }
870  return true;
871  }
872 }
873 ?>