mirror of
https://github.com/espocrm/espocrm.git
synced 2026-03-05 19:37:01 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f062ac255a | ||
|
|
3a24784980 | ||
|
|
b1dbd173ad | ||
|
|
a92c294255 | ||
|
|
27624ead8d | ||
|
|
15c980e57f | ||
|
|
a98465f30e | ||
|
|
8862fd279e | ||
|
|
bd6eafd291 | ||
|
|
a63306603a |
@@ -181,7 +181,7 @@ class Container
|
||||
|
||||
protected function loadNumber()
|
||||
{
|
||||
return new \Espo\Core\Utils\Number(
|
||||
return new \Espo\Core\Utils\NumberUtil(
|
||||
$this->get('config')->get('decimalMark'),
|
||||
$this->get('config')->get('thousandSeparator')
|
||||
);
|
||||
|
||||
@@ -34,7 +34,7 @@ use Espo\Core\Exceptions\Error;
|
||||
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
use Espo\Core\Utils\DateTime;
|
||||
use Espo\Core\Utils\Number;
|
||||
use Espo\Core\Utils\NumberUtil;
|
||||
|
||||
require('vendor/zordius/lightncandy/src/lightncandy.php');
|
||||
|
||||
@@ -48,7 +48,7 @@ class Htmlizer
|
||||
|
||||
protected $acl;
|
||||
|
||||
public function __construct(FileManager $fileManager, DateTime $dateTime, Number $number, $acl = null)
|
||||
public function __construct(FileManager $fileManager, DateTime $dateTime, NumberUtil $number, $acl = null)
|
||||
{
|
||||
$this->fileManager = $fileManager;
|
||||
$this->dateTime = $dateTime;
|
||||
|
||||
@@ -39,6 +39,18 @@ class FiltersMatcher
|
||||
|
||||
}
|
||||
|
||||
protected function matchTo(Email $email, $filter)
|
||||
{
|
||||
if ($email->get('to')) {
|
||||
$toArr = explode(';', $email->get('to'));
|
||||
foreach ($toArr as $to) {
|
||||
if ($this->matchString(strtolower($filter->get('to')), strtolower($to))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function match(Email $email, $subject, $skipBody = false)
|
||||
{
|
||||
if (is_array($subject) || $subject instanceof \Traversable) {
|
||||
@@ -48,30 +60,42 @@ class FiltersMatcher
|
||||
}
|
||||
|
||||
foreach ($filterList as $filter) {
|
||||
if ($filter->get('from')) {
|
||||
if ($this->matchString(strtolower($filter->get('from')), strtolower($email->get('from')))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if ($filter->get('to')) {
|
||||
if ($email->get('to')) {
|
||||
$toArr = explode(';', $email->get('to'));
|
||||
foreach ($toArr as $to) {
|
||||
if ($this->matchString(strtolower($filter->get('to')), strtolower($to))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($filter->get('subject')) {
|
||||
if ($this->matchString($filter->get('subject'), $email->get('name'))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$filterCount = 0;
|
||||
|
||||
if (!$skipBody) {
|
||||
if ($this->matchBody($email, $filterList)) {
|
||||
if ($filter->get('from')) {
|
||||
$filterCount++;
|
||||
if (!$this->matchString(strtolower($filter->get('from')), strtolower($email->get('from')))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($filter->get('to')) {
|
||||
$filterCount++;
|
||||
if (!$this->matchTo($email, $filter)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($filter->get('subject')) {
|
||||
$filterCount++;
|
||||
if (!$this->matchString($filter->get('subject'), $email->get('name'))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$wordList = $filter->get('bodyContains');
|
||||
if (!empty($wordList)) {
|
||||
$filterCount++;
|
||||
if ($skipBody) {
|
||||
continue;
|
||||
}
|
||||
if (!$this->matchBody($email, $filter)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($filterCount) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -79,30 +103,19 @@ class FiltersMatcher
|
||||
return false;
|
||||
}
|
||||
|
||||
public function matchBody(Email $email, $subject)
|
||||
protected function matchBody(Email $email, $filter)
|
||||
{
|
||||
if (is_array($subject) || $subject instanceof \Traversable) {
|
||||
$filterList = $subject;
|
||||
} else {
|
||||
$filterList = [$subject];
|
||||
}
|
||||
|
||||
foreach ($filterList as $filter) {
|
||||
if ($filter->get('bodyContains')) {
|
||||
$phraseList = $filter->get('bodyContains');
|
||||
$body = $email->get('body');
|
||||
$bodyPlain = $email->get('bodyPlain');
|
||||
foreach ($phraseList as $phrase) {
|
||||
if (stripos($bodyPlain, $phrase) !== false) {
|
||||
return true;
|
||||
}
|
||||
if (stripos($body, $phrase) !== false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$phraseList = $filter->get('bodyContains');
|
||||
$body = $email->get('body');
|
||||
$bodyPlain = $email->get('bodyPlain');
|
||||
foreach ($phraseList as $phrase) {
|
||||
if (stripos($bodyPlain, $phrase) !== false) {
|
||||
return true;
|
||||
}
|
||||
if (stripos($body, $phrase) !== false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function matchString($pattern, $value)
|
||||
|
||||
@@ -208,7 +208,7 @@ class Importer
|
||||
$email->set('body', $body);
|
||||
}
|
||||
|
||||
if ($this->getFiltersMatcher()->matchBody($email, $filterList)) {
|
||||
if ($this->getFiltersMatcher()->match($email, $filterList)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -185,6 +185,11 @@ class Language
|
||||
$options = $this->get($scope. '.options.' . $field);
|
||||
if (is_array($options) && array_key_exists($value, $options)) {
|
||||
return $options[$value];
|
||||
} else if ($scope !== 'Global') {
|
||||
$options = $this->get('Global.options.' . $field);
|
||||
if (is_array($options) && array_key_exists($value, $options)) {
|
||||
return $options[$value];
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Utils;
|
||||
|
||||
class Number
|
||||
class NumberUtil
|
||||
{
|
||||
protected $decimalMark;
|
||||
|
||||
@@ -104,6 +104,9 @@ class Email extends \Espo\Core\Notificators\Base
|
||||
$this->getEntityManager()->getRepository('Email')->loadFromField($entity);
|
||||
}
|
||||
|
||||
if (!$entity->has('to')) {
|
||||
$this->getEntityManager()->getRepository('Email')->loadToField($entity);
|
||||
}
|
||||
$person = null;
|
||||
|
||||
$from = $entity->get('from');
|
||||
|
||||
@@ -80,6 +80,45 @@ class Email extends \Espo\Core\ORM\Repositories\RDB
|
||||
}
|
||||
}
|
||||
|
||||
public function loadToField(Entity $entity)
|
||||
{
|
||||
$entity->loadLinkMultipleField('toEmailAddresses');
|
||||
$names = $entity->get('toEmailAddressesNames');
|
||||
if (!empty($names)) {
|
||||
$arr = array();
|
||||
foreach ($names as $id => $address) {
|
||||
$arr[] = $address;
|
||||
}
|
||||
$entity->set('to', implode(';', $arr));
|
||||
}
|
||||
}
|
||||
|
||||
public function loadCcField(Entity $entity)
|
||||
{
|
||||
$entity->loadLinkMultipleField('ccEmailAddresses');
|
||||
$names = $entity->get('ccEmailAddressesNames');
|
||||
if (!empty($names)) {
|
||||
$arr = array();
|
||||
foreach ($names as $id => $address) {
|
||||
$arr[] = $address;
|
||||
}
|
||||
$entity->set('cc', implode(';', $arr));
|
||||
}
|
||||
}
|
||||
|
||||
public function loadBccField(Entity $entity)
|
||||
{
|
||||
$entity->loadLinkMultipleField('bccEmailAddresses');
|
||||
$names = $entity->get('bccEmailAddressesNames');
|
||||
if (!empty($names)) {
|
||||
$arr = array();
|
||||
foreach ($names as $id => $address) {
|
||||
$arr[] = $address;
|
||||
}
|
||||
$entity->set('bcc', implode(';', $arr));
|
||||
}
|
||||
}
|
||||
|
||||
public function loadNameHash(Entity $entity, array $fieldList = ['from', 'to', 'cc'])
|
||||
{
|
||||
$addressList = array();
|
||||
@@ -201,6 +240,12 @@ class Email extends \Espo\Core\ORM\Repositories\RDB
|
||||
}
|
||||
|
||||
if ($entity->get('isBeingImported')) {
|
||||
if (!$entity->has('from')) {
|
||||
$this->loadFromField($entity);
|
||||
}
|
||||
if (!$entity->has('to')) {
|
||||
$this->loadToField($entity);
|
||||
}
|
||||
foreach ($entity->getLinkMultipleIdList('users') as $userId) {
|
||||
$filter = $this->getEmailFilterManager()->getMatchingFilter($entity, $userId);
|
||||
if ($filter) {
|
||||
|
||||
@@ -250,41 +250,17 @@ class Email extends Record
|
||||
|
||||
public function loadToField(Entity $entity)
|
||||
{
|
||||
$entity->loadLinkMultipleField('toEmailAddresses');
|
||||
$names = $entity->get('toEmailAddressesNames');
|
||||
if (!empty($names)) {
|
||||
$arr = array();
|
||||
foreach ($names as $id => $address) {
|
||||
$arr[] = $address;
|
||||
}
|
||||
$entity->set('to', implode(';', $arr));
|
||||
}
|
||||
$this->getEntityManager()->getRepository('Email')->loadToField($entity);
|
||||
}
|
||||
|
||||
public function loadCcField(Entity $entity)
|
||||
{
|
||||
$entity->loadLinkMultipleField('ccEmailAddresses');
|
||||
$names = $entity->get('ccEmailAddressesNames');
|
||||
if (!empty($names)) {
|
||||
$arr = array();
|
||||
foreach ($names as $id => $address) {
|
||||
$arr[] = $address;
|
||||
}
|
||||
$entity->set('cc', implode(';', $arr));
|
||||
}
|
||||
$this->getEntityManager()->getRepository('Email')->loadCcField($entity);
|
||||
}
|
||||
|
||||
public function loadBccField(Entity $entity)
|
||||
{
|
||||
$entity->loadLinkMultipleField('bccEmailAddresses');
|
||||
$names = $entity->get('bccEmailAddressesNames');
|
||||
if (!empty($names)) {
|
||||
$arr = array();
|
||||
foreach ($names as $id => $address) {
|
||||
$arr[] = $address;
|
||||
}
|
||||
$entity->set('bcc', implode(';', $arr));
|
||||
}
|
||||
$this->getEntityManager()->getRepository('Email')->loadBccField($entity);
|
||||
}
|
||||
|
||||
public function getEntity($id = null)
|
||||
|
||||
@@ -101,12 +101,6 @@ Espo.define('views/admin/layouts/base', 'view', function (Dep) {
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
cancel: function () {
|
||||
this.loadLayout(function () {
|
||||
this.render();
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
reset: function () {
|
||||
this.render();
|
||||
},
|
||||
|
||||
@@ -40,7 +40,12 @@ Espo.define('views/admin/layouts/filters', 'views/admin/layouts/rows', function
|
||||
Dep.prototype.setup.call(this);
|
||||
|
||||
this.wait(true);
|
||||
this.loadLayout(function () {
|
||||
this.wait(false);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
loadLayout: function (callback) {
|
||||
this.getModelFactory().create(this.scope, function (model) {
|
||||
this.getHelper().layoutManager.get(this.scope, this.type, function (layout) {
|
||||
|
||||
@@ -80,7 +85,7 @@ Espo.define('views/admin/layouts/filters', 'views/admin/layouts/rows', function
|
||||
this.rowLayout[i].label = this.getLanguage().translate(this.rowLayout[i].name, 'fields', this.scope);
|
||||
}
|
||||
|
||||
this.wait(false);
|
||||
callback();
|
||||
}.bind(this), false);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
@@ -42,7 +42,12 @@ Espo.define('views/admin/layouts/mass-update', 'views/admin/layouts/rows', funct
|
||||
Dep.prototype.setup.call(this);
|
||||
|
||||
this.wait(true);
|
||||
this.loadLayout(function () {
|
||||
this.wait(false);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
loadLayout: function (callback) {
|
||||
this.getModelFactory().create(this.scope, function (model) {
|
||||
this.getHelper().layoutManager.get(this.scope, this.type, function (layout) {
|
||||
|
||||
@@ -83,7 +88,7 @@ Espo.define('views/admin/layouts/mass-update', 'views/admin/layouts/rows', funct
|
||||
this.rowLayout[i].label = this.getLanguage().translate(this.rowLayout[i].name, 'fields', this.scope);
|
||||
}
|
||||
|
||||
this.wait(false);
|
||||
callback();
|
||||
}.bind(this), false);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
@@ -38,7 +38,12 @@ Espo.define('views/admin/layouts/relationships', 'views/admin/layouts/rows', fun
|
||||
Dep.prototype.setup.call(this);
|
||||
|
||||
this.wait(true);
|
||||
this.loadLayout(function () {
|
||||
this.wait(false);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
loadLayout: function (callback) {
|
||||
this.getModelFactory().create(this.scope, function (model) {
|
||||
this.getHelper().layoutManager.get(this.scope, this.type, function (layout) {
|
||||
|
||||
@@ -80,7 +85,7 @@ Espo.define('views/admin/layouts/relationships', 'views/admin/layouts/rows', fun
|
||||
this.rowLayout[i].label = this.getLanguage().translate(this.rowLayout[i].name, 'links', this.scope);
|
||||
}
|
||||
|
||||
this.wait(false);
|
||||
callback();
|
||||
}.bind(this), false);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
@@ -129,7 +129,18 @@ Espo.define('views/notification/badge', 'view', function (Dep) {
|
||||
this.$badge.attr('title', '');
|
||||
},
|
||||
|
||||
checkBypass: function () {
|
||||
var last = this.getRouter().getLast() || {};
|
||||
if (last.controller == 'Admin' && last.action == 'upgrade') {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
checkUpdates: function (isFirstCheck) {
|
||||
if (this.checkBypass()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax('Notification/action/notReadCount').done(function (count) {
|
||||
if (!isFirstCheck && count > this.unreadCount) {
|
||||
|
||||
@@ -172,13 +183,21 @@ Espo.define('views/notification/badge', 'view', function (Dep) {
|
||||
isFirstCheck = true;
|
||||
}
|
||||
|
||||
var jqxhr = $.ajax(url).done(function (list) {
|
||||
list.forEach(function (d) {
|
||||
this.showPopupNotification(name, d, isFirstCheck);
|
||||
}, this);
|
||||
}.bind(this));
|
||||
(new Promise(function (resolve) {
|
||||
if (this.checkBypass()) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
var jqxhr = $.ajax(url).done(function (list) {
|
||||
list.forEach(function (d) {
|
||||
this.showPopupNotification(name, d, isFirstCheck);
|
||||
}, this);
|
||||
}.bind(this));
|
||||
|
||||
jqxhr.always(function() {
|
||||
jqxhr.always(function() {
|
||||
resolve();
|
||||
});
|
||||
}.bind(this))).then(function () {
|
||||
this.popoupTimeouts[name] = setTimeout(function () {
|
||||
this.popupCheckIteration++;
|
||||
this.checkPopupNotifications(name);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "espocrm",
|
||||
"version": "4.2.5",
|
||||
"version": "4.2.7",
|
||||
"description": "",
|
||||
"main": "index.php",
|
||||
"repository": {
|
||||
|
||||
Reference in New Issue
Block a user