mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-11-03 10:58:50 +03:00
Improved Nextcloud integration for #96
This commit is contained in:
parent
dc241ded1b
commit
5c597c4c1d
10 changed files with 123 additions and 35 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
];
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue