ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 
 chi_init (&$chi_target_obj, $a_ref_id=null)
 
 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 $ilCtrl, $lng, $tpl, $tree, ilObjectFactory\getInstanceByRefId(), setTargetId(), setTargetRefId(), setTargetTitle(), and setTargetType().

43  {
44  global $lng,$tpl,$tree,$ilCtrl;
45 
46  include_once "./Services/AccessControl/classes/class.ilConditionHandler.php";
47 
48  $this->ch_obj = new ilConditionHandler();
49 
50  $this->ctrl =&$ilCtrl;
51  $this->gui_obj =&$gui_obj;
52  $this->lng =&$lng;
53  $this->lng->loadLanguageModule('rbac');
54  $this->tpl =&$tpl;
55  $this->tree =&$tree;
56 
57  if ($a_ref_id) {
58  $this->target_obj =&ilObjectFactory::getInstanceByRefId($a_ref_id);
59  } else {
60  $this->target_obj =&$this->gui_obj->object;
61  }
62 
63  // this only works for ilObject derived objects (other objects
64  // should call set() methods manually
65  if (is_object($this->target_obj)) {
66  $this->setTargetId($this->target_obj->getId());
67  $this->setTargetRefId($this->target_obj->getRefId());
68  $this->setTargetType($this->target_obj->getType());
69  $this->setTargetTitle($this->target_obj->getTitle());
70  }
71  }
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
Handles conditions for accesses to different ILIAS objects.
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 699 of file class.ilConditionHandlerGUI.php.

References ilConditionHandler\_getConditionsOfTarget(), array, getTargetId(), getTargetRefId(), and getTargetType().

Referenced by chi_update().

700  {
701  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
702 
703  foreach (ilConditionHandler::_getConditionsOfTarget($this->getTargetRefId(), $this->getTargetId(), $this->getTargetType()) as $condition) {
704  if ($condition['operator'] == 'not_member') {
705  continue;
706  } else {
707  $cond[] = $condition;
708  }
709  }
710  return $cond ? $cond : array();
711  }
static _getConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all conditions of target object
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add()

ilConditionHandlerGUI::add ( )

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

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

Referenced by assign().

593  {
594  global $ilObjDataCache;
595 
596  if (!$_GET['source_id']) {
597  ilUtil::sendFailure("Missing id: condition_id");
598  $this->selector();
599  return false;
600  }
601 
602  $this->initFormCondition((int) $_GET['source_id'], 0, 'add');
603  $this->tpl->addBlockfile(
604  'ADM_CONTENT',
605  'adm_content',
606  'tpl.condition_handler_add.html',
607  "Services/AccessControl"
608  );
609  $this->tpl->setVariable('CONDITION_TABLE', $this->form->getHTML());
610  }
$_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 521 of file class.ilConditionHandlerGUI.php.

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

522  {
523  global $tpl;
524 
525  if (!count($_POST['conditions'])) {
526  ilUtil::sendFailure($this->lng->txt('no_condition_selected'));
527  $this->listConditions();
528  return true;
529  }
530 
531  // display confirmation message
532  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
533  $cgui = new ilConfirmationGUI();
534  $cgui->setFormAction($this->ctrl->getFormAction($this, "listConditions"));
535  $cgui->setHeaderText($this->lng->txt("rbac_condition_delete_sure"));
536  $cgui->setCancel($this->lng->txt("cancel"), "listConditions");
537  $cgui->setConfirm($this->lng->txt("delete"), "delete");
538 
539  // list conditions that should be deleted
540  foreach ($_POST['conditions'] as $condition_id) {
541  $condition = ilConditionHandler::_getCondition($condition_id);
542 
543  $title = ilObject::_lookupTitle($condition['trigger_obj_id']) .
544  " (" . $this->lng->txt("condition") . ": " .
545  $this->lng->txt('condition_' . $condition['operator']) . ")";
546  $icon = ilUtil::getImagePath('icon_' . $condition['trigger_type'] . '.svg');
547  $alt = $this->lng->txt('obj_' . $condition['trigger_type']);
548 
549  $cgui->addItem("conditions[]", $condition_id, $title, $icon, $alt);
550  }
551 
552  $tpl->setContent($cgui->getHTML());
553  }
listConditions()
list conditions ilToolbar
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 616 of file class.ilConditionHandlerGUI.php.

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

