diff --git a/lib/LMSManagers/LMSEventManager.php b/lib/LMSManagers/LMSEventManager.php
index 4b087f685d..bc4727161d 100644
--- a/lib/LMSManagers/LMSEventManager.php
+++ b/lib/LMSManagers/LMSEventManager.php
@@ -293,9 +293,9 @@ public function GetEvent($id)
$event['helpdesk'] = !empty($event['ticketid']);
$event['userlist'] = $this->db->GetAllByKey(
- 'SELECT u.id, u.rname, u.name, u.login
+ 'SELECT u.id, u.rname, u.name, u.login, u.deleted, u.access
FROM vusers u
- JOIN eventassignments a ON a.userid = u.id
+ JOIN eventassignments a ON a.userid = u.id
WHERE a.eventid = ?',
'id',
array($id)
@@ -514,11 +514,12 @@ public function GetEventList(array $params)
$row['nodelocation'] = $customerstuffaddresses[$row['customerid']];
}
- $row['userlist'] = $this->db->GetAll(
+ $row['userlist'] = $this->db->GetAllByKey(
'SELECT userid AS id, vusers.name,
vusers.access, vusers.deleted, vusers.accessfrom, vusers.accessto
FROM eventassignments, vusers
WHERE userid = vusers.id AND eventid = ? ',
+ 'id',
array($row['id'])
);
diff --git a/lib/LMSManagers/LMSHelpdeskManager.php b/lib/LMSManagers/LMSHelpdeskManager.php
index b2f9d241bd..af0a9bbda3 100644
--- a/lib/LMSManagers/LMSHelpdeskManager.php
+++ b/lib/LMSManagers/LMSHelpdeskManager.php
@@ -893,10 +893,13 @@ public function GetUserRightsToCategory($user, $category, $ticket = null)
return ($owner === '1');
}
- public function GetCategoryList($stats = true)
+ public function GetCategoryList($stats = true, $owners = true)
{
- if ($result = $this->db->GetAll('SELECT id, name, description, style
- FROM rtcategories ORDER BY name')) {
+ if ($result = $this->db->GetAll(
+ 'SELECT id, name, description, style
+ FROM rtcategories
+ ORDER BY name'
+ )) {
if ($stats) {
foreach ($result as $idx => $row) {
foreach ($this->GetCategoryStats($row['id']) as $sidx => $row2) {
@@ -904,15 +907,27 @@ public function GetCategoryList($stats = true)
}
}
}
- foreach ($result as $idx => $category) {
- $result[$idx]['owners'] = $this->db->GetAll('SELECT u.id, name FROM rtcategoryusers cu
- LEFT JOIN vusers u ON cu.userid = u.id
- WHERE categoryid = ?', array($category['id']));
+ if ($owners) {
+ foreach ($result as $idx => $row) {
+ $result[$idx]['owners'] = $this->GetCategoryUsers($row['id']);
+ }
}
}
return $result;
}
+ public function GetCategoryUsers($categoryid)
+ {
+ return $this->db->GetAll(
+ 'SELECT u.id, u.name, u.deleted,
+ (CASE WHEN u.access = 1 AND u.accessfrom <= ?NOW? AND (u.accessto >=?NOW? OR u.accessto = 0) THEN 1 ELSE 0 END) AS access
+ FROM rtcategoryusers cu
+ LEFT JOIN vusers u ON cu.userid = u.id
+ WHERE categoryid = ?',
+ array($categoryid)
+ );
+ }
+
public function GetCategoryStats($id)
{
if ($result = $this->db->GetAll('SELECT state, COUNT(state) AS scount
diff --git a/lib/LMSManagers/LMSHelpdeskManagerInterface.php b/lib/LMSManagers/LMSHelpdeskManagerInterface.php
index 8c74cf6e2e..a4330c9ef6 100644
--- a/lib/LMSManagers/LMSHelpdeskManagerInterface.php
+++ b/lib/LMSManagers/LMSHelpdeskManagerInterface.php
@@ -61,7 +61,9 @@ public function GetCategory($id);
public function GetUserRightsToCategory($user, $category, $ticket = null);
- public function GetCategoryList($stats = true);
+ public function GetCategoryList($stats = true, $owners = true);
+
+ public function GetCategoryUsers($categoryid);
public function GetCategoryStats($id);
diff --git a/lib/SmartyPlugins/LMSSmartyPlugins.php b/lib/SmartyPlugins/LMSSmartyPlugins.php
index 2e8b60aa47..82e43a03ef 100644
--- a/lib/SmartyPlugins/LMSSmartyPlugins.php
+++ b/lib/SmartyPlugins/LMSSmartyPlugins.php
@@ -1337,6 +1337,36 @@ public static function networkDeviceTypesFunction(array $params, $template)
. '';
}
+ public static function userCompactListFunction(array $params, $template)
+ {
+ $default_user_row_limit = 4;
+
+ $elemid = $params['elemid'] ?? false;
+ $elemname = $params['elemname'] ?? false;
+ $class = $params['class'] ?? false;
+ $limit = empty($params['limit']) ? $default_user_row_limit : intval($params['limit']);
+ $userlist = empty($params['userlist']) ? trans('No avaiable users') : $params['userlist'];
+ $usercount = sizeof($userlist);
+ $ul = '';
+
+ foreach ($userlist as $item) {
+ $ul .= ''
+ . htmlspecialchars(substr(trans($item['name']), 0, 40))
+ . '
';
+ }
+
+ return '
- {foreach $category.owners as $key => $owner}
- {$owner.name}{if $key+1
{$category.new|default:0}
| |