public function appsGroups() { Logger::debug('main', 'USER::appsGroups'); $apps_group_list = array(); $ApplicationsGroupDB = ApplicationsGroupDB::getInstance(); $UserGroupDB = UserGroupDB::getInstance(); $publications = Abstract_Liaison::load('UsersGroupApplicationsGroup', NULL, NULL); $users_group_id = array(); foreach ($publications as $publication) { if (in_array($publication->element, $users_group_id)) { continue; } $users_group_id[] = $publication->element; } // from this group, which are these I am into $users_groups_mine_ids = $this->get_my_usersgroups_from_list($users_group_id); foreach ($publications as $publication) { if (!in_array($publication->element, $users_groups_mine_ids)) { continue; } if (in_array($publication->group, $apps_group_list)) { continue; } $g = $ApplicationsGroupDB->import($publication->group); if (!is_object($g)) { continue; } if (!$g->published) { continue; } array_push($apps_group_list, $publication->group); } return array_unique($apps_group_list); }
public function serverGroups() { Logger::debug('main', 'USERSGROUP::serversGroups (for id=' . $this->getUniqueID() . ')'); $ApplicationsGroupDB = ApplicationsGroupDB::getInstance(); $groups = Abstract_Liaison::load('UsersGroupServersGroup', $this->getUniqueID(), NULL); if (!is_array($groups)) { Logger::error('main', 'USERSGROUP::serversGroups (for id=' . $this->getUniqueID() . ') result query is false'); return NULL; } $result = array(); foreach ($groups as $UGAG_liaison) { $g = Abstract_ServersGroup::load($UGAG_liaison->group); if (is_object($g)) { $result[$UGAG_liaison->group] = $g; } } return $result; }
function show_default() { $applicationsGroupDB = ApplicationsGroupDB::getInstance(); $publications = array(); $groups_apps = $applicationsGroupDB->getList(true); if (is_null($groups_apps)) { $groups_apps = array(); } foreach ($groups_apps as $i => $group_apps) { if (!$group_apps->published) { unset($groups_apps[$i]); } } $usergroupdb = UserGroupDB::getInstance(); $groups_users = $usergroupdb->getList(true); foreach ($groups_users as $i => $group_users) { if (!$group_users->published) { unset($groups_users[$i]); } } // Starts from the applications groups instead of users groups because // it's possible to not be able to have the complete users groups list (LDAP) foreach ($groups_apps as $group_apps) { foreach ($group_apps->userGroups() as $group_users) { if (!$group_users->published) { continue; } $publications[] = array('user' => $group_users, 'app' => $group_apps); } } $has_publish = count($publications); $can_add_publish = true; if (count($groups_users) == 0) { $can_add_publish = false; } elseif (count($groups_apps) == 0) { $can_add_publish = false; } elseif (count($groups_users) * count($groups_apps) <= count($publications)) { $can_add_publish = false; } $count = 0; $can_manage_publications = isAuthorized('managePublications'); page_header(array('js_files' => array('media/script/publication.js'))); echo '<div>'; echo '<h1>' . _('Publications') . '</h1>'; echo '<table class="main_sub sortable" id="publications_list_table" border="0" cellspacing="1" cellpadding="5">'; echo '<thead>'; echo '<tr class="title">'; echo '<th>' . _('Users group') . '</th>'; echo '<th>' . _('Applications group') . '</th>'; echo '</tr>'; echo '</thead>'; echo '<tbody>'; if (!$has_publish) { $content = 'content' . ($count++ % 2 == 0 ? 1 : 2); echo '<tr class="' . $content . '"><td colspan="3">' . _('No publication') . '</td></tr>'; } else { foreach ($publications as $publication) { $content = 'content' . ($count++ % 2 == 0 ? 1 : 2); $group_u = $publication['user']; $group_a = $publication['app']; echo '<tr class="' . $content . '">'; echo '<td><a href="usersgroup.php?action=manage&id=' . $group_u->getUniqueID() . '">' . $group_u->name . '</a></td>'; echo '<td><a href="appsgroup.php?action=manage&id=' . $group_a->id . '">' . $group_a->name . '</a></td>'; if ($can_manage_publications) { echo '<td><form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this publication?') . '\');"><div>'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="name" value="Publication" />'; echo '<input type="hidden" name="group_a" value="' . $group_a->id . '" />'; echo '<input type="hidden" name="group_u" value="' . $group_u->getUniqueID() . '" />'; echo '<input type="submit" value="' . _('Delete') . '"/>'; echo '</div></form></td>'; } echo '</tr>'; } } echo '</tbody>'; $nb_groups_apps = count($groups_apps); $nb_groups_users = count($groups_users); if ($can_add_publish and $can_manage_publications) { $content = 'content' . ($count++ % 2 == 0 ? 1 : 2); echo '<tfoot>'; echo '<tr class="' . $content . '">'; echo '<td>'; echo '<select id="select_group_u" name="group_u" onchange="ovdsm_publication_hook_select(this)" style="width: 100%;">'; echo '<option value="">*</option>'; foreach ($groups_users as $group_users) { if (count($group_users->appsGroups()) < $nb_groups_apps) { echo '<option value="' . $group_users->getUniqueID() . '" >' . $group_users->name . '</option>'; } } echo '</select>'; echo '</td>'; echo '<td>'; echo '<select id="select_group_a" name="group_a" onchange="ovdsm_publication_hook_select(this)" style="width: 100%;">'; echo '<option value="" >*</option>'; foreach ($groups_apps as $group_apps) { if (count($group_apps->userGroups()) < $nb_groups_users) { echo '<option value="' . $group_apps->id . '" >' . $group_apps->name . '</option>'; } } echo '</select>'; echo '</td><td>'; echo '<form action="actions.php" method="post" ><div>'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="name" value="Publication" />'; echo '<input type="hidden" name="group_u" value="" id="input_group_u" />'; echo '<input type="hidden" name="group_a" value="" id="input_group_a" />'; echo '<input type="button" value="' . _('Add') . '" onclick="if($(\'input_group_u\').value == \'\') {alert(\'' . addslashes(_('Please select an users group')) . '\'); return;} if($(\'input_group_a\').value == \'\') {alert(\'' . addslashes(_('Please select an applications group')) . '\'); return;} this.form.submit();" />'; echo '</div></form>'; echo '</td>'; echo '</tr>'; echo '</tfoot>'; } echo '</table>'; echo '<br /><br /><br />'; echo '</div>'; echo '</div>'; page_footer(); }
function show_manage($id, $applicationDB) { global $types; $applicationsGroupDB = ApplicationsGroupDB::getInstance(); $app = $applicationDB->import($id); if (!is_object($app)) { return false; } $is_rw = $applicationDB->isWriteable(); $can_manage_applications = isAuthorized('manageApplications'); // App groups $appgroups = $applicationsGroupDB->getList(); $groups_id = array(); $liaisons = Abstract_Liaison::load('AppsGroup', $app->getAttribute('id'), NULL); foreach ($liaisons as $liaison) { $groups_id[] = $liaison->group; } $groups = array(); $groups_available = array(); foreach ($appgroups as $group) { if (in_array($group->id, $groups_id)) { $groups[] = $group; } else { $groups_available[] = $group; } } $servers_all = Abstract_Server::load_available_by_role(Server::SERVER_ROLE_APS, true); $liaisons = Abstract_Liaison::load('ApplicationServer', $app->getAttribute('id'), NULL); $servers_id = array(); foreach ($liaisons as $liaison) { $servers_id[] = $liaison->group; } $servers = array(); $servers_available = array(); foreach ($servers_all as $server) { if (in_array($server->fqdn, $servers_id)) { $servers[] = $server; } elseif (!$server->isOnline()) { continue; } elseif ($server->type != $app->getAttribute('type')) { continue; } else { $servers_available[] = $server; } } $mimes = $applicationDB->getAllMimeTypes(); $mimeliste1 = $app->getMimeTypes(); $mimeliste2 = array(); foreach ($mimes as $mime) { if (!in_array($mime, $mimeliste1)) { $mimeliste2[] = $mime; } } $can_manage_server = isAuthorized('manageServers'); page_header(); echo '<div>'; echo '<h1><img src="media/image/cache.php?id=' . $app->getAttribute('id') . '" alt="" title="" /> ' . $app->getAttribute('name') . '</h1>'; echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="3">'; echo '<tr class="title">'; // echo '<th>'._('Package').'</th>'; echo '<th>' . _('Type') . '</th>'; echo '<th>' . _('Description') . '</th>'; echo '<th>' . _('Command') . '</th>'; if ($is_rw and $can_manage_applications) { echo '<th></th>'; } echo '</tr>'; echo '<tr class="content1">'; // echo '<td>'.$app->getAttribute('package').'</td>'; echo '<td style="text-align: center;"><img src="media/image/server-' . $app->getAttribute('type') . '.png" alt="' . $app->getAttribute('type') . '" title="' . $app->getAttribute('type') . '" /><br />' . $app->getAttribute('type') . '</td>'; echo '<td>' . $app->getAttribute('description') . '</td>'; echo '<td>'; echo $app->getAttribute('executable_path'); echo '</td>'; if ($is_rw and $can_manage_applications) { echo '<td>'; echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this application?') . '\');">'; echo '<input type="hidden" name="name" value="Application_static" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="checked_applications[]" value="' . $app->getAttribute('id') . '" />'; echo '<input type="submit" value="' . _('Delete') . '" />'; echo '</form>'; echo '</td>'; } echo '</tr>'; echo '</table>'; if ($is_rw and $can_manage_applications) { echo '<br />'; echo '<form action="actions.php" method="post"">'; echo '<input type="hidden" name="name" value="Application" />'; echo '<input type="hidden" name="action" value="clone" />'; echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />'; echo '<input type="submit" value="' . _('Clone to new application') . '"/>'; echo '</form>'; echo '<br />'; echo '<h2>' . _('Modify') . '</h2>'; echo '<div id="application_modify">'; echo '<form id="delete_icon" action="actions.php" method="post" style="display: none;">'; echo '<input type="hidden" name="name" value="Application_static" />'; echo '<input type="hidden" name="action" value="del_icon" />'; echo '<input type="hidden" name="checked_applications[]" value="' . $app->getAttribute('id') . '" />'; echo '</form>'; echo '<form action="actions.php" method="post" enctype="multipart/form-data" >'; // form A echo '<input type="hidden" name="name" value="Application_static" />'; echo '<input type="hidden" name="action" value="modify" />'; echo '<input type="hidden" name="published" value="1" />'; echo '<input type="hidden" name="static" value="1" />'; echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />'; echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="5">'; $count = 1; $app->setAttribute('application_name', $app->getAttribute('name')); // ugly hack $app->unsetAttribute('name'); $attr_list = $app->getAttributesList(); foreach ($attr_list as $k => $v) { if (in_array($v, array('id', 'type', 'static', 'published', 'desktopfile', 'package', 'revision'))) { unset($attr_list[$k]); } } asort($attr_list); foreach ($attr_list as $attr_name) { $content = 'content' . ($count++ % 2 == 0 ? 1 : 2); echo '<tr class="' . $content . '">'; echo '<td style="text-transform: capitalize;">'; if ($attr_name == 'executable_path') { echo _('Command'); } else { if ($attr_name == 'application_name') { echo _('Name'); } else { echo _($attr_name); } } echo '</td>'; echo '<td>'; echo '<input type="text" name="' . $attr_name . '" value="' . htmlspecialchars($app->getAttribute($attr_name)) . '" style="with:100%;"/>'; echo '<input type="hidden" name="attributes_send[]" value="' . $attr_name . '" />'; echo '</td>'; echo '</tr>'; } if (get_classes_startwith('Imagick') != array()) { $content = 'content' . ($count++ % 2 == 0 ? 1 : 2); echo '<tr class="' . $content . '">'; echo '<td>' . _('Icon') . '</td>'; echo '<td>'; if ($app->getIconPath() != $app->getDefaultIconPath() && file_exists($app->getIconPath())) { echo '<img src="media/image/cache.php?id=' . $app->getAttribute('id') . '" alt="" title="" /> '; echo '<input type="button" value="' . _('Delete this icon') . '" onclick="return confirm(\'' . _('Are you sure you want to delete this icon?') . '\') && $(\'delete_icon\').submit();"/>'; echo '<br />'; } echo '<input type="file" name="file_icon" /> '; echo '</td>'; echo '</tr>'; } else { Logger::info('main', 'No Imagick support found'); } $content = 'content' . ($count++ % 2 == 0 ? 1 : 2); echo '<tr class="' . $content . '">'; echo '<td colspan="2">'; echo '<input type="submit" value="' . _('Modify') . '" />'; echo '</td>'; echo '</tr>'; echo '</table>'; echo '</form>'; // form A echo '</div>'; // application_modify } if (count($servers) + count($servers_available) > 0) { echo '<div>'; echo '<h2>' . _('Servers with this application') . '</h2>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($servers as $server) { echo '<tr><td>'; echo '<a href="servers.php?action=manage&fqdn=' . $server->fqdn . '">' . $server->fqdn . '</a>'; echo '</td>'; echo '<td>'; if ($server->isOnline() and $can_manage_server) { echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to remove this application from this server?') . '\');">'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="name" value="Application_Server" />'; echo '<input type="hidden" name="application" value="' . $id . '" />'; echo '<input type="hidden" name="server" value="' . $server->fqdn . '" />'; echo '<input type="submit" value="' . _('Remove from this server') . '"/>'; echo '</form>'; } echo '</td>'; echo '</tr>'; } if (count($servers_available) > 0 and $can_manage_server) { echo '<tr>'; echo '<form action="actions.php" method="post"><td>'; echo '<input type="hidden" name="name" value="Application_Server" />'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="application" value="' . $id . '" />'; echo '<select name="server">'; foreach ($servers_available as $server) { echo '<option value="' . $server->fqdn . '">' . $server->fqdn . '</option>'; } echo '</select>'; echo '</td><td><input type="submit" value="' . _('Add to this server') . '" /></td>'; echo '</form>'; echo '</tr>'; } echo '</table>'; echo "<div>\n"; } if (count($appgroups) > 0) { echo '<div>'; echo '<h2>' . _('Groups with this application') . '</h2>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($groups as $group) { echo '<tr>'; echo '<td>'; echo '<a href="appsgroup.php?action=manage&id=' . $group->id . '">' . $group->name . '</a>'; echo '</td>'; echo '<td><form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this application from this group?') . '\');">'; echo '<input type="hidden" name="name" value="Application_ApplicationGroup" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="element" value="' . $id . '" />'; echo '<input type="hidden" name="group" value="' . $group->id . '" />'; echo '<input type="submit" value="' . _('Delete from this group') . '" />'; echo '</form></td>'; echo '</tr>'; } if (count($groups_available) > 0) { echo '<tr>'; echo '<form action="actions.php" method="post"><td>'; echo '<input type="hidden" name="name" value="Application_ApplicationGroup" />'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="element" value="' . $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>'; echo '</tr>'; } echo '</table>'; echo "<div>\n"; } // Mime-Type part echo '<div>'; echo '<h2>' . _('Mime-Types') . '</h2>'; echo '<div>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($mimeliste1 as $mime) { echo '<tr><td>'; echo '<a href="mimetypes.php?action=manage&id=' . urlencode($mime) . '">' . $mime . '</a>'; echo '</td>'; echo '<td>'; echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="Application_MimeType" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />'; echo '<input type="hidden" name="mime" value="' . $mime . '" />'; echo '<input type="submit" value="' . _('Del') . '"/>'; echo '</form>'; echo '</td>'; echo '</tr>'; } if (is_array($mimeliste2) && count($mimeliste2) > 0) { echo '<tr>'; echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="Application_MimeType" />'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />'; echo '<td>'; echo '<select name="mime">'; foreach ($mimeliste2 as $mime) { echo '<option>' . $mime . '</option>'; } echo '</select>'; echo '</td>'; echo '<td>'; echo '<input type="submit" value="' . _('Add') . '"/>'; echo '</td>'; echo '</form>'; echo '</tr>'; } echo '<tr>'; echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="Application_MimeType" />'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />'; echo '<td>' . _('Custom Mime-Type: ') . '<input type="text" name="mime" /></td>'; echo '<td>'; echo '<input type="submit" value="' . _('Add') . '"/>'; echo '</td>'; echo '</form>'; echo '</tr>'; echo '</table>'; echo '</div>'; echo '</div>'; // mime div echo '</div>'; echo '</div>'; echo '</div>'; echo '</div>'; echo '</div>'; echo '</div>'; page_footer(); die; }
function do_validate() { if ($_SESSION['wizard']['use_users'] == 'users') { if (!checkAuthorization('manageUsersGroups')) { redirect(); } $userGroupDB = UserGroupDB::getInstance(); if (!$userGroupDB->isWriteable()) { return false; } $g = new UsersGroup(NULL, $_SESSION['wizard']['user_group_name'], $_SESSION['wizard']['user_group_description'], 1); $res = $userGroupDB->add($g); if (!$res || !is_object($g) || $g->id == NULL) { popup_error(_('Cannot create usergroup')); } $users = $_SESSION['wizard']['users']; foreach ($users as $user) { Abstract_Liaison::save('UsersGroup', $user, $g->getUniqueID()); } $usergroups = array($g->getUniqueID()); } else { $usergroups = $_SESSION['wizard']['usergroups']; } if ($_SESSION['wizard']['use_apps'] == 'apps') { if (!checkAuthorization('manageApplicationsGroups')) { redirect(); } $g = new AppsGroup(NULL, $_SESSION['wizard']['application_group_name'], $_SESSION['wizard']['application_group_description'], 1); $applicationsGroupDB = ApplicationsGroupDB::getInstance(); $res = $applicationsGroupDB->add($g); if (!$res || !is_object($g) || $g->id == NULL) { popup_error(_('Cannot create application group')); } $apps = $_SESSION['wizard']['apps']; foreach ($apps as $app) { Abstract_Liaison::save('AppsGroup', $app, $g->id); } $appgroups = array($g->id); } else { $appgroups = $_SESSION['wizard']['appgroups']; } foreach ($usergroups as $usergroup) { foreach ($appgroups as $appgroup) { $exists = Abstract_Liaison::load('UsersGroupApplicationsGroup', $usergroup, $appgroup); if (is_object($exists) === false) { Abstract_Liaison::save('UsersGroupApplicationsGroup', $usergroup, $appgroup); } } } if (isset($_SESSION['wizard'])) { } unset($_SESSION['wizard']); redirect('publications.php'); die; }
public function groups() { Logger::debug('main', 'APPLICATION::groups'); $ApplicationsGroupDB = ApplicationsGroupDB::getInstance(); $result = array(); $rows = Abstract_Liaison::load('AppsGroup', $this->attributes['id'], NULL); foreach ($rows as $row) { $g = $ApplicationsGroupDB->import($row->group); if (is_object($g)) { $result[] = $g; } } return $result; }
function show_default() { $userDB = UserDB::getInstance(); $userGroupDB = UserGroupDB::getInstance(); $applicationsGroupDB = ApplicationsGroupDB::getInstance(); $sessionmanagement = SessionManagement::getInstance(); $usersList = new UsersList($_REQUEST); $us = $usersList->search(); $searchDiv = $usersList->getForm(); page_header(); echo '<h2>' . _('List of users') . '</h2>'; echo $searchDiv; if (count($us) == 0) { echo _('No available user') . '<br />'; } else { echo '<table id="users_table" class="main_sub sortable" border="0" cellspacing="1" cellpadding="3">'; echo '<thead>'; echo '<tr class="title2">'; echo '<th class="unsortable" colspan="3">' . _('Users') . '</th>'; echo '<th colspan="2">' . _('Applications') . '</th>'; echo '<th>' . _('Folders') . '</th>'; echo '<th>' . _('Session') . '</th>'; echo '</tr>'; echo '<tr class="title">'; echo '<th>' . _('Login') . '</th>'; echo '<th>' . _('Name') . '</th>'; echo '<th>' . _('In these users groups') . '</th>'; echo '<th>' . _('Published applications groups') . '</th>'; echo '<th>' . _('Access to these applications') . '</th>'; echo '<th>' . _('Access to these folders') . '</th>'; echo '</tr>'; echo '</thead>'; echo '<tbody>'; $count = 0; foreach ($us as $u) { $session_settings_defaults = $u->getSessionSettings('session_settings_defaults'); echo '<tr class="content'; if ($count % 2 == 0) { echo '1'; } else { echo '2'; } echo '">'; echo '<td><a href="users.php?action=manage&id=' . $u->getAttribute('login') . '">' . $u->getAttribute('login') . '</a></td>'; // login echo '<td><a href="users.php?action=manage&id=' . $u->getAttribute('login') . '">' . $u->getAttribute('displayname') . '</a></td>'; //nam $users_grps = $u->usersGroups(); // in user group echo '<td>'; if (count($users_grps) == 0) { echo '<em>' . _('Not in any users group') . '</em>'; } else { echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($users_grps as $ugrp) { echo '<tr>'; echo '<td><a href="usersgroup.php?action=manage&id=' . $ugrp->getUniqueID() . '">' . $ugrp->name . '</a></td>'; echo '</tr>'; } echo '</table>'; } echo '</td>'; $apps_grps = $u->appsGroups(); if (count($apps_grps) == 0) { echo '<td colspan="2">'; echo '<em>' . _('No publication') . '</em>'; echo '</td>'; } else { echo '<td>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($apps_grps as $agrp_id) { $agrp = $applicationsGroupDB->import($agrp_id); if (is_object($agrp)) { echo '<tr>'; echo '<td><a href="appsgroup.php?action=manage&id=' . $agrp->id . '">' . $agrp->name . '</a></td>'; echo '</tr>'; } } echo '</table>'; echo '</td>'; echo '<td>'; // in app $apps_s = $u->applications(); if (count($apps_s) == 0) { echo '<em>' . _('No applications in these groups') . '</em>'; } else { echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($apps_s as $aaa) { echo '<tr>'; echo '<td><img src="media/image/cache.php?id=' . $aaa->getAttribute('id') . '" alt="" title="" /></td>'; echo '<td><a href="applications.php?action=manage&id=' . $aaa->getAttribute('id') . '">' . $aaa->getAttribute('name') . '</a></td>'; echo '<td style="text-align: center;"><img src="media/image/server-' . $aaa->getAttribute('type') . '.png" width="16" height="16" alt="' . $aaa->getAttribute('type') . '" title="' . $aaa->getAttribute('type') . '" /></td>'; echo '</tr>'; } echo '</table>'; } echo '</td>'; } echo '<td>'; $folders = array(); if (array_key_exists('enable_sharedfolders', $session_settings_defaults) && $session_settings_defaults['enable_sharedfolders'] == 1) { $folders = $u->getSharedFolders(); } $profiles = array(); if (array_key_exists('enable_profiles', $session_settings_defaults) && $session_settings_defaults['enable_profiles'] == 1) { $profiles = $u->getProfiles(); } $networkfolder_s = array_merge($folders, $profiles); if (count($networkfolder_s) > 0) { echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($networkfolder_s as $a_networkfolder) { echo '<tr>'; echo '<td>' . $a_networkfolder->prettyName() . '</td>'; if (isset($a_networkfolder->name) && $a_networkfolder->name !== '') { $name = $a_networkfolder->name; } else { $name = $a_networkfolder->id; } echo '<td>'; if (isset($a_networkfolder->name)) { $page = 'sharedfolders'; } else { $page = 'profiles'; } echo '<a href="' . $page . '.php?action=manage&id=' . $a_networkfolder->id . '">' . $name . '</a></td>'; echo '</tr>'; } echo '</table>'; } echo '</td>'; echo '<td style="text-align: center;">'; // server $sessionmanagement2 = clone $sessionmanagement; $sessionmanagement2->user = $u; $can_start_session = $sessionmanagement2->buildServersList(); if ($can_start_session === true) { echo '<img src="media/image/ok.png" alt="" title="" />'; } else { echo '<img src="media/image/cancel.png" alt="" title="" />'; } echo '</td>'; echo '</tr>'; $count++; } echo '</tbody>'; echo '</table>'; } page_footer(); }
* 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. **/ require_once dirname(__FILE__) . '/includes/core.inc.php'; require_once dirname(__FILE__) . '/includes/page_template.php'; if (!checkAuthorization('viewSummary')) { redirect('index.php'); } function my_own_callback($matches) { return '<span class="' . strtolower($matches[1]) . '">' . trim($matches[0]) . '</span>'; } $userDB = UserDB::getInstance(); $userGroupDB = UserGroupDB::getInstance(); $applicationsGroupDB = ApplicationsGroupDB::getInstance(); $usersList = new UsersList($_REQUEST); $us = $usersList->search(); $searchDiv = $usersList->getForm(); page_header(); echo '<h2>' . _('List of users') . '</h2>'; echo $searchDiv; if (is_null($us)) { } else { if (count($us) > 0) { echo '<table id="users_table" class="main_sub sortable" border="0" cellspacing="1" cellpadding="3">'; echo '<thead>'; echo '<tr class="title">'; echo '<th>' . _('login') . '</th><th>' . _('name') . '</th><th>' . _('in this user group') . '</th><th>' . _('in this application group') . '</th><th>' . _('access to these applications') . '</th><th>' . _('access to these network folders') . '</th>'; // <th>'._('Desktop File').'</th> echo '<th>' . _('Available servers') . '</th>';
function checkup_liaison($type_, $element_, $group_) { switch ($type_) { case 'ApplicationServer': $applicationDB = ApplicationDB::getInstance(); $buf = $applicationDB->import($element_); if (!is_object($buf)) { return 'Application "' . $element_ . '" does not exist'; } $buf = Abstract_Server::load($group_); if (!$buf) { return 'Server "' . $group_ . '" does not exist'; } break; case 'AppsGroup': $applicationDB = ApplicationDB::getInstance(); $buf = $applicationDB->import($element_); if (!is_object($buf)) { return 'Application "' . $element_ . '" does not exist'; } $applicationsGroupDB = ApplicationsGroupDB::getInstance(); $buf = $applicationsGroupDB->import($group_); if (!is_object($buf)) { return 'ApplicationsGroup "' . $group_ . '" does not exist'; } break; case 'ApplicationMimeType': $applicationDB = ApplicationDB::getInstance(); $buf = $applicationDB->import($element_); if (!is_object($buf)) { return 'Application "' . $element_ . '" does not exist'; } break; case 'ServerSession': $buf = Abstract_Server::load($element_); if (!$buf) { return 'Server "' . $element_ . '" does not exist'; } $buf = Abstract_Session::load($group_); if (!$buf) { return 'Session "' . $group_ . '" does not exist'; } break; case 'UserGroupSharedFolder': $sharedfolderdb = SharedFolderDB::getInstance(); $userGroupDB = UserGroupDB::getInstance(); $buf = $userGroupDB->import($element_); if (!is_object($buf)) { return 'UserGroup "' . $element_ . '" does not exist'; } $buf = $sharedfolderdb->import($group_); if (!$buf) { return 'SharedFolder "' . $group_ . '" does not exist'; } break; case 'UserProfile': $profiledb = ProfileDB::getInstance(); $userDB = UserDB::getInstance(); $buf = $userDB->import($element_); if (!is_object($buf)) { return 'User "' . $element_ . '" does not exist'; } $buf = $profiledb->import($group_); if (!$buf) { return 'Profile "' . $group_ . '" does not exist'; } break; case 'UsersGroup': $userDB = UserDB::getInstance(); $buf = $userDB->import($element_); if (!is_object($buf)) { return 'User "' . $element_ . '" does not exist'; } $userGroupDB = UserGroupDB::getInstance(); $buf = $userGroupDB->import($group_); if (!is_object($buf)) { return 'UserGroup "' . $group_ . '" does not exist'; } break; case 'UsersGroupApplicationsGroup': $userGroupDB = UserGroupDB::getInstance(); $buf = $userGroupDB->import($element_); if (!is_object($buf)) { return 'UserGroup "' . $element_ . '" does not exist'; } $applicationsGroupDB = ApplicationsGroupDB::getInstance(); $buf = $applicationsGroupDB->import($group_); if (!is_object($buf)) { return 'ApplicationsGroup "' . $group_ . '" does not exist'; } break; case 'UsersGroupCached': $userDB = UserDB::getInstance(); $buf = $userDB->import($element_); if (!is_object($buf)) { return 'User "' . $element_ . '" does not exist'; } $userGroupDB = UserGroupDB::getInstance(); $buf = $userGroupDB->import($group_); if (!is_object($buf)) { return 'UserGroup "' . $group_ . '" does not exist'; } break; } return true; }
public function session_simulate($user_login_) { $this->check_authorized('viewSummary'); $userDB = UserDB::getInstance(); $user = $userDB->import($user_login_); if (!$user) { return null; } $userGroupDB = UserGroupDB::getInstance(); $applicationsGroupDB = ApplicationsGroupDB::getInstance(); try { $sessionmanagement = SessionManagement::getInstance(); } catch (Exception $err) { die_error('Unable to instanciate SessionManagement: ' . $err->getMessage(), __FILE__, __LINE__); } $info = array(); // Should only request SessionManagement instance to catch all these information ... $info['settings'] = $user->getSessionSettings('session_settings_defaults'); $search_limit = $this->prefs->get('general', 'max_items_per_page'); $usergroupDB = UserGroupDB::getInstance(); list($groups, $sizelimit_exceeded) = $usergroupDB->getGroupsContains('', array(), $search_limit, $user); $info['user_grps'] = array(); $info['groups_partial_list'] = $sizelimit_exceeded; foreach ($groups as $group_id => $group) { $info['user_grps'][$group_id] = $group->name; } $info['apps_grps'] = array(); $apps_grps = $user->appsGroups(); foreach ($apps_grps as $agrp_id) { $agrp = $applicationsGroupDB->import($agrp_id); if (!is_object($agrp)) { continue; } $info['apps_grps'][$agrp_id] = $agrp->name; } $info['apps'] = array(); $applications = $user->applications(); foreach ($applications as $application) { $a = array('id' => $application->getAttribute('id'), 'name' => $application->getAttribute('name'), 'type' => $application->getAttribute('type')); $info['apps'][$a['id']] = $a; } $info['shared_folders'] = array(); if (array_key_exists('enable_sharedfolders', $info['settings']) && $info['settings']['enable_sharedfolders'] == 1) { $shared_folders = $user->getSharedFolders(); foreach ($shared_folders as $shared_folder_id => $infos) { $info['shared_folders'][$shared_folder_id] = array('share_name' => $infos['share']->name, 'mode' => $infos['mode']); } } $info['profiles'] = array(); if (array_key_exists('enable_profiles', $info['settings']) && $info['settings']['enable_profiles'] == 1) { $profiles = $user->getProfiles(); foreach ($profiles as $profile) { $info['profiles'][$profile->id] = $profile->id; } } $can_start_session = $user->can_use_session(); $remote_desktop_settings = $user->getSessionSettings('remote_desktop_settings'); $remote_desktop_enabled = $remote_desktop_settings['enabled'] == 1; $remote_applications_settings = $user->getSessionSettings('remote_applications_settings'); $remote_applications_enabled = $remote_applications_settings['enabled'] == 1; $bypass_servers_restrictions = $info['settings']['bypass_servers_restrictions'] == 1; $sessionmanagement2 = clone $sessionmanagement; $sessionmanagement2->user = $user; $info['can_start_session_desktop'] = $can_start_session && $remote_desktop_enabled && $sessionmanagement2->getDesktopServer($bypass_servers_restrictions) && $sessionmanagement2->buildServersList(true); $sessionmanagement2 = clone $sessionmanagement; $sessionmanagement2->user = $user; $info['can_start_session_applications'] = $can_start_session && $remote_applications_enabled && $sessionmanagement2->buildServersList(true); if ($info['can_start_session_desktop'] || $info['can_start_session_applications']) { $sessionmanagement2 = clone $sessionmanagement; $sessionmanagement2->user = $user; $servers = $sessionmanagement2->chooseApplicationServers($bypass_servers_restrictions); $info['servers'] = array(); if (is_array($servers)) { foreach ($servers as $server) { $s = array('id' => $server->id, 'name' => $server->getDisplayName(), 'type' => $server->getAttribute('type')); $info['servers'][$s['id']] = $s; } } } if (!$info['can_start_session_desktop'] || !$info['can_start_session_applications']) { if (!$can_start_session) { $info['cannot_start_session_reason'] = 'time_restriction'; } else { if (!$remote_desktop_enabled || !$remote_applications_enabled) { $info['cannot_start_session_reason'] = 'unauthorized_session_mode'; } else { $info['cannot_start_session_reason'] = 'invalid_publications'; } } } return $info; }
function show_manage($id) { global $schedules; $prefs = Preferences::getInstance(); if (!$prefs) { die_error('get Preferences failed', __FILE__, __LINE__); } $userGroupDB = UserGroupDB::getInstance(); $group = $userGroupDB->import($id); if (!is_object($group)) { die_error(_('Failed to load usergroup')); } $usergroupdb_rw = $userGroupDB->isWriteable(); $policy = $group->getPolicy(); $policy_rule_enable = 0; $policy_rules_disable = 0; foreach ($policy as $key => $value) { if ($value === true) { $policy_rule_enable++; } else { $policy_rules_disable++; } } $buffer = $prefs_policy = $prefs->get('general', 'policy'); $default_policy = $prefs_policy['default_policy']; if (!is_object($group)) { die_error('Group "' . $id . '" is not OK', __FILE__, __LINE__); } if ($group->published) { $status = '<span class="msg_ok">' . _('Enabled') . '</span>'; $status_change = _('Block'); $status_change_value = 0; } else { $status = '<span class="msg_error">' . _('Blocked') . '</span>'; $status_change = _('Enable'); $status_change_value = 1; } $userDB = UserDB::getInstance(); $applicationsGroupDB = ApplicationsGroupDB::getInstance(); if ($group->isDefault() == false) { $users = $group->usersLogin(); sort($users); $has_users = count($users) > 0; if ($usergroupdb_rw) { $usersList = new UsersList($_REQUEST); $users_all = $usersList->search(); $search_form = $usersList->getForm(array('action' => 'manage', 'id' => $id, 'search_user' => true)); if (is_null($users_all)) { $users_all = array(); } $users_available = array(); foreach ($users_all as $user) { $found = false; foreach ($users as $user2) { if ($user2 == $user->getAttribute('login')) { $found = true; } } if (!$found) { $users_available[] = $user->getAttribute('login'); } } } else { $users_available = array(); $users_all = array(); foreach ($users as $a_login) { $users_all[] = $userDB->import($a_login); } usort($users_all, "user_cmp"); } } else { $users = array(); $users_available = array(); $users_all = array(); $search_form = null; } // Default usergroup $is_default_group = $prefs->get('general', 'user_default_group') == $id; // Publications $groups_apps = array(); foreach (Abstract_Liaison::load('UsersGroupApplicationsGroup', $id, NULL) as $group_a) { $obj = $applicationsGroupDB->import($group_a->group); if (is_object($obj)) { $groups_apps[] = $obj; } } $groups_apps_all = $applicationsGroupDB->getList(); $groups_apps_available = array(); foreach ($groups_apps_all as $group_apps) { if (!in_array($group_apps, $groups_apps)) { $groups_apps_available[] = $group_apps; } } $can_manage_usersgroups = isAuthorized('manageUsersGroups'); $can_manage_publications = isAuthorized('managePublications'); $can_manage_sharedfolders = isAuthorized('manageServers'); $prefs_to_get_for_a_group = array('session_settings_defaults', 'remote_desktop_settings', 'remote_applications_settings'); $prefs_of_a_group = array(); $unuse_settings = array(); $session_prefs = array(); foreach ($prefs_to_get_for_a_group as $prefs_to_get_for_a_group_value) { $prefs_of_a_group[$prefs_to_get_for_a_group_value] = array(); $unuse_settings[$prefs_to_get_for_a_group_value] = array(); $session_prefs[$prefs_to_get_for_a_group_value] = $prefs->getElements('general', $prefs_to_get_for_a_group_value); $prefs_of_a_group_unsort = Abstract_UserGroup_Preferences::loadByUserGroupId($group->getUniqueID(), 'general', $prefs_to_get_for_a_group_value); foreach ($session_prefs[$prefs_to_get_for_a_group_value] as $k4 => $v4) { // we should use the ones from the group ($prefs_of_a_group_unsort) but we can display then if they are in $session_prefs if (array_key_exists($k4, $prefs_of_a_group_unsort)) { $prefs_of_a_group[$prefs_to_get_for_a_group_value][$k4] = $prefs_of_a_group_unsort[$k4]; } else { $unuse_settings[$prefs_to_get_for_a_group_value][$k4] = $v4; } } } page_header(); echo '<div id="users_div">'; echo '<h1><a href="?">' . _('User groups management') . '</a> - ' . $group->name . '</h1>'; echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="5">'; echo '<tr class="title">'; echo '<th>' . _('Description') . '</th>'; echo '<th>' . _('Status') . '</th>'; echo '</tr>'; echo '<tr class="content1">'; echo '<td>' . $group->description . '</td>'; echo '<td>' . $status . '</td>'; echo '</tr>'; echo '</table>'; if ($can_manage_usersgroups) { echo '<div>'; echo '<h2>' . _('Settings') . '</h1>'; if ($group->type == 'static' and $can_manage_usersgroups and $usergroupdb_rw) { echo '<form action="actions.php" method="post">'; if ($is_default_group) { echo '<input type="submit" value="' . _('Remove from default') . '"/>'; echo '<input type="hidden" name="action" value="unset_default" />'; } else { echo '<input type="submit" value="' . _('Define as default') . '"/>'; echo '<input type="hidden" name="action" value="set_default" />'; } echo '<input type="hidden" name="name" value="UserGroup" />'; echo '<input type="hidden" name="id" value="' . $group->getUniqueID() . '" />'; echo '</form>'; echo '<br/>'; } if ($usergroupdb_rw || $group->type != 'static') { echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this group?') . '\');">'; echo '<input type="submit" value="' . _('Delete this group') . '"/>'; echo '<input type="hidden" name="name" value="UserGroup" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="checked_groups[]" value="' . $id . '" />'; echo '</form>'; echo '<br/>'; echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="UserGroup" />'; echo '<input type="hidden" name="action" value="modify" />'; echo '<input type="hidden" name="id" value="' . $id . '" />'; echo '<input type="hidden" name="published" value="' . $status_change_value . '" />'; echo '<input type="submit" value="' . $status_change . '"/>'; echo '</form>'; echo '<br/>'; echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="UserGroup" />'; echo '<input type="hidden" name="action" value="modify" />'; echo '<input type="hidden" name="id" value="' . $id . '" />'; echo '<input type="text" name="name_group" value="' . $group->name . '" size="50" /> '; echo '<input type="submit" value="' . _('Update the name') . '"/>'; echo '</form>'; echo '<br/>'; echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="UserGroup" />'; echo '<input type="hidden" name="action" value="modify" />'; echo '<input type="hidden" name="id" value="' . $id . '" />'; echo '<input type="text" name="description" value="' . $group->description . '" size="50" /> '; echo '<input type="submit" value="' . _('Update the description') . '"/>'; echo '</form>'; } if ($group->type == 'dynamiccached') { echo '<br />'; echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="UserGroup" />'; echo '<input type="hidden" name="action" value="modify" />'; echo '<input type="hidden" name="id" value="' . $id . '" />'; echo ' <select name="schedule">'; foreach ($schedules as $interval => $text) { echo '<option value="' . $interval . '"'; if ($group->schedule == $interval) { echo ' selected="selected"'; } echo '>' . $text . '</option>'; } echo '</select>'; echo '<input type="submit" value="' . _('Update the schedule') . '"/>'; echo '</form>'; } echo '</div>'; echo '<br/>'; } if (str_startswith($group->type, 'dynamic')) { echo '<div>'; echo '<h2>' . _('Rules') . '</h1>'; if ($can_manage_usersgroups) { echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="UserGroup" />'; echo '<input type="hidden" name="action" value="modify_rules" />'; echo '<input type="hidden" name="id" value="' . $id . '" />'; } echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="3">'; echo '<tr class="content1">'; echo '<th>' . _('Validation type') . '</th>'; echo '<td><input type="radio" name="validation_type" value="and"'; if ($group->validation_type == 'and') { echo ' checked="checked"'; } echo ' /> ' . _('All') . ' <input type="radio" name="validation_type" value="or"'; if ($group->validation_type == 'or') { echo ' checked="checked"'; } echo ' /> ' . _('At least one') . '</td>'; echo '</tr>'; echo '<tr class="content2">'; echo '<th>' . _('Filters') . '</th>'; echo '<td>'; $i = 0; $filter_attributes = $userDB->getAttributesList(); foreach ($filter_attributes as $key1 => $value1) { if ($value1 == 'password') { unset($filter_attributes[$key1]); } } $filter_types = UserGroup_Rule::$types; echo '<table border="0" cellspacing="1" cellpadding="3">'; $i = 0; foreach ($group->rules as $rule) { echo '<tr>'; echo '<td><select name="rules[' . $i . '][attribute]">'; foreach ($filter_attributes as $filter_attribute) { echo '<option value="' . $filter_attribute . '"'; if ($rule->attribute == $filter_attribute) { echo ' selected="selected"'; } echo '>' . $filter_attribute . '</option>'; } echo '</select></td>'; echo '<td><select name="rules[' . $i . '][type]">'; foreach ($filter_types as $filter_type) { echo '<option value="' . $filter_type . '"'; if ($rule->type == $filter_type) { echo ' selected="selected"'; } echo '>' . $filter_type . '</option>'; } echo '</select></td>'; echo '<td><input type="text" name="rules[' . $i . '][value]" value="' . $rule->value . '" /></td>'; if ($can_manage_usersgroups) { echo '<td>'; echo '<input'; if ($i == 0 && count($group->rules) == 1 || $i == count($group->rules)) { echo ' style="display: none;"'; } echo ' type="button" onclick="del_field(this.parentNode.parentNode); return false;" value="-" />'; echo '<input'; if ($i + 1 != count($group->rules)) { echo ' style="display: none;"'; } echo ' type="button" onclick="add_field(this.parentNode.parentNode); return false;" value="+" />'; echo '</td>'; } echo '</tr>'; $i++; } echo '</table>'; echo '</td>'; echo '</tr>'; echo '</table>'; echo '<br />'; if ($can_manage_usersgroups) { echo '<input type="submit" value="' . _('Update rules') . '" />'; echo '</form>'; } echo '</div>'; echo '<br />'; } // Users list if (count($users_all) > 0 || count($users) > 0 || $group->isDefault()) { echo '<div>'; echo '<h2>' . _('List of users in this group') . '</h2>'; if ($group->isDefault()) { echo _('All available users are in this group.'); } else { echo '<table border="0" cellspacing="1" cellpadding="3">'; if (count($users) > 0) { foreach ($users as $user) { echo '<tr>'; echo '<td><a href="users.php?action=manage&id=' . $user . '">' . $user . '</td>'; echo '<td>'; if ($usergroupdb_rw && $group->type == 'static' && !$group->isDefault() and $can_manage_usersgroups) { echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this user?') . '\');">'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="name" value="User_UserGroup" />'; echo '<input type="hidden" name="group" value="' . $id . '" />'; echo '<input type="hidden" name="element" value="' . $user . '" />'; echo '<input type="submit" value="' . _('Delete from this group') . '" />'; echo '</form>'; echo '</td>'; } echo '</tr>'; } } if (count($users_available) > 0 && $usergroupdb_rw && $group->type == 'static' 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="group" value="' . $id . '" />'; echo '<select name="element">'; foreach ($users_available as $user) { echo '<option value="' . $user . '" >' . $user . '</option>'; } echo '</select>'; echo '</td><td><input type="submit" value="' . _('Add to this group') . '" /></td>'; echo '</form></tr>'; } echo '</table>'; if ($usergroupdb_rw && $group->type == 'static' and $can_manage_usersgroups) { echo '<br/>'; echo $search_form; } echo '</div>'; echo '<br/>'; } } // Publications part if (count($groups_apps_all) > 0) { echo '<div>'; echo '<h2>' . _('List of publications for this group') . '</h1>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; if (count($groups_apps) > 0) { foreach ($groups_apps as $groups_app) { echo '<tr>'; echo '<td><a href="appsgroup.php?action=manage&id=' . $groups_app->id . '">' . $groups_app->name . '</td>'; if ($can_manage_publications) { echo '<td>'; echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this publication?') . '\');">'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="name" value="Publication" />'; echo '<input type="hidden" name="group_u" value="' . $id . '" />'; echo '<input type="hidden" name="group_a" value="' . $groups_app->id . '" />'; echo '<input type="submit" value="' . _('Delete this publication') . '" />'; echo '</form>'; echo '</td>'; } echo '</tr>'; } } if (count($groups_apps_available) > 0 and $can_manage_publications) { echo '<tr><form action="actions.php" method="post"><td>'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="name" value="Publication" />'; echo '<input type="hidden" name="group_u" value="' . $id . '" />'; echo '<select name="group_a">'; foreach ($groups_apps_available as $group_apps) { echo '<option value="' . $group_apps->id . '" >' . $group_apps->name . '</option>'; } echo '</select>'; echo '</td><td><input type="submit" value="' . _('Add this publication') . '" /></td>'; echo '</form></tr>'; } echo '</table>'; echo '</div>'; } // Policy of this group echo '<div>'; echo '<h2>' . _('Policy of this group') . '</h2>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($policy as $key => $value) { if ($value === false) { continue; } $extends_from_default = in_array($key, $default_policy); $buffer = $extends_from_default === true ? ' (' . _('extend from default') . ')' : ''; echo '<tr>'; echo '<td>' . $key . ' ' . $buffer . '</td>'; if ($can_manage_usersgroups && !$extends_from_default) { echo '<td>'; echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this rule?') . '\');">'; echo '<input type="hidden" name="name" value="UserGroup_PolicyRule" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="id" value="' . $group->getUniqueID() . '" />'; echo '<input type="hidden" name="element" value="' . $key . '" />'; echo '<input type="submit" value="' . _('Delete this rule') . '" />'; echo '</form>'; echo '</td>'; } echo '</tr>'; } if ($can_manage_usersgroups && count($policy_rules_disable) > 0 && array_search(false, $policy) !== false) { echo '<tr><form action="actions.php" method="post"><td>'; echo '<input type="hidden" name="name" value="UserGroup_PolicyRule" />'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="id" value="' . $group->getUniqueID() . '" />'; echo '<select name="element">'; foreach ($policy as $key => $value) { if ($value === true) { continue; } echo '<option value="' . $key . '" >' . $key . '</option>'; } echo '</select>'; echo '</td><td><input type="submit" value="' . _('Add this rule') . '" /></td>'; echo '</form></tr>'; } echo '</table>'; echo '</div>'; echo '<br/>'; if (Preferences::moduleIsEnabled('SharedFolderDB')) { $sharedfolderdb = SharedFolderDB::getInstance(); $all_sharedfolders = $sharedfolderdb->getList(); if (count($all_sharedfolders) > 0) { $available_sharedfolders = array(); $used_sharedfolders = $sharedfolderdb->importFromUsergroup($group->getUniqueID()); foreach ($all_sharedfolders as $sharedfolder) { if (in_array($sharedfolder->id, array_keys($used_sharedfolders))) { continue; } $available_sharedfolders[] = $sharedfolder; } echo '<br />'; echo '<div>'; echo '<h2>' . _('Shared folders') . '</h1>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($used_sharedfolders as $sharedfolder) { echo '<tr>'; echo '<td><a href="sharedfolders.php?action=manage&id=' . $sharedfolder->id . '">' . $sharedfolder->name . '</a></td>'; if ($can_manage_sharedfolders) { echo '<td><form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this shared folder access?') . '\');">'; echo '<input type="hidden" name="name" value="SharedFolder_ACL" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="sharedfolder_id" value="' . $sharedfolder->id . '" />'; echo '<input type="hidden" name="usergroup_id" value="' . $group->getUniqueID() . '" />'; echo '<input type="submit" value="' . _('Delete access to this shared folder') . '" />'; echo '</form></td>'; } echo '</tr>'; } if (count($available_sharedfolders) > 0 && $can_manage_sharedfolders) { echo '<tr><form action="actions.php" method="post"><td>'; echo '<input type="hidden" name="name" value="SharedFolder_ACL" />'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="usergroup_id" value="' . $group->getUniqueID() . '" />'; echo '<select name="sharedfolder_id">'; foreach ($available_sharedfolders as $sharedfolder) { echo '<option value="' . $sharedfolder->id . '" >' . $sharedfolder->name . '</option>'; } echo '</select>'; echo '</td><td><input type="submit" value="' . _('Add access to this shared folder') . '" /></td>'; echo '</form></tr>'; } echo '</table>'; echo '</div>'; } echo '<br />'; } echo '<div>'; // Session settings configuration echo '<h2>'; echo _('Session settings configuration'); echo '</h2>'; if ($prefs_of_a_group != array()) { foreach ($prefs_of_a_group as $container => $prefs_of_a_group_value) { echo '<fieldset class="prefssessionusergroup">'; echo '<legend>' . $prefs->getPrettyName($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_group_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_group_value as $element_key => $usersgroup_preferences) { $config_element = $usersgroup_preferences->toConfigElement(); 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 overriden setting') . '" onclick="usergroup_settings_remove(\'' . $group->getUniqueID() . '\',\'' . $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="UserGroup_settings" />'; echo '<input type="hidden" name="container" value="' . $container . '" />'; echo '<input type="hidden" name="unique_id" value="' . $group->getUniqueID() . '" />'; 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="UserGroup_settings" />'; echo '<input type="hidden" name="container" value="' . $container . '" />'; echo '<input type="hidden" name="unique_id" value="' . $group->getUniqueID() . '" />'; 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"; echo '</div>'; page_footer(); die; }
function show_icon($id, $applicationDB) { $applicationsGroupDB = ApplicationsGroupDB::getInstance(); $app = $applicationDB->import($id); if (!is_object($app)) { return false; } // die_error('Unable to import application "'.$id.'"',__FILE__,__LINE__); if ($app->getAttribute('static')) { redirect('applications_static.php?action=manage&id=' . $app->getAttribute('id')); } $is_rw = $applicationDB->isWriteable(); $liaisons = Abstract_Liaison::load('ApplicationServer', $app->getAttribute('id'), NULL); $servers = array(); foreach ($liaisons as $liaison) { $server = Abstract_Server::load($liaison->group); if (!$server->isOnline()) { continue; } $servers[] = $server; } page_header(); echo '<div>'; echo '<h1><img src="media/image/cache.php?id=' . $app->getAttribute('id') . '" alt="" title="" /> ' . $app->getAttribute('name') . '</h1>'; echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="3">'; echo '<tr class="title">'; echo '<th>' . _('Package') . '</th>'; echo '<th>' . _('Type') . '</th>'; // echo '<th>'._('Status').'</th>'; echo '<th>' . _('Description') . '</th>'; echo '<th>' . _('Executable') . '</th>'; echo '</tr>'; echo '<tr class="content1">'; echo '<td>' . $app->getAttribute('package') . '</td>'; echo '<td style="text-align: center;"><img src="media/image/server-' . $app->getAttribute('type') . '.png" alt="' . $app->getAttribute('type') . '" title="' . $app->getAttribute('type') . '" /><br />' . $app->getAttribute('type') . '</td>'; // echo '<td>'.$status.'</td>'; echo '<td>' . $app->getAttribute('description') . '</td>'; echo '<td>' . $app->getAttribute('executable_path') . '</td>'; echo '</tr>'; echo '</table>'; echo '<br />'; echo '<h2>' . _('Select an icon from an Application Server') . '</h2>'; echo '<table border="0" cellspacing="1" cellpadding="5">'; foreach ($servers as $server) { $ret = query_url($server->getBaseURL() . '/aps/application/icon/' . $app->getAttribute('id')); if (!$ret) { continue; } $imgfile = tempnam(NULL, 'ico'); @file_put_contents($imgfile, $ret); try { if (class_exists('Imagick')) { $imagick = new Imagick(); $imagick->readImage($imgfile); } else { if (file_exists($imgfile)) { @unlink($imgfile); } continue; } } catch (Exception $e) { if (file_exists($imgfile)) { @unlink($imgfile); } continue; } if (!file_exists($imgfile)) { continue; } echo '<tr>'; echo '<td style="width: 32px;"><img src="media/image/temp_icon.php?tempnam=' . basename($imgfile) . '" /></td><td><a href="servers.php?action=manage&fqdn=' . $server->getAttribute('fqdn') . '">' . $server->getAttribute('fqdn') . '</a></td><td><form action="actions.php" method="post"><input type="hidden" name="name" value="Application" /><input type="hidden" name="action" value="icon" /><input type="hidden" name="id" value="' . $app->getAttribute('id') . '" /><input type="hidden" name="server" value="' . $server->getAttribute('fqdn') . '" /><input type="submit" value="' . _('Select this icon') . '" /></form></td>'; echo '</tr>'; } echo '</table>'; echo '<br />'; echo '<h2>' . _('Upload an icon') . '</h2>'; echo '<table border="0" cellspacing="1" cellpadding="5">'; echo '<tr>'; echo '<td>'; echo '<form action="actions.php" method="post" enctype="multipart/form-data" >'; // form A echo '<input type="hidden" name="name" value="Application" />'; echo '<input type="hidden" name="action" value="icon" />'; echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />'; echo '<input type="file" name="file_icon" /> '; echo '<input type="submit" value="' . _('Upload this icon') . '" />'; echo '</form>'; echo '</td>'; echo '</tr>'; echo '</table>'; echo '</div>'; page_footer(); die; }
function show_manage($id) { $applicationsGroupDB = ApplicationsGroupDB::getInstance(); $group = $applicationsGroupDB->import($id); if (!is_object($group)) { die_error('Import Group "' . $id . '" failed', __FILE__, __LINE__); } if ($group->published) { $status = '<span class="msg_ok">' . _('Enabled') . '</span>'; $status_change = _('Block'); $status_change_value = 0; } else { $status = '<span class="msg_error">' . _('Blocked') . '</span>'; $status_change = _('Enable'); $status_change_value = 1; } $applicationDB = ApplicationDB::getInstance(); $userGroupDB = UserGroupDB::getInstance(); $applications_all = $applicationDB->getList(true); $applications_id = array(); $liaisons = Abstract_Liaison::load('AppsGroup', NULL, $id); foreach ($liaisons as $liaison) { $applications_id[] = $liaison->element; } $applications = array(); $applications_available = array(); foreach ($applications_all as $application) { if (!in_array($application->getAttribute('id'), $applications_id)) { $applications_available[] = $application; } else { $applications[] = $application; } } // Publications $groups_users = array(); foreach (Abstract_Liaison::load('UsersGroupApplicationsGroup', NULL, $id) as $group_liaison) { $obj = $userGroupDB->import($group_liaison->element); if (is_object($obj)) { $groups_users[] = $obj; } } $groups_users_all = $userGroupDB->getList(true); $groups_users_available = array(); foreach ($groups_users_all as $group_users) { if (!in_array($group_users, $groups_users)) { $groups_users_available[] = $group_users; } } $can_manage_applicationsgroups = isAuthorized('manageApplicationsGroups'); $can_manage_publications = isAuthorized('managePublications'); page_header(); echo '<div>'; echo '<h1><a href="?">' . _('Application groups management') . '</a> - ' . $group->name . '</h1>'; echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="3">'; echo '<tr class="title">'; echo '<th>' . _('Description') . '</th>'; echo '<th>' . _('Status') . '</th>'; echo '</tr>'; echo '<tr class="content1">'; echo '<td>' . $group->description . '</td>'; echo '<td>' . $status . '</td>'; echo '</tr>'; echo '</table>'; if ($can_manage_applicationsgroups) { echo '<div>'; echo '<h2>' . _('Settings') . '</h2>'; echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this group?') . '\');">'; echo '<input type="submit" value="' . _('Delete this group') . '"/>'; echo '<input type="hidden" name="name" value="ApplicationsGroup" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="checked_groups[]" value="' . $id . '" />'; echo '<input type="hidden" name="id" value="' . $id . '" />'; echo '</form>'; echo '<br/>'; echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="ApplicationsGroup" />'; echo '<input type="hidden" name="action" value="modify" />'; echo '<input type="hidden" name="id" value="' . $id . '" />'; echo '<input type="hidden" name="published_appsgroup" value="' . $status_change_value . '" />'; echo '<input type="submit" value="' . $status_change . '"/>'; echo '</form>'; echo '<br/>'; echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="ApplicationsGroup" />'; echo '<input type="hidden" name="action" value="modify" />'; echo '<input type="hidden" name="id" value="' . $id . '" />'; echo '<input type="text" name="name_appsgroup" value="' . $group->name . '" size="50" /> '; echo '<input type="submit" value="' . _('Update the name') . '"/>'; echo '</form>'; echo '<br/>'; echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="ApplicationsGroup" />'; echo '<input type="hidden" name="action" value="modify" />'; echo '<input type="hidden" name="id" value="' . $id . '" />'; echo '<input type="text" name="description_appsgroup" value="' . $group->description . '" size="50" /> '; echo '<input type="submit" value="' . _('Update the description') . '"/>'; echo '</form>'; echo '<br/>'; } // Application part if (count($applications_all) > 0 and $can_manage_applicationsgroups or count($applications) > 0) { echo '<div>'; echo '<h2>' . _('List of applications in this group') . '</h2>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; if (count($applications) > 0) { foreach ($applications as $application) { echo '<tr>'; echo '<td><img src="media/image/cache.php?id=' . $application->getAttribute('id') . '" alt="' . $application->getAttribute('name') . '" title="' . $application->getAttribute('name') . '" /> <a href="applications.php?action=manage&id=' . $application->getAttribute('id') . '">' . $application->getAttribute('name') . '</a>'; echo '</td>'; if ($can_manage_applicationsgroups) { echo '<td>'; echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this application?') . '\');">'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="name" value="Application_ApplicationGroup" />'; echo '<input type="hidden" name="group" value="' . $id . '" />'; echo '<input type="hidden" name="element" value="' . $application->getAttribute('id') . '" />'; echo '<input type="submit" value="' . _('Delete from this group') . '" />'; echo '</form>'; echo '</td>'; } echo '</tr>'; } } if (count($applications_available) > 0 and $can_manage_applicationsgroups) { echo '<tr><form action="actions.php" method="post"><td>'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="name" value="Application_ApplicationGroup" />'; echo '<input type="hidden" name="group" value="' . $id . '" />'; echo '<select name="element">'; foreach ($applications_available as $application) { echo '<option value="' . $application->getAttribute('id') . '" >' . $application->getAttribute('name') . ' (' . $application->getAttribute('type') . ')</option>'; } echo '</select>'; echo '</td><td><input type="submit" value="' . _('Add to this group') . '" /></td>'; echo '</form></tr>'; } echo '</table>'; echo '</div>'; } /* // Servers echo '<div>'; echo '<h2>'._('List of servers including this group').'</h2>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; if (count($servers) == 0) echo '<tr><td colspan="2">'._('No server has this group').'</td></tr>'; else { foreach($servers as $server) { echo '<tr>'; echo '<td><a href="servers.php?action=manage&id='.$server->fqdn.'">'.$server->fqdn.'</a>'; echo '</td>'; echo '<td>'; echo '<form action="actions.php" method="post" onsubmit="return confirm(\''._('Are you sure you want to delete this group from this server?').'\');">'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="name" value="ApplicationGroup_Server" />'; echo '<input type="hidden" name="group" value="'.$id.'" />'; echo '<input type="hidden" name="server" value="'.$server->fqdn.'" />'; echo '<input type="submit" value="'._('Delete from this group').'" /> FIXME'; echo '</form>'; echo '</td>'; echo '</tr>'; } } if (count ($servers_available) ==0) echo '<tr><td colspan="2">'._('Not any available server to add').'</td></tr>'; else { echo '<tr><form action="actions.php" method="post"><td>'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="name" value="Application_ApplicationGroup" />'; echo '<input type="hidden" name="group" value="'.$id.'" />'; echo '<select name="element">'; foreach($servers_available as $servers) echo '<option value="'.$server->fqdn.'" >'.$server->fqdn.'</option>'; echo '</select>'; echo '</td><td><input type="submit" value="'._('Add to this server').'" /></td>'; echo '</form></tr>'; } echo '</table>'; echo '</div>'; */ // Publication part if (count($groups_users_all) > 0) { echo '<div>'; echo '<h2>' . _('List of publications for this group') . '</h1>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; if (count($groups_users) > 0) { foreach ($groups_users as $group_users) { echo '<tr>'; echo '<td><a href="usersgroup.php?action=manage&id=' . $group_users->getUniqueID() . '">' . $group_users->name . '</td>'; if ($can_manage_publications) { echo '<td>'; echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this publication?') . '\');">'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="name" value="Publication" />'; echo '<input type="hidden" name="group_a" value="' . $id . '" />'; echo '<input type="hidden" name="group_u" value="' . $group_users->getUniqueID() . '" />'; echo '<input type="submit" value="' . _('Delete this publication') . '" />'; echo '</form>'; echo '</td>'; } echo '</tr>'; } } if (count($groups_users_available) > 0 and $can_manage_publications) { echo '<tr><form action="actions.php" method="get"><td>'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="name" value="Publication" />'; echo '<input type="hidden" name="group_a" value="' . $id . '" />'; echo '<select name="group_u">'; foreach ($groups_users_available as $group_users) { echo '<option value="' . $group_users->getUniqueID() . '" >' . $group_users->name . '</option>'; } echo '</select>'; echo '</td><td><input type="submit" value="' . _('Add this publication') . '" /></td>'; echo '</form></tr>'; } echo '</table>'; echo '</div>'; } echo '</div>'; echo '</div>'; echo '</div>'; page_footer(); die; }