version 1.536, 2023/09/08 18:02:23
|
version 1.541, 2023/11/03 01:12:15
|
Line 436 sub primary_menu {
|
Line 436 sub primary_menu {
|
# |
# |
#TODO this should probably be moved somewhere more central |
#TODO this should probably be moved somewhere more central |
#since it can be used by different parts of the system |
#since it can be used by different parts of the system |
sub getauthor{ |
sub getauthor { |
return unless $env{'request.role'}=~/^(ca|aa|au)/; #nothing to do if user isn't some kind of author |
return unless $env{'request.role'}=~/^(ca|aa|au)/; #nothing to do if user isn't some kind of author |
|
|
#co- or assistent author? |
#co- or assistant author? |
my ($dom, $user) = ($env{'request.role'} =~ /^(?:ca|aa)\.\/($match_domain)\/($match_username)$/) |
my ($dom, $user) = ($env{'request.role'} =~ /^(?:ca|aa)\.\/($match_domain)\/($match_username)$/) |
? ($1, $2) #domain, username of the parent author |
? ($1, $2) #domain, username of the parent author |
: @env{ ('request.role.domain', 'user.name') }; #own domain, username |
: @env{ ('request.role.domain', 'user.name') }; #own domain, username |
Line 480 sub secondary_menu {
|
Line 480 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 ($is_author,$is_coauthor); |
|
if ($author) { |
|
if ($env{'request.role'} =~ /^au\./) { |
|
$is_author = 1; |
|
} elsif ($env{'request.role'} =~ /^ca\./) { |
|
$is_coauthor = 1; |
|
} |
|
} |
|
|
my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools, |
my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools, |
$lti,$ltimapres,%ltiexc,%menuopts); |
$lti,$ltimapres,%ltiexc,%menuopts); |
$grouptools = 0; |
$grouptools = 0; |
Line 539 sub secondary_menu {
|
Line 548 sub secondary_menu {
|
$linkattr = 'aria-disabled="true"'; |
$linkattr = 'aria-disabled="true"'; |
} |
} |
|
|
my ($canmodifycoauthor); |
my ($canlistcoauthors,$canmodifycoauthor); |
if ($env{'request.role'} eq "au./$env{'user.domain'}/") { |
if ($env{'request.role'} eq "au./$env{'user.domain'}/") { |
my $extent = "$env{'user.domain'}/$env{'user.name'}"; |
my $extent = "$env{'user.domain'}/$env{'user.name'}"; |
if ((&Apache::lonnet::allowed('cca',$extent)) || |
if ((&Apache::lonnet::allowed('cca',$extent)) || |
(&Apache::lonnet::allowed('caa',$extent))) { |
(&Apache::lonnet::allowed('caa',$extent))) { |
$canmodifycoauthor = 1; |
$canmodifycoauthor = 1; |
} |
} |
|
} elsif ($env{'request.role'} =~ m{^(aa|ca)\./($match_domain/$match_username)$}) { |
|
my ($role,$extent) = ($1,$2); |
|
if (&Apache::lonnet::allowed('vca',$extent)) { |
|
if ($env{"environment.internal.manager./$extent"}) { |
|
$canmodifycoauthor = 1; |
|
} else { |
|
$canlistcoauthors = 1; |
|
} |
|
} elsif (&Apache::lonnet::allowed('vaa',$extent)) { |
|
$canlistcoauthors = 1; |
|
} |
} |
} |
|
|
my ($roleswitcher_js,$roleswitcher_form); |
my ($roleswitcher_js,$roleswitcher_form); |
if ($links_target ne '') { |
if ($links_target ne '') { |
$target = $links_target; |
$target = $links_target; |
Line 570 sub secondary_menu {
|
Line 589 sub secondary_menu {
|
# evaluate conditions |
# evaluate conditions |
next if ref($menuitem) ne 'ARRAY'; |
next if ref($menuitem) ne 'ARRAY'; |
next if (($crstype eq 'Placement') && ($$menuitem[3] ne 'Roles') && (!$env{'request.role.adv'})); |
next if (($crstype eq 'Placement') && ($$menuitem[3] ne 'Roles') && (!$env{'request.role.adv'})); |
next if $$menuitem[4] ne 'always' |
next if $$menuitem[4] ne 'always' |
&& ($$menuitem[4] ne 'author' && $$menuitem[4] ne 'cca') |
&& $$menuitem[4] ne 'coauthor' |
|
&& $$menuitem[4] ne 'author' |
|
&& $$menuitem[4] ne 'authorspace' |
|
&& $$menuitem[4] ne 'vca' |
|
&& $$menuitem[4] ne 'mca' |
&& !$env{'request.course.id'}; |
&& !$env{'request.course.id'}; |
next if $$menuitem[4] =~ /^crsedit/ |
next if $$menuitem[4] =~ /^crsedit/ |
&& (!$canedit && !$canvieweditor); |
&& (!$canedit && !$canvieweditor); |
Line 599 sub secondary_menu {
|
Line 622 sub secondary_menu {
|
&& !$showfeeds; |
&& !$showfeeds; |
next if $$menuitem[4] eq 'plc' |
next if $$menuitem[4] eq 'plc' |
&& !$canplc; |
&& !$canplc; |
next if $$menuitem[4] eq 'author' |
next if $$menuitem[4] eq 'authorspace' |
&& !$author; |
&& !$author; |
next if $$menuitem[4] eq 'cca' |
next if $$menuitem[4] eq 'author' |
|
&& !$is_author; |
|
next if $$menuitem[4] eq 'coauthor' |
|
&& !$is_coauthor; |
|
next if $$menuitem[4] eq 'vca' |
|
&& (!$canlistcoauthors || $canmodifycoauthor); |
|
next if $$menuitem[4] eq 'vaa' |
|
&& (!$canlistcoauthors || $canmodifycoauthor); |
|
next if $$menuitem[4] eq 'mca' |
&& !$canmodifycoauthor; |
&& !$canmodifycoauthor; |
next if $$menuitem[4] eq 'notltimapres' |
next if $$menuitem[4] eq 'notltimapres' |
&& $ltimapres; |
&& $ltimapres; |
Line 637 sub secondary_menu {
|
Line 668 sub secondary_menu {
|
next if ($item->[2] eq 'vcg' && !$canviewgrps); |
next if ($item->[2] eq 'vcg' && !$canviewgrps); |
next if ($item->[2] eq 'crsedit' && !$canedit && !$canvieweditor); |
next if ($item->[2] eq 'crsedit' && !$canedit && !$canvieweditor); |
next if ($item->[2] eq 'params' && !$canmodpara && !$canviewpara); |
next if ($item->[2] eq 'params' && !$canmodpara && !$canviewpara); |
next if ($item->[2] eq 'author' && !$author); |
next if ($item->[2] eq 'author' && !$is_author); |
next if ($item->[2] eq 'cca' && !$canmodifycoauthor); |
next if ($item->[2] eq 'vca' && !$canlistcoauthors); |
next if ($item->[2] eq 'lti' && !$lti); |
next if ($item->[2] eq 'lti' && !$lti); |
if ($item->[2] =~ /^lti(portfolio|wishlist|blog)$/) { |
if ($item->[2] =~ /^lti(portfolio|wishlist|blog)$/) { |
my $tool = $1; |
my $tool = $1; |
Line 724 sub secondary_menu {
|
Line 755 sub secondary_menu {
|
} |
} |
$menu =~ s/\[url\]/$escurl/g; |
$menu =~ s/\[url\]/$escurl/g; |
$menu =~ s/\[symb\]/$escsymb/g; |
$menu =~ s/\[symb\]/$escsymb/g; |
|
} elsif (($menu =~ m{/adm/preferences\?}) && ($menu =~ /\[returnurl\]/)) { |
|
my $returnurl = $ENV{'REQUEST_URI'}; |
|
if ($ENV{'REQUEST_URI'} =~ m{/adm/preferences\?action=authorsettings\&returnurl=([^\&]+)$}) { |
|
$returnurl = $1; |
|
} |
|
if (($returnurl =~ m{^/adm/createuser($|\?action=)}) || |
|
($returnurl =~ m{^/priv/$match_domain/$match_username}) || |
|
($returnurl =~ m{^/res(/?$|/$match_domain/$match_username)})) { |
|
$returnurl =~ s{\?.*$}{}; |
|
$returnurl = '&returnurl='.&HTML::Entities::encode($returnurl,'"<>&\''); |
|
} else { |
|
undef($returnurl); |
|
} |
|
$menu =~ s/\[returnurl\]/$returnurl/; |
} |
} |
$menu =~ s/\[uname\]/$$author{user}/g; |
$menu =~ s/\[uname\]/$$author{user}/g; |
$menu =~ s/\[udom\]/$$author{dom}/g; |
$menu =~ s/\[udom\]/$$author{dom}/g; |
Line 968 sub innerregister {
|
Line 1013 sub innerregister {
|
$$showncrumbsref = 1; |
$$showncrumbsref = 1; |
} |
} |
return $trail; |
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) = |
|
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,1); |
|
return $trail; |
} |
} |
unless ($env{'request.state'} eq 'construct') { |
unless ($env{'request.state'} eq 'construct') { |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
Line 1069 sub innerregister {
|
Line 1126 sub innerregister {
|
if (($env{'request.symb'} ne '') && |
if (($env{'request.symb'} ne '') && |
($env{'request.filename'}=~/$LONCAPA::assess_re/) && |
($env{'request.filename'}=~/$LONCAPA::assess_re/) && |
(($perms{'mgr'}) || ($perms{'vgr'}))) { |
(($perms{'mgr'}) || ($perms{'vgr'}))) { |
my ($viewas,$text,$change,$visibility,$vuname,$vudom,$vid,$leftvis,$defdom,$righticon); |
my ($viewas,$text,$change,$visibility,$vuname,$vudom,$vid,$leftvis,$defdom, |
|
$domselector,$righticon); |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
view => 'View', |
view => 'View', |
upda => 'Update', |
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)$/) { |
if ($env{'request.user_in_effect'} =~ /^($match_username):($match_domain)$/) { |
($vuname,$vudom) = ($1,$2); |
($vuname,$vudom) = ($1,$2); |
unless (&Apache::lonnet::is_advanced_user($vudom,$vuname)) { |
unless (&Apache::lonnet::is_advanced_user($vudom,$vuname)) { |
Line 1091 sub innerregister {
|
Line 1167 sub innerregister {
|
$change = 'on'; |
$change = 'on'; |
$visibility = 'none'; |
$visibility = 'none'; |
$leftvis = 'inline'; |
$leftvis = 'inline'; |
$defdom = $cdom; |
if ($defdom eq '') { |
|
$defdom = $cdom; |
|
} |
} |
} |
my $sellink = &Apache::loncommon::selectstudent_link('userview','vuname','vudom'); |
my $sellink = &Apache::loncommon::selectstudent_link('userview','vuname','vudom','','','vuidentifier'); |
my $selscript=&Apache::loncommon::studentbrowser_javascript(); |
my $selscript=&Apache::loncommon::studentbrowser_javascript(); |
my $shownsymb = &HTML::Entities::encode(&Apache::lonenc::check_encrypt($env{'request.symb'}),'<>&"'); |
my $shownsymb = &HTML::Entities::encode(&Apache::lonenc::check_encrypt($env{'request.symb'}),'<>&"'); |
my $input = &mt('User: [_1] or ID: [_2] at: [_3]', |
my $input; |
'<input name="vuname" type="text" size="8" value="'.$vuname.'" />', |
my @items = ( |
'<input name="vid" type="text" size="8" value="'.$vid.'" />', |
'<label><input type="radio" name="vuidentifier" value="uname" checked="checked" onclick="javascript:toggleIdentifier(this.form);" />', |
&Apache::loncommon::select_dom_form($defdom,'vudom')). |
'</label><input name="vuname" type="text" size="6" value="'.$vuname.'" id="LC_vuname" />', |
'<input name="LC_viewas" type="hidden" value="'.$viewas.'" />', |
'<label><input type="radio" name="vuidentifier" value="uid" onclick="javascript:toggleIdentifier(this.form);" />', |
'<input name="symb" type="hidden" value="'.$shownsymb.'" />'; |
'</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; |
my $chooser = <<END; |
$selscript |
$selscript |
<a href="javascript:toggleViewAsUser('$change');" class="LC_menubuttons_link"> |
<a href="javascript:toggleViewAsUser('$change');" class="LC_menubuttons_link"> |
Line 1516 sub prepare_functions {
|
Line 1604 sub prepare_functions {
|
$editbutton = &get_editbutton($cfile,$home,$switchserver, |
$editbutton = &get_editbutton($cfile,$home,$switchserver, |
$forceedit,$forceview,$forcereg); |
$forceedit,$forceview,$forcereg); |
} |
} |
} elsif ((!$env{'request.course.id'}) && |
} elsif (!$env{'request.course.id'}) { |
($env{'user.author'}) && ($env{'request.filename'}) && |
if (($env{'user.author'}) && ($resurl eq '/adm/viewcoauthors')) { |
($env{'request.role'} !~/^(aa|ca|au)/)) { |
if ($env{'request.role'} =~/^(ca|au)/) { |
|
my ($audom,$auname); |
|
if ($env{'request.role'} eq "au./$env{'user.domain'}/") { |
|
($audom,$auname) = ($env{'user.domain'},$env{'user.name'}); |
|
} elsif ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)}) { |
|
($audom,$auname) = ($1,$2); |
|
} |
|
if (($audom ne '') && ($auname ne '')) { |
|
my $file=&Apache::lonnet::declutter($env{'request.filename'}); |
|
($cfile,$home,$switchserver,$forceedit,$forceview) = |
|
&Apache::lonnet::can_edit_resource($file,$auname,$audom, |
|
$resurl); |
|
if ($cfile) { |
|
$editbutton = &get_editbutton($resurl,'','',$forceedit, |
|
$forceview); |
|
} |
|
} |
|
} |
|
} elsif (($env{'user.author'}) && ($env{'request.filename'}) && |
|
($env{'request.role'} !~/^(aa|ca|au)/)) { |
# |
# |
# Currently do not have the role of author or co-author. |
# Currently do not have the role of author or co-author. |
# Do we have authoring privileges for the resource? |
# Do we have authoring privileges for the resource? |
# |
# |
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')) { |
$editbutton = &get_editbutton($cfile,$home,$switchserver, |
$editbutton = &get_editbutton($cfile,$home,$switchserver, |
$forceedit,$forceview,$forcereg); |
$forceedit,$forceview,$forcereg); |
|
} |
} |
} |
} elsif ($env{'request.course.id'}) { |
} elsif ($env{'request.course.id'}) { |
# |
# |
Line 1937 sub rawconfig {
|
Line 2045 sub rawconfig {
|
} else { |
} else { |
next; |
next; |
} |
} |
|
} elsif ($priv eq 'cca') { |
|
next if ($rol eq 'cm'); |
} |
} |
if ((($priv eq 'bre') && (&Apache::lonnet::allowed($priv,$prt) eq 'F')) || |
if ((($priv eq 'bre') && (&Apache::lonnet::allowed($priv,$prt) eq 'F')) || |
(($priv ne 'bre') && (&Apache::lonnet::allowed($priv,$prt)))) { |
(($priv ne 'bre') && (&Apache::lonnet::allowed($priv,$prt)))) { |
Line 2018 sub rawconfig {
|
Line 2128 sub rawconfig {
|
} |
} |
} |
} |
} |
} |
|
} elsif ($pro eq 'coauthor') { |
|
if ($env{'request.role'}=~ m{^(ca|aa)\./($match_domain)/($match_username)$}) { |
|
my ($role,$audom,$auname) = ($1,$2,$3); |
|
if ((($prt eq 'raa') && ($role eq 'aa')) || |
|
(($prt eq 'rca') && ($role eq 'ca') && |
|
(!$env{"environment.internal.manager./$audom/$auname"}))) { |
|
$output.=&switch($auname,$audom, |
|
$row,$col,$img,$top,$bot,$act,$desc,$cat); |
|
} |
|
} |
|
} elsif ($pro eq 'coauthorenv_manager') { |
|
if ($env{'request.role'}=~ m{^ca\./($match_domain)/($match_username)$}) { |
|
my ($audom,$auname) = ($1,$2); |
|
if ($env{"environment.internal.manager./$audom/$auname"}) { |
|
$output.=&switch($auname,$audom, |
|
$row,$col,$img,$top,$bot,$act,$desc,$cat); |
|
} |
|
} |
} elsif ($pro eq 'tools') { |
} elsif ($pro eq 'tools') { |
my @tools = ('aboutme','blog','portfolio'); |
my @tools = ('aboutme','blog','portfolio'); |
if (grep(/^\Q$prt\E$/,@tools)) { |
if (grep(/^\Q$prt\E$/,@tools)) { |
Line 2368 function toggleViewAsUser(change) {
|
Line 2496 function toggleViewAsUser(change) {
|
seluserid.style.display = 'inline'; |
seluserid.style.display = 'inline'; |
document.getElementById('usexpand').innerHTML=''; |
document.getElementById('usexpand').innerHTML=''; |
document.getElementById('uscollapse').innerHTML='◄ '; |
document.getElementById('uscollapse').innerHTML='◄ '; |
|
toggleIdentifier(document.userview); |
} |
} |
} |
} |
} |
} |
Line 2377 function toggleViewAsUser(change) {
|
Line 2506 function toggleViewAsUser(change) {
|
function validCourseUser(form,change) { |
function validCourseUser(form,change) { |
var possuname = form.elements['vuname'].value; |
var possuname = form.elements['vuname'].value; |
var possuid = form.elements['vid'].value; |
var possuid = form.elements['vid'].value; |
var possudom = form.elements['vudom'].options[form.elements['vudom'].selectedIndex].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 ((possuname == '') && (possuid == '')) { |
if (change == 'off') { |
if (change == 'off') { |
form.elements['LC_viewas'].value = ''; |
form.elements['LC_viewas'].value = ''; |
Line 2413 function validCourseUser(form,change) {
|
Line 2548 function validCourseUser(form,change) {
|
return false; |
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 |
END |
} |
} |
|
|