/**
  * Call this before using getHTML()
  * @access	public
  * @return	ilMailFolderTableGUI
  * @final
  *
  */
 public final function prepareHTML()
 {
     global $ilUser;
     $this->addColumn('', '', '1px', true);
     $this->addColumn($this->lng->txt('personal_picture'), '', '10%');
     if ($this->isDraftFolder() || $this->isSentFolder()) {
         $this->addColumn($this->lng->txt('recipient'), 'rcp_to', '25%');
     } else {
         $this->addColumn($this->lng->txt('sender'), 'from', '25%');
     }
     $this->addColumn($this->lng->txt('subject'), 'm_subject', '40%');
     $this->addColumn($this->lng->txt('date'), 'send_time', '20%');
     // init folder data
     $mtree = new ilTree($ilUser->getId());
     $mtree->setTableNames('mail_tree', 'mail_obj_data');
     $this->_folderNode = $mtree->getNodeData($this->_currentFolderId);
     // command buttons
     $this->initCommandButtons();
     // mail actions
     $this->initMultiCommands($this->_parentObject->mbox->getActions($this->_currentFolderId));
     // fetch table data
     $this->fetchTableData();
     return $this;
 }
 /**
  * Execute Drag Drop Action
  *
  * @param	string	$source_id		Source element ID
  * @param	string	$target_id		Target element ID
  * @param	string	$first_child	Insert as first child of target
  * @param	string	$movecopy		Position ("move" | "copy")
  */
 function executeDragDrop($source_id, $target_id, $first_child, $as_subitem = false, $movecopy = "move")
 {
     $lmtree = new ilTree($this->getId());
     $lmtree->setTableNames('lm_tree', 'lm_data');
     $lmtree->setTreeTablePK("lm_id");
     //echo "-".$source_id."-".$target_id."-".$first_child."-".$as_subitem."-";
     $source_obj = ilLMObjectFactory::getInstance($this, $source_id, true);
     $source_obj->setLMId($this->getId());
     if (!$first_child) {
         $target_obj = ilLMObjectFactory::getInstance($this, $target_id, true);
         $target_obj->setLMId($this->getId());
         $target_parent = $lmtree->getParentId($target_id);
     }
     // handle pages
     if ($source_obj->getType() == "pg") {
         //echo "1";
         if ($lmtree->isInTree($source_obj->getId())) {
             $node_data = $lmtree->getNodeData($source_obj->getId());
             // cut on move
             if ($movecopy == "move") {
                 $parent_id = $lmtree->getParentId($source_obj->getId());
                 $lmtree->deleteTree($node_data);
                 // write history entry
                 require_once "./Services/History/classes/class.ilHistory.php";
                 ilHistory::_createEntry($source_obj->getId(), "cut", array(ilLMObject::_lookupTitle($parent_id), $parent_id), $this->getType() . ":pg");
                 ilHistory::_createEntry($parent_id, "cut_page", array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()), $this->getType() . ":st");
             } else {
                 // copy page
                 $new_page =& $source_obj->copy();
                 $source_id = $new_page->getId();
                 $source_obj =& $new_page;
             }
             // paste page
             if (!$lmtree->isInTree($source_obj->getId())) {
                 if ($first_child) {
                     $target_pos = IL_FIRST_NODE;
                     $parent = $target_id;
                 } else {
                     if ($as_subitem) {
                         $parent = $target_id;
                         $target_pos = IL_FIRST_NODE;
                         $pg_childs =& $lmtree->getChildsByType($parent, "pg");
                         if (count($pg_childs) != 0) {
                             $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
                         }
                     } else {
                         $target_pos = $target_id;
                         $parent = $target_parent;
                     }
                 }
                 // insert page into tree
                 $lmtree->insertNode($source_obj->getId(), $parent, $target_pos);
                 // write history entry
                 if ($movecopy == "move") {
                     // write history comments
                     include_once "./Services/History/classes/class.ilHistory.php";
                     ilHistory::_createEntry($source_obj->getId(), "paste", array(ilLMObject::_lookupTitle($parent), $parent), $this->getType() . ":pg");
                     ilHistory::_createEntry($parent, "paste_page", array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()), $this->getType() . ":st");
                 }
             }
         }
     }
     // handle chapters
     if ($source_obj->getType() == "st") {
         //echo "2";
         $source_node = $lmtree->getNodeData($source_id);
         $subnodes = $lmtree->getSubtree($source_node);
         // check, if target is within subtree
         foreach ($subnodes as $subnode) {
             if ($subnode["obj_id"] == $target_id) {
                 return;
             }
         }
         $target_pos = $target_id;
         if ($first_child) {
             $target_pos = IL_FIRST_NODE;
             $target_parent = $target_id;
             $pg_childs =& $lmtree->getChildsByType($target_parent, "pg");
             if (count($pg_childs) != 0) {
                 $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
             }
         } else {
             if ($as_subitem) {
                 $target_parent = $target_id;
                 $target_pos = IL_FIRST_NODE;
                 $childs =& $lmtree->getChilds($target_parent);
                 if (count($childs) != 0) {
                     $target_pos = $childs[count($childs) - 1]["obj_id"];
                 }
             }
         }
         // insert into
         /*
         			if ($position == "into")
         			{
         				$target_parent = $target_id;
         				$target_pos = IL_FIRST_NODE;
         
         				// if target_pos is still first node we must skip all pages
         				if ($target_pos == IL_FIRST_NODE)
         				{
         					$pg_childs =& $lmtree->getChildsByType($target_parent, "pg");
         					if (count($pg_childs) != 0)
         					{
         						$target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
         					}
         				}
         			}
         */
         // delete source tree
         if ($movecopy == "move") {
             $lmtree->deleteTree($source_node);
         } else {
             // copy chapter (incl. subcontents)
             $new_chapter =& $source_obj->copy($lmtree, $target_parent, $target_pos);
         }
         if (!$lmtree->isInTree($source_id)) {
             $lmtree->insertNode($source_id, $target_parent, $target_pos);
             // insert moved tree
             if ($movecopy == "move") {
                 foreach ($subnodes as $node) {
                     if ($node["obj_id"] != $source_id) {
                         $lmtree->insertNode($node["obj_id"], $node["parent"]);
                     }
                 }
             }
         }
         // check the tree
         $this->checkTree();
     }
     $this->checkTree();
 }
 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;
 }
 /**
  * Shows current folder. Current Folder is determined by $_GET["mobj_id"]
  */
 public function showFolder($a_show_confirmation = false)
 {
     /**
      * @var $ilUser ilObjUser
      * @var $ilToolbar ilToolbarGUI
      */
     global $ilUser, $ilToolbar;
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail.html', 'Services/Mail');
     $this->tpl->setTitle($this->lng->txt('mail'));
     $sentFolderId = $this->mbox->getSentFolder();
     $draftsFolderId = $this->mbox->getDraftsFolder();
     $isTrashFolder = $_GET['mobj_id'] == $this->mbox->getTrashFolder();
     $isSentFolder = $_GET['mobj_id'] == $sentFolderId;
     $isDraftFolder = $_GET['mobj_id'] == $draftsFolderId;
     if ($this->current_selected_cmd == 'deleteMails' && !$this->errorDelete && $this->current_selected_cmd != 'confirm' && $isTrashFolder) {
         if (isset($_REQUEST['mail_id']) && !is_array($_REQUEST['mail_id'])) {
             $_REQUEST['mail_id'] = array($_REQUEST['mail_id']);
         }
         $confirmation = new ilConfirmationGUI();
         $confirmation->setHeaderText($this->lng->txt('mail_sure_delete'));
         $this->ctrl->setParameter($this, 'mail_id', implode(',', (array) $_REQUEST['mail_id']));
         $confirmation->setFormAction($this->ctrl->getFormAction($this, 'confirmDeleteMails'));
         $confirmation->setConfirm($this->lng->txt('confirm'), 'confirmDeleteMails');
         $confirmation->setCancel($this->lng->txt('cancel'), 'cancelDeleteMails');
         $this->tpl->setVariable('CONFIRMATION', $confirmation->getHTML());
         $a_show_confirmation = true;
     }
     $folders = $this->mbox->getSubFolders();
     $mtree = new ilTree($ilUser->getId());
     $mtree->setTableNames('mail_tree', 'mail_obj_data');
     $check_uf = false;
     $check_local = false;
     if ('tree' == ilSession::get(ilMailGUI::VIEWMODE_SESSION_KEY)) {
         $folder_d = $mtree->getNodeData($_GET['mobj_id']);
         if ($folder_d['m_type'] == 'user_folder') {
             $check_uf = true;
         } else {
             if ($folder_d['m_type'] == 'local') {
                 $check_local = true;
             }
         }
     }
     $mailtable = new ilMailFolderTableGUI($this, (int) $_GET['mobj_id'], 'showFolder');
     $mailtable->isSentFolder($isSentFolder)->isDraftFolder($isDraftFolder)->isTrashFolder($isTrashFolder)->initFilter();
     $mailtable->setSelectedItems($_POST['mail_id']);
     try {
         $mailtable->prepareHTML();
     } catch (Exception $e) {
         ilUtil::sendFailure($this->lng->txt($e->getMessage()) != '-' . $e->getMessage() . '-' ? $this->lng->txt($e->getMessage()) : $e->getMessage());
     }
     $table_html = $mailtable->getHtml();
     $folder_options = array();
     if ('tree' != ilSession::get(ilMailGUI::VIEWMODE_SESSION_KEY)) {
         foreach ($folders as $folder) {
             $folder_d = $mtree->getNodeData($folder['obj_id']);
             if ($folder['obj_id'] == $_GET['mobj_id']) {
                 if ($folder['type'] == 'user_folder') {
                     $check_uf = true;
                 } else {
                     if ($folder['type'] == 'local') {
                         $check_local = true;
                         $check_uf = false;
                     }
                 }
             }
             if ($folder['type'] == 'user_folder') {
                 $pre = '';
                 for ($i = 2; $i < $folder_d['depth'] - 1; $i++) {
                     $pre .= '&nbsp';
                 }
                 if ($folder_d['depth'] > 1) {
                     $pre .= '+';
                 }
                 $folder_options[$folder['obj_id']] = $pre . ' ' . $folder['title'];
             } else {
                 $folder_options[$folder['obj_id']] = $this->lng->txt('mail_' . $folder['title']);
             }
         }
     }
     if ($a_show_confirmation == false && $this->askForConfirmation == false) {
         if ('tree' != ilSession::get(ilMailGUI::VIEWMODE_SESSION_KEY)) {
             $ilToolbar->addText($this->lng->txt('mail_change_to_folder'));
             include_once './Services/Form/classes/class.ilSelectInputGUI.php';
             $si = new ilSelectInputGUI("", "mobj_id");
             $si->setOptions($folder_options);
             $si->setValue($_GET['mobj_id']);
             $ilToolbar->addInputItem($si);
             $ilToolbar->addFormButton($this->lng->txt('change'), 'showFolder');
             $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'showFolder'));
         }
         if ($check_local == true || $check_uf == true) {
             $this->addSubfolderCommands($check_uf);
         }
     }
     // END SHOW_FOLDER
     if ($mailtable->isTrashFolder() && $mailtable->getNumerOfMails() > 0 && $this->askForConfirmation) {
         $confirmation = new ilConfirmationGUI();
         $confirmation->setHeaderText($this->lng->txt('mail_empty_trash_confirmation'));
         $confirmation->setFormAction($this->ctrl->getFormAction($this, 'performEmptyTrash'));
         $confirmation->setConfirm($this->lng->txt('confirm'), 'performEmptyTrash');
         $confirmation->setCancel($this->lng->txt('cancel'), 'cancelEmptyTrash');
         $this->tpl->setVariable('CONFIRMATION', $confirmation->getHTML());
     }
     $this->tpl->setVariable('MAIL_TABLE', $table_html);
     $this->tpl->show();
 }
 function exportHTMLScoObjects($a_inst, $a_target_dir, &$expLog, $a_one_file = "")
 {
     global $ilBench;
     $tree = new ilTree($this->getId());
     $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
     $tree->setTreeTablePK("slm_id");
     // copy all necessary files now
     if ($a_one_file != "") {
         $this->prepareHTMLExporter($a_target_dir);
         // put header into file
         $sco_tpl = new ilTemplate("tpl.sco.html", true, true, "Modules/Scorm2004");
         include_once "./Services/COPage/classes/class.ilCOPageHTMLExport.php";
         $sco_tpl = ilCOPageHTMLExport::getPreparedMainTemplate($sco_tpl);
         $sco_tpl->setCurrentBlock("js_file");
         $sco_tpl->setVariable("JS_FILE", "./js/pure.js");
         $sco_tpl->parseCurrentBlock();
         $sco_tpl->setCurrentBlock("js_file");
         $sco_tpl->setVariable("JS_FILE", "./js/question_handling.js");
         $sco_tpl->parseCurrentBlock();
         $sco_tpl->setCurrentBlock("head");
         $sco_tpl->parseCurrentBlock();
         fputs($a_one_file, $sco_tpl->get("head"));
         // toc
         include_once "./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php";
         $manifestBuilder = new ilContObjectManifestBuilder($this);
         $manifestBuilder->buildManifest('12');
         $xsl = file_get_contents("./Modules/Scorm2004/templates/xsl/module.xsl");
         $xml = simplexml_load_string($manifestBuilder->writer->xmlDumpMem());
         $args = array('/_xml' => $xml->organizations->organization->asXml(), '/_xsl' => $xsl);
         $xh = xslt_create();
         $params = array("one_page" => "y");
         $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params);
         xslt_free($xh);
         fputs($a_one_file, $output);
     }
     foreach ($tree->getSubTree($tree->getNodeData($tree->getRootId()), true, 'sco') as $sco) {
         include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php";
         $sco_folder = $a_target_dir . "/" . $sco['obj_id'];
         ilUtil::makeDir($sco_folder);
         $node = new ilSCORM2004Sco($this, $sco['obj_id']);
         if ($a_one_file == "") {
             $node->exportHTML($a_inst, $sco_folder, $expLog, $a_one_file);
         } else {
             $node->exportHTMLPageObjects($a_inst, $a_target_dir, $expLog, 'full', "sco", $a_one_file, $sco_tpl);
         }
         if ($this->getAssignedGlossary() != 0) {
             include_once "./Modules/Glossary/classes/class.ilObjGlossary.php";
             $glos = new ilObjGlossary($this->getAssignedGlossary(), false);
             //$glos->exportHTML($sco_folder."/glossary", $expLog);
         }
     }
     // copy all necessary files now
     if ($a_one_file != "") {
         // put tail into file
         fputs($a_one_file, $sco_tpl->get("tail"));
     }
 }
