diff --git a/build/owncloud/rainloop-app/admin.php b/build/owncloud/rainloop-app/admin.php index 3fc6a67bd..3f7a6bf3f 100644 --- a/build/owncloud/rainloop-app/admin.php +++ b/build/owncloud/rainloop-app/admin.php @@ -13,20 +13,7 @@ OCP\User::checkAdminUser(); OCP\Util::addScript('rainloop', 'admin'); -$bInstalledLocaly = file_exists(__DIR__.'/app/index.php'); -if ($bInstalledLocaly) -{ - $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 = new OCP\Template('rainloop', 'admin-local'); +$oTemplate->assign('rainloop-admin-panel-link', OC_RainLoop_Helper::getAppUrl().'?admin'); $oTemplate->assign('rainloop-autologin', OCP\Config::getAppValue('rainloop', 'rainloop-autologin', false)); return $oTemplate->fetchPage(); diff --git a/build/owncloud/rainloop-app/ajax/admin.php b/build/owncloud/rainloop-app/ajax/admin.php index 8c935d93e..29fe17eab 100644 --- a/build/owncloud/rainloop-app/ajax/admin.php +++ b/build/owncloud/rainloop-app/ajax/admin.php @@ -17,32 +17,20 @@ $sUrl = ''; $sPath = ''; $bAutologin = false; -$bInstalledLocaly = file_exists(__DIR__.'/../app/index.php'); - -if (isset($_POST['appname']) && 'rainloop' === $_POST['appname'] && - ($bInstalledLocaly ? true : isset($_POST['rainloop-url'], $_POST['rainloop-path']))) +if (isset($_POST['appname']) && 'rainloop' === $_POST['appname']) { OCP\Config::setAppValue('rainloop', 'rainloop-autologin', isset($_POST['rainloop-autologin']) ? '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); } else { sleep(1); - OC_JSON::error(array('Message' => 'Invalid Argument(s)', 'Url' => $sUrl, 'Path' => $sPath)); + OC_JSON::error(array('Message' => 'Invalid Argument(s)')); return false; } sleep(1); -OCP\JSON::success(array('Message' => 'Saved successfully', 'Url' => $sUrl, 'Path' => $sPath)); +OCP\JSON::success(array('Message' => 'Saved successfully')); return true; diff --git a/build/owncloud/rainloop-app/app.php b/build/owncloud/rainloop-app/app.php index 9fe0f27f8..802dc1a68 100644 --- a/build/owncloud/rainloop-app/app.php +++ b/build/owncloud/rainloop-app/app.php @@ -13,7 +13,7 @@ if (@file_exists(__DIR__.'/app/index.php')) $sUser = OCP\User::getUser(); - if ($bAutologin) + if (OCP\Config::getAppValue('rainloop', 'rainloop-autologin', false)) { $sEmail = $sUser; $sEncodedPassword = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-autologin-password', ''); diff --git a/build/owncloud/rainloop-app/appinfo/app.php b/build/owncloud/rainloop-app/appinfo/app.php index b3d808b56..48dc5ab3d 100644 --- a/build/owncloud/rainloop-app/appinfo/app.php +++ b/build/owncloud/rainloop-app/appinfo/app.php @@ -21,18 +21,13 @@ if (OCP\Config::getAppValue('rainloop', 'rainloop-autologin', false)) OCP\Util::connectHook('OC_User', 'post_setPassword', 'OC_RainLoop_Helper', 'changePassword'); } -$sUrl = trim(OCP\Config::getAppValue('rainloop', 'rainloop-url', '')); -$sPath = trim(OCP\Config::getAppValue('rainloop', 'rainloop-path', '')); +OCP\Util::addScript('rainloop', 'rainloop'); -if (('' !== $sUrl && '' !== $sPath) || OC_User::isAdminUser(OC_User::getUser())) -{ - OCP\Util::addScript('rainloop', 'rainloop'); +OCP\App::addNavigationEntry(array( + 'id' => 'rainloop_index', + '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' - )); -} diff --git a/build/owncloud/rainloop-app/index.php b/build/owncloud/rainloop-app/index.php index 9de5e2c4a..30bbb4f5d 100644 --- a/build/owncloud/rainloop-app/index.php +++ b/build/owncloud/rainloop-app/index.php @@ -15,57 +15,9 @@ OCP\App::setActiveNavigationEntry('rainloop_index'); include_once OC_App::getAppPath('rainloop').'/lib/RainLoopHelper.php'; -$sUrl = ''; -$sPath = ''; +$sUrl = OC_RainLoop_Helper::normalizeUrl(OC_RainLoop_Helper::getAppUrl()); -$bInstalledLocaly = file_exists(__DIR__.'/app/index.php'); -if ($bInstalledLocaly) -{ - $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 = new OCP\Template('rainloop', 'index', 'user'); +$oTemplate->assign('rainloop-iframe-url', OC_RainLoop_Helper::normalizeUrl($sUrl).'?OwnCloudAuth'); $oTemplate->printpage(); diff --git a/build/owncloud/rainloop-app/lib/RainLoopHelper.php b/build/owncloud/rainloop-app/lib/RainLoopHelper.php index c3d1ec1cd..78bdee728 100644 --- a/build/owncloud/rainloop-app/lib/RainLoopHelper.php +++ b/build/owncloud/rainloop-app/lib/RainLoopHelper.php @@ -7,13 +7,9 @@ class OC_RainLoop_Helper */ public static function getAppUrl() { - if (class_exists('\\OC\\URLGenerator') && isset(\OC::$server)) + if (class_exists('\\OCP\\Util')) { - $oUrlGenerator = new \OC\URLGenerator(\OC::$server->getConfig()); - if ($oUrlGenerator) - { - return $oUrlGenerator->linkToRoute('rainloop_app'); - } + return OCP\Util::linkToRoute('rainloop_app'); } $sRequestUri = empty($_SERVER['REQUEST_URI']) ? '': trim($_SERVER['REQUEST_URI']); @@ -105,14 +101,8 @@ class OC_RainLoop_Helper $sEmail = $sUser; $sPassword = $aParams['password']; - $sUrl = trim(OCP\Config::getAppValue('rainloop', 'rainloop-url', '')); - $sPath = trim(OCP\Config::getAppValue('rainloop', 'rainloop-path', '')); - - if ('' !== $sUrl && '' !== $sPath) - { - $sPassword = self::encodePassword($sPassword, md5($sEmail)); - return OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-autologin-password', $sPassword); - } + return OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-autologin-password', + self::encodePassword($sPassword, md5($sEmail))); } return false; @@ -133,16 +123,15 @@ class OC_RainLoop_Helper $sEmail = $sUser; $sPassword = $aParams['password']; - $sUrl = trim(OCP\Config::getAppValue('rainloop', 'rainloop-url', '')); - $sPath = trim(OCP\Config::getAppValue('rainloop', 'rainloop-path', '')); + OCP\Util::writeLog('rainloop', 'rainloop|login: Setting new RainLoop password for '.$sEmail, OCP\Util::DEBUG); - if ('' !== $sUrl && '' !== $sPath) - { - OCP\Util::writeLog('rainloop', 'rainloop|login: Setting new RainLoop password for '.$sEmail, OCP\Util::DEBUG); + OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-autologin-password', + self::encodePassword($sPassword, md5($sEmail))); - $sPassword = self::encodePassword($sPassword, md5($sEmail)); - return OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-password', $sPassword); - } + OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-password', + self::encodePassword($sPassword, md5($sEmail))); + + return true; } return false; diff --git a/build/owncloud/rainloop-app/personal.php b/build/owncloud/rainloop-app/personal.php index 0499d520e..92b1ee659 100644 --- a/build/owncloud/rainloop-app/personal.php +++ b/build/owncloud/rainloop-app/personal.php @@ -14,19 +14,7 @@ OCP\App::checkAppEnabled('rainloop'); OCP\Util::addScript('rainloop', 'personal'); -$sUrl = ''; -$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))) +if (OCP\Config::getAppValue('rainloop', 'rainloop-autologin', false)) { $oTemplate = new OCP\Template('rainloop', 'empty'); } diff --git a/build/owncloud/rainloop-app/templates/admin.php b/build/owncloud/rainloop-app/templates/admin.php deleted file mode 100644 index d2dca468c..000000000 --- a/build/owncloud/rainloop-app/templates/admin.php +++ /dev/null @@ -1,31 +0,0 @@ -
-
- - - -
-

t('RainLoop Webmail')); ?>

