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