version 1.540, 2023/10/06 02:04:47
|
version 1.543, 2023/12/13 22:12:16
|
Line 245 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,$links_target) = @_; |
my ($crstype,$ltimenu,$menucoll,$menuref,$links_disabled,$links_target,$collapsible) = @_; |
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 366 sub primary_menu {
|
Line 366 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 (($item->[2] eq 'browsepub') && ($item->[0] eq '/res/')) { |
|
if ($env{'request.role'} =~ /^au\./) { |
|
$item->[0] .= $env{'request.role.domain'}.'/?launch=1'; |
|
} elsif ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)$}) { |
|
$item->[0] .= $1.'/'.$2.'/?launch=1'; |
|
} elsif (&Apache::lonnet::allowed('bre',$env{'user.domain'})) { |
|
$item->[0] .= $env{'user.domain'}.'/?launch=1'; |
|
} elsif (&Apache::lonnet::allowed('bro','/res/')) { |
|
$item->[0] .= '?launch=1'; |
|
} else { |
|
next; |
|
} |
if ($env{'request.course.id'} && $menucoll) { |
if ($env{'request.course.id'} && $menucoll) { |
next if ($item->[3]) && (!$menuopts{$item->[3]}); |
next if ($item->[3]) && (!$menuopts{$item->[3]}); |
} |
} |
Line 421 sub primary_menu {
|
Line 433 sub primary_menu {
|
} |
} |
my @output = ('',''); |
my @output = ('',''); |
if ($menu{'left'} ne '') { |
if ($menu{'left'} ne '') { |
|
if ($collapsible) { |
|
$menu{'left'} = ($listclass?'<li class="'.$listclass.'">':'<li>'). |
|
' </li>'.$menu{'left'}; |
|
} |
$output[0] = "<ol class=\"LC_primary_menu LC_floatleft\">$menu{'left'}</ol>"; |
$output[0] = "<ol class=\"LC_primary_menu LC_floatleft\">$menu{'left'}</ol>"; |
} |
} |
if ($menu{'right'} ne '') { |
if ($menu{'right'} ne '') { |
Line 436 sub primary_menu {
|
Line 452 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 496 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 564 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 605 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 638 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 684 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 771 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 1559 sub prepare_functions {
|
Line 1620 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 1980 sub rawconfig {
|
Line 2061 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 2061 sub rawconfig {
|
Line 2144 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)) { |