--- loncom/interface/londocs.pm 2022/10/22 17:24:54 1.684
+++ loncom/interface/londocs.pm 2023/07/16 03:50:54 1.703
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.684 2022/10/22 17:24:54 raeburn Exp $
+# $Id: londocs.pm,v 1.703 2023/07/16 03:50:54 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -45,7 +45,6 @@ use Apache::lontemplate();
use Apache::lonsimplepage();
use Apache::lonhomework();
use Apache::lonpublisher();
-use Apache::lonparmset();
use Apache::loncourserespicker();
use HTML::Entities;
use HTML::TokeParser;
@@ -183,43 +182,62 @@ sub default_folderpath {
}
}
-sub validate_folderpath {
- my ($supplementalflag) = @_;
- if ($env{'form.folderpath'} ne '') {
- my @items = split(/\&/,$env{'form.folderpath'});
- my $badpath;
- for (my $i=0; $i<@items; $i++) {
- my $odd = $i%2;
- if (($odd) && (!$supplementalflag) && ($items[$i] !~ /^[^:]*:(|\d+):(|1):(|1):(|1):(|1)$/)) {
- $badpath = 1;
- } elsif ((!$odd) && ($items[$i] !~ /^(default|supplemental)(|_\d+)$/)) {
- $badpath = 1;
- }
- last if ($badpath);
- }
- if ($badpath) {
- delete($env{'form.folderpath'});
- }
- }
- return;
-}
-
-sub validate_suppath {
+sub validate_supppath {
+ my ($coursenum,$coursedom) = @_;
+ my $backto;
if ($env{'form.supppath'} ne '') {
my @items = split(/\&/,$env{'form.supppath'});
- my $badpath;
+ my ($badpath,$got_supp,$supppath,%supphidden,%suppids);
for (my $i=0; $i<@items; $i++) {
my $odd = $i%2;
if ((!$odd) && ($items[$i] !~ /^supplemental(|_\d+)$/)) {
$badpath = 1;
+ last;
+ } elsif ($odd) {
+ my $suffix;
+ my $idx = $i-1;
+ if ($items[$i] =~ /^([^:]*)::(|1):::$/) {
+ $backto .= '&'.$1;
+ } elsif ($items[$idx] eq 'supplemental') {
+ $backto .= '&'.$items[$i];
+ } else {
+ $backto .= '&'.$items[$i];
+ my $is_hidden;
+ unless ($got_supp) {
+ my ($supplemental) = &Apache::loncommon::get_supplemental($coursenum,$coursedom);
+ if (ref($supplemental) eq 'HASH') {
+ if (ref($supplemental->{'hidden'}) eq 'HASH') {
+ %supphidden = %{$supplemental->{'hidden'}};
+ }
+ if (ref($supplemental->{'ids'}) eq 'HASH') {
+ %suppids = %{$supplemental->{'ids'}};
+ }
+ }
+ $got_supp = 1;
+ }
+ if (ref($suppids{"/uploaded/$coursedom/$coursenum/$items[$idx].sequence"}) eq 'ARRAY') {
+ my $mapid = $suppids{"/uploaded/$coursedom/$coursenum/$items[$idx].sequence"}->[0];
+ if ($supphidden{$mapid}) {
+ $is_hidden = 1;
+ }
+ }
+ $suffix = '::'.$is_hidden.':::';
+ }
+ $supppath .= '&'.$items[$i].$suffix;
+ } else {
+ $supppath .= '&'.$items[$i];
+ $backto .= '&'.$items[$i];
}
- last if ($badpath);
}
if ($badpath) {
delete($env{'form.supppath'});
+ } else {
+ $supppath =~ s/^\&//;
+ $backto =~ s/^\&//;
+ $env{'form.supppath'} = $supppath;
}
}
- return;
+ return $backto;
}
sub dumpcourse {
@@ -700,7 +718,7 @@ sub group_import {
$url = $1;
my $marker = $2;
my $info = $3;
- my ($toolid,%toolhash,%toolsettings);
+ my ($toolid,$toolprefix,$tooltype,%toolhash,%toolsettings);
my @extras = ('linktext','explanation','crslabel','crstitle','crsappend');
my @toolinfo = split(/:/,$info);
if ($residx) {
@@ -709,6 +727,12 @@ sub group_import {
} else {
$toolid = shift(@toolinfo);
}
+ if ($toolid =~ /^c/) {
+ $tooltype = 'crs';
+ $toolprefix = 'c';
+ } else {
+ $tooltype = 'dom';
+ }
$toolid =~ s/\D//g;
($toolhash{'target'},$toolhash{'width'},$toolhash{'height'},
$toolhash{'linktext'},$toolhash{'explanation'},$toolhash{'crslabel'},
@@ -722,127 +746,130 @@ sub group_import {
$toolhash{'gradable'} =~ s/\D+//g;
}
if (ref($ltitoolsref) eq 'HASH') {
- if (ref($ltitoolsref->{$toolid}) eq 'HASH') {
- my @deleted;
- $toolhash{'id'} = $toolid;
- if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'tab') ||
- ($toolhash{'target'} eq 'window')) {
- if ($toolhash{'target'} eq 'window') {
- foreach my $item ('width','height') {
- $toolhash{$item} =~ s/^\s+//;
- $toolhash{$item} =~ s/\s+$//;
- if ($toolhash{$item} =~ /\D/) {
- delete($toolhash{$item});
- if ($residx) {
- if ($toolsettings{$item}) {
- push(@deleted,$item);
+ if (ref($ltitoolsref->{$tooltype}) eq 'HASH') {
+ if (ref($ltitoolsref->{$tooltype}->{$toolid}) eq 'HASH') {
+ my %tools = %{$ltitoolsref->{$tooltype}->{$toolid}};
+ my @deleted;
+ $toolhash{'id'} = $toolprefix.$toolid;
+ if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'tab') ||
+ ($toolhash{'target'} eq 'window')) {
+ if ($toolhash{'target'} eq 'window') {
+ foreach my $item ('width','height') {
+ $toolhash{$item} =~ s/^\s+//;
+ $toolhash{$item} =~ s/\s+$//;
+ if ($toolhash{$item} =~ /\D/) {
+ delete($toolhash{$item});
+ if ($residx) {
+ if ($toolsettings{$item}) {
+ push(@deleted,$item);
+ }
}
}
}
}
- }
- } elsif ($residx) {
- $toolhash{'target'} = $toolsettings{'target'};
- if ($toolhash{'target'} eq 'window') {
- foreach my $item ('width','height') {
- $toolhash{$item} = $toolsettings{$item};
+ } elsif ($residx) {
+ $toolhash{'target'} = $toolsettings{'target'};
+ if ($toolhash{'target'} eq 'window') {
+ foreach my $item ('width','height') {
+ $toolhash{$item} = $toolsettings{$item};
+ }
+ }
+ } elsif (ref($tools{'display'}) eq 'HASH') {
+ $toolhash{'target'} = $tools{'display'}{'target'};
+ if ($toolhash{'target'} eq 'window') {
+ $toolhash{'width'} = $tools{'display'}{'width'};
+ $toolhash{'height'} = $tools{'display'}{'height'};
}
}
- } elsif (ref($ltitoolsref->{$toolid}->{'display'}) eq 'HASH') {
- $toolhash{'target'} = $ltitoolsref->{$toolid}->{'display'}->{'target'};
- if ($toolhash{'target'} eq 'window') {
- $toolhash{'width'} = $ltitoolsref->{$toolid}->{'display'}->{'width'};
- $toolhash{'height'} = $ltitoolsref->{$toolid}->{'display'}->{'height'};
- }
- }
- if ($toolhash{'target'} eq 'iframe') {
- foreach my $item ('width','height','linktext','explanation') {
- delete($toolhash{$item});
- if ($residx) {
- if ($toolsettings{$item}) {
- push(@deleted,$item);
+ if ($toolhash{'target'} eq 'iframe') {
+ foreach my $item ('width','height','linktext','explanation') {
+ delete($toolhash{$item});
+ if ($residx) {
+ if ($toolsettings{$item}) {
+ push(@deleted,$item);
+ }
}
}
- }
- } elsif ($toolhash{'target'} eq 'tab') {
- foreach my $item ('width','height') {
- delete($toolhash{$item});
- if ($residx) {
- if ($toolsettings{$item}) {
- push(@deleted,$item);
+ } elsif ($toolhash{'target'} eq 'tab') {
+ foreach my $item ('width','height') {
+ delete($toolhash{$item});
+ if ($residx) {
+ if ($toolsettings{$item}) {
+ push(@deleted,$item);
+ }
}
}
}
- }
- if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') {
- foreach my $item ('label','title','linktext','explanation') {
- my $crsitem;
- if (($item eq 'label') || ($item eq 'title')) {
- $crsitem = 'crs'.$item;
- } else {
- $crsitem = $item;
- }
- if ($ltitoolsref->{$toolid}->{'crsconf'}->{$item}) {
- $toolhash{$crsitem} =~ s/^\s+//;
- $toolhash{$crsitem} =~ s/\s+$//;
- if ($toolhash{$crsitem} eq '') {
+ if (ref($tools{'crsconf'}) eq 'HASH') {
+ foreach my $item ('label','title','linktext','explanation') {
+ my $crsitem;
+ if (($item eq 'label') || ($item eq 'title')) {
+ $crsitem = 'crs'.$item;
+ } else {
+ $crsitem = $item;
+ }
+ if ($tools{'crsconf'}{$item}) {
+ $toolhash{$crsitem} =~ s/^\s+//;
+ $toolhash{$crsitem} =~ s/\s+$//;
+ if ($toolhash{$crsitem} eq '') {
+ delete($toolhash{$crsitem});
+ }
+ } else {
delete($toolhash{$crsitem});
}
- } else {
- delete($toolhash{$crsitem});
- }
- if (($residx) && (exists($toolsettings{$crsitem}))) {
- unless (exists($toolhash{$crsitem})) {
- push(@deleted,$crsitem);
+ if (($residx) && (exists($toolsettings{$crsitem}))) {
+ unless (exists($toolhash{$crsitem})) {
+ push(@deleted,$crsitem);
+ }
}
}
}
- }
- if ($toolhash{'passback'}) {
- my $gradesecret = UUID::Tiny::create_uuid_as_string(UUID_V4);
- $toolhash{'gradesecret'} = $gradesecret;
- $toolhash{'gradesecretdate'} = time;
- }
- if ($toolhash{'roster'}) {
- my $rostersecret = UUID::Tiny::create_uuid_as_string(UUID_V4);
- $toolhash{'rostersecret'} = $rostersecret;
- $toolhash{'rostersecretdate'} = time;
- }
- my $changegradable;
- if (($residx) && ($folder =~ /^default/)) {
- if ($toolsettings{'gradable'}) {
- unless (($toolhash{'gradable'}) || (defined($LONCAPA::map::zombies[$residx]))) {
- push(@deleted,'gradable');
- $changegradable = 1;
- }
- } elsif ($toolhash{'gradable'}) {
- $changegradable = 1;
+ if ($toolhash{'passback'}) {
+ my $gradesecret = UUID::Tiny::create_uuid_as_string(UUID_V4);
+ $toolhash{'gradesecret'} = $gradesecret;
+ $toolhash{'gradesecretdate'} = time;
+ }
+ if ($toolhash{'roster'}) {
+ my $rostersecret = UUID::Tiny::create_uuid_as_string(UUID_V4);
+ $toolhash{'rostersecret'} = $rostersecret;
+ $toolhash{'rostersecretdate'} = time;
}
- if (($caller eq 'londocs') && (defined($LONCAPA::map::zombies[$residx]))) {
- $changegradable = 1;
+ my $changegradable;
+ if (($residx) && ($folder =~ /^default/)) {
if ($toolsettings{'gradable'}) {
- $toolhash{'gradable'} = 1;
+ unless (($toolhash{'gradable'}) || (defined($LONCAPA::map::zombies[$residx]))) {
+ push(@deleted,'gradable');
+ $changegradable = 1;
+ }
+ } elsif ($toolhash{'gradable'}) {
+ $changegradable = 1;
+ }
+ if (($caller eq 'londocs') && (defined($LONCAPA::map::zombies[$residx]))) {
+ $changegradable = 1;
+ if ($toolsettings{'gradable'}) {
+ $toolhash{'gradable'} = 1;
+ }
}
}
- }
- my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum);
- if ($putres eq 'ok') {
- if (@deleted) {
- &Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum);
- }
- if (($changegradable) && ($folder =~ /^default/)) {
- my $val;
- if ($toolhash{'gradable'}) {
- $val = 'yes';
- } else {
- $val = 'no';
+ my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum);
+ if ($putres eq 'ok') {
+ if (@deleted) {
+ &Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum);
+ }
+ if (($changegradable) && ($folder =~ /^default/)) {
+ my $val;
+ if ($toolhash{'gradable'}) {
+ $val = 'yes';
+ } else {
+ $val = 'no';
+ }
+ &LONCAPA::map::storeparameter($residx,'parameter_0_gradable',$val,
+ 'string_yesno');
+ &remember_parms($residx,'gradable','set',$val);
}
- &LONCAPA::map::storeparameter($residx,'parameter_0_gradable',$val,
- 'string_yesno');
- &remember_parms($residx,'gradable','set',$val);
+ } else {
+ return (&mt('Failed to save update to external tool.'),1);
}
- } else {
- return (&mt('Failed to save update to external tool.'),1);
}
}
}
@@ -1188,7 +1215,13 @@ sub docs_change_log {
}
$r->print('');
if ($docslog{$id}{'logentry'}{'parameter_res'}) {
- $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':
');
+ my ($title,$url) = split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'},3);
+ if ($title eq '') {
+ ($title) = ($url =~ m{/([^/]+)$});
+ } elsif ($is_supp) {
+ $title = &Apache::loncommon::parse_supplemental_title($title);
+ }
+ $r->print(&LONCAPA::map::qtescape($title).':');
foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder','gradable') {
if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
# FIXME: internationalization seems wrong here
@@ -1452,6 +1485,14 @@ sub print_paste_buffer {
$nopaste = &mt('Paste from another course unavailable.');
}
}
+ } elsif ($url =~ m{/res/($match_domain)/($match_username)/}) {
+ my ($audom,$auname) = ($1,$2);
+ unless (($auname eq $coursenum) && ($audom eq $coursedom)) {
+ if (&Apache::lonnet::is_course($audom,$auname)) {
+ $canpaste = 0;
+ $nopaste = &mt('Paste from another course unavailable.');
+ }
+ }
}
if ($canpaste) {
push(@pasteable,$suffix);
@@ -1792,6 +1833,16 @@ sub do_paste_from_buffer {
}
$srcdom{$suffix} = $srcd;
$srcnum{$suffix} = $srcn;
+ } elsif ($url =~ m{^/res/($match_domain)/($match_courseid)/}) {
+ my ($audom,$auname) = ($1,$2);
+# When buffer was populated using an active role in a different course
+# disallow pasting of published resources from Course Authoring Space
+ unless (($auname eq $coursenum) && ($audom eq $coursedom)) {
+ if (&Apache::lonnet::is_course($audom,$auname)) {
+ $othcrsres{$suffix} = 1;
+ next;
+ }
+ }
}
$srcmapidx{$suffix} = $mapidx;
push(@dopaste,$suffix);
@@ -1843,6 +1894,7 @@ sub do_paste_from_buffer {
notinsupp => 'Paste failed: content type is not supported within Supplemental Content',
notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.',
notindom => 'Paste failed: Item is an external tool from a course in a different domain.',
+ othcrsres => 'Paste failed: Item is a course-authored resource from a different course',
duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.',
);
@@ -2489,6 +2541,15 @@ sub contained_map_check {
next;
}
}
+ if ($ressrc =~ m{^/res/($match_domain)/($match_courseid)/}) {
+ my ($srcdom,$srcnum) = ($1,$2);
+ unless (($srcnum eq $coursenum) && ($srcdom eq $coursedom)) {
+ if (&Apache::lonnet::is_course($srcdom,$srcnum)) {
+ $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
+ next;
+ }
+ }
+ }
if ($ressrc =~ m{^/(res|uploaded)/.+\.(sequence|page)$}) {
if ($1 eq 'uploaded') {
$hierarchy->{$url}{$token->[2]->{'id'}} = $ressrc;
@@ -2623,7 +2684,7 @@ sub url_paste_fixups {
if ($is_exttool) {
$exttoolchg = 1;
}
- } elsif (($rem =~ m{\d+/ext\.tool$}) &&
+ } elsif (($is_exttool) &&
($env{'form.docs.markedcopy_options'} ne 'move')) {
$dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
$dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
@@ -3090,7 +3151,7 @@ sub update_parameter {
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
$name=&LONCAPA::map::qtescape($name);
$url=&LONCAPA::map::qtescape($url);
- next unless ($name && $url);
+ next unless $url;
my $is_map;
if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
$is_map = 1;
@@ -3277,28 +3338,11 @@ sub editor {
return $errtext if ($fatal);
}
- my (%supphidden,%suppids,$suppmapid);
-
if ($#LONCAPA::map::order<1) {
my $idx=&LONCAPA::map::getresidx();
if ($idx<=0) { $idx=1; }
$LONCAPA::map::order[0]=$idx;
$LONCAPA::map::resources[$idx]='';
- } elsif ($supplementalflag && !$allowed) {
- my ($supplemental) = &Apache::lonnet::get_supplemental($coursenum,$coursedom);
- if (ref($supplemental) eq 'HASH') {
- if (ref($supplemental->{'hidden'}) eq 'HASH') {
- %supphidden = %{$supplemental->{'hidden'}};
- }
- if (ref($supplemental->{'ids'}) eq 'HASH') {
- %suppids = %{$supplemental->{'ids'}};
- }
- }
- if ($folder eq 'supplemental') {
- $suppmapid = 0;
- } elsif ($folder =~ /^supplemental_(\d+)$/) {
- $suppmapid = $1;
- }
}
# ------------------------------------------------------------ Process commands
@@ -3559,6 +3603,21 @@ sub editor {
$r->print('');
}
+ if ((!$allowed) && ($folder =~ /^supplemental_\d+$/)) {
+ my ($supplemental) = &Apache::loncommon::get_supplemental($coursenum,$coursedom);
+ if (ref($supplemental) eq 'HASH') {
+ if ((ref($supplemental->{'hidden'}) eq 'HASH') &&
+ (ref($supplemental->{'ids'}) eq 'HASH')) {
+ if (ref($supplemental->{'ids'}->{"/uploaded/$coursedom/$coursenum/$folder.$container"}) eq 'ARRAY') {
+ my $mapnum = $supplemental->{'ids'}->{"/uploaded/$coursedom/$coursenum/$folder.$container"}->[0];
+ if ($supplemental->{'hidden'}->{$mapnum}) {
+ $ishidden = 1;
+ }
+ }
+ }
+ }
+ }
+
my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups);
%filters = (
canremove => [],
@@ -3583,14 +3642,16 @@ sub editor {
}
if (($supplementalflag) && (!$allowed) && (!$env{'request.role.adv'})) {
- next if ($supphidden{$suppmapid.':'.$res});
+ if (($ishidden) || ((&LONCAPA::map::getparameter($res,'parameter_hiddenresource'))[0]=~/^yes$/i)) {
+ $idx++;
+ next;
+ }
}
$output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
$coursenum,$coursedom,$crstype,
$pathitem,$supplementalflag,$container,
\%filters,\%curr_groups,$ltitoolsref,$canedit,
- $isencrypted,$navmapref,$hostname,
- \%supphidden,\%suppids,$suppmapid);
+ $isencrypted,$ishidden,$navmapref,$hostname);
$idx++;
$shown++;
}
@@ -3720,7 +3781,7 @@ sub multiple_check_form {
return unless (ref($listsref) eq 'HASH');
my $disabled;
unless ($canedit) {
- $disabled = 'disabled="disabled"';
+ $disabled = ' disabled="disabled"';
}
my $output =
'
NWEBFORM
-
+ my $showpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
my @ids=&Apache::lonnet::current_machine_ids();
- my %select_menus;
- my $numauthor = 0;
- my $numcrsdirs = 0;
- my $toppath = "/priv/$env{'user.domain'}/$env{'user.name'}";
+ my $machines_str = "'".join("','",@ids)."'";
+ my (%is_home,%toppath,$rolehomes);
if ($env{'user.author'}) {
- $numauthor ++;
- $select_menus{'author'}->{'text'} = &Apache::lonnet::plaintext('au');
if (grep(/^\Q$env{'user.home'}\E$/,@ids)) {
- my $is_home = 1;
- my %subdirs;
- &Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs);
- $select_menus{'author'}->{'default'} = '/';
- $select_menus{'author'}->{'select2'}->{'/'} = '/';
- my @ordered = ('/');
- foreach my $relpath (sort { lc($a) cmp lc($b) } (keys(%subdirs))) {
- $select_menus{'author'}->{'select2'}->{$relpath} = $relpath;
- push(@ordered,$relpath);
- }
- $select_menus{'author'}->{'order'} = \@ordered;
- } else {
- $select_menus{'author'}->{'select2'}->{'switch'} = &mt('Switch server required');
- $select_menus{'author'}->{'default'} = 'switch';
- $select_menus{'author'}->{'order'} = ['switch'];
+ $is_home{'author'} = 1;
}
+ $rolehomes = ''."\n";
}
my %roleshash = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles',
['active'],['ca','aa']);
- my $crshome = $env{'course.'.$env{'request.course.id'}.'.home'};
my %by_roletype;
if (keys(%roleshash)) {
foreach my $entry (keys(%roleshash)) {
my ($auname,$audom,$roletype) = split(/:/,$entry);
my $key = $entry;
$key =~ s/:/___/g;
- $by_roletype{$roletype}{$auname.'___'.$audom} = 1;
- $select_menus{$key}->{'text'} = &Apache::lonnet::plaintext($roletype)." ($audom/$auname)";
+ my $author = $auname.'___'.$audom;
+ $by_roletype{$roletype}{$author} = 1;
my $rolehome = &Apache::lonnet::homeserver($auname,$audom);
- if (grep(/^\Q$rolehome\E$/,@ids)) {
- my $is_home = 1;
- my (%subdirs,@ordered);
- my $toppath="/priv/$audom/$auname";
- &Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs);
- $select_menus{$key}->{'default'} = '/';
- $select_menus{$key}->{'select2'}->{'/'} = '/';
- my @ordered = ('/');
- foreach my $relpath (sort { lc($a) cmp lc($b) } (keys(%subdirs))) {
- $select_menus{$key}->{'select2'}->{$relpath} = $relpath;
- push(@ordered,$relpath);
- }
- $select_menus{$key}->{'order'} = \@ordered;
- } else {
- $select_menus{$key}->{'select2'}->{'switch'} = &mt('Switch server required');
- $select_menus{$key}->{'default'} = 'switch';
- $select_menus{$key}->{'order'} = ['switch'];
- }
- $numauthor ++;
- }
- }
- my ($pickdir,$showtitle);
- if ($numauthor) {
- my @order;
- my $defrole;
- if ($env{'user.author'}) {
- push(@order,'author');
- $defrole = 'author';
- }
- if (keys(%by_roletype)) {
- foreach my $possrole ('ca','aa') {
- if (ref($by_roletype{$possrole}) eq 'HASH') {
- foreach my $author (sort { lc($a) cmp lc($b) } (keys(%{$by_roletype{$possrole}}))) {
- unless ($defrole) {
- $defrole = $author;
- }
- push(@order,$author.'___'.$possrole);
- }
- }
+ $toppath{$author} = "/priv/$audom/$auname";
+ if (grep(/^\Q$rolehome\E$/,@ids)) {
+ $is_home{$author} = 1;
}
+ $rolehomes .= ''."\n";
}
- $select_menus{'course'}->{'text'} = &mt('Course Resource');
- if (grep(/^\Q$crshome\E$/,@ids)) {
- my $is_home = 1;
- my %subdirs;
- my $toppath="/priv/$coursedom/$coursenum";
- &Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs);
- $numcrsdirs = keys(%subdirs);
- $select_menus{'course'}->{'default'} = '/';
- $select_menus{'course'}->{'select2'}->{'/'} = '/';
- my @ordered = ('/');
- foreach my $relpath (sort { lc($a) cmp lc($b) } (keys(%subdirs))) {
- $select_menus{'course'}->{'select2'}->{$relpath} = $relpath;
- push(@ordered,$relpath);
- }
- $select_menus{'course'}->{'order'} = \@ordered;
- } else {
- $select_menus{'course'}->{'select2'}->{'switch'} = &mt('Switch server required');
- $select_menus{'course'}->{'default'} = 'switch';
- $select_menus{'course'}->{'order'} = ['switch'];
- }
- push(@order,'course');
- $pickdir = $lt{'loca'}.
- &Apache::loncommon::linked_select_forms('courseresform','
'.$lt{'dire'},
- $defrole,'authorrole','authorpath',
- \%select_menus,\@order,'toggleCrsResTitle();',
- '','priv').'
';
- $showtitle = 'none';
- } else {
- my $is_home;
- $showtitle = 'inline';
- if (grep(/^\Q$crshome\E$/,@ids)) {
- $is_home = 1;
- $pickdir .= '';
- my $toppath="/priv/$coursedom/$coursenum'}";
- my %subdirs;
- &Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs);
- $numcrsdirs = keys(%subdirs);
- if ($numcrsdirs) {
- $pickdir .= &mt('Directory: ').'
'."\n".
+ $lt{'dire'}.
+ ''.
+ ''.
+ '
'."\n";
my %seltemplate_menus;
my @files = &Apache::lonhomework::get_template_list('problem');
@@ -6578,9 +6692,9 @@ NWEBFORM
"resize_scrollbox('contentscroll','1','0');",
"toggleExampleText();",'template').'
';
my $templatepreview = ''.
- ''.&mt('Example').'';
+ ''.&mt('Example').'';
my $crsresform=(<