Ejemplo n.º 1
0
 /**
  * Import XML
  *
  * @param
  * @return
  */
 function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
 {
     if ($a_entity == "glo") {
         // case i container
         if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
             $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
             $xml_file = $this->getImportDirectory() . '/' . basename($this->getImportDirectory()) . '.xml';
             $GLOBALS['ilLog']->write(__METHOD__ . ': Using XML file ' . $xml_file);
         } else {
             if ($new_id = $a_mapping->getMapping('Modules/Glossary', 'glo', "new_id")) {
                 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
                 $xml_file = $this->getImportDirectory() . '/' . basename($this->getImportDirectory()) . '.xml';
                 $GLOBALS['ilLog']->write(__METHOD__ . ': Using XML file ' . $xml_file);
             } else {
                 // Shouldn't happen
                 $GLOBALS['ilLog']->write(__METHOD__ . ': Called in non container mode');
                 $GLOBALS['ilLog']->logStack();
                 return false;
             }
         }
         if (!file_exists($xml_file)) {
             $GLOBALS['ilLog']->write(__METHOD__ . ': ERROR Cannot find ' . $xml_file);
             return false;
         }
         include_once './Modules/LearningModule/classes/class.ilContObjParser.php';
         $contParser = new ilContObjParser($newObj, $xml_file, basename($this->getImportDirectory()));
         $contParser->startParsing();
         ilObject::_writeImportId($newObj->getId(), $newObj->getImportId());
         // write term map for taxonomies to mapping object
         $term_map = $contParser->getGlossaryTermMap();
         foreach ($term_map as $k => $v) {
             $a_mapping->addMapping("Services/Taxonomy", "tax_item", "glo:term:" . $k, $v);
             // this is since 4.3 does not export these ids but 4.4 tax node assignment needs it
             $a_mapping->addMapping("Services/Taxonomy", "tax_item_obj_id", "glo:term:" . $k, $newObj->getId());
             $a_mapping->addMapping("Services/AdvancedMetaData", "advmd_sub_item", "advmd:term:" . $k, $v);
         }
         // ???
         $a_mapping->addMapping("Services/Taxonomy", "tax_item", "glo:term:" . $k, $v);
         $a_mapping->addMapping("Modules/Glossary", "glo", $a_id, $newObj->getId());
         $a_mapping->addMapping("Services/AdvancedMetaData", "parent", $a_id, $newObj->getId());
         $this->current_glo = $newObj;
     }
 }
 /**
  * handler for begin of element
  *
  * @param	resource	$a_xml_parser		xml parser
  * @param	string		$a_name				element name
  * @param	array		$a_attribs			element attributes array
  */
 function handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
 {
     if ($this->in_meta_data) {
         parent::handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
         return;
     }
     switch ($a_name) {
         case 'Course':
             if (strlen($a_attribs['importId'])) {
                 $this->log->write("CourseXMLParser: importId = " . $a_attribs['importId']);
                 $this->course_obj->setImportId($a_attribs['importId']);
                 ilObject::_writeImportId($this->course_obj->getId(), $a_attribs['importId']);
             }
             if (strlen($a_attribs['showMembers'])) {
                 $this->course_obj->setShowMembers($a_attribs['showMembers'] == 'Yes' ? true : false);
             }
             break;
         case 'Admin':
             if ($id_data = $this->__parseId($a_attribs['id'])) {
                 if ($id_data['local'] or $id_data['imported']) {
                     $this->handleAdmin($a_attribs, $id_data);
                 }
             }
             break;
         case 'Tutor':
             if ($id_data = $this->__parseId($a_attribs['id'])) {
                 if ($id_data['local'] or $id_data['imported']) {
                     $this->handleTutor($a_attribs, $id_data);
                 }
             }
             break;
         case 'Member':
             if ($id_data = $this->__parseId($a_attribs['id'])) {
                 if ($id_data['local'] or $id_data['imported']) {
                     $this->handleMember($a_attribs, $id_data);
                 }
             }
             break;
         case 'Subscriber':
             if ($id_data = $this->__parseId($a_attribs['id'])) {
                 if ($id_data['local'] or $id_data['imported']) {
                     $this->handleSubscriber($a_attribs, $id_data);
                 }
             }
             break;
         case 'WaitingList':
             if ($id_data = $this->__parseId($a_attribs['id'])) {
                 if ($id_data['local'] or $id_data['imported']) {
                     $this->handleWaitingList($a_attribs, $id_data);
                 }
             }
             break;
         case 'Settings':
             $this->in_settings = true;
             break;
         case 'Availability':
             $this->in_availability = true;
             break;
         case 'NotAvailable':
             if ($this->in_availability) {
                 $this->course_obj->setActivationType(IL_CRS_ACTIVATION_OFFLINE);
             } elseif ($this->in_registration) {
                 $this->course_obj->setSubscriptionLimitationType(IL_CRS_SUBSCRIPTION_DEACTIVATED);
             }
             break;
         case 'Unlimited':
             if ($this->in_availability) {
                 $this->course_obj->setOfflineStatus(false);
                 $this->course_obj->setActivationType(IL_CRS_ACTIVATION_UNLIMITED);
             } elseif ($this->in_registration) {
                 $this->course_obj->setSubscriptionLimitationType(IL_CRS_SUBSCRIPTION_UNLIMITED);
             }
             break;
         case 'TemporarilyAvailable':
             if ($this->in_availability) {
                 $this->course_obj->setOfflineStatus(false);
                 $this->course_obj->setActivationType(IL_CRS_ACTIVATION_LIMITED);
             } elseif ($this->in_registration) {
                 $this->course_obj->setSubscriptionLimitationType(IL_CRS_SUBSCRIPTION_LIMITED);
             }
             break;
         case 'Start':
             break;
         case 'End':
             break;
         case 'Syllabus':
             break;
         case 'Contact':
             break;
         case 'Name':
         case 'Responsibility':
         case 'Phone':
         case 'Email':
         case 'Consultation':
             break;
         case 'Registration':
             $this->in_registration = true;
             switch ($a_attribs['registrationType']) {
                 case 'Confirmation':
                     $this->course_obj->setSubscriptionType(IL_CRS_SUBSCRIPTION_CONFIRMATION);
                     break;
                 case 'Direct':
                     $this->course_obj->setSubscriptionType(IL_CRS_SUBSCRIPTION_DIRECT);
                     break;
                 case 'Password':
                     $this->course_obj->setSubscriptionType(IL_CRS_SUBSCRIPTION_PASSWORD);
                     break;
             }
             $this->course_obj->setSubscriptionMaxMembers((int) $a_attribs['maxMembers']);
             $this->course_obj->setSubscriptionNotify($a_attribs['notification'] == 'Yes' ? true : false);
             $this->course_obj->enableWaitingList($a_attribs['waitingList'] == 'Yes' ? true : false);
             break;
         case 'Sort':
             switch ($a_attribs['type']) {
                 case 'Manual':
                     $this->course_obj->setOrderType(ilContainer::SORT_MANUAL);
                     break;
                 case 'Title':
                     $this->course_obj->setOrderType(ilContainer::SORT_TITLE);
                     break;
                 case 'Activation':
                     $this->course_obj->setOrderType(ilContainer::SORT_ACTIVATION);
                     break;
             }
             break;
         case 'Archive':
             $this->in_archive = true;
             switch ($a_attribs['Access']) {
                 case 'Disabled':
                     $this->course_obj->setArchiveType(IL_CRS_ARCHIVE_NONE);
                     break;
                 case 'Read':
                     $this->course_obj->setArchiveType(IL_CRS_ARCHIVE_NONE);
                     #$this->course_obj->setViewMode(IL_CRS_VIEW_ARCHIVE);
                     break;
                 case 'Download':
                     #$this->course_obj->setViewMode(IL_CRS_VIEW_ARCHIVE);
                     $this->course_obj->setArchiveType(IL_CRS_ARCHIVE_DOWNLOAD);
                     break;
             }
             break;
         case 'Disabled':
             $this->course_obj->setSubscriptionType(IL_CRS_SUBSCRIPTION_DEACTIVATED);
             break;
         case "MetaData":
             $this->in_meta_data = true;
             parent::handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
             break;
     }
 }
 /**
  * Import lm from directory
  *
  * @param
  * @return
  */
 function importFromDirectory($a_directory, $a_validate = true)
 {
     global $lng;
     // determine filename of xml file
     $subdir = basename($a_directory);
     $xml_file = $a_directory . "/" . $subdir . ".xml";
     // check directory exists within zip file
     if (!is_dir($a_directory)) {
         return sprintf($lng->txt("cont_no_subdir_in_zip"), $subdir);
     }
     // check whether xml file exists within zip file
     if (!is_file($xml_file)) {
         return sprintf($lng->txt("cont_zip_file_invalid"), $subdir . "/" . $subdir . ".xml");
     }
     // import questions
     $qti_file = $a_directory . "/qti.xml";
     $qtis = array();
     if (is_file($qti_file)) {
         include_once "./Services/QTI/classes/class.ilQTIParser.php";
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
         $result = $qtiParser->startParsing();
         $founditems =& $qtiParser->getFoundItems();
         $testObj = new ilObjTest(0, true);
         if (count($founditems) > 0) {
             $qtiParser = new ilQTIParser($qti_file, IL_MO_PARSE_QTI, 0, "");
             $qtiParser->setTestObject($testObj);
             $result = $qtiParser->startParsing();
             $qtis = array_merge($qtis, $qtiParser->getImportMapping());
         }
     }
     include_once "./Modules/LearningModule/classes/class.ilContObjParser.php";
     $contParser = new ilContObjParser($this, $xml_file, $subdir, $qmapping);
     $contParser->setQuestionMapping($qtis);
     $contParser->startParsing();
     ilObject::_writeImportId($this->getId(), $this->getImportId());
     $this->MDUpdateListener('General');
     // import style
     $style_file = $a_directory . "/style.xml";
     $style_zip_file = $a_directory . "/style.zip";
     if (is_file($style_zip_file)) {
         require_once "./Services/Style/classes/class.ilObjStyleSheet.php";
         $style = new ilObjStyleSheet();
         $style->import($style_zip_file);
         $this->writeStyleSheetId($style->getId());
     } else {
         if (is_file($style_file)) {
             require_once "./Services/Style/classes/class.ilObjStyleSheet.php";
             $style = new ilObjStyleSheet();
             $style->import($style_file);
             $this->writeStyleSheetId($style->getId());
         }
     }
     //		// validate
     if ($a_validate) {
         $mess = $this->validatePages();
     }
     if ($mess == "") {
         // handle internal links to this learning module
         include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
         ilLMPage::_handleImportRepositoryLinks($this->getImportId(), $this->getType(), $this->getRefId());
     }
     return $mess;
 }
