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
00036 require_once "class.ilObjectGUI.php";
00037
00038 class ilObjRoleFolderGUI extends ilObjectGUI
00039 {
00045 var $type;
00046
00051 function ilObjRoleFolderGUI($a_data,$a_id,$a_call_by_reference)
00052 {
00053 global $ilCtrl;
00054
00055 $this->ctrl =& $ilCtrl;
00056 $this->ctrl->saveParameter($this,array("ref_id","cmdClass"));
00057
00058 $this->type = "rolf";
00059 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference);
00060 }
00061
00062 function &executeCommand()
00063 {
00064 global $rbacsystem;
00065
00066 $next_class = $this->ctrl->getNextClass($this);
00067 $cmd = $this->ctrl->getCmd();
00068
00069 switch($next_class)
00070 {
00071 default:
00072 if(!$cmd)
00073 {
00074 $cmd = "view";
00075 }
00076 $cmd .= "Object";
00077 $this->$cmd();
00078
00079 break;
00080 }
00081 return true;
00082 }
00083
00089 function viewObject ()
00090 {
00091 global $rbacreview,$rbacsystem;
00092
00093 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00094 {
00095 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00096 }
00097
00098 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.usr_role_assignment.html');
00099
00100 $assignable = false;
00101
00102 if ($this->object->getId() == ROLE_FOLDER_ID)
00103 {
00104 $assignable = true;
00105
00106 $_SESSION['filtered_roles'] = isset($_POST['filter']) ? $_POST['filter'] : $_SESSION['filtered_roles'];
00107
00108 if ($_SESSION['filtered_roles'] == 0)
00109 {
00110 $_SESSION['filtered_roles'] = 2;
00111 }
00112
00113 $this->tpl->setCurrentBlock("filter");
00114 $this->tpl->setVariable("FILTER_TXT_FILTER",$this->lng->txt('filter'));
00115 $this->tpl->setVariable("SELECT_FILTER",$this->__buildFilterSelect());
00116 $this->tpl->setVariable("FILTER_ACTION",$this->ctrl->getFormAction($this));
00117 $this->tpl->setVariable("FILTER_NAME",'view');
00118 $this->tpl->setVariable("FILTER_VALUE",$this->lng->txt('apply_filter'));
00119 $this->tpl->parseCurrentBlock();
00120
00121
00122
00123 $role_list = $rbacreview->getRolesByFilter($_SESSION["filtered_roles"],$this->object->getId());
00124 }
00125 else
00126 {
00127 $role_list = $rbacreview->getRoleListByObject($_GET["ref_id"],true);
00128 }
00129
00130 $rbacreview->setRoleType($role_list);
00131
00132 $counter = 0;
00133
00134 include_once ('class.ilObjRole.php');
00135
00136 foreach ($role_list as $role)
00137 {
00138
00139 if ($role["type"] == "rolt")
00140 {
00141 $path = $this->lng->txt("obj_rolt");
00142 $rolf = ROLE_FOLDER_ID;
00143 }
00144 else
00145 {
00146
00147 $rolf_list = $rbacreview->getFoldersAssignedToRole($role["obj_id"],$assignable);
00148
00149 if ($this->object->getId() != ROLE_FOLDER_ID)
00150 {
00151 $rolf = $this->object->getRefId();
00152 }
00153 else
00154 {
00155 $rolf = $rolf_list[0];
00156 }
00157
00158
00159 if ($rbacreview->isDeleted($rolf))
00160 {
00161 continue;
00162 }
00163
00164
00165 $path = "";
00166
00167 if ($this->tree->isInTree($rolf))
00168 {
00169 if ($rolf[0] == ROLE_FOLDER_ID)
00170 {
00171 $path = $this->lng->txt("global");
00172 }
00173 else
00174 {
00175 $tmpPath = $this->tree->getPathFull($rolf);
00176 $path = $tmpPath[count($tmpPath)-2]["title"];
00177 }
00178 }
00179 else
00180 {
00181 $path = "<b>Rolefolder ".$rolf." not found in tree! (Role ".$role["obj_id"].")</b>";
00182 }
00183 }
00184
00185 $disabled = false;
00186 $checkbox = ilUtil::formCheckBox(0,"role_id[]",$role["obj_id"],$disabled);
00187
00188
00189 if ($role["role_type"] != 'linked'
00190 && ($role["obj_id"] == SYSTEM_ROLE_ID
00191 or $role["obj_id"] == ANONYMOUS_ROLE_ID
00192 or substr($role["title"],0,3) == "il_"))
00193 {
00194 $disabled = true;
00195 $checkbox = "";
00196 }
00197
00198 if ($_SESSION["filtered_roles"] != 4)
00199 {
00200 $result_set[$counter][] = $checkbox;
00201 $role_ids[$counter] = $role["obj_id"];
00202 }
00203
00204 if (substr($role["title"],0,3) == "il_" and $role['type'] != "rolt")
00205 {
00206 if (!$assignable)
00207 {
00208 $rolf_arr = $rbacreview->getFoldersAssignedToRole($role["obj_id"],true);
00209 $rolf2 = $rolf_arr[0];
00210 }
00211 else
00212 {
00213 $rolf2 = $rolf;
00214 }
00215
00216 $parent_node = $this->tree->getParentNodeData($rolf2);
00217
00218 $role["description"] = $this->lng->txt("obj_".$parent_node["type"])." (#".$parent_node["obj_id"].")";
00219 }
00220
00221 if ($role["type"] == "rolt" and (substr($role["title"],0,3) == "il_"))
00222 {
00223 $role["description"] .= "<br/><i>".$this->lng->txt("predefined_template")." (".$role["title"].")</i>";
00224 }
00225
00226 $result_set[$counter][] = "<img src=\"".ilUtil::getImagePath("icon_".$role["type"]."_b.gif")."\" alt=\"".$this->lng->txt("obj_".$role["type"])."\" title=\"".$this->lng->txt("obj_".$role["type"])."\" border=\"0\" vspace=\"0\"/>";
00227 $result_set[$counter][] = "<a href=\"adm_object.php?ref_id=".$rolf."&obj_id=".$role["obj_id"]."&cmd=perm\">".ilObjRole::_getTranslation($role["title"])."</a>";
00228 $result_set[$counter][] = $role["description"];
00229
00230
00231
00232 $result_set[$counter][] = $path." (".$role["role_type"].")";;
00233
00234 ++$counter;
00235 }
00236
00237 return $this->__showRolesTable($result_set,$role_ids);
00238 }
00239
00240
00247 function confirmedDeleteObject()
00248 {
00249 global $rbacsystem,$rbacreview;
00250
00251
00252 if (!$rbacsystem->checkAccess('delete',$this->object->getRefId()))
00253 {
00254 $perform_delete = false;
00255 $this->ilias->raiseError($this->lng->txt("msg_no_perm_delete")." ".
00256 $not_deletable,$this->ilias->error_obj->MESSAGE);
00257 }
00258
00259 $return_loc = $this->tree->getParentId($this->object->getRefId());
00260
00261 $feedback["count"] = count($_SESSION["saved_post"]);
00262
00263
00264 foreach ($_SESSION["saved_post"] as $id)
00265 {
00266
00267 $obj =& $this->ilias->obj_factory->getInstanceByObjId($id);
00268
00269 if ($obj->getType() == "role")
00270 {
00271 $rolf_arr = $rbacreview->getFoldersAssignedToRole($obj->getId(),true);
00272 $obj->setParent($rolf_arr[0]);
00273 $feedback["role"] = true;
00274 }
00275 else
00276 {
00277 $feedback["rolt"] = true;
00278 }
00279 $obj->delete();
00280 unset($obj);
00281 }
00282
00283
00284 $return_loc = ilObject::_exists($this->object->getId()) ? $_GET["ref_id"] : $return_loc;
00285
00286
00287 if ($feedback["count"] > 1)
00288 {
00289 if ($feedback["role"] === true)
00290 {
00291 if ($feedback["rolt"] === true)
00292 {
00293 sendInfo($this->lng->txt("msg_deleted_roles_rolts"),true);
00294 }
00295 else
00296 {
00297 sendInfo($this->lng->txt("msg_deleted_roles"),true);
00298 }
00299 }
00300 else
00301 {
00302 sendInfo($this->lng->txt("msg_deleted_rolts"),true);
00303 }
00304 }
00305 else
00306 {
00307 if ($feedback["role"] === true)
00308 {
00309 sendInfo($this->lng->txt("msg_deleted_role"),true);
00310 }
00311 else
00312 {
00313 sendInfo($this->lng->txt("msg_deleted_rolt"),true);
00314 }
00315 }
00316
00317 ilUtil::redirect("adm_object.php?ref_id=".$return_loc);
00318 }
00319
00325 function createObject()
00326 {
00327 $this->object->setTitle($this->lng->txt("obj_".$this->object->getType()."_local"));
00328 $this->object->setDescription("obj_".$this->object->getType()."_local_desc");
00329
00330 $this->saveObject();
00331 }
00332
00338 function deleteObject()
00339 {
00340 if(!isset($_POST["role_id"]))
00341 {
00342 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00343 }
00344
00345 $_SESSION["saved_post"] = $_POST["role_id"];
00346
00347 unset($this->data);
00348 $this->data["cols"] = array("type", "title", "description", "last_change");
00349
00350 foreach($_POST["role_id"] as $id)
00351 {
00352 $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($id);
00353
00354 $this->data["data"]["$id"] = array(
00355 "type" => $obj_data->getType(),
00356 "title" => $obj_data->getTitle(),
00357 "desc" => $obj_data->getDescription(),
00358 "last_update" => $obj_data->getLastUpdateDate());
00359 }
00360
00361 $this->data["buttons"] = array( "cancelDelete" => $this->lng->txt("cancel"),
00362 "confirmedDelete" => $this->lng->txt("confirm"));
00363
00364 $this->getTemplateFile("confirm");
00365
00366 sendInfo($this->lng->txt("info_delete_sure"));
00367
00368 $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=gateway");
00369
00370
00371 foreach ($this->data["cols"] as $key)
00372 {
00373 $this->tpl->setCurrentBlock("table_header");
00374 $this->tpl->setVariable("TEXT",$this->lng->txt($key));
00375 $this->tpl->parseCurrentBlock();
00376 }
00377
00378
00379
00380 $counter = 0;
00381
00382 foreach ($this->data["data"] as $key => $value)
00383 {
00384
00385 foreach ($value as $key => $cell_data)
00386 {
00387 $this->tpl->setCurrentBlock("table_cell");
00388
00389
00390 if ($key == "type")
00391 {
00392 $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
00393 }
00394 else
00395 {
00396 $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
00397 }
00398
00399 $this->tpl->parseCurrentBlock();
00400 }
00401
00402 $this->tpl->setCurrentBlock("table_row");
00403 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
00404 $this->tpl->parseCurrentBlock();
00405
00406 }
00407
00408
00409
00410 foreach ($this->data["buttons"] as $name => $value)
00411 {
00412 $this->tpl->setCurrentBlock("operation_btn");
00413 $this->tpl->setVariable("BTN_NAME",$name);
00414 $this->tpl->setVariable("BTN_VALUE",$value);
00415 $this->tpl->parseCurrentBlock();
00416 }
00417 }
00418
00424 function adoptPermSaveObject()
00425 {
00426 sendinfo($this->lng->txt("saved_successfully"),true);
00427
00428 ilUtil::redirect("adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=perm");
00429 }
00430
00437 function showPossibleSubObjects($a_tpl)
00438 {
00439 global $rbacsystem;
00440
00441 $d = $this->objDefinition->getCreatableSubObjects($this->object->getType());
00442
00443 if ($this->object->getRefId() != ROLE_FOLDER_ID or !$rbacsystem->checkAccess('create_rolt',ROLE_FOLDER_ID))
00444 {
00445 unset($d["rolt"]);
00446 }
00447
00448 if (!$rbacsystem->checkAccess('create_role',$this->object->getRefId()))
00449 {
00450 unset($d["role"]);
00451 }
00452
00453 if (count($d) > 0)
00454 {
00455 foreach ($d as $row)
00456 {
00457 $count = 0;
00458 if ($row["max"] > 0)
00459 {
00460
00461 for ($i=0; $i<count($this->data["ctrl"]); $i++)
00462 {
00463 if ($this->data["ctrl"][$i]["type"] == $row["name"])
00464 {
00465 $count++;
00466 }
00467 }
00468 }
00469 if ($row["max"] == "" || $count < $row["max"])
00470 {
00471 $subobj[] = $row["name"];
00472 }
00473 }
00474 }
00475
00476 if (is_array($subobj))
00477 {
00478
00479 $opts = ilUtil::formSelect(12,"new_type",$subobj);
00480 $a_tpl->setCurrentBlock("add_object");
00481 $a_tpl->setVariable("SELECT_OBJTYPE", $opts);
00482 $a_tpl->setVariable("BTN_NAME", "create");
00483 $a_tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
00484 $a_tpl->parseCurrentBlock();
00485 }
00486
00487 return $a_tpl;
00488 }
00489
00494 function saveObject()
00495 {
00496 global $rbacadmin;
00497
00498
00499 $_GET["new_type"] = $this->object->getType();
00500 $_POST["Fobject"]["title"] = $this->object->getTitle();
00501 $_POST["Fobject"]["desc"] = $this->object->getDescription();
00502
00503
00504 $newObj = parent::saveObject();
00505
00506
00507
00508
00509 sendInfo($this->lng->txt("rolf_added"),true);
00510
00511 ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
00512 }
00513
00514 function __showRolesTable($a_result_set,$a_role_ids)
00515 {
00516 global $rbacsystem;
00517
00518 $actions = array("delete" => $this->lng->txt("delete"));
00519
00520 $tbl =& $this->__initTableGUI();
00521 $tpl =& $tbl->getTemplateObject();
00522
00523 $tpl->setCurrentBlock("tbl_form_header");
00524 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00525 $tpl->parseCurrentBlock();
00526
00527 $tpl = $this->showPossibleSubObjects($tpl);
00528
00529 $tpl->setCurrentBlock("tbl_action_row");
00530
00531 $tpl->setVariable("COLUMN_COUNTS",($_SESSION["filtered_roles"] == 4) ? 4 : 5);
00532
00533 if ($_SESSION["filtered_roles"] != 4)
00534 {
00535 $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00536
00537 foreach ($actions as $name => $value)
00538 {
00539 $tpl->setCurrentBlock("tbl_action_btn");
00540 $tpl->setVariable("BTN_NAME",$name);
00541 $tpl->setVariable("BTN_VALUE",$value);
00542 $tpl->parseCurrentBlock();
00543 }
00544
00545 if (!empty($a_role_ids))
00546 {
00547
00548
00549 $tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
00550 $tpl->setVariable("JS_VARNAME","role_id");
00551 $tpl->setVariable("JS_ONCLICK",ilUtil::array_php2js($a_role_ids));
00552 $tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
00553 $tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
00554 $tpl->parseCurrentBlock();
00555 }
00556 }
00557
00558 $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
00559
00560
00561 $this->ctrl->setParameter($this,"cmd","view");
00562
00563
00564 $tbl->setTitle($this->lng->txt("roles"),"icon_role_b.gif",$this->lng->txt("roles"));
00565
00566 if ($_SESSION["filtered_roles"] == 4)
00567 {
00568 $tbl->setHeaderNames(array($this->lng->txt("type"),$this->lng->txt("role"),
00569 $this->lng->txt("description"),$this->lng->txt("context")));
00570 $tbl->setHeaderVars(array("type","title","description","context"),$this->ctrl->getParameterArray($this,"",false));
00571 $tbl->setColumnWidth(array("","30%","40%","30%"));
00572 }
00573 else
00574 {
00575 $tbl->setHeaderNames(array("",$this->lng->txt("type"),
00576 $this->lng->txt("role"),
00577 $this->lng->txt("description"),
00578 $this->lng->txt("context")));
00579 $tbl->setHeaderVars(array("","type","title","description","context"),$this->ctrl->getParameterArray($this,"",false));
00580 $tbl->setColumnWidth(array("","","30%","40%","30%"));
00581 }
00582
00583 $this->__setTableGUIBasicData($tbl,$a_result_set,"view");
00584 $tbl->render();
00585 $this->tpl->setVariable("ROLES_TABLE",$tbl->tpl->get());
00586
00587 return true;
00588 }
00589
00590 function &__initTableGUI()
00591 {
00592 include_once "class.ilTableGUI.php";
00593
00594 return new ilTableGUI(0,false);
00595 }
00596
00597 function __setTableGUIBasicData(&$tbl,&$result_set,$from = "")
00598 {
00599 switch($from)
00600 {
00601 default:
00602 if (!$_GET["sort_by"] or $_GET["sort_by"] == "name")
00603 {
00604 $_GET["sort_by"] = "title";
00605 }
00606
00607 $order = $_GET["sort_by"];
00608 break;
00609 }
00610
00611
00612 $tbl->setOrderColumn($order);
00613 $tbl->setOrderDirection($_GET["sort_order"]);
00614 $tbl->setOffset($_GET["offset"]);
00615 $tbl->setLimit($_GET["limit"]);
00616 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00617 $tbl->setData($result_set);
00618 }
00619
00620 function __unsetSessionVariables()
00621 {
00622
00623 }
00624
00625 function __buildFilterSelect()
00626 {
00627 $action[1] = $this->lng->txt('all_roles');
00628 $action[2] = $this->lng->txt('all_global_roles');
00629 $action[3] = $this->lng->txt('all_local_roles');
00630 $action[4] = $this->lng->txt('internal_local_roles_only');
00631 $action[5] = $this->lng->txt('non_internal_local_roles_only');
00632 $action[6] = $this->lng->txt('role_templates_only');
00633
00634 return ilUtil::formSelect($_SESSION['filtered_roles'],"filter",$action,false,true);
00635 }
00636
00637 function hitsperpageObject()
00638 {
00639 parent::hitsperpageObject();
00640 $this->viewObject();
00641 }
00642 }
00643 ?>