<%doc> HTML form for access rights (special case of edit) <%args> $table => undef $id => undef $select_id => undef $selected => undef $showheader => undef $dowindow => 0 $object_class => undef @object_id => undef $person => undef $contactlist => undef @access => undef $submit => undef $return_comp => undef $return_id => undef $return_view => undef %args => undef <%init> my $DEBUG = 0; # Consolidate args variables foreach my $arg ( %args ){ $ARGS{$arg} = $args{$arg}; } my %anames = $ui->get_access_names(); my $title = ($table)? "$table " . $ui->table_descr_link($table, "[?]") : 'Add'; print '%ARGS is
', Dumper(%ARGS), '

' if $DEBUG; if ( $submit ){ if ( !defined($access[0]) ){ $m->comp('error.mhtml', error=>"No rights were selected, please select one or more rights to grant"); } if( !$object_id[0] ){ $m->comp('error.mhtml', error=>"No objects were selected, please select objects to grant rights on"); } if( !$object_class ){ $m->comp('error.mhtml', error=>"No object class was selected, please select an object class"); } eval { if ( $object_class && $object_id[0] ){ foreach my $object_id ( @object_id ){ foreach my $access ( @access ){ my $accessright = AccessRight->find_or_create({object_class => $object_class, object_id => $object_id, access => $access}); if ( $table eq 'Person' ){ UserRight->find_or_create({accessright=>$accessright, person=>$id}); }elsif ( $table eq 'ContactList' ){ GroupRight->find_or_create({accessright=>$accessright, contactlist=>$id}); } } } } }; if ( my $e= $@ ){ $m->comp('error.mhtml', error=>$e); } } <%perl> if( $id ) { if ( $return_comp && $return_id ){ $m->comp($return_comp, id=>$return_id, view=>$return_view); }else{ if ( $table eq 'Person' ){ $m->comp('view.html', table=>$table, id=>$id); }else{ $m->comp('contactlist.html', id=>$id); } } }else{ if ( !$showheader ){ $m->clear_buffer; % my $js_prefix = $r->dir_config('NetdotPath') . "java_script"; % for my $script ( qw(select jsrsClient) ){ % } %}
<% $title %>
<%perl> my (@field_headers, @cell_data); if ( $ARGS{person} ){ my $person = Person->retrieve($ARGS{person}); push @field_headers, 'User:'; push @cell_data, $person->get_label; print ""; print ""; }elsif ( $ARGS{contactlist} ){ my $cl = ContactList->retrieve($ARGS{contactlist}); push @field_headers, 'Contact List:'; push @cell_data, $cl->get_label; print ""; print ""; }else{ push @field_headers, 'Subject Type:'; push @cell_data, (''); push @field_headers, 'Name:'; push @cell_data, (''. ''. '' ); } push @field_headers, 'Object Class:'; if ( $object_class ){ push @cell_data, &{sub{ my $out = $object_class; $out .= ""; }}; }else{ my %classes = AccessRight->get_classes(); push @cell_data, &{sub{ my $out; $out .= ""; }}; } push @field_headers, 'Object(s):'; if ( $object_id[0] ){ push @cell_data, &{sub{ my $out = join(', ', map { $object_class->retrieve($_)->get_label } @object_id); foreach my $oid ( @object_id ){ $out .= ""; } $out; }}; }else{ push @cell_data, &{sub{ my $out; $out .= "
"; $out .= ""; $out .= ""; }}; } push @field_headers, 'Rights:'; my $txt = ''; push @cell_data, $txt; <& /generic/attribute_table.mhtml, field_headers=>\@field_headers, data=>\@cell_data, width=>"1", headercolwidth=>"15%", datacolwidth=>"35%" &>
% if ( $dowindow ){ % }else{ % }
% if ( $showheader ){ % }else{ % } % }