]> git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Conf/Admin.pm
these modules should now work with ne Lock-module
[selfforum.git] / selfforum-cgi / shared / Conf / Admin.pm
1 package Conf::Admin;
2
3 ################################################################################
4 # #
5 # File: shared/CheckRFC.pm #
6 # #
7 # Authors: Andre Malo <nd@o3media.de>, 2001-06-16 #
8 # #
9 # Description: read and parse admin default config #
10 # #
11 ################################################################################
12
13 use strict;
14 use vars qw(
15 @EXPORT
16 $VERSION
17 );
18
19 use Lock;
20
21 use XML::DOM;
22
23 ################################################################################
24 #
25 # Version check
26 #
27 $VERSION = do { my @r =(q$Revision$ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
28
29 ################################################################################
30 #
31 # Export
32 #
33 use base qw(Exporter);
34 @EXPORT = qw(read_admin_conf);
35
36 ### get_severance () ###########################################################
37 #
38 # read out severance config (used twice)
39 #
40 # Params: $severance - element node
41 #
42 # Return: hashref
43 #
44 sub get_severance ($) {
45 my $severance = shift;
46
47 my $after_byte = $severance -> getElementsByTagName ('AfterByte', 0) -> item (0);
48 my $after_message = $severance -> getElementsByTagName ('AfterMessage', 0) -> item (0);
49 my $after_thread = $severance -> getElementsByTagName ('AfterThread', 0) -> item (0);
50 my $last_posting = $severance -> getElementsByTagName ('AfterLastPosting', 0) -> item (0);
51
52 my %conf =(
53 exArchiving => $severance -> getAttribute ('executeArchiving'),
54 archiving => $severance
55 -> getElementsByTagName ('Archiving', 0) -> item (0)
56 -> getElementsByTagName ('*', 0) -> item (0) -> getTagName,
57 severance => $severance -> getAttribute ('executeSeverance'),
58 afterByte => (
59 $after_byte
60 ? $after_byte -> getFirstChild -> getData
61 : undef
62 ),
63 afterThread => (
64 $after_thread
65 ? $after_thread -> getFirstChild -> getData
66 : undef
67 ),
68 afterMessage => (
69 $after_message
70 ? $after_message -> getFirstChild -> getData
71 : undef
72 ),
73 lastPosting => (
74 $last_posting
75 ? $last_posting -> getFirstChild -> getData
76 : undef
77 )
78 );
79
80 \%conf;
81 }
82
83 ### read_admin_conf () #########################################################
84 #
85 # read and parse admin config
86 #
87 # Params: $filename - filename
88 #
89 # Return: hashref
90 #
91 sub read_admin_conf ($) {
92 my $filename=shift;
93 my %conf;
94
95 if (-f $filename) {
96 my $admin = new Lock ($filename);
97 if ($admin -> lock(LH_SHARED)) {
98 my $xml = new XML::DOM::Parser -> parsefile ($admin -> filename);
99 $admin -> unlock;
100
101 # write data into the hash
102 #
103 my $forum = $xml -> getElementsByTagName ('Forum',0) -> item (0);
104
105 # View
106 my $forum_view = $forum -> getElementsByTagName ('ForumView', 0) -> item (0);
107 my $thread_view = $forum_view -> getElementsByTagName ('ThreadView', 0) -> item (0);
108 my $show_thread = $thread_view -> getElementsByTagName ('ShowThread', 0) -> item (0);
109 my $show_how = $show_thread -> getElementsByTagName ('*', 0) -> item (0);
110 my $how_name = $show_how -> getTagName;
111 my $message_view = $forum_view -> getElementsByTagName ('MessageView', 0) -> item (0);
112 my $flags = $forum_view -> getElementsByTagName ('Flags', 0) -> item (0);
113 my $quoting = $forum_view -> getElementsByTagName ('Quoting', 0) -> item (0);
114 my $char = $quoting -> getElementsByTagName ('Chars', 0) -> item (0);
115
116 $conf {View} = {
117 threadOpen => $thread_view -> getAttribute ('threadOpen'),
118 countMessages => $thread_view -> getAttribute ('countMessages'),
119 sortThreads => $thread_view -> getAttribute ('sortThreads'),
120 sortMessages => $thread_view -> getAttribute ('sortMessages'),
121 showThread => (($how_name eq 'ShowAll')
122 ? undef
123 : (($how_name eq 'ShowNone')
124 ? 1
125 : ($show_how -> getFirstChild -> getData))),
126 showPreview => $message_view -> getAttribute ('previewON'),
127 showNA => $flags -> getAttribute ('showNA'),
128 showHQ => $flags -> getAttribute ('showHQ'),
129 quoting => $quoting -> getAttribute ('quotingON'),
130 quoteChars => $char?$char -> getFirstChild -> getData:undef
131 };
132
133 my $voting = $forum -> getElementsByTagName ('Voting', 0) -> item (0);
134 $conf {Voting} = {
135 voteLock => $voting -> getAttribute ('voteLock'),
136 Limit => $voting -> getAttribute ('Limit')
137 };
138
139 # Severance
140 $conf {Severance} = get_severance ($forum -> getElementsByTagName ('Severance', 0) -> item (0));
141
142 # Messaging
143 my $messaging = $forum -> getElementsByTagName ('Messaging', 0) -> item (0);
144 my $call_by_user = $messaging -> getElementsByTagName ('CallByUser', 0) -> item (0);
145
146 $conf {Messaging} = {
147 userAnswer => $messaging -> getAttribute ('callUserAnswer'),
148 thread => $messaging -> getAttribute ('callAdminThread'),
149 na => $messaging -> getAttribute ('callAdminNA'),
150 hq => $messaging -> getAttribute ('callAdminHQ'),
151 voting => $messaging -> getAttribute ('callAdminVoting'),
152 archiving => $messaging -> getAttribute ('callAdminArchiving'),
153 byUser => $messaging -> getAttribute ('callUserAnswer'),
154 callByName => [
155 $call_by_user
156 ? map {$_ -> getFirstChild -> getData} $call_by_user -> getElementsByTagName ('Name', 0)
157 : ()
158 ],
159 callByMail => [
160 $call_by_user
161 ? map {$_ -> getFirstChild -> getData} $call_by_user -> getElementsByTagName ('Email', 0)
162 : ()
163 ],
164 callByIP => [
165 $call_by_user
166 ? map {$_ -> getFirstChild -> getData} $call_by_user -> getElementsByTagName ('IpAddress', 0)
167 : ()
168 ]
169 };
170
171 # Instant
172 my $instant = $forum -> getElementsByTagName ('InstantJob', 0) -> item (0);
173 my $job = $instant -> getElementsByTagName ('*',0) -> item (0);
174 my $job_name = $job -> getTagName;
175 $job_name = $job -> getAttribute ('reason') if ($job_name ne 'Severance');
176
177 $conf {Instant} = {
178 execute => $instant -> getAttribute ('executeJob'),
179 description => $job_name,
180 url => (
181 ($job_name ne 'Severance')
182 ? $job -> getElementsByTagName ('FileUrl', 0) -> item (0) -> getFirstChild -> getData
183 : undef
184 ),
185 Severance => (
186 ($job_name eq 'Severance')
187 ? get_severance ($job)
188 : undef
189 )
190 };
191
192 # User
193 my $user = $forum -> getElementsByTagName ('UserManagement', 0) -> item (0);
194
195 $conf {User} = {
196 deleteAfterDays => $user
197 -> getElementsByTagName ('DeleteUser', 0) -> item (0)
198 -> getElementsByTagName ('AfterDays', 0) -> item (0)
199 -> getFirstChild -> getData
200 };
201 }
202 }
203
204 # return
205 \%conf;
206 }
207
208 # keep 'require' happy
209 1;
210
211 #
212 #
213 ### end of Conf::Admin #########################################################

patrick-canterino.de