617  {
618  if (!isset($_GET['source_id'])) {
619  echo "class.ilConditionHandlerGUI: no source_id given";
620 
621  return false;
622  }
623  if (!$_POST['operator']) {
624  ilUtil::sendFailure($this->lng->txt('err_check_input'));
625  $this->add();
626  return false;
627  }
628 
629  $this->ch_obj->setTargetRefId($this->getTargetRefId());
630  $this->ch_obj->setTargetObjId($this->getTargetId());
631  $this->ch_obj->setTargetType($this->getTargetType());
632 
633  switch ($this->getTargetType()) {
634  case 'st':
635  $this->ch_obj->setReferenceHandlingType($_POST['ref_handling']);
636  break;
637 
638  default:
639  $this->ch_obj->setReferenceHandlingType(ilConditionHandler::UNIQUE_CONDITIONS);
640  break;
641  }
642  // this has to be changed, if non referenced trigger are implemted
643  if (!$trigger_obj =&ilObjectFactory::getInstanceByRefId((int) $_GET['source_id'], false)) {
644  echo 'ilConditionHandler: Trigger object does not exist';
645  }
646  $this->ch_obj->setTriggerRefId($trigger_obj->getRefId());
647  $this->ch_obj->setTriggerObjId($trigger_obj->getId());
648  $this->ch_obj->setTriggerType($trigger_obj->getType());
649  $this->ch_obj->setOperator($_POST['operator']);
650  $this->ch_obj->setObligatory((int) $_POST['obligatory']);
651  $this->ch_obj->setHiddenStatus(ilConditionHandler::lookupHiddenStatusByTarget($this->getTargetRefId()));
652  $this->ch_obj->setValue('');
653 
654  // Save assigned sco's
655  if ($this->ch_obj->getTriggerType() == 'sahs') {
656  include_once 'Services/Object/classes/class.ilObjectLP.php';
657  $olp = ilObjectLP::getInstance($this->ch_obj->getTriggerObjId());
658  $collection = $olp->getCollectionInstance();
659  if ($collection) {
660  $collection->delete();
661  }
662 
663  if (is_array($_POST['item_ids'])) { // #12901
664  $collection->activateEntries($_POST['item_ids']);
665  }
666  }
667 
668  $this->ch_obj->enableAutomaticValidation($this->getAutomaticValidation());
669  if (!$this->ch_obj->storeCondition()) {
670  ilUtil::sendFailure($this->ch_obj->getErrorMessage(), true);
671  } else {
672  ilUtil::sendSuccess($this->lng->txt('added_new_condition'), true);
673  }
674 
675  $this->ctrl->redirect($this, 'listConditions');
676 
677  return true;
678  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_GET["client_id"]
static lookupHiddenStatusByTarget($a_target_ref_id)
Lookup hidden status type $ilDB.
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_init()

ilConditionHandlerGUI::chi_init ( $chi_target_obj,
  $a_ref_id = null 
)

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

References ilObjectFactory\getInstanceByRefId().

215  {
216  echo 'deprecated';
217 
218  include_once "./Services/AccessControl/classes/class.ilConditionHandler.php";
219 
220  $this->ch_obj = new ilConditionHandler();
221 
222  if ($a_ref_id) {
223  $this->target_obj =&ilObjectFactory::getInstanceByRefId($a_ref_id);
224  } else {
225  $this->target_obj =&$this->object;
226  }
227 
228  return true;
229  }
Handles conditions for accesses to different ILIAS objects.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:

◆ chi_update()

ilConditionHandlerGUI::chi_update ( )

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

References $_POST, __getConditionsOfTarget(), and ilUtil\sendSuccess().

681  {
682  #if(in_array('',$_POST['operator']))
683  #{
684  # ilUtil::sendInfo($this->lng->txt('select_one_operator'));
685 
686  # return false;
687  #}
688  foreach ($this->__getConditionsOfTarget() as $condition) {
689  $this->ch_obj->setOperator($_POST['operator'][$condition["id"]]);
690  $this->ch_obj->setValue($_POST['value'][$condition["id"]]);
691  $this->ch_obj->updateCondition($condition['id']);
692  }
693  ilUtil::sendSuccess($this->lng->txt('conditions_updated'));
694 
695  $this->ctrl->returnToParent($this);
696 
697  return true;
698  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:

◆ delete()

ilConditionHandlerGUI::delete ( )

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

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

556  {
557  if (!count($_POST['conditions'])) {
558  ilUtil::sendFailure($this->lng->txt('no_condition_selected'));
559  $this->listConditions();
560  return true;
561  }
562 
563  foreach ($_POST['conditions'] as $condition_id) {
564  $this->ch_obj->deleteCondition($condition_id);
565  }
566  ilUtil::sendSuccess($this->lng->txt('condition_deleted'), true);
567  $this->ctrl->redirect($this, 'listConditions');
568 
569  return true;
570  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
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 447 of file class.ilConditionHandlerGUI.php.

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

448  {
449  global $ilObjDataCache;
450 
451  if (!$_GET['condition_id']) {
452  ilUtil::sendFailure("Missing id: condition_id");
453  $this->listConditions();
454  return false;
455  }
456  $condition = ilConditionHandler::_getCondition((int) $_GET['condition_id']);
457 
458  $this->tpl->addBlockfile(
459  'ADM_CONTENT',
460  'adm_content',
461  'tpl.condition_handler_edit_condition.html',
462  "Services/AccessControl"
463  );
464  $this->ctrl->setParameter($this, 'condition_id', (int) $_GET['condition_id']);
465 
466  $this->initFormCondition($condition['trigger_ref_id'], (int) $_GET['condition_id'], 'edit');
467  $this->tpl->setVariable('CONDITION_TABLE', $this->form->getHTML());
468  }
listConditions()
list conditions ilToolbar
$_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 110 of file class.ilConditionHandlerGUI.php.

References $ilErr, and $lng.

111  {
112  global $ilErr, $ilAccess, $lng;
113 
114  if (!$ilAccess->checkAccess('write', '', $this->getTargetRefId())) {
115  $ilErr->raiseError($lng->txt('permission_denied'), $ilErr->WARNING);
116  }
117 
118  $next_class = $this->ctrl->getNextClass($this);
119  $cmd = $this->ctrl->getCmd();
120 
121  switch ($next_class) {
122  default:
123  if (empty($cmd)) {
124  $cmd = "view";
125  }
126  $this->$cmd();
127  break;
128  }
129  }
global $ilErr
Definition: raiseError.php:16

◆ getAutomaticValidation()

ilConditionHandlerGUI::getAutomaticValidation ( )

Definition at line 135 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 105 of file class.ilConditionHandlerGUI.php.

References $_SESSION, and array.

106  {
107  return $_SESSION['precon_btn'] ? $_SESSION['precon_btn'] : array();
108  }
$_SESSION["AccountId"]
Create styles array
The data for the language used.

◆ getConditionHandler()

ilConditionHandlerGUI::getConditionHandler ( )
protected

Get condition handler.

Returns
ilConditionHandler

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

References $ch_obj.

Referenced by selector().

+ Here is the caller graph for this function:

◆ getTargetId()

ilConditionHandlerGUI::getTargetId ( )

get target id

Definition at line 152 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 168 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 209 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 184 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 720 of file class.ilConditionHandlerGUI.php.

References $ch_obj, $counter, $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().

721  {
722  $trigger_obj_id = ilObject::_lookupObjId($a_source_id);
723  $trigger_type = ilObject::_lookupType($trigger_obj_id);
724 
725  $condition = ilConditionHandler::_getCondition($a_condition_id);
726 
727  if (is_object($this->form)) {
728  return true;
729  }
730  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
731  $this->form = new ilPropertyFormGUI();
732  $this->ctrl->setParameter($this, 'source_id', $a_source_id);
733  $this->form->setFormAction($this->ctrl->getFormAction($this));
734 
735  $info_source = new ilNonEditableValueGUI($this->lng->txt("rbac_precondition_source"));
736  $info_source->setValue(ilObject::_lookupTitle(ilObject::_lookupObjId($a_source_id)));
737  $this->form->addItem($info_source);
738 
739  $info_target = new ilNonEditableValueGUI($this->lng->txt("rbac_precondition_target"));
740  $info_target->setValue($this->getTargetTitle());
741  $this->form->addItem($info_target);
742 
743  /* moved to list
744  $obl = new ilCheckboxInputGUI($this->lng->txt('precondition_obligatory'), 'obligatory');
745  $obl->setInfo($this->lng->txt('precondition_obligatory_info'));
746  $obl->setValue(1);
747  if($a_condition_id)
748  {
749  $obl->setChecked($condition['obligatory']);
750  }
751  else
752  {
753  $obl->setChecked(true);
754  }
755  $this->form->addItem($obl);
756  */
757  $obl = new ilHiddenInputGUI('obligatory');
758  if ($a_condition_id) {
759  $obl->setValue($condition['obligatory']);
760  } else {
761  $obl->setValue(1);
762  }
763  $this->form->addItem($obl);
764 
765  $sel = new ilSelectInputGUI($this->lng->txt('condition'), 'operator');
766  include_once "./Services/AccessControl/classes/class.ilConditionHandler.php";
767  $ch_obj = new ilConditionHandler();
768  if ($a_mode == 'add') {
769  $operators[0] = $this->lng->txt('select_one');
770  }
771  foreach ($ch_obj->getOperatorsByTargetType($trigger_type) as $operator) {
772  $operators[$operator] = $this->lng->txt('condition_' . $operator);
773  }
774  $sel->setValue(isset($condition['operator']) ? $condition['operator'] : 0);
775  $sel->setOptions($operators);
776  $sel->setRequired(true);
777  $this->form->addItem($sel);
778 
780  $rad_opt = new ilRadioGroupInputGUI($this->lng->txt('cond_ref_handling'), 'ref_handling');
781  $rad_opt->setValue(isset($condition['ref_handling']) ? $condition['ref_handling'] : ilConditionHandler::SHARED_CONDITIONS);
782 
783  $opt2 = new ilRadioOption($this->lng->txt('cond_ref_shared'), ilConditionHandler::SHARED_CONDITIONS);
784  $rad_opt->addOption($opt2);
785 
786  $opt1 = new ilRadioOption($this->lng->txt('cond_ref_unique'), ilConditionHandler::UNIQUE_CONDITIONS);
787  $rad_opt->addOption($opt1);
788 
789  $this->form->addItem($rad_opt);
790  }
791 
792  // Additional settings for SCO's
793  if ($trigger_type == 'sahs') {
794  $this->lng->loadLanguageModule('trac');
795 
796  $cus = new ilCustomInputGUI($this->lng->txt('trac_sahs_relevant_items'), 'item_ids[]');
797  $cus->setRequired(true);
798 
799  $tpl = new ilTemplate(
800  'tpl.condition_handler_sco_row.html',
801  true,
802  true,
803  "Services/AccessControl"
804  );
805  $counter = 0;
806 
807  include_once 'Services/Object/classes/class.ilObjectLP.php';
808  $olp = ilObjectLP::getInstance($trigger_obj_id);
809  $collection = $olp->getCollectionInstance();
810  if ($collection) {
811  foreach ($collection->getPossibleItems() as $item_id => $sahs_item) {
812  $tpl->setCurrentBlock("sco_row");
813  $tpl->setVariable('SCO_ID', $item_id);
814  $tpl->setVariable('SCO_TITLE', $sahs_item['title']);
815  $tpl->setVariable('CHECKED', $collection->isAssignedEntry($item_id) ? 'checked="checked"' : '');
816  $tpl->parseCurrentBlock();
817  $counter++;
818  }
819  }
820  $tpl->setVariable('INFO_SEL', $this->lng->txt('trac_lp_determination_info_sco'));
821  $cus->setHTML($tpl->get());
822  $this->form->addItem($cus);
823  }
824  switch ($a_mode) {
825  case 'edit':
826  $this->form->setTitleIcon(ilUtil::getImagePath('icon_' . $this->getTargetType() . '.svg'));
827  $this->form->setTitle($this->lng->txt('rbac_edit_condition'));
828  $this->form->addCommandButton('updateCondition', $this->lng->txt('save'));
829  $this->form->addCommandButton('listConditions', $this->lng->txt('cancel'));
830  break;
831 
832 
833  case 'add':
834  $this->form->setTitleIcon(ilUtil::getImagePath('icon_' . $this->getTargetType() . '.svg'));
835  $this->form->setTitle($this->lng->txt('add_condition'));
836  $this->form->addCommandButton('assign', $this->lng->txt('save'));
837  $this->form->addCommandButton('selector', $this->lng->txt('back'));
838  break;
839  }
840  return true;
841  }
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
$counter
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
Handles conditions for accesses to different ILIAS objects.
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 201 of file class.ilConditionHandlerGUI.php.

References getTargetRefId().

202  {
203  return $this->getTargetRefId() ? true : false;
204  }
+ Here is the call graph for this function:

◆ listConditions()

ilConditionHandlerGUI::listConditions ( )
protected

list conditions ilToolbar

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

References $form, $h, $table, ilConditionHandler\_getConditionsOfTarget(), ilConditionHandler\getOptionalConditionsOfTarget(), getTargetId(), getTargetRefId(), getTargetType(), and showObligatoryForm().

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

236  {
237  global $ilToolbar;
238 
239  $ilToolbar->addButton($this->lng->txt('add_condition'), $this->ctrl->getLinkTarget($this, 'selector'));
240 
241  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.list_conditions.html', 'Services/AccessControl');
242 
244  $this->getTargetRefId(),
245  $this->getTargetId(),
246  $this->getTargetType()
247  );
248  if (count($optional_conditions)) {
249  if (!$_REQUEST["list_mode"]) {
250  $_REQUEST["list_mode"] = "subset";
251  }
252  } elseif (!$_REQUEST["list_mode"]) {
253  $_REQUEST["list_mode"] = "all";
254  }
255 
256  // Show form only if conditions are availabe
258  $this->getTargetRefId(),
259  $this->getTargetId(),
260  $this->getTargetType()
261  ))
262  ) {
263  $form = $this->showObligatoryForm($optional_conditions);
264  if ($form instanceof ilPropertyFormGUI) {
265  $this->tpl->setVariable('TABLE_SETTINGS', $form->getHTML());
266  }
267  }
268 
269  include_once './Services/AccessControl/classes/class.ilConditionHandlerTableGUI.php';
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  }
static _getConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all conditions of target object
This class represents a property form user interface.
$h
if(isset($_POST['submit'])) $form
Table presentation of conditions.
static getOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
Get optional conditions.
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 344 of file class.ilConditionHandlerGUI.php.

