Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
WIP: chunked upload and event logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodor Truffer committed Feb 10, 2021
1 parent fa7c29a commit 6e331cc
Show file tree
Hide file tree
Showing 104 changed files with 210 additions and 7,952 deletions.
18 changes: 14 additions & 4 deletions classes/class.ilOneDriveActionListGUI.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php

use srag\Plugins\OneDrive\EventLog\EventLogger;
use srag\Plugins\OneDrive\EventLog\ObjectType;

require_once('./Modules/Cloud/classes/class.ilCloudPluginActionListGUI.php');
require_once('./Customizing/global/plugins/Modules/Cloud/CloudHook/OneDrive/classes/Client/Item/class.exodItemCache.php');
require_once('./Customizing/global/plugins/Modules/Cloud/CloudHook/OneDrive/classes/class.ilOneDrivePlugin.php');
Expand Down Expand Up @@ -165,6 +169,7 @@ protected function initRename()
*/
protected function rename()
{
global $DIC;
$response = new stdClass();
// TODO: access check
$form = $this->buildForm();
Expand All @@ -178,14 +183,19 @@ protected function rename()
$id = filter_input(INPUT_GET, self::GET_ID, FILTER_SANITIZE_STRING);
$title = $form->getInput(self::POST_TITLE);

$exoFile = exodItemCache::get($id);
if ($exoFile instanceof exodFile) {
$title = exodFile::formatRename($title, $exoFile->getName());
$exoItem = exodItemCache::get($id);
if ($exoItem instanceof exodFile) {
$title = exodFile::formatRename($title, $exoItem->getName());
}

try {
$this->getService()->getClient()->renameItemById($id, $title);

EventLogger::logObjectRenamed(
$DIC->user()->getId(),
$exoItem->getPath(),
$title,
ObjectType::fromExodItem($exoItem)
);
$response->message = ilUtil::getSystemMessageHTML($this->txt("msg_renamed"), "success");
$response->success = true;
} catch (Exception $e) {
Expand Down
42 changes: 42 additions & 0 deletions classes/class.ilOneDriveDeleteGUI.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

use srag\Plugins\OneDrive\EventLog\EventLogger;
use srag\Plugins\OneDrive\EventLog\ObjectType;

/**
* Class ilOneDriveDeleteGUI
* @author Theodor Truffer <[email protected]>
*/
class ilOneDriveDeleteGUI extends ilCloudPluginDeleteGUI
{
public function deleteItem()
{
global $DIC;
$tpl = $DIC['tpl'];
$lng = $DIC['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;
EventLogger::logObjectDeleted(
$DIC->user()->getId(),
$node->getPath(),
ObjectType::fromExodItem(exodItemCache::get($node->getId()))
);
} 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; }

}
28 changes: 28 additions & 0 deletions classes/class.ilOneDriveSettingsGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
*/
class ilOneDriveSettingsGUI extends ilCloudPluginSettingsGUI {

const SUBTAB_GENERAL = 'general';
const SUBTAB_LOGS = 'logs';

/**
* @var ilPropertyFormGUI
*/
Expand All @@ -28,6 +31,7 @@ protected function initPluginSettings()
public function updateSettings() {
global $DIC;
$ilCtrl = $DIC['ilCtrl'];
$this->initSubtabs(self::SUBTAB_GENERAL);

try {
$this->initSettingsForm();
Expand All @@ -51,6 +55,8 @@ function editSettings()
$ilCtrl = $DIC['ilCtrl'];
$lng = $DIC['lng'];

$this->initSubtabs(self::SUBTAB_GENERAL);

$cloud_object_changed = false;

// On object creation set cloud root id
Expand Down Expand Up @@ -90,6 +96,28 @@ public function initSettingsForm()

}

protected function showLogs()
{
global $DIC;
$DIC->tabs()->activateTab('settings');
$this->initSubtabs(self::SUBTAB_LOGS);

}

protected function initSubtabs(string $active)
{
global $DIC;
$DIC->tabs()->addSubTab(
self::SUBTAB_GENERAL,
$this->txt('subtab_' . self::SUBTAB_GENERAL),
$DIC->ctrl()->getLinkTargetByClass(parent::class, 'editSettings'));
$DIC->tabs()->addSubTab(
self::SUBTAB_LOGS,
$this->txt('subtab_' . self::SUBTAB_LOGS),
$DIC->ctrl()->getLinkTargetByClass(parent::class, 'showLogs'));
$DIC->tabs()->setSubTabActive($active);
}


public function txt($var = "")
{
Expand Down
11 changes: 8 additions & 3 deletions classes/class.ilOneDriveUploadGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ function handleFileUpload($file_upload)

protected function afterUpload()
{
// TODO: event logging
global $DIC;
$name = filter_input(INPUT_POST, 'filename', FILTER_SANITIZE_STRING);
$parent_id = $_SESSION["cld_folder_id"];
EventLogger::logUploadComplete(
$DIC->user()->getId(),
ilCloudFileTree::getFileTreeFromSession()->getNodeFromId($parent_id)->getPath() . '/' . $name
);
}

protected function asyncGetResumableUploadUrl()
Expand All @@ -99,8 +105,7 @@ protected function asyncGetResumableUploadUrl()
}
EventLogger::logUploadStarted(
$DIC->user()->getId(),
$name,
ilCloudFileTree::getFileTreeFromSession()->getNodeFromId($parent_id)->getPath()
ilCloudFileTree::getFileTreeFromSession()->getNodeFromId($parent_id)->getPath() . '/' . $name
);
http_response_code(200);
echo $upload_url->toJson();
Expand Down
38 changes: 38 additions & 0 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

182 changes: 0 additions & 182 deletions node_modules/@mux/upchunk/README.md

This file was deleted.

10 changes: 0 additions & 10 deletions node_modules/@mux/upchunk/README_INTERNAL.md

This file was deleted.

Loading

0 comments on commit 6e331cc

Please sign in to comment.