--- loncom/lonnet/perl/lonnet.pm 2004/06/30 12:33:47 1.517
+++ loncom/lonnet/perl/lonnet.pm 2004/07/22 22:12:06 1.523
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.517 2004/06/30 12:33:47 albertel Exp $
+# $Id: lonnet.pm,v 1.523 2004/07/22 22:12:06 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1282,6 +1282,22 @@ sub userfileupload {
# See if there is anything left
unless ($fname) { return 'error: no uploaded file'; }
chop($ENV{'form.'.$formname});
+ if (($formname eq 'screenshot') && ($subdir eq 'helprequests')) { #files uploaded to help request form are handled differently
+ my $now = time;
+ my $filepath = 'tmp/helprequests/'.$now;
+ my @parts=split(/\//,$filepath);
+ my $fullpath = $perlvar{'lonDaemons'};
+ for (my $i=0;$i<@parts;$i++) {
+ $fullpath .= '/'.$parts[$i];
+ if ((-e $fullpath)!=1) {
+ mkdir($fullpath,0777);
+ }
+ }
+ open(my $fh,'>'.$fullpath.'/'.$fname);
+ print $fh $ENV{'form.'.$formname};
+ close($fh);
+ return $fullpath.'/'.$fname;
+ }
# Create the directory if not present
my $docuname='';
my $docudom='';
@@ -1600,7 +1616,7 @@ sub getannounce {
if ($announcement=~/\w/) {
return
'
';
+ ''.$announcement.' |
';
} else {
return '';
}
@@ -3203,6 +3219,32 @@ sub auto_create_password {
return ($authparam,$create_passwd,$authchk);
}
+sub auto_instcode_format {
+ my ($caller,$codedom,$instcodes,$codes,$codetitles,$cat_titles,$cat_order) = @_;
+ my $courses = '';
+ my $homeserver;
+ if ($caller eq 'global') {
+ $homeserver = $perlvar{'lonHostID'};
+ } else {
+ $homeserver = &homeserver($caller,$codedom);
+ }
+ my $host=$hostname{$homeserver};
+ foreach (keys %{$instcodes}) {
+ $courses .= &escape($_).'='.&escape($$instcodes{$_}).'&';
+ }
+ chop($courses);
+ my $response=&reply('autoinstcodeformat:'.$codedom.':'.$courses,$homeserver);
+ unless ($response =~ /(con_lost|error|no_such_host|refused)/) {
+ my ($codes_str,$codetitles_str,$cat_titles_str,$cat_order_str) = split/:/,$response;
+ %{$codes} = &str2hash($codes_str);
+ @{$codetitles} = &str2array($codetitles_str);
+ %{$cat_titles} = &str2hash($cat_titles_str);
+ %{$cat_order} = &str2hash($cat_order_str);
+ return 'ok';
+ }
+ return $response;
+}
+
# ------------------------------------------------------------------ Plain Text
sub plaintext {
@@ -3585,16 +3627,19 @@ sub revokecustomrole {
# ------------------------------------------------------------ Portfolio Director Lister
+# returns listing of contents of user's /userfiles/portfolio/ directory
+#
+
sub portfoliolist {
-#FIXME us the ls: command instead please
-#FIXME uhome should never be an argument to any lonnet functions
- # returns listing of contents of user's /userfiles/portfolio/ directory
- #
- my ($udom,$uname,$uhome);
+ my ($currentPath, $currentFile) = @_;
+ my ($udom, $uname, $portfolioRoot);
$uname=$ENV{'user.name'};
$udom=$ENV{'user.domain'};
- $uhome=$ENV{'user.home'};
- my $listing = &reply('portls:'.$uname.':'.$udom, $uhome);
+ # really should interrogate the system for home directory information, but . . .
+ $portfolioRoot = '/home/httpd/lonUsers/'.$udom.'/';
+ $uname =~ /^(.?)(.?)(.?)/;
+ $portfolioRoot = $portfolioRoot.$1.'/'.$2.'/'.$3.'/'.$uname.'/userfiles/portfolio';
+ my $listing = &reply('ls:'.$portfolioRoot.$currentPath, &homeserver($uname,$udom));
return $listing;
}
@@ -4899,7 +4944,6 @@ sub getfile {
}
} else {
$lwpresp = &getuploaded('GET',$file,$cdom,$cnum,\$info,\$rtncode);
- &logthis("return is $lwpresp");
if ($lwpresp ne 'ok') {
my $ua=new LWP::UserAgent;
my $request=new HTTP::Request('GET',&tokenwrapper($file));
@@ -4913,7 +4957,7 @@ sub getfile {
my @parts = ($cdom,$cnum);
if ($filename =~ m|^(.+)/[^/]+$|) {
push @parts, split(/\//,$1);
- }
+ }
foreach my $part (@parts) {
$path .= '/'.$part;
if (!-e $path) {