0ch_force774
@@ -0,0 +1,186 @@ | ||
1 | +#============================================================================================================ | |
2 | +# | |
3 | +# 拡張機能 - 強制名無し | |
4 | +# 0ch_force774.pl | |
5 | +# | |
6 | +#============================================================================================================ | |
7 | +package ZPL_force774; | |
8 | + | |
9 | + | |
10 | + | |
11 | +#------------------------------------------------------------------------------------------------------------ | |
12 | +# 拡張機能名称取得 | |
13 | +#------------------------------------------------------------------------------------------------------------ | |
14 | +sub getName | |
15 | +{ | |
16 | + return '強制名無し'; | |
17 | +} | |
18 | + | |
19 | +#------------------------------------------------------------------------------------------------------------ | |
20 | +# 拡張機能説明取得 | |
21 | +#------------------------------------------------------------------------------------------------------------ | |
22 | +sub getExplanation | |
23 | +{ | |
24 | + return 'システム共通権限のあるキャップでメール欄にコマンド「!774」または「!774:任意の名無し」を入力することで名無しを強制することができます。'; | |
25 | +} | |
26 | + | |
27 | +#------------------------------------------------------------------------------------------------------------ | |
28 | +# 拡張機能タイプ取得 | |
29 | +#------------------------------------------------------------------------------------------------------------ | |
30 | +sub getType | |
31 | +{ | |
32 | + return 1|2; | |
33 | +} | |
34 | + | |
35 | +#------------------------------------------------------------------------------------------------------------ | |
36 | +# 設定リスト取得 (0ch+ Only) | |
37 | +#------------------------------------------------------------------------------------------------------------ | |
38 | +sub getConfig | |
39 | +{ | |
40 | + return { | |
41 | + 'owner_can_set' => { | |
42 | + 'default' => 1, | |
43 | + 'valuetype' => 3, | |
44 | + 'description' => 'キャップなしでもスレ主はスレ立て時に設定することができる。', | |
45 | + }, | |
46 | + 'cap_not_forced' => { | |
47 | + 'default' => 1, | |
48 | + 'valuetype' => 3, | |
49 | + 'description' => 'キャップコテハン★は名無しを強制されない。', | |
50 | + }, | |
51 | + }; | |
52 | +} | |
53 | + | |
54 | +#------------------------------------------------------------------------------------------------------------ | |
55 | +# 拡張機能実行インタフェイス | |
56 | +#------------------------------------------------------------------------------------------------------------ | |
57 | +sub execute | |
58 | +{ | |
59 | + my $this = shift; | |
60 | + my ($Sys, $Form, $type) = @_; | |
61 | + | |
62 | + my $CGI = $Sys->Get('MainCGI'); | |
63 | + my $Threads = $CGI->{'THREADS'} || $Sys->Get('_THREAD_'); | |
64 | + my $threadid = $Sys->Get('KEY'); | |
65 | + | |
66 | + # スレッド属性情報を読み込む | |
67 | + $Threads->LoadAttr($Sys); | |
68 | + | |
69 | + # キャップ管理モジュールを準備 | |
70 | + my $Sec = SECURITY->new; | |
71 | + $Sec->Init($Sys); | |
72 | + $Sec->SetGroupInfo($bbs); | |
73 | + | |
74 | + # 設定 | |
75 | + my $owner_can_set = $this->GetConf('owner_can_set'); | |
76 | + my $cap_not_forced = $this->GetConf('cap_not_forced'); | |
77 | + | |
78 | + # 各種情報を取得 | |
79 | + my $name = $Form->Get('FROM'); | |
80 | + my $mail = $Form->Get('mail'); | |
81 | + my $tate = $Sys->Equal('MODE', 1); | |
82 | + my $bbs = $Sys->Get('BBS'); | |
83 | + my $capid = $Sys->Get('CAPID', ''); | |
84 | + my $admin = $capid && $Sec->IsAuthority($capid, 0, '*'); | |
85 | + my $kote = $capid && $Sec->IsAuthority($capid, $ZP::CAP_DISP_HANLDLE, $bbs); | |
86 | + | |
87 | + # システム共通権限ありのキャップ または >>1 なら設定可 | |
88 | + if ($admin || ($owner_can_set && $tate)) { | |
89 | + if ($mail =~ s/!774(?:\:(.*))?$//g) { | |
90 | + $Form->Set('mail', $mail); | |
91 | + $Threads->SetAttr($threadid, 'force774', "!$1"); | |
92 | + } | |
93 | + $Threads->SaveAttr($Sys); | |
94 | + } | |
95 | + | |
96 | + my $force774 = $Threads->GetAttr($threadid, 'force774'); | |
97 | + if ($force774 =~ /^!(.*)$/ && !($cap_not_forced && $kote)) { | |
98 | + $Form->Set('FROM', $1); | |
99 | + } | |
100 | + | |
101 | + return 0; | |
102 | +} | |
103 | + | |
104 | +#------------------------------------------------------------------------------------------------------------ | |
105 | +# なんちゃってbbs.cgiエラーページ表示 | |
106 | +#------------------------------------------------------------------------------------------------------------ | |
107 | +sub PrintBBSError | |
108 | +{ | |
109 | + my ($Sys, $err) = @_; | |
110 | + | |
111 | + require './module/orald.pl'; | |
112 | + | |
113 | + my $CGI = $Sys->Get('MainCGI'); | |
114 | + my $Page = $CGI->{'PAGE'}; | |
115 | + | |
116 | + my $Error = ORALD->new; | |
117 | + $Error->Load($Sys); | |
118 | + $Error->Print($CGI, $Page, $err, $Sys->Get('AGENT')); | |
119 | + | |
120 | + $Page->Flush('', 0, 0); | |
121 | + | |
122 | + exit($err); | |
123 | +} | |
124 | + | |
125 | + | |
126 | + | |
127 | +#------------------------------------------------------------------------------------------------------------ | |
128 | +# コンストラクタ | |
129 | +#------------------------------------------------------------------------------------------------------------ | |
130 | +sub new | |
131 | +{ | |
132 | + my $class = shift; | |
133 | + my ($Config) = @_; | |
134 | + | |
135 | + my $this = {}; | |
136 | + bless $this, $class; | |
137 | + | |
138 | + if (defined $Config) { | |
139 | + $this->{'PLUGINCONF'} = $Config; | |
140 | + $this->{'is0ch+'} = 1; | |
141 | + } | |
142 | + else { | |
143 | + $this->{'CONFIG'} = $class->getConfig(); | |
144 | + $this->{'is0ch+'} = 0; | |
145 | + } | |
146 | + | |
147 | + return $this; | |
148 | +} | |
149 | + | |
150 | +#------------------------------------------------------------------------------------------------------------ | |
151 | +# 設定値取得 (0ch+ Only) | |
152 | +#------------------------------------------------------------------------------------------------------------ | |
153 | +sub GetConf | |
154 | +{ | |
155 | + my $this = shift; | |
156 | + my ($key) = @_; | |
157 | + if ($this->{'is0ch+'}) { | |
158 | + return $this->{'PLUGINCONF'}->GetConfig($key); | |
159 | + } | |
160 | + elsif (defined $this->{'CONFIG'}->{$key}) { | |
161 | + return $this->{'CONFIG'}->{$key}->{'default'}; | |
162 | + } | |
163 | +} | |
164 | + | |
165 | +#------------------------------------------------------------------------------------------------------------ | |
166 | +# 設定値設定 (0ch+ Only) | |
167 | +#------------------------------------------------------------------------------------------------------------ | |
168 | +sub SetConf | |
169 | +{ | |
170 | + my $this = shift; | |
171 | + my ($key, $val) = @_; | |
172 | + if ($this->{'is0ch+'}) { | |
173 | + $this->{'PLUGINCONF'}->SetConfig($key, $val); | |
174 | + } | |
175 | + elsif (defined $this->{'CONFIG'}->{$key}) { | |
176 | + $this->{'CONFIG'}->{$key}->{'default'} = $val; | |
177 | + } | |
178 | + else { | |
179 | + $this->{'CONFIG'}->{$key} = { 'default' => $val }; | |
180 | + } | |
181 | +} | |
182 | + | |
183 | +#============================================================================================================ | |
184 | +# Module END | |
185 | +#============================================================================================================ | |
186 | +1; |