@@ -34,16 +34,7 @@ public function registerHooks()
34
34
public static function startApp (bool $ api = false )
35
35
{
36
36
if (!\class_exists ('RainLoop \\Api ' )) {
37
- if ($ api ) {
38
- $ _ENV ['SNAPPYMAIL_INCLUDE_AS_API ' ] = true ;
39
- }
40
37
$ _ENV ['SNAPPYMAIL_NEXTCLOUD ' ] = true ;
41
- $ _SERVER ['SCRIPT_NAME ' ] = \OC ::$ server ->getAppManager ()->getAppWebPath ('snappymail ' ) . '/app/index.php ' ;
42
-
43
- $ sData = \rtrim (\trim (\OC ::$ server ->getSystemConfig ()->getValue ('datadirectory ' , '' )), '\\/ ' ).'/appdata_snappymail/ ' ;
44
- if (\is_dir ($ sData )) {
45
- \define ('APP_DATA_FOLDER_PATH ' , $ sData );
46
- }
47
38
48
39
// Nextcloud the default spl_autoload_register() not working
49
40
\spl_autoload_register (function ($ sClassName ){
@@ -53,7 +44,40 @@ public static function startApp(bool $api = false)
53
44
}
54
45
});
55
46
56
- require_once \OC ::$ server ->getAppManager ()->getAppPath ('snappymail ' ) . '/app/index.php ' ;
47
+ $ path = \OC ::$ server ->getAppManager ()->getAppPath ('snappymail ' ) . '/app/ ' ;
48
+
49
+ $ sData = \rtrim (\trim (\OC ::$ server ->getSystemConfig ()->getValue ('datadirectory ' , '' )), '\\/ ' ).'/appdata_snappymail/ ' ;
50
+ if (!\is_file ("{$ path }include.php " )) {
51
+ \file_put_contents ("{$ path }include.php " ,
52
+ \file_get_contents ("{$ path }_include.php " )
53
+ . "define('APP_DATA_FOLDER_PATH', ' {$ sData }'); \n"
54
+ );
55
+ }
56
+ // \define('APP_DATA_FOLDER_PATH', $sData);
57
+
58
+ if ($ api ) {
59
+ $ _ENV ['SNAPPYMAIL_INCLUDE_AS_API ' ] = true ;
60
+ }
61
+
62
+ require_once "{$ path }index.php " ;
63
+
64
+ if ($ api ) {
65
+ $ oConfig = \RainLoop \Api::Config ();
66
+ if (!$ oConfig ->Get ('webmail ' , 'app_path ' )) {
67
+ $ oConfig ->Set ('webmail ' , 'app_path ' , \OC ::$ server ->getAppManager ()->getAppWebPath ('snappymail ' ) . '/app/ ' );
68
+ $ oConfig ->Save ();
69
+ }
70
+ /*
71
+ if (!\is_dir(APP_PLUGINS_PATH . 'nextcloud')) {
72
+ \SnappyMail\Repository::installPackage('plugin', 'nextcloud');
73
+ $oConfig->Set('plugins', 'enable', true);
74
+ $aList = \SnappyMail\Repository::getEnabledPackagesNames();
75
+ $aList[] = 'nextcloud';
76
+ $oConfig->Set('plugins', 'enabled_list', \implode(',', \array_unique($aList)));
77
+ $oConfig->Save();
78
+ }
79
+ */
80
+ }
57
81
}
58
82
}
59
83
0 commit comments