/**
  * get top chapter of page for that any precondition is missing
  */
 function _getMissingPreconditionsTopChapter($cont_obj_ref_id, $cont_obj_id, $page_id)
 {
     $lm_tree = new ilTree($cont_obj_id);
     $lm_tree->setTableNames('lm_tree', 'lm_data');
     $lm_tree->setTreeTablePK("lm_id");
     $conds = array();
     if ($lm_tree->isInTree($page_id)) {
         // get full path of page
         $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId());
         foreach ($path as $node) {
             if ($node["type"] == "st") {
                 // get all preconditions of upper chapters
                 $tconds = ilConditionHandler::_getConditionsOfTarget($cont_obj_ref_id, $node["child"], "st");
                 foreach ($tconds as $tcond) {
                     // look for missing precondition
                     if (!ilConditionHandler::_checkCondition($tcond["id"])) {
                         return $node["child"];
                     }
                 }
             }
         }
     }
     return "";
 }
Пример #2
0
 /**
  * test preconditions
  * @param
  * @return
  */
 public function testConditions()
 {
     include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
     ilConditionHandler::_getDistinctTargetRefIds();
     ilConditionHandler::_deleteTargetConditionsByRefId(1);
     $handler = new ilConditionHandler();
     $handler->setTargetRefId(99999);
     $handler->setTargetObjId(99998);
     $handler->setTargetType('xxx');
     $handler->setTriggerRefId(99997);
     $handler->setTriggerObjId(99996);
     $handler->setTriggerType('yyy');
     $handler->setReferenceHandlingType(0);
     $handler->enableAutomaticValidation(false);
     $suc = $handler->storeCondition();
     $this->assertEquals($suc, true);
     $suc = $handler->checkExists();
     $this->assertEquals($suc, false);
     $suc = $handler->delete(99999);
     $this->assertEquals($suc, true);
     // syntax check
     $handler->deleteByObjId(-1);
     $handler->deleteCondition(-1);
     ilConditionHandler::_getConditionsOfTrigger(-1, -1);
     ilConditionHandler::_getConditionsOfTarget(-1, -1);
     ilConditionHandler::_getCondition(-1);
 }
Пример #3
0
 /**
  * Clone object dependencies
  *
  * This method allows to refresh any ref id references to other objects
  * that are affected in the same copy process. Ask ilCopyWizardOptions for
  * the mappings.
  *
  * @access public
  * @param int ref_id of target object
  * @param int copy_id
  * 
  */
 public function cloneDependencies($a_target_id, $a_copy_id)
 {
     include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
     include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
     $mappings = $cwo->getMappings();
     $conditions = ilConditionHandler::_getConditionsOfTarget($this->getRefId(), $this->getId());
     foreach ($conditions as $con) {
         if ($mappings[$con['trigger_ref_id']]) {
             $newCondition = new ilConditionHandler();
             $target_obj = ilObject::_lookupObjId($a_target_id);
             $target_typ = ilObject::_lookupType($target_obj);
             $newCondition->setTargetRefId($a_target_id);
             $newCondition->setTargetObjId($target_obj);
             $newCondition->setTargetType($target_typ);
             $trigger_ref = $mappings[$con['trigger_ref_id']];
             $trigger_obj = ilObject::_lookupObjId($trigger_ref);
             $trigger_typ = ilObject::_lookupType($trigger_obj);
             $newCondition->setTriggerRefId($trigger_ref);
             $newCondition->setTriggerObjId($trigger_obj);
             $newCondition->setTriggerType($trigger_typ);
             $newCondition->setOperator($con['operator']);
             $newCondition->setValue($con['value']);
             $newCondition->setReferenceHandlingType($con['ref_handling']);
             $newCondition->setObligatory($con['obligatory']);
             $newCondition->setHiddenStatus(ilConditionHandler::lookupHiddenStatusByTarget($this->getRefId()));
             $newCondition->storeCondition();
         }
     }
     include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
     $tpl_id = ilDidacticTemplateObjSettings::lookupTemplateId($this->getRefId());
     if ($tpl_id) {
         include_once './Services/Object/classes/class.ilObjectFactory.php';
         $factory = new ilObjectFactory();
         $obj = $factory->getInstanceByRefId($a_target_id, FALSE);
         if ($obj instanceof ilObject) {
             $obj->applyDidacticTemplate($tpl_id);
         }
     }
     return true;
 }
