00001 <?php 00002 /* 00003 +-----------------------------------------------------------------------------+ 00004 | ILIAS open source | 00005 +-----------------------------------------------------------------------------+ 00006 | Copyright (c) 1998-2005 ILIAS open source, University of Cologne | 00007 | | 00008 | This program is free software; you can redistribute it and/or | 00009 | modify it under the terms of the GNU General Public License | 00010 | as published by the Free Software Foundation; either version 2 | 00011 | of the License, or (at your option) any later version. | 00012 | | 00013 | This program is distributed in the hope that it will be useful, | 00014 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00015 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00016 | GNU General Public License for more details. | 00017 | | 00018 | You should have received a copy of the GNU General Public License | 00019 | along with this program; if not, write to the Free Software | 00020 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 00021 +-----------------------------------------------------------------------------+ 00022 */ 00023 00024 include_once("classes/class.ilTableGUI.php"); 00025 //include_once("classes/class.ilObjGroupGUI.php"); // costs 887816 Bytes 00026 //include_once("classes/class.ilObjFolderGUI.php"); // costs 137416 Bytes 00027 //include_once("classes/class.ilObjFolder.php"); 00028 //include_once("classes/class.ilObjFileGUI.php"); // costs 122224 Bytes 00029 //include_once("classes/class.ilObjFile.php"); 00030 include_once("classes/class.ilTabsGUI.php"); 00031 //include_once("classes/class.ilObjUserGUI.php"); // costs 789880 Bytes 00032 //include_once("classes/class.ilObjUserFolderGUI.php"); // costs 737696 Bytes 00033 //include_once("classes/class.ilObjRoleGUI.php"); // costs 827840 Bytes 00034 include_once("payment/classes/class.ilPaymentObject.php"); 00035 //include_once("./ilinc/classes/class.ilObjiLincCourseGUI.php"); // costs 715832 Bytes 00036 //include_once("./ilinc/classes/class.ilObjiLincClassroomGUI.php"); // costs > 348488 Bytes 00037 00038 00056 class ilRepositoryGUI 00057 { 00058 var $lng; 00059 var $ilias; 00060 var $tpl; 00061 var $tree; 00062 var $rbacsystem; 00063 var $cur_ref_id; 00064 var $cmd; 00065 var $mode; 00066 var $ctrl; 00067 00072 function ilRepositoryGUI() 00073 { 00074 global $lng, $ilias, $tpl, $tree, $rbacsystem, $objDefinition, 00075 $_GET, $ilCtrl, $ilLog;; 00076 //var_dump($_SESSION['il_rep_clipboard']); 00077 $this->lng =& $lng; 00078 $this->ilias =& $ilias; 00079 $this->tpl =& $tpl; 00080 $this->tree =& $tree; 00081 $this->rbacsystem =& $rbacsystem; 00082 $this->objDefinition =& $objDefinition; 00083 00084 $this->ctrl =& $ilCtrl; 00085 00086 $this->creation_mode = false; 00087 00088 $this->ctrl->saveParameter($this, array("ref_id")); 00089 if (!ilUtil::isAPICall()) 00090 $this->ctrl->setReturn($this,""); 00091 00092 // determine current ref id and mode 00093 if (!empty($_GET["ref_id"]) || $this->ctrl->getCmd() == "showTree") 00094 { 00095 $this->cur_ref_id = $_GET["ref_id"]; 00096 } 00097 else 00098 { 00099 //echo "1-".$_SESSION["il_rep_ref_id"]."-"; 00100 if (!empty($_SESSION["il_rep_ref_id"]) && !empty($_GET["getlast"])) 00101 { 00102 $this->cur_ref_id = $_SESSION["il_rep_ref_id"]; 00103 //echo "2-".$this->cur_ref_id."-"; 00104 } 00105 else 00106 { 00107 $this->cur_ref_id = $this->tree->getRootId(); 00108 00109 if ($_GET["cmd"] != "" && $_GET["cmd"] != "frameset") 00110 { 00111 //echo "hhh"; 00112 $get_str = $post_str = ""; 00113 foreach($_GET as $key => $value) 00114 { 00115 $get_str.= "-$key:$value"; 00116 } 00117 foreach($_POST as $key => $value) 00118 { 00119 $post_str.= "-$key:$value"; 00120 } 00121 $ilLog->write("Repository: command called without ref_id.". 00122 "GET:".$get_str."-POST:".$post_str, $ilLog->WARNING); 00123 } 00124 $_GET = array(); 00125 $_POST = array(); 00126 $this->ctrl->setCmd("frameset"); 00127 } 00128 } 00129 //echo "<br>+".$_GET["ref_id"]."+"; 00130 if (!$tree->isInTree($this->cur_ref_id) && $this->ctrl->getCmd() != "showTree") 00131 { 00132 $this->cur_ref_id = $this->tree->getRootId(); 00133 00134 // check wether command has been called with 00135 // item that is not in tree 00136 if ($_GET["cmd"] != "" && $_GET["cmd"] != "frameset") 00137 { 00138 $get_str = $post_str = ""; 00139 foreach($_GET as $key => $value) 00140 { 00141 $get_str.= "-$key:$value"; 00142 } 00143 foreach($_POST as $key => $value) 00144 { 00145 $post_str.= "-$key:$value"; 00146 } 00147 $ilLog->write("Repository: command called with ref_id that is not in tree.". 00148 "GET:".$get_str."-POST:".$post_str, $ilLog->WARNING); 00149 } 00150 $_GET = array(); 00151 $_POST = array(); 00152 $this->ctrl->setCmd("frameset"); 00153 } 00154 00155 // set current repository view mode 00156 if (!empty($_GET["set_mode"])) 00157 { 00158 $_SESSION["il_rep_mode"] = $_GET["set_mode"]; 00159 if ($this->ilias->account->getId() != ANONYMOUS_USER_ID) 00160 { 00161 $this->ilias->account->writePref("il_rep_mode", $_GET["set_mode"]); 00162 } 00163 } 00164 00165 // get user setting 00166 if ($_SESSION["il_rep_mode"] == "") 00167 { 00168 if ($this->ilias->account->getId() != ANONYMOUS_USER_ID) 00169 { 00170 $_SESSION["il_rep_mode"] = $this->ilias->account->getPref("il_rep_mode"); 00171 } 00172 } 00173 00174 // if nothing set, get default view 00175 if ($_SESSION["il_rep_mode"] == "") 00176 { 00177 $_SESSION["il_rep_mode"] = $this->ilias->getSetting("default_repository_view"); 00178 } 00179 00180 $this->mode = ($_SESSION["il_rep_mode"] != "") 00181 ? $_SESSION["il_rep_mode"] 00182 : "flat"; 00183 00184 // store current ref id 00185 if ($this->ctrl->getCmd() != "showTree" && 00186 $rbacsystem->checkAccess("read", $this->cur_ref_id)) 00187 { 00188 $type = ilObject::_lookupType($this->cur_ref_id, true); 00189 if ($type == "cat" || $type == "grp" || $type == "crs" 00190 || $type == "root") 00191 { 00192 $_SESSION["il_rep_ref_id"] = $this->cur_ref_id; 00193 } 00194 } 00195 00196 $_GET["ref_id"] = $this->cur_ref_id; 00197 } 00198 00199 00203 function &executeCommand() 00204 { 00205 global $tree, $rbacsystem, $ilias, $lng; 00206 00207 // check creation mode 00208 // determined by "new_type" parameter 00209 $new_type = $_POST["new_type"] 00210 ? $_POST["new_type"] 00211 : $_GET["new_type"]; 00212 00213 if ($new_type != "") 00214 { 00215 $this->creation_mode = true; 00216 } 00217 00218 // handle frameset command 00219 $cmd = $this->ctrl->getCmd(); 00220 if (($cmd == "frameset" || $_GET["rep_frame"] == 1) && $_SESSION["il_rep_mode"] == "tree") 00221 { 00222 $next_class = ""; 00223 $cmd = "frameset"; 00224 } 00225 else if ($cmd == "frameset" && $_SESSION["il_rep_mode"] != "tree") 00226 { 00227 $this->ctrl->setCmd(""); 00228 $cmd = ""; 00229 } 00230 00231 // determine next class 00232 if ($cmd != "frameset") 00233 { 00234 if ($this->creation_mode) 00235 { 00236 $obj_type = $new_type; 00237 $class_name = $this->objDefinition->getClassName($obj_type); 00238 if (strtolower($class_name) != "user") 00239 { 00240 $next_class = strtolower("ilObj".$class_name."GUI"); 00241 } 00242 else 00243 { 00244 $next_class = $this->ctrl->getNextClass(); 00245 } 00246 } 00247 else if ((($next_class = $this->ctrl->getNextClass($this)) == "") 00248 || ($next_class == "ilrepositorygui" && $this->ctrl->getCmd() == "return")) 00249 { 00250 if ($cmd != "frameset" && $cmd != "showTree") 00251 { 00252 // get GUI of current object 00253 $obj_type = ilObject::_lookupType($this->cur_ref_id,true); 00254 $class_name = $this->objDefinition->getClassName($obj_type); 00255 $next_class = strtolower("ilObj".$class_name."GUI"); 00256 $this->ctrl->setCmdClass($next_class); 00257 if ($this->ctrl->getCmd() == "return") 00258 { 00259 $this->ctrl->setCmd(""); 00260 } 00261 } 00262 } 00263 } 00264 00265 // commands that are always handled by repository gui 00266 // to do: move to container 00267 //if ($cmd == "showTree" || $cmd == "linkSelector" || $cmd == "linkChilds") 00268 if ($cmd == "showTree") 00269 { 00270 $next_class = ""; 00271 } 00272 //echo "<br>cmd:$cmd:nextclass:$next_class:"; 00273 switch ($next_class) 00274 { 00275 //case "ilobjrootfoldergui": 00276 //case "ilobjcategorygui": 00277 //case "ilobjgroupgui": 00278 //case "ilobjcoursegui": 00279 //case "ilobjfilegui": 00280 //case "ilobjforumgui": 00281 //case "ilobjfoldergui": 00282 //case "ilobjilinccoursegui": 00283 //case "ilobjfilegui": 00284 00285 default: 00286 // forward all other classes to gui commands 00287 if ($next_class != "" && $next_class != "ilrepositorygui") 00288 { 00289 $class_path = $this->ctrl->lookupClassPath($next_class); 00290 //echo "<br>repositorygui:forwarding_to:".$next_class; 00291 //echo "<br>creation_mode:".$this->creation_mode.":"; 00292 // get gui class instance 00293 include_once($class_path); 00294 $class_name = $this->ctrl->getClassForClasspath($class_path); 00295 00296 if (!$this->creation_mode) 00297 { 00298 $this->gui_obj = new $class_name("", $this->cur_ref_id, true, false); 00299 } 00300 else 00301 { 00302 // dirty walkaround for ilinc classrooms which need passed the ref_id of the parent iLinc course 00303 if ($class_name == 'ilObjiLincClassroomGUI') 00304 { 00305 $this->gui_obj = new $class_name("", $this->cur_ref_id, true, false); 00306 } 00307 else 00308 { 00309 $this->gui_obj = new $class_name("", 0, true, false); 00310 } 00311 } 00312 //$this->gui_obj = new $class_name("", $this->cur_ref_id, true, false); 00313 00314 // special treatment for old admin compliance 00315 // to do: get rid of it... 00316 //$this->cmd_admin_compliance($cmd, false); 00317 00318 $tabs_out = ($new_type == "") 00319 ? true 00320 : false; 00321 00322 // forward command 00323 //if ($_GET["mode"] == "create" || $cmd == "linkSelector") 00324 //{ 00325 // $tabs_out = false; 00326 //} 00327 //$this->prepareOutput($tabs_out); 00328 00329 // get standard template 00330 // add repository items to $ilLocator 00331 //$this->prepareOutput($tabs_out); 00332 00333 $this->gui_obj->setCreationMode($this->creation_mode); 00334 $this->ctrl->setReturn($this, "return"); 00335 //echo "<br>forwarding-".$_GET["cmd"]."-"; 00336 $ret =& $this->ctrl->forwardCommand($this->gui_obj); 00337 $html = $this->gui_obj->getHTML(); 00338 if ($html != "") 00339 { 00340 $this->tpl->setVariable("OBJECTS", $html); 00341 } 00342 $this->tpl->show(); 00343 } 00344 else // 00345 { 00346 // process repository frameset 00347 if ($cmd == "frameset") 00348 { 00349 if ($_SESSION["il_rep_mode"] == "tree") 00350 { 00351 $this->frameset(); 00352 return; 00353 } 00354 $cmd = ""; 00355 $this->ctrl->setCmd(""); 00356 } 00357 00358 // process tree command 00359 if ($cmd == "showTree") 00360 { 00361 $this->showTree(); 00362 return; 00363 } 00364 00365 //if (!isset($obj_type)) 00366 //{ 00367 // $obj_type = ilObject::_lookupType($this->cur_ref_id,true); 00368 //} 00369 00370 // get GUI of current object 00371 //$class_name = $this->objDefinition->getClassName($obj_type); 00372 //$module = $this->objDefinition->getModule($obj_type); 00373 //$module_dir = ($module == "") ? "" : $module."/"; 00374 //$class_constr = "ilObj".$class_name."GUI"; 00375 //include_once("./".$module_dir."classes/class.ilObj".$class_name."GUI.php"); 00376 //$this->gui_obj = new $class_constr("", $this->cur_ref_id, true, false); 00377 00378 // execute repository cmd 00379 //if (empty($cmd)) 00380 //{ 00381 // if($obj_type == "crs" or $obj_type == 'fold' or $obj_type == 'grp' or 00382 // $obj_type == 'frm' or $obj_type == 'crsg') 00383 // { 00384 // $this->prepareOutput(); 00385 // $this->ctrl->forwardCommand($this->gui_obj); 00386 // $this->tpl->show(); 00387 // break; 00388 // } 00389 // else 00390 // { 00391 //echo "A-$cmd-$obj_type-"; 00392 $cmd = $this->ctrl->getCmd(""); 00393 // } 00394 //$next_class = ""; 00395 //} 00396 //echo "2-$cmd-$obj_type-"; 00397 // check read access for category 00398 if ($this->cur_ref_id > 0 && !$rbacsystem->checkAccess("read", $this->cur_ref_id)) 00399 { 00400 //echo "2"; 00401 $_SESSION["il_rep_ref_id"] = ""; 00402 $ilias->raiseError($lng->txt("permission_denied"), $ilias->error_obj->MESSAGE); 00403 $this->tpl->show(); 00404 } 00405 else 00406 { 00407 $this->cmd = $cmd; 00408 $this->$cmd(); 00409 } 00410 } 00411 break; 00412 } 00413 } 00414 00418 function frameset() 00419 { 00420 global $lng; 00421 00422 include_once("Services/Frameset/classes/class.ilFramesetGUI.php"); 00423 $fs_gui = new ilFramesetGUI(); 00424 00425 if ($_GET["rep_frame"] == 1) 00426 { 00427 // workaround for passing anchors (e.g. used in ilNoteGUI) 00428 $anchor = ($_GET["anchor"] != "") 00429 ? "#".$_GET["anchor"] 00430 : ""; 00431 $fs_gui->setMainFrameSource( 00432 str_replace("rep_frame", "rep_frame_done", $_SERVER["REQUEST_URI"]).$anchor); 00433 } 00434 else 00435 { 00436 $fs_gui->setMainFrameSource( 00437 "repository.php?getlast=true&ref_id=".$this->cur_ref_id); 00438 } 00439 $fs_gui->setSideFrameSource( 00440 "repository.php?cmd=showTree&ref_id=".$this->cur_ref_id); 00441 00442 $fs_gui->setSideFrameTitle($lng->txt("explorer_frame")); 00443 $fs_gui->setMainFrameTitle($lng->txt("repository_frame")); 00444 $fs_gui->setSideFrameName("tree"); 00445 $fs_gui->setMainFrameName("rep_content"); 00446 $fs_gui->setFramesetTitle($this->lng->txt("repository")); 00447 $fs_gui->show(); 00448 exit; 00449 } 00450 00454 //function prepareOutput($a_tabs_out = true) 00455 function prepareOutput() 00456 { 00457 // output objects 00458 //$this->tpl->getStandardTemplate(); 00459 //$this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html"); 00460 //$this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html"); 00461 00462 // output tabs 00463 //$this->setTabs(); 00464 00465 // output locator 00466 //$this->setLocator(); 00467 00468 // output message 00469 /* 00470 if ($this->message) 00471 { 00472 sendInfo($this->message); 00473 } 00474 00475 // display infopanel if something happened 00476 infoPanel(); 00477 00478 // set header 00479 //$this->setHeader($a_tabs_out); 00480 $this->setHeader();*/ 00481 } 00482 00483 00487 function showTree() 00488 { 00489 $this->tpl = new ilTemplate("tpl.main.html", true, true); 00490 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation()); 00491 00492 //$this->tpl = new ilTemplate("tpl.explorer.html", false, false); 00493 $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html"); 00494 $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false)); 00495 00496 include_once ("classes/class.ilRepositoryExplorer.php"); 00497 $exp = new ilRepositoryExplorer("repository.php?cmd=goto"); 00498 $exp->setExpandTarget("repository.php?cmd=showTree"); 00499 $exp->setTargetGet("ref_id"); 00500 00501 if ($_GET["repexpand"] == "") 00502 { 00503 $expanded = $this->tree->readRootId(); 00504 } 00505 else 00506 { 00507 $expanded = $_GET["repexpand"]; 00508 } 00509 00510 $exp->setExpand($expanded); 00511 00512 // build html-output 00513 $exp->setOutput(0); 00514 $output = $exp->getOutput(); 00515 00516 $this->tpl->setCurrentBlock("content"); 00517 //$this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("repository")); 00518 $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh")); 00519 $this->tpl->setVariable("EXPLORER", $output); 00520 //$this->tpl->setVariable("ACTION", "repository.php?repexpand=".$_GET["repexpand"]); 00521 $this->tpl->parseCurrentBlock(); 00522 //$this->tpl->show(true); 00523 $this->tpl->show(false); 00524 } 00525 00526 00530 function setHeader($a_tabs_out = true) 00531 { 00532 if ($this->cur_ref_id == $this->tree->getRootId()) 00533 { 00534 // todo -> done: header to cmd object 00535 //$this->tpl->setVariable("HEADER", $this->lng->txt("repository")); 00536 if ($a_tabs_out) 00537 { 00538 // todo -> done: subobjects to container object 00539 //$this->showPossibleSubObjects("root"); 00540 } 00541 } 00542 else 00543 { 00544 // todo -> done: header to cmd object 00545 //$this->tpl->setVariable("HEADER", $this->gui_obj->object->getTitle()); 00546 00547 // todo -> done: description to cmd object 00548 //$desc = ($this->gui_obj->object->getLongDescription()) 00549 // ? $this->gui_obj->object->getLongDescription() 00550 // : ""; 00551 //$desc = nl2br($desc); 00552 00553 //$this->tpl->setVariable("H_DESCRIPTION", $desc); 00554 //if ($a_tabs_out) 00555 //{ 00556 // $this->showPossibleSubObjects($this->gui_obj->object->getType()); 00557 //} 00558 } 00559 00560 // header icon 00561 // todo -> done: header icon to cmd object 00562 //$this->tpl->setCurrentBlock("header_image"); 00563 //$ic_type = ilObject::_lookupType($this->cur_ref_id, true); 00564 //$icon = ilUtil::getImagePath("icon_".$ic_type."_b.gif"); 00565 00566 // custom icon 00567 // todo -> done: custom header icon to cmd object 00568 //if ($this->ilias->getSetting("custom_icons") && 00569 // in_array($ic_type, array("cat","grp","crs"))) 00570 //{ 00571 // require_once("classes/class.ilContainer.php"); 00572 // if (($path = ilContainer::_lookupIconPath(ilObject::_lookupObjId($this->cur_ref_id), "big")) != "") 00573 // { 00574 // $icon = $path; 00575 // } 00576 //} 00577 00578 //$this->tpl->setVariable("IMG_HEADER", $icon); 00579 00580 //$this->tpl->parseCurrentBlock(); 00581 //$this->tpl->setCurrentBlock("content"); 00582 00583 // todo -> done: move upper icon to container 00584 //if ($this->cur_ref_id != $this->tree->getRootId() && $a_tabs_out && 00585 // ($this->gui_obj->object->getType() != "frm")) 00586 //{ 00587 // $par_id = $this->tree->getParentId($this->cur_ref_id); 00588 // $this->tpl->setCurrentBlock("top"); 00589 // $this->tpl->setVariable("LINK_TOP", "repository.php?ref_id=".$par_id); 00590 // $this->tpl->setVariable("IMG_TOP",ilUtil::getImagePath("ic_top.gif")); 00591 // $this->tpl->parseCurrentBlock(); 00592 //} 00593 00594 // todo -> done: move tree/flat icon to container 00595 /* 00596 if ($a_tabs_out && ($this->gui_obj->object->getType() != "frm")) 00597 { 00598 $this->setAdminTabs(); 00599 00600 $s_mode = ($_SESSION["il_rep_mode"] == "flat") 00601 ? "tree" 00602 : "flat"; 00603 $this->tpl->setCurrentBlock("tree_mode"); 00604 // $this->tpl->setVariable("LINK_MODE", "repository.php?cmd=frameset&set_mode=".$s_mode."&ref_id=".$this->cur_ref_id); 00605 $this->tpl->setVariable("IMG_TREE",ilUtil::getImagePath("ic_".$s_mode."view.gif")); 00606 $this->tpl->parseCurrentBlock(); 00607 } 00608 */ 00609 } 00610 00611 00615 function setAdminTabs() 00616 { 00617 // todo -> done: move tabs output to object 00618 /* 00619 if (is_object($this->gui_obj)) 00620 { 00621 $tabs_gui =& new ilTabsGUI(); 00622 00623 $this->gui_obj->getTabs($tabs_gui); 00624 // add info tab to all objects 00625 //$tabs_gui->addTarget("info_short",$this->ctrl->getLinkTarget($this->gui_obj, "info"), "info", get_class($this->gui_obj)); 00626 00627 // output tabs 00628 $this->tpl->setVariable("TABS", $tabs_gui->getHTML()); 00629 } 00630 */ 00631 } 00632 00638 /* 00639 function getVisibleOnly() 00640 { 00641 $this->visible_only_items = true; 00642 return "<a href=\"#visible_only_expl\">[*]</a>"; 00643 }*/ 00644 00649 /* 00650 function showVisibleOnlyMessage() 00651 { 00652 $this->tpl->setCurrentBlock("visible_items_message"); 00653 if ($this->ilias->account->getId() != ANONYMOUS_USER_ID) 00654 { 00655 $this->tpl->setVariable("VIS_ITEMS_MESSAGE", $this->lng->txt("no_access_item")); 00656 } 00657 else 00658 { 00659 $this->tpl->setVariable("VIS_ITEMS_MESSAGE", $this->lng->txt("no_access_item_public")); 00660 } 00661 $this->tpl->parseCurrentBlock(); 00662 }*/ 00663 00667 /* 00668 function setLocator() 00669 { 00670 global $ilias_locator; 00671 00672 00673 // special forum handling (forums should complete go to 00674 // a separate module and not use repository.php) 00675 00676 if ($this->gui_obj->object->getType() == "frm") 00677 { 00678 require_once("classes/class.ilForumLocatorGUI.php"); 00679 $frm_loc =& new ilForumLocatorGUI(); 00680 $frm_loc->setRefId($this->cur_ref_id); 00681 $frm_loc->setForum($frm); 00682 $frm_loc->display(); 00683 return; 00684 } 00685 00686 $a_tree =& $this->tree; 00687 $a_id = $this->cur_ref_id; 00688 00689 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html"); 00690 00691 $path = $a_tree->getPathFull($a_id); 00692 00693 // this is a stupid workaround for a bug in PEAR:IT 00694 $modifier = 1; 00695 00696 // ... and to make it more stupid ... 00697 if (!empty($_GET["obj_id"]) and $_GET['cmdClass'] != 'ilobjusergui' and $_GET['cmdClass'] != 'ilobjcategorygui') 00698 { 00699 $modifier = 0; 00700 } 00701 00702 // ### AA 03.11.10 added new locator GUI class ### 00703 $i = 1; 00704 */ 00705 /* possible deprecated 00706 if ($this->gui_obj->object->getType() != "grp" && ($_GET["cmd"] == "delete" || $_GET["cmd"] == "edit")) 00707 { 00708 unset($path[count($path) - 1]); 00709 }*/ 00710 /* 00711 foreach ($path as $key => $row) 00712 { 00713 if ($key < count($path) - $modifier) 00714 { 00715 $this->tpl->touchBlock("locator_separator"); 00716 } 00717 00718 $this->tpl->setCurrentBlock("locator_item"); 00719 if ($row["child"] != $a_tree->getRootId()) 00720 { 00721 $this->tpl->setVariable("ITEM", $row["title"]); 00722 } 00723 else 00724 { 00725 $this->tpl->setVariable("ITEM", $this->lng->txt("repository")); 00726 } 00727 00728 // NOT NICE 00729 if($row["type"] == "crs") 00730 { 00731 $this->ctrl->setParameterByClass("ilObjCourseGUI","ref_id",$row["child"]); 00732 $this->tpl->setVariable("LINK_ITEM",$this->ctrl->getLinkTargetByClass("ilObjCourseGUI")); 00733 } 00734 else 00735 { 00736 $this->tpl->setVariable("LINK_ITEM","repository.php?ref_id=".$row["child"]); 00737 } 00738 $this->tpl->parseCurrentBlock(); 00739 00740 $this->tpl->setCurrentBlock("locator"); 00741 00742 // ### AA 03.11.10 added new locator GUI class ### 00743 // navigate locator 00744 if ($row["child"] != $a_tree->getRootId()) 00745 { 00746 // $ilias_locator->navigate($i++,$row["title"],"repository.php?ref_id=".$row["child"],"bottom"); 00747 } 00748 else 00749 { 00750 // $ilias_locator->navigate($i++,$this->lng->txt("repository"),"repository.php?ref_id=".$row["child"],"bottom"); 00751 } 00752 } 00753 00754 $this->tpl->setVariable("TXT_LOCATOR",$debug.$this->lng->txt("locator")); 00755 $this->tpl->parseCurrentBlock(); 00756 } 00757 */ 00758 00759 00765 /* 00766 function showPossibleSubObjects($type) 00767 { 00768 $found = false; 00769 $cmd = ($this->cmd != "") 00770 ? $this->cmd 00771 : $this->ctrl->getCmd(); 00772 00773 if ($cmd != "" && $cmd != "showList" && $cmd != "render" 00774 && $cmd != "view") 00775 { 00776 return; 00777 } 00778 00779 $d = $this->objDefinition->getCreatableSubObjects($type); 00780 00781 if (count($d) > 0) 00782 { 00783 foreach ($d as $row) 00784 { 00785 $count = 0; 00786 if ($row["max"] > 0) 00787 { 00788 00789 //how many elements are present? 00790 for ($i=0; $i<count($this->data["ctrl"]); $i++) 00791 { 00792 if ($this->data["ctrl"][$i]["type"] == $row["name"]) 00793 { 00794 $count++; 00795 } 00796 } 00797 } 00798 00799 if ($row["max"] == "" || $count < $row["max"]) 00800 { 00801 if (in_array($row["name"], array("sahs", "alm", "hlm", "lm", "grp", "frm", "mep","crs", 00802 "cat", "glo", "dbk","exc", "qpl", "tst", "svy", "spl", "chat", 00803 "htlm","fold","linkr","file","icrs","icla","crsg",'webr'))) 00804 { 00805 if ($this->rbacsystem->checkAccess("create", $this->cur_ref_id, $row["name"])) 00806 { 00807 $subobj[] = $row["name"]; 00808 } 00809 } 00810 } 00811 } 00812 } 00813 00814 if (is_array($subobj)) 00815 { 00816 $this->tpl->parseCurrentBlock("add_commands"); 00817 $this->tpl->setVariable("H_FORMACTION", "repository.php?ref_id=".$this->cur_ref_id. 00818 "&cmd=post"); 00819 // possible subobjects 00820 $opts = ilUtil::formSelect("", "new_type", $subobj); 00821 $this->tpl->setVariable("SELECT_OBJTYPE_REPOS", $opts); 00822 $this->tpl->setVariable("BTN_NAME_REPOS", "create"); 00823 $this->tpl->setVariable("TXT_ADD_REPOS", $this->lng->txt("add")); 00824 $this->tpl->parseCurrentBlock(); 00825 } 00826 } 00827 */ 00828 00829 00830 /* // DEPRECATED !? 00831 function showActionSelect(&$subobj) 00832 { 00833 $actions = array("edit" => $this->lng->txt("edit"), 00834 "addToDesk" => $this->lng->txt("to_desktop"), 00835 "export" => $this->lng->txt("export")); 00836 00837 if (is_array($subobj)) 00838 { 00839 if (in_array("dbk",$subobj) or in_array("lm",$subobj)) 00840 { 00841 $this->tpl->setVariable("TPLPATH",$this->tpl->tplPath); 00842 00843 $this->tpl->setCurrentBlock("tbl_action_select"); 00844 $this->tpl->setVariable("SELECT_ACTION",ilUtil::formSelect("","action_type",$actions,false,true)); 00845 $this->tpl->setVariable("BTN_NAME","action"); 00846 $this->tpl->setVariable("BTN_VALUE",$this->lng->txt("submit")); 00847 $this->tpl->parseCurrentBlock(); 00848 } 00849 } 00850 } 00851 */ 00852 00853 // DEPRECATED? IF NOT-> MOVE TO CONTAINER, COURSE/FOLDER/GROUP WANTS TO 00854 // MAKE DECISIONS 00855 /* 00856 function addToDeskCourse() 00857 { 00858 global $tree; 00859 */ 00860 /*$tmp_obj =& $this->ilias->obj_factory->getInstanceByRefId($this->cur_ref_id); 00861 00862 while ($tmp_obj->getType() != 'crs') 00863 { 00864 $parent_ref_id = $tree->getParentId($tmp_obj->getRefId()); 00865 $tmp_obj =& $this->ilias->obj_factory->getInstanceByRefId($parent_ref_id); 00866 }*/ 00867 /* 00868 if ($_GET["item_ref_id"] and $_GET["type"]) 00869 { 00870 $this->ilias->account->addDesktopItem($_GET["item_ref_id"], $_GET["type"]); 00871 //$this->showList(); 00872 } 00873 else 00874 { 00875 if ($_POST["items"]) 00876 { 00877 foreach ($_POST["items"] as $item) 00878 { 00879 $tmp_obj_item =& $this->ilias->obj_factory->getInstanceByRefId($item); 00880 $this->ilias->account->addDesktopItem($item, $tmp_obj_item->getType()); 00881 unset($tmp_obj_item); 00882 } 00883 } 00884 //$this->showList(); 00885 } 00886 // include_once("./course/classes/class.ilObjCourseGUI.php"); 00887 //var_dump($_GET["item_ref_id"],$this->cur_ref_id);exit; 00888 // $this->gui_obj =& new ilObjCourseGUI("",$tmp_obj->getRefId(),true,false); 00889 00890 $this->prepareOutput(); 00891 $ret =& $this->gui_obj->viewObject(); 00892 $this->tpl->show(); 00893 } 00894 */ 00895 00899 function executeAdminCommand() 00900 { 00901 $cmd = $this->cmd; 00902 $tabs_out = true; 00903 00904 if ($cmd == "delete" || $cmd == "cancelDelete" || $cmd == "confirmedDelete" || 00905 $cmd == "create" || $cmd == "save" || $cmd=="importFile" || 00906 $cmd == "cloneAll" || $_GET["mode"] == "create" || 00907 $cmd == "linkSelector" || $cmd == "importVerifiedFile" || 00908 $cmd == "cancelImport" ) 00909 { 00910 $tabs_out = false; 00911 } 00912 $this->prepareOutput($tabs_out); 00913 00914 00915 $id = $this->cur_ref_id; 00916 $new_type = $_POST["new_type"] 00917 ? $_POST["new_type"] 00918 : $_GET["new_type"]; 00919 00920 if (!empty($new_type)) // creation 00921 { 00922 if (!$this->rbacsystem->checkAccess("create", $this->cur_ref_id, $new_type)) 00923 { 00924 $this->ilias->raiseError($this->lng->txt("msg_no_perm_create_object1")." ". 00925 $this->lng->txt($new_type."_a")." ".$this->lng->txt("msg_no_perm_create_object2"), 00926 $this->ilias->error_obj->MESSAGE); 00927 } 00928 else 00929 { 00930 $class_name = $this->objDefinition->getClassName($new_type); 00931 $module = $this->objDefinition->getModule($new_type); 00932 $module_dir = ($module == "") ? "" : $module."/"; 00933 $class_constr = "ilObj".$class_name."GUI"; 00934 include_once("./".$module_dir."classes/class.ilObj".$class_name."GUI.php"); 00935 00936 $obj =& new $class_constr($data, $id, true, false); 00937 00938 $method = $cmd."Object"; 00939 //$obj->setReturnLocation("save", "repository.php?ref_id=".$this->cur_ref_id); 00940 $obj->setReturnLocation("cancel", "repository.php?ref_id=".$this->cur_ref_id); 00941 $obj->setReturnLocation("addTranslation", 00942 "repository.php?cmd=".$_GET["mode"]."&entry=0&mode=session&ref_id=".$this->cur_ref_id."&new_type=".$_GET["new_type"]); 00943 00944 $obj->setFormAction("save","repository.php?cmd=post&mode=$cmd&ref_id=".$this->cur_ref_id."&new_type=".$new_type); 00945 00946 //$this->ctrl->setCmdClass(strtolower("Obj".$class_name."GUI")); 00947 //$this->ctrl->setCmd($method); 00948 //$this->ctrl->forwardCommand($obj); 00949 $obj->$method(); 00950 } 00951 } 00952 else // all other commands 00953 { 00954 00955 /* $obj =& ilObjectFactory::getInstanceByRefId($this->cur_ref_id); 00956 $class_name = $objDefinition->getClassName($obj->getType()); 00957 $module = $objDefinition->getModule($obj->getType()); 00958 $module_dir = ($module == "") 00959 ? "" 00960 : $module."/"; 00961 00962 $class_constr = "ilObj".$class_name."GUI"; 00963 include_once("./".$module_dir."classes/class.ilObj".$class_name."GUI.php"); 00964 $obj_gui =& new $class_constr("", $this->cur_ref_id, true, false);*/ 00965 00966 $this->cmd_admin_compliance($cmd); 00967 00968 } 00969 00970 $this->tpl->show(); 00971 } 00972 00973 00977 /* 00978 function cmd_admin_compliance($cmd, $execute = true) 00979 { 00980 return; 00981 // object creation 00982 $new_type = $_POST["new_type"] 00983 ? $_POST["new_type"] 00984 : $_GET["new_type"]; 00985 if (!empty($new_type)) 00986 { 00987 if (!$this->rbacsystem->checkAccess("create", $this->cur_ref_id, $new_type)) 00988 { 00989 $this->ilias->raiseError($this->lng->txt("msg_no_perm_create_object1")." ". 00990 $this->lng->txt($new_type."_a")." ".$this->lng->txt("msg_no_perm_create_object2"), 00991 $this->ilias->error_obj->MESSAGE); 00992 } 00993 else 00994 { 00995 //$this->gui_obj->setReturnLocation("save", "repository.php?ref_id=".$this->cur_ref_id); 00996 $this->gui_obj->setReturnLocation("cancel", "repository.php?ref_id=".$this->cur_ref_id); 00997 $this->gui_obj->setReturnLocation("addTranslation", 00998 "repository.php?cmd=".$_GET["mode"]."&entry=0&mode=session&ref_id=".$this->cur_ref_id."&new_type=".$_GET["new_type"]); 00999 01000 $this->gui_obj->setFormAction("save","repository.php?cmd=post&mode=$cmd&ref_id=".$this->cur_ref_id."&new_type=".$new_type); 01001 } 01002 } 01003 01004 // to do: check all these commands! 01005 01006 // other commands 01007 switch($cmd) 01008 { 01009 case "cut": 01010 $_POST["cmd"]["cut"] = "cut"; 01011 $_POST["id"] = ($_GET["item_ref_id"] != "") 01012 ? array($_GET["item_ref_id"]) 01013 : $_POST["rep_item_id"]; 01014 $this->gui_obj->setReturnLocation("cut", "repository.php?ref_id=".$this->cur_ref_id); 01015 break; 01016 01017 case "link": 01018 $_POST["cmd"]["link"] = "link"; 01019 $_POST["id"] = ($_GET["item_ref_id"] != "") 01020 ? array($_GET["item_ref_id"]) 01021 : $_POST["rep_item_id"]; 01022 $this->gui_obj->setReturnLocation("link", "repository.php?ref_id=".$this->cur_ref_id); 01023 break; 01024 01025 case "delete": 01026 $_POST["id"] = ($_GET["item_ref_id"] != "") 01027 ? array($_GET["item_ref_id"]) 01028 : $_POST["rep_item_id"]; 01029 $this->gui_obj->setFormAction("delete", "repository.php?cmd=post&ref_id=".$this->cur_ref_id); 01030 if ($execute) 01031 { 01032 $this->gui_obj->deleteObject(); 01033 } 01034 break; 01035 01036 case "cancelDelete": 01037 $this->gui_obj->setReturnLocation("cancelDelete", "repository.php?ref_id=".$this->cur_ref_id); 01038 if ($execute) 01039 { 01040 $this->gui_obj->cancelDeleteObject(); 01041 } 01042 break; 01043 01044 case "confirmedDelete": 01045 //$node = $this->tree->getNodeData($this->cur_ref_id); 01046 $this->gui_obj->setReturnLocation("confirmedDelete", "repository.php?ref_id=".$this->cur_ref_id); 01047 if ($execute) 01048 { 01049 $this->gui_obj->confirmedDeleteObject(); 01050 } 01051 break; 01052 01053 case "edit": 01054 $node = $this->tree->getNodeData($this->cur_ref_id); 01055 $_POST["id"] = array($this->cur_ref_id); 01056 $_GET["type"] = $this->gui_obj->object->getType(); 01057 $this->gui_obj->setFormAction("update", "repository.php?cmd=post&mode=$cmd&ref_id=".$this->cur_ref_id); 01058 if ($execute) 01059 { 01060 $this->gui_obj->editObject(); 01061 } 01062 break; 01063 01064 case "cancel": 01065 $node = $this->tree->getNodeData($this->cur_ref_id); 01066 //$this->gui_obj->setReturnLocation("cancel", "repository.php?ref_id=".$node["parent"]); 01067 if ($execute) 01068 { 01069 $this->gui_obj->cancelObject(true); 01070 } 01071 break; 01072 01073 case "update": 01074 $node = $this->tree->getNodeData($this->cur_ref_id); 01075 //$this->gui_obj->setReturnLocation("update", "repository.php?ref_id=".$node["parent"]); 01076 if ($execute) 01077 { 01078 $this->gui_obj->updateObject(); 01079 } 01080 break; 01081 01082 case "clear": 01083 $this->gui_obj->setReturnLocation("clear", "repository.php?ref_id=".$this->cur_ref_id); 01084 if ($execute) 01085 { 01086 $this->gui_obj->clearObject(); 01087 } 01088 break; 01089 01090 case "paste": 01091 $this->gui_obj->setReturnLocation("paste", "repository.php?ref_id=".$this->cur_ref_id); 01092 if ($execute) 01093 { 01094 $this->gui_obj->pasteObject(); 01095 } 01096 break; 01097 01098 case "addTranslation": 01099 $this->gui_obj->setReturnLocation("addTranslation", 01100 "repository.php?cmd=".$_GET["mode"]."&entry=0&mode=session&ref_id=".$this->cur_ref_id); 01101 if ($execute) 01102 { 01103 $this->gui_obj->addTranslationObject(); 01104 } 01105 break; 01106 01107 case "sendfile": 01108 // PAYMENT STUFF 01109 // check if object is purchased 01110 include_once './payment/classes/class.ilPaymentObject.php'; 01111 include_once './classes/class.ilSearch.php'; 01112 01113 if(!ilPaymentObject::_hasAccess($_GET['ref_id'])) 01114 { 01115 ilUtil::redirect('./payment/start_purchase.php?ref_id='.$_GET['ref_id']); 01116 } 01117 if(!ilSearch::_checkParentConditions($_GET['ref_id'])) 01118 { 01119 $this->ilias->raiseError($this->lng->txt('access_denied'),$ilias->error_obj->WARNING); 01120 } 01121 $this->gui_obj->object->sendfile($_GET["hist_id"]); 01122 break; 01123 } 01124 } 01125 */ 01126 01127 //todo: check all these commands 01128 01129 /* 01130 function save() 01131 { 01132 $this->executeAdminCommand(); 01133 } 01134 01135 function create() 01136 { 01137 $this->executeAdminCommand(); 01138 } 01139 01140 function importFile() 01141 { 01142 $this->executeAdminCommand(); 01143 } 01144 01145 function importVerifiedFile() 01146 { 01147 $this->executeAdminCommand(); 01148 } 01149 01150 function cloneAll() 01151 { 01152 $this->executeAdminCommand(); 01153 } 01154 01155 function import() 01156 { 01157 $this->executeAdminCommand(); 01158 } 01159 01160 function cancel() 01161 { 01162 $this->executeAdminCommand(); 01163 } 01164 01165 function cancelImport() 01166 { 01167 $this->executeAdminCommand(); 01168 } 01169 01170 function delete() 01171 { 01172 $this->executeAdminCommand(); 01173 } 01174 01175 function cancelDelete() 01176 { 01177 $this->executeAdminCommand(); 01178 } 01179 01180 function confirmedDelete() 01181 { 01182 $this->executeAdminCommand(); 01183 } 01184 01185 function addTranslation() 01186 { 01187 $this->executeAdminCommand(); 01188 } 01189 01190 function sendfile() 01191 { 01192 $this->executeAdminCommand(); 01193 } 01194 01195 function edit() 01196 { 01197 $this->executeAdminCommand(); 01198 } 01199 01200 function clear() 01201 { 01202 $this->executeAdminCommand(); 01203 } 01204 01205 function paste() 01206 { 01207 $this->executeAdminCommand(); 01208 } 01209 01210 function update() 01211 { 01212 $this->executeAdminCommand(); 01213 } 01214 */ 01215 01216 /* copy and link selector deprecated! 01217 function copySelector() 01218 { 01219 if(is_array($_POST["cmd"])) 01220 { 01221 $_SESSION["copy_new_type"] = $_POST["new_type"]; 01222 } 01223 if($_POST['new_type'] == 'cat') 01224 { 01225 $this->lng->loadLanguageModule('crs'); 01226 01227 sendInfo($this->lng->txt('crs_copy_cat_not_allowed'),true); 01228 $this->ctrl->redirect($this); 01229 } 01230 01231 01232 include_once ("classes/class.ilRepositoryCopySelector.php"); 01233 01234 $this->prepareOutput(); 01235 $this->tpl->setCurrentBlock("content"); 01236 $this->tpl->addBlockFile("OBJECTS", "objects", "tpl.rep_copy_selector.html"); 01237 01238 sendInfo($this->lng->txt("select_object_to_copy")); 01239 01240 $exp = new ilRepositoryCopySelector($this->ctrl->getLinkTarget($this,'copySelector')); 01241 $exp->setExpand($_GET["rep_copy_expand"] ? $_GET["rep_copy_expand"] : $this->tree->readRootId()); 01242 $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'copySelector')); 01243 $exp->setTargetGet("ref_id"); 01244 $exp->setRefId($this->cur_ref_id); 01245 $exp->addFilter($_SESSION["copy_new_type"]); 01246 $exp->setSelectableType($_SESSION["copy_new_type"]); 01247 01248 // build html-output 01249 $exp->setOutput(0); 01250 01251 $this->tpl->setCurrentBlock("objects"); 01252 $this->tpl->setVariable("EXPLORER",$exp->getOutput()); 01253 $this->tpl->parseCurrentBlock(); 01254 $this->tpl->show(); 01255 } 01256 01257 function linkSelector() 01258 { 01259 if(is_array($_POST["cmd"])) 01260 { 01261 $_SESSION["link_new_type"] = $_POST["new_type"]; 01262 } 01263 if($_POST['new_type'] == 'cat' or $_POST['new_type'] == 'grp' or $_POST['new_type'] == 'crs' or 01264 $_POST['new_type'] == 'fold') 01265 { 01266 $this->lng->loadLanguageModule('crs'); 01267 01268 sendInfo($this->lng->txt('crs_container_link_not_allowed'),true); 01269 ilUtil::redirect('repository.php?ref_id='.$this->cur_ref_id); 01270 } 01271 01272 01273 include_once ("classes/class.ilRepositoryLinkSelector.php"); 01274 01275 $this->prepareOutput(false); 01276 $this->tpl->setCurrentBlock("content"); 01277 $this->tpl->addBlockFile("OBJECTS", "objects", "tpl.rep_copy_selector.html"); 01278 01279 sendInfo($this->lng->txt("select_object_to_link")); 01280 01281 $exp = new ilRepositoryLinkSelector($this->ctrl->getLinkTarget($this,'linkSelector')); 01282 $exp->setExpand($_GET["rep_link_expand"] ? $_GET["rep_link_expand"] : $this->tree->readRootId()); 01283 $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'linkSelector')); 01284 $exp->setTargetGet("ref_id"); 01285 $exp->setRefId($this->cur_ref_id); 01286 $exp->addFilter($_SESSION["link_new_type"]); 01287 $exp->setSelectableType($_SESSION["link_new_type"]); 01288 01289 // build html-output 01290 $exp->setOutput(0); 01291 01292 $this->tpl->setCurrentBlock("objects"); 01293 $this->tpl->setVariable("EXPLORER",$exp->getOutput()); 01294 $this->tpl->parseCurrentBlock(); 01295 $this->tpl->show(); 01296 } 01297 */ 01298 01299 /* todo: move to container 01300 function linkChilds() 01301 { 01302 if($_GET['source_id']) 01303 { 01304 $this->linkObject($this->cur_ref_id,(int) $_GET['source_id']); 01305 01306 sendInfo($this->lng->txt('linked_object'),true); 01307 ilUtil::redirect("./repository.php?ref_id=".$this->cur_ref_id); 01308 } 01309 01310 01311 } 01312 01313 function copyChilds() 01314 { 01315 global $objDefinition; 01316 01317 $this->prepareOutput(); 01318 $this->tpl->setCurrentBlock("content"); 01319 $this->tpl->addBlockFile("OBJECTS", "objects", "tpl.rep_copy_childs.html"); 01320 01321 if(!count($this->tree->getFilteredChilds(array('rolf'),(int) $_GET["source_id"]))) 01322 { 01323 $tmp_target =& ilObjectFactory::getInstanceByRefId($this->cur_ref_id); 01324 $tmp_source =& ilObjectFactory::getInstanceByRefId((int) $_GET["source_id"]); 01325 01326 $info = $this->lng->txt("copy").": '".$tmp_source->getTitle()."' ". 01327 $this->lng->txt("copy_to")." '".$tmp_target->getTitle()."' ?"; 01328 sendInfo($info); 01329 01330 $this->tpl->setCurrentBlock("confirm"); 01331 $this->tpl->setVariable("CMD_CONFIRM_CANCEL",'cancel'); 01332 $this->tpl->setVariable("TXT_CONFIRM_CANCEL",$this->lng->txt("cancel")); 01333 $this->tpl->setVariable("CMD_CONFIRM_COPY",'performCopy'); 01334 $this->tpl->setVariable("TXT_CONFIRM_COPY",$this->lng->txt("copy")); 01335 $this->tpl->parseCurrentBlock(); 01336 01337 unset($tmp_source); 01338 unset($tmp_target); 01339 } 01340 else 01341 { 01342 // OBJECT is grp,crs or folder 01343 $tmp_source =& ilObjectFactory::getInstanceByRefId((int) $_GET["source_id"]); 01344 $sub_types = $this->tree->getSubTreeTypes((int) $_GET["source_id"],array('rolf')); 01345 01346 foreach($sub_types as $type) 01347 { 01348 $pos_actions = $objDefinition->getActions($type); 01349 01350 $actions = array(); 01351 if($objDefinition->allowLink($type)) 01352 { 01353 $actions['link'] = $this->lng->txt("link"); 01354 } 01355 #if(isset($pos_actions['copy'])) 01356 if(1) 01357 { 01358 $actions['copy'] = $this->lng->txt("copy"); 01359 } 01360 if($type == 'grp' or $type == 'frm') 01361 { 01362 $actions['no_content'] = $this->lng->txt('crs_no_content'); 01363 } 01364 01365 01366 $this->tpl->setCurrentBlock("object_options"); 01367 $this->tpl->setVariable("OBJECT_TYPE",$this->lng->txt("obj_".$type)); 01368 $this->tpl->setVariable("SELECT_OBJ",ilUtil::formSelect('copy',"action[$type]",$actions,false,true)); 01369 $this->tpl->parseCurrentBlock(); 01370 } 01371 01372 $this->tpl->setCurrentBlock("container"); 01373 $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt("cancel")); 01374 $this->tpl->setVariable("CMD_SUBMIT",'performCopy'); 01375 $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt("copy")); 01376 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath("icon_".$tmp_source->getType()."_b.gif")); 01377 $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_".$tmp_source->getType())); 01378 $this->tpl->setVariable("TITLE",$this->lng->txt("options_for_subobjects")); 01379 } 01380 01381 $this->ctrl->setParameterByClass('ilrepositorygui','source_id',(int) $_GET['source_id']); 01382 $this->tpl->setVariable("COPY_ACTION",$this->ctrl->getFormAction($this)); 01383 $this->tpl->show(); 01384 } 01385 */ 01386 01387 /* move to 01388 function performCopy() 01389 { 01390 if(!count($this->tree->getFilteredChilds(array('rolf'),(int) $_GET["source_id"]))) 01391 { 01392 $this->copyObject($this->cur_ref_id,(int) $_GET["source_id"]); 01393 } 01394 else 01395 { 01396 if(in_array("link",$_POST["action"])) 01397 { 01398 if(!$this->checkDuplicateAccess($_POST["action"],$_GET["source_id"])) 01399 { 01400 sendInfo($this->lng->txt("no_access_link_object"),true); 01401 01402 $this->ctrl->redirect($this,''); 01403 } 01404 } 01405 // call recursive copy link method 01406 $this->duplicate($_POST["action"],$this->cur_ref_id,(int) $_GET["source_id"]); 01407 } 01408 sendInfo($this->lng->txt("copied_object"),true); 01409 ilUtil::redirect("./repository.php?ref_id=".$this->cur_ref_id); 01410 } 01411 01412 function duplicate($post,$a_target,$a_source) 01413 { 01414 $stop_recursion = false; 01415 01416 $tmp_object =& ilObjectFactory::getInstanceByRefId($a_source); 01417 $type = $tmp_object->getType(); 01418 01419 switch($post[$type]) 01420 { 01421 case "copy": 01422 $new_ref = $this->copyObject($a_target,$a_source); 01423 break; 01424 case "link": 01425 $new_ref = $this->linkObject($a_target,$a_source); 01426 break; 01427 case "no_content": 01428 switch($type) 01429 { 01430 case 'grp': 01431 $stop_recursion = true; 01432 $new_ref = $this->copyObject($a_target,$a_source); 01433 break; 01434 01435 case 'frm': 01436 $new_ref = $this->copyObject($a_target,$a_source,false); 01437 break; 01438 } 01439 break; 01440 01441 default: 01442 echo "ilRepositoryGUI:: duplicate(): not possible"; 01443 } 01444 01445 if($stop_recursion) 01446 { 01447 return true; 01448 } 01449 foreach($this->tree->getFilteredChilds(array('rolf'),$a_source) as $child) 01450 { 01451 $this->duplicate($post,$new_ref,$child["child"]); 01452 } 01453 return true; 01454 } 01455 01456 function copyObject($a_target,$a_source,$a_with_content = true) 01457 { 01458 $tmp_source =& ilObjectFactory::getInstanceByRefId($a_source); 01459 01460 if($a_with_content) 01461 { 01462 $new_ref = $tmp_source->ilClone($a_target); 01463 } 01464 else 01465 { 01466 $new_ref = $tmp_source->ilClone($a_target,false); 01467 } 01468 unset($tmp_source); 01469 01470 return $new_ref; 01471 } 01472 01473 function linkObject($a_target,$a_source) 01474 { 01475 $tmp_source =& ilObjectFactory::getInstanceByRefId($a_source); 01476 01477 $new_ref = $tmp_source->createReference(); 01478 01479 $this->tree->insertNode($new_ref,$a_target); 01480 $tmp_source->setPermissions($new_ref); 01481 $tmp_source->initDefaultRoles(); 01482 01483 return $new_ref; 01484 } 01485 function checkDuplicateAccess($a_types,$a_source_id) 01486 { 01487 foreach($this->tree->getSubTree($this->tree->getNodeData($a_source_id)) as $node) 01488 { 01489 if($node["type"] == 'rolf') 01490 { 01491 continue; 01492 } 01493 if($a_types["$node[type]"] == 'link') 01494 { 01495 if(!$this->rbacsystem->checkAccess('write',$node["child"])) 01496 { 01497 return false; 01498 } 01499 } 01500 } 01501 return true; 01502 } 01503 01504 /* 01505 function addToClipboard() 01506 { 01507 // check preconditions (dirty implementation, should merged with linkObject & cutObject in ilObjectGUI) 01508 // CHECK LINK OPERATION 01509 if ($_GET['act'] == 'link') 01510 { 01511 if (!$this->rbacsystem->checkAccess('delete',$_GET['item_ref_id'])) 01512 { 01513 $no_cut[] = $ref_id; 01514 } 01515 01516 $object =& $this->ilias->obj_factory->getInstanceByRefId($_GET['item_ref_id']); 01517 01518 if (!$this->objDefinition->allowLink($object->getType())) 01519 { 01520 $no_link[] = $object->getType(); 01521 } 01522 01523 // NO ACCESS 01524 if (count($no_cut)) 01525 { 01526 $this->ilias->raiseError($this->lng->txt("msg_no_perm_link")." ". 01527 implode(',',$no_cut),$this->ilias->error_obj->MESSAGE); 01528 } 01529 01530 if (count($no_link)) 01531 { 01532 $no_link = array_unique($no_link); 01533 01534 foreach ($no_link as $type) 01535 { 01536 $txt_objs[] = $this->lng->txt("objs_".$type); 01537 } 01538 01539 $this->ilias->raiseError(implode(', ',$txt_objs)." ".$this->lng->txt("msg_obj_no_link"),$this->ilias->error_obj->MESSAGE); 01540 } 01541 01542 $message = "msg_link_clipboard"; 01543 } 01544 // CHECK CUT OPERATION 01545 elseif ($_GET['act'] == 'cut') 01546 { 01547 // FOR ALL OBJECTS THAT SHOULD BE COPIED 01548 // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES 01549 $node_data = $this->tree->getNodeData($_GET['item_ref_id']); 01550 $subtree_nodes = $this->tree->getSubTree($node_data); 01551 01552 $all_node_data[] = $node_data; 01553 $all_subtree_nodes[] = $subtree_nodes; 01554 01555 // CHECK DELETE PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE 01556 foreach ($subtree_nodes as $node) 01557 { 01558 if (!$this->rbacsystem->checkAccess('delete',$node["ref_id"])) 01559 { 01560 $no_cut[] = $node["ref_id"]; 01561 } 01562 } 01563 01564 // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'delete' 01565 if (count($no_cut)) 01566 { 01567 $this->ilias->raiseError($this->lng->txt("msg_no_perm_cut")." ".implode(',',$this->getTitlesByRefId($no_cut)), 01568 $this->ilias->error_obj->MESSAGE); 01569 } 01570 01571 $message = "msg_cut_clipboard"; 01572 } 01573 01574 // clear clipboard (only one object is possible for now) 01575 $_SESSION['il_rep_clipboard'] = ""; 01576 01577 // all okay. store selected object in clipboard 01578 $_SESSION['il_rep_clipboard'][] = array('ref_id' => $_GET['item_ref_id'],'act' => $_GET['act']); 01579 sendInfo($this->lng->txt($message),true); 01580 $this->showList(); 01581 } 01582 */ 01583 01584 } // END class.ilRepository 01585 01586 01587 ?>