Diff for /loncom/interface/loncreateuser.pm between versions 1.377 and 1.384

version 1.377, 2013/06/04 23:12:08 version 1.384, 2013/12/24 19:15:10
Line 122  sub auth_abbrev { Line 122  sub auth_abbrev {
   
 # ====================================================  # ====================================================
   
 sub portfolio_quota {  sub user_quotas {
     my ($ccuname,$ccdomain) = @_;      my ($ccuname,$ccdomain) = @_;
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
                    'usrt'      => "User Tools",                     'usrt'      => "User Tools",
                    'disk'      => "Disk space allocated to user's portfolio files",  
                    'cuqu'      => "Current quota",                     'cuqu'      => "Current quota",
                    'cust'      => "Custom quota",                     'cust'      => "Custom quota",
                    'defa'      => "Default",                     'defa'      => "Default",
                    'chqu'      => "Change quota",                     'chqu'      => "Change quota",
     );      );
     my ($currquota,$quotatype,$inststatus,$defquota) =      
         &Apache::loncommon::get_user_quota($ccuname,$ccdomain);  
     my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($ccdomain);  
     my ($longinsttype,$showquota,$custom_on,$custom_off,$defaultinfo);  
     if ($inststatus ne '') {  
         if ($usertypes->{$inststatus} ne '') {  
             $longinsttype = $usertypes->{$inststatus};  
         }  
     }  
     $custom_on = ' ';  
     $custom_off = ' checked="checked" ';  
     my $quota_javascript = <<"END_SCRIPT";      my $quota_javascript = <<"END_SCRIPT";
 <script type="text/javascript">  <script type="text/javascript">
 // <![CDATA[  // <![CDATA[
 function quota_changes(caller) {  function quota_changes(caller,context) {
       var customoff = document.getElementById('custom_'+context+'quota_off');
       var customon = document.getElementById('custom_'+context+'quota_on');
       var number = document.getElementById(context+'quota');
     if (caller == "custom") {      if (caller == "custom") {
         if (document.cu.customquota[0].checked) {          if (customoff) {
             document.cu.portfolioquota.value = "";              if (customoff.checked) {
                   number.value = "";
               }
         }          }
     }      }
     if (caller == "quota") {      if (caller == "quota") {
         document.cu.customquota[1].checked = true;          if (customon) {
               customon.checked = true;
           }
     }      }
       return;
 }  }
 // ]]>  // ]]>
 </script>  </script>
 END_SCRIPT  END_SCRIPT
     if ($quotatype eq 'custom') {      my $longinsttype;
         $custom_on = $custom_off;      my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($ccdomain);
         $custom_off = ' ';  
         $showquota = $currquota;  
         if ($longinsttype eq '') {  
             $defaultinfo = &mt('For this user, the default quota would be [_1]'  
                             .' Mb.',$defquota);  
         } else {  
             $defaultinfo = &mt("For this user, the default quota would be [_1]".  
                                " Mb, as determined by the user's institutional".  
                                " affiliation ([_2]).",$defquota,$longinsttype);  
         }  
     } else {  
         if ($longinsttype eq '') {  
             $defaultinfo = &mt('For this user, the default quota is [_1]'  
                             .' Mb.',$defquota);  
         } else {  
             $defaultinfo = &mt("For this user, the default quota of [_1]".  
                                " Mb, is determined by the user's institutional".  
                                " affiliation ([_2]).",$defquota,$longinsttype);  
         }  
     }  
   
     my $output = $quota_javascript."\n".      my $output = $quota_javascript."\n".
                  '<h3>'.$lt{'usrt'}.'</h3>'."\n".                   '<h3>'.$lt{'usrt'}.'</h3>'."\n".
                  &Apache::loncommon::start_data_table();                   &Apache::loncommon::start_data_table();
Line 189  END_SCRIPT Line 165  END_SCRIPT
     if (&Apache::lonnet::allowed('mut',$ccdomain)) {      if (&Apache::lonnet::allowed('mut',$ccdomain)) {
         $output .= &build_tools_display($ccuname,$ccdomain,'tools');          $output .= &build_tools_display($ccuname,$ccdomain,'tools');
     }      }
     if (&Apache::lonnet::allowed('mpq',$ccdomain)) {  
         $output .= '<tr class="LC_info_row">'."\n".      my %titles = &Apache::lonlocal::texthash (
                    '    <td>'.$lt{'disk'}.'</td>'."\n".                      portfolio => "Disk space allocated to user's portfolio files",
                    '  </tr>'."\n".                      author    => "Disk space allocated to user's authoring space (if role assigned)",
                    &Apache::loncommon::start_data_table_row()."\n".                   );
                    '  <td>'.$lt{'cuqu'}.': '.      foreach my $name ('portfolio','author') {
                    $currquota.'&nbsp;Mb.&nbsp;&nbsp;'.          my ($currquota,$quotatype,$inststatus,$defquota) =
                    $defaultinfo.'</td>'."\n".              &Apache::loncommon::get_user_quota($ccuname,$ccdomain,$name);
                    &Apache::loncommon::end_data_table_row()."\n".          if ($longinsttype eq '') { 
                    &Apache::loncommon::start_data_table_row()."\n".              if ($inststatus ne '') {
                    '  <td><span class="LC_nobreak">'.$lt{'chqu'}.                  if ($usertypes->{$inststatus} ne '') {
                    ': <label>'.                      $longinsttype = $usertypes->{$inststatus};
                    '<input type="radio" name="customquota" value="0" '.                  }
                    $custom_off.' onchange="javascript:quota_changes('."'custom'".')"'.              }
                    ' />'.$lt{'defa'}.'&nbsp;('.$defquota.' Mb).</label>&nbsp;'.          }
                    '&nbsp;<label><input type="radio" name="customquota" value="1" '.           my ($showquota,$custom_on,$custom_off,$defaultinfo);
                    $custom_on.'  onchange="javascript:quota_changes('."'custom'".')" />'.          $custom_on = ' ';
                    $lt{'cust'}.':</label>&nbsp;'.          $custom_off = ' checked="checked" ';
                    '<input type="text" name="portfolioquota" size ="5" value="'.          if ($quotatype eq 'custom') {
                    $showquota.'" onfocus="javascript:quota_changes('."'quota'".')" '.              $custom_on = $custom_off;
                    '/>&nbsp;Mb</span></td>'."\n".              $custom_off = ' ';
                    &Apache::loncommon::end_data_table_row()."\n";              $showquota = $currquota;
     }                if ($longinsttype eq '') {
                   $defaultinfo = &mt('For this user, the default quota would be [_1]'
                                 .' MB.',$defquota);
               } else {
                   $defaultinfo = &mt("For this user, the default quota would be [_1]".
                                      " MB, as determined by the user's institutional".
                                      " affiliation ([_2]).",$defquota,$longinsttype);
               }
           } else {
               if ($longinsttype eq '') {
                   $defaultinfo = &mt('For this user, the default quota is [_1]'
                                 .' MB.',$defquota);
               } else {
                   $defaultinfo = &mt("For this user, the default quota of [_1]".
                                      " MB, is determined by the user's institutional".
                                      " affiliation ([_2]).",$defquota,$longinsttype);
               }
           }
   
           if (&Apache::lonnet::allowed('mpq',$ccdomain)) {
               $output .= '<tr class="LC_info_row">'."\n".
                          '    <td>'.$titles{$name}.'</td>'."\n".
                          '  </tr>'."\n".
                          &Apache::loncommon::start_data_table_row()."\n".
                          '  <td>'.$lt{'cuqu'}.': '.
                          $currquota.'&nbsp;MB.&nbsp;&nbsp;'.
                          $defaultinfo.'</td>'."\n".
                          &Apache::loncommon::end_data_table_row()."\n".
                          &Apache::loncommon::start_data_table_row()."\n".
                          '  <td><span class="LC_nobreak">'.$lt{'chqu'}.
                          ': <label>'.
                          '<input type="radio" name="custom_'.$name.'quota" id="custom_'.$name.'quota_off" '.
                          'value="0" '.$custom_off.' onchange="javascript:quota_changes('."'custom','$name'".');"'.
                          ' />'.$lt{'defa'}.'&nbsp;('.$defquota.' MB).</label>&nbsp;'.
                          '&nbsp;<label><input type="radio" name="custom_'.$name.'quota" id="custom_'.$name.'quota_on" '.
                          'value="1" '.$custom_on.'  onchange="javascript:quota_changes('."'custom','$name'".');"'.
                          ' />'.$lt{'cust'}.':</label>&nbsp;'.
                          '<input type="text" name="'.$name.'quota" id="'.$name.'quota" size ="5" '.
                          'value="'.$showquota.'" onfocus="javascript:quota_changes('."'quota','$name'".');"'.
                          ' />&nbsp;MB</span></td>'."\n".
                          &Apache::loncommon::end_data_table_row()."\n";
           }
       }
     $output .= &Apache::loncommon::end_data_table();      $output .= &Apache::loncommon::end_data_table();
     return $output;      return $output;
 }  }
