protected function parseConditions($toggle_id, $conditions, $obligatory = true)
 {
     global $ilAccess, $lng, $objDefinition, $tree;
     $num_required = ilConditionHandler::calculateRequiredTriggers($this->ref_id, $this->obj_id);
     $num_optional_required = $num_required - count($conditions) + count(ilConditionHandler::getOptionalConditionsOfTarget($this->ref_id, $this->obj_id));
     // Check if all conditions are fullfilled
     $visible_conditions = array();
     $passed_optional = 0;
     foreach ($conditions as $condition) {
         if ($obligatory and !$condition['obligatory']) {
             continue;
         }
         if (!$obligatory and $condition['obligatory']) {
             continue;
         }
         if ($tree->isDeleted($condition['trigger_ref_id'])) {
             continue;
         }
         include_once 'Services/Container/classes/class.ilMemberViewSettings.php';
         $ok = ilConditionHandler::_checkCondition($condition['id']) and !ilMemberViewSettings::getInstance()->isActive();
         if (!$ok) {
             $visible_conditions[] = $condition['id'];
         }
         if (!$obligatory and $ok) {
             ++$passed_optional;
             // optional passed
             if ($passed_optional >= $num_optional_required) {
                 return true;
             }
         }
     }
     foreach ($conditions as $condition) {
         if (!in_array($condition['id'], $visible_conditions)) {
             continue;
         }
         include_once './Services/AccessControl/classes/class.ilConditionHandlerGUI.php';
         $cond_txt = ilConditionHandlerGUI::translateOperator($condition['trigger_obj_id'], $condition['operator']) . ' ' . $condition['value'];
         // display trigger item
         $class = $objDefinition->getClassName($condition["trigger_type"]);
         $location = $objDefinition->getLocation($condition["trigger_type"]);
         if ($class == "" && $location == "") {
             continue;
         }
         $missing_cond_exist = true;
         $full_class = "ilObj" . $class . "ListGUI";
         include_once $location . "/class." . $full_class . ".php";
         $item_list_gui = new $full_class($this);
         $item_list_gui->setMode(IL_LIST_AS_TRIGGER);
         $item_list_gui->enablePath(false);
         $item_list_gui->enableIcon(true);
         $item_list_gui->setConditionDepth($this->condition_depth + 1);
         $item_list_gui->setParentRefId($this->getUniqueItemId());
         // yes we can
         $item_list_gui->addCustomProperty($this->lng->txt("precondition_required_itemlist"), $cond_txt, false, true);
         $item_list_gui->enableCommands($this->commands_enabled, $this->std_cmd_only);
         $item_list_gui->enableProperties($this->properties_enabled);
         $trigger_html = $item_list_gui->getListItemHTML($condition['trigger_ref_id'], $condition['trigger_obj_id'], ilObject::_lookupTitle($condition["trigger_obj_id"]), "");
         $this->tpl->setCurrentBlock("precondition");
         if ($trigger_html == "") {
             $trigger_html = $this->lng->txt("precondition_not_accessible");
         }
         $this->tpl->setVariable("TXT_CONDITION", trim($cond_txt));
         $this->tpl->setVariable("TRIGGER_ITEM", $trigger_html);
         $this->tpl->parseCurrentBlock();
     }
     if ($missing_cond_exist and $obligatory) {
         $this->tpl->setCurrentBlock("preconditions");
         $this->tpl->setVariable("CONDITION_TOGGLE_ID", "_obl_" . $toggle_id);
         $this->tpl->setVariable("TXT_PRECONDITIONS", $lng->txt("preconditions_obligatory_hint"));
         $this->tpl->parseCurrentBlock();
     } elseif ($missing_cond_exist and !$obligatory) {
         $this->tpl->setCurrentBlock("preconditions");
         $this->tpl->setVariable("CONDITION_TOGGLE_ID", "_opt_" . $toggle_id);
         $this->tpl->setVariable("TXT_PRECONDITIONS", sprintf($lng->txt("preconditions_optional_hint"), $num_optional_required));
         $this->tpl->parseCurrentBlock();
     }
     return !$missing_cond_exist;
 }
 /**
  * Show obligatory form
  * @return ilPropertyFormGUI
  */
 protected function showObligatoryForm($opt = array())
 {
     if (!$opt) {
         $opt = ilConditionHandler::getOptionalConditionsOfTarget($this->getTargetRefId(), $this->getTargetId(), $this->getTargetType());
     }
     $all = ilConditionHandler::_getConditionsOfTarget($this->getTargetRefId(), $this->getTargetId());
     include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this), 'listConditions');
     $form->setTitle($this->lng->txt('precondition_obligatory_settings'));
     $form->addCommandButton('saveObligatorySettings', $this->lng->txt('save'));
     $hide = new ilCheckboxInputGUI($this->lng->txt('rbac_precondition_hide'), 'hidden');
     $hide->setChecked(ilConditionHandler::lookupHiddenStatusByTarget($this->getTargetRefId()));
     $hide->setValue(1);
     $hide->setInfo($this->lng->txt('rbac_precondition_hide_info'));
     $form->addItem($hide);
     $mode = new ilRadioGroupInputGUI($this->lng->txt("rbac_precondition_mode"), "list_mode");
     $form->addItem($mode);
     $mode->setValue($_REQUEST["list_mode"]);
     $mall = new ilRadioOption($this->lng->txt("rbac_precondition_mode_all"), "all");
     $mall->setInfo($this->lng->txt("rbac_precondition_mode_all_info"));
     $mode->addOption($mall);
     $msubset = new ilRadioOption($this->lng->txt("rbac_precondition_mode_subset"), "subset");
     $msubset->setInfo($this->lng->txt("rbac_precondition_mode_subset_info"));
     $mode->addOption($msubset);
     $obl = new ilNumberInputGUI($this->lng->txt('precondition_num_obligatory'), 'required');
     $obl->setInfo($this->lng->txt('precondition_num_optional_info'));
     if (count($opt)) {
         $obligatory = ilConditionHandler::calculateRequiredTriggers($this->getTargetRefId(), $this->getTargetId(), $this->getTargetType());
         $min = count($all) - count($opt) + 1;
         $max = count($all) - 1;
     } else {
         $obligatory = $min = $max = 1;
     }
     $obl->setValue($obligatory);
     $obl->setRequired(true);
     $obl->setSize(1);
     $obl->setMinValue($min);
     $obl->setMaxValue($max);
     $msubset->addSubItem($obl);
     $old_mode = new ilHiddenInputGUI("old_list_mode");
     $old_mode->setValue($_REQUEST["list_mode"]);
     $form->addItem($old_mode);
     return $form;
 }