Annotation of loncom/interface/lonpreferences.pm, revision 1.196.4.22
1.1 www 1: # The LearningOnline Network
2: # Preferences
3: #
1.196.4.22! raeburn 4: # $Id: lonpreferences.pm,v 1.196.4.21 2016/09/16 22:00:55 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.196.4.10 raeburn 109: my %userenv = &Apache::lonnet::get('environment',['languages']);
1.29 www 110: my $language=$userenv{'languages'};
1.32 www 111:
1.196.4.10 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.196.4.18 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.196.4.3 raeburn 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.196.4.3 raeburn 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.196.4.3 raeburn 186: 'mathjax' => 'MathJax:',
1.196.4.15 raeburn 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.196.4.3 raeburn 206: <h3>$lt{'mathjax'}</h3>
207: </script>
1.196.4.15 raeburn 208: <iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=MathJax" width="400" height="150"></iframe>
1.196.4.3 raeburn 209: </p>
210: <p>
1.196.4.15 raeburn 211: $lt{'mathjaxinfo'}
1.196.4.3 raeburn 212: </p>
213:
1.123 bisitz 214: <h3>$lt{'mimetex'}</h3>
215: <p>
1.196.4.15 raeburn 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.196.4.15 raeburn 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.196.4.18 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.196.4.5 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.196.4.5 raeburn 278: text => $brtext});
1.147 schafran 279: $r->print(Apache::loncommon::start_page('Content Display Settings'));
1.196.4.5 raeburn 280: $r->print(Apache::lonhtmlcommon::breadcrumbs($brtitle));
1.50 albertel 281: my $hotlist_flag=$userenv{'recentroles'};
282: my $hotlist_n=$userenv{'recentrolesn'};
1.196.4.5 raeburn 283: my ($checkedon,$checkedoff);
1.50 albertel 284: if ($hotlist_flag) {
1.196.4.5 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.196.4.5 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.196.4.5 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.196.4.5 raeburn 346: <form name="prefs" action="'.$actionurl.'" method="post">
1.50 albertel 347: <input type="hidden" name="action" value="verify_and_change_rolespref" />
1.196.4.5 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.196.4.5 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.196.4.5 raeburn 363: $options.'
364: </select>'.
1.181 wenzelju 365: &Apache::lonhtmlcommon::row_closure(1).
1.196.4.5 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.196.4.8 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.196.4.5 raeburn 375: </div>');
376: } else {
377: $r->print('<br clear="all" />'.
1.196.4.13 raeburn 378: &mt('Once the Hotlist contains recently visited '.$lc_role.'s you can return to this page to also set frozen roles.'));
1.196.4.5 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.196.4.5 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.196.4.4 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.196.4.5 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'};
689: my $newclickers = $env{'form.clickers'};
1.108 www 690: $newclickers=~s/[^\w\:\-]+/\,/gs;
1.105 www 691: $newclickers=~tr/a-z/A-Z/;
1.108 www 692: $newclickers=~s/[\:\-]+/\-/g;
693: $newclickers=~s/\,+/\,/g;
1.105 www 694: $newclickers=~s/^\,//;
695: $newclickers=~s/\,$//;
696: &Apache::lonnet::put('environment',{'clickers' => $newclickers});
1.116 raeburn 697: &Apache::lonnet::appenv({'environment.clickers' => $newclickers});
1.158 bisitz 698: my $message=&Apache::lonhtmlcommon::confirm_success(&mt('Registering clickers: [_1]',$newclickers));
699: $message=&Apache::loncommon::confirmwrapper($message);
700: &print_main_menu($r, $message);
1.105 www 701: }
702:
1.119 www 703: ################################################################
704: # Domcoord Access Subroutines #
705: ################################################################
706:
707: sub domcoordchanger {
708: my $r = shift;
1.154 www 709: &Apache::lonhtmlcommon::add_breadcrumb(
1.126 droeschl 710: { href => '/adm/preferences?action=changedomcoord',
711: text => 'Restrict Domain Coordinator Access'});
712: $r->print(Apache::loncommon::start_page('Restrict Domain Coordinator Access'));
713: $r->print(Apache::lonhtmlcommon::breadcrumbs('Restrict Domain Coordinator Access'));
1.119 www 714: my $user = $env{'user.name'};
715: my $domain = $env{'user.domain'};
716: my %userenv = &Apache::lonnet::get
1.120 www 717: ('environment',['domcoord.author']);
1.119 www 718: my $constchecked='';
719: if ($userenv{'domcoord.author'} eq 'blocked') {
1.159 bisitz 720: $constchecked=' checked="checked"';
1.119 www 721: }
1.196.4.11 raeburn 722: my $text=&mt('By default, the Domain Coordinator can enter your Authoring Space.');
723: my $construction=&mt('Block access to Authoring Space');
1.136 schafran 724: my $change=&mt('Save');
1.119 www 725: $r->print(<<ENDSCREEN);
726: <form name="prefs" action="/adm/preferences" method="post">
727: <input type="hidden" name="action" value="verify_and_change_domcoord" />
728: $text<br />
1.159 bisitz 729: <label><input type="checkbox" name="construction"$constchecked />$construction</label><br />
1.119 www 730: <input type="submit" value="$change" />
731: </form>
732: ENDSCREEN
733: }
734:
735: sub verify_and_change_domcoord {
736: my $r = shift;
737: my $user = $env{'user.name'};
738: my $domain = $env{'user.domain'};
1.120 www 739: my %domcoord=('domcoord.author' => '');
1.119 www 740: if ($env{'form.construction'}) { $domcoord{'domcoord.author'}='blocked'; }
741: &Apache::lonnet::put('environment',\%domcoord);
1.120 www 742: &Apache::lonnet::appenv({'environment.domcoord.author' => $domcoord{'domcoord.author'}});
1.158 bisitz 743: my $status='';
744: if ($domcoord{'domcoord.author'} eq 'blocked') {
745: $status=&mt('on');
746: } else {
747: $status=&mt('off');
748: }
1.196.4.11 raeburn 749: 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 750: $message=&Apache::loncommon::confirmwrapper($message);
751: &print_main_menu($r,$message);
1.119 www 752: }
753:
1.118 www 754: #################################################################
755: ## Lock Subroutines #
756: #################################################################
757:
758: sub lockwarning {
759: my $r = shift;
760: my $title=&mt('Action locked');
761: my $texttop=&mt('LON-CAPA is currently performing the following actions:');
762: my $textbottom=&mt('Changing roles or logging out may result in data corruption.');
763: my ($num,%which)=&Apache::lonnet::get_locks();
764: my $which='';
1.196.4.16 raeburn 765: foreach my $id (keys(%which)) {
1.118 www 766: $which.='<li>'.$which{$id}.'</li>';
767: }
768: my $change=&mt('Override');
769: $r->print(<<ENDSCREEN);
770: <form name="prefs" action="/adm/preferences" method="post">
771: <input type="hidden" name="action" value="verify_and_change_locks" />
772: <h1>$title</h1>
773: $texttop
774: <ul>
775: $which
776: </ul>
777: $textbottom
778: <input type="submit" value="$change" />
779: </form>
780: ENDSCREEN
781: }
782:
783: sub verify_and_change_lockwarning {
784: my $r = shift;
785: &Apache::lonnet::remove_all_locks();
786: $r->print(&mt('Cleared locks.'));
787: }
788:
789:
1.105 www 790: ################################################################
1.20 www 791: # Message Forward #
792: ################################################################
793:
794: sub msgforwardchanger {
1.102 raeburn 795: my ($r,$message) = @_;
1.59 albertel 796: my $user = $env{'user.name'};
797: my $domain = $env{'user.domain'};
1.102 raeburn 798: my %userenv = &Apache::lonnet::get('environment',['msgforward','notification','critnotification','notifywithhtml']);
1.20 www 799: my $msgforward=$userenv{'msgforward'};
1.102 raeburn 800: my %lt = &Apache::lonlocal::texthash(
801: all => 'All',
802: crit => 'Critical only',
803: reg => 'Non-critical only',
1.175 raeburn 804: foad => 'Forward to account(s)',
805: fwdm => 'Forward messages to other account(s) in LON-CAPA',
806: noti => 'E-mail notification of LON-CAPA messages',
807: mnot => 'E-mail address(es) which should be notified about new LON-CAPA messages',
1.136 schafran 808: chg => 'Save',
1.104 raeburn 809: email => 'The e-mail address entered in row ',
1.102 raeburn 810: notv => 'is not a valid e-mail address',
1.103 raeburn 811: toen => "To enter multiple addresses, enter one address at a time, click 'Change' and then add the next one",
1.136 schafran 812: prme => 'Back',
1.102 raeburn 813: );
1.196.4.12 raeburn 814: $lt{'foad_exmpl'} = &mt('e.g. [_1]userA:domain1,userB:domain2,...[_2]','<tt>','</tt>');
815: $lt{'mnot_exmpl'} = &mt('e.g. [_1]joe@doe.com[_2]','<tt>','</tt>');
1.126 droeschl 816: Apache::lonhtmlcommon::add_breadcrumb(
817: { href => '/adm/preferences?action=changemsgforward',
1.176 raeburn 818: text => 'Messages & Notifications'});
1.178 bisitz 819: $r->print(Apache::loncommon::start_page('Messages & Notifications'));
820: $r->print(Apache::lonhtmlcommon::breadcrumbs('Messages & Notifications'));
1.113 raeburn 821: my $forwardingHelp = &Apache::loncommon::help_open_topic("Prefs_Forwarding");
822: my $notificationHelp = &Apache::loncommon::help_open_topic("Prefs_Notification");
823: my $criticalMessageHelp = &Apache::loncommon::help_open_topic("Course_Critical_Message");
1.102 raeburn 824: my @allow_html = split(/,/,$userenv{'notifywithhtml'});
825: my %allnot = &get_notifications(\%userenv);
826: my $validatescript = &Apache::lonhtmlcommon::javascript_valid_email();
827: my $jscript = qq|
1.148 bisitz 828: <script type="text/javascript" language="JavaScript">
1.102 raeburn 829: function validate() {
830: for (var i=0; i<document.prefs.numnotify.value; i++) {
1.104 raeburn 831: var checkaddress = 0;
1.102 raeburn 832: var addr = document.prefs.elements['address_'+i].value;
1.104 raeburn 833: var rownum = i+1;
1.102 raeburn 834: if (i < document.prefs.numnotify.value-1) {
1.104 raeburn 835: if (document.prefs.elements['modify_notify_'+i].checked) {
1.102 raeburn 836: checkaddress = 1;
1.104 raeburn 837: }
1.102 raeburn 838: } else {
839: if (document.prefs.elements['add_notify_'+i].checked == true) {
840: checkaddress = 1;
841: }
842: }
1.104 raeburn 843: if (checkaddress == 1) {
1.102 raeburn 844: var addr = document.prefs.elements['address_'+i].value;
845: if (validmail(document.prefs.elements['address_'+i]) == false) {
1.104 raeburn 846: var multimsg = '';
847: if (addr.indexOf(",") >= 0) {
848: multimsg = "\\n($lt{'toen'}).";
849: }
1.110 bisitz 850: alert("$lt{'email'} "+rownum+" ('"+addr+"') $lt{'notv'}."+multimsg);
1.102 raeburn 851: return;
852: }
853: }
854: }
855: document.prefs.submit();
856: }
1.104 raeburn 857:
858: function address_changes (adnum) {
859: if (!document.prefs.elements['del_notify_'+adnum].checked) {
860: document.prefs.elements['modify_notify_'+adnum].checked = true;
861: }
862: }
863:
864: function new_address(adnum) {
865: document.prefs.elements['add_notify_'+adnum].checked = true;
866: }
867:
868: function delete_address(adnum) {
869: if (document.prefs.elements['del_notify_'+adnum].checked) {
870: document.prefs.elements['modify_notify_'+adnum].checked = false;
871: }
872: }
873:
874: function modify_address(adnum) {
875: if (document.prefs.elements['modify_notify_'+adnum].checked) {
876: document.prefs.elements['del_notify_'+adnum].checked = false;
877: }
878: }
879:
1.102 raeburn 880: $validatescript
881: </script>
882: |;
1.20 www 883: $r->print(<<ENDMSG);
1.102 raeburn 884: $jscript
885: $message
1.175 raeburn 886: <h3>$lt{'fwdm'} $forwardingHelp</h3>
1.88 albertel 887: <form name="prefs" action="/adm/preferences" method="post">
1.20 www 888: <input type="hidden" name="action" value="verify_and_change_msgforward" />
1.110 bisitz 889: $lt{'foad'} ($lt{'foad_exmpl'}):
1.175 raeburn 890: <input type="text" size="40" value="$msgforward" name="msgforward" />
891: <br /><br />
1.113 raeburn 892: <h3>$lt{'noti'} $notificationHelp</h3>
1.110 bisitz 893: $lt{'mnot'} ($lt{'mnot_exmpl'}):<br />
1.102 raeburn 894: ENDMSG
895: my @sortforwards = sort (keys(%allnot));
896: my $output = &Apache::loncommon::start_data_table().
897: &Apache::loncommon::start_data_table_header_row().
1.104 raeburn 898: '<th> </th>'.
1.102 raeburn 899: '<th>'.&mt('Action').'</th>'.
900: '<th>'.&mt('Notification address').'</th><th>'.
1.113 raeburn 901: &mt('Types of message for which notification is sent').
902: $criticalMessageHelp.'</th><th>'.
1.104 raeburn 903: &mt('Excerpt retains HTML tags in message').'</th>'.
1.102 raeburn 904: &Apache::loncommon::end_data_table_header_row();
905: my $num = 0;
1.104 raeburn 906: my $counter = 1;
1.102 raeburn 907: foreach my $item (@sortforwards) {
908: $output .= &Apache::loncommon::start_data_table_row().
1.104 raeburn 909: '<td><b>'.$counter.'</b></td>'.
910: '<td><span class="LC_nobreak"><label>'.
911: '<input type="checkbox" name="modify_notify_'.
912: $num.'" onclick="javscript:modify_address('."'$num'".')" />'.
913: &mt('Modify').'</label></span> '.
914: '<span class="LC_nobreak"><label>'.
915: '<input type="checkbox" name="del_notify_'.$num.
916: '" onclick="javscript:delete_address('."'$num'".')" />'.
917: &mt('Delete').'</label></span></td>'.
1.102 raeburn 918: '<td><input type="text" value="'.$item.'" name="address_'.
1.196.4.12 raeburn 919: $num.'" onfocus="javascript:address_changes('."'$num'".
1.104 raeburn 920: ')" /></td><td>';
1.102 raeburn 921: my %chk;
922: if (defined($allnot{$item}{'crit'})) {
923: if (defined($allnot{$item}{'reg'})) {
924: $chk{'all'} = 'checked="checked" ';
925: } else {
926: $chk{'crit'} = 'checked="checked" ';
927: }
928: } else {
929: $chk{'reg'} = 'checked="checked" ';
930: }
931: foreach my $type ('all','crit','reg') {
932: $output .= '<span class="LC_nobreak"><label>'.
933: '<input type="radio" name="notify_type_'.$num.
1.104 raeburn 934: '" value="'.$type.'" '.$chk{$type}.
935: ' onchange="javascript:address_changes('."'$num'".')" />'.
1.175 raeburn 936: $lt{$type}.'</label></span>'.(' ' x4);
1.102 raeburn 937: }
938: my $htmlon = '';
939: my $htmloff = '';
940: if (grep/^\Q$item\E/,@allow_html) {
941: $htmlon = 'checked="checked" ';
942: } else {
943: $htmloff = 'checked="checked" ';
944: }
945: $output .= '</td><td><label><input type="radio" name="html_'.$num.
1.104 raeburn 946: '" value="1" '.$htmlon.
947: ' onchange="javascript:address_changes('."'$num'".')" />'.
1.175 raeburn 948: &mt('Yes').'</label>'.(' ' x3).
1.102 raeburn 949: '<label><input type="radio" name="html_'.$num.'" value="0" '.
1.104 raeburn 950: $htmloff. ' onchange="javascript:address_changes('."'$num'".
951: ')" />'.
952: &mt('No').'</label></td>'.
1.102 raeburn 953: &Apache::loncommon::end_data_table_row();
954: $num ++;
1.104 raeburn 955: $counter ++;
1.102 raeburn 956: }
957: my %defchk = (
958: all => 'checked="checked" ',
959: crit => '',
960: reg => '',
961: );
962: $output .= &Apache::loncommon::start_data_table_row().
1.104 raeburn 963: '<td><b>'.$counter.'</b></td>'.
964: '<td><span class="LC_nobreak"><label>'.
965: '<input type="checkbox" name="add_notify_'.$num.
966: '" value="1" />'.&mt('Add new address').'</label></span></td>'.
1.102 raeburn 967: '<td><input type="text" value="" name="address_'.$num.
1.196.4.12 raeburn 968: '" onfocus="javascript:new_address('."'$num'".')" /></td><td>';
1.102 raeburn 969: foreach my $type ('all','crit','reg') {
970: $output .= '<span class="LC_nobreak"><label>'.
971: '<input type="radio" name="notify_type_'.$num.
972: '" value="'.$type.'" '.$defchk{$type}.'/>'.
1.175 raeburn 973: $lt{$type}.'</label></span>'.(' ' x4);
1.102 raeburn 974: }
975: $output .= '</td><td><label><input type="radio" name="html_'.$num.
1.175 raeburn 976: '" value="1" />'.&mt('Yes').'</label>'.(' ' x3).
1.102 raeburn 977: '<label><input type="radio" name="html_'.$num.'" value="0" '.
978: ' checked="checked" />'.
979: &mt('No').'</label></td>'.
980: &Apache::loncommon::end_data_table_row().
981: &Apache::loncommon::end_data_table();
982: $num ++;
983: $r->print($output);
984: $r->print(qq|
1.113 raeburn 985: <br /><hr />
1.102 raeburn 986: <input type="hidden" name="numnotify" value="$num" />
1.136 schafran 987: <input type="button" value="$lt{'prme'}" onclick="location.href='/adm/preferences'" />
1.102 raeburn 988: <input type="button" value="$lt{'chg'}" onclick="javascript:validate()" />
1.20 www 989: </form>
1.102 raeburn 990: |);
991:
992: }
993:
994: sub get_notifications {
995: my ($userenv) = @_;
996: my %allnot;
997: my @critnot = split(/,/,$userenv->{'critnotification'});
998: my @regnot = split(/,/,$userenv->{'notification'});
999: foreach my $item (@critnot) {
1000: $allnot{$item}{crit} = 1;
1001: }
1002: foreach my $item (@regnot) {
1003: $allnot{$item}{reg} = 1;
1004: }
1005: return %allnot;
1.20 www 1006: }
1007:
1008: sub verify_and_change_msgforward {
1009: my $r = shift;
1.59 albertel 1010: my $user = $env{'user.name'};
1011: my $domain = $env{'user.domain'};
1.20 www 1012: my $newscreen = '';
1013: my $message='';
1.182 raeburn 1014: foreach my $recip (split(/\,/,$env{'form.msgforward'})) {
1015: my ($msuser,$msdomain);
1016: if ($recip =~ /:/) {
1017: ($msuser,$msdomain)=split(':',$recip);
1018: } else {
1019: ($msuser,$msdomain)=split(/\@/,$recip);
1020: }
1.95 albertel 1021: $msuser = &LONCAPA::clean_username($msuser);
1022: $msdomain = &LONCAPA::clean_domain($msdomain);
1.20 www 1023: if (($msuser) && ($msdomain)) {
1024: if (&Apache::lonnet::homeserver($msuser,$msdomain) ne 'no_host') {
1.182 raeburn 1025: $newscreen.=$msuser.':'.$msdomain.',';
1026: } else {
1027: $message.= &mt('No such user: ').'<tt>'.$msuser.':'.$msdomain.'</tt><br />';
1028: }
1.20 www 1029: }
1030: }
1031: $newscreen=~s/\,$//;
1032: if ($newscreen) {
1033: &Apache::lonnet::put('environment',{'msgforward' => $newscreen});
1.116 raeburn 1034: &Apache::lonnet::appenv({'environment.msgforward' => $newscreen});
1.180 wenzelju 1035: $message .= &Apache::lonhtmlcommon::confirm_success(&mt('Set message forwarding to ').'<tt>"'.$newscreen.'"</tt>.<br />');
1.20 www 1036: } else {
1037: &Apache::lonnet::del('environment',['msgforward']);
1.139 raeburn 1038: &Apache::lonnet::delenv('environment.msgforward');
1.180 wenzelju 1039: $message.= &Apache::lonhtmlcommon::confirm_success(&mt("Set message forwarding to 'off'.").'<br />');
1.20 www 1040: }
1.102 raeburn 1041: my $critnotification;
1042: my $notification;
1043: my $notify_with_html;
1044: my $lastnotify = $env{'form.numnotify'}-1;
1.104 raeburn 1045: my $totaladdresses = 0;
1.102 raeburn 1046: for (my $i=0; $i<$env{'form.numnotify'}; $i++) {
1047: if ((!defined($env{'form.del_notify_'.$i})) &&
1.104 raeburn 1048: ((($i==$lastnotify) && ($env{'form.add_notify_'.$lastnotify} == 1)) ||
1.102 raeburn 1049: ($i<$lastnotify))) {
1050: if (defined($env{'form.address_'.$i})) {
1051: if ($env{'form.notify_type_'.$i} eq 'all') {
1052: $critnotification .= $env{'form.address_'.$i}.',';
1053: $notification .= $env{'form.address_'.$i}.',';
1054: } elsif ($env{'form.notify_type_'.$i} eq 'crit') {
1055: $critnotification .= $env{'form.address_'.$i}.',';
1056: } elsif ($env{'form.notify_type_'.$i} eq 'reg') {
1057: $notification .= $env{'form.address_'.$i}.',';
1058: }
1059: if ($env{'form.html_'.$i} eq '1') {
1060: $notify_with_html .= $env{'form.address_'.$i}.',';
1061: }
1.104 raeburn 1062: $totaladdresses ++;
1.102 raeburn 1063: }
1064: }
1065: }
1066: $critnotification =~ s/,$//;
1067: $critnotification=~s/\s//gs;
1068: $notification =~ s/,$//;
1.20 www 1069: $notification=~s/\s//gs;
1.102 raeburn 1070: $notify_with_html =~ s/,$//;
1071: $notify_with_html =~ s/\s//gs;
1.20 www 1072: if ($notification) {
1073: &Apache::lonnet::put('environment',{'notification' => $notification});
1.116 raeburn 1074: &Apache::lonnet::appenv({'environment.notification' => $notification});
1.180 wenzelju 1075: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Set non-critical message notification address(es) to ').'<tt>"'.$notification.'"</tt>.<br />');
1.20 www 1076: } else {
1077: &Apache::lonnet::del('environment',['notification']);
1.139 raeburn 1078: &Apache::lonnet::delenv('environment.notification');
1.180 wenzelju 1079: $message.=&Apache::lonhtmlcommon::confirm_success(&mt("Set non-critical message notification to 'off'.").'<br />');
1.20 www 1080: }
1081: if ($critnotification) {
1082: &Apache::lonnet::put('environment',{'critnotification' => $critnotification});
1.116 raeburn 1083: &Apache::lonnet::appenv({'environment.critnotification' => $critnotification});
1.180 wenzelju 1084: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Set critical message notification address(es) to ').'<tt>"'.$critnotification.'"</tt>.<br />');
1.20 www 1085: } else {
1086: &Apache::lonnet::del('environment',['critnotification']);
1.139 raeburn 1087: &Apache::lonnet::delenv('environment.critnotification');
1.180 wenzelju 1088: $message.=&Apache::lonhtmlcommon::confirm_success(&mt("Set critical message notification to 'off'.").'<br />');
1.102 raeburn 1089: }
1090: if ($critnotification || $notification) {
1091: if ($notify_with_html) {
1092: &Apache::lonnet::put('environment',{'notifywithhtml' => $notify_with_html});
1.116 raeburn 1093: &Apache::lonnet::appenv({'environment.notifywithhtml' => $notify_with_html});
1.180 wenzelju 1094: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Set address(es) to receive excerpts with html retained ').'<tt>"'.$notify_with_html.'"</tt>.');
1.102 raeburn 1095: } else {
1096: &Apache::lonnet::del('environment',['notifywithhtml']);
1.139 raeburn 1097: &Apache::lonnet::delenv('environment.notifywithhtml');
1.104 raeburn 1098: if ($totaladdresses == 1) {
1.180 wenzelju 1099: $message.=&Apache::lonhtmlcommon::confirm_success(&mt("Set notification address to receive excerpts with html stripped."));
1.104 raeburn 1100: } else {
1.180 wenzelju 1101: $message.=&Apache::lonhtmlcommon::confirm_success(&mt("Set all notification addresses to receive excerpts with html stripped."));
1.104 raeburn 1102: }
1.102 raeburn 1103: }
1104: } else {
1105: &Apache::lonnet::del('environment',['notifywithhtml']);
1.139 raeburn 1106: &Apache::lonnet::delenv('environment.notifywithhtml');
1.102 raeburn 1107: }
1.109 albertel 1108: &Apache::loncommon::flush_email_cache($user,$domain);
1.180 wenzelju 1109: $message=&Apache::loncommon::confirmwrapper($message);
1.102 raeburn 1110: &msgforwardchanger($r,$message);
1.6 www 1111: }
1112:
1.12 www 1113: ################################################################
1.19 www 1114: # Colors #
1.12 www 1115: ################################################################
1116:
1.19 www 1117: sub colorschanger {
1.12 www 1118: my $r = shift;
1.126 droeschl 1119: Apache::lonhtmlcommon::add_breadcrumb(
1120: { href => '/adm/preferences?action=changecolors',
1121: text => 'Change Colors'});
1.147 schafran 1122: $r->print(Apache::loncommon::start_page('Page Display Settings'));
1.126 droeschl 1123: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Colors'));
1.19 www 1124: # figure out colors
1.80 albertel 1125: my $function=&Apache::loncommon::get_users_function();
1.19 www 1126: my $domain=&Apache::loncommon::determinedomain();
1.157 bisitz 1127: my %colortypes=&Apache::lonlocal::texthash(
1128: 'pgbg' => 'Page Background Color',
1129: 'tabbg' => 'Header Background Color',
1130: 'sidebg' => 'Header Border Color',
1131: 'font' => 'Font Color',
1132: 'fontmenu' => 'Font Menu Color',
1133: 'link' => 'Un-Visited Link Color',
1134: 'vlink' => 'Visited Link Color',
1135: 'alink' => 'Active Link Color',
1136: );
1.82 albertel 1137: my $start_data_table = &Apache::loncommon::start_data_table();
1.19 www 1138: my $chtable='';
1.22 matthew 1139: foreach my $item (sort(keys(%colortypes))) {
1.19 www 1140: my $curcol=&Apache::loncommon::designparm($function.'.'.$item,$domain);
1.82 albertel 1141: $chtable.=&Apache::loncommon::start_data_table_row().
1.196.4.7 raeburn 1142: '<td>'.$colortypes{$item}.'<td><input name="'.$item.
1143: '" class="colorchooser" size="10" value="'.$curcol.
1144: '" /></td>'.
1145: &Apache::loncommon::end_data_table_row()."\n";
1.19 www 1146: }
1.82 albertel 1147: my $end_data_table = &Apache::loncommon::end_data_table();
1.23 matthew 1148: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.157 bisitz 1149: my $savebutton = &mt('Save');
1150: my $resetbutton = &mt('Reset All');
1151: my $resetbuttondesc = &mt('Reset All Colors to Default');
1.196.4.7 raeburn 1152: my $colorchooser=&Apache::lonhtmlcommon::color_picker();
1.196.4.9 raeburn 1153: $r->print('<script type="text/javascript" language="JavaScript">
1.196.4.7 raeburn 1154: ' . $colorchooser . '
1155: </script>
1156: ');
1.19 www 1157:
1.196.4.7 raeburn 1158: $r->print(<<ENDCOL);
1.19 www 1159:
1.196.4.12 raeburn 1160: <form name="parmform" action="">
1.21 www 1161: <input type="hidden" name="pres_marker" />
1162: <input type="hidden" name="pres_type" />
1163: <input type="hidden" name="pres_value" />
1164: </form>
1.88 albertel 1165: <form name="prefs" action="/adm/preferences" method="post">
1.19 www 1166: <input type="hidden" name="action" value="verify_and_change_colors" />
1.82 albertel 1167: $start_data_table
1.19 www 1168: $chtable
1.82 albertel 1169: $end_data_table
1.19 www 1170: </table>
1.157 bisitz 1171: <p>
1172: <input type="submit" value="$savebutton" />
1173: <input type="submit" name="resetall" value="$resetbutton" title="$resetbuttondesc" />
1174: </p>
1.12 www 1175: </form>
1.19 www 1176: ENDCOL
1.12 www 1177: }
1178:
1.19 www 1179: sub verify_and_change_colors {
1.12 www 1180: my $r = shift;
1.19 www 1181: # figure out colors
1.80 albertel 1182: my $function=&Apache::loncommon::get_users_function();
1.19 www 1183: my $domain=&Apache::loncommon::determinedomain();
1.157 bisitz 1184: my %colortypes=&Apache::lonlocal::texthash(
1185: 'pgbg' => 'Page Background Color',
1186: 'tabbg' => 'Header Background Color',
1187: 'sidebg' => 'Header Border Color',
1188: 'font' => 'Font Color',
1189: 'fontmenu' => 'Font Menu Color',
1190: 'link' => 'Un-Visited Link Color',
1191: 'vlink' => 'Visited Link Color',
1192: 'alink' => 'Active Link Color',
1193: );
1.19 www 1194:
1.12 www 1195: my $message='';
1.196.4.16 raeburn 1196: foreach my $item (keys(%colortypes)) {
1.59 albertel 1197: my $color=$env{'form.'.$item};
1.196.4.7 raeburn 1198: if (!($color =~ /^#/)) {
1199: $color = '#' . $color;
1200: }
1.21 www 1201: my $entry='color.'.$function.'.'.$item;
1.59 albertel 1202: if (($color=~/^\#[0-9A-Fa-f]{6}$/) && (!$env{'form.resetall'})) {
1.21 www 1203: &Apache::lonnet::put('environment',{$entry => $color});
1.116 raeburn 1204: &Apache::lonnet::appenv({'environment.'.$entry => $color});
1.157 bisitz 1205: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]','<i>'.$colortypes{$item}.'</i>','<tt>"'.$color.'"</tt>'))
1206: .'<br />';
1.21 www 1207: } else {
1208: &Apache::lonnet::del('environment',[$entry]);
1.138 schafran 1209: &Apache::lonnet::delenv('environment.'.$entry);
1.157 bisitz 1210: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Reset [_1]','<i>'.$colortypes{$item}.'</i>'))
1211: .'<br />';
1.21 www 1212: }
1213: }
1.158 bisitz 1214: $message=&Apache::loncommon::confirmwrapper($message);
1.157 bisitz 1215:
1.84 albertel 1216: my $now = time;
1217: &Apache::lonnet::put('environment',{'color.timestamp' => $now});
1.116 raeburn 1218: &Apache::lonnet::appenv({'environment.color.timestamp' => $now});
1.84 albertel 1219:
1.152 www 1220: &print_main_menu($r, $message);
1.12 www 1221: }
1222:
1.4 matthew 1223: ######################################################
1224: # password handler subroutines #
1225: ######################################################
1.3 matthew 1226: sub passwordchanger {
1.94 raeburn 1227: my ($r,$errormessage,$caller,$mailtoken) = @_;
1.4 matthew 1228: # This function is a bit of a mess....
1.3 matthew 1229: # Passwords are encrypted using londes.js (DES encryption)
1.4 matthew 1230: $errormessage = ($errormessage || '');
1.193 raeburn 1231: my ($user,$domain,$currentpass);
1.152 www 1232: &Apache::lonhtmlcommon::add_breadcrumb(
1.126 droeschl 1233: { href => '/adm/preferences?action=changepass',
1234: text => 'Change Password'});
1.144 raeburn 1235: unless ($caller eq 'reset_by_email') {
1.147 schafran 1236: $r->print(Apache::loncommon::start_page('Personal Data'));
1.144 raeburn 1237: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Password'));
1238: }
1.196.4.17 raeburn 1239: my ($blocked,$blocktext) =
1240: &Apache::loncommon::blocking_status('passwd');
1241: if ($blocked) {
1242: $r->print('<p class="LC_warning">'.$blocktext.'</p>');
1243: return;
1244: }
1.94 raeburn 1245: if ((!defined($caller)) || ($caller eq 'preferences')) {
1246: $user = $env{'user.name'};
1247: $domain = $env{'user.domain'};
1248: if (!defined($caller)) {
1249: $caller = 'preferences';
1250: }
1251: } elsif ($caller eq 'reset_by_email') {
1252: my %data = &Apache::lonnet::tmpget($mailtoken);
1253: if (keys(%data) == 0) {
1.196.4.6 raeburn 1254: $r->print(
1255: '<p class="LC_warning">'
1256: .&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.'
1.155 bisitz 1257: ,'<a href="/adm/resetpw">','</a>')
1.196.4.6 raeburn 1258: .'</p>'
1.155 bisitz 1259: );
1.94 raeburn 1260: return;
1261: }
1262: if (defined($data{time})) {
1263: if (time - $data{'time'} < 7200) {
1264: $user = $data{'username'};
1265: $domain = $data{'domain'};
1266: $currentpass = $data{'temppasswd'};
1267: } else {
1.196.4.6 raeburn 1268: $r->print(
1269: '<p class="LC_warning">'
1270: .&mt('Sorry, the token generated when you requested'
1271: .' a password reset has expired.')
1272: .'</p>'
1273: );
1.94 raeburn 1274: return;
1275: }
1276: } else {
1.196.4.6 raeburn 1277: $r->print(
1278: '<p class="LC_warning">'
1279: .&mt('Sorry, the URL generated when you requested reset of'
1280: .' your password contained incomplete information.')
1281: .'</p>'
1282: );
1.94 raeburn 1283: return;
1284: }
1.193 raeburn 1285: if (&Apache::lonnet::domain($domain) eq '') {
1286: $domain = $r->dir_config('lonDefDomain');
1287: }
1288: } else {
1.196.4.6 raeburn 1289: $r->print(
1290: '<p class="LC_error">'
1291: .&mt('Page requested in unexpected context')
1292: .'</p>'
1293: );
1.94 raeburn 1294: return;
1295: }
1.3 matthew 1296: my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
1297: # Check for authentication types that allow changing of the password.
1298: return if ($currentauth !~ /^(unix|internal):/);
1299: #
1300: # Generate keys
1.196.4.14 raeburn 1301: my ($lkey_cpass ,$ukey_cpass ) = &Apache::loncommon::des_keys();
1302: my ($lkey_npass1,$ukey_npass1) = &Apache::loncommon::des_keys();
1303: my ($lkey_npass2,$ukey_npass2) = &Apache::loncommon::des_keys();
1.4 matthew 1304: # Store the keys in the log files
1.3 matthew 1305: my $lonhost = $r->dir_config('lonHostID');
1306: my $logtoken=Apache::lonnet::reply('tmpput:'
1307: .$ukey_cpass . $lkey_cpass .'&'
1308: .$ukey_npass1 . $lkey_npass1.'&'
1309: .$ukey_npass2 . $lkey_npass2,
1310: $lonhost);
1.4 matthew 1311: # Hexify the keys for output as javascript variables
1.94 raeburn 1312: my %hexkey;
1313: $hexkey{'ukey_cpass'} = hex($ukey_cpass);
1314: $hexkey{'lkey_cpass'} = hex($lkey_cpass);
1315: $hexkey{'ukey_npass1'} = hex($ukey_npass1);
1316: $hexkey{'lkey_npass1'} = hex($lkey_npass1);
1317: $hexkey{'ukey_npass2'} = hex($ukey_npass2);
1318: $hexkey{'lkey_npass2'} = hex($lkey_npass2);
1.3 matthew 1319: # Output javascript to deal with passwords
1.4 matthew 1320: # Output DES javascript
1.3 matthew 1321: {
1322: my $include = $r->dir_config('lonIncludes');
1323: my $jsh=Apache::File->new($include."/londes.js");
1324: $r->print(<$jsh>);
1325: }
1.94 raeburn 1326: $r->print(&jscript_send($caller));
1.3 matthew 1327: $r->print(<<ENDFORM);
1.94 raeburn 1328: $errormessage
1329:
1330: <p>
1331: <!-- We separate the forms into 'server' and 'client' in order to
1332: ensure that unencrypted passwords will not be sent out by a
1333: crappy browser -->
1334: ENDFORM
1335: $r->print(&server_form($logtoken,$caller,$mailtoken));
1.193 raeburn 1336: $r->print(&client_form($caller,\%hexkey,$currentpass,$domain));
1.94 raeburn 1337:
1338: #
1339: return;
1340: }
1341:
1342: sub jscript_send {
1343: my ($caller) = @_;
1344: my $output = qq|
1.148 bisitz 1345: <script type="text/javascript" language="JavaScript">
1.3 matthew 1346:
1347: function send() {
1348: uextkey=this.document.client.elements.ukey_cpass.value;
1349: lextkey=this.document.client.elements.lkey_cpass.value;
1350: initkeys();
1.196.4.19 raeburn 1351: this.document.pserver.elements.currentpass.value =
1352: getCrypted(this.document.client.elements.currentpass.value);
1.3 matthew 1353: uextkey=this.document.client.elements.ukey_npass1.value;
1354: lextkey=this.document.client.elements.lkey_npass1.value;
1355: initkeys();
1.52 raeburn 1356: this.document.pserver.elements.newpass_1.value
1.196.4.19 raeburn 1357: =getCrypted(this.document.client.elements.newpass_1.value);
1.3 matthew 1358: uextkey=this.document.client.elements.ukey_npass2.value;
1359: lextkey=this.document.client.elements.lkey_npass2.value;
1360: initkeys();
1.52 raeburn 1361: this.document.pserver.elements.newpass_2.value
1.196.4.19 raeburn 1362: =getCrypted(this.document.client.elements.newpass_2.value);
1.94 raeburn 1363: |;
1364: if ($caller eq 'reset_by_email') {
1365: $output .= qq|
1366: this.document.pserver.elements.uname.value =
1367: this.document.client.elements.uname.value;
1368: this.document.pserver.elements.udom.value =
1369: this.document.client.elements.udom.options[this.document.client.elements.udom.selectedIndex].value;
1.173 raeburn 1370: this.document.pserver.elements.email.value =
1371: this.document.client.elements.email.value;
1.94 raeburn 1372: |;
1373: }
1374: $ output .= qq|
1.52 raeburn 1375: this.document.pserver.submit();
1.3 matthew 1376: }
1.196.4.19 raeburn 1377:
1.3 matthew 1378: </script>
1.94 raeburn 1379: |;
1380: }
1.3 matthew 1381:
1.94 raeburn 1382: sub client_form {
1383: my ($caller,$hexkey,$currentpass,$defdom) = @_;
1.99 www 1384: my %lt=&Apache::lonlocal::texthash(
1.115 raeburn 1385: 'email' => 'E-mail Address',
1.99 www 1386: 'username' => 'Username',
1387: 'domain' => 'Domain',
1388: 'currentpass' => 'Current Password',
1389: 'newpass' => 'New Password',
1390: 'confirmpass' => 'Confirm Password',
1.169 raeburn 1391: 'changepass' => 'Save',
1392: );
1.99 www 1393:
1.196.4.12 raeburn 1394: my $output = '<form name="client" action="">'
1.164 bisitz 1395: .&Apache::lonhtmlcommon::start_pick_box();
1.94 raeburn 1396: if ($caller eq 'reset_by_email') {
1.196.4.22! raeburn 1397: my $mobileargs;
! 1398: (undef,undef,undef,undef,undef,undef,my $clientmobile) =
! 1399: &Apache::loncommon::decode_user_agent();
! 1400: if ($clientmobile) {
! 1401: $mobileargs = 'autocapitalize="off" autocorrect="off" ';
! 1402: }
1.164 bisitz 1403: $output .= &Apache::lonhtmlcommon::row_title(
1404: '<label for="email">'.$lt{'email'}.'</label>')
1.196.4.22! raeburn 1405: .'<input type="text" name="email" size="30" '.$mobileargs.'/>'
1.164 bisitz 1406: .&Apache::lonhtmlcommon::row_closure()
1407: .&Apache::lonhtmlcommon::row_title(
1408: '<label for="uname">'.$lt{'username'}.'</label>')
1.196.4.22! raeburn 1409: .'<input type="text" name="uname" size="20" '.$mobileargs.'/>'
1.164 bisitz 1410: .'<input type="hidden" name="currentpass" value="'.$currentpass.'" />'
1411: .&Apache::lonhtmlcommon::row_closure()
1412: .&Apache::lonhtmlcommon::row_title(
1413: '<label for="udom">'.$lt{'domain'}.'</label>')
1414: .&Apache::loncommon::select_dom_form($defdom,'udom')
1415: .&Apache::lonhtmlcommon::row_closure();
1.94 raeburn 1416: } else {
1.164 bisitz 1417: $output .= &Apache::lonhtmlcommon::row_title(
1418: '<label for="currentpass">'.$lt{'currentpass'}.'</label>')
1.196.4.19 raeburn 1419: .'<input type="password" name="currentpass" size="20"/>'
1.164 bisitz 1420: .&Apache::lonhtmlcommon::row_closure();
1421: }
1422: $output .= &Apache::lonhtmlcommon::row_title(
1423: '<label for="newpass_1">'.$lt{'newpass'}.'</label>')
1.196.4.19 raeburn 1424: .'<input type="password" name="newpass_1" size="20" />'
1.164 bisitz 1425: .&Apache::lonhtmlcommon::row_closure()
1426: .&Apache::lonhtmlcommon::row_title(
1427: '<label for="newpass_2">'.$lt{'confirmpass'}.'</label>')
1.196.4.19 raeburn 1428: .'<input type="password" name="newpass_2" size="20" />'
1.164 bisitz 1429: .&Apache::lonhtmlcommon::row_closure(1)
1430: .&Apache::lonhtmlcommon::end_pick_box();
1.196.4.12 raeburn 1431: $output .= '<p><input type="button" value="'.$lt{'changepass'}.'" onclick="send();" /></p>'
1.164 bisitz 1432: .qq|
1.94 raeburn 1433: <input type="hidden" name="ukey_cpass" value="$hexkey->{'ukey_cpass'}" />
1434: <input type="hidden" name="lkey_cpass" value="$hexkey->{'lkey_cpass'}" />
1435: <input type="hidden" name="ukey_npass1" value="$hexkey->{'ukey_npass1'}" />
1436: <input type="hidden" name="lkey_npass1" value="$hexkey->{'lkey_npass1'}" />
1437: <input type="hidden" name="ukey_npass2" value="$hexkey->{'ukey_npass2'}" />
1438: <input type="hidden" name="lkey_npass2" value="$hexkey->{'lkey_npass2'}" />
1.3 matthew 1439: </form>
1440: </p>
1.164 bisitz 1441: |;
1.94 raeburn 1442: return $output;
1443: }
1444:
1445: sub server_form {
1446: my ($logtoken,$caller,$mailtoken) = @_;
1447: my $action = '/adm/preferences';
1448: if ($caller eq 'reset_by_email') {
1449: $action = '/adm/resetpw';
1450: }
1451: my $output = qq|
1452: <form name="pserver" action="$action" method="post">
1453: <input type="hidden" name="logtoken" value="$logtoken" />
1454: <input type="hidden" name="currentpass" value="" />
1455: <input type="hidden" name="newpass_1" value="" />
1456: <input type="hidden" name="newpass_2" value="" />
1457: |;
1458: if ($caller eq 'reset_by_email') {
1459: $output .= qq|
1460: <input type="hidden" name="token" value="$mailtoken" />
1461: <input type="hidden" name="uname" value="" />
1462: <input type="hidden" name="udom" value="" />
1.173 raeburn 1463: <input type="hidden" name="email" value="" />
1.94 raeburn 1464:
1465: |;
1466: }
1467: $output .= qq|
1468: <input type="hidden" name="action" value="verify_and_change_pass" />
1469: </form>
1470: |;
1471: return $output;
1.3 matthew 1472: }
1473:
1474: sub verify_and_change_password {
1.94 raeburn 1475: my ($r,$caller,$mailtoken) = @_;
1476: my ($user,$domain,$homeserver);
1.196.4.17 raeburn 1477: my ($blocked,$blocktext) =
1478: &Apache::loncommon::blocking_status('passwd');
1479: if ($blocked) {
1480: $r->print('<p class="LC_warning">'.$blocktext.'</p>');
1481: return;
1482: }
1.94 raeburn 1483: if ($caller eq 'reset_by_email') {
1484: $user = $env{'form.uname'};
1485: $domain = $env{'form.udom'};
1486: if ($user ne '' && $domain ne '') {
1487: $homeserver = &Apache::lonnet::homeserver($user,$domain);
1488: if ($homeserver eq 'no_host') {
1.99 www 1489: &passwordchanger($r,"<p>\n<span class='LC_error'>".
1490: &mt("Invalid username and/or domain")."</span>\n</p>",
1.94 raeburn 1491: $caller,$mailtoken);
1492: return 1;
1493: }
1494: } else {
1.99 www 1495: &passwordchanger($r,"<p>\n<span class='LC_error'>".
1496: &mt("Username and domain were blank")."</span>\n</p>",
1.94 raeburn 1497: $caller,$mailtoken);
1498: return 1;
1499: }
1500: } else {
1501: $user = $env{'user.name'};
1502: $domain = $env{'user.domain'};
1503: $homeserver = $env{'user.home'};
1504: }
1.3 matthew 1505: my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
1.4 matthew 1506: # Check for authentication types that allow changing of the password.
1.94 raeburn 1507: if ($currentauth !~ /^(unix|internal):/) {
1508: if ($caller eq 'reset_by_email') {
1.99 www 1509: &passwordchanger($r,"<p>\n<span class='LC_error'>".
1510: &mt("Authentication type for this user can not be changed by this mechanism").
1511: "</span>\n</p>",
1.94 raeburn 1512: $caller,$mailtoken);
1513: return 1;
1514: } else {
1515: return;
1516: }
1517: }
1.3 matthew 1518: #
1.59 albertel 1519: my $currentpass = $env{'form.currentpass'};
1520: my $newpass1 = $env{'form.newpass_1'};
1521: my $newpass2 = $env{'form.newpass_2'};
1522: my $logtoken = $env{'form.logtoken'};
1.3 matthew 1523: # Check for empty data
1.4 matthew 1524: unless (defined($currentpass) &&
1525: defined($newpass1) &&
1526: defined($newpass2) ){
1.99 www 1527: &passwordchanger($r,"<p>\n<span class='LC_error'>".
1528: &mt("One or more password fields were blank").
1529: "</span>\n</p>",$caller,$mailtoken);
1.3 matthew 1530: return;
1531: }
1.16 albertel 1532: # Get the keys
1533: my $lonhost = $r->dir_config('lonHostID');
1.3 matthew 1534: my $tmpinfo = Apache::lonnet::reply('tmpget:'.$logtoken,$lonhost);
1535: if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) {
1.4 matthew 1536: # I do not a have a better idea about how to handle this
1.94 raeburn 1537: my $tryagain_text = &mt('Please log out and try again.');
1538: if ($caller eq 'reset_by_email') {
1539: $tryagain_text = &mt('Please try again later.');
1540: }
1.101 albertel 1541: my $unable=&mt("Unable to retrieve saved token for password decryption");
1.3 matthew 1542: $r->print(<<ENDERROR);
1543: <p>
1.99 www 1544: <span class="LC_error">$unable. $tryagain_text</span>
1.3 matthew 1545: </p>
1546: ENDERROR
1.4 matthew 1547: # Probably should log an error here
1.75 albertel 1548: return 1;
1.3 matthew 1549: }
1550: my ($ckey,$n1key,$n2key)=split(/&/,$tmpinfo);
1.4 matthew 1551: #
1.196.4.14 raeburn 1552: $currentpass = &Apache::loncommon::des_decrypt($ckey ,$currentpass);
1553: $newpass1 = &Apache::loncommon::des_decrypt($n1key,$newpass1);
1554: $newpass2 = &Apache::loncommon::des_decrypt($n2key,$newpass2);
1.94 raeburn 1555: #
1556: if ($caller eq 'reset_by_email') {
1557: my %data = &Apache::lonnet::tmpget($mailtoken);
1.117 raeburn 1558: if (keys(%data) == 0) {
1559: &passwordchanger($r,
1560: '<span class="LC_error">'.
1561: &mt('Could not verify current authentication.').' '.
1562: &mt('Please try again.').'</span>',$caller,$mailtoken);
1563: return 1;
1564: }
1.94 raeburn 1565: if ($currentpass ne $data{'temppasswd'}) {
1566: &passwordchanger($r,
1.99 www 1567: '<span class="LC_error">'.
1.110 bisitz 1568: &mt('Could not verify current authentication.').' '.
1569: &mt('Please try again.').'</span>',$caller,$mailtoken);
1.94 raeburn 1570: return 1;
1571: }
1572: }
1.3 matthew 1573: if ($newpass1 ne $newpass2) {
1.4 matthew 1574: &passwordchanger($r,
1.196.4.6 raeburn 1575: '<span class="LC_warning">'.
1.110 bisitz 1576: &mt('The new passwords you entered do not match.').' '.
1577: &mt('Please try again.').'</span>',$caller,$mailtoken);
1.75 albertel 1578: return 1;
1.4 matthew 1579: }
1580: if (length($newpass1) < 7) {
1581: &passwordchanger($r,
1.196.4.6 raeburn 1582: '<span class="LC_warning">'.
1.110 bisitz 1583: &mt('Passwords must be a minimum of 7 characters long.').' '.
1584: &mt('Please try again.').'</span>',$caller,$mailtoken);
1.75 albertel 1585: return 1;
1.3 matthew 1586: }
1.4 matthew 1587: #
1588: # Check for bad characters
1589: my $badpassword = 0;
1590: foreach (split(//,$newpass1)) {
1591: $badpassword = 1 if ((ord($_)<32)||(ord($_)>126));
1592: }
1593: if ($badpassword) {
1594: # I can't figure out how to enter bad characters on my browser.
1.196.4.6 raeburn 1595: my $errormessage ='<span class="LC_warning">'.
1.110 bisitz 1596: &mt('The password you entered contained illegal characters.').'<br />'.
1.99 www 1597: &mt('Valid characters are').(<<"ENDERROR");
1598: : space and <br />
1.4 matthew 1599: <pre>
1600: !"\#$%&\'()*+,-./0123456789:;<=>?\@
1601: ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}~
1.99 www 1602: </pre></span>
1.4 matthew 1603: ENDERROR
1.94 raeburn 1604: &passwordchanger($r,$errormessage,$caller,$mailtoken);
1605: return 1;
1.4 matthew 1606: }
1607: #
1608: # Change the password (finally)
1609: my $result = &Apache::lonnet::changepass
1.94 raeburn 1610: ($user,$domain,$currentpass,$newpass1,$homeserver,$caller);
1.4 matthew 1611: # Inform the user the password has (not?) been changed
1.126 droeschl 1612: my $message;
1.4 matthew 1613: if ($result =~ /^ok$/) {
1.170 bisitz 1614: $message = &Apache::lonhtmlcommon::confirm_success(&mt('The password for user [_1] was successfully changed.','<i>'.$user.'</i>'));
1.180 wenzelju 1615: $message = &Apache::loncommon::confirmwrapper($message);
1.144 raeburn 1616: if ($caller eq 'reset_by_email') {
1617: $r->print($message.'<br />');
1618: } else {
1619: &print_main_menu($r, $message);
1620: }
1.4 matthew 1621: } else {
1622: # error error: run in circles, scream and shout
1.173 raeburn 1623: if ($caller eq 'reset_by_email') {
1624: if (!$result) {
1625: return 1;
1626: } else {
1627: return $result;
1628: }
1629: } else {
1630: $message = &Apache::lonhtmlcommon::confirm_success(
1631: &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 1632: $message=&Apache::loncommon::confirmwrapper($message);
1.144 raeburn 1633: &print_main_menu($r, $message);
1634: }
1.4 matthew 1635: }
1636: return;
1.3 matthew 1637: }
1638:
1.42 raeburn 1639: ################################################################
1640: # discussion display subroutines
1641: ################################################################
1642: sub discussionchanger {
1643: my $r = shift;
1.126 droeschl 1644: Apache::lonhtmlcommon::add_breadcrumb(
1645: { href => '/adm/preferences?action=changediscussions',
1646: text => 'Change Discussion Preferences'});
1.178 bisitz 1647: $r->print(Apache::loncommon::start_page('Change Discussion Preferences'));
1.126 droeschl 1648: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Discussion Preferences'));
1.59 albertel 1649: my $user = $env{'user.name'};
1650: my $domain = $env{'user.domain'};
1.42 raeburn 1651: my %userenv = &Apache::lonnet::get
1.43 raeburn 1652: ('environment',['discdisplay','discmarkread']);
1653: my $discdisp = 'allposts';
1654: my $discmark = 'onmark';
1655:
1656: if (defined($userenv{'discdisplay'})) {
1657: unless ($userenv{'discdisplay'} eq '') {
1658: $discdisp = $userenv{'discdisplay'};
1659: }
1660: }
1661: if (defined($userenv{'discmarkread'})) {
1.171 raeburn 1662: unless ($userenv{'discmarkread'} eq '') {
1.43 raeburn 1663: $discmark = $userenv{'discmarkread'};
1664: }
1665: }
1666:
1667: my $newdisp = 'unread';
1668: my $newmark = 'ondisp';
1669:
1670: my $function = &Apache::loncommon::get_users_function();
1671: my $color = &Apache::loncommon::designparm($function.'.tabbg',
1.59 albertel 1672: $env{'user.domain'});
1.43 raeburn 1673: my %lt = &Apache::lonlocal::texthash(
1674: 'pref' => 'Display Preference',
1675: 'curr' => 'Current setting ',
1676: 'actn' => 'Action',
1.135 schafran 1677: 'sdpf' => 'Set display preferences for discussion posts for both discussion boards and individual resources in all your courses.',
1.43 raeburn 1678: 'prca' => 'Preferences can be set that determine',
1.135 schafran 1679: 'whpo' => 'Which posts are displayed when you display a discussion board or resource, and',
1.194 raeburn 1680: 'unwh' => 'Under what circumstances posts are identified as "NEW"',
1.43 raeburn 1681: 'allposts' => 'All posts',
1682: 'unread' => 'New posts only',
1683: 'ondisp' => 'Once displayed',
1.194 raeburn 1684: 'onmark' => 'Once marked not NEW',
1.43 raeburn 1685: 'disa' => 'Posts displayed?',
1.194 raeburn 1686: 'npmr' => 'New posts cease to be identified as "NEW"?',
1.43 raeburn 1687: 'thde' => 'The preferences you set here can be overridden within each individual discussion.',
1688: 'chgt' => 'Change to '
1689: );
1690: my $dispchange = $lt{'unread'};
1691: my $markchange = $lt{'ondisp'};
1692: my $currdisp = $lt{'allposts'};
1693: my $currmark = $lt{'onmark'};
1694:
1695: if ($discdisp eq 'unread') {
1696: $dispchange = $lt{'allposts'};
1697: $currdisp = $lt{'unread'};
1698: $newdisp = 'allposts';
1699: }
1700:
1701: if ($discmark eq 'ondisp') {
1702: $markchange = $lt{'onmark'};
1703: $currmark = $lt{'ondisp'};
1704: $newmark = 'onmark';
1.42 raeburn 1705: }
1.171 raeburn 1706:
1.43 raeburn 1707: $r->print(<<"END");
1.88 albertel 1708: <form name="prefs" action="/adm/preferences" method="post">
1.42 raeburn 1709: <input type="hidden" name="action" value="verify_and_change_discussion" />
1710: <br />
1.87 albertel 1711: $lt{'sdpf'}<br /> $lt{'prca'} <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li></ol>
1.82 albertel 1712: END
1.158 bisitz 1713:
1714: $r->print('<p class="LC_info">'.$lt{'thde'}.'</p>');
1715:
1.82 albertel 1716: $r->print(&Apache::loncommon::start_data_table());
1717: $r->print(<<"END");
1718: <tr>
1719: <th>$lt{'pref'}</th>
1720: <th>$lt{'curr'}</th>
1721: <th>$lt{'actn'}?</th>
1.43 raeburn 1722: </tr>
1.82 albertel 1723: END
1724: $r->print(&Apache::loncommon::start_data_table_row());
1725: $r->print(<<"END");
1.43 raeburn 1726: <td>$lt{'disa'}</td>
1727: <td>$lt{$discdisp}</td>
1.82 albertel 1728: <td><label><input type="checkbox" name="discdisp" /><input type="hidden" name="newdisp" value="$newdisp" /> $lt{'chgt'} "$dispchange"</label></td>
1729: END
1730: $r->print(&Apache::loncommon::end_data_table_row().
1731: &Apache::loncommon::start_data_table_row());
1732: $r->print(<<"END");
1.43 raeburn 1733: <td>$lt{'npmr'}</td>
1734: <td>$lt{$discmark}</td>
1.82 albertel 1735: <td><label><input type="checkbox" name="discmark" /><input type="hidden" name="newmark" value="$newmark" /> $lt{'chgt'} "$markchange"</label></td>
1.43 raeburn 1736: </tr>
1.82 albertel 1737: END
1738: $r->print(&Apache::loncommon::end_data_table_row().
1739: &Apache::loncommon::end_data_table());
1.142 zhu 1740:
1.158 bisitz 1741: $r->print('<br />'
1742: .'<input type="submit" name="sub" value="'.&mt('Save').'" />'
1743: .'</form>'
1744: );
1.42 raeburn 1745: }
1746:
1747: sub verify_and_change_discussion {
1748: my $r = shift;
1.59 albertel 1749: my $user = $env{'user.name'};
1750: my $domain = $env{'user.domain'};
1.42 raeburn 1751: my $message='';
1.59 albertel 1752: if (defined($env{'form.discdisp'}) ) {
1753: my $newdisp = $env{'form.newdisp'};
1.43 raeburn 1754: if ($newdisp eq 'unread') {
1.171 raeburn 1755: $message .=&Apache::lonhtmlcommon::confirm_success(&mt('In discussions: only new posts will be displayed.')).'<br />';
1.43 raeburn 1756: &Apache::lonnet::put('environment',{'discdisplay' => $newdisp});
1.116 raeburn 1757: &Apache::lonnet::appenv({'environment.discdisplay' => $newdisp});
1.43 raeburn 1758: } else {
1.171 raeburn 1759: $message .= &Apache::lonhtmlcommon::confirm_success(&mt('In discussions: all posts will be displayed.')).'<br />';
1.43 raeburn 1760: &Apache::lonnet::del('environment',['discdisplay']);
1.139 raeburn 1761: &Apache::lonnet::delenv('environment.discdisplay');
1.43 raeburn 1762: }
1763: }
1.59 albertel 1764: if (defined($env{'form.discmark'}) ) {
1765: my $newmark = $env{'form.newmark'};
1.43 raeburn 1766: if ($newmark eq 'ondisp') {
1.196.4.12 raeburn 1767: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('In discussions: new posts will cease to be identified as "NEW" after display.')).'<br />';
1.43 raeburn 1768: &Apache::lonnet::put('environment',{'discmarkread' => $newmark});
1.116 raeburn 1769: &Apache::lonnet::appenv({'environment.discmarkread' => $newmark});
1.43 raeburn 1770: } else {
1.194 raeburn 1771: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('In discussions: posts will be identified as "NEW" until marked as not "NEW".')).'<br />';
1.43 raeburn 1772: &Apache::lonnet::del('environment',['discmarkread']);
1.139 raeburn 1773: &Apache::lonnet::delenv('environment.discmarkread');
1.43 raeburn 1774: }
1.42 raeburn 1775: }
1.158 bisitz 1776: $message=&Apache::loncommon::confirmwrapper($message);
1.152 www 1777: &print_main_menu($r, $message);
1.42 raeburn 1778: }
1779:
1.63 raeburn 1780: ################################################################
1781: # Subroutines for page display on course access (Course Coordinators)
1782: ################################################################
1783: sub coursedisplaychanger {
1784: my $r = shift;
1.152 www 1785: &Apache::lonhtmlcommon::add_breadcrumb(
1.126 droeschl 1786: { href => '/adm/preferences?action=changecourseinit',
1787: text => 'Change Course Init. Pref.'});
1788: $r->print(Apache::loncommon::start_page('Change Course Initialization Preference'));
1789: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Course Init. Pref.'));
1.63 raeburn 1790: my $user = $env{'user.name'};
1791: my $domain = $env{'user.domain'};
1.66 albertel 1792: my %userenv = &Apache::lonnet::get('environment',['course_init_display']);
1.71 raeburn 1793: my $currvalue = 'whatsnew';
1.73 albertel 1794: my $firstselect = '';
1795: my $whatsnewselect = 'checked="checked"';
1.71 raeburn 1796: if (exists($userenv{'course_init_display'})) {
1797: if ($userenv{'course_init_display'} eq 'firstres') {
1798: $currvalue = 'firstres';
1.73 albertel 1799: $firstselect = 'checked="checked"';
1800: $whatsnewselect = '';
1.71 raeburn 1801: }
1.63 raeburn 1802: }
1.134 bisitz 1803: my %pagenames = &Apache::lonlocal::texthash(
1.71 raeburn 1804: firstres => 'First resource',
1.143 hauer 1805: whatsnew => "What's New Page",
1.71 raeburn 1806: );
1.134 bisitz 1807: my $whatsnew_off=&mt('Display the [_1]first resource[_2] in the course.','<b>','</b>');
1.143 hauer 1808: 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 1809:
1.134 bisitz 1810: $r->print('<br /><b>'
1811: .&mt('Set the default page to be displayed when you select a course role')
1812: .'</b> '
1813: .&mt('(Currently: [_1])',$pagenames{$currvalue})
1814: .'<br />'
1.143 hauer 1815: .&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 1816: .'<br /><br />'
1817: );
1.63 raeburn 1818: $r->print(<<ENDLSCREEN);
1.88 albertel 1819: <form name="prefs" action="/adm/preferences" method="post">
1.63 raeburn 1820: <input type="hidden" name="action" value="verify_and_change_coursepage" />
1.72 albertel 1821: <br />
1.65 albertel 1822: <label><input type="radio" name="newdisp" value="firstres" $firstselect /> $whatsnew_off</label><br />
1.70 raeburn 1823: <label><input type="radio" name="newdisp" value="whatsnew" $whatsnewselect /> $whatsnew_on</label><input type="hidden" name="refpage" value="$env{'form.refpage'}" />
1.63 raeburn 1824: ENDLSCREEN
1.140 schafran 1825: $r->print('<br /><br /><input type="submit" value="'.&mt('Save').'" />
1.63 raeburn 1826: </form>');
1827: }
1828:
1829: sub verify_and_change_coursepage {
1830: my $r = shift;
1831: my $message='';
1832: my %lt = &Apache::lonlocal::texthash(
1.70 raeburn 1833: 'defs' => 'Default now set',
1.71 raeburn 1834: 'when' => 'when you select a course role from the roles screen',
1.63 raeburn 1835: 'ywbt' => 'you will be taken to the start of the course.',
1836: 'apwb' => 'a page will be displayed that lists items in the course that may require action from you.',
1837: 'gtts' => 'Go to the start of the course',
1.146 hauer 1838: 'dasp' => "Display the What's New Page",
1.63 raeburn 1839: );
1840: my $newdisp = $env{'form.newdisp'};
1.70 raeburn 1841: $message = '<b>'.$lt{'defs'}.'</b>: '.$lt{'when'}.', ';
1.63 raeburn 1842: if ($newdisp eq 'firstres') {
1.87 albertel 1843: $message .= $lt{'ywbt'}.'<br />';
1.63 raeburn 1844: &Apache::lonnet::put('environment',{'course_init_display' => $newdisp});
1.116 raeburn 1845: &Apache::lonnet::appenv({'environment.course_init_display' => $newdisp});
1.63 raeburn 1846: } else {
1.87 albertel 1847: $message .= $lt{'apwb'}.'<br />';
1.63 raeburn 1848: &Apache::lonnet::del('environment',['course_init_display']);
1.139 raeburn 1849: &Apache::lonnet::delenv('environment.course_init_display');
1.63 raeburn 1850: }
1.70 raeburn 1851: my $refpage = $env{'form.refpage'};
1.63 raeburn 1852: if (($env{'request.course.fn'}) && ($env{'request.course.id'})) {
1853: if ($newdisp eq 'firstres') {
1854: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1855: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1856: my ($furl,$ferr)=
1857: &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
1.180 wenzelju 1858: $message .= '<br /><a href="'.$furl.'">'.$lt{'gtts'}.' <i>'.&mt('now').'</i></a>';
1.63 raeburn 1859: } else {
1.180 wenzelju 1860: $message .= '<br /><a href="/adm/whatsnew?refpage='.
1861: $refpage.'">'.$lt{'dasp'}.'</a>';
1.63 raeburn 1862: }
1863: }
1.180 wenzelju 1864: $message = &Apache::lonhtmlcommon::confirm_success($message);
1865: $message = &Apache::loncommon::confirmwrapper($message);
1866: &print_main_menu($r,$message);
1.63 raeburn 1867: }
1868:
1.196.4.20 raeburn 1869: sub author_space_settings {
1870: my $r = shift;
1871: &Apache::lonhtmlcommon::add_breadcrumb(
1872: { href => '/adm/preferences?action=authorsettings',
1873: text => 'Authoring Space Settings'});
1874: my $user = $env{'user.name'};
1875: my $domain = $env{'user.domain'};
1876: my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au','ca','aa']);
1877: if (keys(%author_roles) > 0) {
1878: $r->print(Apache::loncommon::start_page('Authoring Space Settings'));
1879: $r->print(Apache::lonhtmlcommon::breadcrumbs('Authoring Space Settings'));
1880: my %userenv = &Apache::lonnet::get('environment',['nocodemirror']);
1881: my $constchecked='';
1882: if ($env{'environment.nocodemirror'}) {
1883: $constchecked=' checked="checked"';
1884: }
1885: my $text=&mt('By default, CodeMirror an editor with advanced functionality for editing code is activated for authors.');
1886: my $cmoff=&mt('Deactivate CodeMirror. This can improve performance on slow computers and accessibility.');
1887: my $change=&mt('Save');
1888: $r->print(<<ENDSCREEN);
1889: <form name="prefs" action="/adm/preferences" method="post">
1890: <input type="hidden" name="action" value="change_authoring_settings" />
1891: $text<br />
1892: <label><input type="checkbox" name="cmoff"$constchecked />$cmoff</label><br />
1893: <input type="submit" value="$change" />
1894: </form>
1895: ENDSCREEN
1896: }
1897: }
1898:
1899: sub change_authoring_settings {
1900: my $r = shift;
1901: my $user = $env{'user.name'};
1902: my $domain = $env{'user.domain'};
1903: my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au','ca','aa']);
1904: if (keys(%author_roles) > 0) {
1905: my %ausettings=('environment.nocodemirror' => '');
1906: if ($env{'form.cmoff'}) { $ausettings{'environment.nocodemirror'}='yes'; }
1907: &Apache::lonnet::put('environment',\%ausettings);
1908: &Apache::lonnet::appenv({'environment.nocodemirror' => $ausettings{'environment.nocodemirror'}});
1909: my $status='';
1910: if ($ausettings{'environment.nocodemirror'} eq 'yes') {
1911: $status=&mt('on');
1912: } else {
1913: $status=&mt('off');
1914: }
1915: my $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]','<i>'.&mt('Deactivate CodeMirror in Authoring Space').'</i>','<tt>'.$status.'</tt>'));
1916: $message=&Apache::loncommon::confirmwrapper($message);
1917: &print_main_menu($r,$message);
1918: }
1919: }
1920:
1.186 raeburn 1921: sub lockednameschanger {
1922: my $r = shift;
1923: &Apache::lonhtmlcommon::add_breadcrumb(
1924: { href => '/adm/preferences?action=changelockednames',
1925: text => 'Automatic name changes'});
1926: $r->print(Apache::loncommon::start_page('Automatic name changes'));
1927: $r->print(Apache::lonhtmlcommon::breadcrumbs('Allow/disallow name updates'));
1928: my %userenv = &Apache::lonnet::get('environment',['lockedname']);
1929: my $lockedname='';
1930: if (&can_toggle_namelocking()) {
1931: if ($userenv{'lockedname'}) {
1932: $lockedname = ' checked="checked"';
1933: }
1934: my %updateable;
1935: my %domconfig =
1936: &Apache::lonnet::get_dom('configuration',['autoupdate'],$env{'user.domain'});
1937: if (ref($domconfig{'autoupdate'}) eq 'HASH') {
1938: if ($domconfig{'autoupdate'}{'run'}) {
1939: my @inststatuses = split(':',$env{'environment.inststatus'});
1940: unless (@inststatuses) {
1941: @inststatuses = ('default');
1942: }
1943: %updateable = &updateable_userinfo($domconfig{'autoupdate'},\@inststatuses);
1944: }
1945: }
1946: if (keys(%updateable)) {
1947: my %longnames = &Apache::lonlocal::texthash (
1948: firstname => 'First Name',
1949: middlename => 'Middle Name',
1950: lastname => 'Last Name',
1951: );
1952: 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:').
1953: '<ul>';
1954: foreach my $item ('firstname','middlename','lastname') {
1955: if ($updateable{$item}) {
1956: $text .= '<li>'.$longnames{$item}.'</li>';
1957: }
1958: }
1959: $text .= '</ul>';
1960: my $locking=&mt('Disallow automatic updates to name information for your LON-CAPA account');
1961: my $change=&mt('Save');
1962: $r->print(<<ENDSCREEN);
1963: <form name="prefs" action="/adm/preferences" method="post">
1964: <input type="hidden" name="action" value="verify_and_change_lockednames" />
1965: $text<br />
1966: <label><input type="checkbox" value="1" name="lockednames"$lockedname />$locking</label><br />
1967: <input type="submit" value="$change" />
1968: </form>
1969: ENDSCREEN
1970: } else {
1971: my $message = &mt('Based on your institutional affiliation no name information is automatically updated for your LON-CAPA account.');
1972: &print_main_menu($r,$message);
1973: }
1974: } else {
1975: my $message = &mt('You are not permitted to set a user preference for automatic name updates for your LON-CAPA account.');
1976: &print_main_menu($r,$message);
1977: }
1978: }
1979:
1980: sub verify_and_change_lockednames {
1981: my $r = shift;
1982: my $message;
1983: if (&can_toggle_namelocking()) {
1984: my $newlockedname = $env{'form.lockednames'};
1985: $newlockedname =~ s/\D//g;
1986: my $currlockedname = $env{'environment.lockedname'};
1987: if ($newlockedname ne $currlockedname) {
1988: if ($newlockedname) {
1989: if (&Apache::lonnet::put('environment',{lockedname => $newlockedname}) eq 'ok') {
1990: &Apache::lonnet::appenv({'environment.lockedname' => $newlockedname});
1991: }
1992: } elsif (&Apache::lonnet::del('environment',['lockedname']) eq 'ok') {
1993: &Apache::lonnet::delenv('environment.lockedname');
1994: }
1995: }
1996: my $status='';
1997: if ($newlockedname) {
1998: $status=&mt('disallowed');
1999: } else {
2000: $status=&mt('allowed');
2001: }
2002: $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>'));
2003: $message=&Apache::loncommon::confirmwrapper($message);
2004: }
2005: &print_main_menu($r,$message);
2006: }
2007:
1.126 droeschl 2008: sub print_main_menu {
2009: my ($r, $message) = @_;
2010: # Determine current authentication method
2011: my $user = $env{'user.name'};
2012: my $domain = $env{'user.domain'};
2013: my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
2014:
2015: # build the data structure for menu generation
2016: my $aboutmeurl='/adm/'.$env{'user.domain'}.'/'.$env{'user.name'}.'/aboutme';
2017: my $role = ($env{'user.adv'} ? 'Roles' : 'Course');
1.131 raeburn 2018: my %permissions;
2019: if (&Apache::lonnet::usertools_access($user,$domain,'aboutme')) {
2020: $permissions{'aboutme'} = 'F';
2021: }
1.126 droeschl 2022: my @menu=
2023: ({ categorytitle=>'Personal Data',
2024: items =>[
1.141 weissno 2025: { linktext => 'Personal Information Page',
1.126 droeschl 2026: url => $aboutmeurl,
1.131 raeburn 2027: permission => $permissions{'aboutme'},
1.126 droeschl 2028: #help => 'Prefs_About_Me',
2029: icon => 'system-users.png',
2030: linktitle => 'Edit information about yourself that should be displayed on your public profile.'
2031: },
2032: { linktext => 'Screen Name',
2033: url => '/adm/preferences?action=changescreenname',
2034: permission => 'F',
2035: #help => 'Prefs_Screen_Name_Nickname',
2036: icon => 'preferences-desktop-font.png',
2037: linktitle => 'Change the name that is displayed in your posts.'
2038: },
2039: ]
2040: },
2041: { categorytitle=>'Content Display Settings',
2042: items =>[
2043: { linktext => 'Language',
2044: url => '/adm/preferences?action=changelanguages',
2045: permission => 'F',
2046: #help => 'Prefs_Language',
2047: icon => 'preferences-desktop-locale.png',
1.127 droeschl 2048: linktitle => 'Choose the default language for this user.'
1.126 droeschl 2049: },
1.128 droeschl 2050: { linktext => $role.' Page',
1.126 droeschl 2051: url => '/adm/preferences?action=changerolespref',
2052: permission => 'F',
2053: #help => '',
1.189 wenzelju 2054: icon => 'role_hotlist.png',
1.126 droeschl 2055: linktitle => 'Configure the roles hotlist.'
2056: },
1.177 raeburn 2057: { linktext => 'Math display settings',
1.126 droeschl 2058: url => '/adm/preferences?action=changetexenginepref',
2059: permission => 'F',
2060: #help => '',
1.188 wenzelju 2061: icon => 'dismath.png',
1.177 raeburn 2062: linktitle => 'Change how math is displayed.'
1.126 droeschl 2063: },
2064: ]
2065: },
1.185 droeschl 2066: { categorytitle=>'Page Display Settings',
2067: items =>[
2068: { linktext => 'Color Scheme',
2069: url => '/adm/preferences?action=changecolors',
2070: permission => 'F',
2071: #help => 'Change_Colors',
2072: icon => 'preferences-desktop-theme.png',
2073: linktitle => 'Change LON-CAPA default colors.'
2074: },
1.192 raeburn 2075: { linktext => 'Menu Display',
2076: url => '/adm/preferences?action=changeicons',
2077: permission => 'F',
2078: #help => '',
2079: icon => 'preferences-system-windows.png',
2080: linktitle => 'Change whether the menus are displayed with icons or icons and text.'
2081: }
1.185 droeschl 2082: ]
2083: },
1.178 bisitz 2084: { categorytitle=>'Messages & Notifications',
1.128 droeschl 2085: items =>[
1.153 www 2086: { linktext => 'Messages & Notifications',
1.128 droeschl 2087: url => '/adm/preferences?action=changemsgforward',
2088: permission => 'F',
2089: #help => 'Prefs_Messages',
2090: icon => 'mail-reply-all.png',
2091: linktitle => 'Change messageforwarding or notifications settings.'
2092: },
2093: { linktext => 'Discussion Display',
2094: url => '/adm/preferences?action=changediscussions',
2095: permission => 'F',
2096: #help => 'Change_Discussion_Display',
1.191 riegler 2097: icon => 'chat.png',
1.135 schafran 2098: linktitle => 'Set display preferences for discussion posts for both discussion boards and individual resources in all your courses.'
1.128 droeschl 2099: },
2100: ]
2101: },
1.126 droeschl 2102: { categorytitle=>'Other',
2103: items =>[
1.153 www 2104: { linktext => 'Register Response Devices ("Clickers")',
1.126 droeschl 2105: url => '/adm/preferences?action=changeclicker',
2106: permission => 'F',
2107: #help => '',
2108: icon => 'network-workgroup.png',
2109: linktitle => 'Register your clicker.'
2110: },
2111: ]
2112: },
2113: );
2114:
2115: if ($currentauth =~ /^(unix|internal):/) {
2116: push(@{ $menu[0]->{items} }, {
2117: linktext => 'Password',
2118: url => '/adm/preferences?action=changepass',
2119: permission => 'F',
2120: #help => 'Change_Password',
2121: icon => 'emblem-readonly.png',
2122: linktitle => 'Change your password.',
2123: });
2124: }
1.196.4.2 raeburn 2125: if ($env{'environment.remote'} eq 'off') {
2126: push(@{ $menu[1]->{items} }, {
2127: linktext => 'Launch Remote Control',
2128: url => '/adm/remote?url=/adm/preferences&action=launch',
2129: permission => 'F',
2130: #help => '',
2131: icon => 'remotecontrol.png',
2132: linktitle => 'Launch the remote control for LON-CAPA.',
2133: });
2134: }else{
2135: push(@{ $menu[1]->{items} }, {
2136: linktext => 'Collapse Remote Control',
2137: url => '/adm/remote?url=/adm/preferences&action=collapse',
2138: permission => 'F',
2139: #help => '',
2140: icon => 'remotecontrol.png',
2141: linktitle => 'Collapse the remote control for LON-CAPA.',
2142: });
2143: }
1.186 raeburn 2144:
2145: if (&can_toggle_namelocking()) {
2146: push(@{ $menu[0]->{items} }, {
2147: linktext => 'Automatic name changes',
2148: url => '/adm/preferences?action=changelockednames',
2149: permission => 'F',
2150: #help => '',
2151: icon => 'system-lock-screen.png',
2152: linktitle => 'Allow/disallow propagation of name changes from institutional directory service',
2153: });
2154: }
2155:
1.126 droeschl 2156: my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au']);
2157: if (keys(%author_roles) > 0) {
2158: push(@{ $menu[4]->{items} }, {
2159: linktext => 'Restrict Domain Coordinator Access',
2160: url => '/adm/preferences?action=changedomcoord',
2161: permission => 'F',
2162: #help => '',
2163: icon => 'system-lock-screen.png',
2164: linktitle => 'Restrict domain coordinator access.',
2165: });
2166: }
2167:
2168: if (&Apache::lonnet::allowed('whn',$env{'request.course.id'})
2169: || &Apache::lonnet::allowed('whn',$env{'request.course.id'}.'/'
2170: .$env{'request.course.sec'})) {
2171: push(@{ $menu[4]->{items} }, {
1.128 droeschl 2172: linktext => 'Course Initialization',
1.126 droeschl 2173: url => '/adm/preferences?action=changecourseinit',
2174: permission => 'F',
2175: #help => '',
1.189 wenzelju 2176: icon => 'course_ini.png',
1.126 droeschl 2177: linktitle => 'Set the default page to be displayed when you select a course role.',
2178: });
2179:
2180: }
1.196.4.21 raeburn 2181:
2182: my %author_coauthor_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au','ca','aa']);
2183: if (keys(%author_coauthor_roles) > 0) {
2184: push(@{ $menu[4]->{items} }, {
2185: linktext => 'Authoring Space Configuration',
2186: url => '/adm/preferences?action=authorsettings',
2187: permission => 'F',
2188: icon => 'course_ini.png',
2189: linktitle => 'Settings for your authoring space.',
2190: });
2191: }
2192:
1.174 raeburn 2193: if (&can_toggle_debug()) {
1.126 droeschl 2194: push(@{ $menu[4]->{items} }, {
1.174 raeburn 2195: linktext => 'Toggle Debug Messages (Currently '.($env{'user.debug'} ? 'on)' : 'off)'),
1.126 droeschl 2196: url => '/adm/preferences?action=debugtoggle',
2197: permission => 'F',
2198: #help => '',
2199: icon => 'blog.png',
2200: linktitle => 'Toggle Debug Messages.',
2201: });
1.186 raeburn 2202: }
1.126 droeschl 2203:
1.147 schafran 2204: $r->print(&Apache::loncommon::start_page('My Space'));
1.126 droeschl 2205: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Preferences'));
2206: $r->print($message);
2207: $r->print(Apache::lonhtmlcommon::generate_menu(@menu));
2208: $r->print(Apache::loncommon::end_page());
2209: }
1.63 raeburn 2210:
1.4 matthew 2211: ######################################################
2212: # other handler subroutines #
2213: ######################################################
2214:
1.3 matthew 2215: ################################################################
2216: # Main handler #
2217: ################################################################
1.126 droeschl 2218: sub handler {
2219: my $r = shift;
2220: Apache::loncommon::content_type($r,'text/html');
2221: # Some pages contain DES keys and should not be cached.
2222: Apache::loncommon::no_cache($r);
2223: $r->send_http_header;
2224: return OK if $r->header_only;
2225: #
2226: Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
2227: ['action','wysiwyg','returnurl','refpage']);
2228: #
2229: Apache::lonhtmlcommon::clear_breadcrumbs();
1.196.4.5 raeburn 2230: my ($brlink,$brtxt,$brhelp);
2231: if (($env{'form.action'} eq 'changerolespref') && ($env{'form.returnurl'} eq '/adm/roles')) {
2232: $brlink ='/adm/roles';
2233: $brtxt = 'User Roles';
2234: } else {
2235: $brlink ='/adm/preferences';
2236: $brtxt = 'Set User Preferences';
2237: $brhelp = 'Prefs_About_Me,Prefs_Language,Prefs_Screen_Name_Nickname,Change_Colors,Change_Password,Prefs_Messages,Change_Discussion_Display';
2238: }
1.126 droeschl 2239: Apache::lonhtmlcommon::add_breadcrumb
1.196.4.5 raeburn 2240: ({href => $brlink,
2241: text => $brtxt,
2242: help => $brhelp,});
1.126 droeschl 2243: if(!exists $env{'form.action'}) {
1.150 droeschl 2244: &print_main_menu($r);
1.126 droeschl 2245: }elsif($env{'form.action'} eq 'changepass'){
2246: &passwordchanger($r);
2247: }elsif($env{'form.action'} eq 'verify_and_change_pass'){
1.196.4.19 raeburn 2248: &verify_and_change_password($r,'preferences');
1.126 droeschl 2249: }elsif($env{'form.action'} eq 'changescreenname'){
2250: &screennamechanger($r);
2251: }elsif($env{'form.action'} eq 'verify_and_change_screenname'){
2252: &verify_and_change_screenname($r);
2253: }elsif($env{'form.action'} eq 'changemsgforward'){
2254: &msgforwardchanger($r);
2255: }elsif($env{'form.action'} eq 'verify_and_change_msgforward'){
2256: &verify_and_change_msgforward($r);
2257: }elsif($env{'form.action'} eq 'changecolors'){
2258: &colorschanger($r);
2259: }elsif($env{'form.action'} eq 'verify_and_change_colors'){
2260: &verify_and_change_colors($r);
2261: }elsif($env{'form.action'} eq 'changelanguages'){
2262: &languagechanger($r);
2263: }elsif($env{'form.action'} eq 'verify_and_change_languages'){
2264: &verify_and_change_languages($r);
2265: }elsif($env{'form.action'} eq 'changewysiwyg'){
2266: &wysiwygchanger($r);
2267: }elsif($env{'form.action'} eq 'set_wysiwyg'){
2268: &verify_and_change_wysiwyg($r);
2269: }elsif($env{'form.action'} eq 'changediscussions'){
2270: &discussionchanger($r);
2271: }elsif($env{'form.action'} eq 'verify_and_change_discussion'){
2272: &verify_and_change_discussion($r);
2273: }elsif($env{'form.action'} eq 'changerolespref'){
2274: &rolesprefchanger($r);
2275: }elsif($env{'form.action'} eq 'verify_and_change_rolespref'){
2276: &verify_and_change_rolespref($r);
2277: }elsif($env{'form.action'} eq 'changetexenginepref'){
2278: &texenginechanger($r);
2279: }elsif($env{'form.action'} eq 'verify_and_change_texengine'){
2280: &verify_and_change_texengine($r);
1.192 raeburn 2281: }elsif($env{'form.action'} eq 'changeicons'){
2282: &iconchanger($r);
2283: }elsif($env{'form.action'} eq 'verify_and_change_icons'){
2284: &verify_and_change_icons($r);
1.126 droeschl 2285: }elsif($env{'form.action'} eq 'changeclicker'){
2286: &clickerchanger($r);
2287: }elsif($env{'form.action'} eq 'verify_and_change_clicker'){
2288: &verify_and_change_clicker($r);
2289: }elsif($env{'form.action'} eq 'changedomcoord'){
2290: &domcoordchanger($r);
2291: }elsif($env{'form.action'} eq 'verify_and_change_domcoord'){
2292: &verify_and_change_domcoord($r);
2293: }elsif($env{'form.action'} eq 'lockwarning'){
2294: &lockwarning($r);
2295: }elsif($env{'form.action'} eq 'verify_and_change_locks'){
2296: &verify_and_change_lockwarning($r);
2297: }elsif($env{'form.action'} eq 'changecourseinit'){
2298: &coursedisplaychanger($r);
2299: }elsif($env{'form.action'} eq 'verify_and_change_coursepage'){
2300: &verify_and_change_coursepage($r);
1.196.4.20 raeburn 2301: }elsif($env{'form.action'} eq 'authorsettings'){
2302: &author_space_settings($r);
2303: }elsif($env{'form.action'} eq 'change_authoring_settings'){
2304: &change_authoring_settings($r);
1.126 droeschl 2305: }elsif($env{'form.action'} eq 'debugtoggle'){
1.174 raeburn 2306: if (&can_toggle_debug()) {
2307: &toggle_debug();
2308: }
1.154 www 2309: &print_main_menu($r);
1.186 raeburn 2310: } elsif ($env{'form.action'} eq 'changelockednames') {
2311: &lockednameschanger($r);
2312: } elsif ($env{'form.action'} eq 'verify_and_change_lockednames') {
2313: &verify_and_change_lockednames($r);
1.126 droeschl 2314: }
2315:
1.165 bisitz 2316: # Properly end the HTML page of all preference pages
2317: # started in each sub routine
2318: # Exception: print_main_menu has its own end_page call
2319: unless (!exists $env{'form.action'} ||
2320: $env{'form.action'} eq 'debugtoggle') {
2321: $r->print(&Apache::loncommon::end_page());
2322: }
2323:
1.126 droeschl 2324: return OK;
1.35 matthew 2325: }
2326:
2327: sub toggle_debug {
1.59 albertel 2328: if ($env{'user.debug'}) {
1.139 raeburn 2329: &Apache::lonnet::delenv('user.debug');
1.35 matthew 2330: } else {
1.116 raeburn 2331: &Apache::lonnet::appenv({'user.debug' => 1});
1.35 matthew 2332: }
1.13 www 2333: }
1.1 www 2334:
1.174 raeburn 2335: sub can_toggle_debug {
2336: my $can_toggle = 0;
2337: my $page = 'toggledebug';
2338: if (&LONCAPA::lonauthcgi::can_view($page)) {
2339: $can_toggle = 1;
2340: } elsif (&LONCAPA::lonauthcgi::check_ipbased_access($page)) {
2341: $can_toggle = 1;
2342: }
2343: return $can_toggle;
2344: }
2345:
1.186 raeburn 2346: sub can_toggle_namelocking {
2347: my $lockablenames;
2348: my %domconfig =
2349: &Apache::lonnet::get_dom('configuration',['autoupdate'],$env{'user.domain'});
2350: if (ref($domconfig{'autoupdate'}) eq 'HASH') {
2351: if ($domconfig{'autoupdate'}{'run'}) {
2352: my @inststatuses = split(':',$env{'environment.inststatus'});
2353: unless (@inststatuses) {
2354: @inststatuses = ('default');
2355: }
2356: my %updateable = &updateable_userinfo($domconfig{'autoupdate'},\@inststatuses);
2357: if ($updateable{'lastname'} || $updateable{'firstname'} ||
2358: $updateable{'middlename'}) {
2359: if (ref($domconfig{'autoupdate'}{'lockablenames'}) eq 'ARRAY') {
2360: unless (@inststatuses) {
2361: @inststatuses = ('default');
2362: }
2363: foreach my $status (@inststatuses) {
2364: if (grep(/^\Q$status\E$/,@{$domconfig{'autoupdate'}{'lockablenames'}})) {
2365: $lockablenames = 1;
2366: last;
2367: }
2368: }
2369: }
2370: }
2371: }
2372: }
2373: return $lockablenames;
2374: }
2375:
2376: sub updateable_userinfo {
2377: my ($autoupdate,$inststatuses) = @_;
2378: my %updateable;
2379: return %updateable unless ((ref($autoupdate) eq 'HASH') &&
2380: (ref($inststatuses) eq 'ARRAY'));
2381: if (ref($autoupdate->{'fields'}) eq 'HASH') {
2382: foreach my $status (@{$inststatuses}) {
2383: if (ref($autoupdate->{'fields'}{$status}) eq 'ARRAY') {
2384: foreach my $field (@{$autoupdate->{'fields'}{$status}}) {
2385: $updateable{$field} = 1;
2386: }
2387: }
2388: }
2389: }
2390: return %updateable;
2391: }
2392:
1.1 www 2393: 1;
2394: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>