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