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
00034 class ilObjectGUI
00035 {
00041 var $ilias;
00042
00048 var $objDefinition;
00049
00055 var $tpl;
00056
00062 var $tree;
00063
00069 var $lng;
00070
00076 var $data;
00077
00083 var $object;
00084 var $ref_id;
00085 var $obj_id;
00086 var $maxcount;
00087 var $formaction;
00088 var $return_location;
00089 var $target_frame;
00090
00091 var $tab_target_script;
00092 var $actions;
00093 var $sub_objects;
00094
00102 function ilObjectGUI($a_data, $a_id = 0, $a_call_by_reference = true, $a_prepare_output = true)
00103 {
00104 global $ilias, $objDefinition, $tpl, $tree, $ilCtrl, $ilErr, $lng;
00105
00106 if (!isset($ilErr))
00107 {
00108 $ilErr = new ilErrorHandling();
00109 $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK,array($ilErr,'errorHandler'));
00110 }
00111 else
00112 {
00113 $this->ilErr =& $ilErr;
00114 }
00115
00116 $this->ilias =& $ilias;
00117 $this->objDefinition =& $objDefinition;
00118 $this->tpl =& $tpl;
00119
00120 $this->ctrl =& $ilCtrl;
00121
00122 $params = array("ref_id");
00123
00124 if (!$a_call_by_reference)
00125 {
00126 $params = array("ref_id","obj_id");
00127 }
00128
00129 $this->ctrl->saveParameter($this, $params);
00130
00131 $this->lng =& $lng;
00132 $this->tree =& $tree;
00133 $this->formaction = array();
00134 $this->return_location = array();
00135 $this->target_frame = array();
00136 $this->tab_target_script = "adm_object.php";
00137 $this->actions = "";
00138 $this->sub_objects = "";
00139
00140 $this->data = $a_data;
00141 $this->id = $a_id;
00142 $this->call_by_reference = $a_call_by_reference;
00143 $this->prepare_output = $a_prepare_output;
00144
00145 $this->ref_id = ($this->call_by_reference) ? $this->id : $_GET["ref_id"];
00146 $this->obj_id = ($this->call_by_reference) ? $_GET["obj_id"] : $this->id;
00147
00148 if ($this->id != 0)
00149 {
00150 $this->link_params = "ref_id=".$this->ref_id;
00151 }
00152
00153
00154 $this->assignObject();
00155
00156
00157
00158
00159
00160 if ($a_prepare_output)
00161 {
00162 $this->prepareOutput();
00163 }
00164
00165
00166 if (empty($_GET["sort_by"]))
00167 {
00168
00169 if ($this->object->getType() == "usrf"
00170 or $this->object->getType() == "rolf")
00171 {
00172 $_GET["sort_by"] = "name";
00173 }
00174 elseif ($this->object->getType() == "typ")
00175 {
00176 $_GET["sort_by"] = "operation";
00177 }
00178 elseif ($this->object->getType() == "lngf")
00179 {
00180 $_GET["sort_by"] = "language";
00181 }
00182 else
00183 {
00184 $_GET["sort_by"] = "title";
00185 }
00186 }
00187 }
00188
00189
00193 function &executeCommand()
00194 {
00195 global $rbacsystem;
00196
00197 $next_class = $this->ctrl->getNextClass($this);
00198 $cmd = $this->ctrl->getCmd();
00199 switch($next_class)
00200 {
00201 default:
00202 if(!$cmd)
00203 {
00204 $cmd = "view";
00205 }
00206 $cmd .= "Object";
00207 $this->$cmd();
00208
00209 break;
00210 }
00211 return true;
00212 }
00213
00214
00218 function withReferences()
00219 {
00220 return $this->call_by_reference;
00221 }
00222
00223 function assignObject()
00224 {
00225
00226
00227 if ($this->id != 0)
00228 {
00229 if ($this->call_by_reference)
00230 {
00231 $this->object =& $this->ilias->obj_factory->getInstanceByRefId($this->id);
00232 }
00233 else
00234 {
00235 $this->object =& $this->ilias->obj_factory->getInstanceByObjId($this->id);
00236 }
00237 }
00238 }
00239
00240 function prepareOutput()
00241 {
00242 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00243 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00244 $title = $this->object->getTitle();
00245
00246
00247 sendInfo();
00248
00249 if (!empty($title))
00250 {
00251 $this->tpl->setVariable("HEADER", $title);
00252 }
00253
00254 $this->setAdminTabs($_POST["new_type"]);
00255 $this->setLocator();
00256
00257 }
00258
00263 function setAdminTabs($a_new_type = 0)
00264 {
00265
00266
00267 if ($this->object->getType() == "grp" or $this->object->getType() == "adm")
00268 {
00269 include_once "./classes/class.ilTabsGUI.php";
00270 $tabs_gui =& new ilTabsGUI();
00271 $this->getTabs($tabs_gui);
00272
00273
00274 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00275 }
00276 else
00277 {
00278 global $rbacsystem;
00279
00280 $tabs = array();
00281 $this->tpl->addBlockFile("TABS", "tabs", "tpl.tabs.html");
00282
00283
00284 if ($a_new_type)
00285 {
00286 $d = $this->objDefinition->getProperties($this->object->getType());
00287 }
00288 else
00289 {
00290 $d = $this->objDefinition->getProperties($this->type);
00291 }
00292
00293 foreach ($d as $key => $row)
00294 {
00295 $tabs[] = array($row["lng"], $row["name"]);
00296 }
00297
00298
00299 if (isset($_GET["obj_id"]) and $this->call_by_reference === false)
00300 {
00301 $object_link = "&obj_id=".$_GET["obj_id"];
00302 }
00303
00304 foreach ($tabs as $row)
00305 {
00306 $i++;
00307
00308 if ($row[1] == $_GET["cmd"])
00309 {
00310 $tabtype = "tabactive";
00311 $tab = $tabtype;
00312 }
00313 else
00314 {
00315 $tabtype = "tabinactive";
00316 $tab = "tab";
00317 }
00318
00319 $show = true;
00320
00321
00322
00323 if (true)
00324
00325 {
00326
00327 switch ($row[1])
00328 {
00329 case 'view':
00330 if (!$rbacsystem->checkAccess('visible',$this->ref_id))
00331 {
00332 $show = false;
00333 }
00334 break;
00335
00336 case 'edit':
00337 if (!$rbacsystem->checkAccess('write',$this->ref_id))
00338 {
00339 $show = false;
00340 }
00341 break;
00342
00343 case 'perm':
00344 if (!$rbacsystem->checkAccess('edit_permission',$this->ref_id))
00345 {
00346 $show = false;
00347 }
00348 break;
00349
00350 case 'trash':
00351 if (!$this->tree->getSavedNodeData($this->ref_id))
00352 {
00353 $show = false;
00354 }
00355 break;
00356
00357
00358 case 'roleassignment':
00359 if (!$rbacsystem->checkAccess('edit_roleassignment',$this->ref_id))
00360 {
00361 $show = false;
00362 }
00363 break;
00364
00365
00366 case 'userassignment':
00367 if (!$rbacsystem->checkAccess('edit_userassignment',$this->ref_id))
00368 {
00369 $show = false;
00370 }
00371 break;
00372 }
00373 }
00374
00375 if (!$show)
00376 {
00377 continue;
00378 }
00379
00380 $this->tpl->setCurrentBlock("tab");
00381 $this->tpl->setVariable("TAB_TYPE", $tabtype);
00382 $this->tpl->setVariable("TAB_TYPE2", $tab);
00383 $this->tpl->setVariable("IMG_LEFT", ilUtil::getImagePath("eck_l.gif"));
00384 $this->tpl->setVariable("IMG_RIGHT", ilUtil::getImagePath("eck_r.gif"));
00385 $this->tpl->setVariable("TAB_LINK", $this->tab_target_script."?ref_id=".$_GET["ref_id"].$object_link."&cmd=".$row[1]);
00386 $this->tpl->setVariable("TAB_TEXT", $this->lng->txt($row[0]));
00387 $this->tpl->parseCurrentBlock();
00388 }
00389 }
00390 }
00391
00392 function setTabTargetScript($a_script = "adm_object.php")
00393 {
00394 $this->tab_target_script = $a_script;
00395 }
00396
00397 function getTabTargetScript()
00398 {
00399 return $this->tab_target_script;
00400 }
00401
00408 function setActions($a_actions = "")
00409 {
00410 if (is_array($a_actions))
00411 {
00412 foreach ($a_actions as $name => $lng)
00413 {
00414 $this->actions[$name] = array("name" => $name, "lng" => $lng);
00415 }
00416 }
00417 else
00418 {
00419 $this->actions = "";
00420 }
00421 }
00422
00429 function setSubObjects($a_sub_objects = "")
00430 {
00431 if (is_array($a_sub_objects))
00432 {
00433 foreach ($a_sub_objects as $name => $options)
00434 {
00435 $this->sub_objects[$name] = array("name" => $name, "max" => $options["max"]);
00436 }
00437 }
00438 else
00439 {
00440 $this->sub_objects = "";
00441 }
00442 }
00443
00452 function setLocator($a_tree = "", $a_id = "", $scriptname="adm_object.php",
00453 $a_child_param = "ref_id", $a_output_obj = true, $a_root_title = "")
00454 {
00455 global $ilias_locator;
00456
00457 if (!is_object($a_tree))
00458 {
00459 $a_tree =& $this->tree;
00460 }
00461
00462 if (!($a_id))
00463 {
00464 $a_id = $_GET["ref_id"];
00465 }
00466
00467 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00468
00469 $path = $a_tree->getPathFull($a_id);
00470
00471
00472
00473 if ($a_parent_parent)
00474 {
00475
00476 $subObj =& $this->ilias->obj_factory->getInstanceByRefId($a_ref_id);
00477
00478 $path[] = array(
00479 "id" => $a_ref_id,
00480 "title" => $this->lng->txt($subObj->getTitle())
00481 );
00482 }
00483
00484
00485 $modifier = 1;
00486
00487 if (isset($_GET["obj_id"]) && $a_output_obj)
00488 {
00489 $modifier = 0;
00490 }
00491
00492
00493 $i = 1;
00494
00495 foreach ($path as $key => $row)
00496 {
00497 if ($key < count($path)-$modifier)
00498 {
00499 $this->tpl->touchBlock("locator_separator");
00500 }
00501
00502 $this->tpl->setCurrentBlock("locator_item");
00503
00504 if ($a_root_title != "" && ($row["child"] == $a_tree->getRootId()))
00505 {
00506 $title = $a_root_title;
00507 }
00508 else
00509 {
00510 $title = $row["title"];
00511 }
00512
00513 $this->tpl->setVariable("ITEM", $title);
00514
00515 $this->tpl->setVariable("LINK_ITEM",
00516 ilUtil::appendUrlParameterString($scriptname, $a_child_param."=".$row["child"]));
00517 $this->tpl->parseCurrentBlock();
00518
00519
00520
00521 $ilias_locator->navigate($i++,$title,
00522 ilUtil::appendUrlParameterString($scriptname, $a_child_param."=".$row["child"]),"bottom");
00523 }
00524
00525 if (($_GET["obj_id"] != "") && $a_output_obj)
00526 {
00527 $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($_GET["obj_id"]);
00528
00529 $this->tpl->setCurrentBlock("locator_item");
00530 $this->tpl->setVariable("ITEM", $obj_data->getTitle());
00531
00532 $this->tpl->setVariable("LINK_ITEM",
00533 ilUtil::appendUrlParameterString($scriptname, "ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]));
00534 $this->tpl->parseCurrentBlock();
00535
00536
00537
00538 $ilias_locator->navigate($i++,$obj_data->getTitle(),
00539 ilUtil::appendUrlParameterString($scriptname, "ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]),"bottom");
00540 }
00541
00542 $this->tpl->setCurrentBlock("locator");
00543
00544 if (DEBUG)
00545 {
00546 $debug = "DEBUG: <font color=\"red\">".$this->type."::".$this->id."::".$_GET["cmd"]."</font><br/>";
00547 }
00548
00549 $prop_name = $this->objDefinition->getPropertyName($_GET["cmd"],$this->type);
00550
00551 if ($_GET["cmd"] == "confirmDeleteAdm")
00552 {
00553 $prop_name = "delete_object";
00554 }
00555
00556 $this->tpl->setVariable("TXT_LOCATOR",$debug.$this->lng->txt("locator"));
00557 $this->tpl->parseCurrentBlock();
00558
00559 }
00560
00566 function copyObject()
00567 {
00568 global $rbacsystem;
00569
00570 if (!isset($_POST["id"]))
00571 {
00572 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00573 }
00574
00575
00576 foreach ($_POST["id"] as $ref_id)
00577 {
00578
00579 $node_data = $this->tree->getNodeData($ref_id);
00580 $subtree_nodes = $this->tree->getSubTree($node_data);
00581
00582 $all_node_data[] = $node_data;
00583 $all_subtree_nodes[] = $subtree_nodes;
00584
00585
00586 foreach ($subtree_nodes as $node)
00587 {
00588 if (!$rbacsystem->checkAccess('read',$node["ref_id"]))
00589 {
00590 $no_copy[] = $node["ref_id"];
00591 }
00592 }
00593 }
00594
00595 if (count($no_copy))
00596 {
00597 $this->ilias->raiseError($this->lng->txt("msg_no_perm_copy")." ".implode(',',$this->getTitlesByRefId($no_copy)),
00598 $this->ilias->error_obj->MESSAGE);
00599 }
00600
00601 $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
00602 $_SESSION["clipboard"]["cmd"] = key($_POST["cmd"]);
00603 $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
00604
00605 sendinfo($this->lng->txt("msg_copy_clipboard"),true);
00606
00607 ilUtil::redirect($this->getReturnLocation("copy","adm_object.php?ref_id=".$_GET["ref_id"]));
00608 }
00609
00616 function pasteObject()
00617 {
00618 global $rbacsystem, $rbacadmin, $rbacreview, $log;
00619
00620 if ($this->ctrl->getTargetScript() == "repository.php")
00621 {
00622 $_SESSION["clipboard"] = "";
00623 $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
00624 $_SESSION["clipboard"]["cmd"] = $_SESSION["il_rep_clipboard"][0]["act"];
00625 $_SESSION["clipboard"]["ref_ids"] = array($_SESSION["il_rep_clipboard"][0]["ref_id"]);
00626
00627 }
00628
00629 if (!in_array($_SESSION["clipboard"]["cmd"],array("cut","link","copy")))
00630 {
00631 $message = get_class($this)."::pasteObject(): cmd was neither 'cut','link' or 'copy'; may be a hack attempt!";
00632 $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
00633 }
00634
00635
00636 foreach ($_SESSION["clipboard"]["ref_ids"] as $ref_id)
00637 {
00638 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
00639
00640
00641 if (!$rbacsystem->checkAccess('create', $_GET["ref_id"], $obj_data->getType()))
00642 {
00643 $no_paste[] = $ref_id;
00644 }
00645
00646
00647 if ($_GET["ref_id"] == $this->tree->getParentId($obj_data->getRefId()))
00648 {
00649 $exists[] = $ref_id;
00650 break;
00651 }
00652
00653
00654 if ($this->tree->isGrandChild($ref_id,$_GET["ref_id"]))
00655 {
00656 $is_child[] = $ref_id;
00657 }
00658
00659
00660 $obj_type = $obj_data->getType();
00661
00662 if (!in_array($obj_type, array_keys($this->objDefinition->getSubObjects($this->object->getType()))))
00663 {
00664 $not_allowed_subobject[] = $obj_data->getType();
00665 }
00666 }
00667
00669
00670 if (count($exists))
00671 {
00672 $this->ilias->raiseError($this->lng->txt("msg_obj_exists"),$this->ilias->error_obj->MESSAGE);
00673 }
00674
00675 if (count($is_child))
00676 {
00677 $this->ilias->raiseError($this->lng->txt("msg_not_in_itself")." ".implode(',',$is_child),
00678 $this->ilias->error_obj->MESSAGE);
00679 }
00680
00681 if (count($not_allowed_subobject))
00682 {
00683 $this->ilias->raiseError($this->lng->txt("msg_may_not_contain")." ".implode(',',$not_allowed_subobject),
00684 $this->ilias->error_obj->MESSAGE);
00685 }
00686
00687 if (count($no_paste))
00688 {
00689 $this->ilias->raiseError($this->lng->txt("msg_no_perm_paste")." ".
00690 implode(',',$no_paste),$this->ilias->error_obj->MESSAGE);
00691 }
00692
00693
00694 $log->write("ilObjectGUI::pasteObject(), cmd: ".$_SESSION["clipboard"]["cmd"]);
00695
00697
00698
00699
00700 $ref_ids = $_SESSION["clipboard"]["ref_ids"];
00701 unset($_SESSION["clipboard"]["ref_ids"]);
00702
00703
00704 if ($_SESSION["clipboard"]["cmd"] == "copy")
00705 {
00706
00707 $this->cloneObject($ref_ids);
00708 }
00709
00710
00711 if ($_SESSION["clipboard"]["cmd"] == "cut")
00712 {
00713
00714 foreach($ref_ids as $ref_id)
00715 {
00716
00717 $top_node = $this->tree->getNodeData($ref_id);
00718
00719
00720 $subnodes[$ref_id] = $this->tree->getSubtree($top_node);
00721 }
00722
00723
00724 $log->write("ilObjectGUI::pasteObject(), (1/3) move subtrees to trash");
00725
00726 foreach($ref_ids as $ref_id)
00727 {
00728 $tnodes = $this->tree->getSubtree($this->tree->getNodeData($ref_id));
00729
00730 foreach ($tnodes as $tnode)
00731 {
00732 $rbacadmin->revokePermission($tnode["child"]);
00733 $affected_users = ilUtil::removeItemFromDesktops($tnode["child"]);
00734 }
00735
00736 $this->tree->saveSubTree($ref_id);
00737 $this->tree->deleteTree($this->tree->getNodeData($ref_id));
00738 }
00739
00740
00741
00742 $log->write("ilObjectGUI::pasteObject(), (2/3) move subtrees to new location");
00743
00744
00745 foreach ($subnodes as $key => $subnode)
00746 {
00747
00748 $rbacadmin->revokePermission($key);
00749 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($key);
00750 $obj_data->putInTree($_GET["ref_id"]);
00751 $obj_data->setPermissions($_GET["ref_id"]);
00752
00753
00754 $log->write("ilObjectGUI::pasteObject(), inserted top node. ref_id: $key,".
00755 " rgt: ".$subnode[0]["rgt"].", lft: ".$subnode[0]["lft"].", parent: ".$subnode[0]["parent"].",".
00756 " obj_id: ".$obj_data->getId().", type: ".$obj_data->getType().
00757 ", title: ".$obj_data->getTitle());
00758
00759
00760 array_shift($subnode);
00761
00762
00763 if (count($subnode) > 0)
00764 {
00765 foreach ($subnode as $node)
00766 {
00767 $rbacadmin->revokePermission($node["child"]);
00768 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($node["child"]);
00769 $obj_data->putInTree($node["parent"]);
00770 $obj_data->setPermissions($node["parent"]);
00771
00772
00773 $log->write("ilObjectGUI::pasteObject(), inserted subnode. ref_id: ".$node["child"].",".
00774 " rgt: ".$node["rgt"].", lft: ".$node["lft"].", parent: ".$node["parent"].",".
00775 " obj_id: ".$obj_data->getId().", type: ".$obj_data->getType().
00776 ", title: ".$obj_data->getTitle());
00777 }
00778 }
00779 }
00780
00781
00782 $log->write("ilObjectGUI::pasteObject(), (3/3) remove trashed subtrees from system");
00783
00784 foreach ($ref_ids as $ref_id)
00785 {
00786
00787 $saved_tree = new ilTree(-(int)$ref_id);
00788 $node_data = $saved_tree->getNodeData($ref_id);
00789 $subtree_nodes = $saved_tree->getSubTree($node_data);
00790
00791
00792 $checked[] = -(int) $ref_id;
00793
00794
00795 $this->removeDeletedNodes($ref_id, $checked, false);
00796
00797
00798 $this->tree->deleteTree($node_data);
00799
00800
00801 $log->write("ilObjectGUI::pasteObject(), deleted tree, tree_id: ".$node_data["tree"].
00802 ", child: ".$node_data["child"]);
00803 }
00804
00805
00806 $log->write("ilObjectGUI::pasteObject(), cut finished");
00807
00808
00809
00810
00811
00812
00813 $tmp_object = $this->ilias->obj_factory->getInstanceByRefId($_SESSION["clipboard"]["parent"]);
00814
00815 unset($tmp_object);
00816 }
00817
00818
00819 if ($_SESSION["clipboard"]["cmd"] == "link")
00820 {
00821 foreach ($ref_ids as $ref_id)
00822 {
00823
00824 $top_node = $this->tree->getNodeData($ref_id);
00825
00826
00827 $subnodes[$ref_id] = $this->tree->getSubtree($top_node);
00828 }
00829
00830
00831 foreach ($subnodes as $key => $subnode)
00832 {
00833
00834 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($key);
00835 $new_ref_id = $obj_data->createReference();
00836 $obj_data->putInTree($_GET["ref_id"]);
00837 $obj_data->setPermissions($_GET["ref_id"]);
00838
00839
00840 array_shift($subnode);
00841
00842
00843 $mapping[$new_ref_id] = $key;
00844
00845
00846 $old_ref_id = $obj_data->getRefId();
00847 $obj_data->setRefId($new_ref_id);
00848 $obj_data->initDefaultRoles();
00849 $rolf_data = $rbacreview->getRoleFolderOfObject($obj_data->getRefId());
00850
00851 if (isset($rolf_data["child"]))
00852 {
00853
00854 $rolf_data_old = $rbacreview->getRoleFolderOfObject($old_ref_id);
00855
00856
00857
00858
00859 $mapping[$rolf_data["child"]] = (int) $rolf_data_old["child"];
00860
00861
00862 $log->write("ilObjectGUI::pasteObject(), created role folder (ref_id): ".$rolf_data["child"].
00863 ", for object ref_id:".$obj_data->getRefId().", obj_id: ".$obj_data->getId().
00864 ", type: ".$obj_data->getType().", title: ".$obj_data->getTitle());
00865
00866 }
00867
00868
00869 if (count($subnode) > 0)
00870 {
00871 foreach ($subnode as $node)
00872 {
00873 if ($node["type"] != 'rolf')
00874 {
00875 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($node["child"]);
00876 $new_ref_id = $obj_data->createReference();
00877
00878
00879 $new_parent = array_search($node["parent"],$mapping);
00880
00881 $mapping[$new_ref_id] = (int) $node["child"];
00882
00883 $obj_data->putInTree($new_parent);
00884 $obj_data->setPermissions($new_parent);
00885
00886
00887 $old_ref_id = $obj_data->getRefId();
00888 $obj_data->setRefId($new_ref_id);
00889 $obj_data->initDefaultRoles();
00890 $rolf_data = $rbacreview->getRoleFolderOfObject($obj_data->getRefId());
00891
00892 if (isset($rolf_data["child"]))
00893 {
00894
00895 $rolf_data_old = $rbacreview->getRoleFolderOfObject($old_ref_id);
00896
00897
00898
00899
00900 $mapping[$rolf_data["child"]] = (int) $rolf_data_old["child"];
00901
00902
00903 $log->write("ilObjectGUI::pasteObject(), created role folder (ref_id): ".$rolf_data["child"].
00904 ", for object ref_id:".$obj_data->getRefId().", obj_id: ".$obj_data->getId().
00905 ", type: ".$obj_data->getType().", title: ".$obj_data->getTitle());
00906
00907 }
00908 }
00909
00910
00911 foreach ($subnodes as $old_ref => $subnode)
00912 {
00913 $new_ref = array_search($old_ref,$mapping);
00914
00915 foreach ($subnode as $node)
00916 {
00917 $node["child"] = array_search($node["child"],$mapping);
00918 $node["parent"] = array_search($node["parent"],$mapping);
00919 $new_subnodes[$ref_id][] = $node;
00920 }
00921 }
00922
00923 }
00924 }
00925 }
00926
00927 $log->write("ilObjectGUI::pasteObject(), link finished");
00928
00929
00930
00931 }
00932
00933
00934 $last_cmd = $_SESSION["clipboard"]["cmd"];
00935
00936
00937
00938 $this->clearObject();
00939
00940 if ($last_cmd == "cut")
00941 {
00942 sendInfo($this->lng->txt("msg_cut_copied"),true);
00943 }
00944 else
00945 {
00946 sendInfo($this->lng->txt("msg_linked"),true);
00947 }
00948
00949 ilUtil::redirect($this->getReturnLocation("paste",$this->ctrl->getLinkTarget($this)),get_class($this));
00950
00951
00952 }
00953
00959 function clearObject()
00960 {
00961 unset($_SESSION["clipboard"]);
00962 unset($_SESSION["il_rep_clipboard"]);
00963
00964
00965
00966 if (isset($_POST["cmd"]["clear"]))
00967 {
00968 sendinfo($this->lng->txt("msg_clear_clipboard"),true);
00969
00970
00971 ilUtil::redirect($this->getReturnLocation("clear",$this->ctrl->getLinkTarget($this)),get_class($this));
00972 }
00973 }
00974
00980 function cutObject()
00981 {
00982 global $rbacsystem;
00983
00984 if (!isset($_POST["id"]))
00985 {
00986 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00987 }
00988
00989
00990 foreach ($_POST["id"] as $ref_id)
00991 {
00992
00993 $node_data = $this->tree->getNodeData($ref_id);
00994 $subtree_nodes = $this->tree->getSubTree($node_data);
00995
00996 $all_node_data[] = $node_data;
00997 $all_subtree_nodes[] = $subtree_nodes;
00998
00999
01000 foreach ($subtree_nodes as $node)
01001 {
01002 if (!$rbacsystem->checkAccess('delete',$node["ref_id"]))
01003 {
01004 $no_cut[] = $node["ref_id"];
01005 }
01006 }
01007 }
01008
01009 if (count($no_cut))
01010 {
01011 $this->ilias->raiseError($this->lng->txt("msg_no_perm_cut")." ".implode(',',$this->getTitlesByRefId($no_cut)),
01012 $this->ilias->error_obj->MESSAGE);
01013 }
01014
01015 $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
01016 $_SESSION["clipboard"]["cmd"] = key($_POST["cmd"]);
01017 $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
01018
01019 sendinfo($this->lng->txt("msg_cut_clipboard"),true);
01020
01021 ilUtil::redirect($this->getReturnLocation("cut","adm_object.php?ref_id=".$_GET["ref_id"]));
01022
01023 }
01024
01031 function linkObject()
01032 {
01033 global $clipboard, $rbacsystem, $rbacadmin;
01034
01035 if (!isset($_POST["id"]))
01036 {
01037 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01038 }
01039
01040
01041 foreach ($_POST["id"] as $ref_id)
01042 {
01043 if (!$rbacsystem->checkAccess('delete',$ref_id))
01044 {
01045 $no_cut[] = $ref_id;
01046 }
01047
01048 $object =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
01049
01050 if (!$this->objDefinition->allowLink($object->getType()))
01051 {
01052 $no_link[] = $object->getType();
01053 }
01054 }
01055
01056
01057 if (count($no_cut))
01058 {
01059 $this->ilias->raiseError($this->lng->txt("msg_no_perm_link")." ".
01060 implode(',',$no_cut),$this->ilias->error_obj->MESSAGE);
01061 }
01062
01063 if (count($no_link))
01064 {
01065 $no_link = array_unique($no_link);
01066
01067 foreach ($no_link as $type)
01068 {
01069 $txt_objs[] = $this->lng->txt("objs_".$type);
01070 }
01071
01072 $this->ilias->raiseError(implode(', ',$txt_objs)." ".$this->lng->txt("msg_obj_no_link"),$this->ilias->error_obj->MESSAGE);
01073
01074
01075
01076 }
01077
01078
01079 $clipboard["parent"] = $_GET["ref_id"];
01080 $clipboard["cmd"] = key($_POST["cmd"]);
01081
01082 foreach ($_POST["id"] as $ref_id)
01083 {
01084 $clipboard["ref_ids"][] = $ref_id;
01085 }
01086
01087 $_SESSION["clipboard"] = $clipboard;
01088
01089 sendinfo($this->lng->txt("msg_link_clipboard"),true);
01090
01091 ilUtil::redirect($this->getReturnLocation("link","adm_object.php?ref_id=".$_GET["ref_id"]));
01092
01093 }
01094
01100 function cloneObject($a_ref_ids)
01101 {
01102 global $rbacsystem;
01103
01104 if(!is_array($a_ref_ids))
01105 {
01106 $this->ilias->raiseError($this->lng->txt("msg_error_copy"),$this->ilias->error_obj->MESSAGE);
01107 }
01108
01109
01110
01111 foreach ($a_ref_ids as $id)
01112 {
01113 $this->cloneNodes($id,$this->ref_id,$mapping);
01114 }
01115
01116
01117
01118
01119 $this->clearObject();
01120
01121 sendinfo($this->lng->txt("msg_cloned"),true);
01122 ilUtil::redirect($this->getReturnLocation("paste","adm_object.php?ref_id=".$_GET["ref_id"]));
01123
01124 }
01125
01136 function cloneNodes($a_source_id,$a_dest_id,&$mapping)
01137 {
01138 if (!$mapping)
01139 {
01140 $mapping = array();
01141 }
01142
01143
01144 $source_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_source_id);
01145 $new_ref_id = $source_obj->ilClone($a_dest_id);
01146 unset($source_obj);
01147
01148 $mapping[$new_ref_id] = $a_source_id;
01149
01150
01151 foreach ($this->tree->getChilds($a_source_id) as $child)
01152 {
01153
01154 if ($child["type"] != 'rolf')
01155 {
01156 $this->cloneNodes($child["ref_id"],$new_ref_id,$mapping);
01157 }
01158 else
01159 {
01160 if (count($rolf = $this->tree->getChildsByType($new_ref_id,"rolf")))
01161 {
01162 $mapping[$rolf[0]["ref_id"]] = $child["ref_id"];
01163 }
01164 }
01165 }
01166
01167 return true;
01168 }
01169
01175 function undeleteObject()
01176 {
01177 global $rbacsystem, $log;
01178
01179
01180 if (!isset($_POST["trash_id"]))
01181 {
01182 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01183 }
01184
01185 foreach ($_POST["trash_id"] as $id)
01186 {
01187 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($id);
01188
01189 if (!$rbacsystem->checkAccess('create',$_GET["ref_id"],$obj_data->getType()))
01190 {
01191 $no_create[] = $id;
01192 }
01193 }
01194
01195 if (count($no_create))
01196 {
01197 $this->ilias->raiseError($this->lng->txt("msg_no_perm_paste")." ".
01198 implode(',',$no_paste),$this->ilias->error_obj->MESSAGE);
01199 }
01200
01201 foreach ($_POST["trash_id"] as $id)
01202 {
01203
01204 $this->insertSavedNodes($id,$_GET["ref_id"],-(int) $id);
01205
01206 $saved_tree = new ilTree(-(int)$id);
01207 $saved_tree->deleteTree($saved_tree->getNodeData($id));
01208
01209 }
01210
01211
01212
01213 sendInfo($this->lng->txt("msg_undeleted"),true);
01214
01215 ilUtil::redirect($this->getReturnLocation("undelete","adm_object.php?ref_id=".$_GET["ref_id"]));
01216
01217 }
01218
01228 function insertSavedNodes($a_source_id,$a_dest_id,$a_tree_id)
01229 {
01230 global $rbacadmin, $rbacreview, $log;
01231
01232 $this->tree->insertNode($a_source_id,$a_dest_id);
01233
01234
01235 $log->write("ilObjectGUI::insertSavedNodes(), restored ref_id $a_source_id from trash");
01236
01237
01238 $parentRoles = $rbacreview->getParentRoleIds($a_dest_id);
01239 $obj =& $this->ilias->obj_factory->getInstanceByRefId($a_source_id);
01240
01241 foreach ($parentRoles as $parRol)
01242 {
01243 $ops = $rbacreview->getOperationsOfRole($parRol["obj_id"], $obj->getType(), $parRol["parent"]);
01244 $rbacadmin->grantPermission($parRol["obj_id"],$ops,$a_source_id);
01245 }
01246
01247 $saved_tree = new ilTree($a_tree_id);
01248 $childs = $saved_tree->getChilds($a_source_id);
01249
01250 foreach ($childs as $child)
01251 {
01252 $this->insertSavedNodes($child["child"],$a_source_id,$a_tree_id);
01253 }
01254 }
01255
01265 function confirmedDeleteObject()
01266 {
01267 include_once './payment/classes/class.ilPaymentObject.php';
01268
01269 global $rbacsystem, $rbacadmin, $log;
01270
01271
01272
01273
01274
01275
01276 if (!isset($_SESSION["saved_post"]))
01277 {
01278 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01279 }
01280
01281
01282 foreach ($_SESSION["saved_post"] as $id)
01283 {
01284
01285 $node_data = $this->tree->getNodeData($id);
01286 $subtree_nodes = $this->tree->getSubTree($node_data);
01287
01288 $all_node_data[] = $node_data;
01289 $all_subtree_nodes[] = $subtree_nodes;
01290
01291
01292 foreach ($subtree_nodes as $node)
01293 {
01294 if($node['type'] == 'rolf')
01295 {
01296 continue;
01297 }
01298 if (!$rbacsystem->checkAccess('delete',$node["child"]))
01299 {
01300 $not_deletable[] = $node["child"];
01301 $perform_delete = false;
01302 }
01303 else if(ilPaymentObject::_isBuyable($node['child']))
01304 {
01305 $buyable[] = $node['child'];
01306 $perform_delete = false;
01307 }
01308 }
01309 }
01310
01311
01312 if (count($not_deletable))
01313 {
01314 $not_deletable = implode(',',$not_deletable);
01315 session_unregister("saved_post");
01316 sendInfo($this->lng->txt("msg_no_perm_delete")." ".$not_deletable."<br/>".$this->lng->txt("msg_cancel"),true);
01317 ilUtil::redirect($this->getReturnLocation("confirmedDelete","adm_object.php?ref_id=".$_GET["ref_id"]));
01318
01319
01320
01321 }
01322 if(count($buyable))
01323 {
01324 foreach($buyable as $id)
01325 {
01326 $tmp_object =& ilObjectFactory::getInstanceByRefId($id);
01327
01328 $titles[] = $tmp_object->getTitle();
01329 }
01330 $title_str = implode(',',$titles);
01331
01332 sendInfo($this->lng->txt('msg_obj_not_deletable_sold').' '.$title_str,true);
01333
01334 $_POST['id'] = $_SESSION['saved_post'];
01335 $this->deleteObject(true);
01336
01337 return false;
01338 }
01339
01340
01341 if (!$all_node_data[0]["type"])
01342 {
01343
01344 if ($rbacsystem->checkAccess('delete',$_GET["ref_id"]))
01345 {
01346 foreach($_SESSION["saved_post"] as $id)
01347 {
01348 $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
01349 $obj->delete();
01350
01351
01352 $log->write("ilObjectGUI::confirmedDeleteObject(), deleted obj_id ".$obj->getId().
01353 ", type: ".$obj->getType().", title: ".$obj->getTitle());
01354 }
01355 }
01356 else
01357 {
01358 unset($_SESSION["saved_post"]);
01359 sendInfo($this->lng->txt("no_perm_delete")."<br/>".$this->lng->txt("msg_cancel"),true);
01360 ilUtil::redirect($this->getReturnLocation("confirmedDelete","adm_object.php?ref_id=".$_GET["ref_id"]));
01361 }
01362 }
01363 else
01364 {
01365
01366 foreach ($_SESSION["saved_post"] as $id)
01367 {
01368
01369 $subnodes = $this->tree->getSubtree($this->tree->getNodeData($id));
01370
01371 foreach ($subnodes as $subnode)
01372 {
01373 $rbacadmin->revokePermission($subnode["child"]);
01374
01375 $affected_users = ilUtil::removeItemFromDesktops($subnode["child"]);
01376
01377
01378
01379 }
01380
01381 $this->tree->saveSubTree($id);
01382 $this->tree->deleteTree($this->tree->getNodeData($id));
01383
01384
01385 $log->write("ilObjectGUI::confirmedDeleteObject(), moved ref_id ".$id.
01386 " to trash");
01387
01388
01389 $affected_users = ilUtil::removeItemFromDesktops($id);
01390
01391
01392
01393 }
01394
01395
01396 }
01397
01398
01399 sendInfo($this->lng->txt("info_deleted"),true);
01400
01401 ilUtil::redirect($this->getReturnLocation("confirmedDelete","adm_object.php?ref_id=".$_GET["ref_id"]));
01402
01403 }
01404
01410 function cancelDeleteObject()
01411 {
01412 session_unregister("saved_post");
01413
01414 sendInfo($this->lng->txt("msg_cancel"),true);
01415
01416 ilUtil::redirect($this->getReturnLocation("cancelDelete","adm_object.php?ref_id=".$_GET["ref_id"]));
01417
01418 }
01419
01425 function removeFromSystemObject()
01426 {
01427 global $rbacsystem, $log;
01428
01429
01430 if (!isset($_POST["trash_id"]))
01431 {
01432 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01433 }
01434
01435
01436
01437
01438 foreach ($_POST["trash_id"] as $id)
01439 {
01440
01441 $saved_tree = new ilTree(-(int)$id);
01442 $node_data = $saved_tree->getNodeData($id);
01443 $subtree_nodes = $saved_tree->getSubTree($node_data);
01444
01445
01446
01447 $checked[] = -(int) $id;
01448
01449
01450 $this->removeDeletedNodes($id,$checked);
01451
01452 foreach ($subtree_nodes as $node)
01453 {
01454 $node_obj =& $this->ilias->obj_factory->getInstanceByRefId($node["ref_id"]);
01455
01456
01457 $log->write("ilObjectGUI::removeFromSystemObject(), delete obj_id: ".$node_obj->getId().
01458 ", ref_id: ".$node_obj->getRefId().", type: ".$node_obj->getType().", ".
01459 "title: ".$node_obj->getTitle());
01460
01461 $node_obj->delete();
01462 }
01463
01464
01465 #$this->tree->deleteTree($node_data);
01466
01467 $saved_tree->deleteTree($node_data);
01468
01469
01470 $log->write("ilObjectGUI::removeFromSystemObject(), deleted tree, tree_id: ".$node_data["tree"].
01471 ", child: ".$node_data["child"]);
01472
01473 }
01474
01475 sendInfo($this->lng->txt("msg_removed"),true);
01476
01477 ilUtil::redirect($this->getReturnLocation("removeFromSystem","adm_object.php?ref_id=".$_GET["ref_id"]));
01478
01479 }
01480
01489 function removeDeletedNodes($a_node_id, $a_checked, $a_delete_objects = true)
01490 {
01491 global $log;
01492
01493 $q = "SELECT tree FROM tree WHERE parent='".$a_node_id."' AND tree < 0";
01494
01495 $r = $this->ilias->db->query($q);
01496
01497 while($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
01498 {
01499
01500 if (!in_array($row->tree,$a_checked))
01501 {
01502 $deleted_tree = new ilTree($row->tree);
01503 $a_checked[] = $row->tree;
01504
01505 $row->tree = $row->tree * (-1);
01506 $del_node_data = $deleted_tree->getNodeData($row->tree);
01507 $del_subtree_nodes = $deleted_tree->getSubTree($del_node_data);
01508
01509 $this->removeDeletedNodes($row->tree,$a_checked);
01510
01511 if ($a_delete_objects)
01512 {
01513 foreach ($del_subtree_nodes as $node)
01514 {
01515 $node_obj =& $this->ilias->obj_factory->getInstanceByRefId($node["ref_id"]);
01516
01517
01518 $log->write("ilObjectGUI::removeDeletedNodes(), delete obj_id: ".$node_obj->getId().
01519 ", ref_id: ".$node_obj->getRefId().", type: ".$node_obj->getType().", ".
01520 "title: ".$node_obj->getTitle());
01521
01522 $node_obj->delete();
01523 }
01524 }
01525
01526 $this->tree->deleteTree($del_node_data);
01527
01528
01529 $log->write("ilObjectGUI::removeDeletedNodes(), deleted tree, tree_id: ".$del_node_data["tree"].
01530 ", child: ".$del_node_data["child"]);
01531 }
01532 }
01533
01534 return true;
01535 }
01536
01542 function createObject()
01543 {
01544 global $rbacsystem;
01545
01546 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
01547
01548 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
01549 {
01550 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01551 }
01552 else
01553 {
01554
01555 $data = array();
01556 $data["fields"] = array();
01557 $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
01558 $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
01559
01560 $this->getTemplateFile("edit",$new_type);
01561
01562 foreach ($data["fields"] as $key => $val)
01563 {
01564 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
01565 $this->tpl->setVariable(strtoupper($key), $val);
01566
01567 if ($this->prepare_output)
01568 {
01569 $this->tpl->parseCurrentBlock();
01570 }
01571 }
01572
01573 $this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".
01574 $_GET["ref_id"]."&new_type=".$new_type));
01575 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
01576 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01577 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
01578 $this->tpl->setVariable("CMD_SUBMIT", "save");
01579 $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
01580 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01581 }
01582 }
01583
01589 function cancelObject($in_rep = false)
01590 {
01591 session_unregister("saved_post");
01592
01593 sendInfo($this->lng->txt("msg_cancel"),true);
01594
01595
01596 $return_location = $_GET["cmd_return_location"];
01597
01598
01599 if ($in_rep)
01600 {
01601 $this->ctrl->returnToParent($this);
01602 }
01603 else
01604 {
01605 ilUtil::redirect($this->getReturnLocation("cancel",$this->ctrl->getTargetScript()."?".$this->link_params));
01606 }
01607 }
01608
01614 function saveObject()
01615 {
01616 global $rbacsystem, $objDefinition;
01617
01618 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
01619
01620
01621 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
01622 {
01623 $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
01624 }
01625
01626 $module = $objDefinition->getModule($_GET["new_type"]);
01627 $module_dir = ($module == "")
01628 ? ""
01629 : $module."/";
01630
01631
01632 $class_name = "ilObj".$objDefinition->getClassName($_GET["new_type"]);
01633 include_once($module_dir."classes/class.".$class_name.".php");
01634 $newObj = new $class_name();
01635 $newObj->setType($_GET["new_type"]);
01636 $newObj->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
01637 $newObj->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
01638 $newObj->create();
01639 $newObj->createReference();
01640 $newObj->putInTree($_GET["ref_id"]);
01641 $newObj->setPermissions($_GET["ref_id"]);
01642
01643
01644 return $newObj;
01645 }
01646
01647
01653 function importObject()
01654 {
01655 global $rbacsystem;
01656
01657
01658 if (!$rbacsystem->checkAccess('write', $_GET["ref_id"], $_POST["new_type"]))
01659 {
01660 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->WARNING);
01661 }
01662
01663 $imp_obj =$this->objDefinition->getImportObjects($this->object->getType());
01664
01665 if (!in_array($_POST["new_type"], $imp_obj))
01666 {
01667 $this->ilias->raiseError($this->lng->txt("no_import_available").
01668 " ".$this->lng->txt("obj_".$_POST["new_type"]),
01669 $this->ilias->error_obj->MESSAGE);
01670 }
01671
01672
01673 }
01674
01675
01681 function editObject()
01682 {
01683 global $rbacsystem;
01684
01685 if (!$rbacsystem->checkAccess("write", $this->ref_id))
01686 {
01687 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
01688 }
01689
01690 $fields = array();
01691
01692 if ($_SESSION["error_post_vars"])
01693 {
01694
01695 $fields["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
01696 $fields["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
01697 }
01698 else
01699 {
01700 $fields["title"] = ilUtil::prepareFormOutput($this->object->getTitle());
01701 $fields["desc"] = ilUtil::stripSlashes($this->object->getDescription());
01702 }
01703
01704 $this->displayEditForm($fields);
01705 }
01706
01713 function displayEditForm($fields)
01714 {
01715 $this->getTemplateFile("edit");
01716
01717 foreach ($fields as $key => $val)
01718 {
01719 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
01720 $this->tpl->setVariable(strtoupper($key), $val);
01721 $this->tpl->parseCurrentBlock();
01722 }
01723
01724 $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
01725
01726 $this->tpl->setVariable("FORMACTION", $this->getFormAction("update",$this->ctrl->getFormAction($this).$obj_str));
01727
01728 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->object->getType()."_edit"));
01729 $this->tpl->setVariable("TARGET", $this->getTargetFrame("update"));
01730 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01731 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
01732 $this->tpl->setVariable("CMD_SUBMIT", "update");
01733 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01734
01735 }
01736
01737
01743 function updateObject()
01744 {
01745 $this->object->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
01746 $this->object->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
01747 $this->update = $this->object->update();
01748
01749 sendInfo($this->lng->txt("msg_obj_modified"),true);
01750
01751 ilUtil::redirect($this->getReturnLocation("update",$this->ctrl->getLinkTarget($this)));
01752
01753 }
01754
01760 function permObject()
01761 {
01762 global $rbacsystem, $rbacreview;
01763
01764 static $num = 0;
01765 if (!$rbacsystem->checkAccess("edit_permission", $this->object->getRefId()))
01766 {
01767 $this->ilias->raiseError($this->lng->txt("msg_no_perm_perm"),$this->ilias->error_obj->MESSAGE);
01768 }
01769
01770
01771 $parentRoles = $rbacreview->getParentRoleIds($this->object->getRefId());
01772
01773 $data = array();
01774
01775
01776 $role_folder = $rbacreview->getRoleFolderOfObject($this->object->getRefId());
01777
01778 $local_roles = array();
01779
01780 if ($role_folder)
01781 {
01782 $local_roles = $rbacreview->getRolesOfRoleFolder($role_folder["ref_id"]);
01783 }
01784
01785 foreach ($parentRoles as $key => $r)
01786 {
01787 if ($r["obj_id"] == SYSTEM_ROLE_ID)
01788 {
01789 unset($parentRoles[$key]);
01790 continue;
01791 }
01792
01793 if (!in_array($r["obj_id"],$local_roles))
01794 {
01795 $data["check_inherit"][] = ilUtil::formCheckBox(0,"stop_inherit[]",$r["obj_id"]);
01796 }
01797 else
01798 {
01799 $r["link"] = true;
01800
01801
01802 if ($rbacreview->isAssignable($r["obj_id"],$role_folder["ref_id"]))
01803 {
01804 $data["check_inherit"][] = " ";
01805 }
01806 else
01807 {
01808
01809 $data["check_inherit"][] = ilUtil::formCheckBox(1,"stop_inherit[]",$r["obj_id"]);
01810 }
01811 }
01812
01813 $data["roles"][] = $r;
01814 }
01815
01816 $ope_list = getOperationList($this->object->getType());
01817
01818
01819 foreach ($ope_list as $key => $operation)
01820 {
01821 $opdata = array();
01822
01823 $opdata["name"] = $operation["operation"];
01824
01825 $colspan = count($parentRoles) + 1;
01826
01827 foreach ($parentRoles as $role)
01828 {
01829 $checked = $rbacsystem->checkPermission($this->object->getRefId(), $role["obj_id"],$operation["operation"],$_GET["parent"]);
01830 $disabled = false;
01831
01832
01833 $box = ilUtil::formCheckBox($checked,"perm[".$role["obj_id"]."][]",$operation["ops_id"],$disabled);
01834 $opdata["values"][] = $box;
01835 }
01836
01837 $data["permission"][] = $opdata;
01838 }
01839
01841
01843 $this->getTemplateFile("perm");
01844 $this->tpl->setCurrentBlock("tableheader");
01845 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("permission_settings"));
01846 $this->tpl->setVariable("COLSPAN", $colspan);
01847 $this->tpl->setVariable("TXT_OPERATION", $this->lng->txt("operation"));
01848 $this->tpl->setVariable("TXT_ROLES", $this->lng->txt("roles"));
01849 $this->tpl->parseCurrentBlock();
01850
01851 $num = 0;
01852
01853 foreach ($data["roles"] as $role)
01854 {
01855 if(0 and $role['role_type'] != 'global' and is_object($this->ctrl))
01856 {
01857 $this->tpl->setCurrentBlock("ROLELINK_OPEN");
01858 $this->ctrl->setParameterByClass('ilobjrolegui','obj_id',$role['obj_id']);
01859 $this->tpl->setVariable("LINK_ROLE_RULESET",
01860 $this->ctrl->getLinkTargetByClass('ilobjrolegui','perm'));
01861 $this->tpl->setVariable("TXT_ROLE_RULESET",$this->lng->txt("edit_perm_ruleset"));
01862 $this->tpl->parseCurrentBlock();
01863
01864 $this->tpl->touchBlock("ROLELINK_CLOSE");
01865 }
01866
01867 $this->tpl->setCurrentBlock("ROLENAMES");
01868 $this->tpl->setVariable("ROLE_NAME",$role["title"]);
01869 $this->tpl->parseCurrentBlock();
01870
01871
01872 if ($this->objDefinition->stopInheritance($this->type))
01873 {
01874 $this->tpl->setCurrentBLock("CHECK_INHERIT");
01875 $this->tpl->setVariable("CHECK_INHERITANCE",$data["check_inherit"][$num]);
01876 $this->tpl->parseCurrentBlock();
01877 }
01878
01879 $num++;
01880 }
01881
01882
01883 $colspan = $num + 1;
01884 $num = 0;
01885
01886
01887 if ($this->objDefinition->stopInheritance($this->type))
01888 {
01889 $this->tpl->setCurrentBLock("STOP_INHERIT");
01890 $this->tpl->setVariable("TXT_STOP_INHERITANCE", $this->lng->txt("stop_inheritance"));
01891 $this->tpl->parseCurrentBlock();
01892 }
01893
01894 foreach ($data["permission"] as $ar_perm)
01895 {
01896 foreach ($ar_perm["values"] as $box)
01897 {
01898
01899 $this->tpl->setCurrentBlock("CHECK_PERM");
01900 $this->tpl->setVariable("CHECK_PERMISSION",$box);
01901 $this->tpl->parseCurrentBlock();
01902
01903 }
01904
01905
01906 $this->tpl->setCurrentBlock("TABLE_DATA_OUTER");
01907 $css_row = ilUtil::switchColor($num++, "tblrow1", "tblrow2");
01908 $this->tpl->setVariable("CSS_ROW",$css_row);
01909 $this->tpl->setVariable("PERMISSION", $this->lng->txt($this->object->getType()."_".$ar_perm["name"]));
01910 if (substr($ar_perm["name"], 0, 7) == "create_")
01911 {
01912 if ($this->objDefinition->getDevMode(substr($ar_perm["name"], 7, strlen($ar_perm["name"]) -7)))
01913 {
01914 $this->tpl->setVariable("TXT_NOT_IMPL", "(".$this->lng->txt("not_implemented_yet").")");
01915 }
01916 }
01917 $this->tpl->parseCurrentBlock();
01918
01919 }
01920
01921
01922
01923
01924 $object_types_exclude = array("adm","root","mail","usrf","objf","lngf","trac","taxf","auth", "assf");
01925
01926 if (!in_array($this->object->getType(),$object_types_exclude) and $this->object->getRefId() != ROLE_FOLDER_ID)
01927
01928 {
01929 $this->tpl->setCurrentBlock("LOCAL_ROLE");
01930
01931
01932 $data = array();
01933 $data["fields"] = array();
01934 $data["fields"]["title"] = $_SESSION["error_post_vars"]["Fobject"]["title"];
01935 $data["fields"]["desc"] = $_SESSION["error_post_vars"]["Fobject"]["desc"];
01936
01937 foreach ($data["fields"] as $key => $val)
01938 {
01939 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
01940 $this->tpl->setVariable(strtoupper($key), $val);
01941 }
01942
01943 $this->tpl->setVariable("FORMACTION_LR",$this->getFormAction("addRole", $this->ctrl->getLinkTarget($this, "addRole")));
01944
01945 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("you_may_add_local_roles"));
01946 $this->tpl->setVariable("TXT_ADD_ROLE", $this->lng->txt("role_add_local"));
01947 $this->tpl->setVariable("TARGET", $this->getTargetFrame("addRole"));
01948 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01949 $this->tpl->parseCurrentBlock();
01950 }
01951
01952
01953
01954 $this->tpl->setCurrentBlock("adm_content");
01955 $this->tpl->setVariable("FORMACTION",
01956 $this->getFormAction("permSave",$this->ctrl->getLinkTarget($this,"permSave")));
01957
01958
01959 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
01960 $this->tpl->setVariable("COL_ANZ",$colspan);
01961 $this->tpl->parseCurrentBlock();
01962 }
01963
01972 function getFormAction($a_cmd, $a_formaction ="")
01973 {
01974 if ($this->formaction[$a_cmd] != "")
01975 {
01976 return $this->formaction[$a_cmd];
01977 }
01978 else
01979 {
01980 return $a_formaction;
01981 }
01982 }
01983
01992 function setFormAction($a_cmd, $a_formaction)
01993 {
01994 $this->formaction[$a_cmd] = $a_formaction;
01995 }
01996
02004 function getReturnLocation($a_cmd, $a_location ="")
02005 {
02006 if ($this->return_location[$a_cmd] != "")
02007 {
02008 return $this->return_location[$a_cmd];
02009 }
02010 else
02011 {
02012 return $a_location;
02013 }
02014 }
02015
02023 function setReturnLocation($a_cmd, $a_location)
02024 {
02025 $this->return_location[$a_cmd] = $a_location;
02026 }
02027
02035 function getTargetFrame($a_cmd, $a_target_frame = "")
02036 {
02037 if ($this->target_frame[$a_cmd] != "")
02038 {
02039 return $this->target_frame[$a_cmd];
02040 }
02041 elseif (!empty($a_target_frame))
02042 {
02043 return "target=\"".$a_target_frame."\"";
02044 }
02045 else
02046 {
02047 return;
02048 }
02049 }
02050
02058 function setTargetFrame($a_cmd, $a_target_frame)
02059 {
02060 $this->target_frame[$a_cmd] = "target=\"".$a_target_frame."\"";
02061 }
02062
02068 function permSaveObject()
02069 {
02070 global $rbacsystem, $rbacreview, $rbacadmin;
02071
02072
02073 $rbacadmin->revokePermission($this->ref_id);
02074
02075 if (is_array($_POST["perm"]))
02076 {
02077 foreach ($_POST["perm"] as $key => $new_role_perms)
02078 {
02079
02080 $rbacadmin->grantPermission($key,$new_role_perms,$this->ref_id);
02081 }
02082 }
02083
02084
02085 $this->object->update();
02086
02087
02088
02089
02090
02091
02092
02093
02094
02095 $rolf_data = $rbacreview->getRoleFolderOfObject($this->ref_id);
02096 $rolf_id = $rolf_data["child"];
02097
02098 if ($_POST["stop_inherit"])
02099 {
02100
02101 if (empty($rolf_id))
02102 {
02103
02104 $rfoldObj = $this->object->createRoleFolder();
02105
02106
02107 $rolf_id = $rfoldObj->getRefId();
02108 }
02109
02110
02111 if (!$rbacsystem->checkAccess('write',$rolf_id))
02112 {
02113 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
02114 }
02115
02116 foreach ($_POST["stop_inherit"] as $stop_inherit)
02117 {
02118 $roles_of_folder = $rbacreview->getRolesOfRoleFolder($rolf_id);
02119
02120
02121 if (!in_array($stop_inherit,$roles_of_folder))
02122 {
02123 $parentRoles = $rbacreview->getParentRoleIds($rolf_id);
02124 $rbacadmin->copyRolePermission($stop_inherit,$parentRoles[$stop_inherit]["parent"],
02125 $rolf_id,$stop_inherit);
02126 $rbacadmin->assignRoleToFolder($stop_inherit,$rolf_id,'n');
02127 }
02128 }
02129 }
02130 elseif (!empty($rolf_id))
02131 {
02132
02133
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143 }
02144
02145 sendinfo($this->lng->txt("saved_successfully"),true);
02146 ilUtil::redirect($this->getReturnLocation("permSave",$this->ctrl->getLinkTarget($this,"perm")));
02147 }
02148
02154 function ownerObject()
02155 {
02156 $this->getTemplateFile("owner");
02157 $this->tpl->setVariable("OWNER_NAME", $this->object->getOwnerName());
02158 $this->tpl->setVariable("TXT_OBJ_OWNER", $this->lng->txt("obj_owner"));
02159 $this->tpl->setVariable("CMD","update");
02160 $this->tpl->parseCurrentBlock();
02161 }
02162
02168 function displayList()
02169 {
02170 include_once "./classes/class.ilTableGUI.php";
02171
02172
02173 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
02174
02175 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
02176
02177 $num = 0;
02178
02179 $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
02180 $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."$obj_str&cmd=gateway");
02181
02182
02183 $tbl = new ilTableGUI();
02184
02185
02186 $tbl->setTitle($this->object->getTitle(),"icon_".$this->object->getType()."_b.gif",
02187 $this->lng->txt("obj_".$this->object->getType()));
02188 $tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
02189
02190 foreach ($this->data["cols"] as $val)
02191 {
02192 $header_names[] = $this->lng->txt($val);
02193 }
02194
02195 $tbl->setHeaderNames($header_names);
02196
02197 $header_params = array("ref_id" => $this->ref_id);
02198 $tbl->setHeaderVars($this->data["cols"],$header_params);
02199 $tbl->setColumnWidth(array("15","15","75%","25%"));
02200
02201
02202 $tbl->setOrderColumn($_GET["sort_by"]);
02203 $tbl->setOrderDirection($_GET["sort_order"]);
02204 $tbl->setLimit($_GET["limit"]);
02205 $tbl->setOffset($_GET["offset"]);
02206 $tbl->setMaxCount($this->maxcount);
02207
02208 $this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
02209
02210
02211 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
02212
02213 $this->showActions(true);
02214
02215 if (!empty($this->data["data"][0]))
02216 {
02217
02218 for ($i=0; $i < count($this->data["data"]); $i++)
02219 {
02220 $data = $this->data["data"][$i];
02221 $ctrl = $this->data["ctrl"][$i];
02222
02223
02224 $css_row = ilUtil::switchColor($i+1,"tblrow1","tblrow2");
02225
02226
02227 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)
02228 {
02229 $this->tpl->touchBlock("empty_cell");
02230 }
02231 else
02232 {
02233
02234 if ($ctrl["type"] == "usr" or $ctrl["type"] == "role" or $ctrl["type"] == "rolt")
02235 {
02236 $link_id = $ctrl["obj_id"];
02237 }
02238 else
02239 {
02240 $link_id = $ctrl["ref_id"];
02241 }
02242
02243 $this->tpl->setCurrentBlock("checkbox");
02244 $this->tpl->setVariable("CHECKBOX_ID", $link_id);
02245 $this->tpl->setVariable("CSS_ROW", $css_row);
02246 $this->tpl->parseCurrentBlock();
02247 }
02248
02249 $this->tpl->setCurrentBlock("table_cell");
02250 $this->tpl->setVariable("CELLSTYLE", "tblrow1");
02251 $this->tpl->parseCurrentBlock();
02252
02253 foreach ($data as $key => $val)
02254 {
02255
02256 $link = "adm_object.php?";
02257
02258 $n = 0;
02259
02260 foreach ($ctrl as $key2 => $val2)
02261 {
02262 $link .= $key2."=".$val2;
02263
02264 if ($n < count($ctrl)-1)
02265 {
02266 $link .= "&";
02267 $n++;
02268 }
02269 }
02270
02271 if ($key == "name" || $key == "title")
02272 {
02273 $name_field = explode("#separator#",$val);
02274 }
02275
02276 if ($key == "title" || $key == "name" || $key == "type")
02277 {
02278 $this->tpl->setCurrentBlock("begin_link");
02279 $this->tpl->setVariable("LINK_TARGET", $link);
02280
02281 $this->tpl->parseCurrentBlock();
02282 $this->tpl->touchBlock("end_link");
02283 }
02284
02285
02286 if (($key == "title" || $key == "name") and isset($_SESSION["clipboard"]))
02287 {
02288
02289 if (in_array($ctrl["ref_id"],$_SESSION["clipboard"]["ref_ids"]))
02290 {
02291 switch($_SESSION["clipboard"]["cmd"])
02292 {
02293 case "cut":
02294 $name_field[0] = "<del>".$name_field[0]."</del>";
02295 break;
02296
02297 case "copy":
02298 $name_field[0] = "<font color=\"green\">+</font> ".$name_field[0];
02299 break;
02300
02301 case "link":
02302 $name_field[0] = "<font color=\"black\"><</font> ".$name_field[0];
02303 break;
02304 }
02305 }
02306 }
02307
02308 $this->tpl->setCurrentBlock("text");
02309
02310 if ($key == "type")
02311 {
02312 $val = ilUtil::getImageTagByType($val,$this->tpl->tplPath);
02313 }
02314
02315 if ($key == "name" || $key == "title")
02316 {
02317 $this->tpl->setVariable("TEXT_CONTENT", $name_field[0]);
02318
02319 $this->tpl->setCurrentBlock("subtitle");
02320 $this->tpl->setVariable("DESC", $name_field[1]);
02321 $this->tpl->parseCurrentBlock();
02322 }
02323 else
02324 {
02325 $this->tpl->setVariable("TEXT_CONTENT", $val);
02326 }
02327
02328 $this->tpl->parseCurrentBlock();
02329
02330 $this->tpl->setCurrentBlock("table_cell");
02331 $this->tpl->parseCurrentBlock();
02332
02333 }
02334
02335 $this->tpl->setCurrentBlock("tbl_content");
02336 $this->tpl->setVariable("CSS_ROW", $css_row);
02337 $this->tpl->parseCurrentBlock();
02338 }
02339 }
02340 else
02341 {
02342 $tbl->disable("header");
02343 $tbl->disable("footer");
02344
02345 $this->tpl->setCurrentBlock("text");
02346 $this->tpl->setVariable("TEXT_CONTENT", $this->lng->txt("obj_not_found"));
02347 $this->tpl->parseCurrentBlock();
02348 }
02349
02350
02351 $tbl->render();
02352 }
02353
02359 function viewObject()
02360 {
02361 global $rbacsystem;
02362
02363 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
02364 {
02365 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
02366 }
02367
02368
02369 $this->objectList = array();
02370 $this->data["data"] = array();
02371 $this->data["ctrl"] = array();
02372 $this->data["cols"] = array("", "type", "title", "last_change");
02373
02374 $childs = $this->tree->getChilds($_GET["ref_id"], $_GET["order"], $_GET["direction"]);
02375
02376 foreach ($childs as $key => $val)
02377 {
02378
02379 if (!$rbacsystem->checkAccess("visible",$val["ref_id"]))
02380 {
02381 continue;
02382 }
02383
02384
02385 if ($this->objDefinition->getDevMode($val["type"]))
02386 {
02387 continue;
02388 }
02389
02390
02391 $this->data["data"][] = array(
02392 "type" => $val["type"],
02393 "title" => $val["title"]."#separator#".$val["desc"],
02394
02395 "last_change" => $val["last_update"],
02396 "ref_id" => $val["ref_id"]
02397 );
02398
02399
02400
02401 }
02402
02403 $this->maxcount = count($this->data["data"]);
02404
02405 $this->data["data"] = ilUtil::sortArray($this->data["data"],$_GET["sort_by"],$_GET["sort_order"]);
02406 $this->data["data"] = array_slice($this->data["data"],$_GET["offset"],$_GET["limit"]);
02407
02408
02409 foreach ($this->data["data"] as $key => $val)
02410 {
02411 $this->data["ctrl"][$key] = array(
02412 "type" => $val["type"],
02413 "ref_id" => $val["ref_id"]
02414 );
02415
02416 unset($this->data["data"][$key]["ref_id"]);
02417 $this->data["data"][$key]["last_change"] = ilFormat::formatDate($this->data["data"][$key]["last_change"]);
02418 }
02419
02420 $this->displayList();
02421 }
02422
02430 function deleteObject($a_error = false)
02431 {
02432 if (!isset($_POST["id"]))
02433 {
02434 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
02435 }
02436
02437
02438 $_SESSION["saved_post"] = $_POST["id"];
02439
02440 unset($this->data);
02441 $this->data["cols"] = array("type", "title", "last_change");
02442
02443 foreach ($_POST["id"] as $id)
02444 {
02445
02446
02447
02448
02449 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($id);
02450
02451
02452
02453
02454
02455
02456 $this->data["data"]["$id"] = array(
02457 "type" => $obj_data->getType(),
02458 "title" => $obj_data->getTitle()."#separator#".$obj_data->getDescription()." ",
02459 "last_update" => $obj_data->getLastUpdateDate()
02460 );
02461 }
02462
02463 $this->data["buttons"] = array( "confirmedDelete" => $this->lng->txt("confirm"),
02464 "cancelDelete" => $this->lng->txt("cancel"));
02465
02466 $this->getTemplateFile("confirm");
02467
02468 if(!$a_error)
02469 {
02470 sendInfo($this->lng->txt("info_delete_sure"));
02471 }
02472
02473 $this->tpl->setVariable("FORMACTION", $this->getFormAction("delete",
02474 "adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=gateway"));
02475
02476
02477 foreach ($this->data["cols"] as $key)
02478 {
02479 $this->tpl->setCurrentBlock("table_header");
02480 $this->tpl->setVariable("TEXT",$this->lng->txt($key));
02481 $this->tpl->parseCurrentBlock();
02482 }
02483
02484
02485
02486 $counter = 0;
02487
02488 foreach ($this->data["data"] as $key => $value)
02489 {
02490
02491 foreach ($value as $key => $cell_data)
02492 {
02493 $this->tpl->setCurrentBlock("table_cell");
02494
02495
02496 if ($key == "type")
02497 {
02498 $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
02499 }
02500 elseif ($key == "title")
02501 {
02502 $name_field = explode("#separator#",$cell_data);
02503
02504 $this->tpl->setVariable("TEXT_CONTENT", "<b>".$name_field[0]."</b>");
02505
02506 $this->tpl->setCurrentBlock("subtitle");
02507 $this->tpl->setVariable("DESC", $name_field[1]);
02508 $this->tpl->parseCurrentBlock();
02509 $this->tpl->setCurrentBlock("table_cell");
02510 }
02511 else
02512 {
02513 $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
02514 }
02515
02516 $this->tpl->parseCurrentBlock();
02517 }
02518
02519 $this->tpl->setCurrentBlock("table_row");
02520 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
02521 $this->tpl->parseCurrentBlock();
02522
02523 }
02524
02525
02526
02527 foreach ($this->data["buttons"] as $name => $value)
02528 {
02529 $this->tpl->setCurrentBlock("operation_btn");
02530 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
02531 $this->tpl->setVariable("BTN_NAME",$name);
02532 $this->tpl->setVariable("BTN_VALUE",$value);
02533 $this->tpl->parseCurrentBlock();
02534 }
02535 }
02536
02542 function trashObject()
02543 {
02544 $objects = $this->tree->getSavedNodeData($_GET["ref_id"]);
02545
02546 if (count($objects) == 0)
02547 {
02548 sendInfo($this->lng->txt("msg_trash_empty"));
02549 $this->data["empty"] = true;
02550 }
02551 else
02552 {
02553 $this->data["empty"] = false;
02554 $this->data["cols"] = array("","type", "title", "last_change");
02555
02556 foreach ($objects as $obj_data)
02557 {
02558 $this->data["data"]["$obj_data[child]"] = array(
02559 "checkbox" => "",
02560 "type" => $obj_data["type"],
02561 "title" => $obj_data["title"]."#separator#".$obj_data["desc"],
02562 "last_update" => $obj_data["last_update"]
02563 );
02564 }
02565
02566 $this->data["buttons"] = array( "undelete" => $this->lng->txt("btn_undelete"),
02567 "removeFromSystem" => $this->lng->txt("btn_remove_system"));
02568 }
02569
02570 $this->getTemplateFile("confirm");
02571
02572 if ($this->data["empty"] == true)
02573 {
02574 return;
02575 }
02576
02577
02578
02579
02580
02581
02582
02583
02584
02585 $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=gateway");
02586 $this->tpl->setVariable("TPLPATH",$this->tpl->tplPath);
02587
02588
02589 foreach ($this->data["cols"] as $key)
02590 {
02591 $this->tpl->setCurrentBlock("table_header");
02592 $this->tpl->setVariable("TEXT",$this->lng->txt($key));
02593 $this->tpl->parseCurrentBlock();
02594 }
02595
02596
02597
02598 $counter = 0;
02599
02600 foreach ($this->data["data"] as $key1 => $value)
02601 {
02602
02603 foreach ($value as $key2 => $cell_data)
02604 {
02605 $this->tpl->setCurrentBlock("table_cell");
02606
02607 if ($key2 == "checkbox")
02608 {
02609 $this->tpl->setVariable("TEXT_CONTENT",ilUtil::formCheckBox(0,"trash_id[]",$key1));
02610 }
02611
02612 elseif ($key2 == "type")
02613 {
02614 $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
02615 }
02616 elseif ($key2 == "title")
02617 {
02618 $name_field = explode("#separator#",$cell_data);
02619
02620 $this->tpl->setVariable("TEXT_CONTENT", "<b>".$name_field[0]."</b>");
02621
02622 $this->tpl->setCurrentBlock("subtitle");
02623 $this->tpl->setVariable("DESC", $name_field[1]);
02624 $this->tpl->parseCurrentBlock();
02625 $this->tpl->setCurrentBlock("table_cell");
02626 }
02627 else
02628 {
02629 $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
02630 }
02631
02632 $this->tpl->parseCurrentBlock();
02633 }
02634
02635 $this->tpl->setCurrentBlock("table_row");
02636 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
02637 $this->tpl->parseCurrentBlock();
02638
02639 }
02640
02641
02642
02643 foreach ($this->data["buttons"] as $name => $value)
02644 {
02645 $this->tpl->setCurrentBlock("operation_btn");
02646 $this->tpl->setVariable("BTN_NAME",$name);
02647 $this->tpl->setVariable("BTN_VALUE",$value);
02648 $this->tpl->parseCurrentBlock();
02649 }
02650 }
02651
02659 function addRoleObject()
02660 {
02661 global $rbacadmin, $rbacreview, $rbacsystem;
02662
02663
02664 if ($rbacreview->roleExists($_POST["Fobject"]["title"]))
02665 {
02666 $this->ilias->raiseError($this->lng->txt("msg_role_exists1")." '".ilUtil::stripSlashes($_POST["Fobject"]["title"])."' ".
02667 $this->lng->txt("msg_role_exists2"),$this->ilias->error_obj->MESSAGE);
02668 }
02669
02670
02671 if (substr($_POST["Fobject"]["title"],0,3) == "il_")
02672 {
02673 $this->ilias->raiseError($this->lng->txt("msg_role_reserved_prefix"),$this->ilias->error_obj->MESSAGE);
02674 }
02675
02676
02677 if ($this->object->getType() != "rolf")
02678 {
02679 $rolf_data = $rbacreview->getRoleFolderOfObject($this->ref_id);
02680
02681
02682 if (!($rolf_id = $rolf_data["child"]))
02683 {
02684
02685 $subobjects = $this->objDefinition->getSubObjects($this->object->getType());
02686
02687 if (!isset($subobjects["rolf"]))
02688 {
02689 $this->ilias->raiseError($this->lng->txt("msg_no_rolf_allowed1")." '".$this->object->getTitle()."' ".
02690 $this->lng->txt("msg_no_rolf_allowed2"),$this->ilias->error_obj->WARNING);
02691 }
02692
02693
02694 if (!$rbacsystem->checkAccess('create',$this->ref_id,'rolf'))
02695 {
02696 $this->ilias->raiseError($this->lng->txt("msg_no_perm_create_rolf"),$this->ilias->error_obj->WARNING);
02697 }
02698
02699
02700 $rolfObj = $this->object->createRoleFolder();
02701 $rolf_id = $rolfObj->getRefId();
02702 }
02703 }
02704 else
02705 {
02706
02707 $rolf_id = $this->object->getRefId();
02708 }
02709
02710
02711 if (!$rbacsystem->checkAccess('write',$rolf_id))
02712 {
02713 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
02714 }
02715 else
02716 {
02717 if ($this->object->getType() == "rolf")
02718 {
02719 $roleObj = $this->object->createRole($_POST["Fobject"]["title"],$_POST["Fobject"]["desc"]);
02720 }
02721 else
02722 {
02723 $rfoldObj = $this->ilias->obj_factory->getInstanceByRefId($rolf_id);
02724 $roleObj = $rfoldObj->createRole($_POST["Fobject"]["title"],$_POST["Fobject"]["desc"]);
02725 }
02726 }
02727
02728 sendInfo($this->lng->txt("role_added"),true);
02729
02730 if ($this->ctrl->getTargetScript() != "repository.php")
02731 {
02732 $this->ctrl->setParameter($this,"obj_id",$roleObj->getId());
02733 $this->ctrl->setParameter($this,"ref_id",$rolf_id);
02734 ilUtil::redirect($this->getReturnLocation("addRole",$this->ctrl->getLinkTarget($this,"perm")));
02735 }
02736
02737 ilUtil::redirect($this->getReturnLocation("addRole",$this->ctrl->getLinkTarget($this,"perm")));
02738 }
02739
02746 function showActions($with_subobjects = false)
02747 {
02748 $notoperations = array();
02749
02750 if (empty($_SESSION["clipboard"]))
02751 {
02752 $notoperations[] = "copy";
02753 $notoperations[] = "paste";
02754 $notoperations[] = "clear";
02755 }
02756
02757 if ($_SESSION["clipboard"])
02758 {
02759 $notoperations[] = "cut";
02760 $notoperations[] = "copy";
02761 $notoperations[] = "link";
02762 }
02763
02764 $operations = array();
02765
02766 if ($this->actions == "")
02767 {
02768 $d = $this->objDefinition->getActions($_GET["type"]);
02769 }
02770 else
02771 {
02772 $d = $this->actions;
02773 }
02774
02775 foreach ($d as $row)
02776 {
02777 if (!in_array($row["name"], $notoperations))
02778 {
02779 $operations[] = $row;
02780 }
02781 }
02782
02783 if (count($operations) > 0)
02784 {
02785 foreach ($operations as $val)
02786 {
02787 $this->tpl->setCurrentBlock("tbl_action_btn");
02788 $this->tpl->setVariable("BTN_NAME", $val["name"]);
02789 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
02790 $this->tpl->parseCurrentBlock();
02791 }
02792 }
02793
02794 if ($with_subobjects === true)
02795 {
02796 $this->showPossibleSubObjects();
02797 }
02798
02799 $this->tpl->setCurrentBlock("tbl_action_row");
02800 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
02801 $this->tpl->parseCurrentBlock();
02802 }
02803
02809 function showPossibleSubObjects()
02810 {
02811 if ($this->sub_objects == "")
02812 {
02813 $d = $this->objDefinition->getCreatableSubObjects($_GET["type"]);
02814 }
02815 else
02816 {
02817 $d = $this->sub_objects;
02818 }
02819
02820 $import = false;
02821
02822 if (count($d) > 0)
02823 {
02824 foreach ($d as $row)
02825 {
02826 $count = 0;
02827
02828 if ($row["max"] > 0)
02829 {
02830
02831 for ($i=0; $i<count($this->data["ctrl"]); $i++)
02832 {
02833 if ($this->data["ctrl"][$i]["type"] == $row["name"])
02834 {
02835 $count++;
02836 }
02837 }
02838 }
02839
02840 if ($row["max"] == "" || $count < $row["max"])
02841 {
02842 $subobj[] = $row["name"];
02843
02844 if ($row["import"] == "1")
02845 {
02846 $import = true;
02847 }
02848 }
02849 }
02850 }
02851
02852 if (is_array($subobj))
02853 {
02854
02855
02856 if ($import)
02857 {
02858 $this->tpl->setCurrentBlock("import_object");
02859 $this->tpl->setVariable("BTN_IMP", "import");
02860 $this->tpl->setVariable("TXT_IMP", $this->lng->txt("import"));
02861 $this->tpl->parseCurrentBlock();
02862 }
02863
02864
02865 $opts = ilUtil::formSelect(12,"new_type",$subobj);
02866 $this->tpl->setCurrentBlock("add_object");
02867 $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
02868 $this->tpl->setVariable("BTN_NAME", "create");
02869 $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
02870 $this->tpl->parseCurrentBlock();
02871 }
02872 }
02873
02882 function getTemplateFile($a_cmd,$a_type = "")
02883 {
02884 if (!$a_type)
02885 {
02886 $a_type = $this->type;
02887 }
02888
02889 $template = "tpl.".$a_type."_".$a_cmd.".html";
02890
02891 if (!$this->tpl->fileExists($template))
02892 {
02893 $template = "tpl.obj_".$a_cmd.".html";
02894 }
02895 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", $template,$a_in_module);
02896
02897 }
02898
02907 function getTitlesByRefId($a_ref_ids)
02908 {
02909 foreach ($a_ref_ids as $id)
02910 {
02911
02912 $tmp_obj =& $this->ilias->obj_factory->getInstanceByRefId($id);
02913 $title[] = $tmp_obj->getTitle();
02914 unset($tmp_obj);
02915 }
02916
02917 return $title ? $title : array();
02918 }
02919
02927 function getTabs(&$tabs_gui)
02928 {
02929
02930 }
02931
02932 function __showButton($a_cmd,$a_text,$a_target = '')
02933 {
02934 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
02935
02936
02937 $this->tpl->setCurrentBlock("btn_cell");
02938 $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this,$a_cmd));
02939 $this->tpl->setVariable("BTN_TXT",$a_text);
02940 if($a_target)
02941 {
02942 $this->tpl->setVariable("BTN_TARGET",$a_target);
02943 }
02944
02945 $this->tpl->parseCurrentBlock();
02946 }
02947
02948 function hitsperpageObject()
02949 {
02950 $_SESSION["tbl_limit"] = $_POST["hitsperpage"];
02951 $_GET["limit"] = $_POST["hitsperpage"];
02952 }
02953
02959 function clipboardObject()
02960 {
02961 global $ilErr,$ilLog;
02962
02963
02964 if (empty($_SESSION['il_rep_clipboard']) or !is_array($_SESSION['il_rep_clipboard']))
02965 {
02966 $message = sprintf('%s::clipboardObject(): Illegal access. Clipboard variable is empty!', get_class($this));
02967 $ilLog->write($message,$ilLog->FATAL);
02968 $ilErr->raiseError($this->lng->txt("permission_denied"),$ilErr->WARNING);
02969 }
02970
02971 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.rep_clipboard.html");
02972
02973
02974 $counter = 0;
02975 $f_result = array();
02976
02977 foreach($_SESSION['il_rep_clipboard'] as $data)
02978 {
02979 if(!$tmp_obj = ilObjectFactory::getInstanceByRefId($data['ref_id'],false))
02980 {
02981 continue;
02982 }
02983
02984
02985 $f_result[$counter][] = $this->lng->txt("obj_".$tmp_obj->getType());
02986 $f_result[$counter][] = $tmp_obj->getTitle();
02987
02988 $f_result[$counter][] = ($data['act'] == 'cut') ? $this->lng->txt("move") :$this->lng->txt($data['act']);
02989
02990 unset($tmp_obj);
02991 ++$counter;
02992 }
02993
02994 $this->__showClipboardTable($f_result,"clipboardObject");
02995
02996 return true;
02997 }
02998
02999 function &__initTableGUI()
03000 {
03001 include_once "./classes/class.ilTableGUI.php";
03002
03003 return new ilTableGUI(0,false);
03004 }
03005
03011 function __setTableGUIBasicData(&$tbl,&$result_set,$a_from = "")
03012 {
03013 switch ($a_from)
03014 {
03015 case "clipboardObject":
03016 $offset = $_GET["offset"];
03017 $order = $_GET["sort_by"];
03018 $direction = $_GET["sort_order"];
03019 $tbl->disable("footer");
03020 break;
03021
03022 default:
03023 $offset = $_GET["offset"];
03024 $order = $_GET["sort_by"];
03025 $direction = $_GET["sort_order"];
03026 break;
03027 }
03028
03029 $tbl->setOrderColumn($order);
03030 $tbl->setOrderDirection($direction);
03031 $tbl->setOffset($offset);
03032 $tbl->setLimit($_GET["limit"]);
03033 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
03034 $tbl->setData($result_set);
03035 }
03036
03037 function __showClipboardTable($a_result_set,$a_from = "")
03038 {
03039 $tbl =& $this->__initTableGUI();
03040 $tpl =& $tbl->getTemplateObject();
03041
03042 $tpl->setCurrentBlock("tbl_form_header");
03043 $tpl->setVariable("FORMACTION",$this->ctrl->getTargetScript()."?".$this->link_params."&cmd=post");
03044 $tpl->parseCurrentBlock();
03045
03046 $tpl->setCurrentBlock("tbl_action_btn");
03047 $tpl->setVariable("BTN_NAME","paste");
03048 $tpl->setVariable("BTN_VALUE",$this->lng->txt("insert_object_here"));
03049 $tpl->parseCurrentBlock();
03050
03051 $tpl->setCurrentBlock("tbl_action_btn");
03052 $tpl->setVariable("BTN_NAME","clear");
03053 $tpl->setVariable("BTN_VALUE",$this->lng->txt("clear_clipboard"));
03054 $tpl->parseCurrentBlock();
03055
03056 $tpl->setCurrentBlock("tbl_action_row");
03057 $tpl->setVariable("COLUMN_COUNTS",3);
03058 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("spacer.gif"));
03059 $tpl->parseCurrentBlock();
03060
03061 $tbl->setTitle($this->lng->txt("clipboard"),"icon_typ_b.gif",$this->lng->txt("clipboard"));
03062 $tbl->setHeaderNames(array($this->lng->txt('obj_type'),
03063 $this->lng->txt('title'),
03064 $this->lng->txt('action')));
03065 $tbl->setHeaderVars(array('type',
03066 'title',
03067 'act'),
03068 array('ref_id' => $this->object->getRefId(),
03069 'cmd' => 'clipboard',
03070 'cmdClass' => $_GET['cmdClass'],
03071 'cmdNode' => $_GET['cmdNode']));
03072
03073 $tbl->setColumnWidth(array("","80%","19%"));
03074
03075
03076 $this->__setTableGUIBasicData($tbl,$a_result_set,$a_from);
03077 $tbl->render();
03078
03079 $this->tpl->setVariable("RESULT_TABLE",$tbl->tpl->get());
03080
03081 return true;
03082 }
03083 }
03084 ?>