mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Added Google Drive support
This commit is contained in:
parent
7107104e1a
commit
7348b9b8a4
12 changed files with 177 additions and 147 deletions
|
|
@ -9,9 +9,11 @@ function AdminSocial()
|
||||||
|
|
||||||
this.googleEnable = oData.googleEnable;
|
this.googleEnable = oData.googleEnable;
|
||||||
this.googleClientID = oData.googleClientID;
|
this.googleClientID = oData.googleClientID;
|
||||||
|
this.googleApiKey = oData.googleApiKey;
|
||||||
this.googleClientSecret = oData.googleClientSecret;
|
this.googleClientSecret = oData.googleClientSecret;
|
||||||
this.googleTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
|
this.googleTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||||
this.googleTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
|
this.googleTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||||
|
this.googleTrigger3 = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||||
|
|
||||||
this.facebookSupported = oData.facebookSupported;
|
this.facebookSupported = oData.facebookSupported;
|
||||||
this.facebookEnable = oData.facebookEnable;
|
this.facebookEnable = oData.facebookEnable;
|
||||||
|
|
@ -45,6 +47,7 @@ AdminSocial.prototype.onBuild = function ()
|
||||||
f4 = Utils.settingsSaveHelperSimpleFunction(self.twitterTrigger2, self),
|
f4 = Utils.settingsSaveHelperSimpleFunction(self.twitterTrigger2, self),
|
||||||
f5 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger1, self),
|
f5 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger1, self),
|
||||||
f6 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger2, self),
|
f6 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger2, self),
|
||||||
|
f7 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger3, self),
|
||||||
f8 = Utils.settingsSaveHelperSimpleFunction(self.dropboxTrigger1, self)
|
f8 = Utils.settingsSaveHelperSimpleFunction(self.dropboxTrigger1, self)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
@ -111,6 +114,12 @@ AdminSocial.prototype.onBuild = function ()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.googleApiKey.subscribe(function (sValue) {
|
||||||
|
RL.remote().saveAdminConfig(f7, {
|
||||||
|
'GoogleApiKey': Utils.trim(sValue)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
self.dropboxEnable.subscribe(function (bValue) {
|
self.dropboxEnable.subscribe(function (bValue) {
|
||||||
RL.remote().saveAdminConfig(Utils.emptyFunction, {
|
RL.remote().saveAdminConfig(Utils.emptyFunction, {
|
||||||
'DropboxEnable': bValue ? '1' : '0'
|
'DropboxEnable': bValue ? '1' : '0'
|
||||||
|
|
|
||||||
|
|
@ -1118,6 +1118,7 @@ Utils.initDataConstructorBySettings = function (oData)
|
||||||
oData.googleEnable = ko.observable(false);
|
oData.googleEnable = ko.observable(false);
|
||||||
oData.googleClientID = ko.observable('');
|
oData.googleClientID = ko.observable('');
|
||||||
oData.googleClientSecret = ko.observable('');
|
oData.googleClientSecret = ko.observable('');
|
||||||
|
oData.googleApiKey = ko.observable('');
|
||||||
|
|
||||||
oData.dropboxEnable = ko.observable(false);
|
oData.dropboxEnable = ko.observable(false);
|
||||||
oData.dropboxApiKey = ko.observable('');
|
oData.dropboxApiKey = ko.observable('');
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,7 @@ AbstractData.prototype.populateDataOnStart = function()
|
||||||
this.googleEnable(!!RL.settingsGet('AllowGoogleSocial'));
|
this.googleEnable(!!RL.settingsGet('AllowGoogleSocial'));
|
||||||
this.googleClientID(RL.settingsGet('GoogleClientID'));
|
this.googleClientID(RL.settingsGet('GoogleClientID'));
|
||||||
this.googleClientSecret(RL.settingsGet('GoogleClientSecret'));
|
this.googleClientSecret(RL.settingsGet('GoogleClientSecret'));
|
||||||
|
this.googleApiKey(RL.settingsGet('GoogleApiKey'));
|
||||||
|
|
||||||
this.dropboxEnable(!!RL.settingsGet('AllowDropboxSocial'));
|
this.dropboxEnable(!!RL.settingsGet('AllowDropboxSocial'));
|
||||||
this.dropboxApiKey(RL.settingsGet('DropboxApiKey'));
|
this.dropboxApiKey(RL.settingsGet('DropboxApiKey'));
|
||||||
|
|
|
||||||
|
|
@ -347,7 +347,9 @@ function PopupsComposeViewModel()
|
||||||
return this.dropboxEnabled();
|
return this.dropboxEnabled();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.driveEnabled = ko.observable(false && Globals.bXMLHttpRequestSupported && !!RL.settingsGet('GoogleClientID'));
|
this.driveEnabled = ko.observable(Globals.bXMLHttpRequestSupported &&
|
||||||
|
!!RL.settingsGet('GoogleClientID') && !!RL.settingsGet('GoogleApiKey'));
|
||||||
|
|
||||||
this.driveVisible = ko.observable(false);
|
this.driveVisible = ko.observable(false);
|
||||||
|
|
||||||
this.driveCommand = Utils.createCommand(this, function () {
|
this.driveCommand = Utils.createCommand(this, function () {
|
||||||
|
|
@ -994,7 +996,8 @@ PopupsComposeViewModel.prototype.onBuild = function ()
|
||||||
|
|
||||||
PopupsComposeViewModel.prototype.driveCallback = function (sAccessToken, oData)
|
PopupsComposeViewModel.prototype.driveCallback = function (sAccessToken, oData)
|
||||||
{
|
{
|
||||||
if (oData && window.google && oData[window.google.picker.Response.ACTION] === window.google.picker.Action.PICKED &&
|
if (oData && window.XMLHttpRequest && window.google &&
|
||||||
|
oData[window.google.picker.Response.ACTION] === window.google.picker.Action.PICKED &&
|
||||||
oData[window.google.picker.Response.DOCUMENTS] && oData[window.google.picker.Response.DOCUMENTS][0] &&
|
oData[window.google.picker.Response.DOCUMENTS] && oData[window.google.picker.Response.DOCUMENTS][0] &&
|
||||||
oData[window.google.picker.Response.DOCUMENTS][0]['id'])
|
oData[window.google.picker.Response.DOCUMENTS][0]['id'])
|
||||||
{
|
{
|
||||||
|
|
@ -1008,19 +1011,49 @@ PopupsComposeViewModel.prototype.driveCallback = function (sAccessToken, oData)
|
||||||
oRequest.addEventListener('load', function() {
|
oRequest.addEventListener('load', function() {
|
||||||
if (oRequest && oRequest.responseText)
|
if (oRequest && oRequest.responseText)
|
||||||
{
|
{
|
||||||
var oItem = JSON.parse(oRequest.responseText);
|
var oItem = JSON.parse(oRequest.responseText), fExport = function (oItem, sMimeType, sExt) {
|
||||||
|
if (oItem && oItem['exportLinks'])
|
||||||
|
{
|
||||||
|
if (oItem['exportLinks'][sMimeType])
|
||||||
|
{
|
||||||
|
oItem['downloadUrl'] = oItem['exportLinks'][sMimeType];
|
||||||
|
oItem['title'] = oItem['title'] + '.' + sExt;
|
||||||
|
oItem['mimeType'] = sMimeType;
|
||||||
|
}
|
||||||
|
else if (oItem['exportLinks']['application/pdf'])
|
||||||
|
{
|
||||||
|
oItem['downloadUrl'] = oItem['exportLinks']['application/pdf'];
|
||||||
|
oItem['title'] = oItem['title'] + '.pdf';
|
||||||
|
oItem['mimeType'] = 'application/pdf';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (oItem && !oItem['downloadUrl'] && oItem['mimeType'] && oItem['exportLinks'])
|
||||||
|
{
|
||||||
|
switch (oItem['mimeType'].toString().toLowerCase())
|
||||||
|
{
|
||||||
|
case 'application/vnd.google-apps.document':
|
||||||
|
fExport(oItem, 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'docx');
|
||||||
|
break;
|
||||||
|
case 'application/vnd.google-apps.spreadsheet':
|
||||||
|
fExport(oItem, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xlsx');
|
||||||
|
break;
|
||||||
|
case 'application/vnd.google-apps.drawing':
|
||||||
|
fExport(oItem, 'image/png', 'png');
|
||||||
|
break;
|
||||||
|
case 'application/vnd.google-apps.presentation':
|
||||||
|
fExport(oItem, 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'pptx');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fExport(oItem, 'application/pdf', 'pdf');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (oItem && oItem['downloadUrl'])
|
if (oItem && oItem['downloadUrl'])
|
||||||
{
|
{
|
||||||
window.console.log(oItem['downloadUrl']);
|
self.addDriveAttachment(oItem, sAccessToken);
|
||||||
var oSubRequest = new window.XMLHttpRequest();
|
|
||||||
oSubRequest.open('GET', oItem['downloadUrl']);
|
|
||||||
oSubRequest.setRequestHeader('Authorization', 'Bearer ' + sAccessToken);
|
|
||||||
oSubRequest.addEventListener('load', function() {
|
|
||||||
window.console.log(oSubRequest);
|
|
||||||
});
|
|
||||||
|
|
||||||
oSubRequest.send();
|
|
||||||
// self.addDriveAttachment(oItem, sAccessToken);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -1434,11 +1467,11 @@ PopupsComposeViewModel.prototype.addDriveAttachment = function (oDriveFile, sAcc
|
||||||
},
|
},
|
||||||
iAttachmentSizeLimit = Utils.pInt(RL.settingsGet('AttachmentLimit')),
|
iAttachmentSizeLimit = Utils.pInt(RL.settingsGet('AttachmentLimit')),
|
||||||
oAttachment = null,
|
oAttachment = null,
|
||||||
mSize = Utils.pInt(oDriveFile['fileSize'])
|
mSize = oDriveFile['fileSize'] ? Utils.pInt(oDriveFile['fileSize']) : 0
|
||||||
;
|
;
|
||||||
|
|
||||||
oAttachment = new ComposeAttachmentModel(
|
oAttachment = new ComposeAttachmentModel(
|
||||||
oDriveFile['downloadUrl'], oDriveFile['originalFilename'], mSize
|
oDriveFile['downloadUrl'], oDriveFile['title'], mSize
|
||||||
);
|
);
|
||||||
|
|
||||||
oAttachment.fromMessage = false;
|
oAttachment.fromMessage = false;
|
||||||
|
|
@ -1464,7 +1497,8 @@ PopupsComposeViewModel.prototype.addDriveAttachment = function (oDriveFile, sAcc
|
||||||
if (oData.Result[oAttachment.id])
|
if (oData.Result[oAttachment.id])
|
||||||
{
|
{
|
||||||
bResult = true;
|
bResult = true;
|
||||||
oAttachment.tempName(oData.Result[oAttachment.id]);
|
oAttachment.tempName(oData.Result[oAttachment.id][0]);
|
||||||
|
oAttachment.size(Utils.pInt(oData.Result[oAttachment.id][1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -521,12 +521,12 @@ class Http
|
||||||
* @param int $iTimeout = 10
|
* @param int $iTimeout = 10
|
||||||
* @param string $sProxy = ''
|
* @param string $sProxy = ''
|
||||||
* @param string $sProxyAuth = ''
|
* @param string $sProxyAuth = ''
|
||||||
* @param string $sAuthorization = ''
|
* @param array $aHttpHeaders = array()
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function SaveUrlToFile($sUrl, $rFile, $sCustomUserAgent = 'MailSo Http User Agent (v1)', &$sContentType = '', &$iCode = 0,
|
public function SaveUrlToFile($sUrl, $rFile, $sCustomUserAgent = 'MailSo Http User Agent (v1)', &$sContentType = '', &$iCode = 0,
|
||||||
$oLogger = null, $iTimeout = 10, $sProxy = '', $sProxyAuth = '', $sAuthorization = '')
|
$oLogger = null, $iTimeout = 10, $sProxy = '', $sProxyAuth = '', $aHttpHeaders = array())
|
||||||
{
|
{
|
||||||
if (!is_resource($rFile))
|
if (!is_resource($rFile))
|
||||||
{
|
{
|
||||||
|
|
@ -538,8 +538,6 @@ class Http
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$aHeaders = array();
|
|
||||||
|
|
||||||
$aOptions = array(
|
$aOptions = array(
|
||||||
CURLOPT_URL => $sUrl,
|
CURLOPT_URL => $sUrl,
|
||||||
CURLOPT_HEADER => false,
|
CURLOPT_HEADER => false,
|
||||||
|
|
@ -557,11 +555,6 @@ class Http
|
||||||
$aOptions[CURLOPT_USERAGENT] = $sCustomUserAgent;
|
$aOptions[CURLOPT_USERAGENT] = $sCustomUserAgent;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 < \strlen($sAuthorization))
|
|
||||||
{
|
|
||||||
$aHeaders[] = 'Authorization '.$sAuthorization;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 < \strlen($sProxy))
|
if (0 < \strlen($sProxy))
|
||||||
{
|
{
|
||||||
$aOptions[CURLOPT_PROXY] = $sProxy;
|
$aOptions[CURLOPT_PROXY] = $sProxy;
|
||||||
|
|
@ -571,9 +564,9 @@ class Http
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 < \count($aHeaders))
|
if (0 < \count($aHttpHeaders))
|
||||||
{
|
{
|
||||||
$aOptions[CURLOPT_HTTPHEADER] = $aHeaders;
|
$aOptions[CURLOPT_HTTPHEADER] = $aHttpHeaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($oLogger)
|
if ($oLogger)
|
||||||
|
|
@ -617,14 +610,15 @@ class Http
|
||||||
* @param int $iTimeout = 10
|
* @param int $iTimeout = 10
|
||||||
* @param string $sProxy = ''
|
* @param string $sProxy = ''
|
||||||
* @param string $sProxyAuth = ''
|
* @param string $sProxyAuth = ''
|
||||||
|
* @param array $aHttpHeaders = array()
|
||||||
*
|
*
|
||||||
* @return string|bool
|
* @return string|bool
|
||||||
*/
|
*/
|
||||||
public function GetUrlAsString($sUrl, $sCustomUserAgent = 'MailSo Http User Agent (v1)', &$sContentType = '', &$iCode = 0,
|
public function GetUrlAsString($sUrl, $sCustomUserAgent = 'MailSo Http User Agent (v1)', &$sContentType = '', &$iCode = 0,
|
||||||
$oLogger = null, $iTimeout = 10, $sProxy = '', $sProxyAuth = '')
|
$oLogger = null, $iTimeout = 10, $sProxy = '', $sProxyAuth = '', $aHttpHeaders = array())
|
||||||
{
|
{
|
||||||
$rMemFile = \MailSo\Base\ResourceRegistry::CreateMemoryResource();
|
$rMemFile = \MailSo\Base\ResourceRegistry::CreateMemoryResource();
|
||||||
if ($this->SaveUrlToFile($sUrl, $rMemFile, $sCustomUserAgent, $sContentType, $iCode, $oLogger, $iTimeout, $sProxy, $sProxyAuth) && \is_resource($rMemFile))
|
if ($this->SaveUrlToFile($sUrl, $rMemFile, $sCustomUserAgent, $sContentType, $iCode, $oLogger, $iTimeout, $sProxy, $sProxyAuth, $aHttpHeaders) && \is_resource($rMemFile))
|
||||||
{
|
{
|
||||||
\rewind($rMemFile);
|
\rewind($rMemFile);
|
||||||
return \stream_get_contents($rMemFile);
|
return \stream_get_contents($rMemFile);
|
||||||
|
|
|
||||||
|
|
@ -649,89 +649,6 @@ class Actions
|
||||||
return $this->oAddressBookProvider;
|
return $this->oAddressBookProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \OAuth2\Client|null
|
|
||||||
*/
|
|
||||||
public function GoogleConnector()
|
|
||||||
{
|
|
||||||
$oGoogle = false;
|
|
||||||
$oConfig = $this->Config();
|
|
||||||
if ($oConfig->Get('social', 'google_enable', false) &&
|
|
||||||
'' !== \trim($oConfig->Get('social', 'google_client_id', '')) &&
|
|
||||||
'' !== \trim($oConfig->Get('social', 'google_client_secret', '')))
|
|
||||||
{
|
|
||||||
include_once APP_VERSION_ROOT_PATH.'app/libraries/PHP-OAuth2/Client.php';
|
|
||||||
include_once APP_VERSION_ROOT_PATH.'app/libraries/PHP-OAuth2/GrantType/IGrantType.php';
|
|
||||||
include_once APP_VERSION_ROOT_PATH.'app/libraries/PHP-OAuth2/GrantType/AuthorizationCode.php';
|
|
||||||
include_once APP_VERSION_ROOT_PATH.'app/libraries/PHP-OAuth2/GrantType/RefreshToken.php';
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$oGoogle = new \OAuth2\Client(
|
|
||||||
\trim($oConfig->Get('social', 'google_client_id', '')),
|
|
||||||
\trim($oConfig->Get('social', 'google_client_secret', '')));
|
|
||||||
}
|
|
||||||
catch (\Exception $oException)
|
|
||||||
{
|
|
||||||
$this->Logger()->WriteException($oException, \MailSo\Log\Enumerations\Type::ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false === $oGoogle ? null : $oGoogle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \tmhOAuth|null
|
|
||||||
*/
|
|
||||||
public function TwitterConnector()
|
|
||||||
{
|
|
||||||
$oTwitter = false;
|
|
||||||
$oConfig = $this->Config();
|
|
||||||
if ($oConfig->Get('social', 'twitter_enable', false) &&
|
|
||||||
'' !== \trim($oConfig->Get('social', 'twitter_consumer_key', '')) &&
|
|
||||||
'' !== \trim($oConfig->Get('social', 'twitter_consumer_secret', '')))
|
|
||||||
{
|
|
||||||
include_once APP_VERSION_ROOT_PATH.'app/libraries/tmhOAuth/tmhOAuth.php';
|
|
||||||
include_once APP_VERSION_ROOT_PATH.'app/libraries/tmhOAuth/tmhUtilities.php';
|
|
||||||
|
|
||||||
$oTwitter = new \tmhOAuth(array(
|
|
||||||
'consumer_key' => \trim($oConfig->Get('social', 'twitter_consumer_key', '')),
|
|
||||||
'consumer_secret' => \trim($oConfig->Get('social', 'twitter_consumer_secret', ''))
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
return false === $oTwitter ? null : $oTwitter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \RainLoop\Account|null $oAccount = null
|
|
||||||
*
|
|
||||||
* @return \Facebook|null
|
|
||||||
*/
|
|
||||||
public function FacebookConnector($oAccount = null)
|
|
||||||
{
|
|
||||||
$oFacebook = false;
|
|
||||||
$oConfig = $this->Config();
|
|
||||||
if ($oConfig->Get('social', 'fb_enable', false) &&
|
|
||||||
'' !== \trim($oConfig->Get('social', 'fb_app_id', '')) &&
|
|
||||||
'' !== \trim($oConfig->Get('social', 'fb_app_secret', '')))
|
|
||||||
{
|
|
||||||
include_once APP_VERSION_ROOT_PATH.'app/libraries/facebook/facebook.php';
|
|
||||||
|
|
||||||
$oFacebook = new \RainLoopFacebook(array(
|
|
||||||
'rlAccount' => $oAccount,
|
|
||||||
'rlUserHash' => \RainLoop\Utils::GetConnectionToken(),
|
|
||||||
'rlStorageProvaider' => $this->StorageProvider(),
|
|
||||||
'appId' => \trim($oConfig->Get('social', 'fb_app_id', '')),
|
|
||||||
'secret' => \trim($oConfig->Get('social', 'fb_app_secret', '')),
|
|
||||||
'fileUpload' => false,
|
|
||||||
'cookie' => true
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
return false === $oFacebook ? null : $oFacebook;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \MailSo\Cache\CacheClient
|
* @return \MailSo\Cache\CacheClient
|
||||||
*/
|
*/
|
||||||
|
|
@ -1130,11 +1047,13 @@ class Actions
|
||||||
|
|
||||||
$aResult['AllowGoogleSocial'] = (bool) $oConfig->Get('social', 'google_enable', false);
|
$aResult['AllowGoogleSocial'] = (bool) $oConfig->Get('social', 'google_enable', false);
|
||||||
$aResult['GoogleClientID'] = \trim($oConfig->Get('social', 'google_client_id', ''));
|
$aResult['GoogleClientID'] = \trim($oConfig->Get('social', 'google_client_id', ''));
|
||||||
|
$aResult['GoogleApiKey'] = \trim($oConfig->Get('social', 'google_api_key', ''));
|
||||||
if ($aResult['AllowGoogleSocial'] && (
|
if ($aResult['AllowGoogleSocial'] && (
|
||||||
'' === \trim($oConfig->Get('social', 'google_client_id', '')) || '' === \trim($oConfig->Get('social', 'google_client_secret', ''))))
|
'' === \trim($oConfig->Get('social', 'google_client_id', '')) || '' === \trim($oConfig->Get('social', 'google_client_secret', ''))))
|
||||||
{
|
{
|
||||||
$aResult['AllowGoogleSocial'] = false;
|
$aResult['AllowGoogleSocial'] = false;
|
||||||
$aResult['GoogleClientID'] = '';
|
$aResult['GoogleClientID'] = '';
|
||||||
|
$aResult['GoogleApiKey'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$aResult['AllowFacebookSocial'] = (bool) $oConfig->Get('social', 'fb_enable', false);
|
$aResult['AllowFacebookSocial'] = (bool) $oConfig->Get('social', 'fb_enable', false);
|
||||||
|
|
@ -1191,6 +1110,7 @@ class Actions
|
||||||
$aResult['AllowGoogleSocial'] = (bool) $oConfig->Get('social', 'google_enable', false);
|
$aResult['AllowGoogleSocial'] = (bool) $oConfig->Get('social', 'google_enable', false);
|
||||||
$aResult['GoogleClientID'] = (string) $oConfig->Get('social', 'google_client_id', '');
|
$aResult['GoogleClientID'] = (string) $oConfig->Get('social', 'google_client_id', '');
|
||||||
$aResult['GoogleClientSecret'] = (string) $oConfig->Get('social', 'google_client_secret', '');
|
$aResult['GoogleClientSecret'] = (string) $oConfig->Get('social', 'google_client_secret', '');
|
||||||
|
$aResult['GoogleApiKey'] = (string) $oConfig->Get('social', 'google_api_key', '');
|
||||||
|
|
||||||
$aResult['AllowFacebookSocial'] = (bool) $oConfig->Get('social', 'fb_enable', false);
|
$aResult['AllowFacebookSocial'] = (bool) $oConfig->Get('social', 'fb_enable', false);
|
||||||
$aResult['FacebookAppID'] = (string) $oConfig->Get('social', 'fb_app_id', '');
|
$aResult['FacebookAppID'] = (string) $oConfig->Get('social', 'fb_app_id', '');
|
||||||
|
|
@ -2396,6 +2316,7 @@ class Actions
|
||||||
$this->setConfigFromParams($oConfig, 'GoogleEnable', 'social', 'google_enable', 'bool');
|
$this->setConfigFromParams($oConfig, 'GoogleEnable', 'social', 'google_enable', 'bool');
|
||||||
$this->setConfigFromParams($oConfig, 'GoogleClientID', 'social', 'google_client_id', 'string');
|
$this->setConfigFromParams($oConfig, 'GoogleClientID', 'social', 'google_client_id', 'string');
|
||||||
$this->setConfigFromParams($oConfig, 'GoogleClientSecret', 'social', 'google_client_secret', 'string');
|
$this->setConfigFromParams($oConfig, 'GoogleClientSecret', 'social', 'google_client_secret', 'string');
|
||||||
|
$this->setConfigFromParams($oConfig, 'GoogleApiKey', 'social', 'google_api_key', 'string');
|
||||||
|
|
||||||
$this->setConfigFromParams($oConfig, 'FacebookEnable', 'social', 'fb_enable', 'bool');
|
$this->setConfigFromParams($oConfig, 'FacebookEnable', 'social', 'fb_enable', 'bool');
|
||||||
$this->setConfigFromParams($oConfig, 'FacebookAppID', 'social', 'fb_app_id', 'string');
|
$this->setConfigFromParams($oConfig, 'FacebookAppID', 'social', 'fb_app_id', 'string');
|
||||||
|
|
@ -5832,14 +5753,16 @@ class Actions
|
||||||
$oAccount = $this->getAccountFromToken();
|
$oAccount = $this->getAccountFromToken();
|
||||||
|
|
||||||
$mResult = false;
|
$mResult = false;
|
||||||
|
|
||||||
$sUrl = $this->GetActionParam('Url', '');
|
$sUrl = $this->GetActionParam('Url', '');
|
||||||
$sAccessToken = $this->GetActionParam('AccessToken', '');
|
$sAccessToken = $this->GetActionParam('AccessToken', '');
|
||||||
|
$sGoogleApiKey = (string) $this->Config()->Get('social', 'google_api_key', '');
|
||||||
|
|
||||||
if (0 < \strlen($sUrl) && 0 < \strlen($sAccessToken))
|
if (0 < \strlen($sUrl) && 0 < \strlen($sAccessToken) && 0 < \strlen($sGoogleApiKey))
|
||||||
{
|
{
|
||||||
$oHttp = \MailSo\Base\Http::SingletonInstance();
|
$oHttp = \MailSo\Base\Http::SingletonInstance();
|
||||||
|
|
||||||
$mResult[$sUrl] = '';
|
$mResult[$sUrl] = false;
|
||||||
|
|
||||||
$sTempName = \md5($sUrl);
|
$sTempName = \md5($sUrl);
|
||||||
|
|
||||||
|
|
@ -5847,17 +5770,22 @@ class Actions
|
||||||
$sContentType = '';
|
$sContentType = '';
|
||||||
|
|
||||||
$rFile = $this->FilesProvider()->GetFile($oAccount, $sTempName, 'wb+');
|
$rFile = $this->FilesProvider()->GetFile($oAccount, $sTempName, 'wb+');
|
||||||
if ($rFile && $oHttp->SaveUrlToFile($sUrl, $rFile, '', $sContentType, $iCode, $this->Logger(), 60,
|
if ($rFile && $oHttp->SaveUrlToFile($sUrl.'&key='.$sGoogleApiKey, $rFile, '', $sContentType, $iCode, $this->Logger(), 60,
|
||||||
$this->Config()->Get('labs', 'curl_proxy', ''), $this->Config()->Get('labs', 'curl_proxy_auth', ''),
|
$this->Config()->Get('labs', 'curl_proxy', ''), $this->Config()->Get('labs', 'curl_proxy_auth', ''),
|
||||||
'Authorization: Bearer '.$sAccessToken))
|
array('Authorization: Bearer '.$sAccessToken)))
|
||||||
{
|
{
|
||||||
$mResult[$sUrl] = $sTempName;
|
$mResult[$sUrl] = array($sTempName, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\is_resource($rFile))
|
if (\is_resource($rFile))
|
||||||
{
|
{
|
||||||
@\fclose($rFile);
|
@\fclose($rFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($mResult[$sUrl][1]))
|
||||||
|
{
|
||||||
|
$mResult[$sUrl][1] = $rFile = $this->FilesProvider()->FileSize($oAccount, $sTempName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->DefaultResponse(__FUNCTION__, $mResult);
|
return $this->DefaultResponse(__FUNCTION__, $mResult);
|
||||||
|
|
|
||||||
|
|
@ -749,7 +749,6 @@ class Social
|
||||||
\trim($oConfig->Get('social', 'google_client_id', '')),
|
\trim($oConfig->Get('social', 'google_client_id', '')),
|
||||||
\trim($oConfig->Get('social', 'google_client_secret', '')));
|
\trim($oConfig->Get('social', 'google_client_secret', '')));
|
||||||
|
|
||||||
|
|
||||||
$sProxy = $this->oActions->Config()->Get('labs', 'curl_proxy', '');
|
$sProxy = $this->oActions->Config()->Get('labs', 'curl_proxy', '');
|
||||||
if (0 < \strlen($sProxy))
|
if (0 < \strlen($sProxy))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,22 @@
|
||||||
<div data-bind="saveTrigger: googleTrigger2"></div>
|
<div data-bind="saveTrigger: googleTrigger2"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<br />
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label">
|
||||||
|
Api Key
|
||||||
|
</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" class="span5" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||||
|
data-bind="value: googleApiKey, saveTrigger: googleTrigger3" />
|
||||||
|
<div data-bind="saveTrigger: googleTrigger3"></div>
|
||||||
|
<blockquote style="margin-top: 10px; margin-bottom: 0">
|
||||||
|
<p class="muted">
|
||||||
|
Required for Google Drive File Picker
|
||||||
|
</p>
|
||||||
|
</blockquote>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="legend">
|
<div class="legend">
|
||||||
Facebook
|
Facebook
|
||||||
<span style="color: #ccc; font-size: 14px;" data-bind="visible: !facebookSupported()">(requires PHP 5.4 or greater)</span>
|
<span style="color: #ccc; font-size: 14px;" data-bind="visible: !facebookSupported()">(requires PHP 5.4 or greater)</span>
|
||||||
|
|
|
||||||
|
|
@ -1920,6 +1920,7 @@ Utils.initDataConstructorBySettings = function (oData)
|
||||||
oData.googleEnable = ko.observable(false);
|
oData.googleEnable = ko.observable(false);
|
||||||
oData.googleClientID = ko.observable('');
|
oData.googleClientID = ko.observable('');
|
||||||
oData.googleClientSecret = ko.observable('');
|
oData.googleClientSecret = ko.observable('');
|
||||||
|
oData.googleApiKey = ko.observable('');
|
||||||
|
|
||||||
oData.dropboxEnable = ko.observable(false);
|
oData.dropboxEnable = ko.observable(false);
|
||||||
oData.dropboxApiKey = ko.observable('');
|
oData.dropboxApiKey = ko.observable('');
|
||||||
|
|
@ -7034,9 +7035,11 @@ function AdminSocial()
|
||||||
|
|
||||||
this.googleEnable = oData.googleEnable;
|
this.googleEnable = oData.googleEnable;
|
||||||
this.googleClientID = oData.googleClientID;
|
this.googleClientID = oData.googleClientID;
|
||||||
|
this.googleApiKey = oData.googleApiKey;
|
||||||
this.googleClientSecret = oData.googleClientSecret;
|
this.googleClientSecret = oData.googleClientSecret;
|
||||||
this.googleTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
|
this.googleTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||||
this.googleTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
|
this.googleTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||||
|
this.googleTrigger3 = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||||
|
|
||||||
this.facebookSupported = oData.facebookSupported;
|
this.facebookSupported = oData.facebookSupported;
|
||||||
this.facebookEnable = oData.facebookEnable;
|
this.facebookEnable = oData.facebookEnable;
|
||||||
|
|
@ -7070,6 +7073,7 @@ AdminSocial.prototype.onBuild = function ()
|
||||||
f4 = Utils.settingsSaveHelperSimpleFunction(self.twitterTrigger2, self),
|
f4 = Utils.settingsSaveHelperSimpleFunction(self.twitterTrigger2, self),
|
||||||
f5 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger1, self),
|
f5 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger1, self),
|
||||||
f6 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger2, self),
|
f6 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger2, self),
|
||||||
|
f7 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger3, self),
|
||||||
f8 = Utils.settingsSaveHelperSimpleFunction(self.dropboxTrigger1, self)
|
f8 = Utils.settingsSaveHelperSimpleFunction(self.dropboxTrigger1, self)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
@ -7136,6 +7140,12 @@ AdminSocial.prototype.onBuild = function ()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.googleApiKey.subscribe(function (sValue) {
|
||||||
|
RL.remote().saveAdminConfig(f7, {
|
||||||
|
'GoogleApiKey': Utils.trim(sValue)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
self.dropboxEnable.subscribe(function (bValue) {
|
self.dropboxEnable.subscribe(function (bValue) {
|
||||||
RL.remote().saveAdminConfig(Utils.emptyFunction, {
|
RL.remote().saveAdminConfig(Utils.emptyFunction, {
|
||||||
'DropboxEnable': bValue ? '1' : '0'
|
'DropboxEnable': bValue ? '1' : '0'
|
||||||
|
|
@ -7611,6 +7621,7 @@ AbstractData.prototype.populateDataOnStart = function()
|
||||||
this.googleEnable(!!RL.settingsGet('AllowGoogleSocial'));
|
this.googleEnable(!!RL.settingsGet('AllowGoogleSocial'));
|
||||||
this.googleClientID(RL.settingsGet('GoogleClientID'));
|
this.googleClientID(RL.settingsGet('GoogleClientID'));
|
||||||
this.googleClientSecret(RL.settingsGet('GoogleClientSecret'));
|
this.googleClientSecret(RL.settingsGet('GoogleClientSecret'));
|
||||||
|
this.googleApiKey(RL.settingsGet('GoogleApiKey'));
|
||||||
|
|
||||||
this.dropboxEnable(!!RL.settingsGet('AllowDropboxSocial'));
|
this.dropboxEnable(!!RL.settingsGet('AllowDropboxSocial'));
|
||||||
this.dropboxApiKey(RL.settingsGet('DropboxApiKey'));
|
this.dropboxApiKey(RL.settingsGet('DropboxApiKey'));
|
||||||
|
|
|
||||||
8
rainloop/v/0.0.0/static/js/admin.min.js
vendored
8
rainloop/v/0.0.0/static/js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -1923,6 +1923,7 @@ Utils.initDataConstructorBySettings = function (oData)
|
||||||
oData.googleEnable = ko.observable(false);
|
oData.googleEnable = ko.observable(false);
|
||||||
oData.googleClientID = ko.observable('');
|
oData.googleClientID = ko.observable('');
|
||||||
oData.googleClientSecret = ko.observable('');
|
oData.googleClientSecret = ko.observable('');
|
||||||
|
oData.googleApiKey = ko.observable('');
|
||||||
|
|
||||||
oData.dropboxEnable = ko.observable(false);
|
oData.dropboxEnable = ko.observable(false);
|
||||||
oData.dropboxApiKey = ko.observable('');
|
oData.dropboxApiKey = ko.observable('');
|
||||||
|
|
@ -9353,7 +9354,9 @@ function PopupsComposeViewModel()
|
||||||
return this.dropboxEnabled();
|
return this.dropboxEnabled();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.driveEnabled = ko.observable(false && Globals.bXMLHttpRequestSupported && !!RL.settingsGet('GoogleClientID'));
|
this.driveEnabled = ko.observable(Globals.bXMLHttpRequestSupported &&
|
||||||
|
!!RL.settingsGet('GoogleClientID') && !!RL.settingsGet('GoogleApiKey'));
|
||||||
|
|
||||||
this.driveVisible = ko.observable(false);
|
this.driveVisible = ko.observable(false);
|
||||||
|
|
||||||
this.driveCommand = Utils.createCommand(this, function () {
|
this.driveCommand = Utils.createCommand(this, function () {
|
||||||
|
|
@ -10000,7 +10003,8 @@ PopupsComposeViewModel.prototype.onBuild = function ()
|
||||||
|
|
||||||
PopupsComposeViewModel.prototype.driveCallback = function (sAccessToken, oData)
|
PopupsComposeViewModel.prototype.driveCallback = function (sAccessToken, oData)
|
||||||
{
|
{
|
||||||
if (oData && window.google && oData[window.google.picker.Response.ACTION] === window.google.picker.Action.PICKED &&
|
if (oData && window.XMLHttpRequest && window.google &&
|
||||||
|
oData[window.google.picker.Response.ACTION] === window.google.picker.Action.PICKED &&
|
||||||
oData[window.google.picker.Response.DOCUMENTS] && oData[window.google.picker.Response.DOCUMENTS][0] &&
|
oData[window.google.picker.Response.DOCUMENTS] && oData[window.google.picker.Response.DOCUMENTS][0] &&
|
||||||
oData[window.google.picker.Response.DOCUMENTS][0]['id'])
|
oData[window.google.picker.Response.DOCUMENTS][0]['id'])
|
||||||
{
|
{
|
||||||
|
|
@ -10014,19 +10018,49 @@ PopupsComposeViewModel.prototype.driveCallback = function (sAccessToken, oData)
|
||||||
oRequest.addEventListener('load', function() {
|
oRequest.addEventListener('load', function() {
|
||||||
if (oRequest && oRequest.responseText)
|
if (oRequest && oRequest.responseText)
|
||||||
{
|
{
|
||||||
var oItem = JSON.parse(oRequest.responseText);
|
var oItem = JSON.parse(oRequest.responseText), fExport = function (oItem, sMimeType, sExt) {
|
||||||
|
if (oItem && oItem['exportLinks'])
|
||||||
|
{
|
||||||
|
if (oItem['exportLinks'][sMimeType])
|
||||||
|
{
|
||||||
|
oItem['downloadUrl'] = oItem['exportLinks'][sMimeType];
|
||||||
|
oItem['title'] = oItem['title'] + '.' + sExt;
|
||||||
|
oItem['mimeType'] = sMimeType;
|
||||||
|
}
|
||||||
|
else if (oItem['exportLinks']['application/pdf'])
|
||||||
|
{
|
||||||
|
oItem['downloadUrl'] = oItem['exportLinks']['application/pdf'];
|
||||||
|
oItem['title'] = oItem['title'] + '.pdf';
|
||||||
|
oItem['mimeType'] = 'application/pdf';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (oItem && !oItem['downloadUrl'] && oItem['mimeType'] && oItem['exportLinks'])
|
||||||
|
{
|
||||||
|
switch (oItem['mimeType'].toString().toLowerCase())
|
||||||
|
{
|
||||||
|
case 'application/vnd.google-apps.document':
|
||||||
|
fExport(oItem, 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'docx');
|
||||||
|
break;
|
||||||
|
case 'application/vnd.google-apps.spreadsheet':
|
||||||
|
fExport(oItem, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xlsx');
|
||||||
|
break;
|
||||||
|
case 'application/vnd.google-apps.drawing':
|
||||||
|
fExport(oItem, 'image/png', 'png');
|
||||||
|
break;
|
||||||
|
case 'application/vnd.google-apps.presentation':
|
||||||
|
fExport(oItem, 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'pptx');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fExport(oItem, 'application/pdf', 'pdf');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (oItem && oItem['downloadUrl'])
|
if (oItem && oItem['downloadUrl'])
|
||||||
{
|
{
|
||||||
window.console.log(oItem['downloadUrl']);
|
self.addDriveAttachment(oItem, sAccessToken);
|
||||||
var oSubRequest = new window.XMLHttpRequest();
|
|
||||||
oSubRequest.open('GET', oItem['downloadUrl']);
|
|
||||||
oSubRequest.setRequestHeader('Authorization', 'Bearer ' + sAccessToken);
|
|
||||||
oSubRequest.addEventListener('load', function() {
|
|
||||||
window.console.log(oSubRequest);
|
|
||||||
});
|
|
||||||
|
|
||||||
oSubRequest.send();
|
|
||||||
// self.addDriveAttachment(oItem, sAccessToken);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -10440,11 +10474,11 @@ PopupsComposeViewModel.prototype.addDriveAttachment = function (oDriveFile, sAcc
|
||||||
},
|
},
|
||||||
iAttachmentSizeLimit = Utils.pInt(RL.settingsGet('AttachmentLimit')),
|
iAttachmentSizeLimit = Utils.pInt(RL.settingsGet('AttachmentLimit')),
|
||||||
oAttachment = null,
|
oAttachment = null,
|
||||||
mSize = Utils.pInt(oDriveFile['fileSize'])
|
mSize = oDriveFile['fileSize'] ? Utils.pInt(oDriveFile['fileSize']) : 0
|
||||||
;
|
;
|
||||||
|
|
||||||
oAttachment = new ComposeAttachmentModel(
|
oAttachment = new ComposeAttachmentModel(
|
||||||
oDriveFile['downloadUrl'], oDriveFile['originalFilename'], mSize
|
oDriveFile['downloadUrl'], oDriveFile['title'], mSize
|
||||||
);
|
);
|
||||||
|
|
||||||
oAttachment.fromMessage = false;
|
oAttachment.fromMessage = false;
|
||||||
|
|
@ -10470,7 +10504,8 @@ PopupsComposeViewModel.prototype.addDriveAttachment = function (oDriveFile, sAcc
|
||||||
if (oData.Result[oAttachment.id])
|
if (oData.Result[oAttachment.id])
|
||||||
{
|
{
|
||||||
bResult = true;
|
bResult = true;
|
||||||
oAttachment.tempName(oData.Result[oAttachment.id]);
|
oAttachment.tempName(oData.Result[oAttachment.id][0]);
|
||||||
|
oAttachment.size(Utils.pInt(oData.Result[oAttachment.id][1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -16393,6 +16428,7 @@ AbstractData.prototype.populateDataOnStart = function()
|
||||||
this.googleEnable(!!RL.settingsGet('AllowGoogleSocial'));
|
this.googleEnable(!!RL.settingsGet('AllowGoogleSocial'));
|
||||||
this.googleClientID(RL.settingsGet('GoogleClientID'));
|
this.googleClientID(RL.settingsGet('GoogleClientID'));
|
||||||
this.googleClientSecret(RL.settingsGet('GoogleClientSecret'));
|
this.googleClientSecret(RL.settingsGet('GoogleClientSecret'));
|
||||||
|
this.googleApiKey(RL.settingsGet('GoogleApiKey'));
|
||||||
|
|
||||||
this.dropboxEnable(!!RL.settingsGet('AllowDropboxSocial'));
|
this.dropboxEnable(!!RL.settingsGet('AllowDropboxSocial'));
|
||||||
this.dropboxApiKey(RL.settingsGet('DropboxApiKey'));
|
this.dropboxApiKey(RL.settingsGet('DropboxApiKey'));
|
||||||
|
|
|
||||||
19
rainloop/v/0.0.0/static/js/app.min.js
vendored
19
rainloop/v/0.0.0/static/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue