--- loncom/interface/loncreateuser.pm	2023/11/03 01:12:15	1.470
+++ loncom/interface/loncreateuser.pm	2023/11/05 20:06:04	1.473
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.470 2023/11/03 01:12:15 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.473 2023/11/05 20:06:04 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -279,7 +279,7 @@ sub build_tools_display {
                    'aboutme'    => "Personal Information Page",
                    'webdav'     => "WebDAV access to Authoring Spaces (https)",
                    'editors'    => "Available Editors",
-                   'managers'   => "Co-authors who can add/revoke co-authors",
+                   'managers'   => "Co-authors who can add/revoke roles",
                    'portfolio'  => "Personal User Portfolio",
                    'portaccess' => "Portfolio Shareable",
                    'timezone'   => "Can set Time Zone",
@@ -324,7 +324,8 @@ sub build_tools_display {
         %domconfig =
             &Apache::lonnet::get_dom('configuration',['quotas','authordefaults'],$ccdomain);
         %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,'tools.webdav',
-                                                    'authoreditors','authormanagers');
+                                                    'authoreditors','authormanagers',
+                                                    'domcoord.author');
         @usertools = ('webdav','editors','managers');
         $colspan = ' colspan="2"';
     } else {
@@ -590,7 +591,9 @@ sub build_tools_display {
         } elsif ($item eq 'managers') {
             $output .= '<td'.$colspan.'>'.$custom_access.'</td>'."\n".
                        &Apache::loncommon::end_data_table_row()."\n";
-            unless (&Apache::lonnet::allowed('udp',$ccdomain)) {
+            unless ((&Apache::lonnet::allowed('udp',$ccdomain)) ||
+                    (($userenv{'domcoord.author'} eq 'blocked') &&
+                     (($env{'user.name'} ne $ccuname) || ($env{'user.domain'} ne $ccdomain)))) {
                 $output .=
                     &Apache::loncommon::start_data_table_row()."\n".
                     '<td'.$colspan.'>';
@@ -3227,7 +3230,7 @@ sub update_user_data {
     my @usertools = ('aboutme','blog','portfolio','portaccess','timezone');
     my @requestcourses = ('official','unofficial','community','textbook','placement','lti');
     my @requestauthor = ('requestauthor');
-    my @authordefaults = ('webdav','editors','managers');
+    my @authordefaults = ('webdav','editors');
     my ($othertitle,$usertypes,$types) = 
         &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
     my %canmodify_status =
@@ -3432,12 +3435,17 @@ sub update_user_data {
              'requestcourses.placement','requestcourses.lti',
              'reqcrsotherdom.official','reqcrsotherdom.unofficial',
              'reqcrsotherdom.community','reqcrsotherdom.textbook',
-             'reqcrsotherdom.placement'],
+             'reqcrsotherdom.placement','domcoord.author'],
               $env{'form.ccdomain'},$env{'form.ccuname'});
         my ($tmp) = keys(%userenv);
         if ($tmp =~ /^(con_lost|error)/i) { 
             %userenv = ();
         }
+        unless (($userenv{'domcoord.author'} eq 'blocked') &&
+                (($env{'user.name'} ne $env{'form.ccuname'}) ||
+                 ($env{'user.domain'} ne $env{'form.ccdomain'}))) {
+            push(@authordefaults,'managers');
+        }
         my $no_forceid_alert;
         # Check to see if user information can be changed
         my %domconfig =
@@ -4017,7 +4025,7 @@ sub display_userinfo {
          'prvs'           => 'Previous Value:',
          'chto'           => 'Changed To:',
          'editors'        => "Available Editors in Authoring Space",
-         'managers'       => "Co-authors who can add/revoke co-authors",
+         'managers'       => "Co-authors who can add/revoke roles",
          'edit'           => 'Standard editor (Edit)',
          'xml'            => 'Text editor (EditXML)',
          'daxe'           => 'Daxe editor (Daxe)',
@@ -5498,7 +5506,7 @@ sub display_coauthor_managers {
         }
         $output .= "</p>\n";
         if (@possmanagers) {
-            $output .= '<p>'.&mt('Select manager(s)').': ';
+            $output .= '<p>'.&mt('If checked, can manage').': ';
             foreach my $user (@possmanagers) {
                  my $checked;
                  if (grep(/^\Q$user\E$/,@custommanagers)) {
@@ -6342,7 +6350,7 @@ sub handler {
         if (($permission->{cusr}) && ($context eq 'author')) {
             push(@{$brcrum},
                      {href => '/adm/createuser?action=camanagers',
-                      text => 'Co-authors who manage',
+                      text => 'Co-author Managers',
                       help => 'Author_Manage_Coauthors'});
             if ($env{'form.state'} eq 'process') {
                 push(@{$brcrum},
@@ -6502,6 +6510,15 @@ function updateCols(caller) {
                 document.getElementById('showcolstart').checked = false;
                 document.getElementById('showcolend').checked = false;
             }
+            if (context == 'author') {
+                if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Expired') {
+                    document.getElementById('showcolmanager').checked = false;
+                    document.getElementById('showcolmanager').disabled = 'disabled';
+                } else if (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value != 'aa') {
+                    document.getElementById('showcolmanager').checked = true;
+                    document.getElementById('showcolmanager').disabled = '';
+                }
+            }
         }
     }
     if (caller == 'output') {
@@ -6587,6 +6604,15 @@ function updateCols(caller) {
                 }
             }
         }
+        if (context == 'author') {
+            if (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'aa') {
+                document.getElementById('showcolmanager').checked = false;
+                document.getElementById('showcolmanager').disabled = 'disabled';
+            } else if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value != 'Expired') {
+                document.getElementById('showcolmanager').checked = true;
+                document.getElementById('showcolmanager').disabled = '';
+            }
+        }
     }
     return;
 }
@@ -6892,16 +6918,16 @@ sub print_main_menu {
              linktitle => 'View change log.',
             },
             {
-             linktext => 'Co-authors who can add/revoke co-author roles',
-             icon => 'helpdesk-access.png',
+             linktext => 'Co-author Managers',
+             icon => 'camanager.png',
              #help => 'Coauthor_Management',
              url => '/adm/createuser?action=camanagers',
              permission => $permission->{'author'},
              linktitle => 'Assign/Revoke right to manage co-author roles',
             },
             {
-             linktext => 'Configure coauthor-viewable listing',
-             icon => 'helpdesk-access.png',
+             linktext => 'Configure Co-author Listing',
+             icon => 'coauthors.png',
              #help => 'Coauthor_Settings',
              url => '/adm/createuser?action=calist&forceedit=1',
              permission => ($permission->{'cusr'}),