Compare commits
279 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f68bb4b491 | |||
| 473e1109b4 | |||
| c4b8b90ff5 | |||
| 70b4017353 | |||
| e6f7bf4d6c | |||
| 69385519d7 | |||
| 235ee7c383 | |||
| a6dba9f09a | |||
| f1352430b9 | |||
| b9b63a8a7c | |||
| 5358bf4a43 | |||
| 1c7a7d8147 | |||
| ca055e8ca9 | |||
| 081c058229 | |||
| a5c941b1b2 | |||
| d43e63b89e | |||
| 102886e23d | |||
| 3b8b9e392e | |||
| 226152135d | |||
| 7f6a5b626e | |||
| c5fa26ffcb | |||
| 7b2bbcfd05 | |||
| e5b336d4f3 | |||
| 2d786d9660 | |||
| a587efddde | |||
| 81dd2bc800 | |||
| b1273176a9 | |||
| 46beb8b6b7 | |||
| 264efa2e8d | |||
| f538f05ec3 | |||
| 069a50c717 | |||
| 08f1329868 | |||
| e48043c2e8 | |||
| 024aeb6d01 | |||
| c79ef63c4d | |||
| 54798b94c9 | |||
| f70f22c503 | |||
| 33adc65dac | |||
| a6541f6f21 | |||
| 0b44fee0e5 | |||
| d03aec270e | |||
| 08bca7daf7 | |||
| d5cb1f5c1b | |||
| 68b16d3de9 | |||
| daffa60cd4 | |||
| 25cb6cdfb3 | |||
| 7afecc4cdd | |||
| 0e9373cf5e | |||
| 7992b78d4e | |||
| fed5e6ded7 | |||
| 82ddd2e562 | |||
| 1470cea4ed | |||
| 43e8929368 | |||
| 6db3600a4b | |||
| 9b2324755b | |||
| dc77b3c73e | |||
| 7627afb7d2 | |||
| e68ad81d57 | |||
| 73b84d720a | |||
| 0743582ef6 | |||
| f73d26fcf3 | |||
| b1dd9f30fb | |||
| 27071695cb | |||
| 1f551b6052 | |||
| 947ebbb6f5 | |||
| 3a706cad86 | |||
| 8cb1709966 | |||
| 7533fc337e | |||
| 601f908992 | |||
| ff72489f39 | |||
| db442e0769 | |||
| 189bbd784d | |||
| 2940de57b6 | |||
| cceb9eccc3 | |||
| 410ba24bef | |||
| 292e90e6b7 | |||
| 3f9b229a9e | |||
| 05c2270f36 | |||
| f22fdd6724 | |||
| 8059669a21 | |||
| 28a8ad927a | |||
| 6f7d27a5fd | |||
| d89a173a41 | |||
| ba5fef320e | |||
| a7982acc8f | |||
| 17742fccf1 | |||
| 7a2b563cd4 | |||
| 549984d1ed | |||
| d9256074fe | |||
| 97be52a0bc | |||
| 26a4d24492 | |||
| 03dad5a178 | |||
| 4c0453d0e3 | |||
| 1299853961 | |||
| e6d792ef5a | |||
| e8e8d0d7b2 | |||
| cec0c7b374 | |||
| fd73a0b8a5 | |||
| 120ff8543e | |||
| 7b8fa73474 | |||
| 85164758ce | |||
| 8a38568617 | |||
| 0c9e795dfd | |||
| ee1a50aa16 | |||
| a13b6af04a | |||
| f847535aea | |||
| b1b03c6dc1 | |||
| eeb10c6bce | |||
| 05241cefa5 | |||
| 1861e2cd87 | |||
| 8a17cbe23c | |||
| 484458c2ba | |||
| c62cc15159 | |||
| 17f8b09782 | |||
| 9fd05672ae | |||
| 69d96450da | |||
| 7393040c12 | |||
| 9097e644d4 | |||
| 837b1691d1 | |||
| 2cdec34062 | |||
| a33e10e92d | |||
| 86631117a2 | |||
| 05dfcf7511 | |||
| 3e1582bd6b | |||
| 743f348fcf | |||
| 2b2ac2a76d | |||
| a7d2d41b0f | |||
| 6ef0081ace | |||
| 4f3304d55f | |||
| 47b6093752 | |||
| ea8d930e56 | |||
| 79f3d86384 | |||
| fff201b7cd | |||
| 1ad454ce0b | |||
| e090fe699b | |||
| f677b5614b | |||
| f7b240e6a9 | |||
| ea3a60aaf7 | |||
| 6a7cfa58ae | |||
| 482f0cc314 | |||
| 28ada61f3d | |||
| 7057210e90 | |||
| 8c5bc59c45 | |||
| b7370ff238 | |||
| fb36f769d9 | |||
| f07b728851 | |||
| 7d4ada7ec2 | |||
| 1c31a6689f | |||
| a839144796 | |||
| 87cbe603d2 | |||
| ec96916013 | |||
| 2c811a4faa | |||
| 6e089c1e25 | |||
| 2e203341b7 | |||
| 5bea143bf0 | |||
| 732494e251 | |||
| 39e1303cbe | |||
| 62c3549004 | |||
| 9bcc942f0f | |||
| e34ee34d7b | |||
| dedef4b36f | |||
| e6f6e0fcf1 | |||
| 11a9e2ab9c | |||
| 9077542f61 | |||
| cb6faaa769 | |||
| a209d5aaaf | |||
| 767cdc75ee | |||
| 3eef0e088a | |||
| 1e5ef6a070 | |||
| a2edc3cf4e | |||
| 9a5dc7b4d1 | |||
| 7b0fd40d3e | |||
| 169df31cab | |||
| 44b0ba2f33 | |||
| 8d70956607 | |||
| 5ad20c8666 | |||
| 790d4a88b5 | |||
| b72ac42068 | |||
| 0a379be049 | |||
| e0e08a1c17 | |||
| 0d825120bb | |||
| 7b81b66b76 | |||
| d39f4e2533 | |||
| 598a2f9f05 | |||
| ce9089b838 | |||
| 45b06fc154 | |||
| f44177a994 | |||
| d91b13a7c1 | |||
| bd1894322c | |||
| 90874535ea | |||
| 8c919dbca4 | |||
| 05223c5272 | |||
| afee6d564b | |||
| b4e879a369 | |||
| de4d96e260 | |||
| 89056f61c2 | |||
| afac29151c | |||
| e54430fb1b | |||
| 7d8736b98c | |||
| 216e9419d4 | |||
| 359fdd4dab | |||
| 2044a87630 | |||
| 171feed28e | |||
| 92dbbbd390 | |||
| 3166cb862e | |||
| b606cb2e04 | |||
| 724ef00d52 | |||
| 0b7857b495 | |||
| a150eb7f0e | |||
| 4cb21a4fdb | |||
| 46e13b0269 | |||
| d4d5138991 | |||
| 9fd00d9f0a | |||
| 9361938285 | |||
| cb054b2f2b | |||
| f8ff6e6cf5 | |||
| 918c1b2114 | |||
| 2026bcb021 | |||
| ce5393155a | |||
| 6f4b752b10 | |||
| 2a5a453517 | |||
| 191bba7afc | |||
| f50d2ef9e3 | |||
| 1ad744d151 | |||
| ba0f86c8d4 | |||
| 372c84bfa3 | |||
| 6ec18950e4 | |||
| 6c3168a356 | |||
| 109ee17a47 | |||
| 21702b3c34 | |||
| 159a2ee99d | |||
| d6151d33b4 | |||
| 2217e03fa8 | |||
| 794c7eb523 | |||
| 98f61c0c4b | |||
| 5f5a450d95 | |||
| 0ba9679a75 | |||
| 85e60d4e32 | |||
| a074b8a214 | |||
| ac593c1d3d | |||
| 170e62bc8b | |||
| 5d19ae42dc | |||
| 9f3fdd01bf | |||
| 65e94e237d | |||
| 7935bc59fe | |||
| f49677b5c0 | |||
| b69f829a3e | |||
| 13dfc90a1b | |||
| 6d49d39480 | |||
| f473ea9cea | |||
| db8536ac55 | |||
| e402745a86 | |||
| abcaaddc2f | |||
| 3ac375c95c | |||
| 56f65e0fc0 | |||
| 471df0034e | |||
| a1b3be9ef3 | |||
| c4f70482ac | |||
| 31a8fa387d | |||
| a0d6cb9be4 | |||
| 4586d26bd6 | |||
| 1609adc766 | |||
| aa0a9cf708 | |||
| d7dfe5fea4 | |||
| 340ed5acec | |||
| 7ec3e38e6d | |||
| 879bf13809 | |||
| b44bbaffa2 | |||
| 4c562cb603 | |||
| 8eb2be46ca | |||
| cd7571387c | |||
| 1b3496edd9 | |||
| 356da4e70d | |||
| f3deffb3f6 | |||
| 8398cc4364 | |||
| 6ddda814c0 | |||
| 76ffa2def9 | |||
| 2fdc0a3a93 | |||
| 0dcc8d08d1 |
+7
-1
@@ -1,3 +1,9 @@
|
||||
## Pull Requests
|
||||
|
||||
Before we can merge your pull request you need to accept our CLA [here](https://github.com/espocrm/cla). It's very simple to do.
|
||||
|
||||
[Code Style Guidelines](https://github.com/espocrm/espocrm/wiki/Code-Style-Guidelines).
|
||||
[Code Style Guidelines](https://github.com/espocrm/espocrm/wiki/Code-Style-Guidelines).
|
||||
|
||||
## Issues
|
||||
|
||||
We don't provide developer help or any kind of support on github. Please use our [forum](http://forum.espocrm.com/) for this.
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2017 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/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Acl;
|
||||
|
||||
use \Espo\Entities\User as EntityUser;
|
||||
use \Espo\ORM\Entity;
|
||||
|
||||
class ActionHistoryRecord extends \Espo\Core\Acl\Base
|
||||
{
|
||||
public function checkIsOwner(EntityUser $user, Entity $entity)
|
||||
{
|
||||
return $entity->get('userId') === $user->id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2017 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/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Acl;
|
||||
|
||||
use \Espo\Entities\User as EntityUser;
|
||||
use \Espo\ORM\Entity;
|
||||
|
||||
class ScheduledJob extends \Espo\Core\Acl\Base
|
||||
{
|
||||
public function checkEntityRead(EntityUser $user, Entity $entity, $data)
|
||||
{
|
||||
if ($entity->get('isInternal')) return false;
|
||||
return $this->checkEntity($user, $entity, $data, 'read');
|
||||
}
|
||||
|
||||
public function checkEntityEdit(EntityUser $user, Entity $entity, $data)
|
||||
{
|
||||
if ($entity->get('isInternal')) return false;
|
||||
return $this->checkEntity($user, $entity, $data, 'edit');
|
||||
}
|
||||
|
||||
public function checkEntityDelete(EntityUser $user, Entity $entity, $data)
|
||||
{
|
||||
if ($entity->get('isInternal')) return false;
|
||||
return $this->checkEntity($user, $entity, $data, 'delete');
|
||||
}
|
||||
|
||||
public function checkEntityCreate(EntityUser $user, Entity $entity, $data)
|
||||
{
|
||||
if ($entity->get('isInternal')) return false;
|
||||
return $this->checkEntity($user, $entity, $data, 'create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2017 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/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Controllers;
|
||||
|
||||
use \Espo\Core\Exceptions\Forbidden;
|
||||
|
||||
class ActionHistoryRecord extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
public function actionUpdate($params, $data, $request)
|
||||
{
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
public function actionCreate($params, $data, $request)
|
||||
{
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
public function actionListLinked($params, $data, $request)
|
||||
{
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
public function actionMassUpdate($params, $data, $request)
|
||||
{
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
public function actionCreateLink($params, $data, $request)
|
||||
{
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
public function actionRemoveLink($params, $data, $request)
|
||||
{
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
public function actionMassDelete($params, $data, $request)
|
||||
{
|
||||
throw new Forbidden();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,9 @@ class App extends \Espo\Core\Controllers\Base
|
||||
$settings->$item = $this->getConfig()->get($item);
|
||||
}
|
||||
|
||||
unset($userData['authTokenId']);
|
||||
unset($userData['password']);
|
||||
|
||||
return array(
|
||||
'user' => $userData,
|
||||
'acl' => $this->getAcl()->getMap(),
|
||||
|
||||
@@ -54,7 +54,7 @@ class Attachment extends \Espo\Core\Controllers\Record
|
||||
|
||||
$attachment = $this->getEntityManager()->getEntity('Attachment');
|
||||
$this->getEntityManager()->saveEntity($attachment);
|
||||
$this->getContainer()->get('fileManager')->putContents('data/upload/' . $attachment->id, $contents);
|
||||
$this->getContainer()->get('fileStorageManager')->putContents($attachment, $contents);
|
||||
|
||||
return array(
|
||||
'attachmentId' => $attachment->id
|
||||
|
||||
@@ -42,20 +42,37 @@ class AuthToken extends \Espo\Core\Controllers\Record
|
||||
|
||||
public function actionUpdate($params, $data, $request)
|
||||
{
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
public function actionCreate($params, $data, $request)
|
||||
{
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
public function actionListLinked($params, $data, $request)
|
||||
{
|
||||
if (
|
||||
is_array($data) &&
|
||||
array_key_exists('isActive', $data) &&
|
||||
$data['isActive'] === false &&
|
||||
count(array_keys($data)) === 1)
|
||||
{
|
||||
return parent::actionUpdate($params, $data, $request);
|
||||
}
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
public function actionMassUpdate($params, $data, $request)
|
||||
{
|
||||
if (empty($data['attributes'])) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$attributes = $data['attributes'];
|
||||
|
||||
if (
|
||||
is_object($attributes) &&
|
||||
isset($attributes->isActive) &&
|
||||
$attributes->isActive === false &&
|
||||
count(array_keys(get_object_vars($attributes))) === 1
|
||||
) {
|
||||
return parent::actionMassUpdate($params, $data, $request);
|
||||
}
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
public function actionCreate($params, $data, $request)
|
||||
{
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@
|
||||
|
||||
namespace Espo\Controllers;
|
||||
|
||||
use \Espo\Core\Exceptions\Error,
|
||||
\Espo\Core\Exceptions\Forbidden,
|
||||
\Espo\Core\Exceptions\NotFound,
|
||||
\Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
|
||||
class FieldManager extends \Espo\Core\Controllers\Base
|
||||
{
|
||||
@@ -49,7 +49,7 @@ class FieldManager extends \Espo\Core\Controllers\Base
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$data = $this->getContainer()->get('fieldManager')->read($params['name'], $params['scope']);
|
||||
$data = $this->getContainer()->get('fieldManager')->read($params['scope'], $params['name']);
|
||||
|
||||
if (!isset($data)) {
|
||||
throw new BadRequest();
|
||||
@@ -65,16 +65,16 @@ class FieldManager extends \Espo\Core\Controllers\Base
|
||||
}
|
||||
|
||||
$fieldManager = $this->getContainer()->get('fieldManager');
|
||||
$fieldManager->create($data['name'], $data, $params['scope']);
|
||||
$fieldManager->create($params['scope'], $data['name'], $data);
|
||||
|
||||
try {
|
||||
$this->getContainer()->get('dataManager')->rebuild($params['scope']);
|
||||
} catch (Error $e) {
|
||||
$fieldManager->delete($data['name'], $params['scope']);
|
||||
$fieldManager->delete($params['scope'], $data['name']);
|
||||
throw new Error($e->getMessage());
|
||||
}
|
||||
|
||||
return $fieldManager->read($data['name'], $params['scope']);
|
||||
return $fieldManager->read($params['scope'], $data['name']);
|
||||
}
|
||||
|
||||
public function putActionUpdate($params, $data)
|
||||
@@ -84,7 +84,7 @@ class FieldManager extends \Espo\Core\Controllers\Base
|
||||
}
|
||||
|
||||
$fieldManager = $this->getContainer()->get('fieldManager');
|
||||
$fieldManager->update($params['name'], $data, $params['scope']);
|
||||
$fieldManager->update($params['scope'], $params['name'], $data);
|
||||
|
||||
if ($fieldManager->isChanged()) {
|
||||
$this->getContainer()->get('dataManager')->rebuild($params['scope']);
|
||||
@@ -92,7 +92,7 @@ class FieldManager extends \Espo\Core\Controllers\Base
|
||||
$this->getContainer()->get('dataManager')->clearCache();
|
||||
}
|
||||
|
||||
return $fieldManager->read($params['name'], $params['scope']);
|
||||
return $fieldManager->read($params['scope'], $params['name']);
|
||||
}
|
||||
|
||||
public function deleteActionDelete($params, $data)
|
||||
@@ -101,11 +101,11 @@ class FieldManager extends \Espo\Core\Controllers\Base
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$res = $this->getContainer()->get('fieldManager')->delete($params['name'], $params['scope']);
|
||||
$result = $this->getContainer()->get('fieldManager')->delete($params['scope'], $params['name']);
|
||||
|
||||
$this->getContainer()->get('dataManager')->rebuildMetadata();
|
||||
|
||||
return $res;
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function postActionResetToDefault($params, $data)
|
||||
@@ -114,7 +114,7 @@ class FieldManager extends \Espo\Core\Controllers\Base
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->getContainer()->get('fieldManager')->resetToDefault($data['name'], $data['scope']);
|
||||
$this->getContainer()->get('fieldManager')->resetToDefault($data['scope'], $data['name']);
|
||||
|
||||
$this->getContainer()->get('dataManager')->rebuildMetadata();
|
||||
|
||||
|
||||
@@ -68,9 +68,9 @@ class Import extends \Espo\Core\Controllers\Record
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
protected function getFileManager()
|
||||
protected function getFileStorageManager()
|
||||
{
|
||||
return $this->getContainer()->get('fileManager');
|
||||
return $this->getContainer()->get('fileStorageManager');
|
||||
}
|
||||
|
||||
protected function getEntityManager()
|
||||
@@ -92,7 +92,7 @@ class Import extends \Espo\Core\Controllers\Record
|
||||
$attachment->set('name', 'import-file.csv');
|
||||
$this->getEntityManager()->saveEntity($attachment);
|
||||
|
||||
$this->getFileManager()->putContents('data/upload/' . $attachment->id, $contents);
|
||||
$this->getFileStorageManager()->putContents($attachment, $contents);
|
||||
|
||||
return array(
|
||||
'attachmentId' => $attachment->id
|
||||
@@ -167,12 +167,18 @@ class Import extends \Espo\Core\Controllers\Record
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$timezone = 'UTC';
|
||||
if (isset($data['timezone'])) {
|
||||
$timezone = $data['timezone'];
|
||||
}
|
||||
|
||||
$importParams = array(
|
||||
'headerRow' => !empty($data['headerRow']),
|
||||
'fieldDelimiter' => $data['fieldDelimiter'],
|
||||
'textQualifier' => $data['textQualifier'],
|
||||
'dateFormat' => $data['dateFormat'],
|
||||
'timeFormat' => $data['timeFormat'],
|
||||
'timezone' => $timezone,
|
||||
'personNameFormat' => $data['personNameFormat'],
|
||||
'decimalMark' => $data['decimalMark'],
|
||||
'currency' => $data['currency'],
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2017 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/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Controllers;
|
||||
|
||||
use \Espo\Core\Exceptions\Forbidden;
|
||||
|
||||
class LastViewed extends \Espo\Core\Controllers\Base
|
||||
{
|
||||
public function getActionIndex($params, $data, $request)
|
||||
{
|
||||
$result = $this->getServiceFactory()->create('LastViewed')->get();
|
||||
|
||||
return [
|
||||
'total' => $result['total'],
|
||||
'list' => isset($result['collection']) ? $result['collection']->toArray() : $result['list']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,11 +33,10 @@ use \Espo\Core\Exceptions\Forbidden;
|
||||
|
||||
class Metadata extends \Espo\Core\Controllers\Base
|
||||
{
|
||||
|
||||
public function actionRead($params, $data)
|
||||
{
|
||||
$data = $this->getMetadata()->getAll();
|
||||
unset($data['formula']);
|
||||
return $data;
|
||||
return $this->getMetadata()->getAllForFrontend();
|
||||
}
|
||||
|
||||
public function getActionGet($params, $data, $request)
|
||||
|
||||
@@ -69,6 +69,11 @@ class Acl
|
||||
return $this->getAclManager()->get($this->getUser(), $permission);
|
||||
}
|
||||
|
||||
public function checkReadNo($scope)
|
||||
{
|
||||
return $this->getAclManager()->checkReadNo($this->getUser(), $scope);
|
||||
}
|
||||
|
||||
public function checkReadOnlyTeam($scope)
|
||||
{
|
||||
return $this->getAclManager()->checkReadOnlyTeam($this->getUser(), $scope);
|
||||
|
||||
@@ -106,6 +106,14 @@ class Base implements Injectable
|
||||
return $data->read === 'team';
|
||||
}
|
||||
|
||||
public function checkReadNo(User $user, $data)
|
||||
{
|
||||
if (empty($data) || !is_object($data) || !isset($data->read)) {
|
||||
return false;
|
||||
}
|
||||
return $data->read === 'no';
|
||||
}
|
||||
|
||||
public function checkReadOnlyOwn(User $user, $data)
|
||||
{
|
||||
if (empty($data) || !is_object($data) || !isset($data->read)) {
|
||||
|
||||
@@ -133,6 +133,15 @@ class AclManager
|
||||
return $this->getTable($user)->get($permission);
|
||||
}
|
||||
|
||||
public function checkReadNo(User $user, $scope)
|
||||
{
|
||||
if ($user->isAdmin()) {
|
||||
return false;
|
||||
}
|
||||
$data = $this->getTable($user)->getScopeData($scope);
|
||||
return $this->getImplementation($scope)->checkReadNo($user, $data);
|
||||
}
|
||||
|
||||
public function checkReadOnlyTeam(User $user, $scope)
|
||||
{
|
||||
if ($user->isAdmin()) {
|
||||
|
||||
@@ -128,6 +128,14 @@ class Container
|
||||
return new \Espo\Core\Utils\Api\Slim();
|
||||
}
|
||||
|
||||
protected function loadFileStorageManager()
|
||||
{
|
||||
return new \Espo\Core\FileStorage\Manager(
|
||||
$this->get('metadata')->get(['app', 'fileStorage', 'implementationClassNameMap']),
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
protected function loadFileManager()
|
||||
{
|
||||
return new \Espo\Core\Utils\File\Manager(
|
||||
@@ -343,6 +351,13 @@ class Container
|
||||
);
|
||||
}
|
||||
|
||||
protected function loadInjectableFactory()
|
||||
{
|
||||
return new \Espo\Core\InjectableFactory(
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
public function setUser(\Espo\Entities\User $user)
|
||||
{
|
||||
$this->set('user', $user);
|
||||
|
||||
@@ -67,7 +67,7 @@ class Record extends Base
|
||||
public function actionRead($params, $data, $request)
|
||||
{
|
||||
$id = $params['id'];
|
||||
$entity = $this->getRecordService()->getEntity($id);
|
||||
$entity = $this->getRecordService()->readEntity($id);
|
||||
|
||||
if (empty($entity)) {
|
||||
throw new NotFound();
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2017 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/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\FileStorage;
|
||||
|
||||
use \Espo\Entities\Attachment;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
|
||||
class Manager
|
||||
{
|
||||
private $implementations = array();
|
||||
|
||||
private $implementationClassNameMap = array();
|
||||
|
||||
private $container;
|
||||
|
||||
public function __construct(array $implementationClassNameMap, $container)
|
||||
{
|
||||
$this->implementationClassNameMap = $implementationClassNameMap;
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
private function getImplementation($storage = null)
|
||||
{
|
||||
if (!$storage) {
|
||||
$storage = 'EspoUploadDir';
|
||||
}
|
||||
|
||||
if (array_key_exists($storage, $this->implementations)) {
|
||||
return $this->implementations[$storage];
|
||||
}
|
||||
|
||||
if (!array_key_exists($storage, $this->implementationClassNameMap)) {
|
||||
throw new Error("FileStorageManager: Unknown storage '{$storage}'");
|
||||
}
|
||||
$className = $this->implementationClassNameMap[$storage];
|
||||
|
||||
$implementation = new $className();
|
||||
foreach ($implementation->getDependencyList() as $dependencyName) {
|
||||
$implementation->inject($dependencyName, $this->container->get($dependencyName));
|
||||
}
|
||||
$this->implementations[$storage] = $implementation;
|
||||
|
||||
return $implementation;
|
||||
}
|
||||
|
||||
public function isFile(Attachment $attachment)
|
||||
{
|
||||
$implementation = $this->getImplementation($attachment->get('storage'));
|
||||
return $implementation->isFile($attachment);
|
||||
}
|
||||
|
||||
public function getContents(Attachment $attachment)
|
||||
{
|
||||
$implementation = $this->getImplementation($attachment->get('storage'));
|
||||
return $implementation->getContents($attachment);
|
||||
}
|
||||
|
||||
public function putContents(Attachment $attachment, $contents)
|
||||
{
|
||||
$implementation = $this->getImplementation($attachment->get('storage'));
|
||||
return $implementation->putContents($attachment, $contents);
|
||||
}
|
||||
|
||||
public function unlink(Attachment $attachment)
|
||||
{
|
||||
$implementation = $this->getImplementation($attachment->get('storage'));
|
||||
return $implementation->unlink($attachment);
|
||||
}
|
||||
|
||||
public function getLocalFilePath(Attachment $attachment)
|
||||
{
|
||||
$implementation = $this->getImplementation($attachment->get('storage'));
|
||||
return $implementation->getLocalFilePath($attachment);
|
||||
}
|
||||
|
||||
public function hasDownloadUrl(Attachment $attachment)
|
||||
{
|
||||
$implementation = $this->getImplementation($attachment->get('storage'));
|
||||
return $implementation->hasDownloadUrl($attachment);
|
||||
}
|
||||
|
||||
public function getDownloadUrl(Attachment $attachment)
|
||||
{
|
||||
$implementation = $this->getImplementation($attachment->get('storage'));
|
||||
return $implementation->getDownloadUrl($attachment);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2017 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/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\FileStorage\Storages;
|
||||
|
||||
use \Espo\Core\Interfaces\Injectable;
|
||||
|
||||
abstract class Base implements Injectable
|
||||
{
|
||||
protected $dependencyList = [];
|
||||
|
||||
protected $injections = array();
|
||||
|
||||
public function inject($name, $object)
|
||||
{
|
||||
$this->injections[$name] = $object;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->init();
|
||||
}
|
||||
|
||||
protected function init()
|
||||
{
|
||||
}
|
||||
|
||||
protected function getInjection($name)
|
||||
{
|
||||
return $this->injections[$name];
|
||||
}
|
||||
|
||||
protected function addDependency($name)
|
||||
{
|
||||
$this->dependencyList[] = $name;
|
||||
}
|
||||
|
||||
protected function addDependencyList(array $list)
|
||||
{
|
||||
foreach ($list as $item) {
|
||||
$this->addDependency($item);
|
||||
}
|
||||
}
|
||||
|
||||
public function getDependencyList()
|
||||
{
|
||||
return $this->dependencyList;
|
||||
}
|
||||
|
||||
abstract public function hasDownloadUrl(\Espo\Entities\Attachment $attachment);
|
||||
|
||||
abstract public function getDownloadUrl(\Espo\Entities\Attachment $attachment);
|
||||
|
||||
abstract public function unlink(\Espo\Entities\Attachment $attachment);
|
||||
|
||||
abstract public function getContents(\Espo\Entities\Attachment $attachment);
|
||||
|
||||
abstract public function isFile(\Espo\Entities\Attachment $attachment);
|
||||
|
||||
abstract public function putContents(\Espo\Entities\Attachment $attachment, $contents);
|
||||
|
||||
abstract public function getLocalFilePath(\Espo\Entities\Attachment $attachment);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2017 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/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\FileStorage\Storages;
|
||||
|
||||
use \Espo\Entities\Attachment;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
|
||||
class EspoUploadDir extends Base
|
||||
{
|
||||
protected $dependencyList = ['fileManager'];
|
||||
|
||||
protected function getFileManager()
|
||||
{
|
||||
return $this->getInjection('fileManager');
|
||||
}
|
||||
|
||||
public function unlink(Attachment $attachment)
|
||||
{
|
||||
return $this->getFileManager()->unlink($this->getFilePath($attachment));
|
||||
}
|
||||
|
||||
public function isFile(Attachment $attachment)
|
||||
{
|
||||
return $this->getFileManager()->isFile($this->getFilePath($attachment));
|
||||
}
|
||||
|
||||
public function getContents(Attachment $attachment)
|
||||
{
|
||||
return $this->getFileManager()->getContents($this->getFilePath($attachment));
|
||||
}
|
||||
|
||||
public function putContents(Attachment $attachment, $contents)
|
||||
{
|
||||
return $this->getFileManager()->putContents($this->getFilePath($attachment), $contents);
|
||||
}
|
||||
|
||||
public function getLocalFilePath(Attachment $attachment)
|
||||
{
|
||||
return $this->getFilePath($attachment);
|
||||
}
|
||||
|
||||
protected function getFilePath(Attachment $attachment)
|
||||
{
|
||||
$sourceId = $attachment->getSourceId();
|
||||
return 'data/upload/' . $sourceId;
|
||||
}
|
||||
|
||||
public function getDownloadUrl(Attachment $attachment)
|
||||
{
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
public function hasDownloadUrl(Attachment $attachment)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
@@ -65,6 +65,13 @@ class AttributeFetcher
|
||||
$methodName = 'getFetched';
|
||||
}
|
||||
|
||||
if ($entity->getAttributeParam($attribute, 'isParentName') && $methodName == 'get') {
|
||||
$relationName = $entity->getAttributeParam($attribute, 'relation');
|
||||
if ($parent = $entity->get($relationName)) {
|
||||
return $parent->get('name');
|
||||
}
|
||||
}
|
||||
|
||||
return $entity->$methodName($attribute);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2017 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/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Formula\Functions\DatetimeGroup;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
|
||||
class DiffType extends \Espo\Core\Formula\Functions\Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
$this->addDependency('dateTime');
|
||||
}
|
||||
|
||||
protected $intevalTypePropertyMap = array(
|
||||
'years' => 'y', 'months' => 'm', 'days' => 'd', 'hours' => 'h', 'minutes' => 'i', 'seconds' => 's'
|
||||
);
|
||||
|
||||
public function process(\StdClass $item)
|
||||
{
|
||||
if (!property_exists($item, 'value')) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
if (!is_array($item->value)) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
if (count($item->value) < 2) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
$dateTime1String = $this->evaluate($item->value[0]);
|
||||
$dateTime2String = $this->evaluate($item->value[1]);
|
||||
|
||||
if (!$dateTime1String) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!$dateTime2String) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!is_string($dateTime1String)) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
if (!is_string($dateTime2String)) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
$intervalType = 'days';
|
||||
if (count($item->value) > 2) {
|
||||
$intervalType = $this->evaluate($item->value[2]);
|
||||
}
|
||||
|
||||
if (!is_string($intervalType)) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
if (!array_key_exists($intervalType, $this->intevalTypePropertyMap)) {
|
||||
throw new Error('Not supported interval type' . $intervalType);
|
||||
}
|
||||
|
||||
|
||||
$isTime = false;
|
||||
if (strlen($dateTime1String) > 10) {
|
||||
$isTime = true;
|
||||
}
|
||||
|
||||
try {
|
||||
$dateTime1 = new \DateTime($dateTime1String);
|
||||
$dateTime2 = new \DateTime($dateTime2String);
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$t1 = $dateTime1->getTimestamp();
|
||||
$t2 = $dateTime2->getTimestamp();
|
||||
|
||||
$secondsDiff = $t1 - $t2;
|
||||
|
||||
if ($intervalType === 'seconds') {
|
||||
$number = $secondsDiff;
|
||||
} else if ($intervalType === 'minutes') {
|
||||
$number = floor($secondsDiff / 60);
|
||||
} else if ($intervalType === 'hours') {
|
||||
$number = floor($secondsDiff / (60 * 60));
|
||||
} else if ($intervalType === 'days') {
|
||||
$number = floor($secondsDiff / (60 * 60 * 24));
|
||||
} else {
|
||||
$property = $this->intevalTypePropertyMap[$intervalType];
|
||||
$interval = $dateTime2->diff($dateTime1);
|
||||
$number = $interval->$property;
|
||||
if ($interval->invert) {
|
||||
$number *= -1;
|
||||
}
|
||||
|
||||
if ($intervalType === 'months') {
|
||||
$number += $interval->y * 12;
|
||||
}
|
||||
}
|
||||
|
||||
return $number;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
@@ -58,10 +58,15 @@ class FormatType extends \Espo\Core\Formula\Functions\Base
|
||||
}
|
||||
$value = $this->evaluate($item->value[0]);
|
||||
|
||||
$format = null;
|
||||
if (count($item->value) > 2) {
|
||||
$format = $this->evaluate($item->value[2]);
|
||||
}
|
||||
|
||||
if (strlen($value) > 11) {
|
||||
return $this->getInjection('dateTime')->convertSystemDateTime($value, $timezone);
|
||||
return $this->getInjection('dateTime')->convertSystemDateTime($value, $timezone, $format);
|
||||
} else {
|
||||
return $this->getInjection('dateTime')->convertSystemDate($value);
|
||||
return $this->getInjection('dateTime')->convertSystemDate($value, $format);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2017 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/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Formula\Functions\NumberGroup;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
|
||||
class AbsType extends \Espo\Core\Formula\Functions\Base
|
||||
{
|
||||
|
||||
public function process(\StdClass $item)
|
||||
{
|
||||
if (!property_exists($item, 'value')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!is_array($item->value)) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
if (count($item->value) < 1) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
$value = $this->evaluate($item->value[0]);
|
||||
|
||||
if (!is_numeric($value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return abs($value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2017 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/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Formula\Functions\NumberGroup;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
|
||||
class RoundType extends \Espo\Core\Formula\Functions\Base
|
||||
{
|
||||
public function process(\StdClass $item)
|
||||
{
|
||||
if (!property_exists($item, 'value')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!is_array($item->value)) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
if (count($item->value) < 1) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
$value = $this->evaluate($item->value[0]);
|
||||
|
||||
$precision = 0;
|
||||
if (count($item->value) > 1) {
|
||||
$precision = $this->evaluate($item->value[1]);
|
||||
}
|
||||
|
||||
if (!is_numeric($value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return round($value, $precision);
|
||||
}
|
||||
}
|
||||
@@ -229,7 +229,11 @@ class Parser
|
||||
$possibleRightOperator = trim($operator . $expression[$index + 1]);
|
||||
}
|
||||
}
|
||||
if ($possibleRightOperator && $possibleRightOperator != $operator && $this->operatorMap[$possibleRightOperator]) continue;
|
||||
if (
|
||||
$possibleRightOperator &&
|
||||
$possibleRightOperator != $operator &&
|
||||
!empty($this->operatorMap[$possibleRightOperator])
|
||||
) continue;
|
||||
|
||||
$firstPart = substr($expression, 0, $index);
|
||||
$secondPart = substr($expression, $index + strlen($operator));
|
||||
|
||||
@@ -42,17 +42,14 @@ class HookManager
|
||||
protected $cacheFile = 'data/cache/application/hooks.php';
|
||||
|
||||
/**
|
||||
* List of defined hooks
|
||||
* List of ignored hook methods
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hookList = array(
|
||||
'beforeSave',
|
||||
'afterSave',
|
||||
'beforeRemove',
|
||||
'afterRemove',
|
||||
'afterRelate',
|
||||
'afterUnrelate'
|
||||
protected $ignoredMethodList = array(
|
||||
'__construct',
|
||||
'getDependencyList',
|
||||
'inject'
|
||||
);
|
||||
|
||||
protected $paths = array(
|
||||
@@ -170,9 +167,12 @@ class HookManager
|
||||
$hookFilePath = Util::concatPath($hookScopeDirPath, $hookFile);
|
||||
$className = Util::getClassName($hookFilePath);
|
||||
|
||||
foreach($this->hookList as $hookName) {
|
||||
$classMethods = get_class_methods($className);
|
||||
$hookMethods = array_diff($classMethods, $this->ignoredMethodList);
|
||||
|
||||
foreach($hookMethods as $hookName) {
|
||||
$entityHookData = isset($hookData[$scopeName][$hookName]) ? $hookData[$scopeName][$hookName] : array();
|
||||
if (method_exists($className, $hookName) && !$this->isHookExists($className, $entityHookData)) {
|
||||
if (!$this->isHookExists($className, $entityHookData)) {
|
||||
$hookData[$normalizedScopeName][$hookName][$className::$order][] = $className;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,12 +48,15 @@ class Htmlizer
|
||||
|
||||
protected $acl;
|
||||
|
||||
public function __construct(FileManager $fileManager, DateTime $dateTime, NumberUtil $number, $acl = null)
|
||||
protected $entityManager;
|
||||
|
||||
public function __construct(FileManager $fileManager, DateTime $dateTime, NumberUtil $number, $acl = null, $entityManager = null)
|
||||
{
|
||||
$this->fileManager = $fileManager;
|
||||
$this->dateTime = $dateTime;
|
||||
$this->number = $number;
|
||||
$this->acl = $acl;
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
protected function getAcl()
|
||||
@@ -61,6 +64,11 @@ class Htmlizer
|
||||
return $this->acl;
|
||||
}
|
||||
|
||||
protected function getEntityManager()
|
||||
{
|
||||
return $this->entityManager;
|
||||
}
|
||||
|
||||
protected function format($value)
|
||||
{
|
||||
if (is_float($value)) {
|
||||
@@ -163,7 +171,8 @@ class Htmlizer
|
||||
'helpers' => [
|
||||
'file' => function ($context, $options) {
|
||||
if (count($context) && $context[0]) {
|
||||
return 'data/upload/'.$context[0];
|
||||
$id = $context[0];
|
||||
return "?entryPoint=attachment&id=" . $id;
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -192,8 +201,20 @@ class Htmlizer
|
||||
|
||||
$html = $renderer($data);
|
||||
|
||||
|
||||
$html = str_replace('?entryPoint=attachment&', '?entryPoint=attachment&', $html);
|
||||
$html = preg_replace('/\?entryPoint=attachment\&id=(.*)/', 'data/upload/$1', $html);
|
||||
|
||||
if ($this->getEntityManager()) {
|
||||
$html = preg_replace_callback('/\?entryPoint=attachment\&id=([A-Za-z0-9]*)/', function ($matches) {
|
||||
$id = $matches[1];
|
||||
$attachment = $this->getEntityManager()->getEntity('Attachment', $id);
|
||||
|
||||
if ($attachment) {
|
||||
$filePath = $this->getEntityManager()->getRepository('Attachment')->getFilePath($attachment);
|
||||
return $filePath;
|
||||
}
|
||||
}, $html);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2017 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/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core;
|
||||
|
||||
abstract class Injectable implements \Espo\Core\Interfaces\Injectable
|
||||
{
|
||||
protected $dependencyList = array();
|
||||
|
||||
protected $injections = array();
|
||||
|
||||
public function inject($name, $object)
|
||||
{
|
||||
$this->injections[$name] = $object;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->init();
|
||||
}
|
||||
|
||||
protected function init()
|
||||
{
|
||||
}
|
||||
|
||||
protected function getInjection($name)
|
||||
{
|
||||
return $this->injections[$name];
|
||||
}
|
||||
|
||||
protected function addDependency($name)
|
||||
{
|
||||
if (in_array($name, $this->dependencyList)) return;
|
||||
$this->dependencyList[] = $name;
|
||||
}
|
||||
|
||||
protected function addDependencyList(array $list)
|
||||
{
|
||||
foreach ($list as $item) {
|
||||
$this->addDependency($item);
|
||||
}
|
||||
}
|
||||
|
||||
public function getDependencyList()
|
||||
{
|
||||
return $this->dependencyList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2017 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/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
|
||||
class InjectableFactory
|
||||
{
|
||||
private $container;
|
||||
|
||||
public function __construct(Container $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function createByClassName($className)
|
||||
{
|
||||
if (class_exists($className)) {
|
||||
$service = new $className();
|
||||
if (!($service instanceof \Espo\Core\Interfaces\Injectable)) {
|
||||
throw new Error("Class '$className' is not instance of Injectable interface");
|
||||
}
|
||||
$dependencyList = $service->getDependencyList();
|
||||
foreach ($dependencyList as $name) {
|
||||
$service->inject($name, $this->container->get($name));
|
||||
}
|
||||
return $service;
|
||||
}
|
||||
throw new Error("Class '$className' does not exist");
|
||||
}
|
||||
}
|
||||
@@ -104,12 +104,16 @@ class Importer
|
||||
}
|
||||
}
|
||||
|
||||
if ($parser->checkMessageAttribute($message, 'from')) {
|
||||
$email->set('fromString', $parser->getMessageAttribute($message, 'from'));
|
||||
$fromAddressData = $parser->getAddressDataFromMessage($message, 'from');
|
||||
if ($fromAddressData) {
|
||||
$fromString = ($fromAddressData['name'] ? ($fromAddressData['name'] . ' ') : '') . '<' . $fromAddressData['address'] .'>';
|
||||
$email->set('fromString', $fromString);
|
||||
}
|
||||
|
||||
if ($parser->checkMessageAttribute($message, 'reply-To')) {
|
||||
$email->set('replyToString', $parser->getMessageAttribute($message, 'reply-To'));
|
||||
$replyToData = $parser->getAddressDataFromMessage($message, 'reply-To');
|
||||
if ($replyToData) {
|
||||
$replyToString = ($replyToData['name'] ? ($replyToData['name'] . ' ') : '') . '<' . $replyToData['address'] .'>';
|
||||
$email->set('replyToString', $replyToString);
|
||||
}
|
||||
|
||||
$fromArr = $parser->getAddressListFromMessage($message, 'from');
|
||||
@@ -124,6 +128,9 @@ class Importer
|
||||
$email->set('cc', implode(';', $ccArr));
|
||||
$email->set('replyTo', implode(';', $replyToArr));
|
||||
|
||||
$addressNameMap = $parser->getAddressNameMap($message);
|
||||
$email->set('addressNameMap', $addressNameMap);
|
||||
|
||||
if ($folderData) {
|
||||
foreach ($folderData as $uId => $folderId) {
|
||||
$email->setLinkMultipleColumn('users', 'folderId', $uId, $folderId);
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2017 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/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Mail\Parsers;
|
||||
|
||||
class MailMimeParser
|
||||
{
|
||||
private $entityManager;
|
||||
|
||||
private $parser = array();
|
||||
|
||||
protected $messageHash = array();
|
||||
|
||||
public function __construct($entityManager)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
protected function getEntityManager()
|
||||
{
|
||||
return $this->entityManager;
|
||||
}
|
||||
|
||||
protected function getParser()
|
||||
{
|
||||
if (!$this->parser) {
|
||||
$this->parser = new \ZBateson\MailMimeParser\MailMimeParser();
|
||||
}
|
||||
|
||||
return $this->parser;
|
||||
}
|
||||
|
||||
protected function loadContent($message)
|
||||
{
|
||||
$raw = $message->getFullRawContent();
|
||||
$key = spl_object_hash($message);
|
||||
$this->messageHash[$key] = $this->getParser()->parse($raw);
|
||||
}
|
||||
|
||||
protected function getMessage($message)
|
||||
{
|
||||
$key = spl_object_hash($message);
|
||||
if (!array_key_exists($key, $this->messageHash)) {
|
||||
$raw = $message->getRawHeader();
|
||||
if (!$raw) {
|
||||
$raw = $message->getFullRawContent();
|
||||
}
|
||||
$this->messageHash[$key] = $this->getParser()->parse($raw);
|
||||
}
|
||||
|
||||
return $this->messageHash[$key];
|
||||
}
|
||||
|
||||
public function checkMessageAttribute($message, $attribute)
|
||||
{
|
||||
return $this->getMessage($message)->getHeaderValue($attribute) !== null;
|
||||
}
|
||||
|
||||
public function getMessageAttribute($message, $attribute)
|
||||
{
|
||||
if (!$this->checkMessageAttribute($message, $attribute)) return null;
|
||||
|
||||
return $this->getMessage($message)->getHeaderValue($attribute);
|
||||
}
|
||||
|
||||
public function getMessageMessageId($message)
|
||||
{
|
||||
return $this->getMessageAttribute($message, 'Message-ID');
|
||||
}
|
||||
|
||||
public function getAddressNameMap($message)
|
||||
{
|
||||
$map = (object) [];
|
||||
|
||||
foreach (['from', 'to', 'cc', 'reply-To'] as $type) {
|
||||
$header = $this->getMessage($message)->getHeader($type);
|
||||
if ($header) {
|
||||
$list = $header->getAddresses();
|
||||
foreach ($list as $item) {
|
||||
$address = $item->getEmail();
|
||||
$name = $item->getName();
|
||||
if ($name && $address) {
|
||||
$map->$address = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
public function getAddressDataFromMessage($message, $type)
|
||||
{
|
||||
$addressList = [];
|
||||
$header = $this->getMessage($message)->getHeader($type);
|
||||
if ($header) {
|
||||
foreach ($header->getAddresses() as $item) {
|
||||
return [
|
||||
'address' => $item->getEmail(),
|
||||
'name' => $item->getName()
|
||||
];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getAddressListFromMessage($message, $type)
|
||||
{
|
||||
$addressList = [];
|
||||
$header = $this->getMessage($message)->getHeader($type);
|
||||
if ($header) {
|
||||
$list = $header->getAddresses();
|
||||
foreach ($list as $address) {
|
||||
$addressList[] = $address->getEmail();
|
||||
}
|
||||
}
|
||||
return $addressList;
|
||||
}
|
||||
|
||||
public function fetchContentParts(\Espo\Entities\Email $email, $message)
|
||||
{
|
||||
$this->loadContent($message);
|
||||
|
||||
$bodyPlain = $this->getMessage($message)->getTextContent();
|
||||
$bodyHtml = $this->getMessage($message)->getHtmlContent();
|
||||
|
||||
if ($bodyHtml) {
|
||||
$email->set('isHtml', true);
|
||||
$email->set('body', $bodyHtml);
|
||||
$email->set('bodyPlain', $bodyPlain);
|
||||
} else {
|
||||
$email->set('isHtml', false);
|
||||
$email->set('body', $bodyPlain);
|
||||
}
|
||||
|
||||
if (!$email->get('body') && $email->get('bodyPlain')) {
|
||||
$email->set('body', $email->get('bodyPlain'));
|
||||
}
|
||||
|
||||
$attachmentObjList = $this->getMessage($message)->getAllAttachmentParts();
|
||||
$inlineIds = array();
|
||||
|
||||
foreach ($attachmentObjList as $attachmentObj) {
|
||||
$attachment = $this->getEntityManager()->getEntity('Attachment');
|
||||
|
||||
$content = $attachmentObj->getContent();
|
||||
|
||||
$disposition = $attachmentObj->getHeaderValue('Content-Disposition');
|
||||
|
||||
$attachment = $this->getEntityManager()->getEntity('Attachment');
|
||||
$attachment->set('name', $attachmentObj->getHeaderParameter('Content-Disposition', 'filename', 'unnamed'));
|
||||
$attachment->set('type', $attachmentObj->getHeaderValue('Content-Type'));
|
||||
|
||||
$contentId = $attachmentObj->getHeaderValue('Content-ID');
|
||||
|
||||
if ($contentId) {
|
||||
$contentId = trim($contentId, '<>');
|
||||
}
|
||||
|
||||
if ($disposition == 'inline') {
|
||||
$attachment->set('role', 'Inline Attachment');
|
||||
} else {
|
||||
$attachment->set('role', 'Attachment');
|
||||
}
|
||||
|
||||
$attachment->set('contents', $content);
|
||||
|
||||
$this->getEntityManager()->saveEntity($attachment);
|
||||
|
||||
if ($disposition == 'attachment') {
|
||||
$email->addLinkMultipleId('attachments', $attachment->id);
|
||||
if ($contentId) {
|
||||
$inlineIds[$contentId] = $attachment->id;
|
||||
}
|
||||
} else if ($disposition == 'inline') {
|
||||
if ($contentId) {
|
||||
$inlineIds[$contentId] = $attachment->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$body = $email->get('body');
|
||||
|
||||
if (!empty($body)) {
|
||||
foreach ($inlineIds as $cid => $attachmentId) {
|
||||
if (strpos($body, 'cid:' . $cid) !== false) {
|
||||
$body = str_replace('cid:' . $cid, '?entryPoint=attachment&id=' . $attachmentId, $body);
|
||||
} else {
|
||||
$email->addLinkMultipleId('attachments', $attachmentId);
|
||||
}
|
||||
}
|
||||
$email->set('body', $body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +85,42 @@ class PhpMimeMailParser
|
||||
return $this->getMessageAttribute($message, 'Message-ID');
|
||||
}
|
||||
|
||||
public function getAddressNameMap($message)
|
||||
{
|
||||
$map = (object) [];
|
||||
|
||||
foreach (['from', 'to', 'cc', 'reply-To'] as $type) {
|
||||
if ($this->checkMessageAttribute($message, $type)) {
|
||||
$list = $this->getParser($message)->getAddresses($type);
|
||||
foreach ($list as $item) {
|
||||
$name = $list[0]['display'];
|
||||
$address = $list[0]['address'];
|
||||
if ($name && $address && $name !== $address) {
|
||||
$map->$address = $name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
public function getAddressDataFromMessage($message, $type)
|
||||
{
|
||||
$addressList = [];
|
||||
if ($this->checkMessageAttribute($message, $type)) {
|
||||
$list = $this->getParser($message)->getAddresses($type);
|
||||
if (count($list)) {
|
||||
return [
|
||||
'address' => $list[0]['address'],
|
||||
'name' => $list[0]['display'],
|
||||
];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getAddressListFromMessage($message, $type)
|
||||
{
|
||||
$addressList = [];
|
||||
@@ -130,9 +166,10 @@ class PhpMimeMailParser
|
||||
$attachment->set('name', $attachmentObj->getFileName());
|
||||
$attachment->set('type', $attachmentObj->getContentType());
|
||||
|
||||
$contentId = $attachmentObj->getContentID();
|
||||
|
||||
if ($disposition == 'inline') {
|
||||
$attachment->set('role', 'Inline Attachment');
|
||||
$contentId = $attachmentObj->getContentID();
|
||||
} else {
|
||||
$attachment->set('role', 'Attachment');
|
||||
}
|
||||
@@ -142,11 +179,14 @@ class PhpMimeMailParser
|
||||
$this->getEntityManager()->saveEntity($attachment);
|
||||
|
||||
if ($disposition == 'attachment') {
|
||||
$attachmentsIds = $email->get('attachmentsIds');
|
||||
$attachmentsIds[] = $attachment->id;
|
||||
$email->set('attachmentsIds', $attachmentsIds);
|
||||
$email->addLinkMultipleId('attachments', $attachment->id);
|
||||
if ($contentId) {
|
||||
$inlineIds[$contentId] = $attachment->id;
|
||||
}
|
||||
} else if ($disposition == 'inline') {
|
||||
$inlineIds[$contentId] = $attachment->id;
|
||||
if ($contentId) {
|
||||
$inlineIds[$contentId] = $attachment->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,9 @@ class Parser extends \PhpMimeMailParser\Parser
|
||||
&& substr($part['content-type'], 0, 10) !== 'multipart/'
|
||||
) {
|
||||
// if we cannot get it by getMessageBody(), we assume it is an attachment
|
||||
$disposition = 'attachment';
|
||||
if ($disposition !== 'inline') {
|
||||
$disposition = 'attachment';
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($disposition, $dispositions) === true && isset($filename) === true) {
|
||||
|
||||
@@ -72,6 +72,45 @@ class ZendMail
|
||||
return $messageId;
|
||||
}
|
||||
|
||||
public function getAddressNameMap($message)
|
||||
{
|
||||
$map = (object) [];
|
||||
|
||||
$zendMessage = $message->getZendMessage();
|
||||
|
||||
foreach (['from', 'to', 'cc', 'reply-To'] as $type) {
|
||||
if (isset($zendMessage->$type)) {
|
||||
$list = $this->normilizeHeader($zendMessage->getHeader($type))->getAddressList();
|
||||
foreach ($list as $item) {
|
||||
$name = $item->getName();
|
||||
$address = $item->getEmail();
|
||||
if ($name && $address && $name !== $address) {
|
||||
$map->$address = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
public function getAddressDataFromMessage($message, $type)
|
||||
{
|
||||
$zendMessage = $message->getZendMessage();
|
||||
|
||||
$addressList = array();
|
||||
if (isset($zendMessage->$type)) {
|
||||
$list = $this->normilizeHeader($zendMessage->getHeader($type))->getAddressList();
|
||||
foreach ($list as $address) {
|
||||
return [
|
||||
'address' => $address->getEmail(),
|
||||
'name' => $address->getName()
|
||||
];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getAddressListFromMessage($message, $type)
|
||||
{
|
||||
$zendMessage = $message->getZendMessage();
|
||||
@@ -227,6 +266,13 @@ class ZendMail
|
||||
$attachmentsIds = $email->get('attachmentsIds');
|
||||
$attachmentsIds[] = $attachment->id;
|
||||
$email->set('attachmentsIds', $attachmentsIds);
|
||||
|
||||
if (isset($part->contentID)) {
|
||||
$contentId = trim($part->contentID, '<>');
|
||||
if ($contentId) {
|
||||
$inlineIds[$contentId] = $attachment->id;
|
||||
}
|
||||
}
|
||||
} else if ($disposition == 'inline') {
|
||||
$inlineIds[$contentId] = $attachment->id;
|
||||
}
|
||||
|
||||
@@ -189,6 +189,16 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
|
||||
$this->getEntityManager()->getHookManager()->process($this->entityType, 'afterRemove', $entity, $options);
|
||||
}
|
||||
|
||||
protected function afterMassRelate(Entity $entity, $relationName, array $params = array(), array $options = array())
|
||||
{
|
||||
$hookData = array(
|
||||
'relationName' => $relationName,
|
||||
'relationParams' => $params
|
||||
);
|
||||
|
||||
$this->getEntityManager()->getHookManager()->process($this->entityType, 'afterMassRelate', $entity, $options, $hookData);
|
||||
}
|
||||
|
||||
public function remove(Entity $entity, array $options = array())
|
||||
{
|
||||
$result = parent::remove($entity, $options);
|
||||
|
||||
@@ -178,6 +178,15 @@ class AclManager extends \Espo\Core\AclManager
|
||||
return parent::checkReadOnlyTeam($user, $scope);
|
||||
}
|
||||
|
||||
public function checkReadNo(User $user, $scope)
|
||||
{
|
||||
if ($this->checkUserIsNotPortal($user)) {
|
||||
$data = $this->getTable($user)->getScopeData($scope);
|
||||
return $this->getMainManager()->checkReadNo($user, $data);
|
||||
}
|
||||
return parent::checkReadNo($user, $scope);
|
||||
}
|
||||
|
||||
public function checkReadOnlyOwn(User $user, $scope)
|
||||
{
|
||||
if ($this->checkUserIsNotPortal($user)) {
|
||||
|
||||
@@ -35,11 +35,6 @@ class Language extends \Espo\Core\Utils\Language
|
||||
{
|
||||
public function setPortal($portal)
|
||||
{
|
||||
if ($portal->get('language') !== '' && $portal->get('language')) {
|
||||
if (!$this->getPreferences()->get('language')) {
|
||||
$this->setLanguage($portal->get('language'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,7 +57,9 @@ class Base
|
||||
|
||||
private $userTimeZone = null;
|
||||
|
||||
protected $additionalFilterTypeList = ['linkedWith', 'inCategory', 'isUserFromTeams'];
|
||||
protected $additionalFilterTypeList = ['inCategory', 'isUserFromTeams'];
|
||||
|
||||
protected $textFilterUseContainsAttributeList = [];
|
||||
|
||||
const MIN_LENGTH_FOR_CONTENT_SEARCH = 4;
|
||||
|
||||
@@ -144,7 +146,7 @@ class Base
|
||||
$list = $this->getMetadata()->get(['entityDefs', $this->getEntityType(), 'fields', $sortBy, 'options']);
|
||||
if ($list && is_array($list) && count($list)) {
|
||||
if ($this->getMetadata()->get(['entityDefs', $this->getEntityType(), 'fields', $sortBy, 'isSorted'])) {
|
||||
$list = asort($list);
|
||||
asort($list);
|
||||
}
|
||||
if ($desc) {
|
||||
$list = array_reverse($list);
|
||||
@@ -210,7 +212,7 @@ class Base
|
||||
foreach ($where as $item) {
|
||||
$type = $item['type'];
|
||||
if (!in_array($type, $ignoreTypeList)) {
|
||||
$part = $this->getWherePart($item);
|
||||
$part = $this->getWherePart($item, $result);
|
||||
if (!empty($part)) {
|
||||
$whereClause[] = $part;
|
||||
}
|
||||
@@ -257,13 +259,18 @@ class Base
|
||||
|
||||
$defs = $relDefs[$link];
|
||||
if ($relationType == 'manyMany') {
|
||||
$this->addJoin([$link, $link . 'Filter'], $result);
|
||||
$this->addLeftJoin([$link, $link . 'Filter'], $result);
|
||||
$midKeys = $seed->getRelationParam($link, 'midKeys');
|
||||
|
||||
if (!empty($midKeys)) {
|
||||
$key = $midKeys[1];
|
||||
$part[$link . 'Filter' . 'Middle.' . $key] = $idsValue;
|
||||
}
|
||||
} else if ($relationType == 'hasMany') {
|
||||
$alias = $link . 'Filter';
|
||||
$this->addLeftJoin([$link, $alias], $result);
|
||||
|
||||
$part[$alias . '.id'] = $idsValue;
|
||||
} else if ($relationType == 'belongsTo') {
|
||||
$key = $seed->getRelationParam($link, 'key');
|
||||
if (!empty($key)) {
|
||||
@@ -428,6 +435,8 @@ class Base
|
||||
if (!$this->getUser()->isAdmin()) {
|
||||
if ($this->getAcl()->checkReadOnlyTeam($this->getEntityType())) {
|
||||
$this->accessOnlyTeam($result);
|
||||
} else if ($this->getAcl()->checkReadNo($this->getEntityType())) {
|
||||
$this->accessNo($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -440,12 +449,21 @@ class Base
|
||||
} else {
|
||||
if ($this->getAcl()->checkReadOnlyContact($this->getEntityType())) {
|
||||
$this->accessPortalOnlyContact($result);
|
||||
} else if ($this->getAcl()->checkReadNo($this->getEntityType())) {
|
||||
$this->accessNo($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function accessNo(&$result)
|
||||
{
|
||||
$result['whereClause'][] = array(
|
||||
'id' => null
|
||||
);
|
||||
}
|
||||
|
||||
protected function accessOnlyOwn(&$result)
|
||||
{
|
||||
if ($this->hasAssignedUsersField()) {
|
||||
@@ -724,7 +742,7 @@ class Base
|
||||
$attribute = $w['attribute'];
|
||||
}
|
||||
if ($attribute) {
|
||||
if (isset($w['type']) && $w['type'] === 'linkedWith') {
|
||||
if (isset($w['type']) && in_array($w['type'], ['isLinked', 'isNotLinked', 'linkedWith', 'notLinkedWith', 'isUserFromTeams'])) {
|
||||
if (in_array($attribute, $this->getAcl()->getScopeForbiddenFieldList($this->getEntityType()))) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
@@ -928,7 +946,7 @@ class Base
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function getWherePart($item)
|
||||
protected function getWherePart($item, &$result = null)
|
||||
{
|
||||
$part = array();
|
||||
|
||||
@@ -940,22 +958,29 @@ class Base
|
||||
$attribute = $item['attribute'];
|
||||
}
|
||||
|
||||
if (!is_null($attribute) && !is_string($attribute)) {
|
||||
throw new Error('Bad attribute in where statement');
|
||||
}
|
||||
|
||||
if (!empty($attribute) && !empty($item['type'])) {
|
||||
$methodName = 'getWherePart' . ucfirst($attribute) . ucfirst($item['type']);
|
||||
if (method_exists($this, $methodName)) {
|
||||
$value = null;
|
||||
if (!empty($item['value'])) {
|
||||
if (array_key_exists('value', $item)) {
|
||||
$value = $item['value'];
|
||||
}
|
||||
return $this->$methodName($value);
|
||||
return $this->$methodName($value, $result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!empty($item['dateTime'])) {
|
||||
return $this->convertDateTimeWhere($item);
|
||||
}
|
||||
|
||||
if (!array_key_exists('value', $item)) {
|
||||
$item['value'] = null;
|
||||
}
|
||||
|
||||
if (!empty($item['type'])) {
|
||||
switch ($item['type']) {
|
||||
case 'or':
|
||||
@@ -963,7 +988,7 @@ class Base
|
||||
if (is_array($item['value'])) {
|
||||
$arr = array();
|
||||
foreach ($item['value'] as $i) {
|
||||
$a = $this->getWherePart($i);
|
||||
$a = $this->getWherePart($i, $result);
|
||||
foreach ($a as $left => $right) {
|
||||
if (!empty($right) || is_null($right) || $right === '') {
|
||||
$arr[] = array($left => $right);
|
||||
@@ -1107,7 +1132,7 @@ class Base
|
||||
$quarter--;
|
||||
if ($quarter == 0) {
|
||||
$quarter = 4;
|
||||
$dt->sub('P1Y');
|
||||
$dt->modify('-1 year');
|
||||
}
|
||||
$part['AND'] = array(
|
||||
$attribute . '>=' => $dt->add(new \DateInterval('P'.(($quarter - 1) * 3).'M'))->format('Y-m-d'),
|
||||
@@ -1136,6 +1161,96 @@ class Base
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'isNotLinked':
|
||||
if (!$result) break;
|
||||
$alias = $attribute . 'IsNotLinkedFilter' . strval(rand(10000, 99999));;
|
||||
$part[$alias . '.id'] = null;
|
||||
$this->setDistinct(true, $result);
|
||||
$this->addLeftJoin([$attribute, $alias], $result);
|
||||
break;
|
||||
case 'isLinked':
|
||||
if (!$result) break;
|
||||
$alias = $attribute . 'IsLinkedFilter' . strval(rand(10000, 99999));;
|
||||
$part[$alias . '.id!='] = null;
|
||||
$this->setDistinct(true, $result);
|
||||
$this->addLeftJoin([$attribute, $alias], $result);
|
||||
break;
|
||||
case 'linkedWith':
|
||||
$seed = $this->getSeed();
|
||||
$link = $attribute;
|
||||
if (!$seed->hasRelation($link)) break;
|
||||
|
||||
$alias = $link . 'Filter' . strval(rand(10000, 99999));
|
||||
|
||||
$value = $item['value'];
|
||||
|
||||
if (is_null($value)) break;
|
||||
|
||||
$relationType = $seed->getRelationType($link);
|
||||
|
||||
if ($relationType == 'manyMany') {
|
||||
$this->addLeftJoin([$link, $alias], $result);
|
||||
$midKeys = $seed->getRelationParam($link, 'midKeys');
|
||||
|
||||
if (!empty($midKeys)) {
|
||||
$key = $midKeys[1];
|
||||
$part[$alias . 'Middle.' . $key] = $value;
|
||||
}
|
||||
} else if ($relationType == 'hasMany') {
|
||||
$this->addLeftJoin([$link, $alias], $result);
|
||||
|
||||
$part[$alias . '.id'] = $value;
|
||||
} else if ($relationType == 'belongsTo') {
|
||||
$key = $seed->getRelationParam($link, 'key');
|
||||
if (!empty($key)) {
|
||||
$part[$key] = $value;
|
||||
}
|
||||
} else if ($relationType == 'hasOne') {
|
||||
$this->addLeftJoin([$link, $alias], $result);
|
||||
$part[$alias . '.id'] = $value;
|
||||
} else {
|
||||
break;;
|
||||
}
|
||||
$this->setDistinct(true, $result);
|
||||
break;
|
||||
case 'notLinkedWith':
|
||||
$seed = $this->getSeed();
|
||||
$link = $attribute;
|
||||
if (!$seed->hasRelation($link)) break;
|
||||
|
||||
$value = $item['value'];
|
||||
|
||||
if (is_null($value)) break;
|
||||
|
||||
$relationType = $seed->getRelationType($link);
|
||||
|
||||
$alias = $link . 'NotLinkedFilter' . strval(rand(10000, 99999));
|
||||
|
||||
if ($relationType == 'manyMany') {
|
||||
$this->addLeftJoin([$link, $alias], $result);
|
||||
$midKeys = $seed->getRelationParam($link, 'midKeys');
|
||||
|
||||
if (!empty($midKeys)) {
|
||||
$key = $midKeys[1];
|
||||
$result['joinConditions'][$alias] = [$key => $value];
|
||||
$part[$alias . 'Middle.' . $key] = null;
|
||||
}
|
||||
} else if ($relationType == 'hasMany') {
|
||||
$this->addLeftJoin([$link, $alias], $result);
|
||||
$result['joinConditions'][$alias] = ['id' => $value];
|
||||
$part[$alias . '.id'] = null;
|
||||
} else if ($relationType == 'belongsTo') {
|
||||
$key = $seed->getRelationParam($link, 'key');
|
||||
if (!empty($key)) {
|
||||
$part[$key . '!='] = $value;
|
||||
}
|
||||
} else if ($relationType == 'hasOne') {
|
||||
$this->addLeftJoin([$link, alias], $result);
|
||||
$part[$alias . '.id!='] = $value;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
$this->setDistinct(true, $result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1322,6 +1437,9 @@ class Base
|
||||
(
|
||||
!empty($fieldDefs[$field]['type']) && $fieldDefs[$field]['type'] == 'text'
|
||||
||
|
||||
!empty($this->textFilterUseContainsAttributeList[$field])
|
||||
||
|
||||
!empty($fieldDefs[$field]['type']) && $fieldDefs[$field]['type'] == 'varchar' &&
|
||||
$this->getConfig()->get('textFilterUseContainsForVarchar')
|
||||
)
|
||||
) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"tab": true,
|
||||
"acl": true,
|
||||
"aclPortal": true,
|
||||
"aclPortalLevelList": ["all", "account", "own", "no"],
|
||||
"aclPortalLevelList": ["all", "account", "contact", "own", "no"],
|
||||
"customizable": true,
|
||||
"importable": true,
|
||||
"notifications": true
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"tab": true,
|
||||
"acl": true,
|
||||
"aclPortal": true,
|
||||
"aclPortalLevelList": ["all", "account", "own", "no"],
|
||||
"aclPortalLevelList": ["all", "account", "contact", "own", "no"],
|
||||
"customizable": true,
|
||||
"importable": true,
|
||||
"notifications": true
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"tab": true,
|
||||
"acl": true,
|
||||
"aclPortal": true,
|
||||
"aclPortalLevelList": ["all", "account", "own", "no"],
|
||||
"aclPortalLevelList": ["all", "account", "contact", "own", "no"],
|
||||
"customizable": true,
|
||||
"importable": true,
|
||||
"notifications": true
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
{
|
||||
"controller": "controllers/record",
|
||||
"boolFilterList": ["onlyMy"],
|
||||
"recordViews": {
|
||||
"detail": "views/templates/event/record/detail"
|
||||
},
|
||||
"activityDefs": {
|
||||
"activitiesCreate": true,
|
||||
"historyCreate": true
|
||||
|
||||
@@ -33,12 +33,12 @@
|
||||
"options": [300, 600, 900, 1800, 2700, 3600, 7200],
|
||||
"default": 300,
|
||||
"notStorable": true,
|
||||
"select": "TIMESTAMPDIFF(SECOND, date_start, date_end)",
|
||||
"select": "TIMESTAMPDIFF(SECOND, {tableName}.date_start, {tableName}.date_end)",
|
||||
"orderBy": "duration {direction}"
|
||||
},
|
||||
"parent": {
|
||||
"type": "linkParent",
|
||||
"entityList": ["Account", "Lead"]
|
||||
"entityList": ["Account", "Lead", "Contact"]
|
||||
},
|
||||
"description": {
|
||||
"type": "text"
|
||||
@@ -46,7 +46,8 @@
|
||||
"reminders": {
|
||||
"type": "jsonArray",
|
||||
"notStorable": true,
|
||||
"view": "crm:views/meeting/fields/reminders"
|
||||
"view": "crm:views/meeting/fields/reminders",
|
||||
"layoutListDisabled": true
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "datetime",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"tab": true,
|
||||
"acl": true,
|
||||
"aclPortal": true,
|
||||
"aclPortalLevelList": ["all", "account", "own", "no"],
|
||||
"aclPortalLevelList": ["all", "account", "contact", "own", "no"],
|
||||
"customizable": true,
|
||||
"importable": true,
|
||||
"notifications": true
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "Opret {entityTypeTranslated} "
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"links": {
|
||||
"meetings": "Møder",
|
||||
"calls": "Opkald",
|
||||
"tasks": "Opgaver"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Opret {entityTypeTranslated} "
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"fields": {
|
||||
"billingAddress": "Betalingsadresse",
|
||||
"shippingAddress": "Leveringsadresse",
|
||||
"website": "Website"
|
||||
},
|
||||
"links": {
|
||||
"meetings": "Møder",
|
||||
"calls": "Opkald",
|
||||
"tasks": "Opgaver"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Opret {entityTypeTranslated} "
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"fields": {
|
||||
"parent": "Henviser til",
|
||||
"dateStart": "Startdato",
|
||||
"dateEnd": "Slutdato",
|
||||
"duration": "Varighed",
|
||||
"status": "Status",
|
||||
"reminders": "Underretninger"
|
||||
},
|
||||
"links": {
|
||||
"parent": "Henviser til"
|
||||
},
|
||||
"options": {
|
||||
"status": {
|
||||
"Planned": "Planlagt",
|
||||
"Held": "Gennemført",
|
||||
"Not Held": "Ikke Gennemført"
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Opret {entityTypeTranslated}",
|
||||
"Schedule {entityType}": "Planlæg {entityTypeTranslated}",
|
||||
"Log {entityType}": "Log {entityTypeTranslated}",
|
||||
"Set Held": "Marker som Gennemført",
|
||||
"Set Not Held": "Marker som Ikke Gennemført"
|
||||
},
|
||||
"massActions": {
|
||||
"setHeld": "Marker som Gennemført",
|
||||
"setNotHeld": "Marker som Ikke Gennemført"
|
||||
},
|
||||
"presetFilters": {
|
||||
"planned": "Planlagt",
|
||||
"held": "Gennemført",
|
||||
"todays": "Dagens"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"fields": {
|
||||
"address": "Adresse"
|
||||
},
|
||||
"links": {
|
||||
"meetings": "Møder",
|
||||
"calls": "Opkald",
|
||||
"tasks": "Opgaver"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Opret {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,8 @@
|
||||
"dateStart": "Startdatum",
|
||||
"dateEnd": "Enddatum",
|
||||
"duration": "Dauer",
|
||||
"status": "Status"
|
||||
"status": "Status",
|
||||
"reminders": "Erinnerungen"
|
||||
},
|
||||
"links": {
|
||||
"parent": "Bezieht sich auf"
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "Opprett {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"links": {
|
||||
"meetings": "Møter",
|
||||
"calls": "Samtaler",
|
||||
"tasks": "Oppgaver"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Opprett {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"fields": {
|
||||
"billingAddress": "Faktureringsadresse",
|
||||
"shippingAddress": "Leveringsadresse",
|
||||
"website": "Nettside"
|
||||
},
|
||||
"links": {
|
||||
"meetings": "Møter",
|
||||
"calls": "Samtaler",
|
||||
"tasks": "Oppgaver"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Opprett {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"fields": {
|
||||
"parent": "Forelder",
|
||||
"dateStart": "Startdato",
|
||||
"dateEnd": "Sluttdato",
|
||||
"duration": "Varighet",
|
||||
"status": "Status",
|
||||
"reminders": "Påminnelser"
|
||||
},
|
||||
"links": {
|
||||
"parent": "Forelder"
|
||||
},
|
||||
"options": {
|
||||
"status": {
|
||||
"Planned": "Planlagt",
|
||||
"Held": "Gjennomført",
|
||||
"Not Held": "Ikke gjennomført"
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Opprett {entityTypeTranslated}",
|
||||
"Schedule {entityType}": "Planlegg {entityTypeTranslated}",
|
||||
"Log {entityType}": "Logg {entityTypeTranslated}",
|
||||
"Set Held": "Merk som gjennomført",
|
||||
"Set Not Held": "Merk som ikke gjennomført"
|
||||
},
|
||||
"massActions": {
|
||||
"setHeld": "Merk som gjennomført",
|
||||
"setNotHeld": "Merk som ikke gjennomført"
|
||||
},
|
||||
"presetFilters": {
|
||||
"planned": "Planlagt",
|
||||
"held": "Gjennomført",
|
||||
"todays": "Dagens"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"fields": {
|
||||
"address": "Adresse"
|
||||
},
|
||||
"links": {
|
||||
"meetings": "Møter",
|
||||
"calls": "Samtaler",
|
||||
"tasks": "Oppgaver"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Opprett {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "{entityTypeTranslated} Oluştur"
|
||||
}
|
||||
}
|
||||
"labels": {
|
||||
"Create {entityType}": "{entityTypeTranslated} oluştur"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "{entityTypeTranslated} Oluştur"
|
||||
}
|
||||
}
|
||||
"links": {
|
||||
"meetings": "Toplantılar",
|
||||
"calls": "(Seslenme)",
|
||||
"tasks": "Görevler"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "{entityTypeTranslated} oluştur"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,15 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "{entityTypeTranslated} Oluştur"
|
||||
}
|
||||
}
|
||||
"fields": {
|
||||
"billingAddress": "Fatura Adresi",
|
||||
"shippingAddress": "Teslimat Adresi",
|
||||
"website": "Web sitesi "
|
||||
},
|
||||
"links": {
|
||||
"meetings": "Toplantılar",
|
||||
"calls": "(Seslenme)",
|
||||
"tasks": "Görevler"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "{entityTypeTranslated} oluştur"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,36 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "{entityTypeTranslated} Oluştur"
|
||||
"fields": {
|
||||
"parent": "Üst",
|
||||
"dateStart": "Başlangıç Tarihi",
|
||||
"dateEnd": "Son Tarih",
|
||||
"duration": "Süre ",
|
||||
"status": "Durum ",
|
||||
"reminders": "Hatırlatıcılar"
|
||||
},
|
||||
"links": {
|
||||
"parent": "Üst"
|
||||
},
|
||||
"options": {
|
||||
"status": {
|
||||
"Planned": "Planlandı",
|
||||
"Held": "Düzenlenen",
|
||||
"Not Held": "Düzenlenmedi"
|
||||
}
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "{entityTypeTranslated} oluştur",
|
||||
"Schedule {entityType}": "Zamanlama {entityTypeTranslated}",
|
||||
"Log {entityType}": "{entityTypeTranslated} günlüğünü kaydet",
|
||||
"Set Held": "Düzenlendi",
|
||||
"Set Not Held": "Düzenlenmedi olarak ayarla"
|
||||
},
|
||||
"massActions": {
|
||||
"setHeld": "Düzenlendi",
|
||||
"setNotHeld": "Düzenlenmedi olarak ayarla"
|
||||
},
|
||||
"presetFilters": {
|
||||
"planned": "Planlandı",
|
||||
"held": "Düzenlenen",
|
||||
"todays": "Bugünün"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,13 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "{entityTypeTranslated} Oluştur"
|
||||
}
|
||||
}
|
||||
"fields": {
|
||||
"address": "Adres "
|
||||
},
|
||||
"links": {
|
||||
"meetings": "Toplantılar",
|
||||
"calls": "(Seslenme)",
|
||||
"tasks": "Görevler"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "{entityTypeTranslated} oluştur"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "Створити {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
"labels": {
|
||||
"Create {entityType}": "Створити {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "Створити {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
"links": {
|
||||
"meetings": "Зустрічі",
|
||||
"calls": "Дзвінки",
|
||||
"tasks": "Завдання"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Створити {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,15 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "Створити {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
"fields": {
|
||||
"billingAddress": "Billing Address",
|
||||
"shippingAddress": "Адреса доставки",
|
||||
"website": "Вебсайт"
|
||||
},
|
||||
"links": {
|
||||
"meetings": "Зустрічі",
|
||||
"calls": "Дзвінки",
|
||||
"tasks": "Завдання"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Створити {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,36 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "Створити {entityTypeTranslated}"
|
||||
"fields": {
|
||||
"parent": "Джерело",
|
||||
"dateStart": "Дата початку",
|
||||
"dateEnd": "Дата завершення",
|
||||
"duration": "Тривалість",
|
||||
"status": "Статус",
|
||||
"reminders": "Нагадування"
|
||||
},
|
||||
"links": {
|
||||
"parent": "Джерело"
|
||||
},
|
||||
"options": {
|
||||
"status": {
|
||||
"Planned": "Плановий",
|
||||
"Held": "Вміщений",
|
||||
"Not Held": "Не вміщений"
|
||||
}
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Створити {entityTypeTranslated}",
|
||||
"Schedule {entityType}": "Розклад {entityTypeTranslated} ",
|
||||
"Log {entityType}": "Log {entityTypeTranslated}",
|
||||
"Set Held": "Set Held",
|
||||
"Set Not Held": "Set Not Held"
|
||||
},
|
||||
"massActions": {
|
||||
"setHeld": "Set Held",
|
||||
"setNotHeld": "Set Not Held"
|
||||
},
|
||||
"presetFilters": {
|
||||
"planned": "Планований",
|
||||
"held": "Вміщений ",
|
||||
"todays": "Сьогоднішні"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,13 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "Створити {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
"fields": {
|
||||
"address": "Адреса"
|
||||
},
|
||||
"links": {
|
||||
"meetings": "Зустрічі",
|
||||
"calls": "Дзвінки",
|
||||
"tasks": "Завдання"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Створити {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "创建 {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"links": {
|
||||
"meetings": "会晤",
|
||||
"calls": "通话",
|
||||
"tasks": "任务"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "创建 {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"fields": {
|
||||
"billingAddress": "账单地址",
|
||||
"shippingAddress": "邮寄地址",
|
||||
"website": "网站"
|
||||
},
|
||||
"links": {
|
||||
"meetings": "会晤",
|
||||
"calls": "通话",
|
||||
"tasks": "任务"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "创建 {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"fields": {
|
||||
"parent": "关联",
|
||||
"dateStart": "开始日期",
|
||||
"dateEnd": "结束日期",
|
||||
"duration": "持续时间",
|
||||
"status": "状态",
|
||||
"reminders": "提醒"
|
||||
},
|
||||
"links": {
|
||||
"parent": "关联"
|
||||
},
|
||||
"options": {
|
||||
"status": {
|
||||
"Planned": "已计划",
|
||||
"Held": "已举行",
|
||||
"Not Held": "未举行"
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "创建 {entityTypeTranslated}",
|
||||
"Schedule {entityType}": "计划 {entityTypeTranslated}",
|
||||
"Log {entityType}": "记录 {entityTypeTranslated} ",
|
||||
"Set Held": "设为已举行",
|
||||
"Set Not Held": "设为未举行"
|
||||
},
|
||||
"massActions": {
|
||||
"setHeld": "设为已举行",
|
||||
"setNotHeld": "设为未举行"
|
||||
},
|
||||
"presetFilters": {
|
||||
"planned": "已计划",
|
||||
"held": "已举行",
|
||||
"todays": "今天的"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"fields": {
|
||||
"address": "地址"
|
||||
},
|
||||
"links": {
|
||||
"meetings": "会晤",
|
||||
"calls": "通话",
|
||||
"tasks": "任务"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "创建 {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,13 @@ class Auth extends \Slim\Middleware
|
||||
list($authUsername, $authPassword) = explode(':', base64_decode($espoAuth));
|
||||
}
|
||||
|
||||
if (!isset($authUsername)) {
|
||||
if (!empty($_COOKIE['auth-username']) && !empty($_COOKIE['auth-token'])) {
|
||||
$authUsername = $_COOKIE['auth-username'];
|
||||
$authPassword = $_COOKIE['auth-token'];
|
||||
}
|
||||
}
|
||||
|
||||
$espoCgiAuth = $req->headers('HTTP_ESPO_CGI_AUTH');
|
||||
if (empty($espoCgiAuth)) {
|
||||
$espoCgiAuth = $req->headers('REDIRECT_HTTP_ESPO_CGI_AUTH');
|
||||
|
||||
@@ -31,6 +31,89 @@ namespace Espo\Core\Utils\Api;
|
||||
|
||||
class Slim extends \Slim\Slim
|
||||
{
|
||||
public function __construct(array $userSettings = array())
|
||||
{
|
||||
// Setup IoC container
|
||||
$this->container = new \Slim\Helper\Set();
|
||||
$this->container['settings'] = array_merge(static::getDefaultSettings(), $userSettings);
|
||||
|
||||
// Default environment
|
||||
$this->container->singleton('environment', function ($c) {
|
||||
/* ESPOCRM: change Environment class */
|
||||
//return \Slim\Environment::getInstance();
|
||||
return \Espo\Core\Utils\Api\Slim\Environment::getInstance();
|
||||
/* ESPOCRM: end */
|
||||
});
|
||||
|
||||
// Default request
|
||||
$this->container->singleton('request', function ($c) {
|
||||
return new \Slim\Http\Request($c['environment']);
|
||||
});
|
||||
|
||||
// Default response
|
||||
$this->container->singleton('response', function ($c) {
|
||||
return new \Slim\Http\Response();
|
||||
});
|
||||
|
||||
// Default router
|
||||
$this->container->singleton('router', function ($c) {
|
||||
return new \Slim\Router();
|
||||
});
|
||||
|
||||
// Default view
|
||||
$this->container->singleton('view', function ($c) {
|
||||
$viewClass = $c['settings']['view'];
|
||||
$templatesPath = $c['settings']['templates.path'];
|
||||
|
||||
$view = ($viewClass instanceOf \Slim\View) ? $viewClass : new $viewClass;
|
||||
$view->setTemplatesDirectory($templatesPath);
|
||||
return $view;
|
||||
});
|
||||
|
||||
// Default log writer
|
||||
$this->container->singleton('logWriter', function ($c) {
|
||||
$logWriter = $c['settings']['log.writer'];
|
||||
|
||||
return is_object($logWriter) ? $logWriter : new \Slim\LogWriter($c['environment']['slim.errors']);
|
||||
});
|
||||
|
||||
// Default log
|
||||
$this->container->singleton('log', function ($c) {
|
||||
$log = new \Slim\Log($c['logWriter']);
|
||||
$log->setEnabled($c['settings']['log.enabled']);
|
||||
$log->setLevel($c['settings']['log.level']);
|
||||
$env = $c['environment'];
|
||||
$env['slim.log'] = $log;
|
||||
|
||||
return $log;
|
||||
});
|
||||
|
||||
// Default mode
|
||||
$this->container['mode'] = function ($c) {
|
||||
$mode = $c['settings']['mode'];
|
||||
|
||||
if (isset($_ENV['SLIM_MODE'])) {
|
||||
$mode = $_ENV['SLIM_MODE'];
|
||||
} else {
|
||||
$envMode = getenv('SLIM_MODE');
|
||||
if ($envMode !== false) {
|
||||
$mode = $envMode;
|
||||
}
|
||||
}
|
||||
|
||||
return $mode;
|
||||
};
|
||||
|
||||
// Define default middleware stack
|
||||
$this->middleware = array($this);
|
||||
$this->add(new \Slim\Middleware\Flash());
|
||||
$this->add(new \Slim\Middleware\MethodOverride());
|
||||
|
||||
// Make default if first instance
|
||||
if (is_null(static::getInstance())) {
|
||||
$this->setName('default');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Redefine the run method
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2017 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/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Utils\Api\Slim;
|
||||
|
||||
class Environment extends \Slim\Environment
|
||||
{
|
||||
/**
|
||||
* Define undefined $_SERVER variables
|
||||
*/
|
||||
private static function setUndefinedVariables()
|
||||
{
|
||||
$list = array(
|
||||
'REQUEST_METHOD',
|
||||
'REMOTE_ADDR',
|
||||
'SERVER_NAME',
|
||||
'SERVER_PORT',
|
||||
'REQUEST_URI',
|
||||
);
|
||||
|
||||
foreach ($list as $name) {
|
||||
if (!array_key_exists($name, $_SERVER)) {
|
||||
$_SERVER[$name] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getInstance($refresh = false)
|
||||
{
|
||||
static::setUndefinedVariables();
|
||||
|
||||
return parent::getInstance($refresh);
|
||||
}
|
||||
}
|
||||
@@ -109,6 +109,7 @@ class Auth
|
||||
}
|
||||
|
||||
$user->set('isAdmin', $isAdmin);
|
||||
$user->set('ipAddress', $_SERVER['REMOTE_ADDR']);
|
||||
|
||||
$entityManager->setUser($user);
|
||||
$this->getContainer()->setUser($user);
|
||||
@@ -116,7 +117,10 @@ class Auth
|
||||
|
||||
public function login($username, $password)
|
||||
{
|
||||
$authToken = $this->getEntityManager()->getRepository('AuthToken')->where(array('token' => $password))->findOne();
|
||||
$authToken = $this->getEntityManager()->getRepository('AuthToken')->where(array(
|
||||
'token' => $password,
|
||||
'isActive' => true
|
||||
))->findOne();
|
||||
|
||||
if ($authToken) {
|
||||
if (!$this->allowAnyAccess) {
|
||||
@@ -167,6 +171,8 @@ class Auth
|
||||
$user->loadLinkMultipleField('teams');
|
||||
}
|
||||
|
||||
$user->set('ipAddress', $_SERVER['REMOTE_ADDR']);
|
||||
|
||||
$this->getEntityManager()->setUser($user);
|
||||
$this->getContainer()->setUser($user);
|
||||
|
||||
@@ -186,6 +192,7 @@ class Auth
|
||||
|
||||
$this->getEntityManager()->saveEntity($authToken);
|
||||
$user->set('token', $authToken->get('token'));
|
||||
$user->set('authTokenId', $authToken->id);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -201,7 +208,8 @@ class Auth
|
||||
{
|
||||
$authToken = $this->getEntityManager()->getRepository('AuthToken')->where(array('token' => $token))->findOne();
|
||||
if ($authToken) {
|
||||
$this->getEntityManager()->removeEntity($authToken);
|
||||
$authToken->set('isActive', false);
|
||||
$this->getEntityManager()->saveEntity($authToken);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,9 @@ class ClientManager
|
||||
$htmlFilePath = $this->mainHtmlFilePath;
|
||||
}
|
||||
|
||||
if ($this->getConfig()->get('isDeveloperMode')) {
|
||||
$isDeveloperMode = $this->getConfig()->get('isDeveloperMode');
|
||||
|
||||
if ($isDeveloperMode) {
|
||||
if (file_exists('frontend/' . $htmlFilePath)) {
|
||||
$htmlFilePath = 'frontend/' . $htmlFilePath;
|
||||
}
|
||||
@@ -102,6 +104,9 @@ class ClientManager
|
||||
$html = str_replace('{{stylesheet}}', $this->getThemeManager()->getStylesheet(), $html);
|
||||
$html = str_replace('{{runScript}}', $runScript , $html);
|
||||
$html = str_replace('{{basePath}}', $this->basePath , $html);
|
||||
if ($isDeveloperMode) {
|
||||
$html = str_replace('{{useCacheInDeveloperMode}}', $this->getConfig()->get('useCacheInDeveloperMode') ? 'true' : 'false', $html);
|
||||
}
|
||||
|
||||
echo $html;
|
||||
exit;
|
||||
|
||||
@@ -48,6 +48,8 @@ class LinkParent extends Base
|
||||
$fieldName.'Name' => array(
|
||||
'type' => 'varchar',
|
||||
'notStorable' => true,
|
||||
'relation' => $fieldName,
|
||||
'isParentName' => true
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -38,6 +38,18 @@ class BelongsTo extends Base
|
||||
$foreignEntityName = $this->getForeignEntityName();
|
||||
$foreignLinkName = $this->getForeignLinkName();
|
||||
|
||||
|
||||
$noForeignName = false;
|
||||
if (!empty($linkParams['noForeignName'])) {
|
||||
$noForeignName = true;
|
||||
} else {
|
||||
if (!empty($linkParams['foreignName'])) {
|
||||
$foreign = $linkParams['foreignName'];
|
||||
} else {
|
||||
$foreign = $this->getForeignField('name', $foreignEntityName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($linkParams['noJoin'])) {
|
||||
$fieldNameDefs = array(
|
||||
'type' => 'varchar',
|
||||
@@ -49,15 +61,14 @@ class BelongsTo extends Base
|
||||
$fieldNameDefs = array(
|
||||
'type' => 'foreign',
|
||||
'relation' => $linkName,
|
||||
'foreign' => $this->getForeignField('name', $foreignEntityName),
|
||||
'foreign' => $foreign,
|
||||
'notStorable' => false
|
||||
);
|
||||
}
|
||||
|
||||
return array (
|
||||
$data = array (
|
||||
$entityName => array (
|
||||
'fields' => array(
|
||||
$linkName.'Name' => $fieldNameDefs,
|
||||
$linkName.'Id' => array(
|
||||
'type' => 'foreignId',
|
||||
'index' => true
|
||||
@@ -74,6 +85,12 @@ class BelongsTo extends Base
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if (!$noForeignName) {
|
||||
$data[$entityName]['fields'][$linkName.'Name'] = $fieldNameDefs;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,11 +36,18 @@ use Espo\Core\Utils\Util,
|
||||
class Converter
|
||||
{
|
||||
private $dbalSchema;
|
||||
|
||||
private $fileManager;
|
||||
|
||||
private $metadata;
|
||||
|
||||
private $ormMeta = null;
|
||||
|
||||
private $customTablePath = 'application/Espo/Core/Utils/Database/Schema/tables';
|
||||
protected $tablePaths = array(
|
||||
'corePath' => 'application/Espo/Core/Utils/Database/Schema/tables',
|
||||
'modulePath' => 'application/Espo/Modules/{*}/Core/Utils/Database/Schema/tables',
|
||||
'customPath' => 'custom/Espo/Custom/Core/Utils/Database/Schema/tables',
|
||||
);
|
||||
|
||||
protected $typeList;
|
||||
|
||||
@@ -69,13 +76,19 @@ class Converter
|
||||
'foreign'
|
||||
);
|
||||
|
||||
public function __construct(\Espo\Core\Utils\File\Manager $fileManager)
|
||||
public function __construct(\Espo\Core\Utils\Metadata $metadata, \Espo\Core\Utils\File\Manager $fileManager)
|
||||
{
|
||||
$this->metadata = $metadata;
|
||||
$this->fileManager = $fileManager;
|
||||
|
||||
$this->typeList = array_keys(\Doctrine\DBAL\Types\Type::getTypesMap());
|
||||
}
|
||||
|
||||
protected function getMetadata()
|
||||
{
|
||||
return $this->metadata;
|
||||
}
|
||||
|
||||
protected function getFileManager()
|
||||
{
|
||||
return $this->fileManager;
|
||||
@@ -112,12 +125,24 @@ class Converter
|
||||
//check if exist files in "Tables" directory and merge with ormMetadata
|
||||
$ormMeta = Util::merge($ormMeta, $this->getCustomTables($ormMeta));
|
||||
|
||||
if (isset($ormMeta['unsetIgnore'])) {
|
||||
$protectedOrmMeta = array();
|
||||
foreach ($ormMeta['unsetIgnore'] as $protectedKey) {
|
||||
$protectedOrmMeta = Util::merge( $protectedOrmMeta, Util::fillArrayKeys($protectedKey, Util::getValueByKey($ormMeta, $protectedKey)) );
|
||||
}
|
||||
unset($ormMeta['unsetIgnore']);
|
||||
}
|
||||
|
||||
//unset some keys in orm
|
||||
if (isset($ormMeta['unset'])) {
|
||||
$ormMeta = Util::unsetInArray($ormMeta, $ormMeta['unset']);
|
||||
unset($ormMeta['unset']);
|
||||
} //END: unset some keys in orm
|
||||
|
||||
if (isset($protectedOrmMeta)) {
|
||||
$ormMeta = Util::merge($ormMeta, $protectedOrmMeta);
|
||||
}
|
||||
|
||||
if (isset($entityList)) {
|
||||
$entityList = is_string($entityList) ? (array) $entityList : $entityList;
|
||||
|
||||
@@ -144,6 +169,12 @@ class Converter
|
||||
|
||||
$tables[$entityName] = $schema->createTable($tableName);
|
||||
|
||||
if (isset($entityParams['params']) && is_array($entityParams['params'])) {
|
||||
foreach ($entityParams['params'] as $paramName => $paramValue) {
|
||||
$tables[$entityName]->addOption($paramName, $paramValue);
|
||||
}
|
||||
}
|
||||
|
||||
$primaryColumns = array();
|
||||
$uniqueColumns = array();
|
||||
$indexList = array(); //list of indexes like array( array(comlumn1, column2), array(column3))
|
||||
@@ -369,17 +400,22 @@ class Converter
|
||||
*/
|
||||
protected function getCustomTables(array $ormMeta)
|
||||
{
|
||||
$customTables = array();
|
||||
$customTables = $this->loadData($this->tablePaths['corePath']);
|
||||
|
||||
$fileList = $this->getFileManager()->getFileList($this->customTablePath, false, '\.php$', true);
|
||||
if (!empty($this->tablePaths['modulePath'])) {
|
||||
$moduleDir = strstr($this->tablePaths['modulePath'], '{*}', true);
|
||||
$moduleList = isset($this->metadata) ? $this->getMetadata()->getModuleList() : $this->getFileManager()->getFileList($moduleDir, false, '', false);
|
||||
|
||||
foreach($fileList as $fileName) {
|
||||
$fileData = $this->getFileManager()->getPhpContents( array($this->customTablePath, $fileName) );
|
||||
if (is_array($fileData)) {
|
||||
$customTables = Util::merge($customTables, $fileData);
|
||||
foreach ($moduleList as $moduleName) {
|
||||
$modulePath = str_replace('{*}', $moduleName, $this->tablePaths['modulePath']);
|
||||
$customTables = Util::merge($customTables, $this->loadData($modulePath));
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->tablePaths['customPath'])) {
|
||||
$customTables = Util::merge($customTables, $this->loadData($this->tablePaths['customPath']));
|
||||
}
|
||||
|
||||
//get custom tables from metdata 'additionalTables'
|
||||
foreach ($ormMeta as $entityName => $entityParams) {
|
||||
if (isset($entityParams['additionalTables']) && is_array($entityParams['additionalTables'])) {
|
||||
@@ -437,4 +473,23 @@ class Converter
|
||||
return implode('_', $names);
|
||||
}
|
||||
|
||||
protected function loadData($path)
|
||||
{
|
||||
$tables = array();
|
||||
|
||||
if (!file_exists($path)) {
|
||||
return $tables;
|
||||
}
|
||||
|
||||
$fileList = $this->getFileManager()->getFileList($path, false, '\.php$', true);
|
||||
|
||||
foreach($fileList as $fileName) {
|
||||
$fileData = $this->getFileManager()->getPhpContents( array($path, $fileName) );
|
||||
if (is_array($fileData)) {
|
||||
$tables = Util::merge($tables, $fileData);
|
||||
}
|
||||
}
|
||||
|
||||
return $tables;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class Schema
|
||||
|
||||
$this->converter = new \Espo\Core\Utils\Database\Converter($this->metadata, $this->fileManager);
|
||||
|
||||
$this->schemaConverter = new Converter($this->fileManager);
|
||||
$this->schemaConverter = new Converter($this->metadata, $this->fileManager);
|
||||
|
||||
$this->ormMetadata = $ormMetadata;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2017 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/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
return array(
|
||||
|
||||
'ActionHistoryRecord' => array(
|
||||
'params' => array(
|
||||
'engine' => 'InnoDB'
|
||||
)
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
@@ -25,13 +25,31 @@
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
************************************************************************/
|
||||
|
||||
return array(
|
||||
return array(
|
||||
|
||||
'unset' => array(
|
||||
'Preferences',
|
||||
'__APPEND__',
|
||||
'Preferences'
|
||||
),
|
||||
'unsetIgnore' => [
|
||||
'__APPEND__',
|
||||
['Preferences', 'fields', 'id'],
|
||||
['Preferences', 'fields', 'data']
|
||||
],
|
||||
'Preferences' => array(
|
||||
'fields' => array(
|
||||
'id' => array(
|
||||
'dbType' => 'varchar',
|
||||
'len' => 24,
|
||||
'type' => 'id'
|
||||
),
|
||||
'data' => array(
|
||||
'type' => 'text'
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
|
||||
@@ -25,12 +25,13 @@
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
************************************************************************/
|
||||
|
||||
return array(
|
||||
return array(
|
||||
|
||||
'unset' => array(
|
||||
'Settings',
|
||||
'__APPEND__',
|
||||
'Settings',
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
@@ -55,6 +55,36 @@ class DateTime
|
||||
'hh:mmA' => 'h:iA',
|
||||
);
|
||||
|
||||
|
||||
protected $formattingMap = array(
|
||||
'MMMM' => 'F',
|
||||
'MMM' => 'M',
|
||||
'MM' => 'm',
|
||||
'M' => 'n',
|
||||
'DDDD' => 'z',
|
||||
'DD' => 'd',
|
||||
'D' => 'j',
|
||||
'dddd' => 'l',
|
||||
'ddd' => 'D',
|
||||
'ww' => 'W',
|
||||
'w' => 'W',
|
||||
'e' => 'w',
|
||||
'YYYY' => 'Y',
|
||||
'YY' => 'y',
|
||||
'HH' => 'H',
|
||||
'H' => 'G',
|
||||
'hh' => 'h',
|
||||
'h' => 'g',
|
||||
'mm' => 'i',
|
||||
'm' => 'i',
|
||||
'A' => 'A',
|
||||
'a' => 'a',
|
||||
'ss' => 's',
|
||||
's' => 's',
|
||||
'Z' => 'O',
|
||||
'z' => 'O'
|
||||
);
|
||||
|
||||
public function __construct($dateFormat = 'YYYY-MM-DD', $timeFormat = 'HH:mm', $timeZone = 'UTC')
|
||||
{
|
||||
$this->dateFormat = $dateFormat;
|
||||
@@ -83,6 +113,11 @@ class DateTime
|
||||
return $this->dateFormats[$this->dateFormat] . ' ' . $this->timeFormats[$this->timeFormat];
|
||||
}
|
||||
|
||||
protected function convertFormatToPhp($format)
|
||||
{
|
||||
return strtr($format, $this->formattingMap);
|
||||
}
|
||||
|
||||
public function convertSystemDateToGlobal($string)
|
||||
{
|
||||
return $this->convertSystemDate($string);
|
||||
@@ -93,25 +128,39 @@ class DateTime
|
||||
return $this->convertSystemDateTime($string);
|
||||
}
|
||||
|
||||
public function convertSystemDate($string)
|
||||
public function convertSystemDate($string, $format = null)
|
||||
{
|
||||
$dateTime = \DateTime::createFromFormat('Y-m-d', $string);
|
||||
if ($dateTime) {
|
||||
return $dateTime->format($this->getPhpDateFormat());
|
||||
if ($format) {
|
||||
$phpFormat = $this->convertFormatToPhp($format);
|
||||
} else {
|
||||
$phpFormat = $this->getPhpDateFormat();
|
||||
}
|
||||
return $dateTime->format($phpFormat);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function convertSystemDateTime($string, $timezone = null)
|
||||
public function convertSystemDateTime($string, $timezone = null, $format = null)
|
||||
{
|
||||
if (is_string($string) && strlen($string) === 16) {
|
||||
$string .= ':00';
|
||||
}
|
||||
$dateTime = \DateTime::createFromFormat('Y-m-d H:i:s', $string);
|
||||
if (empty($timezone)) {
|
||||
$timezone = $this->timezone;
|
||||
} else {
|
||||
$timezone = new \DateTimeZone($timezone);
|
||||
}
|
||||
|
||||
if ($dateTime) {
|
||||
return $dateTime->setTimezone($timezone)->format($this->getPhpDateTimeFormat());
|
||||
if ($format) {
|
||||
$phpFormat = $this->convertFormatToPhp($format);
|
||||
} else {
|
||||
$phpFormat = $this->getPhpDateTimeFormat();
|
||||
}
|
||||
return $dateTime->setTimezone($timezone)->format($phpFormat);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -68,6 +68,13 @@ class EntityManager
|
||||
return $this->metadata;
|
||||
}
|
||||
|
||||
protected function getEntityManager()
|
||||
{
|
||||
if (!$this->container) return;
|
||||
|
||||
return $this->container->get('entityManager');
|
||||
}
|
||||
|
||||
protected function getLanguage()
|
||||
{
|
||||
return $this->language;
|
||||
@@ -210,6 +217,7 @@ class EntityManager
|
||||
$filePath = "application/Espo/Core/Templates/Metadata/{$type}/entityDefs.json";
|
||||
$entityDefsDataContents = $this->getFileManager()->getContents($filePath);
|
||||
$entityDefsDataContents = str_replace('{entityType}', $name, $entityDefsDataContents);
|
||||
$entityDefsDataContents = str_replace('{tableName}', $this->getEntityManager()->getQuery()->toDb($name), $entityDefsDataContents);
|
||||
$entityDefsData = Json::decode($entityDefsDataContents, true);
|
||||
$this->getMetadata()->set('entityDefs', $name, $entityDefsData);
|
||||
|
||||
@@ -655,7 +663,7 @@ class EntityManager
|
||||
}
|
||||
|
||||
if (
|
||||
$this->getMetadata()->get("entityDefs.{$entity}.links.{$link}.type") == 'hasMany'
|
||||
in_array($this->getMetadata()->get("entityDefs.{$entity}.links.{$link}.type"), ['hasMany', 'hasChildren'])
|
||||
) {
|
||||
if (array_key_exists('audited', $params)) {
|
||||
$audited = $params['audited'];
|
||||
@@ -672,7 +680,7 @@ class EntityManager
|
||||
}
|
||||
|
||||
if (
|
||||
$this->getMetadata()->get("entityDefs.{$entityForeign}.links.{$linkForeign}.type") == 'hasMany'
|
||||
in_array($this->getMetadata()->get("entityDefs.{$entityForeign}.links.{$linkForeign}.type"), ['hasMany', 'hasChildren'])
|
||||
) {
|
||||
if (array_key_exists('auditedForeign', $params)) {
|
||||
$auditedForeign = $params['auditedForeign'];
|
||||
|
||||
@@ -28,10 +28,10 @@
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Utils;
|
||||
use \Espo\Core\Exceptions\Error,
|
||||
\Espo\Core\Exceptions\Conflict;
|
||||
|
||||
use \Espo\Core\Container;
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Exceptions\Conflict;
|
||||
use Espo\Core\Container;
|
||||
|
||||
class FieldManager
|
||||
{
|
||||
@@ -49,6 +49,8 @@ class FieldManager
|
||||
|
||||
protected $customOptionName = 'isCustom';
|
||||
|
||||
protected $forbiddenFieldNameList = ['id', 'deleted'];
|
||||
|
||||
public function __construct(Metadata $metadata, Language $language, Container $container = null)
|
||||
{
|
||||
$this->metadata = $metadata;
|
||||
@@ -78,9 +80,9 @@ class FieldManager
|
||||
return $this->container->get('defaultLanguage');
|
||||
}
|
||||
|
||||
public function read($name, $scope)
|
||||
public function read($scope, $name)
|
||||
{
|
||||
$fieldDefs = $this->getFieldDefs($name, $scope);
|
||||
$fieldDefs = $this->getFieldDefs($scope, $name);
|
||||
|
||||
$fieldDefs['label'] = $this->getLanguage()->translate($name, 'fields', $scope);
|
||||
|
||||
@@ -91,30 +93,36 @@ class FieldManager
|
||||
return $fieldDefs;
|
||||
}
|
||||
|
||||
public function create($name, $fieldDefs, $scope)
|
||||
public function create($scope, $name, $fieldDefs)
|
||||
{
|
||||
$existingField = $this->getFieldDefs($name, $scope);
|
||||
$existingField = $this->getFieldDefs($scope, $name);
|
||||
if (isset($existingField)) {
|
||||
throw new Conflict('Field ['.$name.'] exists in '.$scope);
|
||||
}
|
||||
if (in_array($name, $this->forbiddenFieldNameList)) {
|
||||
throw new Conflict('Field ['.$name.'] is not allowed');
|
||||
}
|
||||
|
||||
return $this->update($name, $fieldDefs, $scope, true);
|
||||
return $this->update($scope, $name, $fieldDefs, true);
|
||||
}
|
||||
|
||||
public function update($name, $fieldDefs, $scope, $isNew = false)
|
||||
public function update($scope, $name, $fieldDefs, $isNew = false)
|
||||
{
|
||||
$name = trim($name);
|
||||
$this->isChanged = false;
|
||||
|
||||
/*Add option to metadata to identify the custom field*/
|
||||
if (!$this->isCore($name, $scope)) {
|
||||
if (!$this->isCore($scope, $name)) {
|
||||
$fieldDefs[$this->customOptionName] = true;
|
||||
}
|
||||
|
||||
$res = true;
|
||||
$result = true;
|
||||
$isLabelChanged = false;
|
||||
if (isset($fieldDefs['label'])) {
|
||||
$this->setLabel($name, $fieldDefs['label'], $scope);
|
||||
$isLabelChanged |= $this->setLabel($scope, $name, $fieldDefs['label']);
|
||||
}
|
||||
if (isset($fieldDefs['tooltipText'])) {
|
||||
$this->setTooltipText($name, $fieldDefs['tooltipText'], $scope);
|
||||
$isLabelChanged |= $this->setTooltipText($scope, $name, $fieldDefs['tooltipText']);
|
||||
}
|
||||
|
||||
$type = isset($fieldDefs['type']) ? $fieldDefs['type'] : $type = $this->getMetadata()->get(['entityDefs', $scope, 'fields', $name, 'type']);
|
||||
@@ -127,16 +135,15 @@ class FieldManager
|
||||
$translatedOptions = json_decode(json_encode($fieldDefs['translatedOptions']), true);
|
||||
if (isset($translatedOptions['_empty_'])) {
|
||||
$translatedOptions[''] = $translatedOptions['_empty_'];
|
||||
unset($translatedOptions['_empty_']);
|
||||
}
|
||||
|
||||
$this->setTranslatedOptions($name, $translatedOptions, $scope);
|
||||
$isLabelChanged |= $this->setTranslatedOptions($scope, $name, $translatedOptions);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
isset($fieldDefs['label']) || isset($fieldDefs['translatedOptions']) || isset($fieldDefs['tooltipText'])
|
||||
) {
|
||||
$res &= $this->getLanguage()->save();
|
||||
if ($isLabelChanged) {
|
||||
$result &= $this->getLanguage()->save();
|
||||
|
||||
if (isset($fieldDefs['tooltipText'])) {
|
||||
$this->getDefaultLanguage()->save();
|
||||
@@ -223,19 +230,20 @@ class FieldManager
|
||||
$this->getMetadata()->set('clientDefs', $scope, $clientDefs);
|
||||
}
|
||||
|
||||
if ($this->isDefsChanged($name, $fieldDefs, $scope)) {
|
||||
$entityDefs = $this->normalizeDefs($name, $fieldDefs, $scope);
|
||||
$entityDefs = $this->normalizeDefs($scope, $name, $fieldDefs);
|
||||
if (!empty($entityDefs)) {
|
||||
$this->getMetadata()->set('entityDefs', $scope, $entityDefs);
|
||||
$metadataToBeSaved = true;
|
||||
$this->isChanged = true;
|
||||
}
|
||||
|
||||
if ($metadataToBeSaved) {
|
||||
$res &= $this->getMetadata()->save();
|
||||
$result &= $this->getMetadata()->save();
|
||||
|
||||
$this->processHook('afterSave', $type, $scope, $name, $fieldDefs, array('isNew' => $isNew));
|
||||
}
|
||||
|
||||
return (bool) $res;
|
||||
return (bool) $result;
|
||||
}
|
||||
|
||||
protected function prepareClientDefsFieldsDynamicLogic(&$clientDefs, $name)
|
||||
@@ -264,9 +272,9 @@ class FieldManager
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($name, $scope)
|
||||
public function delete($scope, $name)
|
||||
{
|
||||
if ($this->isCore($name, $scope)) {
|
||||
if ($this->isCore($scope, $name)) {
|
||||
throw new Error('Cannot delete core field ['.$name.'] in '.$scope);
|
||||
}
|
||||
|
||||
@@ -288,16 +296,16 @@ class FieldManager
|
||||
|
||||
|
||||
$res = $this->getMetadata()->save();
|
||||
$res &= $this->deleteLabel($name, $scope);
|
||||
$res &= $this->deleteLabel($scope, $name);
|
||||
|
||||
$this->processHook('afterRemove', $type, $scope, $name);
|
||||
|
||||
return (bool) $res;
|
||||
}
|
||||
|
||||
public function resetToDefault($name, $scope)
|
||||
public function resetToDefault($scope, $name)
|
||||
{
|
||||
if (!$this->isCore($name, $scope)) {
|
||||
if (!$this->isCore($scope, $name)) {
|
||||
throw new Error('Cannot reset to default custom field ['.$name.'] in '.$scope);
|
||||
}
|
||||
|
||||
@@ -321,28 +329,32 @@ class FieldManager
|
||||
$this->getDefaultLanguage()->save();
|
||||
}
|
||||
|
||||
protected function setEntityDefs($name, $fieldDefs, $scope)
|
||||
protected function setTranslatedOptions($scope, $name, $value)
|
||||
{
|
||||
$fieldDefs = $this->normalizeDefs($name, $fieldDefs, $scope);
|
||||
if (!$this->isLabelChanged($scope, 'options', $name, $value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->getMetadata()->set('entityDefs', $scope, $fieldDefs);
|
||||
$res = $this->getMetadata()->save();
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
protected function setTranslatedOptions($name, $value, $scope)
|
||||
{
|
||||
$this->getLanguage()->set($scope, 'options', $name, $value);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function setLabel($name, $value, $scope)
|
||||
protected function setLabel($scope, $name, $value)
|
||||
{
|
||||
return $this->getLanguage()->set($scope, 'fields', $name, $value);
|
||||
if (!$this->isLabelChanged($scope, 'fields', $name, $value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->getLanguage()->set($scope, 'fields', $name, $value);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function setTooltipText($name, $value, $scope)
|
||||
protected function setTooltipText($scope, $name, $value)
|
||||
{
|
||||
if (!$this->isLabelChanged($scope, 'tooltips', $name, $value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($value && $value !== '') {
|
||||
$this->getLanguage()->set($scope, 'tooltips', $name, $value);
|
||||
$this->getDefaultLanguage()->set($scope, 'tooltips', $name, $value);
|
||||
@@ -350,9 +362,11 @@ class FieldManager
|
||||
$this->getLanguage()->delete($scope, 'tooltips', $name);
|
||||
$this->getDefaultLanguage()->delete($scope, 'tooltips', $name);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function deleteLabel($name, $scope)
|
||||
protected function deleteLabel($scope, $name)
|
||||
{
|
||||
$this->getLanguage()->delete($scope, 'fields', $name);
|
||||
$this->getLanguage()->delete($scope, 'tooltips', $name);
|
||||
@@ -363,12 +377,12 @@ class FieldManager
|
||||
$this->getDefaultLanguage()->save();
|
||||
}
|
||||
|
||||
protected function getFieldDefs($name, $scope)
|
||||
protected function getFieldDefs($scope, $name)
|
||||
{
|
||||
return $this->getMetadata()->get('entityDefs'.'.'.$scope.'.fields.'.$name);
|
||||
}
|
||||
|
||||
protected function getLinkDefs($name, $scope)
|
||||
protected function getLinkDefs($scope, $name)
|
||||
{
|
||||
return $this->getMetadata()->get('entityDefs'.'.'.$scope.'.links.'.$name);
|
||||
}
|
||||
@@ -381,12 +395,16 @@ class FieldManager
|
||||
* @param string $scope
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareFieldDefs($name, $fieldDefs, $scope)
|
||||
protected function prepareFieldDefs($scope, $name, $fieldDefs)
|
||||
{
|
||||
$unnecessaryFields = array(
|
||||
'name',
|
||||
'label',
|
||||
'translatedOptions',
|
||||
'dynamicLogicVisible',
|
||||
'dynamicLogicReadOnly',
|
||||
'dynamicLogicRequired',
|
||||
'dynamicLogicOptions',
|
||||
);
|
||||
|
||||
foreach ($unnecessaryFields as $fieldName) {
|
||||
@@ -395,7 +413,7 @@ class FieldManager
|
||||
}
|
||||
}
|
||||
|
||||
$currentOptionList = array_keys((array) $this->getFieldDefs($name, $scope));
|
||||
$currentOptionList = array_keys((array) $this->getFieldDefs($scope, $name));
|
||||
foreach ($fieldDefs as $defName => $defValue) {
|
||||
if ( (!isset($defValue) || $defValue === '') && !in_array($defName, $currentOptionList) ) {
|
||||
unset($fieldDefs[$defName]);
|
||||
@@ -408,14 +426,14 @@ class FieldManager
|
||||
/**
|
||||
* Add all needed block for a field defenition
|
||||
*
|
||||
* @param string $scope
|
||||
* @param string $fieldName
|
||||
* @param array $fieldDefs
|
||||
* @param string $scope
|
||||
* @return array
|
||||
*/
|
||||
protected function normalizeDefs($fieldName, array $fieldDefs, $scope)
|
||||
protected function normalizeDefs($scope, $fieldName, array $fieldDefs)
|
||||
{
|
||||
$fieldDefs = $this->prepareFieldDefs($fieldName, $fieldDefs, $scope);
|
||||
$fieldDefs = $this->prepareFieldDefs($scope, $fieldName, $fieldDefs);
|
||||
|
||||
$metaFieldDefs = $this->getMetadataHelper()->getFieldDefsInFieldMeta($fieldDefs);
|
||||
if (isset($metaFieldDefs)) {
|
||||
@@ -427,19 +445,29 @@ class FieldManager
|
||||
unset($fieldDefs['linkDefs']);
|
||||
}
|
||||
|
||||
$defs = array(
|
||||
'fields' => array(
|
||||
$fieldName => $fieldDefs,
|
||||
),
|
||||
);
|
||||
$defs = array();
|
||||
|
||||
$currentFieldDefs = (array) $this->getFieldDefs($scope, $fieldName);
|
||||
$normalizedFieldDefs = Util::arrayDiff($currentFieldDefs, $fieldDefs);
|
||||
if (!empty($normalizedFieldDefs)) {
|
||||
$defs['fields'] = array(
|
||||
$fieldName => $normalizedFieldDefs,
|
||||
);
|
||||
}
|
||||
|
||||
/** Save links for a field. */
|
||||
$metaLinkDefs = $this->getMetadataHelper()->getLinkDefsInFieldMeta($scope, $fieldDefs);
|
||||
if (isset($linkDefs) || isset($metaLinkDefs)) {
|
||||
$linkDefs = Util::merge((array) $metaLinkDefs, (array) $linkDefs);
|
||||
$defs['links'] = array(
|
||||
$fieldName => $linkDefs,
|
||||
);
|
||||
|
||||
$metaLinkDefs = isset($metaLinkDefs) ? $metaLinkDefs : array();
|
||||
$linkDefs = isset($linkDefs) ? $linkDefs : array();
|
||||
|
||||
$normalizedLinkdDefs = Util::merge($metaLinkDefs, $linkDefs);
|
||||
if (!empty($normalizedLinkdDefs)) {
|
||||
$defs['links'] = array(
|
||||
$fieldName => $normalizedLinkdDefs,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $defs;
|
||||
@@ -448,18 +476,45 @@ class FieldManager
|
||||
/**
|
||||
* Check if changed metadata defenition for a field except 'label'
|
||||
*
|
||||
* @param string $scope
|
||||
* @param string $name
|
||||
* @param array $fieldDefs
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function isDefsChanged($name, $fieldDefs, $scope)
|
||||
protected function isDefsChanged($scope, $name, $fieldDefs)
|
||||
{
|
||||
$fieldDefs = $this->prepareFieldDefs($name, $fieldDefs, $scope);
|
||||
$currentFieldDefs = $this->getFieldDefs($name, $scope);
|
||||
$fieldDefs = $this->prepareFieldDefs($scope, $name, $fieldDefs);
|
||||
$currentFieldDefs = $this->getFieldDefs($scope, $name);
|
||||
|
||||
$this->isChanged = Util::isEquals($fieldDefs, $currentFieldDefs) ? false : true;
|
||||
$diffDefs = Util::arrayDiff($currentFieldDefs, $fieldDefs);
|
||||
|
||||
$this->isChanged = empty($diffDefs) ? false : true;
|
||||
|
||||
return $this->isChanged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if label is changed
|
||||
*
|
||||
* @param string $scope
|
||||
* @param string $category
|
||||
* @param string $name
|
||||
* @param mixed $newLabel
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function isLabelChanged($scope, $category, $name, $newLabel)
|
||||
{
|
||||
$currentLabel = $this->getLanguage()->get([$scope, $category, $name]);
|
||||
|
||||
if ($newLabel != $currentLabel) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only for update method
|
||||
*
|
||||
@@ -477,9 +532,9 @@ class FieldManager
|
||||
* @param string $scope
|
||||
* @return boolean
|
||||
*/
|
||||
protected function isCore($name, $scope)
|
||||
protected function isCore($scope, $name)
|
||||
{
|
||||
$existingField = $this->getFieldDefs($name, $scope);
|
||||
$existingField = $this->getFieldDefs($scope, $name);
|
||||
if (isset($existingField) && (!isset($existingField[$this->customOptionName]) || !$existingField[$this->customOptionName])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -61,6 +61,12 @@ class Metadata
|
||||
|
||||
private $moduleList = null;
|
||||
|
||||
protected $frontendHiddenPathList = [
|
||||
['app', 'formula', 'functionClassNameMap'],
|
||||
['app', 'fileStorage', 'implementationClassNameMap'],
|
||||
['app', 'emailNotifications', 'handlerClassNameMap']
|
||||
];
|
||||
|
||||
/**
|
||||
* Default module order
|
||||
* @var integer
|
||||
@@ -198,6 +204,36 @@ class Metadata
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function getAllForFrontend()
|
||||
{
|
||||
$data = $this->getAll();
|
||||
|
||||
foreach ($this->frontendHiddenPathList as $row) {
|
||||
$p =& $data;
|
||||
$path = [&$p];
|
||||
foreach ($row as $i => $item) {
|
||||
if (!array_key_exists($item, $p)) break;
|
||||
if ($i == count($row) - 1) {
|
||||
unset($p[$item]);
|
||||
$o =& $p;
|
||||
for ($j = $i - 1; $j > 0; $j--) {
|
||||
if (is_array($o) && empty($o)) {
|
||||
$o =& $path[$j];
|
||||
$k = $row[$j];
|
||||
unset($o[$k]);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$p =& $p[$item];
|
||||
$path[] = &$p;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* todo: move to a separate file
|
||||
* Add additional fields defined from metadata -> fields
|
||||
@@ -290,6 +326,26 @@ class Metadata
|
||||
$unsets = (array) $unsets;
|
||||
}
|
||||
|
||||
switch ($key1) {
|
||||
case 'entityDefs':
|
||||
//unset related additional fields, e.g. a field with "address" type
|
||||
$unsetList = $unsets;
|
||||
foreach ($unsetList as $unsetItem) {
|
||||
if (preg_match('/fields\.([^\.]+)/', $unsetItem, $matches) && isset($matches[1])) {
|
||||
$fieldName = $matches[1];
|
||||
$fieldPath = [$key1, $key2, 'fields', $fieldName];
|
||||
|
||||
$additionalFields = $this->getMetadataHelper()->getAdditionalFieldList($fieldName, $this->get($fieldPath));
|
||||
if (is_array($additionalFields)) {
|
||||
foreach ($additionalFields as $additionalFieldName => $additionalFieldParams) {
|
||||
$unsets[] = 'fields.' . $additionalFieldName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$normalizedData = array(
|
||||
'__APPEND__',
|
||||
);
|
||||
|
||||
@@ -55,7 +55,7 @@ class ScheduledJob
|
||||
|
||||
protected $cronSetup = array(
|
||||
'linux' => '* * * * * cd {DOCUMENT_ROOT}; {PHP-BIN-DIR} -f {CRON-FILE} > /dev/null 2>&1',
|
||||
'windows' => '{PHP-BIN-DIR}.exe -f {FULL-CRON-PATH}',
|
||||
'windows' => '{PHP-BINARY} -f {FULL-CRON-PATH}',
|
||||
'mac' => '* * * * * cd {DOCUMENT_ROOT}; {PHP-BIN-DIR} -f {CRON-FILE} > /dev/null 2>&1',
|
||||
'default' => '* * * * * cd {DOCUMENT_ROOT}; {PHP-BIN-DIR} -f {CRON-FILE} > /dev/null 2>&1',
|
||||
);
|
||||
@@ -165,6 +165,7 @@ class ScheduledJob
|
||||
|
||||
$data = array(
|
||||
'PHP-BIN-DIR' => $this->getSystemUtil()->getPhpBin(),
|
||||
'PHP-BINARY' => $this->getSystemUtil()->getPhpBinary(),
|
||||
'CRON-FILE' => $this->cronFile,
|
||||
'DOCUMENT_ROOT' => $this->getSystemUtil()->getRootDir(),
|
||||
'FULL-CRON-PATH' => Util::concatPath($this->getSystemUtil()->getRootDir(), $this->cronFile),
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Utils;
|
||||
|
||||
class System
|
||||
{
|
||||
/**
|
||||
@@ -105,7 +106,17 @@ class System
|
||||
*/
|
||||
public function getPhpBin()
|
||||
{
|
||||
return (defined("PHP_BINDIR"))? PHP_BINDIR.DIRECTORY_SEPARATOR.'php' : 'php';
|
||||
return defined("PHP_BINDIR") ? PHP_BINDIR . DIRECTORY_SEPARATOR . 'php' : 'php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHP binary
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPhpBinary()
|
||||
{
|
||||
return defined("PHP_BINARY") ? PHP_BINARY : 'php';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -146,9 +146,9 @@ class Util
|
||||
{
|
||||
$mergeIdentifier = '__APPEND__';
|
||||
|
||||
if (is_array($currentArray) && (!is_array($newArray) || empty($newArray))) {
|
||||
if (is_array($currentArray) && !is_array($newArray)) {
|
||||
return $currentArray;
|
||||
} else if ((!is_array($currentArray) || empty($currentArray)) && is_array($newArray)) {
|
||||
} else if (!is_array($currentArray) && is_array($newArray)) {
|
||||
return $newArray;
|
||||
} else if ((!is_array($currentArray) || empty($currentArray)) && (!is_array($newArray) || empty($newArray))) {
|
||||
return array();
|
||||
@@ -156,10 +156,6 @@ class Util
|
||||
|
||||
foreach ($newArray as $newName => $newValue) {
|
||||
|
||||
if (is_array($newValue) && empty($newValue)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_array($newValue) && array_key_exists($newName, $currentArray) && is_array($currentArray[$newName])) {
|
||||
|
||||
// check __APPEND__ identifier
|
||||
@@ -557,5 +553,54 @@ class Util
|
||||
return preg_replace("/([^\w\s\d\-_~,;:\[\]\(\).])/u", '_', $fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Improved computing the difference of arrays
|
||||
*
|
||||
* @param array $array1
|
||||
* @param array $array2
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function arrayDiff(array $array1, array $array2)
|
||||
{
|
||||
$diff = array();
|
||||
|
||||
foreach ($array1 as $key1 => $value1) {
|
||||
if (array_key_exists($key1, $array2)) {
|
||||
if ($value1 !== $array2[$key1]) {
|
||||
$diff[$key1] = $array2[$key1];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$diff[$key1] = $value1;
|
||||
}
|
||||
|
||||
$diff = array_merge($diff, array_diff_key($array2, $array1));
|
||||
|
||||
return $diff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill array with specified keys
|
||||
*
|
||||
* @param array|string $keys
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function fillArrayKeys($keys, $value)
|
||||
{
|
||||
$arrayKeys = is_array($keys) ? $keys : explode('.', $keys);
|
||||
|
||||
$array = array();
|
||||
foreach (array_reverse($arrayKeys) as $i => $key) {
|
||||
$array = array(
|
||||
$key => ($i == 0) ? $value : $array,
|
||||
);
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,11 +65,13 @@ return array (
|
||||
'languageList' => [
|
||||
'en_US',
|
||||
'cs_CZ',
|
||||
'da_DK',
|
||||
'de_DE',
|
||||
'es_ES',
|
||||
'fr_FR',
|
||||
'id_ID',
|
||||
'it_IT',
|
||||
'nb_NO',
|
||||
'nl_NL',
|
||||
'tr_TR',
|
||||
'ro_RO',
|
||||
@@ -77,7 +79,8 @@ return array (
|
||||
'pl_PL',
|
||||
'pt_BR',
|
||||
'uk_UA',
|
||||
'vi_VN'
|
||||
'vi_VN',
|
||||
'zh_CN'
|
||||
],
|
||||
'language' => 'en_US',
|
||||
'logger' =>
|
||||
@@ -95,8 +98,8 @@ return array (
|
||||
'Lead',
|
||||
'Opportunity',
|
||||
),
|
||||
"tabList" => ["Account", "Contact", "Lead", "Opportunity", "Case", "Email", "Calendar", "Meeting", "Call", "Task", "_delimiter_", "Document", "Campaign", "KnowledgeBaseArticle", "Stream", "User"],
|
||||
"quickCreateList" => ["Account", "Contact", "Lead", "Opportunity", "Meeting", "Call", "Task", "Case", "Email"],
|
||||
'tabList' => ["Account", "Contact", "Lead", "Opportunity", "Case", "Email", "Calendar", "Meeting", "Call", "Task", "_delimiter_", "Document", "Campaign", "KnowledgeBaseArticle", "Stream", "User"],
|
||||
'quickCreateList' => ["Account", "Contact", "Lead", "Opportunity", "Meeting", "Call", "Task", "Case", "Email"],
|
||||
'exportDisabled' => false,
|
||||
'assignmentEmailNotifications' => false,
|
||||
'assignmentEmailNotificationsEntityList' => ['Lead', 'Opportunity', 'Task', 'Case'],
|
||||
@@ -150,9 +153,13 @@ return array (
|
||||
]
|
||||
]
|
||||
],
|
||||
"calendarEntityList" => ["Meeting", "Call", "Task"],
|
||||
"activitiesEntityList" => ["Meeting", "Call"],
|
||||
"historyEntityList" => ["Meeting", "Call", "Email"],
|
||||
'isInstalled' => false,
|
||||
'calendarEntityList' => ['Meeting', 'Call', 'Task'],
|
||||
'activitiesEntityList' => ['Meeting', 'Call'],
|
||||
'historyEntityList' => ['Meeting', 'Call', 'Email'],
|
||||
'lastViewedCount' => 20,
|
||||
'cleanupJobPeriod' => '1 month',
|
||||
'cleanupActionHistoryPeriod' => '15 days',
|
||||
'cleanupAuthTokenPeriod' => '1 month',
|
||||
'isInstalled' => false
|
||||
);
|
||||
|
||||
|
||||
@@ -149,7 +149,9 @@ return array ( 'defaultPermissions' =>
|
||||
'ldapUserDefaultTeamId',
|
||||
'ldapUserDefaultTeamName',
|
||||
'ldapUserTeamsIds',
|
||||
'ldapUserTeamsNames'
|
||||
'ldapUserTeamsNames',
|
||||
'cleanupJobPeriod',
|
||||
'cleanupActionHistoryPeriod'
|
||||
),
|
||||
'userItems' =>
|
||||
array (
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2017 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/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Entities;
|
||||
|
||||
class ActionHistoryRecord extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -67,6 +67,12 @@ class Download extends \Espo\Core\EntryPoints\Base
|
||||
|
||||
$sourceId = $attachment->getSourceId();
|
||||
|
||||
if ($this->getEntityManager()->getRepository('Attachment')->hasDownloadUrl($attachment)) {
|
||||
$downloadUrl = $this->getEntityManager()->getRepository('Attachment')->getDownloadUrl($attachment);
|
||||
header('Location: ' . $downloadUrl);
|
||||
exit;
|
||||
}
|
||||
|
||||
$fileName = $this->getEntityManager()->getRepository('Attachment')->getFilePath($attachment);
|
||||
|
||||
if (!file_exists($fileName)) {
|
||||
|
||||
@@ -149,6 +149,10 @@ class Image extends \Espo\Core\EntryPoints\Base
|
||||
|
||||
protected function getThumbImage($filePath, $fileType, $size)
|
||||
{
|
||||
if (!@is_array(getimagesize($filePath))) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
list($originalWidth, $originalHeight) = getimagesize($filePath);
|
||||
list($width, $height) = $this->imageSizes[$size];
|
||||
|
||||
|
||||
@@ -70,29 +70,13 @@ class NextNumber extends \Espo\Core\Hooks\Base
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$this->getEntityManager()->getPdo()->query('LOCK TABLES `next_number` WRITE');
|
||||
$nextNumber = $this->getEntityManager()->getRepository('NextNumber')->where(array(
|
||||
'fieldName' => $fieldName,
|
||||
'entityType' => $entity->getEntityType()
|
||||
))->findOne();
|
||||
if (!$nextNumber) continue;
|
||||
$entity->set($fieldName, $this->composeNumberAttribute($nextNumber));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function afterSave(Entity $entity, array $options = array())
|
||||
{
|
||||
if (!$entity->isNew()) return;
|
||||
|
||||
$fieldDefs = $this->getMetadata()->get(['entityDefs', $entity->getEntityType(), 'fields'], array());
|
||||
|
||||
foreach ($fieldDefs as $fieldName => $defs) {
|
||||
if (isset($defs['type']) && $defs['type'] === 'number') {
|
||||
$nextNumber = $this->getEntityManager()->getRepository('NextNumber')->where(array(
|
||||
'fieldName' => $fieldName,
|
||||
'entityType' => $entity->getEntityType()
|
||||
))->findOne();
|
||||
if (!$nextNumber) continue;
|
||||
|
||||
$value = $nextNumber->get('value');
|
||||
if (!$value) {
|
||||
@@ -102,10 +86,11 @@ class NextNumber extends \Espo\Core\Hooks\Base
|
||||
|
||||
$nextNumber->set('value', $value);
|
||||
$this->getEntityManager()->saveEntity($nextNumber);
|
||||
|
||||
$this->getEntityManager()->getPdo()->query('UNLOCK TABLES');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,9 @@ class AuthTokenControl extends \Espo\Core\Jobs\Base
|
||||
return;
|
||||
}
|
||||
|
||||
$whereClause = array();
|
||||
$whereClause = array(
|
||||
'isActive' => true
|
||||
);
|
||||
|
||||
if ($authTokenLifetime) {
|
||||
$dt = new \DateTime();
|
||||
@@ -60,10 +62,11 @@ class AuthTokenControl extends \Espo\Core\Jobs\Base
|
||||
$whereClause['lastAccess<'] = $authTokenMaxIdleTimeThreshold;
|
||||
}
|
||||
|
||||
$tokenList = $this->getEntityManager()->getRepository('AuthToken')->where($whereClause)->limit(0, 100)->find();
|
||||
$tokenList = $this->getEntityManager()->getRepository('AuthToken')->where($whereClause)->limit(0, 500)->find();
|
||||
|
||||
foreach ($tokenList as $token) {
|
||||
$this->getEntityManager()->removeEntity($token);
|
||||
$token->set('isActive', false);
|
||||
$this->getEntityManager()->saveEntity($token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,11 @@ use \Espo\Core\Exceptions;
|
||||
|
||||
class Cleanup extends \Espo\Core\Jobs\Base
|
||||
{
|
||||
protected $period = '-1 month';
|
||||
protected $cleanupJobPeriod = '1 month';
|
||||
|
||||
protected $cleanupActionHistoryPeriod = '15 days';
|
||||
|
||||
protected $cleanupAuthTokenPeriod = '1 month';
|
||||
|
||||
public function run()
|
||||
{
|
||||
@@ -43,11 +47,13 @@ class Cleanup extends \Espo\Core\Jobs\Base
|
||||
$this->cleanupEmails();
|
||||
$this->cleanupNotes();
|
||||
$this->cleanupNotifications();
|
||||
$this->cleanupActionHistory();
|
||||
$this->cleanupAuthToken();
|
||||
}
|
||||
|
||||
protected function cleanupJobs()
|
||||
{
|
||||
$query = "DELETE FROM `job` WHERE DATE(modified_at) < '".$this->getCleanupFromDate()."' AND status <> 'Pending'";
|
||||
$query = "DELETE FROM `job` WHERE DATE(modified_at) < '".$this->getCleanupJobFromDate()."' AND status <> 'Pending'";
|
||||
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
$sth = $pdo->prepare($query);
|
||||
@@ -71,20 +77,45 @@ class Cleanup extends \Espo\Core\Jobs\Base
|
||||
|
||||
$delSql = "DELETE FROM `scheduled_job_log_record`
|
||||
WHERE scheduled_job_id = '".$id."'
|
||||
AND DATE(created_at) < '".$this->getCleanupFromDate()."'
|
||||
AND DATE(created_at) < '".$this->getCleanupJobFromDate()."'
|
||||
AND id NOT IN ('".implode("', '", $lastRowIds)."')
|
||||
";
|
||||
$pdo->query($delSql);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getCleanupFromDate()
|
||||
protected function cleanupActionHistory()
|
||||
{
|
||||
$format = 'Y-m-d';
|
||||
|
||||
$period = '-' . $this->getConfig()->get('cleanupActionHistoryPeriod', $this->cleanupActionHistoryPeriod);
|
||||
$datetime = new \DateTime();
|
||||
$datetime->modify($this->period);
|
||||
return $datetime->format($format);
|
||||
$datetime->modify($period);
|
||||
|
||||
$query = "DELETE FROM `action_history_record` WHERE DATE(created_at) < '" . $datetime->format('Y-m-d') . "'";
|
||||
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
$sth = $pdo->prepare($query);
|
||||
$sth->execute();
|
||||
}
|
||||
|
||||
protected function cleanupAuthToken()
|
||||
{
|
||||
$period = '-' . $this->getConfig()->get('cleanupAuthTokenPeriod', $this->cleanupAuthTokenPeriod);
|
||||
$datetime = new \DateTime();
|
||||
$datetime->modify($period);
|
||||
|
||||
$query = "DELETE FROM `auth_token` WHERE DATE(modified_at) < '" . $datetime->format('Y-m-d') . "' AND is_active = 0";
|
||||
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
$sth = $pdo->prepare($query);
|
||||
$sth->execute();
|
||||
}
|
||||
|
||||
protected function getCleanupJobFromDate()
|
||||
{
|
||||
$period = '-' . $this->getConfig()->get('cleanupJobPeriod', $this->cleanupJobPeriod);
|
||||
$datetime = new \DateTime();
|
||||
$datetime->modify($period);
|
||||
return $datetime->format('Y-m-d');
|
||||
}
|
||||
|
||||
protected function cleanupAttachments()
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2017 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/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\AclPortal;
|
||||
|
||||
use \Espo\Entities\User as EntityUser;
|
||||
use \Espo\ORM\Entity;
|
||||
|
||||
class KnowledgeBaseArticle extends \Espo\Core\AclPortal\Base
|
||||
{
|
||||
|
||||
public function checkEntityRead(EntityUser $user, Entity $entity, $data)
|
||||
{
|
||||
if (!$this->checkEntity($user, $entity, $data, 'read')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($entity->get('status') !== 'Published') return false;
|
||||
|
||||
$portalIdList = $entity->getLinkMultipleIdList('portals');
|
||||
|
||||
if ($user->get('portalId') && !in_array($user->get('portalId'), $portalIdList)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2017 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/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Business\EmailNotificationHandlers;
|
||||
|
||||
class CaseObj extends \Espo\Core\Injectable
|
||||
{
|
||||
protected $dependencyList = [
|
||||
'entityManager'
|
||||
];
|
||||
|
||||
protected $inboundEmailEntityHash = array();
|
||||
|
||||
public function getSmtpParams($type, $case, $user = null)
|
||||
{
|
||||
$inboundEmailId = $case->get('inboundEmailId');
|
||||
|
||||
if (!$inboundEmailId) return;
|
||||
|
||||
if (!array_key_exists($inboundEmailId, $this->inboundEmailEntityHash)) {
|
||||
$this->inboundEmailEntityHash[$inboundEmailId] = $this->getInjection('entityManager')->getEntity('InboundEmail', $inboundEmailId);
|
||||
}
|
||||
|
||||
$inboundEmail = $this->inboundEmailEntityHash[$inboundEmailId];
|
||||
|
||||
if (!$inboundEmail) return;
|
||||
|
||||
$emailAddress = $inboundEmail->get('emailAddress');
|
||||
|
||||
if (!$emailAddress) return;
|
||||
|
||||
return array(
|
||||
'replyToAddress' => $emailAddress
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,11 @@ class SubscribeAgain extends \Espo\Core\EntryPoints\Base
|
||||
{
|
||||
public static $authRequired = false;
|
||||
|
||||
private function getHookManager()
|
||||
{
|
||||
return $this->getContainer()->get('hookManager');
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
if (empty($_GET['id'])) {
|
||||
@@ -96,9 +101,17 @@ class SubscribeAgain extends \Espo\Core\EntryPoints\Base
|
||||
$targetListList = $massEmail->get('targetLists');
|
||||
|
||||
foreach ($targetListList as $targetList) {
|
||||
$this->getEntityManager()->getRepository('TargetList')->updateRelation($targetList, $link, $target->id, array(
|
||||
$optedInResult = $this->getEntityManager()->getRepository('TargetList')->updateRelation($targetList, $link, $target->id, array(
|
||||
'optedOut' => false
|
||||
));
|
||||
if ($optedInResult) {
|
||||
$hookData = [
|
||||
'link' => $link,
|
||||
'targetId' => $targetId,
|
||||
'targetType' => $targetType
|
||||
];
|
||||
$this->getHookManager()->process('TargetList', 'afterCancelOptOut', $targetList, [], $hookData);
|
||||
}
|
||||
}
|
||||
echo $this->getLanguage()->translate('subscribedAgain', 'messages', 'Campaign');
|
||||
echo '<br><br>';
|
||||
@@ -108,6 +121,17 @@ class SubscribeAgain extends \Espo\Core\EntryPoints\Base
|
||||
}
|
||||
}
|
||||
|
||||
if ($campaign && $target) {
|
||||
$logRecord = $this->getEntityManager()->getRepository('CampaignLogRecord')->where(array(
|
||||
'queueItemId' => $queueItemId,
|
||||
'action' => 'Opted Out'
|
||||
))->order('createdAt', true)->findOne();
|
||||
|
||||
if ($logRecord) {
|
||||
$this->getEntityManager()->removeEntity($logRecord);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user