Now integrate with Nextcloud by default, but keep iframe option available

This commit is contained in:
the-djmaze 2022-11-04 12:14:22 +01:00
parent 7d3cbcd333
commit e5572975a5
5 changed files with 46 additions and 60 deletions

View file

@ -51,7 +51,7 @@ class FetchController extends Controller {
isset($_POST['snappymail-autologin']) ? '1' === $_POST['snappymail-autologin'] : false);
$this->config->setAppValue('snappymail', 'snappymail-autologin-with-email',
isset($_POST['snappymail-autologin']) ? '2' === $_POST['snappymail-autologin'] : false);
$this->config->setAppValue('snappymail', 'snappymail-embed', isset($_POST['snappymail-embed']));
// $this->config->setAppValue('snappymail', 'snappymail-no-embed', isset($_POST['snappymail-no-embed']));
} else {
return new JSONResponse([
'status' => 'error',

View file

@ -27,63 +27,23 @@ class PageController extends Controller
}
}
if ($bAdmin || $config->getAppValue('snappymail', 'snappymail-embed')) {
return static::index_embed($bAdmin);
if (!$bAdmin && $config->getAppValue('snappymail', 'snappymail-no-embed')) {
\OC::$server->getNavigationManager()->setActiveEntry('snappymail');
\OCP\Util::addScript('snappymail', 'snappymail');
\OCP\Util::addStyle('snappymail', 'style');
SnappyMailHelper::startApp();
$response = new TemplateResponse('snappymail', 'index', [
'snappymail-iframe-url' => SnappyMailHelper::normalizeUrl(SnappyMailHelper::getAppUrl())
. (empty($_GET['target']) ? '' : "#{$_GET['target']}")
]);
$csp = new ContentSecurityPolicy();
$csp->addAllowedFrameDomain("'self'");
$response->setContentSecurityPolicy($csp);
return $response;
}
\OC::$server->getNavigationManager()->setActiveEntry('snappymail');
\OCP\Util::addScript('snappymail', 'snappymail');
\OCP\Util::addStyle('snappymail', 'style');
SnappyMailHelper::startApp();
$response = new TemplateResponse('snappymail', 'index', [
'snappymail-iframe-url' => SnappyMailHelper::normalizeUrl(SnappyMailHelper::getAppUrl())
. (empty($_GET['target']) ? '' : "#{$_GET['target']}")
]);
$csp = new ContentSecurityPolicy();
$csp->addAllowedFrameDomain("'self'");
$response->setContentSecurityPolicy($csp);
return $response;
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function appGet()
{
SnappyMailHelper::startApp(true);
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function appPost()
{
SnappyMailHelper::startApp(true);
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function indexPost()
{
SnappyMailHelper::startApp(true);
}
/**
* Draft code to run without using an iframe
*/
private static function index_embed(bool $bAdmin)
{
\OC::$server->getNavigationManager()->setActiveEntry('snappymail');
\OCP\Util::addStyle('snappymail', 'embed');
SnappyMailHelper::startApp();
@ -132,4 +92,30 @@ class PageController extends Controller
return $response;
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function appGet()
{
SnappyMailHelper::startApp(true);
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function appPost()
{
SnappyMailHelper::startApp(true);
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function indexPost()
{
SnappyMailHelper::startApp(true);
}
}

View file

@ -92,10 +92,10 @@ class Provider implements IProvider
$baseURL = $this->urlGenerator->linkToRoute('snappymail.page.index');
$config = \OC::$server->getConfig();
if ($config->getAppValue('snappymail', 'snappymail-embed')) {
$baseURL .= '#';
} else {
if ($config->getAppValue('snappymail', 'snappymail-no-embed')) {
$baseURL .= '?target=';
} else {
$baseURL .= '#';
}
$search = \rawurlencode($oParams->sSearch);

View file

@ -22,7 +22,7 @@ class AdminSettings implements ISettings
$keys = [
'snappymail-autologin',
'snappymail-autologin-with-email',
'snappymail-embed'
// 'snappymail-no-embed'
];
$parameters = [];
foreach ($keys as $k) {

View file

@ -39,8 +39,8 @@
</p>
<br />
<p>
<input id="snappymail-embed" name="snappymail-embed" type="checkbox" class="checkbox" <?php if ($_['snappymail-embed']) echo 'checked="checked"'; ?>>
<label for="snappymail-embed">Embed without iframe (experimental)</label>
<input id="snappymail-no-embed" name="snappymail-no-embed" type="checkbox" class="checkbox" <?php if ($_['snappymail-no-embed']) echo 'checked="checked"'; ?>>
<label for="snappymail-no-embed">Don't fully integrate in Nextcloud, use in iframe</label>
</p>
<br />
<p>