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

raeburn raeburn at source.lon-capa.org
Sat Jan 21 18:30:19 EST 2017


raeburn		Sat Jan 21 23:30:19 2017 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	loncreateuser.pm 
  Log:
  - For 2.11
    - Backport 1.426, 1.427.
  
  
-------------- next part --------------
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.406.2.8 loncom/interface/loncreateuser.pm:1.406.2.9
--- loncom/interface/loncreateuser.pm:1.406.2.8	Tue Nov 29 13:22:10 2016
+++ loncom/interface/loncreateuser.pm	Sat Jan 21 23:30:18 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.406.2.8 2016/11/29 13:22:10 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.406.2.9 2017/01/21 23:30:18 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -531,84 +531,6 @@
            &Apache::loncommon::end_data_table();
 }
 
-sub domadhocroles {
-    my ($ccuname,$ccdomain) = @_;
-    my $confname = &Apache::lonnet::get_domainconfiguser($env{'request.role.domain'});
-    my %existing=&Apache::lonnet::dump('roles',$env{'request.role.domain'},
-                                       $confname,'rolesdef_');
-    my ($output,$canmodify);
-    if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) {
-        $canmodify = 1;
-    }
-    if (keys(%existing) > 0) {
-        my @current;
-        my $curradhoc = 'adhocroles.'.$env{'request.role.domain'};
-        my %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,$curradhoc);
-        if ($userenv{$curradhoc}) {
-            @current = split(/,/,$userenv{$curradhoc});
-        }
-        if (!$canmodify && !@current) {
-            return;
-        }
-        my %customroles;
-        foreach my $key (keys(%existing)) {
-            if ($key=~/^rolesdef\_(\w+)$/) {
-                my $rolename = $1;
-                my %privs;
-                ($privs{'system'},$privs{'domain'},$privs{'course'}) = split(/\_/,$existing{$key});
-                $customroles{$rolename} = \%privs;
-            }
-        }
-        $output = '<br /><h3>'.
-                  &mt('Ad Hoc Course Roles Selectable via Helpdesk Role').
-                  '</h3>'."\n".
-                  &Apache::loncommon::start_data_table().
-                  &Apache::loncommon::start_data_table_header_row();
-        if ($canmodify) {
-            $output .= '<th>'.&mt('Action').'</th>';
-        }
-        $output .= '<th>'.&mt('Role').'</th>'.
-                   '<th>'.&mt('Privileges in Course').'<th>'.
-                   &Apache::loncommon::end_data_table_header_row();
-        foreach my $key (sort(keys(%customroles))) {
-            next if ((!$canmodify) && (!grep(/^\Q$key\E$/, at current)));
-            $output .= &Apache::loncommon::start_data_table_row();
-            if ($canmodify) {
-                if (grep(/^\Q$key\E$/, at current)) {
-                    $output .= '<td><label>'.
-                               '<input type="checkbox" name="adhocroledel" value="'.$key.'" />'.
-                               &mt('Delete').'</label>'.
-                               '</td>';
-                } else {
-                    $output .= '<td><label>'.
-                               '<input type="checkbox" name="adhocroleadd" value="'.$key.'" />'.
-                               &mt('Add').'</label>'.
-                               '</td>';
-                }
-            }
-            $output .= '<td>'.$key.'</td><td>';
-            foreach my $level ('course','domain','system') {
-                if ($customroles{$key}{$level}) {
-                    my $suffix;
-                    if (($level eq 'domain') || ($level eq 'system')) {
-                        $suffix = ' ('.&mt($level).')';
-                    }
-                    my @privs = split(/:/,$customroles{$key}{$level});
-                    foreach my $item (@privs) {
-                        next if ($item eq '');
-                        my ($priv,$cond) = split(/\&/,$item);
-                        $output .= &Apache::lonnet::plaintext($priv,'Course').$suffix.'<br />';
-                    }
-                }
-            }
-            $output .= '</td>'.
-                       &Apache::loncommon::end_data_table_row();
-        }
-        $output .= &Apache::loncommon::end_data_table();
-    }
-    return $output;
-}
-
 sub courserequest_titles {
     my %titles = &Apache::lonlocal::texthash (
                                    official   => 'Official',
@@ -1357,7 +1279,7 @@
     }
     my $title = '';
     if ($newuser) {
-        my ($portfolioform,$domroleform,$adhocroleform);
+        my ($portfolioform,$domroleform);
         if ((&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) ||
             (&Apache::lonnet::allowed('mut',$env{'request.role.domain'}))) {
             # Current user has quota or user tools modification privileges
@@ -1367,12 +1289,6 @@
             ($ccdomain eq $env{'request.role.domain'})) {
             $domroleform = '<br />'.&domainrole_req($ccuname,$ccdomain);
         }
-        if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) {
-            $adhocroleform = &domadhocroles($ccuname,$ccdomain);
-            if ($adhocroleform) {
-                $adhocroleform = '<br />'.$adhocroleform;
-            }
-        }
         &initialize_authen_forms($ccdomain,$formname);
         my %lt=&Apache::lonlocal::texthash(
                 'lg'             => 'Login Data',
@@ -1483,7 +1399,7 @@
         } else {
             $r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc)); 
         }
