1: # The LearningOnline Network with CAPA
2: # Create a user
3: #
4: # $Id: loncreateuser.pm,v 1.66 2003/07/25 01:18:04 bowersj2 Exp $
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: #
28: ###
29:
30: package Apache::loncreateuser;
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
61:
62: use strict;
63: use Apache::Constants qw(:common :http);
64: use Apache::lonnet;
65: use Apache::loncommon;
66:
67: my $loginscript; # piece of javascript used in two separate instances
68: my $generalrule;
69: my $authformnop;
70: my $authformkrb;
71: my $authformint;
72: my $authformfsys;
73: my $authformloc;
74:
75: BEGIN {
76: $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
77: my $krbdefdom=$1;
78: $krbdefdom=~tr/a-z/A-Z/;
79: my %param = ( formname => 'document.cu',
80: kerb_def_dom => $krbdefdom
81: );
82: # no longer static due to configurable kerberos defaults
83: # $loginscript = &Apache::loncommon::authform_header(%param);
84: $generalrule = &Apache::loncommon::authform_authorwarning(%param);
85: $authformnop = &Apache::loncommon::authform_nochange(%param);
86: # no longer static due to configurable kerberos defaults
87: # $authformkrb = &Apache::loncommon::authform_kerberos(%param);
88: $authformint = &Apache::loncommon::authform_internal(%param);
89: $authformfsys = &Apache::loncommon::authform_filesystem(%param);
90: $authformloc = &Apache::loncommon::authform_local(%param);
91: }
92:
93:
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+)$/) {
101: $returnhash{$1}=$1;
102: }
103: }
104: return %returnhash;
105: }
106:
107: # ==================================================== Figure out author access
108:
109: sub authorpriv {
110: my ($auname,$audom)=@_;
111: if (($auname ne $ENV{'user.name'}) ||
112: (($audom ne $ENV{'user.domain'}) &&
113: ($audom ne $ENV{'request.role.domain'}))) { return ''; }
114: unless (&Apache::lonnet::allowed('cca',$audom)) { return ''; }
115: return 1;
116: }
117:
118: # =================================================================== Phase one
119:
120: sub print_username_entry_form {
121: my $r=shift;
122: my $defdom=$ENV{'request.role.domain'};
123: my @domains = &Apache::loncommon::get_domains();
124: my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
125: my $bodytag =&Apache::loncommon::bodytag(
126: 'Create Users, Change User Privileges');
127: my $selscript=&Apache::loncommon::studentbrowser_javascript();
128: my $sellink=&Apache::loncommon::selectstudent_link
129: ('crtuser','ccuname','ccdomain');
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));
133: $r->print(<<"ENDDOCUMENT");
134: <html>
135: <head>
136: <title>The LearningOnline Network with CAPA</title>
137: $selscript
138: </head>
139: $bodytag
140: <form action="/adm/createuser" method="post" name="crtuser">
141: <input type="hidden" name="phase" value="get_user_info">
142: <h2>Set Individual User Roles</h2>
143: <table>
144: <tr><td>Username:</td><td><input type="text" size="15" name="ccuname">
145: </td><td rowspan="2">$sellink</td></tr><tr><td>
146: Domain:</td><td>$domform</td></tr>
147: </table>
148: <input name="userrole" type="submit" value="User Roles" />
149: </form>
150: <form action="/adm/createuser" method="post" name="docustom">
151: <input type="hidden" name="phase" value="selected_custom_edit">
152: <h2>Edit Custom Role Privileges</h2>
153: Name of Role: $choice <input type="text" size="15" name="newrolename" /><br />
154: <input name="customeditor" type="submit" value="Custom Role Editor" />
155: </body>
156: </html>
157: ENDDOCUMENT
158: }
159:
160: # =================================================================== Phase two
161: sub print_user_modification_page {
162: my $r=shift;
163: my $ccuname=$ENV{'form.ccuname'};
164: my $ccdomain=$ENV{'form.ccdomain'};
165:
166: $ccuname=~s/\W//gs;
167: $ccdomain=~s/\W//gs;
168:
169: unless (($ccuname) && ($ccdomain)) {
170: &print_username_entry_form($r);
171: return;
172: }
173:
174: my $defdom=$ENV{'request.role.domain'};
175:
176: my ($krbdef,$krbdefdom) =
177: &Apache::loncommon::get_kerberos_defaults($defdom);
178:
179: my %param = ( formname => 'document.cu',
180: kerb_def_dom => $krbdefdom,
181: kerb_def_auth => $krbdef
182: );
183: $loginscript = &Apache::loncommon::authform_header(%param);
184: $authformkrb = &Apache::loncommon::authform_kerberos(%param);
185:
186: $ccuname=~s/\W//g;
187: $ccdomain=~s/\W//g;
188: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
189: my $dochead =<<"ENDDOCHEAD";
190: <html>
191: <head>
192: <title>The LearningOnline Network with CAPA</title>
193: <script type="text/javascript" language="Javascript">
194:
195: function pclose() {
196: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
197: "height=350,width=350,scrollbars=no,menubar=no");
198: parmwin.close();
199: }
200:
201: $pjump_def
202:
203: function dateset() {
204: eval("document.cu."+document.cu.pres_marker.value+
205: ".value=document.cu.pres_value.value");
206: pclose();
207: }
208:
209: </script>
210: </head>
211: ENDDOCHEAD
212: $r->print(&Apache::loncommon::bodytag(
213: 'Create Users, Change User Privileges'));
214: my $forminfo =<<"ENDFORMINFO";
215: <form action="/adm/createuser" method="post" name="cu">
216: <input type="hidden" name="phase" value="update_user_data">
217: <input type="hidden" name="ccuname" value="$ccuname">
218: <input type="hidden" name="ccdomain" value="$ccdomain">
219: <input type="hidden" name="pres_value" value="" >
220: <input type="hidden" name="pres_type" value="" >
221: <input type="hidden" name="pres_marker" value="" >
222: ENDFORMINFO
223: my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
224: my %incdomains;
225: my %inccourses;
226: foreach (values(%Apache::lonnet::hostdom)) {
227: $incdomains{$_}=1;
228: }
229: foreach (keys(%ENV)) {
230: if ($_=~/^user\.priv\.cm\.\/(\w+)\/(\w+)/) {
231: $inccourses{$1.'_'.$2}=1;
232: }
233: }
234: if ($uhome eq 'no_host') {
235: my $home_server_list=
236: '<option value="default" selected>default</option>'."\n".
237: &Apache::loncommon::home_server_option_list($ccdomain);
238:
239: $r->print(<<ENDNEWUSER);
240: $dochead
241: <h1>Create New User</h1>
242: $forminfo
243: <h2>New user "$ccuname" in domain $ccdomain</h2>
244: <script type="text/javascript" language="Javascript">
245: $loginscript
246: </script>
247: <input type='hidden' name='makeuser' value='1' />
248: <h3>Personal Data</h3>
249: <p>
250: <table>
251: <tr><td>First Name </td>
252: <td><input type='text' name='cfirst' size='15' /></td></tr>
253: <tr><td>Middle Name </td>
254: <td><input type='text' name='cmiddle' size='15' /></td></tr>
255: <tr><td>Last Name </td>
256: <td><input type='text' name='clast' size='15' /></td></tr>
257: <tr><td>Generation </td>
258: <td><input type='text' name='cgen' size='5' /></td></tr>
259: </table>
260: ID/Student Number <input type='text' name='cstid' size='15' /></p>
261: Home Server: <select name="hserver" size="1"> $home_server_list </select>
262: <hr />
263: <h3>Login Data</h3>
264: <p>$generalrule </p>
265: <p>$authformkrb </p>
266: <p>$authformint </p>
267: <p>$authformfsys</p>
268: <p>$authformloc </p>
269: ENDNEWUSER
270: } else { # user already exists
271: $r->print(<<ENDCHANGEUSER);
272: $dochead
273: <h1>Change User Privileges</h1>
274: $forminfo
275: <h2>User "$ccuname" in domain "$ccdomain"</h2>
276: ENDCHANGEUSER
277: # Get the users information
278: my %userenv = &Apache::lonnet::get('environment',
279: ['firstname','middlename','lastname','generation'],
280: $ccdomain,$ccuname);
281: my %rolesdump=&Apache::lonnet::dump('roles',$ccdomain,$ccuname);
282: $r->print(<<END);
283: <hr />
284: <table border="2">
285: <tr>
286: <th>first name</th><th>middle name</th><th>last name</th><th>generation</th>
287: </tr>
288: <tr>
289: END
290: foreach ('firstname','middlename','lastname','generation') {
291: if (&Apache::lonnet::allowed('mau',$ccdomain)) {
292: $r->print(<<"END");
293: <td><input type="text" name="c$_" value="$userenv{$_}" size="15" /></td>
294: END
295: } else {
296: $r->print('<td>'.$userenv{$_}.'</td>');
297: }
298: }
299: $r->print(<<END);
300: </tr>
301: </table>
302: END
303: # Build up table of user roles to allow revocation of a role.
304: my ($tmp) = keys(%rolesdump);
305: unless ($tmp =~ /^(con_lost|error)/i) {
306: my $now=time;
307: $r->print(<<END);
308: <hr />
309: <h3>Revoke Existing Roles</h3>
310: <table border=2>
311: <tr><th>Revoke</th><th>Delete</th><th>Role</th><th>Extent</th><th>Start</th><th>End</th>
312: END
313: foreach my $area (sort keys(%rolesdump)) {
314: next if ($area =~ /^rolesdef/);
315: my $role = $rolesdump{$area};
316: my $thisrole=$area;
317: $area =~ s/\_\w\w$//;
318: my ($role_code,$role_end_time,$role_start_time) =
319: split(/_/,$role);
320: # Is this a custom role? Get role owner and title.
321: my ($croleudom,$croleuname,$croletitle)=
322: ($role_code=~/^cr\/(\w+)\/(\w+)\/(\w+)$/);
323: my $bgcol='ffffff';
324: my $allowed=0;
325: my $delallowed=0;
326: if ($area =~ /^\/(\w+)\/(\d\w+)/ ) {
327: my ($coursedom,$coursedir) = ($1,$2);
328: # $1.'_'.$2 is the course id (eg. 103_12345abcef103l3).
329: my %coursedata=
330: &Apache::lonnet::coursedescription($1.'_'.$2);
331: my $carea;
332: if (defined($coursedata{'description'})) {
333: $carea='Course: '.$coursedata{'description'}.
334: '<br />Domain: '.$coursedom.(' 'x8).
335: &Apache::loncommon::syllabuswrapper('Syllabus',$coursedir,$coursedom);
336: } else {
337: $carea='Unavailable course: '.$area;
338: }
339: $inccourses{$1.'_'.$2}=1;
340: if ((&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2)) ||
341: (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
342: $allowed=1;
343: }
344: if ((&Apache::lonnet::allowed('dro',$1)) ||
345: (&Apache::lonnet::allowed('dro',$ccdomain))) {
346: $delallowed=1;
347: }
348: # - custom role. Needs more info, too
349: if ($croletitle) {
350: if (&Apache::lonnet::allowed('ccr',$1.'/'.$2)) {
351: $allowed=1;
352: $thisrole.='.'.$role_code;
353: }
354: }
355: # Compute the background color based on $area
356: $bgcol=$1.'_'.$2;
357: $bgcol=~s/[^7-9a-e]//g;
358: $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',2,6);
359: if ($area=~/^\/(\w+)\/(\d\w+)\/(\w+)/) {
360: $carea.='<br>Section/Group: '.$3;
361: }
362: $area=$carea;
363: } else {
364: # Determine if current user is able to revoke privileges
365: if ($area=~ /^\/(\w+)\//) {
366: if ((&Apache::lonnet::allowed('c'.$role_code,$1)) ||
367: (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
368: $allowed=1;
369: }
370: if (((&Apache::lonnet::allowed('dro',$1)) ||
371: (&Apache::lonnet::allowed('dro',$ccdomain))) &&
372: ($role_code ne 'dc')) {
373: $delallowed=1;
374: }
375: } else {
376: if (&Apache::lonnet::allowed('c'.$role_code,'/')) {
377: $allowed=1;
378: }
379: }
380: }
381: if ($role_code eq 'ca') {
382: $area=~/\/(\w+)\/(\w+)/;
383: if (&authorpriv($2,$1)) {
384: $allowed=1;
385: } else {
386: $allowed=0;
387: }
388: }
389: my $row = '';
390: $row.='<tr bgcolor="#'.$bgcol.'"><td>';
391: my $active=1;
392: $active=0 if (($role_end_time) && ($now>$role_end_time));
393: if (($active) && ($allowed)) {
394: $row.= '<input type="checkbox" name="rev:'.$thisrole.'">';
395: } else {
396: if ($active) {
397: $row.=' ';
398: } else {
399: $row.='expired or revoked';
400: }
401: }
402: $row.='</td><td>';
403: if ($delallowed) {
404: $row.= '<input type="checkbox" name="del:'.$thisrole.'">';
405: } else {
406: $row.=' ';
407: }
408: my $plaintext='';
409: unless ($croletitle) {
410: $plaintext=&Apache::lonnet::plaintext($role_code);
411: } else {
412: $plaintext=
413: "Customrole '$croletitle' defined by $croleuname\@$croleudom";
414: }
415: $row.= '</td><td>'.$plaintext.
416: '</td><td>'.$area.
417: '</td><td>'.($role_start_time?localtime($role_start_time)
418: : ' ' ).
419: '</td><td>'.($role_end_time ?localtime($role_end_time)
420: : ' ' )
421: ."</td></tr>\n";
422: $r->print($row);
423: } # end of foreach (table building loop)
424: $r->print('</table>');
425: } # End of unless
426: my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain);
427: if ($currentauth=~/^krb(4|5):/) {
428: $currentauth=~/^krb(4|5):(.*)/;
429: my $krbdefdom=$1;
430: my %param = ( formname => 'document.cu',
431: kerb_def_dom => $krbdefdom
432: );
433: $loginscript = &Apache::loncommon::authform_header(%param);
434: }
435: # Check for a bad authentication type
436: unless ($currentauth=~/^krb(4|5):/ or
437: $currentauth=~/^unix:/ or
438: $currentauth=~/^internal:/ or
439: $currentauth=~/^localauth:/
440: ) { # bad authentication scheme
441: if (&Apache::lonnet::allowed('mau',$ENV{'request.role.domain'})) {
442: $r->print(<<ENDBADAUTH);
443: <hr />
444: <script type="text/javascript" language="Javascript">
445: $loginscript
446: </script>
447: <font color='#ff0000'>ERROR:</font>
448: This user has an unrecognized authentication scheme ($currentauth).
449: Please specify login data below.
450: <h3>Login Data</h3>
451: <p>$generalrule</p>
452: <p>$authformkrb</p>
453: <p>$authformint</p>
454: <p>$authformfsys</p>
455: <p>$authformloc</p>
456: ENDBADAUTH
457: } else {
458: # This user is not allowed to modify the users
459: # authentication scheme, so just notify them of the problem
460: $r->print(<<ENDBADAUTH);
461: <hr />
462: <script type="text/javascript" language="Javascript">
463: $loginscript
464: </script>
465: <font color="#ff0000"> ERROR: </font>
466: This user has an unrecognized authentication scheme ($currentauth).
467: Please alert a domain coordinator of this situation.
468: <hr />
469: ENDBADAUTH
470: }
471: } else { # Authentication type is valid
472: my $authformcurrent='';
473: my $authform_other='';
474: if ($currentauth=~/^krb(4|5):/) {
475: $authformcurrent=$authformkrb;
476: $authform_other="<p>$authformint</p>\n".
477: "<p>$authformfsys</p><p>$authformloc</p>";
478: }
479: elsif ($currentauth=~/^internal:/) {
480: $authformcurrent=$authformint;
481: $authform_other="<p>$authformkrb</p>".
482: "<p>$authformfsys</p><p>$authformloc</p>";
483: }
484: elsif ($currentauth=~/^unix:/) {
485: $authformcurrent=$authformfsys;
486: $authform_other="<p>$authformkrb</p>".
487: "<p>$authformint</p><p>$authformloc;</p>";
488: }
489: elsif ($currentauth=~/^localauth:/) {
490: $authformcurrent=$authformloc;
491: $authform_other="<p>$authformkrb</p>".
492: "<p>$authformint</p><p>$authformfsys</p>";
493: }
494: $authformcurrent.=' <i>(will override current values)</i><br />';
495: if (&Apache::lonnet::allowed('mau',$ENV{'request.role.domain'})) {
496: # Current user has login modification privileges
497: $r->print(<<ENDOTHERAUTHS);
498: <hr />
499: <script type="text/javascript" language="Javascript">
500: $loginscript
501: </script>
502: <h3>Change Current Login Data</h3>
503: <p>$generalrule</p>
504: <p>$authformnop</p>
505: <p>$authformcurrent</p>
506: <h3>Enter New Login Data</h3>
507: $authform_other
508: ENDOTHERAUTHS
509: }
510: } ## End of "check for bad authentication type" logic
511: } ## End of new user/old user logic
512: $r->print('<hr /><h3>Add Roles</h3>');
513: #
514: # Co-Author
515: #
516: if (&authorpriv($ENV{'user.name'},$ENV{'request.role.domain'}) &&
517: ($ENV{'user.name'} ne $ccuname || $ENV{'user.domain'} ne $ccdomain)) {
518: # No sense in assigning co-author role to yourself
519: my $cuname=$ENV{'user.name'};
520: my $cudom=$ENV{'request.role.domain'};
521: $r->print(<<ENDCOAUTH);
522: <h4>Construction Space</h4>
523: <table border=2><tr><th>Activate</th><th>Role</th><th>Extent</th>
524: <th>Start</th><th>End</th></tr>
525: <tr>
526: <td><input type=checkbox name="act_$cudom\_$cuname\_ca"></td>
527: <td>Co-Author</td>
528: <td>$cudom\_$cuname</td>
529: <td><input type=hidden name="start_$cudom\_$cuname\_ca" value=''>
530: <a href=
531: "javascript:pjump('date_start','Start Date Co-Author',document.cu.start_$cudom\_$cuname\_ca.value,'start_$cudom\_$cuname\_ca','cu.pres','dateset')">Set Start Date</a></td>
532: <td><input type=hidden name="end_$cudom\_$cuname\_ca" value=''>
533: <a href=
534: "javascript:pjump('date_end','End Date Co-Author',document.cu.end_$cudom\_$cuname\_ca.value,'end_$cudom\_$cuname\_ca','cu.pres','dateset')">Set End Date</a></td>
535: </tr>
536: </table>
537: ENDCOAUTH
538: }
539: #
540: # Domain level
541: #
542: $r->print('<h4>Domain Level</h4>'.
543: '<table border=2><tr><th>Activate</th><th>Role</th><th>Extent</th>'.
544: '<th>Start</th><th>End</th></tr>');
545: foreach ( sort( keys(%incdomains))) {
546: my $thisdomain=$_;
547: foreach ('dc','li','dg','au') {
548: if (&Apache::lonnet::allowed('c'.$_,$thisdomain)) {
549: my $plrole=&Apache::lonnet::plaintext($_);
550: $r->print(<<ENDDROW);
551: <tr>
552: <td><input type=checkbox name="act_$thisdomain\_$_"></td>
553: <td>$plrole</td>
554: <td>$thisdomain</td>
555: <td><input type=hidden name="start_$thisdomain\_$_" value=''>
556: <a href=
557: "javascript:pjump('date_start','Start Date $plrole',document.cu.start_$thisdomain\_$_.value,'start_$thisdomain\_$_','cu.pres','dateset')">Set Start Date</a></td>
558: <td><input type=hidden name="end_$thisdomain\_$_" value=''>
559: <a href=
560: "javascript:pjump('date_end','End Date $plrole',document.cu.end_$thisdomain\_$_.value,'end_$thisdomain\_$_','cu.pres','dateset')">Set End Date</a></td>
561: </tr>
562: ENDDROW
563: }
564: }
565: }
566: $r->print('</table>');
567: #
568: # Course level
569: #
570: $r->print(&course_level_table(%inccourses));
571: $r->print("<hr /><input type=submit value=\"Modify User\">\n");
572: $r->print("</form></body></html>");
573: }
574:
575: # ================================================================= Phase Three
576: sub update_user_data {
577: my $r=shift;
578: my $uhome=&Apache::lonnet::homeserver($ENV{'form.ccuname'},
579: $ENV{'form.ccdomain'});
580: # Error messages
581: my $error = '<font color="#ff0000">Error:</font>';
582: my $end = '</body></html>';
583: # Print header
584: $r->print(<<ENDTHREEHEAD);
585: <html>
586: <head>
587: <title>The LearningOnline Network with CAPA</title>
588: </head>
589: ENDTHREEHEAD
590: my $title;
591: if (exists($ENV{'form.makeuser'})) {
592: $title='Set Privileges for New User';
593: } else {
594: $title='Modify User Privileges';
595: }
596: $r->print(&Apache::loncommon::bodytag($title));
597: # Check Inputs
598: if (! $ENV{'form.ccuname'} ) {
599: $r->print($error.'No login name specified.'.$end);
600: return;
601: }
602: if ( $ENV{'form.ccuname'} =~/\W/) {
603: $r->print($error.'Invalid login name. '.
604: 'Only letters, numbers, and underscores are valid.'.
605: $end);
606: return;
607: }
608: if (! $ENV{'form.ccdomain'} ) {
609: $r->print($error.'No domain specified.'.$end);
610: return;
611: }
612: if ( $ENV{'form.ccdomain'} =~/\W/) {
613: $r->print($error.'Invalid domain name. '.
614: 'Only letters, numbers, and underscores are valid.'.
615: $end);
616: return;
617: }
618: if (! exists($ENV{'form.makeuser'})) {
619: # Modifying an existing user, so check the validity of the name
620: if ($uhome eq 'no_host') {
621: $r->print($error.'Unable to determine home server for '.
622: $ENV{'form.ccuname'}.' in domain '.
623: $ENV{'form.ccdomain'}.'.');
624: return;
625: }
626: }
627: # Determine authentication method and password for the user being modified
628: my $amode='';
629: my $genpwd='';
630: if ($ENV{'form.login'} eq 'krb') {
631: $amode='krb';
632: $amode.=$ENV{'form.krbver'};
633: $genpwd=$ENV{'form.krbarg'};
634: } elsif ($ENV{'form.login'} eq 'int') {
635: $amode='internal';
636: $genpwd=$ENV{'form.intarg'};
637: } elsif ($ENV{'form.login'} eq 'fsys') {
638: $amode='unix';
639: $genpwd=$ENV{'form.fsysarg'};
640: } elsif ($ENV{'form.login'} eq 'loc') {
641: $amode='localauth';
642: $genpwd=$ENV{'form.locarg'};
643: $genpwd=" " if (!$genpwd);
644: } elsif (($ENV{'form.login'} eq 'nochange') ||
645: ($ENV{'form.login'} eq '' )) {
646: # There is no need to tell the user we did not change what they
647: # did not ask us to change.
648: # If they are creating a new user but have not specified login
649: # information this will be caught below.
650: } else {
651: $r->print($error.'Invalid login mode or password'.$end);
652: return;
653: }
654: if ($ENV{'form.makeuser'}) {
655: # Create a new user
656: $r->print(<<ENDNEWUSERHEAD);
657: <h3>Creating user "$ENV{'form.ccuname'}" in domain "$ENV{'form.ccdomain'}"</h2>
658: ENDNEWUSERHEAD
659: # Check for the authentication mode and password
660: if (! $amode || ! $genpwd) {
661: $r->print($error.'Invalid login mode or password'.$end);
662: return;
663: }
664: # Determine desired host
665: my $desiredhost = $ENV{'form.hserver'};
666: if (lc($desiredhost) eq 'default') {
667: $desiredhost = undef;
668: } else {
669: my %home_servers = &Apache::loncommon::get_library_servers
670: ($ENV{'form.ccdomain'});
671: if (! exists($home_servers{$desiredhost})) {
672: $r->print($error.'Invalid home server specified');
673: return;
674: }
675: }
676: # Call modifyuser
677: my $result = &Apache::lonnet::modifyuser
678: ($ENV{'form.ccdomain'},$ENV{'form.ccuname'},$ENV{'form.cstid'},
679: $amode,$genpwd,$ENV{'form.cfirst'},
680: $ENV{'form.cmiddle'},$ENV{'form.clast'},$ENV{'form.cgen'},
681: undef,$desiredhost
682: );
683: $r->print('Generating user: '.$result);
684: my $home = &Apache::lonnet::homeserver($ENV{'form.ccuname'},
685: $ENV{'form.ccdomain'});
686: $r->print('<br>Home server: '.$home.' '.
687: $Apache::lonnet::libserv{$home});
688: } elsif (($ENV{'form.login'} ne 'nochange') &&
689: ($ENV{'form.login'} ne '' )) {
690: # Modify user privileges
691: $r->print(<<ENDMODIFYUSERHEAD);
692: <h2>User "$ENV{'form.ccuname'}" in domain "$ENV{'form.ccdomain'}"</h2>
693: ENDMODIFYUSERHEAD
694: if (! $amode || ! $genpwd) {
695: $r->print($error.'Invalid login mode or password'.$end);
696: return;
697: }
698: # Only allow authentification modification if the person has authority
699: if (&Apache::lonnet::allowed('mau',$ENV{'form.ccdomain'})) {
700: $r->print('Modifying authentication: '.
701: &Apache::lonnet::modifyuserauth(
702: $ENV{'form.ccdomain'},$ENV{'form.ccuname'},
703: $amode,$genpwd));
704: $r->print('<br>Home server: '.&Apache::lonnet::homeserver
705: ($ENV{'form.ccuname'},$ENV{'form.ccdomain'}));
706: } else {
707: # Okay, this is a non-fatal error.
708: $r->print($error.'You do not have the authority to modify '.
709: 'this users authentification information.');
710: }
711: }
712: ##
713: if (! $ENV{'form.makeuser'} ) {
714: # Check for need to change
715: my %userenv = &Apache::lonnet::get
716: ('environment',['firstname','middlename','lastname','generation'],
717: $ENV{'form.ccdomain'},$ENV{'form.ccuname'});
718: my ($tmp) = keys(%userenv);
719: if ($tmp =~ /^(con_lost|error)/i) {
720: %userenv = ();
721: }
722: # Check to see if we need to change user information
723: foreach ('firstname','middlename','lastname','generation') {
724: # Strip leading and trailing whitespace
725: $ENV{'form.c'.$_} =~ s/(\s+$|^\s+)//g;
726: }
727: if (&Apache::lonnet::allowed('mau',$ENV{'form.ccdomain'}) &&
728: ($ENV{'form.cfirstname'} ne $userenv{'firstname'} ||
729: $ENV{'form.cmiddlename'} ne $userenv{'middlename'} ||
730: $ENV{'form.clastname'} ne $userenv{'lastname'} ||
731: $ENV{'form.cgeneration'} ne $userenv{'generation'} )) {
732: # Make the change
733: my %changeHash;
734: $changeHash{'firstname'} = $ENV{'form.cfirstname'};
735: $changeHash{'middlename'} = $ENV{'form.cmiddlename'};
736: $changeHash{'lastname'} = $ENV{'form.clastname'};
737: $changeHash{'generation'} = $ENV{'form.cgeneration'};
738: my $putresult = &Apache::lonnet::put
739: ('environment',\%changeHash,
740: $ENV{'form.ccdomain'},$ENV{'form.ccuname'});
741: if ($putresult eq 'ok') {
742: # Tell the user we changed the name
743: $r->print(<<"END");
744: <table border="2">
745: <caption>User Information Changed</caption>
746: <tr><th> </th>
747: <th>first</th>
748: <th>middle</th>
749: <th>last</th>
750: <th>generation</th></tr>
751: <tr><td>Previous</td>
752: <td>$userenv{'firstname'} </td>
753: <td>$userenv{'middlename'} </td>
754: <td>$userenv{'lastname'} </td>
755: <td>$userenv{'generation'} </td></tr>
756: <tr><td>Changed To</td>
757: <td>$ENV{'form.cfirstname'} </td>
758: <td>$ENV{'form.cmiddlename'} </td>
759: <td>$ENV{'form.clastname'} </td>
760: <td>$ENV{'form.cgeneration'} </td></tr>
761: </table>
762: END
763: } else { # error occurred
764: $r->print("<h2>Unable to successfully change environment for ".
765: $ENV{'form.ccuname'}." in domain ".
766: $ENV{'form.ccdomain'}."</h2>");
767: }
768: } else { # End of if ($ENV ... ) logic
769: # They did not want to change the users name but we can
770: # still tell them what the name is
771: $r->print(<<"END");
772: <h2>User "$ENV{'form.ccuname'}" in domain "$ENV{'form.ccdomain'}"</h2>
773: <h4>$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} </h4>
774: <h4>Generation: $userenv{'generation'}</h4>
775: END
776: }
777: }
778: ##
779: my $now=time;
780: $r->print('<h3>Modifying Roles</h3>');
781: foreach (keys (%ENV)) {
782: next if (! $ENV{$_});
783: # Revoke roles
784: if ($_=~/^form\.rev/) {
785: if ($_=~/^form\.rev\:([^\_]+)\_([^\_\.]+)$/) {
786: # Revoke standard role
787: $r->print('Revoking '.$2.' in '.$1.': <b>'.
788: &Apache::lonnet::revokerole($ENV{'form.ccdomain'},
789: $ENV{'form.ccuname'},$1,$2).'</b><br>');
790: if ($2 eq 'st') {
791: $1=~/^\/(\w+)\/(\w+)/;
792: my $cid=$1.'_'.$2;
793: $r->print('Drop from classlist: <b>'.
794: &Apache::lonnet::critical('put:'.
795: $ENV{'course.'.$cid.'.domain'}.':'.
796: $ENV{'course.'.$cid.'.num'}.':classlist:'.
797: &Apache::lonnet::escape($ENV{'form.ccuname'}.':'.
798: $ENV{'form.ccdomain'}).'='.
799: &Apache::lonnet::escape($now.':'),
800: $ENV{'course.'.$cid.'.home'}).'</b><br>');
801: }
802: }
803: if ($_=~/^form\.rev\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
804: # Revoke custom role
805: $r->print(
806: 'Revoking custom role '.$4.' by '.$3.'@'.$2.' in '.$1.': <b>'.
807: &Apache::lonnet::revokecustomrole($ENV{'form.ccdomain'},
808: $ENV{'form.ccuname'},$1,$2,$3,$4).
809: '</b><br>');
810: }
811: } elsif ($_=~/^form\.del/) {
812: if ($_=~/^form\.del\:([^\_]+)\_([^\_]+)$/) {
813: $r->print('Deleting '.$2.' in '.$1.': '.
814: &Apache::lonnet::assignrole($ENV{'form.ccdomain'},
815: $ENV{'form.ccuname'},$1,$2,$now,0,1).'<br>');
816: if ($2 eq 'st') {
817: $1=~/^\/(\w+)\/(\w+)/;
818: my $cid=$1.'_'.$2;
819: $r->print('Drop from classlist: <b>'.
820: &Apache::lonnet::critical('put:'.
821: $ENV{'course.'.$cid.'.domain'}.':'.
822: $ENV{'course.'.$cid.'.num'}.':classlist:'.
823: &Apache::lonnet::escape($ENV{'form.ccuname'}.':'.
824: $ENV{'form.ccdomain'}).'='.
825: &Apache::lonnet::escape($now.':'),
826: $ENV{'course.'.$cid.'.home'}).'</b><br>');
827: }
828: }
829: } elsif ($_=~/^form\.act/) {
830: if
831: ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_cr_cr_([^\_]+)_(\w+)_([^\_]+)$/) {
832: # Activate a custom role
833: my $url='/'.$1.'/'.$2;
834: my $full=$1.'_'.$2.'_cr_cr_'.$3.'_'.$4.'_'.$5;
835: if ($ENV{'form.sec_'.$full}) {
836: $url.='/'.$ENV{'form.sec_'.$full};
837: }
838:
839: my $start = ( $ENV{'form.start_'.$full} ?
840: $ENV{'form.start_'.$full} :
841: $now );
842: my $end = ( $ENV{'form.end_'.$full} ?
843: $ENV{'form.end_'.$full} :
844: 0 );
845:
846: $r->print('Assigning custom role "'.$5.'" by '.$4.'@'.$3.' in '.$url.
847: ($start?', starting '.localtime($start):'').
848: ($end?', ending '.localtime($end):'').': <b>'.
849: &Apache::lonnet::assigncustomrole(
850: $ENV{'form.ccdomain'},$ENV{'form.ccuname'},$url,$3,$4,$5,$end,$start).
851: '</b><br>');
852: } elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_([^\_]+)$/) {
853: # Activate roles for sections with 3 id numbers
854: # set start, end times, and the url for the class
855:
856: my $start = ( $ENV{'form.start_'.$1.'_'.$2.'_'.$3} ?
857: $ENV{'form.start_'.$1.'_'.$2.'_'.$3} :
858: $now );
859: my $end = ( $ENV{'form.end_'.$1.'_'.$2.'_'.$3} ?
860: $ENV{'form.end_'.$1.'_'.$2.'_'.$3} :
861: 0 );
862: my $url='/'.$1.'/'.$2;
863: if ($ENV{'form.sec_'.$1.'_'.$2.'_'.$3}) {
864: $url.='/'.$ENV{'form.sec_'.$1.'_'.$2.'_'.$3};
865: }
866: # Assign the role and report it
867: $r->print('Assigning '.$3.' in '.$url.
868: ($start?', starting '.localtime($start):'').
869: ($end?', ending '.localtime($end):'').': <b>'.
870: &Apache::lonnet::assignrole(
871: $ENV{'form.ccdomain'},$ENV{'form.ccuname'},
872: $url,$3,$end,$start).
873: '</b><br>');
874: # Handle students differently
875: if ($3 eq 'st') {
876: $url=~/^\/(\w+)\/(\w+)/;
877: my $cid=$1.'_'.$2;
878: $r->print('Add to classlist: <b>'.
879: &Apache::lonnet::critical(
880: 'put:'.$ENV{'course.'.$cid.'.domain'}.':'.
881: $ENV{'course.'.$cid.'.num'}.':classlist:'.
882: &Apache::lonnet::escape(
883: $ENV{'form.ccuname'}.':'.
884: $ENV{'form.ccdomain'} ).'='.
885: &Apache::lonnet::escape($end.':'.$start),
886: $ENV{'course.'.$cid.'.home'})
887: .'</b><br>');
888: }
889: } elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)$/) {
890: # Activate roles for sections with two id numbers
891: # set start, end times, and the url for the class
892: my $start = ( $ENV{'form.start_'.$1.'_'.$2} ?
893: $ENV{'form.start_'.$1.'_'.$2} :
894: $now );
895: my $end = ( $ENV{'form.end_'.$1.'_'.$2} ?
896: $ENV{'form.end_'.$1.'_'.$2} :
897: 0 );
898: my $url='/'.$1.'/';
899: # Assign the role and report it.
900: $r->print('Assigning '.$2.' in '.$url.': '.
901: ($start?', starting '.localtime($start):'').
902: ($end?', ending '.localtime($end):'').': <b>'.
903: &Apache::lonnet::assignrole(
904: $ENV{'form.ccdomain'},$ENV{'form.ccuname'},
905: $url,$2,$end,$start)
906: .'</b><br>');
907: } else {
908: $r->print('<p>ERROR: Unknown command <tt>'.$_.'</tt></p><br>');
909: }
910: }
911: } # End of foreach (keys(%ENV))
912: $r->print('</body></html>');
913: }
914:
915: # ========================================================== Custom Role Editor
916:
917: sub custom_role_editor {
918: my $r=shift;
919: my $rolename=$ENV{'form.rolename'};
920:
921: if ($rolename eq 'make new role') {
922: $rolename=$ENV{'form.newrolename'};
923: }
924:
925: $rolename=~s/[^A-Za-z0-9]//gs;
926:
927: unless ($rolename) {
928: &print_username_entry_form($r);
929: return;
930: }
931:
932: $r->print(&Apache::loncommon::bodytag(
933: 'Create Users, Change User Privileges').'<h2>');
934: my $syspriv='';
935: my $dompriv='';
936: my $coursepriv='';
937: my ($rdummy,$roledef)=
938: &Apache::lonnet::get('roles',["rolesdef_$rolename"]);
939: # ------------------------------------------------------- Does this role exist?
940: if (($rdummy ne 'con_lost') && ($roledef ne '')) {
941: $r->print('Existing Role "');
942: # ------------------------------------------------- Get current role privileges
943: ($syspriv,$dompriv,$coursepriv)=split(/\_/,$roledef);
944: } else {
945: $r->print('New Role "');
946: $roledef='';
947: }
948: $r->print($rolename.'"</h2>');
949: # ------------------------------------------------------- What can be assigned?
950: my %full=();
951: my %courselevel=();
952: my %courselevelcurrent=();
953: foreach (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
954: my ($priv,$restrict)=split(/\&/,$_);
955: unless ($restrict) { $restrict='F'; }
956: $courselevel{$priv}=$restrict;
957: if ($coursepriv=~/\:$priv/) {
958: $courselevelcurrent{$priv}=1;
959: }
960: $full{$priv}=1;
961: }
962: my %domainlevel=();
963: my %domainlevelcurrent=();
964: foreach (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
965: my ($priv,$restrict)=split(/\&/,$_);
966: unless ($restrict) { $restrict='F'; }
967: $domainlevel{$priv}=$restrict;
968: if ($dompriv=~/\:$priv/) {
969: $domainlevelcurrent{$priv}=1;
970: }
971: $full{$priv}=1;
972: }
973: my %systemlevel=();
974: my %systemlevelcurrent=();
975: foreach (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
976: my ($priv,$restrict)=split(/\&/,$_);
977: unless ($restrict) { $restrict='F'; }
978: $systemlevel{$priv}=$restrict;
979: if ($syspriv=~/\:$priv/) {
980: $systemlevelcurrent{$priv}=1;
981: }
982: $full{$priv}=1;
983: }
984: $r->print(<<ENDCCF);
985: <form method="post">
986: <input type="hidden" name="phase" value="set_custom_roles" />
987: <input type="hidden" name="rolename" value="$rolename" />
988: <table border="2">
989: <tr><th>Privilege</th><th>Course Level</th><th>Domain Level</th>
990: <th>System Level</th></tr>
991: ENDCCF
992: foreach (sort keys %full) {
993: $r->print('<tr><td>'.&Apache::lonnet::plaintext($_).'</td><td>'.
994: ($courselevel{$_}?'<input type="checkbox" name="'.$_.':c" '.
995: ($courselevelcurrent{$_}?'checked="1"':'').' />':' ').
996: '</td><td>'.
997: ($domainlevel{$_}?'<input type="checkbox" name="'.$_.':d" '.
998: ($domainlevelcurrent{$_}?'checked="1"':'').' />':' ').
999: '</td><td>'.
1000: ($systemlevel{$_}?'<input type="checkbox" name="'.$_.':s" '.
1001: ($systemlevelcurrent{$_}?'checked="1"':'').' />':' ').
1002: '</td></tr>');
1003: }
1004: $r->print(
1005: '<table><input type="submit" value="Define Role" /></form></body></html>');
1006: }
1007:
1008: # ---------------------------------------------------------- Call to definerole
1009: sub set_custom_role {
1010: my $r=shift;
1011:
1012: my $rolename=$ENV{'form.rolename'};
1013:
1014: $rolename=~s/[^A-Za-z0-9]//gs;
1015:
1016: unless ($rolename) {
1017: &print_username_entry_form($r);
1018: return;
1019: }
1020:
1021: $r->print(&Apache::loncommon::bodytag(
1022: 'Create Users, Change User Privileges').'<h2>');
1023: my ($rdummy,$roledef)=
1024: &Apache::lonnet::get('roles',["rolesdef_$rolename"]);
1025: # ------------------------------------------------------- Does this role exist?
1026: if (($rdummy ne 'con_lost') && ($roledef ne '')) {
1027: $r->print('Existing Role "');
1028: } else {
1029: $r->print('New Role "');
1030: $roledef='';
1031: }
1032: $r->print($rolename.'"</h2>');
1033: # ------------------------------------------------------- What can be assigned?
1034: my $sysrole='';
1035: my $domrole='';
1036: my $courole='';
1037:
1038: foreach (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
1039: my ($priv,$restrict)=split(/\&/,$_);
1040: unless ($restrict) { $restrict=''; }
1041: if ($ENV{'form.'.$priv.':c'}) {
1042: $courole.=':'.$_;
1043: }
1044: }
1045:
1046: foreach (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
1047: my ($priv,$restrict)=split(/\&/,$_);
1048: unless ($restrict) { $restrict=''; }
1049: if ($ENV{'form.'.$priv.':d'}) {
1050: $domrole.=':'.$_;
1051: }
1052: }
1053:
1054: foreach (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
1055: my ($priv,$restrict)=split(/\&/,$_);
1056: unless ($restrict) { $restrict=''; }
1057: if ($ENV{'form.'.$priv.':s'}) {
1058: $sysrole.=':'.$_;
1059: }
1060: }
1061: $r->print('<br />Defining Role: '.
1062: &Apache::lonnet::definerole($rolename,$sysrole,$domrole,$courole));
1063: if ($ENV{'request.course.id'}) {
1064: my $url='/'.$ENV{'request.course.id'};
1065: $url=~s/\_/\//g;
1066: $r->print('<br />Assigning Role to Self: '.
1067: &Apache::lonnet::assigncustomrole($ENV{'user.domain'},
1068: $ENV{'user.name'},
1069: $url,
1070: $ENV{'user.domain'},
1071: $ENV{'user.name'},
1072: $rolename));
1073: }
1074: $r->print('</body></html>');
1075: }
1076:
1077: # ================================================================ Main Handler
1078: sub handler {
1079: my $r = shift;
1080:
1081: if ($r->header_only) {
1082: $r->content_type('text/html');
1083: $r->send_http_header;
1084: return OK;
1085: }
1086:
1087: if ((&Apache::lonnet::allowed('cta',$ENV{'request.course.id'})) ||
1088: (&Apache::lonnet::allowed('cin',$ENV{'request.course.id'})) ||
1089: (&Apache::lonnet::allowed('ccr',$ENV{'request.course.id'})) ||
1090: (&Apache::lonnet::allowed('cep',$ENV{'request.course.id'})) ||
1091: (&Apache::lonnet::allowed('cca',$ENV{'request.role.domain'})) ||
1092: (&Apache::lonnet::allowed('mau',$ENV{'request.role.domain'}))) {
1093: $r->content_type('text/html');
1094: $r->send_http_header;
1095: unless ($ENV{'form.phase'}) {
1096: &print_username_entry_form($r);
1097: }
1098: if ($ENV{'form.phase'} eq 'get_user_info') {
1099: &print_user_modification_page($r);
1100: } elsif ($ENV{'form.phase'} eq 'update_user_data') {
1101: &update_user_data($r);
1102: } elsif ($ENV{'form.phase'} eq 'selected_custom_edit') {
1103: &custom_role_editor($r);
1104: } elsif ($ENV{'form.phase'} eq 'set_custom_roles') {
1105: &set_custom_role($r);
1106: }
1107: } else {
1108: $ENV{'user.error.msg'}=
1109: "/adm/createuser:mau:0:0:Cannot modify user data";
1110: return HTTP_NOT_ACCEPTABLE;
1111: }
1112: return OK;
1113: }
1114:
1115: #-------------------------------------------------- functions for &phase_two
1116: sub course_level_table {
1117: my %inccourses = @_;
1118: my $table = '';
1119: # Custom Roles?
1120:
1121: my %customroles=&my_custom_roles();
1122:
1123: foreach (sort( keys(%inccourses))) {
1124: my $thiscourse=$_;
1125: my $protectedcourse=$_;
1126: $thiscourse=~s:_:/:g;
1127: my %coursedata=&Apache::lonnet::coursedescription($thiscourse);
1128: my $area=$coursedata{'description'};
1129: if (!defined($area)) { $area='Unavailable course: '.$_; }
1130: my $bgcol=$thiscourse;
1131: $bgcol=~s/[^7-9a-e]//g;
1132: $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',2,6);
1133: foreach ('st','ta','ep','ad','in','cc') {
1134: if (&Apache::lonnet::allowed('c'.$_,$thiscourse)) {
1135: my $plrole=&Apache::lonnet::plaintext($_);
1136: $table .= <<ENDEXTENT;
1137: <tr bgcolor="#$bgcol">
1138: <td><input type="checkbox" name="act_$protectedcourse\_$_"></td>
1139: <td>$plrole</td>
1140: <td>$area</td>
1141: ENDEXTENT
1142: if ($_ ne 'cc') {
1143: $table .= <<ENDSECTION;
1144: <td><input type="text" size="5" name="sec_$protectedcourse\_$_"></td>
1145: ENDSECTION
1146: } else {
1147: $table .= <<ENDSECTION;
1148: <td> </td>
1149: ENDSECTION
1150: }
1151: $table .= <<ENDTIMEENTRY;
1152: <td><input type=hidden name="start_$protectedcourse\_$_" value=''>
1153: <a href=
1154: "javascript:pjump('date_start','Start Date $plrole',document.cu.start_$protectedcourse\_$_.value,'start_$protectedcourse\_$_','cu.pres','dateset')">Set Start Date</a></td>
1155: <td><input type=hidden name="end_$protectedcourse\_$_" value=''>
1156: <a href=
1157: "javascript:pjump('date_end','End Date $plrole',document.cu.end_$protectedcourse\_$_.value,'end_$protectedcourse\_$_','cu.pres','dateset')">Set End Date</a></td>
1158: ENDTIMEENTRY
1159: $table.= "</tr>\n";
1160: }
1161: }
1162: foreach (sort keys %customroles) {
1163: if (&Apache::lonnet::allowed('ccr',$thiscourse)) {
1164: my $plrole=$_;
1165: my $customrole=$protectedcourse.'_cr_cr_'.$ENV{'user.domain'}.
1166: '_'.$ENV{'user.name'}.'_'.$plrole;
1167: $table .= <<ENDENTRY;
1168: <tr bgcolor="#$bgcol">
1169: <td><input type="checkbox" name="act_$customrole"></td>
1170: <td>$plrole</td>
1171: <td>$area</td>
1172: <td><input type="text" size="5" name="sec_$customrole"></td>
1173: <td><input type=hidden name="start_$customrole" value=''>
1174: <a href=
1175: "javascript:pjump('date_start','Start Date $plrole',document.cu.start_$customrole.value,'start_$customrole','cu.pres','dateset')">Set Start Date</a></td>
1176: <td><input type=hidden name="end_$customrole" value=''>
1177: <a href=
1178: "javascript:pjump('date_end','End Date $plrole',document.cu.end_$customrole.value,'end_$customrole','cu.pres','dateset')">Set End Date</a></td></tr>
1179: ENDENTRY
1180: }
1181: }
1182: }
1183: return '' if ($table eq ''); # return nothing if there is nothing
1184: # in the table
1185: my $result = <<ENDTABLE;
1186: <h4>Course Level</h4>
1187: <table border=2><tr><th>Activate</th><th>Role</th><th>Extent</th>
1188: <th>Group/Section</th><th>Start</th><th>End</th></tr>
1189: $table
1190: </table>
1191: ENDTABLE
1192: return $result;
1193: }
1194: #---------------------------------------------- end functions for &phase_two
1195:
1196: #--------------------------------- functions for &phase_two and &phase_three
1197:
1198: #--------------------------end of functions for &phase_two and &phase_three
1199:
1200: 1;
1201: __END__
1202:
1203:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>