Line 233  sub build_tools_display { Line 251  sub build_tools_display {
                    'official'   => 'Can request creation of official courses',                     'official'   => 'Can request creation of official courses',
                    'unofficial' => 'Can request creation of unofficial courses',                     'unofficial' => 'Can request creation of unofficial courses',
                    'community'  => 'Can request creation of communities',                     'community'  => 'Can request creation of communities',
                      'textbook'   => 'Can request creation of textbook courses',
                    'requestauthor'  => 'Can request author space',                     'requestauthor'  => 'Can request author space',
     );      );
     if ($context eq 'requestcourses') {      if ($context eq 'requestcourses') {
         %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,          %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
                       'requestcourses.official','requestcourses.unofficial',                        'requestcourses.official','requestcourses.unofficial',
                       'requestcourses.community');                        'requestcourses.community','requestcourses.textbook');
         @usertools = ('official','unofficial','community');          @usertools = ('official','unofficial','community','textbook');
         @options =('norequest','approval','autolimit','validate');          @options =('norequest','approval','autolimit','validate');
         %validations = &Apache::lonnet::auto_courserequest_checks($ccdomain);          %validations = &Apache::lonnet::auto_courserequest_checks($ccdomain);
         %reqtitles = &courserequest_titles();          %reqtitles = &courserequest_titles();
Line 428  sub coursereq_externaluser { Line 447  sub coursereq_externaluser {
                    'official'   => 'Can request creation of official courses',                     'official'   => 'Can request creation of official courses',
                    'unofficial' => 'Can request creation of unofficial courses',                     'unofficial' => 'Can request creation of unofficial courses',
                    'community'  => 'Can request creation of communities',                     'community'  => 'Can request creation of communities',
                      'textbook'   => 'Can request creation of textbook courses',
     );      );
   
     %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,      %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
                       'reqcrsotherdom.official','reqcrsotherdom.unofficial',                        'reqcrsotherdom.official','reqcrsotherdom.unofficial',
                       'reqcrsotherdom.community');                        'reqcrsotherdom.community','reqcrsotherdom.textbook');
     @usertools = ('official','unofficial','community');      @usertools = ('official','unofficial','community','textbook');
     @options = ('approval','validate','autolimit');      @options = ('approval','validate','autolimit');
     %validations = &Apache::lonnet::auto_courserequest_checks($cdom);      %validations = &Apache::lonnet::auto_courserequest_checks($cdom);
     my $optregex = join('|',@options);      my $optregex = join('|',@options);
Line 513  sub courserequest_titles { Line 533  sub courserequest_titles {
                                    official   => 'Official',                                     official   => 'Official',
                                    unofficial => 'Unofficial',                                     unofficial => 'Unofficial',
                                    community  => 'Communities',                                     community  => 'Communities',
                                      textbook   => 'Textbook',
                                    norequest  => 'Not allowed',                                     norequest  => 'Not allowed',
                                    approval   => 'Approval by Dom. Coord.',                                     approval   => 'Approval by Dom. Coord.',
                                    validate   => 'With validation',                                     validate   => 'With validation',
Line 550  sub requestauthor_display { Line 571  sub requestauthor_display {
    return %titles;     return %titles;
 }  }
   
   sub requestchange_display {
       my %titles = &Apache::lonlocal::texthash (
                                      approval   => "availability set to 'on' (approval required)", 
                                      automatic  => "availability set to 'on' (automatic approval)",
                                      norequest  => "availability set to 'off'",
      );
      return %titles;
   }
   
 sub curr_requestauthor {  sub curr_requestauthor {
     my ($uname,$udom,$isadv,$inststatuses,$domconfig) = @_;      my ($uname,$udom,$isadv,$inststatuses,$domconfig) = @_;
     return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH'));      return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH'));
Line 970  ENDSCRIPT Line 1000  ENDSCRIPT
             $r->print('</h3>');              $r->print('</h3>');
         }          }
     }      }
     $r->print('<form name="usersrchform" method="post">'.      $r->print('<form name="usersrchform" method="post" action="">'.
               &Apache::loncommon::start_data_table()."\n".                &Apache::loncommon::start_data_table()."\n".
               &Apache::loncommon::start_data_table_header_row()."\n".                &Apache::loncommon::start_data_table_header_row()."\n".
               ' <th> </th>'."\n");                ' <th> </th>'."\n");
Line 1205  ENDFORMINFO Line 1235  ENDFORMINFO
         if ((&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) ||          if ((&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) ||
             (&Apache::lonnet::allowed('mut',$env{'request.role.domain'}))) {              (&Apache::lonnet::allowed('mut',$env{'request.role.domain'}))) {
             # Current user has quota or user tools modification privileges              # Current user has quota or user tools modification privileges
             $portfolioform = '<br />'.&portfolio_quota($ccuname,$ccdomain);              $portfolioform = '<br />'.&user_quotas($ccuname,$ccdomain);
         }          }
         if (&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) {          if ((&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) &&
               ($ccdomain eq $env{'request.role.domain'})) {
             $domroleform = '<br />'.&domainrole_req($ccuname,$ccdomain);              $domroleform = '<br />'.&domainrole_req($ccuname,$ccdomain);
         }          }
         &initialize_authen_forms($ccdomain,$formname);          &initialize_authen_forms($ccdomain,$formname);