References $_POST, ilConditionHandler\_getConditionsOfTarget(), ilConditionHandler\calculateRequiredTriggers(), getTargetId(), getTargetRefId(), getTargetType(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and ilConditionHandler\updateObligatory().

345  {
347  $this->getTargetRefId(),
348  $this->getTargetId(),
349  $this->getTargetType()
350  );
351 
352  if ($_POST["obl"] && sizeof($_POST["obl"]) > sizeof($all_conditions)-2) {
353  ilUtil::sendFailure($this->lng->txt("rbac_precondition_minimum_optional"), true);
354  $this->ctrl->redirect($this, 'listConditions');
355  }
356 
357  foreach ($all_conditions as $item) {
358  $status = false;
359  if ($_POST["obl"] && in_array($item["condition_id"], $_POST["obl"])) {
360  $status = true;
361  }
362  ilConditionHandler::updateObligatory($item["condition_id"], $status);
363  }
364 
365  // re-calculate
367  $this->getTargetRefId(),
368  $this->getTargetId(),
369  $this->getTargetType(),
370  true
371  );
372 
373  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
374  $this->ctrl->redirect($this, 'listConditions');
375  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _getConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all conditions of target object
static calculateRequiredTriggers($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.
$_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\_getConditionsOfTarget(), array, ilConditionHandler\getOptionalConditionsOfTarget(), getTargetId(), getTargetRefId(), getTargetType(), ilConditionHandler\saveNumberOfRequiredTriggers(), ilUtil\sendFailure(), ilUtil\sendSuccess(), 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") {
295  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
297  $this->getTargetRefId(),
298  $this->getTargetId(),
299  $this->getTargetType()
300  );
301  // Set all optional conditions to obligatory
302  foreach ((array) $optional_conditions as $item) {
303  ilConditionHandler::updateObligatory($item["condition_id"], true);
304  }
305  }
306  break;
307 
308  case "subset":
309  $num_req = $form->getInput('required');
310  if ($old_mode != "subset") {
312  $this->getTargetRefId(),
313  $this->getTargetId(),
314  $this->getTargetType()
315  );
316  foreach ($all_conditions as $item) {
317  ilConditionHandler::updateObligatory($item["condition_id"], false);
318  }
319  }
321  $this->getTargetRefId(),
322  $this->getTargetId(),
323  $num_req
324  );
325  break;
326  }
327 
328  $cond = new ilConditionHandler();
329  $cond->setTargetRefId($this->getTargetRefId());
330  $cond->updateHiddenStatus((int) $form->getInput('hidden'));
331 
332  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
333  $this->ctrl->redirect($this, 'listConditions');
334  }
335 
336  $form->setValuesByPost();
337  ilUtil::sendFailure($this->lng->txt('err_check_input'));
338  $this->tpl->setContent($form->getHTML());
339  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static saveNumberOfRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_num)
Save number of obigatory triggers.
static _getConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all conditions of target object
if(isset($_POST['submit'])) $form
static getOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
Get optional conditions.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Handles conditions for accesses to different ILIAS objects.
static updateObligatory($a_id, $a_status)
Toggle condition obligatory status.
showObligatoryForm($opt=array())
Show obligatory form.
+ Here is the call graph for this function:

