Diff for /rat/lonambiguous.pm between versions 1.1 and 1.2

version 1.1, 2000/10/12 02:14:01 version 1.2, 2000/10/12 14:54:08
Line 5 Line 5
 #  #
 # 05/29/00,05/30,10/11 Gerd Kortemeyer)  # 05/29/00,05/30,10/11 Gerd Kortemeyer)
 #  #
 # 10/11 Gerd Kortemeyer  # 10/11,10/12 Gerd Kortemeyer
   
 package Apache::lonambiguous;  package Apache::lonambiguous;
   
Line 18  use GDBM_File; Line 18  use GDBM_File;
 # ----------------------------------------------------------- Could not resolve  # ----------------------------------------------------------- Could not resolve
   
 sub getlost {  sub getlost {
     my $r=shift;      my ($r,$errmsg)=@_;
     $r->content_type('text/html');      $r->content_type('text/html');
     $r->send_http_header;      $r->send_http_header;
     $r->print('<head><title>Unknown Error</title><body bgcolor="#FFFFFF">'.      $r->print(
  '<h1>LON-CAPA</h1>Could not handle ambiguous file reference.</body></html>');   '<head><title>Unknown Error</title></head><body bgcolor="#FFFFFF"><h1>'.
    'LON-CAPA</h1>Could not handle ambiguous resource reference.<p>'.$errmsg.
    '</body></html>');
 }  }
   
 # ================================================================ Main Handler  # ================================================================ Main Handler
Line 36  sub handler { Line 38  sub handler {
       return OK;        return OK;
    }     }
   
   # ---------------------------------------------------------- Is this selecting?
      
      my %bighash;
   
      if ($ENV{'form.selecturl'}) {
          my $envkey;
          if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
                       &GDBM_READER,0640)) {
             foreach $envkey (keys %ENV) {
                if ($envkey=~/^form\.(\d+)\.(\d+)$/) {
            my $mapid=$1;
                    my $resid=$2;
                    my $resurl=$bighash{'src_'.$mapid.'.'.$resid};
                    &Apache::lonnet::symblist($bighash{'map_id_'.$mapid},
              $resurl => $resid);
                    $r->header_out(Location => 
                                   'http://'.$ENV{'HTTP_HOST'}.$resurl);
                    return REDIRECT;
                }
     }
             untie(%bighash);
   # ---------------------------------------------------- Update symb and redirect
          } else {
             &getlost($r,'Could not access course structure.');
             return OK;
          }
      }
   
 # ---------------------------------------------------------- Do we have a case?  # ---------------------------------------------------------- Do we have a case?
   
    my $thisfn;     my $thisfn;
    unless (($thisfn=$ENV{'request.ambiguous'})&&($ENV{'request.course.fn'})) {     unless (($thisfn=$ENV{'request.ambiguous'})&&($ENV{'request.course.fn'})) {
        getlost($r);         &getlost($r,'Could not find information on resource.');
        return OK;         return OK;
    }     }
               
Line 48  sub handler { Line 78  sub handler {
   
     $thisfn=&Apache::lonnet::declutter($thisfn);      $thisfn=&Apache::lonnet::declutter($thisfn);
     my %hash;      my %hash;
     my %bighash;  
     my $syval='';      my $syval='';
           
     if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db',      if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db',
Line 56  sub handler { Line 85  sub handler {
        $syval=$hash{$thisfn};         $syval=$hash{$thisfn};
        untie(%hash);         untie(%hash);
     }      }
   
 # ---------------------------------------------------------- There was an entry  # ---------------------------------------------------------- There was an entry
   
     if ($syval) {      if ($syval) {
   
        if ($syval=~/\_$/) {         if ($syval=~/\_$/) {
 # ----------------------------------- Okay, this should have appeared on a page  # ----------------------------------- Okay, this should have appeared on a page
    $syval=~s/\_\_\_$//;     $syval=~s/\_\_\_$//;
Line 67  sub handler { Line 99  sub handler {
            return REDIRECT;             return REDIRECT;
        } else {         } else {
 #  There is not really a problem (???), but cannot go back without endless loop  #  There is not really a problem (???), but cannot go back without endless loop
            getlost($r);             &getlost($r,'The nature of the problem is unclear');
            return OK;             return OK;
        }         }
     }      }
Line 83  sub handler { Line 115  sub handler {
          my @possibilities=split(/\,/,$ids);           my @possibilities=split(/\,/,$ids);
          my $couldbe='';           my $couldbe='';
          map {           map {
              if (&allowed('bre',$bighash{'src_'.$_})) {               if (&Apache::lonnet::allowed('bre',$bighash{'src_'.$_})) {
          if ($couldbe) {           if ($couldbe) {
      $couldbe.=','.$_;       $couldbe.=','.$_;
                  } else {                   } else {
Line 97  sub handler { Line 129  sub handler {
 # ----------------------------------------------- Okay, really multiple choices  # ----------------------------------------------- Okay, really multiple choices
                $r->content_type('text/html');                 $r->content_type('text/html');
                $r->send_http_header;                 $r->send_http_header;
                $r->print(                 $r->print(<<ENDSTART);
                 '<head><title>Choose Location</title><body bgcolor="#FFFFFF">'.  <head><title>Choose Location</title></head>
                 '<h1>LON-CAPA</h1>Cool.</body></html>');  <body bgcolor="#FFFFFF">
   <h1>LON-CAPA</h1>
   The resource you had been accessing appears more than once in this course,
   and LON-CAPA has insufficient session information to determine which instance
   of the resource you meant.
   <p>
   Please click on the instance of the resource you intended to access:
   <p>
   <form action="/adm/ambiguous" method=post>
   <input type=hidden name=orgurl value="$thisfn">
   <input type=hidden name=selecturl value=1>
   <table border=2>
   <tr><th>&nbsp;</th><th>Title</th><th>Type</th><th>Part of ...</th></tr>
   ENDSTART
                  map {
                      my $mapurl=$bighash{'map_id_'.(split(/\./,$_))[0]};
                      $r->print('<tr><td><input type=submit value=Select name="'.
                                 $_.'"></td><td>'.$bighash{'title_'.$_}.
                                 '</td><td>'.$bighash{'type_'.$_}.
                                 '</td><td><a href="'.$mapurl.'">'.$mapurl.
         '</a></td></tr>');
                  } @possibilities;
                  $r->print('</table></form></body></html>');
        untie(%bighash);         untie(%bighash);
                return OK;                 return OK;
             }              }
Line 109  sub handler { Line 163  sub handler {
   }    }
   
 # ------------------------------------ This handler should not have been called  # ------------------------------------ This handler should not have been called
    getlost($r);     &getlost($r,'Invalid call of handler');
    return OK;     return OK;
 }  }
   

Removed from v.1.1  
changed lines
  Added in v.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>