Compare commits
284 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 09e364625d | |||
| 35f575ed7f | |||
| 7b0d46b37f | |||
| f474137b91 | |||
| 7a18d88c50 | |||
| 8d1c9fe666 | |||
| e6566bccdc | |||
| 14ed7282f3 | |||
| b13145adce | |||
| 3cfca9845a | |||
| afa8d07bb4 | |||
| 02434e0ca1 | |||
| 11f76c507b | |||
| c68f3eb44d | |||
| 6a1d8dcdca | |||
| ba358e5847 | |||
| 5e174fd5a9 | |||
| 9af2500292 | |||
| 8e9dea260e | |||
| 29ed6cb3b0 | |||
| 4670bb49e8 | |||
| fcc18befc3 | |||
| 52ac9b1621 | |||
| 9bca545f01 | |||
| 80032f8ed7 | |||
| a63a690307 | |||
| 24dc2716f7 | |||
| 3f40896374 | |||
| 8d8778b397 | |||
| 68d3b422cc | |||
| 145420aaaa | |||
| 34ee17b7f5 | |||
| 2a0646d1dd | |||
| 52620e84cd | |||
| 4747113742 | |||
| f26d7c6a62 | |||
| 2e0d8cfd43 | |||
| db57c53652 | |||
| badf1aec6f | |||
| 19bb4514df | |||
| 778be7fea8 | |||
| 326970bcd4 | |||
| 9411bce8b0 | |||
| 244c1a426b | |||
| b3f9ca8721 | |||
| 8c66a83054 | |||
| df6a1f6613 | |||
| 1033a926fc | |||
| d339c04177 | |||
| edcf0aae84 | |||
| 20f97caab3 | |||
| 86be4e7352 | |||
| 697e271e66 | |||
| 5f74504da8 | |||
| fb3d46d389 | |||
| 875971fb6e | |||
| 1939a58f17 | |||
| 40b3374fdd | |||
| c564b1b75a | |||
| c28e73ce3f | |||
| 788a6bfdc3 | |||
| 15d1f79115 | |||
| bf699d88f7 | |||
| d7f8e4e050 | |||
| 3872d7897a | |||
| 17a1f6ce63 | |||
| eaa155eff7 | |||
| 13fba6d71c | |||
| 0d423aa349 | |||
| 2fca224ba4 | |||
| 574f85df46 | |||
| b7176983e2 | |||
| e8f19ff0dc | |||
| d3cb4607ea | |||
| 8ae0696f07 | |||
| 299c3c13fc | |||
| a79a8bcef6 | |||
| 2a0dd46b5e | |||
| 6c287bc2e2 | |||
| 7add59ffcb | |||
| 9747c43988 | |||
| 8b9a0f1437 | |||
| 1315ca007c | |||
| e753d767fc | |||
| db893859c2 | |||
| 16af3d2ad8 | |||
| f334080fe6 | |||
| b2acfbed98 | |||
| 2aca6ca28a | |||
| c96040edec | |||
| e0ebb44e64 | |||
| ee1af88f8d | |||
| 1659e583ea | |||
| 6f0575d798 | |||
| ba05c45f47 | |||
| 353caf29b3 | |||
| 7600d473bb | |||
| c9ff48245e | |||
| 4ed4a94209 | |||
| c88e01fe75 | |||
| 9e46edce79 | |||
| bae5c67839 | |||
| 635d5d9c6c | |||
| 65be8c385f | |||
| c3d44e2472 | |||
| 4a781ed5f4 | |||
| d9995512a1 | |||
| 6ed2466785 | |||
| 724c74b488 | |||
| 67887c5ba4 | |||
| ea2a0068ed | |||
| 0bfdea5976 | |||
| 305ebc293f | |||
| f17f74672e | |||
| fcaf184b13 | |||
| efe653f1f6 | |||
| c1022bf8f3 | |||
| 0f4c3988f8 | |||
| 498b7b5679 | |||
| ca445a3cb7 | |||
| 8a293749e0 | |||
| 5c034279e8 | |||
| 9460943ad2 | |||
| 5eaeabe231 | |||
| 2202b00600 | |||
| 68ba5a5c4a | |||
| e80b490152 | |||
| 380937b644 | |||
| ac72305101 | |||
| a41779b0bb | |||
| 86cdbf24b7 | |||
| 5d7bc98088 | |||
| 1359e8eb2f | |||
| f3a7003444 | |||
| 624f76b1a0 | |||
| 484ffa071c | |||
| 850fb3cb15 | |||
| 40075ed2e3 | |||
| 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 |
+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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class Admin extends \Espo\Core\Controllers\Base
|
||||
{
|
||||
$scheduledJob = $this->getContainer()->get('scheduledJob');
|
||||
|
||||
return $scheduledJob->getAllNamesOnly();
|
||||
return $scheduledJob->getAvailableList();
|
||||
}
|
||||
|
||||
public function postActionUploadUpgradePackage($params, $data)
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
*
|
||||
* 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;
|
||||
|
||||
@@ -34,17 +34,19 @@ use \Espo\Core\Exceptions\Error;
|
||||
class EmailTemplate extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
public function actionParse($params, $data, $request)
|
||||
{
|
||||
{
|
||||
$id = $request->get('id');
|
||||
$emailAddress = $request->get('emailAddress');
|
||||
if (empty($id)) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
|
||||
return $this->getRecordService()->parse($id, array(
|
||||
'emailAddress' => $request->get('emailAddress'),
|
||||
'parentType' => $request->get('parentType'),
|
||||
'parentId' => $request->get('parentId'),
|
||||
'relatedType' => $request->get('relatedType'),
|
||||
'relatedId' => $request->get('relatedId')
|
||||
), true);
|
||||
}
|
||||
|
||||
|
||||
@@ -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']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -36,7 +36,7 @@ use \Espo\Entities\User;
|
||||
|
||||
use \Espo\Core\Utils\Config;
|
||||
use \Espo\Core\Utils\Metadata;
|
||||
use \Espo\Core\Utils\FieldManager;
|
||||
use \Espo\Core\Utils\FieldManagerUtil;
|
||||
use \Espo\Core\Utils\File\Manager as FileManager;
|
||||
|
||||
class Table
|
||||
@@ -77,7 +77,7 @@ class Table
|
||||
|
||||
protected $forbiddenFieldsCache = array();
|
||||
|
||||
public function __construct(User $user, Config $config = null, FileManager $fileManager = null, Metadata $metadata = null, FieldManager $fieldManager = null)
|
||||
public function __construct(User $user, Config $config = null, FileManager $fileManager = null, Metadata $metadata = null, FieldManagerUtil $fieldManager = null)
|
||||
{
|
||||
$this->data = (object) [
|
||||
'table' => (object) [],
|
||||
|
||||
@@ -107,7 +107,7 @@ class AclManager
|
||||
$config = $this->getContainer()->get('config');
|
||||
$fileManager = $this->getContainer()->get('fileManager');
|
||||
$metadata = $this->getContainer()->get('metadata');
|
||||
$fieldManager = $this->getContainer()->get('fieldManager');
|
||||
$fieldManager = $this->getContainer()->get('fieldManagerUtil');
|
||||
|
||||
$this->tableHashMap[$key] = new $this->tableClassName($user, $config, $fileManager, $metadata, $fieldManager);
|
||||
}
|
||||
@@ -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()) {
|
||||
|
||||
@@ -37,7 +37,7 @@ use \Espo\Entities\Portal;
|
||||
|
||||
use \Espo\Core\Utils\Config;
|
||||
use \Espo\Core\Utils\Metadata;
|
||||
use \Espo\Core\Utils\FieldManager;
|
||||
use \Espo\Core\Utils\FieldManagerUtil;
|
||||
use \Espo\Core\Utils\File\Manager as FileManager;
|
||||
|
||||
class Table extends \Espo\Core\Acl\Table
|
||||
@@ -52,7 +52,7 @@ class Table extends \Espo\Core\Acl\Table
|
||||
|
||||
protected $valuePermissionList = [];
|
||||
|
||||
public function __construct(User $user, Portal $portal, Config $config = null, FileManager $fileManager = null, Metadata $metadata = null, FieldManager $fieldManager = null)
|
||||
public function __construct(User $user, Portal $portal, Config $config = null, FileManager $fileManager = null, Metadata $metadata = null, FieldManagerUtil $fieldManager = null)
|
||||
{
|
||||
if (empty($portal)) {
|
||||
throw new Error("No portal was passed to AclPortal\\Table constructor.");
|
||||
|
||||
@@ -335,6 +335,13 @@ class Container
|
||||
);
|
||||
}
|
||||
|
||||
protected function loadFieldManagerUtil()
|
||||
{
|
||||
return new \Espo\Core\Utils\FieldManagerUtil(
|
||||
$this->get('metadata')
|
||||
);
|
||||
}
|
||||
|
||||
protected function loadThemeManager()
|
||||
{
|
||||
return new \Espo\Core\Utils\ThemeManager(
|
||||
|
||||
@@ -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();
|
||||
@@ -258,6 +258,14 @@ class Record extends Base
|
||||
$params['attributeList'] = $data['attributeList'];
|
||||
}
|
||||
|
||||
if (isset($data['fieldList'])) {
|
||||
$params['fieldList'] = $data['fieldList'];
|
||||
}
|
||||
|
||||
if (isset($data['format'])) {
|
||||
$params['format'] = $data['format'];
|
||||
}
|
||||
|
||||
return array(
|
||||
'id' => $this->getRecordService()->export($params)
|
||||
);
|
||||
|
||||
@@ -59,6 +59,8 @@ class DataManager
|
||||
|
||||
$result &= $this->rebuildDatabase($entityList);
|
||||
|
||||
$this->rebuildScheduledJobs();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -121,6 +123,40 @@ class DataManager
|
||||
return empty($ormData) ? false : true;
|
||||
}
|
||||
|
||||
public function rebuildScheduledJobs()
|
||||
{
|
||||
$metadata = $this->getContainer()->get('metadata');
|
||||
$entityManager = $this->getContainer()->get('entityManager');
|
||||
|
||||
$jobs = $metadata->get(['entityDefs', 'ScheduledJob', 'jobs'], array());
|
||||
|
||||
foreach ($jobs as $jobName => $defs) {
|
||||
if ($jobName && !empty($defs['isSystem']) && !empty($defs['scheduling'])) {
|
||||
if (!$entityManager->getRepository('ScheduledJob')->where(array(
|
||||
'job' => $jobName,
|
||||
'status' => 'Active',
|
||||
'scheduling' => $defs['scheduling']
|
||||
))->findOne()) {
|
||||
$job = $entityManager->getRepository('ScheduledJob')->where(array(
|
||||
'job' => $jobName
|
||||
))->findOne();
|
||||
if ($job) {
|
||||
$entityManager->removeEntity($job);
|
||||
}
|
||||
$job = $entityManager->getEntity('ScheduledJob');
|
||||
$job->set(array(
|
||||
'job' => $jobName,
|
||||
'status' => 'Active',
|
||||
'scheduling' => $defs['scheduling'],
|
||||
'isInternal' => true,
|
||||
'name' => $jobName
|
||||
));
|
||||
$entityManager->saveEntity($job);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update cache timestamp
|
||||
*
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<?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\Export;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
|
||||
class Csv extends \Espo\Core\Injectable
|
||||
{
|
||||
protected $dependencyList = [
|
||||
'config',
|
||||
'preferences'
|
||||
];
|
||||
|
||||
public function process($entityType, $params, $dataList)
|
||||
{
|
||||
if (!is_array($params['attributeList'])) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
$attributeList = $params['attributeList'];
|
||||
|
||||
$delimiter = $this->getInjection('preferences')->get('exportDelimiter');
|
||||
if (empty($delimiter)) {
|
||||
$delimiter = $this->getInjection('config')->get('exportDelimiter', ';');
|
||||
}
|
||||
|
||||
$fp = fopen('php://temp', 'w');
|
||||
fputcsv($fp, $attributeList, $delimiter);
|
||||
foreach ($dataList as $row) {
|
||||
fputcsv($fp, $row, $delimiter);
|
||||
}
|
||||
rewind($fp);
|
||||
$csv = stream_get_contents($fp);
|
||||
fclose($fp);
|
||||
|
||||
return $csv;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,449 @@
|
||||
<?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\Export;
|
||||
|
||||
use \Espo\ORM\Entity;
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
|
||||
class Xlsx extends \Espo\Core\Injectable
|
||||
{
|
||||
protected $dependencyList = [
|
||||
'language',
|
||||
'metadata',
|
||||
'config',
|
||||
'dateTime',
|
||||
'entityManager',
|
||||
'fileStorageManager',
|
||||
'fileManager'
|
||||
];
|
||||
|
||||
protected function getConfig()
|
||||
{
|
||||
return $this->getInjection('config');
|
||||
}
|
||||
|
||||
protected function getMetadata()
|
||||
{
|
||||
return $this->getInjection('metadata');
|
||||
}
|
||||
|
||||
protected function getEntityManager()
|
||||
{
|
||||
return $this->getInjection('entityManager');
|
||||
}
|
||||
|
||||
public function loadAdditionalFields(Entity $entity, $fieldList)
|
||||
{
|
||||
foreach ($entity->getRelationList() as $link) {
|
||||
if ($entity->getRelationType($link) === 'belongsToParent') {
|
||||
if (in_array($link, $fieldList)) {
|
||||
$parent = $entity->get($link);
|
||||
if ($parent instanceof Entity) {
|
||||
$entity->set($link . 'Name', $parent->get('name'));
|
||||
}
|
||||
}
|
||||
} else if ($entity->getRelationType($link) === 'belongsTo' && $entity->getRelationParam($link, 'noJoin') && $entity->hasField($link . 'Name')) {
|
||||
if (in_array($link, $fieldList)) {
|
||||
$related = $entity->get($link);
|
||||
if ($related instanceof Entity) {
|
||||
$entity->set($link . 'Name', $related->get('name'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addAdditionalAttributes($entityType, &$attributeList, $fieldList)
|
||||
{
|
||||
$linkList = [];
|
||||
|
||||
if (!in_array('id', $attributeList)) {
|
||||
$attributeList[] = 'id';
|
||||
}
|
||||
|
||||
$linkDefs = $this->getMetadata()->get(['entityDefs', $entityType, 'links']);
|
||||
if (is_array($linkDefs)) {
|
||||
foreach ($linkDefs as $link => $defs) {
|
||||
if (empty($defs['type'])) continue;
|
||||
if ($defs['type'] === 'belongsToParent') {
|
||||
$linkList[] = $link;
|
||||
} else if ($defs['type'] === 'belongsTo' && !empty($defs['noJoin'])) {
|
||||
if ($this->getMetadata()->get(['entityDefs', $entityType, 'fields', $link])) {
|
||||
$linkList[] = $link;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($linkList as $item) {
|
||||
if (in_array($item, $fieldList) && !in_array($item . 'Name', $attributeList)) {
|
||||
$attributeList[] = $item . 'Name';
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($fieldList as $field) {
|
||||
$type = $this->getMetadata()->get(['entityDefs', $entityType, 'fields', $field, 'type']);
|
||||
if ($type === 'currencyConverted') {
|
||||
if (!in_array($field, $attributeList)) {
|
||||
$attributeList[] = $field;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function process($entityType, $params, $dataList)
|
||||
{
|
||||
if (!is_array($params['fieldList'])) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
$phpExcel = new \PHPExcel();
|
||||
$sheet = $phpExcel->setActiveSheetIndex(0);
|
||||
|
||||
if (isset($params['exportName'])) {
|
||||
$exportName = $params['exportName'];
|
||||
} else {
|
||||
$exportName = $this->getInjection('language')->translate($entityType, 'scopeNamesPlural');
|
||||
}
|
||||
|
||||
$sheetName = substr($exportName, 0, 30);
|
||||
$badCharList = ['*', ':', '/', '\\', '?', '[', ']'];
|
||||
foreach ($badCharList as $badChar) {
|
||||
$sheetName = str_replace($badCharList, ' ', $sheetName);
|
||||
}
|
||||
$sheetName = str_replace('\'', '', $sheetName);
|
||||
|
||||
$sheet->setTitle($sheetName);
|
||||
|
||||
$fieldList = $params['fieldList'];
|
||||
|
||||
$titleStyle = array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 12
|
||||
)
|
||||
);
|
||||
$dateStyle = array(
|
||||
'font' => array(
|
||||
'size' => 12
|
||||
)
|
||||
);
|
||||
|
||||
$sheet->setCellValue('A1', $exportName);
|
||||
|
||||
$sheet->setCellValue('B1', \PHPExcel_Shared_Date::PHPToExcel(strtotime(date('Y-m-d H:i:s'))));
|
||||
|
||||
|
||||
$sheet->getStyle('A1')->applyFromArray($titleStyle);
|
||||
$sheet->getStyle('B1')->applyFromArray($dateStyle);
|
||||
|
||||
$sheet->getStyle('B1')->getNumberFormat()
|
||||
->setFormatCode($this->getInjection('dateTime')->getDateTimeFormat());
|
||||
|
||||
$azRange = range('A', 'Z');
|
||||
$azRangeCopied = $azRange;
|
||||
foreach ($azRangeCopied as $i => $char1) {
|
||||
foreach ($azRangeCopied as $j => $char2) {
|
||||
$azRange[] = $char1 . $char2;
|
||||
if ($i * count($azRangeCopied) + $j === count($fieldList)) {
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rowNumber = 3;
|
||||
|
||||
$linkColList = [];
|
||||
|
||||
$lastIndex = 0;
|
||||
|
||||
foreach ($fieldList as $i => $name) {
|
||||
$col = $azRange[$i];
|
||||
|
||||
$defs = $this->getInjection('metadata')->get(['entityDefs', $entityType, 'fields', $name]);
|
||||
|
||||
if (!$defs) {
|
||||
$defs['type'] = 'base';
|
||||
}
|
||||
|
||||
$label = $name;
|
||||
if (strpos($name, '_') !== false) {
|
||||
list($linkName, $foreignField) = explode('_', $name);
|
||||
$foreigScope = $this->getInjection('metadata')->get(['entityDefs', $entityType, 'links', $linkName, 'entity']);
|
||||
if ($foreigScope) {
|
||||
$label = $this->getInjection('language')->translate($linkName, 'links', $entityType) . '.' . $this->getInjection('language')->translate($foreignField, 'fields', $foreigScope);
|
||||
}
|
||||
} else {
|
||||
$label = $this->getInjection('language')->translate($name, 'fields', $entityType);
|
||||
}
|
||||
|
||||
$sheet->setCellValue($col . $rowNumber, $label);
|
||||
$sheet->getColumnDimension($col)->setAutoSize(true);
|
||||
if (
|
||||
$defs['type'] == 'phone'
|
||||
|| $defs['type'] == 'email'
|
||||
|| $defs['type'] == 'url'
|
||||
|| $defs['type'] == 'link'
|
||||
|| $defs['type'] == 'linkParent'
|
||||
) {
|
||||
$linkColList[] = $col;
|
||||
} else if ($name == 'name') {
|
||||
$linkColList[] = $col;
|
||||
}
|
||||
$lastIndex = $i;
|
||||
}
|
||||
|
||||
$col = $azRange[$i];
|
||||
|
||||
$headerStyle = array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 12
|
||||
)
|
||||
);
|
||||
|
||||
$sheet->getStyle("A$rowNumber:$col$rowNumber")->applyFromArray($headerStyle);
|
||||
$sheet->setAutoFilter("A$rowNumber:$col$rowNumber");
|
||||
|
||||
$rowNumber++;
|
||||
foreach ($dataList as $row) {
|
||||
$i = 0;
|
||||
foreach ($fieldList as $i => $name) {
|
||||
$col = $azRange[$i];
|
||||
|
||||
$defs = $this->getInjection('metadata')->get(['entityDefs', $entityType, 'fields', $name]);
|
||||
if (!$defs) {
|
||||
$defs = array();
|
||||
$defs['type'] = 'base';
|
||||
}
|
||||
$link = null;
|
||||
if ($defs['type'] == 'link') {
|
||||
if (array_key_exists($name.'Name', $row)) {
|
||||
$sheet->setCellValue("$col$rowNumber", $row[$name.'Name']);
|
||||
}
|
||||
} else if ($defs['type'] == 'linkParent') {
|
||||
if (array_key_exists($name.'Name', $row)) {
|
||||
$sheet->setCellValue("$col$rowNumber", $row[$name.'Name']);
|
||||
}
|
||||
} else if ($defs['type'] == 'int') {
|
||||
$sheet->setCellValue("$col$rowNumber", $row[$name] ?: 0);
|
||||
} else if ($defs['type'] == 'currency') {
|
||||
if (array_key_exists($name.'Currency', $row) && array_key_exists($name, $row)) {
|
||||
$sheet->setCellValue("$col$rowNumber", $row[$name] ? $row[$name] : '');
|
||||
$currency = $row[$name . 'Currency'];
|
||||
$currencySymbol = $this->getMetadata()->get(['app', 'currency', 'symbolMap', $currency], '');
|
||||
|
||||
$sheet->getStyle("$col$rowNumber")
|
||||
->getNumberFormat()
|
||||
->setFormatCode('[$'.$currencySymbol.'-409]#,##0.00;-[$'.$currencySymbol.'-409]#,##0.00');
|
||||
}
|
||||
} else if ($defs['type'] == 'currencyConverted') {
|
||||
if (array_key_exists($name, $row)) {
|
||||
$currency = $this->getConfig()->get('baseCurrency');
|
||||
$currencySymbol = $this->getMetadata()->get(['app', 'currency', 'symbolMap', $currency], '');
|
||||
|
||||
$sheet->getStyle("$col$rowNumber")
|
||||
->getNumberFormat()
|
||||
->setFormatCode('[$'.$currencySymbol.'-409]#,##0.00;-[$'.$currencySymbol.'-409]#,##0.00');
|
||||
|
||||
$sheet->setCellValue("$col$rowNumber", $row[$name] ? $row[$name] : '');
|
||||
}
|
||||
} else if ($defs['type'] == 'personName') {
|
||||
if (!empty($row['name'])) {
|
||||
$sheet->setCellValue("$col$rowNumber", $row['name']);
|
||||
} else {
|
||||
$personName = '';
|
||||
if (!empty($row['firstName'])) {
|
||||
$personName .= $row['firstName'];
|
||||
}
|
||||
if (!empty($row['lastName'])) {
|
||||
if (!empty($row['firstName'])) {
|
||||
$personName .= ' ';
|
||||
}
|
||||
$personName .= $row['lastName'];
|
||||
}
|
||||
$sheet->setCellValue("$col$rowNumber", $personName);
|
||||
}
|
||||
} else if ($defs['type'] == 'date') {
|
||||
if (isset($row[$name])) {
|
||||
$sheet->setCellValue("$col$rowNumber", \PHPExcel_Shared_Date::PHPToExcel(strtotime($row[$name])));
|
||||
}
|
||||
} else if ($defs['type'] == 'datetime' || $defs['type'] == 'datetimeOptional') {
|
||||
if (isset($row[$name])) {
|
||||
$sheet->setCellValue("$col$rowNumber", \PHPExcel_Shared_Date::PHPToExcel(strtotime($row[$name])));
|
||||
}
|
||||
} else if ($defs['type'] == 'image') {
|
||||
if (isset($row[$name . 'Id']) && $row[$name . 'Id']) {
|
||||
$attachment = $this->getEntityManager()->getEntity('Attachment', $row[$name . 'Id']);
|
||||
|
||||
if ($attachment) {
|
||||
$objDrawing = new \PHPExcel_Worksheet_Drawing();
|
||||
$filePath = $this->getInjection('fileStorageManager')->getLocalFilePath($attachment);
|
||||
|
||||
if ($filePath && file_exists($filePath)) {
|
||||
$objDrawing->setPath($filePath);
|
||||
$objDrawing->setHeight(100);
|
||||
$objDrawing->setCoordinates("$col$rowNumber");
|
||||
$objDrawing->setWorksheet($sheet);
|
||||
$sheet->getRowDimension($rowNumber)->setRowHeight(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if ($defs['type'] == 'file') {
|
||||
if (array_key_exists($name.'Name', $row)) {
|
||||
$sheet->setCellValue("$col$rowNumber", $row[$name.'Name']);
|
||||
}
|
||||
} else if ($defs['type'] == 'enum') {
|
||||
if (array_key_exists($name, $row)) {
|
||||
$value = $this->getInjection('language')->translateOption($row[$name], $name, $entityType);
|
||||
$sheet->setCellValue("$col$rowNumber", $value);
|
||||
}
|
||||
} else {
|
||||
if (array_key_exists($name, $row)) {
|
||||
$sheet->setCellValue("$col$rowNumber", $row[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
$link = false;
|
||||
|
||||
if ($name == 'name') {
|
||||
if (array_key_exists('id', $row)) {
|
||||
$link = $this->getConfig()->getSiteUrl() . "/#".$entityType . "/view/" . $row['id'];
|
||||
}
|
||||
} else if ($defs['type'] == 'url') {
|
||||
if (array_key_exists($name, $row) && filter_var($row[$name], FILTER_VALIDATE_URL)) {
|
||||
$link = $row[$name];
|
||||
}
|
||||
} else if ($defs['type'] == 'link') {
|
||||
if (array_key_exists($name.'Id', $row)) {
|
||||
$foreignEntity = $this->getMetadata()->get(['entityDefs', $entityType, 'links', $name, 'entity']);
|
||||
if ($foreignEntity) {
|
||||
$link = $this->getConfig()->getSiteUrl() . "/#" . $foreignEntity. "/view/". $row[$name.'Id'];
|
||||
}
|
||||
}
|
||||
} else if ($defs['type'] == 'file') {
|
||||
if (array_key_exists($name.'Id', $row)) {
|
||||
$link = $this->getConfig()->getSiteUrl() . "/?entryPoint=download&id=" . $row[$name.'Id'];
|
||||
}
|
||||
} else if ($defs['type'] == 'linkParent') {
|
||||
if (array_key_exists($name.'Id', $row) && array_key_exists($name.'Type', $row)) {
|
||||
$link = $this->getConfig()->getSiteUrl() . "/#".$row[$name.'Type']."/view/". $row[$name.'Id'];
|
||||
}
|
||||
} else if ($defs['type'] == 'phone') {
|
||||
if (array_key_exists($name, $row)) {
|
||||
$link = "tel:".$row[$name];
|
||||
}
|
||||
} else if ($defs['type'] == 'email' && array_key_exists($name, $row)) {
|
||||
if (array_key_exists($name, $row)) {
|
||||
$link = "mailto:".$row[$name];
|
||||
}
|
||||
}
|
||||
if ($link) {
|
||||
$sheet->getCell("$col$rowNumber")->getHyperlink()->setUrl($link);
|
||||
$sheet->getCell("$col$rowNumber")->getHyperlink()->setTooltip($link);
|
||||
}
|
||||
}
|
||||
$rowNumber++;
|
||||
}
|
||||
|
||||
$startingRowNumber = 4;
|
||||
|
||||
foreach ($fieldList as $i => $name) {
|
||||
$col = $azRange[$i];
|
||||
|
||||
$defs = $this->getInjection('metadata')->get(['entityDefs', $entityType, 'fields', $name]);
|
||||
if (!$defs) {
|
||||
$defs['type'] = 'base';
|
||||
}
|
||||
|
||||
if ($col == 'A') {
|
||||
$sheet->getStyle("A2:A$rowNumber")
|
||||
->getNumberFormat()
|
||||
->setFormatCode(\PHPExcel_Style_NumberFormat::FORMAT_TEXT);
|
||||
} else {
|
||||
switch($defs['type']) {
|
||||
case 'currency':
|
||||
case 'currencyConverted': {
|
||||
|
||||
} break;
|
||||
case 'int': {
|
||||
$sheet->getStyle($col.$startingRowNumber.':'.$col.$rowNumber)
|
||||
->getNumberFormat()
|
||||
->setFormatCode('0');
|
||||
} break;
|
||||
case 'date': {
|
||||
$sheet->getStyle($col.$startingRowNumber.':'.$col.$rowNumber)
|
||||
->getNumberFormat()
|
||||
->setFormatCode($this->getInjection('dateTime')->getDateFormat());
|
||||
} break;
|
||||
case 'datetime': {
|
||||
$sheet->getStyle($col.$startingRowNumber.':'.$col.$rowNumber)
|
||||
->getNumberFormat()
|
||||
->setFormatCode($this->getInjection('dateTime')->getDateTimeFormat());
|
||||
} break;
|
||||
case 'datetimeOptional': {
|
||||
$sheet->getStyle($col.$startingRowNumber.':'.$col.$rowNumber)
|
||||
->getNumberFormat()
|
||||
->setFormatCode($this->getInjection('dateTime')->getDateTimeFormat());
|
||||
} break;
|
||||
default: {
|
||||
$sheet->getStyle($col.$startingRowNumber.':'.$col.$rowNumber)
|
||||
->getNumberFormat()
|
||||
->setFormatCode('@');
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$linkStyle = [
|
||||
'font' => [
|
||||
'color' => ['rgb' => '345b7c'],
|
||||
'underline' => 'single'
|
||||
]
|
||||
];
|
||||
foreach ($linkColList as $linkColumn) {
|
||||
$sheet->getStyle($linkColumn.$startingRowNumber.':'.$linkColumn.$rowNumber)->applyFromArray($linkStyle);
|
||||
}
|
||||
|
||||
$objWriter = \PHPExcel_IOFactory::createWriter($phpExcel, 'Excel2007');
|
||||
|
||||
if (!$this->getInjection('fileManager')->isDir('data/cache/')) {
|
||||
$this->getInjection('fileManager')->mkdir('data/cache/');
|
||||
}
|
||||
$tempFileName = 'data/cache/' . 'export_' . substr(md5(rand()), 0, 7);
|
||||
|
||||
$objWriter->save($tempFileName);
|
||||
$fp = fopen($tempFileName, 'r');
|
||||
$xlsx = stream_get_contents($fp);
|
||||
$this->getInjection('fileManager')->unlink($tempFileName);
|
||||
|
||||
return $xlsx;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?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\ArrayGroup;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
|
||||
class IncludesType extends \Espo\Core\Formula\Functions\Base
|
||||
{
|
||||
public function process(\StdClass $item)
|
||||
{
|
||||
if (!property_exists($item, 'value') || !is_array($item->value)) {
|
||||
throw new Error('Value for \'Array\\Includses\' item is not array.');
|
||||
}
|
||||
if (count($item->value) < 2) {
|
||||
throw new Error('Bad arguments passed to \'Array\\Includses\'.');
|
||||
}
|
||||
$list = $this->evaluate($item->value[0]);
|
||||
$needle = $this->evaluate($item->value[1]);
|
||||
|
||||
if (!is_array($list)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return in_array($needle, $list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?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 DateType extends \Espo\Core\Formula\Functions\Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
$this->addDependency('dateTime');
|
||||
}
|
||||
|
||||
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 (empty($value)) return 0;
|
||||
|
||||
if (strlen($value) > 11) {
|
||||
$resultString = $this->getInjection('dateTime')->convertSystemDateTime($value, null, 'D');
|
||||
} else {
|
||||
$resultString = $this->getInjection('dateTime')->convertSystemDate($value, 'D');
|
||||
}
|
||||
|
||||
return intval($resultString);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?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 DayOfWeekType extends \Espo\Core\Formula\Functions\Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
$this->addDependency('dateTime');
|
||||
}
|
||||
|
||||
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 (empty($value)) return 0;
|
||||
|
||||
if (strlen($value) > 11) {
|
||||
$resultString = $this->getInjection('dateTime')->convertSystemDateTime($value, null, 'D');
|
||||
} else {
|
||||
$resultString = $this->getInjection('dateTime')->convertSystemDate($value, 'D');
|
||||
}
|
||||
|
||||
$result = intval($resultString) + 1;
|
||||
if ($result == 8) {
|
||||
$result = 1;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ class DiffType extends \Espo\Core\Formula\Functions\Base
|
||||
$this->addDependency('dateTime');
|
||||
}
|
||||
|
||||
protected $intevalTypePropertyMap = array(
|
||||
protected $intevalTypePropertyMap = array(
|
||||
'years' => 'y', 'months' => 'm', 'days' => 'd', 'hours' => 'h', 'minutes' => 'i', 'seconds' => 's'
|
||||
);
|
||||
|
||||
@@ -88,7 +88,6 @@ class DiffType extends \Espo\Core\Formula\Functions\Base
|
||||
throw new Error('Not supported interval type' . $intervalType);
|
||||
}
|
||||
|
||||
$property = $this->intevalTypePropertyMap[$intervalType];
|
||||
|
||||
$isTime = false;
|
||||
if (strlen($dateTime1String) > 10) {
|
||||
@@ -102,12 +101,30 @@ class DiffType extends \Espo\Core\Formula\Functions\Base
|
||||
return null;
|
||||
}
|
||||
|
||||
$interval = $dateTime2->diff($dateTime1);
|
||||
$t1 = $dateTime1->getTimestamp();
|
||||
$t2 = $dateTime2->getTimestamp();
|
||||
|
||||
$number = $interval->$property;
|
||||
$secondsDiff = $t1 - $t2;
|
||||
|
||||
if ($interval->invert) {
|
||||
$number *= -1;
|
||||
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;
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?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 HourType extends \Espo\Core\Formula\Functions\Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
$this->addDependency('dateTime');
|
||||
}
|
||||
|
||||
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 (empty($value)) return -1;
|
||||
|
||||
if (strlen($value) > 11) {
|
||||
$resultString = $this->getInjection('dateTime')->convertSystemDateTime($value, null, 'H');
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return intval($resultString);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?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 MinuteType extends \Espo\Core\Formula\Functions\Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
$this->addDependency('dateTime');
|
||||
}
|
||||
|
||||
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 (empty($value)) return -1;
|
||||
|
||||
if (strlen($value) > 11) {
|
||||
$resultString = $this->getInjection('dateTime')->convertSystemDateTime($value, null, 'm');
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return intval($resultString);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?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 MonthType extends \Espo\Core\Formula\Functions\Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
$this->addDependency('dateTime');
|
||||
}
|
||||
|
||||
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 (empty($value)) return 0;
|
||||
|
||||
if (strlen($value) > 11) {
|
||||
$resultString = $this->getInjection('dateTime')->convertSystemDateTime($value, null, 'M');
|
||||
} else {
|
||||
$resultString = $this->getInjection('dateTime')->convertSystemDate($value, 'M');
|
||||
}
|
||||
|
||||
return intval($resultString);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?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 YearType extends \Espo\Core\Formula\Functions\Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
$this->addDependency('dateTime');
|
||||
}
|
||||
|
||||
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 (empty($value)) return 0;
|
||||
|
||||
if (strlen($value) > 11) {
|
||||
$resultString = $this->getInjection('dateTime')->convertSystemDateTime($value, null, 'YYYY');
|
||||
} else {
|
||||
$resultString = $this->getInjection('dateTime')->convertSystemDate($value, 'YYYY');
|
||||
}
|
||||
|
||||
return intval($resultString);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?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;
|
||||
|
||||
use \Espo\ORM\Entity;
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
|
||||
class ListType extends Base
|
||||
{
|
||||
public function process(\StdClass $item)
|
||||
{
|
||||
if (!property_exists($item, 'value')) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
if (!is_array($item->value)) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
$result = [];
|
||||
foreach ($item->value as $item) {
|
||||
$result[] = $this->evaluate($item);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -219,6 +219,11 @@ class Parser
|
||||
$firstOperator = null;
|
||||
$minIndex = null;
|
||||
|
||||
if ($expression === '') return (object) [
|
||||
'type' => 'value',
|
||||
'value' => null
|
||||
];
|
||||
|
||||
foreach ($this->priorityList as $operationList) {
|
||||
foreach ($operationList as $operator) {
|
||||
$index = strpos($expression, $operator, 1);
|
||||
@@ -235,6 +240,18 @@ class Parser
|
||||
!empty($this->operatorMap[$possibleRightOperator])
|
||||
) continue;
|
||||
|
||||
$possibleLeftOperator = null;
|
||||
if (strlen($operator) === 1) {
|
||||
if ($index > 0) {
|
||||
$possibleLeftOperator = trim($expression[$index - 1] . $operator);
|
||||
}
|
||||
}
|
||||
if (
|
||||
$possibleLeftOperator &&
|
||||
$possibleLeftOperator != $operator &&
|
||||
!empty($this->operatorMap[$possibleLeftOperator])
|
||||
) 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +117,9 @@ class Htmlizer
|
||||
if ($item instanceof \StdClass) {
|
||||
$v = get_object_vars($v);
|
||||
}
|
||||
if (!is_array($v)) {
|
||||
$v = [];
|
||||
}
|
||||
foreach ($v as $k => $w) {
|
||||
$v[$k] = $this->format($v[$k]);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -269,18 +279,22 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
|
||||
$entity->set('modifiedAt', $nowString);
|
||||
}
|
||||
if ($entity->hasAttribute('createdById')) {
|
||||
if (empty($options['import']) || !$entity->has('createdById')) {
|
||||
$entity->set('createdById', $this->getEntityManager()->getUser()->id);
|
||||
if (empty($options['skipCreatedBy']) && (empty($options['import']) || !$entity->has('createdById'))) {
|
||||
if ($this->getEntityManager()->getUser()) {
|
||||
$entity->set('createdById', $this->getEntityManager()->getUser()->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (empty($options['silent'])) {
|
||||
if (empty($options['silent']) && empty($options['skipModifiedBy'])) {
|
||||
if ($entity->hasAttribute('modifiedAt')) {
|
||||
$entity->set('modifiedAt', $nowString);
|
||||
}
|
||||
if ($entity->hasAttribute('modifiedById')) {
|
||||
$entity->set('modifiedById', $this->getEntityManager()->getUser()->id);
|
||||
$entity->set('modifiedByName', $this->getEntityManager()->getUser()->get('name'));
|
||||
if ($this->getEntityManager()->getUser()) {
|
||||
$entity->set('modifiedById', $this->getEntityManager()->getUser()->id);
|
||||
$entity->set('modifiedByName', $this->getEntityManager()->getUser()->get('name'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ class AclManager extends \Espo\Core\AclManager
|
||||
$config = $this->getContainer()->get('config');
|
||||
$fileManager = $this->getContainer()->get('fileManager');
|
||||
$metadata = $this->getContainer()->get('metadata');
|
||||
$fieldManager = $this->getContainer()->get('fieldManager');
|
||||
$fieldManager = $this->getContainer()->get('fieldManagerUtil');
|
||||
$portal = $this->getPortal();
|
||||
|
||||
$this->tableHashMap[$key] = new $this->tableClassName($user, $portal, $config, $fileManager, $metadata, $fieldManager);
|
||||
@@ -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'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class ThemeManager extends \Espo\Core\Utils\ThemeManager
|
||||
{
|
||||
$theme = $this->portal->get('theme');
|
||||
if (!$theme) {
|
||||
$theme = $this->defaultName;
|
||||
$theme = $this->config->get('theme', $this->defaultName);
|
||||
}
|
||||
return $theme;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class Base
|
||||
|
||||
private $userTimeZone = null;
|
||||
|
||||
protected $additionalFilterTypeList = ['linkedWith', 'inCategory', 'isUserFromTeams'];
|
||||
protected $additionalFilterTypeList = ['inCategory', 'isUserFromTeams'];
|
||||
|
||||
protected $textFilterUseContainsAttributeList = [];
|
||||
|
||||
@@ -130,7 +130,7 @@ class Base
|
||||
|
||||
$result['orderBy'] = $sortBy;
|
||||
$type = $this->getMetadata()->get(['entityDefs', $this->getEntityType(), 'fields', $sortBy, 'type']);
|
||||
if ($type === 'link') {
|
||||
if (in_array($type, ['link', 'file', 'image'])) {
|
||||
$result['orderBy'] .= 'Name';
|
||||
} else if ($type === 'linkParent') {
|
||||
$result['orderBy'] .= 'Type';
|
||||
@@ -212,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;
|
||||
}
|
||||
@@ -259,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)) {
|
||||
@@ -430,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -442,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()) {
|
||||
@@ -726,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();
|
||||
}
|
||||
@@ -930,7 +946,7 @@ class Base
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function getWherePart($item)
|
||||
protected function getWherePart($item, &$result = null)
|
||||
{
|
||||
$part = array();
|
||||
|
||||
@@ -942,30 +958,38 @@ 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':
|
||||
case 'and':
|
||||
case 'not':
|
||||
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);
|
||||
@@ -1138,6 +1162,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
},
|
||||
"parent": {
|
||||
"type": "linkParent",
|
||||
"entityList": ["Account", "Lead"]
|
||||
"entityList": ["Account", "Lead", "Contact"]
|
||||
},
|
||||
"description": {
|
||||
"type": "text"
|
||||
|
||||
@@ -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}"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "Créer un {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
"labels": {
|
||||
"Create {entityType}": "Créer un {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "Créer un {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
"links": {
|
||||
"meetings": "Meetings",
|
||||
"calls": "Calls",
|
||||
"tasks": "Tasks"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Créer un {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,15 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "Créer un {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
"fields": {
|
||||
"billingAddress": "Billing Address",
|
||||
"shippingAddress": "Shipping Address",
|
||||
"website": "Website"
|
||||
},
|
||||
"links": {
|
||||
"meetings": "Meetings",
|
||||
"calls": "Calls",
|
||||
"tasks": "Tasks"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Créer un {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,36 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "Créer un {entityTypeTranslated}"
|
||||
"fields": {
|
||||
"parent": "Parent",
|
||||
"dateStart": "Date de début",
|
||||
"dateEnd": "Date End",
|
||||
"duration": "Duration",
|
||||
"status": "Status",
|
||||
"reminders": "Reminders"
|
||||
},
|
||||
"links": {
|
||||
"parent": "Parent"
|
||||
},
|
||||
"options": {
|
||||
"status": {
|
||||
"Planned": "Planned",
|
||||
"Held": "Held",
|
||||
"Not Held": "Not Held"
|
||||
}
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Créer un {entityTypeTranslated}",
|
||||
"Schedule {entityType}": "Schedule {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": "Planned",
|
||||
"held": "Held",
|
||||
"todays": "Today's"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,13 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "Créer un {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
"fields": {
|
||||
"address": "Address"
|
||||
},
|
||||
"links": {
|
||||
"meetings": "Meetings",
|
||||
"calls": "Calls",
|
||||
"tasks": "Tasks"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Créer un {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -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}"
|
||||
}
|
||||
}
|
||||
"labels": {
|
||||
"Create {entityType}": "Создать {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "Создать {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
"links": {
|
||||
"meetings": "Meetings",
|
||||
"calls": "Calls",
|
||||
"tasks": "Tasks"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Создать {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,15 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "Создать {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
"fields": {
|
||||
"billingAddress": "Платежный адрес",
|
||||
"shippingAddress": "Адрес доставки",
|
||||
"website": "Website"
|
||||
},
|
||||
"links": {
|
||||
"meetings": "Meetings",
|
||||
"calls": "Calls",
|
||||
"tasks": "Tasks"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Создать {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,36 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "Создать {entityTypeTranslated}"
|
||||
"fields": {
|
||||
"parent": "Parent",
|
||||
"dateStart": "Date Start",
|
||||
"dateEnd": "Date End",
|
||||
"duration": "Duration",
|
||||
"status": "Status",
|
||||
"reminders": "Reminders"
|
||||
},
|
||||
"links": {
|
||||
"parent": "Parent"
|
||||
},
|
||||
"options": {
|
||||
"status": {
|
||||
"Planned": "Planned",
|
||||
"Held": "Held",
|
||||
"Not Held": "Not Held"
|
||||
}
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Создать {entityTypeTranslated}",
|
||||
"Schedule {entityType}": "Schedule {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": "Held",
|
||||
"todays": "Сегодняшние"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,13 @@
|
||||
{
|
||||
"labels": {
|
||||
"Create {entityType}": "Создать {entityTypeTranslated}"
|
||||
}
|
||||
}
|
||||
"fields": {
|
||||
"address": "Адрес"
|
||||
},
|
||||
"links": {
|
||||
"meetings": "Meetings",
|
||||
"calls": "Calls",
|
||||
"tasks": "Tasks"
|
||||
},
|
||||
"labels": {
|
||||
"Create {entityType}": "Создать {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": "Адреса виставлення рахунку",
|
||||
"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}": "Лог {entityTypeTranslated}",
|
||||
"Set Held": "Позначити виконаним",
|
||||
"Set Not Held": "Позначити невиконаним"
|
||||
},
|
||||
"massActions": {
|
||||
"setHeld": "Позначити виконаними",
|
||||
"setNotHeld": "Позначити невиконаними"
|
||||
},
|
||||
"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');
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -125,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;
|
||||
|
||||
@@ -157,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))
|
||||
|
||||
@@ -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'
|
||||
)
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
@@ -31,8 +31,25 @@ return array(
|
||||
|
||||
'unset' => array(
|
||||
'__APPEND__',
|
||||
'Preferences',
|
||||
'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'
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
|
||||
@@ -93,6 +93,16 @@ class DateTime
|
||||
$this->timezone = new \DateTimeZone($timeZone);
|
||||
}
|
||||
|
||||
public function getDateFormat()
|
||||
{
|
||||
return $this->dateFormat;
|
||||
}
|
||||
|
||||
public function getDateTimeFormat()
|
||||
{
|
||||
return $this->dateFormat . ' ' . $this->timeFormat;
|
||||
}
|
||||
|
||||
public function getInternalDateTimeFormat()
|
||||
{
|
||||
return $this->internalDateTimeFormat;
|
||||
|
||||
@@ -663,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'];
|
||||
@@ -680,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'];
|
||||
|
||||
@@ -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;
|
||||
@@ -97,6 +99,17 @@ class FieldManager
|
||||
if (isset($existingField)) {
|
||||
throw new Conflict('Field ['.$name.'] exists in '.$scope);
|
||||
}
|
||||
if ($this->getMetadata()->get(['entityDefs', $scope, 'links', $name])) {
|
||||
throw new Conflict('Link with name ['.$name.'] exists in '.$scope);
|
||||
}
|
||||
if (in_array($name, $this->forbiddenFieldNameList)) {
|
||||
throw new Conflict('Field ['.$name.'] is not allowed');
|
||||
}
|
||||
|
||||
$firstLatter = $name[0];
|
||||
if (is_numeric($firstLatter)) {
|
||||
throw new Conflict('Field name should begin with a letter');
|
||||
}
|
||||
|
||||
return $this->update($scope, $name, $fieldDefs, true);
|
||||
}
|
||||
@@ -122,7 +135,7 @@ class FieldManager
|
||||
|
||||
$type = isset($fieldDefs['type']) ? $fieldDefs['type'] : $type = $this->getMetadata()->get(['entityDefs', $scope, 'fields', $name, 'type']);
|
||||
|
||||
$this->processHook('beforeSave', $type, $scope, $name, $fieldDefs);
|
||||
$this->processHook('beforeSave', $type, $scope, $name, $fieldDefs, array('isNew' => $isNew));
|
||||
|
||||
if ($this->getMetadata()->get(['fields', $type, 'translatedOptions'])) {
|
||||
if (isset($fieldDefs['translatedOptions'])) {
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?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\FieldManager\Hooks;
|
||||
|
||||
use Espo\Core\Exceptions\Conflict;
|
||||
|
||||
class AttachmentMultipleType extends Base
|
||||
{
|
||||
public function beforeSave($scope, $name, $defs, $options)
|
||||
{
|
||||
if (!empty($options['isNew'])) {
|
||||
$fieldDefs = $this->getMetadata()->get(['entityDefs', $scope, 'fields'], array());
|
||||
foreach ($fieldDefs as $field => $defs) {
|
||||
$type = $this->getMetadata()->get(['entityDefs', $scope, 'fields', $field, 'type']);
|
||||
if ($type === 'attachmentMultiple') {
|
||||
throw new Conflict("Attachment-Multiple field already exists in '{$scope}'. There can be only one Attachment-Multiple field per entity type.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?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;
|
||||
|
||||
class FieldManagerUtil
|
||||
{
|
||||
private $metadata;
|
||||
|
||||
public function __construct(Metadata $metadata)
|
||||
{
|
||||
$this->metadata = $metadata;
|
||||
}
|
||||
|
||||
protected function getMetadata()
|
||||
{
|
||||
return $this->metadata;
|
||||
}
|
||||
|
||||
private function getAttributeListByType($scope, $name, $type)
|
||||
{
|
||||
$fieldType = $this->getMetadata()->get('entityDefs.' . $scope . '.fields.' . $name . '.type');
|
||||
if (!$fieldType) return [];
|
||||
|
||||
$defs = $this->getMetadata()->get('fields.' . $fieldType);
|
||||
if (!$defs) return [];
|
||||
if (is_object($defs)) {
|
||||
$defs = get_object_vars($defs);
|
||||
}
|
||||
|
||||
$fieldList = [];
|
||||
|
||||
if (isset($defs[$type . 'Fields'])) {
|
||||
$list = $defs[$type . 'Fields'];
|
||||
$naming = 'suffix';
|
||||
if (isset($defs['naming'])) {
|
||||
$naming = $defs['naming'];
|
||||
}
|
||||
if ($naming == 'prefix') {
|
||||
foreach ($list as $f) {
|
||||
$fieldList[] = $f . ucfirst($name);
|
||||
}
|
||||
} else {
|
||||
foreach ($list as $f) {
|
||||
$fieldList[] = $name . ucfirst($f);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($type == 'actual') {
|
||||
$fieldList[] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
return $fieldList;
|
||||
}
|
||||
|
||||
public function getActualAttributeList($scope, $name)
|
||||
{
|
||||
return $this->getAttributeListByType($scope, $name, 'actual');
|
||||
}
|
||||
|
||||
public function getNotActualAttributeList($scope, $name)
|
||||
{
|
||||
return $this->getAttributeListByType($scope, $name, 'notActual');
|
||||
}
|
||||
|
||||
public function getAttributeList($scope, $name)
|
||||
{
|
||||
return array_merge($this->getActualAttributeList($scope, $name), $this->getNotActualAttributeList($scope, $name));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -326,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',
|
||||
);
|
||||
@@ -111,6 +111,15 @@ class ScheduledJob
|
||||
return $this->getClassName($name);
|
||||
}
|
||||
|
||||
public function getAvailableList()
|
||||
{
|
||||
$data = $this->getAll();
|
||||
|
||||
$list = array_keys($data);
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of all job names
|
||||
*
|
||||
@@ -165,6 +174,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';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,7 +35,7 @@ class ThemeManager
|
||||
|
||||
protected $metadata;
|
||||
|
||||
private $defaultName = 'Espo';
|
||||
protected $defaultName = 'Espo';
|
||||
|
||||
private $defaultStylesheet = 'Espo';
|
||||
|
||||
|
||||
@@ -580,5 +580,27 @@ class Util
|
||||
|
||||
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,15 @@ 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',
|
||||
'currencyFormat' => 1,
|
||||
'currencyDecimalPlaces' => null,
|
||||
'isInstalled' => false
|
||||
);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user