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