diff --git a/build/nextcloud.php b/build/nextcloud.php index 3c8a50681..ce3e47023 100755 --- a/build/nextcloud.php +++ b/build/nextcloud.php @@ -21,8 +21,8 @@ foreach ($files as $file) { $nc_tar->addFile('data/.htaccess'); $nc_tar->addFromString('data/VERSION', $package->version); $nc_tar->addFile('data/README.md'); -*/ $nc_tar->addFile('_include.php', 'snappymail/app/_include.php'); +*/ $nc_tar->addFile('.htaccess', 'snappymail/app/.htaccess'); $index = file_get_contents('index.php'); diff --git a/dev/External/SquireUI.js b/dev/External/SquireUI.js index 428d0476a..46b7e08d6 100644 --- a/dev/External/SquireUI.js +++ b/dev/External/SquireUI.js @@ -283,7 +283,7 @@ class SquireUI this.wysiwyg = wysiwyg; toolbar.className = 'squire-toolbar btn-toolbar'; - let group, action, touchTap; + let group, action/*, touchTap*/; for (group in actions) { /* if ('bidi' == group && !rl.settings.app('allowHtmlEditorBitiButtons')) { @@ -328,16 +328,18 @@ class SquireUI input.className = 'btn'; input.innerHTML = cfg.html; input.action_cmd = cfg.cmd; - input.addEventListener('touchstart', () => touchTap = input, {passive:true}); - input.addEventListener('touchmove', () => touchTap = null, {passive:true}); - input.addEventListener('touchcancel', () => touchTap = null); - input.addEventListener('touchend', e => { +/* + input.addEventListener('pointerdown', () => touchTap = input, {passive:true}); + input.addEventListener('pointermove', () => touchTap = null, {passive:true}); + input.addEventListener('pointercancel', () => touchTap = null); + input.addEventListener('pointerup', e => { if (touchTap === input) { e.preventDefault(); cfg.cmd(input); } touchTap = null; }); +*/ } input.addEventListener(ev, () => cfg.cmd(input)); if (cfg.hint) { diff --git a/integrations/nextcloud/snappymail/README.md b/integrations/nextcloud/snappymail/README.md index b06cda361..56fb9af52 100644 --- a/integrations/nextcloud/snappymail/README.md +++ b/integrations/nextcloud/snappymail/README.md @@ -69,9 +69,9 @@ To fill in the default email address and password to use, each Nextcloud user sh ## How to Activate SnappyMail Logging and then Find Logs -You can activate SnappyMail logging here: `/path/to/nextcloud/data/snappymail-storage/_data_/_default_/configs/application.ini` +You can activate SnappyMail logging here: `/path/to/nextcloud/data/appdata_snappymail/_data_/_default_/configs/application.ini` ``` [logs] enable = On ``` -Logs are then available in `/path/to/nextcloud/data/snappymail-storage/_data_/_default_/logs/` +Logs are then available in `/path/to/nextcloud/data/appdata_snappymail/_data_/_default_/logs/` diff --git a/integrations/nextcloud/snappymail/app/include.php b/integrations/nextcloud/snappymail/app/include.php new file mode 100644 index 000000000..56e342f36 --- /dev/null +++ b/integrations/nextcloud/snappymail/app/include.php @@ -0,0 +1,44 @@ +getSystemConfig()->getValue('datadirectory', '')), '\\/').'/appdata_snappymail/'); +} else { + http_response_code(400); + header($_SERVER['SERVER_PROTOCOL'].' 400 Bad Request', true, 400); + error_log("SnappyMail outside Nextcloud {$_SERVER['REQUEST_URI']}"); + exit('Not inside Nextcloud'); +// define('APP_DATA_FOLDER_PATH', dirname(__DIR__) . '/snappymail-data/'); +// define('APP_DATA_FOLDER_PATH', '/var/external-snappymail-data-folder/'); +} + +/** + * Additional configuration file name + */ +//define('APP_CONFIGURATION_NAME', $_SERVER['HTTP_HOST'].'.ini'); diff --git a/integrations/nextcloud/snappymail/appinfo/routes.php b/integrations/nextcloud/snappymail/appinfo/routes.php index ce0e24721..4c1b7f56a 100755 --- a/integrations/nextcloud/snappymail/appinfo/routes.php +++ b/integrations/nextcloud/snappymail/appinfo/routes.php @@ -7,6 +7,11 @@ return [ 'url' => '/', 'verb' => 'GET' ], + [ + 'name' => 'page#indexPost', + 'url' => '/', + 'verb' => 'POST' + ], [ 'name' => 'page#appGet', 'url' => '/run/', diff --git a/integrations/nextcloud/snappymail/css/embed.css b/integrations/nextcloud/snappymail/css/embed.css new file mode 100644 index 000000000..4d1a9bf82 --- /dev/null +++ b/integrations/nextcloud/snappymail/css/embed.css @@ -0,0 +1,40 @@ +/* +SnappyMail runs in an iframe, so this style sheet is not used there. +Only needed to give you the opportunity to theme the nextcloud part of this app. +However, there is hidden code in the PageController to embed instead of using an iframe. +Then the below #rl-app can be used to style it. +*/ +#rl-app { + position: relative; + min-width: 100%; + min-height: 100%; +} + +#content[class*="app-"] #rl-app * { + box-sizing: content-box; +} +#content[class*="app-"] #rl-app #V-Settings-Domains .domain-name, +#content[class*="app-"] #rl-app #V-Settings-Domains .domain-alias +#content[class*="app-"] #rl-app #rl-settings-subscreen, +#content[class*="app-"] #rl-app .e-checkbox.material-design > div > div, +#content[class*="app-"] #rl-app .attachmentItem .iconMain, +#content[class*="app-"] #rl-app .attachmentItem .iconPreview, +#content[class*="app-"] #rl-app #V-PopupsCompose .textAreaParent, +#content[class*="app-"] #rl-app #V-PopupsCompose .attachmentAreaParent, +#content[class*="app-"] #rl-app .emailaddresses, +#content[class*="app-"] #rl-app .squire-wysiwyg, +#content[class*="app-"] #rl-app .squire-plain, +/* bootstrap */ +#content[class*="app-"] #rl-app .btn-block, +#content[class*="app-"] #rl-app select, +#content[class*="app-"] #rl-app .select, +#content[class*="app-"] #rl-app textarea, +#content[class*="app-"] #rl-app input, +#content[class*="app-"] #rl-app .input-block-level +{ + box-sizing: border-box; +} +.squire-wysiwyg { + min-width: 100%; + min-height: 100%; +} diff --git a/integrations/nextcloud/snappymail/lib/AppInfo/Application.php b/integrations/nextcloud/snappymail/lib/AppInfo/Application.php index a45a2fbdd..629c72062 100644 --- a/integrations/nextcloud/snappymail/lib/AppInfo/Application.php +++ b/integrations/nextcloud/snappymail/lib/AppInfo/Application.php @@ -26,13 +26,12 @@ class Application extends App implements IBootstrap $this->getContainer()->query('SnappyMailHelper')->registerHooks(); } - public function __construct(array $urlParams = []) +// public function __construct(string $appName, array $urlParams = []) + public function __construct() { parent::__construct('snappymail', $urlParams); $container = $this->getContainer(); -// $server = $container->getServer(); -// $config = $server->getConfig(); /** * Controllers diff --git a/integrations/nextcloud/snappymail/lib/Controller/PageController.php b/integrations/nextcloud/snappymail/lib/Controller/PageController.php index 92854d357..78247ee58 100644 --- a/integrations/nextcloud/snappymail/lib/Controller/PageController.php +++ b/integrations/nextcloud/snappymail/lib/Controller/PageController.php @@ -76,17 +76,30 @@ class PageController extends Controller SnappyMailHelper::startApp(); } + /** + * @NoAdminRequired + * @NoCSRFRequired + */ + public function indexPost() + { + SnappyMailHelper::startApp(); + } + /** * Draft code to run without using an iframe */ private static function index_embed() { + if (!empty($_SERVER['QUERY_STRING'])) { + SnappyMailHelper::startApp(); + return; + } + \OC::$server->getNavigationManager()->setActiveEntry('snappymail'); - \OCP\Util::addStyle('snappymail', 'style'); + \OCP\Util::addStyle('snappymail', 'embed'); SnappyMailHelper::startApp(true); - $webPath = \OC::$server->getAppManager()->getAppWebPath('snappymail') . '/app'; $oConfig = \RainLoop\Api::Config(); $oActions = \RainLoop\Api::Actions(); $oHttp = \MailSo\Base\Http::SingletonInstance(); @@ -102,11 +115,7 @@ class PageController extends Controller $params = [ 'LoadingDescriptionEsc' => \htmlspecialchars($oConfig->Get('webmail', 'loading_description', 'SnappyMail'), ENT_QUOTES|ENT_IGNORE, 'UTF-8'), 'BaseTemplates' => \RainLoop\Utils::ClearHtmlOutput($oServiceActions->compileTemplates(false)), - 'BaseAppBootScript' => \str_replace( - 'loadScript(`./?/', - 'loadScript(`'.$webPath.'/?/', - \file_get_contents(APP_VERSION_ROOT_PATH.'static/js'.($sAppJsMin ? '/min' : '').'/boot'.$sAppJsMin.'.js') - ), + 'BaseAppBootScript' => \file_get_contents(APP_VERSION_ROOT_PATH.'static/js'.($sAppJsMin ? '/min' : '').'/boot'.$sAppJsMin.'.js'), 'BaseAppBootScriptNonce' => $sScriptNonce, 'BaseLanguage' => $oActions->compileLanguage($sLanguage, false), ]; diff --git a/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php b/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php index 081d08ec0..ea4832c8c 100644 --- a/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php +++ b/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php @@ -44,39 +44,29 @@ class SnappyMailHelper } }); - $path = \OC::$server->getAppManager()->getAppPath('snappymail') . '/app/'; - - $sData = \rtrim(\trim(\OC::$server->getSystemConfig()->getValue('datadirectory', '')), '\\/').'/appdata_snappymail/'; - if (!\is_file("{$path}include.php")) { - \file_put_contents("{$path}include.php", - \file_get_contents("{$path}_include.php") - . "define('APP_DATA_FOLDER_PATH', '{$sData}');\n" - ); - } -// \define('APP_DATA_FOLDER_PATH', $sData); - if ($api) { $_ENV['SNAPPYMAIL_INCLUDE_AS_API'] = true; } - require_once "{$path}index.php"; + require_once \dirname(\dirname(__DIR__)) . '/app/index.php'; if ($api) { $oConfig = \RainLoop\Api::Config(); + $bSave = false; if (!$oConfig->Get('webmail', 'app_path')) { $oConfig->Set('webmail', 'app_path', \OC::$server->getAppManager()->getAppWebPath('snappymail') . '/app/'); - $oConfig->Save(); + $bSave = true; } -/* if (!\is_dir(APP_PLUGINS_PATH . 'nextcloud')) { \SnappyMail\Repository::installPackage('plugin', 'nextcloud'); $oConfig->Set('plugins', 'enable', true); $aList = \SnappyMail\Repository::getEnabledPackagesNames(); $aList[] = 'nextcloud'; $oConfig->Set('plugins', 'enabled_list', \implode(',', \array_unique($aList))); - $oConfig->Save(); + $oConfig->Set('webmail', 'theme', 'Nextcloud@custom'); + $bSave = true; } -*/ + $bSave && $oConfig->Save(); } } } diff --git a/plugins/nextcloud/index.php b/plugins/nextcloud/index.php index cb351e1e4..543d0bfd7 100644 --- a/plugins/nextcloud/index.php +++ b/plugins/nextcloud/index.php @@ -41,7 +41,6 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin /* \OC::$server->getCalendarManager(); \OC::$server->getLDAPProvider(); - \OC::$server->getAppDataDir('snappymail'); ?? $oFiles = \OCP\Files::getStorage('files'); if ($oFiles and $oFiles->is_dir('/')) {