4 require_once 
"./classes/class.ilObjectGUI.php";
 
    5 require_once 
"./Modules/File/classes/class.ilObjFile.php";
 
    6 require_once 
"./Modules/File/classes/class.ilObjFileAccess.php";
 
   25         function ilObjFileGUI($a_data,$a_id,$a_call_by_reference = 
true, $a_prepare_output = 
true)
 
   28                 $this->
ilObjectGUI($a_data,$a_id,$a_call_by_reference, 
false);
 
   29                 $this->lng->loadLanguageModule(
'file');
 
   39                 global $ilAccess, $ilNavigationHistory, 
$ilCtrl, $ilUser, $ilTabs;
 
   43                         $ilAccess->checkAccess(
"read", 
"", 
$_GET[
"ref_id"]))
 
   45                         $ilNavigationHistory->addItem(
$_GET[
"ref_id"],
 
   46                                 "repository.php?cmd=infoScreen&ref_id=".
$_GET[
"ref_id"], 
"file");
 
   49                 $next_class = $this->ctrl->getNextClass($this);
 
   50                 $cmd = $this->ctrl->getCmd();
 
   54                         if(IS_PAYMENT_ENABLED)
 
   56                                 include_once 
'Services/Payment/classes/class.ilPaymentObject.php';
 
   57                                 if(ANONYMOUS_USER_ID == $ilUser->getId()  && isset(
$_GET[
'transaction']))
 
   59                                         $transaction = 
$_GET[
'transaction'];
 
   60                                         include_once 
'./Services/Payment/classes/class.ilPaymentBookings.php';
 
   69                                         $this->tpl->getStandardTemplate();
 
   71                                         include_once 
'Services/Payment/classes/class.ilShopPurchaseGUI.php';
 
   73                                         $ret = $this->ctrl->forwardCommand($pp);
 
   83                         case "ilinfoscreengui":
 
   88                                 $ilTabs->activateTab(
"id_meta");
 
   90                                 include_once 
'Services/MetaData/classes/class.ilMDEditorGUI.php';
 
   92                                 $md_gui =& 
new ilMDEditorGUI($this->object->getId(), 0, $this->
object->getType());
 
   93                                 $md_gui->
addObserver($this->
object,
'MDUpdateListener',
'General');
 
   96                                 $md_gui->addObserver($this->
object,
'MDUpdateListener',
'Technical');
 
   98                                 $this->ctrl->forwardCommand($md_gui);
 
  101                         case 'ilpermissiongui':
 
  102                                 $ilTabs->activateTab(
"id_permissions");
 
  103                                 include_once(
"Services/AccessControl/classes/class.ilPermissionGUI.php");
 
  105                                 $ret =& $this->ctrl->forwardCommand($perm_gui);
 
  109                                 $ilTabs->activateTab(
"export");
 
  110                                 include_once(
"./Services/Export/classes/class.ilExportGUI.php");
 
  112                                 $exp_gui->addFormat(
"xml");
 
  113                                 $ret = $this->ctrl->forwardCommand($exp_gui);
 
  116                         case 'ilobjectcopygui':
 
  117                                 include_once 
