Compare commits

...

10 Commits
4.2.5 ... 4.2.7

Author SHA1 Message Date
yuri
f062ac255a version 2016-10-10 15:19:14 +03:00
yuri
3a24784980 fix email filter 2016-10-07 12:46:46 +03:00
yuri
b1dbd173ad fix mail filters 2016-10-07 11:14:37 +03:00
yuri
a92c294255 fix layout manager reset to default 2016-10-05 12:37:38 +03:00
yuri
27624ead8d number fix 2 2016-09-29 17:25:25 +03:00
yuri
15c980e57f rename number to number util 2016-09-29 17:20:52 +03:00
yuri
a98465f30e skip notification checking while upgrade 2016-09-26 12:04:10 +03:00
yuri
8862fd279e fix language enum translation 2016-09-20 15:47:58 +03:00
yuri
bd6eafd291 version 2016-09-16 17:44:26 +03:00
yuri
a63306603a fix email filter 2016-09-16 17:44:10 +03:00
15 changed files with 162 additions and 92 deletions

View File

@@ -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')
);

View File

@@ -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;

View File

@@ -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)

View File

@@ -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 {

View File

@@ -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;
}

View File

@@ -29,7 +29,7 @@
namespace Espo\Core\Utils;
class Number
class NumberUtil
{
protected $decimalMark;

View File

@@ -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');

View File

@@ -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) {

View File

@@ -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)

View File

@@ -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();
},

View File

@@ -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));
},

View File

@@ -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));
},

View File

@@ -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));
},

View File

@@ -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);

View File

@@ -1,6 +1,6 @@
{
"name": "espocrm",
"version": "4.2.5",
"version": "4.2.7",
"description": "",
"main": "index.php",
"repository": {