mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 20:49:20 +03:00
Capability improvements
Additional branding options
This commit is contained in:
parent
7fce424758
commit
763fae345b
46 changed files with 880 additions and 556 deletions
|
|
@ -893,9 +893,16 @@ class Actions
|
|||
{
|
||||
if (null === $this->oAddressBookProvider)
|
||||
{
|
||||
$this->oAddressBookProvider = new \RainLoop\Providers\AddressBook(
|
||||
$this->Config()->Get('contacts', 'enable', false) || $bForceEnable ? $this->fabrica('address-book', $oAccount) : null);
|
||||
$oDriver = null;
|
||||
if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::CONTACTS, $oAccount))
|
||||
{
|
||||
if ($this->Config()->Get('contacts', 'enable', false) || $bForceEnable)
|
||||
{
|
||||
$oDriver = $this->fabrica('address-book', $oAccount);
|
||||
}
|
||||
}
|
||||
|
||||
$this->oAddressBookProvider = new \RainLoop\Providers\AddressBook($oDriver);
|
||||
$this->oAddressBookProvider->SetLogger($this->Logger());
|
||||
}
|
||||
|
||||
|
|
@ -1078,7 +1085,7 @@ class Actions
|
|||
$this->oLoggerAuth->AddForbiddenType(\MailSo\Log\Enumerations\Type::TIME_DELTA);
|
||||
|
||||
$oDriver = \MailSo\Log\Drivers\File::NewInstance($sAuthLogFileFullPath);
|
||||
|
||||
|
||||
$oDriver->DisableTimePrefix();
|
||||
$oDriver->DisableGuidPrefix();
|
||||
$oDriver->DisableTypedPrefix();
|
||||
|
|
@ -1344,6 +1351,7 @@ class Actions
|
|||
'LoginCss' => '',
|
||||
'UserLogo' => '',
|
||||
'UserLogoTitle' => '',
|
||||
'UserLogoMessage' => '',
|
||||
'UserCss' => '',
|
||||
'WelcomePageUrl' => '',
|
||||
'WelcomePageDisplay' => 'none',
|
||||
|
|
@ -1357,7 +1365,6 @@ class Actions
|
|||
'AllowCtrlEnterOnCompose' => (bool) $oConfig->Get('labs', 'allow_ctrl_enter_on_compose', false),
|
||||
'UseRsaEncryption' => (bool) $oConfig->Get('security', 'use_rsa_encryption', false),
|
||||
'RsaPublicKey' => '',
|
||||
'HideDangerousActions' => $oConfig->Get('labs', 'hide_dangerous_actions', false),
|
||||
'CustomLoginLink' => $oConfig->Get('labs', 'custom_login_link', ''),
|
||||
'CustomLogoutLink' => $oConfig->Get('labs', 'custom_logout_link', ''),
|
||||
'LoginDefaultDomain' => $oConfig->Get('login', 'default_domain', ''),
|
||||
|
|
@ -1383,7 +1390,7 @@ class Actions
|
|||
'Plugins' => array()
|
||||
);
|
||||
|
||||
if ($oConfig->Get('capa', 'attachments_actions', false))
|
||||
if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::ATTACHMENTS_ACTIONS))
|
||||
{
|
||||
if (!!\class_exists('ZipArchive'))
|
||||
{
|
||||
|
|
@ -1404,7 +1411,6 @@ class Actions
|
|||
$aResult['AllowDropboxSocial'] = (bool) $oConfig->Get('social', 'dropbox_enable', false);
|
||||
$aResult['DropboxApiKey'] = \trim($oConfig->Get('social', 'dropbox_api_key', ''));
|
||||
|
||||
|
||||
if ($aResult['UseRsaEncryption'] &&
|
||||
\file_exists(APP_PRIVATE_DATA.'rsa/public') && \file_exists(APP_PRIVATE_DATA.'rsa/private'))
|
||||
{
|
||||
|
|
@ -1417,7 +1423,7 @@ class Actions
|
|||
}
|
||||
}
|
||||
|
||||
if (0 === strlen($aResult['RsaPublicKey']))
|
||||
if (0 === \strlen($aResult['RsaPublicKey']))
|
||||
{
|
||||
$aResult['UseRsaEncryption'] = false;
|
||||
}
|
||||
|
|
@ -2749,7 +2755,7 @@ class Actions
|
|||
*/
|
||||
public function DoAttachmentsActions()
|
||||
{
|
||||
if (!$this->Config()->Get('capa', 'attachments_actions', false))
|
||||
if (!$this->GetCapa(false, \RainLoop\Enumerations\Capa::ATTACHMENTS_ACTIONS))
|
||||
{
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
|
@ -3491,7 +3497,7 @@ class Actions
|
|||
$this->setConfigFromParams($oConfig, $sParamName, 'webmail', 'allow_additional_identities', 'bool');
|
||||
break;
|
||||
case \RainLoop\Enumerations\Capa::TEMPLATES:
|
||||
$this->setConfigFromParams($oConfig, $sParamName, 'capa', 'templates', 'bool');
|
||||
$this->setConfigFromParams($oConfig, $sParamName, 'capa', 'x-templates', 'bool');
|
||||
break;
|
||||
case \RainLoop\Enumerations\Capa::TWO_FACTOR:
|
||||
$this->setConfigFromParams($oConfig, $sParamName, 'security', 'allow_two_factor_auth', 'bool');
|
||||
|
|
@ -5126,9 +5132,6 @@ class Actions
|
|||
*/
|
||||
public function DoFolders()
|
||||
{
|
||||
// \sleep(1);
|
||||
// throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::MailServerError);
|
||||
|
||||
$oAccount = $this->initMailClientConnection();
|
||||
|
||||
$oFolderCollection = null;
|
||||
|
|
@ -5136,7 +5139,8 @@ class Actions
|
|||
|
||||
if (null === $oFolderCollection)
|
||||
{
|
||||
$oFolderCollection = $this->MailClient()->Folders('', '*',
|
||||
$oFolderCollection = $this->MailClient()->Folders('',
|
||||
$this->GetCapa(false, \RainLoop\Enumerations\Capa::FOLDERS, $oAccount) ? '*' : 'INBOX',
|
||||
!!$this->Config()->Get('labs', 'use_imap_list_subscribe', true),
|
||||
(int) $this->Config()->Get('labs', 'imap_folder_list_limit', 200)
|
||||
);
|
||||
|
|
@ -5152,7 +5156,8 @@ class Actions
|
|||
$this->recFoldersTypes($oAccount, $oFolderCollection, $aSystemFolders);
|
||||
$oFolderCollection->SystemFolders = $aSystemFolders;
|
||||
|
||||
if ($this->Config()->Get('labs', 'autocreate_system_folders', true))
|
||||
if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::FOLDERS, $oAccount) &&
|
||||
$this->Config()->Get('labs', 'autocreate_system_folders', true))
|
||||
{
|
||||
$bDoItAgain = false;
|
||||
|
||||
|
|
@ -5272,10 +5277,12 @@ class Actions
|
|||
*/
|
||||
public function DoFolderCreate()
|
||||
{
|
||||
// \sleep(1);
|
||||
// throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantCreateFolder);
|
||||
$oAccount = $this->initMailClientConnection();
|
||||
|
||||
$this->initMailClientConnection();
|
||||
if (!$this->GetCapa(false, \RainLoop\Enumerations\Capa::FOLDERS, $oAccount))
|
||||
{
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -5298,7 +5305,12 @@ class Actions
|
|||
*/
|
||||
public function DoFolderSubscribe()
|
||||
{
|
||||
$this->initMailClientConnection();
|
||||
$oAccount = $this->initMailClientConnection();
|
||||
|
||||
if (!$this->GetCapa(false, \RainLoop\Enumerations\Capa::FOLDERS, $oAccount))
|
||||
{
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
||||
$sFolderFullNameRaw = $this->GetActionParam('Folder', '');
|
||||
$bSubscribe = '1' === (string) $this->GetActionParam('Subscribe', '0');
|
||||
|
|
@ -5329,6 +5341,11 @@ class Actions
|
|||
{
|
||||
$oAccount = $this->getAccountFromToken();
|
||||
|
||||
if (!$this->GetCapa(false, \RainLoop\Enumerations\Capa::FOLDERS, $oAccount))
|
||||
{
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
||||
$sFolderFullNameRaw = $this->GetActionParam('Folder', '');
|
||||
$bCheckable = '1' === (string) $this->GetActionParam('Checkable', '0');
|
||||
|
||||
|
|
@ -5374,7 +5391,12 @@ class Actions
|
|||
*/
|
||||
public function DoFolderRename()
|
||||
{
|
||||
$this->initMailClientConnection();
|
||||
$oAccount = $this->initMailClientConnection();
|
||||
|
||||
if (!$this->GetCapa(false, \RainLoop\Enumerations\Capa::FOLDERS, $oAccount))
|
||||
{
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
||||
$sPrevFolderFullNameRaw = $this->GetActionParam('Folder', '');
|
||||
$sNewTopFolderNameInUtf = $this->GetActionParam('NewFolderName', '');
|
||||
|
|
@ -5399,10 +5421,12 @@ class Actions
|
|||
*/
|
||||
public function DoFolderDelete()
|
||||
{
|
||||
// \sleep(1);
|
||||
// throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantRenameFolder);
|
||||
$oAccount = $this->initMailClientConnection();
|
||||
|
||||
$this->initMailClientConnection();
|
||||
if (!$this->GetCapa(false, \RainLoop\Enumerations\Capa::FOLDERS, $oAccount))
|
||||
{
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
||||
$sFolderFullNameRaw = $this->GetActionParam('Folder', '');
|
||||
|
||||
|
|
@ -5619,7 +5643,8 @@ class Actions
|
|||
$this->cacherForUids(),
|
||||
!!$this->Config()->Get('labs', 'use_imap_sort', false),
|
||||
$bUseThreads,
|
||||
$sThreadUid
|
||||
$sThreadUid,
|
||||
''
|
||||
);
|
||||
}
|
||||
catch (\Exception $oException)
|
||||
|
|
@ -5886,6 +5911,11 @@ class Actions
|
|||
{
|
||||
$oAccount = $this->initMailClientConnection();
|
||||
|
||||
if (!$this->GetCapa(false, \RainLoop\Enumerations\Capa::COMPOSER, $oAccount))
|
||||
{
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
||||
$sMessageFolder = $this->GetActionParam('MessageFolder', '');
|
||||
$sMessageUid = $this->GetActionParam('MessageUid', '');
|
||||
|
||||
|
|
@ -6098,6 +6128,11 @@ class Actions
|
|||
{
|
||||
$oAccount = $this->initMailClientConnection();
|
||||
|
||||
if (!$this->GetCapa(false, \RainLoop\Enumerations\Capa::COMPOSER, $oAccount))
|
||||
{
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
||||
$oConfig = $this->Config();
|
||||
|
||||
$sDraftFolder = $this->GetActionParam('MessageFolder', '');
|
||||
|
|
@ -6283,6 +6318,11 @@ class Actions
|
|||
{
|
||||
$oAccount = $this->initMailClientConnection();
|
||||
|
||||
if (!$this->GetCapa(false, \RainLoop\Enumerations\Capa::COMPOSER, $oAccount))
|
||||
{
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
||||
$oMessage = $this->buildReadReceiptMessage($oAccount);
|
||||
|
||||
$this->Plugins()->RunHook('filter.send-read-receipt-message', array(&$oMessage, $oAccount));
|
||||
|
|
@ -7875,10 +7915,10 @@ class Actions
|
|||
}
|
||||
}
|
||||
|
||||
// if ($oConfig->Get('capa', 'templates', true))
|
||||
// {
|
||||
// $aResult[] = \RainLoop\Enumerations\Capa::TEMPLATES;
|
||||
// }
|
||||
if ($oConfig->Get('capa', 'x-templates', true))
|
||||
{
|
||||
$aResult[] = \RainLoop\Enumerations\Capa::TEMPLATES;
|
||||
}
|
||||
|
||||
if ($oConfig->Get('webmail', 'allow_additional_accounts', false))
|
||||
{
|
||||
|
|
@ -7890,6 +7930,66 @@ class Actions
|
|||
$aResult[] = \RainLoop\Enumerations\Capa::IDENTITIES;
|
||||
}
|
||||
|
||||
if ($oConfig->Get('capa', 'folders', true))
|
||||
{
|
||||
$aResult[] = \RainLoop\Enumerations\Capa::FOLDERS;
|
||||
|
||||
if ($oConfig->Get('capa', 'messagelist_actions', true))
|
||||
{
|
||||
$aResult[] = \RainLoop\Enumerations\Capa::MESSAGELIST_ACTIONS;
|
||||
|
||||
if ($oConfig->Get('capa', 'dangerous_actions', true))
|
||||
{
|
||||
$aResult[] = \RainLoop\Enumerations\Capa::DANGEROUS_ACTIONS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($oConfig->Get('capa', 'reload', true))
|
||||
{
|
||||
$aResult[] = \RainLoop\Enumerations\Capa::RELOAD;
|
||||
}
|
||||
|
||||
if ($oConfig->Get('capa', 'settings', true))
|
||||
{
|
||||
$aResult[] = \RainLoop\Enumerations\Capa::SETTINGS;
|
||||
}
|
||||
|
||||
if ($oConfig->Get('capa', 'help', true))
|
||||
{
|
||||
$aResult[] = \RainLoop\Enumerations\Capa::HELP;
|
||||
}
|
||||
|
||||
if ($oConfig->Get('capa', 'attachments_actions', false))
|
||||
{
|
||||
$aResult[] = \RainLoop\Enumerations\Capa::ATTACHMENTS_ACTIONS;
|
||||
}
|
||||
|
||||
if ($oConfig->Get('capa', 'message_actions', true))
|
||||
{
|
||||
$aResult[] = \RainLoop\Enumerations\Capa::MESSAGE_ACTIONS;
|
||||
}
|
||||
|
||||
if ($oConfig->Get('capa', 'composer', true))
|
||||
{
|
||||
$aResult[] = \RainLoop\Enumerations\Capa::COMPOSER;
|
||||
|
||||
if ($oConfig->Get('capa', 'contacts', true))
|
||||
{
|
||||
$aResult[] = \RainLoop\Enumerations\Capa::CONTACTS;
|
||||
}
|
||||
}
|
||||
|
||||
if ($oConfig->Get('capa', 'search', true))
|
||||
{
|
||||
$aResult[] = \RainLoop\Enumerations\Capa::SEARCH;
|
||||
|
||||
if ($oConfig->Get('capa', 'search_adv', true))
|
||||
{
|
||||
$aResult[] = \RainLoop\Enumerations\Capa::SEARCH_ADV;
|
||||
}
|
||||
}
|
||||
|
||||
if ($oConfig->Get('security', 'allow_two_factor_auth', false) &&
|
||||
($bAdmin || ($oAccount && !$oAccount->IsAdditionalAccount())))
|
||||
{
|
||||
|
|
@ -9219,7 +9319,7 @@ class Actions
|
|||
}
|
||||
else if ('MailSo\Mail\Message' === $sClassName)
|
||||
{
|
||||
$oAccount = call_user_func($fGetAccount);
|
||||
$oAccount = \call_user_func($fGetAccount);
|
||||
|
||||
$mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array(
|
||||
'Folder' => $mResponse->Folder(),
|
||||
|
|
@ -9275,6 +9375,11 @@ class Actions
|
|||
$mResult['IsForwarded'] = 0 < \strlen($sForwardedFlag) && \in_array(\strtolower($sForwardedFlag), $aFlags);
|
||||
$mResult['IsReadReceipt'] = 0 < \strlen($sReadReceiptFlag) && \in_array(\strtolower($sReadReceiptFlag), $aFlags);
|
||||
|
||||
if (!$this->GetCapa(false, \RainLoop\Enumerations\Capa::COMPOSER, $oAccount))
|
||||
{
|
||||
$mResult['IsReadReceipt'] = true;
|
||||
}
|
||||
|
||||
$mResult['TextPartIsTrimmed'] = false;
|
||||
|
||||
if ('Message' === $sParent)
|
||||
|
|
@ -9483,17 +9588,19 @@ class Actions
|
|||
else if ('MailSo\Mail\Folder' === $sClassName)
|
||||
{
|
||||
$aExtended = null;
|
||||
$mStatus = $mResponse->Status();
|
||||
if (\is_array($mStatus) && isset($mStatus['MESSAGES'], $mStatus['UNSEEN'], $mStatus['UIDNEXT']))
|
||||
{
|
||||
$aExtended = array(
|
||||
'MessageCount' => (int) $mStatus['MESSAGES'],
|
||||
'MessageUnseenCount' => (int) $mStatus['UNSEEN'],
|
||||
'UidNext' => (string) $mStatus['UIDNEXT'],
|
||||
'Hash' => $this->MailClient()->GenerateFolderHash(
|
||||
$mResponse->FullNameRaw(), $mStatus['MESSAGES'], $mStatus['UNSEEN'], $mStatus['UIDNEXT'])
|
||||
);
|
||||
}
|
||||
|
||||
// $mStatus = $mResponse->Status();
|
||||
// if (\is_array($mStatus) && isset($mStatus['MESSAGES'], $mStatus['UNSEEN'], $mStatus['UIDNEXT']))
|
||||
// {
|
||||
// $aExtended = array(
|
||||
// 'MessageCount' => (int) $mStatus['MESSAGES'],
|
||||
// 'MessageUnseenCount' => (int) $mStatus['UNSEEN'],
|
||||
// 'UidNext' => (string) $mStatus['UIDNEXT'],
|
||||
// 'Hash' => $this->MailClient()->GenerateFolderHash(
|
||||
// $mResponse->FullNameRaw(), $mStatus['MESSAGES'], $mStatus['UNSEEN'], $mStatus['UIDNEXT'],
|
||||
// empty($mStatus['HIGHESTMODSEQ']) ? '' : $mStatus['HIGHESTMODSEQ'])
|
||||
// );
|
||||
// }
|
||||
|
||||
$aCheckableFolder = \call_user_func($fGetCheckableFolder);
|
||||
if (!\is_array($aCheckableFolder))
|
||||
|
|
|
|||
|
|
@ -91,9 +91,13 @@ class Api
|
|||
\MailSo\Config::$MessageListDateFilter =
|
||||
(int) \RainLoop\Api::Config()->Get('labs', 'imap_message_list_date_filter', 0);
|
||||
|
||||
\MailSo\Config::$MessageListPermanentFilter =
|
||||
\trim(\RainLoop\Api::Config()->Get('labs', 'imap_message_list_permanent_filter', ''));
|
||||
|
||||
\MailSo\Config::$LargeThreadLimit =
|
||||
(int) \RainLoop\Api::Config()->Get('labs', 'imap_large_thread_limit', 50);
|
||||
|
||||
|
||||
\MailSo\Config::$SystemLogger = \RainLoop\Api::Logger();
|
||||
|
||||
$sSslCafile = \RainLoop\Api::Config()->Get('ssl', 'cafile', '');
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ class Application extends \RainLoop\Config\AbstractConfig
|
|||
'login_powered' => array(true),
|
||||
'user_logo' => array(''),
|
||||
'user_logo_title' => array(''),
|
||||
'user_logo_message' => array(''),
|
||||
'user_css' => array(''),
|
||||
'welcome_page_url' => array(''),
|
||||
'welcome_page_display' => array('none')
|
||||
|
|
@ -134,8 +135,19 @@ class Application extends \RainLoop\Config\AbstractConfig
|
|||
),
|
||||
|
||||
'capa' => array(
|
||||
'folders' => array(true),
|
||||
'composer' => array(true),
|
||||
'contacts' => array(true),
|
||||
'settings' => array(true),
|
||||
'help' => array(true),
|
||||
'reload' => array(true),
|
||||
'search' => array(true),
|
||||
'search_adv' => array(true),
|
||||
'filters' => array(true),
|
||||
'templates' => array(true),
|
||||
'x-templates' => array(false),
|
||||
'dangerous_actions' => array(true),
|
||||
'message_actions' => array(true),
|
||||
'messagelist_actions' => array(true),
|
||||
'attachments_actions' => array(true)
|
||||
),
|
||||
|
||||
|
|
@ -299,6 +311,7 @@ Enables caching in the system'),
|
|||
'imap_message_list_fast_simple_search' => array(true),
|
||||
'imap_message_list_count_limit_trigger' => array(0),
|
||||
'imap_message_list_date_filter' => array(0),
|
||||
'imap_message_list_permanent_filter' => array(''),
|
||||
'imap_large_thread_limit' => array(50),
|
||||
'imap_folder_list_limit' => array(200),
|
||||
'imap_show_login_alert' => array(true),
|
||||
|
|
|
|||
|
|
@ -17,6 +17,18 @@ class Capa
|
|||
const ATTACHMENT_THUMBNAILS = 'ATTACHMENT_THUMBNAILS';
|
||||
const ADDITIONAL_ACCOUNTS = 'ADDITIONAL_ACCOUNTS';
|
||||
const IDENTITIES = 'IDENTITIES';
|
||||
const FOLDERS = 'FOLDERS';
|
||||
const COMPOSER = 'COMPOSER';
|
||||
const CONTACTS = 'CONTACTS';
|
||||
const RELOAD = 'RELOAD';
|
||||
const SEARCH = 'SEARCH';
|
||||
const SEARCH_ADV = 'SEARCH_ADV';
|
||||
const SETTINGS = 'SETTINGS';
|
||||
const HELP = 'HELP';
|
||||
const TEMPLATES = 'TEMPLATES';
|
||||
const MESSAGE_ACTIONS = 'MESSAGE_ACTIONS';
|
||||
const MESSAGELIST_ACTIONS = 'MESSAGELIST_ACTIONS';
|
||||
const ATTACHMENTS_ACTIONS = 'ATTACHMENTS_ACTIONS';
|
||||
const DANGEROUS_ACTIONS = 'DANGEROUS_ACTIONS';
|
||||
const AUTOLOGOUT = 'AUTOLOGOUT';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -437,8 +437,18 @@ class Account extends \RainLoop\Account // for backward compatibility
|
|||
}
|
||||
else
|
||||
{
|
||||
$oMailClient->Login($aImapCredentials['Login'], $aImapCredentials['Password'], '',
|
||||
$aImapCredentials['UseAuthPlainIfSupported']);
|
||||
$iGatLen = \strlen(APP_GOOGLE_ACCESS_TOKEN_PREFIX);
|
||||
$sPassword = $aImapCredentials['Password'];
|
||||
if (APP_GOOGLE_ACCESS_TOKEN_PREFIX === \substr($sPassword, 0, $iGatLen))
|
||||
{
|
||||
$oMailClient->LoginWithXOauth2(
|
||||
\base64_encode('user='.$aImapCredentials['Login']."\1".'auth=Bearer '.\substr($sPassword, $iGatLen)."\1\1"));
|
||||
}
|
||||
else
|
||||
{
|
||||
$oMailClient->Login($aImapCredentials['Login'], $aImapCredentials['Password'], '',
|
||||
$aImapCredentials['UseAuthPlainIfSupported']);
|
||||
}
|
||||
}
|
||||
|
||||
$bLogin = true;
|
||||
|
|
@ -495,7 +505,17 @@ class Account extends \RainLoop\Account // for backward compatibility
|
|||
|
||||
if ($aSmtpCredentials['UseAuth'] && !$aSmtpCredentials['UsePhpMail'] && $oSmtpClient)
|
||||
{
|
||||
$oSmtpClient->Login($aSmtpCredentials['Login'], $aSmtpCredentials['Password']);
|
||||
$iGatLen = \strlen(APP_GOOGLE_ACCESS_TOKEN_PREFIX);
|
||||
$sPassword = $aSmtpCredentials['Password'];
|
||||
if (APP_GOOGLE_ACCESS_TOKEN_PREFIX === \substr($sPassword, 0, $iGatLen))
|
||||
{
|
||||
$oSmtpClient->LoginWithXOauth2(
|
||||
\base64_encode('user='.$aSmtpCredentials['Login']."\1".'auth=Bearer '.\substr($sPassword, $iGatLen)."\1\1"));
|
||||
}
|
||||
else
|
||||
{
|
||||
$oSmtpClient->Login($aSmtpCredentials['Login'], $aSmtpCredentials['Password']);
|
||||
}
|
||||
|
||||
$bLogin = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -766,7 +766,8 @@ class ServiceActions
|
|||
*/
|
||||
public function ServiceSocialGoogle()
|
||||
{
|
||||
return $this->oActions->Social()->GooglePopupService();
|
||||
$bXAuth = '1' === (string) $this->oHttp->GetQuery('xauth', '0');
|
||||
return $this->oActions->Social()->GooglePopupService($bXAuth);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class Social
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GooglePopupService()
|
||||
public function GooglePopupService($bGmail = false)
|
||||
{
|
||||
$sResult = '';
|
||||
$sLoginUrl = '';
|
||||
|
|
@ -152,23 +152,36 @@ class Social
|
|||
$sState = $this->oHttp->GetQuery('state');
|
||||
if (!empty($sState))
|
||||
{
|
||||
$aParts = explode('|', $sState, 2);
|
||||
$sCheckToken = !empty($aParts[0]) ? $aParts[0] : '';
|
||||
$sCheckAuth = !empty($aParts[1]) ? $aParts[1] : '';
|
||||
$aParts = explode('|', $sState, 3);
|
||||
|
||||
if (!$bGmail)
|
||||
{
|
||||
$bGmail = !empty($aParts[0]) ? '1' === (string) $aParts[0] : false;
|
||||
}
|
||||
|
||||
$sCheckToken = !empty($aParts[1]) ? $aParts[1] : '';
|
||||
$sCheckAuth = !empty($aParts[2]) ? $aParts[2] : '';
|
||||
}
|
||||
|
||||
$sRedirectUrl = $this->oHttp->GetFullUrl().'?SocialGoogle';
|
||||
if (!$this->oHttp->HasQuery('code'))
|
||||
{
|
||||
// https://www.google.com/m8/feeds/
|
||||
$aParams = array(
|
||||
'scope' => 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile',
|
||||
'state' => \RainLoop\Utils::GetConnectionToken().'|'.$this->oActions->GetSpecAuthToken(),
|
||||
// 'access_type' => 'offline',
|
||||
// 'approval_prompt' => 'force',
|
||||
'scope' => \trim(\implode(' ', array(
|
||||
'https://www.googleapis.com/auth/userinfo.email',
|
||||
'https://www.googleapis.com/auth/userinfo.profile',
|
||||
$bGmail ? 'https://mail.google.com/' : ''
|
||||
))),
|
||||
'state' => ($bGmail ? '1' : '0').'|'.\RainLoop\Utils::GetConnectionToken().'|'.$this->oActions->GetSpecAuthToken(),
|
||||
'response_type' => 'code'
|
||||
);
|
||||
|
||||
// if ($bGmail)
|
||||
// {
|
||||
// $aParams['access_type'] = 'offline';
|
||||
// $aParams['approval_prompt'] = 'force';
|
||||
// }
|
||||
|
||||
$sLoginUrl = $oGoogle->getAuthenticationUrl('https://accounts.google.com/o/oauth2/auth', $sRedirectUrl, $aParams);
|
||||
}
|
||||
else if (!empty($sState) && $sCheckToken === \RainLoop\Utils::GetConnectionToken())
|
||||
|
|
@ -192,12 +205,26 @@ class Social
|
|||
{
|
||||
if ($bLogin)
|
||||
{
|
||||
$sUserData = $this->oActions->StorageProvider()->Get(null,
|
||||
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY,
|
||||
$this->GoogleUserLoginStorageKey($oGoogle, $aUserInfoResponse['result']['id'])
|
||||
);
|
||||
$aUserData = null;
|
||||
if ($bGmail)
|
||||
{
|
||||
if (!empty($aUserInfoResponse['result']['email']))
|
||||
{
|
||||
$aUserData = array(
|
||||
'Email' => $aUserInfoResponse['result']['email'],
|
||||
'Password' => APP_GOOGLE_ACCESS_TOKEN_PREFIX.$aAuthorizationResponse['result']['access_token']
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sUserData = $this->oActions->StorageProvider()->Get(null,
|
||||
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY,
|
||||
$this->GoogleUserLoginStorageKey($oGoogle, $aUserInfoResponse['result']['id'])
|
||||
);
|
||||
|
||||
$aUserData = \RainLoop\Utils::DecodeKeyValues($sUserData);
|
||||
$aUserData = \RainLoop\Utils::DecodeKeyValues($sUserData);
|
||||
}
|
||||
|
||||
if ($aUserData && \is_array($aUserData) &&
|
||||
!empty($aUserData['Email']) && isset($aUserData['Password']))
|
||||
|
|
@ -210,7 +237,7 @@ class Social
|
|||
}
|
||||
}
|
||||
|
||||
if ($oAccount)
|
||||
if ($oAccount && !$bGmail)
|
||||
{
|
||||
$aUserData = array(
|
||||
'ID' => $aUserInfoResponse['result']['id'],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue