File: RevokeAdmin.pm

package info (click to toggle)
sporum 1.8b1-3.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,108 kB
  • ctags: 676
  • sloc: perl: 14,300; makefile: 52
file content (92 lines) | stat: -rw-r--r-- 2,253 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package Templates::Admin::RevokeAdmin;

use SmallPigVars qw($config);

use CGI qw(:standard :cgi-lib);

use Templates::Admin::Block;
use Templates::Admin::OptBlock;

use strict;
my @ISA = qw(Templates::Admin::Block);

my %CACHE;

my $lang;

sub new{
  my ($class) = @_;
  my $self = Templates::Admin::Block->new();
  
  my $id = join '', sort values %$self, "revokeadminblock";
  return $CACHE{$id} if $CACHE{$id};
  return $CACHE{$id} = bless $self, $class;
}

sub display{
  my ($self, $STATE) = @_;
  my $theme = $STATE->{'theme'};

  $lang = $STATE->{'langptr'}; 

  my $standardindex = Templates::Admin::StandardIndex->new($STATE);

  my $content = _get_adminslist($STATE);
  my $classvars = {('content' => $content)};
  my $adminslist = Templates::Admin::OptBlock->new($classvars, $theme);
  
  my $ret;
  $ret = start_form(-method=>"post", 
		    -action=>"$config->{'cgidir'}/admin.cgi");
  $ret .= $standardindex->get();
  $ret .= $adminslist->get();
  $ret .= "<font size=1>".submit(-name=>"op", -value=>$lang->{'RevokeAdmin'})."</font>";
  $ret .= end_form()."</TD>";
  
  return $ret;
}

sub _get_adminslist{
  my $STATE = shift;
  my $ret = "";
  my $postsper = $STATE->{'postsper'};
  my $theme = $STATE->{'theme'};
  my $select = "uid, username,
                date_format(registered, \"$config->{date_format}\")";
  my $from = "Users";
  my $where = "isadmin=1 AND uid<>1 AND active=1";
  require SPDB;
  my ($admins) = SPDB->new->db_select_many(1, $select, $from, $where);
  
  $ret .= qq!
<TR BGCOLOR=$theme->{'dhdrcolor'} CELLPADDING=2>
<TD WIDTH=10% CLASS=bheader2>$lang->{'select'}</TD>
<TD CLASS=bheader2>$lang->{'loginusername'}</TD>
<TD WIDTH=25% CLASS=bheader2>$lang->{'assigned_on'}</TD>
</TR>
  !;

  unless($admins){
    $ret .= "<TR><TD COLSPAN=3>$lang->{'no_admins'}</TD></TR>";
  }

  foreach (@$admins){
    my ($uid, $username, $registered) = @$_;

 $registered =~ s/(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/$lang->{$1}/ig;

    $ret .= qq!
<TR>
  <TD WIDTH=10%><INPUT TYPE=radio NAME=selectedadmin VALUE=$uid></TD>
  <TD><A HREF=$config->{'cgidir'}/user.cgi?op=userinfo&uid=$uid&page=1&postsper=$postsper>$username</A></TD>
  <TD WIDTH=25%>$registered</TD>
</TR>
  !;
    
  }
  
  return $ret;
}


return 1;