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