diff --git a/integrations/nextcloud/snappymail/app/themes/Nextcloud/styles.css b/integrations/nextcloud/snappymail/app/themes/Nextcloud/styles.css
index ed11cba1f..18f928970 100644
--- a/integrations/nextcloud/snappymail/app/themes/Nextcloud/styles.css
+++ b/integrations/nextcloud/snappymail/app/themes/Nextcloud/styles.css
@@ -49,3 +49,11 @@
background-image: linear-gradient(to bottom, #f4f4f4, #dfdfdf) !important;
background-repeat: repeat-x !important;
}
+#V-AdminPane > .b-toolbar {
+ background-color: #0082c9;
+ background-image: linear-gradient(40deg, #0082c9 0%, #30b6ff 100%);
+ color: #fff;
+}
+#V-AdminPane > .b-toolbar h4::before {
+ content: 'Nextcloud: ';
+}
diff --git a/plugins/nextcloud/index.php b/plugins/nextcloud/index.php
index 01b81361e..b67397a66 100644
--- a/plugins/nextcloud/index.php
+++ b/plugins/nextcloud/index.php
@@ -7,16 +7,18 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
VERSION = '2.1',
RELEASE = '2022-10-10',
CATEGORY = 'Integrations',
- DESCRIPTION = 'Integrate with Nextcloud v18+',
- REQUIRED = '2.15.2';
+ DESCRIPTION = 'Integrate with Nextcloud v20+',
+ REQUIRED = '2.18.6';
public function Init() : void
{
if (static::IsIntegrated()) {
+ $this->UseLangs(true);
+
$this->addHook('main.fabrica', 'MainFabrica');
$this->addHook('filter.app-data', 'FilterAppData');
- $this->addHook('json.attachments', 'DoAttachmentsActions');
+ $this->addHook('json.attachments', 'DoAttachmentsActions');
$this->addJs('js/attachments.js');
}
}
@@ -36,11 +38,33 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
return static::IsIntegrated() && \OC::$server->getUserSession()->isLoggedIn();
}
+ /*
+ $sUID = \OC::$server->getUserSession()->getUser()->getUID();
+ WebDAV /nextcloud/remote.php/dav/files/$sUID/
+ \OCP\Util::linkToRemote('files');
+
+ \OC::$server->getCalendarManager();
+ \OC::$server->getLDAPProvider();
+ \OC::$server->getAppDataDir('snappymail'); ??
+
+ $oFiles = \OCP\Files::getStorage('files');
+ if ($oFiles and $oFiles->is_dir('/')) {
+ $dh = $oFiles->opendir('/');
+ if (\is_resource($dh)) {
+ while (($file = \readdir($dh)) !== false) {
+ if ($file != '.' && $file != '..') {
+ // DO THINGS
+ }
+ }
+ }
+ }
+ */
+
public function DoAttachmentsActions(\SnappyMail\AttachmentsAction $data)
{
- if ('nextcloud' === $data->action) {
+ if (static::isLoggedIn() && 'nextcloud' === $data->action) {
$oFiles = \OCP\Files::getStorage('files');
- if ($oFiles && $data->filesProvider->IsActive() && \method_exists($oFiles, 'file_put_contents')) {
+ if ($oFiles && \method_exists($oFiles, 'file_put_contents')) {
$sSaveFolder = $this->Config()->Get('plugin', 'save_folder', '') ?: 'Attachments';
$oFiles->is_dir($sSaveFolder) || $oFiles->mkdir($sSaveFolder);
$data->result = true;
@@ -77,14 +101,11 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
public function FilterAppData($bAdmin, &$aResult) : void
{
- if (!$bAdmin && \is_array($aResult) && static::IsIntegrated()) {
+ if (!$bAdmin && \is_array($aResult)) {
$key = \array_search(\RainLoop\Enumerations\Capa::AUTOLOGOUT, $aResult['Capa']);
if (false !== $key) {
unset($aResult['Capa'][$key]);
}
- if (static::IsLoggedIn() && \class_exists('OCP\Files')) {
- $aResult['System']['attachmentsActions'][] = 'nextcloud';
- }
}
}
diff --git a/plugins/nextcloud/js/attachments.js b/plugins/nextcloud/js/attachments.js
index c23ada8a5..cf312723b 100644
--- a/plugins/nextcloud/js/attachments.js
+++ b/plugins/nextcloud/js/attachments.js
@@ -1,43 +1,40 @@
(rl => {
- if (rl) {
- addEventListener('rl-view-model.create', e => {
- if ('MailMessageView' === e.detail.viewModelTemplateID) {
- let view = e.detail;
- view.saveNextcloudError = ko.observable(false).extend({ falseTimeout: 7000 });
- view.saveNextcloudLoading = ko.observable(false);
- view.saveNextcloud = () => {
- const
- hashes = (view.message()?.attachments || [])
- .map(item => item?.checked() /*&& !item?.isLinked()*/ ? item.download : '')
- .filter(v => v);
- if (hashes.length) {
- rl.fetchJSON('./?/Json/&q[]=/0/', {}, {
- Action: 'AttachmentsActions',
- Do: 'nextcloud',
- Hashes: hashes
- })
- .then(result => {
- if (result?.Result) {
- // success
- } else {
- view.saveNextcloudError(true);
- }
- })
- .catch(() => view.saveNextcloudError(true));
-
- }
- };
- }
- });
-
- let template = document.getElementById('MailMessageView');
- const attachmentsControls = template.content.querySelector('.attachmentsControls');
- if (attachmentsControls) {
- attachmentsControls.append(Element.fromHTML(''
- + '✖'
- + ''
- + 'Save Nextcloud'
- + ''));
+ addEventListener('rl-view-model.create', e => {
+ if ('MailMessageView' === e.detail.viewModelTemplateID) {
+ let view = e.detail;
+ view.saveNextcloudError = ko.observable(false).extend({ falseTimeout: 7000 });
+ view.saveNextcloudLoading = ko.observable(false);
+ view.saveNextcloud = () => {
+ const
+ hashes = (view.message()?.attachments || [])
+ .map(item => item?.checked() /*&& !item?.isLinked()*/ ? item.download : '')
+ .filter(v => v);
+ if (hashes.length) {
+ rl.fetchJSON('./?/Json/&q[]=/0/', {}, {
+ Action: 'AttachmentsActions',
+ Do: 'nextcloud',
+ Hashes: hashes
+ })
+ .then(result => {
+ if (result?.Result) {
+ // success
+ } else {
+ view.saveNextcloudError(true);
+ }
+ })
+ .catch(() => view.saveNextcloudError(true));
+ }
+ };
}
+ });
+
+ let template = document.getElementById('MailMessageView');
+ const attachmentsControls = template.content.querySelector('.attachmentsControls');
+ if (attachmentsControls) {
+ attachmentsControls.append(Element.fromHTML(''
+ + '✖'
+ + '💾'
+ + 'Save Nextcloud'
+ + ''));
}
})(window.rl);