Ejemplo n.º 4
0
 final function _writeImportId($a_obj_id, $a_import_id)
 {
     return parent::_writeImportId($a_obj_id, $a_import_id);
 }
 /**
  * create new user
  *
  * @access protected
  */
 protected function createUser(ilECSUser $user)
 {
     global $ilClientIniFile, $ilSetting, $rbacadmin, $ilLog;
     $userObj = new ilObjUser();
     include_once './Services/Authentication/classes/class.ilAuthUtils.php';
     $local_user = ilAuthUtils::_generateLogin($this->getAbreviation() . '_' . $user->getLogin());
     $newUser["login"] = $local_user;
     $newUser["firstname"] = $user->getFirstname();
     $newUser["lastname"] = $user->getLastname();
     $newUser['email'] = $user->getEmail();
     $newUser['institution'] = $user->getInstitution();
     // set "plain md5" password (= no valid password)
     $newUser["passwd"] = "";
     $newUser["passwd_type"] = IL_PASSWD_MD5;
     $newUser["auth_mode"] = "ecs";
     $newUser["profile_incomplete"] = 0;
     // system data
     $userObj->assignData($newUser);
     $userObj->setTitle($userObj->getFullname());
     $userObj->setDescription($userObj->getEmail());
     // set user language to system language
     $userObj->setLanguage($ilSetting->get("language"));
     // Time limit
     $userObj->setTimeLimitOwner(7);
     $userObj->setTimeLimitUnlimited(0);
     $userObj->setTimeLimitFrom(time() - 5);
     $userObj->setTimeLimitUntil(time() + $ilClientIniFile->readVariable("session", "expire"));
     $now = new ilDateTime(time(), IL_CAL_UNIX);
     $userObj->setAgreeDate($now->get(IL_CAL_DATETIME));
     // Create user in DB
     $userObj->setOwner(6);
     $userObj->create();
     $userObj->setActive(1);
     $userObj->updateOwner();
     $userObj->saveAsNew();
     $userObj->writePrefs();
     if ($global_role = $this->getCurrentServer()->getGlobalRole()) {
         $rbacadmin->assignUser($this->getCurrentServer()->getGlobalRole(), $userObj->getId(), true);
     }
     ilObject::_writeImportId($userObj->getId(), $user->getImportId());
     $ilLog->write(__METHOD__ . ': Created new remote user with usr_id: ' . $user->getImportId());
     // Send Mail
     #$this->sendNotification($userObj);
     return $userObj->getLogin();
 }