◆ selector()

ilConditionHandlerGUI::selector ( )

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

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

Referenced by add().

573  {
574  include_once("./Services/AccessControl/classes/class.ilConditionSelector.php");
575 
576  ilUtil::sendInfo($this->lng->txt("condition_select_object"));
577 
578  $exp = new ilConditionSelector($this, "selector");
579  $exp->setTypeWhiteList(array_merge(
580  $this->getConditionHandler()->getTriggerTypes(),
581  array("root", "cat", "grp", "fold", "crs", "prg")
582  ));
583  //setRefId have to be after setTypeWhiteList!
584  $exp->setRefId($this->getTargetRefId());
585  $exp->setClickableTypes($this->getConditionHandler()->getTriggerTypes());
586 
587  if (!$exp->handleCommand()) {
588  $this->tpl->setContent($exp->getHTML());
589  }
590  }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
getConditionHandler()
Get condition handler.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAutomaticValidation()

ilConditionHandlerGUI::setAutomaticValidation (   $a_status)

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

132  {
133  $this->automatic_validation = $a_status;
134  }

◆ setBackButtons()

ilConditionHandlerGUI::setBackButtons (   $a_btn_arr)

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

References $_SESSION.

102  {
103  $_SESSION['precon_btn'] = $a_btn_arr;
104  }
$_SESSION["AccountId"]

