ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilConditionHandlerGUI Class Reference

class ilConditionHandlerGUI More...

+ Collaboration diagram for ilConditionHandlerGUI:

Public Member Functions

 __construct ($gui_obj, $a_ref_id=null)
 Constructor <type> $lng <type> $tpl <type> $tree <type> $ilCtrl. More...
 
 setBackButtons ($a_btn_arr)
 
 getBackButtons ()
 
 executeCommand ()
 
 setAutomaticValidation ($a_status)
 
 getAutomaticValidation ()
 
 setTargetId ($a_target_id)
 set target id More...
 
 getTargetId ()
 get target id More...
 
 setTargetRefId ($a_target_ref_id)
 set target ref id More...
 
 getTargetRefId ()
 get target ref id More...
 
 setTargetType ($a_target_type)
 set target type More...
 
 getTargetType ()
 get target type More...
 
 setTargetTitle ($a_target_title)
 set target title More...
 
 isTargetReferenced ()
 Check if target has refernce id. More...
 
 getTargetTitle ()
 get target title More...
 
 edit ()
 
 updateCondition ()
 
 askDelete ()
 
 delete ()
 
 selector ()
 
 add ()
 
 assign ()
 assign new trigger condition to target More...
 
 chi_update ()
 
 __getConditionsOfTarget ()
 

Static Public Member Functions

static translateOperator ($a_obj_id, $a_operator)
 Translate operator. More...
 

Data Fields

 $ctrl = null
 
 $lng
 
 $tpl
 
 $tree
 
 $ch_obj
 
 $target_obj
 
 $client_obj
 
 $target_id
 
 $target_type
 
 $target_title
 
 $target_ref_id
 
 $automatic_validation = true
 

Protected Member Functions

 getConditionHandler ()
 Get condition handler. More...
 
 listConditions ()
 list conditions ilToolbar More...
 
 saveObligatorySettings ()
 Save obligatory settings. More...
 
 saveObligatoryList ()
 Save obligatory settings. More...
 
 showObligatoryForm ($opt=array())
 Show obligatory form. More...
 

Private Member Functions

 initFormCondition ($a_source_id, $a_condition_id=0, $a_mode='add')
 Init form for condition table. More...
 

Detailed Description

class ilConditionHandlerGUI

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$ This class is aggregated in folders, groups which have a parent course object Since it is something like an interface, all varirables, methods have there own name space (names start with cci) to avoid collisions

ilConditionHandlerGUI:

Definition at line 15 of file class.ilConditionHandlerGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilConditionHandlerGUI::__construct (   $gui_obj,
  $a_ref_id = null 
)

Constructor <type> $lng <type> $tpl <type> $tree <type> $ilCtrl.

Parameters
<type>$gui_obj
<type>$a_ref_id

Definition at line 42 of file class.ilConditionHandlerGUI.php.

References $DIC, $ilCtrl, $lng, $tpl, $tree, ilObjectFactory\getInstanceByRefId(), setTargetId(), setTargetRefId(), setTargetTitle(), and setTargetType().

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  }
global $DIC
Definition: saml.php:7
setTargetId($a_target_id)
set target id
global $ilCtrl
Definition: ilias.php:18
setTargetRefId($a_target_ref_id)
set target ref id
setTargetTitle($a_target_title)
set target title
INTERNAL CLASS: Please do not use in consumer code.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
setTargetType($a_target_type)
set target type
+ Here is the call graph for this function:

Member Function Documentation

◆ __getConditionsOfTarget()

ilConditionHandlerGUI::__getConditionsOfTarget ( )

Definition at line 703 of file class.ilConditionHandlerGUI.php.

References ilConditionHandler\_getPersistedConditionsOfTarget(), getTargetId(), getTargetRefId(), and getTargetType().

Referenced by chi_update().

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  }
static _getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all persisted conditions of target object
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add()

ilConditionHandlerGUI::add ( )

Definition at line 594 of file class.ilConditionHandlerGUI.php.

References $_GET, $DIC, initFormCondition(), selector(), and ilUtil\sendFailure().

