File: AssignUsers.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 (85 lines) | stat: -rw-r--r-- 2,282 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
package Templates::Admin::AssignUsers;

use SmallPigVars qw($config);
use SmallPig;
use CGI qw(:standard :cgi-lib);
use Templates::Admin::Block;
use Templates::Admin::OptBlock;
use Templates::Admin::UsersList;
use Templates::Admin::AssignUsersList;
use Templates::Admin::Caution;

use strict;
use vars qw(@ISA);

@ISA = qw(Templates::Admin::Block Templates::Admin::OptBlock);

my %CACHE;

my $lang;

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

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

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

  my $standardindex = Templates::Admin::StandardIndex->new($STATE);
  my $userslist = Templates::Admin::UsersList->new($STATE);
  my $caution = Templates::Admin::Caution->new($theme);
  my $assignuserslist = Templates::Admin::AssignUsersList->new($STATE);

  my ($msg, $ul);
  if($op eq "assignmod" || $prev_op =~ "assignmod"){
      $msg = $lang->{'assign_mod3'};
      $msg .= $lang->{'make_mult_sel'};
      $ul = $userslist->get_modlist($STATE);
  }
  else{
      $msg = $lang->{'assign_group'};
      $msg .= $lang->{'make_mult_sel'};
      $ul .= $userslist->get_grouplist($STATE);
  }
  
  my $ret;
  $ret = start_form(-method=>"post", 
		    -action=>"$config->{'cgidir'}/admin.cgi");
  $ret .= $standardindex->get(); 
  $ret .= $ul;
  $ret .= $caution->get($msg);
  $ret .= $assignuserslist->get();
  $ret .= "<font size=1>";

  if($op eq $lang->{'PreviewModerator'}){
      $ret .= submit(-name=>"op", -value=>$lang->{'SaveModerator'});
  }
  elsif($op eq $lang->{'PreviewGroup'}){
      $ret .= submit(-name=>"op", -value=>$lang->{'SaveGroup'});
  }
  if($op eq $lang->{'PreviewModerator'} || $op eq "assignmod"){
      $ret .= submit(-name=>"op", -value=>$lang->{'PreviewModerator'});
  }
  else{
      $ret .= submit(-name=>"op", -value=>$lang->{'PreviewGroup'});
  }
  $op = "$prev_op\#$op" if $prev_op;
  $ret .= hidden(-name=>"prev_op", -value=>$op);
  $ret .= "</font>";
  $ret .= end_form()."</TD>";
  
  return $ret;
}

return 1;