Diff for /loncom/interface/lonsearchcourse.pm between versions 1.3 and 1.11

version 1.3, 2011/01/17 22:56:27 version 1.11, 2024/02/11 22:20:06
Line 41  use Apache::lonlocal; Line 41  use Apache::lonlocal;
 use LONCAPA::lonmetadata();  use LONCAPA::lonmetadata();
 use HTML::Entities();  use HTML::Entities();
 use Apache::lonnavmaps;  use Apache::lonnavmaps;
 use Apache::londocs();  use Apache::lonnavdisplay();
 use Apache::lonindexer();  use Apache::lonindexer();
 use LONCAPA;  use LONCAPA;
   
Line 123  sub course_search { Line 123  sub course_search {
     my $discuss=$env{'form.crsdiscuss'};      my $discuss=$env{'form.crsdiscuss'};
     my @allwords=($search_string,@New_Words);      my @allwords=($search_string,@New_Words);
     $totalfound=0;      $totalfound=0;
       my $target = 'cat';
       if ((($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) ||
           (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self'))) {
           $target = '_self';
       }
   
     $r->print(      $r->print(
               '<hr /><center><font size="+2" face="arial">'.                '<hr /><center><font size="+2" face="arial">'.
Line 136  sub course_search { Line 141  sub course_search {
         foreach (sort(keys(%hash))) {          foreach (sort(keys(%hash))) {
             if ($c->aborted()) { last; }              if ($c->aborted()) { last; }
             if (($_=~/^src\_(.+)$/)) {              if (($_=~/^src\_(.+)$/)) {
                 if ($hash{'randomout_'.$1} & !$env{'request.role.adv'}) {                  my $rid = $1;
                     next;                  unless ($env{'request.role.adv'}) {
                       next if ($hash{'randomout_'.$rid} || $hash{'deeplinkout_'.$rid});
                       if (!$env{'request.deeplink.login'} && $hash{'deeplinkonly_'.$rid}) {
                           my ($value) = map { &unescape($_); } split(/:/,$hash{'deeplinkonly_'.$rid});
                           my ($state,$others,$listed) = split(/,/,$value);
                           next if (($state eq 'only') &&
                                    (($listed eq 'absent') || ($listed eq 'grades')));
                       }
                 }                  }
                 my $symb=&make_symb($1);                  my $symb=&make_symb($1);
                 &checkonthis($r,$1,$hash{$_},0,&Apache::lonnet::gettitle($symb),                  &checkonthis($r,$1,$hash{$_},0,&Apache::lonnet::gettitle($symb),
                              $fulltext,$symb,@allwords);                               $fulltext,$symb,$target,@allwords);
             }              }
         }          }
         untie(%hash);          untie(%hash);
Line 213  sub course_search { Line 225  sub course_search {
                     }                      }
                     $url .= &escape($resource->symb());                      $url .= &escape($resource->symb());
                     my $title = $resource->compTitle();                      my $title = $resource->compTitle();
                     $r->print('<br /><a href="'.$url.'" target="cat">'.                      $r->print('<br /><a href="'.$url.'" target="'.$target.'">'.
                          ($title?$title:$url).'</a>&nbsp;&nbsp;-&nbsp;'.                           ($title?$title:$url).'</a>&nbsp;&nbsp;-&nbsp;'.
                          $disctype.'<br />');                           $disctype.'<br />');
                     $totaldiscussions++;                      $totaldiscussions++;
Line 233  sub course_search { Line 245  sub course_search {
 # =============================== This pulls up a resource and its dependencies  # =============================== This pulls up a resource and its dependencies
   
 sub checkonthis {  sub checkonthis {
     my ($r,$id,$url,$level,$title,$fulltext,$symb,@allwords)=@_;      my ($r,$id,$url,$level,$title,$fulltext,$symb,$target,@allwords)=@_;
     $alreadyseen{$id}=1;      $alreadyseen{$id}=1;
     if (&Apache::loncommon::connection_aborted($r)) { return; }      if (&Apache::loncommon::connection_aborted($r)) { return; }
     $r->rflush();      $r->rflush();
Line 261  sub checkonthis { Line 273  sub checkonthis {
        }         }
        my $href=$url;         my $href=$url;
        if ($hash{'encrypted_'.$id} && !$env{'request.role.adv'}) {         if ($hash{'encrypted_'.$id} && !$env{'request.role.adv'}) {
            $href=&Apache::lonenc::encrypted($href)             $href=&Apache::lonenc::encrypted($href);
                .'?symb='.&Apache::lonenc::encrypted($symb);             if ($url =~ /\.sequence$/) {
                  $href .= '?navmap=1';
              } else {
                  $href .= '?symb='.&Apache::lonenc::encrypted($symb);
              }
        } else {         } else {
            $href.='?symb='.&escape($symb);             if ($href =~ /\.sequence$/) {
                  $href .= '?navmap=1';
              } else {
                  $href .= '?symb='.&escape($symb);
              }
        }         }
        $r->print('<a href="'.$href.'" target="cat">'.($title?$title:$url).         $r->print('<a href="'.$href.'" target="'.$target.'">'.($title?$title:$url).
                  '</a><br />');                   '</a><br />');
        $totalfound++;         $totalfound++;
     } elsif ($fulltext) {      } elsif ($fulltext) {
Line 278  sub checkonthis { Line 298  sub checkonthis {
                 &Apache::lonnet::metadata($url,'dependencies');                  &Apache::lonnet::metadata($url,'dependencies');
     foreach (split(/\,/,$dependencies)) {      foreach (split(/\,/,$dependencies)) {
        if (($_=~/^\/res\//) && (!$alreadyseen{$id})) {         if (($_=~/^\/res\//) && (!$alreadyseen{$id})) {
           &checkonthis($r,$id,$_,$level+1,'',$fulltext,undef,@allwords);            &checkonthis($r,$id,$_,$level+1,'',$fulltext,undef,$target,@allwords);
        }         }
     }      }
 }  }
Line 311  sub handler { Line 331  sub handler {
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['phase']);      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['phase']);
     $r->print(&Apache::loncommon::start_page("$crstype Search"));      $r->print(&Apache::loncommon::start_page("$crstype Search"));
     &Apache::lonhtmlcommon::clear_breadcrumbs();      &Apache::lonhtmlcommon::clear_breadcrumbs();
       if ($env{'request.course.id'} eq '') {
           $r->print(&Apache::lonhtmlcommon::breadcrumbs("$crstype Search"));
           $r->print(&Apache::loncommon::end_page());
           my $requrl = $r->uri;
           $env{'user.error.msg'} = "$requrl:bre:0:0:Course not initialized";
           $env{'user.reinit'} = 1;
           return HTTP_NOT_ACCEPTABLE;
       }
     &Apache::lonhtmlcommon::add_breadcrumb(      &Apache::lonhtmlcommon::add_breadcrumb(
             {   href => '/adm/searchcourse',              {   href => '/adm/searchcourse',
                 text => "$crstype Search"});                  text => "$crstype Search"});
Line 320  sub handler { Line 348  sub handler {
                 text => 'Search Results'});                  text => 'Search Results'});
     }      }
     $r->print(&Apache::lonhtmlcommon::breadcrumbs("$crstype Search"));      $r->print(&Apache::lonhtmlcommon::breadcrumbs("$crstype Search"));
     &Apache::londocs::startContentScreen($r,'coursesearch');      &Apache::lonnavdisplay::startContentScreen($r,'coursesearch');
     if ($env{'form.phase'} eq 'results') {      my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
        &course_search($r);      my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
       my $clientip = &Apache::lonnet::get_requestor_ip($r);
       my ($blocked,$blocktext) =
           &Apache::loncommon::blocking_status('search',$clientip,$cnum,$cdom);
       if ($blocked) {
           my $checkrole = "cm./$cdom/$cnum";
           if ($env{'request.course.sec'} ne '') {
               $checkrole .= "/$env{'request.course.sec'}";
           }
           if ((&Apache::lonnet::allowed('evb',undef,undef,$checkrole)) &&
               ($env{'request.role'} !~ m{^st\./$cdom/$cnum})) {
               undef($blocked);
           }
       }
       if ($blocked) {
           $r->print($blocktext);
       } elsif ($env{'form.phase'} eq 'results') {
           &course_search($r);
     } else {      } else {
        $r->print(&menu());          $r->print(&menu());
     }      }
     &Apache::londocs::endContentScreen($r);      &Apache::lonnavdisplay::endContentScreen($r);
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
     return OK;      return OK;
 }  }

Removed from v.1.3  
changed lines
  Added in v.1.11


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