Referenced by assign().

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  }
global $DIC
Definition: saml.php:7
$_GET["client_id"]
initFormCondition($a_source_id, $a_condition_id=0, $a_mode='add')
Init form for condition table.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ askDelete()

ilConditionHandlerGUI::askDelete ( )

Definition at line 523 of file class.ilConditionHandlerGUI.php.

References $_POST, $DIC, $title, $tpl, ilConditionHandler\_getCondition(), ilObject\_lookupTitle(), ilUtil\getImagePath(), listConditions(), and ilUtil\sendFailure().

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  }
listConditions()
list conditions ilToolbar
global $DIC
Definition: saml.php:7
static _lookupTitle($a_id)
lookup object title
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
Confirmation screen class.
+ Here is the call graph for this function:

◆ assign()

ilConditionHandlerGUI::assign ( )

assign new trigger condition to target

Definition at line 620 of file class.ilConditionHandlerGUI.php.

References $_GET, $_POST, add(), getAutomaticValidation(), ilObjectLP\getInstance(), ilObjectFactory\getInstanceByRefId(), getTargetId(), getTargetRefId(), getTargetType(), ilConditionHandler\lookupPersistedHiddenStatusByTarget(), ilUtil\sendFailure(), and ilConditionHandler\UNIQUE_CONDITIONS.

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  }
$_GET["client_id"]
static lookupPersistedHiddenStatusByTarget($a_target_ref_id)
Lookup persistedhidden status.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static getInstance($a_obj_id)
$_POST["username"]
+ Here is the call graph for this function:

◆ chi_update()

ilConditionHandlerGUI::chi_update ( )

Definition at line 684 of file class.ilConditionHandlerGUI.php.

References $_POST, and __getConditionsOfTarget().

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  }
$_POST["username"]
+ Here is the call graph for this function:

◆ delete()

ilConditionHandlerGUI::delete ( )

Definition at line 559 of file class.ilConditionHandlerGUI.php.

References $_POST, listConditions(), and ilUtil\sendFailure().

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  }
listConditions()
list conditions ilToolbar
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:

◆ edit()

ilConditionHandlerGUI::edit ( )

Definition at line 446 of file class.ilConditionHandlerGUI.php.

References $_GET, $DIC, ilConditionHandler\_getCondition(), initFormCondition(), listConditions(), and ilUtil\sendFailure().

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  }
listConditions()
list conditions ilToolbar
global $DIC
Definition: saml.php:7
$_GET["client_id"]
initFormCondition($a_source_id, $a_condition_id=0, $a_mode='add')
Init form for condition table.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ executeCommand()

ilConditionHandlerGUI::executeCommand ( )

Definition at line 114 of file class.ilConditionHandlerGUI.php.

References $DIC, $ilErr, and $lng.

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  }
global $DIC
Definition: saml.php:7
$ilErr
Definition: raiseError.php:18

◆ getAutomaticValidation()

ilConditionHandlerGUI::getAutomaticValidation ( )

Definition at line 143 of file class.ilConditionHandlerGUI.php.

References $automatic_validation.

Referenced by assign().

+ Here is the caller graph for this function:

◆ getBackButtons()

ilConditionHandlerGUI::getBackButtons ( )

Definition at line 109 of file class.ilConditionHandlerGUI.php.

References $_SESSION.

110  {
111  return $_SESSION['precon_btn'] ? $_SESSION['precon_btn'] : array();
112  }
$_SESSION["AccountId"]

◆ getConditionHandler()

ilConditionHandlerGUI::getConditionHandler ( )
protected

Get condition handler.

Returns
ilConditionHandler

Definition at line 100 of file class.ilConditionHandlerGUI.php.

References $ch_obj.

Referenced by selector().

101  {
102  return $this->ch_obj;
103  }
+ Here is the caller graph for this function:

◆ getTargetId()

ilConditionHandlerGUI::getTargetId ( )

get target id

Definition at line 160 of file class.ilConditionHandlerGUI.php.

References $target_id.

Referenced by __getConditionsOfTarget(), assign(), listConditions(), saveObligatoryList(), saveObligatorySettings(), and showObligatoryForm().

+ Here is the caller graph for this function:

◆ getTargetRefId()

ilConditionHandlerGUI::getTargetRefId ( )

