mirror of
https://github.com/espocrm/espocrm.git
synced 2026-03-11 14:17:02 +00:00
Compare commits
336 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b27b356997 | ||
|
|
3b76eec06c | ||
|
|
04a768ee40 | ||
|
|
0a3490d4f2 | ||
|
|
df71605c47 | ||
|
|
7424828f0c | ||
|
|
c9c759f33b | ||
|
|
98835fdb6c | ||
|
|
d32887ed40 | ||
|
|
6dd7573f7b | ||
|
|
0027e1bf9a | ||
|
|
eb10aa33d6 | ||
|
|
cfe77569f1 | ||
|
|
62da3462bc | ||
|
|
334b0baacc | ||
|
|
d16d177eaf | ||
|
|
2966f158fe | ||
|
|
1f57bcb250 | ||
|
|
90e775c27a | ||
|
|
9ff47844e7 | ||
|
|
042d98d05b | ||
|
|
0533c5a3ef | ||
|
|
0325f637b2 | ||
|
|
3d2bfe48b9 | ||
|
|
c8a538d73e | ||
|
|
fbc171b07f | ||
|
|
70e4921961 | ||
|
|
1ca96c7ca8 | ||
|
|
65359f103f | ||
|
|
e5afffbde1 | ||
|
|
66364e91b7 | ||
|
|
567ca19398 | ||
|
|
1e073def9d | ||
|
|
70c772dfd2 | ||
|
|
709259f45e | ||
|
|
dca51642e3 | ||
|
|
f24aea6354 | ||
|
|
c020cd4251 | ||
|
|
452e2ddc51 | ||
|
|
1860c69313 | ||
|
|
201beca8fa | ||
|
|
9182aeef99 | ||
|
|
d2cb7f60de | ||
|
|
c6beb0aac3 | ||
|
|
e394b12888 | ||
|
|
a461c8515f | ||
|
|
9bb36e1a35 | ||
|
|
1a5c75daac | ||
|
|
2c7633e74d | ||
|
|
996ad352e1 | ||
|
|
5c4b0d7723 | ||
|
|
6485ed38d6 | ||
|
|
48d9c0a7ff | ||
|
|
40c4b77cbf | ||
|
|
9b0ed1c833 | ||
|
|
bc6e74a092 | ||
|
|
52bdb136d4 | ||
|
|
f0e77da5d4 | ||
|
|
0b77c4cdfe | ||
|
|
2efa0c0ca7 | ||
|
|
87892c799c | ||
|
|
5bfa258881 | ||
|
|
d742de40c5 | ||
|
|
bb3bd0e915 | ||
|
|
8d50f52b7f | ||
|
|
bd2fd5eb3a | ||
|
|
2db25fda63 | ||
|
|
3067abcac2 | ||
|
|
c0c77e6e6b | ||
|
|
4037ffa295 | ||
|
|
2aa263847f | ||
|
|
50f9f24887 | ||
|
|
e36ee5aaff | ||
|
|
6d8017f1dc | ||
|
|
d22ce60f7b | ||
|
|
bc7d4f214f | ||
|
|
daa80d7196 | ||
|
|
8d3da43dca | ||
|
|
15b329580c | ||
|
|
0e2f8d9bf9 | ||
|
|
951d68724b | ||
|
|
f678253b05 | ||
|
|
0603eaf48d | ||
|
|
753caf7eeb | ||
|
|
5dbf719a53 | ||
|
|
1e945cff41 | ||
|
|
4a1237cdcc | ||
|
|
b60e65379e | ||
|
|
6da4e1796b | ||
|
|
2666f05bd5 | ||
|
|
461bffbf02 | ||
|
|
2653bba158 | ||
|
|
56d73519bf | ||
|
|
df3a7d78f4 | ||
|
|
898a7d89c7 | ||
|
|
2734b9bf8c | ||
|
|
2c074c6e82 | ||
|
|
1e67fe69e1 | ||
|
|
08cf333c0c | ||
|
|
0f62d7da13 | ||
|
|
8ce806d41f | ||
|
|
59a564cc1b | ||
|
|
1135573af6 | ||
|
|
c9a1e3733c | ||
|
|
6dbeba3473 | ||
|
|
351087781e | ||
|
|
92f977d6c2 | ||
|
|
489fbb8800 | ||
|
|
159c19fe08 | ||
|
|
c13e46554d | ||
|
|
6f45e26028 | ||
|
|
7e02481b35 | ||
|
|
79e94a8255 | ||
|
|
288398d4c2 | ||
|
|
92afc4deee | ||
|
|
f6892877c1 | ||
|
|
30c57921d1 | ||
|
|
d23bf569c0 | ||
|
|
796830d2dd | ||
|
|
286ec0325d | ||
|
|
c8338e1759 | ||
|
|
5f8adf51c1 | ||
|
|
c7cc44edf6 | ||
|
|
e958d7c488 | ||
|
|
77ff11990b | ||
|
|
e1538a5028 | ||
|
|
994e0c1eda | ||
|
|
d51e88be60 | ||
|
|
b1ba07a995 | ||
|
|
146a7aba1f | ||
|
|
981c60c78a | ||
|
|
2e85e7fc56 | ||
|
|
99edab675a | ||
|
|
1a8d3a3cdf | ||
|
|
43abd1740e | ||
|
|
261d60f338 | ||
|
|
1a36d7758b | ||
|
|
c09fc39881 | ||
|
|
0a7cd28ab5 | ||
|
|
bf8bf5e4d9 | ||
|
|
1defafd258 | ||
|
|
4854133f46 | ||
|
|
d93879a24d | ||
|
|
8ff6d2063c | ||
|
|
a46ecce6d0 | ||
|
|
49175ae1b1 | ||
|
|
532473df15 | ||
|
|
252ba4dccc | ||
|
|
1ddac304d7 | ||
|
|
44ecebad03 | ||
|
|
67d8c6cb17 | ||
|
|
c52ca7244f | ||
|
|
b42b276054 | ||
|
|
619a279dbb | ||
|
|
56e0c9928e | ||
|
|
25a424266b | ||
|
|
c8b13e07b1 | ||
|
|
9595d528a8 | ||
|
|
48cf4a6ed6 | ||
|
|
9de2b5f7ef | ||
|
|
9bfb27e10a | ||
|
|
be50630d2f | ||
|
|
7d7234a226 | ||
|
|
a7517bed9d | ||
|
|
66fca4dadd | ||
|
|
645b64437f | ||
|
|
efa2755f19 | ||
|
|
4fe0f53878 | ||
|
|
d8b629a5a0 | ||
|
|
5db5b41f7f | ||
|
|
6d0b39f2b6 | ||
|
|
909aa49e39 | ||
|
|
dd3d09f895 | ||
|
|
395182bda5 | ||
|
|
fd7d73756a | ||
|
|
aff95d47dd | ||
|
|
b778f74628 | ||
|
|
9f72d65281 | ||
|
|
6db658c0b3 | ||
|
|
6fb88665bb | ||
|
|
669cc2b883 | ||
|
|
dec262e999 | ||
|
|
cb03047ac3 | ||
|
|
8c5f94ace4 | ||
|
|
6269f02bca | ||
|
|
f20a47542a | ||
|
|
c77e3b7e92 | ||
|
|
e7b033304c | ||
|
|
2b8a8d23eb | ||
|
|
0f59f79a9e | ||
|
|
2904cd1f53 | ||
|
|
d87ae60fea | ||
|
|
0d17cf6e78 | ||
|
|
81739d59f5 | ||
|
|
7704d5afd0 | ||
|
|
da268f2b29 | ||
|
|
01dc251ef2 | ||
|
|
9054d70f4c | ||
|
|
788b265cd4 | ||
|
|
c96640bcb1 | ||
|
|
66fb7b4e81 | ||
|
|
d83a19e316 | ||
|
|
452e39903e | ||
|
|
797fcc172c | ||
|
|
cdb7c919b3 | ||
|
|
0f7f438935 | ||
|
|
7c01eedda8 | ||
|
|
bab7f3e9fc | ||
|
|
761d85a112 | ||
|
|
52e323123a | ||
|
|
01af1677cf | ||
|
|
d4f4fcb10e | ||
|
|
74fd228bfb | ||
|
|
f452d2e5d2 | ||
|
|
3a01348e02 | ||
|
|
b1743ee4a2 | ||
|
|
ab14769387 | ||
|
|
5c800601e4 | ||
|
|
8aea81340b | ||
|
|
8513911f21 | ||
|
|
6a46c453cd | ||
|
|
2029dc5e10 | ||
|
|
70664d1a7a | ||
|
|
7d212ec62f | ||
|
|
fa7b145e07 | ||
|
|
830645cb73 | ||
|
|
94e03b3c18 | ||
|
|
3ace85eebc | ||
|
|
c6cfdd9e90 | ||
|
|
d1b2dfae3e | ||
|
|
98fb345a5a | ||
|
|
481314886f | ||
|
|
ad90cd171a | ||
|
|
8272e0e652 | ||
|
|
f218de2e04 | ||
|
|
53529fc506 | ||
|
|
aef99fb4fd | ||
|
|
86f690c79f | ||
|
|
71f9e90436 | ||
|
|
75608f41b1 | ||
|
|
0730ae5b3f | ||
|
|
a7f537879e | ||
|
|
6066cf1d65 | ||
|
|
ccda236b6e | ||
|
|
32ec348369 | ||
|
|
d85f66171d | ||
|
|
8c6aa46ec8 | ||
|
|
d2f7bc475a | ||
|
|
410cf02518 | ||
|
|
958414017e | ||
|
|
8fbfad9637 | ||
|
|
07e8f94748 | ||
|
|
4db162f9f7 | ||
|
|
459dfb7937 | ||
|
|
56b0536152 | ||
|
|
5bb7dd3ccd | ||
|
|
6e50e4fd8e | ||
|
|
878e1616da | ||
|
|
64a410099e | ||
|
|
9cb8664ddf | ||
|
|
6d5c3c8ad5 | ||
|
|
f07c8fca64 | ||
|
|
944c76ad93 | ||
|
|
ae8f9df02b | ||
|
|
6da3659b7d | ||
|
|
1f1d9f3abd | ||
|
|
530d7f2d81 | ||
|
|
e67ecded2a | ||
|
|
b9343d5e64 | ||
|
|
898393c7ac | ||
|
|
9b2ea5298d | ||
|
|
0d2b56c58f | ||
|
|
076c920dc7 | ||
|
|
638df642ec | ||
|
|
d2f4190612 | ||
|
|
7201f517e8 | ||
|
|
c91365f627 | ||
|
|
f3bc4dbccf | ||
|
|
d4daef6012 | ||
|
|
dbf4f68a44 | ||
|
|
8a7325963b | ||
|
|
fc0d8dffcd | ||
|
|
f8498e3adc | ||
|
|
e4b51ba675 | ||
|
|
83f9ead607 | ||
|
|
bf6778770e | ||
|
|
093b80293a | ||
|
|
34dee314e7 | ||
|
|
313b94168e | ||
|
|
d6085bbdcf | ||
|
|
160dc5d61c | ||
|
|
987b383d7c | ||
|
|
8b4cb1568e | ||
|
|
aef4028180 | ||
|
|
9b779ee8cd | ||
|
|
ccc339cf48 | ||
|
|
6aabbfd944 | ||
|
|
0e87626e34 | ||
|
|
8641181511 | ||
|
|
123c3ef8ab | ||
|
|
07bd5a9d60 | ||
|
|
deca89039a | ||
|
|
1542fa86d8 | ||
|
|
93ca814fe3 | ||
|
|
4d9e5ee302 | ||
|
|
0a697cdc0a | ||
|
|
1b01e476ac | ||
|
|
ee689fb351 | ||
|
|
92a76d80f2 | ||
|
|
a662c1a5fe | ||
|
|
3ffa949276 | ||
|
|
371966e2cf | ||
|
|
8f1a4d2a02 | ||
|
|
3128b6f25a | ||
|
|
0920821f1e | ||
|
|
0f8f9c01ff | ||
|
|
1d9621bc91 | ||
|
|
e138daec5f | ||
|
|
4a51e754d7 | ||
|
|
e6e0bc1703 | ||
|
|
49fbc6e082 | ||
|
|
a0ed610f60 | ||
|
|
9f8c0eb4a2 | ||
|
|
be29fac010 | ||
|
|
b3cefd9bcb | ||
|
|
501d6f2692 | ||
|
|
3d7560024f | ||
|
|
a201b45d04 | ||
|
|
41f88a4015 | ||
|
|
52a131ef93 | ||
|
|
7ab28601ca | ||
|
|
5de509a0de | ||
|
|
2534b14dce | ||
|
|
27f98b95eb | ||
|
|
b08bee78b9 | ||
|
|
a39327a95b |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -13,4 +13,4 @@
|
||||
/tests/testData/cache/*
|
||||
composer.phar
|
||||
vendor/
|
||||
/custom/Espo/Custom/Resources/*
|
||||
/custom/Espo/Custom/*
|
||||
@@ -126,7 +126,8 @@ module.exports = function (grunt) {
|
||||
'modules/**',
|
||||
'img/**',
|
||||
'css/**',
|
||||
'sounds/**'
|
||||
'sounds/**',
|
||||
'custom/**'
|
||||
],
|
||||
dest: 'build/tmp/client',
|
||||
},
|
||||
@@ -154,6 +155,7 @@ module.exports = function (grunt) {
|
||||
'bootstrap.php',
|
||||
'cron.php',
|
||||
'rebuild.php',
|
||||
'clear_cache.php',
|
||||
'upgrade.php',
|
||||
'index.php',
|
||||
'LICENSE.txt',
|
||||
|
||||
24
README.md
24
README.md
@@ -2,10 +2,17 @@
|
||||
|
||||
<a href='http://www.espocrm.com'>EspoCRM is an Open Source CRM</a> (Customer Relationship Management) software that allows you to see, enter and evaluate all your company relationships regardless of the type. People, companies or opportunities - all in an easy and intuitive interface.
|
||||
|
||||
It's a web application with a frontend designed as a single page application based on backbone.js and a RESTful backend written in PHP.
|
||||
It's a web application with a frontend designed as a single page application based on backbone.js and a REST API backend written in PHP.
|
||||
|
||||
Download the latest release from our [website](http://www.espocrm.com).
|
||||
|
||||
### Requirements
|
||||
|
||||
* PHP 5.4 or above (with pdo, json, gd, mcrypt extensions);
|
||||
* MySQL 5.1 or above.
|
||||
|
||||
For more information about server configuration see [this article](http://blog.espocrm.com/administration/server-configuration-for-espocrm/).
|
||||
|
||||
### How to report bug
|
||||
|
||||
Create an issue [here](https://github.com/espocrm/espocrm/issues) or post on our [forum](http://forum.espocrm.com/bug-reports?routestring=forum/bug-reports).
|
||||
@@ -33,6 +40,21 @@ You need to have nodejs and Grunt CLI installed.
|
||||
|
||||
The build will be created in the `build` directory.
|
||||
|
||||
### How to make translation
|
||||
|
||||
Build po file with command:
|
||||
`node po.js en_EN`
|
||||
(specify needed language instead of en_EN)
|
||||
|
||||
After that tranlate the generated po file.
|
||||
|
||||
Build json files from the translated po file:
|
||||
|
||||
1. Put your po file espocrm-en_EN.po to the `build` directory
|
||||
2. Run `node lang.js en_EN`
|
||||
|
||||
The files will be created in build directory.
|
||||
|
||||
### License
|
||||
|
||||
EspoCRM is published under the GNU GPLv3 [license](https://raw.githubusercontent.com/espocrm/espocrm/master/LICENSE.txt).
|
||||
|
||||
72
application/Espo/Acl/Email.php
Normal file
72
application/Espo/Acl/Email.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Acl;
|
||||
|
||||
use \Espo\Entities\User;
|
||||
use \Espo\ORM\Entity;
|
||||
|
||||
class Email extends \Espo\Core\Acl\Base
|
||||
{
|
||||
|
||||
public function checkEntityRead(User $user, Entity $entity, $data)
|
||||
{
|
||||
if ($this->checkEntity($user, $entity, $data, 'read')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($data === false) {
|
||||
return false;
|
||||
}
|
||||
if (is_array($data)) {
|
||||
if (empty($data['read']) || $data['read'] == 'no') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$entity->has('usersIds')) {
|
||||
$entity->loadLinkMultipleField('users');
|
||||
}
|
||||
$userIdList = $entity->get('usersIds');
|
||||
if (is_array($userIdList) && in_array($user->id, $userIdList)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function checkIsOwner(User $user, Entity $entity)
|
||||
{
|
||||
if ($entity->has('assignedUserId')) {
|
||||
if ($user->id === $entity->get('assignedUserId')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($user->id === $entity->get('createdById')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class App extends \Espo\Core\Controllers\Base
|
||||
|
||||
return array(
|
||||
'user' => $this->getUser()->toArray(),
|
||||
'acl' => $this->getAcl()->toArray(),
|
||||
'acl' => $this->getAcl()->getMap(),
|
||||
'preferences' => $preferences,
|
||||
'token' => $this->getUser()->get('token')
|
||||
);
|
||||
|
||||
@@ -41,7 +41,7 @@ class Email extends \Espo\Core\Controllers\Record
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (empty($data['password'])) {
|
||||
if (is_null($data['password'])) {
|
||||
if ($data['type'] == 'preferences') {
|
||||
if (!$this->getUser()->isAdmin() && $data['id'] != $this->getUser()->id) {
|
||||
throw new Forbidden();
|
||||
@@ -75,5 +75,13 @@ class Email extends \Espo\Core\Controllers\Record
|
||||
|
||||
return $this->getRecordService()->markAsReadByIds($ids);
|
||||
}
|
||||
|
||||
public function actionMarkAllAsRead($params, $data, $request)
|
||||
{
|
||||
if (!$request->isPost()) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
return $this->getRecordService()->markAllAsRead();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class EmailAccount extends \Espo\Core\Controllers\Record
|
||||
return $this->getRecordService()->getFolders(array(
|
||||
'host' => $request->get('host'),
|
||||
'port' => $request->get('port'),
|
||||
'ssl' => $request->get('ssl'),
|
||||
'ssl' => $request->get('ssl') === 'true',
|
||||
'username' => $request->get('username'),
|
||||
'password' => $request->get('password'),
|
||||
'id' => $request->get('id')
|
||||
@@ -44,5 +44,27 @@ class EmailAccount extends \Espo\Core\Controllers\Record
|
||||
throw new Forbidden();
|
||||
}
|
||||
}
|
||||
|
||||
public function actionTestConnection($params, $data, $request)
|
||||
{
|
||||
if (!$request->isPost()) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (is_null($data['password'])) {
|
||||
$emailAccount = $this->getEntityManager()->getEntity('EmailAccount', $data['id']);
|
||||
if (!$emailAccount) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
if ($emailAccount->get('assignedUserId') != $this->getUser()->id && !$this->getUser()->isAdmin()) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$data['password'] = $this->getContainer()->get('crypt')->decrypt($emailAccount->get('password'));
|
||||
}
|
||||
|
||||
return $this->getRecordService()->testConnection($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,12 @@ class EntityManager extends \Espo\Core\Controllers\Base
|
||||
if (!empty($data['stream'])) {
|
||||
$params['stream'] = $data['stream'];
|
||||
}
|
||||
if (!empty($data['sortBy'])) {
|
||||
$params['sortBy'] = $data['sortBy'];
|
||||
}
|
||||
if (!empty($data['sortDirection'])) {
|
||||
$params['asc'] = $data['sortDirection'] === 'asc';
|
||||
}
|
||||
|
||||
$result = $this->getContainer()->get('entityManagerUtil')->create($name, $type, $params);
|
||||
|
||||
@@ -90,6 +96,10 @@ class EntityManager extends \Espo\Core\Controllers\Base
|
||||
$name = $data['name'];
|
||||
$name = filter_var($name, \FILTER_SANITIZE_STRING);
|
||||
|
||||
if (!empty($data['sortDirection'])) {
|
||||
$data['asc'] = $data['sortDirection'] === 'asc';
|
||||
}
|
||||
|
||||
$result = $this->getContainer()->get('entityManagerUtil')->update($name, $data);
|
||||
|
||||
if ($result) {
|
||||
|
||||
@@ -18,50 +18,94 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Controllers;
|
||||
|
||||
use Espo\Core\Utils as Utils;
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
use \Espo\Core\Exceptions\Forbidden;
|
||||
use \Espo\Core\Exceptions\BadRequest;
|
||||
|
||||
class Import extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
protected function checkControllerAccess()
|
||||
{
|
||||
if (!$this->getUser()->isAdmin()) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
}
|
||||
|
||||
public function actionPatch($params, $data)
|
||||
{
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
public function actionUpdate($params, $data)
|
||||
{
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
public function actionMassUpdate($params, $data, $request)
|
||||
{
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
public function actionCreateLink($params, $data)
|
||||
{
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
public function actionRemoveLink($params, $data)
|
||||
{
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
class Import extends \Espo\Core\Controllers\Base
|
||||
{
|
||||
|
||||
protected function getFileManager()
|
||||
{
|
||||
return $this->getContainer()->get('fileManager');
|
||||
}
|
||||
|
||||
|
||||
protected function getEntityManager()
|
||||
{
|
||||
return $this->getContainer()->get('entityManager');
|
||||
}
|
||||
|
||||
|
||||
public function actionUploadFile($params, $data)
|
||||
{
|
||||
{
|
||||
$contents = $data;
|
||||
|
||||
|
||||
$attachment = $this->getEntityManager()->getEntity('Attachment');
|
||||
$attachment->set('type', 'text/csv');
|
||||
$attachment->set('role', 'Import File');
|
||||
$attachment->set('role', 'Import File');
|
||||
$attachment->set('name', 'import-file.csv');
|
||||
$this->getEntityManager()->saveEntity($attachment);
|
||||
|
||||
|
||||
$this->getFileManager()->putContents('data/upload/' . $attachment->id, $contents);
|
||||
|
||||
|
||||
return array(
|
||||
'attachmentId' => $attachment->id
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function actionRevert($params, $data)
|
||||
{
|
||||
return $this->getService('Import')->revert($data['entityType'], $data['idsToRemove']);
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
return $this->getService('Import')->revert($data['id']);
|
||||
}
|
||||
|
||||
|
||||
public function actionRemoveDuplicates($params, $data)
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
return $this->getService('Import')->removeDuplicates($data['id']);
|
||||
}
|
||||
|
||||
public function actionCreate($params, $data)
|
||||
{
|
||||
{
|
||||
$importParams = array(
|
||||
'headerRow' => $data['headerRow'],
|
||||
'fieldDelimiter' => $data['fieldDelimiter'],
|
||||
@@ -74,13 +118,13 @@ class Import extends \Espo\Core\Controllers\Base
|
||||
'defaultValues' => $data['defaultValues'],
|
||||
'action' => $data['action'],
|
||||
);
|
||||
|
||||
|
||||
$attachmentId = $data['attachmentId'];
|
||||
|
||||
|
||||
if (!$this->getAcl()->check($data['entityType'], 'edit')) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
|
||||
return $this->getService('Import')->import($data['entityType'], $data['fields'], $attachmentId, $importParams);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
namespace Espo\Controllers;
|
||||
|
||||
class InboundEmail extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
@@ -30,18 +30,34 @@ class InboundEmail extends \Espo\Core\Controllers\Record
|
||||
throw new Forbidden();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function actionGetFolders($params, $data, $request)
|
||||
{
|
||||
{
|
||||
return $this->getRecordService()->getFolders(array(
|
||||
'host' => $request->get('host'),
|
||||
'port' => $request->get('port'),
|
||||
'ssl' => $request->get('ssl'),
|
||||
'ssl' => $request->get('ssl') === 'true',
|
||||
'username' => $request->get('username'),
|
||||
'password' => $request->get('password'),
|
||||
'id' => $request->get('id')
|
||||
));
|
||||
}
|
||||
|
||||
public function actionTestConnection($params, $data, $request)
|
||||
{
|
||||
if (!$request->isPost()) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (is_null($data['password'])) {
|
||||
$inboundEmail = $this->getEntityManager()->getEntity('InboundEmail', $data['id']);
|
||||
if (!$inboundEmail) {
|
||||
throw new Error();
|
||||
}
|
||||
$data['password'] = $this->getContainer()->get('crypt')->decrypt($inboundEmail->get('password'));
|
||||
}
|
||||
|
||||
return $this->getRecordService()->testConnection($data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,9 +45,7 @@ class User extends \Espo\Core\Controllers\Record
|
||||
throw new NotFound();
|
||||
}
|
||||
|
||||
$acl = new \Espo\Core\Acl($user, $this->getConfig(), $this->getContainer()->get('fileManager'), $this->getMetadata());
|
||||
|
||||
return $acl->toArray();
|
||||
return $this->getAclManager()->getMap($user);
|
||||
}
|
||||
|
||||
public function actionChangeOwnPassword($params, $data, $request)
|
||||
@@ -89,7 +87,7 @@ class User extends \Espo\Core\Controllers\Record
|
||||
if (!$request->isPost()) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
|
||||
if (empty($data['userName']) || empty($data['emailAddress'])) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
@@ -22,305 +22,61 @@
|
||||
|
||||
namespace Espo\Core;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
|
||||
use \Espo\ORM\Entity;
|
||||
|
||||
class Acl
|
||||
{
|
||||
private $data = array(
|
||||
'table' => array()
|
||||
);
|
||||
private $user;
|
||||
|
||||
private $cacheFile;
|
||||
private $aclManager;
|
||||
|
||||
private $actionList = array('read', 'edit', 'delete');
|
||||
|
||||
private $levelList = array('all', 'team', 'own', 'no');
|
||||
|
||||
protected $fileManager;
|
||||
|
||||
protected $metadata;
|
||||
|
||||
public function __construct(\Espo\Entities\User $user, $config = null, $fileManager = null, $metadata = null)
|
||||
public function __construct(AclManager $aclManager, \Espo\Entities\User $user)
|
||||
{
|
||||
$this->aclManager = $aclManager;
|
||||
$this->user = $user;
|
||||
|
||||
$this->metadata = $metadata;
|
||||
|
||||
if (!$this->user->isFetched()) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
$this->user->loadLinkMultipleField('teams');
|
||||
|
||||
if ($fileManager) {
|
||||
$this->fileManager = $fileManager;
|
||||
}
|
||||
|
||||
$this->cacheFile = 'data/cache/application/acl/' . $user->id . '.php';
|
||||
|
||||
if ($config && $config->get('useCache') && file_exists($this->cacheFile)) {
|
||||
$cached = include $this->cacheFile;
|
||||
$this->data = $cached;
|
||||
$this->initSolid();
|
||||
} else {
|
||||
$this->load();
|
||||
$this->initSolid();
|
||||
if ($config && $fileManager && $config->get('useCache')) {
|
||||
$this->buildCache();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function checkScope($scope, $action = null, $isOwner = null, $inTeam = null, $entity = null)
|
||||
protected function getAclManager()
|
||||
{
|
||||
if (array_key_exists($scope, $this->data['table'])) {
|
||||
if ($this->data['table'][$scope] === false) {
|
||||
return false;
|
||||
}
|
||||
if ($this->data['table'][$scope] === true) {
|
||||
return true;
|
||||
}
|
||||
if (!is_null($action)) {
|
||||
if (array_key_exists($action, $this->data['table'][$scope])) {
|
||||
$value = $this->data['table'][$scope][$action];
|
||||
|
||||
if ($value === 'all' || $value === true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!$value || $value === 'no') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_null($isOwner)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($isOwner) {
|
||||
if ($value === 'own' || $value === 'team') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if ($inTeam === null && $entity) {
|
||||
$inTeam = $this->checkInTeam($entity);
|
||||
}
|
||||
|
||||
if ($inTeam) {
|
||||
if ($value === 'team') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return $this->aclManager;
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
protected function getUser()
|
||||
{
|
||||
return $this->data;
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function get($permission)
|
||||
public function getMap()
|
||||
{
|
||||
if ($this->user->isAdmin()) {
|
||||
return true;
|
||||
}
|
||||
if ($permission == 'table') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (array_key_exists($permission, $this->data)) {
|
||||
return $this->data[$permission];
|
||||
}
|
||||
return null;
|
||||
return $this->getAclManager()->getMap($this->getUser());
|
||||
}
|
||||
|
||||
public function getLevel($scope, $action)
|
||||
{
|
||||
if ($this->user->isAdmin()) {
|
||||
return 'all';
|
||||
}
|
||||
if (array_key_exists($scope, $this->data['table'])) {
|
||||
if (array_key_exists($action, $this->data['table'][$scope])) {
|
||||
return $this->data['table'][$scope][$action];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return $this->getAclManager()->getLevel($this->getUser(), $scope, $action);
|
||||
}
|
||||
|
||||
public function check($subject, $action = null, $isOwner = null, $inTeam = null)
|
||||
public function get($permission)
|
||||
{
|
||||
if ($this->user->isAdmin()) {
|
||||
return true;
|
||||
}
|
||||
if (is_string($subject)) {
|
||||
return $this->checkScope($subject, $action, $isOwner, $inTeam);
|
||||
} else {
|
||||
$entity = $subject;
|
||||
if ($entity instanceof Entity) {
|
||||
$entityName = $entity->getEntityName();
|
||||
return $this->checkScope($entityName, $action, $this->checkIsOwner($entity), $inTeam, $entity);
|
||||
}
|
||||
}
|
||||
return $this->getAclManager()->get($this->getUser(), $permission);
|
||||
}
|
||||
|
||||
public function checkReadOnlyTeam($scope)
|
||||
{
|
||||
if (isset($this->data['table'][$scope]) && isset($this->data['table'][$scope]['read'])) {
|
||||
return $this->data['table'][$scope]['read'] === 'team';
|
||||
}
|
||||
return false;
|
||||
return $this->getAclManager()->checkReadOnlyTeam($this->getUser(), $scope);
|
||||
}
|
||||
|
||||
public function checkReadOnlyOwn($scope)
|
||||
{
|
||||
if ($this->user->isAdmin()) {
|
||||
return false;
|
||||
}
|
||||
if (isset($this->data['table'][$scope]) && isset($this->data['table'][$scope]['read'])) {
|
||||
return $this->data['table'][$scope]['read'] === 'own';
|
||||
}
|
||||
return false;
|
||||
return $this->getAclManager()->checkReadOnlyOwn($this->getUser(), $scope);
|
||||
}
|
||||
|
||||
public function checkIsOwner($entity)
|
||||
public function check($subject, $action = null, $isOwner = null, $inTeam = null)
|
||||
{
|
||||
if ($this->user->isAdmin()) {
|
||||
return false;
|
||||
}
|
||||
$userId = $this->user->id;
|
||||
if ($userId === $entity->get('assignedUserId') || $userId === $entity->get('createdById')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return $this->getAclManager()->check($this->getUser(), $subject, $action, $isOwner, $inTeam) ;
|
||||
}
|
||||
|
||||
public function checkInTeam($entity)
|
||||
public function checkScope($scope, $action = null, $isOwner = null, $inTeam = null, $entity = null)
|
||||
{
|
||||
$userTeamIds = $this->user->get('teamsIds');
|
||||
|
||||
if (!$entity->hasRelation('teams') || !$entity->hasField('teamsIds')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$entity->has('teamsIds')) {
|
||||
$entity->loadLinkMultipleField('teams');
|
||||
}
|
||||
|
||||
$teamIds = $entity->get('teamsIds');
|
||||
|
||||
if (empty($teamIds)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($userTeamIds as $id) {
|
||||
if (in_array($id, $teamIds)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function load()
|
||||
{
|
||||
$aclTables = [];
|
||||
$assignmentPermissionList = [];
|
||||
|
||||
$userRoles = $this->user->get('roles');
|
||||
|
||||
foreach ($userRoles as $role) {
|
||||
$aclTables[] = $role->get('data');
|
||||
$assignmentPermissionList[] = $role->get('assignmentPermission');
|
||||
}
|
||||
|
||||
$teams = $this->user->get('teams');
|
||||
foreach ($teams as $team) {
|
||||
$teamRoles = $team->get('roles');
|
||||
foreach ($teamRoles as $role) {
|
||||
$aclTables[] = $role->get('data');
|
||||
$assignmentPermissionList[] = $role->get('assignmentPermission');
|
||||
}
|
||||
}
|
||||
|
||||
$this->data['table'] = $this->merge($aclTables);
|
||||
$this->data['assignmentPermission'] = $this->mergeValues($assignmentPermissionList, 'all');
|
||||
}
|
||||
|
||||
private function initSolid()
|
||||
{
|
||||
if (!$this->metadata) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = $this->metadata->get('app.acl.solid', array());
|
||||
|
||||
foreach ($data as $entityName => $item) {
|
||||
$this->data['table'][$entityName] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
private function mergeValues(array $list, $defaultValue)
|
||||
{
|
||||
$result = null;
|
||||
foreach ($list as $level) {
|
||||
if ($level != 'not-set') {
|
||||
if (is_null($result)) {
|
||||
$result = $level;
|
||||
continue;
|
||||
}
|
||||
if (array_search($result, $this->levelList) > array_search($level, $this->levelList)) {
|
||||
$result = $level;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_null($result)) {
|
||||
$result = $defaultValue;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function merge($tables)
|
||||
{
|
||||
$data = array();
|
||||
foreach ($tables as $table) {
|
||||
foreach ($table as $scope => $row) {
|
||||
if ($row == false) {
|
||||
if (!isset($data[$scope])) {
|
||||
$data[$scope] = false;
|
||||
}
|
||||
} else {
|
||||
if (!isset($data[$scope])) {
|
||||
$data[$scope] = array();
|
||||
}
|
||||
if ($data[$scope] == false) {
|
||||
$data[$scope] = array();
|
||||
}
|
||||
foreach ($row as $action => $level) {
|
||||
if (!isset($data[$scope][$action])) {
|
||||
$data[$scope][$action] = $level;
|
||||
} else {
|
||||
if (array_search($data[$scope][$action], $this->levelList) > array_search($level, $this->levelList)) {
|
||||
$data[$scope][$action] = $level;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function buildCache()
|
||||
{
|
||||
$contents = '<' . '?'. 'php return ' . var_export($this->data, true) . ';';
|
||||
$this->fileManager->putContents($this->cacheFile, $contents);
|
||||
return $this->getAclManager()->checkScope($this->getUser(), $subject, $action, $isOwner, $inTeam, $entity) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
223
application/Espo/Core/Acl/Base.php
Normal file
223
application/Espo/Core/Acl/Base.php
Normal file
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Acl;
|
||||
|
||||
use \Espo\Core\Interfaces\Injectable;
|
||||
|
||||
use \Espo\Entities\User;
|
||||
use \Espo\ORM\Entity;
|
||||
|
||||
class Base implements Injectable
|
||||
{
|
||||
protected $dependencies = array(
|
||||
'config',
|
||||
'entityManager',
|
||||
'aclManager'
|
||||
);
|
||||
|
||||
protected $injections = array();
|
||||
|
||||
public function inject($name, $object)
|
||||
{
|
||||
$this->injections[$name] = $object;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->init();
|
||||
}
|
||||
|
||||
protected function init()
|
||||
{
|
||||
}
|
||||
|
||||
protected function getInjection($name)
|
||||
{
|
||||
return $this->injections[$name];
|
||||
}
|
||||
|
||||
protected function addDependency($name)
|
||||
{
|
||||
$this->dependencies[] = $name;
|
||||
}
|
||||
|
||||
public function getDependencyList()
|
||||
{
|
||||
return $this->dependencies;
|
||||
}
|
||||
|
||||
protected function getConfig()
|
||||
{
|
||||
return $this->getInjection('config');
|
||||
}
|
||||
|
||||
protected function getEntityManager()
|
||||
{
|
||||
return $this->getInjection('entityManager');
|
||||
}
|
||||
|
||||
protected function getAclManager()
|
||||
{
|
||||
return $this->getInjection('aclManager');
|
||||
}
|
||||
|
||||
public function checkReadOnlyTeam(User $user, $scope, $data)
|
||||
{
|
||||
if (empty($data) || !is_array($data) || !isset($data['read'])) {
|
||||
return false;
|
||||
}
|
||||
return $data['read'] === 'team';
|
||||
}
|
||||
|
||||
public function checkReadOnlyOwn(User $user, $scope, $data)
|
||||
{
|
||||
if (empty($data) || !is_array($data) || !isset($data['read'])) {
|
||||
return false;
|
||||
}
|
||||
return $data['read'] === 'own';
|
||||
}
|
||||
|
||||
public function checkEntity(User $user, Entity $entity, $data, $action)
|
||||
{
|
||||
return $this->checkScope($user, $data, $entity->getEntityType(), $action, null, null, $entity);
|
||||
}
|
||||
|
||||
public function checkScope(User $user, $data, $scope, $action = null, $isOwner = null, $inTeam = null, Entity $entity = null)
|
||||
{
|
||||
if (is_null($data)) {
|
||||
return true;
|
||||
}
|
||||
if ($data === false) {
|
||||
return false;
|
||||
}
|
||||
if ($data === true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!is_null($action)) {
|
||||
if (array_key_exists($action, $data)) {
|
||||
$value = $data[$action];
|
||||
|
||||
if ($value === 'all' || $value === true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!$value || $value === 'no') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_null($isOwner)) {
|
||||
if ($entity) {
|
||||
$isOwner = $this->checkIsOwner($user, $entity);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($isOwner) {
|
||||
if ($value === 'own' || $value === 'team') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (is_null($inTeam) && $entity) {
|
||||
$inTeam = $this->checkInTeam($user, $entity);
|
||||
}
|
||||
|
||||
if ($inTeam) {
|
||||
if ($value === 'team') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkIsOwner(User $user, Entity $entity)
|
||||
{
|
||||
if ($entity->has('assignedUserId')) {
|
||||
if ($user->id === $entity->get('assignedUserId')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if ($entity->has('createdById')) {
|
||||
if ($user->id === $entity->get('createdById')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function checkInTeam(User $user, Entity $entity)
|
||||
{
|
||||
$userTeamIds = $user->get('teamsIds');
|
||||
|
||||
if (!$entity->hasRelation('teams') || !$entity->hasField('teamsIds')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$entity->has('teamsIds')) {
|
||||
$entity->loadLinkMultipleField('teams');
|
||||
}
|
||||
|
||||
$teamIds = $entity->get('teamsIds');
|
||||
|
||||
if (empty($teamIds)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($userTeamIds as $id) {
|
||||
if (in_array($id, $teamIds)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function checkEntityDelete(User $user, Entity $entity, $data)
|
||||
{
|
||||
$result = $this->checkEntity($user, $entity, $data, 'delete');
|
||||
if (!$result) {
|
||||
if (is_array($data)) {
|
||||
if ($data['edit'] != 'no') {
|
||||
if ($entity->has('createdById') && $entity->get('createdById') == $user->id) {
|
||||
if (!$entity->has('assignedUserId')) {
|
||||
return true;
|
||||
} else {
|
||||
if (!$entity->get('assignedUserId')) {
|
||||
return true;
|
||||
}
|
||||
if ($entity->get('assignedUserId') == $entity->get('createdById')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
239
application/Espo/Core/Acl/Table.php
Normal file
239
application/Espo/Core/Acl/Table.php
Normal file
@@ -0,0 +1,239 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Acl;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
|
||||
use \Espo\ORM\Entity;
|
||||
|
||||
class Table
|
||||
{
|
||||
private $data = array(
|
||||
'table' => array()
|
||||
);
|
||||
|
||||
private $cacheFile;
|
||||
|
||||
private $actionList = array('read', 'edit', 'delete');
|
||||
|
||||
private $levelList = array('all', 'team', 'own', 'no');
|
||||
|
||||
protected $fileManager;
|
||||
|
||||
protected $metadata;
|
||||
|
||||
public function __construct(\Espo\Entities\User $user, $config = null, $fileManager = null, $metadata = null)
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
$this->metadata = $metadata;
|
||||
|
||||
if (!$this->user->isFetched()) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
$this->user->loadLinkMultipleField('teams');
|
||||
|
||||
if ($fileManager) {
|
||||
$this->fileManager = $fileManager;
|
||||
}
|
||||
|
||||
$this->cacheFile = 'data/cache/application/acl/' . $user->id . '.php';
|
||||
|
||||
if ($config && $config->get('useCache') && file_exists($this->cacheFile)) {
|
||||
$cached = include $this->cacheFile;
|
||||
$this->data = $cached;
|
||||
$this->initSolid();
|
||||
} else {
|
||||
$this->load();
|
||||
$this->initSolid();
|
||||
if ($config && $fileManager && $config->get('useCache')) {
|
||||
$this->buildCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getMap()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function getScopeData($scope)
|
||||
{
|
||||
if (array_key_exists($scope, $this->data['table'])) {
|
||||
return $this->data['table'][$scope];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function get($permission)
|
||||
{
|
||||
if ($permission == 'table') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (array_key_exists($permission, $this->data)) {
|
||||
return $this->data[$permission];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getLevel($scope, $action)
|
||||
{
|
||||
if (array_key_exists($scope, $this->data['table'])) {
|
||||
if (array_key_exists($action, $this->data['table'][$scope])) {
|
||||
return $this->data['table'][$scope][$action];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function load()
|
||||
{
|
||||
$aclTables = [];
|
||||
$assignmentPermissionList = [];
|
||||
|
||||
$userRoles = $this->user->get('roles');
|
||||
|
||||
foreach ($userRoles as $role) {
|
||||
$aclTables[] = $role->get('data');
|
||||
$assignmentPermissionList[] = $role->get('assignmentPermission');
|
||||
}
|
||||
|
||||
$teams = $this->user->get('teams');
|
||||
foreach ($teams as $team) {
|
||||
$teamRoles = $team->get('roles');
|
||||
foreach ($teamRoles as $role) {
|
||||
$aclTables[] = $role->get('data');
|
||||
$assignmentPermissionList[] = $role->get('assignmentPermission');
|
||||
}
|
||||
}
|
||||
|
||||
$this->data['table'] = $this->merge($aclTables);
|
||||
$this->data['assignmentPermission'] = $this->mergeValues($assignmentPermissionList, 'all');
|
||||
}
|
||||
|
||||
private function initSolid()
|
||||
{
|
||||
if (!$this->metadata) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = $this->metadata->get('app.acl.solid', array());
|
||||
|
||||
foreach ($data as $entityType => $item) {
|
||||
$this->data['table'][$entityType] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
private function mergeValues(array $list, $defaultValue)
|
||||
{
|
||||
$result = null;
|
||||
foreach ($list as $level) {
|
||||
if ($level != 'not-set') {
|
||||
if (is_null($result)) {
|
||||
$result = $level;
|
||||
continue;
|
||||
}
|
||||
if (array_search($result, $this->levelList) > array_search($level, $this->levelList)) {
|
||||
$result = $level;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_null($result)) {
|
||||
$result = $defaultValue;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function getScopeList()
|
||||
{
|
||||
$scopeList = [];
|
||||
$scopes = $this->metadata->get('scopes');
|
||||
foreach ($scopes as $scope => $d) {
|
||||
if (!empty($d['acl'])) {
|
||||
$scopeList[] = $scope;
|
||||
}
|
||||
}
|
||||
return $scopeList;
|
||||
}
|
||||
|
||||
private function merge($tables)
|
||||
{
|
||||
$data = array();
|
||||
$scopeList = $this->getScopeList();
|
||||
|
||||
foreach ($tables as $table) {
|
||||
foreach ($scopeList as $scope) {
|
||||
if (!isset($table->$scope)) {
|
||||
continue;
|
||||
}
|
||||
$row = $table->$scope;
|
||||
|
||||
if ($row == false) {
|
||||
if (!isset($data[$scope])) {
|
||||
$data[$scope] = false;
|
||||
}
|
||||
} else if ($row === true) {
|
||||
$data[$scope] = true;
|
||||
} else {
|
||||
if (!isset($data[$scope])) {
|
||||
$data[$scope] = array();
|
||||
}
|
||||
if ($data[$scope] == false) {
|
||||
$data[$scope] = array();
|
||||
}
|
||||
|
||||
if (is_array($row) || $row instanceof \stdClass) {
|
||||
foreach ($row as $action => $level) {
|
||||
if (!isset($data[$scope][$action])) {
|
||||
$data[$scope][$action] = $level;
|
||||
} else {
|
||||
if (array_search($data[$scope][$action], $this->levelList) > array_search($level, $this->levelList)) {
|
||||
$data[$scope][$action] = $level;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($scopeList as $scope) {
|
||||
if (!array_key_exists($scope, $data)) {
|
||||
$aclType = $this->metadata->get('scopes.' . $scope . '.acl');
|
||||
if (!empty($aclType) && ($aclType === true || $aclType === 'record')) {
|
||||
$data[$scope] = $this->metadata->get('app.acl.recordDefault');
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function buildCache()
|
||||
{
|
||||
$contents = '<' . '?'. 'php return ' . var_export($this->data, true) . ';';
|
||||
$this->fileManager->putContents($this->cacheFile, $contents);
|
||||
}
|
||||
}
|
||||
|
||||
181
application/Espo/Core/AclManager.php
Normal file
181
application/Espo/Core/AclManager.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
|
||||
use \Espo\ORM\Entity;
|
||||
use \Espo\Entities\User;
|
||||
use \Espo\Core\Utils\Util;
|
||||
|
||||
class AclManager
|
||||
{
|
||||
private $container;
|
||||
|
||||
private $metadata;
|
||||
|
||||
private $implementationHashMap = array();
|
||||
|
||||
private $tableHashMap = array();
|
||||
|
||||
public function __construct(Container $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->metadata = $container->get('metadata');
|
||||
}
|
||||
|
||||
protected function getContainer()
|
||||
{
|
||||
return $this->container;
|
||||
}
|
||||
|
||||
public function getImplementation($scope)
|
||||
{
|
||||
if (empty($this->implementationHashMap[$scope])) {
|
||||
$normalizedName = Util::normilizeClassName($scope);
|
||||
|
||||
$className = '\\Espo\\Custom\\Acl\\' . $normalizedName;
|
||||
if (!class_exists($className)) {
|
||||
$moduleName = $this->metadata->getScopeModuleName($scope);
|
||||
if ($moduleName) {
|
||||
$className = '\\Espo\\Modules\\' . $moduleName . '\\Acl\\' . $normalizedName;
|
||||
} else {
|
||||
$className = '\\Espo\\Acl\\' . $normalizedName;
|
||||
}
|
||||
if (!class_exists($className)) {
|
||||
$className = '\\Espo\\Core\\Acl\\Base';
|
||||
}
|
||||
}
|
||||
|
||||
if (class_exists($className)) {
|
||||
$acl = new $className();
|
||||
$dependencies = $acl->getDependencyList();
|
||||
foreach ($dependencies as $name) {
|
||||
$acl->inject($name, $this->container->get($name));
|
||||
}
|
||||
$this->implementationHashMap[$scope] = $acl;
|
||||
} else {
|
||||
throw new Error();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->implementationHashMap[$scope];
|
||||
}
|
||||
|
||||
protected function getTable(User $user)
|
||||
{
|
||||
$key = spl_object_hash($user);
|
||||
|
||||
if (empty($this->tableHashMap[$key])) {
|
||||
$config = $this->getContainer()->get('config');
|
||||
$fileManager = $this->getContainer()->get('fileManager');
|
||||
$metadata = $this->getContainer()->get('metadata');
|
||||
|
||||
$this->tableHashMap[$key] = new \Espo\Core\Acl\Table($user, $config, $fileManager, $metadata);
|
||||
}
|
||||
|
||||
return $this->tableHashMap[$key];
|
||||
}
|
||||
|
||||
public function getMap(User $user)
|
||||
{
|
||||
return $this->getTable($user)->getMap();
|
||||
}
|
||||
|
||||
public function getLevel(User $user, $scope, $action)
|
||||
{
|
||||
if ($user->isAdmin()) {
|
||||
return 'all';
|
||||
}
|
||||
return $this->getTable($user)->getLevel($scope, $action);
|
||||
}
|
||||
|
||||
public function get(User $user, $permission)
|
||||
{
|
||||
if ($user->isAdmin()) {
|
||||
return true;
|
||||
}
|
||||
$this->getTable($user)->get($permission);
|
||||
}
|
||||
|
||||
public function checkReadOnlyTeam(User $user, $scope)
|
||||
{
|
||||
if ($user->isAdmin()) {
|
||||
return false;
|
||||
}
|
||||
$data = $this->getTable($user)->getScopeData($scope);
|
||||
return $this->getImplementation($scope)->checkReadOnlyTeam($user, $scope, $data);
|
||||
}
|
||||
|
||||
public function checkReadOnlyOwn(User $user, $scope)
|
||||
{
|
||||
if ($user->isAdmin()) {
|
||||
return false;
|
||||
}
|
||||
$data = $this->getTable($user)->getScopeData($scope);
|
||||
return $this->getImplementation($scope)->checkReadOnlyOwn($user, $scope, $data);
|
||||
}
|
||||
|
||||
public function check(User $user, $subject, $action = null, $isOwner = null, $inTeam = null)
|
||||
{
|
||||
if ($user->isAdmin()) {
|
||||
return true;
|
||||
}
|
||||
if (is_string($subject)) {
|
||||
return $this->checkScope($user, $subject, $action, $isOwner, $inTeam);
|
||||
} else {
|
||||
$entity = $subject;
|
||||
if ($entity instanceof Entity) {
|
||||
$entityType = $entity->getEntityType();
|
||||
|
||||
$impl = $this->getImplementation($entityType);
|
||||
$methodName = 'checkEntity' . ucfirst($action);
|
||||
if (method_exists($impl, $methodName)) {
|
||||
$data = $this->getTable($user)->getScopeData($entityType);
|
||||
return $impl->$methodName($user, $entity, $data);
|
||||
}
|
||||
|
||||
return $this->checkEntity($user, $entity, $action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function checkEntity(User $user, Entity $entity, $action)
|
||||
{
|
||||
if ($user->isAdmin()) {
|
||||
return true;
|
||||
}
|
||||
$data = $this->getTable($user)->getScopeData($entity->getEntityType());
|
||||
return $this->getImplementation($scope)->checkEntity($user, $entity, $data, $action);
|
||||
}
|
||||
|
||||
public function checkScope(User $user, $scope, $action = null, $isOwner = null, $inTeam = null, $entity = null)
|
||||
{
|
||||
if ($user->isAdmin()) {
|
||||
return true;
|
||||
}
|
||||
$data = $this->getTable($user)->getScopeData($scope);
|
||||
return $this->getImplementation($scope)->checkScope($user, $data, $scope, $action, $isOwner, $inTeam, $entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +138,12 @@ class Application
|
||||
$dataManager->rebuild();
|
||||
}
|
||||
|
||||
public function runClearCache()
|
||||
{
|
||||
$dataManager = $this->getContainer()->get('dataManager');
|
||||
$dataManager->clearCache();
|
||||
}
|
||||
|
||||
public function isInstalled()
|
||||
{
|
||||
$config = $this->getContainer()->get('config');
|
||||
|
||||
@@ -194,14 +194,20 @@ class Container
|
||||
);
|
||||
}
|
||||
|
||||
private function loadAclManager()
|
||||
{
|
||||
$className = $this->getServiceClassName('acl', '\\Espo\\Core\\AclManager');
|
||||
return new $className(
|
||||
$this->get('container')
|
||||
);
|
||||
}
|
||||
|
||||
private function loadAcl()
|
||||
{
|
||||
$className = $this->getServiceClassName('acl', '\\Espo\\Core\\Acl');
|
||||
return new $className(
|
||||
$this->get('user'),
|
||||
$this->get('config'),
|
||||
$this->get('fileManager'),
|
||||
$this->get('metadata')
|
||||
$this->get('aclManager'),
|
||||
$this->get('user')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,11 @@ abstract class Base
|
||||
return $this->container->get('acl');
|
||||
}
|
||||
|
||||
protected function getAclManager()
|
||||
{
|
||||
return $this->container->get('aclManager');
|
||||
}
|
||||
|
||||
protected function getConfig()
|
||||
{
|
||||
return $this->container->get('config');
|
||||
|
||||
@@ -34,6 +34,8 @@ class Record extends Base
|
||||
|
||||
public static $defaultAction = 'list';
|
||||
|
||||
protected $defaultRecordServiceName = 'Record';
|
||||
|
||||
protected function getEntityManager()
|
||||
{
|
||||
return $this->getContainer()->get('entityManager');
|
||||
@@ -48,7 +50,7 @@ class Record extends Base
|
||||
if ($this->getServiceFactory()->checkExists($name)) {
|
||||
$service = $this->getServiceFactory()->create($name);
|
||||
} else {
|
||||
$service = $this->getServiceFactory()->create('Record');
|
||||
$service = $this->getServiceFactory()->create($this->defaultRecordServiceName);
|
||||
$service->setEntityName($name);
|
||||
}
|
||||
|
||||
|
||||
57
application/Espo/Core/Controllers/RecordTree.php
Normal file
57
application/Espo/Core/Controllers/RecordTree.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Controllers;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
use \Espo\Core\Exceptions\Forbidden;
|
||||
use \Espo\Core\Exceptions\NotFound;
|
||||
use \Espo\Core\Exceptions\BadRequest;
|
||||
use \Espo\Core\Utils\Util;
|
||||
|
||||
class RecordTree extends Record
|
||||
{
|
||||
|
||||
public static $defaultAction = 'list';
|
||||
|
||||
protected $defaultRecordServiceName = 'RecordTree';
|
||||
|
||||
public function actionListTree($params, $data, $request)
|
||||
{
|
||||
if (!$this->getAcl()->check($this->name, 'read')) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$where = $request->get('where');
|
||||
$parentId = $request->get('parentId');
|
||||
$maxDepth = $request->get('maxDepth');
|
||||
|
||||
$collection = $this->getRecordService()->getTree($parentId, array(
|
||||
'where' => $where
|
||||
), 0, $maxDepth);
|
||||
return array(
|
||||
'list' => $collection->toArray(),
|
||||
'path' => $this->getRecordService()->getTreeItemPath($parentId)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
43
application/Espo/Core/Entities/CategoryTreeItem.php
Normal file
43
application/Espo/Core/Entities/CategoryTreeItem.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Entities;
|
||||
|
||||
class CategoryTreeItem extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
public function toArray()
|
||||
{
|
||||
$data = parent::toArray();
|
||||
$childList = $this->get('childList');
|
||||
if (is_null($childList)) {
|
||||
$data['childList'] = null;
|
||||
} else {
|
||||
$arr = [];
|
||||
foreach ($childList as $entity) {
|
||||
$arr[] = $entity->toArray();
|
||||
}
|
||||
$data['childList'] = $arr;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\EntryPoints;
|
||||
|
||||
@@ -29,50 +29,50 @@ use \Espo\Core\Exceptions\Forbidden;
|
||||
abstract class Base
|
||||
{
|
||||
private $container;
|
||||
|
||||
|
||||
public static $authRequired = true;
|
||||
|
||||
|
||||
protected function getContainer()
|
||||
{
|
||||
return $this->container;
|
||||
}
|
||||
|
||||
|
||||
protected function getUser()
|
||||
{
|
||||
return $this->getContainer()->get('user');
|
||||
}
|
||||
|
||||
|
||||
protected function getAcl()
|
||||
{
|
||||
return $this->getContainer()->get('acl');
|
||||
}
|
||||
|
||||
|
||||
protected function getEntityManager()
|
||||
{
|
||||
return $this->getContainer()->get('entityManager');
|
||||
}
|
||||
|
||||
|
||||
protected function getServiceFactory()
|
||||
{
|
||||
return $this->getContainer()->get('serviceFactory');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function getConfig()
|
||||
{
|
||||
return $this->getContainer()->get('config');
|
||||
}
|
||||
|
||||
|
||||
protected function getMetadata()
|
||||
{
|
||||
return $this->getContainer()->get('metadata');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function __construct(Container $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
abstract public function run();
|
||||
|
||||
abstract public function run();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -93,10 +93,10 @@ class HookManager
|
||||
}
|
||||
}
|
||||
|
||||
public function process($scope, $hookName, $injection = null)
|
||||
public function process($scope, $hookName, $injection = null, array $options = array())
|
||||
{
|
||||
if ($scope != 'Common') {
|
||||
$this->process('Common', $hookName, $injection);
|
||||
$this->process('Common', $hookName, $injection, $options);
|
||||
}
|
||||
|
||||
if (!empty($this->data[$scope])) {
|
||||
@@ -106,7 +106,7 @@ class HookManager
|
||||
$this->hooks[$className] = $this->createHookByClassName($className);
|
||||
}
|
||||
$hook = $this->hooks[$className];
|
||||
$hook->$hookName($injection);
|
||||
$hook->$hookName($injection, $options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Espo\Core\Hooks;
|
||||
|
||||
use \Espo\Core\Interfaces\Injectable;
|
||||
|
||||
class Base implements Injectable
|
||||
abstract class Base implements Injectable
|
||||
{
|
||||
protected $dependencies = array(
|
||||
'entityManager',
|
||||
@@ -52,6 +52,11 @@ class Base implements Injectable
|
||||
return $this->dependencies;
|
||||
}
|
||||
|
||||
protected function addDependency($name)
|
||||
{
|
||||
$this->dependencies[] = $name;
|
||||
}
|
||||
|
||||
protected function getInjection($name)
|
||||
{
|
||||
return $this->injections[$name];
|
||||
|
||||
@@ -74,7 +74,10 @@ class Importer
|
||||
|
||||
$fromArr = $this->getAddressListFromMessage($message, 'from');
|
||||
if (isset($message->from)) {
|
||||
$email->set('fromName', $message->from);
|
||||
$email->set('fromString', $message->from);
|
||||
}
|
||||
if (isset($message->replyTo)) {
|
||||
$email->set('replyToString', $message->replyTo);
|
||||
}
|
||||
|
||||
$toArr = $this->getAddressListFromMessage($message, 'to');
|
||||
@@ -92,7 +95,12 @@ class Importer
|
||||
}
|
||||
|
||||
if ($duplicate = $this->findDuplicate($email)) {
|
||||
$this->getEntityManager()->getRepository('Email')->relate($duplicate, 'users', $userId);
|
||||
$duplicate->loadLinkMultipleField('users');
|
||||
$usersIds = $duplicate->get('usersIds');
|
||||
$usersIds[] = $userId;
|
||||
$duplicate->set('usersIds', $usersIds);
|
||||
$this->getEntityManager()->saveEntity($duplicate);
|
||||
|
||||
if (!empty($teamsIds)) {
|
||||
foreach ($teamsIds as $teamId) {
|
||||
$this->getEntityManager()->getRepository('Email')->relate($duplicate, 'teams', $teamId);
|
||||
@@ -107,7 +115,9 @@ class Importer
|
||||
$dateSent = $dt->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d H:i:s');
|
||||
$email->set('dateSent', $dateSent);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$email->set('dateSent', date('Y-m-d H:i:s'));
|
||||
}
|
||||
if (isset($message->deliveryDate)) {
|
||||
$dt = new \DateTime($message->deliveryDate);
|
||||
if ($dt) {
|
||||
@@ -123,7 +133,7 @@ class Importer
|
||||
$this->importPartDataToEmail($email, $part, $inlineIds);
|
||||
}
|
||||
} else {
|
||||
$this->importPartDataToEmail($email, $message, $inlineIds);
|
||||
$this->importPartDataToEmail($email, $message, $inlineIds, 'text/plain');
|
||||
}
|
||||
|
||||
$body = $email->get('body');
|
||||
@@ -194,7 +204,16 @@ class Importer
|
||||
$email->set('parentType', 'Account');
|
||||
$email->set('parentId', $account->id);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
$lead = $this->getEntityManager()->getRepository('Lead')->where(array(
|
||||
'emailAddress' => $emailAddress
|
||||
))->findOne();
|
||||
if ($lead) {
|
||||
$email->set('parentType', 'Lead');
|
||||
$email->set('parentId', $lead->id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,19 +242,29 @@ class Importer
|
||||
return $addressList;
|
||||
}
|
||||
|
||||
protected function importPartDataToEmail(\Espo\Entities\Email $email, $part, &$inlineIds = array())
|
||||
protected function importPartDataToEmail(\Espo\Entities\Email $email, $part, &$inlineIds = array(), $defaultContentType = null)
|
||||
{
|
||||
try {
|
||||
if (!$part->getHeaders() || !isset($part->contentType)) {
|
||||
return;
|
||||
$type = null;
|
||||
|
||||
if ($part->getHeaders() && isset($part->contentType)) {
|
||||
$type = strtok($part->contentType, ';');
|
||||
}
|
||||
|
||||
if (empty($type)) {
|
||||
if (!empty($defaultContentType)) {
|
||||
$type = $defaultContentType;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$type = strtok($part->contentType, ';');
|
||||
$encoding = null;
|
||||
|
||||
$isAttachment = true;
|
||||
|
||||
if ($type == 'text/plain' || $type == 'text/html') {
|
||||
|
||||
$isAttachment = false;
|
||||
$content = $this->getContentFromPart($part);
|
||||
if ($type == 'text/plain') {
|
||||
|
||||
@@ -284,9 +284,19 @@ class Sender
|
||||
|
||||
$message->setBody($body);
|
||||
|
||||
if ($message->getHeaders()->has('content-type')) {
|
||||
if ($messageType == 'text/plain') {
|
||||
if ($message->getHeaders()->has('content-type')) {
|
||||
$message->getHeaders()->removeHeader('content-type');
|
||||
}
|
||||
$message->getHeaders()->addHeaderLine('Content-Type', 'text/plain; charset=UTF-8');
|
||||
} else {
|
||||
if (!$message->getHeaders()->has('content-type')) {
|
||||
$contentTypeHeader = new \Zend\Mail\Header\ContentType();
|
||||
$message->getHeaders()->addHeader($contentTypeHeader);
|
||||
}
|
||||
$message->getHeaders()->get('content-type')->setType($messageType);
|
||||
}
|
||||
|
||||
$message->setEncoding('UTF-8');
|
||||
|
||||
try {
|
||||
@@ -304,7 +314,7 @@ class Sender
|
||||
|
||||
$this->transport->send($message);
|
||||
|
||||
$email->set('messageId', $messageId);
|
||||
$email->set('messageId', '<' . $messageId . '>');
|
||||
$email->set('status', 'Sent');
|
||||
$email->set('dateSent', date("Y-m-d H:i:s"));
|
||||
} catch (\Exception $e) {
|
||||
|
||||
103
application/Espo/Core/Notificators/Base.php
Normal file
103
application/Espo/Core/Notificators/Base.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Notificators;
|
||||
|
||||
use \Espo\Core\Interfaces\Injectable;
|
||||
|
||||
use \Espo\ORM\Entity;
|
||||
|
||||
class Base implements Injectable
|
||||
{
|
||||
protected $dependencies = array(
|
||||
'user',
|
||||
'entityManager',
|
||||
);
|
||||
|
||||
protected $injections = array();
|
||||
|
||||
public static $order = 9;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->init();
|
||||
}
|
||||
|
||||
protected function init()
|
||||
{
|
||||
}
|
||||
|
||||
protected function addDependency($name)
|
||||
{
|
||||
$this->dependencies[] = $name;
|
||||
}
|
||||
|
||||
public function getDependencyList()
|
||||
{
|
||||
return $this->dependencies;
|
||||
}
|
||||
|
||||
protected function getInjection($name)
|
||||
{
|
||||
return $this->injections[$name];
|
||||
}
|
||||
|
||||
public function inject($name, $object)
|
||||
{
|
||||
$this->injections[$name] = $object;
|
||||
}
|
||||
|
||||
protected function getEntityManager()
|
||||
{
|
||||
return $this->injections['entityManager'];
|
||||
}
|
||||
|
||||
protected function getUser()
|
||||
{
|
||||
return $this->injections['user'];
|
||||
}
|
||||
|
||||
public function process(Entity $entity)
|
||||
{
|
||||
if ($entity->has('assignedUserId') && $entity->get('assignedUserId')) {
|
||||
$assignedUserId = $entity->get('assignedUserId');
|
||||
if ($assignedUserId != $this->getUser()->id && $entity->isFieldChanged('assignedUserId')) {
|
||||
$notification = $this->getEntityManager()->getEntity('Notification');
|
||||
$notification->set(array(
|
||||
'type' => 'Assign',
|
||||
'userId' => $assignedUserId,
|
||||
'data' => array(
|
||||
'entityType' => $entity->getEntityType(),
|
||||
'entityId' => $entity->id,
|
||||
'entityName' => $entity->get('name'),
|
||||
'isNew' => $entity->isNew(),
|
||||
'userId' => $this->getUser()->id,
|
||||
'userName' => $this->getUser()->get('name')
|
||||
)
|
||||
));
|
||||
$this->getEntityManager()->saveEntity($notification);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,17 +41,20 @@ class Entity extends \Espo\ORM\Entity
|
||||
$columnsData = new \stdClass();
|
||||
}
|
||||
|
||||
foreach ($collection as $e) {
|
||||
$id = $e->id;
|
||||
$ids[] = $id;
|
||||
$names->$id = $e->get('name');
|
||||
if (!empty($columns)) {
|
||||
$columnsData->$id = new \stdClass();
|
||||
foreach ($columns as $column => $f) {
|
||||
$columnsData->$id->$column = $e->get($f);
|
||||
if ($collection) {
|
||||
foreach ($collection as $e) {
|
||||
$id = $e->id;
|
||||
$ids[] = $id;
|
||||
$names->$id = $e->get('name');
|
||||
if (!empty($columns)) {
|
||||
$columnsData->$id = new \stdClass();
|
||||
foreach ($columns as $column => $f) {
|
||||
$columnsData->$id->$column = $e->get($f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->set($field . 'Ids', $ids);
|
||||
$this->set($field . 'Names', $names);
|
||||
if (!empty($columns)) {
|
||||
|
||||
@@ -140,10 +140,10 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
|
||||
}
|
||||
}
|
||||
|
||||
protected function beforeRemove(Entity $entity)
|
||||
protected function beforeRemove(Entity $entity, array $options = array())
|
||||
{
|
||||
parent::beforeRemove($entity);
|
||||
$this->getEntityManager()->getHookManager()->process($this->entityName, 'beforeRemove', $entity);
|
||||
parent::beforeRemove($entity, $options);
|
||||
$this->getEntityManager()->getHookManager()->process($this->entityName, 'beforeRemove', $entity, $options);
|
||||
|
||||
$nowString = date('Y-m-d H:i:s', time());
|
||||
if ($entity->hasField('modifiedAt')) {
|
||||
@@ -154,53 +154,53 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
|
||||
}
|
||||
}
|
||||
|
||||
protected function afterRemove(Entity $entity)
|
||||
protected function afterRemove(Entity $entity, array $options = array())
|
||||
{
|
||||
parent::afterRemove($entity);
|
||||
$this->getEntityManager()->getHookManager()->process($this->entityName, 'afterRemove', $entity);
|
||||
parent::afterRemove($entity, $options);
|
||||
$this->getEntityManager()->getHookManager()->process($this->entityName, 'afterRemove', $entity, $options);
|
||||
}
|
||||
|
||||
public function remove(Entity $entity)
|
||||
public function remove(Entity $entity, array $options = array())
|
||||
{
|
||||
$this->getEntityManager()->getHookManager()->process($this->entityName, 'beforeRemove', $entity);
|
||||
$this->getEntityManager()->getHookManager()->process($this->entityName, 'beforeRemove', $entity, $options);
|
||||
|
||||
$result = parent::remove($entity);
|
||||
$result = parent::remove($entity, $options);
|
||||
if ($result) {
|
||||
$this->getEntityManager()->getHookManager()->process($this->entityName, 'afterRemove', $entity);
|
||||
$this->getEntityManager()->getHookManager()->process($this->entityName, 'afterRemove', $entity, $options);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function beforeSave(Entity $entity)
|
||||
protected function beforeSave(Entity $entity, array $options = array())
|
||||
{
|
||||
parent::beforeSave($entity);
|
||||
parent::beforeSave($entity, $options);
|
||||
|
||||
$this->getEntityManager()->getHookManager()->process($this->entityName, 'beforeSave', $entity);
|
||||
$this->getEntityManager()->getHookManager()->process($this->entityName, 'beforeSave', $entity, $options);
|
||||
}
|
||||
|
||||
protected function afterSave(Entity $entity)
|
||||
protected function afterSave(Entity $entity, array $options = array())
|
||||
{
|
||||
if (!empty($this->restoreData)) {
|
||||
$entity->set($this->restoreData);
|
||||
$this->restoreData = null;
|
||||
}
|
||||
parent::afterSave($entity);
|
||||
parent::afterSave($entity, $options);
|
||||
|
||||
$this->handleEmailAddressSave($entity);
|
||||
$this->handlePhoneNumberSave($entity);
|
||||
$this->handleSpecifiedRelations($entity);
|
||||
|
||||
$this->getEntityManager()->getHookManager()->process($this->entityName, 'afterSave', $entity);
|
||||
$this->getEntityManager()->getHookManager()->process($this->entityName, 'afterSave', $entity, $options);
|
||||
}
|
||||
|
||||
public function save(Entity $entity)
|
||||
public function save(Entity $entity, array $options = array())
|
||||
{
|
||||
$nowString = date('Y-m-d H:i:s', time());
|
||||
$restoreData = array();
|
||||
|
||||
if ($entity->isNew()) {
|
||||
if (!$entity->has('id')) {
|
||||
$entity->set('id', uniqid());
|
||||
$entity->set('id', Util::generateId());
|
||||
}
|
||||
|
||||
if ($entity->hasField('createdAt')) {
|
||||
@@ -221,11 +221,13 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
|
||||
}
|
||||
$entity->clear('modifiedById');
|
||||
} else {
|
||||
if ($entity->hasField('modifiedAt')) {
|
||||
$entity->set('modifiedAt', $nowString);
|
||||
}
|
||||
if ($entity->hasField('modifiedById')) {
|
||||
$entity->set('modifiedById', $this->entityManager->getUser()->id);
|
||||
if (empty($options['silent'])) {
|
||||
if ($entity->hasField('modifiedAt')) {
|
||||
$entity->set('modifiedAt', $nowString);
|
||||
}
|
||||
if ($entity->hasField('modifiedById')) {
|
||||
$entity->set('modifiedById', $this->entityManager->getUser()->id);
|
||||
}
|
||||
}
|
||||
|
||||
if ($entity->has('createdById')) {
|
||||
@@ -239,7 +241,7 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
|
||||
}
|
||||
$this->restoreData = $restoreData;
|
||||
|
||||
$result = parent::save($entity);
|
||||
$result = parent::save($entity, $options);
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -268,6 +270,10 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
|
||||
|
||||
if ($entity->has($fieldName) || $entity->has($columnsFieldsName)) {
|
||||
|
||||
if ($this->getMetadata()->get("entityDefs." . $entity->getEntityType() . ".fields.{$name}.noSave")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($entity->has($fieldName)) {
|
||||
$specifiedIds = $entity->get($fieldName);
|
||||
} else {
|
||||
@@ -283,24 +289,27 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
|
||||
$existingColumnsData = new \stdClass();
|
||||
|
||||
$defs = array();
|
||||
$columns = $this->getMetadata()->get("entityDefs." . $entity->getEntityName() . ".fields.{$name}.columns");
|
||||
$columns = $this->getMetadata()->get("entityDefs." . $entity->getEntityType() . ".fields.{$name}.columns");
|
||||
if (!empty($columns)) {
|
||||
$columnData = $entity->get($columnsFieldsName);
|
||||
$defs['additionalColumns'] = $columns;
|
||||
}
|
||||
|
||||
foreach ($entity->get($name, $defs) as $foreignEntity) {
|
||||
$existingIds[] = $foreignEntity->id;
|
||||
if (!empty($columns)) {
|
||||
$data = new \stdClass();
|
||||
foreach ($columns as $columnName => $columnField) {
|
||||
$foreignId = $foreignEntity->id;
|
||||
$data->$columnName = $foreignEntity->get($columnField);
|
||||
$foreignCollection = $entity->get($name, $defs);
|
||||
if ($foreignCollection) {
|
||||
foreach ($foreignCollection as $foreignEntity) {
|
||||
$existingIds[] = $foreignEntity->id;
|
||||
if (!empty($columns)) {
|
||||
$data = new \stdClass();
|
||||
foreach ($columns as $columnName => $columnField) {
|
||||
$foreignId = $foreignEntity->id;
|
||||
$data->$columnName = $foreignEntity->get($columnField);
|
||||
}
|
||||
$existingColumnsData->$foreignId = $data;
|
||||
$entity->setFetched($columnsFieldsName, $existingColumnsData);
|
||||
}
|
||||
$existingColumnsData->$foreignId = $data;
|
||||
$entity->setFetched($columnsFieldsName, $existingColumnsData);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($entity->has($fieldName)) {
|
||||
|
||||
95
application/Espo/Core/Repositories/CategoryTree.php
Normal file
95
application/Espo/Core/Repositories/CategoryTree.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Repositories;
|
||||
|
||||
use \Espo\Core\Entities\CategoryTreeItem as Entity;
|
||||
|
||||
class CategoryTree extends \Espo\Core\ORM\Repositories\RDB
|
||||
{
|
||||
public function afterSave(Entity $entity, $options)
|
||||
{
|
||||
parent::afterSave($entity, $options);
|
||||
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
$query = $this->getEntityManager()->getQuery();
|
||||
|
||||
$parentId = $entity->get('parentId');
|
||||
$pathsTableName = $query->toDb($entity->getEntityType() . 'Path');
|
||||
|
||||
if ($entity->isNew()) {
|
||||
if ($parentId) {
|
||||
$sql = "
|
||||
INSERT INTO `".$pathsTableName."` (ascendor_id, descendor_id)
|
||||
SELECT ascendor_id, ".$pdo->quote($entity->id)."
|
||||
FROM `".$pathsTableName."`
|
||||
WHERE descendor_id = ".$pdo->quote($parentId)."
|
||||
UNION ALL
|
||||
SELECT ".$pdo->quote($entity->id).", ".$pdo->quote($entity->id)."
|
||||
";
|
||||
} else {
|
||||
$sql = "
|
||||
INSERT INTO `".$pathsTableName."` (ascendor_id, descendor_id)
|
||||
VALUES
|
||||
(".$pdo->quote($entity->id).", ".$pdo->quote($entity->id).")
|
||||
";
|
||||
}
|
||||
$pdo->query($sql);
|
||||
} else {
|
||||
if ($entity->isFieldChanged('parentId')) {
|
||||
$sql = "
|
||||
DELETE a FROM `".$pathsTableName."` AS a
|
||||
JOIN `".$pathsTableName."` AS d ON a.descendor_id = d.descendor_id
|
||||
LEFT JOIN `".$pathsTableName."` AS x ON x.ascendor_id = d.ascendor_id AND x.descendor_id = a.ascendor_id
|
||||
WHERE d.ascendor_id = ".$pdo->quote($entity->id)." AND x.ascendor_id IS NULL
|
||||
";
|
||||
$pdo->query($sql);
|
||||
if (!empty($parentId)) {
|
||||
$sql = "
|
||||
INSERT INTO `".$pathsTableName."` (ascendor_id, descendor_id)
|
||||
SELECT supertree.ascendor_id, subtree.descendor_id
|
||||
FROM `".$pathsTableName."` AS supertree
|
||||
JOIN `".$pathsTableName."` AS subtree
|
||||
WHERE
|
||||
subtree.ascendor_id = ".$pdo->quote($entity->id)." AND
|
||||
supertree.descendor_id = ".$pdo->quote($parentId)."
|
||||
";
|
||||
$pdo->query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function afterRemove(Entity $entity, $options)
|
||||
{
|
||||
parent::afterRemove($entity, $options);
|
||||
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
$query = $this->getEntityManager()->getQuery();
|
||||
|
||||
$pathsTableName = $query->toDb($entity->getEntityType() . 'Path');
|
||||
|
||||
$sql = "DELETE FROM `".$pathsTableName."` WHERE descendor_id = ".$pdo->quote($entity->id)."";
|
||||
$pdo->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,13 +44,13 @@ class SelectManagerFactory
|
||||
$this->metadata = $metadata;
|
||||
}
|
||||
|
||||
public function create($entityName)
|
||||
public function create($entityType)
|
||||
{
|
||||
$normalizedName = Util::normilizeClassName($entityName);
|
||||
$normalizedName = Util::normilizeClassName($entityType);
|
||||
|
||||
$className = '\\Espo\\Custom\\SelectManagers\\' . $normalizedName;
|
||||
if (!class_exists($className)) {
|
||||
$moduleName = $this->metadata->getScopeModuleName($entityName);
|
||||
$moduleName = $this->metadata->getScopeModuleName($entityType);
|
||||
if ($moduleName) {
|
||||
$className = '\\Espo\\Modules\\' . $moduleName . '\\SelectManagers\\' . $normalizedName;
|
||||
} else {
|
||||
@@ -62,7 +62,7 @@ class SelectManagerFactory
|
||||
}
|
||||
|
||||
$selectManager = new $className($this->entityManager, $this->user, $this->acl, $this->metadata);
|
||||
$selectManager->setEntityName($entityName);
|
||||
$selectManager->setEntityType($entityType);
|
||||
|
||||
return $selectManager;
|
||||
}
|
||||
|
||||
@@ -36,12 +36,14 @@ class Base
|
||||
|
||||
protected $entityManager;
|
||||
|
||||
protected $entityName;
|
||||
protected $entityType;
|
||||
|
||||
protected $metadata;
|
||||
|
||||
private $seed = null;
|
||||
|
||||
private $userTimeZone = null;
|
||||
|
||||
const MIN_LENGTH_FOR_CONTENT_SEARCH = 4;
|
||||
|
||||
public function __construct($entityManager, \Espo\Entities\User $user, Acl $acl, $metadata)
|
||||
@@ -63,9 +65,14 @@ class Base
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setEntityName($entityName)
|
||||
public function setEntityType($entityType)
|
||||
{
|
||||
$this->entityName = $entityName;
|
||||
$this->entityType = $entityType;
|
||||
}
|
||||
|
||||
protected function getEntityType()
|
||||
{
|
||||
return $this->entityType;
|
||||
}
|
||||
|
||||
protected function limit($params, &$result)
|
||||
@@ -82,7 +89,7 @@ class Base
|
||||
{
|
||||
if (!empty($params['sortBy'])) {
|
||||
$result['orderBy'] = $params['sortBy'];
|
||||
$type = $this->metadata->get("entityDefs.{$this->entityName}.fields." . $result['orderBy'] . ".type");
|
||||
$type = $this->metadata->get("entityDefs.{$this->entityType}.fields." . $result['orderBy'] . ".type");
|
||||
if ($type == 'link') {
|
||||
$result['orderBy'] .= 'Name';
|
||||
} else if ($type == 'linkParent') {
|
||||
@@ -100,13 +107,13 @@ class Base
|
||||
|
||||
protected function getTextFilterFields()
|
||||
{
|
||||
return $this->metadata->get("entityDefs.{$this->entityName}.collection.textFilterFields", array('name'));
|
||||
return $this->metadata->get("entityDefs.{$this->entityType}.collection.textFilterFields", array('name'));
|
||||
}
|
||||
|
||||
protected function getSeed()
|
||||
{
|
||||
if (empty($this->seed)) {
|
||||
$this->seed = $this->entityManager->getEntity($this->entityName);
|
||||
$this->seed = $this->entityManager->getEntity($this->entityType);
|
||||
}
|
||||
return $this->seed;
|
||||
}
|
||||
@@ -139,7 +146,7 @@ class Base
|
||||
$where = array();
|
||||
|
||||
foreach ($params['where'] as $item) {
|
||||
if ($item['type'] == 'boolFilters' && !empty($item['value']) && is_array($item['value'])) {
|
||||
if ($item['type'] == 'bool' && !empty($item['value']) && is_array($item['value'])) {
|
||||
foreach ($item['value'] as $filter) {
|
||||
$p = $this->getBoolFilterWhere($filter);
|
||||
if (!empty($p)) {
|
||||
@@ -151,11 +158,15 @@ class Base
|
||||
if (!empty($item['value'])) {
|
||||
$this->textFilter($item['value'], $result);
|
||||
}
|
||||
} else if ($item['type'] == 'primary' && !empty($item['value'])) {
|
||||
$this->primaryFilter($item['value'], $result);
|
||||
}
|
||||
}
|
||||
|
||||
$linkedWith = array();
|
||||
$ignoreList = array('linkedWith', 'boolFilters');
|
||||
$inCategory = array();
|
||||
|
||||
$ignoreList = ['linkedWith', 'inCategory', 'bool', 'primary'];
|
||||
foreach ($params['where'] as $item) {
|
||||
if (!in_array($item['type'], $ignoreList)) {
|
||||
$part = $this->getWherePart($item);
|
||||
@@ -165,51 +176,117 @@ class Base
|
||||
} else {
|
||||
if ($item['type'] == 'linkedWith' && !empty($item['value'])) {
|
||||
$linkedWith[$item['field']] = $item['value'];
|
||||
} else if ($item['type'] == 'inCategory' && !empty($item['value'])) {
|
||||
$inCategory[$item['field']] = $item['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($linkedWith)) {
|
||||
$joins = array();
|
||||
|
||||
$part = array();
|
||||
foreach ($linkedWith as $link => $idsValue) {
|
||||
if (is_array($idsValue) && count($idsValue) == 1) {
|
||||
$idsValue = $idsValue[0];
|
||||
}
|
||||
|
||||
$relDefs = $this->getSeed()->getRelations();
|
||||
|
||||
if (!empty($relDefs[$link])) {
|
||||
$defs = $relDefs[$link];
|
||||
if ($defs['type'] == 'manyMany') {
|
||||
$joins[] = $link;
|
||||
if (!empty($defs['relationName']) && !empty($defs['midKeys'])) {
|
||||
$key = $defs['midKeys'][1];
|
||||
$relationName = $defs['relationName'];
|
||||
$part[$relationName . '.' . $key] = $idsValue;
|
||||
}
|
||||
} else if ($defs['type'] == 'belongsTo') {
|
||||
if (!empty($defs['type']['key'])) {
|
||||
$key = $defs['type']['key'];
|
||||
$part[$key] = $idsValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($part)) {
|
||||
$where[] = $part;
|
||||
}
|
||||
$result['joins'] = $joins;
|
||||
$result['distinct'] = true;
|
||||
|
||||
}
|
||||
|
||||
$result['whereClause'] = array_merge($result['whereClause'], $where);
|
||||
|
||||
if (!empty($linkedWith)) {
|
||||
$this->handleLinkedWith($linkedWith, $result);
|
||||
}
|
||||
if (!empty($inCategory)) {
|
||||
$this->handleInCategory($inCategory, $result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function handleLinkedWith($linkedWith, &$result)
|
||||
{
|
||||
$joins = [];
|
||||
|
||||
$part = array();
|
||||
foreach ($linkedWith as $link => $idsValue) {
|
||||
if (is_array($idsValue) && count($idsValue) == 1) {
|
||||
$idsValue = $idsValue[0];
|
||||
}
|
||||
|
||||
$relDefs = $this->getSeed()->getRelations();
|
||||
|
||||
if (!empty($relDefs[$link])) {
|
||||
$defs = $relDefs[$link];
|
||||
if ($defs['type'] == 'manyMany') {
|
||||
$joins[] = $link;
|
||||
if (!empty($defs['relationName']) && !empty($defs['midKeys'])) {
|
||||
$key = $defs['midKeys'][1];
|
||||
$relationName = lcfirst($defs['relationName']);
|
||||
$part[$relationName . '.' . $key] = $idsValue;
|
||||
}
|
||||
} else if ($defs['type'] == 'belongsTo') {
|
||||
if (!empty($defs['key'])) {
|
||||
$key = $defs['key'];
|
||||
$part[$key] = $idsValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($part)) {
|
||||
$result['whereClause'][] = $part;
|
||||
}
|
||||
$result['joins'] = array_merge($result['joins'], $joins);
|
||||
$result['distinct'] = true;
|
||||
}
|
||||
|
||||
protected function handleInCategory($inCategory, &$result)
|
||||
{
|
||||
$joins = [];
|
||||
|
||||
$part = array();
|
||||
|
||||
$query = $this->getEntityManager()->getQuery();
|
||||
|
||||
$tableName = $query->toDb($this->getSeed()->getEntityType());
|
||||
|
||||
foreach ($inCategory as $link => $val) {
|
||||
|
||||
$relDefs = $this->getSeed()->getRelations();
|
||||
|
||||
if (!empty($relDefs[$link])) {
|
||||
$defs = $relDefs[$link];
|
||||
|
||||
$foreignEntity = $defs['entity'];
|
||||
if (empty($foreignEntity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$pathName = lcfirst($query->sanitize($foreignEntity . 'Path'));
|
||||
|
||||
if ($defs['type'] == 'manyMany') {
|
||||
|
||||
if (!empty($defs['relationName']) && !empty($defs['midKeys'])) {
|
||||
$result['distinct'] = true;
|
||||
$result['joins'][] = $link;
|
||||
$key = $defs['midKeys'][1];
|
||||
|
||||
$relationName = lcfirst($defs['relationName']);
|
||||
|
||||
$result['customJoin'] .= "
|
||||
JOIN " . $query->toDb($pathName) . " AS `{$pathName}` ON {$pathName}.descendor_id = ".$query->sanitize($relationName) . "." . $query->toDb($key) . "
|
||||
";
|
||||
$part[$pathName . '.ascendorId'] = $val;
|
||||
}
|
||||
} else if ($defs['type'] == 'belongsTo') {
|
||||
if (!empty($defs['key'])) {
|
||||
$key = $defs['key'];
|
||||
$result['customJoin'] .= "
|
||||
JOIN " . $query->toDb($pathName) . " AS `{$pathName}` ON {$pathName}.descendor_id = {$tableName}." . $query->toDb($key) . "
|
||||
";
|
||||
$part[$pathName . '.ascendorId'] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!empty($part)) {
|
||||
$result['whereClause'][] = $part;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function q($params, &$result)
|
||||
{
|
||||
if (!empty($params['q'])) {
|
||||
@@ -239,10 +316,10 @@ class Base
|
||||
|
||||
protected function access(&$result)
|
||||
{
|
||||
if ($this->acl->checkReadOnlyOwn($this->entityName)) {
|
||||
if ($this->acl->checkReadOnlyOwn($this->entityType)) {
|
||||
$this->accessOnlyOwn($result);
|
||||
}
|
||||
if (!$this->user->isAdmin() && $this->acl->checkReadOnlyTeam($this->entityName)) {
|
||||
if (!$this->user->isAdmin() && $this->acl->checkReadOnlyTeam($this->entityType)) {
|
||||
$this->accessOnlyTeam($result);
|
||||
}
|
||||
}
|
||||
@@ -268,7 +345,7 @@ class Base
|
||||
}
|
||||
$result['whereClause'][] = array(
|
||||
'OR' => array(
|
||||
'Team.id' => $this->user->get('teamsIds'),
|
||||
'teams.id' => $this->user->get('teamsIds'),
|
||||
'assignedUserId' => $this->getUser()->id
|
||||
)
|
||||
);
|
||||
@@ -284,9 +361,10 @@ class Base
|
||||
public function getSelectParams(array $params, $withAcl = false)
|
||||
{
|
||||
$result = array(
|
||||
'joins' => array(),
|
||||
'leftJoins' => array(),
|
||||
'whereClause' => array()
|
||||
'joins' => [],
|
||||
'leftJoins' => [],
|
||||
'whereClause' => [],
|
||||
'customJoin' => ''
|
||||
);
|
||||
|
||||
$this->order($params, $result);
|
||||
@@ -301,6 +379,17 @@ class Base
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function getUserTimeZone()
|
||||
{
|
||||
if (empty($this->userTimeZone)) {
|
||||
$preferences = $this->getEntityManager()->getEntity('Preferences', $this->getUser()->id);
|
||||
$timeZone = $preferences->get('timeZone');
|
||||
$this->userTimeZone = $timeZone;
|
||||
}
|
||||
|
||||
return $this->userTimeZone;
|
||||
}
|
||||
|
||||
protected function convertDateTimeWhere($item)
|
||||
{
|
||||
$format = 'Y-m-d H:i:s';
|
||||
@@ -429,6 +518,12 @@ class Base
|
||||
case 'on':
|
||||
$part[$item['field'] . '='] = $item['value'];
|
||||
break;
|
||||
case 'startsWith':
|
||||
$part[$item['field'] . '*'] = $item['value'] . '%';
|
||||
break;
|
||||
case 'contains':
|
||||
$part[$item['field'] . '*'] = '%' . $item['value'] . '%';
|
||||
break;
|
||||
case 'notEquals':
|
||||
case 'notOn':
|
||||
$part[$item['field'] . '!='] = $item['value'];
|
||||
@@ -453,6 +548,12 @@ class Base
|
||||
case 'notIn':
|
||||
$part[$item['field'] . '!='] = $item['value'];
|
||||
break;
|
||||
case 'isNull':
|
||||
$part[$item['field'] . '='] = null;
|
||||
break;
|
||||
case 'isNotNull':
|
||||
$part[$item['field'] . '!='] = null;
|
||||
break;
|
||||
case 'isTrue':
|
||||
$part[$item['field'] . '='] = true;
|
||||
break;
|
||||
@@ -541,6 +642,14 @@ class Base
|
||||
}
|
||||
}
|
||||
|
||||
protected function primaryFilter($filterName, &$result)
|
||||
{
|
||||
$method = 'filter' . ucfirst($filterName);
|
||||
if (method_exists($this, $method)) {
|
||||
$this->$method($result);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getBoolFilterWhere($filterName)
|
||||
{
|
||||
$method = 'getBoolFilterWhere' . ucfirst($filterName);
|
||||
@@ -555,5 +664,21 @@ class Base
|
||||
'assignedUserId' => $this->getUser()->id
|
||||
);
|
||||
}
|
||||
|
||||
protected function filterFollowed(&$result)
|
||||
{
|
||||
$query = $this->getEntityManager()->getQuery();
|
||||
$result['customJoin'] .= "
|
||||
JOIN subscription ON
|
||||
subscription.entity_type = ".$query->quote($this->getEntityType())." AND
|
||||
subscription.entity_id = ".$query->toDb($this->getEntityType()).".id AND
|
||||
subscription.user_id = ".$query->quote($this->getUser()->id)."
|
||||
";
|
||||
}
|
||||
|
||||
protected function boolFilterFollowed(&$result)
|
||||
{
|
||||
$this->filterFollowed($result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,11 @@ abstract class Base implements Injectable
|
||||
return $this->injections[$name];
|
||||
}
|
||||
|
||||
protected function addDependency($name)
|
||||
{
|
||||
$this->dependencies[] = $name;
|
||||
}
|
||||
|
||||
public function getDependencyList()
|
||||
{
|
||||
return $this->dependencies;
|
||||
|
||||
30
application/Espo/Core/Templates/Controllers/CategoryTree.php
Normal file
30
application/Espo/Core/Templates/Controllers/CategoryTree.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Templates\Controllers;
|
||||
|
||||
|
||||
class CategoryTree extends \Espo\Core\Controllers\RecordTree
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
29
application/Espo/Core/Templates/Entities/CategoryTree.php
Normal file
29
application/Espo/Core/Templates/Entities/CategoryTree.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Templates\Entities;
|
||||
|
||||
class CategoryTree extends \Espo\Core\Entities\CategoryTreeItem
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
[
|
||||
{
|
||||
"label": "Overview",
|
||||
"rows": [
|
||||
[
|
||||
{
|
||||
"name": "name"
|
||||
},
|
||||
{
|
||||
"name": "order"
|
||||
}
|
||||
],
|
||||
[
|
||||
false,
|
||||
{
|
||||
"name": "parent"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,22 @@
|
||||
[
|
||||
{
|
||||
"label": "",
|
||||
"rows": [
|
||||
[
|
||||
{
|
||||
"name": "name"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"name": "order"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"name": "parent"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,3 @@
|
||||
[
|
||||
"parent"
|
||||
]
|
||||
@@ -0,0 +1,14 @@
|
||||
[
|
||||
{
|
||||
"name": "name",
|
||||
"width": 40,
|
||||
"link": true
|
||||
},
|
||||
{
|
||||
"name": "order",
|
||||
"width": 15
|
||||
},
|
||||
{
|
||||
"name": "parent"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,14 @@
|
||||
[
|
||||
{
|
||||
"name": "name",
|
||||
"width": 40,
|
||||
"link": true
|
||||
},
|
||||
{
|
||||
"name": "order",
|
||||
"width": 15
|
||||
},
|
||||
{
|
||||
"name": "parent"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,3 @@
|
||||
[
|
||||
|
||||
]
|
||||
@@ -0,0 +1,3 @@
|
||||
[
|
||||
"children"
|
||||
]
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"controller": "Controllers.Record",
|
||||
"boolFilters": ["onlyMy"]
|
||||
"boolFilterList": ["onlyMy"]
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@
|
||||
"teams": {
|
||||
"type": "hasMany",
|
||||
"entity": "Team",
|
||||
"relationName": "EntityTeam"
|
||||
"relationName": "EntityTeam",
|
||||
"layoutRelationshipsDisabled": true
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"controller": "Controllers.RecordTree",
|
||||
"collection": "Collections.Tree",
|
||||
"menu": {
|
||||
"listTree": {
|
||||
"buttons": [
|
||||
{
|
||||
"label": "List View",
|
||||
"link": "#{entityType}/list",
|
||||
"acl": "read",
|
||||
"style": "default"
|
||||
}
|
||||
]
|
||||
},
|
||||
"list": {
|
||||
"buttons": [
|
||||
{
|
||||
"label": "Tree View",
|
||||
"link": "#{entityType}",
|
||||
"acl": "read",
|
||||
"style": "default"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
{
|
||||
"fields": {
|
||||
"name": {
|
||||
"type": "varchar",
|
||||
"required": true
|
||||
},
|
||||
"order": {
|
||||
"type": "int",
|
||||
"required": true,
|
||||
"default": 1
|
||||
},
|
||||
"description": {
|
||||
"type": "text"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "datetime",
|
||||
"readOnly": true
|
||||
},
|
||||
"modifiedAt": {
|
||||
"type": "datetime",
|
||||
"readOnly": true
|
||||
},
|
||||
"createdBy": {
|
||||
"type": "link",
|
||||
"readOnly": true
|
||||
},
|
||||
"modifiedBy": {
|
||||
"type": "link",
|
||||
"readOnly": true
|
||||
},
|
||||
"teams": {
|
||||
"type": "linkMultiple"
|
||||
},
|
||||
"parent": {
|
||||
"type": "link"
|
||||
},
|
||||
"childList": {
|
||||
"type": "jsonArray",
|
||||
"notStorable": true,
|
||||
"disabled": true
|
||||
}
|
||||
},
|
||||
"links": {
|
||||
"createdBy": {
|
||||
"type": "belongsTo",
|
||||
"entity": "User"
|
||||
},
|
||||
"modifiedBy": {
|
||||
"type": "belongsTo",
|
||||
"entity": "User"
|
||||
},
|
||||
"teams": {
|
||||
"type": "hasMany",
|
||||
"entity": "Team",
|
||||
"relationName": "EntityTeam",
|
||||
"layoutRelationshipsDisabled": true
|
||||
},
|
||||
"parent": {
|
||||
"type": "belongsTo",
|
||||
"foreign": "children",
|
||||
"entity": "{entityType}",
|
||||
"isCustom": true
|
||||
},
|
||||
"children": {
|
||||
"type": "hasMany",
|
||||
"foreign": "parent",
|
||||
"entity": "{entityType}",
|
||||
"isCustom": true
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "parent",
|
||||
"asc": true
|
||||
},
|
||||
"indexes": {
|
||||
"name": {
|
||||
"columns": [
|
||||
"name",
|
||||
"deleted"
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalTables": {
|
||||
"{entityType}Path": {
|
||||
"fields": {
|
||||
"id": {
|
||||
"type": "id",
|
||||
"dbType": "int",
|
||||
"len": "11",
|
||||
"autoincrement": true,
|
||||
"unique" : true
|
||||
},
|
||||
"ascendorId": {
|
||||
"type": "varchar",
|
||||
"len": "100",
|
||||
"index": true
|
||||
},
|
||||
"descendorId": {
|
||||
"type": "varchar",
|
||||
"len": "24",
|
||||
"index": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"controller": "Controllers.Record",
|
||||
"boolFilters": ["onlyMy"]
|
||||
"boolFilterList": ["onlyMy"]
|
||||
}
|
||||
|
||||
@@ -89,7 +89,8 @@
|
||||
"teams": {
|
||||
"type": "hasMany",
|
||||
"entity": "Team",
|
||||
"relationName": "EntityTeam"
|
||||
"relationName": "EntityTeam",
|
||||
"layoutRelationshipsDisabled": true
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Templates\Repositories;
|
||||
|
||||
|
||||
class CategoryTree extends \Espo\Core\Repositories\CategoryTree
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
30
application/Espo/Core/Templates/Services/CategoryTree.php
Normal file
30
application/Espo/Core/Templates/Services/CategoryTree.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Templates\Services;
|
||||
|
||||
|
||||
class CategoryTree extends \Espo\Services\RecordTree
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -551,7 +551,7 @@ abstract class Base
|
||||
$result = $this->getFileManager()->isWritableList($fullFileList);
|
||||
if (!$result) {
|
||||
$permissionDeniedList = $this->getFileManager()->getLastPermissionDeniedList();
|
||||
throw new Error("Permission denied in <br>". implode(", <br>", $permissionDeniedList));
|
||||
throw new Error("Permission denied for <br>". implode(", <br>", $permissionDeniedList));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,13 +27,6 @@ use Espo\Core\Utils\Util;
|
||||
|
||||
class Install extends \Espo\Core\Upgrades\Actions\Base
|
||||
{
|
||||
/**
|
||||
* Is copied extension files to Espo
|
||||
*
|
||||
* @var [type]
|
||||
*/
|
||||
protected $isCopied = null;
|
||||
|
||||
/**
|
||||
* Main installation process
|
||||
*
|
||||
@@ -54,8 +47,6 @@ class Install extends \Espo\Core\Upgrades\Actions\Base
|
||||
|
||||
$this->initialize();
|
||||
|
||||
$this->isCopied = false;
|
||||
|
||||
/** check if an archive is unzipped, if no then unzip */
|
||||
$packagePath = $this->getPackagePath();
|
||||
if (!file_exists($packagePath)) {
|
||||
@@ -77,7 +68,6 @@ class Install extends \Espo\Core\Upgrades\Actions\Base
|
||||
if (!$this->copyFiles()) {
|
||||
$this->throwErrorAndRemovePackage('Cannot copy files.');
|
||||
}
|
||||
$this->isCopied = true;
|
||||
|
||||
/* remove files defined in a manifest */
|
||||
$this->deleteFiles(true);
|
||||
@@ -103,10 +93,6 @@ class Install extends \Espo\Core\Upgrades\Actions\Base
|
||||
|
||||
protected function restoreFiles()
|
||||
{
|
||||
if (!$this->isCopied) {
|
||||
return;
|
||||
}
|
||||
|
||||
$GLOBALS['log']->info('Installer: Restore previous files.');
|
||||
|
||||
$backupPath = $this->getPath('backupPath');
|
||||
|
||||
@@ -160,7 +160,7 @@ class Install extends \Espo\Core\Upgrades\Actions\Base\Install
|
||||
$extensionEntity = $this->getExtensionEntity();
|
||||
|
||||
if (isset($extensionEntity)) {
|
||||
$comparedVersion = version_compare($manifest['version'], $extensionEntity->get('version'));
|
||||
$comparedVersion = version_compare($manifest['version'], $extensionEntity->get('version'), '>=');
|
||||
if ($comparedVersion <= 0) {
|
||||
$this->throwErrorAndRemovePackage('You cannot install an older version of this extension.');
|
||||
}
|
||||
|
||||
@@ -67,7 +67,9 @@ class Output
|
||||
$currentRoute = $this->getSlim()->router()->getCurrentRoute();
|
||||
|
||||
if (isset($currentRoute)) {
|
||||
$GLOBALS['log']->error('API ['.$this->getSlim()->request()->getMethod().']:'.$currentRoute->getPattern().', Params:'.print_r($currentRoute->getParams(), true).', InputData: '.$this->getSlim()->request()->getBody().' - '.$message);
|
||||
$inputData = $this->getSlim()->request()->getBody();
|
||||
$inputData = $this->clearPasswords($inputData);
|
||||
$GLOBALS['log']->error('API ['.$this->getSlim()->request()->getMethod().']:'.$currentRoute->getPattern().', Params:'.print_r($currentRoute->getParams(), true).', InputData: '.$inputData.' - '.$message);
|
||||
}
|
||||
|
||||
$this->displayError($message, $code, $isPrint);
|
||||
@@ -118,5 +120,17 @@ class Output
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear passwords for inputData
|
||||
*
|
||||
* @param string $inputData
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function clearPasswords($inputData)
|
||||
{
|
||||
return preg_replace('/"(.*?password.*?)":".*?"/i', '"$1":"*****"', $inputData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,8 @@ class Auth
|
||||
$authenticationMethod = $this->config->get('authenticationMethod', 'Espo');
|
||||
$authenticationClassName = "\\Espo\\Core\\Utils\\Authentication\\" . $authenticationMethod;
|
||||
$this->authentication = new $authenticationClassName($this->config, $this->entityManager, $this);
|
||||
|
||||
$this->request = $this->container->get('slim')->request();
|
||||
}
|
||||
|
||||
public function useNoAuth($isAdmin = false)
|
||||
@@ -78,20 +80,21 @@ class Auth
|
||||
$entityManager->setUser($user);
|
||||
$this->container->setUser($user);
|
||||
|
||||
if (!$authToken) {
|
||||
$authToken = $entityManager->getEntity('AuthToken');
|
||||
$token = $this->createToken($user);
|
||||
$authToken->set('token', $token);
|
||||
$authToken->set('hash', $user->get('password'));
|
||||
$authToken->set('ipAddress', $_SERVER['REMOTE_ADDR']);
|
||||
$authToken->set('userId', $user->id);
|
||||
if ($this->request->headers->get('HTTP_ESPO_AUTHORIZATION')) {
|
||||
if (!$authToken) {
|
||||
$authToken = $entityManager->getEntity('AuthToken');
|
||||
$token = $this->createToken($user);
|
||||
$authToken->set('token', $token);
|
||||
$authToken->set('hash', $user->get('password'));
|
||||
$authToken->set('ipAddress', $_SERVER['REMOTE_ADDR']);
|
||||
$authToken->set('userId', $user->id);
|
||||
}
|
||||
$authToken->set('lastAccess', date('Y-m-d H:i:s'));
|
||||
|
||||
$entityManager->saveEntity($authToken);
|
||||
$user->set('token', $authToken->get('token'));
|
||||
}
|
||||
|
||||
$authToken->set('lastAccess', date('Y-m-d H:i:s'));
|
||||
|
||||
$entityManager->saveEntity($authToken);
|
||||
$user->set('token', $authToken->get('token'));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,10 +33,14 @@ class Job
|
||||
|
||||
private $entityManager;
|
||||
|
||||
private $cronScheduledJob;
|
||||
|
||||
public function __construct(Config $config, EntityManager $entityManager)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->entityManager = $entityManager;
|
||||
|
||||
$this->cronScheduledJob = new ScheduledJob($this->config, $this->entityManager);
|
||||
}
|
||||
|
||||
protected function getConfig()
|
||||
@@ -49,6 +53,11 @@ class Job
|
||||
return $this->entityManager;
|
||||
}
|
||||
|
||||
protected function getCronScheduledJob()
|
||||
{
|
||||
return $this->cronScheduledJob;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Pending Jobs
|
||||
*
|
||||
@@ -145,13 +154,30 @@ class Job
|
||||
$currentTime = time();
|
||||
$periodTime = $currentTime - intval($jobConfigs['jobPeriod']);
|
||||
|
||||
$update = "UPDATE job SET `status` = '" . CronManager::FAILED ."' WHERE
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
|
||||
$select = "SELECT id, scheduled_job_id, execute_time FROM `job` WHERE
|
||||
(`status` = '" . CronManager::RUNNING ."')
|
||||
AND execute_time < '".date('Y-m-d H:i:s', $periodTime)."' ";
|
||||
$sth = $pdo->prepare($select);
|
||||
$sth->execute();
|
||||
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
$jobData = array();
|
||||
while ($row = $sth->fetch(PDO::FETCH_ASSOC)){
|
||||
$jobData[$row['id']] = $row;
|
||||
}
|
||||
|
||||
$update = "UPDATE job SET `status` = '". CronManager::FAILED ."' WHERE id IN ('".implode("', '", array_keys($jobData))."')";
|
||||
$sth = $pdo->prepare($update);
|
||||
$sth->execute();
|
||||
|
||||
//add status 'Failed' to SchediledJobLog
|
||||
$cronScheduledJob = $this->getCronScheduledJob();
|
||||
foreach ($jobData as $jobId => $job) {
|
||||
if (!empty($job['scheduled_job_id'])) {
|
||||
$cronScheduledJob->addLogRecord($job['scheduled_job_id'], CronManager::FAILED, $job['execute_time']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -81,14 +81,16 @@ class ScheduledJob
|
||||
*
|
||||
* @return string ID of created ScheduledJobLogRecord
|
||||
*/
|
||||
public function addLogRecord($scheduledJobId, $status)
|
||||
public function addLogRecord($scheduledJobId, $status, $runTime = null)
|
||||
{
|
||||
$lastRun = date('Y-m-d H:i:s');
|
||||
if (!isset($runTime)) {
|
||||
$runTime = date('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
$entityManager = $this->getEntityManager();
|
||||
|
||||
$scheduledJob = $entityManager->getEntity('ScheduledJob', $scheduledJobId);
|
||||
$scheduledJob->set('lastRun', $lastRun);
|
||||
$scheduledJob->set('lastRun', $runTime);
|
||||
$entityManager->saveEntity($scheduledJob);
|
||||
|
||||
$scheduledJobLog = $entityManager->getEntity('ScheduledJobLogRecord');
|
||||
@@ -96,7 +98,7 @@ class ScheduledJob
|
||||
'scheduledJobId' => $scheduledJobId,
|
||||
'name' => $scheduledJob->get('name'),
|
||||
'status' => $status,
|
||||
'executionTime' => $lastRun,
|
||||
'executionTime' => $runTime,
|
||||
));
|
||||
$scheduledJobLogId = $entityManager->saveEntity($scheduledJobLog);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class Converter
|
||||
{
|
||||
private $metadata;
|
||||
private $fileManager;
|
||||
private $metadataUtils;
|
||||
private $metadataHelper;
|
||||
|
||||
private $relationManager;
|
||||
|
||||
@@ -82,6 +82,15 @@ class Converter
|
||||
'len' => '24',
|
||||
);
|
||||
|
||||
/**
|
||||
* Permitted Entity options which will be moved to ormMetadata
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $permittedEntityOptions = array(
|
||||
'indexes',
|
||||
'additionalTables',
|
||||
);
|
||||
|
||||
public function __construct(\Espo\Core\Utils\Metadata $metadata, \Espo\Core\Utils\File\Manager $fileManager)
|
||||
{
|
||||
@@ -90,10 +99,9 @@ class Converter
|
||||
|
||||
$this->relationManager = new RelationManager($this->metadata);
|
||||
|
||||
$this->metadataUtils = new \Espo\Core\Utils\Metadata\Utils($this->metadata);
|
||||
$this->metadataHelper = new \Espo\Core\Utils\Metadata\Helper($this->metadata);
|
||||
}
|
||||
|
||||
|
||||
protected function getMetadata()
|
||||
{
|
||||
return $this->metadata;
|
||||
@@ -118,9 +126,9 @@ class Converter
|
||||
return $this->relationManager;
|
||||
}
|
||||
|
||||
protected function getMetadataUtils()
|
||||
protected function getMetadataHelper()
|
||||
{
|
||||
return $this->metadataUtils;
|
||||
return $this->metadataHelper;
|
||||
}
|
||||
|
||||
public function process()
|
||||
@@ -153,11 +161,14 @@ class Converter
|
||||
),
|
||||
);
|
||||
|
||||
if (isset($entityMeta['indexes'])) {
|
||||
$ormMeta[$entityName]['indexes'] = $entityMeta['indexes'];
|
||||
foreach ($this->permittedEntityOptions as $optionName) {
|
||||
if (isset($entityMeta[$optionName])) {
|
||||
$ormMeta[$entityName][$optionName] = $entityMeta[$optionName];
|
||||
}
|
||||
}
|
||||
|
||||
$ormMeta[$entityName]['fields'] = $this->convertFields($entityName, $entityMeta);
|
||||
$ormMeta = $this->correctFields($entityName, $ormMeta);
|
||||
|
||||
$convertedLinks = $this->convertLinks($entityName, $entityMeta, $ormMeta);
|
||||
|
||||
@@ -168,47 +179,6 @@ class Converter
|
||||
|
||||
public function afterProcess(array $ormMeta)
|
||||
{
|
||||
$entityDefs = $this->getEntityDefs();
|
||||
|
||||
$currentOrmMeta = $ormMeta;
|
||||
//load custom field definitions and customCodes
|
||||
foreach($currentOrmMeta as $entityName => $entityParams) {
|
||||
foreach($entityParams['fields'] as $fieldName => $fieldParams) {
|
||||
|
||||
//load custom field definitions
|
||||
$fieldType = ucfirst($fieldParams['type']);
|
||||
$className = '\Espo\Custom\Core\Utils\Database\Orm\Fields\\'.$fieldType;
|
||||
if (!class_exists($className)) {
|
||||
$className = '\Espo\Core\Utils\Database\Orm\Fields\\'.$fieldType;
|
||||
}
|
||||
|
||||
if (class_exists($className) && method_exists($className, 'load')) {
|
||||
$helperClass = new $className($this->metadata, $ormMeta, $entityDefs);
|
||||
$fieldResult = $helperClass->process( $fieldName, $entityName );
|
||||
if (isset($fieldResult['unset'])) {
|
||||
$ormMeta = Util::unsetInArray($ormMeta, $fieldResult['unset']);
|
||||
unset($fieldResult['unset']);
|
||||
}
|
||||
|
||||
$ormMeta = Util::merge($ormMeta, $fieldResult);
|
||||
|
||||
} //END: load custom field definitions
|
||||
|
||||
//todo move to separate file
|
||||
//add a field 'isFollowed' for scopes with 'stream => true'
|
||||
$scopeDefs = $this->getMetadata()->get('scopes.'.$entityName);
|
||||
if (isset($scopeDefs['stream']) && $scopeDefs['stream']) {
|
||||
if (!isset($entityParams['fields']['isFollowed'])) {
|
||||
$ormMeta[$entityName]['fields']['isFollowed'] = array(
|
||||
'type' => 'varchar',
|
||||
'notStorable' => true,
|
||||
);
|
||||
}
|
||||
} //END: add a field 'isFollowed' for stream => true
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
foreach($ormMeta as $entityName => &$entityParams) {
|
||||
foreach($entityParams['fields'] as $fieldName => &$fieldParams) {
|
||||
|
||||
@@ -226,7 +196,9 @@ class Converter
|
||||
|
||||
case 'foreignType':
|
||||
$fieldParams['dbType'] = Entity::VARCHAR;
|
||||
$fieldParams['len'] = $this->defaultLength['varchar'];
|
||||
if (empty($fieldParams['len'])) {
|
||||
$fieldParams['len'] = $this->defaultLength['varchar'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'bool':
|
||||
@@ -234,7 +206,6 @@ class Converter
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $ormMeta;
|
||||
@@ -264,31 +235,16 @@ class Converter
|
||||
foreach($entityMeta['fields'] as $fieldName => $fieldParams) {
|
||||
|
||||
/** check if "fields" option exists in $fieldMeta */
|
||||
$fieldTypeMeta = $this->getMetadataUtils()->getFieldDefsByType($fieldParams);
|
||||
$fieldTypeMeta = $this->getMetadataHelper()->getFieldDefsByType($fieldParams);
|
||||
|
||||
if (isset($fieldTypeMeta['fields']) && is_array($fieldTypeMeta['fields'])) {
|
||||
|
||||
foreach($fieldTypeMeta['actualFields'] as $subFieldName) {
|
||||
|
||||
$subField = $this->convertActualFields($entityName, $fieldName, $fieldParams, $subFieldName, $fieldTypeMeta);
|
||||
|
||||
if (!isset($outputMeta[ $subField['naming'] ])) {
|
||||
$subFieldDefs = $this->convertField($entityName, $subField['name'], $subField['params']);
|
||||
if ($subFieldDefs !== false) {
|
||||
$outputMeta[ $subField['naming'] ] = $subFieldDefs; //push fieldDefs to the main array
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$fieldDefs = $this->convertField($entityName, $fieldName, $fieldParams, $fieldTypeMeta);
|
||||
if ($fieldDefs !== false) {
|
||||
$outputMeta[$fieldName] = $fieldDefs; //push fieldDefs to the main array
|
||||
}
|
||||
$fieldDefs = $this->convertField($entityName, $fieldName, $fieldParams, $fieldTypeMeta);
|
||||
if ($fieldDefs !== false) {
|
||||
$outputMeta[$fieldName] = $fieldDefs; //push fieldDefs to the main array
|
||||
}
|
||||
|
||||
/** check and set the linkDefs from 'fields' metadata */
|
||||
if (isset($fieldTypeMeta['linkDefs'])) {
|
||||
$linkDefs = $this->getMetadataUtils()->getLinkDefsInFieldMeta($entityName, $fieldParams, $fieldTypeMeta['linkDefs']);
|
||||
$linkDefs = $this->getMetadataHelper()->getLinkDefsInFieldMeta($entityName, $fieldParams, $fieldTypeMeta['linkDefs']);
|
||||
if (isset($linkDefs)) {
|
||||
if (!isset($entityMeta['links'])) {
|
||||
$entityMeta['links'] = array();
|
||||
@@ -308,6 +264,56 @@ class Converter
|
||||
return $outputMeta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct fields defenitions based on \Espo\Custom\Core\Utils\Database\Orm\Fields
|
||||
*
|
||||
* @param array $ormMeta
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function correctFields($entityName, array $ormMeta)
|
||||
{
|
||||
$entityDefs = $this->getEntityDefs();
|
||||
|
||||
$entityMeta = $ormMeta[$entityName];
|
||||
//load custom field definitions and customCodes
|
||||
foreach($entityMeta['fields'] as $fieldName => $fieldParams) {
|
||||
|
||||
//load custom field definitions
|
||||
$fieldType = ucfirst($fieldParams['type']);
|
||||
$className = '\Espo\Custom\Core\Utils\Database\Orm\Fields\\' . $fieldType;
|
||||
if (!class_exists($className)) {
|
||||
$className = '\Espo\Core\Utils\Database\Orm\Fields\\' . $fieldType;
|
||||
}
|
||||
|
||||
if (class_exists($className) && method_exists($className, 'load')) {
|
||||
$helperClass = new $className($this->metadata, $ormMeta, $entityDefs);
|
||||
$fieldResult = $helperClass->process( $fieldName, $entityName );
|
||||
if (isset($fieldResult['unset'])) {
|
||||
$ormMeta = Util::unsetInArray($ormMeta, $fieldResult['unset']);
|
||||
unset($fieldResult['unset']);
|
||||
}
|
||||
|
||||
$ormMeta = Util::merge($ormMeta, $fieldResult);
|
||||
|
||||
} //END: load custom field definitions
|
||||
}
|
||||
|
||||
//todo move to separate file
|
||||
//add a field 'isFollowed' for scopes with 'stream => true'
|
||||
$scopeDefs = $this->getMetadata()->get('scopes.'.$entityName);
|
||||
if (isset($scopeDefs['stream']) && $scopeDefs['stream']) {
|
||||
if (!isset($entityMeta['fields']['isFollowed'])) {
|
||||
$ormMeta[$entityName]['fields']['isFollowed'] = array(
|
||||
'type' => 'varchar',
|
||||
'notStorable' => true,
|
||||
);
|
||||
}
|
||||
} //END: add a field 'isFollowed' for stream => true
|
||||
|
||||
return $ormMeta;
|
||||
}
|
||||
|
||||
protected function convertField($entityName, $fieldName, array $fieldParams, $fieldTypeMeta = null)
|
||||
{
|
||||
/** set default type if exists */
|
||||
@@ -318,15 +324,15 @@ class Converter
|
||||
|
||||
/** merge fieldDefs option from field definition */
|
||||
if (!isset($fieldTypeMeta)) {
|
||||
$fieldTypeMeta = $this->getMetadataUtils()->getFieldDefsByType($fieldParams);
|
||||
$fieldTypeMeta = $this->getMetadataHelper()->getFieldDefsByType($fieldParams);
|
||||
}
|
||||
|
||||
if (isset($fieldTypeMeta['fieldDefs'])) {
|
||||
$fieldParams = Util::merge($fieldParams, $fieldTypeMeta['fieldDefs']);
|
||||
}
|
||||
|
||||
/** check if need to skip this field in ORM metadata */
|
||||
if (isset($fieldParams['skip']) && $fieldParams['skip'] === true) {
|
||||
/** check if need to skipOrmDefs this field in ORM metadata */
|
||||
if (isset($fieldParams['skipOrmDefs']) && $fieldParams['skipOrmDefs'] === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -350,37 +356,6 @@ class Converter
|
||||
return $fieldDefs;
|
||||
}
|
||||
|
||||
protected function convertActualFields($entityName, $fieldName, $fieldParams, $subFieldName, $fieldTypeMeta)
|
||||
{
|
||||
$subField = array();
|
||||
|
||||
$subField['params'] = $this->getInitValues($fieldParams);
|
||||
|
||||
if (isset($fieldTypeMeta['fieldDefs'])) {
|
||||
$subField['params'] = Util::merge($subField['params'], $fieldTypeMeta['fieldDefs']);
|
||||
}
|
||||
|
||||
//if empty field name, then use the main field
|
||||
if (trim($subFieldName) == '') {
|
||||
|
||||
$subField['name'] = $fieldName;
|
||||
$subField['naming'] = $fieldName;
|
||||
|
||||
} else {
|
||||
|
||||
$namingType = isset($fieldTypeMeta['naming']) ? $fieldTypeMeta['naming'] : $this->defaultNaming;
|
||||
|
||||
$subField['name'] = $subFieldName;
|
||||
$subField['naming'] = Util::getNaming($fieldName, $subFieldName, $namingType);
|
||||
if (isset($fieldTypeMeta['fields'][$subFieldName])) {
|
||||
$subField['params'] = Util::merge($subField['params'], $fieldTypeMeta['fields'][$subFieldName]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $subField;
|
||||
}
|
||||
|
||||
protected function convertLinks($entityName, $entityMeta, $ormMeta)
|
||||
{
|
||||
if (!isset($entityMeta['links'])) {
|
||||
|
||||
@@ -30,7 +30,7 @@ class Email extends Base
|
||||
$entityName => array(
|
||||
'fields' => array(
|
||||
$fieldName => array(
|
||||
'select' => 'email_address.name',
|
||||
'select' => 'emailAddresses.name',
|
||||
'where' =>
|
||||
array (
|
||||
'LIKE' => \Espo\Core\Utils\Util::toUnderScore($entityName) . ".id IN (
|
||||
@@ -58,7 +58,7 @@ class Email extends Base
|
||||
email_address.deleted = 0 AND email_address.name <> {value}
|
||||
)"
|
||||
),
|
||||
'orderBy' => 'email_address.name {direction}',
|
||||
'orderBy' => 'emailAddresses.name {direction}',
|
||||
),
|
||||
$fieldName .'Data' => array(
|
||||
'type' => 'text',
|
||||
|
||||
57
application/Espo/Core/Utils/Database/Orm/Fields/Link.php
Normal file
57
application/Espo/Core/Utils/Database/Orm/Fields/Link.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Utils\Database\Orm\Fields;
|
||||
|
||||
class Link extends Base
|
||||
{
|
||||
protected function load($fieldName, $entityName)
|
||||
{
|
||||
$fieldParams = $this->getFieldParams();
|
||||
|
||||
$data = array(
|
||||
$entityName => array (
|
||||
'fields' => array(
|
||||
$fieldName.'Id' => array(
|
||||
'type' => 'foreignId',
|
||||
'index' => $fieldName,
|
||||
),
|
||||
$fieldName.'Name' => array(
|
||||
'type' => 'varchar',
|
||||
'notStorable' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
'unset' => array(
|
||||
$entityName => array(
|
||||
'fields.'.$fieldName,
|
||||
),
|
||||
),
|
||||
);
|
||||
if (!empty($fieldParams['notStorable'])) {
|
||||
$data[$entityName]['fields'][$fieldName.'Id']['notStorable'] = true;
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,11 @@ class LinkParent extends Base
|
||||
),
|
||||
),
|
||||
),
|
||||
'unset' => array(
|
||||
$entityName => array(
|
||||
'fields.'.$fieldName,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ class Phone extends Base
|
||||
$entityName => array(
|
||||
'fields' => array(
|
||||
$fieldName => array(
|
||||
'select' => 'phone_number.name',
|
||||
'select' => 'phoneNumbers.name',
|
||||
'where' =>
|
||||
array (
|
||||
'LIKE' => \Espo\Core\Utils\Util::toUnderScore($entityName) . ".id IN (
|
||||
@@ -58,7 +58,7 @@ class Phone extends Base
|
||||
phone_number.deleted = 0 AND phone_number.name <> {value}
|
||||
)"
|
||||
),
|
||||
'orderBy' => 'phone_number.name {direction}',
|
||||
'orderBy' => 'phoneNumbers.name {direction}',
|
||||
),
|
||||
$fieldName .'Data' => array(
|
||||
'type' => 'text',
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
namespace Espo\Core\Utils\Database\Orm\Relations;
|
||||
|
||||
use Espo\Core\Utils\Util;
|
||||
|
||||
class Base extends \Espo\Core\Utils\Database\Orm\Base
|
||||
{
|
||||
private $params;
|
||||
@@ -119,8 +121,11 @@ class Base extends \Espo\Core\Utils\Database\Orm\Base
|
||||
|
||||
$additionalParrams = $this->getAllowedAdditionalParams($name);
|
||||
|
||||
if (isset($additionalParrams) && !isset($linkParams[$name])) {
|
||||
if (isset($additionalParrams)) {
|
||||
$linkParams[$name] = $additionalParrams;
|
||||
if (isset($linkParams[$name]) && is_array($linkParams[$name])) {
|
||||
$linkParams[$name] = Util::merge($linkParams[$name], $additionalParrams);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ class BelongsTo extends Base
|
||||
'type' => 'foreign',
|
||||
'relation' => $linkName,
|
||||
'foreign' => $this->getForeignField('name', $foreignEntityName),
|
||||
'notStorable' => false,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Utils\Database\Orm\Relations;
|
||||
|
||||
class BelongsToParent extends Base
|
||||
{
|
||||
protected function load($linkName, $entityName)
|
||||
{
|
||||
$linkParams = $this->getLinkParams();
|
||||
|
||||
return array(
|
||||
$entityName => array (
|
||||
'fields' => array(
|
||||
$linkName.'Id' => array(
|
||||
'type' => 'foreignId',
|
||||
'index' => $linkName,
|
||||
),
|
||||
$linkName.'Type' => array(
|
||||
'type' => 'foreignType',
|
||||
'notNull' => false,
|
||||
'index' => $linkName,
|
||||
'len' => 100
|
||||
),
|
||||
$linkName.'Name' => array(
|
||||
'type' => 'varchar',
|
||||
'notStorable' => true,
|
||||
),
|
||||
),
|
||||
'relations' => array(
|
||||
$linkName => array(
|
||||
'type' => 'belongsToParent',
|
||||
'key' => $linkName.'Id',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -89,7 +89,7 @@ class Converter
|
||||
$GLOBALS['log']->debug('Schema\Converter - Start: building schema');
|
||||
|
||||
//check if exist files in "Tables" directory and merge with ormMetadata
|
||||
$ormMeta = Util::merge($ormMeta, $this->getCustomTables());
|
||||
$ormMeta = Util::merge($ormMeta, $this->getCustomTables($ormMeta));
|
||||
|
||||
//unset some keys in orm
|
||||
if (isset($ormMeta['unset'])) {
|
||||
@@ -335,11 +335,14 @@ class Converter
|
||||
return $keyList;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @return array - ormMeta
|
||||
/**
|
||||
* Get custom table defenition in "application/Espo/Core/Utils/Database/Schema/tables/" and in metadata 'additionalTables'
|
||||
*
|
||||
* @param array $ormMeta
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getCustomTables()
|
||||
protected function getCustomTables(array $ormMeta)
|
||||
{
|
||||
$customTables = array();
|
||||
|
||||
@@ -352,6 +355,13 @@ class Converter
|
||||
}
|
||||
}
|
||||
|
||||
//get custom tables from metdata 'additionalTables'
|
||||
foreach ($ormMeta as $entityName => $entityParams) {
|
||||
if (isset($entityParams['additionalTables']) && is_array($entityParams['additionalTables'])) {
|
||||
$customTables = Util::merge($customTables, $entityParams['additionalTables']);
|
||||
}
|
||||
}
|
||||
|
||||
return $customTables;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
return array(
|
||||
|
||||
'ImportEntity' => array(
|
||||
'fields' => array(
|
||||
'id' => array(
|
||||
'type' => 'id',
|
||||
'dbType' => 'int',
|
||||
'len' => '11',
|
||||
'autoincrement' => true,
|
||||
'unique' => true
|
||||
),
|
||||
'entityId' => array(
|
||||
'type' => 'varchar',
|
||||
'len' => '24',
|
||||
'index' => 'entity'
|
||||
),
|
||||
'entityType' => array(
|
||||
'type' => 'varchar',
|
||||
'len' => '100',
|
||||
'index' => 'entity'
|
||||
),
|
||||
'importId' => array(
|
||||
'type' => 'varchar',
|
||||
'len' => '24',
|
||||
'index' => true
|
||||
),
|
||||
'isImported' => array(
|
||||
'type' => 'bool'
|
||||
),
|
||||
'isUpdated' => array(
|
||||
'type' => 'bool'
|
||||
),
|
||||
'isDuplicate' => array(
|
||||
'type' => 'bool'
|
||||
),
|
||||
),
|
||||
"indexes" => array(
|
||||
"entityImport" => array(
|
||||
"columns" => ["importId", "entityType"]
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
@@ -35,7 +35,7 @@ class EntityManager
|
||||
|
||||
private $fileManager;
|
||||
|
||||
private $metadataUtils;
|
||||
private $metadataHelper;
|
||||
|
||||
public function __construct(Metadata $metadata, Language $language, File\Manager $fileManager)
|
||||
{
|
||||
@@ -43,7 +43,7 @@ class EntityManager
|
||||
$this->language = $language;
|
||||
$this->fileManager = $fileManager;
|
||||
|
||||
$this->metadataUtils = new \Espo\Core\Utils\Metadata\Utils($this->metadata);
|
||||
$this->metadataHelper = new \Espo\Core\Utils\Metadata\Helper($this->metadata);
|
||||
}
|
||||
|
||||
protected function getMetadata()
|
||||
@@ -61,9 +61,9 @@ class EntityManager
|
||||
return $this->fileManager;
|
||||
}
|
||||
|
||||
protected function getMetadataUtils()
|
||||
protected function getMetadataHelper()
|
||||
{
|
||||
return $this->metadataUtils;
|
||||
return $this->metadataHelper;
|
||||
}
|
||||
|
||||
public function create($name, $type, $params = array())
|
||||
@@ -77,8 +77,8 @@ class EntityManager
|
||||
|
||||
$normalizedName = Util::normilizeClassName($name);
|
||||
|
||||
$contents = "<" . "?" . "php\n".
|
||||
"namespace Espo\Custom\Entities;\n".
|
||||
$contents = "<" . "?" . "php\n\n".
|
||||
"namespace Espo\Custom\Entities;\n\n".
|
||||
"class {$normalizedName} extends \Espo\Core\Templates\Entities\\{$type}\n".
|
||||
"{\n".
|
||||
" protected \$entityType = \"$name\";\n".
|
||||
@@ -87,24 +87,24 @@ class EntityManager
|
||||
$filePath = "custom/Espo/Custom/Entities/{$normalizedName}.php";
|
||||
$this->getFileManager()->putContents($filePath, $contents);
|
||||
|
||||
$contents = "<" . "?" . "php\n".
|
||||
"namespace Espo\Custom\Controllers;\n".
|
||||
$contents = "<" . "?" . "php\n\n".
|
||||
"namespace Espo\Custom\Controllers;\n\n".
|
||||
"class {$normalizedName} extends \Espo\Core\Templates\Controllers\\{$type}\n".
|
||||
"{\n".
|
||||
"}\n";
|
||||
$filePath = "custom/Espo/Custom/Controllers/{$normalizedName}.php";
|
||||
$this->getFileManager()->putContents($filePath, $contents);
|
||||
|
||||
$contents = "<" . "?" . "php\n".
|
||||
"namespace Espo\Custom\Services;\n".
|
||||
$contents = "<" . "?" . "php\n\n".
|
||||
"namespace Espo\Custom\Services;\n\n".
|
||||
"class {$normalizedName} extends \Espo\Core\Templates\Services\\{$type}\n".
|
||||
"{\n".
|
||||
"}\n";
|
||||
$filePath = "custom/Espo/Custom/Services/{$normalizedName}.php";
|
||||
$this->getFileManager()->putContents($filePath, $contents);
|
||||
|
||||
$contents = "<" . "?" . "php\n".
|
||||
"namespace Espo\Custom\Repositories;\n".
|
||||
$contents = "<" . "?" . "php\n\n".
|
||||
"namespace Espo\Custom\Repositories;\n\n".
|
||||
"class {$normalizedName} extends \Espo\Core\Templates\Repositories\\{$type}\n".
|
||||
"{\n".
|
||||
"}\n";
|
||||
@@ -136,16 +136,21 @@ class EntityManager
|
||||
'customizable' => true,
|
||||
'importable' => true,
|
||||
'type' => $type,
|
||||
'stream' => $stream
|
||||
'stream' => $stream,
|
||||
'notifications' => true
|
||||
);
|
||||
$this->getMetadata()->set('scopes', $name, $scopeData);
|
||||
|
||||
$filePath = "application/Espo/Core/Templates/Metadata/{$type}/entityDefs.json";
|
||||
$entityDefsData = Json::decode($this->getFileManager()->getContents($filePath), true);
|
||||
$entityDefsDataContents = $this->getFileManager()->getContents($filePath);
|
||||
$entityDefsDataContents = str_replace('{entityType}', $name, $entityDefsDataContents);
|
||||
$entityDefsData = Json::decode($entityDefsDataContents, true);
|
||||
$this->getMetadata()->set('entityDefs', $name, $entityDefsData);
|
||||
|
||||
$filePath = "application/Espo/Core/Templates/Metadata/{$type}/clientDefs.json";
|
||||
$clientDefsData = Json::decode($this->getFileManager()->getContents($filePath), true);
|
||||
$clientDefsContents = $this->getFileManager()->getContents($filePath);
|
||||
$clientDefsContents = str_replace('{entityType}', $name, $clientDefsContents);
|
||||
$clientDefsData = Json::decode($clientDefsContents, true);
|
||||
$this->getMetadata()->set('clientDefs', $name, $clientDefsData);
|
||||
|
||||
$this->getLanguage()->set('Global', 'scopeNames', $name, $labelSingular);
|
||||
@@ -155,6 +160,11 @@ class EntityManager
|
||||
$this->getMetadata()->save();
|
||||
$this->getLanguage()->save();
|
||||
|
||||
$layoutsPath = "application/Espo/Core/Templates/Layouts/{$type}";
|
||||
if ($this->getFileManager()->isDir($layoutsPath)) {
|
||||
$this->getFileManager()->copy($layoutsPath, 'custom/Espo/Custom/Resources/layouts/' . $name);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -183,6 +193,16 @@ class EntityManager
|
||||
$this->getLanguage()->set('Global', 'scopeNamesPlural', $name, $labelPlural);
|
||||
}
|
||||
|
||||
if (isset($data['sortBy'])) {
|
||||
$entityDefsData = array(
|
||||
'collection' => array(
|
||||
'sortBy' => $data['sortBy'],
|
||||
'asc' => !empty($data['asc'])
|
||||
)
|
||||
);
|
||||
$this->getMetadata()->set('entityDefs', $name, $entityDefsData);
|
||||
}
|
||||
|
||||
$this->getMetadata()->save();
|
||||
$this->getLanguage()->save();
|
||||
|
||||
@@ -342,6 +362,10 @@ class EntityManager
|
||||
)
|
||||
)
|
||||
);
|
||||
if ($entityForeign == $entity) {
|
||||
$dataLeft['links'][$link]['midKeys'] = ['leftId', 'rightId'];
|
||||
$dataRight['links'][$linkForeign]['midKeys'] = ['rightId', 'leftId'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class FieldManager
|
||||
|
||||
private $language;
|
||||
|
||||
private $metadataUtils;
|
||||
private $metadataHelper;
|
||||
|
||||
protected $isChanged = null;
|
||||
|
||||
@@ -44,7 +44,7 @@ class FieldManager
|
||||
$this->metadata = $metadata;
|
||||
$this->language = $language;
|
||||
|
||||
$this->metadataUtils = new \Espo\Core\Utils\Metadata\Utils($this->metadata);
|
||||
$this->metadataHelper = new \Espo\Core\Utils\Metadata\Helper($this->metadata);
|
||||
}
|
||||
|
||||
protected function getMetadata()
|
||||
@@ -57,9 +57,9 @@ class FieldManager
|
||||
return $this->language;
|
||||
}
|
||||
|
||||
protected function getMetadataUtils()
|
||||
protected function getMetadataHelper()
|
||||
{
|
||||
return $this->metadataUtils;
|
||||
return $this->metadataHelper;
|
||||
}
|
||||
|
||||
public function read($name, $scope)
|
||||
@@ -187,11 +187,6 @@ class FieldManager
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($fieldDef['linkDefs'])) {
|
||||
$linkDefs = $fieldDef['linkDefs'];
|
||||
unset($fieldDef['linkDefs']);
|
||||
}
|
||||
|
||||
$currentOptionList = array_keys((array) $this->getFieldDef($name, $scope));
|
||||
foreach ($fieldDef as $defName => $defValue) {
|
||||
if ( (!isset($defValue) || $defValue === '') && !in_array($defName, $currentOptionList) ) {
|
||||
@@ -214,11 +209,16 @@ class FieldManager
|
||||
{
|
||||
$fieldDef = $this->prepareFieldDef($fieldName, $fieldDef, $scope);
|
||||
|
||||
$metaFieldDef = $this->getMetadataUtils()->getFieldDefsInFieldMeta($fieldDef);
|
||||
$metaFieldDef = $this->getMetadataHelper()->getFieldDefsInFieldMeta($fieldDef);
|
||||
if (isset($metaFieldDef)) {
|
||||
$fieldDef = Util::merge($metaFieldDef, $fieldDef);
|
||||
}
|
||||
|
||||
if (isset($fieldDef['linkDefs'])) {
|
||||
$linkDefs = $fieldDef['linkDefs'];
|
||||
unset($fieldDef['linkDefs']);
|
||||
}
|
||||
|
||||
$defs = array(
|
||||
'fields' => array(
|
||||
$fieldName => $fieldDef,
|
||||
@@ -226,7 +226,7 @@ class FieldManager
|
||||
);
|
||||
|
||||
/** Save links for a field. */
|
||||
$metaLinkDef = $this->getMetadataUtils()->getLinkDefsInFieldMeta($scope, $fieldDef);
|
||||
$metaLinkDef = $this->getMetadataHelper()->getLinkDefsInFieldMeta($scope, $fieldDef);
|
||||
if (isset($linkDefs) || isset($metaLinkDef)) {
|
||||
$linkDefs = Util::merge((array) $metaLinkDef, (array) $linkDefs);
|
||||
$defs['links'] = array(
|
||||
|
||||
@@ -205,7 +205,7 @@ class Manager
|
||||
$fullPath = $this->concatPaths($path); //todo remove after changing the params
|
||||
|
||||
if ($this->checkCreateFile($fullPath) === false) {
|
||||
throw new Error('Permission denied in '. $fullPath);
|
||||
throw new Error('Permission denied for '. $fullPath);
|
||||
}
|
||||
|
||||
$res = (file_put_contents($fullPath, $data, $flags, $context) !== FALSE);
|
||||
@@ -459,7 +459,7 @@ class Manager
|
||||
|
||||
if (!empty($permissionDeniedList)) {
|
||||
$betterPermissionList = $this->getPermissionUtils()->arrangePermissionList($permissionDeniedList);
|
||||
throw new Error("Permission denied in <br>". implode(", <br>", $betterPermissionList));
|
||||
throw new Error("Permission denied for <br>". implode(", <br>", $betterPermissionList));
|
||||
}
|
||||
|
||||
$res = true;
|
||||
@@ -472,7 +472,7 @@ class Manager
|
||||
$sourceFile = is_file($sourcePath) ? $sourcePath : $this->concatPaths(array($sourcePath, $file));
|
||||
$destFile = $this->concatPaths(array($destPath, $file));
|
||||
|
||||
if (file_exists($sourceFile)) {
|
||||
if (file_exists($sourceFile) && is_file($sourceFile)) {
|
||||
$res &= copy($sourceFile, $destFile);
|
||||
}
|
||||
}
|
||||
@@ -628,7 +628,7 @@ class Manager
|
||||
|
||||
if (!empty($permissionDeniedList)) {
|
||||
$betterPermissionList = $this->getPermissionUtils()->arrangePermissionList($permissionDeniedList);
|
||||
throw new Error("Permission denied in <br>". implode(", <br>", $betterPermissionList));
|
||||
throw new Error("Permission denied for <br>". implode(", <br>", $betterPermissionList));
|
||||
}
|
||||
|
||||
$result = true;
|
||||
@@ -669,6 +669,17 @@ class Manager
|
||||
return (bool) $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if $dirname is directory.
|
||||
*
|
||||
* @param string $dirname
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDir($dirname)
|
||||
{
|
||||
return is_dir($dirname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if $filename is file. If $filename doesn'ot exist, check by pathinfo
|
||||
*
|
||||
|
||||
@@ -163,7 +163,7 @@ class Language
|
||||
return $translated;
|
||||
}
|
||||
|
||||
public function translateOption($value, $field, $scope)
|
||||
public function translateOption($value, $field, $scope = 'Global')
|
||||
{
|
||||
$options = $this->get($scope. '.options.' . $field);
|
||||
if (array_key_exists($value, $options)) {
|
||||
|
||||
@@ -136,7 +136,7 @@ class Layout
|
||||
}
|
||||
|
||||
$layoutPath = $this->getLayoutPath($controllerName, true);
|
||||
$data = Json::encode($layoutData);
|
||||
$data = Json::encode($layoutData, \JSON_PRETTY_PRINT);
|
||||
|
||||
$result &= $this->getFileManager()->putContents(array($layoutPath, $layoutName.'.json'), $data);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ class Metadata
|
||||
private $fileManager;
|
||||
private $converter;
|
||||
private $moduleConfig;
|
||||
private $metadataHelper;
|
||||
|
||||
/**
|
||||
* @var string - uses for loading default values
|
||||
@@ -76,12 +77,6 @@ class Metadata
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->fileManager = $fileManager;
|
||||
|
||||
$this->unifier = new \Espo\Core\Utils\File\Unifier($this->fileManager);
|
||||
|
||||
$this->converter = new \Espo\Core\Utils\Database\Converter($this, $this->fileManager);
|
||||
|
||||
$this->moduleConfig = new \Espo\Core\Utils\Module($this->config, $this->fileManager);
|
||||
}
|
||||
|
||||
protected function getConfig()
|
||||
@@ -89,26 +84,47 @@ class Metadata
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
protected function getUnifier()
|
||||
{
|
||||
return $this->unifier;
|
||||
}
|
||||
|
||||
protected function getFileManager()
|
||||
{
|
||||
return $this->fileManager;
|
||||
}
|
||||
|
||||
protected function getUnifier()
|
||||
{
|
||||
if (!isset($this->unifier)) {
|
||||
$this->unifier = new \Espo\Core\Utils\File\Unifier($this->fileManager);
|
||||
}
|
||||
|
||||
return $this->unifier;
|
||||
}
|
||||
|
||||
protected function getConverter()
|
||||
{
|
||||
if (!isset($this->converter)) {
|
||||
$this->converter = new \Espo\Core\Utils\Database\Converter($this, $this->fileManager);
|
||||
}
|
||||
|
||||
return $this->converter;
|
||||
}
|
||||
|
||||
protected function getModuleConfig()
|
||||
{
|
||||
if (!isset($this->moduleConfig)) {
|
||||
$this->moduleConfig = new \Espo\Core\Utils\Module($this->config, $this->fileManager);
|
||||
}
|
||||
|
||||
return $this->moduleConfig;
|
||||
}
|
||||
|
||||
protected function getMetadataHelper()
|
||||
{
|
||||
if (!isset($this->metadataHelper)) {
|
||||
$this->metadataHelper = new Metadata\Helper($this);
|
||||
}
|
||||
|
||||
return $this->metadataHelper;
|
||||
}
|
||||
|
||||
public function isCached()
|
||||
{
|
||||
if (!$this->getConfig()->get('useCache')) {
|
||||
@@ -139,6 +155,7 @@ class Metadata
|
||||
} else {
|
||||
$this->meta = $this->getUnifier()->unify($this->name, $this->paths, true);
|
||||
$this->meta = $this->setLanguageFromConfig($this->meta);
|
||||
$this->meta = $this->addAdditionalFields($this->meta);
|
||||
|
||||
if ($this->getConfig()->get('useCache')) {
|
||||
$isSaved = $this->getFileManager()->putPhpContents($this->cacheFile, $this->meta);
|
||||
@@ -197,6 +214,7 @@ class Metadata
|
||||
}
|
||||
|
||||
/**
|
||||
* todo: move to a separate file
|
||||
* Set language list and default for Settings, Preferences metadata
|
||||
*
|
||||
* @param array $data Meta
|
||||
@@ -222,6 +240,37 @@ class Metadata
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* todo: move to a separate file
|
||||
* Add additional fields defined from metadata -> fields
|
||||
*
|
||||
* @param array $meta
|
||||
*/
|
||||
protected function addAdditionalFields(array $meta)
|
||||
{
|
||||
$metaCopy = $meta;
|
||||
$definitionList = $meta['fields'];
|
||||
|
||||
foreach ($metaCopy['entityDefs'] as $entityName => $entityParams) {
|
||||
foreach ($entityParams['fields'] as $fieldName => $fieldParams) {
|
||||
|
||||
$additionalFields = $this->getMetadataHelper()->getAdditionalFieldList($fieldName, $fieldParams, $definitionList);
|
||||
if (!empty($additionalFields)) {
|
||||
//merge or add to the end of meta array
|
||||
foreach ($additionalFields as $subFieldName => $subFieldParams) {
|
||||
if (isset($entityParams['fields'][$subFieldName])) {
|
||||
$meta['entityDefs'][$entityName]['fields'][$subFieldName] = Util::merge($subFieldParams, $entityParams['fields'][$subFieldName]);
|
||||
} else {
|
||||
$meta['entityDefs'][$entityName]['fields'][$subFieldName] = $subFieldParams;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Metadata data
|
||||
* Ex. $key1 = menu, $key2 = Account then will be created a file metadataFolder/menu/Account.json
|
||||
|
||||
@@ -22,10 +22,26 @@
|
||||
|
||||
namespace Espo\Core\Utils\Metadata;
|
||||
|
||||
class Utils
|
||||
use Espo\Core\Utils\Util;
|
||||
|
||||
class Helper
|
||||
{
|
||||
private $metadata;
|
||||
|
||||
protected $defaultNaming = 'postfix';
|
||||
|
||||
/**
|
||||
* List of copied params for metadata -> 'fields' from parent items
|
||||
*/
|
||||
protected $copiedDefParams = array(
|
||||
'readOnly',
|
||||
'notStorable',
|
||||
'layoutListDisabled',
|
||||
'layoutDetailDisabled',
|
||||
'layoutMassUpdateDisabled',
|
||||
'layoutFiltersDisabled',
|
||||
);
|
||||
|
||||
public function __construct(\Espo\Core\Utils\Metadata $metadata)
|
||||
{
|
||||
$this->metadata = $metadata;
|
||||
@@ -102,7 +118,41 @@ class Utils
|
||||
return $linkFieldDefsByType;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Get additional field list based on field definition in metadata 'fields'
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @param array $fieldParams
|
||||
* @param array|null $definitionList
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAdditionalFieldList($fieldName, array $fieldParams, array $definitionList = null)
|
||||
{
|
||||
if (empty($fieldParams['type'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$fieldType = $fieldParams['type'];
|
||||
$fieldDefinition = isset($definitionList[$fieldType]) ? $definitionList[$fieldType] : $this->getMetadata()->get('fields.'.$fieldType);
|
||||
|
||||
?>
|
||||
if (!empty($fieldDefinition['fields']) && is_array($fieldDefinition['fields'])) {
|
||||
|
||||
$copiedParams = array_intersect_key($fieldParams, array_flip($this->copiedDefParams));
|
||||
|
||||
$additionalFields = array();
|
||||
|
||||
//add additional fields
|
||||
foreach ($fieldDefinition['fields'] as $subFieldName => $subFieldParams) {
|
||||
$namingType = isset($fieldDefinition['naming']) ? $fieldDefinition['naming'] : $this->defaultNaming;
|
||||
|
||||
$subFieldNaming = Util::getNaming($fieldName, $subFieldName, $namingType);
|
||||
$additionalFields[$subFieldNaming] = array_merge($copiedParams, $subFieldParams);
|
||||
}
|
||||
|
||||
return $additionalFields;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -510,6 +510,11 @@ class Util
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function generateId()
|
||||
{
|
||||
return uniqid() . substr(md5(rand()), 0, 4);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ return array (
|
||||
'ru_RU',
|
||||
'pl_PL',
|
||||
'pt_BR',
|
||||
'uk_UA',
|
||||
'vi_VN'
|
||||
),
|
||||
'language' => 'en_US',
|
||||
@@ -93,10 +94,13 @@ return array (
|
||||
'disableExport' => false,
|
||||
'assignmentEmailNotifications' => false,
|
||||
'assignmentEmailNotificationsEntityList' => array('Lead', 'Opportunity', 'Task', 'Case'),
|
||||
'assignmentNotificationsEntityList' => array('Meeting', 'Call', 'Task', 'Email'),
|
||||
'emailMessageMaxSize' => 10,
|
||||
'notificationsCheckInterval' => 10,
|
||||
'disabledCountQueryEntityList' => array('Email'),
|
||||
'maxEmailAccountCount' => 2,
|
||||
'followCreatedEntities' => false,
|
||||
'b2cMode' => false,
|
||||
'isInstalled' => false,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[{
|
||||
"label":"Overview",
|
||||
"rows": [
|
||||
[{"name":"name"}]
|
||||
[{"name":"name"}, false]
|
||||
]
|
||||
}]
|
||||
|
||||
28
application/Espo/Entities/Import.php
Normal file
28
application/Espo/Entities/Import.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Entities;
|
||||
|
||||
class Import extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
|
||||
}
|
||||
@@ -18,9 +18,9 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Entities;
|
||||
namespace Espo\Entities;
|
||||
|
||||
class InboundEmail extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
@@ -26,12 +26,13 @@ use Espo\ORM\Entity;
|
||||
|
||||
class AssignmentEmailNotification extends \Espo\Core\Hooks\Base
|
||||
{
|
||||
|
||||
public function afterSave(Entity $entity)
|
||||
{
|
||||
if (
|
||||
$this->getConfig()->get('assignmentEmailNotifications')
|
||||
&&
|
||||
$entity->has('assignedUserId')
|
||||
&&
|
||||
in_array($entity->getEntityName(), $this->getConfig()->get('assignmentEmailNotificationsEntityList', array()))
|
||||
) {
|
||||
|
||||
|
||||
106
application/Espo/Hooks/Common/Notifications.php
Normal file
106
application/Espo/Hooks/Common/Notifications.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Hooks\Common;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\Core\Utils\Util;
|
||||
|
||||
class Notifications extends \Espo\Core\Hooks\Base
|
||||
{
|
||||
public static $order = 10;
|
||||
|
||||
protected $noticatorsHash = array();
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->dependencies[] = 'container';
|
||||
$this->dependencies[] = 'metadata';
|
||||
}
|
||||
|
||||
private $hasStreamCache = array();
|
||||
|
||||
protected function getContainer()
|
||||
{
|
||||
return $this->getInjection('container');
|
||||
}
|
||||
|
||||
protected function getMetadata()
|
||||
{
|
||||
return $this->getInjection('metadata');
|
||||
}
|
||||
|
||||
protected function checkHasStream($entityType)
|
||||
{
|
||||
if (!array_key_exists($entityType, $this->hasStreamCache)) {
|
||||
$this->hasStreamCache[$entityType] = $this->getMetadata()->get("scopes.{$entityType}.stream");
|
||||
}
|
||||
return $this->hasStreamCache[$entityType];
|
||||
}
|
||||
|
||||
protected function getNotificator($entityType)
|
||||
{
|
||||
if (empty($this->noticatorsHash[$entityType])) {
|
||||
$normalizedName = Util::normilizeClassName($entityType);
|
||||
|
||||
$className = '\\Espo\\Custom\\Notificators\\' . $normalizedName;
|
||||
if (!class_exists($className)) {
|
||||
$moduleName = $this->getMetadata()->getScopeModuleName($entityType);
|
||||
if ($moduleName) {
|
||||
$className = '\\Espo\\Modules\\' . $moduleName . '\\Notificators\\' . $normalizedName;
|
||||
} else {
|
||||
$className = '\\Espo\\Notificators\\' . $normalizedName;
|
||||
}
|
||||
if (!class_exists($className)) {
|
||||
$className = '\\Espo\\Core\\Notificators\\Base';
|
||||
}
|
||||
}
|
||||
|
||||
$notificator = new $className();
|
||||
$dependencies = $notificator->getDependencyList();
|
||||
foreach ($dependencies as $name) {
|
||||
$notificator->inject($name, $this->getContainer()->get($name));
|
||||
}
|
||||
|
||||
$this->noticatorsHash[$entityType] = $notificator;
|
||||
}
|
||||
return $this->noticatorsHash[$entityType];
|
||||
}
|
||||
|
||||
public function afterSave(Entity $entity, array $options = array())
|
||||
{
|
||||
$entityType = $entity->getEntityType();
|
||||
|
||||
if (!empty($options['silent']) && !empty($options['noNotifications'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->checkHasStream($entityType)) {
|
||||
if (in_array($entityType, $this->getConfig()->get('assignmentNotificationsEntityList', []))) {
|
||||
$notificator = $this->getNotificator($entityType);
|
||||
$notificator->process($entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,11 +34,9 @@ class Stream extends \Espo\Core\Hooks\Base
|
||||
|
||||
protected $isLinkObservableInStreamCache = array();
|
||||
|
||||
protected $statusDefs = array(
|
||||
'Lead' => 'status',
|
||||
'Case' => 'status',
|
||||
'Opportunity' => 'stage',
|
||||
);
|
||||
protected $statusFields = null;
|
||||
|
||||
public static $order = 9;
|
||||
|
||||
protected function init()
|
||||
{
|
||||
@@ -75,6 +73,12 @@ class Stream extends \Espo\Core\Hooks\Base
|
||||
if ($this->checkHasStream($entity)) {
|
||||
$this->getStreamService()->unfollowAllUsersFromEntity($entity);
|
||||
}
|
||||
$query = $this->getEntityManager()->getQuery();
|
||||
$sql = "
|
||||
DELETE FROM `note`
|
||||
WHERE related_id = ".$query->quote($entity->id)." AND related_type = ".$query->quote($entity->getEntityType()) ."
|
||||
";
|
||||
$this->getEntityManager()->getPDO()->query($sql);
|
||||
}
|
||||
|
||||
protected function handleCreateRelated(Entity $entity)
|
||||
@@ -154,31 +158,35 @@ class Stream extends \Espo\Core\Hooks\Base
|
||||
return $userIdList;
|
||||
}
|
||||
|
||||
public function afterSave(Entity $entity)
|
||||
public function afterSave(Entity $entity, array $options = array())
|
||||
{
|
||||
$entityName = $entity->getEntityName();
|
||||
|
||||
if ($this->checkHasStream($entity)) {
|
||||
if ($entity->isNew()) {
|
||||
$userIdList = [];
|
||||
|
||||
$assignedUserId = $entity->get('assignedUserId');
|
||||
$createdById = $entity->get('createdById');
|
||||
|
||||
$userIdList = [];
|
||||
if (!empty($createdById)) {
|
||||
if ($this->getConfig()->get('followCreatedEntities') && !empty($createdById)) {
|
||||
$userIdList[] = $createdById;
|
||||
}
|
||||
if (!empty($assignedUserId) && $createdById != $assignedUserId) {
|
||||
if (!empty($assignedUserId) && !in_array($assignedUserId, $userIdList)) {
|
||||
$userIdList[] = $assignedUserId;
|
||||
}
|
||||
|
||||
|
||||
if (!empty($userIdList)) {
|
||||
$this->getStreamService()->followEntityMass($entity, $userIdList);
|
||||
}
|
||||
|
||||
$this->getStreamService()->noteCreate($entity);
|
||||
if (empty($options['noStream'])) {
|
||||
$this->getStreamService()->noteCreate($entity);
|
||||
}
|
||||
|
||||
if (in_array($this->getUser()->id, $userIdList)) {
|
||||
$entity->set('isFollowed', true);
|
||||
}
|
||||
|
||||
$autofollowUserIdList = $this->getAutofollowUserIdList($entity, $userIdList);
|
||||
foreach ($autofollowUserIdList as $i => $userId) {
|
||||
@@ -195,7 +203,7 @@ class Stream extends \Espo\Core\Hooks\Base
|
||||
'method' => 'afterRecordCreatedJob',
|
||||
'data' => array(
|
||||
'userIdList' => $autofollowUserIdList,
|
||||
'entityType' => $entity->getEntityName(),
|
||||
'entityType' => $entity->getEntityType(),
|
||||
'entityId' => $entity->id
|
||||
)
|
||||
));
|
||||
@@ -203,31 +211,47 @@ class Stream extends \Espo\Core\Hooks\Base
|
||||
}
|
||||
|
||||
} else {
|
||||
if ($entity->isFieldChanged('assignedUserId')) {
|
||||
$assignedUserId = $entity->get('assignedUserId');
|
||||
if (!empty($assignedUserId)) {
|
||||
$this->getStreamService()->followEntity($entity, $assignedUserId);
|
||||
$this->getStreamService()->noteAssign($entity);
|
||||
}
|
||||
}
|
||||
$this->getStreamService()->handleAudited($entity);
|
||||
if (empty($options['noStream'])) {
|
||||
if ($entity->isFieldChanged('assignedUserId')) {
|
||||
$assignedUserId = $entity->get('assignedUserId');
|
||||
if (!empty($assignedUserId)) {
|
||||
$this->getStreamService()->followEntity($entity, $assignedUserId);
|
||||
$this->getStreamService()->noteAssign($entity);
|
||||
|
||||
if (array_key_exists($entityName, $this->statusDefs)) {
|
||||
$field = $this->statusDefs[$entityName];
|
||||
$value = $entity->get($field);
|
||||
if (!empty($value) && $value != $entity->getFetched($field)) {
|
||||
$this->getStreamService()->noteStatus($entity, $field);
|
||||
if ($this->getUser()->id === $assignedUserId) {
|
||||
$entity->set('isFollowed', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->getStreamService()->handleAudited($entity);
|
||||
|
||||
$statusFields = $this->getStatusFields();
|
||||
|
||||
if (array_key_exists($entityName, $this->statusFields)) {
|
||||
$field = $this->statusFields[$entityName];
|
||||
$value = $entity->get($field);
|
||||
if (!empty($value) && $value != $entity->getFetched($field)) {
|
||||
$this->getStreamService()->noteStatus($entity, $field);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($entity->isNew() && $this->getMetadata()->get("scopes.{$entityName}.tab")) {
|
||||
if ($entity->isNew() && empty($options['noStream']) && $this->getMetadata()->get("scopes.{$entityName}.tab")) {
|
||||
$this->handleCreateRelated($entity);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getStatusFields()
|
||||
{
|
||||
if (is_null($this->statusFields)) {
|
||||
$this->statusFields = $this->getMetadata()->get("entityDefs.Note.statusFields", array());
|
||||
}
|
||||
return $this->statusFields;
|
||||
}
|
||||
|
||||
protected function getStreamService()
|
||||
{
|
||||
if (empty($this->streamService)) {
|
||||
|
||||
@@ -40,7 +40,7 @@ class Notifications extends \Espo\Core\Hooks\Base
|
||||
return $this->getInjection('serviceFactory');
|
||||
}
|
||||
|
||||
protected function getMentionedUserList($entity)
|
||||
protected function getMentionedUserIdList($entity)
|
||||
{
|
||||
$mentionedUserList = array();
|
||||
$data = $entity->get('data');
|
||||
@@ -53,33 +53,49 @@ class Notifications extends \Espo\Core\Hooks\Base
|
||||
return $mentionedUserList;
|
||||
}
|
||||
|
||||
protected function getSubscriberIdList($parentType, $parentId)
|
||||
{
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
$sql = "
|
||||
SELECT user_id AS userId
|
||||
FROM subscription
|
||||
WHERE entity_id = " . $pdo->quote($parentId) . " AND entity_type = " . $pdo->quote($parentType);
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute();
|
||||
$userIdList = [];
|
||||
while ($row = $sth->fetch(\PDO::FETCH_ASSOC)) {
|
||||
if ($this->getUser()->id != $row['userId']) {
|
||||
$userIdList[] = $row['userId'];
|
||||
}
|
||||
}
|
||||
return $userIdList;
|
||||
}
|
||||
|
||||
public function afterSave(Entity $entity)
|
||||
{
|
||||
if ($entity->isNew()) {
|
||||
|
||||
$parentType = $entity->get('parentType');
|
||||
$parentId = $entity->get('parentId');
|
||||
|
||||
$superParentType = $entity->get('superParentType');
|
||||
$superParentTypeId = $entity->get('superParentTypeId');
|
||||
|
||||
$userIdList = [];
|
||||
|
||||
if ($parentType && $parentId) {
|
||||
$userIdList = array_merge($userIdList, $this->getSubscriberIdList($parentType, $parentId));
|
||||
}
|
||||
|
||||
$mentionedUserList = $this->getMentionedUserList($entity);
|
||||
if ($superParentType && $superParentTypeId) {
|
||||
$userIdList = array_merge($userIdList, $this->getSubscriberIdList($superParentType, $superParentTypeId));
|
||||
}
|
||||
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
$sql = "
|
||||
SELECT user_id AS userId
|
||||
FROM subscription
|
||||
WHERE entity_id = " . $pdo->quote($parentId) . " AND entity_type = " . $pdo->quote($parentType);
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute();
|
||||
$userIdList = array();
|
||||
while ($row = $sth->fetch(\PDO::FETCH_ASSOC)) {
|
||||
if ($this->getUser()->id != $row['userId'] && !in_array($row['userId'], $mentionedUserList)) {
|
||||
$userIdList[] = $row['userId'];
|
||||
}
|
||||
}
|
||||
if (!empty($userIdList)) {
|
||||
$this->getNotificationService()->notifyAboutNote($userIdList, $entity);
|
||||
}
|
||||
//$userIdList = array_merge($userIdList, $this->getMentionedUserIdList($entity));
|
||||
|
||||
$userIdList = array_unique($userIdList);
|
||||
|
||||
if (!empty($userIdList)) {
|
||||
$this->getNotificationService()->notifyAboutNote($userIdList, $entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,9 @@ class Cleanup extends \Espo\Core\Jobs\Base
|
||||
$this->cleanupJobs();
|
||||
$this->cleanupScheduledJobLog();
|
||||
$this->cleanupAttachments();
|
||||
$this->cleanupEmails();
|
||||
$this->cleanupNotes();
|
||||
$this->cleanupNotifications();
|
||||
}
|
||||
|
||||
protected function cleanupJobs()
|
||||
@@ -46,21 +49,26 @@ class Cleanup extends \Espo\Core\Jobs\Base
|
||||
|
||||
protected function cleanupScheduledJobLog()
|
||||
{
|
||||
$lastTenRecords = "SELECT c.id FROM (
|
||||
SELECT i1.id
|
||||
FROM scheduled_job_log_record i1
|
||||
CROSS JOIN scheduled_job_log_record i2 ON ( i1.scheduled_job_id = i2.scheduled_job_id
|
||||
AND i1.id < i2.id )
|
||||
GROUP BY i1.id
|
||||
HAVING COUNT( * ) <10
|
||||
ORDER BY i1.created_at DESC
|
||||
) AS c";
|
||||
|
||||
$query = "DELETE FROM `scheduled_job_log_record` WHERE DATE(created_at) < '".$this->getDate()."' AND id NOT IN (".$lastTenRecords.") ";
|
||||
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
$sth = $pdo->prepare($query);
|
||||
|
||||
$sql = "SELECT id FROM scheduled_job";
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute();
|
||||
while ($row = $sth->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$id = $row['id'];
|
||||
|
||||
$lastRowsSql = "SELECT id FROM scheduled_job_log_record WHERE scheduled_job_id = '".$id."' ORDER BY created_at DESC LIMIT 0,10";
|
||||
$lastRowsSth = $pdo->prepare($lastRowsSql);
|
||||
$lastRowsSth->execute();
|
||||
$lastRowIds = $lastRowsSth->fetchAll(\PDO::FETCH_COLUMN, 0);
|
||||
|
||||
$delSql = "DELETE FROM `scheduled_job_log_record`
|
||||
WHERE scheduled_job_id = '".$id."'
|
||||
AND DATE(created_at) < '".$this->getDate()."'
|
||||
AND id NOT IN ('".implode("', '", $lastRowIds)."')
|
||||
";
|
||||
$pdo->query($delSql);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getDate($format = 'Y-m-d')
|
||||
@@ -72,19 +80,84 @@ class Cleanup extends \Espo\Core\Jobs\Base
|
||||
|
||||
protected function cleanupAttachments()
|
||||
{
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
|
||||
$dateBefore = date('Y-m-d H:i:s', time() - 3600 * 24);
|
||||
|
||||
$collection = $this->getEntityManager()->getRepository('Attachment')->where(array(
|
||||
'role' => array(
|
||||
'Import File',
|
||||
'Export File'
|
||||
),
|
||||
'role' => ['Export File'],
|
||||
'createdAt<' => $dateBefore
|
||||
))->limit(0, 100)->find();
|
||||
|
||||
foreach ($collection as $e) {
|
||||
$this->getEntityManager()->removeEntity($e);
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM attachment WHERE deleted = 1 AND created_at < ".$pdo->quote($dateBefore);
|
||||
$sth = $pdo->query($sql);
|
||||
}
|
||||
|
||||
protected function cleanupEmails()
|
||||
{
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
|
||||
$dateBefore = date('Y-m-d H:i:s', time() - 3600 * 24 * 20);
|
||||
|
||||
$sql = "SELECT * FROM email WHERE deleted = 1 AND created_at < ".$pdo->quote($dateBefore);
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute();
|
||||
while ($row = $sth->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$id = $row['id'];
|
||||
$attachments = $this->getEntityManager()->getRepository('Attachment')->where(array(
|
||||
'parentId' => $id,
|
||||
'parentType' => 'Email'
|
||||
))->find();
|
||||
foreach ($attachments as $attachment) {
|
||||
$this->getEntityManager()->removeEntity($attachment);
|
||||
}
|
||||
$sqlDel = "DELETE FROM email WHERE deleted = 1 AND id = ".$pdo->quote($id);
|
||||
$pdo->query($sqlDel);
|
||||
$sqlDel = "DELETE FROM email_user WHERE email_id = ".$pdo->quote($id);
|
||||
$pdo->query($sqlDel);
|
||||
}
|
||||
}
|
||||
|
||||
protected function cleanupNotes()
|
||||
{
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
|
||||
$dateBefore = date('Y-m-d H:i:s', time() - 3600 * 24 * 20);
|
||||
|
||||
$sql = "SELECT * FROM `note` WHERE deleted = 1 AND created_at < ".$pdo->quote($dateBefore);
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute();
|
||||
while ($row = $sth->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$id = $row['id'];
|
||||
$attachments = $this->getEntityManager()->getRepository('Attachment')->where(array(
|
||||
'parentId' => $id,
|
||||
'parentType' => 'Note'
|
||||
))->find();
|
||||
foreach ($attachments as $attachment) {
|
||||
$this->getEntityManager()->removeEntity($attachment);
|
||||
}
|
||||
$sqlDel = "DELETE FROM `note` WHERE deleted = 1 AND id = ".$pdo->quote($id);
|
||||
$pdo->query($sqlDel);
|
||||
}
|
||||
}
|
||||
|
||||
protected function cleanupNotifications()
|
||||
{
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
|
||||
$dateBefore = date('Y-m-d H:i:s', time() - 3600 * 24 * 50);
|
||||
|
||||
$sql = "SELECT * FROM `notification` WHERE created_at < ".$pdo->quote($dateBefore);
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute();
|
||||
while ($row = $sth->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$id = $row['id'];
|
||||
$this->getEntityManager()->getRepository('Notification')->deleteFromDb($id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,10 @@ class Invitations
|
||||
case 'date':
|
||||
$contents = str_replace($key, $this->dateTime->convertSystemDateToGlobal($entity->get($field)), $contents);
|
||||
break;
|
||||
case 'jsonArray':
|
||||
break;
|
||||
case 'jsonObject':
|
||||
break;
|
||||
default:
|
||||
$contents = str_replace($key, $entity->get($field), $contents);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
@@ -30,22 +30,40 @@ class Call extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
|
||||
public function actionSendInvitations($params, $data)
|
||||
{
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
|
||||
$entity = $this->getRecordService()->getEntity($data['id']);
|
||||
|
||||
|
||||
if (!$entity) {
|
||||
throw new NotFound();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!$this->getAcl()->check($entity, 'edit')) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
|
||||
return $this->getRecordService()->sendInvitations($entity);
|
||||
}
|
||||
|
||||
public function actionMassSetHeld($params, $data)
|
||||
{
|
||||
if (empty($data['ids']) && !is_array($data['ids'])) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
return $this->getRecordService()->massSetHeld($data['ids']);
|
||||
}
|
||||
|
||||
public function actionMassSetNotHeld($params, $data)
|
||||
{
|
||||
if (empty($data['ids']) && !is_array($data['ids'])) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
return $this->getRecordService()->massSetNotHeld($data['ids']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
@@ -27,25 +27,43 @@ use \Espo\Core\Exceptions\BadRequest;
|
||||
use \Espo\Core\Exceptions\NotFound;
|
||||
|
||||
class Meeting extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
public function actionSendInvitations($params, $data)
|
||||
{
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
|
||||
$entity = $this->getRecordService()->getEntity($data['id']);
|
||||
|
||||
|
||||
if (!$entity) {
|
||||
throw new NotFound();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!$this->getAcl()->check($entity, 'edit')) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
|
||||
return $this->getRecordService()->sendInvitations($entity);
|
||||
}
|
||||
|
||||
public function actionMassSetHeld($params, $data)
|
||||
{
|
||||
if (empty($data['ids']) && !is_array($data['ids'])) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
return $this->getRecordService()->massSetHeld($data['ids']);
|
||||
}
|
||||
|
||||
public function actionMassSetNotHeld($params, $data)
|
||||
{
|
||||
if (empty($data['ids']) && !is_array($data['ids'])) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
return $this->getRecordService()->massSetNotHeld($data['ids']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,24 +29,24 @@ class Contact extends \Espo\Core\ORM\Repositories\RDB
|
||||
public function handleSelectParams(&$params)
|
||||
{
|
||||
parent::handleSelectParams($params);
|
||||
|
||||
|
||||
if (empty($params['customJoin'])) {
|
||||
$params['customJoin'] = '';
|
||||
}
|
||||
|
||||
|
||||
$params['customJoin'] .= "
|
||||
LEFT JOIN `account_contact` AS accountContact
|
||||
ON accountContact.contact_id = contact.id AND accountContact.account_id = contact.account_id AND accountContact.deleted = 0
|
||||
";
|
||||
}
|
||||
|
||||
public function afterSave(Entity $entity)
|
||||
|
||||
public function afterSave(Entity $entity, array $options)
|
||||
{
|
||||
$result = parent::afterSave($entity);
|
||||
|
||||
$result = parent::afterSave($entity, $options);
|
||||
|
||||
$accountIdChanged = $entity->has('accountId') && $entity->get('accountId') != $entity->getFetched('accountId');
|
||||
$titleChanged = $entity->has('title') && $entity->get('title') != $entity->getFetched('title');
|
||||
|
||||
|
||||
if ($accountIdChanged) {
|
||||
$accountId = $entity->get('accountId');
|
||||
if (empty($accountId)) {
|
||||
@@ -54,7 +54,7 @@ class Contact extends \Espo\Core\ORM\Repositories\RDB
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($titleChanged) {
|
||||
if (empty($accountId)) {
|
||||
$accountId = $entity->getFetched('accountId');
|
||||
@@ -63,11 +63,10 @@ class Contact extends \Espo\Core\ORM\Repositories\RDB
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($accountIdChanged || $titleChanged) {
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
|
||||
|
||||
$sql = "
|
||||
SELECT id, role FROM account_contact
|
||||
WHERE
|
||||
@@ -92,7 +91,7 @@ class Contact extends \Espo\Core\ORM\Repositories\RDB
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,21 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Repositories;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
class Lead extends \Espo\Core\ORM\Repositories\RDB
|
||||
{
|
||||
|
||||
{
|
||||
public function afterSave(Entity $entity, array $options)
|
||||
{
|
||||
parent::afterSave($entity, $options);
|
||||
|
||||
if ($entity->has('targetListId') && $entity->isNew()) {
|
||||
$this->relate($entity, 'targetLists', $entity->get('targetListId'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,16 +26,16 @@ use Espo\ORM\Entity;
|
||||
|
||||
class Meeting extends \Espo\Core\ORM\Repositories\RDB
|
||||
{
|
||||
protected function beforeSave(Entity $entity)
|
||||
protected function beforeSave(Entity $entity, array $options)
|
||||
{
|
||||
parent::beforeSave($entity);
|
||||
|
||||
parent::beforeSave($entity, $options);
|
||||
|
||||
$parentId = $entity->get('parentId');
|
||||
$parentType = $entity->get('parentType');
|
||||
if (!empty($parentId) || !empty($parentType)) {
|
||||
$parent = $this->getEntityManager()->getEntity($parentType, $parentId);
|
||||
if (!empty($parent)) {
|
||||
if ($parent->getEntityName() == 'Account') {
|
||||
if ($parent->getEntityType() == 'Account') {
|
||||
$accountId = $parent->id;
|
||||
} else if ($parent->has('accountId')) {
|
||||
$accountId = $parent->get('accountId');
|
||||
@@ -73,7 +73,7 @@ class Meeting extends \Espo\Core\ORM\Repositories\RDB
|
||||
SELECT id, `seconds`, `type`
|
||||
FROM `reminder`
|
||||
WHERE
|
||||
`entity_type` = ".$pdo->quote($entity->getEntityName())." AND
|
||||
`entity_type` = ".$pdo->quote($entity->getEntityType())." AND
|
||||
`entity_id` = ".$pdo->quote($entity->id)." AND
|
||||
`deleted` = 0
|
||||
ORDER BY `seconds` ASC
|
||||
@@ -95,9 +95,9 @@ class Meeting extends \Espo\Core\ORM\Repositories\RDB
|
||||
$entity->set('reminders', $reminders);
|
||||
}
|
||||
|
||||
protected function afterSave(Entity $entity)
|
||||
protected function afterSave(Entity $entity, array $options)
|
||||
{
|
||||
parent::afterSave($entity);
|
||||
parent::afterSave($entity, $options);
|
||||
|
||||
if (
|
||||
$entity->isNew() ||
|
||||
@@ -125,7 +125,7 @@ class Meeting extends \Espo\Core\ORM\Repositories\RDB
|
||||
";
|
||||
$pdo->query($sql);
|
||||
}
|
||||
|
||||
|
||||
if (empty($reminders) || !is_array($reminders)) return;
|
||||
|
||||
$entityType = $entity->getEntityName();
|
||||
|
||||
@@ -18,15 +18,14 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Repositories;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
class Opportunity extends \Espo\Core\ORM\Repositories\RDB
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -57,9 +57,17 @@ class Task extends \Espo\Core\ORM\Repositories\RDB
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function beforeSave(Entity $entity)
|
||||
protected function beforeSave(Entity $entity, array $options)
|
||||
{
|
||||
parent::beforeSave($entity);
|
||||
parent::beforeSave($entity, $options);
|
||||
|
||||
if ($entity->isFieldChanged('status')) {
|
||||
if ($entity->get('status') == 'Completed') {
|
||||
$entity->set('dateCompleted', date('Y-m-d H:i:s'));
|
||||
} else {
|
||||
$entity->set('dateCompleted', null);
|
||||
}
|
||||
}
|
||||
|
||||
if ($entity->has('dateStartDate')) {
|
||||
$dateStartDate = $entity->get('dateStartDate');
|
||||
@@ -84,6 +92,22 @@ class Task extends \Espo\Core\ORM\Repositories\RDB
|
||||
$entity->set('dateEndDate', null);
|
||||
}
|
||||
}
|
||||
|
||||
$parentId = $entity->get('parentId');
|
||||
$parentType = $entity->get('parentType');
|
||||
if (!empty($parentId) || !empty($parentType)) {
|
||||
$parent = $this->getEntityManager()->getEntity($parentType, $parentId);
|
||||
if (!empty($parent)) {
|
||||
if ($parent->getEntityType() == 'Account') {
|
||||
$accountId = $parent->id;
|
||||
} else if ($parent->has('accountId')) {
|
||||
$accountId = $parent->get('accountId');
|
||||
}
|
||||
if (!empty($accountId)) {
|
||||
$entity->set('accountId', $accountId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"sicCode": "Sic Code",
|
||||
"industry": "Industry",
|
||||
"type": "Type",
|
||||
"contactRole": "Role",
|
||||
"contactRole": "Title",
|
||||
"campaign": "Campaign"
|
||||
},
|
||||
"links": {
|
||||
@@ -18,9 +18,10 @@
|
||||
"opportunities": "Opportunities",
|
||||
"cases": "Cases",
|
||||
"documents": "Documents",
|
||||
"meetingsPrimary": "Meetings (Internal)",
|
||||
"callsPrimary": "Calls (Internal)",
|
||||
"tasksPrimary": "Tasks (Internal)",
|
||||
"meetingsPrimary": "Meetings (expanded)",
|
||||
"callsPrimary": "Calls (expanded)",
|
||||
"tasksPrimary": "Tasks (expanded)",
|
||||
"emailsPrimary": "Emails (expanded)",
|
||||
"targetLists": "Target Lists",
|
||||
"campaignLogRecords": "Campaign Log"
|
||||
},
|
||||
@@ -63,5 +64,9 @@
|
||||
"labels": {
|
||||
"Create Account": "Create Account",
|
||||
"Copy Billing": "Copy Billing"
|
||||
},
|
||||
"presetFilters": {
|
||||
"customers": "Customers",
|
||||
"partners": "Partners"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"layouts": {
|
||||
"detailConvert": "Convert Lead"
|
||||
"detailConvert": "Convert Lead",
|
||||
"listForAccount": "List (for Account)"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
"Tentative": "Tentative"
|
||||
}
|
||||
},
|
||||
"massActions": {
|
||||
"setHeld": "Set Held",
|
||||
"setNotHeld": "Set Not Held"
|
||||
},
|
||||
"labels": {
|
||||
"Create Call": "Create Call",
|
||||
"Set Held": "Set Held",
|
||||
|
||||
@@ -10,9 +10,11 @@
|
||||
"doNotCall": "Do Not Call",
|
||||
"address": "Address",
|
||||
"opportunityRole": "Opportunity Role",
|
||||
"accountRole": "Role",
|
||||
"accountRole": "Title",
|
||||
"description": "Description",
|
||||
"campaign": "Campaign"
|
||||
"campaign": "Campaign",
|
||||
"targetLists": "Target Lists",
|
||||
"targetList": "Target List"
|
||||
},
|
||||
"links": {
|
||||
"opportunities": "Opportunities",
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create Lead": "Create Lead",
|
||||
"Create Contact": "Create Contact",
|
||||
"Create Task": "Create Task"
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@
|
||||
"Call": "Call",
|
||||
"Task": "Task",
|
||||
"Case": "Case",
|
||||
"InboundEmail": "Inbound Email",
|
||||
"Document": "Document",
|
||||
"Campaign": "Campaign",
|
||||
"TargetList": "Target List"
|
||||
@@ -26,7 +25,6 @@
|
||||
"Call": "Calls",
|
||||
"Task": "Tasks",
|
||||
"Case": "Cases",
|
||||
"InboundEmail": "Inbound Emails",
|
||||
"Document": "Documents",
|
||||
"Campaign": "Campaigns",
|
||||
"TargetList": "Target Lists"
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
"createdAccount": "Account",
|
||||
"createdContact": "Contact",
|
||||
"createdOpportunity": "Opportunity",
|
||||
"campaign": "Campaign"
|
||||
"campaign": "Campaign",
|
||||
"targetLists": "Target Lists",
|
||||
"targetList": "Target List"
|
||||
},
|
||||
"links": {
|
||||
"targetLists": "Target Lists",
|
||||
@@ -48,6 +50,7 @@
|
||||
}
|
||||
},
|
||||
"presetFilters": {
|
||||
"active": "Active"
|
||||
"active": "Active",
|
||||
"converted": "Converted"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,10 @@
|
||||
"Tentative": "Tentative"
|
||||
}
|
||||
},
|
||||
"massActions": {
|
||||
"setHeld": "Set Held",
|
||||
"setNotHeld": "Set Not Held"
|
||||
},
|
||||
"labels": {
|
||||
"Create Meeting": "Create Meeting",
|
||||
"Set Held": "Set Held",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user