Diff for /loncom/lonnet/perl/lonnet.pm between versions 1.1493 and 1.1494

version 1.1493, 2022/10/07 12:53:32 version 1.1494, 2022/10/07 14:31:28
Line 985  sub spareserver { Line 985  sub spareserver {
                                                      :  $userloadpercent;                                                       :  $userloadpercent;
     my ($uint_dom,$remotesessions);      my ($uint_dom,$remotesessions);
     if (($udom ne '') && (&domain($udom) ne '')) {      if (($udom ne '') && (&domain($udom) ne '')) {
         my $uprimary_id = &Apache::lonnet::domain($udom,'primary');          my $uprimary_id = &domain($udom,'primary');
         $uint_dom = &Apache::lonnet::internet_dom($uprimary_id);          $uint_dom = &internet_dom($uprimary_id);
         my %udomdefaults = &Apache::lonnet::get_domain_defaults($udom);          my %udomdefaults = &get_domain_defaults($udom);
         $remotesessions = $udomdefaults{'remotesessions'};          $remotesessions = $udomdefaults{'remotesessions'};
     }      }
     my $spareshash = &this_host_spares($udom);      my $spareshash = &this_host_spares($udom);
Line 1023  sub spareserver { Line 1023  sub spareserver {
                 if ($protocol{$spare_server} eq 'https') {                  if ($protocol{$spare_server} eq 'https') {
                     $protocol = $protocol{$spare_server};                      $protocol = $protocol{$spare_server};
                 }                  }
                 my $alias = &Apache::lonnet::use_proxy_alias($r,$spare_server);                  my $alias = &use_proxy_alias($r,$spare_server);
                 $hostname = $alias if ($alias ne '');                  $hostname = $alias if ($alias ne '');
         $spare_server = $protocol.'://'.$hostname;          $spare_server = $protocol.'://'.$hostname;
             }              }
Line 1211  sub choose_server { Line 1211  sub choose_server {
         unless (defined($cached)) {          unless (defined($cached)) {
             my $cachetime = 60*60*24;              my $cachetime = 60*60*24;
             my %domconfig =              my %domconfig =
                 &Apache::lonnet::get_dom('configuration',['loadbalancing'],$udom);                  &get_dom('configuration',['loadbalancing'],$udom);
             if (ref($domconfig{'loadbalancing'}) eq 'HASH') {              if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
                 $balancers = &do_cache_new('loadbalancing',$udom,$domconfig{'loadbalancing'},                  $balancers = &do_cache_new('loadbalancing',$udom,$domconfig{'loadbalancing'},
                                            $cachetime);                                             $cachetime);
Line 1404  sub can_switchserver { Line 1404  sub can_switchserver {
 sub can_host_session {  sub can_host_session {
     my ($udom,$lonhost,$remoterev,$remotesessions,$hostedsessions) = @_;      my ($udom,$lonhost,$remoterev,$remotesessions,$hostedsessions) = @_;
     my $canhost = 1;      my $canhost = 1;
     my $host_idn = &Apache::lonnet::internet_dom($lonhost);      my $host_idn = &internet_dom($lonhost);
     if (ref($remotesessions) eq 'HASH') {      if (ref($remotesessions) eq 'HASH') {
         if (ref($remotesessions->{'excludedomain'}) eq 'ARRAY') {          if (ref($remotesessions->{'excludedomain'}) eq 'ARRAY') {
             if (grep(/^\Q$host_idn\E$/,@{$remotesessions->{'excludedomain'}})) {              if (grep(/^\Q$host_idn\E$/,@{$remotesessions->{'excludedomain'}})) {
Line 1440  sub can_host_session { Line 1440  sub can_host_session {
     }      }
     if ($canhost) {      if ($canhost) {
         if (ref($hostedsessions) eq 'HASH') {          if (ref($hostedsessions) eq 'HASH') {
             my $uprimary_id = &Apache::lonnet::domain($udom,'primary');              my $uprimary_id = &domain($udom,'primary');
             my $uint_dom = &Apache::lonnet::internet_dom($uprimary_id);              my $uint_dom = &internet_dom($uprimary_id);
             if (ref($hostedsessions->{'excludedomain'}) eq 'ARRAY') {              if (ref($hostedsessions->{'excludedomain'}) eq 'ARRAY') {
                 if (($uint_dom ne '') &&                   if (($uint_dom ne '') && 
                     (grep(/^\Q$uint_dom\E$/,@{$hostedsessions->{'excludedomain'}}))) {                      (grep(/^\Q$uint_dom\E$/,@{$hostedsessions->{'excludedomain'}}))) {
Line 1533  sub spares_for_offload  { Line 1533  sub spares_for_offload  {
     } else {      } else {
         my $cachetime = 60*60*24;          my $cachetime = 60*60*24;
         my %domconfig =          my %domconfig =
             &Apache::lonnet::get_dom('configuration',['usersessions'],$dom_in_use);              &get_dom('configuration',['usersessions'],$dom_in_use);
         if (ref($domconfig{'usersessions'}) eq 'HASH') {          if (ref($domconfig{'usersessions'}) eq 'HASH') {
             if (ref($domconfig{'usersessions'}{'spares'}) eq 'HASH') {              if (ref($domconfig{'usersessions'}{'spares'}) eq 'HASH') {
                 if (ref($domconfig{'usersessions'}{'spares'}{$lonhost_in_use}) eq 'HASH') {                  if (ref($domconfig{'usersessions'}{'spares'}{$lonhost_in_use}) eq 'HASH') {
Line 1585  sub check_loadbalancing { Line 1585  sub check_loadbalancing {
         $rule_in_effect,$offloadto,$otherserver,$setcookie,$dom_balancers);          $rule_in_effect,$offloadto,$otherserver,$setcookie,$dom_balancers);
     my $lonhost = $perlvar{'lonHostID'};      my $lonhost = $perlvar{'lonHostID'};
     my @hosts = &current_machine_ids();      my @hosts = &current_machine_ids();
     my $uprimary_id = &Apache::lonnet::domain($udom,'primary');      my $uprimary_id = &domain($udom,'primary');
     my $uintdom = &Apache::lonnet::internet_dom($uprimary_id);      my $uintdom = &internet_dom($uprimary_id);
     my $intdom = &Apache::lonnet::internet_dom($lonhost);      my $intdom = &internet_dom($lonhost);
     my $serverhomedom = &host_domain($lonhost);      my $serverhomedom = &host_domain($lonhost);
     my $domneedscache;      my $domneedscache;
     my $cachetime = 60*60*24;      my $cachetime = 60*60*24;
Line 1601  sub check_loadbalancing { Line 1601  sub check_loadbalancing {
     my ($result,$cached)=&is_cached_new('loadbalancing',$dom_in_use);      my ($result,$cached)=&is_cached_new('loadbalancing',$dom_in_use);
     unless (defined($cached)) {      unless (defined($cached)) {
         my %domconfig =          my %domconfig =
             &Apache::lonnet::get_dom('configuration',['loadbalancing'],$dom_in_use);              &get_dom('configuration',['loadbalancing'],$dom_in_use);
         if (ref($domconfig{'loadbalancing'}) eq 'HASH') {          if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
             $result = &do_cache_new('loadbalancing',$dom_in_use,$domconfig{'loadbalancing'},$cachetime);              $result = &do_cache_new('loadbalancing',$dom_in_use,$domconfig{'loadbalancing'},$cachetime);
         } else {          } else {
Line 1662  sub check_loadbalancing { Line 1662  sub check_loadbalancing {
         ($result,$cached)=&is_cached_new('loadbalancing',$serverhomedom);          ($result,$cached)=&is_cached_new('loadbalancing',$serverhomedom);
         unless (defined($cached)) {          unless (defined($cached)) {
             my %domconfig =              my %domconfig =
                 &Apache::lonnet::get_dom('configuration',['loadbalancing'],$serverhomedom);                  &get_dom('configuration',['loadbalancing'],$serverhomedom);
             if (ref($domconfig{'loadbalancing'}) eq 'HASH') {              if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
                 $result = &do_cache_new('loadbalancing',$serverhomedom,$domconfig{'loadbalancing'},$cachetime);                  $result = &do_cache_new('loadbalancing',$serverhomedom,$domconfig{'loadbalancing'},$cachetime);
             } else {              } else {
Line 1795  sub get_loadbalancer_targets { Line 1795  sub get_loadbalancer_targets {
             }              }
         } elsif ($rule_in_effect eq 'externalbalancer') {          } elsif ($rule_in_effect eq 'externalbalancer') {
             my %domconfig =              my %domconfig =
                 &Apache::lonnet::get_dom('configuration',['loadbalancing'],$udom);                  &get_dom('configuration',['loadbalancing'],$udom);
             if (ref($domconfig{'loadbalancing'}) eq 'HASH') {              if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
                 if ($domconfig{'loadbalancing'}{'lonhost'} ne '') {                  if ($domconfig{'loadbalancing'}{'lonhost'} ne '') {
                     if (&hostname($domconfig{'loadbalancing'}{'lonhost'}) ne '') {                      if (&hostname($domconfig{'loadbalancing'}{'lonhost'}) ne '') {
Line 1859  sub trusted_domains { Line 1859  sub trusted_domains {
         return ($trusted,$untrusted);          return ($trusted,$untrusted);
     }      }
     my $callprimary = &domain($calldom,'primary');      my $callprimary = &domain($calldom,'primary');
     my $intcalldom = &Apache::lonnet::internet_dom($callprimary);      my $intcalldom = &internet_dom($callprimary);
     if ($intcalldom eq '') {      if ($intcalldom eq '') {
         return ($trusted,$untrusted);          return ($trusted,$untrusted);
     }      }
   
     my ($trustconfig,$cached)=&Apache::lonnet::is_cached_new('trust',$calldom);      my ($trustconfig,$cached)=&is_cached_new('trust',$calldom);
     unless (defined($cached)) {      unless (defined($cached)) {
         my %domconfig = &Apache::lonnet::get_dom('configuration',['trust'],$calldom);          my %domconfig = &get_dom('configuration',['trust'],$calldom);
         &Apache::lonnet::do_cache_new('trust',$calldom,$domconfig{'trust'},3600);          &do_cache_new('trust',$calldom,$domconfig{'trust'},3600);
         $trustconfig = $domconfig{'trust'};          $trustconfig = $domconfig{'trust'};
     }      }
     if (ref($trustconfig)) {      if (ref($trustconfig)) {
Line 2345  sub get_domainconfiguser { Line 2345  sub get_domainconfiguser {
 sub retrieve_inst_usertypes {  sub retrieve_inst_usertypes {
     my ($udom) = @_;      my ($udom) = @_;
     my (%returnhash,@order);      my (%returnhash,@order);
     my %domdefs = &Apache::lonnet::get_domain_defaults($udom);      my %domdefs = &get_domain_defaults($udom);
     if ((ref($domdefs{'inststatustypes'}) eq 'HASH') &&       if ((ref($domdefs{'inststatustypes'}) eq 'HASH') && 
         (ref($domdefs{'inststatusorder'}) eq 'ARRAY')) {          (ref($domdefs{'inststatusorder'}) eq 'ARRAY')) {
         return ($domdefs{'inststatustypes'},$domdefs{'inststatusorder'});          return ($domdefs{'inststatustypes'},$domdefs{'inststatusorder'});
Line 2693  sub get_domain_defaults { Line 2693  sub get_domain_defaults {
     }      }
     my %domdefaults;      my %domdefaults;
     my %domconfig =      my %domconfig =
          &Apache::lonnet::get_dom('configuration',['defaults','quotas',           &get_dom('configuration',['defaults','quotas',
                                   'requestcourses','inststatus',                                    'requestcourses','inststatus',
                                   'coursedefaults','usersessions',                                    'coursedefaults','usersessions',
                                   'requestauthor','selfenrollment',                                    'requestauthor','selfenrollment',
Line 2907  sub get_dom_cats { Line 2907  sub get_dom_cats {
         } else {          } else {
             $cats = {};              $cats = {};
         }          }
         &Apache::lonnet::do_cache_new('cats',$dom,$cats,3600);          &do_cache_new('cats',$dom,$cats,3600);
     }      }
     return $cats;      return $cats;
 }  }
Line 2962  sub course_portal_url { Line 2962  sub course_portal_url {
     if ($domdefaults{'portal_def'}) {      if ($domdefaults{'portal_def'}) {
         $firsturl = $domdefaults{'portal_def'};          $firsturl = $domdefaults{'portal_def'};
     } else {      } else {
         my $alias = &Apache::lonnet::use_proxy_alias($r,$chome);          my $alias = &use_proxy_alias($r,$chome);
         $hostname = $alias if ($alias ne '');          $hostname = $alias if ($alias ne '');
         $firsturl = $protocol.'://'.$hostname;          $firsturl = $protocol.'://'.$hostname;
     }      }
Line 3160  sub courseid_to_courseurl { Line 3160  sub courseid_to_courseurl {
  return "/$cdom/$cnum";   return "/$cdom/$cnum";
     }      }
   
     my %courseinfo=&Apache::lonnet::coursedescription($courseid);      my %courseinfo=&coursedescription($courseid);
     if (exists($courseinfo{'num'})) {      if (exists($courseinfo{'num'})) {
  return "/$courseinfo{'domain'}/$courseinfo{'num'}";   return "/$courseinfo{'domain'}/$courseinfo{'num'}";
     }      }
Line 3358  sub userenvironment { Line 3358  sub userenvironment {
 # ---------------------------------------------------------- Get a studentphoto  # ---------------------------------------------------------- Get a studentphoto
 sub studentphoto {  sub studentphoto {
     my ($udom,$unam,$ext) = @_;      my ($udom,$unam,$ext) = @_;
     my $home=&Apache::lonnet::homeserver($unam,$udom);      my $home=&homeserver($unam,$udom);
     if (defined($env{'request.course.id'})) {      if (defined($env{'request.course.id'})) {
         if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {          if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {
             if ($udom eq $env{'course.'.$env{'request.course.id'}.'.domain'}) {              if ($udom eq $env{'course.'.$env{'request.course.id'}.'.domain'}) {
                 return(&retrievestudentphoto($udom,$unam,$ext));                   return(&retrievestudentphoto($udom,$unam,$ext)); 
             } else {              } else {
                 my ($result,$perm_reqd)=                  my ($result,$perm_reqd)=
     &Apache::lonnet::auto_photo_permission($unam,$udom);      &auto_photo_permission($unam,$udom);
                 if ($result eq 'ok') {                  if ($result eq 'ok') {
                     if (!($perm_reqd eq 'yes')) {                      if (!($perm_reqd eq 'yes')) {
                         return(&retrievestudentphoto($udom,$unam,$ext));                          return(&retrievestudentphoto($udom,$unam,$ext));
Line 3375  sub studentphoto { Line 3375  sub studentphoto {
         }          }
     } else {      } else {
         my ($result,$perm_reqd) =           my ($result,$perm_reqd) = 
     &Apache::lonnet::auto_photo_permission($unam,$udom);      &auto_photo_permission($unam,$udom);
         if ($result eq 'ok') {          if ($result eq 'ok') {
             if (!($perm_reqd eq 'yes')) {              if (!($perm_reqd eq 'yes')) {
                 return(&retrievestudentphoto($udom,$unam,$ext));                  return(&retrievestudentphoto($udom,$unam,$ext));
Line 3387  sub studentphoto { Line 3387  sub studentphoto {
   
 sub retrievestudentphoto {  sub retrievestudentphoto {
     my ($udom,$unam,$ext,$type) = @_;      my ($udom,$unam,$ext,$type) = @_;
     my $home=&Apache::lonnet::homeserver($unam,$udom);      my $home=&homeserver($unam,$udom);
     my $ret=&Apache::lonnet::reply("studentphoto:$udom:$unam:$ext:$type",$home);      my $ret=&reply("studentphoto:$udom:$unam:$ext:$type",$home);
     if ($ret eq 'ok') {      if ($ret eq 'ok') {
         my $url="/uploaded/$udom/$unam/internal/studentphoto.$ext";          my $url="/uploaded/$udom/$unam/internal/studentphoto.$ext";
         if ($type eq 'thumbnail') {          if ($type eq 'thumbnail') {
             $url="/uploaded/$udom/$unam/internal/studentphoto_tn.$ext";               $url="/uploaded/$udom/$unam/internal/studentphoto_tn.$ext"; 
         }          }
         my $tokenurl=&Apache::lonnet::tokenwrapper($url);          my $tokenurl=&tokenwrapper($url);
         return $tokenurl;          return $tokenurl;
     } else {      } else {
         if ($type eq 'thumbnail') {          if ($type eq 'thumbnail') {
Line 3671  sub ssi { Line 3671  sub ssi {
         ($form{'grade_courseid'} eq $env{'request.course.id'}) &&          ($form{'grade_courseid'} eq $env{'request.course.id'}) &&
         ($form{'grade_username'} ne '') && ($form{'grade_domain'} ne '') &&          ($form{'grade_username'} ne '') && ($form{'grade_domain'} ne '') &&
         ($form{'grade_symb'} ne '') &&          ($form{'grade_symb'} ne '') &&
         (&Apache::lonnet::allowed('mgr',$env{'request.course.id'}.          (&allowed('mgr',$env{'request.course.id'}.
                                  ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')))) {                          ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')))) {
         $islocal = 1;          $islocal = 1;
     }      }
     $response= &LONCAPA::LWPReq::makerequest($lonhost,$request,'',\%perlvar,      $response= &LONCAPA::LWPReq::makerequest($lonhost,$request,'',\%perlvar,
Line 3823  sub can_edit_resource { Line 3823  sub can_edit_resource {
     }      }
   
     if ($env{'request.course.id'}) {      if ($env{'request.course.id'}) {
         my $crsedit = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});          my $crsedit = &allowed('mdc',$env{'request.course.id'});
         if ($group ne '') {          if ($group ne '') {
 # if this is a group homepage or group bulletin board, check group privs  # if this is a group homepage or group bulletin board, check group privs
             my $allowed = 0;              my $allowed = 0;
Line 3852  sub can_edit_resource { Line 3852  sub can_edit_resource {
             }              }
         } else {          } else {
             if ($resurl =~ m{^/?adm/viewclasslist$}) {              if ($resurl =~ m{^/?adm/viewclasslist$}) {
                 unless (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {                  unless (&allowed('opa',$env{'request.course.id'})) {
                     return;                      return;
                 }                  }
             } elsif (!$crsedit) {              } elsif (!$crsedit) {
Line 5134  sub flushcourselogs { Line 5134  sub flushcourselogs {
     foreach my $entry (keys(%userrolehash)) {      foreach my $entry (keys(%userrolehash)) {
         my ($role,$uname,$udom,$runame,$rudom,$rsec)=          my ($role,$uname,$udom,$runame,$rudom,$rsec)=
     split(/\:/,$entry);      split(/\:/,$entry);
         if (&Apache::lonnet::put('nohist_userroles',          if (&put('nohist_userroles',
              { $role.':'.$uname.':'.$udom.':'.$rsec => $userrolehash{$entry} },               { $role.':'.$uname.':'.$udom.':'.$rsec => $userrolehash{$entry} },
                 $rudom,$runame) eq 'ok') {                  $rudom,$runame) eq 'ok') {
     delete $userrolehash{$entry};      delete $userrolehash{$entry};
Line 5333  sub domainrolelog { Line 5333  sub domainrolelog {
     my ($trole,$username,$domain,$area,$tstart,$tend,$delflag,$context)=@_;      my ($trole,$username,$domain,$area,$tstart,$tend,$delflag,$context)=@_;
     if ($area =~ m{^/($match_domain)/$}) {      if ($area =~ m{^/($match_domain)/$}) {
         my $cdom = $1;          my $cdom = $1;
         my $domconfiguser = &Apache::lonnet::get_domainconfiguser($cdom);          my $domconfiguser = &get_domainconfiguser($cdom);
         my $namespace = 'rolelog';          my $namespace = 'rolelog';
         my %storehash = (          my %storehash = (
                            role    => $trole,                             role    => $trole,
Line 5564  sub get_my_adhocroles { Line 5564  sub get_my_adhocroles {
     } elsif ($cid =~ /^($match_domain)_($match_courseid)$/) {      } elsif ($cid =~ /^($match_domain)_($match_courseid)$/) {
         $cdom = $1;          $cdom = $1;
         $cnum = $2;          $cnum = $2;
         %info = &Apache::lonnet::get('environment',['internal.coursecode'],          %info = &get('environment',['internal.coursecode'],
                                      $cdom,$cnum);                       $cdom,$cnum);
     }      }
     if (($info{'internal.coursecode'} ne '') && ($checkreg)) {      if (($info{'internal.coursecode'} ne '') && ($checkreg)) {
         my $user = $env{'user.name'}.':'.$env{'user.domain'};          my $user = $env{'user.name'}.':'.$env{'user.domain'};
Line 5892  sub extract_lastaccess { Line 5892  sub extract_lastaccess {
   
 sub dcmailput {  sub dcmailput {
     my ($domain,$msgid,$message,$server)=@_;      my ($domain,$msgid,$message,$server)=@_;
     my $status = &Apache::lonnet::critical(      my $status = &critical(
        'dcmailput:'.$domain.':'.&escape($msgid).'='.         'dcmailput:'.$domain.':'.&escape($msgid).'='.
        &escape($message),$server);         &escape($message),$server);
     return $status;      return $status;
Line 7485  sub putstore { Line 7485  sub putstore {
                      '&host='.&escape($perlvar{'lonHostID'}).                       '&host='.&escape($perlvar{'lonHostID'}).
                      '&version='.$esc_v.                       '&version='.$esc_v.
                      '&by='.&escape($env{'user.name'}.':'.$env{'user.domain'});                       '&by='.&escape($env{'user.name'}.':'.$env{'user.domain'});
        &Apache::lonnet::courselog($symb.':'.$uname.':'.$udomain.':PUTSTORE:'.$namevalue);         &courselog($symb.':'.$uname.':'.$udomain.':PUTSTORE:'.$namevalue);
    }     }
    if ($reply eq 'unknown_cmd') {     if ($reply eq 'unknown_cmd') {
        # gfall back to way things use to be done         # gfall back to way things use to be done
Line 7635  sub get_timebased_id { Line 7635  sub get_timebased_id {
     my $tries = 0;      my $tries = 0;
   
 # attempt to get lock on nohist_$namespace file  # attempt to get lock on nohist_$namespace file
     my $gotlock = &Apache::lonnet::newput('nohist_'.$namespace,$lockhash,$cdom,$cnum);      my $gotlock = &newput('nohist_'.$namespace,$lockhash,$cdom,$cnum);
     while (($gotlock ne 'ok') && $tries <$locktries) {      while (($gotlock ne 'ok') && $tries <$locktries) {
         $tries ++;          $tries ++;
         sleep 1;          sleep 1;
         $gotlock = &Apache::lonnet::newput('nohist_'.$namespace,$lockhash,$cdom,$cnum);          $gotlock = &newput('nohist_'.$namespace,$lockhash,$cdom,$cnum);
     }      }
   
 # attempt to get unique identifier, based on current timestamp  # attempt to get unique identifier, based on current timestamp
     if ($gotlock eq 'ok') {      if ($gotlock eq 'ok') {
         my %inuse = &Apache::lonnet::dump('nohist_'.$namespace,$cdom,$cnum,$prefix);          my %inuse = &dump('nohist_'.$namespace,$cdom,$cnum,$prefix);
         my $id = time;          my $id = time;
         $newid = $id;          $newid = $id;
         if ($idtype eq 'addcode') {          if ($idtype eq 'addcode') {
Line 7665  sub get_timebased_id { Line 7665  sub get_timebased_id {
             my %new_item =  (              my %new_item =  (
                               $prefix."\0".$newid => $who,                                $prefix."\0".$newid => $who,
                             );                              );
             my $putresult = &Apache::lonnet::put('nohist_'.$namespace,\%new_item,              my $putresult = &put('nohist_'.$namespace,\%new_item,
                                                  $cdom,$cnum);                                                   $cdom,$cnum);
             if ($putresult ne 'ok') {              if ($putresult ne 'ok') {
                 undef($newid);                  undef($newid);
Line 8104  sub is_course_owner { Line 8104  sub is_course_owner {
             if ($env{'course.'.$cdom.'_'.$cnum.'.internal.courseowner'} eq $uname.':'.$udom) {              if ($env{'course.'.$cdom.'_'.$cnum.'.internal.courseowner'} eq $uname.':'.$udom) {
                 return 1;                  return 1;
             } else {              } else {
                 my %courseinfo = &Apache::lonnet::coursedescription($cdom.'/'.$cnum);                  my %courseinfo = &coursedescription($cdom.'/'.$cnum);
                 if ($courseinfo{'internal.courseowner'} eq $uname.':'.$udom) {                  if ($courseinfo{'internal.courseowner'} eq $uname.':'.$udom) {
                     return 1;                      return 1;
                 }                  }
Line 8996  sub get_comm_blocks { Line 8996  sub get_comm_blocks {
     if ((defined($cached)) && (ref($blocksref) eq 'HASH')) {      if ((defined($cached)) && (ref($blocksref) eq 'HASH')) {
         %commblocks = %{$blocksref};          %commblocks = %{$blocksref};
     } else {      } else {
         %commblocks = &Apache::lonnet::dump('comm_block',$cdom,$cnum);          %commblocks = &dump('comm_block',$cdom,$cnum);
         my $cachetime = 600;          my $cachetime = 600;
         &do_cache_new('comm_block',$hashid,\%commblocks,$cachetime);          &do_cache_new('comm_block',$hashid,\%commblocks,$cachetime);
     }      }
Line 10622  sub store_coowners { Line 10622  sub store_coowners {
     }      }
     if (($putresult eq 'ok') || ($delresult eq 'ok')) {      if (($putresult eq 'ok') || ($delresult eq 'ok')) {
         my %crsinfo =          my %crsinfo =
             &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,undef,undef,'.');              &courseiddump($cdom,'.',1,'.','.',$cnum,undef,undef,'.');
         if (ref($crsinfo{$cid}) eq 'HASH') {          if (ref($crsinfo{$cid}) eq 'HASH') {
             $crsinfo{$cid}{'co-owners'} = \@newcoowners;              $crsinfo{$cid}{'co-owners'} = \@newcoowners;
             my $cidput = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');              my $cidput = &courseidput($cdom,\%crsinfo,$chome,'notime');
         }          }
     }      }
 }  }
Line 10843  sub modifyuser { Line 10843  sub modifyuser {
         return 'error: '.$reply;          return 'error: '.$reply;
     }      }
     if ($names{'permanentemail'} ne $oldnames{'permanentemail'}) {      if ($names{'permanentemail'} ne $oldnames{'permanentemail'}) {
         &Apache::lonnet::devalidate_cache_new('emailscache',$uname.':'.$udom);          &devalidate_cache_new('emailscache',$uname.':'.$udom);
     }      }
     my $sqlresult = &update_allusers_table($uname,$udom,\%names);      my $sqlresult = &update_allusers_table($uname,$udom,\%names);
     &devalidate_cache_new('namescache',$uname.':'.$udom);      &devalidate_cache_new('namescache',$uname.':'.$udom);
Line 10923  sub modify_student_enrollment { Line 10923  sub modify_student_enrollment {
     }      }
     my $fullname = &format_name($first,$middle,$last,$gene,'lastname');      my $fullname = &format_name($first,$middle,$last,$gene,'lastname');
     my $user = "$uname:$udom";      my $user = "$uname:$udom";
     my %old_entry = &Apache::lonnet::get('classlist',[$user],$cdom,$cnum);      my %old_entry = &get('classlist',[$user],$cdom,$cnum);
     my $reply=cput('classlist',      my $reply=cput('classlist',
    {$user =>      {$user => 
  join(':',$end,$start,$uid,$usec,$fullname,$type,$locktype,$credits,$instsec) },   join(':',$end,$start,$uid,$usec,$fullname,$type,$locktype,$credits,$instsec) },
Line 11057  sub createcourse { Line 11057  sub createcourse {
         }          }
     }      }
     my %host_servers =      my %host_servers =
         &Apache::lonnet::get_servers($udom,'library');          &get_servers($udom,'library');
     unless ($host_servers{$course_server}) {      unless ($host_servers{$course_server}) {
         return 'error: invalid home server for course: '.$course_server;          return 'error: invalid home server for course: '.$course_server;
     }      }
Line 13551  sub get_reservable_slots { Line 13551  sub get_reservable_slots {
 sub get_course_slots {  sub get_course_slots {
     my ($cnum,$cdom) = @_;      my ($cnum,$cdom) = @_;
     my $hashid=$cnum.':'.$cdom;      my $hashid=$cnum.':'.$cdom;
     my ($result,$cached) = &Apache::lonnet::is_cached_new('allslots',$hashid);      my ($result,$cached) = &is_cached_new('allslots',$hashid);
     if (defined($cached)) {      if (defined($cached)) {
         if (ref($result) eq 'HASH') {          if (ref($result) eq 'HASH') {
             return %{$result};              return %{$result};
         }          }
     } else {      } else {
         my %slots=&Apache::lonnet::dump('slots',$cdom,$cnum);          my %slots=&dump('slots',$cdom,$cnum);
         my ($tmp) = keys(%slots);          my ($tmp) = keys(%slots);
         if ($tmp !~ /^(con_lost|error|no_such_host)/i) {          if ($tmp !~ /^(con_lost|error|no_such_host)/i) {
             &do_cache_new('allslots',$hashid,\%slots,600);              &do_cache_new('allslots',$hashid,\%slots,600);
Line 14771  sub get_requestor_ip { Line 14771  sub get_requestor_ip {
   
 sub get_proxy_settings {  sub get_proxy_settings {
     my ($dom_in_use) = @_;      my ($dom_in_use) = @_;
     my %domdefaults = &Apache::lonnet::get_domain_defaults($dom_in_use);      my %domdefaults = &get_domain_defaults($dom_in_use);
     my $proxyinfo = {      my $proxyinfo = {
                        ipheader => $domdefaults{'waf_ipheader'},                         ipheader => $domdefaults{'waf_ipheader'},
                        trusted  => $domdefaults{'waf_trusted'},                         trusted  => $domdefaults{'waf_trusted'},
Line 14804  sub get_proxy_alias { Line 14804  sub get_proxy_alias {
         if ($cached) {          if ($cached) {
             return $alias;              return $alias;
         }          }
         my $dom = &Apache::lonnet::host_domain($lonid);          my $dom = &host_domain($lonid);
         if ($dom ne '') {          if ($dom ne '') {
             my $cachetime = 60*60*24;              my $cachetime = 60*60*24;
             my %domconfig =              my %domconfig =
                 &Apache::lonnet::get_dom('configuration',['wafproxy'],$dom);                  &get_dom('configuration',['wafproxy'],$dom);
             if (ref($domconfig{'wafproxy'}) eq 'HASH') {              if (ref($domconfig{'wafproxy'}) eq 'HASH') {
                 if (ref($domconfig{'wafproxy'}{'alias'}) eq 'HASH') {                  if (ref($domconfig{'wafproxy'}{'alias'}) eq 'HASH') {
                     $alias = $domconfig{'wafproxy'}{'alias'}{$lonid};                      $alias = $domconfig{'wafproxy'}{'alias'}{$lonid};
Line 14855  sub alias_sso { Line 14855  sub alias_sso {
         if ($cached) {          if ($cached) {
             return $use_alias;              return $use_alias;
         }          }
         my $dom = &Apache::lonnet::host_domain($lonid);          my $dom = &host_domain($lonid);
         if ($dom ne '') {          if ($dom ne '') {
             my $cachetime = 60*60*24;              my $cachetime = 60*60*24;
             my %domconfig =              my %domconfig =
                 &Apache::lonnet::get_dom('configuration',['wafproxy'],$dom);                  &get_dom('configuration',['wafproxy'],$dom);
             if (ref($domconfig{'wafproxy'}) eq 'HASH') {              if (ref($domconfig{'wafproxy'}) eq 'HASH') {
                 if (ref($domconfig{'wafproxy'}{'saml'}) eq 'HASH') {                  if (ref($domconfig{'wafproxy'}{'saml'}) eq 'HASH') {
                     $use_alias = $domconfig{'wafproxy'}{'saml'}{$lonid};                      $use_alias = $domconfig{'wafproxy'}{'saml'}{$lonid};
Line 14887  sub get_saml_landing { Line 14887  sub get_saml_landing {
             $lonid = $perlvar{'lonHostID'};              $lonid = $perlvar{'lonHostID'};
         }          }
         if ($lonid) {          if ($lonid) {
             unless (&Apache::lonnet::host_domain($lonid) eq $defdom) {              unless (&host_domain($lonid) eq $defdom) {
                 return;                  return;
             }              }
         } else {          } else {
Line 14900  sub get_saml_landing { Line 14900  sub get_saml_landing {
     if ($cached) {      if ($cached) {
         return $landing;          return $landing;
     }      }
     my $dom = &Apache::lonnet::host_domain($lonid);      my $dom = &host_domain($lonid);
     if ($dom ne '') {      if ($dom ne '') {
         my $cachetime = 60*60*24;          my $cachetime = 60*60*24;
         my %domconfig =          my %domconfig =
             &Apache::lonnet::get_dom('configuration',['login'],$dom);              &get_dom('configuration',['login'],$dom);
         if (ref($domconfig{'login'}) eq 'HASH') {          if (ref($domconfig{'login'}) eq 'HASH') {
             if (ref($domconfig{'login'}{'saml'}) eq 'HASH') {              if (ref($domconfig{'login'}{'saml'}) eq 'HASH') {
                 if (ref($domconfig{'login'}{'saml'}{$lonid}) eq 'HASH') {                  if (ref($domconfig{'login'}{'saml'}{$lonid}) eq 'HASH') {
Line 15034  sub get_dns { Line 15034  sub get_dns {
     my ($url,$func,$ignore_cache,$nocache,$hashref) = @_;      my ($url,$func,$ignore_cache,$nocache,$hashref) = @_;
     if (!$ignore_cache) {      if (!$ignore_cache) {
  my ($content,$cached)=   my ($content,$cached)=
     &Apache::lonnet::is_cached_new('dns',$url);      &is_cached_new('dns',$url);
  if ($cached) {   if ($cached) {
     &$func($content,$hashref);      &$func($content,$hashref);
     return;      return;
Line 15113  sub get_dns { Line 15113  sub get_dns {
 sub parse_dns_checksums_tab {  sub parse_dns_checksums_tab {
     my ($lines,$hashref) = @_;      my ($lines,$hashref) = @_;
     my $lonhost = $perlvar{'lonHostID'};      my $lonhost = $perlvar{'lonHostID'};
     my $machine_dom = &Apache::lonnet::host_domain($lonhost);      my $machine_dom = &host_domain($lonhost);
     my $loncaparev = &get_server_loncaparev($machine_dom);      my $loncaparev = &get_server_loncaparev($machine_dom);
     my $distro = (split(/\:/,&get_server_distarch($lonhost)))[0];      my $distro = (split(/\:/,&get_server_distarch($lonhost)))[0];
     my $webconfdir = '/etc/httpd/conf';      my $webconfdir = '/etc/httpd/conf';
Line 15157  sub parse_dns_checksums_tab { Line 15157  sub parse_dns_checksums_tab {
   
 sub fetch_dns_checksums {  sub fetch_dns_checksums {
     my %checksums;      my %checksums;
     my $machine_dom = &Apache::lonnet::host_domain($perlvar{'lonHostID'});      my $machine_dom = &host_domain($perlvar{'lonHostID'});
     my $loncaparev = &get_server_loncaparev($machine_dom,$perlvar{'lonHostID'});      my $loncaparev = &get_server_loncaparev($machine_dom,$perlvar{'lonHostID'});
     my ($release,$timestamp) = split(/\-/,$loncaparev);      my ($release,$timestamp) = split(/\-/,$loncaparev);
     &get_dns("/adm/dns/checksums/$release",\&parse_dns_checksums_tab,1,1,      &get_dns("/adm/dns/checksums/$release",\&parse_dns_checksums_tab,1,1,
Line 15545  sub parse_getdns_url { Line 15545  sub parse_getdns_url {
  return %iphost;   return %iphost;
     }      }
     my ($ip_info,$cached)=      my ($ip_info,$cached)=
  &Apache::lonnet::is_cached_new('iphost','iphost');   &is_cached_new('iphost','iphost');
     if ($cached) {      if ($cached) {
  %iphost      = %{$ip_info->[0]};   %iphost      = %{$ip_info->[0]};
  %name_to_ip  = %{$ip_info->[1]};   %name_to_ip  = %{$ip_info->[1]};
Line 15557  sub parse_getdns_url { Line 15557  sub parse_getdns_url {
  # get yesterday's info for fallback   # get yesterday's info for fallback
  my %old_name_to_ip;   my %old_name_to_ip;
  my ($ip_info,$cached)=   my ($ip_info,$cached)=
     &Apache::lonnet::is_cached_new('iphost','iphost');      &s_cached_new('iphost','iphost');
  if ($cached) {   if ($cached) {
     %old_name_to_ip = %{$ip_info->[1]};      %old_name_to_ip = %{$ip_info->[1]};
  }   }
Line 15624  sub parse_getdns_url { Line 15624  sub parse_getdns_url {
         my ($lonid) = @_;          my ($lonid) = @_;
         return if ($lonid eq '');          return if ($lonid eq '');
         my ($idnref,$cached)=          my ($idnref,$cached)=
             &Apache::lonnet::is_cached_new('internetnames',$lonid);              &is_cached_new('internetnames',$lonid);
         if ($cached) {          if ($cached) {
             return $idnref;              return $idnref;
         }          }

Removed from v.1.1493  
changed lines
  Added in v.1.1494


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