[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /auth lonroles.pm

raeburn raeburn at source.lon-capa.org
Thu May 23 10:56:40 EDT 2013


raeburn		Thu May 23 14:56:40 2013 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/auth	lonroles.pm 
  Log:
  - For 2.11
    - Backport 1.286.
  
  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.269.2.8 loncom/auth/lonroles.pm:1.269.2.9
--- loncom/auth/lonroles.pm:1.269.2.8	Fri May 10 20:26:22 2013
+++ loncom/auth/lonroles.pm	Thu May 23 14:56:40 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.269.2.8 2013/05/10 20:26:22 raeburn Exp $
+# $Id: lonroles.pm,v 1.269.2.9 2013/05/23 14:56:40 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2446,9 +2446,11 @@
                                 &unescape($groupinfo{'description'});
                         }
                         $groupdesc = $groupdescs{$cdom.'_'.$cnum}{$group};
-                        $groupmsg .= '<li>'.
-                                     &mt('[_1] with status: [_2].',
-                                     '<b>'.$groupdesc.'</b>',$newgroup{$item}).'</li>';
+                        if ($groupdesc) {
+                            $groupmsg .= '<li>'.
+                                         &mt('[_1] with status: [_2].',
+                                         '<b>'.$groupdesc.'</b>',$newgroup{$item}).'</li>';
+                        }
                     }
                 }
                 if ($groupmsg) {
@@ -2462,47 +2464,67 @@
             }
         }
         if (keys(%newrole) > 0) {
-            $changemsg .= '<li>'.&mt('New roles').
-                          '<ul>';
+            my $newmsg;
             foreach my $item (sort(keys(%newrole))) {
                 my $desc = &role_desc($item,$update,$refresh,$now);
-                $changemsg .= '<li>'.
-                              &mt('[_1] with status: [_2].',
-                              $desc,$newrole{$item}).'</li>';
+                if ($desc) {
+                    $newmsg .= '<li>'.
+                               &mt('[_1] with status: [_2].',
+                               $desc,$newrole{$item}).'</li>';
+                }
+            }
+            if ($newmsg) {
+                $changemsg .= '<li>'.&mt('New roles').
+                              '<ul>'.$newmsg.'</ul>'.
+                              '</li>';
             }
-            $changemsg .= '</ul></li>';
         }
         if (keys(%customprivchg) > 0) {
-            $changemsg .= '<li>'.
-                          &mt('Custom roles with privilege changes').
-                          '<ul>';
+            my $privmsg;
             foreach my $item (sort(keys(%customprivchg))) {
                 my $desc = &role_desc($item,$update,$refresh,$now);
-                $changemsg .= '<li>'.$desc.'</li>';
+                if ($desc) {
+                    $privmsg .= '<li>'.$desc.'</li>';
+                }
             }
-            $changemsg .= '</ul></li>';
+            if ($privmsg) {
+                $changemsg .= '<li>'.
+                              &mt('Custom roles with privilege changes').
+                              '<ul>'.$privmsg.'</ul>'.
+                              '</li>';
+             }
         }
         if (keys(%rolechange) > 0) {
-            $changemsg .= '<li>'.
-                          &mt('Existing roles with status changes').'</li>'.
-                          '<ul>';
+            my $rolemsg;
             foreach my $item (sort(keys(%rolechange))) {
-                my $desc = &role_desc($item,$update,$refresh,$now);
+                my $desc = &role_desc($item,$update,$refresh,$now);  
+                if ($desc) {
+                    $rolemsg .= '<li>'.
+                                &mt('[_1] status now: [_2].',$desc,
+                                $rolechange{$item}).'</li>';
+                }
+            }
+            if ($rolemsg) {
                 $changemsg .= '<li>'.
-                              &mt('[_1] status now: [_2].',$desc,
-                              $rolechange{$item}).'</li>';
+                              &mt('Existing roles with status changes').'</li>'.
+                              '<ul>'.$rolemsg.'</ul>'.
+                              '</li>';
             }
-            $changemsg .= '</ul></li>';
         }
         if (keys(%deletedroles) > 0) {
-            $changemsg .= '<li>'.
-                          &mt('Existing roles now expired').'</li>'.
-                          '<ul>';
+            my $delmsg;
             foreach my $item (sort(keys(%deletedroles))) {
                 my $desc = &role_desc($item,$update,$refresh,$now);
-                $changemsg .= '<li>'.$desc.'</li>';
+                if ($desc) {
+                    $delmsg .= '<li>'.$desc.'</li>';
+                }
+            }
+            if ($delmsg) {
+                $changemsg .= '<li>'.
+                              &mt('Existing roles now expired').'</li>'.
+                              '<ul>'.$delmsg.'</ul>'.
+                              '</li>';
             }
-            $changemsg .= '</ul></li>';
         }
     }
     if ((keys(%changed_groups) > 0) || (keys(%groupchange) > 0)) {
@@ -2562,6 +2584,12 @@
     }
     if ($changemsg) {
         $msg .= '<ul>'.$changemsg.'</ul>';
+    } else {
+        if (&Apache::loncommon::show_course()) {
+            $msg = &mt('No new courses or communities');
+        } else {
+            $msg = &mt('No role changes');
+        }
     }
     return $msg;
 }
@@ -2573,6 +2601,7 @@
     &Apache::lonnet::role_status('user.role.'.$item,$update,$refresh,
                                  $now,\$role,\$where,\$trolecode,
                                  \$tstatus,\$tstart,\$tend);
+    return unless ($role);
     if ($role =~ /^cr\//) {
         my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
         $tremark = &mt('Customrole defined by [_1].',$rauthor.':'.$rdomain);
@@ -2614,9 +2643,15 @@
     } elsif ($tdom) {
         $twhere = &mt('Domain').': '.$tdom;
     }
-    my $output = "$trole -- $twhere";
-    if ($tremark) {
-        $output .= '<br />'.$tremark;
+    my $output;
+    if ($trole) {
+        $output = $trole;
+        if ($twhere) {
+            $output .= " -- $twhere";
+        }
+        if ($tremark) {
+            $output .= '<br />'.$tremark;
+        }
     }
     return $output;
 }




More information about the LON-CAPA-cvs mailing list