From 94f8065cb37cb79125b2fb275a2aca0f1c32d916 Mon Sep 17 00:00:00 2001 From: Theodor Truffer Date: Wed, 3 Feb 2021 14:01:06 +0100 Subject: [PATCH] v2.2.3 (generalized office online permission) --- CHANGELOG.md | 3 ++ classes/class.ilOneDriveActionListGUI.php | 3 +- classes/class.ilOneDriveHeaderActionGUI.php | 5 +-- classes/class.ilOneDrivePlugin.php | 46 +-------------------- lang/ilias_de.lang | 4 +- lang/ilias_en.lang | 4 +- plugin.php | 2 +- sql/dbupdate.php | 22 ++++++++-- 8 files changed, 28 insertions(+), 61 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ddb5be..71df949 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## [2.2.3] +- Change: changed Office-Online permission to general 'Edit in online editor' (shared with other cloud plugins) - **might require an ILIAS language reload** + ## [2.2.2] - Fix: 'invalid_token' bug (access tokens too long) diff --git a/classes/class.ilOneDriveActionListGUI.php b/classes/class.ilOneDriveActionListGUI.php index ee2a17b..dfbf181 100644 --- a/classes/class.ilOneDriveActionListGUI.php +++ b/classes/class.ilOneDriveActionListGUI.php @@ -123,10 +123,9 @@ private function checkOpenInOfficePerm() global $DIC; $user = $DIC->user(); $user_id = $user->getId(); - $perm = ilOneDrivePlugin::getInstance()->getPrefix() . '_asl_open_msoffice'; $ref_id = $_GET["ref_id"]; - return $DIC->access()->checkAccessOfUser($user_id, $perm, "", $ref_id); + return $DIC->access()->checkAccessOfUser($user_id, 'edit_in_online_editor', "", $ref_id); } diff --git a/classes/class.ilOneDriveHeaderActionGUI.php b/classes/class.ilOneDriveHeaderActionGUI.php index ecb932c..1ecacdf 100644 --- a/classes/class.ilOneDriveHeaderActionGUI.php +++ b/classes/class.ilOneDriveHeaderActionGUI.php @@ -30,10 +30,9 @@ protected function checkOpenInOfficePerm() global $DIC; $user = $DIC->user(); $user_id = $user->getId(); - $perm = ilOneDrivePlugin::getInstance()->getPrefix() . '_asl_open_msoffice'; $ref_id = $_GET["ref_id"]; - return $DIC->access()->checkAccessOfUser($user_id, $perm, "", $ref_id); + return $DIC->access()->checkAccessOfUser($user_id, 'edit_in_online_editor', "", $ref_id); } @@ -60,4 +59,4 @@ public function getCustomListActions() return $customActionList; } -} \ No newline at end of file +} diff --git a/classes/class.ilOneDrivePlugin.php b/classes/class.ilOneDrivePlugin.php index ef340c8..5aa88f3 100644 --- a/classes/class.ilOneDrivePlugin.php +++ b/classes/class.ilOneDrivePlugin.php @@ -26,50 +26,6 @@ public function getPluginName() { return self::PLUGIN_NAME; } - - public function updateLanguages($a_lang_keys = null) - { - global $DIC; - parent::updateLanguages($a_lang_keys); - $lang_entries_de = []; - $lang_entries_en = []; - $lang_entries_de['cld_cldh_exod_asl_open_msoffice'] = 'In Office Online öffnen'; - $lang_entries_en['cld_cldh_exod_asl_open_msoffice'] = 'Open in Office Online'; - $lang_entries_de['cld_cld_cldh_exod_asl_open_msoffice'] = 'Benutzer können Dokumente in Office Online bearbeiten'; - $lang_entries_en['cld_cld_cldh_exod_asl_open_msoffice'] = 'Users can edit documents in Office Online'; - - foreach ($lang_entries_de as $identifier => $value) { - ilObjLanguage::replaceLangEntry('rbac', $identifier, 'de', $value); - } - - foreach ($lang_entries_en as $identifier => $value) { - ilObjLanguage::replaceLangEntry('rbac', $identifier, 'en', $value); - } - - $q = "SELECT * FROM lng_modules WHERE " . - " lang_key = 'de'" . - " AND module = 'rbac'"; - $set = $DIC->database()->query($q); - $row = $DIC->database()->fetchAssoc($set); - $arr2 = unserialize($row["lang_array"]); - if (is_array($arr2)) { - $lang_entries_de = array_merge($arr2, $lang_entries_de); - } - ilObjLanguage::replaceLangModule('de', 'rbac', $lang_entries_de); - - $q = "SELECT * FROM lng_modules WHERE " . - " lang_key = 'en'" . - " AND module = 'rbac'"; - $set = $DIC->database()->query($q); - $row = $DIC->database()->fetchAssoc($set); - $arr2 = unserialize($row["lang_array"]); - if (is_array($arr2)) { - $lang_entries_en = array_merge($arr2, $lang_entries_en); - } - ilObjLanguage::replaceLangModule('en', 'rbac', $lang_entries_en); - } - - /** * @param exodBearerToken $exodBearerToken * @@ -142,4 +98,4 @@ public function getCsvPath() { public function getAjaxLink() { return null; } -} \ No newline at end of file +} diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index 0f6dd45..738ce0e 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -9,8 +9,6 @@ add_new_default_base_folder#:#Hauptordner add_new_default_base_folder_info#:#Auf Ihrem OneDrive wird innerhalb des Ordners ILIASCloud ein Unterordner erstellt. Der Titel oben ist identisch mit dem Namen des Unterordners. Wenn der Ordner bereits existiert, wird dessen Inhalt in ILIAS angezeigt. app_secret#:#App-Secret asl_open_msoffice#:#In Office Online öffnen -cld_cld_cldh_exod_asl_open_msoffice#:#In Office Online öffnen -cld_cldh_exod_asl_open_msoffice#:#In Office Online öffnen asl_rename#:#Umbenennen client_id#:#Client-ID client_secret#:#Client-Secret @@ -50,4 +48,4 @@ info_message_info#:#Die hier angegebene Meldung wird beim Erstellen von OneDrive msg_name_already_exists#:#Eine Datei mit diesem Namen existiert bereits. msg_illegal_characters#:#Der angegebene Name darf keine unzulässigen Zeichen enthalten. msg_leading_or_trailing_spaces#:#Der angegebene Name darf keine führenden oder nachgestellten Leerzeichen enthalten. -msg_rename_failed#:#Umbenennen fehlgeschlagen \ No newline at end of file +msg_rename_failed#:#Umbenennen fehlgeschlagen diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index 3eeb0e5..80d61db 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -9,8 +9,6 @@ add_new_default_base_folder#:#Main folder add_new_default_base_folder_info#:#A subfolder will be added inside ILIASCloud on your OneDrive. The name of the folder will be the title above. If the folder already exists, the content will be shown here. app_secret#:#App-Name asl_open_msoffice#:#Open in Office Online -cld_cld_cldh_exod_asl_open_msoffice#:#Open in Office Online -cld_cldh_exod_asl_open_msoffice#:#Open in Office Online asl_rename#:#Rename client_id#:#Client-ID client_secret#:#Client-Secret @@ -50,4 +48,4 @@ info_message_info#:#This message will be shown when creating a new OneDrive obje msg_name_already_exists#:#A file with the same name already exists. msg_illegal_characters#:#The provided name cannot contain any illegal characters. msg_leading_or_trailing_spaces#:#The provided name cannot contain leading, or trailing, spaces. -msg_rename_failed#:#Renaming failed \ No newline at end of file +msg_rename_failed#:#Renaming failed diff --git a/plugin.php b/plugin.php index 6865e14..89b63d9 100644 --- a/plugin.php +++ b/plugin.php @@ -1,6 +1,6 @@ <#4> getPrefix() . '_asl_open_msoffice', 'open ms office', 'object', 280); - if ($open_ms_office) { - ilDBUpdateNewObjectType::addRBACOperation($cld_type_id, $open_ms_office); + $open_online_editor = ilDBUpdateNewObjectType::addCustomRBACOperation('edit_in_online_editor', 'edit in online editor', 'object', 280); + if ($open_online_editor) { + ilDBUpdateNewObjectType::addRBACOperation($cld_type_id, $open_online_editor); } } ?> @@ -127,3 +127,17 @@ ] ); ?> +<#8> +database()->query('SELECT * FROM rbac_operations WHERE operation = "cld_cldh_exod_asl_open_msoffice"'); +if ($res = $DIC->database()->fetchAssoc($query)) { + require_once("./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php"); + if (ilDBUpdateNewObjectType::getCustomRBACOperationId('edit_in_online_editor')) { + $DIC->database()->query('DELETE FROM rbac_operations WHERE ops_id = ' . $res['ops_id']); + } else { + $DIC->database()->query('UPDATE rbac_operations SET operation = "edit_in_online_editor", description = "edit in online editor" WHERE ops_id = ' . $res['ops_id']); + } +} +?>