/**
  * 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;
 }
 function assignCourse()
 {
     global $ilErr, $ilAccess, $ilObjDataCache, $tree, $ilUser;
     if (!$ilAccess->checkAccess('write', '', $this->content_obj->getRefId())) {
         $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
     }
     if (!$_GET['obj_id']) {
         $this->listGroupings();
         return false;
     }
     // delete all existing conditions
     include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
     $condh = new ilConditionHandler();
     $condh->deleteByObjId((int) $_GET['obj_id']);
     $added = 0;
     $container_ids = is_array($_POST['crs_ids']) ? $_POST['crs_ids'] : array();
     foreach ($container_ids as $course_ref_id) {
         $tmp_crs = ilObjectFactory::getInstanceByRefId($course_ref_id);
         $tmp_condh = new ilConditionHandler();
         $tmp_condh->enableAutomaticValidation(false);
         $tmp_condh->setTargetRefId($course_ref_id);
         $tmp_condh->setTargetObjId($tmp_crs->getId());
         $tmp_condh->setTargetType($this->getContentType());
         $tmp_condh->setTriggerRefId(0);
         $tmp_condh->setTriggerObjId($this->id);
         $tmp_condh->setTriggerType('crsg');
         $tmp_condh->setOperator('not_member');
         $tmp_condh->setValue($this->grp_obj->getUniqueField());
         if (!$tmp_condh->checkExists()) {
             $tmp_condh->storeCondition();
             ++$added;
         }
     }
     ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
     $this->ctrl->redirect($this, 'edit');
 }
示例#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;
 }
 function updateCondition()
 {
     global $ilObjDataCache;
     if (!$_GET['condition_id']) {
         ilUtil::sendFailure("Missing id: condition_id");
         $this->listConditions();
         return false;
     }
     // Update condition
     include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
     $condition_handler = new ilConditionHandler();
     $condition = ilConditionHandler::_getCondition((int) $_GET['condition_id']);
     $condition_handler->setOperator($_POST['operator']);
     $condition_handler->setObligatory((int) $_POST['obligatory']);
     $condition_handler->setTargetRefId($this->getTargetRefId());
     $condition_handler->setValue('');
     switch ($this->getTargetType()) {
         case 'st':
             $condition_handler->setReferenceHandlingType($_POST['ref_handling']);
             break;
         default:
             $condition_handler->setReferenceHandlingType(ilConditionHandler::UNIQUE_CONDITIONS);
             break;
     }
     $condition_handler->updateCondition($condition['id']);
     // Update relevant sco's
     if ($condition['trigger_type'] == 'sahs') {
         include_once 'Services/Object/classes/class.ilObjectLP.php';
         $olp = ilObjectLP::getInstance($condition['trigger_obj_id']);
         $collection = $olp->getCollectionInstance();
         if ($collection) {
             $collection->delete();
         }
         if (is_array($_POST['item_ids'])) {
             $collection->activateEntries($_POST['item_ids']);
         }
         include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
         ilLPStatusWrapper::_refreshStatus($condition['trigger_obj_id']);
     }
     ilUtil::sendSuccess($this->lng->txt('settings_saved'));
     $this->ctrl->redirect($this, 'listConditions');
 }