Пример #4
0
 /**
  * Clone object dependencies
  *
  * This method allows to refresh any ref id references to other objects
  * that are affected in the same copy process. Ask ilCopyWizardOptions for
  * the mappings.
  *
  * @access public
  * @param int ref_id of target object
  * @param int copy_id
  * 
  */
 public function cloneDependencies($a_target_id, $a_copy_id)
 {
     include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
     include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
     $mappings = $cwo->getMappings();
     $conditions = ilConditionHandler::_getConditionsOfTarget($this->getRefId(), $this->getId());
     foreach ($conditions as $con) {
         if ($mappings[$con['trigger_ref_id']]) {
             $newCondition = new ilConditionHandler();
             $target_obj = ilObject::_lookupObjId($a_target_id);
             $target_typ = ilObject::_lookupType($target_obj);
             $newCondition->setTargetRefId($a_target_id);
             $newCondition->setTargetObjId($target_obj);
             $newCondition->setTargetType($target_typ);
             $trigger_ref = $mappings[$con['trigger_ref_id']];
             $trigger_obj = ilObject::_lookupObjId($trigger_ref);
             $trigger_typ = ilObject::_lookupType($trigger_obj);
             $newCondition->setTriggerRefId($trigger_ref);
             $newCondition->setTriggerObjId($trigger_obj);
             $newCondition->setTriggerType($trigger_typ);
             $newCondition->setOperator($con['operator']);
             $newCondition->setValue($con['value']);
             $newCondition->setReferenceHandlingType($con['ref_handling']);
             $newCondition->setObligatory($con['obligatory']);
             $newCondition->storeCondition();
         }
     }
     return true;
 }