Beispiel #6
0
 public function testTreeTrash()
 {
     global $tree;
     $obj = new ilObject();
     $obj->setType("xxx");
     $obj->setTitle("TestObject");
     $obj->setDescription("TestDescription");
     $obj->setImportId("imp_44");
     $obj->create();
     $obj->createReference();
     $id = $obj->getId();
     $ref_id = $obj->getRefId();
     $obj = new ilObject($ref_id);
     $obj->putInTree(ROOT_FOLDER_ID);
     $obj->createRoleFolder();
     $obj->setPermissions(ROOT_FOLDER_ID);
     if ($tree->isInTree($ref_id)) {
         $value .= "tree1-";
     }
     if (ilObject::_hasUntrashedReference($id)) {
         $value .= "tree2-";
     }
     // isSaved() uses internal cache!
     $tree->useCache(false);
     $tree->saveSubTree($ref_id, true);
     if ($tree->isDeleted($ref_id)) {
         $value .= "tree3-";
     }
     if ($tree->isSaved($ref_id)) {
         $value .= "tree4-";
     }
     if (ilObject::_isInTrash($ref_id)) {
         $value .= "tree5-";
     }
     if (!ilObject::_hasUntrashedReference($id)) {
         $value .= "tree6-";
     }
     $saved_tree = new ilTree(-(int) $ref_id);
     $node_data = $saved_tree->getNodeData($ref_id);
     $saved_tree->deleteTree($node_data);
     if (!ilObject::_isInTrash($ref_id)) {
         $value .= "tree7-";
     }
     $obs = ilUtil::_getObjectsByOperations("cat", "read");
     foreach ($obs as $ob) {
         if (ilObject::_lookupType(ilObject::_lookupObjId($ob)) != "cat") {
             $value .= "nocat-";
         }
     }
     $obj->delete();
     $this->assertEquals("tree1-tree2-tree3-tree4-tree5-tree6-tree7-", $value);
 }
