1 |
3 |
ahitrov@rambler.ru |
package SQL::UserTable; |
2 |
|
|
|
3 |
|
|
use strict; |
4 |
|
|
use base 'SQL::ProtoTable'; |
5 |
|
|
use vars qw($available_filters @required_properties); |
6 |
|
|
|
7 |
|
|
sub db_table |
8 |
|
|
{ |
9 |
|
|
return 'users'; |
10 |
|
|
} |
11 |
|
|
|
12 |
|
|
$available_filters = [qw( |
13 |
|
|
_class_filter |
14 |
|
|
_status_filter |
15 |
|
|
_in_id_filter |
16 |
|
|
_id_filter |
17 |
|
|
_name_filter |
18 |
|
|
_class_excludes_filter |
19 |
|
|
_excludes_filter |
20 |
|
|
_datetime_filter |
21 |
|
|
_date_equal_filter |
22 |
|
|
_date_filter |
23 |
|
|
|
24 |
|
|
_groups_filter |
25 |
|
|
_login_filter |
26 |
|
|
)]; |
27 |
|
|
|
28 |
|
|
sub available_filters { |
29 |
|
|
return $available_filters; |
30 |
|
|
} |
31 |
|
|
|
32 |
|
|
# ---------------------------------------------------------------------------- |
33 |
|
|
# �������� ������ � ��������, ������ ��� ������� �����! |
34 |
|
|
# ��� ����� �������� - ���������� ��� ���� ����������. |
35 |
|
|
# |
36 |
|
|
# attr - ������������ ��������, �������� ��������; |
37 |
|
|
# type - ��� ���������, ��������� ��� ������������; |
38 |
|
|
# rusname - ������� ��������, ����� �� ��������� ��� �����������; |
39 |
|
|
# hidden - ����� 1, ����� |
40 |
|
|
# readonly - ������������� ��� ������ ������ ��� ��������� � ���������� |
41 |
|
|
# db_field - ���� � ������� |
42 |
|
|
# default - �������� �� ��������� (���� ������ ����� ��� ��������) |
43 |
|
|
# ---------------------------------------------------------------------------- |
44 |
|
|
@required_properties = ( |
45 |
|
|
{ # ������������� ���������, �������� �� ���� �����... |
46 |
|
|
'attr' => 'id', |
47 |
|
|
'type' => 'integer', |
48 |
|
|
'rusname' => '������������� ���������', |
49 |
|
|
'hidden' => 1, |
50 |
|
|
'auto' => 1, |
51 |
|
|
'readonly' => 1, |
52 |
|
|
'db_field' => 'id', |
53 |
|
|
'db_type' => 'integer', |
54 |
|
|
}, |
55 |
|
|
{ # ������������� ���������, �������� �� ���� �����... |
56 |
|
|
'attr' => 'login', |
57 |
|
|
'type' => 'string', |
58 |
|
|
'rusname' => '�����', |
59 |
|
|
'db_field' => 'login', |
60 |
|
|
'db_type' => 'varchar(255)', |
61 |
|
|
}, |
62 |
|
|
{ # ����� ���������... |
63 |
|
|
'attr' => 'class', |
64 |
|
|
'type' => 'string', |
65 |
|
|
'rusname' => '����� ���������', |
66 |
|
|
'hidden' => 1, |
67 |
|
|
'readonly' => 1, |
68 |
|
|
'db_field' => 'class', |
69 |
|
|
'db_type' => 'varchar(48)', |
70 |
|
|
}, |
71 |
|
|
{ # ��� ���������... |
72 |
|
|
'attr' => 'name', |
73 |
|
|
'type' => 'string', |
74 |
|
|
'rusname' => '���', |
75 |
|
|
'db_field' => 'name', |
76 |
|
|
'db_type' => 'varchar(255)', |
77 |
|
|
}, |
78 |
|
|
{ # ����� �������� ���������, ��������� ����... |
79 |
|
|
'attr' => 'ctime', |
80 |
|
|
'type' => 'datetime', |
81 |
|
|
'rusname' => '����� ��������', |
82 |
|
|
'hidden' => 1, |
83 |
|
|
'auto' => 1, |
84 |
|
|
'readonly' => 1, |
85 |
|
|
'db_field' => 'ctime', |
86 |
|
|
'db_type' => 'timestamp', |
87 |
|
|
'default' => 'CURRENT_TIMESTAMP', |
88 |
|
|
}, |
89 |
|
|
{ # ����� ����������� ���������, ��������� ����... |
90 |
|
|
'attr' => 'mtime', |
91 |
|
|
'type' => 'datetime', |
92 |
|
|
'rusname' => '����� �����������', |
93 |
|
|
'hidden' => 1, |
94 |
|
|
'auto' => 1, |
95 |
|
|
'db_field' => 'mtime', |
96 |
|
|
'db_type' => 'timestamp', |
97 |
|
|
'default' => 'CURRENT_TIMESTAMP', |
98 |
|
|
}, |
99 |
|
|
{ # ���� ���� ������� �������� ����������... |
100 |
|
|
'attr' => 'status', |
101 |
|
|
'type' => 'status', |
102 |
|
|
'rusname' => '������', |
103 |
|
|
'db_field' => 'status', |
104 |
|
|
'db_type' => 'integer', |
105 |
|
|
}, |
106 |
|
|
{ # ������ |
107 |
|
|
'attr' => 'passwd', |
108 |
|
|
'type' => 'string', |
109 |
|
|
'rusname' => '������', |
110 |
|
|
'db_field' => 'passwd', |
111 |
|
|
'db_type' => 'varchar(255)', |
112 |
|
|
}, |
113 |
|
|
{ # ������ |
114 |
|
|
'attr' => 'groups', |
115 |
|
|
'type' => 'array of integer', |
116 |
|
|
'rusname' => '������', |
117 |
|
|
'hidden' => 1, |
118 |
|
|
'db_field' => 'groups', |
119 |
|
|
'db_type' => 'integer[]', |
120 |
|
|
} |
121 |
|
|
); |
122 |
|
|
|
123 |
|
|
sub required_properties { |
124 |
|
|
return @required_properties; |
125 |
|
|
} |
126 |
|
|
|
127 |
|
|
########### FILTERS DESCRIPTION #################################################################################### |
128 |
|
|
sub _login_filter { |
129 |
|
|
my ($self,%opts)=@_; |
130 |
|
|
return undef unless ( exists($opts{login}) ); |
131 |
|
|
return &SQL::Common::_generic_text_filter('d.login', $opts{login}); |
132 |
|
|
} |
133 |
|
|
|
134 |
|
|
sub _groups_filter { |
135 |
|
|
my ($self,%opts)=@_; |
136 |
|
|
return undef unless ( exists($opts{s}) ); |
137 |
|
|
return &SQL::Common::_generic_intarray_filter('d.groups', $opts{s}); |
138 |
|
|
} |
139 |
|
|
|
140 |
|
|
1; |