'./Services/Object/classes/class.ilObjectCopyGUI.php';
 
  119                                 $cp->setType(
'file');
 
  120                                 $this->ctrl->forwardCommand($cp);
 
  149                 if (!$rbacsystem->checkAccess(
"create", 
$_GET[
"ref_id"], $new_type))
 
  151                         $this->ilErr->raiseError($this->lng->txt(
"permission_denied"),$this->ilErr->MESSAGE);
 
  157                 if ($a_reload_form != 
"single_upload")
 
  161                 $this->tpl->setVariable(
"SINGLE_UPLOAD_FORM", $this->single_form_gui->getHtml());
 
  163                 if ($a_reload_form != 
"zip_upload")
 
  168                 $this->tpl->setVariable(
"ZIP_UPLOAD_FORM", $this->zip_form_gui->getHtml());
 
  170                 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
 
  171                 $this->tpl->setVariable(
"TXT_TAKE_OVER_STRUCTURE", $this->lng->txt(
"take_over_structure"));
 
  172                 $this->tpl->setVariable(
"TXT_HEADER_ZIP", $this->lng->txt(
"header_zip"));
 
  179                         $this->tpl->setVariable(
"IMPORT", $this->form->getHTML());
 
  192                 $lng->loadLanguageModule(
"file");
 
  194                 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
 
  196                 $this->form->setTarget(
"_top");
 
  199                 include_once(
"./Services/Form/classes/class.ilFileInputGUI.php");
 
  202                 $fi->setRequired(
true);
 
  203                 $this->form->addItem($fi);
 
  205                 $this->form->addCommandButton(
"importFile", $lng->txt(
"import"));
 
  206                 $this->form->addCommandButton(
"cancel", $lng->txt(
"cancel"));
 
  207                 $this->form->setTitle($lng->txt($a_new_type.
"_import"));
 
  209                 $this->form->setFormAction($ilCtrl->getFormAction($this));
 
  224                 if (!$rbacsystem->checkAccess(
"create", 
$_GET[
"ref_id"], $new_type))
 
  226                         $this->ilias->raiseError($this->lng->txt(
"no_create_permission"), $this->ilias->error_obj->MESSAGE);
 
  228                 $this->ctrl->setParameter($this, 
"new_type", $new_type);
 
  230                 if ($this->form->checkInput())
 
  233                         include_once(
"./Services/Export/classes/class.ilImport.php");
 
  235                         $new_id = $imp->importObject($newObj, $_FILES[
"importfile"][
"tmp_name"],
 
  236                                 $_FILES[
"importfile"][
"name"], $new_type);
 
  241                                 $newObj->createReference();
 
  242                                 $newObj->putInTree($_GET[
"ref_id"]);
 
  243                                 $newObj->setPermissions($_GET[
"ref_id"]);
 
  246                                 $this->ctrl->returnToParent($this);
 
  251                 $this->form->setValuesByPost();
 
  252                 $tpl->setContent($this->form->getHtml());
 
  264                 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
 
  266                 $this->single_form_gui->setMultipart(
true);
 
  270                 $in_title->
setInfo($this->lng->txt(
"if_no_title_then_filename"));
 
  271                 $in_title->setMaxLength(128);
 
  272                 $in_title->setSize(40);
 
  273                 $this->single_form_gui->addItem($in_title);
 
  277                 $this->single_form_gui->addItem($in_descr);
 
  282                 $this->single_form_gui->addItem($in_file);
 
  285                 if ($a_mode == 
"create")
 
  287                         $this->single_form_gui->addCommandButton(
"save", $this->lng->txt($this->type.
"_add"));
 
  288                         $this->single_form_gui->addCommandButton(
"saveAndMeta", $this->lng->txt(
"file_add_and_metadata"));
 
  289                         $this->single_form_gui->addCommandButton(
"cancel", $lng->txt(
"cancel"));
 
  297                 $this->single_form_gui->setTableWidth(
"600px");
 
  299                 $this->single_form_gui->setTitle($this->lng->txt($this->type.
"_new"));
 
  300                 $this->single_form_gui->setTitleIcon(
ilUtil::getImagePath(
'icon_file.gif'), $this->lng->txt(
'obj_file'));
 
  302                 if ($a_mode == 
"create")
 
  304                         $this->ctrl->setParameter($this, 
"new_type", 
"file");
 
  306                 $this->single_form_gui->setFormAction($this->ctrl->getFormAction($this, 
"save"));
 
  318                 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
 
  320                 $this->zip_form_gui->setMultipart(
true);
 
  325                 $in_file->setSuffixes(array(
"zip"));
 
  326                 $this->zip_form_gui->addItem($in_file);
 
  329                 $in_str = 
