Update users list to use User class instead of sql. Remove Monitors column

This commit is contained in:
Isaac Connor
2023-04-25 14:01:14 -04:00
parent d81a8a9c9c
commit 0d65281b24

View File

@@ -17,47 +17,29 @@
<th class="colSystem"><?php echo translate('System') ?></th>
<th class="colDevices"><?php echo translate('Devices') ?></th>
<th class="colBandwidth"><?php echo translate('Bandwidth') ?></th>
<th class="colMonitor"><?php echo translate('Monitor') ?></th>
<?php if ( ZM_OPT_USE_API ) { ?><th class="colAPIEnabled"><?php echo translate('APIEnabled') ?></th><?php } ?>
<th class="colMark"><?php echo translate('Mark') ?></th>
</tr>
</thead>
<tbody>
<?php
$sql = 'SELECT * FROM Monitors ORDER BY Sequence ASC';
$monitors = array();
foreach (dbFetchAll($sql) as $monitor) {
$monitors[$monitor['Id']] = $monitor;
}
$sql = 'SELECT * FROM Users ORDER BY Username';
foreach (dbFetchAll($sql) as $user_row) {
$userMonitors = array();
if (!empty($user_row['MonitorIds'])) {
foreach ( explode(',', $user_row['MonitorIds']) as $monitorId ) {
// A deleted monitor will cause an error since we don't update
// the user monitors list on monitor delete
if (!isset($monitors[$monitorId])) continue;
$userMonitors[] = $monitors[$monitorId]['Name'];
}
}
foreach (ZM\User::find([], ['order'=>'Username']) as $user_row) {
?>
<tr>
<td class="colUsername"><?php echo makeLink('?view=user&amp;uid='.$user_row['Id'], validHtmlStr($user_row['Username']).($user->Username()==$user_row['Username']?'*':''), $canEdit) ?></td>
<td class="colLanguage"><?php echo $user_row['Language']?validHtmlStr($user_row['Language']):'default' ?></td>
<td class="colEnabled"><?php echo translate($user_row['Enabled']?'Yes':'No') ?></td>
<td class="colStream"><?php echo validHtmlStr($user_row['Stream']) ?></td>
<td class="colEvents"><?php echo validHtmlStr($user_row['Events']) ?></td>
<td class="colControl"><?php echo validHtmlStr($user_row['Control']) ?></td>
<td class="colMonitors"><?php echo validHtmlStr($user_row['Monitors']) ?></td>
<td class="colGroups"><?php echo validHtmlStr($user_row['Groups']) ?></td>
<td class="colSnapshots"><?php echo validHtmlStr($user_row['Snapshots']) ?></td>
<td class="colSystem"><?php echo validHtmlStr($user_row['System']) ?></td>
<td class="colDevices"><?php echo validHtmlStr($user_row['Devices']) ?></td>
<td class="colBandwidth"><?php echo $user_row['MaxBandwidth']?$bandwidth_options[$user_row['MaxBandwidth']]:'&nbsp;' ?></td>
<td class="colMonitor"><?php echo count($userMonitors)?(join(', ', $userMonitors)):'&nbsp;' ?></td>
<?php if ( ZM_OPT_USE_API ) { ?><td class="colAPIEnabled"><?php echo translate($user_row['APIEnabled']?'Yes':'No') ?></td><?php } ?>
<td class="colMark"><input type="checkbox" name="markUids[]" value="<?php echo $user_row['Id'] ?>" data-on-click-this="configureDeleteButton"<?php echo (!$canEdit) ? ' disabled="disabled"' : '' ?>/></td>
<td class="colUsername"><?php echo makeLink('?view=user&amp;uid='.$user_row->Id(), validHtmlStr($user_row->Username()).($user->Username()==$user_row->Username()?'*':''), $canEdit) ?></td>
<td class="colLanguage"><?php echo $user_row->Language()?validHtmlStr($user_row->Language()):'default' ?></td>
<td class="colEnabled"><?php echo translate($user_row->Enabled()?'Yes':'No') ?></td>
<td class="colStream"><?php echo validHtmlStr($user_row->Stream()) ?></td>
<td class="colEvents"><?php echo validHtmlStr($user_row->Events()) ?></td>
<td class="colControl"><?php echo validHtmlStr($user_row->Control()) ?></td>
<td class="colMonitors"><?php echo validHtmlStr($user_row->Monitors()) ?></td>
<td class="colGroups"><?php echo validHtmlStr($user_row->Groups()) ?></td>
<td class="colSnapshots"><?php echo validHtmlStr($user_row->Snapshots()) ?></td>
<td class="colSystem"><?php echo validHtmlStr($user_row->System()) ?></td>
<td class="colDevices"><?php echo validHtmlStr($user_row->Devices()) ?></td>
<td class="colBandwidth"><?php echo $user_row->MaxBandwidth()?$bandwidth_options[$user_row->MaxBandwidth()]:'&nbsp;' ?></td>
<?php if ( ZM_OPT_USE_API ) { ?><td class="colAPIEnabled"><?php echo translate($user_row->APIEnabled()?'Yes':'No') ?></td><?php } ?>
<td class="colMark"><input type="checkbox" name="markUids[]" value="<?php echo $user_row->Id() ?>" data-on-click-this="configureDeleteButton"<?php echo (!$canEdit) ? ' disabled="disabled"' : '' ?>/></td>
</tr>
<?php
}