Пример #1
0
 /**
  * Import XML
  *
  * @param
  * @return
  */
 function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
 {
     include_once './Modules/Course/classes/class.ilCourseXMLParser.php';
     include_once './Modules/Course/classes/class.ilObjCourse.php';
     if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
         $refs = ilObject::_getAllReferences($new_id);
         $this->course = ilObjectFactory::getInstanceByRefId(end($refs), false);
         #$this->course = ilObjectFactory::getInstanceByObjId($new_id,false);
     } elseif ($new_id = $a_mapping->getMapping('Services/Container', 'refs', 0)) {
         $this->course = ilObjectFactory::getInstanceByRefId($new_id, false);
     } elseif (!$this->course instanceof ilObjCourse) {
         $this->course = new ilObjCourse();
         $this->course->create(true);
     }
     try {
         $parser = new ilCourseXMLParser($this->course);
         $parser->setXMLContent($a_xml);
         $parser->startParsing();
         $a_mapping->addMapping('Modules/Course', 'crs', $a_id, $this->course->getId());
     } catch (ilSaxParserException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Parsing failed with message, "' . $e->getMessage() . '".');
     } catch (Exception $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Parsing failed with message, "' . $e->getMessage() . '".');
     }
 }
 function updateCourse($sid, $course_id, $xml)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     if (!is_numeric($course_id)) {
         return $this->__raiseError('No valid course id given. Please choose an existing reference id of an ILIAS course', 'Client');
     }
     global $rbacsystem;
     if (($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs') {
         $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
         if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs') {
             return $this->__raiseError('Invalid course id. Object with id "' . $course_id . '" is not of type "course"', 'Client');
         }
     }
     if (!($tmp_course = ilObjectFactory::getInstanceByRefId($course_id, false))) {
         return $this->__raiseError('Cannot create course instance!', 'Server');
     }
     if (!$rbacsystem->checkAccess('write', $course_id)) {
         return $this->__raiseError('Check access failed. No permission to write course', 'Server');
     }
     // First delete old meta data
     include_once 'Services/MetaData/classes/class.ilMD.php';
     $md = new ilMD($tmp_course->getId(), 0, 'crs');
     $md->deleteAll();
     include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
     ilCourseParticipants::_deleteAllEntries($tmp_course->getId());
     include_once 'Modules/Course/classes/class.ilCourseWaitingList.php';
     ilCourseWaitingList::_deleteAll($tmp_course->getId());
     include_once 'Modules/Course/classes/class.ilCourseXMLParser.php';
     $xml_parser = new ilCourseXMLParser($tmp_course);
     $xml_parser->setXMLContent($xml);
     $xml_parser->startParsing();
     $tmp_course->MDUpdateListener('General');
     return true;
 }