new ilCheckboxInputGUI($this->lng->txt(
"take_over_structure"), 
"adopt_structure");
 
  330                 $in_str->
setInfo($this->lng->txt(
"take_over_structure_info"));
 
  331                 $this->zip_form_gui->addItem($in_str);
 
  334                 if ($a_mode == 
"create")
 
  336                         $this->zip_form_gui->addCommandButton(
"saveUnzip", $this->lng->txt($this->type.
"_add"));
 
  337                         $this->zip_form_gui->addCommandButton(
"cancel", $lng->txt(
"cancel"));
 
  345                 $this->zip_form_gui->setTableWidth(
"600px");
 
  347                 $this->zip_form_gui->setTitle($this->lng->txt(
"header_zip"));
 
  348                 $this->zip_form_gui->setTitleIcon(
ilUtil::getImagePath(
'icon_file.gif'), $this->lng->txt(
'obj_file'));
 
  350                 if ($a_mode == 
"create")
 
  352                         $this->ctrl->setParameter($this, 
"new_type", 
"file");
 
  354                 $this->zip_form_gui->setFormAction($this->ctrl->getFormAction($this, 
"saveUnzip"));
 
  368                 if ($rbacsystem->checkAccess(
"create", 
$_GET[
"ref_id"], 
"file")) {
 
  369                         if ($this->zip_form_gui->checkInput())
 
  371                                 $zip_file = $this->zip_form_gui->getInput(
"zip_file");
 
  372                                 $adopt_structure = $this->zip_form_gui->getInput(
"adopt_structure");
 
  374                                 include_once (
"Services/Utilities/classes/class.ilFileUtils.php");
 
  382                                 if($type == 
'cat' or $type == 
'root')
 
  384                                         $permission = $rbacsystem->checkAccess(
"create", $_GET[
"ref_id"], 
"cat");
 
  385                                         $containerType = 
"Category";
 
  388                                         $permission = $rbacsystem->checkAccess(
"create", $_GET[
"ref_id"], 
"fold");
 
  389                                         $containerType = 
"Folder";                      
 
  402                                                 $zip_file[
"tmp_name"],
 
  403                                                 ($adopt_structure && $permission),
 
  415                                 $this->ctrl->returnToParent($this);
 
  419                                 $this->zip_form_gui->setValuesByPost();
 
  425                         $this->ilErr->raiseError($this->lng->txt(
"permission_denied"),$this->ilErr->MESSAGE);
 
  440                 if ($this->single_form_gui->checkInput())
 
  442                         $title = $this->single_form_gui->getInput(
"title");
 
  443                         $description = $this->single_form_gui->getInput(
"description");
 
  444                         $upload_file = $this->single_form_gui->getInput(
"upload_file");
 
  448                                 $title = $upload_file[
"name"];
 
  455                                 if ($titleExtension != $fileExtension && strlen($fileExtension) > 0)
 
  457                                         $title .= 
'.'.$fileExtension;
 
  463                         include_once(
"./Modules/File/classes/class.ilObjFile.php");
 
  465                         $fileObj->setTitle(
$title);
 
  466                         $fileObj->setDescription($description);
 
  467                         $fileObj->setFileName($upload_file[
"name"]);
 
  469                         include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
 
  471                                 "", $upload_file[
"name"], $upload_file[
"type"]));
 
  472                         $fileObj->setFileSize($upload_file[
"size"]);
 
  474                         $fileObj->createReference();
 
  475                         $fileObj->putInTree(
$_GET[
"ref_id"]);
 
  476                         $fileObj->setPermissions(
$_GET[
"ref_id"]);
 
  478                         $fileObj->createDirectory();
 
  479                         $fileObj->getUploadFile($upload_file[
"tmp_name"],
 
  480                                 $upload_file[
"name"]);
 
  483                         require_once(
'Services/Tracking/classes/class.ilChangeEvent.php');
 
  491                         $this->ctrl->setParameter($this, 
"ref_id", $fileObj->getRefId());
 
  492                         if ($this->ctrl->getCmd() == 
"saveAndMeta")
 
  494                                 $target = $this->ctrl->getLinkTargetByClass(array(
"ilobjfilegui", 
"ilmdeditorgui"), 
"listSection", 
"", 
false, 
false);
 
  495                                 $target = str_replace(
"new_type=", 
"nt=", $target);
 
  500                                 $this->ctrl->returnToParent($this);
 
  505                         $this->single_form_gui->setValuesByPost();
 
  529                 $ilTabs->activateTab(
"id_edit");
 
  532                 if(!$this->form->checkInput())
 
  534                         $this->form->setValuesByPost();
 
  535                         $this->tpl->setContent($this->form->getHTML());
 
  539                 $data = $this->form->getInput(
'file');          
 
  542                 while (substr(
$data[
"name"],-1) == 
'/')
 
  548                 $title = $this->form->getInput(
'title');
 
  549                 if(strlen(trim(
$title)) == 0)
 
  557                 $this->
