Diff for /loncom/interface/loncoursequeueadmin.pm between versions 1.63 and 1.64

version 1.63, 2022/11/23 02:55:37 version 1.64, 2022/12/01 01:28:26
Line 295  sub send_selfserve_notification { Line 295  sub send_selfserve_notification {
  -> Queued Role Assignments (this domain) [_3]to display a list of pending requests, which you can either approve or reject.',   -> Queued Role Assignments (this domain) [_3]to display a list of pending requests, which you can either approve or reject.',
                       args => ["\n","\n\n  ","\n\n"],                        args => ["\n","\n\n  ","\n\n"],
                      });                       });
       } elsif ($context eq 'othdombydc') {
           $rawsubj = 'Status of Role Assignment Requests';
           push(@rawmsg,{
                         mt =>'A Domain Coordinator in a domain different to your own LON-CAPA domain '.
                              'has taken action on queued role assignment(s) in this domain for user(s) from that other domain ([_1])',
                         args => ["\n$contextdesc\n"],
                         });
     }      }
     my @to_notify = split(/,/,$notifylist);      my @to_notify = split(/,/,$notifylist);
     my $numsent = 0;      my $numsent = 0;
Line 383  sub send_selfserve_notification { Line 390  sub send_selfserve_notification {
             if ($rejectedlist) {              if ($rejectedlist) {
                 $message .= "\n\n".&mt_user($sender_lh,'Rejected LON-CAPA account requests:')."\n".$rejectedlist;                  $message .= "\n\n".&mt_user($sender_lh,'Rejected LON-CAPA account requests:')."\n".$rejectedlist;
             }              }
           } elsif ($context eq 'othdombydc') {
               if ($approvedlist) {
                   $message .= "\n\n".&mt_user($sender_lh,'Approved LON-CAPA role assignments:')."\n".$approvedlist;
               }
               if ($rejectedlist) {
                   $message .= "\n\n".&mt_user($sender_lh,'Rejected LON-CAPA role assignments:')."\n".$rejectedlist;
               }
         }          }
         $status .= &Apache::lonmsg::user_normal_msg($ccname,$ccdom,$subject,$message,undef,undef,undef,1,          $status .= &Apache::lonmsg::user_normal_msg($ccname,$ccdom,$subject,$message,undef,undef,undef,1,
                                                     \%sentmessage,undef,undef,undef,1,$recipid).',';                                                      \%sentmessage,undef,undef,undef,1,$recipid).',';
