Annotation of loncom/interface/loncreateuser.pm, revision 1.115
1.20 harris41 1: # The LearningOnline Network with CAPA
1.1 www 2: # Create a user
3: #
1.115 ! albertel 4: # $Id: loncreateuser.pm,v 1.114 2006/05/09 14:38:10 albertel 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.88 raeburn 977:
1.101 albertel 978: if ($env{'request.role'} =~ m-^dc\./(\w+)/$-) {
1.88 raeburn 979: $r->print(&course_level_dc($1));
980: $r->print('<hr /><input type="button" value="'.&mt('Modify User').'" onClick="setCourse()">'."\n");
981: } else {
982: $r->print(&course_level_table(%inccourses));
1.89 raeburn 983: $r->print('<hr /><input type="button" value="'.&mt('Modify User').'" onClick="setSections()">'."\n");
1.88 raeburn 984: }
1.110 albertel 985: $r->print("</form>".&Apache::loncommon::end_page());
1.2 www 986: }
1.1 www 987:
1.4 www 988: # ================================================================= Phase Three
1.42 matthew 989: sub update_user_data {
1.4 www 990: my $r=shift;
1.101 albertel 991: my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'},
992: $env{'form.ccdomain'});
1.27 matthew 993: # Error messages
1.73 sakharuk 994: my $error = '<font color="#ff0000">'.&mt('Error').':</font>';
1.110 albertel 995: my $end = &Apache::loncommon::end_page();
996:
1.40 www 997: my $title;
1.101 albertel 998: if (exists($env{'form.makeuser'})) {
1.40 www 999: $title='Set Privileges for New User';
1000: } else {
1001: $title='Modify User Privileges';
1002: }
1.110 albertel 1003: $r->print(&Apache::loncommon::start_page($title));
1.113 raeburn 1004: my %disallowed;
1.27 matthew 1005: # Check Inputs
1.101 albertel 1006: if (! $env{'form.ccuname'} ) {
1.73 sakharuk 1007: $r->print($error.&mt('No login name specified').'.'.$end);
1.27 matthew 1008: return;
1009: }
1.101 albertel 1010: if ( $env{'form.ccuname'} =~/\W/) {
1.73 sakharuk 1011: $r->print($error.&mt('Invalid login name').'. '.
1012: &mt('Only letters, numbers, and underscores are valid').'.'.
1.27 matthew 1013: $end);
1014: return;
1015: }
1.101 albertel 1016: if (! $env{'form.ccdomain'} ) {
1.73 sakharuk 1017: $r->print($error.&mt('No domain specified').'.'.$end);
1.27 matthew 1018: return;
1019: }
1.101 albertel 1020: if ( $env{'form.ccdomain'} =~/\W/) {
1.73 sakharuk 1021: $r->print($error.&mt ('Invalid domain name').'. '.
1022: &mt('Only letters, numbers, and underscores are valid').'.'.
1.27 matthew 1023: $end);
1024: return;
1025: }
1.101 albertel 1026: if (! exists($env{'form.makeuser'})) {
1.29 matthew 1027: # Modifying an existing user, so check the validity of the name
1028: if ($uhome eq 'no_host') {
1.73 sakharuk 1029: $r->print($error.&mt('Unable to determine home server for ').
1.101 albertel 1030: $env{'form.ccuname'}.&mt(' in domain ').
1031: $env{'form.ccdomain'}.'.');
1.29 matthew 1032: return;
1033: }
1034: }
1.27 matthew 1035: # Determine authentication method and password for the user being modified
1036: my $amode='';
1037: my $genpwd='';
1.101 albertel 1038: if ($env{'form.login'} eq 'krb') {
1.41 albertel 1039: $amode='krb';
1.101 albertel 1040: $amode.=$env{'form.krbver'};
1041: $genpwd=$env{'form.krbarg'};
1042: } elsif ($env{'form.login'} eq 'int') {
1.27 matthew 1043: $amode='internal';
1.101 albertel 1044: $genpwd=$env{'form.intarg'};
1045: } elsif ($env{'form.login'} eq 'fsys') {
1.27 matthew 1046: $amode='unix';
1.101 albertel 1047: $genpwd=$env{'form.fsysarg'};
1048: } elsif ($env{'form.login'} eq 'loc') {
1.27 matthew 1049: $amode='localauth';
1.101 albertel 1050: $genpwd=$env{'form.locarg'};
1.27 matthew 1051: $genpwd=" " if (!$genpwd);
1.101 albertel 1052: } elsif (($env{'form.login'} eq 'nochange') ||
1053: ($env{'form.login'} eq '' )) {
1.34 matthew 1054: # There is no need to tell the user we did not change what they
1055: # did not ask us to change.
1.35 matthew 1056: # If they are creating a new user but have not specified login
1057: # information this will be caught below.
1.30 matthew 1058: } else {
1.73 sakharuk 1059: $r->print($error.&mt('Invalid login mode or password').$end);
1.30 matthew 1060: return;
1.27 matthew 1061: }
1.101 albertel 1062: if ($env{'form.makeuser'}) {
1.27 matthew 1063: # Create a new user
1.73 sakharuk 1064: my %lt=&Apache::lonlocal::texthash(
1065: 'cru' => "Creating user",
1066: 'id' => "in domain"
1067: );
1.27 matthew 1068: $r->print(<<ENDNEWUSERHEAD);
1.101 albertel 1069: <h3>$lt{'cru'} "$env{'form.ccuname'}" $lt{'id'} "$env{'form.ccdomain'}"</h3>
1.27 matthew 1070: ENDNEWUSERHEAD
1071: # Check for the authentication mode and password
1072: if (! $amode || ! $genpwd) {
1.73 sakharuk 1073: $r->print($error.&mt('Invalid login mode or password').$end);
1.27 matthew 1074: return;
1.18 albertel 1075: }
1.29 matthew 1076: # Determine desired host
1.101 albertel 1077: my $desiredhost = $env{'form.hserver'};
1.29 matthew 1078: if (lc($desiredhost) eq 'default') {
1079: $desiredhost = undef;
1080: } else {
1.39 matthew 1081: my %home_servers = &Apache::loncommon::get_library_servers
1.101 albertel 1082: ($env{'form.ccdomain'});
1.29 matthew 1083: if (! exists($home_servers{$desiredhost})) {
1.73 sakharuk 1084: $r->print($error.&mt('Invalid home server specified'));
1.29 matthew 1085: return;
1086: }
1087: }
1.27 matthew 1088: # Call modifyuser
1089: my $result = &Apache::lonnet::modifyuser
1.101 albertel 1090: ($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cstid'},
1091: $amode,$genpwd,$env{'form.cfirst'},
1092: $env{'form.cmiddle'},$env{'form.clast'},$env{'form.cgen'},
1.29 matthew 1093: undef,$desiredhost
1.27 matthew 1094: );
1.77 www 1095: $r->print(&mt('Generating user').': '.$result);
1.101 albertel 1096: my $home = &Apache::lonnet::homeserver($env{'form.ccuname'},
1097: $env{'form.ccdomain'});
1.77 www 1098: $r->print('<br />'.&mt('Home server').': '.$home.' '.
1.29 matthew 1099: $Apache::lonnet::libserv{$home});
1.101 albertel 1100: } elsif (($env{'form.login'} ne 'nochange') &&
1101: ($env{'form.login'} ne '' )) {
1.27 matthew 1102: # Modify user privileges
1.73 sakharuk 1103: my %lt=&Apache::lonlocal::texthash(
1104: 'usr' => "User",
1105: 'id' => "in domain"
1106: );
1.27 matthew 1107: $r->print(<<ENDMODIFYUSERHEAD);
1.101 albertel 1108: <h2>$lt{'usr'} "$env{'form.ccuname'}" $lt{'id'} "$env{'form.ccdomain'}"</h2>
1.27 matthew 1109: ENDMODIFYUSERHEAD
1110: if (! $amode || ! $genpwd) {
1111: $r->print($error.'Invalid login mode or password'.$end);
1112: return;
1.20 harris41 1113: }
1.27 matthew 1114: # Only allow authentification modification if the person has authority
1.101 albertel 1115: if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
1.20 harris41 1116: $r->print('Modifying authentication: '.
1.31 matthew 1117: &Apache::lonnet::modifyuserauth(
1.101 albertel 1118: $env{'form.ccdomain'},$env{'form.ccuname'},
1.21 harris41 1119: $amode,$genpwd));
1.102 albertel 1120: $r->print('<br />'.&mt('Home server').': '.&Apache::lonnet::homeserver
1.101 albertel 1121: ($env{'form.ccuname'},$env{'form.ccdomain'}));
1.4 www 1122: } else {
1.27 matthew 1123: # Okay, this is a non-fatal error.
1.73 sakharuk 1124: $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.');
1.27 matthew 1125: }
1.28 matthew 1126: }
1127: ##
1.101 albertel 1128: if (! $env{'form.makeuser'} ) {
1.28 matthew 1129: # Check for need to change
1130: my %userenv = &Apache::lonnet::get
1131: ('environment',['firstname','middlename','lastname','generation'],
1.101 albertel 1132: $env{'form.ccdomain'},$env{'form.ccuname'});
1.28 matthew 1133: my ($tmp) = keys(%userenv);
1134: if ($tmp =~ /^(con_lost|error)/i) {
1135: %userenv = ();
1136: }
1137: # Check to see if we need to change user information
1138: foreach ('firstname','middlename','lastname','generation') {
1139: # Strip leading and trailing whitespace
1.101 albertel 1140: $env{'form.c'.$_} =~ s/(\s+$|^\s+)//g;
1.28 matthew 1141: }
1.101 albertel 1142: if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}) &&
1143: ($env{'form.cfirstname'} ne $userenv{'firstname'} ||
1144: $env{'form.cmiddlename'} ne $userenv{'middlename'} ||
1145: $env{'form.clastname'} ne $userenv{'lastname'} ||
1146: $env{'form.cgeneration'} ne $userenv{'generation'} )) {
1.28 matthew 1147: # Make the change
1148: my %changeHash;
1.101 albertel 1149: $changeHash{'firstname'} = $env{'form.cfirstname'};
1150: $changeHash{'middlename'} = $env{'form.cmiddlename'};
1151: $changeHash{'lastname'} = $env{'form.clastname'};
1152: $changeHash{'generation'} = $env{'form.cgeneration'};
1.28 matthew 1153: my $putresult = &Apache::lonnet::put
1154: ('environment',\%changeHash,
1.101 albertel 1155: $env{'form.ccdomain'},$env{'form.ccuname'});
1.28 matthew 1156: if ($putresult eq 'ok') {
1157: # Tell the user we changed the name
1.73 sakharuk 1158: my %lt=&Apache::lonlocal::texthash(
1159: 'uic' => "User Information Changed",
1160: 'frst' => "first",
1161: 'mddl' => "middle",
1162: 'lst' => "last",
1163: 'gen' => "generation",
1164: 'prvs' => "Previous",
1165: 'chto' => "Changed To"
1166: );
1.28 matthew 1167: $r->print(<<"END");
1168: <table border="2">
1.73 sakharuk 1169: <caption>$lt{'uic'}</caption>
1.28 matthew 1170: <tr><th> </th>
1.73 sakharuk 1171: <th>$lt{'frst'}</th>
1172: <th>$lt{'mddl'}</th>
1173: <th>$lt{'lst'}</th>
1174: <th>$lt{'gen'}</th></tr>
1175: <tr><td>$lt{'prvs'}</td>
1.28 matthew 1176: <td>$userenv{'firstname'} </td>
1177: <td>$userenv{'middlename'} </td>
1178: <td>$userenv{'lastname'} </td>
1179: <td>$userenv{'generation'} </td></tr>
1.73 sakharuk 1180: <tr><td>$lt{'chto'}</td>
1.101 albertel 1181: <td>$env{'form.cfirstname'} </td>
1182: <td>$env{'form.cmiddlename'} </td>
1183: <td>$env{'form.clastname'} </td>
1184: <td>$env{'form.cgeneration'} </td></tr>
1.28 matthew 1185: </table>
1186: END
1187: } else { # error occurred
1.73 sakharuk 1188: $r->print("<h2>".&mt('Unable to successfully change environment for')." ".
1.101 albertel 1189: $env{'form.ccuname'}." ".&mt('in domain')." ".
1190: $env{'form.ccdomain'}."</h2>");
1.28 matthew 1191: }
1.101 albertel 1192: } else { # End of if ($env ... ) logic
1.28 matthew 1193: # They did not want to change the users name but we can
1194: # still tell them what the name is
1.73 sakharuk 1195: my %lt=&Apache::lonlocal::texthash(
1196: 'usr' => "User",
1197: 'id' => "in domain",
1198: 'gen' => "Generation"
1199: );
1.28 matthew 1200: $r->print(<<"END");
1.101 albertel 1201: <h2>$lt{'usr'} "$env{'form.ccuname'}" $lt{'id'} "$env{'form.ccdomain'}"</h2>
1.28 matthew 1202: <h4>$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} </h4>
1.73 sakharuk 1203: <h4>$lt{'gen'}: $userenv{'generation'}</h4>
1.28 matthew 1204: END
1205: }
1.4 www 1206: }
1.27 matthew 1207: ##
1.4 www 1208: my $now=time;
1.73 sakharuk 1209: $r->print('<h3>'.&mt('Modifying Roles').'</h3>');
1.101 albertel 1210: foreach (keys (%env)) {
1211: next if (! $env{$_});
1.27 matthew 1212: # Revoke roles
1213: if ($_=~/^form\.rev/) {
1.64 www 1214: if ($_=~/^form\.rev\:([^\_]+)\_([^\_\.]+)$/) {
1215: # Revoke standard role
1.73 sakharuk 1216: $r->print(&mt('Revoking').' '.$2.' in '.$1.': <b>'.
1.101 albertel 1217: &Apache::lonnet::revokerole($env{'form.ccdomain'},
1.102 albertel 1218: $env{'form.ccuname'},$1,$2).'</b><br />');
1.53 www 1219: if ($2 eq 'st') {
1220: $1=~/^\/(\w+)\/(\w+)/;
1221: my $cid=$1.'_'.$2;
1.73 sakharuk 1222: $r->print(&mt('Drop from classlist').': <b>'.
1.53 www 1223: &Apache::lonnet::critical('put:'.
1.101 albertel 1224: $env{'course.'.$cid.'.domain'}.':'.
1225: $env{'course.'.$cid.'.num'}.':classlist:'.
1226: &Apache::lonnet::escape($env{'form.ccuname'}.':'.
1227: $env{'form.ccdomain'}).'='.
1.53 www 1228: &Apache::lonnet::escape($now.':'),
1.102 albertel 1229: $env{'course.'.$cid.'.home'}).'</b><br />');
1.53 www 1230: }
1231: }
1.64 www 1232: if ($_=~/^form\.rev\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
1233: # Revoke custom role
1.113 raeburn 1234: $r->print(&mt('Revoking custom role:').
1.73 sakharuk 1235: ' '.$4.' by '.$3.'@'.$2.' in '.$1.': <b>'.
1.101 albertel 1236: &Apache::lonnet::revokecustomrole($env{'form.ccdomain'},
1237: $env{'form.ccuname'},$1,$2,$3,$4).
1.102 albertel 1238: '</b><br />');
1.64 www 1239: }
1.53 www 1240: } elsif ($_=~/^form\.del/) {
1241: if ($_=~/^form\.del\:([^\_]+)\_([^\_]+)$/) {
1.73 sakharuk 1242: $r->print(&mt('Deleting').' '.$2.' in '.$1.': '.
1.101 albertel 1243: &Apache::lonnet::assignrole($env{'form.ccdomain'},
1.102 albertel 1244: $env{'form.ccuname'},$1,$2,$now,0,1).'<br />');
1.27 matthew 1245: if ($2 eq 'st') {
1246: $1=~/^\/(\w+)\/(\w+)/;
1247: my $cid=$1.'_'.$2;
1.73 sakharuk 1248: $r->print(&mt('Drop from classlist').': <b>'.
1.27 matthew 1249: &Apache::lonnet::critical('put:'.
1.101 albertel 1250: $env{'course.'.$cid.'.domain'}.':'.
1251: $env{'course.'.$cid.'.num'}.':classlist:'.
1252: &Apache::lonnet::escape($env{'form.ccuname'}.':'.
1253: $env{'form.ccdomain'}).'='.
1.27 matthew 1254: &Apache::lonnet::escape($now.':'),
1.102 albertel 1255: $env{'course.'.$cid.'.home'}).'</b><br />');
1.81 albertel 1256: }
1.113 raeburn 1257: }
1.81 albertel 1258: } elsif ($_=~/^form\.ren/) {
1.101 albertel 1259: my $udom = $env{'form.ccdomain'};
1260: my $uname = $env{'form.ccuname'};
1.81 albertel 1261: if ($_=~/^form\.ren\:([^\_]+)\_([^\_]+)$/) {
1.89 raeburn 1262: my $url = $1;
1263: my $role = $2;
1264: my $logmsg;
1265: my $output;
1266: if ($role eq 'st') {
1267: if ($url =~ m-^/(\w+)/(\w+)/?(\w*)$-) {
1.99 raeburn 1268: my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3);
1.89 raeburn 1269: if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) {
1270: $output = "Error: $result\n";
1271: } else {
1272: $output = &mt('Assigning').' '.$role.' in '.$url.
1273: &mt('starting').' '.localtime($now).
1274: ': <br />'.$logmsg.'<br />'.
1275: &mt('Add to classlist').': <b>ok</b><br />';
1276: }
1277: }
1278: } else {
1.101 albertel 1279: my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'},
1280: $env{'form.ccuname'},$url,$role,0,$now);
1.89 raeburn 1281: $output = &mt('Re-Enabling [_1] in [_2]: [_3]',
1282: $role,$url,$result).'<br />';
1.27 matthew 1283: }
1.89 raeburn 1284: $r->print($output);
1.113 raeburn 1285: }
1.27 matthew 1286: } elsif ($_=~/^form\.act/) {
1.101 albertel 1287: my $udom = $env{'form.ccdomain'};
1288: my $uname = $env{'form.ccuname'};
1.83 albertel 1289: if ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_cr_cr_([^\_]+)_(\w+)_([^\_]+)$/) {
1.65 www 1290: # Activate a custom role
1.83 albertel 1291: my ($one,$two,$three,$four,$five)=($1,$2,$3,$4,$5);
1292: my $url='/'.$one.'/'.$two;
1293: my $full=$one.'_'.$two.'_cr_cr_'.$three.'_'.$four.'_'.$five;
1.65 www 1294:
1.101 albertel 1295: my $start = ( $env{'form.start_'.$full} ?
1296: $env{'form.start_'.$full} :
1.88 raeburn 1297: $now );
1.101 albertel 1298: my $end = ( $env{'form.end_'.$full} ?
1299: $env{'form.end_'.$full} :
1.88 raeburn 1300: 0 );
1301:
1302: # split multiple sections
1303: my %sections = ();
1.101 albertel 1304: my $num_sections = &build_roles($env{'form.sec_'.$full},\%sections,$5);
1.88 raeburn 1305: if ($num_sections == 0) {
1.99 raeburn 1306: $r->print(&commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end));
1.88 raeburn 1307: } else {
1.114 albertel 1308: my %curr_groups =
1309: &Apache::loncommon::coursegroups($one,$two);
1.113 raeburn 1310: foreach my $sec (sort {$a cmp $b} keys %sections) {
1311: if (($sec eq 'none') || ($sec eq 'all') ||
1312: exists($curr_groups{$sec})) {
1313: $disallowed{$sec} = $url;
1314: next;
1315: }
1316: my $securl = $url.'/'.$sec;
1.99 raeburn 1317: $r->print(&commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end));
1.88 raeburn 1318: }
1319: }
1.98 albertel 1320: } elsif ($_=~/^form\.act\_([^\_]+)\_(\w+)\_([^\_]+)$/) {
1.27 matthew 1321: # Activate roles for sections with 3 id numbers
1322: # set start, end times, and the url for the class
1.83 albertel 1323: my ($one,$two,$three)=($1,$2,$3);
1.101 albertel 1324: my $start = ( $env{'form.start_'.$one.'_'.$two.'_'.$three} ?
1325: $env{'form.start_'.$one.'_'.$two.'_'.$three} :
1.27 matthew 1326: $now );
1.101 albertel 1327: my $end = ( $env{'form.end_'.$one.'_'.$two.'_'.$three} ?
1328: $env{'form.end_'.$one.'_'.$two.'_'.$three} :
1.27 matthew 1329: 0 );
1.83 albertel 1330: my $url='/'.$one.'/'.$two;
1.88 raeburn 1331: my $type = 'three';
1332: # split multiple sections
1333: my %sections = ();
1.101 albertel 1334: my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);
1.88 raeburn 1335: if ($num_sections == 0) {
1.99 raeburn 1336: $r->print(&commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
1.88 raeburn 1337: } else {
1.114 albertel 1338: my %curr_groups =
1339: &Apache::loncommon::coursegroups($one,$two);
1.88 raeburn 1340: my $emptysec = 0;
1341: foreach my $sec (sort {$a cmp $b} keys %sections) {
1342: $sec =~ s/\W//g;
1.113 raeburn 1343: if ($sec ne '') {
1344: if (($sec eq 'none') || ($sec eq 'all') ||
1345: exists($curr_groups{$sec})) {
1346: $disallowed{$sec} = $url;
1347: next;
1348: }
1.88 raeburn 1349: my $securl = $url.'/'.$sec;
1.99 raeburn 1350: $r->print(&commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec));
1.88 raeburn 1351: } else {
1352: $emptysec = 1;
1353: }
1354: }
1355: if ($emptysec) {
1.99 raeburn 1356: $r->print(&commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
1.88 raeburn 1357: }
1358: }
1.27 matthew 1359: } elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)$/) {
1360: # Activate roles for sections with two id numbers
1361: # set start, end times, and the url for the class
1.101 albertel 1362: my $start = ( $env{'form.start_'.$1.'_'.$2} ?
1363: $env{'form.start_'.$1.'_'.$2} :
1.27 matthew 1364: $now );
1.101 albertel 1365: my $end = ( $env{'form.end_'.$1.'_'.$2} ?
1366: $env{'form.end_'.$1.'_'.$2} :
1.27 matthew 1367: 0 );
1368: my $url='/'.$1.'/';
1.88 raeburn 1369: # split multiple sections
1370: my %sections = ();
1.101 albertel 1371: my $num_sections = &build_roles($env{'form.sec_'.$1.'_'.$2},\%sections,$2);
1.88 raeburn 1372: if ($num_sections == 0) {
1.99 raeburn 1373: $r->print(&commit_standardrole($udom,$uname,$url,$2,$start,$end,$1,undef,''));
1.88 raeburn 1374: } else {
1375: my $emptysec = 0;
1376: foreach my $sec (sort {$a cmp $b} keys %sections) {
1377: if ($sec ne '') {
1378: my $securl = $url.'/'.$sec;
1.99 raeburn 1379: $r->print(&commit_standardrole($udom,$uname,$securl,$2,$start,$end,$1,undef,$sec));
1.88 raeburn 1380: } else {
1381: $emptysec = 1;
1382: }
1383: }
1384: if ($emptysec) {
1.99 raeburn 1385: $r->print(&commit_standardrole($udom,$uname,$url,$2,$start,$end,$1,undef,''));
1.88 raeburn 1386: }
1387: }
1.64 www 1388: } else {
1.102 albertel 1389: $r->print('<p>'.&mt('ERROR').': '.&mt('Unknown command').' <tt>'.$_.'</tt></p><br />');
1.64 www 1390: }
1.113 raeburn 1391: foreach my $key (sort(keys(%disallowed))) {
1392: if (($key eq 'none') || ($key eq 'all')) {
1393: $r->print('<p>'.&mt('[_1] may not be used as the name for a section, as it is a reserved word.',$key));
1394: } else {
1395: $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));
1396: }
1397: $r->print(' '.&mt('Please <a href="javascript:history.go(-1)">go back</a> and choose a different section name.').'</p><br />');
1398: }
1399: }
1.101 albertel 1400: } # End of foreach (keys(%env))
1.75 www 1401: # Flush the course logs so reverse user roles immediately updated
1402: &Apache::lonnet::flushcourselogs();
1.103 albertel 1403: $r->print('<p><a href="/adm/createuser">Create/Modify Another User</a></p>');
1.110 albertel 1404: $r->print(&Apache::loncommon::end_page());
1.4 www 1405: }
1406:
1.88 raeburn 1407: sub commit_customrole {
1.99 raeburn 1408: my ($udom,$uname,$url,$three,$four,$five,$start,$end) = @_;
1.88 raeburn 1409: my $output = &mt('Assigning custom role').' "'.$five.'" by '.$four.'@'.$three.' in '.$url.
1410: ($start?', '.&mt('starting').' '.localtime($start):'').
1411: ($end?', ending '.localtime($end):'').': <b>'.
1412: &Apache::lonnet::assigncustomrole(
1.99 raeburn 1413: $udom,$uname,$url,$three,$four,$five,$end,$start).
1.102 albertel 1414: '</b><br />';
1.88 raeburn 1415: return $output;
1416: }
1417:
1418: sub commit_standardrole {
1.99 raeburn 1419: my ($udom,$uname,$url,$three,$start,$end,$one,$two,$sec) = @_;
1.89 raeburn 1420: my $output;
1421: my $logmsg;
1422: if ($three eq 'st') {
1.99 raeburn 1423: my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec);
1.89 raeburn 1424: if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) {
1425: $output = "Error: $result\n";
1426: } else {
1427: $output = &mt('Assigning').' '.$three.' in '.$url.
1428: ($start?', '.&mt('starting').' '.localtime($start):'').
1429: ($end?', '.&mt('ending').' '.localtime($end):'').
1430: ': <b>'.$result.'</b><br />'.
1431: &mt('Add to classlist').': <b>ok</b><br />';
1432: }
1433: } else {
1.92 raeburn 1434: $output = &mt('Assigning').' '.$three.' in '.$url.
1.89 raeburn 1435: ($start?', '.&mt('starting').' '.localtime($start):'').
1436: ($end?', '.&mt('ending').' '.localtime($end):'').': <b>'.
1437: &Apache::lonnet::assignrole(
1.99 raeburn 1438: $udom,$uname,$url,$three,$end,$start).
1.102 albertel 1439: '</b><br />';
1.88 raeburn 1440: }
1441: return $output;
1442: }
1443:
1.89 raeburn 1444: sub commit_studentrole {
1.99 raeburn 1445: my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec) = @_;
1.89 raeburn 1446: my $linefeed = '<br />'."\n";
1447: my $result;
1448: if (defined($one) && defined($two)) {
1449: my $cid=$one.'_'.$two;
1450: my $oldsec=&Apache::lonnet::getsection($udom,$uname,$cid);
1451: my $secchange = 0;
1452: my $expire_role_result;
1453: my $modify_section_result;
1454: unless ($oldsec eq '-1') {
1455: unless ($sec eq $oldsec) {
1456: $secchange = 1;
1457: my $uurl='/'.$cid;
1458: $uurl=~s/\_/\//g;
1459: if ($oldsec) {
1460: $uurl.='/'.$oldsec;
1461: }
1462: $expire_role_result = &Apache::lonnet::assignrole($udom,$uname,$uurl,'st',time);
1463: $result = $expire_role_result;
1464: }
1465: }
1466: if (($expire_role_result eq 'ok') || ($secchange == 0)) {
1467: $modify_section_result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,'','',$cid);
1468: if ($modify_section_result =~ /^ok/) {
1469: if ($secchange == 1) {
1470: $$logmsg .= "Section for $uname switched from old section: $oldsec to new section: $sec".$linefeed;
1471: } elsif ($oldsec eq '-1') {
1472: $$logmsg .= "New student role for $uname in section $sec in course $cid".$linefeed;
1473: } else {
1474: $$logmsg .= "Student $uname assigned to unchanged section $sec in course $cid".$linefeed;
1475: }
1476: } else {
1477: $$logmsg .= "Error when attempting section change for $uname from old section $oldsec to new section: $sec in course $cid -error: $modify_section_result".$linefeed;
1478: }
1479: $result = $modify_section_result;
1480: } elsif ($secchange == 1) {
1481: $$logmsg .= "Error when attempting to expire role for $uname in old section $oldsec in course $cid -error: $expire_role_result".$linefeed;
1482: }
1483: } else {
1484: $$logmsg .= "Incomplete course id defined. Addition of user $uname from domain $udom to course $one\_$two, section $sec not completed.$linefeed";
1.113 raeburn 1485: $result = "error: incomplete course id\n";
1.89 raeburn 1486: }
1487: return $result;
1488: }
1.88 raeburn 1489:
1490: sub build_roles {
1.89 raeburn 1491: my ($sectionstr,$sections,$role) = @_;
1.88 raeburn 1492: my $num_sections = 0;
1493: if ($sectionstr=~ /,/) {
1494: my @secnums = split/,/,$sectionstr;
1.89 raeburn 1495: if ($role eq 'st') {
1496: $secnums[0] =~ s/\W//g;
1497: $$sections{$secnums[0]} = 1;
1498: $num_sections = 1;
1499: } else {
1500: foreach my $sec (@secnums) {
1501: $sec =~ ~s/\W//g;
1502: unless ($sec eq "") {
1503: if (exists($$sections{$sec})) {
1504: $$sections{$sec} ++;
1505: } else {
1506: $$sections{$sec} = 1;
1507: $num_sections ++;
1508: }
1.88 raeburn 1509: }
1510: }
1511: }
1512: } else {
1513: $sectionstr=~s/\W//g;
1514: unless ($sectionstr eq '') {
1515: $$sections{$sectionstr} = 1;
1516: $num_sections ++;
1517: }
1518: }
1519:
1520: return $num_sections;
1521: }
1522:
1.58 www 1523: # ========================================================== Custom Role Editor
1524:
1525: sub custom_role_editor {
1526: my $r=shift;
1.101 albertel 1527: my $rolename=$env{'form.rolename'};
1.58 www 1528:
1.59 www 1529: if ($rolename eq 'make new role') {
1.101 albertel 1530: $rolename=$env{'form.newrolename'};
1.59 www 1531: }
1532:
1.63 www 1533: $rolename=~s/[^A-Za-z0-9]//gs;
1.58 www 1534:
1535: unless ($rolename) {
1536: &print_username_entry_form($r);
1537: return;
1538: }
1539:
1.110 albertel 1540: $r->print(&Apache::loncommon::start_page('Custom Role Editor'));
1.61 www 1541: my $syspriv='';
1542: my $dompriv='';
1543: my $coursepriv='';
1.59 www 1544: my ($rdummy,$roledef)=
1545: &Apache::lonnet::get('roles',["rolesdef_$rolename"]);
1.60 www 1546: # ------------------------------------------------------- Does this role exist?
1.110 albertel 1547: $r->print('<h2>');
1.59 www 1548: if (($rdummy ne 'con_lost') && ($roledef ne '')) {
1.73 sakharuk 1549: $r->print(&mt('Existing Role').' "');
1.61 www 1550: # ------------------------------------------------- Get current role privileges
1551: ($syspriv,$dompriv,$coursepriv)=split(/\_/,$roledef);
1.59 www 1552: } else {
1.73 sakharuk 1553: $r->print(&mt('New Role').' "');
1.59 www 1554: $roledef='';
1555: }
1556: $r->print($rolename.'"</h2>');
1.60 www 1557: # ------------------------------------------------------- What can be assigned?
1558: my %full=();
1559: my %courselevel=();
1.61 www 1560: my %courselevelcurrent=();
1.60 www 1561: foreach (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
1562: my ($priv,$restrict)=split(/\&/,$_);
1563: unless ($restrict) { $restrict='F'; }
1564: $courselevel{$priv}=$restrict;
1.61 www 1565: if ($coursepriv=~/\:$priv/) {
1566: $courselevelcurrent{$priv}=1;
1567: }
1.60 www 1568: $full{$priv}=1;
1569: }
1570: my %domainlevel=();
1.61 www 1571: my %domainlevelcurrent=();
1.60 www 1572: foreach (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
1573: my ($priv,$restrict)=split(/\&/,$_);
1574: unless ($restrict) { $restrict='F'; }
1575: $domainlevel{$priv}=$restrict;
1.61 www 1576: if ($dompriv=~/\:$priv/) {
1577: $domainlevelcurrent{$priv}=1;
1578: }
1.60 www 1579: $full{$priv}=1;
1580: }
1.61 www 1581: my %systemlevel=();
1582: my %systemlevelcurrent=();
1583: foreach (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
1584: my ($priv,$restrict)=split(/\&/,$_);
1585: unless ($restrict) { $restrict='F'; }
1586: $systemlevel{$priv}=$restrict;
1587: if ($syspriv=~/\:$priv/) {
1588: $systemlevelcurrent{$priv}=1;
1589: }
1590: $full{$priv}=1;
1591: }
1.73 sakharuk 1592: my %lt=&Apache::lonlocal::texthash(
1593: 'prv' => "Privilege",
1594: 'crl' => "Course Level",
1595: 'dml' => "Domain Level",
1596: 'ssl' => "System Level"
1597: );
1.61 www 1598: $r->print(<<ENDCCF);
1599: <form method="post">
1600: <input type="hidden" name="phase" value="set_custom_roles" />
1601: <input type="hidden" name="rolename" value="$rolename" />
1602: <table border="2">
1.73 sakharuk 1603: <tr><th>$lt{'prv'}</th><th>$lt{'crl'}</th><th>$lt{'dml'}</th>
1604: <th>$lt{'ssl'}</th></tr>
1.61 www 1605: ENDCCF
1.60 www 1606: foreach (sort keys %full) {
1607: $r->print('<tr><td>'.&Apache::lonnet::plaintext($_).'</td><td>'.
1.61 www 1608: ($courselevel{$_}?'<input type="checkbox" name="'.$_.':c" '.
1609: ($courselevelcurrent{$_}?'checked="1"':'').' />':' ').
1610: '</td><td>'.
1611: ($domainlevel{$_}?'<input type="checkbox" name="'.$_.':d" '.
1612: ($domainlevelcurrent{$_}?'checked="1"':'').' />':' ').
1613: '</td><td>'.
1614: ($systemlevel{$_}?'<input type="checkbox" name="'.$_.':s" '.
1615: ($systemlevelcurrent{$_}?'checked="1"':'').' />':' ').
1616: '</td></tr>');
1.60 www 1617: }
1.61 www 1618: $r->print(
1.110 albertel 1619: '<table><input type="submit" value="'.&mt('Define Role').'" /></form>'.
1620: &Apache::loncommon::end_page());
1.61 www 1621: }
1622:
1623: # ---------------------------------------------------------- Call to definerole
1624: sub set_custom_role {
1.110 albertel 1625: my ($r) = @_;
1.61 www 1626:
1.101 albertel 1627: my $rolename=$env{'form.rolename'};
1.61 www 1628:
1.63 www 1629: $rolename=~s/[^A-Za-z0-9]//gs;
1.61 www 1630:
1631: unless ($rolename) {
1632: &print_username_entry_form($r);
1633: return;
1634: }
1635:
1.110 albertel 1636: $r->print(&Apache::loncommon::start_page('Save Custom Role').'<h2>');
1.61 www 1637: my ($rdummy,$roledef)=
1.110 albertel 1638: &Apache::lonnet::get('roles',["rolesdef_$rolename"]);
1639:
1.61 www 1640: # ------------------------------------------------------- Does this role exist?
1641: if (($rdummy ne 'con_lost') && ($roledef ne '')) {
1.73 sakharuk 1642: $r->print(&mt('Existing Role').' "');
1.61 www 1643: } else {
1.73 sakharuk 1644: $r->print(&mt('New Role').' "');
1.61 www 1645: $roledef='';
1646: }
1647: $r->print($rolename.'"</h2>');
1648: # ------------------------------------------------------- What can be assigned?
1649: my $sysrole='';
1650: my $domrole='';
1651: my $courole='';
1652:
1653: foreach (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
1654: my ($priv,$restrict)=split(/\&/,$_);
1655: unless ($restrict) { $restrict=''; }
1.101 albertel 1656: if ($env{'form.'.$priv.':c'}) {
1.61 www 1657: $courole.=':'.$_;
1658: }
1659: }
1660:
1661: foreach (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
1662: my ($priv,$restrict)=split(/\&/,$_);
1663: unless ($restrict) { $restrict=''; }
1.101 albertel 1664: if ($env{'form.'.$priv.':d'}) {
1.61 www 1665: $domrole.=':'.$_;
1666: }
1667: }
1668:
1669: foreach (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
1670: my ($priv,$restrict)=split(/\&/,$_);
1671: unless ($restrict) { $restrict=''; }
1.101 albertel 1672: if ($env{'form.'.$priv.':s'}) {
1.61 www 1673: $sysrole.=':'.$_;
1674: }
1675: }
1.63 www 1676: $r->print('<br />Defining Role: '.
1.61 www 1677: &Apache::lonnet::definerole($rolename,$sysrole,$domrole,$courole));
1.101 albertel 1678: if ($env{'request.course.id'}) {
1679: my $url='/'.$env{'request.course.id'};
1.63 www 1680: $url=~s/\_/\//g;
1.73 sakharuk 1681: $r->print('<br />'.&mt('Assigning Role to Self').': '.
1.101 albertel 1682: &Apache::lonnet::assigncustomrole($env{'user.domain'},
1683: $env{'user.name'},
1.63 www 1684: $url,
1.101 albertel 1685: $env{'user.domain'},
1686: $env{'user.name'},
1.63 www 1687: $rolename));
1688: }
1.109 albertel 1689: $r->print('<p><a href="/adm/createuser">Create another role, or Create/Modify a user.</a></p>');
1.110 albertel 1690: $r->print(&Apache::loncommon::end_page());
1.58 www 1691: }
1692:
1.2 www 1693: # ================================================================ Main Handler
1694: sub handler {
1695: my $r = shift;
1696:
1697: if ($r->header_only) {
1.68 www 1698: &Apache::loncommon::content_type($r,'text/html');
1.2 www 1699: $r->send_http_header;
1700: return OK;
1701: }
1702:
1.101 albertel 1703: if ((&Apache::lonnet::allowed('cta',$env{'request.course.id'})) ||
1704: (&Apache::lonnet::allowed('cin',$env{'request.course.id'})) ||
1705: (&Apache::lonnet::allowed('ccr',$env{'request.course.id'})) ||
1706: (&Apache::lonnet::allowed('cep',$env{'request.course.id'})) ||
1.104 albertel 1707: (&authorpriv($env{'user.name'},$env{'request.role.domain'})) ||
1.101 albertel 1708: (&Apache::lonnet::allowed('mau',$env{'request.role.domain'}))) {
1.68 www 1709: &Apache::loncommon::content_type($r,'text/html');
1.2 www 1710: $r->send_http_header;
1.101 albertel 1711: unless ($env{'form.phase'}) {
1.42 matthew 1712: &print_username_entry_form($r);
1.2 www 1713: }
1.101 albertel 1714: if ($env{'form.phase'} eq 'get_user_info') {
1.42 matthew 1715: &print_user_modification_page($r);
1.101 albertel 1716: } elsif ($env{'form.phase'} eq 'update_user_data') {
1.42 matthew 1717: &update_user_data($r);
1.101 albertel 1718: } elsif ($env{'form.phase'} eq 'selected_custom_edit') {
1.58 www 1719: &custom_role_editor($r);
1.101 albertel 1720: } elsif ($env{'form.phase'} eq 'set_custom_roles') {
1.61 www 1721: &set_custom_role($r);
1.2 www 1722: }
1.1 www 1723: } else {
1.101 albertel 1724: $env{'user.error.msg'}=
1.9 albertel 1725: "/adm/createuser:mau:0:0:Cannot modify user data";
1.1 www 1726: return HTTP_NOT_ACCEPTABLE;
1727: }
1728: return OK;
1729: }
1.26 matthew 1730:
1.27 matthew 1731: #-------------------------------------------------- functions for &phase_two
1.26 matthew 1732: sub course_level_table {
1.89 raeburn 1733: my (%inccourses) = @_;
1.26 matthew 1734: my $table = '';
1.62 www 1735: # Custom Roles?
1736:
1737: my %customroles=&my_custom_roles();
1.89 raeburn 1738: my %lt=&Apache::lonlocal::texthash(
1739: 'exs' => "Existing sections",
1740: 'new' => "Define new section",
1741: 'ssd' => "Set Start Date",
1742: 'sed' => "Set End Date",
1743: 'crl' => "Course Level",
1744: 'act' => "Activate",
1745: 'rol' => "Role",
1746: 'ext' => "Extent",
1.113 raeburn 1747: 'grs' => "Section",
1.89 raeburn 1748: 'sta' => "Start",
1749: 'end' => "End"
1750: );
1.62 www 1751:
1.26 matthew 1752: foreach (sort( keys(%inccourses))) {
1753: my $thiscourse=$_;
1754: my $protectedcourse=$_;
1755: $thiscourse=~s:_:/:g;
1756: my %coursedata=&Apache::lonnet::coursedescription($thiscourse);
1757: my $area=$coursedata{'description'};
1.72 sakharuk 1758: if (!defined($area)) { $area=&mt('Unavailable course').': '.$_; }
1.26 matthew 1759: my $bgcol=$thiscourse;
1.62 www 1760: $bgcol=~s/[^7-9a-e]//g;
1761: $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',2,6);
1.89 raeburn 1762: my ($domain,$cnum)=split(/\//,$thiscourse);
1.115 ! albertel 1763: my %sections_count;
1.101 albertel 1764: if (defined($env{'request.course.id'})) {
1765: if ($env{'request.course.id'} eq $domain.'_'.$cnum) {
1.115 ! albertel 1766: %sections_count =
! 1767: &Apache::loncommon::get_sections($domain,$cnum);
1.92 raeburn 1768: }
1769: }
1.26 matthew 1770: foreach ('st','ta','ep','ad','in','cc') {
1771: if (&Apache::lonnet::allowed('c'.$_,$thiscourse)) {
1772: my $plrole=&Apache::lonnet::plaintext($_);
1773: $table .= <<ENDEXTENT;
1774: <tr bgcolor="#$bgcol">
1775: <td><input type="checkbox" name="act_$protectedcourse\_$_"></td>
1776: <td>$plrole</td>
1.82 albertel 1777: <td>$area<br />Domain: $domain</td>
1.26 matthew 1778: ENDEXTENT
1779: if ($_ ne 'cc') {
1.115 ! albertel 1780: if (%sections_count) {
! 1781: my $currsec = &course_sections(\%sections_count,$protectedcourse.'_'.$_);
1.89 raeburn 1782: $table .=
1783: '<td><table border="0" cellspacing="0" cellpadding="0">'.
1784: '<tr><td valign="top">'.$lt{'exs'}.'<br />'.
1785: $currsec.'</td>'.
1786: '<td> </td>'.
1787: '<td valign="top"> '.$lt{'new'}.'<br />'.
1788: '<input type="text" name="newsec_'.$protectedcourse.'_'.$_.'" value="" /></td>'.
1789: '<input type="hidden" '.
1790: 'name="sec_'.$protectedcourse.'_'.$_.'"></td>'.
1791: '</tr></table></td>';
1792: } else {
1793: $table .= '<td><input type="text" size="10" '.
1794: 'name="sec_'.$protectedcourse.'_'.$_.'"></td>';
1795: }
1.26 matthew 1796: } else {
1.89 raeburn 1797: $table .= '<td> </td>';
1.26 matthew 1798: }
1799: $table .= <<ENDTIMEENTRY;
1800: <td><input type=hidden name="start_$protectedcourse\_$_" value=''>
1801: <a href=
1.73 sakharuk 1802: "javascript:pjump('date_start','Start Date $plrole',document.cu.start_$protectedcourse\_$_.value,'start_$protectedcourse\_$_','cu.pres','dateset')">$lt{'ssd'}</a></td>
1.26 matthew 1803: <td><input type=hidden name="end_$protectedcourse\_$_" value=''>
1804: <a href=
1.73 sakharuk 1805: "javascript:pjump('date_end','End Date $plrole',document.cu.end_$protectedcourse\_$_.value,'end_$protectedcourse\_$_','cu.pres','dateset')">$lt{'sed'}</a></td>
1.26 matthew 1806: ENDTIMEENTRY
1807: $table.= "</tr>\n";
1808: }
1809: }
1.62 www 1810: foreach (sort keys %customroles) {
1.65 www 1811: if (&Apache::lonnet::allowed('ccr',$thiscourse)) {
1812: my $plrole=$_;
1.101 albertel 1813: my $customrole=$protectedcourse.'_cr_cr_'.$env{'user.domain'}.
1814: '_'.$env{'user.name'}.'_'.$plrole;
1.89 raeburn 1815: $table .= <<END;
1.62 www 1816: <tr bgcolor="#$bgcol">
1.65 www 1817: <td><input type="checkbox" name="act_$customrole"></td>
1.62 www 1818: <td>$plrole</td>
1819: <td>$area</td>
1.89 raeburn 1820: END
1.115 ! albertel 1821: if (%sections_count) {
! 1822: my $currsec = &course_sections(\%sections_count,$customrole);
1.89 raeburn 1823: $table.=
1824: '<td><table border="0" cellspacing="0" cellpadding="0">'.
1825: '<tr><td valign="top">'.$lt{'exs'}.'<br />'.
1826: $currsec.'</td>'.
1827: '<td> </td>'.
1828: '<td valign="top"> '.$lt{'new'}.'<br />'.
1829: '<input type="text" name="newsec_'.$customrole.'" value="" /></td>'.
1830: '<input type="hidden" '.
1831: 'name="sec_'.$customrole.'"></td>'.
1832: '</tr></table></td>';
1833: } else {
1834: $table .= '<td><input type="text" size="10" '.
1835: 'name="sec_'.$customrole.'"></td>';
1836: }
1837: $table .= <<ENDENTRY;
1.65 www 1838: <td><input type=hidden name="start_$customrole" value=''>
1.62 www 1839: <a href=
1.73 sakharuk 1840: "javascript:pjump('date_start','Start Date $plrole',document.cu.start_$customrole.value,'start_$customrole','cu.pres','dateset')">$lt{'ssd'}</a></td>
1.65 www 1841: <td><input type=hidden name="end_$customrole" value=''>
1.62 www 1842: <a href=
1.73 sakharuk 1843: "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 1844: ENDENTRY
1.65 www 1845: }
1.62 www 1846: }
1.26 matthew 1847: }
1848: return '' if ($table eq ''); # return nothing if there is nothing
1849: # in the table
1850: my $result = <<ENDTABLE;
1.73 sakharuk 1851: <h4>$lt{'crl'}</h4>
1852: <table border=2><tr><th>$lt{'act'}</th><th>$lt{'rol'}</th><th>$lt{'ext'}</th>
1853: <th>$lt{'grs'}</th><th>$lt{'sta'}</th><th>$lt{'end'}</th></tr>
1.26 matthew 1854: $table
1855: </table>
1856: ENDTABLE
1857: return $result;
1858: }
1.88 raeburn 1859:
1.89 raeburn 1860: sub course_sections {
1.115 ! albertel 1861: my ($sections_count,$role) = @_;
1.89 raeburn 1862: my $output = '';
1863: my @sections = (sort {$a <=> $b} keys %{$sections_count});
1.115 ! albertel 1864: if (scalar(@sections) == 1) {
1.92 raeburn 1865: $output = '<select name="currsec_'.$role.'" >'."\n".
1866: ' <option value="">Select</option>'."\n".
1.93 raeburn 1867: ' <option value="">No section</option>'."\n".
1.92 raeburn 1868: ' <option value="'.$sections[0].'" >'.$sections[0].'</option>'."\n";
1869: } else {
1870: $output = '<select name="currsec_'.$role.'" ';
1871: my $multiple = 4;
1.115 ! albertel 1872: if (scalar(@sections) < 4) { $multiple = scalar(@sections); }
1.95 albertel 1873: $output .= '"multiple" size="'.$multiple.'">'."\n";
1.92 raeburn 1874: foreach (@sections) {
1875: $output .= '<option value="'.$_.'">'.$_."</option>\n";
1876: }
1.89 raeburn 1877: }
1878: $output .= '</select>';
1879: return $output;
1880: }
1881:
1.88 raeburn 1882: sub course_level_dc {
1883: my ($dcdom) = @_;
1884: my %customroles=&my_custom_roles();
1885: my $hiddenitems = '<input type="hidden" name="dcdomain" value="'.$dcdom.'" />'.
1886: '<input type="hidden" name="origdom" value="'.$dcdom.'" />'.
1887: '<input type="hidden" name="dccourse" value="" />';
1888: my $courseform='<b>'.&Apache::loncommon::selectcourse_link
1889: ('cu','dccourse','dcdomain','coursedesc').'</b>';
1890:
1891: my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,$dcdom);
1892: my %lt=&Apache::lonlocal::texthash(
1893: 'crl' => "Course Level",
1894: 'crt' => "Course Title",
1895: 'rol' => "Role",
1.113 raeburn 1896: 'grs' => "Section",
1.88 raeburn 1897: 'exs' => "Existing sections",
1898: 'new' => "Define new section",
1899: 'sta' => "Start",
1900: 'end' => "End",
1901: 'ssd' => "Set Start Date",
1902: 'sed' => "Set End Date"
1903: );
1904: my $header = '<h4>'.$lt{'crl'}.'</h4>'.
1905: '<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 1906: my $otheritems = '<tr><td><input type="text" name="coursedesc" value="" onFocus="this.blur();opencrsbrowser('."'".'cu'."'".','."'".'dccourse'."'".','."'".'dcdomain'."'".','."'".'coursedesc'."',''".')" /></td>'.
1.88 raeburn 1907: '<td><select name="role">'."\n";
1908: foreach ('st','ta','ep','ad','in','cc') {
1909: my $plrole=&Apache::lonnet::plaintext($_);
1910: $otheritems .= ' <option value="'.$_.'">'.$plrole;
1911: }
1912: if ( keys %customroles > 0) {
1913: foreach (sort keys %customroles) {
1.101 albertel 1914: my $custrole='cr_cr_'.$env{'user.domain'}.
1915: '_'.$env{'user.name'}.'_'.$_;
1.88 raeburn 1916: $otheritems .= ' <option value="'.$custrole.'">'.$_;
1917: }
1918: }
1919: $otheritems .= '</select></td><td>'.
1920: '<table border="0" cellspacing="0" cellpadding="0">'.
1921: '<tr><td valign="top"><b>'.$lt{'exs'}.'</b><br /><select name="currsec">'.
1922: ' <option value=""><--'.&mt('Pick course first').'</select></td>'.
1923: '<td> </td>'.
1924: '<td valign="top"> <b>'.$lt{'new'}.'</b><br />'.
1.113 raeburn 1925: '<input type="text" name="newsec" value="" />'.
1926: '<input type="hidden" name="groups" value="" /></td>'.
1.88 raeburn 1927: '</tr></table></td>';
1928: $otheritems .= <<ENDTIMEENTRY;
1929: <td><input type=hidden name="start" value=''>
1930: <a href=
1931: "javascript:pjump('date_start','Start Date',document.cu.start.value,'start','cu.pres','dateset')">$lt{'ssd'}</a></td>
1932: <td><input type=hidden name="end" value=''>
1933: <a href=
1934: "javascript:pjump('date_end','End Date',document.cu.end.value,'end','cu.pres','dateset')">$lt{'sed'}</a></td>
1935: ENDTIMEENTRY
1936: $otheritems .= "</tr></table>\n";
1937: return $cb_jscript.$header.$hiddenitems.$otheritems;
1938: }
1939:
1.27 matthew 1940: #---------------------------------------------- end functions for &phase_two
1.29 matthew 1941:
1942: #--------------------------------- functions for &phase_two and &phase_three
1943:
1944: #--------------------------end of functions for &phase_two and &phase_three
1.1 www 1945:
1946: 1;
1947: __END__
1.2 www 1948:
1949:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>