File: ThreadsBlock.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 (118 lines) | stat: -rw-r--r-- 3,410 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package Templates::Admin::ThreadsBlock;

use SmallPigVars qw($config);
use Templates::Admin::SmallPig;

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

use Templates::Admin::Boards;
use Templates::Admin::TopicsList;
use Templates::Admin::PageIndex;
use Templates::Admin::Block;
use Templates::Admin::OptBlock;
use Templates::Admin::Caution;

use strict;
use vars qw(@ISA $DBH $lang);

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

my %CACHE;

sub new{
  # --- expire threads (2)
  # --- open threads   (2)
  # --- close threads  (2)
  # --- approve threads(2)
  # --- move copy threads(2)
  # --- list the threads information for above operations
  my ($class) = @_;
  my $self = Templates::Admin::Block->new("boardblock");
  
  my $id = join '', sort values %$self, "closethreadsblock";
  return $CACHE{$id} if $CACHE{$id};

  return $CACHE{$id} = bless $self, $class;
}

sub get{
  my ($self, $STATE) = @_;
  my ($op, $sid, $userstatus, $tuserstatus, $mostparent) = 
      map{ $STATE->{$_} } qw(op sid userstatus tuserstatus mostparent);
  my ($ret, $msg);
  
  $lang = $STATE->{'langptr'};

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

  $msg = 
    ($op eq "closethreads")?$lang->{'close_threads_msg2'}:
      ($op eq "expirethreads")?$lang->{'expire_threads_msg2'}:
	($op eq "openthreads")?$lang->{'open_threads_msg2'}:
          ($op eq "movecopythreads")?$lang->{'move_copy_threads_msg2'}:
	      ($op eq "umovethreads")?$lang->{'move_copy_threads_msg2'}:
		  $lang->{'approve_threads_msg2'};

  my $theme = $STATE->{'theme'};
  my $caution = Templates::Admin::Caution->new($theme);
  
  # --- make sure it is in collapsed view
  $STATE->{'view'} = "collapsed";
  my $topicslist = Templates::Admin::TopicsList->new("", "", $STATE);
  
  my $name = ($op eq "closethreads")?"closethreads":
    ($op eq "expirethreads")?"expirethreads":
      ($op eq "openthreads")?"openthreads":
	  ($op eq "movecopythreads")?"movecopythreads":
	      ($op eq "umovethreads")?"umovethreads":
		  "approvethreads";
  my $submit = ($op eq "closethreads")?$lang->{'CloseThreads'}:
    ($op eq "expirethreads")?$lang->{'ExpireThreads'}:
      ($op eq "openthreads")?$lang->{'OpenThreads'}:
	  $lang->{'ApproveThreads'};
  
  $ret = Templates::Admin::SmallPig::check_all_script($name);
  my ($tmp) = $topicslist->get($STATE);
  $ret .= "<!--ThreadsBlock-->\n";
  my $script = ($op eq "umovethreads")?"user.cgi":"admin.cgi";
  $ret .= start_form(-action=>"$config->{'cgidir'}/$script", 
		     -name=>$name, -method=>"post");
  $ret .= $standardindex->get();
  $ret .= $caution->get($msg);
  $ret .= $tmp;
  $ret .= hidden(-name=>"sid", -value=>"$sid");
  $ret .= "<font size=1>";
  if($op eq "movecopythreads" || $op eq "umovethreads"){
      $ret .= 
Templates::Admin::SmallPig::select_forums_w_cats($sid, $userstatus, 
						 $tuserstatus, $lang);
      $ret .= submit(-name=>"op", -value=>$lang->{'MoveThreads'});
#      $ret .= submit(-name=>"op", -value=>$lang->{'CopyThreads'});
  }
  else{
      $ret .= submit(-name=>"op", -value=>"$submit");
  }

  $ret .= "<input type=hidden name=mostparent value=1>" if $mostparent;

  $ret .= "</font>";
  $ret .= end_form()."</TD>";
  $ret .= "<!--end ThreadsBlock-->\n";
  
  return $ret;
}

sub display{
  my ($self, $STATE) = @_;
  print get($self, $STATE);
}

sub save{
  my ($self, $STATE) = @_;
  my $content = get($self, $STATE);
  $self->save1($content);
}



return 1;