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
00037 require_once "class.ilObjectGUI.php";
00038
00039 class ilObjTypeDefinitionGUI extends ilObjectGUI
00040 {
00046 function ilObjTypeDefinitionGUI($a_data,$a_id,$a_call_by_reference)
00047 {
00048 $this->type = "typ";
00049 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference);
00050 }
00051
00056 function viewObject()
00057 {
00058 global $rbacadmin, $rbacreview;
00059
00060
00061 $this->data = array();
00062 $this->data["data"] = array();
00063 $this->data["ctrl"] = array();
00064 $this->data["cols"] = array("type", "operation", "description", "status");
00065
00066 $ops_valid = $rbacreview->getOperationsOnType($_GET["obj_id"]);
00067
00068 if ($list = getOperationList("",$_GET["order"], $_GET["direction"]))
00069 {
00070 foreach ($list as $key => $val)
00071 {
00072
00073 if (in_array($val["ops_id"],$ops_valid))
00074 {
00075 $ops_status = 'enabled';
00076 }
00077 else
00078 {
00079 $ops_status = 'disabled';
00080 }
00081
00082
00083 $this->data["data"][] = array(
00084 "type" => "perm",
00085 "operation" => $val["operation"],
00086 "description" => $val["desc"],
00087 "status" => $ops_status,
00088 "obj_id" => $val["ops_id"]
00089 );
00090
00091 }
00092 }
00093
00094 $this->maxcount = count($this->data["data"]);
00095
00096
00097 $this->data["data"] = ilUtil::sortArray($this->data["data"],$_GET["sort_by"],$_GET["sort_order"]);
00098
00099
00100 foreach ($this->data["data"] as $key => $val)
00101 {
00102 $this->data["ctrl"][$key] = array(
00103 "obj_id" => $val["obj_id"],
00104 "type" => $val["type"]
00105 );
00106
00107 unset($this->data["data"][$key]["obj_id"]);
00108 }
00109
00110 $this->displayList();
00111 }
00112
00118 function displayList()
00119 {
00120 include_once "./classes/class.ilTableGUI.php";
00121
00122
00123 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
00124
00125 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
00126
00127 $num = 0;
00128
00129 $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
00130 $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."$obj_str&cmd=gateway");
00131
00132
00133 $tbl = new ilTableGUI();
00134
00135
00136 $tbl->setTitle($this->lng->txt("obj_".$this->object->getType())." '".$this->object->getTitle()."'","icon_".$this->object->getType()."_b.gif",$this->lng->txt("obj_".$this->object->getType()));
00137 $tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00138
00139 foreach ($this->data["cols"] as $val)
00140 {
00141 $header_names[] = $this->lng->txt($val);
00142 }
00143
00144 $tbl->setHeaderNames($header_names);
00145
00146 $header_params = array("ref_id" => $this->ref_id,"obj_id" => $this->id);
00147 $tbl->setHeaderVars($this->data["cols"],$header_params);
00148
00149
00150 $tbl->setOrderColumn($_GET["sort_by"]);
00151 $tbl->setOrderDirection($_GET["sort_order"]);
00152 $tbl->setLimit(0);
00153 $tbl->setOffset(0);
00154 $tbl->setMaxCount($this->maxcount);
00155
00156
00157 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00158
00159
00160
00161 $tbl->render();
00162
00163 if (is_array($this->data["data"][0]))
00164 {
00165
00166 for ($i=0; $i < count($this->data["data"]); $i++)
00167 {
00168 $data = $this->data["data"][$i];
00169 $ctrl = $this->data["ctrl"][$i];
00170
00171
00172 $css_row = ilUtil::switchColor($i+1,"tblrow1","tblrow2");
00173
00174 $this->tpl->setCurrentBlock("table_cell");
00175 $this->tpl->setVariable("CELLSTYLE", "tblrow1");
00176 $this->tpl->parseCurrentBlock();
00177
00178 foreach ($data as $key => $val)
00179 {
00180
00181 if ($key == "status")
00182 {
00183 if ($val == "enabled")
00184 {
00185 $color = "green";
00186 }
00187 else
00188 {
00189 $color = "red";
00190 }
00191
00192 $val = "<font color=\"".$color."\">".$this->lng->txt($val)."</font>";
00193 }
00194
00195 $this->tpl->setCurrentBlock("text");
00196
00197 if ($key == "type")
00198 {
00199 $val = ilUtil::getImageTagByType($val,$this->tpl->tplPath);
00200 }
00201
00202 $this->tpl->setVariable("TEXT_CONTENT", $val);
00203 $this->tpl->parseCurrentBlock();
00204
00205 $this->tpl->setCurrentBlock("table_cell");
00206 $this->tpl->parseCurrentBlock();
00207
00208 }
00209
00210 $this->tpl->setCurrentBlock("tbl_content");
00211 $this->tpl->setVariable("CSS_ROW", $css_row);
00212 $this->tpl->parseCurrentBlock();
00213 }
00214 }
00215 }
00216
00222 function saveObject()
00223 {
00224 global $rbacsystem, $rbacadmin, $rbacreview;
00225
00226 if (!$rbacsystem->checkAccess('edit_permission', $_GET["ref_id"]))
00227 {
00228 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->WARNING);
00229 }
00230
00231 $ops_valid = $rbacreview->getOperationsOnType($_GET["obj_id"]);
00232
00233 foreach ($_POST["id"] as $ops_id => $status)
00234 {
00235 if ($status == 'enabled')
00236 {
00237 if (!in_array($ops_id,$ops_valid))
00238 {
00239 $rbacadmin->assignOperationToObject($_GET["obj_id"],$ops_id);
00240 }
00241 }
00242
00243 if ($status == 'disabled')
00244 {
00245 if (in_array($ops_id,$ops_valid))
00246 {
00247 $rbacadmin->deassignOperationFromObject($_GET["obj_id"],$ops_id);
00248 }
00249 }
00250 }
00251
00252 $this->update = $this->object->update();
00253
00254 sendInfo($this->lng->txt("saved_successfully"),true);
00255
00256 header("Location: adm_object.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]);
00257 exit();
00258 }
00259
00260
00266 function editObject()
00267 {
00268 global $rbacsystem, $rbacreview;
00269
00270 if (!$rbacsystem->checkAccess("edit_permission",$_GET["ref_id"]))
00271 {
00272 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00273 }
00274
00275
00276 $this->data = array();
00277 $this->data["data"] = array();
00278 $this->data["ctrl"] = array();
00279 $this->data["cols"] = array("type", "operation", "description", "status");
00280
00281 $ops_valid = $rbacreview->getOperationsOnType($this->obj_id);
00282
00283 if ($ops_arr = getOperationList('', $a_order, $a_direction))
00284 {
00285 $options = array("e" => "enabled","d" => "disabled");
00286
00287 foreach ($ops_arr as $key => $ops)
00288 {
00289
00290 if (in_array($ops["ops_id"],$ops_valid))
00291 {
00292 $ops_status = 'e';
00293 }
00294 else
00295 {
00296 $ops_status = 'd';
00297 }
00298
00299 $obj = $ops["ops_id"];
00300 $ops_options = ilUtil::formSelect($ops_status,"id[$obj]",$options);
00301
00302
00303 $this->data["data"][] = array(
00304 "type" => "perm",
00305 "operation" => $ops["operation"],
00306 "description" => $ops["desc"],
00307 "status" => $ops_status,
00308 "status_html" => $ops_options,
00309 "obj_id" => $val["ops_id"]
00310 );
00311 }
00312 }
00313
00314 $this->maxcount = count($this->data["data"]);
00315
00316
00317 $this->data["data"] = ilUtil::sortArray($this->data["data"],$_GET["sort_by"],$_GET["sort_order"]);
00318
00319
00320 foreach ($this->data["data"] as $key => $val)
00321 {
00322 $this->data["ctrl"][$key] = array(
00323 "obj_id" => $val["obj_id"],
00324 "type" => $val["type"]
00325 );
00326
00327 unset($this->data["data"][$key]["obj_id"]);
00328 $this->data["data"][$key]["status"] = $this->data["data"][$key]["status_html"];
00329 unset($this->data["data"][$key]["status_html"]);
00330 }
00331
00332
00333 include_once "./classes/class.ilTableGUI.php";
00334
00335
00336 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
00337
00338 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
00339
00340 $num = 0;
00341
00342 $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
00343 $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."$obj_str&cmd=save");
00344
00345
00346 $tbl = new ilTableGUI();
00347
00348
00349 $tbl->setTitle($this->lng->txt("edit_operations")." ".strtolower($this->lng->txt("of"))." '".$this->object->getTitle()."'","icon_".$this->object->getType()."_b.gif",$this->lng->txt("obj_".$this->object->getType()));
00350 $tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00351
00352 foreach ($this->data["cols"] as $val)
00353 {
00354 $header_names[] = $this->lng->txt($val);
00355 }
00356
00357 $tbl->setHeaderNames($header_names);
00358
00359 $header_params = array("ref_id" => $this->ref_id,"obj_id" => $this->id,"cmd" => "edit");
00360 $tbl->setHeaderVars($this->data["cols"],$header_params);
00361
00362
00363 $tbl->setOrderColumn($_GET["sort_by"]);
00364 $tbl->setOrderDirection($_GET["sort_order"]);
00365 $tbl->setLimit(0);
00366 $tbl->setOffset(0);
00367 $tbl->setMaxCount($this->maxcount);
00368
00369
00370 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00371 $this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
00372
00373
00374 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00375
00376
00377
00378 $tbl->render();
00379
00380 if (is_array($this->data["data"][0]))
00381 {
00382
00383 for ($i=0; $i < count($this->data["data"]); $i++)
00384 {
00385 $data = $this->data["data"][$i];
00386 $ctrl = $this->data["ctrl"][$i];
00387
00388
00389 $css_row = ilUtil::switchColor($i+1,"tblrow1","tblrow2");
00390
00391 $this->tpl->setCurrentBlock("table_cell");
00392 $this->tpl->setVariable("CELLSTYLE", "tblrow1");
00393 $this->tpl->parseCurrentBlock();
00394
00395 foreach ($data as $key => $val)
00396 {
00397 $this->tpl->setCurrentBlock("text");
00398
00399 if ($key == "type")
00400 {
00401 $val = ilUtil::getImageTagByType($val,$this->tpl->tplPath);
00402 }
00403
00404 $this->tpl->setVariable("TEXT_CONTENT", $val);
00405 $this->tpl->parseCurrentBlock();
00406
00407 $this->tpl->setCurrentBlock("table_cell");
00408 $this->tpl->parseCurrentBlock();
00409
00410 }
00411
00412 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("save"));
00413
00414 $this->tpl->setCurrentBlock("tbl_content");
00415 $this->tpl->setVariable("CSS_ROW", $css_row);
00416 $this->tpl->parseCurrentBlock();
00417 }
00418 }
00419 }
00420
00421 function &executeCommand()
00422 {
00423 $next_class = $this->ctrl->getNextClass($this);
00424 $cmd = $this->ctrl->getCmd();
00425
00426 switch($next_class)
00427 {
00428 default:
00429 if(!$cmd)
00430 {
00431 $cmd = "view";
00432 }
00433 $cmd .= "Object";
00434 $this->$cmd();
00435
00436 break;
00437 }
00438 return true;
00439 }
00440
00446 function getTabs(&$tabs_gui)
00447 {
00448 global $rbacsystem;
00449
00450 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00451 {
00452 $tabs_gui->addTarget("settings",
00453 $this->ctrl->getLinkTarget($this, "view"), array("view",""), "", "");
00454
00455 $tabs_gui->addTarget("edit_operations",
00456 $this->ctrl->getLinkTarget($this, "edit"), "edit", "", "");
00457 }
00458 }
00459 }
00460 ?>