Beispiel #7
0
 /**
  * get path ids (adjacenca and nested set)
  * @group IL_Init
  * @param
  * @return
  */
 public function testAllOthers()
 {
     $tree = new ilTree(ROOT_FOLDER_ID);
     $d = $tree->getDepth(24);
     $this->assertEquals($d, 4);
     $node = $tree->getNodeData(24);
     $this->assertEquals($node['title'], 'Public chat');
     $bool = $tree->isInTree(24);
     $this->assertEquals($bool, true);
     $bool = $tree->isInTree(24242424);
     $this->assertEquals($bool, false);
     /* ref_id 14 => obj_id 98 does not exist
     		$node = $tree->getParentNodeData(24);
     		$this->assertEquals($node['title'],'Chat-Server');
     		*/
     $bool = $tree->isGrandChild(9, 24);
     $this->assertEquals($bool, 1);
     /* see above
     		$node = $tree->getNodeDataByType('chac');
     		$this->assertEquals($node[0]['title'],'Chat-Server');
     		*/
     $bool = $tree->isDeleted(24);
     $this->assertEquals($bool, false);
     $id = $tree->getParentId(24);
     $this->assertEquals($id, 14);
     $lft = $tree->getLeftValue(24);
     $this->assertEquals($lft, 14);
     $seq = $tree->getChildSequenceNumber($tree->getNodeData(24));
     $this->assertEquals($seq, 1);
     $tree->getNodePath(9, 1);
     $max_depth = $tree->getMaximumDepth();
     // Round trip
     $tree = new ilTree(ROOT_FOLDER_ID);
     $suc = $tree->fetchSuccessorNode(16);
     // cals
     $cals = $tree->fetchPredecessorNode($suc['child']);
     $this->assertEquals($cals['child'], 16);
 }
 /**
  * export (sub)structure objects of structure object (see ilias_co.dtd)
  *
  * @param	object		$a_xml_writer	ilXmlWriter object that receives the
  *										xml data
  */
 static function getChapterList($a_lm_id)
 {
     $tree = new ilTree($a_lm_id);
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     $chapters = array();
     $ndata = $tree->getNodeData($tree->readRootId());
     $childs = $tree->getSubtree($ndata);
     foreach ($childs as $child) {
         if ($child["type"] == "st") {
             $chapters[] = $child;
         }
     }
     return $chapters;
 }
 function mapCurrentPageId($current_page_id)
 {
     $subtree = $this->lm_tree->getSubTree($this->lm_tree->getNodeData(1));
     $node = $this->lm_tree->getNodeData($current_page_id);
     $pos = array_search($node, $subtree);
     $this->tr_obj =& $this->ilias->obj_factory->getInstanceByRefId($_SESSION["tr_id"]);
     $lmtree = new ilTree($this->tr_obj->getId());
     $lmtree->setTableNames('lm_tree', 'lm_data');
     $lmtree->setTreeTablePK("lm_id");
     $subtree = $lmtree->getSubTree($lmtree->getNodeData(1));
     return $subtree[$pos]["child"];
 }
 /**
  * cut page
  */
 function cutPage()
 {
     $this->cutItems();
     return;
     if (!isset($_POST["id"])) {
         $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
     }
     if (count($_POST["id"]) > 1) {
         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"), $this->ilias->error_obj->MESSAGE);
     }
     if (count($_POST["id"]) == 1 && $_POST["id"][0] == IL_FIRST_NODE) {
         $this->ilias->raiseError($this->lng->txt("cont_select_item"), $this->ilias->error_obj->MESSAGE);
     }
     // SAVE POST VALUES
     ilEditClipboard::storeContentObject("pg", $_POST["id"][0]);
     $tree = new ilTree($this->content_object->getId());
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     // cut selected object
     $cutted = 0;
     foreach ($_POST["id"] as $id) {
         if ($id == -1) {
             continue;
         }
         $obj =& ilLMObjectFactory::getInstance($this->content_object, $id);
         $obj->setLMId($this->content_object->getId());
         $node_data = $tree->getNodeData($id);
         //$obj->delete();
         if ($tree->isInTree($id)) {
             $parent_id = $tree->getParentId($id);
             $tree->deleteTree($node_data);
             // write history entry
             require_once "./Services/History/classes/class.ilHistory.php";
             ilHistory::_createEntry($id, "cut", array(ilLMObject::_lookupTitle($parent_id), $parent_id), $this->content_object->getType() . ":pg");
             ilHistory::_createEntry($parent_id, "cut_page", array(ilLMObject::_lookupTitle($id), $id), $this->content_object->getType() . ":st");
         }
         $cutted++;
     }
     // tree check
     $this->checkTree();
     if ($cutted > 0) {
         ilUtil::sendInfo($this->lng->txt("msg_cut_clipboard"), true);
     }
     $this->ctrl->redirect($this, "view");
 }
 /**
  * get all subobject (structure and page objects) of a lm 
  *
  * @access protected
  * @return
  */
 protected function getAllSubObjects($a_ref_id)
 {
     $tree = new ilTree(ilObject::_lookupObjId($a_ref_id));
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     foreach ($tree->getSubTree($tree->getNodeData($tree->getRootId())) as $node) {
         if ($node['type'] == 'st' or $node['type'] == 'pg') {
             $depth = $node['depth'] - 1;
             $child = $node['child'];
             $chapter[$child]['depth'] = $depth;
             $chapter[$child]['type'] = $node['type'];
         }
     }
     return $chapter ? $chapter : array();
 }
