--- loncom/interface/londocs.pm 2004/01/15 03:18:19 1.99 +++ loncom/interface/londocs.pm 2004/02/27 19:11:08 1.109 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.99 2004/01/15 03:18:19 www Exp $ +# $Id: londocs.pm,v 1.109 2004/02/27 19:11:08 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -68,10 +68,13 @@ sub mapread { sub storemap { my ($coursenum,$coursedom,$map)=@_; - $hadchanges=1; - return + my ($outtext,$errtext)= &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'. $map,1); + if ($errtext) { return ($errtext,2); } + + $hadchanges=1; + return ($errtext,0); } # ----------------------------------------- Return hash with valid author names @@ -94,13 +97,15 @@ sub authorhosts { } else { ($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/); } - if (&Apache::lonnet::homeserver($ca,$cd) eq - $Apache::lonnet::perlvar{'lonHostID'}) { + my $allowed=0; + my $myhome=&Apache::lonnet::homeserver($ca,$cd); + my @ids=&Apache::lonnet::current_machine_ids(); + foreach my $id (@ids) { if ($id eq $myhome) { $allowed=1; } } + if ($allowed) { $home++; $outhash{'home_'.$ca.'@'.$cd}=1; } else { - $outhash{'otherhome_'.$ca.'@'.$cd}= - &Apache::lonnet::homeserver($ca,$cd); + $outhash{'otherhome_'.$ca.'@'.$cd}=$myhome; $other++; } } @@ -250,7 +255,7 @@ sub group_import { join ':', ($name, $url, $ext, 'normal', 'res'); } } - &storemap($coursenum, $coursedom, $folder.'.sequence'); + return &storemap($coursenum, $coursedom, $folder.'.sequence'); } sub editor { @@ -295,7 +300,12 @@ sub editor { $comment.':'.$url.':'.$ext.':normal:res'; $Apache::lonratedt::order[$#Apache::lonratedt::order+1]= $newidx; - &storemap($coursenum,$coursedom,$folder.'.sequence'); + + ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.sequence'); + if ($fatal) { + $r->print('

'.$errtext.'

'); + return; + } } } if ($ENV{'form.cmd'}) { @@ -335,7 +345,12 @@ sub editor { } # Store the changed version - &storemap($coursenum,$coursedom,$folder.'.sequence'); + ($errtext,$fatal)=&storemap($coursenum,$coursedom, + $folder.'.sequence'); + if ($fatal) { + $r->print('

'.$errtext.'

'); + return; + } } # Group import/search if ($ENV{'form.importdetail'}) { @@ -349,21 +364,30 @@ sub editor { } } # Store the changed version - group_import($coursenum, $coursedom, $folder, @imports); + ($errtext,$fatal)=group_import($coursenum, $coursedom, $folder, + @imports); + if ($fatal) { + $r->print('

'.$errtext.'

'); + return; + } } # Loading a complete map if (($ENV{'form.importmap'}) && ($ENV{'form.loadmap'})) { - foreach -(&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$ENV{'form.importmap'}))) { + foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$ENV{'form.importmap'}))) { my $idx=$#Apache::lonratedt::resources; $idx++; $Apache::lonratedt::resources[$idx]=$_; $Apache::lonratedt::order - [$#Apache::lonratedt::order+1]=$idx; - } + [$#Apache::lonratedt::order+1]=$idx; + } # Store the changed version - &storemap($coursenum,$coursedom,$folder.'.sequence'); + ($errtext,$fatal)=&storemap($coursenum,$coursedom, + $folder.'.sequence'); + if ($fatal) { + $r->print('

'.$errtext.'

