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

raeburn raeburn at source.lon-capa.org
Sun Nov 13 10:47:05 EST 2016


raeburn		Sun Nov 13 15:47:05 2016 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	loncreateuser.pm 
  Log:
  - For 2.11
    - Backport 1.420, 1.421, 1.422
  
  
-------------- next part --------------
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.406.2.6 loncom/interface/loncreateuser.pm:1.406.2.7
--- loncom/interface/loncreateuser.pm:1.406.2.6	Fri Nov 11 02:13:51 2016
+++ loncom/interface/loncreateuser.pm	Sun Nov 13 15:47:04 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.406.2.6 2016/11/11 02:13:51 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.406.2.7 2016/11/13 15:47:04 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -751,7 +751,7 @@
     } elsif ($env{'form.action'} eq 'accesslogs') {
         $helpitem = 'Domain_User_Access_Logs';
     }
-    my %breadcrumb_text = &singleuser_breadcrumb($crstype);
+    my %breadcrumb_text = &singleuser_breadcrumb($crstype,$context,$defdom);
     if ($env{'form.action'} eq 'custom') {
         push(@{$brcrum},
                  {href=>"javascript:backPage(document.crtuser)",       
@@ -779,6 +779,7 @@
                     'srst' => 'Search for a user and enroll as a student',
                     'srme' => 'Search for a user and enroll as a member',
                     'srad' => 'Search for a user and modify/add user information or roles',
+                    'srvu' => 'Search for a user and view user information and roles',
                     'srva' => 'Search for a user and view access log information',
 		    'usr'  => "Username",
                     'dom'  => "Domain",
@@ -834,6 +835,9 @@
             }
         } elsif ($env{'form.action'} eq 'accesslogs') {
             $actiontext = $lt{'srva'};
+        } elsif (($env{'form.action'} eq 'singleuser') &&
+                 ($context eq 'domain') && (!&Apache::lonnet::allowed('mau',$defdom))) {
+            $actiontext = $lt{'srvu'};
         }
         $r->print("<h3>$actiontext</h3>");
         if ($env{'form.origform'} ne 'crtusername') {
@@ -927,7 +931,9 @@
     } else {
         $output = '<p>'.$userpicker.'</p>';
     }
-    if (($env{'form.phase'} eq '') && ($env{'form.action'} ne 'accesslogs')) {
+    if (($env{'form.phase'} eq '') && ($env{'form.action'} ne 'accesslogs') &&
+        (!(($env{'form.action'} eq 'singleuser') && ($context eq 'domain') &&
+        (!&Apache::lonnet::allowed('mau',$env{'request.role.domain'}))))) {
         my $defdom=$env{'request.role.domain'};
         my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');
         my %lt=&Apache::lonlocal::texthash(
@@ -1044,7 +1050,9 @@
                                        'stusrch'        => "User Search to enroll student",
                                        'memsrch'        => "User Search to enroll member",
                                        'srcva'          => "Search for a user and view access log information",
+                                       'usrvu'          => "User Search to view user roles",
                                        'usel'           => "Select a user to add/modify roles",
+                                       'suvr'           => "Select a user to view roles",
                                        'stusel'         => "Select a user to enroll as a student",
                                        'memsel'         => "Select a user to enroll as a member",
                                        'vacsel'         => "Select a user to view access log",
@@ -1057,7 +1065,7 @@
     if ($context eq 'requestcrs') {
         $r->print('<div>');
     } else {
-        my %breadcrumb_text = &singleuser_breadcrumb($crstype);
+        my %breadcrumb_text = &singleuser_breadcrumb($crstype,$context,$srch->{'srchdomain'});
         my $helpitem;
         if ($env{'form.action'} eq 'singleuser') {
             $helpitem = 'Course_Change_Privileges';
@@ -1077,9 +1085,19 @@
                   );
         $r->print(&Apache::loncommon::start_page('User Management',$jscript,{bread_crumbs => $brcrum}));
         if ($env{'form.action'} eq 'singleuser') {
-            $r->print("<b>$lt{'usrch'}</b><br />");
+            my $readonly;
+            if (($context eq 'domain') && (!&Apache::lonnet::allowed('mau',$srch->{'srchdomain'}))) {
+                $readonly = 1;
+                $r->print("<b>$lt{'usrvu'}</b><br />");
+            } else {
+                $r->print("<b>$lt{'usrch'}</b><br />");
+            }
             $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context,undef,$crstype));
-            $r->print('<h3>'.$lt{'usel'}.'</h3>');
+            if ($readonly) {
+                $r->print('<h3>'.$lt{'suvr'}.'</h3>');
+            } else {
+                $r->print('<h3>'.$lt{'usel'}.'</h3>');
+            }
         } elsif ($env{'form.action'} eq 'singlestudent') {
             $r->print($jscript."<b>");
             if ($crstype eq 'Community') {
@@ -1273,7 +1291,7 @@
 
     my $js = &validation_javascript($context,$ccdomain,$pjump_def,$crstype,
                                $groupslist,$newuser,$formname,\%loaditem);
-    my %breadcrumb_text = &singleuser_breadcrumb($crstype);
+    my %breadcrumb_text = &singleuser_breadcrumb($crstype,$context,$ccdomain);
     my $helpitem = 'Course_Change_Privileges';
     if ($env{'form.action'} eq 'singlestudent') {
         $helpitem = 'Course_Add_Student';
@@ -1648,7 +1666,7 @@
 }
 
 sub singleuser_breadcrumb {
-    my ($crstype) = @_;
+    my ($crstype,$context,$domain) = @_;
     my %breadcrumb_text;
     if ($env{'form.action'} eq 'singlestudent') {
         if ($crstype eq 'Community') {
@@ -1656,16 +1674,21 @@
         } else {
             $breadcrumb_text{'search'} = 'Enroll a student';
         }
-        $breadcrumb_text{'userpicked'} = 'Select a user',
-        $breadcrumb_text{'modify'} = 'Set section/dates',
+        $breadcrumb_text{'userpicked'} = 'Select a user';
+        $breadcrumb_text{'modify'} = 'Set section/dates';
     } elsif ($env{'form.action'} eq 'accesslogs') {
         $breadcrumb_text{'search'} = 'View access logs for a user';
-        $breadcrumb_text{'userpicked'} = 'Select a user',
-        $breadcrumb_text{'activity'} = 'Activity',
+        $breadcrumb_text{'userpicked'} = 'Select a user';
+        $breadcrumb_text{'activity'} = 'Activity';
+    } elsif (($env{'form.action'} eq 'singleuser') && ($context eq 'domain') &&
+             (!&Apache::lonnet::allowed('mau',$domain))) {
+        $breadcrumb_text{'search'} = "View user's roles";
+        $breadcrumb_text{'userpicked'} = 'Select a user';
+        $breadcrumb_text{'modify'} = 'User roles';
     } else {
         $breadcrumb_text{'search'} = 'Create/modify a user';
-        $breadcrumb_text{'userpicked'} = 'Select a user',
-        $breadcrumb_text{'modify'} = 'Set user role',
+        $breadcrumb_text{'userpicked'} = 'Select a user';
+        $breadcrumb_text{'modify'} = 'Set user role';
     }
     return %breadcrumb_text;
 }
@@ -1830,11 +1853,12 @@
         my $class='Unknown';
         my $credits='';
         my $csec;
-        if ($area =~ m{^/($match_domain)/($match_courseid)} ) {
+        if ($area =~ m{^/($match_domain)/($match_courseid)}) {
             $class='Course';
             my ($coursedom,$coursedir) = ($1,$2);
             my $cid = $1.'_'.$2;
             # $1.'_'.$2 is the course id (eg. 103_12345abcef103l3).
+            next if ($envkey =~ m{^/$match_domain/$match_courseid/[A-Za-z0-9]+_gr$});
             my %coursedata=
                 &Apache::lonnet::coursedescription($cid);
             if ($coursedir =~ /^$match_community$/) {
@@ -1994,7 +2018,8 @@
             $rolepriv{$envkey}='edit';
         } else {
             if ($context eq 'domain') {
-                if (&Apache::lonnet::allowed('vur',$ccdomain)) {
+                if ((&Apache::lonnet::allowed('vur',$ccdomain)) &&
+                    ($envkey=~m{^/$ccdomain/})) {
                     $rolepriv{$envkey}='view';
                 }
             } elsif ($context eq 'course') {
@@ -2680,7 +2705,7 @@
                   $jsback."\n".
                   '// ]]>'."\n".
                   '</script>'."\n";
-    my %breadcrumb_text = &singleuser_breadcrumb($crstype);
+    my %breadcrumb_text = &singleuser_breadcrumb($crstype,$context,$env{'form.ccdomain'});
     push (@{$brcrum},
              {href => "javascript:backPage(document.userupdate)",
               text => $breadcrumb_text{'search'},
@@ -6800,7 +6825,7 @@
     my $form = 'document.accesslog';
 
 # set breadcrumbs
-    my %breadcrumb_text = &singleuser_breadcrumb();
+    my %breadcrumb_text = &singleuser_breadcrumb('','domain',$udom);
     push (@{$brcrum},
         {href => "javascript:backPage($form)",
          text => $breadcrumb_text{'search'}});
@@ -7748,18 +7773,20 @@
                                 .&mt("Click 'Search'")
                                 .'</li></ul><br />';
                 } else {
-                    my $helplink = ' href="javascript:helpMenu('."'display'".')"';
-                    $response .= '<br /><br />';
-                    if ($context eq 'requestcrs') {
-                        $response .= &mt("You are not authorized to define 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);
+                    unless (($context eq 'domain') && ($env{'form.action'} eq 'singleuser')) {
+                        my $helplink = ' href="javascript:helpMenu('."'display'".')"';
+                        $response .= '<br /><br />';
+                        if ($context eq 'requestcrs') {
+                            $response .= &mt("You are not authorized to define 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 />';
                     }
-                    $response .= '<br />'
-                                 .&mt('Please contact the [_1]helpdesk[_2] if you need to create a new user.'
-                                    ,' <a'.$helplink.'>'
-                                    ,'</a>')
-                                 .'<br />';
                 }
             }
         }


More information about the LON-CAPA-cvs mailing list