mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 07:35:55 +08:00
Suggestion Provider
OwnCloud Suggestion Driver
This commit is contained in:
parent
d30292d500
commit
000711086a
|
@ -13,20 +13,7 @@ OCP\User::checkAdminUser();
|
||||||
|
|
||||||
OCP\Util::addScript('rainloop', 'admin');
|
OCP\Util::addScript('rainloop', 'admin');
|
||||||
|
|
||||||
$bInstalledLocaly = file_exists(__DIR__.'/app/index.php');
|
$oTemplate = new OCP\Template('rainloop', 'admin-local');
|
||||||
if ($bInstalledLocaly)
|
$oTemplate->assign('rainloop-admin-panel-link', OC_RainLoop_Helper::getAppUrl().'?admin');
|
||||||
{
|
|
||||||
$oTemplate = new OCP\Template('rainloop', 'admin-local');
|
|
||||||
$oTemplate->assign('rainloop-admin-panel-link',
|
|
||||||
OC_RainLoop_Helper::getAppUrl().'?admin');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$oTemplate = new OCP\Template('rainloop', 'admin');
|
|
||||||
$oTemplate->assign('rainloop-admin-panel-link', '');
|
|
||||||
$oTemplate->assign('rainloop-url', OCP\Config::getAppValue('rainloop', 'rainloop-url', ''));
|
|
||||||
$oTemplate->assign('rainloop-path', OCP\Config::getAppValue('rainloop', 'rainloop-path', ''));
|
|
||||||
}
|
|
||||||
|
|
||||||
$oTemplate->assign('rainloop-autologin', OCP\Config::getAppValue('rainloop', 'rainloop-autologin', false));
|
$oTemplate->assign('rainloop-autologin', OCP\Config::getAppValue('rainloop', 'rainloop-autologin', false));
|
||||||
return $oTemplate->fetchPage();
|
return $oTemplate->fetchPage();
|
||||||
|
|
|
@ -17,32 +17,20 @@ $sUrl = '';
|
||||||
$sPath = '';
|
$sPath = '';
|
||||||
$bAutologin = false;
|
$bAutologin = false;
|
||||||
|
|
||||||
$bInstalledLocaly = file_exists(__DIR__.'/../app/index.php');
|
if (isset($_POST['appname']) && 'rainloop' === $_POST['appname'])
|
||||||
|
|
||||||
if (isset($_POST['appname']) && 'rainloop' === $_POST['appname'] &&
|
|
||||||
($bInstalledLocaly ? true : isset($_POST['rainloop-url'], $_POST['rainloop-path'])))
|
|
||||||
{
|
{
|
||||||
OCP\Config::setAppValue('rainloop', 'rainloop-autologin', isset($_POST['rainloop-autologin']) ?
|
OCP\Config::setAppValue('rainloop', 'rainloop-autologin', isset($_POST['rainloop-autologin']) ?
|
||||||
'1' === $_POST['rainloop-autologin'] : false);
|
'1' === $_POST['rainloop-autologin'] : false);
|
||||||
|
|
||||||
if (!$bInstalledLocaly)
|
|
||||||
{
|
|
||||||
OCP\Config::setAppValue('rainloop', 'rainloop-url', $_POST['rainloop-url']);
|
|
||||||
OCP\Config::setAppValue('rainloop', 'rainloop-path', $_POST['rainloop-path']);
|
|
||||||
|
|
||||||
$sUrl = OCP\Config::getAppValue('rainloop', 'rainloop-url', '');
|
|
||||||
$sPath = OCP\Config::getAppValue('rainloop', 'rainloop-path', '');
|
|
||||||
}
|
|
||||||
|
|
||||||
$bAutologin = OCP\Config::getAppValue('rainloop', 'rainloop-autologin', false);
|
$bAutologin = OCP\Config::getAppValue('rainloop', 'rainloop-autologin', false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sleep(1);
|
sleep(1);
|
||||||
OC_JSON::error(array('Message' => 'Invalid Argument(s)', 'Url' => $sUrl, 'Path' => $sPath));
|
OC_JSON::error(array('Message' => 'Invalid Argument(s)'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
OCP\JSON::success(array('Message' => 'Saved successfully', 'Url' => $sUrl, 'Path' => $sPath));
|
OCP\JSON::success(array('Message' => 'Saved successfully'));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -13,7 +13,7 @@ if (@file_exists(__DIR__.'/app/index.php'))
|
||||||
|
|
||||||
$sUser = OCP\User::getUser();
|
$sUser = OCP\User::getUser();
|
||||||
|
|
||||||
if ($bAutologin)
|
if (OCP\Config::getAppValue('rainloop', 'rainloop-autologin', false))
|
||||||
{
|
{
|
||||||
$sEmail = $sUser;
|
$sEmail = $sUser;
|
||||||
$sEncodedPassword = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-autologin-password', '');
|
$sEncodedPassword = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-autologin-password', '');
|
||||||
|
|
|
@ -21,18 +21,13 @@ if (OCP\Config::getAppValue('rainloop', 'rainloop-autologin', false))
|
||||||
OCP\Util::connectHook('OC_User', 'post_setPassword', 'OC_RainLoop_Helper', 'changePassword');
|
OCP\Util::connectHook('OC_User', 'post_setPassword', 'OC_RainLoop_Helper', 'changePassword');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sUrl = trim(OCP\Config::getAppValue('rainloop', 'rainloop-url', ''));
|
OCP\Util::addScript('rainloop', 'rainloop');
|
||||||
$sPath = trim(OCP\Config::getAppValue('rainloop', 'rainloop-path', ''));
|
|
||||||
|
|
||||||
if (('' !== $sUrl && '' !== $sPath) || OC_User::isAdminUser(OC_User::getUser()))
|
OCP\App::addNavigationEntry(array(
|
||||||
{
|
'id' => 'rainloop_index',
|
||||||
OCP\Util::addScript('rainloop', 'rainloop');
|
'order' => 10,
|
||||||
|
'href' => OCP\Util::linkToRoute('rainloop_index'),
|
||||||
|
'icon' => OCP\Util::imagePath('rainloop', 'mail.png'),
|
||||||
|
'name' => 'Email'
|
||||||
|
));
|
||||||
|
|
||||||
OCP\App::addNavigationEntry(array(
|
|
||||||
'id' => 'rainloop_index',
|
|
||||||
'order' => 10,
|
|
||||||
'href' => OCP\Util::linkTo('rainloop', 'index.php'),
|
|
||||||
'icon' => OCP\Util::imagePath('rainloop', 'mail.png'),
|
|
||||||
'name' => 'Email'
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
|
@ -15,57 +15,9 @@ OCP\App::setActiveNavigationEntry('rainloop_index');
|
||||||
|
|
||||||
include_once OC_App::getAppPath('rainloop').'/lib/RainLoopHelper.php';
|
include_once OC_App::getAppPath('rainloop').'/lib/RainLoopHelper.php';
|
||||||
|
|
||||||
$sUrl = '';
|
$sUrl = OC_RainLoop_Helper::normalizeUrl(OC_RainLoop_Helper::getAppUrl());
|
||||||
$sPath = '';
|
|
||||||
|
|
||||||
$bInstalledLocaly = file_exists(__DIR__.'/app/index.php');
|
$oTemplate = new OCP\Template('rainloop', 'index', 'user');
|
||||||
if ($bInstalledLocaly)
|
$oTemplate->assign('rainloop-iframe-url', OC_RainLoop_Helper::normalizeUrl($sUrl).'?OwnCloudAuth');
|
||||||
{
|
|
||||||
$sUrl = OC_RainLoop_Helper::getAppUrl();
|
|
||||||
$sPath = __DIR__.'/app/';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$sUrl = trim(OCP\Config::getAppValue('rainloop', 'rainloop-url', ''));
|
|
||||||
$sPath = trim(OCP\Config::getAppValue('rainloop', 'rainloop-path', ''));
|
|
||||||
}
|
|
||||||
|
|
||||||
$bAutologin = OCP\Config::getAppValue('rainloop', 'rainloop-autologin', false);
|
|
||||||
|
|
||||||
if ('' === $sUrl || '' === $sPath)
|
|
||||||
{
|
|
||||||
$oTemplate = new OCP\Template('rainloop', 'index-empty', 'user');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$sUrl = OC_RainLoop_Helper::normalizeUrl($sUrl);
|
|
||||||
if ($bInstalledLocaly)
|
|
||||||
{
|
|
||||||
$sResultUrl = $sUrl.'?OwnCloudAuth';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$sUser = OCP\User::getUser();
|
|
||||||
|
|
||||||
if ($bAutologin)
|
|
||||||
{
|
|
||||||
$sEmail = $sUser;
|
|
||||||
$sEncodedPassword = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-autologin-password', '');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$sEmail = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-email', '');
|
|
||||||
$sEncodedPassword = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-password', '');
|
|
||||||
}
|
|
||||||
|
|
||||||
$sDecodedPassword = OC_RainLoop_Helper::decodePassword($sEncodedPassword, md5($sEmail));
|
|
||||||
|
|
||||||
$sSsoHash = OC_RainLoop_Helper::getSsoHash($sPath, $sEmail, $sDecodedPassword);
|
|
||||||
$sResultUrl = empty($sSsoHash) ? $sUrl.'?sso' : $sUrl.'?sso&hash='.$sSsoHash;
|
|
||||||
}
|
|
||||||
|
|
||||||
$oTemplate = new OCP\Template('rainloop', 'index', 'user');
|
|
||||||
$oTemplate->assign('rainloop-url', $sResultUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
$oTemplate->printpage();
|
$oTemplate->printpage();
|
||||||
|
|
|
@ -7,13 +7,9 @@ class OC_RainLoop_Helper
|
||||||
*/
|
*/
|
||||||
public static function getAppUrl()
|
public static function getAppUrl()
|
||||||
{
|
{
|
||||||
if (class_exists('\\OC\\URLGenerator') && isset(\OC::$server))
|
if (class_exists('\\OCP\\Util'))
|
||||||
{
|
{
|
||||||
$oUrlGenerator = new \OC\URLGenerator(\OC::$server->getConfig());
|
return OCP\Util::linkToRoute('rainloop_app');
|
||||||
if ($oUrlGenerator)
|
|
||||||
{
|
|
||||||
return $oUrlGenerator->linkToRoute('rainloop_app');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$sRequestUri = empty($_SERVER['REQUEST_URI']) ? '': trim($_SERVER['REQUEST_URI']);
|
$sRequestUri = empty($_SERVER['REQUEST_URI']) ? '': trim($_SERVER['REQUEST_URI']);
|
||||||
|
@ -105,14 +101,8 @@ class OC_RainLoop_Helper
|
||||||
$sEmail = $sUser;
|
$sEmail = $sUser;
|
||||||
$sPassword = $aParams['password'];
|
$sPassword = $aParams['password'];
|
||||||
|
|
||||||
$sUrl = trim(OCP\Config::getAppValue('rainloop', 'rainloop-url', ''));
|
return OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-autologin-password',
|
||||||
$sPath = trim(OCP\Config::getAppValue('rainloop', 'rainloop-path', ''));
|
self::encodePassword($sPassword, md5($sEmail)));
|
||||||
|
|
||||||
if ('' !== $sUrl && '' !== $sPath)
|
|
||||||
{
|
|
||||||
$sPassword = self::encodePassword($sPassword, md5($sEmail));
|
|
||||||
return OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-autologin-password', $sPassword);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -133,16 +123,15 @@ class OC_RainLoop_Helper
|
||||||
$sEmail = $sUser;
|
$sEmail = $sUser;
|
||||||
$sPassword = $aParams['password'];
|
$sPassword = $aParams['password'];
|
||||||
|
|
||||||
$sUrl = trim(OCP\Config::getAppValue('rainloop', 'rainloop-url', ''));
|
OCP\Util::writeLog('rainloop', 'rainloop|login: Setting new RainLoop password for '.$sEmail, OCP\Util::DEBUG);
|
||||||
$sPath = trim(OCP\Config::getAppValue('rainloop', 'rainloop-path', ''));
|
|
||||||
|
|
||||||
if ('' !== $sUrl && '' !== $sPath)
|
OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-autologin-password',
|
||||||
{
|
self::encodePassword($sPassword, md5($sEmail)));
|
||||||
OCP\Util::writeLog('rainloop', 'rainloop|login: Setting new RainLoop password for '.$sEmail, OCP\Util::DEBUG);
|
|
||||||
|
|
||||||
$sPassword = self::encodePassword($sPassword, md5($sEmail));
|
OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-password',
|
||||||
return OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-password', $sPassword);
|
self::encodePassword($sPassword, md5($sEmail)));
|
||||||
}
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -14,19 +14,7 @@ OCP\App::checkAppEnabled('rainloop');
|
||||||
|
|
||||||
OCP\Util::addScript('rainloop', 'personal');
|
OCP\Util::addScript('rainloop', 'personal');
|
||||||
|
|
||||||
$sUrl = '';
|
if (OCP\Config::getAppValue('rainloop', 'rainloop-autologin', false))
|
||||||
$sPath = '';
|
|
||||||
|
|
||||||
$bAutologin = OCP\Config::getAppValue('rainloop', 'rainloop-autologin', false);
|
|
||||||
|
|
||||||
$bInstalledLocaly = file_exists(__DIR__.'/app/index.php');
|
|
||||||
if (!$bInstalledLocaly)
|
|
||||||
{
|
|
||||||
$sUrl = trim(OCP\Config::getAppValue('rainloop', 'rainloop-url', ''));
|
|
||||||
$sPath = trim(OCP\Config::getAppValue('rainloop', 'rainloop-path', ''));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($bAutologin || (!$bInstalledLocaly && ('' === $sUrl || '' === $sPath)))
|
|
||||||
{
|
{
|
||||||
$oTemplate = new OCP\Template('rainloop', 'empty');
|
$oTemplate = new OCP\Template('rainloop', 'empty');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
<div class="section">
|
|
||||||
<form id="mail-rainloop-admin-form" action="#" method="post">
|
|
||||||
<input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>" id="requesttoken">
|
|
||||||
<input type="hidden" name="appname" value="rainloop">
|
|
||||||
|
|
||||||
<fieldset class="personalblock">
|
|
||||||
<h2><?php p($l->t('RainLoop Webmail')); ?></h2>
|
|
||||||
<br />
|
|
||||||
<p>
|
|
||||||
<?php p($l->t('RainLoop Webmail URL')); ?>:
|
|
||||||
<br />
|
|
||||||
<input type="text" style="width:300px;" id="rainloop-url" name="rainloop-url" value="<?php echo $_['rainloop-url']; ?>" placeholder="https://" />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<?php p($l->t('Absolute (full) path to RainLoop Webmail installation')); ?>:
|
|
||||||
<br />
|
|
||||||
<input type="text" style="width:300px;" id="rainloop-path" name="rainloop-path" value="<?php echo $_['rainloop-path']; ?>" />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<input type="checkbox" id="rainloop-autologin" id="rainloop-autologin" name="rainloop-autologin" value="1" <?php if ($_['rainloop-autologin']): ?>checked="checked"<?php endif; ?> />
|
|
||||||
<label for="rainloop-autologin">
|
|
||||||
<?php p($l->t('Automatically login with ownCloud user credentials')); ?>
|
|
||||||
</label>
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<input type="button" id="rainloop-save-button" name="rainloop-save-button" value="<?php p($l->t('Save')); ?>" />
|
|
||||||
<span class="rainloop-result-desc"></span>
|
|
||||||
</p>
|
|
||||||
</fieldset>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
|
@ -1,3 +1,3 @@
|
||||||
<div style="box-sizing: border-box; width: 100%; height: 100%; padding: 0px; margin: 0px; background-color: #383c43; position: relative; overflow: hidden;"
|
<div style="box-sizing: border-box; width: 100%; height: 100%; padding: 0px; margin: 0px; background-color: #383c43; position: relative; overflow: hidden;"
|
||||||
><iframe id="rliframe" style="border: none; width: 100%; height: 100%; position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px;" tabindex="-1" frameborder="0"
|
><iframe id="rliframe" style="border: none; width: 100%; height: 100%; position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px;" tabindex="-1" frameborder="0"
|
||||||
src="<?php echo $_['rainloop-url']; ?>"></iframe></div><?php OCP\Util::addScript('rainloop', 'resize');
|
src="<?php echo $_['rainloop-iframe-url']; ?>"></iframe></div><?php OCP\Util::addScript('rainloop', 'resize');
|
15
gulpfile.js
15
gulpfile.js
|
@ -557,7 +557,7 @@ gulp.task('rainloop:start', ['js:lint', 'rainloop:copy', 'rainloop:setup']);
|
||||||
gulp.task('rainloop', ['rainloop:start', 'rainloop:zip', 'rainloop:md5', 'rainloop:clean']);
|
gulp.task('rainloop', ['rainloop:start', 'rainloop:zip', 'rainloop:md5', 'rainloop:clean']);
|
||||||
|
|
||||||
gulp.task('owncloud', ['rainloop:owncloud:copy',
|
gulp.task('owncloud', ['rainloop:owncloud:copy',
|
||||||
'rainloop:owncloud:copy-rainloop',
|
'rainloop:owncloud:copy-rainloop', 'rainloop:owncloud:copy-rainloop:clean',
|
||||||
'rainloop:owncloud:setup', 'rainloop:owncloud:zip', 'rainloop:owncloud:md5', 'rainloop:owncloud:clean']);
|
'rainloop:owncloud:setup', 'rainloop:owncloud:zip', 'rainloop:owncloud:md5', 'rainloop:owncloud:clean']);
|
||||||
|
|
||||||
//WATCH
|
//WATCH
|
||||||
|
@ -567,12 +567,13 @@ gulp.task('watch', ['fast'], function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
// ALIASES
|
// ALIASES
|
||||||
gulp.task('w', ['watch']);
|
|
||||||
gulp.task('f', ['fast']);
|
|
||||||
|
|
||||||
gulp.task('rl', ['rainloop']);
|
|
||||||
gulp.task('build', ['rainloop']);
|
gulp.task('build', ['rainloop']);
|
||||||
gulp.task('b', ['build']);
|
gulp.task('js:hint', ['js:lint']);
|
||||||
|
|
||||||
gulp.task('own', ['owncloud']);
|
gulp.task('own', ['owncloud']);
|
||||||
gulp.task('js:hint', ['js:lint']);
|
gulp.task('rl', ['rainloop']);
|
||||||
|
gulp.task('w', ['watch']);
|
||||||
|
gulp.task('f', ['fast']);
|
||||||
|
gulp.task('o', ['owncloud']);
|
||||||
|
gulp.task('b', ['build']);
|
||||||
|
gulp.task('h', ['js:lint']);
|
|
@ -278,31 +278,37 @@ class Actions
|
||||||
$oResult = new \RainLoop\Providers\Filters\SieveStorage(
|
$oResult = new \RainLoop\Providers\Filters\SieveStorage(
|
||||||
$this->Plugins(), $this->Config()
|
$this->Plugins(), $this->Config()
|
||||||
);
|
);
|
||||||
|
|
||||||
$oResult->SetLogger($this->Logger());
|
|
||||||
break;
|
break;
|
||||||
case 'address-book':
|
case 'address-book':
|
||||||
// \RainLoop\Providers\AddressBook\AddressBookInterface
|
// \RainLoop\Providers\AddressBook\AddressBookInterface
|
||||||
|
|
||||||
$sDsn = \trim($this->Config()->Get('contacts', 'pdo_dsn', ''));
|
if (!\RainLoop\Utils::IsOwnCloud()) // disabled for ownCloud
|
||||||
$sUser = \trim($this->Config()->Get('contacts', 'pdo_user', ''));
|
|
||||||
$sPassword = (string) $this->Config()->Get('contacts', 'pdo_password', '');
|
|
||||||
|
|
||||||
$sDsnType = $this->ValidateContactPdoType(\trim($this->Config()->Get('contacts', 'type', 'sqlite')));
|
|
||||||
if ('sqlite' === $sDsnType)
|
|
||||||
{
|
{
|
||||||
$oResult = new \RainLoop\Providers\AddressBook\PdoAddressBook(
|
$sDsn = \trim($this->Config()->Get('contacts', 'pdo_dsn', ''));
|
||||||
'sqlite:'.APP_PRIVATE_DATA.'AddressBook.sqlite', '', '', 'sqlite');
|
$sUser = \trim($this->Config()->Get('contacts', 'pdo_user', ''));
|
||||||
}
|
$sPassword = (string) $this->Config()->Get('contacts', 'pdo_password', '');
|
||||||
else
|
|
||||||
{
|
|
||||||
$oResult = new \RainLoop\Providers\AddressBook\PdoAddressBook($sDsn, $sUser, $sPassword, $sDsnType);
|
|
||||||
}
|
|
||||||
|
|
||||||
$oResult->SetLogger($this->Logger());
|
$sDsnType = $this->ValidateContactPdoType(\trim($this->Config()->Get('contacts', 'type', 'sqlite')));
|
||||||
|
if ('sqlite' === $sDsnType)
|
||||||
|
{
|
||||||
|
$oResult = new \RainLoop\Providers\AddressBook\PdoAddressBook(
|
||||||
|
'sqlite:'.APP_PRIVATE_DATA.'AddressBook.sqlite', '', '', 'sqlite');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$oResult = new \RainLoop\Providers\AddressBook\PdoAddressBook($sDsn, $sUser, $sPassword, $sDsnType);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'suggestions':
|
case 'suggestions':
|
||||||
// \RainLoop\Providers\Suggestions\SuggestionsInterface
|
// \RainLoop\Providers\Suggestions\SuggestionsInterface
|
||||||
|
// $oResult = new \RainLoop\Providers\Suggestions\TestSuggestions();
|
||||||
|
|
||||||
|
if (\RainLoop\Utils::IsOwnCloud())
|
||||||
|
{
|
||||||
|
$oResult = new \RainLoop\Providers\Suggestions\OwnCloudSuggestions();
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'change-password':
|
case 'change-password':
|
||||||
// \RainLoop\Providers\ChangePassword\ChangePasswordInterface
|
// \RainLoop\Providers\ChangePassword\ChangePasswordInterface
|
||||||
|
@ -314,6 +320,11 @@ class Actions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($oResult && \method_exists($oResult, 'SetLogger'))
|
||||||
|
{
|
||||||
|
$oResult->SetLogger($this->Logger());
|
||||||
|
}
|
||||||
|
|
||||||
$this->Plugins()->RunHook('filter.fabrica', array($sName, &$oResult, $oAccount), false);
|
$this->Plugins()->RunHook('filter.fabrica', array($sName, &$oResult, $oAccount), false);
|
||||||
|
|
||||||
return $oResult;
|
return $oResult;
|
||||||
|
@ -2085,6 +2096,7 @@ class Actions
|
||||||
'accounts'
|
'accounts'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$aAccounts = array();
|
||||||
if ('' !== $sAccounts && '{' === \substr($sAccounts, 0, 1))
|
if ('' !== $sAccounts && '{' === \substr($sAccounts, 0, 1))
|
||||||
{
|
{
|
||||||
$aAccounts = @\json_decode($sAccounts, true);
|
$aAccounts = @\json_decode($sAccounts, true);
|
||||||
|
@ -6589,6 +6601,20 @@ class Actions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($iLimit > \count($aResult) && 0 < \strlen($sQuery))
|
||||||
|
{
|
||||||
|
$oSuggestionsProvider = $this->SuggestionsProvider();
|
||||||
|
if ($oSuggestionsProvider && $oSuggestionsProvider->IsActive())
|
||||||
|
{
|
||||||
|
$iSuggestionLimit = $iLimit - \count($aResult);
|
||||||
|
$aSuggestionsProviderResult = $oSuggestionsProvider->Process($oAccount, $sQuery, $iSuggestionLimit);
|
||||||
|
if (\is_array($aSuggestionsProviderResult) && 0 < \count($aSuggestionsProviderResult))
|
||||||
|
{
|
||||||
|
$aResult = \array_merge($aResult, $aSuggestionsProviderResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($iLimit < \count($aResult))
|
if ($iLimit < \count($aResult))
|
||||||
{
|
{
|
||||||
$aResult = \array_slice($aResult, 0, $iLimit);
|
$aResult = \array_slice($aResult, 0, $iLimit);
|
||||||
|
|
|
@ -22,12 +22,14 @@ class Suggestions extends \RainLoop\Providers\AbstractProvider
|
||||||
/**
|
/**
|
||||||
* @param \RainLoop\Account $oAccount
|
* @param \RainLoop\Account $oAccount
|
||||||
* @param string $sQuery
|
* @param string $sQuery
|
||||||
|
* @param int $iLimit = 20
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function Process(\RainLoop\Account $oAccount, $sQuery)
|
public function Process(\RainLoop\Account $oAccount, $sQuery, $iLimit = 20)
|
||||||
{
|
{
|
||||||
return $this->oDriver && $this->IsActive() && 0 < \strlen($sQuery) ? $this->oDriver->Process($oAccount, $sQuery) : array();
|
return $this->oDriver && $this->IsActive() && 0 < \strlen($sQuery) ?
|
||||||
|
$this->oDriver->Process($oAccount, $sQuery, $iLimit = 20) : array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace RainLoop\Providers\Suggestions;
|
||||||
|
|
||||||
|
class OwnCloudSuggestions implements \RainLoop\Providers\Suggestions\SuggestionsInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var \MailSo\Log\Logger
|
||||||
|
*/
|
||||||
|
private $oLogger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \RainLoop\Model\Account $oAccount
|
||||||
|
* @param string $sQuery
|
||||||
|
* @param int $iLimit = 20
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function Process($oAccount, $sQuery, $iLimit = 20)
|
||||||
|
{
|
||||||
|
$aResult = array();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!$oAccount || !\RainLoop\Utils::IsOwnCloud() ||
|
||||||
|
!\class_exists('\\OCP\\Contacts') || !\OCP\Contacts::isEnabled())
|
||||||
|
{
|
||||||
|
return $aResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
$aSearchResult = \OCP\Contacts::search($sQuery, array('FN', 'EMAIL'));
|
||||||
|
|
||||||
|
foreach ($aSearchResult as $aContact)
|
||||||
|
{
|
||||||
|
if (0 >= $iLimit)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sUid = empty($aContact['UID']) ? '' : $aContact['UID'];
|
||||||
|
if (!empty($sUid))
|
||||||
|
{
|
||||||
|
$sFullName = isset($aContact['FN']) ? \trim($aContact['FN']) : '';
|
||||||
|
$mEmails = isset($aContact['EMAIL']) ? $aContact['EMAIL'] : '';
|
||||||
|
|
||||||
|
if (!\is_array($mEmails))
|
||||||
|
{
|
||||||
|
$mEmails = array($mEmails);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($mEmails as $sEmail)
|
||||||
|
{
|
||||||
|
$sEmail = \trim($sEmail);
|
||||||
|
if (!empty($sEmail))
|
||||||
|
{
|
||||||
|
$iLimit--;
|
||||||
|
$aResult[$sUid] = array($sEmail, $sFullName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($aSearchResult);
|
||||||
|
|
||||||
|
$aResult = \array_values($aResult);
|
||||||
|
}
|
||||||
|
catch (\Exception $oException)
|
||||||
|
{
|
||||||
|
if ($this->oLogger)
|
||||||
|
{
|
||||||
|
$this->oLogger->WriteException($oException);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $aResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \MailSo\Log\Logger $oLogger
|
||||||
|
*/
|
||||||
|
public function SetLogger($oLogger)
|
||||||
|
{
|
||||||
|
$this->oLogger = $oLogger instanceof \MailSo\Log\Logger ? $oLogger : null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,8 +7,9 @@ interface SuggestionsInterface
|
||||||
/**
|
/**
|
||||||
* @param \RainLoop\Model\Account $oAccount
|
* @param \RainLoop\Model\Account $oAccount
|
||||||
* @param string $sQuery
|
* @param string $sQuery
|
||||||
|
* @param int $iLimit = 20
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function Process(\RainLoop\Model\Account $oAccount, $sQuery);
|
public function Process($oAccount, $sQuery, $iLimit = 20);
|
||||||
}
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace RainLoop\Providers\Suggestions;
|
||||||
|
|
||||||
|
class TestSuggestions implements \RainLoop\Providers\Suggestions\SuggestionsInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param \RainLoop\Model\Account $oAccount
|
||||||
|
* @param string $sQuery
|
||||||
|
* @param int $iLimit = 20
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function Process($oAccount, $sQuery, $iLimit = 20)
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array($oAccount->Email(), ''),
|
||||||
|
array('xxx@xxx', 'xxx')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue