3declare(strict_types=1);
 
   63        $this->
ctrl = $DIC->ctrl();
 
   64        $this->
lng = $DIC->language();
 
   65        $this->
lng->loadLanguageModule(
'rbac');
 
   66        $this->
lng->loadLanguageModule(
'cond');
 
   67        $this->tpl = 
$DIC->ui()->mainTemplate();
 
   68        $this->tree = 
$DIC->repositoryTree();
 
   69        $this->
access = $DIC->access();
 
   70        $this->
toolbar = $DIC->toolbar();
 
   71        $this->conditionUtil = 
$DIC->conditions()->util();
 
   73        $this->
http = $DIC->http();
 
   89        if ($this->
http->wrapper()->query()->has(
'condition_id')) {
 
   90            return $this->
http->wrapper()->query()->retrieve(
 
  100        if ($this->
http->wrapper()->post()->has(
'conditions')) {
 
  101            return SplFixedArray::fromArray(
 
  102                $this->
http->wrapper()->post()->retrieve(
 
  104                    $this->refinery->kindlyTo()->listOf(
 
  105                        $this->refinery->kindlyTo()->int()
 
  110        return new SplFixedArray(0);
 
  115        if ($this->
http->wrapper()->post()->has(
'item_ids')) {
 
  116            return SplFixedArray::fromArray(
 
  117                $this->
http->wrapper()->post()->retrieve(
 
  119                    $this->refinery->kindlyTo()->listOf(
 
  120                        $this->refinery->kindlyTo()->int()
 
  125        return new SplFixedArray(0);
 
  130        if ($this->
http->wrapper()->post()->has(
'obl')) {
 
  131            return SplFixedArray::fromArray(
 
  132                $this->
http->wrapper()->post()->retrieve(
 
  134                    $this->refinery->kindlyTo()->listOf(
 
  135                        $this->refinery->kindlyTo()->int()
 
  140        return new SplFixedArray(0);
 
  145        return $this->
http->wrapper()->post()->retrieve(
 
  148                $this->refinery->kindlyTo()->string(),
 
  149                $this->refinery->always(self::LIST_MODE_UNDEFINED)
 
  156        if ($this->
http->wrapper()->query()->has(
'source_id')) {
 
  157            return $this->
http->wrapper()->query()->retrieve(
 
  170        switch ($a_operator) {
 
  179                return $lng->
txt(
'condition_' . $a_operator);
 
  207        if (!$this->
access->checkAccess(
'write', 
'', $this->getTargetRefId())) {
 
  208            $ilErr->raiseError($this->
lng->txt(
'permission_denied'), 
$ilErr->WARNING);
 
  211        $next_class = $this->
ctrl->getNextClass($this);
 
  212        $cmd = $this->
ctrl->getCmd();
 
  213        switch ($next_class) {
 
  225        $this->automatic_validation = $a_status;
 
  235        $this->target_id = $a_target_id;
 
  245        $this->target_ref_id = $a_target_ref_id;
 
  255        $this->target_type = $a_target_type;
 
  265        $this->target_title = $a_target_title;
 
  286            $this->conditionUtil->isUnderParentControl($this->getTargetRefId())
 
  288            $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"cond_under_parent_control"));
 
  292        $this->
toolbar->addButton($this->
lng->txt(
'add_condition'), $this->ctrl->getLinkTarget($this, 
'selector'));
 
  293        $this->tpl->addBlockFile(
'ADM_CONTENT', 
'adm_content', 
'tpl.list_conditions.html', 
'Services/AccessControl');
 
  301        if (count($optional_conditions)) {
 
  302            if ($list_mode === self::LIST_MODE_UNDEFINED) {
 
  305        } elseif ($list_mode === self::LIST_MODE_UNDEFINED) {
 
  318                $this->tpl->setVariable(
'TABLE_SETTINGS', $form->getHTML());
 
  323        $table->setConditions(
 
  331        $h = $table->getHTML();
 
  332        $this->tpl->setVariable(
'TABLE_CONDITIONS', $h);
 
  338        if ($form !== 
null && $form->checkInput()) {
 
  339            $old_mode = $form->getInput(
"old_list_mode");
 
  340            switch ($form->getInput(
"list_mode")) {
 
  342                    if ($old_mode !== 
"all") {
 
  349                        foreach ($optional_conditions as $item) {
 
  356                    $num_req = $form->getInput(
'required');
 
  357                    if ($old_mode !== 
"subset") {
 
  363                        foreach ($all_conditions as $item) {
 
  377            $cond->updateHiddenStatus((
bool) $form->getInput(
'hidden'));
 
  379            $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'), 
true);
 
  380            $this->
ctrl->redirect($this, 
'listConditions');
 
  383        $form->setValuesByPost();
 
  384        $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
 
  385        $this->tpl->setContent($form->getHTML());
 
  397        if (count($obligatory_ids) > count($all_conditions) - 2) {
 
  398            $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"rbac_precondition_minimum_optional"), 
true);
 
  399            $this->
ctrl->redirect($this, 
'listConditions');
 
  402        foreach ($all_conditions as $item) {
 
  404            if (in_array($item[
'condition_id'], $obligatory_ids->toArray(), 
true)) {
 
  418        $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'), 
true);
 
  419        $this->
ctrl->redirect($this, 
'listConditions');
 
  423        string $list_mode = self::LIST_MODE_ALL
 
  431        $form->setFormAction($this->
ctrl->getFormAction($this, 
'listConditions'));
 
  432        $form->setTitle($this->
lng->txt(
'precondition_obligatory_settings'));
 
  433        $form->addCommandButton(
'saveObligatorySettings', $this->
lng->txt(
'save'));
 
  437        $hide->setValue(
"1");
 
  438        $hide->setInfo($this->
lng->txt(
'rbac_precondition_hide_info'));
 
  439        $form->addItem($hide);
 
  442        $form->addItem($mode);
 
  443        $mode->setValue($list_mode);
 
  445        $mall = 
new ilRadioOption($this->
lng->txt(
"rbac_precondition_mode_all"), 
"all");
 
  446        $mall->setInfo($this->
lng->txt(
"rbac_precondition_mode_all_info"));
 
  447        $mode->addOption($mall);
 
  449        if (count($all) > 1) {
 
  451            $max = count($all) - 1;
 
  453            $msubset = 
new ilRadioOption($this->
lng->txt(
"rbac_precondition_mode_subset"), 
"subset");
 
  454            $msubset->setInfo($this->
lng->txt(
"rbac_precondition_mode_subset_info"));
 
  455            $mode->addOption($msubset);
 
  458            $obl->setInfo($this->
lng->txt(
'precondition_num_optional_info'));
 
  464            $obl->setValue($num_required > 0 ? (
string) $num_required : 
null);
 
  465            $obl->setRequired(
true);
 
  467            $obl->setMinValue($min);
 
  468            $obl->setMaxValue($max);
 
  469            $msubset->addSubItem($obl);
 
  473        $old_mode->setValue($list_mode);
 
  474        $form->addItem($old_mode);
 
  481        $condition_id = $this->initConditionIdFromQuery();
 
  482        if (!$condition_id) {
 
  483            $this->tpl->setOnScreenMessage(
'failure', 
"Missing id: condition_id");
 
  484            $this->listConditions();
 
  487        $this->
ctrl->setParameter($this, 
'condition_id', $condition_id);
 
  491            $form = $this->initFormCondition($condition[
'trigger_ref_id'], $condition_id, 
'edit');
 
  493        $this->tpl->setContent($form->getHTML());
 
  498        $condition_id = $this->initConditionIdFromQuery();
 
  499        if (!$condition_id) {
 
  500            $this->tpl->setOnScreenMessage(
'failure', 
"Missing id: condition_id");
 
  501            $this->listConditions();
 
  508        $form = $this->initFormCondition(
 
  509            $condition[
'trigger_ref_id'],
 
  514        if (!$form->checkInput()) {
 
  515            $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
 
  520        $condition_handler->setOperator((
string) $form->getInput(
'operator'));
 
  521        $condition_handler->setObligatory((
bool) $form->getInput(
'obligatory'));
 
  522        $condition_handler->setTargetRefId($this->getTargetRefId());
 
  523        $condition_handler->setValue(
'');
 
  524        switch ($this->getTargetType()) {
 
  526                $condition_handler->setReferenceHandlingType((
int) $form->getInput(
'ref_handling'));
 
  533        $condition_handler->updateCondition($condition[
'id']);
 
  536        if ($condition[
'trigger_type'] === 
'sahs') {
 
  538            $collection = $olp->getCollectionInstance();
 
  540                $collection->delete();
 
  542            $item_ids = $this->initItemIdsFromPost();
 
  543            if (count($item_ids)) { 
 
  544                $collection->activateEntries($item_ids->toArray());
 
  548        $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'), 
true);
 
  549        $this->
ctrl->redirect($this, 
'listConditions');
 
  554        $condition_ids = $this->initConditionsIdsFromPost();
 
  555        if (!count($condition_ids)) {
 
  556            $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_condition_selected'));
 
  557            $this->listConditions();
 
  563        $cgui->setFormAction($this->
ctrl->getFormAction($this, 
"listConditions"));
 
  564        $cgui->setHeaderText($this->
lng->txt(
"rbac_condition_delete_sure"));
 
  565        $cgui->setCancel($this->
lng->txt(
"cancel"), 
"listConditions");
 
  566        $cgui->setConfirm($this->
lng->txt(
"delete"), 
"delete");
 
  569        foreach ($condition_ids as $condition_id) {
 
  573                " (" . $this->
lng->txt(
"condition") . 
": " .
 
  574                $this->
lng->txt(
'condition_' . $condition[
'operator']) . 
")";
 
  576            $alt = $this->
lng->txt(
'obj_' . $condition[
'trigger_type']);
 
  578            $cgui->addItem(
"conditions[]", (
string) $condition_id, $title, $icon, $alt);
 
  581        $this->tpl->setContent($cgui->getHTML());
 
  584    public function delete(): 
void 
  586        $condition_ids = $this->initConditionsIdsFromPost();
 
  587        if (!count($condition_ids)) {
 
  588            $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_condition_selected'));
 
  589            $this->listConditions();
 
  593        foreach ($condition_ids as $condition_id) {
 
  594            $this->ch_obj->deleteCondition($condition_id);
 
  596        $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'condition_deleted'), 
true);
 
  597        $this->
ctrl->redirect($this, 
'listConditions');
 
  602        $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"condition_select_object"));
 
  605        $exp->setTypeWhiteList(array_merge(
 
  606            $this->getConditionHandler()->getTriggerTypes(),
 
  607            array(
"root", 
"cat", 
"grp", 
"fold", 
"crs", 
"prg")
 
  610        $exp->setRefId($this->getTargetRefId());
 
  611        $exp->setClickableTypes($this->getConditionHandler()->getTriggerTypes());
 
  613        if (!$exp->handleCommand()) {
 
  614            $this->tpl->setContent($exp->getHTML());
 
  620        $source_id = $this->initSourceIdFromQuery();
 
  622            $this->tpl->setOnScreenMessage(
'failure', 
"Missing id: condition_id");
 
  627            $form = $this->initFormCondition($source_id, 0, 
'add');
 
  629        $this->tpl->setContent($form->getHTML());
 
  637        $source_id = $this->initSourceIdFromQuery();
 
  639            $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_condition_selected'));
 
  644        $form = $this->initFormCondition($source_id, 0, 
'add');
 
  645        if (!$form->checkInput()) {
 
  646            $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
 
  650        $this->ch_obj->setTargetRefId($this->getTargetRefId());
 
  651        $this->ch_obj->setTargetObjId($this->getTargetId());
 
  652        $this->ch_obj->setTargetType($this->getTargetType());
 
  654        switch ($this->getTargetType()) {
 
  656                $this->ch_obj->setReferenceHandlingType((
int) $form->getInput(
'ref_handling'));
 
  665        if ($trigger_obj !== 
null) {
 
  666            $this->ch_obj->setTriggerRefId($trigger_obj->getRefId());
 
  667            $this->ch_obj->setTriggerObjId($trigger_obj->getId());
 
  668            $this->ch_obj->setTriggerType($trigger_obj->getType());
 
  670        $this->ch_obj->setOperator($form->getInput(
'operator'));
 
  671        $this->ch_obj->setObligatory((
bool) $form->getInput(
'obligatory'));
 
  673        $this->ch_obj->setValue(
'');
 
  676        if ($this->ch_obj->getTriggerType() === 
'sahs') {
 
  678            $collection = $olp->getCollectionInstance();
 
  680                $collection->delete();
 
  683            $items_ids = $this->initItemIdsFromPost();
 
  684            if (count($items_ids)) { 
 
  685                $collection->activateEntries($items_ids->toArray());
 
  688        $this->ch_obj->enableAutomaticValidation($this->getAutomaticValidation());
 
  689        if (!$this->ch_obj->storeCondition()) {
 
  690            $this->tpl->setOnScreenMessage(
'failure', $this->ch_obj->getErrorMessage(), 
true);
 
  692            $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'added_new_condition'), 
true);
 
  694        $this->
ctrl->redirect($this, 
'listConditions');
 
  701            $this->getTargetRefId(),
 
  702            $this->getTargetId(),
 
  703            $this->getTargetType()
 
  705            if ($condition[
'operator'] === 
'not_member') {
 
  709            $cond[] = $condition;
 
  716        int $a_condition_id = 0,
 
  717        string $a_mode = 
'add' 
  719        $trigger_obj_id = 
ilObject::_lookupObjId($a_source_id);
 
  724        $this->
ctrl->setParameter($this, 
'source_id', $a_source_id);
 
  725        $form->setFormAction($this->
ctrl->getFormAction($this));
 
  729        $form->addItem($info_source);
 
  732        $info_target->setValue($this->getTargetTitle());
 
  733        $form->addItem($info_target);
 
  736        if ($a_condition_id) {
 
  737            $obl->setValue((
string) (
bool) $condition[
'obligatory']);
 
  741        $form->addItem($obl);
 
  746        if ($a_mode === 
'add') {
 
  747            $operators[
''] = $this->
lng->txt(
'select_one');
 
  750            $operators[$operator] = $this->
lng->txt(
'condition_' . $operator);
 
  752        $sel->setValue($condition[
'operator'] ?? 
'');
 
  753        $sel->setOptions($operators);
 
  754        $sel->setRequired(
true);
 
  755        $form->addItem($sel);
 
  762                $this->
lng->txt(
'cond_ref_shared'),
 
  763                (
string) ilConditionHandler::SHARED_CONDITIONS
 
  765            $rad_opt->addOption($opt2);
 
  768                $this->
lng->txt(
'cond_ref_unique'),
 
  771            $rad_opt->addOption($opt1);
 
  773            $form->addItem($rad_opt);
 
  777        if ($trigger_type === 
'sahs') {
 
  778            $this->
lng->loadLanguageModule(
'trac');
 
  781            $cus->setInfo($this->
lng->txt(
'trac_lp_determination_info_sco'));
 
  782            $cus->setRequired(
true);
 
  785            $collection = $olp->getCollectionInstance();
 
  788                foreach ($collection->getPossibleItems() as $item_id => $sahs_item) {
 
  790                    if ($collection->isAssignedEntry($item_id)) {
 
  791                        $checked[] = $item_id;
 
  793                    $cus->addOption($sco);
 
  796            $cus->setValue($checked);
 
  797            $form->addItem($cus);
 
  802                $form->setTitle($this->
lng->txt(
'rbac_edit_condition'));
 
  803                $form->addCommandButton(
'updateCondition', $this->
lng->txt(
'save'));
 
  804                $form->addCommandButton(
'listConditions', $this->
lng->txt(
'cancel'));
 
  809                $form->setTitle($this->
lng->txt(
'add_condition'));
 
  810                $form->addCommandButton(
'assign', $this->
lng->txt(
'save'));
 
  811                $form->addCommandButton(
'selector', $this->
lng->txt(
'back'));
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
class ilConditionHandlerGUI
 
showObligatoryForm(string $list_mode=self::LIST_MODE_ALL)
 
ilConditionHandler $ch_obj
 
initObligatoryItemsFromPost()
 
initConditionsIdsFromPost()
 
edit(?ilPropertyFormGUI $form=null)
 
ilConditionUtil $conditionUtil
 
setTargetType(string $a_target_type)
 
add(?ilPropertyFormGUI $form=null)
 
const LIST_MODE_UNDEFINED
 
isTargetReferenced()
Check if target has refernce id.
 
setTargetId(int $a_target_id)
 
setTargetRefId(int $a_target_ref_id)
 
initConditionIdFromQuery()
 
ilObjectDefinition $objectDefinition
 
static translateOperator(int $a_obj_id, string $a_operator)
 
bool $automatic_validation
 
assign()
assign new trigger condition to target
 
initFormCondition(int $a_source_id, int $a_condition_id=0, string $a_mode='add')
 
setTargetTitle(string $a_target_title)
 
setBackButtons(array $a_btn_arr)
 
__construct(int $a_ref_id=null)
 
setAutomaticValidation(bool $a_status)
 
ilGlobalTemplateInterface $tpl
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static getPersistedOptionalConditionsOfTarget(int $a_target_ref_id, int $a_target_obj_id, string $a_obj_type='')
 
static _getPersistedConditionsOfTarget(int $a_target_ref_id, int $a_target_obj_id, string $a_target_type="")
get all persisted conditions of target object
 
static saveNumberOfRequiredTriggers(int $a_target_ref_id, int $a_target_obj_id, int $a_num)
 
getOperatorsByTriggerType(string $a_type)
 
static _isReferenceHandlingOptional(string $a_type)
 
static lookupObligatoryConditionsOfTarget(int $a_target_ref_id, int $a_target_obj_id)
 
static _getCondition(int $a_id)
 
static updateObligatory(int $a_id, bool $a_status)
Toggle condition obligatory status.
 
static calculatePersistedRequiredTriggers(int $a_target_ref_id, int $a_target_obj_id, string $a_target_obj_type='', bool $a_force_update=false)
 
static lookupPersistedHiddenStatusByTarget(int $a_target_ref_id)
 
Condition utility object Wraps some ilConditionHandler methods (which will become deprecated) Depende...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
Class ilCtrl provides processing control methods.
 
static _mode2Text(int $a_mode)
 
static _refreshStatus(int $a_obj_id, ?array $a_users=null)
 
loadLanguageModule(string $a_module)
Load language module.
 
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
parses the objects.xml it handles the xml-description of all ilias objects
 
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
 
static getInstance(int $obj_id)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static _lookupType(int $id, bool $reference=false)
 
static _lookupObjId(int $ref_id)
 
static _lookupTitle(int $obj_id)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static get(string $a_var)
 
static set(string $a_var, $a_val)
Set a value.
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
 
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
Interface GlobalHttpState.
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static http()
Fetches the global http state from ILIAS.