[prev in list] [next in list] [prev in thread] [next in thread] 

List:       webmin-l
Subject:    How to add the link on top of the table in User/Group
From:       "Mark Jeremy" <mark () grapevine2 ! net>
Date:       2001-02-28 15:59:57
[Download RAW message or body]

Well, I took a dive into CGI/Perl Programming and thought I could give these
developers a hand.

I did a bit of investigation on CGI and webmin code and how they work
together and I managed to come up a simple solution for those who want to
have the "Create a new user" and "Create multiple users" on top of the table
rather than below the table.

Please make a backup of your copy of webmin before going ahead with this in
case something goes wrong.

You will only need to modify the useradmin/index.cgi with your favorite
editor. I'm going to try to follow Joe Cooper method of where to add the
code. There are four areas within the code that you need to add
"&createnewuser" subroutine and you would need to add the whole subroutine
at the end of the file.




elsif (@ulist) {
        # Display a table of all users
        print "<hr>\n";
        if ($config{'sort_mode'} == 1) {
                @ulist = sort { $a->{'user'} cmp $b->{'user'} } @ulist;
                }
        elsif ($config{'sort_mode'} == 2) {
                @ulist = sort { lc($a->{'real'}) cmp lc($b->{'real'}) }
@ulist;
                }
        elsif ($config{'sort_mode'} == 3) {
                @ulist = sort { @wa = split(/\s+/, $a->{'real'});
                                @wb = split(/\s+/, $b->{'real'});
                                lc($wa[@wa-1]) cmp lc($wb[@wb-1]) } @ulist;
                }
        elsif ($config{'sort_mode'} == 4) {
                @ulist = sort { $a->{'shell'} cmp $b->{'shell'} } @ulist;
                }
        if ($access{'icons'}) {
                # Show an icon for each user
                print "<h3>$text{'index_users'}</h3>\n";
------->
                &createnewuser;
<-------
                local @icons = map { "images/user.gif" } @ulist;
                local @links = map { "edit_user.cgi?num=$_->{'num'}" }
@ulist;
                local @titles = map { $_->{'user'} } @ulist;
                &icons_table(\@links, \@titles, \@icons, 5);
                }
        elsif ($config{'display_mode'} == 2) {
                # Show usernames under groups
                foreach $u (@ulist) {
                        push(@{$ug{$u->{'gid'}}}, $u);
                        }
------->
                &createnewuser;
<-------
                print "<table width0% border>\n";
                print "<tr $tb> <td><b>$text{'index_ugroup'}</b></td> ",
                      "<td><b>$text{'index_users'}</b></td> </tr>\n";
                foreach $g (keys %ug) {
                        print "<tr $cb> <td width %><b>",
                              "$usedgid{$g}->{'group'}</b></td>\n";
                        print "<td width€%><table width0% ",
                              "cellpadding=0 cellspacing=0>\n";
                        $i = 0;
                        foreach $u (@{$ug{$g}}) {
                                if ($i%4 == 0) { print "<tr>\n"; }
                                print "<td width%%><a
href=\"edit_user.cgi?",
                                      "num=$u->{'num'}\">",
                                      "$u->{'user'}</a></td>\n";
                                if ($i%4 == 3) { print "</tr>\n"; }
                                $i++;
                                }
                        print "</table></td> </tr>\n";
                        }
                print "</table>\n";
                }
        elsif ($config{'display_mode'} == 1) {
                # Show names, real names, home dirs and shells
                print "<h3>$text{'index_users'}</h3>\n";
------->
                &createnewuser;
<-------
                print "<table width0% border>\n";
                print "<tr $tb> <td><b>$text{'user'}</b></td> ",
                      "<td><b>$text{'uid'}</b></td> ",
                      "<td><b>$text{'real'}</b></td> ",
                      "<td><b>$text{'home'}</b></td> ",
                      "<td><b>$text{'shell'}</b></td> </tr>\n";
                foreach $u (@ulist) {
                        print "<tr $cb> <td><a href='edit_user.cgi?",
                              "num=$u->{'num'}'>$u->{'user'}</a></td> ",
                              "<td>$u->{'uid'}</td> ",
                              "<td>",&ifblank($u->{'real'}),"</td> ",
                              "<td>",&ifblank($u->{'home'}),"</td> ",
                              "<td>",&ifblank($u->{'shell'}),"</td>
</tr>\n";
                        }
                print "</table>\n";
                }
        else {
------->
                &createnewuser;
<-------
                # Just show names
                print "<table width0% border>\n";
                print "<tr $tb> <td><b>$text{'index_users'}</b></td>
</tr>\n";
                print "<tr $cb> <td><table width0%>\n";
                for($i=0; $i<@ulist; $i++) {
                        if ($i%4 == 0) { print "<tr>\n"; }
                        print "<td><a href=\"edit_user.cgi?",
                              "num=$ulist[$i]->{'num'}\">",
                              "$ulist[$i]->{'user'}</a></td>\n";
                        if ($i%4 == 3) { print "</tr>\n"; }
                        }
                print "</table></td> </tr></table>\n";
                }
        }



***** Note: Add this subroute at the end of the file, after sub ifblank
code.
...........
&footer("/", $text{'index'});

sub ifblank
{
return $_[0] ? $_[0] : "&nbsp;";
}

----->
sub createnewuser
{
               print "<a href=\"edit_user.cgi\">",
                      "$text{'index_createuser'}</a>\n";
                if ($access{'uedit_mode'} == 0 && $access{'lowuid'} == 0 &&
                    $access{'ugroups'} eq '*' && $access{'shells'} eq '*' &&
                    $access{'peopt'} && $access{'home'} eq '/') {
                        print "&nbsp;&nbsp;<a href=\"many_form.cgi\">",
                              "$text{'index_createmany'}</a>\n";
                        }
                print "<p>\n";
}
<-----

If you guys came across any problems with this, let me know

Cheers,
Mark

__________________________________________________________
Mark Jeremy

-----Original Message-----
From: webadmin-list-admin@lists.sourceforge.net
[mailto:webadmin-list-admin@lists.sourceforge.net]On Behalf Of Terry
Wilson
Sent: Monday, February 26, 2001 4:48 PM
To: webadmin-list@lists.sourceforge.net
Subject: Re: Question about Bind8



>its a bit of a pain in the nick to
>scroll down the list just to click on "Create new master zone" every time
>when I add a new domain.

Concur...I have same problem with Users and Groups pages.

Terry Wilson
aka Tux the Linux Freak


______________________________________________________________________
Get Your Own Private, Free Email Account at http://www.dotcomemail.com
Now With Over 1,500 Com, Net, and Org Domains to Choose From!


-
Forwarded by the Webmin mailing list at webmin-l@webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-list


-
Forwarded by the Webmin mailing list at webmin-l@webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-list

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic