Diff for /loncom/interface/domainprefs.pm between versions 1.160.6.72 and 1.160.6.73

version 1.160.6.72, 2016/09/18 19:24:14 version 1.160.6.73, 2016/10/24 04:01:16
Line 213  sub handler { Line 213  sub handler {
                 'quotas','autoenroll','autoupdate','autocreate',                  'quotas','autoenroll','autoupdate','autocreate',
                 'directorysrch','usercreation','usermodification',                  'directorysrch','usercreation','usermodification',
                 'contacts','defaults','scantron','coursecategories',                  'contacts','defaults','scantron','coursecategories',
                 'serverstatuses','requestcourses','coursedefaults',                  'serverstatuses','requestcourses','helpsettings',
                 'usersessions','loadbalancing','requestauthor',                  'coursedefaults','usersessions','loadbalancing',
                   'requestauthor','selfenrollment','inststatus'],$dom);
                 'selfenrollment','inststatus'],$dom);                  'selfenrollment','inststatus'],$dom);
     my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',      my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
                        'autoupdate','autocreate','directorysrch','contacts',                         'autoupdate','autocreate','directorysrch','contacts',
                        'usercreation','selfcreation','usermodification','scantron',                         'usercreation','selfcreation','usermodification','scantron',
                        'requestcourses','requestauthor','coursecategories',                         'requestcourses','requestauthor','coursecategories',
                        'serverstatuses','coursedefaults','selfenrollment',                         'serverstatuses','helpsettings','coursedefaults',
                        'usersessions');                         'selfenrollment','usersessions');
     my %existing;      my %existing;
     if (ref($domconfig{'loadbalancing'}) eq 'HASH') {      if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
         %existing = %{$domconfig{'loadbalancing'}};          %existing = %{$domconfig{'loadbalancing'}};
Line 413  sub handler { Line 414  sub handler {
                   print => \&print_serverstatuses,                    print => \&print_serverstatuses,
                   modify => \&modify_serverstatuses,                    modify => \&modify_serverstatuses,
                  },                   },
           'helpsettings' =>
                    {text   => 'Support settings',
                     help   => 'Domain_Configuration_Help_Settings',
                     header => [{col1 => 'Help Page Settings (logged-in users)',
                                 col2 => 'Value'},
                                {col1 => 'Helpdesk Roles',
                                 col2 => 'Settings'},],
                     print  => \&print_helpsettings,
                     modify => \&modify_helpsettings,
                    },
         'coursedefaults' =>           'coursedefaults' => 
                  {text => 'Course/Community defaults',                   {text => 'Course/Community defaults',
                   help => 'Domain_Configuration_Course_Defaults',                    help => 'Domain_Configuration_Course_Defaults',
Line 621  sub process_changes { Line 632  sub process_changes {
         $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig);          $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig);
     } elsif ($action eq 'requestauthor') {      } elsif ($action eq 'requestauthor') {
         $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig);          $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig);
       } elsif ($action eq 'helpsettings') {
           $output = &modify_helpsettings($r,$dom,$confname,%domconfig);
     } elsif ($action eq 'coursedefaults') {      } elsif ($action eq 'coursedefaults') {
         $output = &modify_coursedefaults($dom,$lastactref,%domconfig);          $output = &modify_coursedefaults($dom,$lastactref,%domconfig);
     } elsif ($action eq 'selfenrollment') {      } elsif ($action eq 'selfenrollment') {
Line 641  sub print_config_box { Line 654  sub print_config_box {
         $output = &coursecategories_javascript($settings);          $output = &coursecategories_javascript($settings);
     } elsif ($action eq 'defaults') {      } elsif ($action eq 'defaults') {
         $output = &defaults_javascript($settings);           $output = &defaults_javascript($settings); 
       } elsif ($action eq 'helpsettings') {
           my (%privs,%levelscurrent);
           my %full=();
           my %levels=(
                        course => {},
                        domain => {},
                        system => {},
                      );
           my $context = 'domain';
           my $crstype = 'Course';
           my $formname = 'display';
           &Apache::lonuserutils::custom_role_privs(\%privs,\%full,\%levels,\%levelscurrent);
           my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype);
           $output =
               &Apache::lonuserutils::custom_roledefs_js($context,$crstype,$formname,\%full,
                                                         \@templateroles);
     }      }
     $output .=      $output .=
          '<table class="LC_nested_outer">           '<table class="LC_nested_outer">
