diff --git a/application/Espo/Core/SelectManagerFactory.php b/application/Espo/Core/SelectManagerFactory.php
index 4514302343..3eca097c18 100644
--- a/application/Espo/Core/SelectManagerFactory.php
+++ b/application/Espo/Core/SelectManagerFactory.php
@@ -44,13 +44,13 @@ class SelectManagerFactory
$this->metadata = $metadata;
}
- public function create($entityName)
+ public function create($entityType)
{
- $normalizedName = Util::normilizeClassName($entityName);
+ $normalizedName = Util::normilizeClassName($entityType);
$className = '\\Espo\\Custom\\SelectManagers\\' . $normalizedName;
if (!class_exists($className)) {
- $moduleName = $this->metadata->getScopeModuleName($entityName);
+ $moduleName = $this->metadata->getScopeModuleName($entityType);
if ($moduleName) {
$className = '\\Espo\\Modules\\' . $moduleName . '\\SelectManagers\\' . $normalizedName;
} else {
@@ -62,7 +62,7 @@ class SelectManagerFactory
}
$selectManager = new $className($this->entityManager, $this->user, $this->acl, $this->metadata);
- $selectManager->setEntityName($entityName);
+ $selectManager->setEntityType($entityType);
return $selectManager;
}
diff --git a/application/Espo/Core/SelectManagers/Base.php b/application/Espo/Core/SelectManagers/Base.php
index 4c73891ca1..20d966ec24 100644
--- a/application/Espo/Core/SelectManagers/Base.php
+++ b/application/Espo/Core/SelectManagers/Base.php
@@ -36,7 +36,7 @@ class Base
protected $entityManager;
- protected $entityName;
+ protected $entityType;
protected $metadata;
@@ -65,9 +65,14 @@ class Base
return $this->user;
}
- public function setEntityName($entityName)
+ public function setEntityType($entityType)
{
- $this->entityName = $entityName;
+ $this->entityType = $entityType;
+ }
+
+ protected function getEntityType()
+ {
+ return $this->entityType;
}
protected function limit($params, &$result)
@@ -84,7 +89,7 @@ class Base
{
if (!empty($params['sortBy'])) {
$result['orderBy'] = $params['sortBy'];
- $type = $this->metadata->get("entityDefs.{$this->entityName}.fields." . $result['orderBy'] . ".type");
+ $type = $this->metadata->get("entityDefs.{$this->entityType}.fields." . $result['orderBy'] . ".type");
if ($type == 'link') {
$result['orderBy'] .= 'Name';
} else if ($type == 'linkParent') {
@@ -102,13 +107,13 @@ class Base
protected function getTextFilterFields()
{
- return $this->metadata->get("entityDefs.{$this->entityName}.collection.textFilterFields", array('name'));
+ return $this->metadata->get("entityDefs.{$this->entityType}.collection.textFilterFields", array('name'));
}
protected function getSeed()
{
if (empty($this->seed)) {
- $this->seed = $this->entityManager->getEntity($this->entityName);
+ $this->seed = $this->entityManager->getEntity($this->entityType);
}
return $this->seed;
}
@@ -311,10 +316,10 @@ class Base
protected function access(&$result)
{
- if ($this->acl->checkReadOnlyOwn($this->entityName)) {
+ if ($this->acl->checkReadOnlyOwn($this->entityType)) {
$this->accessOnlyOwn($result);
}
- if (!$this->user->isAdmin() && $this->acl->checkReadOnlyTeam($this->entityName)) {
+ if (!$this->user->isAdmin() && $this->acl->checkReadOnlyTeam($this->entityType)) {
$this->accessOnlyTeam($result);
}
}
@@ -659,5 +664,16 @@ class Base
'assignedUserId' => $this->getUser()->id
);
}
+
+ protected function boolFilterFollowed(&$result)
+ {
+ $query = $this->getEntityManager()->getQuery();
+ $result['customJoin'] .= "
+ JOIN subscription ON
+ subscription.entity_type = ".$query->quote($this->getEntityType())." AND
+ subscription.entity_id = ".$query->toDb($this->getEntityType()).".id AND
+ subscription.user_id = ".$query->toDb($this->getUser()->id)."
+ ";
+ }
}
diff --git a/application/Espo/ORM/DB/Query/Base.php b/application/Espo/ORM/DB/Query/Base.php
index d40adc8adb..201e4c5893 100644
--- a/application/Espo/ORM/DB/Query/Base.php
+++ b/application/Espo/ORM/DB/Query/Base.php
@@ -426,6 +426,11 @@ abstract class Base
return $selectPart;
}
+ public function quote($value)
+ {
+ return $this->pdo->quote($value);
+ }
+
public function toDb($field)
{
if (array_key_exists($field, $this->fieldsMapCache)) {
diff --git a/application/Espo/Resources/i18n/en_US/Global.json b/application/Espo/Resources/i18n/en_US/Global.json
index b1601b82c4..9cccf2fb3f 100644
--- a/application/Espo/Resources/i18n/en_US/Global.json
+++ b/application/Espo/Resources/i18n/en_US/Global.json
@@ -189,7 +189,8 @@
"streamPostInfo": "Type @username to mention users in the post.\n\nAvailable markdown syntax:\n`code`\n**strong text**\n*emphasized text*\n~deleted text~\n> blockquote\n(url)[link]"
},
"boolFilters": {
- "onlyMy": "Only My"
+ "onlyMy": "Only My",
+ "followed": "Followed"
},
"massActions": {
"remove": "Remove",
diff --git a/frontend/client/src/views/record/search.js b/frontend/client/src/views/record/search.js
index 49d68e917a..74bb0e35be 100644
--- a/frontend/client/src/views/record/search.js
+++ b/frontend/client/src/views/record/search.js
@@ -71,6 +71,10 @@ Espo.define('Views.Record.Search', 'View', function (Dep) {
this.boolFilterList = Espo.Utils.clone(this.getMetadata().get('clientDefs.' + this.scope + '.boolFilterList') || []);
+ if (this.getMetadata().get('scopes.' + this.scope + '.stream')) {
+ this.boolFilterList.push('followed');
+ }
+
this._helper.layoutManager.get(this.scope, 'filters', function (list) {
this.moreFields = list;
this.tryReady();