mirror of
https://github.com/espocrm/espocrm.git
synced 2026-03-06 09:17:01 +00:00
Compare commits
291 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
667a46f141 | ||
|
|
67f65492de | ||
|
|
b6a98e7121 | ||
|
|
9669ff91bb | ||
|
|
acb6e245a2 | ||
|
|
b5e015e9c9 | ||
|
|
70d2e311e5 | ||
|
|
6c7e5c0d02 | ||
|
|
d4558d73b3 | ||
|
|
e2257f6cfd | ||
|
|
149fa41e2b | ||
|
|
71e4c2fca0 | ||
|
|
5a4613617c | ||
|
|
cbf9dd458e | ||
|
|
08553bdf9d | ||
|
|
d0b61b42e0 | ||
|
|
3e3348c4a7 | ||
|
|
c32b0f365b | ||
|
|
8fd0554714 | ||
|
|
982f0e1f62 | ||
|
|
c87f5dfab3 | ||
|
|
b335462aa4 | ||
|
|
97c951484d | ||
|
|
2215f15aaf | ||
|
|
65f38a4906 | ||
|
|
6429823cc3 | ||
|
|
2a71bb2ea1 | ||
|
|
1674c2221e | ||
|
|
e3b448f520 | ||
|
|
a04c973817 | ||
|
|
01c9939215 | ||
|
|
2d57824cb0 | ||
|
|
878385f14b | ||
|
|
8b82058d06 | ||
|
|
68e05f0935 | ||
|
|
cb7492c042 | ||
|
|
beb811755f | ||
|
|
7c7fc4ee0f | ||
|
|
aeef25f7ec | ||
|
|
6856ff97b1 | ||
|
|
10f6f7600c | ||
|
|
a0b678a3d9 | ||
|
|
f78e558a33 | ||
|
|
e205ef3370 | ||
|
|
8b6e4d469e | ||
|
|
a63ec2710b | ||
|
|
6895fac58c | ||
|
|
ea3c8f2d35 | ||
|
|
0f2c050537 | ||
|
|
2cd8866c73 | ||
|
|
86a5e19b55 | ||
|
|
61f435812d | ||
|
|
217d0f6540 | ||
|
|
f0e7a8f029 | ||
|
|
d2954483d9 | ||
|
|
999b88cba1 | ||
|
|
717df30063 | ||
|
|
d889c78f0c | ||
|
|
4737c506f2 | ||
|
|
78cb1a8052 | ||
|
|
dac8ca5a6d | ||
|
|
e04ac6778a | ||
|
|
5f34d4f2fd | ||
|
|
ca7c0f07e9 | ||
|
|
af26f29bec | ||
|
|
0c44f78ea1 | ||
|
|
bed62e2e71 | ||
|
|
6d61db86df | ||
|
|
4feb055256 | ||
|
|
10a44239ed | ||
|
|
8a78eda520 | ||
|
|
891b159b30 | ||
|
|
0d06770e80 | ||
|
|
f8675bd45c | ||
|
|
c35136b524 | ||
|
|
a0384deb00 | ||
|
|
e35fb15a31 | ||
|
|
fe86807091 | ||
|
|
e12a15ecdb | ||
|
|
24dcd46d6f | ||
|
|
15196f2062 | ||
|
|
1ae1b20111 | ||
|
|
84de477be0 | ||
|
|
97407de17d | ||
|
|
84bc5beed2 | ||
|
|
6974b1637d | ||
|
|
dc89aff7b1 | ||
|
|
2bfea69fe3 | ||
|
|
0e1e481546 | ||
|
|
52e938888d | ||
|
|
a2ef1656fb | ||
|
|
c168c3ff9b | ||
|
|
56af0baea2 | ||
|
|
35ecf2e144 | ||
|
|
d25692b15e | ||
|
|
59a66cb8fa | ||
|
|
75ce454b2a | ||
|
|
b94134a35a | ||
|
|
4b09f055e4 | ||
|
|
d743eca6a3 | ||
|
|
0e3c872310 | ||
|
|
f8b56cba24 | ||
|
|
b506cd726c | ||
|
|
998aaec170 | ||
|
|
4c30507a85 | ||
|
|
a55f1aca58 | ||
|
|
868cf4e22c | ||
|
|
2decd9016e | ||
|
|
9cba465473 | ||
|
|
b9344afb27 | ||
|
|
7074991771 | ||
|
|
b43d37ac79 | ||
|
|
18b393b286 | ||
|
|
728fce75d7 | ||
|
|
50d441aea0 | ||
|
|
d75f9e5acd | ||
|
|
3c96cf240e | ||
|
|
2583c77108 | ||
|
|
a3ad210ec2 | ||
|
|
6bd7d2398d | ||
|
|
017cd3d978 | ||
|
|
a3af86d248 | ||
|
|
99e9cbde84 | ||
|
|
85d60d2555 | ||
|
|
1fe4555209 | ||
|
|
8b80df2f91 | ||
|
|
3d7d4eb7db | ||
|
|
4215621eb7 | ||
|
|
d138a5d0b7 | ||
|
|
b3023192d0 | ||
|
|
7cc0c527e0 | ||
|
|
f3f36e87a4 | ||
|
|
b55b133ddf | ||
|
|
28eafdbc6c | ||
|
|
0036ab1ed2 | ||
|
|
a60378a9bd | ||
|
|
30b246f67c | ||
|
|
3a23b28657 | ||
|
|
42e21d585f | ||
|
|
a30ab9a1a0 | ||
|
|
4510295792 | ||
|
|
ed5de64cd3 | ||
|
|
1c89187c49 | ||
|
|
169a3f6e6d | ||
|
|
7e2ead7949 | ||
|
|
8413067194 | ||
|
|
81c7dcaa63 | ||
|
|
3b12c7f1cf | ||
|
|
cdab200898 | ||
|
|
0f9c3e1c1c | ||
|
|
fe5a5b76ca | ||
|
|
0e3720c038 | ||
|
|
99f1ba8987 | ||
|
|
8ff5d79788 | ||
|
|
9d6485194f | ||
|
|
21e306774e | ||
|
|
ffa340f255 | ||
|
|
d6b65edfb1 | ||
|
|
a3ed33a443 | ||
|
|
38ff477cef | ||
|
|
c5c638b007 | ||
|
|
181fd8dc73 | ||
|
|
e57f58bec3 | ||
|
|
5c2067f61a | ||
|
|
3ec5cf259b | ||
|
|
e5e898222b | ||
|
|
18b2876853 | ||
|
|
cec4ffcb6c | ||
|
|
1063aa74dd | ||
|
|
b59dba0e6d | ||
|
|
0d9a182833 | ||
|
|
8674f66b4d | ||
|
|
605a720694 | ||
|
|
aa761d5ef7 | ||
|
|
3d4d8aa7d3 | ||
|
|
556b72edb2 | ||
|
|
be372b90f9 | ||
|
|
846e93741f | ||
|
|
b82af3a0c6 | ||
|
|
02b429cb32 | ||
|
|
3332469c35 | ||
|
|
0a2469aaa4 | ||
|
|
e7e15a32bf | ||
|
|
fc3fa53dba | ||
|
|
4604f27176 | ||
|
|
b7b118c122 | ||
|
|
371f243a6d | ||
|
|
ea2934129a | ||
|
|
ba2d72dff9 | ||
|
|
7312988057 | ||
|
|
de12418a8f | ||
|
|
b4c7075331 | ||
|
|
355ec4398f | ||
|
|
2c681ede52 | ||
|
|
cb2df7b6a2 | ||
|
|
f2a5474b4a | ||
|
|
1fc8921a18 | ||
|
|
0458544bbb | ||
|
|
c09c4b2035 | ||
|
|
176c77ec96 | ||
|
|
7b032802e9 | ||
|
|
8a7a317252 | ||
|
|
3ef01a4639 | ||
|
|
e27edf5b0d | ||
|
|
fe0f5b3886 | ||
|
|
9836517c6c | ||
|
|
c143ba47d2 | ||
|
|
64a8ccf787 | ||
|
|
31eafca88f | ||
|
|
80e440c875 | ||
|
|
92451934af | ||
|
|
7e2ad2ae94 | ||
|
|
c410e47d6b | ||
|
|
7bb3780277 | ||
|
|
d734b8b3d2 | ||
|
|
2acc245100 | ||
|
|
fac477330c | ||
|
|
7993a65939 | ||
|
|
1285008af7 | ||
|
|
a67d43edbb | ||
|
|
d326925e06 | ||
|
|
13d65c7535 | ||
|
|
e5762b96d2 | ||
|
|
180983940e | ||
|
|
31f36caffa | ||
|
|
6f76efee36 | ||
|
|
44792d1a35 | ||
|
|
3f824be525 | ||
|
|
fbed072a80 | ||
|
|
f92da57b4d | ||
|
|
9059ce615f | ||
|
|
c13cc2a798 | ||
|
|
17bf3b017f | ||
|
|
9e04d2f2f0 | ||
|
|
98e998dc34 | ||
|
|
3155947795 | ||
|
|
fa6f471be9 | ||
|
|
865f87018a | ||
|
|
8da5ba8961 | ||
|
|
9842ebcc4a | ||
|
|
787d47c2aa | ||
|
|
ee3cbc2358 | ||
|
|
87caba2646 | ||
|
|
c45b614270 | ||
|
|
eccef0b92f | ||
|
|
f9b68fcbba | ||
|
|
776acd9b64 | ||
|
|
60b11cb11e | ||
|
|
defa3b5cfc | ||
|
|
f89ff39dbb | ||
|
|
6284b56718 | ||
|
|
5d78730dde | ||
|
|
bfba129846 | ||
|
|
b48bf2685c | ||
|
|
c5549000b4 | ||
|
|
fe88d10e35 | ||
|
|
4dd85eb97d | ||
|
|
245e99ef9f | ||
|
|
3478cf2d8c | ||
|
|
da1feee303 | ||
|
|
9fdd0b9a86 | ||
|
|
d4f2975f0d | ||
|
|
47ce2f587e | ||
|
|
0a25c0dbc2 | ||
|
|
7aeaa153ae | ||
|
|
5c4afa8a23 | ||
|
|
0a7e442194 | ||
|
|
6b8a05cd4e | ||
|
|
946a7a65f7 | ||
|
|
b68946375f | ||
|
|
463299c3ab | ||
|
|
34f81f4831 | ||
|
|
72ba8892b7 | ||
|
|
3ece40f9de | ||
|
|
f392c1da04 | ||
|
|
589b8f3210 | ||
|
|
ff6fd2698d | ||
|
|
6b22c8e370 | ||
|
|
340eb6d004 | ||
|
|
071e5fb85d | ||
|
|
a21469846b | ||
|
|
32ce8629a1 | ||
|
|
93be4a43d0 | ||
|
|
e21f5daa59 | ||
|
|
5cae7dff68 | ||
|
|
4cd08fc8ad | ||
|
|
c065b95f48 | ||
|
|
23d0620890 | ||
|
|
620510b6cd | ||
|
|
31690f2199 | ||
|
|
3972269738 |
@@ -4,5 +4,7 @@ RedirectMatch 403 \.config$
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteRule .* - [E=HTTP_ESPO_CGI_AUTH:%{HTTP:Authorization}]
|
||||
|
||||
RewriteRule reset/?$ reset.html [QSA,L]
|
||||
</IfModule>
|
||||
41
Gruntfile.js
41
Gruntfile.js
@@ -52,8 +52,7 @@ module.exports = function (grunt) {
|
||||
'frontend/client/lib/base64.js',
|
||||
'frontend/client/lib/jquery-ui.min.js',
|
||||
'frontend/client/lib/moment.min.js',
|
||||
'frontend/client/lib/moment-timezone.min.js',
|
||||
'frontend/client/lib/moment-timezone-data.js',
|
||||
'frontend/client/lib/moment-timezone-with-data.min.js',
|
||||
'frontend/client/lib/jquery.timepicker.min.js',
|
||||
'frontend/client/lib/jquery.autocomplete.js',
|
||||
'frontend/client/lib/bootstrap.min.js',
|
||||
@@ -88,9 +87,6 @@ module.exports = function (grunt) {
|
||||
'frontend/client/src/models/user.js',
|
||||
'frontend/client/src/models/preferences.js',
|
||||
'frontend/client/src/controllers/base.js',
|
||||
'frontend/client/src/controllers/record.js',
|
||||
'frontend/client/src/controllers/role.js',
|
||||
'frontend/client/src/controllers/admin.js',
|
||||
'frontend/client/src/view.js',
|
||||
'frontend/client/src/views/base.js',
|
||||
'frontend/client/src/views/login.js',
|
||||
@@ -134,6 +130,7 @@ module.exports = function (grunt) {
|
||||
'vendor/**',
|
||||
'bootstrap.php',
|
||||
'cron.php',
|
||||
'rebuild.php',
|
||||
'index.php',
|
||||
'LICENSE.txt',
|
||||
'.htaccess',
|
||||
@@ -146,9 +143,30 @@ module.exports = function (grunt) {
|
||||
dot: true,
|
||||
src: '**',
|
||||
cwd: 'build/tmp',
|
||||
dest: 'build/EspoCRM-<%= pkg.espoVersion %>/',
|
||||
dest: 'build/EspoCRM-<%= pkg.version %>/',
|
||||
},
|
||||
},
|
||||
chmod: {
|
||||
options: {
|
||||
mode: '755'
|
||||
},
|
||||
php: {
|
||||
options: {
|
||||
mode: '644'
|
||||
},
|
||||
src: [
|
||||
'build/EspoCRM-<%= pkg.version %>/**/*.php',
|
||||
'build/EspoCRM-<%= pkg.version %>/**/*.json',
|
||||
'build/EspoCRM-<%= pkg.version %>/**/*.config',
|
||||
'build/EspoCRM-<%= pkg.version %>/**/.htaccess',
|
||||
'build/EspoCRM-<%= pkg.version %>/client/**/*.js',
|
||||
'build/EspoCRM-<%= pkg.version %>/client/**/*.css',
|
||||
'build/EspoCRM-<%= pkg.version %>/client/**/*.tpl',
|
||||
'build/EspoCRM-<%= pkg.version %>/**/*.html',
|
||||
'build/EspoCRM-<%= pkg.version %>/**/*.txt',
|
||||
]
|
||||
}
|
||||
},
|
||||
replace: {
|
||||
timestamp: {
|
||||
options: {
|
||||
@@ -171,7 +189,7 @@ module.exports = function (grunt) {
|
||||
patterns: [
|
||||
{
|
||||
match: 'version',
|
||||
replacement: '<%= pkg.espoVersion %>'
|
||||
replacement: '<%= pkg.version %>'
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -186,12 +204,12 @@ module.exports = function (grunt) {
|
||||
compress: {
|
||||
final: {
|
||||
options: {
|
||||
archive: 'build/EspoCRM-<%= pkg.espoVersion %>.zip',
|
||||
archive: 'build/EspoCRM-<%= pkg.version %>.zip',
|
||||
mode: 'zip'
|
||||
},
|
||||
src: ['**'],
|
||||
cwd: 'build/EspoCRM-<%= pkg.espoVersion %>',
|
||||
dest: 'EspoCRM-<%= pkg.espoVersion %>'
|
||||
cwd: 'build/EspoCRM-<%= pkg.version %>',
|
||||
dest: 'EspoCRM-<%= pkg.version %>'
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -204,6 +222,7 @@ module.exports = function (grunt) {
|
||||
grunt.loadNpmTasks('grunt-contrib-copy');
|
||||
grunt.loadNpmTasks('grunt-replace');
|
||||
grunt.loadNpmTasks('grunt-contrib-compress');
|
||||
grunt.loadNpmTasks('grunt-chmod');
|
||||
|
||||
grunt.registerTask('default', [
|
||||
'clean:start',
|
||||
@@ -217,8 +236,8 @@ module.exports = function (grunt) {
|
||||
'copy:backend',
|
||||
'replace',
|
||||
'copy:final',
|
||||
'chmod',
|
||||
'clean:final',
|
||||
//'compress',
|
||||
]);
|
||||
|
||||
};
|
||||
|
||||
@@ -6,5 +6,7 @@ RewriteEngine On
|
||||
#
|
||||
# RewriteBase /
|
||||
|
||||
RewriteRule .* - [E=HTTP_ESPO_CGI_AUTH:%{HTTP:Authorization}]
|
||||
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [QSA,L]
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
namespace Espo\Controllers;
|
||||
|
||||
use \Espo\Core\Exceptions\BadRequest;
|
||||
|
||||
class App extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
public function actionUser()
|
||||
@@ -29,7 +31,20 @@ class App extends \Espo\Core\Controllers\Record
|
||||
return array(
|
||||
'user' => $this->getUser()->toArray(),
|
||||
'acl' => $this->getAcl()->toArray(),
|
||||
'preferences' => $this->getPreferences()->toArray()
|
||||
'preferences' => $this->getPreferences()->toArray(),
|
||||
'token' => $this->getUser()->get('token')
|
||||
);
|
||||
}
|
||||
|
||||
public function actionDestroyAuthToken($params, $data)
|
||||
{
|
||||
$token = $data['token'];
|
||||
if (empty($token)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$auth = new \Espo\Core\Utils\Auth($this->getContainer());
|
||||
return $auth->destroyAuthToken($token);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
66
application/Espo/Controllers/AuthToken.php
Normal file
66
application/Espo/Controllers/AuthToken.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 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\Controllers;
|
||||
|
||||
use \Espo\Core\Exceptions\Forbidden;
|
||||
|
||||
class AuthToken extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
protected function checkControllerAccess()
|
||||
{
|
||||
if (!$this->getUser()->isAdmin()) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
}
|
||||
|
||||
public function actionUpdate($params, $data)
|
||||
{
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
public function actionCreate($params, $data)
|
||||
{
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
public function actionListLinked($params, $data)
|
||||
{
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
public function actionMassUpdate($params, $data)
|
||||
{
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
public function actionCreateLink($params, $data)
|
||||
{
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
public function actionRemoveLink($params, $data)
|
||||
{
|
||||
throw new Forbidden();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,12 @@ class FieldManager extends \Espo\Core\Controllers\Base
|
||||
$fieldManager = $this->getContainer()->get('fieldManager');
|
||||
$fieldManager->create($data['name'], $data, $params['scope']);
|
||||
|
||||
$this->getContainer()->get('dataManager')->rebuild($params['scope']);
|
||||
try {
|
||||
$this->getContainer()->get('dataManager')->rebuild($params['scope']);
|
||||
} catch (Error $e) {
|
||||
$fieldManager->delete($data['name'], $params['scope']);
|
||||
throw new Error($e->getMessage());
|
||||
}
|
||||
|
||||
return $fieldManager->read($data['name'], $params['scope']);
|
||||
}
|
||||
|
||||
@@ -23,12 +23,27 @@
|
||||
namespace Espo\Controllers;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
use \Espo\Core\Exceptions\Forbidden;
|
||||
|
||||
class Settings extends \Espo\Core\Controllers\Base
|
||||
{
|
||||
public function actionRead($params, $data)
|
||||
protected function getConfigData()
|
||||
{
|
||||
return $this->getConfig()->getData($this->getUser()->isAdmin());
|
||||
$data = $this->getConfig()->getData($this->getUser()->isAdmin());
|
||||
|
||||
$fieldDefs = $this->getMetadata()->get('entityDefs.Settings.fields');
|
||||
|
||||
foreach ($fieldDefs as $field => $d) {
|
||||
if ($d['type'] == 'password') {
|
||||
unset($data[$field]);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function actionRead($params, $data)
|
||||
{
|
||||
return $this->getConfigData();
|
||||
}
|
||||
|
||||
public function actionUpdate($params, $data)
|
||||
@@ -38,11 +53,16 @@ class Settings extends \Espo\Core\Controllers\Base
|
||||
|
||||
public function actionPatch($params, $data)
|
||||
{
|
||||
$result = $this->getConfig()->setData($data, $this->getUser()->isAdmin());
|
||||
if ($result === false) {
|
||||
throw new Error('Cannot save settings');
|
||||
}
|
||||
if (!$this->getUser()->isAdmin()) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
return $this->getConfig()->getData($this->getUser()->isAdmin());
|
||||
$this->getConfig()->setData($data, $this->getUser()->isAdmin());
|
||||
$result = $this->getConfig()->save();
|
||||
if ($result === false) {
|
||||
throw new Error('Cannot save settings');
|
||||
}
|
||||
|
||||
return $this->getConfigData();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,4 +48,10 @@ class User extends \Espo\Core\Controllers\Record
|
||||
|
||||
return $acl->toArray();
|
||||
}
|
||||
|
||||
public function actionChangeOwnPassword($params, $data)
|
||||
{
|
||||
return $this->getService('User')->changePassword($this->getUser()->id, $data['password']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,8 @@ class Acl
|
||||
|
||||
if ($config && $config->get('useCache') && file_exists($this->cacheFile)) {
|
||||
$cached = include $this->cacheFile;
|
||||
$this->data = $cached;
|
||||
$this->initSolid();
|
||||
} else {
|
||||
$this->load();
|
||||
$this->initSolid();
|
||||
@@ -62,7 +64,6 @@ class Acl
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function checkScope($scope, $action = null, $isOwner = null, $inTeam = null)
|
||||
@@ -217,6 +218,11 @@ class Acl
|
||||
'edit' => 'no',
|
||||
'delete' => 'no',
|
||||
);
|
||||
$this->data['Note'] = array(
|
||||
'read' => 'all',
|
||||
'edit' => 'own',
|
||||
'delete' => 'own',
|
||||
);
|
||||
}
|
||||
|
||||
private function merge($tables)
|
||||
|
||||
@@ -129,6 +129,12 @@ class Application
|
||||
$cronManager->run();
|
||||
}
|
||||
|
||||
public function runRebuild()
|
||||
{
|
||||
$dataManager = $this->getContainer()->get('dataManager');
|
||||
$dataManager->rebuild();
|
||||
}
|
||||
|
||||
public function isInstalled()
|
||||
{
|
||||
$config = $this->getContainer()->get('config');
|
||||
|
||||
@@ -76,9 +76,7 @@ class Container
|
||||
private function loadFileManager()
|
||||
{
|
||||
return new \Espo\Core\Utils\File\Manager(
|
||||
array(
|
||||
'defaultPermissions' => $this->get('config')->get('defaultPermissions'),
|
||||
)
|
||||
$this->get('config')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,13 +38,17 @@ class Record extends Base
|
||||
return $this->getContainer()->get('entityManager');
|
||||
}
|
||||
|
||||
protected function getRecordService()
|
||||
protected function getRecordService($name = null)
|
||||
{
|
||||
if ($this->getServiceFactory()->checkExists($this->name)) {
|
||||
$service = $this->getServiceFactory()->create($this->name);
|
||||
if (empty($name)) {
|
||||
$name = $this->name;
|
||||
}
|
||||
|
||||
if ($this->getServiceFactory()->checkExists($name)) {
|
||||
$service = $this->getServiceFactory()->create($name);
|
||||
} else {
|
||||
$service = $this->getServiceFactory()->create('Record');
|
||||
$service->setEntityName($this->name);
|
||||
$service->setEntityName($name);
|
||||
}
|
||||
|
||||
return $service;
|
||||
@@ -178,8 +182,10 @@ class Record extends Base
|
||||
}
|
||||
|
||||
public function actionExport($params, $data, $request)
|
||||
{
|
||||
// TODO move to service
|
||||
{
|
||||
if ($this->getConfig()->get('disableExport') && !$this->getUser()->isAdmin()) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
if (!$this->getAcl()->check($this->name, 'read')) {
|
||||
throw new Forbidden();
|
||||
|
||||
@@ -44,7 +44,7 @@ class DataManager
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function rebuild($entityList = array())
|
||||
public function rebuild($entityList = null)
|
||||
{
|
||||
$result = $this->clearCache();
|
||||
|
||||
@@ -78,7 +78,7 @@ class DataManager
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function rebuildDatabase($entityList = array())
|
||||
public function rebuildDatabase($entityList = null)
|
||||
{
|
||||
try {
|
||||
$result = $this->getContainer()->get('schema')->rebuild($entityList);
|
||||
|
||||
@@ -31,7 +31,9 @@ class Person extends \Espo\Core\ORM\Entity
|
||||
$this->setValue('lastName', $value);
|
||||
|
||||
$firstName = $this->get('firstName');
|
||||
if (!empty($firstName)) {
|
||||
if (empty($firstName)) {
|
||||
$this->setValue('name', $value);
|
||||
} else {
|
||||
$this->setValue('name', $firstName . ' ' . $value);
|
||||
}
|
||||
}
|
||||
@@ -41,7 +43,9 @@ class Person extends \Espo\Core\ORM\Entity
|
||||
$this->setValue('firstName', $value);
|
||||
|
||||
$lastName = $this->get('lastName');
|
||||
if (!empty($lastName)) {
|
||||
if (empty($lastName)) {
|
||||
$this->setValue('name', $value);
|
||||
} else {
|
||||
$this->setValue('name', $value . ' ' . $lastName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ class EntityManager
|
||||
|
||||
$params = array(
|
||||
'host' => $config->get('database.host'),
|
||||
'port' => $config->get('database.port'),
|
||||
'dbname' => $config->get('database.dbname'),
|
||||
'user' => $config->get('database.user'),
|
||||
'password' => $config->get('database.password'),
|
||||
|
||||
@@ -24,19 +24,39 @@ namespace Espo\Core\ORM;
|
||||
|
||||
class Entity extends \Espo\ORM\Entity
|
||||
{
|
||||
public function loadLinkMultipleField($field)
|
||||
public function loadLinkMultipleField($field, $columns = null)
|
||||
{
|
||||
if ($this->hasRelation($field) && $this->hasField($field . 'Ids')) {
|
||||
$collection = $this->get($field);
|
||||
|
||||
$defs = array();
|
||||
if (!empty($columns)) {
|
||||
$defs['additionalColumns'] = $columns;
|
||||
}
|
||||
|
||||
$collection = $this->get($field, $defs);
|
||||
$ids = array();
|
||||
$names = new \stdClass();
|
||||
$names = new \stdClass();
|
||||
if (!empty($columns)) {
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->set($field . 'Ids', $ids);
|
||||
$this->set($field . 'Names', $names);
|
||||
if (!empty($columns)) {
|
||||
$this->set($field . 'Columns', $columnsData);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,12 @@ class EntityManager extends \Espo\ORM\EntityManager
|
||||
public function getUser()
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
}
|
||||
|
||||
public function getEspoMetadata()
|
||||
{
|
||||
return $this->espoMetadata;
|
||||
}
|
||||
|
||||
public function setEspoMetadata($espoMetadata)
|
||||
{
|
||||
|
||||
@@ -59,16 +59,15 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
|
||||
return $this->getInjection('metadata');
|
||||
}
|
||||
|
||||
protected function handleSelectParams(&$params, $entityName = false)
|
||||
public function handleSelectParams(&$params)
|
||||
{
|
||||
$this->handleEmailAddressParams($params, $entityName);
|
||||
$this->handleEmailAddressParams($params);
|
||||
$this->handlePhoneNumberParams($params);
|
||||
}
|
||||
|
||||
protected function handleEmailAddressParams(&$params, $entityName = false)
|
||||
protected function handleEmailAddressParams(&$params)
|
||||
{
|
||||
if (empty($entityName)) {
|
||||
$entityName = $this->entityName;
|
||||
}
|
||||
$entityName = $this->entityName;
|
||||
|
||||
$defs = $this->getEntityManager()->getMetadata()->get($entityName);
|
||||
if (!empty($defs['relations']) && array_key_exists('emailAddresses', $defs['relations'])) {
|
||||
@@ -81,11 +80,31 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
|
||||
if (empty($params['joinConditions'])) {
|
||||
$params['joinConditions'] = array();
|
||||
}
|
||||
$params['leftJoins'] = array('emailAddresses');
|
||||
$params['joinConditions'] = array(
|
||||
'emailAddresses' => array(
|
||||
'primary' => 1
|
||||
)
|
||||
$params['leftJoins'][] = 'emailAddresses';
|
||||
$params['joinConditions']['emailAddresses'] = array(
|
||||
'primary' => 1
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected function handlePhoneNumberParams(&$params)
|
||||
{
|
||||
$entityName = $this->entityName;
|
||||
|
||||
$defs = $this->getEntityManager()->getMetadata()->get($entityName);
|
||||
if (!empty($defs['relations']) && array_key_exists('phoneNumbers', $defs['relations'])) {
|
||||
if (empty($params['leftJoins'])) {
|
||||
$params['leftJoins'] = array();
|
||||
}
|
||||
if (empty($params['whereClause'])) {
|
||||
$params['whereClause'] = array();
|
||||
}
|
||||
if (empty($params['joinConditions'])) {
|
||||
$params['joinConditions'] = array();
|
||||
}
|
||||
$params['leftJoins'][] = 'phoneNumbers';
|
||||
$params['joinConditions']['phoneNumbers'] = array(
|
||||
'primary' => 1
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -172,56 +191,23 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
|
||||
$entity->set($restoreData);
|
||||
|
||||
$this->handleEmailAddressSave($entity);
|
||||
$this->handlePhoneNumberSave($entity);
|
||||
$this->handleSpecifiedRelations($entity);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function handleEmailAddressSave(Entity $entity)
|
||||
{
|
||||
if ($entity->hasRelation('emailAddresses') && $entity->hasField('emailAddress')) {
|
||||
$email = $entity->get('emailAddress');
|
||||
$pdo = $this->getPDO();
|
||||
|
||||
$emailAddressRepository = $this->getEntityManager()->getRepository('EmailAddress');
|
||||
|
||||
if (!empty($email)) {
|
||||
if ($email != $entity->getFetched('emailAddress')) {
|
||||
|
||||
$emailAddressNew = $emailAddressRepository->where(array('lower' => strtolower($email)))->findOne();
|
||||
$isNewEmailAddress = false;
|
||||
if (!$emailAddressNew) {
|
||||
$emailAddressNew = $emailAddressRepository->get();
|
||||
$emailAddressNew->set('name', $email);
|
||||
$emailAddressRepository->save($emailAddressNew);
|
||||
$isNewEmailAddress = true;
|
||||
}
|
||||
|
||||
$emailOld = $entity->getFetched('emailAddress');
|
||||
if (!empty($emailOld)) {
|
||||
$emailAddressOld = $emailAddressRepository->where(array('lower' => strtolower($emailOld)))->findOne();
|
||||
$this->unrelate($entity, 'emailAddresses', $emailAddressOld);
|
||||
}
|
||||
$this->relate($entity, 'emailAddresses', $emailAddressNew);
|
||||
|
||||
$query = "
|
||||
UPDATE entity_email_address
|
||||
SET `primary` = 1
|
||||
WHERE
|
||||
entity_id = ".$pdo->quote($entity->id)." AND
|
||||
entity_type = ".$pdo->quote($this->entityName)." AND
|
||||
email_address_id = ".$pdo->quote($emailAddressNew->id)."
|
||||
";
|
||||
$sth = $pdo->prepare($query);
|
||||
$sth->execute();
|
||||
}
|
||||
} else {
|
||||
$emailOld = $entity->getFetched('emailAddress');
|
||||
if (!empty($emailOld)) {
|
||||
$emailAddressOld = $emailAddressRepository->where(array('lower' => strtolower($emailOld)))->findOne();
|
||||
$this->unrelate($entity, 'emailAddresses', $emailAddressOld);
|
||||
}
|
||||
}
|
||||
{
|
||||
if ($entity->hasRelation('emailAddresses') && $entity->hasField('emailAddress')) {
|
||||
$emailAddressRepository = $this->getEntityManager()->getRepository('EmailAddress')->storeEntityEmailAddress($entity);
|
||||
}
|
||||
}
|
||||
|
||||
protected function handlePhoneNumberSave(Entity $entity)
|
||||
{
|
||||
if ($entity->hasRelation('phoneNumbers') && $entity->hasField('phoneNumber')) {
|
||||
$emailAddressRepository = $this->getEntityManager()->getRepository('PhoneNumber')->storeEntityPhoneNumber($entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,22 +222,60 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
|
||||
if (is_array($specifiedIds)) {
|
||||
$toRemoveIds = array();
|
||||
$existingIds = array();
|
||||
foreach ($entity->get($name) as $foreignEntity) {
|
||||
$toUpdateIds = array();
|
||||
$existingColumnsData = new \stdClass();
|
||||
|
||||
$defs = array();
|
||||
$columns = $this->getMetadata()->get("entityDefs." . $entity->getEntityName() . ".fields.{$name}.columns");
|
||||
if (!empty($columns)) {
|
||||
$columnData = $entity->get($name . 'Columns');
|
||||
$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);
|
||||
}
|
||||
$existingColumnsData->$foreignId = $data;
|
||||
}
|
||||
|
||||
}
|
||||
foreach ($existingIds as $id) {
|
||||
if (!in_array($id, $specifiedIds)) {
|
||||
$toRemoveIds[] = $id;
|
||||
} else {
|
||||
if (!empty($columns)) {
|
||||
foreach ($columns as $columnName => $columnField) {
|
||||
if ($columnData->$id->$columnName != $existingColumnsData->$id->$columnName) {
|
||||
$toUpdateIds[] = $id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($specifiedIds as $id) {
|
||||
if (!in_array($id, $existingIds)) {
|
||||
$this->relate($entity, $name, $id);
|
||||
$data = null;
|
||||
if (!empty($columns)) {
|
||||
$data = $columnData->$id;
|
||||
}
|
||||
$this->relate($entity, $name, $id, $data);
|
||||
}
|
||||
}
|
||||
foreach ($toRemoveIds as $id) {
|
||||
$this->unrelate($entity, $name, $id);
|
||||
}
|
||||
if (!empty($columns)) {
|
||||
foreach ($toUpdateIds as $id) {
|
||||
$data = $columnData->$id;
|
||||
$this->updateRelation($entity, $name, $id, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,11 @@ class Base
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function getTextFilterFields()
|
||||
{
|
||||
return $this->metadata->get("entityDefs.{$this->entityName}.collection.textFilterFields", array('name'));
|
||||
}
|
||||
|
||||
protected function where($params, &$result)
|
||||
{
|
||||
@@ -96,6 +101,18 @@ class Base
|
||||
$params['where'][] = $p;
|
||||
}
|
||||
}
|
||||
} else if ($item['type'] == 'textFilter' && !empty($item['value'])) {
|
||||
if (!empty($item['value'])) {
|
||||
if (empty($result['whereClause'])) {
|
||||
$result['whereClause'] = array();
|
||||
}
|
||||
$fieldList = $this->getTextFilterFields();
|
||||
$d = array();
|
||||
foreach ($fieldList as $field) {
|
||||
$d[$field . '*'] = $item['value'] . '%';
|
||||
}
|
||||
$where['OR'] = $d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +125,7 @@ class Base
|
||||
$where[] = $part;
|
||||
}
|
||||
} else {
|
||||
if ($item['type'] == 'linkedWith') {
|
||||
if ($item['type'] == 'linkedWith' && !empty($item['value'])) {
|
||||
$linkedWith[$item['field']] = $item['value'];
|
||||
}
|
||||
}
|
||||
@@ -255,6 +272,15 @@ class Base
|
||||
case 'isFalse':
|
||||
$part[$item['field'] . '='] = false;
|
||||
break;
|
||||
case 'today':
|
||||
$part[$item['field'] . '='] = date('Y-m-d');
|
||||
break;
|
||||
case 'past':
|
||||
$part[$item['field'] . '<'] = date('Y-m-d');
|
||||
break;
|
||||
case 'future':
|
||||
$part[$item['field'] . '>'] = date('Y-m-d');
|
||||
break;
|
||||
case 'between':
|
||||
if (is_array($item['value'])) {
|
||||
$part['AND'] = array(
|
||||
@@ -269,7 +295,7 @@ class Base
|
||||
return $part;
|
||||
}
|
||||
|
||||
protected function getBoolFilterWhere($filterName, $entityName)
|
||||
protected function getBoolFilterWhere($filterName)
|
||||
{
|
||||
$method = 'getBoolFilterWhere' . ucfirst($filterName);
|
||||
if (method_exists($this, $method)) {
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
namespace Espo\Core;
|
||||
|
||||
use Espo\Core\Exceptions\Error;
|
||||
|
||||
class UpgradeManager extends Upgrades\Base
|
||||
{
|
||||
protected $packagePath = 'data/upload/upgrades';
|
||||
@@ -31,6 +33,4 @@ class UpgradeManager extends Upgrades\Base
|
||||
'after' => 'AfterUpgrade',
|
||||
);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -255,7 +255,7 @@ abstract class Base
|
||||
return;
|
||||
}
|
||||
|
||||
$beforeInstallScript = Util::concatPath( array($upgradePath, $this->paths['scripts'], $scriptName) );
|
||||
$beforeInstallScript = Util::concatPath( array($upgradePath, $this->paths['scripts'], $scriptName) ) . '.php';
|
||||
|
||||
if (file_exists($beforeInstallScript)) {
|
||||
require_once($beforeInstallScript);
|
||||
@@ -316,7 +316,13 @@ abstract class Base
|
||||
{
|
||||
if (!isset($this->data['manifest'])) {
|
||||
$upgradePath = $this->getUpgradePath();
|
||||
$manifestJson = $this->getFileManager()->getContents(array($upgradePath, $this->manifestName));
|
||||
|
||||
$manifestPath = Util::concatPath($upgradePath, $this->manifestName);
|
||||
if (!file_exists($manifestPath)) {
|
||||
throw new Error('It\'s not an uprgade package.');
|
||||
}
|
||||
|
||||
$manifestJson = $this->getFileManager()->getContents($manifestPath);
|
||||
$this->data['manifest'] = Json::decode($manifestJson, true);
|
||||
|
||||
if (!$this->data['manifest']) {
|
||||
@@ -375,6 +381,9 @@ abstract class Base
|
||||
$manifest = $this->getManifest();
|
||||
|
||||
$res = $this->getConfig()->set('version', $manifest['version']);
|
||||
if (method_exists($this->getConfig(), 'save')) {
|
||||
$res = $this->getConfig()->save();
|
||||
}
|
||||
$res &= $this->getContainer()->get('dataManager')->rebuild();
|
||||
|
||||
return $res;
|
||||
|
||||
@@ -51,9 +51,12 @@ class Auth extends \Slim\Middleware
|
||||
|
||||
$espoAuth = $req->headers('HTTP_ESPO_AUTHORIZATION');
|
||||
if (isset($espoAuth)) {
|
||||
$credentials = explode(':', base64_decode($espoAuth));
|
||||
$authUsername = $credentials[0];
|
||||
$authPassword = $credentials[1];
|
||||
list($authUsername, $authPassword) = explode(':', base64_decode($espoAuth));
|
||||
}
|
||||
|
||||
$espoCgiAuth = $req->headers('HTTP_ESPO_CGI_AUTH');
|
||||
if ( !isset($authUsername) && !isset($authPassword) && isset($espoCgiAuth) ) {
|
||||
list($authUsername, $authPassword) = explode(':' , base64_decode(substr($espoCgiAuth, 6)));
|
||||
}
|
||||
|
||||
if (is_null($this->authRequired)) {
|
||||
|
||||
@@ -18,52 +18,93 @@
|
||||
*
|
||||
* 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;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
|
||||
class Auth
|
||||
class Auth
|
||||
{
|
||||
protected $container;
|
||||
|
||||
|
||||
protected $authentication;
|
||||
|
||||
protected $config;
|
||||
|
||||
protected $entityManager;
|
||||
|
||||
public function __construct(\Espo\Core\Container $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
|
||||
$this->entityManager = $this->container->get('entityManager');
|
||||
$this->config = $this->container->get('config');
|
||||
|
||||
$authenticationMethod = $this->config->get('authenticationMethod', 'Espo');
|
||||
$authenticationClassName = "\\Espo\\Core\\Utils\\Authentication\\" . $authenticationMethod;
|
||||
$this->authentication = new $authenticationClassName($this->config, $this->entityManager, $this);
|
||||
}
|
||||
|
||||
|
||||
public function useNoAuth($isAdmin = false)
|
||||
{
|
||||
$entityManager = $this->container->get('entityManager');
|
||||
|
||||
$entityManager = $this->container->get('entityManager');
|
||||
|
||||
$user = $entityManager->getRepository('User')->get('system');
|
||||
$user->set('isAdmin', $isAdmin);
|
||||
$user->set('isAdmin', $isAdmin);
|
||||
if (!$user) {
|
||||
throw new Error('System user is not found');
|
||||
throw new Error('System user is not found');
|
||||
}
|
||||
|
||||
$entityManager->setUser($user);
|
||||
$this->container->setUser($user);
|
||||
}
|
||||
|
||||
|
||||
public function login($username, $password)
|
||||
{
|
||||
$GLOBALS['log']->debug('AUTH: Try to authenticate');
|
||||
|
||||
$entityManager = $this->container->get('entityManager');
|
||||
|
||||
$user = $entityManager->getRepository('User')->findOne(array(
|
||||
'whereClause' => array(
|
||||
'userName' => $username,
|
||||
'password' => md5($password)
|
||||
),
|
||||
));
|
||||
|
||||
if ($user instanceof \Espo\Entities\User) {
|
||||
|
||||
$entityManager = $this->entityManager;
|
||||
|
||||
$authToken = $entityManager->getRepository('AuthToken')->where(array('token' => $password))->findOne();
|
||||
|
||||
$user = $this->authentication->login($username, $password, $authToken);
|
||||
|
||||
if ($user) {
|
||||
$entityManager->setUser($user);
|
||||
$this->container->setUser($user);
|
||||
$GLOBALS['log']->debug('AUTH: Result of authenticate is [true]');
|
||||
|
||||
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'));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected function createToken($user)
|
||||
{
|
||||
return md5(uniqid($user->get('id')));
|
||||
}
|
||||
|
||||
public function destroyAuthToken($token)
|
||||
{
|
||||
$entityManager = $this->container->get('entityManager');
|
||||
|
||||
$authToken = $entityManager->getRepository('AuthToken')->where(array('token' => $token))->findOne();
|
||||
if ($authToken) {
|
||||
$entityManager->removeEntity($authToken);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,18 +20,41 @@
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
ob_start();
|
||||
$result = array('success' => true, 'errorMsg' => '');
|
||||
namespace Espo\Core\Utils\Authentication;
|
||||
|
||||
use \Espo\Core\Utils\Config;
|
||||
use \Espo\Core\ORM\EntityManager;
|
||||
use \Espo\Core\Utils\Auth;
|
||||
|
||||
abstract class Base
|
||||
{
|
||||
private $config;
|
||||
|
||||
private $entityManager;
|
||||
|
||||
private $auth;
|
||||
|
||||
public function __construct(Config $config, EntityManager $entityManager, Auth $auth)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->entityManager = $entityManager;
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
protected function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
protected function getEntityManager()
|
||||
{
|
||||
return $this->entityManager;
|
||||
}
|
||||
|
||||
protected function getAuth()
|
||||
{
|
||||
return $this->auth;
|
||||
}
|
||||
|
||||
if (!$installer->isWritable()) {
|
||||
$result['success'] = false;
|
||||
$urls = $installer->getLastWritableError();
|
||||
foreach ($urls as &$url) {
|
||||
$url = ' '.$url;
|
||||
}
|
||||
$result['errorMsg'] = $langs['messages']['Permission denied to files'].':<br>'.implode('<br>', $urls);
|
||||
$result['errorFixInstruction'] = $systemHelper->getPermissionCommands('', array('644', '755'));
|
||||
}
|
||||
|
||||
ob_clean();
|
||||
echo json_encode($result);
|
||||
48
application/Espo/Core/Utils/Authentication/Espo.php
Normal file
48
application/Espo/Core/Utils/Authentication/Espo.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 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\Authentication;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
|
||||
class Espo extends Base
|
||||
{
|
||||
|
||||
public function login($username, $password, \Espo\Entities\AuthToken $authToken = null)
|
||||
{
|
||||
if ($authToken) {
|
||||
$hash = $authToken->get('hash');
|
||||
} else {
|
||||
$hash = md5($password);
|
||||
}
|
||||
|
||||
$user = $this->getEntityManager()->getRepository('User')->findOne(array(
|
||||
'whereClause' => array(
|
||||
'userName' => $username,
|
||||
'password' => $hash
|
||||
),
|
||||
));
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
|
||||
201
application/Espo/Core/Utils/Authentication/LDAP.php
Normal file
201
application/Espo/Core/Utils/Authentication/LDAP.php
Normal file
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 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\Authentication;
|
||||
|
||||
use Espo\Core\Exceptions\Error,
|
||||
Espo\Core\Utils\Config,
|
||||
Espo\Core\ORM\EntityManager,
|
||||
Espo\Core\Utils\Auth;
|
||||
|
||||
class LDAP extends Base
|
||||
{
|
||||
private $utils;
|
||||
|
||||
private $zendLdap;
|
||||
|
||||
/**
|
||||
* Espo => LDAP name
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $fields = array(
|
||||
'userName' => 'cn',
|
||||
'firstName' => 'givenname',
|
||||
'lastName' => 'sn',
|
||||
'title' => 'title',
|
||||
'emailAddress' => 'mail',
|
||||
'phoneNumber' => 'telephonenumber',
|
||||
);
|
||||
|
||||
public function __construct(Config $config, EntityManager $entityManager, Auth $auth)
|
||||
{
|
||||
parent::__construct($config, $entityManager, $auth);
|
||||
|
||||
$this->zendLdap = new LDAP\LDAP();
|
||||
$this->utils = new LDAP\Utils($config);
|
||||
}
|
||||
|
||||
protected function getZendLdap()
|
||||
{
|
||||
return $this->zendLdap;
|
||||
}
|
||||
|
||||
protected function getUtils()
|
||||
{
|
||||
return $this->utils;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* LDAP login
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param \Espo\Entities\AuthToken $authToken
|
||||
* @return \Espo\Entities\User | null
|
||||
*/
|
||||
public function login($username, $password, \Espo\Entities\AuthToken $authToken = null)
|
||||
{
|
||||
if ($authToken) {
|
||||
return $this->loginByToken($username, $authToken);
|
||||
}
|
||||
|
||||
$options = $this->getUtils()->getZendOptions();
|
||||
|
||||
$ldap = $this->getZendLdap();
|
||||
$ldap = $ldap->setOptions($options);
|
||||
|
||||
try {
|
||||
$ldap->bind($username, $password);
|
||||
|
||||
$dn = $ldap->getDn($username);
|
||||
|
||||
$loginFilter = $this->getUtils()->getOption('userLoginFilter');
|
||||
$userData = $ldap->searchByLoginFilter($loginFilter, $dn, 3);
|
||||
|
||||
} catch (\Zend\Ldap\Exception\LdapException $zle) {
|
||||
|
||||
$admin = $this->adminLogin($username, $password);
|
||||
if (!isset($admin)) {
|
||||
$GLOBALS['log']->info('LDAP Authentication: ' . $zle->getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
$GLOBALS['log']->info('LDAP Authentication: Administrator login by username ['.$username.']');
|
||||
}
|
||||
|
||||
$user = $this->getEntityManager()->getRepository('User')->findOne(array(
|
||||
'whereClause' => array(
|
||||
'userName' => $username,
|
||||
),
|
||||
));
|
||||
|
||||
$isCreateUser = $this->getUtils()->getOption('createEspoUser');
|
||||
if (!isset($user) && $isCreateUser) {
|
||||
$this->getAuth()->useNoAuth(); /** Required to fix Acl "isFetched()" error */
|
||||
$user = $this->createUser($userData);
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Login by authorization token
|
||||
*
|
||||
* @param string $username
|
||||
* @param \Espo\Entities\AuthToken $authToken
|
||||
* @return \Espo\Entities\User | null
|
||||
*/
|
||||
protected function loginByToken($username, \Espo\Entities\AuthToken $authToken = null)
|
||||
{
|
||||
if (!isset($authToken)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$userId = $authToken->get('userId');
|
||||
$user = $this->getEntityManager()->getEntity('User', $userId);
|
||||
|
||||
$tokenUsername = $user->get('userName');
|
||||
if ($username != $tokenUsername) {
|
||||
$GLOBALS['log']->alert('Unauthorized access attempt for user ['.$username.'] from IP ['.$_SERVER['REMOTE_ADDR'].']');
|
||||
return null;
|
||||
}
|
||||
|
||||
$user = $this->getEntityManager()->getRepository('User')->findOne(array(
|
||||
'whereClause' => array(
|
||||
'userName' => $username,
|
||||
),
|
||||
));
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Login user with administrator rights
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @return \Espo\Entities\User | null
|
||||
*/
|
||||
protected function adminLogin($username, $password)
|
||||
{
|
||||
$hash = md5($password);
|
||||
|
||||
$user = $this->getEntityManager()->getRepository('User')->findOne(array(
|
||||
'whereClause' => array(
|
||||
'userName' => $username,
|
||||
'password' => $hash,
|
||||
'isAdmin' => 1
|
||||
),
|
||||
));
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Espo user with data gets from LDAP server
|
||||
*
|
||||
* @param array $userData LDAP entity data
|
||||
* @return \Espo\Entities\User
|
||||
*/
|
||||
protected function createUser(array $userData)
|
||||
{
|
||||
$data = array();
|
||||
foreach ($this->fields as $espo => $ldap) {
|
||||
if (isset($userData[$ldap][0])) {
|
||||
$data[$espo] = $userData[$ldap][0];
|
||||
}
|
||||
}
|
||||
|
||||
$user = $this->getEntityManager()->getEntity('User');
|
||||
$user->set($data);
|
||||
|
||||
$this->getEntityManager()->saveEntity($user);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
123
application/Espo/Core/Utils/Authentication/LDAP/LDAP.php
Normal file
123
application/Espo/Core/Utils/Authentication/LDAP/LDAP.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 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\Authentication\LDAP;
|
||||
|
||||
class LDAP extends \Zend\Ldap\Ldap
|
||||
{
|
||||
protected $usernameAttribute = 'cn';
|
||||
|
||||
|
||||
/**
|
||||
* Get DN depends on options, ex. "cn=test,ou=People,dc=maxcrc,dc=com"
|
||||
*
|
||||
* @return string DN format
|
||||
*/
|
||||
public function getDn($acctname)
|
||||
{
|
||||
return $this->getAccountDn($acctname, \Zend\Ldap\Ldap::ACCTNAME_FORM_DN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix a bug, ex. CN=Alice Baker,CN=Users,DC=example,DC=com
|
||||
*
|
||||
* @param string $acctname
|
||||
* @return string - Account DN
|
||||
*/
|
||||
protected function getAccountDn($acctname)
|
||||
{
|
||||
$baseDn = $this->getBaseDn();
|
||||
|
||||
if ($this->getBindRequiresDn() && isset($baseDn)) {
|
||||
try {
|
||||
return parent::getAccountDn($acctname);
|
||||
} catch (\Zend\Ldap\Exception\LdapException $zle) {
|
||||
if ($zle->getCode() != \Zend\Ldap\Exception\LdapException::LDAP_NO_SUCH_OBJECT) {
|
||||
throw $zle;
|
||||
}
|
||||
}
|
||||
|
||||
$acctname = $this->usernameAttribute . '=' . \Zend\Ldap\Filter\AbstractFilter::escapeValue($acctname) . ',' . $baseDn;
|
||||
}
|
||||
|
||||
return parent::getAccountDn($acctname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search a user using userLoginFilter
|
||||
*
|
||||
* @param string $filter
|
||||
* @param string $basedn
|
||||
* @param int $scope
|
||||
* @param array $attributes
|
||||
* @return array
|
||||
*/
|
||||
public function searchByLoginFilter($filter, $basedn = null, $scope = self::SEARCH_SCOPE_SUB, array $attributes = array())
|
||||
{
|
||||
$filter = $this->getLoginFilter($filter);
|
||||
|
||||
$result = $this->search($filter, $basedn, $scope, $attributes);
|
||||
|
||||
if ($result->count() > 0) {
|
||||
return $result->getFirst();
|
||||
}
|
||||
|
||||
throw new \Zend\Ldap\Exception\LdapException($this, 'searching: ' . $filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get login filter in LDAP format
|
||||
*
|
||||
* @param string $filter
|
||||
* @return string
|
||||
*/
|
||||
protected function getLoginFilter($filter)
|
||||
{
|
||||
$baseFilter = '(objectClass=*)';
|
||||
|
||||
if (!empty($filter)) {
|
||||
$baseFilter = '(&' . $baseFilter . $this->convertToFilterFormat($filter). ')';
|
||||
}
|
||||
|
||||
return $baseFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check and convert filter item in LDAP format
|
||||
*
|
||||
* @param string $filter [description]
|
||||
* @return string
|
||||
*/
|
||||
protected function convertToFilterFormat($filter)
|
||||
{
|
||||
$filter = trim($filter);
|
||||
if (substr($filter, 0, 1) != '(') {
|
||||
$filter = '(' . $filter;
|
||||
}
|
||||
|
||||
if (substr($filter, -1) != ')') {
|
||||
$filter = $filter . ')';
|
||||
}
|
||||
|
||||
return $filter;
|
||||
}
|
||||
}
|
||||
155
application/Espo/Core/Utils/Authentication/LDAP/Utils.php
Normal file
155
application/Espo/Core/Utils/Authentication/LDAP/Utils.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 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\Authentication\LDAP;
|
||||
|
||||
use \Espo\Core\Utils\Config;
|
||||
|
||||
class Utils
|
||||
{
|
||||
private $config;
|
||||
|
||||
protected $options = null;
|
||||
|
||||
/**
|
||||
* Association between LDAP and Espo fields
|
||||
* @var array
|
||||
*/
|
||||
protected $fieldMap = array(
|
||||
'host' => 'ldapHost',
|
||||
'port' => 'ldapPort',
|
||||
'useSsl' => 'ldapSecurity',
|
||||
'useStartTls' => 'ldapSecurity',
|
||||
'username' => 'ldapUsername',
|
||||
'password' => 'ldapPassword',
|
||||
'bindRequiresDn' => 'ldapBindRequiresDn',
|
||||
'baseDn' => 'ldapBaseDn',
|
||||
'accountCanonicalForm' => 'ldapAccountCanonicalForm',
|
||||
'accountDomainName' => 'ldapAccountDomainName',
|
||||
'accountDomainNameShort' => 'ldapAccountDomainNameShort',
|
||||
'accountFilterFormat' => 'ldapAccountFilterFormat',
|
||||
'optReferrals' => 'ldapOptReferrals',
|
||||
'tryUsernameSplit' => 'ldapTryUsernameSplit',
|
||||
'networkTimeout' => 'ldapNetworkTimeout',
|
||||
'createEspoUser' => 'ldapCreateEspoUser',
|
||||
'userLoginFilter' => 'ldapUserLoginFilter',
|
||||
);
|
||||
|
||||
/**
|
||||
* Permitted Espo Options
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $permittedEspoOptions = array(
|
||||
'createEspoUser' => false,
|
||||
'userLoginFilter' => null,
|
||||
);
|
||||
|
||||
/**
|
||||
* accountCanonicalForm Map between Espo and Zend value
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $accountCanonicalFormMap = array(
|
||||
'Dn' => 1,
|
||||
'Username' => 2,
|
||||
'Backslash' => 3,
|
||||
'Principal' => 4,
|
||||
);
|
||||
|
||||
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
protected function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Options from espo config according to $this->fieldMap
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
if (isset($this->options)) {
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
$options = array();
|
||||
foreach ($this->fieldMap as $ldapName => $espoName) {
|
||||
|
||||
$option = $this->getConfig()->get($espoName);
|
||||
if (isset($option)) {
|
||||
$options[$ldapName] = $option;
|
||||
}
|
||||
}
|
||||
|
||||
/** peculiar fields */
|
||||
$options['useSsl'] = (bool) ($options['useSsl'] == 'SSL');
|
||||
$options['useStartTls'] = (bool) ($options['useStartTls'] == 'TLS');
|
||||
$options['accountCanonicalForm'] = $this->accountCanonicalFormMap[ $options['accountCanonicalForm'] ];
|
||||
|
||||
$this->options = $options;
|
||||
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an ldap option
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $returns Return value
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOption($name, $returns = null)
|
||||
{
|
||||
if (isset($this->options)) {
|
||||
$this->getOptions();
|
||||
}
|
||||
|
||||
if (isset($this->options[$name])) {
|
||||
return $this->options[$name];
|
||||
}
|
||||
|
||||
return $returns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Zend options for using Zend\Ldap
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getZendOptions()
|
||||
{
|
||||
$options = $this->getOptions();
|
||||
$espoOptions = array_keys($this->permittedEspoOptions);
|
||||
|
||||
$zendOptions = array_diff_key($options, array_flip($espoOptions));
|
||||
|
||||
return $zendOptions;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,6 +32,8 @@ class Config
|
||||
*/
|
||||
private $defaultConfigPath = 'application/Espo/Core/defaults/config.php';
|
||||
|
||||
private $systemConfigPath = 'application/Espo/Core/defaults/systemConfig.php';
|
||||
|
||||
protected $configPath = 'data/config.php';
|
||||
|
||||
private $cacheTimestamp = 'cacheTimestamp';
|
||||
@@ -51,7 +53,9 @@ class Config
|
||||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
private $configData;
|
||||
private $data;
|
||||
|
||||
private $changedData = array();
|
||||
|
||||
private $fileManager;
|
||||
|
||||
@@ -107,28 +111,25 @@ class Config
|
||||
$name = array($name => $value);
|
||||
}
|
||||
|
||||
return $this->setArray($name);
|
||||
foreach ($name as $key => $value) {
|
||||
$this->data[$key] = $value;
|
||||
$this->changedData[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set options from array
|
||||
*
|
||||
* @param array $values
|
||||
* @return bool
|
||||
*/
|
||||
protected function setArray($values)
|
||||
public function save()
|
||||
{
|
||||
if (!is_array($values)) {
|
||||
return false;
|
||||
}
|
||||
$values = $this->changedData;
|
||||
|
||||
if (!isset($values[$this->cacheTimestamp])) {
|
||||
$values = array_merge($this->updateCacheTimestamp(true), $values);
|
||||
}
|
||||
|
||||
$result = $this->getFileManager()->mergeContentsPHP($this->configPath, $values, true);
|
||||
$this->loadConfig(true);
|
||||
if ($result) {
|
||||
$this->changedData = array();
|
||||
$this->loadConfig(true);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -145,15 +146,18 @@ class Config
|
||||
*/
|
||||
protected function loadConfig($reload = false)
|
||||
{
|
||||
if (!$reload && isset($this->configData) && !empty($this->configData)) {
|
||||
return $this->configData;
|
||||
if (!$reload && isset($this->data) && !empty($this->data)) {
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
$configPath = file_exists($this->configPath) ? $this->configPath : $this->defaultConfigPath;
|
||||
|
||||
$this->configData = $this->getFileManager()->getContents($configPath);
|
||||
$this->data = $this->getFileManager()->getContents($configPath);
|
||||
|
||||
return $this->configData;
|
||||
$systemConfig = $this->getFileManager()->getContents($this->systemConfigPath);
|
||||
$this->data = Util::merge($systemConfig, $this->data);
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,9 +169,9 @@ class Config
|
||||
*/
|
||||
public function getData($isAdmin = false)
|
||||
{
|
||||
$configData = $this->loadConfig();
|
||||
$data = $this->loadConfig();
|
||||
|
||||
$restrictedConfig = $configData;
|
||||
$restrictedConfig = $data;
|
||||
foreach($this->getRestrictItems($isAdmin) as $name) {
|
||||
if (isset($restrictedConfig[$name])) {
|
||||
unset($restrictedConfig[$name]);
|
||||
@@ -195,7 +199,7 @@ class Config
|
||||
}
|
||||
}
|
||||
|
||||
return $this->setArray($values);
|
||||
return $this->set($values);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,14 +228,14 @@ class Config
|
||||
*/
|
||||
protected function getRestrictItems($onlySystemItems = false)
|
||||
{
|
||||
$configData = $this->loadConfig();
|
||||
$data = $this->loadConfig();
|
||||
|
||||
if ($onlySystemItems) {
|
||||
return $configData['systemItems'];
|
||||
return $data['systemItems'];
|
||||
}
|
||||
|
||||
if (empty($this->adminItems)) {
|
||||
$this->adminItems= Util::merge($configData['systemItems'], $configData['adminItems']);
|
||||
$this->adminItems= Util::merge($data['systemItems'], $data['adminItems']);
|
||||
}
|
||||
|
||||
return $this->adminItems;
|
||||
|
||||
@@ -70,7 +70,7 @@ class Converter
|
||||
}
|
||||
|
||||
|
||||
public function getSchemaFromMetadata($entityList = array())
|
||||
public function getSchemaFromMetadata($entityList = null)
|
||||
{
|
||||
$ormMeta = $this->getMetadata()->getOrmMetadata();
|
||||
$entityDefs = $this->getMetadata()->get('entityDefs');
|
||||
|
||||
@@ -31,4 +31,9 @@ class JsonArray extends \Doctrine\DBAL\Types\JsonArrayType
|
||||
return self::JSON_ARRAY;
|
||||
}
|
||||
|
||||
public static function getDbTypeName()
|
||||
{
|
||||
return 'TEXT';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,18 +26,21 @@ use Espo\Core\Utils\Util;
|
||||
|
||||
class Base
|
||||
{
|
||||
private $itemName = null;
|
||||
|
||||
private $entityName = null;
|
||||
|
||||
private $metadata;
|
||||
|
||||
private $params;
|
||||
private $ormEntityDefs;
|
||||
|
||||
private $foreignParams;
|
||||
private $entityDefs;
|
||||
|
||||
protected $allowParams = array();
|
||||
|
||||
|
||||
public function __construct(\Espo\Core\Utils\Metadata $metadata)
|
||||
public function __construct(\Espo\Core\Utils\Metadata $metadata, array $ormEntityDefs, array $entityDefs)
|
||||
{
|
||||
$this->metadata = $metadata;
|
||||
$this->ormEntityDefs = $ormEntityDefs;
|
||||
$this->entityDefs = $entityDefs;
|
||||
}
|
||||
|
||||
protected function getMetadata()
|
||||
@@ -45,80 +48,197 @@ class Base
|
||||
return $this->metadata;
|
||||
}
|
||||
|
||||
protected function getParams()
|
||||
protected function getOrmEntityDefs()
|
||||
{
|
||||
return $this->params;
|
||||
return $this->ormEntityDefs;
|
||||
}
|
||||
|
||||
protected function getForeignParams()
|
||||
protected function getEntityDefs()
|
||||
{
|
||||
return $this->foreignParams;
|
||||
return $this->entityDefs;
|
||||
}
|
||||
|
||||
protected function setParams(array $params)
|
||||
/**
|
||||
* Set current Field name OR Link name
|
||||
*
|
||||
* @param void
|
||||
*/
|
||||
protected function setItemName($itemName)
|
||||
{
|
||||
$this->params = $params;
|
||||
$this->itemName = $itemName;
|
||||
}
|
||||
|
||||
protected function setForeignParams(array $foreignParams)
|
||||
/**
|
||||
* Get current Field name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getFieldName()
|
||||
{
|
||||
$this->foreignParams = $foreignParams;
|
||||
return $this->itemName;
|
||||
}
|
||||
|
||||
|
||||
public function process($params, $foreignParams)
|
||||
/**
|
||||
* Get current Link name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getLinkName()
|
||||
{
|
||||
$this->setParams($params);
|
||||
$this->setForeignParams($foreignParams);
|
||||
|
||||
$loads = $this->load($params, $foreignParams);
|
||||
|
||||
$loads = $this->mergeAllowedParams($loads);
|
||||
|
||||
return $loads;
|
||||
return $this->itemName;
|
||||
}
|
||||
|
||||
private function mergeAllowedParams($loads)
|
||||
/**
|
||||
* Set current Entity Name
|
||||
*
|
||||
* @param void
|
||||
*/
|
||||
protected function setEntityName($entityName)
|
||||
{
|
||||
$params = $this->getParams();
|
||||
$this->entityName = $entityName;
|
||||
}
|
||||
|
||||
if (!empty($this->allowParams)) {
|
||||
$linkParams = &$loads[$params['entityName']] ['relations'] [$params['link']['name']];
|
||||
/**
|
||||
* Get current Entity Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getEntityName()
|
||||
{
|
||||
return $this->entityName;
|
||||
}
|
||||
|
||||
foreach ($this->allowParams as $name) {
|
||||
|
||||
$additionalParrams = $this->getAllowedAdditionalParams($name);
|
||||
|
||||
if (isset($additionalParrams) && !isset($linkParams[$name])) {
|
||||
$linkParams[$name] = $additionalParrams;
|
||||
}
|
||||
protected function setMethods(array $keyValueList)
|
||||
{
|
||||
foreach ($keyValueList as $key => $value) {
|
||||
$methodName = 'set' . ucfirst($key);
|
||||
if (method_exists($this, $methodName)) {
|
||||
$this->$methodName($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $loads;
|
||||
}
|
||||
|
||||
private function getAllowedAdditionalParams($allowedItemName)
|
||||
/**
|
||||
* Start process Orm converting for fields/relations
|
||||
*
|
||||
* @param string $itemName Field name OR Link name
|
||||
* @param string $entityName
|
||||
* @return array
|
||||
*/
|
||||
public function process($itemName, $entityName)
|
||||
{
|
||||
$params = $this->getParams();
|
||||
$foreignParams = $this->getForeignParams();
|
||||
$inputs = array(
|
||||
'itemName' => $itemName,
|
||||
'entityName' => $entityName,
|
||||
);
|
||||
$this->setMethods($inputs);
|
||||
|
||||
$linkParams = isset($params['link']['params'][$allowedItemName]) ? $params['link']['params'][$allowedItemName] : null;
|
||||
$foreignLinkParams = isset($foreignParams['link']['params'][$allowedItemName]) ? $foreignParams['link']['params'][$allowedItemName] : null;
|
||||
$convertedDefs = $this->load($itemName, $entityName);
|
||||
|
||||
$additionalParrams = null;
|
||||
$inputs = $this->setArrayValue(null, $inputs);
|
||||
$this->setMethods($inputs);
|
||||
|
||||
if (isset($linkParams) && isset($foreignLinkParams)) {
|
||||
$additionalParrams = Util::merge($linkParams, $foreignLinkParams);
|
||||
} else if (isset($linkParams)) {
|
||||
$additionalParrams = $linkParams;
|
||||
} else if (isset($foreignLinkParams)) {
|
||||
$additionalParrams = $foreignLinkParams;
|
||||
return $convertedDefs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Entity Defs by type (entity/orm)
|
||||
*
|
||||
* @param boolean $isOrmEntityDefs
|
||||
* @return array
|
||||
*/
|
||||
protected function getDefs($isOrmEntityDefs = false)
|
||||
{
|
||||
$entityDefs = $isOrmEntityDefs ? $this->getOrmEntityDefs() : $this->getEntityDefs();
|
||||
|
||||
return $entityDefs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get entity params by name
|
||||
*
|
||||
* @param string $entityName
|
||||
* @param bool $isOrmEntityDefs
|
||||
* @param mixed $returns
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getEntityParams($entityName = null, $isOrmEntityDefs = false, $returns = null)
|
||||
{
|
||||
if (!isset($entityName)) {
|
||||
$entityName = $this->getEntityName();
|
||||
}
|
||||
|
||||
return $additionalParrams;
|
||||
$entityDefs = $this->getDefs($isOrmEntityDefs);
|
||||
|
||||
if (isset($entityDefs[$entityName])) {
|
||||
return $entityDefs[$entityName];
|
||||
}
|
||||
|
||||
return $returns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get field params by name for a specified entity
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @param string $entityName
|
||||
* @param bool $isOrmEntityDefs
|
||||
* @param mixed $returns
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getFieldParams($fieldName = null, $entityName = null, $isOrmEntityDefs = false, $returns = null)
|
||||
{
|
||||
if (!isset($fieldName)) {
|
||||
$fieldName = $this->getFieldName();
|
||||
}
|
||||
if (!isset($entityName)) {
|
||||
$entityName = $this->getEntityName();
|
||||
}
|
||||
|
||||
$entityDefs = $this->getDefs($isOrmEntityDefs);
|
||||
|
||||
if (isset($entityDefs[$entityName]) && isset($entityDefs[$entityName]['fields'][$fieldName])) {
|
||||
return $entityDefs[$entityName]['fields'][$fieldName];
|
||||
}
|
||||
|
||||
return $returns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get relation params by name for a specified entity
|
||||
*
|
||||
* @param string $linkName
|
||||
* @param string $entityName
|
||||
* @param bool $isOrmEntityDefs
|
||||
* @param mixed $returns
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getLinkParams($linkName = null, $entityName = null, $isOrmEntityDefs = false, $returns = null)
|
||||
{
|
||||
if (!isset($linkName)) {
|
||||
$linkName = $this->getLinkName();
|
||||
}
|
||||
if (!isset($entityName)) {
|
||||
$entityName = $this->getEntityName();
|
||||
}
|
||||
|
||||
$entityDefs = $this->getDefs($isOrmEntityDefs);
|
||||
$relationKeyName = $isOrmEntityDefs ? 'relations' : 'links';
|
||||
|
||||
if (isset($entityDefs[$entityName]) && isset($entityDefs[$entityName][$relationKeyName][$linkName])) {
|
||||
return $entityDefs[$entityName][$relationKeyName][$linkName];
|
||||
}
|
||||
|
||||
return $returns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Foreign field
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $entityName
|
||||
* @return string
|
||||
*/
|
||||
protected function getForeignField($name, $entityName)
|
||||
{
|
||||
$foreignField = $this->getMetadata()->get('entityDefs.'.$entityName.'.fields.'.$name);
|
||||
@@ -141,6 +261,19 @@ class Base
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a value for all elements of array. So, in result all elements will have the same values
|
||||
*
|
||||
* @param string $value
|
||||
* @param array $array
|
||||
*/
|
||||
protected function setArrayValue($inputValue, array $array)
|
||||
{
|
||||
foreach ($array as &$value) {
|
||||
$value = $inputValue;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ class Converter
|
||||
|
||||
private $relationManager;
|
||||
|
||||
private $entityDefs;
|
||||
|
||||
protected $defaultFieldType = 'varchar';
|
||||
protected $defaultNaming = 'postfix';
|
||||
|
||||
@@ -69,6 +71,9 @@ class Converter
|
||||
'default' => '{0}',
|
||||
),
|
||||
),
|
||||
'select' => 'select',
|
||||
'orderBy' => 'orderBy',
|
||||
'where' => 'where',
|
||||
);
|
||||
|
||||
protected $idParams = array(
|
||||
@@ -85,6 +90,8 @@ class Converter
|
||||
$this->relationManager = new RelationManager($this->metadata);
|
||||
|
||||
$this->metadataUtils = new \Espo\Core\Utils\Metadata\Utils($this->metadata);
|
||||
|
||||
$this->entityDefs = $this->getMetadata()->get('entityDefs');
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +100,11 @@ class Converter
|
||||
return $this->metadata;
|
||||
}
|
||||
|
||||
protected function getEntityDefs()
|
||||
{
|
||||
return $this->entityDefs;
|
||||
}
|
||||
|
||||
protected function getFileManager()
|
||||
{
|
||||
return $this->fileManager;
|
||||
@@ -108,11 +120,9 @@ class Converter
|
||||
return $this->metadataUtils;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function process()
|
||||
{
|
||||
$entityDefs = $this->getMetadata()->get('entityDefs');
|
||||
$entityDefs = $this->getEntityDefs();
|
||||
|
||||
$ormMeta = array();
|
||||
foreach($entityDefs as $entityName => $entityMeta) {
|
||||
@@ -122,7 +132,7 @@ class Converter
|
||||
continue;
|
||||
}
|
||||
|
||||
$ormMeta = Util::merge($ormMeta, $this->convertEntity($entityName, $entityMeta, $entityDefs));
|
||||
$ormMeta = Util::merge($ormMeta, $this->convertEntity($entityName, $entityMeta));
|
||||
}
|
||||
|
||||
$ormMeta = $this->afterProcess($ormMeta);
|
||||
@@ -130,10 +140,7 @@ class Converter
|
||||
return $ormMeta;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//convertToDatabaseFormat
|
||||
protected function convertEntity($entityName, $entityMeta, $entityDefs)
|
||||
protected function convertEntity($entityName, $entityMeta)
|
||||
{
|
||||
$ormMeta = array();
|
||||
$ormMeta[$entityName] = array(
|
||||
@@ -145,18 +152,19 @@ class Converter
|
||||
|
||||
$ormMeta[$entityName]['fields'] = $this->convertFields($entityName, $entityMeta);
|
||||
|
||||
$convertedLinks = $this->convertLinks($entityName, $entityMeta, $entityDefs);
|
||||
$convertedLinks = $this->convertLinks($entityName, $entityMeta, $ormMeta);
|
||||
|
||||
$ormMeta = Util::merge($ormMeta, $convertedLinks);
|
||||
|
||||
return $ormMeta;
|
||||
}
|
||||
|
||||
|
||||
public function afterProcess(array $meta)
|
||||
public function afterProcess(array $ormMeta)
|
||||
{
|
||||
$entityDefs = $this->getEntityDefs();
|
||||
|
||||
//load custom field definitions and customCodes
|
||||
foreach($meta as $entityName => &$entityParams) {
|
||||
foreach($ormMeta as $entityName => &$entityParams) {
|
||||
foreach($entityParams['fields'] as $fieldName => $fieldParams) {
|
||||
|
||||
//load custom field definitions
|
||||
@@ -167,17 +175,14 @@ class Converter
|
||||
}
|
||||
|
||||
if (class_exists($className) && method_exists($className, 'load')) {
|
||||
$helperClass = new $className($this->metadata);
|
||||
$fieldResult = $helperClass->load(
|
||||
array('name' => $entityName, 'params' => $entityParams),
|
||||
array('name' => $fieldName, 'params' => $fieldParams)
|
||||
);
|
||||
$helperClass = new $className($this->metadata, $ormMeta, $entityDefs);
|
||||
$fieldResult = $helperClass->process( $fieldName, $entityName );
|
||||
if (isset($fieldResult['unset'])) {
|
||||
$meta = Util::unsetInArray($meta, $fieldResult['unset']);
|
||||
$ormMeta = Util::unsetInArray($ormMeta, $fieldResult['unset']);
|
||||
unset($fieldResult['unset']);
|
||||
}
|
||||
|
||||
$meta = Util::merge($meta, $fieldResult);
|
||||
$ormMeta = Util::merge($ormMeta, $fieldResult);
|
||||
} //END: load custom field definitions
|
||||
|
||||
|
||||
@@ -196,7 +201,7 @@ class Converter
|
||||
}
|
||||
}
|
||||
|
||||
foreach($meta as $entityName => &$entityParams) {
|
||||
foreach($ormMeta as $entityName => &$entityParams) {
|
||||
foreach($entityParams['fields'] as $fieldName => &$fieldParams) {
|
||||
|
||||
switch ($fieldParams['type']) {
|
||||
@@ -224,10 +229,9 @@ class Converter
|
||||
|
||||
}
|
||||
|
||||
return $meta;
|
||||
return $ormMeta;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Metadata conversion from Espo format into Doctrine
|
||||
*
|
||||
@@ -293,8 +297,6 @@ class Converter
|
||||
return $outputMeta;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function convertField($entityName, $fieldName, array $fieldParams, $fieldTypeMeta = null)
|
||||
{
|
||||
/** set default type if exists */
|
||||
@@ -376,34 +378,20 @@ class Converter
|
||||
return $subField;
|
||||
}
|
||||
|
||||
protected function convertLinks($entityName, $entityMeta, array $entityDefs)
|
||||
protected function convertLinks($entityName, $entityMeta, $ormMeta)
|
||||
{
|
||||
if (!isset($entityMeta['links'])) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$entityDefs = $this->getEntityDefs();
|
||||
|
||||
$relationships = array();
|
||||
foreach($entityMeta['links'] as $linkName => $linkParams) {
|
||||
|
||||
$linkEntityName = $this->getRelationManager()->getLinkEntityName($entityName, $linkParams);
|
||||
$convertedLink = $this->getRelationManager()->convert($linkName, $linkParams, $entityName, $ormMeta);
|
||||
|
||||
$currentType = $linkParams['type'];
|
||||
|
||||
$foreignLink = $this->getForeignLink($linkName, $linkParams, $entityDefs[$linkEntityName]);
|
||||
|
||||
$method = $currentType;
|
||||
if ($foreignLink !== false) {
|
||||
$method .= '-'.$foreignLink['params']['type'];
|
||||
}
|
||||
$method = Util::toCamelCase($method);
|
||||
|
||||
if ( $this->getRelationManager()->isRelationExists($method) ) { //ex. hasManyHasMany
|
||||
$convertedLink = $this->getRelationManager()->process($method, $entityName, array('name'=>$linkName, 'params'=>$linkParams), $foreignLink);
|
||||
} else { //ex. hasMany
|
||||
$convertedLink = $this->getRelationManager()->process($currentType, $entityName, array('name'=>$linkName, 'params'=>$linkParams), $foreignLink);
|
||||
}
|
||||
|
||||
if ($convertedLink !== false) {
|
||||
if (isset($convertedLink)) {
|
||||
$relationships = Util::merge($convertedLink, $relationships);
|
||||
}
|
||||
}
|
||||
@@ -411,27 +399,6 @@ class Converter
|
||||
return $relationships;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get foreign Link
|
||||
*
|
||||
* @param string $parentLinkName
|
||||
* @param array $parentLinkParams
|
||||
* @param array $currentEntityDefs
|
||||
*
|
||||
* @return array - in format array('name', 'params')
|
||||
*/
|
||||
protected function getForeignLink($parentLinkName, $parentLinkParams, $currentEntityDefs)
|
||||
{
|
||||
if (isset($parentLinkParams['foreign']) && isset($currentEntityDefs['links'][$parentLinkParams['foreign']])) {
|
||||
return array(
|
||||
'name' => $parentLinkParams['foreign'],
|
||||
'params' => $currentEntityDefs['links'][$parentLinkParams['foreign']],
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getInitValues(array $fieldParams)
|
||||
{
|
||||
$values = array();
|
||||
@@ -460,4 +427,4 @@ class Converter
|
||||
return $values;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,30 +18,47 @@
|
||||
*
|
||||
* 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 Email extends \Espo\Core\Utils\Database\Orm\Base
|
||||
{
|
||||
|
||||
public function load($entity, $field)
|
||||
protected function load($fieldName, $entityName)
|
||||
{
|
||||
return array(
|
||||
$entity['name'] => array(
|
||||
'fields' => array(
|
||||
$field['name'] => array(
|
||||
return array(
|
||||
$entityName => array(
|
||||
'fields' => array(
|
||||
$fieldName => array(
|
||||
'select' => 'email_address.name',
|
||||
'where' =>
|
||||
array (
|
||||
'LIKE' => 'email_address.name LIKE \'{text}\'',
|
||||
'=' => 'email_address.name = \'{text}\'',
|
||||
),
|
||||
'orderBy' => 'email_address.name {direction}',
|
||||
'where' =>
|
||||
array (
|
||||
'LIKE' => \Espo\Core\Utils\Util::toUnderScore($entityName) . ".id IN (
|
||||
SELECT entity_id
|
||||
FROM entity_email_address
|
||||
JOIN email_address ON email_address.id = entity_email_address.email_address_id
|
||||
WHERE
|
||||
entity_email_address.deleted = 0 AND entity_email_address.entity_type = '{$entityName}' AND
|
||||
email_address.deleted = 0 AND email_address.name LIKE '{text}'
|
||||
)",
|
||||
'=' => \Espo\Core\Utils\Util::toUnderScore($entityName) . ".id IN (
|
||||
SELECT entity_id
|
||||
FROM entity_email_address
|
||||
JOIN email_address ON email_address.id = entity_email_address.email_address_id
|
||||
WHERE
|
||||
entity_email_address.deleted = 0 AND entity_email_address.entity_type = '{$entityName}' AND
|
||||
email_address.deleted = 0 AND email_address.name = '{text}'
|
||||
)"
|
||||
),
|
||||
'orderBy' => 'email_address.name {direction}',
|
||||
),
|
||||
$fieldName .'Data' => array(
|
||||
'type' => 'text',
|
||||
'notStorable' => true
|
||||
),
|
||||
),
|
||||
'relations' => array(
|
||||
$field['name'].'es' => array(
|
||||
$fieldName.'es' => array(
|
||||
'type' => 'manyMany',
|
||||
'entity' => 'EmailAddress',
|
||||
'relationName' => 'entityEmailAddress',
|
||||
@@ -50,16 +67,16 @@ class Email extends \Espo\Core\Utils\Database\Orm\Base
|
||||
'email_address_id',
|
||||
),
|
||||
'conditions' => array(
|
||||
'entityType' => $entity['name'],
|
||||
'entityType' => $entityName,
|
||||
),
|
||||
'additionalColumns' => array(
|
||||
'entityType' => array(
|
||||
'entityType' => array(
|
||||
'type' => 'varchar',
|
||||
'len' => 100,
|
||||
'len' => 100,
|
||||
),
|
||||
'primary' => array(
|
||||
'type' => 'bool',
|
||||
'default' => false,
|
||||
'default' => false,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -69,4 +86,4 @@ class Email extends \Espo\Core\Utils\Database\Orm\Base
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,35 +18,44 @@
|
||||
*
|
||||
* 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 LinkMultiple extends \Espo\Core\Utils\Database\Orm\Base
|
||||
{
|
||||
|
||||
public function load($entity, $field)
|
||||
protected function load($fieldName, $entityName)
|
||||
{
|
||||
return array(
|
||||
$entity['name'] => array (
|
||||
'fields' => array(
|
||||
$field['name'].'Ids' => array(
|
||||
$data = array(
|
||||
$entityName => array (
|
||||
'fields' => array(
|
||||
$fieldName.'Ids' => array(
|
||||
'type' => 'varchar',
|
||||
'notStorable' => true,
|
||||
),
|
||||
$field['name'].'Names' => array(
|
||||
$fieldName.'Names' => array(
|
||||
'type' => 'varchar',
|
||||
'notStorable' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
'unset' => array(
|
||||
$entity['name'] => array(
|
||||
'fields.'.$field['name'],
|
||||
),
|
||||
),
|
||||
'unset' => array(
|
||||
$entityName => array(
|
||||
'fields.'.$fieldName,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$columns = $this->getMetadata()->get("entityDefs.{$entityName}.fields.{$fieldName}.columns");
|
||||
if (!empty($columns)) {
|
||||
$data[$entityName]['fields'][$fieldName . 'Columns'] = array(
|
||||
'type' => 'varchar',
|
||||
'notStorable' => true,
|
||||
);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,28 +24,27 @@ namespace Espo\Core\Utils\Database\Orm\Fields;
|
||||
|
||||
class LinkParent extends \Espo\Core\Utils\Database\Orm\Base
|
||||
{
|
||||
|
||||
public function load($entity, $field)
|
||||
protected function load($fieldName, $entityName)
|
||||
{
|
||||
return array(
|
||||
$entity['name'] => array (
|
||||
'fields' => array(
|
||||
$field['name'].'Id' => array(
|
||||
return array(
|
||||
$entityName => array (
|
||||
'fields' => array(
|
||||
$fieldName.'Id' => array(
|
||||
'type' => 'foreignId',
|
||||
'index' => $field['name'],
|
||||
'index' => $fieldName,
|
||||
),
|
||||
$field['name'].'Type' => array(
|
||||
$fieldName.'Type' => array(
|
||||
'type' => 'foreignType',
|
||||
'notNull' => false,
|
||||
'index' => $field['name'],
|
||||
'index' => $fieldName,
|
||||
),
|
||||
$field['name'].'Name' => array(
|
||||
$fieldName.'Name' => array(
|
||||
'type' => 'varchar',
|
||||
'notStorable' => true,
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,11 +26,10 @@ use Espo\Core\Utils\Util;
|
||||
|
||||
class PersonName extends \Espo\Core\Utils\Database\Orm\Base
|
||||
{
|
||||
|
||||
public function load($entity, $field)
|
||||
protected function load($fieldName, $entityName)
|
||||
{
|
||||
$foreignField = $this->getForeignField($field['name'], $entity['name']);
|
||||
$tableName = Util::toUnderScore($entity['name']);
|
||||
$foreignField = $this->getForeignField($fieldName, $entityName);
|
||||
$tableName = Util::toUnderScore($entityName);
|
||||
|
||||
$fullList = array(); //contains empty string (" ") like delimiter
|
||||
$fullListReverse = array(); //reverse of $fullList
|
||||
@@ -38,9 +37,9 @@ class PersonName extends \Espo\Core\Utils\Database\Orm\Base
|
||||
$like = array();
|
||||
$equal = array();
|
||||
|
||||
foreach($foreignField as $fieldName) {
|
||||
foreach($foreignField as $foreignFieldName) {
|
||||
|
||||
$fieldNameTrimmed = trim($fieldName);
|
||||
$fieldNameTrimmed = trim($foreignFieldName);
|
||||
if (!empty($fieldNameTrimmed)) {
|
||||
$columnName = $tableName.'.'.Util::toUnderScore($fieldNameTrimmed);
|
||||
|
||||
@@ -48,16 +47,16 @@ class PersonName extends \Espo\Core\Utils\Database\Orm\Base
|
||||
$like[] = $columnName." LIKE '{text}'";
|
||||
$equal[] = $columnName." = '{text}'";
|
||||
} else {
|
||||
$fullList[] = "'".$fieldName."'";
|
||||
$fullList[] = "'".$foreignFieldName."'";
|
||||
}
|
||||
}
|
||||
|
||||
$fullListReverse = array_reverse($fullList);
|
||||
|
||||
return array(
|
||||
$entity['name'] => array (
|
||||
$entityName => array (
|
||||
'fields' => array(
|
||||
$field['name'] => array(
|
||||
$fieldName => array(
|
||||
'type' => 'varchar',
|
||||
'select' => $this->getSelect($fullList),
|
||||
'where' => array(
|
||||
|
||||
89
application/Espo/Core/Utils/Database/Orm/Fields/Phone.php
Normal file
89
application/Espo/Core/Utils/Database/Orm/Fields/Phone.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 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 Phone extends \Espo\Core\Utils\Database\Orm\Base
|
||||
{
|
||||
protected function load($fieldName, $entityName)
|
||||
{
|
||||
return array(
|
||||
$entityName => array(
|
||||
'fields' => array(
|
||||
$fieldName => array(
|
||||
'select' => 'phone_number.name',
|
||||
'where' =>
|
||||
array (
|
||||
'LIKE' => \Espo\Core\Utils\Util::toUnderScore($entityName) . ".id IN (
|
||||
SELECT entity_id
|
||||
FROM entity_phone_number
|
||||
JOIN phone_number ON phone_number.id = entity_phone_number.phone_number_id
|
||||
WHERE
|
||||
entity_phone_number.deleted = 0 AND entity_phone_number.entity_type = '{$entityName}' AND
|
||||
phone_number.deleted = 0 AND phone_number.name LIKE '{text}'
|
||||
)",
|
||||
'=' => \Espo\Core\Utils\Util::toUnderScore($entityName) . ".id IN (
|
||||
SELECT entity_id
|
||||
FROM entity_phone_number
|
||||
JOIN phone_number ON phone_number.id = entity_phone_number.phone_number_id
|
||||
WHERE
|
||||
entity_phone_number.deleted = 0 AND entity_phone_number.entity_type = '{$entityName}' AND
|
||||
phone_number.deleted = 0 AND phone_number.name = '{text}'
|
||||
)"
|
||||
),
|
||||
'orderBy' => 'phone_number.name {direction}',
|
||||
),
|
||||
$fieldName .'Data' => array(
|
||||
'type' => 'text',
|
||||
'notStorable' => true
|
||||
),
|
||||
),
|
||||
'relations' => array(
|
||||
$fieldName.'s' => array(
|
||||
'type' => 'manyMany',
|
||||
'entity' => 'PhoneNumber',
|
||||
'relationName' => 'entityPhoneNumber',
|
||||
'midKeys' => array(
|
||||
'entity_id',
|
||||
'phone_number_id',
|
||||
),
|
||||
'conditions' => array(
|
||||
'entityType' => $entityName,
|
||||
),
|
||||
'additionalColumns' => array(
|
||||
'entityType' => array(
|
||||
'type' => 'varchar',
|
||||
'len' => 100,
|
||||
),
|
||||
'primary' => array(
|
||||
'type' => 'bool',
|
||||
'default' => false,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,10 +28,14 @@ class RelationManager
|
||||
{
|
||||
private $metadata;
|
||||
|
||||
private $entityDefs;
|
||||
|
||||
|
||||
public function __construct(\Espo\Core\Utils\Metadata $metadata)
|
||||
{
|
||||
$this->metadata = $metadata;
|
||||
|
||||
$this->entityDefs = $this->getMetadata()->get('entityDefs');
|
||||
}
|
||||
|
||||
protected function getMetadata()
|
||||
@@ -39,14 +43,15 @@ class RelationManager
|
||||
return $this->metadata;
|
||||
}
|
||||
|
||||
|
||||
public function getLinkEntityName($entityName, $link)
|
||||
protected function getEntityDefs()
|
||||
{
|
||||
if (isset($link['params'])) {
|
||||
return isset($link['params']['entity']) ? $link['params']['entity'] : $entityName;
|
||||
}
|
||||
return $this->entityDefs;
|
||||
}
|
||||
|
||||
return isset($link['entity']) ? $link['entity'] : $entityName;
|
||||
|
||||
public function getLinkEntityName($entityName, $linkParams)
|
||||
{
|
||||
return isset($linkParams['entity']) ? $linkParams['entity'] : $entityName;
|
||||
}
|
||||
|
||||
public function isRelationExists($relationName)
|
||||
@@ -81,33 +86,58 @@ class RelationManager
|
||||
return method_exists($className, 'load');
|
||||
}
|
||||
|
||||
public function process($method, $entityName, $link, $foreignLink = array())
|
||||
/**
|
||||
* Get foreign Link
|
||||
*
|
||||
* @param string $parentLinkName
|
||||
* @param array $parentLinkParams
|
||||
* @param array $currentEntityDefs
|
||||
*
|
||||
* @return array - in format array('name', 'params')
|
||||
*/
|
||||
private function getForeignLink($parentLinkName, $parentLinkParams, $currentEntityDefs)
|
||||
{
|
||||
$params = array();
|
||||
$params['entityName'] = $entityName;
|
||||
$params['link'] = $link;
|
||||
|
||||
$foreignParams = array();
|
||||
$foreignParams['entityName'] = $this->getLinkEntityName($entityName, $link);
|
||||
$foreignParams['link'] = $foreignLink;
|
||||
|
||||
$params['targetEntity'] = $foreignParams['entityName'];
|
||||
$foreignParams['targetEntity'] = $params['entityName'];
|
||||
|
||||
//relationDefs defined in separate file
|
||||
if (isset($link['params']['relationName']) && $this->isMethodExists($link['params']['relationName'])) {
|
||||
$className = $this->getRelationClass($link['params']['relationName']);
|
||||
} else if ($this->isMethodExists($method)) {
|
||||
$className = $this->getRelationClass($method);
|
||||
if (isset($parentLinkParams['foreign']) && isset($currentEntityDefs['links'][$parentLinkParams['foreign']])) {
|
||||
return array(
|
||||
'name' => $parentLinkParams['foreign'],
|
||||
'params' => $currentEntityDefs['links'][$parentLinkParams['foreign']],
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($className) && $className !== false) {
|
||||
$helperClass = new $className($this->metadata);
|
||||
return $helperClass->process($params, $foreignParams);
|
||||
}
|
||||
//END: relationDefs defined in separate file
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function convert($linkName, $linkParams, $entityName, $ormMeta)
|
||||
{
|
||||
$entityDefs = $this->getEntityDefs();
|
||||
|
||||
$foreignEntityName = $this->getLinkEntityName($entityName, $linkParams);
|
||||
$foreignLink = $this->getForeignLink($linkName, $linkParams, $entityDefs[$foreignEntityName]);
|
||||
|
||||
$currentType = $linkParams['type'];
|
||||
|
||||
$method = $currentType;
|
||||
if ($foreignLink !== false) {
|
||||
$method .= '-'.$foreignLink['params']['type'];
|
||||
}
|
||||
$method = Util::toCamelCase($method);
|
||||
|
||||
$relationName = $this->isRelationExists($method) ? $method /*hasManyHasMany*/ : $currentType /*hasMany*/;
|
||||
|
||||
//relationDefs defined in separate file
|
||||
if (isset($linkParams['relationName']) && $this->isMethodExists($linkParams['relationName'])) {
|
||||
$className = $this->getRelationClass($linkParams['relationName']);
|
||||
} else if ($this->isMethodExists($relationName)) {
|
||||
$className = $this->getRelationClass($relationName);
|
||||
}
|
||||
|
||||
if (isset($className) && $className !== false) {
|
||||
$helperClass = new $className($this->metadata, $ormMeta, $entityDefs);
|
||||
return $helperClass->process($linkName, $entityName, $foreignLink['name'], $foreignEntityName);
|
||||
}
|
||||
//END: relationDefs defined in separate file
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
146
application/Espo/Core/Utils/Database/Orm/Relations/Base.php
Normal file
146
application/Espo/Core/Utils/Database/Orm/Relations/Base.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 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 Base extends \Espo\Core\Utils\Database\Orm\Base
|
||||
{
|
||||
private $params;
|
||||
|
||||
private $foreignParams;
|
||||
|
||||
protected $foreignLinkName = null;
|
||||
protected $foreignEntityName = null;
|
||||
|
||||
protected $allowParams = array();
|
||||
|
||||
protected function getParams()
|
||||
{
|
||||
return $this->params;
|
||||
}
|
||||
|
||||
protected function getForeignParams()
|
||||
{
|
||||
return $this->foreignParams;
|
||||
}
|
||||
|
||||
protected function setParams(array $params)
|
||||
{
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
protected function setForeignParams(array $foreignParams)
|
||||
{
|
||||
$this->foreignParams = $foreignParams;
|
||||
}
|
||||
|
||||
protected function setForeignLinkName($foreignLinkName)
|
||||
{
|
||||
$this->foreignLinkName = $foreignLinkName;
|
||||
}
|
||||
|
||||
protected function getForeignLinkName()
|
||||
{
|
||||
return $this->foreignLinkName;
|
||||
}
|
||||
|
||||
protected function setForeignEntityName($foreignEntityName)
|
||||
{
|
||||
$this->foreignEntityName = $foreignEntityName;
|
||||
}
|
||||
|
||||
protected function getForeignEntityName()
|
||||
{
|
||||
return $this->foreignEntityName;
|
||||
}
|
||||
|
||||
protected function getForeignLinkParams()
|
||||
{
|
||||
$foreignLinkName = $this->getForeignLinkName();
|
||||
$foreignEntityName = $this->getForeignEntityName();
|
||||
$foreignLinkParams = $this->getLinkParams($foreignLinkName, $foreignEntityName);
|
||||
|
||||
return $foreignLinkParams;
|
||||
}
|
||||
|
||||
public function process($linkName, $entityName, $foreignLinkName, $foreignEntityName)
|
||||
{
|
||||
$inputs = array(
|
||||
'itemName' => $linkName,
|
||||
'entityName' => $entityName,
|
||||
'foreignLinkName' => $foreignLinkName,
|
||||
'foreignEntityName' => $foreignEntityName,
|
||||
);
|
||||
$this->setMethods($inputs);
|
||||
|
||||
$convertedDefs = $this->load($linkName, $entityName);
|
||||
$convertedDefs = $this->mergeAllowedParams($convertedDefs);
|
||||
|
||||
$inputs = $this->setArrayValue(null, $inputs);
|
||||
$this->setMethods($inputs);
|
||||
|
||||
return $convertedDefs;
|
||||
}
|
||||
|
||||
private function mergeAllowedParams($loads)
|
||||
{
|
||||
$linkName = $this->getLinkName();
|
||||
$entityName = $this->getEntityName();
|
||||
|
||||
if (!empty($this->allowParams)) {
|
||||
$linkParams = &$loads[$entityName]['relations'][$linkName];
|
||||
|
||||
foreach ($this->allowParams as $name) {
|
||||
|
||||
$additionalParrams = $this->getAllowedAdditionalParams($name);
|
||||
|
||||
if (isset($additionalParrams) && !isset($linkParams[$name])) {
|
||||
$linkParams[$name] = $additionalParrams;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $loads;
|
||||
}
|
||||
|
||||
private function getAllowedAdditionalParams($allowedItemName)
|
||||
{
|
||||
$linkParams = $this->getLinkParams();
|
||||
$foreignLinkParams = $this->getForeignLinkParams();
|
||||
|
||||
$itemLinkParams = isset($linkParams[$allowedItemName]) ? $linkParams[$allowedItemName] : null;
|
||||
$itemForeignLinkParams = isset($foreignLinkParams[$allowedItemName]) ? $foreignLinkParams[$allowedItemName] : null;
|
||||
|
||||
$additionalParrams = null;
|
||||
|
||||
if (isset($itemLinkParams) && isset($itemForeignLinkParams)) {
|
||||
$additionalParrams = Util::merge($itemLinkParams, $itemForeignLinkParams);
|
||||
} else if (isset($itemLinkParams)) {
|
||||
$additionalParrams = $itemLinkParams;
|
||||
} else if (isset($itemForeignLinkParams)) {
|
||||
$additionalParrams = $itemForeignLinkParams;
|
||||
}
|
||||
|
||||
return $additionalParrams;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,33 +18,34 @@
|
||||
*
|
||||
* 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 BelongsTo extends \Espo\Core\Utils\Database\Orm\Base
|
||||
class BelongsTo extends Base
|
||||
{
|
||||
|
||||
public function load($params, $foreignParams)
|
||||
protected function load($linkName, $entityName)
|
||||
{
|
||||
$foreignEntityName = $this->getForeignEntityName();
|
||||
|
||||
return array (
|
||||
$params['entityName'] => array (
|
||||
$entityName => array (
|
||||
'fields' => array(
|
||||
$params['link']['name'].'Name' => array(
|
||||
$linkName.'Name' => array(
|
||||
'type' => 'foreign',
|
||||
'relation' => $params['link']['name'],
|
||||
'foreign' => $this->getForeignField('name', $foreignParams['entityName']),
|
||||
'relation' => $linkName,
|
||||
'foreign' => $this->getForeignField('name', $foreignEntityName),
|
||||
),
|
||||
$params['link']['name'].'Id' => array(
|
||||
$linkName.'Id' => array(
|
||||
'type' => 'foreignId',
|
||||
'index' => true,
|
||||
),
|
||||
),
|
||||
'relations' => array(
|
||||
$params['link']['name'] => array(
|
||||
$linkName => array(
|
||||
'type' => 'belongsTo',
|
||||
'entity' => $params['targetEntity'],
|
||||
'key' => $params['link']['name'].'Id',
|
||||
'entity' => $foreignEntityName,
|
||||
'key' => $linkName.'Id',
|
||||
'foreignKey' => 'id', //????
|
||||
),
|
||||
),
|
||||
@@ -52,5 +53,4 @@ class BelongsTo extends \Espo\Core\Utils\Database\Orm\Base
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -18,35 +18,34 @@
|
||||
*
|
||||
* 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 EmailEmailAddress extends \Espo\Core\Utils\Database\Orm\Relations\HasMany
|
||||
class EmailEmailAddress extends HasMany
|
||||
{
|
||||
|
||||
public function load($params, $foreignParams)
|
||||
protected function load($linkName, $entityName)
|
||||
{
|
||||
$parentRelation = parent::load($linkName, $entityName);
|
||||
|
||||
$parentRelation = parent::load($params, $foreignParams);
|
||||
$foreignEntityName = $this->getForeignEntityName();
|
||||
|
||||
$relation = array(
|
||||
$params['entityName'] => array (
|
||||
$entityName => array (
|
||||
'relations' => array(
|
||||
$params['link']['name'] => array(
|
||||
$linkName => array(
|
||||
'midKeys' => array(
|
||||
lcfirst($params['entityName']).'Id',
|
||||
lcfirst($foreignParams['entityName']).'Id',
|
||||
lcfirst($entityName).'Id',
|
||||
lcfirst($foreignEntityName).'Id',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
$relation = \Espo\Core\Utils\Util::merge($parentRelation, $relation);
|
||||
|
||||
return $relation;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,28 +18,30 @@
|
||||
*
|
||||
* 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 EntityTeam extends \Espo\Core\Utils\Database\Orm\Base
|
||||
class EntityTeam extends Base
|
||||
{
|
||||
|
||||
public function load($params, $foreignParams)
|
||||
protected function load($linkName, $entityName)
|
||||
{
|
||||
$linkParams = $this->getLinkParams();
|
||||
$foreignEntityName = $this->getForeignEntityName();
|
||||
|
||||
return array(
|
||||
$params['entityName'] => array(
|
||||
$entityName => array(
|
||||
'relations' => array(
|
||||
$params['link']['name'] => array(
|
||||
$linkName => array(
|
||||
'type' => 'manyMany',
|
||||
'entity' => $params['targetEntity'],
|
||||
'relationName' => lcfirst($params['link']['params']['relationName']),
|
||||
'entity' => $foreignEntityName,
|
||||
'relationName' => lcfirst($linkParams['relationName']),
|
||||
'midKeys' => array(
|
||||
'entity_id',
|
||||
'team_id',
|
||||
),
|
||||
'conditions' => array(
|
||||
'entityType' => $params['entityName'],
|
||||
'entityType' => $entityName,
|
||||
),
|
||||
'additionalColumns' => array(
|
||||
'entityType' => array(
|
||||
|
||||
@@ -18,33 +18,35 @@
|
||||
*
|
||||
* 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 HasChildren extends \Espo\Core\Utils\Database\Orm\Base
|
||||
class HasChildren extends Base
|
||||
{
|
||||
|
||||
public function load($params, $foreignParams)
|
||||
protected function load($linkName, $entityName)
|
||||
{
|
||||
$foreignLinkName = $this->getForeignLinkName();
|
||||
$foreignEntityName = $this->getForeignEntityName();
|
||||
|
||||
return array(
|
||||
$params['entityName'] => array (
|
||||
$entityName => array (
|
||||
'fields' => array(
|
||||
$params['link']['name'].'Ids' => array(
|
||||
$linkName.'Ids' => array(
|
||||
'type' => 'varchar',
|
||||
'notStorable' => true,
|
||||
),
|
||||
$params['link']['name'].'Names' => array(
|
||||
$linkName.'Names' => array(
|
||||
'type' => 'varchar',
|
||||
'notStorable' => true,
|
||||
),
|
||||
),
|
||||
'relations' => array(
|
||||
$params['link']['name'] => array(
|
||||
$linkName => array(
|
||||
'type' => 'hasChildren',
|
||||
'entity' => $params['targetEntity'],
|
||||
'foreignKey' => $foreignParams['link']['name'].'Id', //???: 'foreignKey' => $params['link']['name'].'Id',
|
||||
'foreignType' => $foreignParams['link']['name'].'Type', //???: 'foreignKey' => $params['link']['name'].'Id',
|
||||
'entity' => $foreignEntityName,
|
||||
'foreignKey' => $foreignLinkName.'Id',
|
||||
'foreignType' => $foreignLinkName.'Type',
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
*
|
||||
* 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 HasMany extends \Espo\Core\Utils\Database\Orm\Base
|
||||
class HasMany extends Base
|
||||
{
|
||||
protected $allowParams = array(
|
||||
'relationName',
|
||||
@@ -30,32 +30,35 @@ class HasMany extends \Espo\Core\Utils\Database\Orm\Base
|
||||
'additionalColumns',
|
||||
);
|
||||
|
||||
public function load($params, $foreignParams)
|
||||
protected function load($linkName, $entityName)
|
||||
{
|
||||
$relationType = isset($params['link']['params']['relationName']) ? 'manyMany' : 'hasMany';
|
||||
$linkParams = $this->getLinkParams();
|
||||
$foreignLinkName = $this->getForeignLinkName();
|
||||
$foreignEntityName = $this->getForeignEntityName();
|
||||
|
||||
$relationType = isset($linkParams['relationName']) ? 'manyMany' : 'hasMany';
|
||||
|
||||
$relation = array(
|
||||
$params['entityName'] => array (
|
||||
$entityName => array (
|
||||
'fields' => array(
|
||||
$params['link']['name'].'Ids' => array(
|
||||
$linkName.'Ids' => array(
|
||||
'type' => 'varchar',
|
||||
'notStorable' => true,
|
||||
),
|
||||
$params['link']['name'].'Names' => array(
|
||||
$linkName.'Names' => array(
|
||||
'type' => 'varchar',
|
||||
'notStorable' => true,
|
||||
),
|
||||
),
|
||||
'relations' => array(
|
||||
$params['link']['name'] => array(
|
||||
//'type' => 'hasMany',
|
||||
$linkName => array(
|
||||
'type' => $relationType,
|
||||
'entity' => $params['targetEntity'],
|
||||
'foreignKey' => lcfirst($foreignParams['link']['name'].'Id'), //???: 'foreignKey' => $params['link']['name'].'Id',
|
||||
'entity' => $foreignEntityName,
|
||||
'foreignKey' => lcfirst($foreignLinkName.'Id'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
|
||||
return $relation;
|
||||
}
|
||||
|
||||
@@ -18,45 +18,46 @@
|
||||
*
|
||||
* 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;
|
||||
|
||||
use Espo\Core\Utils\Util;
|
||||
|
||||
class ManyMany extends \Espo\Core\Utils\Database\Orm\Base
|
||||
class ManyMany extends Base
|
||||
{
|
||||
|
||||
protected $allowParams = array(
|
||||
'relationName',
|
||||
'conditions',
|
||||
'additionalColumns',
|
||||
);
|
||||
|
||||
public function load($params, $foreignParams)
|
||||
protected function load($linkName, $entityName)
|
||||
{
|
||||
$foreignEntityName = $this->getForeignEntityName();
|
||||
|
||||
return array(
|
||||
$params['entityName'] => array(
|
||||
$entityName => array(
|
||||
'fields' => array(
|
||||
$params['link']['name'].'Ids' => array(
|
||||
$linkName.'Ids' => array(
|
||||
'type' => 'varchar',
|
||||
'notStorable' => true,
|
||||
),
|
||||
$params['link']['name'].'Names' => array(
|
||||
$linkName.'Names' => array(
|
||||
'type' => 'varchar',
|
||||
'notStorable' => true,
|
||||
),
|
||||
),
|
||||
'relations' => array(
|
||||
$params['link']['name'] => array(
|
||||
$linkName => array(
|
||||
'type' => 'manyMany',
|
||||
'entity' => $params['targetEntity'],
|
||||
'relationName' => $this->getJoinTable($params['entityName'], $foreignParams['entityName']),
|
||||
'entity' => $foreignEntityName,
|
||||
'relationName' => $this->getJoinTable($entityName, $foreignEntityName),
|
||||
'key' => 'id', //todo specify 'key'
|
||||
'foreignKey' => 'id', //todo specify 'foreignKey'
|
||||
'midKeys' => array(
|
||||
lcfirst($params['entityName']).'Id',
|
||||
lcfirst($foreignParams['entityName']).'Id',
|
||||
lcfirst($entityName).'Id',
|
||||
lcfirst($foreignEntityName).'Id',
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 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 NoteAttachments extends HasChildren
|
||||
{
|
||||
protected function load($linkName, $entityName)
|
||||
{
|
||||
$parentRelation = parent::load($linkName, $entityName);
|
||||
|
||||
$relation = array(
|
||||
$entityName => array (
|
||||
'fields' => array(
|
||||
$linkName.'Types' => array(
|
||||
'type' => 'varchar',
|
||||
'notStorable' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$relation = \Espo\Core\Utils\Util::merge($parentRelation, $relation);
|
||||
|
||||
return $relation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class Converter
|
||||
}
|
||||
|
||||
|
||||
public function process(array $ormMeta, $entityDefs, $entityList = array())
|
||||
public function process(array $ormMeta, $entityDefs, $entityList = null)
|
||||
{
|
||||
$GLOBALS['log']->debug('Schema\Converter - Start: building schema');
|
||||
|
||||
@@ -97,7 +97,7 @@ class Converter
|
||||
unset($ormMeta['unset']);
|
||||
} //END: unset some keys in orm
|
||||
|
||||
if (!empty($entityList)) {
|
||||
if (isset($entityList)) {
|
||||
$entityList = is_string($entityList) ? (array) $entityList : $entityList;
|
||||
|
||||
$dependentEntities = $this->getDependentEntities($entityList, $ormMeta);
|
||||
@@ -203,7 +203,6 @@ class Converter
|
||||
}
|
||||
//END: check and create columns/tables for relations
|
||||
|
||||
|
||||
$GLOBALS['log']->debug('Schema\Converter - End: building schema');
|
||||
|
||||
return $schema;
|
||||
@@ -276,6 +275,7 @@ class Converter
|
||||
switch ($fieldParams['type']) {
|
||||
case 'array':
|
||||
case 'jsonArray':
|
||||
case 'text':
|
||||
$dbFieldParams['default'] = ''; //for db type TEXT can't be defined a default value
|
||||
break;
|
||||
|
||||
@@ -361,4 +361,4 @@ class Converter
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ class Schema
|
||||
/*
|
||||
* Rebuild database schema
|
||||
*/
|
||||
public function rebuild($entityList = array())
|
||||
public function rebuild($entityList = null)
|
||||
{
|
||||
if ($this->getConverter()->process() === false) {
|
||||
return false;
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
|
||||
namespace Espo\Core\Utils;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
use \Espo\Core\Exceptions\Error,
|
||||
\Espo\Core\Exceptions\Conflict;
|
||||
|
||||
class FieldManager
|
||||
{
|
||||
@@ -74,7 +75,7 @@ class FieldManager
|
||||
{
|
||||
$existingField = $this->getFieldDef($name, $scope);
|
||||
if (isset($existingField)) {
|
||||
throw new Error('Field ['.$name.'] exists in '.$scope);
|
||||
throw new Conflict('Field ['.$name.'] exists in '.$scope);
|
||||
}
|
||||
|
||||
return $this->update($name, $fieldDef, $scope);
|
||||
@@ -165,7 +166,7 @@ class FieldManager
|
||||
}
|
||||
|
||||
foreach ($fieldDef as $defName => $defValue) {
|
||||
if (!isset($defValue)) {
|
||||
if (!isset($defValue) || (is_string($defValue) && $defValue == '') ) {
|
||||
unset($fieldDef[$defName]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,17 @@ class Manager
|
||||
{
|
||||
private $permission;
|
||||
|
||||
public function __construct(array $params = null)
|
||||
public function __construct(\Espo\Core\Utils\Config $config = null)
|
||||
{
|
||||
$this->permission = new Permission($params);
|
||||
$params = null;
|
||||
if (isset($config)) {
|
||||
$params = array(
|
||||
'defaultPermissions' => $config->get('defaultPermissions'),
|
||||
'permissionMap' => $config->get('permissionMap'),
|
||||
);
|
||||
}
|
||||
|
||||
$this->permission = new Permission($this, $params);
|
||||
}
|
||||
|
||||
public function getPermissionUtils()
|
||||
@@ -39,8 +47,6 @@ class Manager
|
||||
return $this->permission;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of files in specified directory
|
||||
*
|
||||
@@ -170,10 +176,15 @@ class Manager
|
||||
$fullPath = $this->concatPaths($path); //todo remove after changing the params
|
||||
|
||||
if ($this->checkCreateFile($fullPath) === false) {
|
||||
throw new Error('Permission denied in '. $path);
|
||||
throw new Error('Permission denied in '. $fullPath);
|
||||
}
|
||||
|
||||
return (file_put_contents($fullPath, $data, $flags, $context) !== FALSE);
|
||||
$res = (file_put_contents($fullPath, $data, $flags, $context) !== FALSE);
|
||||
if ($res && function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate($fullPath);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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\Utils\File;
|
||||
|
||||
@@ -27,71 +27,119 @@ use Espo\Core\Utils,
|
||||
|
||||
class Permission
|
||||
{
|
||||
private $fileManager;
|
||||
|
||||
/**
|
||||
* Last permission error
|
||||
*
|
||||
* @var array | string
|
||||
*/
|
||||
protected $permissionError = null;
|
||||
|
||||
protected $permissionErrorRules = null;
|
||||
|
||||
protected $params = array(
|
||||
'defaultPermissions' => array (
|
||||
'dir' => '0775',
|
||||
'file' => '0664',
|
||||
'user' => '',
|
||||
'group' => '',
|
||||
'dir' => '0775',
|
||||
'file' => '0664',
|
||||
'user' => '',
|
||||
'group' => '',
|
||||
),
|
||||
'permissionMap' => array(
|
||||
|
||||
/** array('0664', '0775') */
|
||||
'writable' => array(
|
||||
'data',
|
||||
'custom',
|
||||
),
|
||||
|
||||
/** array('0644', '0755') */
|
||||
'readable' => array(
|
||||
'api',
|
||||
'application',
|
||||
'client',
|
||||
'vendor',
|
||||
'index.php',
|
||||
'cron.php',
|
||||
'rebuild.php',
|
||||
'main.html',
|
||||
'reset.html',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
protected $permissionRules = array(
|
||||
'writable' => array('0664', '0775'),
|
||||
'readable' => array('0644', '0755'),
|
||||
);
|
||||
|
||||
public function __construct(array $params = null)
|
||||
|
||||
public function __construct(Manager $fileManager, array $params = null)
|
||||
{
|
||||
$this->fileManager = $fileManager;
|
||||
if (isset($params)) {
|
||||
$this->params = $params;
|
||||
}
|
||||
}
|
||||
|
||||
protected function getFileManager()
|
||||
{
|
||||
return $this->fileManager;
|
||||
}
|
||||
|
||||
protected function getParams()
|
||||
{
|
||||
return $this->params;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get default settings
|
||||
/**
|
||||
* Get default settings
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function getDefaultPermissions()
|
||||
public function getDefaultPermissions()
|
||||
{
|
||||
$params = $this->getParams();
|
||||
return $params['defaultPermissions'];
|
||||
}
|
||||
|
||||
|
||||
public function getPermissionRules()
|
||||
{
|
||||
return $this->permissionRules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default permission
|
||||
* Set default permission
|
||||
*
|
||||
* @param string $path
|
||||
* @param bool $recurse
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setDefaultPermissions($path, $recurse = false)
|
||||
public function setDefaultPermissions($path, $recurse = false)
|
||||
{
|
||||
if (!file_exists($path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$permission = $this->getDefaultPermissions();
|
||||
$permission = $this->getDefaultPermissions();
|
||||
|
||||
$result = $this->chmod($path, array($permission['file'], $permission['dir']), $recurse);
|
||||
$result = $this->chmod($path, array($permission['file'], $permission['dir']), $recurse);
|
||||
if (!empty($permission['user'])) {
|
||||
$result &= $this->chown($path, $permission['user'], $recurse);
|
||||
$result &= $this->chown($path, $permission['user'], $recurse);
|
||||
}
|
||||
if (!empty($permission['group'])) {
|
||||
$result &= $this->chgrp($path, $permission['group'], $recurse);
|
||||
$result &= $this->chgrp($path, $permission['group'], $recurse);
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get current permissions
|
||||
* Get current permissions
|
||||
*
|
||||
* @param string $filename
|
||||
* @return string | bool
|
||||
@@ -108,7 +156,7 @@ class Permission
|
||||
}
|
||||
|
||||
/**
|
||||
* Change permissions
|
||||
* Change permissions
|
||||
*
|
||||
* @param string $filename
|
||||
* @param int | array $octal - ex. 0755, array(0644, 0755), array('file'=>0644, 'dir'=>0755)
|
||||
@@ -118,7 +166,7 @@ class Permission
|
||||
*/
|
||||
public function chmod($path, $octal, $recurse = false)
|
||||
{
|
||||
if (!file_exists($path)) {
|
||||
if (!file_exists($path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -130,17 +178,17 @@ class Permission
|
||||
foreach ($octal as $key => $val) {
|
||||
$pKey= strval($key);
|
||||
if (!in_array($pKey, $rule)) {
|
||||
$pKey= $rule[$count];
|
||||
$pKey= $rule[$count];
|
||||
}
|
||||
|
||||
if (!empty($pKey)) {
|
||||
$permission[$pKey]= $val;
|
||||
$permission[$pKey]= $val;
|
||||
}
|
||||
$count++;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
elseif (is_int((int)$octal)) {
|
||||
$permission= array(
|
||||
$permission= array(
|
||||
'file' => $octal,
|
||||
'dir' => $octal,
|
||||
);
|
||||
@@ -152,25 +200,25 @@ class Permission
|
||||
//conver to octal value
|
||||
foreach($permission as $key => $val) {
|
||||
if (is_string($val)) {
|
||||
$permission[$key]= base_convert($val,8,10);
|
||||
$permission[$key]= base_convert($val,8,10);
|
||||
}
|
||||
}
|
||||
|
||||
//Set permission for non-recursive request
|
||||
if (!$recurse) {
|
||||
if (is_dir($path)) {
|
||||
return $this->chmodReal($path, $permission['dir']);
|
||||
return $this->chmodReal($path, $permission['dir']);
|
||||
}
|
||||
return $this->chmodReal($path, $permission['file']);
|
||||
return $this->chmodReal($path, $permission['file']);
|
||||
}
|
||||
|
||||
//Recursive permission
|
||||
return $this->chmodRecurse($path, $permission['file'], $permission['dir']);
|
||||
return $this->chmodRecurse($path, $permission['file'], $permission['dir']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change permissions recursive
|
||||
/**
|
||||
* Change permissions recursive
|
||||
*
|
||||
* @param string $filename
|
||||
* @param int $fileOctal - ex. 0644
|
||||
@@ -189,8 +237,7 @@ class Permission
|
||||
}
|
||||
|
||||
if (is_dir($path)) {
|
||||
$allFiles = scandir($path);
|
||||
$items = array_slice($allFiles, 2);
|
||||
$allFiles = $this->getFileManager()->getFileList($path);
|
||||
|
||||
foreach ($items as $item) {
|
||||
$this->chmodRecurse($path. Utils\Util::getSeparator() .$item, $fileOctal, $dirOctal);
|
||||
@@ -203,11 +250,11 @@ class Permission
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Change owner permission
|
||||
* Change owner permission
|
||||
*
|
||||
* @param string $path
|
||||
* @param int | string $user
|
||||
@@ -217,7 +264,7 @@ class Permission
|
||||
*/
|
||||
public function chown($path, $user='', $recurse=false)
|
||||
{
|
||||
if (!file_exists($path)) {
|
||||
if (!file_exists($path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -227,15 +274,15 @@ class Permission
|
||||
|
||||
//Set chown for non-recursive request
|
||||
if (!$recurse) {
|
||||
return $this->chownReal($path, $user);
|
||||
return $this->chownReal($path, $user);
|
||||
}
|
||||
|
||||
//Recursive chown
|
||||
return $this->chownRecurse($path, $user);
|
||||
return $this->chownRecurse($path, $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change owner permission recursive
|
||||
* Change owner permission recursive
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $user
|
||||
@@ -248,8 +295,7 @@ class Permission
|
||||
return false;
|
||||
}
|
||||
|
||||
$allFiles = scandir($path);
|
||||
$items = array_slice($allFiles, 2);
|
||||
$allFiles = $this->getFileManager()->getFileList($path);
|
||||
|
||||
foreach ($items as $item) {
|
||||
$this->chownRecurse($path. Utils\Util::getSeparator() .$item, $user);
|
||||
@@ -259,7 +305,7 @@ class Permission
|
||||
}
|
||||
|
||||
/**
|
||||
* Change group permission
|
||||
* Change group permission
|
||||
*
|
||||
* @param string $path
|
||||
* @param int | string $group
|
||||
@@ -269,7 +315,7 @@ class Permission
|
||||
*/
|
||||
public function chgrp($path, $group = null, $recurse = false)
|
||||
{
|
||||
if (!file_exists($path)) {
|
||||
if (!file_exists($path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -279,15 +325,15 @@ class Permission
|
||||
|
||||
//Set chgrp for non-recursive request
|
||||
if (!$recurse) {
|
||||
return $this->chgrpReal($path, $group);
|
||||
return $this->chgrpReal($path, $group);
|
||||
}
|
||||
|
||||
//Recursive chown
|
||||
return $this->chgrpRecurse($path, $group);
|
||||
return $this->chgrpRecurse($path, $group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change group permission recursive
|
||||
* Change group permission recursive
|
||||
*
|
||||
* @param string $filename
|
||||
* @param int $fileOctal - ex. 0644
|
||||
@@ -301,8 +347,7 @@ class Permission
|
||||
return false;
|
||||
}
|
||||
|
||||
$allFiles = scandir($path);
|
||||
$items = array_slice($allFiles, 2);
|
||||
$allFiles = $this->getFileManager()->getFileList($path);
|
||||
|
||||
foreach ($items as $item) {
|
||||
$this->chgrpRecurse($path. Utils\Util::getSeparator() .$item, $group);
|
||||
@@ -313,17 +358,17 @@ class Permission
|
||||
|
||||
|
||||
/**
|
||||
* Change permissions recursive
|
||||
* Change permissions recursive
|
||||
*
|
||||
* @param string $filename
|
||||
* @param int $mode - ex. 0644
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function chmodReal($filename, $mode)
|
||||
protected function chmodReal($filename, $mode)
|
||||
{
|
||||
try {
|
||||
$result = chmod($filename, $mode);
|
||||
$result = chmod($filename, $mode);
|
||||
} catch (\Exception $e) {
|
||||
$result = false;
|
||||
}
|
||||
@@ -333,39 +378,39 @@ class Permission
|
||||
$this->chgrp($filename, $this->getDefaultGroup(true));
|
||||
|
||||
try {
|
||||
$result = chmod($filename, $mode);
|
||||
$result = chmod($filename, $mode);
|
||||
} catch (\Exception $e) {
|
||||
throw new Error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function chownReal($path, $user)
|
||||
{
|
||||
try {
|
||||
$result = chown($path, $user);
|
||||
$result = chown($path, $user);
|
||||
} catch (\Exception $e) {
|
||||
throw new Error($e->getMessage());
|
||||
throw new Error($e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function chgrpReal($path, $group)
|
||||
{
|
||||
try {
|
||||
$result = chgrp($path, $group);
|
||||
$result = chgrp($path, $group);
|
||||
} catch (\Exception $e) {
|
||||
throw new Error($e->getMessage());
|
||||
throw new Error($e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default owner user
|
||||
* Get default owner user
|
||||
*
|
||||
* @return int - owner id
|
||||
*/
|
||||
@@ -374,19 +419,19 @@ class Permission
|
||||
$defaultPermissions = $this->getDefaultPermissions();
|
||||
|
||||
$owner = $defaultPermissions['user'];
|
||||
if (empty($owner) && $usePosix) {
|
||||
$owner = posix_getuid();
|
||||
}
|
||||
if (empty($owner) && $usePosix) {
|
||||
$owner = posix_getuid();
|
||||
}
|
||||
|
||||
if (empty($owner)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $owner;
|
||||
return $owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default group user
|
||||
* Get default group user
|
||||
*
|
||||
* @return int - group id
|
||||
*/
|
||||
@@ -395,15 +440,98 @@ class Permission
|
||||
$defaultPermissions = $this->getDefaultPermissions();
|
||||
|
||||
$group = $defaultPermissions['group'];
|
||||
if (empty($group) && $usePosix) {
|
||||
$group = posix_getegid();
|
||||
}
|
||||
if (empty($group) && $usePosix) {
|
||||
$group = posix_getegid();
|
||||
}
|
||||
|
||||
if (empty($group)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $group;
|
||||
return $group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set permission regarding defined in permissionMap
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setMapPermission($mode = null)
|
||||
{
|
||||
$this->permissionError = array();
|
||||
$this->permissionErrorRules = array();
|
||||
|
||||
$params = $this->getParams();
|
||||
|
||||
$permissionRules = $this->permissionRules;
|
||||
if (isset($mode)) {
|
||||
foreach ($permissionRules as &$value) {
|
||||
$value = $mode;
|
||||
}
|
||||
}
|
||||
|
||||
$result = true;
|
||||
foreach ($params['permissionMap'] as $type => $items) {
|
||||
|
||||
$permission = $permissionRules[$type];
|
||||
|
||||
foreach ($items as $item) {
|
||||
|
||||
if (file_exists($item)) {
|
||||
|
||||
try {
|
||||
$res = $this->chmod($item, $permission, true);
|
||||
} catch (\Exception $e) {
|
||||
$res = false;
|
||||
}
|
||||
|
||||
/** check is wtitable */
|
||||
if ($type == 'writable') {
|
||||
|
||||
$res &= is_writable($item);
|
||||
|
||||
if (is_dir($item)) {
|
||||
$name = uniqid();
|
||||
|
||||
try {
|
||||
$res &= $this->getFileManager()->putContents(array($item, $name), 'test');
|
||||
$res &= $this->getFileManager()->removeFile($name, $item);
|
||||
} catch (\Exception $e) {
|
||||
$res = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$res) {
|
||||
$result = false;
|
||||
$this->permissionError[] = $item;
|
||||
$this->permissionErrorRules[$item] = $permission;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get last permission error
|
||||
*
|
||||
* @return array | string
|
||||
*/
|
||||
public function getLastError()
|
||||
{
|
||||
return $this->permissionError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get last permission error rules
|
||||
*
|
||||
* @return array | string
|
||||
*/
|
||||
public function getLastErrorRules()
|
||||
{
|
||||
return $this->permissionErrorRules;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -142,6 +142,8 @@ class Language
|
||||
|
||||
if (is_array($translated) && isset($requiredOptions)) {
|
||||
|
||||
$translated = array_intersect_key($translated, array_flip($requiredOptions));
|
||||
|
||||
$optionKeys = array_keys($translated);
|
||||
foreach ($requiredOptions as $option) {
|
||||
if (!in_array($option, $optionKeys)) {
|
||||
@@ -152,6 +154,15 @@ class Language
|
||||
|
||||
return $translated;
|
||||
}
|
||||
|
||||
public function translateOption($value, $field, $scope)
|
||||
{
|
||||
$options = $this->get($scope. '.options.' . $field);
|
||||
if (array_key_exists($value, $options)) {
|
||||
return $options[$value];
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
public function get($key = null, $returns = null)
|
||||
|
||||
@@ -25,6 +25,7 @@ return array (
|
||||
array (
|
||||
'driver' => 'pdo_mysql',
|
||||
'host' => 'localhost',
|
||||
'port' => '',
|
||||
'dbname' => '',
|
||||
'user' => '',
|
||||
'password' => '',
|
||||
@@ -40,6 +41,7 @@ return array (
|
||||
'weekStart' => 0,
|
||||
'thousandSeparator' => ',',
|
||||
'decimalMark' => '.',
|
||||
'exportDelimiter' => ',',
|
||||
'currencyList' =>
|
||||
array (
|
||||
),
|
||||
@@ -60,8 +62,14 @@ return array (
|
||||
'smtpUsername' => '',
|
||||
'smtpPassword' => '',
|
||||
'languageList' => array(
|
||||
'en_US',
|
||||
'en_US',
|
||||
'de_DE',
|
||||
'es_ES',
|
||||
'fr_FR',
|
||||
'tr_TR',
|
||||
'ro_RO',
|
||||
'pt_BR',
|
||||
'vi_VN'
|
||||
),
|
||||
'language' => 'en_US',
|
||||
'logger' =>
|
||||
@@ -71,68 +79,17 @@ return array (
|
||||
'isRotate' => true, /** rotate log files every day */
|
||||
'maxRotateFiles' => 30, /** max number of rotate files */
|
||||
),
|
||||
'defaultPermissions' =>
|
||||
array (
|
||||
'dir' => '0775',
|
||||
'file' => '0664',
|
||||
'user' => '',
|
||||
'group' => '',
|
||||
),
|
||||
'cron' => array(
|
||||
'maxJobNumber' => 15, /** Max number of jobs per one execution */
|
||||
'jobPeriod' => 7800, /** Period for jobs, ex. if cron executed at 15:35, it will execute all pending jobs for times from 14:05 to 15:35 */
|
||||
'minExecutionTime' => 50, /** to avoid too frequency execution **/
|
||||
),
|
||||
'authenticationMethod' => 'Espo',
|
||||
'globalSearchEntityList' =>
|
||||
array (
|
||||
0 => 'Account',
|
||||
1 => 'Contact',
|
||||
2 => 'Lead',
|
||||
3 => 'Prospect',
|
||||
4 => 'Opportunity',
|
||||
),
|
||||
"tabList" => array("Account", "Contact", "Lead", "Opportunity", "Calendar", "Meeting", "Call", "Task", "Case", "Prospect", "Email"),
|
||||
"quickCreateList" => array("Account", "Contact", "Lead", "Opportunity", "Meeting", "Call", "Task", "Case", "Prospect"),
|
||||
'crud' => array(
|
||||
'get' => 'read',
|
||||
'post' => 'create',
|
||||
'put' => 'update',
|
||||
'patch' => 'patch',
|
||||
'delete' => 'delete',
|
||||
),
|
||||
'systemUser' => array(
|
||||
'id' => 'system',
|
||||
'userName' => 'system',
|
||||
'firstName' => '',
|
||||
'lastName' => 'System',
|
||||
),
|
||||
'systemItems' =>
|
||||
array (
|
||||
'systemItems',
|
||||
'adminItems',
|
||||
'configPath',
|
||||
'cachePath',
|
||||
'database',
|
||||
'crud',
|
||||
'logger',
|
||||
'isInstalled',
|
||||
'defaultPermissions',
|
||||
'systemUser',
|
||||
),
|
||||
'adminItems' =>
|
||||
array (
|
||||
'devMode',
|
||||
'outboundEmailIsShared',
|
||||
'outboundEmailFromName',
|
||||
'outboundEmailFromAddress',
|
||||
'smtpServer',
|
||||
'smtpPort',
|
||||
'smtpAuth',
|
||||
'smtpSecurity',
|
||||
'smtpUsername',
|
||||
'smtpPassword',
|
||||
'cron',
|
||||
3 => 'Opportunity',
|
||||
),
|
||||
"tabList" => array("Account", "Contact", "Lead", "Opportunity", "Calendar", "Meeting", "Call", "Task", "Case", "Email"),
|
||||
"quickCreateList" => array("Account", "Contact", "Lead", "Opportunity", "Meeting", "Call", "Task", "Case"),
|
||||
'calendarDefaultEntity' => 'Meeting',
|
||||
'isInstalled' => false,
|
||||
);
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"name":"name"},{"name":"email","type":"base","sortable":false,"params":{}},{"name":"city"}]
|
||||
[{"name":"name"}]
|
||||
|
||||
119
application/Espo/Core/defaults/systemConfig.php
Normal file
119
application/Espo/Core/defaults/systemConfig.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 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 (
|
||||
'defaultPermissions' =>
|
||||
array (
|
||||
'dir' => '0775',
|
||||
'file' => '0664',
|
||||
'user' => '',
|
||||
'group' => '',
|
||||
),
|
||||
|
||||
'permissionMap' => array(
|
||||
|
||||
/** array('0664', '0775') */
|
||||
'writable' => array(
|
||||
'data',
|
||||
'custom',
|
||||
),
|
||||
|
||||
/** array('0644', '0755') */
|
||||
'readable' => array(
|
||||
'api',
|
||||
'application',
|
||||
'client',
|
||||
'vendor',
|
||||
'index.php',
|
||||
'cron.php',
|
||||
'rebuild.php',
|
||||
'main.html',
|
||||
'reset.html',
|
||||
),
|
||||
),
|
||||
'cron' => array(
|
||||
'maxJobNumber' => 15, /** Max number of jobs per one execution */
|
||||
'jobPeriod' => 7800, /** Period for jobs, ex. if cron executed at 15:35, it will execute all pending jobs for times from 14:05 to 15:35 */
|
||||
'minExecutionTime' => 50, /** to avoid too frequency execution **/
|
||||
),
|
||||
'crud' => array(
|
||||
'get' => 'read',
|
||||
'post' => 'create',
|
||||
'put' => 'update',
|
||||
'patch' => 'patch',
|
||||
'delete' => 'delete',
|
||||
),
|
||||
'systemUser' => array(
|
||||
'id' => 'system',
|
||||
'userName' => 'system',
|
||||
'firstName' => '',
|
||||
'lastName' => 'System',
|
||||
),
|
||||
'systemItems' =>
|
||||
array (
|
||||
'systemItems',
|
||||
'adminItems',
|
||||
'configPath',
|
||||
'cachePath',
|
||||
'database',
|
||||
'crud',
|
||||
'logger',
|
||||
'isInstalled',
|
||||
'defaultPermissions',
|
||||
'systemUser',
|
||||
'permissionMap',
|
||||
'permissionRules',
|
||||
),
|
||||
'adminItems' =>
|
||||
array (
|
||||
'devMode',
|
||||
'outboundEmailIsShared',
|
||||
'outboundEmailFromName',
|
||||
'outboundEmailFromAddress',
|
||||
'smtpServer',
|
||||
'smtpPort',
|
||||
'smtpAuth',
|
||||
'smtpSecurity',
|
||||
'smtpUsername',
|
||||
'smtpPassword',
|
||||
'cron',
|
||||
'authenticationMethod',
|
||||
'ldapHost',
|
||||
'ldapPort',
|
||||
'ldapSecurity',
|
||||
'ldapAuth',
|
||||
'ldapUsername',
|
||||
'ldapPassword',
|
||||
'ldapBindRequiresDn',
|
||||
'ldapBaseDn',
|
||||
'ldapUserLoginFilter',
|
||||
'ldapAccountCanonicalForm',
|
||||
'ldapAccountDomainName',
|
||||
'ldapAccountDomainNameShort',
|
||||
'ldapAccountFilterFormat',
|
||||
'ldapTryUsernameSplit',
|
||||
'ldapOptReferrals',
|
||||
'ldapCreateEspoUser',
|
||||
),
|
||||
'isInstalled' => false,
|
||||
);
|
||||
|
||||
29
application/Espo/Entities/AuthToken.php
Normal file
29
application/Espo/Entities/AuthToken.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 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 AuthToken extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -24,5 +24,21 @@ namespace Espo\Entities;
|
||||
|
||||
class Note extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
|
||||
public function loadAttachments()
|
||||
{
|
||||
$collection = $this->get('attachments');
|
||||
$ids = array();
|
||||
$names = new \stdClass();
|
||||
$types = new \stdClass();
|
||||
foreach ($collection as $e) {
|
||||
$id = $e->id;
|
||||
$ids[] = $id;
|
||||
$names->$id = $e->get('name');
|
||||
$types->$id = $e->get('type');
|
||||
}
|
||||
$this->set('attachmentsIds', $ids);
|
||||
$this->set('attachmentsNames', $names);
|
||||
$this->set('attachmentsTypes', $types);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,21 +18,20 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
************************************************************************/
|
||||
|
||||
ob_start();
|
||||
$result = array('success' => false, 'errors' => array());
|
||||
namespace Espo\Entities;
|
||||
|
||||
if (!empty($_REQUEST['url'])) {
|
||||
if ($installer->fixAjaxPermission($_REQUEST['url'])) {
|
||||
$result['success'] = true;
|
||||
}
|
||||
else {
|
||||
$result['success'] = false;
|
||||
$result['errorMsg'] = $_REQUEST['url'];
|
||||
$result['errorFixInstruction'] = $systemHelper->getPermissionCommands('', array('644', '755'));
|
||||
use Espo\Core\Exceptions\Error;
|
||||
|
||||
class PhoneNumber extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
protected function setName($value)
|
||||
{
|
||||
if (empty($value)) {
|
||||
throw new Error("Phone number can't be empty");
|
||||
}
|
||||
$this->valuesContainer['name'] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
ob_clean();
|
||||
echo json_encode($result);
|
||||
@@ -25,19 +25,45 @@ namespace Espo\EntryPoints;
|
||||
use \Espo\Core\Exceptions\NotFound;
|
||||
use \Espo\Core\Exceptions\Forbidden;
|
||||
use \Espo\Core\Exceptions\BadRequest;
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
|
||||
class Image extends \Espo\Core\EntryPoints\Base
|
||||
{
|
||||
public static $authRequired = false;
|
||||
public static $authRequired = true;
|
||||
|
||||
protected $allowedFileTypes = array(
|
||||
'image/jpeg',
|
||||
'image/png',
|
||||
'image/gif',
|
||||
);
|
||||
|
||||
protected $imageSizes = array(
|
||||
'x-small' => array(64, 64),
|
||||
'small' => array(128, 128),
|
||||
'medium' => array(256, 256),
|
||||
'large' => array(512, 512),
|
||||
'x-large' => array(864, 864),
|
||||
'xx-large' => array(1024, 1024),
|
||||
);
|
||||
|
||||
|
||||
public function run()
|
||||
{
|
||||
|
||||
{
|
||||
$id = $_GET['id'];
|
||||
if (empty($id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
}
|
||||
|
||||
$size = null;
|
||||
if (!empty($_GET['size'])) {
|
||||
$size = $_GET['size'];
|
||||
}
|
||||
|
||||
$this->show($id, $size);
|
||||
}
|
||||
|
||||
protected function show($id, $size)
|
||||
{
|
||||
$attachment = $this->getEntityManager()->getEntity('Attachment', $id);
|
||||
|
||||
if (!$attachment) {
|
||||
@@ -51,29 +77,118 @@ class Image extends \Espo\Core\EntryPoints\Base
|
||||
}
|
||||
}
|
||||
|
||||
$fileName = "data/upload/{$attachment->id}";
|
||||
$filePath = "data/upload/{$attachment->id}";
|
||||
|
||||
if (!file_exists($fileName)) {
|
||||
$fileType = $attachment->get('type');
|
||||
|
||||
if (!file_exists($filePath)) {
|
||||
throw new NotFound();
|
||||
}
|
||||
|
||||
if (!$attachment->get('global')) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($attachment->get('type')) {
|
||||
header('Content-Type: ' . $attachment->get('type'));
|
||||
if (!in_array($fileType, $this->allowedFileTypes)) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
|
||||
if (!empty($size)) {
|
||||
if (!empty($this->imageSizes[$size])) {
|
||||
$thumbFilePath = "data/upload/thumbs/{$attachment->id}_{$size}";
|
||||
|
||||
if (!file_exists($thumbFilePath)) {
|
||||
$targetImage = $this->getThumbImage($filePath, $fileType, $size);
|
||||
ob_start();
|
||||
|
||||
switch ($fileType) {
|
||||
case 'image/jpeg':
|
||||
imagejpeg($targetImage);
|
||||
break;
|
||||
case 'image/png':
|
||||
imagepng($targetImage);
|
||||
break;
|
||||
case 'image/gif':
|
||||
imagegif($targetImage);
|
||||
break;
|
||||
}
|
||||
$contents = ob_get_contents();
|
||||
ob_end_clean();
|
||||
imagedestroy($targetImage);
|
||||
$this->getContainer()->get('fileManager')->putContents($thumbFilePath, $contents);
|
||||
}
|
||||
$filePath = $thumbFilePath;
|
||||
|
||||
} else {
|
||||
throw new Error();
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($size)) {
|
||||
$fileName = $attachment->id . '_' . $size . '.jpg';
|
||||
} else {
|
||||
$fileName = $attachment->get('name');
|
||||
}
|
||||
header('Content-Disposition:inline;filename="'.$fileName.'"');
|
||||
if (!empty($fileType)) {
|
||||
header('Content-Type: ' . $fileType);
|
||||
}
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . filesize($fileName));
|
||||
$fileSize = filesize($filePath);
|
||||
if ($fileSize) {
|
||||
header('Content-Length: ' . $fileSize);
|
||||
}
|
||||
ob_clean();
|
||||
flush();
|
||||
readfile($fileName);
|
||||
exit;
|
||||
}
|
||||
readfile($filePath);
|
||||
exit;
|
||||
}
|
||||
|
||||
protected function getThumbImage($filePath, $fileType, $size)
|
||||
{
|
||||
list($originalWidth, $originalHeight) = getimagesize($filePath);
|
||||
list($width, $height) = $this->imageSizes[$size];
|
||||
|
||||
|
||||
if ($originalWidth <= $width && $originalHeight <= $height) {
|
||||
$targetWidth = $originalWidth;
|
||||
$targetHeight = $originalHeight;
|
||||
} else {
|
||||
if ($originalWidth > $originalHeight) {
|
||||
$targetWidth = $width;
|
||||
$targetHeight = $originalHeight / ($originalWidth / $width);
|
||||
if ($targetHeight > $height) {
|
||||
$targetHeight = $height;
|
||||
$targetWidth = $originalWidth / ($originalHeight / $height);
|
||||
}
|
||||
} else {
|
||||
$targetHeight = $height;
|
||||
$targetWidth = $originalWidth / ($originalHeight / $height);
|
||||
if ($targetWidth > $width) {
|
||||
$targetWidth = $width;
|
||||
$targetHeight = $originalHeight / ($originalWidth / $width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$targetImage = imagecreatetruecolor($targetWidth, $targetHeight);
|
||||
switch ($fileType) {
|
||||
case 'image/jpeg':
|
||||
$sourceImage = imagecreatefromjpeg($filePath);
|
||||
imagecopyresized($targetImage, $sourceImage, 0, 0, 0, 0, $targetWidth, $targetHeight, $originalWidth, $originalHeight);
|
||||
break;
|
||||
case 'image/png':
|
||||
$sourceImage = imagecreatefrompng($filePath);
|
||||
imagealphablending($targetImage, false);
|
||||
imagesavealpha($targetImage, true);
|
||||
$transparent = imagecolorallocatealpha($targetImage, 255, 255, 255, 127);
|
||||
imagefilledrectangle($targetImage, 0, 0, $targetWidth, $targetHeight, $transparent);
|
||||
imagecopyresampled($targetImage, $sourceImage, 0, 0, 0, 0, $targetWidth, $targetHeight, $originalWidth, $originalHeight);
|
||||
break;
|
||||
case 'image/gif':
|
||||
$sourceImage = imagecreatefromgif($filePath);
|
||||
imagecopyresized($targetImage, $sourceImage, 0, 0, 0, 0, $targetWidth, $targetHeight, $originalWidth, $originalHeight);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return $targetImage;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
52
application/Espo/EntryPoints/LogoImage.php
Normal file
52
application/Espo/EntryPoints/LogoImage.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 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\EntryPoints;
|
||||
|
||||
use \Espo\Core\Exceptions\NotFound;
|
||||
use \Espo\Core\Exceptions\Forbidden;
|
||||
use \Espo\Core\Exceptions\BadRequest;
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
|
||||
class LogoImage extends Image
|
||||
{
|
||||
public static $authRequired = false;
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->imageSizes['small-logo'] = array(173, 38);
|
||||
|
||||
$id = $this->getConfig()->get('companyLogoId');
|
||||
|
||||
if (empty($id)) {
|
||||
throw new NotFound();
|
||||
}
|
||||
|
||||
$size = null;
|
||||
if (!empty($_GET['size'])) {
|
||||
$size = $_GET['size'];
|
||||
}
|
||||
|
||||
$this->show($id, $size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,11 +53,25 @@ class Notifications extends \Espo\Core\Hooks\Base
|
||||
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']) {
|
||||
$this->getNotificationService()->notifyAboutNote($row['userId'], $entity->id);
|
||||
$userIdList[] = $row['userId'];
|
||||
}
|
||||
}
|
||||
if (!empty($userIdList)) {
|
||||
$job = $this->getEntityManager()->getEntity('Job');
|
||||
$job->set(array(
|
||||
'serviceName' => 'Notification',
|
||||
'method' => 'notifyAboutNoteFromJob',
|
||||
'data' => json_encode(array(
|
||||
'userIdList' => $userIdList,
|
||||
'noteId' => $entity->id
|
||||
)),
|
||||
'executeTime' => date('Y-m-d H:i:s'),
|
||||
));
|
||||
$this->getEntityManager()->saveEntity($job);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,13 +32,14 @@ class InboundEmail extends \Espo\Core\Controllers\Record
|
||||
}
|
||||
|
||||
public function actionGetFolders($params, $data, $request)
|
||||
{
|
||||
{
|
||||
return $this->getRecordService()->getFolders(array(
|
||||
'host' => $request->get('host'),
|
||||
'port' => $request->get('port'),
|
||||
'ssl' => $request->get('ssl'),
|
||||
'username' => $request->get('username'),
|
||||
'password' => $request->get('password'),
|
||||
'id' => $request->get('id')
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Espo\Modules\Crm\Controllers;
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
use \Espo\Core\Exceptions\BadRequest;
|
||||
|
||||
class Prospect extends \Espo\Core\Controllers\Record
|
||||
class Target extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
|
||||
public function actionConvert($params, $data)
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
namespace Espo\Modules\Crm\Entities;
|
||||
|
||||
class Prospect extends \Espo\Core\Entities\Person
|
||||
class Target extends \Espo\Core\Entities\Person
|
||||
{
|
||||
|
||||
}
|
||||
50
application/Espo/Modules/Crm/Repositories/Call.php
Normal file
50
application/Espo/Modules/Crm/Repositories/Call.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 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\Modules\Crm\Repositories;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
class Call extends \Espo\Core\ORM\Repositories\RDB
|
||||
{
|
||||
protected function beforeSave(Entity $entity)
|
||||
{
|
||||
parent::beforeSave($entity);
|
||||
|
||||
$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') {
|
||||
$accountId = $parent->id;
|
||||
} else if ($parent->has('accountId')) {
|
||||
$accountId = $parent->get('accountId');
|
||||
}
|
||||
if (!empty($accountId)) {
|
||||
$entity->set('accountId', $accountId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
95
application/Espo/Modules/Crm/Repositories/Contact.php
Normal file
95
application/Espo/Modules/Crm/Repositories/Contact.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 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\Modules\Crm\Repositories;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
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 save(Entity $entity)
|
||||
{
|
||||
$result = parent::save($entity);
|
||||
|
||||
$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)) {
|
||||
$this->unrelate($entity, 'accounts', $entity->getFetched('accountId'));
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
if ($titleChanged) {
|
||||
if (empty($accountId)) {
|
||||
$accountId = $entity->getFetched('accountId');
|
||||
if (empty($accountId)) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($accountIdChanged || $titleChanged) {
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
|
||||
$sql = "
|
||||
SELECT id, role FROM account_contact
|
||||
WHERE
|
||||
account_id = ".$pdo->quote($accountId)." AND
|
||||
contact_id = ".$pdo->quote($entity->id)." AND
|
||||
deleted = 0
|
||||
";
|
||||
$sth = $pdo->prepare($sql);
|
||||
if ($row = $sth->fetch()) {
|
||||
if ($titleChanged && $entity->get('title') != $row['role']) {
|
||||
$this->updateRelation($entity, 'accounts', $accountId, array(
|
||||
'role' => $entity->get('title')
|
||||
));
|
||||
}
|
||||
} else {
|
||||
$this->relate($entity, 'accounts', $accountId, array(
|
||||
'role' => $entity->get('title')
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
50
application/Espo/Modules/Crm/Repositories/Meeting.php
Normal file
50
application/Espo/Modules/Crm/Repositories/Meeting.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 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\Modules\Crm\Repositories;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
class Meeting extends \Espo\Core\ORM\Repositories\RDB
|
||||
{
|
||||
protected function beforeSave(Entity $entity)
|
||||
{
|
||||
parent::beforeSave($entity);
|
||||
|
||||
$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') {
|
||||
$accountId = $parent->id;
|
||||
} else if ($parent->has('accountId')) {
|
||||
$accountId = $parent->get('accountId');
|
||||
}
|
||||
if (!empty($accountId)) {
|
||||
$entity->set('accountId', $accountId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
"name": "Name",
|
||||
"emailAddress": "E-Mail",
|
||||
"website": "Webseite",
|
||||
"phone": "Telefon",
|
||||
"fax": "Fax",
|
||||
"phoneNumber": "Telefon",
|
||||
"billingAddress": "Rechnungsadresse",
|
||||
"shippingAddress": "Lieferadresse",
|
||||
"description": "Beschreibung",
|
||||
"sicCode": "WKN Nummer",
|
||||
"industry": "Branche",
|
||||
"type": "Typ"
|
||||
"type": "Typ",
|
||||
"contactRole": "Rolle"
|
||||
},
|
||||
"links": {
|
||||
"contacts": "Kontakte",
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
"emailAddress": "E-Mail",
|
||||
"title": "Funktion",
|
||||
"account": "Firma",
|
||||
"phone": "Telefon",
|
||||
"phoneOffice": "Phone (Office)",
|
||||
"fax": "Fax",
|
||||
"accounts": "Firmen",
|
||||
"phoneNumber": "Telefon",
|
||||
"accountType": "Firmentyp",
|
||||
"doNotCall": "Nicht anrufen",
|
||||
"address": "Adresse",
|
||||
"description": "Beschreibung"
|
||||
"opportunityRole": "Opportunity Role",
|
||||
"accountRole": "Rolle",
|
||||
"description": "Beschreibung"
|
||||
},
|
||||
"links": {
|
||||
"opportunities": "Verkaufschancen",
|
||||
@@ -18,5 +19,13 @@
|
||||
},
|
||||
"labels": {
|
||||
"Create Contact": "Neuer Kontakt"
|
||||
},
|
||||
"options": {
|
||||
"opportunityRole": {
|
||||
"": "--None--",
|
||||
"Decision Maker": "Decision Maker",
|
||||
"Evaluator": "Evaluator",
|
||||
"Influencer": "Influencer"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"Account": "Firma",
|
||||
"Contact": "Kontakt",
|
||||
"Lead": "Interessent",
|
||||
"Prospect": "Zielkontakt",
|
||||
"Target": "Zielkontakt",
|
||||
"Opportunity": "Verkaufschance",
|
||||
"Meeting": "Meeting",
|
||||
"Calendar": "Kalender",
|
||||
@@ -16,7 +16,7 @@
|
||||
"Account": "Firmen",
|
||||
"Contact": "Kontakte",
|
||||
"Lead": "Interessenten",
|
||||
"Prospect": "Zielkontakte",
|
||||
"Target": "Targets",
|
||||
"Opportunity": "Verkaufschancen",
|
||||
"Meeting": "Meetings",
|
||||
"Calendar": "Kalender",
|
||||
|
||||
@@ -36,5 +36,8 @@
|
||||
"IMAP": "IMAP",
|
||||
"Actions": "Aktionen",
|
||||
"Main": "Wichtig"
|
||||
},
|
||||
"messages": {
|
||||
"couldNotConnectToImap": "Kann keine Verbindung zum IMAP Server herstellen"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,7 @@
|
||||
"emailAddress": "E-Mail",
|
||||
"title": "Funktion",
|
||||
"website": "Webseite",
|
||||
"phone": "Telefon",
|
||||
"phoneOffice": "Phone (Office)",
|
||||
"fax": "Fax",
|
||||
"phoneNumber": "Telefon",
|
||||
"accountName": "Firmenname",
|
||||
"doNotCall": "Nicht anrufen",
|
||||
"address": "Adresse",
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"leadSource": "Quelle",
|
||||
"doNotCall": "Nicht anrufen",
|
||||
"closeDate": "Abschlussdatum",
|
||||
"contacts": "Kontakte",
|
||||
"description": "Beschreibung"
|
||||
},
|
||||
"links": {
|
||||
@@ -19,22 +20,12 @@
|
||||
"Qualification": "Qualifikation",
|
||||
"Needs Analysis": "Bedarfserhebung",
|
||||
"Value Proposition": "Richtangebot",
|
||||
"Id. Decision Makers": "id. Entscheider",
|
||||
"Id. Decision Makers": "Entscheider ident.",
|
||||
"Perception Analysis": "Analyse Sichtweise",
|
||||
"Proposal/Price Quote": "Preisangebot",
|
||||
"Negotiation/Review": "Verhandlung/Überarbeitung",
|
||||
"Closed Won": "Gewonnen",
|
||||
"Closed Lost": "Verloren"
|
||||
},
|
||||
"leadSource": {
|
||||
"Call": "Anruf",
|
||||
"Email": "E-Mail",
|
||||
"Existing Customer": "Bestehender Kunde",
|
||||
"Partner": "Partner",
|
||||
"Public Relations": "Public Relations",
|
||||
"Web Site": "Web Seite",
|
||||
"Campaign": "Kampagne",
|
||||
"Other": "Andere"
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
"title": "Funktion",
|
||||
"website": "Webseite",
|
||||
"accountName": "Firmenname",
|
||||
"phone": "Telefon",
|
||||
"phoneOffice": "Phone (Office)",
|
||||
"fax": "Fax",
|
||||
"phoneNumber": "Telefon",
|
||||
"doNotCall": "Nicht anrufen",
|
||||
"address": "Adresse",
|
||||
"description": "Beschreibung"
|
||||
@@ -15,7 +13,7 @@
|
||||
"links": {
|
||||
},
|
||||
"labels": {
|
||||
"Create Prospect": "Neuer Zielkontakt",
|
||||
"Create Target": "Create Target",
|
||||
"Convert to Lead": "Zu Interessent umwandeln"
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,14 @@
|
||||
"name": "Name",
|
||||
"emailAddress": "Email",
|
||||
"website": "Website",
|
||||
"phone": "Phone",
|
||||
"fax": "Fax",
|
||||
"phoneNumber": "Phone",
|
||||
"billingAddress": "Billing Address",
|
||||
"shippingAddress": "Shipping Address",
|
||||
"description": "Description",
|
||||
"sicCode": "Sic Code",
|
||||
"industry": "Industry",
|
||||
"type": "Type"
|
||||
"type": "Type",
|
||||
"contactRole": "Role"
|
||||
},
|
||||
"links": {
|
||||
"contacts": "Contacts",
|
||||
|
||||
@@ -30,5 +30,10 @@
|
||||
"Set Held": "Set Held",
|
||||
"Set Not Held": "Set Not Held",
|
||||
"Send Invitations": "Send Invitations"
|
||||
},
|
||||
"presetFilters": {
|
||||
"planned": "Planned",
|
||||
"held": "Held",
|
||||
"todays": "Today's"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,5 +34,9 @@
|
||||
},
|
||||
"labels": {
|
||||
"Create Case": "Create Case"
|
||||
},
|
||||
"presetFilters": {
|
||||
"open": "Open",
|
||||
"closed": "Closed"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
"emailAddress": "Email",
|
||||
"title": "Title",
|
||||
"account": "Account",
|
||||
"phone": "Phone",
|
||||
"phoneOffice": "Phone (Office)",
|
||||
"fax": "Fax",
|
||||
"accounts": "Accounts",
|
||||
"phoneNumber": "Phone",
|
||||
"accountType": "Account Type",
|
||||
"doNotCall": "Do Not Call",
|
||||
"address": "Address",
|
||||
"description": "Description"
|
||||
"opportunityRole": "Opportunity Role",
|
||||
"accountRole": "Role",
|
||||
"description": "Description"
|
||||
},
|
||||
"links": {
|
||||
"opportunities": "Opportunities",
|
||||
@@ -18,5 +19,13 @@
|
||||
},
|
||||
"labels": {
|
||||
"Create Contact": "Create Contact"
|
||||
},
|
||||
"options": {
|
||||
"opportunityRole": {
|
||||
"": "--None--",
|
||||
"Decision Maker": "Decision Maker",
|
||||
"Evaluator": "Evaluator",
|
||||
"Influencer": "Influencer"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"Account": "Account",
|
||||
"Contact": "Contact",
|
||||
"Lead": "Lead",
|
||||
"Prospect": "Prospect",
|
||||
"Target": "Target",
|
||||
"Opportunity": "Opportunity",
|
||||
"Meeting": "Meeting",
|
||||
"Calendar": "Calendar",
|
||||
@@ -16,7 +16,7 @@
|
||||
"Account": "Accounts",
|
||||
"Contact": "Contacts",
|
||||
"Lead": "Leads",
|
||||
"Prospect": "Prospects",
|
||||
"Target": "Targets",
|
||||
"Opportunity": "Opportunities",
|
||||
"Meeting": "Meetings",
|
||||
"Calendar": "Calendar",
|
||||
|
||||
@@ -36,5 +36,8 @@
|
||||
"IMAP": "IMAP",
|
||||
"Actions": "Actions",
|
||||
"Main": "Main"
|
||||
},
|
||||
"messages": {
|
||||
"couldNotConnectToImap": "Could not connect to IMAP server"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,7 @@
|
||||
"emailAddress": "Email",
|
||||
"title": "Title",
|
||||
"website": "Website",
|
||||
"phone": "Phone",
|
||||
"phoneOffice": "Phone (Office)",
|
||||
"fax": "Fax",
|
||||
"phoneNumber": "Phone",
|
||||
"accountName": "Account Name",
|
||||
"doNotCall": "Do Not Call",
|
||||
"address": "Address",
|
||||
@@ -44,5 +42,8 @@
|
||||
"Campaign": "Campaign",
|
||||
"Other": "Other"
|
||||
}
|
||||
},
|
||||
"presetFilters": {
|
||||
"active": "Active"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,13 @@
|
||||
"Create Meeting": "Create Meeting",
|
||||
"Set Held": "Set Held",
|
||||
"Set Not Held": "Set Not Held",
|
||||
"Send Invitations": "Send Invitations"
|
||||
"Send Invitations": "Send Invitations",
|
||||
"Saved as Held": "Saved as Held",
|
||||
"Saved as Not Held": "Saved as Not Held"
|
||||
},
|
||||
"presetFilters": {
|
||||
"planned": "Planned",
|
||||
"held": "Held",
|
||||
"todays": "Today's"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
"account": "Account",
|
||||
"stage": "Stage",
|
||||
"amount": "Amount",
|
||||
"probability": "Probability",
|
||||
"probability": "Probability, %",
|
||||
"leadSource": "Lead Source",
|
||||
"doNotCall": "Do Not Call",
|
||||
"closeDate": "Close Date",
|
||||
"contacts": "Contacts",
|
||||
"description": "Description"
|
||||
},
|
||||
"links": {
|
||||
@@ -25,19 +26,13 @@
|
||||
"Negotiation/Review": "Negotiation/Review",
|
||||
"Closed Won": "Closed Won",
|
||||
"Closed Lost": "Closed Lost"
|
||||
},
|
||||
"leadSource": {
|
||||
"Call": "Call",
|
||||
"Email": "Email",
|
||||
"Existing Customer": "Existing Customer",
|
||||
"Partner": "Partner",
|
||||
"Public Relations": "Public Relations",
|
||||
"Web Site": "Web Site",
|
||||
"Campaign": "Campaign",
|
||||
"Other": "Other"
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"Create Opportunity": "Create Opportunity"
|
||||
},
|
||||
"presetFilters": {
|
||||
"open": "Open",
|
||||
"won": "Won"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
"title": "Title",
|
||||
"website": "Website",
|
||||
"accountName": "Account Name",
|
||||
"phone": "Phone",
|
||||
"phoneOffice": "Phone (Office)",
|
||||
"fax": "Fax",
|
||||
"phoneNumber": "Phone",
|
||||
"doNotCall": "Do Not Call",
|
||||
"address": "Address",
|
||||
"description": "Description"
|
||||
@@ -15,7 +13,7 @@
|
||||
"links": {
|
||||
},
|
||||
"labels": {
|
||||
"Create Prospect": "Create Prospect",
|
||||
"Create Target": "Create Target",
|
||||
"Convert to Lead": "Convert to Lead"
|
||||
}
|
||||
}
|
||||
@@ -27,5 +27,11 @@
|
||||
},
|
||||
"labels": {
|
||||
"Create Task": "Create Task"
|
||||
},
|
||||
"presetFilters": {
|
||||
"active": "Active",
|
||||
"completed": "Completed",
|
||||
"todays": "Today's",
|
||||
"overdue": "Overdue"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"fields": {
|
||||
"name": "Nombre",
|
||||
"emailAddress": "Correo electrónico",
|
||||
"website": "Sito Web",
|
||||
"phone": "Teléfono",
|
||||
"fax": "Fax",
|
||||
"billingAddress": "Dirección de Facturación",
|
||||
"shippingAddress": "Dirección de Envío",
|
||||
"description": "Descripción",
|
||||
"sicCode": "Sic Code",
|
||||
"industry": "Industria",
|
||||
"type": "Tipo"
|
||||
},
|
||||
"links": {
|
||||
"contacts": "Contactos",
|
||||
"opportunities": "Oportunidades",
|
||||
"cases": "Casos"
|
||||
},
|
||||
"options": {
|
||||
"type": {
|
||||
"Customer": "Cliente",
|
||||
"Investor": "Inversor",
|
||||
"Partner": "Partner",
|
||||
"Reseller": "REvendedor"
|
||||
},
|
||||
"industry": {
|
||||
"Apparel": "Apparel",
|
||||
"Banking": "Banking",
|
||||
"Computer Software": "Software",
|
||||
"Education": "Educación",
|
||||
"Electronics": "Electrónicos",
|
||||
"Finance": "Finanzas",
|
||||
"Insurance": "Seguros"
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"Create Account": "Crear Cuenta"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"modes": {
|
||||
"month": "Mes",
|
||||
"week": "Semana",
|
||||
"day": "Día",
|
||||
"agendaWeek": "Semana",
|
||||
"agendaDay": "Día"
|
||||
},
|
||||
"labels": {
|
||||
"Today": "Hoy",
|
||||
"Create": "Crear"
|
||||
}
|
||||
}
|
||||
34
application/Espo/Modules/Crm/Resources/i18n/es_ES/Call.json
Normal file
34
application/Espo/Modules/Crm/Resources/i18n/es_ES/Call.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"fields": {
|
||||
"name": "Nombre",
|
||||
"parent": "Padre",
|
||||
"status": "Estado",
|
||||
"dateStart": "Fecha de Comienzo",
|
||||
"dateEnd": "Fecha de Finalización",
|
||||
"direction": "Dirección",
|
||||
"duration": "Duración",
|
||||
"description": "Descripción",
|
||||
"users": "Usuarios",
|
||||
"contacts": "Contactos",
|
||||
"leads": "Potenciales"
|
||||
},
|
||||
"links": {
|
||||
},
|
||||
"options": {
|
||||
"status": {
|
||||
"Planned": "Planeada",
|
||||
"Held": "Celebrada",
|
||||
"Not Held": "Sin Celebrar"
|
||||
},
|
||||
"direction": {
|
||||
"Outbound": "Saliente",
|
||||
"Inbound": "Entrante"
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"Create Call": "Crear Llamada",
|
||||
"Set Held": "Establecer Celebrada",
|
||||
"Set Not Held": "Establecer no Celebrada",
|
||||
"Send Invitations": "Enviar Invitaciones"
|
||||
}
|
||||
}
|
||||
38
application/Espo/Modules/Crm/Resources/i18n/es_ES/Case.json
Normal file
38
application/Espo/Modules/Crm/Resources/i18n/es_ES/Case.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"fields": {
|
||||
"name": "Nombre",
|
||||
"number": "Número",
|
||||
"status": "Estado",
|
||||
"account": "Cuenta",
|
||||
"contact": "Contacto",
|
||||
"priority": "Prioridad",
|
||||
"type": "Tipo",
|
||||
"description": "Descripción"
|
||||
},
|
||||
"links": {
|
||||
},
|
||||
"options": {
|
||||
"status": {
|
||||
"New": "Nuevo",
|
||||
"Assigned": "Asignado",
|
||||
"Pending": "Pendiente",
|
||||
"Closed": "Cerrado",
|
||||
"Rejected": "Rechazado",
|
||||
"Duplicate": "Duplicado"
|
||||
},
|
||||
"priority" : {
|
||||
"Low": "Baja",
|
||||
"Normal": "Normal",
|
||||
"High": "Alta",
|
||||
"Urgent": "Urgente"
|
||||
},
|
||||
"type": {
|
||||
"Question": "Pregunta",
|
||||
"Incident": "Incidente",
|
||||
"Problem": "Problema"
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"Create Case": "Crear Caso"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"fields": {
|
||||
"name": "Nombre",
|
||||
"emailAddress": "Correo electrónico",
|
||||
"title": "Título",
|
||||
"account": "Cuenta",
|
||||
"phone": "Teléfono",
|
||||
"phoneOffice": "Phone (Office)",
|
||||
"fax": "Fax",
|
||||
"accountType": "Cuenta Tipo",
|
||||
"doNotCall": "No Llamar",
|
||||
"address": "Dirección",
|
||||
"description": "Descripción"
|
||||
},
|
||||
"links": {
|
||||
"opportunities": "Oportunidades",
|
||||
"cases": "Casos"
|
||||
},
|
||||
"labels": {
|
||||
"Create Contact": "Crear Contacto"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"scopeNames": {
|
||||
"Account": "Cuenta",
|
||||
"Contact": "Contacto",
|
||||
"Lead": "Potenciales",
|
||||
"Target": "Prospecto",
|
||||
"Opportunity": "Opportunidad",
|
||||
"Meeting": "Reunión",
|
||||
"Calendar": "Calendario",
|
||||
"Call": "Llamada",
|
||||
"Task": "Tarea",
|
||||
"Case": "Caso",
|
||||
"InboundEmail": "Correo Entrante"
|
||||
},
|
||||
"scopeNamesPlural": {
|
||||
"Account": "Cuentas",
|
||||
"Contact": "Contactos",
|
||||
"Lead": "Potenciales",
|
||||
"Targets": "Prospectos",
|
||||
"Opportunity": "Oportunidades",
|
||||
"Meeting": "Reuniones",
|
||||
"Calendar": "Calendario",
|
||||
"Call": "Llamadas",
|
||||
"Task": "Tareas",
|
||||
"Case": "Casos",
|
||||
"InboundEmail": "Correos Entrantes"
|
||||
},
|
||||
"dashlets": {
|
||||
"Leads": "Mis potenciales",
|
||||
"Opportunities": "Mis Opportunidades",
|
||||
"Tasks": "Mis Tareas",
|
||||
"Cases": "Mis Casos",
|
||||
"Calendar": "Calendario",
|
||||
"OpportunitiesByStage": "Oportunidades por Etapa",
|
||||
"OpportunitiesByLeadSource": "Oportunidades de origen de cliente potencial",
|
||||
"SalesByMonth": "Ventas por Mes",
|
||||
"SalesPipeline": "Canalización de ventas"
|
||||
},
|
||||
"labels": {
|
||||
"Create InboundEmail": "Crear Correo Entrante",
|
||||
"Activities": "Actividades",
|
||||
"History": "Historia",
|
||||
"Attendees": "Los asistentes",
|
||||
"Schedule Meeting": "Reunión Programada",
|
||||
"Schedule Call": "Llamada Programada",
|
||||
"Compose Email": "Componer Correo",
|
||||
"Log Meeting": "Log de Reunión",
|
||||
"Log Call": "Log de Llamada",
|
||||
"Archive Email": "Archivar Correo",
|
||||
"Create Task": "Crear Tarea",
|
||||
"Tasks": "Tareas"
|
||||
},
|
||||
"fields": {
|
||||
"billingAddressCity": "Ciudad",
|
||||
"billingAddressCountry": "país",
|
||||
"billingAddressPostalCode": "Código Postal",
|
||||
"billingAddressState": "Estado/Distrito",
|
||||
"billingAddressStreet": "Calle",
|
||||
"addressCity": "Ciudad",
|
||||
"addressStreet": "Calle",
|
||||
"addressCountry": "país",
|
||||
"addressState": "Estado/Distrito",
|
||||
"addressPostalCode": "Código Postal",
|
||||
"shippingAddressCity": "City (Shipping)",
|
||||
"shippingAddressStreet": "Street (Shipping)",
|
||||
"shippingAddressCountry": "Country (Shipping)",
|
||||
"shippingAddressState": "State (Shipping)",
|
||||
"shippingAddressPostalCode": "Postal Code (Shipping)"
|
||||
},
|
||||
"links": {
|
||||
"contacts": "Contactos",
|
||||
"opportunities": "Oportunidades",
|
||||
"leads": "Potenciales",
|
||||
"meetings": "Reuniones",
|
||||
"calls": "Llamadas",
|
||||
"tasks": "Tareas",
|
||||
"emails": "Correos"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"fields": {
|
||||
"name": "Nombre",
|
||||
"team": "Equipo",
|
||||
"status": "Estado",
|
||||
"assignToUser": "Asignado a Usuario",
|
||||
"host": "Host",
|
||||
"username": "Nombre de Usuario",
|
||||
"password": "Contraseña",
|
||||
"port": "Puerto",
|
||||
"monitoredFolders": "Carpetas supervisadas",
|
||||
"trashFolder": "Carpeta Basura",
|
||||
"ssl": "SSL",
|
||||
"createCase": "Crear Caso",
|
||||
"reply": "Responder",
|
||||
"caseDistribution": "Caso Distribución",
|
||||
"replyEmailTemplate": "Responder De Plantilla",
|
||||
"replyFromAddress": "Responder De Dirección",
|
||||
"replyFromName": "Responder De Nombre"
|
||||
},
|
||||
"links": {
|
||||
},
|
||||
"options": {
|
||||
"status": {
|
||||
"Active": "Activo",
|
||||
"Inactive": "Inactivo"
|
||||
},
|
||||
"caseDistribution": {
|
||||
"Direct-Assignment": "Asignación-Directa",
|
||||
"Round-Robin": "Round-Robin",
|
||||
"Least-Busy": "Least-Busy"
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"Create InboundEmail": "Crear Correo Entrante",
|
||||
"IMAP": "IMAP",
|
||||
"Actions": "Acciones",
|
||||
"Main": "Principal"
|
||||
},
|
||||
"messages": {
|
||||
"couldNotConnectToImap": "No se pudo conectar con el servidor IMAP"
|
||||
}
|
||||
}
|
||||
48
application/Espo/Modules/Crm/Resources/i18n/es_ES/Lead.json
Normal file
48
application/Espo/Modules/Crm/Resources/i18n/es_ES/Lead.json
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"labels": {
|
||||
"Converted To": "Convertido a",
|
||||
"Create Lead": "Crear Principal",
|
||||
"Convert": "Convertir"
|
||||
},
|
||||
"fields": {
|
||||
"name": "Nombre",
|
||||
"emailAddress": "Correo electrónico",
|
||||
"title": "Título",
|
||||
"website": "Sito Web",
|
||||
"phone": "Teléfono",
|
||||
"phoneOffice": "Phone (Office)",
|
||||
"fax": "Fax",
|
||||
"accountName": "Nombre de Cuenta",
|
||||
"doNotCall": "No Llamar",
|
||||
"address": "Dirección",
|
||||
"status": "Estado",
|
||||
"source": "Fuente",
|
||||
"opportunityAmount": "Oportunidad Cantidad",
|
||||
"description": "Descripción",
|
||||
"createdAccount": "Cuenta",
|
||||
"createdContact": "Contacto",
|
||||
"createdOpportunity": "Opportunidad"
|
||||
},
|
||||
"links": {
|
||||
},
|
||||
"options": {
|
||||
"status": {
|
||||
"New": "Nuevo",
|
||||
"Assigned": "Asignado",
|
||||
"In Process": "En Proceso",
|
||||
"Converted": "Convertido",
|
||||
"Recycled": "Reciclado",
|
||||
"Dead": "Muerto"
|
||||
},
|
||||
"source": {
|
||||
"Call": "Llamada",
|
||||
"Email": "Correo electrónico",
|
||||
"Existing Customer": "Cliente Existente",
|
||||
"Partner": "Partner",
|
||||
"Public Relations": "Relaciones Públicas",
|
||||
"Web Site": "Sitio Web",
|
||||
"Campaign": "Campaña",
|
||||
"Other": "Otro"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"fields": {
|
||||
"name": "Nombre",
|
||||
"parent": "Padre",
|
||||
"status": "Estado",
|
||||
"dateStart": "Fecha de Comienzo",
|
||||
"dateEnd": "Fecha de Finalización",
|
||||
"duration": "Duración",
|
||||
"description": "Descripción",
|
||||
"users": "Usuarios",
|
||||
"contacts": "Contactos",
|
||||
"leads": "Potenciales"
|
||||
},
|
||||
"links": {
|
||||
},
|
||||
"options": {
|
||||
"status": {
|
||||
"Planned": "Planeada",
|
||||
"Held": "Celebrada",
|
||||
"Not Held": "Sin Celebrar"
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"Create Meeting": "Crear Reunión",
|
||||
"Set Held": "Establecer Celebrada",
|
||||
"Set Not Held": "Establecer no Celebrada",
|
||||
"Send Invitations": "Enviar Invitaciones"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"fields": {
|
||||
"name": "Nombre",
|
||||
"account": "Cuenta",
|
||||
"stage": "Etapa",
|
||||
"amount": "Cantidad",
|
||||
"probability": "Probabilidad, %",
|
||||
"leadSource": "Fuente Principal",
|
||||
"doNotCall": "No Llamar",
|
||||
"closeDate": "Fecha de cierre",
|
||||
"description": "Descripción"
|
||||
},
|
||||
"links": {
|
||||
"contacts": "Contactos"
|
||||
},
|
||||
"options": {
|
||||
"stage": {
|
||||
"Prospecting": "Prospección",
|
||||
"Qualification": "Calificación",
|
||||
"Needs Analysis": "Análisis de Necesidades",
|
||||
"Value Proposition": "Valor de la Propuesta",
|
||||
"Id. Decision Makers": "Id. Tomadores de Decisiones",
|
||||
"Perception Analysis": "Análisis de la Percepción",
|
||||
"Proposal/Price Quote": "Propuesta/precio Presupuesto",
|
||||
"Negotiation/Review": "Negociación/Revisión",
|
||||
"Closed Won": "Cerrado Ganado",
|
||||
"Closed Lost": "Cerrado Perdido"
|
||||
},
|
||||
"leadSource": {
|
||||
"Call": "Llamada",
|
||||
"Email": "Correo electrónico",
|
||||
"Existing Customer": "Cliente Existente",
|
||||
"Partner": "Partner",
|
||||
"Public Relations": "Relaciones Públicas",
|
||||
"Web Site": "Sitio Web",
|
||||
"Campaign": "Campaña",
|
||||
"Other": "Otro"
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"Create Opportunity": "Crear Oportunidad"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"fields": {
|
||||
"name": "Nombre",
|
||||
"emailAddress": "Correo electrónico",
|
||||
"title": "Título",
|
||||
"website": "Sito Web",
|
||||
"accountName": "Nombre de Cuenta",
|
||||
"phone": "Teléfono",
|
||||
"phoneOffice": "Phone (Office)",
|
||||
"fax": "Fax",
|
||||
"doNotCall": "No Llamar",
|
||||
"address": "Dirección",
|
||||
"description": "Descripción"
|
||||
},
|
||||
"links": {
|
||||
},
|
||||
"labels": {
|
||||
"Create Target": "Crear Prospecto",
|
||||
"Convert to Lead": "Convertir en Lider"
|
||||
}
|
||||
}
|
||||
31
application/Espo/Modules/Crm/Resources/i18n/es_ES/Task.json
Normal file
31
application/Espo/Modules/Crm/Resources/i18n/es_ES/Task.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"fields": {
|
||||
"name": "Nombre",
|
||||
"parent": "Padre",
|
||||
"status": "Estado",
|
||||
"dateStart": "Fecha de Comienzo",
|
||||
"dateEnd": "Fecha de vencimiento",
|
||||
"priority": "Prioridad",
|
||||
"description": "Descripción",
|
||||
"isOverdue": "Atrasado"
|
||||
},
|
||||
"links": {
|
||||
},
|
||||
"options": {
|
||||
"status": {
|
||||
"Not Started": "Sin Empezar",
|
||||
"Started": "Comenzado",
|
||||
"Completed": "Completado",
|
||||
"Canceled": "Cancelado"
|
||||
},
|
||||
"priority" : {
|
||||
"Low": "Baja",
|
||||
"Normal": "Normal",
|
||||
"High": "Alta",
|
||||
"Urgent": "Urgente"
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"Create Task": "Crear Tarea"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"fields": {
|
||||
"name": "Nom",
|
||||
"emailAddress": "Email",
|
||||
"website": "Site Web",
|
||||
"phoneNumber": "Téléphone",
|
||||
"billingAddress": "Adresse de Facturation",
|
||||
"shippingAddress": "Adresse de Livraison",
|
||||
"description": "Description",
|
||||
"sicCode": "Code SIC",
|
||||
"industry": "Industrie",
|
||||
"type": "Type",
|
||||
"contactRole": "Rôle"
|
||||
},
|
||||
"links": {
|
||||
"contacts": "Contacts",
|
||||
"opportunities": "Opportunités",
|
||||
"cases": "Tickets"
|
||||
},
|
||||
"options": {
|
||||
"type": {
|
||||
"Customer": "Clients",
|
||||
"Investor": "Investisseur",
|
||||
"Partner": "Partenaire",
|
||||
"Reseller": "Revendeur"
|
||||
},
|
||||
"industry": {
|
||||
"Apparel": "Vêtements",
|
||||
"Banking": "Banque",
|
||||
"Computer Software": "Logiciel Informatique",
|
||||
"Education": "Education",
|
||||
"Electronics": "Electronique",
|
||||
"Finance": "Finance",
|
||||
"Insurance": "Assurance"
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"Create Account": "Nouveau Compte"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"modes": {
|
||||
"month": "Mois",
|
||||
"week": "Semaine",
|
||||
"day": "Jour",
|
||||
"agendaWeek": "Semaine",
|
||||
"agendaDay": "Jour"
|
||||
},
|
||||
"labels": {
|
||||
"Today": "Aujourd'hui",
|
||||
"Create": "Créer"
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user