--- loncom/interface/londocs.pm 2004/07/08 19:58:29 1.135 +++ loncom/interface/londocs.pm 2004/08/03 20:44:33 1.136 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.135 2004/07/08 19:58:29 albertel Exp $ +# $Id: londocs.pm,v 1.136 2004/08/03 20:44:33 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -650,12 +650,20 @@ ENDPARMS # ---------------------------------------------------------------- tie the hash sub tiehash { + my ($mode)=@_; $hashtied=0; if ($ENV{'request.course.fn'}) { - if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db", - &GDBM_READER(),0640)) { + if ($mode eq 'write') { + if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db", + &GDBM_WRCREAT(),0640)) { + $hashtied=2; + } + } else { + if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db", + &GDBM_READER(),0640)) { $hashtied=1; - } + } + } } } @@ -821,8 +829,9 @@ sub checkversions { } else { $r->print('

'.&mt('An Error Occured while Attempting to Store your Version Settings').'

'); } - &changewarning($r,''); + &mark_hash_old(); } + &changewarning($r,''); if ($ENV{'form.timerange'} eq 'all') { # show all documents $header=&mt('All Documents in Course'); @@ -942,7 +951,9 @@ ENDHEADERS # Set version $r->print(&Apache::loncommon::select_form($setversions{$linkurl}, 'set_version_'.$linkurl, - ('' => '', + ('select_form_order' => + ['',1..$currentversion,'mostrecent'], + '' => '', 'mostrecent' => 'most recent', map {$_,$_} (1..$currentversion)))); $r->print(''); @@ -1003,8 +1014,32 @@ ENDHEADERS &untiehash(); } +sub mark_hash_old { + my $retie_hash=0; + if ($hashtied) { + $retie_hash=1; + &untiehash(); + } + &tiehash('write'); + $hash{'old'}=1; + &untiehash(); + if ($retie_hash) { &tiehash(); } +} + +sub is_hash_old { + my $untie_hash=0; + if (!$hashtied) { + $untie_hash=1; + &tiehash(); + } + my $return=$hash{'old'}; + if ($untie_hash) { &untiehash(); } + return $return; +} + sub changewarning { my ($r,$postexec)=@_; + if (!&is_hash_old()) { return; } $r->print( ''. '
'. @@ -1313,8 +1348,9 @@ ENDCOURSEVERIFY $hadchanges=0; &editor($r,$coursenum,$coursedom,$folder,$allowed); if ($hadchanges) { - &changewarning($r,$postexec); + &mark_hash_old() } + &changewarning($r,$postexec); my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. '.sequence'; $r->print(<