[LON-CAPA-cvs] cvs: loncom /interface lonrequestcourse.pm

raeburn raeburn@source.lon-capa.org
Fri, 11 Sep 2009 12:53:10 -0000


This is a MIME encoded message

--raeburn1252673590
Content-Type: text/plain

raeburn		Fri Sep 11 12:53:10 2009 EDT

  Modified files:              
    /loncom/interface	lonrequestcourse.pm 
  Log:
  - If course is being created immediately, add CC role to assignment of new roles 
    to requestor's %env, if no additional personnel were included in the request.
  - Some localization of course types.
  
  
--raeburn1252673590
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20090911125310.txt"

Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.34 loncom/interface/lonrequestcourse.pm:1.35
--- loncom/interface/lonrequestcourse.pm:1.34	Thu Sep 10 03:00:31 2009
+++ loncom/interface/lonrequestcourse.pm	Fri Sep 11 12:53:10 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Request a course
 #
-# $Id: lonrequestcourse.pm,v 1.34 2009/09/10 03:00:31 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.35 2009/09/11 12:53:10 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -631,7 +631,7 @@
                          official   => 'Official course',
                          unofficial => 'Unofficial course',
                          community  => 'Community',
-                    );
+                   );
     return (\@types,\%typename);
 }
 
@@ -725,7 +725,7 @@
 END
 
     $r->print(&header('Course Requests',$js.$jscript,$loaditems).$crumb.
-             '<p>'.&mt('Request creation of a new course, or manage pending course requests.').'</p>'.
+             '<p>'.&mt('Request creation of a new course, or review your pending course requests.').'</p>'.
              '<div>'.
               &Apache::lonhtmlcommon::start_pick_box().
               &Apache::lonhtmlcommon::row_title(&mt('Course Domain')).
@@ -757,7 +757,7 @@
             if ($type eq 'official') {
                 $selected = ' selected="selected"';
             }
-            $r->print('<option value="'.$type.'"'.$selected.'>'.$typename->{$type}.
+            $r->print('<option value="'.$type.'"'.$selected.'>'.&mt($typename->{$type}).
                       '</option>'."\n");
         }
     }
@@ -1748,14 +1748,8 @@
     my ($dom) = @_;
     my %statusinfo = &Apache::lonnet::dump('courserequests',$env{'user.domain'},
                                            $env{'user.name'},'^status:'.$dom);
