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