Line # Revision Author
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 455 ahitrov # configured
15 $self->{debug} = (lc('@DEBUG@') eq 'yes');
16 $self->{project} = '@PROJECT@';
17 $self->{contenido_notab} = 0;
18 $self->{tab_name} = 'Пользователи';
19
20 196 ahitrov # зашитая конфигурация плагина
21 $self->{db_type} = 'none';
22 $self->{db_keepalive} = 0;
23 $self->{db_host} = '';
24 $self->{db_name} = '';
25 $self->{db_user} = '';
26 $self->{db_password} = '';
27 $self->{db_port} = '';
28 $self->{profile_document_class} = '@PROFILE_DOCUMENT_CLASS@' || 'users::UserProfile';
29 305 ahitrov $self->{use_credentials} = uc('@PROFILE_USE_CREDENTIALS@') eq 'YES' ? 1 : 0;
30 196 ahitrov
31 $self->{data_directory} = '';
32 $self->{images_directory} = '';
33 $self->{binary_directory} = '';
34 $self->{preview} = '';
35 $self->{debug} = '';
36 $self->{store_method} = '';
37 $self->{cascade} = '';
38 $self->{memcached_enable} = '';
39
40 $self->_init_();
41 $self;
42 }
43
44 sub info {
45 my $self = shift;
46 return unless ref $self;
47
48 for (sort keys %{$self->{attributes}}) {
49 my $la = length $_;
50 warn "\t$_".("\t" x (2-int($la/8))).": $self->{$_}\n";
51 }
52 }
53
54 sub _init_ {
55 my $self = shift;
56
57 # зашитая конфигурация плагина
58 $self->{attributes}->{$_} = 'SCALAR' for qw(
59 455 ahitrov debug
60 project
61 tab_name
62
63 196 ahitrov db_type
64 profile_document_class
65 305 ahitrov use_credentials
66 196 ahitrov db_keepalive
67 db_host
68 db_port
69 db_name
70 db_user
71 db_password
72 data_directory images_directory binary_directory preview debug store_method cascade memcached_enable
73 );
74 }
75
76 sub AUTOLOAD {
77 my $self = shift;
78 my $attribute = $AUTOLOAD;
79
80 $attribute =~ s/.*:://;
81 return unless $attribute =~ /[^A-Z]/; # Отключаем методы типа DESTROY
82
83 if (!exists $self->{attributes}->{$attribute}) {
84 warn "Contenido Error (users::State): Вызов метода, для которого не существует обрабатываемого свойства: ->$attribute()\n";
85 return;
86 }
87
88 $self->{$attribute} = shift @_ if $#_>=0;
89 $self->{$attribute};
90 }
91
92 1;