Repository navigation
Expand file tree
/
Copy pathWebApplication.pm
More file actions
1863 lines (1361 loc) · 45 KB
/
Copy pathWebApplication.pm
File metadata and controls
1863 lines (1361 loc) · 45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package WebApplication;
# WebApplication - framework to develop application-like web sites
use strict;
use warnings;
use FreezeThaw qw( freeze thaw );
use CGI;
use CGI::Cookie;
use HTML::Strip;
use DBMaster;
use Scalar::Util qw/reftype/;
# include default WebPages
use WebMenu;
use WebConfig;
use WebPage::Error;
use WebApplicationDBHandle;
use Conf;
1;
=pod
=head1 WebApplication
=head2 DESCRIPTION
The WebApplication is a framework to support fast, comprehesible and componentalized
creation of applications on the web. Main features include:
=over 4
=item * menus
=item * user authentication
=item * page oriented structure
=item * session management
=item * action management
=item * reusable components
=back
For setup and usage, please refer to the WebApplication Tutorial.
=head2 METHODS
=head3 B<new> ($params)
B<Returns:> a reference to a WebApplication object
Creates a new instance of the WebApplication object.
$params is a hash which supports the following values:
=over 4
=item dbmaster
An instance of the PPO DBMaster which points to the user database.
If this parameter is omitted, a dbmaster will be created with the following settings in
WebConfig, located in FIGdisk/config/WebApplication/$appname.cfg:
=over 8
=item * DBNAME
=item * DBHOST
=item * DBUSER
=item * DBPWD
=back
If the configuration file is not present, these values will default to the ones set in
WebConfig
=item menu
An instance of WebMenu which will represent the current structure of the navigation menu.
If this is omitted it will default to an empty menu.
=item default
The name of the page to be displayed when no $cgi->param('page') is present.
=item layout
An instance of WebLayout which represents the layout of the page.
=item id
A string representing the name of the application. This is used to identify the application
in the database. If this does not yet exist in the database, it will be created.
=item cgi
An instance of the CGI object. If omitted, this will default to CGI->new()
=item noTrace
If TRUE, tracing will not be activated. This is useful when you want to activate
tracing before constructing the WebApplication object.
=back
=cut
sub new {
my ($class, $params) = @_;
my $dbmaster = $params->{'dbmaster'};
my $menu = $params->{'menu'} || WebMenu->new();
my $default = $params->{'default'};
my $layout = $params->{'layout'};
my $backend_name = $params->{'id'};
my $cgi = $params->{'cgi'} || CGI->new();
my $hs = HTML::Strip->new();
my @cgi_params = $cgi->param;
foreach my $p (@cgi_params) {
my @plist = $cgi->param($p);
foreach my $p1 (@plist) {
if ($p1 && reftype($p1) eq "") {
$p1 = $hs->parse($p1);
}
}
$cgi->param($p, @plist);
}
$hs->eof;
my $self = { cgi => $cgi,
menu => $menu,
menu_backup => freeze($menu),
layout => $layout,
backend => undef,
page => undef,
default => $default,
error => undef,
redirect => undef,
show_login_user_info => 0,
fancy_login => 0,
messages => {},
components => {},
component_index => {},
data_handlers => {},
actions => {},
time => time,
page_title_prefix => '',
test_bot => $cgi->param('test_bot') || 0,
no_bot => 0,
bot_no_follow => 0,
metatags => [],
strict_browser => 0,
anonymous_mode => $Conf::anonymous_mode || 0,
transmitted => 0,
require_terms_of_service => $Conf::require_terms_of_service || 0,
in_request => 0,
js_init_functions => [],
};
bless $self, $class;
# Generate an event if we're tracking this user.
# read in local configuration into global WebConfig
&WebConfig::import_local_config($backend_name);
# create a dbmaster
unless (defined($dbmaster) || $WebConfig::NODB) {
my $error;
($dbmaster, $error) = WebApplicationDBHandle->new();
if ($error) {
print STDERR $@;
}
}
$self->{dbmaster} = $dbmaster;
if ($dbmaster && !$self->anonymous_mode()) {
$self->{session} = $dbmaster->UserSession->create($cgi);
# check if application is registered
my $backend = $dbmaster->Backend->init({ 'name' => $backend_name });
if (ref $backend and $backend->isa('WebServerBackend::Backend')) {
$self->{'backend'} = $backend;
}
else {
$self->{'backend'} = $dbmaster->Backend->create({ 'name' => $backend_name });
}
unless ($self->backend) {
}
} else {
# create a backend stub
my $backend = Backend->new( $backend_name );
{
package Backend;
sub new {
my $self = { name => $_[1] };
bless $self, 'Backend';
}
sub name {
return $_[0]->{name};
}
sub init {
return undef;
}
}
$self->{backend} = $backend;
# create a session stub
my $session = UserSession->new();
{
package UserSession;
sub new {
my $self = { user => undef };
bless $self, 'UserSession';
}
sub add_entry { return undef; }
sub get_entry { return undef; }
sub user { return $_[0]->{user}; }
sub cookie {
my ($self) = @_;
my $uname = '0';
if (defined($self->user)) {
$uname = $self->user->login;
}
return CGI::Cookie->new( -name => 'AnonWebSession',
-value => $uname,
-expires => '+2h' );
}
}
$self->{session} = $session;
}
return $self;
}
#******************************************************************************
#* ACCESSOR METHODS
#******************************************************************************
=pod
=head3 B<default> ()
B<Returns:> a scalar string
Getter for the default attribute. The default attribute determines the initial page
to be displayed if no $cgi->param('page') is given.
=cut
sub default {
return $_[0]->{default};
}
=pod
=head3 B<dbmaster> ()
B<Returns:> a reference to a DBMaster object
Getter for the dbmaster attribute. See above description for details.
=cut
sub dbmaster {
return $_[0]->{dbmaster};
}
=pod
=head3 B<session> ()
B<Returns:> a reference to a WebServerBackend::Session object
Getter for the session attribute. This is an instance of the Session object, which
stores the current user and a history of three last visited pages.
=cut
sub session {
return $_[0]->{session};
}
=pod
=head3 B<cgi> ()
B<Returns:> a reference to a CGI object
Getter for the cgi attribute. This the instance of the CGI object used throughout the
WebApplication.
=cut
sub cgi {
my ($self, $cgi) = @_;
if (defined($cgi)) {
$self->{cgi} = $cgi;
}
return $self->{cgi};
}
=pod
=head3 B<menu> ()
B<Returns:> a reference to a WebMenu object
Getter for the menu attribute. This is an instance of the WebMenu object which stores
the structure of the menu.
=cut
sub menu {
return $_[0]->{menu};
}
=pod
=head3 B<layout> ()
B<Returns:> a reference to a WebLayout object
Getter for the layout attribute. This is an instance of the WebLayout object which
stores required javascript, css and the html template.
=cut
sub layout {
return $_[0]->{layout};
}
=pod
=head3 B<backend> ()
B<Returns:> a reference to a WebServerBackend object
Getter for the backend attribute. This is an instance of the WebServerBackend object
which is used to identify the current application.
=cut
sub backend {
return $_[0]->{'backend'};
}
=pod
=head3 B<url> (I<url>)
B<Returns:> a scalar string
Getter / setter for the url attribute. This will return the name of the cgi script of
this application (e.g. index.cgi).
=cut
sub url {
my ($self, $url) = @_;
if (defined($url)) {
$self->{url} = $url;
}
unless (defined($self->{url})) {
my $cgi = $_[0]->{'cgi'};
$url = $cgi->url(-relative=>1);
$url =~ s/\.cgi.*$/\.cgi/;
$self->{url} = $url
}
return $self->{url};
}
=pod
=head3 B<error> (I<error>)
B<Returns:> a scalar string
Getter / setter for the current error status. If the optional parameter I<error> is
given, the error status is stored in the application. Setting this parameter will cause
the application to not display the current page, but an error page stating this
error message instead.
=cut
sub error {
my ($self, $message) = @_;
if (defined $message) {
$self->{error} = $message;
}
return $self->{error};
}
=pod
=head3 B<page> (I<page>)
B<Returns:> a reference to a WebPage object
Returns a reference to the current WebPage object. If the optional parameter I<page> is
given, the page object is stored in the application.
=cut
sub page {
if ($_[1]) {
$_[0]->{'page'} = $_[1];
}
return $_[0]->{'page'};
}
=pod
=head3 B<show_login_user_info> (I<BOOL>)
B<Returns:> a scalar boolean
Get/set the flag if the login box should be inserted into the user info template. The
default value is false.
=cut
sub show_login_user_info {
if (scalar(@_) > 1) {
$_[0]->{show_login_user_info} = $_[1];
}
return $_[0]->{show_login_user_info};
}
=pod
=head3 B<fancy_login> (I<BOOL>)
B<Returns:> a scalar boolean
Get/set the flag if the fancy login box should be inserted into the user info template. The
default value is false.
=cut
sub fancy_login {
if (scalar(@_) > 1) {
$_[0]->{fancy_login} = $_[1];
}
return $_[0]->{fancy_login};
}
=pod
=head3 B<rights> ()
B<Returns:> a reference to an array of Right objects
Returns a reference to an array of Rights objects this application supports.
=cut
sub rights {
my ($self) = @_;
# check if the rights have been loaded
unless (defined($self->{'rights'})) {
# set the rights
{
no strict;
my $rights_method = $self->backend->name()."::MyAppRights::rights()";
my $rights_module = "require " .$self->backend->name()."::MyAppRights;";
eval($rights_module);
$self->{'rights'} = eval($rights_method);
}
}
return $self->{'rights'};
}
#******************************************************************************
#* WEB COMPONENTS
#******************************************************************************
=pod
=head3 B<register_component> (I<component_name>, I<identifier>)
B<Returns:> a reference to a WebComponent object
Register a web component of the name I<component_name> where I<component_name>
is a module in the WebComponent directory. Web components are re-usable html
blocks to include into web pages like default dialogs, tables, charts and so on.
This method returns a reference to a WebComponent object.
I<identifier> is a unique name which is used to later reference that component.
=cut
sub register_component {
my ($self, $component, $id) = @_;
# require web component
$component = 'WebComponent::'.$component;
{
no strict;
eval "require $component;";
}
# init internal component cache if necessary
unless ($self->{'components'}->{$component}) {
$self->{'components'}->{$component} = [];
}
# check for singleton
my $web_component;
if (scalar(@{$self->{'components'}->{$component}}) && $self->{'components'}->{$component}->[0]->{singleton}) {
# get the existing component
$web_component = $self->{'components'}->{$component}->[0];
} else {
# init new web component
$web_component = $component->new($self, scalar(@{$self->{'components'}->{$component}}), $component);
$web_component->{_id} = $id;
push @{$self->{'components'}->{$component}}, $web_component;
}
# update index
$self->{'component_index'}->{$id} = $web_component;
return $web_component;
}
=pod
=head3 B<component> (I<identifier>)
B<Returns:> a reference to a WebComponent object
Retrieve the web component registered with the unique name I<identifier> from
the component repository of the WebApplication. The method confesses if called
with an unknown identifier.
=cut
sub component {
my ($self, $id) = @_;
unless ($self->{'component_index'}->{$id}) {
return undef;
}
return $self->{'component_index'}->{$id};
}
#******************************************************************************
#* DATA HANDLING
#******************************************************************************
=pod
=head3 B<data_handle> (I<type>, I<options>)
B<Returns:> a reference to an object
Request the DataHandler of the given type I<type>. Some DataHandlers may accept
additional parameters, those can be passed by providing the optional parameter
I<options>.
=cut
sub data_handle {
my ($self, $type, $options) = @_;
# get from internal data cache if possible
unless ($self->{'data_handlers'}->{$type}) {
# require the data handler package
my $package = $self->backend->name().'::DataHandler::'.$type;
{
no strict;
eval "require $package";
my $error = "";
if ($@) {
$error = $@;
$package = 'DataHandler::'.$type;
eval "require $package";
if ($@) {
return undef;
}
}
}
my $data = $package->new($self);
$self->{'data_handlers'}->{$type} = $data;
}
if ($options) {
return $self->{'data_handlers'}->{$type}->handle($options);
}
return $self->{'data_handlers'}->{$type}->handle;
}
#******************************************************************************
#* ACTION MANAGEMENT
#******************************************************************************
=pod
=head3 B<register_action> (I<object>, I<method>, I<trigger>)
B<Returns:> a reference to a WebApplication object
Registers an action with the web application framework. If the WebApplication is
called with the cgi parameter I<action>, it will check if the action has been registered.
If not, it will throw an error. If the action is registered, it's method will be
executed in between WebPage->init and WebPage->output.
=cut
sub register_action {
my ($self, $object, $method, $trigger) = @_;
$self->{'actions'}->{$trigger} = [ $object, $method ];
return $self;
}
=pod
=head3 B<execute_action> ()
Checks if a cgi param parameter 'action' is present and if it is registered as a trigger,
then executes the action (invokes the method on the WebPage or WebComponent object).
=cut
sub execute_action {
my ($self) = @_;
return unless ($self->cgi->param('action'));
my $action = $self->cgi->param('action');
if ($self->{'actions'}->{$action}) {
my ($object, $method) = @{$self->{'actions'}->{$action}};
if (ref $object and $method) {
my $result = $object->$method();
push @{$self->{'actions'}->{$action}}, $result;
}
}
else {
$self->error("This page was called with an unregistered action parameter '".
$self->cgi->param('action')."'.");
}
}
=pod
=head3 B<get_action_result> (I<trigger>)
B<Returns:> whatever the according action method returns
Return the result of an action registered with the trigger I<trigger>. If the
action has not been executed this will return undef.
=cut
sub get_action_result {
my ($self, $trigger) = @_;
if ($self->{'actions'}->{$trigger}) {
return $self->{'actions'}->{$trigger}->[2];
}
}
#******************************************************************************
#* APPLICATION MESSAGES
#******************************************************************************
=pod
=head3 B<add_message> (I<msg_type>, I<message>)
B<Returns:> a reference to a WebApplication object
Adds a message with the content of I<message> to the output of the page. The
message type I<msg_type> determines the css formatting and position of the
html output.
The following message type are recognised: 'warning', 'info'.
=cut
sub add_message {
my ($self, $type, $msg, $fadetimer) = @_;
# check type
# check msg
unless ($msg) {
print STDERR "Empty message in method add_message.";
$msg = '';
}
# init message type if necessary
unless ($self->{'messages'}->{$type}) {
$self->{'messages'}->{$type} = [];
}
my $fade_flag = 1;
foreach(@{$self->{'messages'}->{$type}}){
if($_ =~ /onload/){
$fade_flag = 0;
}
}
if($fadetimer && $fade_flag){
my $div_id;
if ($type eq 'warning'){
$div_id = 'warning';
} else {
$div_id = 'info';
}
$msg .= "<img src=\"$Conf::cgi_url/Html/clear.gif\" onload='fade(\"" . $div_id . "\", ". $fadetimer . ");'>";
}
push @{$self->{'messages'}->{$type}}, $msg;
return $self;
}
=pod
=head3 B<get_messages> (I<msg_type>)
B<Returns:> a scalar string
Returns an array reference to all message of the type I<msg_type>.
The following message type are recognised: 'warning', 'info'.
=cut
sub get_messages {
my ($self, $type) = @_;
my $msg = [];
# get messages of that type
if ($self->{'messages'}->{$type}) {
$msg = $self->{'messages'}->{$type};
}
return $msg;
}
#******************************************************************************
#* PAGE REDIRECTION
#******************************************************************************
=pod
=head3 B<redirect> (I<page>)
B<Returns:> a scalar string
Request a redirect to another WebApplication page. I<params> is mandatory
and expects either the name of a page module or a hash containing the page
module name and the frozen cgi parameters
=cut
sub redirect {
my ($self, $params) = @_;
if ($params) {
if (ref($params) eq 'HASH') {
$self->{redirect} = $params;
unless (defined($params->{page}) && length($params->{page})) {
$self->{redirect}->{page} = $self->default;
}
} else {
$self->{redirect} = { page => $params };
}
}
return $self->{redirect};
}
=pod
=head3 B<do_redirect> ()
Executes the actual redirect to another WebPage available in the current WebApplication.
If the page redirected from is omitted from the session, the redirect will flush all
CGI parameters before the redirect.
If the redirect is with frozen CGI parameters, tose CGI parameters are restored.
=cut
sub do_redirect {
my ($self) = @_;
# check if we have at least a page to redirect to
unless ($self->redirect->{page}) {
die "redirect called without page to redirect to.\n";
}
# check for recursive call of redirect
if ($self->{last_redirect} && ($self->{last_redirect} eq $self->redirect->{page})) {
die "recursive call of redirect.\n";
}
# clear cgi params from omitted pages
$self->cgi->delete_all() if ($self->page->omit_from_session);
# set up new cgi data
if ($self->redirect->{parameters}) {
$self->cgi->delete_all();
my @t = thaw($self->redirect->{parameters});
my $params = $t[0];
foreach my $p (keys(%$params)) {
$self->cgi->param( -name => $p, -values => $params->{$p});
}
}
# set the page parameter
$self->cgi->param('page', $self->redirect->{page});
# reset application and re-run
$self->{last_redirect} = $self->redirect->{page};
$self->reset_application;
$self->run;
}
=pod
=head3 B<reset_application> ()
Resets all internal variables of the WebApplication except for already generated
messages. This will also restore the default menu from the backup copy.
=cut
sub reset_application {
my $self = shift;
my ( $menu ) = thaw( $self->{'menu_backup'} );
$self->{'menu'} = $menu;
$self->{'error'} = undef;
$self->{'redirect'} = undef;
$self->{'components'} = {};
$self->{'component_index'} = {};
$self->{'actions'} = {};
}
#******************************************************************************
#* CONTENT GENERATION
#******************************************************************************
=pod
=head3 B<check_for_maintenance> (I<read_maintenance_msg_flag>)
B<Returns:> an array of $flag and $msg or a scalar string
Returns true if the server is locked down for maintenance. The method checks
for the presence of a I<Backend_name>.disabled file at the location of the
script running the WebApplication.
If the optional parameter I<read_maintenance_msg_flag> is provided and true,
the method will read out the content of the file and return it. This is used
by the Maintenance page to disabled a non default maintenance notification.
=cut
sub check_for_maintenance {
my $disabled = $_[0]->backend->name.".disabled";
my $flag = (-e $disabled);
my $msg;
if ($flag and $_[1]) {
open(MSG, "$disabled");
$msg = <MSG>;
close(MSG);
return ($flag, $msg);
}
return $flag;
}
=pod
=head3 B<check_for_silent_login> ()
This method checks for the presence of the CGI parameter I<silent_login>
to allow authenticating as a user from an URL. If present, this CGI param
will be read as loginname:password and the WebApplication tries to login
as that user.
=cut
sub check_for_silent_login {
if ($_[0]->cgi->param('silent_login')) {
$_[0]->cgi->param('silent_login') =~ /^([^:.]+)\:(.+)$/ ;
my $user = $_[0]->dbmaster->User->init( { login => $1 } );
if (ref $user and $user->active and
crypt($2, $user->password) eq $user->password) {
$_[0]->session->user($user);
warn "Silent authentication successful: $1\n";
}
else {
warn "Silent authentication failed: $1\n";
}
}
}
=pod
=head3 B<check_for_anonymous_login> ()
This method checks for the presence of the CGI parameter I<anonymous_login>
to keep the chosen name of the current user if the application is running in
anonymous mode.
=cut
sub check_for_anonymous_login {
my ($self) = @_;
return undef unless $self->anonymous_mode;
my $cgi = $self->cgi;
my $cookie = $cgi->cookie('AnonWebSession');
my $uname = $cgi->param('anonymous_login') || $cookie;
if ($uname) {
if ($uname eq 'logout') {
$self->session->{user} = undef;
} else {
$self->session->{user} = User->new( $uname );
{
package User;
sub new {
my $self = { firstname => $_[1] };
bless $self, 'User';
}
sub has_right { return 1; }
sub firstname { return $_[0]->{firstname}; }
sub lastname { return ''; }
sub login { return $_[0]->{firstname}; }
sub has_right_to { return []; }
sub get_user_scope { return {} };