function show_manage($script_id_) { $script = $_SESSION['service']->script_info($script_id_); if (!is_object($script)) { redirect('script.php'); } $can_manage_script = isAuthorized('manageNews'); page_header(); echo '<div id="script_div">'; echo '<h1><a href="?">' . _('Login Script management') . '</a> - ' . $script->name . '</h1>'; echo '<div>'; echo '<h2>' . _('Modify') . '</h2>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; if ($can_manage_script) { $os_options = array("Windows", "Linux"); $type_options = array("bash", "python", "VBS", "batch", "powershell"); echo '<form action="script.php" method="post" enctype="multipart/form-data">'; echo '<input type="hidden" name="action" value="rename" />'; echo '<input type="hidden" name="id" value="' . $script->id . '" />'; echo '<tr><td><strong>' . _('Name:') . '</strong></td><td><input type="text" name="script_name" value="' . $script->name . '" /></td></tr>'; echo '<tr><td><strong>' . _('OS:') . '</strong></td><td><select name="script_os">'; foreach ($os_options as $os_option) { echo '<option value="' . $os_option . '" '; if ($os_option == $script->os) { echo 'selected="selected"'; } echo '/>' . $os_option . '</option>'; } echo '</select></td></tr>'; echo '<tr><td><strong>' . _('Type:') . '</strong></td><td><select name="script_type" onchange="changeScriptAreaSyntax(this, \'scriptArea\')">'; foreach ($type_options as $type_option) { echo '<option value="' . $type_option . '" '; if ($type_option == $script->type) { echo 'selected="selected"'; } echo '/>' . $type_option . '</option>'; } echo '</select></td></tr>'; echo '<tr><td></td><td><textarea name="script_data" id=\'scriptArea\' cols="100" rows="20">' . $script->data . '</textarea></td></tr>'; echo '<script language="javascript" type="text/javascript"> initScriptArea(\'scriptArea\') </script>'; echo '<tr><td colspan="2">'; echo '<input type="file" name="script_file" onchange="loadFileAsText(this,\'scriptArea\')"/><BR/>'; echo '<input type="submit" value="' . _('Modify') . '" /></td></tr>'; echo '</form>'; } echo '</table>'; echo '</div>'; // User groups part $groups_mine = $script->getAttribute('groups'); $groups_partial_list = $script->getAttribute('groups_partial_list'); $usersgroupsList = new UsersGroupsList($_REQUEST); if ($groups_partial_list) { if ($usersgroupsList->is_empty_filter()) { $usersgroupsList->set_external_result($groups_mine, true); } else { $groups_mine2 = $usersgroupsList->search($login); if (is_null($groups_mine)) { die_error(_('Error while requesting User Group data'), __FILE__, __LINE__); } $groups_mine = array(); foreach ($groups_mine2 as $group) { $groups_mine[$group->id] = $group->name; } } } // do not request other groups if we do not display the 'add to' panel ... $groups_all = $usersgroupsList->search(); usort($groups_all, "usergroup_cmp"); $searchDiv = $usersgroupsList->getForm(); $groups_available = array(); foreach ($groups_all as $group) { if (!array_key_exists($group->id, $groups_mine)) { $groups_available[] = $group; } } echo '<div>'; echo '<h2>' . _('User Groups with this user') . '</h2>'; echo $searchDiv; echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($groups_mine as $group_id => $group_name) { echo '<tr><td>'; if ($can_manage_script) { echo '<a href="usersgroup.php?action=manage&id=' . $group_id . '">' . $group_name . '</a>'; } else { echo $group_name; } echo '</td>'; if ($can_manage_script) { echo '<td><form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this user from this group?') . '\');">'; echo '<input type="hidden" name="name" value="Script_UserGroup" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="group" value="' . $group_id . '" />'; echo '<input type="hidden" name="element" value="' . $script->id . '" />'; echo '<input type="submit" value="' . _('Delete from this group') . '" />'; echo '</form></td>'; } echo '</tr>'; } if (count($groups_available) > 0 and $can_manage_script) { echo '<tr><form action="actions.php" method="post"><td>'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="name" value="Script_UserGroup" />'; echo '<input type="hidden" name="element" value="' . $script->id . '" />'; echo '<select name="group">'; foreach ($groups_available as $group) { echo '<option value="' . $group->id . '" >' . $group->name . '</option>'; } echo '</select>'; echo '</td><td><input type="submit" value="' . _('Add to this group') . '" /></td>'; } echo '</form></tr>'; echo '</table>'; echo '</div>'; echo '</div>'; page_footer(); }
function show_manage($login) { $u = $_SESSION['service']->user_info($login); if (!is_object($u)) { die_error('Unable to import user "' . $login . '"', __FILE__, __LINE__); } $userdb_rw = userdb_is_writable(); $usergroupdb_rw = usergroupdb_is_writable(); $keys = array(); foreach ($u->getAttributesList() as $attr) { if (!in_array($attr, array('login', 'displayname'))) { $keys[] = $attr; } } // Users Group $groups_mine = $u->getAttribute('groups'); $groups_partial_list = $u->getAttribute('groups_partial_list'); $usersgroupsList = new UsersGroupsList($_REQUEST); if ($groups_partial_list) { if ($usersgroupsList->is_empty_filter()) { $usersgroupsList->set_external_result($groups_mine, true); } else { $groups_mine2 = $usersgroupsList->search($login); if (is_null($groups_mine)) { die_error(_('Error while requesting User Group data'), __FILE__, __LINE__); } $groups_mine = array(); foreach ($groups_mine2 as $group) { $groups_mine[$group->id] = $group->name; } } } uasort($groups_mine, 'usergroup_cmp'); $groups_available = array(); $default_group_id = null; if ($usergroupdb_rw) { // do not request other groups if we do not display the 'add to' panel ... $groups_all = $usersgroupsList->search(); usort($groups_all, "usergroup_cmp"); foreach ($groups_all as $group) { if (!array_key_exists($group->id, $groups_mine)) { $groups_available[] = $group; } if ($group->isDefault()) { $default_group_id = $group->id; } } } uasort($groups_available, 'usergroup_cmp'); // need to be after all search call! $searchDiv = $usersgroupsList->getForm(); $can_manage_users = isAuthorized('manageUsers'); $can_manage_usersgroups = isAuthorized('manageUsersGroups'); $can_manage_profiles = isAuthorized('manageSharedFolders'); $prefs_of_a_user = array(); $unuse_settings = array(); $session_prefs = array(); if ($u->hasAttribute('settings_default')) { $prefs = new Preferences_admin(null, false); $categs = $u->getAttribute('settings_default'); $categs2 = array(); if ($u->hasAttribute('settings')) { $categs2 = $u->getAttribute('settings'); } foreach ($categs as $categ => $settings) { $session_prefs[$categ] = array(); $prefs_of_a_user[$categ] = array(); $unuse_settings[$categ] = array(); foreach ($settings as $setting_id => $setting_attributes) { $p = $prefs->load_element($setting_attributes, 'general_' . $categ); $session_prefs[$categ][$setting_id] = $p; if (array_key_exists($categ, $categs2) && array_key_exists($setting_id, $categs2[$categ])) { $p2 = clone $p; $p2->content = $categs2[$categ][$setting_id]; $prefs_of_a_user[$categ][$setting_id] = $p2; } else { $unuse_settings[$categ][$setting_id] = $p; } } } } $applications = array(); if ($u->hasAttribute('applications')) { $applications = $u->getAttribute('applications'); uasort($applications, 'application_cmp'); } page_header(); echo '<div id="users_div">'; echo '<h1>' . $u->getAttribute('displayname') . '</h1>'; echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="5">'; echo '<tr class="title">'; echo '<th>' . _('Login') . '</th>'; echo '<th>' . _('Locale') . '</th>'; echo '</tr>'; echo '<tr class="content1">'; echo '<td>' . $u->getAttribute('login') . '</td>'; echo '<td>' . $u->getAttribute('locale') . '</td>'; echo '</tr>'; echo '</table>'; if ($userdb_rw and $can_manage_users) { echo '<div>'; echo '<h2>' . _('Settings') . '</h2>'; echo '<div>'; echo '<form action="actions.php" onsubmit="return confirm(\'' . _('Are you sure you want to delete this user?') . '\');">'; echo '<input type="submit" value="' . _('Delete this user') . '"/>'; echo '<input type="hidden" name="name" value="User" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="checked_users[]" value="' . htmlspecialchars($login) . '" />'; echo '</form>'; echo '</div>'; echo '<br/><br/>'; echo '<div>'; echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="User" />'; echo '<input type="hidden" name="action" value="modify" />'; echo '<input type="hidden" name="id" value="' . htmlspecialchars($login) . '" />'; echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="5">'; $count = 0; $content = 'content' . ($count++ % 2 == 0 ? 1 : 2); echo '<tr class="' . $content . '">'; echo '<th>' . _('Display name') . '</th>'; echo '<td><input type="text" name="displayname" value="' . htmlspecialchars($u->getAttribute('displayname')) . '" /></td>'; echo '</tr>'; if ($u->hasAttribute('password')) { $content = 'content' . ($count++ % 2 == 0 ? 1 : 2); echo '<tr class="' . $content . '">'; echo '<th>' . _('New password') . '</th>'; echo '<td><input type="password" name="password" value="" /></td>'; echo '</tr>'; } $content = 'content' . ($count % 2 == 0 ? 1 : 2); echo '<tr class="' . $content . '">'; echo '<td colspan="2">'; echo '<input type="submit" name="modify" value="' . _('Save changes') . '" />'; echo '</td>'; echo '</tr>'; echo '</table>'; echo '</form>'; echo '</div>'; } // User groups part if (count($groups_mine) > 0 or !$usersgroupsList->is_empty_filter() or $usergroupdb_rw and count($groups_all) > 0) { echo '<div>'; echo '<h2>' . _('User Groups with this user') . '</h2>'; echo $searchDiv; echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($groups_mine as $group_id => $group_name) { echo '<tr><td>'; if ($can_manage_usersgroups) { echo '<a href="usersgroup.php?action=manage&id=' . $group_id . '">' . $group_name . '</a>'; } else { echo $group_name; } echo '</td>'; if ($usergroupdb_rw and $can_manage_usersgroups and $group_id != $default_group_id) { echo '<td><form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this user from this group?') . '\');">'; echo '<input type="hidden" name="name" value="User_UserGroup" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="group" value="' . $group_id . '" />'; echo '<input type="hidden" name="element" value="' . htmlspecialchars($login) . '" />'; echo '<input type="submit" value="' . _('Delete from this group') . '" />'; echo '</form></td>'; } echo '</tr>'; } if (count($groups_available) > 0 && $usergroupdb_rw and $can_manage_usersgroups) { echo '<tr><form action="actions.php" method="post"><td>'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="name" value="User_UserGroup" />'; echo '<input type="hidden" name="element" value="' . htmlspecialchars($login) . '" />'; echo '<select name="group">'; foreach ($groups_available as $group) { echo '<option value="' . $group->id . '" >' . $group->name . '</option>'; } echo '</select>'; echo '</td><td><input type="submit" value="' . _('Add to this group') . '" /></td>'; echo '</form></tr>'; } echo '</table>'; echo "</div>\n"; } $apps_s = array(); if (count($applications) > 0) { echo '<br />'; echo '<h2>' . _('Published Applications') . '</h2>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($applications as $application_id => $application_name) { echo '<tr>'; echo '<td><img class="icon32" src="media/image/cache.php?id=' . $application_id . '" alt="" title="" /></td>'; echo '<td><a href="applications.php?action=manage&id=' . $application_id . '">' . $application_name . '</a></td>'; echo '</tr>'; } echo '</table>'; } echo '<h2>'; echo _('Session Settings configuration'); echo '</h2>'; if ($prefs_of_a_user != array()) { foreach ($prefs_of_a_user as $container => $prefs_of_a_user_value) { echo '<fieldset class="prefssessionusergroup">'; echo '<legend>' . $prefs->getPrettyName('general_' . $container) . '</legend>'; echo '<form action="actions.php" method="post">'; $key_name = 'general'; echo '<input type="hidden" name="container" value="' . $container . '" />'; // from admin/functions.inc.php $color = 0; if (count($prefs_of_a_user_value) != 0) { echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="3" style="margin-bottom: 10px;">'; // TODO echo '<tr class="title">'; echo '<th>' . _('Name') . '</th>'; echo '<th>' . _('Default value') . '</th>'; echo '<th>' . _('Value') . '</th>'; echo '<th>' . _('Action') . '</th>'; echo '<tr>'; foreach ($prefs_of_a_user_value as $element_key => $config_element) { echo '<tr class="content' . ($color % 2 + 1) . '">'; echo '<td style="width: 250px;">'; echo '<span onmouseover="showInfoBulle(\'' . str_replace("'", "’", $config_element->description_detailed) . '\'); return false;" onmouseout="hideInfoBulle(); return false;">' . $config_element->label . '</span>'; echo '<td>'; $default_element = $session_prefs[$container][$config_element->id]; $default_element->setFormSeparator('NaN'); // it must be different of ___ $default_element->setPath(array('key_name' => $key_name, 'container' => $container, 'element_id' => $config_element->id)); echo $default_element->toHTML(true); echo '</td>'; echo '</td>'; echo '<td style="padding: 3px;">'; print_element($key_name, $container, $element_key, $config_element); echo '</td>'; echo '<td>'; echo '<input type="button" value="' . _('Remove this overridden setting') . '" onclick="user_settings_remove(\'' . $u->getAttribute('login') . '\',\'' . $container . '\',\'' . $config_element->id . '\'); return false;"/>'; echo '</td>'; echo '</tr>'; $color++; } // end from echo '<tr class="content' . ($color % 2 + 1) . '">'; echo '<td colspan="3"></td>'; echo '<td>'; echo '<input type="hidden" name="name" value="User_settings" />'; echo '<input type="hidden" name="container" value="' . $container . '" />'; echo '<input type="hidden" name="unique_id" value="' . $u->getAttribute('login') . '" />'; echo '<input type="hidden" name="action" value="modify" />'; echo '<input type="submit" value="' . _('Save settings') . '" />'; echo '</td>'; echo '</tr>'; echo '</table>'; echo '</form>'; } if ($unuse_settings[$container] != array()) { echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="User_settings" />'; echo '<input type="hidden" name="container" value="' . $container . '" />'; echo '<input type="hidden" name="unique_id" value="' . $u->getAttribute('login') . '" />'; echo '<input type="hidden" name="action" value="add" />'; echo '<select name="element_id">'; foreach ($unuse_settings[$container] as $setting_name => $setting_content) { echo '<option value="' . $setting_name . '" >' . $setting_content->label . '</option>'; } echo '</select>'; echo ' '; echo '<input type="submit" value="' . _('Add this setting') . '" />'; echo '</form>'; } echo '</fieldset>'; } } echo '</div>'; // Session settings configuration echo "\n\n\n"; if ($u->hasAttribute('sessions') && count($u->getAttribute('sessions')) > 0) { echo '<div>'; echo '<h2>' . _('Active sessions') . '</h2>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($u->getAttribute('sessions') as $session_id => $session_start_time) { echo '<tr>'; echo '<td>'; if (!$session_start_time) { echo _('Not started yet'); } else { echo @date('d/m/Y H:i:s', $session_start_time); } echo '</td>'; echo '<td><a href="sessions.php?info=' . $session_id . '">' . $session_id . '</td>'; echo '<td></td>'; echo '<td>'; echo '<form action="sessions.php">'; echo '<input type="hidden" name="info" value="' . $session_id . '" />'; echo '<input type="submit" value="' . _('Information about this session') . '" />'; echo '</form>'; echo '</td>'; echo '</tr>'; } echo '</table>'; echo '</div>'; } $use_profiles = false; $settings = $u->getAttribute('settings'); $settings = $settings['session_settings_defaults']; if (array_key_exists('enable_profiles', $settings)) { if ($settings['enable_profiles']['value'] == 1) { $use_profiles = true; } } else { $settings = $u->getAttribute('settings_default'); $settings = $settings['session_settings_defaults']; if (array_key_exists('enable_profiles', $settings)) { if ($settings['enable_profiles']['value'] == 1) { $use_profiles = true; } } } if ($use_profiles) { echo '<div>'; echo '<h2>' . _('Profile') . '</h2>'; if (!$u->hasAttribute('profiles')) { echo '<p>'; echo _('This user doesn\'t have a user profile'); echo '</p>'; if ($can_manage_profiles) { echo '<div>'; echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to create a profile for this user?') . '\');">'; echo '<input type="hidden" name="name" value="Profile" />'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="users[]" value="' . $u->getAttribute('login') . '" />'; echo '<input type="submit" value="' . _('Create a profile') . '" />'; echo '</form>'; echo '</div>'; } } else { foreach ($u->getAttribute('profiles') as $profile_id => $profile_info) { echo '<p>'; echo str_replace('%SERVER%', '<a href="servers.php?action=manage&id=' . $profile_info['server_id'] . '"> ' . $profile_info['server_name'] . '</a>', _('User has profile stored on server %SERVER%.')); echo '</p>'; if ($can_manage_profiles) { echo '<div>'; echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this profile?') . '\');">'; echo '<input type="hidden" name="name" value="Profile" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="ids[]" value="' . $profile_id . '" />'; echo '<input type="submit" value="' . _('Delete this profile') . '" />'; echo '</form>'; echo '</div>'; } } } echo '</div>'; } echo '</div>'; page_footer(); die; }