Beispiel #12
0
 /**
  * Move objects from trash back to repository
  */
 function restoreObjects($a_cur_ref_id, $a_ref_ids)
 {
     global $rbacsystem, $log, $ilAppEventHandler, $lng, $tree;
     $cur_obj_id = ilObject::_lookupObjId($a_cur_ref_id);
     foreach ($a_ref_ids as $id) {
         $obj_data = ilObjectFactory::getInstanceByRefId($id);
         if (!$rbacsystem->checkAccess('create', $a_cur_ref_id, $obj_data->getType())) {
             $no_create[] = ilObject::_lookupTitle(ilObject::_lookupObjId($id));
         }
     }
     if (count($no_create)) {
         include_once "./Services/Repository/exceptions/class.ilRepositoryException.php";
         throw new ilRepositoryException($lng->txt("msg_no_perm_paste") . " " . implode(',', $no_create));
     }
     $affected_ids = array();
     foreach ($a_ref_ids as $id) {
         $affected_ids[$id] = $id;
         // INSERT AND SET PERMISSIONS
         ilRepUtil::insertSavedNodes($id, $a_cur_ref_id, -(int) $id, $affected_ids);
         // DELETE SAVED TREE
         $saved_tree = new ilTree(-(int) $id);
         $saved_tree->deleteTree($saved_tree->getNodeData($id));
         include_once './Services/Object/classes/class.ilObjectFactory.php';
         $factory = new ilObjectFactory();
         $ref_obj = $factory->getInstanceByRefId($id, FALSE);
         if ($ref_obj instanceof ilObject) {
             $lroles = $GLOBALS['rbacreview']->getRolesOfRoleFolder($id, FALSE);
             foreach ($lroles as $role_id) {
                 include_once './Services/AccessControl/classes/class.ilObjRole.php';
                 $role = new ilObjRole($role_id);
                 $role->setParent($id);
                 $role->delete();
             }
             $parent_ref = $GLOBALS['tree']->getParentId($id);
             if ($parent_ref) {
                 $ref_obj->setPermissions($parent_ref);
             }
         }
         // BEGIN ChangeEvent: Record undelete.
         require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
         global $ilUser;
         ilChangeEvent::_recordWriteEvent(ilObject::_lookupObjId($id), $ilUser->getId(), 'undelete', ilObject::_lookupObjId($tree->getParentId($id)));
         ilChangeEvent::_catchupWriteEvents($cur_obj_id, $ilUser->getId());
         // END PATCH ChangeEvent: Record undelete.
     }
     // send events
     foreach ($affected_ids as $id) {
         // send global event
         $ilAppEventHandler->raise("Services/Object", "undelete", array("obj_id" => ilObject::_lookupObjId($id), "ref_id" => $id));
     }
 }
 function confirmedMove()
 {
     global $ilUser;
     $tgt = (int) $_REQUEST["bmfmv_id"];
     $bm_ids = explode(";", $_REQUEST['bm_id_tgt']);
     if (!$bm_ids || !$tgt) {
         ilUtil::sendFailure($this->lng->txt("no_checkbox"));
         return $this->view();
     }
     $tree = new ilTree($ilUser->getId());
     $tree->setTableNames('bookmark_tree', 'bookmark_data');
     $tgt_node = $tree->getNodeData($tgt);
     // sanity check
     foreach ($bm_ids as $node_id) {
         if ($tree->isGrandChild($node_id, $tgt)) {
             ilUtil::sendFailure($this->lng->txt("error"), true);
             $this->ctrl->redirect($this, "view");
         }
         $node = $tree->getNodeData($node_id);
         // already at correct position
         if ($node["parent"] == $tgt) {
             continue;
         }
         $tree->moveTree($node_id, $tgt);
     }
     ilUtil::sendSuccess($this->lng->txt("bookmark_moved_ok"), true);
     $this->ctrl->setParameter($this, "bmf_id", $tgt);
     $this->ctrl->redirect($this, "view");
 }
