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