'); + return; + } } } # ---------------------------------------------------------------- End commands @@ -373,7 +397,7 @@ sub editor { foreach (@Apache::lonratedt::order) { my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]); unless ($name) { $name=(split(/\//,$url))[-1]; } - unless ($name) { $name='NO RESOURCE'; $url='/adm/notfound.html'; } + unless ($name) { next; } $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_)); $idx++; } @@ -387,38 +411,42 @@ sub entryline { my ($index,$title,$url,$folder,$allowed,$residx)=@_; $title=~s/\&colon\;/\:/g; $title=&HTML::Entities::encode(&HTML::Entities::decode( - &Apache::lonnet::unescape($title)),'\"\<\>\&\''); + &Apache::lonnet::unescape($title)),'"<>&\''); my $renametitle=$title; my $foldertitle=$title; - if ($title=~ - /^(\d+)\_\_\_\&\;\&\;\&\;\_\_\_(\w+)\_\_\_\&\;\&\;\&\;\_\_\_(\w+)\_\_\_\&\;\&\;\&\;\_\_\_(.*)$/ - ) { - $foldertitle=&Apache::lontexconvert::msgtexconverted($4); - $renametitle=$4; - $title=''.&Apache::lonlocal::locallocaltime($1).' '. - &Apache::loncommon::plainname($2,$3).':
'. - $foldertitle; - } + if ($title=~ /^(\d+)___&&&___(\w+)___&&&___(\w+)___&&&___(.*)$/ ) { + $foldertitle=&Apache::lontexconvert::msgtexconverted($4); + $renametitle=$4; + $title=''.&Apache::lonlocal::locallocaltime($1).' '. + &Apache::loncommon::plainname($2,$3).':
'. + $foldertitle; + } $renametitle=~s/\"\;/\\\"/g; my $line=''; # Edit commands - if ($allowed) { - my %lt=('up' => 'Move Up', - 'dw' => 'Move Down', - 'rm' => 'Remove', - 'rn' => 'Rename'); - $line.=(< 'Move Up', + 'dw' => 'Move Down', + 'rm' => 'Remove', + 'rn' => 'Rename'); + my ($foldername,$htmlfoldername); + if ($ENV{'form.foldername'}) { + $foldername='&foldername='. + &Apache::lonnet::escape($ENV{'form.foldername'}); + $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'}); + } + $line.=(<
- + $lt{
- + $lt{
- + $lt{'rm'} - + $lt{'rn'} END } @@ -480,7 +508,7 @@ sub checkonthis { $alreadyseen{$url}=1; $r->rflush(); if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) { - $r->print('
'); + $r->print("\n
"); for (my $i=0;$i<=$level*5;$i++) { $r->print(' '); } @@ -535,7 +563,11 @@ sub checkonthis { } elsif ($result==HTTP_SERVICE_UNAVAILABLE) { $r->print(''.&mt('connection down').''); } elsif ($result==HTTP_NOT_FOUND) { - $r->print(''.&mt('not found').''); + unless ($url=~/\$/) { + $r->print(''.&mt('not found').''); + } else { + $r->print(''.&mt('unable to verify variable URL').''); + } } else { $r->print(''.&mt('access denied').''); } @@ -564,7 +596,8 @@ sub verifycontent { } } &untiehash(); - $r->print('

'.&mt('Done').'.

'); + $r->print('

'.&mt('Done').'.

'.''. + &mt('Return to DOCS').''); } # -------------------------------------------------------------- Check Versions @@ -705,10 +738,7 @@ sub checkversions {

$header

- - - - +
$lt{'fi'}$lt{'md'}$lt{'mr'}$lt{'ve'}$lt{'vu'}$lt{'di'}
ENDHEADERS foreach (sort keys %changes) { if ($changes{$_}>$starttime) { @@ -719,13 +749,25 @@ ENDHEADERS } my $linkurl=&Apache::lonnet::clutter($_); $r->print( - ''. + ''. + ''. + ''. + ''. + ''. + ''); my $lastold=1; for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { my $url=$root.'.'.$prevvers.'.'.$extension; @@ -749,11 +792,27 @@ ENDHEADERS $lastold=$prevvers; } } + # + # Code to figure out how many version entries should go in + # each of the four columns + my $entries_per_col = 0; + my $num_entries = ($currentversion-$lastold); + if ($num_entries % 4 == 0) { + $entries_per_col = $num_entries/4; + } else { + $entries_per_col = $num_entries/4 + 1; + } + my $entries_count = 0; + $r->print(''); + if ($cols_output != 4) { + $r->print(''); + while($cols_output++ < 4) { + $r->print(''."\n"); } } $r->print('
'. + '


'. &Apache::lonnet::gettitle($linkurl). - '
'.$linkurl. - '
'. - &Apache::lonlocal::locallocaltime($changes{$_}). - ''. - $currentversion.''); + '
   '. + ''.$linkurl. + '
'. + &Apache::lonlocal::locallocaltime( + &Apache::lonnet::metadata($root.'.'.$extension, + 'lastrevisiondate') + ). + 'Most Recent: '. + ''.$currentversion.''. + 'In Course: '. + ''); # Used in course my $usedversion=$hash{'version_'.$linkurl}; if (($usedversion) && ($usedversion ne 'mostrecent')) { @@ -733,14 +775,15 @@ ENDHEADERS } else { $r->print($currentversion); } - $r->print(''); + $r->print(''. + 'Use: '); # Set version $r->print(&Apache::loncommon::select_form($setversions{$linkurl}, 'set_version_'.$linkurl, ('' => '', 'mostrecent' => 'most recent', map {$_,$_} (1..$currentversion)))); - $r->print('
    '); + $r->print('
'); + my $cols_output = 1; for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) { my $url=$root.'.'.$prevvers.'.'.$extension; - $r->print('
  • '.&mt('Version').' '.$prevvers.' ('. - &Apache::lonlocal::locallocaltime(&Apache::lonnet::metadata($url,'lastrevisiondate')). + &Apache::lonlocal::locallocaltime( + &Apache::lonnet::metadata($url, + 'lastrevisiondate') + ). ')'); if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') { $r->print(' '.&mt('Diffs').''); } - $r->print('
  • '); + $r->print('
    '); + if (++$entries_count % $entries_per_col == 0) { + $r->print('
    '); + $cols_output++; + } + } } - $r->print('
    ') + } + $r->print('
    '); @@ -929,6 +998,21 @@ function makebulboard() { } } +function makeabout() { + var user=prompt("Enter user\@domain for User's 'About Me' Page"); + if (user) { + var comp=new Array(); + comp=user.split('\@'); + if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) { + if ((comp[0]) && (comp[1])) { + this.document.forms.newaboutsomeone.importdetail.value= + 'About '+user+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme'; + this.document.forms.newaboutsomeone.submit(); + } + } + } +} + function finishpick() { var title=this.document.forms.extimport.title.value; var url=this.document.forms.extimport.url.value; @@ -938,20 +1022,22 @@ function finishpick() { '";this.document.forms.'+form+'.submit();'); } -function changename(folder,index,oldtitle) { +function changename(folder,index,oldtitle,foldername) { var title=prompt('New Title',oldtitle); if (title) { this.document.forms.renameform.title.value=title; this.document.forms.renameform.cmd.value='rename_'+index; this.document.forms.renameform.folder.value=folder; + this.document.forms.renameform.foldername.value=foldername; this.document.forms.renameform.submit(); } } -function removeres(folder,index,oldtitle) { - if ((oldtitle=='NO RESOURCE') || (confirm('Remove "'+oldtitle+'"?'))) { +function removeres(folder,index,oldtitle,foldername) { + if (confirm('Remove "'+oldtitle+'"?')) { this.document.forms.renameform.cmd.value='del_'+index; this.document.forms.renameform.folder.value=folder; + this.document.forms.renameform.foldername.value=foldername; this.document.forms.renameform.submit(); } } @@ -986,6 +1072,7 @@ ENDNEWSCRIPT 'scuf' => 'Score Upload Form', 'bull' => 'Bulletin Board', 'mypi' => 'My Personal Info', + 'abou' => 'About User', 'file' => 'File', 'title' => 'Title', 'comment' => 'Comment' @@ -1002,10 +1089,12 @@ ENDNEWSCRIPT +
    +
    @@ -1021,6 +1110,7 @@ ENDCOURSEVERIFY &mt('Editing the Table of Contents for your Course'))); } # --------------------------------------------------------- Standard documents + my $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'}); $r->print('
    '); if (($standard) && ($allowed) && (!$forcesupplement)) { $r->print('

    '.&mt('Main Course Documents'). @@ -1054,7 +1144,7 @@ $lt{'file'}:
    $lt{'title'}:
    - + @@ -1065,7 +1155,7 @@ $lt{'title'}:

    - + @@ -1085,7 +1175,7 @@ $help{'Load_Map'} - + $help{'Adding_Fold
    - + $help{'Adding_Ext
    - + @@ -1114,7 +1204,7 @@ value="Syllabus=/public/$coursedom/$cour
    - + @@ -1124,7 +1214,7 @@ $help{'Navigate_Content'}
    - + $
    - + - + - + - + @@ -1170,6 +1260,15 @@ value="$plainname=/adm/$udom/$uname/abou $help{'My Personal Info'}
    +
    + + + + + + +
    ENDFORM @@ -1191,7 +1290,6 @@ ENDFORM $r->print(< $lt{'upls'} -$lt{'impp'} $lt{'spec'} @@ -1201,7 +1299,7 @@ ENDFORM - + @@ -1210,26 +1308,9 @@ ENDFORM -
    - - - - -$help{'Importing_LON-CAPA_Resource'} -

    -


    - -$help{'Load_Map'} -

    -
    -
    - + $help{'Adding_Fol
    - + $help{'Adding_Ext
    - + @@ -1259,7 +1340,7 @@ $help{'Syllabus'}
    - +