mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
fix email account controller
This commit is contained in:
@@ -46,12 +46,8 @@ class Email extends \Espo\Core\Controllers\Record
|
||||
return $this->getRecordService()->getCopiedAttachments($id);
|
||||
}
|
||||
|
||||
public function actionSendTestEmail($params, $data, $request)
|
||||
public function postActionSendTestEmail($params, $data, $request)
|
||||
{
|
||||
if (!$request->isPost()) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (!$this->getAcl()->checkScope('Email')) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
@@ -34,17 +34,17 @@ use \Espo\Core\Exceptions\BadRequest;
|
||||
|
||||
class EmailAccount extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
public function actionGetFolders($params, $data, $request)
|
||||
public function postActionGetFolders($params, $data)
|
||||
{
|
||||
return $this->getRecordService()->getFolders([
|
||||
'host' => $request->get('host'),
|
||||
'port' => $request->get('port'),
|
||||
'ssl' => $request->get('ssl') === 'true',
|
||||
'username' => $request->get('username'),
|
||||
'password' => $request->get('password'),
|
||||
'id' => $request->get('id'),
|
||||
'emailAddress' => $request->get('emailAddress'),
|
||||
'userId' => $request->get('userId'),
|
||||
'host' => $data->host ?? null,
|
||||
'port' => $data->port ?? null,
|
||||
'ssl' => $data->ssl ?? false,
|
||||
'username' => $data->username ?? null,
|
||||
'password' => $data->password ?? null,
|
||||
'id' => $data->id ?? null,
|
||||
'emailAddress' => $data->emailAddress ?? null,
|
||||
'userId' => $data->userId ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -55,12 +55,8 @@ class EmailAccount extends \Espo\Core\Controllers\Record
|
||||
}
|
||||
}
|
||||
|
||||
public function actionTestConnection($params, $data, $request)
|
||||
public function postActionTestConnection($params, $data, $request)
|
||||
{
|
||||
if (!$request->isPost()) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (is_null($data->password)) {
|
||||
$emailAccount = $this->getEntityManager()->getEntity('EmailAccount', $data->id);
|
||||
if (!$emailAccount || !$emailAccount->id) {
|
||||
@@ -77,4 +73,3 @@ class EmailAccount extends \Espo\Core\Controllers\Record
|
||||
return $this->getRecordService()->testConnection(get_object_vars($data));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,24 +41,20 @@ class InboundEmail extends \Espo\Core\Controllers\Record
|
||||
}
|
||||
}
|
||||
|
||||
public function actionGetFolders($params, $data, $request)
|
||||
public function postActionGetFolders($params, $data, $request)
|
||||
{
|
||||
return $this->getRecordService()->getFolders(array(
|
||||
'host' => $request->get('host'),
|
||||
'port' => $request->get('port'),
|
||||
'ssl' => $request->get('ssl') === 'true',
|
||||
'username' => $request->get('username'),
|
||||
'password' => $request->get('password'),
|
||||
'id' => $request->get('id')
|
||||
));
|
||||
return $this->getRecordService()->getFolders([
|
||||
'host' => $data->host ?? null,
|
||||
'port' => $data->port ?? null,
|
||||
'ssl' => $data->ssl ?? false,
|
||||
'username' => $data->username ?? null,
|
||||
'password' => $data->password ?? null,
|
||||
'id' => $data->id ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionTestConnection($params, $data, $request)
|
||||
public function postActionTestConnection($params, $data, $request)
|
||||
{
|
||||
if (!$request->isPost()) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (is_null($data->password)) {
|
||||
$inboundEmail = $this->getEntityManager()->getEntity('InboundEmail', $data->id);
|
||||
if (!$inboundEmail || !$inboundEmail->id) {
|
||||
@@ -69,5 +65,4 @@ class InboundEmail extends \Espo\Core\Controllers\Record
|
||||
|
||||
return $this->getRecordService()->testConnection(get_object_vars($data));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,9 +34,7 @@ Espo.define('views/email-account/fields/folder', 'views/fields/base', function (
|
||||
|
||||
events: {
|
||||
'click [data-action="selectFolder"]': function () {
|
||||
var self = this;
|
||||
|
||||
this.notify('Please wait...');
|
||||
Espo.Ui.notify(this.translate('pleaseWait', 'messages'));
|
||||
|
||||
var data = {
|
||||
host: this.model.get('host'),
|
||||
@@ -55,26 +53,21 @@ Espo.define('views/email-account/fields/folder', 'views/fields/base', function (
|
||||
}
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: 'EmailAccount/action/getFolders',
|
||||
data: data,
|
||||
error: function (xhr) {
|
||||
Espo.Ui.error(self.translate('couldNotConnectToImap', 'messages', 'EmailAccount'));
|
||||
xhr.errorIsHandled = true;
|
||||
},
|
||||
}).done(function (folders) {
|
||||
Espo.Ajax.postRequest('EmailAccount/action/getFolders', data).then(function (folders) {
|
||||
this.createView('modal', 'views/email-account/modals/select-folder', {
|
||||
folders: folders
|
||||
}, function (view) {
|
||||
self.notify(false);
|
||||
this.notify(false);
|
||||
view.render();
|
||||
|
||||
self.listenToOnce(view, 'select', function (folder) {
|
||||
this.listenToOnce(view, 'select', function (folder) {
|
||||
view.close();
|
||||
self.addFolder(folder);
|
||||
});
|
||||
this.addFolder(folder);
|
||||
}, this);
|
||||
});
|
||||
}.bind(this)).fail(function () {
|
||||
Espo.Ui.error(this.translate('couldNotConnectToImap', 'messages', 'EmailAccount'));
|
||||
xhr.errorIsHandled = true;
|
||||
}.bind(this));
|
||||
}
|
||||
},
|
||||
|
||||
@@ -34,9 +34,7 @@ Espo.define('views/inbound-email/fields/folder', 'views/fields/base', function (
|
||||
|
||||
events: {
|
||||
'click [data-action="selectFolder"]': function () {
|
||||
var self = this;
|
||||
|
||||
this.notify('Please wait...');
|
||||
Espo.Ui.notify(this.translate('pleaseWait', 'messages'));
|
||||
|
||||
var data = {
|
||||
host: this.model.get('host'),
|
||||
@@ -53,27 +51,21 @@ Espo.define('views/inbound-email/fields/folder', 'views/fields/base', function (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: 'InboundEmail/action/getFolders',
|
||||
data: data,
|
||||
error: function (xhr) {
|
||||
Espo.Ui.error(self.translate('couldNotConnectToImap', 'messages', 'InboundEmail'));
|
||||
xhr.errorIsHandled = true;
|
||||
},
|
||||
}).done(function (folders) {
|
||||
Espo.Ajax.postRequest('InboundEmail/action/getFolders', data).then(function (folders) {
|
||||
this.createView('modal', 'views/inbound-email/modals/select-folder', {
|
||||
folders: folders
|
||||
}, function (view) {
|
||||
self.notify(false);
|
||||
this.notify(false);
|
||||
view.render();
|
||||
|
||||
self.listenToOnce(view, 'select', function (folder) {
|
||||
this.listenToOnce(view, 'select', function (folder) {
|
||||
view.close();
|
||||
self.addFolder(folder);
|
||||
});
|
||||
this.addFolder(folder);
|
||||
}, this);
|
||||
});
|
||||
}.bind(this)).fail(function () {
|
||||
Espo.Ui.error(this.translate('couldNotConnectToImap', 'messages', 'InboundEmail'));
|
||||
xhr.errorIsHandled = true;
|
||||
}.bind(this));
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user