use object for conroller action data
This commit is contained in:
@@ -53,7 +53,7 @@ class Admin extends \Espo\Core\Controllers\Base
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function postActionClearCache($params, $data)
|
||||
public function postActionClearCache($params)
|
||||
{
|
||||
$result = $this->getContainer()->get('dataManager')->clearCache();
|
||||
return $result;
|
||||
@@ -93,17 +93,17 @@ class Admin extends \Espo\Core\Controllers\Base
|
||||
}
|
||||
|
||||
$upgradeManager = new \Espo\Core\UpgradeManager($this->getContainer());
|
||||
$upgradeManager->install($data);
|
||||
$upgradeManager->install(get_object_vars($data));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function actionCronMessage($params, $data)
|
||||
public function actionCronMessage($params)
|
||||
{
|
||||
return $this->getContainer()->get('scheduledJob')->getSetupMessage();
|
||||
}
|
||||
|
||||
public function actionAdminNotificationList($params, $data)
|
||||
public function actionAdminNotificationList($params)
|
||||
{
|
||||
$adminNotificationManager = new \Espo\Core\Utils\AdminNotificationManager($this->getContainer());
|
||||
return $adminNotificationManager->getNotificationList();
|
||||
|
||||
@@ -40,12 +40,11 @@ class App extends \Espo\Core\Controllers\Base
|
||||
|
||||
public function postActionDestroyAuthToken($params, $data)
|
||||
{
|
||||
$token = $data['token'];
|
||||
if (empty($token)) {
|
||||
if (empty($data->token)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$auth = new \Espo\Core\Utils\Auth($this->getContainer());
|
||||
return $auth->destroyAuthToken($token);
|
||||
return $auth->destroyAuthToken($data->token);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,12 +42,17 @@ class AuthToken extends \Espo\Core\Controllers\Record
|
||||
|
||||
public function actionUpdate($params, $data, $request)
|
||||
{
|
||||
$dataAr = get_object_vars($data);
|
||||
|
||||
if (
|
||||
is_array($data) &&
|
||||
array_key_exists('isActive', $data) &&
|
||||
$data['isActive'] === false &&
|
||||
count(array_keys($data)) === 1)
|
||||
{
|
||||
is_object($data)
|
||||
&&
|
||||
isset($data->isActive)
|
||||
&&
|
||||
$data->isActive === false
|
||||
&&
|
||||
count(array_keys($dataAr)) === 1
|
||||
) {
|
||||
return parent::actionUpdate($params, $data, $request);
|
||||
}
|
||||
throw new Forbidden();
|
||||
@@ -55,16 +60,19 @@ class AuthToken extends \Espo\Core\Controllers\Record
|
||||
|
||||
public function actionMassUpdate($params, $data, $request)
|
||||
{
|
||||
if (empty($data['attributes'])) {
|
||||
if (empty($data->attributes)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$attributes = $data['attributes'];
|
||||
$attributes = $data->attributes;
|
||||
|
||||
if (
|
||||
is_object($attributes) &&
|
||||
isset($attributes->isActive) &&
|
||||
$attributes->isActive === false &&
|
||||
is_object($attributes)
|
||||
&&
|
||||
isset($attributes->isActive)
|
||||
&&
|
||||
$attributes->isActive === false
|
||||
&&
|
||||
count(array_keys(get_object_vars($attributes))) === 1
|
||||
) {
|
||||
return parent::actionMassUpdate($params, $data, $request);
|
||||
@@ -87,4 +95,3 @@ class AuthToken extends \Espo\Core\Controllers\Record
|
||||
throw new Forbidden();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,10 +38,10 @@ class Email extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
public function postActionGetCopiedAttachments($params, $data, $request)
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
$id = $data['id'];
|
||||
$id = $data->id;
|
||||
|
||||
return $this->getRecordService()->getCopiedAttachments($id);
|
||||
}
|
||||
@@ -56,25 +56,25 @@ class Email extends \Espo\Core\Controllers\Record
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
if (is_null($data['password'])) {
|
||||
if ($data['type'] == 'preferences') {
|
||||
if (!$this->getUser()->isAdmin() && $data['id'] !== $this->getUser()->id) {
|
||||
if (is_null($data->password)) {
|
||||
if ($data->type == 'preferences') {
|
||||
if (!$this->getUser()->isAdmin() && $data->id !== $this->getUser()->id) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
$preferences = $this->getEntityManager()->getEntity('Preferences', $data['id']);
|
||||
$preferences = $this->getEntityManager()->getEntity('Preferences', $data->id);
|
||||
if (!$preferences) {
|
||||
throw new NotFound();
|
||||
}
|
||||
|
||||
if (is_null($data['password'])) {
|
||||
$data['password'] = $this->getContainer()->get('crypt')->decrypt($preferences->get('smtpPassword'));
|
||||
if (is_null($data->password)) {
|
||||
$data->password = $this->getContainer()->get('crypt')->decrypt($preferences->get('smtpPassword'));
|
||||
}
|
||||
} else if ($data['type'] == 'emailAccount') {
|
||||
} else if ($data->type == 'emailAccount') {
|
||||
if (!$this->getAcl()->checkScope('EmailAccount')) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
if (!empty($data['id'])) {
|
||||
$emailAccount = $this->getEntityManager()->getEntity('EmailAccount', $data['id']);
|
||||
if (!empty($data->id)) {
|
||||
$emailAccount = $this->getEntityManager()->getEntity('EmailAccount', $data->id);
|
||||
if (!$emailAccount) {
|
||||
throw new NotFound();
|
||||
}
|
||||
@@ -83,29 +83,29 @@ class Email extends \Espo\Core\Controllers\Record
|
||||
throw new Forbidden();
|
||||
}
|
||||
}
|
||||
if (is_null($data['password'])) {
|
||||
$data['password'] = $this->getContainer()->get('crypt')->decrypt($emailAccount->get('smtpPassword'));
|
||||
if (is_null($data->password)) {
|
||||
$data->password = $this->getContainer()->get('crypt')->decrypt($emailAccount->get('smtpPassword'));
|
||||
}
|
||||
}
|
||||
} else if ($data['type'] == 'inboundEmail') {
|
||||
} else if ($data->type == 'inboundEmail') {
|
||||
if (!$this->getUser()->isAdmin()) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
if (!empty($data['id'])) {
|
||||
$emailAccount = $this->getEntityManager()->getEntity('InboundEmail', $data['id']);
|
||||
if (!empty($data->id)) {
|
||||
$emailAccount = $this->getEntityManager()->getEntity('InboundEmail', $data->id);
|
||||
if (!$emailAccount) {
|
||||
throw new NotFound();
|
||||
}
|
||||
if (is_null($data['password'])) {
|
||||
$data['password'] = $this->getContainer()->get('crypt')->decrypt($emailAccount->get('smtpPassword'));
|
||||
if (is_null($data->password)) {
|
||||
$data->password = $this->getContainer()->get('crypt')->decrypt($emailAccount->get('smtpPassword'));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!$this->getUser()->isAdmin()) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
if (is_null($data['password'])) {
|
||||
$data['password'] = $this->getConfig()->get('smtpPassword');
|
||||
if (is_null($data->password)) {
|
||||
$data->password = $this->getConfig()->get('smtpPassword');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,30 +115,30 @@ class Email extends \Espo\Core\Controllers\Record
|
||||
|
||||
public function postActionMarkAsRead($params, $data, $request)
|
||||
{
|
||||
if (!empty($data['ids'])) {
|
||||
$ids = $data['ids'];
|
||||
if (!empty($data->ids)) {
|
||||
$idList = $data->ids;
|
||||
} else {
|
||||
if (!empty($data['id'])) {
|
||||
$ids = [$data['id']];
|
||||
if (!empty($data->id)) {
|
||||
$idList = [$data->id];
|
||||
} else {
|
||||
throw new BadRequest();
|
||||
}
|
||||
}
|
||||
return $this->getRecordService()->markAsReadByIdList($ids);
|
||||
return $this->getRecordService()->markAsReadByIdList($idList);
|
||||
}
|
||||
|
||||
public function postActionMarkAsNotRead($params, $data, $request)
|
||||
{
|
||||
if (!empty($data['ids'])) {
|
||||
$ids = $data['ids'];
|
||||
if (!empty($data->ids)) {
|
||||
$idList = $data->ids;
|
||||
} else {
|
||||
if (!empty($data['id'])) {
|
||||
$ids = [$data['id']];
|
||||
if (!empty($data->id)) {
|
||||
$idList = [$data->id];
|
||||
} else {
|
||||
throw new BadRequest();
|
||||
}
|
||||
}
|
||||
return $this->getRecordService()->markAsNotReadByIdList($ids);
|
||||
return $this->getRecordService()->markAsNotReadByIdList($idList);
|
||||
}
|
||||
|
||||
public function postActionMarkAllAsRead($params, $data, $request)
|
||||
@@ -148,58 +148,58 @@ class Email extends \Espo\Core\Controllers\Record
|
||||
|
||||
public function postActionMarkAsImportant($params, $data, $request)
|
||||
{
|
||||
if (!empty($data['ids'])) {
|
||||
$ids = $data['ids'];
|
||||
if (!empty($data->ids)) {
|
||||
$idList = $data->ids;
|
||||
} else {
|
||||
if (!empty($data['id'])) {
|
||||
$ids = [$data['id']];
|
||||
if (!empty($data->id)) {
|
||||
$idList = [$data->id];
|
||||
} else {
|
||||
throw new BadRequest();
|
||||
}
|
||||
}
|
||||
return $this->getRecordService()->markAsImportantByIdList($ids);
|
||||
return $this->getRecordService()->markAsImportantByIdList($idList);
|
||||
}
|
||||
|
||||
public function postActionMarkAsNotImportant($params, $data, $request)
|
||||
{
|
||||
if (!empty($data['ids'])) {
|
||||
$ids = $data['ids'];
|
||||
if (!empty($data->ids)) {
|
||||
$idList = $data->ids;
|
||||
} else {
|
||||
if (!empty($data['id'])) {
|
||||
$ids = [$data['id']];
|
||||
if (!empty($data->id)) {
|
||||
$idList = [$data->id];
|
||||
} else {
|
||||
throw new BadRequest();
|
||||
}
|
||||
}
|
||||
return $this->getRecordService()->markAsNotImportantByIdList($ids);
|
||||
return $this->getRecordService()->markAsNotImportantByIdList($idList);
|
||||
}
|
||||
|
||||
public function postActionMoveToTrash($params, $data)
|
||||
{
|
||||
if (!empty($data['ids'])) {
|
||||
$ids = $data['ids'];
|
||||
if (!empty($data->ids)) {
|
||||
$idList = $data->ids;
|
||||
} else {
|
||||
if (!empty($data['id'])) {
|
||||
$ids = [$data['id']];
|
||||
if (!empty($data->id)) {
|
||||
$idList = [$data->id];
|
||||
} else {
|
||||
throw new BadRequest();
|
||||
}
|
||||
}
|
||||
return $this->getRecordService()->moveToTrashByIdList($ids);
|
||||
return $this->getRecordService()->moveToTrashByIdList($idList);
|
||||
}
|
||||
|
||||
public function postActionRetrieveFromTrash($params, $data)
|
||||
{
|
||||
if (!empty($data['ids'])) {
|
||||
$ids = $data['ids'];
|
||||
if (!empty($data->ids)) {
|
||||
$idList = $data->ids;
|
||||
} else {
|
||||
if (!empty($data['id'])) {
|
||||
$ids = [$data['id']];
|
||||
if (!empty($data->id)) {
|
||||
$idList = [$data->id];
|
||||
} else {
|
||||
throw new BadRequest();
|
||||
}
|
||||
}
|
||||
return $this->getRecordService()->retrieveFromTrashByIdList($ids);
|
||||
return $this->getRecordService()->retrieveFromTrashByIdList($idList);
|
||||
}
|
||||
|
||||
public function getActionGetFoldersNotReadCounts(&$params, $request, $data)
|
||||
@@ -219,20 +219,19 @@ class Email extends \Espo\Core\Controllers\Record
|
||||
|
||||
public function postActionMoveToFolder($params, $data)
|
||||
{
|
||||
if (!empty($data['ids'])) {
|
||||
$ids = $data['ids'];
|
||||
if (!empty($data->ids)) {
|
||||
$idList = $data->ids;
|
||||
} else {
|
||||
if (!empty($data['id'])) {
|
||||
$ids = [$data['id']];
|
||||
if (!empty($data->id)) {
|
||||
$idList = [$data->id];
|
||||
} else {
|
||||
throw new BadRequest();
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($data['folderId'])) {
|
||||
if (empty($data->folderId)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
return $this->getRecordService()->moveToFolderByIdList($ids, $data['folderId']);
|
||||
return $this->getRecordService()->moveToFolderByIdList($idList, $data->folderId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,9 +59,9 @@ class EmailAccount extends \Espo\Core\Controllers\Record
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (is_null($data['password'])) {
|
||||
$emailAccount = $this->getEntityManager()->getEntity('EmailAccount', $data['id']);
|
||||
if (!$emailAccount) {
|
||||
if (is_null($data->password)) {
|
||||
$emailAccount = $this->getEntityManager()->getEntity('EmailAccount', $data->id);
|
||||
if (!$emailAccount || !$emailAccount->id) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
@@ -69,10 +69,10 @@ class EmailAccount extends \Espo\Core\Controllers\Record
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$data['password'] = $this->getContainer()->get('crypt')->decrypt($emailAccount->get('password'));
|
||||
$data->password = $this->getContainer()->get('crypt')->decrypt($emailAccount->get('password'));
|
||||
}
|
||||
|
||||
return $this->getRecordService()->testConnection($data);
|
||||
return $this->getRecordService()->testConnection(get_object_vars($data));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,22 +35,22 @@ class EmailFolder extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
public function postActionMoveUp($params, $data, $request)
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->getRecordService()->moveUp($data['id']);
|
||||
$this->getRecordService()->moveUp($data->id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function postActionMoveDown($params, $data, $request)
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->getRecordService()->moveDown($data['id']);
|
||||
$this->getRecordService()->moveDown($data->id);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -60,4 +60,3 @@ class EmailFolder extends \Espo\Core\Controllers\Record
|
||||
return $this->getRecordService()->listAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ class EntityManager extends \Espo\Core\Controllers\Base
|
||||
|
||||
public function actionCreateEntity($params, $data, $request)
|
||||
{
|
||||
$data = get_object_vars($data);
|
||||
|
||||
if (!$request->isPost()) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
@@ -103,6 +105,8 @@ class EntityManager extends \Espo\Core\Controllers\Base
|
||||
|
||||
public function actionUpdateEntity($params, $data, $request)
|
||||
{
|
||||
$data = get_object_vars($data);
|
||||
|
||||
if (!$request->isPost()) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
@@ -129,6 +133,8 @@ class EntityManager extends \Espo\Core\Controllers\Base
|
||||
|
||||
public function actionRemoveEntity($params, $data, $request)
|
||||
{
|
||||
$data = get_object_vars($data);
|
||||
|
||||
if (!$request->isPost()) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
@@ -160,6 +166,8 @@ class EntityManager extends \Espo\Core\Controllers\Base
|
||||
|
||||
public function actionCreateLink($params, $data, $request)
|
||||
{
|
||||
$data = get_object_vars($data);
|
||||
|
||||
if (!$request->isPost()) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
@@ -218,6 +226,8 @@ class EntityManager extends \Espo\Core\Controllers\Base
|
||||
|
||||
public function actionUpdateLink($params, $data, $request)
|
||||
{
|
||||
$data = get_object_vars($data);
|
||||
|
||||
if (!$request->isPost()) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
@@ -269,6 +279,8 @@ class EntityManager extends \Espo\Core\Controllers\Base
|
||||
|
||||
public function actionRemoveLink($params, $data, $request)
|
||||
{
|
||||
$data = get_object_vars($data);
|
||||
|
||||
if (!$request->isPost()) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
@@ -295,20 +307,19 @@ class EntityManager extends \Espo\Core\Controllers\Base
|
||||
|
||||
public function postActionFormula($params, $data, $request)
|
||||
{
|
||||
if (empty($data['scope'])) {
|
||||
if (empty($data->scope)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
if (!array_key_exists('data', $data)) {
|
||||
if (!property_exists($data, 'data')) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$formulaData = get_object_vars($data['data']);
|
||||
$formulaData = get_object_vars($data->data);
|
||||
|
||||
$this->getContainer()->get('entityManagerUtil')->setFormulaData($data['scope'], $formulaData);
|
||||
$this->getContainer()->get('entityManagerUtil')->setFormulaData($data->scope, $formulaData);
|
||||
|
||||
$this->getContainer()->get('dataManager')->clearCache();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ class Extension extends \Espo\Core\Controllers\Record
|
||||
|
||||
$manager = new \Espo\Core\ExtensionManager($this->getContainer());
|
||||
|
||||
$manager->install($data);
|
||||
$manager->install(get_object_vars($data));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ class Extension extends \Espo\Core\Controllers\Record
|
||||
}
|
||||
|
||||
$manager = new \Espo\Core\ExtensionManager($this->getContainer());
|
||||
$manager->uninstall($data);
|
||||
$manager->uninstall(get_object_vars($data));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -149,4 +149,3 @@ class Extension extends \Espo\Core\Controllers\Record
|
||||
throw new Forbidden();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,6 @@ class ExternalAccount extends \Espo\Core\Controllers\Record
|
||||
$id = $request->get('id');
|
||||
list($integration, $userId) = explode('__', $id);
|
||||
|
||||
|
||||
if ($this->getUser()->id != $userId) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
@@ -109,8 +108,8 @@ class ExternalAccount extends \Espo\Core\Controllers\Record
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
if (isset($data['enabled']) && !$data['enabled']) {
|
||||
$data['data'] = null;
|
||||
if (isset($data->enabled) && !$data->enabled) {
|
||||
$data->data = null;
|
||||
}
|
||||
|
||||
$entity = $this->getEntityManager()->getEntity('ExternalAccount', $params['id']);
|
||||
@@ -126,8 +125,8 @@ class ExternalAccount extends \Espo\Core\Controllers\Record
|
||||
throw new Error('Bad HTTP method type.');
|
||||
}
|
||||
|
||||
$id = $data['id'];
|
||||
$code = $data['code'];
|
||||
$id = $data->id;
|
||||
$code = $data->code;
|
||||
|
||||
list($integration, $userId) = explode('__', $id);
|
||||
|
||||
@@ -139,4 +138,3 @@ class ExternalAccount extends \Espo\Core\Controllers\Record
|
||||
return $service->authorizationCode($integration, $userId, $code);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,21 +60,21 @@ class FieldManager extends \Espo\Core\Controllers\Base
|
||||
|
||||
public function postActionCreate($params, $data)
|
||||
{
|
||||
if (empty($params['scope']) || empty($data['name'])) {
|
||||
if (empty($params['scope']) || empty($data->name)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$fieldManager = $this->getContainer()->get('fieldManager');
|
||||
$fieldManager->create($params['scope'], $data['name'], $data);
|
||||
$fieldManager->create($params['scope'], $data->name, get_object_vars($data));
|
||||
|
||||
try {
|
||||
$this->getContainer()->get('dataManager')->rebuild($params['scope']);
|
||||
} catch (Error $e) {
|
||||
$fieldManager->delete($params['scope'], $data['name']);
|
||||
$fieldManager->delete($params['scope'], $data->name);
|
||||
throw new Error($e->getMessage());
|
||||
}
|
||||
|
||||
return $fieldManager->read($params['scope'], $data['name']);
|
||||
return $fieldManager->read($params['scope'], $data->name);
|
||||
}
|
||||
|
||||
public function putActionUpdate($params, $data)
|
||||
@@ -84,7 +84,7 @@ class FieldManager extends \Espo\Core\Controllers\Base
|
||||
}
|
||||
|
||||
$fieldManager = $this->getContainer()->get('fieldManager');
|
||||
$fieldManager->update($params['scope'], $params['name'], $data);
|
||||
$fieldManager->update($params['scope'], $params['name'], get_object_vars($data));
|
||||
|
||||
if ($fieldManager->isChanged()) {
|
||||
$this->getContainer()->get('dataManager')->rebuild($params['scope']);
|
||||
@@ -110,15 +110,14 @@ class FieldManager extends \Espo\Core\Controllers\Base
|
||||
|
||||
public function postActionResetToDefault($params, $data)
|
||||
{
|
||||
if (empty($data['scope']) || empty($data['name'])) {
|
||||
if (empty($data->scope) || empty($data->name)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->getContainer()->get('fieldManager')->resetToDefault($data['scope'], $data['name']);
|
||||
$this->getContainer()->get('fieldManager')->resetToDefault($data->scope, $data->name);
|
||||
|
||||
$this->getContainer()->get('dataManager')->rebuildMetadata();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,24 +101,24 @@ class Import extends \Espo\Core\Controllers\Record
|
||||
|
||||
public function actionRevert($params, $data, $request)
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
if (!$request->isPost()) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
return $this->getService('Import')->revert($data['id']);
|
||||
return $this->getService('Import')->revert($data->id);
|
||||
}
|
||||
|
||||
public function actionRemoveDuplicates($params, $data, $request)
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
if (!$request->isPost()) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
return $this->getService('Import')->removeDuplicates($data['id']);
|
||||
return $this->getService('Import')->removeDuplicates($data->id);
|
||||
}
|
||||
|
||||
public function actionCreate($params, $data, $request)
|
||||
@@ -127,87 +127,90 @@ class Import extends \Espo\Core\Controllers\Record
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (!isset($data['fieldDelimiter'])) {
|
||||
if (!isset($data->fieldDelimiter)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (!isset($data['textQualifier'])) {
|
||||
if (!isset($data->textQualifier)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (!isset($data['dateFormat'])) {
|
||||
if (!isset($data->dateFormat)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (!isset($data['timeFormat'])) {
|
||||
if (!isset($data->timeFormat)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (!isset($data['personNameFormat'])) {
|
||||
if (!isset($data->personNameFormat)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (!isset($data['decimalMark'])) {
|
||||
if (!isset($data->decimalMark)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (!isset($data['defaultValues'])) {
|
||||
if (!isset($data->defaultValues)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (!isset($data['action'])) {
|
||||
if (!isset($data->action)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (!isset($data['attachmentId'])) {
|
||||
if (!isset($data->attachmentId)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (!isset($data['entityType'])) {
|
||||
if (!isset($data->entityType)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (!isset($data->fields)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$timezone = 'UTC';
|
||||
if (isset($data['timezone'])) {
|
||||
$timezone = $data['timezone'];
|
||||
if (isset($data->timezone)) {
|
||||
$timezone = $data->timezone;
|
||||
}
|
||||
|
||||
$importParams = array(
|
||||
'headerRow' => !empty($data['headerRow']),
|
||||
'fieldDelimiter' => $data['fieldDelimiter'],
|
||||
'textQualifier' => $data['textQualifier'],
|
||||
'dateFormat' => $data['dateFormat'],
|
||||
'timeFormat' => $data['timeFormat'],
|
||||
'headerRow' => !empty($data->headerRow),
|
||||
'fieldDelimiter' => $data->fieldDelimiter,
|
||||
'textQualifier' => $data->textQualifier,
|
||||
'dateFormat' => $data->dateFormat,
|
||||
'timeFormat' => $data->timeFormat,
|
||||
'timezone' => $timezone,
|
||||
'personNameFormat' => $data['personNameFormat'],
|
||||
'decimalMark' => $data['decimalMark'],
|
||||
'currency' => $data['currency'],
|
||||
'defaultValues' => $data['defaultValues'],
|
||||
'action' => $data['action'],
|
||||
'skipDuplicateChecking' => !empty($data['skipDuplicateChecking']),
|
||||
'idleMode' => !empty($data['idleMode'])
|
||||
'personNameFormat' => $data->personNameFormat,
|
||||
'decimalMark' => $data->decimalMark,
|
||||
'currency' => $data->currency,
|
||||
'defaultValues' => $data->defaultValues,
|
||||
'action' => $data->action,
|
||||
'skipDuplicateChecking' => !empty($data->skipDuplicateChecking),
|
||||
'idleMode' => !empty($data->idleMode)
|
||||
);
|
||||
|
||||
if (array_key_exists('updateBy', $data)) {
|
||||
$importParams['updateBy'] = $data['updateBy'];
|
||||
if (property_exists($data, 'updateBy')) {
|
||||
$importParams['updateBy'] = $data->updateBy;
|
||||
}
|
||||
|
||||
$attachmentId = $data['attachmentId'];
|
||||
$attachmentId = $data->attachmentId;
|
||||
|
||||
if (!$this->getAcl()->check($data['entityType'], 'edit')) {
|
||||
if (!$this->getAcl()->check($data->entityType, 'edit')) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
return $this->getService('Import')->import($data['entityType'], $data['fields'], $attachmentId, $importParams);
|
||||
return $this->getService('Import')->import($data->entityType, $data->fields, $attachmentId, $importParams);
|
||||
}
|
||||
|
||||
public function postActionUnmarkAsDuplicate($params, $data)
|
||||
{
|
||||
if (empty($data['id']) || empty($data['entityType']) || empty($data['entityId'])) {
|
||||
if (empty($data->id) || empty($data->entityType) || empty($data->entityId)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
$this->getService('Import')->unmarkAsDuplicate($data['id'], $data['entityType'], $data['entityId']);
|
||||
$this->getService('Import')->unmarkAsDuplicate($data->id, $data->entityType, $data->entityId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,15 +59,15 @@ class InboundEmail extends \Espo\Core\Controllers\Record
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (is_null($data['password'])) {
|
||||
$inboundEmail = $this->getEntityManager()->getEntity('InboundEmail', $data['id']);
|
||||
if (!$inboundEmail) {
|
||||
if (is_null($data->password)) {
|
||||
$inboundEmail = $this->getEntityManager()->getEntity('InboundEmail', $data->id);
|
||||
if (!$inboundEmail || !$inboundEmail->id) {
|
||||
throw new Error();
|
||||
}
|
||||
$data['password'] = $this->getContainer()->get('crypt')->decrypt($inboundEmail->get('password'));
|
||||
$data->password = $this->getContainer()->get('crypt')->decrypt($inboundEmail->get('password'));
|
||||
}
|
||||
|
||||
return $this->getRecordService()->testConnection($data);
|
||||
return $this->getRecordService()->testConnection(get_object_vars($data));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -79,7 +79,6 @@ class Integration extends \Espo\Core\Controllers\Record
|
||||
|
||||
$this->getConfig()->save();
|
||||
|
||||
|
||||
return $entity->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,4 +76,3 @@ class Job extends \Espo\Core\Controllers\Record
|
||||
throw new Forbidden();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,23 +53,23 @@ class LabelManager extends \Espo\Core\Controllers\Base
|
||||
|
||||
public function postActionGetScopeData($params, $data, $request)
|
||||
{
|
||||
if (empty($data['scope']) || empty($data['language'])) {
|
||||
if (empty($data->scope) || empty($data->language)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
$labelManager = $this->getContainer()->get('injectableFactory')->createByClassName('\\Espo\\Core\\Utils\\LabelManager');
|
||||
return $labelManager->getScopeData($data['language'], $data['scope']);
|
||||
return $labelManager->getScopeData($data->language, $data->scope);
|
||||
}
|
||||
|
||||
public function postActionSaveLabels($params, $data)
|
||||
{
|
||||
if (empty($data['scope']) || empty($data['language']) || !isset($data['labels'])) {
|
||||
if (empty($data->scope) || empty($data->language) || !isset($data->labels)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$labels = get_object_vars($data['labels']);
|
||||
$labels = get_object_vars($data->labels);
|
||||
|
||||
$labelManager = $this->getContainer()->get('injectableFactory')->createByClassName('\\Espo\\Core\\Utils\\LabelManager');
|
||||
$returnData = $labelManager->saveLabels($data['language'], $data['scope'], $labels);
|
||||
$returnData = $labelManager->saveLabels($data->language, $data->scope, $labels);
|
||||
|
||||
$this->getContainer()->get('dataManager')->clearCache();
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ class Layout extends \Espo\Core\Controllers\Base
|
||||
|
||||
public function actionUpdate($params, $data, $request)
|
||||
{
|
||||
$data = get_object_vars($data);
|
||||
|
||||
if (!$this->getUser()->isAdmin()) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
@@ -79,10 +81,10 @@ class Layout extends \Espo\Core\Controllers\Base
|
||||
if (!$request->isPost()) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
if (empty($data['scope']) || empty($data['name'])) {
|
||||
if (empty($data->scope) || empty($data->name)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
return $this->getContainer()->get('layout')->resetToDefault($data['scope'], $data['name']);
|
||||
return $this->getContainer()->get('layout')->resetToDefault($data->scope, $data->name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,11 +93,11 @@ class Preferences extends \Espo\Core\Controllers\Base
|
||||
}
|
||||
|
||||
foreach ($this->getAcl()->getScopeForbiddenAttributeList('Preferences', 'edit') as $attribute) {
|
||||
unset($data[$attribute]);
|
||||
unset($data->$attribute);
|
||||
}
|
||||
|
||||
if (array_key_exists('smtpPassword', $data)) {
|
||||
$data['smtpPassword'] = $this->getCrypt()->encrypt($data['smtpPassword']);
|
||||
if (property_exists($data, 'smtpPassword')) {
|
||||
$data->smtpPassword = $this->getCrypt()->encrypt($data->smtpPassword);
|
||||
}
|
||||
|
||||
$user = $this->getEntityManager()->getEntity('User', $userId);
|
||||
@@ -113,7 +113,7 @@ class Preferences extends \Espo\Core\Controllers\Base
|
||||
|
||||
$entity->clear('smtpPassword');
|
||||
|
||||
return $entity->toArray();
|
||||
return $entity->getValueMap();
|
||||
}
|
||||
throw new Error();
|
||||
}
|
||||
@@ -140,7 +140,7 @@ class Preferences extends \Espo\Core\Controllers\Base
|
||||
$entity->clear($attribute);
|
||||
}
|
||||
|
||||
return $entity->toArray();
|
||||
return $entity->getValueMap();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,4 +38,3 @@ class ScheduledJob extends \Espo\Core\Controllers\Record
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class Settings extends \Espo\Core\Controllers\Base
|
||||
$fieldDefs = $this->getMetadata()->get('entityDefs.Settings.fields');
|
||||
|
||||
foreach ($fieldDefs as $field => $d) {
|
||||
if ($d['type'] == 'password') {
|
||||
if ($d['type'] === 'password') {
|
||||
unset($data[$field]);
|
||||
}
|
||||
}
|
||||
@@ -77,9 +77,9 @@ class Settings extends \Espo\Core\Controllers\Base
|
||||
}
|
||||
|
||||
if (
|
||||
(isset($data['useCache']) && $data['useCache'] != $this->getConfig()->get('useCache'))
|
||||
(isset($data->useCache) && $data->useCache !== $this->getConfig()->get('useCache'))
|
||||
||
|
||||
(isset($data['aclStrictMode']) && $data['aclStrictMode'] !== $this->getConfig()->get('aclStrictMode'))
|
||||
(isset($data->aclStrictMode) && $data->aclStrictMode !== $this->getConfig()->get('aclStrictMode'))
|
||||
) {
|
||||
$this->getContainer()->get('dataManager')->clearCache();
|
||||
}
|
||||
@@ -91,8 +91,8 @@ class Settings extends \Espo\Core\Controllers\Base
|
||||
}
|
||||
|
||||
/** Rebuild for Currency Settings */
|
||||
if (isset($data['baseCurrency']) || isset($data['currencyRates'])) {
|
||||
$this->getContainer()->get('dataManager')->rebuildDatabase(array());
|
||||
if (isset($data->baseCurrency) || isset($data->currencyRates)) {
|
||||
$this->getContainer()->get('dataManager')->rebuildDatabase([]);
|
||||
}
|
||||
/** END Rebuild for Currency Settings */
|
||||
|
||||
@@ -105,10 +105,12 @@ class Settings extends \Espo\Core\Controllers\Base
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
if (!isset($data['password'])) {
|
||||
$data['password'] = $this->getConfig()->get('ldapPassword');
|
||||
if (!isset($data->password)) {
|
||||
$data->password = $this->getConfig()->get('ldapPassword');
|
||||
}
|
||||
|
||||
$data = get_object_vars($data);
|
||||
|
||||
$ldapUtils = new \Espo\Core\Utils\Authentication\LDAP\Utils();
|
||||
$options = $ldapUtils->normalizeOptions($data);
|
||||
|
||||
|
||||
@@ -31,6 +31,4 @@ namespace Espo\Controllers;
|
||||
|
||||
class Team extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -35,4 +35,3 @@ class Template extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -57,20 +57,20 @@ class User extends \Espo\Core\Controllers\Record
|
||||
|
||||
public function postActionChangeOwnPassword($params, $data, $request)
|
||||
{
|
||||
if (!array_key_exists('password', $data) || !array_key_exists('currentPassword', $data)) {
|
||||
if (!property_exists($data, 'password') || !property_exists($data, 'currentPassword')) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
return $this->getService('User')->changePassword($this->getUser()->id, $data['password'], true, $data['currentPassword']);
|
||||
return $this->getService('User')->changePassword($this->getUser()->id, $data->password, true, $data->currentPassword);
|
||||
}
|
||||
|
||||
public function postActionChangePasswordByRequest($params, $data, $request)
|
||||
{
|
||||
if (empty($data['requestId']) || empty($data['password'])) {
|
||||
if (empty($data->requestId) || empty($data->password)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$p = $this->getEntityManager()->getRepository('PasswordChangeRequest')->where(array(
|
||||
'requestId' => $data['requestId']
|
||||
'requestId' => $data->requestId
|
||||
))->findOne();
|
||||
|
||||
if (!$p) {
|
||||
@@ -83,7 +83,7 @@ class User extends \Espo\Core\Controllers\Record
|
||||
|
||||
$this->getEntityManager()->removeEntity($p);
|
||||
|
||||
if ($this->getService('User')->changePassword($userId, $data['password'])) {
|
||||
if ($this->getService('User')->changePassword($userId, $data->password)) {
|
||||
return array(
|
||||
'url' => $p->get('url')
|
||||
);
|
||||
@@ -92,15 +92,15 @@ class User extends \Espo\Core\Controllers\Record
|
||||
|
||||
public function postActionPasswordChangeRequest($params, $data, $request)
|
||||
{
|
||||
if (empty($data['userName']) || empty($data['emailAddress'])) {
|
||||
if (empty($data->userName) || empty($data->emailAddress)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$userName = $data['userName'];
|
||||
$emailAddress = $data['emailAddress'];
|
||||
$userName = $data->userName;
|
||||
$emailAddress = $data->emailAddress;
|
||||
$url = null;
|
||||
if (!empty($data['url'])) {
|
||||
$url = $data['url'];
|
||||
if (!empty($data->url)) {
|
||||
$url = $data->url;
|
||||
}
|
||||
|
||||
return $this->getService('User')->passwordChangeRequest($userName, $emailAddress, $url);
|
||||
|
||||
@@ -76,11 +76,6 @@ class ControllerManager
|
||||
$data = json_decode($data);
|
||||
}
|
||||
|
||||
|
||||
if ($data instanceof \stdClass) {
|
||||
$data = get_object_vars($data);
|
||||
}
|
||||
|
||||
if (!class_exists($controllerClassName)) {
|
||||
throw new NotFound("Controller '$controllerName' is not found");
|
||||
}
|
||||
@@ -109,6 +104,13 @@ class ControllerManager
|
||||
throw new NotFound("Action '$actionName' (".$request->getMethod().") does not exist in controller '$controllerName'");
|
||||
}
|
||||
|
||||
// TODO Remove in 5.1.0
|
||||
if ($data instanceof \stdClass) {
|
||||
if ($this->getMetadata()->get(['app', 'deprecatedControllerActions', $controllerName, $primaryActionMethodName])) {
|
||||
$data = get_object_vars($data);
|
||||
}
|
||||
}
|
||||
|
||||
if (method_exists($controller, $beforeMethodName)) {
|
||||
$controller->$beforeMethodName($params, $data, $request);
|
||||
}
|
||||
@@ -125,6 +127,4 @@ class ControllerManager
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -245,10 +245,10 @@ class Record extends Base
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$ids = isset($data['ids']) ? $data['ids'] : null;
|
||||
$where = isset($data['where']) ? json_decode(json_encode($data['where']), true) : null;
|
||||
$byWhere = isset($data['byWhere']) ? $data['byWhere'] : false;
|
||||
$selectData = isset($data['selectData']) ? json_decode(json_encode($data['selectData']), true) : null;
|
||||
$ids = isset($data->ids) ? $data->ids : null;
|
||||
$where = isset($data->where) ? json_decode(json_encode($data->where), true) : null;
|
||||
$byWhere = isset($data->byWhere) ? $data->byWhere : false;
|
||||
$selectData = isset($data->selectData) ? json_decode(json_encode($data->selectData), true) : null;
|
||||
|
||||
$params = array();
|
||||
if ($byWhere) {
|
||||
@@ -258,16 +258,16 @@ class Record extends Base
|
||||
$params['ids'] = $ids;
|
||||
}
|
||||
|
||||
if (isset($data['attributeList'])) {
|
||||
$params['attributeList'] = $data['attributeList'];
|
||||
if (isset($data->attributeList)) {
|
||||
$params['attributeList'] = $data->attributeList;
|
||||
}
|
||||
|
||||
if (isset($data['fieldList'])) {
|
||||
$params['fieldList'] = $data['fieldList'];
|
||||
if (isset($data->fieldList)) {
|
||||
$params['fieldList'] = $data->fieldList;
|
||||
}
|
||||
|
||||
if (isset($data['format'])) {
|
||||
$params['format'] = $data['format'];
|
||||
if (isset($data->format)) {
|
||||
$params['format'] = $data->format;
|
||||
}
|
||||
|
||||
return array(
|
||||
@@ -284,21 +284,21 @@ class Record extends Base
|
||||
if (!$this->getAcl()->check($this->name, 'edit')) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
if (empty($data['attributes'])) {
|
||||
if (empty($data->attributes)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$params = array();
|
||||
if (array_key_exists('where', $data) && !empty($data['byWhere'])) {
|
||||
$params['where'] = json_decode(json_encode($data['where']), true);
|
||||
if (array_key_exists('selectData', $data)) {
|
||||
$params['selectData'] = json_decode(json_encode($data['selectData']), true);
|
||||
if (property_exists($data, 'where') && !empty($data->byWhere)) {
|
||||
$params['where'] = json_decode(json_encode($data->where), true);
|
||||
if (property_exists($data, 'selectData')) {
|
||||
$params['selectData'] = json_decode(json_encode($data->selectData), true);
|
||||
}
|
||||
} else if (array_key_exists('ids', $data)) {
|
||||
$params['ids'] = $data['ids'];
|
||||
} else if (property_exists($data, 'ids')) {
|
||||
$params['ids'] = $data->ids;
|
||||
}
|
||||
|
||||
$attributes = $data['attributes'];
|
||||
$attributes = $data->attributes;
|
||||
|
||||
$idsUpdated = $this->getRecordService()->massUpdate($attributes, $params);
|
||||
|
||||
@@ -315,15 +315,15 @@ class Record extends Base
|
||||
}
|
||||
|
||||
$params = array();
|
||||
if (array_key_exists('where', $data) && !empty($data['byWhere'])) {
|
||||
$where = json_decode(json_encode($data['where']), true);
|
||||
if (property_exists($data, 'where') && !empty($data->byWhere)) {
|
||||
$where = json_decode(json_encode($data->where), true);
|
||||
$params['where'] = $where;
|
||||
if (array_key_exists('selectData', $data)) {
|
||||
$params['selectData'] = json_decode(json_encode($data['selectData']), true);
|
||||
if (property_exists($data, 'selectData')) {
|
||||
$params['selectData'] = json_decode(json_encode($data->selectData), true);
|
||||
}
|
||||
}
|
||||
if (array_key_exists('ids', $data)) {
|
||||
$params['ids'] = $data['ids'];
|
||||
if (property_exists($data, 'ids')) {
|
||||
$params['ids'] = $data->ids;
|
||||
}
|
||||
|
||||
return $this->getRecordService()->massRemove($params);
|
||||
@@ -342,25 +342,25 @@ class Record extends Base
|
||||
$id = $params['id'];
|
||||
$link = $params['link'];
|
||||
|
||||
if (!empty($data['massRelate'])) {
|
||||
if (!is_array($data['where'])) {
|
||||
if (!empty($data->massRelate)) {
|
||||
if (!is_array($data->where)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
$where = json_decode(json_encode($data['where']), true);
|
||||
$where = json_decode(json_encode($data->where), true);
|
||||
|
||||
$selectData = null;
|
||||
if (isset($data['selectData']) && is_array($data['selectData'])) {
|
||||
$selectData = json_decode(json_encode($data['selectData']), true);
|
||||
if (isset($data->selectData) && is_array($data->selectData)) {
|
||||
$selectData = json_decode(json_encode($data->selectData), true);
|
||||
}
|
||||
|
||||
return $this->getRecordService()->linkEntityMass($id, $link, $where, $selectData);
|
||||
} else {
|
||||
$foreignIdList = array();
|
||||
if (isset($data['id'])) {
|
||||
$foreignIdList[] = $data['id'];
|
||||
if (isset($data->id)) {
|
||||
$foreignIdList[] = $data->id;
|
||||
}
|
||||
if (isset($data['ids']) && is_array($data['ids'])) {
|
||||
foreach ($data['ids'] as $foreignId) {
|
||||
if (isset($data->ids) && is_array($data->ids)) {
|
||||
foreach ($data->ids as $foreignId) {
|
||||
$foreignIdList[] = $foreignId;
|
||||
}
|
||||
}
|
||||
@@ -392,18 +392,18 @@ class Record extends Base
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$foreignIds = array();
|
||||
if (isset($data['id'])) {
|
||||
$foreignIds[] = $data['id'];
|
||||
$foreignIdList = [];
|
||||
if (isset($data->id)) {
|
||||
$foreignIdList[] = $data->id;
|
||||
}
|
||||
if (isset($data['ids']) && is_array($data['ids'])) {
|
||||
foreach ($data['ids'] as $foreignId) {
|
||||
$foreignIds[] = $foreignId;
|
||||
if (isset($data->ids) && is_array($data->ids)) {
|
||||
foreach ($data->ids as $foreignId) {
|
||||
$foreignIdList[] = $foreignId;
|
||||
}
|
||||
}
|
||||
|
||||
$result = false;
|
||||
foreach ($foreignIds as $foreignId) {
|
||||
foreach ($foreignIdList as $foreignId) {
|
||||
if ($this->getRecordService()->unlinkEntity($id, $link, $foreignId)) {
|
||||
$result = $result || true;
|
||||
}
|
||||
@@ -445,12 +445,12 @@ class Record extends Base
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (empty($data['targetId']) || empty($data['sourceIds']) || !is_array($data['sourceIds']) || !($data['attributes'] instanceof \StdClass)) {
|
||||
if (empty($data->targetId) || empty($data->sourceIds) || !is_array($data->sourceIds) || !($data->attributes instanceof \StdClass)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
$targetId = $data['targetId'];
|
||||
$sourceIds = $data['sourceIds'];
|
||||
$attributes = get_object_vars($data['attributes']);
|
||||
$targetId = $data->targetId;
|
||||
$sourceIds = $data->sourceIds;
|
||||
$attributes = get_object_vars($data->attributes);
|
||||
|
||||
if (!$this->getAcl()->check($this->name, 'edit')) {
|
||||
throw new Forbidden();
|
||||
@@ -461,7 +461,7 @@ class Record extends Base
|
||||
|
||||
public function postActionGetDuplicateAttributes($params, $data, $request)
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
@@ -472,7 +472,7 @@ class Record extends Base
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
return $this->getRecordService()->getDuplicateAttributes($data['id']);
|
||||
return $this->getRecordService()->getDuplicateAttributes($data->id);
|
||||
}
|
||||
|
||||
public function postActionMassFollow($params, $data, $request)
|
||||
@@ -481,8 +481,8 @@ class Record extends Base
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
if (array_key_exists('ids', $data)) {
|
||||
$params['ids'] = $data['ids'];
|
||||
if (property_exists($data, 'ids')) {
|
||||
$params['ids'] = $data->ids;
|
||||
}
|
||||
|
||||
return $this->getRecordService()->massFollow($params);
|
||||
@@ -494,11 +494,10 @@ class Record extends Base
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
if (array_key_exists('ids', $data)) {
|
||||
$params['ids'] = $data['ids'];
|
||||
if (property_exists($data, 'ids')) {
|
||||
$params['ids'] = $data->ids;
|
||||
}
|
||||
|
||||
return $this->getRecordService()->massUnfollow($params);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ use \Espo\ORM\Entity;
|
||||
|
||||
class Company extends \Espo\Services\Record
|
||||
{
|
||||
protected function getDuplicateWhereClause(Entity $entity, $data = array())
|
||||
protected function getDuplicateWhereClause(Entity $entity, $data)
|
||||
{
|
||||
return array(
|
||||
'name' => $entity->get('name')
|
||||
|
||||
@@ -33,7 +33,7 @@ use \Espo\ORM\Entity;
|
||||
|
||||
class Person extends \Espo\Services\Record
|
||||
{
|
||||
protected function getDuplicateWhereClause(Entity $entity, $data = array())
|
||||
protected function getDuplicateWhereClause(Entity $entity, $data)
|
||||
{
|
||||
$data = array(
|
||||
'OR' => []
|
||||
|
||||
@@ -126,6 +126,10 @@ class Config
|
||||
*/
|
||||
public function set($name, $value = null, $dontMarkDirty = false)
|
||||
{
|
||||
if (is_object($name)) {
|
||||
$name = get_object_vars($name);
|
||||
}
|
||||
|
||||
if (!is_array($name)) {
|
||||
$name = array($name => $value);
|
||||
}
|
||||
@@ -251,6 +255,10 @@ class Config
|
||||
{
|
||||
$restrictItems = $this->getRestrictItems($isAdmin);
|
||||
|
||||
if (is_object($data)) {
|
||||
$data = get_object_vars($data);
|
||||
}
|
||||
|
||||
$values = array();
|
||||
foreach ($data as $key => $item) {
|
||||
if (!in_array($key, $restrictItems)) {
|
||||
@@ -326,5 +334,3 @@ class Config
|
||||
return rtrim($this->get('siteUrl'), '/');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -25,11 +25,10 @@
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Entities;
|
||||
|
||||
class ExternalAccount extends Integration
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,10 @@ class Integration extends \Espo\Core\ORM\Entity
|
||||
|
||||
public function set($p1, $p2 = null)
|
||||
{
|
||||
if (is_object($p1)) {
|
||||
$p1 = get_object_vars($p1);
|
||||
}
|
||||
|
||||
if (is_array($p1)) {
|
||||
if ($p2 === null) {
|
||||
$p2 = false;
|
||||
@@ -140,7 +144,6 @@ class Integration extends \Espo\Core\ORM\Entity
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->set($field, $value);
|
||||
}
|
||||
}
|
||||
@@ -175,5 +178,10 @@ class Integration extends \Espo\Core\ORM\Entity
|
||||
return $arr;
|
||||
}
|
||||
|
||||
}
|
||||
public function getValueMap()
|
||||
{
|
||||
$arr = $this->toArray();
|
||||
|
||||
return (object) $arr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,4 +82,3 @@ class Note extends \Espo\Core\ORM\Entity
|
||||
return in_array($userId, $userIdList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class PhoneNumber extends \Espo\Core\ORM\Entity
|
||||
if (empty($value)) {
|
||||
throw new Error("Phone number can't be empty");
|
||||
}
|
||||
$this->valuesContainer['name'] = $value;
|
||||
$this->valuesContainer['name'] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ namespace Espo\Entities;
|
||||
|
||||
class Preferences extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
|
||||
public function getSmtpParams()
|
||||
{
|
||||
$smtpParams = array();
|
||||
@@ -49,4 +48,3 @@ class Preferences extends \Espo\Core\ORM\Entity
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,5 @@ namespace Espo\Entities;
|
||||
|
||||
class Team extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -127,10 +127,10 @@ class Activities extends \Espo\Core\Controllers\Base
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
$id = $data['id'];
|
||||
$id = $data->id;
|
||||
|
||||
return $this->getService('Activities')->removeReminder($id);
|
||||
}
|
||||
|
||||
@@ -38,11 +38,11 @@ class Call extends \Espo\Core\Controllers\Record
|
||||
|
||||
public function postActionSendInvitations($params, $data)
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$entity = $this->getRecordService()->getEntity($data['id']);
|
||||
$entity = $this->getRecordService()->getEntity($data->id);
|
||||
|
||||
if (!$entity) {
|
||||
throw new NotFound();
|
||||
@@ -61,20 +61,19 @@ class Call extends \Espo\Core\Controllers\Record
|
||||
|
||||
public function postActionMassSetHeld($params, $data)
|
||||
{
|
||||
if (empty($data['ids']) && !is_array($data['ids'])) {
|
||||
if (empty($data->ids) && !is_array($data->ids)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
return $this->getRecordService()->massSetHeld($data['ids']);
|
||||
return $this->getRecordService()->massSetHeld($data->ids);
|
||||
}
|
||||
|
||||
public function postActionMassSetNotHeld($params, $data)
|
||||
{
|
||||
if (empty($data['ids']) && !is_array($data['ids'])) {
|
||||
if (empty($data->ids) && !is_array($data->ids)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
return $this->getRecordService()->massSetNotHeld($data['ids']);
|
||||
return $this->getRecordService()->massSetNotHeld($data->ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,20 +35,19 @@ use \Espo\Core\Exceptions\BadRequest;
|
||||
|
||||
class Document extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
|
||||
public function postActionGetAttachmentList($params, $data)
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$id = $data['id'];
|
||||
$id = $data->id;
|
||||
|
||||
if (!$this->getAcl()->checkScope('Attachment', 'create')) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
return $this->getRecordService()->getAttachmentList($id)->toArray();
|
||||
return $this->getRecordService()->getAttachmentList($id)->getValueMapList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,74 +33,74 @@ class KnowledgeBaseArticle extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
public function postActionGetCopiedAttachments($params, $data, $request)
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
$id = $data['id'];
|
||||
$id = $data->id;
|
||||
|
||||
return $this->getRecordService()->getCopiedAttachments($id);
|
||||
}
|
||||
|
||||
public function postActionMoveToTop($params, $data, $request)
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
$where = null;
|
||||
if (!empty($data['where'])) {
|
||||
$where = $data['where'];
|
||||
if (!empty($data->where)) {
|
||||
$where = $data->where;
|
||||
$where = json_decode(json_encode($where), true);
|
||||
}
|
||||
|
||||
$this->getRecordService()->moveToTop($data['id'], $where);
|
||||
$this->getRecordService()->moveToTop($data->id, $where);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function postActionMoveUp($params, $data, $request)
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
$where = null;
|
||||
if (!empty($data['where'])) {
|
||||
$where = $data['where'];
|
||||
if (!empty($data->where)) {
|
||||
$where = $data->where;
|
||||
$where = json_decode(json_encode($where), true);
|
||||
}
|
||||
|
||||
$this->getRecordService()->moveUp($data['id'], $where);
|
||||
$this->getRecordService()->moveUp($data->id, $where);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function postActionMoveDown($params, $data, $request)
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
$where = null;
|
||||
if (!empty($data['where'])) {
|
||||
$where = $data['where'];
|
||||
if (!empty($data->where)) {
|
||||
$where = $data->where;
|
||||
$where = json_decode(json_encode($where), true);
|
||||
}
|
||||
|
||||
$this->getRecordService()->moveDown($data['id'], $where);
|
||||
$this->getRecordService()->moveDown($data->id, $where);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function postActionMoveToBottom($params, $data, $request)
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
$where = null;
|
||||
if (!empty($data['where'])) {
|
||||
$where = $data['where'];
|
||||
if (!empty($data->where)) {
|
||||
$where = $data->where;
|
||||
$where = json_decode(json_encode($where), true);
|
||||
}
|
||||
|
||||
$this->getRecordService()->moveToBottom($data['id'], $where);
|
||||
$this->getRecordService()->moveToBottom($data->id, $where);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -36,10 +36,13 @@ class Lead extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
public function postActionConvert($params, $data, $request)
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
$entity = $this->getRecordService()->convert($data['id'], $data['records']);
|
||||
if (empty($data->records)) {
|
||||
$data->records = (object) [];
|
||||
}
|
||||
$entity = $this->getRecordService()->convert($data->id, $data->records);
|
||||
|
||||
if (!empty($entity)) {
|
||||
return $entity->toArray();
|
||||
@@ -49,10 +52,10 @@ class Lead extends \Espo\Core\Controllers\Record
|
||||
|
||||
public function postActionGetConvertAttributes($params, $data, $request)
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
return $this->getRecordService()->getConvertAttributes($data['id']);
|
||||
return $this->getRecordService()->getConvertAttributes($data->id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,14 +37,14 @@ class MassEmail extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
public function postActionSendTest($params, $data)
|
||||
{
|
||||
if (empty($data['id']) || empty($data['targetList']) || !is_array($data['targetList'])) {
|
||||
if (empty($data->id) || empty($data->targetList) || !is_array($data->targetList)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$id = $data['id'];
|
||||
$id = $data->id;
|
||||
|
||||
$targetList = [];
|
||||
foreach ($data['targetList'] as $item) {
|
||||
foreach ($data->targetList as $item) {
|
||||
if (empty($item->id) || empty($item->type)) continue;
|
||||
$targetId = $item->id;
|
||||
$targetType = $item->type;
|
||||
|
||||
@@ -38,11 +38,11 @@ class Meeting extends \Espo\Core\Controllers\Record
|
||||
|
||||
public function postActionSendInvitations($params, $data)
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$entity = $this->getRecordService()->getEntity($data['id']);
|
||||
$entity = $this->getRecordService()->getEntity($data->id);
|
||||
|
||||
if (!$entity) {
|
||||
throw new NotFound();
|
||||
@@ -61,20 +61,19 @@ class Meeting extends \Espo\Core\Controllers\Record
|
||||
|
||||
public function postActionMassSetHeld($params, $data)
|
||||
{
|
||||
if (empty($data['ids']) && !is_array($data['ids'])) {
|
||||
if (empty($data->ids) && !is_array($data->ids)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
return $this->getRecordService()->massSetHeld($data['ids']);
|
||||
return $this->getRecordService()->massSetHeld($data->ids);
|
||||
}
|
||||
|
||||
public function postActionMassSetNotHeld($params, $data)
|
||||
{
|
||||
if (empty($data['ids']) && !is_array($data['ids'])) {
|
||||
if (empty($data->ids) && !is_array($data->ids)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
return $this->getRecordService()->massSetNotHeld($data['ids']);
|
||||
return $this->getRecordService()->massSetNotHeld($data->ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,28 +25,26 @@
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
use \Espo\Core\Exceptions\BadRequest;
|
||||
|
||||
|
||||
class Target extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
|
||||
|
||||
public function actionConvert($params, $data)
|
||||
{
|
||||
|
||||
if (empty($data['id'])) {
|
||||
{
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
$entity = $this->getRecordService()->convert($data['id']);
|
||||
|
||||
if (!empty($entity)) {
|
||||
return $entity->toArray();
|
||||
}
|
||||
throw new Error();
|
||||
}
|
||||
$entity = $this->getRecordService()->convert($data->id);
|
||||
|
||||
if (!empty($entity)) {
|
||||
return $entity->getValueMap();
|
||||
}
|
||||
throw new Error();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,43 +41,42 @@ class TargetList extends \Espo\Core\Controllers\Record
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (empty($data['link'])) {
|
||||
if (empty($data->link)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
return $this->getRecordService()->unlinkAll($data['id'], $data['link']);
|
||||
return $this->getRecordService()->unlinkAll($data->id, $data->link);
|
||||
}
|
||||
|
||||
public function postActionOptOut($params, $data)
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
if (empty($data['targetType'])) {
|
||||
if (empty($data->targetType)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
if (empty($data['targetId'])) {
|
||||
if (empty($data->targetId)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
return $this->getRecordService()->optOut($data['id'], $data['targetType'], $data['targetId']);
|
||||
return $this->getRecordService()->optOut($data->id, $data->targetType, $data->targetId);
|
||||
}
|
||||
|
||||
public function postActionCancelOptOut($params, $data)
|
||||
{
|
||||
if (empty($data['id'])) {
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
if (empty($data['targetType'])) {
|
||||
if (empty($data->targetType)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
if (empty($data['targetId'])) {
|
||||
if (empty($data->targetId)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
return $this->getRecordService()->cancelOptOut($data['id'], $data['targetType'], $data['targetId']);
|
||||
return $this->getRecordService()->cancelOptOut($data->id, $data->targetType, $data->targetId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ class Account extends \Espo\Services\Record
|
||||
)
|
||||
);
|
||||
|
||||
protected function getDuplicateWhereClause(Entity $entity, $data = array())
|
||||
protected function getDuplicateWhereClause(Entity $entity, $data)
|
||||
{
|
||||
if (!$entity->get('name')) {
|
||||
return false;
|
||||
|
||||
@@ -34,12 +34,11 @@ use \Espo\ORM\Entity;
|
||||
|
||||
class CampaignTrackingUrl extends \Espo\Services\Record
|
||||
{
|
||||
protected function beforeCreate(Entity $entity, array $data = array())
|
||||
protected function beforeCreateEntity(Entity $entity, $data)
|
||||
{
|
||||
parent::beforeCreate($entity, $data);
|
||||
parent::beforeCreateEntity($entity, $data);
|
||||
if (!$this->getAcl()->check($entity, 'edit')) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,9 +48,9 @@ class CaseObj extends \Espo\Services\Record
|
||||
'articles'
|
||||
];
|
||||
|
||||
public function beforeCreate(Entity $entity, array $data = array())
|
||||
public function beforeCreateEntity(Entity $entity, $data)
|
||||
{
|
||||
parent::beforeCreate($entity, $data);
|
||||
parent::beforeCreateEntity($entity, $data);
|
||||
|
||||
if ($this->getUser()->isPortal()) {
|
||||
if (!$entity->has('accountId')) {
|
||||
@@ -69,11 +69,11 @@ class CaseObj extends \Espo\Services\Record
|
||||
}
|
||||
}
|
||||
|
||||
public function afterCreate(Entity $entity, array $data = array())
|
||||
public function afterCreateEntity(Entity $entity, $data)
|
||||
{
|
||||
parent::afterCreate($entity, $data);
|
||||
if (!empty($data['emailId'])) {
|
||||
$email = $this->getEntityManager()->getEntity('Email', $data['emailId']);
|
||||
parent::afterCreateEntity($entity, $data);
|
||||
if (!empty($data->emailId)) {
|
||||
$email = $this->getEntityManager()->getEntity('Email', $data->emailId);
|
||||
if ($email && !$email->get('parentId')) {
|
||||
$email->set(array(
|
||||
'parentType' => 'Case',
|
||||
@@ -83,6 +83,5 @@ class CaseObj extends \Espo\Services\Record
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -62,17 +62,17 @@ class MassEmail extends \Espo\Services\Record
|
||||
return $this->getInjection('language');
|
||||
}
|
||||
|
||||
protected function beforeCreate(Entity $entity, array $data = array())
|
||||
protected function beforeCreateEntity(Entity $entity, $data)
|
||||
{
|
||||
parent::beforeCreate($entity, $data);
|
||||
parent::beforeCreateEntity($entity, $data);
|
||||
if (!$this->getAcl()->check($entity, 'edit')) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
}
|
||||
|
||||
protected function afterRemove(Entity $massEmail, array $data = array())
|
||||
protected function afterDeleteEntity(Entity $massEmail)
|
||||
{
|
||||
parent::afterRemove($massEmail, $data);
|
||||
parent::afterDeleteEntity($massEmail);
|
||||
$existingQueueItemList = $this->getEntityManager()->getRepository('EmailQueueItem')->where(array(
|
||||
'status' => ['Pending', 'Failed'],
|
||||
'massEmailId' => $massEmail->id
|
||||
|
||||
@@ -35,7 +35,7 @@ use \Espo\ORM\Entity;
|
||||
|
||||
class Target extends \Espo\Services\Record
|
||||
{
|
||||
protected function getDuplicateWhereClause(Entity $entity, $data = array())
|
||||
protected function getDuplicateWhereClause(Entity $entity, $data)
|
||||
{
|
||||
$data = array(
|
||||
'OR' => array(
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"BpmnProcess": {
|
||||
"postActionStop": true
|
||||
},
|
||||
"GoogleContacts": {
|
||||
"actionPush": true
|
||||
},
|
||||
"MailChimp": {
|
||||
"actionUpdate": true
|
||||
},
|
||||
"MailChimpCampaign": {
|
||||
"actionCreate": true
|
||||
},
|
||||
"MailChimpList": {
|
||||
"actionCreate": true
|
||||
},
|
||||
"MailChimpListGroup": {
|
||||
"actionCreate": true
|
||||
},
|
||||
"Quote": {
|
||||
"postActionGetAttributesForEmail": true
|
||||
},
|
||||
"Report": {
|
||||
"actionPopulateTargetList": true,
|
||||
"actionSyncTargetListWithReports": true,
|
||||
"postActionExportList": true,
|
||||
"postActionGetEmailAttributes": true
|
||||
}
|
||||
}
|
||||
@@ -66,29 +66,29 @@ class Attachment extends Record
|
||||
|
||||
public function createEntity($data)
|
||||
{
|
||||
if (!empty($data['file'])) {
|
||||
$arr = explode(',', $data['file']);
|
||||
if (!empty($data->file)) {
|
||||
$arr = explode(',', $data->file);
|
||||
$contents = '';
|
||||
if (count($arr) > 1) {
|
||||
$contents = $arr[1];
|
||||
}
|
||||
|
||||
$contents = base64_decode($contents);
|
||||
$data['contents'] = $contents;
|
||||
$data->contents = $contents;
|
||||
|
||||
$relatedEntityType = null;
|
||||
$field = null;
|
||||
$role = 'Attachment';
|
||||
if (isset($data['parentType'])) {
|
||||
$relatedEntityType = $data['parentType'];
|
||||
} else if (isset($data['relatedType'])) {
|
||||
$relatedEntityType = $data['relatedType'];
|
||||
if (isset($data->parentType)) {
|
||||
$relatedEntityType = $data->parentType;
|
||||
} else if (isset($data->relatedType)) {
|
||||
$relatedEntityType = $data->relatedType;
|
||||
}
|
||||
if (isset($data['field'])) {
|
||||
$field = $data['field'];
|
||||
if (isset($data->field)) {
|
||||
$field = $data->field;
|
||||
}
|
||||
if (isset($data['role'])) {
|
||||
$role = $data['role'];
|
||||
if (isset($data->role)) {
|
||||
$role = $data->role;
|
||||
}
|
||||
if (!$relatedEntityType || !$field) {
|
||||
throw new BadRequest("Params 'field' and 'parentType' not passed along with 'file'.");
|
||||
@@ -144,14 +144,14 @@ class Attachment extends Record
|
||||
|
||||
$entity = parent::createEntity($data);
|
||||
|
||||
if (!empty($data['file'])) {
|
||||
if (!empty($data->file)) {
|
||||
$entity->clear('contents');
|
||||
}
|
||||
|
||||
return $entity;
|
||||
}
|
||||
|
||||
protected function beforeCreate(Entity $entity, array $data = array())
|
||||
protected function beforeCreateEntity(Entity $entity, $data)
|
||||
{
|
||||
$storage = $entity->get('storage');
|
||||
if ($storage && !$this->getMetadata()->get(['app', 'fileStorage', 'implementationClassNameMap', $storage])) {
|
||||
@@ -159,7 +159,7 @@ class Attachment extends Record
|
||||
}
|
||||
}
|
||||
|
||||
protected function beforeUpdate(Entity $entity, array $data = array())
|
||||
protected function beforeUpdateEntity(Entity $entity, $data)
|
||||
{
|
||||
$storage = $entity->get('storage');
|
||||
if ($storage && !$this->getMetadata()->get(['app', 'fileStorage', 'implementationClassNameMap', $storage])) {
|
||||
|
||||
@@ -37,7 +37,6 @@ use \Espo\Core\Exceptions\Forbidden;
|
||||
use \Espo\Core\Exceptions\NotFound;
|
||||
use \Espo\Core\Exceptions\BadRequest;
|
||||
|
||||
|
||||
class Email extends Record
|
||||
{
|
||||
protected function init()
|
||||
@@ -238,7 +237,7 @@ class Email extends Record
|
||||
return $entity;
|
||||
}
|
||||
|
||||
protected function beforeCreate(Entity $entity, array $data = array())
|
||||
protected function beforeCreateEntity(Entity $entity, $data)
|
||||
{
|
||||
if ($entity->get('status') == 'Sending') {
|
||||
$messageId = \Espo\Core\Mail\Sender::generateMessageId($entity);
|
||||
@@ -246,7 +245,7 @@ class Email extends Record
|
||||
}
|
||||
}
|
||||
|
||||
protected function afterUpdate(Entity $entity, array $data = array())
|
||||
protected function afterUpdateEntity(Entity $entity, $data)
|
||||
{
|
||||
if ($entity && $entity->get('status') == 'Sending') {
|
||||
$this->send($entity);
|
||||
@@ -716,7 +715,7 @@ class Email extends Record
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function beforeUpdate(Entity $entity, array $data = array())
|
||||
protected function beforeUpdateEntity(Entity $entity, $data)
|
||||
{
|
||||
$skipFilter = false;
|
||||
|
||||
@@ -782,4 +781,3 @@ class Email extends Record
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,14 +54,14 @@ class EmailAccount extends Record
|
||||
return $this->getInjection('crypt');
|
||||
}
|
||||
|
||||
protected function handleInput(&$data)
|
||||
protected function handleInput($data)
|
||||
{
|
||||
parent::handleInput($data);
|
||||
if (array_key_exists('password', $data)) {
|
||||
$data['password'] = $this->getCrypt()->encrypt($data['password']);
|
||||
if (property_exists($data, 'password')) {
|
||||
$data->password = $this->getCrypt()->encrypt($data->password);
|
||||
}
|
||||
if (array_key_exists('smtpPassword', $data)) {
|
||||
$data['smtpPassword'] = $this->getCrypt()->encrypt($data['smtpPassword']);
|
||||
if (property_exists($data, 'smtpPassword')) {
|
||||
$data->smtpPassword = $this->getCrypt()->encrypt($data->smtpPassword);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,13 +35,11 @@ use \Espo\Core\Exceptions\Forbidden;
|
||||
|
||||
class EmailFilter extends Record
|
||||
{
|
||||
|
||||
protected function beforeCreate(Entity $entity, array $data = array())
|
||||
protected function beforeCreateEntity(Entity $entity, $data)
|
||||
{
|
||||
parent::beforeCreate($entity, $data);
|
||||
parent::beforeCreateEntity($entity, $data);
|
||||
if (!$this->getAcl()->check($entity, 'edit')) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,9 +47,9 @@ class EmailFolder extends Record
|
||||
$this->addDependency('language');
|
||||
}
|
||||
|
||||
protected function beforeCreate(Entity $entity, array $data = array())
|
||||
protected function beforeCreateEntity(Entity $entity, $data)
|
||||
{
|
||||
parent::beforeCreate($entity, $data);
|
||||
parent::beforeCreateEntity($entity, $data);
|
||||
|
||||
if (!$this->getUser()->isAdmin() || !$entity->get('assignedUserId')) {
|
||||
$entity->set('assignedUserId', $this->getUser()->id);
|
||||
|
||||
@@ -88,14 +88,14 @@ class InboundEmail extends \Espo\Services\Record
|
||||
return $this->getInjection('crypt');
|
||||
}
|
||||
|
||||
protected function handleInput(&$data)
|
||||
protected function handleInput($data)
|
||||
{
|
||||
parent::handleInput($data);
|
||||
if (array_key_exists('password', $data)) {
|
||||
$data['password'] = $this->getCrypt()->encrypt($data['password']);
|
||||
if (property_exists($data, 'password')) {
|
||||
$data->password = $this->getCrypt()->encrypt($data->password);
|
||||
}
|
||||
if (array_key_exists('smtpPassword', $data)) {
|
||||
$data['smtpPassword'] = $this->getCrypt()->encrypt($data['smtpPassword']);
|
||||
if (property_exists($data, 'smtpPassword')) {
|
||||
$data->smtpPassword = $this->getCrypt()->encrypt($data->smtpPassword);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,8 +48,8 @@ class Note extends Record
|
||||
|
||||
public function createEntity($data)
|
||||
{
|
||||
if (!empty($data['parentType']) && !empty($data['parentId'])) {
|
||||
$entity = $this->getEntityManager()->getEntity($data['parentType'], $data['parentId']);
|
||||
if (!empty($data->parentType) && !empty($data->parentId)) {
|
||||
$entity = $this->getEntityManager()->getEntity($data->parentType, $data->parentId);
|
||||
if ($entity) {
|
||||
if (!$this->getAcl()->check($entity, 'read')) {
|
||||
throw new Forbidden();
|
||||
@@ -60,9 +60,9 @@ class Note extends Record
|
||||
return parent::createEntity($data);
|
||||
}
|
||||
|
||||
protected function afterCreate(Entity $entity, array $data = array())
|
||||
protected function afterCreateEntity(iEntity $entity, $data)
|
||||
{
|
||||
parent::afterCreate($entity, $data);
|
||||
parent::afterCreateEntity($entity, $data);
|
||||
|
||||
if ($entity->get('type') === 'Post' && $entity->get('parentType') && $entity->get('parentType')) {
|
||||
$preferences = $this->getEntityManager()->getEntity('Preferences', $this->getUser()->id);
|
||||
@@ -77,9 +77,9 @@ class Note extends Record
|
||||
}
|
||||
}
|
||||
|
||||
protected function beforeCreate(Entity $entity, array $data = array())
|
||||
protected function beforeCreateEntity(Entity $entity, $data)
|
||||
{
|
||||
parent::beforeUpdate($entity, $data);
|
||||
parent::beforeCreateEntity($entity, $data);
|
||||
$targetType = $entity->get('targetType');
|
||||
|
||||
$entity->clear('isGlobal');
|
||||
@@ -113,9 +113,10 @@ class Note extends Record
|
||||
}
|
||||
}
|
||||
|
||||
protected function beforeUpdate(Entity $entity, array $data = array())
|
||||
protected function beforeUpdateEntity(Entity $entity, $data)
|
||||
{
|
||||
parent::beforeUpdate($entity, $data);
|
||||
parent::beforeUpdateEntity($entity, $data);
|
||||
|
||||
$entity->clear('targetType');
|
||||
$entity->clear('usersIds');
|
||||
$entity->clear('teamsIds');
|
||||
@@ -123,7 +124,6 @@ class Note extends Record
|
||||
$entity->clear('isGlobal');
|
||||
}
|
||||
|
||||
|
||||
public function checkAssignment(Entity $entity)
|
||||
{
|
||||
if ($entity->isNew()) {
|
||||
@@ -203,7 +203,6 @@ class Note extends Record
|
||||
return parant::linkEntity($id, $link, $foreignId);
|
||||
}
|
||||
|
||||
|
||||
public function unlinkEntity($id, $link, $foreignId)
|
||||
{
|
||||
if ($link === 'teams' || $link === 'users') {
|
||||
@@ -211,6 +210,4 @@ class Note extends Record
|
||||
}
|
||||
return parant::unlinkEntity($id, $link, $foreignId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -501,40 +501,40 @@ class Record extends \Espo\Core\Services\Base
|
||||
return $value;
|
||||
}
|
||||
|
||||
protected function filterInput(&$data)
|
||||
protected function filterInput($data)
|
||||
{
|
||||
foreach ($this->readOnlyAttributeList as $attribute) {
|
||||
unset($data[$attribute]);
|
||||
unset($data->$attribute);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if (is_array($data[$key])) {
|
||||
foreach ($data[$key] as $i => $v) {
|
||||
$data[$key][$i] = $this->filterInputAttribute($i, $data[$key][$i]);
|
||||
if (is_array($data->$key)) {
|
||||
foreach ($data->$key as $i => $v) {
|
||||
$data->$key[$i] = $this->filterInputAttribute($i, $data->$key[$i]);
|
||||
}
|
||||
} else if ($data[$key] instanceof \stdClass) {
|
||||
$propertyList = get_object_vars($data[$key]);
|
||||
} else if ($data->$key instanceof \stdClass) {
|
||||
$propertyList = get_object_vars($data->$key);
|
||||
foreach ($propertyList as $property => $value) {
|
||||
$data[$key]->$property = $this->filterInputAttribute($property, $data[$key]->$property);
|
||||
$data->$key->$property = $this->filterInputAttribute($property, $data->$key->$property);
|
||||
}
|
||||
} else {
|
||||
$data[$key] = $this->filterInputAttribute($key, $data[$key]);
|
||||
$data->$key = $this->filterInputAttribute($key, $data->$key);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getAcl()->getScopeForbiddenAttributeList($this->entityType, 'edit') as $attribute) {
|
||||
unset($data[$attribute]);
|
||||
unset($data->$attribute);
|
||||
}
|
||||
}
|
||||
|
||||
protected function handleInput(&$data)
|
||||
protected function handleInput($data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected function processDuplicateCheck(Entity $entity, $data)
|
||||
{
|
||||
if (empty($data['forceDuplicate'])) {
|
||||
if (empty($data->forceDuplicate)) {
|
||||
$duplicates = $this->checkEntityForDuplicate($entity, $data);
|
||||
if (!empty($duplicates)) {
|
||||
$reason = array(
|
||||
@@ -557,12 +557,12 @@ class Record extends \Espo\Core\Services\Base
|
||||
$this->filterInput($data);
|
||||
$this->handleInput($data);
|
||||
|
||||
unset($data['modifiedById']);
|
||||
unset($data['modifiedByName']);
|
||||
unset($data['modifiedAt']);
|
||||
unset($data['createdById']);
|
||||
unset($data['createdByName']);
|
||||
unset($data['createdAt']);
|
||||
unset($data->modifiedById);
|
||||
unset($data->modifiedByName);
|
||||
unset($data->modifiedAt);
|
||||
unset($data->createdById);
|
||||
unset($data->createdByName);
|
||||
unset($data->createdAt);
|
||||
|
||||
$entity->set($data);
|
||||
|
||||
@@ -570,7 +570,7 @@ class Record extends \Espo\Core\Services\Base
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$this->beforeCreate($entity, $data);
|
||||
$this->beforeCreateEntity($entity, $data);
|
||||
|
||||
if (!$this->isValid($entity)) {
|
||||
throw new BadRequest();
|
||||
@@ -583,7 +583,7 @@ class Record extends \Espo\Core\Services\Base
|
||||
$this->processDuplicateCheck($entity, $data);
|
||||
|
||||
if ($this->storeEntity($entity)) {
|
||||
$this->afterCreate($entity, $data);
|
||||
$this->afterCreateEntity($entity, $data);
|
||||
$this->afterCreateProcessDuplicating($entity, $data);
|
||||
$this->prepareEntityForOutput($entity);
|
||||
|
||||
@@ -597,7 +597,7 @@ class Record extends \Espo\Core\Services\Base
|
||||
|
||||
public function updateEntity($id, $data)
|
||||
{
|
||||
unset($data['deleted']);
|
||||
unset($data->deleted);
|
||||
|
||||
if (empty($id)) {
|
||||
throw BadRequest();
|
||||
@@ -606,12 +606,12 @@ class Record extends \Espo\Core\Services\Base
|
||||
$this->filterInput($data);
|
||||
$this->handleInput($data);
|
||||
|
||||
unset($data['modifiedById']);
|
||||
unset($data['modifiedByName']);
|
||||
unset($data['modifiedAt']);
|
||||
unset($data['createdById']);
|
||||
unset($data['createdByName']);
|
||||
unset($data['createdAt']);
|
||||
unset($data->modifiedById);
|
||||
unset($data->modifiedByName);
|
||||
unset($data->modifiedAt);
|
||||
unset($data->createdById);
|
||||
unset($data->createdByName);
|
||||
unset($data->createdAt);
|
||||
|
||||
if ($this->getEntityBeforeUpdate) {
|
||||
$entity = $this->getEntity($id);
|
||||
@@ -627,11 +627,9 @@ class Record extends \Espo\Core\Services\Base
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$dataBefore = $entity->getValues();
|
||||
|
||||
$entity->set($data);
|
||||
|
||||
$this->beforeUpdate($entity, $data);
|
||||
$this->beforeUpdateEntity($entity, $data);
|
||||
|
||||
if (!$this->isValid($entity)) {
|
||||
throw new BadRequest();
|
||||
@@ -646,7 +644,7 @@ class Record extends \Espo\Core\Services\Base
|
||||
}
|
||||
|
||||
if ($this->storeEntity($entity)) {
|
||||
$this->afterUpdate($entity, $data);
|
||||
$this->afterUpdateEntity($entity, $data);
|
||||
$this->prepareEntityForOutput($entity);
|
||||
|
||||
$this->processActionHistoryRecord('update', $entity);
|
||||
@@ -657,26 +655,63 @@ class Record extends \Espo\Core\Services\Base
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
protected function beforeCreateEntity(Entity $entity, $data)
|
||||
{
|
||||
|
||||
$this->beforeCreate($entity, get_object_vars($data)); // TODO remove in 5.1.0
|
||||
}
|
||||
|
||||
protected function afterCreateEntity(Entity $entity, $data)
|
||||
{
|
||||
$this->afterCreate($entity, get_object_vars($data)); // TODO remove in 5.1.0
|
||||
}
|
||||
|
||||
protected function beforeUpdateEntity(Entity $entity, $data)
|
||||
{
|
||||
$this->beforeUpdate($entity, get_object_vars($data)); // TODO remove in 5.1.0
|
||||
}
|
||||
|
||||
protected function afterUpdateEntity(Entity $entity, $data)
|
||||
{
|
||||
$this->afterUpdate($entity, get_object_vars($data)); // TODO remove in 5.1.0
|
||||
}
|
||||
|
||||
protected function beforeDeleteEntity(Entity $entity)
|
||||
{
|
||||
$this->beforeDelete($entity); // TODO remove in 5.1.0
|
||||
}
|
||||
|
||||
protected function afterDeleteEntity(Entity $entity)
|
||||
{
|
||||
$this->afterDelete($entity); // TODO remove in 5.1.0
|
||||
}
|
||||
|
||||
/** Deprecated */
|
||||
protected function beforeCreate(Entity $entity, array $data = array())
|
||||
{
|
||||
}
|
||||
|
||||
/** Deprecated */
|
||||
protected function afterCreate(Entity $entity, array $data = array())
|
||||
{
|
||||
}
|
||||
|
||||
/** Deprecated */
|
||||
protected function beforeUpdate(Entity $entity, array $data = array())
|
||||
{
|
||||
}
|
||||
|
||||
/** Deprecated */
|
||||
protected function afterUpdate(Entity $entity, array $data = array())
|
||||
{
|
||||
}
|
||||
|
||||
/** Deprecated */
|
||||
protected function beforeDelete(Entity $entity)
|
||||
{
|
||||
}
|
||||
|
||||
/** Deprecated */
|
||||
protected function afterDelete(Entity $entity)
|
||||
{
|
||||
}
|
||||
@@ -705,11 +740,11 @@ class Record extends \Espo\Core\Services\Base
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$this->beforeDelete($entity);
|
||||
$this->beforeDeleteEntity($entity);
|
||||
|
||||
$result = $this->getRepository()->remove($entity);
|
||||
if ($result) {
|
||||
$this->afterDelete($entity);
|
||||
$this->afterDeleteEntity($entity);
|
||||
|
||||
$this->processActionHistoryRecord('delete', $entity);
|
||||
|
||||
@@ -1214,12 +1249,12 @@ class Record extends \Espo\Core\Services\Base
|
||||
);
|
||||
}
|
||||
|
||||
protected function getDuplicateWhereClause(Entity $entity, $data = array())
|
||||
protected function getDuplicateWhereClause(Entity $entity, $data)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function checkEntityForDuplicate(Entity $entity, $data = array())
|
||||
public function checkEntityForDuplicate(Entity $entity, $data)
|
||||
{
|
||||
$where = $this->getDuplicateWhereClause($entity, $data);
|
||||
|
||||
@@ -1683,8 +1718,8 @@ class Record extends \Espo\Core\Services\Base
|
||||
throw new NotFound();
|
||||
}
|
||||
|
||||
$attributes = $entity->getValues();
|
||||
unset($attributes['id']);
|
||||
$attributes = $entity->getValueMap();
|
||||
unset($attributes->id);
|
||||
|
||||
$fields = $this->getMetadata()->get(['entityDefs', $this->getEntityType(), 'fields'], array());
|
||||
|
||||
@@ -1697,7 +1732,7 @@ class Record extends \Espo\Core\Services\Base
|
||||
if (!empty($item['duplicateIgnore'])) {
|
||||
$attributeToIgnoreList = $fieldManager->getAttributeList($this->entityType, $field);
|
||||
foreach ($attributeToIgnoreList as $attribute) {
|
||||
unset($attributes[$attribute]);
|
||||
unset($attributes->$attribute);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -1708,7 +1743,7 @@ class Record extends \Espo\Core\Services\Base
|
||||
$attachment = $this->getEntityManager()->getRepository('Attachment')->getCopiedAttachment($attachment);
|
||||
$idAttribute = $field . 'Id';
|
||||
if ($attachment) {
|
||||
$attributes[$idAttribute] = $attachment->id;
|
||||
$attributes->$idAttribute = $attachment->id;
|
||||
}
|
||||
}
|
||||
} else if (in_array($type, ['attachmentMultiple'])) {
|
||||
@@ -1725,23 +1760,23 @@ class Record extends \Espo\Core\Services\Base
|
||||
$typeHash->{$attachment->id} = $attachment->get('type');
|
||||
}
|
||||
}
|
||||
$attributes[$field . 'Ids'] = $idList;
|
||||
$attributes[$field . 'Names'] = $nameHash;
|
||||
$attributes[$field . 'Types'] = $typeHash;
|
||||
$attributes->{$field . 'Ids'} = $idList;
|
||||
$attributes->{$field . 'Names'} = $nameHash;
|
||||
$attributes->{$field . 'Types'} = $typeHash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$attributes['_duplicatingEntityId'] = $id;
|
||||
$attributes->_duplicatingEntityId = $id;
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
protected function afterCreateProcessDuplicating(Entity $entity, $data)
|
||||
{
|
||||
if (!isset($data['_duplicatingEntityId'])) return;
|
||||
if (!isset($data->_duplicatingEntityId)) return;
|
||||
|
||||
$duplicatingEntityId = $data['_duplicatingEntityId'];
|
||||
$duplicatingEntityId = $data->_duplicatingEntityId;
|
||||
if (!$duplicatingEntityId) return;
|
||||
$duplicatingEntity = $this->getEntityManager()->getEntity($entity->getEntityType(), $duplicatingEntityId);
|
||||
if (!$duplicatingEntity) return;
|
||||
|
||||
@@ -159,11 +159,12 @@ class RecordTree extends Record
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function beforeCreate(Entity $entity, array $data = array())
|
||||
protected function beforeCreateEntity(Entity $entity, $data)
|
||||
{
|
||||
parent::beforeCreate($entity, $data);
|
||||
if (!empty($data['parentId'])) {
|
||||
$parent = $this->getEntityManager()->getEntity($this->getEntityType(), $data['parentId']);
|
||||
parent::beforeCreateEntity($entity, $data);
|
||||
|
||||
if (!empty($data->parentId)) {
|
||||
$parent = $this->getEntityManager()->getEntity($this->getEntityType(), $data->parentId);
|
||||
if (!$parent) {
|
||||
throw new Error("Tried to create tree item entity with not existing parent.");
|
||||
}
|
||||
@@ -175,7 +176,7 @@ class RecordTree extends Record
|
||||
|
||||
public function updateEntity($id, $data)
|
||||
{
|
||||
if (!empty($data['parentId']) && $data['parentId'] == $id) {
|
||||
if (!empty($data->parentId) && $data->parentId == $id) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
|
||||
@@ -215,17 +215,17 @@ class User extends Record
|
||||
public function createEntity($data)
|
||||
{
|
||||
$newPassword = null;
|
||||
if (array_key_exists('password', $data)) {
|
||||
$newPassword = $data['password'];
|
||||
$data['password'] = $this->hashPassword($data['password']);
|
||||
if (property_exists($data, 'password')) {
|
||||
$newPassword = $data->password;
|
||||
$data->password = $this->hashPassword($data->password);
|
||||
}
|
||||
if (!$this->getUser()->get('isSuperAdmin')) {
|
||||
unset($data['isSuperAdmin']);
|
||||
unset($data->isSuperAdmin);
|
||||
}
|
||||
|
||||
$user = parent::createEntity($data);
|
||||
|
||||
if (!is_null($newPassword) && !empty($data['sendAccessInfo'])) {
|
||||
if (!is_null($newPassword) && !empty($data->sendAccessInfo)) {
|
||||
if ($user->isActive()) {
|
||||
try {
|
||||
$this->sendPassword($user, $newPassword);
|
||||
@@ -242,24 +242,24 @@ class User extends Record
|
||||
throw new Forbidden();
|
||||
}
|
||||
$newPassword = null;
|
||||
if (array_key_exists('password', $data)) {
|
||||
$newPassword = $data['password'];
|
||||
$data['password'] = $this->hashPassword($data['password']);
|
||||
if (property_exists($data, 'password')) {
|
||||
$newPassword = $data->password;
|
||||
$data->password = $this->hashPassword($data->password);
|
||||
}
|
||||
|
||||
if ($id == $this->getUser()->id) {
|
||||
unset($data['isActive']);
|
||||
unset($data['isPortalUser']);
|
||||
unset($data->isActive);
|
||||
unset($data->isPortalUser);
|
||||
}
|
||||
if (!$this->getUser()->get('isSuperAdmin')) {
|
||||
unset($data['isSuperAdmin']);
|
||||
unset($data->isSuperAdmin);
|
||||
}
|
||||
|
||||
$user = parent::updateEntity($id, $data);
|
||||
|
||||
if (!is_null($newPassword)) {
|
||||
try {
|
||||
if ($user->isActive() && !empty($data['sendAccessInfo'])) {
|
||||
if ($user->isActive() && !empty($data->sendAccessInfo)) {
|
||||
$this->sendPassword($user, $newPassword);
|
||||
}
|
||||
} catch (\Exception $e) {}
|
||||
@@ -288,7 +288,7 @@ class User extends Record
|
||||
))->count();
|
||||
}
|
||||
|
||||
protected function beforeCreate(Entity $entity, array $data = array())
|
||||
protected function beforeCreateEntity(Entity $entity, $data))
|
||||
{
|
||||
if ($this->getConfig()->get('userLimit') && !$this->getUser()->get('isSuperAdmin')) {
|
||||
$userCount = $this->getInternalUserCount();
|
||||
@@ -304,7 +304,7 @@ class User extends Record
|
||||
}
|
||||
}
|
||||
|
||||
protected function beforeUpdate(Entity $user, array $data = array())
|
||||
protected function beforeUpdateEntity(Entity $user, $data)
|
||||
{
|
||||
if ($this->getConfig()->get('userLimit') && !$this->getUser()->get('isSuperAdmin')) {
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user