Annotation of loncom/interface/loncreateuser.pm, revision 1.114
1.20 harris41 1: # The LearningOnline Network with CAPA
1.1 www 2: # Create a user
3: #
1.114 ! albertel 4: # $Id: loncreateuser.pm,v 1.113 2006/05/08 21:40:20 raeburn Exp $
1.22 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.20 harris41 28: ###
29:
1.1 www 30: package Apache::loncreateuser;
1.66 bowersj2 31:
32: =pod
33:
34: =head1 NAME
35:
36: Apache::loncreateuser - handler to create users and custom roles
37:
38: =head1 SYNOPSIS
39:
40: Apache::loncreateuser provides an Apache handler for creating users,
41: editing their login parameters, roles, and removing roles, and
42: also creating and assigning custom roles.
43:
44: =head1 OVERVIEW
45:
46: =head2 Custom Roles
47:
48: In LON-CAPA, roles are actually collections of privileges. "Teaching
49: Assistant", "Course Coordinator", and other such roles are really just
50: collection of privileges that are useful in many circumstances.
51:
52: Creating custom roles can be done by the Domain Coordinator through
53: the Create User functionality. That screen will show all privileges
54: that can be assigned to users. For a complete list of privileges,
55: please see C</home/httpd/lonTabs/rolesplain.tab>.
56:
57: Custom role definitions are stored in the C<roles.db> file of the role
58: author.
59:
60: =cut
1.1 www 61:
62: use strict;
63: use Apache::Constants qw(:common :http);
64: use Apache::lonnet;
1.54 bowersj2 65: use Apache::loncommon;
1.68 www 66: use Apache::lonlocal;
1.1 www 67:
1.20 harris41 68: my $loginscript; # piece of javascript used in two separate instances
69: my $generalrule;
70: my $authformnop;
71: my $authformkrb;
72: my $authformint;
73: my $authformfsys;
74: my $authformloc;
75:
1.94 matthew 76: sub initialize_authen_forms {
77: my ($krbdefdom)=( $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/);
78: $krbdefdom= uc($krbdefdom);
1.31 matthew 79: my %param = ( formname => 'document.cu',
80: kerb_def_dom => $krbdefdom
81: );
1.48 albertel 82: # no longer static due to configurable kerberos defaults
83: # $loginscript = &Apache::loncommon::authform_header(%param);
1.31 matthew 84: $generalrule = &Apache::loncommon::authform_authorwarning(%param);
85: $authformnop = &Apache::loncommon::authform_nochange(%param);
1.48 albertel 86: # no longer static due to configurable kerberos defaults
87: # $authformkrb = &Apache::loncommon::authform_kerberos(%param);
1.31 matthew 88: $authformint = &Apache::loncommon::authform_internal(%param);
89: $authformfsys = &Apache::loncommon::authform_filesystem(%param);
90: $authformloc = &Apache::loncommon::authform_local(%param);
1.20 harris41 91: }
92:
1.43 www 93:
1.59 www 94: # ======================================================= Existing Custom Roles
95:
96: sub my_custom_roles {
97: my %returnhash=();
98: my %rolehash=&Apache::lonnet::dump('roles');
99: foreach (keys %rolehash) {
100: if ($_=~/^rolesdef\_(\w+)$/) {
1.61 www 101: $returnhash{$1}=$1;
1.59 www 102: }
103: }
104: return %returnhash;
105: }
1.43 www 106:
107: # ==================================================== Figure out author access
108:
109: sub authorpriv {
110: my ($auname,$audom)=@_;
1.105 www 111: unless ((&Apache::lonnet::allowed('cca',$audom.'/'.$auname))
112: || (&Apache::lonnet::allowed('caa',$audom.'/'.$auname))) { return ''; }
1.43 www 113: return 1;
114: }
115:
1.2 www 116: # =================================================================== Phase one
1.1 www 117:
1.42 matthew 118: sub print_username_entry_form {
1.110 albertel 119: my ($r) = @_;
1.101 albertel 120: my $defdom=$env{'request.role.domain'};
1.33 matthew 121: my @domains = &Apache::loncommon::get_domains();
122: my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
1.46 www 123: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1.110 albertel 124: my $start_page =
125: &Apache::loncommon::start_page('Create Users, Change User Privileges',
126: $selscript);
127:
1.46 www 128: my $sellink=&Apache::loncommon::selectstudent_link
129: ('crtuser','ccuname','ccdomain');
1.59 www 130: my %existingroles=&my_custom_roles();
131: my $choice=&Apache::loncommon::select_form('make new role','rolename',
132: ('make new role' => 'Generate new role ...',%existingroles));
1.71 sakharuk 133: my %lt=&Apache::lonlocal::texthash(
134: 'siur' => "Set Individual User Roles",
135: 'usr' => "Username",
136: 'dom' => "Domain",
137: 'usrr' => "User Roles",
138: 'ecrp' => "Edit Custom Role Privileges",
1.72 sakharuk 139: 'nr' => "Name of Role",
1.71 sakharuk 140: 'cre' => "Custom Role Editor"
141: );
1.110 albertel 142: my $help = &Apache::loncommon::help_open_menu('',undef,undef,'',282,'Instructor Interface');
1.76 www 143: my $helpsiur=&Apache::loncommon::help_open_topic('Course_Change_Privileges');
144: my $helpecpr=&Apache::loncommon::help_open_topic('Course_Editing_Custom_Roles');
1.33 matthew 145: $r->print(<<"ENDDOCUMENT");
1.111 albertel 146: $start_page
1.46 www 147: <form action="/adm/createuser" method="post" name="crtuser">
1.42 matthew 148: <input type="hidden" name="phase" value="get_user_info">
1.76 www 149: <h2>$lt{siur}$helpsiur</h2>
1.43 www 150: <table>
1.71 sakharuk 151: <tr><td>$lt{usr}:</td><td><input type="text" size="15" name="ccuname">
1.46 www 152: </td><td rowspan="2">$sellink</td></tr><tr><td>
1.71 sakharuk 153: $lt{'dom'}:</td><td>$domform</td></tr>
1.58 www 154: </table>
1.71 sakharuk 155: <input name="userrole" type="submit" value="$lt{usrr}" />
1.2 www 156: </form>
1.106 www 157: ENDDOCUMENT
158: if (&Apache::lonnet::allowed('mcr','/')) {
159: $r->print(<<ENDCUSTOM);
1.58 www 160: <form action="/adm/createuser" method="post" name="docustom">
161: <input type="hidden" name="phase" value="selected_custom_edit">
1.76 www 162: <h2>$lt{'ecrp'}$helpecpr</h2>
1.72 sakharuk 163: $lt{'nr'}: $choice <input type="text" size="15" name="newrolename" /><br />
1.71 sakharuk 164: <input name="customeditor" type="submit" value="$lt{'cre'}" />
1.107 www 165: </form>
1.106 www 166: ENDCUSTOM
1.107 www 167: }
1.110 albertel 168: $r->print(&Apache::loncommon::end_page());
169: }
170:
171:
172: sub user_modification_js {
1.113 raeburn 173: my ($pjump_def,$dc_setcourse_code,$nondc_setsection_code,$groupslist)=@_;
174:
1.110 albertel 175: return <<END;
176: <script type="text/javascript" language="Javascript">
177:
178: function pclose() {
179: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
180: "height=350,width=350,scrollbars=no,menubar=no");
181: parmwin.close();
182: }
183:
184: $pjump_def
185: $dc_setcourse_code
186:
187: function dateset() {
188: eval("document.cu."+document.cu.pres_marker.value+
189: ".value=document.cu.pres_value.value");
190: pclose();
191: }
192:
1.113 raeburn 193: $nondc_setsection_code
194:
1.110 albertel 195: function setSections() {
196: var re1 = /^currsec_/;
1.113 raeburn 197: var groups = new Array($groupslist);
1.110 albertel 198: for (var i=0;i<document.cu.elements.length;i++) {
199: var str = document.cu.elements[i].name;
200: var checkcurr = str.match(re1);
201: if (checkcurr != null) {
202: var re2 = /^currsec_[a-zA-Z0-9]+_[a-zA-Z0-9]+_(\\w+)\$/;
203: if (document.cu.elements[i-1].checked == true) {
204: var re2 = /^currsec_[a-zA-Z0-9]+_[a-zA-Z0-9]+_(\\w+)\$/;
205: match = re2.exec(str);
206: var role = match[1];
207: if (role == 'cc') {
208: alert("Section designations do not apply to Course Coordinator roles.\\nA course coordinator role will be added with access to all sections.");
209: }
210: else {
211: var sections = '';
212: var numsec = 0;
213: var sections;
214: for (var j=0; j<document.cu.elements[i].length; j++) {
215: if (document.cu.elements[i].options[j].selected == true ) {
216: if (document.cu.elements[i].options[j].value != "") {
217: if (numsec == 0) {
218: if (document.cu.elements[i].options[j].value != "") {
219: sections = document.cu.elements[i].options[j].value;
220: numsec ++;
221: }
222: }
223: else {
224: sections = sections + "," + document.cu.elements[i].options[j].value
225: numsec ++;
226: }
227: }
228: }
229: }
230: if (numsec > 0) {
231: if (document.cu.elements[i+1].value != "" && document.cu.elements[i+1].value != null) {
232: sections = sections + "," + document.cu.elements[i+1].value;
1.113 raeburn 233: }
1.110 albertel 234: }
235: else {
236: sections = document.cu.elements[i+1].value;
237: }
238: var newsecs = document.cu.elements[i+1].value;
239: if (newsecs != null && newsecs != "") {
240: var numsplit = newsecs.split(/,/g);
241: numsec = numsec + numsplit.length;
242: }
243: if ((role == 'st') && (numsec > 1)) {
244: alert("In each course, each user may only have one student role at a time. You had selected "+numsec+" sections.\\nPlease modify your selections so they include no more than one section.")
245: return;
246: }
1.113 raeburn 247: else {
248: for (var j=0; j<numsplit.length; j++) {
249: if ((numsplit[j] == 'all') ||
250: (numsplit[j] == 'none')) {
251: alert("'"+numsplit[j]+"' may not be used as the name for a section, as it is a reserved word.\\nPlease choose a different section name.");
252: return;
253: }
254: for (var k=0; k<groups.length; k++) {
255: if (numsplit[j] == groups[k]) {
256: alert("'"+numsplit[j]+"' may not be used as a section name, as it is the name of a course group.\\nSection names and group names must be distinct. Please choose a different section name.");
257: return;
258: }
259: }
260: }
1.110 albertel 261: document.cu.elements[i+2].value = sections;
262: }
263: }
264: }
265: }
266: }
267: document.cu.submit();
268: }
269: </script>
270: END
1.2 www 271: }
272:
273: # =================================================================== Phase two
1.42 matthew 274: sub print_user_modification_page {
1.2 www 275: my $r=shift;
1.101 albertel 276: my $ccuname=$env{'form.ccuname'};
277: my $ccdomain=$env{'form.ccdomain'};
1.4 www 278:
1.98 albertel 279: $ccuname=~s/\W//g;
280: $ccdomain=~s/\W//g;
1.58 www 281:
282: unless (($ccuname) && ($ccdomain)) {
283: &print_username_entry_form($r);
284: return;
285: }
286:
1.101 albertel 287: my $defdom=$env{'request.role.domain'};
1.48 albertel 288:
289: my ($krbdef,$krbdefdom) =
290: &Apache::loncommon::get_kerberos_defaults($defdom);
291:
1.31 matthew 292: my %param = ( formname => 'document.cu',
1.48 albertel 293: kerb_def_dom => $krbdefdom,
294: kerb_def_auth => $krbdef
1.31 matthew 295: );
296: $loginscript = &Apache::loncommon::authform_header(%param);
1.48 albertel 297: $authformkrb = &Apache::loncommon::authform_kerberos(%param);
1.4 www 298:
1.2 www 299: $ccuname=~s/\W//g;
300: $ccdomain=~s/\W//g;
1.52 matthew 301: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.88 raeburn 302: my $dc_setcourse_code = '';
1.113 raeburn 303: my $nondc_setsection_code = '';
1.112 albertel 304: my %loaditem;
1.114 ! albertel 305:
! 306: my $groupslist;
! 307: my %curr_groups = &Apache::loncommon::coursegroups();
! 308: if (%curr_groups) {
1.113 raeburn 309: $groupslist = join('","',sort(keys(%curr_groups)));
310: $groupslist = '"'.$groupslist.'"';
311: }
1.114 ! albertel 312:
1.101 albertel 313: if ($env{'request.role'} =~ m-^dc\./(\w+)/$-) {
1.88 raeburn 314: my $dcdom = $1;
1.112 albertel 315: $loaditem{'onload'} = "document.cu.coursedesc.value=''";
1.88 raeburn 316: $dc_setcourse_code = <<"ENDSCRIPT";
317: function setCourse() {
318: var course = document.cu.dccourse.value;
319: if (course != "") {
320: if (document.cu.dcdomain.value != document.cu.origdom.value) {
321: alert("You must select a course in the current domain");
322: return;
323: }
324: var userrole = document.cu.role.options[document.cu.role.selectedIndex].value
1.91 raeburn 325: var section="";
1.88 raeburn 326: var numsections = 0;
1.89 raeburn 327: for (var i=0; i<document.cu.currsec.length; i++) {
328: if (document.cu.currsec.options[i].selected == true ) {
329: if (document.cu.currsec.options[i].value != "" && document.cu.currsec.options[i].value != null) {
330: if (numsections == 0) {
331: section = document.cu.currsec.options[i].value
332: numsections = 1;
333: }
334: else {
335: section = section + "," + document.cu.currsec.options[i].value
336: numsections ++;
1.88 raeburn 337: }
338: }
339: }
1.89 raeburn 340: }
341: if (document.cu.newsec.value != "" && document.cu.newsec.value != null) {
342: if (numsections == 0) {
343: section = document.cu.newsec.value
344: }
345: else {
346: section = section + "," + document.cu.newsec.value
1.88 raeburn 347: }
1.89 raeburn 348: var numsplit = document.cu.newsec.value.split(/,/g);
349: numsections = numsections + numsplit.length;
350: }
351: if ((userrole == 'st') && (numsections > 1)) {
352: alert("In each course, each user may only have one student role at a time. You had selected "+numsections+" sections.\\nPlease modify your selections so they include no more than one section.")
353: return;
354: }
1.113 raeburn 355: for (var j=0; j<numsplit.length; j++) {
356: if ((numsplit[j] == 'all') || (numsplit[j] == 'none')) {
357: alert("'"+numsplit[j]+"' may not be used as the name for a section, as it is a reserved word.\\nPlease choose a different section name.");
358: return;
359: }
360: if (document.cu.groups.value != '') {
361: var groups = document.cu.groups.value.split(/,/g);
362: for (var k=0; k<groups.length; k++) {
363: if (numsplit[j] == groups[k]) {
364: alert("'"+numsplit[j]+"' may not be used as the name for a section, as it is the name of a course group.\\nSection names and group names must be distinct. Please choose a different section name.");
365: return;
366: }
367: }
368: }
369: }
1.89 raeburn 370: if ((userrole == 'cc') && (numsections > 0)) {
371: alert("Section designations do not apply to Course Coordinator roles.\\nA course coordinator role will be added with access to all sections.");
372: section = "";
1.88 raeburn 373: }
374: var numcourse = getIndex(document.cu.dccourse);
375: if (numcourse == "-1") {
376: alert("There was a problem with your course selection");
377: return
378: }
379: else {
380: var coursename = "_$dcdom"+"_"+course+"_"+userrole
381: document.cu.elements[numcourse].name = "act"+coursename
382: document.cu.elements[numcourse+4].name = "sec"+coursename
383: document.cu.elements[numcourse+4].value = section
384: document.cu.elements[numcourse+5].name = "start"+coursename
385: document.cu.elements[numcourse+6].name = "end"+coursename
386: }
387: }
388: document.cu.submit();
389: }
390:
391: function getIndex(caller) {
392: for (var i=0;i<document.cu.elements.length;i++) {
393: if (document.cu.elements[i] == caller) {
394: return i;
395: }
396: }
397: return -1;
398: }
399: ENDSCRIPT
1.113 raeburn 400: } else {
401: $nondc_setsection_code = <<"ENDSECCODE";
402: function setSections() {
403: var re1 = /^currsec_/;
404: var groups = new Array($groupslist);
405: for (var i=0;i<document.cu.elements.length;i++) {
406: var str = document.cu.elements[i].name;
407: var checkcurr = str.match(re1);
408: if (checkcurr != null) {
409: var re2 = /^currsec_[a-zA-Z0-9]+_[a-zA-Z0-9]+_(\\w+)\$/;
410: if (document.cu.elements[i-1].checked == true) {
411: var re2 = /^currsec_[a-zA-Z0-9]+_[a-zA-Z0-9]+_(\\w+)\$/;
412: match = re2.exec(str);
413: var role = match[1];
414: if (role == 'cc') {
415: alert("Section designations do not apply to Course Coordinator roles.\\nA course coordinator role will be added with access to all sections.");
416: }
417: else {
418: var sections = '';
419: var numsec = 0;
420: var sections;
421: for (var j=0; j<document.cu.elements[i].length; j++) {
422: if (document.cu.elements[i].options[j].selected == true ) {
423: if (document.cu.elements[i].options[j].value != "") {
424: if (numsec == 0) {
425: if (document.cu.elements[i].options[j].value != "") {
426: sections = document.cu.elements[i].options[j].value;
427: numsec ++;
428: }
429: }
430: else {
431: sections = sections + "," + document.cu.elements[i].options[j].value
432: numsec ++;
433: }
434: }
435: }
436: }
437: if (numsec > 0) {
438: if (document.cu.elements[i+1].value != "" && document.cu.elements[i+1].value != null) {
439: sections = sections + "," + document.cu.elements[i+1].value;
440: }
441: }
442: else {
443: sections = document.cu.elements[i+1].value;
444: }
445: var newsecs = document.cu.elements[i+1].value;
446: if (newsecs != null && newsecs != "") {
447: var numsplit = newsecs.split(/,/g);
448: numsec = numsec + numsplit.length;
449: }
450: if ((role == 'st') && (numsec > 1)) {
451: alert("In each course, each user may only have one student role at a time. You had selected "+numsec+" sections.\\nPlease modify your selections so they include no more than one section.")
452: return;
453: }
454: else {
455: for (var j=0; j<numsplit.length; j++) {
456: if ((numsplit[j] == 'all') ||
457: (numsplit[j] == 'none')) {
458: alert("'"+numsplit[j]+"' may not be used as the name for a section, as it is a reserved word.\\nPlease choose a different section name.");
459: return;
460: }
461: for (var k=0; k<groups.length; k++) {
462: if (numsplit[j] == groups[k]) {
463: alert("'"+numsplit[j]+"' may not be used as a section name, as it is the name of a course group.\\nSection names and group names must be distinct. Please choose a different section name.");
464: return;
465: }
466: }
467: }
468: document.cu.elements[i+2].value = sections;
469: }
470: }
471: }
472: }
473: }
474: document.cu.submit();
475: }
476: ENDSECCODE
1.88 raeburn 477: }
1.113 raeburn 478: my $js = &user_modification_js($pjump_def,$dc_setcourse_code,
479: $nondc_setsection_code,$groupslist);
1.110 albertel 480: my $start_page =
481: &Apache::loncommon::start_page('Create Users, Change User Privileges',
1.112 albertel 482: $js,{'add_entries' => \%loaditem,});
1.3 www 483:
1.25 matthew 484: my $forminfo =<<"ENDFORMINFO";
485: <form action="/adm/createuser" method="post" name="cu">
1.42 matthew 486: <input type="hidden" name="phase" value="update_user_data">
1.25 matthew 487: <input type="hidden" name="ccuname" value="$ccuname">
488: <input type="hidden" name="ccdomain" value="$ccdomain">
489: <input type="hidden" name="pres_value" value="" >
490: <input type="hidden" name="pres_type" value="" >
491: <input type="hidden" name="pres_marker" value="" >
492: ENDFORMINFO
1.2 www 493: my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
494: my %incdomains;
495: my %inccourses;
1.49 albertel 496: foreach (values(%Apache::lonnet::hostdom)) {
1.13 www 497: $incdomains{$_}=1;
1.24 matthew 498: }
1.101 albertel 499: foreach (keys(%env)) {
1.2 www 500: if ($_=~/^user\.priv\.cm\.\/(\w+)\/(\w+)/) {
501: $inccourses{$1.'_'.$2}=1;
502: }
1.24 matthew 503: }
1.2 www 504: if ($uhome eq 'no_host') {
1.29 matthew 505: my $home_server_list=
1.32 matthew 506: '<option value="default" selected>default</option>'."\n".
507: &Apache::loncommon::home_server_option_list($ccdomain);
508:
1.79 albertel 509: my %lt=&Apache::lonlocal::texthash(
1.72 sakharuk 510: 'cnu' => "Create New User",
511: 'nu' => "New User",
512: 'id' => "in domain",
513: 'pd' => "Personal Data",
514: 'fn' => "First Name",
515: 'mn' => "Middle Name",
516: 'ln' => "Last Name",
517: 'gen' => "Generation",
518: 'idsn' => "ID/Student Number",
519: 'hs' => "Home Server",
520: 'lg' => "Login Data"
521: );
1.78 www 522: my $genhelp=&Apache::loncommon::help_open_topic('Generation');
1.94 matthew 523: &initialize_authen_forms();
1.26 matthew 524: $r->print(<<ENDNEWUSER);
1.110 albertel 525: $start_page
1.72 sakharuk 526: <h1>$lt{'cnu'}</h1>
1.25 matthew 527: $forminfo
1.72 sakharuk 528: <h2>$lt{'nu'} "$ccuname" $lt{'id'} $ccdomain</h2>
1.31 matthew 529: <script type="text/javascript" language="Javascript">
1.20 harris41 530: $loginscript
1.31 matthew 531: </script>
1.20 harris41 532: <input type='hidden' name='makeuser' value='1' />
1.72 sakharuk 533: <h3>$lt{'pd'}</h3>
1.25 matthew 534: <p>
535: <table>
1.72 sakharuk 536: <tr><td>$lt{'fn'} </td>
1.25 matthew 537: <td><input type='text' name='cfirst' size='15' /></td></tr>
1.72 sakharuk 538: <tr><td>$lt{'mn'} </td>
1.25 matthew 539: <td><input type='text' name='cmiddle' size='15' /></td></tr>
1.72 sakharuk 540: <tr><td>$lt{'ln'} </td>
1.25 matthew 541: <td><input type='text' name='clast' size='15' /></td></tr>
1.78 www 542: <tr><td>$lt{'gen'}$genhelp</td>
1.25 matthew 543: <td><input type='text' name='cgen' size='5' /></td></tr>
544: </table>
1.72 sakharuk 545: $lt{'idsn'} <input type='text' name='cstid' size='15' /></p>
1.74 sakharuk 546: $lt{'hs'}: <select name="hserver" size="1"> $home_server_list </select>
1.25 matthew 547: <hr />
1.72 sakharuk 548: <h3>$lt{'lg'}</h3>
1.31 matthew 549: <p>$generalrule </p>
550: <p>$authformkrb </p>
551: <p>$authformint </p>
552: <p>$authformfsys</p>
553: <p>$authformloc </p>
1.26 matthew 554: ENDNEWUSER
1.25 matthew 555: } else { # user already exists
1.79 albertel 556: my %lt=&Apache::lonlocal::texthash(
1.72 sakharuk 557: 'cup' => "Change User Privileges",
558: 'usr' => "User",
559: 'id' => "in domain",
560: 'fn' => "first name",
561: 'mn' => "middle name",
562: 'ln' => "last name",
563: 'gen' => "generation"
564: );
1.26 matthew 565: $r->print(<<ENDCHANGEUSER);
1.110 albertel 566: $start_page
1.72 sakharuk 567: <h1>$lt{'cup'}</h1>
1.25 matthew 568: $forminfo
1.72 sakharuk 569: <h2>$lt{'usr'} "$ccuname" $lt{'id'} "$ccdomain"</h2>
1.26 matthew 570: ENDCHANGEUSER
1.28 matthew 571: # Get the users information
572: my %userenv = &Apache::lonnet::get('environment',
573: ['firstname','middlename','lastname','generation'],
574: $ccdomain,$ccuname);
575: my %rolesdump=&Apache::lonnet::dump('roles',$ccdomain,$ccuname);
576: $r->print(<<END);
577: <hr />
578: <table border="2">
579: <tr>
1.72 sakharuk 580: <th>$lt{'fn'}</th><th>$lt{'mn'}</th><th>$lt{'ln'}</th><th>$lt{'gen'}</th>
1.28 matthew 581: </tr>
582: <tr>
583: END
584: foreach ('firstname','middlename','lastname','generation') {
585: if (&Apache::lonnet::allowed('mau',$ccdomain)) {
586: $r->print(<<"END");
1.53 www 587: <td><input type="text" name="c$_" value="$userenv{$_}" size="15" /></td>
1.28 matthew 588: END
589: } else {
590: $r->print('<td>'.$userenv{$_}.'</td>');
591: }
592: }
1.72 sakharuk 593: $r->print(<<END);
1.28 matthew 594: </tr>
595: </table>
596: END
1.25 matthew 597: # Build up table of user roles to allow revocation of a role.
1.28 matthew 598: my ($tmp) = keys(%rolesdump);
599: unless ($tmp =~ /^(con_lost|error)/i) {
1.2 www 600: my $now=time;
1.72 sakharuk 601: my %lt=&Apache::lonlocal::texthash(
602: 'rer' => "Revoke Existing Roles",
603: 'rev' => "Revoke",
604: 'del' => "Delete",
1.81 albertel 605: 'ren' => "Re-Enable",
1.72 sakharuk 606: 'rol' => "Role",
607: 'ext' => "Extent",
608: 'sta' => "Start",
609: 'end' => "End"
610: );
1.89 raeburn 611: my (%roletext,%sortrole,%roleclass,%rolepriv);
1.67 albertel 612: foreach my $area (sort { my $a1=join('_',(split('_',$a))[1,0]);
613: my $b1=join('_',(split('_',$b))[1,0]);
614: return $a1 cmp $b1;
615: } keys(%rolesdump)) {
1.37 matthew 616: next if ($area =~ /^rolesdef/);
1.79 albertel 617: my $envkey=$area;
1.37 matthew 618: my $role = $rolesdump{$area};
619: my $thisrole=$area;
620: $area =~ s/\_\w\w$//;
621: my ($role_code,$role_end_time,$role_start_time) =
622: split(/_/,$role);
1.64 www 623: # Is this a custom role? Get role owner and title.
624: my ($croleudom,$croleuname,$croletitle)=
625: ($role_code=~/^cr\/(\w+)\/(\w+)\/(\w+)$/);
1.37 matthew 626: my $bgcol='ffffff';
627: my $allowed=0;
1.53 www 628: my $delallowed=0;
1.79 albertel 629: my $sortkey=$role_code;
630: my $class='Unknown';
1.37 matthew 631: if ($area =~ /^\/(\w+)\/(\d\w+)/ ) {
1.79 albertel 632: $class='Course';
1.57 matthew 633: my ($coursedom,$coursedir) = ($1,$2);
1.79 albertel 634: $sortkey.="\0$1";
1.57 matthew 635: # $1.'_'.$2 is the course id (eg. 103_12345abcef103l3).
1.37 matthew 636: my %coursedata=
637: &Apache::lonnet::coursedescription($1.'_'.$2);
1.51 albertel 638: my $carea;
639: if (defined($coursedata{'description'})) {
1.79 albertel 640: $carea=$coursedata{'description'}.
1.72 sakharuk 641: '<br />'.&mt('Domain').': '.$coursedom.(' 'x8).
1.57 matthew 642: &Apache::loncommon::syllabuswrapper('Syllabus',$coursedir,$coursedom);
1.79 albertel 643: $sortkey.="\0".$coursedata{'description'};
1.51 albertel 644: } else {
1.72 sakharuk 645: $carea=&mt('Unavailable course').': '.$area;
1.86 albertel 646: $sortkey.="\0".&mt('Unavailable course').': '.$area;
1.51 albertel 647: }
1.37 matthew 648: $inccourses{$1.'_'.$2}=1;
1.53 www 649: if ((&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2)) ||
650: (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
1.37 matthew 651: $allowed=1;
652: }
1.53 www 653: if ((&Apache::lonnet::allowed('dro',$1)) ||
654: (&Apache::lonnet::allowed('dro',$ccdomain))) {
655: $delallowed=1;
656: }
1.64 www 657: # - custom role. Needs more info, too
658: if ($croletitle) {
659: if (&Apache::lonnet::allowed('ccr',$1.'/'.$2)) {
660: $allowed=1;
661: $thisrole.='.'.$role_code;
662: }
663: }
1.37 matthew 664: # Compute the background color based on $area
665: $bgcol=$1.'_'.$2;
1.62 www 666: $bgcol=~s/[^7-9a-e]//g;
667: $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',2,6);
1.37 matthew 668: if ($area=~/^\/(\w+)\/(\d\w+)\/(\w+)/) {
1.113 raeburn 669: $carea.='<br />Section: '.$3;
1.87 albertel 670: $sortkey.="\0$3";
1.37 matthew 671: }
672: $area=$carea;
673: } else {
1.79 albertel 674: $sortkey.="\0".$area;
1.37 matthew 675: # Determine if current user is able to revoke privileges
676: if ($area=~ /^\/(\w+)\//) {
1.53 www 677: if ((&Apache::lonnet::allowed('c'.$role_code,$1)) ||
678: (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
1.37 matthew 679: $allowed=1;
680: }
1.53 www 681: if (((&Apache::lonnet::allowed('dro',$1)) ||
682: (&Apache::lonnet::allowed('dro',$ccdomain))) &&
683: ($role_code ne 'dc')) {
684: $delallowed=1;
685: }
1.37 matthew 686: } else {
687: if (&Apache::lonnet::allowed('c'.$role_code,'/')) {
688: $allowed=1;
689: }
690: }
1.79 albertel 691: if ($role_code eq 'ca' || $role_code eq 'au') {
692: $class='Construction Space';
693: } elsif ($role_code eq 'su') {
694: $class='System';
695: } else {
696: $class='Domain';
697: }
1.37 matthew 698: }
1.105 www 699: if (($role_code eq 'ca') || ($role_code eq 'aa')) {
1.43 www 700: $area=~/\/(\w+)\/(\w+)/;
701: if (&authorpriv($2,$1)) {
702: $allowed=1;
703: } else {
704: $allowed=0;
1.37 matthew 705: }
706: }
1.79 albertel 707: $bgcol='77FF77';
1.37 matthew 708: my $row = '';
1.62 www 709: $row.='<tr bgcolor="#'.$bgcol.'"><td>';
1.37 matthew 710: my $active=1;
711: $active=0 if (($role_end_time) && ($now>$role_end_time));
712: if (($active) && ($allowed)) {
713: $row.= '<input type="checkbox" name="rev:'.$thisrole.'">';
714: } else {
1.56 www 715: if ($active) {
716: $row.=' ';
717: } else {
1.72 sakharuk 718: $row.=&mt('expired or revoked');
1.56 www 719: }
1.37 matthew 720: }
1.53 www 721: $row.='</td><td>';
1.81 albertel 722: if ($allowed && !$active) {
723: $row.= '<input type="checkbox" name="ren:'.$thisrole.'">';
724: } else {
725: $row.=' ';
726: }
727: $row.='</td><td>';
1.53 www 728: if ($delallowed) {
729: $row.= '<input type="checkbox" name="del:'.$thisrole.'">';
730: } else {
731: $row.=' ';
732: }
1.64 www 733: my $plaintext='';
734: unless ($croletitle) {
735: $plaintext=&Apache::lonnet::plaintext($role_code);
736: } else {
737: $plaintext=
738: "Customrole '$croletitle' defined by $croleuname\@$croleudom";
739: }
740: $row.= '</td><td>'.$plaintext.
1.37 matthew 741: '</td><td>'.$area.
742: '</td><td>'.($role_start_time?localtime($role_start_time)
743: : ' ' ).
744: '</td><td>'.($role_end_time ?localtime($role_end_time)
745: : ' ' )
746: ."</td></tr>\n";
1.79 albertel 747: $sortrole{$sortkey}=$envkey;
748: $roletext{$envkey}=$row;
749: $roleclass{$envkey}=$class;
1.89 raeburn 750: $rolepriv{$envkey}=$allowed;
1.79 albertel 751: #$r->print($row);
1.28 matthew 752: } # end of foreach (table building loop)
1.89 raeburn 753: my $rolesdisplay = 0;
754: my %output = ();
1.79 albertel 755: foreach my $type ('Construction Space','Course','Domain','System','Unknown') {
1.89 raeburn 756: $output{$type} = '';
1.79 albertel 757: foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
1.89 raeburn 758: if ( ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/ ) && ($rolepriv{$sortrole{$which}}) ) {
759: $output{$type}.=$roletext{$sortrole{$which}};
1.79 albertel 760: }
761: }
1.89 raeburn 762: unless($output{$type} eq '') {
763: $output{$type} = "<tr bgcolor='#BBffBB'>".
764: "<td align='center' colspan='7'>".&mt($type)."</td>".
765: $output{$type};
766: $rolesdisplay = 1;
1.79 albertel 767: }
768: }
1.89 raeburn 769: if ($rolesdisplay == 1) {
770: $r->print(<<END);
771: <hr />
772: <h3>$lt{'rer'}</h3>
773: <table>
774: <tr><th>$lt{'rev'}</th><th>$lt{'ren'}</th><th>$lt{'del'}</th><th>$lt{'rol'}</th><th>$lt{'e
775: xt'}</th><th>$lt{'sta'}</th><th>$lt{'end'}</th>
776: END
777: foreach my $type ('Construction Space','Course','Domain','System','Unknown') {
778: if ($output{$type}) {
779: $r->print($output{$type}."\n");
780: }
781: }
782: $r->print('</table>');
783: }
1.28 matthew 784: } # End of unless
1.20 harris41 785: my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain);
1.41 albertel 786: if ($currentauth=~/^krb(4|5):/) {
787: $currentauth=~/^krb(4|5):(.*)/;
1.108 albertel 788: my $krbdefdom=$2;
1.31 matthew 789: my %param = ( formname => 'document.cu',
790: kerb_def_dom => $krbdefdom
791: );
792: $loginscript = &Apache::loncommon::authform_header(%param);
1.20 harris41 793: }
1.26 matthew 794: # Check for a bad authentication type
1.41 albertel 795: unless ($currentauth=~/^krb(4|5):/ or
1.20 harris41 796: $currentauth=~/^unix:/ or
797: $currentauth=~/^internal:/ or
798: $currentauth=~/^localauth:/
1.26 matthew 799: ) { # bad authentication scheme
1.101 albertel 800: if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) {
1.94 matthew 801: &initialize_authen_forms();
1.73 sakharuk 802: my %lt=&Apache::lonlocal::texthash(
803: 'err' => "ERROR",
804: 'uuas' => "This user has an unrecognized authentication scheme",
805: 'sldb' => "Please specify login data below",
806: 'ld' => "Login Data"
807: );
1.26 matthew 808: $r->print(<<ENDBADAUTH);
1.21 harris41 809: <hr />
1.31 matthew 810: <script type="text/javascript" language="Javascript">
1.21 harris41 811: $loginscript
1.31 matthew 812: </script>
1.73 sakharuk 813: <font color='#ff0000'>$lt{'err'}:</font>
814: $lt{'uuas'} ($currentauth). $lt{'sldb'}.
815: <h3>$lt{'ld'}</h3>
1.31 matthew 816: <p>$generalrule</p>
817: <p>$authformkrb</p>
818: <p>$authformint</p>
819: <p>$authformfsys</p>
820: <p>$authformloc</p>
1.26 matthew 821: ENDBADAUTH
822: } else {
823: # This user is not allowed to modify the users
824: # authentication scheme, so just notify them of the problem
1.73 sakharuk 825: my %lt=&Apache::lonlocal::texthash(
826: 'err' => "ERROR",
827: 'uuas' => "This user has an unrecognized authentication scheme",
828: 'adcs' => "Please alert a domain coordinator of this situation"
829: );
1.26 matthew 830: $r->print(<<ENDBADAUTH);
831: <hr />
1.31 matthew 832: <script type="text/javascript" language="Javascript">
1.26 matthew 833: $loginscript
1.31 matthew 834: </script>
1.73 sakharuk 835: <font color="#ff0000"> $lt{'err'}: </font>
836: $lt{'uuas'} ($currentauth). $lt{'adcs'}.
1.26 matthew 837: <hr />
838: ENDBADAUTH
839: }
840: } else { # Authentication type is valid
1.20 harris41 841: my $authformcurrent='';
1.26 matthew 842: my $authform_other='';
1.94 matthew 843: &initialize_authen_forms();
1.41 albertel 844: if ($currentauth=~/^krb(4|5):/) {
1.20 harris41 845: $authformcurrent=$authformkrb;
1.31 matthew 846: $authform_other="<p>$authformint</p>\n".
847: "<p>$authformfsys</p><p>$authformloc</p>";
1.20 harris41 848: }
849: elsif ($currentauth=~/^internal:/) {
850: $authformcurrent=$authformint;
1.31 matthew 851: $authform_other="<p>$authformkrb</p>".
852: "<p>$authformfsys</p><p>$authformloc</p>";
1.20 harris41 853: }
854: elsif ($currentauth=~/^unix:/) {
855: $authformcurrent=$authformfsys;
1.31 matthew 856: $authform_other="<p>$authformkrb</p>".
857: "<p>$authformint</p><p>$authformloc;</p>";
1.20 harris41 858: }
859: elsif ($currentauth=~/^localauth:/) {
860: $authformcurrent=$authformloc;
1.31 matthew 861: $authform_other="<p>$authformkrb</p>".
862: "<p>$authformint</p><p>$authformfsys</p>";
1.20 harris41 863: }
1.53 www 864: $authformcurrent.=' <i>(will override current values)</i><br />';
1.101 albertel 865: if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) {
1.26 matthew 866: # Current user has login modification privileges
1.73 sakharuk 867: my %lt=&Apache::lonlocal::texthash(
868: 'ccld' => "Change Current Login Data",
869: 'enld' => "Enter New Login Data"
870: );
1.26 matthew 871: $r->print(<<ENDOTHERAUTHS);
1.21 harris41 872: <hr />
1.31 matthew 873: <script type="text/javascript" language="Javascript">
1.21 harris41 874: $loginscript
1.31 matthew 875: </script>
1.73 sakharuk 876: <h3>$lt{'ccld'}</h3>
1.31 matthew 877: <p>$generalrule</p>
878: <p>$authformnop</p>
879: <p>$authformcurrent</p>
1.73 sakharuk 880: <h3>$lt{'enld'}</h3>
1.26 matthew 881: $authform_other
882: ENDOTHERAUTHS
883: }
884: } ## End of "check for bad authentication type" logic
1.25 matthew 885: } ## End of new user/old user logic
1.72 sakharuk 886: $r->print('<hr /><h3>'.&mt('Add Roles').'</h3>');
1.17 www 887: #
888: # Co-Author
889: #
1.101 albertel 890: if (&authorpriv($env{'user.name'},$env{'request.role.domain'}) &&
891: ($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain)) {
1.44 matthew 892: # No sense in assigning co-author role to yourself
1.101 albertel 893: my $cuname=$env{'user.name'};
894: my $cudom=$env{'request.role.domain'};
1.72 sakharuk 895: my %lt=&Apache::lonlocal::texthash(
896: 'cs' => "Construction Space",
897: 'act' => "Activate",
898: 'rol' => "Role",
899: 'ext' => "Extent",
900: 'sta' => "Start",
1.80 www 901: 'end' => "End",
1.72 sakharuk 902: 'cau' => "Co-Author",
1.105 www 903: 'caa' => "Assistant Co-Author",
1.72 sakharuk 904: 'ssd' => "Set Start Date",
905: 'sed' => "Set End Date"
906: );
1.17 www 907: $r->print(<<ENDCOAUTH);
1.72 sakharuk 908: <h4>$lt{'cs'}</h4>
1.74 sakharuk 909: <table border=2><tr><th>$lt{'act'}</th><th>$lt{'rol'}</th><th>$lt{'ext'}</th>
1.72 sakharuk 910: <th>$lt{'sta'}</th><th>$lt{'end'}</th></tr>
1.17 www 911: <tr>
1.80 www 912: <td><input type=checkbox name="act_$cudom\_$cuname\_ca" /></td>
1.72 sakharuk 913: <td>$lt{'cau'}</td>
1.17 www 914: <td>$cudom\_$cuname</td>
1.80 www 915: <td><input type=hidden name="start_$cudom\_$cuname\_ca" value='' />
1.17 www 916: <a href=
1.72 sakharuk 917: "javascript:pjump('date_start','Start Date Co-Author',document.cu.start_$cudom\_$cuname\_ca.value,'start_$cudom\_$cuname\_ca','cu.pres','dateset')">$lt{'ssd'}</a></td>
1.80 www 918: <td><input type=hidden name="end_$cudom\_$cuname\_ca" value='' />
1.17 www 919: <a href=
1.72 sakharuk 920: "javascript:pjump('date_end','End Date Co-Author',document.cu.end_$cudom\_$cuname\_ca.value,'end_$cudom\_$cuname\_ca','cu.pres','dateset')">$lt{'sed'}</a></td>
1.17 www 921: </tr>
1.105 www 922: <tr>
923: <td><input type=checkbox name="act_$cudom\_$cuname\_aa" /></td>
924: <td>$lt{'caa'}</td>
925: <td>$cudom\_$cuname</td>
926: <td><input type=hidden name="start_$cudom\_$cuname\_aa" value='' />
927: <a href=
928: "javascript:pjump('date_start','Start Date Assistant Co-Author',document.cu.start_$cudom\_$cuname\_aa.value,'start_$cudom\_$cuname\_aa','cu.pres','dateset')">$lt{'ssd'}</a></td>
929: <td><input type=hidden name="end_$cudom\_$cuname\_aa" value='' />
930: <a href=
931: "javascript:pjump('date_end','End Date Assistant Co-Author',document.cu.end_$cudom\_$cuname\_aa.value,'end_$cudom\_$cuname\_aa','cu.pres','dateset')">$lt{'sed'}</a></td>
932: </tr>
1.17 www 933: </table>
934: ENDCOAUTH
935: }
1.8 www 936: #
937: # Domain level
938: #
1.89 raeburn 939: my $num_domain_level = 0;
940: my $domaintext =
941: '<h4>'.&mt('Domain Level').'</h4>'.
1.73 sakharuk 942: '<table border=2><tr><th>'.&mt('Activate').'</th><th>'.&mt('Role').'</th><th>'.&mt('Extent').'</th>'.
1.89 raeburn 943: '<th>'.&mt('Start').'</th><th>'.&mt('End').'</th></tr>';
1.24 matthew 944: foreach ( sort( keys(%incdomains))) {
1.2 www 945: my $thisdomain=$_;
1.69 albertel 946: foreach ('dc','li','dg','au','sc') {
1.2 www 947: if (&Apache::lonnet::allowed('c'.$_,$thisdomain)) {
1.8 www 948: my $plrole=&Apache::lonnet::plaintext($_);
1.72 sakharuk 949: my %lt=&Apache::lonlocal::texthash(
950: 'ssd' => "Set Start Date",
951: 'sed' => "Set End Date"
952: );
1.89 raeburn 953: $num_domain_level ++;
954: $domaintext .= <<"ENDDROW";
1.8 www 955: <tr>
956: <td><input type=checkbox name="act_$thisdomain\_$_"></td>
957: <td>$plrole</td>
958: <td>$thisdomain</td>
959: <td><input type=hidden name="start_$thisdomain\_$_" value=''>
960: <a href=
1.72 sakharuk 961: "javascript:pjump('date_start','Start Date $plrole',document.cu.start_$thisdomain\_$_.value,'start_$thisdomain\_$_','cu.pres','dateset')">$lt{'ssd'}</a></td>
1.8 www 962: <td><input type=hidden name="end_$thisdomain\_$_" value=''>
963: <a href=
1.72 sakharuk 964: "javascript:pjump('date_end','End Date $plrole',document.cu.end_$thisdomain\_$_.value,'end_$thisdomain\_$_','cu.pres','dateset')">$lt{'sed'}</a></td>
1.8 www 965: </tr>
966: ENDDROW
1.2 www 967: }
1.24 matthew 968: }
969: }
1.89 raeburn 970: $domaintext.='</table>';
971: if ($num_domain_level > 0) {
972: $r->print($domaintext);
973: }
1.8 www 974: #
975: # Course level
976: #
1.89 raeburn 977: my $num_sections;
1.88 raeburn 978:
1.101 albertel 979: if ($env{'request.role'} =~ m-^dc\./(\w+)/$-) {
1.88 raeburn 980: $r->print(&course_level_dc($1));
981: $r->print('<hr /><input type="button" value="'.&mt('Modify User').'" onClick="setCourse()">'."\n");
982: } else {
983: $r->print(&course_level_table(%inccourses));
1.89 raeburn 984: $r->print('<hr /><input type="button" value="'.&mt('Modify User').'" onClick="setSections()">'."\n");
1.88 raeburn 985: }
1.110 albertel 986: $r->print("</form>".&Apache::loncommon::end_page());
1.2 www 987: }
1.1 www 988:
1.4 www 989: # ================================================================= Phase Three
1.42 matthew 990: sub update_user_data {
1.4 www 991: my $r=shift;
1.101 albertel 992: my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'},
993: $env{'form.ccdomain'});
1.27 matthew 994: # Error messages
1.73 sakharuk 995: my $error = '<font color="#ff0000">'.&mt('Error').':</font>';
1.110 albertel 996: my $end = &Apache::loncommon::end_page();
997:
1.40 www 998: my $title;
1.101 albertel 999: if (exists($env{'form.makeuser'})) {
1.40 www 1000: $title='Set Privileges for New User';
1001: } else {
1002: $title='Modify User Privileges';
1003: }
1.110 albertel 1004: $r->print(&Apache::loncommon::start_page($title));
1.113 raeburn 1005: my %disallowed;
1.27 matthew 1006: # Check Inputs
1.101 albertel 1007: if (! $env{'form.ccuname'} ) {
1.73 sakharuk 1008: $r->print($error.&mt('No login name specified').'.'.$end);
1.27 matthew 1009: return;
1010: }
1.101 albertel 1011: if ( $env{'form.ccuname'} =~/\W/) {
1.73 sakharuk 1012: $r->print($error.&mt('Invalid login name').'. '.
1013: &mt('Only letters, numbers, and underscores are valid').'.'.
1.27 matthew 1014: $end);
1015: return;
1016: }
1.101 albertel 1017: if (! $env{'form.ccdomain'} ) {
1.73 sakharuk 1018: $r->print($error.&mt('No domain specified').'.'.$end);
1.27 matthew 1019: return;
1020: }
1.101 albertel 1021: if ( $env{'form.ccdomain'} =~/\W/) {
1.73 sakharuk 1022: $r->print($error.&mt ('Invalid domain name').'. '.
1023: &mt('Only letters, numbers, and underscores are valid').'.'.
1.27 matthew 1024: $end);
1025: return;
1026: }
1.101 albertel 1027: if (! exists($env{'form.makeuser'})) {
1.29 matthew 1028: # Modifying an existing user, so check the validity of the name
1029: if ($uhome eq 'no_host') {
1.73 sakharuk 1030: $r->print($error.&mt('Unable to determine home server for ').
1.101 albertel 1031: $env{'form.ccuname'}.&mt(' in domain ').
1032: $env{'form.ccdomain'}.'.');
1.29 matthew 1033: return;
1034: }
1035: }
1.27 matthew 1036: # Determine authentication method and password for the user being modified
1037: my $amode='';
1038: my $genpwd='';
1.101 albertel 1039: if ($env{'form.login'} eq 'krb') {
1.41 albertel 1040: $amode='krb';
1.101 albertel 1041: $amode.=$env{'form.krbver'};
1042: $genpwd=$env{'form.krbarg'};
1043: } elsif ($env{'form.login'} eq 'int') {
1.27 matthew 1044: $amode='internal';
1.101 albertel 1045: $genpwd=$env{'form.intarg'};
1046: } elsif ($env{'form.login'} eq 'fsys') {
1.27 matthew 1047: $amode='unix';
1.101 albertel 1048: $genpwd=$env{'form.fsysarg'};
1049: } elsif ($env{'form.login'} eq 'loc') {
1.27 matthew 1050: $amode='localauth';
1.101 albertel 1051: $genpwd=$env{'form.locarg'};
1.27 matthew 1052: $genpwd=" " if (!$genpwd);
1.101 albertel 1053: } elsif (($env{'form.login'} eq 'nochange') ||
1054: ($env{'form.login'} eq '' )) {
1.34 matthew 1055: # There is no need to tell the user we did not change what they
1056: # did not ask us to change.
1.35 matthew 1057: # If they are creating a new user but have not specified login
1058: # information this will be caught below.
1.30 matthew 1059: } else {
1.73 sakharuk 1060: $r->print($error.&mt('Invalid login mode or password').$end);
1.30 matthew 1061: return;
1.27 matthew 1062: }
1.101 albertel 1063: if ($env{'form.makeuser'}) {
1.27 matthew 1064: # Create a new user
1.73 sakharuk 1065: my %lt=&Apache::lonlocal::texthash(
1066: 'cru' => "Creating user",
1067: 'id' => "in domain"
1068: );
1.27 matthew 1069: $r->print(<<ENDNEWUSERHEAD);
1.101 albertel 1070: <h3>$lt{'cru'} "$env{'form.ccuname'}" $lt{'id'} "$env{'form.ccdomain'}"</h3>
1.27 matthew 1071: ENDNEWUSERHEAD
1072: # Check for the authentication mode and password
1073: if (! $amode || ! $genpwd) {
1.73 sakharuk 1074: $r->print($error.&mt('Invalid login mode or password').$end);
1.27 matthew 1075: return;
1.18 albertel 1076: }
1.29 matthew 1077: # Determine desired host
1.101 albertel 1078: my $desiredhost = $env{'form.hserver'};
1.29 matthew 1079: if (lc($desiredhost) eq 'default') {
1080: $desiredhost = undef;
1081: } else {
1.39 matthew 1082: my %home_servers = &Apache::loncommon::get_library_servers
1.101 albertel 1083: ($env{'form.ccdomain'});
1.29 matthew 1084: if (! exists($home_servers{$desiredhost})) {
1.73 sakharuk 1085: $r->print($error.&mt('Invalid home server specified'));
1.29 matthew 1086: return;
1087: }
1088: }
1.27 matthew 1089: # Call modifyuser
1090: my $result = &Apache::lonnet::modifyuser
1.101 albertel 1091: ($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cstid'},
1092: $amode,$genpwd,$env{'form.cfirst'},
1093: $env{'form.cmiddle'},$env{'form.clast'},$env{'form.cgen'},
1.29 matthew 1094: undef,$desiredhost
1.27 matthew 1095: );
1.77 www 1096: $r->print(&mt('Generating user').': '.$result);
1.101 albertel 1097: my $home = &Apache::lonnet::homeserver($env{'form.ccuname'},
1098: $env{'form.ccdomain'});
1.77 www 1099: $r->print('<br />'.&mt('Home server').': '.$home.' '.
1.29 matthew 1100: $Apache::lonnet::libserv{$home});
1.101 albertel 1101: } elsif (($env{'form.login'} ne 'nochange') &&
1102: ($env{'form.login'} ne '' )) {
1.27 matthew 1103: # Modify user privileges
1.73 sakharuk 1104: my %lt=&Apache::lonlocal::texthash(
1105: 'usr' => "User",
1106: 'id' => "in domain"
1107: );
1.27 matthew 1108: $r->print(<<ENDMODIFYUSERHEAD);
1.101 albertel 1109: <h2>$lt{'usr'} "$env{'form.ccuname'}" $lt{'id'} "$env{'form.ccdomain'}"</h2>
1.27 matthew 1110: ENDMODIFYUSERHEAD
1111: if (! $amode || ! $genpwd) {
1112: $r->print($error.'Invalid login mode or password'.$end);
1113: return;
1.20 harris41 1114: }
1.27 matthew 1115: # Only allow authentification modification if the person has authority
1.101 albertel 1116: if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
1.20 harris41 1117: $r->print('Modifying authentication: '.
1.31 matthew 1118: &Apache::lonnet::modifyuserauth(
1.101 albertel 1119: $env{'form.ccdomain'},$env{'form.ccuname'},
1.21 harris41 1120: $amode,$genpwd));
1.102 albertel 1121: $r->print('<br />'.&mt('Home server').': '.&Apache::lonnet::homeserver
1.101 albertel 1122: ($env{'form.ccuname'},$env{'form.ccdomain'}));
1.4 www 1123: } else {
1.27 matthew 1124: # Okay, this is a non-fatal error.
1.73 sakharuk 1125: $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.');
1.27 matthew 1126: }
1.28 matthew 1127: }
1128: ##
1.101 albertel 1129: if (! $env{'form.makeuser'} ) {
1.28 matthew 1130: # Check for need to change
1131: my %userenv = &Apache::lonnet::get
1132: ('environment',['firstname','middlename','lastname','generation'],
1.101 albertel 1133: $env{'form.ccdomain'},$env{'form.ccuname'});
1.28 matthew 1134: my ($tmp) = keys(%userenv);
1135: if ($tmp =~ /^(con_lost|error)/i) {
1136: %userenv = ();
1137: }
1138: # Check to see if we need to change user information
1139: foreach ('firstname','middlename','lastname','generation') {
1140: # Strip leading and trailing whitespace
1.101 albertel 1141: $env{'form.c'.$_} =~ s/(\s+$|^\s+)//g;
1.28 matthew 1142: }
1.101 albertel 1143: if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}) &&
1144: ($env{'form.cfirstname'} ne $userenv{'firstname'} ||
1145: $env{'form.cmiddlename'} ne $userenv{'middlename'} ||
1146: $env{'form.clastname'} ne $userenv{'lastname'} ||
1147: $env{'form.cgeneration'} ne $userenv{'generation'} )) {
1.28 matthew 1148: # Make the change
1149: my %changeHash;
1.101 albertel 1150: $changeHash{'firstname'} = $env{'form.cfirstname'};
1151: $changeHash{'middlename'} = $env{'form.cmiddlename'};
1152: $changeHash{'lastname'} = $env{'form.clastname'};
1153: $changeHash{'generation'} = $env{'form.cgeneration'};
1.28 matthew 1154: my $putresult = &Apache::lonnet::put
1155: ('environment',\%changeHash,
1.101 albertel 1156: $env{'form.ccdomain'},$env{'form.ccuname'});
1.28 matthew 1157: if ($putresult eq 'ok') {
1158: # Tell the user we changed the name
1.73 sakharuk 1159: my %lt=&Apache::lonlocal::texthash(
1160: 'uic' => "User Information Changed",
1161: 'frst' => "first",
1162: 'mddl' => "middle",
1163: 'lst' => "last",
1164: 'gen' => "generation",
1165: 'prvs' => "Previous",
1166: 'chto' => "Changed To"
1167: );
1.28 matthew 1168: $r->print(<<"END");
1169: <table border="2">
1.73 sakharuk 1170: <caption>$lt{'uic'}</caption>
1.28 matthew 1171: <tr><th> </th>
1.73 sakharuk 1172: <th>$lt{'frst'}</th>
1173: <th>$lt{'mddl'}</th>
1174: <th>$lt{'lst'}</th>
1175: <th>$lt{'gen'}</th></tr>
1176: <tr><td>$lt{'prvs'}</td>
1.28 matthew 1177: <td>$userenv{'firstname'} </td>
1178: <td>$userenv{'middlename'} </td>
1179: <td>$userenv{'lastname'} </td>
1180: <td>$userenv{'generation'} </td></tr>
1.73 sakharuk 1181: <tr><td>$lt{'chto'}</td>
1.101 albertel 1182: <td>$env{'form.cfirstname'} </td>
1183: <td>$env{'form.cmiddlename'} </td>
1184: <td>$env{'form.clastname'} </td>
1185: <td>$env{'form.cgeneration'} </td></tr>
1.28 matthew 1186: </table>
1187: END
1188: } else { # error occurred
1.73 sakharuk 1189: $r->print("<h2>".&mt('Unable to successfully change environment for')." ".
1.101 albertel 1190: $env{'form.ccuname'}." ".&mt('in domain')." ".
1191: $env{'form.ccdomain'}."</h2>");
1.28 matthew 1192: }
1.101 albertel 1193: } else { # End of if ($env ... ) logic
1.28 matthew 1194: # They did not want to change the users name but we can
1195: # still tell them what the name is
1.73 sakharuk 1196: my %lt=&Apache::lonlocal::texthash(
1197: 'usr' => "User",
1198: 'id' => "in domain",
1199: 'gen' => "Generation"
1200: );
1.28 matthew 1201: $r->print(<<"END");
1.101 albertel 1202: <h2>$lt{'usr'} "$env{'form.ccuname'}" $lt{'id'} "$env{'form.ccdomain'}"</h2>
1.28 matthew 1203: <h4>$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} </h4>
1.73 sakharuk 1204: <h4>$lt{'gen'}: $userenv{'generation'}</h4>
1.28 matthew 1205: END
1206: }
1.4 www 1207: }
1.27 matthew 1208: ##
1.4 www 1209: my $now=time;
1.73 sakharuk 1210: $r->print('<h3>'.&mt('Modifying Roles').'</h3>');
1.101 albertel 1211: foreach (keys (%env)) {
1212: next if (! $env{$_});
1.27 matthew 1213: # Revoke roles
1214: if ($_=~/^form\.rev/) {
1.64 www 1215: if ($_=~/^form\.rev\:([^\_]+)\_([^\_\.]+)$/) {
1216: # Revoke standard role
1.73 sakharuk 1217: $r->print(&mt('Revoking').' '.$2.' in '.$1.': <b>'.
1.101 albertel 1218: &Apache::lonnet::revokerole($env{'form.ccdomain'},
1.102 albertel 1219: $env{'form.ccuname'},$1,$2).'</b><br />');
1.53 www 1220: if ($2 eq 'st') {
1221: $1=~/^\/(\w+)\/(\w+)/;
1222: my $cid=$1.'_'.$2;
1.73 sakharuk 1223: $r->print(&mt('Drop from classlist').': <b>'.
1.53 www 1224: &Apache::lonnet::critical('put:'.
1.101 albertel 1225: $env{'course.'.$cid.'.domain'}.':'.
1226: $env{'course.'.$cid.'.num'}.':classlist:'.
1227: &Apache::lonnet::escape($env{'form.ccuname'}.':'.
1228: $env{'form.ccdomain'}).'='.
1.53 www 1229: &Apache::lonnet::escape($now.':'),
1.102 albertel 1230: $env{'course.'.$cid.'.home'}).'</b><br />');
1.53 www 1231: }
1232: }
1.64 www 1233: if ($_=~/^form\.rev\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
1234: # Revoke custom role
1.113 raeburn 1235: $r->print(&mt('Revoking custom role:').
1.73 sakharuk 1236: ' '.$4.' by '.$3.'@'.$2.' in '.$1.': <b>'.
1.101 albertel 1237: &Apache::lonnet::revokecustomrole($env{'form.ccdomain'},
1238: $env{'form.ccuname'},$1,$2,$3,$4).
1.102 albertel 1239: '</b><br />');
1.64 www 1240: }
1.53 www 1241: } elsif ($_=~/^form\.del/) {
1242: if ($_=~/^form\.del\:([^\_]+)\_([^\_]+)$/) {
1.73 sakharuk 1243: $r->print(&mt('Deleting').' '.$2.' in '.$1.': '.
1.101 albertel 1244: &Apache::lonnet::assignrole($env{'form.ccdomain'},
1.102 albertel 1245: $env{'form.ccuname'},$1,$2,$now,0,1).'<br />');
1.27 matthew 1246: if ($2 eq 'st') {
1247: $1=~/^\/(\w+)\/(\w+)/;
1248: my $cid=$1.'_'.$2;
1.73 sakharuk 1249: $r->print(&mt('Drop from classlist').': <b>'.
1.27 matthew 1250: &Apache::lonnet::critical('put:'.
1.101 albertel 1251: $env{'course.'.$cid.'.domain'}.':'.
1252: $env{'course.'.$cid.'.num'}.':classlist:'.
1253: &Apache::lonnet::escape($env{'form.ccuname'}.':'.
1254: $env{'form.ccdomain'}).'='.
1.27 matthew 1255: &Apache::lonnet::escape($now.':'),
1.102 albertel 1256: $env{'course.'.$cid.'.home'}).'</b><br />');
1.81 albertel 1257: }
1.113 raeburn 1258: }
1.81 albertel 1259: } elsif ($_=~/^form\.ren/) {
1.101 albertel 1260: my $udom = $env{'form.ccdomain'};
1261: my $uname = $env{'form.ccuname'};
1.81 albertel 1262: if ($_=~/^form\.ren\:([^\_]+)\_([^\_]+)$/) {
1.89 raeburn 1263: my $url = $1;
1264: my $role = $2;
1265: my $logmsg;
1266: my $output;
1267: if ($role eq 'st') {
1268: if ($url =~ m-^/(\w+)/(\w+)/?(\w*)$-) {
1.99 raeburn 1269: my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3);
1.89 raeburn 1270: if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) {
1271: $output = "Error: $result\n";
1272: } else {
1273: $output = &mt('Assigning').' '.$role.' in '.$url.
1274: &mt('starting').' '.localtime($now).
1275: ': <br />'.$logmsg.'<br />'.
1276: &mt('Add to classlist').': <b>ok</b><br />';
1277: }
1278: }
1279: } else {
1.101 albertel 1280: my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'},
1281: $env{'form.ccuname'},$url,$role,0,$now);
1.89 raeburn 1282: $output = &mt('Re-Enabling [_1] in [_2]: [_3]',
1283: $role,$url,$result).'<br />';
1.27 matthew 1284: }
1.89 raeburn 1285: $r->print($output);
1.113 raeburn 1286: }
1.27 matthew 1287: } elsif ($_=~/^form\.act/) {
1.101 albertel 1288: my $udom = $env{'form.ccdomain'};
1289: my $uname = $env{'form.ccuname'};
1.83 albertel 1290: if ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_cr_cr_([^\_]+)_(\w+)_([^\_]+)$/) {
1.65 www 1291: # Activate a custom role
1.83 albertel 1292: my ($one,$two,$three,$four,$five)=($1,$2,$3,$4,$5);
1293: my $url='/'.$one.'/'.$two;
1294: my $full=$one.'_'.$two.'_cr_cr_'.$three.'_'.$four.'_'.$five;
1.65 www 1295:
1.101 albertel 1296: my $start = ( $env{'form.start_'.$full} ?
1297: $env{'form.start_'.$full} :
1.88 raeburn 1298: $now );
1.101 albertel 1299: my $end = ( $env{'form.end_'.$full} ?
1300: $env{'form.end_'.$full} :
1.88 raeburn 1301: 0 );
1302:
1303: # split multiple sections
1304: my %sections = ();
1.101 albertel 1305: my $num_sections = &build_roles($env{'form.sec_'.$full},\%sections,$5);
1.88 raeburn 1306: if ($num_sections == 0) {
1.99 raeburn 1307: $r->print(&commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end));
1.88 raeburn 1308: } else {
1.114 ! albertel 1309: my %curr_groups =
! 1310: &Apache::loncommon::coursegroups($one,$two);
1.113 raeburn 1311: foreach my $sec (sort {$a cmp $b} keys %sections) {
1312: if (($sec eq 'none') || ($sec eq 'all') ||
1313: exists($curr_groups{$sec})) {
1314: $disallowed{$sec} = $url;
1315: next;
1316: }
1317: my $securl = $url.'/'.$sec;
1.99 raeburn 1318: $r->print(&commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end));
1.88 raeburn 1319: }
1320: }
1.98 albertel 1321: } elsif ($_=~/^form\.act\_([^\_]+)\_(\w+)\_([^\_]+)$/) {
1.27 matthew 1322: # Activate roles for sections with 3 id numbers
1323: # set start, end times, and the url for the class
1.83 albertel 1324: my ($one,$two,$three)=($1,$2,$3);
1.101 albertel 1325: my $start = ( $env{'form.start_'.$one.'_'.$two.'_'.$three} ?
1326: $env{'form.start_'.$one.'_'.$two.'_'.$three} :
1.27 matthew 1327: $now );
1.101 albertel 1328: my $end = ( $env{'form.end_'.$one.'_'.$two.'_'.$three} ?
1329: $env{'form.end_'.$one.'_'.$two.'_'.$three} :
1.27 matthew 1330: 0 );
1.83 albertel 1331: my $url='/'.$one.'/'.$two;
1.88 raeburn 1332: my $type = 'three';
1333: # split multiple sections
1334: my %sections = ();
1.101 albertel 1335: my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);
1.88 raeburn 1336: if ($num_sections == 0) {
1.99 raeburn 1337: $r->print(&commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
1.88 raeburn 1338: } else {
1.114 ! albertel 1339: my %curr_groups =
! 1340: &Apache::loncommon::coursegroups($one,$two);
1.88 raeburn 1341: my $emptysec = 0;
1342: foreach my $sec (sort {$a cmp $b} keys %sections) {
1343: $sec =~ s/\W//g;
1.113 raeburn 1344: if ($sec ne '') {
1345: if (($sec eq 'none') || ($sec eq 'all') ||
1346: exists($curr_groups{$sec})) {
1347: $disallowed{$sec} = $url;
1348: next;
1349: }
1.88 raeburn 1350: my $securl = $url.'/'.$sec;
1.99 raeburn 1351: $r->print(&commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec));
1.88 raeburn 1352: } else {
1353: $emptysec = 1;
1354: }
1355: }
1356: if ($emptysec) {
1.99 raeburn 1357: $r->print(&commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
1.88 raeburn 1358: }
1359: }
1.27 matthew 1360: } elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)$/) {
1361: # Activate roles for sections with two id numbers
1362: # set start, end times, and the url for the class
1.101 albertel 1363: my $start = ( $env{'form.start_'.$1.'_'.$2} ?
1364: $env{'form.start_'.$1.'_'.$2} :
1.27 matthew 1365: $now );
1.101 albertel 1366: my $end = ( $env{'form.end_'.$1.'_'.$2} ?
1367: $env{'form.end_'.$1.'_'.$2} :
1.27 matthew 1368: 0 );
1369: my $url='/'.$1.'/';
1.88 raeburn 1370: # split multiple sections
1371: my %sections = ();
1.101 albertel 1372: my $num_sections = &build_roles($env{'form.sec_'.$1.'_'.$2},\%sections,$2);
1.88 raeburn 1373: if ($num_sections == 0) {
1.99 raeburn 1374: $r->print(&commit_standardrole($udom,$uname,$url,$2,$start,$end,$1,undef,''));
1.88 raeburn 1375: } else {
1376: my $emptysec = 0;
1377: foreach my $sec (sort {$a cmp $b} keys %sections) {
1378: if ($sec ne '') {
1379: my $securl = $url.'/'.$sec;
1.99 raeburn 1380: $r->print(&commit_standardrole($udom,$uname,$securl,$2,$start,$end,$1,undef,$sec));
1.88 raeburn 1381: } else {
1382: $emptysec = 1;
1383: }
1384: }
1385: if ($emptysec) {
1.99 raeburn 1386: $r->print(&commit_standardrole($udom,$uname,$url,$2,$start,$end,$1,undef,''));
1.88 raeburn 1387: }
1388: }
1.64 www 1389: } else {
1.102 albertel 1390: $r->print('<p>'.&mt('ERROR').': '.&mt('Unknown command').' <tt>'.$_.'</tt></p><br />');
1.64 www 1391: }
1.113 raeburn 1392: foreach my $key (sort(keys(%disallowed))) {
1393: if (($key eq 'none') || ($key eq 'all')) {
1394: $r->print('<p>'.&mt('[_1] may not be used as the name for a section, as it is a reserved word.',$key));
1395: } else {
1396: $r->print('<p>'.&mt('[_1] may not be used as the name for a section, as it is the name of a course group.',$key));
1397: }
1398: $r->print(' '.&mt('Please <a href="javascript:history.go(-1)">go back</a> and choose a different section name.').'</p><br />');
1399: }
1400: }
1.101 albertel 1401: } # End of foreach (keys(%env))
1.75 www 1402: # Flush the course logs so reverse user roles immediately updated
1403: &Apache::lonnet::flushcourselogs();
1.103 albertel 1404: $r->print('<p><a href="/adm/createuser">Create/Modify Another User</a></p>');
1.110 albertel 1405: $r->print(&Apache::loncommon::end_page());
1.4 www 1406: }
1407:
1.88 raeburn 1408: sub commit_customrole {
1.99 raeburn 1409: my ($udom,$uname,$url,$three,$four,$five,$start,$end) = @_;
1.88 raeburn 1410: my $output = &mt('Assigning custom role').' "'.$five.'" by '.$four.'@'.$three.' in '.$url.
1411: ($start?', '.&mt('starting').' '.localtime($start):'').
1412: ($end?', ending '.localtime($end):'').': <b>'.
1413: &Apache::lonnet::assigncustomrole(
1.99 raeburn 1414: $udom,$uname,$url,$three,$four,$five,$end,$start).
1.102 albertel 1415: '</b><br />';
1.88 raeburn 1416: return $output;
1417: }
1418:
1419: sub commit_standardrole {
1.99 raeburn 1420: my ($udom,$uname,$url,$three,$start,$end,$one,$two,$sec) = @_;
1.89 raeburn 1421: my $output;
1422: my $logmsg;
1423: if ($three eq 'st') {
1.99 raeburn 1424: my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec);
1.89 raeburn 1425: if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) {
1426: $output = "Error: $result\n";
1427: } else {
1428: $output = &mt('Assigning').' '.$three.' in '.$url.
1429: ($start?', '.&mt('starting').' '.localtime($start):'').
1430: ($end?', '.&mt('ending').' '.localtime($end):'').
1431: ': <b>'.$result.'</b><br />'.
1432: &mt('Add to classlist').': <b>ok</b><br />';
1433: }
1434: } else {
1.92 raeburn 1435: $output = &mt('Assigning').' '.$three.' in '.$url.
1.89 raeburn 1436: ($start?', '.&mt('starting').' '.localtime($start):'').
1437: ($end?', '.&mt('ending').' '.localtime($end):'').': <b>'.
1438: &Apache::lonnet::assignrole(
1.99 raeburn 1439: $udom,$uname,$url,$three,$end,$start).
1.102 albertel 1440: '</b><br />';
1.88 raeburn 1441: }
1442: return $output;
1443: }
1444:
1.89 raeburn 1445: sub commit_studentrole {
1.99 raeburn 1446: my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec) = @_;
1.89 raeburn 1447: my $linefeed = '<br />'."\n";
1448: my $result;
1449: if (defined($one) && defined($two)) {
1450: my $cid=$one.'_'.$two;
1451: my $oldsec=&Apache::lonnet::getsection($udom,$uname,$cid);
1452: my $secchange = 0;
1453: my $expire_role_result;
1454: my $modify_section_result;
1455: unless ($oldsec eq '-1') {
1456: unless ($sec eq $oldsec) {
1457: $secchange = 1;
1458: my $uurl='/'.$cid;
1459: $uurl=~s/\_/\//g;
1460: if ($oldsec) {
1461: $uurl.='/'.$oldsec;
1462: }
1463: $expire_role_result = &Apache::lonnet::assignrole($udom,$uname,$uurl,'st',time);
1464: $result = $expire_role_result;
1465: }
1466: }
1467: if (($expire_role_result eq 'ok') || ($secchange == 0)) {
1468: $modify_section_result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,'','',$cid);
1469: if ($modify_section_result =~ /^ok/) {
1470: if ($secchange == 1) {
1471: $$logmsg .= "Section for $uname switched from old section: $oldsec to new section: $sec".$linefeed;
1472: } elsif ($oldsec eq '-1') {
1473: $$logmsg .= "New student role for $uname in section $sec in course $cid".$linefeed;
1474: } else {
1475: $$logmsg .= "Student $uname assigned to unchanged section $sec in course $cid".$linefeed;
1476: }
1477: } else {
1478: $$logmsg .= "Error when attempting section change for $uname from old section $oldsec to new section: $sec in course $cid -error: $modify_section_result".$linefeed;
1479: }
1480: $result = $modify_section_result;
1481: } elsif ($secchange == 1) {
1482: $$logmsg .= "Error when attempting to expire role for $uname in old section $oldsec in course $cid -error: $expire_role_result".$linefeed;
1483: }
1484: } else {
1485: $$logmsg .= "Incomplete course id defined. Addition of user $uname from domain $udom to course $one\_$two, section $sec not completed.$linefeed";
1.113 raeburn 1486: $result = "error: incomplete course id\n";
1.89 raeburn 1487: }
1488: return $result;
1489: }
1.88 raeburn 1490:
1491: sub build_roles {
1.89 raeburn 1492: my ($sectionstr,$sections,$role) = @_;
1.88 raeburn 1493: my $num_sections = 0;
1494: if ($sectionstr=~ /,/) {
1495: my @secnums = split/,/,$sectionstr;
1.89 raeburn 1496: if ($role eq 'st') {
1497: $secnums[0] =~ s/\W//g;
1498: $$sections{$secnums[0]} = 1;
1499: $num_sections = 1;
1500: } else {
1501: foreach my $sec (@secnums) {
1502: $sec =~ ~s/\W//g;
1503: unless ($sec eq "") {
1504: if (exists($$sections{$sec})) {
1505: $$sections{$sec} ++;
1506: } else {
1507: $$sections{$sec} = 1;
1508: $num_sections ++;
1509: }
1.88 raeburn 1510: }
1511: }
1512: }
1513: } else {
1514: $sectionstr=~s/\W//g;
1515: unless ($sectionstr eq '') {
1516: $$sections{$sectionstr} = 1;
1517: $num_sections ++;
1518: }
1519: }
1520:
1521: return $num_sections;
1522: }
1523:
1.58 www 1524: # ========================================================== Custom Role Editor
1525:
1526: sub custom_role_editor {
1527: my $r=shift;
1.101 albertel 1528: my $rolename=$env{'form.rolename'};
1.58 www 1529:
1.59 www 1530: if ($rolename eq 'make new role') {
1.101 albertel 1531: $rolename=$env{'form.newrolename'};
1.59 www 1532: }
1533:
1.63 www 1534: $rolename=~s/[^A-Za-z0-9]//gs;
1.58 www 1535:
1536: unless ($rolename) {
1537: &print_username_entry_form($r);
1538: return;
1539: }
1540:
1.110 albertel 1541: $r->print(&Apache::loncommon::start_page('Custom Role Editor'));
1.61 www 1542: my $syspriv='';
1543: my $dompriv='';
1544: my $coursepriv='';
1.59 www 1545: my ($rdummy,$roledef)=
1546: &Apache::lonnet::get('roles',["rolesdef_$rolename"]);
1.60 www 1547: # ------------------------------------------------------- Does this role exist?
1.110 albertel 1548: $r->print('<h2>');
1.59 www 1549: if (($rdummy ne 'con_lost') && ($roledef ne '')) {
1.73 sakharuk 1550: $r->print(&mt('Existing Role').' "');
1.61 www 1551: # ------------------------------------------------- Get current role privileges
1552: ($syspriv,$dompriv,$coursepriv)=split(/\_/,$roledef);
1.59 www 1553: } else {
1.73 sakharuk 1554: $r->print(&mt('New Role').' "');
1.59 www 1555: $roledef='';
1556: }
1557: $r->print($rolename.'"</h2>');
1.60 www 1558: # ------------------------------------------------------- What can be assigned?
1559: my %full=();
1560: my %courselevel=();
1.61 www 1561: my %courselevelcurrent=();
1.60 www 1562: foreach (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
1563: my ($priv,$restrict)=split(/\&/,$_);
1564: unless ($restrict) { $restrict='F'; }
1565: $courselevel{$priv}=$restrict;
1.61 www 1566: if ($coursepriv=~/\:$priv/) {
1567: $courselevelcurrent{$priv}=1;
1568: }
1.60 www 1569: $full{$priv}=1;
1570: }
1571: my %domainlevel=();
1.61 www 1572: my %domainlevelcurrent=();
1.60 www 1573: foreach (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
1574: my ($priv,$restrict)=split(/\&/,$_);
1575: unless ($restrict) { $restrict='F'; }
1576: $domainlevel{$priv}=$restrict;
1.61 www 1577: if ($dompriv=~/\:$priv/) {
1578: $domainlevelcurrent{$priv}=1;
1579: }
1.60 www 1580: $full{$priv}=1;
1581: }
1.61 www 1582: my %systemlevel=();
1583: my %systemlevelcurrent=();
1584: foreach (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
1585: my ($priv,$restrict)=split(/\&/,$_);
1586: unless ($restrict) { $restrict='F'; }
1587: $systemlevel{$priv}=$restrict;
1588: if ($syspriv=~/\:$priv/) {
1589: $systemlevelcurrent{$priv}=1;
1590: }
1591: $full{$priv}=1;
1592: }
1.73 sakharuk 1593: my %lt=&Apache::lonlocal::texthash(
1594: 'prv' => "Privilege",
1595: 'crl' => "Course Level",
1596: 'dml' => "Domain Level",
1597: 'ssl' => "System Level"
1598: );
1.61 www 1599: $r->print(<<ENDCCF);
1600: <form method="post">
1601: <input type="hidden" name="phase" value="set_custom_roles" />
1602: <input type="hidden" name="rolename" value="$rolename" />
1603: <table border="2">
1.73 sakharuk 1604: <tr><th>$lt{'prv'}</th><th>$lt{'crl'}</th><th>$lt{'dml'}</th>
1605: <th>$lt{'ssl'}</th></tr>
1.61 www 1606: ENDCCF
1.60 www 1607: foreach (sort keys %full) {
1608: $r->print('<tr><td>'.&Apache::lonnet::plaintext($_).'</td><td>'.
1.61 www 1609: ($courselevel{$_}?'<input type="checkbox" name="'.$_.':c" '.
1610: ($courselevelcurrent{$_}?'checked="1"':'').' />':' ').
1611: '</td><td>'.
1612: ($domainlevel{$_}?'<input type="checkbox" name="'.$_.':d" '.
1613: ($domainlevelcurrent{$_}?'checked="1"':'').' />':' ').
1614: '</td><td>'.
1615: ($systemlevel{$_}?'<input type="checkbox" name="'.$_.':s" '.
1616: ($systemlevelcurrent{$_}?'checked="1"':'').' />':' ').
1617: '</td></tr>');
1.60 www 1618: }
1.61 www 1619: $r->print(
1.110 albertel 1620: '<table><input type="submit" value="'.&mt('Define Role').'" /></form>'.
1621: &Apache::loncommon::end_page());
1.61 www 1622: }
1623:
1624: # ---------------------------------------------------------- Call to definerole
1625: sub set_custom_role {
1.110 albertel 1626: my ($r) = @_;
1.61 www 1627:
1.101 albertel 1628: my $rolename=$env{'form.rolename'};
1.61 www 1629:
1.63 www 1630: $rolename=~s/[^A-Za-z0-9]//gs;
1.61 www 1631:
1632: unless ($rolename) {
1633: &print_username_entry_form($r);
1634: return;
1635: }
1636:
1.110 albertel 1637: $r->print(&Apache::loncommon::start_page('Save Custom Role').'<h2>');
1.61 www 1638: my ($rdummy,$roledef)=
1.110 albertel 1639: &Apache::lonnet::get('roles',["rolesdef_$rolename"]);
1640:
1.61 www 1641: # ------------------------------------------------------- Does this role exist?
1642: if (($rdummy ne 'con_lost') && ($roledef ne '')) {
1.73 sakharuk 1643: $r->print(&mt('Existing Role').' "');
1.61 www 1644: } else {
1.73 sakharuk 1645: $r->print(&mt('New Role').' "');
1.61 www 1646: $roledef='';
1647: }
1648: $r->print($rolename.'"</h2>');
1649: # ------------------------------------------------------- What can be assigned?
1650: my $sysrole='';
1651: my $domrole='';
1652: my $courole='';
1653:
1654: foreach (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
1655: my ($priv,$restrict)=split(/\&/,$_);
1656: unless ($restrict) { $restrict=''; }
1.101 albertel 1657: if ($env{'form.'.$priv.':c'}) {
1.61 www 1658: $courole.=':'.$_;
1659: }
1660: }
1661:
1662: foreach (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
1663: my ($priv,$restrict)=split(/\&/,$_);
1664: unless ($restrict) { $restrict=''; }
1.101 albertel 1665: if ($env{'form.'.$priv.':d'}) {
1.61 www 1666: $domrole.=':'.$_;
1667: }
1668: }
1669:
1670: foreach (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
1671: my ($priv,$restrict)=split(/\&/,$_);
1672: unless ($restrict) { $restrict=''; }
1.101 albertel 1673: if ($env{'form.'.$priv.':s'}) {
1.61 www 1674: $sysrole.=':'.$_;
1675: }
1676: }
1.63 www 1677: $r->print('<br />Defining Role: '.
1.61 www 1678: &Apache::lonnet::definerole($rolename,$sysrole,$domrole,$courole));
1.101 albertel 1679: if ($env{'request.course.id'}) {
1680: my $url='/'.$env{'request.course.id'};
1.63 www 1681: $url=~s/\_/\//g;
1.73 sakharuk 1682: $r->print('<br />'.&mt('Assigning Role to Self').': '.
1.101 albertel 1683: &Apache::lonnet::assigncustomrole($env{'user.domain'},
1684: $env{'user.name'},
1.63 www 1685: $url,
1.101 albertel 1686: $env{'user.domain'},
1687: $env{'user.name'},
1.63 www 1688: $rolename));
1689: }
1.109 albertel 1690: $r->print('<p><a href="/adm/createuser">Create another role, or Create/Modify a user.</a></p>');
1.110 albertel 1691: $r->print(&Apache::loncommon::end_page());
1.58 www 1692: }
1693:
1.2 www 1694: # ================================================================ Main Handler
1695: sub handler {
1696: my $r = shift;
1697:
1698: if ($r->header_only) {
1.68 www 1699: &Apache::loncommon::content_type($r,'text/html');
1.2 www 1700: $r->send_http_header;
1701: return OK;
1702: }
1703:
1.101 albertel 1704: if ((&Apache::lonnet::allowed('cta',$env{'request.course.id'})) ||
1705: (&Apache::lonnet::allowed('cin',$env{'request.course.id'})) ||
1706: (&Apache::lonnet::allowed('ccr',$env{'request.course.id'})) ||
1707: (&Apache::lonnet::allowed('cep',$env{'request.course.id'})) ||
1.104 albertel 1708: (&authorpriv($env{'user.name'},$env{'request.role.domain'})) ||
1.101 albertel 1709: (&Apache::lonnet::allowed('mau',$env{'request.role.domain'}))) {
1.68 www 1710: &Apache::loncommon::content_type($r,'text/html');
1.2 www 1711: $r->send_http_header;
1.101 albertel 1712: unless ($env{'form.phase'}) {
1.42 matthew 1713: &print_username_entry_form($r);
1.2 www 1714: }
1.101 albertel 1715: if ($env{'form.phase'} eq 'get_user_info') {
1.42 matthew 1716: &print_user_modification_page($r);
1.101 albertel 1717: } elsif ($env{'form.phase'} eq 'update_user_data') {
1.42 matthew 1718: &update_user_data($r);
1.101 albertel 1719: } elsif ($env{'form.phase'} eq 'selected_custom_edit') {
1.58 www 1720: &custom_role_editor($r);
1.101 albertel 1721: } elsif ($env{'form.phase'} eq 'set_custom_roles') {
1.61 www 1722: &set_custom_role($r);
1.2 www 1723: }
1.1 www 1724: } else {
1.101 albertel 1725: $env{'user.error.msg'}=
1.9 albertel 1726: "/adm/createuser:mau:0:0:Cannot modify user data";
1.1 www 1727: return HTTP_NOT_ACCEPTABLE;
1728: }
1729: return OK;
1730: }
1.26 matthew 1731:
1.27 matthew 1732: #-------------------------------------------------- functions for &phase_two
1.26 matthew 1733: sub course_level_table {
1.89 raeburn 1734: my (%inccourses) = @_;
1.26 matthew 1735: my $table = '';
1.62 www 1736: # Custom Roles?
1737:
1738: my %customroles=&my_custom_roles();
1.89 raeburn 1739: my %lt=&Apache::lonlocal::texthash(
1740: 'exs' => "Existing sections",
1741: 'new' => "Define new section",
1742: 'ssd' => "Set Start Date",
1743: 'sed' => "Set End Date",
1744: 'crl' => "Course Level",
1745: 'act' => "Activate",
1746: 'rol' => "Role",
1747: 'ext' => "Extent",
1.113 raeburn 1748: 'grs' => "Section",
1.89 raeburn 1749: 'sta' => "Start",
1750: 'end' => "End"
1751: );
1.62 www 1752:
1.26 matthew 1753: foreach (sort( keys(%inccourses))) {
1754: my $thiscourse=$_;
1755: my $protectedcourse=$_;
1756: $thiscourse=~s:_:/:g;
1757: my %coursedata=&Apache::lonnet::coursedescription($thiscourse);
1758: my $area=$coursedata{'description'};
1.72 sakharuk 1759: if (!defined($area)) { $area=&mt('Unavailable course').': '.$_; }
1.26 matthew 1760: my $bgcol=$thiscourse;
1.62 www 1761: $bgcol=~s/[^7-9a-e]//g;
1762: $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',2,6);
1.89 raeburn 1763: my ($domain,$cnum)=split(/\//,$thiscourse);
1764: my %sections_count = ();
1.92 raeburn 1765: my $num_sections = 0;
1.101 albertel 1766: if (defined($env{'request.course.id'})) {
1767: if ($env{'request.course.id'} eq $domain.'_'.$cnum) {
1.92 raeburn 1768: $num_sections = &Apache::loncommon::get_sections($domain,$cnum,\%sections_count);
1769: }
1770: }
1.26 matthew 1771: foreach ('st','ta','ep','ad','in','cc') {
1772: if (&Apache::lonnet::allowed('c'.$_,$thiscourse)) {
1773: my $plrole=&Apache::lonnet::plaintext($_);
1774: $table .= <<ENDEXTENT;
1775: <tr bgcolor="#$bgcol">
1776: <td><input type="checkbox" name="act_$protectedcourse\_$_"></td>
1777: <td>$plrole</td>
1.82 albertel 1778: <td>$area<br />Domain: $domain</td>
1.26 matthew 1779: ENDEXTENT
1780: if ($_ ne 'cc') {
1.89 raeburn 1781: if ($num_sections > 0) {
1782: my $currsec = &course_sections($num_sections,\%sections_count,$protectedcourse.'_'.$_);
1783: $table .=
1784: '<td><table border="0" cellspacing="0" cellpadding="0">'.
1785: '<tr><td valign="top">'.$lt{'exs'}.'<br />'.
1786: $currsec.'</td>'.
1787: '<td> </td>'.
1788: '<td valign="top"> '.$lt{'new'}.'<br />'.
1789: '<input type="text" name="newsec_'.$protectedcourse.'_'.$_.'" value="" /></td>'.
1790: '<input type="hidden" '.
1791: 'name="sec_'.$protectedcourse.'_'.$_.'"></td>'.
1792: '</tr></table></td>';
1793: } else {
1794: $table .= '<td><input type="text" size="10" '.
1795: 'name="sec_'.$protectedcourse.'_'.$_.'"></td>';
1796: }
1.26 matthew 1797: } else {
1.89 raeburn 1798: $table .= '<td> </td>';
1.26 matthew 1799: }
1800: $table .= <<ENDTIMEENTRY;
1801: <td><input type=hidden name="start_$protectedcourse\_$_" value=''>
1802: <a href=
1.73 sakharuk 1803: "javascript:pjump('date_start','Start Date $plrole',document.cu.start_$protectedcourse\_$_.value,'start_$protectedcourse\_$_','cu.pres','dateset')">$lt{'ssd'}</a></td>
1.26 matthew 1804: <td><input type=hidden name="end_$protectedcourse\_$_" value=''>
1805: <a href=
1.73 sakharuk 1806: "javascript:pjump('date_end','End Date $plrole',document.cu.end_$protectedcourse\_$_.value,'end_$protectedcourse\_$_','cu.pres','dateset')">$lt{'sed'}</a></td>
1.26 matthew 1807: ENDTIMEENTRY
1808: $table.= "</tr>\n";
1809: }
1810: }
1.62 www 1811: foreach (sort keys %customroles) {
1.65 www 1812: if (&Apache::lonnet::allowed('ccr',$thiscourse)) {
1813: my $plrole=$_;
1.101 albertel 1814: my $customrole=$protectedcourse.'_cr_cr_'.$env{'user.domain'}.
1815: '_'.$env{'user.name'}.'_'.$plrole;
1.89 raeburn 1816: $table .= <<END;
1.62 www 1817: <tr bgcolor="#$bgcol">
1.65 www 1818: <td><input type="checkbox" name="act_$customrole"></td>
1.62 www 1819: <td>$plrole</td>
1820: <td>$area</td>
1.89 raeburn 1821: END
1822: if ($num_sections > 0) {
1823: my $currsec = &course_sections($num_sections,\%sections_count,$customrole);
1824: $table.=
1825: '<td><table border="0" cellspacing="0" cellpadding="0">'.
1826: '<tr><td valign="top">'.$lt{'exs'}.'<br />'.
1827: $currsec.'</td>'.
1828: '<td> </td>'.
1829: '<td valign="top"> '.$lt{'new'}.'<br />'.
1830: '<input type="text" name="newsec_'.$customrole.'" value="" /></td>'.
1831: '<input type="hidden" '.
1832: 'name="sec_'.$customrole.'"></td>'.
1833: '</tr></table></td>';
1834: } else {
1835: $table .= '<td><input type="text" size="10" '.
1836: 'name="sec_'.$customrole.'"></td>';
1837: }
1838: $table .= <<ENDENTRY;
1.65 www 1839: <td><input type=hidden name="start_$customrole" value=''>
1.62 www 1840: <a href=
1.73 sakharuk 1841: "javascript:pjump('date_start','Start Date $plrole',document.cu.start_$customrole.value,'start_$customrole','cu.pres','dateset')">$lt{'ssd'}</a></td>
1.65 www 1842: <td><input type=hidden name="end_$customrole" value=''>
1.62 www 1843: <a href=
1.73 sakharuk 1844: "javascript:pjump('date_end','End Date $plrole',document.cu.end_$customrole.value,'end_$customrole','cu.pres','dateset')">$lt{'sed'}</a></td></tr>
1.62 www 1845: ENDENTRY
1.65 www 1846: }
1.62 www 1847: }
1.26 matthew 1848: }
1849: return '' if ($table eq ''); # return nothing if there is nothing
1850: # in the table
1851: my $result = <<ENDTABLE;
1.73 sakharuk 1852: <h4>$lt{'crl'}</h4>
1853: <table border=2><tr><th>$lt{'act'}</th><th>$lt{'rol'}</th><th>$lt{'ext'}</th>
1854: <th>$lt{'grs'}</th><th>$lt{'sta'}</th><th>$lt{'end'}</th></tr>
1.26 matthew 1855: $table
1856: </table>
1857: ENDTABLE
1858: return $result;
1859: }
1.88 raeburn 1860:
1.89 raeburn 1861: sub course_sections {
1862: my ($num_sections,$sections_count,$role) = @_;
1863: my $output = '';
1864: my @sections = (sort {$a <=> $b} keys %{$sections_count});
1.92 raeburn 1865: if ($num_sections == 1) {
1866: $output = '<select name="currsec_'.$role.'" >'."\n".
1867: ' <option value="">Select</option>'."\n".
1.93 raeburn 1868: ' <option value="">No section</option>'."\n".
1.92 raeburn 1869: ' <option value="'.$sections[0].'" >'.$sections[0].'</option>'."\n";
1870: } else {
1871: $output = '<select name="currsec_'.$role.'" ';
1872: my $multiple = 4;
1873: if ($num_sections <4) { $multiple = $num_sections; }
1.95 albertel 1874: $output .= '"multiple" size="'.$multiple.'">'."\n";
1.92 raeburn 1875: foreach (@sections) {
1876: $output .= '<option value="'.$_.'">'.$_."</option>\n";
1877: }
1.89 raeburn 1878: }
1879: $output .= '</select>';
1880: return $output;
1881: }
1882:
1.88 raeburn 1883: sub course_level_dc {
1884: my ($dcdom) = @_;
1885: my %customroles=&my_custom_roles();
1886: my $hiddenitems = '<input type="hidden" name="dcdomain" value="'.$dcdom.'" />'.
1887: '<input type="hidden" name="origdom" value="'.$dcdom.'" />'.
1888: '<input type="hidden" name="dccourse" value="" />';
1889: my $courseform='<b>'.&Apache::loncommon::selectcourse_link
1890: ('cu','dccourse','dcdomain','coursedesc').'</b>';
1891:
1892: my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,$dcdom);
1893: my %lt=&Apache::lonlocal::texthash(
1894: 'crl' => "Course Level",
1895: 'crt' => "Course Title",
1896: 'rol' => "Role",
1.113 raeburn 1897: 'grs' => "Section",
1.88 raeburn 1898: 'exs' => "Existing sections",
1899: 'new' => "Define new section",
1900: 'sta' => "Start",
1901: 'end' => "End",
1902: 'ssd' => "Set Start Date",
1903: 'sed' => "Set End Date"
1904: );
1905: my $header = '<h4>'.$lt{'crl'}.'</h4>'.
1906: '<table border="2"><tr><th>'.$courseform.'</th><th>'.$lt{'rol'}.'</th><th>'.$lt{'grs'}.'</th><th>'.$lt{'sta'}.'</th><th>'.$lt{'end'}.'</th></tr>';
1.89 raeburn 1907: my $otheritems = '<tr><td><input type="text" name="coursedesc" value="" onFocus="this.blur();opencrsbrowser('."'".'cu'."'".','."'".'dccourse'."'".','."'".'dcdomain'."'".','."'".'coursedesc'."',''".')" /></td>'.
1.88 raeburn 1908: '<td><select name="role">'."\n";
1909: foreach ('st','ta','ep','ad','in','cc') {
1910: my $plrole=&Apache::lonnet::plaintext($_);
1911: $otheritems .= ' <option value="'.$_.'">'.$plrole;
1912: }
1913: if ( keys %customroles > 0) {
1914: foreach (sort keys %customroles) {
1.101 albertel 1915: my $custrole='cr_cr_'.$env{'user.domain'}.
1916: '_'.$env{'user.name'}.'_'.$_;
1.88 raeburn 1917: $otheritems .= ' <option value="'.$custrole.'">'.$_;
1918: }
1919: }
1920: $otheritems .= '</select></td><td>'.
1921: '<table border="0" cellspacing="0" cellpadding="0">'.
1922: '<tr><td valign="top"><b>'.$lt{'exs'}.'</b><br /><select name="currsec">'.
1923: ' <option value=""><--'.&mt('Pick course first').'</select></td>'.
1924: '<td> </td>'.
1925: '<td valign="top"> <b>'.$lt{'new'}.'</b><br />'.
1.113 raeburn 1926: '<input type="text" name="newsec" value="" />'.
1927: '<input type="hidden" name="groups" value="" /></td>'.
1.88 raeburn 1928: '</tr></table></td>';
1929: $otheritems .= <<ENDTIMEENTRY;
1930: <td><input type=hidden name="start" value=''>
1931: <a href=
1932: "javascript:pjump('date_start','Start Date',document.cu.start.value,'start','cu.pres','dateset')">$lt{'ssd'}</a></td>
1933: <td><input type=hidden name="end" value=''>
1934: <a href=
1935: "javascript:pjump('date_end','End Date',document.cu.end.value,'end','cu.pres','dateset')">$lt{'sed'}</a></td>
1936: ENDTIMEENTRY
1937: $otheritems .= "</tr></table>\n";
1938: return $cb_jscript.$header.$hiddenitems.$otheritems;
1939: }
1940:
1.27 matthew 1941: #---------------------------------------------- end functions for &phase_two
1.29 matthew 1942:
1943: #--------------------------------- functions for &phase_two and &phase_three
1944:
1945: #--------------------------end of functions for &phase_two and &phase_three
1.1 www 1946:
1947: 1;
1948: __END__
1.2 www 1949:
1950:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>