ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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  public $ctrl = null;
18 
19  public $lng;
20  public $tpl;
21  public $tree;
22 
23  public $ch_obj;
24  public $target_obj;
25  public $client_obj;
26  public $target_id;
27  public $target_type;
28  public $target_title;
30 
31  public $automatic_validation = true;
32 
42  public function __construct($gui_obj, $a_ref_id = null)
43  {
44  global $DIC;
45 
46  $lng = $DIC['lng'];
47  $tpl = $DIC['tpl'];
48  $tree = $DIC['tree'];
49  $ilCtrl = $DIC['ilCtrl'];
50 
51  $this->ch_obj = new ilConditionHandler();
52 
53  $this->ctrl = $ilCtrl;
54  $this->gui_obj = $gui_obj;
55  $this->lng = $lng;
56  $this->lng->loadLanguageModule('rbac');
57  $this->lng->loadLanguageModule('cond');
58  $this->tpl = $tpl;
59  $this->tree = $tree;
60 
61  if ($a_ref_id) {
62  $this->target_obj = &ilObjectFactory::getInstanceByRefId($a_ref_id);
63  } else {
64  $this->target_obj = &$this->gui_obj->object;
65  }
66 
67  // this only works for ilObject derived objects (other objects
68  // should call set() methods manually
69  if (is_object($this->target_obj)) {
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) {
85  $GLOBALS['DIC']['lng']->loadLanguageModule('trac');
86  include_once './Services/Tracking/classes/class.ilLPObjSettings.php';
87  $obj_settings = new ilLPObjSettings($a_obj_id);
88  return ilLPObjSettings::_mode2Text($obj_settings->getMode());
89 
90  default:
91  $GLOBALS['DIC']['lng']->loadLanguageModule('rbac');
92  return $GLOBALS['DIC']['lng']->txt('condition_' . $a_operator);
93  }
94  }
95 
100  protected function getConditionHandler()
101  {
102  return $this->ch_obj;
103  }
104 
105  public function setBackButtons($a_btn_arr)
106  {
107  $_SESSION['precon_btn'] = $a_btn_arr;
108  }
109  public function getBackButtons()
110  {
111  return $_SESSION['precon_btn'] ? $_SESSION['precon_btn'] : array();
112  }
113 
114  public function executeCommand()
115  {
116  global $DIC;
117 
118  $ilErr = $DIC['ilErr'];
119  $ilAccess = $DIC['ilAccess'];
120  $lng = $DIC['lng'];
121 
122  if (!$ilAccess->checkAccess('write', '', $this->getTargetRefId())) {
123  $ilErr->raiseError($lng->txt('permission_denied'), $ilErr->WARNING);
124  }
125 
126  $next_class = $this->ctrl->getNextClass($this);
127  $cmd = $this->ctrl->getCmd();
128 
129  switch ($next_class) {
130  default:
131  if (empty($cmd)) {
132  $cmd = "view";
133  }
134  $this->$cmd();
135  break;
136  }
137  }
138 
139  public function setAutomaticValidation($a_status)
140  {
141  $this->automatic_validation = $a_status;
142  }
143  public function getAutomaticValidation()
144  {
146  }
147 
148 
152  public function setTargetId($a_target_id)
153  {
154  $this->target_id = $a_target_id;
155  }
156 
160  public function getTargetId()
161  {
162  return $this->target_id;
163  }
164 
168  public function setTargetRefId($a_target_ref_id)
169  {
170  $this->target_ref_id = $a_target_ref_id;
171  }
172 
176  public function getTargetRefId()
177  {
178  return $this->target_ref_id;
179  }
180 
184  public function setTargetType($a_target_type)
185  {
186  $this->target_type = $a_target_type;
187  }
188 
192  public function getTargetType()
193  {
194  return $this->target_type;
195  }
196 
200  public 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  public function getTargetTitle()
218  {
219  return $this->target_title;
220  }
221 
226  protected function listConditions()
227  {
228  global $DIC;
229 
230  $util = $DIC->conditions()->util();
231 
232  // check if parent deals with conditions
233  if ($this->getTargetRefId() > 0 && $util->isUnderParentControl($this->getTargetRefId())) {
234  ilUtil::sendInfo($this->lng->txt("cond_under_parent_control"));
235  return;
236  }
237 
238  $ilToolbar = $DIC['ilToolbar'];
239 
240  $ilToolbar->addButton($this->lng->txt('add_condition'), $this->ctrl->getLinkTarget($this, 'selector'));
241 
242  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.list_conditions.html', 'Services/AccessControl');
243 
245  $this->getTargetRefId(),
246  $this->getTargetId(),
247  $this->getTargetType()
248  );
249  if (count($optional_conditions)) {
250  if (!$_REQUEST["list_mode"]) {
251  $_REQUEST["list_mode"] = "subset";
252  }
253  } elseif (!$_REQUEST["list_mode"]) {
254  $_REQUEST["list_mode"] = "all";
255  }
256 
257  // Show form only if conditions are availabe
259  $this->getTargetRefId(),
260  $this->getTargetId(),
261  $this->getTargetType()
262  ))
263  ) {
264  $form = $this->showObligatoryForm($optional_conditions);
265  if ($form instanceof ilPropertyFormGUI) {
266  $this->tpl->setVariable('TABLE_SETTINGS', $form->getHTML());
267  }
268  }
269 
270  $table = new ilConditionHandlerTableGUI($this, 'listConditions', ($_REQUEST["list_mode"] != "all"));
271  $table->setConditions(
273  $this->getTargetRefId(),
274  $this->getTargetId(),
275  $this->getTargetType()
276  )
277  );
278 
279  $h = $table->getHTML();
280  $this->tpl->setVariable('TABLE_CONDITIONS', $h);
281  //$this->tpl->setContent($h);
282  }
283 
287  protected function saveObligatorySettings()
288  {
289  $form = $this->showObligatoryForm();
290  if ($form->checkInput()) {
291  $old_mode = $form->getInput("old_list_mode");
292  switch ($form->getInput("list_mode")) {
293  case "all":
294  if ($old_mode != "all") {
296  $this->getTargetRefId(),
297  $this->getTargetId(),
298  $this->getTargetType()
299  );
300  // Set all optional conditions to obligatory
301  foreach ((array) $optional_conditions as $item) {
302  ilConditionHandler::updateObligatory($item["condition_id"], true);
303  }
304  }
305  break;
306 
307  case "subset":
308  $num_req = $form->getInput('required');
309  if ($old_mode != "subset") {
311  $this->getTargetRefId(),
312  $this->getTargetId(),
313  $this->getTargetType()
314  );
315  foreach ($all_conditions as $item) {
316  ilConditionHandler::updateObligatory($item["condition_id"], false);
317  }
318  }
320  $this->getTargetRefId(),
321  $this->getTargetId(),
322  $num_req
323  );
324  break;
325  }
326 
327  $cond = new ilConditionHandler();
328  $cond->setTargetRefId($this->getTargetRefId());
329  $cond->updateHiddenStatus((int) $form->getInput('hidden'));
330 
331  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
332  $this->ctrl->redirect($this, 'listConditions');
333  }
334 
335  $form->setValuesByPost();
336  ilUtil::sendFailure($this->lng->txt('err_check_input'));
337  $this->tpl->setContent($form->getHTML());
338  }
339 
343  protected function saveObligatoryList()
344  {
346  $this->getTargetRefId(),
347  $this->getTargetId(),
348  $this->getTargetType()
349  );
350 
351  if ($_POST["obl"] && sizeof($_POST["obl"]) > sizeof($all_conditions) - 2) {
352  ilUtil::sendFailure($this->lng->txt("rbac_precondition_minimum_optional"), true);
353  $this->ctrl->redirect($this, 'listConditions');
354  }
355 
356  foreach ($all_conditions as $item) {
357  $status = false;
358  if ($_POST["obl"] && in_array($item["condition_id"], $_POST["obl"])) {
359  $status = true;
360  }
361  ilConditionHandler::updateObligatory($item["condition_id"], $status);
362  }
363 
364  // re-calculate
366  $this->getTargetRefId(),
367  $this->getTargetId(),
368  $this->getTargetType(),
369  true
370  );
371 
372  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
373  $this->ctrl->redirect($this, 'listConditions');
374  }
375 
380  protected function showObligatoryForm($opt = array())
381  {
382  if (!$GLOBALS['DIC']['objDefinition']->isRbacObject($this->getTargetType())) {
383  return;
384  }
385 
386 
387  if (!$opt) {
389  $this->getTargetRefId(),
390  $this->getTargetId(),
391  $this->getTargetType()
392  );
393  }
394 
396 
397  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
398  $form = new ilPropertyFormGUI();
399  $form->setFormAction($this->ctrl->getFormAction($this), 'listConditions');
400  $form->setTitle($this->lng->txt('precondition_obligatory_settings'));
401  $form->addCommandButton('saveObligatorySettings', $this->lng->txt('save'));
402 
403  $hide = new ilCheckboxInputGUI($this->lng->txt('rbac_precondition_hide'), 'hidden');
405  $hide->setValue(1);
406  $hide->setInfo($this->lng->txt('rbac_precondition_hide_info'));
407  $form->addItem($hide);
408 
409  $mode = new ilRadioGroupInputGUI($this->lng->txt("rbac_precondition_mode"), "list_mode");
410  $form->addItem($mode);
411  $mode->setValue($_REQUEST["list_mode"]);
412 
413  $mall = new ilRadioOption($this->lng->txt("rbac_precondition_mode_all"), "all");
414  $mall->setInfo($this->lng->txt("rbac_precondition_mode_all_info"));
415  $mode->addOption($mall);
416 
417 
418  if (count($all) > 1) {
419  $min = 1;
420  $max = count($all) - 1;
421 
422  $msubset = new ilRadioOption($this->lng->txt("rbac_precondition_mode_subset"), "subset");
423  $msubset->setInfo($this->lng->txt("rbac_precondition_mode_subset_info"));
424  $mode->addOption($msubset);
425 
426  $obl = new ilNumberInputGUI($this->lng->txt('precondition_num_obligatory'), 'required');
427  $obl->setInfo($this->lng->txt('precondition_num_optional_info'));
428 
430  $obl->setValue($num_required > 0 ? $num_required : null);
431  $obl->setRequired(true);
432  $obl->setSize(1);
433  $obl->setMinValue($min);
434  $obl->setMaxValue($max);
435  $msubset->addSubItem($obl);
436  }
437 
438  $old_mode = new ilHiddenInputGUI("old_list_mode");
439  $old_mode->setValue($_REQUEST["list_mode"]);
440  $form->addItem($old_mode);
441 
442  return $form;
443  }
444 
445 
446  public function edit()
447  {
448  global $DIC;
449 
450  $ilObjDataCache = $DIC['ilObjDataCache'];
451 
452  if (!$_GET['condition_id']) {
453  ilUtil::sendFailure("Missing id: condition_id");
454  $this->listConditions();
455  return false;
456  }
457  $condition = ilConditionHandler::_getCondition((int) $_GET['condition_id']);
458 
459  $this->tpl->addBlockfile(
460  'ADM_CONTENT',
461  'adm_content',
462  'tpl.condition_handler_edit_condition.html',
463  "Services/AccessControl"
464  );
465  $this->ctrl->setParameter($this, 'condition_id', (int) $_GET['condition_id']);
466 
467  $this->initFormCondition($condition['trigger_ref_id'], (int) $_GET['condition_id'], 'edit');
468  $this->tpl->setVariable('CONDITION_TABLE', $this->form->getHTML());
469  }
470 
471  public function updateCondition()
472  {
473  global $DIC;
474 
475  $ilObjDataCache = $DIC['ilObjDataCache'];
476 
477  if (!$_GET['condition_id']) {
478  ilUtil::sendFailure("Missing id: condition_id");
479  $this->listConditions();
480  return false;
481  }
482 
483  // Update condition
484  $condition_handler = new ilConditionHandler();
485 
486  $condition = ilConditionHandler::_getCondition((int) $_GET['condition_id']);
487  $condition_handler->setOperator($_POST['operator']);
488  $condition_handler->setObligatory((int) $_POST['obligatory']);
489  $condition_handler->setTargetRefId($this->getTargetRefId());
490  $condition_handler->setValue('');
491  switch ($this->getTargetType()) {
492  case 'st':
493  $condition_handler->setReferenceHandlingType($_POST['ref_handling']);
494  break;
495 
496  default:
497  $condition_handler->setReferenceHandlingType(ilConditionHandler::UNIQUE_CONDITIONS);
498  break;
499  }
500  $condition_handler->updateCondition($condition['id']);
501 
502  // Update relevant sco's
503  if ($condition['trigger_type'] == 'sahs') {
504  include_once 'Services/Object/classes/class.ilObjectLP.php';
505  $olp = ilObjectLP::getInstance($condition['trigger_obj_id']);
506  $collection = $olp->getCollectionInstance();
507  if ($collection) {
508  $collection->delete();
509  }
510 
511  if (is_array($_POST['item_ids'])) { // #12901
512  $collection->activateEntries($_POST['item_ids']);
513  }
514 
515  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
516  ilLPStatusWrapper::_refreshStatus($condition['trigger_obj_id']);
517  }
518 
519  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
520  $this->ctrl->redirect($this, 'listConditions');
521  }
522 
523  public function askDelete()
524  {
525  global $DIC;
526 
527  $tpl = $DIC['tpl'];
528 
529  if (!count($_POST['conditions'])) {
530  ilUtil::sendFailure($this->lng->txt('no_condition_selected'));
531  $this->listConditions();
532  return true;
533  }
534 
535  // display confirmation message
536  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
537  $cgui = new ilConfirmationGUI();
538  $cgui->setFormAction($this->ctrl->getFormAction($this, "listConditions"));
539  $cgui->setHeaderText($this->lng->txt("rbac_condition_delete_sure"));
540  $cgui->setCancel($this->lng->txt("cancel"), "listConditions");
541  $cgui->setConfirm($this->lng->txt("delete"), "delete");
542 
543  // list conditions that should be deleted
544  foreach ($_POST['conditions'] as $condition_id) {
545  $condition = ilConditionHandler::_getCondition($condition_id);
546 
547  $title = ilObject::_lookupTitle($condition['trigger_obj_id']) .
548  " (" . $this->lng->txt("condition") . ": " .
549  $this->lng->txt('condition_' . $condition['operator']) . ")";
550  $icon = ilUtil::getImagePath('icon_' . $condition['trigger_type'] . '.svg');
551  $alt = $this->lng->txt('obj_' . $condition['trigger_type']);
552 
553  $cgui->addItem("conditions[]", $condition_id, $title, $icon, $alt);
554  }
555 
556  $tpl->setContent($cgui->getHTML());
557  }
558 
559  public function delete()
560  {
561  if (!count($_POST['conditions'])) {
562  ilUtil::sendFailure($this->lng->txt('no_condition_selected'));
563  $this->listConditions();
564  return true;
565  }
566 
567  foreach ($_POST['conditions'] as $condition_id) {
568  $this->ch_obj->deleteCondition($condition_id);
569  }
570  ilUtil::sendSuccess($this->lng->txt('condition_deleted'), true);
571  $this->ctrl->redirect($this, 'listConditions');
572 
573  return true;
574  }
575 
576  public function selector()
577  {
578  ilUtil::sendInfo($this->lng->txt("condition_select_object"));
579 
580  $exp = new ilConditionSelector($this, "selector");
581  $exp->setTypeWhiteList(array_merge(
582  $this->getConditionHandler()->getTriggerTypes(),
583  array("root", "cat", "grp", "fold", "crs", "prg")
584  ));
585  //setRefId have to be after setTypeWhiteList!
586  $exp->setRefId($this->getTargetRefId());
587  $exp->setClickableTypes($this->getConditionHandler()->getTriggerTypes());
588 
589  if (!$exp->handleCommand()) {
590  $this->tpl->setContent($exp->getHTML());
591  }
592  }
593 
594  public function add()
595  {
596  global $DIC;
597 
598  $ilObjDataCache = $DIC['ilObjDataCache'];
599 
600  if (!$_GET['source_id']) {
601  ilUtil::sendFailure("Missing id: condition_id");
602  $this->selector();
603  return false;
604  }
605 
606  $this->initFormCondition((int) $_GET['source_id'], 0, 'add');
607  $this->tpl->addBlockfile(
608  'ADM_CONTENT',
609  'adm_content',
610  'tpl.condition_handler_add.html',
611  "Services/AccessControl"
612  );
613  $this->tpl->setVariable('CONDITION_TABLE', $this->form->getHTML());
614  }
615 
616 
620  public function assign()
621  {
622  if (!isset($_GET['source_id'])) {
623  echo "class.ilConditionHandlerGUI: no source_id given";
624 
625  return false;
626  }
627  if (!$_POST['operator']) {
628  ilUtil::sendFailure($this->lng->txt('err_check_input'));
629  $this->add();
630  return false;
631  }
632 
633  $this->ch_obj->setTargetRefId($this->getTargetRefId());
634  $this->ch_obj->setTargetObjId($this->getTargetId());
635  $this->ch_obj->setTargetType($this->getTargetType());
636 
637  switch ($this->getTargetType()) {
638  case 'st':
639  $this->ch_obj->setReferenceHandlingType($_POST['ref_handling']);
640  break;
641 
642  default:
643  $this->ch_obj->setReferenceHandlingType(ilConditionHandler::UNIQUE_CONDITIONS);
644  break;
645  }
646  // this has to be changed, if non referenced trigger are implemted
647  if (!$trigger_obj = &ilObjectFactory::getInstanceByRefId((int) $_GET['source_id'], false)) {
648  echo 'ilConditionHandler: Trigger object does not exist';
649  }
650  $this->ch_obj->setTriggerRefId($trigger_obj->getRefId());
651  $this->ch_obj->setTriggerObjId($trigger_obj->getId());
652  $this->ch_obj->setTriggerType($trigger_obj->getType());
653  $this->ch_obj->setOperator($_POST['operator']);
654  $this->ch_obj->setObligatory((int) $_POST['obligatory']);
655  $this->ch_obj->setHiddenStatus(ilConditionHandler::lookupPersistedHiddenStatusByTarget($this->getTargetRefId()));
656  $this->ch_obj->setValue('');
657 
658  // Save assigned sco's
659  if ($this->ch_obj->getTriggerType() == 'sahs') {
660  include_once 'Services/Object/classes/class.ilObjectLP.php';
661  $olp = ilObjectLP::getInstance($this->ch_obj->getTriggerObjId());
662  $collection = $olp->getCollectionInstance();
663  if ($collection) {
664  $collection->delete();
665  }
666 
667  if (is_array($_POST['item_ids'])) { // #12901
668  $collection->activateEntries($_POST['item_ids']);
669  }
670  }
671 
672  $this->ch_obj->enableAutomaticValidation($this->getAutomaticValidation());
673  if (!$this->ch_obj->storeCondition()) {
674  ilUtil::sendFailure($this->ch_obj->getErrorMessage(), true);
675  } else {
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  public 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  $this->ch_obj->setOperator($_POST['operator'][$condition["id"]]);
694  $this->ch_obj->setValue($_POST['value'][$condition["id"]]);
695  $this->ch_obj->updateCondition($condition['id']);
696  }
697  ilUtil::sendSuccess($this->lng->txt('conditions_updated'));
698 
699  $this->ctrl->returnToParent($this);
700 
701  return true;
702  }
703  public function __getConditionsOfTarget()
704  {
705  foreach (ilConditionHandler::_getPersistedConditionsOfTarget($this->getTargetRefId(), $this->getTargetId(), $this->getTargetType()) as $condition) {
706  if ($condition['operator'] == 'not_member') {
707  continue;
708  } else {
709  $cond[] = $condition;
710  }
711  }
712  return $cond ? $cond : array();
713  }
714 
722  private function initFormCondition($a_source_id, $a_condition_id = 0, $a_mode = 'add')
723  {
724  $trigger_obj_id = ilObject::_lookupObjId($a_source_id);
725  $trigger_type = ilObject::_lookupType($trigger_obj_id);
726 
727  $condition = ilConditionHandler::_getCondition($a_condition_id);
728 
729  if (is_object($this->form)) {
730  return true;
731  }
732  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
733  $this->form = new ilPropertyFormGUI();
734  $this->ctrl->setParameter($this, 'source_id', $a_source_id);
735  $this->form->setFormAction($this->ctrl->getFormAction($this));
736 
737  $info_source = new ilNonEditableValueGUI($this->lng->txt("rbac_precondition_source"));
738  $info_source->setValue(ilObject::_lookupTitle(ilObject::_lookupObjId($a_source_id)));
739  $this->form->addItem($info_source);
740 
741  $info_target = new ilNonEditableValueGUI($this->lng->txt("rbac_precondition_target"));
742  $info_target->setValue($this->getTargetTitle());
743  $this->form->addItem($info_target);
744 
745  /* moved to list
746  $obl = new ilCheckboxInputGUI($this->lng->txt('precondition_obligatory'), 'obligatory');
747  $obl->setInfo($this->lng->txt('precondition_obligatory_info'));
748  $obl->setValue(1);
749  if($a_condition_id)
750  {
751  $obl->setChecked($condition['obligatory']);
752  }
753  else
754  {
755  $obl->setChecked(true);
756  }
757  $this->form->addItem($obl);
758  */
759  $obl = new ilHiddenInputGUI('obligatory');
760  if ($a_condition_id) {
761  $obl->setValue($condition['obligatory']);
762  } else {
763  $obl->setValue(1);
764  }
765  $this->form->addItem($obl);
766 
767  $sel = new ilSelectInputGUI($this->lng->txt('condition'), 'operator');
768  $ch_obj = new ilConditionHandler();
769  if ($a_mode == 'add') {
770  $operators[0] = $this->lng->txt('select_one');
771  }
772  foreach ($ch_obj->getOperatorsByTriggerType($trigger_type) as $operator) {
773  $operators[$operator] = $this->lng->txt('condition_' . $operator);
774  }
775  $sel->setValue(isset($condition['operator']) ? $condition['operator'] : 0);
776  $sel->setOptions($operators);
777  $sel->setRequired(true);
778  $this->form->addItem($sel);
779 
781  $rad_opt = new ilRadioGroupInputGUI($this->lng->txt('cond_ref_handling'), 'ref_handling');
782  $rad_opt->setValue(isset($condition['ref_handling']) ? $condition['ref_handling'] : ilConditionHandler::SHARED_CONDITIONS);
783 
784  $opt2 = new ilRadioOption($this->lng->txt('cond_ref_shared'), ilConditionHandler::SHARED_CONDITIONS);
785  $rad_opt->addOption($opt2);
786 
787  $opt1 = new ilRadioOption($this->lng->txt('cond_ref_unique'), ilConditionHandler::UNIQUE_CONDITIONS);
788  $rad_opt->addOption($opt1);
789 
790  $this->form->addItem($rad_opt);
791  }
792 
793  // Additional settings for SCO's
794  if ($trigger_type == 'sahs') {
795  $this->lng->loadLanguageModule('trac');
796 
797  $cus = new ilCustomInputGUI($this->lng->txt('trac_sahs_relevant_items'), 'item_ids[]');
798  $cus->setRequired(true);
799 
800  $tpl = new ilTemplate(
801  'tpl.condition_handler_sco_row.html',
802  true,
803  true,
804  "Services/AccessControl"
805  );
806  $counter = 0;
807 
808  include_once 'Services/Object/classes/class.ilObjectLP.php';
809  $olp = ilObjectLP::getInstance($trigger_obj_id);
810  $collection = $olp->getCollectionInstance();
811  if ($collection) {
812  foreach ($collection->getPossibleItems() as $item_id => $sahs_item) {
813  $tpl->setCurrentBlock("sco_row");
814  $tpl->setVariable('SCO_ID', $item_id);
815  $tpl->setVariable('SCO_TITLE', $sahs_item['title']);
816  $tpl->setVariable('CHECKED', $collection->isAssignedEntry($item_id) ? 'checked="checked"' : '');
817  $tpl->parseCurrentBlock();
818  $counter++;
819  }
820  }
821  $tpl->setVariable('INFO_SEL', $this->lng->txt('trac_lp_determination_info_sco'));
822  $cus->setHTML($tpl->get());
823  $this->form->addItem($cus);
824  }
825  switch ($a_mode) {
826  case 'edit':
827  $this->form->setTitleIcon(ilUtil::getImagePath('icon_' . $this->getTargetType() . '.svg'));
828  $this->form->setTitle($this->lng->txt('rbac_edit_condition'));
829  $this->form->addCommandButton('updateCondition', $this->lng->txt('save'));
830  $this->form->addCommandButton('listConditions', $this->lng->txt('cancel'));
831  break;
832 
833 
834  case 'add':
835  $this->form->setTitleIcon(ilUtil::getImagePath('icon_' . $this->getTargetType() . '.svg'));
836  $this->form->setTitle($this->lng->txt('add_condition'));
837  $this->form->addCommandButton('assign', $this->lng->txt('save'));
838  $this->form->addCommandButton('selector', $this->lng->txt('back'));
839  break;
840  }
841  return true;
842  }
843 }
listConditions()
list conditions ilToolbar
This class represents an option in a radio group.
class ilConditionHandlerGUI
static saveNumberOfRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_num)
Save number of obigatory triggers.
$_SESSION["AccountId"]
This class represents a selection list property in a property form.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
$h
static translateOperator($a_obj_id, $a_operator)
Translate operator.
initFormCondition($a_source_id, $a_condition_id=0, $a_mode='add')
Init form for condition table.
setTargetId($a_target_id)
set target id
This class represents a checkbox property in a property form.
static calculatePersistedRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_target_obj_type='', $a_force_update=false)
calculate number of obligatory items
static _lookupTitle($a_id)
lookup object title
static lookupPersistedHiddenStatusByTarget($a_target_ref_id)
Lookup persistedhidden status.
assign()
assign new trigger condition to target
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
static lookupObligatoryConditionsOfTarget($a_target_ref_id, $a_target_obj_id)
Lookup obligatory conditions of target.
setInfo($a_info)
Set Info.
$ilErr
Definition: raiseError.php:18
global $ilCtrl
Definition: ilias.php:18
setInfo($a_info)
Set Information Text.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
setChecked($a_checked)
Set Checked.
This class represents a hidden form property in a property form.
__construct($gui_obj, $a_ref_id=null)
Constructor <type> $lng <type> $tpl <type> $tree <type> $ilCtrl.
This class represents a property in a property form.
setTargetRefId($a_target_ref_id)
set target ref id
if(isset($_POST['submit'])) $form
static getPersistedOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
Get optional conditions.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This class represents a number property in a property form.
getConditionHandler()
Get condition handler.
static _lookupObjId($a_id)
special template class to simplify handling of ITX/PEAR
Table presentation of conditions.
setTargetTitle($a_target_title)
set target title
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
INTERNAL CLASS: Please do not use in consumer code.
saveObligatorySettings()
Save obligatory settings.
This class represents a custom property in a property form.
static _isReferenceHandlingOptional($a_type)
is reference handling optional
saveObligatoryList()
Save obligatory settings.
This class represents a non editable value in a property form.
static updateObligatory($a_id, $a_status)
Toggle condition obligatory status.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all persisted conditions of target object
setTargetType($a_target_type)
set target type
if(empty($password)) $table
Definition: pwgen.php:24
isTargetReferenced()
Check if target has refernce id.
static getInstance($a_obj_id)
showObligatoryForm($opt=array())
Show obligatory form.
$_POST["username"]
setRequired($a_required)
Set Required.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
Confirmation screen class.
static _mode2Text($a_mode)