/** * Update properties */ public function deleteItem() { global $tpl, $lng; $response = new stdClass(); $response->success = null; $response->message = null; if (true) { try { $file_tree = ilCloudFileTree::getFileTreeFromSession(); $node = $file_tree->getNodeFromId($_POST["id"]); $file_tree->deleteFromService($node->getId()); $response->message = $tpl->getMessageHTML($lng->txt("cld_file_deleted"), "success"); $response->success = true; } catch (Exception $e) { $response->message = $tpl->getMessageHTML($e->getMessage(), "failure"); } } echo "<script language='javascript' type='text/javascript'>window.parent.il.CloudFileList.afterDeleteItem(" . ilJsonUtil::encode($response) . ");</script>"; exit; }
/** * Update properties */ public function createFolder() { global $tpl, $lng; $response = new stdClass(); $response->success = null; $response->message = null; $response->folder_id = null; try { $response->status = "done"; include_once "class.ilCloudFileTree.php"; $file_tree = ilCloudFileTree::getFileTreeFromSession(); $new_node = $file_tree->addFolderToService($_POST["parent_folder_id"], $_POST["folder_name"]); $response->folder_id = $new_node->getId(); $response->folder_path = $new_node->getPath(); $response->success = true; $response->message = $tpl->getMessageHTML($lng->txt("cld_folder_created"), "success"); } catch (Exception $e) { $response->message = $tpl->getMessageHTML($e->getMessage(), "failure"); } echo "<script language='javascript' type='text/javascript'>window.parent.il.CloudFileList.afterCreateFolder(" . ilJsonUtil::encode($response) . ");</script>"; exit; }
public function initGUI(ilObjCloudGUI $gui_class, $perm_create_folder, $perm_upload_items, $perm_delete_files, $perm_delete_folders, $perm_download, $perm_files_visible, $perm_folders_visible) { global $ilTabs, $lng, $tpl; $ilTabs->activateTab("content"); $this->setGuiClass($gui_class); $this->setPermUploadItems($perm_upload_items); $this->setPermCreateFolders($perm_create_folder); $this->setPermDeleteFiles($perm_delete_files); $this->setPermDeleteFolders($perm_delete_folders); $this->setPermDownload($perm_download); $this->setPermFilesVisible($perm_files_visible); $this->setPermFoldersVisible($perm_folders_visible); try { ilCloudConnector::checkServiceActive($this->getGUIClass()->object->getServiceName()); $this->beforeInitGUI(); $tpl->addJavaScript("./Modules/Cloud/js/ilCloudFileList.js"); $tpl->addJavaScript("./Modules/Cloud/js/jquery.address.js"); $tpl->addJavascript("./Services/UIComponent/AdvancedSelectionList/js/AdvancedSelectionList.js"); $tpl->addCss("./Modules/Cloud/templates/css/cloud.css"); include_once "./Services/YUI/classes/class.ilYuiUtil.php"; ilYuiUtil::initConnection(); $this->tpl_file_tree = new ilTemplate("tpl.cloud_file_tree.html", true, true, "Modules/Cloud"); $file_tree = new ilCloudFileTree($this->getGUIClass()->object->getRootFolder(), $this->getGUIClass()->object->getRootId(), $this->getGUIClass()->object->getId(), $this->getGUIClass()->object->getServiceName()); $file_tree->storeFileTreeToSession(); $this->addToolbar($file_tree->getRootNode()); $this->tpl_file_tree->setVariable("ASYNC_GET_BLOCK", json_encode($this->getGUIClass()->ctrl->getLinkTargetByClass("ilobjcloudgui", "asyncGetBlock", true))); $this->tpl_file_tree->setVariable("ASYNC_CREATE_FOLDER", json_encode($this->getGUIClass()->ctrl->getLinkTargetByClass("ilcloudplugincreatefoldergui", "asyncCreateFolder", true))); $this->tpl_file_tree->setVariable("ASYNC_UPLOAD_FILE", json_encode($this->getGUIClass()->ctrl->getLinkTargetByClass("ilcloudpluginuploadgui", "asyncUploadFile", true))); $this->tpl_file_tree->setVariable("ASYNC_DELETE_ITEM", json_encode($this->getGUIClass()->ctrl->getLinkTargetByClass("ilcloudplugindeletegui", "asyncDeleteItem", true))); $this->tpl_file_tree->setVariable("ROOT_ID", json_encode($file_tree->getRootNode()->getId())); $this->tpl_file_tree->setVariable("ROOT_PATH", json_encode($file_tree->getRootNode()->getPath())); if (isset($_POST["path"])) { $this->tpl_file_tree->setVariable("CURRENT_PATH", json_encode($_POST["path"])); $file_tree->updateFileTree($_POST["path"]); $node = $file_tree->getNodeFromPath($_POST["path"]); $this->tpl_file_tree->setVariable("CURRENT_ID", json_encode($node->getId())); } else { $this->tpl_file_tree->setVariable("CURRENT_PATH", json_encode($file_tree->getRootNode()->getPath())); $this->tpl_file_tree->setVariable("CURRENT_ID", json_encode($file_tree->getRootNode()->getID())); } $txt_max_file_size = $lng->txt("file_notice") . " " . ilCloudConnector::getPluginClass($this->getGUIClass()->object->getServiceName(), $this->getGUIClass()->object->getId())->getMaxFileSize() . " MB"; $this->tpl_file_tree->setVariable("MAX_FILE_SIZE", json_encode($txt_max_file_size)); $this->beforeSetContent(); $tpl->setContent($this->tpl_file_tree->get()); $tpl->setPermanentLink("cld", $this->getGuiClass()->object->getRefId(), "_path__endPath"); /** else { $file_tree = ilCloudFileTree::getFileTreeFromSession(); if($_GET["current_path"] && $_GET["current_id"] && $file_tree && $file_tree->getId() == $this->getGUIClass()->object->getId()) { $path = $_GET["current_path"]; $id = $_GET["current_id"]; } else { $path = $gui_class->object->getRootFolder(); $id = $gui_class->object->getRootId(); ilCloudFileTree::clearFileTreeSession(); $file_tree = new ilCloudFileTree($this->getGUIClass()->object->getRootFolder(), $this->getGUIClass()->object->getRootId(), $this->getGUIClass()->object->getId(), $this->getGUIClass()->object->getServiceName()); } $file_tree->updateFileTree($path); $file_tree_gui = ilCloudConnector::getFileTreeGUIClass($this->getService(), $file_tree); $this->content = $file_tree_gui->getFolderHtml($this->getGuiClass(), $id, $this->getPermDeleteFiles(), $this->getPermDeleteFolders(), $this->getPermDownload(), $this->getPermFilesVisible(), $this->getPermCreateFolders()); $tpl->setContent($this->content); }**/ $this->afterInitGUI(); } catch (Exception $e) { if ($e->getCode() == ilCloudException::AUTHENTIFICATION_FAILED) { $this->getGUIClass()->object->setAuthComplete(false); $this->getGUIClass()->object->doUpdate(); } ilUtil::sendFailure($e->getMessage()); } }
function handleFileUpload($file_upload) { // create answer object $response = new stdClass(); $response->fileName = $_POST["title"]; $response->fileSize = intval($file_upload["size"]); $response->fileType = $file_upload["type"]; $response->fileUnzipped = false; $response->error = null; $file_tree = ilCloudFileTree::getFileTreeFromSession(); $file_tree->uploadFileToService($_SESSION["cld_folder_id"], $file_upload["tmp_name"], $_POST["title"]); return $response; }
function asyncGetActionListContent() { $action_list = ilCloudConnector::getActionListGUIClass($this->plugin_service); $file_tree = ilCloudFileTree::getFileTreeFromSession(); return $action_list->asyncGetContent($this->checkPermissionBool("delete_files"), $this->checkPermissionBool("delete_folders"), $file_tree->getNodeFromId($_GET["node_id"])); }
/** * @param null $path * @param ilCloudFileTree $file_tree * * @return bool */ public function deleteItem($path = NULL, ilCloudFileTree $file_tree = NULL) { // throw new ilCloudException(-1, print_r($file_tree, true)); $path = ilCloudUtil::joinPaths($file_tree->getRootPath(), $path); return $this->getClient()->delete($path); }
/** * @param null $path * @param ilCloudFileTree|null $file_tree * @return mixed * @throws \Dropbox\Exception_BadResponseCode * @throws \Dropbox\Exception_InvalidAccessToken * @throws \Dropbox\Exception_RetryLater * @throws \Dropbox\Exception_ServerError */ public function deleteItem($path = null, ilCloudFileTree $file_tree = null) { $path = ilCloudUtil::joinPaths($file_tree->getRootPath(), $path); return $this->getServiceObject()->delete($path); }