/** * With trailing and leading slashes * @param $path1 * @param $path2 * @return string */ public static function joinPathsAbsolute($path1, $path2) { $path = ilCloudUtil::normalizePath(str_replace('//', '/', $path1 . $path2)); if ($path == "/") { return $path; } else { return "/" . ltrim($path, "/") . "/"; } }
/** * @param string $path */ public function setPath($path = "/") { $this->path = ilCloudUtil::normalizePath($path, $this->is_dir); }
/** * Set root_folder, this may only be changed by the owner of the object. This is due too security constraints. * The parameter $no_check could be used by plugins for which these constraint is not an issue. * * @param string root_folder */ function setRootFolder($a_val, $no_check = false) { if ($this->currentUserIsOwner() || $no_check || $this->getRootFolder() == null) { $a_val = ilCloudUtil::normalizePath($a_val); $this->root_folder = $a_val; } else { throw new ilCloudException(ilCloudException::PERMISSION_TO_CHANGE_ROOT_FOLDER_DENIED); } }
/** * @param $id * @param $folder_name * @throws ilCloudException */ public function addFolderToService($id, $folder_name) { try { if ($folder_name == null) { throw new ilCloudException(ilCloudException::INVALID_INPUT, $folder_name); } $current_node = $this->getNodeFromId($id); $path = ilCloudUtil::joinPaths($current_node->getPath(), ilCloudUtil::normalizePath($folder_name)); if ($this->getNodeFromPath($path) != null) { throw new ilCloudException(ilCloudException::FOLDER_ALREADY_EXISTING_ON_SERVICE, $folder_name); } $current_node->setLoadingComplete(false); $this->storeFileTreeToSession(); $service = ilCloudConnector::getServiceClass($this->getServiceName(), $this->getId()); $service->createFolder($path, $this); $this->addItemsFromService($current_node->getId()); $new_path = ilCloudUtil::joinPaths($current_node->getPath(), $folder_name); $new_node = $this->getNodeFromPath($new_path); return $new_node; } catch (Exception $e) { if ($e instanceof ilCloudException) { throw $e; } throw new ilCloudException(ilCloudException::FOLDER_CREATION_FAILED, $e->getMessage()); } }