-// BEGIN LON-CAPA Internal
//
@@ -257,8 +364,7 @@ $reloadlink
$navmaps
$docs
$groups
-$remote
-$lt{'roles'} |
+$roles
$helplink |
$lt{'exit'} |
@@ -274,7 +380,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) = @_;
@@ -291,7 +409,9 @@ sub registerurl {
&unescape($env{'request.noversionuri'})))) &&
(!$forcereg))) {
return $result.
- ''.$force_title;
+ ''.$force_title;
}
# Graphical display after login only
if ($env{'request.registered'} && !$forcereg) { return ''; }
@@ -299,9 +419,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 +451,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 +495,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 +516,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 +549,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,6 +558,7 @@ 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/;
@@ -447,10 +579,27 @@ sub innerregister {
$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 +617,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 ($noremote) {
+ my $showreqcrs = &check_for_rcrs();
+ if ($showreqcrs) {
+ $menuitems.="s&8&1&rcrs.gif&request[_1]&course[_16]".
+ "&go('/adm/requestcourse')&Course requests\n";
+ }
+ }
unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
- if (!$env{'request.enc'}) {
+ if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) {
$menuitems.=(<
+//
ENDREGTHIS
}
@@ -642,6 +811,7 @@ ENDDONOTREGTEXT
$result = (<
+//
ENDDONOTREGTHIS
}
@@ -674,6 +845,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 ''; }
@@ -686,7 +893,6 @@ sub unloadevents() {
return 'LONCAPAstale();';
}
-# ============================================================= Start up remote
sub startupremote {
my ($lowerurl)=@_;
@@ -702,6 +908,7 @@ sub startupremote {
my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
return(<
+//
ENDREMOTESTARTUP
}
@@ -759,8 +966,10 @@ ENDREMOTESTARTUP
sub setflags() {
return(<
+//
ENDSETFLAGS
}
@@ -770,7 +979,9 @@ sub maincall() {
($env{'environment.remote'} eq 'off')) { return ''; }
return(<
+//
ENDMAINCALL
}
@@ -782,8 +993,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(<
|