2022-10-10 23:45:48 +08:00
|
|
|
<?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)
|
|
|
|
{
|
2022-10-11 00:41:15 +08:00
|
|
|
if (static::isLoggedIn()) {
|
|
|
|
if ('suggestions' === $sName) {
|
|
|
|
if (!\is_array($mResult)) {
|
|
|
|
$mResult = array();
|
|
|
|
}
|
|
|
|
include_once __DIR__ . '/NextcloudContactsSuggestions.php';
|
|
|
|
$mResult[] = new NextcloudContactsSuggestions();
|
2022-10-10 23:45:48 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|