get target ref id

Definition at line 176 of file class.ilConditionHandlerGUI.php.

References $target_ref_id.

Referenced by __getConditionsOfTarget(), assign(), isTargetReferenced(), listConditions(), saveObligatoryList(), saveObligatorySettings(), selector(), showObligatoryForm(), and updateCondition().

+ Here is the caller graph for this function:

◆ getTargetTitle()

ilConditionHandlerGUI::getTargetTitle ( )

get target title

Definition at line 217 of file class.ilConditionHandlerGUI.php.

References $target_title.

Referenced by initFormCondition().

+ Here is the caller graph for this function:

◆ getTargetType()

ilConditionHandlerGUI::getTargetType ( )

get target type

Definition at line 192 of file class.ilConditionHandlerGUI.php.

References $target_type.

Referenced by __getConditionsOfTarget(), assign(), initFormCondition(), listConditions(), saveObligatoryList(), saveObligatorySettings(), showObligatoryForm(), and updateCondition().

+ Here is the caller graph for this function:

◆ initFormCondition()

ilConditionHandlerGUI::initFormCondition (   $a_source_id,
  $a_condition_id = 0,
  $a_mode = 'add' 
)
private

Init form for condition table.

private

Parameters

Definition at line 722 of file class.ilConditionHandlerGUI.php.

References $ch_obj, $tpl, ilConditionHandler\_getCondition(), ilConditionHandler\_isReferenceHandlingOptional(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilUtil\getImagePath(), ilObjectLP\getInstance(), getTargetTitle(), getTargetType(), ilFormPropertyGUI\setRequired(), ilRadioGroupInputGUI\setValue(), ilNonEditableValueGUI\setValue(), ilConditionHandler\SHARED_CONDITIONS, and ilConditionHandler\UNIQUE_CONDITIONS.

Referenced by add(), and edit().

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  }
This class represents an option in a radio group.
This class represents a selection list property in a property form.
This class represents a property form user interface.
static _lookupTitle($a_id)
lookup object title
This class represents a hidden form property in a property form.
This class represents a property in a property form.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static _lookupObjId($a_id)
special template class to simplify handling of ITX/PEAR
static _lookupType($a_id, $a_reference=false)
lookup object type
INTERNAL CLASS: Please do not use in consumer code.
This class represents a custom property in a property form.
static _isReferenceHandlingOptional($a_type)
is reference handling optional
This class represents a non editable value in a property form.
static getInstance($a_obj_id)
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isTargetReferenced()

ilConditionHandlerGUI::isTargetReferenced ( )

Check if target has refernce id.

Returns
bool

Definition at line 209 of file class.ilConditionHandlerGUI.php.

References getTargetRefId().

210  {
211  return $this->getTargetRefId() ? true : false;
212  }
+ Here is the call graph for this function:

◆ listConditions()

ilConditionHandlerGUI::listConditions ( )
protected

list conditions ilToolbar

Definition at line 226 of file class.ilConditionHandlerGUI.php.

References $DIC, $form, $h, $table, ilConditionHandler\_getPersistedConditionsOfTarget(), ilConditionHandler\getPersistedOptionalConditionsOfTarget(), getTargetId(), getTargetRefId(), getTargetType(), ilUtil\sendInfo(), and showObligatoryForm().

Referenced by askDelete(), delete(), edit(), and updateCondition().

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  }
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
$h
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if(isset($_POST['submit'])) $form
static getPersistedOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
Get optional conditions.
Table presentation of conditions.
static _getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all persisted conditions of target object
if(empty($password)) $table
Definition: pwgen.php:24
showObligatoryForm($opt=array())
Show obligatory form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveObligatoryList()

ilConditionHandlerGUI::saveObligatoryList ( )
protected

Save obligatory settings.

Definition at line 343 of file class.ilConditionHandlerGUI.php.

References $_POST, ilConditionHandler\_getPersistedConditionsOfTarget(), ilConditionHandler\calculatePersistedRequiredTriggers(), getTargetId(), getTargetRefId(), getTargetType(), ilUtil\sendFailure(), and ilConditionHandler\updateObligatory().

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  }
static calculatePersistedRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_target_obj_type='', $a_force_update=false)
calculate number of obligatory items
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static updateObligatory($a_id, $a_status)
Toggle condition obligatory status.
static _getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all persisted conditions of target object
$_POST["username"]
+ Here is the call graph for this function:

