コード例 #1
0
ファイル: ilRBACTest.php プロジェクト: Walid-Synakene/ilias
 /**
  * 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);
 }
コード例 #2
0
ファイル: class.ilObject.php プロジェクト: arlendotcn/ilias
 /**
  * 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
 /**
  * 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;
 }
コード例 #4
0
 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');
 }