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

patrick-canterino.de