◆ setTargetId()

ilConditionHandlerGUI::setTargetId (   $a_target_id)

set target id

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

Referenced by __construct().

145  {
146  $this->target_id = $a_target_id;
147  }
+ Here is the caller graph for this function:

◆ setTargetRefId()

ilConditionHandlerGUI::setTargetRefId (   $a_target_ref_id)

set target ref id

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

Referenced by __construct().

161  {
162  $this->target_ref_id = $a_target_ref_id;
163  }
+ Here is the caller graph for this function:

◆ setTargetTitle()

ilConditionHandlerGUI::setTargetTitle (   $a_target_title)

set target title

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

Referenced by __construct().

193  {
194  $this->target_title = $a_target_title;
195  }
+ Here is the caller graph for this function:

◆ setTargetType()

ilConditionHandlerGUI::setTargetType (   $a_target_type)

set target type

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

Referenced by __construct().

177  {
178  $this->target_type = $a_target_type;
179  }
+ Here is the caller graph for this function:

◆ showObligatoryForm()

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

Show obligatory form.

Returns
ilPropertyFormGUI

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

References $form, $GLOBALS, ilConditionHandler\_getConditionsOfTarget(), ilConditionHandler\getOptionalConditionsOfTarget(), getTargetId(), getTargetRefId(), getTargetType(), ilConditionHandler\lookupHiddenStatusByTarget(), ilConditionHandler\lookupObligatoryConditionsOfTarget(), ilCheckboxInputGUI\setChecked(), ilRadioOption\setInfo(), and ilFormPropertyGUI\setInfo().

