Diff for /loncom/interface/lonpreferences.pm between versions 1.95 and 1.101

version 1.95, 2006/12/06 22:22:37 version 1.101, 2007/05/02 01:33:49
Line 280  ENDVCSCREEN Line 280  ENDVCSCREEN
 ################################################################  ################################################################
 sub rolesprefchanger {  sub rolesprefchanger {
     my $r = shift;      my $r = shift;
       my $role    = ($env{'user.adv'} ? 'Role' : 'Course');
       my $lc_role = ($env{'user.adv'} ? 'role' : 'course');
     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
Line 314  sub rolesprefchanger { Line 316  sub rolesprefchanger {
         $roles_check_list .=          $roles_check_list .=
     &Apache::loncommon::start_data_table().      &Apache::loncommon::start_data_table().
     &Apache::loncommon::start_data_table_header_row().      &Apache::loncommon::start_data_table_header_row().
     "<th>".&mt('Freeze Role')."</th>".      "<th>".&mt('Freeze '.$role)."</th>".
     "<th>".&mt('Role')."</td>".      "<th>".&mt($role)."</td>".
     &Apache::loncommon::end_data_table_header_row().      &Apache::loncommon::end_data_table_header_row().
     "\n";      "\n";
  my $count;   my $count;
Line 339  sub rolesprefchanger { Line 341  sub rolesprefchanger {
     }      }
   
     $r->print('      $r->print('
 <p>'.&mt('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>'.&mt('Some LON-CAPA users have a long list of '.$lc_role.'s. The Recent '.$role.'s Hotlist feature keeps track of the last N '.$lc_role.'s which have been visited and places a table of these at the top of the '.$lc_role.'s page. People with very few '.$lc_role.'s should leave this feature disabled.').'
 </p>  </p>
 <form name="prefs" action="/adm/preferences" method="POST">  <form name="prefs" action="/adm/preferences" method="POST">
 <input type="hidden" name="action" value="verify_and_change_rolespref" />  <input type="hidden" name="action" value="verify_and_change_rolespref" />
 <br /><label>'.&mt('Enable Recent Roles Hotlist:').'  <br /><label>'.&mt('Enable Recent '.$role.'s Hotlist:').'
 <input type="checkbox" '.$checked.' name="recentroles" value="true" /></label>  <input type="checkbox" '.$checked.' name="recentroles" value="true" /></label>
 <br />'.&mt('Number of roles in Hotlist:').'  <br />'.&mt('Number of '.$role.'s in Hotlist:').'
 <select name="recentrolesn" size="1">  <select name="recentrolesn" size="1">
 '.$options.'  '.$options.'
 </select>  </select>
 <p>'.&mt('This list below can be used to <q>freeze</q> roles on your screen. Those marked as frozen will not be removed from the list, even if they have not been used recently.').'  <p>'.&mt('This list below can be used to <q>freeze</q> '.$lc_role.'s on your screen. Those marked as frozen will not be removed from the list, even if they have not been used recently.').'
 </p>  </p>
 '.$roles_check_list.'  '.$roles_check_list.'
 <br />  <br />
Line 389  sub rolespref_get_role_text { Line 391  sub rolespref_get_role_text {
   
 sub verify_and_change_rolespref {  sub verify_and_change_rolespref {
     my $r = shift;      my $r = shift;
       my $role = ($env{'user.adv'} ? 'Role' : 'Course');
     my $user       = $env{'user.name'};      my $user       = $env{'user.name'};
     my $domain     = $env{'user.domain'};      my $domain     = $env{'user.domain'};
 # Recent Roles Hotlist Flag  # Recent Roles Hotlist Flag
Line 398  sub verify_and_change_rolespref { Line 401  sub verify_and_change_rolespref {
     if ($hotlist_flag) {      if ($hotlist_flag) {
         &Apache::lonnet::put('environment',{'recentroles' => $hotlist_flag});          &Apache::lonnet::put('environment',{'recentroles' => $hotlist_flag});
         &Apache::lonnet::appenv('environment.recentroles' => $hotlist_flag);          &Apache::lonnet::appenv('environment.recentroles' => $hotlist_flag);
         $message=&mt('Recent Roles Hotlist is Enabled');          $message=&mt('Recent '.$role.'s Hotlist is Enabled');
     } else {      } else {
         &Apache::lonnet::del('environment',['recentroles']);          &Apache::lonnet::del('environment',['recentroles']);
         &Apache::lonnet::delenv('environment\.recentroles');          &Apache::lonnet::delenv('environment\.recentroles');
         $message=&mt('Recent Roles Hotlist is Disabled');          $message=&mt('Recent '.$role.'s Hotlist is Disabled');
     }      }
     if ($hotlist_n) {      if ($hotlist_n) {
         &Apache::lonnet::put('environment',{'recentrolesn' => $hotlist_n});          &Apache::lonnet::put('environment',{'recentrolesn' => $hotlist_n});
         &Apache::lonnet::appenv('environment.recentrolesn' => $hotlist_n);          &Apache::lonnet::appenv('environment.recentrolesn' => $hotlist_n);
         if ($hotlist_flag) {          if ($hotlist_flag) {
             $message.="<br />".              $message.="<br />".
  &mt('Display [_1] Most Recent Roles',$hotlist_n)."\n";   &mt('Display [_1] Most Recent '.$role.'s',$hotlist_n)."\n";
         }          }
     }      }
   
Line 431  sub verify_and_change_rolespref { Line 434  sub verify_and_change_rolespref {
 # Unset any roles that were previously frozen but aren't in list  # Unset any roles that were previously frozen but aren't in list
     foreach my $role_key (sort(keys(%recent_roles))) {      foreach my $role_key (sort(keys(%recent_roles))) {
         if (($frozen_roles{$role_key}) && (!exists($freeze{$role_key}))) {          if (($frozen_roles{$role_key}) && (!exists($freeze{$role_key}))) {
     $message .= "<br />".&mt('Unfreezing Role: [_1]',$role_text{$role_key})."\n";      $message .= "<br />".&mt('Unfreezing '.$role.': [_1]',$role_text{$role_key})."\n";
     &Apache::lonhtmlcommon::store_recent('roles',$role_key,' ',0);      &Apache::lonhtmlcommon::store_recent('roles',$role_key,' ',0);
         }          }
     }      }
Line 439  sub verify_and_change_rolespref { Line 442  sub verify_and_change_rolespref {
 # Freeze selected roles  # Freeze selected roles
     foreach my $role_key (@freeze_list) {      foreach my $role_key (@freeze_list) {
         if (!$frozen_roles{$role_key}) {          if (!$frozen_roles{$role_key}) {
              $message .= "<br />".&mt('Freezing Role: [_1]',$role_text{$role_key})."\n";               $message .= "<br />".&mt('Freezing '.$role.': [_1]',$role_text{$role_key})."\n";
              &Apache::lonhtmlcommon::store_recent('roles',               &Apache::lonhtmlcommon::store_recent('roles',
                                           $role_key,' ',1);                                            $role_key,' ',1);
         }          }
Line 513  ENDVCSCREEN Line 516  ENDVCSCREEN
 }  }
   
 ################################################################  ################################################################
   #                     Icon Subroutines                         #
   ################################################################
   sub iconchanger {
       my $r = shift;
       my $user       = $env{'user.name'};
       my $domain     = $env{'user.domain'};
       my %userenv = &Apache::lonnet::get
           ('environment',['icons']);
       my $iconic='checked="checked"';
       my $classic='';
       my $onlyicon='';
       if ($userenv{'icons'} eq 'classic') {
          $classic='checked="checked"';
          $iconic='';
       }
       if ($userenv{'icons'} eq 'iconsonly') {
          $onlyicon='checked="checked"';
          $iconic='';
       }
       my $useicons=&mt('Use icons and text');
       my $usebuttons=&mt('Use buttons and text');
       my $useicononly=&mt('Use icons only');
       my $change=&mt('Change');
       $r->print(<<ENDSCREEN);
   <form name="prefs" action="/adm/preferences" method="post">
   <input type="hidden" name="action" value="verify_and_change_icons" />
   <label><input type="radio" name="menumode" value="iconic" $iconic /> $useicons</label><br />
   <label><input type="radio" name="menumode" value="classic" $classic /> $usebuttons</label><br />
   <label><input type="radio" name="menumode" value="iconsonly" $onlyicon /> $useicononly</label><br />
   <input type="submit" value="$change" />
   </form>
   ENDSCREEN
   }
   
   sub verify_and_change_icons {
       my $r = shift;
       my $user       = $env{'user.name'};
       my $domain     = $env{'user.domain'};
       my $newicons  = $env{'form.menumode'};
   
       &Apache::lonnet::put('environment',{'icons' => $newicons});
       &Apache::lonnet::appenv('environment.icons' => $newicons);
       $r->print(&mt('Set menu mode to [_1].',$newicons));
   }
   
   ################################################################
 #         Message Forward                                      #  #         Message Forward                                      #
 ################################################################  ################################################################
   
Line 842  sub jscript_send { Line 891  sub jscript_send {
   
 sub client_form {  sub client_form {
     my ($caller,$hexkey,$currentpass,$defdom) = @_;      my ($caller,$hexkey,$currentpass,$defdom) = @_;
       my %lt=&Apache::lonlocal::texthash(
                   'email' => 'EMail Address',
                   'username' => 'Username',
                   'domain' => 'Domain',
                   'currentpass' => 'Current Password',
                   'newpass' => 'New Password',
                   'confirmpass' => 'Confirm Password',
                   'changepass' => 'Change Password');
   
     my $output = qq|      my $output = qq|
 <form name="client" >  <form name="client" >
 <table>  <table>
 |;  |;
     if ($caller eq 'reset_by_email') {      if ($caller eq 'reset_by_email') {
         $output .= qq|          $output .= qq|
 <tr><td align="right"> E-mail address:                        </td>  <tr><td class="LC_preferences_labeltext"><label for="email">$lt{'email'}</label>:</td>
     <td><input type="text" name="email" size="15" /> </td></tr>      <td><input type="text" name="email" size="30" /> </td></tr>
 <tr><td align="right"> Username:                        </td>  <tr><td class="LC_preferences_labeltext"><label for="uname">$lt{'username'}</label>:</td>
     <td>      <td>
      <input type="text" name="uname" size="10" />       <input type="text" name="uname" size="15" />
      <input type="hidden" name="currentpass" value="$currentpass" />       <input type="hidden" name="currentpass" value="$currentpass" />
     </td></tr>      </td></tr>
 <tr><td align="right"> Domain:                               </td>  <tr><td class="LC_preferences_labeltext"><label for="udom">$lt{'udom'}</label>:</td>
     <td>      <td>
 |;  |;
         $output .= &Apache::loncommon::select_dom_form($defdom,'udom').'          $output .= &Apache::loncommon::select_dom_form($defdom,'udom').'
Line 864  sub client_form { Line 922  sub client_form {
 ';  ';
     } else {      } else {
         $output .= qq|          $output .= qq|
 <tr><td align="right"> Current password:                      </td>  <tr><td class="LC_preferences_labeltext"><label for="currentpass">$lt{'currentpass'}</label></td>
     <td><input type="password" name="currentpass" size="10"/> </td></tr>      <td><input type="password" name="currentpass" size="10"/> </td></tr>
 |;  |;
     }      }
     $output .= <<"ENDFORM";      $output .= <<"ENDFORM";
 <tr><td align="right"> New password:                          </td>  <tr><td class="LC_preferences_labeltext"><label for="newpass_1">$lt{'newpass'}</label></td>
     <td><input type="password" name="newpass_1" size="10"  /> </td></tr>      <td><input type="password" name="newpass_1" size="10"  /> </td></tr>
 <tr><td align="right"> Confirm password:                      </td>  <tr><td class="LC_preferences_labeltext"><label for="newpass_2">$lt{'confirmpass'}</label></td>
     <td><input type="password" name="newpass_2" size="10"  /> </td></tr>      <td><input type="password" name="newpass_2" size="10"  /> </td></tr>
 <tr><td colspan="2" align="center">  <tr><td colspan="2" align="center">
     <input type="button" value="Change Password" onClick="send();">      <input type="button" value="$lt{'changepass'}" onClick="send();">
 </table>  </table>
 <input type="hidden" name="ukey_cpass"  value="$hexkey->{'ukey_cpass'}" />  <input type="hidden" name="ukey_cpass"  value="$hexkey->{'ukey_cpass'}" />
 <input type="hidden" name="lkey_cpass"  value="$hexkey->{'lkey_cpass'}" />  <input type="hidden" name="lkey_cpass"  value="$hexkey->{'lkey_cpass'}" />
Line 925  sub verify_and_change_password { Line 983  sub verify_and_change_password {
         if ($user ne '' && $domain ne '') {          if ($user ne '' && $domain ne '') {
             $homeserver = &Apache::lonnet::homeserver($user,$domain);              $homeserver = &Apache::lonnet::homeserver($user,$domain);
             if ($homeserver eq 'no_host') {              if ($homeserver eq 'no_host') {
         &passwordchanger($r,"<p>\n<font color='#ff0000'>ERROR</font>".          &passwordchanger($r,"<p>\n<span class='LC_error'>".
                          "Invalid username and/or domain .\n</p>",                           &mt("Invalid username and/or domain")."</span>\n</p>",
                          $caller,$mailtoken);                           $caller,$mailtoken);
                 return 1;                  return 1;
             }              }
         } else {          } else {
             &passwordchanger($r,"<p>\n<font color='#ff0000'>ERROR</font>".              &passwordchanger($r,"<p>\n<span class='LC_error'>".
                              "Username and Domain were blank.\n</p>",                               &mt("Username and domain were blank")."</span>\n</p>",
                              $caller,$mailtoken);                               $caller,$mailtoken);
             return 1;              return 1;
         }          }
Line 945  sub verify_and_change_password { Line 1003  sub verify_and_change_password {
     # Check for authentication types that allow changing of the password.      # Check for authentication types that allow changing of the password.
     if ($currentauth !~ /^(unix|internal):/) {      if ($currentauth !~ /^(unix|internal):/) {
         if ($caller eq 'reset_by_email') {          if ($caller eq 'reset_by_email') {
             &passwordchanger($r,"<p>\n<font color='#ff0000'>ERROR</font>".              &passwordchanger($r,"<p>\n<span class='LC_error'>".
                              "Authentication type for this user can not be changed by this mechanism..\n</p>",                               &mt("Authentication type for this user can not be changed by this mechanism").
                                "</span>\n</p>",
                               $caller,$mailtoken);                                $caller,$mailtoken);
             return 1;              return 1;
         } else {          } else {
Line 962  sub verify_and_change_password { Line 1021  sub verify_and_change_password {
     unless (defined($currentpass) &&       unless (defined($currentpass) && 
     defined($newpass1)    &&       defined($newpass1)    && 
     defined($newpass2)    ){      defined($newpass2)    ){
  &passwordchanger($r,"<p>\n<font color='#ff0000'>ERROR</font>".   &passwordchanger($r,"<p>\n<span class='LC_error'>".
  "One or more password fields were blank.\n</p>",$caller,$mailtoken);   &mt("One or more password fields were blank").
                            "</span>\n</p>",$caller,$mailtoken);
  return;   return;
     }      }
     # Get the keys      # Get the keys
Line 975  sub verify_and_change_password { Line 1035  sub verify_and_change_password {
         if ($caller eq 'reset_by_email') {          if ($caller eq 'reset_by_email') {
             $tryagain_text = &mt('Please try again later.');              $tryagain_text = &mt('Please try again later.');
         }          }
           my $unable=&mt("Unable to retrieve saved token for password decryption");
  $r->print(<<ENDERROR);   $r->print(<<ENDERROR);
 <p>  <p>
 <font color="#ff0000">ERROR:</font> Unable to retrieve stored token for  <span class="LC_error">$unable.  $tryagain_text</span>
 password decryption.  $tryagain_text  
 </p>  </p>
 ENDERROR  ENDERROR
         # Probably should log an error here          # Probably should log an error here
Line 994  ENDERROR Line 1054  ENDERROR
         my %data = &Apache::lonnet::tmpget($mailtoken);          my %data = &Apache::lonnet::tmpget($mailtoken);
         if ($currentpass ne $data{'temppasswd'}) {          if ($currentpass ne $data{'temppasswd'}) {
             &passwordchanger($r,              &passwordchanger($r,
                          '<font color="#ff0000">ERROR:</font>'.                           '<span class="LC_error">'.
                          'Could not verify current authentication.  '.                           &mt('Could not verify current authentication').'.  '.
                          'Please try again.',$caller,$mailtoken);                           &mt('Please try again').'.</span>',$caller,$mailtoken);
             return 1;              return 1;
         }          }
     }       } 
     if ($newpass1 ne $newpass2) {      if ($newpass1 ne $newpass2) {
  &passwordchanger($r,   &passwordchanger($r,
  '<font color="#ff0000">ERROR:</font>'.   '<span class="LC_error">'.
  'The new passwords you entered do not match.  '.   &mt('The new passwords you entered do not match').'.  '.
  'Please try again.',$caller,$mailtoken);   &mt('Please try again').'.</span>',$caller,$mailtoken);
  return 1;   return 1;
     }      }
     if (length($newpass1) < 7) {      if (length($newpass1) < 7) {
  &passwordchanger($r,   &passwordchanger($r,
  '<font color="#ff0000">ERROR:</font>'.   '<span class="LC_error">'.
  'Passwords must be a minimum of 7 characters long.  '.   &mt('Passwords must be a minimum of 7 characters long').'.  '.
  'Please try again.',$caller,$mailtoken);   &mt('Please try again').'</span>.',$caller,$mailtoken);
  return 1;   return 1;
     }      }
     #      #
Line 1022  ENDERROR Line 1082  ENDERROR
     }      }
     if ($badpassword) {      if ($badpassword) {
  # I can't figure out how to enter bad characters on my browser.   # I can't figure out how to enter bad characters on my browser.
  my $errormessage = <<"ENDERROR";   my $errormessage ='<span class="LC_error">'.
 <font color="#ff0000">ERROR:</font>             &mt('The password you entered contained illegal characters').'.<br />'.
 The password you entered contained illegal characters.<br />             &mt('Valid characters are').(<<"ENDERROR");
 Valid characters are: space and <br />  : space and <br />
 <pre>  <pre>
 !&quot;\#$%&amp;\'()*+,-./0123456789:;&lt;=&gt;?\@  !&quot;\#$%&amp;\'()*+,-./0123456789:;&lt;=&gt;?\@
 ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}~  ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}~
 </pre>  </pre></span>
 ENDERROR  ENDERROR
         &passwordchanger($r,$errormessage,$caller,$mailtoken);          &passwordchanger($r,$errormessage,$caller,$mailtoken);
         return 1;          return 1;
Line 1040  ENDERROR Line 1100  ENDERROR
  ($user,$domain,$currentpass,$newpass1,$homeserver,$caller);   ($user,$domain,$currentpass,$newpass1,$homeserver,$caller);
     # Inform the user the password has (not?) been changed      # Inform the user the password has (not?) been changed
     if ($result =~ /^ok$/) {      if ($result =~ /^ok$/) {
  $r->print(<<"ENDTEXT");   $r->print("<h3>".&mt('The password for [_1] was successfully changed',$user)."</h3>");
 <h3>The password for $user was successfully changed</h3>  
 ENDTEXT  
     } else {      } else {
  # error error: run in circles, scream and shout   # error error: run in circles, scream and shout
         $r->print(<<ENDERROR);          $r->print("<h3><span class='LC_error'>".&mt("The password for [_1] was not changed",$user)."</span></h3>".
 <h3><font color="#ff0000">The password for $user was not changed</font></h3>                    &mt('Please make sure your old password was entered correctly').'.');
 Please make sure your old password was entered correctly.  
 ENDERROR  
         return 1;          return 1;
     }      }
     return;      return;
Line 1152  END Line 1208  END
     $r->print(<<"END");      $r->print(<<"END");
 <br />  <br />
 <br />  <br />
 <input type="submit" name="sub" value="Store Changes" />  <input type="submit" name="sub" value="Save Changes" />
 <br />  <br />
 <br />  <br />
 Note: $lt{'thde'}  Note: $lt{'thde'}
Line 1337  sub handler { Line 1393  sub handler {
                       }));                        }));
   
     push (@Options,({ action   => 'changemsgforward',      push (@Options,({ action   => 'changemsgforward',
                       linktext => 'Change Message Forwarding and Notification Addresses',                        linktext => 'Change Message Forwarding and Notification Email Addresses',
                       href     => '/adm/preferences',                        href     => '/adm/preferences',
                       help     => 'Prefs_Forwarding',                        help     => 'Prefs_Forwarding',
                       breadcrumb =>                         breadcrumb => 
Line 1421  sub handler { Line 1477  sub handler {
                       printmenu => 'yes',                        printmenu => 'yes',
                       subroutine => \&verify_and_change_discussion, }                        subroutine => \&verify_and_change_discussion, }
                     ));                      ));
                          
       my $role = ($env{'user.adv'} ? 'Roles' : 'Course');
     push (@Options,({ action   => 'changerolespref',      push (@Options,({ action   => 'changerolespref',
                       linktext => 'Change Roles Page Preferences',                        linktext => 'Change '.$role.' Page Preferences',
                       href     => '/adm/preferences',                        href     => '/adm/preferences',
                       subroutine => \&rolesprefchanger,                        subroutine => \&rolesprefchanger,
                       breadcrumb =>                        breadcrumb =>
                           { href => '/adm/preferences?action=changerolespref',                            { href => '/adm/preferences?action=changerolespref',
                             text => 'Change Roles Pref'},                              text => 'Change '.$role.' Page Pref'},
                       },                        },
                     { action   => 'verify_and_change_rolespref',                      { action   => 'verify_and_change_rolespref',
                       subroutine => \&verify_and_change_rolespref,                        subroutine => \&verify_and_change_rolespref,
                       breadcrumb =>                        breadcrumb =>
                           { href => '/adm/preferences?action=changerolespref',                            { href => '/adm/preferences?action=changerolespref',
                             text => 'Change Roles Preferences'},                              text => 'Change '.$role.' Page Preferences'},
                       printmenu => 'yes',                        printmenu => 'yes',
                       }));                        }));
   
Line 1466  sub handler { Line 1523  sub handler {
       }));        }));
     }      }
   
       push (@Options,({ action   => 'changeicons',
                         linktext => 'Change How Menus are Displayed',
                         href     => '/adm/preferences',
                         subroutine => \&iconchanger,
                         breadcrumb =>
                             { href => '/adm/preferences?action=changeicons',
                               text => 'Change Main Menu'},
                         },
                       { action   => 'verify_and_change_icons',
                         subroutine => \&verify_and_change_icons,
                         breadcrumb =>
                             { href => '/adm/preferences?action=changeicons',
                               text => 'Change Main Menu'},
                         printmenu => 'yes',
                         }));
   
     if (&Apache::lonnet::allowed('whn',$env{'request.course.id'})      if (&Apache::lonnet::allowed('whn',$env{'request.course.id'})
  || &Apache::lonnet::allowed('whn',$env{'request.course.id'}.'/'   || &Apache::lonnet::allowed('whn',$env{'request.course.id'}.'/'
     .$env{'request.course.sec'})) {      .$env{'request.course.sec'})) {

Removed from v.1.95  
changed lines
  Added in v.1.101


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