示例#1
0
 public function getList()
 {
     $liaisons = Abstract_Liaison::load('UserProfile', NULL, NULL);
     if (is_array($liaisons) == false) {
         Logger::error('main', 'UserDB::anyuser::getList() problem with liaison');
         return false;
     }
     $results = array();
     foreach ($liaisons as $liaison) {
         $results[] = $this->import($liaison->element);
     }
     return $results;
 }
示例#2
0
 public function getUsers()
 {
     $liaisons = Abstract_Liaison::load('UserProfile', NULL, $this->id);
     if (is_array($liaisons) == false) {
         Logger::error('main', 'NetworkFolder::getUsers()');
         return false;
     }
     $userDB = UserDB::getInstance();
     $users = array();
     foreach ($liaisons as $liaison) {
         array_push($users, $liaison->element);
     }
     return $userDB->imports($users);
 }
示例#3
0
 public function userGroups()
 {
     Logger::debug('main', 'APPSGROUPS::userGroups (for id=' . $this->id . ')');
     $UserGroupDB = UserGroupDB::getInstance();
     $groups = Abstract_Liaison::load('UsersGroupApplicationsGroup', NULL, $this->id);
     if (is_array($groups)) {
         $result = array();
         foreach ($groups as $UGAG_liaison) {
             array_push($result, $UGAG_liaison->element);
         }
         return $UserGroupDB->imports($result);
     } else {
         Logger::error('main', 'APPSGROUPS::userGroups (for id=' . $this->id . ') load liaison liaison failed');
         return NULL;
     }
 }
示例#4
0
 public function importFromUser($login_)
 {
     $liaisons = Abstract_Liaison::load('UserProfile', $login_, NULL);
     if (is_array($liaisons) == false) {
         Logger::error('main', "ProfileDB::internal::importFromUser({$login_}) problem with liaison");
         return false;
     }
     $profiles = array();
     foreach ($liaisons as $liaison) {
         $profile = self::import($liaison->group);
         if (!is_object($profile)) {
             continue;
         }
         $profiles[$profile->id] = $profile;
     }
     return $profiles;
 }
 public function updateCache()
 {
     // update the liaison
     Logger::debug('main', 'UsersGroup_dynamic_cached::updateCache for ID=' . $this->getUniqueID());
     $logins = parent::usersLogin();
     $liaisons = Abstract_Liaison::load('UsersGroupCached', NULL, $this->getUniqueID());
     foreach ($liaisons as $a_liaison) {
         if (!in_array($a_liaison->element, $logins)) {
             Abstract_Liaison::delete('UsersGroupCached', $a_liaison->element, $a_liaison->group);
         }
     }
     foreach ($logins as $a_login) {
         if (!isset($liaisons[$a_login])) {
             Abstract_Liaison::save('UsersGroupCached', $a_login, $this->getUniqueID());
         }
     }
 }
示例#6
0
 public function getUsers()
 {
     $liaisons = Abstract_Liaison::load('UserProfile', NULL, $this->id);
     if (is_array($liaisons) == false) {
         Logger::error('main', 'NetworkFolder::getUsers()');
         return false;
     }
     $userDB = UserDB::getInstance();
     $users = array();
     foreach ($liaisons as $liaison) {
         $user = $userDB->import($liaison->element);
         if (!is_object($user)) {
             continue;
         }
         $users[$user->getAttribute('login')] = $user;
     }
     return $users;
 }
示例#7
0
 public function getUserGroups()
 {
     $liaisons = Abstract_Liaison::load('UserGroupSharedFolder', NULL, $this->id);
     if (is_array($liaisons) == false) {
         Logger::error('main', 'NetworkFolder::getUserGroups()');
         return false;
     }
     $usergroupDB = UserGroupDB::getInstance();
     $usergroups = array();
     foreach ($liaisons as $liaison) {
         $usergroup = $usergroupDB->import($liaison->element);
         if (!is_object($usergroup)) {
             continue;
         }
         $usergroups[$usergroup->getUniqueID()] = $usergroup;
     }
     return $usergroups;
 }
示例#8
0
 public function usersGroups()
 {
     Logger::debug('main', 'Script::usersGroups');
     $userGroupDB = UserGroupDB::getInstance();
     $result = array();
     // add the default user group is enable
     $prefs = Preferences::getInstance();
     if (!$prefs) {
         Logger::critical('main', 'Script::usersGroups get prefs failed');
         die_error('get Preferences failed', __FILE__, __LINE__);
     }
     $liaison = Abstract_Liaison::load('Scripts', $this->getAttribute('name'), NULL);
     if (is_null($liaison)) {
         Logger::error('main', 'Script::usersGroups load(' . $this->getAttribute('name') . ') is null');
         return $result;
     }
     foreach ($liaison as $row) {
         $g = $userGroupDB->import($row->group);
         if (is_object($g)) {
             $result[] = $g;
         }
     }
     return $result;
 }
示例#9
0
 public static function getAllMimeTypes()
 {
     $mimes = array();
     $liaisons = Abstract_Liaison::load('ApplicationMimeType', NULL, NULL);
     if (is_array($liaisons)) {
         foreach ($liaisons as $elem) {
             if (!in_array($elem->group, $mimes)) {
                 $mimes[] = $elem->group;
             }
         }
     }
     return $mimes;
 }