Referenced by listConditions(), and saveObligatorySettings().

382  {
383  if (!$GLOBALS['objDefinition']->isRbacObject($this->getTargetType())) {
384  return;
385  }
386 
387 
388  if (!$opt) {
390  $this->getTargetRefId(),
391  $this->getTargetId(),
392  $this->getTargetType()
393  );
394  }
395 
397 
398  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
399  $form = new ilPropertyFormGUI();
400  $form->setFormAction($this->ctrl->getFormAction($this), 'listConditions');
401  $form->setTitle($this->lng->txt('precondition_obligatory_settings'));
402  $form->addCommandButton('saveObligatorySettings', $this->lng->txt('save'));
403 
404  $hide = new ilCheckboxInputGUI($this->lng->txt('rbac_precondition_hide'), 'hidden');
406  $hide->setValue(1);
407  $hide->setInfo($this->lng->txt('rbac_precondition_hide_info'));
408  $form->addItem($hide);
409 
410  $mode = new ilRadioGroupInputGUI($this->lng->txt("rbac_precondition_mode"), "list_mode");
411  $form->addItem($mode);
412  $mode->setValue($_REQUEST["list_mode"]);
413 
414  $mall = new ilRadioOption($this->lng->txt("rbac_precondition_mode_all"), "all");
415  $mall->setInfo($this->lng->txt("rbac_precondition_mode_all_info"));
416  $mode->addOption($mall);
417 
418 
419  if (count($all) > 1) {
420  $min = 1;
421  $max = count($all) - 1;
422 
423  $msubset = new ilRadioOption($this->lng->txt("rbac_precondition_mode_subset"), "subset");
424  $msubset->setInfo($this->lng->txt("rbac_precondition_mode_subset_info"));
425  $mode->addOption($msubset);
426 
427  $obl = new ilNumberInputGUI($this->lng->txt('precondition_num_obligatory'), 'required');
428  $obl->setInfo($this->lng->txt('precondition_num_optional_info'));
429 
431  $obl->setValue($num_required > 0 ? $num_required : null);
432  $obl->setRequired(true);
433  $obl->setSize(1);
434  $obl->setMinValue($min);
435  $obl->setMaxValue($max);
436  $msubset->addSubItem($obl);
437  }
438 
439  $old_mode = new ilHiddenInputGUI("old_list_mode");
440  $old_mode->setValue($_REQUEST["list_mode"]);
441  $form->addItem($old_mode);
442 
443  return $form;
444  }
This class represents an option in a radio group.
static _getConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all conditions of target object
This class represents a property form user interface.
static lookupHiddenStatusByTarget($a_target_ref_id)
Lookup hidden status type $ilDB.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
This class represents a checkbox property in a property form.
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
This class represents a number property in a property form.
static getOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
Get optional conditions.
+ 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 77 of file class.ilConditionHandlerGUI.php.

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

