Annotation of loncom/interface/lonpreferences.pm, revision 1.178
1.1 www 1: # The LearningOnline Network
2: # Preferences
3: #
1.178 ! bisitz 4: # $Id: lonpreferences.pm,v 1.177 2009/10/17 00:04:01 raeburn Exp $
1.2 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.3 matthew 28: # This package uses the "londes.js" javascript code.
29: #
30: # TODOs that have to be completed:
31: # interface with lonnet to change the password
32:
1.1 www 33: package Apache::lonpreferences;
34:
35: use strict;
1.86 albertel 36: use LONCAPA;
1.1 www 37: use Apache::Constants qw(:common);
1.3 matthew 38: use Apache::File;
39: use Crypt::DES;
40: use DynaLoader; # for Crypt::DES version
1.4 matthew 41: use Apache::loncommon();
1.23 matthew 42: use Apache::lonhtmlcommon();
1.32 www 43: use Apache::lonlocal;
1.59 albertel 44: use Apache::lonnet;
1.174 raeburn 45: use LONCAPA::lonauthcgi();
1.95 albertel 46: use LONCAPA();
1.3 matthew 47:
48: #
49: # Write lonnet::passwd to do the call below.
50: # Use:
51: # my $answer=reply("encrypt:passwd:$udom:$uname:$upass",$tryserver);
52: #
53: ##################################################
54: # password associated functions #
55: ##################################################
56: sub des_keys {
1.4 matthew 57: # Make a new key for DES encryption.
1.36 www 58: # Each key has two parts which are returned separately.
1.4 matthew 59: # Please note: Each key must be passed through the &hex function
60: # before it is output to the web browser. The hex versions cannot
61: # be used to decrypt.
1.3 matthew 62: my @hexstr=('0','1','2','3','4','5','6','7',
63: '8','9','a','b','c','d','e','f');
64: my $lkey='';
65: for (0..7) {
66: $lkey.=$hexstr[rand(15)];
67: }
68: my $ukey='';
69: for (0..7) {
70: $ukey.=$hexstr[rand(15)];
71: }
72: return ($lkey,$ukey);
73: }
74:
75: sub des_decrypt {
76: my ($key,$cyphertext) = @_;
77: my $keybin=pack("H16",$key);
78: my $cypher;
79: if ($Crypt::DES::VERSION>=2.03) {
80: $cypher=new Crypt::DES $keybin;
81: } else {
82: $cypher=new DES $keybin;
83: }
84: my $plaintext=
85: $cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,0,16))));
86: $plaintext.=
87: $cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,16,16))));
1.4 matthew 88: $plaintext=substr($plaintext,1,ord(substr($plaintext,0,1)) );
1.3 matthew 89: return $plaintext;
90: }
91:
1.4 matthew 92: ################################################################
93: # Handler subroutines #
94: ################################################################
1.9 matthew 95:
96: ################################################################
1.28 www 97: # Language Change Subroutines #
98: ################################################################
1.44 www 99:
100: sub wysiwygchanger {
101: my $r = shift;
1.126 droeschl 102: Apache::lonhtmlcommon::add_breadcrumb(
103: { href => '/adm/preferences?action=changewysiwyg',
104: text => 'Change WYSIWYG Preferences'});
1.147 schafran 105: $r->print(Apache::loncommon::start_page('Content Display Settings'));
1.126 droeschl 106: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change WYSIWYG Preferences'));
107:
1.44 www 108: my %userenv = &Apache::lonnet::get
109: ('environment',['wysiwygeditor']);
1.78 albertel 110: my $onselect='checked="checked"';
1.44 www 111: my $offselect='';
1.77 albertel 112: if ($userenv{'wysiwygeditor'} eq 'on') {
1.44 www 113: $onselect='';
1.78 albertel 114: $offselect='checked="checked"';
1.44 www 115: }
116: my $switchoff=&mt('Disable WYSIWYG editor');
117: my $switchon=&mt('Enable WYSIWYG editor');
1.124 www 118: my $warning='';
119: if ($env{'user.adv'}) {
120: $warning.="<p>".&mt("The WYSIWYG editor only supports simple HTML and is in many cases unsuited for advanced authoring. In a number of cases, it may destroy advanced authoring involving LaTeX and script function calls.")."</p>";
121: }
1.44 www 122: $r->print(<<ENDLSCREEN);
1.88 albertel 123: <form name="prefs" action="/adm/preferences" method="post">
1.44 www 124: <input type="hidden" name="action" value="set_wysiwyg" />
1.124 www 125: $warning
1.44 www 126: <br />
1.65 albertel 127: <label><input type="radio" name="wysiwyg" value="off" $onselect /> $switchoff</label><br />
128: <label><input type="radio" name="wysiwyg" value="on" $offselect /> $switchon</label>
1.44 www 129: ENDLSCREEN
1.136 schafran 130: $r->print('<br /><input type="submit" value="'.&mt('Save').'" />');
1.44 www 131: }
132:
133:
134: sub verify_and_change_wysiwyg {
135: my $r = shift;
1.59 albertel 136: my $newsetting=$env{'form.wysiwyg'};
1.44 www 137: &Apache::lonnet::put('environment',{'wysiwygeditor' => $newsetting});
1.116 raeburn 138: &Apache::lonnet::appenv({'environment.wysiwygeditor' => $newsetting});
1.158 bisitz 139: my $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]','<i>'.&mt('WYSIWYG Editor').'</i>','<tt>'.&mt($newsetting).'</tt>'));
140: $message=&Apache::loncommon::confirmwrapper($message);
141: &print_main_menu($r,$message);
1.44 www 142: }
143:
144: ################################################################
145: # Language Change Subroutines #
146: ################################################################
1.28 www 147: sub languagechanger {
148: my $r = shift;
1.126 droeschl 149:
150: Apache::lonhtmlcommon::add_breadcrumb(
151: { href => '/adm/preferences?action=changelanguages',
1.127 droeschl 152: text => 'Change Language'});
1.147 schafran 153: $r->print(Apache::loncommon::start_page('Content Display Settings'));
1.126 droeschl 154: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Language'));
1.59 albertel 155: my $user = $env{'user.name'};
156: my $domain = $env{'user.domain'};
1.28 www 157: my %userenv = &Apache::lonnet::get
1.32 www 158: ('environment',['languages']);
1.29 www 159: my $language=$userenv{'languages'};
1.32 www 160:
1.33 www 161: my $pref=&mt('Preferred language');
162: my %langchoices=('' => 'No language preference');
163: foreach (&Apache::loncommon::languageids()) {
164: if (&Apache::loncommon::supportedlanguagecode($_)) {
165: $langchoices{&Apache::loncommon::supportedlanguagecode($_)}
166: = &Apache::loncommon::plainlanguagedescription($_);
167: }
168: }
169: my $selectionbox=&Apache::loncommon::select_form($language,'language',
170: %langchoices);
1.28 www 171: $r->print(<<ENDLSCREEN);
1.88 albertel 172: <form name="prefs" action="/adm/preferences" method="post">
1.28 www 173: <input type="hidden" name="action" value="verify_and_change_languages" />
1.33 www 174: <br />$pref: $selectionbox
1.28 www 175: ENDLSCREEN
1.136 schafran 176: $r->print('<br /><input type="submit" value="'.&mt('Save').'" />');
1.28 www 177: }
178:
179:
180: sub verify_and_change_languages {
181: my $r = shift;
1.59 albertel 182: my $user = $env{'user.name'};
183: my $domain = $env{'user.domain'};
1.28 www 184: # Screenname
1.59 albertel 185: my $newlanguage = $env{'form.language'};
1.28 www 186: $newlanguage=~s/[^\-\w]//g;
187: my $message='';
188: if ($newlanguage) {
1.29 www 189: &Apache::lonnet::put('environment',{'languages' => $newlanguage});
1.116 raeburn 190: &Apache::lonnet::appenv({'environment.languages' => $newlanguage});
1.158 bisitz 191: $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]','<i>'.&mt('Preferred language').'</i>','<tt>"'.$newlanguage.'"</tt>.'));
1.28 www 192: } else {
1.29 www 193: &Apache::lonnet::del('environment',['languages']);
1.139 raeburn 194: &Apache::lonnet::delenv('environment.languages');
1.158 bisitz 195: $message=&Apache::lonhtmlcommon::confirm_success(&mt('Reset [_1]','<i>'.&mt('Preferred language').'</i>'));
1.28 www 196: }
1.158 bisitz 197: $message=&Apache::loncommon::confirmwrapper($message);
1.132 raeburn 198: &Apache::loncommon::flush_langs_cache($user,$domain);
1.152 www 199: &print_main_menu($r, $message);
1.28 www 200: }
201:
1.50 albertel 202: ################################################################
1.54 albertel 203: # Tex Engine Change Subroutines #
204: ################################################################
205: sub texenginechanger {
206: my $r = shift;
1.126 droeschl 207: Apache::lonhtmlcommon::add_breadcrumb(
208: { href => '/adm/preferences?action=changetexenginepref',
1.177 raeburn 209: text => 'Math display settings'});
1.147 schafran 210: $r->print(Apache::loncommon::start_page('Content Display Settings'));
1.177 raeburn 211: $r->print(Apache::lonhtmlcommon::breadcrumbs('Math display settings'));
1.59 albertel 212: my $user = $env{'user.name'};
213: my $domain = $env{'user.domain'};
1.54 albertel 214: my %userenv = &Apache::lonnet::get('environment',['texengine']);
215: my $texengine=$userenv{'texengine'};
216:
1.69 albertel 217: my %mathchoices=('' => 'Default',
1.123 bisitz 218: 'tth' => 'tth (TeX to HTML)',
1.64 albertel 219: #'ttm' => 'TeX to MathML',
1.54 albertel 220: 'jsMath' => 'jsMath',
1.168 www 221: 'mimetex' => 'mimetex (Convert to Images)',
222: 'raw' => 'Raw (Screen Reader)'
1.54 albertel 223: );
224: my $selectionbox=&Apache::loncommon::select_form($texengine,'texengine',
225: %mathchoices);
1.67 albertel 226: my $jsMath_start=&Apache::lontexconvert::jsMath_header();
1.123 bisitz 227: my %lt=&Apache::lonlocal::texthash(
1.177 raeburn 228: 'headline' => 'Change how math is displayed',
229: 'preftxt' => 'Preferred method to display math',
1.136 schafran 230: 'change' => 'Save',
1.123 bisitz 231: 'exmpl' => 'Examples',
232: 'jsmath' => 'jsMath:',
233: 'tth' => 'tth (TeX to HTML):',
234: 'mimetex' => 'mimetex (Convert to Images):',
235: );
236:
1.162 bisitz 237: my $jsMathWarning='<p>'
238: .'<div class="LC_warning">'
239: .&mt("It looks like you don't have the TeX math fonts installed.")
240: .'</div>'
241: .'<div>'
242: .&mt('The jsMath example on this page may not look right without them. '
243: .'The [_1]jsMath Home Page[_2] has information on how to download the '
244: .'needed fonts. In the meantime, jsMath will do the best it can '
245: .'with the fonts you have, but it may not be pretty and some equations '
246: .'may not be rendered correctly.'
247: ,'<a href="http://www.math.union.edu/locate/jsMath/" target="_blank">'
248: ,'</a>')
249: .'</div>'
250: .'</p>';
251:
1.54 albertel 252: $r->print(<<ENDLSCREEN);
1.123 bisitz 253: <h2>$lt{'headline'}</h2>
1.88 albertel 254: <form name="prefs" action="/adm/preferences" method="post">
1.54 albertel 255: <input type="hidden" name="action" value="verify_and_change_texengine" />
1.123 bisitz 256: <p>
1.136 schafran 257: $lt{'preftxt'}: $selectionbox
258: <br />
259: <input type="submit" value="$lt{'change'}" />
1.123 bisitz 260: </p>
1.54 albertel 261: </form>
1.123 bisitz 262: <br />
263: <hr />
264: $lt{'exmpl'}
265:
266: <h3>$lt{'jsmath'}</h3>
267: <p>
1.67 albertel 268: $jsMath_start
1.148 bisitz 269: <script type="text/javascript" language="JavaScript">
1.54 albertel 270: if (jsMath.nofonts == 1) {
1.162 bisitz 271: document.writeln($jsMathWarning);
1.54 albertel 272: }
273: </script>
1.122 www 274: <iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=jsMath" width="400" height="120"></iframe>
1.123 bisitz 275: </p>
1.54 albertel 276:
1.123 bisitz 277: <h3>$lt{'mimetex'}</h3>
278: <p>
279: <iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=mimetex" width="400" height="100"></iframe>
1.67 albertel 280: </p>
1.123 bisitz 281:
282: <h3>$lt{'tth'}</h3>
283: <p>
1.177 raeburn 284: <iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=tth" width="400" height="220"></iframe>
1.67 albertel 285: </p>
1.54 albertel 286: ENDLSCREEN
1.59 albertel 287: if ($env{'environment.texengine'} ne 'jsMath') {
1.148 bisitz 288: $r->print('<script type="text/javascript" language="JavaScript">jsMath.Process()</script>');
1.55 albertel 289: }
1.54 albertel 290: }
291:
292:
293: sub verify_and_change_texengine {
294: my $r = shift;
1.59 albertel 295: my $user = $env{'user.name'};
296: my $domain = $env{'user.domain'};
1.54 albertel 297: # Screenname
1.59 albertel 298: my $newtexengine = $env{'form.texengine'};
1.54 albertel 299: $newtexengine=~s/[^\-\w]//g;
1.56 albertel 300: if ($newtexengine eq 'ttm') {
1.116 raeburn 301: &Apache::lonnet::appenv({'browser.mathml' => 1});
1.56 albertel 302: } else {
1.59 albertel 303: if ($env{'environment.texengine'} eq 'ttm') {
1.116 raeburn 304: &Apache::lonnet::appenv({'browser.mathml' => 0});
1.56 albertel 305: }
306: }
1.54 albertel 307: my $message='';
308: if ($newtexengine) {
309: &Apache::lonnet::put('environment',{'texengine' => $newtexengine});
1.116 raeburn 310: &Apache::lonnet::appenv({'environment.texengine' => $newtexengine});
1.158 bisitz 311: $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]','<i>'.&mt('Preferred method to display Math').'</i>','<tt>"'.$newtexengine.'"</tt>'));
1.54 albertel 312: } else {
313: &Apache::lonnet::del('environment',['texengine']);
1.139 raeburn 314: &Apache::lonnet::delenv('environment.texengine');
1.158 bisitz 315: $message=&Apache::lonhtmlcommon::confirm_success(&mt('Reset [_1]','<i>'.&mt('Preferred method to display Math').'</i>'));
1.54 albertel 316: }
1.158 bisitz 317: $message=&Apache::loncommon::confirmwrapper($message);
1.152 www 318: &print_main_menu($r, $message);
1.54 albertel 319: }
320:
321: ################################################################
1.50 albertel 322: # Roles Page Preference Change Subroutines #
323: ################################################################
324: sub rolesprefchanger {
325: my $r = shift;
1.96 albertel 326: my $role = ($env{'user.adv'} ? 'Role' : 'Course');
327: my $lc_role = ($env{'user.adv'} ? 'role' : 'course');
1.59 albertel 328: my $user = $env{'user.name'};
329: my $domain = $env{'user.domain'};
1.50 albertel 330: my %userenv = &Apache::lonnet::get
331: ('environment',['recentroles','recentrolesn']);
1.126 droeschl 332: Apache::lonhtmlcommon::add_breadcrumb(
333: { href => '/adm/preferences?action=changerolespref',
334: text => 'Change '.$role.' Page Pref'});
1.147 schafran 335: $r->print(Apache::loncommon::start_page('Content Display Settings'));
1.126 droeschl 336: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change '.$role.' Page Pref'));
1.50 albertel 337: my $hotlist_flag=$userenv{'recentroles'};
338: my $hotlist_n=$userenv{'recentrolesn'};
339: my $checked;
340: if ($hotlist_flag) {
341: $checked = 'checked="checked"';
342: }
343:
344: if (!$hotlist_n) { $hotlist_n=3; }
345: my $options;
346: for (my $i=1; $i<10; $i++) {
347: my $select;
348: if ($hotlist_n == $i) { $select = 'selected="selected"'; }
349: $options .= "<option $select>$i</option>\n";
350: }
351:
1.89 albertel 352: # Get list of recent roles and display with checkbox in front
353: my $roles_check_list = '';
354: my $role_key='';
355: if ($env{'environment.recentroles'}) {
356: my %recent_roles =
357: &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'});
1.91 albertel 358: my %frozen_roles =
359: &Apache::lonhtmlcommon::get_recent_frozen('roles',$env{'environment.recentrolesn'});
1.89 albertel 360:
1.93 albertel 361: my %role_text = &rolespref_get_role_text([keys(%recent_roles)]);
1.92 albertel 362: my @sorted_roles = sort {$role_text{$a} cmp $role_text{$b}} keys(%role_text);
363:
1.89 albertel 364: $roles_check_list .=
365: &Apache::loncommon::start_data_table().
366: &Apache::loncommon::start_data_table_header_row().
1.96 albertel 367: "<th>".&mt('Freeze '.$role)."</th>".
368: "<th>".&mt($role)."</td>".
1.89 albertel 369: &Apache::loncommon::end_data_table_header_row().
370: "\n";
371: my $count;
1.92 albertel 372: foreach $role_key (@sorted_roles) {
1.89 albertel 373: my $checked = "";
374: my $value = $recent_roles{$role_key};
1.91 albertel 375: if ($frozen_roles{$role_key}) {
1.159 bisitz 376: $checked = ' checked="checked"';
1.89 albertel 377: }
378: $count++;
379: $roles_check_list .=
380: &Apache::loncommon::start_data_table_row().
381: '<td class="LC_table_cell_checkbox">'.
1.159 bisitz 382: "<input type=\"checkbox\"$checked name=\"freezeroles\"".
1.89 albertel 383: " id=\"freezeroles$count\" value=\"$role_key\" /></td>".
384: "<td><label for=\"freezeroles$count\">".
1.92 albertel 385: "$role_text{$role_key}</label></td>".
1.89 albertel 386: &Apache::loncommon::end_data_table_row(). "\n";
387: }
388: $roles_check_list .= "</table>\n";
389: }
390:
391: $r->print('
1.96 albertel 392: <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.').'
1.50 albertel 393: </p>
1.160 bisitz 394: <form name="prefs" action="/adm/preferences" method="post">
1.50 albertel 395: <input type="hidden" name="action" value="verify_and_change_rolespref" />
1.96 albertel 396: <br /><label>'.&mt('Enable Recent '.$role.'s Hotlist:').'
1.159 bisitz 397: <input type="checkbox"'.$checked.' name="recentroles" value="true" /></label>
1.96 albertel 398: <br />'.&mt('Number of '.$role.'s in Hotlist:').'
1.50 albertel 399: <select name="recentrolesn" size="1">
1.89 albertel 400: '.$options.'
1.50 albertel 401: </select>
1.96 albertel 402: <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.').'
1.89 albertel 403: </p>
404: '.$roles_check_list.'
1.50 albertel 405: <br />
1.136 schafran 406: <input type="submit" value="'.&mt('Save').'" />
1.89 albertel 407: </form>');
1.50 albertel 408: }
409:
1.92 albertel 410: sub rolespref_get_role_text {
411: # Get a line of text for each role
412: my ($roles) = @_;
413: my %roletext = ();
414:
415: foreach my $item (@$roles) {
416: # get course information
417: my ($role,$rest) = split(/\./, $item);
1.93 albertel 418: my $trole = "";
419: $trole = &Apache::lonnet::plaintext($role);
1.92 albertel 420: my ($tdomain,$other,$tsection)= split(/\//,Apache::lonnet::declutter($rest));
421: my $tother = '-';
1.93 albertel 422: if ($role =~ /^(cc|st|in|ta|ep|cr)/ ) {
1.92 albertel 423: my %newhash=&Apache::lonnet::coursedescription($tdomain."_".$other);
424: $tother = " - ".$newhash{'description'};
425: } elsif ($role =~ /dc/) {
426: $tother = "";
427: } else {
428: $tother = " - $other";
429: }
430:
431: my $section="";
432: if ($tsection) {
433: $section = " - Section/Group: $tsection";
434: }
435: $roletext{$item} = $tdomain." - ".$trole.$tother.$section;
436: }
437: return %roletext;
438: }
439:
1.50 albertel 440: sub verify_and_change_rolespref {
441: my $r = shift;
1.96 albertel 442: my $role = ($env{'user.adv'} ? 'Role' : 'Course');
1.59 albertel 443: my $user = $env{'user.name'};
444: my $domain = $env{'user.domain'};
1.50 albertel 445: # Recent Roles Hotlist Flag
1.59 albertel 446: my $hotlist_flag = $env{'form.recentroles'};
447: my $hotlist_n = $env{'form.recentrolesn'};
1.89 albertel 448: my $message='<hr />';
1.50 albertel 449: if ($hotlist_flag) {
450: &Apache::lonnet::put('environment',{'recentroles' => $hotlist_flag});
1.116 raeburn 451: &Apache::lonnet::appenv({'environment.recentroles' => $hotlist_flag});
1.96 albertel 452: $message=&mt('Recent '.$role.'s Hotlist is Enabled');
1.50 albertel 453: } else {
454: &Apache::lonnet::del('environment',['recentroles']);
1.139 raeburn 455: &Apache::lonnet::delenv('environment.recentroles');
1.96 albertel 456: $message=&mt('Recent '.$role.'s Hotlist is Disabled');
1.50 albertel 457: }
458: if ($hotlist_n) {
459: &Apache::lonnet::put('environment',{'recentrolesn' => $hotlist_n});
1.116 raeburn 460: &Apache::lonnet::appenv({'environment.recentrolesn' => $hotlist_n});
1.50 albertel 461: if ($hotlist_flag) {
1.90 albertel 462: $message.="<br />".
1.96 albertel 463: &mt('Display [_1] Most Recent '.$role.'s',$hotlist_n)."\n";
1.89 albertel 464: }
465: }
466:
467: # Get list of froze roles and list of recent roles
468: my @freeze_list = &Apache::loncommon::get_env_multiple('form.freezeroles');
469: my %freeze = ();
1.92 albertel 470: my %roletext = ();
471:
1.89 albertel 472: foreach my $key (@freeze_list) {
1.91 albertel 473: $freeze{$key}='1';
1.89 albertel 474: }
1.92 albertel 475:
1.89 albertel 476: my %recent_roles =
477: &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'});
1.91 albertel 478: my %frozen_roles =
479: &Apache::lonhtmlcommon::get_recent_frozen('roles',$env{'environment.recentrolesn'});
1.92 albertel 480: my %role_text = &rolespref_get_role_text([keys(%recent_roles)]);
1.89 albertel 481:
482: # Unset any roles that were previously frozen but aren't in list
483: foreach my $role_key (sort(keys(%recent_roles))) {
1.91 albertel 484: if (($frozen_roles{$role_key}) && (!exists($freeze{$role_key}))) {
1.158 bisitz 485: $message .= "<br />".&Apache::lonhtmlcommon::confirm_success(&mt('Unfreezing '.$role.': [_1]','<i>'.$role_text{$role_key}.'</i>'));
1.91 albertel 486: &Apache::lonhtmlcommon::store_recent('roles',$role_key,' ',0);
1.89 albertel 487: }
488: }
489:
490: # Freeze selected roles
491: foreach my $role_key (@freeze_list) {
1.91 albertel 492: if (!$frozen_roles{$role_key}) {
1.154 www 493: $message .= "<br />".
1.158 bisitz 494: &Apache::lonhtmlcommon::confirm_success(&mt('Freezing '.$role.': [_1]','<i>'.$role_text{$role_key}.'</i>'));
1.89 albertel 495: &Apache::lonhtmlcommon::store_recent('roles',
1.91 albertel 496: $role_key,' ',1);
1.50 albertel 497: }
498: }
1.158 bisitz 499: $message=&Apache::loncommon::confirmwrapper($message);
1.152 www 500: &print_main_menu($r, $message);
1.50 albertel 501: }
502:
503:
1.28 www 504:
505: ################################################################
1.9 matthew 506: # Anonymous Discussion Name Change Subroutines #
507: ################################################################
1.5 www 508: sub screennamechanger {
509: my $r = shift;
1.59 albertel 510: my $user = $env{'user.name'};
511: my $domain = $env{'user.domain'};
1.14 www 512: my %userenv = &Apache::lonnet::get
513: ('environment',['screenname','nickname']);
1.6 www 514: my $screenname=$userenv{'screenname'};
1.14 www 515: my $nickname=$userenv{'nickname'};
1.126 droeschl 516: Apache::lonhtmlcommon::add_breadcrumb(
517: { href => '/adm/preferences?action=changescreenname',
518: text => 'Change Screen Name'});
1.147 schafran 519: $r->print(Apache::loncommon::start_page('Personal Data'));
1.126 droeschl 520: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Screen Name'));
1.133 bisitz 521: $r->print('<p>'
522: .&mt('Change the name that is displayed in your posts.')
523: .'</p>'
524: );
525: $r->print('<form name="prefs" action="/adm/preferences" method="post">'
526: .'<input type="hidden" name="action" value="verify_and_change_screenname" />'
527: .&Apache::lonhtmlcommon::start_pick_box()
1.158 bisitz 528: .&Apache::lonhtmlcommon::row_title(&mt('Screenname').' '.&mt('(shown if you post anonymously)'))
1.133 bisitz 529: .'<input type="text" size="20" value="'.$screenname.'" name="screenname" />'
530: .&Apache::lonhtmlcommon::row_closure()
1.158 bisitz 531: .&Apache::lonhtmlcommon::row_title(&mt('Nickname').' '.&mt('(shown if you post non-anonymously)'))
1.133 bisitz 532: .'<input type="text" size="20" value="'.$nickname.'" name="nickname" />'
533: .&Apache::lonhtmlcommon::row_closure()
534: .&Apache::lonhtmlcommon::row_title()
535: .'<input type="submit" value="'.&mt('Save').'" />'
536: .&Apache::lonhtmlcommon::row_closure(1)
537: .&Apache::lonhtmlcommon::end_pick_box()
538: .'</form>'
539: );
1.5 www 540: }
1.6 www 541:
542: sub verify_and_change_screenname {
543: my $r = shift;
1.59 albertel 544: my $user = $env{'user.name'};
545: my $domain = $env{'user.domain'};
1.14 www 546: # Screenname
1.59 albertel 547: my $newscreen = $env{'form.screenname'};
1.14 www 548: $newscreen=~s/[^ \w]//g;
1.6 www 549: my $message='';
550: if ($newscreen) {
1.7 www 551: &Apache::lonnet::put('environment',{'screenname' => $newscreen});
1.116 raeburn 552: &Apache::lonnet::appenv({'environment.screenname' => $newscreen});
1.161 bisitz 553: $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]','<i>'.&mt('Screenname').'</i>','<tt>"'.$newscreen.'"</tt>'));
1.6 www 554: } else {
555: &Apache::lonnet::del('environment',['screenname']);
1.139 raeburn 556: &Apache::lonnet::delenv('environment.screenname');
1.158 bisitz 557: $message=&Apache::lonhtmlcommon::confirm_success(&mt('Reset [_1]','<i>'.&mt('Screenname').'</i>'));
1.6 www 558: }
1.14 www 559: # Nickname
560: $message.='<br />';
1.59 albertel 561: $newscreen = $env{'form.nickname'};
1.14 www 562: $newscreen=~s/[^ \w]//g;
563: if ($newscreen) {
564: &Apache::lonnet::put('environment',{'nickname' => $newscreen});
1.116 raeburn 565: &Apache::lonnet::appenv({'environment.nickname' => $newscreen});
1.161 bisitz 566: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]','<i>'.&mt('Nickname').'</i>','<tt>"'.$newscreen.'"</tt>'));
1.14 www 567: } else {
568: &Apache::lonnet::del('environment',['nickname']);
1.139 raeburn 569: &Apache::lonnet::delenv('environment.nickname');
1.158 bisitz 570: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Reset [_1]','<i>'.&mt('Nickname').'</i>'));
1.14 www 571: }
1.68 www 572: &Apache::lonnet::devalidate_cache_new('namescache',$user.':'.$domain);
1.158 bisitz 573: $message=&Apache::loncommon::confirmwrapper($message);
1.152 www 574: &print_main_menu($r, $message);
1.20 www 575: }
576:
577: ################################################################
1.98 www 578: # Icon Subroutines #
579: ################################################################
580: sub iconchanger {
581: my $r = shift;
1.154 www 582: &Apache::lonhtmlcommon::add_breadcrumb(
1.126 droeschl 583: { href => '/adm/preferences?action=changeicons',
584: text => 'Change Main Menu'});
1.147 schafran 585: $r->print(Apache::loncommon::start_page('Page Display Settings'));
1.126 droeschl 586: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Main Menu'));
587:
1.98 www 588: my $user = $env{'user.name'};
589: my $domain = $env{'user.domain'};
590: my %userenv = &Apache::lonnet::get
591: ('environment',['icons']);
592: my $iconic='checked="checked"';
593: my $classic='';
1.100 www 594: my $onlyicon='';
1.98 www 595: if ($userenv{'icons'} eq 'classic') {
596: $classic='checked="checked"';
597: $iconic='';
598: }
1.100 www 599: if ($userenv{'icons'} eq 'iconsonly') {
600: $onlyicon='checked="checked"';
601: $iconic='';
602: }
603: my $useicons=&mt('Use icons and text');
604: my $usebuttons=&mt('Use buttons and text');
605: my $useicononly=&mt('Use icons only');
1.136 schafran 606: my $change=&mt('Save');
1.98 www 607: $r->print(<<ENDSCREEN);
608: <form name="prefs" action="/adm/preferences" method="post">
609: <input type="hidden" name="action" value="verify_and_change_icons" />
610: <label><input type="radio" name="menumode" value="iconic" $iconic /> $useicons</label><br />
611: <label><input type="radio" name="menumode" value="classic" $classic /> $usebuttons</label><br />
1.100 www 612: <label><input type="radio" name="menumode" value="iconsonly" $onlyicon /> $useicononly</label><br />
1.98 www 613: <input type="submit" value="$change" />
614: </form>
615: ENDSCREEN
616: }
617:
618: sub verify_and_change_icons {
619: my $r = shift;
620: my $user = $env{'user.name'};
621: my $domain = $env{'user.domain'};
1.158 bisitz 622: my $newicons = $env{'form.menumode'};
1.98 www 623:
624: &Apache::lonnet::put('environment',{'icons' => $newicons});
1.116 raeburn 625: &Apache::lonnet::appenv({'environment.icons' => $newicons});
1.158 bisitz 626: my $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]','<i>'.&mt('Menu Display').'</i>','<tt>'.$newicons.'</tt>'));
627: $message=&Apache::loncommon::confirmwrapper($message);
628: &print_main_menu($r, $message);
1.98 www 629: }
630:
631: ################################################################
1.105 www 632: # Clicker Subroutines #
633: ################################################################
634:
635: sub clickerchanger {
636: my $r = shift;
1.152 www 637: &Apache::lonhtmlcommon::add_breadcrumb(
1.126 droeschl 638: { href => '/adm/preferences?action=changeclicker',
639: text => 'Register Clicker'});
1.147 schafran 640: $r->print(Apache::loncommon::start_page('Other'));
1.126 droeschl 641: $r->print(Apache::lonhtmlcommon::breadcrumbs('Register Clicker'));
1.105 www 642: my $user = $env{'user.name'};
643: my $domain = $env{'user.domain'};
644: my %userenv = &Apache::lonnet::get
645: ('environment',['clickers']);
646: my $clickers=$userenv{'clickers'};
647: $clickers=~s/\,/\n/gs;
648: my $text=&mt('Enter response device ("clicker") numbers');
1.151 bisitz 649: my $change=&mt('Save');
1.114 bisitz 650: my $helplink=&Apache::loncommon::help_open_topic('Clicker_Registration',&mt('Locating your clicker ID'));
1.105 www 651: $r->print(<<ENDSCREEN);
652: <form name="prefs" action="/adm/preferences" method="post">
653: <input type="hidden" name="action" value="verify_and_change_clicker" />
1.151 bisitz 654: <label>$helplink<br /><br />$text<br />
1.108 www 655: <textarea name="clickers" rows="5" cols="20">$clickers</textarea>
1.105 www 656: </label>
1.151 bisitz 657: <br />
1.105 www 658: <input type="submit" value="$change" />
659: </form>
660: ENDSCREEN
661: }
662:
663: sub verify_and_change_clicker {
664: my $r = shift;
665: my $user = $env{'user.name'};
666: my $domain = $env{'user.domain'};
667: my $newclickers = $env{'form.clickers'};
1.108 www 668: $newclickers=~s/[^\w\:\-]+/\,/gs;
1.105 www 669: $newclickers=~tr/a-z/A-Z/;
1.108 www 670: $newclickers=~s/[\:\-]+/\-/g;
671: $newclickers=~s/\,+/\,/g;
1.105 www 672: $newclickers=~s/^\,//;
673: $newclickers=~s/\,$//;
674: &Apache::lonnet::put('environment',{'clickers' => $newclickers});
1.116 raeburn 675: &Apache::lonnet::appenv({'environment.clickers' => $newclickers});
1.158 bisitz 676: my $message=&Apache::lonhtmlcommon::confirm_success(&mt('Registering clickers: [_1]',$newclickers));
677: $message=&Apache::loncommon::confirmwrapper($message);
678: &print_main_menu($r, $message);
1.105 www 679: }
680:
1.119 www 681: ################################################################
682: # Domcoord Access Subroutines #
683: ################################################################
684:
685: sub domcoordchanger {
686: my $r = shift;
1.154 www 687: &Apache::lonhtmlcommon::add_breadcrumb(
1.126 droeschl 688: { href => '/adm/preferences?action=changedomcoord',
689: text => 'Restrict Domain Coordinator Access'});
690: $r->print(Apache::loncommon::start_page('Restrict Domain Coordinator Access'));
691: $r->print(Apache::lonhtmlcommon::breadcrumbs('Restrict Domain Coordinator Access'));
1.119 www 692: my $user = $env{'user.name'};
693: my $domain = $env{'user.domain'};
694: my %userenv = &Apache::lonnet::get
1.120 www 695: ('environment',['domcoord.author']);
1.119 www 696: my $constchecked='';
697: if ($userenv{'domcoord.author'} eq 'blocked') {
1.159 bisitz 698: $constchecked=' checked="checked"';
1.119 www 699: }
1.120 www 700: my $text=&mt('By default, the Domain Coordinator can enter your construction space.');
1.119 www 701: my $construction=&mt('Block access to construction space');
1.136 schafran 702: my $change=&mt('Save');
1.119 www 703: $r->print(<<ENDSCREEN);
704: <form name="prefs" action="/adm/preferences" method="post">
705: <input type="hidden" name="action" value="verify_and_change_domcoord" />
706: $text<br />
1.159 bisitz 707: <label><input type="checkbox" name="construction"$constchecked />$construction</label><br />
1.119 www 708: <input type="submit" value="$change" />
709: </form>
710: ENDSCREEN
711: }
712:
713: sub verify_and_change_domcoord {
714: my $r = shift;
715: my $user = $env{'user.name'};
716: my $domain = $env{'user.domain'};
1.120 www 717: my %domcoord=('domcoord.author' => '');
1.119 www 718: if ($env{'form.construction'}) { $domcoord{'domcoord.author'}='blocked'; }
719: &Apache::lonnet::put('environment',\%domcoord);
1.120 www 720: &Apache::lonnet::appenv({'environment.domcoord.author' => $domcoord{'domcoord.author'}});
1.158 bisitz 721: my $status='';
722: if ($domcoord{'domcoord.author'} eq 'blocked') {
723: $status=&mt('on');
724: } else {
725: $status=&mt('off');
726: }
727: my $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]','<i>'.&mt('Block access to construction space').'</i>','<tt>'.$status.'</tt>'));
728: $message=&Apache::loncommon::confirmwrapper($message);
729: &print_main_menu($r,$message);
1.119 www 730: }
731:
1.118 www 732: #################################################################
733: ## Lock Subroutines #
734: #################################################################
735:
736: sub lockwarning {
737: my $r = shift;
738: my $title=&mt('Action locked');
739: my $texttop=&mt('LON-CAPA is currently performing the following actions:');
740: my $textbottom=&mt('Changing roles or logging out may result in data corruption.');
741: my ($num,%which)=&Apache::lonnet::get_locks();
742: my $which='';
743: foreach my $id (keys %which) {
744: $which.='<li>'.$which{$id}.'</li>';
745: }
746: my $change=&mt('Override');
747: $r->print(<<ENDSCREEN);
748: <form name="prefs" action="/adm/preferences" method="post">
749: <input type="hidden" name="action" value="verify_and_change_locks" />
750: <h1>$title</h1>
751: $texttop
752: <ul>
753: $which
754: </ul>
755: $textbottom
756: <input type="submit" value="$change" />
757: </form>
758: ENDSCREEN
759: }
760:
761: sub verify_and_change_lockwarning {
762: my $r = shift;
763: &Apache::lonnet::remove_all_locks();
764: $r->print(&mt('Cleared locks.'));
765: }
766:
767:
1.105 www 768: ################################################################
1.20 www 769: # Message Forward #
770: ################################################################
771:
772: sub msgforwardchanger {
1.102 raeburn 773: my ($r,$message) = @_;
1.59 albertel 774: my $user = $env{'user.name'};
775: my $domain = $env{'user.domain'};
1.102 raeburn 776: my %userenv = &Apache::lonnet::get('environment',['msgforward','notification','critnotification','notifywithhtml']);
1.20 www 777: my $msgforward=$userenv{'msgforward'};
1.102 raeburn 778: my %lt = &Apache::lonlocal::texthash(
779: all => 'All',
780: crit => 'Critical only',
781: reg => 'Non-critical only',
1.175 raeburn 782: foad => 'Forward to account(s)',
783: fwdm => 'Forward messages to other account(s) in LON-CAPA',
784: noti => 'E-mail notification of LON-CAPA messages',
1.110 bisitz 785: foad_exmpl => 'e.g. <tt>userA:domain1,userB:domain2,...</tt>',
1.175 raeburn 786: mnot => 'E-mail address(es) which should be notified about new LON-CAPA messages',
1.110 bisitz 787: mnot_exmpl => 'e.g. <tt>joe@doe.com</tt>',
1.136 schafran 788: chg => 'Save',
1.104 raeburn 789: email => 'The e-mail address entered in row ',
1.102 raeburn 790: notv => 'is not a valid e-mail address',
1.103 raeburn 791: toen => "To enter multiple addresses, enter one address at a time, click 'Change' and then add the next one",
1.136 schafran 792: prme => 'Back',
1.102 raeburn 793: );
1.126 droeschl 794: Apache::lonhtmlcommon::add_breadcrumb(
795: { href => '/adm/preferences?action=changemsgforward',
1.176 raeburn 796: text => 'Messages & Notifications'});
1.178 ! bisitz 797: $r->print(Apache::loncommon::start_page('Messages & Notifications'));
! 798: $r->print(Apache::lonhtmlcommon::breadcrumbs('Messages & Notifications'));
1.113 raeburn 799: my $forwardingHelp = &Apache::loncommon::help_open_topic("Prefs_Forwarding");
800: my $notificationHelp = &Apache::loncommon::help_open_topic("Prefs_Notification");
801: my $criticalMessageHelp = &Apache::loncommon::help_open_topic("Course_Critical_Message");
1.102 raeburn 802: my @allow_html = split(/,/,$userenv{'notifywithhtml'});
803: my %allnot = &get_notifications(\%userenv);
804: my $validatescript = &Apache::lonhtmlcommon::javascript_valid_email();
805: my $jscript = qq|
1.148 bisitz 806: <script type="text/javascript" language="JavaScript">
1.102 raeburn 807: function validate() {
808: for (var i=0; i<document.prefs.numnotify.value; i++) {
1.104 raeburn 809: var checkaddress = 0;
1.102 raeburn 810: var addr = document.prefs.elements['address_'+i].value;
1.104 raeburn 811: var rownum = i+1;
1.102 raeburn 812: if (i < document.prefs.numnotify.value-1) {
1.104 raeburn 813: if (document.prefs.elements['modify_notify_'+i].checked) {
1.102 raeburn 814: checkaddress = 1;
1.104 raeburn 815: }
1.102 raeburn 816: } else {
817: if (document.prefs.elements['add_notify_'+i].checked == true) {
818: checkaddress = 1;
819: }
820: }
1.104 raeburn 821: if (checkaddress == 1) {
1.102 raeburn 822: var addr = document.prefs.elements['address_'+i].value;
823: if (validmail(document.prefs.elements['address_'+i]) == false) {
1.104 raeburn 824: var multimsg = '';
825: if (addr.indexOf(",") >= 0) {
826: multimsg = "\\n($lt{'toen'}).";
827: }
1.110 bisitz 828: alert("$lt{'email'} "+rownum+" ('"+addr+"') $lt{'notv'}."+multimsg);
1.102 raeburn 829: return;
830: }
831: }
832: }
833: document.prefs.submit();
834: }
1.104 raeburn 835:
836: function address_changes (adnum) {
837: if (!document.prefs.elements['del_notify_'+adnum].checked) {
838: document.prefs.elements['modify_notify_'+adnum].checked = true;
839: }
840: }
841:
842: function new_address(adnum) {
843: document.prefs.elements['add_notify_'+adnum].checked = true;
844: }
845:
846: function delete_address(adnum) {
847: if (document.prefs.elements['del_notify_'+adnum].checked) {
848: document.prefs.elements['modify_notify_'+adnum].checked = false;
849: }
850: }
851:
852: function modify_address(adnum) {
853: if (document.prefs.elements['modify_notify_'+adnum].checked) {
854: document.prefs.elements['del_notify_'+adnum].checked = false;
855: }
856: }
857:
1.102 raeburn 858: $validatescript
859: </script>
860: |;
1.20 www 861: $r->print(<<ENDMSG);
1.102 raeburn 862: $jscript
863: $message
1.175 raeburn 864: <h3>$lt{'fwdm'} $forwardingHelp</h3>
1.88 albertel 865: <form name="prefs" action="/adm/preferences" method="post">
1.20 www 866: <input type="hidden" name="action" value="verify_and_change_msgforward" />
1.110 bisitz 867: $lt{'foad'} ($lt{'foad_exmpl'}):
1.175 raeburn 868: <input type="text" size="40" value="$msgforward" name="msgforward" />
869: <br /><br />
1.113 raeburn 870: <h3>$lt{'noti'} $notificationHelp</h3>
1.110 bisitz 871: $lt{'mnot'} ($lt{'mnot_exmpl'}):<br />
1.102 raeburn 872: ENDMSG
873: my @sortforwards = sort (keys(%allnot));
874: my $output = &Apache::loncommon::start_data_table().
875: &Apache::loncommon::start_data_table_header_row().
1.104 raeburn 876: '<th> </th>'.
1.102 raeburn 877: '<th>'.&mt('Action').'</th>'.
878: '<th>'.&mt('Notification address').'</th><th>'.
1.113 raeburn 879: &mt('Types of message for which notification is sent').
880: $criticalMessageHelp.'</th><th>'.
1.104 raeburn 881: &mt('Excerpt retains HTML tags in message').'</th>'.
1.102 raeburn 882: &Apache::loncommon::end_data_table_header_row();
883: my $num = 0;
1.104 raeburn 884: my $counter = 1;
1.102 raeburn 885: foreach my $item (@sortforwards) {
886: $output .= &Apache::loncommon::start_data_table_row().
1.104 raeburn 887: '<td><b>'.$counter.'</b></td>'.
888: '<td><span class="LC_nobreak"><label>'.
889: '<input type="checkbox" name="modify_notify_'.
890: $num.'" onclick="javscript:modify_address('."'$num'".')" />'.
891: &mt('Modify').'</label></span> '.
892: '<span class="LC_nobreak"><label>'.
893: '<input type="checkbox" name="del_notify_'.$num.
894: '" onclick="javscript:delete_address('."'$num'".')" />'.
895: &mt('Delete').'</label></span></td>'.
1.102 raeburn 896: '<td><input type="text" value="'.$item.'" name="address_'.
1.104 raeburn 897: $num.'" onFocus="javascript:address_changes('."'$num'".
898: ')" /></td><td>';
1.102 raeburn 899: my %chk;
900: if (defined($allnot{$item}{'crit'})) {
901: if (defined($allnot{$item}{'reg'})) {
902: $chk{'all'} = 'checked="checked" ';
903: } else {
904: $chk{'crit'} = 'checked="checked" ';
905: }
906: } else {
907: $chk{'reg'} = 'checked="checked" ';
908: }
909: foreach my $type ('all','crit','reg') {
910: $output .= '<span class="LC_nobreak"><label>'.
911: '<input type="radio" name="notify_type_'.$num.
1.104 raeburn 912: '" value="'.$type.'" '.$chk{$type}.
913: ' onchange="javascript:address_changes('."'$num'".')" />'.
1.175 raeburn 914: $lt{$type}.'</label></span>'.(' ' x4);
1.102 raeburn 915: }
916: my $htmlon = '';
917: my $htmloff = '';
918: if (grep/^\Q$item\E/,@allow_html) {
919: $htmlon = 'checked="checked" ';
920: } else {
921: $htmloff = 'checked="checked" ';
922: }
923: $output .= '</td><td><label><input type="radio" name="html_'.$num.
1.104 raeburn 924: '" value="1" '.$htmlon.
925: ' onchange="javascript:address_changes('."'$num'".')" />'.
1.175 raeburn 926: &mt('Yes').'</label>'.(' ' x3).
1.102 raeburn 927: '<label><input type="radio" name="html_'.$num.'" value="0" '.
1.104 raeburn 928: $htmloff. ' onchange="javascript:address_changes('."'$num'".
929: ')" />'.
930: &mt('No').'</label></td>'.
1.102 raeburn 931: &Apache::loncommon::end_data_table_row();
932: $num ++;
1.104 raeburn 933: $counter ++;
1.102 raeburn 934: }
935: my %defchk = (
936: all => 'checked="checked" ',
937: crit => '',
938: reg => '',
939: );
940: $output .= &Apache::loncommon::start_data_table_row().
1.104 raeburn 941: '<td><b>'.$counter.'</b></td>'.
942: '<td><span class="LC_nobreak"><label>'.
943: '<input type="checkbox" name="add_notify_'.$num.
944: '" value="1" />'.&mt('Add new address').'</label></span></td>'.
1.102 raeburn 945: '<td><input type="text" value="" name="address_'.$num.
1.104 raeburn 946: '" onFocus="javascript:new_address('."'$num'".')" /></td><td>';
1.102 raeburn 947: foreach my $type ('all','crit','reg') {
948: $output .= '<span class="LC_nobreak"><label>'.
949: '<input type="radio" name="notify_type_'.$num.
950: '" value="'.$type.'" '.$defchk{$type}.'/>'.
1.175 raeburn 951: $lt{$type}.'</label></span>'.(' ' x4);
1.102 raeburn 952: }
953: $output .= '</td><td><label><input type="radio" name="html_'.$num.
1.175 raeburn 954: '" value="1" />'.&mt('Yes').'</label>'.(' ' x3).
1.102 raeburn 955: '<label><input type="radio" name="html_'.$num.'" value="0" '.
956: ' checked="checked" />'.
957: &mt('No').'</label></td>'.
958: &Apache::loncommon::end_data_table_row().
959: &Apache::loncommon::end_data_table();
960: $num ++;
961: $r->print($output);
962: $r->print(qq|
1.113 raeburn 963: <br /><hr />
1.102 raeburn 964: <input type="hidden" name="numnotify" value="$num" />
1.136 schafran 965: <input type="button" value="$lt{'prme'}" onclick="location.href='/adm/preferences'" />
1.102 raeburn 966: <input type="button" value="$lt{'chg'}" onclick="javascript:validate()" />
1.20 www 967: </form>
1.102 raeburn 968: |);
969:
970: }
971:
972: sub get_notifications {
973: my ($userenv) = @_;
974: my %allnot;
975: my @critnot = split(/,/,$userenv->{'critnotification'});
976: my @regnot = split(/,/,$userenv->{'notification'});
977: foreach my $item (@critnot) {
978: $allnot{$item}{crit} = 1;
979: }
980: foreach my $item (@regnot) {
981: $allnot{$item}{reg} = 1;
982: }
983: return %allnot;
1.20 www 984: }
985:
986: sub verify_and_change_msgforward {
987: my $r = shift;
1.59 albertel 988: my $user = $env{'user.name'};
989: my $domain = $env{'user.domain'};
1.20 www 990: my $newscreen = '';
991: my $message='';
1.59 albertel 992: foreach (split(/\,/,$env{'form.msgforward'})) {
1.20 www 993: my ($msuser,$msdomain)=split(/[\@\:]/,$_);
1.95 albertel 994: $msuser = &LONCAPA::clean_username($msuser);
995: $msdomain = &LONCAPA::clean_domain($msdomain);
1.20 www 996: if (($msuser) && ($msdomain)) {
997: if (&Apache::lonnet::homeserver($msuser,$msdomain) ne 'no_host') {
998: $newscreen.=$msuser.':'.$msdomain.',';
999: } else {
1.163 bisitz 1000: $message.= &mt('No such user: ').'<tt>'.$msuser.':'.$msdomain.'</tt><br />';
1.20 www 1001: }
1002: }
1003: }
1004: $newscreen=~s/\,$//;
1005: if ($newscreen) {
1006: &Apache::lonnet::put('environment',{'msgforward' => $newscreen});
1.116 raeburn 1007: &Apache::lonnet::appenv({'environment.msgforward' => $newscreen});
1.110 bisitz 1008: $message .= &mt('Set message forwarding to ').'<tt>"'.$newscreen.'"</tt>.'
1009: .'<br />';
1.20 www 1010: } else {
1011: &Apache::lonnet::del('environment',['msgforward']);
1.139 raeburn 1012: &Apache::lonnet::delenv('environment.msgforward');
1.102 raeburn 1013: $message.= &mt("Set message forwarding to 'off'.").'<br />';
1.20 www 1014: }
1.102 raeburn 1015: my $critnotification;
1016: my $notification;
1017: my $notify_with_html;
1018: my $lastnotify = $env{'form.numnotify'}-1;
1.104 raeburn 1019: my $totaladdresses = 0;
1.102 raeburn 1020: for (my $i=0; $i<$env{'form.numnotify'}; $i++) {
1021: if ((!defined($env{'form.del_notify_'.$i})) &&
1.104 raeburn 1022: ((($i==$lastnotify) && ($env{'form.add_notify_'.$lastnotify} == 1)) ||
1.102 raeburn 1023: ($i<$lastnotify))) {
1024: if (defined($env{'form.address_'.$i})) {
1025: if ($env{'form.notify_type_'.$i} eq 'all') {
1026: $critnotification .= $env{'form.address_'.$i}.',';
1027: $notification .= $env{'form.address_'.$i}.',';
1028: } elsif ($env{'form.notify_type_'.$i} eq 'crit') {
1029: $critnotification .= $env{'form.address_'.$i}.',';
1030: } elsif ($env{'form.notify_type_'.$i} eq 'reg') {
1031: $notification .= $env{'form.address_'.$i}.',';
1032: }
1033: if ($env{'form.html_'.$i} eq '1') {
1034: $notify_with_html .= $env{'form.address_'.$i}.',';
1035: }
1.104 raeburn 1036: $totaladdresses ++;
1.102 raeburn 1037: }
1038: }
1039: }
1040: $critnotification =~ s/,$//;
1041: $critnotification=~s/\s//gs;
1042: $notification =~ s/,$//;
1.20 www 1043: $notification=~s/\s//gs;
1.102 raeburn 1044: $notify_with_html =~ s/,$//;
1045: $notify_with_html =~ s/\s//gs;
1.20 www 1046: if ($notification) {
1047: &Apache::lonnet::put('environment',{'notification' => $notification});
1.116 raeburn 1048: &Apache::lonnet::appenv({'environment.notification' => $notification});
1.110 bisitz 1049: $message.=&mt('Set non-critical message notification address(es) to ').'<tt>"'.$notification.'"</tt>.<br />';
1.20 www 1050: } else {
1051: &Apache::lonnet::del('environment',['notification']);
1.139 raeburn 1052: &Apache::lonnet::delenv('environment.notification');
1.110 bisitz 1053: $message.=&mt("Set non-critical message notification to 'off'.").'<br />';
1.20 www 1054: }
1055: if ($critnotification) {
1056: &Apache::lonnet::put('environment',{'critnotification' => $critnotification});
1.116 raeburn 1057: &Apache::lonnet::appenv({'environment.critnotification' => $critnotification});
1.110 bisitz 1058: $message.=&mt('Set critical message notification address(es) to ').'<tt>"'.$critnotification.'"</tt>.<br />';
1.20 www 1059: } else {
1060: &Apache::lonnet::del('environment',['critnotification']);
1.139 raeburn 1061: &Apache::lonnet::delenv('environment.critnotification');
1.110 bisitz 1062: $message.=&mt("Set critical message notification to 'off'.").'<br />';
1.102 raeburn 1063: }
1064: if ($critnotification || $notification) {
1065: if ($notify_with_html) {
1066: &Apache::lonnet::put('environment',{'notifywithhtml' => $notify_with_html});
1.116 raeburn 1067: &Apache::lonnet::appenv({'environment.notifywithhtml' => $notify_with_html});
1.110 bisitz 1068: $message.=&mt('Set address(es) to receive excerpts with html retained ').'<tt>"'.$notify_with_html.'"</tt>.';
1.102 raeburn 1069: } else {
1070: &Apache::lonnet::del('environment',['notifywithhtml']);
1.139 raeburn 1071: &Apache::lonnet::delenv('environment.notifywithhtml');
1.104 raeburn 1072: if ($totaladdresses == 1) {
1073: $message.=&mt("Set notification address to receive excerpts with html stripped.");
1074: } else {
1075: $message.=&mt("Set all notification addresses to receive excerpts with html stripped.");
1076: }
1.102 raeburn 1077: }
1078: } else {
1079: &Apache::lonnet::del('environment',['notifywithhtml']);
1.139 raeburn 1080: &Apache::lonnet::delenv('environment.notifywithhtml');
1.102 raeburn 1081: }
1082: if ($message) {
1083: $message .= '<br /><hr />';
1.20 www 1084: }
1.109 albertel 1085: &Apache::loncommon::flush_email_cache($user,$domain);
1.102 raeburn 1086: &msgforwardchanger($r,$message);
1.6 www 1087: }
1088:
1.12 www 1089: ################################################################
1.19 www 1090: # Colors #
1.12 www 1091: ################################################################
1092:
1.19 www 1093: sub colorschanger {
1.12 www 1094: my $r = shift;
1.126 droeschl 1095: Apache::lonhtmlcommon::add_breadcrumb(
1096: { href => '/adm/preferences?action=changecolors',
1097: text => 'Change Colors'});
1.147 schafran 1098: $r->print(Apache::loncommon::start_page('Page Display Settings'));
1.126 droeschl 1099: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Colors'));
1.19 www 1100: # figure out colors
1.80 albertel 1101: my $function=&Apache::loncommon::get_users_function();
1.19 www 1102: my $domain=&Apache::loncommon::determinedomain();
1.157 bisitz 1103: my %colortypes=&Apache::lonlocal::texthash(
1104: 'pgbg' => 'Page Background Color',
1105: 'tabbg' => 'Header Background Color',
1106: 'sidebg' => 'Header Border Color',
1107: 'font' => 'Font Color',
1108: 'fontmenu' => 'Font Menu Color',
1109: 'link' => 'Un-Visited Link Color',
1110: 'vlink' => 'Visited Link Color',
1111: 'alink' => 'Active Link Color',
1112: );
1.82 albertel 1113: my $start_data_table = &Apache::loncommon::start_data_table();
1.19 www 1114: my $chtable='';
1.22 matthew 1115: foreach my $item (sort(keys(%colortypes))) {
1.19 www 1116: my $curcol=&Apache::loncommon::designparm($function.'.'.$item,$domain);
1.82 albertel 1117: $chtable.=&Apache::loncommon::start_data_table_row().
1.83 albertel 1118: '<td>'.$colortypes{$item}.'</td><td style="background: '.$curcol.
1.19 www 1119: '"> </td><td><input name="'.$item.
1.21 www 1120: '" size="10" value="'.$curcol.
1121: '" /></td><td><a href="javascript:pjump('."'color_custom','".$colortypes{$item}.
1.19 www 1122: "','".$curcol."','"
1.157 bisitz 1123: .$item."','parmform.pres','psub'".');">'.&mt('Select').'</a></td>'.
1.83 albertel 1124: &Apache::loncommon::end_data_table_row()."\n";
1.19 www 1125: }
1.82 albertel 1126: my $end_data_table = &Apache::loncommon::end_data_table();
1.23 matthew 1127: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.157 bisitz 1128: my $savebutton = &mt('Save');
1129: my $resetbutton = &mt('Reset All');
1130: my $resetbuttondesc = &mt('Reset All Colors to Default');
1.19 www 1131: $r->print(<<ENDCOL);
1.148 bisitz 1132: <script type="text/javascript" language="JavaScript">
1.19 www 1133:
1134: function pclose() {
1135: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
1136: "height=350,width=350,scrollbars=no,menubar=no");
1137: parmwin.close();
1138: }
1139:
1.23 matthew 1140: $pjump_def
1.19 www 1141:
1142: function psub() {
1143: pclose();
1144: if (document.parmform.pres_marker.value!='') {
1.21 www 1145: if (document.parmform.pres_type.value!='') {
1.77 albertel 1146: eval('document.prefs.'+
1.21 www 1147: document.parmform.pres_marker.value+
1.19 www 1148: '.value=document.parmform.pres_value.value;');
1.21 www 1149: }
1.19 www 1150: } else {
1151: document.parmform.pres_value.value='';
1152: document.parmform.pres_marker.value='';
1153: }
1154: }
1155:
1156:
1157: </script>
1.21 www 1158: <form name="parmform">
1159: <input type="hidden" name="pres_marker" />
1160: <input type="hidden" name="pres_type" />
1161: <input type="hidden" name="pres_value" />
1162: </form>
1.88 albertel 1163: <form name="prefs" action="/adm/preferences" method="post">
1.19 www 1164: <input type="hidden" name="action" value="verify_and_change_colors" />
1.82 albertel 1165: $start_data_table
1.19 www 1166: $chtable
1.82 albertel 1167: $end_data_table
1.19 www 1168: </table>
1.157 bisitz 1169: <p>
1170: <input type="submit" value="$savebutton" />
1171: <input type="submit" name="resetall" value="$resetbutton" title="$resetbuttondesc" />
1172: </p>
1.12 www 1173: </form>
1.19 www 1174: ENDCOL
1.12 www 1175: }
1176:
1.19 www 1177: sub verify_and_change_colors {
1.12 www 1178: my $r = shift;
1.19 www 1179: # figure out colors
1.80 albertel 1180: my $function=&Apache::loncommon::get_users_function();
1.19 www 1181: my $domain=&Apache::loncommon::determinedomain();
1.157 bisitz 1182: my %colortypes=&Apache::lonlocal::texthash(
1183: 'pgbg' => 'Page Background Color',
1184: 'tabbg' => 'Header Background Color',
1185: 'sidebg' => 'Header Border Color',
1186: 'font' => 'Font Color',
1187: 'fontmenu' => 'Font Menu Color',
1188: 'link' => 'Un-Visited Link Color',
1189: 'vlink' => 'Visited Link Color',
1190: 'alink' => 'Active Link Color',
1191: );
1.19 www 1192:
1.12 www 1193: my $message='';
1.21 www 1194: foreach my $item (keys %colortypes) {
1.59 albertel 1195: my $color=$env{'form.'.$item};
1.21 www 1196: my $entry='color.'.$function.'.'.$item;
1.59 albertel 1197: if (($color=~/^\#[0-9A-Fa-f]{6}$/) && (!$env{'form.resetall'})) {
1.21 www 1198: &Apache::lonnet::put('environment',{$entry => $color});
1.116 raeburn 1199: &Apache::lonnet::appenv({'environment.'.$entry => $color});
1.157 bisitz 1200: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]','<i>'.$colortypes{$item}.'</i>','<tt>"'.$color.'"</tt>'))
1201: .'<br />';
1.21 www 1202: } else {
1203: &Apache::lonnet::del('environment',[$entry]);
1.138 schafran 1204: &Apache::lonnet::delenv('environment.'.$entry);
1.157 bisitz 1205: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Reset [_1]','<i>'.$colortypes{$item}.'</i>'))
1206: .'<br />';
1.21 www 1207: }
1208: }
1.158 bisitz 1209: $message=&Apache::loncommon::confirmwrapper($message);
1.157 bisitz 1210:
1.84 albertel 1211: my $now = time;
1212: &Apache::lonnet::put('environment',{'color.timestamp' => $now});
1.116 raeburn 1213: &Apache::lonnet::appenv({'environment.color.timestamp' => $now});
1.84 albertel 1214:
1.152 www 1215: &print_main_menu($r, $message);
1.12 www 1216: }
1217:
1.4 matthew 1218: ######################################################
1219: # password handler subroutines #
1220: ######################################################
1.3 matthew 1221: sub passwordchanger {
1.94 raeburn 1222: my ($r,$errormessage,$caller,$mailtoken) = @_;
1.4 matthew 1223: # This function is a bit of a mess....
1.3 matthew 1224: # Passwords are encrypted using londes.js (DES encryption)
1.4 matthew 1225: $errormessage = ($errormessage || '');
1.94 raeburn 1226: my ($user,$domain,$currentpass,$defdom);
1.152 www 1227: &Apache::lonhtmlcommon::add_breadcrumb(
1.126 droeschl 1228: { href => '/adm/preferences?action=changepass',
1229: text => 'Change Password'});
1.144 raeburn 1230: unless ($caller eq 'reset_by_email') {
1.147 schafran 1231: $r->print(Apache::loncommon::start_page('Personal Data'));
1.144 raeburn 1232: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Password'));
1233: }
1.94 raeburn 1234: if ((!defined($caller)) || ($caller eq 'preferences')) {
1235: $user = $env{'user.name'};
1236: $domain = $env{'user.domain'};
1237: if (!defined($caller)) {
1238: $caller = 'preferences';
1239: }
1240: } elsif ($caller eq 'reset_by_email') {
1241: $defdom = $r->dir_config('lonDefDomain');
1242: my %data = &Apache::lonnet::tmpget($mailtoken);
1243: if (keys(%data) == 0) {
1.155 bisitz 1244: $r->print(&mt('Sorry, the URL you provided to complete the reset of your password was invalid. Either the token included in the URL has been deleted or the URL you provided was invalid. Please submit a [_1]new request[_2] for a password reset, and follow the link to the new URL included in the e-mail that will be sent to you, to allow you to enter a new password.'
1245: ,'<a href="/adm/resetpw">','</a>')
1246: );
1.94 raeburn 1247: return;
1248: }
1249: if (defined($data{time})) {
1250: if (time - $data{'time'} < 7200) {
1251: $user = $data{'username'};
1252: $domain = $data{'domain'};
1253: $currentpass = $data{'temppasswd'};
1254: } else {
1255: $r->print(&mt('Sorry, the token generated when you requested a password reset has expired.').'<br />');
1256: return;
1257: }
1258: } else {
1259: $r->print(&mt('Sorry, the URL generated when you requested reset of your password contained incomplete information.').'<br />');
1260: return;
1261: }
1262: } else {
1263: $r->print(&mt('Page requested in unexpected context').'<br />');
1264: return;
1265: }
1.3 matthew 1266: my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
1267: # Check for authentication types that allow changing of the password.
1268: return if ($currentauth !~ /^(unix|internal):/);
1269: #
1270: # Generate keys
1271: my ($lkey_cpass ,$ukey_cpass ) = &des_keys();
1272: my ($lkey_npass1,$ukey_npass1) = &des_keys();
1273: my ($lkey_npass2,$ukey_npass2) = &des_keys();
1.4 matthew 1274: # Store the keys in the log files
1.3 matthew 1275: my $lonhost = $r->dir_config('lonHostID');
1276: my $logtoken=Apache::lonnet::reply('tmpput:'
1277: .$ukey_cpass . $lkey_cpass .'&'
1278: .$ukey_npass1 . $lkey_npass1.'&'
1279: .$ukey_npass2 . $lkey_npass2,
1280: $lonhost);
1.4 matthew 1281: # Hexify the keys for output as javascript variables
1.94 raeburn 1282: my %hexkey;
1283: $hexkey{'ukey_cpass'} = hex($ukey_cpass);
1284: $hexkey{'lkey_cpass'} = hex($lkey_cpass);
1285: $hexkey{'ukey_npass1'} = hex($ukey_npass1);
1286: $hexkey{'lkey_npass1'} = hex($lkey_npass1);
1287: $hexkey{'ukey_npass2'} = hex($ukey_npass2);
1288: $hexkey{'lkey_npass2'} = hex($lkey_npass2);
1.3 matthew 1289: # Output javascript to deal with passwords
1.4 matthew 1290: # Output DES javascript
1.3 matthew 1291: {
1292: my $include = $r->dir_config('lonIncludes');
1293: my $jsh=Apache::File->new($include."/londes.js");
1294: $r->print(<$jsh>);
1295: }
1.94 raeburn 1296: $r->print(&jscript_send($caller));
1.3 matthew 1297: $r->print(<<ENDFORM);
1.94 raeburn 1298: $errormessage
1299:
1300: <p>
1301: <!-- We separate the forms into 'server' and 'client' in order to
1302: ensure that unencrypted passwords will not be sent out by a
1303: crappy browser -->
1304: ENDFORM
1305: $r->print(&server_form($logtoken,$caller,$mailtoken));
1306: $r->print(&client_form($caller,\%hexkey,$currentpass,$defdom));
1307:
1308: #
1309: return;
1310: }
1311:
1312: sub jscript_send {
1313: my ($caller) = @_;
1314: my $output = qq|
1.148 bisitz 1315: <script type="text/javascript" language="JavaScript">
1.3 matthew 1316:
1317: function send() {
1318: uextkey=this.document.client.elements.ukey_cpass.value;
1319: lextkey=this.document.client.elements.lkey_cpass.value;
1320: initkeys();
1321:
1.52 raeburn 1322: this.document.pserver.elements.currentpass.value
1.3 matthew 1323: =crypted(this.document.client.elements.currentpass.value);
1324:
1325: uextkey=this.document.client.elements.ukey_npass1.value;
1326: lextkey=this.document.client.elements.lkey_npass1.value;
1327: initkeys();
1.52 raeburn 1328: this.document.pserver.elements.newpass_1.value
1.3 matthew 1329: =crypted(this.document.client.elements.newpass_1.value);
1330:
1331: uextkey=this.document.client.elements.ukey_npass2.value;
1332: lextkey=this.document.client.elements.lkey_npass2.value;
1333: initkeys();
1.52 raeburn 1334: this.document.pserver.elements.newpass_2.value
1.3 matthew 1335: =crypted(this.document.client.elements.newpass_2.value);
1.94 raeburn 1336: |;
1337: if ($caller eq 'reset_by_email') {
1338: $output .= qq|
1339: this.document.pserver.elements.uname.value =
1340: this.document.client.elements.uname.value;
1341: this.document.pserver.elements.udom.value =
1342: this.document.client.elements.udom.options[this.document.client.elements.udom.selectedIndex].value;
1.173 raeburn 1343: this.document.pserver.elements.email.value =
1344: this.document.client.elements.email.value;
1.94 raeburn 1345: |;
1346: }
1347: $ output .= qq|
1.52 raeburn 1348: this.document.pserver.submit();
1.3 matthew 1349: }
1350: </script>
1.94 raeburn 1351: |;
1352: }
1.3 matthew 1353:
1.94 raeburn 1354: sub client_form {
1355: my ($caller,$hexkey,$currentpass,$defdom) = @_;
1.99 www 1356: my %lt=&Apache::lonlocal::texthash(
1.115 raeburn 1357: 'email' => 'E-mail Address',
1.99 www 1358: 'username' => 'Username',
1359: 'domain' => 'Domain',
1360: 'currentpass' => 'Current Password',
1361: 'newpass' => 'New Password',
1362: 'confirmpass' => 'Confirm Password',
1.169 raeburn 1363: 'changepass' => 'Save',
1364: );
1.99 www 1365:
1.164 bisitz 1366: my $output = '<form name="client">'
1367: .&Apache::lonhtmlcommon::start_pick_box();
1.94 raeburn 1368: if ($caller eq 'reset_by_email') {
1.164 bisitz 1369: $output .= &Apache::lonhtmlcommon::row_title(
1370: '<label for="email">'.$lt{'email'}.'</label>')
1371: .'<input type="text" name="email" size="30" />'
1372: .&Apache::lonhtmlcommon::row_closure()
1373: .&Apache::lonhtmlcommon::row_title(
1374: '<label for="uname">'.$lt{'username'}.'</label>')
1375: .'<input type="text" name="uname" size="15" />'
1376: .'<input type="hidden" name="currentpass" value="'.$currentpass.'" />'
1377: .&Apache::lonhtmlcommon::row_closure()
1378: .&Apache::lonhtmlcommon::row_title(
1379: '<label for="udom">'.$lt{'domain'}.'</label>')
1380: .&Apache::loncommon::select_dom_form($defdom,'udom')
1381: .&Apache::lonhtmlcommon::row_closure();
1.94 raeburn 1382: } else {
1.164 bisitz 1383: $output .= &Apache::lonhtmlcommon::row_title(
1384: '<label for="currentpass">'.$lt{'currentpass'}.'</label>')
1385: .'<input type="password" name="currentpass" size="10"/>'
1386: .&Apache::lonhtmlcommon::row_closure();
1387: }
1388: $output .= &Apache::lonhtmlcommon::row_title(
1389: '<label for="newpass_1">'.$lt{'newpass'}.'</label>')
1390: .'<input type="password" name="newpass_1" size="10" />'
1391: .&Apache::lonhtmlcommon::row_closure()
1392: .&Apache::lonhtmlcommon::row_title(
1393: '<label for="newpass_2">'.$lt{'confirmpass'}.'</label>')
1394: .'<input type="password" name="newpass_2" size="10" />'
1395: .&Apache::lonhtmlcommon::row_closure(1)
1396: .&Apache::lonhtmlcommon::end_pick_box();
1397: $output .= '<p><input type="button" value="'.$lt{'changepass'}.'" onClick="send();" /></p>'
1398: .qq|
1.94 raeburn 1399: <input type="hidden" name="ukey_cpass" value="$hexkey->{'ukey_cpass'}" />
1400: <input type="hidden" name="lkey_cpass" value="$hexkey->{'lkey_cpass'}" />
1401: <input type="hidden" name="ukey_npass1" value="$hexkey->{'ukey_npass1'}" />
1402: <input type="hidden" name="lkey_npass1" value="$hexkey->{'lkey_npass1'}" />
1403: <input type="hidden" name="ukey_npass2" value="$hexkey->{'ukey_npass2'}" />
1404: <input type="hidden" name="lkey_npass2" value="$hexkey->{'lkey_npass2'}" />
1.3 matthew 1405: </form>
1406: </p>
1.164 bisitz 1407: |;
1.94 raeburn 1408: return $output;
1409: }
1410:
1411: sub server_form {
1412: my ($logtoken,$caller,$mailtoken) = @_;
1413: my $action = '/adm/preferences';
1414: if ($caller eq 'reset_by_email') {
1415: $action = '/adm/resetpw';
1416: }
1417: my $output = qq|
1418: <form name="pserver" action="$action" method="post">
1419: <input type="hidden" name="logtoken" value="$logtoken" />
1420: <input type="hidden" name="currentpass" value="" />
1421: <input type="hidden" name="newpass_1" value="" />
1422: <input type="hidden" name="newpass_2" value="" />
1423: |;
1424: if ($caller eq 'reset_by_email') {
1425: $output .= qq|
1426: <input type="hidden" name="token" value="$mailtoken" />
1427: <input type="hidden" name="uname" value="" />
1428: <input type="hidden" name="udom" value="" />
1.173 raeburn 1429: <input type="hidden" name="email" value="" />
1.94 raeburn 1430:
1431: |;
1432: }
1433: $output .= qq|
1434: <input type="hidden" name="action" value="verify_and_change_pass" />
1435: </form>
1436: |;
1437: return $output;
1.3 matthew 1438: }
1439:
1440: sub verify_and_change_password {
1.94 raeburn 1441: my ($r,$caller,$mailtoken) = @_;
1442: my ($user,$domain,$homeserver);
1443: if ($caller eq 'reset_by_email') {
1444: $user = $env{'form.uname'};
1445: $domain = $env{'form.udom'};
1446: if ($user ne '' && $domain ne '') {
1447: $homeserver = &Apache::lonnet::homeserver($user,$domain);
1448: if ($homeserver eq 'no_host') {
1.99 www 1449: &passwordchanger($r,"<p>\n<span class='LC_error'>".
1450: &mt("Invalid username and/or domain")."</span>\n</p>",
1.94 raeburn 1451: $caller,$mailtoken);
1452: return 1;
1453: }
1454: } else {
1.99 www 1455: &passwordchanger($r,"<p>\n<span class='LC_error'>".
1456: &mt("Username and domain were blank")."</span>\n</p>",
1.94 raeburn 1457: $caller,$mailtoken);
1458: return 1;
1459: }
1460: } else {
1461: $user = $env{'user.name'};
1462: $domain = $env{'user.domain'};
1463: $homeserver = $env{'user.home'};
1464: }
1.3 matthew 1465: my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
1.4 matthew 1466: # Check for authentication types that allow changing of the password.
1.94 raeburn 1467: if ($currentauth !~ /^(unix|internal):/) {
1468: if ($caller eq 'reset_by_email') {
1.99 www 1469: &passwordchanger($r,"<p>\n<span class='LC_error'>".
1470: &mt("Authentication type for this user can not be changed by this mechanism").
1471: "</span>\n</p>",
1.94 raeburn 1472: $caller,$mailtoken);
1473: return 1;
1474: } else {
1475: return;
1476: }
1477: }
1.3 matthew 1478: #
1.59 albertel 1479: my $currentpass = $env{'form.currentpass'};
1480: my $newpass1 = $env{'form.newpass_1'};
1481: my $newpass2 = $env{'form.newpass_2'};
1482: my $logtoken = $env{'form.logtoken'};
1.3 matthew 1483: # Check for empty data
1.4 matthew 1484: unless (defined($currentpass) &&
1485: defined($newpass1) &&
1486: defined($newpass2) ){
1.99 www 1487: &passwordchanger($r,"<p>\n<span class='LC_error'>".
1488: &mt("One or more password fields were blank").
1489: "</span>\n</p>",$caller,$mailtoken);
1.3 matthew 1490: return;
1491: }
1.16 albertel 1492: # Get the keys
1493: my $lonhost = $r->dir_config('lonHostID');
1.3 matthew 1494: my $tmpinfo = Apache::lonnet::reply('tmpget:'.$logtoken,$lonhost);
1495: if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) {
1.4 matthew 1496: # I do not a have a better idea about how to handle this
1.94 raeburn 1497: my $tryagain_text = &mt('Please log out and try again.');
1498: if ($caller eq 'reset_by_email') {
1499: $tryagain_text = &mt('Please try again later.');
1500: }
1.101 albertel 1501: my $unable=&mt("Unable to retrieve saved token for password decryption");
1.3 matthew 1502: $r->print(<<ENDERROR);
1503: <p>
1.99 www 1504: <span class="LC_error">$unable. $tryagain_text</span>
1.3 matthew 1505: </p>
1506: ENDERROR
1.4 matthew 1507: # Probably should log an error here
1.75 albertel 1508: return 1;
1.3 matthew 1509: }
1510: my ($ckey,$n1key,$n2key)=split(/&/,$tmpinfo);
1.4 matthew 1511: #
1.17 matthew 1512: $currentpass = &des_decrypt($ckey ,$currentpass);
1513: $newpass1 = &des_decrypt($n1key,$newpass1);
1514: $newpass2 = &des_decrypt($n2key,$newpass2);
1.94 raeburn 1515: #
1516: if ($caller eq 'reset_by_email') {
1517: my %data = &Apache::lonnet::tmpget($mailtoken);
1.117 raeburn 1518: if (keys(%data) == 0) {
1519: &passwordchanger($r,
1520: '<span class="LC_error">'.
1521: &mt('Could not verify current authentication.').' '.
1522: &mt('Please try again.').'</span>',$caller,$mailtoken);
1523: return 1;
1524: }
1.94 raeburn 1525: if ($currentpass ne $data{'temppasswd'}) {
1526: &passwordchanger($r,
1.99 www 1527: '<span class="LC_error">'.
1.110 bisitz 1528: &mt('Could not verify current authentication.').' '.
1529: &mt('Please try again.').'</span>',$caller,$mailtoken);
1.94 raeburn 1530: return 1;
1531: }
1532: }
1.3 matthew 1533: if ($newpass1 ne $newpass2) {
1.4 matthew 1534: &passwordchanger($r,
1.99 www 1535: '<span class="LC_error">'.
1.110 bisitz 1536: &mt('The new passwords you entered do not match.').' '.
1537: &mt('Please try again.').'</span>',$caller,$mailtoken);
1.75 albertel 1538: return 1;
1.4 matthew 1539: }
1540: if (length($newpass1) < 7) {
1541: &passwordchanger($r,
1.99 www 1542: '<span class="LC_error">'.
1.110 bisitz 1543: &mt('Passwords must be a minimum of 7 characters long.').' '.
1544: &mt('Please try again.').'</span>',$caller,$mailtoken);
1.75 albertel 1545: return 1;
1.3 matthew 1546: }
1.4 matthew 1547: #
1548: # Check for bad characters
1549: my $badpassword = 0;
1550: foreach (split(//,$newpass1)) {
1551: $badpassword = 1 if ((ord($_)<32)||(ord($_)>126));
1552: }
1553: if ($badpassword) {
1554: # I can't figure out how to enter bad characters on my browser.
1.99 www 1555: my $errormessage ='<span class="LC_error">'.
1.110 bisitz 1556: &mt('The password you entered contained illegal characters.').'<br />'.
1.99 www 1557: &mt('Valid characters are').(<<"ENDERROR");
1558: : space and <br />
1.4 matthew 1559: <pre>
1560: !"\#$%&\'()*+,-./0123456789:;<=>?\@
1561: ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}~
1.99 www 1562: </pre></span>
1.4 matthew 1563: ENDERROR
1.94 raeburn 1564: &passwordchanger($r,$errormessage,$caller,$mailtoken);
1565: return 1;
1.4 matthew 1566: }
1567: #
1568: # Change the password (finally)
1569: my $result = &Apache::lonnet::changepass
1.94 raeburn 1570: ($user,$domain,$currentpass,$newpass1,$homeserver,$caller);
1.4 matthew 1571: # Inform the user the password has (not?) been changed
1.126 droeschl 1572: my $message;
1.4 matthew 1573: if ($result =~ /^ok$/) {
1.170 bisitz 1574: $message = &Apache::lonhtmlcommon::confirm_success(&mt('The password for user [_1] was successfully changed.','<i>'.$user.'</i>'));
1.144 raeburn 1575: if ($caller eq 'reset_by_email') {
1576: $r->print($message.'<br />');
1577: } else {
1578: &print_main_menu($r, $message);
1579: }
1.4 matthew 1580: } else {
1581: # error error: run in circles, scream and shout
1.173 raeburn 1582: if ($caller eq 'reset_by_email') {
1583: if (!$result) {
1584: return 1;
1585: } else {
1586: return $result;
1587: }
1588: } else {
1589: $message = &Apache::lonhtmlcommon::confirm_success(
1590: &mt("The password for user [_1] was not changed.",'<i>'.$user.'</i>').' '.&mt('Please make sure your old password was entered correctly.'),1);
1.158 bisitz 1591: $message=&Apache::loncommon::confirmwrapper($message);
1.144 raeburn 1592: &print_main_menu($r, $message);
1593: }
1.4 matthew 1594: }
1595: return;
1.3 matthew 1596: }
1597:
1.42 raeburn 1598: ################################################################
1599: # discussion display subroutines
1600: ################################################################
1601: sub discussionchanger {
1602: my $r = shift;
1.126 droeschl 1603: Apache::lonhtmlcommon::add_breadcrumb(
1604: { href => '/adm/preferences?action=changediscussions',
1605: text => 'Change Discussion Preferences'});
1.178 ! bisitz 1606: $r->print(Apache::loncommon::start_page('Change Discussion Preferences'));
1.126 droeschl 1607: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Discussion Preferences'));
1.59 albertel 1608: my $user = $env{'user.name'};
1609: my $domain = $env{'user.domain'};
1.42 raeburn 1610: my %userenv = &Apache::lonnet::get
1.43 raeburn 1611: ('environment',['discdisplay','discmarkread']);
1612: my $discdisp = 'allposts';
1613: my $discmark = 'onmark';
1614:
1615: if (defined($userenv{'discdisplay'})) {
1616: unless ($userenv{'discdisplay'} eq '') {
1617: $discdisp = $userenv{'discdisplay'};
1618: }
1619: }
1620: if (defined($userenv{'discmarkread'})) {
1.171 raeburn 1621: unless ($userenv{'discmarkread'} eq '') {
1.43 raeburn 1622: $discmark = $userenv{'discmarkread'};
1623: }
1624: }
1625:
1626: my $newdisp = 'unread';
1627: my $newmark = 'ondisp';
1628:
1629: my $function = &Apache::loncommon::get_users_function();
1630: my $color = &Apache::loncommon::designparm($function.'.tabbg',
1.59 albertel 1631: $env{'user.domain'});
1.43 raeburn 1632: my %lt = &Apache::lonlocal::texthash(
1633: 'pref' => 'Display Preference',
1634: 'curr' => 'Current setting ',
1635: 'actn' => 'Action',
1.135 schafran 1636: 'sdpf' => 'Set display preferences for discussion posts for both discussion boards and individual resources in all your courses.',
1.43 raeburn 1637: 'prca' => 'Preferences can be set that determine',
1.135 schafran 1638: 'whpo' => 'Which posts are displayed when you display a discussion board or resource, and',
1.43 raeburn 1639: 'unwh' => 'Under what circumstances posts are identfied as "New"',
1640: 'allposts' => 'All posts',
1641: 'unread' => 'New posts only',
1642: 'ondisp' => 'Once displayed',
1643: 'onmark' => 'Once marked as read',
1644: 'disa' => 'Posts displayed?',
1645: 'npmr' => 'New posts cease to be identified as "New"?',
1646: 'thde' => 'The preferences you set here can be overridden within each individual discussion.',
1647: 'chgt' => 'Change to '
1648: );
1649: my $dispchange = $lt{'unread'};
1650: my $markchange = $lt{'ondisp'};
1651: my $currdisp = $lt{'allposts'};
1652: my $currmark = $lt{'onmark'};
1653:
1654: if ($discdisp eq 'unread') {
1655: $dispchange = $lt{'allposts'};
1656: $currdisp = $lt{'unread'};
1657: $newdisp = 'allposts';
1658: }
1659:
1660: if ($discmark eq 'ondisp') {
1661: $markchange = $lt{'onmark'};
1662: $currmark = $lt{'ondisp'};
1663: $newmark = 'onmark';
1.42 raeburn 1664: }
1.171 raeburn 1665:
1.43 raeburn 1666: $r->print(<<"END");
1.88 albertel 1667: <form name="prefs" action="/adm/preferences" method="post">
1.42 raeburn 1668: <input type="hidden" name="action" value="verify_and_change_discussion" />
1669: <br />
1.87 albertel 1670: $lt{'sdpf'}<br /> $lt{'prca'} <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li></ol>
1.82 albertel 1671: END
1.158 bisitz 1672:
1673: $r->print('<p class="LC_info">'.$lt{'thde'}.'</p>');
1674:
1.82 albertel 1675: $r->print(&Apache::loncommon::start_data_table());
1676: $r->print(<<"END");
1677: <tr>
1678: <th>$lt{'pref'}</th>
1679: <th>$lt{'curr'}</th>
1680: <th>$lt{'actn'}?</th>
1.43 raeburn 1681: </tr>
1.82 albertel 1682: END
1683: $r->print(&Apache::loncommon::start_data_table_row());
1684: $r->print(<<"END");
1.43 raeburn 1685: <td>$lt{'disa'}</td>
1686: <td>$lt{$discdisp}</td>
1.82 albertel 1687: <td><label><input type="checkbox" name="discdisp" /><input type="hidden" name="newdisp" value="$newdisp" /> $lt{'chgt'} "$dispchange"</label></td>
1688: END
1689: $r->print(&Apache::loncommon::end_data_table_row().
1690: &Apache::loncommon::start_data_table_row());
1691: $r->print(<<"END");
1.43 raeburn 1692: <td>$lt{'npmr'}</td>
1693: <td>$lt{$discmark}</td>
1.82 albertel 1694: <td><label><input type="checkbox" name="discmark" /><input type="hidden" name="newmark" value="$newmark" /> $lt{'chgt'} "$markchange"</label></td>
1.43 raeburn 1695: </tr>
1.82 albertel 1696: END
1697: $r->print(&Apache::loncommon::end_data_table_row().
1698: &Apache::loncommon::end_data_table());
1.142 zhu 1699:
1.158 bisitz 1700: $r->print('<br />'
1701: .'<input type="submit" name="sub" value="'.&mt('Save').'" />'
1702: .'</form>'
1703: );
1.42 raeburn 1704: }
1705:
1706: sub verify_and_change_discussion {
1707: my $r = shift;
1.59 albertel 1708: my $user = $env{'user.name'};
1709: my $domain = $env{'user.domain'};
1.42 raeburn 1710: my $message='';
1.59 albertel 1711: if (defined($env{'form.discdisp'}) ) {
1712: my $newdisp = $env{'form.newdisp'};
1.43 raeburn 1713: if ($newdisp eq 'unread') {
1.171 raeburn 1714: $message .=&Apache::lonhtmlcommon::confirm_success(&mt('In discussions: only new posts will be displayed.')).'<br />';
1.43 raeburn 1715: &Apache::lonnet::put('environment',{'discdisplay' => $newdisp});
1.116 raeburn 1716: &Apache::lonnet::appenv({'environment.discdisplay' => $newdisp});
1.43 raeburn 1717: } else {
1.171 raeburn 1718: $message .= &Apache::lonhtmlcommon::confirm_success(&mt('In discussions: all posts will be displayed.')).'<br />';
1.43 raeburn 1719: &Apache::lonnet::del('environment',['discdisplay']);
1.139 raeburn 1720: &Apache::lonnet::delenv('environment.discdisplay');
1.43 raeburn 1721: }
1722: }
1.59 albertel 1723: if (defined($env{'form.discmark'}) ) {
1724: my $newmark = $env{'form.newmark'};
1.43 raeburn 1725: if ($newmark eq 'ondisp') {
1.152 www 1726: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('In discussions: new posts will be cease to be identified as "NEW" after display.')).'<br />';
1.43 raeburn 1727: &Apache::lonnet::put('environment',{'discmarkread' => $newmark});
1.116 raeburn 1728: &Apache::lonnet::appenv({'environment.discmarkread' => $newmark});
1.43 raeburn 1729: } else {
1.152 www 1730: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('In discussions: posts will be identified as "NEW" until marked as read by the reader.')).'<br />';
1.43 raeburn 1731: &Apache::lonnet::del('environment',['discmarkread']);
1.139 raeburn 1732: &Apache::lonnet::delenv('environment.discmarkread');
1.43 raeburn 1733: }
1.42 raeburn 1734: }
1.158 bisitz 1735: $message=&Apache::loncommon::confirmwrapper($message);
1.152 www 1736: &print_main_menu($r, $message);
1.42 raeburn 1737: }
1738:
1.63 raeburn 1739: ################################################################
1740: # Subroutines for page display on course access (Course Coordinators)
1741: ################################################################
1742: sub coursedisplaychanger {
1743: my $r = shift;
1.152 www 1744: &Apache::lonhtmlcommon::add_breadcrumb(
1.126 droeschl 1745: { href => '/adm/preferences?action=changecourseinit',
1746: text => 'Change Course Init. Pref.'});
1747: $r->print(Apache::loncommon::start_page('Change Course Initialization Preference'));
1748: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Course Init. Pref.'));
1.63 raeburn 1749: my $user = $env{'user.name'};
1750: my $domain = $env{'user.domain'};
1.66 albertel 1751: my %userenv = &Apache::lonnet::get('environment',['course_init_display']);
1.71 raeburn 1752: my $currvalue = 'whatsnew';
1.73 albertel 1753: my $firstselect = '';
1754: my $whatsnewselect = 'checked="checked"';
1.71 raeburn 1755: if (exists($userenv{'course_init_display'})) {
1756: if ($userenv{'course_init_display'} eq 'firstres') {
1757: $currvalue = 'firstres';
1.73 albertel 1758: $firstselect = 'checked="checked"';
1759: $whatsnewselect = '';
1.71 raeburn 1760: }
1.63 raeburn 1761: }
1.134 bisitz 1762: my %pagenames = &Apache::lonlocal::texthash(
1.71 raeburn 1763: firstres => 'First resource',
1.143 hauer 1764: whatsnew => "What's New Page",
1.71 raeburn 1765: );
1.134 bisitz 1766: my $whatsnew_off=&mt('Display the [_1]first resource[_2] in the course.','<b>','</b>');
1.143 hauer 1767: my $whatsnew_on=&mt("Display the [_1]What's New Page[_2] - a summary of items in the course which require attention.",'<b>','</b>');
1.63 raeburn 1768:
1.134 bisitz 1769: $r->print('<br /><b>'
1770: .&mt('Set the default page to be displayed when you select a course role')
1771: .'</b> '
1772: .&mt('(Currently: [_1])',$pagenames{$currvalue})
1773: .'<br />'
1.143 hauer 1774: .&mt("The global user preference you set for your courses can be overridden in an individual course by setting a course specific setting via the [_1]What's New Page[_2] in the course.",'<i>','</i>')
1.134 bisitz 1775: .'<br /><br />'
1776: );
1.63 raeburn 1777: $r->print(<<ENDLSCREEN);
1.88 albertel 1778: <form name="prefs" action="/adm/preferences" method="post">
1.63 raeburn 1779: <input type="hidden" name="action" value="verify_and_change_coursepage" />
1.72 albertel 1780: <br />
1.65 albertel 1781: <label><input type="radio" name="newdisp" value="firstres" $firstselect /> $whatsnew_off</label><br />
1.70 raeburn 1782: <label><input type="radio" name="newdisp" value="whatsnew" $whatsnewselect /> $whatsnew_on</label><input type="hidden" name="refpage" value="$env{'form.refpage'}" />
1.63 raeburn 1783: ENDLSCREEN
1.140 schafran 1784: $r->print('<br /><br /><input type="submit" value="'.&mt('Save').'" />
1.63 raeburn 1785: </form>');
1786: }
1787:
1788: sub verify_and_change_coursepage {
1789: my $r = shift;
1790: my $message='';
1791: my %lt = &Apache::lonlocal::texthash(
1.70 raeburn 1792: 'defs' => 'Default now set',
1.71 raeburn 1793: 'when' => 'when you select a course role from the roles screen',
1.63 raeburn 1794: 'ywbt' => 'you will be taken to the start of the course.',
1795: 'apwb' => 'a page will be displayed that lists items in the course that may require action from you.',
1796: 'gtts' => 'Go to the start of the course',
1.146 hauer 1797: 'dasp' => "Display the What's New Page",
1.63 raeburn 1798: );
1799: my $newdisp = $env{'form.newdisp'};
1.70 raeburn 1800: $message = '<b>'.$lt{'defs'}.'</b>: '.$lt{'when'}.', ';
1.63 raeburn 1801: if ($newdisp eq 'firstres') {
1.87 albertel 1802: $message .= $lt{'ywbt'}.'<br />';
1.63 raeburn 1803: &Apache::lonnet::put('environment',{'course_init_display' => $newdisp});
1.116 raeburn 1804: &Apache::lonnet::appenv({'environment.course_init_display' => $newdisp});
1.63 raeburn 1805: } else {
1.87 albertel 1806: $message .= $lt{'apwb'}.'<br />';
1.63 raeburn 1807: &Apache::lonnet::del('environment',['course_init_display']);
1.139 raeburn 1808: &Apache::lonnet::delenv('environment.course_init_display');
1.63 raeburn 1809: }
1.70 raeburn 1810: my $refpage = $env{'form.refpage'};
1.63 raeburn 1811: if (($env{'request.course.fn'}) && ($env{'request.course.id'})) {
1812: if ($newdisp eq 'firstres') {
1813: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1814: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1815: my ($furl,$ferr)=
1816: &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
1817: $message .= '<br /><font size="+1"><a href="'.$furl.'">'.$lt{'gtts'}.' <i>'.&mt('now').'</i></a></font>';
1818: } else {
1.70 raeburn 1819: $message .= '<br /><font size="+1"><a href="/adm/whatsnew?refpage='.
1820: $refpage.'">'.$lt{'dasp'}.'</a></font>';
1.63 raeburn 1821: }
1822: }
1.152 www 1823: &print_main_menu($r, &Apache::lonhtmlcommon::confirm_success($message));
1.63 raeburn 1824: }
1825:
1.126 droeschl 1826: sub print_main_menu {
1827: my ($r, $message) = @_;
1828: # Determine current authentication method
1829: my $user = $env{'user.name'};
1830: my $domain = $env{'user.domain'};
1831: my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
1832:
1833: # build the data structure for menu generation
1834: my $aboutmeurl='/adm/'.$env{'user.domain'}.'/'.$env{'user.name'}.'/aboutme';
1835: my $role = ($env{'user.adv'} ? 'Roles' : 'Course');
1.131 raeburn 1836: my %permissions;
1837: if (&Apache::lonnet::usertools_access($user,$domain,'aboutme')) {
1838: $permissions{'aboutme'} = 'F';
1839: }
1.126 droeschl 1840: my @menu=
1841: ({ categorytitle=>'Personal Data',
1842: items =>[
1.141 weissno 1843: { linktext => 'Personal Information Page',
1.126 droeschl 1844: url => $aboutmeurl,
1.131 raeburn 1845: permission => $permissions{'aboutme'},
1.126 droeschl 1846: #help => 'Prefs_About_Me',
1847: icon => 'system-users.png',
1848: linktitle => 'Edit information about yourself that should be displayed on your public profile.'
1849: },
1850: { linktext => 'Screen Name',
1851: url => '/adm/preferences?action=changescreenname',
1852: permission => 'F',
1853: #help => 'Prefs_Screen_Name_Nickname',
1854: icon => 'preferences-desktop-font.png',
1855: linktitle => 'Change the name that is displayed in your posts.'
1856: },
1857: ]
1858: },
1859: { categorytitle=>'Page Display Settings',
1860: items =>[
1861: { linktext => 'Color Scheme',
1862: url => '/adm/preferences?action=changecolors',
1863: permission => 'F',
1864: #help => 'Change_Colors',
1865: icon => 'preferences-desktop-theme.png',
1866: linktitle => 'Change LON-CAPA default colors.'
1867: },
1868: { linktext => 'Menu Display',
1869: url => '/adm/preferences?action=changeicons',
1870: permission => 'F',
1871: #help => '',
1872: icon => 'preferences-system-windows.png',
1873: linktitle => 'Change whether the menus are displayed with buttons, icons or icons and text.'
1874: }
1875:
1876: ]
1877: },
1878: { categorytitle=>'Content Display Settings',
1879: items =>[
1880: { linktext => 'Language',
1881: url => '/adm/preferences?action=changelanguages',
1882: permission => 'F',
1883: #help => 'Prefs_Language',
1884: icon => 'preferences-desktop-locale.png',
1.127 droeschl 1885: linktitle => 'Choose the default language for this user.'
1.126 droeschl 1886: },
1.128 droeschl 1887: { linktext => 'WYSIWYG Editor',
1.126 droeschl 1888: url => '/adm/preferences?action=changewysiwyg',
1889: permission => 'F',
1890: #help => '',
1891: icon => 'edit-select-all.png',
1892: linktitle => 'Enable or disable the WYSIWYG-Editor.'
1893: },
1.128 droeschl 1894: { linktext => $role.' Page',
1.126 droeschl 1895: url => '/adm/preferences?action=changerolespref',
1896: permission => 'F',
1897: #help => '',
1898: icon => 'sctr.png',
1899: linktitle => 'Configure the roles hotlist.'
1900: },
1.177 raeburn 1901: { linktext => 'Math display settings',
1.126 droeschl 1902: url => '/adm/preferences?action=changetexenginepref',
1903: permission => 'F',
1904: #help => '',
1905: icon => 'stat.png',
1.177 raeburn 1906: linktitle => 'Change how math is displayed.'
1.126 droeschl 1907: },
1908: ]
1909: },
1.178 ! bisitz 1910: { categorytitle=>'Messages & Notifications',
1.128 droeschl 1911: items =>[
1.153 www 1912: { linktext => 'Messages & Notifications',
1.128 droeschl 1913: url => '/adm/preferences?action=changemsgforward',
1914: permission => 'F',
1915: #help => 'Prefs_Messages',
1916: icon => 'mail-reply-all.png',
1917: linktitle => 'Change messageforwarding or notifications settings.'
1918: },
1919: { linktext => 'Discussion Display',
1920: url => '/adm/preferences?action=changediscussions',
1921: permission => 'F',
1922: #help => 'Change_Discussion_Display',
1923: icon => 'mail-message-new.png',
1.135 schafran 1924: linktitle => 'Set display preferences for discussion posts for both discussion boards and individual resources in all your courses.'
1.128 droeschl 1925: },
1926: ]
1927: },
1.126 droeschl 1928: { categorytitle=>'Other',
1929: items =>[
1.153 www 1930: { linktext => 'Register Response Devices ("Clickers")',
1.126 droeschl 1931: url => '/adm/preferences?action=changeclicker',
1932: permission => 'F',
1933: #help => '',
1934: icon => 'network-workgroup.png',
1935: linktitle => 'Register your clicker.'
1936: },
1937: ]
1938: },
1939: );
1940:
1941: if ($currentauth =~ /^(unix|internal):/) {
1942: push(@{ $menu[0]->{items} }, {
1943: linktext => 'Password',
1944: url => '/adm/preferences?action=changepass',
1945: permission => 'F',
1946: #help => 'Change_Password',
1947: icon => 'emblem-readonly.png',
1948: linktitle => 'Change your password.',
1949: });
1950: }
1951: if ($env{'environment.remote'} eq 'off') {
1952: push(@{ $menu[1]->{items} }, {
1953: linktext => 'Launch Remote Control',
1.167 droeschl 1954: url => '/adm/remote?url=/adm/preferences&action=launch',
1.126 droeschl 1955: permission => 'F',
1956: #help => '',
1.172 raeburn 1957: icon => 'remotecontrol.png',
1.126 droeschl 1958: linktitle => 'Launch the remote control for LON-CAPA.',
1959: });
1960: }else{
1961: push(@{ $menu[1]->{items} }, {
1962: linktext => 'Collapse Remote Control',
1.167 droeschl 1963: url => '/adm/remote?url=/adm/preferences&action=collapse',
1.126 droeschl 1964: permission => 'F',
1965: #help => '',
1.172 raeburn 1966: icon => 'remotecontrol.png',
1.126 droeschl 1967: linktitle => 'Collapse the remote control for LON-CAPA.',
1968: });
1969: }
1970: my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au']);
1971: if (keys(%author_roles) > 0) {
1972: push(@{ $menu[4]->{items} }, {
1973: linktext => 'Restrict Domain Coordinator Access',
1974: url => '/adm/preferences?action=changedomcoord',
1975: permission => 'F',
1976: #help => '',
1977: icon => 'system-lock-screen.png',
1978: linktitle => 'Restrict domain coordinator access.',
1979: });
1980: }
1981:
1982: if (&Apache::lonnet::allowed('whn',$env{'request.course.id'})
1983: || &Apache::lonnet::allowed('whn',$env{'request.course.id'}.'/'
1984: .$env{'request.course.sec'})) {
1985: push(@{ $menu[4]->{items} }, {
1.128 droeschl 1986: linktext => 'Course Initialization',
1.126 droeschl 1987: url => '/adm/preferences?action=changecourseinit',
1988: permission => 'F',
1989: #help => '',
1990: icon => 'edit-copy.png',
1991: linktitle => 'Set the default page to be displayed when you select a course role.',
1992: });
1993:
1994: }
1.174 raeburn 1995: if (&can_toggle_debug()) {
1.126 droeschl 1996: push(@{ $menu[4]->{items} }, {
1.174 raeburn 1997: linktext => 'Toggle Debug Messages (Currently '.($env{'user.debug'} ? 'on)' : 'off)'),
1.126 droeschl 1998: url => '/adm/preferences?action=debugtoggle',
1999: permission => 'F',
2000: #help => '',
2001: icon => 'blog.png',
2002: linktitle => 'Toggle Debug Messages.',
2003: });
2004: }
2005:
1.147 schafran 2006: $r->print(&Apache::loncommon::start_page('My Space'));
1.126 droeschl 2007: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Preferences'));
2008: $r->print($message);
2009: $r->print(Apache::lonhtmlcommon::generate_menu(@menu));
2010: $r->print(Apache::loncommon::end_page());
2011: }
1.63 raeburn 2012:
1.4 matthew 2013: ######################################################
2014: # other handler subroutines #
2015: ######################################################
2016:
1.3 matthew 2017: ################################################################
2018: # Main handler #
2019: ################################################################
1.126 droeschl 2020: sub handler {
2021: my $r = shift;
2022: Apache::loncommon::content_type($r,'text/html');
2023: # Some pages contain DES keys and should not be cached.
2024: Apache::loncommon::no_cache($r);
2025: $r->send_http_header;
2026: return OK if $r->header_only;
2027: #
2028: Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
2029: ['action','wysiwyg','returnurl','refpage']);
2030: #
2031: Apache::lonhtmlcommon::clear_breadcrumbs();
2032: Apache::lonhtmlcommon::add_breadcrumb
2033: ({href => '/adm/preferences',
1.150 droeschl 2034: text => 'Set User Preferences',
2035: help =>
2036: 'Prefs_About_Me,Prefs_Language,Prefs_Screen_Name_Nickname,Change_Colors,Change_Password,Prefs_Messages,Change_Discussion_Display'});
1.126 droeschl 2037: if(!exists $env{'form.action'}) {
1.150 droeschl 2038: &print_main_menu($r);
1.126 droeschl 2039: }elsif($env{'form.action'} eq 'changepass'){
2040: &passwordchanger($r);
2041: }elsif($env{'form.action'} eq 'verify_and_change_pass'){
2042: &verify_and_change_password($r);
2043: }elsif($env{'form.action'} eq 'changescreenname'){
2044: &screennamechanger($r);
2045: }elsif($env{'form.action'} eq 'verify_and_change_screenname'){
2046: &verify_and_change_screenname($r);
2047: }elsif($env{'form.action'} eq 'changemsgforward'){
2048: &msgforwardchanger($r);
2049: }elsif($env{'form.action'} eq 'verify_and_change_msgforward'){
2050: &verify_and_change_msgforward($r);
2051: }elsif($env{'form.action'} eq 'changecolors'){
2052: &colorschanger($r);
2053: }elsif($env{'form.action'} eq 'verify_and_change_colors'){
2054: &verify_and_change_colors($r);
2055: }elsif($env{'form.action'} eq 'changelanguages'){
2056: &languagechanger($r);
2057: }elsif($env{'form.action'} eq 'verify_and_change_languages'){
2058: &verify_and_change_languages($r);
2059: }elsif($env{'form.action'} eq 'changewysiwyg'){
2060: &wysiwygchanger($r);
2061: }elsif($env{'form.action'} eq 'set_wysiwyg'){
2062: &verify_and_change_wysiwyg($r);
2063: }elsif($env{'form.action'} eq 'changediscussions'){
2064: &discussionchanger($r);
2065: }elsif($env{'form.action'} eq 'verify_and_change_discussion'){
2066: &verify_and_change_discussion($r);
2067: }elsif($env{'form.action'} eq 'changerolespref'){
2068: &rolesprefchanger($r);
2069: }elsif($env{'form.action'} eq 'verify_and_change_rolespref'){
2070: &verify_and_change_rolespref($r);
2071: }elsif($env{'form.action'} eq 'changetexenginepref'){
2072: &texenginechanger($r);
2073: }elsif($env{'form.action'} eq 'verify_and_change_texengine'){
2074: &verify_and_change_texengine($r);
2075: }elsif($env{'form.action'} eq 'changeicons'){
2076: &iconchanger($r);
2077: }elsif($env{'form.action'} eq 'verify_and_change_icons'){
2078: &verify_and_change_icons($r);
2079: }elsif($env{'form.action'} eq 'changeclicker'){
2080: &clickerchanger($r);
2081: }elsif($env{'form.action'} eq 'verify_and_change_clicker'){
2082: &verify_and_change_clicker($r);
2083: }elsif($env{'form.action'} eq 'changedomcoord'){
2084: &domcoordchanger($r);
2085: }elsif($env{'form.action'} eq 'verify_and_change_domcoord'){
2086: &verify_and_change_domcoord($r);
2087: }elsif($env{'form.action'} eq 'lockwarning'){
2088: &lockwarning($r);
2089: }elsif($env{'form.action'} eq 'verify_and_change_locks'){
2090: &verify_and_change_lockwarning($r);
2091: }elsif($env{'form.action'} eq 'changecourseinit'){
2092: &coursedisplaychanger($r);
2093: }elsif($env{'form.action'} eq 'verify_and_change_coursepage'){
2094: &verify_and_change_coursepage($r);
2095: }elsif($env{'form.action'} eq 'debugtoggle'){
1.174 raeburn 2096: if (&can_toggle_debug()) {
2097: &toggle_debug();
2098: }
1.154 www 2099: &print_main_menu($r);
1.126 droeschl 2100: }
2101:
1.165 bisitz 2102: # Properly end the HTML page of all preference pages
2103: # started in each sub routine
2104: # Exception: print_main_menu has its own end_page call
2105: unless (!exists $env{'form.action'} ||
2106: $env{'form.action'} eq 'debugtoggle') {
2107: $r->print(&Apache::loncommon::end_page());
2108: }
2109:
1.126 droeschl 2110: return OK;
1.35 matthew 2111: }
2112:
2113: sub toggle_debug {
1.59 albertel 2114: if ($env{'user.debug'}) {
1.139 raeburn 2115: &Apache::lonnet::delenv('user.debug');
1.35 matthew 2116: } else {
1.116 raeburn 2117: &Apache::lonnet::appenv({'user.debug' => 1});
1.35 matthew 2118: }
1.13 www 2119: }
1.1 www 2120:
1.174 raeburn 2121: sub can_toggle_debug {
2122: my $can_toggle = 0;
2123: my $page = 'toggledebug';
2124: if (&LONCAPA::lonauthcgi::can_view($page)) {
2125: $can_toggle = 1;
2126: } elsif (&LONCAPA::lonauthcgi::check_ipbased_access($page)) {
2127: $can_toggle = 1;
2128: }
2129: return $can_toggle;
2130: }
2131:
1.1 www 2132: 1;
2133: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>