Diff for /loncom/interface/lonpreferences.pm between versions 1.42 and 1.45

version 1.42, 2004/05/11 10:42:41 version 1.45, 2004/06/09 01:20:07
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 634  sub discussionchanger { Line 669  sub discussionchanger {
     my $user       = $ENV{'user.name'};      my $user       = $ENV{'user.name'};
     my $domain     = $ENV{'user.domain'};      my $domain     = $ENV{'user.domain'};
     my %userenv = &Apache::lonnet::get      my %userenv = &Apache::lonnet::get
         ('environment',['discdisplay']);          ('environment',['discdisplay','discmarkread']);
     my $discdisplay=$userenv{'discdisplay'};      my $discdisp = 'allposts';
     my $discchange = 'unread';      my $discmark = 'onmark';
     my $alllong = &mt('all posts');  
     my $unreadlong = &mt('only unread posts');      if (defined($userenv{'discdisplay'})) {
     my $discbutton = $unreadlong;          unless ($userenv{'discdisplay'} eq '') { 
     my $currdisc = $alllong;              $discdisp = $userenv{'discdisplay'};
     if ($discdisplay eq 'unread') {          }
         $discchange = 'allposts';  
         $discbutton = $alllong;  
         $currdisc = $unreadlong;  
     }      }
     $r->print(<<ENDLSCREEN);      if (defined($userenv{'discmarkread'})) {
           unless ($userenv{'discdisplay'} eq '') { 
               $discmark = $userenv{'discmarkread'};
           }
       }
   
       my $newdisp = 'unread';
       my $newmark = 'ondisp';
   
       my $function = &Apache::loncommon::get_users_function();
       my $color = &Apache::loncommon::designparm($function.'.tabbg',
                                                       $ENV{'user.domain'});
       my %lt = &Apache::lonlocal::texthash(
           'pref' => 'Display Preference',
           'curr' => 'Current setting ',
           'actn' => 'Action',
           'sdpf' => 'Set display preferences for discussion posts for both bulletin boards and individual resources in all your courses.',
           'prca' => 'Preferences can be set that determine',
           'whpo' => 'Which posts are displayed when you display a bulletin board or resource, and',
           'unwh' => 'Under what circumstances posts are identfied as "New"',
           'allposts' => 'All posts',
           'unread' => 'New posts only',
           'ondisp' => 'Once displayed',
           'onmark' => 'Once marked as read',
           'disa' => 'Posts displayed?',
           'npmr' => 'New posts cease to be identified as "New"?',
           'thde'  => 'The preferences you set here can be overridden within each individual discussion.',
           'chgt' => 'Change to '
       );
       my $dispchange = $lt{'unread'};
       my $markchange = $lt{'ondisp'};
       my $currdisp = $lt{'allposts'};
       my $currmark = $lt{'onmark'};
   
       if ($discdisp eq 'unread') {
           $dispchange = $lt{'allposts'};
           $currdisp = $lt{'unread'};
           $newdisp = 'allposts';
       }
   
       if ($discmark eq 'ondisp') {
           $markchange = $lt{'onmark'};
           $currmark = $lt{'ondisp'};
           $newmark = 'onmark';
       }
       
       $r->print(<<"END");
 <form name="server" action="/adm/preferences" method="post">  <form name="server" action="/adm/preferences" method="post">
 <input type="hidden" name="action" value="verify_and_change_discussion" />  <input type="hidden" name="action" value="verify_and_change_discussion" />
 <br />  <br />
 ENDLSCREEN  $lt{'sdpf'}<br/> $lt{'prca'}  <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li></ol> 
     $r->print(  <br />
 &mt('You can set a display preference for discussion posts for both bulletin boards and individual resources in all your courses.').'<br/>'.  <br />
 &mt('This default preference can be overridden within each individual discussion.').'<br/><br />'.  <table border="0" cellpadding="0" cellspacing="0">
 &mt('Your discussion post display preference is currently set to display').' '.$currdisc.    <tr>
 '.<br /><br /><input type="hidden" name="discdisplay" value="'.    <td width="100%" bgcolor="#000000">
 $discchange.'" /><input type="submit" value="'.     <table width="100%" border="0" cellpadding="1" cellspacing="0">
 &mt('Change to display').' '.$discbutton.'" /></form>'      <tr>
     );       <td width="100%" bgcolor="#000000">
         <table border="0" cellpadding="3" cellspacing="3" bgcolor="#FFFFFF">
          <tr bgcolor="$color">
           <td><b>$lt{'pref'}</b></td>
           <td><b>$lt{'curr'}</b></td>
           <td><b>$lt{'actn'}?</b></td>
          </tr>
          <tr bgcolor="#dddddd">
          <td>$lt{'disa'}</td>
          <td>$lt{$discdisp}</td>
          <td><input type="checkbox" name="discdisp" /><input type="hidden" name="newdisp" value="$newdisp" />&nbsp;$lt{'chgt'} "$dispchange"</td>
         </tr><tr bgcolor="#eeeeee">
          <td>$lt{'npmr'}</td>
          <td>$lt{$discmark}</td>
          <td><input type="checkbox" name="discmark" /><input type="hidden" name="newmark" value="$newmark" />&nbsp;$lt{'chgt'} "$markchange"</td>
         </tr>
        </table>
       </td>
      </tr>
     </table>
    </td>
   </tr>
   </table>
   <br />
   <br />
   <input type="submit" name="sub" value="Store Changes" />
   <br />
   <br />
   Note: $lt{'thde'}
   </form>
   END
 }  }
                                                                                                                                                                                                                                   
 sub verify_and_change_discussion {  sub verify_and_change_discussion {
     my $r = shift;      my $r = shift;
     my $user       = $ENV{'user.name'};      my $user     = $ENV{'user.name'};
     my $domain     = $ENV{'user.domain'};      my $domain   = $ENV{'user.domain'};
 # Discussion  
     my $discdisplay  = $ENV{'form.discdisplay'};  
     my $message='';      my $message='';
     if ($discdisplay eq 'unread') {      if (defined($ENV{'form.discdisp'}) ) {
         &Apache::lonnet::put('environment',{'discdisplay' => $discdisplay});          my $newdisp  = $ENV{'form.newdisp'};
         &Apache::lonnet::appenv('environment.discdisplay' => $discdisplay);          if ($newdisp eq 'unread') {
         $message='Discussions set to display only unread posts';              $message .='In discussions: only new posts will be displayed.<br/>';
     } else {              &Apache::lonnet::put('environment',{'discdisplay' => $newdisp});
         &Apache::lonnet::del('environment',['discdisplay']);              &Apache::lonnet::appenv('environment.discdisplay' => $newdisp);
         &Apache::lonnet::delenv('environment\.discdisplay');          } else {
         $message='Discussions set to display all posts';              $message .= 'In discussions: all posts will be displayed.<br/>';
               &Apache::lonnet::del('environment',['discdisplay']);
               &Apache::lonnet::delenv('environment\.discdisplay');
           }
       }
       if (defined($ENV{'form.discmark'}) ) {
           my $newmark = $ENV{'form.newmark'};
           if ($newmark eq 'ondisp') {
              $message.='In discussions: new posts will be cease to be identified as "new" after display.<br/>';
               &Apache::lonnet::put('environment',{'discmarkread' => $newmark});
               &Apache::lonnet::appenv('environment.discmarkread' => $newmark);
           } else {
               $message.='In discussions: posts will be identified as "new" until marked as read by the reader.<br/>';
               &Apache::lonnet::del('environment',['discmarkread']);
               &Apache::lonnet::delenv('environment\.discmarkread');
           }
     }      }
     $r->print(<<ENDVCSCREEN);      $r->print(<<ENDVCSCREEN);
 </p>  </p>
Line 701  sub handler { Line 822  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 767  sub handler { Line 888  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 787  sub handler { Line 909  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 799  sub handler { Line 922  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',
                       breadcrumb =>                         breadcrumb => 
                             { href => '/adm/preferences?action=changediscussions',                              { href => '/adm/preferences?action=changediscussions',
                               text => 'Change Discussions'},                                text => 'Change Discussion Preferences'},
                       subroutine => \&discussionchanger,                        subroutine => \&discussionchanger,
                   },                    },
                     { action => 'verify_and_change_discussion',                      { action => 'verify_and_change_discussion',
                       breadcrumb =>                        breadcrumb =>
                           { href => '/adm/preferences?action=changediscussions',                            { href => '/adm/preferences?action=changediscussions',
                             text => 'Change Discussions'},                              text => 'Change Discussion Preferences'},
                       printmenu => 'yes',                        printmenu => 'yes',
                       subroutine => \&verify_and_change_discussion, }                        subroutine => \&verify_and_change_discussion, }
                     ));                      ));
Line 845  ENDHEADER Line 983  ENDHEADER
     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|korte|hallmat3|turtle)$/
Line 885  ENDHEADER Line 1023  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.42  
changed lines
  Added in v.1.45


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