version 1.502, 2020/02/18 23:10:53
|
version 1.519, 2022/05/28 15:55:34
|
Line 99 It gets filled in the BEGIN block of thi
|
Line 99 It gets filled in the BEGIN block of thi
|
|
|
=over |
=over |
|
|
=item prep_menuitems(\@menuitem,$ltitarget) |
=item prep_menuitems(\@menuitem,$ltitarget,$deeplinktarget,$listclass,$linkattr) |
|
|
This routine wraps a menuitem in proper HTML. It is used by primary_menu() and |
This routine wraps a menuitem in proper HTML. It is used by primary_menu() and |
secondary_menu(). |
secondary_menu(). |
Line 220 use vars qw(@desklines %category_names %
|
Line 220 use vars qw(@desklines %category_names %
|
my @inlineremote; |
my @inlineremote; |
|
|
sub prep_menuitem { |
sub prep_menuitem { |
my ($menuitem,$ltitarget) = @_; |
my ($menuitem,$ltitarget,$deeplinktarget,$listclass,$linkattr) = @_; |
return '' unless(ref($menuitem) eq 'ARRAY'); |
return '' unless(ref($menuitem) eq 'ARRAY'); |
my $link; |
my $link; |
if ($$menuitem[1]) { # graphical Link |
if ($$menuitem[1]) { # graphical Link |
Line 233 sub prep_menuitem {
|
Line 233 sub prep_menuitem {
|
my $target = ' target="_top"'; |
my $target = ' target="_top"'; |
if ($ltitarget eq 'iframe') { |
if ($ltitarget eq 'iframe') { |
$target =''; |
$target =''; |
|
} elsif ($deeplinktarget eq '_self') { |
|
$target = ' target="'.$deeplinktarget.'"'; |
} |
} |
return '<li><a' |
return ($listclass?'<li class="'.$listclass.'">':'<li>').'<a' |
# highlighting for new messages |
# highlighting for new messages |
. ( $$menuitem[4] eq 'newmsg' ? ' class="LC_new_message"' : '') |
. ( $$menuitem[4] eq 'newmsg' ? ' class="LC_new_message"' : '') |
. qq| href="$$menuitem[0]"$target>$link</a></li>|; |
. qq| href="$$menuitem[0]"$target $linkattr>$link</a></li>|; |
} |
} |
|
|
# primary_menu() evaluates @primary_menu and returns a two item array, |
# primary_menu() evaluates @primary_menu and returns a two item array, |
Line 247 sub prep_menuitem {
|
Line 249 sub prep_menuitem {
|
# @primary_menu is filled within the BEGIN block of this module with |
# @primary_menu is filled within the BEGIN block of this module with |
# entries from mydesk.tab |
# entries from mydesk.tab |
sub primary_menu { |
sub primary_menu { |
my ($crstype,$ltimenu) = @_; |
my ($crstype,$ltimenu,$menucoll,$menuref,$links_disabled) = @_; |
my (%menu,%ltiexc); |
my (%menu,%ltiexc,%menuopts); |
# each element of @primary contains following array: |
# each element of @primary contains following array: |
# (link url, icon path, alt text, link text, condition, position) |
# (link url, icon path, alt text, link text, condition, position) |
my $public; |
my $public; |
Line 265 sub primary_menu {
|
Line 267 sub primary_menu {
|
my %roles_in_env; |
my %roles_in_env; |
$rolecount = &Apache::lonroles::roles_from_env(\%roles_in_env,$update); |
$rolecount = &Apache::lonroles::roles_from_env(\%roles_in_env,$update); |
} |
} |
my ($lti,$ltitarget); |
my ($lti,$ltitarget,$deeplinktarget); |
if ($env{'request.lti.login'}) { |
if ($env{'request.lti.login'}) { |
$lti = 1; |
$lti = 1; |
$ltitarget = $env{'request.lti.target'}; |
$ltitarget = $env{'request.lti.target'}; |
Line 277 sub primary_menu {
|
Line 279 sub primary_menu {
|
} |
} |
} |
} |
} |
} |
|
if ($env{'request.deeplink.login'}) { |
|
$deeplinktarget = $env{'request.deeplink.target'}; |
|
} |
|
if (($menucoll) && (ref($menuref) eq 'HASH')) { |
|
%menuopts = %{$menuref}; |
|
} |
foreach my $menuitem (@primary_menu) { |
foreach my $menuitem (@primary_menu) { |
# evaluate conditions |
# evaluate conditions |
next if ref($menuitem) ne 'ARRAY'; # |
next if ref($menuitem) ne 'ARRAY'; # |
Line 292 sub primary_menu {
|
Line 300 sub primary_menu {
|
# users |
# users |
next if $$menuitem[4] eq 'roles' ##show links depending on |
next if $$menuitem[4] eq 'roles' ##show links depending on |
&& (&Apache::loncommon::show_course() ##term 'Courses' or |
&& (&Apache::loncommon::show_course() ##term 'Courses' or |
|| $env{'request.lti.login'}); ##'Roles' wanted |
|| $lti); ##'Roles' wanted |
next if $$menuitem[4] eq 'courses' ##and not LTI access |
next if $$menuitem[4] eq 'courses' ##and not LTI access |
&& (!&Apache::loncommon::show_course() |
&& (!&Apache::loncommon::show_course() |
|| !$env{'request.lti.login'}); |
|| $lti); |
next if $$menuitem[4] eq 'notlti' |
next if $$menuitem[4] eq 'notlti' |
&& $lti; |
&& $lti; |
next if $$menuitem[4] eq 'ltiexc' |
next if $$menuitem[4] eq 'ltiexc' |
Line 312 sub primary_menu {
|
Line 320 sub primary_menu {
|
if ($position eq '') { |
if ($position eq '') { |
$position = 'right'; |
$position = 'right'; |
} |
} |
|
if ($env{'request.course.id'} && $menucoll) { |
|
if (($menuitem->[6]) && (!$menuopts{$menuitem->[6]})) { |
|
if ($menuitem->[6] eq 'pers') { |
|
if ($menuopts{'name'} && !$ltiexc{'fullname'} && |
|
$env{'user.name'} && $env{'user.domain'}) { |
|
$menu{$position} .= '<li><a href="#">'. |
|
&Apache::loncommon::plainname($env{'user.name'}, |
|
$env{'user.domain'}).'</a></li>'; |
|
next; |
|
} else { |
|
next; |
|
} |
|
} else { |
|
next; |
|
} |
|
} |
|
} |
|
my ($listclass,$linkattr); |
|
if ($links_disabled) { |
|
$listclass = 'LCisDisabled'; |
|
$linkattr = 'aria-disabled="true"'; |
|
} |
if (defined($primary_submenu{$title})) { |
if (defined($primary_submenu{$title})) { |
my ($link,$target); |
my ($link,$target); |
if ($menuitem->[0] ne '') { |
if ($menuitem->[0] ne '') { |
$link = $menuitem->[0]; |
$link = $menuitem->[0]; |
unless ($ltitarget eq 'iframe') { |
unless (($ltitarget eq 'iframe') || ($deeplinktarget eq '_self')) { |
$target = '_top'; |
$target = '_top'; |
} |
} |
} else { |
} else { |
Line 331 sub primary_menu {
|
Line 361 sub primary_menu {
|
($item->[2] eq 'blog')) && |
($item->[2] eq 'blog')) && |
(!&Apache::lonnet::usertools_access('','',$item->[2], |
(!&Apache::lonnet::usertools_access('','',$item->[2], |
undef,'tools'))); |
undef,'tools'))); |
|
if ($env{'request.course.id'} && $menucoll) { |
|
next if ($item->[3]) && (!$menuopts{$item->[3]}); |
|
} |
push(@primsub,$item); |
push(@primsub,$item); |
} |
} |
if ($title eq 'Personal' && $env{'user.name'} && $env{'user.domain'} ) { |
if ($title eq 'Personal') { |
unless ($ltiexc{'fullname'}) { |
if ($env{'user.name'} && $env{'user.domain'} && !$ltiexc{'fullname'}) { |
$title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'}); |
unless (($env{'request.course.id'}) && ($menucoll) && (!$menuopts{'name'})) { |
|
$title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'}); |
|
} |
|
} |
|
next if (($env{'request.course.id'}) && ($menucoll) && ($title eq 'Personal') && |
|
(!@primsub)); |
|
if ($title eq 'Personal') { |
|
$title = &mt($title); |
} |
} |
} else { |
} else { |
$title = &mt($title); |
$title = &mt($title); |
} |
} |
if (@primsub > 0) { |
if (@primsub > 0) { |
$menu{$position} .= &create_submenu($link,$target,$title,\@primsub,1); |
$menu{$position} .= &create_submenu($link,$target,$title,\@primsub,1,undef,$listclass,$linkattr); |
} elsif ($link) { |
} elsif ($link) { |
$menu{$position} .= '<li><a href="'.$link.'" target="'.$target.'">'.$title.'</a></li>'; |
$menu{$position} .= ($listclass?'<li class="'.$listclass.'">':'<li>'). |
|
'<a href="'.$link.'" target="'.$target.'" '.$linkattr.'>'.$title.'</a></li>'; |
} |
} |
} |
} |
} elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink |
} elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink |
Line 355 sub primary_menu {
|
Line 396 sub primary_menu {
|
'helpdeskmail', |
'helpdeskmail', |
$defdom,$origmail); |
$defdom,$origmail); |
if ($to ne '') { |
if ($to ne '') { |
$menu{$position} .= &prep_menuitem($menuitem,$ltitarget); |
$menu{$position} .= &prep_menuitem($menuitem,$ltitarget,$deeplinktarget,$listclass,$linkattr); |
} |
} |
} else { |
} else { |
$menu{$position} .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>'; |
$menu{$position} .= ($listclass?'<li class="'.$listclass.'">':'<li>'). |
|
&Apache::loncommon::top_nav_help('Help',$linkattr). |
|
'</li>'; |
|
} |
|
} elsif ($$menuitem[3] eq 'Log In') { |
|
if ($public) { |
|
if (&Apache::lonnet::get_saml_landing()) { |
|
$$menuitem[0] = '/adm/login'; |
|
} |
} |
} |
|
$menu{$position} .= prep_menuitem($menuitem,$ltitarget,$deeplinktarget,$listclass,$linkattr); |
} else { |
} else { |
$menu{$position} .= prep_menuitem($menuitem,$ltitarget); |
$menu{$position} .= prep_menuitem($menuitem,$ltitarget,$deeplinktarget,$listclass,$linkattr); |
} |
} |
} |
} |
my @output = ('',''); |
my @output = ('',''); |
Line 400 sub getauthor{
|
Line 450 sub getauthor{
|
} |
} |
|
|
sub secondary_menu { |
sub secondary_menu { |
my ($httphost,$ltiscope,$ltimenu,$noprimary) = @_; |
my ($httphost,$ltiscope,$ltimenu,$noprimary,$menucoll,$menuref,$links_disabled) = @_; |
my $menu; |
my $menu; |
|
|
my $crstype = &Apache::loncommon::course_type(); |
my $crstype = &Apache::loncommon::course_type(); |
Line 424 sub secondary_menu {
|
Line 474 sub secondary_menu {
|
my $canplc = &Apache::lonnet::allowed('plc', $crs_sec); |
my $canplc = &Apache::lonnet::allowed('plc', $crs_sec); |
my $author = &getauthor(); |
my $author = &getauthor(); |
|
|
my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools,$lti,$ltimapres,%ltiexc); |
my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools, |
|
$lti,$ltimapres,%ltiexc,%menuopts); |
$grouptools = 0; |
$grouptools = 0; |
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'}; |
Line 472 sub secondary_menu {
|
Line 523 sub secondary_menu {
|
} |
} |
} |
} |
} |
} |
|
if (($menucoll) && (ref($menuref) eq 'HASH')) { |
|
%menuopts = %{$menuref}; |
|
} |
|
|
|
my ($listclass,$linkattr); |
|
if ($links_disabled) { |
|
$listclass = 'LCisDisabled'; |
|
$linkattr = 'aria-disabled="true"'; |
|
} |
|
|
my ($canmodifycoauthor); |
my ($canmodifycoauthor); |
if ($env{'request.role'} eq "au./$env{'user.domain'}/") { |
if ($env{'request.role'} eq "au./$env{'user.domain'}/") { |
Line 482 sub secondary_menu {
|
Line 542 sub secondary_menu {
|
} |
} |
} |
} |
|
|
my ($roleswitcher_js,$roleswitcher_form,$ltitarget); |
my ($roleswitcher_js,$roleswitcher_form,$ltitarget,$deeplinktarget); |
if ($env{'request.lti.login'}) { |
if ($env{'request.lti.login'}) { |
$ltitarget = $env{'request.lti.target'}; |
$ltitarget = $env{'request.lti.target'}; |
} |
} |
|
if ($env{'request.deeplink.login'}) { |
|
$deeplinktarget = $env{'request.deeplink.target'}; |
|
} |
|
|
foreach my $menuitem (@secondary_menu) { |
foreach my $menuitem (@secondary_menu) { |
# evaluate conditions |
# evaluate conditions |
Line 534 sub secondary_menu {
|
Line 597 sub secondary_menu {
|
&& $ltiexc{'logout'}; |
&& $ltiexc{'logout'}; |
|
|
my $title = $menuitem->[3]; |
my $title = $menuitem->[3]; |
|
if ($env{'request.course.id'} && $menucoll) { |
|
unless ($$menuitem[5] eq 'roles') { |
|
next if (($$menuitem[5]) && (!$menuopts{$$menuitem[5]})); |
|
} |
|
} |
if (defined($secondary_submenu{$title})) { |
if (defined($secondary_submenu{$title})) { |
my ($link,$target); |
my ($link,$target); |
if ($menuitem->[0] ne '') { |
if ($menuitem->[0] ne '') { |
$link = $menuitem->[0]; |
$link = $menuitem->[0]; |
unless ($ltitarget eq 'iframe') { |
unless (($ltitarget eq 'iframe') || ($deeplinktarget eq '_self')) { |
$target = '_top'; |
$target = '_top'; |
} |
} |
} else { |
} else { |
Line 568 sub secondary_menu {
|
Line 636 sub secondary_menu {
|
push(@scndsub,$item); |
push(@scndsub,$item); |
} |
} |
} |
} |
if ($title eq 'Personal' && $env{'user.name'} && $env{'user.domain'} ) { |
if ($title eq 'Personal' && $env{'user.name'} && $env{'user.domain'}) { |
unless ($ltiexc{'fullname'}) { |
unless ($ltiexc{'fullname'}) { |
$title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'}); |
$title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'}); |
} |
} |
} |
} |
if (@scndsub > 0) { |
if (@scndsub > 0) { |
$menu .= &create_submenu($link,$target,$title,\@scndsub,1); |
$menu .= &create_submenu($link,$target,&mt($title),\@scndsub,1,undef, |
|
$listclass,$linkattr); |
} elsif ($link ne '#') { |
} elsif ($link ne '#') { |
$menu .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>'; |
$menu .= ($listclass?'<li class="'.$listclass.'">':'<li>'). |
|
'<a href="'.$link.'" target="'.$target.'" '.$linkattr.'>'. |
|
&mt($title).'</a></li>'; |
} |
} |
} |
} |
} elsif ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) { |
} elsif ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) { |
# special treatment for role selector |
# special treatment for role selector |
($roleswitcher_js,$roleswitcher_form,my $switcher) = |
my ($switcher,$has_opa_priv); |
|
($roleswitcher_js,$roleswitcher_form,$switcher,$has_opa_priv) = |
&roles_selector( |
&roles_selector( |
$env{'course.' . $env{'request.course.id'} . '.domain'}, |
$env{'course.' . $env{'request.course.id'} . '.domain'}, |
$env{'course.' . $env{'request.course.id'} . '.num'}, |
$env{'course.' . $env{'request.course.id'} . '.num'}, |
$httphost,$ltitarget |
$httphost,$menucoll,$menuref |
); |
); |
|
if (($$menuitem[5]) && (!$menuopts{$$menuitem[5]})) { |
|
next unless ($has_opa_priv); |
|
} |
$menu .= $switcher; |
$menu .= $switcher; |
} elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink |
} elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink |
next if ($crstype eq 'Placement'); |
next if ($crstype eq 'Placement'); |
Line 604 sub secondary_menu {
|
Line 679 sub secondary_menu {
|
} |
} |
if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://}) { |
if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://}) { |
if (($ENV{'SERVER_PORT'} == 443) || ($env{'request.use_absolute'} =~ m{^https://})) { |
if (($ENV{'SERVER_PORT'} == 443) || ($env{'request.use_absolute'} =~ m{^https://})) { |
unless (&Apache::lonnet::uses_sts()) { |
unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl())) { |
unless ($$menuitem[0] =~ m{^https?://}) { |
unless ($$menuitem[0] =~ m{^https?://}) { |
$$menuitem[0] = 'http://'.$ENV{'SERVER_NAME'}.$$menuitem[0]; |
$$menuitem[0] = 'http://'.$ENV{'SERVER_NAME'}.$$menuitem[0]; |
} |
} |
Line 616 sub secondary_menu {
|
Line 691 sub secondary_menu {
|
} |
} |
$$menuitem[0] = &HTML::Entities::encode($$menuitem[0],'&<>"'); |
$$menuitem[0] = &HTML::Entities::encode($$menuitem[0],'&<>"'); |
} |
} |
$menu .= &prep_menuitem(\@$menuitem,$ltitarget); |
$menu .= &prep_menuitem(\@$menuitem,$ltitarget,$deeplinktarget,$listclass,$linkattr); |
} |
} |
} |
} |
if ($menu =~ /\[url\].*\[symb\]/) { |
if ($menu =~ /\[url\].*\[symb\]/) { |
Line 654 sub secondary_menu {
|
Line 729 sub secondary_menu {
|
} |
} |
|
|
sub create_submenu { |
sub create_submenu { |
my ($link,$target,$title,$submenu,$translate,$addclass) = @_; |
my ($link,$target,$title,$submenu,$translate,$addclass,$listclass,$linkattr) = @_; |
return unless (ref($submenu) eq 'ARRAY'); |
return unless (ref($submenu) eq 'ARRAY'); |
my $disptarget; |
my $disptarget; |
if ($target ne '') { |
if ($target ne '') { |
Line 669 sub create_submenu {
|
Line 744 sub create_submenu {
|
|
|
# $link and $title are only used in the initial string written in $menu |
# $link and $title are only used in the initial string written in $menu |
# as seen above, not needed for nested submenus |
# as seen above, not needed for nested submenus |
$menu .= &build_submenu($target, $submenu, $translate, '1'); |
$menu .= &build_submenu($target, $submenu, $translate, '1', $listclass, $linkattr); |
$menu .= '</ul></li>'; |
$menu .= '</ul></li>'; |
|
|
return $menu; |
return $menu; |
Line 679 sub create_submenu {
|
Line 754 sub create_submenu {
|
# build the dropdown (and nested submenus) recursively |
# build the dropdown (and nested submenus) recursively |
# see perldoc create_submenu documentation for further information |
# see perldoc create_submenu documentation for further information |
sub build_submenu { |
sub build_submenu { |
my ($target, $submenu, $translate, $first_level) = @_; |
my ($target, $submenu, $translate, $first_level, $listclass, $linkattr) = @_; |
unless (@{$submenu}) { |
unless (@{$submenu}) { |
return ''; |
return ''; |
} |
} |
Line 744 sub build_submenu {
|
Line 819 sub build_submenu {
|
} |
} |
} |
} |
|
|
$menu .= '<li style="margin:0;padding:0;'. $bordertop . $borderbot .'">'; |
$menu .= '<li '; |
$menu .= '<a href="'.$href.'"'.$target.'>' . $title . '</a>'; |
$menu .= ($listclass?'class="'.$listclass.'" ':''); |
|
$menu .= 'style="margin:0;padding:0;'. $bordertop . $borderbot .'">'; |
|
$menu .= '<a href="'.$href.'"'.$target.' '.$linkattr.'>' . $title . '</a>'; |
$menu .= '</li>'; |
$menu .= '</li>'; |
} |
} |
} |
} |
Line 987 sub innerregister {
|
Line 1064 sub innerregister {
|
$currdir =~ s|[^/]+$||; |
$currdir =~ s|[^/]+$||; |
my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn); |
my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn); |
my $esc_currdir = &Apache::loncommon::escape_single($currdir); |
my $esc_currdir = &Apache::loncommon::escape_single($currdir); |
|
my $pubfile = "/res/$udom/$uname/$thisdisfn"; |
|
my $candelete = 1; |
|
if (-e $londocroot.$pubfile) { |
|
unless (&Apache::lonnet::metadata($pubfile,'obsolete')) { |
|
undef($candelete); |
|
} |
|
} |
# |
# |
# Probably should be in mydesk.tab |
# Probably should be in mydesk.tab |
# |
# |
Line 994 sub innerregister {
|
Line 1078 sub innerregister {
|
s&6&1&list.png&Directory&dir[_1]&golist('$esc_currdir')&List current directory |
s&6&1&list.png&Directory&dir[_1]&golist('$esc_currdir')&List current directory |
s&6&2&rtrv.png&Retrieve&version[_1]&gocstr('/adm/retrieve','/priv/$udom/$uname/$cleandisfn')&Retrieve old version |
s&6&2&rtrv.png&Retrieve&version[_1]&gocstr('/adm/retrieve','/priv/$udom/$uname/$cleandisfn')&Retrieve old version |
s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource |
s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource |
|
s&7&3©.png&Copy&resource[_4]&gocstr('/adm/cfile?action=copy','/priv/$udom/$uname/$cleandisfn')&Copy this resource |
|
ENDMENUITEMS |
|
# |
|
# Rename and Delete only available if obsolete or unpublished |
|
# |
|
if ($candelete) { |
|
$menuitems .= (<<ENDMENUITEMS); |
|
s&7&4&rename.png&Rename&resource[_5]&gocstr('/adm/cfile?action=rename','/priv/$udom/$uname/$cleandisfn')&Rename this resource |
s&7&1&del.png&Delete&resource[_2]&gocstr('/adm/cfile?action=delete','/priv/$udom/$uname/$cleandisfn')&Delete this resource |
s&7&1&del.png&Delete&resource[_2]&gocstr('/adm/cfile?action=delete','/priv/$udom/$uname/$cleandisfn')&Delete this resource |
|
ENDMENUITEMS |
|
} |
|
$menuitems .= (<<ENDMENUITEMS); |
s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','/priv/$udom/$uname/$cleandisfn')&Prepare a printable document |
s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','/priv/$udom/$uname/$cleandisfn')&Prepare a printable document |
ENDMENUITEMS |
ENDMENUITEMS |
} |
} |
Line 1279 sub prepare_functions {
|
Line 1374 sub prepare_functions {
|
|
|
my $editbutton = ''; |
my $editbutton = ''; |
my $viewsrcbutton = ''; |
my $viewsrcbutton = ''; |
|
my $clientip = &Apache::lonnet::get_requestor_ip(); |
# |
# |
# Determine whether or not to display 'Edit' or 'View Source' icon/button |
# Determine whether or not to display 'Edit' or 'View Source' icon/button |
# |
# |
if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) { |
if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) { |
|
my $blocked = &Apache::loncommon::blocking_status('about',$clientip,$2,$1); |
my $file=&Apache::lonnet::declutter($env{'request.filename'}); |
my $file=&Apache::lonnet::declutter($env{'request.filename'}); |
($cfile,$home,$switchserver,$forceedit,$forceview) = |
($cfile,$home,$switchserver,$forceedit,$forceview) = |
&Apache::lonnet::can_edit_resource($file,$cnum,$cdom, |
&Apache::lonnet::can_edit_resource($file,$cnum,$cdom, |
&Apache::lonnet::clutter($resurl),$env{'request.symb'},$group); |
&Apache::lonnet::clutter($resurl),$env{'request.symb'},$group); |
if (($cfile) && ($home ne '') && ($home ne 'no_host')) { |
if (($cfile) && ($home ne '') && ($home ne 'no_host') && (!$blocked)) { |
$editbutton = &get_editbutton($cfile,$home,$switchserver, |
$editbutton = &get_editbutton($cfile,$home,$switchserver, |
$forceedit,$forceview,$forcereg); |
$forceedit,$forceview,$forcereg); |
} |
} |
Line 1400 sub prepare_functions {
|
Line 1497 sub prepare_functions {
|
if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) { |
if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) { |
my ($sdom,$sname) = ($1,$2); |
my ($sdom,$sname) = ($1,$2); |
unless (&Apache::lonnet::is_course($sdom,$sname)) { |
unless (&Apache::lonnet::is_course($sdom,$sname)) { |
&switch('','',6,4,'mail-message-new-22x22.png','Message to user', |
my $blocked = &Apache::loncommon::blocking_status('about',$clientip,$sname,$sdom); |
'', |
unless ($blocked) { |
"go('/adm/email?compose=individual&recname=$sname&recdom=$sdom')", |
&switch('','',6,4,'mail-message-new-22x22.png','Message to user', |
'Send message to specific user'); |
'', |
|
"go('/adm/email?compose=individual&recname=$sname&recdom=$sdom')", |
|
'Send message to specific user'); |
|
} |
} |
} |
my $hideprivileged = 1; |
my $hideprivileged = 1; |
if (&Apache::lonnet::in_course($sdom,$sname,$cdom,$cnum,undef, |
if (&Apache::lonnet::in_course($sdom,$sname,$cdom,$cnum,undef, |
Line 1492 sub advtools_crumbs {
|
Line 1592 sub advtools_crumbs {
|
&Apache::lonhtmlcommon::add_breadcrumb_tool( |
&Apache::lonhtmlcommon::add_breadcrumb_tool( |
'advtools', @funcs[61,64,65,66,67,74]); |
'advtools', @funcs[61,64,65,66,67,74]); |
} elsif ($env{'request.noversionuri'} !~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) { |
} elsif ($env{'request.noversionuri'} !~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) { |
&Apache::lonhtmlcommon::add_breadcrumb_tool( |
if ($env{'request.state'} eq 'construct') { |
'advtools', @funcs[61,71,72,73,74,92]); |
&Apache::lonhtmlcommon::add_breadcrumb_tool( |
|
'advtools', @funcs[61,73,74,71,72]); |
|
} else { |
|
&Apache::lonhtmlcommon::add_breadcrumb_tool( |
|
'advtools', @funcs[61,71,72,73,74,92]); |
|
} |
} elsif ($env{'request.noversionuri'} eq '/adm/viewclasslist') { |
} elsif ($env{'request.noversionuri'} eq '/adm/viewclasslist') { |
&Apache::lonhtmlcommon::add_breadcrumb_tool( |
&Apache::lonhtmlcommon::add_breadcrumb_tool( |
'advtools', $funcs[61]); |
'advtools', $funcs[61]); |
Line 1909 sub done_button_js {
|
Line 2014 sub done_button_js {
|
key => 'Key:', |
key => 'Key:', |
nokey => 'A proctor key is required', |
nokey => 'A proctor key is required', |
); |
); |
|
my $shownsymb = &HTML::Entities::encode(&Apache::lonenc::check_encrypt($env{'request.symb'})); |
my $navmap = Apache::lonnavmaps::navmap->new(); |
my $navmap = Apache::lonnavmaps::navmap->new(); |
my ($missing,$tried) = (0,0); |
my ($missing,$tried) = (0,0); |
if (ref($navmap)) { |
if (ref($navmap)) { |
Line 1971 sub done_button_js {
|
Line 2077 sub done_button_js {
|
<form method="post" name="LCdoneButton" action=""> |
<form method="post" name="LCdoneButton" action=""> |
<input type="hidden" name="LC_interval_done" value="" /> |
<input type="hidden" name="LC_interval_done" value="" /> |
<input type="hidden" name="LC_interval_done_proctorpass" value="" /> |
<input type="hidden" name="LC_interval_done_proctorpass" value="" /> |
|
<input type="hidden" name="symb" value="$shownsymb" /> |
<button id="LC_done-confirm-opener" type="button">$donebuttontext</button> |
<button id="LC_done-confirm-opener" type="button">$donebuttontext</button> |
</form> |
</form> |
|
|
Line 2052 END
|
Line 2159 END
|
|
|
<form method="post" name="LCdoneButton" action=""> |
<form method="post" name="LCdoneButton" action=""> |
<input type="hidden" name="LC_interval_done" value="" /> |
<input type="hidden" name="LC_interval_done" value="" /> |
|
<input type="hidden" name="symb" value="$shownsymb" /> |
<button id="LC_done-confirm-opener" type="button">$donebuttontext</button> |
<button id="LC_done-confirm-opener" type="button">$donebuttontext</button> |
</form> |
</form> |
|
|
Line 2131 sub utilityfunctions {
|
Line 2239 sub utilityfunctions {
|
|
|
my $esc_url=&escape($currenturl); |
my $esc_url=&escape($currenturl); |
my $esc_symb=&escape($currentsymb); |
my $esc_symb=&escape($currentsymb); |
|
my $newname = &mt('New Name'); |
|
|
my $countdown = &countdown_toggle_js(); |
my $countdown = &countdown_toggle_js(); |
|
|
my $ltitarget; |
my ($ltitarget,$deeplinktarget); |
if ($env{'request.lti.login'}) { |
if ($env{'request.lti.login'}) { |
$ltitarget = $env{'request.lti.target'}; |
$ltitarget = $env{'request.lti.target'}; |
} |
} |
|
if ($env{'request.deeplink.login'}) { |
|
$deeplinktarget = $env{'request.deeplink.target'}; |
|
} |
|
|
my $annotateurl = '/adm/annotation'; |
my $annotateurl = '/adm/annotation'; |
if ($httphost) { |
if ($httphost) { |
Line 2201 function gocstr(url,filename) {
|
Line 2313 function gocstr(url,filename) {
|
this.document.cstrdelete.submit(); |
this.document.cstrdelete.submit(); |
return; |
return; |
} |
} |
|
if ((url == '/adm/cfile?action=copy') || (url == '/adm/cfile?action=rename')) { |
|
this.document.cstrcopy.filename.value = filename; |
|
var oldname = filename.substring(filename.lastIndexOf("/") + 1); |
|
var newname=prompt('$newname',oldname); |
|
if (newname == "" || !newname || newname == oldname) { |
|
return; |
|
} |
|
if (url == '/adm/cfile?action=rename') { |
|
this.document.cstrcopy.action.value = 'rename'; |
|
} else { |
|
this.document.cstrcopy.action.value = 'copy'; |
|
} |
|
this.document.cstrcopy.newfilename.value = newname; |
|
this.document.cstrcopy.submit(); |
|
return; |
|
} |
if (url == '/adm/printout') { |
if (url == '/adm/printout') { |
this.document.cstrprint.postdata.value = filename |
this.document.cstrprint.postdata.value = filename |
this.document.cstrprint.curseed.value = 0; |
this.document.cstrprint.curseed.value = 0; |
Line 2240 function golist(url) {
|
Line 2368 function golist(url) {
|
currentSymb= null; |
currentSymb= null; |
var lcHostname = setLCHost(); |
var lcHostname = setLCHost(); |
var ltitarget = '$ltitarget'; |
var ltitarget = '$ltitarget'; |
if (ltitarget == 'iframe') { |
var deeplinktarget = '$deeplinktarget'; |
|
if ((ltitarget == 'iframe') || (deeplinktarget == '_self')) { |
document.location.href=lcHostname+url; |
document.location.href=lcHostname+url; |
} else { |
} else { |
top.location.href=lcHostname+url; |
top.location.href=lcHostname+url; |
Line 2338 sub serverform {
|
Line 2467 sub serverform {
|
unless (($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) { |
unless (($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) { |
$target = ' target="_top"'; |
$target = ' target="_top"'; |
} |
} |
|
if (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self')) { |
|
$target = ' target="_self"'; |
|
} |
return(<<ENDSERVERFORM); |
return(<<ENDSERVERFORM); |
<form name="server" action="/adm/logout" method="post"$target> |
<form name="server" action="/adm/logout" method="post"$target> |
<input type="hidden" name="postdata" value="none" /> |
<input type="hidden" name="postdata" value="none" /> |
Line 2349 ENDSERVERFORM
|
Line 2481 ENDSERVERFORM
|
} |
} |
|
|
sub constspaceform { |
sub constspaceform { |
|
my ($frameset) = @_; |
my ($target,$printtarget); |
my ($target,$printtarget); |
unless (($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) { |
if ($frameset) { |
$target = ' target="_top"'; |
$target = ' target="_parent"'; |
$printtarget = ' target="_parent"'; |
$printtarget = ' target="_parent"'; |
|
} else { |
|
unless ((($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) || |
|
(($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self'))) { |
|
$target = ' target="_top"'; |
|
$printtarget = ' target="_parent"'; |
|
} |
} |
} |
return(<<ENDCONSTSPACEFORM); |
return(<<ENDCONSTSPACEFORM); |
<form name="constspace" action="/adm/logout" method="post"$target> |
<form name="constspace" action="/adm/logout" method="post"$target> |
Line 2367 sub constspaceform {
|
Line 2506 sub constspaceform {
|
<input type="hidden" name="curseed" value="" /> |
<input type="hidden" name="curseed" value="" /> |
<input type="hidden" name="problemtype" value="" /> |
<input type="hidden" name="problemtype" value="" /> |
</form> |
</form> |
|
<form name="cstrcopy" action="/adm/cfile" method="post"$target> |
|
<input type="hidden" name="action" value="copy" /> |
|
<input type="hidden" name="filename" value="" /> |
|
<input type="hidden" name="newfilename" value="" /> |
|
</form> |
|
|
ENDCONSTSPACEFORM |
ENDCONSTSPACEFORM |
} |
} |
Line 2382 sub hidden_button_check {
|
Line 2526 sub hidden_button_check {
|
} |
} |
|
|
sub roles_selector { |
sub roles_selector { |
my ($cdom,$cnum,$httphost,$ltitarget) = @_; |
my ($cdom,$cnum,$httphost,$menucoll,$menuref) = @_; |
my $crstype = &Apache::loncommon::course_type(); |
my $crstype = &Apache::loncommon::course_type(); |
my $now = time; |
my $now = time; |
my (%courseroles,%seccount,%courseprivs,%roledesc); |
my (%courseroles,%seccount,%courseprivs,%roledesc); |
my $is_cc; |
my $is_cc; |
my ($js,$form,$switcher); |
my ($js,$form,$switcher,$has_opa_priv); |
my $ccrole; |
my $ccrole; |
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
$ccrole = 'co'; |
$ccrole = 'co'; |
Line 2489 sub roles_selector {
|
Line 2633 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,\%roledesc,$privref); |
$js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs, |
|
\%roledesc,$privref,$menucoll,$menuref); |
$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 2508 sub roles_selector {
|
Line 2653 sub roles_selector {
|
if ($env{'request.role'} =~ m{^\Q$role\E}) { |
if ($env{'request.role'} =~ m{^\Q$role\E}) { |
if ($seccount{$role} > 1) { |
if ($seccount{$role} > 1) { |
$include = 1; |
$include = 1; |
|
} else { |
|
if ($env{'user.priv.'.$env{'request.role'}."./$cdom/$cnum"} =~/opa\&([^\:]*)/) { |
|
$has_opa_priv = 1; |
|
} |
} |
} |
} else { |
} else { |
$include = 1; |
$include = 1; |
} |
} |
} |
} |
if ($include) { |
if ($include) { |
|
if ($env{"user.priv.$role./$cdom/$cnum./$cdom/$cnum"} =~/opa\&([^\:]*)/) { |
|
$has_opa_priv = 1; |
|
} |
push(@submenu,['javascript:adhocRole('."'$role'".')', |
push(@submenu,['javascript:adhocRole('."'$role'".')', |
&Apache::lonnet::plaintext($role,$crstype)]); |
&Apache::lonnet::plaintext($role,$crstype)]); |
} |
} |
Line 2538 sub roles_selector {
|
Line 2690 sub roles_selector {
|
} else { |
} else { |
$rolename = &Apache::lonnet::plaintext($role); |
$rolename = &Apache::lonnet::plaintext($role); |
} |
} |
|
if ($env{"user.priv.$role./$cdom/$cnum./$cdom/$cnum"} =~/opa\&([^\:]*)/) { |
|
$has_opa_priv = 1; |
|
} |
push(@submenu,['javascript:adhocRole('."'$role'".')', |
push(@submenu,['javascript:adhocRole('."'$role'".')', |
$rolename]); |
$rolename]); |
} |
} |
} |
} |
} |
} |
if (@submenu > 0) { |
if (@submenu > 0) { |
$switcher = &create_submenu('','',&mt('Switch role'),\@submenu,'','',$ltitarget); |
$switcher = &create_submenu('','',&mt('Switch role'),\@submenu); |
} |
} |
} |
} |
return ($js,$form,$switcher); |
return ($js,$form,$switcher,$has_opa_priv); |
} |
} |
|
|
sub get_all_courseroles { |
sub get_all_courseroles { |
Line 2714 sub get_customadhoc_roles {
|
Line 2869 sub get_customadhoc_roles {
|
} |
} |
|
|
sub jump_to_role { |
sub jump_to_role { |
my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$roledesc,$privref) = @_; |
my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$roledesc,$privref, |
|
$menucoll,$menuref) = @_; |
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 2725 sub jump_to_role {
|
Line 2881 sub jump_to_role {
|
role => 'The role you selected is not permitted to view the current page.', |
role => 'The role you selected is not permitted to view the current page.', |
swit => 'Switch role, but display Main Menu page instead?', |
swit => 'Switch role, but display Main Menu page instead?', |
); |
); |
|
&js_escape(\%lt); |
my $js; |
my $js; |
if (ref($courseroles) eq 'HASH') { |
if (ref($courseroles) eq 'HASH') { |
$js = ' var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n". |
$js = ' var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n". |
Line 2747 sub jump_to_role {
|
Line 2904 sub jump_to_role {
|
} |
} |
} |
} |
my $checkroles = 0; |
my $checkroles = 0; |
|
my $fallback = '/adm/menu'; |
|
my $displaymsg = $lt{'swit'}; |
if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0) && (ref($courseprivs) eq 'HASH')) { |
if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0) && (ref($courseprivs) eq 'HASH')) { |
my %disallowed; |
my %disallowed; |
foreach my $role (sort(keys(%{$courseprivs}))) { |
foreach my $role (sort(keys(%{$courseprivs}))) { |
Line 2768 sub jump_to_role {
|
Line 2927 sub jump_to_role {
|
$checkroles = 1; |
$checkroles = 1; |
$js .= " var disallow = new Array('".join("','",keys(%disallowed))."');\n". |
$js .= " var disallow = new Array('".join("','",keys(%disallowed))."');\n". |
" var rolecheck = 1;\n"; |
" var rolecheck = 1;\n"; |
|
if ($menucoll) { |
|
if (ref($menuref) eq 'HASH') { |
|
if ($menuref->{'main'} eq 'n') { |
|
$fallback = '/adm/navmaps'; |
|
if (&Apache::loncommon::course_type() eq 'Community') { |
|
$displaymsg = &mt('Switch role, but display Community Contents page instead?'); |
|
} else { |
|
$displaymsg = &mt('Switch role, but display Course Contents page instead?'); |
|
} |
|
&js_escape(\$displaymsg); |
|
} |
|
} |
|
} |
} |
} |
} |
} |
|
&js_escape(\$fallback); |
if (!$checkroles) { |
if (!$checkroles) { |
$js .= " var disallow = new Array();\n". |
$js .= " var disallow = new Array();\n". |
" rolecheck = 0;\n"; |
" rolecheck = 0;\n"; |
Line 2792 function adhocRole(newrole) {
|
Line 2965 function adhocRole(newrole) {
|
if (rolecheck > 0) { |
if (rolecheck > 0) { |
for (var i=0; i<disallow.length; i++) { |
for (var i=0; i<disallow.length; i++) { |
if (disallow[i] == newrole) { |
if (disallow[i] == newrole) { |
if (confirm("$lt{'role'}\\n$lt{'swit'}")) { |
if (confirm("$lt{'role'}\\n$displaymsg")) { |
document.rolechooser.destinationurl.value = '/adm/menu'; |
document.rolechooser.destinationurl.value = '$fallback'; |
} else { |
} else { |
return; |
return; |
} |
} |
Line 2995 BEGIN {
|
Line 3168 BEGIN {
|
$category_positions{$entries[2]}=$entries[1]; |
$category_positions{$entries[2]}=$entries[1]; |
$category_names{$entries[2]}=$entries[3]; |
$category_names{$entries[2]}=$entries[3]; |
} elsif ($configline=~/^prim\:/) { |
} elsif ($configline=~/^prim\:/) { |
my @entries = (split(/\:/, $configline))[1..6]; |
my @entries = (split(/\:/, $configline))[1..7]; |
push(@primary_menu,\@entries); |
push(@primary_menu,\@entries); |
} elsif ($configline=~/^primsub\:/) { |
} elsif ($configline=~/^primsub\:/) { |
my ($parent,@entries) = (split(/\:/, $configline))[1..4]; |
my ($parent,@entries) = (split(/\:/, $configline))[1..5]; |
push(@{$primary_submenu{$parent}},\@entries); |
push(@{$primary_submenu{$parent}},\@entries); |
} elsif ($configline=~/^scnd\:/) { |
} elsif ($configline=~/^scnd\:/) { |
my @entries = (split(/\:/, $configline))[1..5]; |
my @entries = (split(/\:/, $configline))[1..6]; |
push(@secondary_menu,\@entries); |
push(@secondary_menu,\@entries); |
} elsif ($configline=~/^scndsub\:/) { |
} elsif ($configline=~/^scndsub\:/) { |
my ($parent,@entries) = (split(/\:/, $configline))[1..4]; |
my ($parent,@entries) = (split(/\:/, $configline))[1..4]; |