Line 676  sub print_config_box { Line 705  sub print_config_box {
         $rowtotal ++;          $rowtotal ++;
         if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') ||          if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') ||
             ($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') ||              ($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') ||
             ($action eq 'selfenrollment') || ($action eq 'usersessions') || ($action eq 'directorysrch')) {              ($action eq 'selfenrollment') || ($action eq 'usersessions') || ($action eq 'directorysrch') ||
               ($action eq 'helpsettings')) {
             $output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);              $output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'coursecategories') {          } elsif ($action eq 'coursecategories') {
             $output .= $item->{'print'}->('top',$dom,$item,$settings,\$rowtotal);              $output .= $item->{'print'}->('top',$dom,$item,$settings,\$rowtotal);
Line 731  sub print_config_box { Line 761  sub print_config_box {
             }              }
             $rowtotal ++;              $rowtotal ++;
         } elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') ||          } elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') ||
                   ($action eq 'defaults') || ($action eq 'directorysrch')) {                   ($action eq 'defaults') || ($action eq 'directorysrch') ||
                    ($action eq 'helpsettings')) {
             $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);              $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'login') {          } elsif ($action eq 'login') {
             if ($numheaders == 4) {              if ($numheaders == 4) {
Line 894  sub print_config_box { Line 925  sub print_config_box {
             $output .= $item->{'print'}->($dom,$settings,\$rowtotal);              $output .= $item->{'print'}->($dom,$settings,\$rowtotal);
         } elsif ($action eq 'scantron') {          } elsif ($action eq 'scantron') {
             $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);              $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
         } elsif ($action eq 'helpsettings') {  
             $output .= &print_helpsettings($dom,$confname,$settings,\$rowtotal);  
         }          }
     }      }
     $output .= '      $output .= '
Line 2854  sub print_contacts { Line 2883  sub print_contacts {
 }  }
   
 sub print_helpsettings {  sub print_helpsettings {
     my ($dom,$confname,$settings,$rowtotal) = @_;      my ($position,$dom,$settings,$rowtotal) = @_;
       my $confname = $dom.'-domainconfig';
     my ($datatable,$itemcount);      my ($datatable,$itemcount);
     $itemcount = 1;      if ($position eq 'top') {
     my (%choices,%defaultchecked,@toggles);          $itemcount = 1;
     $choices{'submitbugs'} = &mt('Display link to: [_1]?',          my (%choices,%defaultchecked,@toggles);
                                  &Apache::loncommon::modal_link('http://bugs.loncapa.org',          $choices{'submitbugs'} = &mt('Display link to: [_1]?',
                                  &mt('LON-CAPA bug tracker'),600,500));                                       &Apache::loncommon::modal_link('http://bugs.loncapa.org',
     %defaultchecked = ('submitbugs' => 'on');                                       &mt('LON-CAPA bug tracker'),600,500));
     @toggles = ('submitbugs',);          %defaultchecked = ('submitbugs' => 'on');
           @toggles = ('submitbugs');
     ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,          ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
                                                  \%choices,$itemcount);                                                       \%choices,$itemcount);
           $$rowtotal ++;
       } else {
           my $css_class;
           my %existing=&Apache::lonnet::dump('roles',$dom,$confname,'rolesdef_');
           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;
               }
           }
           my $count = 0;
           my $context = 'domprefs';
           my $crstype = 'Course';
           foreach my $role (sort(keys(%customroles))) {
               my $prefix = 'custhelp'.$count;
               my %full=();
               my %levels= (
                            course => {},
                            domain => {},
                            system => {},
                           );
               my %levelscurrent=(
                                  course => {},
                                  domain => {},
                                  system => {},
                                 );
               &Apache::lonuserutils::custom_role_privs($customroles{$role},\%full,\%levels,\%levelscurrent);
               my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype);
               $css_class = $itemcount%2?' class="LC_odd_row"':'';
               $datatable .= '<tr '.$css_class.'><td><label>'.
                             '<input type="checkbox" name="modifycusthelp" value="'.$count.'" />'.
                             '<input type="hidden" name="custhelprole'.$count.'" value="'.$role.'" />'.
                             &mt('Modify').'</label></td>'.
                             '<td>'.&mt('Existing helpdesk role:').'&nbsp;'.
                             '<b>'.$role.'</b><br />'.
                             &Apache::lonuserutils::custom_role_header($context,$crstype,
                                                                       \@templateroles,$prefix).
                             &Apache::lonuserutils::custom_role_table($crstype,\%full,\%levels,
                                                                      \%levelscurrent,$prefix).
                             '<br /></td>';
               $count ++;
               $itemcount ++;
           }
           $css_class = $itemcount%2?' class="LC_odd_row"':'';
           my $newcust = 'custhelp'.$count;
           my (%privs,%levelscurrent);
           my %full=();
           my %levels= (
                        course => {},
                        domain => {},
                        system => {},
                       );
           &Apache::lonuserutils::custom_role_privs(\%privs,\%full,\%levels,\%levelscurrent);
           my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype);
           $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak"><label>'.
                         '<input type="checkbox" name="newcusthelp" value="'.$count.'" />'. &mt('Add').
                         '</label></span></td>'.
                         '<td><span class="LC_nobreak">'.
                         '<b>'.&mt('Name of new helpdesk role:').'</b>&nbsp;'.
                         '<input type="text" size="20" name="newcusthelpname" value="" />'.
                         '</span><br />'.
                         &Apache::lonuserutils::custom_role_header($context,$crstype,
                                                                   \@templateroles,$newcust).
                         &Apache::lonuserutils::custom_role_table('Course',\%full,\%levels,
                                                                  \%levelscurrent,$newcust).
                         '<br /><br />'.
                         '</td></tr>';
           $count ++;
           $$rowtotal += $count;
       }
     return $datatable;      return $datatable;
 }  }
   
