version 1.515, 2022/05/06 19:36:09
|
version 1.540, 2023/10/06 02:04:47
|
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,$target,$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 210 use Apache::lonenc();
|
Line 210 use Apache::lonenc();
|
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonmsg(); |
use Apache::lonmsg(); |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA::ltiutils; |
|
use HTML::Entities(); |
use HTML::Entities(); |
use Apache::lonwishlist(); |
use Apache::lonwishlist(); |
|
|
Line 220 use vars qw(@desklines %category_names %
|
Line 219 use vars qw(@desklines %category_names %
|
my @inlineremote; |
my @inlineremote; |
|
|
sub prep_menuitem { |
sub prep_menuitem { |
my ($menuitem,$ltitarget,$listclass,$linkattr) = @_; |
my ($menuitem,$target,$listclass,$linkattr) = @_; |
return '' unless(ref($menuitem) eq 'ARRAY'); |
return '' unless(ref($menuitem) eq 'ARRAY'); |
my $link; |
my ($link,$targetattr); |
if ($$menuitem[1]) { # graphical Link |
if ($$menuitem[1]) { # graphical Link |
$link = "<img class=\"LC_noBorder\"" |
$link = "<img class=\"LC_noBorder\"" |
. " src=\"" . &Apache::loncommon::lonhttpdurl($$menuitem[1]) . "\"" |
. " src=\"" . &Apache::loncommon::lonhttpdurl($$menuitem[1]) . "\"" |
Line 230 sub prep_menuitem {
|
Line 229 sub prep_menuitem {
|
} else { # textual Link |
} else { # textual Link |
$link = &mt($$menuitem[3]); |
$link = &mt($$menuitem[3]); |
} |
} |
my $target = ' target="_top"'; |
if ($target ne '') { |
if ($ltitarget eq 'iframe') { |
$targetattr = ' target="'.$target.'"'; |
$target =''; |
|
} |
} |
return ($listclass?'<li class="'.$listclass.'">':'<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 $linkattr>$link</a></li>|; |
. qq| href="$$menuitem[0]"$targetattr $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 245 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,$menucoll,$menuref,$links_disabled) = @_; |
my ($crstype,$ltimenu,$menucoll,$menuref,$links_disabled,$links_target) = @_; |
my (%menu,%ltiexc,%menuopts); |
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) |
Line 265 sub primary_menu {
|
Line 263 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; |
if ($env{'request.lti.login'}) { |
if ($env{'request.lti.login'}) { |
$lti = 1; |
$lti = 1; |
$ltitarget = $env{'request.lti.target'}; |
|
if (ref($ltimenu) eq 'HASH') { |
if (ref($ltimenu) eq 'HASH') { |
foreach my $item ('fullname','logout') { |
foreach my $item ('fullname','logout') { |
unless ($ltimenu->{$item}) { |
unless ($ltimenu->{$item}) { |
Line 277 sub primary_menu {
|
Line 274 sub primary_menu {
|
} |
} |
} |
} |
} |
} |
|
my ($listclass,$linkattr,$target); |
|
if ($links_disabled) { |
|
$listclass = 'LCisDisabled'; |
|
$linkattr = 'aria-disabled="true"'; |
|
} |
|
if ($links_target ne '') { |
|
$target = $links_target; |
|
} else { |
|
my ($ltitarget,$deeplinktarget); |
|
if ($env{'request.lti.login'}) { |
|
$ltitarget = $env{'request.lti.target'}; |
|
} |
|
if ($env{'request.deeplink.login'}) { |
|
$deeplinktarget = $env{'request.deeplink.target'}; |
|
} |
|
if (($ltitarget eq 'iframe') || ($deeplinktarget eq '_self')) { |
|
$target = '_self'; |
|
} else { |
|
$target = '_top'; |
|
} |
|
} |
if (($menucoll) && (ref($menuref) eq 'HASH')) { |
if (($menucoll) && (ref($menuref) eq 'HASH')) { |
%menuopts = %{$menuref}; |
%menuopts = %{$menuref}; |
} |
} |
Line 332 sub primary_menu {
|
Line 350 sub primary_menu {
|
} |
} |
} |
} |
} |
} |
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; |
if ($menuitem->[0] ne '') { |
if ($menuitem->[0] ne '') { |
$link = $menuitem->[0]; |
$link = $menuitem->[0]; |
unless ($ltitarget eq 'iframe') { |
|
$target = '_top'; |
|
} |
|
} else { |
} else { |
$link = '#'; |
$link = '#'; |
} |
} |
Line 391 sub primary_menu {
|
Line 401 sub primary_menu {
|
'helpdeskmail', |
'helpdeskmail', |
$defdom,$origmail); |
$defdom,$origmail); |
if ($to ne '') { |
if ($to ne '') { |
$menu{$position} .= &prep_menuitem($menuitem,$ltitarget,$listclass,$linkattr); |
$menu{$position} .= &prep_menuitem($menuitem,$target,$listclass,$linkattr); |
} |
} |
} else { |
} else { |
$menu{$position} .= ($listclass?'<li class="'.$listclass.'">':'<li>'). |
$menu{$position} .= ($listclass?'<li class="'.$listclass.'">':'<li>'). |
Line 404 sub primary_menu {
|
Line 414 sub primary_menu {
|
$$menuitem[0] = '/adm/login'; |
$$menuitem[0] = '/adm/login'; |
} |
} |
} |
} |
$menu{$position} .= prep_menuitem($menuitem,$ltitarget,$listclass,$linkattr); |
$menu{$position} .= prep_menuitem($menuitem,$target,$listclass,$linkattr); |
} else { |
} else { |
$menu{$position} .= prep_menuitem($menuitem,$ltitarget,$listclass,$linkattr); |
$menu{$position} .= prep_menuitem($menuitem,$target,$listclass,$linkattr); |
} |
} |
} |
} |
my @output = ('',''); |
my @output = ('',''); |
Line 445 sub getauthor{
|
Line 455 sub getauthor{
|
} |
} |
|
|
sub secondary_menu { |
sub secondary_menu { |
my ($httphost,$ltiscope,$ltimenu,$noprimary,$menucoll,$menuref,$links_disabled) = @_; |
my ($httphost,$ltiscope,$ltimenu,$noprimary,$menucoll,$menuref, |
|
$links_disabled,$links_target) = @_; |
my $menu; |
my $menu; |
|
|
my $crstype = &Apache::loncommon::course_type(); |
my $crstype = &Apache::loncommon::course_type(); |
Line 522 sub secondary_menu {
|
Line 533 sub secondary_menu {
|
%menuopts = %{$menuref}; |
%menuopts = %{$menuref}; |
} |
} |
|
|
my ($listclass,$linkattr); |
my ($listclass,$linkattr,$target); |
if ($links_disabled) { |
if ($links_disabled) { |
$listclass = 'LCisDisabled'; |
$listclass = 'LCisDisabled'; |
$linkattr = 'aria-disabled="true"'; |
$linkattr = 'aria-disabled="true"'; |
Line 537 sub secondary_menu {
|
Line 548 sub secondary_menu {
|
} |
} |
} |
} |
|
|
my ($roleswitcher_js,$roleswitcher_form,$ltitarget); |
my ($roleswitcher_js,$roleswitcher_form); |
if ($env{'request.lti.login'}) { |
if ($links_target ne '') { |
$ltitarget = $env{'request.lti.target'}; |
$target = $links_target; |
|
} else { |
|
my ($ltitarget,$deeplinktarget); |
|
if ($env{'request.lti.login'}) { |
|
$ltitarget = $env{'request.lti.target'}; |
|
} |
|
if ($env{'request.deeplink.login'}) { |
|
$deeplinktarget = $env{'request.deeplink.target'}; |
|
} |
|
if (($ltitarget eq 'iframe') || ($deeplinktarget eq '_self')) { |
|
$target = '_self'; |
|
} else { |
|
$target = '_top'; |
|
} |
} |
} |
|
|
foreach my $menuitem (@secondary_menu) { |
foreach my $menuitem (@secondary_menu) { |
Line 595 sub secondary_menu {
|
Line 619 sub secondary_menu {
|
} |
} |
} |
} |
if (defined($secondary_submenu{$title})) { |
if (defined($secondary_submenu{$title})) { |
my ($link,$target); |
my $link; |
if ($menuitem->[0] ne '') { |
if ($menuitem->[0] ne '') { |
$link = $menuitem->[0]; |
$link = $menuitem->[0]; |
unless ($ltitarget eq 'iframe') { |
|
$target = '_top'; |
|
} |
|
} else { |
} else { |
$link = '#'; |
$link = '#'; |
} |
} |
Line 649 sub secondary_menu {
|
Line 670 sub secondary_menu {
|
&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,$target,$menucoll,$menuref |
); |
); |
if (($$menuitem[5]) && (!$menuopts{$$menuitem[5]})) { |
if (($$menuitem[5]) && (!$menuopts{$$menuitem[5]})) { |
next unless ($has_opa_priv); |
next unless ($has_opa_priv); |
Line 683 sub secondary_menu {
|
Line 704 sub secondary_menu {
|
} |
} |
$$menuitem[0] = &HTML::Entities::encode($$menuitem[0],'&<>"'); |
$$menuitem[0] = &HTML::Entities::encode($$menuitem[0],'&<>"'); |
} |
} |
$menu .= &prep_menuitem(\@$menuitem,$ltitarget,$listclass,$linkattr); |
$menu .= &prep_menuitem(\@$menuitem,$target,$listclass,$linkattr); |
} |
} |
} |
} |
if ($menu =~ /\[url\].*\[symb\]/) { |
if ($menu =~ /\[url\].*\[symb\]/) { |
Line 723 sub secondary_menu {
|
Line 744 sub secondary_menu {
|
sub create_submenu { |
sub create_submenu { |
my ($link,$target,$title,$submenu,$translate,$addclass,$listclass,$linkattr) = @_; |
my ($link,$target,$title,$submenu,$translate,$addclass,$listclass,$linkattr) = @_; |
return unless (ref($submenu) eq 'ARRAY'); |
return unless (ref($submenu) eq 'ARRAY'); |
my $disptarget; |
my $targetattr; |
if ($target ne '') { |
if (($target ne '') && ($link ne '#')) { |
$disptarget = ' target="'.$target.'"'; |
$targetattr = ' target="'.$target.'"'; |
} |
} |
my $menu = '<li class="LC_hoverable '.$addclass.'">'. |
my $menu = '<li class="LC_hoverable '.$addclass.'">'. |
'<a href="'.$link.'"'.$disptarget.'>'. |
'<a href="'.$link.'"'.$targetattr.'>'. |
'<span class="LC_nobreak">'.$title. |
'<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>'. |
Line 805 sub build_submenu {
|
Line 826 sub build_submenu {
|
} |
} |
$href =~ s/\[returnurl\]/$returnurl/; |
$href =~ s/\[returnurl\]/$returnurl/; |
} |
} |
|
my $targetattr; |
unless (($href eq '') || ($href =~ /^\#/)) { |
unless (($href eq '') || ($href =~ /^\#/)) { |
if ($target eq '_top') { |
if ($target ne '') { |
$target = ' target="_top"'; |
$targetattr = ' target="'.$target.'"'; |
} |
} |
} |
} |
|
|
$menu .= '<li '; |
$menu .= '<li '; |
$menu .= ($listclass?'class="'.$listclass.'" ':''); |
$menu .= ($listclass?'class="'.$listclass.'" ':''); |
$menu .= 'style="margin:0;padding:0;'. $bordertop . $borderbot .'">'; |
$menu .= 'style="margin:0;padding:0;'. $bordertop . $borderbot .'">'; |
$menu .= '<a href="'.$href.'"'.$target.' '.$linkattr.'>' . $title . '</a>'; |
$menu .= '<a href="'.$href.'"'.$targetattr.' '.$linkattr.'>' . $title . '</a>'; |
$menu .= '</li>'; |
$menu .= '</li>'; |
} |
} |
} |
} |
Line 823 sub build_submenu {
|
Line 845 sub build_submenu {
|
} |
} |
|
|
sub innerregister { |
sub innerregister { |
my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname,$ltiscope,$ltiuri) = @_; |
my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname, |
|
$ltiscope,$ltiuri,$showncrumbsref) = @_; |
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 864 sub innerregister {
|
Line 887 sub innerregister {
|
} |
} |
} |
} |
} |
} |
unless (($forcereg) && |
unless ((($crstype eq 'Placement') && (!$env{'request.role.adv'})) || |
($env{'request.noversionuri'} eq '/adm/navmaps') && |
|
($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'}) || |
|
(($crstype eq 'Placement') && (!$env{'request.role.adv'})) || |
|
($ltiscope eq 'map') || ($ltiscope eq 'resource')) { |
($ltiscope eq 'map') || ($ltiscope eq 'resource')) { |
@crumbs = ({text => $crstype.' Contents', |
@crumbs = ({text => $crstype.' Contents', |
href => "Javascript:gopost('/adm/navmaps','')"}); |
href => "Javascript:gopost('/adm/navmaps','')"}); |
Line 914 sub innerregister {
|
Line 934 sub innerregister {
|
if ($env{'form.title'}) { |
if ($env{'form.title'}) { |
$title = $env{'form.title'}; |
$title = $env{'form.title'}; |
} |
} |
my $trail; |
my ($trail,$cnum,$cdom); |
|
if ($env{'form.folderpath'}) { |
|
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
&Apache::loncommon::validate_folderpath(1,'',$cnum,$cdom); |
|
} |
if ($env{'form.folderpath'}) { |
if ($env{'form.folderpath'}) { |
&prepare_functions($resurl,$forcereg,$group,undef,undef,1,$hostname); |
&prepare_functions($resurl,$forcereg,$group,undef,undef,1,$hostname); |
|
$title = &HTML::Entities::encode($title,'\'"<>&'); |
($trail) = |
($trail) = |
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1); |
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,1); |
} else { |
} else { |
&Apache::lonhtmlcommon::add_breadcrumb( |
&Apache::lonhtmlcommon::add_breadcrumb( |
{text => "Supplemental $crstype Content", |
{text => "Supplemental $crstype Content", |
href => "javascript:gopost('/adm/supplemental','')"}); |
href => "javascript:gopost('/adm/supplemental','')"}); |
$title = &mt('View Resource'); |
$title = &HTML::Entities::encode(&mt('View Resource'),'\'"<>&'); |
($trail) = |
($trail) = |
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1); |
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,1); |
|
} |
|
if (ref($showncrumbsref)) { |
|
$$showncrumbsref = 1; |
} |
} |
return $trail; |
return $trail; |
} 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,$hostname); |
$forcereg,$group,undef,undef,1,$hostname); |
$title = &mt('Syllabus File'); |
$title = &HTML::Entities::encode(&mt('Syllabus File'),'\'"<>&'); |
|
my ($trail) = |
|
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,1); |
|
if (ref($showncrumbsref)) { |
|
$$showncrumbsref = 1; |
|
} |
|
return $trail; |
|
} elsif (($resurl eq '/public'.$courseurl.'/syllabus') && |
|
($env{'form.folderpath'})) { |
|
if ($env{'form.title'}) { |
|
$title = $env{'form.title'}; |
|
} else { |
|
$title = 'Syllabus'; |
|
} |
|
&prepare_functions($resurl,$forcereg,$group,undef,undef,1,$hostname); |
|
$title = &HTML::Entities::encode($title,'\'"<>&'); |
my ($trail) = |
my ($trail) = |
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,$hostname); |
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,1); |
return $trail; |
return $trail; |
} |
} |
unless ($env{'request.state'} eq 'construct') { |
unless ($env{'request.state'} eq 'construct') { |
Line 1029 sub innerregister {
|
Line 1073 sub innerregister {
|
'Folder/Page Content'); |
'Folder/Page Content'); |
} |
} |
# End modifiable folder/page container check |
# End modifiable folder/page container check |
|
|
|
# |
|
# Determine whether to show View As button for shortcut to display problem, answer, and submissions |
|
# |
|
|
|
if (($env{'request.symb'} ne '') && |
|
($env{'request.filename'}=~/$LONCAPA::assess_re/) && |
|
(($perms{'mgr'}) || ($perms{'vgr'}))) { |
|
my ($viewas,$text,$change,$visibility,$vuname,$vudom,$vid,$leftvis,$defdom, |
|
$domselector,$righticon); |
|
my %lt = &Apache::lonlocal::texthash( |
|
view => 'View', |
|
upda => 'Update', |
|
); |
|
my $possdomstr = $env{'course.'.$env{'request.course.id'}.'.internal.userdomains'}; |
|
if ($possdomstr =~ /,/) { |
|
my @possdoms = split(/,/,$possdomstr); |
|
if ($env{'request.user_in_effect'} =~ /^$match_username:($match_domain)$/) { |
|
$defdom = $1; |
|
} elsif (grep(/^\Q$cdom\E$/,@possdoms)) { |
|
$defdom = $cdom; |
|
} elsif (&Apache::lonnet::domain($possdoms[0]) ne '') { |
|
$defdom = $possdoms[0]; |
|
} |
|
$domselector = &Apache::loncommon::select_dom_form($defdom,'vudom','','','',\@possdoms); |
|
} elsif (($possdomstr ne '') && (&Apache::lonnet::domain($possdomstr) ne '')) { |
|
if ($env{'request.user_in_effect'} =~ /^$match_username:($match_domain)$/) { |
|
$defdom = $1; |
|
} else { |
|
$defdom = $possdomstr; |
|
} |
|
} |
|
if ($env{'request.user_in_effect'} =~ /^($match_username):($match_domain)$/) { |
|
($vuname,$vudom) = ($1,$2); |
|
unless (&Apache::lonnet::is_advanced_user($vudom,$vuname)) { |
|
$vid = (&Apache::lonnet::idrget($vudom,$vuname))[1]; |
|
} |
|
$viewas = $env{'request.user_in_effect'}; |
|
$text = $lt{'upda'}; |
|
$change = 'off'; |
|
$visibility = 'inline'; |
|
$leftvis = 'none'; |
|
$defdom = $vudom; |
|
$righticon = '✖'; |
|
} else { |
|
$text = $lt{'view'}; |
|
$change = 'on'; |
|
$visibility = 'none'; |
|
$leftvis = 'inline'; |
|
if ($defdom eq '') { |
|
$defdom = $cdom; |
|
} |
|
} |
|
my $sellink = &Apache::loncommon::selectstudent_link('userview','vuname','vudom','','','vuidentifier'); |
|
my $selscript=&Apache::loncommon::studentbrowser_javascript(); |
|
my $shownsymb = &HTML::Entities::encode(&Apache::lonenc::check_encrypt($env{'request.symb'}),'<>&"'); |
|
my $input; |
|
my @items = ( |
|
'<label><input type="radio" name="vuidentifier" value="uname" checked="checked" onclick="javascript:toggleIdentifier(this.form);" />', |
|
'</label><input name="vuname" type="text" size="6" value="'.$vuname.'" id="LC_vuname" />', |
|
'<label><input type="radio" name="vuidentifier" value="uid" onclick="javascript:toggleIdentifier(this.form);" />', |
|
'</label><input name="vid" type="hidden" size="6" value="'.$vid.'" id="LC_vid" />' |
|
); |
|
if ($domselector) { |
|
push(@items,$domselector); |
|
$input = &mt('[_1]User:[_2] or [_3]ID:[_4] at [_5] | ',@items); |
|
} else { |
|
$input = &mt('[_1]Username:[_2] or [_3]ID:[_4] | ',@items). |
|
'<input name="vudom" type="hidden" value="'.$defdom.'" />'; |
|
} |
|
$input .= '<input name="LC_viewas" type="hidden" value="'.$viewas.'" />', |
|
'<input name="symb" type="hidden" value="'.$shownsymb.'" />'; |
|
my $chooser = <<END; |
|
$selscript |
|
<a href="javascript:toggleViewAsUser('$change');" class="LC_menubuttons_link"> |
|
<span id="usexpand" class="LC_menubuttons_inline_text" style="display:$leftvis">► </span> |
|
</a> |
|
<fieldset id="LC_selectuser" style="display:$visibility"> |
|
<form name="userview" action="" method="post" onsubmit="event.preventDefault(); return validCourseUser(this,'$change');"> |
|
<span class="LC_menubuttons_inline_text LC_nobreak"> |
|
$input |
|
$sellink |
|
</span> |
|
<input type="submit" value="$text" /> |
|
</form> |
|
</fieldset> |
|
<a href="javascript:toggleViewAsUser('$change');" class="LC_menubuttons_link"> |
|
<span id="uscollapse" class="LC_menubuttons_inline_text">$righticon</span> |
|
</a> |
|
END |
|
&switch('','',7,5,'viewuser.png','View As','user[_1]', |
|
'toggleViewAsUser('."'$change'".')', |
|
'View As','','',$chooser); |
|
} |
|
# End view as user check |
|
|
} |
} |
# End course context |
# End course context |
|
|
# Prepare the rest of the buttons |
# Prepare the rest of the buttons |
my ($menuitems,$got_prt,$got_wishlist); |
my ($menuitems,$got_prt,$got_wishlist,$crsauthor); |
if ($const_space) { |
if ($const_space) { |
# |
# |
# We are in construction space |
# We are in construction space |
Line 1042 sub innerregister {
|
Line 1182 sub innerregister {
|
my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'}; |
my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'}; |
my ($udom,$uname,$thisdisfn) = |
my ($udom,$uname,$thisdisfn) = |
($env{'request.filename'}=~m{^\Q$londocroot/priv/\E([^/]+)/([^/]+)/(.*)$}); |
($env{'request.filename'}=~m{^\Q$londocroot/priv/\E([^/]+)/([^/]+)/(.*)$}); |
|
my $crsauthor; |
|
if (($env{'request.course.id'}) && |
|
($env{'course.'.$env{'request.course.id'}.'.num'} eq $uname) && |
|
($env{'course.'.$env{'request.course.id'}.'.domain'} eq $udom)) { |
|
$crsauthor = 1; |
|
} |
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 '') { |
if (($thisdisfn eq '') && ($crsauthor)) { |
unless (($env{'request.course.id'}) && |
$is_const_dir = 2; |
($env{'course.'.$env{'request.course.id'}.'.num'} eq $uname) && |
|
($env{'course.'.$env{'request.course.id'}.'.domain'} eq $udom)) { |
|
$is_const_dir = 2; |
|
} |
|
} |
} |
|
my $esc_currdir = &Apache::loncommon::escape_single($currdir); |
|
$menuitems=(<<ENDMENUITEMS); |
|
s&6&3&pub.png&Publish&dir[_2]&gocstr('/adm/publish','$esc_currdir')&Publish this Directory |
|
s&7&4&docs-22x22.png&Edit Metadata&defaults[_1]&gopost('${esc_currdir}default.meta','')&Edit metadata for this Directory |
|
s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','$esc_currdir')&Print contents of directory |
|
s&7&1&del.png&Delete&dir[_3]&gocstr('/adm/cfile?action=delete','$esc_currdir')&Delete this Directory |
|
ENDMENUITEMS |
} else { |
} else { |
$currdir =~ s|[^/]+$||; |
$currdir =~ s|[^/]+$||; |
my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn); |
my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn); |
Line 1066 sub innerregister {
|
Line 1215 sub innerregister {
|
# |
# |
# Probably should be in mydesk.tab |
# Probably should be in mydesk.tab |
# |
# |
$menuitems=(<<ENDMENUITEMS); |
if (($crsauthor) && ($pubfile eq "/res/$udom/$uname/default.rights")) { |
|
$menuitems=(<<ENDMENUITEMS); |
|
s&6&1&list.png&Directory&dir[_1]&golist('$esc_currdir')&List current directory |
|
s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource |
|
ENDMENUITEMS |
|
} else { |
|
$menuitems=(<<ENDMENUITEMS); |
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 |
s&7&3©.png&Copy&resource[_4]&gocstr('/adm/cfile?action=copy','/priv/$udom/$uname/$cleandisfn')&Copy this resource |
ENDMENUITEMS |
ENDMENUITEMS |
|
} |
# |
# |
# Rename and Delete only available if obsolete or unpublished |
# Rename and Delete only available if obsolete or unpublished |
# |
# |
Line 1157 ENDMENUITEMS
|
Line 1313 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'})) { |
my ($cnum,$cdom) = &Apache::loncommon::crsauthor_url($env{'request.uri'}); |
my $privurl = $env{'request.uri'}; |
unless ($cnum) { |
$privurl =~ s{^/res/}{/priv/}; |
|
my ($cnum,$cdom) = &Apache::loncommon::crsauthor_url($privurl); |
|
if ($cnum) { |
|
$crsauthor = 1; |
|
} else { |
# 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); |
Line 1213 s&8&3&prt.png&Print&printout[_1]&gopost(
|
Line 1373 s&8&3&prt.png&Print&printout[_1]&gopost(
|
ENDMENUITEMS |
ENDMENUITEMS |
$got_prt = 1; |
$got_prt = 1; |
} |
} |
unless ($got_wishlist) { |
unless (($got_wishlist) || ($crsauthor)) { |
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); |
Line 1241 ENDMENUITEMS
|
Line 1401 ENDMENUITEMS
|
} |
} |
} |
} |
} |
} |
my $showprogress; |
my ($showprogress,$linkprotout); |
if (($crstype eq 'Placement') && (!$env{'request.role.adv'})) { |
if (($crstype eq 'Placement') && (!$env{'request.role.adv'})) { |
$showprogress = &placement_progress(); |
$showprogress = &placement_progress(); |
} |
} |
|
if ($env{'request.deeplink.login'}) { |
|
$linkprotout = &linkprot_exit(); |
|
} |
|
|
my $addremote=0; |
my $addremote=0; |
foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} } |
foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} } |
Line 1270 ENDMENUITEMS
|
Line 1433 ENDMENUITEMS
|
if ($countdown) { |
if ($countdown) { |
&Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown); |
&Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown); |
} |
} |
|
if ($linkprotout) { |
|
&Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$linkprotout); |
|
} |
if ($showprogress) { |
if ($showprogress) { |
&Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$showprogress); |
&Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$showprogress); |
} |
} |
Line 1278 ENDMENUITEMS
|
Line 1444 ENDMENUITEMS
|
if ($countdown) { |
if ($countdown) { |
unshift(@tools,$countdown); |
unshift(@tools,$countdown); |
} |
} |
|
if ($linkprotout) { |
|
unshift(@tools,$linkprotout); |
|
} |
&Apache::lonhtmlcommon::add_breadcrumb_tool( |
&Apache::lonhtmlcommon::add_breadcrumb_tool( |
'tools',@tools); |
'tools',@tools); |
|
|
Line 1295 ENDMENUITEMS
|
Line 1464 ENDMENUITEMS
|
if ($showprogress) { |
if ($showprogress) { |
&Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$showprogress); |
&Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$showprogress); |
} |
} |
|
if ($linkprotout) { |
|
&Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$linkprotout); |
|
} |
} |
} |
my ($topic_help,$topic_help_text); |
my ($topic_help,$topic_help_text); |
if ($is_const_dir == 2) { |
if ($is_const_dir == 2) { |
Line 1306 ENDMENUITEMS
|
Line 1478 ENDMENUITEMS
|
$topic_help_text = 'About WebDAV access'; |
$topic_help_text = 'About WebDAV access'; |
} |
} |
} |
} |
|
if (ref($showncrumbsref)) { |
|
$$showncrumbsref = 1; |
|
} |
return &Apache::lonhtmlcommon::scripttag('', 'start') |
return &Apache::lonhtmlcommon::scripttag('', 'start') |
. &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'','','','',$topic_help,$topic_help_text) |
. &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'','','','',$topic_help,$topic_help_text) |
. &Apache::lonhtmlcommon::scripttag('', 'end'); |
. &Apache::lonhtmlcommon::scripttag('', 'end'); |
Line 1329 sub get_editbutton {
|
Line 1504 sub get_editbutton {
|
if ($env{'form.folderpath'}) { |
if ($env{'form.folderpath'}) { |
$suppanchor = $env{'form.anchor'}; |
$suppanchor = $env{'form.anchor'}; |
} |
} |
|
my $shownsymb; |
|
if ($env{'request.symb'}) { |
|
$shownsymb = &Apache::lonenc::check_encrypt($env{'request.symb'}); |
|
} |
$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'},$shownsymb, |
&escape($env{'form.folderpath'}), |
&escape($env{'form.folderpath'}), |
&escape($env{'form.title'}),$hostname, |
&escape($env{'form.title'}),$hostname, |
$env{'form.idx'},&escape($env{'form.suppurl'}), |
$env{'form.idx'},&escape($env{'form.suppurl'}), |
Line 1589 sub advtools_crumbs {
|
Line 1768 sub advtools_crumbs {
|
'advtools', @funcs[61,73,74,71,72]); |
'advtools', @funcs[61,73,74,71,72]); |
} else { |
} else { |
&Apache::lonhtmlcommon::add_breadcrumb_tool( |
&Apache::lonhtmlcommon::add_breadcrumb_tool( |
'advtools', @funcs[61,71,72,73,74,92]); |
'advtools', @funcs[61,71,72,73,74,75,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( |
Line 1611 sub clear {
|
Line 1790 sub clear {
|
# The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)". |
# The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)". |
|
|
sub switch { |
sub switch { |
my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_; |
my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak,$form)=@_; |
$act=~s/\$uname/$uname/g; |
$act=~s/\$uname/$uname/g; |
$act=~s/\$udom/$udom/g; |
$act=~s/\$udom/$udom/g; |
$top=&mt($top); |
$top=&mt($top); |
Line 1662 sub switch {
|
Line 1841 sub switch {
|
} else { |
} else { |
$inlineremote[$idx] = |
$inlineremote[$idx] = |
'<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic. |
'<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic. |
'<span class="LC_menubuttons_inline_text">'.$top.' </span></a>'; |
'<span class="LC_menubuttons_inline_text">'.$top.' </span></a>'.$form; |
} |
} |
} |
} |
return ''; |
return ''; |
Line 1926 sub check_for_rcrs {
|
Line 2105 sub check_for_rcrs {
|
if (!$showreqcrs) { |
if (!$showreqcrs) { |
foreach my $type (@reqtypes) { |
foreach my $type (@reqtypes) { |
if ($env{'environment.reqcrsotherdom.'.$type} ne '') { |
if ($env{'environment.reqcrsotherdom.'.$type} ne '') { |
$showreqcrs = 1; |
my @domains = split(',',$env{'environment.reqcrsotherdom.'.$type}); |
last; |
foreach my $entry (@domains) { |
|
my ($extdom,$extopt) = split(':',$entry); |
|
if (&Apache::lonnet::will_trust('reqcrs',$env{'user.domain'},$extdom)) { |
|
$showreqcrs = 1; |
|
last; |
|
} |
|
} |
|
if ($showreqcrs) { |
|
last; |
|
} |
} |
} |
} |
} |
} |
} |
Line 2194 END
|
Line 2382 END
|
} |
} |
} |
} |
|
|
|
sub view_as_js { |
|
my ($url,$symb) = @_; |
|
my %lt = &Apache::lonlocal::texthash( |
|
ente => 'Enter a username or a student/employee ID', |
|
info => 'Information you entered does not match a valid course user', |
|
); |
|
&js_escape(\%lt); |
|
return <<"END"; |
|
|
|
function toggleViewAsUser(change) { |
|
if (document.getElementById('LC_selectuser')) { |
|
var seluserid = document.getElementById('LC_selectuser'); |
|
var currstyle = seluserid.style.display; |
|
if (change == 'off') { |
|
document.userview.elements['LC_viewas'].value = ''; |
|
document.userview.elements['vuname'].value = ''; |
|
document.userview.elements['vid'].value = ''; |
|
document.userview.submit(); |
|
return; |
|
} |
|
if ((document.getElementById('usexpand')) && (document.getElementById('uscollapse'))) { |
|
if (currstyle == 'inline') { |
|
seluserid.style.display = 'none'; |
|
document.getElementById('usexpand').innerHTML='► '; |
|
document.getElementById('uscollapse').innerHTML=''; |
|
} else { |
|
seluserid.style.display = 'inline'; |
|
document.getElementById('usexpand').innerHTML=''; |
|
document.getElementById('uscollapse').innerHTML='◄ '; |
|
toggleIdentifier(document.userview); |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
function validCourseUser(form,change) { |
|
var possuname = form.elements['vuname'].value; |
|
var possuid = form.elements['vid'].value; |
|
var domelem = form.elements['vudom']; |
|
var possudom = ''; |
|
if ((domelem.tagName === 'INPUT') && ((domelem.type === 'text') || (domelem.type === 'hidden'))) { |
|
possudom = domelem.value; |
|
} else if (domelem.tagName === 'SELECT') { |
|
possudom = domelem.options[domelem.selectedIndex].value; |
|
} |
|
if ((possuname == '') && (possuid == '')) { |
|
if (change == 'off') { |
|
form.elements['LC_viewas'].value = ''; |
|
form.submit(); |
|
} else { |
|
alert("$lt{'ente'}"); |
|
} |
|
return; |
|
} |
|
var http = new XMLHttpRequest(); |
|
var url = "/adm/courseuser"; |
|
var params = "uname="+possuname+"&uid="+possuid+"&udom="+possudom; |
|
http.open("POST", url, true); |
|
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
|
http.onreadystatechange = function() { |
|
if (http.readyState == 4 && http.status == 200) { |
|
var data = JSON.parse(http.responseText); |
|
if (Array.isArray(data.match)) { |
|
var len = data.match.length; |
|
if (len == 2) { |
|
if (data.match[0] != '' && data.match[1] != '') { |
|
form.elements['LC_viewas'].value = data.match[0]+':'+data.match[1]; |
|
form.submit(); |
|
} |
|
} else { |
|
alert("$lt{'info'}"); |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
http.send(params); |
|
return false; |
|
} |
|
|
|
function toggleIdentifier(form) { |
|
if ((document.getElementById('LC_vuname')) && (document.getElementById('LC_vid'))) { |
|
var radioelem = form.elements['vuidentifier']; |
|
if (radioelem.length > 0) { |
|
var i; |
|
for (i=0; i<radioelem.length; i++) { |
|
if (radioelem[i].checked == true) { |
|
if (radioelem[i].value == 'uname') { |
|
document.getElementById('LC_vuname').type = 'text'; |
|
document.getElementById('LC_vid').type = 'hidden'; |
|
document.getElementById('LC_vid').value = ''; |
|
} else { |
|
document.getElementById('LC_vuname').type = 'hidden'; |
|
document.getElementById('LC_vuname').value = ''; |
|
document.getElementById('LC_vid').type = 'text'; |
|
} |
|
break; |
|
} |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
END |
|
} |
|
|
sub utilityfunctions { |
sub utilityfunctions { |
my ($httphost) = @_; |
my ($httphost) = @_; |
my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0])); |
my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0])); |
Line 2235 sub utilityfunctions {
|
Line 2531 sub utilityfunctions {
|
|
|
my $countdown = &countdown_toggle_js(); |
my $countdown = &countdown_toggle_js(); |
|
|
my $ltitarget; |
my $viewuser; |
|
if (($env{'request.course.id'}) && |
|
($env{'request.symb'} ne '') && |
|
($env{'request.filename'}=~/$LONCAPA::assess_re/)) { |
|
my $canview; |
|
foreach my $priv ('msg','vgr') { |
|
$canview = &Apache::lonnet::allowed($priv,$env{'request.course.id'}); |
|
if (!$canview && $env{'request.course.sec'} ne '') { |
|
$canview = |
|
&Apache::lonnet::allowed($priv,"$env{'request.course.id'}/$env{'request.course.sec'}"); |
|
} |
|
last if ($canview); |
|
} |
|
if ($canview) { |
|
$viewuser = &view_as_js($esc_url,$esc_symb); |
|
} |
|
} |
|
|
|
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 2357 function golist(url) {
|
Line 2674 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 2447 function open_aboutLC() {
|
Line 2765 function open_aboutLC() {
|
|
|
$countdown |
$countdown |
|
|
|
$viewuser |
|
|
ENDUTILITY |
ENDUTILITY |
} |
} |
|
|
Line 2455 sub serverform {
|
Line 2775 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 2466 ENDSERVERFORM
|
Line 2789 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="_top"'; |
|
} |
} |
} |
return(<<ENDCONSTSPACEFORM); |
return(<<ENDCONSTSPACEFORM); |
<form name="constspace" action="/adm/logout" method="post"$target> |
<form name="constspace" action="/adm/logout" method="post"$target> |
Line 2504 sub hidden_button_check {
|
Line 2834 sub hidden_button_check {
|
} |
} |
|
|
sub roles_selector { |
sub roles_selector { |
my ($cdom,$cnum,$httphost,$ltitarget) = @_; |
my ($cdom,$cnum,$httphost,$target,$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); |
Line 2610 sub roles_selector {
|
Line 2940 sub roles_selector {
|
} |
} |
} |
} |
if ((keys(%seccount) > 1) || ($numdiffsec > 1)) { |
if ((keys(%seccount) > 1) || ($numdiffsec > 1)) { |
|
my $targetattr; |
|
if ($target ne '') { |
|
$targetattr = ' target="'.$target.'"'; |
|
} |
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"'.$targetattr.'>'."\n". |
' <input type="hidden" name="destinationurl" value="'. |
' <input type="hidden" name="destinationurl" value="'. |
&HTML::Entities::encode($destinationurl).'" />'."\n". |
&HTML::Entities::encode($destinationurl).'" />'."\n". |
' <input type="hidden" name="gotorole" value="1" />'."\n". |
' <input type="hidden" name="gotorole" value="1" />'."\n". |
Line 2676 sub roles_selector {
|
Line 3011 sub roles_selector {
|
} |
} |
} |
} |
if (@submenu > 0) { |
if (@submenu > 0) { |
$switcher = &create_submenu('','',&mt('Switch role'),\@submenu,'','',$ltitarget); |
$switcher = &create_submenu('#',$target,&mt('Switch role'),\@submenu); |
} |
} |
} |
} |
return ($js,$form,$switcher,$has_opa_priv); |
return ($js,$form,$switcher,$has_opa_priv); |
Line 2846 sub get_customadhoc_roles {
|
Line 3181 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 2857 sub jump_to_role {
|
Line 3193 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 2879 sub jump_to_role {
|
Line 3216 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 2900 sub jump_to_role {
|
Line 3239 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 2924 function adhocRole(newrole) {
|
Line 3277 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 3111 sub placement_progress {
|
Line 3464 sub placement_progress {
|
&mt('Test is [_1]% complete',$complete).'</span>'; |
&mt('Test is [_1]% complete',$complete).'</span>'; |
} |
} |
|
|
|
sub linkprot_exit { |
|
if (($env{'request.course.id'}) && ($env{'request.deeplink.login'})) { |
|
my ($deeplink_symb,$deeplink); |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
if (($cnum ne '') && ($cdom ne '')) { |
|
$deeplink_symb = &Apache::loncommon::deeplink_login_symb($cnum,$cdom); |
|
if ($deeplink_symb) { |
|
if ($deeplink_symb =~ /\.(page|sequence)$/) { |
|
my $mapname = &Apache::lonnet::deversion((&Apache::lonnet::decode_symb($deeplink_symb))[2]); |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
if (ref($navmap)) { |
|
$deeplink = $navmap->get_mapparam(undef,$mapname,'0.deeplink'); |
|
} |
|
} else { |
|
$deeplink = &Apache::lonnet::EXT('resource.0.deeplink',$deeplink_symb); |
|
} |
|
if ($deeplink ne '') { |
|
my ($state,$others,$listed,$scope,$protect,$display,$target,$exit) = split(/,/,$deeplink); |
|
my %lt = &Apache::lonlocal::texthash( |
|
title => 'Exit Tool', |
|
okdone => 'Click "OK" to exit embedded tool', |
|
cancel => 'Click "Cancel" to continue working.', |
|
ok => 'OK', |
|
exit => 'Cancel', |
|
); |
|
if ($exit) { |
|
my ($show,$text) = split(/:/,$exit); |
|
unless ($show eq 'no') { |
|
my $height = 250; |
|
my $width = 300; |
|
my $exitbuttontext; |
|
if ($text eq '') { |
|
$exitbuttontext = &mt('Exit Tool'); |
|
} else { |
|
$exitbuttontext = $text; |
|
} |
|
return <<END; |
|
<form method="post" name="LCexitButton" action="/adm/linkexit"> |
|
<input type="hidden" name="LC_deeplink_exit" value="" /> |
|
<button id="LC_exit-confirm-opener" type="button">$exitbuttontext</button> |
|
</form> |
|
|
|
<div id="LC_exit-confirm" title="$lt{'title'}"> |
|
<p>$lt{'okdone'} $lt{'cancel'}</p> |
|
</div> |
|
|
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
\$( "#LC_exit-confirm" ).dialog({ autoOpen: false }); |
|
\$( "#LC_exit-confirm-opener" ).click(function() { |
|
\$( "#LC_exit-confirm" ).dialog( "open" ); |
|
\$( "#LC_exit-confirm" ).dialog({ |
|
resizable: false, |
|
height: $height, |
|
width: $width, |
|
modal: true, |
|
buttons: [ |
|
{ |
|
text: "$lt{'ok'}", |
|
click: function() { |
|
\$( this ).dialog( "close" ); |
|
\$( '[name="LC_deeplink_exit"]' )[0].value = 'true'; |
|
\$( '[name="LCexitButton"]' )[0].submit(); |
|
}, |
|
}, |
|
{ |
|
text: "$lt{'exit'}", |
|
click: function() { |
|
\$( this ).dialog( "close" ); |
|
}, |
|
}, |
|
], |
|
}); |
|
}); |
|
// ]]> |
|
</script> |
|
|
|
END |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
# ================================================================ Main Program |
# ================================================================ Main Program |
|
|
BEGIN { |
BEGIN { |