Diff for /loncom/interface/loncoursequeueadmin.pm between versions 1.30 and 1.38

version 1.30, 2012/08/14 15:45:06 version 1.38, 2013/12/24 19:15:10
Line 70  described at http://www.lon-capa.org. Line 70  described at http://www.lon-capa.org.
   
 =item process_official_reqs()  =item process_official_reqs()
   
   =item is_active_author()
   
   =item author_prompt()
   
   =item reqauthor_check()
   
   =item process_reqauthor()
   
 =back  =back
   
 =cut  =cut
Line 101  sub send_selfserve_notification { Line 109  sub send_selfserve_notification {
     } elsif ($context eq 'domainmanagers') {      } elsif ($context eq 'domainmanagers') {
         $rawsubj = 'Course/Community requests reviewed';          $rawsubj = 'Course/Community requests reviewed';
         push(@rawmsg,{          push(@rawmsg,{
                       mt  => 'Course/Community creation requests in the following domain: [_1] have been reviewed.',                        mt  => 'Course/Community creation requests in the following domain: "[_1]" have been reviewed.',
                       args => ["\n$contextdesc"],                        args => ["\n$contextdesc"],
                      });                       });
         if (ref($textstr) eq 'ARRAY') {          if (ref($textstr) eq 'ARRAY') {
Line 110  sub send_selfserve_notification { Line 118  sub send_selfserve_notification {
     } elsif ($context eq 'authormanagers') {      } elsif ($context eq 'authormanagers') {
         $rawsubj = 'Authoring space requests reviewed';          $rawsubj = 'Authoring space requests reviewed';
         push(@rawmsg,{          push(@rawmsg,{
                       mt  => 'Authoring requests in the following domain: [_1] have been reviewed.',                        mt  => 'Authoring requests in the following domain: "[_1]" have been reviewed.',
                       args => ["\n$contextdesc"],                        args => ["\n$contextdesc"],
                      });                       });
         if (ref($textstr) eq 'ARRAY') {          if (ref($textstr) eq 'ARRAY') {
Line 170  sub send_selfserve_notification { Line 178  sub send_selfserve_notification {
                      },                       },
                      {                       {
                       mt =>'[_1]As Domain Coordinator, use: [_2]Main Menu -> Course and community creation -> Approve or reject requests[_3]to display a list of pending requests, which you can either approve or reject.',                        mt =>'[_1]As Domain Coordinator, use: [_2]Main Menu -> Course and community creation -> Approve or reject requests[_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 'selfenrollreq') {      } elsif ($context eq 'selfenrollreq') {
         $rawsubj = 'Self-enrollment request';          $rawsubj = 'Self-enrollment request';
         if ($crstype eq 'community') {          if ($crstype eq 'community') {
             $msgtxt = 'Enrollment in the following community: [_1] was requested by [_2] on [_3].'              $msgtxt = 'Enrollment in the following community: [_1]was requested by [_2] on [_3].'
         } else {          } else {
             $msgtxt = 'Enrollment in the following course: [_1] was requested by [_2] on [_3].'              $msgtxt = 'Enrollment in the following course: [_1]was requested by [_2] on [_3].'
         }          }
         push(@rawmsg,{          push(@rawmsg,{
                       mt  => $msgtxt,                        mt  => $msgtxt,
Line 196  sub send_selfserve_notification { Line 204  sub send_selfserve_notification {
                      });                       });
     } elsif ($context eq 'authorreq') {      } elsif ($context eq 'authorreq') {
         $rawsubj = 'Authoring space request to review';          $rawsubj = 'Authoring space request to review';
         $msgtxt = 'Assignment of an author role in the [_1] domain[_2] was requested by [_3] on [_4].';          $msgtxt = 'Assignment of an author role in the [_1] domain[_2]was requested by [_3] on [_4].';
         push(@rawmsg,{          push(@rawmsg,{
                       mt  => $msgtxt,                        mt  => $msgtxt,
                       args => [$contextdesc,"\n",$textstr,$timestamp],                        args => [$contextdesc,"\n",$textstr,$timestamp],
Line 427  sub build_queue_display { Line 435  sub build_queue_display {
                         official   => 'Official course',                          official   => 'Official course',
                         unofficial => 'Unofficial course',                          unofficial => 'Unofficial course',
                         community  => 'Community',                          community  => 'Community',
                           textbook   => 'Textbook course',
                     );                      );
         $output .= '<th>'.&mt('Type').'</th>'.          $output .= '<th>'.&mt('Type').'</th>'.
                    '<th>'.&mt('Date requested').'</th>'.                     '<th>'.&mt('Date requested').'</th>'.
Line 528  sub update_request_queue { Line 537  sub update_request_queue {
         $firsturl);          $firsturl);
     my $count=0;      my $count=0;
     while (my @course = &Apache::loncommon::get_env_multiple('form.'.$count.'radioreq')) {      while (my @course = &Apache::loncommon::get_env_multiple('form.'.$count.'radioreq')) {
         if (@course[0] =~ /^\d+:.*/) {          if ($course[0] =~ /^\d+:.*/) {
             push(@approvals,@course[0]);              push(@approvals,$course[0]);
         } elsif (@course[0] =~ /^later:.*/) {          } elsif ($course[0] =~ /^later:.*/) {
             #decide later              #decide later
         } else {          } else {
             push(@rejections,@course[0]);              push(@rejections,$course[0]);
         }          }
         $count+=1;          $count+=1;
     }      }
Line 1248  sub update_request_queue { Line 1257  sub update_request_queue {
             }              }
             $output .= '</ul></p>';              $output .= '</ul></p>';
         } else {          } else {
             $output .= '<p>'.&mt("For the following course/community requests an error occurred when removing requests for the following 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) {
                 my $showcourse;                  my $showcourse;
                 if (ref($requesthash{$cnum.'_'.$queue})) {                  if (ref($requesthash{$cnum.'_'.$queue})) {
Line 1344  sub build_batchcreatehash { Line 1353  sub build_batchcreatehash {
         }          }
         $batchhash{'title'} = $details->{'cdescr'};          $batchhash{'title'} = $details->{'cdescr'};
         $batchhash{'coursecode'} = $details->{'instcode'};          $batchhash{'coursecode'} = $details->{'instcode'};
           if ($domdefs->{'officialcredits'} || $domdefs->{'unofficialcredits'}) {
               $batchhash{'defaultcredits'} = $details->{'defaultcredits'};
           }
         $batchhash{'emailenc'} = $emailenc;          $batchhash{'emailenc'} = $emailenc;
         $batchhash{'adds'} = $details->{'autoadds'};          $batchhash{'adds'} = $details->{'autoadds'};
         $batchhash{'drops'} = $details->{'autodrops'};          $batchhash{'drops'} = $details->{'autodrops'};
Line 1462  sub get_processtype { Line 1474  sub get_processtype {
         } else {          } else {
             my %alltasks;              my %alltasks;
             if (($isadv) && ($settings{'_LC_adv'} ne '')) {              if (($isadv) && ($settings{'_LC_adv'} ne '')) {
                 $val = $settings{$crstype}{'_LC_adv'};                  $val = $settings{'_LC_adv'};
                 @{$inststatuses} = ('_LC_adv_');                  @{$inststatuses} = ('_LC_adv_');
             } else {              } else {
                 if ($userenv{'inststatus'} ne '') {                  if ($userenv{'inststatus'} ne '') {
Line 1548  sub queued_selfenrollment { Line 1560  sub queued_selfenrollment {
     }      }
     if (keys(%reqs_by_date)) {      if (keys(%reqs_by_date)) {
         unless ($notitle) {          unless ($notitle) {
             $output .= '<b>'.&mt('Enrollment requests pending Course Coordinator approval').'</b><br />';              $output .= '<br /><b>'.&mt('Enrollment requests pending Course Coordinator approval').'</b><br />';
         }          }
         $output .= &Apache::loncommon::start_data_table().          $output .= &Apache::loncommon::start_data_table().
                    &Apache::loncommon::start_data_table_header_row().                     &Apache::loncommon::start_data_table_header_row().
Line 1781  sub process_official_reqs { Line 1793  sub process_official_reqs {
         }          }
     }      }
     return $output;      return $output;
   }
   
   sub is_active_author {
       if ($env{'user.role.au./'.$env{'user.domain'}.'/'} =~ /^(\d*)\.(\d*)$/) {
           if ((!$1 || $1 < time) &&
               (!$2 || $2 > time)) {
               return 1;
           }
       }
   }
   
   sub author_prompt {
       my ($is_active_author,$offer_author);
       if ($env{'environment.canrequest.author'}) {
           unless (&is_active_author()) {
               unless (&reqauthor_check() =~ /^approval:\d+$/) {
                   $offer_author = 1;
               }
           }
       }
       return $offer_author;
   }
   
   sub reqauthor_check {
       my $queued = $env{'environment.requestauthorqueued'};
       my %reqauthor = &Apache::lonnet::get('requestauthor',['author_status','author'],
                                            $env{'user.domain'},$env{'user.name'});
       my $reqstatus = $reqauthor{'author_status'};
       if (($reqstatus eq '' && $queued ne '') ||
           ($env{'environment.requestauthorqueued'} !~ /^\Q$reqstatus\E/)) {
           if (ref($reqauthor{'author'}) eq 'HASH') {
               $queued = $reqstatus.':'.$reqauthor{'author'}{'timestamp'};
           } else {
               undef($queued);
           }
           &Apache::lonnet::appenv({'environment.requestauthorqueued' => $queued});
       }
       return $queued;
   }
   
   sub process_reqauthor {
       my ($dispositionref,$updateref) = @_;
       if (&is_active_author()) {
           return '<span class="LC_warning">'.
                   &mt('An authoring space has already been assigned to you.').'<br />'.
                   &mt('Please select the Author role from your [_1]roles page[_2].','<a href="/adm/roles">',
                   '</a>').'</span>';
       }
       unless ($env{'environment.canrequest.author'}) {
           return '<span class="LC_warning">'.
                   &mt('You do not currently have rights to request an authoring space.').'<br />'.
                   &mt('Please contact the [_1]helpdesk[_2] for assistance.','<a href="/adm/helpdesk">',
                   '</a>').'</span>';
       }
       my $queued = &reqauthor_check();
       if ($queued =~ /^approval:(\d+)$/) {
           my $timestamp = $1;
           return '<span class="LC_info">'.
                  &mt('A request for authoring space submitted on [_1] is awaiting approval',
                  &Apache::lonlocal::locallocaltime($timestamp)).
                  '</span>';
       } elsif ($queued =~ /^approved:(\d+)$/) {
           my $timestamp = $1;   
           my %roleshash = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles',
                                                         ['active'],['au'],[$env{'user.domain'}]);
           if (keys(%roleshash) > 0) {
               return '<span class="LC_info">'.
                      &mt('A request for authoring space submitted on [_1] has been approved.',
                      &Apache::lonlocal::locallocaltime($timestamp)).
                      '</span>';
           }
       }
       my ($output,@inststatuses,%domconfig);
       %domconfig = &Apache::lonnet::get_dom('configuration',['requestauthor'],
                                             $env{'user.domain'});
       my $val = &get_processtype('requestauthor',$env{'user.name'},$env{'user.domain'},
                                  $env{'user.adv'},$env{'user.domain'},undef,
                                  \@inststatuses,\%domconfig);
       my $now = time;
       if ($val eq 'automatic') {
           my $start = $now-1;
           if (&Apache::lonnet::assignrole($env{'user.domain'},$env{'user.name'},'/'.$env{'user.domain'}.'/',
                                           'au',undef,$start,undef,undef,'requestauthor') eq 'ok') {
               $output = '<span class="LC_info">'.
                         &mt('Access to authoring space has been activated').'</span><br />';
                         &Apache::lonroles::update_session_roles();
               &Apache::lonnet::appenv({'user.update.time'  => $now});
               if (ref($updateref)) {
                   $$updateref = $now;
               }
               if (ref($dispositionref)) {
                   $$dispositionref = 'created';
               }
           } else {
               $output = '<span class="LC_info">'.
                         &mt('An error occurred while activating your access to authoring space');
           }
       } elsif ($val eq 'approval') {
           my $domconfiguser = &Apache::lonnet::get_domainconfiguser($env{'user.domain'});
           if (&Apache::lonnet::put('requestauthorqueue',{ $env{'user.name'}.'_'.$val => $now },
                                    $env{'user.domain'},$domconfiguser) eq 'ok') {
               my %userrequest = (
                   author => {
                               timestamp   => $now,
                               status      => $val,
                             },
                   author_status => $val,
               );
               my $req_notifylist;
               if (ref($domconfig{'requestauthor'}) eq 'HASH') {
                   if (ref($domconfig{'requestauthor'}{'notify'}) eq 'HASH') {
                       my $req_notifylist = $domconfig{'requestauthor'}{'notify'}{'approval'};
                       if ($req_notifylist) {
                           my $fullname = &Apache::loncommon::plainname($env{'user.name'},
                                                                        $env{'user.domain'});
                           my $sender = $env{'user.name'}.':'.$env{'user.domain'};
                           my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
                           &send_selfserve_notification($req_notifylist,
                                                        "$fullname ($env{'user.name'}:$env{'user.domain'})",
                                                        undef,$domdesc,$now,'authorreq',$sender);
                       }
                   }
               }
               my $userresult =
                   &Apache::lonnet::put('requestauthor',\%userrequest,$env{'user.domain'},$env{'user.name'});
               $output = '<span class="LC_info">'.
                         &mt('Your request for authoring space has been submitted for approval.').
                         '</span>';
               &Apache::lonnet::appenv({'environment.requestauthorqueued' => $val.':'.$now});
           } else {
               $output = '<span class="LC_info">'.
                         &mt('An error occurred saving your request for authoring space.').
                         '</span>';
           }
       }
       return $output;
 }  }
   
 1;  1;

Removed from v.1.30  
changed lines
  Added in v.1.38


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