-    my ($output,$formname,%queue_by_date,%typenames);
-    if ($env{'form.crstype'} eq 'any') {
-        %typenames = &Apache::lonlocal::texthash (
-                                                   official   => 'Official course',
-                                                   unofficial => 'Unofficial course',
-                                                   community  => 'Community',
-                                                 );
-    }
+    my ($output,$formname,%queue_by_date);
+    my ($types,$typenames) = &course_types();
     foreach my $key (keys(%statusinfo)) {
         if (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending')) { 
             (undef,my($cdom,$cnum)) = split(':',$key);
@@ -1826,7 +1820,10 @@
      '<td>'.&unescape($desc).'</td>'.
      '<td>'.$cdom.'</td>';
                     if ($env{'form.crstype'} eq 'any') {
-                        my $typename = $typenames{$type};
+                        my $typename;
+                        if (ref($typenames) eq 'HASH') {
+                            $typename = &mt($typenames->{$type});
+                        }
                         if ($typename eq '') {
                             $typename = &mt('Unknown type');
                         }
@@ -1979,7 +1976,7 @@
     $crstypename = $env{'form.crstype'};
     if (ref($typename) eq 'HASH') {
         unless ($typename->{$env{'form.crstype'}} eq '') {
-            $crstypename = $typename->{$env{'form.crstype'}};
+            $crstypename = &mt($typename->{$env{'form.crstype'}});
         }
     }
     my $category = 'Course';
@@ -2295,14 +2292,14 @@
     if ($crstype eq 'community') {
         $type = 'Community';
     }
-    my $cloneform = &Apache::loncommon::select_dom_form($dom,'clonedom').
+    my $cloneform = &Apache::loncommon::select_dom_form($dom,'clonedom').'&nbsp;'.
                     &Apache::loncommon::selectcourse_link($formname,'clonecrs','clonedom','','','',$type);
     my %lt = &clone_text();
     my $output .= 
         &Apache::lonhtmlcommon::row_title($lt{'cid'}).'<label>'.
         '<input type="text" size="25" name="clonecrs" value=""  />'.
-        '</label>'.&Apache::lonhtmlcommon::row_closure(1).'<label>'.
-        &Apache::lonhtmlcommon::row_title($lt{'dmn'}).'</label>'.
+        '</label>'.&Apache::lonhtmlcommon::row_closure(1).
+        &Apache::lonhtmlcommon::row_title($lt{'dmn'}).'<label>'.
         $cloneform.'</label>'.&Apache::lonhtmlcommon::row_closure(1).
         &Apache::lonhtmlcommon::row_title($lt{'dsh'}).'<label>'.
         '<input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}.
@@ -2857,85 +2854,90 @@
     my $owner = $env{'user.name'}.':'.$env{'user.domain'};
     if (ref($details) eq 'HASH') {
         if (ref($details->{'personnel'}) eq 'HASH') {
-            if (ref($details->{'personnel'}{$owner}) eq 'HASH') {
-                my @roles;
-                if (ref($details->{'personnel'}{$owner}{'roles'}) eq 'ARRAY') {
-                    @roles = sort(@{$details->{'personnel'}{$owner}{'roles'}});
-                    unless (grep(/^cc$/,@roles)) {
-                        push(@roles,'cc');
-                    }
-                } else {
-                    @roles = ('cc');
+            unless (ref($details->{'personnel'}{$owner}) eq 'HASH') {
+                $details->{'personnel'}{$owner} = {
+                                                    'roles' => ['cc'],
+                                                    'cc'    => { 'usec' => [] },
+                                                  };
+            }
+            my @roles;
+            if (ref($details->{'personnel'}{$owner}{'roles'}) eq 'ARRAY') {
+                @roles = sort(@{$details->{'personnel'}{$owner}{'roles'}});
+                unless (grep(/^cc$/,@roles)) {
+                    push(@roles,'cc');
                 }
-                foreach my $role (@roles) {
-                    my $start = $now;
-                    my $end = '0';
-                    if ($role eq 'st') {
-                        if ($details->{'accessstart'} ne '') {
-                            $start = $details->{'accessstart'};
-                        }
-                        if ($details->{'accessend'} ne '') {
-                            $end = $details->{'accessend'};
-                        }
-                    }
-                    my @usecs;
-                    if ($role ne 'cc') {
-                        if (ref($details->{'personnel'}{$owner}{$role}{'usec'}) eq 'ARRAY') {
-                            @usecs = @{$details->{'personnel'}{$owner}{$role}{'usec'}};
-                        }
-                    } 
-                    if ($role eq 'st') {
-                        if (@usecs > 1) {
-                            my $firstsec = $usecs[0];
-                            @usecs = ($firstsec);
-                        }
-                    }
-                    if (@usecs == 0) {
-                        push(@usecs,'');
-                    }
-                    foreach my $usec (@usecs) {
-                        my (%userroles,%newrole,%newgroups,$spec,$area);
-                        my $area = '/'.$dom.'/'.$cnum;
-                        my $spec = $role.'.'.$area;
-                        if ($usec ne '') {
-                           $spec .= '/'.$usec;
-                           $area .= '/'.$usec;
-                        }
+            } else {
+                @roles = ('cc');
+            }
+            foreach my $role (@roles) {
+                my $start = $now;
+                my $end = '0';
+                if ($role eq 'st') {
+                    if ($details->{'accessstart'} ne '') {
+                        $start = $details->{'accessstart'};
+                    }
+                    if ($details->{'accessend'} ne '') {
+                        $end = $details->{'accessend'};
+                    }
+                }
+                my @usecs;
+                if ($role ne 'cc') {
+                    if (ref($details->{'personnel'}{$owner}{$role}{'usec'}) eq 'ARRAY') {
+                        @usecs = @{$details->{'personnel'}{$owner}{$role}{'usec'}};
+                    }
+                } 
+                if ($role eq 'st') {
+                    if (@usecs > 1) {
+                        my $firstsec = $usecs[0];
+                        @usecs = ($firstsec);
+                    }
+                }
+                if (@usecs == 0) {
+                    push(@usecs,'');
+                }
+                foreach my $usec (@usecs) {
+                    my (%userroles,%newrole,%newgroups,$spec,$area);
+                    my $area = '/'.$dom.'/'.$cnum;
+                    my $spec = $role.'.'.$area;
+                    if ($usec ne '') {
+                       $spec .= '/'.$usec;
+                       $area .= '/'.$usec;
+                    }
+                    if ($role =~ /^cr\//) {
+                        &Apache::lonnet::custom_roleprivs(\%newrole,$role,$dom,
+                                                          $cnum,$spec,$area);
+                    } else {
+                        &Apache::lonnet::standard_roleprivs(\%newrole,$role,$dom,
+                                                            $spec,$cnum,$area);
+                    }
+                    &Apache::lonnet::set_userprivs(\%userroles,\%newrole,
+                                                   \%newgroups);
+                    $userroles{'user.role.'.$spec} = $start.'.'.$end;
+                    &Apache::lonnet::appenv(\%userroles,[$role,'cm']);
+                    if (($end == 0) || ($end > $now)) {
+                        my $showrole = $role;
                         if ($role =~ /^cr\//) {
-                            &Apache::lonnet::custom_roleprivs(\%newrole,$role,$dom,
-                                                              $cnum,$spec,$area);
-                        } else {
-                            &Apache::lonnet::standard_roleprivs(\%newrole,$role,$dom,
-                                                                $spec,$cnum,$area);
+                            $showrole = &Apache::lonnet::plaintext($role,$crstype);
+                        } elsif (ref($longroles) eq 'HASH') {
+                            if ($longroles->{$role} ne '') {
+                                $showrole = $longroles->{$role};
+                            }
                         }
-                        &Apache::lonnet::set_userprivs(\%userroles,\%newrole,
-                                                       \%newgroups);
-                        $userroles{'user.role.'.$spec} = $start.'.'.$end;
-                        &Apache::lonnet::appenv(\%userroles,[$role,'cm']);
-                        if (($end == 0) || ($end > $now)) {
-                            my $showrole = $role;
-                            if ($role =~ /^cr\//) {
-                                $showrole = &Apache::lonnet::plaintext($role,$crstype);
-                            } elsif (ref($longroles) eq 'HASH') {
-                                if ($longroles->{$role} ne '') {
-                                    $showrole = $longroles->{$role};
-                                }
+                        if ($start <= $now) {
+                            $active .= '<li><a href="/adm/roles?selectrole=1&'.
+                                       $spec.'=1">'.$showrole;
+                            if ($usec ne '') {
+                                $active .= ' - '.&mt('section:').' '.$usec; 
                             }
-                            if ($start <= $now) {
-                                $active .= '<li><a href="/adm/roles?selectrole=1&'.                                             $spec.'=1">'.$showrole;
-                                if ($usec ne '') {
-                                    $active .= ' - '.&mt('section:').' '.$usec; 
-                                }
-                                $active .= '</a></li>';
-                                $numactive ++;
-                            } else { 
-                                $future .= '<li>'.$showrole;
-                                if ($usec ne '') {
-                                    $future .= ' - '.&mt('section:').' '.$usec;
-                                }
-                                $future .= '</li>';
-                                $numfuture ++;
+                            $active .= '</a></li>';
+                            $numactive ++;
+                        } else { 
+                            $future .= '<li>'.$showrole;
+                            if ($usec ne '') {
+                                $future .= ' - '.&mt('section:').' '.$usec;
                             }
+                            $future .= '</li>';
+                            $numfuture ++;
                         }
                     }
                 }

--raeburn1252673590--