mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Improved Nextcloud integration #96
This commit is contained in:
parent
b2e1fa993d
commit
b5fb4f5b52
3 changed files with 74 additions and 48 deletions
|
|
@ -49,3 +49,11 @@
|
||||||
background-image: linear-gradient(to bottom, #f4f4f4, #dfdfdf) !important;
|
background-image: linear-gradient(to bottom, #f4f4f4, #dfdfdf) !important;
|
||||||
background-repeat: repeat-x !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: ';
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,18 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
VERSION = '2.1',
|
VERSION = '2.1',
|
||||||
RELEASE = '2022-10-10',
|
RELEASE = '2022-10-10',
|
||||||
CATEGORY = 'Integrations',
|
CATEGORY = 'Integrations',
|
||||||
DESCRIPTION = 'Integrate with Nextcloud v18+',
|
DESCRIPTION = 'Integrate with Nextcloud v20+',
|
||||||
REQUIRED = '2.15.2';
|
REQUIRED = '2.18.6';
|
||||||
|
|
||||||
public function Init() : void
|
public function Init() : void
|
||||||
{
|
{
|
||||||
if (static::IsIntegrated()) {
|
if (static::IsIntegrated()) {
|
||||||
|
$this->UseLangs(true);
|
||||||
|
|
||||||
$this->addHook('main.fabrica', 'MainFabrica');
|
$this->addHook('main.fabrica', 'MainFabrica');
|
||||||
$this->addHook('filter.app-data', 'FilterAppData');
|
$this->addHook('filter.app-data', 'FilterAppData');
|
||||||
$this->addHook('json.attachments', 'DoAttachmentsActions');
|
|
||||||
|
|
||||||
|
$this->addHook('json.attachments', 'DoAttachmentsActions');
|
||||||
$this->addJs('js/attachments.js');
|
$this->addJs('js/attachments.js');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -36,11 +38,33 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
return static::IsIntegrated() && \OC::$server->getUserSession()->isLoggedIn();
|
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)
|
public function DoAttachmentsActions(\SnappyMail\AttachmentsAction $data)
|
||||||
{
|
{
|
||||||
if ('nextcloud' === $data->action) {
|
if (static::isLoggedIn() && 'nextcloud' === $data->action) {
|
||||||
$oFiles = \OCP\Files::getStorage('files');
|
$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';
|
$sSaveFolder = $this->Config()->Get('plugin', 'save_folder', '') ?: 'Attachments';
|
||||||
$oFiles->is_dir($sSaveFolder) || $oFiles->mkdir($sSaveFolder);
|
$oFiles->is_dir($sSaveFolder) || $oFiles->mkdir($sSaveFolder);
|
||||||
$data->result = true;
|
$data->result = true;
|
||||||
|
|
@ -77,14 +101,11 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
|
|
||||||
public function FilterAppData($bAdmin, &$aResult) : void
|
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']);
|
$key = \array_search(\RainLoop\Enumerations\Capa::AUTOLOGOUT, $aResult['Capa']);
|
||||||
if (false !== $key) {
|
if (false !== $key) {
|
||||||
unset($aResult['Capa'][$key]);
|
unset($aResult['Capa'][$key]);
|
||||||
}
|
}
|
||||||
if (static::IsLoggedIn() && \class_exists('OCP\Files')) {
|
|
||||||
$aResult['System']['attachmentsActions'][] = 'nextcloud';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
(rl => {
|
(rl => {
|
||||||
if (rl) {
|
|
||||||
addEventListener('rl-view-model.create', e => {
|
addEventListener('rl-view-model.create', e => {
|
||||||
if ('MailMessageView' === e.detail.viewModelTemplateID) {
|
if ('MailMessageView' === e.detail.viewModelTemplateID) {
|
||||||
let view = e.detail;
|
let view = e.detail;
|
||||||
|
|
@ -24,7 +23,6 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => view.saveNextcloudError(true));
|
.catch(() => view.saveNextcloudError(true));
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -35,9 +33,8 @@
|
||||||
if (attachmentsControls) {
|
if (attachmentsControls) {
|
||||||
attachmentsControls.append(Element.fromHTML('<span>'
|
attachmentsControls.append(Element.fromHTML('<span>'
|
||||||
+ '<i class="fontastic iconcolor-red" data-bind="visible: saveNextcloudError">✖</i>'
|
+ '<i class="fontastic iconcolor-red" data-bind="visible: saveNextcloudError">✖</i>'
|
||||||
+ '<i class="icon-file-archive" data-bind="visible: !saveNextcloudError(), css: {\'icon-file-archive\': !saveNextcloudLoading(), \'icon-spinner\': saveNextcloudLoading()}"></i>'
|
+ '<i class="fontastic" data-bind="visible: !saveNextcloudError(), css: {\'icon-spinner\': saveNextcloudLoading()}">💾</i>'
|
||||||
+ '<span class="g-ui-link" data-bind="click: saveNextcloud" data-i18n="NEXTCLOUD/SAVE_ATTACHMENTS">Save Nextcloud</span>'
|
+ '<span class="g-ui-link" data-bind="click: saveNextcloud" data-i18n="NEXTCLOUD/SAVE_ATTACHMENTS">Save Nextcloud</span>'
|
||||||
+ '</span>'));
|
+ '</span>'));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})(window.rl);
|
})(window.rl);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue