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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Fri, 21 Dec 2007 14:35:43 -0000


raeburn		Fri Dec 21 09:35:43 2007 EDT

  Modified files:              
    /loncom/interface	loncreateuser.pm 
  Log:
  - &print_user_modification() accepts $permission argument
  - cancreate check for new user uses usertype and displays appropriate message if user account creation disallowed in current context
  - missing ;
  - portfolio quota setting (if user has mpq priv).
  
  
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.214 loncom/interface/loncreateuser.pm:1.215
--- loncom/interface/loncreateuser.pm:1.214	Fri Dec 21 09:05:40 2007
+++ loncom/interface/loncreateuser.pm	Fri Dec 21 09:35:42 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.214 2007/12/21 14:05:40 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.215 2007/12/21 14:35:42 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -493,9 +493,10 @@
 }
 
 sub print_user_modification_page {
-    my ($r,$ccuname,$ccdomain,$srch,$response,$context) = @_;
+    my ($r,$ccuname,$ccdomain,$srch,$response,$context,$permission) = @_;
     if (($ccuname eq '') || ($ccdomain eq '')) {
-        my $usermsg = &mt('No username and/or domain provided.'); 
+        my $usermsg = &mt('No username and/or domain provided.');
+        $env{'form.phase'} = '';
 	&print_username_entry_form($r,$context,$usermsg);
         return;
     }
@@ -512,6 +513,30 @@
         %alerts,%curr_rules,%got_rules);
     my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
     if ($uhome eq 'no_host') {
+        my $usertype;
+        my ($rules,$ruleorder) =
+            &Apache::lonnet::inst_userrules($ccdomain,'username');
+            $usertype =
+                &Apache::lonuserutils::check_usertype($ccdomain,$ccuname,$rules);
+        my $cancreate =
+            &Apache::lonuserutils::can_create_user($ccdomain,$context,
+                                                   $usertype);
+        if (!$cancreate) {
+            my $helplink = ' href="javascript:helpMenu('."'display'".')"';
+            my %usertypetext = (
+                official   => 'institutional',
+                unofficial => 'non-institutional',
+            );
+            my $response;
+            if ($env{'form.origform'} eq 'crtusername') {
+                $response =  '<span class="LC_warning">'.&mt('No match was found for the username ([_1]) in LON-CAPA domain: [_2]',$ccuname,$ccdomain).
+                            '</span><br />';
+            }
+            $response .= '<span class="LC_warning">'.&mt("You are not authorized to create new $usertypetext{$usertype} users in this domain.").' '.&mt('Contact the <a[_1]>helpdesk</a> for assistance.',$helplink).'</span><br /><br />';
+            $env{'form.phase'} = '';
+            &print_username_entry_form($r,$context,$response);
+            return;
+        }
         $newuser = 1;
         my $checkhash;
         my $checks = { 'username' => 1 };
@@ -532,9 +557,10 @@
                             $domdesc,$curr_rules{$ccdomain}{'username'},
                             'username');
                     }
+                    $env{'form.phase'} = '';
                     &print_username_entry_form($r,$context,$userchkmsg);
                     return;
-                } 
+                }
             }
         }
     } else {
@@ -549,7 +575,7 @@
         }
     }
     if ($response) {
-        $response = '<br />'.$response
+        $response = '<br />'.$response;
     }
     my $defdom=$env{'request.role.domain'};
 
@@ -569,7 +595,6 @@
     my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
     my $dc_setcourse_code = '';
     my $nondc_setsection_code = '';                                        
-
     my %loaditem;
 
     my $groupslist;
@@ -835,7 +860,12 @@
         } else {
             $r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc)); 
         }
-        $r->print('</h2>'."\n".'<div class="LC_left_float">');
+        $r->print($portfolioform);
+        if ($env{'form.action'} eq 'singlestudent') {
+            $r->print(&date_sections_select($context,$newuser,$formname,
+                                            $permission));
+        }
+        $r->print('</div><div class="LC_clear_float_footer"></div>');
     } else { # user already exist-
 	my %lt=&Apache::lonlocal::texthash(
                     'cup'  => "Modify existing user: ",