object->setTitle(
$title);
 
  559                 if (!empty(
$data[
"name"]))
 
  561                         switch($this->form->getInput(
'replace'))
 
  564                                         $this->
object->deleteVersions();
 
  565                                         $this->
object->clearDataDirectory();
 
  566                                         $this->
object->replaceFile(
$data[
'tmp_name'],
$data[
'name']);
 
  569                                         $this->
object->addFileVersion(
$data[
'tmp_name'],
$data[
'name']);
 
  572                         $this->
object->setFileName(
$data[
'name']);
 
  573                         include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
 
  576                         $this->
object->setFileSize(
$data[
'size']);
 
  578                 $this->
object->setDescription($this->form->getInput(
'description'));
 
  579                 $this->update = $this->
object->update();
 
  582                 if (!empty(
$data[
"name"]))
 
  584                         require_once(
'Services/Tracking/classes/class.ilChangeEvent.php');
 
  606                 global $ilAccess, $ilTabs;
 
  608                 if (!$ilAccess->checkAccess(
"write", 
"", $this->ref_id))
 
  610                         $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
 
  613                 $ilTabs->activateTab(
"id_edit");
 
  618                 $this->tpl->setContent($this->form->getHTML());
 
  637                 $this->tpl->setVariable(
"TXT_TITLE", $this->lng->txt(
"title"));
 
  638                 $this->tpl->setVariable(
"TITLE", $fields[
"title"]);
 
  639                 $this->tpl->setVariable(
"TXT_DESC", $this->lng->txt(
"desc"));
 
  640                 $this->tpl->setVariable(
"DESC", $fields[
"desc"]);
 
  641                 $this->tpl->setVariable(
"TXT_REPLACE_FILE", $this->lng->txt(
"replace_file"));
 
  644                 $obj_str = ($this->call_by_reference) ? 
"" : 
"&obj_id=".$this->obj_id;
 
  646                 $this->tpl->setVariable(
"FORMACTION", $this->
getFormAction(
"update",$this->ctrl->getFormAction($this, 
"update").$obj_str));
 
  647                 $this->tpl->setVariable(
"TXT_HEADER", $this->lng->txt($this->object->getType().
"_edit"));
 
  648                 $this->tpl->setVariable(
"TARGET", $this->
getTargetFrame(
"update"));
 
  649                 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
 
  650                 $this->tpl->setVariable(
"TXT_SUBMIT", $this->lng->txt(
"save"));
 
  651                 $this->tpl->setVariable(
"CMD_SUBMIT", 
"update");
 
  652                 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
 
  658                 if($a_mode == 
'edit')
 
  660                         $val[
'title'] = $this->
object->getTitle();
 
  661                         $val[
'description'] = $this->
object->getLongDescription();
 
  662                         $this->form->setValuesByArray($val);
 
  676                 include_once(
'./Services/Form/classes/class.ilPropertyFormGUI.php');
 
  679                 $this->form->setFormAction($this->ctrl->getFormAction($this),
'update');
 
  680                 $this->form->setTitle($this->lng->txt(
'file_edit'));
 
  681                 $this->form->addCommandButton(
'update',$this->lng->txt(
'save'));
 
  682                 $this->form->addCommandButton(
'cancel',$this->lng->txt(
'cancel'));
 
  685                 $title->setValue($this->object->getTitle());
 
  686                 $title->setInfo($lng->txt(
"if_no_title_then_filename"));
 
  687                 $this->form->addItem(
$title);
 
  690                 $file->setRequired(
false);
 
  692                 $this->form->addItem(
$file);
 
  697                         $replace = 
