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