-        $r->print($portfolioform.$domroleform.$adhocroleform);
+        $r->print($portfolioform.$domroleform);
         if ($env{'form.action'} eq 'singlestudent') {
             $r->print(&date_sections_select($context,$newuser,$formname,
                                             $permission,$crstype,$ccuname,
@@ -1526,7 +1442,7 @@
             $r->print(&Apache::loncommon::end_data_table());
         }
         $r->print('</div>');
-        my @order = ('auth','quota','tools','requestauthor','adhocroles');
+        my @order = ('auth','quota','tools','requestauthor');
         my %user_text;
         my ($isadv,$isauthor) = 
             &Apache::lonnet::is_advanced_user($ccdomain,$ccuname);
@@ -1536,10 +1452,6 @@
              ($env{'request.role.domain'} eq $ccdomain)) {
             $user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain);
         }
-        if ((&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) ||
-            (&Apache::lonnet::allowed('udp',$env{'request.role.domain'}))) {
-            $user_text{'adhocroles'} = &domadhocroles($ccuname,$ccdomain);
-        }
         $user_text{'auth'} =  &user_authentication($ccuname,$ccdomain,$formname);
         if ((&Apache::lonnet::allowed('mpq',$ccdomain)) ||
             (&Apache::lonnet::allowed('mut',$ccdomain)) ||
@@ -2299,7 +2211,7 @@
                         $result = &mt('Currently Kerberos authenticated, Version [_1].',$krbver);
                     } else {
                         $result = &mt('Currently Kerberos authenticated with domain [_1] Version [_2].',
-                                      $krbver,$krbrealm);
+                                      $krbrealm,$krbver);
                     }
                 } elsif ($currentauth =~ /^internal:/) {
                     $result = &mt('Currently internally authenticated.');
@@ -2924,12 +2836,6 @@
                                                     $newcustom{'requestauthor'},
                                                     \%changeHash,'requestauthor');
                 }
-                if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) {
-                    my @adds = &Apache::loncommon::get_env_multiple('form.adhocroleadd');
-                    if (&adhocrole_changes(\%changeHash)) {
-                        $changed{'adhocroles.'.$env{'request.role.domain'}} = $changeHash{'adhocroles.'.$env{'request.role.domain'}};
-                    }
-                }
             }
             if ($canmodify_status{'inststatus'}) {
                 if (exists($env{'form.inststatus'})) {
@@ -2993,7 +2899,7 @@
              'requestcourses.community','requestcourses.textbook',
              'reqcrsotherdom.official','reqcrsotherdom.unofficial',
              'reqcrsotherdom.community','reqcrsotherdom.textbook',
-             'requestauthor','adhocroles.'.$env{'request.role.domain'}],
+             'requestauthor'],
               $env{'form.ccdomain'},$env{'form.ccuname'});
         my ($tmp) = keys(%userenv);
         if ($tmp =~ /^(con_lost|error)/i) { 
@@ -3132,7 +3038,6 @@
                 &Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus,$name);
             ($newdefquota{$name},$newsettingstatus{$name}) = ($olddefquota{$name},$oldsettingstatus{$name});
         }
-        push(@disporder,'adhocroles');
         my %canshow;
         if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
             $canshow{'quota'} = 1;
@@ -3151,9 +3056,6 @@
         if (&Apache::lonnet::allowed('cau',$env{'form.ccdomain'})) {
             $canshow{'requestauthor'} = 1;
         }
