Files
zoneminder/web/skins/classic/views/groups.php
T
IgorA100 8009884171 - Moved the getDelConfirmModal() function from options.js to skin.js
- Removed the getDelConfirmModal() function (and its call) from report.js, options.js, reports.js, devices.js, +++controlcaps.js(?view=options&tab=control), and snapshots.js. This is because it's now a single function in skin.js, which is called when the "Delete" button is pressed, rather than during page initialization.
- Slightly modified the local functions of manageDelConfirmModalBtns(). Removed the listener, so the code is executed immediately.
- You can now call local functions from the global getDelConfirmModal() function (instead of just executing submitThisForm() ). Applies to report.js, reports.js, devices.js, controlcaps.js, snapshots.js
- Changed the style of the "Delete" button on the Groups page
- Added deletion confirmation to the Storage, Roles, and Groups pages
- On the Event page, deletion permissions were broken. Deletes were allowed for those who did NOT have edit permissions, but deletions were blocked for those who did. !
- On the Report page, deletion didn't work and still doesn't work. This needs to be addressed, or maybe it's possible to delete reports only on the Reports page. (FIXED...)
- On the Devices page, the "canEdit.Device" permissions check was being performed, but it should be performed like this: "canEdit.Devices"
- The $action variable was not defined in \ajax\devices.php
- Added translations.
- Added a style for the disabled "Delete" button
- Minor fixes
2026-05-04 19:09:10 +03:00

124 lines
4.7 KiB
PHP

<?php
//
// ZoneMinder web monitor groups file, $Date$, $Revision$
// Copyright (C) 2001-2008 Philip Coombes
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
if ( !canView('Groups') ) {
$view = 'error';
return;
}
# This will end up with the group_id of the deepest selection
$group_id = 0;
$max_depth = 0;
$Groups = array();
foreach ( ZM\Group::find() as $Group ) {
$Groups[$Group->Id()] = $Group;
}
# This array is indexed by parent_id
$children = array();
foreach ( $Groups as $id=>$Group ) {
// From PHP 8.5, using 'null' as an array offset is deprecated
$parentID = $Group->ParentId() ?? '';
if ( ! isset( $children[$parentID] ) )
$children[$parentID] = array();
$children[$parentID][] = $Group;
if ( $max_depth < $Group->depth() )
$max_depth = $Group->depth();
}
xhtmlHeaders(__FILE__, translate('Groups'));
getBodyTopHTML();
?>
<div id="page">
<?php echo $navbar = getNavBarHTML(); ?>
<div id="content" class="row">
<div id="optionsContainer" class="col">
<form name="groupsForm" method="post" action="?">
<div id="options">
<input type="hidden" name="view" value="groups"/>
<input type="hidden" name="action" value="setgroup"/>
<div class="row">
<div class="col">
<div id="contentButtons">
<button type="button" value="New" data-on-click="newGroup"<?php echo canEdit('Groups')?'':' disabled="disabled"' ?>>
<i class="material-icons md-18">add_circle</i>
<span class="text"><?php echo translate('New') ?></span>
</button>
<button type="button" class="btn-danger" name="deleteBtn" value="Delete" data-on-click-this="deleteGroup" disabled="disabled">
<i class="material-icons md-18">delete</i>
<span class="text"><?php echo translate('Delete') ?></span>
</button>
</div>
</div> <!-- .col -->
</div> <!-- .row -->
<div class="wrapper-scroll-table">
<div class="row">
<div class="col">
<table id="contentTable" class="major table-sm table-striped">
<thead class="thead-highlight">
<tr>
<?php if ( canEdit('Groups') ) { ?>
<th class="colSelect"><?php echo translate('Mark') ?></th>
<?php } ?>
<th class="colName" colspan="<?php echo $max_depth+1 ?>"><?php echo translate('Name') ?></th>
<th class="colIds"><?php echo translate('Monitors') ?></th>
</tr>
</thead>
<tbody>
<?php
function group_line( $Group ) {
global $children;
global $max_depth;
$html = '<tr>';
if ( canEdit('Groups') ) {
$html .= '<td class="colSelect"><input type="checkbox" name="gid[]" value="'. $Group->Id() .'" data-on-click-this="configureButtons"/></td>';
}
$html .= str_repeat('<td class="colName">&nbsp;</td>', $Group->depth());
$html .= '<td class="colName" colspan="'.($max_depth-($Group->depth()-1)).'">';
if ( canEdit('Groups') ) {
$html .= '<a href="#" data-on-click-this="editGroup" data-group-id="'.$Group->Id().'">'.validHtmlStr($Group->Id().' '.$Group->Name()).'</a>';
} else {
$html .= validHtmlStr($Group->Name());
}
$html .= '</td><td class="colIds">'. validHtmlStr(monitorIdsToNames($Group->MonitorIds(), 30)).'</td>';
$html .= '</tr>';
if ( isset( $children[$Group->Id()] ) ) {
foreach ( $children[$Group->Id()] as $G ) {
$html .= group_line($G);
}
}
return $html;
}
if ( isset( $children[''] ) )
foreach ( $children[''] as $Group )
echo group_line($Group);
?>
</tbody>
</table>
</div> <!-- .col -->
</div> <!-- .row -->
</div> <!-- .wrapper-scroll-table -->
</div><!-- .options -->
</form>
</div> <!-- .col -->
</div> <!-- .row -->
</div> <!-- #page -->
<?php xhtmlFooter() ?>