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

raeburn raeburn@source.lon-capa.org
Thu, 06 Aug 2009 20:40:59 -0000


This is a MIME encoded message

--raeburn1249591259
Content-Type: text/plain

raeburn		Thu Aug  6 20:40:59 2009 EDT

  Modified files:              
    /loncom/interface	lonrequestcourse.pm loncreateuser.pm loncommon.pm 
  Log:
  - Provide domain of requested course to routines used for pop-up "Pick User" window used to add course personnel to the request.
  
  
--raeburn1249591259
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20090806204059.txt"

Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.6 loncom/interface/lonrequestcourse.pm:1.7
--- loncom/interface/lonrequestcourse.pm:1.6	Thu Aug  6 04:01:36 2009
+++ loncom/interface/lonrequestcourse.pm	Thu Aug  6 20:40:59 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Request a course
 #
-# $Id: lonrequestcourse.pm,v 1.6 2009/08/06 04:01:36 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.7 2009/08/06 20:40:59 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -858,13 +858,13 @@
     for (my $i=0; $i<$persontotal; $i++) { 
         my @linkargs = map { 'person_'.$i.'_'.$_ } (@items);
         my $linkargstr = join("','",@linkargs);
-        my $userlink = &Apache::loncommon::selectuser_link($formname,@linkargs,$userlinktxt);
+        my $userlink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom,$userlinktxt);
         my $uname_form = '<input type="text" name="person_'.$i.'_uname" value=""'.
                          ' onFocus="this.blur();'.
-                         'openuserbrowser('."'$formname','$linkargstr'".');" />';
+                         'openuserbrowser('."'$formname','$linkargstr','$dom'".');" />';
         my $onchange = 'javascript:fix_domain('."'$formname','person_".$i."_dom',".
                        "'person_".$i."_hidedom'".');'.
-                       'openuserbrowser('."'$formname','$linkargstr'".');';
+                       'openuserbrowser('."'$formname','$linkargstr','$dom'".');';
         my $udom_form = &Apache::loncommon::select_dom_form($dom,'person_'.$i.'_dom','',
                                                             1,$onchange).
                         '<input type="hidden" name="person_'.$i.'_hidedom" value="'.$dom.'" />';
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.304 loncom/interface/loncreateuser.pm:1.305
--- loncom/interface/loncreateuser.pm:1.304	Thu Aug  6 05:48:56 2009
+++ loncom/interface/loncreateuser.pm	Thu Aug  6 20:40:59 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.304 2009/08/06 05:48:56 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.305 2009/08/06 20:40:59 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -5631,17 +5631,27 @@
                     $response .= '<br />'.&mt('You may want to broaden your search to the selected LON-CAPA domain.');
                 }
             }
-            if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $env{'request.role.domain'})) {
+            my $createdom = $env{'request.role.domain'};
+            if ($context eq 'requestcrs') {
+                if ($env{'form.coursedom'} ne '') {
+                    $createdom = $env{'form.coursedom'};
+                }
+            }
+            if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $createdom)) {
                 my $cancreate =
-                    &Apache::lonuserutils::can_create_user($env{'request.role.domain'},$context);
+                    &Apache::lonuserutils::can_create_user($createdom,$context);
+                my $targetdom = '<span class="LC_cusr_emph">'.$createdom.'</span>';
                 if ($cancreate) {
-                    my $showdom = &display_domain_info($env{'request.role.domain'}); 
+                    my $showdom = &display_domain_info($createdom); 
                     $response .= '<br /><br />'
                                 .'<b>'.&mt('To add a new user:').'</b>'
-                                .'<br />'
-                                .&mt("(You can only create new users in your current role's domain - [_1])"
-                                    ,'<span class="LC_cusr_emph">'.$env{'request.role.domain'}.'</span>')
-                                .'<ul><li>'
+                                .'<br />';
+                    if ($context eq 'requestcrs') {
+                        $response .= &mt("(You can only define new users in the new course's domain - [_1])",$targetdom);
+                    } else {
+                        $response .= &mt("(You can only create new users in your current role's domain - [_1])",$targetdom);
+                    }
+                    $response .='<ul><li>'
                                 .&mt("Set 'Domain/institution to search' to: [_1]",'<span class="LC_cusr_emph">'.$showdom.'</span>')
                                 .'</li><li>'
                                 .&mt("Set 'Search criteria' to: [_1]username is ..... in selected LON-CAPA domain[_2]",'<span class="LC_cusr_emph">','</span>')
@@ -5652,14 +5662,17 @@
                                 .'</li></ul><br />';
                 } else {
                     my $helplink = ' href="javascript:helpMenu('."'display'".')"';
-                    $response .= '<br /><br />'
-                                .&mt("You are not authorized to create new users in your current role's domain - [_1]."
-                                    ,'<span class="LC_cusr_emph">'.$env{'request.role.domain'}.'</span>')
-                                .'<br />'
-                                .&mt('Please contact the [_1]helpdesk[_2] if you need to create a new user.'
+                    $response .= '<br /><br />';
+                    if ($context eq 'requestcrs') {
+                        $response .= &mt("You are not authorized to defined new users in the new course's domain - [_1].",$targetdom);
+                    } else {
+                        $response .= &mt("You are not authorized to create new users in your current role's domain - [_1].",$targetdom);
+                    }
+                    $response .= '<br />'
+                                 .&mt('Please contact the [_1]helpdesk[_2] if you need to create a new user.'
                                     ,' <a'.$helplink.'>'
                                     ,'</a>')
-                                .'<br /><br />';
+                                 .'<br /><br />';
                 }
             }
         }
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.880 loncom/interface/loncommon.pm:1.881
--- loncom/interface/loncommon.pm:1.880	Thu Aug  6 04:05:38 2009
+++ loncom/interface/loncommon.pm	Thu Aug  6 20:40:59 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.880 2009/08/06 04:05:38 raeburn Exp $
+# $Id: loncommon.pm,v 1.881 2009/08/06 20:40:59 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -602,7 +602,7 @@
     my $id_functions = &javascript_index_functions();
     return <<"ENDUSERBRW";
 
-function openuserbrowser(formname,uname,udom,ulast,ufirst,uemail,hideudom) {
+function openuserbrowser(formname,uname,udom,ulast,ufirst,uemail,hideudom,crsdom) {
     var url = '/adm/pickuser?';
     var userdom = getDomainFromSelectbox(formname,udom);
     if (userdom != null) {
@@ -615,7 +615,8 @@
                                 '&ulastelement='+ulast+
                                 '&ufirstelement='+ufirst+
                                 '&uemailelement='+uemail+
-                                '&hideudomelement='+hideudom;
+                                '&hideudomelement='+hideudom+
+                                '&coursedom='+crsdom;
     var title = 'User_Browser';
     var options = 'scrollbars=1,resizable=1,menubar=0';
     options += ',width=700,height=600';
@@ -713,9 +714,11 @@
 }
 
 sub selectuser_link {
-    my ($form,$unameelem,$domelem,$lastelem,$firstelem,$emailelem,$hdomelem,$linktext) = @_;
+    my ($form,$unameelem,$domelem,$lastelem,$firstelem,$emailelem,$hdomelem,
+        $coursedom,$linktext) = @_;
     return '<a href="javascript:openuserbrowser('."'$form','$unameelem','$domelem',".
-           "'$lastelem','$firstelem','$emailelem','$hdomelem'".');">'.$linktext.'</a>';
+           "'$lastelem','$firstelem','$emailelem','$hdomelem','$coursedom'".
+           ');">'.$linktext.'</a>';
 }
 
 sub check_uncheck_jscript {

--raeburn1249591259--