@@ -249,24 +362,26 @@ ENDCRELOAD
$utility
// ]]>
-
+$role_selector
+
$form
+
$reg
ENDINLINEMENU
} else {
@@ -274,7 +389,19 @@ ENDINLINEMENU
}
}
-# ====================================== This gets called in the header section
+sub show_return_link {
+ return (($env{'request.noversionuri'}=~m{^/(res|public)/} &&
+ $env{'request.symb'} eq '')
+ ||
+ ($env{'request.noversionuri'}=~ m{^/cgi-bin/printout.pl})
+ ||
+ (($env{'request.noversionuri'}=~/^\/adm\//) &&
+ ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
+ ($env{'request.noversionuri'}!~
+ m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])
+ ));
+}
+
sub registerurl {
my ($forcereg) = @_;
@@ -299,9 +426,6 @@ sub registerurl {
return $result.$force_title;
}
-# =========== This gets called in order to register a URL, both with the Remote
-# =========== and in the body of the document
-
sub innerregister {
my ($forcereg, $titletable) = @_;
my $result = '';
@@ -334,16 +458,18 @@ sub innerregister {
} else {
$newmail= 'swmenu.setstatus("you have","messages");';
}
- } elsif (($textual)
+ }
+ if (($textual)
&& ($env{'request.symb'})
&& ($env{'request.course.id'})) {
$newmail.= '';
my ($mapurl,$rid,$resurl)=
&Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
- $newmail.=$env{'course.'.$env{'request.course.id'}.'.description'};
+ my $coursetitle=$env{'course.'.$env{'request.course.id'}.'.description'};
+ $newmail.=$coursetitle;
my $maptitle=&Apache::lonnet::gettitle($mapurl);
my $restitle=&Apache::lonnet::gettitle(&Apache::lonnet::symbread());
- if ($maptitle && $maptitle ne 'default.sequence') {
+ if ($maptitle && ($maptitle ne 'default.sequence') && ($maptitle ne $coursetitle)) {
$newmail.=', '.$maptitle;
}
if ($restitle) {
@@ -376,7 +502,7 @@ sub innerregister {
if ($env{'request.symb'} ne '' &&
$env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) {
if (&Apache::lonnet::allowed('mgr',$crs)) {
- $hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_3]',
+ $hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_4]',
"gocmd('/adm/grades','gradingmenu')",
'Modify user grades for this assessment resource');
} elsif (&Apache::lonnet::allowed('vgr',$crs)) {
@@ -397,20 +523,31 @@ sub innerregister {
### resource
###
my $editbutton = '';
+ my $noeditbutton = 1;
+ my ($cnum,$cdom);
+ if ($env{'request.course.id'}) {
+ $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ }
if ($env{'user.author'}) {
- if ($env{'request.role'}=~/^(ca|au)/) {
+ if ($env{'request.role'}=~/^(aa|ca|au)/) {
# Set defaults for authors
my ($top,$bottom) = ('con-','struct');
my $action = "go('/priv/".$env{'user.name'}."');";
my $cadom = $env{'request.role.domain'};
my $caname = $env{'user.name'};
- my $desc = "Enter my resource construction space";
+ my $desc = "Enter my construction space";
# Set defaults for co-authors
if ($env{'request.role'} =~ /^ca/) {
($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
($top,$bottom) = ('co con-','struct');
$action = "go('/priv/".$caname."');";
$desc = "Enter construction space as co-author";
+ } elsif ($env{'request.role'} =~ /^aa/) {
+ ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
+ ($top,$bottom) = ('co con-','struct');
+ $action = "go('/priv/".$caname."');";
+ $desc = "Enter construction space as assistant co-author";
}
# Check that we are on the correct machine
my $home = &Apache::lonnet::homeserver($caname,$cadom);
@@ -419,6 +556,7 @@ sub innerregister {
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
if (!$allowed) {
$editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);
+ $noeditbutton = 0;
}
}
##
@@ -427,30 +565,53 @@ sub innerregister {
my $cfile='';
my $cfuname='';
my $cfudom='';
+ my $uploaded;
if ($env{'request.filename'}) {
my $file=&Apache::lonnet::declutter($env{'request.filename'});
- $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/;
- # Check that the user has permission to edit this resource
- ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
- if (defined($cfudom)) {
- my $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
- my $allowed=0;
- my @ids=&Apache::lonnet::current_machine_ids();
- foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
- if ($allowed) {
- $cfile=$file;
+ if (defined($cnum) && defined($cdom)) {
+ $uploaded = &is_course_upload($file,$cnum,$cdom);
+ }
+ if (!$uploaded) {
+ $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/;
+ # Check that the user has permission to edit this resource
+ ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
+ if (defined($cfudom)) {
+ my $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
+ my $allowed=0;
+ my @ids=&Apache::lonnet::current_machine_ids();
+ foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
+ if ($allowed) {
+ $cfile=$file;
+ }
}
}
- }
+ }
# Finally, turn the button on or off
if ($cfile && !$const_space) {
$editbutton=&switch
('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',
"go('".$cfile."');","Edit this resource");
+ $noeditbutton = 0;
} elsif ($editbutton eq '') {
$editbutton=&clear(6,1);
}
}
+ if (($noeditbutton) && ($env{'request.filename'})) {
+ if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
+ my $file=&Apache::lonnet::declutter($env{'request.filename'});
+ if (defined($cnum) && defined($cdom)) {
+ if (&is_course_upload($file,$cnum,$cdom)) {
+ my $cfile = &edit_course_upload($file,$cnum,$cdom);
+ if ($cfile) {
+ $editbutton=&switch
+ ('','',6,1,'pcstr.gif','edit[_1]',
+ 'resource[_2]',"go('".$cfile."');",
+ 'Edit this resource');
+ }
+ }
+ }
+ }
+ }
###
###
# Prepare the rest of the buttons
@@ -468,7 +629,7 @@ sub innerregister {
$menuitems=(< 0){
+ $menuitems.="anot2.gif";
+}else{
+ $menuitems.="anot.gif";
+}
+$menuitems.="&anno-[_1]&tations[_1]&annotate()&";
+$menuitems.="Make notes and annotations about this resource&&1\n";
+
unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
if (!$env{'request.enc'}) {
$menuitems.=(<
$inlineremote[21] $inlineremote[23]
+ENDARROWSINLINE
+ if (&hidden_button_check() ne 'yes') {
+ $inlinebuttons .= (<
ENDINLINEICONS
+ }
} else {
- $inlinebuttons=(<$inlineremote[21] | | $inlineremote[23] |
-$inlineremote[61] | $inlineremote[62] | $inlineremote[63] |
-$inlineremote[71] | $inlineremote[72] | $inlineremote[73] |
-$inlineremote[81] | $inlineremote[82] | $inlineremote[83] |
-$inlineremote[91] | $inlineremote[92] | $inlineremote[93] |
-ENDINLINE
- }
- }
+ENDFIRSTLINE
+ }
+ if (&hidden_button_check() ne 'yes') {
+ foreach my $row (6..9) {
+ if ($inlineremote[${row}.'1'] ne ''
+ || $inlineremote[$row.'2'] ne ''
+ || $inlineremote[$row.'3'] ne '') {
+ $inlinebuttons .= <<"ENDLINE";
+$inlineremote["${row}1"] | $inlineremote["${row}2"] | $inlineremote["${row}3"] |
+ENDLINE
+ }
+ }
+ }
+ }
+ }
}
$result =(<
// BEGIN LON-CAPA Internal
$timesync
-$newmail
$tablestart
$inlinebuttons
$tableend
+$newmail
@@ -653,6 +846,42 @@ ENDDONOTREGTHIS
return $result;
}
+sub is_course_upload {
+ my ($file,$cnum,$cdom) = @_;
+ my $uploadpath = &LONCAPA::propath($cdom,$cnum);
+ $uploadpath =~ s{^\/}{};
+ if (($file =~ m{^\Q$uploadpath\E/userfiles/docs/}) ||
+ ($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/docs/})) {
+ return 1;
+ }
+ return;
+}
+
+sub edit_course_upload {
+ my ($file,$cnum,$cdom) = @_;
+ my $cfile;
+ if ($file =~/\.(htm|html|css|js|txt)$/) {
+ my $ext = $1;
+ my $url = &Apache::lonnet::hreflocation('',$file);
+ my $home = &Apache::lonnet::homeserver($cnum,$cdom);
+ my @ids=&Apache::lonnet::current_machine_ids();
+ my $dest;
+ if ($home && grep(/^\Q$home\E$/,@ids)) {
+ $dest = $url.'?forceedit=1';
+ } else {
+ unless (&Apache::lonnet::get_locks()) {
+ $dest = '/adm/switchserver?otherserver='.
+ $home.'&role='.$env{'request.role'}.
+ '&url='.$url.'&forceedit=1';
+ }
+ }
+ if ($dest) {
+ $cfile = &HTML::Entities::encode($dest,'"<>&');
+ }
+ }
+ return $cfile;
+}
+
sub loadevents() {
if ($env{'request.state'} eq 'construct' ||
$env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
@@ -665,7 +894,6 @@ sub unloadevents() {
return 'LONCAPAstale();';
}
-# ============================================================= Start up remote
sub startupremote {
my ($lowerurl)=@_;
@@ -761,8 +989,9 @@ sub load_remote_msg {
($env{'environment.remote'} eq 'off')) { return ''; }
my $esclowerurl=&escape($lowerurl);
- my $link=&mt('Continue on in Inline Menu mode',
- "/adm/remote?action=collapse&url=$esclowerurl");
+ my $link=&mt('[_1]Continue[_2] on in Inline Menu mode'
+ ,''
+ ,'');
return(<
| |