mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-06 16:07:03 +03:00
Also fix settings on upgrade inside Nextcloud
This commit is contained in:
parent
82a1f4d781
commit
f6f3040ad2
2 changed files with 33 additions and 43 deletions
|
|
@ -81,5 +81,8 @@ There, click on the link to go to the SnappyMail admin panel.
|
||||||
<install>
|
<install>
|
||||||
<step>OCA\SnappyMail\Migration\InstallStep</step>
|
<step>OCA\SnappyMail\Migration\InstallStep</step>
|
||||||
</install>
|
</install>
|
||||||
|
<post-migration>
|
||||||
|
<step>OCA\SnappyMail\Migration\InstallStep</step>
|
||||||
|
</post-migration>
|
||||||
</repair-steps>
|
</repair-steps>
|
||||||
</info>
|
</info>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,11 @@ use OCP\Migration\IOutput;
|
||||||
use OCP\Migration\IRepairStep;
|
use OCP\Migration\IRepairStep;
|
||||||
use OCP\ILogger;
|
use OCP\ILogger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Note: this is not run at install, but when:
|
||||||
|
* - app is enabled in Admin -> Settings -> Apps
|
||||||
|
* - after upgrade
|
||||||
|
*/
|
||||||
class InstallStep implements IRepairStep
|
class InstallStep implements IRepairStep
|
||||||
{
|
{
|
||||||
public function getName() {
|
public function getName() {
|
||||||
|
|
@ -13,36 +18,23 @@ class InstallStep implements IRepairStep
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run(IOutput $output) {
|
public function run(IOutput $output) {
|
||||||
$_ENV['SNAPPYMAIL_NEXTCLOUD'] = true; // Obsolete
|
|
||||||
$_ENV['SNAPPYMAIL_INCLUDE_AS_API'] = true;
|
|
||||||
|
|
||||||
// define('APP_VERSION', '0.0.0');
|
\clearstatcache();
|
||||||
// define('APP_INDEX_ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
\clearstatcache(true);
|
||||||
// include APP_INDEX_ROOT_PATH.'snappymail/v/'.APP_VERSION.'/include.php';
|
|
||||||
// define('APP_DATA_FOLDER_PATH', \rtrim(\trim(\OC::$server->getSystemConfig()->getValue('datadirectory', '')), '\\/').'/appdata_snappymail/');
|
\OCA\SnappyMail\Util\SnappyMailHelper::loadApp();
|
||||||
|
|
||||||
$app_dir = \dirname(\dirname(__DIR__)) . '/app';
|
$app_dir = \dirname(\dirname(__DIR__)) . '/app';
|
||||||
|
|
||||||
if (!\class_exists('RainLoop\\Api')) {
|
|
||||||
// Nextcloud the default spl_autoload_register() not working
|
|
||||||
\spl_autoload_register(function($sClassName){
|
|
||||||
$file = SNAPPYMAIL_LIBRARIES_PATH . \strtolower(\strtr($sClassName, '\\', DIRECTORY_SEPARATOR)) . '.php';
|
|
||||||
if (\is_file($file)) {
|
|
||||||
include_once $file;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
require_once $app_dir . '/index.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://github.com/the-djmaze/snappymail/issues/790#issuecomment-1366527884
|
// https://github.com/the-djmaze/snappymail/issues/790#issuecomment-1366527884
|
||||||
if (!file_exists($app_dir . '/.htaccess') && file_exists($app_dir . '/_htaccess')) {
|
if (!\file_exists($app_dir . '/.htaccess') && \file_exists($app_dir . '/_htaccess')) {
|
||||||
rename($app_dir . '/_htaccess', $app_dir . '/.htaccess');
|
\rename($app_dir . '/_htaccess', $app_dir . '/.htaccess');
|
||||||
}
|
}
|
||||||
if (!file_exists(APP_VERSION_ROOT_PATH . 'app/.htaccess') && file_exists(APP_VERSION_ROOT_PATH . 'app/_htaccess')) {
|
if (!\file_exists(APP_VERSION_ROOT_PATH . 'app/.htaccess') && \file_exists(APP_VERSION_ROOT_PATH . 'app/_htaccess')) {
|
||||||
rename(APP_VERSION_ROOT_PATH . 'app/_htaccess', APP_VERSION_ROOT_PATH . 'app/.htaccess');
|
\rename(APP_VERSION_ROOT_PATH . 'app/_htaccess', APP_VERSION_ROOT_PATH . 'app/.htaccess');
|
||||||
}
|
}
|
||||||
if (!file_exists(APP_VERSION_ROOT_PATH . 'static/.htaccess') && file_exists(APP_VERSION_ROOT_PATH . 'static/_htaccess')) {
|
if (!\file_exists(APP_VERSION_ROOT_PATH . 'static/.htaccess') && \file_exists(APP_VERSION_ROOT_PATH . 'static/_htaccess')) {
|
||||||
rename(APP_VERSION_ROOT_PATH . 'static/_htaccess', APP_VERSION_ROOT_PATH . 'static/.htaccess');
|
\rename(APP_VERSION_ROOT_PATH . 'static/_htaccess', APP_VERSION_ROOT_PATH . 'static/.htaccess');
|
||||||
}
|
}
|
||||||
|
|
||||||
$oConfig = \RainLoop\Api::Config();
|
$oConfig = \RainLoop\Api::Config();
|
||||||
|
|
@ -72,26 +64,21 @@ class InstallStep implements IRepairStep
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pre-configure domain
|
// Pre-configure domain
|
||||||
$ocConfig = \OC::$server->getConfig();
|
$oProvider = \RainLoop\Api::Actions()->DomainProvider();
|
||||||
if ($ocConfig->getAppValue('snappymail', 'snappymail-autologin', false)
|
$oDomain = $oProvider->Load('nextcloud');
|
||||||
|| $ocConfig->getAppValue('snappymail', 'snappymail-autologin-with-email', false)
|
if (!$oDomain) {
|
||||||
) {
|
// $oDomain = \RainLoop\Model\Domain::fromIniArray('nextcloud', []);
|
||||||
$oProvider = \RainLoop\Api::Actions()->DomainProvider();
|
$oDomain = new \RainLoop\Model\Domain('nextcloud');
|
||||||
$oDomain = $oProvider->Load('nextcloud');
|
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::NONE;
|
||||||
if (!$oDomain) {
|
$oDomain->SetConfig(
|
||||||
// $oDomain = \RainLoop\Model\Domain::fromIniArray('nextcloud', []);
|
'localhost', 143, $iSecurityType, true,
|
||||||
$oDomain = new \RainLoop\Model\Domain('nextcloud');
|
true, 'localhost', 4190, $iSecurityType,
|
||||||
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::NONE;
|
'localhost', 25, $iSecurityType, true, true, false, false,
|
||||||
$oDomain->SetConfig(
|
'');
|
||||||
'localhost', 143, $iSecurityType, true,
|
$oProvider->Save($oDomain);
|
||||||
true, 'localhost', 4190, $iSecurityType,
|
if (!$oConfig->Get('login', 'default_domain', '')) {
|
||||||
'localhost', 25, $iSecurityType, true, true, false, false,
|
$oConfig->Set('login', 'default_domain', 'nextcloud');
|
||||||
'');
|
$bSave = true;
|
||||||
$oProvider->Save($oDomain);
|
|
||||||
if (!$oConfig->Get('login', 'default_domain', '')) {
|
|
||||||
$oConfig->Set('login', 'default_domain', 'nextcloud');
|
|
||||||
$bSave = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue