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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Sun, 23 Dec 2007 15:50:24 -0000


raeburn		Sun Dec 23 10:50:24 2007 EDT

  Modified files:              
    /loncom/interface	loncreateuser.pm lonuserutils.pm 
  Log:
  loncreateuser.pm
  If user modification fails - if the error type was "refusea"d display the logmsg, otherwise display the error result
  
  After bulk update of users, add  form containing original filters as hidden form elements. "Display User Lists" link submits form, so display uses original filter choices.   
  
  
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.222 loncom/interface/loncreateuser.pm:1.223
--- loncom/interface/loncreateuser.pm:1.222	Fri Dec 21 16:02:10 2007
+++ loncom/interface/loncreateuser.pm	Sun Dec 23 10:50:23 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.222 2007/12/21 21:02:10 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.223 2007/12/23 15:50:23 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2109,7 +2109,11 @@
                     if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) {
                         my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3);
                         if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) {
-                            $output = "Error: $result\n";
+                            if ($result eq 'refused' && $logmsg) {
+                                $output = $logmsg;
+                            } else { 
+                                $output = "Error: $result\n";
+                            }
                         } else {
                             $output = &mt('Assigning').' '.$role.' in '.$url.
                                       &mt('starting').' '.localtime($now).
@@ -2836,10 +2840,10 @@
                                                           'User_Management_List'));
             if ($permission->{'cusr'}) {
                 &Apache::lonuserutils::update_user_list($r,$context,$setting,$choice);
-                $r->print('<p><a href="/adm/createuser?action=listusers">'.&mt('Display User Lists').'</a>');
                 $r->print(&Apache::loncommon::end_page());
             } else {
                 $r->print(&mt('You are not authorized to make bulk changes to user roles'));
+                $r->print('<p><a href="/adm/createuser?action=listusers">'.&mt('Display User Lists').'</a>');
                 $r->print(&Apache::loncommon::end_page());
             }
         } else {
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.31 loncom/interface/lonuserutils.pm:1.32
--- loncom/interface/lonuserutils.pm:1.31	Sat Dec 22 22:21:28 2007
+++ loncom/interface/lonuserutils.pm	Sun Dec 23 10:50:24 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Utility functions for managing LON-CAPA user accounts
 #
-# $Id: lonuserutils.pm,v 1.31 2007/12/23 03:21:28 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.32 2007/12/23 15:50:24 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3888,6 +3888,12 @@
                     $plrole,$extent,$uname.':'.$udom,$result).'<br />');
         }
     }
+    $r->print('<form name="studentform" method="post" action="/adm/createuser">'."\n");
+    foreach my $item ('action','sortby','roletype','showrole','Status') {
+        if ($env{'form.'.$item} ne '') {
+            $r->print('<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n");
+        }
+    }
     $r->print('<p><b>'.&mt("$result_text{'ok'}{$choice} role(s) for [quant,_1,user,users,no users].",$count).'</b></p>');
     if ($count > 0) {
         if ($choice eq 'revoke' || $choice eq 'drop') {
@@ -3901,6 +3907,7 @@
             $r->print(&make_dates_default($startdate,$enddate,$context));
         }
     }
+    $r->print('<a href="javascript:document.studentform.submit()">'.&mt('Display User Lists').'</a></form>'."\n");
 }
 
 sub classlist_drop {