version 1.369.2.53, 2014/09/22 01:33:17
|
version 1.369.2.66, 2016/11/29 15:19:49
|
Line 124 dropdown list when mouse hovers over top
|
Line 124 dropdown list when mouse hovers over top
|
(no hover psuedo class) via LC_hoverable class for <li> tag for top- |
(no hover psuedo class) via LC_hoverable class for <li> tag for top- |
level item, which employs jQuery to handle behavior on mouseover. |
level item, which employs jQuery to handle behavior on mouseover. |
|
|
Inputs: 4 - (a) link and (b) target for anchor href in top level item, |
Inputs: 6 - (a) link and (b) target for anchor href in top level item, |
(c) title for text wrapped by anchor tag in top level item. |
(c) title for text wrapped by anchor tag in top level item. |
(d) reference to array of arrays of sub-menu items. |
(d) reference to array of arrays of sub-menu items. |
|
(e) boolean to indicate whether to call &mt() to translate |
|
name of menu item, |
|
(f) optional class for <li> element in primary menu, for which |
|
sub menu is being generated. |
|
|
|
The underlying datastructure used in (d) contains data from mydesk.tab. |
|
It consists of an array which has an array for each item appearing in |
|
the menu (e.g. [["link", "title", "condition"]] for a single-item menu). |
|
create_submenu() supports also the creation of XHTML for nested dropdown |
|
menus represented by unordered lists. This is done by replacing the |
|
scalar used for the link with an arrayreference containing the menuitems |
|
for the nested menu. This can be done recursively so that the next menu |
|
may also contain nested submenus. |
|
|
|
Example: |
|
[ # begin of datastructure |
|
["/home/", "Home", "condition1"], # 1st item of the 1st layer menu |
|
[ # 2nd item of the 1st layer menu |
|
[ # anon. array for nested menu |
|
["/path1", "Path1", undef], # 1st item of the 2nd layer menu |
|
["/path2", "Path2", undef], # 2nd item of the 2nd layer menu |
|
[ # 3rd item of the 2nd layer menu |
|
[[...], [...], ..., [...]], # containing another menu layer |
|
"Sub-Sub-Menu", # title for this container |
|
undef |
|
] |
|
], # end of array/nested menu |
|
"Sub-Menu", # title for the container item |
|
undef |
|
] # end of 2nd item of the 1st layer menu |
|
] |
|
|
|
|
=item innerregister() |
=item innerregister() |
|
|
Line 281 sub primary_menu {
|
Line 313 sub primary_menu {
|
push(@primsub,$item); |
push(@primsub,$item); |
} |
} |
if (@primsub > 0) { |
if (@primsub > 0) { |
|
if ($title eq 'Personal' && $env{'user.name'} && $env{'user.domain'} ) { |
|
$title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'}); |
|
} else { |
|
$title = &mt($title); |
|
} |
$menu{$position} .= &create_submenu($link,$target,$title,\@primsub,1); |
$menu{$position} .= &create_submenu($link,$target,$title,\@primsub,1); |
} elsif ($link) { |
} elsif ($link) { |
$menu{$position} .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>'; |
$menu{$position} .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>'; |
Line 353 sub secondary_menu {
|
Line 390 sub secondary_menu {
|
} |
} |
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 376 sub secondary_menu {
|
Line 415 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 416 sub secondary_menu {
|
Line 455 sub secondary_menu {
|
&& $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] eq 'nvcg' |
next if $$menuitem[4] eq 'nvcg' |
&& ($canviewgrps || !%groups); |
&& ($canviewgrps || !%groups); |
next if $$menuitem[4] eq 'showsyllabus' |
next if $$menuitem[4] eq 'showsyllabus' |
Line 454 sub secondary_menu {
|
Line 493 sub secondary_menu {
|
if (ref($item) eq 'ARRAY') { |
if (ref($item) eq 'ARRAY') { |
next if ($item->[2] eq 'vgr' && !$canvgr); |
next if ($item->[2] eq 'vgr' && !$canvgr); |
next if ($item->[2] eq 'opa' && !$canmodpara); |
next if ($item->[2] eq 'opa' && !$canmodpara); |
next if ($item->[2] eq 'cst' && !$canmodifyuser); |
next if ($item->[2] eq 'vpa' && !$canviewpara); |
|
next if ($item->[2] eq 'viewusers' && !($canmodifyuser || $canviewusers)); |
next if ($item->[2] eq 'mgr' && !$canmgr); |
next if ($item->[2] eq 'mgr' && !$canmgr); |
next if ($item->[2] eq 'vcg' && !$canviewgrps); |
next if ($item->[2] eq 'vcg' && !$canviewgrps); |
next if ($item->[2] eq 'mdc' && !$canedit); |
next if ($item->[2] eq 'mdc' && !$canedit); |
Line 525 sub secondary_menu {
|
Line 565 sub secondary_menu {
|
} |
} |
|
|
sub create_submenu { |
sub create_submenu { |
my ($link,$target,$title,$submenu,$translate) = @_; |
my ($link,$target,$title,$submenu,$translate,$addclass) = @_; |
return unless (ref($submenu) eq 'ARRAY'); |
return unless (ref($submenu) eq 'ARRAY'); |
my $disptarget; |
my $disptarget; |
if ($target ne '') { |
if ($target ne '') { |
$disptarget = ' target="'.$target.'"'; |
$disptarget = ' target="'.$target.'"'; |
} |
} |
my $name; |
my $menu = '<li class="LC_hoverable '.$addclass.'">'. |
if ($title eq 'Personal') { |
|
if ($env{'user.name'} && $env{'user.domain'}) { |
|
$name = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'}); |
|
} else { |
|
$name = &mt($title); |
|
} |
|
} else { |
|
$name = &mt($title); |
|
} |
|
my $menu = '<li class="LC_hoverable">'. |
|
'<a href="'.$link.'"'.$disptarget.'>'. |
'<a href="'.$link.'"'.$disptarget.'>'. |
'<span class="LC_nobreak">'.$name. |
'<span class="LC_nobreak">'.$title. |
'<span class="LC_fontsize_small" style="font-weight:normal;">'. |
'<span class="LC_fontsize_small" style="font-weight:normal;">'. |
' ▼</span></span></a>'. |
' ▼</span></span></a>'. |
'<ul>'; |
'<ul>'; |
|
|
|
# $link and $title are only used in the initial string written in $menu |
|
# as seen above, not needed for nested submenus |
|
$menu .= &build_submenu($target, $submenu, $translate, '1'); |
|
$menu .= '</ul></li>'; |
|
|
|
return $menu; |
|
} |
|
|
|
# helper routine for create_submenu |
|
# build the dropdown (and nested submenus) recursively |
|
# see perldoc create_submenu documentation for further information |
|
sub build_submenu { |
|
my ($target, $submenu, $translate, $first_level) = @_; |
|
unless (@{$submenu}) { |
|
return ''; |
|
} |
|
|
|
my $menu = ''; |
my $count = 0; |
my $count = 0; |
my $numsub = scalar(@{$submenu}); |
my $numsub = scalar(@{$submenu}); |
foreach my $item (@{$submenu}) { |
foreach my $item (@{$submenu}) { |
$count ++; |
$count ++; |
if (ref($item) eq 'ARRAY') { |
if (ref($item) eq 'ARRAY') { |
my $href = $item->[0]; |
my $href = $item->[0]; |
if ($href =~ /(aboutme|rss\.html)$/) { |
my $bordertop; |
next unless (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')); |
|
$href =~ s/\[domain\]/$env{'user.domain'}/g; |
|
$href =~ s/\[user\]/$env{'user.name'}/g; |
|
} |
|
my $borderbot; |
my $borderbot; |
if ($count == $numsub) { |
my $title; |
$borderbot = 'border-bottom:1px solid black;'; |
|
} |
|
unless (($href eq '') || ($href =~ /^\#/)) { |
|
$target = ' target="_top"'; |
|
} |
|
$menu .= '<li style="margin:0;padding:0;'. |
|
$borderbot.'"><a href="'.$href.'"'.$target.'>'; |
|
if ($translate) { |
if ($translate) { |
$menu .= &mt($item->[1]); |
$title = &mt($item->[1]); |
} else { |
} else { |
$menu .= $item->[1]; |
$title = $item->[1]; |
|
} |
|
|
|
if ($count == 1 && !$first_level) { |
|
$bordertop = 'border-top: 1px solid black;'; |
|
} |
|
if ($count == $numsub) { |
|
$borderbot = 'border-bottom: 1px solid black;'; |
|
} |
|
|
|
# href is a reference to another submenu |
|
if (ref($href) eq 'ARRAY') { |
|
$menu .= '<li style="margin:0;padding:0;'.$bordertop . $borderbot . '">'; |
|
$menu .= '<p><span class="LC_primary_menu_innertitle">' |
|
. $title . '</span><span class="LC_primary_menu_innerarrow">▶</span></p>'; |
|
$menu .= '<ul>'; |
|
$menu .= &build_submenu($target, $href, $translate); |
|
$menu .= '</ul>'; |
|
$menu .= '</li>'; |
|
} else { # href is the actual hyperlink and does not represent another submenu |
|
# for the current menu title |
|
if ($href =~ /(aboutme|rss\.html)$/) { |
|
next unless (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')); |
|
$href =~ s/\[domain\]/$env{'user.domain'}/g; |
|
$href =~ s/\[user\]/$env{'user.name'}/g; |
|
} |
|
unless (($href eq '') || ($href =~ /^\#/)) { |
|
$target = ' target="_top"'; |
|
} |
|
|
|
$menu .= '<li style="margin:0;padding:0;'. $bordertop . $borderbot .'">'; |
|
$menu .= '<a href="'.$href.'"'.$target.'>' . $title . '</a>'; |
|
$menu .= '</li>'; |
} |
} |
$menu .= '</a></li>'; |
|
} |
} |
} |
} |
$menu .= '</ul></li>'; |
|
return $menu; |
return $menu; |
} |
} |
|
|
Line 608 sub registerurl {
|
Line 677 sub registerurl {
|
} |
} |
|
|
sub innerregister { |
sub innerregister { |
my ($forcereg,$bread_crumbs,$group) = @_; |
my ($forcereg,$bread_crumbs,$group,$pagebuttonshide) = @_; |
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 660 sub innerregister {
|
Line 729 sub innerregister {
|
&& $maptitle ne 'default.sequence' |
&& $maptitle ne 'default.sequence' |
&& $maptitle ne $coursetitle); |
&& $maptitle ne $coursetitle); |
|
|
push @crumbs, {text => $restitle, no_mt => 1} if $restitle; |
push @crumbs, {text => $restitle, no_mt => 1} if $restitle; |
|
my @tools; |
|
if ($env{'request.filename'} =~ /\.page$/) { |
|
my %breadcrumb_tools = &Apache::lonhtmlcommon::current_breadcrumb_tools(); |
|
if (ref($breadcrumb_tools{'tools'}) eq 'ARRAY') { |
|
@tools = @{$breadcrumb_tools{'tools'}}; |
|
} |
|
} |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::add_breadcrumb(@crumbs); |
&Apache::lonhtmlcommon::add_breadcrumb(@crumbs); |
|
if (@tools) { |
|
&Apache::lonhtmlcommon::add_breadcrumb_tool('tools',@tools); |
|
} |
} else { |
} else { |
$resurl = $env{'request.noversionuri'}; |
$resurl = $env{'request.noversionuri'}; |
my $courseurl = &Apache::lonnet::courseid_to_courseurl($env{'request.course.id'}); |
my $courseurl = &Apache::lonnet::courseid_to_courseurl($env{'request.course.id'}); |
Line 744 sub innerregister {
|
Line 823 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 775 sub innerregister {
|
Line 855 sub innerregister {
|
'Content Submissions'); |
'Content Submissions'); |
} |
} |
} |
} |
if (($env{'request.symb'} ne '') && ($perms{'opa'})) { |
if (($env{'request.symb'} ne '') && (($perms{'opa'}) || ($perms{'vpa'}))) { |
$hwkadd .= &switch('','',7,3,'pparm.png','Content Settings', |
$hwkadd .= &switch('','',7,3,'pparm.png','Content Settings', |
'parms[_2]',"gocmd('/adm/parmset','set')", |
'parms[_2]',"gocmd('/adm/parmset','set')", |
'Content Settings'); |
'Content Settings'); |
Line 785 sub innerregister {
|
Line 865 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 813 sub innerregister {
|
Line 893 sub innerregister {
|
my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn; |
my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn; |
if ($currdir =~ m-/$-) { |
if ($currdir =~ m-/$-) { |
$is_const_dir = 1; |
$is_const_dir = 1; |
|
if ($thisdisfn eq '') { |
|
$is_const_dir = 2; |
|
} |
} else { |
} else { |
$currdir =~ s|[^/]+$||; |
$currdir =~ s|[^/]+$||; |
my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn); |
my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn); |
Line 860 ENDMENUITEMS
|
Line 943 ENDMENUITEMS
|
# wishlist is only available for users with access to resource-pool |
# wishlist is only available for users with access to resource-pool |
# and links can only be set for resources within the resource-pool |
# and links can only be set for resources within the resource-pool |
$menuitems .= (<<ENDMENUITEMS); |
$menuitems .= (<<ENDMENUITEMS); |
s&9&1&alnk.png&$swtext{'alnk'}&linkstor[_1]&set_wishlistlink()&Save a link for this resource in my personal Stored Links repository&&1 |
s&9&1&alnk.png&$swtext{'alnk'}&linkstor[_1]&set_wishlistlink('',currentURL)&Save a link for this resource in my personal Stored Links repository&&1 |
ENDMENUITEMS |
ENDMENUITEMS |
$got_wishlist = 1; |
$got_wishlist = 1; |
} |
} |
Line 911 ENDMENUITEMS
|
Line 994 ENDMENUITEMS
|
if (($env{'user.adv'}) && (!$env{'request.enc'})) { |
if (($env{'user.adv'}) && (!$env{'request.enc'})) { |
# wishlist is only available for users with access to resource-pool |
# wishlist is only available for users with access to resource-pool |
$menuitems .= (<<ENDMENUITEMS); |
$menuitems .= (<<ENDMENUITEMS); |
s&9&1&alnk.png&$swtext{'alnk'}&linkstor[_1]&set_wishlistlink()&Save a link for this resource in your personal Stored Links repository&&1 |
s&9&1&alnk.png&$swtext{'alnk'}&linkstor[_1]&set_wishlistlink('',currentURL)&Save a link for this resource in your personal Stored Links repository&&1 |
ENDMENUITEMS |
ENDMENUITEMS |
$got_wishlist = 1; |
$got_wishlist = 1; |
} |
} |
Line 949 ENDMENUITEMS
|
Line 1032 ENDMENUITEMS
|
my $addremote=0; |
my $addremote=0; |
foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} } |
foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} } |
if ($addremote) { |
if ($addremote) { |
|
my ($countdown,$buttonshide); |
|
if ($env{'request.filename'} =~ /\.page$/) { |
|
my %breadcrumb_tools = &Apache::lonhtmlcommon::current_breadcrumb_tools(); |
|
if (ref($breadcrumb_tools{'tools'}) eq 'ARRAY') { |
|
$countdown = $breadcrumb_tools{'tools'}->[0]; |
|
} |
|
$buttonshide = $pagebuttonshide; |
|
} else { |
|
$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]); |
|
|
my $countdown = &countdown_timer(); |
if ($buttonshide eq 'yes') { |
if (&hidden_button_check() eq 'yes') { |
|
if ($countdown) { |
if ($countdown) { |
&Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown); |
&Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown); |
} |
} |
Line 979 ENDMENUITEMS
|
Line 1072 ENDMENUITEMS
|
&advtools_crumbs(@inlineremote); |
&advtools_crumbs(@inlineremote); |
} |
} |
} |
} |
|
my ($topic_help,$topic_help_text); |
|
if ($is_const_dir == 2) { |
|
if ((($ENV{'SERVER_PORT'} == 443) || |
|
($Apache::lonnet::protocol{$Apache::lonnet::perlvar{'lonHostID'}} eq 'https')) && |
|
(&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},'webdav'))) { |
|
$topic_help = 'Authoring_WebDAV,Authoring_WebDAV_Mac_10v6,Authoring_WebDAV_Mac_10v10,'. |
|
'Authoring_WebDAV_Windows_v7,Authoring_WebDAV_Linux_Centos'; |
|
$topic_help_text = 'About WebDAV access'; |
|
} |
|
} |
return &Apache::lonhtmlcommon::scripttag('', 'start') |
return &Apache::lonhtmlcommon::scripttag('', 'start') |
. &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0) |
. &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'','','','',$topic_help,$topic_help_text) |
. &Apache::lonhtmlcommon::scripttag('', 'end'); |
. &Apache::lonhtmlcommon::scripttag('', 'end'); |
|
|
} else { |
} else { |
Line 1299 sub get_editbutton {
|
Line 1402 sub get_editbutton {
|
my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg) = @_; |
my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg) = @_; |
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 1309 sub get_editbutton {
|
Line 1412 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'}),$env{'form.idx'}, |
&escape($env{'form.suppurl'},$env{'form.todocs'})); |
&escape($env{'form.suppurl'}),$env{'form.todocs'}, |
|
$suppanchor); |
} |
} |
if ($jscall) { |
if ($jscall) { |
my $icon = 'pcstr.png'; |
my $icon = 'pcstr.png'; |
Line 1485 sub prepare_functions {
|
Line 1593 sub prepare_functions {
|
($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'}),'<>&"')); |
&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='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path&anchor=$suppanchor'", |
'Folder/Page Content','','',1); |
'Folder/Page Content','','',1); |
} |
} |
} |
} |
Line 2249 sub roles_selector {
|
Line 2361 sub roles_selector {
|
my $now = time; |
my $now = time; |
my (%courseroles,%seccount,%courseprivs); |
my (%courseroles,%seccount,%courseprivs); |
my $is_cc; |
my $is_cc; |
my ($js,$form,$switcher,$switchtext); |
my ($js,$form,$switcher); |
my $ccrole; |
my $ccrole; |
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
$ccrole = 'co'; |
$ccrole = 'co'; |
} 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; |
Line 2277 sub roles_selector {
|
Line 2389 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 2292 sub roles_selector {
|
Line 2407 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,$privref); |
} else { |
} else { |
my %gotnosection; |
my %gotnosection; |
foreach my $item (keys(%env)) { |
foreach my $item (keys(%env)) { |
Line 2308 sub roles_selector {
|
Line 2425 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 2337 sub roles_selector {
|
Line 2454 sub roles_selector {
|
} |
} |
} |
} |
} |
} |
$switchtext = 'Switch role'; # do not translate here |
|
my @roles_order = ($ccrole,'in','ta','ep','ad','st'); |
my @roles_order = ($ccrole,'in','ta','ep','ad','st'); |
my $numdiffsec; |
my $numdiffsec; |
if (keys(%seccount) == 1) { |
if (keys(%seccount) == 1) { |
Line 2347 sub roles_selector {
|
Line 2463 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,$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 2387 sub roles_selector {
|
Line 2503 sub roles_selector {
|
$include = 1; |
$include = 1; |
} |
} |
if ($include) { |
if ($include) { |
|
my $rolename; |
|
if ($role =~ m{^cr/$cdom/$cdom\-domainconfig/(\w+)(?:/\w+|$)}) { |
|
$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]); |
} |
} |
} |
} |
} |
} |
if (@submenu > 0) { |
if (@submenu > 0) { |
$switcher = &create_submenu('','',$switchtext,\@submenu); |
$switcher = &create_submenu('','',&mt('Switch role'),\@submenu); |
} |
} |
} |
} |
return ($js,$form,$switcher); |
return ($js,$form,$switcher); |
Line 2469 sub get_all_courseroles {
|
Line 2591 sub get_all_courseroles {
|
return; |
return; |
} |
} |
|
|
|
sub get_customadhoc_roles { |
|
my ($cdom,$cnum,$courseroles,$seccount,$courseprivs,$privref) = @_; |
|
unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') && |
|
(ref($courseprivs) eq 'HASH')) { |
|
return; |
|
} |
|
if ($env{'environment.adhocroles.'.$cdom} ne '') { |
|
my @customroles = split(/,/,$env{'environment.adhocroles.'.$cdom}); |
|
if (@customroles > 1) { |
|
if ($env{"user.role.dh./$cdom/"}) { |
|
my ($start,$end)=split(/\./,$env{"user.role.dh./$cdom/"}); |
|
my $now = time; |
|
if (!($start && ($now<$start)) & !($end && ($now>$end))) { |
|
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); |
|
$numsec += scalar(keys(%sections_count)); |
|
$allseclist = join(',',sort(keys(%sections_count))); |
|
&Apache::lonnet::do_cache_new('courseseclist',$cdom.'_'.$cnum,$allseclist); |
|
} |
|
my (%adhoc,$gotprivs); |
|
my $prefix = "cr/$cdom/$cdom".'-domainconfig'; |
|
foreach my $role (@customroles) { |
|
next if (($role eq '') || ($role =~ /\W/)); |
|
$seccount->{"$prefix/$role"} = $numsec; |
|
$courseroles->{"$prefix/$role"} = \@sections; |
|
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 '') { |
|
$adhoc{$rolename} = $roledefs{$key}; |
|
} |
|
} |
|
&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}); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
sub jump_to_role { |
sub jump_to_role { |
my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$priv) = @_; |
my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$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 2503 sub jump_to_role {
|
Line 2700 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 2623 END
|
Line 2817 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') { |