示例#10
0
            redirect();
        }
        $l = Abstract_Liaison::load('UsersGroupApplicationsGroup', $_REQUEST['group_u'], $_REQUEST['group_a']);
        if (is_null($l)) {
            $ret = Abstract_Liaison::save('UsersGroupApplicationsGroup', $_REQUEST['group_u'], $_REQUEST['group_a']);
            if ($ret === true) {
                popup_info(_('Publication successfully added'));
            } else {
                popup_error(_('Unable to save the publication'));
            }
        } else {
            popup_error(_('This publication already exists'));
        }
    }
    if ($_REQUEST['action'] == 'del') {
        $l = Abstract_Liaison::load('UsersGroupApplicationsGroup', $_REQUEST['group_u'], $_REQUEST['group_a']);
        if (!is_null($l)) {
            $ret = Abstract_Liaison::delete('UsersGroupApplicationsGroup', $_REQUEST['group_u'], $_REQUEST['group_a']);
            if ($ret === true) {
                popup_info(_('Publication successfully deleted'));
            } else {
                popup_error(_('Unable to delete the publication'));
            }
        } else {
            popup_error(_('This publication does not exist'));
        }
    }
}
if ($_REQUEST['name'] == 'UserGroup') {
    if (!checkAuthorization('manageUsersGroups')) {
        redirect();
示例#11
0
 public function remove($usergroup_)
 {
     Logger::debug('main', 'UserGroupDBDynamic_cached::remove');
     // first we delete liaisons
     $sql2 = SQL::getInstance();
     $liaisons = Abstract_Liaison::load('UsersGroupApplicationsGroup', $usergroup_->id, NULL);
     foreach ($liaisons as $liaison) {
         Abstract_Liaison::delete('UsersGroupApplicationsGroup', $liaison->element, $liaison->group);
     }
     foreach ($liaisons as $liaison) {
         Abstract_Liaison::delete('UsersGroup', NULL, $usergroup_->getUniqueID());
     }
     // second we delete the group
     $res = $sql2->DoQuery('DELETE FROM @1 WHERE @2 = %3', $this->table, 'id', $usergroup_->id);
     if ($res === false) {
         Logger::error('main', 'UserGroupDBDynamic_cached::remove Failed to remove group from SQL DB');
         return false;
     }
     // third we delete the rules
     $rules = UserGroup_Rules::getByUserGroupId($usergroup_->getUniqueID());
     foreach ($rules as $a_rule) {
         if (Abstract_UserGroup_Rule::delete($a_rule->id) === false) {
             Logger::error('main', 'UserGroupDBDynamic_cached::remove Failed to remove rule from SQL DB');
             return false;
         }
     }
     return true;
 }
示例#12
0
 public function get_all_published_servers()
 {
     Logger::debug('main', "USER::get_all_published_servers");
     $servers = array();
     $liaisons = Abstract_Liaison::load('UsersGroupServersGroup', NULL, NULL);
     foreach ($liaisons as $liaison) {
         $liaisons2 = Abstract_Liaison::load('ServersGroup', NULL, $liaison->group);
         foreach ($liaisons2 as $liaison2) {
             $servers[] = $liaison2->element;
         }
     }
     return $servers;
 }
示例#13
0
文件: sql.php 项目: skdong/nfs-ovd
 public function remove($user_)
 {
     Logger::debug('main', 'UserDB::sql::remove');
     if (is_object($user_) && $user_->hasAttribute('login')) {
         $SQL = SQL::getInstance();
         // first we delete all liaisons
         $liaisons = Abstract_Liaison::load('UsersGroup', $user_->getAttribute('login'), NULL);
         foreach ($liaisons as $liaison) {
             Abstract_Liaison::delete('UsersGroup', $liaison->element, $liaison->group);
         }
         // second we delete the user
         return $SQL->DoQuery('DELETE FROM @1 WHERE @2 = %3', $this->table, 'login', $user_->getAttribute('login'));
     } else {
         Logger::debug('main', 'UserDB::sql::remove failed (user not ok)');
         return false;
     }
 }
示例#14
0
            $module_failed = true;
            echo '<span class="msg_error">ERROR</span>';
        }
        echo '</td>';
        echo '</tr>';
    }
    echo '</table>';
    page_footer();
    die;
} else {
    echo '<span class="msg_ok">OK</span><br />';
    echo '<br />';
}
echo '<h2>' . _('Liaisons') . '</h2>';
foreach ($liaisons_types as $liaisons_type) {
    $liaisons = Abstract_Liaison::load($liaisons_type, NULL, NULL);
    if (is_null($liaisons)) {
        continue;
    }
    $all_ok = true;
    echo '<br /><h3>' . $liaisons_type . '</h3>';
    echo '<table border="0" cellspacing="1" cellpadding="3">';
    foreach ($liaisons as $liaison) {
        $ret = checkup_liaison($liaisons_type, $liaison->element, $liaison->group);
        if ($ret === true) {
            continue;
        }
        if ($all_ok === true) {
            $everything_ok = false;
            $all_ok = false;
            echo '<tr><td colspan="5"><span class="msg_error">ERROR</span></td></tr>';
示例#15
0
function show_icon($id, $applicationDB)
{
    $applicationsGroupDB = ApplicationsGroupDB::getInstance();
    $app = $applicationDB->import($id);
    if (!is_object($app)) {
        return false;
    }
    //     die_error('Unable to import application "'.$id.'"',__FILE__,__LINE__);
    if ($app->getAttribute('static')) {
        redirect('applications_static.php?action=manage&id=' . $app->getAttribute('id'));
    }
    $is_rw = $applicationDB->isWriteable();
    $liaisons = Abstract_Liaison::load('ApplicationServer', $app->getAttribute('id'), NULL);
    $servers = array();
    foreach ($liaisons as $liaison) {
        $server = Abstract_Server::load($liaison->group);
        if (!$server->isOnline()) {
            continue;
        }
        $servers[] = $server;
    }
    page_header();
    echo '<div>';
    echo '<h1><img src="media/image/cache.php?id=' . $app->getAttribute('id') . '" alt="" title="" /> ' . $app->getAttribute('name') . '</h1>';
    echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="3">';
    echo '<tr class="title">';
    echo '<th>' . _('Package') . '</th>';
    echo '<th>' . _('Type') . '</th>';
    //   echo '<th>'._('Status').'</th>';
    echo '<th>' . _('Description') . '</th>';
    echo '<th>' . _('Executable') . '</th>';
    echo '</tr>';
    echo '<tr class="content1">';
    echo '<td>' . $app->getAttribute('package') . '</td>';
    echo '<td style="text-align: center;"><img src="media/image/server-' . $app->getAttribute('type') . '.png" alt="' . $app->getAttribute('type') . '" title="' . $app->getAttribute('type') . '" /><br />' . $app->getAttribute('type') . '</td>';
    //   echo '<td>'.$status.'</td>';
    echo '<td>' . $app->getAttribute('description') . '</td>';
    echo '<td>' . $app->getAttribute('executable_path') . '</td>';
    echo '</tr>';
    echo '</table>';
    echo '<br />';
    echo '<h2>' . _('Select an icon from an Application Server') . '</h2>';
    echo '<table border="0" cellspacing="1" cellpadding="5">';
    foreach ($servers as $server) {
        $ret = query_url($server->getBaseURL() . '/aps/application/icon/' . $app->getAttribute('id'));
        if (!$ret) {
            continue;
        }
        $imgfile = tempnam(NULL, 'ico');
        @file_put_contents($imgfile, $ret);
        try {
            if (class_exists('Imagick')) {
                $imagick = new Imagick();
                $imagick->readImage($imgfile);
            } else {
                if (file_exists($imgfile)) {
                    @unlink($imgfile);
                }
                continue;
            }
        } catch (Exception $e) {
            if (file_exists($imgfile)) {
                @unlink($imgfile);
            }
            continue;
        }
        if (!file_exists($imgfile)) {
            continue;
        }
        echo '<tr>';
        echo '<td style="width: 32px;"><img src="media/image/temp_icon.php?tempnam=' . basename($imgfile) . '" /></td><td><a href="servers.php?action=manage&amp;fqdn=' . $server->getAttribute('fqdn') . '">' . $server->getAttribute('fqdn') . '</a></td><td><form action="actions.php" method="post"><input type="hidden" name="name" value="Application" /><input type="hidden" name="action" value="icon" /><input type="hidden" name="id" value="' . $app->getAttribute('id') . '" /><input type="hidden" name="server" value="' . $server->getAttribute('fqdn') . '" /><input type="submit" value="' . _('Select this icon') . '" /></form></td>';
        echo '</tr>';
    }
    echo '</table>';
    echo '<br />';
    echo '<h2>' . _('Upload an icon') . '</h2>';
    echo '<table border="0" cellspacing="1" cellpadding="5">';
    echo '<tr>';
    echo '<td>';
    echo '<form action="actions.php" method="post" enctype="multipart/form-data" >';
    // form A
    echo '<input type="hidden" name="name" value="Application" />';
    echo '<input type="hidden" name="action" value="icon" />';
    echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />';
    echo '<input type="file" name="file_icon" /> ';
    echo '<input type="submit" value="' . _('Upload this icon') . '" />';
    echo '</form>';
    echo '</td>';
    echo '</tr>';
    echo '</table>';
    echo '</div>';
    page_footer();
    die;
}
示例#16
0
 public function cleanup_liaisons()
 {
     $this->check_authorized('manageConfiguration');
     foreach (self::get_liaisons_types() as $liaisons_type) {
         $liaisons = Abstract_Liaison::load($liaisons_type, NULL, NULL);
         if (is_null($liaisons)) {
             continue;
         }
         foreach ($liaisons as $k => $liaison) {
             if (self::checkup_liaison($liaisons_type, $liaison->element, $liaison->group) === true) {
                 continue;
             }
             Abstract_Liaison::delete($liaisons_type, $liaison->element, $liaison->group);
         }
     }
     $this->log_action('cleanup_liaisons');
     return true;
 }
示例#17
0
 public function get_groups_including_user_from_list($groups_id_, $user_)
 {
     $liasons = Abstract_Liaison::load('UsersGroup', $user_->getAttribute('login'), NULL);
     $groups_id2 = array();
     foreach ($liasons as $useless => $liason) {
         if (!str_startswith($liason->group, 'static_')) {
             continue;
         }
         $group_id = substr($liason->group, strlen('static_'));
         if (!in_array($group_id, $groups_id_)) {
             continue;
         }
         array_push($groups_id2, $group_id);
     }
     return $this->imports($groups_id2);
 }
示例#18
0
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&amp;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("'", "&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 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;
}
示例#19
0
文件: wizard.php 项目: skdong/nfs-ovd
function do_validate()
{
    if ($_SESSION['wizard']['use_users'] == 'users') {
        if (!checkAuthorization('manageUsersGroups')) {
            redirect();
        }
        $userGroupDB = UserGroupDB::getInstance();
        if (!$userGroupDB->isWriteable()) {
            return false;
        }
        $g = new UsersGroup(NULL, $_SESSION['wizard']['user_group_name'], $_SESSION['wizard']['user_group_description'], 1);
        $res = $userGroupDB->add($g);
        if (!$res || !is_object($g) || $g->id == NULL) {
            popup_error(_('Cannot create usergroup'));
        }
        $users = $_SESSION['wizard']['users'];
        foreach ($users as $user) {
            Abstract_Liaison::save('UsersGroup', $user, $g->getUniqueID());
        }
        $usergroups = array($g->getUniqueID());
    } else {
        $usergroups = $_SESSION['wizard']['usergroups'];
    }
    if ($_SESSION['wizard']['use_apps'] == 'apps') {
        if (!checkAuthorization('manageApplicationsGroups')) {
            redirect();
        }
        $g = new AppsGroup(NULL, $_SESSION['wizard']['application_group_name'], $_SESSION['wizard']['application_group_description'], 1);
        $applicationsGroupDB = ApplicationsGroupDB::getInstance();
        $res = $applicationsGroupDB->add($g);
        if (!$res || !is_object($g) || $g->id == NULL) {
            popup_error(_('Cannot create application group'));
        }
        $apps = $_SESSION['wizard']['apps'];
        foreach ($apps as $app) {
            Abstract_Liaison::save('AppsGroup', $app, $g->id);
        }
        $appgroups = array($g->id);
    } else {
        $appgroups = $_SESSION['wizard']['appgroups'];
    }
    foreach ($usergroups as $usergroup) {
        foreach ($appgroups as $appgroup) {
            $exists = Abstract_Liaison::load('UsersGroupApplicationsGroup', $usergroup, $appgroup);
            if (is_object($exists) === false) {
                Abstract_Liaison::save('UsersGroupApplicationsGroup', $usergroup, $appgroup);
            }
        }
    }
    if (isset($_SESSION['wizard'])) {
    }
    unset($_SESSION['wizard']);
    redirect('publications.php');
    die;
}
示例#20
0
 public function applications($type = NULL, $with_static_ = true)
 {
     Logger::debug('main', "USER::applications(type={$type}, with_static={$with_static_})");
     $applicationDB = ApplicationDB::getInstance();
     $my_applications_id = array();
     $my_applications = array();
     $appgroups_id = $this->appsGroups();
     foreach ($appgroups_id as $agrp_id) {
         $els = Abstract_Liaison::load('AppsGroup', NULL, $agrp_id);
         if (is_array($els)) {
             foreach ($els as $e) {
                 array_push($my_applications_id, $e->element);
             }
         }
     }
     $my_applications_id = array_unique($my_applications_id);
     foreach ($my_applications_id as $id) {
         $app = $applicationDB->import($id);
         if (is_object($app)) {
             if ($type != NULL) {
                 if ($app->getAttribute('type') == $type) {
                     if ($app->getAttribute('static')) {
                         if ($with_static_) {
                             $my_applications[] = $app;
                         }
                     } else {
                         $my_applications[] = $app;
                     }
                 }
             } else {
                 if ($app->getAttribute('static')) {
                     if ($with_static_) {
                         $my_applications[] = $app;
                     }
                 } else {
                     $my_applications[] = $app;
                 }
             }
         }
     }
     return $my_applications;
 }
示例#21
0
 public function isOrphan()
 {
     Logger::debug('main', 'Application::isOrphan');
     $liaisons = Abstract_Liaison::load('ApplicationServer', $this->getAttribute('id'), NULL);
     if (is_array($liaisons) && count($liaisons) == 0) {
         return true;
     }
     return false;
 }
示例#22
0
 public function getGroupsContains($contains_, $attributes_ = array('name', 'description'), $limit_ = 0, $user_ = null)
 {
     if (!is_null($user_)) {
         $liasons = Abstract_Liaison::load('UsersGroup', $user_->getAttribute('id'), NULL);
         $groups2 = array();
         if (is_array($liasons)) {
             foreach ($liasons as $group_id => $liason) {
                 array_push($groups2, $group_id);
             }
         }
     }
     $groups = array();
     $count = 0;
     $sizelimit_exceeded = false;
     $list = $this->getList();
     foreach ($list as $a_group) {
         if (!is_null($user_) && !in_array($a_group->getUniqueID(), $groups2)) {
             continue;
         }
         foreach ($attributes_ as $an_attribute) {
             if ($contains_ == '' or isset($a_group->{$an_attribute}) and is_string(strstr($a_group->{$an_attribute}, $contains_))) {
                 $groups[] = $a_group;
                 $count++;
                 if ($limit_ > 0 && $count >= $limit_) {
                     $sizelimit_exceeded = next($list) !== false;
                     // is it the last element ?
                     return array($users, $sizelimit_exceeded);
                 }
                 break;
             }
         }
     }
     return array($groups, $sizelimit_exceeded);
 }
示例#23
0
function show_manage($id, $applicationDB)
{
    global $types;
    $applicationsGroupDB = ApplicationsGroupDB::getInstance();
    $app = $applicationDB->import($id);
    if (!is_object($app)) {
        return false;
    }
    $is_rw = $applicationDB->isWriteable();
    $can_manage_applications = isAuthorized('manageApplications');
    // App groups
    $appgroups = $applicationsGroupDB->getList();
    $groups_id = array();
    $liaisons = Abstract_Liaison::load('AppsGroup', $app->getAttribute('id'), NULL);
    foreach ($liaisons as $liaison) {
        $groups_id[] = $liaison->group;
    }
    $groups = array();
    $groups_available = array();
    foreach ($appgroups as $group) {
        if (in_array($group->id, $groups_id)) {
            $groups[] = $group;
        } else {
            $groups_available[] = $group;
        }
    }
    $servers_all = Abstract_Server::load_available_by_role(Server::SERVER_ROLE_APS, true);
    $liaisons = Abstract_Liaison::load('ApplicationServer', $app->getAttribute('id'), NULL);
    $servers_id = array();
    foreach ($liaisons as $liaison) {
        $servers_id[] = $liaison->group;
    }
    $servers = array();
    $servers_available = array();
    foreach ($servers_all as $server) {
        if (in_array($server->fqdn, $servers_id)) {
            $servers[] = $server;
        } elseif (!$server->isOnline()) {
            continue;
        } elseif ($server->type != $app->getAttribute('type')) {
            continue;
        } else {
            $servers_available[] = $server;
        }
    }
    $mimes = $applicationDB->getAllMimeTypes();
    $mimeliste1 = $app->getMimeTypes();
    $mimeliste2 = array();
    foreach ($mimes as $mime) {
        if (!in_array($mime, $mimeliste1)) {
            $mimeliste2[] = $mime;
        }
    }
    $can_manage_server = isAuthorized('manageServers');
    page_header();
    echo '<div>';
    echo '<h1><img src="media/image/cache.php?id=' . $app->getAttribute('id') . '" alt="" title="" /> ' . $app->getAttribute('name') . '</h1>';
    echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="3">';
    echo '<tr class="title">';
    // 	echo '<th>'._('Package').'</th>';
    echo '<th>' . _('Type') . '</th>';
    echo '<th>' . _('Description') . '</th>';
    echo '<th>' . _('Command') . '</th>';
    if ($is_rw and $can_manage_applications) {
        echo '<th></th>';
    }
    echo '</tr>';
    echo '<tr class="content1">';
    // 		echo '<td>'.$app->getAttribute('package').'</td>';
    echo '<td style="text-align: center;"><img src="media/image/server-' . $app->getAttribute('type') . '.png" alt="' . $app->getAttribute('type') . '" title="' . $app->getAttribute('type') . '" /><br />' . $app->getAttribute('type') . '</td>';
    echo '<td>' . $app->getAttribute('description') . '</td>';
    echo '<td>';
    echo $app->getAttribute('executable_path');
    echo '</td>';
    if ($is_rw and $can_manage_applications) {
        echo '<td>';
        echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this application?') . '\');">';
        echo '<input type="hidden" name="name" value="Application_static" />';
        echo '<input type="hidden" name="action" value="del" />';
        echo '<input type="hidden" name="checked_applications[]" value="' . $app->getAttribute('id') . '" />';
        echo '<input type="submit"  value="' . _('Delete') . '" />';
        echo '</form>';
        echo '</td>';
    }
    echo '</tr>';
    echo '</table>';
    if ($is_rw and $can_manage_applications) {
        echo '<br />';
        echo '<form action="actions.php" method="post"">';
        echo '<input type="hidden" name="name" value="Application" />';
        echo '<input type="hidden" name="action" value="clone" />';
        echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />';
        echo '<input type="submit" value="' . _('Clone to new application') . '"/>';
        echo '</form>';
        echo '<br />';
        echo '<h2>' . _('Modify') . '</h2>';
        echo '<div id="application_modify">';
        echo '<form id="delete_icon" action="actions.php" method="post" style="display: none;">';
        echo '<input type="hidden" name="name" value="Application_static" />';
        echo '<input type="hidden" name="action" value="del_icon" />';
        echo '<input type="hidden" name="checked_applications[]" value="' . $app->getAttribute('id') . '" />';
        echo '</form>';
        echo '<form action="actions.php" method="post" enctype="multipart/form-data" >';
        // form A
        echo '<input type="hidden" name="name" value="Application_static" />';
        echo '<input type="hidden" name="action" value="modify" />';
        echo '<input type="hidden" name="published" value="1" />';
        echo '<input type="hidden" name="static" value="1" />';
        echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />';
        echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="5">';
        $count = 1;
        $app->setAttribute('application_name', $app->getAttribute('name'));
        // ugly hack
        $app->unsetAttribute('name');
        $attr_list = $app->getAttributesList();
        foreach ($attr_list as $k => $v) {
            if (in_array($v, array('id', 'type', 'static', 'published', 'desktopfile', 'package', 'revision'))) {
                unset($attr_list[$k]);
            }
        }
        asort($attr_list);
        foreach ($attr_list as $attr_name) {
            $content = 'content' . ($count++ % 2 == 0 ? 1 : 2);
            echo '<tr class="' . $content . '">';
            echo '<td style="text-transform: capitalize;">';
            if ($attr_name == 'executable_path') {
                echo _('Command');
            } else {
                if ($attr_name == 'application_name') {
                    echo _('Name');
                } else {
                    echo _($attr_name);
                }
            }
            echo '</td>';
            echo '<td>';
            echo '<input type="text" name="' . $attr_name . '" value="' . htmlspecialchars($app->getAttribute($attr_name)) . '" style="with:100%;"/>';
            echo '<input type="hidden" name="attributes_send[]" value="' . $attr_name . '" />';
            echo '</td>';
            echo '</tr>';
        }
        if (get_classes_startwith('Imagick') != array()) {
            $content = 'content' . ($count++ % 2 == 0 ? 1 : 2);
            echo '<tr class="' . $content . '">';
            echo '<td>' . _('Icon') . '</td>';
            echo '<td>';
            if ($app->getIconPath() != $app->getDefaultIconPath() && file_exists($app->getIconPath())) {
                echo '<img src="media/image/cache.php?id=' . $app->getAttribute('id') . '" alt="" title="" /> ';
                echo '<input type="button" value="' . _('Delete this icon') . '" onclick="return confirm(\'' . _('Are you sure you want to delete this icon?') . '\') && $(\'delete_icon\').submit();"/>';
                echo '<br />';
            }
            echo '<input type="file"  name="file_icon" /> ';
            echo '</td>';
            echo '</tr>';
        } else {
            Logger::info('main', 'No Imagick support found');
        }
        $content = 'content' . ($count++ % 2 == 0 ? 1 : 2);
        echo '<tr class="' . $content . '">';
        echo '<td colspan="2">';
        echo '<input type="submit" value="' . _('Modify') . '" />';
        echo '</td>';
        echo '</tr>';
        echo '</table>';
        echo '</form>';
        // form A
        echo '</div>';
        // application_modify
    }
    if (count($servers) + count($servers_available) > 0) {
        echo '<div>';
        echo '<h2>' . _('Servers with this application') . '</h2>';
        echo '<table border="0" cellspacing="1" cellpadding="3">';
        foreach ($servers as $server) {
            echo '<tr><td>';
            echo '<a href="servers.php?action=manage&fqdn=' . $server->fqdn . '">' . $server->fqdn . '</a>';
            echo '</td>';
            echo '<td>';
            if ($server->isOnline() and $can_manage_server) {
                echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to remove this application from this server?') . '\');">';
                echo '<input type="hidden" name="action" value="del" />';
                echo '<input type="hidden" name="name" value="Application_Server" />';
                echo '<input type="hidden" name="application" value="' . $id . '" />';
                echo '<input type="hidden" name="server" value="' . $server->fqdn . '" />';
                echo '<input type="submit" value="' . _('Remove from this server') . '"/>';
                echo '</form>';
            }
            echo '</td>';
            echo '</tr>';
        }
        if (count($servers_available) > 0 and $can_manage_server) {
            echo '<tr>';
            echo '<form action="actions.php" method="post"><td>';
            echo '<input type="hidden" name="name" value="Application_Server" />';
            echo '<input type="hidden" name="action" value="add" />';
            echo '<input type="hidden" name="application" value="' . $id . '" />';
            echo '<select name="server">';
            foreach ($servers_available as $server) {
                echo '<option value="' . $server->fqdn . '">' . $server->fqdn . '</option>';
            }
            echo '</select>';
            echo '</td><td><input type="submit" value="' . _('Add to this server') . '" /></td>';
            echo '</form>';
            echo '</tr>';
        }
        echo '</table>';
        echo "<div>\n";
    }
    if (count($appgroups) > 0) {
        echo '<div>';
        echo '<h2>' . _('Groups with this application') . '</h2>';
        echo '<table border="0" cellspacing="1" cellpadding="3">';
        foreach ($groups as $group) {
            echo '<tr>';
            echo '<td>';
            echo '<a href="appsgroup.php?action=manage&id=' . $group->id . '">' . $group->name . '</a>';
            echo '</td>';
            echo '<td><form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this application from this group?') . '\');">';
            echo '<input type="hidden" name="name" value="Application_ApplicationGroup" />';
            echo '<input type="hidden" name="action" value="del" />';
            echo '<input type="hidden" name="element" value="' . $id . '" />';
            echo '<input type="hidden" name="group" value="' . $group->id . '" />';
            echo '<input type="submit" value="' . _('Delete from this group') . '" />';
            echo '</form></td>';
            echo '</tr>';
        }
        if (count($groups_available) > 0) {
            echo '<tr>';
            echo '<form action="actions.php" method="post"><td>';
            echo '<input type="hidden" name="name" value="Application_ApplicationGroup" />';
            echo '<input type="hidden" name="action" value="add" />';
            echo '<input type="hidden" name="element" value="' . $id . '" />';
            echo '<select name="group">';
            foreach ($groups_available as $group) {
                echo '<option value="' . $group->id . '">' . $group->name . '</option>';
            }
            echo '</select>';
            echo '</td><td><input type="submit" value="' . _('Add to this group') . '" /></td>';
            echo '</form>';
            echo '</tr>';
        }
        echo '</table>';
        echo "<div>\n";
    }
    // Mime-Type part
    echo '<div>';
    echo '<h2>' . _('Mime-Types') . '</h2>';
    echo '<div>';
    echo '<table border="0" cellspacing="1" cellpadding="3">';
    foreach ($mimeliste1 as $mime) {
        echo '<tr><td>';
        echo '<a href="mimetypes.php?action=manage&id=' . urlencode($mime) . '">' . $mime . '</a>';
        echo '</td>';
        echo '<td>';
        echo '<form action="actions.php" method="post">';
        echo '<input type="hidden" name="name" value="Application_MimeType" />';
        echo '<input type="hidden" name="action" value="del" />';
        echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />';
        echo '<input type="hidden" name="mime" value="' . $mime . '" />';
        echo '<input type="submit" value="' . _('Del') . '"/>';
        echo '</form>';
        echo '</td>';
        echo '</tr>';
    }
    if (is_array($mimeliste2) && count($mimeliste2) > 0) {
        echo '<tr>';
        echo '<form action="actions.php" method="post">';
        echo '<input type="hidden" name="name" value="Application_MimeType" />';
        echo '<input type="hidden" name="action" value="add" />';
        echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />';
        echo '<td>';
        echo '<select name="mime">';
        foreach ($mimeliste2 as $mime) {
            echo '<option>' . $mime . '</option>';
        }
        echo '</select>';
        echo '</td>';
        echo '<td>';
        echo '<input type="submit" value="' . _('Add') . '"/>';
        echo '</td>';
        echo '</form>';
        echo '</tr>';
    }
    echo '<tr>';
    echo '<form action="actions.php" method="post">';
    echo '<input type="hidden" name="name" value="Application_MimeType" />';
    echo '<input type="hidden" name="action" value="add" />';
    echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />';
    echo '<td>' . _('Custom Mime-Type: ') . '<input type="text" name="mime" /></td>';
    echo '<td>';
    echo '<input type="submit" value="' . _('Add') . '"/>';
    echo '</td>';
    echo '</form>';
    echo '</tr>';
    echo '</table>';
    echo '</div>';
    echo '</div>';
    // mime div
    echo '</div>';
    echo '</div>';
    echo '</div>';
    echo '</div>';
    echo '</div>';
    echo '</div>';
    page_footer();
    die;
}
 public static function delete($id_)
 {
     Logger::debug('main', 'Starting Abstract_Server::delete for \'' . $id_ . '\'');
     $SQL = SQL::getInstance();
     $SQL->DoQuery('SELECT 1 FROM #1 WHERE @2 = %3 LIMIT 1', self::table, 'id', $id_);
     $total = $SQL->NumRows();
     if ($total == 0) {
         Logger::error('main', "Abstract_Server::delete({$id_}) server does not exist (NumRows == 0)");
         return false;
     }
     $sessions_liaisons = Abstract_Liaison::load('ServerSession', $id_, NULL);
     foreach ($sessions_liaisons as $sessions_liaison) {
         $session = Abstract_Session::load($sessions_liaison->group);
         if (!$session) {
             continue;
         }
         $session->orderDeletion(true, Session::SESSION_END_STATUS_SERVER_DELETED);
     }
     Abstract_Liaison::delete('ServerSession', $id_, NULL);
     $a_server = Abstract_Server::load($id_);
     $roles = $a_server->getAttribute('roles');
     if (is_array($roles)) {
         foreach ($roles as $a_role => $role_enabled) {
             Abstract_Server::removeRole($id_, $a_role);
         }
     }
     $SQL->DoQuery('DELETE FROM #1 WHERE @2 = %3', self::table_properties, 'server', $id_);
     $SQL->DoQuery('DELETE FROM #1 WHERE @2 = %3 LIMIT 1', self::table, 'id', $id_);
     return true;
 }
示例#25
0
 public function importFromUsergroup($group_id_)
 {
     Logger::debug('main', "SharedFolderDB::internal::importFromUsergroup({$group_id_})");
     $liaisons = Abstract_Liaison::load('UserGroupSharedFolder', $group_id_, NULL);
     if (is_array($liaisons) == false) {
         Logger::error('main', "SharedFolderDB::internal::importFromUsergroup({$group_id_}) problem with liaison");
         return false;
     }
     $sharedfolders = array();
     foreach ($liaisons as $liaison) {
         $sharedfolder = $this->import($liaison->group);
         if (!is_object($sharedfolder)) {
             continue;
         }
         $sharedfolders[$sharedfolder->id] = $sharedfolder;
     }
     return $sharedfolders;
 }
示例#26
0
$buf = Abstract_Server::load($_GET['fqdn']);
if (!$buf || !$buf->isAuthorized()) {
    Logger::error('main', '(webservices/application) Server not authorized : ' . $_GET['fqdn'] . ' == ' . @gethostbyname($_GET['fqdn']) . ' ?');
    die('Server not authorized');
}
Logger::debug('main', '(webservices/application) Security check OK');
$prefs = Preferences::getInstance();
if (!$prefs) {
    die_error('get Preferences failed', __FILE__, __LINE__);
}
$mods_enable = $prefs->get('general', 'module_enable');
if (!in_array('ApplicationDB', $mods_enable)) {
    Logger::error('main', '(webservices/application) Module ApplicationDB must be enabled');
    header('HTTP/1.1 400 Bad Request');
    die;
}
$applicationDB = ApplicationDB::getInstance();
$app = $applicationDB->import($_GET['id']);
if (!is_object($app)) {
    Logger::error('main', '(webservices/application) error final');
    header('HTTP/1.1 404 Not Found');
    die;
}
if ($app->getAttribute('static')) {
    if (!is_object(Abstract_Liaison::load('StaticApplicationServer', $app->getAttribute('id'), $buf->fqdn))) {
        Abstract_Liaison::save('StaticApplicationServer', $app->getAttribute('id'), $buf->fqdn);
    }
}
header('Content-Type: text/xml; charset=utf-8');
echo $app->toXML($buf);
die;
示例#27
0
 public function updateApplications()
 {
     Logger::debug('main', 'Server::updateApplications');
     if (!is_array($this->roles) || !array_key_exists(Server::SERVER_ROLE_APS, $this->roles)) {
         Logger::critical('main', 'SERVER::updateApplications - Not an ApS');
         return false;
     }
     if (!$this->isOnline()) {
         Logger::debug('main', 'Server::updateApplications server "' . $this->fqdn . ':' . $this->web_port . '" is not online');
         return false;
     }
     $applicationDB = ApplicationDB::getInstance();
     $xml = query_url($this->getBaseURL() . '/aps/applications');
     if (!$xml) {
         $this->isUnreachable();
         Logger::error('main', 'Server::updateApplications server \'' . $this->fqdn . '\' is unreachable');
         return false;
     }
     if (!is_string($xml)) {
         Logger::error('main', 'Server::updateApplications invalid xml1');
         return false;
     }
     if (substr($xml, 0, 5) == 'ERROR') {
         $this->returnedError();
         Logger::error('main', 'Server::updateApplications invalid xml2');
         return false;
     }
     if ($xml == '') {
         Logger::error('main', 'Server::updateApplications invalid xml3');
         return false;
     }
     $dom = new DomDocument('1.0', 'utf-8');
     @$dom->loadXML($xml);
     $root = $dom->documentElement;
     // before adding application, we remove all previous applications
     $previous_liaison = Abstract_Liaison::load('ApplicationServer', NULL, $this->fqdn);
     // see end of function
     $current_liaison_key = array();
     $application_node = $dom->getElementsByTagName("application");
     $sync_apps = array();
     foreach ($application_node as $app_node) {
         $app_name = '';
         $app_description = '';
         $app_path_exe = '';
         $app_path_args = NULL;
         $app_package = NULL;
         $app_desktopfile = NULL;
         if ($app_node->hasAttribute("name")) {
             $app_name = $app_node->getAttribute("name");
         }
         if ($app_node->hasAttribute("description")) {
             $app_description = $app_node->getAttribute("description");
         }
         if ($app_node->hasAttribute("package")) {
             $app_package = $app_node->getAttribute("package");
         }
         if ($app_node->hasAttribute("desktopfile")) {
             $app_desktopfile = $app_node->getAttribute("desktopfile");
         }
         $local_id = $app_node->getAttribute("id");
         $exe_node = $app_node->getElementsByTagName('executable')->item(0);
         if ($exe_node->hasAttribute("command")) {
             $command = $exe_node->getAttribute("command");
             $command = str_replace(array("%U", "%u", "%c", "%i", "%f", "%m"), "", $command);
             $app_path_exe = trim($command);
         }
         $mimetypes = array();
         $mime_nodes = $app_node->getElementsByTagName('mime');
         foreach ($mime_nodes as $mime_node) {
             if (!$mime_node->hasAttribute("type")) {
                 continue;
             }
             $mimetypes[] = $mime_node->getAttribute("type");
         }
         $a = new Application(NULL, $app_name, $app_description, $this->getAttribute('type'), $app_path_exe, $app_package, true, $app_desktopfile);
         $a->setMimeTypes($mimetypes);
         $a_search = $applicationDB->search($app_name, $app_description, $this->getAttribute('type'), $app_path_exe);
         if (is_object($a_search)) {
             //already in DB
             // echo $app_name." already in DB\n";
             $a = $a_search;
         } else {
             // echo $app_name." NOT in DB\n";
             if ($applicationDB->isWriteable() == false) {
                 Logger::debug('main', 'Server::updateApplications applicationDB is not writeable');
             } else {
                 if ($applicationDB->add($a) == false) {
                     //echo 'app '.$app_name." not insert<br>\n";
                     return false;
                 }
             }
         }
         if ($applicationDB->isWriteable() == true) {
             if ($applicationDB->isOK($a) == true) {
                 // we add the app to the server
                 if (!is_object(Abstract_Liaison::load('ApplicationServer', $a->getAttribute('id'), $this->fqdn))) {
                     $ret = Abstract_Liaison::save('ApplicationServer', $a->getAttribute('id'), $this->fqdn);
                     if ($ret === false) {
                         Logger::error('main', 'Server::updateApplications failed to save application');
                         return $ret;
                     }
                 }
                 $current_liaison_key[] = $a->getAttribute('id');
             } else {
                 //echo "Application not ok<br>\n";
             }
         }
         $sync_apps[$local_id] = $a->getAttribute('id');
     }
     $previous_liaison_key = array_keys($previous_liaison);
     foreach ($previous_liaison_key as $key) {
         if (in_array($key, $current_liaison_key) == false) {
             $a = $applicationDB->import($key);
             if (is_null($a) || $a->getAttribute('static') == false) {
                 Abstract_Liaison::delete('ApplicationServer', $key, $this->fqdn);
             }
         }
     }
     if (count($sync_apps) > 0) {
         $dom = new DomDocument('1.0', 'utf-8');
         $applications_node = $dom->createElement('applications');
         foreach ($sync_apps as $local_id => $id) {
             $application_node = $dom->createElement('application');
             $application_node->setAttribute('id', $id);
             $application_node->setAttribute('local_id', $local_id);
             $applications_node->appendChild($application_node);
         }
         $dom->appendChild($applications_node);
         $xml = $dom->saveXML();
         query_url_post_xml($this->getBaseURL() . '/aps/applications/ids', $xml);
         foreach ($sync_apps as $local_id => $id) {
             $a = $applicationDB->import($id);
             if (!is_object($a)) {
                 continue;
             }
             if (!file_exists($a->getIconPathRW())) {
                 $this->getApplicationIcon($a->getAttribute('id'));
             }
         }
     }
     return true;
 }
示例#28
0
 public static function delete($fqdn_)
 {
     Logger::debug('main', 'Starting Abstract_Server::delete for \'' . $fqdn_ . '\'');
     if (substr($fqdn_, -1) == '.') {
         $fqdn_ = substr($fqdn_, 0, strlen($fqdn_) - 1);
     }
     $SQL = SQL::getInstance();
     $fqdn = $fqdn_;
     $SQL->DoQuery('SELECT 1 FROM @1 WHERE @2 = %3 LIMIT 1', $SQL->prefix . 'servers', 'fqdn', $fqdn);
     $total = $SQL->NumRows();
     if ($total == 0) {
         Logger::error('main', "Abstract_Server::delete({$server_}) server does not exist (NumRows == 0)");
         return false;
     }
     $sessions_liaisons = Abstract_Liaison::load('ServerSession', $fqdn_, NULL);
     foreach ($sessions_liaisons as $sessions_liaison) {
         $session = Abstract_Session::load($sessions_liaison->group);
         if (!$session) {
             continue;
         }
         $session->orderDeletion(true, Session::SESSION_END_STATUS_SERVER_DELETED);
     }
     Abstract_Liaison::delete('ServerSession', $fqdn_, NULL);
     $a_server = Abstract_Server::load($fqdn_);
     $roles = $a_server->getAttribute('roles');
     if (is_array($roles)) {
         foreach ($roles as $a_role) {
             Abstract_Server::removeRole($fqdn_, $a_role);
         }
     }
     $SQL->DoQuery('DELETE FROM @1 WHERE @2 = %3', $SQL->prefix . 'servers_properties', 'fqdn', $fqdn);
     $SQL->DoQuery('DELETE FROM @1 WHERE @2 = %3 LIMIT 1', $SQL->prefix . 'servers', 'fqdn', $fqdn);
     return true;
 }
示例#29
0
 public function getPolicy($with_default_ = true)
 {
     Logger::debug('main', 'UsersGroup::getPolicy for ' . $this->id);
     $prefs = Preferences::getInstance();
     $prefs_policy = $prefs->get('general', 'policy');
     $elements = $prefs->getElements('general', 'policy');
     if (array_key_exists('default_policy', $elements) == false) {
         Logger::error('main', 'UsersGroup::getPolicy, default_policy not found on general policy');
         return array();
     }
     $result_keys = $elements['default_policy']->content_available;
     $result = array();
     foreach ($result_keys as $key) {
         $result[$key] = false;
     }
     $default_policy = $prefs_policy['default_policy'];
     foreach ($default_policy as $k => $v) {
         if ($with_default_) {
             $result[$v] = true;
         } else {
             unset($result[$v]);
         }
     }
     $acls = Abstract_Liaison::load('ACL', $this->getUniqueID(), NULL);
     if (is_array($acls)) {
         foreach ($acls as $acl_liaison) {
             $result[$acl_liaison->group] = True;
         }
     }
     return $result;
 }
示例#30
0
function show_manage($id)
{
    $applicationsGroupDB = ApplicationsGroupDB::getInstance();
    $group = $applicationsGroupDB->import($id);
    if (!is_object($group)) {
        die_error('Import Group "' . $id . '" failed', __FILE__, __LINE__);
    }
    if ($group->published) {
        $status = '<span class="msg_ok">' . _('Enabled') . '</span>';
        $status_change = _('Block');
        $status_change_value = 0;
    } else {
        $status = '<span class="msg_error">' . _('Blocked') . '</span>';
        $status_change = _('Enable');
        $status_change_value = 1;
    }
    $applicationDB = ApplicationDB::getInstance();
    $userGroupDB = UserGroupDB::getInstance();
    $applications_all = $applicationDB->getList(true);
    $applications_id = array();
    $liaisons = Abstract_Liaison::load('AppsGroup', NULL, $id);
    foreach ($liaisons as $liaison) {
        $applications_id[] = $liaison->element;
    }
    $applications = array();
    $applications_available = array();
    foreach ($applications_all as $application) {
        if (!in_array($application->getAttribute('id'), $applications_id)) {
            $applications_available[] = $application;
        } else {
            $applications[] = $application;
        }
    }
    // Publications
    $groups_users = array();
    foreach (Abstract_Liaison::load('UsersGroupApplicationsGroup', NULL, $id) as $group_liaison) {
        $obj = $userGroupDB->import($group_liaison->element);
        if (is_object($obj)) {
            $groups_users[] = $obj;
        }
    }
    $groups_users_all = $userGroupDB->getList(true);
    $groups_users_available = array();
    foreach ($groups_users_all as $group_users) {
        if (!in_array($group_users, $groups_users)) {
            $groups_users_available[] = $group_users;
        }
    }
    $can_manage_applicationsgroups = isAuthorized('manageApplicationsGroups');
    $can_manage_publications = isAuthorized('managePublications');
    page_header();
    echo '<div>';
    echo '<h1><a href="?">' . _('Application groups management') . '</a> - ' . $group->name . '</h1>';
    echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="3">';
    echo '<tr class="title">';
    echo '<th>' . _('Description') . '</th>';
    echo '<th>' . _('Status') . '</th>';
    echo '</tr>';
    echo '<tr class="content1">';
    echo '<td>' . $group->description . '</td>';
    echo '<td>' . $status . '</td>';
    echo '</tr>';
    echo '</table>';
    if ($can_manage_applicationsgroups) {
        echo '<div>';
        echo '<h2>' . _('Settings') . '</h2>';
        echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this group?') . '\');">';
        echo '<input type="submit" value="' . _('Delete this group') . '"/>';
        echo '<input type="hidden" name="name" value="ApplicationsGroup" />';
        echo '<input type="hidden" name="action" value="del" />';
        echo '<input type="hidden" name="checked_groups[]" value="' . $id . '" />';
        echo '<input type="hidden" name="id" value="' . $id . '" />';
        echo '</form>';
        echo '<br/>';
        echo '<form action="actions.php" method="post">';
        echo '<input type="hidden" name="name" value="ApplicationsGroup" />';
        echo '<input type="hidden" name="action" value="modify" />';
        echo '<input type="hidden" name="id" value="' . $id . '" />';
        echo '<input type="hidden" name="published_appsgroup" value="' . $status_change_value . '" />';
        echo '<input type="submit" value="' . $status_change . '"/>';
        echo '</form>';
        echo '<br/>';
        echo '<form action="actions.php" method="post">';
        echo '<input type="hidden" name="name" value="ApplicationsGroup" />';
        echo '<input type="hidden" name="action" value="modify" />';
        echo '<input type="hidden" name="id" value="' . $id . '" />';
        echo '<input type="text" name="name_appsgroup"  value="' . $group->name . '" size="50" /> ';
        echo '<input type="submit" value="' . _('Update the name') . '"/>';
        echo '</form>';
        echo '<br/>';
        echo '<form action="actions.php" method="post">';
        echo '<input type="hidden" name="name" value="ApplicationsGroup" />';
        echo '<input type="hidden" name="action" value="modify" />';
        echo '<input type="hidden" name="id" value="' . $id . '" />';
        echo '<input type="text" name="description_appsgroup"  value="' . $group->description . '" size="50" /> ';
        echo '<input type="submit" value="' . _('Update the description') . '"/>';
        echo '</form>';
        echo '<br/>';
    }
    // Application part
    if (count($applications_all) > 0 and $can_manage_applicationsgroups or count($applications) > 0) {
        echo '<div>';
        echo '<h2>' . _('List of applications in this group') . '</h2>';
        echo '<table border="0" cellspacing="1" cellpadding="3">';
        if (count($applications) > 0) {
            foreach ($applications as $application) {
                echo '<tr>';
                echo '<td><img src="media/image/cache.php?id=' . $application->getAttribute('id') . '" alt="' . $application->getAttribute('name') . '" title="' . $application->getAttribute('name') . '" /> <a href="applications.php?action=manage&id=' . $application->getAttribute('id') . '">' . $application->getAttribute('name') . '</a>';
                echo '</td>';
                if ($can_manage_applicationsgroups) {
                    echo '<td>';
                    echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this application?') . '\');">';
                    echo '<input type="hidden" name="action" value="del" />';
                    echo '<input type="hidden" name="name" value="Application_ApplicationGroup" />';
                    echo '<input type="hidden" name="group" value="' . $id . '" />';
                    echo '<input type="hidden" name="element" value="' . $application->getAttribute('id') . '" />';
                    echo '<input type="submit" value="' . _('Delete from this group') . '" />';
                    echo '</form>';
                    echo '</td>';
                }
                echo '</tr>';
            }
        }
        if (count($applications_available) > 0 and $can_manage_applicationsgroups) {
            echo '<tr><form action="actions.php" method="post"><td>';
            echo '<input type="hidden" name="action" value="add" />';
            echo '<input type="hidden" name="name" value="Application_ApplicationGroup" />';
            echo '<input type="hidden" name="group" value="' . $id . '" />';
            echo '<select name="element">';
            foreach ($applications_available as $application) {
                echo '<option value="' . $application->getAttribute('id') . '" >' . $application->getAttribute('name') . ' (' . $application->getAttribute('type') . ')</option>';
            }
            echo '</select>';
            echo '</td><td><input type="submit" value="' . _('Add to this group') . '" /></td>';
            echo '</form></tr>';
        }
        echo '</table>';
        echo '</div>';
    }
    /*
      // Servers
      echo '<div>';
      echo '<h2>'._('List of servers including this group').'</h2>';
      echo '<table border="0" cellspacing="1" cellpadding="3">';
      if (count($servers) == 0)
        echo '<tr><td colspan="2">'._('No server has this group').'</td></tr>';
      else {
        foreach($servers as $server) {
          echo '<tr>';
          echo '<td><a href="servers.php?action=manage&id='.$server->fqdn.'">'.$server->fqdn.'</a>';
          echo '</td>';
          echo '<td>';
          echo '<form action="actions.php" method="post" onsubmit="return confirm(\''._('Are you sure you want to delete this group from this server?').'\');">';
          echo '<input type="hidden" name="action" value="del" />';
          echo '<input type="hidden" name="name" value="ApplicationGroup_Server" />';
          echo '<input type="hidden" name="group" value="'.$id.'" />';
          echo '<input type="hidden" name="server" value="'.$server->fqdn.'" />';
          echo '<input type="submit" value="'._('Delete from this group').'" /> FIXME';
          echo '</form>';
          echo '</td>';
          echo '</tr>';
        }
      }
      if (count ($servers_available) ==0)
        echo '<tr><td colspan="2">'._('Not any available server to add').'</td></tr>';
      else {
        echo '<tr><form action="actions.php" method="post"><td>';
        echo '<input type="hidden" name="action" value="add" />';
        echo '<input type="hidden" name="name" value="Application_ApplicationGroup" />';
        echo '<input type="hidden" name="group" value="'.$id.'" />';
        echo '<select name="element">';
        foreach($servers_available as $servers)
          echo '<option value="'.$server->fqdn.'" >'.$server->fqdn.'</option>';
        echo '</select>';
        echo '</td><td><input type="submit" value="'._('Add to this server').'" /></td>';
        echo '</form></tr>';
      }
      echo '</table>';
      echo '</div>';
    */
    // Publication part
    if (count($groups_users_all) > 0) {
        echo '<div>';
        echo '<h2>' . _('List of publications for this group') . '</h1>';
        echo '<table border="0" cellspacing="1" cellpadding="3">';
        if (count($groups_users) > 0) {
            foreach ($groups_users as $group_users) {
                echo '<tr>';
                echo '<td><a href="usersgroup.php?action=manage&id=' . $group_users->getUniqueID() . '">' . $group_users->name . '</td>';
                if ($can_manage_publications) {
                    echo '<td>';
                    echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this publication?') . '\');">';
                    echo '<input type="hidden" name="action" value="del" />';
                    echo '<input type="hidden" name="name" value="Publication" />';
                    echo '<input type="hidden" name="group_a" value="' . $id . '" />';
                    echo '<input type="hidden" name="group_u" value="' . $group_users->getUniqueID() . '" />';
                    echo '<input type="submit" value="' . _('Delete this publication') . '" />';
                    echo '</form>';
                    echo '</td>';
                }
                echo '</tr>';
            }
        }
        if (count($groups_users_available) > 0 and $can_manage_publications) {
            echo '<tr><form action="actions.php" method="get"><td>';
            echo '<input type="hidden" name="action" value="add" />';
            echo '<input type="hidden" name="name" value="Publication" />';
            echo '<input type="hidden" name="group_a" value="' . $id . '" />';
            echo '<select name="group_u">';
            foreach ($groups_users_available as $group_users) {
                echo '<option value="' . $group_users->getUniqueID() . '" >' . $group_users->name . '</option>';
            }
            echo '</select>';
            echo '</td><td><input type="submit" value="' . _('Add this publication') . '" /></td>';
            echo '</form></tr>';
        }
        echo '</table>';
        echo '</div>';
    }
    echo '</div>';
    echo '</div>';
    echo '</div>';
    page_footer();
    die;
}