Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/LMSManagers/LMSEventManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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'])
);

Expand Down
29 changes: 22 additions & 7 deletions lib/LMSManagers/LMSHelpdeskManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -893,26 +893,41 @@ 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) {
$result[$idx][$sidx] = $row2;
}
}
}
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
Expand Down
4 changes: 3 additions & 1 deletion lib/LMSManagers/LMSHelpdeskManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
30 changes: 30 additions & 0 deletions lib/SmartyPlugins/LMSSmartyPlugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,36 @@ public static function networkDeviceTypesFunction(array $params, $template)
. '</select>';
}

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 .= '<a href="?m=userinfo&id=' . $item['id'] . '" class="'
. (empty($item['deleted']) ? '' : 'crossed disabled')
. (empty($item['access']) ? ' blend' : '')
. (empty($item['class']) ? '' : ' ' . $class)
. '" style="font-weight: normal">'
. htmlspecialchars(substr(trans($item['name']), 0, 40))
. '</a><br>';
}

return '<div '
. ($elemname ? ' name="' . $elemname . '"' : '')
. ($elemid ? ' id="' . $elemid . '"' : '') . '>'
. ($usercount < $limit ?
$ul : self::hintFunction(array('content' => $ul, 'icon' => 'user'), $template) . $usercount)
. '</div>';
}

public static function userSelectionFunction(array $params, $template)
{
static $userlist = array();
Expand Down
30 changes: 30 additions & 0 deletions lib/SmartyPlugins/function.user_compact_list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/*
* LMS version 1.11-git
*
* (C) Copyright 2001-2021 LMS Developers
*
* Please, see the doc/AUTHORS for more information about authors!
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id$
*/

function smarty_function_user_compact_list($params, $template)
{
return LMSSmartyPlugins::userCompactListFunction($params, $template);
}
17 changes: 14 additions & 3 deletions modules/eventinfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,25 @@

if (!$_GET['id']) {
$SESSION->redirect('?m=eventlist');
} else {
$id = intval($_GET['id']);
}
$user_row_limit = ConfigHelper::getConfig(
'timetable.row_user_limit',
ConfigHelper::getConfig('phpui.timetable_user_row_limit', 4)
);

$event = $LMS->GetEvent($_GET['id']);
$event = $LMS->GetEvent($id);

$layout['pagetitle'] = trans('Event Info');
$layout['pagetitle'] = trans('Event Info') . '#' . $id;

$SESSION->add_history_entry();

$SMARTY->assign('event', $event);
$SMARTY->assign(
array(
'event' => $event,
'user_row_limit' => $user_row_limit,
)
);

$SMARTY->display('event/eventinfo.html');
2 changes: 2 additions & 0 deletions modules/eventlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
$hide_disabled_users = ConfigHelper::checkConfig('timetable.hide_disabled_users', ConfigHelper::checkConfig('phpui.timetable_hide_disabled_users'));
$show_delayed_events = ConfigHelper::checkConfig('timetable.show_delayed_events', ConfigHelper::checkConfig('phpui.timetable_overdue_events'));
$big_networks = ConfigHelper::checkConfig('phpui.big_networks');
$user_row_limit = ConfigHelper::getConfig('timetable.row_user_limit', ConfigHelper::getConfig('phpui.timetable_user_row_limit', 4));
$params['userid'] = Auth::GetCurrentUser();

if (!empty($filter['edate'])) {
Expand Down Expand Up @@ -248,5 +249,6 @@
'overdue_events_only' => $overdue_events_only,
'getHolidays', getHolidays($year ?? null),
'customerlist' => $big_networks ? null : $LMS->GetCustomerNames(),
'user_row_limit' => $user_row_limit,
));
$SMARTY->display('event/eventlist.html');
7 changes: 1 addition & 6 deletions templates/default/event/eventinfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,7 @@ <h1>{$layout.pagetitle}</h1>
<strong>{trans("Users")}</strong>
</td>
<td class="nobr">
{foreach $event.userlist as $userid => $user}
<a href="?m=userinfo&id={$userid}">{$user.rname|escape}</a>
{if !$user@last}
<br>
{/if}
{/foreach}
{user_compact_list limit=$user_row_limit userlist=$event.userlist}
</td>
</tr>
{/if}
Expand Down
25 changes: 6 additions & 19 deletions templates/default/event/eventlistboxrow.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</a>
{/if}
</td>
<TD class="text-left nobr bold" style="min-width:100px" data-target-url="?m=eventinfo&id={$event.id}">
<TD class="text-left nobr bold" style="min-width:100px">
{if $event.endtime == 86400}
{trans("whole day")}
{else}
Expand All @@ -28,24 +28,11 @@
{if $overdue == 1}
<br>{$event.date|date_format:"Y-m-d"}
{/if}
{$imadded=0}
{$user_row_limit = intval(ConfigHelper::getConfig('timetable.row_user_limit', ConfigHelper::getConfig('phpui.timetable_user_row_limit', 4)))}
{if !empty($event.userlist)}
{if !$user_row_limit || count($event.userlist) <= $user_row_limit}
{foreach $event.userlist as $user}
{if $layout.logid == $user.id}
{$imadded=1}
{/if}
<br>
<a href="?m=userinfo&amp;id={$user.id}"
style="font-weight: normal;" {if isset($user.noaccess)} class="lms-ui-crossed"{/if}>{$user.name|trunescape:25}</a>
{/foreach}
{else}
<br>
<i class="lms-ui-icon-user lms-ui-hint-rollover"
data-url="?m=eventinfoshort&id={$event.id}"></i>
{$event.userlist|@count}
{/if}
{user_compact_list limit=$user_row_limit userlist=$event.userlist}
{if in_array($layout.logid, array_column($event.userlist, 'id'))}
{assign var="imadded" value=1}
{else}
{assign var="imadded" value=0}
{/if}
</TD>
<TD data-target-url="?m=eventinfo&id={$event.id}">
Expand Down
6 changes: 3 additions & 3 deletions templates/default/rt/rtcategorylist.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
{$user_row_limit = ConfigHelper::getConfig('rt.row_user_limit', 4)}

<!-- $Id$ -->
<h1>{$layout.pagetitle}</h1>
<table class="lmsbox lms-ui-background-cycle">
Expand Down Expand Up @@ -59,9 +61,7 @@ <h1>{$layout.pagetitle}</h1>
</div>
</td>
<td class="lms-ui-buttons">
{foreach $category.owners as $key => $owner}
<a href="?m=userinfo&id={$owner.id}">{$owner.name}</a>{if $key+1<count($category.owners)}, {/if}
{/foreach}
{user_compact_list limit=$user_row_limit userlist=$category.owners}
</td>
<td class="text-center">
{$category.new|default:0}
Expand Down