Пример #5
0
 /**
  * insert all missing preconditions
  */
 function insertPreconditions()
 {
     global $ilAccess, $lng, $objDefinition, $tree;
     include_once "./Services/AccessControl/classes/class.ilConditionHandler.php";
     $missing_cond_exist = false;
     // do not show multi level conditions (messes up layout)
     if ($this->condition_depth > 0) {
         return;
     }
     // Sort by title
     /*
     foreach(ilConditionHandler::_getConditionsOfTarget($this->ref_id, $this->obj_id) as $condition)
     {
     	$condition['title'] = ilObject::_lookupTitle($condition['trigger_obj_id']);
     }
     */
     if ($this->condition_target) {
         $conditions = ilConditionHandler::_getConditionsOfTarget($this->condition_target['ref_id'], $this->condition_target['obj_id'], $this->condition_target['target_type']);
     } else {
         $conditions = ilConditionHandler::_getConditionsOfTarget($this->ref_id, $this->obj_id);
     }
     if (sizeof($conditions)) {
         for ($i = 0; $i < count($conditions); $i++) {
             $conditions[$i]['title'] = ilObject::_lookupTitle($conditions[$i]['trigger_obj_id']);
         }
         $conditions = ilUtil::sortArray($conditions, 'title', 'DESC');
         ++self::$js_unique_id;
         // Show obligatory and optional preconditions seperated
         $all_done_obl = $this->parseConditions(self::$js_unique_id, $conditions, true);
         $all_done_opt = $this->parseConditions(self::$js_unique_id, $conditions, false);
         if (!$all_done_obl || !$all_done_opt) {
             $this->tpl->setCurrentBlock("preconditions_toggle");
             $this->tpl->setVariable("PRECONDITION_TOGGLE_INTRO", $this->lng->txt("precondition_toggle"));
             $this->tpl->setVariable("PRECONDITION_TOGGLE_TRIGGER", $this->lng->txt("show"));
             $this->tpl->setVariable("PRECONDITION_TOGGLE_ID", self::$js_unique_id);
             $this->tpl->setVariable("TXT_PRECONDITION_SHOW", $this->lng->txt("show"));
             $this->tpl->setVariable("TXT_PRECONDITION_HIDE", $this->lng->txt("hide"));
             $this->tpl->parseCurrentBlock();
         }
     }
 }
 function __getConditionsOfTarget()
 {
     include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
     foreach (ilConditionHandler::_getConditionsOfTarget($this->getTargetRefId(), $this->getTargetId(), $this->getTargetType()) as $condition) {
         if ($condition['operator'] == 'not_member') {
             continue;
         } else {
             $cond[] = $condition;
         }
     }
     return $cond ? $cond : array();
 }
 /**
  * condition check (currently only implemented for read permission)
  * 
  */
 function doConditionCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id, $a_obj_id, $a_type)
 {
     //echo "conditionCheck<br/>";
     global $lng, $ilBench;
     if (($a_permission == "read" or $a_permission == 'join') && !$this->checkAccessOfUser($a_user_id, "write", "", $a_ref_id, $a_type, $a_obj_id)) {
         $ilBench->start("AccessControl", "4000_checkAccess_condition_check");
         if (!ilConditionHandler::_checkAllConditionsOfTarget($a_ref_id, $a_obj_id, $a_type, $a_user_id)) {
             $conditions = ilConditionHandler::_getConditionsOfTarget($a_ref_id, $a_obj_id, $a_type);
             foreach ($conditions as $condition) {
                 $this->current_info->addInfoItem(IL_MISSING_PRECONDITION, $lng->txt("missing_precondition") . ": " . ilObject::_lookupTitle($condition["trigger_obj_id"]) . " " . $lng->txt("condition_" . $condition["operator"]) . " " . $condition["value"], $condition);
             }
             $ilBench->stop("AccessControl", "4000_checkAccess_condition_check");
             return false;
         }
         $ilBench->stop("AccessControl", "4000_checkAccess_condition_check");
     }
     return true;
 }
 /**
  * Get courses/groups that are assigned to the same membership limitation
  * 
  * @param object container object
  * @return array array of reference ids
  */
 function _getGroupingItems($container_obj)
 {
     global $tree, $ilObjDataCache, $ilAccess, $tree;
     include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
     $trigger_ids = array();
     foreach (ilConditionHandler::_getConditionsOfTarget($container_obj->getRefId(), $container_obj->getId(), $container_obj->getType()) as $condition) {
         if ($condition['operator'] == 'not_member') {
             $trigger_ids[] = $condition['trigger_obj_id'];
         }
     }
     if (!count($trigger_ids)) {
         return false;
     }
     $hash_table = array();
     foreach ($trigger_ids as $trigger_id) {
         foreach (ilConditionHandler::_getConditionsOfTrigger('crsg', $trigger_id) as $condition) {
             // Continue if trigger is deleted
             if ($tree->isDeleted($condition['target_ref_id'])) {
                 continue;
             }
             if ($condition['operator'] == 'not_member') {
                 if (!$hash_table[$condition['target_ref_id']]) {
                     $items[] = $condition['target_ref_id'];
                 }
                 $hash_table[$condition['target_ref_id']] = true;
             }
         }
     }
     return $items ? $items : array();
 }
 function checkCircle($a_ref_id, $a_obj_id)
 {
     foreach (ilConditionHandler::_getConditionsOfTarget($a_ref_id, $a_obj_id) as $condition) {
         if ($condition['trigger_obj_id'] == $this->target_obj_id and $condition['operator'] == $this->getOperator()) {
             $this->circle = true;
             break;
         } else {
             $this->checkCircle($condition['trigger_ref_id'], $condition['trigger_obj_id']);
         }
     }
     return $this->circle;
 }