/**
  * Determines whether files can be uploaded to the object with the specified reference id.
  * 
  * @param int $a_ref_id The reference id to check.
  * @param string $a_type The type of the object to check.
  * @return bool true, if file upload is allowed; otherwise, false.
  */
 public static function isUploadAllowed($a_ref_id, $a_type = "")
 {
     global $objDefinition, $ilAccess;
     if (self::isUploadSupported()) {
         include_once "./Services/FileUpload/classes/class.ilFileUploadSettings.php";
         // repository upload enabled?
         if (ilFileUploadSettings::isDragAndDropUploadEnabled() && ilFileUploadSettings::isRepositoryDragAndDropUploadEnabled()) {
             if ($a_type == "") {
                 $a_type = ilObject::_lookupType($a_ref_id, true);
             }
             if ($objDefinition->isContainer($a_type)) {
                 return $ilAccess->checkAccess("create_file", "", $a_ref_id, "file");
             }
         }
     }
     return false;
 }
 /**
  * Gets the instance of the ilFileUploadSettings.
  * @return ilFileUploadSettings
  */
 private static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new ilFileUploadSettings();
     }
     return self::$instance;
 }
Example #3
0
 protected function initCreationForms()
 {
     $forms = array();
     if ($this->id_type == self::WORKSPACE_NODE_ID) {
         include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
         if (!ilDiskQuotaHandler::isUploadPossible()) {
             $this->lng->loadLanguageModule("file");
             ilUtil::sendFailure($this->lng->txt("personal_workspace_quota_exceeded_warning"), true);
             $this->ctrl->redirect($this, "cancel");
         }
     }
     // use drag-and-drop upload if configured
     require_once "Services/FileUpload/classes/class.ilFileUploadSettings.php";
     if (ilFileUploadSettings::isDragAndDropUploadEnabled()) {
         $forms[] = $this->initMultiUploadForm();
     } else {
         $forms[] = $this->initSingleUploadForm();
         $forms[] = $this->initZipUploadForm();
     }
     // repository only
     if ($this->id_type != self::WORKSPACE_NODE_ID) {
         $forms[self::CFORM_IMPORT] = $this->initImportForm('file');
         $forms[self::CFORM_CLONE] = $this->fillCloneTemplate(null, "file");
     }
     return $forms;
 }
 /**
  * Save upload settings
  */
 public function saveUploadSettings()
 {
     global $rbacsystem, $ilErr, $ilCtrl, $lng, $tpl, $ilSetting;
     if (!$rbacsystem->checkAccess("write", $this->object->getRefId())) {
         $ilErr->raiseError($lng->txt("no_permission"), $ilErr->WARNING);
     }
     // get form
     $form = $this->initUploadSettingsForm();
     if ($form->checkInput()) {
         require_once "Services/FileUpload/classes/class.ilFileUploadSettings.php";
         ilFileUploadSettings::setDragAndDropUploadEnabled($_POST["enable_dnd_upload"] == 1);
         ilFileUploadSettings::setRepositoryDragAndDropUploadEnabled($_POST["enable_repository_dnd_upload"] == 1);
         ilFileUploadSettings::setConcurrentUploads($_POST["concurrent_uploads"]);
         // file suffic replacements
         $ilSetting->set("suffix_repl_additional", $_POST["suffix_repl_additional"]);
         ilUtil::sendSuccess($lng->txt('settings_saved'), true);
         $ilCtrl->redirect($this, "editUploadSettings");
     } else {
         $form->setValuesByPost();
         $tpl->setContent($form->getHTML());
     }
 }
 /**
  * Gets the code that is shared by all upload instances.
  * 
  * @return string The shared code by all upload instances.
  */
 protected function getSharedHtml()
 {
     global $lng;
     // already loaded?
     if (self::$shared_code_loaded) {
         return "";
     }
     // make sure required scripts are loaded
     self::initFileUpload();
     // load script template
     $tpl_shared = new ilTemplate("tpl.fileupload_shared.html", true, true, "Services/FileUpload");
     // initialize localized texts
     $lng->loadLanguageModule("form");
     $tpl_shared->setCurrentBlock("fileupload_texts");
     $tpl_shared->setVariable("ERROR_MSG_FILE_TOO_LARGE", $lng->txt("form_msg_file_size_exceeds"));
     $tpl_shared->setVariable("ERROR_MSG_WRONG_FILE_TYPE", $lng->txt("form_msg_file_wrong_file_type"));
     $tpl_shared->setVariable("ERROR_MSG_EMPTY_FILE_OR_FOLDER", $lng->txt("error_empty_file_or_folder"));
     $tpl_shared->setVariable("ERROR_MSG_UPLOAD_ZERO_BYTES", $lng->txt("error_upload_was_zero_bytes"));
     $tpl_shared->setVariable("QUESTION_CANCEL_ALL", $lng->txt("cancel_file_upload"));
     $tpl_shared->setVariable("ERROR_MSG_EXTRACT_FAILED", $lng->txt("error_extraction_failed"));
     $tpl_shared->setVariable("PROGRESS_UPLOADING", $lng->txt("uploading"));
     $tpl_shared->setVariable("PROGRESS_EXTRACTING", $lng->txt("extracting"));
     $tpl_shared->setVariable("DROP_FILES_HERE", $lng->txt("drop_files_on_repo_obj_info"));
     $tpl_shared->parseCurrentBlock();
     // initialize default values
     $tpl_shared->setCurrentBlock("fileupload_defaults");
     $tpl_shared->setVariable("CONCURRENT_UPLOADS", ilFileUploadSettings::getConcurrentUploads());
     $tpl_shared->setVariable("MAX_FILE_SIZE", ilFileUploadUtil::getMaxFileSize());
     $tpl_shared->setVariable("ALLOWED_SUFFIXES", "");
     $tpl_shared->setVariable("SUPPORTED_ARCHIVES", "\"zip\"");
     $tpl_shared->parseCurrentBlock();
     // load panel template
     $tpl_panel = new ilTemplate("tpl.fileupload_panel_template.html", true, true, "Services/FileUpload");
     $tpl_panel->setVariable("TXT_HEADER", $lng->txt("upload_files_title"));
     $tpl_panel->setVariable("TXT_SHOW_ALL_DETAILS", $lng->txt('show_all_details'));
     $tpl_panel->setVariable("TXT_HIDE_ALL_DETAILS", $lng->txt('hide_all_details'));
     $tpl_shared->setCurrentBlock("fileupload_panel_tmpl");
     $tpl_shared->setVariable("PANEL_TEMPLATE_HTML", $tpl_panel->get());
     $tpl_shared->parseCurrentBlock();
     // load row template
     $tpl_row = new ilTemplate("tpl.fileupload_row_template.html", true, true, "Services/FileUpload");
     $tpl_row->setVariable("IMG_ALERT", ilUtil::getImagePath("icon_alert_s.gif"));
     $tpl_row->setVariable("ALT_ALERT", $lng->txt("alert"));
     $tpl_row->setVariable("TXT_CANCEL", $lng->txt("cancel"));
     $tpl_row->setVariable("TXT_REMOVE", $lng->txt("remove"));
     $tpl_row->setVariable("TXT_TITLE", $lng->txt("title"));
     $tpl_row->setVariable("TXT_DESCRIPTION", $lng->txt("description"));
     $tpl_row->setVariable("TXT_EXTRACT", $lng->txt("unzip"));
     $tpl_row->setVariable("TXT_KEEP_STRUCTURE", $lng->txt("take_over_structure"));
     $tpl_row->setVariable("TXT_KEEP_STRUCTURE_INFO", $lng->txt("take_over_structure_info"));
     $tpl_row->setVariable("TXT_PENDING", $lng->txt("upload_pending"));
     $tpl_shared->setCurrentBlock("fileupload_row_tmpl");
     $tpl_shared->setVariable("ROW_TEMPLATE_HTML", $tpl_row->get());
     $tpl_shared->parseCurrentBlock();
     // shared code now loaded
     self::$shared_code_loaded = true;
     // create HTML
     return $tpl_shared->get();
 }