Beispiel #14
0
 /**
  * remove already deleted objects within the objects in trash
  * recursive function
  *
  * @access	public
  * @param	integer ref_id of source object
  * @param    boolean 
  */
 function removeDeletedNodes($a_node_id, $a_checked, $a_delete_objects = true)
 {
     global $ilDB, $log, $ilias, $tree;
     $query = "SELECT tree FROM tree WHERE parent = ? AND tree < 0 ";
     $sta = $ilDB->prepare($query, array('integer', 'integer'));
     $res = $ilDB->execute($sta, array($a_node_id, 0));
     while ($row = $ilDB->fetchObject($res)) {
         // only continue recursion if fetched node wasn't touched already!
         if (!in_array($row->tree, $a_checked)) {
             $deleted_tree = new ilTree($row->tree);
             $a_checked[] = $row->tree;
             $row->tree = $row->tree * -1;
             $del_node_data = $deleted_tree->getNodeData($row->tree);
             $del_subtree_nodes = $deleted_tree->getSubTree($del_node_data);
             $this->removeDeletedNodes($row->tree, $a_checked);
             if ($a_delete_objects) {
                 foreach ($del_subtree_nodes as $node) {
                     $node_obj =& $ilias->obj_factory->getInstanceByRefId($node["ref_id"]);
                     // write log entry
                     /*$this->writelog("removeDeletedNodes(), delete obj_id: ".$node_obj->getId().
                     			", ref_id: ".$node_obj->getRefId().", type: ".$node_obj->getType().", ".
                     			"title: ".$node_obj->getTitle());
                     		*/
                     $node_obj->delete();
                 }
             }
             $tree->deleteTree($del_node_data);
             // write log entry
             //$this->writelog("removeDeletedNodes(), deleted tree, tree_id: ".$del_node_data["tree"].", child: ".$del_node_data["child"]);
         }
     }
     return true;
 }
 function exportXMLPageObjects($a_target_dir, &$a_xml_writer, $a_inst, &$expLog)
 {
     global $ilBench;
     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php";
     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Page.php";
     $tree = new ilTree($this->slm_id);
     $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
     $tree->setTreeTablePK("slm_id");
     $pages = $tree->getSubTree($tree->getNodeData($this->getId()), true, 'page');
     foreach ($pages as $page) {
         $expLog->write(date("[y-m-d H:i:s] ") . "Page Object " . $page["obj_id"]);
         // export xml to writer object
         $page_obj = new ilSCORM2004Page($page["obj_id"]);
         $page_obj->exportXML($a_xml_writer, "normal", $a_inst);
         //collect media objects
         $mob_ids = $page_obj->getMediaObjectIds();
         foreach ($mob_ids as $mob_id) {
             $this->mob_ids[$mob_id] = $mob_id;
         }
         // collect all file items
         $file_ids = $page_obj->getFileItemIds();
         foreach ($file_ids as $file_id) {
             $this->file_ids[$file_id] = $file_id;
         }
         include_once "./Services/COPage/classes/class.ilPCQuestion.php";
         $q_ids = ilPCQuestion::_getQuestionIdsForPage("sahs", $page["obj_id"]);
         if (count($q_ids) > 0) {
             include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
             foreach ($q_ids as $q_id) {
                 $q_obj =& assQuestion::_instanciateQuestion($q_id);
                 $qti_file = fopen($a_target_dir . "/qti_" . $q_id . ".xml", "w");
                 fwrite($qti_file, $q_obj->toXML());
                 fclose($qti_file);
             }
         }
         unset($page_obj);
     }
 }
 /**
  * Move objects from trash back to repository
  */
 function restoreObjects($a_cur_ref_id, $a_ref_ids)
 {
     global $rbacsystem, $log, $ilAppEventHandler, $lng;
     $cur_obj_id = ilObject::_lookupObjId($a_cur_ref_id);
     foreach ($a_ref_ids as $id) {
         $obj_data = ilObjectFactory::getInstanceByRefId($id);
         if (!$rbacsystem->checkAccess('create', $a_cur_ref_id, $obj_data->getType())) {
             $no_create[] = ilObject::_lookupTitle(ilObject::_lookupObjId($id));
         }
     }
     if (count($no_create)) {
         include_once "./Services/Repository/exceptions/class.ilRepositoryException.php";
         throw new ilRepositoryException($lng->txt("msg_no_perm_paste") . " " . implode(',', $no_create));
     }
     $affected_ids = array();
     foreach ($a_ref_ids as $id) {
         $affected_ids[$id] = $id;
         // INSERT AND SET PERMISSIONS
         ilRepUtil::insertSavedNodes($id, $a_cur_ref_id, -(int) $id, $affected_ids);
         // DELETE SAVED TREE
         $saved_tree = new ilTree(-(int) $id);
         $saved_tree->deleteTree($saved_tree->getNodeData($id));
         // BEGIN ChangeEvent: Record undelete.
         require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
         global $ilUser, $tree;
         $node_data = $saved_tree->getNodeData($id);
         $saved_tree->deleteTree($node_data);
         // Record undelete event
         $node_data = $tree->getNodeData($id);
         $parent_data = $tree->getParentNodeData($node_data['ref_id']);
         ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'undelete', $parent_data['obj_id']);
         ilChangeEvent::_catchupWriteEvents($cur_obj_id, $ilUser->getId());
         // END PATCH ChangeEvent: Record undelete.
     }
     // send events
     foreach ($affected_ids as $id) {
         // send global event
         $ilAppEventHandler->raise("Services/Object", "undelete", array("obj_id" => ilObject::_lookupObjId($id), "ref_id" => $id));
     }
 }
 /**
  * Delete chapters/scos/pages
  */
 function confirmedDelete($a_redirect = true)
 {
     global $ilCtrl;
     $tree = new ilTree($this->object->getId());
     $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
     $tree->setTreeTablePK("slm_id");
     // delete all selected objects
     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php";
     foreach ($_POST["id"] as $id) {
         if ($id != IL_FIRST_NODE) {
             $obj = ilSCORM2004NodeFactory::getInstance($this->object, $id, false);
             $node_data = $tree->getNodeData($id);
             if (is_object($obj)) {
                 $obj->setSLMId($this->object->getId());
                 /*include_once("./Services/History/classes/class.ilHistory.php");
                 	 ilHistory::_createEntry($this->object->getId(), "delete_".$obj->getType(),
                 		array(ilLMObject::_lookupTitle($id), $id),
                 		$this->object->getType());*/
                 $obj->delete();
             }
             if ($tree->isInTree($id)) {
                 $tree->deleteTree($node_data);
             }
         }
     }
     // check the tree
     //		$this->object->checkTree();
     // feedback
     ilUtil::sendInfo($this->lng->txt("info_deleted"), true);
     if ($a_redirect) {
         $ilCtrl->redirect($this, "showOrganization");
     }
 }
 function updateQuickEdit_scorm_propagate($request, $type)
 {
     $module_id = $this->md_obj->obj_id;
     if ($this->md_obj->obj_type == 'sco') {
         $module_id = $this->md_obj->rbac_id;
     }
     $tree = new ilTree($module_id);
     $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
     $tree->setTreeTablePK("slm_id");
     foreach ($tree->getSubTree($tree->getNodeData($tree->getRootId()), true, 'sco') as $sco) {
         $sco_md = new ilMD($module_id, $sco['obj_id'], 'sco');
         if ($_POST[$request] != "") {
             $sco_md_section;
             if (!is_object($sco_md_section = $sco_md->getLifecycle())) {
                 $sco_md_section = $sco_md->addLifecycle();
                 $sco_md_section->save();
             }
             // determine all entered authors
             $auth_arr = explode(",", $_POST[$request]);
             for ($i = 0; $i < count($auth_arr); $i++) {
                 $auth_arr[$i] = trim($auth_arr[$i]);
             }
             $md_con_author = "";
             // update existing author entries (delete if not entered)
             foreach ($ids = $sco_md_section->getContributeIds() as $con_id) {
                 $md_con = $sco_md_section->getContribute($con_id);
                 if ($md_con->getRole() == $type) {
                     foreach ($ent_ids = $md_con->getEntityIds() as $ent_id) {
                         $md_ent = $md_con->getEntity($ent_id);
                         // entered author already exists
                         if (in_array($md_ent->getEntity(), $auth_arr)) {
                             unset($auth_arr[array_search($md_ent->getEntity(), $auth_arr)]);
                         } else {
                             $md_ent->delete();
                         }
                     }
                     $md_con_author = $md_con;
                 }
             }
             // insert enterd, but not existing authors
             if (count($auth_arr) > 0) {
                 if (!is_object($md_con_author)) {
                     $md_con_author = $sco_md_section->addContribute();
                     $md_con_author->setRole($type);
                     $md_con_author->save();
                 }
                 foreach ($auth_arr as $auth) {
                     $md_ent = $md_con_author->addEntity();
                     $md_ent->setEntity(ilUtil::stripSlashes($auth));
                     $md_ent->save();
                 }
             }
         } else {
             if (is_object($sco_md_section = $sco_md->getLifecycle())) {
                 foreach ($ids = $sco_md_section->getContributeIds() as $con_id) {
                     $md_con = $sco_md_section->getContribute($con_id);
                     if ($md_con->getRole() == $type) {
                         $md_con->delete();
                     }
                 }
             }
         }
         $sco_md->update();
     }
     $this->updateQuickEdit_scorm();
 }
 /**
  * checks if rolefolder contains any roles. if not the rolefolder is deleted
  * @access	public
  * @return	boolean	true if rolefolder is deleted
  */
 function purge()
 {
     global $rbacreview, $rbacadmin, $tree;
     $local_roles = $rbacreview->getRolesOfRoleFolder($this->getRefId());
     if (count($local_roles) == 0) {
         $rbacadmin->revokePermission($this->getRefId());
         if ($tree_id = $this->isDeleted()) {
             $deleted_tree = new ilTree($tree_id, -(int) $tree_id);
             $deleted_tree->deleteTree($deleted_tree->getNodeData($this->getRefId()));
         } else {
             $tree->deleteTree($tree->getNodeData($this->getRefId()));
         }
         $this->delete();
         return true;
     }
     return false;
 }
 /**
  * static
  */
 function getObject($a_id)
 {
     $a_tree_id = $_SESSION["AccountId"];
     $tree = new ilTree($a_tree_id);
     $tree->setTableNames('bookmark_tree', 'bookmark_data');
     if (empty($a_id)) {
         $a_id = $tree->getRootId();
     }
     $object = $tree->getNodeData($a_id);
     return $object;
 }
 /**
  * delete page object or structure objects
  *
  * @param	int		$a_parent_subobj_id		id of parent object (structure object)
  *											of the objects, that should be deleted
  *											(or no parent object id for top level)
  */
 function confirmedDelete($a_parent_subobj_id = 0)
 {
     $tree = new ilTree($this->object->getId());
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     // check number of objects
     if (!$_POST["id"]) {
         $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
     }
     // delete all selected objects
     foreach ($_POST["id"] as $id) {
         if ($id != IL_FIRST_NODE) {
             $obj =& ilLMObjectFactory::getInstance($this->object, $id, false);
             $node_data = $tree->getNodeData($id);
             if (is_object($obj)) {
                 $obj->setLMId($this->object->getId());
                 include_once "./Services/History/classes/class.ilHistory.php";
                 ilHistory::_createEntry($this->object->getId(), "delete_" . $obj->getType(), array(ilLMObject::_lookupTitle($id), $id), $this->object->getType());
                 $obj->delete();
             }
             if ($tree->isInTree($id)) {
                 $tree->deleteTree($node_data);
             }
         }
     }
     // check the tree
     $this->object->checkTree();
     // feedback
     ilUtil::sendSuccess($this->lng->txt("info_deleted"), true);
     if ($a_parent_subobj_id == 0) {
         $this->ctrl->redirect($this, $_GET["backcmd"]);
     }
 }
 /**
  * Shows current folder. Current Folder is determined by $_GET["mobj_id"]
  */
 public function showFolder($a_show_confirmation = false)
 {
     /**
      * @var $ilUser ilObjUser
      * @var $ilToolbar ilToolbarGUI
      */
     global $ilUser, $ilToolbar;
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail.html', 'Services/Mail');
     $this->tpl->setTitle($this->lng->txt('mail'));
     include_once 'Services/Mail/classes/class.ilMailFolderTableGUI.php';
     $sentFolderId = $this->mbox->getSentFolder();
     $draftsFolderId = $this->mbox->getDraftsFolder();
     $isTrashFolder = $_GET['mobj_id'] == $this->mbox->getTrashFolder();
     $isSentFolder = $_GET['mobj_id'] == $sentFolderId;
     $isDraftFolder = $_GET['mobj_id'] == $draftsFolderId;
     // BEGIN CONFIRM_DELETE
     if ($this->current_selected_cmd == 'deleteMails' && !$this->errorDelete && $this->current_selected_cmd != 'confirm' && $isTrashFolder) {
         if (isset($_REQUEST['mail_id']) && !is_array($_REQUEST['mail_id'])) {
             $_REQUEST['mail_id'] = array($_REQUEST['mail_id']);
         }
         foreach ((array) $_REQUEST['mail_id'] as $id) {
             $this->tpl->setCurrentBlock('mail_ids');
             $this->tpl->setVariable('MAIL_ID_VALUE', $id);
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->setCurrentBlock('confirm_delete');
         $this->tpl->setVariable('ACTION', $this->ctrl->getFormAction($this, 'confirmDeleteMails'));
         $this->tpl->setVariable('BUTTON_CONFIRM', $this->lng->txt('confirm'));
         $this->tpl->setVariable('BUTTON_CANCEL', $this->lng->txt('cancel'));
         $this->tpl->parseCurrentBlock();
     }
     $folders = $this->mbox->getSubFolders();
     $mtree = new ilTree($ilUser->getId());
     $mtree->setTableNames('mail_tree', 'mail_obj_data');
     $check_uf = false;
     $check_local = false;
     if ('tree' == ilSession::get(ilMailGUI::VIEWMODE_SESSION_KEY)) {
         $folder_d = $mtree->getNodeData($_GET['mobj_id']);
         if ($folder_d['m_type'] == 'user_folder') {
             $check_uf = true;
         } else {
             if ($folder_d['m_type'] == 'local') {
                 $check_local = true;
             }
         }
     }
     $mailtable = new ilMailFolderTableGUI($this, (int) $_GET['mobj_id'], 'showFolder');
     $mailtable->isSentFolder($isSentFolder)->isDraftFolder($isDraftFolder)->isTrashFolder($isTrashFolder)->setSelectedItems($_POST['mail_id'])->prepareHTML();
     $folder_options = array();
     if ('tree' != ilSession::get(ilMailGUI::VIEWMODE_SESSION_KEY)) {
         foreach ($folders as $folder) {
             $folder_d = $mtree->getNodeData($folder['obj_id']);
             if ($folder['obj_id'] == $_GET['mobj_id']) {
                 if ($folder['type'] == 'user_folder') {
                     $check_uf = true;
                 } else {
                     if ($folder['type'] == 'local') {
                         $check_local = true;
                         $check_uf = false;
                     }
                 }
             }
             if ($folder['type'] == 'user_folder') {
                 $pre = '';
                 for ($i = 2; $i < $folder_d['depth'] - 1; $i++) {
                     $pre .= '&nbsp';
                 }
                 if ($folder_d['depth'] > 1) {
                     $pre .= '+';
                 }
                 $folder_options[$folder['obj_id']] = $pre . ' ' . $folder['title'];
             } else {
                 $folder_options[$folder['obj_id']] = $this->lng->txt('mail_' . $folder['title']);
             }
         }
     }
     if ($a_show_confirmation == false) {
         if ('tree' != ilSession::get(ilMailGUI::VIEWMODE_SESSION_KEY)) {
             $ilToolbar->addText($this->lng->txt('mail_change_to_folder'));
             include_once './Services/Form/classes/class.ilSelectInputGUI.php';
             $si = new ilSelectInputGUI("", "mobj_id");
             $si->setOptions($folder_options);
             $si->setValue($_GET['mobj_id']);
             $ilToolbar->addInputItem($si);
             $ilToolbar->addFormButton($this->lng->txt('change'), 'showFolder');
             $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'showFolder'));
         }
         if ($check_local == true || $check_uf == true) {
             $this->addSubfolderCommands($check_uf);
         }
     }
     // END SHOW_FOLDER
     // BEGIN Trash delete confirmation
     if ($mailtable->isTrashFolder() && $mailtable->getNumerOfMails() > 0) {
         if ($this->askForConfirmation == true) {
             $this->tpl->setCurrentBlock('confirm_empty_trash');
             $this->tpl->setVariable('ACTION_EMPTY_TRASH_CONFIRMATION', $this->ctrl->getFormAction($this, 'performEmptyTrash'));
             $this->tpl->setVariable('BUTTON_CONFIRM_EMPTY_TRASH', $this->lng->txt('confirm'));
             $this->tpl->setVariable('BUTTON_CANCEL_EMPTY_TRASH', $this->lng->txt('cancel'));
             $this->tpl->parseCurrentBlock();
         }
     }
     // END Trash delete confirmation
     $this->tpl->setVariable('MAIL_TABLE', $mailtable->getHtml());
     $this->tpl->show();
 }