line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- perl -*- |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# $Id: Admin.pm,v 1.31 2005/11/04 00:32:48 eserte Exp $ |
5
|
|
|
|
|
|
|
# Author: Slaven Rezic |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Copyright (C) 2003,2004 Slaven Rezic. All rights reserved. |
8
|
|
|
|
|
|
|
# This package is free software; you can redistribute it and/or |
9
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# Mail: slaven@rezic.de |
12
|
|
|
|
|
|
|
# WWW: http://www.rezic.de/eserte/ |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
package WebEditor::OldController::Admin; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
1875
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
18
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2571
|
|
19
|
|
|
|
|
|
|
$VERSION = sprintf("%d.%02d", q$Revision: 1.31 $ =~ /(\d+)\.(\d+)/); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
package WebEditor::OldController; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub admin { |
24
|
0
|
|
|
0
|
|
|
my $self = shift; |
25
|
0
|
|
|
|
|
|
my $c = $self->C; |
26
|
0
|
|
|
|
|
|
$self->check_login; |
27
|
0
|
0
|
|
|
|
|
if (!param("nohttpheader")) { |
28
|
|
|
|
|
|
|
# XXX find better solution --- do not output HTML here! |
29
|
0
|
|
|
|
|
|
print ""; |
30
|
|
|
|
|
|
|
} |
31
|
0
|
|
|
|
|
|
my $root = $self->Root; |
32
|
0
|
0
|
|
|
|
|
if (!$root->is_allowed([qw/admin useradmin release publish/])) { |
33
|
0
|
|
|
|
|
|
print "Not allowed!"; |
34
|
0
|
|
|
|
|
|
print ""; |
35
|
0
|
|
|
|
|
|
exit; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $msg; |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
param('action', '') if !defined param('action'); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# XXX this block should be generated automatically somehow |
43
|
0
|
0
|
|
|
|
|
if (param('action') eq "makemenu") { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
|
if ($self->can("makemenu")) { |
45
|
0
|
|
|
|
|
|
$self->makemenu; |
46
|
0
|
|
|
|
|
|
$msg = "Menus/Navigation erfolgreich neu gebaut."; # XXX lang |
47
|
|
|
|
|
|
|
} else { |
48
|
0
|
|
|
|
|
|
die "No makemenu method available"; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} elsif (param('action') eq "makehtml") { |
51
|
0
|
|
|
|
|
|
require WebEditor::OldFeatures::MakeOnePageHTML; |
52
|
0
|
|
|
|
|
|
my $lang = param("lang"); |
53
|
0
|
|
|
|
|
|
return WebEditor::OldFeatures::MakeOnePageHTML::makeonepagehtml_send |
54
|
|
|
|
|
|
|
($self, -debug => $c->debug, -lang => $lang); |
55
|
|
|
|
|
|
|
} elsif (param('action') eq "makeps") { |
56
|
|
|
|
|
|
|
# XXX toc etc. should be supplied by form params |
57
|
0
|
|
|
|
|
|
require WebEditor::OldFeatures::MakePS; |
58
|
0
|
|
|
|
|
|
my $lang = param("lang"); |
59
|
0
|
|
|
|
|
|
return WebEditor::OldFeatures::MakePS::makeps_send |
60
|
|
|
|
|
|
|
($self, -debug => $c->debug, -lang => $lang, -toc => 1); |
61
|
|
|
|
|
|
|
} elsif (param('action') eq "makepdf") { |
62
|
|
|
|
|
|
|
# XXX toc etc. should be supplied by form params |
63
|
0
|
|
|
|
|
|
require WebEditor::OldFeatures::MakePDF; |
64
|
0
|
|
|
|
|
|
my $lang = param("lang"); |
65
|
0
|
|
|
|
|
|
return WebEditor::OldFeatures::MakePDF::makepdf_send |
66
|
|
|
|
|
|
|
($self, -debug => $c->debug, -lang => $lang, -toc => 1); |
67
|
|
|
|
|
|
|
} elsif (param('action') eq 'timebasedupdatehtml') { |
68
|
0
|
|
|
|
|
|
return $self->timebasedupdatehtml; |
69
|
|
|
|
|
|
|
} elsif (param('action') eq 'do_timebasedupdatehtml') { |
70
|
0
|
|
|
|
|
|
return $self->do_timebasedupdatehtml; |
71
|
|
|
|
|
|
|
} elsif (param('action') eq 'info') { |
72
|
0
|
|
|
|
|
|
require mixin; mixin::->import("WebEditor::OldFeatures::SystemInfo"); |
|
0
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
print $self->system_info_as_html; |
74
|
|
|
|
|
|
|
} elsif (param('action') eq 'groupadmin') { |
75
|
|
|
|
|
|
|
# XXX automatically load the admingroup mixin if not yet loaded? |
76
|
0
|
|
|
|
|
|
return $self->groupadmin; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
if ($self->can("admin_modules")) { |
80
|
0
|
|
|
|
|
|
$self->admin_modules; # XXX do not supply $c anymore! |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
$self->_tpl("bestwe", "we_admin.tpl.html", { message => $msg }); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub admin_modules { |
87
|
0
|
|
|
0
|
|
|
my $self = shift; |
88
|
|
|
|
|
|
|
#XXX how to access features in WebEditor::OldFeatures cleanly? |
89
|
0
|
0
|
|
|
|
|
if (param('action') eq "htdig") { |
90
|
0
|
|
|
|
|
|
require mixin; |
91
|
0
|
|
|
|
|
|
mixin->import("WebEditor::OldFeatures::AdminHtdig"); |
92
|
0
|
|
|
|
|
|
$self->admin_htdig_module; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
###################################################################### |
97
|
|
|
|
|
|
|
# |
98
|
|
|
|
|
|
|
# publish all released pages |
99
|
|
|
|
|
|
|
# |
100
|
|
|
|
|
|
|
sub publish { |
101
|
0
|
|
|
0
|
|
|
my $self = shift; |
102
|
0
|
|
|
|
|
|
my $root = $self->Root; |
103
|
0
|
|
|
|
|
|
$self->check_login; |
104
|
0
|
0
|
|
|
|
|
if (!$root->is_allowed(["admin","publish"])) { |
105
|
0
|
|
|
|
|
|
die "This function is only allowed for users with admin or publish rights\n"; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
print "Sync Site"; |
109
|
0
|
|
|
|
|
|
print "Copying HTML files to the live server ..."; |
110
|
0
|
|
|
|
|
|
print "\n"; |
111
|
0
|
|
|
|
|
|
my $publish_done; |
112
|
0
|
0
|
|
|
|
|
if (param("simulate")) { |
113
|
0
|
0
|
|
|
|
|
if ($self->can("do_simulate_publish")) { |
114
|
0
|
|
|
|
|
|
$self->do_simulate_publish(-verbose => 2); # XXX make configurable? |
115
|
|
|
|
|
|
|
} else { |
116
|
0
|
|
|
|
|
|
print "Eine Simulation ist nicht möglich... \n"; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
} else { |
119
|
0
|
0
|
|
|
|
|
if ($self->can("do_publish")) { |
120
|
0
|
|
|
|
|
|
$self->do_publish(-verbose => 2); # XXX drop to 1? make configurable? |
121
|
0
|
|
|
|
|
|
$publish_done++; |
122
|
|
|
|
|
|
|
} else { |
123
|
0
|
|
|
|
|
|
my $fe = $self->FE; |
124
|
0
|
0
|
0
|
|
|
|
if (!$fe || !$fe->can("publish")) { |
125
|
0
|
|
|
|
|
|
print "Publishing is not configured, aborting...\n"; |
126
|
|
|
|
|
|
|
} else { |
127
|
0
|
|
|
|
|
|
$fe->publish(-verbose => 2); # XXX drop to 1? |
128
|
0
|
|
|
|
|
|
$publish_done++; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
} |
132
|
0
|
|
|
|
|
|
print "\n"; |
133
|
|
|
|
|
|
|
# print 'Go back'; |
134
|
0
|
|
|
|
|
|
print "\n"; |
135
|
0
|
0
|
0
|
|
|
|
$self->notify("publish") if $publish_done && $self->can("notify"); |
136
|
|
|
|
|
|
|
} #### sub publish END |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub timebasedupdatehtml { |
139
|
0
|
|
|
0
|
|
|
my $self = shift; |
140
|
0
|
|
|
|
|
|
my $root = $self->Root; |
141
|
0
|
|
|
|
|
|
$self->check_login; |
142
|
0
|
0
|
|
|
|
|
if (!$root->is_allowed(["admin","release"])) { |
143
|
0
|
|
|
|
|
|
die "This function is only allowed for users with admin or release rights\n"; |
144
|
|
|
|
|
|
|
} |
145
|
0
|
|
|
|
|
|
$self->_tpl("bestwe", "we_admin_timebasedupdatehtml.tpl.html"); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub do_timebasedupdatehtml { |
149
|
0
|
|
|
0
|
|
|
my $self = shift; |
150
|
0
|
|
|
|
|
|
my $root = $self->Root; |
151
|
0
|
|
|
|
|
|
$self->check_login; |
152
|
0
|
0
|
|
|
|
|
if (!$root->is_allowed(["admin","release"])) { |
153
|
0
|
|
|
|
|
|
die "This function is only allowed for users with admin or release rights\n"; |
154
|
|
|
|
|
|
|
} |
155
|
0
|
|
|
|
|
|
my $date = param("date"); |
156
|
0
|
|
|
|
|
|
require WE::Util::Date; |
157
|
0
|
|
|
|
|
|
my $isodate = WE::Util::Date::epoch2isodate(WE::Util::Date::isodate2epoch(param("date"))); |
158
|
0
|
|
|
|
|
|
my $dir = $isodate; |
159
|
0
|
|
|
|
|
|
$dir =~ s/[^a-zA-Z0-9]/_/g; |
160
|
0
|
|
|
|
|
|
$dir = "/tmp/" . $self->C->project->name . "_$dir"; |
161
|
0
|
|
|
|
|
|
mkdir $dir, 0755; |
162
|
0
|
|
|
|
|
|
mkdir "$dir/html", 0755; |
163
|
0
|
|
|
|
|
|
warn "Update wird für das Datum $isodate in $dir gemacht"; |
164
|
0
|
|
|
|
|
|
$self->updatehtml(-pubhtmldir => $dir, |
165
|
|
|
|
|
|
|
-now => $isodate); |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
###################################################################### |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub linkchecker { |
171
|
0
|
|
|
0
|
|
|
my $self = shift; |
172
|
|
|
|
|
|
|
# no access control... |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
# This is a long-running process without need to access the database: |
175
|
0
|
|
|
|
|
|
$self->Root->disconnect; |
176
|
0
|
|
|
|
|
|
require WE_Frontend::LinkChecker; |
177
|
0
|
|
|
|
|
|
local $WE_Frontend::LinkChecker::VERBOSE = $WE_Frontend::LinkChecker::VERBOSE = 1; |
178
|
0
|
|
|
|
|
|
my $c = $self->C; |
179
|
0
|
|
|
|
|
|
my @urls; |
180
|
0
|
|
|
|
|
|
foreach my $lang (@{ $c->project->sitelanguages }) { |
|
0
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
push @urls, $c->paths->absoluteurl . "/html/$lang/index.html"; |
182
|
|
|
|
|
|
|
} |
183
|
0
|
|
|
|
|
|
my $lc = WE_Frontend::LinkChecker->new |
184
|
|
|
|
|
|
|
(-url => \@urls, |
185
|
|
|
|
|
|
|
# -follow => [$c->paths->absoluteurl], |
186
|
|
|
|
|
|
|
-restrict => [$c->paths->absoluteurl], |
187
|
|
|
|
|
|
|
# -ignore => ['\.php$'], |
188
|
|
|
|
|
|
|
); |
189
|
|
|
|
|
|
|
# print $lc->check_html; |
190
|
0
|
|
|
|
|
|
require Template; |
191
|
0
|
|
|
|
|
|
my $t = Template->new($self->TemplateConf); |
192
|
0
|
|
|
|
|
|
print $lc->check_tt($t, "we_linkchecker_result.tpl.html", |
193
|
|
|
|
|
|
|
$self->TemplateVars); |
194
|
0
|
|
|
|
|
|
exit 0; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
###################################################################### |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub checkreleased { |
200
|
0
|
|
|
0
|
|
|
my $self = shift; |
201
|
0
|
|
|
|
|
|
$self->check_login; |
202
|
0
|
|
|
|
|
|
my $root = $self->Root; |
203
|
0
|
0
|
|
|
|
|
if (!$root->is_allowed(["admin","release"])) { |
204
|
0
|
|
|
|
|
|
die "This function is only allowed for users with admin or release rights\n"; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
my $unreleased_objects = []; |
208
|
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
|
my $objdb = $root->ObjDB; |
210
|
|
|
|
|
|
|
$objdb->walk_preorder |
211
|
|
|
|
|
|
|
($objdb->root_object->Id, sub { |
212
|
0
|
|
|
0
|
|
|
my $objid = shift; |
213
|
0
|
|
|
|
|
|
my $o = $objdb->get_object($objid); |
214
|
0
|
0
|
0
|
|
|
|
if (defined $o->Release_State && $o->Release_State eq 'inactive') { |
215
|
|
|
|
|
|
|
# Skipping inactive folder/document |
216
|
0
|
|
|
|
|
|
$WE::DB::Obj::prune = 1; # cut off subtree |
217
|
0
|
|
|
|
|
|
return; |
218
|
|
|
|
|
|
|
} |
219
|
0
|
0
|
0
|
|
|
|
if ($o->is_doc && (!defined $o->Release_State || $o->Release_State ne 'released')) { |
|
|
|
0
|
|
|
|
|
220
|
0
|
|
|
|
|
|
push @$unreleased_objects, |
221
|
|
|
|
|
|
|
{Title => langstring($o->Title, $self->EditorLang), |
222
|
|
|
|
|
|
|
Id => $o->Id, |
223
|
|
|
|
|
|
|
}; |
224
|
|
|
|
|
|
|
} |
225
|
0
|
|
|
|
|
|
}); |
226
|
|
|
|
|
|
|
|
227
|
0
|
|
|
|
|
|
my $templatevars = $self->TemplateVars; |
228
|
0
|
|
|
|
|
|
$templatevars->{'unreleased'} = $unreleased_objects; |
229
|
0
|
|
|
|
|
|
$self->_tpl("bestwe", "we_check_released.tpl.html"); |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub releasepages { |
234
|
0
|
|
|
0
|
|
|
my $self = shift; |
235
|
0
|
|
|
|
|
|
$self->check_login; |
236
|
0
|
|
|
|
|
|
my $root = $self->Root; |
237
|
0
|
0
|
|
|
|
|
if (!$root->is_allowed("admin")) { |
238
|
0
|
|
|
|
|
|
die "This function is only allowed for users with admin rights\n"; |
239
|
|
|
|
|
|
|
} |
240
|
0
|
|
|
|
|
|
my $released_objects = []; |
241
|
0
|
|
|
|
|
|
my $unreleased_objects = []; |
242
|
0
|
|
|
|
|
|
my $objdb = $root->ObjDB; |
243
|
|
|
|
|
|
|
$objdb->connect_if_necessary(sub { |
244
|
0
|
|
|
0
|
|
|
for my $id (param("pageid")) { |
245
|
0
|
|
|
|
|
|
my $obj = $objdb->get_object($id); |
246
|
0
|
0
|
|
|
|
|
if (!$obj) { |
247
|
0
|
|
|
|
|
|
warn "Object with id $id unavailable for release.\n"; |
248
|
0
|
|
|
|
|
|
push @$unreleased_objects, {Id => $id}; |
249
|
0
|
|
|
|
|
|
next; |
250
|
|
|
|
|
|
|
} |
251
|
0
|
|
|
|
|
|
my $descr = {Title => langstring($obj->Title, $self->EditorLang), |
252
|
|
|
|
|
|
|
Id => $obj->Id}; |
253
|
0
|
|
|
|
|
|
$root->release_page($obj); |
254
|
0
|
|
|
|
|
|
push @$released_objects, $descr; |
255
|
|
|
|
|
|
|
} |
256
|
0
|
|
|
|
|
|
}); |
257
|
|
|
|
|
|
|
|
258
|
0
|
|
|
|
|
|
my $templatevars = $self->TemplateVars; |
259
|
0
|
|
|
|
|
|
$templatevars->{'released'} = $released_objects; |
260
|
0
|
|
|
|
|
|
$templatevars->{'unreleased'} = $unreleased_objects; |
261
|
0
|
|
|
|
|
|
$self->_tpl("bestwe", "we_release_result.tpl.html"); |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
###################################################################### |
265
|
|
|
|
|
|
|
# |
266
|
|
|
|
|
|
|
# Simple User Management Interface SUMI |
267
|
|
|
|
|
|
|
# |
268
|
|
|
|
|
|
|
# XXX use ->msg! |
269
|
|
|
|
|
|
|
sub useradmin { |
270
|
0
|
|
|
0
|
|
|
my $self = shift; |
271
|
|
|
|
|
|
|
# XXX problem: if root changes his own password... |
272
|
0
|
|
|
|
|
|
$self->check_login; |
273
|
0
|
|
|
|
|
|
my $root = $self->Root; |
274
|
0
|
0
|
|
|
|
|
if (!$root->is_allowed(["admin","useradmin"])) { |
275
|
0
|
|
|
|
|
|
print "Not allowed! Back to admin page"; |
276
|
0
|
|
|
|
|
|
exit; |
277
|
|
|
|
|
|
|
} |
278
|
0
|
|
|
|
|
|
my $c = $self->C; |
279
|
0
|
|
|
|
|
|
my $templatevars = $self->TemplateVars; |
280
|
|
|
|
|
|
|
|
281
|
0
|
|
|
|
|
|
my $u; |
282
|
0
|
|
0
|
|
|
|
my $useradmindb = param('useradmindb') || ''; |
283
|
0
|
|
|
|
|
|
my $userdb_prop; |
284
|
0
|
0
|
|
|
|
|
if ($useradmindb eq '') { |
285
|
0
|
|
|
|
|
|
$u = $root->UserDB; |
286
|
0
|
0
|
|
|
|
|
if ($root->can('get_userdb_prop')) { |
287
|
0
|
|
|
|
|
|
$userdb_prop = $root->get_userdb_prop(""); |
288
|
|
|
|
|
|
|
} |
289
|
|
|
|
|
|
|
} else { |
290
|
0
|
|
|
|
|
|
$u = $self->get_custom_userdb($useradmindb); |
291
|
|
|
|
|
|
|
} |
292
|
0
|
0
|
|
|
|
|
if (!$u) { |
293
|
0
|
|
|
|
|
|
$self->error("No userdb for $useradmindb defined"); |
294
|
|
|
|
|
|
|
} |
295
|
|
|
|
|
|
|
|
296
|
0
|
|
|
|
|
|
my $message; |
297
|
0
|
|
|
|
|
|
my $useradminaction = param('useradminaction'); |
298
|
0
|
|
|
|
|
|
my $useradminuser = param('useradminuser'); |
299
|
0
|
|
|
|
|
|
my $useradminname = param('useradminname'); |
300
|
0
|
|
|
|
|
|
my $useradmingroups = param('useradmingroups'); |
301
|
0
|
|
|
|
|
|
my $useradmindeluser = param('useradmindeluser'); |
302
|
0
|
|
|
|
|
|
my $useradminpassword1 = param('useradminpassword1'); |
303
|
0
|
|
|
|
|
|
my $useradminpassword2 = param('useradminpassword2'); |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
my $extra_userinfo_update = sub { |
306
|
0
|
0
|
|
0
|
|
|
if ($c->project->features->{wwwauth}) { |
307
|
|
|
|
|
|
|
# XXX passing -userdb not necessary anymore? |
308
|
0
|
0
|
0
|
|
|
|
$self->update_auth_files(-verbose => 0, -userdb => $u) |
309
|
|
|
|
|
|
|
if $useradmindb && $self->can("update_auth_files"); |
310
|
|
|
|
|
|
|
} |
311
|
0
|
|
|
|
|
|
}; |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
my $userinfo_update = sub { |
314
|
0
|
|
|
0
|
|
|
my %new; |
315
|
0
|
|
|
|
|
|
foreach my $key (param()) { |
316
|
0
|
0
|
|
|
|
|
next unless $key =~ /^useradminuser_(.*)/; |
317
|
0
|
|
|
|
|
|
my $fieldkey = $1; |
318
|
0
|
|
|
|
|
|
my $val = param($key); |
319
|
0
|
|
|
|
|
|
$new{$fieldkey} = $val; |
320
|
|
|
|
|
|
|
} |
321
|
0
|
0
|
|
|
|
|
if (keys %new) { |
322
|
0
|
|
|
|
|
|
my $userobj = $u->get_user_object($useradminuser); |
323
|
0
|
|
|
|
|
|
@{$userobj}{keys %new} = values %new; |
|
0
|
|
|
|
|
|
|
324
|
0
|
|
|
|
|
|
$u->set_user_object($useradminuser, $userobj); |
325
|
|
|
|
|
|
|
} |
326
|
|
|
|
|
|
|
|
327
|
0
|
|
|
|
|
|
$extra_userinfo_update->(); |
328
|
0
|
|
|
|
|
|
}; |
329
|
|
|
|
|
|
|
|
330
|
0
|
0
|
|
|
|
|
$useradminaction = "" if !defined $useradminaction; |
331
|
|
|
|
|
|
|
|
332
|
0
|
0
|
|
|
|
|
if ($useradminaction eq "adduser") { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
333
|
0
|
0
|
0
|
|
|
|
if ($useradminuser =~ /^\s*$/ || ($useradminpassword1 =~ /^\s*$/ && param("useradminuser_AuthType") ne "POP3")) { |
|
|
0
|
0
|
|
|
|
|
334
|
0
|
|
|
|
|
|
$message = "Error: no user or password given!"; |
335
|
|
|
|
|
|
|
} elsif ($useradminpassword1 ne $useradminpassword2) { |
336
|
0
|
|
|
|
|
|
$message = "Error: two different passwords!"; |
337
|
|
|
|
|
|
|
} else { |
338
|
0
|
0
|
|
|
|
|
if ($u->add_user($useradminuser, $useradminpassword1, $useradminname)) { |
339
|
0
|
|
|
|
|
|
foreach my $grp ( split(/\#/,$useradmingroups) ) { |
340
|
0
|
|
|
|
|
|
$u->add_group($useradminuser,$grp); |
341
|
|
|
|
|
|
|
} |
342
|
0
|
|
|
|
|
|
$userinfo_update->(); |
343
|
0
|
|
|
|
|
|
$message = "User $useradminuser successfully added."; |
344
|
|
|
|
|
|
|
} else { |
345
|
0
|
|
|
|
|
|
$message = "Could not add user $useradminuser"; |
346
|
|
|
|
|
|
|
} |
347
|
|
|
|
|
|
|
} |
348
|
|
|
|
|
|
|
} elsif ($useradminaction eq "upduser") { |
349
|
0
|
0
|
|
|
|
|
if ($useradminpassword1 ne $useradminpassword2) { |
350
|
0
|
|
|
|
|
|
$message = "Error: two different passwords!"; |
351
|
|
|
|
|
|
|
} else { |
352
|
0
|
0
|
|
|
|
|
if ($useradminpassword1 eq '') { |
353
|
0
|
|
|
|
|
|
undef $useradminpassword1; |
354
|
|
|
|
|
|
|
} |
355
|
0
|
0
|
|
|
|
|
if ($u->update_user($useradminuser,$useradminpassword1,$useradminname)) { |
356
|
0
|
|
|
|
|
|
$u->set_groups($useradminuser, split(/\#/,$useradmingroups)); |
357
|
0
|
|
|
|
|
|
$userinfo_update->(); |
358
|
0
|
|
|
|
|
|
$message = "User $useradminuser successfully updatded."; |
359
|
0
|
|
|
|
|
|
my $userobj; |
360
|
0
|
0
|
|
|
|
|
if ($userobj = $u->get_user($useradminuser)) { |
361
|
0
|
|
|
|
|
|
$message = "Updated user information."; |
362
|
0
|
|
|
|
|
|
$templatevars->{'user'} = $userobj; |
363
|
|
|
|
|
|
|
} |
364
|
|
|
|
|
|
|
} else { |
365
|
0
|
|
|
|
|
|
$message = "Could nt update user $useradminuser"; |
366
|
|
|
|
|
|
|
} |
367
|
|
|
|
|
|
|
} |
368
|
|
|
|
|
|
|
} elsif ($useradminaction eq "deluser") { |
369
|
0
|
0
|
|
|
|
|
if ($u->delete_user($useradmindeluser)) { |
370
|
0
|
|
|
|
|
|
$extra_userinfo_update->(); |
371
|
0
|
|
|
|
|
|
$message = "User $useradmindeluser successfully deleted."; |
372
|
|
|
|
|
|
|
} else { |
373
|
0
|
|
|
|
|
|
$message = "Could not delete user $useradmindeluser"; |
374
|
|
|
|
|
|
|
} |
375
|
|
|
|
|
|
|
} elsif ($useradminaction eq "edituser") { |
376
|
0
|
|
|
|
|
|
my $userobj; |
377
|
0
|
0
|
|
|
|
|
if ($userobj = $u->get_user($useradminuser)) { |
378
|
0
|
|
|
|
|
|
$message = "Please edit user $useradminuser. Leave the password empty to keep the old password."; |
379
|
0
|
|
|
|
|
|
$templatevars->{'user'} = $userobj; |
380
|
|
|
|
|
|
|
} else { |
381
|
0
|
|
|
|
|
|
$message = "Could not get user data for $useradminuser"; |
382
|
|
|
|
|
|
|
} |
383
|
|
|
|
|
|
|
} else { # newuser |
384
|
0
|
|
|
|
|
|
$message = "Please edit new user."; |
385
|
|
|
|
|
|
|
} |
386
|
0
|
|
|
|
|
|
my @allusers = $u->get_all_users(); |
387
|
0
|
|
|
|
|
|
@allusers = sort @allusers; |
388
|
0
|
|
|
|
|
|
my @allgroups = ($userdb_prop && $userdb_prop->allgroups |
389
|
0
|
0
|
0
|
|
|
|
? @{ $userdb_prop->allgroups } |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
390
|
|
|
|
|
|
|
: ($root->can("get_all_groups") |
391
|
|
|
|
|
|
|
? $root->get_all_groups |
392
|
|
|
|
|
|
|
: ($u->can("get_all_groups") |
393
|
|
|
|
|
|
|
? $u->get_all_groups |
394
|
|
|
|
|
|
|
: () |
395
|
|
|
|
|
|
|
) |
396
|
|
|
|
|
|
|
) |
397
|
|
|
|
|
|
|
); |
398
|
0
|
|
|
|
|
|
@allgroups = sort @allgroups; |
399
|
0
|
|
|
|
|
|
$templatevars->{'allgroups'} = \@allgroups; |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
# process Template |
402
|
0
|
|
|
|
|
|
$templatevars->{'allusers'} = \@allusers; |
403
|
0
|
|
|
|
|
|
$templatevars->{'useradmindb'} = $useradmindb; |
404
|
0
|
|
|
|
|
|
$templatevars->{'message'} = $message; |
405
|
0
|
0
|
|
|
|
|
$templatevars->{'headline'} = $self->msg($useradmindb eq 'wwwuser' ? "cap_webuseradmin" : "cap_useradmin"); |
406
|
0
|
0
|
|
|
|
|
if ($c->project->features->{groupadmin}) { |
407
|
0
|
0
|
|
|
|
|
$templatevars->{'groupadminbutton'} = $self->msg($useradmindb eq 'wwwuser' ? "cap_webgroupadmin" : "cap_groupadmin"); |
408
|
|
|
|
|
|
|
} |
409
|
0
|
|
|
|
|
|
$self->_tpl("bestwe", "we_useradmin.tpl.html"); |
410
|
|
|
|
|
|
|
} |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
1; |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
__END__ |