function addCourse($sid, $target_id, $crs_xml) { $this->initAuth($sid); $this->initIlias(); if (!$this->__checkSession($sid)) { return $this->__raiseError($this->__getMessage(), $this->__getMessageCode()); } if (!is_numeric($target_id)) { return $this->__raiseError('No valid target id given. Please choose an existing reference id of an ILIAS category', 'Client'); } global $rbacsystem; if (!($target_obj =& ilObjectFactory::getInstanceByRefId($target_id, false))) { return $this->__raiseError('No valid target given.', 'Client'); } if (ilObject::_isInTrash($target_id)) { return $this->__raiseError("Parent with ID {$target_id} has been deleted.", 'CLIENT_OBJECT_DELETED'); } if (!$rbacsystem->checkAccess('create', $target_id, 'crs')) { return $this->__raiseError('Check access failed. No permission to create courses', 'Server'); } // Start import include_once "Modules/Course/classes/class.ilObjCourse.php"; $newObj = new ilObjCourse(); $newObj->setType('crs'); $newObj->setTitle('dummy'); $newObj->setDescription(""); $newObj->create(true); // true for upload $newObj->createReference(); $newObj->putInTree($target_id); $newObj->setPermissions($target_id); include_once 'Modules/Course/classes/class.ilCourseXMLParser.php'; $xml_parser = new ilCourseXMLParser($newObj); $xml_parser->setXMLContent($crs_xml); $xml_parser->startParsing(); return $newObj->getRefId() ? $newObj->getRefId() : "0"; }