Example #1
0
function init($host_, $database_, $prefix_, $user_, $password_)
{
    $p = new Preferences_admin();
    $sql_conf = array();
    $sql_conf['host'] = $host_;
    $sql_conf['database'] = $database_;
    $sql_conf['user'] = $user_;
    $sql_conf['password'] = $password_;
    $sql_conf['prefix'] = $prefix_;
    $p->set('general', 'sql', $sql_conf);
    $ret = $p->isValid();
    if ($ret !== true) {
        echo 'error isValid : ' . $ret . "\n";
        return false;
    }
    $p->backup();
    return true;
}
Example #2
0
 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;
 }
Example #3
0
 public function remove($usergroup_)
 {
     if ($usergroup_->isDefault()) {
         // unset the default usergroup
         $prefs = new Preferences_admin();
         $mods_enable = $prefs->set('general', 'user_default_group', '');
         $prefs->backup();
     }
     return true;
 }
Example #4
0
        // conf not valid
        if ($setup) {
            popup_error('Error : ' . $ret);
            redirect('configuration.php?action=init');
        } else {
            header_static(_('Configuration'));
            echo '<p class="msg_error centered">' . $ret . '</p>';
            print_prefs($prefs);
            footer_static();
        }
    }
} else {
    $can_manage_configuration = isAuthorized('manageConfiguration');
    if (isset($_GET['action']) && $_GET['action'] == 'init') {
        try {
            $prefs = new Preferences_admin();
        } catch (Exception $e) {
        }
        $prefs->initialize();
        require_once dirname(__FILE__) . '/includes/page_template.php';
        page_header();
        // printing of preferences
        if ($can_manage_configuration) {
            echo '<form method="post" action="configuration.php">';
            echo '<input type="hidden" name="setup" value="setup" />';
        }
        print_prefs5($prefs, 'general', 'sql');
        if ($can_manage_configuration) {
            echo '<input type="submit" id="submit" name="submit"  value="' . _('Save') . '" />';
            echo '</form>';
        }
Example #5
0
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * 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-minimal.inc.php';
if (!defined('STDIN')) {
    echo "This script cannot be used in CGI mode.\n";
    exit(1);
}
// Check if session manager is in maintenance
try {
    $prefs = new Preferences_admin();
} catch (Exception $e) {
    echo "Internal error while loading settings, unable to continue.\n";
    exit(2);
}
if ($prefs->isValid() !== true) {
    // First install
    exit(0);
}
$system_in_maintenance = $prefs->get('general', 'system_in_maintenance');
if ($system_in_maintenance != '1') {
    echo "The Session Manager is in production mode. It's not possible to perform an upgrade until it's on maintenance mode.\n";
    exit(3);
}
// Check if there still have sessions
$nb_sessions = Abstract_Session::countByStatus();
Example #6
0
         }
         if (!$userGroupDB->update($group)) {
             popup_error(sprintf(_("Unable to update Usergroup '%s'"), $group->name));
             redirect();
         }
         popup_info(sprintf(_("UserGroup '%s' successfully modified"), $group->name));
         redirect('usersgroup.php?action=manage&id=' . $group->getUniqueID());
     }
 }
 if ($_REQUEST['action'] == 'set_default' or $_REQUEST['action'] == 'unset_default') {
     if (!checkAuthorization('manageConfiguration')) {
         die_error(_('Not enough rights'));
     }
     if (isset($_REQUEST['id'])) {
         try {
             $prefs = new Preferences_admin();
         } catch (Exception $e) {
             // Error header save
             die_error('error R6');
         }
         $id = $_REQUEST['id'];
         $new_default = $_REQUEST['action'] == 'set_default' ? $id : NULL;
         $group = $userGroupDB->import($id);
         if (!is_object($group)) {
             popup_error(sprintf(_("Failed to import group '%s'"), $id));
             redirect();
         }
         $mods_enable = $prefs->set('general', 'user_default_group', $new_default);
         if (!$prefs->backup()) {
             Logger::error('main', 'usersgroup.php action_default: Unable to save prefs');
             popup_error(_("Unable to save prefs"));
Example #7
0
     redirect();
 }
 // saving preferences
 unset($_POST['submit']);
 $setup = false;
 if (isset($_POST['setup'])) {
     $setup = true;
     unset($_POST['setup']);
     $elements_form = formToArray($_POST);
     try {
         $prefs = new Preferences_admin($elements_form, true);
     } catch (Exception $e) {
     }
 } else {
     $elements_form = formToArray($_POST);
     $prefs = new Preferences_admin($elements_form);
 }
 $ret = $prefs->backup();
 if ($ret > 0) {
     // configuration saved
     popup_info(_('Configuration successfully saved'));
     if (defined('EXPERT_MODE') && EXPERT_MODE === true && !isset($_SESSION['admin_ovd_user'])) {
         redirect();
     } else {
         redirect('index.php');
     }
 } else {
     require_once dirname(dirname(__FILE__)) . '/includes/page_template_static.php';
     header_static(_('Configuration'));
     echo 'problem : configuration not saved<br>';
     // TODO (class msg...) + gettext
Example #8
0
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * 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';
if (!isset($_REQUEST['tempnam'])) {
    header('HTTP/1.1 400 Bad Request');
    die;
}
$prefs = new Preferences_admin();
if (!$prefs) {
    header('HTTP/1.1 500 Internal Error');
    die;
}
$mods_enable = $prefs->get('general', 'module_enable');
if (!in_array('ApplicationDB', $mods_enable)) {
    header('HTTP/1.1 500 Internal Error');
    die;
}
if (!file_exists('/tmp/ico' . substr($_REQUEST['tempnam'], 3))) {
    header('HTTP/1.1 404 Not Found');
    die;
}
header('Content-Type: image/png');
echo @file_get_contents('/tmp/ico' . substr($_REQUEST['tempnam'], 3));
 **/
require_once dirname(dirname(__FILE__)) . '/includes/core.inc.php';
if (!checkAuthorization('viewConfiguration')) {
    redirect('index.php');
}
// core of the page
$sep = '___';
if (isset($_POST['submit'])) {
    if (!checkAuthorization('manageConfiguration')) {
        redirect();
    }
    // saving preferences
    unset($_POST['submit']);
    unset($_POST['mode']);
    $elements_form = formToArray($_POST);
    $prefs = new Preferences_admin($elements_form, true);
    $ret = $prefs->backup();
    if ($ret > 0) {
        $buf = $prefs->get('general', 'admin_language');
        $language = locale2unix($buf);
        setlocale(LC_ALL, $language . '.UTF-8');
        // configuration saved
        popup_info(_('Configuration successfully saved'));
        redirect();
    } else {
        require_once dirname(dirname(__FILE__)) . '/includes/page_template_static.php';
        header_static(_('Configuration'));
        echo '<p class="msg_error centered">problem : configuration not saved</p>';
        // TODO (class msg...) + gettext
        footer_static();
    }
Example #10
0
function updateVIP($vip)
{
    $t = false;
    $prefs_vars = extractVarsFromConfFile();
    if (!count($prefs_vars)) {
        popup_error(_('Could not extract configuration values from file!'));
        return false;
    }
    $prefs = Preferences::getInstance();
    $all_prefs = $prefs->get('HA', 'high_availability');
    $prefs_vars["VIP"] = $vip;
    $all_prefs["VIP"] = $vip;
    if (isset($all_prefs["VIP"]) && isset($prefs_vars["VIP"])) {
        try {
            $prefs_admin = new Preferences_admin();
            $prefs_admin->set('HA', 'high_availability', $all_prefs);
            $ret = $prefs_admin->backup();
            return true;
        } catch (Exception $e) {
            popup_error(_('An error occured when updating the virtual IP!'));
        }
        return false;
    } else {
        popup_error(_('An error occured when updating the virtual IP!'));
    }
    return false;
}
Example #11
0
function show_manage($id)
{
    global $schedules;
    $group = $_SESSION['service']->users_group_info($id);
    if (!is_object($group)) {
        die_error(_('Failed to load User Group'));
    }
    $usergroupdb_rw = usergroupdb_is_writable();
    $policy = $group->getAttribute('policy');
    $policy_rule_enable = 0;
    $policy_rules_disable = 0;
    foreach ($policy as $key => $value) {
        if ($value === true) {
            $policy_rule_enable++;
        } else {
            $policy_rules_disable++;
        }
    }
    $default_policy = $group->getAttribute('default_policy');
    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;
    }
    if ($group->isDefault() == false) {
        $users = array();
        if ($group->hasAttribute('users')) {
            $users = $group->getAttribute('users');
        }
        $users_partial_list = $group->getAttribute('users_partial_list');
        $usersList = new UsersList($_REQUEST);
        if ($users_partial_list) {
            if ($usersList->is_empty_filter()) {
                $usersList->set_external_result($users, true);
            } else {
                $users2 = $usersList->search($id);
                if (is_null($users2)) {
                    die_error(_('Error while requesting users'), __FILE__, __LINE__);
                }
                $users = array();
                foreach ($users2 as $user) {
                    $users[$user->getAttribute('login')] = $user->getAttribute('displayname');
                }
            }
        }
        asort($users);
        $has_users = count($users) > 0;
        if ($usergroupdb_rw) {
            $users_all = $usersList->search();
            if (is_null($users_all)) {
                $users_all = array();
            }
            $users_available = array();
            foreach ($users_all as $user) {
                if (!array_key_exists($user->getAttribute('login'), $users)) {
                    $users_available[] = $user->getAttribute('login');
                }
            }
        } else {
            $users_available = array();
            $users_all = $users;
            uasort($users_all, "user_cmp");
        }
        $search_form = $usersList->getForm();
    } else {
        $users = array();
        $users_available = array();
        $users_all = array();
        $search_form = null;
    }
    // Default usergroup
    $is_default_group = $group->isDefault();
    // Publications
    $groups_apps = array();
    if ($group->hasAttribute('applicationsgroups')) {
        $groups_apps = $group->getAttribute('applicationsgroups');
    }
    $groups_apps_all = $_SESSION['service']->applications_groups_list();
    $groups_apps_available = array();
    foreach ($groups_apps_all as $group_apps) {
        if (!array_key_exists($group_apps->id, $groups_apps)) {
            $groups_apps_available[] = $group_apps;
        }
    }
    // Scripts
    $groups_scripts_all = $_SESSION['service']->scripts_groups_list($id);
    $all_scripts = $_SESSION['service']->scripts_list();
    $scripts_available = array();
    foreach ($all_scripts as $script) {
        if (!array_key_exists($script->id, $groups_scripts_all)) {
            $scripts_available[] = $script;
        }
    }
    // Servers publications
    $servers_groups_list = $_SESSION['service']->servers_groups_list();
    $servers_groups_published = array();
    if ($group->hasAttribute('serversgroups')) {
        $servers_groups_published = $group->getAttribute('serversgroups');
    }
    $can_manage_scripts = isAuthorized('manageScripts');
    $can_manage_usersgroups = isAuthorized('manageUsersGroups');
    $can_manage_publications = isAuthorized('managePublications');
    $can_manage_sharedfolders = isAuthorized('manageServers');
    $prefs_of_a_group = array();
    $unuse_settings = array();
    $session_prefs = array();
    if ($group->hasAttribute('settings_default')) {
        $prefs = new Preferences_admin(null, false);
        $categs = $group->getAttribute('settings_default');
        $categs2 = array();
        if ($group->hasAttribute('settings')) {
            $categs2 = $group->getAttribute('settings');
        }
        foreach ($categs as $categ => $settings) {
            $session_prefs[$categ] = array();
            $prefs_of_a_group[$categ] = array();
            $unuse_settings[$categ] = array();
            foreach ($settings as $setting_id => $setting_attributes) {
                $p = $prefs->load_element($setting_attributes, 'general_' . $categ);
                $session_prefs[$categ][$setting_id] = $p;
                if (array_key_exists($categ, $categs2) && array_key_exists($setting_id, $categs2[$categ])) {
                    $p2 = clone $p;
                    $p2->content = $categs2[$categ][$setting_id];
                    $prefs_of_a_group[$categ][$setting_id] = $p2;
                } else {
                    $unuse_settings[$categ][$setting_id] = $p;
                }
            }
        }
    }
    page_header();
    echo '<div id="users_div">';
    echo '<h1><a href="?">' . _('User Group 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->id . '" />';
            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 />';
    }
    // User list
    if ($group->isDefault() || (count($users_all) > 0 || !$usersList->is_empty_filter() || count($users) > 0)) {
        echo '<div>';
        echo '<h2>' . _('List of users in this group') . '</h2>';
        if (!is_null($search_form)) {
            echo $search_form;
        }
        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_login => $user_displayname) {
                    echo '<tr>';
                    echo '<td><a href="users.php?action=manage&id=' . $user_login . '">' . $user_login . '</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_login . '" />';
                        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>';
            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_id => $groups_app_name) {
                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>';
    }
    // Scripts part
    if (count($groups_scripts_all) > 0) {
        echo '<div>';
        echo '<h2>' . _('List of scripts for this group') . '</h2>';
        echo '<table border="0" cellspacing="1" cellpadding="3">';
        if (count($groups_scripts_all) > 0) {
            foreach ($groups_scripts_all as $script) {
                echo '<tr>';
                echo '<td><a href="script.php?action=manage&amp;id=' . $script["id"] . '">' . $script["name"] . '</a></td>';
                if ($can_manage_scripts) {
                    echo '<td><form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this user from this group?') . '\');">';
                    echo '<input type="hidden" name="name" value="Script_UserGroup" />';
                    echo '<input type="hidden" name="action" value="del" />';
                    echo '<input type="hidden" name="group" value="' . $id . '" />';
                    echo '<input type="hidden" name="element" value="' . $script["id"] . '" />';
                    echo '<input type="submit" value="' . _('Delete from this group') . '" />';
                    echo '</form></td>';
                }
                echo '</tr>';
            }
        }
        if (count($scripts_available) > 0 and $can_manage_scripts) {
            echo '<tr><form action="actions.php" method="post"><td>';
            echo '<input type="hidden" name="action" value="add" />';
            echo '<input type="hidden" name="name" value="Script_UserGroup" />';
            echo '<input type="hidden" name="group" value="' . $id . '" />';
            echo '<select name="element">';
            foreach ($scripts_available as $script) {
                echo '<option value="' . $script->id . '" >' . $script->name . '</option>';
            }
            echo '</select>';
            echo '</td><td><input type="submit" value="' . _('Add this script') . '" /></td>';
            echo '</form></tr>';
        }
        echo '</table>';
        echo '</div>';
    }
    // Servers publications part
    if (count($servers_groups_list) > 0) {
        echo '<div>';
        echo '<h2>' . _('List of published Server Groups for this group') . '</h1>';
        echo '<table border="0" cellspacing="1" cellpadding="3">';
        if (count($servers_groups_published) > 0) {
            foreach ($servers_groups_published as $servers_group_id => $servers_group_name) {
                echo '<tr>';
                echo '<td><a href="serversgroup.php?action=manage&id=' . $servers_group_id . '">' . $servers_group_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="UsersGroupServersGroup" />';
                    echo '<input type="hidden" name="users_group" value="' . $id . '" />';
                    echo '<input type="hidden" name="servers_group" value="' . $servers_group_id . '" />';
                    echo '<input type="submit" value="' . _('Delete this publication') . '" />';
                    echo '</form>';
                    echo '</td>';
                }
                echo '</tr>';
            }
        }
        if (count($servers_groups_list) > count($servers_groups_published) 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="UsersGroupServersGroup" />';
            echo '<input type="hidden" name="users_group" value="' . $id . '" />';
            echo '<select name="servers_group">';
            foreach ($servers_groups_list as $servers_group) {
                if (array_key_exists($servers_group->id, $servers_groups_published)) {
                    continue;
                }
                echo '<option value="' . $servers_group->id . '" >' . $servers_group->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 = $default_policy[$key] === $value;
        $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->id . '" />';
            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->id . '" />';
        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 (is_module_enabled('SharedFolderDB')) {
        $all_sharedfolders = $_SESSION['service']->shared_folders_list();
        if (is_null($all_sharedfolders)) {
            $all_sharedfolders = array();
        }
        if (count($all_sharedfolders) > 0) {
            $available_sharedfolders = array();
            $used_sharedfolders = array();
            if ($group->hasAttribute('shared_folders')) {
                $data = $group->getAttribute('shared_folders');
                $mods_by_share = array();
                foreach ($data as $mode => $used_sharedfolders2) {
                    foreach ($used_sharedfolders2 as $share_id => $share_name) {
                        $used_sharedfolders[$share_id] = $share_name;
                        $mods_by_share[$share_id] = $mode;
                    }
                }
            }
            foreach ($all_sharedfolders as $sharedfolder) {
                if (array_key_exists($sharedfolder->id, $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_id => $sharedfolder_name) {
                echo '<tr>';
                echo '<td><a href="sharedfolders.php?action=manage&amp;id=' . $sharedfolder_id . '">' . $sharedfolder_name . '</a></td>';
                echo '<td>' . $mods_by_share[$sharedfolder_id] . '</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->id . '" />';
                    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->id . '" />';
                echo '<select name="sharedfolder_id">';
                foreach ($available_sharedfolders as $sharedfolder) {
                    echo '<option value="' . $sharedfolder->id . '" >' . $sharedfolder->name . '</option>';
                }
                echo '</select>';
                echo '</td><td>';
                echo '<select name="mode">';
                echo '<option value="rw" >' . _('Read-write') . '</option>';
                echo '<option value="ro" >' . _('Read only') . '</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('general_' . $container) . '</legend>';
            echo '<form action="actions.php" method="post">';
            $key_name = 'general';
            echo '<input type="hidden" name="container" value="' . $container . '" />';
            // from admin/functions.inc.php
            $color = 0;
            if (count($prefs_of_a_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 => $config_element) {
                    echo '<tr class="content' . ($color % 2 + 1) . '">';
                    echo '<td style="width: 250px;">';
                    echo '<span onmouseover="showInfoBulle(\'' . str_replace("'", "&rsquo;", $config_element->description_detailed) . '\'); return false;" onmouseout="hideInfoBulle(); return false;">' . $config_element->label . '</span>';
                    echo '<td>';
                    $default_element = $session_prefs[$container][$config_element->id];
                    $default_element->setFormSeparator('NaN');
                    // it must be different of ___
                    $default_element->setPath(array('key_name' => $key_name, 'container' => $container, 'element_id' => $config_element->id));
                    echo $default_element->toHTML(true);
                    echo '</td>';
                    echo '</td>';
                    echo '<td style="padding: 3px;">';
                    print_element($key_name, $container, $element_key, $config_element);
                    echo '</td>';
                    echo '<td>';
                    echo '<input type="button" value="' . _('Remove this overridden setting') . '" onclick="usergroup_settings_remove(\'' . $group->id . '\',\'' . $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->id . '" />';
                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->id . '" />';
                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;
}
Example #12
0
function show_manage($login)
{
    $u = $_SESSION['service']->user_info($login);
    if (!is_object($u)) {
        die_error('Unable to import user "' . $login . '"', __FILE__, __LINE__);
    }
    $userdb_rw = userdb_is_writable();
    $usergroupdb_rw = usergroupdb_is_writable();
    $keys = array();
    foreach ($u->getAttributesList() as $attr) {
        if (!in_array($attr, array('login', 'displayname'))) {
            $keys[] = $attr;
        }
    }
    // Users Group
    $groups_mine = $u->getAttribute('groups');
    $groups_partial_list = $u->getAttribute('groups_partial_list');
    $usersgroupsList = new UsersGroupsList($_REQUEST);
    if ($groups_partial_list) {
        if ($usersgroupsList->is_empty_filter()) {
            $usersgroupsList->set_external_result($groups_mine, true);
        } else {
            $groups_mine2 = $usersgroupsList->search($login);
            if (is_null($groups_mine)) {
                die_error(_('Error while requesting User Group data'), __FILE__, __LINE__);
            }
            $groups_mine = array();
            foreach ($groups_mine2 as $group) {
                $groups_mine[$group->id] = $group->name;
            }
        }
    }
    uasort($groups_mine, 'usergroup_cmp');
    $groups_available = array();
    $default_group_id = null;
    if ($usergroupdb_rw) {
        // do not request other groups if we do not display the 'add to' panel ...
        $groups_all = $usersgroupsList->search();
        usort($groups_all, "usergroup_cmp");
        foreach ($groups_all as $group) {
            if (!array_key_exists($group->id, $groups_mine)) {
                $groups_available[] = $group;
            }
            if ($group->isDefault()) {
                $default_group_id = $group->id;
            }
        }
    }
    uasort($groups_available, 'usergroup_cmp');
    // need to be after all search call!
    $searchDiv = $usersgroupsList->getForm();
    $can_manage_users = isAuthorized('manageUsers');
    $can_manage_usersgroups = isAuthorized('manageUsersGroups');
    $can_manage_profiles = isAuthorized('manageSharedFolders');
    $prefs_of_a_user = array();
    $unuse_settings = array();
    $session_prefs = array();
    if ($u->hasAttribute('settings_default')) {
        $prefs = new Preferences_admin(null, false);
        $categs = $u->getAttribute('settings_default');
        $categs2 = array();
        if ($u->hasAttribute('settings')) {
            $categs2 = $u->getAttribute('settings');
        }
        foreach ($categs as $categ => $settings) {
            $session_prefs[$categ] = array();
            $prefs_of_a_user[$categ] = array();
            $unuse_settings[$categ] = array();
            foreach ($settings as $setting_id => $setting_attributes) {
                $p = $prefs->load_element($setting_attributes, 'general_' . $categ);
                $session_prefs[$categ][$setting_id] = $p;
                if (array_key_exists($categ, $categs2) && array_key_exists($setting_id, $categs2[$categ])) {
                    $p2 = clone $p;
                    $p2->content = $categs2[$categ][$setting_id];
                    $prefs_of_a_user[$categ][$setting_id] = $p2;
                } else {
                    $unuse_settings[$categ][$setting_id] = $p;
                }
            }
        }
    }
    $applications = array();
    if ($u->hasAttribute('applications')) {
        $applications = $u->getAttribute('applications');
        uasort($applications, 'application_cmp');
    }
    page_header();
    echo '<div id="users_div">';
    echo '<h1>' . $u->getAttribute('displayname') . '</h1>';
    echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="5">';
    echo '<tr class="title">';
    echo '<th>' . _('Login') . '</th>';
    echo '<th>' . _('Locale') . '</th>';
    echo '</tr>';
    echo '<tr class="content1">';
    echo '<td>' . $u->getAttribute('login') . '</td>';
    echo '<td>' . $u->getAttribute('locale') . '</td>';
    echo '</tr>';
    echo '</table>';
    if ($userdb_rw and $can_manage_users) {
        echo '<div>';
        echo '<h2>' . _('Settings') . '</h2>';
        echo '<div>';
        echo '<form action="actions.php" onsubmit="return confirm(\'' . _('Are you sure you want to delete this user?') . '\');">';
        echo '<input type="submit" value="' . _('Delete this user') . '"/>';
        echo '<input type="hidden" name="name" value="User" />';
        echo '<input type="hidden" name="action" value="del" />';
        echo '<input type="hidden" name="checked_users[]" value="' . htmlspecialchars($login) . '" />';
        echo '</form>';
        echo '</div>';
        echo '<br/><br/>';
        echo '<div>';
        echo '<form action="actions.php" method="post">';
        echo '<input type="hidden" name="name" value="User" />';
        echo '<input type="hidden" name="action" value="modify" />';
        echo '<input type="hidden" name="id" value="' . htmlspecialchars($login) . '" />';
        echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="5">';
        $count = 0;
        $content = 'content' . ($count++ % 2 == 0 ? 1 : 2);
        echo '<tr class="' . $content . '">';
        echo '<th>' . _('Display name') . '</th>';
        echo '<td><input type="text" name="displayname" value="' . htmlspecialchars($u->getAttribute('displayname')) . '" /></td>';
        echo '</tr>';
        if ($u->hasAttribute('password')) {
            $content = 'content' . ($count++ % 2 == 0 ? 1 : 2);
            echo '<tr class="' . $content . '">';
            echo '<th>' . _('New password') . '</th>';
            echo '<td><input type="password" name="password" value="" /></td>';
            echo '</tr>';
        }
        $content = 'content' . ($count % 2 == 0 ? 1 : 2);
        echo '<tr class="' . $content . '">';
        echo '<td colspan="2">';
        echo '<input type="submit" name="modify" value="' . _('Save changes') . '" />';
        echo '</td>';
        echo '</tr>';
        echo '</table>';
        echo '</form>';
        echo '</div>';
    }
    // User groups part
    if (count($groups_mine) > 0 or !$usersgroupsList->is_empty_filter() or $usergroupdb_rw and count($groups_all) > 0) {
        echo '<div>';
        echo '<h2>' . _('User Groups with this user') . '</h2>';
        echo $searchDiv;
        echo '<table border="0" cellspacing="1" cellpadding="3">';
        foreach ($groups_mine as $group_id => $group_name) {
            echo '<tr><td>';
            if ($can_manage_usersgroups) {
                echo '<a href="usersgroup.php?action=manage&id=' . $group_id . '">' . $group_name . '</a>';
            } else {
                echo $group_name;
            }
            echo '</td>';
            if ($usergroupdb_rw and $can_manage_usersgroups and $group_id != $default_group_id) {
                echo '<td><form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this user from this group?') . '\');">';
                echo '<input type="hidden" name="name" value="User_UserGroup" />';
                echo '<input type="hidden" name="action" value="del" />';
                echo '<input type="hidden" name="group" value="' . $group_id . '" />';
                echo '<input type="hidden" name="element" value="' . htmlspecialchars($login) . '" />';
                echo '<input type="submit" value="' . _('Delete from this group') . '" />';
                echo '</form></td>';
            }
            echo '</tr>';
        }
        if (count($groups_available) > 0 && $usergroupdb_rw and $can_manage_usersgroups) {
            echo '<tr><form action="actions.php" method="post"><td>';
            echo '<input type="hidden" name="action" value="add" />';
            echo '<input type="hidden" name="name" value="User_UserGroup" />';
            echo '<input type="hidden" name="element" value="' . htmlspecialchars($login) . '" />';
            echo '<select name="group">';
            foreach ($groups_available as $group) {
                echo '<option value="' . $group->id . '" >' . $group->name . '</option>';
            }
            echo '</select>';
            echo '</td><td><input type="submit" value="' . _('Add to this group') . '" /></td>';
            echo '</form></tr>';
        }
        echo '</table>';
        echo "</div>\n";
    }
    $apps_s = array();
    if (count($applications) > 0) {
        echo '<br />';
        echo '<h2>' . _('Published Applications') . '</h2>';
        echo '<table border="0" cellspacing="1" cellpadding="3">';
        foreach ($applications as $application_id => $application_name) {
            echo '<tr>';
            echo '<td><img class="icon32" src="media/image/cache.php?id=' . $application_id . '" alt="" title="" /></td>';
            echo '<td><a href="applications.php?action=manage&id=' . $application_id . '">' . $application_name . '</a></td>';
            echo '</tr>';
        }
        echo '</table>';
    }
    echo '<h2>';
    echo _('Session Settings configuration');
    echo '</h2>';
    if ($prefs_of_a_user != array()) {
        foreach ($prefs_of_a_user as $container => $prefs_of_a_user_value) {
            echo '<fieldset class="prefssessionusergroup">';
            echo '<legend>' . $prefs->getPrettyName('general_' . $container) . '</legend>';
            echo '<form action="actions.php" method="post">';
            $key_name = 'general';
            echo '<input type="hidden" name="container" value="' . $container . '" />';
            // from admin/functions.inc.php
            $color = 0;
            if (count($prefs_of_a_user_value) != 0) {
                echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="3" style="margin-bottom: 10px;">';
                // TODO
                echo '<tr  class="title">';
                echo '<th>' . _('Name') . '</th>';
                echo '<th>' . _('Default value') . '</th>';
                echo '<th>' . _('Value') . '</th>';
                echo '<th>' . _('Action') . '</th>';
                echo '<tr>';
                foreach ($prefs_of_a_user_value as $element_key => $config_element) {
                    echo '<tr class="content' . ($color % 2 + 1) . '">';
                    echo '<td style="width: 250px;">';
                    echo '<span onmouseover="showInfoBulle(\'' . str_replace("'", "&rsquo;", $config_element->description_detailed) . '\'); return false;" onmouseout="hideInfoBulle(); return false;">' . $config_element->label . '</span>';
                    echo '<td>';
                    $default_element = $session_prefs[$container][$config_element->id];
                    $default_element->setFormSeparator('NaN');
                    // it must be different of ___
                    $default_element->setPath(array('key_name' => $key_name, 'container' => $container, 'element_id' => $config_element->id));
                    echo $default_element->toHTML(true);
                    echo '</td>';
                    echo '</td>';
                    echo '<td style="padding: 3px;">';
                    print_element($key_name, $container, $element_key, $config_element);
                    echo '</td>';
                    echo '<td>';
                    echo '<input type="button" value="' . _('Remove this overridden setting') . '" onclick="user_settings_remove(\'' . $u->getAttribute('login') . '\',\'' . $container . '\',\'' . $config_element->id . '\'); return false;"/>';
                    echo '</td>';
                    echo '</tr>';
                    $color++;
                }
                // end from
                echo '<tr class="content' . ($color % 2 + 1) . '">';
                echo '<td colspan="3"></td>';
                echo '<td>';
                echo '<input type="hidden" name="name" value="User_settings" />';
                echo '<input type="hidden" name="container" value="' . $container . '" />';
                echo '<input type="hidden" name="unique_id" value="' . $u->getAttribute('login') . '" />';
                echo '<input type="hidden" name="action" value="modify" />';
                echo '<input type="submit" value="' . _('Save settings') . '" />';
                echo '</td>';
                echo '</tr>';
                echo '</table>';
                echo '</form>';
            }
            if ($unuse_settings[$container] != array()) {
                echo '<form action="actions.php" method="post">';
                echo '<input type="hidden" name="name" value="User_settings" />';
                echo '<input type="hidden" name="container" value="' . $container . '" />';
                echo '<input type="hidden" name="unique_id" value="' . $u->getAttribute('login') . '" />';
                echo '<input type="hidden" name="action" value="add" />';
                echo '<select name="element_id">';
                foreach ($unuse_settings[$container] as $setting_name => $setting_content) {
                    echo '<option value="' . $setting_name . '" >' . $setting_content->label . '</option>';
                }
                echo '</select>';
                echo ' ';
                echo '<input type="submit" value="' . _('Add this setting') . '" />';
                echo '</form>';
            }
            echo '</fieldset>';
        }
    }
    echo '</div>';
    // Session settings configuration
    echo "\n\n\n";
    if ($u->hasAttribute('sessions') && count($u->getAttribute('sessions')) > 0) {
        echo '<div>';
        echo '<h2>' . _('Active sessions') . '</h2>';
        echo '<table border="0" cellspacing="1" cellpadding="3">';
        foreach ($u->getAttribute('sessions') as $session_id => $session_start_time) {
            echo '<tr>';
            echo '<td>';
            if (!$session_start_time) {
                echo _('Not started yet');
            } else {
                echo @date('d/m/Y H:i:s', $session_start_time);
            }
            echo '</td>';
            echo '<td><a href="sessions.php?info=' . $session_id . '">' . $session_id . '</td>';
            echo '<td></td>';
            echo '<td>';
            echo '<form action="sessions.php">';
            echo '<input type="hidden" name="info" value="' . $session_id . '" />';
            echo '<input type="submit" value="' . _('Information about this session') . '" />';
            echo '</form>';
            echo '</td>';
            echo '</tr>';
        }
        echo '</table>';
        echo '</div>';
    }
    $use_profiles = false;
    $settings = $u->getAttribute('settings');
    $settings = $settings['session_settings_defaults'];
    if (array_key_exists('enable_profiles', $settings)) {
        if ($settings['enable_profiles']['value'] == 1) {
            $use_profiles = true;
        }
    } else {
        $settings = $u->getAttribute('settings_default');
        $settings = $settings['session_settings_defaults'];
        if (array_key_exists('enable_profiles', $settings)) {
            if ($settings['enable_profiles']['value'] == 1) {
                $use_profiles = true;
            }
        }
    }
    if ($use_profiles) {
        echo '<div>';
        echo '<h2>' . _('Profile') . '</h2>';
        if (!$u->hasAttribute('profiles')) {
            echo '<p>';
            echo _('This user doesn\'t have a user profile');
            echo '</p>';
            if ($can_manage_profiles) {
                echo '<div>';
                echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to create a profile for this user?') . '\');">';
                echo '<input type="hidden" name="name" value="Profile" />';
                echo '<input type="hidden" name="action" value="add" />';
                echo '<input type="hidden" name="users[]" value="' . $u->getAttribute('login') . '" />';
                echo '<input type="submit" value="' . _('Create a profile') . '" />';
                echo '</form>';
                echo '</div>';
            }
        } else {
            foreach ($u->getAttribute('profiles') as $profile_id => $profile_info) {
                echo '<p>';
                echo str_replace('%SERVER%', '<a href="servers.php?action=manage&id=' . $profile_info['server_id'] . '"> ' . $profile_info['server_name'] . '</a>', _('User has profile stored on server %SERVER%.'));
                echo '</p>';
                if ($can_manage_profiles) {
                    echo '<div>';
                    echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this profile?') . '\');">';
                    echo '<input type="hidden" name="name" value="Profile" />';
                    echo '<input type="hidden" name="action" value="del" />';
                    echo '<input type="hidden" name="ids[]" value="' . $profile_id . '" />';
                    echo '<input type="submit" value="' . _('Delete this profile') . '" />';
                    echo '</form>';
                    echo '</div>';
                }
            }
        }
        echo '</div>';
    }
    echo '</div>';
    page_footer();
    die;
}
Example #13
0
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();
        }
    }
}
Example #14
0
 public function cleanup_preferences()
 {
     $this->check_authorized('manageConfiguration');
     $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();
         }
     }
     $this->log_action('cleanup_preferences');
     return true;
 }
Example #15
0
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * 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-minimal.inc.php';
if (!defined('STDIN')) {
    echo "This script cannot be used in CGI mode.\n";
    exit(1);
}
// Update database
try {
    $prefs = new Preferences_admin();
} catch (Exception $e) {
    echo "Internal error while loading settings, unable to continue.\n";
    exit(1);
}
if ($prefs->isValid() !== true) {
    // First install
    exit(0);
}
if (!$prefs->backup()) {
    echo "Internal error while update the database. Your system may no longer works. Please contact Ulteo for support\n";
    exit(2);
}
exit(0);