version 1.451, 2016/06/19 04:27:50
|
version 1.477, 2017/09/04 23:47:22
|
Line 381 sub secondary_menu {
|
Line 381 sub secondary_menu {
|
? "/$env{'request.course.sec'}" |
? "/$env{'request.course.sec'}" |
: ''); |
: ''); |
my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'}); |
my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'}); |
|
my $canvieweditor = &Apache::lonnet::allowed('cev', $env{'request.course.id'}); |
my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'}; |
my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'}; |
if ($canviewroster eq 'disabled') { |
if ($canviewroster eq 'disabled') { |
undef($canviewroster); |
undef($canviewroster); |
} |
} |
my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec); |
my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec); |
my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec); |
my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec); |
|
my $canviewusers = &Apache::lonnet::allowed('vcl', $crs_sec); |
my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec); |
my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec); |
|
my $canviewpara = &Apache::lonnet::allowed('vpa', $crs_sec); |
my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec); |
my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec); |
my $canvgr = &Apache::lonnet::allowed('vgr', $crs_sec); |
my $canvgr = &Apache::lonnet::allowed('vgr', $crs_sec); |
my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec); |
my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec); |
Line 398 sub secondary_menu {
|
Line 401 sub secondary_menu {
|
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
if ($canedit) { |
if ($canedit || $canvieweditor) { |
$showsyllabus = 1; |
$showsyllabus = 1; |
$showfeeds = 1; |
$showfeeds = 1; |
} else { |
} else { |
Line 414 sub secondary_menu {
|
Line 417 sub secondary_menu {
|
$showfeeds = 1; |
$showfeeds = 1; |
} |
} |
} |
} |
unless ($canmgr) { |
unless ($canmgr || $canvgr) { |
my %slots = &Apache::lonnet::get_course_slots($cnum,$cdom); |
my %slots = &Apache::lonnet::get_course_slots($cnum,$cdom); |
if (keys(%slots) > 0) { |
if (keys(%slots) > 0) { |
$showresv = 1; |
$showresv = 1; |
Line 450 sub secondary_menu {
|
Line 453 sub secondary_menu {
|
next if $$menuitem[4] ne 'always' |
next if $$menuitem[4] ne 'always' |
&& ($$menuitem[4] ne 'author' && $$menuitem[4] ne 'cca') |
&& ($$menuitem[4] ne 'author' && $$menuitem[4] ne 'cca') |
&& !$env{'request.course.id'}; |
&& !$env{'request.course.id'}; |
next if $$menuitem[4] =~ /^mdc/ |
next if $$menuitem[4] =~ /^crsedit/ |
&& !$canedit; |
&& (!$canedit && !$canvieweditor); |
next if $$menuitem[4] eq 'nvgr' |
next if $$menuitem[4] eq 'nvgr' |
&& $canvgr; |
&& $canvgr; |
next if $$menuitem[4] eq 'vgr' |
next if $$menuitem[4] eq 'vgr' |
&& !$canvgr; |
&& !$canvgr; |
next if $$menuitem[4] eq 'cst' |
next if $$menuitem[4] eq 'viewusers' |
&& !$canmodifyuser; |
&& !$canmodifyuser && !$canviewusers; |
next if $$menuitem[4] eq 'ncst' |
next if $$menuitem[4] eq 'noviewusers' |
&& ($canmodifyuser || !$canviewroster); |
&& ($canmodifyuser || $canviewusers || !$canviewroster); |
next if $$menuitem[4] eq 'mgr' |
next if $$menuitem[4] eq 'mgr' |
&& !$canmgr; |
&& !$canmgr; |
next if $$menuitem[4] eq 'showresv' |
next if $$menuitem[4] eq 'showresv' |
&& !$showresv; |
&& !$showresv; |
next if $$menuitem[4] eq 'whn' |
next if $$menuitem[4] eq 'whn' |
&& !$canviewwnew; |
&& !$canviewwnew; |
next if $$menuitem[4] eq 'opa' |
next if $$menuitem[4] eq 'params' |
&& !$canmodpara; |
&& (!$canmodpara && !$canviewpara); |
next if $$menuitem[4] =~ /showgroups$/ |
next if $$menuitem[4] =~ /showgroups$/ |
&& !$canviewgrps |
&& !$canviewgrps |
&& !$grouptools; |
&& !$grouptools; |
Line 494 sub secondary_menu {
|
Line 497 sub secondary_menu {
|
my $url = $$menuitem[0]; |
my $url = $$menuitem[0]; |
$url =~ s{\[cdom\]/\[cnum\]}{$cdom/$cnum}; |
$url =~ s{\[cdom\]/\[cnum\]}{$cdom/$cnum}; |
if (&Apache::lonnet::is_on_map($url)) { |
if (&Apache::lonnet::is_on_map($url)) { |
unless ($$menuitem[0] =~ /\?register=1/) { |
unless ($$menuitem[0] =~ /(\?|\&)register=1/) { |
$$menuitem[0] .= '?register=1'; |
$$menuitem[0] .= (($$menuitem[0]=~/\?/)? '&' : '?').'register=1'; |
} |
} |
} else { |
} else { |
$$menuitem[0] =~ s{\?register=1}{}; |
$$menuitem[0] =~ s{\&?register=1}{}; |
} |
} |
|
if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://}) { |
|
if (($ENV{'SERVER_PORT'} == 443) || ($env{'request.use_absolute'} =~ m{^https://})) { |
|
unless ($$menuitem[0] =~ m{^https?://}) { |
|
$$menuitem[0] = 'http://'.$ENV{'SERVER_NAME'}.$$menuitem[0]; |
|
} |
|
unless ($$menuitem[0] =~ /(\&|\?)usehttp=1/) { |
|
$$menuitem[0] .= (($$menuitem[0]=~/\?/) ? '&' : '?').'usehttp=1'; |
|
} |
|
} |
|
} |
|
$$menuitem[0] = &HTML::Entities::encode($$menuitem[0],'&<>"'); |
} |
} |
$menu .= &prep_menuitem(\@$menuitem); |
$menu .= &prep_menuitem(\@$menuitem); |
} |
} |
Line 518 sub secondary_menu {
|
Line 532 sub secondary_menu {
|
my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'}; |
my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'}; |
($escurl = $env{'request.filename'}) =~ s{^\Q$londocroot\E}{}; |
($escurl = $env{'request.filename'}) =~ s{^\Q$londocroot\E}{}; |
$escurl = &escape($escurl); |
$escurl = &escape($escurl); |
} |
} |
$menu =~ s/\[url\]/$escurl/g; |
$menu =~ s/\[url\]/$escurl/g; |
$menu =~ s/\[symb\]/$escsymb/g; |
$menu =~ s/\[symb\]/$escsymb/g; |
} |
} |
Line 622 sub build_submenu {
|
Line 636 sub build_submenu {
|
} |
} |
|
|
sub innerregister { |
sub innerregister { |
my ($forcereg,$bread_crumbs,$group) = @_; |
my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname) = @_; |
my $const_space = ($env{'request.state'} eq 'construct'); |
my $const_space = ($env{'request.state'} eq 'construct'); |
my $is_const_dir = 0; |
my $is_const_dir = 0; |
|
|
Line 632 sub innerregister {
|
Line 646 sub innerregister {
|
|
|
undef(@inlineremote); |
undef(@inlineremote); |
|
|
my ($mapurl,$resurl,$crstype); |
my ($mapurl,$resurl,$crstype,$navmap); |
|
|
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
# |
# |
Line 640 sub innerregister {
|
Line 654 sub innerregister {
|
# |
# |
$crstype = &Apache::loncommon::course_type(); |
$crstype = &Apache::loncommon::course_type(); |
if ($env{'request.symb'}) { |
if ($env{'request.symb'}) { |
($mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread()); |
my $ignorenull; |
|
unless ($env{'request.noversionuri'} eq '/adm/navmaps') { |
|
$ignorenull = 1; |
|
} |
|
my $symb = &Apache::lonnet::symbread('','',$ignorenull); |
|
($mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb($symb); |
my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'}; |
my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'}; |
|
|
my $maptitle = &Apache::lonnet::gettitle($mapurl); |
my $maptitle = &Apache::lonnet::gettitle($mapurl); |
my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread()); |
my $restitle = &Apache::lonnet::gettitle($symb); |
my @crumbs; |
my (@crumbs,@mapcrumbs); |
|
if (($env{'request.noversionuri'} ne '/adm/navmaps') && ($mapurl ne '')) { |
|
$navmap = Apache::lonnavmaps::navmap->new(); |
|
if (ref($navmap)) { |
|
@mapcrumbs = $navmap->recursed_crumbs($mapurl); |
|
} |
|
} |
unless (($forcereg) && |
unless (($forcereg) && |
($env{'request.noversionuri'} eq '/adm/navmaps') && |
($env{'request.noversionuri'} eq '/adm/navmaps') && |
($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'}) || |
($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'}) || |
Line 654 sub innerregister {
|
Line 679 sub innerregister {
|
href => "Javascript:gopost('/adm/navmaps','')"}); |
href => "Javascript:gopost('/adm/navmaps','')"}); |
} |
} |
if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { |
if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { |
push(@crumbs, {text => '...', |
if (@mapcrumbs) { |
no_mt => 1}); |
push(@crumbs,@mapcrumbs); |
|
} else { |
|
push(@crumbs, {text => '...', |
|
no_mt => 1}); |
|
} |
} |
} |
|
|
unless (($crstype eq 'Placement') || (!$env{'request.role.adv'})) { |
unless ((($crstype eq 'Placement') && (!$env{'request.role.adv'})) || (@mapcrumbs) || |
push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle |
(!$maptitle) || ($maptitle eq 'default.sequence') || |
&& $maptitle ne 'default.sequence' |
($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) { |
&& $maptitle ne $coursetitle); |
push @crumbs, {text => $maptitle, no_mt => 1, href => $mapurl}; |
} |
} |
|
|
push @crumbs, {text => $restitle, no_mt => 1} if $restitle; |
push @crumbs, {text => $restitle, no_mt => 1} if $restitle; |
Line 689 sub innerregister {
|
Line 718 sub innerregister {
|
} |
} |
my $trail; |
my $trail; |
if ($env{'form.folderpath'}) { |
if ($env{'form.folderpath'}) { |
&prepare_functions($resurl,$forcereg,$group,undef,undef,1); |
&prepare_functions($resurl,$forcereg,$group,undef,undef,1,$hostname); |
($trail) = |
($trail) = |
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1); |
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1); |
} else { |
} else { |
Line 704 sub innerregister {
|
Line 733 sub innerregister {
|
} elsif ($resurl =~ m{^\Q/uploaded$courseurl/portfolio/syllabus/}) { |
} elsif ($resurl =~ m{^\Q/uploaded$courseurl/portfolio/syllabus/}) { |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&prepare_functions('/public'.$courseurl."/syllabus", |
&prepare_functions('/public'.$courseurl."/syllabus", |
$forcereg,$group,undef,undef,1); |
$forcereg,$group,undef,undef,1,$hostname); |
$title = &mt('Syllabus File'); |
$title = &mt('Syllabus File'); |
my ($trail) = |
my ($trail) = |
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1); |
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,$hostname); |
return $trail; |
return $trail; |
} |
} |
unless ($env{'request.state'} eq 'construct') { |
unless ($env{'request.state'} eq 'construct') { |
Line 731 sub innerregister {
|
Line 760 sub innerregister {
|
$forceview,$editbutton); |
$forceview,$editbutton); |
if (($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) || |
if (($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) || |
($env{'request.role'} !~/^(aa|ca|au)/)) { |
($env{'request.role'} !~/^(aa|ca|au)/)) { |
$editbutton = &prepare_functions($resurl,$forcereg,$group); |
$editbutton = &prepare_functions($resurl,$forcereg,$group,'','','',$hostname); |
} |
} |
if ($editbutton eq '') { |
if ($editbutton eq '') { |
$editbutton = &clear(6,1); |
$editbutton = &clear(6,1); |
Line 744 sub innerregister {
|
Line 773 sub innerregister {
|
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'}); |
$perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'}); |
|
$perms{'cev'} = &Apache::lonnet::allowed('cev',$env{'request.course.id'}); |
my @privs; |
my @privs; |
if ($env{'request.symb'} ne '') { |
if ($env{'request.symb'} ne '') { |
if ($env{'request.filename'}=~/$LONCAPA::assess_re/) { |
if ($env{'request.filename'}=~/$LONCAPA::assess_re/) { |
push(@privs,('mgr','vgr')); |
push(@privs,('mgr','vgr')); |
} |
} |
push(@privs,'opa'); |
push(@privs,('opa','vpa')); |
} |
} |
foreach my $priv (@privs) { |
foreach my $priv (@privs) { |
$perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'}); |
$perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'}); |
Line 773 sub innerregister {
|
Line 803 sub innerregister {
|
'Content Submissions'); |
'Content Submissions'); |
} |
} |
} |
} |
if (($env{'request.symb'} ne '') && ($perms{'opa'})) { |
if (($env{'request.symb'} ne '') && (($perms{'opa'}) || ($perms{'vpa'}))) { |
&switch('','',7,3,'pparm.png','Content Settings','parms[_2]', |
&switch('','',7,3,'pparm.png','Content Settings','parms[_2]', |
"gocmd('/adm/parmset','set')", |
"gocmd('/adm/parmset','set')", |
'Content Settings'); |
'Content Settings'); |
Line 783 sub innerregister {
|
Line 813 sub innerregister {
|
# |
# |
# This applies to items inside a folder/page modifiable in the course. |
# This applies to items inside a folder/page modifiable in the course. |
# |
# |
if (($env{'request.symb'}=~/^uploaded/) && ($perms{'mdc'})) { |
if (($env{'request.symb'}=~/^uploaded/) && (($perms{'mdc'}) || ($perms{'cev'}))) { |
my $text = 'Edit Folder'; |
my $text = 'Edit Folder'; |
if (($mapurl =~ /\.page$/) || |
if (($mapurl =~ /\.page$/) || |
($env{'request.symb'}=~ |
($env{'request.symb'}=~ |
Line 877 ENDMENUITEMS
|
Line 907 ENDMENUITEMS
|
$got_prt = 1; |
$got_prt = 1; |
if (($env{'user.adv'}) && ($env{'request.uri'} =~ /^\/res/) |
if (($env{'user.adv'}) && ($env{'request.uri'} =~ /^\/res/) |
&& (!$env{'request.enc'})) { |
&& (!$env{'request.enc'})) { |
# wishlist is only available for users with access to resource-pool |
my ($cnum,$cdom) = &Apache::loncommon::crsauthor_url($env{'request.uri'}); |
# and links can only be set for resources within the resource-pool |
unless ($cnum) { |
$menuitems .= (<<ENDMENUITEMS); |
# wishlist is only available for users with access to resource-pool |
|
# and links can only be set for resources within the resource-pool |
|
$menuitems .= (<<ENDMENUITEMS); |
s&9&1&wishlist-link.png&Stored Links&wishlistlink[_2]&set_wishlistlink()&Save a link for this resource in my personal Stored Links repository&&1 |
s&9&1&wishlist-link.png&Stored Links&wishlistlink[_2]&set_wishlistlink()&Save a link for this resource in my personal Stored Links repository&&1 |
ENDMENUITEMS |
ENDMENUITEMS |
$got_wishlist = 1; |
$got_wishlist = 1; |
|
} |
} |
} |
|
|
my $currentURL = &Apache::loncommon::get_symb(); |
my $currentURL = &Apache::loncommon::get_symb(); |
Line 901 if ($env{'browser.mobile'}) {
|
Line 934 if ($env{'browser.mobile'}) {
|
$is_mobile = 1; |
$is_mobile = 1; |
} |
} |
|
|
unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio|exttools?)(\?|$)/) { |
unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio|ext\.tool)(\?|$)/) { |
if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/docs/})) { |
if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/docs/})) { |
$menuitems.=(<<ENDREALRES); |
$menuitems.=(<<ENDREALRES); |
s&6&3&catalog.png&Info&info[_1]&catalog_info('$is_mobile')&Show Metadata |
s&6&3&catalog.png&Info&info[_1]&catalog_info('$is_mobile')&Show Metadata |
Line 964 ENDMENUITEMS
|
Line 997 ENDMENUITEMS
|
foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} } |
foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} } |
|
|
if ($addremote) { |
if ($addremote) { |
my $countdown; |
my ($countdown,$buttonshide); |
if ($env{'request.filename'} =~ /\.page$/) { |
if ($env{'request.filename'} =~ /\.page$/) { |
my %breadcrumb_tools = &Apache::lonhtmlcommon::current_breadcrumb_tools(); |
my %breadcrumb_tools = &Apache::lonhtmlcommon::current_breadcrumb_tools(); |
if (ref($breadcrumb_tools{'tools'}) eq 'ARRAY') { |
if (ref($breadcrumb_tools{'tools'}) eq 'ARRAY') { |
$countdown = $breadcrumb_tools{'tools'}[0]; |
$countdown = $breadcrumb_tools{'tools'}->[0]; |
} |
} |
|
$buttonshide = $pagebuttonshide; |
} else { |
} else { |
$countdown = &countdown_timer(); |
$countdown = &countdown_timer(); |
|
$buttonshide = &hidden_button_check(); |
} |
} |
&Apache::lonhtmlcommon::clear_breadcrumb_tools(); |
&Apache::lonhtmlcommon::clear_breadcrumb_tools(); |
|
|
&Apache::lonhtmlcommon::add_breadcrumb_tool( |
&Apache::lonhtmlcommon::add_breadcrumb_tool( |
'navigation', @inlineremote[21,23]); |
'navigation', @inlineremote[21,23]); |
|
|
if (&hidden_button_check() eq 'yes') { |
if ($buttonshide eq 'yes') { |
if ($countdown) { |
if ($countdown) { |
&Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown); |
&Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown); |
} |
} |
Line 1024 ENDMENUITEMS
|
Line 1059 ENDMENUITEMS
|
} |
} |
|
|
sub get_editbutton { |
sub get_editbutton { |
my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg) = @_; |
my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg,$hostname) = @_; |
my $jscall; |
my $jscall; |
if (($forceview) && ($env{'form.todocs'})) { |
if (($forceview) && ($env{'form.todocs'})) { |
my ($folderpath,$command); |
my ($folderpath,$command,$navmap); |
if ($env{'request.symb'}) { |
if ($env{'request.symb'}) { |
$folderpath = &Apache::loncommon::symb_to_docspath($env{'request.symb'}); |
$folderpath = &Apache::loncommon::symb_to_docspath($env{'request.symb'},\$navmap); |
} elsif ($env{'form.folderpath'} =~ /^supplemental/) { |
} elsif ($env{'form.folderpath'} =~ /^supplemental/) { |
$folderpath = $env{'form.folderpath'}; |
$folderpath = $env{'form.folderpath'}; |
$command = '&forcesupplement=1'; |
$command = '&forcesupplement=1'; |
Line 1037 sub get_editbutton {
|
Line 1072 sub get_editbutton {
|
$folderpath = &escape(&HTML::Entities::encode(&escape($folderpath),'<>&"')); |
$folderpath = &escape(&HTML::Entities::encode(&escape($folderpath),'<>&"')); |
$jscall = "go('/adm/coursedocs?folderpath=$folderpath$command')"; |
$jscall = "go('/adm/coursedocs?folderpath=$folderpath$command')"; |
} else { |
} else { |
|
my $suppanchor; |
|
if ($env{'form.folderpath'}) { |
|
$suppanchor = $env{'form.anchor'}; |
|
} |
$jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver, |
$jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver, |
$forceedit,$forcereg,$env{'request.symb'}, |
$forceedit,$forcereg,$env{'request.symb'}, |
&escape($env{'form.folderpath'}), |
&escape($env{'form.folderpath'}), |
&escape($env{'form.title'}),$env{'form.idx'}, |
&escape($env{'form.title'}),$hostname, |
&escape($env{'form.suppurl'},$env{'form.todocs'})); |
$env{'form.idx'},&escape($env{'form.suppurl'}), |
|
$env{'form.todocs'},$suppanchor); |
} |
} |
if ($jscall) { |
if ($jscall) { |
my $icon = 'pcstr.png'; |
my $icon = 'pcstr.png'; |
Line 1058 sub get_editbutton {
|
Line 1098 sub get_editbutton {
|
} |
} |
|
|
sub prepare_functions { |
sub prepare_functions { |
my ($resurl,$forcereg,$group,$bread_crumbs,$advtools,$docscrumbs) = @_; |
my ($resurl,$forcereg,$group,$bread_crumbs,$advtools,$docscrumbs,$hostname) = @_; |
unless ($env{'request.registered'}) { |
unless ($env{'request.registered'}) { |
undef(@inlineremote); |
undef(@inlineremote); |
} |
} |
Line 1104 sub prepare_functions {
|
Line 1144 sub prepare_functions {
|
# This applies in course context |
# This applies in course context |
# |
# |
if (($perms{'mdc'}) && |
if (($perms{'mdc'}) && |
(($resurl eq "/public/$cdom/$cnum/syllabus") || |
(($resurl =~ m{^/?public/$cdom/$cnum/syllabus}) || |
($resurl =~ m{^/uploaded/$cdom/$cnum/portfolio/syllabus/}))) { |
($resurl =~ m{^/?uploaded/$cdom/$cnum/portfolio/syllabus/}) || |
$cfile = $resurl; |
(($resurl =~ m{^/?uploaded/$cdom/$cnum/default_\d+\.sequence$}) && ($env{'form.navmap'})))) { |
|
if ($resurl =~ m{^/}) { |
|
$cfile = $resurl; |
|
} else { |
|
$cfile = "/$resurl"; |
|
} |
$home = &Apache::lonnet::homeserver($cnum,$cdom); |
$home = &Apache::lonnet::homeserver($cnum,$cdom); |
if ($env{'form.forceedit'}) { |
if ($env{'form.forceedit'}) { |
$forceview = 1; |
$forceview = 1; |
} else { |
} else { |
$forceedit = 1; |
$forceedit = 1; |
} |
} |
$editbutton = &get_editbutton($cfile,$home,$switchserver, |
if ($cfile =~ m{^/uploaded/$cdom/$cnum/default_\d+\.sequence$}) { |
$forceedit,$forceview,$forcereg); |
my $text = 'Edit Folder'; |
|
&switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]', |
|
"gocmd('/adm/coursedocs','direct')", |
|
'Folder/Page Content'); |
|
$editbutton = 1; |
|
} else { |
|
$editbutton = &get_editbutton($cfile,$home,$switchserver, |
|
$forceedit,$forceview,$forcereg, |
|
$hostname); |
|
} |
} elsif (($resurl eq '/adm/extresedit') && |
} elsif (($resurl eq '/adm/extresedit') && |
(($env{'form.symb'}) || ($env{'form.folderpath'}))) { |
(($env{'form.symb'}) || ($env{'form.folderpath'}))) { |
($cfile,$home,$switchserver,$forceedit,$forceview) = |
($cfile,$home,$switchserver,$forceedit,$forceview) = |
Line 1122 sub prepare_functions {
|
Line 1176 sub prepare_functions {
|
$env{'form.symb'}); |
$env{'form.symb'}); |
if ($cfile ne '') { |
if ($cfile ne '') { |
$editbutton = &get_editbutton($cfile,$home,$switchserver, |
$editbutton = &get_editbutton($cfile,$home,$switchserver, |
$forceedit,$forceview,$forcereg, |
$forceedit,$forceview,$forcereg); |
$env{'form.title'},$env{'form.suppurl'}); |
|
} |
} |
} elsif (($resurl =~ m{^/?adm/viewclasslist$}) && |
} elsif (($resurl =~ m{^/?adm/viewclasslist$}) && |
(&Apache::lonnet::allowed('opa',$env{'request.course.id'}))) { |
(&Apache::lonnet::allowed('opa',$env{'request.course.id'}))) { |
Line 1141 sub prepare_functions {
|
Line 1194 sub prepare_functions {
|
&Apache::lonnet::clutter($resurl),$env{'request.symb'},$group); |
&Apache::lonnet::clutter($resurl),$env{'request.symb'},$group); |
if ($cfile ne '') { |
if ($cfile ne '') { |
$editbutton = &get_editbutton($cfile,$home,$switchserver, |
$editbutton = &get_editbutton($cfile,$home,$switchserver, |
$forceedit,$forceview,$forcereg); |
$forceedit,$forceview,$forcereg, |
|
$hostname); |
} |
} |
} |
} |
} |
} |
Line 1191 sub prepare_functions {
|
Line 1245 sub prepare_functions {
|
if (($env{'form.folderpath'} =~ /^supplemental/) && |
if (($env{'form.folderpath'} =~ /^supplemental/) && |
(&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) && |
(&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) && |
(($resurl =~ m{^/adm/wrapper/ext/}) || |
(($resurl =~ m{^/adm/wrapper/ext/}) || |
($resurl =~ m{^/adm/$cdom/$cnum/\d+/exttools?$}) || |
($resurl =~ m{^/adm/$cdom/$cnum/\d+/ext\.tool$}) || |
($resurl =~ m{^/uploaded/$cdom/$cnum/supplemental/}) || |
($resurl =~ m{^/uploaded/$cdom/$cnum/supplemental/}) || |
($resurl eq '/adm/supplemental') || |
($resurl eq '/adm/supplemental') || |
($resurl =~ m{^/public/$cdom/$cnum/syllabus$}) || |
($resurl =~ m{^/public/$cdom/$cnum/syllabus$}) || |
($resurl =~ m{^/adm/$match_domain/$match_username/aboutme$}))) { |
($resurl =~ m{^/adm/$match_domain/$match_username/aboutme$}))) { |
my @folders=split('&',$env{'form.folderpath'}); |
my @folders=split('&',$env{'form.folderpath'}); |
if ((@folders > 2) || ($resurl ne '/adm/supplemental')) { |
if ((@folders > 2) || ($resurl ne '/adm/supplemental')) { |
|
my $suppanchor; |
|
if ($resurl =~ m{^/adm/wrapper/ext/}) { |
|
$suppanchor = $env{'form.anchor'}; |
|
} |
my $esc_path=&escape(&HTML::Entities::encode(&escape($env{'form.folderpath'}),'<>&"')); |
my $esc_path=&escape(&HTML::Entities::encode(&escape($env{'form.folderpath'}),'<>&"')); |
|
my $link = '/adm/coursedocs?command=direct&forcesupplement=1&supppath='. |
|
"$esc_path&anchor=$suppanchor"; |
|
if ($env{'request.use_absolute'} ne '') { |
|
$link = $env{'request.use_absolute'}.$link; |
|
} |
&switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]', |
&switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]', |
"location.href='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path'", |
"location.href='$link'",'Folder/Page Content'); |
'Folder/Page Content'); |
|
} |
} |
} |
} |
} |
} |
Line 2081 sub roles_selector {
|
Line 2143 sub roles_selector {
|
my ($cdom,$cnum,$httphost) = @_; |
my ($cdom,$cnum,$httphost) = @_; |
my $crstype = &Apache::loncommon::course_type(); |
my $crstype = &Apache::loncommon::course_type(); |
my $now = time; |
my $now = time; |
my (%courseroles,%seccount,%courseprivs); |
my (%courseroles,%seccount,%courseprivs,%roledesc); |
my $is_cc; |
my $is_cc; |
my ($js,$form,$switcher); |
my ($js,$form,$switcher); |
my $ccrole; |
my $ccrole; |
Line 2090 sub roles_selector {
|
Line 2152 sub roles_selector {
|
} else { |
} else { |
$ccrole = 'cc'; |
$ccrole = 'cc'; |
} |
} |
my ($priv,$gotsymb,$destsymb); |
my ($privref,$gotsymb,$destsymb); |
my $destinationurl = $ENV{'REQUEST_URI'}; |
my $destinationurl = $ENV{'REQUEST_URI'}; |
if ($destinationurl =~ /\?symb=/) { |
if ($destinationurl =~ /(\?|\&)symb=/) { |
$gotsymb = 1; |
$gotsymb = 1; |
} elsif ($destinationurl =~ m{^/enc/}) { |
} elsif ($destinationurl =~ m{^/enc/}) { |
my $plainurl = &Apache::lonenc::unencrypted($destinationurl); |
my $plainurl = &Apache::lonenc::unencrypted($destinationurl); |
if ($plainurl =~ /\?symb=/) { |
if ($plainurl =~ /(\?|\&)symb=/) { |
$gotsymb = 1; |
$gotsymb = 1; |
} |
} |
} |
} |
Line 2111 sub roles_selector {
|
Line 2173 sub roles_selector {
|
my $destination = $destinationurl; |
my $destination = $destinationurl; |
$destination =~ s/(\?.*)$//; |
$destination =~ s/(\?.*)$//; |
if (exists($reqprivs->{$destination})) { |
if (exists($reqprivs->{$destination})) { |
$priv = $reqprivs->{$destination}; |
if ($reqprivs->{$destination} =~ /,/) { |
|
@{$privref} = split(/,/,$reqprivs->{$destination}); |
|
} else { |
|
$privref = [$reqprivs->{$destination}]; |
|
} |
} |
} |
} |
} |
if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) { |
if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) { |
my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}); |
my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}); |
|
|
if ((($start) && ($start<0)) || |
if ((($start) && ($start<0)) || |
(($end) && ($end<$now)) || |
(($end) && ($end<$now)) || |
(($start) && ($now<$start))) { |
(($start) && ($now<$start))) { |
Line 2126 sub roles_selector {
|
Line 2191 sub roles_selector {
|
} |
} |
} |
} |
if ($is_cc) { |
if ($is_cc) { |
&get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,$priv); |
&get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs); |
|
} elsif ($env{'request.role'} =~ m{^\Qcr/$cdom/$cdom-domainconfig/\E(\w+)\.\Q/$cdom/$cnum\E}) { |
|
&get_customadhoc_roles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,\%roledesc,$privref); |
} else { |
} else { |
my %gotnosection; |
my %gotnosection; |
foreach my $item (keys(%env)) { |
foreach my $item (keys(%env)) { |
Line 2142 sub roles_selector {
|
Line 2209 sub roles_selector {
|
$gotnosection{$role} = 1; |
$gotnosection{$role} = 1; |
} |
} |
} |
} |
if ($priv ne '') { |
if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0)) { |
my $cnumsec = $cnum; |
my $cnumsec = $cnum; |
if ($sec ne '') { |
if ($sec ne '') { |
$cnumsec .= "/$sec"; |
$cnumsec .= "/$sec"; |
Line 2180 sub roles_selector {
|
Line 2247 sub roles_selector {
|
} |
} |
if ((keys(%seccount) > 1) || ($numdiffsec > 1)) { |
if ((keys(%seccount) > 1) || ($numdiffsec > 1)) { |
my @submenu; |
my @submenu; |
$js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,$priv); |
$js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,\%roledesc,$privref); |
$form = |
$form = |
'<form name="rolechooser" method="post" action="'.$httphost.'/adm/roles">'."\n". |
'<form name="rolechooser" method="post" action="'.$httphost.'/adm/roles">'."\n". |
' <input type="hidden" name="destinationurl" value="'. |
' <input type="hidden" name="destinationurl" value="'. |
Line 2220 sub roles_selector {
|
Line 2287 sub roles_selector {
|
$include = 1; |
$include = 1; |
} |
} |
if ($include) { |
if ($include) { |
|
my $rolename; |
|
if ($role =~ m{^cr/$cdom/$cdom\-domainconfig/(\w+)(?:/\w+|$)}) { |
|
$rolename = $roledesc{$role}; |
|
if ($rolename eq '') { |
|
$rolename = &mt('Helpdesk [_1]',$1); |
|
} |
|
} else { |
|
$rolename = &Apache::lonnet::plaintext($role); |
|
} |
push(@submenu,['javascript:adhocRole('."'$role'".')', |
push(@submenu,['javascript:adhocRole('."'$role'".')', |
&Apache::lonnet::plaintext($role)]); |
$rolename]); |
} |
} |
} |
} |
} |
} |
Line 2302 sub get_all_courseroles {
|
Line 2378 sub get_all_courseroles {
|
return; |
return; |
} |
} |
|
|
|
sub get_customadhoc_roles { |
|
my ($cdom,$cnum,$courseroles,$seccount,$courseprivs,$roledesc,$privref) = @_; |
|
unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') && |
|
(ref($courseprivs) eq 'HASH') && (ref($roledesc) eq 'HASH')) { |
|
return; |
|
} |
|
my $is_helpdesk = 0; |
|
my $now = time; |
|
foreach my $role ('dh','da') { |
|
if ($env{"user.role.$role./$cdom/"}) { |
|
my ($start,$end)=split(/\./,$env{"user.role.$role./$cdom/"}); |
|
if (!($start && ($now<$start)) && !($end && ($now>$end))) { |
|
$is_helpdesk = 1; |
|
last; |
|
} |
|
} |
|
} |
|
if ($is_helpdesk) { |
|
my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($cdom.'_'.$cnum); |
|
my %available; |
|
if (ref($possroles) eq 'ARRAY') { |
|
map { $available{$_} = 1; } @{$possroles}; |
|
} |
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom); |
|
if (ref($domdefaults{'adhocroles'}) eq 'HASH') { |
|
if (keys(%{$domdefaults{'adhocroles'}})) { |
|
my $numsec = 1; |
|
my @sections; |
|
my ($allseclist,$cached) = |
|
&Apache::lonnet::is_cached_new('courseseclist',$cdom.'_'.$cnum); |
|
if (defined($cached)) { |
|
if ($allseclist ne '') { |
|
@sections = split(/,/,$allseclist); |
|
$numsec += scalar(@sections); |
|
} |
|
} else { |
|
my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum); |
|
@sections = sort(keys(%sections_count)); |
|
$numsec += scalar(@sections); |
|
$allseclist = join(',',@sections); |
|
&Apache::lonnet::do_cache_new('courseseclist',$cdom.'_'.$cnum,$allseclist); |
|
} |
|
my (%adhoc,$gotprivs); |
|
my $prefix = "cr/$cdom/$cdom".'-domainconfig'; |
|
foreach my $role (keys(%{$domdefaults{'adhocroles'}})) { |
|
next if (($role eq '') || ($role =~ /\W/)); |
|
$seccount->{"$prefix/$role"} = $numsec; |
|
$roledesc->{"$prefix/$role"} = $description->{$role}; |
|
if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0)) { |
|
if (exists($env{"user.priv.$prefix/$role./$cdom/$cnum./"})) { |
|
$courseprivs->{"$prefix/$role./$cdom/$cnum./"} = |
|
$env{"user.priv.$prefix/$role./$cdom/$cnum./"}; |
|
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/"} = |
|
$env{"user.priv.$prefix/$role./$cdom/$cnum./$cdom/"}; |
|
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/$cnum"} = |
|
$env{"user.priv.$prefix/$role./$cdom/$cnum./$cdom/$cnum"}; |
|
} else { |
|
unless ($gotprivs) { |
|
my ($adhocroles,$privscached) = |
|
&Apache::lonnet::is_cached_new('adhocroles',$cdom); |
|
if ((defined($privscached)) && (ref($adhocroles) eq 'HASH')) { |
|
%adhoc = %{$adhocroles}; |
|
} else { |
|
my $confname = &Apache::lonnet::get_domainconfiguser($cdom); |
|
my %roledefs = &Apache::lonnet::dump('roles',$cdom,$confname,'rolesdef_'); |
|
foreach my $key (keys(%roledefs)) { |
|
(undef,my $rolename) = split(/_/,$key); |
|
if ($rolename ne '') { |
|
my ($systempriv,$domainpriv,$coursepriv) = split(/\_/,$roledefs{$key}); |
|
$coursepriv = &Apache::lonnet::course_adhocrole_privs($rolename,$cdom,$cnum,$coursepriv); |
|
$adhoc{$rolename} = join('_',($systempriv,$domainpriv,$coursepriv)); |
|
} |
|
} |
|
&Apache::lonnet::do_cache_new('adhocroles',$cdom,\%adhoc); |
|
} |
|
$gotprivs = 1; |
|
} |
|
($courseprivs->{"$prefix/$role./$cdom/$cnum./"}, |
|
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/"}, |
|
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/$cnum"}) = |
|
split(/\_/,$adhoc{$role}); |
|
} |
|
} |
|
if ($available{$role}) { |
|
$courseroles->{"$prefix/$role"} = \@sections; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
sub jump_to_role { |
sub jump_to_role { |
my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$priv) = @_; |
my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$roledesc,$privref) = @_; |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
this => 'This role has section(s) associated with it.', |
this => 'This role has section(s) associated with it.', |
ente => 'Enter a specific section.', |
ente => 'Enter a specific section.', |
Line 2336 sub jump_to_role {
|
Line 2505 sub jump_to_role {
|
} |
} |
} |
} |
my $checkroles = 0; |
my $checkroles = 0; |
if ($priv && ref($courseprivs) eq 'HASH') { |
if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0) && (ref($courseprivs) eq 'HASH')) { |
my (%disallowed,%allowed,@disallow); |
my %disallowed; |
foreach my $role (sort(keys(%{$courseprivs}))) { |
foreach my $role (sort(keys(%{$courseprivs}))) { |
my $trole; |
my $trole; |
if ($role =~ m{^(.+?)\Q./$cdom/$cnum\E}) { |
if ($role =~ m{^(.+?)\Q./$cdom/$cnum\E}) { |
$trole = $1; |
$trole = $1; |
} |
} |
if (($trole ne '') && ($trole ne 'cm')) { |
if (($trole ne '') && ($trole ne 'cm')) { |
if ($courseprivs->{$role} =~ /\Q:$priv\E($|:|\&\w+)/) { |
$disallowed{$trole} = 1; |
$allowed{$trole} = 1; |
foreach my $priv (@{$privref}) { |
} else { |
if ($courseprivs->{$role} =~ /\Q:$priv\E($|:|\&\w+)/) { |
$disallowed{$trole} = 1; |
delete($disallowed{$trole}); |
|
last; |
|
} |
} |
} |
} |
} |
} |
} |
foreach my $trole (keys(%disallowed)) { |
if (keys(%disallowed) > 0) { |
unless ($allowed{$trole}) { |
|
push(@disallow,$trole); |
|
} |
|
} |
|
if (@disallow > 0) { |
|
$checkroles = 1; |
$checkroles = 1; |
$js .= " var disallow = new Array('".join("','",@disallow)."');\n". |
$js .= " var disallow = new Array('".join("','",keys(%disallowed))."');\n". |
" var rolecheck = 1;\n"; |
" var rolecheck = 1;\n"; |
} |
} |
} |
} |
Line 2455 END
|
Line 2621 END
|
|
|
sub required_privs { |
sub required_privs { |
my $privs = { |
my $privs = { |
'/adm/parmset' => 'opa', |
'/adm/parmset' => 'opa,vpa', |
'/adm/courseprefs' => 'opa', |
'/adm/courseprefs' => 'opa,vpa', |
'/adm/whatsnew' => 'whn', |
'/adm/whatsnew' => 'whn', |
'/adm/populate' => 'cst', |
'/adm/populate' => 'cst,vpa,vcl', |
'/adm/trackstudent' => 'vsa', |
'/adm/trackstudent' => 'vsa', |
'/adm/statistics' => 'vgr', |
'/adm/statistics' => 'mgr,vgr', |
'/adm/setblock' => 'dcm', |
'/adm/setblock' => 'dcm,vcb', |
'/adm/coursedocs' => 'mdc', |
'/adm/coursedocs' => 'mdc', |
}; |
}; |
unless ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'spreadsheet') { |
unless ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'spreadsheet') { |