2008-07-14 21:54:50 +08:00
|
|
|
<?php
|
|
|
|
//
|
|
|
|
// ZoneMinder web monitor groups file, $Date$, $Revision$
|
2008-07-25 17:48:16 +08:00
|
|
|
// Copyright (C) 2001-2008 Philip Coombes
|
2008-07-14 21:54:50 +08:00
|
|
|
//
|
|
|
|
// 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
|
2016-12-26 23:23:16 +08:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2008-07-14 21:54:50 +08:00
|
|
|
//
|
|
|
|
|
2018-01-13 03:25:15 +08:00
|
|
|
if ( !canView('Groups') ) {
|
2017-10-01 02:19:32 +08:00
|
|
|
$view = 'error';
|
|
|
|
return;
|
2015-08-16 01:01:57 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2017-10-10 22:38:13 +08:00
|
|
|
# This will end up with the group_id of the deepest selection
|
2017-10-05 04:40:09 +08:00
|
|
|
$group_id = 0;
|
|
|
|
$max_depth = 0;
|
|
|
|
|
|
|
|
$Groups = array();
|
2019-02-22 22:19:07 +08:00
|
|
|
foreach ( ZM\Group::find() as $Group ) {
|
2017-10-05 04:40:09 +08:00
|
|
|
$Groups[$Group->Id()] = $Group;
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-10-05 04:40:09 +08:00
|
|
|
# This array is indexed by parent_id
|
|
|
|
$children = array();
|
|
|
|
foreach ( $Groups as $id=>$Group ) {
|
|
|
|
if ( ! isset( $children[$Group->ParentId()] ) )
|
|
|
|
$children[$Group->ParentId()] = array();
|
|
|
|
$children[$Group->ParentId()][] = $Group;
|
|
|
|
if ( $max_depth < $Group->depth() )
|
|
|
|
$max_depth = $Group->depth();
|
|
|
|
}
|
2018-09-08 04:31:11 +08:00
|
|
|
xhtmlHeaders(__FILE__, translate('Groups'));
|
2008-07-14 21:54:50 +08:00
|
|
|
?>
|
|
|
|
<body>
|
|
|
|
<div id="page">
|
2017-10-01 02:19:32 +08:00
|
|
|
<?php echo $navbar = getNavBarHTML(); ?>
|
2008-07-14 21:54:50 +08:00
|
|
|
<div id="content">
|
2019-02-10 13:39:19 +08:00
|
|
|
<form name="groupsForm" method="get" action="?">
|
2008-07-14 21:54:50 +08:00
|
|
|
<input type="hidden" name="view" value="none"/>
|
|
|
|
<input type="hidden" name="action" value="setgroup"/>
|
2017-10-05 04:40:09 +08:00
|
|
|
<table id="contentTable" class="major">
|
2018-03-26 23:14:46 +08:00
|
|
|
<thead class="thead-highlight">
|
2008-07-14 21:54:50 +08:00
|
|
|
<tr>
|
2018-12-24 22:40:23 +08:00
|
|
|
<th class="colName" colspan="<?php echo $max_depth+1 ?>"><?php echo translate('Name') ?></th>
|
2017-10-01 02:19:32 +08:00
|
|
|
<th class="colIds"><?php echo translate('Monitors') ?></th>
|
2019-09-29 00:58:01 +08:00
|
|
|
<?php if ( canEdit('Groups') ) { ?>
|
2017-10-01 02:19:32 +08:00
|
|
|
<th class="colSelect"><?php echo translate('Mark') ?></th>
|
2019-09-29 00:58:01 +08:00
|
|
|
<?php } ?>
|
2008-07-14 21:54:50 +08:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2017-10-01 02:19:32 +08:00
|
|
|
<?php
|
2017-10-05 04:40:09 +08:00
|
|
|
function group_line( $Group ) {
|
|
|
|
global $children;
|
|
|
|
global $max_depth;
|
|
|
|
$html = '<tr>';
|
2018-09-08 04:31:11 +08:00
|
|
|
$html .= str_repeat('<td class="colName"> </td>', $Group->depth());
|
2017-10-05 04:40:09 +08:00
|
|
|
$html .= '<td class="colName" colspan="'.($max_depth-($Group->depth()-1)).'">';
|
2017-10-01 02:19:32 +08:00
|
|
|
if ( canEdit('Groups') ) {
|
2020-04-03 02:13:28 +08:00
|
|
|
$html .= '<a href="#" data-on-click-this="editGroup" data-group-id="'.$Group->Id().'">'.validHtmlStr($Group->Id().' '.$Group->Name()).'</a>';
|
2017-10-01 02:19:32 +08:00
|
|
|
} else {
|
2017-10-05 04:40:09 +08:00
|
|
|
$html .= validHtmlStr($Group->Name());
|
2017-10-01 02:19:32 +08:00
|
|
|
}
|
2020-04-10 23:05:19 +08:00
|
|
|
$html .= '</td><td class="colIds">'. validHtmlStr(monitorIdsToNames($Group->MonitorIds(), 30)).'</td>';
|
2019-09-29 00:58:01 +08:00
|
|
|
if ( canEdit('Groups') ) {
|
|
|
|
$html .= '<td class="colSelect"><input type="checkbox" name="gid[]" value="'. $Group->Id() .'" data-on-click-this="configureButtons"/></td>';
|
|
|
|
}
|
|
|
|
$html .= '</tr>';
|
2017-10-05 04:40:09 +08:00
|
|
|
if ( isset( $children[$Group->Id()] ) ) {
|
|
|
|
foreach ( $children[$Group->Id()] as $G ) {
|
2018-09-08 04:31:11 +08:00
|
|
|
$html .= group_line($G);
|
2017-10-05 04:40:09 +08:00
|
|
|
}
|
2017-10-01 02:19:32 +08:00
|
|
|
}
|
2017-10-05 04:40:09 +08:00
|
|
|
return $html;
|
|
|
|
}
|
2017-10-10 22:38:13 +08:00
|
|
|
if ( isset( $children[null] ) )
|
|
|
|
foreach ( $children[null] as $Group )
|
2018-09-08 04:31:11 +08:00
|
|
|
echo group_line($Group);
|
2017-10-01 02:19:32 +08:00
|
|
|
?>
|
2008-07-14 21:54:50 +08:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<div id="contentButtons">
|
2019-01-16 22:59:58 +08:00
|
|
|
<button type="button" value="New" data-on-click="newGroup"<?php echo canEdit('Groups')?'':' disabled="disabled"' ?>>
|
2018-09-08 04:31:11 +08:00
|
|
|
<?php echo translate('New') ?>
|
|
|
|
</button>
|
2019-01-16 22:59:58 +08:00
|
|
|
<button type="button" name="deleteBtn" value="Delete" data-on-click-this="deleteGroup" disabled="disabled">
|
2018-09-08 04:31:11 +08:00
|
|
|
<?php echo translate('Delete') ?>
|
|
|
|
</button>
|
2008-07-14 21:54:50 +08:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-09-03 06:17:12 +08:00
|
|
|
<?php xhtmlFooter() ?>
|