Annotation of loncom/interface/lonpreferences.pm, revision 1.220
1.1 www 1: # The LearningOnline Network
2: # Preferences
3: #
1.220 ! raeburn 4: # $Id: lonpreferences.pm,v 1.219 2016/02/17 19:15:48 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.164 bisitz 1431: $output .= &Apache::lonhtmlcommon::row_title(
1432: '<label for="email">'.$lt{'email'}.'</label>')
1433: .'<input type="text" name="email" size="30" />'
1434: .&Apache::lonhtmlcommon::row_closure()
1435: .&Apache::lonhtmlcommon::row_title(
1436: '<label for="uname">'.$lt{'username'}.'</label>')
1.219 raeburn 1437: .'<input type="text" name="uname" size="20" />'
1.164 bisitz 1438: .'<input type="hidden" name="currentpass" value="'.$currentpass.'" />'
1439: .&Apache::lonhtmlcommon::row_closure()
1440: .&Apache::lonhtmlcommon::row_title(
1441: '<label for="udom">'.$lt{'domain'}.'</label>')
1442: .&Apache::loncommon::select_dom_form($defdom,'udom')
1443: .&Apache::lonhtmlcommon::row_closure();
1.94 raeburn 1444: } else {
1.164 bisitz 1445: $output .= &Apache::lonhtmlcommon::row_title(
1446: '<label for="currentpass">'.$lt{'currentpass'}.'</label>')
1.219 raeburn 1447: .'<input type="password" name="currentpass" size="20"/>'
1.164 bisitz 1448: .&Apache::lonhtmlcommon::row_closure();
1449: }
1450: $output .= &Apache::lonhtmlcommon::row_title(
1451: '<label for="newpass_1">'.$lt{'newpass'}.'</label>')
1.219 raeburn 1452: .'<input type="password" name="newpass_1" size="20" />'
1.164 bisitz 1453: .&Apache::lonhtmlcommon::row_closure()
1454: .&Apache::lonhtmlcommon::row_title(
1455: '<label for="newpass_2">'.$lt{'confirmpass'}.'</label>')
1.219 raeburn 1456: .'<input type="password" name="newpass_2" size="20" />'
1.164 bisitz 1457: .&Apache::lonhtmlcommon::row_closure(1)
1458: .&Apache::lonhtmlcommon::end_pick_box();
1.206 bisitz 1459: $output .= '<p><input type="button" value="'.$lt{'changepass'}.'" onclick="send();" /></p>'
1.164 bisitz 1460: .qq|
1.94 raeburn 1461: <input type="hidden" name="ukey_cpass" value="$hexkey->{'ukey_cpass'}" />
1462: <input type="hidden" name="lkey_cpass" value="$hexkey->{'lkey_cpass'}" />
1463: <input type="hidden" name="ukey_npass1" value="$hexkey->{'ukey_npass1'}" />
1464: <input type="hidden" name="lkey_npass1" value="$hexkey->{'lkey_npass1'}" />
1465: <input type="hidden" name="ukey_npass2" value="$hexkey->{'ukey_npass2'}" />
1466: <input type="hidden" name="lkey_npass2" value="$hexkey->{'lkey_npass2'}" />
1.3 matthew 1467: </form>
1468: </p>
1.164 bisitz 1469: |;
1.94 raeburn 1470: return $output;
1471: }
1472:
1473: sub server_form {
1474: my ($logtoken,$caller,$mailtoken) = @_;
1475: my $action = '/adm/preferences';
1476: if ($caller eq 'reset_by_email') {
1477: $action = '/adm/resetpw';
1478: }
1479: my $output = qq|
1480: <form name="pserver" action="$action" method="post">
1481: <input type="hidden" name="logtoken" value="$logtoken" />
1482: <input type="hidden" name="currentpass" value="" />
1483: <input type="hidden" name="newpass_1" value="" />
1484: <input type="hidden" name="newpass_2" value="" />
1485: |;
1486: if ($caller eq 'reset_by_email') {
1487: $output .= qq|
1488: <input type="hidden" name="token" value="$mailtoken" />
1489: <input type="hidden" name="uname" value="" />
1490: <input type="hidden" name="udom" value="" />
1.173 raeburn 1491: <input type="hidden" name="email" value="" />
1.94 raeburn 1492:
1493: |;
1494: }
1495: $output .= qq|
1496: <input type="hidden" name="action" value="verify_and_change_pass" />
1497: </form>
1498: |;
1499: return $output;
1.3 matthew 1500: }
1501:
1502: sub verify_and_change_password {
1.94 raeburn 1503: my ($r,$caller,$mailtoken) = @_;
1504: my ($user,$domain,$homeserver);
1.217 raeburn 1505: my ($blocked,$blocktext) =
1506: &Apache::loncommon::blocking_status('passwd');
1507: if ($blocked) {
1508: $r->print('<p class="LC_warning">'.$blocktext.'</p>');
1509: return;
1510: }
1.94 raeburn 1511: if ($caller eq 'reset_by_email') {
1512: $user = $env{'form.uname'};
1513: $domain = $env{'form.udom'};
1514: if ($user ne '' && $domain ne '') {
1515: $homeserver = &Apache::lonnet::homeserver($user,$domain);
1516: if ($homeserver eq 'no_host') {
1.99 www 1517: &passwordchanger($r,"<p>\n<span class='LC_error'>".
1518: &mt("Invalid username and/or domain")."</span>\n</p>",
1.94 raeburn 1519: $caller,$mailtoken);
1520: return 1;
1521: }
1522: } else {
1.99 www 1523: &passwordchanger($r,"<p>\n<span class='LC_error'>".
1524: &mt("Username and domain were blank")."</span>\n</p>",
1.94 raeburn 1525: $caller,$mailtoken);
1526: return 1;
1527: }
1528: } else {
1529: $user = $env{'user.name'};
1530: $domain = $env{'user.domain'};
1531: $homeserver = $env{'user.home'};
1532: }
1.3 matthew 1533: my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
1.4 matthew 1534: # Check for authentication types that allow changing of the password.
1.94 raeburn 1535: if ($currentauth !~ /^(unix|internal):/) {
1536: if ($caller eq 'reset_by_email') {
1.99 www 1537: &passwordchanger($r,"<p>\n<span class='LC_error'>".
1538: &mt("Authentication type for this user can not be changed by this mechanism").
1539: "</span>\n</p>",
1.94 raeburn 1540: $caller,$mailtoken);
1541: return 1;
1542: } else {
1543: return;
1544: }
1545: }
1.3 matthew 1546: #
1.59 albertel 1547: my $currentpass = $env{'form.currentpass'};
1548: my $newpass1 = $env{'form.newpass_1'};
1549: my $newpass2 = $env{'form.newpass_2'};
1550: my $logtoken = $env{'form.logtoken'};
1.3 matthew 1551: # Check for empty data
1.4 matthew 1552: unless (defined($currentpass) &&
1553: defined($newpass1) &&
1554: defined($newpass2) ){
1.99 www 1555: &passwordchanger($r,"<p>\n<span class='LC_error'>".
1556: &mt("One or more password fields were blank").
1557: "</span>\n</p>",$caller,$mailtoken);
1.3 matthew 1558: return;
1559: }
1.16 albertel 1560: # Get the keys
1561: my $lonhost = $r->dir_config('lonHostID');
1.3 matthew 1562: my $tmpinfo = Apache::lonnet::reply('tmpget:'.$logtoken,$lonhost);
1563: if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) {
1.4 matthew 1564: # I do not a have a better idea about how to handle this
1.94 raeburn 1565: my $tryagain_text = &mt('Please log out and try again.');
1566: if ($caller eq 'reset_by_email') {
1567: $tryagain_text = &mt('Please try again later.');
1568: }
1.101 albertel 1569: my $unable=&mt("Unable to retrieve saved token for password decryption");
1.3 matthew 1570: $r->print(<<ENDERROR);
1571: <p>
1.99 www 1572: <span class="LC_error">$unable. $tryagain_text</span>
1.3 matthew 1573: </p>
1574: ENDERROR
1.4 matthew 1575: # Probably should log an error here
1.75 albertel 1576: return 1;
1.3 matthew 1577: }
1578: my ($ckey,$n1key,$n2key)=split(/&/,$tmpinfo);
1.219 raeburn 1579: #
1.211 raeburn 1580: $currentpass = &Apache::loncommon::des_decrypt($ckey ,$currentpass);
1581: $newpass1 = &Apache::loncommon::des_decrypt($n1key,$newpass1);
1582: $newpass2 = &Apache::loncommon::des_decrypt($n2key,$newpass2);
1.94 raeburn 1583: #
1584: if ($caller eq 'reset_by_email') {
1585: my %data = &Apache::lonnet::tmpget($mailtoken);
1.117 raeburn 1586: if (keys(%data) == 0) {
1587: &passwordchanger($r,
1588: '<span class="LC_error">'.
1589: &mt('Could not verify current authentication.').' '.
1590: &mt('Please try again.').'</span>',$caller,$mailtoken);
1591: return 1;
1592: }
1.94 raeburn 1593: if ($currentpass ne $data{'temppasswd'}) {
1594: &passwordchanger($r,
1.99 www 1595: '<span class="LC_error">'.
1.110 bisitz 1596: &mt('Could not verify current authentication.').' '.
1597: &mt('Please try again.').'</span>',$caller,$mailtoken);
1.94 raeburn 1598: return 1;
1599: }
1600: }
1.3 matthew 1601: if ($newpass1 ne $newpass2) {
1.4 matthew 1602: &passwordchanger($r,
1.199 bisitz 1603: '<span class="LC_warning">'.
1.110 bisitz 1604: &mt('The new passwords you entered do not match.').' '.
1605: &mt('Please try again.').'</span>',$caller,$mailtoken);
1.75 albertel 1606: return 1;
1.4 matthew 1607: }
1608: if (length($newpass1) < 7) {
1609: &passwordchanger($r,
1.199 bisitz 1610: '<span class="LC_warning">'.
1.110 bisitz 1611: &mt('Passwords must be a minimum of 7 characters long.').' '.
1612: &mt('Please try again.').'</span>',$caller,$mailtoken);
1.75 albertel 1613: return 1;
1.3 matthew 1614: }
1.4 matthew 1615: #
1616: # Check for bad characters
1617: my $badpassword = 0;
1618: foreach (split(//,$newpass1)) {
1619: $badpassword = 1 if ((ord($_)<32)||(ord($_)>126));
1620: }
1621: if ($badpassword) {
1622: # I can't figure out how to enter bad characters on my browser.
1.199 bisitz 1623: my $errormessage ='<span class="LC_warning">'.
1.110 bisitz 1624: &mt('The password you entered contained illegal characters.').'<br />'.
1.99 www 1625: &mt('Valid characters are').(<<"ENDERROR");
1626: : space and <br />
1.4 matthew 1627: <pre>
1628: !"\#$%&\'()*+,-./0123456789:;<=>?\@
1629: ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}~
1.99 www 1630: </pre></span>
1.4 matthew 1631: ENDERROR
1.94 raeburn 1632: &passwordchanger($r,$errormessage,$caller,$mailtoken);
1633: return 1;
1.4 matthew 1634: }
1635: #
1636: # Change the password (finally)
1637: my $result = &Apache::lonnet::changepass
1.94 raeburn 1638: ($user,$domain,$currentpass,$newpass1,$homeserver,$caller);
1.4 matthew 1639: # Inform the user the password has (not?) been changed
1.126 droeschl 1640: my $message;
1.4 matthew 1641: if ($result =~ /^ok$/) {
1.170 bisitz 1642: $message = &Apache::lonhtmlcommon::confirm_success(&mt('The password for user [_1] was successfully changed.','<i>'.$user.'</i>'));
1.180 wenzelju 1643: $message = &Apache::loncommon::confirmwrapper($message);
1.144 raeburn 1644: if ($caller eq 'reset_by_email') {
1645: $r->print($message.'<br />');
1646: } else {
1647: &print_main_menu($r, $message);
1648: }
1.4 matthew 1649: } else {
1650: # error error: run in circles, scream and shout
1.173 raeburn 1651: if ($caller eq 'reset_by_email') {
1652: if (!$result) {
1653: return 1;
1654: } else {
1655: return $result;
1656: }
1657: } else {
1658: $message = &Apache::lonhtmlcommon::confirm_success(
1659: &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 1660: $message=&Apache::loncommon::confirmwrapper($message);
1.144 raeburn 1661: &print_main_menu($r, $message);
1662: }
1.4 matthew 1663: }
1664: return;
1.3 matthew 1665: }
1666:
1.42 raeburn 1667: ################################################################
1668: # discussion display subroutines
1669: ################################################################
1670: sub discussionchanger {
1671: my $r = shift;
1.126 droeschl 1672: Apache::lonhtmlcommon::add_breadcrumb(
1673: { href => '/adm/preferences?action=changediscussions',
1674: text => 'Change Discussion Preferences'});
1.178 bisitz 1675: $r->print(Apache::loncommon::start_page('Change Discussion Preferences'));
1.126 droeschl 1676: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Discussion Preferences'));
1.59 albertel 1677: my $user = $env{'user.name'};
1678: my $domain = $env{'user.domain'};
1.42 raeburn 1679: my %userenv = &Apache::lonnet::get
1.43 raeburn 1680: ('environment',['discdisplay','discmarkread']);
1681: my $discdisp = 'allposts';
1682: my $discmark = 'onmark';
1683:
1684: if (defined($userenv{'discdisplay'})) {
1685: unless ($userenv{'discdisplay'} eq '') {
1686: $discdisp = $userenv{'discdisplay'};
1687: }
1688: }
1689: if (defined($userenv{'discmarkread'})) {
1.171 raeburn 1690: unless ($userenv{'discmarkread'} eq '') {
1.43 raeburn 1691: $discmark = $userenv{'discmarkread'};
1692: }
1693: }
1694:
1695: my $newdisp = 'unread';
1696: my $newmark = 'ondisp';
1697:
1698: my $function = &Apache::loncommon::get_users_function();
1699: my $color = &Apache::loncommon::designparm($function.'.tabbg',
1.59 albertel 1700: $env{'user.domain'});
1.43 raeburn 1701: my %lt = &Apache::lonlocal::texthash(
1702: 'pref' => 'Display Preference',
1703: 'curr' => 'Current setting ',
1704: 'actn' => 'Action',
1.135 schafran 1705: 'sdpf' => 'Set display preferences for discussion posts for both discussion boards and individual resources in all your courses.',
1.43 raeburn 1706: 'prca' => 'Preferences can be set that determine',
1.135 schafran 1707: 'whpo' => 'Which posts are displayed when you display a discussion board or resource, and',
1.194 raeburn 1708: 'unwh' => 'Under what circumstances posts are identified as "NEW"',
1.43 raeburn 1709: 'allposts' => 'All posts',
1710: 'unread' => 'New posts only',
1711: 'ondisp' => 'Once displayed',
1.194 raeburn 1712: 'onmark' => 'Once marked not NEW',
1.43 raeburn 1713: 'disa' => 'Posts displayed?',
1.194 raeburn 1714: 'npmr' => 'New posts cease to be identified as "NEW"?',
1.43 raeburn 1715: 'thde' => 'The preferences you set here can be overridden within each individual discussion.',
1716: 'chgt' => 'Change to '
1717: );
1718: my $dispchange = $lt{'unread'};
1719: my $markchange = $lt{'ondisp'};
1720: my $currdisp = $lt{'allposts'};
1721: my $currmark = $lt{'onmark'};
1722:
1723: if ($discdisp eq 'unread') {
1724: $dispchange = $lt{'allposts'};
1725: $currdisp = $lt{'unread'};
1726: $newdisp = 'allposts';
1727: }
1728:
1729: if ($discmark eq 'ondisp') {
1730: $markchange = $lt{'onmark'};
1731: $currmark = $lt{'ondisp'};
1732: $newmark = 'onmark';
1.42 raeburn 1733: }
1.171 raeburn 1734:
1.43 raeburn 1735: $r->print(<<"END");
1.88 albertel 1736: <form name="prefs" action="/adm/preferences" method="post">
1.42 raeburn 1737: <input type="hidden" name="action" value="verify_and_change_discussion" />
1738: <br />
1.87 albertel 1739: $lt{'sdpf'}<br /> $lt{'prca'} <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li></ol>
1.82 albertel 1740: END
1.158 bisitz 1741:
1742: $r->print('<p class="LC_info">'.$lt{'thde'}.'</p>');
1743:
1.82 albertel 1744: $r->print(&Apache::loncommon::start_data_table());
1745: $r->print(<<"END");
1746: <tr>
1747: <th>$lt{'pref'}</th>
1748: <th>$lt{'curr'}</th>
1749: <th>$lt{'actn'}?</th>
1.43 raeburn 1750: </tr>
1.82 albertel 1751: END
1752: $r->print(&Apache::loncommon::start_data_table_row());
1753: $r->print(<<"END");
1.43 raeburn 1754: <td>$lt{'disa'}</td>
1755: <td>$lt{$discdisp}</td>
1.82 albertel 1756: <td><label><input type="checkbox" name="discdisp" /><input type="hidden" name="newdisp" value="$newdisp" /> $lt{'chgt'} "$dispchange"</label></td>
1757: END
1758: $r->print(&Apache::loncommon::end_data_table_row().
1759: &Apache::loncommon::start_data_table_row());
1760: $r->print(<<"END");
1.43 raeburn 1761: <td>$lt{'npmr'}</td>
1762: <td>$lt{$discmark}</td>
1.82 albertel 1763: <td><label><input type="checkbox" name="discmark" /><input type="hidden" name="newmark" value="$newmark" /> $lt{'chgt'} "$markchange"</label></td>
1.43 raeburn 1764: </tr>
1.82 albertel 1765: END
1766: $r->print(&Apache::loncommon::end_data_table_row().
1767: &Apache::loncommon::end_data_table());
1.142 zhu 1768:
1.158 bisitz 1769: $r->print('<br />'
1770: .'<input type="submit" name="sub" value="'.&mt('Save').'" />'
1771: .'</form>'
1772: );
1.42 raeburn 1773: }
1774:
1775: sub verify_and_change_discussion {
1776: my $r = shift;
1.59 albertel 1777: my $user = $env{'user.name'};
1778: my $domain = $env{'user.domain'};
1.42 raeburn 1779: my $message='';
1.59 albertel 1780: if (defined($env{'form.discdisp'}) ) {
1781: my $newdisp = $env{'form.newdisp'};
1.43 raeburn 1782: if ($newdisp eq 'unread') {
1.171 raeburn 1783: $message .=&Apache::lonhtmlcommon::confirm_success(&mt('In discussions: only new posts will be displayed.')).'<br />';
1.43 raeburn 1784: &Apache::lonnet::put('environment',{'discdisplay' => $newdisp});
1.116 raeburn 1785: &Apache::lonnet::appenv({'environment.discdisplay' => $newdisp});
1.43 raeburn 1786: } else {
1.171 raeburn 1787: $message .= &Apache::lonhtmlcommon::confirm_success(&mt('In discussions: all posts will be displayed.')).'<br />';
1.43 raeburn 1788: &Apache::lonnet::del('environment',['discdisplay']);
1.139 raeburn 1789: &Apache::lonnet::delenv('environment.discdisplay');
1.43 raeburn 1790: }
1791: }
1.59 albertel 1792: if (defined($env{'form.discmark'}) ) {
1793: my $newmark = $env{'form.newmark'};
1.43 raeburn 1794: if ($newmark eq 'ondisp') {
1.209 bisitz 1795: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('In discussions: new posts will cease to be identified as "NEW" after display.')).'<br />';
1.43 raeburn 1796: &Apache::lonnet::put('environment',{'discmarkread' => $newmark});
1.116 raeburn 1797: &Apache::lonnet::appenv({'environment.discmarkread' => $newmark});
1.43 raeburn 1798: } else {
1.194 raeburn 1799: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('In discussions: posts will be identified as "NEW" until marked as not "NEW".')).'<br />';
1.43 raeburn 1800: &Apache::lonnet::del('environment',['discmarkread']);
1.139 raeburn 1801: &Apache::lonnet::delenv('environment.discmarkread');
1.43 raeburn 1802: }
1.42 raeburn 1803: }
1.158 bisitz 1804: $message=&Apache::loncommon::confirmwrapper($message);
1.152 www 1805: &print_main_menu($r, $message);
1.42 raeburn 1806: }
1807:
1.63 raeburn 1808: ################################################################
1809: # Subroutines for page display on course access (Course Coordinators)
1810: ################################################################
1811: sub coursedisplaychanger {
1812: my $r = shift;
1.152 www 1813: &Apache::lonhtmlcommon::add_breadcrumb(
1.126 droeschl 1814: { href => '/adm/preferences?action=changecourseinit',
1815: text => 'Change Course Init. Pref.'});
1816: $r->print(Apache::loncommon::start_page('Change Course Initialization Preference'));
1817: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Course Init. Pref.'));
1.63 raeburn 1818: my $user = $env{'user.name'};
1819: my $domain = $env{'user.domain'};
1.66 albertel 1820: my %userenv = &Apache::lonnet::get('environment',['course_init_display']);
1.71 raeburn 1821: my $currvalue = 'whatsnew';
1.73 albertel 1822: my $firstselect = '';
1823: my $whatsnewselect = 'checked="checked"';
1.71 raeburn 1824: if (exists($userenv{'course_init_display'})) {
1825: if ($userenv{'course_init_display'} eq 'firstres') {
1826: $currvalue = 'firstres';
1.73 albertel 1827: $firstselect = 'checked="checked"';
1828: $whatsnewselect = '';
1.71 raeburn 1829: }
1.63 raeburn 1830: }
1.134 bisitz 1831: my %pagenames = &Apache::lonlocal::texthash(
1.71 raeburn 1832: firstres => 'First resource',
1.143 hauer 1833: whatsnew => "What's New Page",
1.71 raeburn 1834: );
1.134 bisitz 1835: my $whatsnew_off=&mt('Display the [_1]first resource[_2] in the course.','<b>','</b>');
1.143 hauer 1836: 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 1837:
1.134 bisitz 1838: $r->print('<br /><b>'
1839: .&mt('Set the default page to be displayed when you select a course role')
1840: .'</b> '
1841: .&mt('(Currently: [_1])',$pagenames{$currvalue})
1842: .'<br />'
1.143 hauer 1843: .&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 1844: .'<br /><br />'
1845: );
1.63 raeburn 1846: $r->print(<<ENDLSCREEN);
1.88 albertel 1847: <form name="prefs" action="/adm/preferences" method="post">
1.63 raeburn 1848: <input type="hidden" name="action" value="verify_and_change_coursepage" />
1.72 albertel 1849: <br />
1.65 albertel 1850: <label><input type="radio" name="newdisp" value="firstres" $firstselect /> $whatsnew_off</label><br />
1.70 raeburn 1851: <label><input type="radio" name="newdisp" value="whatsnew" $whatsnewselect /> $whatsnew_on</label><input type="hidden" name="refpage" value="$env{'form.refpage'}" />
1.63 raeburn 1852: ENDLSCREEN
1.140 schafran 1853: $r->print('<br /><br /><input type="submit" value="'.&mt('Save').'" />
1.63 raeburn 1854: </form>');
1855: }
1856:
1857: sub verify_and_change_coursepage {
1858: my $r = shift;
1859: my $message='';
1860: my %lt = &Apache::lonlocal::texthash(
1.70 raeburn 1861: 'defs' => 'Default now set',
1.71 raeburn 1862: 'when' => 'when you select a course role from the roles screen',
1.63 raeburn 1863: 'ywbt' => 'you will be taken to the start of the course.',
1864: 'apwb' => 'a page will be displayed that lists items in the course that may require action from you.',
1865: 'gtts' => 'Go to the start of the course',
1.146 hauer 1866: 'dasp' => "Display the What's New Page",
1.63 raeburn 1867: );
1868: my $newdisp = $env{'form.newdisp'};
1.70 raeburn 1869: $message = '<b>'.$lt{'defs'}.'</b>: '.$lt{'when'}.', ';
1.63 raeburn 1870: if ($newdisp eq 'firstres') {
1.87 albertel 1871: $message .= $lt{'ywbt'}.'<br />';
1.63 raeburn 1872: &Apache::lonnet::put('environment',{'course_init_display' => $newdisp});
1.116 raeburn 1873: &Apache::lonnet::appenv({'environment.course_init_display' => $newdisp});
1.63 raeburn 1874: } else {
1.87 albertel 1875: $message .= $lt{'apwb'}.'<br />';
1.63 raeburn 1876: &Apache::lonnet::del('environment',['course_init_display']);
1.139 raeburn 1877: &Apache::lonnet::delenv('environment.course_init_display');
1.63 raeburn 1878: }
1.70 raeburn 1879: my $refpage = $env{'form.refpage'};
1.63 raeburn 1880: if (($env{'request.course.fn'}) && ($env{'request.course.id'})) {
1881: if ($newdisp eq 'firstres') {
1882: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1883: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1884: my ($furl,$ferr)=
1885: &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
1.180 wenzelju 1886: $message .= '<br /><a href="'.$furl.'">'.$lt{'gtts'}.' <i>'.&mt('now').'</i></a>';
1.63 raeburn 1887: } else {
1.180 wenzelju 1888: $message .= '<br /><a href="/adm/whatsnew?refpage='.
1889: $refpage.'">'.$lt{'dasp'}.'</a>';
1.63 raeburn 1890: }
1891: }
1.180 wenzelju 1892: $message = &Apache::lonhtmlcommon::confirm_success($message);
1893: $message = &Apache::loncommon::confirmwrapper($message);
1894: &print_main_menu($r,$message);
1.63 raeburn 1895: }
1896:
1.215 golterma 1897: sub author_space_settings {
1898: my $r = shift;
1899: &Apache::lonhtmlcommon::add_breadcrumb(
1900: { href => '/adm/preferences?action=authorsettings',
1901: text => 'Authoring Space Settings'});
1902: my $user = $env{'user.name'};
1903: my $domain = $env{'user.domain'};
1904: my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au','ca','aa']);
1905: if (keys(%author_roles) > 0) {
1906: $r->print(Apache::loncommon::start_page('Authoring Space Settings'));
1907: $r->print(Apache::lonhtmlcommon::breadcrumbs('Authoring Space Settings'));
1908: my %userenv = &Apache::lonnet::get('environment',['nocodemirror']);
1909: my $constchecked='';
1910: if ($env{'environment.nocodemirror'}) {
1911: $constchecked=' checked="checked"';
1912: }
1.216 droeschl 1913: my $text=&mt('By default, CodeMirror an editor with advanced functionality for editing code is activated for authors.');
1914: my $cmoff=&mt('Deactivate CodeMirror. This can improve performance on slow computers and accessibility.');
1.215 golterma 1915: my $change=&mt('Save');
1916: $r->print(<<ENDSCREEN);
1917: <form name="prefs" action="/adm/preferences" method="post">
1918: <input type="hidden" name="action" value="change_authoring_settings" />
1919: $text<br />
1920: <label><input type="checkbox" name="cmoff"$constchecked />$cmoff</label><br />
1921: <input type="submit" value="$change" />
1922: </form>
1923: ENDSCREEN
1924: }
1925: }
1926:
1927: sub change_authoring_settings {
1928: my $r = shift;
1929: my $user = $env{'user.name'};
1930: my $domain = $env{'user.domain'};
1931: my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au','ca','aa']);
1932: if (keys(%author_roles) > 0) {
1933: my %ausettings=('environment.nocodemirror' => '');
1934: if ($env{'form.cmoff'}) { $ausettings{'environment.nocodemirror'}='yes'; }
1935: &Apache::lonnet::put('environment',\%ausettings);
1936: &Apache::lonnet::appenv({'environment.nocodemirror' => $ausettings{'environment.nocodemirror'}});
1937: my $status='';
1938: if ($ausettings{'environment.nocodemirror'} eq 'yes') {
1939: $status=&mt('on');
1940: } else {
1941: $status=&mt('off');
1942: }
1.216 droeschl 1943: 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 1944: $message=&Apache::loncommon::confirmwrapper($message);
1945: &print_main_menu($r,$message);
1946: }
1947: }
1948:
1.186 raeburn 1949: sub lockednameschanger {
1950: my $r = shift;
1951: &Apache::lonhtmlcommon::add_breadcrumb(
1952: { href => '/adm/preferences?action=changelockednames',
1953: text => 'Automatic name changes'});
1954: $r->print(Apache::loncommon::start_page('Automatic name changes'));
1955: $r->print(Apache::lonhtmlcommon::breadcrumbs('Allow/disallow name updates'));
1956: my %userenv = &Apache::lonnet::get('environment',['lockedname']);
1957: my $lockedname='';
1958: if (&can_toggle_namelocking()) {
1959: if ($userenv{'lockedname'}) {
1960: $lockedname = ' checked="checked"';
1961: }
1962: my %updateable;
1963: my %domconfig =
1964: &Apache::lonnet::get_dom('configuration',['autoupdate'],$env{'user.domain'});
1965: if (ref($domconfig{'autoupdate'}) eq 'HASH') {
1966: if ($domconfig{'autoupdate'}{'run'}) {
1967: my @inststatuses = split(':',$env{'environment.inststatus'});
1968: unless (@inststatuses) {
1969: @inststatuses = ('default');
1970: }
1971: %updateable = &updateable_userinfo($domconfig{'autoupdate'},\@inststatuses);
1972: }
1973: }
1974: if (keys(%updateable)) {
1975: my %longnames = &Apache::lonlocal::texthash (
1976: firstname => 'First Name',
1977: middlename => 'Middle Name',
1978: lastname => 'Last Name',
1979: );
1980: 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:').
1981: '<ul>';
1982: foreach my $item ('firstname','middlename','lastname') {
1983: if ($updateable{$item}) {
1984: $text .= '<li>'.$longnames{$item}.'</li>';
1985: }
1986: }
1987: $text .= '</ul>';
1988: my $locking=&mt('Disallow automatic updates to name information for your LON-CAPA account');
1989: my $change=&mt('Save');
1990: $r->print(<<ENDSCREEN);
1991: <form name="prefs" action="/adm/preferences" method="post">
1992: <input type="hidden" name="action" value="verify_and_change_lockednames" />
1993: $text<br />
1994: <label><input type="checkbox" value="1" name="lockednames"$lockedname />$locking</label><br />
1995: <input type="submit" value="$change" />
1996: </form>
1997: ENDSCREEN
1998: } else {
1999: my $message = &mt('Based on your institutional affiliation no name information is automatically updated for your LON-CAPA account.');
2000: &print_main_menu($r,$message);
2001: }
2002: } else {
2003: my $message = &mt('You are not permitted to set a user preference for automatic name updates for your LON-CAPA account.');
2004: &print_main_menu($r,$message);
2005: }
2006: }
2007:
2008: sub verify_and_change_lockednames {
2009: my $r = shift;
2010: my $message;
2011: if (&can_toggle_namelocking()) {
2012: my $newlockedname = $env{'form.lockednames'};
2013: $newlockedname =~ s/\D//g;
2014: my $currlockedname = $env{'environment.lockedname'};
2015: if ($newlockedname ne $currlockedname) {
2016: if ($newlockedname) {
2017: if (&Apache::lonnet::put('environment',{lockedname => $newlockedname}) eq 'ok') {
2018: &Apache::lonnet::appenv({'environment.lockedname' => $newlockedname});
2019: }
2020: } elsif (&Apache::lonnet::del('environment',['lockedname']) eq 'ok') {
2021: &Apache::lonnet::delenv('environment.lockedname');
2022: }
2023: }
2024: my $status='';
2025: if ($newlockedname) {
2026: $status=&mt('disallowed');
2027: } else {
2028: $status=&mt('allowed');
2029: }
2030: $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>'));
2031: $message=&Apache::loncommon::confirmwrapper($message);
2032: }
2033: &print_main_menu($r,$message);
2034: }
2035:
1.126 droeschl 2036: sub print_main_menu {
2037: my ($r, $message) = @_;
2038: # Determine current authentication method
2039: my $user = $env{'user.name'};
2040: my $domain = $env{'user.domain'};
2041: my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
2042:
2043: # build the data structure for menu generation
2044: my $aboutmeurl='/adm/'.$env{'user.domain'}.'/'.$env{'user.name'}.'/aboutme';
2045: my $role = ($env{'user.adv'} ? 'Roles' : 'Course');
1.131 raeburn 2046: my %permissions;
2047: if (&Apache::lonnet::usertools_access($user,$domain,'aboutme')) {
2048: $permissions{'aboutme'} = 'F';
2049: }
1.126 droeschl 2050: my @menu=
2051: ({ categorytitle=>'Personal Data',
2052: items =>[
1.141 weissno 2053: { linktext => 'Personal Information Page',
1.126 droeschl 2054: url => $aboutmeurl,
1.131 raeburn 2055: permission => $permissions{'aboutme'},
1.126 droeschl 2056: #help => 'Prefs_About_Me',
2057: icon => 'system-users.png',
2058: linktitle => 'Edit information about yourself that should be displayed on your public profile.'
2059: },
2060: { linktext => 'Screen Name',
2061: url => '/adm/preferences?action=changescreenname',
2062: permission => 'F',
2063: #help => 'Prefs_Screen_Name_Nickname',
2064: icon => 'preferences-desktop-font.png',
2065: linktitle => 'Change the name that is displayed in your posts.'
2066: },
2067: ]
2068: },
2069: { categorytitle=>'Content Display Settings',
2070: items =>[
2071: { linktext => 'Language',
2072: url => '/adm/preferences?action=changelanguages',
2073: permission => 'F',
2074: #help => 'Prefs_Language',
2075: icon => 'preferences-desktop-locale.png',
1.127 droeschl 2076: linktitle => 'Choose the default language for this user.'
1.126 droeschl 2077: },
1.128 droeschl 2078: { linktext => $role.' Page',
1.126 droeschl 2079: url => '/adm/preferences?action=changerolespref',
2080: permission => 'F',
2081: #help => '',
1.189 wenzelju 2082: icon => 'role_hotlist.png',
1.126 droeschl 2083: linktitle => 'Configure the roles hotlist.'
2084: },
1.177 raeburn 2085: { linktext => 'Math display settings',
1.126 droeschl 2086: url => '/adm/preferences?action=changetexenginepref',
2087: permission => 'F',
2088: #help => '',
1.188 wenzelju 2089: icon => 'dismath.png',
1.177 raeburn 2090: linktitle => 'Change how math is displayed.'
1.126 droeschl 2091: },
2092: ]
2093: },
1.185 droeschl 2094: { categorytitle=>'Page Display Settings',
2095: items =>[
2096: { linktext => 'Color Scheme',
2097: url => '/adm/preferences?action=changecolors',
2098: permission => 'F',
2099: #help => 'Change_Colors',
2100: icon => 'preferences-desktop-theme.png',
2101: linktitle => 'Change LON-CAPA default colors.'
2102: },
1.192 raeburn 2103: { linktext => 'Menu Display',
2104: url => '/adm/preferences?action=changeicons',
2105: permission => 'F',
2106: #help => '',
2107: icon => 'preferences-system-windows.png',
2108: linktitle => 'Change whether the menus are displayed with icons or icons and text.'
2109: }
1.185 droeschl 2110: ]
2111: },
1.178 bisitz 2112: { categorytitle=>'Messages & Notifications',
1.128 droeschl 2113: items =>[
1.153 www 2114: { linktext => 'Messages & Notifications',
1.128 droeschl 2115: url => '/adm/preferences?action=changemsgforward',
2116: permission => 'F',
2117: #help => 'Prefs_Messages',
2118: icon => 'mail-reply-all.png',
2119: linktitle => 'Change messageforwarding or notifications settings.'
2120: },
2121: { linktext => 'Discussion Display',
2122: url => '/adm/preferences?action=changediscussions',
2123: permission => 'F',
2124: #help => 'Change_Discussion_Display',
1.191 riegler 2125: icon => 'chat.png',
1.135 schafran 2126: linktitle => 'Set display preferences for discussion posts for both discussion boards and individual resources in all your courses.'
1.128 droeschl 2127: },
2128: ]
2129: },
1.126 droeschl 2130: { categorytitle=>'Other',
2131: items =>[
1.153 www 2132: { linktext => 'Register Response Devices ("Clickers")',
1.126 droeschl 2133: url => '/adm/preferences?action=changeclicker',
2134: permission => 'F',
2135: #help => '',
2136: icon => 'network-workgroup.png',
2137: linktitle => 'Register your clicker.'
2138: },
2139: ]
2140: },
2141: );
2142:
2143: if ($currentauth =~ /^(unix|internal):/) {
2144: push(@{ $menu[0]->{items} }, {
2145: linktext => 'Password',
2146: url => '/adm/preferences?action=changepass',
2147: permission => 'F',
2148: #help => 'Change_Password',
2149: icon => 'emblem-readonly.png',
2150: linktitle => 'Change your password.',
2151: });
2152: }
1.186 raeburn 2153:
2154: if (&can_toggle_namelocking()) {
2155: push(@{ $menu[0]->{items} }, {
2156: linktext => 'Automatic name changes',
2157: url => '/adm/preferences?action=changelockednames',
2158: permission => 'F',
2159: #help => '',
2160: icon => 'system-lock-screen.png',
2161: linktitle => 'Allow/disallow propagation of name changes from institutional directory service',
2162: });
2163: }
2164:
1.126 droeschl 2165: my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au']);
2166: if (keys(%author_roles) > 0) {
2167: push(@{ $menu[4]->{items} }, {
2168: linktext => 'Restrict Domain Coordinator Access',
2169: url => '/adm/preferences?action=changedomcoord',
2170: permission => 'F',
2171: #help => '',
2172: icon => 'system-lock-screen.png',
2173: linktitle => 'Restrict domain coordinator access.',
2174: });
2175: }
2176:
2177: if (&Apache::lonnet::allowed('whn',$env{'request.course.id'})
2178: || &Apache::lonnet::allowed('whn',$env{'request.course.id'}.'/'
2179: .$env{'request.course.sec'})) {
2180: push(@{ $menu[4]->{items} }, {
1.128 droeschl 2181: linktext => 'Course Initialization',
1.126 droeschl 2182: url => '/adm/preferences?action=changecourseinit',
2183: permission => 'F',
2184: #help => '',
1.189 wenzelju 2185: icon => 'course_ini.png',
1.126 droeschl 2186: linktitle => 'Set the default page to be displayed when you select a course role.',
2187: });
2188:
2189: }
1.215 golterma 2190:
2191: my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au','ca','aa']);
2192: if (keys(%author_roles) > 0) {
2193: push(@{ $menu[4]->{items} }, {
2194: linktext => 'Authoring Space Configuration',
2195: url => '/adm/preferences?action=authorsettings',
2196: permission => 'F',
2197: icon => 'course_ini.png',
2198: linktitle => 'Settings for your authoring space.',
2199: });
2200: }
2201:
1.174 raeburn 2202: if (&can_toggle_debug()) {
1.126 droeschl 2203: push(@{ $menu[4]->{items} }, {
1.174 raeburn 2204: linktext => 'Toggle Debug Messages (Currently '.($env{'user.debug'} ? 'on)' : 'off)'),
1.126 droeschl 2205: url => '/adm/preferences?action=debugtoggle',
2206: permission => 'F',
2207: #help => '',
2208: icon => 'blog.png',
2209: linktitle => 'Toggle Debug Messages.',
2210: });
1.186 raeburn 2211: }
1.126 droeschl 2212:
1.147 schafran 2213: $r->print(&Apache::loncommon::start_page('My Space'));
1.126 droeschl 2214: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Preferences'));
2215: $r->print($message);
2216: $r->print(Apache::lonhtmlcommon::generate_menu(@menu));
2217: $r->print(Apache::loncommon::end_page());
2218: }
1.63 raeburn 2219:
1.4 matthew 2220: ######################################################
2221: # other handler subroutines #
2222: ######################################################
2223:
1.3 matthew 2224: ################################################################
2225: # Main handler #
2226: ################################################################
1.126 droeschl 2227: sub handler {
2228: my $r = shift;
2229: Apache::loncommon::content_type($r,'text/html');
2230: # Some pages contain DES keys and should not be cached.
2231: Apache::loncommon::no_cache($r);
2232: $r->send_http_header;
2233: return OK if $r->header_only;
2234: #
2235: Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
2236: ['action','wysiwyg','returnurl','refpage']);
2237: #
2238: Apache::lonhtmlcommon::clear_breadcrumbs();
1.198 raeburn 2239: my ($brlink,$brtxt,$brhelp);
2240: if (($env{'form.action'} eq 'changerolespref') && ($env{'form.returnurl'} eq '/adm/roles')) {
2241: $brlink ='/adm/roles';
2242: $brtxt = 'User Roles';
2243: } else {
2244: $brlink ='/adm/preferences';
2245: $brtxt = 'Set User Preferences';
2246: $brhelp = 'Prefs_About_Me,Prefs_Language,Prefs_Screen_Name_Nickname,Change_Colors,Change_Password,Prefs_Messages,Change_Discussion_Display';
2247: }
1.126 droeschl 2248: Apache::lonhtmlcommon::add_breadcrumb
1.198 raeburn 2249: ({href => $brlink,
2250: text => $brtxt,
2251: help => $brhelp,});
1.126 droeschl 2252: if(!exists $env{'form.action'}) {
1.150 droeschl 2253: &print_main_menu($r);
1.126 droeschl 2254: }elsif($env{'form.action'} eq 'changepass'){
2255: &passwordchanger($r);
2256: }elsif($env{'form.action'} eq 'verify_and_change_pass'){
1.219 raeburn 2257: &verify_and_change_password($r,'preferences');
1.126 droeschl 2258: }elsif($env{'form.action'} eq 'changescreenname'){
2259: &screennamechanger($r);
2260: }elsif($env{'form.action'} eq 'verify_and_change_screenname'){
2261: &verify_and_change_screenname($r);
2262: }elsif($env{'form.action'} eq 'changemsgforward'){
2263: &msgforwardchanger($r);
2264: }elsif($env{'form.action'} eq 'verify_and_change_msgforward'){
2265: &verify_and_change_msgforward($r);
2266: }elsif($env{'form.action'} eq 'changecolors'){
2267: &colorschanger($r);
2268: }elsif($env{'form.action'} eq 'verify_and_change_colors'){
2269: &verify_and_change_colors($r);
2270: }elsif($env{'form.action'} eq 'changelanguages'){
2271: &languagechanger($r);
2272: }elsif($env{'form.action'} eq 'verify_and_change_languages'){
2273: &verify_and_change_languages($r);
2274: }elsif($env{'form.action'} eq 'changewysiwyg'){
2275: &wysiwygchanger($r);
2276: }elsif($env{'form.action'} eq 'set_wysiwyg'){
2277: &verify_and_change_wysiwyg($r);
2278: }elsif($env{'form.action'} eq 'changediscussions'){
2279: &discussionchanger($r);
2280: }elsif($env{'form.action'} eq 'verify_and_change_discussion'){
2281: &verify_and_change_discussion($r);
2282: }elsif($env{'form.action'} eq 'changerolespref'){
2283: &rolesprefchanger($r);
2284: }elsif($env{'form.action'} eq 'verify_and_change_rolespref'){
2285: &verify_and_change_rolespref($r);
2286: }elsif($env{'form.action'} eq 'changetexenginepref'){
2287: &texenginechanger($r);
2288: }elsif($env{'form.action'} eq 'verify_and_change_texengine'){
2289: &verify_and_change_texengine($r);
1.192 raeburn 2290: }elsif($env{'form.action'} eq 'changeicons'){
2291: &iconchanger($r);
2292: }elsif($env{'form.action'} eq 'verify_and_change_icons'){
2293: &verify_and_change_icons($r);
1.126 droeschl 2294: }elsif($env{'form.action'} eq 'changeclicker'){
2295: &clickerchanger($r);
2296: }elsif($env{'form.action'} eq 'verify_and_change_clicker'){
2297: &verify_and_change_clicker($r);
2298: }elsif($env{'form.action'} eq 'changedomcoord'){
2299: &domcoordchanger($r);
2300: }elsif($env{'form.action'} eq 'verify_and_change_domcoord'){
2301: &verify_and_change_domcoord($r);
2302: }elsif($env{'form.action'} eq 'lockwarning'){
2303: &lockwarning($r);
2304: }elsif($env{'form.action'} eq 'verify_and_change_locks'){
2305: &verify_and_change_lockwarning($r);
2306: }elsif($env{'form.action'} eq 'changecourseinit'){
2307: &coursedisplaychanger($r);
2308: }elsif($env{'form.action'} eq 'verify_and_change_coursepage'){
2309: &verify_and_change_coursepage($r);
1.215 golterma 2310: }elsif($env{'form.action'} eq 'authorsettings'){
2311: &author_space_settings($r);
2312: }elsif($env{'form.action'} eq 'change_authoring_settings'){
2313: &change_authoring_settings($r);
1.126 droeschl 2314: }elsif($env{'form.action'} eq 'debugtoggle'){
1.174 raeburn 2315: if (&can_toggle_debug()) {
2316: &toggle_debug();
2317: }
1.154 www 2318: &print_main_menu($r);
1.186 raeburn 2319: } elsif ($env{'form.action'} eq 'changelockednames') {
2320: &lockednameschanger($r);
2321: } elsif ($env{'form.action'} eq 'verify_and_change_lockednames') {
2322: &verify_and_change_lockednames($r);
1.126 droeschl 2323: }
2324:
1.165 bisitz 2325: # Properly end the HTML page of all preference pages
2326: # started in each sub routine
2327: # Exception: print_main_menu has its own end_page call
2328: unless (!exists $env{'form.action'} ||
2329: $env{'form.action'} eq 'debugtoggle') {
2330: $r->print(&Apache::loncommon::end_page());
2331: }
2332:
1.126 droeschl 2333: return OK;
1.35 matthew 2334: }
2335:
2336: sub toggle_debug {
1.59 albertel 2337: if ($env{'user.debug'}) {
1.139 raeburn 2338: &Apache::lonnet::delenv('user.debug');
1.35 matthew 2339: } else {
1.116 raeburn 2340: &Apache::lonnet::appenv({'user.debug' => 1});
1.35 matthew 2341: }
1.13 www 2342: }
1.1 www 2343:
1.174 raeburn 2344: sub can_toggle_debug {
2345: my $can_toggle = 0;
2346: my $page = 'toggledebug';
2347: if (&LONCAPA::lonauthcgi::can_view($page)) {
2348: $can_toggle = 1;
2349: } elsif (&LONCAPA::lonauthcgi::check_ipbased_access($page)) {
2350: $can_toggle = 1;
2351: }
2352: return $can_toggle;
2353: }
2354:
1.186 raeburn 2355: sub can_toggle_namelocking {
2356: my $lockablenames;
2357: my %domconfig =
2358: &Apache::lonnet::get_dom('configuration',['autoupdate'],$env{'user.domain'});
2359: if (ref($domconfig{'autoupdate'}) eq 'HASH') {
2360: if ($domconfig{'autoupdate'}{'run'}) {
2361: my @inststatuses = split(':',$env{'environment.inststatus'});
2362: unless (@inststatuses) {
2363: @inststatuses = ('default');
2364: }
2365: my %updateable = &updateable_userinfo($domconfig{'autoupdate'},\@inststatuses);
2366: if ($updateable{'lastname'} || $updateable{'firstname'} ||
2367: $updateable{'middlename'}) {
2368: if (ref($domconfig{'autoupdate'}{'lockablenames'}) eq 'ARRAY') {
2369: unless (@inststatuses) {
2370: @inststatuses = ('default');
2371: }
2372: foreach my $status (@inststatuses) {
2373: if (grep(/^\Q$status\E$/,@{$domconfig{'autoupdate'}{'lockablenames'}})) {
2374: $lockablenames = 1;
2375: last;
2376: }
2377: }
2378: }
2379: }
2380: }
2381: }
2382: return $lockablenames;
2383: }
2384:
2385: sub updateable_userinfo {
2386: my ($autoupdate,$inststatuses) = @_;
2387: my %updateable;
2388: return %updateable unless ((ref($autoupdate) eq 'HASH') &&
2389: (ref($inststatuses) eq 'ARRAY'));
2390: if (ref($autoupdate->{'fields'}) eq 'HASH') {
2391: foreach my $status (@{$inststatuses}) {
2392: if (ref($autoupdate->{'fields'}{$status}) eq 'ARRAY') {
2393: foreach my $field (@{$autoupdate->{'fields'}{$status}}) {
2394: $updateable{$field} = 1;
2395: }
2396: }
2397: }
2398: }
2399: return %updateable;
2400: }
2401:
1.1 www 2402: 1;
2403: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>