/**
  * assign new trigger condition to target
  */
 function assign()
 {
     if (!isset($_GET['source_id'])) {
         echo "class.ilConditionHandlerGUI: no source_id given";
         return false;
     }
     if (!$_POST['operator']) {
         ilUtil::sendFailure($this->lng->txt('err_check_input'));
         $this->add();
         return false;
     }
     $this->ch_obj->setTargetRefId($this->getTargetRefId());
     $this->ch_obj->setTargetObjId($this->getTargetId());
     $this->ch_obj->setTargetType($this->getTargetType());
     switch ($this->getTargetType()) {
         case 'st':
             $this->ch_obj->setReferenceHandlingType($_POST['ref_handling']);
             break;
         default:
             $this->ch_obj->setReferenceHandlingType(ilConditionHandler::UNIQUE_CONDITIONS);
             break;
     }
     // this has to be changed, if non referenced trigger are implemted
     if (!($trigger_obj =& ilObjectFactory::getInstanceByRefId((int) $_GET['source_id'], false))) {
         echo 'ilConditionHandler: Trigger object does not exist';
     }
     $this->ch_obj->setTriggerRefId($trigger_obj->getRefId());
     $this->ch_obj->setTriggerObjId($trigger_obj->getId());
     $this->ch_obj->setTriggerType($trigger_obj->getType());
     $this->ch_obj->setOperator($_POST['operator']);
     $this->ch_obj->setObligatory((int) $_POST['obligatory']);
     $this->ch_obj->setHiddenStatus(ilConditionHandler::lookupHiddenStatusByTarget($this->getTargetRefId()));
     $this->ch_obj->setValue('');
     // Save assigned sco's
     if ($this->ch_obj->getTriggerType() == 'sahs') {
         include_once 'Services/Object/classes/class.ilObjectLP.php';
         $olp = ilObjectLP::getInstance($this->ch_obj->getTriggerObjId());
         $collection = $olp->getCollectionInstance();
         if ($collection) {
             $collection->delete();
         }
         if (is_array($_POST['item_ids'])) {
             $collection->activateEntries($_POST['item_ids']);
         }
     }
     $this->ch_obj->enableAutomaticValidation($this->getAutomaticValidation());
     if (!$this->ch_obj->storeCondition()) {
         ilUtil::sendFailure($this->ch_obj->getErrorMessage(), true);
     } else {
         ilUtil::sendSuccess($this->lng->txt('added_new_condition'), true);
     }
     $this->ctrl->redirect($this, 'listConditions');
     return true;
 }
예제 #2
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;
 }
예제 #3
0
 /**
  * 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 == 'visible' and !$this->checkAccessOfUser($a_user_id, "write", "", $a_ref_id, $a_type, $a_obj_id)) {
         if (ilConditionHandler::lookupHiddenStatusByTarget($a_ref_id)) {
             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);
                 }
                 return FALSE;
             }
             $ilBench->stop("AccessControl", "4000_checkAccess_condition_check");
         }
     }
     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;
 }