◆ saveObligatorySettings()

ilConditionHandlerGUI::saveObligatorySettings ( )
protected

Save obligatory settings.

Definition at line 287 of file class.ilConditionHandlerGUI.php.

References $form, ilConditionHandler\_getPersistedConditionsOfTarget(), ilConditionHandler\getPersistedOptionalConditionsOfTarget(), getTargetId(), getTargetRefId(), getTargetType(), ilConditionHandler\saveNumberOfRequiredTriggers(), ilUtil\sendFailure(), showObligatoryForm(), and ilConditionHandler\updateObligatory().

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  }
static saveNumberOfRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_num)
Save number of obigatory triggers.
if(isset($_POST['submit'])) $form
static getPersistedOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
Get optional conditions.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
INTERNAL CLASS: Please do not use in consumer code.
static updateObligatory($a_id, $a_status)
Toggle condition obligatory status.
static _getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all persisted conditions of target object
showObligatoryForm($opt=array())
Show obligatory form.
+ Here is the call graph for this function:

◆ selector()

ilConditionHandlerGUI::selector ( )

Definition at line 576 of file class.ilConditionHandlerGUI.php.

References getConditionHandler(), getTargetRefId(), and ilUtil\sendInfo().

Referenced by add().

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  }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
getConditionHandler()
Get condition handler.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAutomaticValidation()

ilConditionHandlerGUI::setAutomaticValidation (   $a_status)

Definition at line 139 of file class.ilConditionHandlerGUI.php.

140  {
141  $this->automatic_validation = $a_status;
142  }

◆ setBackButtons()

ilConditionHandlerGUI::setBackButtons (   $a_btn_arr)

Definition at line 105 of file class.ilConditionHandlerGUI.php.

References $_SESSION.

106  {
107  $_SESSION['precon_btn'] = $a_btn_arr;
108  }
$_SESSION["AccountId"]

◆ setTargetId()

ilConditionHandlerGUI::setTargetId (   $a_target_id)

set target id

Definition at line 152 of file class.ilConditionHandlerGUI.php.

Referenced by __construct().

153  {
154  $this->target_id = $a_target_id;
155  }
+ Here is the caller graph for this function:

◆ setTargetRefId()

ilConditionHandlerGUI::setTargetRefId (   $a_target_ref_id)

set target ref id

Definition at line 168 of file class.ilConditionHandlerGUI.php.

Referenced by __construct().

169  {
170  $this->target_ref_id = $a_target_ref_id;
171  }
+ Here is the caller graph for this function:

◆ setTargetTitle()

ilConditionHandlerGUI::setTargetTitle (   $a_target_title)

set target title

Definition at line 200 of file class.ilConditionHandlerGUI.php.

Referenced by __construct().

201  {
202  $this->target_title = $a_target_title;
203  }
+ Here is the caller graph for this function:

◆ setTargetType()

ilConditionHandlerGUI::setTargetType (   $a_target_type)

set target type

Definition at line 184 of file class.ilConditionHandlerGUI.php.

Referenced by __construct().

185  {
186  $this->target_type = $a_target_type;
187  }
+ Here is the caller graph for this function:

◆ showObligatoryForm()

ilConditionHandlerGUI::showObligatoryForm (   $opt = array())
protected

Show obligatory form.

Returns
ilPropertyFormGUI

Definition at line 380 of file class.ilConditionHandlerGUI.php.

References $form, $GLOBALS, ilConditionHandler\_getPersistedConditionsOfTarget(), ilConditionHandler\getPersistedOptionalConditionsOfTarget(), getTargetId(), getTargetRefId(), getTargetType(), ilConditionHandler\lookupObligatoryConditionsOfTarget(), ilConditionHandler\lookupPersistedHiddenStatusByTarget(), ilCheckboxInputGUI\setChecked(), ilRadioOption\setInfo(), and ilFormPropertyGUI\setInfo().

