1 |
8 |
ahitrov@rambler.ru |
<%args> |
2 |
|
|
$id => undef |
3 |
|
|
$login => undef |
4 |
|
|
$ret => undef |
5 |
|
|
|
6 |
|
|
$delete => undef |
7 |
|
|
$save => undef |
8 |
|
|
|
9 |
|
|
$class => undef |
10 |
|
|
</%args> |
11 |
|
|
<%init> |
12 |
|
|
unless ($user->check_group(1)) { |
13 |
|
|
$m->clear_buffer; |
14 |
|
|
$m->abort(403); |
15 |
|
|
} |
16 |
|
|
|
17 |
|
|
my $luser; |
18 |
|
|
|
19 |
|
|
# Проверка заданности класса - он должен быть задан явно... |
20 |
|
|
if ($class) |
21 |
|
|
{ |
22 |
|
|
my @correct_classes = (@{ $state->{available_users} }, 'Contenido::User'); |
23 |
|
|
if (! (grep { $_ eq $class } @correct_classes)) |
24 |
|
|
{ |
25 |
|
|
# Класс задан, но он не корректный |
26 |
|
|
$class = undef; |
27 |
|
|
} |
28 |
|
|
} |
29 |
|
|
|
30 |
|
|
if ($id && ($id>0)) { |
31 |
|
|
$luser = $keeper->get_user_by_id($id, class=>$class); |
32 |
|
|
} elsif ($login && (length $login > 0)) { |
33 |
|
|
$luser = $keeper->get_user_by_login($login, class=>$class); |
34 |
|
|
} |
35 |
|
|
|
36 |
|
|
if ($class and !ref($luser)) { |
37 |
|
|
$luser = $class->new($keeper); |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
# Удаление... |
41 |
|
|
if (ref $luser && $delete == 1) |
42 |
|
|
{ |
43 |
|
|
$luser->delete(); |
44 |
|
|
|
45 |
|
|
$r->header_out("Location", "/contenido/?set_context=profile-admin"); |
46 |
|
|
$r->status(302); |
47 |
|
|
$r->send_http_header(); |
48 |
|
|
$m->abort(); |
49 |
|
|
} |
50 |
|
|
|
51 |
|
|
# Сохранение ... |
52 |
|
|
elsif (ref $luser && $save == 1) |
53 |
|
|
{ |
54 |
|
|
my @groups = $luser->groups(); |
55 |
|
|
my $res = $m->comp('/contenido/components/set_properties.msn', object => $luser, SETS => \%ARGS); |
56 |
|
|
if ($res != 1) |
57 |
|
|
{ |
58 |
|
|
# Ошибка, надо бы обработать... |
59 |
|
|
warn "Contenido Debug: set_properties.msn вернул $res\n" if ($state->debug()); |
60 |
|
|
} |
61 |
|
|
$luser->groups(@groups); |
62 |
|
|
$luser->store(); |
63 |
|
|
|
64 |
|
|
$r->header_out("Location", "users.html?id=".$luser->id()."&class=$class"); |
65 |
|
|
$r->status(302); |
66 |
|
|
$r->send_http_header(); |
67 |
|
|
$m->abort(); |
68 |
|
|
} |
69 |
|
|
|
70 |
|
|
</%init> |
71 |
|
|
|
72 |
|
|
|
73 |
|
|
<& "/contenido/components/header.msn" &> |
74 |
|
|
|
75 |
|
|
<& "/contenido/components/naviline.msn" &> |
76 |
|
|
|
77 |
|
|
% if ((!defined $luser || !$luser->login) && (!defined $class || !$class)) |
78 |
|
|
% { |
79 |
|
|
% if (!defined $class || !$class) { |
80 |
|
|
<!-- Блок с выбором нового пользователя для создания --> |
81 |
|
|
<table width="50%" border="0"> |
82 |
|
|
<tr> |
83 |
|
|
<td> |
84 |
|
|
<fieldset> |
85 |
|
|
<legend>Выберите тип пользователя для создания</legend> |
86 |
|
|
<& "/contenido/components/new_objects_form.msn", proto => 'users' &> |
87 |
|
|
</fieldset> |
88 |
|
|
</td> |
89 |
|
|
</tr> |
90 |
|
|
</table> |
91 |
|
|
% } |
92 |
|
|
% } elsif (ref $luser) { |
93 |
|
|
<& "/contenido/components/obj_list_js.msn", object => $luser &> |
94 |
|
|
<& "/contenido/components/object_form.msn", object => $luser, proto => 'users' &> |
95 |
|
|
% if ($luser->login) { |
96 |
|
|
<!-- Доступ к секциям --> |
97 |
|
|
<br> |
98 |
|
|
<table width="100%" cellspacing="5" cellpadding="0" border="0"> |
99 |
|
|
<tr> |
100 |
|
|
<td valign=top><& "/contenido/components/user_sections.msn", luser => $luser &></td> |
101 |
|
|
</tr> |
102 |
|
|
</table> |
103 |
|
|
<!-- / Доступ к секциям --> |
104 |
|
|
% } |
105 |
|
|
% } |
106 |
|
|
|
107 |
|
|
</body> |
108 |
|
|
</html> |