');
+ $r->print(&Apache::loncommon::start_data_table_row().' ');
if ($constructmode) {
$r->print(&Apache::loncommon::select_form('','action_0',
('' => '',
@@ -210,19 +217,20 @@ ENDSTARTTABLE
} else {
$r->print($token->[2]->{'effect'});
}
- $r->print(' Default');
+ $r->print(' '.&mt('Default'));
if (($token->[2]->{'realm'}) || ($token->[2]->{'role'})) {
- $r->print(' - '.&mt('Error! No default set.').
- ' ');
+ $r->print(' - '.&mt('Error! No default set.').
+ ' ');
}
- $r->print(' ');
+ $r->print(''.&Apache::loncommon::end_data_table_row());
# Additional roles
while ($token=$parser->get_token) {
if (($token->[0] eq 'S') && ($token->[1] eq 'accessrule')) {
$rulecounter++;
- $r->print('');
+ $r->print(&Apache::loncommon::start_data_table_row().
+ ' ');
# insert, delete, etc
- $r->print($rulecounter.'. ');
+ $r->print(''.$rulecounter.'. ');
if ($constructmode) {
$r->print(&Apache::loncommon::select_form(
'','action_'.$rulecounter,
@@ -233,7 +241,8 @@ ENDSTARTTABLE
'moveup' => 'Move rule up',
'movedown' => 'Move rule down')));
}
- $r->print(' ');
+ $r->print(' '.
+ '');
# effect
if ($constructmode) {
$r->print(&Apache::loncommon::select_form
@@ -244,14 +253,34 @@ ENDSTARTTABLE
} else {
$r->print($token->[2]->{'effect'});
}
- $r->print(' ');
+
+# type
+ $r->print(' ');
+ my $type = ($token->[2]{'type'} || 'course');
+ if ($constructmode) {
+ $r->print(&Apache::loncommon::select_form($type,
+ 'type_'.$rulecounter,
+ ('course' => 'Course',
+ 'user' => 'User')));
+ } else {
+ $r->print($type);
+ }
+
# ---- realm
my $realm=$token->[2]->{'realm'};
- $realm=~s/^\W//;
my ($rdom,$rcourse,$rsec)=split(/[\/\_]/,$realm);
+ $rdom = &LONCAPA::clean_domain($rdom);
+ if ($type eq 'course') {
+ $rcourse = &LONCAPA::clean_courseid($rcourse);
+ } else {
+ $rcourse = &LONCAPA::clean_username($rcourse);
+ }
+
+
+ $r->print(' ');
# realm domain
if ($constructmode) {
- unless ($rdom) { $rdom=$ENV{'user.domain'}; }
+ unless ($rdom) { $rdom=$env{'user.domain'}; }
$r->print(&Apache::loncommon::select_dom_form($rdom,
'domain_'.$rulecounter));
} else {
@@ -260,62 +289,74 @@ ENDSTARTTABLE
$r->print(' ');
# realm course
if ($constructmode) {
- $r->print(' ');
} else {
$r->print($rcourse);
}
- $r->print(' ');
+ $r->print(' ');
# realm section
- if ($constructmode) {
- $r->print(' ');
- } else {
- $r->print($rsec);
- }
+ if ($type eq 'course') {
+ if ($constructmode) {
+ $r->print(' ');
+ } else {
+ $r->print($rsec);
+ }
+ }
$r->print(' ');
# role
- if ($constructmode) {
- my %hash=('' => '');
- foreach ('au','cc','in','ta','st') {
- $hash{$_}=&Apache::lonnet::plaintext($_);
- }
- my $role=$token->[2]->{'role'};
- unless ($role) { $role=''; }
- $r->print(&Apache::loncommon::select_form(
- $role,'role_'.$rulecounter,%hash));
- } else {
- $r->print(&Apache::lonnet::plaintext($token->[2]->{'role'}));
- }
-# use access
- # if ($constructmode) {
- #
- # } else {
- # $r->print(&Apache::lonnet::plaintext($token->[2]->{'role'}));
- # }
+ if ($type eq 'course') {
+ if ($constructmode) {
+ my %hash=('' => '');
+ foreach ('au','cc','in','ta','st') {
+ $hash{$_}=&Apache::lonnet::plaintext($_);
+ }
+ my $role=$token->[2]->{'role'};
+ unless ($role) { $role=''; }
+ $r->print(&Apache::loncommon::select_form(
+ $role,'role_'.$rulecounter,%hash));
+ } else {
+ $r->print(&Apache::lonnet::plaintext($token->[2]->{'role'}));
+ }
+ }
# course selection link
- $r->print(' ');
- if ($rcourse) {
- my %descript=
- &Apache::lonnet::coursedescription($rdom.'_'.$rcourse);
- $r->print($descript{'description'}.' ');
- }
- if ($constructmode) {
- $r->print(&Apache::loncommon::selectcourse_link('rules',
- 'course_'.$rulecounter,'domain_'.$rulecounter));
+ $r->print(' '.
+ &Apache::loncommon::end_data_table_row().
+ &Apache::loncommon::continue_data_table_row().
+ '');
+ if ($type eq 'course') {
+ if ($rcourse) {
+ my %descript=
+ &Apache::lonnet::coursedescription($rdom.'_'.$rcourse,
+ {'one_time' => 1});
+ $r->print($descript{'description'}.' ');
+ }
+ if ($constructmode) {
+ $r->print(&Apache::loncommon::selectcourse_link('rules',
+ 'course_'.$rulecounter,'domain_'.$rulecounter));
+ }
+ } else {
+ if ($rcourse) {
+ my $name = &Apache::loncommon::plainname($rcourse,$rdom);
+ $r->print($name.' ');
+ }
+ if ($constructmode) {
+ $r->print(&Apache::loncommon::selectstudent_link('rules','course_'.$rulecounter,'domain_'.$rulecounter));
+ }
}
# close row
- $r->print(' ');
+ $r->print(''.&Apache::loncommon::end_data_table_row());
}
}
- $r->print('');
+ $r->print(&Apache::loncommon::end_data_table());
# ------------------------------------------------------------ End table output
if ($constructmode) {
- $r->print('