new ilRadioOption($this->lng->txt(
'replace_file'),1);
 
  698                         $replace->
setInfo($this->lng->txt(
'replace_file_info'));
 
  699                         $group->addOption($replace);
 
  702                         $keep = 
new ilRadioOption($this->lng->txt(
'file_new_version'),0);
 
  703                         $keep->
setInfo($this->lng->txt(
'file_new_version_info'));
 
  704                         $group->addOption($keep);
 
  706                 $file->addSubItem($group);
 
  711                 $this->form->addItem($desc);
 
  716                 global $ilAccess, $ilUser, 
$ilCtrl;
 
  718                 if(ANONYMOUS_USER_ID == $ilUser->getId() && isset(
$_GET[
'transaction']) )
 
  720                         $this->
object->sendFile(
$_GET[
"hist_id"]);
 
  723                 if ($ilAccess->checkAccess(
"read", 
"", $this->ref_id))
 
  726                         require_once(
'Services/Tracking/classes/class.ilChangeEvent.php');
 
  732                                         $this->
object->getId(), $ilUser->getId());
 
  736                         $this->
object->sendFile(
$_GET[
"hist_id"]);
 
  740                         $this->ilErr->raiseError($this->lng->txt(
"permission_denied"),$this->ilErr->MESSAGE);
 
  753                 global $ilAccess, $ilTabs;
 
  755                 $ilTabs->activateTab(
"id_versions");
 
  757                 if (!$ilAccess->checkAccess(
"write", 
"", 
$_GET[
"ref_id"]))
 
  759                         $this->ilErr->raiseError($this->lng->txt(
"permission_denied"),$this->ilErr->MESSAGE);
 
  762                 require_once(
"classes/class.ilHistoryGUI.php");
 
  769                         array(
"ref_id" => 
$_GET[
"ref_id"], 
"cmd" => 
"versions",
 
  770                         "cmdClass" =>
$_GET[
"cmdClass"], 
"cmdNode" =>
$_GET[
"cmdNode"]));
 
  772                 $this->tpl->setVariable(
"ADM_CONTENT", $hist_html);
 
  782                 $this->ctrl->setCmd(
"showSummary");
 
  783                 $this->ctrl->setCmdClass(
"ilinfoscreengui");
 
  792                 global $ilAccess, $ilTabs;
 
  794                 $ilTabs->activateTab(
"id_info");
 
  796                 if (!$ilAccess->checkAccess(
"visible", 
"", $this->ref_id))
 
  798                         $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
 
  801                 include_once(
"./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
 
  804                 if ($ilAccess->checkAccess(
"read", 
"sendfile", $this->ref_id))
 
  806                         $info->addButton($this->lng->txt(
"file_read"), $this->ctrl->getLinkTarget($this, 
"sendfile"));
 
  809                 $info->enablePrivateNotes();
 
  811                 if ($ilAccess->checkAccess(
"read", 
"", 
$_GET[
"ref_id"]))
 
  817                 $info->enableNewsEditing(
false);
 
  818                 if ($ilAccess->checkAccess(
"write", 
"", 
$_GET[
"ref_id"]))
 
  821                         $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
 
  823                         if ($enable_internal_rss)
 
  825                                 $info->setBlockProperty(
"news", 
"settings", 
true);
 
  826                                 $info->setBlockProperty(
"news", 
"public_notifications_option", 
true);
 
  832                 $info->addMetaDataSections($this->object->getId(),0, $this->
object->getType());
 
  834                 $info->addSection($this->lng->txt(
"file_info"));
 
  835                 $info->addProperty($this->lng->txt(
"filename"),
 
  836                         $this->
object->getFileName());
 
  838                 $info->addProperty($this->lng->txt(
"type"),
 
  839                                 $this->
object->guessFileType());
 
  841                 $info->addProperty($this->lng->txt(
"size"),
 
  843                 $info->addProperty($this->lng->txt(
"version"),
 
  844                         $this->
object->getVersion());
 
  847                 $this->ctrl->forwardCommand($info);
 
  854                 global $ilAccess, $ilTabs, 
$lng;
 
  856                 $this->ctrl->setParameter($this,
"ref_id",$this->ref_id);
 
  858                 if ($ilAccess->checkAccess(
"visible", 
"", $this->ref_id))
 
  860                         $ilTabs->addTab(
"id_info",
 
  861                                 $lng->txt(
"info_short"),
 
  862                                 $this->ctrl->getLinkTargetByClass(array(
"ilobjfilegui", 
"ilinfoscreengui"), 
"showSummary"));
 
  865                 if ($ilAccess->checkAccess(
"write", 
"", $this->ref_id))
 
  867                         $ilTabs->addTab(
"id_edit",
 
  869                                 $this->ctrl->getLinkTarget($this, 
"edit"));
 
  872                 if ($ilAccess->checkAccess(
"write", 
"", $this->ref_id))
 
  874                         $ilTabs->addTab(
"id_versions",
 
  875                                 $lng->txt(
"versions"),
 
  876                                 $this->ctrl->getLinkTarget($this, 
"versions"));
 
  880                 if ($ilAccess->checkAccess(
"write", 
"", $this->ref_id))
 
  882                         $ilTabs->addTab(
"id_meta",
 
  883                                 $lng->txt(
"meta_data"),
 
  884                                 $this->ctrl->getLinkTargetByClass(array(
'ilobjfilegui',
'ilmdeditorgui'),
'listSection'));
 
  888                 if ($ilAccess->checkAccess(
"write", 
"", $this->object->getRefId()))
 
  890                         $ilTabs->addTab(
"export",
 
  892                                 $this->ctrl->getLinkTargetByClass(
"ilexportgui", 
""));
 
  895                 if ($ilAccess->checkAccess(
"edit_permission", 
"", $this->ref_id))
 
  897                                 $ilTabs->addTab(
"id_permissions",
 
  898                                 $lng->txt(
"perm_settings"),
 
  899                                 $this->ctrl->getLinkTargetByClass(array(get_class($this),
'ilpermissiongui'), 
"perm"));
 
  907                 if ($ilAccess->checkAccess(
"visible", 
"", $a_target))
 
  909                         $_GET[
"cmd"] = 
"infoScreen";
 
  910                         $_GET[
"ref_id"] = $a_target;
 
  911                         include(
"repository.php");
 
  914                 else if ($ilAccess->checkAccess(
"read", 
"", ROOT_FOLDER_ID))
 
  916                         $_GET[
"cmd"] = 
"frameset";
 
  917                         $_GET[
"target"] = 
"";
 
  918                         $_GET[
"ref_id"] = ROOT_FOLDER_ID;
 
  921                         include(
"repository.php");
 
  925                 $ilErr->raiseError($lng->txt(
"msg_no_perm_read"), $ilErr->FATAL);
 
  936                 if (is_object($this->
object))
 
  938                         $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, 
""), 
"", 
$_GET[
"ref_id"]);