stream notes created modified by
This commit is contained in:
@@ -313,7 +313,9 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable
|
||||
$entity->set('modifiedAt', $nowString);
|
||||
}
|
||||
if ($entity->hasAttribute('modifiedById')) {
|
||||
if ($this->getEntityManager()->getUser()) {
|
||||
if (!empty($options['modifiedById'])) {
|
||||
$entity->set('modifiedById', $options['modifiedById']);
|
||||
} else if ($this->getEntityManager()->getUser()) {
|
||||
$entity->set('modifiedById', $this->getEntityManager()->getUser()->id);
|
||||
$entity->set('modifiedByName', $this->getEntityManager()->getUser()->get('name'));
|
||||
}
|
||||
|
||||
@@ -100,11 +100,11 @@ class Stream extends \Espo\Core\Hooks\Base
|
||||
$this->getEntityManager()->getPDO()->query($sql);
|
||||
}
|
||||
|
||||
protected function handleCreateRelated(Entity $entity)
|
||||
protected function handleCreateRelated(Entity $entity, array $options = [])
|
||||
{
|
||||
$linkDefs = $this->getMetadata()->get("entityDefs." . $entity->getEntityType() . ".links", array());
|
||||
$linkDefs = $this->getMetadata()->get("entityDefs." . $entity->getEntityType() . ".links", []);
|
||||
|
||||
$scopeNotifiedList = array();
|
||||
$scopeNotifiedList = [];
|
||||
foreach ($linkDefs as $link => $defs) {
|
||||
if ($defs['type'] == 'belongsTo') {
|
||||
if (empty($defs['foreign']) || empty($defs['entity'])) {
|
||||
@@ -131,7 +131,7 @@ class Stream extends \Espo\Core\Hooks\Base
|
||||
if (in_array($scope, $scopeNotifiedList) || !$this->isLinkObservableInStream($scope, $foreign)) {
|
||||
continue;
|
||||
}
|
||||
$this->getStreamService()->noteCreateRelated($entity, $scope, $entityId);
|
||||
$this->getStreamService()->noteCreateRelated($entity, $scope, $entityId, $options);
|
||||
$scopeNotifiedList[] = $scope;
|
||||
|
||||
}
|
||||
@@ -147,14 +147,14 @@ class Stream extends \Espo\Core\Hooks\Base
|
||||
continue;
|
||||
}
|
||||
$entityId = $entityIds[0];
|
||||
$this->getStreamService()->noteCreateRelated($entity, $scope, $entityId);
|
||||
$this->getStreamService()->noteCreateRelated($entity, $scope, $entityId, $options);
|
||||
$scopeNotifiedList[] = $scope;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function getAutofollowUserIdList(Entity $entity, array $ignoreList = array())
|
||||
protected function getAutofollowUserIdList(Entity $entity, array $ignoreList = [])
|
||||
{
|
||||
$entityType = $entity->getEntityType();
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
@@ -240,7 +240,7 @@ class Stream extends \Espo\Core\Hooks\Base
|
||||
}
|
||||
|
||||
if (empty($options['noStream']) && empty($options['silent'])) {
|
||||
$this->getStreamService()->noteCreate($entity);
|
||||
$this->getStreamService()->noteCreate($entity, $options);
|
||||
}
|
||||
|
||||
if (in_array($this->getUser()->id, $userIdList)) {
|
||||
@@ -275,16 +275,16 @@ class Stream extends \Espo\Core\Hooks\Base
|
||||
$assignedUserId = $entity->get('assignedUserId');
|
||||
if (!empty($assignedUserId)) {
|
||||
$this->getStreamService()->followEntity($entity, $assignedUserId);
|
||||
$this->getStreamService()->noteAssign($entity);
|
||||
$this->getStreamService()->noteAssign($entity, $options);
|
||||
|
||||
if ($this->getUser()->id === $assignedUserId) {
|
||||
$entity->set('isFollowed', true);
|
||||
}
|
||||
} else {
|
||||
$this->getStreamService()->noteAssign($entity);
|
||||
$this->getStreamService()->noteAssign($entity, $options);
|
||||
}
|
||||
}
|
||||
$this->getStreamService()->handleAudited($entity);
|
||||
$this->getStreamService()->handleAudited($entity, $options);
|
||||
|
||||
$statusFields = $this->getStatusFields();
|
||||
|
||||
@@ -292,7 +292,7 @@ class Stream extends \Espo\Core\Hooks\Base
|
||||
$field = $this->statusFields[$entityType];
|
||||
$value = $entity->get($field);
|
||||
if (!empty($value) && $value != $entity->getFetched($field)) {
|
||||
$this->getStreamService()->noteStatus($entity, $field);
|
||||
$this->getStreamService()->noteStatus($entity, $field, $options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,11 +352,11 @@ class Stream extends \Espo\Core\Hooks\Base
|
||||
}
|
||||
|
||||
if ($entity->isNew() && empty($options['noStream']) && empty($options['silent']) && $this->getMetadata()->get(['scopes', $entityType, 'object'])) {
|
||||
$this->handleCreateRelated($entity);
|
||||
$this->handleCreateRelated($entity, $options);
|
||||
}
|
||||
}
|
||||
|
||||
public function afterRelate(Entity $entity, array $options = array(), array $data = array())
|
||||
public function afterRelate(Entity $entity, array $options = [], array $data = [])
|
||||
{
|
||||
$entityType = $entity->getEntityType();
|
||||
if (
|
||||
|
||||
@@ -1057,7 +1057,7 @@ class Stream extends \Espo\Core\Services\Base
|
||||
$this->getEntityManager()->saveEntity($note);
|
||||
}
|
||||
|
||||
public function noteCreate(Entity $entity)
|
||||
public function noteCreate(Entity $entity, array $options = [])
|
||||
{
|
||||
$entityType = $entity->getEntityType();
|
||||
|
||||
@@ -1097,6 +1097,10 @@ class Stream extends \Espo\Core\Services\Base
|
||||
|
||||
$note->set('data', (object) $data);
|
||||
|
||||
if (!empty($options['createdById'])) {
|
||||
$note->set('createdById', $options['createdById']);
|
||||
}
|
||||
|
||||
$this->getEntityManager()->saveEntity($note);
|
||||
}
|
||||
|
||||
@@ -1122,7 +1126,7 @@ class Stream extends \Espo\Core\Services\Base
|
||||
return $style;
|
||||
}
|
||||
|
||||
public function noteCreateRelated(Entity $entity, $parentType, $parentId)
|
||||
public function noteCreateRelated(Entity $entity, $parentType, $parentId, array $options = [])
|
||||
{
|
||||
$note = $this->getEntityManager()->getEntity('Note');
|
||||
|
||||
@@ -1143,10 +1147,14 @@ class Stream extends \Espo\Core\Services\Base
|
||||
$note->set('superParentType', 'Account');
|
||||
}
|
||||
|
||||
if (!empty($options['createdById'])) {
|
||||
$note->set('createdById', $options['createdById']);
|
||||
}
|
||||
|
||||
$this->getEntityManager()->saveEntity($note);
|
||||
}
|
||||
|
||||
public function noteAssign(Entity $entity)
|
||||
public function noteAssign(Entity $entity, array $options = [])
|
||||
{
|
||||
$note = $this->getEntityManager()->getEntity('Note');
|
||||
|
||||
@@ -1175,10 +1183,18 @@ class Stream extends \Espo\Core\Services\Base
|
||||
]);
|
||||
}
|
||||
|
||||
if (!empty($options['createdById'])) {
|
||||
$note->set('createdById', $options['createdById']);
|
||||
}
|
||||
|
||||
if (!empty($options['modifiedById'])) {
|
||||
$note->set('createdById', $options['modifiedById']);
|
||||
}
|
||||
|
||||
$this->getEntityManager()->saveEntity($note);
|
||||
}
|
||||
|
||||
public function noteStatus(Entity $entity, $field)
|
||||
public function noteStatus(Entity $entity, $field, array $options = [])
|
||||
{
|
||||
$note = $this->getEntityManager()->getEntity('Note');
|
||||
|
||||
@@ -1204,6 +1220,14 @@ class Stream extends \Espo\Core\Services\Base
|
||||
'style' => $style
|
||||
]);
|
||||
|
||||
if (!empty($options['createdById'])) {
|
||||
$note->set('createdById', $options['createdById']);
|
||||
}
|
||||
|
||||
if (!empty($options['modifiedById'])) {
|
||||
$note->set('createdById', $options['modifiedById']);
|
||||
}
|
||||
|
||||
$this->getEntityManager()->saveEntity($note);
|
||||
}
|
||||
|
||||
@@ -1233,13 +1257,13 @@ class Stream extends \Espo\Core\Services\Base
|
||||
return $this->auditedFieldsCache[$entityType];
|
||||
}
|
||||
|
||||
public function handleAudited($entity)
|
||||
public function handleAudited($entity, array $options = [])
|
||||
{
|
||||
$auditedFields = $this->getAuditedFieldsData($entity);
|
||||
|
||||
$updatedFieldList = [];
|
||||
$was = array();
|
||||
$became = array();
|
||||
$was = [];
|
||||
$became = [];
|
||||
|
||||
foreach ($auditedFields as $field => $item) {
|
||||
$updated = false;
|
||||
@@ -1289,6 +1313,10 @@ class Stream extends \Espo\Core\Services\Base
|
||||
]
|
||||
]);
|
||||
|
||||
if (!empty($options['modifiedById'])) {
|
||||
$note->set('createdById', $options['modifiedById']);
|
||||
}
|
||||
|
||||
$this->getEntityManager()->saveEntity($note);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user