Referenced by listConditions(), and saveObligatorySettings().

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  }
This class represents an option in a radio group.
This class represents a property form user interface.
This class represents a checkbox property in a property form.
static lookupPersistedHiddenStatusByTarget($a_target_ref_id)
Lookup persistedhidden status.
static lookupObligatoryConditionsOfTarget($a_target_ref_id, $a_target_obj_id)
Lookup obligatory conditions of target.
setInfo($a_info)
Set Info.
setInfo($a_info)
Set Information Text.
setChecked($a_checked)
Set Checked.
This class represents a hidden form property in a property form.
This class represents a property in a property form.
if(isset($_POST['submit'])) $form
static getPersistedOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
Get optional conditions.
This class represents a number property in a property form.
static _getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all persisted conditions of target object
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ translateOperator()

static ilConditionHandlerGUI::translateOperator (   $a_obj_id,
  $a_operator 
)
static

Translate operator.

Parameters
type$a_operator

Definition at line 81 of file class.ilConditionHandlerGUI.php.

References $GLOBALS, ilLPObjSettings\_mode2Text(), and ilConditionHandler\OPERATOR_LP.

Referenced by ilInfoScreenGUI\addPreconditionSection(), and ilObjectListGUI\parseConditions().

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  }
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
static _mode2Text($a_mode)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateCondition()

ilConditionHandlerGUI::updateCondition ( )

Definition at line 471 of file class.ilConditionHandlerGUI.php.

References $_GET, $_POST, $DIC, ilConditionHandler\_getCondition(), ilLPStatusWrapper\_refreshStatus(), ilObjectLP\getInstance(), getTargetRefId(), getTargetType(), listConditions(), ilUtil\sendFailure(), and ilConditionHandler\UNIQUE_CONDITIONS.

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  }
listConditions()
list conditions ilToolbar
global $DIC
Definition: saml.php:7
$_GET["client_id"]
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
INTERNAL CLASS: Please do not use in consumer code.
static getInstance($a_obj_id)
$_POST["username"]
+ Here is the call graph for this function:

Field Documentation

◆ $automatic_validation

ilConditionHandlerGUI::$automatic_validation = true

Definition at line 31 of file class.ilConditionHandlerGUI.php.

Referenced by getAutomaticValidation().

◆ $ch_obj

ilConditionHandlerGUI::$ch_obj

Definition at line 23 of file class.ilConditionHandlerGUI.php.

Referenced by getConditionHandler(), and initFormCondition().

◆ $client_obj

ilConditionHandlerGUI::$client_obj

Definition at line 25 of file class.ilConditionHandlerGUI.php.

◆ $ctrl

ilConditionHandlerGUI::$ctrl = null

Definition at line 17 of file class.ilConditionHandlerGUI.php.

◆ $lng

ilConditionHandlerGUI::$lng

Definition at line 19 of file class.ilConditionHandlerGUI.php.

Referenced by __construct(), and executeCommand().

◆ $target_id

ilConditionHandlerGUI::$target_id

Definition at line 26 of file class.ilConditionHandlerGUI.php.

Referenced by getTargetId().

◆ $target_obj

ilConditionHandlerGUI::$target_obj

Definition at line 24 of file class.ilConditionHandlerGUI.php.

◆ $target_ref_id

ilConditionHandlerGUI::$target_ref_id

Definition at line 29 of file class.ilConditionHandlerGUI.php.

Referenced by getTargetRefId().

◆ $target_title

ilConditionHandlerGUI::$target_title

Definition at line 28 of file class.ilConditionHandlerGUI.php.

Referenced by getTargetTitle().

◆ $target_type

ilConditionHandlerGUI::$target_type

Definition at line 27 of file class.ilConditionHandlerGUI.php.

Referenced by getTargetType().

◆ $tpl

ilConditionHandlerGUI::$tpl

Definition at line 20 of file class.ilConditionHandlerGUI.php.

Referenced by __construct(), askDelete(), and initFormCondition().

◆ $tree

ilConditionHandlerGUI::$tree

Definition at line 21 of file class.ilConditionHandlerGUI.php.

Referenced by __construct().


The documentation for this class was generated from the following file: