'
. sprintf(__('Users of \'%s\' user group'), htmlspecialchars($userGroup))
. '';
$cfgRelation = $relation->getRelationsParam();
$usersTable = Util::backquote($cfgRelation['db'])
. "." . Util::backquote($cfgRelation['users']);
$sql_query = "SELECT `username` FROM " . $usersTable
. " WHERE `usergroup`='" . $GLOBALS['dbi']->escapeString($userGroup)
. "'";
$result = $relation->queryAsControlUser($sql_query, false);
if ($result) {
if ($GLOBALS['dbi']->numRows($result) == 0) {
$html_output .= '
'
. __('No users were found belonging to this user group.')
. '
';
} else {
$html_output .= ''
. '| # | ' . __('User') . ' |
'
. '';
$i = 0;
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
$i++;
$html_output .= ''
. '| ' . $i . ' | '
. '' . htmlspecialchars($row[0]) . ' | '
. '
';
}
$html_output .= ''
. '
';
}
}
$GLOBALS['dbi']->freeResult($result);
return $html_output;
}
/**
* Returns HTML for the 'user groups' table
*
* @return string HTML for the 'user groups' table
*/
public static function getHtmlForUserGroupsTable()
{
$relation = new Relation($GLOBALS['dbi']);
$html_output = '' . __('User groups') . '
';
$cfgRelation = $relation->getRelationsParam();
$groupTable = Util::backquote($cfgRelation['db'])
. "." . Util::backquote($cfgRelation['usergroups']);
$sql_query = "SELECT * FROM " . $groupTable . " ORDER BY `usergroup` ASC";
$result = $relation->queryAsControlUser($sql_query, false);
if ($result && $GLOBALS['dbi']->numRows($result)) {
$html_output .= '';
}
$GLOBALS['dbi']->freeResult($result);
$html_output .= '';
return $html_output;
}
/**
* Returns the list of allowed menu tab names
* based on a data row from usergroup table.
*
* @param array $row row of usergroup table
* @param string $level 'server', 'db' or 'table'
*
* @return string comma separated list of allowed menu tab names
*/
public static function getAllowedTabNames(array $row, $level)
{
$tabNames = [];
$tabs = Util::getMenuTabList($level);
foreach ($tabs as $tab => $tabName) {
if (! isset($row[$level . '_' . $tab])
|| $row[$level . '_' . $tab] == 'Y'
) {
$tabNames[] = $tabName;
}
}
return implode(', ', $tabNames);
}
/**
* Deletes a user group
*
* @param string $userGroup user group name
*
* @return void
*/
public static function delete($userGroup)
{
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
$userTable = Util::backquote($cfgRelation['db'])
. "." . Util::backquote($cfgRelation['users']);
$groupTable = Util::backquote($cfgRelation['db'])
. "." . Util::backquote($cfgRelation['usergroups']);
$sql_query = "DELETE FROM " . $userTable
. " WHERE `usergroup`='" . $GLOBALS['dbi']->escapeString($userGroup)
. "'";
$relation->queryAsControlUser($sql_query, true);
$sql_query = "DELETE FROM " . $groupTable
. " WHERE `usergroup`='" . $GLOBALS['dbi']->escapeString($userGroup)
. "'";
$relation->queryAsControlUser($sql_query, true);
}
/**
* Returns HTML for add/edit user group dialog
*
* @param string $userGroup name of the user group in case of editing
*
* @return string HTML for add/edit user group dialog
*/
public static function getHtmlToEditUserGroup($userGroup = null)
{
$relation = new Relation($GLOBALS['dbi']);
$html_output = '';
if ($userGroup == null) {
$html_output .= '' . __('Add user group') . '
';
} else {
$html_output .= ''
. sprintf(__('Edit user group: \'%s\''), htmlspecialchars($userGroup))
. '
';
}
$html_output .= '