Line 6227  sub modify_login { Line 6330  sub modify_login {
                 if ($domservers{$lonhost}) {                  if ($domservers{$lonhost}) {
                     if (ref($domconfig{'login'}{'headtag'}{$lonhost}) eq 'HASH') {                      if (ref($domconfig{'login'}{'headtag'}{$lonhost}) eq 'HASH') {
                         $currheadtagurls{$lonhost} = $domconfig{'login'}{'headtag'}{$lonhost}{'url'};                          $currheadtagurls{$lonhost} = $domconfig{'login'}{'headtag'}{$lonhost}{'url'};
                         $currexempt{$lonhost} = $domconfig{'login'}{'headtag'}{$lonhost}{'exempt'}                          $currexempt{$lonhost} = $domconfig{'login'}{'headtag'}{$lonhost}{'exempt'};
                     }                      }
                 }                  }
             }              }
Line 10430  sub modify_helpsettings { Line 10533  sub modify_helpsettings {
     my %defaultchecked = ('submitbugs' => 'on');      my %defaultchecked = ('submitbugs' => 'on');
     my @offon = ('off','on');      my @offon = ('off','on');
     my @toggles = ('submitbugs');      my @toggles = ('submitbugs');
       my %current = ('submitbugs' => '');
     if (ref($domconfig{'helpsettings'}) eq 'HASH') {      if (ref($domconfig{'helpsettings'}) eq 'HASH') {
         foreach my $item (@toggles) {          %current = %{$domconfig{'helpsettings'}};
             if ($defaultchecked{$item} eq 'on') {       }
                 if ($domconfig{'helpsettings'}{$item} eq '') {      foreach my $item (@toggles) {
                     if ($env{'form.'.$item} eq '0') {          if ($defaultchecked{$item} eq 'on') { 
                         $changes{$item} = 1;              if ($current{$item} eq '') {
                     }                  if ($env{'form.'.$item} eq '0') {
                 } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {  
                     $changes{$item} = 1;                      $changes{$item} = 1;
                 }                  }
             } elsif ($defaultchecked{$item} eq 'off') {              } elsif ($current{$item} ne $env{'form.'.$item}) {
                 if ($domconfig{'helpsettings'}{$item} eq '') {                  $changes{$item} = 1;
                     if ($env{'form.'.$item} eq '1') {              }
                         $changes{$item} = 1;          } elsif ($defaultchecked{$item} eq 'off') {
                     }              if ($current{$item} eq '') {
                 } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {                  if ($env{'form.'.$item} eq '1') {
                     $changes{$item} = 1;                      $changes{$item} = 1;
                 }                  }
               } elsif ($current{$item} ne $env{'form.'.$item}) {
                   $changes{$item} = 1;
               }
           }
           if (($env{'form.'.$item} eq '0') || ($env{'form.'.$item} eq '1')) {
               $helphash{'helpsettings'}{$item} = $env{'form.'.$item};
           }
       }
   
       my @modify = &Apache::loncommon::get_env_multiple('form.modifycusthelp');
       my $confname = $dom.'-domainconfig';
       my %existing=&Apache::lonnet::dump('roles',$dom,$confname,'rolesdef_');
       if (@modify) {
           foreach my $num (@modify) {
               my $rolename = $env{'form.custhelprole'.$num};
               if ($rolename ne '') {
                   if (exists($existing{'rolesdef_'.$rolename})) {
                       my $prefix = 'custhelp'.$num;
                       my %newprivs = &Apache::lonuserutils::custom_role_update($rolename,$prefix);
                       my %currprivs;
                       ($currprivs{'s'},$currprivs{'d'},$currprivs{'c'}) =
                           split(/\_/,$existing{'rolesdef_'.$rolename});
                       foreach my $level ('c','d','s') {
                           if ($newprivs{$level} ne $currprivs{$level}) {
                               $changes{'customrole'}{$rolename} = 1;
                               my $result = &Apache::lonnet::definerole($rolename,$newprivs{'s'},$newprivs{'d'},
                                                                        $newprivs{'c'},$confname,$dom);
                               last;
                           }
                       }
                   }
             }              }
             if (($env{'form.'.$item} eq '0') || ($env{'form.'.$item} eq '1')) {          }
                 $helphash{'helpsettings'}{$item} = $env{'form.'.$item};      }
       if ($env{'form.newcusthelp'} ne '') {
           my $prefix = 'custhelp'.$env{'form.newcusthelp'};
           my $rolename = $env{'form.newcusthelpname'};
           $rolename=~s/[^A-Za-z0-9]//gs;
           if ($rolename ne '') {
               unless(exists($existing{'rolesdef_'.$rolename})) {
                   my $errmsg;
                   my $result = &Apache::lonuserutils::store_custom_role($rolename,$prefix,
                                                                         $confname,$dom);
                   if ($result eq 'ok') {
                       $changes{'newcustomrole'} = $rolename;
                   } else {
                       $errmsg = ': '.$result;
                   }
             }              }
         }          }
     }      }
   
     my $putresult;      my $putresult;
     if (keys(%changes) > 0) {      if (keys(%changes) > 0) {
         $putresult = &Apache::lonnet::put_dom('configuration',\%helphash,$dom);          $putresult = &Apache::lonnet::put_dom('configuration',\%helphash,$dom);
Line 10464  sub modify_helpsettings { Line 10613  sub modify_helpsettings {
                     $resulttext .= '<li>'.&mt('Display link to: [_1] set to "'.$offon[$env{'form.'.$item}].'".',                      $resulttext .= '<li>'.&mt('Display link to: [_1] set to "'.$offon[$env{'form.'.$item}].'".',
                                               &Apache::loncommon::modal_link('http://bugs.loncapa.org',                                                &Apache::loncommon::modal_link('http://bugs.loncapa.org',
                                               &mt('LON-CAPA bug tracker'),600,500)).'</li>';                                                &mt('LON-CAPA bug tracker'),600,500)).'</li>';
                   } elsif ($item eq 'customrole') {
                       if (ref($changes{'customrole'}) eq 'HASH') {
                           foreach my $role (sort(keys(%{$changes{'customrole'}}))) {
                               $resulttext .= '<li>'.&mt('Existing custom role modified: [_1]',
                                                        $role).'</li>';
                           }
                       }
                   } elsif ($item eq 'newcustomrole') {
                       $resulttext .= '<li>'.&mt('New custom role added: [_1]',
                                                 $changes{'newcustomrole'}).'</li>';
                 }                  }
             }              }
             $resulttext .= '</ul>';              $resulttext .= '</ul>';

Removed from v.1.160.6.72  
changed lines
  Added in v.1.160.6.73


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