-        if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) {
-            $canshow{'adhocroles'} = 1;
-        }
         my (%changeHash,%changed);
         if ($oldinststatus eq '') {
             $oldsettings{'inststatus'} = $othertitle; 
@@ -3267,14 +3169,6 @@
                 &tool_changes('reqcrsotherdom',\@requestcourses,\%oldsettings,\%oldsettingstext,
                               \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
             }
-            if ($userenv{'adhocroles.'.$env{'request.role.domain'}}) {
-                $changeHash{'adhocroles.'.$env{'request.role.domain'}} = $userenv{'adhocroles.'.$env{'request.role.domain'}};
-            }
-            if (&adhocrole_changes(\%changeHash,\%userenv)) {
-                $changed{'adhocroles'} = 1;
-                $oldsettings{'adhocroles'} = $userenv{'adhocroles.'.$env{'request.role.domain'}};
-                $newsettings{'adhocroles'} = $changeHash{'adhocroles.'.$env{'request.role.domain'}};
-            }
         }
         foreach my $item (@userinfo) {
             if ($env{'form.c'.$item} ne $userenv{$item}) {
@@ -3316,9 +3210,6 @@
           &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
                                             $key,'reload','requestauthor');
                                 }
-                            } elsif ($key eq 'adhocroles') {
-                                $newenvhash{'adhocroles.'.$env{'request.role.domain'}} =
-                                    $changeHash{'adhocroles.'.$env{'request.role.domain'}};
                             } elsif ($key ne 'quota') {
                                 $newenvhash{'environment.tools.'.$key} = 
                                     $changeHash{'tools.'.$key};
@@ -3510,7 +3401,6 @@
          'community'      => 'Can Request Communities',
          'textbook'       => 'Can Request Textbook Courses',
          'requestauthor'  => 'Can Request Author Role',
-         'adhocroles'     => 'Ad Hoc Roles Selectable via Helpdesk Role',
          'inststatus'     => "Affiliation",
          'prvs'           => 'Previous Value:',
          'chto'           => 'Changed To:'
@@ -3876,70 +3766,6 @@
     return;
 }
 
-sub adhocrole_changes {
-    my ($changehashref,$userenv) = @_;
-    my @adds = &Apache::loncommon::get_env_multiple('form.adhocroleadd');
-    my @dels = &Apache::loncommon::get_env_multiple('form.adhocroledel');
-    my (@saved, at added, at alladhoc,$changed);
-    my $adhoc_key = 'adhocroles.'.$env{'request.role.domain'};
-    if (!$env{'form.makeuser'}) {
-        if (ref($userenv) eq 'HASH') {
-            my @current;
-            if ($userenv->{$adhoc_key}) {
-                @current = split(/,/,$userenv->{$adhoc_key});
-                if (@dels) {
-                    foreach my $curr (@current) {
-                        next if ($curr eq '');
-                        unless (grep(/\Q$curr\E$/, at dels)) {
-                            push(@saved,$curr);
-                        }
-                    }
-                    $changed = 1;
-                } else {
-                    @saved = @current;
-                }
-            }
-        }
-    }
-    if (@adds) {
-        my $confname = &Apache::lonnet::get_domainconfiguser($env{'request.role.domain'});
-        my %existing=&Apache::lonnet::dump('roles',$env{'request.role.domain'},
-                                           $confname,'rolesdef_');
-        foreach my $poss (@adds) {
-            if (exists($existing{'rolesdef_'.$poss})) {
-                push(@added,$poss);
-                $changed = 1;
-            }
-        }
-    }
-    if (@added) {
-        if (@saved) {
-            foreach my $add (@added) {
-                unless (grep(/^\Q$add\E$/, at saved)) {
-                    push(@alladhoc,$add);
-                }
-            }
-        } else {
-            push(@alladhoc, at added);
-        }
-    }
-    if (@saved) {
-        push(@alladhoc, at saved);
-    }
-    if (@alladhoc) {
-        my $adhocstr = join(',',sort(@alladhoc));
-        $changehashref->{$adhoc_key} = $adhocstr;
-    } elsif (@dels) {
-        &Apache::lonnet::del('environment',[$adhoc_key],$env{'form.ccdomain'},$env{'form.ccuname'});
-        delete($changehashref->{$adhoc_key});
-        if (($env{'form.ccdomain'} eq $env{'user.domain'}) &&
-            ($env{'form.ccuname'} eq $env{'user.name'})) {
-            &Apache::lonnet::delenv($adhoc_key);
-        }
-    }
-    return $changed;
-}
-
 sub update_roles {
     my ($r,$context,$showcredits) = @_;
     my $now=time;


More information about the LON-CAPA-cvs mailing list