1<?php
2/**
3 * @package     Joomla.Administrator
4 * @subpackage  Template.hathor
5 *
6 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
7 * @license     GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10defined('_JEXEC') or die;
11
12// Include the component HTML helpers.
13JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
14
15JHtml::_('behavior.multiselect');
16
17$user      = JFactory::getUser();
18$listOrder = $this->escape($this->state->get('list.ordering'));
19$listDirn  = $this->escape($this->state->get('list.direction'));
20
21JText::script('COM_USERS_GROUPS_CONFIRM_DELETE');
22
23$groupsWithUsers = array();
24
25foreach ($this->items as $i => $item)
26{
27	if ($item->user_count > 0)
28	{
29		$groupsWithUsers[] = $i;
30	}
31}
32JFactory::getDocument()->addScriptDeclaration('
33		Joomla.submitbutton = function(task) {
34			if (task == "groups.delete") {
35				var f = document.adminForm;
36				var cb = "";
37				var groupsWithUsers = [' . implode(',', $groupsWithUsers) . '];
38				for (index = 0; index < groupsWithUsers.length; ++index) {
39					cb = f["cb" + groupsWithUsers[index]];
40					if (cb && cb.checked) {
41						if (confirm(Joomla.JText._("COM_USERS_GROUPS_CONFIRM_DELETE"))) {
42							Joomla.submitform(task);
43						}
44						return;
45					}
46				}
47			}
48			Joomla.submitform(task);
49		};
50');
51?>
52<form action="<?php echo JRoute::_('index.php?option=com_users&view=groups');?>" method="post" name="adminForm" id="adminForm">
53<?php if (!empty( $this->sidebar)) : ?>
54	<div id="j-sidebar-container" class="span2">
55		<?php echo $this->sidebar; ?>
56	</div>
57	<div id="j-main-container" class="span10">
58<?php else : ?>
59	<div id="j-main-container">
60<?php endif;?>
61	<fieldset id="filter-bar">
62	<legend class="element-invisible"><?php echo JText::_('COM_USERS_SEARCH_GROUPS_LABEL'); ?></legend>
63		<div class="filter-search">
64			<label class="filter-search-lbl" for="filter_search"><?php echo JText::_('COM_USERS_SEARCH_GROUPS_LABEL'); ?></label>
65			<input type="text" name="filter_search" id="filter_search" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" title="<?php echo JText::_('COM_USERS_SEARCH_IN_GROUPS'); ?>" />
66			<button type="submit"><?php echo JText::_('JSEARCH_FILTER_SUBMIT'); ?></button>
67			<button type="button" onclick="document.getElementById('filter_search').value='';this.form.submit();"><?php echo JText::_('JSEARCH_FILTER_CLEAR'); ?></button>
68		</div>
69	</fieldset>
70	<div class="clr"> </div>
71
72	<table class="adminlist">
73		<thead>
74			<tr>
75				<th class="checkmark-col">
76					<input type="checkbox" name="checkall-toggle" value="" title="<?php echo JText::_('JGLOBAL_CHECK_ALL'); ?>" onclick="Joomla.checkAll(this)" />
77				</th>
78				<th class="title">
79					<?php echo JText::_('COM_USERS_HEADING_GROUP_TITLE'); ?>
80				</th>
81				<th class="width-10">
82					<?php echo JText::_('COM_USERS_HEADING_USERS_IN_GROUP'); ?>
83				</th>
84				<th class="nowrap id-col">
85					<?php echo JText::_('JGRID_HEADING_ID'); ?>
86				</th>
87			</tr>
88		</thead>
89
90		<tbody>
91		<?php foreach ($this->items as $i => $item) :
92			$canCreate = $user->authorise('core.create', 'com_users');
93			$canEdit   = $user->authorise('core.edit',   'com_users');
94			// If this group is super admin and this user is not super admin, $canEdit is false
95			if (!$user->authorise('core.admin') && JAccess::checkGroup($item->id, 'core.admin'))
96			{
97				$canEdit = false;
98			}
99			$canChange = $user->authorise('core.edit.state',	'com_users');
100		?>
101			<tr class="row<?php echo $i % 2; ?>">
102				<td>
103					<?php if ($canEdit) : ?>
104						<?php echo JHtml::_('grid.id', $i, $item->id); ?>
105					<?php endif; ?>
106				</td>
107				<td>
108					<?php echo str_repeat('<span class="gi">|&mdash;</span>', $item->level) ?>
109					<?php if ($canEdit) : ?>
110					<a href="<?php echo JRoute::_('index.php?option=com_users&task=group.edit&id='.$item->id);?>">
111						<?php echo $this->escape($item->title); ?></a>
112					<?php else : ?>
113						<?php echo $this->escape($item->title); ?>
114					<?php endif; ?>
115					<?php if (JDEBUG) : ?>
116						<div class="fltrt"><div class="button2-left smallsub"><div class="blank"><a href="<?php echo JRoute::_('index.php?option=com_users&view=debuggroup&group_id='.(int) $item->id);?>">
117						<?php echo JText::_('COM_USERS_DEBUG_GROUP');?></a></div></div></div>
118					<?php endif; ?>
119				</td>
120				<td class="center">
121					<?php echo $item->user_count ?: ''; ?>
122				</td>
123				<td class="center">
124					<?php echo (int) $item->id; ?>
125				</td>
126			</tr>
127			<?php endforeach; ?>
128		</tbody>
129	</table>
130
131	<?php echo $this->pagination->getListFooter(); ?>
132
133	<input type="hidden" name="task" value="" />
134	<input type="hidden" name="boxchecked" value="0" />
135	<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
136	<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
137	<?php echo JHtml::_('form.token'); ?>
138</div>
139</form>
140