Пример #1
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);
 }
 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');
 }