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 ilObjRoleGUI extends ilObjectGUI
00039 {
00045 var $type;
00046
00052 var $rolf_ref_id;
00053
00054
00055 var $ctrl;
00056
00061 function ilObjRoleGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
00062 {
00063 define("USER_FOLDER_ID",7);
00064
00065 global $ilCtrl;
00066
00067 $this->type = "role";
00068 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
00069 $this->rolf_ref_id =& $this->ref_id;
00070
00071 $this->ctrl =& $ilCtrl;
00072 $this->ctrl->saveParameter($this,'obj_id');
00073 }
00074
00075 function &executeCommand()
00076 {
00077 global $rbacsystem;
00078
00079 if($this->ctrl->getTargetScript() == 'role.php')
00080 {
00081 $this->__prepareOutput();
00082 }
00083
00084 $next_class = $this->ctrl->getNextClass($this);
00085
00086 $cmd = $this->ctrl->getCmd();
00087 switch($next_class)
00088 {
00089 default:
00090 if(!$cmd)
00091 {
00092 $cmd = "perm";
00093 }
00094 $cmd .= "Object";
00095 $this->$cmd();
00096
00097 break;
00098 }
00099 return true;
00100 }
00101
00102 function listDesktopItemsObject()
00103 {
00104 global $rbacsystem,$rbacreview,$tree;
00105
00106 if(!$rbacsystem->checkAccess('edit_permission', $this->rolf_ref_id))
00107 {
00108 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00109 }
00110
00111 if(!$rbacreview->isAssignable($this->object->getId(),$this->rolf_ref_id))
00112 {
00113 sendInfo($this->lng->txt('role_no_users_no_desk_items'));
00114 return true;
00115 }
00116
00117
00118 include_once './classes/class.ilRoleDesktopItem.php';
00119
00120 $role_desk_item_obj =& new ilRoleDesktopItem($this->object->getId());
00121
00122
00123 $this->__showButton('selectDesktopItem',$this->lng->txt('role_desk_add'));
00124 if(!count($items = $role_desk_item_obj->getAll()))
00125 {
00126 sendInfo($this->lng->txt('role_desk_none_created'));
00127
00128 return true;
00129 }
00130 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.role_desktop_item_list.html");
00131 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00132 $this->tpl->setVariable("TBL_TITLE_IMG",ilUtil::getImagePath('icon_role_b.gif'));
00133 $this->tpl->setVariable("TBL_TITLE_IMG_ALT",$this->lng->txt('obj_role'));
00134 $this->tpl->setVariable("TBL_TITLE",$this->lng->txt('role_assigned_desk_items').' ('.$this->object->getTitle().')');
00135 $this->tpl->setVariable("HEADER_DESC",$this->lng->txt('description'));
00136 $this->tpl->setVariable("BTN_DELETE",$this->lng->txt('delete'));
00137 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
00138
00139 $counter = 0;
00140 foreach($items as $role_item_id => $item)
00141 {
00142 $tmp_obj = ilObjectFactory::getInstanceByRefId($item['item_id']);
00143
00144 if(strlen($desc = $tmp_obj->getDescription()))
00145 {
00146 $this->tpl->setCurrentBlock("description");
00147 $this->tpl->setVariable("DESCRIPTION_DESK",$desc);
00148 $this->tpl->parseCurrentBlock();
00149 }
00150 $this->tpl->setCurrentBlock("desk_row");
00151 $this->tpl->setVariable("DESK_TITLE",$tmp_obj->getTitle());
00152 $this->tpl->setVariable("ROW_CLASS",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
00153 $this->tpl->setVariable("CHECK_DESK",ilUtil::formCheckBox(0,'del_desk_item[]',$role_item_id));
00154 $this->tpl->setVariable("TXT_PATH",$this->lng->txt('path').':');
00155 $this->tpl->setVariable("PATH",$this->__formatPath($tree->getPathFull($item['item_id'])));
00156 $this->tpl->parseCurrentBlock();
00157 }
00158 return true;
00159 }
00160
00161 function askDeleteDesktopItemObject()
00162 {
00163 global $rbacsystem;
00164
00165 if(!$rbacsystem->checkAccess('edit_permission', $this->rolf_ref_id))
00166 {
00167 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00168 }
00169 if(!$rbacsystem->checkAccess('push_desktop_items',USER_FOLDER_ID))
00170 {
00171 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00172 }
00173 if(!count($_POST['del_desk_item']))
00174 {
00175 sendInfo($this->lng->txt('role_select_one_item'));
00176
00177 $this->listDesktopItemsObject();
00178
00179 return true;
00180 }
00181 sendInfo($this->lng->txt('role_sure_delete_desk_items'));
00182
00183 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.role_ask_delete_desktop_item.html");
00184 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00185 $this->tpl->setVariable("TBL_TITLE_IMG",ilUtil::getImagePath('icon_role_b.gif'));
00186 $this->tpl->setVariable("TBL_TITLE_IMG_ALT",$this->lng->txt('obj_role'));
00187 $this->tpl->setVariable("TBL_TITLE",$this->lng->txt('role_assigned_desk_items').' ('.$this->object->getTitle().')');
00188 $this->tpl->setVariable("HEADER_DESC",$this->lng->txt('description'));
00189 $this->tpl->setVariable("BTN_DELETE",$this->lng->txt('delete'));
00190 $this->tpl->setVariable("BTN_CANCEL",$this->lng->txt('cancel'));
00191
00192 include_once './classes/class.ilRoleDesktopItem.php';
00193
00194 $role_desk_item_obj =& new ilRoleDesktopItem($this->object->getId());
00195
00196 $counter = 0;
00197 foreach($_POST['del_desk_item'] as $role_item_id)
00198 {
00199 $item_data = $role_desk_item_obj->getItem($role_item_id);
00200 $tmp_obj =& ilObjectFactory::getInstanceByRefId($item_data['item_id']);
00201
00202 if(strlen($desc = $tmp_obj->getDescription()))
00203 {
00204 $this->tpl->setCurrentBlock("description");
00205 $this->tpl->setVariable("DESCRIPTION_DESK",$desc);
00206 $this->tpl->parseCurrentBlock();
00207 }
00208 $this->tpl->setCurrentBlock("desk_row");
00209 $this->tpl->setVariable("DESK_TITLE",$tmp_obj->getTitle());
00210 $this->tpl->setVariable("ROW_CLASS",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
00211 $this->tpl->parseCurrentBlock();
00212 }
00213 $_SESSION['role_del_desk_items'] = $_POST['del_desk_item'];
00214
00215 return true;
00216 }
00217
00218 function deleteDesktopItemsObject()
00219 {
00220 global $rbacsystem;
00221
00222 if(!$rbacsystem->checkAccess('edit_permission', $this->rolf_ref_id))
00223 {
00224 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00225 }
00226 if(!$rbacsystem->checkAccess('push_desktop_items',USER_FOLDER_ID))
00227 {
00228 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00229 }
00230 if(!count($_SESSION['role_del_desk_items']))
00231 {
00232 sendInfo($this->lng->txt('role_select_one_item'));
00233
00234 $this->listDesktopItemsObject();
00235
00236 return true;
00237 }
00238
00239 include_once './classes/class.ilRoleDesktopItem.php';
00240
00241 $role_desk_item_obj =& new ilRoleDesktopItem($this->object->getId());
00242
00243 foreach($_SESSION['role_del_desk_items'] as $role_item_id)
00244 {
00245 $role_desk_item_obj->delete($role_item_id);
00246 }
00247
00248 sendInfo($this->lng->txt('role_deleted_desktop_items'));
00249 $this->listDesktopItemsObject();
00250
00251 return true;
00252 }
00253
00254
00255 function selectDesktopItemObject()
00256 {
00257 global $rbacsystem,$tree;
00258
00259 include_once './classes/class.ilRoleDesktopItemSelector.php';
00260 include_once './classes/class.ilRoleDesktopItem.php';
00261
00262
00263 if(!$rbacsystem->checkAccess('push_desktop_items',USER_FOLDER_ID))
00264 {
00265 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00266 }
00267
00268 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.role_desktop_item_selector.html");
00269 $this->__showButton('listDesktopItems',$this->lng->txt('back'));
00270
00271
00272 sendInfo($this->lng->txt("role_select_desktop_item"));
00273
00274 $exp = new ilRoleDesktopItemSelector($this->ctrl->getLinkTarget($this,'selectDesktopItem'),
00275 new ilRoleDesktopItem($this->object->getId()));
00276 $exp->setExpand($_GET["role_desk_item_link_expand"] ? $_GET["role_desk_item_link_expand"] : $tree->readRootId());
00277 $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'selectDesktopItem'));
00278
00279 $exp->setOutput(0);
00280
00281 $this->tpl->setVariable("EXPLORER",$exp->getOutput());
00282
00283 return true;
00284 }
00285
00286 function assignDesktopItemObject()
00287 {
00288 global $rbacsystem;
00289
00290 if(!$rbacsystem->checkAccess('push_desktop_items',USER_FOLDER_ID))
00291 {
00292 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00293
00294 return false;
00295 }
00296
00297 if(!$rbacsystem->checkAccess('edit_permission', $this->rolf_ref_id))
00298 {
00299 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00300
00301 return false;
00302 }
00303 if(!isset($_GET['item_id']))
00304 {
00305 sendInfo($this->lng->txt('role_no_item_selected'));
00306 $this->selectDesktopItemObject();
00307
00308 return false;
00309 }
00310 include_once './classes/class.ilRoleDesktopItem.php';
00311
00312 $role_desk_item_obj =& new ilRoleDesktopItem($this->object->getId());
00313 $role_desk_item_obj->add((int) $_GET['item_id'],ilObject::_lookupType((int) $_GET['item_id'],true));
00314
00315 sendInfo($this->lng->txt('role_assigned_desktop_item'));
00316
00317
00318 $this->ctrl->redirect($this,'listDesktopItems');
00319 return true;
00320 }
00321
00322
00323
00324
00328 function createObject()
00329 {
00330 global $rbacsystem;
00331
00332 if (!$rbacsystem->checkAccess('create_role', $this->rolf_ref_id))
00333 {
00334 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00335 }
00336
00337 $this->getTemplateFile("edit","role");
00338
00339 if ($this->rolf_ref_id == ROLE_FOLDER_ID)
00340 {
00341 $this->tpl->setCurrentBlock("allow_register");
00342 $allow_register = ($_SESSION["error_post_vars"]["Fobject"]["allow_register"]) ? "checked=\"checked\"" : "";
00343 $this->tpl->setVariable("TXT_ALLOW_REGISTER",$this->lng->txt("allow_register"));
00344 $this->tpl->setVariable("ALLOW_REGISTER",$allow_register);
00345 $this->tpl->parseCurrentBlock();
00346
00347 $this->tpl->setCurrentBlock("assign_users");
00348 $assign_users = $_SESSION["error_post_vars"]["Fobject"]["assign_users"] ? "checked=\"checked\"" : "";
00349 $this->tpl->setVariable("TXT_ASSIGN_USERS",$this->lng->txt("allow_assign_users"));
00350 $this->tpl->setVariable("ASSIGN_USERS",$assign_users);
00351 $this->tpl->parseCurrentBlock();
00352 }
00353
00354
00355 $this->tpl->setVariable("TITLE",ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"]),true);
00356 $this->tpl->setVariable("DESC",ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]));
00357
00358 $this->tpl->setVariable("TXT_TITLE",$this->lng->txt("title"));
00359 $this->tpl->setVariable("TXT_DESC",$this->lng->txt("desc"));
00360 $this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".$this->rolf_ref_id."&new_type=".$this->type));
00361 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->type."_new"));
00362 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00363 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($this->type."_add"));
00364 $this->tpl->setVariable("CMD_SUBMIT", "save");
00365 $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
00366 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00367 }
00368
00374 function saveObject()
00375 {
00376 global $rbacsystem, $rbacadmin, $rbacreview;
00377
00378
00379 if (!$rbacsystem->checkAccess("create_role",$this->rolf_ref_id))
00380 {
00381 $this->ilias->raiseError($this->lng->txt("msg_no_perm_create_role"),$this->ilias->error_obj->MESSAGE);
00382 }
00383
00384
00385 if (empty($_POST["Fobject"]["title"]))
00386 {
00387 $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
00388 }
00389
00390
00391 if ($rbacreview->roleExists($_POST["Fobject"]["title"]))
00392 {
00393 $this->ilias->raiseError($this->lng->txt("msg_role_exists1")." '".ilUtil::stripSlashes($_POST["Fobject"]["title"])."' ".
00394 $this->lng->txt("msg_role_exists2"),$this->ilias->error_obj->MESSAGE);
00395 }
00396
00397
00398 if (substr($_POST["Fobject"]["title"],0,3) == "il_")
00399 {
00400 $this->ilias->raiseError($this->lng->txt("msg_role_reserved_prefix"),$this->ilias->error_obj->MESSAGE);
00401 }
00402
00403
00404 include_once("class.ilObjRole.php");
00405 $roleObj = new ilObjRole();
00406
00407 $roleObj->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
00408 $roleObj->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
00409 $roleObj->setAllowRegister($_POST["Fobject"]["allow_register"]);
00410 $roleObj->toggleAssignUsersStatus($_POST["Fobject"]["assign_users"]);
00411 $roleObj->create();
00412 $rbacadmin->assignRoleToFolder($roleObj->getId(), $this->rolf_ref_id,'y');
00413
00414 sendInfo($this->lng->txt("role_added"),true);
00415
00416 ilUtil::redirect("adm_object.php?ref_id=".$this->rolf_ref_id);
00417 }
00418
00424 function permObject()
00425 {
00426 global $rbacadmin, $rbacreview, $rbacsystem,$objDefinition,$tree;
00427
00428 #$to_filter = $objDefinition->getSubobjectsToFilter();
00429
00430 if ($this->rolf_ref_id != ROLE_FOLDER_ID)
00431 {
00432 if (!$rbacsystem->checkAccess('edit_permission',$tree->getParentId($this->rolf_ref_id)))
00433 {
00434 $this->ilias->raiseError($this->lng->txt("msg_no_perm_perm"),$this->ilias->error_obj->MESSAGE);
00435 }
00436 }
00437 else
00438 {
00439
00440 if (!$rbacsystem->checkAccess('write',$this->rolf_ref_id))
00441 {
00442 $this->ilias->raiseError($this->lng->txt("msg_no_perm_perm"),$this->ilias->error_obj->MESSAGE);
00443 }
00444 }
00445
00446
00447 $q = "SELECT ta.typ_id,obj.title,ops.ops_id,ops.operation FROM rbac_ta AS ta ".
00448 "LEFT JOIN object_data AS obj ON obj.obj_id=ta.typ_id ".
00449 "LEFT JOIN rbac_operations AS ops ON ops.ops_id=ta.ops_id";
00450 $r = $this->ilias->db->query($q);
00451
00452 while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
00453 {
00454
00455 #if(in_array($row->title,$to_filter))
00456 #{
00457 # continue;
00458 #}
00459 $rbac_objects[$row->typ_id] = array("obj_id" => $row->typ_id,
00460 "type" => $row->title
00461 );
00462
00463 $rbac_operations[$row->typ_id][$row->ops_id] = array(
00464 "ops_id" => $row->ops_id,
00465 "title" => $row->operation,
00466 "name" => $this->lng->txt($row->title."_".$row->operation)
00467 );
00468 }
00469
00470 foreach ($rbac_objects as $key => $obj_data)
00471 {
00472 $rbac_objects[$key]["name"] = $this->lng->txt("obj_".$obj_data["type"]);
00473 $rbac_objects[$key]["ops"] = $rbac_operations[$key];
00474 }
00475
00476
00477
00478 if ($this->rolf_ref_id != ROLE_FOLDER_ID)
00479 {
00480
00481 $parent_data = $this->tree->getParentNodeData($this->rolf_ref_id);
00482
00483 $subobj_data = $this->objDefinition->getSubObjects($parent_data["type"]);
00484
00485
00486 foreach ($rbac_objects as $key => $obj_data)
00487 {
00488 if (!$subobj_data[$obj_data["type"]] and $parent_data["type"] != $obj_data["type"])
00489 {
00490 unset($rbac_objects[$key]);
00491 }
00492 }
00493 }
00494
00495
00496 sort($rbac_objects);
00497
00498 foreach ($rbac_objects as $key => $obj_data)
00499 {
00500 sort($rbac_objects[$key]["ops"]);
00501 }
00502
00503
00504 $rbac_objects = ilUtil::sortArray($rbac_objects,"name","asc");
00505
00506
00507 foreach ($rbac_objects as $key => $obj_data)
00508 {
00509 $arr_selected = $rbacreview->getOperationsOfRole($this->object->getId(), $obj_data["type"], $this->rolf_ref_id);
00510 $arr_checked = array_intersect($arr_selected,array_keys($rbac_operations[$obj_data["obj_id"]]));
00511
00512 foreach ($rbac_operations[$obj_data["obj_id"]] as $operation)
00513 {
00514
00515 if ($this->object->getId() == SYSTEM_ROLE_ID)
00516 {
00517 $checked = true;
00518 $disabled = true;
00519 }
00520 else
00521 {
00522 $checked = in_array($operation["ops_id"],$arr_checked);
00523 $disabled = false;
00524 }
00525
00526
00527 $box = ilUtil::formCheckBox($checked,"template_perm[".$obj_data["type"]."][]",$operation["ops_id"],$disabled);
00528 $output["perm"][$obj_data["obj_id"]][$operation["ops_id"]] = $box;
00529 }
00530 }
00531
00532
00533 $output["col_anz"] = count($rbac_objects);
00534 $output["txt_save"] = $this->lng->txt("save");
00535 $output["check_bottom"] = ilUtil::formCheckBox(0,"recursive",1);
00536 $output["message_table"] = $this->lng->txt("change_existing_objects");
00537
00538
00539
00540
00541
00542
00543 $output["message_middle"] = $this->lng->txt("adopt_perm_from_template");
00544
00545
00546 if ($this->object->getId() == SYSTEM_ROLE_ID)
00547 {
00548 $output["adopt"] = array();
00549 $output["sysrole_msg"] = $this->lng->txt("msg_sysrole_not_editable");
00550 }
00551 else
00552 {
00553
00554 $parent_role_ids = $rbacreview->getParentRoleIds($this->rolf_ref_id,true);
00555
00556
00557 ksort($parent_role_ids);
00558
00559 foreach ($parent_role_ids as $key => $par)
00560 {
00561 if ($par["obj_id"] != SYSTEM_ROLE_ID)
00562 {
00563 $radio = ilUtil::formRadioButton(0,"adopt",$par["obj_id"]);
00564 $output["adopt"][$key]["css_row_adopt"] = ilUtil::switchColor($key, "tblrow1", "tblrow2");
00565 $output["adopt"][$key]["check_adopt"] = $radio;
00566 $output["adopt"][$key]["role_id"] = $par["obj_id"];
00567 $output["adopt"][$key]["type"] = ($par["type"] == 'role' ? 'Role' : 'Template');
00568 $output["adopt"][$key]["role_name"] = $par["title"];
00569 }
00570 }
00571
00572 #$output["formaction_adopt"] = "adm_object.php?cmd=adoptPermSave&ref_id=".$this->rolf_ref_id."&obj_id=".$this->object->getId();
00573 $output["formaction_adopt"] = $this->ctrl->getFormAction($this,'adoptPermSave');
00574
00575 }
00576
00577 #$output["formaction"] = "adm_object.php?cmd=permSave&ref_id=".$this->rolf_ref_id."&obj_id=".$this->object->getId();
00578 $output["formaction"] = $this->ctrl->getFormAction($this,'permSave');
00579
00580 $this->data = $output;
00581
00582
00583
00584
00585
00586
00587 # $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00588 # $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00589 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.adm_perm_role.html");
00590
00591 foreach ($rbac_objects as $obj_data)
00592 {
00593
00594 $this->tpl->setCurrentBlock("object_operations");
00595
00596 $ops_ids = "";
00597
00598 foreach ($obj_data["ops"] as $operation)
00599 {
00600 $ops_ids[] = $operation["ops_id"];
00601
00602 $css_row = ilUtil::switchColor($key, "tblrow1", "tblrow2");
00603 $this->tpl->setVariable("CSS_ROW",$css_row);
00604 $this->tpl->setVariable("PERMISSION",$operation["name"]);
00605 if (substr($operation["title"], 0, 7) == "create_")
00606 {
00607 if ($this->objDefinition->getDevMode(substr($operation["title"], 7, strlen($operation["title"]) -7)))
00608 {
00609 $this->tpl->setVariable("TXT_NOT_IMPL", "(".$this->lng->txt("not_implemented_yet").")");
00610 }
00611 }
00612 $this->tpl->setVariable("CHECK_PERMISSION",$this->data["perm"][$obj_data["obj_id"]][$operation["ops_id"]]);
00613 $this->tpl->setVariable("LABEL_ID","template_perm_".$obj_data["type"]."_".$operation["ops_id"]);
00614 $this->tpl->parseCurrentBlock();
00615 }
00616
00617
00618 $this->tpl->setCurrentBlock("object_type");
00619 $this->tpl->setVariable("TXT_OBJ_TYPE",$obj_data["name"]);
00620
00621
00622 if ($this->objDefinition->getDevMode($obj_data["type"]))
00623 {
00624 $this->tpl->setVariable("TXT_NOT_IMPL", "(".$this->lng->txt("not_implemented_yet").")");
00625 }
00626 else if ($obj_data["type"] == "icrs" and !$this->ilias->getSetting("ilinc_active"))
00627 {
00628 $this->tpl->setVariable("TXT_NOT_IMPL", "(".$this->lng->txt("not_enabled_or_configured").")");
00629 }
00630
00631
00632 $this->tpl->setVariable("JS_VARNAME","template_perm_".$obj_data["type"]);
00633 $this->tpl->setVariable("JS_ONCLICK",ilUtil::array_php2js($ops_ids));
00634 $this->tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
00635 $this->tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
00636
00637 $this->tpl->parseCurrentBlock();
00638
00639 }
00640
00641
00642 if ($this->object->getId() != SYSTEM_ROLE_ID)
00643 {
00644
00645 foreach ($this->data["adopt"] as $key => $value)
00646 {
00647 $this->tpl->setCurrentBlock("ADOPT_PERM_ROW");
00648 $this->tpl->setVariable("CSS_ROW_ADOPT",$value["css_row_adopt"]);
00649 $this->tpl->setVariable("CHECK_ADOPT",$value["check_adopt"]);
00650 $this->tpl->setVariable("LABEL_ID",$value["role_id"]);
00651 $this->tpl->setVariable("TYPE",$value["type"]);
00652 $this->tpl->setVariable("ROLE_NAME",$value["role_name"]);
00653 $this->tpl->parseCurrentBlock();
00654 }
00655
00656 $this->tpl->setCurrentBlock("ADOPT_PERM_FORM");
00657 $this->tpl->setVariable("MESSAGE_MIDDLE",$this->data["message_middle"]);
00658 $this->tpl->setVariable("FORMACTION_ADOPT",$this->data["formaction_adopt"]);
00659 $this->tpl->parseCurrentBlock();
00660
00661
00662 $this->tpl->setCurrentBlock("tblfooter_recursive");
00663 $this->tpl->setVariable("COL_ANZ",3);
00664 $this->tpl->setVariable("CHECK_BOTTOM",$this->data["check_bottom"]);
00665 $this->tpl->setVariable("MESSAGE_TABLE",$this->data["message_table"]);
00666 $this->tpl->parseCurrentBlock();
00667
00668 $this->tpl->setCurrentBlock("tblfooter_standard");
00669 $this->tpl->setVariable("COL_ANZ_PLUS",4);
00670 $this->tpl->setVariable("TXT_SAVE",$this->data["txt_save"]);
00671 $this->tpl->parseCurrentBlock();
00672 }
00673 else
00674 {
00675
00676 $this->tpl->setCurrentBlock("tblfooter_sysrole");
00677 $this->tpl->setVariable("COL_ANZ_SYS",3);
00678 $this->tpl->parseCurrentBlock();
00679
00680
00681 $this->tpl->setCurrentBlock("sysrole_msg");
00682 $this->tpl->setVariable("TXT_SYSROLE_MSG",$this->data["sysrole_msg"]);
00683 $this->tpl->parseCurrentBlock();
00684 }
00685
00686 $this->tpl->setCurrentBlock("adm_content");
00687 $this->tpl->setVariable("TBL_TITLE_IMG",ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif"));
00688 $this->tpl->setVariable("TBL_TITLE_IMG_ALT",$this->lng->txt($this->object->getType()));
00689 $this->tpl->setVariable("TBL_HELP_IMG",ilUtil::getImagePath("icon_help.gif"));
00690 $this->tpl->setVariable("TBL_HELP_LINK","tbl_help.php");
00691 $this->tpl->setVariable("TBL_HELP_IMG_ALT",$this->lng->txt("help"));
00692
00693
00694 $global_roles = $rbacreview->getGlobalRoles();
00695
00696 if (in_array($this->object->getId(),$global_roles))
00697 {
00698 $desc = "global";
00699 }
00700 else
00701 {
00702
00703 $rolf = $rbacreview->getFoldersAssignedToRole($this->object->getId(),true);
00704 $parent_node = $this->tree->getParentNodeData($rolf[0]);
00705
00706 $desc = $this->lng->txt("obj_".$parent_node['type'])." (#".$parent_node['obj_id'].") : ".$parent_node['title'];
00707 }
00708
00709 $description = "<br/> <span class=\"small\">".$desc."</span>";
00710
00711
00712 if (substr($this->object->getTitle(),0,3) == "il_")
00713 {
00714 $title = ilObjRole::_getTranslation($this->object->getTitle())." (".$this->object->getTitle().")";
00715 }
00716 else
00717 {
00718 $title = $this->object->getTitle();
00719 }
00720
00721 $this->tpl->setVariable("TBL_TITLE",$title.$description);
00722
00723 $this->tpl->setVariable("TXT_PERMISSION",$this->data["txt_permission"]);
00724 $this->tpl->setVariable("FORMACTION",$this->data["formaction"]);
00725 $this->tpl->parseCurrentBlock();
00726 }
00727
00733 function permSaveObject()
00734 {
00735 global $rbacsystem, $rbacadmin, $rbacreview,$objDefinition,$tree;
00736
00737 if ($this->rolf_ref_id != ROLE_FOLDER_ID)
00738 {
00739 if (!$rbacsystem->checkAccess('edit_permission',$tree->getParentId($this->rolf_ref_id)))
00740 {
00741 $this->ilias->raiseError($this->lng->txt("msg_no_perm_perm"),$this->ilias->error_obj->MESSAGE);
00742 }
00743 }
00744 else
00745 {
00746 if (!$rbacsystem->checkAccess('write',$this->rolf_ref_id))
00747 {
00748 $this->ilias->raiseError($this->lng->txt("msg_no_perm_perm"),$this->ilias->error_obj->MESSAGE);
00749 }
00750 }
00751
00752
00753 $rbacadmin->deleteRolePermission($this->object->getId(), $this->rolf_ref_id);
00754
00755 if (empty($_POST["template_perm"]))
00756 {
00757 $_POST["template_perm"] = array();
00758 }
00759
00760 foreach ($_POST["template_perm"] as $key => $ops_array)
00761 {
00762
00763 $rbacadmin->setRolePermission($this->object->getId(), $key, $ops_array, $this->rolf_ref_id);
00764 }
00765
00766
00767 $this->object->update();
00768
00769
00770
00771 if ($_POST["recursive"])
00772 {
00773
00774 if ($this->rolf_ref_id == ROLE_FOLDER_ID)
00775 {
00776 $node_id = ROOT_FOLDER_ID;
00777 }
00778 else
00779 {
00780 $node_id = $this->tree->getParentId($this->rolf_ref_id);
00781 }
00782
00783
00784 $node_data = $this->tree->getNodeData($node_id);
00785 $subtree_nodes = $this->tree->getSubTree($node_data);
00786
00787
00788 $all_parent_obj_of_rolf = $rbacreview->getObjectsWithStopedInheritance($this->object->getId());
00789
00790
00791 if ($this->rolf_ref_id == ROLE_FOLDER_ID)
00792 {
00793 $key = array_keys($all_parent_obj_of_rolf,SYSTEM_FOLDER_ID);
00794 }
00795 else
00796 {
00797 $key = array_keys($all_parent_obj_of_rolf,$node_id);
00798 }
00799
00800 unset($all_parent_obj_of_rolf[$key[0]]);
00801
00802 $check = false;
00803
00804 foreach ($subtree_nodes as $node)
00805 {
00806 if (!$check)
00807 {
00808 if (in_array($node["child"],$all_parent_obj_of_rolf))
00809 {
00810 $lft = $node["lft"];
00811 $rgt = $node["rgt"];
00812 $check = true;
00813 continue;
00814 }
00815
00816 $valid_nodes[] = $node;
00817 }
00818 else
00819 {
00820 if (($node["lft"] > $lft) && ($node["rgt"] < $rgt))
00821 {
00822 continue;
00823 }
00824 else
00825 {
00826 $check = false;
00827
00828 if (in_array($node["child"],$all_parent_obj_of_rolf))
00829 {
00830 $lft = $node["lft"];
00831 $rgt = $node["rgt"];
00832 $check = true;
00833 continue;
00834 }
00835
00836 $valid_nodes[] = $node;
00837 }
00838 }
00839 }
00840
00841
00842 foreach ($valid_nodes as $key => $node)
00843 {
00844 #if(!in_array($node["type"],$to_filter))
00845 {
00846 $node_ids[] = $node["child"];
00847 $valid_nodes[$key]["perms"] = $_POST["template_perm"][$node["type"]];
00848 }
00849 }
00850
00851
00852 $rbacadmin->revokePermissionList($node_ids,$this->object->getId());
00853
00854
00855 foreach ($valid_nodes as $node)
00856 {
00857 if (is_array($node["perms"]))
00858 {
00859 $rbacadmin->grantPermission($this->object->getId(),$node["perms"],$node["child"]);
00860 }
00861 }
00862 }
00863
00864
00865
00866 sendInfo($this->lng->txt("saved_successfully"),true);
00867 if($this->ctrl->getTargetScript() == 'adm_object.php')
00868 {
00869 ilUtil::redirect("adm_object.php?ref_id=".$this->rolf_ref_id."&obj_id=".$this->object->getId()."&cmd=perm");
00870 }
00871 else
00872 {
00873 $this->permObject();
00874 }
00875 }
00876
00877
00883 function adoptPermSaveObject()
00884 {
00885 global $rbacadmin, $rbacsystem, $rbacreview,$tree;
00886
00887 if ($this->rolf_ref_id != ROLE_FOLDER_ID)
00888 {
00889 if (!$rbacsystem->checkAccess('edit_permission',$tree->getParentId($this->rolf_ref_id)))
00890 {
00891 $this->ilias->raiseError($this->lng->txt("msg_no_perm_perm"),$this->ilias->error_obj->MESSAGE);
00892 }
00893 }
00894 else
00895 {
00896 if (!$rbacsystem->checkAccess('write',$this->rolf_ref_id))
00897 {
00898 $this->ilias->raiseError($this->lng->txt("msg_no_perm_perm"),$this->ilias->error_obj->MESSAGE);
00899 }
00900 }
00901
00902 if (empty($_POST["adopt"]))
00903 {
00904 $this->ilias->raiseError($this->lng->txt("msg_no_adopt_selected"),$this->ilias->error_obj->MESSAGE);
00905 }
00906
00907 if ($this->object->getId() == $_POST["adopt"])
00908 {
00909 sendInfo($this->lng->txt("msg_perm_adopted_from_itself"),true);
00910 }
00911 else
00912 {
00913 $rbacadmin->deleteRolePermission($this->object->getId(), $this->rolf_ref_id);
00914 $parentRoles = $rbacreview->getParentRoleIds($this->rolf_ref_id,true);
00915 $rbacadmin->copyRolePermission($_POST["adopt"],$parentRoles[$_POST["adopt"]]["parent"],
00916 $this->rolf_ref_id,$this->object->getId());
00917
00918
00919 $this->object->update();
00920
00921
00922 $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($_POST["adopt"]);
00923 sendInfo($this->lng->txt("msg_perm_adopted_from1")." '".$obj_data->getTitle()."'.<br/>".
00924 $this->lng->txt("msg_perm_adopted_from2"),true);
00925 }
00926
00927 if($this->ctrl->getTargetScript() == 'adm_object.php')
00928 {
00929 ilUtil::redirect("adm_object.php?ref_id=".$this->rolf_ref_id."&obj_id=".$this->object->getId()."&cmd=perm");
00930 }
00931 else
00932 {
00933 $this->permObject();
00934 }
00935 }
00936
00942 function assignSaveObject()
00943 {
00944 $this->assignUserObject();
00945 }
00946
00952 function assignUserObject()
00953 {
00954 global $rbacsystem, $rbacadmin, $rbacreview;
00955
00956 if (!$rbacsystem->checkAccess("edit_userassignment", $this->rolf_ref_id))
00957 {
00958 $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_user_to_role"),$this->ilias->error_obj->MESSAGE);
00959 }
00960
00961 if (!$rbacreview->isAssignable($this->object->getId(),$this->rolf_ref_id))
00962 {
00963 $this->ilias->raiseError($this->lng->txt("err_role_not_assignable"),$this->ilias->error_obj->MESSAGE);
00964 }
00965
00966 if (!$rbacsystem->checkAccess('write',$this->rolf_ref_id))
00967 {
00968 $this->ilias->raiseError($this->lng->txt("msg_no_perm_perm"),$this->ilias->error_obj->MESSAGE);
00969 }
00970
00971 if (!isset($_POST["user"]))
00972 {
00973 sendInfo($this->lng->txt("no_checkbox"));
00974 $this->searchObject();
00975
00976 return false;
00977 }
00978
00979 $selected_users = $_POST["user"];
00980 $assigned_users_all = $rbacreview->assignedUsers($this->object->getId());
00981
00982
00983 $assigned_users_new = array_diff($selected_users,array_intersect($selected_users,$assigned_users_all));
00984
00985
00986 if (count($assigned_users_new) == 0)
00987 {
00988 sendInfo($this->lng->txt("msg_selected_users_already_assigned"));
00989 $this->searchObject();
00990
00991 return false;
00992 }
00993
00994
00995
00996
00997 foreach ($assigned_users_new as $user)
00998 {
00999 $rbacadmin->assignUser($this->object->getId(),$user,false);
01000 }
01001
01002
01003 $this->object->_updateSessionRoles($assigned_users_new);
01004
01005
01006 $this->object->update();
01007
01008 sendInfo($this->lng->txt("msg_userassignment_changed"),true);
01009
01010 if($this->ctrl->getTargetScript() == 'adm_object.php')
01011 {
01012 ilUtil::redirect("adm_object.php?ref_id=".$this->rolf_ref_id."&obj_id=".
01013 $this->object->getId()."&cmd=userassignment&sort_by=".$_GET["sort_by"]."&sort_order=".
01014 $_GET["sort_order"]."&offset=".$_GET["offset"]);
01015 }
01016 else
01017 {
01018 $this->userassignmentObject();
01019 return true;
01020 }
01021 }
01022
01028 function deassignUserObject()
01029 {
01030 global $rbacsystem, $rbacadmin, $rbacreview;
01031
01032 if (!$rbacsystem->checkAccess("edit_userassignment", $this->rolf_ref_id))
01033 {
01034 $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_user_to_role"),$this->ilias->error_obj->MESSAGE);
01035 }
01036
01037 if (!$rbacsystem->checkAccess('write',$this->rolf_ref_id))
01038 {
01039 $this->ilias->raiseError($this->lng->txt("msg_no_perm_perm"),$this->ilias->error_obj->MESSAGE);
01040 }
01041
01042 $selected_users = ($_POST["user_id"]) ? $_POST["user_id"] : array($_GET["user_id"]);
01043
01044 if ($selected_users[0]=== NULL)
01045 {
01046 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01047 }
01048
01049
01050 if ($this->object->getId() == SYSTEM_ROLE_ID)
01051 {
01052 if ($admin = array_search(SYSTEM_USER_ID,$selected_users) !== false)
01053 unset($selected_users[$admin]);
01054 }
01055
01056
01057
01058 $last_role = array();
01059 $global_roles = $rbacreview->getGlobalRoles();
01060
01061 foreach ($selected_users as $user)
01062 {
01063 $assigned_roles = $rbacreview->assignedRoles($user);
01064 $assigned_global_roles = array_intersect($assigned_roles,$global_roles);
01065
01066 if (count($assigned_roles) == 1 or (count($assigned_global_roles) == 1 and in_array($this->object->getId(),$assigned_global_roles)))
01067 {
01068 $userObj = $this->ilias->obj_factory->getInstanceByObjId($user);
01069 $last_role[$user] = $userObj->getFullName();
01070 unset($userObj);
01071 }
01072 }
01073
01074
01075 if (count($last_role) > 0)
01076 {
01077 $user_list = implode(", ",$last_role);
01078 $this->ilias->raiseError($this->lng->txt("msg_is_last_role").": ".$user_list."<br/>".$this->lng->txt("msg_min_one_role")."<br/>".$this->lng->txt("action_aborted"),$this->ilias->error_obj->MESSAGE);
01079 }
01080
01081
01082 foreach ($selected_users as $user)
01083 {
01084 $rbacadmin->deassignUser($this->object->getId(),$user);
01085 }
01086
01087
01088 $this->object->_updateSessionRoles($selected_users);
01089
01090
01091 $this->object->update();
01092
01093 sendInfo($this->lng->txt("msg_userassignment_changed"),true);
01094
01095 if($this->ctrl->getTargetScript() == 'adm_object.php')
01096 {
01097 ilUtil::redirect("adm_object.php?ref_id=".$this->rolf_ref_id."&obj_id=".
01098 $this->object->getId()."&cmd=userassignment&sort_by=".$_GET["sort_by"]."&sort_order=".
01099 $_GET["sort_order"]."&offset=".$_GET["offset"]);
01100 }
01101 else
01102 {
01103 $this->userassignmentObject();
01104 return true;
01105 }
01106 }
01107
01113 function updateObject()
01114 {
01115 global $rbacsystem, $rbacreview;
01116
01117
01118 if (!$rbacsystem->checkAccess("write", $this->rolf_ref_id))
01119 {
01120 $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_role"),$this->ilias->error_obj->MESSAGE);
01121 }
01122
01123 if (substr($this->object->getTitle(),0,3) != "il_")
01124 {
01125
01126 if (empty($_POST["Fobject"]["title"]))
01127 {
01128 $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
01129 }
01130
01131
01132 if (substr($_POST["Fobject"]["title"],0,3) == "il_")
01133 {
01134 $this->ilias->raiseError($this->lng->txt("msg_role_reserved_prefix"),$this->ilias->error_obj->MESSAGE);
01135 }
01136
01137
01138 if ($rbacreview->roleExists($_POST["Fobject"]["title"],$this->object->getId()))
01139 {
01140 $this->ilias->raiseError($this->lng->txt("msg_role_exists1")." '".ilUtil::stripSlashes($_POST["Fobject"]["title"])."' ".
01141 $this->lng->txt("msg_role_exists2"),$this->ilias->error_obj->MESSAGE);
01142 }
01143
01144
01145 $this->object->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
01146 $this->object->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
01147 }
01148
01149
01150
01151
01152 if ($_POST["Fobject"]["allow_register"] == "")
01153 {
01154 $roles_allowed = $this->object->_lookupRegisterAllowed();
01155 if (count($roles_allowed) == 1 and $roles_allowed[0]['id'] == $this->object->getId())
01156 {
01157 $this->ilias->raiseError($this->lng->txt("msg_last_role_for_registration"),$this->ilias->error_obj->MESSAGE);
01158 }
01159 }
01160
01161 $this->object->setAllowRegister($_POST["Fobject"]["allow_register"]);
01162 $this->object->toggleAssignUsersStatus($_POST["Fobject"]["assign_users"]);
01163 $this->object->update();
01164
01165 sendInfo($this->lng->txt("saved_successfully"),true);
01166
01167 if($this->ctrl->getTargetScript() == 'adm_object.php')
01168 {
01169 ilUtil::redirect("adm_object.php?ref_id=".$this->rolf_ref_id);
01170 }
01171 else
01172 {
01173 $this->editObject();
01174 }
01175 return true;
01176 }
01177
01183 function editObject()
01184 {
01185 global $rbacsystem, $rbacreview;
01186
01187 if (!$rbacsystem->checkAccess("write", $this->rolf_ref_id))
01188 {
01189 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
01190 }
01191
01192 $this->getTemplateFile("edit");
01193
01194 if ($_SESSION["error_post_vars"])
01195 {
01196
01197 if (substr($this->object->getTitle(false),0,3) != "il_")
01198 {
01199 $this->tpl->setVariable("TITLE",ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"]),true);
01200 $this->tpl->setVariable("DESC",ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]));
01201 }
01202
01203 $allow_register = ($_SESSION["error_post_vars"]["Fobject"]["allow_register"]) ? "checked=\"checked\"" : "";
01204 $assign_users = ($_SESSION["error_post_vars"]["Fobject"]["assign_users"]) ? "checked=\"checked\"" : "";
01205 }
01206 else
01207 {
01208 if (substr($this->object->getTitle(),0,3) != "il_")
01209 {
01210 $this->tpl->setVariable("TITLE",ilUtil::prepareFormOutput($this->object->getTitle()));
01211 $this->tpl->setVariable("DESC",ilUtil::stripSlashes($this->object->getDescription()));
01212 }
01213
01214 $allow_register = ($this->object->getAllowRegister()) ? "checked=\"checked\"" : "";
01215 $assign_users = $this->object->getAssignUsersStatus() ? "checked=\"checked\"" : "";
01216
01217 }
01218
01219 $obj_str = "&obj_id=".$this->obj_id;
01220
01221 $this->tpl->setVariable("TXT_TITLE",$this->lng->txt("title"));
01222 $this->tpl->setVariable("TXT_DESC",$this->lng->txt("desc"));
01223
01224
01225 $global_roles = $rbacreview->getGlobalRoles();
01226
01227 #$this->tpl->setVariable("FORMACTION", $this->getFormAction("update","adm_object.php?cmd=gateway&ref_id=".
01228 # $this->rolf_ref_id.$obj_str));
01229
01230 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01231 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->object->getType()."_edit"));
01232 $this->tpl->setVariable("TARGET", $this->getTargetFrame("update"));
01233 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01234 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
01235 $this->tpl->setVariable("CMD_SUBMIT", "update");
01236 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01237
01238 if (substr($this->object->getTitle(),0,3) == "il_")
01239 {
01240 $this->tpl->setVariable("SHOW_TITLE",ilObjRole::_getTranslation($this->object->getTitle())." (".$this->object->getTitle().")");
01241
01242 $rolf = $rbacreview->getFoldersAssignedToRole($this->object->getId(),true);
01243 $parent_node = $this->tree->getParentNodeData($rolf[0]);
01244
01245 $this->tpl->setVariable("SHOW_DESC",$this->lng->txt("obj_".$parent_node['type'])." (".$parent_node['obj_id'].") <br/>".$parent_node['title']);
01246
01247 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01248 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("back"));
01249 $this->tpl->setVariable("CMD_SUBMIT", "cancel");
01250 }
01251
01252 if ($this->object->getId() != ANONYMOUS_ROLE_ID and
01253 $this->object->getId() != SYSTEM_ROLE_ID and
01254 in_array($this->object->getId(),$global_roles))
01255 {
01256 $this->tpl->setCurrentBlock("allow_register");
01257 $this->tpl->setVariable("TXT_ALLOW_REGISTER",$this->lng->txt("allow_register"));
01258 $this->tpl->setVariable("ALLOW_REGISTER",$allow_register);
01259 $this->tpl->parseCurrentBlock();
01260
01261 $this->tpl->setCurrentBlock("assign_users");
01262 $this->tpl->setVariable("TXT_ASSIGN_USERS",$this->lng->txt('allow_assign_users'));
01263 $this->tpl->setVariable("ASSIGN_USERS",$assign_users);
01264 $this->tpl->parseCurrentBlock();
01265 }
01266 }
01267
01271 function userassignmentObject()
01272 {
01273 global $rbacreview, $rbacsystem;
01274
01275 if (!$rbacsystem->checkAccess("edit_userassignment", $this->rolf_ref_id))
01276 {
01277 $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_user_to_role"),$this->ilias->error_obj->MESSAGE);
01278 }
01279
01280 $assigned_users = $rbacreview->assignedUsers($this->object->getId(),array("login","firstname","lastname","usr_id"));
01281
01282
01283 $val_contact = "<img src=\"".ilUtil::getImagePath("icon_pencil_b.gif")."\" alt=\"".
01284 $this->lng->txt("role_user_send_mail")."\" title=\"".
01285 $this->lng->txt("role_user_send_mail")."\" border=\"0\" vspace=\"0\"/>";
01286 $val_change = "<img src=\"".ilUtil::getImagePath("icon_change_b.gif")."\" alt=\"".
01287 $this->lng->txt("role_user_edit")."\" title=\"".$this->lng->txt("role_user_edit")."\" border=\"0\" vspace=\"0\"/>";
01288 $val_leave = "<img src=\"".ilUtil::getImagePath("icon_group_out_b.gif")."\" alt=\"".
01289 $this->lng->txt("role_user_deassign")."\" title=\"".$this->lng->txt("role_user_deassign")."\" border=\"0\" vspace=\"0\"/>";
01290
01291 $counter = 0;
01292
01293 foreach ($assigned_users as $user)
01294 {
01295 $link_contact = "mail_new.php?type=new&rcp_to=".$user["login"];
01296 $link_change = "adm_object.php?ref_id=7&obj_id=".$user["usr_id"]."&cmd=edit";
01297 $link_leave = $this->ctrl->getLinkTarget($this,"deassignUser")."&user_id=".$user["usr_id"];
01298
01299 $member_functions = "";
01300
01301
01302 if ($this->object->getId() != ANONYMOUS_ROLE_ID or $user["usr_id"] != ANONYMOUS_USER_ID)
01303 {
01304
01305 $member_functions = "<a href=\"".$link_contact."\">".$val_contact."</a>";
01306 if($this->ctrl->getTargetScript() == 'adm_object.php')
01307 {
01308 $member_functions .= "<a href=\"".$link_change."\">".$val_change."</a>";
01309 }
01310
01311 if ($this->object->getId() != SYSTEM_ROLE_ID or $user["usr_id"] != SYSTEM_USER_ID)
01312 {
01313 $member_functions .="<a href=\"".$link_leave."\">".$val_leave."</a>";
01314 }
01315 }
01316
01317
01318 if (($this->object->getId() == SYSTEM_ROLE_ID and $user["usr_id"] == SYSTEM_USER_ID)
01319 or ($this->object->getId() == ANONYMOUS_ROLE_ID and $user["usr_id"] == ANONYMOUS_USER_ID))
01320 {
01321 $result_set[$counter][] = "";
01322 }
01323 else
01324 {
01325 $result_set[$counter][] = ilUtil::formCheckBox(0,"user_id[]",$user["usr_id"]);
01326 }
01327
01328 $user_ids[$counter] = $user["usr_id"];
01329
01330 $result_set[$counter][] = $user["login"];
01331 $result_set[$counter][] = $user["firstname"];
01332 $result_set[$counter][] = $user["lastname"];
01333 $result_set[$counter][] = $member_functions;
01334
01335 ++$counter;
01336
01337 unset($member_functions);
01338 }
01339
01340 return $this->__showAssignedUsersTable($result_set,$user_ids);
01341 }
01342
01343 function __showAssignedUsersTable($a_result_set,$a_user_ids = NULL)
01344 {
01345 global $rbacsystem;
01346
01347 $actions = array("deassignUser" => $this->lng->txt("remove"));
01348
01349 $tbl =& $this->__initTableGUI();
01350 $tpl =& $tbl->getTemplateObject();
01351
01352 $tpl->setCurrentBlock("tbl_form_header");
01353 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01354 $tpl->parseCurrentBlock();
01355
01356 $tpl->setCurrentBlock("tbl_action_row");
01357
01358 $tpl->setCurrentBlock("plain_button");
01359 $tpl->setVariable("PBTN_NAME","searchUserForm");
01360 $tpl->setVariable("PBTN_VALUE",$this->lng->txt("role_add_user"));
01361 $tpl->parseCurrentBlock();
01362 $tpl->setCurrentBlock("plain_buttons");
01363 $tpl->parseCurrentBlock();
01364
01365 $tpl->setVariable("COLUMN_COUNTS",5);
01366 $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01367
01368 foreach ($actions as $name => $value)
01369 {
01370 $tpl->setCurrentBlock("tbl_action_btn");
01371 $tpl->setVariable("BTN_NAME",$name);
01372 $tpl->setVariable("BTN_VALUE",$value);
01373 $tpl->parseCurrentBlock();
01374 }
01375
01376 if (!empty($a_user_ids))
01377 {
01378
01379 $tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
01380 $tpl->setVariable("JS_VARNAME","user_id");
01381 $tpl->setVariable("JS_ONCLICK",ilUtil::array_php2js($a_user_ids));
01382 $tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
01383 $tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
01384 $tpl->parseCurrentBlock();
01385 }
01386
01387 $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
01388
01389
01390 $this->ctrl->setParameter($this,"cmd","userassignment");
01391
01392
01393
01394 $tbl->setTitle($this->lng->txt("assigned_users"),"icon_usr_b.gif",$this->lng->txt("users"));
01395
01396
01397 $tbl->setHeaderNames(array("",$this->lng->txt("username"),$this->lng->txt("firstname"),
01398 $this->lng->txt("lastname"),$this->lng->txt("grp_options")));
01399 $tbl->setHeaderVars(array("","login","firstname","lastname","functions"),$this->ctrl->getParameterArray($this,"",false));
01400 $tbl->setColumnWidth(array("","30%","30%","30%","10%"));
01401
01402 $this->__setTableGUIBasicData($tbl,$a_result_set,"userassignment");
01403 $tbl->render();
01404 $this->tpl->setVariable("ADM_CONTENT",$tbl->tpl->get());
01405
01406 return true;
01407 }
01408
01409 function &__initTableGUI()
01410 {
01411 include_once "class.ilTableGUI.php";
01412
01413 return new ilTableGUI(0,false);
01414 }
01415
01416 function __setTableGUIBasicData(&$tbl,&$result_set,$from = "")
01417 {
01418 switch($from)
01419 {
01420 case "group":
01421 $order = $_GET["sort_by"] ? $_GET["sort_by"] : "title";
01422 break;
01423
01424 case "role":
01425 $order = $_GET["sort_by"] ? $_GET["sort_by"] : "title";
01426 break;
01427
01428 default:
01429
01430 if ($_GET["sort_by"] == "title" or empty($_GET["sort_by"]))
01431 {
01432 $_GET["sort_by"] = "login";
01433 }
01434 $order = $_GET["sort_by"];
01435 break;
01436 }
01437
01438 $tbl->setOrderColumn($order);
01439 $tbl->setOrderDirection($_GET["sort_order"]);
01440 $tbl->setOffset($_GET["offset"]);
01441 $tbl->setLimit($_GET["limit"]);
01442 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01443 $tbl->setData($result_set);
01444 }
01445
01446 function searchUserFormObject()
01447 {
01448 global $rbacsystem;
01449
01450 if (!$rbacsystem->checkAccess("edit_userassignment", $this->rolf_ref_id))
01451 {
01452 $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_user_to_role"),$this->ilias->error_obj->MESSAGE);
01453 }
01454
01455 $this->lng->loadLanguageModule('search');
01456
01457 $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.role_users_search.html");
01458
01459 $this->tpl->setVariable("F_ACTION",$this->ctrl->getFormAction($this));
01460 $this->tpl->setVariable("SEARCH_ASSIGN_USR",$this->lng->txt("role_search_users"));
01461 $this->tpl->setVariable("SEARCH_SEARCH_TERM",$this->lng->txt("search_search_term"));
01462 $this->tpl->setVariable("SEARCH_VALUE",$_SESSION["role_search_str"] ? $_SESSION["role_search_str"] : "");
01463 $this->tpl->setVariable("SEARCH_FOR",$this->lng->txt("exc_search_for"));
01464 $this->tpl->setVariable("SEARCH_ROW_TXT_USER",$this->lng->txt("exc_users"));
01465 $this->tpl->setVariable("SEARCH_ROW_TXT_ROLE",$this->lng->txt("exc_roles"));
01466 $this->tpl->setVariable("SEARCH_ROW_TXT_GROUP",$this->lng->txt("exc_groups"));
01467 $this->tpl->setVariable("BTN2_VALUE",$this->lng->txt("cancel"));
01468 $this->tpl->setVariable("BTN1_VALUE",$this->lng->txt("search"));
01469
01470 $usr = ($_POST["search_for"] == "usr" || $_POST["search_for"] == "") ? 1 : 0;
01471 $grp = ($_POST["search_for"] == "grp") ? 1 : 0;
01472 $role = ($_POST["search_for"] == "role") ? 1 : 0;
01473
01474 $this->tpl->setVariable("SEARCH_ROW_CHECK_USER",ilUtil::formRadioButton($usr,"search_for","usr"));
01475 $this->tpl->setVariable("SEARCH_ROW_CHECK_ROLE",ilUtil::formRadioButton($role,"search_for","role"));
01476 $this->tpl->setVariable("SEARCH_ROW_CHECK_GROUP",ilUtil::formRadioButton($grp,"search_for","grp"));
01477
01478 $this->__unsetSessionVariables();
01479 }
01480
01481 function __unsetSessionVariables()
01482 {
01483 unset($_SESSION["role_delete_member_ids"]);
01484 unset($_SESSION["role_delete_subscriber_ids"]);
01485 unset($_SESSION["role_search_str"]);
01486 unset($_SESSION["role_search_for"]);
01487 unset($_SESSION["role_role"]);
01488 unset($_SESSION["role_group"]);
01489 unset($_SESSION["role_archives"]);
01490 }
01491
01496 function cancelObject()
01497 {
01498 if ($_GET["new_type"] != "role")
01499 {
01500 $return_location = "userassignment";
01501 }
01502
01503 sendInfo($this->lng->txt("action_aborted"),true);
01504 ilUtil::redirect($this->ctrl->getLinkTarget($this,$return_location));
01505 }
01506
01507 function searchObject()
01508 {
01509 global $rbacsystem, $tree;
01510
01511 if (!$rbacsystem->checkAccess("edit_userassignment", $this->rolf_ref_id))
01512 {
01513 $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_user_to_role"),$this->ilias->error_obj->MESSAGE);
01514 }
01515
01516 $_SESSION["role_search_str"] = $_POST["search_str"] = $_POST["search_str"] ? $_POST["search_str"] : $_SESSION["role_search_str"];
01517 $_SESSION["role_search_for"] = $_POST["search_for"] = $_POST["search_for"] ? $_POST["search_for"] : $_SESSION["role_search_for"];
01518
01519 if(!isset($_POST["search_for"]) or !isset($_POST["search_str"]))
01520 {
01521 sendInfo($this->lng->txt("role_search_enter_search_string"));
01522 $this->searchUserFormObject();
01523
01524 return false;
01525 }
01526
01527 if(!count($result = $this->__search(ilUtil::stripSlashes($_POST["search_str"]),$_POST["search_for"])))
01528 {
01529 sendInfo($this->lng->txt("role_no_results_found"));
01530 $this->searchUserFormObject();
01531
01532 return false;
01533 }
01534
01535 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.role_usr_selection.html");
01536 $this->__showButton("searchUserForm",$this->lng->txt("role_new_search"));
01537
01538 $counter = 0;
01539 $f_result = array();
01540
01541 switch($_POST["search_for"])
01542 {
01543 case "usr":
01544 foreach($result as $user)
01545 {
01546 if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user["id"],false))
01547 {
01548 continue;
01549 }
01550
01551 $user_ids[$counter] = $user["id"];
01552
01553 $f_result[$counter][] = ilUtil::formCheckbox(0,"user[]",$user["id"]);
01554 $f_result[$counter][] = $tmp_obj->getLogin();
01555 $f_result[$counter][] = $tmp_obj->getFirstname();
01556 $f_result[$counter][] = $tmp_obj->getLastname();
01557
01558 unset($tmp_obj);
01559 ++$counter;
01560 }
01561 $this->__showSearchUserTable($f_result,$user_ids);
01562
01563 return true;
01564
01565 case "role":
01566 foreach($result as $role)
01567 {
01568
01569 if ($role["id"] == ANONYMOUS_ROLE_ID)
01570 {
01571 continue;
01572 }
01573
01574 if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($role["id"],false))
01575 {
01576 continue;
01577 }
01578
01579
01580 if ($tmp_obj->getCountMembers() == 0)
01581 {
01582 continue;
01583 }
01584
01585 $role_ids[$counter] = $role["id"];
01586
01587 $f_result[$counter][] = ilUtil::formCheckbox(0,"role[]",$role["id"]);
01588 $f_result[$counter][] = array($tmp_obj->getTitle(),$tmp_obj->getDescription());
01589 $f_result[$counter][] = $tmp_obj->getCountMembers();
01590
01591 unset($tmp_obj);
01592 ++$counter;
01593 }
01594
01595 $this->__showSearchRoleTable($f_result,$role_ids);
01596
01597 return true;
01598
01599 case "grp":
01600 foreach($result as $group)
01601 {
01602 if(!$tree->isInTree($group["id"]))
01603 {
01604 continue;
01605 }
01606
01607 if(!$tmp_obj = ilObjectFactory::getInstanceByRefId($group["id"],false))
01608 {
01609 continue;
01610 }
01611
01612
01613 if ($tmp_obj->getId() == $this->object->getId())
01614 {
01615 continue;
01616 }
01617
01618 $grp_ids[$counter] = $group["id"];
01619
01620 $f_result[$counter][] = ilUtil::formCheckbox(0,"group[]",$group["id"]);
01621 $f_result[$counter][] = array($tmp_obj->getTitle(),$tmp_obj->getDescription());
01622 $f_result[$counter][] = $tmp_obj->getCountMembers();
01623
01624 unset($tmp_obj);
01625 ++$counter;
01626 }
01627 $this->__showSearchGroupTable($f_result,$grp_ids);
01628
01629 return true;
01630 }
01631 }
01632
01633 function __search($a_search_string,$a_search_for)
01634 {
01635 include_once("class.ilSearch.php");
01636
01637 $this->lng->loadLanguageModule("content");
01638 $search =& new ilSearch($_SESSION["AccountId"]);
01639 $search->setPerformUpdate(false);
01640 $search->setSearchString(ilUtil::stripSlashes($a_search_string));
01641 $search->setCombination("and");
01642 $search->setSearchFor(array(0 => $a_search_for));
01643 $search->setSearchType('new');
01644
01645 if($search->validate($message))
01646 {
01647 $search->performSearch();
01648 }
01649 else
01650 {
01651 sendInfo($message,true);
01652 $this->ctrl->redirect($this,"searchUserForm");
01653 }
01654
01655 return $search->getResultByType($a_search_for);
01656 }
01657
01658 function __showSearchUserTable($a_result_set,$a_user_ids = NULL,$a_cmd = "search")
01659 {
01660 $return_to = "searchUserForm";
01661
01662 if ($a_cmd == "listUsersRole" or $a_cmd == "listUsersGroup")
01663 {
01664 $return_to = "search";
01665 }
01666
01667 $tbl =& $this->__initTableGUI();
01668 $tpl =& $tbl->getTemplateObject();
01669
01670
01671 $tpl->setCurrentBlock("tbl_form_header");
01672 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01673 $tpl->parseCurrentBlock();
01674
01675 $tpl->setCurrentBlock("tbl_action_btn");
01676 $tpl->setVariable("BTN_NAME",$return_to);
01677 $tpl->setVariable("BTN_VALUE",$this->lng->txt("back"));
01678 $tpl->parseCurrentBlock();
01679
01680 $tpl->setCurrentBlock("tbl_action_btn");
01681 $tpl->setVariable("BTN_NAME","assignUser");
01682 $tpl->setVariable("BTN_VALUE",$this->lng->txt("add"));
01683 $tpl->parseCurrentBlock();
01684
01685 if (!empty($a_user_ids))
01686 {
01687
01688 $tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
01689 $tpl->setVariable("JS_VARNAME","user");
01690 $tpl->setVariable("JS_ONCLICK",ilUtil::array_php2js($a_user_ids));
01691 $tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
01692 $tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
01693 $tpl->parseCurrentBlock();
01694 }
01695
01696 $tpl->setCurrentBlock("tbl_action_row");
01697 $tpl->setVariable("COLUMN_COUNTS",4);
01698 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01699 $tpl->parseCurrentBlock();
01700
01701 $tbl->setTitle($this->lng->txt("role_header_edit_users"),"icon_usr_b.gif",$this->lng->txt("role_header_edit_users"));
01702 $tbl->setHeaderNames(array("",
01703 $this->lng->txt("username"),
01704 $this->lng->txt("firstname"),
01705 $this->lng->txt("lastname")));
01706 $tbl->setHeaderVars(array("",
01707 "login",
01708 "firstname",
01709 "lastname"),
01710 array("ref_id" => $this->rolf_ref_id,
01711 "obj_id" => $this->object->getId(),
01712 "cmd" => $a_cmd,
01713 "cmdClass" => "ilobjrolegui",
01714 "cmdNode" => $_GET["cmdNode"]));
01715
01716 $tbl->setColumnWidth(array("","33%","33%","33%"));
01717
01718 $this->__setTableGUIBasicData($tbl,$a_result_set);
01719 $tbl->render();
01720
01721 $this->tpl->setVariable("SEARCH_RESULT_TABLE",$tbl->tpl->get());
01722
01723 return true;
01724 }
01725
01726 function __showSearchRoleTable($a_result_set,$a_role_ids = NULL)
01727 {
01728 $tbl =& $this->__initTableGUI();
01729 $tpl =& $tbl->getTemplateObject();
01730
01731 $tpl->setCurrentBlock("tbl_form_header");
01732 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01733 $tpl->parseCurrentBlock();
01734
01735 $tpl->setCurrentBlock("tbl_action_btn");
01736 $tpl->setVariable("BTN_NAME","searchUserForm");
01737 $tpl->setVariable("BTN_VALUE",$this->lng->txt("back"));
01738 $tpl->parseCurrentBlock();
01739
01740 $tpl->setCurrentBlock("tbl_action_btn");
01741 $tpl->setVariable("BTN_NAME","listUsersRole");
01742 $tpl->setVariable("BTN_VALUE",$this->lng->txt("role_list_users"));
01743 $tpl->parseCurrentBlock();
01744
01745 if (!empty($a_role_ids))
01746 {
01747
01748 $tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
01749 $tpl->setVariable("JS_VARNAME","role");
01750 $tpl->setVariable("JS_ONCLICK",ilUtil::array_php2js($a_role_ids));
01751 $tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
01752 $tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
01753 $tpl->parseCurrentBlock();
01754 }
01755
01756 $tpl->setCurrentBlock("tbl_action_row");
01757 $tpl->setVariable("COLUMN_COUNTS",4);
01758 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01759 $tpl->parseCurrentBlock();
01760
01761 $tbl->setTitle($this->lng->txt("role_header_edit_users"),"icon_usr_b.gif",$this->lng->txt("role_header_edit_users"));
01762 $tbl->setHeaderNames(array("",
01763 $this->lng->txt("obj_role"),
01764 $this->lng->txt("role_count_users")));
01765 $tbl->setHeaderVars(array("",
01766 "title",
01767 "nr_members"),
01768 array("ref_id" => $this->rolf_ref_id,
01769 "obj_id" => $this->object->getId(),
01770 "cmd" => "search",
01771 "cmdClass" => "ilobjrolegui",
01772 "cmdNode" => $_GET["cmdNode"]));
01773
01774 $tbl->setColumnWidth(array("","80%","19%"));
01775
01776
01777 $this->__setTableGUIBasicData($tbl,$a_result_set,"role");
01778 $tbl->render();
01779
01780 $this->tpl->setVariable("SEARCH_RESULT_TABLE",$tbl->tpl->get());
01781
01782 return true;
01783 }
01784
01785 function __showSearchGroupTable($a_result_set,$a_grp_ids = NULL)
01786 {
01787 $tbl =& $this->__initTableGUI();
01788 $tpl =& $tbl->getTemplateObject();
01789
01790 $tpl->setCurrentBlock("tbl_form_header");
01791 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01792 $tpl->parseCurrentBlock();
01793
01794 $tpl->setCurrentBlock("tbl_action_btn");
01795 $tpl->setVariable("BTN_NAME","searchUserForm");
01796 $tpl->setVariable("BTN_VALUE",$this->lng->txt("back"));
01797 $tpl->parseCurrentBlock();
01798
01799 $tpl->setCurrentBlock("tbl_action_btn");
01800 $tpl->setVariable("BTN_NAME","listUsersGroup");
01801 $tpl->setVariable("BTN_VALUE",$this->lng->txt("grp_list_users"));
01802 $tpl->parseCurrentBlock();
01803
01804 if (!empty($a_grp_ids))
01805 {
01806
01807 $tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
01808 $tpl->setVariable("JS_VARNAME","group");
01809 $tpl->setVariable("JS_ONCLICK",ilUtil::array_php2js($a_grp_ids));
01810 $tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
01811 $tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
01812 $tpl->parseCurrentBlock();
01813 }
01814
01815 $tpl->setCurrentBlock("tbl_action_row");
01816 $tpl->setVariable("COLUMN_COUNTS",4);
01817 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01818 $tpl->parseCurrentBlock();
01819
01820 $tbl->setTitle($this->lng->txt("grp_header_edit_members"),"icon_usr_b.gif",$this->lng->txt("grp_header_edit_members"));
01821 $tbl->setHeaderNames(array("",
01822 $this->lng->txt("obj_grp"),
01823 $this->lng->txt("grp_count_members")));
01824 $tbl->setHeaderVars(array("",
01825 "title",
01826 "nr_members"),
01827 array("ref_id" => $this->rolf_ref_id,
01828 "obj_id" => $this->object->getId(),
01829 "cmd" => "search",
01830 "cmdClass" => "ilobjrolegui",
01831 "cmdNode" => $_GET["cmdNode"]));
01832
01833 $tbl->setColumnWidth(array("","80%","19%"));
01834
01835
01836 $this->__setTableGUIBasicData($tbl,$a_result_set,"group");
01837 $tbl->render();
01838
01839 $this->tpl->setVariable("SEARCH_RESULT_TABLE",$tbl->tpl->get());
01840
01841 return true;
01842 }
01843
01844 function listUsersRoleObject()
01845 {
01846 global $rbacsystem,$rbacreview;
01847
01848 $_SESSION["role_role"] = $_POST["role"] = $_POST["role"] ? $_POST["role"] : $_SESSION["role_role"];
01849
01850 if(!is_array($_POST["role"]))
01851 {
01852 sendInfo($this->lng->txt("role_no_roles_selected"));
01853 $this->searchObject();
01854
01855 return false;
01856 }
01857
01858 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.role_usr_selection.html");
01859 $this->__showButton("searchUserForm",$this->lng->txt("role_new_search"));
01860
01861
01862 $members = array();
01863 foreach($_POST["role"] as $role_id)
01864 {
01865 $members = array_merge($rbacreview->assignedUsers($role_id),$members);
01866 }
01867
01868 $members = array_unique($members);
01869
01870
01871 $counter = 0;
01872 $f_result = array();
01873 foreach($members as $user)
01874 {
01875 if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user,false))
01876 {
01877 continue;
01878 }
01879
01880 $user_ids[$counter] = $user;
01881
01882
01883 $f_result[$counter][] = ilUtil::formCheckbox(0,"user[]",$user);
01884 $f_result[$counter][] = $tmp_obj->getLogin();
01885 $f_result[$counter][] = $tmp_obj->getFirstname();
01886 $f_result[$counter][] = $tmp_obj->getLastname();
01887
01888 unset($tmp_obj);
01889 ++$counter;
01890 }
01891 $this->__showSearchUserTable($f_result,$user_ids,"listUsersRole");
01892
01893 return true;
01894 }
01895
01896 function listUsersGroupObject()
01897 {
01898 global $rbacsystem,$rbacreview,$tree;
01899
01900 $_SESSION["role_group"] = $_POST["group"] = $_POST["group"] ? $_POST["group"] : $_SESSION["role_group"];
01901
01902 if(!is_array($_POST["group"]))
01903 {
01904 sendInfo($this->lng->txt("role_no_groups_selected"));
01905 $this->searchObject();
01906
01907 return false;
01908 }
01909
01910 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.role_usr_selection.html");
01911 $this->__showButton("searchUserForm",$this->lng->txt("role_new_search"));
01912
01913
01914 $members = array();
01915 foreach($_POST["group"] as $group_id)
01916 {
01917 if (!$tree->isInTree($group_id))
01918 {
01919 continue;
01920 }
01921 if (!$tmp_obj = ilObjectFactory::getInstanceByRefId($group_id))
01922 {
01923 continue;
01924 }
01925
01926 $members = array_merge($tmp_obj->getGroupMemberIds(),$members);
01927
01928 unset($tmp_obj);
01929 }
01930
01931 $members = array_unique($members);
01932
01933
01934 $counter = 0;
01935 $f_result = array();
01936 foreach($members as $user)
01937 {
01938 if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user,false))
01939 {
01940 continue;
01941 }
01942
01943 $user_ids[$counter] = $user;
01944
01945 $f_result[$counter][] = ilUtil::formCheckbox(0,"user[]",$user);
01946 $f_result[$counter][] = $tmp_obj->getLogin();
01947 $f_result[$counter][] = $tmp_obj->getFirstname();
01948 $f_result[$counter][] = $tmp_obj->getLastname();
01949
01950 unset($tmp_obj);
01951 ++$counter;
01952 }
01953 $this->__showSearchUserTable($f_result,$user_ids,"listUsersGroup");
01954
01955 return true;
01956 }
01957
01958
01959 function __formatPath($a_path_arr)
01960 {
01961 $counter = 0;
01962 foreach($a_path_arr as $data)
01963 {
01964 if($counter++)
01965 {
01966 $path .= " -> ";
01967 }
01968 $path .= $data['title'];
01969 }
01970 if(strlen($path) > 50)
01971 {
01972 return '...'.substr($path,-50);
01973 }
01974 return $path;
01975 }
01976
01977 function __prepareOutput()
01978 {
01979
01980 $this->tpl->addBlockFile("CONTENT", "content", "tpl.role.html");
01981 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
01982
01983
01984 $this->__setLocator();
01985
01986
01987 if ($this->message)
01988 {
01989 sendInfo($this->message);
01990 }
01991
01992
01993 infoPanel();
01994
01995
01996 $this->__setHeader();
01997 }
01998
01999 function __setHeader()
02000 {
02001 include_once './classes/class.ilTabsGUI.php';
02002
02003 $this->tpl->setVariable("HEADER",$this->lng->txt('role'));
02004 $this->tpl->setVariable("H_DESCRIPTION",$this->object->getTitle());
02005
02006 $tabs_gui =& new ilTabsGUI();
02007 $this->getTabs($tabs_gui);
02008
02009
02010 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
02011 }
02012
02013 function __setLocator()
02014 {
02015 global $tree;
02016 global $ilias_locator;
02017
02018 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
02019
02020 $counter = 0;
02021 foreach ($tree->getPathFull($this->rolf_ref_id) as $key => $row)
02022 {
02023 if($counter++)
02024 {
02025 $this->tpl->touchBlock('locator_separator_prefix');
02026 }
02027
02028 $this->tpl->setCurrentBlock("locator_item");
02029
02030 if($row["type"] == 'rolf')
02031 {
02032 $this->tpl->setVariable("ITEM",$this->object->getTitle());
02033 $this->tpl->setVariable("LINK_ITEM",$this->ctrl->getLinkTarget($this));
02034 }
02035 elseif ($row["child"] != $tree->getRootId())
02036 {
02037 $this->tpl->setVariable("ITEM", $row["title"]);
02038 $this->tpl->setVariable("LINK_ITEM","repository.php?ref_id=".$row["child"]);
02039 }
02040 else
02041 {
02042 $this->tpl->setVariable("ITEM", $this->lng->txt("repository"));
02043 $this->tpl->setVariable("LINK_ITEM","repository.php?ref_id=".$row["child"]);
02044 }
02045
02046 $this->tpl->parseCurrentBlock();
02047 }
02048
02049 $this->tpl->setVariable("TXT_LOCATOR",$this->lng->txt("locator"));
02050 $this->tpl->parseCurrentBlock();
02051 }
02052
02053 function getTabs(&$tabs_gui)
02054 {
02055 global $rbacsystem,$rbacreview;
02056
02057 $base_role_folder = $rbacreview->getFoldersAssignedToRole($this->object->getId(),true);
02058 $real_local_role = in_array($this->rolf_ref_id,$base_role_folder);
02059
02060 $this->ctrl->setParameter($this,"ref_id",$this->rolf_ref_id);
02061 $this->ctrl->setParameter($this,"obj_id",$this->object->getId());
02062
02063 if($rbacsystem->checkAccess('write',$this->rolf_ref_id) and $real_local_role)
02064 {
02065 $tabs_gui->addTarget("edit_properties",
02066 $this->ctrl->getLinkTarget($this, "edit"), "edit", get_class($this));
02067 }
02068 if($rbacsystem->checkAccess('write',$this->rolf_ref_id))
02069 {
02070 $tabs_gui->addTarget("default_perm_settings",
02071 $this->ctrl->getLinkTarget($this, "perm"), "perm", get_class($this));
02072 }
02073 if($rbacsystem->checkAccess('edit_userassignment',$this->rolf_ref_id) and $real_local_role)
02074 {
02075 $tabs_gui->addTarget("user_assignment",
02076 $this->ctrl->getLinkTarget($this, "userassignment"), "userassignment", get_class($this));
02077 }
02078 if($rbacsystem->checkAccess('write',$this->rolf_ref_id) and $real_local_role)
02079 {
02080 $tabs_gui->addTarget("desktop_items",
02081 $this->ctrl->getLinkTarget($this, "listDesktopItems"), "listDesktopItems", get_class($this));
02082 }
02083
02084 }
02085
02086
02087
02088 }
02089 ?>