]> git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Conf/Admin.pm
27a8c936ec7ce45540279e63ee52e5382f054c11
[selfforum.git] / selfforum-cgi / shared / Conf / Admin.pm
1 # Admin.pm
2
3 # ====================================================
4 # Autor: n.d.p. / 2001-01-05
5 # lm : n.d.p. / 2001-02-25
6 # ====================================================
7 # Funktion:
8 # Einlesen der Admindefaultkonfiguration
9 # ====================================================
10
11 use strict;
12
13 package Conf::Admin;
14
15 use vars qw(@EXPORT);
16
17 use Lock qw(:READ);
18
19 use XML::DOM;
20
21 # ====================================================
22 # Funktionsexport
23 # ====================================================
24
25 use base qw(Exporter);
26 @EXPORT = qw(read_admin_conf);
27
28 ################################
29 # sub read_admin_conf
30 #
31 # Default-Admin-Konf. lesen
32 ################################
33
34 sub read_admin_conf ($) {
35 my $filename=shift;
36 my %conf;
37
38 if (-f $filename) { # gibts die Datei ueberhaupt?
39 if (lock_file ($filename)) { # sperren...
40 my $xml = new XML::DOM::Parser -> parsefile ($filename); # ...einlesen und parsen...
41 violent_unlock_file ($filename) unless (unlock_file ($filename)); # ...freigeben
42
43 # =================================
44 # jetzt Daten in den Hash schreiben
45
46 my $forum = $xml -> getElementsByTagName ('Forum',0) -> item (0);
47
48 # View
49 my $forum_view = $forum -> getElementsByTagName ('ForumView', 0) -> item (0);
50 my $thread_view = $forum_view -> getElementsByTagName ('ThreadView', 0) -> item (0);
51 my $show_thread = $thread_view -> getElementsByTagName ('ShowThread', 0) -> item (0);
52 my $show_how = $show_thread -> getElementsByTagName ('*', 0) -> item (0);
53 my $how_name = $show_how -> getTagName;
54 my $message_view = $forum_view -> getElementsByTagName ('MessageView', 0) -> item (0);
55 my $flags = $forum_view -> getElementsByTagName ('Flags', 0) -> item (0);
56 my $quoting = $forum_view -> getElementsByTagName ('Quoting', 0) -> item (0);
57 my $char = $quoting -> getElementsByTagName ('Chars', 0) -> item (0);
58
59 $conf {View} = {threadOpen => $thread_view -> getAttribute ('threadOpen'),
60 countMessages => $thread_view -> getAttribute ('countMessages'),
61 sortThreads => $thread_view -> getAttribute ('sortThreads'),
62 sortMessages => $thread_view -> getAttribute ('sortMessages'),
63 showThread => (($how_name eq 'ShowAll')?undef:
64 (($how_name eq 'ShowNone')?1:
65 ($show_how -> getFirstChild -> getData))),
66 showPreview => $message_view -> getAttribute ('previewON'),
67 showNA => $flags -> getAttribute ('showNA'),
68 showHQ => $flags -> getAttribute ('showHQ'),
69 quoting => $quoting -> getAttribute ('quotingON'),
70 quoteChars => $char?$char -> getFirstChild -> getData:undef};
71
72 my $voting = $forum -> getElementsByTagName ('Voting', 0) -> item (0);
73 $conf {Voting} = {voteLock => $voting -> getAttribute ('voteLock')};
74
75 # Severance
76 $conf {Severance} = &get_severance ($forum -> getElementsByTagName ('Severance', 0) -> item (0));
77
78 # Messaging
79 my $messaging = $forum -> getElementsByTagName ('Messaging', 0) -> item (0);
80 my $call_by_user = $messaging -> getElementsByTagName ('CallByUser', 0) -> item (0);
81
82 $conf {Messaging} = {userAnswer => $messaging -> getAttribute ('callUserAnswer'),
83 thread => $messaging -> getAttribute ('callAdminThread'),
84 na => $messaging -> getAttribute ('callAdminNA'),
85 hq => $messaging -> getAttribute ('callAdminHQ'),
86 voting => $messaging -> getAttribute ('callAdminVoting'),
87 archiving => $messaging -> getAttribute ('callAdminArchiving'),
88 byUser => $messaging -> getAttribute ('callUserAnswer'),
89 callByName => [$call_by_user?map {$_ -> getFirstChild -> getData} $call_by_user -> getElementsByTagName ('Name', 0):()],
90 callByMail => [$call_by_user?map {$_ -> getFirstChild -> getData} $call_by_user -> getElementsByTagName ('Email', 0):()],
91 callByIP => [$call_by_user?map {$_ -> getFirstChild -> getData} $call_by_user -> getElementsByTagName ('IpAddress', 0):()]};
92
93 # Instant
94 my $instant = $forum -> getElementsByTagName ('InstantJob', 0) -> item (0);
95 my $job = $instant -> getElementsByTagName ('*',0) -> item (0);
96 my $job_name = $job -> getTagName;
97 $job_name = $job -> getAttribute ('reason') if ($job_name ne 'Severance');
98
99 $conf {Instant} = {execute => $instant -> getAttribute ('executeJob'),
100 description => $job_name,
101 url => (($job_name ne 'Severance')?$job -> getElementsByTagName ('FileUrl', 0) -> item (0) -> getFirstChild -> getData:undef),
102 Severance => (($job_name eq 'Severance')?&get_severance ($job):undef)};
103
104 # User
105 my $user = $forum -> getElementsByTagName ('UserManagement', 0) -> item (0);
106
107 $conf {User} = {deleteAfterDays => $user -> getElementsByTagName ('DeleteUser', 0) -> item (0)
108 -> getElementsByTagName ('AfterDays', 0) -> item (0)
109 -> getFirstChild -> getData};
110 }
111
112 else {
113 violent_unlock_file ($filename);}}
114
115 # Rueckgabe
116 \%conf;
117 }
118
119 # ====================================================
120 # Private Funktionen
121 # ====================================================
122
123 sub get_severance ($) {
124 my $severance = shift;
125
126 my $after_byte = $severance -> getElementsByTagName ('AfterByte', 0) -> item (0);
127 my $after_message = $severance -> getElementsByTagName ('AfterMessage', 0) -> item (0);
128 my $after_thread = $severance -> getElementsByTagName ('AfterThread', 0) -> item (0);
129 my $last_posting = $severance -> getElementsByTagName ('AfterLastPosting', 0) -> item (0);
130
131 my %conf =( exArchiving => $severance -> getAttribute ('executeArchiving'),
132 archiving => $severance -> getElementsByTagName ('Archiving', 0) -> item (0)
133 -> getElementsByTagName ('*', 0) -> item (0) -> getTagName,
134 severance => $severance -> getAttribute ('executeSeverance'),
135 afterByte => ($after_byte?$after_byte -> getFirstChild -> getData:undef),
136 afterThread => ($after_thread?$after_thread -> getFirstChild -> getData:undef),
137 afterMessage => ($after_message?$after_message -> getFirstChild -> getData:undef),
138 lastPosting => ($last_posting?$last_posting -> getFirstChild -> getData:undef));
139
140 \%conf;
141 }
142
143 # ====================================================
144 # Modulinitialisierung
145 # ====================================================
146
147 # making require happy
148 1;
149
150 # ====================================================
151 # end of Conf::Admin
152 # ====================================================

patrick-canterino.de