-
-

- t('RainLoop Webmail URL')); ?>: -
- -
-
- t('Absolute (full) path to RainLoop Webmail installation')); ?>: -
- -
-
- checked="checked" /> - -
-
- -    -

-
-
-
\ No newline at end of file diff --git a/build/owncloud/rainloop-app/templates/index.php b/build/owncloud/rainloop-app/templates/index.php index d10fd0026..cb4bb0290 100755 --- a/build/owncloud/rainloop-app/templates/index.php +++ b/build/owncloud/rainloop-app/templates/index.php @@ -1,3 +1,3 @@ -
Plugins(), $this->Config() ); - - $oResult->SetLogger($this->Logger()); break; case 'address-book': // \RainLoop\Providers\AddressBook\AddressBookInterface - $sDsn = \trim($this->Config()->Get('contacts', 'pdo_dsn', '')); - $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) + if (!\RainLoop\Utils::IsOwnCloud()) // disabled for ownCloud { - $oResult = new \RainLoop\Providers\AddressBook\PdoAddressBook( - 'sqlite:'.APP_PRIVATE_DATA.'AddressBook.sqlite', '', '', 'sqlite'); - } - else - { - $oResult = new \RainLoop\Providers\AddressBook\PdoAddressBook($sDsn, $sUser, $sPassword, $sDsnType); - } + $sDsn = \trim($this->Config()->Get('contacts', 'pdo_dsn', '')); + $sUser = \trim($this->Config()->Get('contacts', 'pdo_user', '')); + $sPassword = (string) $this->Config()->Get('contacts', 'pdo_password', ''); - $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; case 'suggestions': // \RainLoop\Providers\Suggestions\SuggestionsInterface +// $oResult = new \RainLoop\Providers\Suggestions\TestSuggestions(); + + if (\RainLoop\Utils::IsOwnCloud()) + { + $oResult = new \RainLoop\Providers\Suggestions\OwnCloudSuggestions(); + } + break; case 'change-password': // \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); return $oResult; @@ -2085,6 +2096,7 @@ class Actions 'accounts' ); + $aAccounts = array(); if ('' !== $sAccounts && '{' === \substr($sAccounts, 0, 1)) { $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)) { $aResult = \array_slice($aResult, 0, $iLimit); diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Suggestions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Suggestions.php index b436f2ca4..b66141033 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Suggestions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Suggestions.php @@ -22,12 +22,14 @@ class Suggestions extends \RainLoop\Providers\AbstractProvider /** * @param \RainLoop\Account $oAccount * @param string $sQuery + * @param int $iLimit = 20 * * @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(); } /** diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Suggestions/OwnCloudSuggestions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Suggestions/OwnCloudSuggestions.php new file mode 100644 index 000000000..d941b1341 --- /dev/null +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Suggestions/OwnCloudSuggestions.php @@ -0,0 +1,85 @@ += $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; + } +} diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Suggestions/SuggestionsInterface.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Suggestions/SuggestionsInterface.php index c2f2f6d5a..9d274b9df 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Suggestions/SuggestionsInterface.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Suggestions/SuggestionsInterface.php @@ -7,8 +7,9 @@ interface SuggestionsInterface /** * @param \RainLoop\Model\Account $oAccount * @param string $sQuery + * @param int $iLimit = 20 * * @return array */ - public function Process(\RainLoop\Model\Account $oAccount, $sQuery); + public function Process($oAccount, $sQuery, $iLimit = 20); } \ No newline at end of file diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Suggestions/TestSuggestions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Suggestions/TestSuggestions.php new file mode 100644 index 000000000..fe8e3ee79 --- /dev/null +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Suggestions/TestSuggestions.php @@ -0,0 +1,21 @@ +Email(), ''), + array('xxx@xxx', 'xxx') + ); + } +}