/**
  * Add an item to the stack. If ref_id is already used,
  * the item is moved to the top.
  */
 public function addItem($a_ref_id, $a_link, $a_type, $a_title = "", $a_sub_obj_id = "", $a_goto_link = "")
 {
     global $ilUser, $ilDB;
     // never store?
     if ($ilUser->prefs["store_last_visited"] == 2) {
         return;
     }
     $a_sub_obj_id = $a_sub_obj_id . "";
     if ($a_title == "" && $a_ref_id > 0) {
         $obj_id = ilObject::_lookupObjId($a_ref_id);
         if (ilObject::_exists($obj_id)) {
             $a_title = ilObject::_lookupTitle($obj_id);
         }
     }
     $id = $a_ref_id . ":" . $a_sub_obj_id;
     $new_items[$id] = array("id" => $id, "ref_id" => $a_ref_id, "link" => $a_link, "title" => $a_title, "type" => $a_type, "sub_obj_id" => $a_sub_obj_id, "goto_link" => $a_goto_link);
     $cnt = 1;
     foreach ($this->items as $key => $item) {
         if ($item["id"] != $id && $cnt <= 10) {
             $new_items[$item["id"]] = $item;
             $cnt++;
         }
     }
     // put items in session
     $this->items = $new_items;
     $items = serialize($this->items);
     $_SESSION["il_nav_history"] = $items;
     //var_dump($this->getItems());
     // only store in session?
     if ($ilUser->prefs["store_last_visited"] == 1) {
         return;
     }
     // update entries in db
     $ilDB->update("usr_data", array("last_visited" => array("clob", serialize($this->getItems()))), array("usr_id" => array("integer", $ilUser->getId())));
 }
 /**
  * Standard Version of Fill Row. Most likely to
  * be overwritten by derived class.
  */
 protected function fillRow($a_set)
 {
     global $lng, $ilCtrl, $ilAccess;
     // rollback command
     if ($a_set["nr"] > 0) {
         $ilCtrl->setParameter($this->getParentObject(), "old_nr", $a_set["nr"]);
         $this->tpl->setCurrentBlock("command");
         $this->tpl->setVariable("TXT_COMMAND", $lng->txt("cont_rollback"));
         $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTarget($this->getParentObject(), "rollbackConfirmation"));
         $this->tpl->parseCurrentBlock();
         $ilCtrl->setParameter($this->getParentObject(), "old_nr", "");
     }
     if (!$this->rselect) {
         $this->tpl->setVariable("RSELECT", 'checked="checked"');
         $this->rselect = true;
     } else {
         if (!$this->lselect) {
             $this->tpl->setVariable("LSELECT", 'checked="checked"');
             $this->lselect = true;
         }
     }
     $this->tpl->setVariable("NR", $a_set["nr"]);
     $this->tpl->setVariable("TXT_HDATE", ilDatePresentation::formatDate(new ilDateTime($a_set["hdate"], IL_CAL_DATETIME)));
     $ilCtrl->setParameter($this->getParentObject(), "old_nr", $a_set["nr"]);
     $ilCtrl->setParameter($this->getParentObject(), "history_mode", "1");
     $this->tpl->setVariable("HREF_OLD_PAGE", $ilCtrl->getLinkTarget($this->getParentObject(), "preview"));
     $ilCtrl->setParameter($this->getParentObject(), "history_mode", "");
     if (ilObject::_exists($a_set["user"])) {
         // user name
         $user = ilObjUser::_lookupName($a_set["user"]);
         $login = ilObjUser::_lookupLogin($a_set["user"]);
         //$this->tpl->setVariable("TXT_LINKED_USER",
         //	$user["lastname"].", ".$user["firstname"]." [".$login."]");
         // profile link
         include_once "./Services/User/classes/class.ilUserUtil.php";
         $name_pres = ilUserUtil::getNamePresentation($a_set["user"], true, true, $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCmd()));
         //$ilCtrl->setParameterByClass("ilpublicuserprofilegui", "user", $a_set["user"]);
         //$ilCtrl->setParameterByClass("ilpublicuserprofilegui", "back_url",
         //	rawurlencode($ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCmd())));
         //$this->tpl->setVariable("USER_LINK",
         //	$ilCtrl->getLinkTargetByClass("ilpublicuserprofilegui", "getHTML"));
         //$img = ilObjUser::_getPersonalPicturePath($a_set["user"], "xxsmall");
         //$this->tpl->setVariable("IMG_USER", $img);
         $this->tpl->setVariable("TXT_USER", $name_pres);
     }
     $ilCtrl->setParameter($this->getParentObject(), "old_nr", "");
 }
 function userDataArrayForExport($user, $b_allowExportPrivacy = false)
 {
     $userArray = array();
     if ($b_allowExportPrivacy == false) {
         $userArray["user"] = $user;
     } else {
         global $ilUser;
         $userArray["login"] = "";
         $userArray["user"] = "";
         $userArray["email"] = "";
         $userArray["department"] = "";
         if (ilObject::_exists($user) && ilObject::_lookUpType($user) == 'usr') {
             $e_user = new ilObjUser($user);
             $userArray["login"] = $e_user->getLogin();
             $userArray["user"] = $e_user->getLastname() . ', ' . $e_user->getFirstname();
             $userArray["email"] = "" . $e_user->getEmail();
             $userArray["department"] = "" . $e_user->getDepartment();
         }
     }
     return $userArray;
 }
示例#4
0
 public function testCreationDeletion()
 {
     $obj = new ilObject();
     $obj->setType("xxx");
     $obj->create();
     $id = $obj->getId();
     $obj2 = new ilObject();
     $obj2->setType("xxx");
     $obj2->create();
     $id2 = $obj2->getId();
     if ($id2 == $id + 1) {
         $value .= "create1-";
     }
     if (ilObject::_exists($id)) {
         $value .= "create2-";
     }
     $obj->delete();
     $obj2->delete();
     if (!ilObject::_exists($id)) {
         $value .= "create3-";
     }
     $this->assertEquals("create1-create2-create3-", $value);
 }
 public function parse($userSelected, $report, $reports)
 {
     global $ilCtrl, $lng;
     $lng->loadLanguageModule("scormtrac");
     $this->form = new ilPropertyFormGUI();
     $this->form->setFormAction($ilCtrl->getFormAction($this->parent_obj));
     $options = array("all" => $lng->txt("all"));
     include_once "Services/Tracking/classes/class.ilTrQuery.php";
     $users = ilTrQuery::getParticipantsForObject($this->parent_obj->object->ref_id);
     include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
     $privacy = ilPrivacySettings::_getInstance();
     $allowExportPrivacy = $privacy->enabledExportSCORM();
     //$users = $this->parent_obj->object->getTrackedUsers("");
     foreach ($users as $user) {
         if (ilObject::_exists($user) && ilObject::_lookUpType($user) == 'usr') {
             if ($allowExportPrivacy == true) {
                 $e_user = new ilObjUser($user);
                 $options[$user] = $e_user->getLastname() . ", " . $e_user->getFirstname();
             } else {
                 $options[$user] = 'User Id: ' . $user;
             }
         }
     }
     $si = new ilSelectInputGUI($lng->txt("user"), "userSelected");
     $si->setOptions($options);
     $si->setValue($userSelected);
     $this->form->addItem($si);
     $options = array("choose" => $lng->txt("please_choose"));
     for ($i = 0; $i < count($reports); $i++) {
         $options[$reports[$i]] = $lng->txt(strtolower($reports[$i]));
     }
     $si = new ilSelectInputGUI($lng->txt("report"), "report");
     $si->setOptions($options);
     $si->setValue($report);
     $this->form->addItem($si);
     $this->form->addCommandButton($this->parent_cmd, $lng->txt("apply_filter"));
 }
示例#6
0
 /**
  * Delete news item
  *
  */
 public function delete()
 {
     global $ilDB;
     // delete il_news_read entries
     $ilDB->manipulate("DELETE FROM il_news_read " . " WHERE news_id = " . $ilDB->quote($this->getId(), "integer"));
     // delete multimedia object
     $mob = $this->getMobId();
     // delete
     parent::delete();
     // delete mob after news, to have a "mob usage" of 0
     if ($mob > 0 and ilObject::_exists($mob)) {
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         $mob = new ilObjMediaObject($mob);
         $mob->delete();
     }
 }
示例#7
0
 public static final function _exists($a_id, $a_reference = false)
 {
     return parent::_exists($a_id, $a_reference);
 }
示例#8
0
 /**
  * Download all submitted files (of all members).
  */
 function downloadAllObject()
 {
     $this->checkPermission("write");
     $members = array();
     foreach ($this->object->members_obj->getMembers() as $member_id) {
         // update download time
         ilExAssignment::updateTutorDownloadTime($this->object->getId(), (int) $_GET["ass_id"], $member_id);
         // get member object (ilObjUser)
         if (ilObject::_exists($member_id)) {
             $tmp_obj =& ilObjectFactory::getInstanceByObjId($member_id);
             $members[$member_id] = $tmp_obj->getFirstname() . " " . $tmp_obj->getLastname();
             unset($tmp_obj);
         }
     }
     ilExAssignment::downloadAllDeliveredFiles($this->object->getId(), (int) $_GET["ass_id"], $members);
     exit;
 }
 /**
  * Get User List HTML (to be displayed besides the map)
  */
 function getUserListHtml()
 {
     $list_tpl = new ilTemplate("tpl.openlayers_map_user_list.html", true, true, "Services/Maps");
     $cnt = 0;
     foreach ($this->user_marker as $user_id) {
         if (ilObject::_exists($user_id)) {
             $user = new ilObjUser($user_id);
             $this->css_row = $this->css_row != "tblrow1_mo" ? "tblrow1_mo" : "tblrow2_mo";
             if ($user->getLatitude() != 0 && $user->getLongitude() != 0 && $user->getPref("public_location") == "y") {
                 $list_tpl->setCurrentBlock("item");
                 $list_tpl->setVariable("MARKER_CNT", $cnt);
                 $list_tpl->setVariable("MAP_ID", $this->getMapId());
                 $cnt++;
             } else {
                 $list_tpl->setCurrentBlock("item_no_link");
             }
             $list_tpl->setVariable("CSS_ROW", $this->css_row);
             $list_tpl->setVariable("TXT_USER", $user->getLogin());
             $list_tpl->setVariable("IMG_USER", $user->getPersonalPicturePath("xxsmall"));
             $list_tpl->parseCurrentBlock();
             $list_tpl->touchBlock("row");
         }
     }
     return $list_tpl->get();
 }
示例#10
0
 /**
  * Before page is being deleted
  *
  * @param object $a_page page object
  */
 static function beforePageDelete($a_page)
 {
     $files = self::collectFileItems($a_page, $a_page->getDomDoc());
     // delete all file usages
     include_once "./Modules/File/classes/class.ilObjFile.php";
     ilObjFile::_deleteAllUsages($a_page->getParentType() . ":pg", $a_page->getId(), false, $a_page->getLanguage());
     include_once "./Modules/File/classes/class.ilObjFile.php";
     foreach ($files as $file_id) {
         if (ilObject::_exists($file_id)) {
             $file_obj = new ilObjFile($file_id, false);
             $file_obj->delete();
         }
     }
 }
 /**
  * get member list data
  */
 function getMemberListData($a_eph_id, $a_ass_id)
 {
     global $ilDB;
     $mem = array();
     // first get list of members from member table
     $set = $ilDB->query("SELECT * FROM rep_robj_xeph_members " . "WHERE obj_id = " . $ilDB->quote($a_eph_id, "integer"));
     while ($rec = $ilDB->fetchAssoc($set)) {
         if (ilObject::_exists($rec["user_id"]) && ilObject::_lookupType($rec["user_id"]) == "usr") {
             $name = ilObjUser::_lookupName($rec["user_id"]);
             $login = ilObjUser::_lookupLogin($rec["user_id"]);
             $mem[$rec["user_id"]] = array("name" => $name["lastname"] . ", " . $name["firstname"], "login" => $login, "user_id" => $rec["user_id"], "lastname" => $name["lastname"], "firstname" => $name["firstname"]);
         }
     }
     $q = "SELECT * FROM rep_robj_xeph_ass_stat " . "WHERE ass_id = " . $ilDB->quote($a_ass_id, "integer");
     $set = $ilDB->query($q);
     while ($rec = $ilDB->fetchAssoc($set)) {
         if (isset($mem[$rec["user_id"]])) {
             $mem[$rec["user_id"]]["sent_time"] = $rec["sent_time"];
             $mem[$rec["user_id"]]["submission"] = ilEphAssignment::getLastSubmission($a_ass_id, $rec["user_id"]);
             $mem[$rec["user_id"]]["status_time"] = $rec["status_time"];
             $mem[$rec["user_id"]]["feedback_time"] = $rec["feedback_time"];
             $mem[$rec["user_id"]]["notice"] = $rec["notice"];
             $mem[$rec["user_id"]]["status"] = $rec["status"];
         }
     }
     return $mem;
 }
 /**
  * Create resource entries for the learning module "PKG" and all SCOS and Assets
  */
 function writeResources()
 {
     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Tree.php";
     $tree = new ilSCORM2004Tree($this->cont_obj->getId());
     //$tree = new ilTree($this->cont_obj->getId());
     //$tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
     //$tree->setTreeTablePK("slm_id");
     foreach ($tree->getSubTree($tree->getNodeData($tree->root_id), true, array('sco', 'ass')) as $obj) {
         $attrs = array();
         $attrs["identifier"] = "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . "_ref";
         $attrs["type"] = "webcontent";
         if ($obj['type'] == "sco") {
             $attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "sco";
         } else {
             $attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "asset";
         }
         $attrs["href"] = "./" . $obj['obj_id'] . "/index.html";
         $this->writer->xmlStartTag("resource", $attrs, "");
         $this->writer->xmlElement("dependency", array("identifierref" => "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'ITSELF'), "");
         $this->writer->xmlElement("dependency", array("identifierref" => "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'OBJECTS'), "");
         $this->writer->xmlElement("dependency", array("identifierref" => "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'RESOURCES'), "");
         $this->writer->xmlElement("dependency", array("identifierref" => "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'FLAVOUR'), "");
         $this->writer->xmlEndTag("resource");
         $attrs = array();
         $attrs["identifier"] = "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'ITSELF';
         $attrs["type"] = "webcontent";
         $attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "asset";
         $this->writer->xmlStartTag("resource", $attrs, "");
         $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/index.xml"), "");
         $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/ilias_co_3_7.dtd"), "");
         $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/index.html"), "");
         $this->writer->xmlEndTag("resource");
         $attrs = array();
         $attrs["identifier"] = "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'RESOURCES';
         $attrs["type"] = "webcontent";
         $attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "asset";
         $this->writer->xmlStartTag("resource", $attrs, "");
         $this->writer->xmlEndTag("resource");
         $attrs = array();
         $attrs["identifier"] = "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'FLAVOUR';
         $attrs["type"] = "webcontent";
         $attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "asset";
         $this->writer->xmlStartTag("resource", $attrs, "");
         $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/index.xml"), "");
         $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/sco.xsl"), "");
         $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/css/system.css"), "");
         $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/css/style.css"), "");
         $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/js/scorm.js"), "");
         $this->writer->xmlEndTag("resource");
         $attrs = array();
         $attrs["identifier"] = "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'OBJECTS';
         $attrs["type"] = "webcontent";
         $attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "asset";
         $this->writer->xmlStartTag("resource", $attrs, "");
         include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
         $active_css = ilObjStyleSheet::getContentStylePath($this->cont_obj->getStyleSheetId());
         $active_css = split(@'\\?', $active_css, 2);
         $css = fread(fopen($active_css[0], 'r'), filesize($active_css[0]));
         preg_match_all("/url\\(([^\\)]*)\\)/", $css, $css_files);
         $css_files = array_unique($css_files[1]);
         $currdir = getcwd();
         chdir(dirname($active_css[0]));
         foreach ($css_files as $fileref) {
             if (file_exists($fileref)) {
                 $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/images/" . basename($fileref)), "");
             }
         }
         chdir($currdir);
         include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Tree.php";
         $pagetree = new ilSCORM2004Tree($this->cont_obj->getId());
         //$pagetree = new ilTree($this->cont_obj->getId());
         //$pagetree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
         //$pagetree->setTreeTablePK("slm_id");
         foreach ($pagetree->getSubTree($pagetree->getNodeData($obj['obj_id']), false, 'page') as $page) {
             $page_obj = new ilSCORM2004Page($page);
             $page_obj->buildDom();
             $mob_ids = $page_obj->collectMediaObjects(false);
             foreach ($mob_ids as $mob_id) {
                 if ($mob_id > 0 && ilObject::_exists($mob_id)) {
                     $media_obj = new ilObjMediaObject($mob_id);
                     $media_obj = $media_obj->getMediaItem("Standard");
                     if ($media_obj != null && $media_obj->getLocationType() == "LocalFile") {
                         $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/objects/il_" . IL_INST_ID . "_mob_" . $mob_id . "/" . rawurlencode($media_obj->getLocation())), "");
                     }
                 }
             }
             $file_ids = $page_obj->collectFileItems();
             foreach ($file_ids as $file_id) {
                 if (ilObject::_lookupType($file_id) == "file") {
                     $file_obj = new ilObjFile($file_id, false);
                     $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/objects/il_" . IL_INST_ID . "_file_" . $file_id . "/" . rawurlencode($file_obj->filename)), "");
                 }
             }
             unset($page_obj);
         }
         $this->writer->xmlEndTag("resource");
     }
     if ($this->version == "2004") {
         $attrs = array();
         $attrs["identifier"] = "PKG";
         $attrs["type"] = "webcontent";
         $attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "asset";
         $this->writer->xmlStartTag("resource", $attrs, "");
         $xsd_files = array('adlcp_v1p3.xsd', 'adlseq_v1p3.xsd', 'imsss_v1p0.xsd', 'adlnav_v1p3.xsd', 'adlnav_v1p3.xsd', 'imscp_v1p1.xsd', 'imsmanifest.xml', 'imsss_v1p0auxresource.xsd', 'imsss_v1p0control.xsd', 'imsss_v1p0delivery.xsd', 'imsss_v1p0limit.xsd', 'imsss_v1p0objective.xsd', 'imsss_v1p0random.xsd', 'imsss_v1p0rollup.xsd', 'imsss_v1p0seqrule.xsd', 'imsss_v1p0util.xsd', 'xml.xsd', 'index.html');
         foreach ($xsd_files as $xsd_file) {
             $attrs = array();
             $attrs["href"] = $xsd_file;
             $this->writer->xmlElement("file", $attrs, "");
         }
         $this->writer->xmlEndTag("resource");
     }
 }
 function addObject($sid, $a_target_id, $a_xml)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     if (!strlen($a_xml)) {
         return $this->__raiseError('No valid xml string given.', 'Client');
     }
     global $rbacsystem, $objDefinition, $ilUser, $lng, $ilObjDataCache;
     if (!($target_obj =& ilObjectFactory::getInstanceByRefId($a_target_id, false))) {
         return $this->__raiseError('No valid target given.', 'Client');
     }
     if (ilObject::_isInTrash($a_target_id)) {
         return $this->__raiseError("Parent with ID {$a_target_id} has been deleted.", 'Client');
     }
     $allowed_types = array('root', 'cat', 'grp', 'crs', 'fold');
     if (!in_array($target_obj->getType(), $allowed_types)) {
         return $this->__raiseError('No valid target type. Target must be reference id of "course, group, category or folder"', 'Client');
     }
     $allowed_subtypes = $objDefinition->getSubObjects($target_obj->getType());
     foreach ($allowed_subtypes as $row) {
         if ($row['name'] != 'rolf') {
             $allowed[] = $row['name'];
         }
     }
     include_once './webservice/soap/classes/class.ilObjectXMLParser.php';
     $xml_parser =& new ilObjectXMLParser($a_xml, true);
     try {
         $xml_parser->startParsing();
     } catch (ilSaxParserException $se) {
         return $this->__raiseError($se->getMessage(), 'Client');
     } catch (ilObjectXMLException $e) {
         return $this->__raiseError($e->getMessage(), 'Client');
     }
     foreach ($xml_parser->getObjectData() as $object_data) {
         $res = $this->validateReferences('create', $object_data, $a_target_id);
         if ($this->isFault($res)) {
             return $res;
         }
         // Check possible subtype
         if (!in_array($object_data['type'], $allowed)) {
             return $this->__raiseError('Objects of type: ' . $object_data['type'] . ' are not allowed to be subobjects of type ' . $target_obj->getType() . '!', 'Client');
         }
         if (!$rbacsystem->checkAccess('create', $a_target_id, $object_data['type'])) {
             return $this->__raiseError('No permission to create objects of type ' . $object_data['type'] . '!', 'Client');
         }
         // begin-patch fm
         /*
         if($object_data['type'] == 'crs')
         {
         	return $this->__raiseError('Cannot create course objects. Use method addCourse() ',
         							   'Client');
         }
         */
         // end-patch fm
         // It's not possible to add objects with non unique import ids
         if (strlen($object_data['import_id']) and ilObject::_lookupObjIdByImportId($object_data['import_id'])) {
             return $this->__raiseError('An object with import id ' . $object_data['import_id'] . ' already exists!', 'Server');
         }
         // call gui object method
         $class_name = $objDefinition->getClassName($object_data['type']);
         $location = $objDefinition->getLocation($object_data['type']);
         $class_constr = "ilObj" . $class_name;
         require_once $location . "/class.ilObj" . $class_name . ".php";
         $newObj = new $class_constr();
         if (isset($object_data['owner']) && strlen($object_data['owner'])) {
             if ((int) $object_data['owner']) {
                 if (ilObject::_exists((int) $object_data['owner']) && $ilObjDataCache->lookupType((int) $object_data['owner']) == 'usr') {
                     $newObj->setOwner((int) $object_data['owner']);
                 }
             } else {
                 $usr_id = ilObjUser::_lookupId(trim($object_data['owner']));
                 if ((int) $usr_id) {
                     $newObj->setOwner((int) $usr_id);
                 }
             }
         }
         $newObj->setType($object_data['type']);
         if (strlen($object_data['import_id'])) {
             $newObj->setImportId($object_data['import_id']);
         }
         $newObj->setTitle($object_data['title']);
         $newObj->setDescription($object_data['description']);
         $newObj->create();
         // true for upload
         $newObj->createReference();
         $newObj->putInTree($a_target_id);
         $newObj->setPermissions($a_target_id);
         switch ($object_data['type']) {
             case 'grp':
                 // Add member
                 $newObj->addMember($object_data['owner'] ? $object_data['owner'] : $ilUser->getId(), $newObj->getDefaultAdminRole());
                 break;
                 // begin-patch fm
             // begin-patch fm
             case 'crs':
                 $newObj->getMemberObject()->add($ilUser->getId(), IL_CRS_ADMIN);
                 break;
                 // end-patch fm
             // end-patch fm
             case 'lm':
             case 'dbk':
                 $newObj->createLMTree();
                 break;
             case 'cat':
                 $newObj->addTranslation($object_data["title"], $object_data["description"], $lng->getLangKey(), $lng->getLangKey());
                 break;
         }
         $this->addReferences($newObj, $object_data);
     }
     $ref_id = $newObj->getRefId();
     return $ref_id ? $ref_id : "0";
 }
 /**
  * lookup owner name for owner id
  */
 function _lookupOwnerName($a_owner_id)
 {
     global $lng;
     if ($a_owner_id != -1) {
         if (ilObject::_exists($a_owner_id)) {
             $owner = new ilObjUser($a_owner_id);
         }
     }
     if (is_object($owner)) {
         $own_name = $owner->getFullname();
     } else {
         $own_name = $lng->txt("unknown");
     }
     return $own_name;
 }
 /**
  * get groups which belong to a specific user, fullilling the status
  *
  * @param string $sid
  * @param string $parameters following xmlresultset, columns (user_id, status with values  1 = "MEMBER", 2 = "TUTOR", 4 = "ADMIN", 8 = "OWNER" and any xor operation e.g.  1 + 4 = 5 = ADMIN and TUTOR, 7 = ADMIN and TUTOR and MEMBER)
  * @param string XMLResultSet, columns (ref_id, xml, parent_ref_id) 
  */
 function getGroupsForUser($sid, $parameters)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     global $rbacreview, $ilObjDataCache, $tree;
     include_once 'webservice/soap/classes/class.ilXMLResultSetParser.php';
     $parser = new ilXMLResultSetParser($parameters);
     try {
         $parser->startParsing();
     } catch (ilSaxParserException $exception) {
         return $this->__raiseError($exception->getMessage(), "Client");
     }
     $xmlResultSet = $parser->getXMLResultSet();
     if (!$xmlResultSet->hasColumn("user_id")) {
         return $this->__raiseError("parameter user_id is missing", "Client");
     }
     if (!$xmlResultSet->hasColumn("status")) {
         return $this->__raiseError("parameter status is missing", "Client");
     }
     $user_id = (int) $xmlResultSet->getValue(0, "user_id");
     $status = (int) $xmlResultSet->getValue(0, "status");
     $ref_ids = array();
     // get roles
     #var_dump($xmlResultSet);
     #echo "uid:".$user_id;
     #echo "status:".$status;
     if (ilSoapGroupAdministration::MEMBER == ($status & ilSoapGroupAdministration::MEMBER) || ilSoapGroupAdministration::ADMIN == ($status & ilSoapGroupAdministration::ADMIN)) {
         foreach ($rbacreview->assignedRoles($user_id) as $role_id) {
             if ($role = ilObjectFactory::getInstanceByObjId($role_id, false)) {
                 #echo $role->getType();
                 if ($role->getType() != "role") {
                     continue;
                 }
                 if ($role->getParent() == ROLE_FOLDER_ID) {
                     continue;
                 }
                 $role_title = $role->getTitle();
                 if ($ref_id = ilUtil::__extractRefId($role_title)) {
                     if (!ilObject::_exists($ref_id, true) || ilObject::_isInTrash($ref_id)) {
                         continue;
                     }
                     #echo $role_title;
                     if (ilSoapGroupAdministration::MEMBER == ($status & ilSoapGroupAdministration::MEMBER) && strpos($role_title, "member") !== false) {
                         $ref_ids[] = $ref_id;
                     } elseif (ilSoapGroupAdministration::ADMIN == ($status & ilSoapGroupAdministration::ADMIN) && strpos($role_title, "admin") !== false) {
                         $ref_ids[] = $ref_id;
                     }
                 }
             }
         }
     }
     if (($status & ilSoapGroupAdministration::OWNER) == ilSoapGroupAdministration::OWNER) {
         $owned_objects = ilObjectFactory::getObjectsForOwner("grp", $user_id);
         foreach ($owned_objects as $obj_id) {
             $allrefs = ilObject::_getAllReferences($obj_id);
             $refs = array();
             foreach ($allrefs as $r) {
                 if ($tree->isDeleted($r)) {
                     continue;
                 }
                 if ($tree->isInTree($r)) {
                     $refs[] = $r;
                 }
             }
             if (count($refs) > 0) {
                 $ref_ids[] = array_pop($refs);
             }
         }
     }
     $ref_ids = array_unique($ref_ids);
     #print_r($ref_ids);
     include_once 'webservice/soap/classes/class.ilXMLResultSetWriter.php';
     include_once 'Modules/Group/classes/class.ilObjGroup.php';
     include_once 'Modules/Group/classes/class.ilGroupXMLWriter.php';
     $xmlResultSet = new ilXMLResultSet();
     $xmlResultSet->addColumn("ref_id");
     $xmlResultSet->addColumn("xml");
     $xmlResultSet->addColumn("parent_ref_id");
     foreach ($ref_ids as $group_id) {
         $group_obj = $this->checkObjectAccess($group_id, "grp", "write", true);
         if ($group_obj instanceof ilObjGroup) {
             $row = new ilXMLResultSetRow();
             $row->setValue("ref_id", $group_id);
             $xmlWriter = new ilGroupXMLWriter($group_obj);
             $xmlWriter->setAttachUsers(false);
             $xmlWriter->start();
             $row->setValue("xml", $xmlWriter->getXML());
             $row->setValue("parent_ref_id", $tree->getParentId($group_id));
             $xmlResultSet->addRow($row);
         }
     }
     $xmlResultSetWriter = new ilXMLResultSetWriter($xmlResultSet);
     $xmlResultSetWriter->start();
     return $xmlResultSetWriter->getXML();
 }
 function exportSelected($a_exportall = 0, $a_user = array())
 {
     global $ilDB, $ilUser;
     $scos = array();
     //get all SCO's of this object
     $query = 'SELECT cp_node.cp_node_id ' . 'FROM cp_node, cp_resource, cp_item ' . 'WHERE cp_item.cp_node_id = cp_node.cp_node_id ' . 'AND cp_item.resourceid = cp_resource.id AND scormtype = %s ' . 'AND nodename = %s	AND cp_node.slm_id = %s';
     $res = $ilDB->queryF($query, array('text', 'text', 'integer'), array('sco', 'item', $this->getId()));
     while ($row = $ilDB->fetchAssoc($res)) {
         $scos[] = $row['cp_node_id'];
     }
     $csv = null;
     //a module is completed when all SCO's are completed
     $user_array = array();
     if ($a_exportall == 1) {
         $query = 'SELECT user_id ' . 'FROM cmi_node, cp_node ' . 'WHERE cmi_node.cp_node_id = cp_node.cp_node_id AND cp_node.slm_id = %s ' . 'GROUP BY user_id';
         $res = $ilDB->queryF($query, array('integer'), array($this->getId()));
         while ($row = $ilDB->fetchAssoc($res)) {
             $user_array[] = $row['user_id'];
         }
     } else {
         $user_array = $a_user;
     }
     foreach ($user_array as $user) {
         $scos_c = $scos;
         //copy SCO_array
         //check if all SCO's are completed
         for ($i = 0; $i < count($scos); $i++) {
             $query = 'SELECT * FROM cmi_node ' . 'WHERE user_id = %s AND cp_node_id = %s ' . 'AND completion_status = %s OR success_status = %s';
             $res = $ilDB->queryF($query, array('integer', 'integer', 'text', 'text'), array($user, $scos[$i], 'completed', 'passed'));
             $data = $ilDB->fetchAssoc($res);
             if (is_array($data) && count($data)) {
                 //delete from array
                 $key = array_search($scos[$i], $scos_c);
                 unset($scos_c[$key]);
             }
         }
         //check for completion
         if (count($scos_c) == 0) {
             $completion = 1;
         } else {
             $completion = 0;
         }
         //write export entry
         if (ilObject::_exists($user) && ilObject::_lookUpType($user) == 'usr') {
             $e_user = new ilObjUser($user);
             $login = $e_user->getLogin();
             $firstname = $e_user->getFirstname();
             $lastname = $e_user->getLastname();
             $email = $e_user->getEmail();
             $department = $e_user->getDepartment();
             $query = 'SELECT user_id, MAX(c_timestamp) exp_date ' . 'FROM cmi_node, cp_node ' . 'WHERE cmi_node.cp_node_id = cp_node.cp_node_id ' . 'AND cp_node.slm_id = %s ' . 'GROUP BY user_id';
             $res = $ilDB->queryF($query, array('integer'), array($this->getId()));
             $data = $ilDB->fetchAssoc($res);
             if (is_array($data) && count($data)) {
                 $validDate = false;
                 $datetime = explode(' ', $data['exp_date']);
                 if (count($datetime) == 2) {
                     $date = explode('-', $datetime[0]);
                     if (count($date) == 3 && checkdate($date[1], $date[2], $date[0])) {
                         $validDate = true;
                     }
                 }
                 if ($validDate) {
                     $date = date('d.m.Y', strtotime($data['exp_date']));
                 } else {
                     $date = '';
                 }
             } else {
                 $date = '';
             }
             $csv = $csv . "{$department};{$login};{$lastname};{$firstname};{$email};{$date};{$completion}\n";
         }
     }
     $header = "Department;Login;Lastname;Firstname;Email;Date;Status\n";
     $this->sendExportFile($header, $csv);
 }
 /**
  * Before page is being deleted
  *
  * @param object $a_page page object
  */
 static function beforePageDelete($a_page)
 {
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $mob_ids = ilObjMediaObject::_getMobsOfObject($a_page->getParentType() . ":pg", $a_page->getId(), 0, $a_page->getLanguage());
     ilObjMediaObject::_deleteAllUsages($a_page->getParentType() . ":pg", $a_page->getId(), false, $a_page->getLanguage());
     foreach ($mob_ids as $mob) {
         if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob") {
             $mob_obj = new ilObjMediaObject($mob);
             $usages = $mob_obj->getUsages(false);
             if (count($usages) == 0) {
                 $mob_obj->delete();
             }
         }
     }
 }
 /**
  * Get all media objects linked in map areas of this media object
  */
 function getLinkedMediaObjects($a_ignore = "")
 {
     $linked = array();
     if (!is_array($a_ignore)) {
         $a_ignore = array();
     }
     // get linked media objects (map areas)
     $med_items = $this->getMediaItems();
     foreach ($med_items as $med_item) {
         $int_links = ilMapArea::_getIntLinks($med_item->getId());
         foreach ($int_links as $k => $int_link) {
             if ($int_link["Type"] == "MediaObject") {
                 include_once "./Services/COPage/classes/class.ilInternalLink.php";
                 $l_id = ilInternalLink::_extractObjIdOfTarget($int_link["Target"]);
                 if (ilObject::_exists($l_id)) {
                     if (!in_array($l_id, $linked) && !in_array($l_id, $a_ignore)) {
                         $linked[] = $l_id;
                     }
                 }
             }
         }
     }
     //var_dump($linked);
     return $linked;
 }
 /**
  * show news
  */
 function showNews()
 {
     global $lng, $ilCtrl, $ilUser;
     // workaround for dynamic mode (if cache is disabled, showNews has no data)
     if (empty(self::$st_data)) {
         $this->setData($this->getNewsData());
     }
     $news_set = new ilSetting("news");
     $enable_internal_rss = $news_set->get("enable_rss_for_internal");
     include_once "./Services/News/classes/class.ilNewsItem.php";
     $news = new ilNewsItem($_GET["news_id"]);
     $tpl = new ilTemplate("tpl.show_news.html", true, true, "Services/News");
     // get current item in data set
     $previous = $next = "";
     reset($this->data);
     $c = current($this->data);
     $curr_cnt = 1;
     while ($c["id"] > 0 && $c["id"] != $_GET["news_id"]) {
         $previous = $c;
         $c = next($this->data);
         $curr_cnt++;
     }
     // collect news items to show
     $news_list = array();
     if (is_array($c["aggregation"])) {
         //$agg_obj_id = ilObject::_lookupObjId($c["agg_ref_id"]);
         //$agg_obj_type = ilObject::_lookupType($agg_obj_id);
         //$agg_obj_title = ilObject::_lookupObjId($agg_obj_id);
         $news_list[] = array("ref_id" => $c["agg_ref_id"], "agg_ref_id" => $c["agg_ref_id"], "aggregation" => $c["aggregation"], "user_id" => "", "content_type" => "text", "mob_id" => 0, "visibility" => "", "content" => "", "content_long" => "", "update_date" => $news->getUpdateDate(), "creation_date" => "", "content_is_lang_var" => false, "loc_context" => $_GET["news_context"], "context_obj_type" => $news->getContextObjType(), "title" => "");
         foreach ($c["aggregation"] as $c_item) {
             ilNewsItem::_setRead($ilUser->getId(), $c_item["id"]);
             $c_item["loc_context"] = $c_item["ref_id"];
             $c_item["loc_stop"] = $_GET["news_context"];
             $news_list[] = $c_item;
         }
     } else {
         $news_list[] = array("ref_id" => $_GET["news_context"], "user_id" => $news->getUserId(), "content_type" => $news->getContentType(), "mob_id" => $news->getMobId(), "visibility" => $news->getVisibility(), "priority" => $news->getPriority(), "content" => $news->getContent(), "content_long" => $news->getContentLong(), "update_date" => $news->getUpdateDate(), "creation_date" => $news->getCreationDate(), "context_sub_obj_type" => $news->getContextSubObjType(), "context_obj_type" => $news->getContextObjType(), "context_sub_obj_id" => $news->getContextSubObjId(), "content_is_lang_var" => $news->getContentIsLangVar(), "content_text_is_lang_var" => $news->getContentTextIsLangVar(), "loc_context" => $_GET["news_context"], "title" => $news->getTitle());
         ilNewsItem::_setRead($ilUser->getId(), $_GET["news_id"]);
     }
     foreach ($news_list as $item) {
         // user
         if ($item["user_id"] > 0 && ilObject::_exists($item["user_id"])) {
             // get login
             if (ilObjUser::_exists($item["user_id"])) {
                 $user = new ilObjUser($item["user_id"]);
                 $displayname = $user->getLogin();
             } else {
                 // this should actually not happen, since news entries
                 // should be deleted when the user is going to be removed
                 $displayname = "&lt;" . strtolower($lng->txt("deleted")) . "&gt;";
             }
             $tpl->setCurrentBlock("user_info");
             $tpl->setVariable("VAL_AUTHOR", $displayname);
             $tpl->setVariable("TXT_AUTHOR", $lng->txt("author"));
             $tpl->parseCurrentBlock();
         }
         // media player
         if ($item["content_type"] == NEWS_AUDIO && $item["mob_id"] > 0 && ilObject::_exists($item["mob_id"])) {
             include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
             include_once "./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php";
             $mob = new ilObjMediaObject($item["mob_id"]);
             $med = $mob->getMediaItem("Standard");
             $mpl = new ilMediaPlayerGUI();
             if (strcasecmp("Reference", $med->getLocationType()) == 0) {
                 $mpl->setFile($med->getLocation());
             } else {
                 $mpl->setFile(ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation());
             }
             $mpl->setDisplayHeight($med->getHeight());
             $tpl->setCurrentBlock("player");
             $tpl->setVariable("PLAYER", $mpl->getMp3PlayerHtml());
             $tpl->parseCurrentBlock();
         }
         // access
         if ($enable_internal_rss && $item["visibility"] != "") {
             $obj_id = ilObject::_lookupObjId($item["ref_id"]);
             $tpl->setCurrentBlock("access");
             $tpl->setVariable("TXT_ACCESS", $lng->txt("news_news_item_visibility"));
             if ($item["visibility"] == NEWS_PUBLIC || $item["priority"] == 0 && ilBlockSetting::_lookup("news", "public_notifications", 0, $obj_id)) {
                 $tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public"));
             } else {
                 $tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users"));
             }
             $tpl->parseCurrentBlock();
         }
         // content
         if (trim($item["content"]) != "") {
             $tpl->setCurrentBlock("content");
             $tpl->setVariable("VAL_CONTENT", nl2br($this->makeClickable(ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"]))));
             //$tpl->setVariable("VAL_CONTENT", nl2br($item["content"]));
             $tpl->parseCurrentBlock();
         }
         if (trim($item["content_long"]) != "") {
             $tpl->setCurrentBlock("long");
             $tpl->setVariable("VAL_LONG_CONTENT", $this->makeClickable($item["content_long"]));
             $tpl->parseCurrentBlock();
         }
         if ($item["update_date"] != $item["creation_date"]) {
             $tpl->setCurrentBlock("ni_update");
             $tpl->setVariable("TXT_LAST_UPDATE", $lng->txt("last_update"));
             $tpl->setVariable("VAL_LAST_UPDATE", ilDatePresentation::formatDate(new ilDateTime($item["update_date"], IL_CAL_DATETIME)));
             $tpl->parseCurrentBlock();
         }
         // creation date
         if ($item["creation_date"] != "") {
             $tpl->setCurrentBlock("ni_update");
             $tpl->setVariable("VAL_CREATION_DATE", ilDatePresentation::formatDate(new ilDateTime($item["creation_date"], IL_CAL_DATETIME)));
             $tpl->setVariable("TXT_CREATED", $lng->txt("created"));
             $tpl->parseCurrentBlock();
         }
         // context / title
         if ($_GET["news_context"] > 0) {
             //$obj_id = ilObject::_lookupObjId($_GET["news_context"]);
             $obj_id = ilObject::_lookupObjId($item["ref_id"]);
             $obj_type = ilObject::_lookupType($obj_id);
             $obj_title = ilObject::_lookupTitle($obj_id);
             // file hack, not nice
             if ($obj_type == "file") {
                 $tpl->setCurrentBlock("download");
                 $tpl->setVariable("TXT_DOWNLOAD", $lng->txt("download"));
                 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $item["ref_id"]);
                 $tpl->setVariable("HREF_DOWNLOAD", $ilCtrl->getLinkTargetByClass("ilrepositorygui", "sendfile"));
                 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
                 $tpl->parseCurrentBlock();
             }
             // forum hack, not nice
             $add = "";
             if ($obj_type == "frm" && $item["context_sub_obj_type"] == "pos" && $item["context_sub_obj_id"] > 0) {
                 include_once "./Modules/Forum/classes/class.ilObjForumAccess.php";
                 $pos = $item["context_sub_obj_id"];
                 $thread = ilObjForumAccess::_getThreadForPosting($pos);
                 if ($thread > 0) {
                     $add = "_" . $thread . "_" . $pos;
                 }
             }
             // wiki hack, not nice
             if ($obj_type == "wiki" && $item["context_sub_obj_type"] == "wpg" && $item["context_sub_obj_id"] > 0) {
                 include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
                 $wptitle = ilWikiPage::lookupTitle($item["context_sub_obj_id"]);
                 if ($wptitle != "") {
                     $add = "_" . ilWikiUtil::makeUrlTitle($wptitle);
                 }
             }
             $url_target = "./goto.php?client_id=" . rawurlencode(CLIENT_ID) . "&target=" . $obj_type . "_" . $item["ref_id"] . $add;
             // lm page hack, not nice
             if (in_array($obj_type, array("dbk", "lm")) && $item["context_sub_obj_type"] == "pg" && $item["context_sub_obj_id"] > 0) {
                 $url_target = "./goto.php?client_id=" . rawurlencode(CLIENT_ID) . "&target=" . "pg_" . $item["context_sub_obj_id"] . "_" . $item["ref_id"];
             }
             $context_opened = false;
             if ($item["loc_context"] != null && $item["loc_context"] != $item["loc_stop"]) {
                 $tpl->setCurrentBlock("context");
                 $context_opened = true;
                 $cont_loc = new ilLocatorGUI();
                 $cont_loc->addContextItems($item["loc_context"], true, $item["loc_stop"]);
                 $tpl->setVariable("CONTEXT_LOCATOR", $cont_loc->getHTML());
             }
             //var_dump($item);
             if ($item["no_context_title"] !== true) {
                 if (!$context_opened) {
                     $tpl->setCurrentBlock("context");
                 }
                 $tpl->setVariable("HREF_CONTEXT_TITLE", $url_target);
                 $tpl->setVariable("CONTEXT_TITLE", $obj_title);
                 $tpl->setVariable("IMG_CONTEXT_TITLE", ilObject::_getIcon($obj_id, "big", $obj_type));
             }
             if ($context_opened) {
                 $tpl->parseCurrentBlock();
             }
             $tpl->setVariable("HREF_TITLE", $url_target);
         }
         // title
         $tpl->setVariable("VAL_TITLE", ilNewsItem::determineNewsTitle($item["context_obj_type"], $item["title"], $item["content_is_lang_var"], $item["agg_ref_id"], $item["aggregation"]));
         $row_css = $row_css != "tblrow1" ? "tblrow1" : "tblrow2";
         $tpl->setCurrentBlock("item");
         $tpl->setVariable("ITEM_ROW_CSS", $row_css);
         $tpl->parseCurrentBlock();
     }
     include_once "./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php";
     $content_block = new ilPDContentBlockGUI();
     $content_block->setContent($tpl->get());
     if ($this->getProperty("title") != "") {
         $content_block->setTitle($this->getProperty("title"));
     } else {
         $content_block->setTitle($lng->txt("news_internal_news"));
     }
     //$content_block->setColSpan(2);
     $content_block->setImage(ilUtil::getImagePath("icon_news.png"));
     $this->addCloseCommand($content_block);
     // previous
     if ($previous != "") {
         if ($previous["ref_id"] > 0) {
             $ilCtrl->setParameter($this, "news_context", $previous["ref_id"]);
         }
         $ilCtrl->setParameter($this, "news_id", $previous["id"]);
         $content_block->addFooterLink($lng->txt("previous"), $ilCtrl->getLinkTarget($this, "showNews"), "", "", true);
         $ilCtrl->setParameter($this, "news_context", "");
     }
     // next
     if ($c = next($this->data)) {
         if ($c["ref_id"] > 0) {
             $ilCtrl->setParameter($this, "news_context", $c["ref_id"]);
         }
         $ilCtrl->setParameter($this, "news_id", $c["id"]);
         $content_block->addFooterLink($lng->txt("next"), $ilCtrl->getLinkTarget($this, "showNews"), "", "", true);
     }
     $ilCtrl->setParameter($this, "news_context", "");
     $ilCtrl->setParameter($this, "news_id", "");
     $content_block->setCurrentItemNumber($curr_cnt);
     $content_block->setEnableNumInfo(true);
     $content_block->setData($this->getData());
     return $content_block->getHTML();
 }
示例#20
0
 /**
  * display content of page
  */
 function showPage()
 {
     global $tree, $ilUser, $lng, $ilCtrl, $ilSetting, $ilTabs;
     // jquery and jquery ui are always provided for components
     include_once "./Services/jQuery/classes/class.iljQueryUtil.php";
     iljQueryUtil::initjQuery();
     iljQueryUtil::initjQueryUI();
     //		$this->initSelfAssessmentRendering();
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php";
     ilObjMediaObjectGUI::includePresentationJS($GLOBALS["tpl"]);
     $GLOBALS["tpl"]->addJavaScript("./Services/COPage/js/ilCOPagePres.js");
     // needed for overlays in iim
     include_once "./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
     ilOverlayGUI::initJavascript();
     include_once "./Services/MediaObjects/classes/class.ilPlayerUtil.php";
     ilPlayerUtil::initMediaElementJs($GLOBALS["tpl"]);
     // init template
     //if($this->outputToTemplate())
     //{
     if ($this->getOutputMode() == "edit") {
         //echo ":".$this->getTemplateTargetVar().":";
         $tpl = new ilTemplate("tpl.page_edit_wysiwyg.html", true, true, "Services/COPage");
         //$this->tpl->addBlockFile($this->getTemplateTargetVar(), "adm_content", "tpl.page_edit_wysiwyg.html", "Services/COPage");
         // to do: status dependent class
         $tpl->setVariable("CLASS_PAGE_TD", "ilc_Page");
         // user comment
         if ($this->isEnabledChangeComments()) {
             $tpl->setCurrentBlock("change_comment");
             $tpl->setVariable("TXT_ADD_COMMENT", $this->lng->txt("cont_add_change_comment"));
             $tpl->parseCurrentBlock();
         }
         $tpl->setVariable("WYSIWYG_ACTION", $ilCtrl->getFormActionByClass("ilpageeditorgui", "", "", true));
         // determine media, html and javascript mode
         $sel_media_mode = $ilUser->getPref("ilPageEditor_MediaMode") == "disable" ? "disable" : "enable";
         $sel_html_mode = $ilUser->getPref("ilPageEditor_HTMLMode") == "disable" ? "disable" : "enable";
         $sel_js_mode = "disable";
         //if($ilSetting->get("enable_js_edit", 1))
         //{
         $sel_js_mode = ilPageEditorGUI::_doJSEditing() ? "enable" : "disable";
         //}
         // show prepending html
         $tpl->setVariable("PREPENDING_HTML", $this->getPrependingHtml());
         $tpl->setVariable("TXT_CONFIRM_DELETE", $lng->txt("cont_confirm_delete"));
         // presentation view
         if ($this->getViewPageLink() != "") {
             $ilTabs->addNonTabbedLink("pres_view", $this->lng->txt("cont_presentation_view"), $this->getViewPageLink(), $this->getViewPageTarget());
         }
         // show actions drop down
         $this->addActionsMenu($tpl, $sel_media_mode, $sel_html_mode, $sel_js_mode);
         // get js files for JS enabled editing
         if ($sel_js_mode == "enable") {
             $this->insertHelp($tpl);
             include_once "./Services/YUI/classes/class.ilYuiUtil.php";
             ilYuiUtil::initDragDrop();
             ilYuiUtil::initConnection();
             ilYuiUtil::initPanel(false);
             $GLOBALS["tpl"]->addJavaScript("./Services/COPage/js/ilcopagecallback.js");
             $GLOBALS["tpl"]->addJavascript("Services/COPage/js/page_editing.js");
             include_once './Services/Style/classes/class.ilObjStyleSheet.php';
             $GLOBALS["tpl"]->addOnloadCode("var preloader = new Image();\n\t\t\t\t\t\tpreloader.src = './templates/default/images/loader.svg';\n\t\t\t\t\t\tilCOPage.setContentCss('" . ilObjStyleSheet::getContentStylePath((int) $this->getStyleId()) . ", " . ilUtil::getStyleSheetLocation() . ", ./Services/COPage/css/tiny_extra.css" . "')");
             //$GLOBALS["tpl"]->addJavascript("Services/RTE/tiny_mce_3_3_9_2/il_tiny_mce_src.js");
             $GLOBALS["tpl"]->addJavascript("Services/COPage/tiny/4_1_5/tinymce.js");
             $tpl->touchBlock("init_dragging");
             $cfg = $this->getPageConfig();
             $tpl->setVariable("IL_TINY_MENU", self::getTinyMenu($this->getPageObject()->getParentType(), $cfg->getEnableInternalLinks(), $cfg->getEnableWikiLinks(), $cfg->getEnableKeywords(), $this->getStyleId(), true, true, $cfg->getEnableAnchors()));
             // add int link parts
             include_once "./Services/Link/classes/class.ilInternalLinkGUI.php";
             $tpl->setCurrentBlock("int_link_prep");
             $tpl->setVariable("INT_LINK_PREP", ilInternalLinkGUI::getInitHTML($ilCtrl->getLinkTargetByClass(array("ilpageeditorgui", "ilinternallinkgui"), "", false, true, false)));
             $tpl->parseCurrentBlock();
             include_once "./Services/YUI/classes/class.ilYuiUtil.php";
             ilYuiUtil::initConnection();
             $GLOBALS["tpl"]->addJavaScript("./Services/UIComponent/Explorer/js/ilExplorer.js");
         }
         // multiple actions
         $cnt_pcs = $this->getPageObject()->countPageContents();
         if ($cnt_pcs > 1 || $this->getPageObject()->getParentType() != "qpl" && $cnt_pcs > 0) {
             $tpl->setCurrentBlock("multi_actions");
             if ($sel_js_mode == "enable") {
                 $tpl->setVariable("ONCLICK_DE_ACTIVATE_SELECTED", 'onclick="return ilEditMultiAction(\'activateSelected\');"');
                 $tpl->setVariable("ONCLICK_DELETE_SELECTED", 'onclick="return ilEditMultiAction(\'deleteSelected\');"');
                 $tpl->setVariable("ONCLICK_ASSIGN_CHARACTERISTIC", 'onclick="return ilEditMultiAction(\'assignCharacteristicForm\');"');
                 $tpl->setVariable("ONCLICK_COPY_SELECTED", 'onclick="return ilEditMultiAction(\'copySelected\');"');
                 $tpl->setVariable("ONCLICK_CUT_SELECTED", 'onclick="return ilEditMultiAction(\'cutSelected\');"');
                 $tpl->setVariable("TXT_SELECT_ALL", $this->lng->txt("select_all"));
                 $tpl->setVariable("ONCLICK_SELECT_ALL", 'onclick="return ilEditMultiAction(\'selectAll\');"');
             }
             $tpl->setVariable("TXT_DE_ACTIVATE_SELECTED", $this->lng->txt("cont_ed_enable"));
             $tpl->setVariable("TXT_ASSIGN_CHARACTERISTIC", $this->lng->txt("cont_assign_characteristic"));
             $tpl->setVariable("TXT_DELETE_SELECTED", $this->lng->txt("cont_delete_selected"));
             $tpl->setVariable("TXT_COPY_SELECTED", $this->lng->txt("copy"));
             $tpl->setVariable("TXT_CUT_SELECTED", $this->lng->txt("cut"));
             $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
             $tpl->parseCurrentBlock();
         }
     } else {
         // presentation or preview here
         $tpl = new ilTemplate("tpl.page.html", true, true, "Services/COPage");
         if ($this->getEnabledPageFocus()) {
             $tpl->touchBlock("page_focus");
         }
         include_once "./Services/User/classes/class.ilUserUtil.php";
         // presentation
         if ($this->isPageContainerToBeRendered()) {
             $tpl->touchBlock("page_container_1");
             $tpl->touchBlock("page_container_2");
             $tpl->touchBlock("page_container_3");
         }
         // history
         $c_old_nr = $this->getPageObject()->old_nr;
         if ($c_old_nr > 0 || $this->getCompareMode() || $_GET["history_mode"] == 1) {
             $hist_info = $this->getPageObject()->getHistoryInfo($c_old_nr);
             if (!$this->getCompareMode()) {
                 $ilCtrl->setParameter($this, "history_mode", "1");
                 // previous revision
                 if (is_array($hist_info["previous"])) {
                     $tpl->setCurrentBlock("previous_rev");
                     $tpl->setVariable("TXT_PREV_REV", $lng->txt("cont_previous_rev"));
                     $ilCtrl->setParameter($this, "old_nr", $hist_info["previous"]["nr"]);
                     $tpl->setVariable("HREF_PREV", $ilCtrl->getLinkTarget($this, "preview"));
                     $tpl->parseCurrentBlock();
                 } else {
                     $tpl->setCurrentBlock("previous_rev_disabled");
                     $tpl->setVariable("TXT_PREV_REV", $lng->txt("cont_previous_rev"));
                     $tpl->parseCurrentBlock();
                 }
                 // next revision
                 if ($c_old_nr > 0) {
                     $tpl->setCurrentBlock("next_rev");
                     $tpl->setVariable("TXT_NEXT_REV", $lng->txt("cont_next_rev"));
                     $ilCtrl->setParameter($this, "old_nr", $hist_info["next"]["nr"]);
                     $tpl->setVariable("HREF_NEXT", $ilCtrl->getLinkTarget($this, "preview"));
                     $tpl->parseCurrentBlock();
                     // latest revision
                     $tpl->setCurrentBlock("latest_rev");
                     $tpl->setVariable("TXT_LATEST_REV", $lng->txt("cont_latest_rev"));
                     $ilCtrl->setParameter($this, "old_nr", "");
                     $tpl->setVariable("HREF_LATEST", $ilCtrl->getLinkTarget($this, "preview"));
                     $tpl->parseCurrentBlock();
                 }
                 $ilCtrl->setParameter($this, "history_mode", "");
                 // rollback
                 if ($c_old_nr > 0 && $ilUser->getId() != ANONYMOUS_USER_ID) {
                     $tpl->setCurrentBlock("rollback");
                     $ilCtrl->setParameter($this, "old_nr", $c_old_nr);
                     $tpl->setVariable("HREF_ROLLBACK", $ilCtrl->getLinkTarget($this, "rollbackConfirmation"));
                     $ilCtrl->setParameter($this, "old_nr", "");
                     $tpl->setVariable("TXT_ROLLBACK", $lng->txt("cont_rollback"));
                     $tpl->parseCurrentBlock();
                 }
             }
             $tpl->setCurrentBlock("hist_nav");
             $tpl->setVariable("TXT_REVISION", $lng->txt("cont_revision"));
             $tpl->setVariable("VAL_REVISION_DATE", ilDatePresentation::formatDate(new ilDateTime($hist_info["current"]["hdate"], IL_CAL_DATETIME)));
             $tpl->setVariable("VAL_REV_USER", ilUserUtil::getNamePresentation($hist_info["current"]["user_id"]));
             $tpl->parseCurrentBlock();
         }
     }
     if ($this->getOutputMode() != IL_PAGE_PRESENTATION && $this->getOutputMode() != IL_PAGE_OFFLINE && $this->getOutputMode() != IL_PAGE_PREVIEW && $this->getOutputMode() != IL_PAGE_PRINT) {
         $tpl->setVariable("FORMACTION", $this->ctrl->getFormActionByClass("ilpageeditorgui"));
     }
     // output media object edit list (of media links)
     if ($this->getOutputMode() == "edit") {
         $links = ilInternalLink::_getTargetsOfSource($this->obj->getParentType() . ":pg", $this->obj->getId(), $this->obj->getLanguage());
         $mob_links = array();
         foreach ($links as $link) {
             if ($link["type"] == "mob") {
                 if (ilObject::_exists($link["id"]) && ilObject::_lookupType($link["id"]) == "mob") {
                     $mob_links[$link["id"]] = ilObject::_lookupTitle($link["id"]) . " [" . $link["id"] . "]";
                 }
             }
         }
         // linked media objects
         if (count($mob_links) > 0) {
             $tpl->setCurrentBlock("med_link");
             $tpl->setVariable("TXT_LINKED_MOBS", $this->lng->txt("cont_linked_mobs"));
             $tpl->setVariable("SEL_MED_LINKS", ilUtil::formSelect(0, "mob_id", $mob_links, false, true));
             $tpl->setVariable("TXT_EDIT_MEDIA", $this->lng->txt("cont_edit_mob"));
             $tpl->setVariable("TXT_COPY_TO_CLIPBOARD", $this->lng->txt("cont_copy_to_clipboard"));
             //$this->tpl->setVariable("TXT_COPY_TO_POOL", $this->lng->txt("cont_copy_to_mediapool"));
             $tpl->parseCurrentBlock();
         }
         // content snippets used
         include_once "./Services/COPage/classes/class.ilPCContentInclude.php";
         $snippets = ilPCContentInclude::collectContentIncludes($this->getPageObject(), $this->getPageObject()->getDomDoc());
         if (count($snippets) > 0) {
             foreach ($snippets as $s) {
                 include_once "./Modules/MediaPool/classes/class.ilMediaPoolPage.php";
                 $sn_arr[$s["id"]] = ilMediaPoolPage::lookupTitle($s["id"]);
             }
             $tpl->setCurrentBlock("med_link");
             $tpl->setVariable("TXT_CONTENT_SNIPPETS_USED", $this->lng->txt("cont_snippets_used"));
             $tpl->setVariable("SEL_SNIPPETS", ilUtil::formSelect(0, "ci_id", $sn_arr, false, true));
             $tpl->setVariable("TXT_SHOW_INFO", $this->lng->txt("cont_show_info"));
             $tpl->parseCurrentBlock();
         }
         // scheduled activation?
         if (!$this->getPageObject()->getActive() && $this->getPageObject()->getActivationStart() != "" && $this->getPageConfig()->getEnableScheduledActivation()) {
             $tpl->setCurrentBlock("activation_txt");
             $tpl->setVariable("TXT_SCHEDULED_ACTIVATION", $lng->txt("cont_scheduled_activation"));
             $tpl->setVariable("SA_FROM", ilDatePresentation::formatDate(new ilDateTime($this->getPageObject()->getActivationStart(), IL_CAL_DATETIME)));
             $tpl->setVariable("SA_TO", ilDatePresentation::formatDate(new ilDateTime($this->getPageObject()->getActivationEnd(), IL_CAL_DATETIME)));
             $tpl->parseCurrentBlock();
         }
     }
     if ($_GET["reloadTree"] == "y") {
         $tpl->setCurrentBlock("reload_tree");
         if ($this->obj->getParentType() == "dbk") {
             $tpl->setVariable("LINK_TREE", $this->ctrl->getLinkTargetByClass("ilobjdlbookgui", "explorer", "", false, false));
         } else {
             $tpl->setVariable("LINK_TREE", $this->ctrl->getLinkTargetByClass("ilobjlearningmodulegui", "explorer", "", false, false));
         }
         $tpl->parseCurrentBlock();
     }
     //		}
     // get content
     $builded = $this->obj->buildDom();
     // manage hierarchical ids
     if ($this->getOutputMode() == "edit") {
         // add pc ids, if necessary
         if (!$this->obj->checkPCIds()) {
             $this->obj->insertPCIds();
             $this->obj->update(true, true);
         }
         $this->obj->addFileSizes();
         $this->obj->addHierIDs();
         $hids = $this->obj->getHierIds();
         $row1_ids = $this->obj->getFirstRowIds();
         $col1_ids = $this->obj->getFirstColumnIds();
         $litem_ids = $this->obj->getListItemIds();
         $fitem_ids = $this->obj->getFileItemIds();
         // standard menues
         $hids = $this->obj->getHierIds();
         foreach ($hids as $hid) {
             $tpl->setCurrentBlock("add_dhtml");
             $tpl->setVariable("CONTEXTMENU", "contextmenu_" . $hid);
             $tpl->parseCurrentBlock();
         }
         // column menues for tables
         foreach ($col1_ids as $hid) {
             $tpl->setCurrentBlock("add_dhtml");
             $tpl->setVariable("CONTEXTMENU", "contextmenu_r" . $hid);
             $tpl->parseCurrentBlock();
         }
         // row menues for tables
         foreach ($row1_ids as $hid) {
             $tpl->setCurrentBlock("add_dhtml");
             $tpl->setVariable("CONTEXTMENU", "contextmenu_c" . $hid);
             $tpl->parseCurrentBlock();
         }
         // list item menues
         foreach ($litem_ids as $hid) {
             $tpl->setCurrentBlock("add_dhtml");
             $tpl->setVariable("CONTEXTMENU", "contextmenu_i" . $hid);
             $tpl->parseCurrentBlock();
         }
         // file item menues
         foreach ($fitem_ids as $hid) {
             $tpl->setCurrentBlock("add_dhtml");
             $tpl->setVariable("CONTEXTMENU", "contextmenu_i" . $hid);
             $tpl->parseCurrentBlock();
         }
     } else {
         $this->obj->addFileSizes();
     }
     //echo "<br>-".htmlentities($this->obj->getXMLContent())."-<br><br>";
     //echo "<br>-".htmlentities($this->getLinkXML())."-";
     // set default link xml, if nothing was set yet
     if (!$this->link_xml_set) {
         $this->setDefaultLinkXml();
     }
     //$content = $this->obj->getXMLFromDom(false, true, true,
     //	$this->getLinkXML().$this->getQuestionXML().$this->getComponentPluginsXML());
     $link_xml = $this->getLinkXML();
     // disable/enable auto margins
     if ($this->getStyleId() > 0) {
         if (ilObject::_lookupType($this->getStyleId()) == "sty") {
             include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
             $style = new ilObjStyleSheet($this->getStyleId());
             $template_xml = $style->getTemplateXML();
             $disable_auto_margins = "n";
             if ($style->lookupStyleSetting("disable_auto_margins")) {
                 $disable_auto_margins = "y";
             }
         }
     }
     if ($this->getAbstractOnly()) {
         $content = "<dummy><PageObject><PageContent><Paragraph>" . $this->obj->getFirstParagraphText() . $link_xml . "</Paragraph></PageContent></PageObject></dummy>";
     } else {
         $content = $this->obj->getXMLFromDom(false, true, true, $link_xml . $this->getQuestionXML() . $template_xml . $this->getComponentPluginsXML());
     }
     // check validation errors
     if ($builded !== true) {
         $this->displayValidationError($builded);
     } else {
         $this->displayValidationError($_SESSION["il_pg_error"]);
     }
     unset($_SESSION["il_pg_error"]);
     if (isset($_SESSION["citation_error"])) {
         ilUtil::sendFailure($this->lng->txt("cont_citation_selection_not_valid"));
         ilSession::clear("citation_error");
     }
     // get title
     $pg_title = $this->getPresentationTitle();
     $col_path = ilUtil::getImagePath("col.svg");
     $row_path = ilUtil::getImagePath("row.svg");
     $item_path = ilUtil::getImagePath("item.svg");
     if ($this->getOutputMode() != "offline") {
         $enlarge_path = ilUtil::getImagePath("enlarge.svg");
         $wb_path = ilUtil::getWebspaceDir("output") . "/";
     } else {
         $enlarge_path = "images/enlarge.svg";
         $wb_path = "";
     }
     $pg_title_class = $this->getOutputMode() == "print" ? "ilc_PrintPageTitle" : "";
     // page splitting only for learning modules and
     // digital books
     $enable_split_new = $this->obj->getParentType() == "lm" || $this->obj->getParentType() == "dbk" ? "y" : "n";
     // page splitting to next page only for learning modules and
     // digital books if next page exists in tree
     if (($this->obj->getParentType() == "lm" || $this->obj->getParentType() == "dbk") && ilObjContentObject::hasSuccessorPage($this->obj->getParentId(), $this->obj->getId())) {
         $enable_split_next = "y";
     } else {
         $enable_split_next = "n";
     }
     $img_path = ilUtil::getImagePath("", false, $this->getOutputMode(), $this->getOutputMode() == "offline");
     if ($this->getPageConfig()->getEnablePCType("Tabs")) {
         //include_once("./Services/YUI/classes/class.ilYuiUtil.php");
         //ilYuiUtil::initTabView();
         include_once "./Services/Accordion/classes/class.ilAccordionGUI.php";
         ilAccordionGUI::addJavaScript();
         ilAccordionGUI::addCss();
     }
     $file_download_link = $this->determineFileDownloadLink();
     $fullscreen_link = $this->determineFullscreenLink();
     $this->sourcecode_download_script = $this->determineSourcecodeDownloadScript();
     // default values for various parameters (should be used by
     // all instances in the future)
     $media_mode = $this->getOutputMode() == "edit" ? $ilUser->getPref("ilPageEditor_MediaMode") : "enable";
     include_once "./Modules/LearningModule/classes/class.ilEditClipboard.php";
     $paste = ilEditClipboard::getAction() == "copy" && $this->getOutputMode() == "edit";
     include_once "./Services/MediaObjects/classes/class.ilPlayerUtil.php";
     $flv_video_player = $this->getOutputMode() != "offline" ? ilPlayerUtil::getFlashVideoPlayerFilename(true) : ilPlayerUtil::getFlashVideoPlayerFilename(true);
     $cfg = $this->getPageConfig();
     // added UTF-8 encoding otherwise umlaute are converted too
     include_once "./Services/Maps/classes/class.ilMapUtil.php";
     $params = array('mode' => $this->getOutputMode(), 'pg_title' => htmlentities($pg_title, ENT_QUOTES, "UTF-8"), 'enable_placeholder' => $cfg->getEnablePCType("PlaceHolder") ? "y" : "n", 'pg_id' => $this->obj->getId(), 'pg_title_class' => $pg_title_class, 'webspace_path' => $wb_path, 'enlarge_path' => $enlarge_path, 'img_col' => $col_path, 'img_row' => $row_path, 'img_item' => $item_path, 'enable_split_new' => $enable_split_new, 'enable_split_next' => $enable_split_next, 'link_params' => $this->link_params, 'file_download_link' => $file_download_link, 'fullscreen_link' => $fullscreen_link, 'img_path' => $img_path, 'parent_id' => $this->obj->getParentId(), 'download_script' => $this->sourcecode_download_script, 'encoded_download_script' => urlencode($this->sourcecode_download_script), 'bib_id' => $this->getBibId(), 'citation' => (int) $this->isEnabledCitation(), 'pagebreak' => $this->lng->txt('dgl_pagebreak'), 'page' => $this->lng->txt('page'), 'citate_page' => $this->lng->txt('citate_page'), 'citate_from' => $this->lng->txt('citate_from'), 'citate_to' => $this->lng->txt('citate_to'), 'citate' => $this->lng->txt('citate'), 'enable_rep_objects' => $cfg->getEnablePCType("Resources") ? "y" : "n", 'enable_login_page' => $cfg->getEnablePCType("LoginPageElement") ? "y" : "n", 'enable_map' => $cfg->getEnablePCType("Map") && ilMapUtil::isActivated() ? "y" : "n", 'enable_tabs' => $cfg->getEnablePCType("Tabs") ? "y" : "n", 'enable_sa_qst' => $cfg->getEnableSelfAssessment() ? "y" : "n", 'enable_file_list' => $cfg->getEnablePCType("FileList") ? "y" : "n", 'enable_content_includes' => $cfg->getEnablePCType("ContentInclude") ? "y" : "n", 'enable_content_templates' => count($this->getPageObject()->getContentTemplates()) > 0 ? "y" : "n", 'paste' => $paste ? "y" : "n", 'media_mode' => $media_mode, 'javascript' => $sel_js_mode, 'paragraph_plugins' => $paragraph_plugin_string, 'disable_auto_margins' => $disable_auto_margins, 'page_toc' => $cfg->getEnablePageToc() ? "y" : "n", 'enable_profile' => $cfg->getEnablePCType("Profile") ? "y" : "n", 'enable_verification' => $cfg->getEnablePCType("Verification") ? "y" : "n", 'enable_blog' => $cfg->getEnablePCType("Blog") ? "y" : "n", 'enable_skills' => $cfg->getEnablePCType("Skills") ? "y" : "n", 'enable_qover' => $cfg->getEnablePCType("QuestionOverview") ? "y" : "n", 'enable_consultation_hours' => $cfg->getEnablePCType("ConsultationHours") ? "y" : "n", 'enable_my_courses' => $cfg->getEnablePCType("MyCourses") ? "y" : "n", 'enable_amd_page_list' => $cfg->getEnablePCType("AMDPageList") ? "y" : "n", 'flv_video_player' => $flv_video_player);
     if ($this->link_frame != "") {
         // todo other link types
         $params["pg_frame"] = $this->link_frame;
     }
     //$content = str_replace("&nbsp;", "", $content);
     // this ensures that cache is emptied with every update
     $params["version"] = ILIAS_VERSION;
     // ensure no cache hit, if included files/media objects have been changed
     $params["incl_elements_date"] = $this->obj->getLastUpdateOfIncludedElements();
     // run xslt
     $md5 = md5(serialize($params) . $link_xml . $template_xml);
     //$a = microtime();
     // check cache (same parameters, non-edit mode and rendered time
     // > last change
     if (($this->getOutputMode() == "preview" || $this->getOutputMode() == "presentation") && !$this->getCompareMode() && !$this->getAbstractOnly() && $md5 == $this->obj->getRenderMd5() && $this->obj->getLastChange() < $this->obj->getRenderedTime() && $this->obj->getRenderedTime() != "" && $this->obj->old_nr == 0) {
         // cache hit
         $output = $this->obj->getRenderedContent();
     } else {
         $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
         $args = array('/_xml' => $content, '/_xsl' => $xsl);
         $xh = xslt_create();
         //		echo "<b>XSLT</b>:".htmlentities($xsl).":<br>";
         //		echo "mode:".$this->getOutputMode().":<br>";
         $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params);
         if (($this->getOutputMode() == "presentation" || $this->getOutputMode() == "preview") && !$this->getAbstractOnly() && $this->obj->old_nr == 0) {
             //echo "writerenderedcontent";
             $this->obj->writeRenderedContent($output, $md5);
         }
         //echo xslt_error($xh);
         xslt_free($xh);
     }
     //$b = microtime();
     //echo "$a - $b";
     //echo "<pre>".htmlentities($output)."</pre>";
     // unmask user html
     if (($this->getOutputMode() != "edit" || $ilUser->getPref("ilPageEditor_HTMLMode") != "disable") && !$this->getPageConfig()->getPreventHTMLUnmasking()) {
         $output = str_replace("&lt;", "<", $output);
         $output = str_replace("&gt;", ">", $output);
     }
     $output = str_replace("&amp;", "&", $output);
     $output = ilUtil::insertLatexImages($output);
     // insert page snippets
     $output = $this->insertContentIncludes($output);
     // insert resource blocks
     $output = $this->insertResources($output);
     // insert page toc
     if ($this->getPageConfig()->getEnablePageToc()) {
         $output = $this->insertPageToc($output);
     }
     // insert advanced output trigger
     $output = $this->insertAdvTrigger($output);
     // workaround for preventing template engine
     // from hiding paragraph text that is enclosed
     // in curly brackets (e.g. "{a}", see ilLMEditorGUI::executeCommand())
     $output = $this->replaceCurlyBrackets($output);
     // remove all newlines (important for code / pre output)
     $output = str_replace("\n", "", $output);
     //echo htmlentities($output);
     $output = $this->postOutputProcessing($output);
     //echo htmlentities($output);
     if ($this->getOutputMode() == "edit" && !$this->getPageObject()->getActive($this->getPageConfig()->getEnableScheduledActivation())) {
         $output = '<div class="il_editarea_disabled">' . $output . '</div>';
     }
     // for all page components...
     include_once "./Services/COPage/classes/class.ilCOPagePCDef.php";
     $defs = ilCOPagePCDef::getPCDefinitions();
     foreach ($defs as $def) {
         ilCOPagePCDef::requirePCClassByName($def["name"]);
         $pc_class = $def["pc_class"];
         $pc_obj = new $pc_class($this->getPageObject());
         // post xsl page content modification by pc elements
         $output = $pc_obj->modifyPageContentPostXsl($output, $this->getOutputMode());
         // javascript files
         $js_files = $pc_obj->getJavascriptFiles($this->getOutputMode());
         foreach ($js_files as $js) {
             $GLOBALS["tpl"]->addJavascript($js);
         }
         // css files
         $css_files = $pc_obj->getCssFiles($this->getOutputMode());
         foreach ($css_files as $css) {
             $GLOBALS["tpl"]->addCss($css);
         }
         // onload code
         $onload_code = $pc_obj->getOnloadCode($this->getOutputMode());
         foreach ($onload_code as $code) {
             $GLOBALS["tpl"]->addOnloadCode($code);
         }
     }
     //		$output = $this->selfAssessmentRendering($output);
     // output
     if ($ilCtrl->isAsynch() && !$this->getRawPageContent() && $this->getOutputMode() == "edit") {
         // e.g. ###3:110dad8bad6df8620071a0a693a2d328###
         if ($_GET["updated_pc_id_str"] != "") {
             echo $_GET["updated_pc_id_str"];
         }
         $tpl->setVariable($this->getTemplateOutputVar(), $output);
         $tpl->setCurrentBlock("edit_page");
         $tpl->parseCurrentBlock();
         echo $tpl->get("edit_page");
         exit;
     }
     if ($this->outputToTemplate()) {
         $tpl->setVariable($this->getTemplateOutputVar(), $output);
         $this->tpl->setVariable($this->getTemplateTargetVar(), $tpl->get());
         return $output;
     } else {
         if ($this->getRawPageContent()) {
             return $output;
         } else {
             $tpl->setVariable($this->getTemplateOutputVar(), $output);
             return $tpl->get();
         }
     }
 }
 /**
  * get content style path
  *
  * static (to avoid full reading)
  */
 function getContentStylePath($a_style_id)
 {
     global $ilias;
     $rand = rand(1, 999999);
     // check global fixed content style
     $fixed_style = $ilias->getSetting("fixed_content_style_id");
     if ($fixed_style > 0) {
         $a_style_id = $fixed_style;
     }
     // check global default style
     if ($a_style_id <= 0) {
         $a_style_id = $ilias->getSetting("default_content_style_id");
     }
     if ($a_style_id > 0 && ilObject::_exists($a_style_id)) {
         // check whether file is up to date
         if (!ilObjStyleSheet::_lookupUpToDate($a_style_id)) {
             $style = new ilObjStyleSheet($a_style_id);
             $style->writeCSSFile();
         }
         return ilUtil::getWebspaceDir("output") . "/css/style_" . $a_style_id . ".css?dummy={$rand}";
     } else {
         return "./Services/COPage/css/content.css";
     }
 }
示例#22
0
 function getExportResources()
 {
     $export_files = array();
     require_once "./Modules/Scorm2004/classes/class.ilSCORM2004Page.php";
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     include_once "./Modules/File/classes/class.ilObjFile.php";
     $tree = new ilTree($this->slm_object->getId());
     $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
     $tree->setTreeTablePK("slm_id");
     foreach ($tree->getSubTree($tree->getNodeData($this->node_object->getId()), true, 'page') as $page) {
         $page_obj = new ilSCORM2004Page($page["obj_id"]);
         $page_obj->buildDom();
         $mob_ids = $page_obj->collectMediaObjects(false);
         foreach ($mob_ids as $mob_id) {
             if ($mob_id > 0 && ilObject::_exists($mob_id)) {
                 $path = ilObjMediaObject::_lookupStandardItemPath($mob_id, false, false);
                 $media_obj = new ilObjMediaObject($mob_id);
                 $export_files[$i]["date"] = $media_obj->getCreateDate();
                 $export_files[$i]["size"] = @filesize($path);
                 // could be remote, e.g. youtube video
                 $export_files[$i]["file"] = $media_obj->getTitle();
                 $export_files[$i]["type"] = $media_obj->getDescription();
                 $export_files[$i]["path"] = $path;
                 $this->ctrl->setParameter($this, "resource", rawurlencode(ilObjMediaObject::_lookupStandardItemPath($mob_id, false, false)));
                 $export_files[$i]["link"] = $this->ctrl->getLinkTarget($this, "downloadResource");
                 $i++;
             }
         }
         include_once "./Services/COPage/classes/class.ilPCFileList.php";
         $file_ids = ilPCFileList::collectFileItems($page_obj, $page_obj->getDomDoc());
         foreach ($file_ids as $file_id) {
             $file_obj = new ilObjFile($file_id, false);
             $export_files[$i]["date"] = $file_obj->getCreateDate();
             $export_files[$i]["size"] = $file_obj->getFileSize();
             $export_files[$i]["file"] = $file_obj->getFileName();
             $export_files[$i]["type"] = $file_obj->getFileType();
             $export_files[$i]["file_id"] = $file_id;
             $this->ctrl->setParameter($this, "file_id", $file_id);
             $export_files[$i]["link"] = $this->ctrl->getLinkTarget($this, "downloadFile", "");
             $i++;
         }
         unset($page_obj);
     }
     return $export_files;
 }
 /**
  * Export page elements
  *
  * @param
  * @return
  */
 function exportPageElements()
 {
     // export all media objects
     $linked_mobs = array();
     foreach ($this->mobs as $mob) {
         if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob") {
             $this->exportHTMLMOB($mob, $linked_mobs);
         }
     }
     $linked_mobs2 = array();
     // mobs linked in link areas
     foreach ($linked_mobs as $mob) {
         if (ilObject::_exists($mob)) {
             $this->exportHTMLMOB($mob, $linked_mobs2);
         }
     }
     // export all file objects
     foreach ($this->files as $file) {
         $this->exportHTMLFile($file);
     }
     // export all files (which are not objects
     foreach ($this->files_direct as $file_id => $attr) {
         $this->exportHTMLFileDirect($file_id, $attr[0], $attr[1]);
     }
 }
 /**
  * export html package
  */
 function exportHTML($a_target_dir, $log, $a_zip_file = true, $a_export_format = "html")
 {
     global $tpl, $ilBench, $ilLocator, $ilUser;
     // initialize temporary target directory
     ilUtil::delDir($a_target_dir);
     ilUtil::makeDir($a_target_dir);
     $mob_dir = $a_target_dir . "/mobs";
     ilUtil::makeDir($mob_dir);
     $file_dir = $a_target_dir . "/files";
     ilUtil::makeDir($file_dir);
     $teximg_dir = $a_target_dir . "/teximg";
     ilUtil::makeDir($teximg_dir);
     $style_dir = $a_target_dir . "/style";
     ilUtil::makeDir($style_dir);
     $style_img_dir = $a_target_dir . "/style/images";
     ilUtil::makeDir($style_img_dir);
     $content_style_dir = $a_target_dir . "/content_style";
     ilUtil::makeDir($content_style_dir);
     $content_style_img_dir = $a_target_dir . "/content_style/images";
     ilUtil::makeDir($content_style_img_dir);
     $GLOBALS["teximgcnt"] = 0;
     // export system style sheet
     $location_stylesheet = ilUtil::getStyleSheetLocation("filesystem");
     $style_name = $ilUser->prefs["style"] . ".css";
     copy($location_stylesheet, $style_dir . "/" . $style_name);
     $fh = fopen($location_stylesheet, "r");
     $css = fread($fh, filesize($location_stylesheet));
     preg_match_all("/url\\(([^\\)]*)\\)/", $css, $files);
     foreach (array_unique($files[1]) as $fileref) {
         $fileref = dirname($location_stylesheet) . "/" . $fileref;
         if (is_file($fileref)) {
             copy($fileref, $style_img_dir . "/" . basename($fileref));
         }
     }
     fclose($fh);
     $location_stylesheet = ilUtil::getStyleSheetLocation();
     // export content style sheet
     $ilBench->start("ExportHTML", "exportContentStyle");
     if ($this->getStyleSheetId() < 1) {
         $cont_stylesheet = "./Services/COPage/css/content.css";
         $css = fread(fopen($cont_stylesheet, 'r'), filesize($cont_stylesheet));
         preg_match_all("/url\\(([^\\)]*)\\)/", $css, $files);
         foreach (array_unique($files[1]) as $fileref) {
             if (is_file(str_replace("..", ".", $fileref))) {
                 copy(str_replace("..", ".", $fileref), $content_style_img_dir . "/" . basename($fileref));
             }
             $css = str_replace($fileref, "images/" . basename($fileref), $css);
         }
         fwrite(fopen($content_style_dir . "/content.css", 'w'), $css);
     } else {
         $style = new ilObjStyleSheet($this->getStyleSheetId());
         $style->writeCSSFile($content_style_dir . "/content.css", "images");
         $style->copyImagesToDir($content_style_img_dir);
     }
     $ilBench->stop("ExportHTML", "exportContentStyle");
     // export syntax highlighting style
     $syn_stylesheet = ilObjStyleSheet::getSyntaxStylePath();
     copy($syn_stylesheet, $a_target_dir . "/syntaxhighlight.css");
     // get learning module presentation gui class
     include_once "./Modules/LearningModule/classes/class.ilLMPresentationGUI.php";
     $_GET["cmd"] = "nop";
     $lm_gui =& new ilLMPresentationGUI();
     $lm_gui->setOfflineMode(true);
     $lm_gui->setOfflineDirectory($a_target_dir);
     $lm_gui->setExportFormat($a_export_format);
     // export pages
     $ilBench->start("ExportHTML", "exportHTMLPages");
     $this->exportHTMLPages($lm_gui, $a_target_dir);
     $ilBench->stop("ExportHTML", "exportHTMLPages");
     // export glossary terms
     $ilBench->start("ExportHTML", "exportHTMLGlossaryTerms");
     $this->exportHTMLGlossaryTerms($lm_gui, $a_target_dir);
     $ilBench->stop("ExportHTML", "exportHTMLGlossaryTerms");
     // export all media objects
     $ilBench->start("ExportHTML", "exportHTMLMediaObjects");
     $linked_mobs = array();
     foreach ($this->offline_mobs as $mob) {
         if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob") {
             $this->exportHTMLMOB($a_target_dir, $lm_gui, $mob, "_blank", $linked_mobs);
         }
     }
     $linked_mobs2 = array();
     // mobs linked in link areas
     foreach ($linked_mobs as $mob) {
         if (ilObject::_exists($mob)) {
             $this->exportHTMLMOB($a_target_dir, $lm_gui, $mob, "_blank", $linked_mobs2);
         }
     }
     $_GET["obj_type"] = "MediaObject";
     $_GET["obj_id"] = $a_mob_id;
     $_GET["cmd"] = "";
     $ilBench->stop("ExportHTML", "exportHTMLMediaObjects");
     // export all file objects
     $ilBench->start("ExportHTML", "exportHTMLFileObjects");
     foreach ($this->offline_files as $file) {
         $this->exportHTMLFile($a_target_dir, $file);
     }
     $ilBench->stop("ExportHTML", "exportHTMLFileObjects");
     // export table of contents
     $ilBench->start("ExportHTML", "exportHTMLTOC");
     $ilLocator->clearItems();
     if ($this->isActiveTOC()) {
         $tpl = new ilTemplate("tpl.main.html", true, true);
         //$tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
         $content =& $lm_gui->showTableOfContents();
         $file = $a_target_dir . "/table_of_contents.html";
         // open file
         if (!($fp = @fopen($file, "w+"))) {
             die("<b>Error</b>: Could not open \"" . $file . "\" for writing" . " in <b>" . __FILE__ . "</b> on line <b>" . __LINE__ . "</b><br />");
         }
         chmod($file, 0770);
         fwrite($fp, $content);
         fclose($fp);
     }
     $ilBench->stop("ExportHTML", "exportHTMLTOC");
     // export images
     $ilBench->start("ExportHTML", "exportHTMLImages");
     $image_dir = $a_target_dir . "/images";
     ilUtil::makeDir($image_dir);
     ilUtil::makeDir($image_dir . "/browser");
     copy(ilUtil::getImagePath("enlarge.png", false, "filesystem"), $image_dir . "/enlarge.png");
     copy(ilUtil::getImagePath("browser/blank.png", false, "filesystem"), $image_dir . "/browser/plus.png");
     copy(ilUtil::getImagePath("browser/blank.png", false, "filesystem"), $image_dir . "/browser/minus.png");
     copy(ilUtil::getImagePath("browser/blank.png", false, "filesystem"), $image_dir . "/browser/blank.png");
     copy(ilUtil::getImagePath("spacer.png", false, "filesystem"), $image_dir . "/spacer.png");
     copy(ilUtil::getImagePath("icon_st.png", false, "filesystem"), $image_dir . "/icon_st.png");
     copy(ilUtil::getImagePath("icon_pg.png", false, "filesystem"), $image_dir . "/icon_pg.png");
     copy(ilUtil::getImagePath("icon_st_s.png", false, "filesystem"), $image_dir . "/icon_st_s.png");
     copy(ilUtil::getImagePath("icon_pg_s.png", false, "filesystem"), $image_dir . "/icon_pg_s.png");
     copy(ilUtil::getImagePath("icon_lm.png", false, "filesystem"), $image_dir . "/icon_lm.png");
     copy(ilUtil::getImagePath("icon_lm_s.png", false, "filesystem"), $image_dir . "/icon_lm_s.png");
     copy(ilUtil::getImagePath("nav_arr_L.png", false, "filesystem"), $image_dir . "/nav_arr_L.png");
     copy(ilUtil::getImagePath("nav_arr_R.png", false, "filesystem"), $image_dir . "/nav_arr_R.png");
     copy(ilUtil::getImagePath("browser/forceexp.png", false, "filesystem"), $image_dir . "/browser/forceexp.png");
     copy(ilUtil::getImagePath("download.png", false, "filesystem"), $image_dir . "/download.png");
     $ilBench->stop("ExportHTML", "exportHTMLImages");
     // export flv/mp3 player
     $services_dir = $a_target_dir . "/Services";
     ilUtil::makeDir($services_dir);
     $media_service_dir = $services_dir . "/MediaObjects";
     ilUtil::makeDir($media_service_dir);
     include_once "./Services/MediaObjects/classes/class.ilPlayerUtil.php";
     $flv_dir = $a_target_dir . "/" . ilPlayerUtil::getFlashVideoPlayerDirectory();
     ilUtil::makeDir($flv_dir);
     $mp3_dir = $media_service_dir . "/flash_mp3_player";
     ilUtil::makeDir($mp3_dir);
     //		copy(ilPlayerUtil::getFlashVideoPlayerFilename(true),
     //			$flv_dir."/".ilPlayerUtil::getFlashVideoPlayerFilename());
     ilPlayerUtil::copyPlayerFilesToTargetDirectory($flv_dir);
     // js files
     ilUtil::makeDir($a_target_dir . '/js');
     ilUtil::makeDir($a_target_dir . '/js/yahoo');
     ilUtil::makeDir($a_target_dir . '/css');
     include_once "./Services/YUI/classes/class.ilYuiUtil.php";
     foreach (self::getSupplyingExportFiles($a_target_dir) as $f) {
         if ($f["source"] != "") {
             copy($f["source"], $f["target"]);
         }
     }
     // template workaround: reset of template
     $tpl = new ilTemplate("tpl.main.html", true, true);
     $tpl->setVariable("LOCATION_STYLESHEET", $location_stylesheet);
     $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
     // zip everything
     $ilBench->start("ExportHTML", "zip");
     if (true) {
         if ($a_zip_file) {
             // zip it all
             $date = time();
             $zip_file = $this->getExportDirectory("html") . "/" . $date . "__" . IL_INST_ID . "__" . $this->getType() . "_" . $this->getId() . ".zip";
             ilUtil::zip($a_target_dir, $zip_file);
             ilUtil::delDir($a_target_dir);
         }
     }
     $ilBench->stop("ExportHTML", "zip");
 }
示例#25
0
 /**
  * delete page object
  */
 function delete()
 {
     global $ilDB;
     $mobs = array();
     $files = array();
     if (!$this->page_not_found) {
         $this->buildDom();
         $mobs = $this->collectMediaObjects(false);
     }
     $this->__beforeDelete();
     // delete style usages
     $this->deleteStyleUsages(false);
     // delete internal links
     $this->deleteInternalLinks();
     // delete all mob usages
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     ilObjMediaObject::_deleteAllUsages($this->getParentType() . ":pg", $this->getId());
     // delete news
     include_once "./Services/News/classes/class.ilNewsItem.php";
     ilNewsItem::deleteNewsOfContext($this->getParentId(), $this->getParentType(), $this->getId(), "pg");
     // delete page_object entry
     $ilDB->manipulate("DELETE FROM page_object " . "WHERE page_id = " . $ilDB->quote($this->getId(), "integer") . " AND parent_type= " . $ilDB->quote($this->getParentType(), "text"));
     //$this->ilias->db->query($query);
     // delete media objects
     foreach ($mobs as $mob_id) {
         if (ilObject::_lookupType($mob_id) != 'mob') {
             $GLOBALS['ilLog']->write(__METHOD__ . ': Type mismatch. Ignoring mob with id: ' . $mob_id);
             continue;
         }
         if (ilObject::_exists($mob_id)) {
             $mob_obj =& new ilObjMediaObject($mob_id);
             $mob_obj->delete();
         }
     }
     /* delete public and private notes (see PageObjectGUI->getNotesHTML())
     		  as they can be seen as personal data we are keeping them for now
     		include_once("Services/Notes/classes/class.ilNote.php");
     		foreach(array(IL_NOTE_PRIVATE, IL_NOTE_PUBLIC) as $note_type)
     		{
     			foreach(ilNote::_getNotesOfObject($this->getParentId(), $this->getId(),
     				$this->getParentType(), $note_type) as $note)
     			{
     				$note->delete();
     			}
     		}
     		*/
 }
示例#26
0
 /**
  * export files of file itmes
  *
  */
 function exportFileItems($a_target_dir, &$expLog)
 {
     include_once "./Modules/File/classes/class.ilObjFile.php";
     if (is_array($this->file_ids)) {
         foreach ($this->file_ids as $file_id) {
             $expLog->write(date("[y-m-d H:i:s] ") . "File Item " . $file_id);
             if (ilObject::_lookupType($file_id) == "file") {
                 $file_obj = new ilObjFile($file_id, false);
                 $file_obj->export($a_target_dir);
                 unset($file_obj);
             } else {
                 $expLog->write(date("[y-m-d H:i:s] ") . "File Item not found, ID: " . $file_id);
             }
         }
     }
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $linked_mobs = array();
     if (is_array($this->mob_ids)) {
         // mobs directly embedded into pages
         foreach ($this->mob_ids as $mob_id) {
             if ($mob_id > 0 && ilObject::_exists($mob_id)) {
                 $expLog->write(date("[y-m-d H:i:s] ") . "Media Object " . $mob_id);
                 $media_obj = new ilObjMediaObject($mob_id);
                 $media_obj->exportFiles($a_target_dir, $expLog);
                 $lmobs = $media_obj->getLinkedMediaObjects($this->mob_ids);
                 $linked_mobs = array_merge($linked_mobs, $lmobs);
                 unset($media_obj);
             }
         }
         // linked mobs (in map areas)
         foreach ($linked_mobs as $mob_id) {
             if ($mob_id > 0 && ilObject::_exists($mob_id)) {
                 $expLog->write(date("[y-m-d H:i:s] ") . "Media Object " . $mob_id);
                 $media_obj = new ilObjMediaObject($mob_id);
                 $media_obj->exportFiles($a_target_dir);
                 unset($media_obj);
             }
         }
     }
     //media files in questions
     foreach ($this->q_media as $media) {
         if ($media != "") {
             error_log($media);
             copy($media, $a_target_dir . "/objects/" . basename($media));
         }
     }
 }
示例#27
0
 public static function _createRandomUserAccount($keyarray)
 {
     global $ilDB, $ilUser, $ilSetting, $rbacadmin;
     if ($_SESSION['create_user_account'] != NULL) {
         $obj_user = new ilObjUser($_SESSION['create_user_account']);
         return $obj_user;
     } else {
         $userLogin = array();
         $res = $ilDB->query('SELECT sequence FROM object_data_seq');
         $row = $ilDB->fetchAssoc($res);
         $temp_user_id = (int) $row['sequence'] + 1;
         $userLogin['login'] = '******' . $temp_user_id;
         $userLogin['passwd'] = ilUtil::generatePasswords(1);
         require_once 'Services/User/classes/class.ilObjUser.php';
         include_once "Services/Mail/classes/class.ilAccountMail.php";
         $obj_user = new ilObjUser();
         $obj_user->setId($temp_user_id);
         $obj_user->setLogin($userLogin['login']);
         $obj_user->setPasswd((string) $userLogin['passwd'][0], IL_PASSWD_PLAIN);
         $_SESSION['tmp_user_account']['login'] = $userLogin['login'];
         $_SESSION['tmp_user_account']['passwd'] = $userLogin['passwd'];
         $obj_user->setFirstname($keyarray['first_name']);
         $obj_user->setLastname($keyarray['last_name']);
         $obj_user->setEmail($keyarray['payer_email']);
         #	$obj_user->setEmail('*****@*****.**');
         $obj_user->setGender('f');
         $obj_user->setLanguage($ilSetting->get("language"));
         $obj_user->setActive(true);
         $obj_user->setTimeLimitUnlimited(true);
         $obj_user->setTitle($obj_user->getFullname());
         $obj_user->setDescription($obj_user->getEmail());
         $obj_user->setTimeLimitOwner(7);
         $obj_user->setTimeLimitUnlimited(1);
         $obj_user->setTimeLimitMessage(0);
         $obj_user->setApproveDate(date("Y-m-d H:i:s"));
         // Set default prefs
         $obj_user->setPref('hits_per_page', $ilSetting->get('hits_per_page', 30));
         $obj_user->setPref('show_users_online', $ilSetting->get('show_users_online', 'y'));
         $obj_user->writePrefs();
         // at the first login the user must complete profile
         $obj_user->setProfileIncomplete(true);
         $obj_user->create();
         $obj_user->saveAsNew();
         $user_role = ilObject::_exists(4, false);
         if (!$user_role) {
             include_once "./Services/AccessControl/classes/class.ilObjRole.php";
             $reg_allowed = ilObjRole::_lookupRegisterAllowed();
             $user_role = $reg_allowed[0]['id'];
         } else {
             $user_role = 4;
         }
         $rbacadmin->assignUser((int) $user_role, $obj_user->getId(), true);
         include_once "Services/Mail/classes/class.ilMimeMail.php";
         global $ilias, $lng;
         $settings = $ilias->getAllSettings();
         $mmail = new ilMimeMail();
         $mmail->autoCheck(false);
         $mmail->From($settings["admin_email"]);
         $mmail->To($obj_user->getEmail());
         // mail subject
         $subject = $lng->txt("reg_mail_subject");
         // mail body
         $body = $lng->txt("reg_mail_body_salutation") . " " . $obj_user->getFullname() . ",\n\n" . $lng->txt("reg_mail_body_text1") . "\n\n" . $lng->txt("reg_mail_body_text2") . "\n" . ILIAS_HTTP_PATH . "/login.php?client_id=" . $ilias->client_id . "\n";
         $body .= $lng->txt("login") . ": " . $obj_user->getLogin() . "\n";
         $body .= $lng->txt("passwd") . ": " . $userLogin['passwd'][0] . "\n";
         $body .= "\n";
         $body .= $lng->txt("reg_mail_body_text3") . "\n\r";
         $body .= $obj_user->getProfileAsString($lng);
         $mmail->Subject($subject);
         $mmail->Body($body);
         $mmail->Send();
         $_SESSION['create_user_account'] = $obj_user->getId();
         return $obj_user;
     }
 }
 /**
  * Deliver vcard information.
  */
 function deliverVCard()
 {
     // get user object
     if (!ilObject::_exists($this->getUserId())) {
         return "";
     }
     $user = new ilObjUser($this->getUserId());
     require_once "./Services/User/classes/class.ilvCard.php";
     $vcard = new ilvCard();
     // ilsharedresourceGUI: embedded in shared portfolio
     if ($user->getPref("public_profile") != "y" && $user->getPref("public_profile") != "g" && $_GET["baseClass"] != "ilsharedresourceGUI") {
         return;
     }
     $vcard->setName($user->getLastName(), $user->getFirstName(), "", $user->getUTitle());
     $vcard->setNickname($user->getLogin());
     $webspace_dir = ilUtil::getWebspaceDir("output");
     $imagefile = $webspace_dir . "/usr_images/" . $user->getPref("profile_image");
     if ($user->getPref("public_upload") == "y" && @is_file($imagefile)) {
         $fh = fopen($imagefile, "r");
         if ($fh) {
             $image = fread($fh, filesize($imagefile));
             fclose($fh);
             require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
             $mimetype = ilObjMediaObject::getMimeType($imagefile);
             if (preg_match("/^image/", $mimetype)) {
                 $type = $mimetype;
             }
             $vcard->setPhoto($image, $type);
         }
     }
     $val_arr = array("getInstitution" => "institution", "getDepartment" => "department", "getStreet" => "street", "getZipcode" => "zipcode", "getCity" => "city", "getCountry" => "country", "getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home", "getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email", "getHobby" => "hobby", "getMatriculation" => "matriculation", "getClientIP" => "client_ip");
     $org = array();
     $adr = array();
     foreach ($val_arr as $key => $value) {
         // if value "y" show information
         if ($user->getPref("public_" . $value) == "y") {
             switch ($value) {
                 case "institution":
                     $org[0] = $user->{$key}();
                     break;
                 case "department":
                     $org[1] = $user->{$key}();
                     break;
                 case "street":
                     $adr[2] = $user->{$key}();
                     break;
                 case "zipcode":
                     $adr[5] = $user->{$key}();
                     break;
                 case "city":
                     $adr[3] = $user->{$key}();
                     break;
                 case "country":
                     $adr[6] = $user->{$key}();
                     break;
                 case "phone_office":
                     $vcard->setPhone($user->{$key}(), TEL_TYPE_WORK);
                     break;
                 case "phone_home":
                     $vcard->setPhone($user->{$key}(), TEL_TYPE_HOME);
                     break;
                 case "phone_mobile":
                     $vcard->setPhone($user->{$key}(), TEL_TYPE_CELL);
                     break;
                 case "fax":
                     $vcard->setPhone($user->{$key}(), TEL_TYPE_FAX);
                     break;
                 case "email":
                     $vcard->setEmail($user->{$key}());
                     break;
                 case "hobby":
                     $vcard->setNote($user->{$key}());
                     break;
             }
         }
     }
     if (count($org)) {
         $vcard->setOrganization(join(";", $org));
     }
     if (count($adr)) {
         $vcard->setAddress($adr[0], $adr[1], $adr[2], $adr[3], $adr[4], $adr[5], $adr[6]);
     }
     ilUtil::deliverData(utf8_decode($vcard->buildVCard()), $vcard->getFilename(), $vcard->getMimetype());
 }
 /**
  * display deletion confirmation screen
  */
 function deleteTrackingForUser()
 {
     if (!isset($_POST["user"])) {
         $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
     }
     // display confirmation message
     include_once "./Services/Utilities/classes/class.ilConfirmationGUI.php";
     $cgui = new ilConfirmationGUI();
     $cgui->setFormAction($this->ctrl->getFormAction($this));
     $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
     $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteTracking");
     $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDeleteTracking");
     foreach ($_POST["user"] as $id) {
         if (ilObject::_exists($id) && ilObject::_lookUpType($id) == "usr") {
             $user = new ilObjUser($id);
             $caption = ilUtil::getImageTagByType("sahs", $this->tpl->tplPath) . " " . $this->lng->txt("cont_tracking_data") . ": " . $user->getLastname() . ", " . $user->getFirstname();
             $cgui->addItem("user[]", $id, $caption);
         }
     }
     $this->tpl->setContent($cgui->getHTML());
 }
 /**
  * Stop offline mode for selected users
  */
 protected function stopUserOfflineMode()
 {
     if (!count((array) $_POST['user'])) {
         ilUtil::sendFailure($this->lng->txt('select_one'), true);
         $this->ctrl->redirect($this, 'offlineModeManager');
     }
     // display confirmation message
     include_once "./Services/Utilities/classes/class.ilConfirmationGUI.php";
     $cgui = new ilConfirmationGUI();
     $cgui->setFormAction($this->ctrl->getFormAction($this));
     $cgui->setHeaderText($this->lng->txt("info_stop_offline_mode_sure"));
     $cgui->setCancel($this->lng->txt("cancel"), "cancelStopUserOfflineMode");
     $cgui->setConfirm($this->lng->txt("confirm"), "confirmedStopUserOfflineMode");
     foreach ($_POST["user"] as $id) {
         if (ilObject::_exists($id) && ilObject::_lookUpType($id) == "usr") {
             $user = new ilObjUser($id);
             $caption = ilUtil::getImageTagByType("sahs_offline", $this->tpl->tplPath) . " " . $this->lng->txt("stop_user_offline_mode_for_user") . ": " . $user->getLastname() . ", " . $user->getFirstname();
             $cgui->addItem("user[]", $id, $caption);
         }
     }
     $this->tpl->setContent($cgui->getHTML());
 }