Diff for /loncom/interface/lonpreferences.pm between versions 1.43 and 1.51

version 1.43, 2004/05/25 22:00:21 version 1.51, 2004/12/22 11:58:32
Line 92  sub des_decrypt { Line 92  sub des_decrypt {
 ################################################################  ################################################################
 #         Language Change Subroutines                          #  #         Language Change Subroutines                          #
 ################################################################  ################################################################
   
   sub wysiwygchanger {
       my $r = shift;
       my %userenv = &Apache::lonnet::get
           ('environment',['wysiwygeditor']);
       my $offselect='';
       my $onselect='checked="1"';
       if ($userenv{'wysiwygeditor'}) {
    $onselect='';
    $offselect='checked="1"';
       }
       my $switchoff=&mt('Disable WYSIWYG editor');
       my $switchon=&mt('Enable WYSIWYG editor');
       $r->print(<<ENDLSCREEN);
   <form name="server" action="/adm/preferences" method="post">
   <input type="hidden" name="action" value="set_wysiwyg" />
   <br />
   <input type="radio" name="wysiwyg" value="off" $onselect /> $switchoff<br />
   <input type="radio" name="wysiwyg" value="on" $offselect /> $switchon
   ENDLSCREEN
       $r->print('<br /><input type="submit" value="'.&mt('Change').'" />');
   }
   
   
   sub verify_and_change_wysiwyg {
       my $r = shift;
       my $newsetting=$ENV{'form.wysiwyg'};
       &Apache::lonnet::put('environment',{'wysiwygeditor' => $newsetting});
       &Apache::lonnet::appenv('environment.wysiwygeditor' => $newsetting);
       $r->print('<p>'.&mt('Setting WYSIWYG editor to:').' '.&mt($newsetting).'</p>');
   }
   
   ################################################################
   #         Language Change Subroutines                          #
   ################################################################
 sub languagechanger {  sub languagechanger {
     my $r = shift;      my $r = shift;
     my $user       = $ENV{'user.name'};      my $user       = $ENV{'user.name'};
Line 142  $message Line 177  $message
 ENDVCSCREEN  ENDVCSCREEN
 }  }
   
   ################################################################
   #         Roles Page Preference Change Subroutines         #
   ################################################################
   sub rolesprefchanger {
       my $r = shift;
       my $user       = $ENV{'user.name'};
       my $domain     = $ENV{'user.domain'};
       my %userenv = &Apache::lonnet::get
           ('environment',['recentroles','recentrolesn']);
       my $hotlist_flag=$userenv{'recentroles'};
       my $hotlist_n=$userenv{'recentrolesn'};
       my $checked;
       if ($hotlist_flag) {
    $checked = 'checked="checked"';
       }
       
       if (!$hotlist_n) { $hotlist_n=3; }
       my $options;
       for (my $i=1; $i<10; $i++) {
    my $select;
    if ($hotlist_n == $i) { $select = 'selected="selected"'; }
    $options .= "<option $select>$i</option>\n";
       }
   
       $r->print(<<ENDSCREEN);
   <p>Some LON-CAPA users have a long list of roles. The Recent Roles Hotlist
   feature keeps track of the last N roles which have been
   visited and places a table of these at the top of the roles page.
   People with very few roles should leave this feature disabled.
   </p>
   
   <form name="server" action="/adm/preferences" method="post">
   <input type="hidden" name="action" value="verify_and_change_rolespref" />
   <br />Enable Recent Roles Hotlist:
   <input type="checkbox" $checked name="recentroles" value="true" />
   <br />Number of roles in Hotlist:
   <select name="recentrolesn" size="1">
   $options
   </select>
   <br />
   <input type="submit" value="Change" />
   </form>
   ENDSCREEN
   }
   
   sub verify_and_change_rolespref {
       my $r = shift;
       my $user       = $ENV{'user.name'};
       my $domain     = $ENV{'user.domain'};
   # Recent Roles Hotlist Flag
       my $hotlist_flag  = $ENV{'form.recentroles'};
       my $hotlist_n  = $ENV{'form.recentrolesn'};
       my $message='';
       if ($hotlist_flag) {
           &Apache::lonnet::put('environment',{'recentroles' => $hotlist_flag});
           &Apache::lonnet::appenv('environment.recentroles' => $hotlist_flag);
           $message='Recent Roles Hotlist is Enabled';
       } else {
           &Apache::lonnet::del('environment',['recentroles']);
           &Apache::lonnet::delenv('environment\.recentroles');
           $message='Recent Roles Hotlist is Disabled';
       }
       if ($hotlist_n) {
           &Apache::lonnet::put('environment',{'recentrolesn' => $hotlist_n});
           &Apache::lonnet::appenv('environment.recentrolesn' => $hotlist_n);
           if ($hotlist_flag) {
               $message.="<br />Display $hotlist_n Most Recent Roles\n";
           }
       }
   
       $r->print(<<ENDRPSCREEN);
   </p>
   $message
   ENDRPSCREEN
   }
   
   
   
 ################################################################  ################################################################
 #         Anonymous Discussion Name Change Subroutines         #  #         Anonymous Discussion Name Change Subroutines         #
Line 787  sub handler { Line 899  sub handler {
     return OK if $r->header_only;      return OK if $r->header_only;
     #      #
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['action']);                                              ['action','wysiwyg','returnurl']);
     #      #
     &Apache::lonhtmlcommon::clear_breadcrumbs();      &Apache::lonhtmlcommon::clear_breadcrumbs();
     &Apache::lonhtmlcommon::add_breadcrumb      &Apache::lonhtmlcommon::add_breadcrumb
Line 833  sub handler { Line 945  sub handler {
                       }));                        }));
   
     push (@Options,({ action   => 'changemsgforward',      push (@Options,({ action   => 'changemsgforward',
                       linktext => 'Change Message Forwarding',                        linktext => 'Change Message Forwarding and Notification Addresses',
                       text     => 'and Notification Addresses',  
                       href     => '/adm/preferences',                        href     => '/adm/preferences',
                       help     => 'Prefs_Forwarding',                        help     => 'Prefs_Forwarding',
                       breadcrumb =>                         breadcrumb => 
Line 853  sub handler { Line 964  sub handler {
     push (@Options,{ action => 'none',       push (@Options,{ action => 'none', 
                      linktext =>                       linktext =>
                          q{Edit the 'About Me' Personal Information Screen},                           q{Edit the 'About Me' Personal Information Screen},
        help => 'Prefs_About_Me',
                      href => $aboutmeaction});                       href => $aboutmeaction});
     push (@Options,({ action => 'changecolors',      push (@Options,({ action => 'changecolors',
                       linktext => 'Change Color Scheme',                        linktext => 'Change Color Scheme',
Line 873  sub handler { Line 985  sub handler {
     push (@Options,({ action => 'changelanguages',      push (@Options,({ action => 'changelanguages',
                       linktext => 'Change Language Preferences',                        linktext => 'Change Language Preferences',
                       href => '/adm/preferences',                        href => '/adm/preferences',
         help => 'Prefs_Language',
                       breadcrumb=>                        breadcrumb=>
                           { href => '/adm/preferences?action=changelanguages',                            { href => '/adm/preferences?action=changelanguages',
                             text => 'Change Language'},                              text => 'Change Language'},
Line 885  sub handler { Line 998  sub handler {
                       printmenu => 'yes',                        printmenu => 'yes',
                       subroutine=>\&verify_and_change_languages, }                        subroutine=>\&verify_and_change_languages, }
                     ));                      ));
       push (@Options,({ action => 'changewysiwyg',
                         linktext => 'Change WYSIWYG Editor Preferences',
                         href => '/adm/preferences',
                         breadcrumb => 
                               { href => '/adm/preferences?action=changewysiwyg',
                                 text => 'Change WYSIWYG Preferences'},
                         subroutine => \&wysiwygchanger,
                     },
                       { action => 'set_wysiwyg',
                         breadcrumb =>
                             { href => '/adm/preferences?action=changewysiwyg',
                               text => 'Change WYSIWYG Preferences'},
                         printmenu => 'yes',
                         subroutine => \&verify_and_change_wysiwyg, }
                       ));
     push (@Options,({ action => 'changediscussions',      push (@Options,({ action => 'changediscussions',
                       linktext => 'Change Discussion Display Preferences',                        linktext => 'Change Discussion Display Preferences',
                       href => '/adm/preferences',                        href => '/adm/preferences',
                         help => 'Change_Discussion_Display',
                       breadcrumb =>                         breadcrumb => 
                             { href => '/adm/preferences?action=changediscussions',                              { href => '/adm/preferences?action=changediscussions',
                               text => 'Change Discussion Preferences'},                                text => 'Change Discussion Preferences'},
Line 901  sub handler { Line 1030  sub handler {
                       subroutine => \&verify_and_change_discussion, }                        subroutine => \&verify_and_change_discussion, }
                     ));                      ));
                                                 
     if ($ENV{'user.name'} =~ /^(albertel|koretemey|korte|hallmat3|turtle)$/) {      push (@Options,({ action   => 'changerolespref',
                         linktext => 'Change Roles Page Preferences',
                         href     => '/adm/preferences',
                         subroutine => \&rolesprefchanger,
                         breadcrumb =>
                             { href => '/adm/preferences?action=changerolespref',
                               text => 'Change Roles Pref'},
                         },
                       { action   => 'verify_and_change_rolespref',
                         subroutine => \&verify_and_change_rolespref,
                         breadcrumb =>
                             { href => '/adm/preferences?action=changerolespref',
                               text => 'Change Roles Preferences'},
                         printmenu => 'yes',
                         }));
   
   
       if ($ENV{'user.name'} =~ /^(albertel|fox|foxr|koretemey|korte|hallmat3|turtle)$/) {
         push (@Options,({ action => 'debugtoggle',          push (@Options,({ action => 'debugtoggle',
                           printmenu => 'yes',                            printmenu => 'yes',
                           subroutine => \&toggle_debug,                            subroutine => \&toggle_debug,
Line 914  sub handler { Line 1060  sub handler {
 </head>  </head>
 ENDHEADER  ENDHEADER
     my $call = undef;      my $call = undef;
       my $help = undef;
     my $printmenu = 'yes';      my $printmenu = 'yes';
     foreach my $option (@Options) {      foreach my $option (@Options) {
         if ($option->{'action'} eq $ENV{'form.action'}) {          if ($option->{'action'} eq $ENV{'form.action'}) {
Line 923  ENDHEADER Line 1070  ENDHEADER
                 &Apache::lonhtmlcommon::add_breadcrumb                  &Apache::lonhtmlcommon::add_breadcrumb
                     ($option->{'breadcrumb'});                      ($option->{'breadcrumb'});
             }              }
       $help=$option->{'help'};
         }          }
     }      }
     $r->print(&Apache::loncommon::bodytag('Change Preferences'));      $r->print(&Apache::loncommon::bodytag('Change Preferences'));
     $r->print(&Apache::lonhtmlcommon::breadcrumbs      $r->print(&Apache::lonhtmlcommon::breadcrumbs
               (undef,'Change Preferences'));                (undef,'Change Preferences',$help));
     if (defined($call)) {      if (defined($call)) {
         $call->($r);          $call->($r);
     }      }
     if ($printmenu eq 'yes') {      if (($printmenu eq 'yes') && (!$ENV{'form.returnurl'})) {
         my $optionlist = '<table cellpadding="5">';          my $optionlist = '<table cellpadding="5">';
         if ($ENV{'user.name'} =~           if ($ENV{'user.name'} =~ 
                          /^(albertel|kortemey|korte|hallmat3|turtle)$/                           /^(albertel|kortemey|fox|foxr|korte|hallmat3|turtle)$/
             ) {              ) {
             push (@Options,({ action => 'debugtoggle',              push (@Options,({ action => 'debugtoggle',
                               linktext => 'Toggle Debug Messages',                                linktext => 'Toggle Debug Messages',
Line 951  ENDHEADER Line 1099  ENDHEADER
                 $optiontext .=                   $optiontext .= 
                     '<a href="'.$option->{'href'}.                      '<a href="'.$option->{'href'}.
                     '?action='.$option->{'action'}.'">'.                      '?action='.$option->{'action'}.'">'.
                     $option->{'linktext'}.'</a>';                      &mt($option->{'linktext'}).'</a>';
             }              }
             if (exists($option->{'text'})) {              if (exists($option->{'text'})) {
                 $optiontext .= ' '.$option->{'text'};                  $optiontext .= ' '.&mt($option->{'text'});
             }              }
             if ($optiontext ne '') {              if ($optiontext ne '') {
                 $optiontext = '<font size="+1">'.$optiontext.'</font>';                   $optiontext = '<font size="+1">'.$optiontext.'</font>'; 
Line 971  ENDHEADER Line 1119  ENDHEADER
         }          }
         $optionlist .= '</table>';          $optionlist .= '</table>';
         $r->print($optionlist);          $r->print($optionlist);
       } elsif ($ENV{'form.returnurl'}) {
    $r->print('<br /><a href="'.$ENV{'form.returnurl'}.'"><font size="+1">'.
     &mt('Return').'</font></a>');
     }      }
     $r->print(<<ENDFOOTER);      $r->print(<<ENDFOOTER);
 </body>  </body>

Removed from v.1.43  
changed lines
  Added in v.1.51


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