Line 415  sub display_queued_requests { Line 429  sub display_queued_requests {
         $nextelement = '<input type="hidden" name="state" value="done" />';          $nextelement = '<input type="hidden" name="state" value="done" />';
     } elsif ($context eq 'othdomqueue') {      } elsif ($context eq 'othdomqueue') {
         $formaction = '/adm/createuser';          $formaction = '/adm/createuser';
         $namespace = 'othdomqueued';          $namespace = 'nohist_othdomqueued';
         if ($secondary eq 'domain') {          if ($secondary eq 'domain') {
             %requesthash = &Apache::lonnet::dump_dom($namespace,$dom);              %requesthash = &Apache::lonnet::dump_dom($namespace,$dom);
             foreach my $key (keys(%requesthash)) {              foreach my $key (keys(%requesthash)) {
Line 433  sub display_queued_requests { Line 447  sub display_queued_requests {
         }          }
     } elsif ($context eq 'othdomaction') {      } elsif ($context eq 'othdomaction') {
         $formaction = '/adm/createuser';          $formaction = '/adm/createuser';
         $namespace = 'queuedrolereqs';          $namespace = 'nohist_queuedrolereqs';
         if ($secondary eq 'domain') {          if ($secondary eq 'domain') {
             my $confname = &Apache::lonnet::get_domainconfiguser($dom);              my $confname = &Apache::lonnet::get_domainconfiguser($dom);
             %requesthash = &Apache::lonnet::dump($namespace,$dom,$confname);              %requesthash = &Apache::lonnet::dump($namespace,$dom,$confname);
Line 457  sub display_queued_requests { Line 471  sub display_queued_requests {
     }      }
     my ($output,%queue_by_date);      my ($output,%queue_by_date);
     if (keys(%requesthash) > 0) {      if (keys(%requesthash) > 0) {
         $output = '<form method="post" name="changequeue" action="'.$formaction.'" />'."\n".  
                   '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".  
                   $nextelement."\n";  
         foreach my $item (keys(%requesthash)) {          foreach my $item (keys(%requesthash)) {
             my ($timestamp,$entry,$pending);              my ($timestamp,$entry,$pending);
             if ($context eq 'course') {              if ($context eq 'course') {
Line 473  sub display_queued_requests { Line 484  sub display_queued_requests {
                 ($entry) = (&unescape($item) =~ /^($match_username)_approval$/);                  ($entry) = (&unescape($item) =~ /^($match_username)_approval$/);
             } elsif ($context eq 'othdomqueue') {              } elsif ($context eq 'othdomqueue') {
                 if (ref($requesthash{$item}) eq 'HASH') {                  if (ref($requesthash{$item}) eq 'HASH') {
                       next unless ($requesthash{'status&'.$item} eq 'pending');
                     my ($puname,$pudom,$prole,$psec) = split(/:/,$item);                      my ($puname,$pudom,$prole,$psec) = split(/:/,$item);
                     $timestamp = $requesthash{$item}{'timestamp'};                      $timestamp = $requesthash{$item}{'timestamp'};
                     my $adj = $requesthash{$item}{'adj'};                      my $adj = $requesthash{$item}{'adj'};
Line 481  sub display_queued_requests { Line 493  sub display_queued_requests {
                                       $psec);                                        $psec);
                 }                  }
             } elsif ($context eq 'othdomaction') {              } elsif ($context eq 'othdomaction') {
                  next unless ($item =~ /^pending:/);
                if (ref($requesthash{$item}) eq 'HASH') {                 if (ref($requesthash{$item}) eq 'HASH') {
                    $timestamp = $requesthash{$item}{'timestamp'};                     $timestamp = $requesthash{$item}{'timestamp'};
                    $entry = &escape($item).':'.&escape($requesthash{$item}{'requester'});                     $entry = &escape($item).':'.&escape($requesthash{$item}{'requester'});
Line 507  sub display_queued_requests { Line 520  sub display_queued_requests {
                 }                  }
             }              }
         }          }
         if (keys(%queue_by_date) > 0) {      }
             if ($context eq 'course') {      if (keys(%queue_by_date) > 0) {
                 $output .=  '<h3>'.&mt('Self-enrollment requests queued pending approval by a Coordinator').'</h3>';          $output = '<form method="post" name="changequeue" action="'.$formaction.'" />'."\n".
             } elsif (($context eq 'pending') || ($context eq 'displaypending')) {                    '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".
                 $output .= '<h3>'.&mt('Requests for official courses queued pending validation').'</h3>'.                    $nextelement."\n";
                            '<p>'.&mt('Requests are validated against institutional data to confirm that the requestor is an instructor of record.').'<br />'.          if ($context eq 'course') {
                            &mt('Validation is attempted when the request is submitted.').' '.              $output .=  '<h3>'.&mt('Self-enrollment requests queued pending approval by a Coordinator').'</h3>';
                            &mt('If unvalidated, the request will be held in a queue.').' '.          } elsif (($context eq 'pending') || ($context eq 'displaypending')) {
                            &mt('Validation of pending requests is automatically repeated daily.').'</p>';              $output .= '<h3>'.&mt('Requests for official courses queued pending validation').'</h3>'.
             } elsif ($context eq 'requestauthor') {                         '<p>'.&mt('Requests are validated against institutional data to confirm that the requestor is an instructor of record.').'<br />'.
                 $output .= '<h3>'.&mt('Requests for Authoring Space queued pending approval by a Domain Coordinator').'</h3>';                         &mt('Validation is attempted when the request is submitted.').' '.
             } elsif ($context eq 'requestusername') {                         &mt('If unvalidated, the request will be held in a queue.').' '.
                 $output .= '<h3>'.&mt('Requests for LON-CAPA accounts queued pending approval by a Domain Coordinator').'</h3>';                         &mt('Validation of pending requests is automatically repeated daily.').'</p>';
             } elsif ($context eq 'othdomqueue') {          } elsif ($context eq 'requestauthor') {
                 if ($secondary eq 'domain') {              $output .= '<h3>'.&mt('Requests for Authoring Space queued pending approval by a Domain Coordinator').'</h3>';
                     $output .= '<h3>'.&mt('Domain role assignments for users from another domain, queued pending approval').'</h3>';          } elsif ($context eq 'requestusername') {
                 } elsif ($secondary eq 'author') {              $output .= '<h3>'.&mt('Requests for LON-CAPA accounts queued pending approval by a Domain Coordinator').'</h3>';
                     $output .= '<h3>'.&mt('Co-author role assignments for users from another domain, queued pending approval').'</h3>';          } elsif ($context eq 'othdomqueue') {
                 } elsif ($secondary eq 'course') {              if ($secondary eq 'domain') {
                     $output .= '<h3>'.&mt('Course role assignments for users from another domain, queued pending approval').'</h3>';                  $output .= '<h3>'.&mt('Domain role assignments for users from another domain, queued pending approval').'</h3>';
                 } elsif ($secondary eq 'community') {              } elsif ($secondary eq 'author') {
                     $output .= '<h3>'.&mt('Community role assignments for users from another domain, queued pending approval').'</h3>';                  $output .= '<h3>'.&mt('Co-author role assignments for users from another domain, queued pending approval').'</h3>';
                 }              } elsif ($secondary eq 'course') {
             } elsif ($context eq 'othdomaction') {                  $output .= '<h3>'.&mt('Course role assignments for users from another domain, queued pending approval').'</h3>';
                 if ($secondary eq 'user') {              } elsif ($secondary eq 'community') {
                     $output .= '<h3>'.&mt('Role assignments for you in other domains, queued pending your acceptance of the role.').'</h3>';                  $output .= '<h3>'.&mt('Community role assignments for users from another domain, queued pending approval').'</h3>';
                 } elsif ($secondary eq 'domain') {  
                     $output .= '<h3>'.&mt('Role assignments in other domains, queued pending domain coordinator approval in this domain.').'</h3>';  
                 }  
             } else {  
                 $output .= '<h3>'.&mt('Course/Community requests queued pending approval by a Domain Coordinator').'</h3>';  
             }   
             $output .= &build_queue_display($dom,$context,\%queue_by_date,$secondary).  
                        '<input type="hidden" name="queue" value="approval" />';  
         } else {  
             $output .= '<div class="LC_info">';  
             if ($context eq 'course') {  
                 $output .= &mt('There are currently no enrollment requests awaiting approval.');  
             } elsif ($context eq 'pending') {  
                 $output .= &mt('There are currently no requests for official courses awaiting validation.');  
             } elsif ($context eq 'requestauthor') {  
                 $output .= &mt('There are currently no requests for Authoring Space awaiting approval.');  
             } elsif ($context eq 'requestusername') {  
                 $output .= &mt('There are currently no requests for LON-CAPA accounts awaiting approval.');  
             } elsif ($context eq 'domain') {  
                 $output .= &mt('There are currently no course or community requests awaiting approval.');  
             } elsif ($context eq 'othdomqueue') {  
                 if ($secondary eq 'domain') {  
                     $output .= &mt('There are currently no domain role assignment(s) for user(s) from another domain queued pending approval');  
                 } elsif ($secondary eq 'author') {  
                     $output .= &mt('There are currently no co-author role assignment(s) for user(s) from another domain queued pending approval');  
                 } elsif ($secondary eq 'course') {  
                     $output .= &mt('There are currently no course role assignment(s) for user(s) from another domain queued pending approval');  
                 } elsif ($secondary eq 'community') {  
                     $output .= &mt('There are currently no community role assignment(s) for user(s) from another domain queued pending approval');  
                 }  
             } elsif ($context eq 'othdomaction') {  
                 if ($secondary eq 'user') {  
                     $output .= &mt('There are currently no pending role assignments for you in other domains, queued pending your acceptance of the role.');  
                 } elsif ($secondary eq 'domain') {  
                     $output .= &mt('There are currently no pending role assignments in other domains, queued pending domain coordinator approval in this domain.');  
                 }  
             }              }
             $output .= '</div>';          } elsif ($context eq 'othdomaction') {
         }              if ($secondary eq 'user') {
                   $output .= '<h3>'.&mt('Role assignments for you in other domains, queued pending your acceptance of the role.').'</h3>';
               } elsif ($secondary eq 'domain') {
                   $output .= '<h3>'.&mt('Role assignments in other domains, queued pending domain coordinator approval in this domain.').'</h3>';
               }
           } else {
               $output .= '<h3>'.&mt('Course/Community requests queued pending approval by a Domain Coordinator').'</h3>';
           } 
           $output .= &build_queue_display($dom,$context,\%queue_by_date,$secondary).
                      '<input type="hidden" name="queue" value="approval" />';
         if ($context eq 'pending') {          if ($context eq 'pending') {
             $output .= '<br /><input type="submit" name="validationcheck" value="'.              $output .= '<br /><input type="submit" name="validationcheck" value="'.
                        &mt('Validate').'" /><br />'."\n".                         &mt('Validate').'" /><br />'."\n".
Line 618  sub display_queued_requests { Line 604  sub display_queued_requests {
 sub build_queue_display {  sub build_queue_display {
     my ($dom,$context,$queue,$secondary) = @_;      my ($dom,$context,$queue,$secondary) = @_;
     return unless (ref($queue) eq 'HASH');      return unless (ref($queue) eq 'HASH');
     my (%crstypes,%roles_by_context);      my (%crstypes,%roles_by_context,$output);
     my $output = &Apache::loncommon::start_data_table().      if ($context eq 'othdomqueue') {
                  &Apache::loncommon::start_data_table_header_row();          $output = &print_filter_menu($context);
       }
       $output .= &Apache::loncommon::start_data_table().
                  &Apache::loncommon::start_data_table_header_row();
     unless (($context eq 'pending') || ($context eq 'displaypending') ||       unless (($context eq 'pending') || ($context eq 'displaypending') || 
             ($context eq 'helpdesk') || ($context eq 'othdomqueue')) {              ($context eq 'helpdesk') || ($context eq 'othdomqueue')) {
         $output .= '<th>'.&mt('Action').'</th>';          $output .= '<th>'.&mt('Action').'</th>';
Line 729  sub build_queue_display { Line 718  sub build_queue_display {
                         }                          }
                     }                      }
                 } elsif ($context eq 'othdomaction') {                  } elsif ($context eq 'othdomaction') {
                     my ($extent,$role,$crstype);                      my ($status,$extent,$role,$crstype);
                     my ($info,$requester) = map { &unescape($_); } split(/:/,$request);                      my ($info,$requester) = map { &unescape($_); } split(/:/,$request);
                     if ($secondary eq 'user') {                      if ($secondary eq 'user') {
                         ($extent,$role) = split(/:/,$info);                          ($status,$extent,$role) = split(/:/,$info);
                         $approve = $count.':'.$extent.':'.$role;                          $approve = $count.':'.$extent.':'.$role;
                         $reject = $extent.':'.$role;                          $reject = $extent.':'.$role;
                     } elsif ($secondary eq 'domain') {                      } elsif ($secondary eq 'domain') {
                         (my $uname,$extent,$role) = split(/:/,$info);                          ($status,my $uname,$extent,$role) = split(/:/,$info);
                         $approve = $count.':'.$extent.':'.$role.':'.$uname.':'.$dom;                          $approve = $count.':'.$extent.':'.$role.':'.$uname.':'.$dom;
                         $reject = $extent.':'.$role.':'.$uname.':'.$dom;                          $reject = $extent.':'.$role.':'.$uname.':'.$dom;
                         unless (&Apache::lonnet::homeserver($uname,$dom) eq 'no_host') {                          unless (&Apache::lonnet::homeserver($uname,$dom) eq 'no_host') {
Line 765  sub build_queue_display { Line 754  sub build_queue_display {
                             $crstype = $info{'type'};                              $crstype = $info{'type'};
                             $location = &mt($crstype).': '.$info{'description'};                              $location = &mt($crstype).': '.$info{'description'};
                             if ($csec ne '') {                              if ($csec ne '') {
                                 $location .= ' '.&mt('Section').': '.$csec;                                  $location .= '<br />'.&mt('Section').': '.$csec;
                             }                              }
                         }                          }
                     } else {                      } else {
Line 778  sub build_queue_display { Line 767  sub build_queue_display {
                                         $crstype = $info{'type'};                                          $crstype = $info{'type'};
                                         $location = &mt($crstype).': '.$info{'description'};                                          $location = &mt($crstype).': '.$info{'description'};
                                         if ($csec ne '') {                                          if ($csec ne '') {
                                             $location .= ' '.&mt('Section').': '.$csec;                                              $location .= '<br />'.&mt('Section').': '.$csec;
                                         }                                          }
                                     }                                      }
                                 } else {                                  } else {
Line 885  sub build_queue_display { Line 874  sub build_queue_display {
     return $output;      return $output;
 }  }
   
   sub print_filter_menu {
       my ($context) = @_;
       return;
   }
   
 sub update_request_queue {  sub update_request_queue {
     my ($context,$cdom,$cnum,$coursedesc) = @_;      my ($context,$cdom,$cnum,$coursedesc) = @_;
     my ($output,$access_start,$access_end,$limit,$cap,$notifylist,$namespace,      my ($output,$access_start,$access_end,$limit,$cap,$notifylist,$namespace,
Line 895  sub update_request_queue { Line 889  sub update_request_queue {
         @rejections,@rejectionerrors,@nopermissions,%courseroles,@toremove,          @rejections,@rejectionerrors,@nopermissions,%courseroles,@toremove,
         %communityroles,%domdefs,%approvalmsg,%rejectionmsg,$crstype,$queue,          %communityroles,%domdefs,%approvalmsg,%rejectionmsg,$crstype,$queue,
         $firsturl,$uniquecode,%codes,%roles_by_context,%requesteractive,          $firsturl,$uniquecode,%codes,%roles_by_context,%requesteractive,
         %gotroles);          %gotroles,$confname,%requestedby,@rejectedreqs,$dbname);
     my $count=0;      my $count=0;
     while (my $item = $env{'form.'.$count.'radioreq'}) {      while (my $item = $env{'form.'.$count.'radioreq'}) {
         if ($item =~ /^\d+:/) {          if ($item =~ /^\d+:/) {
Line 978  sub update_request_queue { Line 972  sub update_request_queue {
                             mt => 'Your request for a LON-CAPA account has not been approved.',                              mt => 'Your request for a LON-CAPA account has not been approved.',
                         }];                          }];
         $domdesc = &Apache::lonnet::domain($cdom);          $domdesc = &Apache::lonnet::domain($cdom);
           $dbname = 'nohist_requestedusernames';
     } elsif (($context eq 'othdombydc') || ($context eq 'othdombyuser')) {      } elsif (($context eq 'othdombydc') || ($context eq 'othdombyuser')) {
         $namespace = 'queuedrolereqs';          $namespace = 'nohist_queuedrolereqs';
         $beneficiary = 'requester';  
         foreach my $type ('domain','course') {          foreach my $type ('domain','course') {
             my @possroles = &Apache::lonuserutils::roles_by_context($type);              my @possroles = &Apache::lonuserutils::roles_by_context($type);
             $roles_by_context{$type} = \@possroles;              $roles_by_context{$type} = \@possroles;
         }          }
         if ($context eq 'othdombydc') {          if ($context eq 'othdombydc') {
             my $confname = &Apache::lonnet::get_domainconfiguser($cdom);              $confname = &Apache::lonnet::get_domainconfiguser($cdom);
             %requesthash = &Apache::lonnet::dump($namespace,$cdom,$confname);              %requesthash = &Apache::lonnet::dump($namespace,$cdom,$confname);
             $approvedmsg = [{  
                                 mt => 'The role assignment you requested for a user from another domain has been approved and the role assigned.',  
                             }];  
             $rejectedmsg = [{  
                                 mt => 'The role assignment you requested for a user from another domain has not been approved.',  
                            }];  
         } else {          } else {
             %requesthash = &Apache::lonnet::dump($namespace,$cdom,$cnum);              %requesthash = &Apache::lonnet::dump($namespace,$cdom,$cnum);
             $approvedmsg = [{  
                                 mt => 'The role assignment you requested for a user from another domain has been has been agreed to by the user.',  
                             }];  
             $rejectedmsg = [{  
                                 mt => 'The role assignment you requested for a user from another domain has not been agreed to by the user.',  
                            }];  
         }          }
         $domdesc = &Apache::lonnet::domain($cdom);          $domdesc = &Apache::lonnet::domain($cdom);
           $dbname = 'nohist_othdomqueued';
     } else {      } else {
         $domdesc = &Apache::lonnet::domain($cdom);          $domdesc = &Apache::lonnet::domain($cdom);
         $namespace = 'courserequestqueue';          $namespace = 'courserequestqueue';
Line 1158  sub update_request_queue { Line 1141  sub update_request_queue {
             push(@toremove,(@invalidusers,@nopermissions));              push(@toremove,(@invalidusers,@nopermissions));
         } elsif ($context eq 'requestusername') {          } elsif ($context eq 'requestusername') {
             my ($num,$uname) = split(/:/,$item);              my ($num,$uname) = split(/:/,$item);
             my $dbname = 'nohist_requestedusernames';  
             my $domconfiguser = &Apache::lonnet::get_domainconfiguser($cdom);              my $domconfiguser = &Apache::lonnet::get_domainconfiguser($cdom);
             my %curr = &Apache::lonnet::get($dbname,[$uname],$cdom,$domconfiguser);              my %curr = &Apache::lonnet::get($dbname,[$uname],$cdom,$domconfiguser);
   
Line 1234  sub update_request_queue { Line 1216  sub update_request_queue {
                 my ($num,$extent,$role,$uname,$udom) = split(/:/,$item);                  my ($num,$extent,$role,$uname,$udom) = split(/:/,$item);
                 my ($logmsg,$result);                  my ($logmsg,$result);
                 if ($udom eq $cdom) {                  if ($udom eq $cdom) {
                     my $key = $uname.':'.$extent.':'.$role;                      my $key = 'pending:'.$uname.':'.$extent.':'.$role;
                     if (exists($requesthash{$key})) {                      if (exists($requesthash{$key})) {
                         if (ref($requesthash{$key}) eq 'HASH') {                          if (ref($requesthash{$key}) eq 'HASH') {
                             my $requester = $requesthash{$key}->{'requester'};                              my $requester = $requesthash{$key}->{'requester'};
Line 1274  sub update_request_queue { Line 1256  sub update_request_queue {
                                                 }                                                  }
                                                 if (ref($requesteractive{$requester}) eq 'HASH') {                                                  if (ref($requesteractive{$requester}) eq 'HASH') {
                                                     if ($requesteractive{$requester}{"$crsnum:$crsdom:$role"}) {                                                      if ($requesteractive{$requester}{"$crsnum:$crsdom:$role"}) {
                                                         $result =                                                          ($logmsg,$result) =
                                                             &Apache::loncommon::commit_standardrole($udom,$uname,$extent,$role,$start,                                                              &Apache::loncommon::commit_standardrole($udom,$uname,$extent,$role,$start,
                                                                                                     $end,$crsdom,$crsnum,'',                                                                                                      $end,$crsdom,$crsnum,'',
                                                                                                     $reqcontext);                                                                                                      $reqcontext);
Line 1297  sub update_request_queue { Line 1279  sub update_request_queue {
                                             }                                              }
                                             if (ref($requesteractive{$requester}) eq 'HASH') {                                              if (ref($requesteractive{$requester}) eq 'HASH') {
                                                 if (&requester_has_perm($crsdom,$crsnum,$mrole,$requesteractive{$requester})) {                                                  if (&requester_has_perm($crsdom,$crsnum,$mrole,$requesteractive{$requester})) {
                                                     $result = &Apache::loncommon::commit_customrole($udom,$uname,$extent,$crudom,$cruname,                                                      ($logmsg,$result) =
                                                                                                     $rolename,$start,$end,$reqcontext);                                                          &Apache::loncommon::commit_customrole($udom,$uname,$extent,$crudom,$cruname,
                                                                                                 $rolename,$start,$end,$reqcontext);
                                                 }                                                  }
                                             }                                              }
                                         }                                          }
Line 1326  sub update_request_queue { Line 1309  sub update_request_queue {
                                                         }                                                          }
                                                         if (ref($requesteractive{$requester}) eq 'HASH') {                                                          if (ref($requesteractive{$requester}) eq 'HASH') {
                                                             if (&requester_has_perm($crsdom,$crsnum,$role,$requesteractive{$requester})) {                                                              if (&requester_has_perm($crsdom,$crsnum,$role,$requesteractive{$requester})) {
                                                                 $result =                                                                  ($logmsg,$result) =
                                                                     &Apache::loncommon::commit_standardrole($udom,$uname,$extent,$role,$start,                                                                      &Apache::loncommon::commit_standardrole($udom,$uname,$extent,$role,$start,
                                                                                                             $end,$crsdom,$crsnum,$csec,                                                                                                              $end,$crsdom,$crsnum,$csec,
                                                                                                             $reqcontext,$credits);                                                                                                              $reqcontext,$credits);
Line 1335  sub update_request_queue { Line 1318  sub update_request_queue {
                                                     }                                                      }
                                                 }                                                  }
                                             } else {                                              } else {
                                                 my ($domain)  = ($extent =~ m{^/($match_domain)/});                                                  my ($domain) = ($extent =~ m{^/($match_domain)/});
                                                 if (&Apache::lonnet::domain($domain) ne '') {                                                  if (&Apache::lonnet::domain($domain) ne '') {
                                                     unless ($gotroles{$requester}) {                                                      unless ($gotroles{$requester}) {
                                                         &requester_roles($requname,$requdom,\%requesteractive);                                                          &requester_roles($requname,$requdom,\%requesteractive);
Line 1352  sub update_request_queue { Line 1335  sub update_request_queue {
                                     }                                      }
                                 }                                  }
                             }                              }
                               if ($result eq 'ok') {
                                   $requestedby{$item} = $requester;
                                   my $statusres;
                                   my $id = $uname.':'.$udom.':'.$role;
                                   if (($role eq 'ca') || ($role eq 'aa')) {
                                       my ($audom,$auname) = ($extent =~ m{^/($match_domain)/($match_username)$});
                                       $statusres = &Apache::lonnet::put($dbname,{'status&'.$id => 'approved'},$audom,$auname);
                                   } elsif ($extent =~ m{^/($match_domain)/$}) {
                                       my $domain = $1;
                                       my $configuser = &Apache::lonnet::get_domainconfiguser($domain);
                                       $statusres = &Apache::lonnet::put($dbname,{'status&'.$id => 'approved'},$domain,$configuser);
                                   } else {
                                       my ($crsdom,$crsnum,$csec) = ($extent =~ m{^/($match_domain)/($match_courseid)(?:|/([^/]+))$});
                                       $id .= ':'.$csec;
                                       $statusres = &Apache::lonnet::put($dbname,{'status&'.$id => 'approved'},$crsdom,$crsnum);
                                   }
                                   if ($statusres eq 'ok') {
                                       my $newkey = 'approved:'.$uname.':'.$extent.':'.$role;
                                       $requesthash{$newkey} = $requesthash{$key};
                                       delete($requesthash{$key});
                                       push(@toremove,$key);
                                       push(@completed,$item);
                                   }
                               }
                         }                          }
                     }                      }
                 }                  }
                 if ($result eq 'ok') {  
                     push(@completed,$item);  
                 }  
             } else {              } else {
                 my ($num,$extent,$role) = split(/:/,$item);                  my ($num,$extent,$role) = split(/:/,$item);
                 if (exists($requesthash{$extent.':'.$role})) {                  if (exists($requesthash{$extent.':'.$role})) {
Line 1514  sub update_request_queue { Line 1518  sub update_request_queue {
         @changes = map {$_.'_approval'} (@changes);          @changes = map {$_.'_approval'} (@changes);
     } elsif ($context eq 'requestusername') {      } elsif ($context eq 'requestusername') {
         @changes = map {&escape($_).'_approval'} (@changes);          @changes = map {&escape($_).'_approval'} (@changes);
     } elsif (($context eq 'othdombydc') || ($context eq 'othdombyuser')) {  
         @changes = ();  
     }      }
     if (@rejections) {      if (@rejections) {
         foreach my $item (@rejections) {          foreach my $item (@rejections) {
Line 1571  sub update_request_queue { Line 1573  sub update_request_queue {
                     push(@warn_rejects,$uname);                      push(@warn_rejects,$uname);
                 }                  }
             } elsif (($context eq 'othdombydc') || ($context eq 'othdombyuser')) {              } elsif (($context eq 'othdombydc') || ($context eq 'othdombyuser')) {
 #FIXME                  if ($context eq 'othdombydc') {
                       my ($extent,$role,$uname,$udom) = split(/:/,$item);
                       my $oldkey = 'pending:'.$uname.':'.$extent.':'.$role;
                       my $newkey = 'rejected:'.$uname.':'.$extent.':'.$role;
                       my $dbname = 'nohist_othdomqueued';
                       if (exists($requesthash{$oldkey})) {
                           if (ref($requesthash{$oldkey}) eq 'HASH') {
                               $requesthash{$newkey} = $requesthash{$oldkey};
                               delete($requesthash{$oldkey});
                               push(@toremove,$oldkey);
                               $requesthash{$newkey}->{'timestamp'} = $now;
                               $requesthash{$newkey}->{'adjudicator'} = $env{'user.name'}.':'.$env{'user.domain'};
                               my $statusres;
                               my $id = $uname.':'.$udom.':'.$role;
                               if (($role eq 'ca') || ($role eq 'aa')) {
                                   my ($audom,$auname) = ($extent =~ m{^/($match_domain)/($match_username)$});
                                   $statusres = &Apache::lonnet::put($dbname,{'status&'.$id => 'rejected'},$audom,$auname);
                               } elsif ($extent =~ m{^/($match_domain)/$}) {
                                   my $domain = $1;
                                   my $configuser = &Apache::lonnet::get_domainconfiguser($domain);
                                   $statusres = &Apache::lonnet::put($dbname,{'status&'.$id => 'rejected'},$domain,$configuser);
                               } else {
                                   my ($crsdom,$crsnum,$csec) = ($extent =~ m{^/($match_domain)/($match_courseid)(?:|/([^/]+))$});
                                   $id .= ':'.$csec;
                                   $statusres = &Apache::lonnet::put($dbname,{'status&'.$id => 'rejected'},$crsdom,$crsnum);
                               }
                               if ($statusres eq 'ok') {
                                   $requestedby{$item} = $requesthash{$newkey}->{'requester'};
                                   push(@rejectedreqs,$item);
                               }
                           }
                       }
                   }
             } else {              } else {
                 my $cnum = $item;                  my $cnum = $item;
                 if (ref($requesthash{$cnum.'_'.$queue}) eq 'HASH') {                  if (ref($requesthash{$cnum.'_'.$queue}) eq 'HASH') {
Line 1658  sub update_request_queue { Line 1692  sub update_request_queue {
                 }                  }
             }              }
         }          }
         @toremove = map {$_.'_approval'} (@toremove);          unless ($context eq 'othdombydc') {
               @toremove = map {$_.'_approval'} (@toremove);
           }
         my $delresult = &Apache::lonnet::del_dom($namespace,\@toremove,$cdom);          my $delresult = &Apache::lonnet::del_dom($namespace,\@toremove,$cdom);
           if (($delresult ne 'ok') && ($context eq 'othdombydc')) {
               push(@warn_dels,@toremove);
           }
     }      }
     if (@changes) {      if (@changes) {
         my $delresult;          my $delresult;
         if ($context eq 'course') {          if ($context eq 'course') {
             $delresult = &Apache::lonnet::del($namespace,\@changes,$cdom,$cnum);              $delresult = &Apache::lonnet::del($namespace,\@changes,$cdom,$cnum);
           } elsif (($context eq 'othdombydc') || ($context eq 'othdombyuser')) {
               if ($context eq 'othdombydc') {
                   $delresult = &Apache::lonnet::put($namespace,\%requesthash,$cdom,$confname);
               }
         } else {          } else {
             $delresult = &Apache::lonnet::del_dom($namespace,\@changes,$cdom);              $delresult = &Apache::lonnet::del_dom($namespace,\@changes,$cdom);
         }          }
Line 1711  sub update_request_queue { Line 1754  sub update_request_queue {
                         my $userlink =                          my $userlink =
                             &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);                              &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
                         $output .= '<li>'.$userlink.'</li>';                          $output .= '<li>'.$userlink.'</li>';
                           
                     }                      }
                     $output .= '</ul></p>';                      $output .= '</ul></p>';
                 }                  }
Line 1755  sub update_request_queue { Line 1797  sub update_request_queue {
                                                  $approvedlist,$rejectedlist);                                                   $approvedlist,$rejectedlist);
                 }                  }
             } elsif (($context eq 'othdombydc') || ($context eq 'othdombyuser')) {              } elsif (($context eq 'othdombydc') || ($context eq 'othdombyuser')) {
 #FIXME                  $chgmsg = "'Action was taken on the following role requests by [_1].',$namelink";
                   my (%approvals_by_requester,%rejections_by_requester,%for_requester);
                   my $sender = $env{'user.name'}.':'.$env{'user.domain'};
                   if (@completed) {
                       $output .= '<p>'.&mt('The following roles in other domain(s) were assigned for user(s) in this domain:').'<ul>'.
                                  &get_othdombydc_results('approved',\@completed,\%approvals_by_requester,\%requestedby,\%for_requester).
                                  '</ul></p>';
                   }
                   if (@rejectedreqs) {
                       $output .= '<p>'.&mt('The following role assignments in other domain(s) for user(s) in this domain were rejected:').'<ul>'.
                                  &get_othdombydc_results('rejected',\@rejectedreqs,\%rejections_by_requester,\%requestedby,\%for_requester).
                                  '</ul></p>';
                   }
                   foreach my $key (sort(keys(%for_requester))) {
                       if (ref($approvals_by_requester{$key}) eq 'ARRAY') {
                           if (@{$approvals_by_requester{$key}} > 0) {
                               $approvedlist = join("\n\n",@{$approvals_by_requester{$key}});
                           }
                       }
                       if (ref($rejections_by_requester{$key}) eq 'ARRAY') {
                           if (@{$rejections_by_requester{$key}} > 0) {
                               $rejectedlist = join("\n\n",@{$rejections_by_requester{$key}});
                           }
                       }
                       if (($approvedlist ne '') || ($rejectedlist ne '')) {
                           &send_selfserve_notification($key,$chgmsg,'',$domdesc,$now,
                                                        $context,$sender,$approvedlist,
                                                        $rejectedlist);
                       }
                   }
             } else {              } else {
                 $chgmsg = "'Action was taken on the following course and community requests by [_1].',$namelink";                  $chgmsg = "'Action was taken on the following course and community requests by [_1].',$namelink";
                 if (@completed) {                  if (@completed) {
Line 1798  sub update_request_queue { Line 1869  sub update_request_queue {
                 }                  }
             }              }
         } else {          } else {
             if (($context eq 'requestauthor') || ($context eq 'requestusername')) {              if (($context eq 'requestauthor') || ($context eq 'requestusername') || ($context eq 'othdombydc')) {
                 push(@warn_dels,@changes);                  push(@warn_dels,@changes);
             }              }
         }          }
Line 1974  sub update_request_queue { Line 2045  sub update_request_queue {
                 $output .= '<li>'.$uname.'</li>';                  $output .= '<li>'.$uname.'</li>';
             }              }
             $output .= '</ul></p>';              $output .= '</ul></p>';
           } elsif ($context eq 'othdombydc') {
   
         } else {          } else {
             $output .= '<p>'.&mt("For the following course/community requests an error occurred when updating the requestor's own requests record:").'<ul>';              $output .= '<p>'.&mt("For the following course/community requests an error occurred when updating the requestor's own requests record:").'<ul>';
             foreach my $cnum (@warn_approves,@warn_rejects) {              foreach my $cnum (@warn_approves,@warn_rejects) {
Line 2003  sub update_request_queue { Line 2076  sub update_request_queue {
                 my ($escuname) = split(/_/,$item);                  my ($escuname) = split(/_/,$item);
                 $output .= '<li>'.&unescape($escuname).'</li>';                  $output .= '<li>'.&unescape($escuname).'</li>';
             }              }
             $output .= '</ul></p>';                          $output .= '</ul></p>';
           } elsif ($context eq 'othdombydc') {
               $output .= '<p>'.
                          &mt("For the following queued role assignments an error occurred when removing the item from the queue:").
                          '<ul>'.&get_othdombydc_results('dequeue_error',\@warn_dels).'</ul>'.
                          '</p>';
         } else {          } else {
             $output .= '<p>'.&mt("For the following course/community requests an error occurred when removing requests from the pending queue:").'<ul>';              $output .= '<p>'.&mt("For the following course/community requests an error occurred when removing requests from the pending queue:").'<ul>';
             foreach my $cnum (@warn_dels) {              foreach my $cnum (@warn_dels) {
Line 2019  sub update_request_queue { Line 2097  sub update_request_queue {
         }          }
     }      }
     return $output;      return $output;
   }
   
   sub get_othdombydc_results {
       my ($action,$items,$results,$requestedby,$for_requester) = @_;
       return unless (ref($items) eq 'ARRAY');
       unless ($action eq 'dequeue_error') {
           return unless ((ref($results) eq 'HASH') && (ref($requestedby) eq 'HASH') &&
                          (ref($for_requester) eq 'HASH'));
       }
       my $output;
       foreach my $item (@{$items}) {
           my ($extent,$role,$uname,$udom);
           if ($action eq 'approved') {
               (my $num,$extent,$role,$uname,$udom) = split(/:/,$item);
           } elsif ($action eq 'rejected') {
               ($extent,$role,$uname,$udom) = split(/:/,$item);
           } elsif ($action eq 'dequeue_error') {
               (my $oldstatus,$uname,$extent,$role) = split(/:/,$item);
               $udom = $env{'request.role.domain'};
           }
           my @text = (&mt('User: [_1]',$uname));
           if (($role eq 'ca') || ($role eq 'aa')) {
               my $plainrole = &Apache::lonnet::plaintext($role);
               my ($audom,$auname) = ($extent =~ m{^/($match_domain)/($match_username)$});
               my $title = &Apache::loncommon::plainname($auname,$audom);
               push(@text,(&mt('Role: [_1]',$plainrole),
                           &mt('Domain: [_1]',&Apache::lonnet::domain($audom)),
                           &mt('Authoring Space belonging to: [_1]',$title)));
           } elsif ($extent =~ m{^/($match_domain)/$}) {
               my $domain = $1;
               my $plainrole = &Apache::lonnet::plaintext($role);
               if (&Apache::lonnet::domain($domain) ne '') {
                   push(@text,(&mt('Role: [_1]',$plainrole),
                               &mt('Domain: [_1]',&Apache::lonnet::domain($domain))));
               }
           } else {
               my ($crsdom,$crsnum,$csec) = ($extent =~ m{^/($match_domain)/($match_courseid)(?:|/([^/]+)$)});
               if (($crsdom ne '') && ($crsnum ne '')) {
                   my %info = &Apache::lonnet::coursedescription("$crsdom/$crsnum");
                   my $plainrole = &Apache::lonnet::plaintext($role,$info{'type'});
                   push(@text,(&mt('Role: [_1]',$plainrole),
                               &mt('Domain: [_1]',&Apache::lonnet::domain($crsdom)),
                               &mt("$info{'type'}: [_1]",$info{'description'})));
                   if ($csec ne '') {
                       push(@text,&mt('Section: [_1]',$csec));
                   }
               }
           }
           $output .= '<li><ul><li>'.join('</li><li>',@text).'</li></ul></li>';
           unless ($action eq 'dequeue_error') {
               push(@{$results->{$requestedby->{$item}}},join("\n",@text));
               $for_requester->{$requestedby->{$item}} = 1;
           }
       }
       return $output;
 }  }
   
 sub requester_roles {  sub requester_roles {

Removed from v.1.63  
changed lines
  Added in v.1.64


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