mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-12-30 03:20:45 +08:00
49 lines
1 KiB
PHP
49 lines
1 KiB
PHP
<?php
|
|
|
|
class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|
{
|
|
const
|
|
NAME = 'Nextcloud',
|
|
VERSION = '1.0',
|
|
RELEASE = '2022-10-10',
|
|
CATEGORY = 'Integrations',
|
|
DESCRIPTION = 'Integrate with Nextcloud',
|
|
REQUIRED = '2.15.2';
|
|
|
|
public function Init() : void
|
|
{
|
|
$this->addHook('main.fabrica', 'MainFabrica');
|
|
}
|
|
|
|
public function Supported() : string
|
|
{
|
|
return static::IsIntegrated() ? '' : 'Not running inside Nextcloud';
|
|
}
|
|
|
|
public static function IsIntegrated()
|
|
{
|
|
// return !empty($_ENV['RAINLOOP_OWNCLOUD']) &&
|
|
return \class_exists('OC') && isset(\OC::$server);
|
|
}
|
|
|
|
public static function IsLoggedIn()
|
|
{
|
|
return static::IsIntegrated() && \OC::$server->getUserSession()->isLoggedIn();
|
|
}
|
|
|
|
/**
|
|
* @param mixed $mResult
|
|
*/
|
|
public function MainFabrica(string $sName, &$mResult)
|
|
{
|
|
if (static::isLoggedIn()) {
|
|
if ('suggestions' === $sName) {
|
|
if (!\is_array($mResult)) {
|
|
$mResult = array();
|
|
}
|
|
include_once __DIR__ . '/NextcloudContactsSuggestions.php';
|
|
$mResult[] = new NextcloudContactsSuggestions();
|
|
}
|
|
}
|
|
}
|
|
}
|