Line 1374  ENDCHANGEUSER Line 1405  ENDCHANGEUSER
         my ($isadv,$isauthor) =           my ($isadv,$isauthor) = 
             &Apache::lonnet::is_advanced_user($ccuname,$ccdomain);              &Apache::lonnet::is_advanced_user($ccuname,$ccdomain);
         if ((!$isauthor) &&           if ((!$isauthor) && 
             (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) {              (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))
               && ($env{'request.role.domain'} eq $ccdomain)) {
             $user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain);              $user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain);
         }          }
         $user_text{'auth'} =  &user_authentication($ccuname,$ccdomain,$formname);          $user_text{'auth'} =  &user_authentication($ccuname,$ccdomain,$formname);
         if ((&Apache::lonnet::allowed('mpq',$ccdomain)) ||          if ((&Apache::lonnet::allowed('mpq',$ccdomain)) ||
             (&Apache::lonnet::allowed('mut',$ccdomain))) {              (&Apache::lonnet::allowed('mut',$ccdomain))) {
             # Current user has quota modification privileges              # Current user has quota modification privileges
             $user_text{'quota'} = &portfolio_quota($ccuname,$ccdomain);              $user_text{'quota'} = &user_quotas($ccuname,$ccdomain);
         }          }
         if (!&Apache::lonnet::allowed('mpq',$ccdomain)) {          if (!&Apache::lonnet::allowed('mpq',$ccdomain)) {
             if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {              if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
                 # Get the user's portfolio information  
                 my %portq = &Apache::lonnet::get('environment',['portfolioquota'],  
                                                  $ccdomain,$ccuname);  
                 my %lt=&Apache::lonlocal::texthash(                  my %lt=&Apache::lonlocal::texthash(
                     'dska'  => "Disk space allocated to user's portfolio files",                      'dska'  => "Disk quotas for user's portfolio and authoring space",
                     'youd'  => "You do not have privileges to modify the portfolio quota for this user.",                      'youd'  => "You do not have privileges to modify the portfolio and/or authoring space quotas for this user.",
                     'ichr'  => "If a change is required, contact a domain coordinator for the domain",                      'ichr'  => "If a change is required, contact a domain coordinator for the domain",
                 );                  );
                 $user_text{'quota'} = <<ENDNOPORTPRIV;                  $user_text{'quota'} = <<ENDNOPORTPRIV;
Line 2487  sub update_user_data { Line 2516  sub update_user_data {
     my (%alerts,%rulematch,%inst_results,%curr_rules);      my (%alerts,%rulematch,%inst_results,%curr_rules);
     my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');      my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
     my @usertools = ('aboutme','blog','webdav','portfolio');      my @usertools = ('aboutme','blog','webdav','portfolio');
     my @requestcourses = ('official','unofficial','community');      my @requestcourses = ('official','unofficial','community','textbook');
     my @requestauthor = ('requestauthor');      my @requestauthor = ('requestauthor');
     my ($othertitle,$usertypes,$types) =       my ($othertitle,$usertypes,$types) = 
         &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});          &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
Line 2557  sub update_user_data { Line 2586  sub update_user_data {
         my (%changeHash,%newcustom,%changed,%changedinfo);          my (%changeHash,%newcustom,%changed,%changedinfo);
         if ($uhome ne 'no_host') {          if ($uhome ne 'no_host') {
             if ($context eq 'domain') {              if ($context eq 'domain') {
                 if ($env{'form.customquota'} == 1) {                  foreach my $name ('portfolio','author') {
                     if ($env{'form.portfolioquota'} eq '') {                      if ($env{'form.custom_'.$name.'quota'} == 1) {
                         $newcustom{'quota'} = 0;                          if ($env{'form.'.$name.'quota'} eq '') {
                     } else {                              $newcustom{$name.'quota'} = 0;
                         $newcustom{'quota'} = $env{'form.portfolioquota'};                          } else {
                         $newcustom{'quota'} =~ s/[^\d\.]//g;                              $newcustom{$name.'quota'} = $env{'form.'.$name.'quota'};
                               $newcustom{$name.'quota'} =~ s/[^\d\.]//g;
                           }
                           if (&quota_admin($newcustom{$name.'quota'},\%changeHash,$name)) {
                               $changed{$name.'quota'} = 1;
                           }
                     }                      }
                     $changed{'quota'} = &quota_admin($newcustom{'quota'},\%changeHash);  
                 }                  }
                 foreach my $item (@usertools) {                  foreach my $item (@usertools) {
                     if ($env{'form.custom'.$item} == 1) {                      if ($env{'form.custom'.$item} == 1) {
Line 2578  sub update_user_data { Line 2611  sub update_user_data {
                         $newcustom{$item} = $env{'form.crsreq_'.$item};                          $newcustom{$item} = $env{'form.crsreq_'.$item};
                         if ($env{'form.crsreq_'.$item} eq 'autolimit') {                          if ($env{'form.crsreq_'.$item} eq 'autolimit') {
                             $newcustom{$item} .= '=';                              $newcustom{$item} .= '=';
                             unless ($env{'form.crsreq_'.$item.'_limit'} =~ /\D/) {                              $env{'form.crsreq_'.$item.'_limit'} =~ s/\D+//g;
                               if ($env{'form.crsreq_'.$item.'_limit'}) {
                                 $newcustom{$item} .= $env{'form.crsreq_'.$item.'_limit'};                                  $newcustom{$item} .= $env{'form.crsreq_'.$item.'_limit'};
                             }                              }
                         }                          }
Line 2649  sub update_user_data { Line 2683  sub update_user_data {
         # Check for need to change          # Check for need to change
         my %userenv = &Apache::lonnet::get          my %userenv = &Apache::lonnet::get
             ('environment',['firstname','middlename','lastname','generation',              ('environment',['firstname','middlename','lastname','generation',
              'id','permanentemail','portfolioquota','inststatus','tools.aboutme',               'id','permanentemail','portfolioquota','authorquota','inststatus',
              'tools.blog','tools.webdav','tools.portfolio',               'tools.aboutme','tools.blog','tools.webdav','tools.portfolio',
              'requestcourses.official','requestcourses.unofficial',               'requestcourses.official','requestcourses.unofficial',
              'requestcourses.community','reqcrsotherdom.official',               'requestcourses.community','requestcourses.textbook',
              'reqcrsotherdom.unofficial','reqcrsotherdom.community',               'reqcrsotherdom.official','reqcrsotherdom.unofficial',
                'reqcrsotherdom.community','reqcrsotherdom.textbook',
              'requestauthor'],               'requestauthor'],
               $env{'form.ccdomain'},$env{'form.ccuname'});                $env{'form.ccdomain'},$env{'form.ccuname'});
         my ($tmp) = keys(%userenv);          my ($tmp) = keys(%userenv);
Line 2776  sub update_user_data { Line 2811  sub update_user_data {
                 }                  }
             }              }
         }          }
         my ($quotachanged,$oldportfolioquota,$newportfolioquota,$oldinststatus,          my (%quotachanged,%oldquota,%newquota,%olddefquota,%newdefquota, 
             $newinststatus,$oldisdefault,$newisdefault,%oldsettings,              $oldinststatus,$newinststatus,%oldisdefault,%newisdefault,%oldsettings,
             %oldsettingstext,%newsettings,%newsettingstext,@disporder,              %oldsettingstext,%newsettings,%newsettingstext,@disporder,
             $olddefquota,$oldsettingstatus,$newdefquota,$newsettingstatus);              %oldsettingstatus,%newsettingstatus);
         @disporder = ('inststatus');          @disporder = ('inststatus');
         if ($env{'request.role.domain'} eq $env{'form.ccdomain'}) {          if ($env{'request.role.domain'} eq $env{'form.ccdomain'}) {
             push(@disporder,'requestcourses','requestauthor');              push(@disporder,'requestcourses','requestauthor');
Line 2788  sub update_user_data { Line 2823  sub update_user_data {
         }          }
         push(@disporder,('quota','tools'));          push(@disporder,('quota','tools'));
         $oldinststatus = $userenv{'inststatus'};          $oldinststatus = $userenv{'inststatus'};
         ($olddefquota,$oldsettingstatus) =           foreach my $name ('portfolio','author') {
             &Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus);              ($olddefquota{$name},$oldsettingstatus{$name}) = 
         ($newdefquota,$newsettingstatus) = ($olddefquota,$oldsettingstatus);                  &Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus,$name);
               ($newdefquota{$name},$newsettingstatus{$name}) = ($olddefquota{$name},$oldsettingstatus{$name});
           }
         my %canshow;          my %canshow;
         if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {          if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
             $canshow{'quota'} = 1;              $canshow{'quota'} = 1;
Line 2829  sub update_user_data { Line 2866  sub update_user_data {
                     $changeHash{'inststatus'} = $newinststatus;                      $changeHash{'inststatus'} = $newinststatus;
                     if ($newinststatus ne $oldinststatus) {                      if ($newinststatus ne $oldinststatus) {
                         $changed{'inststatus'} = $newinststatus;                          $changed{'inststatus'} = $newinststatus;
                         ($newdefquota,$newsettingstatus) =                          foreach my $name ('portfolio','author') {
                             &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus);                              ($newdefquota{$name},$newsettingstatus{$name}) =
                                   &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus,$name);
                           }
                     }                      }
                     if (ref($usertypes) eq 'HASH') {                      if (ref($usertypes) eq 'HASH') {
                         $newsettings{'inststatus'} = join(', ',map{ $usertypes->{$_}; } (@inststatuses));                           $newsettings{'inststatus'} = join(', ',map{ $usertypes->{$_}; } (@inststatuses)); 
Line 2844  sub update_user_data { Line 2883  sub update_user_data {
                 $newsettings{'inststatus'} = $othertitle;                  $newsettings{'inststatus'} = $othertitle;
                 if ($newinststatus ne $oldinststatus) {                  if ($newinststatus ne $oldinststatus) {
                     $changed{'inststatus'} = $changeHash{'inststatus'};                      $changed{'inststatus'} = $changeHash{'inststatus'};
                     ($newdefquota,$newsettingstatus) =                      foreach my $name ('portfolio','author') {
                         &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus);                          ($newdefquota{$name},$newsettingstatus{$name}) =
                               &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus,$name);
                       }
                 }                  }
             }              }
         } elsif ($context ne 'selfcreate') {          } elsif ($context ne 'selfcreate') {
             $canshow{'inststatus'} = 1;              $canshow{'inststatus'} = 1;
             $newsettings{'inststatus'} = $oldsettings{'inststatus'};              $newsettings{'inststatus'} = $oldsettings{'inststatus'};
         }          }
         $changeHash{'portfolioquota'} = $userenv{'portfolioquota'};          foreach my $name ('portfolio','author') {
               $changeHash{$name.'quota'} = $userenv{$name.'quota'};
           }
         if ($context eq 'domain') {          if ($context eq 'domain') {
             if ($userenv{'portfolioquota'} ne '') {              foreach my $name ('portfolio','author') {
                 $oldportfolioquota = $userenv{'portfolioquota'};                  if ($userenv{$name.'quota'} ne '') {
                 if ($env{'form.customquota'} == 1) {                      $oldquota{$name} = $userenv{$name.'quota'};
                     if ($env{'form.portfolioquota'} eq '') {                      if ($env{'form.custom_'.$name.'quota'} == 1) {
                         $newportfolioquota = 0;                          if ($env{'form.'.$name.'quota'} eq '') {
                               $newquota{$name} = 0;
                           } else {
                               $newquota{$name} = $env{'form.'.$name.'quota'};
                               $newquota{$name} =~ s/[^\d\.]//g;
                           }
                           if ($newquota{$name} != $oldquota{$name}) {
                               if (&quota_admin($newquota{$name},\%changeHash,$name)) {
                                   $changed{$name.'quota'} = 1;
                               }
                           }
                     } else {                      } else {
                         $newportfolioquota = $env{'form.portfolioquota'};                          if (&quota_admin('',\%changeHash,$name)) {
                         $newportfolioquota =~ s/[^\d\.]//g;                              $changed{$name.'quota'} = 1;
                     }                              $newquota{$name} = $newdefquota{$name};
                     if ($newportfolioquota != $oldportfolioquota) {                              $newisdefault{$name} = 1;
                         $changed{'quota'} = &quota_admin($newportfolioquota,\%changeHash);                          }
                     }                      }
                 } else {                  } else {
                     $changed{'quota'} = &quota_admin('',\%changeHash);                      $oldisdefault{$name} = 1;
                     $newportfolioquota = $newdefquota;                      $oldquota{$name} = $olddefquota{$name};
                     $newisdefault = 1;                      if ($env{'form.custom_'.$name.'quota'} == 1) {
                 }                          if ($env{'form.'.$name.'quota'} eq '') {
             } else {                              $newquota{$name} = 0;
                 $oldisdefault = 1;                          } else {
                 $oldportfolioquota = $olddefquota;                              $newquota{$name} = $env{'form.'.$name.'quota'};
                 if ($env{'form.customquota'} == 1) {                              $newquota{$name} =~ s/[^\d\.]//g;
                     if ($env{'form.portfolioquota'} eq '') {                          }
                         $newportfolioquota = 0;                          if (&quota_admin($newquota{$name},\%changeHash,$name)) {
                               $changed{$name.'quota'} = 1;
                           }
                     } else {                      } else {
                         $newportfolioquota = $env{'form.portfolioquota'};                          $newquota{$name} = $newdefquota{$name};
                         $newportfolioquota =~ s/[^\d\.]//g;                          $newisdefault{$name} = 1;
                     }                      }
                     $changed{'quota'} = &quota_admin($newportfolioquota,\%changeHash);                  }
                   if ($oldisdefault{$name}) {
                       $oldsettingstext{'quota'}{$name} = &get_defaultquota_text($oldsettingstatus{$name});
                   }  else {
                       $oldsettingstext{'quota'}{$name} = &mt('custom quota: [_1] MB',$oldquota{$name});
                   }
                   if ($newisdefault{$name}) {
                       $newsettingstext{'quota'}{$name} = &get_defaultquota_text($newsettingstatus{$name});
                 } else {                  } else {
                     $newportfolioquota = $newdefquota;                      $newsettingstext{'quota'}{$name} = &mt('custom quota: [_1] MB',$newquota{$name});
                     $newisdefault = 1;  
                 }                  }
             }              }
             if ($oldisdefault) {  
                 $oldsettingstext{'quota'} = &get_defaultquota_text($oldsettingstatus);  
             }  
             if ($newisdefault) {  
                 $newsettingstext{'quota'} = &get_defaultquota_text($newsettingstatus);  
             }  
             &tool_changes('tools',\@usertools,\%oldsettings,\%oldsettingstext,\%userenv,              &tool_changes('tools',\@usertools,\%oldsettings,\%oldsettingstext,\%userenv,
                           \%changeHash,\%changed,\%newsettings,\%newsettingstext);                            \%changeHash,\%changed,\%newsettings,\%newsettingstext);
             if ($env{'form.ccdomain'} eq $env{'request.role.domain'}) {              if ($env{'form.ccdomain'} eq $env{'request.role.domain'}) {
                 &tool_changes('requestcourses',\@requestcourses,\%oldsettings,\%oldsettingstext,                  &tool_changes('requestcourses',\@requestcourses,\%oldsettings,\%oldsettingstext,
                               \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);                                \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
                 &tool_changes('requestauthor',\@requestauthor,\%oldsettings,\%oldsettingstext,\%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);                  &tool_changes('requestauthor',\@requestauthor,\%oldsettings,\%oldsettingstext,
                                 \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
             } else {              } else {
                 &tool_changes('reqcrsotherdom',\@requestcourses,\%oldsettings,\%oldsettingstext,                  &tool_changes('reqcrsotherdom',\@requestcourses,\%oldsettings,\%oldsettingstext,
                               \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);                                \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
Line 2909  sub update_user_data { Line 2965  sub update_user_data {
                 $namechanged{$item} = 1;                  $namechanged{$item} = 1;
             }              }
         }          }
         $oldsettings{'quota'} = $oldportfolioquota.' Mb';          foreach my $name ('portfolio','author') {
         $newsettings{'quota'} = $newportfolioquota.' Mb';              $oldsettings{'quota'}{$name} = $oldquota{$name}.' MB';
               $newsettings{'quota'}{$name} = $newquota{$name}.' MB';
           }
         if ((keys(%namechanged) > 0) || (keys(%changed) > 0)) {          if ((keys(%namechanged) > 0) || (keys(%changed) > 0)) {
             my ($chgresult,$namechgresult);              my ($chgresult,$namechgresult);
             if (keys(%changed) > 0) {              if (keys(%changed) > 0) {
Line 3118  sub display_userinfo { Line 3176  sub display_userinfo {
          'generation'     => 'Generation',           'generation'     => 'Generation',
          'id'             => 'Student/Employee ID',           'id'             => 'Student/Employee ID',
          'permanentemail' => 'Permanent e-mail address',           'permanentemail' => 'Permanent e-mail address',
          'quota'          => 'Disk space allocated to portfolio files',           'portfolioquota' => 'Disk space allocated to portfolio files',
            'authorquota'    => 'Disk space allocated to authoring space',
          'blog'           => 'Blog Availability',           'blog'           => 'Blog Availability',
          'webdav'         => 'WebDAV Availability',           'webdav'         => 'WebDAV Availability',
          'aboutme'        => 'Personal Information Page Availability',           'aboutme'        => 'Personal Information Page Availability',
Line 3126  sub display_userinfo { Line 3185  sub display_userinfo {
          'official'       => 'Can Request Official Courses',           'official'       => 'Can Request Official Courses',
          'unofficial'     => 'Can Request Unofficial Courses',           'unofficial'     => 'Can Request Unofficial Courses',
          'community'      => 'Can Request Communities',           'community'      => 'Can Request Communities',
            'textbook'       => 'Can Request Textbook Courses',
          'requestauthor'  => 'Can Request Author Role',           'requestauthor'  => 'Can Request Author Role',
          'inststatus'     => "Affiliation",           'inststatus'     => "Affiliation",
          'prvs'           => 'Previous Value:',           'prvs'           => 'Previous Value:',
Line 3140  sub display_userinfo { Line 3200  sub display_userinfo {
         $r->print('<th><span class="LC_nobreak"><b>'.$lt{'chto'}.'</b></span></th>');          $r->print('<th><span class="LC_nobreak"><b>'.$lt{'chto'}.'</b></span></th>');
         $r->print(&Apache::loncommon::end_data_table_header_row());          $r->print(&Apache::loncommon::end_data_table_header_row());
         my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');          my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
           
   
         foreach my $item (@userinfo) {          foreach my $item (@userinfo) {
             my $value = $env{'form.c'.$item};              my $value = $env{'form.c'.$item};
             #show changes only:              #show changes only:
             unless($value eq $userenv->{$item}){              unless ($value eq $userenv->{$item}){
                 $r->print(&Apache::loncommon::start_data_table_row());                  $r->print(&Apache::loncommon::start_data_table_row());
   
                 $r->print("<td>$lt{$item}</td>\n");                  $r->print("<td>$lt{$item}</td>\n");
                 $r->print('<td>'.$userenv->{$item}.' </td>');                  $r->print("<td>".$userenv->{$item}."</td>\n");
                 $r->print("<td>$value </td>\n");                  $r->print("<td>$value </td>\n");
   
                 $r->print(&Apache::loncommon::end_data_table_row());                  $r->print(&Apache::loncommon::end_data_table_row());
             }              }
         }          }
         foreach my $entry (@{$order}) {          foreach my $entry (@{$order}) {
             if ($canshow->{$entry} && ($newsetting->{$entry} ne $newsetting->{$entry})) {              if ($canshow->{$entry}) {
                 $r->print(&Apache::loncommon::start_data_table_row());                  if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom') || ($entry eq 'requestauthor')) {
                 if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) {                      my @items;
                     foreach my $item (@{$requestcourses}) {                      if ($entry eq 'requestauthor') {
                         $r->print("<td>$lt{$item}</td>\n");                          @items = ($entry);
                         $r->print("<td>$oldsetting->{$item} $oldsettingtext->{$item}</td>\n");                      } else {
                         my $value = $newsetting->{$item}.' '.$newsettingtext->{$item};                          @items = @{$requestcourses};
                         if ($changedhash->{$item}) {                      }
                             $value = '<span class="LC_cusr_emph">'.$value.'</span>';                      foreach my $item (@items) {
                           if (($newsetting->{$item} ne $oldsetting->{$item}) || 
                               ($newsettingtext->{$item} ne $oldsettingtext->{$item})) {
                               $r->print(&Apache::loncommon::start_data_table_row()."\n");  
                               $r->print("<td>$lt{$item}</td>\n");
                               $r->print("<td>".$oldsetting->{$item});
                               if ($oldsettingtext->{$item}) {
                                   if ($oldsetting->{$item}) {
                                       $r->print(' -- ');
                                   }
                                   $r->print($oldsettingtext->{$item});
                               }
                               $r->print("</td>\n");
                               $r->print("<td>".$newsetting->{$item});
                               if ($newsettingtext->{$item}) {
                                   if ($newsetting->{$item}) {
                                       $r->print(' -- ');
                                   }
                                   $r->print($newsettingtext->{$item});
                               }
                               $r->print("</td>\n");
                               $r->print(&Apache::loncommon::end_data_table_row()."\n");
                         }                          }
                         $r->print("<td>$value </td>\n");  
                     }                      }
                 } elsif ($entry eq 'tools') {                  } elsif ($entry eq 'tools') {
                     foreach my $item (@{$usertools}) {                      foreach my $item (@{$usertools}) {
                         $r->print("<td>$lt{$item}</td>\n");                          if ($newsetting->{$item} ne $oldsetting->{$item}) {
                         $r->print("<td>$oldsetting->{$item} $oldsettingtext->{$item}</td>\n");                              $r->print(&Apache::loncommon::start_data_table_row()."\n");
                         my $value = $newsetting->{$item}.' '.$newsettingtext->{$item};                              $r->print("<td>$lt{$item}</td>\n");
                         if ($changedhash->{$item}) {                              $r->print("<td>".$oldsetting->{$item}.' '.$oldsettingtext->{$item}."</td>\n");
                             $value = '<span class="LC_cusr_emph">'.$value.'</span>';                              $r->print("<td>".$newsetting->{$item}.' '.$newsettingtext->{$item}."</td>\n");
                               $r->print(&Apache::loncommon::end_data_table_row()."\n");
                           }
                       }
                   } elsif ($entry eq 'quota') {
                       if ((ref($oldsetting->{$entry}) eq 'HASH') && (ref($oldsettingtext->{$entry}) eq 'HASH') &&
                           (ref($newsetting->{$entry}) eq 'HASH') && (ref($newsettingtext->{$entry}) eq 'HASH')) {
                           foreach my $name ('portfolio','author') {
                               if ($newsetting->{$entry}->{$name} ne $oldsetting->{$entry}->{$name}) {
                                   $r->print(&Apache::loncommon::start_data_table_row()."\n");
                                   $r->print("<td>$lt{$name.$entry}</td>\n");
                                   $r->print("<td>".$oldsettingtext->{$entry}->{$name}."</td>\n");
                                   $r->print("<td>".$newsettingtext->{$entry}->{$name}."</td>\n");
                                   $r->print(&Apache::loncommon::end_data_table_row()."\n");
                               }
                         }                          }
                         $r->print("<td>$value </td>\n");  
                     }                      }
                 } else {                  } else {
                     $r->print("<td>$lt{$entry}</td>\n");                      if ($newsetting->{$entry} ne $oldsetting->{$entry}) {
                     $r->print("<td>$oldsetting->{$entry} $oldsettingtext->{$entry} </td>\n");                          $r->print(&Apache::loncommon::start_data_table_row()."\n");
                     my $value = $newsetting->{$entry}.' '.$newsettingtext->{$entry};                          $r->print("<td>$lt{$entry}</td>\n");
                     if ($changedhash->{$entry}) {                          $r->print("<td>".$oldsetting->{$entry}.' '.$oldsettingtext->{$entry}."</td>\n");
                         $value = '<span class="LC_cusr_emph">'.$value.'</span>';                          $r->print("<td>".$newsetting->{$entry}.' '.$newsettingtext->{$entry}."</td>\n");
                           $r->print(&Apache::loncommon::end_data_table_row()."\n");
                     }                      }
                     $r->print("<td>$value </td>\n");  
                 }                  }
                 $r->print(&Apache::loncommon::end_data_table_row());  
             }              }
         }          }
         $r->print(&Apache::loncommon::end_data_table().'<br />');          $r->print(&Apache::loncommon::end_data_table().'<br />');
Line 3207  sub tool_changes { Line 3296  sub tool_changes {
           (ref($newaccess) eq 'HASH') && (ref($newaccesstext) eq 'HASH'))) {            (ref($newaccess) eq 'HASH') && (ref($newaccesstext) eq 'HASH'))) {
         return;          return;
     }      }
       my %reqdisplay = &requestchange_display();
     if ($context eq 'reqcrsotherdom') {      if ($context eq 'reqcrsotherdom') {
         my @options = ('approval','validate','autolimit');          my @options = ('approval','validate','autolimit');
         my $optregex = join('|',@options);          my $optregex = join('|',@options);
         my %reqdisplay = &courserequest_display();  
         my $cdom = $env{'request.role.domain'};          my $cdom = $env{'request.role.domain'};
         foreach my $tool (@{$usertools}) {          foreach my $tool (@{$usertools}) {
             $oldaccesstext->{$tool} = &mt('No');              $oldaccesstext->{$tool} = &mt("availability set to 'off'");
             $newaccesstext->{$tool} = $oldaccesstext->{$tool};              $newaccesstext->{$tool} = $oldaccesstext->{$tool};
             $changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool};              $changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool};
             my $newop;              my ($newop,$limit);
             if ($env{'form.'.$context.'_'.$tool}) {              if ($env{'form.'.$context.'_'.$tool}) {
                 $newop = $env{'form.'.$context.'_'.$tool};                  $newop = $env{'form.'.$context.'_'.$tool};
                 if ($newop eq 'autolimit') {                  if ($newop eq 'autolimit') {
                     my $limit = $env{'form.'.$context.'_'.$tool.'_limit'};                      $limit = $env{'form.'.$context.'_'.$tool.'_limit'};
                     $limit =~ s/\D+//g;                      $limit =~ s/\D+//g;
                     $newop .= '='.$limit;                      $newop .= '='.$limit;
                 }                  }
Line 3230  sub tool_changes { Line 3319  sub tool_changes {
                     $changed->{$tool}=&tool_admin($tool,$cdom.':'.$newop,                      $changed->{$tool}=&tool_admin($tool,$cdom.':'.$newop,
                                                   $changeHash,$context);                                                    $changeHash,$context);
                     if ($changed->{$tool}) {                      if ($changed->{$tool}) {
                         $newaccesstext->{$tool} = &mt('Yes');                          if ($newop =~ /^autolimit/) {
                               if ($limit) {
                                   $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
                               } else {
                                   $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
                               }
                           } else {
                               $newaccesstext->{$tool} = $reqdisplay{$newop};
                           }
                     } else {                      } else {
                         $newaccesstext->{$tool} = $oldaccesstext->{$tool};                          $newaccesstext->{$tool} = $oldaccesstext->{$tool};
                     }                      }
Line 3241  sub tool_changes { Line 3338  sub tool_changes {
                 my $changedoms;                  my $changedoms;
                 foreach my $req (@curr) {                  foreach my $req (@curr) {
                     if ($req =~ /^\Q$cdom\E\:($optregex\=?\d*)$/) {                      if ($req =~ /^\Q$cdom\E\:($optregex\=?\d*)$/) {
                         $oldaccesstext->{$tool} = &mt('Yes');  
                         my $oldop = $1;                          my $oldop = $1;
                           if ($oldop =~ /^autolimit=(\d*)/) {
                               my $limit = $1;
                               if ($limit) {
                                   $oldaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
                               } else {
                                   $oldaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
                               }
                           } else {
                               $oldaccesstext->{$tool} = $reqdisplay{$oldop};
                           }
                         if ($oldop ne $newop) {                          if ($oldop ne $newop) {
                             $changedoms = 1;                              $changedoms = 1;
                             foreach my $item (@curr) {                              foreach my $item (@curr) {
Line 3276  sub tool_changes { Line 3382  sub tool_changes {
                                 my $limit = $env{'form.'.$context.'_'.$tool.'_limit'};                                  my $limit = $env{'form.'.$context.'_'.$tool.'_limit'};
                                 $limit =~ s/\D+//g;                                  $limit =~ s/\D+//g;
                                 if ($limit) {                                  if ($limit) {
                                     $newaccesstext->{$tool} = &mt('Yes, up to limit of [quant,_1,request] per user.',$limit);                                      $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
                                 } else {                                  } else {
                                     $newaccesstext->{$tool} = &mt('Yes, processed automatically');                                      $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
                                 }                                  }
                             } else {                              } else {
                                 $newaccesstext->{$tool} = $reqdisplay{$env{'form.'.$context.'_'.$tool}};                                  $newaccesstext->{$tool} = $reqdisplay{$env{'form.'.$context.'_'.$tool}};
                             }                              }
                         } else {                          } else {
                             $newaccesstext->{$tool} = &mt('No');                              $newaccesstext->{$tool} = &mt("availability set to 'off'");
                         }                          }
                     }                      }
                 }                  }
Line 3293  sub tool_changes { Line 3399  sub tool_changes {
         return;          return;
     }      }
     foreach my $tool (@{$usertools}) {      foreach my $tool (@{$usertools}) {
         my ($newval,$envkey);          my ($newval,$limit,$envkey);
         $envkey = $context.'.'.$tool;          $envkey = $context.'.'.$tool;
         if ($context eq 'requestcourses') {          if ($context eq 'requestcourses') {
             $newval = $env{'form.crsreq_'.$tool};              $newval = $env{'form.crsreq_'.$tool};
             if ($newval eq 'autolimit') {              if ($newval eq 'autolimit') {
                 $newval .= '='.$env{'form.crsreq_'.$tool.'_limit'};                  $limit = $env{'form.crsreq_'.$tool.'_limit'};
                   $limit =~ s/\D+//g;
                   $newval .= '='.$limit;
             }              }
         } elsif ($context eq 'requestauthor') {          } elsif ($context eq 'requestauthor') {
             $newval = $env{'form.'.$context};              $newval = $env{'form.'.$context};
Line 3308  sub tool_changes { Line 3416  sub tool_changes {
         }          }
         if ($userenv->{$envkey} ne '') {          if ($userenv->{$envkey} ne '') {
             $oldaccess->{$tool} = &mt('custom');              $oldaccess->{$tool} = &mt('custom');
             if ($userenv->{$envkey}) {              if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
                 $oldaccesstext->{$tool} = &mt("availability set to 'on'");                  if ($userenv->{$envkey} =~ /^autolimit=(\d*)$/) {
                       my $currlimit = $1;
                       if ($currlimit eq '') {
                           $oldaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
                       } else {
                           $oldaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$currlimit);
                       }
                   } elsif ($userenv->{$envkey}) {
                       $oldaccesstext->{$tool} = $reqdisplay{$userenv->{$envkey}};
                   } else {
                       $oldaccesstext->{$tool} = &mt("availability set to 'off'");
                   }
             } else {              } else {
                 $oldaccesstext->{$tool} = &mt("availability set to 'off'");                  if ($userenv->{$envkey}) {
                       $oldaccesstext->{$tool} = &mt("availability set to 'on'");
                   } else {
                       $oldaccesstext->{$tool} = &mt("availability set to 'off'");
                   }
             }              }
             $changeHash->{$envkey} = $userenv->{$envkey};              $changeHash->{$envkey} = $userenv->{$envkey};
             if ($env{'form.custom'.$tool} == 1) {              if ($env{'form.custom'.$tool} == 1) {
Line 3320  sub tool_changes { Line 3443  sub tool_changes {
                                                     $context);                                                      $context);
                     if ($changed->{$tool}) {                      if ($changed->{$tool}) {
                         $newaccess->{$tool} = &mt('custom');                          $newaccess->{$tool} = &mt('custom');
                         if ($newval) {                          if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
                             $newaccesstext->{$tool} = &mt("availability set to 'on'");                              if ($newval =~ /^autolimit/) {
                                   if ($limit) {
                                       $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
                                   } else {
                                       $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
                                   }
                               } elsif ($newval) {
                                   $newaccesstext->{$tool} = $reqdisplay{$newval};
                               } else {
                                   $newaccesstext->{$tool} = &mt("availability set to 'off'");
                               }
                         } else {                          } else {
                             $newaccesstext->{$tool} = &mt("availability set to 'off'");                              if ($newval) {
                                   $newaccesstext->{$tool} = &mt("availability set to 'on'");
                               } else {
                                   $newaccesstext->{$tool} = &mt("availability set to 'off'");
                               }
                         }                          }
                     } else {                      } else {
                         $newaccess->{$tool} = $oldaccess->{$tool};                          $newaccess->{$tool} = $oldaccess->{$tool};
                         if ($userenv->{$context.'.'.$tool}) {                          if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
                             $newaccesstext->{$tool} = &mt("availability set to 'on'");                              if ($newval =~ /^autolimit/) {
                                   if ($limit) {
                                       $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
                                   } else {
                                       $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
                                   }
                               } elsif ($newval) {
                                   $newaccesstext->{$tool} = $reqdisplay{$newval};
                               } else {
                                   $newaccesstext->{$tool} = &mt("availability set to 'off'");
                               }
                         } else {                          } else {
                             $newaccesstext->{$tool} = &mt("availability set to 'off'");                              if ($userenv->{$context.'.'.$tool}) {
                                   $newaccesstext->{$tool} = &mt("availability set to 'on'");
                               } else {
                                   $newaccesstext->{$tool} = &mt("availability set to 'off'");
                               }
                         }                          }
                     }                      }
                 } else {                  } else {
Line 3343  sub tool_changes { Line 3494  sub tool_changes {
                     $newaccess->{$tool} = &mt('default');                      $newaccess->{$tool} = &mt('default');
                 } else {                  } else {
                     $newaccess->{$tool} = $oldaccess->{$tool};                      $newaccess->{$tool} = $oldaccess->{$tool};
                     if ($userenv->{$context.'.'.$tool}) {                      if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
                         $newaccesstext->{$tool} = &mt("availability set to 'on'");                          if ($newval =~ /^autolimit/) {
                               if ($limit) {
                                   $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
                               } else {
                                   $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
                               }
                           } elsif ($newval) {
                               $newaccesstext->{$tool} = $reqdisplay{$newval};
                           } else {
                               $newaccesstext->{$tool} = &mt("availability set to 'off'");
                           }
                     } else {                      } else {
                         $newaccesstext->{$tool} = &mt("availability set to 'off'");                          if ($userenv->{$context.'.'.$tool}) {
                               $newaccesstext->{$tool} = &mt("availability set to 'on'");
                           } else {
                               $newaccesstext->{$tool} = &mt("availability set to 'off'");
                           }
                     }                      }
                 }                  }
             }              }
Line 3357  sub tool_changes { Line 3522  sub tool_changes {
                                                 $context);                                                  $context);
                 if ($changed->{$tool}) {                  if ($changed->{$tool}) {
                     $newaccess->{$tool} = &mt('custom');                      $newaccess->{$tool} = &mt('custom');
                     if ($newval) {                      if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
                         $newaccesstext->{$tool} = &mt("availability set to 'on'");                          if ($newval =~ /^autolimit/) {
                               if ($limit) {
                                   $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
                               } else {
                                   $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
                               }
                           } elsif ($newval) {
                               $newaccesstext->{$tool} = $reqdisplay{$newval};
                           } else {
                               $newaccesstext->{$tool} = &mt("availability set to 'off'");
                           }
                     } else {                      } else {
                         $newaccesstext->{$tool} = &mt("availability set to 'off'");                          if ($newval) {
                               $newaccesstext->{$tool} = &mt("availability set to 'on'");
                           } else {
                               $newaccesstext->{$tool} = &mt("availability set to 'off'");
                           }
                     }                      }
                 } else {                  } else {
                     $newaccess->{$tool} = $oldaccess->{$tool};                      $newaccess->{$tool} = $oldaccess->{$tool};
Line 3748  sub enroll_single_student { Line 3927  sub enroll_single_student {
             $startdate,'manual',undef,$env{'request.course.id'},'',$context,              $startdate,'manual',undef,$env{'request.course.id'},'',$context,
             $credits);              $credits);
     if ($enroll_result =~ /^ok/) {      if ($enroll_result =~ /^ok/) {
         $r->print(&mt('<b>[_1]</b> enrolled',$env{'form.ccuname'}.':'.$env{'form.ccdomain'}));          $r->print(&mt('[_1] enrolled','<b>'.$env{'form.ccuname'}.':'.$env{'form.ccdomain'}.'</b>'));
         if ($env{'form.sections'} ne '') {          if ($env{'form.sections'} ne '') {
             $r->print(' '.&mt('in section [_1]',$env{'form.sections'}));              $r->print(' '.&mt('in section [_1]',$env{'form.sections'}));
         }          }
Line 3783  sub get_defaultquota_text { Line 3962  sub get_defaultquota_text {
     my ($settingstatus) = @_;      my ($settingstatus) = @_;
     my $defquotatext;       my $defquotatext; 
     if ($settingstatus eq '') {      if ($settingstatus eq '') {
         $defquotatext = &mt('(default)');          $defquotatext = &mt('default');
     } else {      } else {
         my ($usertypes,$order) =          my ($usertypes,$order) =
             &Apache::lonnet::retrieve_inst_usertypes($env{'form.ccdomain'});              &Apache::lonnet::retrieve_inst_usertypes($env{'form.ccdomain'});
         if ($usertypes->{$settingstatus} eq '') {          if ($usertypes->{$settingstatus} eq '') {
             $defquotatext = &mt('(default)');              $defquotatext = &mt('default');
         } else {          } else {
             $defquotatext = &mt('(default for [_1])',$usertypes->{$settingstatus});              $defquotatext = &mt('default for [_1]',$usertypes->{$settingstatus});
         }          }
     }      }
     return $defquotatext;      return $defquotatext;
Line 3815  sub update_result_form { Line 3994  sub update_result_form {
         $outcome .= '<input type="hidden" name="forcenewuser" value="1" />'."\n";          $outcome .= '<input type="hidden" name="forcenewuser" value="1" />'."\n";
     }      }
     $outcome .= '<input type="hidden" name="phase" value="" />'."\n".      $outcome .= '<input type="hidden" name="phase" value="" />'."\n".
                 '<input type ="hidden" name="currstate" value="" />'."\n".                  '<input type="hidden" name="currstate" value="" />'."\n".
                 '<input type ="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".                  '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".
                 '</form>';                  '</form>';
     return $outcome;      return $outcome;
 }  }
   
 sub quota_admin {  sub quota_admin {
     my ($setquota,$changeHash) = @_;      my ($setquota,$changeHash,$name) = @_;
     my $quotachanged;      my $quotachanged;
     if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {      if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
         # Current user has quota modification privileges          # Current user has quota modification privileges
         if (ref($changeHash) eq 'HASH') {          if (ref($changeHash) eq 'HASH') {
             $quotachanged = 1;              $quotachanged = 1;
             $changeHash->{'portfolioquota'} = $setquota;              $changeHash->{$name.'quota'} = $setquota;
         }          }
     }      }
     return $quotachanged;      return $quotachanged;
Line 4073  sub custom_role_editor { Line 4252  sub custom_role_editor {
     $r->print('<br clear="all" />');      $r->print('<br clear="all" />');
   
     $r->print(<<ENDCCF);      $r->print(<<ENDCCF);
 <form name="form1" method="post">  <form name="form1" method="post" action="">
 <input type="hidden" name="phase" value="set_custom_roles" />  <input type="hidden" name="phase" value="set_custom_roles" />
 <input type="hidden" name="rolename" value="$rolename" />  <input type="hidden" name="rolename" value="$rolename" />
 ENDCCF  ENDCCF
Line 4269  sub set_custom_role { Line 4448  sub set_custom_role {
  $env{'user.name'},   $env{'user.name'},
  $rolename,undef,undef,undef,$context));   $rolename,undef,undef,undef,$context));
     }      }
     $r->print('<p><a href="javascript:backPage(document.customresult,'."'pickrole'".')">'.&mt('Create or edit another custom role').'</a></p><form name="customresult" method="post">');      $r->print(
     $r->print(&Apache::lonhtmlcommon::echo_form_input([]).'</form>');          '<p><a href="javascript:backPage(document.customresult,'."'pickrole'".')">'
          .&mt('Create or edit another custom role')
          .'</a></p>'
          .'<form name="customresult" method="post" action="">'
          .&Apache::lonhtmlcommon::echo_form_input([]).'</form>'
       );
 }  }
   
 # ================================================================ Main Handler  # ================================================================ Main Handler
Line 4748  function updateCols(caller) { Line 4932  function updateCols(caller) {
             document.getElementById('showcolrole').disabled = 'disabled';              document.getElementById('showcolrole').disabled = 'disabled';
         }          }
         if (context == 'domain') {          if (context == 'domain') {
               var quotausageshow = 0;
             if ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') ||              if ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') ||
                 (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community')) {                  (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community')) {
                 document.getElementById('showcolstatus').checked = false;                  document.getElementById('showcolstatus').checked = false;
Line 4767  function updateCols(caller) { Line 4952  function updateCols(caller) {
                 document.getElementById('showcolextent').checked = 'false';                  document.getElementById('showcolextent').checked = 'false';
                 document.getElementById('showextent').style.display='none';                  document.getElementById('showextent').style.display='none';
                 document.getElementById('showcoltextextent').innerHTML = '';                  document.getElementById('showcoltextextent').innerHTML = '';
                   if ((document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'au') ||
                       (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any')) {
                       if (document.getElementById('showcolauthorusage')) {
                           document.getElementById('showcolauthorusage').disabled = '';
                       }
                       if (document.getElementById('showcolauthorquota')) {
                           document.getElementById('showcolauthorquota').disabled = '';
                       }
                       quotausageshow = 1;
                   }
             } else {              } else {
                 document.getElementById('showextent').style.display='block';                  document.getElementById('showextent').style.display='block';
                 document.getElementById('showextent').style.textAlign='left';                  document.getElementById('showextent').style.textAlign='left';
Line 4785  function updateCols(caller) { Line 4980  function updateCols(caller) {
                     }                      }
                 }                  }
             }              }
               if (quotausageshow == 0)  {
                   if (document.getElementById('showcolauthorusage')) {
                       document.getElementById('showcolauthorusage').checked = false;
                       document.getElementById('showcolauthorusage').disabled = 'disabled';
                   }
                   if (document.getElementById('showcolauthorquota')) {
                       document.getElementById('showcolauthorquota').checked = false;
                       document.getElementById('showcolauthorquota').disabled = 'disabled';
                   }
               }
         }          }
     }      }
     return;      return;

Removed from v.1.377  
changed lines
  Added in v.1.384


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>