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
00025
00038 require_once "class.ilContainerGUI.php";
00039
00040 class ilObjFolderGUI extends ilContainerGUI
00041 {
00042 var $folder_tree;
00043
00048 function ilObjFolderGUI($a_data, $a_id = 0, $a_call_by_reference = true, $a_prepare_output = false)
00049 {
00050 $this->type = "fold";
00051 $this->ilContainerGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output, false);
00052 }
00053
00054
00055 function viewObject()
00056 {
00057 global $tree;
00058
00059 if (strtolower($_GET["baseClass"]) == "iladministrationgui")
00060 {
00061 parent::viewObject();
00062 return true;
00063 }
00064 else if(!$tree->checkForParentType($this->ref_id,'crs'))
00065 {
00066
00067 $this->renderObject();
00068 }
00069 else
00070 {
00071 $this->initCourseContentInterface();
00072 $this->cci_obj->cci_setContainer($this);
00073 $this->cci_obj->cci_view();
00074 }
00075
00076 $this->tabs_gui->setTabActive('view_content');
00077 return true;
00078 }
00079
00080
00081
00082 function &executeCommand()
00083 {
00084 $next_class = $this->ctrl->getNextClass($this);
00085 $cmd = $this->ctrl->getCmd();
00086 $this->prepareOutput();
00087
00088 switch ($next_class)
00089 {
00090 case "ilconditionhandlerinterface":
00091 include_once './classes/class.ilConditionHandlerInterface.php';
00092
00093 if($_GET['item_id'])
00094 {
00095 $this->ctrl->saveParameter($this,'item_id',$_GET['item_id']);
00096 $this->__setSubTabs('activation');
00097 $this->tabs_gui->setTabActive('view_content');
00098
00099 $new_gui =& new ilConditionHandlerInterface($this,(int) $_GET['item_id']);
00100 $this->ctrl->forwardCommand($new_gui);
00101 }
00102 else
00103 {
00104 $new_gui =& new ilConditionHandlerInterface($this);
00105 $this->ctrl->forwardCommand($new_gui);
00106 }
00107 break;
00108
00109 case 'ilpermissiongui':
00110 include_once("./classes/class.ilPermissionGUI.php");
00111 $perm_gui =& new ilPermissionGUI($this);
00112 $ret =& $this->ctrl->forwardCommand($perm_gui);
00113 break;
00114
00115 default:
00116 if (empty($cmd))
00117 {
00118 $cmd = "view";
00119 }
00120 $cmd .= "Object";
00121 $this->$cmd();
00122 break;
00123 }
00124 }
00125
00129 function setFolderTree($a_tree)
00130 {
00131 $this->folder_tree =& $a_tree;
00132 }
00133
00139 function createObject()
00140 {
00141 global $lng;
00142
00143 $this->lng =& $lng;
00144
00145 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
00146
00147
00148 $data = array();
00149 $data["fields"] = array();
00150 $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
00151 $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
00152
00153 $this->getTemplateFile("edit",$new_type);
00154
00155 foreach ($data["fields"] as $key => $val)
00156 {
00157 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
00158 $this->tpl->setVariable(strtoupper($key), $val);
00159 }
00160
00161 $this->tpl->setVariable("FORMACTION", $this->getFormAction("save",$this->ctrl->getFormAction($this)."&new_type=".$new_type));
00162 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->type."_new"));
00163 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00164 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($this->type."_add"));
00165 $this->tpl->setVariable("CMD_SUBMIT", "save");
00166 $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
00167 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00168 }
00169
00175 function saveObject($a_parent = 0)
00176 {
00177 global $lng;
00178
00179 $this->lng =& $lng;
00180
00181 if ($a_parent == 0)
00182 {
00183 $a_parent = $_GET["ref_id"];
00184 }
00185
00186
00187 include_once("classes/class.ilObjFolder.php");
00188 $folderObj = new ilObjFolder(0,$this->withReferences());
00189 $folderObj->setType($this->type);
00190 $folderObj->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
00191 $folderObj->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
00192 $folderObj->create();
00193 $this->object =& $folderObj;
00194
00195 if (is_object($this->folder_tree))
00196 {
00197 $folderObj->setFolderTree($this->folder_tree);
00198 }
00199 else
00200 {
00201 $folderObj->setFolderTree($this->tree);
00202 }
00203
00204 if ($this->withReferences())
00205 {
00206 $folderObj->createReference();
00207 $folderObj->setPermissions($a_parent);
00208 }
00209
00210 $folderObj->putInTree($a_parent);
00211
00212 sendInfo($this->lng->txt("fold_added"),true);
00213 $this->ctrl->returnToParent($this);
00214
00215 }
00216
00222 function updateObject($a_return_to_parent = false)
00223 {
00224 $this->object->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
00225 $this->object->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
00226 $this->update = $this->object->update();
00227
00228 sendInfo($this->lng->txt("msg_obj_modified"),true);
00229
00230 if ($a_return_to_parent)
00231 {
00232 $this->ctrl->returnToParent($this);
00233 }
00234 else
00235 {
00236 $this->ctrl->redirect($this);
00237 }
00238 }
00239
00240
00241
00242 function getTabs(&$tabs_gui)
00243 {
00244 global $rbacsystem;
00245
00246 $this->ctrl->setParameter($this,"ref_id",$this->ref_id);
00247
00248 $tabs_gui->setTabActive("");
00249 if ($rbacsystem->checkAccess('read',$this->ref_id))
00250 {
00251 $tabs_gui->addTarget("view_content",
00252 $this->ctrl->getLinkTarget($this, ""),
00253 array("", "view", "cciMove", "enableAdministrationPanel",
00254 "disableAdministrationPanel", "render"),
00255 get_class($this));
00256 }
00257
00258 if ($rbacsystem->checkAccess('write',$this->ref_id))
00259 {
00260 $tabs_gui->addTarget("edit_properties",
00261 $this->ctrl->getLinkTarget($this, "edit"), "edit", get_class($this));
00262 }
00263
00264 if ($rbacsystem->checkAccess('edit_permission',$this->ref_id))
00265 {
00266 $tabs_gui->addTarget("perm_settings",
00267 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
00268 }
00269
00270
00271 if ($this->ctrl->getTargetScript() == "repository.php" and !empty($_SESSION['il_rep_clipboard']))
00272 {
00273 $tabs_gui->addTarget("clipboard",
00274 $this->ctrl->getLinkTarget($this, "clipboard"), "clipboard", get_class($this));
00275 }
00276
00277 }
00278
00279
00280 function initCourseContentInterface()
00281 {
00282 include_once "./course/classes/class.ilCourseContentInterface.php";
00283
00284 $this->cci_obj =& new ilCourseContentInterface($this,$this->object->getRefId());
00285
00286
00287 #aggregate($this,"ilCourseContentInterface");
00288 #$this->cci_init($this,$this->object->getRefId());
00289 }
00290
00291 function cciEditObject()
00292 {
00293 global $rbacsystem;
00294
00295
00296 if(!$rbacsystem->checkAccess("write", $this->ref_id))
00297 {
00298 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
00299 }
00300
00301 $this->ctrl->setParameter($this, "item_id", $_GET["item_id"]);
00302 $this->__setSubTabs('activation');
00303 $this->tabs_gui->setTabActive('view_content');
00304
00305 $this->initCourseContentInterface();
00306 $this->cci_obj->cci_setContainer($this);
00307 $this->cci_obj->cci_edit();
00308
00309 return true;;
00310 }
00311
00312 function cciUpdateObject()
00313 {
00314 global $rbacsystem;
00315
00316
00317 if(!$rbacsystem->checkAccess("write", $this->ref_id))
00318 {
00319 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
00320 }
00321
00322 $this->initCourseContentInterface();
00323 $this->cci_obj->cci_setContainer($this);
00324 $this->cci_obj->cci_update();
00325
00326 return true;;
00327 }
00328 function cciMoveObject()
00329 {
00330 global $rbacsystem;
00331
00332
00333 if(!$rbacsystem->checkAccess("write", $this->ref_id))
00334 {
00335 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
00336 }
00337
00338 $this->initCourseContentInterface();
00339 $this->cci_obj->cci_setContainer($this);
00340 $this->cci_obj->cci_move();
00341
00342 return true;;
00343 }
00344
00345 function initConditionHandlerGUI($item_id)
00346 {
00347 include_once './classes/class.ilConditionHandlerInterface.php';
00348
00349 if(!is_object($this->chi_obj))
00350 {
00351 if($_GET['item_id'])
00352 {
00353 $this->chi_obj =& new ilConditionHandlerInterface($this,$item_id);
00354 $this->ctrl->saveParameter($this,'item_id',$_GET['item_id']);
00355 }
00356 else
00357 {
00358 $this->chi_obj =& new ilConditionHandlerInterface($this);
00359 }
00360 }
00361 return true;
00362 }
00363
00364 function chi_updateObject()
00365 {
00366 $this->initConditionHandlerGUI($_GET['item_id'] ? $_GET['item_id'] : $this->object->getRefId());
00367 $this->chi_obj->chi_update();
00368
00369 if($_GET['item_id'])
00370 {
00371 $this->cciEditObject();
00372 }
00373 else
00374 {
00375 $this->editObject();
00376 }
00377 }
00378 function chi_deleteObject()
00379 {
00380 $this->initConditionHandlerGUI($_GET['item_id'] ? $_GET['item_id'] : $this->object->getRefId());
00381 $this->chi_obj->chi_delete();
00382
00383 if($_GET['item_id'])
00384 {
00385 $this->cciEditObject();
00386 }
00387 else
00388 {
00389 $this->editObject();
00390 }
00391 }
00392
00393 function chi_selectorObject()
00394 {
00395 $this->initConditionHandlerGUI($_GET['item_id'] ? $_GET['item_id'] : $this->object->getRefId());
00396 $this->chi_obj->chi_selector();
00397 }
00398
00399 function chi_assignObject()
00400 {
00401 $this->initConditionHandlerGUI($_GET['item_id'] ? $_GET['item_id'] : $this->object->getRefId());
00402 $this->chi_obj->chi_assign();
00403
00404 if($_GET['item_id'])
00405 {
00406 $this->cciEditObject();
00407 }
00408 else
00409 {
00410 $this->editObject();
00411 }
00412 }
00413
00414
00418 function __setSubTabs($a_tab)
00419 {
00420 global $rbacsystem,$ilUser;
00421
00422 switch ($a_tab)
00423 {
00424
00425 case "activation":
00426 $this->tabs_gui->addSubTabTarget("activation",
00427 $this->ctrl->getLinkTarget($this,'cciEdit'),
00428 "cciEdit", get_class($this));
00429 $this->tabs_gui->addSubTabTarget("preconditions",
00430 $this->ctrl->getLinkTargetByClass('ilConditionHandlerInterface','listConditions'),
00431 "", "ilConditionHandlerInterface");
00432 break;
00433 }
00434 }
00435
00436 }
00437 ?>