public static function getInstance() { if (is_null(self::$instance)) { self::$instance = new self(); } return self::$instance; }
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); }
function search() { $userGroupDB = UserGroupDB::getInstance(); list($this->result, $nb) = $userGroupDB->getGroupsContains($this->search_item, $this->search_fields, $this->search_limit + 1); if ($nb || count($this->result) > $this->search_limit) { array_pop($this->result); $this->partial_result = true; } else { $this->partial_result = false; } return $this->result; }
public static function getInstance($sub_ = null) { if (is_null(self::$instance)) { self::$instance = new self(); } if (!is_null($sub_)) { if (!array_key_exists($sub_, self::$instance->instance_type)) { return null; } return self::$instance->instance_type[$sub_]; } return self::$instance; }
public function userGroups() { Logger::debug('main', 'APPSGROUPS::userGroups (for id=' . $this->id . ')'); $UserGroupDB = UserGroupDB::getInstance(); $groups = Abstract_Liaison::load('UsersGroupApplicationsGroup', NULL, $this->id); if (is_array($groups)) { $result = array(); foreach ($groups as $UGAG_liaison) { array_push($result, $UGAG_liaison->element); } return $UserGroupDB->imports($result); } else { Logger::error('main', 'APPSGROUPS::userGroups (for id=' . $this->id . ') load liaison liaison failed'); return NULL; } }
public function getUserGroups() { $liaisons = Abstract_Liaison::load('UserGroupSharedFolder', NULL, $this->id); if (is_array($liaisons) == false) { Logger::error('main', 'NetworkFolder::getUserGroups()'); return false; } $usergroupDB = UserGroupDB::getInstance(); $usergroups = array(); foreach ($liaisons as $liaison) { $usergroup = $usergroupDB->import($liaison->element); if (!is_object($usergroup)) { continue; } $usergroups[$usergroup->getUniqueID()] = $usergroup; } return $usergroups; }
public function getPublishedUserGroups() { $sharedfolderdb = SharedFolderDB::getInstance(); $usergroups_id = $sharedfolderdb->get_usersgroups($this); $usergroupDB = UserGroupDB::getInstance(); $usergroups = array(); foreach ($usergroups_id as $usergroup_id => $mode) { $usergroup = $usergroupDB->import($usergroup_id); if (!is_object($usergroup)) { continue; } if (!array_key_exists($mode, $usergroups)) { $usergroups[$mode] = array(); } $usergroups[$mode][$usergroup->getUniqueID()] = $usergroup; } return $usergroups; }
public function usersGroups() { Logger::debug('main', 'USER::UsersGroups'); $result = array(); // add the default user group is enable $prefs = Preferences::getInstance(); if (!$prefs) { Logger::critical('main', 'USER::UsersGroups get prefs failed'); die_error('get Preferences failed', __FILE__, __LINE__); } $user_default_group = $prefs->get('general', 'user_default_group'); $userGroupDB = UserGroupDB::getInstance(); $static = Abstract_Liaison::load('UsersGroup', $this->attributes['login'], NULL); if (is_null($static)) { Logger::error('main', 'User::usersGroups load(' . $this->attributes['login'] . ') is null'); return $result; } if ($userGroupDB->isDynamic()) { $dynamic = Abstract_Liaison_dynamic::load('UsersGroup', $this->attributes['login'], NULL); if (is_null($dynamic)) { $dynamic = array(); } } else { $dynamic = array(); } $rows = array_unique(array_merge($static, $dynamic)); if (!is_null($user_default_group) && $user_default_group !== '-1' && $user_default_group !== '') { $g = $userGroupDB->import($user_default_group); // safe because even if group = -1, the import failed safely if (is_object($g)) { $result[$user_default_group] = $g; } } foreach ($rows as $lug) { $g = $userGroupDB->import($lug->group); if (is_object($g)) { $result[$lug->group] = $g; } else { Logger::error('main', 'USER::usersGroups user group (\'' . $lug->group . '\') not ok'); } } return $result; }
public function usersGroups() { Logger::debug('main', 'Script::usersGroups'); $userGroupDB = UserGroupDB::getInstance(); $result = array(); // add the default user group is enable $prefs = Preferences::getInstance(); if (!$prefs) { Logger::critical('main', 'Script::usersGroups get prefs failed'); die_error('get Preferences failed', __FILE__, __LINE__); } $liaison = Abstract_Liaison::load('Scripts', $this->getAttribute('name'), NULL); if (is_null($liaison)) { Logger::error('main', 'Script::usersGroups load(' . $this->getAttribute('name') . ') is null'); return $result; } foreach ($liaison as $row) { $g = $userGroupDB->import($row->group); if (is_object($g)) { $result[] = $g; } } return $result; }
* * 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>
function action_del_sharedfolder_acl($sharedfolder_id_, $usergroup_id_) { $sharedfolderdb = SharedFolderDB::getInstance(); $sharedfolder = $sharedfolderdb->import($sharedfolder_id_); if (!$sharedfolder) { popup_error(_('Unable to delete this shared folder access')); return false; } $usergroupDB = UserGroupDB::getInstance(); $group = $usergroupDB->import($usergroup_id_); if (is_object($group) === false) { popup_error(_('Unable to load usergroup')); return false; } $ret = $sharedfolder->delUserGroup($group); if ($ret === true) { popup_info(_('Shared folder successfully modified')); return true; } else { popup_error(sprintf(_("Unable to modify shared folder named '%s'"), $sharedfolder->name)); return false; } }
public static function loadGroups($type_, $element_) { Logger::debug('main', "Abstract_Liaison_unix::loadGroups ({$type_},{$element_})"); $groups = array(); $userGroupDB = UserGroupDB::getInstance(); $userDB = UserDB::getInstance(); $element_user = $userDB->import($element_); if (!is_object($element_user)) { Logger::error('main', "Abstract_Liaison_unix::loadGroups load element ({$element_}) failed"); return NULL; } $userGroupDB = UserGroupDB::getInstance(); $groups_list = $userGroupDB->getList(); foreach ($groups_list as $group) { $liaisons = self::loadElements($type_, $group->getUniqueID()); if (is_array($liaisons)) { foreach ($liaisons as $liaison) { $l = new Liaison($element_user->getAttribute('login'), $group->getUniqueID()); $groups[$l->group] = $l; } } } return $groups; }
public static function loadGroups($type_, $element_) { Logger::debug('main', "Abstract_Liaison_ldap_posix::loadGroups ({$type_},{$element_})"); $userGroupDB = UserGroupDB::getInstance(); $userDB = UserDB::getInstance(); $groups = array(); $groups_all = $userGroupDB->getList(); if (!is_array($groups_all)) { Logger::error('main', 'Abstract_Liaison_ldap::loadGroups userGroupDB->getList failed'); return NULL; } foreach ($groups_all as $a_group) { if (in_array($element_, $a_group->usersLogin())) { $l = new Liaison($element_, $a_group->getUniqueID()); $groups[$l->group] = $l; } } return $groups; }
public function getUsersContains($contains_, $attributes_ = array('login', 'displayname'), $limit_ = 0, $group_ = null) { $sql2 = SQL::getInstance(); $search = array(); if (strlen($contains_) > 0) { $contains = str_replace('*', '%', $contains_); $contains = preg_replace('/\\%\\%+/', '%', '%' . $contains . '%'); $rules_contain = array(); foreach ($attributes_ as $attribute) { if (!in_array($attribute, array('login', 'displayname'))) { continue; } array_push($rules_contain, $sql2->QuoteField($attribute) . " LIKE " . $sql2->Quote($contains)); } if (count($rules_contain) > 0) { array_push($search, '(' . implode(' OR ', $rules_contain) . ') '); } } if (!is_null($group_)) { $userGroupDB = UserGroupDB::getInstance('static'); $group_filter_res = $userGroupDB->get_filter_groups_member($group_); if (!array_key_exists('users', $group_filter_res) || !is_array($group_filter_res['users']) || count($group_filter_res['users']) == 0) { return array(array(), false); } $users_login_sql = array(); foreach ($group_filter_res['users'] as $login) { array_push($users_login_sql, $sql2->Quote($login)); } array_push($search, $sql2->QuoteField('login') . 'IN (' . implode(',', $users_login_sql) . ')'); } $users = array(); $sizelimit_exceeded = false; $request = 'SELECT * FROM #1'; if (count($search) > 0) { $request .= ' WHERE ' . implode(' AND ', $search); } $count = 0; if ($limit_ != 0) { $request .= ' LIMIT ' . (int) ($limit_ + 1); // SQL do not have a status sizelimit_exceeded } $res = $sql2->DoQuery($request, self::table); if ($res === false) { Logger::error('main', 'USERDB::MYSQL::getUsersContains failed (sql query failed)'); return NULL; } $rows = $sql2->FetchAllResults($res); foreach ($rows as $row) { if ($limit_ > 0 && $count >= $limit_) { $sizelimit_exceeded = true; break; } $a_user = $this->generateUserFromRow($row); if ($this->isOK($a_user)) { $users[] = $a_user; $count++; } else { if (isset($row['login'])) { Logger::info('main', 'USERDB::MYSQL::getUsersContains user \'' . $row['login'] . '\' not ok'); } else { Logger::info('main', 'USERDB::MYSQL::getUsersContains user does not have login'); } } } return array($users, $sizelimit_exceeded); }
public static function loadParentsGroups($group_) { Logger::debug('main', "Abstract_Liaison_activedirectory::loadParentsGroups ({$group_})"); $userDBAD2 = new UserDB_activedirectory(); $userDBAD = UserDB::getInstance(); if (get_class($userDBAD) == get_class($userDBAD2)) { $userDBAD = $userDBAD2; // for cache } $userGroupDB = UserGroupDB::getInstance(); $groups = array(); $u = $userDBAD->importFromDN($group_); if (is_null($u)) { return $groups; } if (!$u->hasAttribute('memberof')) { return $groups; } $memberof = $u->getAttribute('memberof'); if (is_string($memberof)) { $memberof = array($memberof); } foreach ($memberof as $id_group) { $g = $userGroupDB->import('static_' . $id_group); if (!is_object($g)) { continue; } $groups[] = $g; $parent_groups = self::loadParentsGroups($id_group); $groups = array_merge($groups, $parent_groups); } return $groups; }
function show_manage($sharedfolder_id_) { $sharedfolderdb = SharedFolderDB::getInstance(); $sharedfolder = $sharedfolderdb->import($sharedfolder_id_); if (!is_object($sharedfolder)) { popup_error(sprintf(_("Failed to import shared folder '%s'"), $sharedfolder_id_)); redirect('sharedfolders.php'); } $userGroupDB = UserGroupDB::getInstance(); $all_groups = $userGroupDB->getList(true); $available_groups = array(); $used_groups = $sharedfolder->getUserGroups(); foreach ($all_groups as $group) { if (array_key_exists($group->getUniqueID(), $used_groups) === false) { $available_groups[$group->getUniqueID()] = $group; } } $can_manage_sharedfolders = isAuthorized('manageSharedFolders'); page_header(); echo '<div id="sharedfolders_div">'; echo '<h1>' . $sharedfolder->name . '</h1>'; echo '<div>'; echo '<h2>' . _('Server') . '</h2>'; echo '<a href="servers.php?action=manage&fqdn=' . $sharedfolder->server . '"> ' . $sharedfolder->server . '</a>'; echo '</div>'; echo '<br />'; echo '<div>'; echo '<h2>' . _('Configuration') . '</h2>'; echo '<table>'; echo '<tr><td>'; echo _('Name') . ': '; echo '</td><td>'; if ($can_manage_sharedfolders) { echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="SharedFolder" />'; echo '<input type="hidden" name="action" value="rename" />'; echo '<input type="hidden" name="id" value="' . $sharedfolder->id . '" />'; } echo '<input type="text" name="sharedfolder_name" value="' . $sharedfolder->name . '" />'; if ($can_manage_sharedfolders) { echo ' <input type="submit" value="' . _('Rename') . '" />'; echo '</form>'; } echo '</td></tr>'; echo '</table>'; echo '</div>'; echo '<br />'; echo '<div>'; echo '<h2>' . _('ACL') . '</h2>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($used_groups as $group) { echo '<tr>'; echo '<td><a href="usersgroup.php?action=manage&id=' . $group->getUniqueID() . '">' . $group->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_groups) > 0 and $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="sharedfolder_id" value="' . $sharedfolder->id . '" />'; echo '<select name="usergroup_id">'; foreach ($available_groups as $group) { echo '<option value="' . $group->getUniqueID() . '" >' . $group->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 '</div>'; page_footer(); }
public function import($id_) { Logger::debug('main', "UserGroupDB::activedirectory::import (id = {$id_})"); // cache if (isset($this->cache[$id_])) { return $this->cache[$id_]; } // cache end if (isset($this->cache[$id_])) { return $this->cache[$id_]; } $userGroupDB = UserGroupDB::getInstance(); $userDBAD2 = new UserDB_activedirectory(); $userDBAD = UserDB::getInstance(); if (get_class($userDBAD) == get_class($userDBAD2)) { $userDBAD = $userDBAD2; // for cache } $config_ldap = $userDBAD->makeLDAPconfig(); $config_ldap['match'] = array('description' => 'description', 'name' => 'name', 'member' => 'member'); if (str_endswith(strtolower($id_), strtolower($config_ldap['suffix'])) === true) { $id2 = substr($id_, 0, -1 * strlen($config_ldap['suffix']) - 1); } else { $id2 = $id_; } $expl = explode(',', $id2, 2); if (count($expl) == 1) { $expl = array($id2, ''); } $config_ldap['userbranch'] = $expl[1]; $buf = $config_ldap['match']; $buf['id'] = $id_; $buf['name'] = ''; $buf['description'] = ''; $ldap = new LDAP($config_ldap); $sr = $ldap->search($expl[0], array_values($config_ldap['match'])); if ($sr === false) { Logger::error('main', "UserGroupDB::activedirectory::import search failed for ({$id_})"); return NULL; } $infos = $ldap->get_entries($sr); if (count($infos) == 0) { Logger::error('main', "UserGroupDB::activedirectory::import search failed for ({$id_}), no data found on the directory"); return NULL; } $keys = array_keys($infos); $dn = $keys[0]; $info = $infos[$dn]; foreach ($config_ldap['match'] as $attribut => $match_ldap) { if (isset($info[$match_ldap][0])) { $buf[$attribut] = $info[$match_ldap][0]; } if (array_key_exists($match_ldap, $info) && is_array($info[$match_ldap])) { if (isset($info[$match_ldap]['count'])) { unset($info[$match_ldap]['count']); } $extras[$attribut] = $info[$match_ldap]; } } if ($buf['name'] == '') { Logger::error('main', "UserGroupDB::activedirectory::import({$id_}) error group name is empty"); return NULL; } $ug = new UsersGroup($buf['id'], $buf['name'], $buf['description'], true); $ug->extras = $extras; $this->cache[$buf['id']] = $ug; return $ug; }
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(); }
public function getUsersContains($contains_, $attributes_ = array('login', 'displayname'), $limit_ = 0, $group_ = null) { $users = array(); $filters = array($this->generateFilter()); if ($contains_ != '') { $contains = preg_replace('/\\*\\*+/', '*', '*' . $contains_ . '*'); // ldap does not handle multiple star characters $filter_contain_rules = array(); $missing_attribute_nb = 0; foreach ($attributes_ as $attribute) { if (!array_key_exists($attribute, $this->config['match']) || strlen($this->config['match'][$attribute]) == 0) { $missing_attribute_nb++; continue; } array_push($filter_contain_rules, $this->config['match'][$attribute] . '=' . $contains); } if ($missing_attribute_nb == count($attributes_)) { return array(array(), false); } array_push($filters, LDAP::join_filters($filter_contain_rules, '|')); } if (!is_null($group_)) { $userGroupDB = UserGroupDB::getInstance('static'); $group_filter_res = $userGroupDB->get_filter_groups_member($group_); if (array_key_exists('filter', $group_filter_res)) { array_push($filters, $group_filter_res['filter']); } else { if (!array_key_exists('users', $group_filter_res) || !is_array($group_filter_res['users']) || count($group_filter_res['users']) == 0) { return array(array(), false); } $filter_group_rules = array(); foreach ($group_filter_res['users'] as $login) { array_push($filter_group_rules, '(' . $this->config['match']['login'] . '=' . $login . ')'); } array_push($filters, LDAP::join_filters($filter_group_rules, '|')); } } $filter = LDAP::join_filters($filters, '&'); $ldap = new LDAP($this->get_user_ldap_config()); $sr = $ldap->search($filter, array_values($this->config['match']), $limit_); if ($sr === false) { Logger::error('main', 'UserDB::ldap::getUsersContaint search failed'); return array(array(), false); } $sizelimit_exceeded = $ldap->errno() === 4; // LDAP_SIZELIMIT_EXCEEDED => 0x04 $infos = $ldap->get_entries($sr); foreach ($infos as $dn => $info) { if (!is_null($group_) && array_key_exists('dns', $group_filter_res)) { if (!in_array($dn, $group_filter_res['dns'])) { continue; } } $u = $this->generateUserFromRow($info); $u->setAttribute('dn', $dn); $u = $this->cleanupUser($u); if ($this->isOK($u)) { $users[] = $u; } else { if ($u->hasAttribute('login')) { Logger::info('main', 'UserDB::ldap::getUsersContaint user \'' . $u->getAttribute('login') . '\' not ok'); } else { Logger::info('main', 'UserDB::ldap::getUsersContaint user does not have login'); } } } return array($users, $sizelimit_exceeded); }
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 cleanup_preferences() { $userGroupDB = UserGroupDB::getInstance(); $prefs = new Preferences_admin(); $default_usergroup_id = $prefs->get('general', 'user_default_group'); if ($default_usergroup_id != '') { $group = $userGroupDB->import($default_usergroup_id); if (!is_object($group)) { // unset the default usergroup $mods_enable = $prefs->set('general', 'user_default_group', ''); $prefs->backup(); } } }
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; }
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 do_save($prefs, $name) { $obj = new $name(); if (!$obj->form_valid($_POST)) { popup_error('Invalid form'); return False; } $flag = $obj->form_read($_POST, $prefs); if ($flag === False) { popup_error('form_read return an error'); return False; } $mod_user_name = 'UserDB_' . $prefs->get('UserDB', 'enable'); //var_dump($mod_user_name); $userDB = new $mod_user_name(); if (!$userDB->prefsIsValid($prefs)) { // error popup_error('Configuration is invalid for Users'); return False; } $userGroupDB = UserGroupDB::getInstance(); if (!$userGroupDB->prefsIsValid($prefs)) { // error popup_error('Configuration is invalid for UserGroups'); return False; } do_auto_clean_db($prefs); if (!$prefs->backup()) { popup_error('Unable to save configuration'); return False; } return True; }
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(); }
public static function loadGroups($type_, $element_) { Logger::debug('main', "Abstract_Liaison_ldap_memberof::loadGroups ({$type_},{$element_})"); $userGroupDB = UserGroupDB::getInstance(); $userDB = UserDB::getInstance(); $element_user = $userDB->import($element_); if (!is_object($element_user)) { Logger::error('main', "Abstract_Liaison_ldap_memberof::loadGroups load element ({$element_}) failed"); return NULL; } if ($element_user->hasAttribute('memberof')) { $groups = array(); $memberof = $element_user->getAttribute('memberof'); if (is_string($memberof)) { $memberof = array($memberof); } foreach ($memberof as $id_group) { $g = $userGroupDB->import($id_group); if (is_object($g)) { $l = new Liaison($element_, $g->getUniqueID()); $groups[$l->group] = $l; } } return $groups; } Logger::error('main', "Abstract_Liaison_ldap_memberof::loadGroups ({$type_},{$element_}) end of function"); return NULL; }
public function get_login() { Logger::debug('main', 'AuthMethod_SAML2::get_login()'); $my_settings = $this->prefs->get('AuthMethod', 'SAML2'); $saml_node = $this->user_node_request->getElementsByTagname('saml_ticket')->item(0); if (is_null($saml_node)) { Logger::error('main', 'Authentication SAML2: No incoming SAML ticket'); return NULL; } $saml_response_ticket = NULL; for ($child = $saml_node->firstChild; $child != NULL; $child = $child->nextSibling) { if ($child->nodeType != XML_TEXT_NODE) { Logger::error('main', 'Authentication SAML2: node is not text'); continue; } $saml_response_ticket = $child->wholeText; } if (is_null($saml_response_ticket)) { Logger::error('main', 'Authentication SAML2: No incoming SAML ticket (bad protocol)'); return NULL; } $settings = $this->build_saml_settings($my_settings['idp_url'], $my_settings['idp_fingerprint'], $my_settings['idp_cert']); try { $response = new OneLogin_Saml2_Response($settings, $saml_response_ticket); ob_start(); // Catch debug messages if (!$response->isValid()) { Logger::error('main', 'Authentication SAML2: the SAML response is not valid ' . ob_get_contents()); ob_end_clean(); return NULL; } ob_end_clean(); $sessionExpiration = $response->getSessionNotOnOrAfter(); if (!empty($sessionExpiration) && $sessionExpiration <= time() || !$response->validateTimestamps()) { Logger::error('main', 'Authentication SAML2: Session expired'); return NULL; } } catch (Exception $e) { Logger::error('main', 'Authentication SAML2: ' . $e->getMessage()); return NULL; } $attributes = $response->getAttributes(); $user = $this->userDB->import($response->getNameId()); if ($user == NULL) { Logger::error('main', 'Authentication SAML2: user not found'); throw new Exception(); } $login = $user->getAttribute('login'); // we recognize following attributes: // * ovd.group_member: for user group matching // * ovd.setting.*: for settings if (array_key_exists("ovd.group_member", $attributes) && is_array($attributes["ovd.group_member"])) { $userGroupDB = UserGroupDB::getInstance(); $to_delete = array(); $current_groups = array_keys(Abstract_Liaison::loadGroups('UsersGroup', $login)); foreach ($attributes["ovd.group_member"] as $group_name) { $found = false; list($groups, $sizelimit_exceeded) = $userGroupDB->getGroupsContains($group_name, array('name')); foreach ($groups as $group) { if ($group->name == $group_name) { $found = True; if (!in_array($group->getUniqueID(), $current_groups)) { Logger::info('main', 'Authentication SAML2: Add user "' . $login . '" to group "' . $group->name . '"'); $ret = Abstract_Liaison::save('UsersGroup', $login, $group->getUniqueID()); if ($ret !== true) { Logger::error('main', 'Authentication SAML2: Unable to add user "' . $login . '" to group "' . $group->name . '"'); throw new Exception(); } } else { unset($current_groups[array_search($group->getUniqueID(), $current_groups)]); } } } if (!$found) { Logger::error('main', 'Authentication SAML2: group "' . $group_name . '" not found'); throw new Exception(); } } foreach ($current_groups as $group) { Logger::info('main', 'Authentication SAML2: remove group "' . $group . '" from ' . $login); Abstract_Liaison::delete('UsersGroup', $login, $group); } } $prefs = Preferences::getInstance(); foreach ($attributes as $attribute => $value) { if (is_array($value) && count($value) == 1) { $value = $value[0]; } if (substr($attribute, 0, 12) == 'ovd.setting.') { $attribute = explode('.', $attribute); if (count($attribute) != 4) { Logger::error('main', 'Authentication SAML2: incorrect setting : "' . implode('.', $attribute) . '"'); throw new Exception(); } $container = $attribute[2]; $setting = $attribute[3]; $session_settings_defaults = $prefs->getElements('general', $container); if (!array_key_exists($setting, $session_settings_defaults)) { Logger::error('main', 'Authentication SAML2: setting "' . implode('.', $attribute) . '" does not exists'); throw new Exception(); } $config_element = clone $session_settings_defaults[$setting]; $ugp = new User_Preferences($login, 'general', $container, $setting, $config_element->content); Logger::info('main', 'Authentication SAML2: set setting "' . implode('.', $attribute) . '" to ' . str_replace("\n", "", print_r($value, true))); $ugp->value = $value; Abstract_User_Preferences::delete($login, 'general', $container, $setting); $ret = Abstract_User_Preferences::save($ugp); if (!$ret) { Logger::error('main', 'Authentication SAML2: impossible to save setting "' . implode('.', $attribute) . '"'); throw new Exception(); } } } // return true or false.. No redirection to any IdP. We must have a valid ticket at this point. No artifact method return $response->getNameId(); }
public static function loadUnique($type_, $element_, $group_) { Logger::debug('main', "Abstract_Liaison_dynamic::loadUnique ({$type_},{$element_},{$group_})"); $userGroupDB = UserGroupDB::getInstance(); $userDB = UserDB::getInstance(); $group = $userGroupDB->import($group_); if (!is_object($group)) { Logger::error('main', "Abstract_Liaison_dynamic::loadUnique load group ({$group_}) failed"); return NULL; } $user = $userDB->import($element_); if (!is_object($user)) { Logger::error('main', "Abstract_Liaison_dynamic::loadUnique load {$element} ({$element_}) failed"); return NULL; } if (!$group->containUser($user)) { Logger::error('main', "Abstract_Liaison_dynamic::loadUnique({$type_},{$element_},{$group_}) group does not contain the user"); return NULL; } else { return new Liaison($user->getAttribute('login'), $group_); } }
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; }