public function __construct() { $prefs = Preferences::getInstance(); if (!$prefs) { die_error('get Preferences failed', __FILE__, __LINE__); } $mods_enable = $prefs->get('general', 'module_enable'); if (!in_array('UserGroupDB', $mods_enable)) { die_error(_('UserGroupDB module must be enabled'), __FILE__, __LINE__); } $this->instance_type = array(); $mod_usergroup_name = 'UserGroupDB_' . $prefs->get('UserGroupDB', 'enable'); $a_userGroupDB = new $mod_usergroup_name(); $this->instance_type['static'] = $a_userGroupDB; if (Preferences::moduleIsEnabled('UserGroupDBDynamic')) { $this->instance_type['dynamic'] = UserGroupDBDynamic::getInstance(); } if (Preferences::moduleIsEnabled('UserGroupDBDynamicCached')) { $this->instance_type['dynamiccached'] = UserGroupDBDynamicCached::getInstance(); } }
function authenticate_ovd_user($login_, $password_) { // it's not the login&password from the conf file in /etc // let's try to login a real user if (Preferences::fileExists() === false) { $_SESSION['admin_error'] = _('The system is not configured'); Logger::info('main', 'admin/login.php::authenticate_ovd_user the system is not configured'); return false; } if (Preferences::moduleIsEnabled('UserDB') === false) { $_SESSION['admin_error'] = _('The module UserDB is not enabled'); Logger::info('main', 'admin/login.php::authenticate_ovd_user module UserDB is not enabled'); return false; } $userDB = UserDB::getInstance(); $user = $userDB->import($login_); if (!is_object($user)) { // the user does not exist $_SESSION['admin_error'] = _('There was an error with your authentication'); Logger::info('main', 'admin/login.php::authenticate_ovd_user authentication failed: user(login='******') does not exist'); return false; } $auth = $userDB->authenticate($user, $password_); if (!$auth) { $_SESSION['admin_error'] = _('There was an error with your authentication'); Logger::info('main', 'admin/login.php::authenticate_ovd_user authentication failed for user(login='******'): wrong password'); return false; } // the user exists, does he have right to log in the admin panel ? $policy = $user->getPolicy(); if (isset($policy['canUseAdminPanel']) && $policy['canUseAdminPanel'] == true) { return $user; } Logger::info('main', 'login.php failed to log in ' . $login_ . ' : access denied to admin panel'); $_SESSION['admin_error'] = _('Unauthorized access'); return false; }
public function get() { $used = 0; $total = 0; if (Preferences::moduleIsEnabled('ProfileDB')) { $profiledb = ProfileDB::getInstance(); $total += $profiledb->count(); $used += $profiledb->countOnServer($this->server->fqdn); } if (Preferences::moduleIsEnabled('SharedFolderDB')) { $sharedfolderdb = SharedFolderDB::getInstance(); $total += $sharedfolderdb->count(); $used += $sharedfolderdb->countOnServer($this->server->fqdn); } if ($total == 0) { return 0; } else { return 1.0 - (double) $used / (double) $total; } }
public function getSharedFolders() { if (Preferences::moduleIsEnabled('SharedFolderDB') == false) { return array(); } $session_settings_defaults = $this->getSessionSettings('session_settings_defaults'); if (array_key_exists('enable_sharedfolders', $session_settings_defaults)) { $enable_sharedfolders = $session_settings_defaults['enable_sharedfolders']; if ($enable_sharedfolders == 0) { return array(); } } $sharedfolderdb = SharedFolderDB::getInstance(); $publications = $sharedfolderdb->get_publications(); $users_group_id = array(); foreach ($publications as $publication) { if (in_array($publication['group'], $users_group_id)) { continue; } array_push($users_group_id, $publication['group']); } // from this group, which are these I am into $users_groups_mine_ids = $this->get_my_usersgroups_from_list($users_group_id); $sharedfolders = array(); foreach ($publications as $publication) { if (!in_array($publication['group'], $users_groups_mine_ids)) { continue; } if (array_key_exists($publication['share'], $sharedfolders)) { if ($publication['mode'] == 'rw' && $sharedfolders[$publication['share']]['mode'] != 'rw') { $sharedfolders[$publication['share']]['mode'] = $publication['mode']; } continue; } $share = $sharedfolderdb->import($publication['share']); if (is_null($share)) { continue; } $sharedfolders[$publication['share']] = array('share' => $share, 'mode' => $publication['mode']); } return $sharedfolders; }
popup_error(_('Shared folder management is not enabled')); redirect(); } if (!checkAuthorization('manageSharedFolders')) { redirect(); } if ($_REQUEST['action'] == 'add' && isset($_REQUEST['sharedfolder_id']) && isset($_REQUEST['usergroup_id'])) { action_add_sharedfolder_acl($_REQUEST['sharedfolder_id'], $_REQUEST['usergroup_id']); redirect(); } elseif ($_REQUEST['action'] == 'del' && isset($_REQUEST['sharedfolder_id']) && isset($_REQUEST['usergroup_id'])) { action_del_sharedfolder_acl($_REQUEST['sharedfolder_id'], $_REQUEST['usergroup_id']); redirect(); } } if ($_REQUEST['name'] == 'Profile') { if (Preferences::moduleIsEnabled('ProfileDB') == false) { popup_error(_('Profile management is not enabled')); redirect(); } if (!checkAuthorization('manageServers')) { redirect(); } if ($_REQUEST['action'] == 'del') { $profiledb = ProfileDB::getInstance(); foreach ($_REQUEST['ids'] as $id) { $network_folder = $profiledb->import($id); if (is_object($network_folder)) { if (!$network_folder->isUsed()) { $buf = $profiledb->remove($network_folder->id); } else { $buf = false;
} else { if ($serverStatus !== Session::SESSION_STATUS_DESTROYED) { Logger::info('main', "Session " . $session->id . " switch status " . Session::SESSION_STATUS_DESTROYED . " on " . $server->fqdn); $session->setServerStatus($server->id, Session::SESSION_STATUS_DESTROYED); } } } } } if (array_key_exists('shares', $ret) && is_array($ret['shares'])) { $profiledb = null; if (Preferences::moduleIsEnabled('ProfileDB')) { $profiledb = ProfileDB::getInstance(); } $sharedfolderdb = null; if (Preferences::moduleIsEnabled('SharedFolderDB')) { $sharedfolderdb = SharedFolderDB::getInstance(); } $disabled_users = array(); foreach ($ret['shares'] as $share) { if (is_object($sharedfolderdb) && $sharedfolderdb->exists($share['id'])) { $buf = $sharedfolderdb->import($share['id']); $db = $sharedfolderdb; } else { if (is_object($profiledb) && $profiledb->exists($share['id'])) { $buf = $profiledb->import($share['id']); $db = $profiledb; } else { $buf = false; } }
public static function load_orphans() { Logger::debug('main', 'Starting Abstract_Network_Folder::load_orphans()'); $sharedfolderdb = null; if (Preferences::moduleIsEnabled('SharedFolderDB')) { $sharedfolderdb = SharedFolderDB::getInstance(); } $profiles = null; if (Preferences::moduleIsEnabled('ProfileDB')) { $profiledb = ProfileDB::getInstance(); } $SQL = SQL::getInstance(); if (is_null($sharedfolderdb) && is_null($profiledb)) { $SQL->DoQuery('SELECT * FROM #1;', self::$table); } else { if (is_null($sharedfolderdb)) { $SQL->DoQuery('SELECT * FROM #1 WHERE @2 NOT IN ( SELECT @2 FROM #3 );', self::$table, 'id', ProfileDB_internal::$table); } else { if (is_null($profiledb)) { $SQL->DoQuery('SELECT * FROM #1 WHERE @2 NOT IN ( SELECT @2 FROM #3 );', self::$table, 'id', SharedFolderDB_internal::$table); } else { $SQL->DoQuery('SELECT * FROM #1 WHERE @2 NOT IN ( SELECT @2 FROM #3 ) AND @2 NOT IN ( SELECT @2 FROM #4 )', self::$table, 'id', ProfileDB_internal::$table, SharedFolderDB_internal::$table); } } } $rows = $SQL->FetchAllResults(); $network_folders = array(); foreach ($rows as $row) { $Network_Folder = self::generateFromRow($row); if (!is_object($Network_Folder)) { continue; } $network_folders[] = $Network_Folder; } return $network_folders; }
* 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__) . '/../admin/includes/core-minimal.inc.php'; if (Preferences::fileExists() === false) { exit(1); } //BEGIN Updating logs cache $servers = Abstract_Server::load_all(); foreach ($servers as $server) { $buf = new Server_Logs($server); $buf->process(); } //END Updating logs cache //BEGIN UserGroupDBDynamic_cached update if (Preferences::moduleIsEnabled('UserGroupDBDynamicCached')) { $ugdbdc = UserGroupDBDynamicCached::getInstance(); $groups = $ugdbdc->getList(); if (!is_array($groups)) { Logger::error('main', '(hourly cron) UserGroupDBDynamic_cached->getList() failed'); } else { foreach ($groups as $a_group) { $ret = $ugdbdc->updateCache($a_group); if ($ret !== true) { Logger::error('main', '(hourly cron) UserGroupDBDynamic_cached->updateCache for group \'' . $a_group->getUniqueID() . '\' failed'); } } } } //END UserGroupDBDynamic_cached update exit(0);
public static function removeRole($fqdn_, $role_) { Logger::debug('main', "Starting Abstract_Server::removeRole for '{$fqdn_}' removing '{$role_}'"); if (substr($fqdn_, -1) == '.') { $fqdn_ = substr($fqdn_, 0, strlen($fqdn_) - 1); } $a_server = Abstract_Server::load($fqdn_); if (is_object($a_server) == false) { Logger::error('main', "Starting Abstract_Server::removeRole error failed to load server '{$fqdn_}'"); return false; } $roles = $a_server->getAttribute('roles'); if (is_array($roles) == false) { return false; } if (in_array($role_, $roles) == false) { return false; } switch ($role_) { case Server::SERVER_ROLE_APS: $prefs = Preferences::getInstance(); if (!$prefs) { die_error('get Preferences failed', __FILE__, __LINE__); } $slave_server_settings = $prefs->get('general', 'slave_server_settings'); $remove_orphan = (bool) $slave_server_settings['remove_orphan']; Abstract_Liaison::delete('ApplicationServer', NULL, $fqdn_); if ($remove_orphan) { $apps = $a_server->getApplications(); $applicationDB = ApplicationDB::getInstance(); // remove the orphan applications if (is_array($apps)) { foreach ($apps as $an_application) { if ($an_application->isOrphan()) { Logger::debug('main', "Abstract_Server::delete {$an_application} is orphan"); $applicationDB->remove($an_application); } } } } $tm = new Tasks_Manager(); $tm->load_from_server($fqdn_); foreach ($tm->tasks as $a_task) { $tm->remove($a_task->id); } break; case Server::SERVER_ROLE_FS: if (Preferences::moduleIsEnabled('ProfileDB')) { $profiledb = ProfileDB::getInstance(); $folders = $profiledb->importFromServer($fqdn_); foreach ($folders as $a_folder) { $profiledb->remove($a_folder->id); } } if (Preferences::moduleIsEnabled('SharedFolderDB')) { $sharedfolderdb = SharedFolderDB::getInstance(); $folders = $sharedfolderdb->importFromServer($fqdn_); foreach ($folders as $a_folder) { $profiledb->remove($a_folder->id); } } break; // case Server::SERVER_ROLE_GATEWAY: // break; } return true; }
public function updateNetworkFolders() { if (!is_array($this->roles) || !array_key_exists(Server::SERVER_ROLE_FS, $this->roles)) { Logger::critical('main', 'Server::updateNetworkFolders - Not an FS'); return false; } if (!$this->isOnline()) { Logger::debug('main', 'Server::updateNetworkFolders server "' . $this->fqdn . ':' . $this->web_port . '" is not online'); return false; } $forders_on_server = $this->getNetworkFoldersList(); if (is_array($forders_on_server) === false) { Logger::error('main', 'Server::updateNetworkFolders getNetworkFoldersList failed for fqdn=' . $this->fqdn); return false; } $folders_on_sm1 = array(); if (Preferences::moduleIsEnabled('ProfileDB')) { $profiledb = ProfileDB::getInstance(); $folders_on_sm1 = $profiledb->importFromServer($this->fqdn); } $folders_on_sm2 = array(); if (Preferences::moduleIsEnabled('SharedFolderDB')) { $sharedfolderdb = SharedFolderDB::getInstance(); $folders_on_sm2 = $sharedfolderdb->importFromServer($this->fqdn); } $folders_on_sm = array(); if (is_array($folders_on_sm1)) { $folders_on_sm = array_merge($folders_on_sm, $folders_on_sm1); } if (is_array($folders_on_sm2)) { $folders_on_sm = array_merge($folders_on_sm, $folders_on_sm2); } foreach ($forders_on_server as $folder_id) { if (Preferences::moduleIsEnabled('SharedFolderDB')) { $folder = $sharedfolderdb->import($folder_id); if ($folder) { $db = $sharedfolderdb; } } if (Preferences::moduleIsEnabled('ProfileDB')) { if (!$folder) { $folder = $profiledb->import($folder_id); $db = $profiledb; } } if (is_object($folder) === false) { // networkfolder does not exist $folder = new NetworkFolder(); $folder->id = $folder_id; $folder->name = $folder_id; $folder->server = $this->fqdn; $profiledb->remove($folder); $sharedfolderdb->remove($folder); } } return true; }
public function getSharedFolders() { $sharedfolders = array(); if (Preferences::moduleIsEnabled('SharedFolderDB') == false) { return array(); } $session_settings_defaults = $this->getSessionSettings('session_settings_defaults'); if (array_key_exists('enable_sharedfolders', $session_settings_defaults)) { $enable_sharedfolders = $session_settings_defaults['enable_sharedfolders']; if ($enable_sharedfolders == 0) { return $sharedfolders; } } $usergroups = $this->usersGroups(); if (is_array($usergroups) === false) { Logger::error('main', 'User::getSharedFolders usersGroups failed for user (login='******'login') . ')'); } else { $sharedfolderdb = SharedFolderDB::getInstance(); foreach ($usergroups as $group) { $prefs_of_a_group_unsort = Abstract_UserGroup_Preferences::loadByUserGroupId($group->getUniqueID(), 'general', 'session_settings_defaults'); if (array_key_exists('enable_sharedfolders', $prefs_of_a_group_unsort)) { $pref = $prefs_of_a_group_unsort['enable_sharedfolders']; $element = $pref->toConfigElement(); $enable_sharedfolders = $element->content; if ($enable_sharedfolders == 0) { continue; } } $networkfolders = $sharedfolderdb->importFromUsergroup($group->getUniqueID()); foreach ($networkfolders as $a_networkfolder) { $sharedfolders[] = $a_networkfolder; } } } return array_unique($sharedfolders); }
private static function get_liaisons_types() { $liaisons_types = array('ApplicationServer', 'AppsGroup', 'ApplicationMimeType', 'ServerSession', 'UsersGroup', 'UsersGroupApplicationsGroup'); if (Preferences::moduleIsEnabled('ProfileDB')) { $liaisons_types[] = 'UserProfile'; } if (Preferences::moduleIsEnabled('UsersGroupDBDynamic') || Preferences::moduleIsEnabled('UsersGroupDBDynamicCached')) { $liaisons_types[] = 'UsersGroupCached'; } return $liaisons_types; }
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; }
$menu['applications'] = array('id' => 'applications', 'name' => _('Applications'), 'page' => 'applications.php', 'parent' => array()); $menu['configuration'] = array('id' => 'configuration', 'name' => _('Configuration'), 'page' => 'configuration-sumup.php', 'parent' => array()); $menu['status'] = array('id' => 'status', 'name' => _('Status'), 'page' => 'sessions.php', 'parent' => array()); if (isAuthorized('viewServers')) { $menu['servers_child'] = array('id' => 'servers_child', 'name' => _('Servers'), 'page' => 'servers.php', 'parent' => array('servers')); $menu['servers_unregistered'] = array('id' => 'servers_unregistered', 'name' => _('Unregistered servers'), 'page' => 'servers.php?view=unregistered', 'parent' => array('servers')); $menu['tasks'] = array('id' => 'tasks', 'name' => _('Tasks'), 'page' => 'tasks.php', 'parent' => array('servers')); } if (isAuthorized('viewSharedFolders')) { if (Preferences::moduleIsEnabled('SharedFolderDB')) { $menu['sharedfolders'] = array('id' => 'sharedfolders', 'name' => _('Shared folders'), 'page' => 'sharedfolders.php', 'parent' => array('servers')); } } if (isAuthorized('viewSharedFolders')) { // it should be viewProfile if (Preferences::moduleIsEnabled('ProfileDB')) { $menu['profile'] = array('id' => 'profiles', 'name' => _('Profiles'), 'page' => 'profiles.php', 'parent' => array('servers')); } } if (isAuthorized('viewUsers')) { $menu['user_child'] = array('id' => 'user_child', 'name' => _('Users'), 'page' => 'users.php', 'parent' => array('users')); } if (isAuthorized('viewUsersGroups')) { $menu['users_groups'] = array('id' => 'users_groups', 'name' => _('Users Groups'), 'page' => 'usersgroup.php', 'parent' => array('users')); } if (isAuthorized('viewApplications')) { $menu['applications_child'] = array('id' => 'applications_child', 'name' => _('Applications'), 'page' => 'applications.php', 'parent' => array('applications')); } if (isAuthorized('viewApplicationsGroups')) { $menu['applications_groups'] = array('id' => 'applications_groups', 'name' => _('Applications Groups'), 'page' => 'appsgroup.php', 'parent' => array('applications')); }
public function remove($usergroup_) { Logger::debug('main', "USERGROUPDB::remove({$usergroup_})"); if (array_key_exists($usergroup_->id, $this->cache)) { unset($this->cache[$usergroup_->id]); } // first we delete liaisons $sql2 = SQL::getInstance(); Abstract_Liaison::delete('UsersGroupApplicationsGroup', $usergroup_->getUniqueID(), NULL); Abstract_Liaison::delete('UsersGroup', NULL, $usergroup_->getUniqueID()); // second we delete sharedfolder acls for the group if (Preferences::moduleIsEnabled('SharedFolderDB')) { $sharedfolderdb = SharedFolderDB::getInstance(); $networkfolders = $sharedfolderdb->importFromUsergroup($usergroup_->getUniqueID()); if (is_array($networkfolders) && count($networkfolders) > 0) { foreach ($networkfolders as $networkfolder) { $networkfolder->delUserGroup($usergroup_); } } } // third remove the preferences if it is default if ($usergroup_->isDefault()) { // unset the default usergroup $prefs = new Preferences_admin(); $mods_enable = $prefs->set('general', 'user_default_group', ''); $prefs->backup(); } // fourth we delete the group $res = $sql2->DoQuery('DELETE FROM @1 WHERE @2 = %3', $this->table, 'id', $usergroup_->id); return $res !== false; }
public static function loadGroups($type_, $element_) { Logger::debug('main', "Abstract_Liaison_dynamic::loadGroups ({$type_},{$element_})"); $groups = array(); if (Preferences::moduleIsEnabled('UserGroupDBDynamic')) { $userGroupDB_dynamic = UserGroupDBDynamic::getInstance(); $usergroup_list = $userGroupDB_dynamic->getList(); foreach ($usergroup_list as $group) { if (in_array($element_, $group->usersLogin())) { $l = new Liaison($element_, $group->getUniqueID()); $groups[$l->group] = $l; } } } if (Preferences::moduleIsEnabled('UserGroupDBDynamicCached')) { $userGroupDB_dynamic = UserGroupDBDynamicCached::getInstance(); $usergroup_list = $userGroupDB_dynamic->getList(); foreach ($usergroup_list as $group) { if (in_array($element_, $group->usersLogin())) { $l = new Liaison($element_, $group->getUniqueID()); $groups[$l->group] = $l; } } } return $groups; }
function server_display_role_fs($server_, $var_) { if (Preferences::moduleIsEnabled('ProfileDB') == false && Preferences::moduleIsEnabled('SharedFolderDB') == false) { return; } $datas = array(0 => array('name' => _('User profiles on the server'), 'folder' => $var_['profiles'], 'usedby' => $var_['used by profiles'], 'page' => 'users'), 1 => array('name' => _('Shared folders on the server'), 'folder' => $var_['sharedfolders'], 'usedby' => $var_['used by sharedfolders'], 'page' => 'usersgroup')); foreach ($datas as $k => $data) { if (is_array($data['folder']) && count($data['folder']) > 0 && is_array($data['usedby'])) { $mass_action = false; if (count($data['folder']) > 1) { foreach ($data['folder'] as $a_networkfolder) { if ($a_networkfolder->isUsed()) { continue; } $mass_action = true; break; } } echo '<h3>' . $data['name'] . '</h3>'; $count = 0; echo '<table id="available_networkfolder_table_' . $k . '" class="main_sub sortable" border="0" cellspacing="1" cellpadding="3">'; echo '<thead>'; echo '<tr class="title">'; if (isset($mass_action) && $mass_action === true) { echo '<th class="unsortable"></th>'; } if ($k != 0) { echo '<th>' . _('Name') . '</th>'; } echo '<th class="unsortable">' . ($k == 0 ? _('Owner') : _('Used by')) . '</th>'; echo '<th>' . _('Status') . '</th>'; if (isset($mass_action) && $mass_action === true) { echo '<th class="unsortable"></th>'; } echo '</tr>'; echo '</thead>'; echo '<tbody>'; foreach ($data['folder'] as $a_networkfolder) { $content = 'content' . ($count++ % 2 == 0 ? 1 : 2); echo '<tr class="' . $content . '">'; if (count($data['folder']) > 1 && isset($mass_action) && $mass_action === true) { echo '<td>'; if (!$a_networkfolder->isUsed()) { echo '<input class="input_checkbox" type="checkbox" name="ids[]" value="' . $a_networkfolder->id . '" />'; } echo '</td>'; } if ($k != 0) { echo '<td>'; if ($data['page'] !== 'users') { echo '<a href="sharedfolders.php?action=manage&id=' . $a_networkfolder->id . '">' . $a_networkfolder->name . '</a>'; } else { echo $a_networkfolder->name; } echo '</td>'; } echo '<td>'; if (array_key_exists($a_networkfolder->id, $data['usedby']) && is_null($data['page']) === false) { $objs = $data['usedby'][$a_networkfolder->id]; if ($k != 0) { echo '<ul>'; foreach ($objs as $a_obj) { echo '<li>'; echo '<a href="' . $data['page'] . '.php?action=manage&id=' . $a_obj['id'] . '">' . $a_obj['name'] . '</a>'; echo '</li>'; } echo '</ul>'; } else { $a_obj = array_pop($objs); echo '<a href="' . $data['page'] . '.php?action=manage&id=' . $a_obj['id'] . '">' . $a_obj['name'] . '</a>'; } } echo '</td>'; echo '<td>'; echo '<span class="msg_' . NetworkFolder::colorStatus($a_networkfolder->status) . '">' . NetworkFolder::textStatus($a_networkfolder->status) . '</span>'; echo '</td>'; echo '<td>'; if (!$a_networkfolder->isUsed()) { echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . ($k == 0 ? _('Are you sure you want to delete this user profile?') : _('Are you sure you want to delete this network folder?')) . '\');">'; echo '<input type="hidden" name="name" value="' . ($k == 0 ? 'Profile' : 'SharedFolder') . '" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="ids[]" value="' . $a_networkfolder->id . '" />'; echo '<input type="submit" value="' . _('Delete') . '" />'; echo '</form>'; } echo '</td>'; echo '</tr>'; } echo '</tbody>'; if (count($data['folder']) > 1 && isset($mass_action) && $mass_action === true) { $content = 'content' . ($count++ % 2 == 0 ? 1 : 2); echo '<tfoot>'; echo '<tr class="' . $content . '">'; echo '<td colspan="' . ($k != 0 ? 4 : 3) . '">'; echo '<a href="javascript:;" onclick="markAllRows(\'available_networkfolder_table_' . $k . '\'); return false">' . _('Mark all') . '</a>'; echo ' / <a href="javascript:;" onclick="unMarkAllRows(\'available_networkfolder_table_' . $k . '\'); return false">' . _('Unmark all') . '</a>'; echo '</td>'; echo '<td>'; echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . ($k == 0 ? _('Are you sure you want to delete these user profiles?') : _('Are you sure you want to delete these network folders?')) . '\') && updateMassActionsForm(this, \'available_networkfolder_table_' . $k . '\');">'; echo '<input type="hidden" name="name" value="' . ($k == 0 ? 'Profile' : 'SharedFolder') . '" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="submit" name="to_production" value="' . _('Delete') . '"/>'; echo '</form>'; echo '</td>'; echo '</tr>'; echo '</tfoot>'; } echo '</table>'; echo '<br />'; } } if ($server_->isOnline()) { echo '<h3>' . _('Action') . '</h3>'; echo '<table>'; echo '<tr><form action="actions.php" method="post"><td>'; echo '<input type="hidden" name="name" value="SharedFolder" />'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="text" name="sharedfolder_name" value="" />'; echo '<input type="hidden" name="sharedfolder_server" value="' . $server_->fqdn . '" />'; echo '</td><td><input type="submit" value="' . _('Create this shared folder') . '" /></td>'; echo '</form></tr>'; echo '</table>'; } }