package users::State; use strict; use warnings 'all'; use vars qw($AUTOLOAD); sub new { my ($proto) = @_; my $class = ref($proto) || $proto; my $self = {}; bless $self, $class; # configured $self->{debug} = (lc('@DEBUG@') eq 'yes'); $self->{project} = '@PROJECT@'; $self->{contenido_notab} = 0; $self->{tab_name} = 'Пользователи'; # зашитая конфигурация плагина $self->{db_type} = 'none'; $self->{db_keepalive} = 0; $self->{db_host} = ''; $self->{db_name} = ''; $self->{db_user} = ''; $self->{db_password} = ''; $self->{db_port} = ''; $self->{profile_document_class} = '@PROFILE_DOCUMENT_CLASS@' || 'users::UserProfile'; $self->{use_credentials} = uc('@PROFILE_USE_CREDENTIALS@') eq 'YES' ? 1 : 0; $self->{data_directory} = ''; $self->{images_directory} = ''; $self->{binary_directory} = ''; $self->{preview} = ''; $self->{debug} = ''; $self->{store_method} = ''; $self->{cascade} = ''; $self->{memcached_enable} = ''; $self->_init_(); $self; } sub info { my $self = shift; return unless ref $self; for (sort keys %{$self->{attributes}}) { my $la = length $_; warn "\t$_".("\t" x (2-int($la/8))).": $self->{$_}\n"; } } sub _init_ { my $self = shift; # зашитая конфигурация плагина $self->{attributes}->{$_} = 'SCALAR' for qw( debug project tab_name db_type profile_document_class use_credentials db_keepalive db_host db_port db_name db_user db_password data_directory images_directory binary_directory preview debug store_method cascade memcached_enable ); } sub AUTOLOAD { my $self = shift; my $attribute = $AUTOLOAD; $attribute =~ s/.*:://; return unless $attribute =~ /[^A-Z]/; # Отключаем методы типа DESTROY if (!exists $self->{attributes}->{$attribute}) { warn "Contenido Error (users::State): Вызов метода, для которого не существует обрабатываемого свойства: ->$attribute()\n"; return; } $self->{$attribute} = shift @_ if $#_>=0; $self->{$attribute}; } 1;