00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00033 class ilObjectGUI
00034 {
00035 const COPY_WIZARD_NEEDS_PAGE = 1;
00036
00042 var $ilias;
00043
00049 var $objDefinition;
00050
00056 var $tpl;
00057
00063 var $tree;
00064
00070 var $lng;
00071
00077 var $data;
00078
00084 var $object;
00085 var $ref_id;
00086 var $obj_id;
00087 var $maxcount;
00088 var $formaction;
00089 var $return_location;
00090 var $target_frame;
00091
00092 var $tab_target_script;
00093 var $actions;
00094 var $sub_objects;
00095 var $omit_locator = false;
00096
00104 function ilObjectGUI($a_data, $a_id = 0, $a_call_by_reference = true, $a_prepare_output = true)
00105 {
00106 global $ilias, $objDefinition, $tpl, $tree, $ilCtrl, $ilErr, $lng, $ilTabs;
00107
00108 $this->tabs_gui =& $ilTabs;
00109
00110 if (!isset($ilErr))
00111 {
00112 $ilErr = new ilErrorHandling();
00113 $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK,array($ilErr,'errorHandler'));
00114 }
00115 else
00116 {
00117 $this->ilErr =& $ilErr;
00118 }
00119
00120 $this->ilias =& $ilias;
00121 $this->objDefinition =& $objDefinition;
00122 $this->tpl =& $tpl;
00123 $this->html = "";
00124 $this->ctrl =& $ilCtrl;
00125
00126 $params = array("ref_id");
00127
00128 if (!$a_call_by_reference)
00129 {
00130 $params = array("ref_id","obj_id");
00131 }
00132
00133 $this->ctrl->saveParameter($this, $params);
00134
00135 $this->lng =& $lng;
00136 $this->tree =& $tree;
00137 $this->formaction = array();
00138 $this->return_location = array();
00139 $this->target_frame = array();
00140 $this->actions = "";
00141 $this->sub_objects = "";
00142
00143 $this->data = $a_data;
00144 $this->id = $a_id;
00145 $this->call_by_reference = $a_call_by_reference;
00146 $this->prepare_output = $a_prepare_output;
00147 $this->creation_mode = false;
00148
00149 $this->ref_id = ($this->call_by_reference) ? $this->id : $_GET["ref_id"];
00150 $this->obj_id = ($this->call_by_reference) ? $_GET["obj_id"] : $this->id;
00151
00152 if ($this->id != 0)
00153 {
00154 $this->link_params = "ref_id=".$this->ref_id;
00155 }
00156
00157
00158 $this->assignObject();
00159
00160
00161 if (is_object($this->object))
00162 {
00163 if ($this->call_by_reference && $this->ref_id = $_GET["ref_id"])
00164 {
00165 $this->ctrl->setContext($this->object->getId(),
00166 $this->object->getType());
00167 }
00168 }
00169
00170
00171
00172
00173
00174 if ($a_prepare_output)
00175 {
00176 $this->prepareOutput();
00177 }
00178 }
00179
00180
00184 function &executeCommand()
00185 {
00186 global $rbacsystem;
00187
00188 $next_class = $this->ctrl->getNextClass($this);
00189 $cmd = $this->ctrl->getCmd();
00190
00191 switch($next_class)
00192 {
00193 default:
00194 $this->prepareOutput();
00195 if(!$cmd)
00196 {
00197 $cmd = "view";
00198 }
00199 $cmd .= "Object";
00200 $this->$cmd();
00201
00202 break;
00203 }
00204
00205 return true;
00206 }
00207
00208
00212 function withReferences()
00213 {
00214 return $this->call_by_reference;
00215 }
00216
00223 function setCreationMode($a_mode = true)
00224 {
00225 $this->creation_mode = $a_mode;
00226 }
00227
00231 function getCreationMode()
00232 {
00233 return $this->creation_mode;
00234 }
00235
00236 function assignObject()
00237 {
00238
00239
00240 if ($this->id != 0)
00241 {
00242 if ($this->call_by_reference)
00243 {
00244 $this->object =& $this->ilias->obj_factory->getInstanceByRefId($this->id);
00245 }
00246 else
00247 {
00248 $this->object =& $this->ilias->obj_factory->getInstanceByObjId($this->id);
00249 }
00250 }
00251 }
00252
00256 function prepareOutput()
00257 {
00258 global $ilLocator, $tpl;
00259
00260 $this->tpl->getStandardTemplate();
00261
00262 if (strtolower($_GET["baseClass"]) == "iladministrationgui")
00263 {
00264 $this->addAdminLocatorItems();
00265 $tpl->setLocator();
00266
00267 ilUtil::sendInfo();
00268 ilUtil::infoPanel();
00269
00270 $this->setTitleAndDescription();
00271
00272 if ($this->getCreationMode() != true)
00273 {
00274 $this->setAdminTabs();
00275 $this->showUpperIcon();
00276 }
00277
00278 return false;
00279 }
00280
00281 $this->setLocator();
00282
00283 ilUtil::sendInfo();
00284 ilUtil::infoPanel();
00285
00286
00287
00288 if ($this->getCreationMode() == true)
00289 {
00290
00291 $obj_type = ilObject::_lookupType($_GET["ref_id"],true);
00292 $class_name = $this->objDefinition->getClassName($obj_type);
00293 $class = strtolower("ilObj".$class_name."GUI");
00294 $class_path = $this->ctrl->lookupClassPath($class);
00295 include_once($class_path);
00296 $class_name = $this->ctrl->getClassForClasspath($class_path);
00297
00298 $this->parent_gui_obj = new $class_name("", $_GET["ref_id"], true, false);
00299 $this->parent_gui_obj->setTitleAndDescription();
00300 }
00301 else
00302 {
00303
00304 $this->setTitleAndDescription();
00305
00306
00307 $this->setTabs();
00308 $this->showUpperIcon();
00309 }
00310
00311 return true;
00312 }
00313
00314
00318 function setTitleAndDescription()
00319 {
00320 $this->tpl->setTitle($this->object->getTitle());
00321 $this->tpl->setDescription($this->object->getLongDescription());
00322 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif"), $this->lng->txt("obj_" . $this->object->getType()));
00323 }
00324
00325 function showUpperIcon()
00326 {
00327 global $tree, $tpl, $objDefinition;
00328
00329 if ($this->object->getRefId() == "")
00330 {
00331 return;
00332 }
00333
00334 if (strtolower($_GET["baseClass"]) == "iladministrationgui")
00335 {
00336 if ($this->object->getRefId() != ROOT_FOLDER_ID &&
00337 $this->object->getRefId() != SYSTEM_FOLDER_ID)
00338 {
00339 $par_id = $tree->getParentId($this->object->getRefId());
00340 $obj_type = ilObject::_lookupType($par_id,true);
00341 $class_name = $objDefinition->getClassName($obj_type);
00342 $class = strtolower("ilObj".$class_name."GUI");
00343 $this->ctrl->setParameterByClass($class, "ref_id", $par_id);
00344 $tpl->setUpperIcon($this->ctrl->getLinkTargetByClass($class, "view"));
00345 $this->ctrl->clearParametersByClass($class);
00346 }
00347
00348 else if ($this->object->getRefId() == ROOT_FOLDER_ID)
00349 {
00350 $this->ctrl->setParameterByClass("iladministrationgui", "ref_id", "");
00351 $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
00352 $tpl->setUpperIcon($this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
00353 ilFrameTargetInfo::_getFrame("MainContent"));
00354 $this->ctrl->clearParametersByClass("iladministrationgui");
00355 }
00356 }
00357 else
00358 {
00359 if ($this->object->getRefId() != ROOT_FOLDER_ID &&
00360 $this->object->getRefId() != SYSTEM_FOLDER_ID &&
00361 $_GET["obj_id"] == "")
00362 {
00363 if (defined("ILIAS_MODULE"))
00364 {
00365 $prefix = "../";
00366 }
00367 $par_id = $tree->getParentId($this->object->getRefId());
00368 $tpl->setUpperIcon($prefix."repository.php?cmd=frameset&ref_id=".$par_id,
00369 ilFrameTargetInfo::_getFrame("MainContent"));
00370 }
00371 }
00372 }
00373
00374
00379 function setTabs()
00380 {
00381 $this->getTabs($this->tabs_gui);
00382 }
00383
00388 function setAdminTabs()
00389 {
00390 $this->getAdminTabs($this->tabs_gui);
00391 }
00392
00396 function getAdminTabs(&$tabs_gui)
00397 {
00398 global $rbacsystem;
00399
00400 if ($_GET["admin_mode"] == "repository")
00401 {
00402 $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
00403 $tabs_gui->setBackTarget($this->lng->txt("administration"),
00404 $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
00405 ilFrameTargetInfo::_getFrame("MainContent"));
00406 $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "repository");
00407 }
00408
00409 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00410 {
00411 $tabs_gui->addTarget("view",
00412 $this->ctrl->getLinkTarget($this, "view"), array("", "view"), get_class($this));
00413 }
00414
00415 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00416 {
00417 $tabs_gui->addTarget("perm_settings",
00418 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), "", "ilpermissiongui");
00419 }
00420
00421 if ($this->tree->getSavedNodeData($this->object->getRefId()))
00422 {
00423 $tabs_gui->addTarget("trash",
00424 $this->ctrl->getLinkTarget($this, "trash"), "trash", get_class($this));
00425 }
00426 }
00427
00428
00429 function getHTML()
00430 {
00431 return $this->html;
00432 }
00433
00434
00441 function setActions($a_actions = "")
00442 {
00443 if (is_array($a_actions))
00444 {
00445 foreach ($a_actions as $name => $lng)
00446 {
00447 $this->actions[$name] = array("name" => $name, "lng" => $lng);
00448 }
00449 }
00450 else
00451 {
00452 $this->actions = "";
00453 }
00454 }
00455
00462 function setSubObjects($a_sub_objects = "")
00463 {
00464 if (is_array($a_sub_objects))
00465 {
00466 foreach ($a_sub_objects as $name => $options)
00467 {
00468 $this->sub_objects[$name] = array("name" => $name, "max" => $options["max"]);
00469 }
00470 }
00471 else
00472 {
00473 $this->sub_objects = "";
00474 }
00475 }
00476
00485 function setLocator()
00486 {
00487 global $ilLocator, $tpl;
00488
00489 if ($this->omit_locator)
00490 {
00491 return;
00492 }
00493
00494
00495
00496
00497 $ref_id = ($_GET["ref_id"] != "")
00498 ? $_GET["ref_id"]
00499 : $this->object->getRefId();
00500 $ilLocator->addRepositoryItems($ref_id);
00501
00502 if(!$this->creation_mode)
00503 {
00504 $this->addLocatorItems();
00505 }
00506
00507
00508 if ($_GET["admin_mode"] == "" &&
00509 strtolower($this->ctrl->getCmdClass()) == "ilobjrolegui")
00510 {
00511 $this->ctrl->setParameterByClass("ilobjrolegui",
00512 "rolf_ref_id", $_GET["rolf_ref_id"]);
00513 $this->ctrl->setParameterByClass("ilobjrolegui",
00514 "obj_id", $_GET["obj_id"]);
00515 $ilLocator->addItem($this->lng->txt("role"),
00516 $this->ctrl->getLinkTargetByClass(array("ilpermissiongui",
00517 "ilobjrolegui"), "perm"));
00518 }
00519
00520 $tpl->setLocator();
00521 }
00522
00527 function addLocatorItems()
00528 {
00529 }
00530
00531 function omitLocator($a_omit = true)
00532 {
00533 $this->omit_locator = $a_omit;
00534 }
00535
00540 function addAdminLocatorItems()
00541 {
00542 global $ilLocator;
00543
00544 if ($_GET["admin_mode"] == "settings")
00545 {
00546 $ilLocator->addItem($this->lng->txt("administration"),
00547 $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
00548 ilFrameTargetInfo::_getFrame("MainContent"));
00549 if ($this->object->getRefId() != SYSTEM_FOLDER_ID)
00550 {
00551 $ilLocator->addItem($this->object->getTitle(),
00552 $this->ctrl->getLinkTarget($this, "view"));
00553 }
00554 }
00555 else
00556 {
00557 $this->ctrl->setParameterByClass("iladministrationgui",
00558 "ref_id", "");
00559 $this->ctrl->setParameterByClass("iladministrationgui",
00560 "admin_mode", "settings");
00561
00562
00563
00564 $this->ctrl->clearParametersByClass("iladministrationgui");
00565 $ilLocator->addAdministrationItems();
00566 }
00567
00568 }
00569
00575 function undeleteObject()
00576 {
00577 global $rbacsystem, $log;
00578
00579
00580 if (!isset($_POST["trash_id"]))
00581 {
00582 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00583 }
00584
00585 foreach ($_POST["trash_id"] as $id)
00586 {
00587 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($id);
00588
00589 if (!$rbacsystem->checkAccess('create',$_GET["ref_id"],$obj_data->getType()))
00590 {
00591 $no_create[] = $id;
00592 }
00593 }
00594
00595 if (count($no_create))
00596 {
00597 $this->ilias->raiseError($this->lng->txt("msg_no_perm_paste")." ".
00598 implode(',',$no_create),$this->ilias->error_obj->MESSAGE);
00599 }
00600 foreach ($_POST["trash_id"] as $id)
00601 {
00602
00603 $this->insertSavedNodes($id,$_GET["ref_id"],-(int) $id);
00604
00605 $saved_tree = new ilTree(-(int)$id);
00606 $saved_tree->deleteTree($saved_tree->getNodeData($id));
00607
00608 }
00609
00610
00611
00612 ilUtil::sendInfo($this->lng->txt("msg_undeleted"),true);
00613
00614 $this->ctrl->redirect($this, "view");
00615 }
00616
00626 function insertSavedNodes($a_source_id,$a_dest_id,$a_tree_id)
00627 {
00628 global $rbacadmin, $rbacreview, $log;
00629
00630 $this->tree->insertNode($a_source_id,$a_dest_id, IL_LAST_NODE, true);
00631
00632
00633 $log->write("ilObjectGUI::insertSavedNodes(), restored ref_id $a_source_id from trash");
00634
00635
00636 $parentRoles = $rbacreview->getParentRoleIds($a_dest_id);
00637 $obj =& $this->ilias->obj_factory->getInstanceByRefId($a_source_id);
00638
00639 foreach ($parentRoles as $parRol)
00640 {
00641 $ops = $rbacreview->getOperationsOfRole($parRol["obj_id"], $obj->getType(), $parRol["parent"]);
00642 $rbacadmin->grantPermission($parRol["obj_id"],$ops,$a_source_id);
00643 }
00644
00645 $saved_tree = new ilTree($a_tree_id);
00646 $childs = $saved_tree->getChilds($a_source_id);
00647
00648 foreach ($childs as $child)
00649 {
00650 $this->insertSavedNodes($child["child"],$a_source_id,$a_tree_id);
00651 }
00652 }
00653
00663 function confirmedDeleteObject()
00664 {
00665 include_once './payment/classes/class.ilPaymentObject.php';
00666
00667 global $rbacsystem, $rbacadmin, $log;
00668
00669
00670
00671
00672
00673
00674 if (!isset($_SESSION["saved_post"]))
00675 {
00676 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00677 }
00678
00679
00680 foreach ($_SESSION["saved_post"] as $id)
00681 {
00682 if($this->tree->isDeleted($id))
00683 {
00684 $log->write(__METHOD__.': Object with ref_id: '.$id.' already deleted.');
00685 ilUtil::sendInfo('Object already deleted.',true);
00686 $this->ctrl->returnToParent($this);
00687 }
00688
00689
00690 $node_data = $this->tree->getNodeData($id);
00691 $subtree_nodes = $this->tree->getSubTree($node_data);
00692
00693 $all_node_data[] = $node_data;
00694 $all_subtree_nodes[] = $subtree_nodes;
00695
00696
00697 foreach ($subtree_nodes as $node)
00698 {
00699 if($node['type'] == 'rolf')
00700 {
00701 continue;
00702 }
00703 if (!$rbacsystem->checkAccess('delete',$node["child"]))
00704 {
00705 $not_deletable[] = $node["child"];
00706 $perform_delete = false;
00707 }
00708 else if(ilPaymentObject::_isBuyable($node['child']))
00709 {
00710 $buyable[] = $node['child'];
00711 $perform_delete = false;
00712 }
00713 }
00714 }
00715
00716
00717 if (count($not_deletable))
00718 {
00719 $not_deletable = implode(',',$not_deletable);
00720 session_unregister("saved_post");
00721 ilUtil::sendInfo($this->lng->txt("msg_no_perm_delete")." ".$not_deletable."<br/>".$this->lng->txt("msg_cancel"),true);
00722
00723 $this->ctrl->returnToParent($this);
00724 }
00725
00726 if(count($buyable))
00727 {
00728 foreach($buyable as $id)
00729 {
00730 $tmp_object =& ilObjectFactory::getInstanceByRefId($id);
00731
00732 $titles[] = $tmp_object->getTitle();
00733 }
00734 $title_str = implode(',',$titles);
00735
00736 ilUtil::sendInfo($this->lng->txt('msg_obj_not_deletable_sold').' '.$title_str,true);
00737
00738 $_POST['id'] = $_SESSION['saved_post'];
00739 $this->deleteObject(true);
00740
00741 return false;
00742 }
00743
00744
00745 if (!$all_node_data[0]["type"])
00746 {
00747
00748 if ($rbacsystem->checkAccess('delete',$_GET["ref_id"]))
00749 {
00750 foreach($_SESSION["saved_post"] as $id)
00751 {
00752 $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
00753 $obj->delete();
00754
00755
00756 $log->write("ilObjectGUI::confirmedDeleteObject(), deleted obj_id ".$obj->getId().
00757 ", type: ".$obj->getType().", title: ".$obj->getTitle());
00758 }
00759 }
00760 else
00761 {
00762 unset($_SESSION["saved_post"]);
00763 ilUtil::sendInfo($this->lng->txt("no_perm_delete")."<br/>".$this->lng->txt("msg_cancel"),true);
00764 $this->ctrl->returnToParent($this);
00765 }
00766 }
00767 else
00768 {
00769
00770 foreach ($_SESSION["saved_post"] as $id)
00771 {
00772 if($this->tree->isDeleted($id))
00773 {
00774 $log->write(__METHOD__.': Object with ref_id: '.$id.' already deleted.');
00775 ilUtil::sendInfo('Object already deleted.',true);
00776 $this->ctrl->returnToParent($this);
00777 }
00778
00779
00780 $subnodes = $this->tree->getSubtree($this->tree->getNodeData($id));
00781
00782 foreach ($subnodes as $subnode)
00783 {
00784 $rbacadmin->revokePermission($subnode["child"]);
00785
00786 $affected_users = ilUtil::removeItemFromDesktops($subnode["child"]);
00787
00788
00789
00790 }
00791
00792 if(!$this->tree->saveSubTree($id, true))
00793 {
00794 $log->write(__METHOD__.': Object with ref_id: '.$id.' already deleted.');
00795 ilUtil::sendInfo('Object already deleted.',true);
00796 $this->ctrl->returnToParent($this);
00797 }
00798
00799
00800 $log->write("ilObjectGUI::confirmedDeleteObject(), moved ref_id ".$id.
00801 " to trash");
00802
00803
00804 $affected_users = ilUtil::removeItemFromDesktops($id);
00805
00806
00807
00808 }
00809
00810
00811 }
00812
00813 if ($this->ilias->getSetting('enable_trash'))
00814 {
00815
00816 ilUtil::sendInfo($this->lng->txt("info_deleted"),true);
00817
00818 $this->ctrl->returnToParent($this);
00819 }
00820 else
00821 {
00822 $_POST["trash_id"] = $_SESSION["saved_post"];
00823
00824 $this->removeFromSystemObject();
00825 }
00826 }
00827
00833 function cancelDeleteObject()
00834 {
00835 session_unregister("saved_post");
00836
00837 ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
00838
00839 $this->ctrl->returnToParent($this);
00840
00841 }
00842
00848 function removeFromSystemObject()
00849 {
00850 global $rbacsystem, $log;
00851
00852
00853 if (!isset($_POST["trash_id"]))
00854 {
00855 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00856 }
00857
00858
00859
00860
00861 foreach ($_POST["trash_id"] as $id)
00862 {
00863
00864 $saved_tree = new ilTree(-(int)$id);
00865 $node_data = $saved_tree->getNodeData($id);
00866 $subtree_nodes = $saved_tree->getSubTree($node_data);
00867
00868
00869 $checked[] = -(int) $id;
00870
00871
00872 $this->removeDeletedNodes($id,$checked);
00873
00874 foreach ($subtree_nodes as $node)
00875 {
00876 $node_obj =& $this->ilias->obj_factory->getInstanceByRefId($node["ref_id"]);
00877
00878
00879 $log->write("ilObjectGUI::removeFromSystemObject(), delete obj_id: ".$node_obj->getId().
00880 ", ref_id: ".$node_obj->getRefId().", type: ".$node_obj->getType().", ".
00881 "title: ".$node_obj->getTitle());
00882
00883 $node_obj->delete();
00884 }
00885
00886
00887 #$this->tree->deleteTree($node_data);
00888
00889 $saved_tree->deleteTree($node_data);
00890
00891
00892 $log->write("ilObjectGUI::removeFromSystemObject(), deleted tree, tree_id: ".$node_data["tree"].
00893 ", child: ".$node_data["child"]);
00894
00895 }
00896
00897 ilUtil::sendInfo($this->lng->txt("msg_removed"),true);
00898
00899 $this->ctrl->returnToParent($this);
00900 }
00901
00910 function removeDeletedNodes($a_node_id, $a_checked, $a_delete_objects = true)
00911 {
00912 global $log, $ilDB;
00913
00914
00915
00916 $q = "SELECT tree FROM tree WHERE parent= ".
00917 $ilDB->quote($a_node_id)." AND tree < 0";
00918
00919 $r = $this->ilias->db->query($q);
00920
00921 while($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
00922 {
00923
00924 if (!in_array($row->tree,$a_checked))
00925 {
00926 $deleted_tree = new ilTree($row->tree);
00927 $a_checked[] = $row->tree;
00928
00929 $row->tree = $row->tree * (-1);
00930 $del_node_data = $deleted_tree->getNodeData($row->tree);
00931 $del_subtree_nodes = $deleted_tree->getSubTree($del_node_data);
00932
00933 $this->removeDeletedNodes($row->tree,$a_checked);
00934
00935 if ($a_delete_objects)
00936 {
00937 foreach ($del_subtree_nodes as $node)
00938 {
00939 $node_obj =& $this->ilias->obj_factory->getInstanceByRefId($node["ref_id"]);
00940
00941
00942 $log->write("ilObjectGUI::removeDeletedNodes(), delete obj_id: ".$node_obj->getId().
00943 ", ref_id: ".$node_obj->getRefId().", type: ".$node_obj->getType().", ".
00944 "title: ".$node_obj->getTitle());
00945
00946 $node_obj->delete();
00947 }
00948 }
00949
00950 $this->tree->deleteTree($del_node_data);
00951
00952
00953 $log->write("ilObjectGUI::removeDeletedNodes(), deleted tree, tree_id: ".$del_node_data["tree"].
00954 ", child: ".$del_node_data["child"]);
00955 }
00956 }
00957
00958 return true;
00959 }
00960
00966 function createObject()
00967 {
00968 global $rbacsystem;
00969
00970 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
00971
00972 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
00973 {
00974 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00975 }
00976 else
00977 {
00978
00979 $data = array();
00980 $data["fields"] = array();
00981 $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
00982 $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
00983
00984 $this->getTemplateFile("edit",$new_type);
00985
00986
00987 $this->tpl->setCurrentBlock("img");
00988 $this->tpl->setVariable("TYPE_IMG",
00989 ilUtil::getImagePath("icon_".$new_type.".gif"));
00990 $this->tpl->setVariable("ALT_IMG",
00991 $this->lng->txt("obj_".$new_type));
00992 $this->tpl->parseCurrentBlock();
00993
00994 foreach ($data["fields"] as $key => $val)
00995 {
00996 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
00997 $this->tpl->setVariable(strtoupper($key), $val);
00998
00999 if ($this->prepare_output)
01000 {
01001 $this->tpl->parseCurrentBlock();
01002 }
01003 }
01004 $this->ctrl->setParameter($this, "new_type", $new_type);
01005 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "save"));
01006 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
01007 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01008 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
01009 $this->tpl->setVariable("CMD_SUBMIT", "save");
01010 $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
01011 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01012 }
01013 }
01014
01015
01021 function cancelObject($in_rep = false)
01022 {
01023 session_unregister("saved_post");
01024
01025 ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
01026
01027
01028 $return_location = $_GET["cmd_return_location"];
01029
01030
01031
01032
01033
01034 $this->ctrl->returnToParent($this);
01035
01036
01037
01038
01039
01040
01041 }
01042
01048 function saveObject()
01049 {
01050 global $rbacsystem, $objDefinition;
01051
01052 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
01053
01054
01055 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
01056 {
01057 $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
01058 }
01059
01060 $module = $objDefinition->getModule($_GET["new_type"]);
01061 $module_dir = ($module == "")
01062 ? ""
01063 : $module."/";
01064
01065
01066 $class_name = "ilObj".$objDefinition->getClassName($_GET["new_type"]);
01067 include_once($module_dir."classes/class.".$class_name.".php");
01068 $newObj = new $class_name();
01069 $newObj->setType($_GET["new_type"]);
01070 $newObj->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
01071 $newObj->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
01072 $newObj->create();
01073 $newObj->createReference();
01074 $newObj->putInTree($_GET["ref_id"]);
01075 $newObj->setPermissions($_GET["ref_id"]);
01076
01077
01078 return $newObj;
01079 }
01080
01081
01087 function importObject()
01088 {
01089 global $rbacsystem;
01090
01091
01092 if (!$rbacsystem->checkAccess('write', $_GET["ref_id"], $_POST["new_type"]))
01093 {
01094 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->WARNING);
01095 }
01096
01097 $imp_obj =$this->objDefinition->getImportObjects($this->object->getType());
01098
01099 if (!in_array($_POST["new_type"], $imp_obj))
01100 {
01101 $this->ilias->raiseError($this->lng->txt("no_import_available").
01102 " ".$this->lng->txt("obj_".$_POST["new_type"]),
01103 $this->ilias->error_obj->MESSAGE);
01104 }
01105
01106
01107 }
01108
01109
01115 function editObject()
01116 {
01117 global $rbacsystem;
01118
01119 if (!$rbacsystem->checkAccess("write", $this->ref_id))
01120 {
01121 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
01122 }
01123
01124 $fields = array();
01125
01126 if ($_SESSION["error_post_vars"])
01127 {
01128
01129 $fields["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
01130 $fields["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
01131 }
01132 else
01133 {
01134 $fields["title"] = ilUtil::prepareFormOutput($this->object->getTitle());
01135 $fields["desc"] = ilUtil::stripSlashes($this->object->getLongDescription());
01136 }
01137
01138 $this->displayEditForm($fields);
01139 }
01140
01147 function displayEditForm($fields)
01148 {
01149 $this->getTemplateFile("edit");
01150
01151 foreach ($fields as $key => $val)
01152 {
01153 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
01154 $this->tpl->setVariable(strtoupper($key), $val);
01155
01156 }
01157
01158
01159 if (!$this->call_by_reference)
01160 {
01161 $this->ctrl->setParameter($this, "obj_id", $this->obj_id);
01162 }
01163
01164 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "update"));
01165 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->object->getType()."_edit"));
01166 $this->tpl->setVariable("TARGET", $this->getTargetFrame("update"));
01167 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01168 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
01169 $this->tpl->setVariable("CMD_SUBMIT", "update");
01170 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01171
01172 }
01173
01174
01180 function updateObject()
01181 {
01182 $this->object->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
01183 $this->object->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
01184 $this->update = $this->object->update();
01185
01186 ilUtil::sendInfo($this->lng->txt("msg_obj_modified"),true);
01187
01188 $this->afterUpdate();
01189 }
01190
01191 function afterUpdate()
01192 {
01193 $this->ctrl->redirect($this);
01194 }
01195
01201 function permObject()
01202 {
01203 include_once './classes/class.ilPermissionGUI.php';
01204 $perm_gui =& new ilPermissionGUI($this);
01205
01206
01207 $this->ctrl->current_node = 1;
01208 $this->ctrl->setCmd('perm');
01209 $ret =& $this->ctrl->forwardCommand($perm_gui);
01210
01211 return true;
01212 }
01213
01222 function getFormAction($a_cmd, $a_formaction ="")
01223 {
01224 if ($this->formaction[$a_cmd] != "")
01225 {
01226 return $this->formaction[$a_cmd];
01227 }
01228 else
01229 {
01230 return $a_formaction;
01231 }
01232 }
01233
01242 function setFormAction($a_cmd, $a_formaction)
01243 {
01244 $this->formaction[$a_cmd] = $a_formaction;
01245 }
01246
01254 function getReturnLocation($a_cmd, $a_location ="")
01255 {
01256 if ($this->return_location[$a_cmd] != "")
01257 {
01258 return $this->return_location[$a_cmd];
01259 }
01260 else
01261 {
01262 return $a_location;
01263 }
01264 }
01265
01273 function setReturnLocation($a_cmd, $a_location)
01274 {
01275
01276 $this->return_location[$a_cmd] = $a_location;
01277 }
01278
01286 function getTargetFrame($a_cmd, $a_target_frame = "")
01287 {
01288 if ($this->target_frame[$a_cmd] != "")
01289 {
01290 return $this->target_frame[$a_cmd];
01291 }
01292 elseif (!empty($a_target_frame))
01293 {
01294 return "target=\"".$a_target_frame."\"";
01295 }
01296 else
01297 {
01298 return;
01299 }
01300 }
01301
01309 function setTargetFrame($a_cmd, $a_target_frame)
01310 {
01311 $this->target_frame[$a_cmd] = "target=\"".$a_target_frame."\"";
01312 }
01313
01319 function permSaveObject()
01320 {
01321 include_once './classes/class.ilPermissionGUI.php';
01322 $perm_gui =& new ilPermissionGUI($this);
01323
01324
01325 $this->ctrl->current_node = 1;
01326 $this->ctrl->setCmd('permSave');
01327 $ret =& $this->ctrl->forwardCommand($perm_gui);
01328
01329 return true;
01330 }
01331
01337 function displayList()
01338 {
01339 include_once "./Services/Table/classes/class.ilTableGUI.php";
01340
01341
01342 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
01343
01344 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
01345
01346 $num = 0;
01347
01348 if (!$this->call_by_reference)
01349 {
01350 $this->ctrl->setParameter($this, "obj_id", $this->obj_id);
01351 }
01352 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01353
01354
01355 $tbl = new ilTableGUI();
01356
01357
01358 $tbl->setTitle($this->object->getTitle(),"icon_".$this->object->getType().".gif",
01359 $this->lng->txt("obj_".$this->object->getType()));
01360 $tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
01361
01362 foreach ($this->data["cols"] as $val)
01363 {
01364 $header_names[] = $this->lng->txt($val);
01365 }
01366
01367 $tbl->setHeaderNames($header_names);
01368
01369
01370
01371 $header_params = $this->ctrl->getParameterArray($this, "view");
01372 $tbl->setHeaderVars($this->data["cols"],$header_params);
01373 $tbl->setColumnWidth(array("15","15","75%","25%"));
01374
01375
01376 $tbl->setOrderColumn($_GET["sort_by"]);
01377 $tbl->setOrderDirection($_GET["sort_order"]);
01378 $tbl->setLimit($_GET["limit"]);
01379 $tbl->setOffset($_GET["offset"]);
01380 $tbl->setMaxCount($this->maxcount);
01381
01382 $this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
01383
01384
01385 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01386
01387 if (!empty($this->data["data"][0]))
01388 {
01389
01390 for ($i=0; $i < count($this->data["data"]); $i++)
01391 {
01392 $data = $this->data["data"][$i];
01393 $ctrl = $this->data["ctrl"][$i];
01394
01395
01396 $css_row = ilUtil::switchColor($i+1,"tblrow2","tblrow1");
01397
01398
01399 if (!$this->objDefinition->hasCheckbox($ctrl["type"]) or $ctrl["obj_id"] == SYSTEM_ROLE_ID or $ctrl["obj_id"] == SYSTEM_USER_ID or $ctrl["obj_id"] == ANONYMOUS_ROLE_ID)
01400 {
01401 $this->tpl->touchBlock("empty_cell");
01402 }
01403 else
01404 {
01405
01406 if ($ctrl["type"] == "usr" or $ctrl["type"] == "role" or $ctrl["type"] == "rolt")
01407 {
01408 $link_id = $ctrl["obj_id"];
01409 }
01410 else
01411 {
01412 $link_id = $ctrl["ref_id"];
01413 }
01414
01415
01416 $this->ids[] = $link_id;
01417
01418 $this->tpl->setCurrentBlock("checkbox");
01419 $this->tpl->setVariable("CHECKBOX_ID", $link_id);
01420 $this->tpl->setVariable("CSS_ROW", $css_row);
01421 $this->tpl->parseCurrentBlock();
01422 }
01423
01424 $this->tpl->setCurrentBlock("table_cell");
01425 $this->tpl->setVariable("CELLSTYLE", "tblrow1");
01426 $this->tpl->parseCurrentBlock();
01427
01428 foreach ($data as $key => $val)
01429 {
01430
01431 $obj_type = ilObject::_lookupType($ctrl["ref_id"],true);
01432 $class_name = $this->objDefinition->getClassName($obj_type);
01433 $class = strtolower("ilObj".$class_name."GUI");
01434 $this->ctrl->setParameterByClass($class, "ref_id", $ctrl["ref_id"]);
01435 $this->ctrl->setParameterByClass($class, "obj_id", $ctrl["obj_id"]);
01436 $link = $this->ctrl->getLinkTargetByClass($class, "view");
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452 if ($key == "name" || $key == "title")
01453 {
01454 $name_field = explode("#separator#",$val);
01455 }
01456
01457 if ($key == "title" || $key == "name" || $key == "type")
01458 {
01459 $this->tpl->setCurrentBlock("begin_link");
01460 $this->tpl->setVariable("LINK_TARGET", $link);
01461
01462 $this->tpl->parseCurrentBlock();
01463 $this->tpl->touchBlock("end_link");
01464 }
01465
01466
01467 if (($key == "title" || $key == "name") and is_array(($_SESSION["clipboard"])))
01468 {
01469
01470 if (in_array($ctrl["ref_id"],$_SESSION["clipboard"]["ref_ids"]))
01471 {
01472 switch($_SESSION["clipboard"]["cmd"])
01473 {
01474 case "cut":
01475 $name_field[0] = "<del>".$name_field[0]."</del>";
01476 break;
01477
01478 case "copy":
01479 $name_field[0] = "<font color=\"green\">+</font> ".$name_field[0];
01480 break;
01481
01482 case "link":
01483 $name_field[0] = "<font color=\"black\"><</font> ".$name_field[0];
01484 break;
01485 }
01486 }
01487 }
01488
01489 $this->tpl->setCurrentBlock("text");
01490
01491 if ($key == "type")
01492 {
01493 $val = ilUtil::getImageTagByType($val,$this->tpl->tplPath);
01494 }
01495
01496 if ($key == "name" || $key == "title")
01497 {
01498 $this->tpl->setVariable("TEXT_CONTENT", $name_field[0]);
01499
01500 $this->tpl->setCurrentBlock("subtitle");
01501 $this->tpl->setVariable("DESC", ilUtil::shortenText($name_field[1],MAXLENGTH_OBJ_DESC,true));
01502 $this->tpl->parseCurrentBlock();
01503 }
01504 else
01505 {
01506 $this->tpl->setVariable("TEXT_CONTENT", $val);
01507 }
01508
01509 $this->tpl->parseCurrentBlock();
01510
01511 $this->tpl->setCurrentBlock("table_cell");
01512 $this->tpl->parseCurrentBlock();
01513
01514 }
01515
01516 $this->tpl->setCurrentBlock("tbl_content");
01517 $this->tpl->setVariable("CSS_ROW", $css_row);
01518 $this->tpl->parseCurrentBlock();
01519 }
01520 }
01521 else
01522 {
01523 $tbl->disable("header");
01524 $tbl->disable("footer");
01525
01526 $this->tpl->setCurrentBlock("text");
01527
01528
01529
01530
01531
01532 $this->tpl->setVariable("CSS_ROW", "tblrow1");
01533 $this->tpl->setVariable("TEXT_CONTENT",
01534 " ");
01535 $this->tpl->parseCurrentBlock();
01536 }
01537
01538 $this->showActions(true);
01539
01540
01541 $tbl->render();
01542 }
01543
01549 function viewObject()
01550 {
01551 global $rbacsystem;
01552
01553 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
01554 {
01555 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01556 }
01557
01558
01559 $this->objectList = array();
01560 $this->data["data"] = array();
01561 $this->data["ctrl"] = array();
01562 $this->data["cols"] = array("", "type", "title", "last_change");
01563
01564 $childs = $this->tree->getChilds($_GET["ref_id"], $_GET["order"], $_GET["direction"]);
01565
01566 foreach ($childs as $key => $val)
01567 {
01568
01569 if (!$rbacsystem->checkAccess("visible",$val["ref_id"]))
01570 {
01571 continue;
01572 }
01573
01574
01575 if ($this->objDefinition->getDevMode($val["type"]))
01576 {
01577 continue;
01578 }
01579
01580
01581 if ($val["type"] == "adm")
01582 {
01583 continue;
01584 }
01585
01586
01587 $this->data["data"][] = array(
01588 "type" => $val["type"],
01589 "title" => $val["title"]."#separator#".$val["desc"],
01590
01591 "last_change" => $val["last_update"],
01592 "ref_id" => $val["ref_id"]
01593 );
01594
01595
01596
01597 }
01598
01599 $this->maxcount = count($this->data["data"]);
01600
01601 $this->data["data"] = ilUtil::sortArray($this->data["data"],$_GET["sort_by"],$_GET["sort_order"]);
01602 $this->data["data"] = array_slice($this->data["data"],$_GET["offset"],$_GET["limit"]);
01603
01604
01605 foreach ($this->data["data"] as $key => $val)
01606 {
01607 $this->data["ctrl"][$key] = array(
01608 "type" => $val["type"],
01609 "ref_id" => $val["ref_id"]
01610 );
01611
01612 unset($this->data["data"][$key]["ref_id"]);
01613 $this->data["data"][$key]["last_change"] = ilFormat::formatDate($this->data["data"][$key]["last_change"]);
01614 }
01615
01616 $this->displayList();
01617 }
01618
01626 function deleteObject($a_error = false)
01627 {
01628 if ($_GET["item_ref_id"] != "")
01629 {
01630 $_POST["id"] = array($_GET["item_ref_id"]);
01631 }
01632
01633 if (!isset($_POST["id"]))
01634 {
01635 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01636 }
01637
01638
01639 $_SESSION["saved_post"] = $_POST["id"];
01640
01641 unset($this->data);
01642 $this->data["cols"] = array("type", "title", "last_change");
01643
01644 foreach ($_POST["id"] as $id)
01645 {
01646
01647
01648
01649
01650 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($id);
01651
01652
01653
01654
01655
01656
01657 $this->data["data"]["$id"] = array(
01658 "type" => $obj_data->getType(),
01659 "title" => $obj_data->getTitle()."#separator#".$obj_data->getDescription()." ",
01660 "last_update" => $obj_data->getLastUpdateDate()
01661 );
01662 }
01663
01664 $this->data["buttons"] = array( "confirmedDelete" => $this->lng->txt("confirm"),
01665 "cancelDelete" => $this->lng->txt("cancel"));
01666
01667 $this->getTemplateFile("confirm");
01668
01669 if(!$a_error)
01670 {
01671 $msg = $this->lng->txt("info_delete_sure");
01672
01673 if (!$this->ilias->getSetting('enable_trash'))
01674 {
01675 $msg .= "<br/>".$this->lng->txt("info_delete_warning_no_trash");
01676 }
01677
01678 ilUtil::sendInfo($msg);
01679 }
01680
01681 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01682
01683
01684 foreach ($this->data["cols"] as $key)
01685 {
01686 $this->tpl->setCurrentBlock("table_header");
01687 $this->tpl->setVariable("TEXT",$this->lng->txt($key));
01688 $this->tpl->parseCurrentBlock();
01689 }
01690
01691
01692
01693 $counter = 0;
01694
01695 foreach ($this->data["data"] as $key => $value)
01696 {
01697
01698 foreach ($value as $key => $cell_data)
01699 {
01700 $this->tpl->setCurrentBlock("table_cell");
01701
01702
01703 if ($key == "type")
01704 {
01705 $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
01706 }
01707 elseif ($key == "title")
01708 {
01709 $name_field = explode("#separator#",$cell_data);
01710
01711 $this->tpl->setVariable("TEXT_CONTENT", "<b>".$name_field[0]."</b>");
01712
01713 $this->tpl->setCurrentBlock("subtitle");
01714 $this->tpl->setVariable("DESC", $name_field[1]);
01715 $this->tpl->parseCurrentBlock();
01716 $this->tpl->setCurrentBlock("table_cell");
01717 }
01718 else
01719 {
01720 $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
01721 }
01722
01723 $this->tpl->parseCurrentBlock();
01724 }
01725
01726 $this->tpl->setCurrentBlock("table_row");
01727 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01728 $this->tpl->parseCurrentBlock();
01729
01730 }
01731
01732
01733
01734 foreach ($this->data["buttons"] as $name => $value)
01735 {
01736 $this->tpl->setCurrentBlock("operation_btn");
01737 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01738 $this->tpl->setVariable("BTN_NAME",$name);
01739 $this->tpl->setVariable("BTN_VALUE",$value);
01740 $this->tpl->parseCurrentBlock();
01741 }
01742 }
01743
01749 function trashObject()
01750 {
01751 $objects = $this->tree->getSavedNodeData($_GET["ref_id"]);
01752
01753 if (count($objects) == 0)
01754 {
01755 ilUtil::sendInfo($this->lng->txt("msg_trash_empty"));
01756 $this->data["empty"] = true;
01757 }
01758 else
01759 {
01760 $this->data["empty"] = false;
01761 $this->data["cols"] = array("","type", "title", "last_change");
01762
01763 foreach ($objects as $obj_data)
01764 {
01765 $this->data["data"]["$obj_data[child]"] = array(
01766 "checkbox" => "",
01767 "type" => $obj_data["type"],
01768 "title" => $obj_data["title"]."#separator#".$obj_data["desc"],
01769 "last_update" => $obj_data["last_update"]
01770 );
01771 }
01772
01773 $this->data["buttons"] = array( "undelete" => $this->lng->txt("btn_undelete"),
01774 "removeFromSystem" => $this->lng->txt("btn_remove_system"));
01775 }
01776
01777 $this->getTemplateFile("confirm");
01778
01779 if ($this->data["empty"] == true)
01780 {
01781 return;
01782 }
01783
01784
01785
01786
01787
01788
01789
01790
01791 $this->tpl->setVariable("FORMACTION",
01792 $this->ctrl->getFormAction($this));
01793 $this->tpl->setVariable("TPLPATH",$this->tpl->tplPath);
01794 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01795
01796
01797 foreach ($this->data["cols"] as $key)
01798 {
01799 $this->tpl->setCurrentBlock("table_header");
01800 $this->tpl->setVariable("TEXT",$this->lng->txt($key));
01801 $this->tpl->parseCurrentBlock();
01802 }
01803
01804
01805
01806 $counter = 0;
01807
01808 foreach ($this->data["data"] as $key1 => $value)
01809 {
01810
01811 foreach ($value as $key2 => $cell_data)
01812 {
01813 $this->tpl->setCurrentBlock("table_cell");
01814
01815 if ($key2 == "checkbox")
01816 {
01817 $this->tpl->setVariable("TEXT_CONTENT",ilUtil::formCheckBox(0,"trash_id[]",$key1));
01818 }
01819
01820 elseif ($key2 == "type")
01821 {
01822 $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
01823 }
01824 elseif ($key2 == "title")
01825 {
01826 $name_field = explode("#separator#",$cell_data);
01827
01828 $this->tpl->setVariable("TEXT_CONTENT", "<b>".$name_field[0]."</b>");
01829
01830 $this->tpl->setCurrentBlock("subtitle");
01831 $this->tpl->setVariable("DESC", $name_field[1]);
01832 $this->tpl->parseCurrentBlock();
01833 $this->tpl->setCurrentBlock("table_cell");
01834 }
01835 else
01836 {
01837 $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
01838 }
01839
01840 $this->tpl->parseCurrentBlock();
01841 }
01842
01843 $this->tpl->setCurrentBlock("table_row");
01844 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01845 $this->tpl->parseCurrentBlock();
01846
01847 }
01848
01849
01850
01851 foreach ($this->data["buttons"] as $name => $value)
01852 {
01853 $this->tpl->setCurrentBlock("operation_btn");
01854 $this->tpl->setVariable("BTN_NAME",$name);
01855 $this->tpl->setVariable("BTN_VALUE",$value);
01856 $this->tpl->parseCurrentBlock();
01857 }
01858 }
01859
01867 function addRoleObject()
01868 {
01869 include_once './classes/class.ilPermissionGUI.php';
01870 $perm_gui =& new ilPermissionGUI($this);
01871
01872
01873 $this->ctrl->current_node = 1;
01874 $this->ctrl->setCmd('addRole');
01875 $ret =& $this->ctrl->forwardCommand($perm_gui);
01876
01877 return true;
01878 }
01879
01886 function showActions($with_subobjects = false)
01887 {
01888 $notoperations = array();
01889
01890 if (empty($_SESSION["clipboard"]))
01891 {
01892 $notoperations[] = "copy";
01893 $notoperations[] = "paste";
01894 $notoperations[] = "clear";
01895 }
01896
01897 if ($_SESSION["clipboard"])
01898 {
01899 $notoperations[] = "cut";
01900 $notoperations[] = "copy";
01901 $notoperations[] = "link";
01902 }
01903
01904 $operations = array();
01905
01906 if ($this->actions == "")
01907 {
01908 $d = $this->objDefinition->getActions($this->object->getType());
01909
01910 }
01911 else
01912 {
01913 $d = $this->actions;
01914 }
01915
01916 foreach ($d as $row)
01917 {
01918 if (!in_array($row["name"], $notoperations))
01919 {
01920 $operations[] = $row;
01921 }
01922 }
01923
01924 if (count($operations) > 0)
01925 {
01926 foreach ($operations as $val)
01927 {
01928 $this->tpl->setCurrentBlock("tbl_action_btn");
01929 $this->tpl->setVariable("BTN_NAME", $val["name"]);
01930 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
01931 $this->tpl->parseCurrentBlock();
01932 }
01933 }
01934
01935 if ($with_subobjects === true)
01936 {
01937
01938 }
01939
01940 if (!empty($this->ids) && count($operations) > 0)
01941 {
01942
01943 $this->tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
01944 $this->tpl->setVariable("JS_VARNAME","id");
01945 $this->tpl->setVariable("JS_ONCLICK",ilUtil::array_php2js($this->ids));
01946 $this->tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
01947 $this->tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
01948 $this->tpl->parseCurrentBlock();
01949 }
01950
01951 if (count($operations) > 0)
01952 {
01953 $this->tpl->setCurrentBlock("tbl_action_row");
01954 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01955 $this->tpl->parseCurrentBlock();
01956 }
01957 }
01958
01964 function showPossibleSubObjects()
01965 {
01966 if ($this->sub_objects == "")
01967 {
01968 $d = $this->objDefinition->getCreatableSubObjects($this->object->getType());
01969 }
01970 else
01971 {
01972 $d = $this->sub_objects;
01973 }
01974
01975 $import = false;
01976
01977 if (count($d) > 0)
01978 {
01979 foreach ($d as $row)
01980 {
01981 $count = 0;
01982
01983 if ($row["max"] > 0)
01984 {
01985
01986 for ($i=0; $i<count($this->data["ctrl"]); $i++)
01987 {
01988 if ($this->data["ctrl"][$i]["type"] == $row["name"])
01989 {
01990 $count++;
01991 }
01992 }
01993 }
01994
01995 if ($row["max"] == "" || $count < $row["max"])
01996 {
01997 $subobj[] = $row["name"];
01998
01999 if ($row["import"] == "1")
02000 {
02001 $import = true;
02002 }
02003 }
02004 }
02005 }
02006
02007 if (is_array($subobj))
02008 {
02009
02010
02011 if ($import)
02012 {
02013 $this->tpl->setCurrentBlock("import_object");
02014 $this->tpl->setVariable("BTN_IMP", "import");
02015 $this->tpl->setVariable("TXT_IMP", $this->lng->txt("import"));
02016 $this->tpl->parseCurrentBlock();
02017 }
02018
02019
02020 $opts = ilUtil::formSelect(12,"new_type",$subobj);
02021 $this->tpl->setCurrentBlock("add_object");
02022 $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
02023 $this->tpl->setVariable("BTN_NAME", "create");
02024 $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
02025 $this->tpl->parseCurrentBlock();
02026 }
02027 }
02028
02037 function getTemplateFile($a_cmd,$a_type = "")
02038 {
02039 if (!$a_type)
02040 {
02041 $a_type = $this->type;
02042 }
02043
02044 $template = "tpl.".$a_type."_".$a_cmd.".html";
02045
02046 if (!$this->tpl->fileExists($template) &&
02047 !file_exists("./templates/default/".$template))
02048 {
02049 $template = "tpl.obj_".$a_cmd.".html";
02050 }
02051
02052 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", $template,$a_in_module);
02053
02054 }
02055
02064 function getTitlesByRefId($a_ref_ids)
02065 {
02066 foreach ($a_ref_ids as $id)
02067 {
02068
02069 $tmp_obj =& $this->ilias->obj_factory->getInstanceByRefId($id);
02070 $title[] = $tmp_obj->getTitle();
02071 unset($tmp_obj);
02072 }
02073
02074 return $title ? $title : array();
02075 }
02076
02084 function getTabs(&$tabs_gui)
02085 {
02086
02087
02088 }
02089
02090
02091 function __showButton($a_cmd,$a_text,$a_target = '')
02092 {
02093 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
02094
02095
02096 $this->tpl->setCurrentBlock("btn_cell");
02097 $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this,$a_cmd));
02098 $this->tpl->setVariable("BTN_TXT",$a_text);
02099 if($a_target)
02100 {
02101 $this->tpl->setVariable("BTN_TARGET",$a_target);
02102 }
02103
02104 $this->tpl->parseCurrentBlock();
02105 }
02106
02107 function hitsperpageObject()
02108 {
02109 $_SESSION["tbl_limit"] = $_POST["hitsperpage"];
02110 $_GET["limit"] = $_POST["hitsperpage"];
02111 }
02112
02113
02114 function &__initTableGUI()
02115 {
02116 include_once "./Services/Table/classes/class.ilTableGUI.php";
02117
02118 return new ilTableGUI(0,false);
02119 }
02120
02126 function __setTableGUIBasicData(&$tbl,&$result_set,$a_from = "")
02127 {
02128 switch ($a_from)
02129 {
02130 case "clipboardObject":
02131 $offset = $_GET["offset"];
02132 $order = $_GET["sort_by"];
02133 $direction = $_GET["sort_order"];
02134 $tbl->disable("footer");
02135 break;
02136
02137 default:
02138 $offset = $_GET["offset"];
02139 $order = $_GET["sort_by"];
02140 $direction = $_GET["sort_order"];
02141 break;
02142 }
02143
02144 $tbl->setOrderColumn($order);
02145 $tbl->setOrderDirection($direction);
02146 $tbl->setOffset($offset);
02147 $tbl->setLimit($_GET["limit"]);
02148 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
02149 $tbl->setData($result_set);
02150 }
02151
02152 function __showClipboardTable($a_result_set,$a_from = "")
02153 {
02154 $tbl =& $this->__initTableGUI();
02155 $tpl =& $tbl->getTemplateObject();
02156
02157 $tpl->setCurrentBlock("tbl_form_header");
02158 $tpl->setVariable("FORMACTION",$this->ctrl->getTargetScript()."?".$this->link_params."&cmd=post");
02159 $tpl->parseCurrentBlock();
02160
02161 $tpl->setCurrentBlock("tbl_action_btn");
02162 $tpl->setVariable("BTN_NAME","paste");
02163 $tpl->setVariable("BTN_VALUE",$this->lng->txt("insert_object_here"));
02164 $tpl->parseCurrentBlock();
02165
02166 $tpl->setCurrentBlock("tbl_action_btn");
02167 $tpl->setVariable("BTN_NAME","clear");
02168 $tpl->setVariable("BTN_VALUE",$this->lng->txt("clear_clipboard"));
02169 $tpl->parseCurrentBlock();
02170
02171 $tpl->setCurrentBlock("tbl_action_row");
02172 $tpl->setVariable("COLUMN_COUNTS",3);
02173 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("spacer.gif"));
02174 $tpl->parseCurrentBlock();
02175
02176 $tbl->setTitle($this->lng->txt("clipboard"),"icon_typ_b.gif",$this->lng->txt("clipboard"));
02177 $tbl->setHeaderNames(array($this->lng->txt('obj_type'),
02178 $this->lng->txt('title'),
02179 $this->lng->txt('action')));
02180 $tbl->setHeaderVars(array('type',
02181 'title',
02182 'act'),
02183 array('ref_id' => $this->object->getRefId(),
02184 'cmd' => 'clipboard',
02185 'cmdClass' => $_GET['cmdClass'],
02186 'cmdNode' => $_GET['cmdNode']));
02187
02188 $tbl->setColumnWidth(array("","80%","19%"));
02189
02190
02191 $this->__setTableGUIBasicData($tbl,$a_result_set,$a_from);
02192 $tbl->render();
02193
02194 $this->tpl->setVariable("RESULT_TABLE",$tbl->tpl->get());
02195
02196 return true;
02197 }
02198
02199 function infoObject()
02200 {
02201 include_once './classes/class.ilPermissionGUI.php';
02202 $perm_gui =& new ilPermissionGUI($this);
02203
02204
02205 $this->ctrl->current_node = 1;
02206 $this->ctrl->setCmd('info');
02207 $ret =& $this->ctrl->forwardCommand($perm_gui);
02208
02209 return true;
02210 }
02211
02212 function __buildRoleFilterSelect()
02213 {
02214 $action[1] = $this->lng->txt('all_roles');
02215 $action[2] = $this->lng->txt('all_global_roles');
02216 $action[3] = $this->lng->txt('all_local_roles');
02217 $action[4] = $this->lng->txt('linked_local_roles');
02218 $action[5] = $this->lng->txt('local_roles_this_object_only');
02219
02220 return ilUtil::formSelect($_SESSION['perm_filtered_roles'],"filter",$action,false,true);
02221 }
02222
02223 function __filterRoles($a_roles,$a_filter)
02224 {
02225 global $rbacreview;
02226
02227 switch ($a_filter)
02228 {
02229 case 1:
02230 return $a_roles;
02231 break;
02232
02233 case 2:
02234 $arr_global_roles = $rbacreview->getGlobalRoles();
02235 $arr_remove_roles = array_diff(array_keys($a_roles),$arr_global_roles);
02236
02237 foreach ($arr_remove_roles as $role_id)
02238 {
02239 unset($a_roles[$role_id]);
02240 }
02241
02242 return $a_roles;
02243 break;
02244
02245 case 3:
02246 $arr_global_roles = $rbacreview->getGlobalRoles();
02247
02248 foreach ($arr_global_roles as $role_id)
02249 {
02250 unset($a_roles[$role_id]);
02251 }
02252
02253 return $a_roles;
02254 break;
02255
02256 case 4:
02257 return $a_roles;
02258 break;
02259
02260 case 5:
02261
02262 $role_folder = $rbacreview->getRoleFolderOfObject($this->object->getRefId());
02263
02264 if (!$role_folder)
02265 {
02266 return array();
02267 }
02268
02269 $arr_local_roles = $rbacreview->getRolesOfRoleFolder($role_folder["ref_id"]);
02270 $arr_remove_roles = array_diff(array_keys($a_roles),$arr_local_roles);
02271
02272 foreach ($arr_remove_roles as $role_id)
02273 {
02274 unset($a_roles[$role_id]);
02275 }
02276
02277 return $a_roles;
02278 break;
02279 }
02280
02281 return $a_roles;
02282 }
02283
02284 function ownerObject()
02285 {
02286 include_once './classes/class.ilPermissionGUI.php';
02287 $perm_gui =& new ilPermissionGUI($this);
02288
02289
02290 $this->ctrl->current_node = 1;
02291 $this->ctrl->setCmd('owner');
02292 $ret =& $this->ctrl->forwardCommand($perm_gui);
02293
02294 return true;
02295 }
02296
02297 function changeOwnerObject()
02298 {
02299 include_once './classes/class.ilPermissionGUI.php';
02300 $perm_gui =& new ilPermissionGUI($this);
02301
02302
02303 $this->ctrl->current_node = 1;
02304 $this->ctrl->setCmd('changeOwner');
02305 $ret =& $this->ctrl->forwardCommand($perm_gui);
02306
02307 return true;
02308 }
02309
02319 function redirectToRefId($a_ref_id, $a_cmd = "")
02320 {
02321 $obj_type = ilObject::_lookupType($a_ref_id,true);
02322 $class_name = $this->objDefinition->getClassName($obj_type);
02323 $class = strtolower("ilObj".$class_name."GUI");
02324 $this->ctrl->redirectByClass(array("ilrepositorygui", $class), $a_cmd);
02325 }
02326
02327
02337 public function fillCloneTemplate($a_tpl_varname,$a_type)
02338 {
02339 global $objDefinition,$ilUser,$ilSetting;
02340
02341 $max_entries = $ilSetting->get('search_max_hits',100);
02342
02343 if(!count($existing_objs = ilUtil::_getObjectsByOperations($a_type,'copy',$ilUser->getId(),$max_entries)))
02344 {
02345
02346 return false;
02347 }
02348
02349 if(count($existing_objs) >= $max_entries)
02350 {
02351 return $this->fillCloneSearchTemplate($a_tpl_varname,$a_type);
02352 }
02353 unset($_SESSION['wizard_search_title']);
02354 $this->tpl->addBlockFile(strtoupper($a_tpl_varname),strtolower($a_tpl_varname),'tpl.obj_duplicate.html');
02355 $this->ctrl->setParameter($this,'new_type',$a_type);
02356 $this->tpl->setVariable('TYPE_IMG3',ilUtil::getImagePath('icon_'.$a_type.'.gif'));
02357 $this->tpl->setVariable('ALT_IMG3',$this->lng->txt('obj_'.$a_type));
02358 $this->tpl->setVariable('TXT_DUPLICATE',$this->lng->txt('obj_'.$a_type.'_duplicate'));
02359
02360 $this->tpl->setVariable('WIZARD_TXT_SELECT',$this->lng->txt('obj_'.$a_type));
02361 $this->tpl->setVariable('WIZARD_OBJS',$this->buildCloneSelect($existing_objs));
02362
02363 if($this->copyWizardHasOptions(self::COPY_WIZARD_NEEDS_PAGE))
02364 {
02365 $this->tpl->setVariable('FORMACTION_CLONE',$this->ctrl->getFormAction($this,'cloneWizardPage'));
02366 $this->tpl->setVariable('BTN_WIZARD',$this->lng->txt('btn_next'));
02367 $this->tpl->setVariable('CMD_WIZARD','cloneWizardPage');
02368 }
02369 else
02370 {
02371 $this->tpl->setVariable('FORMACTION_CLONE',$this->ctrl->getFormAction($this,'cloneAll'));
02372 $this->tpl->setVariable('BTN_WIZARD',$this->lng->txt('obj_'.$a_type.'_duplicate'));
02373 $this->tpl->setVariable('CMD_WIZARD','cloneAll');
02374 }
02375
02376 $this->tpl->setVariable('WIZARD_TXT_CANCEL',$this->lng->txt('cancel'));
02377 }
02378
02387 public function fillCloneSearchTemplate($a_tpl_varname,$a_type)
02388 {
02389 unset($_SESSION['wizard_search_title']);
02390
02391 $this->tpl->addBlockFile(strtoupper($a_tpl_varname),strtolower($a_tpl_varname),'tpl.obj_duplicate_search.html');
02392 $this->ctrl->setParameter($this,'new_type',$a_type);
02393 $this->tpl->setVariable('FORMACTION_CLONE',$this->ctrl->getFormAction($this,'searchCloneSource'));
02394 $this->tpl->setVariable('TYPE_IMG3',ilUtil::getImagePath('icon_'.$a_type.'.gif'));
02395 $this->tpl->setVariable('ALT_IMG3',$this->lng->txt('obj_'.$a_type));
02396 $this->tpl->setVariable('TXT_DUPLICATE',$this->lng->txt('obj_'.$a_type.'_duplicate'));
02397
02398 $this->tpl->setVariable('WIZARD_TXT_TITLE',$this->lng->txt('title'));
02399 $this->tpl->setVariable('WIZARD_TITLE',ilUtil::prepareFormOutput($_POST['wizard_search_title'],true));
02400 $this->tpl->setVariable('WIZARD_TITLE_INFO',$this->lng->txt('wizard_title_info'));
02401
02402 $this->tpl->setVariable('BTN_WIZARD',$this->lng->txt('btn_next'));
02403 $this->tpl->setVariable('CMD_WIZARD','searchCloneSource');
02404 $this->tpl->setVariable('WIZARD_TXT_CANCEL',$this->lng->txt('cancel'));
02405 }
02406
02412 protected function searchCloneSourceObject()
02413 {
02414 global $tree,$ilObjDataCache;
02415
02416 $this->ctrl->setParameter($this,'new_type',$_REQUEST['new_type']);
02417
02418 $_SESSION['wizard_search_title'] = ilUtil::stripSlashes($_POST['wizard_search_title']) ?
02419 ilUtil::stripSlashes($_POST['wizard_search_title']) :
02420 $_SESSION['wizard_search_title'];
02421
02422 $this->lng->loadLanguageModule('search');
02423 include_once './Services/Search/classes/class.ilQueryParser.php';
02424 $query_parser =& new ilQueryParser(ilUtil::stripSlashes($_SESSION['wizard_search_title']));
02425 $query_parser->setMinWordLength(1);
02426 $query_parser->setCombination(QP_COMBINATION_AND);
02427 $query_parser->parse();
02428 if(!$query_parser->validate())
02429 {
02430 ilUtil::sendInfo($query_parser->getMessage());
02431 $this->createObject();
02432 return true;
02433 }
02434
02435
02436 include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
02437 $object_search =& new ilLikeObjectSearch($query_parser);
02438
02439 $object_search->setFilter(array($_REQUEST['new_type']));
02440 $res = $object_search->performSearch();
02441 $res->setRequiredPermission('copy');
02442
02443
02444 $res->filter(ROOT_FOLDER_ID,true);
02445
02446 if(!count($results = $res->getResultsByObjId()))
02447 {
02448 ilUtil::sendInfo($this->lng->txt('search_no_match'));
02449 $this->createObject();
02450 return true;
02451 }
02452
02453 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.obj_duplicate_search_results.html');
02454
02455 $num_rows = 0;
02456 foreach($results as $obj_id => $references)
02457 {
02458 foreach($references as $ref_id)
02459 {
02460 $this->tpl->setCurrentBlock('ref_row');
02461 $this->tpl->setVariable('RADIO_REF',ilUtil::formRadioButton(0,'clone_source',$ref_id));
02462 $this->tpl->setVariable('TXT_PATH',$this->lng->txt('path'));
02463
02464 $path_arr = $tree->getPathFull($ref_id,ROOT_FOLDER_ID);
02465 $counter = 0;
02466 $path = '';
02467 foreach($path_arr as $data)
02468 {
02469 if($counter++)
02470 {
02471 $path .= " -> ";
02472 }
02473 $path .= $data['title'];
02474 }
02475 $this->tpl->setVariable('PATH',$path);
02476 $this->tpl->parseCurrentBlock();
02477 break;
02478 }
02479 if(strlen($desc = $ilObjDataCache->lookupDescription($obj_id)))
02480 {
02481 $this->tpl->setCurrentBlock('desc');
02482 $this->tpl->setVariable('DESCRIPTION',$desc);
02483 $this->tpl->parseCurrentBlock();
02484 }
02485 $this->tpl->setCurrentBlock('res_row');
02486 $this->tpl->setVariable('TBLROW',ilUtil::switchColor($num_rows++,'tblrow1','tblrow2'));
02487 $this->tpl->setVariable('TITLE',$ilObjDataCache->lookupTitle($obj_id));
02488 $this->tpl->setVariable('REFERENCES',$this->lng->txt('pathes'));
02489 $this->tpl->parseCurrentBlock();
02490 }
02491
02492 $this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this,'cancel'));
02493 $this->tpl->setVariable('TYPE_IMG',ilUtil::getImagePath('icon_'.$_REQUEST['new_type'].'.gif'));
02494 $this->tpl->setVariable('ALT_IMG',$this->lng->txt('obj_'.$_REQUEST['new_type']));
02495 $this->tpl->setVariable('TXT_DUPLICATE',$this->lng->txt('obj_'.$_REQUEST['new_type'].'_duplicate'));
02496 $this->tpl->setVariable('INFO_DUPLICATE',$this->lng->txt('wizard_search_list'));
02497 if($this->copyWizardHasOptions(self::COPY_WIZARD_NEEDS_PAGE))
02498 {
02499 $this->tpl->setVariable('BTN_COPY',$this->lng->txt('btn_next'));
02500 $this->tpl->setVariable('CMD_COPY','cloneWizardPage');
02501 }
02502 else
02503 {
02504 $this->tpl->setVariable('BTN_COPY',$this->lng->txt('obj_'.$_REQUEST['new_type'].'_duplicate'));
02505 $this->tpl->setVariable('CMD_COPY','cloneAll');
02506 }
02507 $this->tpl->setVariable('BTN_BACK',$this->lng->txt('btn_back'));
02508 return true;
02509 }
02510
02517 public function cloneAllObject()
02518 {
02519 include_once('classes/class.ilLink.php');
02520 include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
02521
02522 global $ilAccess,$ilErr,$rbacsystem,$ilUser;
02523
02524 $new_type = $_REQUEST['new_type'];
02525 if(!$rbacsystem->checkAccess('create',(int) $_GET['ref_id'],$new_type))
02526 {
02527 $ilErr->raiseError($this->lng->txt('permission_denied'));
02528 }
02529 if(!(int) $_REQUEST['clone_source'])
02530 {
02531 ilUtil::sendInfo($this->lng->txt('select_one'));
02532 $this->createObject();
02533 return false;
02534 }
02535 if(!$ilAccess->checkAccess('write','',(int) $_REQUEST['clone_source'],$new_type))
02536 {
02537 $ilErr->raiseError($this->lng->txt('permission_denied'));
02538 }
02539
02540
02541 $copy_id = ilCopyWizardOptions::_allocateCopyId();
02542 $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
02543 $wizard_options->saveOwner($ilUser->getId());
02544 $wizard_options->saveRoot((int) $_REQUEST['clone_source']);
02545
02546 $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
02547 foreach($options as $source_id => $option)
02548 {
02549 $wizard_options->addEntry($source_id,$option);
02550 }
02551 $wizard_options->read();
02552
02553 $orig = ilObjectFactory::getInstanceByRefId((int) $_REQUEST['clone_source']);
02554 $new_obj = $orig->cloneObject((int) $_GET['ref_id'],$copy_id);
02555
02556
02557 $wizard_options->deleteAll();
02558
02559 ilUtil::sendInfo($this->lng->txt("object_duplicated"),true);
02560 ilUtil::redirect(ilLink::_getLink($new_obj->getRefId()));
02561 }
02562
02570 public function copyWizardHasOptions($a_mode)
02571 {
02572 return false;
02573 }
02574
02581 protected function buildCloneSelect($existing_objs)
02582 {
02583 $options = ilObject::_prepareCloneSelection($existing_objs,$_REQUEST['new_type']);
02584 return ilUtil::formSelect((int) $_REQUEST['clone_source'],'clone_source',$options,false,true);
02585 }
02586
02590 function getCenterColumnHTML()
02591 {
02592 global $ilCtrl, $ilAccess;
02593
02594 include_once("Services/Block/classes/class.ilColumnGUI.php");
02595
02596 $obj_id = ilObject::_lookupObjId($this->object->getRefId());
02597 $obj_type = ilObject::_lookupType($obj_id);
02598
02599 if ($ilCtrl->getNextClass() != "ilcolumngui")
02600 {
02601
02602 return $this->getContent();
02603 }
02604 else
02605 {
02606 if (!$ilCtrl->isAsynch())
02607 {
02608
02609 if (ilColumnGUI::getScreenMode() != IL_SCREEN_SIDE)
02610 {
02611
02612 if (ilColumnGUI::getCmdSide() == IL_COL_RIGHT)
02613 {
02614 $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
02615 $this->setColumnSettings($column_gui);
02616 $this->html = $ilCtrl->forwardCommand($column_gui);
02617 }
02618
02619 if (ilColumnGUI::getCmdSide() == IL_COL_LEFT)
02620 {
02621 $column_gui = new ilColumnGUI($obj_type, IL_COL_LEFT);
02622 $this->setColumnSettings($column_gui);
02623 $this->html = $ilCtrl->forwardCommand($column_gui);
02624 }
02625 }
02626 else
02627 {
02628
02629 return $this->getContent();
02630 }
02631 }
02632 }
02633 }
02634
02638 function getRightColumnHTML()
02639 {
02640 global $ilUser, $lng, $ilCtrl, $ilAccess;
02641
02642 $obj_id = ilObject::_lookupObjId($this->object->getRefId());
02643 $obj_type = ilObject::_lookupType($obj_id);
02644
02645 include_once("Services/Block/classes/class.ilColumnGUI.php");
02646 $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
02647
02648 if ($column_gui->getScreenMode() == IL_SCREEN_FULL)
02649 {
02650 return "";
02651 }
02652
02653 $this->setColumnSettings($column_gui);
02654
02655 if ($ilCtrl->getNextClass() == "ilcolumngui" &&
02656 $column_gui->getCmdSide() == IL_COL_RIGHT &&
02657 $column_gui->getScreenMode() == IL_SCREEN_SIDE)
02658 {
02659 $html = $ilCtrl->forwardCommand($column_gui);
02660 }
02661 else
02662 {
02663 if (!$ilCtrl->isAsynch())
02664 {
02665 $html = $ilCtrl->getHTML($column_gui);
02666 }
02667 }
02668
02669 return $html;
02670 }
02671
02675 function setColumnSettings($column_gui)
02676 {
02677 global $ilAccess;
02678
02679 $column_gui->setRepositoryMode(true);
02680 $column_gui->setEnableEdit(false);
02681 if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
02682 {
02683 $column_gui->setEnableEdit(true);
02684 }
02685 }
02686
02687 function checkPermission($a_perm, $a_cmd = "")
02688 {
02689 global $ilAccess, $lng, $PHP_SELF;
02690
02691 if (!is_object($this->object))
02692 {
02693 return;
02694 }
02695 if (!$ilAccess->checkAccess($a_perm, $a_cmd, $this->object->getRefId()))
02696 {
02697 $_SESSION["il_rep_ref_id"] = "";
02698 ilUtil::sendInfo($lng->txt("permission_denied"), true);
02699
02700 if (!is_int(strpos($PHP_SELF, "goto.php")))
02701 {
02702 ilUtil::redirect("goto.php?target=".$this->object->getType()."_".
02703 $this->object->getRefId());
02704 }
02705 else
02706 {
02707 die("Permission Denied.");
02708 }
02709 }
02710 }
02711
02712 }
02713 ?>