Referenced by ilObjectListGUI\parseConditions().

78  {
79  switch ($a_operator) {
81  $GLOBALS['lng']->loadLanguageModule('trac');
82  include_once './Services/Tracking/classes/class.ilLPObjSettings.php';
83  $obj_settings = new ilLPObjSettings($a_obj_id);
84  return ilLPObjSettings::_mode2Text($obj_settings->getMode());
85 
86  default:
87  $GLOBALS['lng']->loadLanguageModule('rbac');
88  return $GLOBALS['lng']->txt('condition_' . $a_operator);
89  }
90  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
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 470 of file class.ilConditionHandlerGUI.php.

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

471  {
472  global $ilObjDataCache;
473 
474  if (!$_GET['condition_id']) {
475  ilUtil::sendFailure("Missing id: condition_id");
476  $this->listConditions();
477  return false;
478  }
479 
480  // Update condition
481  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
482  $condition_handler = new ilConditionHandler();
483 
484  $condition = ilConditionHandler::_getCondition((int) $_GET['condition_id']);
485  $condition_handler->setOperator($_POST['operator']);
486  $condition_handler->setObligatory((int) $_POST['obligatory']);
487  $condition_handler->setTargetRefId($this->getTargetRefId());
488  $condition_handler->setValue('');
489  switch ($this->getTargetType()) {
490  case 'st':
491  $condition_handler->setReferenceHandlingType($_POST['ref_handling']);
492  break;
493 
494  default:
495  $condition_handler->setReferenceHandlingType(ilConditionHandler::UNIQUE_CONDITIONS);
496  break;
497  }
498  $condition_handler->updateCondition($condition['id']);
499 
500  // Update relevant sco's
501  if ($condition['trigger_type'] == 'sahs') {
502  include_once 'Services/Object/classes/class.ilObjectLP.php';
503  $olp = ilObjectLP::getInstance($condition['trigger_obj_id']);
504  $collection = $olp->getCollectionInstance();
505  if ($collection) {
506  $collection->delete();
507  }
508 
509  if (is_array($_POST['item_ids'])) { // #12901
510  $collection->activateEntries($_POST['item_ids']);
511  }
512 
513  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
514  ilLPStatusWrapper::_refreshStatus($condition['trigger_obj_id']);
515  }
516 
517  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
518  $this->ctrl->redirect($this, 'listConditions');
519  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
listConditions()
list conditions ilToolbar
$_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.
Handles conditions for accesses to different ILIAS objects.
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: