Diff for /loncom/interface/loncommon.pm between versions 1.566 and 1.577

version 1.566, 2007/08/23 21:54:40 version 1.577, 2007/08/31 17:58:47
Line 721  sub help_open_topic { Line 721  sub help_open_topic {
   
     my $template = "";      my $template = "";
     my $link;      my $link;
       
     $topic=~s/\W/\_/g;      $topic=~s/\W/\_/g;
   
     if (!$stayOnPage)      if (!$stayOnPage) {
     {  
  $link = "javascript:void(open('/adm/help/${filename}.hlp', 'Help_for_$topic', 'menubar=0,toolbar=1,scrollbars=1,width=$width,height=$height,resizable=yes'))";   $link = "javascript:void(open('/adm/help/${filename}.hlp', 'Help_for_$topic', 'menubar=0,toolbar=1,scrollbars=1,width=$width,height=$height,resizable=yes'))";
     }      } else {
     else  
     {  
  $link = "/adm/help/${filename}.hlp";   $link = "/adm/help/${filename}.hlp";
     }      }
   
     # Add the text      # Add the text
     if ($text ne "")      if ($text ne "") {
     {  
  $template .=    $template .= 
   "<table bgcolor='#3333AA' cellspacing='1' cellpadding='1' border='0'><tr>".              "<table bgcolor='#3333AA' cellspacing='1' cellpadding='1' border='0'><tr>".
   "<td bgcolor='#5555FF'><a target=\"_top\" href=\"$link\"><font color='#FFFFFF' size='2'>$text</font></a>";              "<td bgcolor='#5555FF'><a target=\"_top\" href=\"$link\"><font color='#FFFFFF' size='2'>$text</font></a>";
     }      }
   
     # Add the graphic      # Add the graphic
Line 805  sub help_open_menu { Line 801  sub help_open_menu {
     my ($topic,$component_help,$faq,$bug,$stayOnPage,$width,$height,$text)       my ($topic,$component_help,$faq,$bug,$stayOnPage,$width,$height,$text) 
  = @_;       = @_;    
     $stayOnPage = 0 if (not defined $stayOnPage);      $stayOnPage = 0 if (not defined $stayOnPage);
     # formerly only used pop-up help (stayOnPage = 0)      # only use pop-up help (stayOnPage == 0)
     # if environment.remote is on (using remote control UI)      # if environment.remote is on (using remote control UI)
     # if ($env{'browser.interface'} eq 'textual' ||      if ($env{'browser.interface'} eq 'textual' ||
     # $env{'environment.remote'} eq 'off' ) {      $env{'environment.remote'} eq 'off' ) {
     #   $stayOnPage=1;  
     #}  
     # Now making pop-up help the default even with remote control  
     if ($env{'browser.interface'} eq 'textual') {  
         $stayOnPage=1;          $stayOnPage=1;
     }      }
     my $output;      my $output;
Line 834  sub help_open_menu { Line 826  sub help_open_menu {
   
 sub top_nav_help {  sub top_nav_help {
     my ($text) = @_;      my ($text) = @_;
   
     $text = &mt($text);      $text = &mt($text);
       my $stay_on_page = 
     my $stayOnPage =   
  ($env{'browser.interface'}  eq 'textual' ||   ($env{'browser.interface'}  eq 'textual' ||
  $env{'environment.remote'} eq 'off' );   $env{'environment.remote'} eq 'off' );
     my $link=  ($stayOnPage) ? "javascript:helpMenu('display')"      my $link = ($stay_on_page) ? "javascript:helpMenu('display')"
                      : "javascript:helpMenu('open')";                       : "javascript:helpMenu('open')";
     my $banner_link = &update_help_link(undef,undef,undef,undef,$stayOnPage);      my $banner_link = &update_help_link(undef,undef,undef,undef,$stay_on_page);
   
     my $title = &mt('Get help');      my $title = &mt('Get help');
   
Line 1099  to be attached to the <body> for the onl Line 1089  to be attached to the <body> for the onl
 sub resize_textarea_js {  sub resize_textarea_js {
     return <<"RESIZE";      return <<"RESIZE";
     <script type="text/javascript">      <script type="text/javascript">
  function myHandleEvent (event) {  
     alert(event.type);  
  }  
   
 var Geometry = {};  var Geometry = {};
 function init_geometry() {  function init_geometry() {
     if (Geometry.init) { return };      if (Geometry.init) { return };
Line 3519  sub bodytag { Line 3505  sub bodytag {
     if (!$realm) { $realm='&nbsp;'; }      if (!$realm) { $realm='&nbsp;'; }
 # Set messages  # Set messages
     my $messages=&domainlogo($domain);      my $messages=&domainlogo($domain);
 # Port for miniserver  
     my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'};  
     if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }  
   
     my $extra_body_attr = &make_attr_string($forcereg,\%design);      my $extra_body_attr = &make_attr_string($forcereg,\%design);
   
Line 3639  ENDROLE Line 3622  ENDROLE
   
     my $imgsrc = $img;      my $imgsrc = $img;
     if ($img =~ /^\/adm/) {      if ($img =~ /^\/adm/) {
         $imgsrc = 'http://'.$ENV{'HTTP_HOST'}.':'.$lonhttpdPort.$img;          $imgsrc = &lonhttpdurl($img);
     }      }
     my $upperleft='<img src="'.$imgsrc.'" alt="'.$function.'" />';      my $upperleft='<img src="'.$imgsrc.'" alt="'.$function.'" />';
   
Line 4515  span.LC_nobreak { Line 4498  span.LC_nobreak {
   white-space: nowrap;    white-space: nowrap;
 }  }
   
   span.LC_cusr_emph {
     font-style: italic;
   }
   
 table.LC_docs_documents {  table.LC_docs_documents {
   background: #BBBBBB;    background: #BBBBBB;
   border-width: 0px;    border-width: 0px;
Line 5613  sub get_secgrprole_info { Line 5600  sub get_secgrprole_info {
 }  }
   
 sub user_picker {  sub user_picker {
     my ($dom,$srch,$forcenewuser) = @_;      my ($dom,$srch,$forcenewuser,$caller) = @_;
     my $currdom = $dom;      my $currdom = $dom;
     my %curr_selected = (      my %curr_selected = (
                         srchin => 'dom',                          srchin => 'dom',
Line 5636  sub user_picker { Line 5623  sub user_picker {
         $srchterm = $srch->{'srchterm'};          $srchterm = $srch->{'srchterm'};
     }      }
     my %lt=&Apache::lonlocal::texthash(      my %lt=&Apache::lonlocal::texthash(
                       'usr'       => 'Search criteria',
                     'doma'      => 'Domain/institution to search',                      'doma'      => 'Domain/institution to search',
                     'uname'     => 'username',                      'uname'     => 'username',
                     'lastname'  => 'last name',                      'lastname'  => 'last name',
                     'lastfirst' => 'last name, first name',                      'lastfirst' => 'last name, first name',
                     'crs'       => 'in this course',                      'crs'       => 'in this course',
                     'dom'       => 'in this domain',                       'dom'       => 'in selected LON-CAPA domain', 
                     'alc'       => 'all LON-CAPA',                      'alc'       => 'all LON-CAPA',
                     'instd'     => 'in institutional directory',                      'instd'     => 'in institutional directory for selected domain',
                     'exact'     => 'is',                      'exact'     => 'is',
                     'contains'  => 'contains',                      'contains'  => 'contains',
                       'begins'    => 'begins with',
                       'youm'      => "You must include some text to search for.",
                       'thte'      => "The text you are searching for must contain at least two characters when using a 'begins' type search.",
                       'thet'      => "The text you are searching for must contain at least three characters when using a 'contains' type search.",
                       'yomc'      => "You must choose a domain when using an institutional directory search.",
                       'ymcd'      => "You must choose a domain when using a domain search.",
                       'whus'      => "When using searching by last,first you must include a comma as separator between last name and first name.",
                       'whse'      => "When searching by last,first you must include at least one character in the first name.",
                        'thfo'     => "The following need to be corrected before the search can be run:",
                                        );                                         );
     my $domform = &select_dom_form($currdom,'srchdomain',1,1);      my $domform = &select_dom_form($currdom,'srchdomain',1,1);
     my $srchinsel = ' <select name="srchin">';      my $srchinsel = ' <select name="srchin">';
Line 5681  sub user_picker { Line 5678  sub user_picker {
     $srchbysel .= "\n  </select>\n";      $srchbysel .= "\n  </select>\n";
   
     my $srchtypesel = ' <select name="srchtype">';      my $srchtypesel = ' <select name="srchtype">';
     foreach my $option ('exact','contains') {      foreach my $option ('exact','begins','contains') {
         if ($curr_selected{'srchtype'} eq $option) {          if ($curr_selected{'srchtype'} eq $option) {
             $srchtypesel .= '              $srchtypesel .= '
    <option value="'.$option.'" selected="selected">'.$lt{$option}.'</option>';     <option value="'.$option.'" selected="selected">'.$lt{$option}.'</option>';
Line 5695  sub user_picker { Line 5692  sub user_picker {
     my ($newuserscript,$new_user_create);      my ($newuserscript,$new_user_create);
   
     if ($forcenewuser) {      if ($forcenewuser) {
  $new_user_create = '<p> <input type="submit" name="forcenew" value="'.&HTML::Entities::encode(&mt('Make new user "[_1]"',$srchterm),'<>&"').'" onclick="javascript:setSearch(\'1\');" /> </p>';          if (ref($srch) eq 'HASH') {
               if ($srch->{'srchby'} eq 'uname' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchin'} eq 'dom' && $srch->{'srchdomain'} eq $env{'request.role.domain'}) {
           $new_user_create = '<p> <input type="submit" name="forcenew" value="'.&HTML::Entities::encode(&mt('Make new user "[_1]"',$srchterm),'<>&"').'" onclick="javascript:setSearch(\'1\','.$caller.');" /> </p>';
               }
           }
   
         $newuserscript = <<"ENDSCRIPT";          $newuserscript = <<"ENDSCRIPT";
   
 function setSearch(createnew) {  function setSearch(createnew,callingForm) {
     if (createnew == 1) {      if (createnew == 1) {
         for (var i=0; i<document.crtuser.srchby.length; i++) {          for (var i=0; i<callingForm.srchby.length; i++) {
             if (document.crtuser.srchby.options[i].value == 'uname') {              if (callingForm.srchby.options[i].value == 'uname') {
                 document.crtuser.srchby.selectedIndex = i;                  callingForm.srchby.selectedIndex = i;
             }              }
         }          }
         for (var i=0; i<document.crtuser.srchin.length; i++) {          for (var i=0; i<callingForm.srchin.length; i++) {
             if ( document.crtuser.srchin.options[i].value == 'dom') {              if ( callingForm.srchin.options[i].value == 'dom') {
  document.crtuser.srchin.selectedIndex = i;   callingForm.srchin.selectedIndex = i;
             }              }
         }          }
         for (var i=0; i<document.crtuser.srchtype.length; i++) {          for (var i=0; i<callingForm.srchtype.length; i++) {
             if (document.crtuser.srchtype.options[i].value == 'exact') {              if (callingForm.srchtype.options[i].value == 'exact') {
                 document.crtuser.srchtype.selectedIndex = i;                  callingForm.srchtype.selectedIndex = i;
             }              }
         }          }
         for (var i=0; i<document.crtuser.srchdomain.length; i++) {          for (var i=0; i<callingForm.srchdomain.length; i++) {
             if (document.crtuser.srchdomain.options[i].value == '$env{'request.role.domain'}') {              if (callingForm.srchdomain.options[i].value == '$env{'request.role.domain'}') {
                 document.crtuser.srchdomain.selectedIndex = i;                  callingForm.srchdomain.selectedIndex = i;
             }              }
         }          }
     }      }
Line 5728  ENDSCRIPT Line 5730  ENDSCRIPT
   
     my $output = <<"END_BLOCK";      my $output = <<"END_BLOCK";
 <script type="text/javascript">  <script type="text/javascript">
 function validateEntry() {  function validateEntry(callingForm) {
   
     var checkok = 1;      var checkok = 1;
     var srchin;      var srchin;
     for (var i=0; i<document.crtuser.srchin.length; i++) {      for (var i=0; i<callingForm.srchin.length; i++) {
  if ( document.crtuser.srchin[i].checked ) {   if ( callingForm.srchin[i].checked ) {
     srchin = document.crtuser.srchin[i].value;      srchin = callingForm.srchin[i].value;
  }   }
     }      }
   
     var srchtype = document.crtuser.srchtype.options[document.crtuser.srchtype.selectedIndex].value;      var srchtype = callingForm.srchtype.options[callingForm.srchtype.selectedIndex].value;
     var srchby = document.crtuser.srchby.options[document.crtuser.srchby.selectedIndex].value;      var srchby = callingForm.srchby.options[callingForm.srchby.selectedIndex].value;
     var srchdomain = document.crtuser.srchdomain.options[document.crtuser.srchdomain.selectedIndex].value;      var srchdomain = callingForm.srchdomain.options[callingForm.srchdomain.selectedIndex].value;
     var srchterm =  document.crtuser.srchterm.value;      var srchterm =  callingForm.srchterm.value;
     var srchin = document.crtuser.srchin.options[document.crtuser.srchin.selectedIndex].value;      var srchin = callingForm.srchin.options[callingForm.srchin.selectedIndex].value;
     var msg = "";      var msg = "";
   
     if (srchterm == "") {      if (srchterm == "") {
         checkok = 0;          checkok = 0;
         msg += "You must include some text to search for.\\n";          msg += "$lt{'youm'}\\n";
       }
   
       if (srchtype== 'begins') {
           if (srchterm.length < 2) {
               checkok = 0;
               msg += "$lt{'thte'}\\n";
           }
     }      }
   
     if (srchtype== 'contains') {      if (srchtype== 'contains') {
         if (srchterm.length < 3) {          if (srchterm.length < 3) {
             checkok = 0;              checkok = 0;
             msg += "The text you are searching for must contain at least three characters when using a 'contains' type search.\\n";              msg += "$lt{'thet'}\\n";
         }          }
     }      }
     if (srchin == 'instd') {      if (srchin == 'instd') {
         if (srchdomain == '') {          if (srchdomain == '') {
             checkok = 0;              checkok = 0;
             msg += "You must choose a domain when using an institutional directory search.\\n";              msg += "$lt{'yomc'}\\n";
         }          }
     }      }
     if (srchin == 'dom') {      if (srchin == 'dom') {
         if (srchdomain == '') {          if (srchdomain == '') {
             checkok = 0;              checkok = 0;
             msg += "You must choose a domain when using a domain search.\\n";              msg += "$lt{'ymcd'}\\n";
         }          }
     }      }
     if (srchby == 'lastfirst') {      if (srchby == 'lastfirst') {
         if (srchterm.indexOf(",") == -1) {          if (srchterm.indexOf(",") == -1) {
             checkok = 0;              checkok = 0;
             msg += "When using searching by last,first you must include a comma as separator between last name and first name.\\n";              msg += "$lt{'whus'}\\n";
         }          }
         if (srchterm.indexOf(",") == srchterm.length -1) {          if (srchterm.indexOf(",") == srchterm.length -1) {
             checkok = 0;              checkok = 0;
             msg += "When searching by last,first you must include at least one character in the first name.\\n";              msg += "$lt{'whse'}\\n";
         }          }
     }      }
     if (checkok == 0) {      if (checkok == 0) {
         alert("The following need to be corrected before the search can be run:\\n"+msg);          alert("$lt{'thfo'}\\n"+msg);
         return;          return;
     }      }
     if (checkok == 1) {      if (checkok == 1) {
         document.crtuser.submit();          callingForm.submit();
     }      }
 }  }
   
Line 5795  $new_user_create Line 5804  $new_user_create
   
 <table>  <table>
  <tr>   <tr>
     <td>$lt{'doma'}:</td>
     <td>$domform</td>
     </td>
    </tr>
    <tr>
     <td>$lt{'usr'}:</td>
   <td>$srchbysel    <td>$srchbysel
       $srchtypesel         $srchtypesel 
       <input type="text" size="15" name="srchterm" value="$srchterm" />        <input type="text" size="15" name="srchterm" value="$srchterm" />
       $srchinsel         $srchinsel 
   </td>    </td>
  </tr>   </tr>
  <tr>  
   <td>$lt{'doma'}: $domform</td>  
   </td>  
  </tr>  
 </table>  </table>
 <br />  <br />
 END_BLOCK  END_BLOCK
Line 5812  END_BLOCK Line 5823  END_BLOCK
     return $output;      return $output;
 }  }
   
   
   
 =pod  =pod
   
 =back  =back
Line 6986  sub check_clone { Line 6995  sub check_clone {
  $args->{'crstype'});   $args->{'crstype'});
     } else {      } else {
  my %clonedesc = &Apache::lonnet::coursedescription($cloneid,{'one_time' => 1});   my %clonedesc = &Apache::lonnet::coursedescription($cloneid,{'one_time' => 1});
  if ($env{'request.role.domain'} eq $args->{'form.clonedomain'}) {   if ($env{'request.role.domain'} eq $args->{'clonedomain'}) {
     $can_clone = 1;      $can_clone = 1;
  } else {   } else {
     my %clonehash = &Apache::lonnet::get('environment',['cloners'],      my %clonehash = &Apache::lonnet::get('environment',['cloners'],
Line 7366  sub icon { Line 7375  sub icon {
     return &lonhttpdurl($iconname);      return &lonhttpdurl($iconname);
 }   } 
   
 sub lonhttpdurl {  sub lonhttpd_port {
     my ($url)=@_;  
     my $lonhttpd_port=$Apache::lonnet::perlvar{'lonhttpdPort'};      my $lonhttpd_port=$Apache::lonnet::perlvar{'lonhttpdPort'};
     if (!defined($lonhttpd_port)) { $lonhttpd_port='8080'; }      if (!defined($lonhttpd_port)) { $lonhttpd_port='8080'; }
       # IE doesn't like a secure page getting images from a non-secure
       # port (when logging we haven't parsed the browser type so default
       # back to secure
       if ((!exists($env{'browser.type'}) || $env{'browser.type'} eq 'explorer')
    && $ENV{'SERVER_PORT'} == 443) {
    return 443;
       }
       return $lonhttpd_port;
   
   }
   
   sub lonhttpdurl {
       my ($url)=@_;
   
       my $lonhttpd_port = &lonhttpd_port();
       if ($lonhttpd_port == 443) {
    return 'https://'.$ENV{'SERVER_NAME'}.$url;
       }
     return 'http://'.$ENV{'SERVER_NAME'}.':'.$lonhttpd_port.$url;      return 'http://'.$ENV{'SERVER_NAME'}.':'.$lonhttpd_port.$url;
 }  }
   

Removed from v.1.566  
changed lines
  Added in v.1.577


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