version 1.71, 2005/01/18 02:18:29
|
version 1.82, 2005/04/07 06:56:23
|
Line 29 use Apache::lonnet;
|
Line 29 use Apache::lonnet;
|
use Apache::lontexconvert; |
use Apache::lontexconvert; |
use Apache::lonfeedback; |
use Apache::lonfeedback; |
use Apache::lonlocal; |
use Apache::lonlocal; |
|
use Apache::lonnet; |
|
|
# receives a file name and path stub from username/userfiles/portfolio/ |
# receives a file name and path stub from username/userfiles/portfolio/ |
# returns an anchor tag consisting encoding filename and currentpath |
# returns an anchor tag consisting encoding filename and currentpath |
Line 46 sub display_common {
|
Line 47 sub display_common {
|
my $displayOut = '<form method="post" enctype="multipart/form-data">'; |
my $displayOut = '<form method="post" enctype="multipart/form-data">'; |
$displayOut .= '<input name="uploaddoc" type="file" />'. |
$displayOut .= '<input name="uploaddoc" type="file" />'. |
'<input type="hidden" name="currentpath" value="'.$current_path.'" />'. |
'<input type="hidden" name="currentpath" value="'.$current_path.'" />'. |
'<input type="hidden" name="action" value="'.$ENV{"form.action"}.'" />'. |
'<input type="hidden" name="action" value="'.$env{"form.action"}.'" />'. |
'<input type="hidden" name="fieldname" value="'.$ENV{"form.fieldname"}.'" />'. |
'<input type="hidden" name="fieldname" value="'.$env{"form.fieldname"}.'" />'. |
'<input type="hidden" name="mode" value="'.$ENV{"form.mode"}.'" />'. |
'<input type="hidden" name="mode" value="'.$env{"form.mode"}.'" />'. |
'<input type="submit" name="storeupl" value="Upload" />'. |
'<input type="submit" name="storeupl" value="Upload" />'. |
'</form>'; |
'</form>'; |
$r->print($displayOut); |
$r->print($displayOut); |
Line 56 sub display_common {
|
Line 57 sub display_common {
|
$displayOut = '<form method="post">'; |
$displayOut = '<form method="post">'; |
$displayOut .= '<input name="newdir" type="input" />'. |
$displayOut .= '<input name="newdir" type="input" />'. |
'<input type="hidden" name="currentpath" value="'.$current_path.'" />'. |
'<input type="hidden" name="currentpath" value="'.$current_path.'" />'. |
'<input type="hidden" name="action" value="'.$ENV{"form.action"}.'" />'. |
'<input type="hidden" name="action" value="'.$env{"form.action"}.'" />'. |
'<input type="hidden" name="fieldname" value="'.$ENV{"form.fieldname"}.'" />'. |
'<input type="hidden" name="fieldname" value="'.$env{"form.fieldname"}.'" />'. |
'<input type="hidden" name="mode" value="'.$ENV{"form.mode"}.'" />'. |
'<input type="hidden" name="mode" value="'.$env{"form.mode"}.'" />'. |
'<input type="submit" name="createdir" value="'.&mt("Create Directory").'" />'. |
'<input type="submit" name="createdir" value="'.&mt("Create Directory").'" />'. |
'</form>'; |
'</form>'; |
$r->print($displayOut); |
$r->print($displayOut); |
$r->print('</td></tr></table>'); |
$r->print('</td></tr></table>'); |
my @tree = split (/\//,$current_path); |
my @tree = split (/\//,$current_path); |
$r->print('<font size="+2">'.&make_anchor('portfolio','/',$ENV{"form.mode"},$ENV{"form.fieldname"}).'/'); |
$r->print('<font size="+2">'.&make_anchor('portfolio','/',$env{"form.mode"},$env{"form.fieldname"}).'/'); |
if (@tree > 1){ |
if (@tree > 1){ |
my $newCurrentPath = ''; |
my $newCurrentPath = ''; |
for (my $i = 1; $i< @tree; $i++){ |
for (my $i = 1; $i< @tree; $i++){ |
$newCurrentPath .= $tree[$i].'/'; |
$newCurrentPath .= $tree[$i].'/'; |
$r->print(&make_anchor($tree[$i],'/'.$newCurrentPath, $ENV{"form.mode"},$ENV{"form.fieldname"}).'/'); |
$r->print(&make_anchor($tree[$i],'/'.$newCurrentPath, $env{"form.mode"},$env{"form.fieldname"}).'/'); |
} |
} |
} |
} |
$r->print('</font>'); |
$r->print('</font>'); |
&Apache::lonhtmlcommon::store_recent('portfolio',$current_path,$current_path); |
&Apache::lonhtmlcommon::store_recent('portfolio',$current_path,$current_path); |
$r->print('<br /><form method=post action="/adm/portfolio?mode='.$ENV{"form.mode"}.'&fieldname='.$ENV{"form.fieldname"}.'">'. |
$r->print('<br /><form method=post action="/adm/portfolio?mode='.$env{"form.mode"}.'&fieldname='.$env{"form.fieldname"}.'">'. |
&Apache::lonhtmlcommon::select_recent('portfolio','currentpath', |
&Apache::lonhtmlcommon::select_recent('portfolio','currentpath', |
'this.form.submit();')); |
'this.form.submit();')); |
$r->print("</form>"); |
$r->print("</form>"); |
Line 83 sub display_directory {
|
Line 84 sub display_directory {
|
my ($r,$current_path,$is_empty,$dir_list)=@_; |
my ($r,$current_path,$is_empty,$dir_list)=@_; |
my $iconpath= $r->dir_config('lonIconsURL') . "/"; |
my $iconpath= $r->dir_config('lonIconsURL') . "/"; |
my $display_out; |
my $display_out; |
my %locked_files = &Apache::lonnet::get_marked_as_readonly_hash ($ENV{'user.domain'},$ENV{'user.name'}); |
my $select_mode; |
|
my $checked_files; |
|
my %locked_files = &Apache::lonnet::get_marked_as_readonly_hash ($env{'user.domain'},$env{'user.name'}); |
|
if ($env{"form.mode"} eq 'selectfile'){ |
|
&select_files($r); |
|
$checked_files =&Apache::lonnet::files_in_path($env{'user.name'},$env{'form.currentpath'}); |
|
$select_mode = 'true'; |
|
} |
if ($is_empty && ($current_path ne '/')) { |
if ($is_empty && ($current_path ne '/')) { |
$display_out = '<form method="post" action="/adm/portfolio">'. |
$display_out = '<form method="post" action="/adm/portfolio">'. |
'<input type="hidden" name="action" value="deletedir" />'. |
'<input type="hidden" name="action" value="deletedir" />'. |
Line 95 sub display_directory {
|
Line 103 sub display_directory {
|
$r->print($display_out); |
$r->print($display_out); |
return; |
return; |
} |
} |
$r->print('<table border="0" cellspacing="2" cellpadding="2">'. |
if ($select_mode eq 'true') { |
|
$r->print('<table border="0" cellspacing="2" cellpadding="2">'. |
|
'<tr><th>Select</th><th> </th><th>Name</th><th>Size</th><th>Last Modified</th></tr>'); |
|
$r->print('<form method="post" name="checkselect" action="/adm/portfolio">'); |
|
} else { |
|
$r->print('<table border="0" cellspacing="2" cellpadding="2">'. |
'<tr><th colspan="2">Actions</th><th> </th><th>Name</th><th>Size</th><th>Last Modified</th></tr>'); |
'<tr><th colspan="2">Actions</th><th> </th><th>Name</th><th>Size</th><th>Last Modified</th></tr>'); |
my $href_location="/uploaded/$ENV{'user.domain'}/$ENV{'user.name'}/portfolio$current_path"; |
$r->print('<form method="post" action="/adm/portfolio">'); |
$r->print('<form method="post" action="/adm/portfolio">'); |
|
foreach my $line (sort |
|
{ |
|
my ($afile)=split('&',$a,2); |
|
my ($bfile)=split('&',$b,2); |
|
return (lc($afile) cmp lc($bfile)); |
|
} (@$dir_list)) { |
|
#$strip holds directory/file name |
|
#$dom |
|
my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); |
|
if (($filename ne '.') && ($filename ne '..')) { |
|
if ($dirptr&$testdir) { |
|
$r->print('<tr bgcolor="#FFAA99"><td colspan="2"><img src="'.$iconpath.'folder_closed.gif"></td>'); |
|
$r->print('<td>Go to ...</td>'); |
|
$r->print('<td>'.&make_anchor($filename.'/',$current_path.$filename.'/',$ENV{'form.mode'},$ENV{"form.fieldname"}).'</td>'); |
|
$r->print('</tr>'); |
|
} else { |
|
$r->print('<tr bgcolor="#CCCCFF">'); |
|
if (exists $locked_files{$current_path.$filename}){ |
|
$r->print('<td colspan="2">Locked</td>'); |
|
} else { |
|
$r->print('<td><input type="checkbox" name="selectfile" value="'.$filename.'" /> |
|
<a href="/adm/portfolio?rename='.$filename.'&currentpath='.$current_path.'">Rename</a></td> |
|
<td><a href="/adm/portfolio?meta='.$filename.'&currentpath='.$current_path.'">Meta</a> |
|
</td>'); |
|
} |
|
$r->print('<td><img src="'.$iconpath.'unknown.gif"></td>'); |
|
$r->print('<td><a href="'.$href_location.$filename.'">'. |
|
$filename.'</a></td>'); |
|
$r->print('<td>'.$size.'</td>'); |
|
$r->print('<td>'.&Apache::lonlocal::locallocaltime($mtime).'</td>'); |
|
$r->print('</tr>'); |
|
} |
|
} |
|
} |
} |
# <tr bgcolor="#FFAA99"> pink bg |
my $href_location="/uploaded/$env{'user.domain'}/$env{'user.name'}/portfolio$current_path"; |
# <tr bgcolor="#CCCCFF"> blue bg |
my $href_edit_location="/editupload/$env{'user.domain'}/$env{'user.name'}/portfolio$current_path"; |
# $r->print(&display_directory($current_path, $currentFile, @dir_list)); |
|
# $r->print('</td>><td>'); |
|
# $r->print(&display_actions($current_path, $currentFile, $isEmpty)); |
|
$r->print('</table> |
|
<input type="submit" name="doit" value="Delete Checked Files" /> |
|
<input type="hidden" name="action" value="delete" /> |
|
<input type="hidden" name="currentpath" value="'.$current_path.'" /> |
|
</form>'); |
|
} |
|
sub display_file_select { |
|
my ($r,$current_path,$is_empty,$dir_list)=@_; |
|
my $iconpath= $r->dir_config('lonIconsURL') . "/"; |
|
my $display_out; |
|
my $checked_files = &Apache::lonnet::files_in_path($ENV{'user.name'}, $ENV{'form.currentpath'}); |
|
if ($is_empty && ($current_path ne '/')) { |
|
$display_out = '<form method="post" action="/adm/portfolio">'. |
|
'<input type="hidden" name="action" value="deletedir" />'. |
|
'<input type="submit" name="deletedir" value="'.&mt("Delete Directory").'" />'. |
|
'<input type="hidden" name="selectfile" value="" />'. |
|
'<input type="hidden" name="currentpath" value="'.$current_path.'" />'. |
|
|
|
'</form>'; |
|
|
|
$r->print($display_out); |
|
return; |
|
} |
|
$r->print('<table border="0" cellspacing="2" cellpadding="2">'. |
|
'<tr><th>Select</th><th> </th><th>Name</th><th>Size</th><th>Last Modified</th></tr>'); |
|
my $href_location="/uploaded/$ENV{'user.domain'}/$ENV{'user.name'}/portfolio$current_path"; |
|
$r->print('<form method="post" name="checkselect" action="/adm/portfolio">'); |
|
foreach my $line (sort |
foreach my $line (sort |
{ |
{ |
my ($afile)=split('&',$a,2); |
my ($afile)=split('&',$a,2); |
Line 175 sub display_file_select {
|
Line 124 sub display_file_select {
|
#$dom |
#$dom |
my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); |
my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); |
$filename =~ s/\s+$//; |
$filename =~ s/\s+$//; |
if (($filename ne '.') && ($filename ne '..')) { |
if (($filename ne '.') && ($filename ne '..') && ($filename !~ /\.meta$/ )) { |
if ($dirptr&$testdir) { |
if ($dirptr&$testdir) { |
$r->print('<tr bgcolor="#FFAA99"><td><img src="'.$iconpath.'folder_closed.gif"></td>'); |
if ($select_mode eq 'true'){ |
|
$r->print('<tr bgcolor="#FFAA99"><td><img src="'.$iconpath.'folder_closed.gif"></td>'); |
|
} else { |
|
$r->print('<tr bgcolor="#FFAA99"><td colspan="2"><img src="'.$iconpath.'folder_closed.gif"></td>'); |
|
} |
$r->print('<td>Go to ...</td>'); |
$r->print('<td>Go to ...</td>'); |
$r->print('<td>'.&make_anchor($filename.'/',$current_path.$filename.'/',$ENV{'form.mode'},$ENV{"form.fieldname"}).'</td>'); |
$r->print('<td>'.&make_anchor($filename.'/',$current_path.$filename.'/',$env{'form.mode'},$env{"form.fieldname"}).'</td>'); |
$r->print('</tr>'); |
$r->print('</tr>'); |
} else { |
} else { |
$r->print('<tr bgcolor="#CCCCFF">'); |
$r->print('<tr bgcolor="#CCCCFF">'); |
$r->print('<td><input type="checkbox" name="selectfile" value="'.$filename.'"'); |
if ($select_mode eq 'true'){ |
if ($$checked_files{$filename} eq 'selected') { |
$r->print('<td><input type="checkbox" name="selectfile" value="'.$filename.'"'); |
$r->print("CHECKED"); |
if ($$checked_files{$filename} eq 'selected') { |
|
$r->print("CHECKED"); |
|
} |
|
$r->print('></td>'); |
|
} else { |
|
if (exists $locked_files{$current_path.$filename}){ |
|
$r->print('<td colspan="2"><a href="portfolio?lockinfo='.$current_path.$filename.'">Locked</a></td>'); |
|
} else { |
|
$r->print('<td><input type="checkbox" name="selectfile" value="'.$filename.'" /> |
|
<a href="/adm/portfolio?rename='.$filename.'&currentpath='.$current_path.'">Rename</a></td> |
|
<td><a href="'.$href_edit_location.$filename.'.meta">Meta</a> |
|
</td>'); |
|
} |
} |
} |
$r->print('></td>'); |
|
$r->print('<td><img src="'.$iconpath.'unknown.gif"></td>'); |
$r->print('<td><img src="'.$iconpath.'unknown.gif"></td>'); |
$r->print('<td><a href="'.$href_location.$filename.'">'. |
$r->print('<td><a href="'.$href_location.$filename.'">'. |
$filename.'</a></td>'); |
$filename.'</a></td>'); |
Line 197 sub display_file_select {
|
Line 161 sub display_file_select {
|
} |
} |
} |
} |
} |
} |
$r->print('</table> |
if ($select_mode eq 'true') { |
|
$r->print('</table> |
<input type="hidden" name="continue" value="true"> |
<input type="hidden" name="continue" value="true"> |
<input type="hidden" name="fieldname" value="'.$ENV{'form.fieldname'}.'"> |
<input type="hidden" name="fieldname" value="'.$env{'form.fieldname'}.'"> |
<input type="hidden" name="mode" value="selectfile"> |
<input type="hidden" name="mode" value="selectfile"> |
<input type="submit" name="submit" value="Select checked files, and continue selecting." /><br /> |
<input type="submit" name="submit" value="Select checked files, and continue selecting." /><br /> |
<input type="button" name="doit" onClick= "finishSelect();" value="Select checked files, and close window" /> |
<input type="button" name="doit" onClick= "finishSelect();" value="Select checked files, and close window" /> |
<input type="hidden" name="currentpath" value="'.$current_path.'" /> |
<input type="hidden" name="currentpath" value="'.$current_path.'" /> |
</form>'); |
</form>'); |
} |
} else { |
sub prettyinput { |
$r->print('</table> |
my ($type,$value,$fieldname,$formname, |
<input type="submit" name="doit" value="Delete Checked Files" /> |
$relatedsearchflag,$relatedsep,$relatedvalue,$size)=@_; |
<input type="hidden" name="action" value="delete" /> |
if (! defined($size)) { |
<input type="hidden" name="currentpath" value="'.$current_path.'" /> |
$size = 80; |
</form>'); |
} |
|
# Language |
|
if ($type eq 'language') { |
|
return &Apache::lonmeta::selectbox($fieldname, |
|
$value, |
|
\&Apache::loncommon::languagedescription, |
|
(&Apache::loncommon::languageids)). |
|
&relatedfield(0,$relatedsearchflag,$relatedsep); |
|
} |
|
# Copyright |
|
if ($type eq 'copyright') { |
|
return &Apache::lonmeta::selectbox($fieldname, |
|
$value, |
|
\&Apache::loncommon::copyrightdescription, |
|
(&Apache::loncommon::copyrightids)). |
|
&relatedfield(0,$relatedsearchflag,$relatedsep); |
|
} |
|
# Source Copyright |
|
if ($type eq 'sourceavail') { |
|
return &Apache::lonmeta::selectbox($fieldname, |
|
$value, |
|
\&Apache::loncommon::source_copyrightdescription, |
|
(&Apache::loncommon::source_copyrightids)). |
|
&relatedfield(0,$relatedsearchflag,$relatedsep); |
|
} |
|
# Gradelevels |
|
if (($type eq 'lowestgradelevel') || |
|
($type eq 'highestgradelevel')) { |
|
return &Apache::loncommon::select_level_form($value,$fieldname). |
|
&relatedfield(0,$relatedsearchflag,$relatedsep); |
|
} |
|
# Obsolete |
|
if ($type eq 'obsolete') { |
|
return '<input type="checkbox" name="'.$fieldname.'"'. |
|
($value?' checked="1"':'').' />'. |
|
&relatedfield(0,$relatedsearchflag,$relatedsep); |
|
} |
|
# Obsolete replacement file |
|
if ($type eq 'obsoletereplacement') { |
|
return '<input type="text" name="'.$fieldname. |
|
'" size="60" value="'.$value.'" /><a href="javascript:openbrowser'. |
|
"('".$formname."','".$fieldname."'". |
|
",'')\">".&mt('Select').'</a>'. |
|
&relatedfield(0,$relatedsearchflag,$relatedsep); |
|
} |
|
# Customdistribution file |
|
if ($type eq 'customdistributionfile') { |
|
return '<input type="text" name="'.$fieldname. |
|
'" size="60" value="'.$value.'" /><a href="javascript:openbrowser'. |
|
"('".$formname."','".$fieldname."'". |
|
",'rights')\">".&mt('Select').'</a>'. |
|
&relatedfield(0,$relatedsearchflag,$relatedsep); |
|
} |
|
# Source Customdistribution file |
|
if ($type eq 'sourcerights') { |
|
return '<input type="text" name="'.$fieldname. |
|
'" size="60" value="'.$value.'" /><a href="javascript:openbrowser'. |
|
"('".$formname."','".$fieldname."'". |
|
",'rights')\">".&mt('Select').'</a>'. |
|
&relatedfield(0,$relatedsearchflag,$relatedsep); |
|
} |
|
# Dates |
|
if (($type eq 'creationdate') || |
|
($type eq 'lastrevisiondate')) { |
|
return |
|
&Apache::lonhtmlcommon::date_setter($formname,$fieldname,$value). |
|
&relatedfield(0,$relatedsearchflag,$relatedsep); |
|
} |
|
# No pretty input found |
|
$value=~s/^\s+//gs; |
|
$value=~s/\s+$//gs; |
|
$value=~s/\s+/ /gs; |
|
$value=~s/\"/\"\;/gs; |
|
return |
|
'<input type="text" name="'.$fieldname.'" size="'.$size.'" '. |
|
'value="'.$value.'" />'. |
|
&relatedfield(1,$relatedsearchflag,$relatedsep,$fieldname, |
|
$relatedvalue); |
|
} |
|
|
|
sub relatedfield { |
|
my ($show,$relatedsearchflag,$relatedsep,$fieldname,$relatedvalue)=@_; |
|
if (! $relatedsearchflag) { |
|
return ''; |
|
} |
|
if (! defined($relatedsep)) { |
|
$relatedsep=' '; |
|
} |
|
if (! $show) { |
|
return $relatedsep.' '; |
|
} |
|
return $relatedsep.'<input type="checkbox" name="'.$fieldname.'_related"'. |
|
($relatedvalue?' checked="1"':'').' />'; |
|
} |
|
|
|
|
|
# The field names |
|
sub fieldnames { |
|
return &Apache::lonlocal::texthash |
|
( |
|
'title' => 'Title', |
|
'author' =>'Author(s)', |
|
'authorspace' => 'Author Space', |
|
'modifyinguser' => 'Last Modifying User', |
|
'subject' => 'Subject', |
|
'keywords' => 'Keyword(s)', |
|
'notes' => 'Notes', |
|
'abstract' => 'Abstract', |
|
'lowestgradelevel' => 'Lowest Grade Level', |
|
'highestgradelevel' => 'Highest Grade Level', |
|
'standards' => 'Standards', |
|
'mime' => 'MIME Type', |
|
'language' => 'Language', |
|
'creationdate' => 'Creation Date', |
|
'lastrevisiondate' => 'Last Revision Date', |
|
'owner' => 'Publisher/Owner', |
|
'copyright' => 'Copyright/Distribution', |
|
'customdistributionfile' => 'Custom Distribution File', |
|
'sourceavail' => 'Source Available', |
|
'sourcerights' => 'Source Custom Distribution File', |
|
'obsolete' => 'Obsolete', |
|
'obsoletereplacement' => 'Suggested Replacement for Obsolete File', |
|
'count' => 'Network-wide number of accesses (hits)', |
|
'course' => 'Network-wide number of courses using resource', |
|
'course_list' => 'Network-wide courses using resource', |
|
'sequsage' => 'Number of resources using or importing resource', |
|
'sequsage_list' => 'Resources using or importing resource', |
|
'goto' => 'Number of resources that follow this resource in maps', |
|
'goto_list' => 'Resources that follow this resource in maps', |
|
'comefrom' => 'Number of resources that lead up to this resource in maps', |
|
'comefrom_list' => 'Resources that lead up to this resource in maps', |
|
'clear' => 'Material presented in clear way', |
|
'depth' => 'Material covered with sufficient depth', |
|
'helpful' => 'Material is helpful', |
|
'correct' => 'Material appears to be correct', |
|
'technical' => 'Resource is technically correct', |
|
'avetries' => 'Average number of tries till solved', |
|
'stdno' => 'Total number of students who have worked on this problem', |
|
'difficulty' => 'Degree of difficulty', |
|
'disc' => 'Degree of discrimination', |
|
'dependencies' => 'Resources used by this resource', |
|
); |
|
} |
|
|
|
sub edit_meta_data { |
|
my ($r,$uri) = @_; |
|
# Construction Space Call |
|
# Header |
|
my $disuri=$uri; |
|
my $fn=&Apache::lonnet::filelocation('',$uri); |
|
$disuri=~s/^\/\~/\/priv\//; |
|
$disuri=~s/\.meta$//; |
|
my $target=$uri; |
|
$target=~s/^\/\~/\/res\/$ENV{'request.role.domain'}\//; |
|
$target=~s/\.meta$//; |
|
$r->print('<script language="JavaScript">'. |
|
&Apache::loncommon::browser_and_searcher_javascript(). |
|
'</script>'); |
|
my %lt=&fieldnames(); |
|
my $output; |
|
foreach ('author','title','subject','keywords','abstract','notes', |
|
'copyright','customdistributionfile','language', |
|
'standards', |
|
'lowestgradelevel','highestgradelevel','sourceavail','sourcerights', |
|
'obsolete','obsoletereplacement') { |
|
if (defined($ENV{'form.new_'.$_})) { |
|
$Apache::lonpublisher::metadatafields{$_}= |
|
$ENV{'form.new_'.$_}; |
|
} |
|
if (! $Apache::lonpublisher::metadatafields{'copyright'}) { |
|
$Apache::lonpublisher::metadatafields{'copyright'}= |
|
'default'; |
|
} |
|
$output.=('<p>'.$lt{$_}.': '. |
|
&prettyinput($_, |
|
$Apache::lonpublisher::metadatafields{$_}, |
|
'new_'.$_,'defaultmeta').'</p>'); |
|
} |
} |
return $output; |
|
} |
} |
|
|
sub open_form { |
sub open_form { |
my ($r)=@_; |
my ($r)=@_; |
my @files=&Apache::loncommon::get_env_multiple('form.selectfile'); |
my @files=&Apache::loncommon::get_env_multiple('form.selectfile'); |
$r->print('<form method="post" action="/adm/portfolio">'); |
$r->print('<form method="post" action="/adm/portfolio">'); |
$r->print('<input type="hidden" name="action" value="'. |
$r->print('<input type="hidden" name="action" value="'. |
$ENV{'form.action'}.'" />'); |
$env{'form.action'}.'" />'); |
$r->print('<input type="hidden" name="confirmed" value="1" />'); |
$r->print('<input type="hidden" name="confirmed" value="1" />'); |
foreach (@files) { |
foreach (@files) { |
$r->print('<input type="hidden" name="selectfile" value="'. |
$r->print('<input type="hidden" name="selectfile" value="'. |
$_.'" />'); |
$_.'" />'); |
} |
} |
$r->print('<input type="hidden" name="currentpath" value="'. |
$r->print('<input type="hidden" name="currentpath" value="'. |
$ENV{'form.currentpath'}.'" />'); |
$env{'form.currentpath'}.'" />'); |
} |
} |
|
|
sub close_form { |
sub close_form { |
Line 413 sub close_form {
|
Line 201 sub close_form {
|
$r->print('<form action="/adm/portfolio" method="POST"> |
$r->print('<form action="/adm/portfolio" method="POST"> |
<p> |
<p> |
<input type="hidden" name="currentpath" value="'. |
<input type="hidden" name="currentpath" value="'. |
$ENV{'form.currentpath'}.'" /> |
$env{'form.currentpath'}.'" /> |
<input type="submit" value="'.&mt('Cancel').'" /> |
<input type="submit" value="'.&mt('Cancel').'" /> |
</p></form>'); |
</p></form>'); |
|
|
Line 422 sub close_form {
|
Line 210 sub close_form {
|
sub display_file { |
sub display_file { |
my ($path,$filename)=@_; |
my ($path,$filename)=@_; |
my $display_file_text; |
my $display_file_text; |
if (!defined($path)) { $path=$ENV{'form.currentpath'}; } |
if (!defined($path)) { $path=$env{'form.currentpath'}; } |
if (!defined($filename)) { |
if (!defined($filename)) { |
$filename=$ENV{'form.selectfile'}; |
$filename=$env{'form.selectfile'}; |
$display_file_text = '<tt>'.$path.$filename.'</tt>'; |
$display_file_text = '<tt>'.$path.$filename.'</tt>'; |
} elsif (ref($filename) eq "ARRAY") { |
} elsif (ref($filename) eq "ARRAY") { |
foreach (@$filename) { |
foreach (@$filename) { |
Line 437 sub display_file {
|
Line 225 sub display_file {
|
} |
} |
|
|
sub done { |
sub done { |
|
my ($message)=@_; |
|
unless (defined $message) { |
|
$message='Done'; |
|
} |
return ('<h3><a href="/adm/portfolio?currentpath='. |
return ('<h3><a href="/adm/portfolio?currentpath='. |
$ENV{'form.currentpath'}. |
$env{'form.currentpath'}. |
'&fieldname='.$ENV{'form.fieldname'}. |
'&fieldname='.$env{'form.fieldname'}. |
'&mode='.$ENV{'form.mode'}. |
'&mode='.$env{'form.mode'}. |
'">'.&mt('Done').'</a></h3>'); |
'">'.&mt($message).'</a></h3>'); |
} |
} |
|
|
sub delete { |
sub delete { |
my ($r)=@_; |
my ($r)=@_; |
my @check; |
my @check; |
my $file_name = $ENV{'form.currentpath'}.$ENV{'form.selectfile'}; |
my $file_name = $env{'form.currentpath'}.$env{'form.selectfile'}; |
my @files=&Apache::loncommon::get_env_multiple('form.selectfile'); |
my @files=&Apache::loncommon::get_env_multiple('form.selectfile'); |
|
|
if (&Apache::lonnet::is_locked($file_name,$ENV{'user.domain'},$ENV{'user.name'} ) eq 'true') { |
if (&Apache::lonnet::is_locked($file_name,$env{'user.domain'},$env{'user.name'} ) eq 'true') { |
$r->print ("The file is locked and cannot be deleted.<br />"); |
$r->print ("The file is locked and cannot be deleted.<br />"); |
$r->print(&done()); |
$r->print(&done('Back')); |
} else { |
} else { |
if (scalar(@files)) { |
if (scalar(@files)) { |
&open_form($r); |
&open_form($r); |
Line 470 sub delete_confirmed {
|
Line 262 sub delete_confirmed {
|
my @files=&Apache::loncommon::get_env_multiple('form.selectfile'); |
my @files=&Apache::loncommon::get_env_multiple('form.selectfile'); |
my $result; |
my $result; |
foreach my $delete_file (@files) { |
foreach my $delete_file (@files) { |
$result=&Apache::lonnet::removeuserfile($ENV{'user.name'}, |
$result=&Apache::lonnet::removeuserfile($env{'user.name'}, |
$ENV{'user.domain'},'portfolio'. |
$env{'user.domain'},'portfolio'. |
$ENV{'form.currentpath'}. |
$env{'form.currentpath'}. |
$delete_file); |
$delete_file); |
if ($result ne 'ok') { |
if ($result ne 'ok') { |
$r->print('<font color="red"> An error occured ('.$result. |
$r->print('<font color="red"> An error occured ('.$result. |
Line 491 sub delete_dir {
|
Line 283 sub delete_dir {
|
|
|
sub delete_dir_confirmed { |
sub delete_dir_confirmed { |
my ($r)=@_; |
my ($r)=@_; |
my $directory_name = $ENV{'form.currentpath'}; |
my $directory_name = $env{'form.currentpath'}; |
$directory_name =~ m/\/$/; |
$directory_name =~ s|/$||; # remove any trailing slash |
$directory_name = $`; |
my $result=&Apache::lonnet::removeuserfile($env{'user.name'}, |
my $result=&Apache::lonnet::removeuserfile($ENV{'user.name'}, |
$env{'user.domain'},'portfolio'. |
$ENV{'user.domain'},'portfolio'. |
|
$directory_name); |
$directory_name); |
|
|
if ($result ne 'ok') { |
if ($result ne 'ok') { |
Line 512 sub delete_dir_confirmed {
|
Line 303 sub delete_dir_confirmed {
|
for (my $i=1; $i < (@dirs - 1); $i ++){ |
for (my $i=1; $i < (@dirs - 1); $i ++){ |
$directory_name .= $dirs[$i].'/'; |
$directory_name .= $dirs[$i].'/'; |
} |
} |
$ENV{'form.currentpath'} = $directory_name; |
$env{'form.currentpath'} = $directory_name; |
} |
} |
$r->print(&done()); |
$r->print(&done()); |
} |
} |
|
|
sub rename { |
sub rename { |
my ($r)=@_; |
my ($r)=@_; |
my $file_name = $ENV{'form.currentpath'}.$ENV{'form.rename'}; |
my $file_name = $env{'form.currentpath'}.$env{'form.rename'}; |
if (&Apache::lonnet::is_locked($file_name,$ENV{'user.domain'},$ENV{'user.name'}) eq 'true') { |
if (&Apache::lonnet::is_locked($file_name,$env{'user.domain'},$env{'user.name'}) eq 'true') { |
$r->print ("The file is locked and cannot be renamed.<br />"); |
$r->print ("The file is locked and cannot be renamed.<br />"); |
$r->print(&done()); |
$r->print(&done()); |
} else { |
} else { |
Line 533 sub rename {
|
Line 324 sub rename {
|
|
|
sub rename_confirmed { |
sub rename_confirmed { |
my ($r)=@_; |
my ($r)=@_; |
my $filenewname=&Apache::lonnet::clean_filename($ENV{'form.filenewname'}); |
my $filenewname=&Apache::lonnet::clean_filename($env{'form.filenewname'}); |
if ($filenewname eq '') { |
if ($filenewname eq '') { |
$r->print('<font color="red">'. |
$r->print('<font color="red">'. |
&mt("Error: no valid filename was provided to rename to."). |
&mt("Error: no valid filename was provided to rename to."). |
Line 542 sub rename_confirmed {
|
Line 333 sub rename_confirmed {
|
return; |
return; |
} |
} |
my $result= |
my $result= |
&Apache::lonnet::renameuserfile($ENV{'user.name'},$ENV{'user.domain'}, |
&Apache::lonnet::renameuserfile($env{'user.name'},$env{'user.domain'}, |
'portfolio'.$ENV{'form.currentpath'}.$ENV{'form.selectfile'}, |
'portfolio'.$env{'form.currentpath'}.$env{'form.selectfile'}, |
'portfolio'.$ENV{'form.currentpath'}.$filenewname); |
'portfolio'.$env{'form.currentpath'}.$filenewname); |
if ($result ne 'ok') { |
if ($result ne 'ok') { |
$r->print('<font color="red"> An errror occured ('.$result. |
$r->print('<font color="red"> An errror occured ('.$result. |
') while trying to rename '.&display_file().' to '. |
') while trying to rename '.&display_file().' to '. |
&display_file(undef,$filenewname).'</font><br />'); |
&display_file(undef,$filenewname).'</font><br />'); |
} |
} |
if ($filenewname ne $ENV{'form.filenewname'}) { |
if ($filenewname ne $env{'form.filenewname'}) { |
$r->print("The new file name was changed from:<br /><strong>".$ENV{'form.filenewname'}."</strong> to <strong>$filenewname </strong>"); |
$r->print("The new file name was changed from:<br /><strong>".$env{'form.filenewname'}."</strong> to <strong>$filenewname </strong>"); |
} |
} |
$r->print(&done()); |
$r->print(&done()); |
} |
} |
sub select_files { |
sub select_files { |
my ($r)=@_; |
my ($r)=@_; |
if ($ENV{'form.continue'} eq 'true') { |
if ($env{'form.continue'} eq 'true') { |
# here we update the selections for the currentpath |
# here we update the selections for the currentpath |
# eventually, have to handle removing those not checked, but . . . |
# eventually, have to handle removing those not checked, but . . . |
my @items=&Apache::loncommon::get_env_multiple('form.selectfile'); |
my @items=&Apache::loncommon::get_env_multiple('form.selectfile'); |
&Apache::lonnet::save_selected_files($ENV{'user.name'}, $ENV{'form.currentpath'}, @items); |
&Apache::lonnet::save_selected_files($env{'user.name'}, $env{'form.currentpath'}, @items); |
} else { |
} else { |
if ($ENV{'form.currentpath'} eq '/') { |
if ($env{'form.currentpath'} eq '/') { |
#empty the file for a fresh start |
#empty the file for a fresh start |
# &Apache::lonnet::clear_selected_files($ENV{'user.name'}); |
# &Apache::lonnet::clear_selected_files($env{'user.name'}); |
} |
} |
} |
} |
my @files = &Apache::lonnet::files_not_in_path($ENV{'user.name'}, $ENV{'form.currentpath'}); |
my @files = &Apache::lonnet::files_not_in_path($env{'user.name'}, $env{'form.currentpath'}); |
my $java_files = join ",", @files; |
my $java_files = join ",", @files; |
if ($java_files) { |
if ($java_files) { |
$java_files.=','; |
$java_files.=','; |
Line 586 ENDSMP
|
Line 377 ENDSMP
|
} |
} |
opener.document.forms.lonhomework. |
opener.document.forms.lonhomework. |
ENDSMP |
ENDSMP |
$javascript .= $ENV{'form.fieldname'}; |
$javascript .= $env{'form.fieldname'}; |
$javascript .= (<<ENDSMP); |
$javascript .= (<<ENDSMP); |
.value=fileList; |
.value=fileList; |
self.close(); |
self.close(); |
Line 597 ENDSMP
|
Line 388 ENDSMP
|
$r->print("<h1>Select portfolio files</h1> |
$r->print("<h1>Select portfolio files</h1> |
Check as many as you wish in response to the essay problem.<br />"); |
Check as many as you wish in response to the essay problem.<br />"); |
$r->print("<strong>Files selected from other directories:</strong><br />"); |
$r->print("<strong>Files selected from other directories:</strong><br />"); |
foreach (&Apache::lonnet::files_not_in_path($ENV{'user.name'}, $ENV{'form.currentpath'})) { |
foreach (&Apache::lonnet::files_not_in_path($env{'user.name'}, $env{'form.currentpath'})) { |
$r->print($_."<br />"); |
$r->print($_."<br />"); |
} |
} |
} |
} |
sub upload { |
sub upload { |
my ($r)=@_; |
my ($r)=@_; |
my $fname=$ENV{'form.uploaddoc.filename'}; |
my $fname=$env{'form.uploaddoc.filename'}; |
my $filesize = (length($ENV{'form.uploaddoc'})) / 1000; #express in k (1024?) |
my $filesize = (length($env{'form.uploaddoc'})) / 1000; #express in k (1024?) |
my $disk_quota = 20000; # expressed in k |
my $disk_quota = 20000; # expressed in k |
$fname=&Apache::lonnet::clean_filename($fname); |
$fname=&Apache::lonnet::clean_filename($fname); |
my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'}, |
my $portfolio_root = &Apache::loncommon::propath($env{'user.domain'}, |
$ENV{'user.name'}). |
$env{'user.name'}). |
'/userfiles/portfolio'; |
'/userfiles/portfolio'; |
# Fixme --- Move the checking for existing file to LOND error return |
# Fixme --- Move the checking for existing file to LOND error return |
my @dir_list=&Apache::lonnet::dirlist($ENV{'form.currentpath'}, |
my @dir_list=&Apache::lonnet::dirlist($env{'form.currentpath'}, |
$ENV{'user.domain'}, |
$env{'user.domain'}, |
$ENV{'user.name'},$portfolio_root); |
$env{'user.name'},$portfolio_root); |
my $found_file = 0; |
my $found_file = 0; |
|
my $locked_file = 0; |
foreach my $line (@dir_list) { |
foreach my $line (@dir_list) { |
my ($filename)=split(/\&/,$line,2); |
my ($file_name)=split(/\&/,$line,2); |
if ($filename eq $fname){ |
if ($file_name eq $fname){ |
$found_file = 1; |
$found_file = 1; |
|
if (&Apache::lonnet::is_locked($env{'form.currentpath'}.$file_name,$env{'user.domain'},$env{'user.name'} ) eq 'true') { |
|
$locked_file = 1; |
|
} |
} |
} |
} |
} |
my $current_disk_usage = &Apache::lonnet::diskusage($ENV{'user.domain'}, $ENV{'user.name'},$portfolio_root); |
my $current_disk_usage = &Apache::lonnet::diskusage($env{'user.domain'}, $env{'user.name'},$portfolio_root); |
if ((($current_disk_usage/1000) + $filesize) > $disk_quota){ |
if ((($current_disk_usage/1000) + $filesize) > $disk_quota){ |
$r->print('<font color="red">Unable to upload <strong>'.$fname.' (size = '.$filesize.' kilobytes</strong>. Disk quota will be exceeded.'. |
$r->print('<font color="red">Unable to upload <strong>'.$fname.' (size = '.$filesize.' kilobytes</strong>. Disk quota will be exceeded.'. |
'<br />Disk quota is '.$disk_quota.' kilobytes. Your current disk usage is '.$current_disk_usage.' kilobytes.'); |
'<br />Disk quota is '.$disk_quota.' kilobytes. Your current disk usage is '.$current_disk_usage.' kilobytes.'); |
|
$r->print(&done('Back')); |
} |
} |
elsif ($found_file){ |
elsif ($found_file){ |
$r->print('<font color="red">Unable to upload <strong>'.$fname.'</strong>, a file by that name was found in <strong>'.$ENV{'form.currentpath'}.'</strong></font>'. |
if ($locked_file){ |
'<br />To upload, rename or delete existing '.$fname.' in '.$ENV{'form.currentpath'}); |
$r->print('<font color="red">Unable to upload <strong>'.$fname.'</strong>, a <strong>locked</strong> file by that name was found in <strong>portfolio'.$env{'form.currentpath'}.'</strong></font>'. |
|
'<br />You will be able to rename or delete existing '.$fname.' after a grade has been assigned.'); |
|
$r->print(&done('Back')); |
|
} else { |
|
$r->print('<font color="red">Unable to upload <strong>'.$fname.'</strong>, a file by that name was found in <strong>portfolio'.$env{'form.currentpath'}.'</strong></font>'. |
|
'<br />To upload, rename or delete existing '.$fname.' in portfolio'.$env{'form.currentpath'}); |
|
$r->print(&done('Back')); |
|
} |
} else { |
} else { |
my $result=&Apache::lonnet::userfileupload('uploaddoc','', |
my $result=&Apache::lonnet::userfileupload('uploaddoc','', |
'portfolio'.$ENV{'form.currentpath'}); |
'portfolio'.$env{'form.currentpath'}); |
if ($result !~ m|^/uploaded/|) { |
if ($result !~ m|^/uploaded/|) { |
$r->print('<font color="red"> An errror occured ('.$result. |
$r->print('<font color="red"> An errror occured ('.$result. |
') while trying to upload '.&display_file().'</font><br />'); |
') while trying to upload '.&display_file().'</font><br />'); |
|
$r->print(&done('Back')); |
|
} else { |
|
$r->print(&done()); |
} |
} |
} |
} |
$r->print(&done()); |
|
} |
} |
|
sub lock_info { |
|
my ($r) = @_; |
|
$r->print("lock info here"); |
|
return 'ok'; |
|
} |
sub createdir { |
sub createdir { |
my ($r)=@_; |
my ($r)=@_; |
my $newdir=&Apache::lonnet::clean_filename($ENV{'form.newdir'}); |
my $newdir=&Apache::lonnet::clean_filename($env{'form.newdir'}); |
if ($newdir eq '') { |
if ($newdir eq '') { |
$r->print('<font color="red">'. |
$r->print('<font color="red">'. |
&mt("Error: no directory name was provided."). |
&mt("Error: no directory name was provided."). |
Line 650 sub createdir {
|
Line 459 sub createdir {
|
$r->print(&done()); |
$r->print(&done()); |
return; |
return; |
} |
} |
my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'}, |
my $portfolio_root = &Apache::loncommon::propath($env{'user.domain'}, |
$ENV{'user.name'}). |
$env{'user.name'}). |
'/userfiles/portfolio'; |
'/userfiles/portfolio'; |
my @dir_list=&Apache::lonnet::dirlist($ENV{'form.currentpath'}, |
my @dir_list=&Apache::lonnet::dirlist($env{'form.currentpath'}, |
$ENV{'user.domain'}, |
$env{'user.domain'}, |
$ENV{'user.name'},$portfolio_root); |
$env{'user.name'},$portfolio_root); |
my $found_file = 0; |
my $found_file = 0; |
foreach my $line (@dir_list) { |
foreach my $line (@dir_list) { |
my ($filename)=split(/\&/,$line,2); |
my ($filename)=split(/\&/,$line,2); |
Line 667 sub createdir {
|
Line 476 sub createdir {
|
$r->print('<font color="red"> Unable to create a directory named <strong>'.$newdir. |
$r->print('<font color="red"> Unable to create a directory named <strong>'.$newdir. |
' </strong>a file or directory by that name already exists.</font><br />'); |
' </strong>a file or directory by that name already exists.</font><br />'); |
} else { |
} else { |
my $result=&Apache::lonnet::mkdiruserfile($ENV{'user.name'}, |
my $result=&Apache::lonnet::mkdiruserfile($env{'user.name'}, |
$ENV{'user.domain'},'portfolio'.$ENV{'form.currentpath'}.$newdir); |
$env{'user.domain'},'portfolio'.$env{'form.currentpath'}.$newdir); |
if ($result ne 'ok') { |
if ($result ne 'ok') { |
$r->print('<font color="red"> An errror occured ('.$result. |
$r->print('<font color="red"> An errror occured ('.$result. |
') while trying to create a new directory '.&display_file().'</font><br />'); |
') while trying to create a new directory '.&display_file().'</font><br />'); |
} |
} |
} |
} |
if ($newdir ne $ENV{'form.newdir'}) { |
if ($newdir ne $env{'form.newdir'}) { |
$r->print("The new directory name was changed from:<br /><strong>".$ENV{'form.newdir'}."</strong> to <strong>$newdir </strong>"); |
$r->print("The new directory name was changed from:<br /><strong>".$env{'form.newdir'}."</strong> to <strong>$newdir </strong>"); |
} |
} |
$r->print(&done()); |
$r->print(&done()); |
} |
} |
Line 683 sub createdir {
|
Line 492 sub createdir {
|
sub handler { |
sub handler { |
# this handles file management |
# this handles file management |
my $r = shift; |
my $r = shift; |
my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'}, |
my $portfolio_root = &Apache::loncommon::propath($env{'user.domain'}, |
$ENV{'user.name'}). |
$env{'user.name'}). |
'/userfiles/portfolio'; |
'/userfiles/portfolio'; |
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
|
['selectfile','currentpath','meta','lockinfo', |
|
'currentfile','action','fieldname','mode','rename']); |
&Apache::loncommon::no_cache($r); |
&Apache::loncommon::no_cache($r); |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
# Give the LON-CAPA page header |
# Give the LON-CAPA page header |
$r->print('<html><head><title>'. |
my $html=&Apache::lonxml::xmlbegin(); |
|
$r->print($html.'<head><title>'. |
&mt('Portfolio Manager'). |
&mt('Portfolio Manager'). |
"</title></head>\n". |
"</title></head>\n"); |
&Apache::loncommon::bodytag('Portfolio Manager')); |
if ($env{"form.mode"} eq 'selectfile'){ |
|
$r->print(&Apache::loncommon::bodytag('Portfolio Manager',undef,undef,1)); |
|
} else { |
|
$r->print(&Apache::loncommon::bodytag('Portfolio Manager')); |
|
} |
$r->rflush(); |
$r->rflush(); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
if (($env{'form.storeupl'} eq 'Upload') & (!$env{'form.uploaddoc.filename'})){ |
['selectfile','currentpath','meta', |
|
'currentfile','action','fieldname','mode','rename']); |
|
if (($ENV{'form.storeupl'} eq 'Upload') & (!$ENV{'form.uploaddoc.filename'})){ |
|
$r->print('<font color="red"> No file was selected to upload.'. |
$r->print('<font color="red"> No file was selected to upload.'. |
'To upload a file, click <strong>Browse...</strong>'. |
'To upload a file, click <strong>Browse...</strong>'. |
', select a file, then click <strong>Upload</strong>,</font>'); |
', select a file, then click <strong>Upload</strong>,</font>'); |
} |
} |
if ($ENV{'form.meta'}) { |
if ($env{'form.meta'}) { |
&open_form($r); |
&open_form($r); |
$r->print(&edit_meta_data($r, $ENV{'form.currentpath'}.$ENV{'form.selectfile'})); |
# $r->print(&edit_meta_data($r, $env{'form.currentpath'}.$env{'form.selectfile'})); |
$r->print('Edit the meta data<br />'); |
$r->print('Edit the meta data<br />'); |
&close_form($r); |
&close_form($r); |
} |
} |
if ($ENV{'form.store'}) { |
if ($env{'form.store'}) { |
} |
} |
|
|
if ($ENV{'form.uploaddoc.filename'}) { |
if ($env{'form.uploaddoc.filename'}) { |
&upload($r); |
&upload($r); |
} elsif ($ENV{'form.action'} eq 'delete' && $ENV{'form.confirmed'}) { |
} elsif ($env{'form.action'} eq 'delete' && $env{'form.confirmed'}) { |
&delete_confirmed($r); |
&delete_confirmed($r); |
} elsif ($ENV{'form.action'} eq 'delete') { |
} elsif ($env{'form.action'} eq 'delete') { |
&delete($r); |
&delete($r); |
} elsif ($ENV{'form.action'} eq 'deletedir' && $ENV{'form.confirmed'}) { |
} elsif ($env{'form.action'} eq 'deletedir' && $env{'form.confirmed'}) { |
&delete_dir_confirmed($r); |
&delete_dir_confirmed($r); |
} elsif ($ENV{'form.action'} eq 'deletedir'){ |
} elsif ($env{'form.action'} eq 'deletedir'){ |
&delete_dir($r); |
&delete_dir($r); |
} elsif ($ENV{'form.action'} eq 'rename' && $ENV{'form.confirmed'}) { |
} elsif ($env{'form.action'} eq 'rename' && $env{'form.confirmed'}) { |
&rename_confirmed($r); |
&rename_confirmed($r); |
} elsif ($ENV{'form.rename'}) { |
} elsif ($env{'form.rename'}) { |
$ENV{'form.selectfile'} = $ENV{'form.rename'}; |
$env{'form.selectfile'} = $env{'form.rename'}; |
$ENV{'form.action'} = 'rename'; |
$env{'form.action'} = 'rename'; |
&rename($r); |
&rename($r); |
} elsif ($ENV{'form.createdir'}) { |
} elsif ($env{'form.createdir'}) { |
&createdir($r); |
&createdir($r); |
|
} elsif ($env{'form.lockinfo'}) { |
|
&lock_info($r); |
} else { |
} else { |
my $current_path='/'; |
my $current_path='/'; |
if ($ENV{'form.currentpath'}) { |
if ($env{'form.currentpath'}) { |
$current_path = $ENV{'form.currentpath'}; |
$current_path = $env{'form.currentpath'}; |
} |
} |
my @dir_list=&Apache::lonnet::dirlist($current_path, |
my @dir_list=&Apache::lonnet::dirlist($current_path, |
$ENV{'user.domain'}, |
$env{'user.domain'}, |
$ENV{'user.name'},$portfolio_root); |
$env{'user.name'},$portfolio_root); |
if ($dir_list[0] eq 'no_such_dir'){ |
if ($dir_list[0] eq 'no_such_dir'){ |
# two main reasons for this: |
# two main reasons for this: |
# 1) never been here, so directory structure not created |
# 1) never been here, so directory structure not created |
# 2) back-button navigation after deleting a directory |
# 2) back-button navigation after deleting a directory |
if ($current_path eq '/'){ |
if ($current_path eq '/'){ |
&Apache::lonnet::mkdiruserfile($ENV{'user.name'}, |
&Apache::lonnet::mkdiruserfile($env{'user.name'}, |
$ENV{'user.domain'},'portfolio'); |
$env{'user.domain'},'portfolio'); |
} else { |
} else { |
# some directory that snuck in get rid of the directory |
# some directory that snuck in get rid of the directory |
# from the recent pulldown, just in case |
# from the recent pulldown, just in case |
Line 754 sub handler {
|
Line 570 sub handler {
|
} |
} |
# now grab the directory list again, for the first time |
# now grab the directory list again, for the first time |
@dir_list=&Apache::lonnet::dirlist($current_path, |
@dir_list=&Apache::lonnet::dirlist($current_path, |
$ENV{'user.domain'}, |
$env{'user.domain'}, |
$ENV{'user.name'},$portfolio_root); |
$env{'user.name'},$portfolio_root); |
} |
} |
# need to know if directory is empty so it can be removed if desired |
# need to know if directory is empty so it can be removed if desired |
my $is_empty=(@dir_list == 2); |
my $is_empty=(@dir_list == 2); |
&display_common($r,$current_path,$is_empty,\@dir_list); |
&display_common($r,$current_path,$is_empty,\@dir_list); |
if ($ENV{"form.mode"} eq 'selectfile'){ |
&display_directory($r,$current_path,$is_empty,\@dir_list); |
&select_files($r); |
|
&display_file_select($r,$current_path,$is_empty,\@dir_list); |
|
} else { |
|
&display_directory($r,$current_path,$is_empty,\@dir_list); |
|
} |
|
$r->print("</body>\n</html>\n"); |
$r->print("</body>\n</html>\n"); |
return OK; |
return OK; |
} |
} |