Ejemplo n.º 6
0
 /**
  * display status information or report errors messages
  * in case of error
  *
  * @access	public
  */
 function importFileObject()
 {
     $new_type = $_REQUEST["new_type"];
     // create permission is already checked in createObject. This check here is done to prevent hacking attempts
     if (!$this->checkPermissionBool("create", "", $new_type)) {
         $ilErr->raiseError($this->lng->txt("no_create_permission"));
     }
     $this->lng->loadLanguageModule($new_type);
     $this->ctrl->setParameter($this, "new_type", $new_type);
     $form = $this->initImportForm($new_type);
     if ($form->checkInput()) {
         $this->ctrl->setParameter($this, "new_type", "");
         $upload = $_FILES["importfile"];
         // create and insert object in objecttree
         include_once "./Modules/Glossary/classes/class.ilObjGlossary.php";
         $newObj = new ilObjGlossary();
         $newObj->setType($new_type);
         $newObj->setTitle($upload["name"]);
         $newObj->create(true);
         $this->putObjectInTree($newObj);
         // create import directory
         $newObj->createImportDirectory();
         // copy uploaded file to import directory
         $file = pathinfo($upload["name"]);
         $full_path = $newObj->getImportDirectory() . "/" . $upload["name"];
         ilUtil::moveUploadedFile($upload["tmp_name"], $upload["name"], $full_path);
         // unzip file
         ilUtil::unzip($full_path);
         // determine filename of xml file
         $subdir = basename($file["basename"], "." . $file["extension"]);
         $xml_file = $newObj->getImportDirectory() . "/" . $subdir . "/" . $subdir . ".xml";
         // check whether this is a new export file.
         // this is the case if manifest.xml exits
         //echo "1-".$newObj->getImportDirectory()."/".$subdir."/manifest.xml"."-";
         if (is_file($newObj->getImportDirectory() . "/" . $subdir . "/manifest.xml")) {
             include_once "./Services/Export/classes/class.ilImport.php";
             $imp = new ilImport((int) $_GET["ref_id"]);
             $map = $imp->getMapping();
             $map->addMapping("Modules/Glossary", "glo", "new_id", $newObj->getId());
             $imp->importObject($newObj, $full_path, $upload["name"], "glo", "Modules/Glossary", true);
             ilUtil::sendSuccess($this->lng->txt("glo_added"), true);
             ilUtil::redirect("ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=" . $newObj->getRefId());
         }
         // check whether subdirectory exists within zip file
         if (!is_dir($newObj->getImportDirectory() . "/" . $subdir)) {
             $this->ilias->raiseError(sprintf($this->lng->txt("cont_no_subdir_in_zip"), $subdir), $this->ilias->error_obj->MESSAGE);
         }
         // check whether xml file exists within zip file
         if (!is_file($xml_file)) {
             $this->ilias->raiseError(sprintf($this->lng->txt("cont_zip_file_invalid"), $subdir . "/" . $subdir . ".xml"), $this->ilias->error_obj->MESSAGE);
         }
         include_once "./Modules/LearningModule/classes/class.ilContObjParser.php";
         $contParser = new ilContObjParser($newObj, $xml_file, $subdir);
         $contParser->startParsing();
         ilObject::_writeImportId($newObj->getId(), $newObj->getImportId());
         // delete import directory
         ilUtil::delDir($newObj->getImportDirectory());
         ilUtil::sendSuccess($this->lng->txt("glo_added"), true);
         ilUtil::redirect("ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=" . $newObj->getRefId());
     }
     // display form to correct errors
     $form->setValuesByPost();
     $tpl->setContent($form->getHtml());
 }