1 |
196 |
ahitrov |
package users::State; |
2 |
|
|
|
3 |
|
|
use strict; |
4 |
|
|
use warnings 'all'; |
5 |
|
|
use vars qw($AUTOLOAD); |
6 |
|
|
|
7 |
|
|
|
8 |
|
|
sub new { |
9 |
|
|
my ($proto) = @_; |
10 |
|
|
my $class = ref($proto) || $proto; |
11 |
|
|
my $self = {}; |
12 |
|
|
bless $self, $class; |
13 |
|
|
|
14 |
|
|
# зашитая конфигурация плагина |
15 |
|
|
$self->{db_type} = 'none'; |
16 |
|
|
$self->{db_keepalive} = 0; |
17 |
|
|
$self->{db_host} = ''; |
18 |
|
|
$self->{db_name} = ''; |
19 |
|
|
$self->{db_user} = ''; |
20 |
|
|
$self->{db_password} = ''; |
21 |
|
|
$self->{db_port} = ''; |
22 |
|
|
$self->{profile_document_class} = '@PROFILE_DOCUMENT_CLASS@' || 'users::UserProfile'; |
23 |
|
|
|
24 |
|
|
$self->{data_directory} = ''; |
25 |
|
|
$self->{images_directory} = ''; |
26 |
|
|
$self->{binary_directory} = ''; |
27 |
|
|
$self->{preview} = ''; |
28 |
|
|
$self->{debug} = ''; |
29 |
|
|
$self->{store_method} = ''; |
30 |
|
|
$self->{cascade} = ''; |
31 |
|
|
$self->{memcached_enable} = ''; |
32 |
|
|
|
33 |
|
|
$self->_init_(); |
34 |
|
|
$self; |
35 |
|
|
} |
36 |
|
|
|
37 |
|
|
sub info { |
38 |
|
|
my $self = shift; |
39 |
|
|
return unless ref $self; |
40 |
|
|
|
41 |
|
|
for (sort keys %{$self->{attributes}}) { |
42 |
|
|
my $la = length $_; |
43 |
|
|
warn "\t$_".("\t" x (2-int($la/8))).": $self->{$_}\n"; |
44 |
|
|
} |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
sub _init_ { |
48 |
|
|
my $self = shift; |
49 |
|
|
|
50 |
|
|
# зашитая конфигурация плагина |
51 |
|
|
$self->{attributes}->{$_} = 'SCALAR' for qw( |
52 |
|
|
db_type |
53 |
|
|
profile_document_class |
54 |
|
|
db_keepalive |
55 |
|
|
db_host |
56 |
|
|
db_port |
57 |
|
|
db_name |
58 |
|
|
db_user |
59 |
|
|
db_password |
60 |
|
|
data_directory images_directory binary_directory preview debug store_method cascade memcached_enable |
61 |
|
|
); |
62 |
|
|
} |
63 |
|
|
|
64 |
|
|
sub AUTOLOAD { |
65 |
|
|
my $self = shift; |
66 |
|
|
my $attribute = $AUTOLOAD; |
67 |
|
|
|
68 |
|
|
$attribute =~ s/.*:://; |
69 |
|
|
return unless $attribute =~ /[^A-Z]/; # Отключаем методы типа DESTROY |
70 |
|
|
|
71 |
|
|
if (!exists $self->{attributes}->{$attribute}) { |
72 |
|
|
warn "Contenido Error (users::State): Вызов метода, для которого не существует обрабатываемого свойства: ->$attribute()\n"; |
73 |
|
|
return; |
74 |
|
|
} |
75 |
|
|
|
76 |
|
|
$self->{$attribute} = shift @_ if $#_>=0; |
77 |
|
|
$self->{$attribute}; |
78 |
|
|
} |
79 |
|
|
|
80 |
|
|
1; |