/** * Determines whether the specified preview object is supported by the renderer. * * @param ilPreview $preview The preview object to check. * @return bool true, if the renderer supports the specified preview object; otherwise, false. */ public function supports($preview) { // let parent check first if (!parent::supports($preview)) { return false; } // get file extension require_once "./Modules/File/classes/class.ilObjFile.php"; include_once './Modules/File/classes/class.ilObjFileAccess.php'; $filename = ilObjFile::_lookupFileName($preview->getObjId()); $ext = ilObjFileAccess::_getFileExtension($filename); // contains that extension? return in_array($ext, $this->getSupportedFileFormats()); }
/** * lookup size */ function _lookupFileSize($a_id) { global $ilDB; $q = "SELECT * FROM file_data WHERE file_id = " . $ilDB->quote($a_id); $r = $ilDB->query($q); $row = $r->fetchRow(DB_FETCHMODE_OBJECT); include_once 'Services/Migration/DBUpdate_904/classes/class.ilFSStorageFile.php'; $fss = new ilFSStorageFile($a_id); $file = $fss->getAbsolutePath() . '/' . $row->file_name; if (@(!is_file($file))) { $version_subdir = "/" . sprintf("%03d", ilObjFileAccess::_lookupVersion($a_id)); $file = $fss->getAbsolutePath() . '/' . $version_subdir . '/' . $row->file_name; } if (is_file($file)) { $size = filesize($file); } else { $size = 0; } return $size; }
/** * Appends the text " - Copy" to a filename in the language of * the current user. * * If the provided $nth_copy parameter is greater than 1, then * is appended in round brackets. If $nth_copy parameter is null, then * the function determines the copy number on its own. * * If this function detects, that the filename already ends with " - Copy", * or with "- Copy ($nth_copy), it only appends the number of the copy to * the filename. * * This function retains the extension of the filename. * * Examples: * - Calling ilObjFileAccess::_appendCopyToTitle('Hello.txt', 1) * returns: "Hello - Copy.txt". * * - Calling ilObjFileAccess::_appendCopyToTitle('Hello.txt', 2) * returns: "Hello - Copy (2).txt". * * - Calling ilObjFileAccess::_appendCopyToTitle('Hello - Copy (3).txt', 2) * returns: "Hello - Copy (2).txt". * * - Calling ilObjFileAccess::_appendCopyToTitle('Hello - Copy (3).txt', null) * returns: "Hello - Copy (4).txt". */ public static function _appendNumberOfCopyToFilename($a_file_name, $nth_copy = null) { global $lng; // Get the extension and the filename without the extension $extension = ilObjFileAccess::_getFileExtension($a_file_name); if (strlen($extension) > 0) { $extension = '.' . $extension; $filenameWithoutExtension = substr($a_file_name, 0, -strlen($extension)); } else { $filenameWithoutExtension = $a_file_name; } // create a regular expression from the language text copy_n_of_suffix, so that // we can match it against $filenameWithoutExtension, and retrieve the number of the copy. // for example, if copy_n_of_suffix is 'Copy (%1s)', this creates the regular // expression '/ Copy \\([0-9]+)\\)$/'. $nthCopyRegex = preg_replace('/([\\^$.\\[\\]|()?*+{}])/', '\\\\${1}', ' ' . $lng->txt('copy_n_of_suffix')); $nthCopyRegex = '/' . preg_replace('/%1\\\\\\$s/', '([0-9]+)', $nthCopyRegex) . '$/'; // Get the filename without any previously added number of copy. // Determine the number of copy, if it has not been specified. if (preg_match($nthCopyRegex, $filenameWithoutExtension, $matches)) { // this is going to be at least the third copy of the filename $filenameWithoutCopy = substr($filenameWithoutExtension, 0, -strlen($matches[0])); if ($nth_copy == null) { $nth_copy = $matches[1] + 1; } } else { if (substr($filenameWithoutExtension, -strlen(' ' . $lng->txt('copy_of_suffix'))) == ' ' . $lng->txt('copy_of_suffix')) { // this is going to be the second copy of the filename $filenameWithoutCopy = substr($filenameWithoutExtension, 0, -strlen(' ' . $lng->txt('copy_of_suffix'))); if ($nth_copy == null) { $nth_copy = 2; } } else { // this is going to be the first copy of the filename $filenameWithoutCopy = $filenameWithoutExtension; if ($nth_copy == null) { $nth_copy = 1; } } } // Construct the new filename if ($nth_copy > 1) { // this is at least the second copy of the filename, append " - Copy ($nth_copy)" $newFilename = $filenameWithoutCopy . sprintf(' ' . $lng->txt('copy_n_of_suffix'), $nth_copy) . $extension; } else { // this is the first copy of the filename, append " - Copy" $newFilename = $filenameWithoutCopy . ' ' . $lng->txt('copy_of_suffix') . $extension; } return $newFilename; }
/** * Prepend Copy info if object with same name exists in that container * * @access public * @param int copy_id * */ public function appendCopyInfo($a_target_id, $a_copy_id) { global $tree; include_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php'; $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id); if (!$cp_options->isRootNode($this->getRefId())) { return $this->getTitle(); } $nodes = $tree->getChilds($a_target_id); $title_unique = false; require_once 'Modules/File/classes/class.ilObjFileAccess.php'; $numberOfCopy = 1; $title = ilObjFileAccess::_appendNumberOfCopyToFilename($this->getTitle(), $numberOfCopy); while (!$title_unique) { $found = 0; foreach ($nodes as $node) { if ($title == $node['title'] and $this->getType() == $node['type']) { $found++; } } if ($found > 0) { $title = ilObjFileAccess::_appendNumberOfCopyToFilename($this->getTitle(), ++$numberOfCopy); } else { break; } } return $title; }
/** * Handles the upload of a single file and adds it to the parent object. * * @param array $file_upload An array containing the file upload parameters. * @return object The response object. */ protected function handleFileUpload($file_upload) { global $ilUser; // file upload params $filename = $file_upload["name"]; $type = $file_upload["type"]; $size = $file_upload["size"]; $temp_name = $file_upload["tmp_name"]; // additional params $title = $file_upload["title"]; $description = $file_upload["description"]; $extract = $file_upload["extract"]; $keep_structure = $file_upload["keep_structure"]; // create answer object $response = new stdClass(); $response->fileName = $filename; $response->fileSize = intval($size); $response->fileType = $type; $response->fileUnzipped = $extract; $response->error = null; // extract archive? if ($extract) { $zip_file = $filename; $adopt_structure = $keep_structure; include_once "Services/Utilities/classes/class.ilFileUtils.php"; // Create unzip-directory $newDir = ilUtil::ilTempnam(); ilUtil::makeDir($newDir); // Check if permission is granted for creation of object, if necessary if ($this->id_type != self::WORKSPACE_NODE_ID) { $type = ilObject::_lookupType((int) $this->parent_id, true); } else { $type = ilObject::_lookupType($this->tree->lookupObjectId($this->parent_id), false); } $tree = $access_handler = null; switch ($type) { // workspace structure case 'wfld': case 'wsrt': $permission = $this->checkPermissionBool("create", "", "wfld"); $containerType = "WorkspaceFolder"; $tree = $this->tree; $access_handler = $this->getAccessHandler(); break; // use categories as structure // use categories as structure case 'cat': case 'root': $permission = $this->checkPermissionBool("create", "", "cat"); $containerType = "Category"; break; // use folders as structure (in courses) // use folders as structure (in courses) default: $permission = $this->checkPermissionBool("create", "", "fold"); $containerType = "Folder"; break; } try { // processZipFile ( // Dir to unzip, // Path to uploaded file, // should a structure be created (+ permission check)? // ref_id of parent // object that contains files (folder or category) // should sendInfo be persistent?) ilFileUtils::processZipFile($newDir, $temp_name, $adopt_structure && $permission, $this->parent_id, $containerType, $tree, $access_handler); } catch (ilFileUtilsException $e) { $response->error = $e->getMessage(); } catch (Exception $ex) { $response->error = $ex->getMessage(); } ilUtil::delDir($newDir); // #15404 if ($this->id_type != self::WORKSPACE_NODE_ID) { foreach (ilFileUtils::getNewObjects() as $parent_ref_id => $objects) { if ($parent_ref_id != $this->parent_id) { continue; } foreach ($objects as $object) { $this->after_creation_callback_objects[] = $object; } } } } else { if (trim($title) == "") { $title = $filename; } else { // BEGIN WebDAV: Ensure that object title ends with the filename extension $fileExtension = ilObjFileAccess::_getFileExtension($filename); $titleExtension = ilObjFileAccess::_getFileExtension($title); if ($titleExtension != $fileExtension && strlen($fileExtension) > 0) { $title .= '.' . $fileExtension; } // END WebDAV: Ensure that object title ends with the filename extension } // create and insert file in grp_tree include_once "./Modules/File/classes/class.ilObjFile.php"; $fileObj = new ilObjFile(); $fileObj->setTitle($title); $fileObj->setDescription($description); $fileObj->setFileName($filename); include_once "./Services/Utilities/classes/class.ilMimeTypeUtil.php"; $fileObj->setFileType(ilMimeTypeUtil::getMimeType("", $filename, $type)); $fileObj->setFileSize($size); $this->object_id = $fileObj->create(); $this->putObjectInTree($fileObj, $this->parent_id); // see uploadFiles() if (is_array($this->after_creation_callback_objects)) { $this->after_creation_callback_objects[] = $fileObj; } // upload file to filesystem $fileObj->createDirectory(); $fileObj->raiseUploadError(false); $fileObj->getUploadFile($temp_name, $filename); $this->handleAutoRating($fileObj); // BEGIN ChangeEvent: Record write event. require_once './Services/Tracking/classes/class.ilChangeEvent.php'; ilChangeEvent::_recordWriteEvent($fileObj->getId(), $ilUser->getId(), 'create'); // END ChangeEvent: Record write event. } return $response; }
/** * parse tree * @param object $a_source * @return */ public function parseContainer($a_source) { global $tree, $objDefinition, $ilAccess; $first = true; foreach ($tree->getSubTree($root = $tree->getNodeData($a_source)) as $node) { if ($node['type'] == 'rolf') { continue; } if (!$objDefinition->allowExport($node['type'])) { #continue; } include_once "./Modules/File/classes/class.ilObjFileAccess.php"; if ($node['type'] == "file" && ilObjFileAccess::_isFileHidden($node['title'])) { continue; } $r = array(); if ($last = ilExportFileInfo::lookupLastExport($node['obj_id'], 'xml')) { $r['last_export'] = $last->getCreationDate()->get(IL_CAL_UNIX); } else { $r['last_export'] = 0; } $r['last'] = false; $r['source'] = $first; $r['ref_id'] = $node['child']; $r['depth'] = $node['depth'] - $root['depth']; $r['type'] = $node['type']; $r['title'] = $node['title']; $r['export'] = $objDefinition->allowExport($node['type']); $r['perm_export'] = $ilAccess->checkAccess('write', '', $node['child']); $rows[] = $r; $first = false; } $rows[] = array('last' => true); $this->setData((array) $rows); }
/** * Get assignable items * * @param * @return */ function getAssignableItems() { if ($this->getItemGroupRefId() <= 0) { return array(); } $parent_node = $this->tree->getNodeData($this->tree->getParentId($this->getItemGroupRefId())); $materials = array(); $nodes = $this->tree->getChilds($parent_node["child"]); include_once "./Modules/File/classes/class.ilObjFileAccess.php"; foreach ($nodes as $node) { // filter side blocks and session, item groups and role folder if ($node['child'] == $parent_node["child"] || $this->obj_def->isSideBlock($node['type']) || in_array($node['type'], array('sess', 'itgr', 'rolf', 'adm'))) { continue; } // filter hidden files // see http://www.ilias.de/mantis/view.php?id=10269 if ($node['type'] == "file" && ilObjFileAccess::_isFileHidden($node['title'])) { continue; } $materials[] = $node; } $materials = ilUtil::sortArray($materials, "title", "asc"); return $materials; }
/** * Add a content from ILIAS to the Adobe Connect server * * @return string cmd */ public function addContentFromILIAS() { require_once 'Modules/File/classes/class.ilFSStorageFile.php'; require_once 'Modules/File/classes/class.ilObjFileAccess.php'; if (!(int) $_POST['file_id']) { ilUtil::sendInfo($this->txt('content_select_one')); return $this->showFileSearchResult($_SESSION['contents']['search_result']); } /** @noinspection PhpUndefinedClassInspection */ $fss = new ilFSStorageFile((int) $_POST['file_id']); /** @noinspection PhpUndefinedClassInspection */ $version_subdir = '/' . sprintf("%03d", ilObjFileAccess::_lookupVersion($_POST['file_id'])); include_once './Modules/File/classes/class.ilObjFile.php'; $file_name = ilObjFile::_lookupFileName((int) $_POST['file_id']); $object_title = ilObject::_lookupTitle((int) $_POST['file_id']); $file = $fss->getAbsolutePath() . $version_subdir . '/' . $file_name; $this->pluginObj->includeClass('class.ilAdobeConnectDuplicateContentException.php'); try { $curl = curl_init($this->object->addContent($object_title, '')); curl_setopt($curl, CURLOPT_VERBOSE, true); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); #curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURL_UPLOAD, true); curl_setopt($curl, CURLOPT_POSTFIELDS, array('name' => $object_title, 'file' => '@' . $file)); $postResult = curl_exec($curl); curl_close($curl); unset($_SESSION['contents']['search_result']); ilUtil::sendSuccess($this->txt('virtualClassroom_content_added')); return $this->showContent(); } catch (ilAdobeConnectDuplicateContentException $e) { ilUtil::sendFailure($this->txt($e->getMessage())); return $this->showFileSearchResult($_SESSION['contents']['search_result']); } }
public function performPasteIntoMultipleObjectsObject() { global $rbacsystem, $rbacadmin, $rbacreview, $log, $tree, $ilObjDataCache, $ilUser; $command = $_SESSION['clipboard']['cmd']; if (!in_array($command, array('cut', 'link', 'copy'))) { $message = __METHOD__ . ": cmd was neither 'cut', 'link' nor 'copy'; may be a hack attempt!"; $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING); } if ($command == 'cut') { if (isset($_POST['node']) && (int) $_POST['node']) { $_POST['nodes'] = array($_POST['node']); } } if (!is_array($_POST['nodes']) || !count($_POST['nodes'])) { ilUtil::sendFailure($this->lng->txt('select_at_least_one_object')); switch ($command) { case 'cut': $this->showPasteTreeObject(); break; case 'copy': $this->showPasteTreeObject(); break; case 'link': $this->showPasteTreeObject(); break; } return; } // this loop does all checks $folder_objects_cache = array(); foreach ($_SESSION['clipboard']['ref_ids'] as $ref_id) { $obj_data = ilObjectFactory::getInstanceByRefId($ref_id); $current_parent_id = $tree->getParentId($obj_data->getRefId()); foreach ($_POST['nodes'] as $folder_ref_id) { if (!array_key_exists($folder_ref_id, $folder_objects_cache)) { $folder_objects_cache[$folder_ref_id] = ilObjectFactory::getInstanceByRefId($folder_ref_id); } // CHECK ACCESS if (!$rbacsystem->checkAccess('create', $folder_ref_id, $obj_data->getType())) { $no_paste[] = sprintf($this->lng->txt('msg_no_perm_paste_object_in_folder'), $obj_data->getTitle() . ' [' . $obj_data->getRefId() . ']', $folder_objects_cache[$folder_ref_id]->getTitle() . ' [' . $folder_objects_cache[$folder_ref_id]->getRefId() . ']'); } // CHECK IF REFERENCE ALREADY EXISTS if ($folder_ref_id == $current_parent_id) { $exists[] = sprintf($this->lng->txt('msg_obj_exists_in_folder'), $obj_data->getTitle() . ' [' . $obj_data->getRefId() . ']', $folder_objects_cache[$folder_ref_id]->getTitle() . ' [' . $folder_objects_cache[$folder_ref_id]->getRefId() . ']'); } // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF if ($tree->isGrandChild($ref_id, $folder_ref_id) || $ref_id == $folder_ref_id) { $is_child[] = sprintf($this->lng->txt('msg_paste_object_not_in_itself'), $obj_data->getTitle() . ' [' . $obj_data->getRefId() . ']'); } // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT if (!in_array($obj_data->getType(), array_keys($this->objDefinition->getSubObjects($folder_objects_cache[$folder_ref_id]->getType())))) { $not_allowed_subobject[] = sprintf($this->lng->txt('msg_obj_may_not_contain_objects_of_type'), $folder_objects_cache[$folder_ref_id]->getTitle() . ' [' . $folder_objects_cache[$folder_ref_id]->getRefId() . ']', $GLOBALS['lng']->txt('obj_' . $obj_data->getType())); } } } //////////////////////////// // process checking results if (count($exists) && $command != "copy") { $error .= implode('<br />', $exists); } if (count($is_child)) { $error .= $error != '' ? '<br />' : ''; $error .= implode('<br />', $is_child); } if (count($not_allowed_subobject)) { $error .= $error != '' ? '<br />' : ''; $error .= implode('<br />', $not_allowed_subobject); } if (count($no_paste)) { $error .= $error != '' ? '<br />' : ''; $error .= implode('<br />', $no_paste); } if ($error != '') { ilUtil::sendFailure($error); switch ($command) { case 'cut': $this->showPasteTreeObject(); break; case 'copy': $this->showPasteTreeObject(); break; case 'link': $this->showPasteTreeObject(); break; } return; } // log pasteObject call $log->write(__METHOD__ . ", cmd: " . $command); //////////////////////////////////////////////////////// // everything ok: now paste the objects to new location // to prevent multiple actions via back/reload button $ref_ids = $_SESSION['clipboard']['ref_ids']; unset($_SESSION['clipboard']['ref_ids']); // BEGIN ChangeEvent: Record paste event. require_once 'Services/Tracking/classes/class.ilChangeEvent.php'; // END ChangeEvent: Record paste event. // process COPY command if ($command == 'copy') { foreach ($_POST['nodes'] as $folder_ref_id) { foreach ($ref_ids as $ref_id) { $revIdMapping = array(); $oldNode_data = $tree->getNodeData($ref_id); if ($oldNode_data['parent'] == $folder_ref_id) { require_once 'Modules/File/classes/class.ilObjFileAccess.php'; $newTitle = ilObjFileAccess::_appendNumberOfCopyToFilename($oldNode_data['title'], null); $newRef = $this->cloneNodes($ref_id, $folder_ref_id, $refIdMapping, $newTitle); } else { $newRef = $this->cloneNodes($ref_id, $folder_ref_id, $refIdMapping, null); } // BEGIN ChangeEvent: Record copy event. $old_parent_data = $tree->getParentNodeData($ref_id); $newNode_data = $tree->getNodeData($newRef); ilChangeEvent::_recordReadEvent($oldNode_data['type'], $ref_id, $oldNode_data['obj_id'], $ilUser->getId()); ilChangeEvent::_recordWriteEvent($newNode_data['obj_id'], $ilUser->getId(), 'add', $ilObjDataCache->lookupObjId($folder_ref_id)); ilChangeEvent::_catchupWriteEvents($newNode_data['obj_id'], $ilUser->getId()); // END PATCH ChangeEvent: Record cut event. } } ilUtil::sendSuccess($this->lng->txt('msg_cloned'), true); } // END COPY // process CUT command if ($command == 'cut') { foreach ($_POST['nodes'] as $folder_ref_id) { foreach ($ref_ids as $ref_id) { // Store old parent $old_parent = $tree->getParentId($ref_id); $tree->moveTree($ref_id, $folder_ref_id); $rbacadmin->adjustMovedObjectPermissions($ref_id, $old_parent); include_once './Services/AccessControl/classes/class.ilConditionHandler.php'; ilConditionHandler::_adjustMovedObjectConditions($ref_id); // BEGIN ChangeEvent: Record cut event. $node_data = $tree->getNodeData($ref_id); $old_parent_data = $tree->getNodeData($old_parent); ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'remove', $old_parent_data['obj_id']); ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add', $ilObjDataCache->lookupObjId($folder_ref_id)); ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId()); // END PATCH ChangeEvent: Record cut event. } // prevent multiple iterations for cut cmommand break; } ilUtil::sendSuccess($this->lng->txt('msg_cut_copied'), true); } // END CUT // process LINK command if ($command == 'link') { $linked_to_folders = array(); include_once "Services/AccessControl/classes/class.ilRbacLog.php"; $rbac_log_active = ilRbacLog::isActive(); foreach ($_POST['nodes'] as $folder_ref_id) { $linked_to_folders[] = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($folder_ref_id)); foreach ($ref_ids as $ref_id) { // get node data $top_node = $tree->getNodeData($ref_id); // get subnodes of top nodes $subnodes[$ref_id] = $tree->getSubtree($top_node); } // now move all subtrees to new location foreach ($subnodes as $key => $subnode) { // first paste top_node.... $obj_data = ilObjectFactory::getInstanceByRefId($key); $new_ref_id = $obj_data->createReference(); $obj_data->putInTree($folder_ref_id); $obj_data->setPermissions($folder_ref_id); // rbac log if ($rbac_log_active) { $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id, false); $rbac_log = ilRbacLog::gatherFaPa($new_ref_id, array_keys($rbac_log_roles), true); ilRbacLog::add(ilRbacLog::LINK_OBJECT, $new_ref_id, $rbac_log, $key); } // BEGIN ChangeEvent: Record link event. $node_data = $tree->getNodeData($new_ref_id); ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add', $ilObjDataCache->lookupObjId($folder_ref_id)); ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId()); // END PATCH ChangeEvent: Record link event. } $log->write(__METHOD__ . ', link finished'); } ilUtil::sendSuccess(sprintf($this->lng->txt('mgs_objects_linked_to_the_following_folders'), implode(', ', $linked_to_folders)), true); } // END LINK // clear clipboard $this->clearObject(); $this->ctrl->returnToParent($this); }
/** * Append object properties * @param ilObject $obj */ public function __appendObjectProperties(ilObject $obj) { switch ($obj->getType()) { case 'file': include_once './Modules/File/classes/class.ilObjFileAccess.php'; $size = ilObjFileAccess::_lookupFileSize($obj->getId()); $extension = ilObjFileAccess::_lookupSuffix($obj->getId()); $this->xmlStartTag('Properties'); $this->xmlElement("Property", array('name' => 'fileSize'), (int) $size); $this->xmlElement("Property", array('name' => 'fileExtension'), (string) $extension); // begin-patch fm $this->xmlElement('Property', array('name' => 'fileVersion'), (string) ilObjFileAccess::_lookupVersion($obj->getId())); // end-patch fm $this->xmlEndTag('Properties'); break; } }
public function _preloadData($a_obj_ids, $a_ref_ids) { global $ilDB; self::$preload_list_gui_data = array(); $set = $ilDB->query("SELECT obj_id,max(hdate) latest" . " FROM history" . " WHERE obj_type = " . $ilDB->quote("file", "text") . " AND " . $ilDB->in("obj_id", $a_obj_ids, "", "integer") . " GROUP BY obj_id"); while ($row = $ilDB->fetchAssoc($set)) { self::$preload_list_gui_data[$row["obj_id"]]["date"] = $row["latest"]; } $set = $ilDB->query("SELECT file_size,version,file_id" . " FROM file_data" . " WHERE " . $ilDB->in("file_id", $a_obj_ids, "", "integer")); while ($row = $ilDB->fetchAssoc($set)) { self::$preload_list_gui_data[$row["file_id"]]["size"] = $row["file_size"]; self::$preload_list_gui_data[$row["file_id"]]["version"] = $row["version"]; } }
/** * Get subitems of container * * @param bool administration panel enabled * @param bool side blocks enabled * * @return array */ function getSubItems($a_admin_panel_enabled = false, $a_include_side_block = false, $a_get_single = 0) { global $objDefinition, $ilBench, $tree, $ilObjDataCache, $ilUser, $rbacsystem, $ilSetting; // Caching if (is_array($this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]) && !$a_get_single) { return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]; } $type_grps = $this->getGroupedObjTypes(); $objects = $tree->getChilds($this->getRefId(), "title"); // using long descriptions? $short_desc = $ilSetting->get("rep_shorten_description"); $short_desc_max_length = $ilSetting->get("rep_shorten_description_length"); if (!$short_desc || $short_desc_max_length != ilObject::TITLE_LENGTH) { // using (part of) shortened description if ($short_desc && $short_desc_max_length && $short_desc_max_length < ilObject::TITLE_LENGTH) { foreach ($objects as $key => $object) { $objects[$key]["description"] = ilUtil::shortenText($object["description"], $short_desc_max_length, true); } } else { $obj_ids = array(); foreach ($objects as $key => $object) { $obj_ids[] = $object["obj_id"]; } if (sizeof($obj_ids)) { $long_desc = ilObject::getLongDescriptions($obj_ids); foreach ($objects as $key => $object) { if ($short_desc && $short_desc_max_length) { $long_desc[$object["obj_id"]] = ilUtil::shortenText($long_desc[$object["obj_id"]], $short_desc_max_length, true); } $objects[$key]["description"] = $long_desc[$object["obj_id"]]; } } } } $found = false; $all_obj_types = array(); $all_ref_ids = array(); $all_obj_ids = array(); include_once 'Services/Container/classes/class.ilContainerSorting.php'; $sort = ilContainerSorting::_getInstance($this->getId()); // TODO: check this // get items attached to a session include_once './Modules/Session/classes/class.ilEventItems.php'; $event_items = ilEventItems::_getItemsOfContainer($this->getRefId()); foreach ($objects as $key => $object) { if ($a_get_single > 0 && $object["child"] != $a_get_single) { continue; } // hide object types in devmode if ($objDefinition->getDevMode($object["type"]) || $object["type"] == "adm" || $object["type"] == "rolf") { continue; } // remove inactive plugins if ($objDefinition->isInactivePlugin($object["type"])) { continue; } // BEGIN WebDAV: Don't display hidden Files, Folders and Categories if (in_array($object['type'], array('file', 'fold', 'cat'))) { include_once 'Modules/File/classes/class.ilObjFileAccess.php'; if (ilObjFileAccess::_isFileHidden($object['title'])) { $this->setHiddenFilesFound(true); if (!$a_admin_panel_enabled) { continue; } } } // END WebDAV: Don't display hidden Files, Folders and Categories // filter out items that are attached to an event if (in_array($object['ref_id'], $event_items)) { continue; } // filter side block items if (!$a_include_side_block && $objDefinition->isSideBlock($object['type'])) { continue; } $all_obj_types[$object["type"]] = $object["type"]; $obj_ids_of_type[$object["type"]][] = $object["obj_id"]; $ref_ids_of_type[$object["type"]][] = $object["child"]; $all_ref_ids[] = $object["child"]; $all_obj_ids[] = $object["obj_id"]; } // data preloader if (!self::$data_preloaded && sizeof($all_ref_ids)) { // type specific preloads foreach ($all_obj_types as $t) { // condition handler: preload conditions include_once "./Services/AccessControl/classes/class.ilConditionHandler.php"; ilConditionHandler::preloadConditionsForTargetRecords($t, $obj_ids_of_type[$t]); $class = $objDefinition->getClassName($t); $location = $objDefinition->getLocation($t); $full_class = "ilObj" . $class . "Access"; include_once $location . "/class." . $full_class . ".php"; call_user_func(array($full_class, "_preloadData"), $obj_ids_of_type[$t], $ref_ids_of_type[$t]); } // general preloads $tree->preloadDeleted($all_ref_ids); $tree->preloadDepthParent($all_ref_ids); $ilObjDataCache->preloadReferenceCache($all_ref_ids, false); ilObjUser::preloadIsDesktopItem($ilUser->getId(), $all_ref_ids); $rbacsystem->preloadRbacPaCache($all_ref_ids, $ilUser->getId()); include_once "./Services/Object/classes/class.ilObjectListGUI.php"; ilObjectListGUI::preloadCommonProperties($all_obj_ids); include_once "./Services/Object/classes/class.ilObjectActivation.php"; ilObjectActivation::preloadData($all_ref_ids); self::$data_preloaded = true; } foreach ($objects as $key => $object) { // see above, objects were filtered if (!in_array($object["child"], $all_ref_ids)) { continue; } // group object type groups together (e.g. learning resources) $type = $objDefinition->getGroupOfObj($object["type"]); if ($type == "") { $type = $object["type"]; } // this will add activation properties (ilObjActivation) $this->addAdditionalSubItemInformation($object); $this->items[$type][$key] = $object; $this->items["_all"][$key] = $object; if ($object["type"] != "sess") { $this->items["_non_sess"][$key] = $object; } } $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block] = $sort->sortItems($this->items); return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]; }
/** * Get subitems of container * * @param bool administration panel enabled * @param bool side blocks enabled * * @return array */ function getSubItems($a_admin_panel_enabled = false, $a_include_side_block = false, $a_get_single = 0) { global $objDefinition, $ilBench, $tree, $ilObjDataCache, $ilUser, $rbacsystem, $ilSetting; // Caching if (is_array($this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]) && !$a_get_single) { return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]; } $type_grps = $this->getGroupedObjTypes(); $objects = $tree->getChilds($this->getRefId(), "title"); // using long descriptions? $short_desc = $ilSetting->get("rep_shorten_description"); $short_desc_max_length = $ilSetting->get("rep_shorten_description_length"); if (!$short_desc || $short_desc_max_length != ilObject::TITLE_LENGTH) { // using (part of) shortened description if ($short_desc && $short_desc_max_length && $short_desc_max_length < ilObject::TITLE_LENGTH) { foreach ($objects as $key => $object) { $objects[$key]["description"] = ilUtil::shortenText($object["description"], $short_desc_max_length, true); } } else { $obj_ids = array(); foreach ($objects as $key => $object) { $obj_ids[] = $object["obj_id"]; } if (sizeof($obj_ids)) { $long_desc = ilObject::getLongDescriptions($obj_ids); foreach ($objects as $key => $object) { // #12166 - keep translation, ignore long description if ($ilObjDataCache->isTranslatedDescription($object["obj_id"])) { $long_desc[$object["obj_id"]] = $object["description"]; } if ($short_desc && $short_desc_max_length) { $long_desc[$object["obj_id"]] = ilUtil::shortenText($long_desc[$object["obj_id"]], $short_desc_max_length, true); } $objects[$key]["description"] = $long_desc[$object["obj_id"]]; } } } } $found = false; $all_ref_ids = array(); if (!self::$data_preloaded) { include_once "./Services/Object/classes/class.ilObjectListGUIPreloader.php"; $preloader = new ilObjectListGUIPreloader(ilObjectListGUI::CONTEXT_REPOSITORY); } include_once 'Services/Container/classes/class.ilContainerSorting.php'; $sort = ilContainerSorting::_getInstance($this->getId()); // TODO: check this // get items attached to a session include_once './Modules/Session/classes/class.ilEventItems.php'; $event_items = ilEventItems::_getItemsOfContainer($this->getRefId()); foreach ($objects as $key => $object) { if ($a_get_single > 0 && $object["child"] != $a_get_single) { continue; } // hide object types in devmode if ($objDefinition->getDevMode($object["type"]) || $object["type"] == "adm" || $object["type"] == "rolf") { continue; } // remove inactive plugins if ($objDefinition->isInactivePlugin($object["type"])) { continue; } // BEGIN WebDAV: Don't display hidden Files, Folders and Categories if (in_array($object['type'], array('file', 'fold', 'cat'))) { include_once 'Modules/File/classes/class.ilObjFileAccess.php'; if (ilObjFileAccess::_isFileHidden($object['title'])) { $this->setHiddenFilesFound(true); if (!$a_admin_panel_enabled) { continue; } } } // END WebDAV: Don't display hidden Files, Folders and Categories // including event items! if (!self::$data_preloaded) { $preloader->addItem($object["obj_id"], $object["type"], $object["child"]); } // filter out items that are attached to an event if (in_array($object['ref_id'], $event_items)) { continue; } // filter side block items if (!$a_include_side_block && $objDefinition->isSideBlock($object['type'])) { continue; } $all_ref_ids[] = $object["child"]; } // data preloader if (!self::$data_preloaded) { $preloader->preload(); unset($preloader); self::$data_preloaded = true; } foreach ($objects as $key => $object) { // see above, objects were filtered if (!in_array($object["child"], $all_ref_ids)) { continue; } // group object type groups together (e.g. learning resources) $type = $objDefinition->getGroupOfObj($object["type"]); if ($type == "") { $type = $object["type"]; } // this will add activation properties $this->addAdditionalSubItemInformation($object); $this->items[$type][$key] = $object; $this->items["_all"][$key] = $object; if ($object["type"] != "sess") { $this->items["_non_sess"][$key] = $object; } } $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block] = $sort->sortItems($this->items); return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]; }
/** * Get all item information (title, commands, description) in HTML * * @access public * @param int $a_ref_id item reference id * @param int $a_obj_id item object id * @param int $a_title item title * @param int $a_description item description * @param bool $a_use_asynch * @param bool $a_get_asynch_commands * @param string $a_asynch_url * @param bool $a_context workspace/tree context * @return string html code */ function getListItemHTML($a_ref_id, $a_obj_id, $a_title, $a_description, $a_use_asynch = false, $a_get_asynch_commands = false, $a_asynch_url = "", $a_context = self::CONTEXT_REPOSITORY) { global $ilAccess, $ilBench, $ilUser, $ilCtrl; // this variable stores wheter any admin commands // are included in the output $this->adm_commands_included = false; // only for permformance exploration $type = ilObject::_lookupType($a_obj_id); // initialization $ilBench->start("ilObjectListGUI", "1000_getListHTML_init{$type}"); $this->initItem($a_ref_id, $a_obj_id, $a_title, $a_description, $a_context); $ilBench->stop("ilObjectListGUI", "1000_getListHTML_init{$type}"); // prepare ajax calls include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php"; if ($a_context == self::CONTEXT_REPOSITORY) { $node_type = ilCommonActionDispatcherGUI::TYPE_REPOSITORY; } else { $node_type = ilCommonActionDispatcherGUI::TYPE_WORKSPACE; } $this->setAjaxHash(ilCommonActionDispatcherGUI::buildAjaxHash($node_type, $a_ref_id, $type, $a_obj_id)); if ($a_use_asynch && $a_get_asynch_commands) { return $this->insertCommands(true, true); } if ($this->rating_enabled) { if (ilRating::hasRatingInListGUI($this->obj_id, $this->type)) { $may_rate = $this->checkCommandAccess("read", "", $this->ref_id, $this->type); $rating = new ilRatingGUI(); $rating->setObject($this->obj_id, $this->type); /* $this->addCustomProperty( $this->lng->txt("rating_average_rating"), $rating->getListGUIProperty($this->ref_id, $may_rate, $this->ajax_hash, $this->parent_ref_id), false, true );*/ $this->addCustomProperty("", $rating->getListGUIProperty($this->ref_id, $may_rate, $this->ajax_hash, $this->parent_ref_id), false, true); } } // read from cache include_once "Services/Object/classes/class.ilListItemAccessCache.php"; $this->acache = new ilListItemAccessCache(); $cres = $this->acache->getEntry($ilUser->getId() . ":" . $a_ref_id); if ($this->acache->getLastAccessStatus() == "hit") { $this->access_cache = unserialize($cres); } else { // write to cache $this->storeAccessCache(); } // visible check if (!$this->checkCommandAccess("visible", "", $a_ref_id, "", $a_obj_id)) { $ilBench->stop("ilObjectListGUI", "2000_getListHTML_check_visible"); $this->resetCustomData(); return ""; } // BEGIN WEBDAV if ($type == 'file' and ilObjFileAccess::_isFileHidden($a_title)) { $this->resetCustomData(); return ""; } // END WEBDAV $this->tpl = new ilTemplate("tpl.container_list_item.html", true, true, "Services/Container", "DEFAULT", false, true); if ($this->getCommandsStatus() || $this->payment_enabled && IS_PAYMENT_ENABLED) { if (!$this->getSeparateCommands()) { $this->tpl->setVariable("COMMAND_SELECTION_LIST", $this->insertCommands($a_use_asynch, $a_get_asynch_commands, $a_asynch_url)); } } if ($this->getProgressInfoStatus()) { $this->insertProgressInfo(); } // insert title and describtion $this->insertTitle(); if (!$this->isMode(IL_LIST_AS_TRIGGER)) { if ($this->getDescriptionStatus()) { $this->insertDescription(); } } if ($this->getSearchFragmentStatus()) { $this->insertSearchFragment(); } if ($this->enabledRelevance()) { $this->insertRelevance(); } // properties $ilBench->start("ilObjectListGUI", "6000_insert_properties{$type}"); if ($this->getPropertiesStatus()) { $this->insertProperties(); } $ilBench->stop("ilObjectListGUI", "6000_insert_properties{$type}"); // notice properties $ilBench->start("ilObjectListGUI", "6500_insert_notice_properties{$type}"); if ($this->getNoticePropertiesStatus()) { $this->insertNoticeProperties(); } $ilBench->stop("ilObjectListGUI", "6500_insert_notice_properties{$type}"); // preconditions $ilBench->start("ilObjectListGUI", "7000_insert_preconditions"); if ($this->getPreconditionsStatus()) { $this->insertPreconditions(); } $ilBench->stop("ilObjectListGUI", "7000_insert_preconditions"); // path $ilBench->start("ilObjectListGUI", "8000_insert_path"); $this->insertPath(); $ilBench->stop("ilObjectListGUI", "8000_insert_path"); $ilBench->start("ilObjectListGUI", "8500_item_detail_links"); if ($this->getItemDetailLinkStatus()) { $this->insertItemDetailLinks(); } $ilBench->stop("ilObjectListGUI", "8500_item_detail_links"); // icons and checkboxes $this->insertIconsAndCheckboxes(); // input field for position $this->insertPositionField(); // subitems $this->insertSubItems(); // file upload if ($this->isFileUploadAllowed()) { $this->insertFileUpload(); } $this->resetCustomData(); $this->tpl->setVariable("DIV_CLASS", 'ilContainerListItemOuter'); $this->tpl->setVariable("DIV_ID", 'id = "' . $this->getUniqueItemId(true) . '"'); $this->tpl->setVariable("ADDITIONAL", $this->getAdditionalInformation()); // #11554 - make sure that internal ids are reset $this->ctrl->setParameter($this->getContainerObject(), "item_ref_id", ""); return $this->tpl->get(); }
/** * paste object from clipboard to current place * Depending on the chosen command the object(s) are linked, copied or moved * * @access public */ function pasteObject() { global $rbacsystem, $rbacadmin, $rbacreview, $log, $tree; global $ilUser, $lng; // BEGIN ChangeEvent: Record paste event. require_once 'Services/Tracking/classes/class.ilChangeEvent.php'; // END ChangeEvent: Record paste event. //var_dump($_SESSION["clipboard"]);exit; if (!in_array($_SESSION["clipboard"]["cmd"], array("cut", "link", "copy"))) { $message = get_class($this) . "::pasteObject(): cmd was neither 'cut','link' or 'copy'; may be a hack attempt!"; $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING); } // this loop does all checks foreach ($_SESSION["clipboard"]["ref_ids"] as $ref_id) { $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($ref_id); // CHECK ACCESS if (!$rbacsystem->checkAccess('create', $this->object->getRefId(), $obj_data->getType())) { $no_paste[] = $ref_id; $no_paste_titles[] = $obj_data->getTitle(); } // CHECK IF REFERENCE ALREADY EXISTS if ($this->object->getRefId() == $this->tree->getParentId($obj_data->getRefId())) { $exists[] = $ref_id; break; } // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF if ($this->tree->isGrandChild($ref_id, $this->object->getRefId())) { $is_child[] = $ref_id; } // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT $obj_type = $obj_data->getType(); if (!in_array($obj_type, array_keys($this->objDefinition->getSubObjects($this->object->getType())))) { $not_allowed_subobject[] = $obj_data->getType(); } } //////////////////////////// // process checking results // BEGIN WebDAV: Copying an object into the same container is allowed if (count($exists) && $_SESSION["clipboard"]["cmd"] != "copy") { $this->ilias->raiseError($this->lng->txt("msg_obj_exists"), $this->ilias->error_obj->MESSAGE); } if (count($is_child)) { $this->ilias->raiseError($this->lng->txt("msg_not_in_itself") . " " . implode(',', $is_child), $this->ilias->error_obj->MESSAGE); } if (count($not_allowed_subobject)) { $this->ilias->raiseError($this->lng->txt("msg_may_not_contain") . " " . implode(',', $not_allowed_subobject), $this->ilias->error_obj->MESSAGE); } if (count($no_paste)) { $this->ilias->raiseError($this->lng->txt("msg_no_perm_paste") . " " . implode(',', $no_paste), $this->ilias->error_obj->MESSAGE); } // log pasteObject call $log->write("ilObjectGUI::pasteObject(), cmd: " . $_SESSION["clipboard"]["cmd"]); //////////////////////////////////////////////////////// // everything ok: now paste the objects to new location // to prevent multiple actions via back/reload button $ref_ids = $_SESSION["clipboard"]["ref_ids"]; unset($_SESSION["clipboard"]["ref_ids"]); // BEGIN WebDAV: Support a copy command in the repository // process COPY command if ($_SESSION["clipboard"]["cmd"] == "copy") { foreach ($ref_ids as $ref_id) { $revIdMapping = array(); $oldNode_data = $tree->getNodeData($ref_id); if ($oldNode_data['parent'] == $this->object->getRefId()) { require_once 'Modules/File/classes/class.ilObjFileAccess.php'; $newTitle = ilObjFileAccess::_appendNumberOfCopyToFilename($oldNode_data['title'], null); $newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, $newTitle); } else { $newRef = $this->cloneNodes($ref_id, $this->object->getRefId(), $refIdMapping, null); } // BEGIN ChangeEvent: Record copy event. $old_parent_data = $tree->getParentNodeData($ref_id); $newNode_data = $tree->getNodeData($newRef); ilChangeEvent::_recordReadEvent($oldNode_data['type'], $ref_id, $oldNode_data['obj_id'], $ilUser->getId()); ilChangeEvent::_recordWriteEvent($newNode_data['obj_id'], $ilUser->getId(), 'add', $this->object->getId()); ilChangeEvent::_catchupWriteEvents($newNode_data['obj_id'], $ilUser->getId()); // END ChangeEvent: Record copy event. } $log->write("ilObjectGUI::pasteObject(), copy finished"); } // END WebDAV: Support a Copy command in the repository // process CUT command if ($_SESSION["clipboard"]["cmd"] == "cut") { foreach ($ref_ids as $ref_id) { // Store old parent $old_parent = $tree->getParentId($ref_id); $this->tree->moveTree($ref_id, $this->object->getRefId()); $rbacadmin->adjustMovedObjectPermissions($ref_id, $old_parent); include_once './Services/AccessControl/classes/class.ilConditionHandler.php'; ilConditionHandler::_adjustMovedObjectConditions($ref_id); // BEGIN ChangeEvent: Record cut event. $node_data = $tree->getNodeData($ref_id); $old_parent_data = $tree->getNodeData($old_parent); ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'remove', $old_parent_data['obj_id']); ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add', $this->object->getId()); ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId()); // END PATCH ChangeEvent: Record cut event. } } // END CUT // process LINK command if ($_SESSION["clipboard"]["cmd"] == "link") { foreach ($ref_ids as $ref_id) { // get node data $top_node = $this->tree->getNodeData($ref_id); // get subnodes of top nodes $subnodes[$ref_id] = $this->tree->getSubtree($top_node); } // now move all subtrees to new location foreach ($subnodes as $key => $subnode) { // first paste top_node.... $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($key); $new_ref_id = $obj_data->createReference(); $obj_data->putInTree($_GET["ref_id"]); $obj_data->setPermissions($_GET["ref_id"]); // BEGIN ChangeEvent: Record link event. $node_data = $tree->getNodeData($new_ref_id); ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'add', $this->object->getId()); ilChangeEvent::_catchupWriteEvents($node_data['obj_id'], $ilUser->getId()); // END PATCH ChangeEvent: Record link event. } $log->write("ilObjectGUI::pasteObject(), link finished"); // inform other objects in hierarchy about link operation //$this->object->notify("link",$this->object->getRefId(),$_SESSION["clipboard"]["parent_non_rbac_id"],$this->object->getRefId(),$subnodes); } // END LINK // save cmd for correct message output after clearing the clipboard $last_cmd = $_SESSION["clipboard"]["cmd"]; // clear clipboard $this->clearObject(); if ($last_cmd == "cut") { ilUtil::sendSuccess($this->lng->txt("msg_cut_copied"), true); } else { if ($last_cmd == "copy") { ilUtil::sendSuccess($this->lng->txt("msg_cloned"), true); } else { if ($last_command == 'link') { ilUtil::sendSuccess($this->lng->txt("msg_linked"), true); } } } $this->ctrl->returnToParent($this); }
/** * Check if the file extension does still exist after an update of the title * @return */ public function checkFileExtension($new_filename, $new_title) { include_once './Modules/File/classes/class.ilObjFileAccess.php'; $fileExtension = ilObjFileAccess::_getFileExtension($new_filename); $titleExtension = ilObjFileAccess::_getFileExtension($new_title); if ($titleExtension != $fileExtension && strlen($fileExtension) > 0) { // remove old extension $pi = pathinfo($this->getFileName()); $suffix = $pi["extension"]; if ($suffix != "") { if (substr($new_title, strlen($new_title) - strlen($suffix) - 1) == "." . $suffix) { $new_title = substr($new_title, 0, strlen($new_title) - strlen($suffix) - 1); } } $new_title .= '.' . $fileExtension; } return $new_title; }
/** * save object * * @access public */ function save() { global $objDefinition, $ilUser; if (!$this->checkPermissionBool("create", "", "file")) { $this->ilErr->raiseError($this->lng->txt("permission_denied"), $this->ilErr->MESSAGE); } $single_form_gui = $this->initSingleUploadForm(); if ($single_form_gui->checkInput()) { $title = $single_form_gui->getInput("title"); $description = $single_form_gui->getInput("description"); $upload_file = $single_form_gui->getInput("upload_file"); if (trim($title) == "") { $title = $upload_file["name"]; } else { // BEGIN WebDAV: Ensure that object title ends with the filename extension $fileExtension = ilObjFileAccess::_getFileExtension($upload_file["name"]); $titleExtension = ilObjFileAccess::_getFileExtension($title); if ($titleExtension != $fileExtension && strlen($fileExtension) > 0) { $title .= '.' . $fileExtension; } // END WebDAV: Ensure that object title ends with the filename extension } // create and insert file in grp_tree include_once "./Modules/File/classes/class.ilObjFile.php"; $fileObj = new ilObjFile(); $fileObj->setTitle($title); $fileObj->setDescription($description); $fileObj->setFileName($upload_file["name"]); //$fileObj->setFileType($upload_file["type"]); include_once "./Services/Utilities/classes/class.ilMimeTypeUtil.php"; $fileObj->setFileType(ilMimeTypeUtil::getMimeType("", $upload_file["name"], $upload_file["type"])); $fileObj->setFileSize($upload_file["size"]); $this->object_id = $fileObj->create(); $this->putObjectInTree($fileObj, $this->parent_id); // upload file to filesystem $fileObj->createDirectory(); $fileObj->getUploadFile($upload_file["tmp_name"], $upload_file["name"]); // BEGIN ChangeEvent: Record write event. require_once 'Services/Tracking/classes/class.ilChangeEvent.php'; ilChangeEvent::_recordWriteEvent($fileObj->getId(), $ilUser->getId(), 'create'); // END ChangeEvent: Record write event. ilUtil::sendSuccess($this->lng->txt("file_added"), true); if ($this->ctrl->getCmd() == "saveAndMeta") { $this->ctrl->setParameter($this, "new_type", ""); $target = $this->ctrl->getLinkTargetByClass(array("ilobjfilegui", "ilmdeditorgui"), "listSection", "", false, false); ilUtil::redirect($target); } else { $this->ctrl->returnToParent($this); } } else { $single_form_gui->setValuesByPost(); $this->tpl->setContent($single_form_gui->getHTML()); } }
/** * Get item properties * * @return array array of property arrays: * "alert" (boolean) => display as an alert property (usually in red) * "property" (string) => property name * "value" (string) => property value */ function getProperties() { global $lng, $ilUser; // BEGIN WebDAV: Get parent properties $props = parent::getProperties(); // END WebDAV: Get parent properties // to do: implement extra smaller file info object include_once "./Modules/File/classes/class.ilObjFileAccess.php"; // Display a warning if a file is not a hidden Unix file, and // the filename extension is missing if (!preg_match('/^\\.|\\.[a-zA-Z0-9]+$/', $this->title)) { $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"), "value" => $lng->txt("filename_extension_missing"), 'propertyNameVisible' => false); } // BEGIN WebDAV: Only display relevant information. $props[] = array("alert" => false, "property" => $lng->txt("type"), "value" => ilObjFileAccess::_getFileExtension($this->title), 'propertyNameVisible' => false); $fileData = ilObjFileAccess::_lookupFileData($this->obj_id); $props[] = array("alert" => false, "property" => $lng->txt("size"), "value" => ilFormat::formatSize($fileData['file_size'], 'short'), 'propertyNameVisible' => false); $version = $fileData['version']; if ($version > 1) { $props[] = array("alert" => false, "property" => $lng->txt("version"), "value" => $version); } $props[] = array("alert" => false, "property" => $lng->txt("last_update"), "value" => ilObject::_lookupLastUpdate($this->obj_id, true), 'propertyNameVisible' => false); // END WebDAV: Only display relevant information. return $props; }
continue; } // Rename $fss = new ilFSStorageFile($file_id); $fss->create(); if ($fss->rename(ilUpdateUtils::getDataDir() . '/files/file_' . $file_id, $fss->getAbsolutePath())) { $ilLog->write('DB Migration 1024: Success renaming file_' . $file_id); } else { $ilLog->write('DB Migration 1024: Failed renaming ' . ilUpdateUtils::getDataDir() . '/files/file_' . $file_id . ' -> ' . $fss->getAbsolutePath()); continue; } // Save success $query = "REPLACE INTO tmp_migration SET obj_id = '" . $file_id . "',passed = '1'"; $ilDB->query($query); // Update file size $size = ilObjFileAccess::_lookupFileSize($file_id); $query = "UPDATE file_data SET file_size = '" . $size . "' " . "WHERE file_id = " . $file_id; $ilDB->query($query); $ilLog->write('DB Migration 905: File size is ' . $size . ' Bytes'); } ?> <#1025> DROP TABLE IF EXISTS tmp_migration; <#1026> DROP TABLE IF EXISTS tmp_migration; CREATE TABLE `tmp_migration` ( `obj_id` int(11) NOT NULL default '0', `passed` tinyint(4) NOT NULL default '0'); ALTER TABLE `tmp_migration` ADD INDEX `obj_passed` ( `obj_id` ,`passed` );
/** * Get command link url. * * @param string $a_cmd The command to get the link for. * @return string The command link. */ function getCommandLink($a_cmd) { // overwritten to always return the permanent download link // only create permalink for repository if ($a_cmd == "sendfile" && $this->context == self::CONTEXT_REPOSITORY) { // return the perma link for downloads return ilObjFileAccess::_getPermanentDownloadLink($this->ref_id); } return parent::getCommandLink($a_cmd); }