Annotation of loncom/interface/loncreateuser.pm, revision 1.228
1.20 harris41 1: # The LearningOnline Network with CAPA
1.1 www 2: # Create a user
3: #
1.228 ! raeburn 4: # $Id: loncreateuser.pm,v 1.227 2008/01/01 17:24:59 raeburn Exp $
1.22 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.20 harris41 28: ###
29:
1.1 www 30: package Apache::loncreateuser;
1.66 bowersj2 31:
32: =pod
33:
34: =head1 NAME
35:
36: Apache::loncreateuser - handler to create users and custom roles
37:
38: =head1 SYNOPSIS
39:
40: Apache::loncreateuser provides an Apache handler for creating users,
41: editing their login parameters, roles, and removing roles, and
42: also creating and assigning custom roles.
43:
44: =head1 OVERVIEW
45:
46: =head2 Custom Roles
47:
48: In LON-CAPA, roles are actually collections of privileges. "Teaching
49: Assistant", "Course Coordinator", and other such roles are really just
50: collection of privileges that are useful in many circumstances.
51:
52: Creating custom roles can be done by the Domain Coordinator through
53: the Create User functionality. That screen will show all privileges
54: that can be assigned to users. For a complete list of privileges,
55: please see C</home/httpd/lonTabs/rolesplain.tab>.
56:
57: Custom role definitions are stored in the C<roles.db> file of the role
58: author.
59:
60: =cut
1.1 www 61:
62: use strict;
63: use Apache::Constants qw(:common :http);
64: use Apache::lonnet;
1.54 bowersj2 65: use Apache::loncommon;
1.68 www 66: use Apache::lonlocal;
1.117 raeburn 67: use Apache::longroup;
1.190 raeburn 68: use Apache::lonuserutils;
1.139 albertel 69: use LONCAPA qw(:DEFAULT :match);
1.1 www 70:
1.20 harris41 71: my $loginscript; # piece of javascript used in two separate instances
72: my $authformnop;
73: my $authformkrb;
74: my $authformint;
75: my $authformfsys;
76: my $authformloc;
77:
1.94 matthew 78: sub initialize_authen_forms {
1.227 raeburn 79: my ($dom,$formname,$curr_authtype,$mode) = @_;
80: my ($krbdef,$krbdefdom) = &Apache::loncommon::get_kerberos_defaults($dom);
81: my %param = ( formname => $formname,
1.187 raeburn 82: kerb_def_dom => $krbdefdom,
1.227 raeburn 83: kerb_def_auth => $krbdef,
1.187 raeburn 84: domain => $dom,
85: );
1.188 raeburn 86: my %abv_auth = &auth_abbrev();
1.227 raeburn 87: if ($curr_authtype =~ /^(krb4|krb5|internal|localauth|unix):(.*)$/) {
1.188 raeburn 88: my $long_auth = $1;
1.227 raeburn 89: my $curr_autharg = $2;
1.188 raeburn 90: my %abv_auth = &auth_abbrev();
91: $param{'curr_authtype'} = $abv_auth{$long_auth};
92: if ($long_auth =~ /^krb(4|5)$/) {
93: $param{'curr_kerb_ver'} = $1;
1.227 raeburn 94: $param{'curr_autharg'} = $curr_autharg;
1.188 raeburn 95: }
1.205 raeburn 96: if ($mode eq 'modifyuser') {
97: $param{'mode'} = $mode;
98: }
1.187 raeburn 99: }
1.227 raeburn 100: $loginscript = &Apache::loncommon::authform_header(%param);
101: $authformkrb = &Apache::loncommon::authform_kerberos(%param);
1.31 matthew 102: $authformnop = &Apache::loncommon::authform_nochange(%param);
103: $authformint = &Apache::loncommon::authform_internal(%param);
104: $authformfsys = &Apache::loncommon::authform_filesystem(%param);
105: $authformloc = &Apache::loncommon::authform_local(%param);
1.20 harris41 106: }
107:
1.188 raeburn 108: sub auth_abbrev {
109: my %abv_auth = (
110: krb4 => 'krb',
111: internal => 'int',
112: localuth => 'loc',
113: unix => 'fsys',
114: );
115: return %abv_auth;
116: }
1.43 www 117:
1.134 raeburn 118: # ====================================================
119:
120: sub portfolio_quota {
121: my ($ccuname,$ccdomain) = @_;
122: my %lt = &Apache::lonlocal::texthash(
123: 'disk' => "Disk space allocated to user's portfolio files",
1.149 raeburn 124: 'cuqu' => "Current quota",
125: 'cust' => "Custom quota",
126: 'defa' => "Default",
127: 'chqu' => "Change quota",
1.134 raeburn 128: );
1.149 raeburn 129: my ($currquota,$quotatype,$inststatus,$defquota) =
130: &Apache::loncommon::get_user_quota($ccuname,$ccdomain);
131: my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($ccdomain);
132: my ($longinsttype,$showquota,$custom_on,$custom_off,$defaultinfo);
133: if ($inststatus ne '') {
134: if ($usertypes->{$inststatus} ne '') {
135: $longinsttype = $usertypes->{$inststatus};
136: }
137: }
138: $custom_on = ' ';
139: $custom_off = ' checked="checked" ';
140: my $quota_javascript = <<"END_SCRIPT";
141: <script type="text/javascript">
142: function quota_changes(caller) {
143: if (caller == "custom") {
144: if (document.cu.customquota[0].checked) {
145: document.cu.portfolioquota.value = "";
146: }
147: }
148: if (caller == "quota") {
149: document.cu.customquota[1].checked = true;
150: }
151: }
152: </script>
153: END_SCRIPT
154: if ($quotatype eq 'custom') {
155: $custom_on = $custom_off;
156: $custom_off = ' ';
157: $showquota = $currquota;
158: if ($longinsttype eq '') {
159: $defaultinfo = &mt('For this user, the default quota would be [_1]
160: Mb.',$defquota);
161: } else {
162: $defaultinfo = &mt("For this user, the default quota would be [_1]
163: Mb, as determined by the user's institutional
164: affiliation ([_2]).",$defquota,$longinsttype);
165: }
166: } else {
167: if ($longinsttype eq '') {
168: $defaultinfo = &mt('For this user, the default quota is [_1]
169: Mb.',$defquota);
170: } else {
171: $defaultinfo = &mt("For this user, the default quota of [_1]
172: Mb, is determined by the user's institutional
173: affiliation ([_2]).",$defquota,$longinsttype);
174: }
175: }
176: my $output = $quota_javascript.
177: '<h3>'.$lt{'disk'}.'</h3>'.
1.188 raeburn 178: &Apache::loncommon::start_data_table().
179: &Apache::loncommon::start_data_table_row().
180: '<td>'.$lt{'cuqu'}.': '.$currquota.' Mb. '.
181: $defaultinfo.'</td>'.
182: &Apache::loncommon::end_data_table_row().
183: &Apache::loncommon::start_data_table_row().
184: '<td><span class="LC_nobreak">'.$lt{'chqu'}.
1.149 raeburn 185: ': <label>'.
186: '<input type="radio" name="customquota" value="0" '.
187: $custom_off.' onchange="javascript:quota_changes('."'custom'".')"
188: />'.$lt{'defa'}.' ('.$defquota.' Mb).</label> '.
189: ' <label><input type="radio" name="customquota" value="1" '.
190: $custom_on.' onchange="javascript:quota_changes('."'custom'".')" />'.
191: $lt{'cust'}.':</label> '.
1.134 raeburn 192: '<input type="text" name="portfolioquota" size ="5" value="'.
1.149 raeburn 193: $showquota.'" onfocus="javascript:quota_changes('."'quota'".')" '.
1.188 raeburn 194: '/> Mb</span></td>'.
195: &Apache::loncommon::end_data_table_row().
196: &Apache::loncommon::end_data_table();
1.134 raeburn 197: return $output;
198: }
199:
1.2 www 200: # =================================================================== Phase one
1.1 www 201:
1.42 matthew 202: sub print_username_entry_form {
1.207 raeburn 203: my ($r,$context,$response,$srch,$forcenewuser) = @_;
1.101 albertel 204: my $defdom=$env{'request.role.domain'};
1.160 raeburn 205: my $formtoset = 'crtuser';
206: if (exists($env{'form.startrolename'})) {
207: $formtoset = 'docustom';
208: $env{'form.rolename'} = $env{'form.startrolename'};
1.207 raeburn 209: } elsif ($env{'form.origform'} eq 'crtusername') {
210: $formtoset = $env{'form.origform'};
1.160 raeburn 211: }
212:
213: my ($jsback,$elements) = &crumb_utilities();
214:
215: my $jscript = &Apache::loncommon::studentbrowser_javascript()."\n".
1.165 albertel 216: '<script type="text/javascript">'."\n".
1.160 raeburn 217: &Apache::lonhtmlcommon::set_form_elements($elements->{$formtoset}).
1.162 raeburn 218: '</script>'."\n";
1.160 raeburn 219:
220: my %loaditems = (
221: 'onload' => "javascript:setFormElements(document.$formtoset)",
222: );
1.110 albertel 223: my $start_page =
1.190 raeburn 224: &Apache::loncommon::start_page('User Management',
1.160 raeburn 225: $jscript,{'add_entries' => \%loaditems,});
1.214 raeburn 226: if ($env{'form.action'} eq 'custom') {
227: &Apache::lonhtmlcommon::add_breadcrumb
228: ({href=>"javascript:backPage(document.crtuser)",
229: text=>"Pick custom role",});
230: } else {
1.190 raeburn 231: &Apache::lonhtmlcommon::add_breadcrumb
232: ({href=>"javascript:backPage(document.crtuser)",
233: text=>"Single user search",
234: faq=>282,bug=>'Instructor Interface',});
235: }
1.224 raeburn 236: my $helpitem = 'Course_Change_Privileges';
237: if ($env{'form.action'} eq 'custom') {
238: $helpitem = 'Course_Editing_Custom_Roles';
239: } elsif ($env{'form.action'} eq 'singlestudent') {
240: $helpitem = 'Course_Add_Student';
241: }
242: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management',
243: $helpitem);
1.190 raeburn 244: my %existingroles=&Apache::lonuserutils::my_custom_roles();
1.59 www 245: my $choice=&Apache::loncommon::select_form('make new role','rolename',
246: ('make new role' => 'Generate new role ...',%existingroles));
1.71 sakharuk 247: my %lt=&Apache::lonlocal::texthash(
1.160 raeburn 248: 'srch' => "User Search",
249: or => "or",
1.71 sakharuk 250: 'usr' => "Username",
251: 'dom' => "Domain",
252: 'ecrp' => "Edit Custom Role Privileges",
1.72 sakharuk 253: 'nr' => "Name of Role",
1.160 raeburn 254: 'cre' => "Custom Role Editor",
1.214 raeburn 255: 'mod' => "to modify user information or add/modify roles",
256: 'enrl' => "to enroll one student",
1.71 sakharuk 257: );
1.122 albertel 258: my $help = &Apache::loncommon::help_open_menu(undef,undef,282,'Instructor Interface');
1.160 raeburn 259: my $sellink=&Apache::loncommon::selectstudent_link('crtuser','srchterm','srchdomain');
260: if ($sellink) {
261: $sellink = "$lt{'or'} ".$sellink;
262: }
1.190 raeburn 263: $r->print($start_page."\n".$crumbs);
1.214 raeburn 264: if ($env{'form.action'} eq 'custom') {
1.190 raeburn 265: if (&Apache::lonnet::allowed('mcr','/')) {
266: $r->print(<<ENDCUSTOM);
1.58 www 267: <form action="/adm/createuser" method="post" name="docustom">
1.190 raeburn 268: <input type="hidden" name="action" value="$env{'form.action'}" />
1.157 albertel 269: <input type="hidden" name="phase" value="selected_custom_edit" />
1.224 raeburn 270: <h3>$lt{'ecrp'}</h3>
1.72 sakharuk 271: $lt{'nr'}: $choice <input type="text" size="15" name="newrolename" /><br />
1.71 sakharuk 272: <input name="customeditor" type="submit" value="$lt{'cre'}" />
1.107 www 273: </form>
1.106 www 274: ENDCUSTOM
1.190 raeburn 275: }
1.213 raeburn 276: } else {
1.224 raeburn 277: my $actiontext = $lt{'mod'};
1.213 raeburn 278: if ($env{'form.action'} eq 'singlestudent') {
1.224 raeburn 279: $actiontext = $lt{'enrl'};
1.213 raeburn 280: }
281: $r->print("
282: <h3>$lt{'srch'} $sellink $actiontext</h3>");
283: if ($env{'form.origform'} ne 'crtusername') {
284: $r->print("\n".$response);
285: }
286: $r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response));
1.107 www 287: }
1.110 albertel 288: $r->print(&Apache::loncommon::end_page());
289: }
290:
1.160 raeburn 291: sub entry_form {
1.214 raeburn 292: my ($dom,$srch,$forcenewuser,$context,$responsemsg) = @_;
1.207 raeburn 293: my %domconf = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom);
1.214 raeburn 294: my $usertype;
295: if (ref($srch) eq 'HASH') {
296: if (($srch->{'srchin'} eq 'dom') &&
297: ($srch->{'srchby'} eq 'uname') &&
298: ($srch->{'srchtype'} eq 'exact') &&
299: ($srch->{'srchdomain'} ne '') &&
300: ($srch->{'srchterm'} ne '')) {
301: my ($rules,$ruleorder) =
302: &Apache::lonnet::inst_userrules($srch->{'srchdomain'},'username');
303: $usertype = &Apache::lonuserutils::check_usertype($srch->{'srchdomain'},$srch->{'srchterm'},$rules);
304: }
1.207 raeburn 305: }
1.214 raeburn 306: my $cancreate =
307: &Apache::lonuserutils::can_create_user($dom,$context,$usertype);
1.160 raeburn 308: my $userpicker =
1.179 raeburn 309: &Apache::loncommon::user_picker($dom,$srch,$forcenewuser,
1.214 raeburn 310: 'document.crtuser',$cancreate,$usertype);
1.160 raeburn 311: my $srchbutton = &mt('Search');
1.207 raeburn 312: my $output = <<"ENDBLOCK";
1.160 raeburn 313: <form action="/adm/createuser" method="post" name="crtuser">
1.190 raeburn 314: <input type="hidden" name="action" value="$env{'form.action'}" />
1.160 raeburn 315: <input type="hidden" name="phase" value="get_user_info" />
316: $userpicker
1.179 raeburn 317: <input name="userrole" type="button" value="$srchbutton" onclick="javascript:validateEntry(document.crtuser)" />
1.160 raeburn 318: </form>
1.207 raeburn 319: ENDBLOCK
1.211 raeburn 320: if ($cancreate && $env{'form.phase'} eq '') {
1.207 raeburn 321: my $defdom=$env{'request.role.domain'};
322: my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');
323: my %lt=&Apache::lonlocal::texthash(
324: 'crnu' => 'Create a new user',
325: 'usr' => 'Username',
326: 'dom' => 'in domain',
327: 'cra' => 'Create user',
328: );
329: $output .= <<"ENDDOCUMENT";
330: <form action="/adm/createuser" method="post" name="crtusername">
331: <input type="hidden" name="action" value="$env{'form.action'}" />
332: <input type="hidden" name="phase" value="createnewuser" />
333: <input type="hidden" name="srchtype" value="exact" />
334: <input type="hidden" name="srchby" value="username" />
335: <input type="hidden" name="srchin" value="dom" />
336: <input type="hidden" name="forcenewuser" value="1" />
337: <input type="hidden" name="origform" value="crtusername" />
1.228 ! raeburn 338: <h3>$lt{crnu}</h3>
1.214 raeburn 339: $responsemsg
1.207 raeburn 340: <table>
341: <tr>
342: <td>$lt{'usr'}:</td>
343: <td><input type="text" size="15" name="srchterm" /></td>
344: <td> $lt{'dom'}:</td><td>$domform</td>
345: <td> <input name="userrole" type="submit" value="$lt{'cra'}" /></td>
346: </tr>
347: </table>
348: </form>
1.160 raeburn 349: ENDDOCUMENT
1.207 raeburn 350: }
1.160 raeburn 351: return $output;
352: }
1.110 albertel 353:
354: sub user_modification_js {
1.113 raeburn 355: my ($pjump_def,$dc_setcourse_code,$nondc_setsection_code,$groupslist)=@_;
356:
1.110 albertel 357: return <<END;
358: <script type="text/javascript" language="Javascript">
359:
360: function pclose() {
361: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
362: "height=350,width=350,scrollbars=no,menubar=no");
363: parmwin.close();
364: }
365:
366: $pjump_def
367: $dc_setcourse_code
368:
369: function dateset() {
370: eval("document.cu."+document.cu.pres_marker.value+
371: ".value=document.cu.pres_value.value");
372: pclose();
373: }
374:
1.113 raeburn 375: $nondc_setsection_code
376:
1.110 albertel 377: </script>
378: END
1.2 www 379: }
380:
381: # =================================================================== Phase two
1.160 raeburn 382: sub print_user_selection_page {
1.207 raeburn 383: my ($r,$response,$srch,$srch_results,$operation,$srcharray,$context) = @_;
1.160 raeburn 384: my @fields = ('username','domain','lastname','firstname','permanentemail');
385: my $sortby = $env{'form.sortby'};
386:
387: if (!grep(/^\Q$sortby\E$/,@fields)) {
388: $sortby = 'lastname';
389: }
390:
391: my ($jsback,$elements) = &crumb_utilities();
392:
393: my $jscript = (<<ENDSCRIPT);
394: <script type="text/javascript">
395: function pickuser(uname,udom) {
396: document.usersrchform.seluname.value=uname;
397: document.usersrchform.seludom.value=udom;
398: document.usersrchform.phase.value="userpicked";
399: document.usersrchform.submit();
400: }
401:
402: $jsback
403: </script>
404: ENDSCRIPT
405:
406: my %lt=&Apache::lonlocal::texthash(
1.179 raeburn 407: 'usrch' => "User Search to add/modify roles",
408: 'stusrch' => "User Search to enroll student",
409: 'usel' => "Select a user to add/modify roles",
410: 'stusel' => "Select a user to enroll as a student",
1.160 raeburn 411: 'username' => "username",
412: 'domain' => "domain",
413: 'lastname' => "last name",
414: 'firstname' => "first name",
415: 'permanentemail' => "permanent e-mail",
416: );
1.214 raeburn 417: $r->print(&Apache::loncommon::start_page('User Management',$jscript));
1.190 raeburn 418: if ($operation eq 'createuser') {
1.179 raeburn 419: &Apache::lonhtmlcommon::add_breadcrumb
420: ({href=>"javascript:backPage(document.usersrchform,'','')",
1.190 raeburn 421: text=>"Create/modify user",
1.179 raeburn 422: faq=>282,bug=>'Instructor Interface',},
423: {href=>"javascript:backPage(document.usersrchform,'get_user_info','select')",
424: text=>"Select User",
425: faq=>282,bug=>'Instructor Interface',});
1.224 raeburn 426: $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
427: 'Course_Change_Privileges'));
1.179 raeburn 428: $r->print("<b>$lt{'usrch'}</b><br />");
1.207 raeburn 429: $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context));
1.179 raeburn 430: $r->print('<h3>'.$lt{'usel'}.'</h3>');
1.214 raeburn 431: } elsif ($operation eq 'enrollstudent') {
432: &Apache::lonhtmlcommon::add_breadcrumb
433: ({href=>"javascript:backPage(document.usersrchform,'','')",
434: text=>"Create/modify student",
435: faq=>282,bug=>'Instructor Interface',},
436: {href=>"javascript:backPage(document.usersrchform,'get_user_info','select')",
437: text=>"Select Student",
438: faq=>282,bug=>'Instructor Interface',});
1.224 raeburn 439: $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
440: 'Course_Add_Student'));
1.179 raeburn 441: $r->print($jscript."<b>$lt{'stusrch'}</b><br />");
1.214 raeburn 442: $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context));
1.179 raeburn 443: $r->print('</form><h3>'.$lt{'stusel'}.'</h3>');
444: }
1.160 raeburn 445: $r->print('<form name="usersrchform" method="post">'.
446: &Apache::loncommon::start_data_table()."\n".
447: &Apache::loncommon::start_data_table_header_row()."\n".
448: ' <th> </th>'."\n");
449: foreach my $field (@fields) {
450: $r->print(' <th><a href="javascript:document.usersrchform.sortby.value='.
451: "'".$field."'".';document.usersrchform.submit();">'.
452: $lt{$field}.'</a></th>'."\n");
453: }
454: $r->print(&Apache::loncommon::end_data_table_header_row());
455:
456: my @sorted_users = sort {
1.167 albertel 457: lc($srch_results->{$a}->{$sortby}) cmp lc($srch_results->{$b}->{$sortby})
1.160 raeburn 458: ||
1.167 albertel 459: lc($srch_results->{$a}->{lastname}) cmp lc($srch_results->{$b}->{lastname})
1.160 raeburn 460: ||
461: lc($srch_results->{$a}->{firstname}) cmp lc($srch_results->{$b}->{firstname})
1.167 albertel 462: ||
463: lc($a) cmp lc($b)
1.160 raeburn 464: } (keys(%$srch_results));
465:
466: foreach my $user (@sorted_users) {
467: my ($uname,$udom) = split(/:/,$user);
468: $r->print(&Apache::loncommon::start_data_table_row().
469: '<td><input type="button" name="seluser" value="'.&mt('Select').'" onclick="javascript:pickuser('."'".$uname."'".','."'".$udom."'".')" /></td>'.
470: '<td><tt>'.$uname.'</tt></td>'.
471: '<td><tt>'.$udom.'</tt></td>');
472: foreach my $field ('lastname','firstname','permanentemail') {
473: $r->print('<td>'.$srch_results->{$user}->{$field}.'</td>');
474: }
475: $r->print(&Apache::loncommon::end_data_table_row());
476: }
477: $r->print(&Apache::loncommon::end_data_table().'<br /><br />');
1.179 raeburn 478: if (ref($srcharray) eq 'ARRAY') {
479: foreach my $item (@{$srcharray}) {
480: $r->print('<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n");
481: }
482: }
1.160 raeburn 483: $r->print(' <input type="hidden" name="sortby" value="'.$sortby.'" />'."\n".
484: ' <input type="hidden" name="seluname" value="" />'."\n".
485: ' <input type="hidden" name="seludom" value="" />'."\n".
1.179 raeburn 486: ' <input type="hidden" name="currstate" value="select" />'."\n".
1.190 raeburn 487: ' <input type="hidden" name="phase" value="get_user_info" />'."\n".
1.214 raeburn 488: ' <input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n");
489: $r->print($response.'</form>'.&Apache::loncommon::end_page());
1.160 raeburn 490: }
491:
492: sub print_user_query_page {
1.179 raeburn 493: my ($r,$caller) = @_;
1.160 raeburn 494: # FIXME - this is for a network-wide name search (similar to catalog search)
495: # To use frames with similar behavior to catalog/portfolio search.
496: # To be implemented.
497: return;
498: }
499:
1.42 matthew 500: sub print_user_modification_page {
1.215 raeburn 501: my ($r,$ccuname,$ccdomain,$srch,$response,$context,$permission) = @_;
1.185 raeburn 502: if (($ccuname eq '') || ($ccdomain eq '')) {
1.215 raeburn 503: my $usermsg = &mt('No username and/or domain provided.');
504: $env{'form.phase'} = '';
1.207 raeburn 505: &print_username_entry_form($r,$context,$usermsg);
1.58 www 506: return;
507: }
1.213 raeburn 508: my ($form,$formname);
509: if ($env{'form.action'} eq 'singlestudent') {
510: $form = 'document.enrollstudent';
511: $formname = 'enrollstudent';
512: } else {
513: $form = 'document.cu';
514: $formname = 'cu';
515: }
1.188 raeburn 516: my %abv_auth = &auth_abbrev();
1.227 raeburn 517: my (%rulematch,%inst_results,$newuser,%alerts,%curr_rules,%got_rules);
1.185 raeburn 518: my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
519: if ($uhome eq 'no_host') {
1.215 raeburn 520: my $usertype;
521: my ($rules,$ruleorder) =
522: &Apache::lonnet::inst_userrules($ccdomain,'username');
523: $usertype =
524: &Apache::lonuserutils::check_usertype($ccdomain,$ccuname,$rules);
525: my $cancreate =
526: &Apache::lonuserutils::can_create_user($ccdomain,$context,
527: $usertype);
528: if (!$cancreate) {
529: my $helplink = ' href="javascript:helpMenu('."'display'".')"';
530: my %usertypetext = (
531: official => 'institutional',
532: unofficial => 'non-institutional',
533: );
534: my $response;
535: if ($env{'form.origform'} eq 'crtusername') {
536: $response = '<span class="LC_warning">'.&mt('No match was found for the username ([_1]) in LON-CAPA domain: [_2]',$ccuname,$ccdomain).
537: '</span><br />';
538: }
539: $response .= '<span class="LC_warning">'.&mt("You are not authorized to create new $usertypetext{$usertype} users in this domain.").' '.&mt('Contact the <a[_1]>helpdesk</a> for assistance.',$helplink).'</span><br /><br />';
540: $env{'form.phase'} = '';
541: &print_username_entry_form($r,$context,$response);
542: return;
543: }
1.188 raeburn 544: $newuser = 1;
1.193 raeburn 545: my $checkhash;
546: my $checks = { 'username' => 1 };
1.196 raeburn 547: $checkhash->{$ccuname.':'.$ccdomain} = { 'newuser' => $newuser };
1.193 raeburn 548: &Apache::loncommon::user_rule_check($checkhash,$checks,
1.196 raeburn 549: \%alerts,\%rulematch,\%inst_results,\%curr_rules,\%got_rules);
550: if (ref($alerts{'username'}) eq 'HASH') {
551: if (ref($alerts{'username'}{$ccdomain}) eq 'HASH') {
552: my $domdesc =
1.193 raeburn 553: &Apache::lonnet::domain($ccdomain,'description');
1.196 raeburn 554: if ($alerts{'username'}{$ccdomain}{$ccuname}) {
555: my $userchkmsg;
556: if (ref($curr_rules{$ccdomain}) eq 'HASH') {
557: $userchkmsg =
558: &Apache::loncommon::instrule_disallow_msg('username',
1.193 raeburn 559: $domdesc,1).
560: &Apache::loncommon::user_rule_formats($ccdomain,
561: $domdesc,$curr_rules{$ccdomain}{'username'},
562: 'username');
1.196 raeburn 563: }
1.215 raeburn 564: $env{'form.phase'} = '';
1.207 raeburn 565: &print_username_entry_form($r,$context,$userchkmsg);
1.196 raeburn 566: return;
1.215 raeburn 567: }
1.193 raeburn 568: }
1.185 raeburn 569: }
1.187 raeburn 570: } else {
1.188 raeburn 571: $newuser = 0;
1.185 raeburn 572: }
1.160 raeburn 573: if ($response) {
1.215 raeburn 574: $response = '<br />'.$response;
1.160 raeburn 575: }
1.149 raeburn 576:
1.52 matthew 577: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.88 raeburn 578: my $dc_setcourse_code = '';
1.119 raeburn 579: my $nondc_setsection_code = '';
1.112 albertel 580: my %loaditem;
1.114 albertel 581:
1.216 raeburn 582: my $groupslist = &Apache::lonuserutils::get_groupslist();
1.88 raeburn 583:
1.216 raeburn 584: my $js = &validation_javascript($context,$ccdomain,$pjump_def,
585: $groupslist,$newuser,$formname,\%loaditem);
1.110 albertel 586: my $start_page =
1.190 raeburn 587: &Apache::loncommon::start_page('User Management',
1.112 albertel 588: $js,{'add_entries' => \%loaditem,});
1.216 raeburn 589: my %breadcrumb_text = &singleuser_breadcrumb();
1.160 raeburn 590: &Apache::lonhtmlcommon::add_breadcrumb
1.216 raeburn 591: ({href=>"javascript:backPage($form)",
592: text=>$breadcrumb_text{'search'},
1.160 raeburn 593: faq=>282,bug=>'Instructor Interface',});
594:
595: if ($env{'form.phase'} eq 'userpicked') {
596: &Apache::lonhtmlcommon::add_breadcrumb
1.216 raeburn 597: ({href=>"javascript:backPage($form,'get_user_info','select')",
598: text=>$breadcrumb_text{'userpicked'},
1.160 raeburn 599: faq=>282,bug=>'Instructor Interface',});
600: }
601: &Apache::lonhtmlcommon::add_breadcrumb
1.216 raeburn 602: ({href=>"javascript:backPage($form,'$env{'form.phase'}','modify')",
603: text=>$breadcrumb_text{'modify'},
1.160 raeburn 604: faq=>282,bug=>'Instructor Interface',});
1.224 raeburn 605: my $helpitem = 'Course_Change_Privileges';
606: if ($env{'form.action'} eq 'singlestudent') {
607: $helpitem = 'Course_Add_Student';
608: }
609: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management',
610: $helpitem);
1.3 www 611:
1.25 matthew 612: my $forminfo =<<"ENDFORMINFO";
1.216 raeburn 613: <form action="/adm/createuser" method="post" name="$formname">
1.190 raeburn 614: <input type="hidden" name="phase" value="update_user_data" />
1.188 raeburn 615: <input type="hidden" name="ccuname" value="$ccuname" />
616: <input type="hidden" name="ccdomain" value="$ccdomain" />
1.157 albertel 617: <input type="hidden" name="pres_value" value="" />
618: <input type="hidden" name="pres_type" value="" />
619: <input type="hidden" name="pres_marker" value="" />
1.25 matthew 620: ENDFORMINFO
1.2 www 621: my %inccourses;
1.135 raeburn 622: foreach my $key (keys(%env)) {
1.139 albertel 623: if ($key=~/^user\.priv\.cm\.\/($match_domain)\/($match_username)/) {
1.2 www 624: $inccourses{$1.'_'.$2}=1;
625: }
1.24 matthew 626: }
1.216 raeburn 627: if ($newuser) {
1.134 raeburn 628: my $portfolioform;
629: if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
630: # Current user has quota modification privileges
1.188 raeburn 631: $portfolioform = '<br />'.&portfolio_quota($ccuname,$ccdomain);
1.134 raeburn 632: }
1.227 raeburn 633: &initialize_authen_forms($ccdomain,$formname);
1.188 raeburn 634: my %lt=&Apache::lonlocal::texthash(
635: 'cnu' => 'Create New User',
1.213 raeburn 636: 'ast' => 'as a student',
1.188 raeburn 637: 'ind' => 'in domain',
638: 'lg' => 'Login Data',
1.190 raeburn 639: 'hs' => "Home Server",
1.188 raeburn 640: );
1.185 raeburn 641: $r->print(<<ENDTITLE);
1.110 albertel 642: $start_page
1.160 raeburn 643: $crumbs
644: $response
1.25 matthew 645: $forminfo
1.31 matthew 646: <script type="text/javascript" language="Javascript">
1.20 harris41 647: $loginscript
1.31 matthew 648: </script>
1.20 harris41 649: <input type='hidden' name='makeuser' value='1' />
1.216 raeburn 650: <h2>$lt{'cnu'} "$ccuname" $lt{'ind'} $ccdomain
1.185 raeburn 651: ENDTITLE
1.213 raeburn 652: if ($env{'form.action'} eq 'singlestudent') {
653: $r->print(' ('.$lt{'ast'}.')');
654: }
655: $r->print('</h2>'."\n".'<div class="LC_left_float">');
1.206 raeburn 656: my $personal_table =
1.210 raeburn 657: &personal_data_display($ccuname,$ccdomain,$newuser,$context,
658: $inst_results{$ccuname.':'.$ccdomain});
1.206 raeburn 659: $r->print($personal_table);
1.187 raeburn 660: my ($home_server_pick,$numlib) =
661: &Apache::loncommon::home_server_form_item($ccdomain,'hserver',
662: 'default','hide');
663: if ($numlib > 1) {
664: $r->print("
1.185 raeburn 665: <br />
1.187 raeburn 666: $lt{'hs'}: $home_server_pick
667: <br />");
668: } else {
669: $r->print($home_server_pick);
670: }
1.188 raeburn 671: $r->print('</div>'."\n".'<div class="LC_left_float"><h3>'.
672: $lt{'lg'}.'</h3>');
1.185 raeburn 673: my ($fixedauth,$varauth,$authmsg);
1.193 raeburn 674: if (ref($rulematch{$ccuname.':'.$ccdomain}) eq 'HASH') {
675: my $matchedrule = $rulematch{$ccuname.':'.$ccdomain}{'username'};
676: my ($rules,$ruleorder) =
677: &Apache::lonnet::inst_userrules($ccdomain,'username');
1.185 raeburn 678: if (ref($rules) eq 'HASH') {
1.193 raeburn 679: if (ref($rules->{$matchedrule}) eq 'HASH') {
680: my $authtype = $rules->{$matchedrule}{'authtype'};
1.185 raeburn 681: if ($authtype !~ /^(krb4|krb5|int|fsys|loc)$/) {
1.190 raeburn 682: $r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc));
1.185 raeburn 683: } else {
1.193 raeburn 684: my $authparm = $rules->{$matchedrule}{'authparm'};
1.185 raeburn 685: if ($authtype =~ /^krb(4|5)$/) {
686: my $ver = $1;
687: if ($authparm ne '') {
688: $fixedauth = <<"KERB";
689: <input type="hidden" name="login" value="krb" />
690: <input type="hidden" name="krbver" value="$ver" />
691: <input type="hidden" name="krbarg" value="$authparm" />
692: KERB
1.193 raeburn 693: $authmsg = $rules->{$matchedrule}{'authmsg'};
1.185 raeburn 694: }
695: } else {
696: $fixedauth =
697: '<input type="hidden" name="login" value="'.$authtype.'" />'."\n";
1.193 raeburn 698: if ($rules->{$matchedrule}{'authparmfixed'}) {
1.185 raeburn 699: $fixedauth .=
700: '<input type="hidden" name="'.$authtype.'arg" value="'.$authparm.'" />'."\n";
701: } else {
702: $varauth =
703: '<input type="text" name="'.$authtype.'arg" value="" />'."\n";
704: }
705: }
706: }
707: } else {
1.190 raeburn 708: $r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc));
1.185 raeburn 709: }
710: }
711: if ($authmsg) {
712: $r->print(<<ENDAUTH);
713: $fixedauth
714: $authmsg
715: $varauth
716: ENDAUTH
717: }
718: } else {
1.190 raeburn 719: $r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc));
1.187 raeburn 720: }
1.215 raeburn 721: $r->print($portfolioform);
722: if ($env{'form.action'} eq 'singlestudent') {
723: $r->print(&date_sections_select($context,$newuser,$formname,
724: $permission));
725: }
726: $r->print('</div><div class="LC_clear_float_footer"></div>');
1.216 raeburn 727: } else { # user already exists
1.79 albertel 728: my %lt=&Apache::lonlocal::texthash(
1.191 raeburn 729: 'cup' => "Modify existing user: ",
1.213 raeburn 730: 'ens' => "Enroll one student: ",
1.72 sakharuk 731: 'id' => "in domain",
732: );
1.26 matthew 733: $r->print(<<ENDCHANGEUSER);
1.110 albertel 734: $start_page
1.160 raeburn 735: $crumbs
1.25 matthew 736: $forminfo
1.213 raeburn 737: <h2>
1.26 matthew 738: ENDCHANGEUSER
1.213 raeburn 739: if ($env{'form.action'} eq 'singlestudent') {
740: $r->print($lt{'ens'});
741: } else {
742: $r->print($lt{'cup'});
743: }
744: $r->print(' "'.$ccuname.'" '.$lt{'id'}.' "'.$ccdomain.'"</h2>'.
745: "\n".'<div class="LC_left_float">');
1.206 raeburn 746: my ($personal_table,$showforceid) =
1.210 raeburn 747: &personal_data_display($ccuname,$ccdomain,$newuser,$context,
748: $inst_results{$ccuname.':'.$ccdomain});
1.206 raeburn 749: $r->print($personal_table);
750: if ($showforceid) {
1.203 raeburn 751: $r->print(&Apache::lonuserutils::forceid_change($context));
1.199 raeburn 752: }
753: $r->print('</div>');
1.227 raeburn 754: my $user_auth_text = &user_authentication($ccuname,$ccdomain,$formname);
1.188 raeburn 755: my $user_quota_text;
756: if (&Apache::lonnet::allowed('mpq',$ccdomain)) {
757: # Current user has quota modification privileges
758: $user_quota_text = &portfolio_quota($ccuname,$ccdomain);
759: } elsif (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
760: # Get the user's portfolio information
761: my %portq = &Apache::lonnet::get('environment',['portfolioquota'],
762: $ccdomain,$ccuname);
763:
764: my %lt=&Apache::lonlocal::texthash(
765: 'dska' => "Disk space allocated to user's portfolio files",
766: 'youd' => "You do not have privileges to modify the portfolio quota for this user.",
767: 'ichr' => "If a change is required, contact a domain coordinator for the domain",
768: );
769: $user_quota_text = <<ENDNOPORTPRIV;
770: <h3>$lt{'dska'}</h3>
771: $lt{'youd'} $lt{'ichr'}: $ccdomain
772: ENDNOPORTPRIV
773: }
774: if ($user_auth_text ne '') {
775: $r->print('<div class="LC_left_float">'.$user_auth_text);
776: if ($user_quota_text ne '') {
777: $r->print($user_quota_text);
778: }
1.213 raeburn 779: if ($env{'form.action'} eq 'singlestudent') {
780: $r->print(&date_sections_select($context,$newuser,$formname));
781: }
1.188 raeburn 782: } elsif ($user_quota_text ne '') {
1.213 raeburn 783: $r->print('<div class="LC_left_float">'.$user_quota_text);
784: if ($env{'form.action'} eq 'singlestudent') {
785: $r->print(&date_sections_select($context,$newuser,$formname));
786: }
787: } else {
788: if ($env{'form.action'} eq 'singlestudent') {
789: $r->print('<div class="LC_left_float">'.
790: &date_sections_select($context,$newuser,$formname));
791: }
1.188 raeburn 792: }
1.213 raeburn 793: $r->print('</div><div class="LC_clear_float_footer"></div>');
1.217 raeburn 794: if ($env{'form.action'} ne 'singlestudent') {
795: &display_existing_roles($r,$ccuname,$ccdomain,\%inccourses);
796: }
1.25 matthew 797: } ## End of new user/old user logic
1.218 raeburn 798:
799: if ($env{'form.action'} eq 'singlestudent') {
800: $r->print('<br /><input type="button" value="'.&mt('Enroll Student').'" onClick="setSections(this.form)" />'."\n");
801: } else {
802: $r->print('<h3>'.&mt('Add Roles').'</h3>');
803: my $addrolesdisplay = 0;
804: if ($context eq 'domain' || $context eq 'author') {
805: $addrolesdisplay = &new_coauthor_roles($r,$ccuname,$ccdomain);
806: }
807: if ($context eq 'domain') {
808: my $add_domainroles = &new_domain_roles($r);
809: if (!$addrolesdisplay) {
810: $addrolesdisplay = $add_domainroles;
1.2 www 811: }
1.218 raeburn 812: $r->print(&course_level_dc($env{'request.role.domain'},'Course'));
813: $r->print('<br /><input type="button" value="'.&mt('Modify User').'" onClick="setCourse()" />'."\n");
814: } elsif ($context eq 'author') {
815: if ($addrolesdisplay) {
816: $r->print('<br /><input type="button" value="'.&mt('Modify User').'"');
817: if ($newuser) {
1.227 raeburn 818: $r->print(' onClick="auth_check()" \>'."\n");
1.218 raeburn 819: } else {
820: $r->print('onClick="this.form.submit()" \>'."\n");
821: }
1.188 raeburn 822: } else {
1.218 raeburn 823: $r->print('<br /><a href="javascript:backPage(document.cu)">'.
824: &mt('Back to previous page').'</a>');
1.188 raeburn 825: }
826: } else {
1.218 raeburn 827: $r->print(&course_level_table(%inccourses));
828: $r->print('<br /><input type="button" value="'.&mt('Modify User').'" onClick="setSections(this.form)" />'."\n");
1.188 raeburn 829: }
1.88 raeburn 830: }
1.188 raeburn 831: $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate','ccuname','ccdomain']));
1.179 raeburn 832: $r->print('<input type="hidden" name="currstate" value="" />');
1.160 raeburn 833: $r->print('<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />');
1.110 albertel 834: $r->print("</form>".&Apache::loncommon::end_page());
1.218 raeburn 835: return;
1.2 www 836: }
1.1 www 837:
1.213 raeburn 838: sub singleuser_breadcrumb {
839: my %breadcrumb_text;
840: if ($env{'form.action'} eq 'singlestudent') {
841: $breadcrumb_text{'search'} = 'Enroll a student';
842: $breadcrumb_text{'userpicked'} = 'Select a user',
843: $breadcrumb_text{'modify'} = 'Set section/dates',
844: } else {
845: $breadcrumb_text{'search'} = 'Create/modify user';
846: $breadcrumb_text{'userpicked'} = 'Select a user',
847: $breadcrumb_text{'modify'} = 'Set user role',
848: }
849: return %breadcrumb_text;
850: }
851:
852: sub date_sections_select {
853: my ($context,$newuser,$formname,$permission) = @_;
854: my $cid = $env{'request.course.id'};
855: my ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity($cid);
856: my $date_table = '<h3>'.&mt('Starting and Ending Dates').'</h3>'."\n".
857: &Apache::lonuserutils::date_setting_table(undef,undef,$context,
858: undef,$formname,$permission);
859: my $rowtitle = 'Section';
860: my $secbox = '<h3>'.&mt('Section').'</h3>'."\n".
861: &Apache::lonuserutils::section_picker($cdom,$cnum,'st',$rowtitle,
862: $permission);
863: my $output = $date_table.$secbox;
864: return $output;
865: }
866:
1.216 raeburn 867: sub validation_javascript {
868: my ($context,$ccdomain,$pjump_def,$groupslist,$newuser,$formname,
869: $loaditem) = @_;
870: my $dc_setcourse_code = '';
871: my $nondc_setsection_code = '';
872: if ($context eq 'domain') {
873: my $dcdom = $env{'request.role.domain'};
874: $loaditem->{'onload'} = "document.cu.coursedesc.value='';";
1.227 raeburn 875: $dc_setcourse_code =
876: &Apache::lonuserutils::dc_setcourse_js('cu','singleuser',$context);
1.216 raeburn 877: } else {
1.227 raeburn 878: my $checkauth;
879: if (($newuser) || (&Apache::lonnet::allowed('mau',$ccdomain))) {
880: $checkauth = 1;
881: }
882: if ($context eq 'course') {
883: $nondc_setsection_code =
884: &Apache::lonuserutils::setsections_javascript($formname,$groupslist,
885: undef,$checkauth);
886: }
887: if ($checkauth) {
888: $nondc_setsection_code .=
889: &Apache::lonuserutils::verify_authen($formname,$context);
890: }
1.216 raeburn 891: }
892: my $js = &user_modification_js($pjump_def,$dc_setcourse_code,
893: $nondc_setsection_code,$groupslist);
894: my ($jsback,$elements) = &crumb_utilities();
895: $js .= "\n".
1.227 raeburn 896: '<script type="text/javascript">'."\n".$jsback."\n".'</script>';
1.216 raeburn 897: return $js;
898: }
899:
1.217 raeburn 900: sub display_existing_roles {
901: my ($r,$ccuname,$ccdomain,$inccourses) = @_;
902: my %rolesdump=&Apache::lonnet::dump('roles',$ccdomain,$ccuname);
903: # Build up table of user roles to allow revocation and re-enabling of roles.
904: my ($tmp) = keys(%rolesdump);
905: if ($tmp !~ /^(con_lost|error)/i) {
906: my $now=time;
907: my %lt=&Apache::lonlocal::texthash(
908: 'rer' => "Existing Roles",
909: 'rev' => "Revoke",
910: 'del' => "Delete",
911: 'ren' => "Re-Enable",
912: 'rol' => "Role",
913: 'ext' => "Extent",
914: 'sta' => "Start",
915: 'end' => "End",
916: );
917: my (%roletext,%sortrole,%roleclass,%rolepriv);
918: foreach my $area (sort { my $a1=join('_',(split('_',$a))[1,0]);
919: my $b1=join('_',(split('_',$b))[1,0]);
920: return $a1 cmp $b1;
921: } keys(%rolesdump)) {
922: next if ($area =~ /^rolesdef/);
923: my $envkey=$area;
924: my $role = $rolesdump{$area};
925: my $thisrole=$area;
926: $area =~ s/\_\w\w$//;
927: my ($role_code,$role_end_time,$role_start_time) =
928: split(/_/,$role);
929: # Is this a custom role? Get role owner and title.
930: my ($croleudom,$croleuname,$croletitle)=
931: ($role_code=~m{^cr/($match_domain)/($match_username)/(\w+)$});
932: my $allowed=0;
933: my $delallowed=0;
934: my $sortkey=$role_code;
935: my $class='Unknown';
936: if ($area =~ m{^/($match_domain)/($match_courseid)} ) {
937: $class='Course';
938: my ($coursedom,$coursedir) = ($1,$2);
939: $sortkey.="\0$coursedom";
940: # $1.'_'.$2 is the course id (eg. 103_12345abcef103l3).
941: my %coursedata=
942: &Apache::lonnet::coursedescription($1.'_'.$2);
943: my $carea;
944: if (defined($coursedata{'description'})) {
945: $carea=$coursedata{'description'}.
946: '<br />'.&mt('Domain').': '.$coursedom.(' 'x8).
947: &Apache::loncommon::syllabuswrapper('Syllabus',$coursedir,$coursedom);
948: $sortkey.="\0".$coursedata{'description'};
949: $class=$coursedata{'type'};
950: } else {
951: $carea=&mt('Unavailable course').': '.$area;
952: $sortkey.="\0".&mt('Unavailable course').': '.$area;
953: }
954: $sortkey.="\0$coursedir";
955: $inccourses->{$1.'_'.$2}=1;
956: if ((&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2)) ||
957: (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
958: $allowed=1;
959: }
960: if ((&Apache::lonnet::allowed('dro',$1)) ||
961: (&Apache::lonnet::allowed('dro',$ccdomain))) {
962: $delallowed=1;
963: }
964: # - custom role. Needs more info, too
965: if ($croletitle) {
966: if (&Apache::lonnet::allowed('ccr',$1.'/'.$2)) {
967: $allowed=1;
968: $thisrole.='.'.$role_code;
969: }
970: }
971: # Compute the background color based on $area
972: if ($area=~m{^/($match_domain)/($match_courseid)/(\w+)}) {
973: $carea.='<br />Section: '.$3;
974: $sortkey.="\0$3";
975: if (!$allowed) {
976: if ($env{'request.course.sec'} eq $3) {
977: if (&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2.'/'.$3)) {
978: $allowed = 1;
979: }
980: }
981: }
982: }
983: $area=$carea;
984: } else {
985: $sortkey.="\0".$area;
986: # Determine if current user is able to revoke privileges
987: if ($area=~m{^/($match_domain)/}) {
988: if ((&Apache::lonnet::allowed('c'.$role_code,$1)) ||
989: (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
990: $allowed=1;
991: }
992: if (((&Apache::lonnet::allowed('dro',$1)) ||
993: (&Apache::lonnet::allowed('dro',$ccdomain))) &&
994: ($role_code ne 'dc')) {
995: $delallowed=1;
996: }
997: } else {
998: if (&Apache::lonnet::allowed('c'.$role_code,'/')) {
999: $allowed=1;
1000: }
1001: }
1002: if ($role_code eq 'ca' || $role_code eq 'au') {
1003: $class='Construction Space';
1004: } elsif ($role_code eq 'su') {
1005: $class='System';
1006: } else {
1007: $class='Domain';
1008: }
1009: }
1010: if (($role_code eq 'ca') || ($role_code eq 'aa')) {
1011: $area=~m{/($match_domain)/($match_username)};
1012: if (&Apache::lonuserutils::authorpriv($2,$1)) {
1013: $allowed=1;
1014: } else {
1015: $allowed=0;
1016: }
1017: }
1018: my $row = '';
1019: $row.= '<td>';
1020: my $active=1;
1021: $active=0 if (($role_end_time) && ($now>$role_end_time));
1022: if (($active) && ($allowed)) {
1023: $row.= '<input type="checkbox" name="rev:'.$thisrole.'" />';
1024: } else {
1025: if ($active) {
1026: $row.=' ';
1027: } else {
1028: $row.=&mt('expired or revoked');
1029: }
1030: }
1031: $row.='</td><td>';
1032: if ($allowed && !$active) {
1033: $row.= '<input type="checkbox" name="ren:'.$thisrole.'" />';
1034: } else {
1035: $row.=' ';
1036: }
1037: $row.='</td><td>';
1038: if ($delallowed) {
1039: $row.= '<input type="checkbox" name="del:'.$thisrole.'" />';
1040: } else {
1041: $row.=' ';
1042: }
1043: my $plaintext='';
1044: if (!$croletitle) {
1045: $plaintext=&Apache::lonnet::plaintext($role_code,$class)
1046: } else {
1047: $plaintext=
1048: "Customrole '$croletitle'<br />defined by $croleuname\@$croleudom";
1049: }
1050: $row.= '</td><td>'.$plaintext.
1051: '</td><td>'.$area.
1052: '</td><td>'.($role_start_time?localtime($role_start_time)
1053: : ' ' ).
1054: '</td><td>'.($role_end_time ?localtime($role_end_time)
1055: : ' ' )
1056: ."</td>";
1057: $sortrole{$sortkey}=$envkey;
1058: $roletext{$envkey}=$row;
1059: $roleclass{$envkey}=$class;
1060: $rolepriv{$envkey}=$allowed;
1061: #$r->print($row);
1062: } # end of foreach (table building loop)
1063: my $rolesdisplay = 0;
1064: my %output = ();
1065: foreach my $type ('Construction Space','Course','Group','Domain','System','Unknown') {
1066: $output{$type} = '';
1067: foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
1068: if ( ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/ ) && ($rolepriv{$sortrole{$which}}) ) {
1069: $output{$type}.=
1070: &Apache::loncommon::start_data_table_row().
1071: $roletext{$sortrole{$which}}.
1072: &Apache::loncommon::end_data_table_row();
1073: }
1074: }
1075: unless($output{$type} eq '') {
1076: $output{$type} = '<tr class="LC_info_row">'.
1077: "<td align='center' colspan='7'>".&mt($type)."</td></tr>".
1078: $output{$type};
1079: $rolesdisplay = 1;
1080: }
1081: }
1082: if ($rolesdisplay == 1) {
1083: $r->print('
1084: <h3>'.$lt{'rer'}.'</h3>'.
1085: &Apache::loncommon::start_data_table("LC_createuser").
1086: &Apache::loncommon::start_data_table_header_row().
1087: '<th>'.$lt{'rev'}.'</th><th>'.$lt{'ren'}.'</th><th>'.$lt{'del'}.
1088: '</th><th>'.$lt{'rol'}.'</th><th>'.$lt{'ext'}.
1089: '</th><th>'.$lt{'sta'}.'</th><th>'.$lt{'end'}.'</th>'.
1090: &Apache::loncommon::end_data_table_header_row());
1091: foreach my $type ('Construction Space','Course','Group','Domain','System','Unknown') {
1092: if ($output{$type}) {
1093: $r->print($output{$type}."\n");
1094: }
1095: }
1096: $r->print(&Apache::loncommon::end_data_table());
1097: }
1098: } # End of check for keys in rolesdump
1099: return;
1100: }
1101:
1.218 raeburn 1102: sub new_coauthor_roles {
1103: my ($r,$ccuname,$ccdomain) = @_;
1104: my $addrolesdisplay = 0;
1105: #
1106: # Co-Author
1107: #
1108: if (&Apache::lonuserutils::authorpriv($env{'user.name'},
1109: $env{'request.role.domain'}) &&
1110: ($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain)) {
1111: # No sense in assigning co-author role to yourself
1112: $addrolesdisplay = 1;
1113: my $cuname=$env{'user.name'};
1114: my $cudom=$env{'request.role.domain'};
1115: my %lt=&Apache::lonlocal::texthash(
1116: 'cs' => "Construction Space",
1117: 'act' => "Activate",
1118: 'rol' => "Role",
1119: 'ext' => "Extent",
1120: 'sta' => "Start",
1121: 'end' => "End",
1122: 'cau' => "Co-Author",
1123: 'caa' => "Assistant Co-Author",
1124: 'ssd' => "Set Start Date",
1125: 'sed' => "Set End Date"
1126: );
1127: $r->print('<h4>'.$lt{'cs'}.'</h4>'."\n".
1128: &Apache::loncommon::start_data_table()."\n".
1129: &Apache::loncommon::start_data_table_header_row()."\n".
1130: '<th>'.$lt{'act'}.'</th><th>'.$lt{'rol'}.'</th>'.
1131: '<th>'.$lt{'ext'}.'</th><th>'.$lt{'sta'}.'</th>'.
1132: '<th>'.$lt{'end'}.'</th>'."\n".
1133: &Apache::loncommon::end_data_table_header_row()."\n".
1134: &Apache::loncommon::start_data_table_row().'
1135: <td>
1136: <input type=checkbox name="act_'.$cudom.'_'.$cuname.'_ca" />
1137: </td>
1138: <td>'.$lt{'cau'}.'</td>
1139: <td>'.$cudom.'_'.$cuname.'</td>
1140: <td><input type="hidden" name="start_'.$cudom.'_'.$cuname.'_ca" value="" />
1141: <a href=
1142: "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>
1143: <td><input type="hidden" name="end_'.$cudom.'_'.$cuname.'_ca" value="" />
1144: <a href=
1145: "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>'."\n".
1146: &Apache::loncommon::end_data_table_row()."\n".
1147: &Apache::loncommon::start_data_table_row()."\n".
1148: '<td><input type=checkbox name="act_'.$cudom.'_'.$cuname.'_aa" /></td>
1149: <td>'.$lt{'caa'}.'</td>
1150: <td>'.$cudom.'_'.$cuname.'</td>
1151: <td><input type="hidden" name="start_'.$cudom.'_'.$cuname.'_aa" value="" />
1152: <a href=
1153: "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>
1154: <td><input type="hidden" name="end_'.$cudom.'_'.$cuname.'_aa" value="" />
1155: <a href=
1156: "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>'."\n".
1157: &Apache::loncommon::end_data_table_row()."\n".
1158: &Apache::loncommon::end_data_table());
1159: } elsif ($env{'request.role'} =~ /^au\./) {
1160: if (!(&Apache::lonuserutils::authorpriv($env{'user.name'},
1161: $env{'request.role.domain'}))) {
1162: $r->print('<span class="LC_error">'.
1163: &mt('You do not have privileges to assign co-author roles.').
1164: '</span>');
1165: } elsif (($env{'user.name'} eq $ccuname) &&
1166: ($env{'user.domain'} eq $ccdomain)) {
1167: $r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Construction Space is not permitted'));
1168: }
1169: }
1170: return $addrolesdisplay;;
1171: }
1172:
1173: sub new_domain_roles {
1174: my ($r) = @_;
1175: my $addrolesdisplay = 0;
1176: #
1177: # Domain level
1178: #
1179: my $num_domain_level = 0;
1180: my $domaintext =
1181: '<h4>'.&mt('Domain Level').'</h4>'.
1182: &Apache::loncommon::start_data_table().
1183: &Apache::loncommon::start_data_table_header_row().
1184: '<th>'.&mt('Activate').'</th><th>'.&mt('Role').'</th><th>'.
1185: &mt('Extent').'</th>'.
1186: '<th>'.&mt('Start').'</th><th>'.&mt('End').'</th>'.
1187: &Apache::loncommon::end_data_table_header_row();
1188: foreach my $thisdomain (sort(&Apache::lonnet::all_domains())) {
1189: foreach my $role ('dc','li','dg','au','sc') {
1190: if (&Apache::lonnet::allowed('c'.$role,$thisdomain)) {
1191: my $plrole=&Apache::lonnet::plaintext($role);
1192: my %lt=&Apache::lonlocal::texthash(
1193: 'ssd' => "Set Start Date",
1194: 'sed' => "Set End Date"
1195: );
1196: $num_domain_level ++;
1197: $domaintext .=
1198: &Apache::loncommon::start_data_table_row().
1199: '<td><input type=checkbox name="act_'.$thisdomain.'_'.$role.'" /></td>
1200: <td>'.$plrole.'</td>
1201: <td>'.$thisdomain.'</td>
1202: <td><input type="hidden" name="start_'.$thisdomain.'_'.$role.'" value="" />
1203: <a href=
1204: "javascript:pjump('."'date_start','Start Date $plrole',document.cu.start_$thisdomain\_$role.value,'start_$thisdomain\_$role','cu.pres','dateset'".')">'.$lt{'ssd'}.'</a></td>
1205: <td><input type="hidden" name="end_'.$thisdomain.'_'.$role.'" value="" />
1206: <a href=
1207: "javascript:pjump('."'date_end','End Date $plrole',document.cu.end_$thisdomain\_$role.value,'end_$thisdomain\_$role','cu.pres','dateset'".')">'.$lt{'sed'}.'</a></td>'.
1208: &Apache::loncommon::end_data_table_row();
1209: }
1210: }
1211: }
1212: $domaintext.= &Apache::loncommon::end_data_table();
1213: if ($num_domain_level > 0) {
1214: $r->print($domaintext);
1215: $addrolesdisplay = 1;
1216: }
1217: return $addrolesdisplay;
1218: }
1219:
1.188 raeburn 1220: sub user_authentication {
1.227 raeburn 1221: my ($ccuname,$ccdomain,$formname) = @_;
1.188 raeburn 1222: my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain);
1.227 raeburn 1223: my $outcome;
1.188 raeburn 1224: # Check for a bad authentication type
1225: if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth):/) {
1226: # bad authentication scheme
1227: my %lt=&Apache::lonlocal::texthash(
1228: 'err' => "ERROR",
1229: 'uuas' => "This user has an unrecognized authentication scheme",
1230: 'adcs' => "Please alert a domain coordinator of this situation",
1231: 'sldb' => "Please specify login data below",
1232: 'ld' => "Login Data"
1233: );
1234: if (&Apache::lonnet::allowed('mau',$ccdomain)) {
1.227 raeburn 1235: &initialize_authen_forms($ccdomain,$formname);
1236:
1.190 raeburn 1237: my $choices = &Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc);
1.188 raeburn 1238: $outcome = <<ENDBADAUTH;
1239: <script type="text/javascript" language="Javascript">
1240: $loginscript
1241: </script>
1242: <span class="LC_error">$lt{'err'}:
1243: $lt{'uuas'} ($currentauth). $lt{'sldb'}.</span>
1244: <h3>$lt{'ld'}</h3>
1245: $choices
1246: ENDBADAUTH
1247: } else {
1248: # This user is not allowed to modify the user's
1249: # authentication scheme, so just notify them of the problem
1250: $outcome = <<ENDBADAUTH;
1251: <span class="LC_error"> $lt{'err'}:
1252: $lt{'uuas'} ($currentauth). $lt{'adcs'}.
1253: </span>
1254: ENDBADAUTH
1255: }
1256: } else { # Authentication type is valid
1.227 raeburn 1257: &initialize_authen_forms($ccdomain,$formname,$currentauth,'modifyuser');
1.205 raeburn 1258: my ($authformcurrent,$can_modify,@authform_others) =
1.188 raeburn 1259: &modify_login_block($ccdomain,$currentauth);
1260: if (&Apache::lonnet::allowed('mau',$ccdomain)) {
1261: # Current user has login modification privileges
1262: my %lt=&Apache::lonlocal::texthash (
1263: 'ld' => "Login Data",
1264: 'ccld' => "Change Current Login Data",
1265: 'enld' => "Enter New Login Data"
1266: );
1267: $outcome =
1268: '<script type="text/javascript" language="Javascript">'."\n".
1269: $loginscript."\n".
1270: '</script>'."\n".
1271: '<h3>'.$lt{'ld'}.'</h3>'.
1272: &Apache::loncommon::start_data_table().
1.205 raeburn 1273: &Apache::loncommon::start_data_table_row().
1.188 raeburn 1274: '<td>'.$authformnop;
1275: if ($can_modify) {
1276: $outcome .= '</td>'."\n".
1277: &Apache::loncommon::end_data_table_row().
1278: &Apache::loncommon::start_data_table_row().
1279: '<td>'.$authformcurrent.'</td>'.
1280: &Apache::loncommon::end_data_table_row()."\n";
1281: } else {
1.200 raeburn 1282: $outcome .= ' ('.$authformcurrent.')</td>'.
1283: &Apache::loncommon::end_data_table_row()."\n";
1.188 raeburn 1284: }
1.205 raeburn 1285: foreach my $item (@authform_others) {
1286: $outcome .= &Apache::loncommon::start_data_table_row().
1287: '<td>'.$item.'</td>'.
1288: &Apache::loncommon::end_data_table_row()."\n";
1.188 raeburn 1289: }
1.205 raeburn 1290: $outcome .= &Apache::loncommon::end_data_table();
1.188 raeburn 1291: } else {
1292: if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) {
1293: my %lt=&Apache::lonlocal::texthash(
1294: 'ccld' => "Change Current Login Data",
1295: 'yodo' => "You do not have privileges to modify the authentication configuration for this user.",
1296: 'ifch' => "If a change is required, contact a domain coordinator for the domain",
1297: );
1298: $outcome .= <<ENDNOPRIV;
1299: <h3>$lt{'ccld'}</h3>
1300: $lt{'yodo'} $lt{'ifch'}: $ccdomain
1301: ENDNOPRIV
1302: }
1303: }
1304: } ## End of "check for bad authentication type" logic
1305: return $outcome;
1306: }
1307:
1.187 raeburn 1308: sub modify_login_block {
1309: my ($dom,$currentauth) = @_;
1310: my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom);
1311: my ($authnum,%can_assign) =
1312: &Apache::loncommon::get_assignable_auth($dom);
1.205 raeburn 1313: my ($authformcurrent,@authform_others,$show_override_msg);
1.187 raeburn 1314: if ($currentauth=~/^krb(4|5):/) {
1315: $authformcurrent=$authformkrb;
1316: if ($can_assign{'int'}) {
1.205 raeburn 1317: push(@authform_others,$authformint);
1.187 raeburn 1318: }
1319: if ($can_assign{'loc'}) {
1.205 raeburn 1320: push(@authform_others,$authformloc);
1.187 raeburn 1321: }
1322: if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) {
1323: $show_override_msg = 1;
1324: }
1325: } elsif ($currentauth=~/^internal:/) {
1326: $authformcurrent=$authformint;
1327: if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) {
1.205 raeburn 1328: push(@authform_others,$authformkrb);
1.187 raeburn 1329: }
1330: if ($can_assign{'loc'}) {
1.205 raeburn 1331: push(@authform_others,$authformloc);
1.187 raeburn 1332: }
1333: if ($can_assign{'int'}) {
1334: $show_override_msg = 1;
1335: }
1336: } elsif ($currentauth=~/^unix:/) {
1337: $authformcurrent=$authformfsys;
1338: if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) {
1.205 raeburn 1339: push(@authform_others,$authformkrb);
1.187 raeburn 1340: }
1341: if ($can_assign{'int'}) {
1.205 raeburn 1342: push(@authform_others,$authformint);
1.187 raeburn 1343: }
1344: if ($can_assign{'loc'}) {
1.205 raeburn 1345: push(@authform_others,$authformloc);
1.187 raeburn 1346: }
1347: if ($can_assign{'fsys'}) {
1348: $show_override_msg = 1;
1349: }
1350: } elsif ($currentauth=~/^localauth:/) {
1351: $authformcurrent=$authformloc;
1352: if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) {
1.205 raeburn 1353: push(@authform_others,$authformkrb);
1.187 raeburn 1354: }
1355: if ($can_assign{'int'}) {
1.205 raeburn 1356: push(@authform_others,$authformint);
1.187 raeburn 1357: }
1358: if ($can_assign{'loc'}) {
1359: $show_override_msg = 1;
1360: }
1361: }
1362: if ($show_override_msg) {
1.205 raeburn 1363: $authformcurrent = '<table><tr><td colspan="3">'.$authformcurrent.
1364: '</td></tr>'."\n".
1365: '<tr><td> </td>'.
1366: '<td><b>'.&mt('Currently in use').'</b></td>'.
1367: '<td align="right"><span class="LC_cusr_emph">'.
1.187 raeburn 1368: &mt('will override current values').
1.205 raeburn 1369: '</span></td></tr></table>';
1.187 raeburn 1370: }
1.205 raeburn 1371: return ($authformcurrent,$show_override_msg,@authform_others);
1.187 raeburn 1372: }
1373:
1.188 raeburn 1374: sub personal_data_display {
1.210 raeburn 1375: my ($ccuname,$ccdomain,$newuser,$context,$inst_results) = @_;
1.219 raeburn 1376: my ($output,$showforceid,%userenv,%canmodify);
1377: my @userinfo = ('firstname','middlename','lastname','generation',
1378: 'permanentemail','id');
1.188 raeburn 1379: if (!$newuser) {
1380: # Get the users information
1381: %userenv = &Apache::lonnet::get('environment',
1382: ['firstname','middlename','lastname','generation',
1383: 'permanentemail','id'],$ccdomain,$ccuname);
1.219 raeburn 1384: %canmodify =
1385: &Apache::lonuserutils::can_modify_userinfo($context,$ccdomain,
1386: \@userinfo);
1.188 raeburn 1387: }
1388: my %lt=&Apache::lonlocal::texthash(
1389: 'pd' => "Personal Data",
1390: 'firstname' => "First Name",
1391: 'middlename' => "Middle Name",
1392: 'lastname' => "Last Name",
1393: 'generation' => "Generation",
1394: 'permanentemail' => "Permanent e-mail address",
1395: 'id' => "ID/Student Number",
1396: 'lg' => "Login Data"
1397: );
1398: my %textboxsize = (
1399: firstname => '15',
1400: middlename => '15',
1401: lastname => '15',
1402: generation => '5',
1403: permanentemail => '25',
1404: id => '15',
1405: );
1406: my $genhelp=&Apache::loncommon::help_open_topic('Generation');
1407: $output = '<h3>'.$lt{'pd'}.'</h3>'.
1408: &Apache::lonhtmlcommon::start_pick_box();
1409: foreach my $item (@userinfo) {
1410: my $rowtitle = $lt{$item};
1411: if ($item eq 'generation') {
1412: $rowtitle = $genhelp.$rowtitle;
1413: }
1414: $output .= &Apache::lonhtmlcommon::row_title($rowtitle,undef,'LC_oddrow_value')."\n";
1415: if ($newuser) {
1.210 raeburn 1416: if (ref($inst_results) eq 'HASH') {
1417: if ($inst_results->{$item} ne '') {
1418: $output .= '<input type="hidden" name="c'.$item.'" value="'.$inst_results->{$item}.'" />'.$inst_results->{$item};
1419: } else {
1420: $output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />';
1421: }
1.188 raeburn 1422: } else {
1423: $output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />';
1424: }
1425: } else {
1.219 raeburn 1426: if ($canmodify{$item}) {
1.188 raeburn 1427: $output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="'.$userenv{$item}.'" />';
1428: } else {
1429: $output .= $userenv{$item};
1430: }
1.206 raeburn 1431: if ($item eq 'id') {
1.219 raeburn 1432: $showforceid = $canmodify{$item};
1433: }
1.188 raeburn 1434: }
1435: $output .= &Apache::lonhtmlcommon::row_closure(1);
1436: }
1437: $output .= &Apache::lonhtmlcommon::end_pick_box();
1.206 raeburn 1438: if (wantarray) {
1439: return ($output,$showforceid);
1440: } else {
1441: return $output;
1442: }
1.188 raeburn 1443: }
1444:
1.4 www 1445: # ================================================================= Phase Three
1.42 matthew 1446: sub update_user_data {
1.206 raeburn 1447: my ($r,$context) = @_;
1.101 albertel 1448: my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'},
1449: $env{'form.ccdomain'});
1.27 matthew 1450: # Error messages
1.188 raeburn 1451: my $error = '<span class="LC_error">'.&mt('Error').': ';
1.193 raeburn 1452: my $end = '</span><br /><br />';
1453: my $rtnlink = '<a href="javascript:backPage(document.userupdate,'.
1.188 raeburn 1454: "'$env{'form.prevphase'}','modify')".'" />'.
1.219 raeburn 1455: &mt('Return to previous page').'</a>'.
1456: &Apache::loncommon::end_page();
1457: my $now = time;
1.40 www 1458: my $title;
1.101 albertel 1459: if (exists($env{'form.makeuser'})) {
1.40 www 1460: $title='Set Privileges for New User';
1461: } else {
1462: $title='Modify User Privileges';
1463: }
1.213 raeburn 1464: my $newuser = 0;
1.160 raeburn 1465: my ($jsback,$elements) = &crumb_utilities();
1466: my $jscript = '<script type="text/javascript">'."\n".
1467: $jsback."\n".'</script>'."\n";
1.213 raeburn 1468: my %breadcrumb_text = &singleuser_breadcrumb();
1.160 raeburn 1469: $r->print(&Apache::loncommon::start_page($title,$jscript));
1470: &Apache::lonhtmlcommon::add_breadcrumb
1471: ({href=>"javascript:backPage(document.userupdate)",
1.213 raeburn 1472: text=>$breadcrumb_text{'search'},
1.160 raeburn 1473: faq=>282,bug=>'Instructor Interface',});
1474: if ($env{'form.prevphase'} eq 'userpicked') {
1475: &Apache::lonhtmlcommon::add_breadcrumb
1476: ({href=>"javascript:backPage(document.userupdate,'get_user_info','select')",
1.213 raeburn 1477: text=>$breadcrumb_text{'userpicked'},
1.160 raeburn 1478: faq=>282,bug=>'Instructor Interface',});
1479: }
1480: &Apache::lonhtmlcommon::add_breadcrumb
1481: ({href=>"javascript:backPage(document.userupdate,'$env{'form.prevphase'}','modify')",
1.219 raeburn 1482: text=>$breadcrumb_text{'modify'},
1.160 raeburn 1483: faq=>282,bug=>'Instructor Interface',},
1484: {href=>"/adm/createuser",
1485: text=>"Result",
1486: faq=>282,bug=>'Instructor Interface',});
1.224 raeburn 1487: my $helpitem = 'Course_Change_Privileges';
1488: if ($env{'form.action'} eq 'singlestudent') {
1489: $helpitem = 'Course_Add_Student';
1490: }
1491: $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
1492: $helpitem));
1.188 raeburn 1493: $r->print(&update_result_form($uhome));
1.27 matthew 1494: # Check Inputs
1.101 albertel 1495: if (! $env{'form.ccuname'} ) {
1.193 raeburn 1496: $r->print($error.&mt('No login name specified').'.'.$end.$rtnlink);
1.27 matthew 1497: return;
1498: }
1.138 albertel 1499: if ( $env{'form.ccuname'} ne
1500: &LONCAPA::clean_username($env{'form.ccuname'}) ) {
1.73 sakharuk 1501: $r->print($error.&mt('Invalid login name').'. '.
1.160 raeburn 1502: &mt('Only letters, numbers, periods, dashes, @, and underscores are valid').'.'.
1.193 raeburn 1503: $end.$rtnlink);
1.27 matthew 1504: return;
1505: }
1.101 albertel 1506: if (! $env{'form.ccdomain'} ) {
1.193 raeburn 1507: $r->print($error.&mt('No domain specified').'.'.$end.$rtnlink);
1.27 matthew 1508: return;
1509: }
1.138 albertel 1510: if ( $env{'form.ccdomain'} ne
1511: &LONCAPA::clean_domain($env{'form.ccdomain'}) ) {
1.73 sakharuk 1512: $r->print($error.&mt ('Invalid domain name').'. '.
1.138 albertel 1513: &mt('Only letters, numbers, periods, dashes, and underscores are valid').'.'.
1.193 raeburn 1514: $end.$rtnlink);
1.27 matthew 1515: return;
1516: }
1.219 raeburn 1517: if ($uhome eq 'no_host') {
1518: $newuser = 1;
1519: }
1.101 albertel 1520: if (! exists($env{'form.makeuser'})) {
1.29 matthew 1521: # Modifying an existing user, so check the validity of the name
1522: if ($uhome eq 'no_host') {
1.73 sakharuk 1523: $r->print($error.&mt('Unable to determine home server for ').
1.101 albertel 1524: $env{'form.ccuname'}.&mt(' in domain ').
1525: $env{'form.ccdomain'}.'.');
1.29 matthew 1526: return;
1527: }
1528: }
1.27 matthew 1529: # Determine authentication method and password for the user being modified
1530: my $amode='';
1531: my $genpwd='';
1.101 albertel 1532: if ($env{'form.login'} eq 'krb') {
1.41 albertel 1533: $amode='krb';
1.101 albertel 1534: $amode.=$env{'form.krbver'};
1535: $genpwd=$env{'form.krbarg'};
1536: } elsif ($env{'form.login'} eq 'int') {
1.27 matthew 1537: $amode='internal';
1.101 albertel 1538: $genpwd=$env{'form.intarg'};
1539: } elsif ($env{'form.login'} eq 'fsys') {
1.27 matthew 1540: $amode='unix';
1.101 albertel 1541: $genpwd=$env{'form.fsysarg'};
1542: } elsif ($env{'form.login'} eq 'loc') {
1.27 matthew 1543: $amode='localauth';
1.101 albertel 1544: $genpwd=$env{'form.locarg'};
1.27 matthew 1545: $genpwd=" " if (!$genpwd);
1.101 albertel 1546: } elsif (($env{'form.login'} eq 'nochange') ||
1547: ($env{'form.login'} eq '' )) {
1.34 matthew 1548: # There is no need to tell the user we did not change what they
1549: # did not ask us to change.
1.35 matthew 1550: # If they are creating a new user but have not specified login
1551: # information this will be caught below.
1.30 matthew 1552: } else {
1.193 raeburn 1553: $r->print($error.&mt('Invalid login mode or password').$end.$rtnlink);
1.30 matthew 1554: return;
1.27 matthew 1555: }
1.164 albertel 1556:
1.188 raeburn 1557: $r->print('<h3>'.&mt('User [_1] in domain [_2]',
1558: $env{'form.ccuname'}, $env{'form.ccdomain'}).'</h3>');
1.193 raeburn 1559: my (%alerts,%rulematch,%inst_results,%curr_rules);
1.101 albertel 1560: if ($env{'form.makeuser'}) {
1.164 albertel 1561: $r->print('<h3>'.&mt('Creating new account.').'</h3>');
1.27 matthew 1562: # Check for the authentication mode and password
1563: if (! $amode || ! $genpwd) {
1.193 raeburn 1564: $r->print($error.&mt('Invalid login mode or password').$end.$rtnlink);
1.27 matthew 1565: return;
1.18 albertel 1566: }
1.29 matthew 1567: # Determine desired host
1.101 albertel 1568: my $desiredhost = $env{'form.hserver'};
1.29 matthew 1569: if (lc($desiredhost) eq 'default') {
1570: $desiredhost = undef;
1571: } else {
1.147 albertel 1572: my %home_servers =
1573: &Apache::lonnet::get_servers($env{'form.ccdomain'},'library');
1.29 matthew 1574: if (! exists($home_servers{$desiredhost})) {
1.193 raeburn 1575: $r->print($error.&mt('Invalid home server specified').$end.$rtnlink);
1576: return;
1577: }
1578: }
1579: # Check ID format
1580: my %checkhash;
1581: my %checks = ('id' => 1);
1582: %{$checkhash{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}}} = (
1.219 raeburn 1583: 'newuser' => $newuser,
1.196 raeburn 1584: 'id' => $env{'form.cid'},
1.193 raeburn 1585: );
1.196 raeburn 1586: if ($env{'form.cid'} ne '') {
1587: &Apache::loncommon::user_rule_check(\%checkhash,\%checks,\%alerts,
1588: \%rulematch,\%inst_results,\%curr_rules);
1589: if (ref($alerts{'id'}) eq 'HASH') {
1590: if (ref($alerts{'id'}{$env{'form.ccdomain'}}) eq 'HASH') {
1591: my $domdesc =
1592: &Apache::lonnet::domain($env{'form.ccdomain'},'description');
1593: if ($alerts{'id'}{$env{'form.ccdomain'}}{$env{'form.cid'}}) {
1594: my $userchkmsg;
1595: if (ref($curr_rules{$env{'form.ccdomain'}}) eq 'HASH') {
1596: $userchkmsg =
1597: &Apache::loncommon::instrule_disallow_msg('id',
1598: $domdesc,1).
1599: &Apache::loncommon::user_rule_formats($env{'form.ccdomain'},
1600: $domdesc,$curr_rules{$env{'form.ccdomain'}}{'id'},'id');
1601: }
1602: $r->print($error.&mt('Invalid ID format').$end.
1603: $userchkmsg.$rtnlink);
1604: return;
1605: }
1606: }
1.29 matthew 1607: }
1608: }
1.27 matthew 1609: # Call modifyuser
1610: my $result = &Apache::lonnet::modifyuser
1.193 raeburn 1611: ($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cid'},
1.188 raeburn 1612: $amode,$genpwd,$env{'form.cfirstname'},
1613: $env{'form.cmiddlename'},$env{'form.clastname'},
1614: $env{'form.cgeneration'},undef,$desiredhost,
1615: $env{'form.cpermanentemail'});
1.77 www 1616: $r->print(&mt('Generating user').': '.$result);
1.219 raeburn 1617: $uhome = &Apache::lonnet::homeserver($env{'form.ccuname'},
1.101 albertel 1618: $env{'form.ccdomain'});
1.219 raeburn 1619: $r->print('<br />'.&mt('Home server').': '.$uhome.' '.
1620: &Apache::lonnet::hostname($uhome));
1.101 albertel 1621: } elsif (($env{'form.login'} ne 'nochange') &&
1622: ($env{'form.login'} ne '' )) {
1.27 matthew 1623: # Modify user privileges
1624: if (! $amode || ! $genpwd) {
1.193 raeburn 1625: $r->print($error.'Invalid login mode or password'.$end.$rtnlink);
1.27 matthew 1626: return;
1.20 harris41 1627: }
1.27 matthew 1628: # Only allow authentification modification if the person has authority
1.101 albertel 1629: if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
1.20 harris41 1630: $r->print('Modifying authentication: '.
1.31 matthew 1631: &Apache::lonnet::modifyuserauth(
1.101 albertel 1632: $env{'form.ccdomain'},$env{'form.ccuname'},
1.21 harris41 1633: $amode,$genpwd));
1.102 albertel 1634: $r->print('<br />'.&mt('Home server').': '.&Apache::lonnet::homeserver
1.101 albertel 1635: ($env{'form.ccuname'},$env{'form.ccdomain'}));
1.4 www 1636: } else {
1.27 matthew 1637: # Okay, this is a non-fatal error.
1.193 raeburn 1638: $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.'.$end);
1.27 matthew 1639: }
1.28 matthew 1640: }
1641: ##
1.213 raeburn 1642: my (@userroles,%userupdate,$cnum,$cdom,$namechanged);
1643: if ($context eq 'course') {
1644: ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity();
1645: }
1.101 albertel 1646: if (! $env{'form.makeuser'} ) {
1.28 matthew 1647: # Check for need to change
1648: my %userenv = &Apache::lonnet::get
1.134 raeburn 1649: ('environment',['firstname','middlename','lastname','generation',
1.196 raeburn 1650: 'id','permanentemail','portfolioquota','inststatus'],
1.160 raeburn 1651: $env{'form.ccdomain'},$env{'form.ccuname'});
1.28 matthew 1652: my ($tmp) = keys(%userenv);
1653: if ($tmp =~ /^(con_lost|error)/i) {
1654: %userenv = ();
1655: }
1.206 raeburn 1656: my $no_forceid_alert;
1657: # Check to see if user information can be changed
1658: my %domconfig =
1659: &Apache::lonnet::get_dom('configuration',['usermodification'],
1660: $env{'form.ccdomain'});
1.213 raeburn 1661: my @statuses = ('active','future');
1662: my %roles = &Apache::lonnet::get_my_roles($env{'form.ccuname'},$env{'form.ccdomain'},'userroles',\@statuses,undef,$env{'request.role.domain'});
1663: my ($auname,$audom);
1.220 raeburn 1664: if ($context eq 'author') {
1.206 raeburn 1665: $auname = $env{'user.name'};
1666: $audom = $env{'user.domain'};
1667: }
1668: foreach my $item (keys(%roles)) {
1.220 raeburn 1669: my ($rolenum,$roledom,$role) = split(/:/,$item,-1);
1.206 raeburn 1670: if ($context eq 'course') {
1671: if ($cnum ne '' && $cdom ne '') {
1672: if ($rolenum eq $cnum && $roledom eq $cdom) {
1673: if (!grep(/^\Q$role\E$/,@userroles)) {
1674: push(@userroles,$role);
1675: }
1676: }
1677: }
1678: } elsif ($context eq 'author') {
1679: if ($rolenum eq $auname && $roledom eq $audom) {
1680: if (!grep(/^\Q$role\E$/,@userroles)) {
1681: push(@userroles,$role);
1682: }
1683: }
1684: }
1685: }
1.220 raeburn 1686: if ($env{'form.action'} eq 'singlestudent') {
1687: if (!grep(/^st$/,@userroles)) {
1688: push(@userroles,'st');
1689: }
1690: } else {
1691: # Check for course or co-author roles being activated or re-enabled
1692: if ($context eq 'author' || $context eq 'course') {
1693: foreach my $key (keys(%env)) {
1694: if ($context eq 'author') {
1695: if ($key=~/^form\.act_\Q$audom\E_\Q$auname\E_([^_]+)/) {
1696: if (!grep(/^\Q$1\E$/,@userroles)) {
1697: push(@userroles,$1);
1698: }
1699: } elsif ($key =~/^form\.ren\:\Q$audom\E\/\Q$auname\E_([^_]+)/) {
1700: if (!grep(/^\Q$1\E$/,@userroles)) {
1701: push(@userroles,$1);
1702: }
1.206 raeburn 1703: }
1.220 raeburn 1704: } elsif ($context eq 'course') {
1705: if ($key=~/^form\.act_\Q$cdom\E_\Q$cnum\E_([^_]+)/) {
1706: if (!grep(/^\Q$1\E$/,@userroles)) {
1707: push(@userroles,$1);
1708: }
1709: } elsif ($key =~/^form\.ren\:\Q$cdom\E\/\Q$cnum\E(\/?\w*)_([^_]+)/) {
1710: if (!grep(/^\Q$1\E$/,@userroles)) {
1711: push(@userroles,$1);
1712: }
1.206 raeburn 1713: }
1714: }
1715: }
1716: }
1717: }
1718: #Check to see if we can change personal data for the user
1719: my (@mod_disallowed,@longroles);
1720: foreach my $role (@userroles) {
1721: if ($role eq 'cr') {
1722: push(@longroles,'Custom');
1723: } else {
1724: push(@longroles,&Apache::lonnet::plaintext($role));
1725: }
1726: }
1.219 raeburn 1727: my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
1728: my %canmodify = &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},\@userinfo,\@userroles);
1729: foreach my $item (@userinfo) {
1.28 matthew 1730: # Strip leading and trailing whitespace
1.203 raeburn 1731: $env{'form.c'.$item} =~ s/(\s+$|^\s+)//g;
1.219 raeburn 1732: if (!$canmodify{$item}) {
1.207 raeburn 1733: if (defined($env{'form.c'.$item})) {
1734: if ($env{'form.c'.$item} ne $userenv{$item}) {
1735: push(@mod_disallowed,$item);
1736: }
1.206 raeburn 1737: }
1738: $env{'form.c'.$item} = $userenv{$item};
1739: }
1.28 matthew 1740: }
1.196 raeburn 1741: # Check to see if we can change the ID/student number
1742: my $forceid = $env{'form.forceid'};
1743: my $recurseid = $env{'form.recurseid'};
1744: my (%alerts,%rulematch,%idinst_results,%curr_rules,%got_rules);
1.203 raeburn 1745: my %uidhash = &Apache::lonnet::idrget($env{'form.ccdomain'},
1746: $env{'form.ccuname'});
1747: if (($uidhash{$env{'form.ccuname'}}) &&
1748: ($uidhash{$env{'form.ccuname'}}!~/error\:/) &&
1749: (!$forceid)) {
1750: if ($env{'form.cid'} ne $uidhash{$env{'form.ccuname'}}) {
1751: $env{'form.cid'} = $userenv{'id'};
1.206 raeburn 1752: $no_forceid_alert = &mt('New student/employeeID does not match existing ID for this user.').'<br />'.&mt('Change is not permitted without checking the \'Force ID change\' checkbox on the previous page.').'<br />'."\n";
1.203 raeburn 1753: }
1754: }
1755: if ($env{'form.cid'} ne $userenv{'id'}) {
1.196 raeburn 1756: my $checkhash;
1757: my $checks = { 'id' => 1 };
1758: $checkhash->{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}} =
1759: { 'newuser' => $newuser,
1760: 'id' => $env{'form.cid'},
1761: };
1762: &Apache::loncommon::user_rule_check($checkhash,$checks,
1763: \%alerts,\%rulematch,\%idinst_results,\%curr_rules,\%got_rules);
1764: if (ref($alerts{'id'}) eq 'HASH') {
1765: if (ref($alerts{'id'}{$env{'form.ccdomain'}}) eq 'HASH') {
1.203 raeburn 1766: $env{'form.cid'} = $userenv{'id'};
1.196 raeburn 1767: }
1768: }
1769: }
1.213 raeburn 1770: my ($quotachanged,$oldportfolioquota,$newportfolioquota,
1.204 raeburn 1771: $inststatus,$oldisdefault,$newisdefault,$olddefquotatext,
1772: $newdefquotatext);
1.149 raeburn 1773: my ($defquota,$settingstatus) =
1774: &Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus);
1.220 raeburn 1775: my $showquota;
1776: if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
1777: $showquota = 1;
1778: }
1.134 raeburn 1779: my %changeHash;
1.204 raeburn 1780: $changeHash{'portfolioquota'} = $userenv{'portfolioquota'};
1.149 raeburn 1781: if ($userenv{'portfolioquota'} ne '') {
1.134 raeburn 1782: $oldportfolioquota = $userenv{'portfolioquota'};
1.149 raeburn 1783: if ($env{'form.customquota'} == 1) {
1784: if ($env{'form.portfolioquota'} eq '') {
1785: $newportfolioquota = 0;
1786: } else {
1787: $newportfolioquota = $env{'form.portfolioquota'};
1788: $newportfolioquota =~ s/[^\d\.]//g;
1789: }
1.204 raeburn 1790: if ($newportfolioquota != $oldportfolioquota) {
1.149 raeburn 1791: $quotachanged = "a_admin($newportfolioquota,\%changeHash);
1.134 raeburn 1792: }
1.149 raeburn 1793: } else {
1794: $quotachanged = "a_admin('',\%changeHash);
1795: $newportfolioquota = $defquota;
1.204 raeburn 1796: $newisdefault = 1;
1.134 raeburn 1797: }
1798: } else {
1.204 raeburn 1799: $oldisdefault = 1;
1.149 raeburn 1800: $oldportfolioquota = $defquota;
1801: if ($env{'form.customquota'} == 1) {
1802: if ($env{'form.portfolioquota'} eq '') {
1803: $newportfolioquota = 0;
1804: } else {
1805: $newportfolioquota = $env{'form.portfolioquota'};
1806: $newportfolioquota =~ s/[^\d\.]//g;
1807: }
1808: $quotachanged = "a_admin($newportfolioquota,\%changeHash);
1809: } else {
1810: $newportfolioquota = $defquota;
1.204 raeburn 1811: $newisdefault = 1;
1.149 raeburn 1812: }
1813: }
1.204 raeburn 1814: if ($oldisdefault) {
1815: $olddefquotatext = &get_defaultquota_text($settingstatus);
1816: }
1817: if ($newisdefault) {
1818: $newdefquotatext = &get_defaultquota_text($settingstatus);
1.134 raeburn 1819: }
1.206 raeburn 1820: if ($env{'form.cfirstname'} ne $userenv{'firstname'} ||
1821: $env{'form.cmiddlename'} ne $userenv{'middlename'} ||
1822: $env{'form.clastname'} ne $userenv{'lastname'} ||
1823: $env{'form.cgeneration'} ne $userenv{'generation'} ||
1824: $env{'form.cid'} ne $userenv{'id'} ||
1825: $env{'form.cpermanentemail'} ne $userenv{'permanentemail'} ) {
1.134 raeburn 1826: $namechanged = 1;
1827: }
1.204 raeburn 1828: if ($namechanged || $quotachanged) {
1.101 albertel 1829: $changeHash{'firstname'} = $env{'form.cfirstname'};
1830: $changeHash{'middlename'} = $env{'form.cmiddlename'};
1831: $changeHash{'lastname'} = $env{'form.clastname'};
1832: $changeHash{'generation'} = $env{'form.cgeneration'};
1.196 raeburn 1833: $changeHash{'id'} = $env{'form.cid'};
1.174 raeburn 1834: $changeHash{'permanentemail'} = $env{'form.cpermanentemail'};
1.204 raeburn 1835: my ($quotachgresult,$namechgresult);
1836: if ($quotachanged) {
1837: $quotachgresult =
1838: &Apache::lonnet::put('environment',\%changeHash,
1839: $env{'form.ccdomain'},$env{'form.ccuname'});
1840: }
1841: if ($namechanged) {
1842: # Make the change
1843: $namechgresult =
1844: &Apache::lonnet::modifyuser($env{'form.ccdomain'},
1845: $env{'form.ccuname'},$changeHash{'id'},undef,undef,
1846: $changeHash{'firstname'},$changeHash{'middlename'},
1847: $changeHash{'lastname'},$changeHash{'generation'},
1848: $changeHash{'id'},undef,$changeHash{'permanentemail'});
1.220 raeburn 1849: %userupdate = (
1850: lastname => $env{'form.clastname'},
1851: middlename => $env{'form.cmiddlename'},
1852: firstname => $env{'form.cfirstname'},
1853: generation => $env{'form.cgeneration'},
1854: id => $env{'form.cid'},
1855: );
1.204 raeburn 1856: }
1857: if (($namechanged && $namechgresult eq 'ok') ||
1858: ($quotachanged && $quotachgresult eq 'ok')) {
1.28 matthew 1859: # Tell the user we changed the name
1.73 sakharuk 1860: my %lt=&Apache::lonlocal::texthash(
1861: 'uic' => "User Information Changed",
1862: 'frst' => "first",
1863: 'mddl' => "middle",
1864: 'lst' => "last",
1865: 'gen' => "generation",
1.196 raeburn 1866: 'id' => "ID/Student number",
1.160 raeburn 1867: 'mail' => "permanent e-mail",
1.134 raeburn 1868: 'disk' => "disk space allocated to portfolio files",
1.73 sakharuk 1869: 'prvs' => "Previous",
1870: 'chto' => "Changed To"
1871: );
1.201 raeburn 1872: $r->print('<h4>'.$lt{'uic'}.'</h4>'.
1873: &Apache::loncommon::start_data_table().
1874: &Apache::loncommon::start_data_table_header_row());
1.28 matthew 1875: $r->print(<<"END");
1.201 raeburn 1876: <th> </th>
1.73 sakharuk 1877: <th>$lt{'frst'}</th>
1878: <th>$lt{'mddl'}</th>
1879: <th>$lt{'lst'}</th>
1.134 raeburn 1880: <th>$lt{'gen'}</th>
1.196 raeburn 1881: <th>$lt{'id'}</th>
1.173 raeburn 1882: <th>$lt{'mail'}</th>
1.201 raeburn 1883: END
1.220 raeburn 1884: if ($showquota) {
1885: $r->print("
1886: <th>$lt{'disk'}</th>\n");
1887: }
1.201 raeburn 1888: $r->print(&Apache::loncommon::end_data_table_header_row().
1889: &Apache::loncommon::start_data_table_row());
1890: $r->print(<<"END");
1891: <td><b>$lt{'prvs'}</b></td>
1.28 matthew 1892: <td>$userenv{'firstname'} </td>
1893: <td>$userenv{'middlename'} </td>
1894: <td>$userenv{'lastname'} </td>
1.134 raeburn 1895: <td>$userenv{'generation'} </td>
1.196 raeburn 1896: <td>$userenv{'id'}</td>
1.160 raeburn 1897: <td>$userenv{'permanentemail'} </td>
1.201 raeburn 1898: END
1.220 raeburn 1899: if ($showquota) {
1900: $r->print("
1901: <td>$oldportfolioquota Mb $olddefquotatext </td>\n");
1902: }
1.201 raeburn 1903: $r->print(&Apache::loncommon::end_data_table_row().
1904: &Apache::loncommon::start_data_table_row());
1905: $r->print(<<"END");
1906: <td><b>$lt{'chto'}</b></td>
1.101 albertel 1907: <td>$env{'form.cfirstname'} </td>
1908: <td>$env{'form.cmiddlename'} </td>
1909: <td>$env{'form.clastname'} </td>
1.134 raeburn 1910: <td>$env{'form.cgeneration'} </td>
1.196 raeburn 1911: <td>$env{'form.cid'} </td>
1.160 raeburn 1912: <td>$env{'form.cpermanentemail'} </td>
1.28 matthew 1913: END
1.220 raeburn 1914: if ($showquota) {
1915: $r->print("
1916: <td>$newportfolioquota Mb $newdefquotatext </td>\n");
1917: }
1.201 raeburn 1918: $r->print(&Apache::loncommon::end_data_table_row().
1.206 raeburn 1919: &Apache::loncommon::end_data_table().'<br />');
1.203 raeburn 1920: if ($env{'form.cid'} ne $userenv{'id'}) {
1921: &Apache::lonnet::idput($env{'form.ccdomain'},
1922: ($env{'form.ccuname'} => $env{'form.cid'}));
1923: if (($recurseid) &&
1924: (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) {
1925: my $idresult =
1926: &Apache::lonuserutils::propagate_id_change(
1927: $env{'form.ccuname'},$env{'form.ccdomain'},
1928: \%userupdate);
1929: $r->print('<br />'.$idresult.'<br />');
1930: }
1.196 raeburn 1931: }
1.149 raeburn 1932: if (($env{'form.ccdomain'} eq $env{'user.domain'}) &&
1933: ($env{'form.ccuname'} eq $env{'user.name'})) {
1934: my %newenvhash;
1935: foreach my $key (keys(%changeHash)) {
1936: $newenvhash{'environment.'.$key} = $changeHash{$key};
1937: }
1938: &Apache::lonnet::appenv(%newenvhash);
1939: }
1.28 matthew 1940: } else { # error occurred
1.188 raeburn 1941: $r->print('<span class="LC_error">'.&mt('Unable to successfully change environment for').' '.
1942: $env{'form.ccuname'}.' '.&mt('in domain').' '.
1.206 raeburn 1943: $env{'form.ccdomain'}.'</span><br />');
1.28 matthew 1944: }
1.101 albertel 1945: } else { # End of if ($env ... ) logic
1.204 raeburn 1946: # They did not want to change the users name or quota but we can
1947: # still tell them what the name and quota are
1.73 sakharuk 1948: my %lt=&Apache::lonlocal::texthash(
1.196 raeburn 1949: 'id' => "ID/Student number",
1.160 raeburn 1950: 'mail' => "Permanent e-mail",
1.134 raeburn 1951: 'disk' => "Disk space allocated to user's portfolio files",
1.73 sakharuk 1952: );
1.134 raeburn 1953: $r->print(<<"END");
1.196 raeburn 1954: <h4>$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'}
1.28 matthew 1955: END
1.204 raeburn 1956: if ($userenv{'permanentemail'} ne '') {
1957: $r->print('<br />['.$lt{'mail'}.': '.
1958: $userenv{'permanentemail'}.']');
1.134 raeburn 1959: }
1.220 raeburn 1960: if ($showquota) {
1961: $r->print('<br />['.$lt{'disk'}.': '.$oldportfolioquota.' Mb '.
1962: $olddefquotatext.']');
1963: }
1964: $r->print('</h4>');
1.28 matthew 1965: }
1.206 raeburn 1966: if (@mod_disallowed) {
1967: my ($rolestr,$contextname);
1968: if (@longroles > 0) {
1969: $rolestr = join(', ',@longroles);
1970: } else {
1971: $rolestr = &mt('No roles');
1972: }
1973: if ($context eq 'course') {
1974: $contextname = &mt('course');
1975: } elsif ($context eq 'author') {
1976: $contextname = &mt('co-author');
1977: }
1978: $r->print(&mt('The following fields were not updated: ').'<ul>');
1979: my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
1980: foreach my $field (@mod_disallowed) {
1981: $r->print('<li>'.$fieldtitles{$field}.'</li>'."\n");
1982: }
1.207 raeburn 1983: $r->print('</ul>');
1984: if (@mod_disallowed == 1) {
1985: $r->print(&mt("You do not have the authority to change this field given the user's current set of active/future [_1] roles:",$contextname));
1986: } else {
1987: $r->print(&mt("You do not have the authority to change these fields given the user's current set of active/future [_1] roles:",$contextname));
1988: }
1989: $r->print('<span class="LC_cusr_emph">'.$rolestr.'</span><br />'.
1990: &mt('Contact your <a href="[_1]">helpdesk</a> for more information.',"javascript:helpMenu('display')").'<br />');
1.206 raeburn 1991: }
1992: $r->print($no_forceid_alert.
1993: &Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts, \%curr_rules));
1.4 www 1994: }
1.220 raeburn 1995: if ($env{'form.action'} eq 'singlestudent') {
1996: &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser);
1.226 raeburn 1997: $r->print('<p><a href="javascript:backPage(document.userupdate)">'. &mt('Enroll Another Student').'</a></p>');
1.220 raeburn 1998: } else {
1.225 raeburn 1999: my @rolechanges = &update_roles($r);
2000: if ($namechanged) {
1.220 raeburn 2001: if ($context eq 'course') {
2002: if (@userroles > 0) {
1.225 raeburn 2003: if ((@rolechanges == 0) ||
2004: (!(grep(/^st$/,@rolechanges)))) {
2005: if (grep(/^st$/,@userroles)) {
2006: my $classlistupdated =
2007: &Apache::lonuserutils::update_classlist($cdom,
1.220 raeburn 2008: $cnum,$env{'form.ccdomain'},
2009: $env{'form.ccuname'},\%userupdate);
1.225 raeburn 2010: }
1.220 raeburn 2011: }
2012: }
2013: }
2014: }
1.226 raeburn 2015: my $userinfo = &Apache::loncommon::plainname($env{'form.ccuname'},
2016: $env{'form.ccdomain'});
2017: $r->print('<p><a href="javascript:backPage(document.userupdate,'."'$env{'form.prevphase'}','modify'".')">'.&mt('Modify this user: <span class="LC_cusr_emph">([_1])</span>',$userinfo).'</a>'.(' 'x5).'<a href="javascript:backPage(document.userupdate)">'.&mt('Create/Modify Another User').'</a></p>');
1.220 raeburn 2018: }
2019: $r->print(&Apache::loncommon::end_page());
2020: }
2021:
2022: sub update_roles {
2023: my ($r) = @_;
1.4 www 2024: my $now=time;
1.225 raeburn 2025: my @rolechanges;
1.220 raeburn 2026: my %disallowed;
1.73 sakharuk 2027: $r->print('<h3>'.&mt('Modifying Roles').'</h3>');
1.135 raeburn 2028: foreach my $key (keys (%env)) {
2029: next if (! $env{$key});
1.190 raeburn 2030: next if ($key eq 'form.action');
1.27 matthew 2031: # Revoke roles
1.135 raeburn 2032: if ($key=~/^form\.rev/) {
2033: if ($key=~/^form\.rev\:([^\_]+)\_([^\_\.]+)$/) {
1.64 www 2034: # Revoke standard role
1.170 albertel 2035: my ($scope,$role) = ($1,$2);
2036: my $result =
2037: &Apache::lonnet::revokerole($env{'form.ccdomain'},
2038: $env{'form.ccuname'},
2039: $scope,$role);
2040: $r->print(&mt('Revoking [_1] in [_2]: [_3]',
2041: $role,$scope,'<b>'.$result.'</b>').'<br />');
2042: if ($role eq 'st') {
1.202 raeburn 2043: my $result =
1.198 raeburn 2044: &Apache::lonuserutils::classlist_drop($scope,
2045: $env{'form.ccuname'},$env{'form.ccdomain'},
1.202 raeburn 2046: $now);
1.170 albertel 2047: $r->print($result);
1.53 www 2048: }
1.225 raeburn 2049: if (!grep(/^\Q$role\E$/,@rolechanges)) {
2050: push(@rolechanges,$role);
2051: }
1.196 raeburn 2052: }
1.195 raeburn 2053: if ($key=~m{^form\.rev\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}s) {
1.64 www 2054: # Revoke custom role
1.113 raeburn 2055: $r->print(&mt('Revoking custom role:').
1.139 albertel 2056: ' '.$4.' by '.$3.':'.$2.' in '.$1.': <b>'.
1.101 albertel 2057: &Apache::lonnet::revokecustomrole($env{'form.ccdomain'},
2058: $env{'form.ccuname'},$1,$2,$3,$4).
1.102 albertel 2059: '</b><br />');
1.225 raeburn 2060: if (!grep(/^cr$/,@rolechanges)) {
2061: push(@rolechanges,'cr');
2062: }
1.64 www 2063: }
1.135 raeburn 2064: } elsif ($key=~/^form\.del/) {
2065: if ($key=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) {
1.116 raeburn 2066: # Delete standard role
1.170 albertel 2067: my ($scope,$role) = ($1,$2);
2068: my $result =
2069: &Apache::lonnet::assignrole($env{'form.ccdomain'},
2070: $env{'form.ccuname'},
2071: $scope,$role,$now,0,1);
2072: $r->print(&mt('Deleting [_1] in [_2]: [_3]',$role,$scope,
2073: '<b>'.$result.'</b>').'<br />');
2074: if ($role eq 'st') {
1.202 raeburn 2075: my $result =
1.198 raeburn 2076: &Apache::lonuserutils::classlist_drop($scope,
2077: $env{'form.ccuname'},$env{'form.ccdomain'},
1.202 raeburn 2078: $now);
1.170 albertel 2079: $r->print($result);
1.81 albertel 2080: }
1.225 raeburn 2081: if (!grep(/^\Q$role\E$/,@rolechanges)) {
2082: push(@rolechanges,$role);
2083: }
1.116 raeburn 2084: }
1.139 albertel 2085: if ($key=~m{^form\.del\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) {
1.116 raeburn 2086: my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
2087: # Delete custom role
1.170 albertel 2088: $r->print(&mt('Deleting custom role [_1] by [_2]:[_3] in [_4]',
1.116 raeburn 2089: $rolename,$rnam,$rdom,$url).': <b>'.
2090: &Apache::lonnet::assigncustomrole($env{'form.ccdomain'},
2091: $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
2092: 0,1).'</b><br />');
1.225 raeburn 2093: if (!grep(/^cr$/,@rolechanges)) {
2094: push(@rolechanges,'cr');
2095: }
1.116 raeburn 2096: }
1.135 raeburn 2097: } elsif ($key=~/^form\.ren/) {
1.101 albertel 2098: my $udom = $env{'form.ccdomain'};
2099: my $uname = $env{'form.ccuname'};
1.116 raeburn 2100: # Re-enable standard role
1.135 raeburn 2101: if ($key=~/^form\.ren\:([^\_]+)\_([^\_\.]+)$/) {
1.89 raeburn 2102: my $url = $1;
2103: my $role = $2;
2104: my $logmsg;
2105: my $output;
2106: if ($role eq 'st') {
1.141 albertel 2107: if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) {
1.129 albertel 2108: my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3);
1.220 raeburn 2109: if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) {
1.223 raeburn 2110: if ($result eq 'refused' && $logmsg) {
2111: $output = $logmsg;
2112: } else {
2113: $output = "Error: $result\n";
2114: }
1.89 raeburn 2115: } else {
2116: $output = &mt('Assigning').' '.$role.' in '.$url.
2117: &mt('starting').' '.localtime($now).
2118: ': <br />'.$logmsg.'<br />'.
2119: &mt('Add to classlist').': <b>ok</b><br />';
2120: }
2121: }
2122: } else {
1.101 albertel 2123: my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'},
2124: $env{'form.ccuname'},$url,$role,0,$now);
1.116 raeburn 2125: $output = &mt('Re-enabling [_1] in [_2]: <b>[_3]</b>',
1.89 raeburn 2126: $role,$url,$result).'<br />';
1.27 matthew 2127: }
1.89 raeburn 2128: $r->print($output);
1.225 raeburn 2129: if (!grep(/^\Q$role\E$/,@rolechanges)) {
2130: push(@rolechanges,$role);
2131: }
1.113 raeburn 2132: }
1.116 raeburn 2133: # Re-enable custom role
1.139 albertel 2134: if ($key=~m{^form\.ren\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) {
1.116 raeburn 2135: my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
2136: my $result = &Apache::lonnet::assigncustomrole(
2137: $env{'form.ccdomain'}, $env{'form.ccuname'},
2138: $url,$rdom,$rnam,$rolename,0,$now);
2139: $r->print(&mt('Re-enabling custom role [_1] by [_2]@[_3] in [_4] : <b>[_5]</b>',
2140: $rolename,$rnam,$rdom,$url,$result).'<br />');
1.225 raeburn 2141: if (!grep(/^cr$/,@rolechanges)) {
2142: push(@rolechanges,'cr');
2143: }
1.116 raeburn 2144: }
1.135 raeburn 2145: } elsif ($key=~/^form\.act/) {
1.101 albertel 2146: my $udom = $env{'form.ccdomain'};
2147: my $uname = $env{'form.ccuname'};
1.141 albertel 2148: if ($key=~/^form\.act\_($match_domain)\_($match_courseid)\_cr_cr_($match_domain)_($match_username)_([^\_]+)$/) {
1.65 www 2149: # Activate a custom role
1.83 albertel 2150: my ($one,$two,$three,$four,$five)=($1,$2,$3,$4,$5);
2151: my $url='/'.$one.'/'.$two;
2152: my $full=$one.'_'.$two.'_cr_cr_'.$three.'_'.$four.'_'.$five;
1.65 www 2153:
1.101 albertel 2154: my $start = ( $env{'form.start_'.$full} ?
2155: $env{'form.start_'.$full} :
1.88 raeburn 2156: $now );
1.101 albertel 2157: my $end = ( $env{'form.end_'.$full} ?
2158: $env{'form.end_'.$full} :
1.88 raeburn 2159: 0 );
2160:
2161: # split multiple sections
2162: my %sections = ();
1.101 albertel 2163: my $num_sections = &build_roles($env{'form.sec_'.$full},\%sections,$5);
1.88 raeburn 2164: if ($num_sections == 0) {
1.129 albertel 2165: $r->print(&Apache::loncommon::commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end));
1.88 raeburn 2166: } else {
1.114 albertel 2167: my %curr_groups =
1.117 raeburn 2168: &Apache::longroup::coursegroups($one,$two);
1.113 raeburn 2169: foreach my $sec (sort {$a cmp $b} keys %sections) {
2170: if (($sec eq 'none') || ($sec eq 'all') ||
2171: exists($curr_groups{$sec})) {
2172: $disallowed{$sec} = $url;
2173: next;
2174: }
2175: my $securl = $url.'/'.$sec;
1.129 albertel 2176: $r->print(&Apache::loncommon::commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end));
1.88 raeburn 2177: }
2178: }
1.225 raeburn 2179: if (!grep(/^cr$/,@rolechanges)) {
2180: push(@rolechanges,'cr');
2181: }
1.142 raeburn 2182: } elsif ($key=~/^form\.act\_($match_domain)\_($match_name)\_([^\_]+)$/) {
1.27 matthew 2183: # Activate roles for sections with 3 id numbers
2184: # set start, end times, and the url for the class
1.83 albertel 2185: my ($one,$two,$three)=($1,$2,$3);
1.101 albertel 2186: my $start = ( $env{'form.start_'.$one.'_'.$two.'_'.$three} ?
2187: $env{'form.start_'.$one.'_'.$two.'_'.$three} :
1.27 matthew 2188: $now );
1.101 albertel 2189: my $end = ( $env{'form.end_'.$one.'_'.$two.'_'.$three} ?
2190: $env{'form.end_'.$one.'_'.$two.'_'.$three} :
1.27 matthew 2191: 0 );
1.83 albertel 2192: my $url='/'.$one.'/'.$two;
1.88 raeburn 2193: my $type = 'three';
2194: # split multiple sections
2195: my %sections = ();
1.101 albertel 2196: my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);
1.88 raeburn 2197: if ($num_sections == 0) {
1.129 albertel 2198: $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
1.88 raeburn 2199: } else {
1.114 albertel 2200: my %curr_groups =
1.117 raeburn 2201: &Apache::longroup::coursegroups($one,$two);
1.88 raeburn 2202: my $emptysec = 0;
2203: foreach my $sec (sort {$a cmp $b} keys %sections) {
2204: $sec =~ s/\W//g;
1.113 raeburn 2205: if ($sec ne '') {
2206: if (($sec eq 'none') || ($sec eq 'all') ||
2207: exists($curr_groups{$sec})) {
2208: $disallowed{$sec} = $url;
2209: next;
2210: }
1.88 raeburn 2211: my $securl = $url.'/'.$sec;
1.129 albertel 2212: $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec));
1.88 raeburn 2213: } else {
2214: $emptysec = 1;
2215: }
2216: }
2217: if ($emptysec) {
1.129 albertel 2218: $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
1.88 raeburn 2219: }
1.225 raeburn 2220: }
2221: if (!grep(/^\Q$three\E$/,@rolechanges)) {
2222: push(@rolechanges,$three);
2223: }
1.135 raeburn 2224: } elsif ($key=~/^form\.act\_([^\_]+)\_([^\_]+)$/) {
1.27 matthew 2225: # Activate roles for sections with two id numbers
2226: # set start, end times, and the url for the class
1.101 albertel 2227: my $start = ( $env{'form.start_'.$1.'_'.$2} ?
2228: $env{'form.start_'.$1.'_'.$2} :
1.27 matthew 2229: $now );
1.101 albertel 2230: my $end = ( $env{'form.end_'.$1.'_'.$2} ?
2231: $env{'form.end_'.$1.'_'.$2} :
1.27 matthew 2232: 0 );
1.225 raeburn 2233: my $one = $1;
2234: my $two = $2;
2235: my $url='/'.$one.'/';
1.88 raeburn 2236: # split multiple sections
2237: my %sections = ();
1.225 raeburn 2238: my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two},\%sections,$two);
1.88 raeburn 2239: if ($num_sections == 0) {
1.225 raeburn 2240: $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,''));
1.88 raeburn 2241: } else {
2242: my $emptysec = 0;
2243: foreach my $sec (sort {$a cmp $b} keys %sections) {
2244: if ($sec ne '') {
2245: my $securl = $url.'/'.$sec;
1.225 raeburn 2246: $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$two,$start,$end,$one,undef,$sec));
1.88 raeburn 2247: } else {
2248: $emptysec = 1;
2249: }
2250: }
2251: if ($emptysec) {
1.225 raeburn 2252: $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,''));
1.88 raeburn 2253: }
2254: }
1.225 raeburn 2255: if (!grep(/^\Q$two\E$/,@rolechanges)) {
2256: push(@rolechanges,$two);
2257: }
1.64 www 2258: } else {
1.190 raeburn 2259: $r->print('<p><span class="LC_error">'.&mt('ERROR').': '.&mt('Unknown command').' <tt>'.$key.'</tt></span></p><br />');
1.64 www 2260: }
1.113 raeburn 2261: foreach my $key (sort(keys(%disallowed))) {
2262: if (($key eq 'none') || ($key eq 'all')) {
2263: $r->print('<p>'.&mt('[_1] may not be used as the name for a section, as it is a reserved word.',$key));
2264: } else {
2265: $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));
2266: }
2267: $r->print(' '.&mt('Please <a href="javascript:history.go(-1)">go back</a> and choose a different section name.').'</p><br />');
2268: }
2269: }
1.101 albertel 2270: } # End of foreach (keys(%env))
1.75 www 2271: # Flush the course logs so reverse user roles immediately updated
2272: &Apache::lonnet::flushcourselogs();
1.225 raeburn 2273: if (@rolechanges == 0) {
1.193 raeburn 2274: $r->print(&mt('No roles to modify'));
2275: }
1.225 raeburn 2276: return @rolechanges;
1.220 raeburn 2277: }
2278:
2279: sub enroll_single_student {
2280: my ($r,$uhome,$amode,$genpwd,$now,$newuser) = @_;
2281: $r->print('<h3>'.&mt('Enrolling Student').'</h3>');
2282:
2283: # Remove non alphanumeric values from section
2284: $env{'form.sections'}=~s/\W//g;
2285:
2286: # Clean out any old student roles the user has in this class.
2287: &Apache::lonuserutils::modifystudent($env{'form.ccdomain'},
2288: $env{'form.ccuname'},$env{'request.course.id'},undef,$uhome);
2289: my ($startdate,$enddate) = &Apache::lonuserutils::get_dates_from_form();
2290: my $enroll_result =
2291: &Apache::lonnet::modify_student_enrollment($env{'form.ccdomain'},
2292: $env{'form.ccuname'},$env{'form.cid'},$env{'form.cfirstname'},
2293: $env{'form.cmiddlename'},$env{'form.clastname'},
2294: $env{'form.generation'},$env{'form.sections'},$enddate,
2295: $startdate,'manual',undef,$env{'request.course.id'});
2296: if ($enroll_result =~ /^ok/) {
2297: $r->print(&mt('<b>[_1]</b> enrolled',$env{'form.ccuname'}.':'.$env{'form.ccdomain'}));
2298: if ($env{'form.sections'} ne '') {
2299: $r->print(' '.&mt('in section [_1]',$env{'form.sections'}));
2300: }
2301: my ($showstart,$showend);
2302: if ($startdate <= $now) {
2303: $showstart = &mt('Access starts immediately');
2304: } else {
2305: $showstart = &mt('Access starts: ').&Apache::lonlocal::locallocaltime($startdate);
2306: }
2307: if ($enddate == 0) {
2308: $showend = &mt('ends: no ending date');
2309: } else {
2310: $showend = &mt('ends: ').&Apache::lonlocal::locallocaltime($enddate);
2311: }
2312: $r->print('.<br />'.$showstart.'; '.$showend);
2313: if ($startdate <= $now && !$newuser) {
2314: $r->print("<p> ".&mt('If the student is currently logged-in to LON-CAPA, the new role will be available when the student next logs in.')."</p>");
2315: }
2316: } else {
2317: $r->print(&mt('unable to enroll').": ".$enroll_result);
2318: }
2319: return;
1.188 raeburn 2320: }
2321:
1.204 raeburn 2322: sub get_defaultquota_text {
2323: my ($settingstatus) = @_;
2324: my $defquotatext;
2325: if ($settingstatus eq '') {
2326: $defquotatext = &mt('(default)');
2327: } else {
2328: my ($usertypes,$order) =
2329: &Apache::lonnet::retrieve_inst_usertypes($env{'form.ccdomain'});
2330: if ($usertypes->{$settingstatus} eq '') {
2331: $defquotatext = &mt('(default)');
2332: } else {
2333: $defquotatext = &mt('(default for [_1])',$usertypes->{$settingstatus});
2334: }
2335: }
2336: return $defquotatext;
2337: }
2338:
1.188 raeburn 2339: sub update_result_form {
2340: my ($uhome) = @_;
2341: my $outcome =
2342: '<form name="userupdate" method="post" />'."\n";
1.160 raeburn 2343: foreach my $item ('srchby','srchin','srchtype','srchterm','srchdomain','ccuname','ccdomain') {
1.188 raeburn 2344: $outcome .= '<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n";
1.160 raeburn 2345: }
1.207 raeburn 2346: if ($env{'form.origname'} ne '') {
2347: $outcome .= '<input type="hidden" name="origname" value="'.$env{'form.origname'}.'" />'."\n";
2348: }
1.160 raeburn 2349: foreach my $item ('sortby','seluname','seludom') {
2350: if (exists($env{'form.'.$item})) {
1.188 raeburn 2351: $outcome .= '<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n";
1.160 raeburn 2352: }
2353: }
1.188 raeburn 2354: if ($uhome eq 'no_host') {
2355: $outcome .= '<input type="hidden" name="forcenewuser" value="1" />'."\n";
2356: }
2357: $outcome .= '<input type="hidden" name="phase" value="" />'."\n".
2358: '<input type ="hidden" name="currstate" value="" />'."\n".
1.220 raeburn 2359: '<input type ="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".
1.188 raeburn 2360: '</form>';
2361: return $outcome;
1.4 www 2362: }
2363:
1.149 raeburn 2364: sub quota_admin {
2365: my ($setquota,$changeHash) = @_;
2366: my $quotachanged;
2367: if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
2368: # Current user has quota modification privileges
2369: $quotachanged = 1;
2370: $changeHash->{'portfolioquota'} = $setquota;
2371: }
2372: return $quotachanged;
2373: }
2374:
1.88 raeburn 2375: sub build_roles {
1.89 raeburn 2376: my ($sectionstr,$sections,$role) = @_;
1.88 raeburn 2377: my $num_sections = 0;
2378: if ($sectionstr=~ /,/) {
2379: my @secnums = split/,/,$sectionstr;
1.89 raeburn 2380: if ($role eq 'st') {
2381: $secnums[0] =~ s/\W//g;
2382: $$sections{$secnums[0]} = 1;
2383: $num_sections = 1;
2384: } else {
2385: foreach my $sec (@secnums) {
2386: $sec =~ ~s/\W//g;
1.150 banghart 2387: if (!($sec eq "")) {
1.89 raeburn 2388: if (exists($$sections{$sec})) {
2389: $$sections{$sec} ++;
2390: } else {
2391: $$sections{$sec} = 1;
2392: $num_sections ++;
2393: }
1.88 raeburn 2394: }
2395: }
2396: }
2397: } else {
2398: $sectionstr=~s/\W//g;
2399: unless ($sectionstr eq '') {
2400: $$sections{$sectionstr} = 1;
2401: $num_sections ++;
2402: }
2403: }
1.129 albertel 2404:
1.88 raeburn 2405: return $num_sections;
2406: }
2407:
1.58 www 2408: # ========================================================== Custom Role Editor
2409:
2410: sub custom_role_editor {
1.160 raeburn 2411: my ($r) = @_;
1.101 albertel 2412: my $rolename=$env{'form.rolename'};
1.58 www 2413:
1.59 www 2414: if ($rolename eq 'make new role') {
1.101 albertel 2415: $rolename=$env{'form.newrolename'};
1.59 www 2416: }
2417:
1.63 www 2418: $rolename=~s/[^A-Za-z0-9]//gs;
1.58 www 2419:
1.190 raeburn 2420: if (!$rolename || $env{'form.phase'} eq 'pickrole') {
1.58 www 2421: &print_username_entry_form($r);
2422: return;
2423: }
1.153 banghart 2424: # ------------------------------------------------------- What can be assigned?
2425: my %full=();
2426: my %courselevel=();
2427: my %courselevelcurrent=();
1.61 www 2428: my $syspriv='';
2429: my $dompriv='';
2430: my $coursepriv='';
1.153 banghart 2431: my $body_top;
1.150 banghart 2432: my ($disp_dummy,$disp_roles) = &Apache::lonnet::get('roles',["st"]);
1.59 www 2433: my ($rdummy,$roledef)=
2434: &Apache::lonnet::get('roles',["rolesdef_$rolename"]);
1.60 www 2435: # ------------------------------------------------------- Does this role exist?
1.153 banghart 2436: $body_top .= '<h2>';
1.59 www 2437: if (($rdummy ne 'con_lost') && ($roledef ne '')) {
1.153 banghart 2438: $body_top .= &mt('Existing Role').' "';
1.61 www 2439: # ------------------------------------------------- Get current role privileges
2440: ($syspriv,$dompriv,$coursepriv)=split(/\_/,$roledef);
1.59 www 2441: } else {
1.153 banghart 2442: $body_top .= &mt('New Role').' "';
1.59 www 2443: $roledef='';
2444: }
1.153 banghart 2445: $body_top .= $rolename.'"</h2>';
1.135 raeburn 2446: foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
2447: my ($priv,$restrict)=split(/\&/,$item);
1.150 banghart 2448: if (!$restrict) { $restrict='F'; }
1.60 www 2449: $courselevel{$priv}=$restrict;
1.61 www 2450: if ($coursepriv=~/\:$priv/) {
2451: $courselevelcurrent{$priv}=1;
2452: }
1.60 www 2453: $full{$priv}=1;
2454: }
2455: my %domainlevel=();
1.61 www 2456: my %domainlevelcurrent=();
1.135 raeburn 2457: foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
2458: my ($priv,$restrict)=split(/\&/,$item);
1.150 banghart 2459: if (!$restrict) { $restrict='F'; }
1.60 www 2460: $domainlevel{$priv}=$restrict;
1.61 www 2461: if ($dompriv=~/\:$priv/) {
2462: $domainlevelcurrent{$priv}=1;
2463: }
1.60 www 2464: $full{$priv}=1;
2465: }
1.61 www 2466: my %systemlevel=();
2467: my %systemlevelcurrent=();
1.135 raeburn 2468: foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
2469: my ($priv,$restrict)=split(/\&/,$item);
1.150 banghart 2470: if (!$restrict) { $restrict='F'; }
1.61 www 2471: $systemlevel{$priv}=$restrict;
2472: if ($syspriv=~/\:$priv/) {
2473: $systemlevelcurrent{$priv}=1;
2474: }
2475: $full{$priv}=1;
2476: }
1.160 raeburn 2477: my ($jsback,$elements) = &crumb_utilities();
1.154 banghart 2478: my $button_code = "\n";
1.153 banghart 2479: my $head_script = "\n";
2480: $head_script .= '<script type="text/javascript">'."\n";
1.154 banghart 2481: my @template_roles = ("cc","in","ta","ep","st");
2482: foreach my $role (@template_roles) {
2483: $head_script .= &make_script_template($role);
2484: $button_code .= &make_button_code($role);
2485: }
1.160 raeburn 2486: $head_script .= "\n".$jsback."\n".'</script>'."\n";
1.153 banghart 2487: $r->print(&Apache::loncommon::start_page('Custom Role Editor',$head_script));
1.160 raeburn 2488: &Apache::lonhtmlcommon::add_breadcrumb
1.190 raeburn 2489: ({href=>"javascript:backPage(document.form1,'pickrole','')",
2490: text=>"Pick custom role",
1.160 raeburn 2491: faq=>282,bug=>'Instructor Interface',},
2492: {href=>"javascript:backPage(document.form1,'','')",
2493: text=>"Edit custom role",
2494: faq=>282,bug=>'Instructor Interface',});
1.224 raeburn 2495: $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
2496: 'Course_Editing_Custom_Roles'));
1.160 raeburn 2497:
1.153 banghart 2498: $r->print($body_top);
1.73 sakharuk 2499: my %lt=&Apache::lonlocal::texthash(
2500: 'prv' => "Privilege",
1.131 raeburn 2501: 'crl' => "Course Level",
1.73 sakharuk 2502: 'dml' => "Domain Level",
1.150 banghart 2503: 'ssl' => "System Level");
1.152 banghart 2504: $r->print('Select a Template<br />');
1.154 banghart 2505: $r->print('<form action="">');
2506: $r->print($button_code);
2507: $r->print('</form>');
1.61 www 2508: $r->print(<<ENDCCF);
1.160 raeburn 2509: <form name="form1" method="post">
1.61 www 2510: <input type="hidden" name="phase" value="set_custom_roles" />
2511: <input type="hidden" name="rolename" value="$rolename" />
2512: ENDCCF
1.135 raeburn 2513: $r->print(&Apache::loncommon::start_data_table().
2514: &Apache::loncommon::start_data_table_header_row().
2515: '<th>'.$lt{'prv'}.'</th><th>'.$lt{'crl'}.'</th><th>'.$lt{'dml'}.
2516: '</th><th>'.$lt{'ssl'}.'</th>'.
2517: &Apache::loncommon::end_data_table_header_row());
1.119 raeburn 2518: foreach my $priv (sort keys %full) {
2519: my $privtext = &Apache::lonnet::plaintext($priv);
1.135 raeburn 2520: $r->print(&Apache::loncommon::start_data_table_row().
2521: '<td>'.$privtext.'</td><td>'.
1.150 banghart 2522: ($courselevel{$priv}?'<input type="checkbox" name="'.$priv.'_c" '.
1.119 raeburn 2523: ($courselevelcurrent{$priv}?'checked="1"':'').' />':' ').
1.61 www 2524: '</td><td>'.
1.150 banghart 2525: ($domainlevel{$priv}?'<input type="checkbox" name="'.$priv.'_d" '.
1.119 raeburn 2526: ($domainlevelcurrent{$priv}?'checked="1"':'').' />':' ').
1.61 www 2527: '</td><td>'.
1.150 banghart 2528: ($systemlevel{$priv}?'<input type="checkbox" name="'.$priv.'_s" '.
1.119 raeburn 2529: ($systemlevelcurrent{$priv}?'checked="1"':'').' />':' ').
1.135 raeburn 2530: '</td>'.
2531: &Apache::loncommon::end_data_table_row());
1.60 www 2532: }
1.135 raeburn 2533: $r->print(&Apache::loncommon::end_data_table().
1.190 raeburn 2534: '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'.
1.160 raeburn 2535: '<input type="hidden" name="startrolename" value="'.$env{'form.rolename'}.
1.179 raeburn 2536: '" />'."\n".'<input type="hidden" name="currstate" value="" />'."\n".
1.160 raeburn 2537: '<input type="reset" value="'.&mt("Reset").'" />'."\n".
2538: '<input type="submit" value="'.&mt('Define Role').'" /></form>'.
1.110 albertel 2539: &Apache::loncommon::end_page());
1.61 www 2540: }
1.153 banghart 2541: # --------------------------------------------------------
2542: sub make_script_template {
2543: my ($role) = @_;
2544: my %full_c=();
2545: my %full_d=();
2546: my %full_s=();
2547: my $return_script;
2548: foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
2549: my ($priv,$restrict)=split(/\&/,$item);
2550: $full_c{$priv}=1;
2551: }
2552: foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
2553: my ($priv,$restrict)=split(/\&/,$item);
2554: $full_d{$priv}=1;
2555: }
1.154 banghart 2556: foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
1.153 banghart 2557: my ($priv,$restrict)=split(/\&/,$item);
2558: $full_s{$priv}=1;
2559: }
2560: $return_script .= 'function set_'.$role.'() {'."\n";
2561: my @temp = split(/:/,$Apache::lonnet::pr{$role.':c'});
2562: my %role_c;
1.155 banghart 2563: foreach my $priv (@temp) {
1.153 banghart 2564: my ($priv_item, $dummy) = split(/\&/,$priv);
2565: $role_c{$priv_item} = 1;
2566: }
2567: foreach my $priv_item (keys(%full_c)) {
2568: my ($priv, $dummy) = split(/\&/,$priv_item);
2569: if (exists($role_c{$priv})) {
2570: $return_script .= "document.form1.$priv"."_c.checked = true;\n";
2571: } else {
2572: $return_script .= "document.form1.$priv"."_c.checked = false;\n";
2573: }
2574: }
1.154 banghart 2575: my %role_d;
2576: @temp = split(/:/,$Apache::lonnet::pr{$role.':d'});
2577: foreach my $priv(@temp) {
2578: my ($priv_item, $dummy) = split(/\&/,$priv);
2579: $role_d{$priv_item} = 1;
2580: }
2581: foreach my $priv_item (keys(%full_d)) {
2582: my ($priv, $dummy) = split(/\&/,$priv_item);
2583: if (exists($role_d{$priv})) {
2584: $return_script .= "document.form1.$priv"."_d.checked = true;\n";
2585: } else {
2586: $return_script .= "document.form1.$priv"."_d.checked = false;\n";
2587: }
2588: }
2589: my %role_s;
2590: @temp = split(/:/,$Apache::lonnet::pr{$role.':s'});
2591: foreach my $priv(@temp) {
2592: my ($priv_item, $dummy) = split(/\&/,$priv);
2593: $role_s{$priv_item} = 1;
2594: }
2595: foreach my $priv_item (keys(%full_s)) {
1.153 banghart 2596: my ($priv, $dummy) = split(/\&/,$priv_item);
1.154 banghart 2597: if (exists($role_s{$priv})) {
2598: $return_script .= "document.form1.$priv"."_s.checked = true;\n";
2599: } else {
2600: $return_script .= "document.form1.$priv"."_s.checked = false;\n";
2601: }
1.153 banghart 2602: }
2603: $return_script .= '}'."\n";
1.154 banghart 2604: return ($return_script);
2605: }
2606: # ----------------------------------------------------------
2607: sub make_button_code {
2608: my ($role) = @_;
2609: my $label = &Apache::lonnet::plaintext($role);
2610: my $button_code = '<input type="button" onClick="set_'.$role.'()" value="'.$label.'" />';
2611: return ($button_code);
1.153 banghart 2612: }
1.61 www 2613: # ---------------------------------------------------------- Call to definerole
2614: sub set_custom_role {
1.110 albertel 2615: my ($r) = @_;
1.101 albertel 2616: my $rolename=$env{'form.rolename'};
1.63 www 2617: $rolename=~s/[^A-Za-z0-9]//gs;
1.150 banghart 2618: if (!$rolename) {
1.190 raeburn 2619: &custom_role_editor($r);
1.61 www 2620: return;
2621: }
1.160 raeburn 2622: my ($jsback,$elements) = &crumb_utilities();
2623: my $jscript = '<script type="text/javascript">'.$jsback."\n".'</script>';
2624:
2625: $r->print(&Apache::loncommon::start_page('Save Custom Role'),$jscript);
2626: &Apache::lonhtmlcommon::add_breadcrumb
1.190 raeburn 2627: ({href=>"javascript:backPage(document.customresult,'pickrole','')",
2628: text=>"Pick custom role",
1.160 raeburn 2629: faq=>282,bug=>'Instructor Interface',},
2630: {href=>"javascript:backPage(document.customresult,'selected_custom_edit','')",
2631: text=>"Edit custom role",
2632: faq=>282,bug=>'Instructor Interface',},
2633: {href=>"javascript:backPage(document.customresult,'set_custom_roles','')",
2634: text=>"Result",
2635: faq=>282,bug=>'Instructor Interface',});
1.224 raeburn 2636: $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
2637: 'Course_Editing_Custom_Roles'));
1.160 raeburn 2638:
1.61 www 2639: my ($rdummy,$roledef)=
1.110 albertel 2640: &Apache::lonnet::get('roles',["rolesdef_$rolename"]);
2641:
1.61 www 2642: # ------------------------------------------------------- Does this role exist?
1.188 raeburn 2643: $r->print('<h3>');
1.61 www 2644: if (($rdummy ne 'con_lost') && ($roledef ne '')) {
1.73 sakharuk 2645: $r->print(&mt('Existing Role').' "');
1.61 www 2646: } else {
1.73 sakharuk 2647: $r->print(&mt('New Role').' "');
1.61 www 2648: $roledef='';
2649: }
1.188 raeburn 2650: $r->print($rolename.'"</h3>');
1.61 www 2651: # ------------------------------------------------------- What can be assigned?
2652: my $sysrole='';
2653: my $domrole='';
2654: my $courole='';
2655:
1.135 raeburn 2656: foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
2657: my ($priv,$restrict)=split(/\&/,$item);
1.150 banghart 2658: if (!$restrict) { $restrict=''; }
2659: if ($env{'form.'.$priv.'_c'}) {
1.135 raeburn 2660: $courole.=':'.$item;
1.61 www 2661: }
2662: }
2663:
1.135 raeburn 2664: foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
2665: my ($priv,$restrict)=split(/\&/,$item);
1.150 banghart 2666: if (!$restrict) { $restrict=''; }
2667: if ($env{'form.'.$priv.'_d'}) {
1.135 raeburn 2668: $domrole.=':'.$item;
1.61 www 2669: }
2670: }
2671:
1.135 raeburn 2672: foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
2673: my ($priv,$restrict)=split(/\&/,$item);
1.150 banghart 2674: if (!$restrict) { $restrict=''; }
2675: if ($env{'form.'.$priv.'_s'}) {
1.135 raeburn 2676: $sysrole.=':'.$item;
1.61 www 2677: }
2678: }
1.63 www 2679: $r->print('<br />Defining Role: '.
1.61 www 2680: &Apache::lonnet::definerole($rolename,$sysrole,$domrole,$courole));
1.101 albertel 2681: if ($env{'request.course.id'}) {
2682: my $url='/'.$env{'request.course.id'};
1.63 www 2683: $url=~s/\_/\//g;
1.73 sakharuk 2684: $r->print('<br />'.&mt('Assigning Role to Self').': '.
1.101 albertel 2685: &Apache::lonnet::assigncustomrole($env{'user.domain'},
2686: $env{'user.name'},
1.63 www 2687: $url,
1.101 albertel 2688: $env{'user.domain'},
2689: $env{'user.name'},
1.63 www 2690: $rolename));
2691: }
1.190 raeburn 2692: $r->print('<p><a href="javascript:backPage(document.customresult,'."'pickrole'".')">'.&mt('Create or edit another custom role').'</a></p><form name="customresult" method="post">');
1.160 raeburn 2693: $r->print(&Apache::lonhtmlcommon::echo_form_input([]).'</form>');
1.110 albertel 2694: $r->print(&Apache::loncommon::end_page());
1.58 www 2695: }
2696:
1.2 www 2697: # ================================================================ Main Handler
2698: sub handler {
2699: my $r = shift;
2700: if ($r->header_only) {
1.68 www 2701: &Apache::loncommon::content_type($r,'text/html');
1.2 www 2702: $r->send_http_header;
2703: return OK;
2704: }
1.190 raeburn 2705: my $context;
2706: if ($env{'request.course.id'}) {
2707: $context = 'course';
2708: } elsif ($env{'request.role'} =~ /^au\./) {
1.206 raeburn 2709: $context = 'author';
1.190 raeburn 2710: } else {
2711: $context = 'domain';
2712: }
2713: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.202 raeburn 2714: ['action','state','callingform','roletype','showrole','bulkaction']);
1.190 raeburn 2715: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.202 raeburn 2716: if ($env{'form.action'} ne 'dateselect') {
2717: &Apache::lonhtmlcommon::add_breadcrumb
2718: ({href=>"/adm/createuser",
2719: text=>"User Management"});
2720: }
1.209 raeburn 2721: my ($permission,$allowed) =
2722: &Apache::lonuserutils::get_permission($context);
1.190 raeburn 2723: if (!$allowed) {
2724: $env{'user.error.msg'}=
2725: "/adm/createuser:cst:0:0:Cannot create/modify user data ".
2726: "or view user status.";
2727: return HTTP_NOT_ACCEPTABLE;
2728: }
2729:
2730: &Apache::loncommon::content_type($r,'text/html');
2731: $r->send_http_header;
2732:
2733: # Main switch on form.action and form.state, as appropriate
2734: if (! exists($env{'form.action'})) {
2735: $r->print(&header());
2736: $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management'));
1.208 raeburn 2737: $r->print(&print_main_menu($permission,$context));
1.190 raeburn 2738: $r->print(&Apache::loncommon::end_page());
2739: } elsif ($env{'form.action'} eq 'upload' && $permission->{'cusr'}) {
2740: $r->print(&header());
2741: &Apache::lonhtmlcommon::add_breadcrumb
2742: ({href=>'/adm/createuser?action=upload&state=',
2743: text=>"Upload Users List"});
2744: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Upload Users List',
1.224 raeburn 2745: 'Course_Create_Class_List'));
1.190 raeburn 2746: $r->print('<form name="studentform" method="post" '.
2747: 'enctype="multipart/form-data" '.
2748: ' action="/adm/createuser">'."\n");
2749: if (! exists($env{'form.state'})) {
2750: &Apache::lonuserutils::print_first_users_upload_form($r,$context);
2751: } elsif ($env{'form.state'} eq 'got_file') {
1.221 raeburn 2752: &Apache::lonuserutils::print_upload_manager_form($r,$context,
2753: $permission);
1.190 raeburn 2754: } elsif ($env{'form.state'} eq 'enrolling') {
2755: if ($env{'form.datatoken'}) {
1.221 raeburn 2756: &Apache::lonuserutils::upfile_drop_add($r,$context,$permission);
1.190 raeburn 2757: }
2758: } else {
2759: &Apache::lonuserutils::print_first_users_upload_form($r,$context);
2760: }
2761: $r->print('</form>'.&Apache::loncommon::end_page());
1.213 raeburn 2762: } elsif ((($env{'form.action'} eq 'singleuser') || ($env{'form.action'}
2763: eq 'singlestudent')) && ($permission->{'cusr'})) {
1.190 raeburn 2764: my $phase = $env{'form.phase'};
2765: my @search = ('srchterm','srchby','srchin','srchtype','srchdomain');
1.192 albertel 2766: &Apache::loncreateuser::restore_prev_selections();
2767: my $srch;
2768: foreach my $item (@search) {
2769: $srch->{$item} = $env{'form.'.$item};
2770: }
1.190 raeburn 2771:
1.207 raeburn 2772: if (($phase eq 'get_user_info') || ($phase eq 'userpicked') ||
2773: ($phase eq 'createnewuser')) {
2774: if ($env{'form.phase'} eq 'createnewuser') {
2775: my $response;
2776: if ($env{'form.srchterm'} !~ /^$match_username$/) {
2777: my $response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @');
1.221 raeburn 2778: $env{'form.phase'} = '';
1.207 raeburn 2779: &print_username_entry_form($r,$context,$response,$srch);
2780: } else {
2781: my $ccuname =&LONCAPA::clean_username($srch->{'srchterm'});
2782: my $ccdomain=&LONCAPA::clean_domain($srch->{'srchdomain'});
2783: &print_user_modification_page($r,$ccuname,$ccdomain,
1.221 raeburn 2784: $srch,$response,$context,
2785: $permission);
1.207 raeburn 2786: }
2787: } elsif ($env{'form.phase'} eq 'get_user_info') {
1.190 raeburn 2788: my ($currstate,$response,$forcenewuser,$results) =
1.221 raeburn 2789: &user_search_result($context,$srch);
1.190 raeburn 2790: if ($env{'form.currstate'} eq 'modify') {
2791: $currstate = $env{'form.currstate'};
2792: }
2793: if ($currstate eq 'select') {
1.214 raeburn 2794: my $operation;
2795: if ($env{'form.action'} eq 'singleuser') {
2796: $operation = 'createuser';
2797: } elsif ($env{'form.action'} eq 'singlestudent') {
2798: $operation = 'enrollstudent';
2799: }
1.190 raeburn 2800: &print_user_selection_page($r,$response,$srch,$results,
1.214 raeburn 2801: $operation,\@search,$context);
1.190 raeburn 2802: } elsif ($currstate eq 'modify') {
2803: my ($ccuname,$ccdomain);
2804: if (($srch->{'srchby'} eq 'uname') &&
2805: ($srch->{'srchtype'} eq 'exact')) {
2806: $ccuname = $srch->{'srchterm'};
2807: $ccdomain= $srch->{'srchdomain'};
2808: } else {
2809: my @matchedunames = keys(%{$results});
2810: ($ccuname,$ccdomain) = split(/:/,$matchedunames[0]);
2811: }
2812: $ccuname =&LONCAPA::clean_username($ccuname);
2813: $ccdomain=&LONCAPA::clean_domain($ccdomain);
2814: if ($env{'form.forcenewuser'}) {
2815: $response = '';
2816: }
2817: &print_user_modification_page($r,$ccuname,$ccdomain,
1.221 raeburn 2818: $srch,$response,$context,
2819: $permission);
1.190 raeburn 2820: } elsif ($currstate eq 'query') {
2821: &print_user_query_page($r,'createuser');
2822: } else {
1.207 raeburn 2823: &print_username_entry_form($r,$context,$response,$srch,
1.190 raeburn 2824: $forcenewuser);
2825: }
2826: } elsif ($env{'form.phase'} eq 'userpicked') {
2827: my $ccuname = &LONCAPA::clean_username($env{'form.seluname'});
2828: my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'});
1.196 raeburn 2829: &print_user_modification_page($r,$ccuname,$ccdomain,$srch,'',
1.221 raeburn 2830: $context,$permission);
1.190 raeburn 2831: }
2832: } elsif ($env{'form.phase'} eq 'update_user_data') {
1.206 raeburn 2833: &update_user_data($r,$context);
1.190 raeburn 2834: } else {
1.207 raeburn 2835: &print_username_entry_form($r,$context,undef,$srch);
1.190 raeburn 2836: }
2837: } elsif ($env{'form.action'} eq 'custom' && $permission->{'custom'}) {
2838: if ($env{'form.phase'} eq 'set_custom_roles') {
2839: &set_custom_role($r);
2840: } else {
2841: &custom_role_editor($r);
2842: }
1.207 raeburn 2843: } elsif (($env{'form.action'} eq 'listusers') &&
2844: ($permission->{'view'} || $permission->{'cusr'})) {
1.202 raeburn 2845: if ($env{'form.phase'} eq 'bulkchange') {
2846: &Apache::lonhtmlcommon::add_breadcrumb
1.221 raeburn 2847: ({href=>'/adm/createuser?action=listusers',
2848: text=>"List Users"},
2849: {href=>"/adm/createuser",
2850: text=>"Result"});
1.202 raeburn 2851: my $setting = $env{'form.roletype'};
2852: my $choice = $env{'form.bulkaction'};
2853: $r->print(&header());
1.221 raeburn 2854: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Update Users",
1.224 raeburn 2855: 'Course_View_Class_List'));
1.202 raeburn 2856: if ($permission->{'cusr'}) {
2857: &Apache::lonuserutils::update_user_list($r,$context,$setting,$choice);
1.221 raeburn 2858: $r->print(&Apache::loncommon::end_page());
2859: } else {
2860: $r->print(&mt('You are not authorized to make bulk changes to user roles'));
1.223 raeburn 2861: $r->print('<p><a href="/adm/createuser?action=listusers">'.&mt('Display User Lists').'</a>');
1.221 raeburn 2862: $r->print(&Apache::loncommon::end_page());
1.202 raeburn 2863: }
2864: } else {
2865: &Apache::lonhtmlcommon::add_breadcrumb
2866: ({href=>'/adm/createuser?action=listusers',
2867: text=>"List Users"});
2868: my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles);
2869: my $formname = 'studentform';
2870: if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
2871: ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles) =
2872: &Apache::lonuserutils::courses_selector($env{'request.role.domain'},
2873: $formname);
2874: $jscript .= &verify_user_display();
2875: my $js = &add_script($jscript).$cb_jscript;
2876: my $loadcode =
2877: &Apache::lonuserutils::course_selector_loadcode($formname);
2878: if ($loadcode ne '') {
2879: $r->print(&header($js,{'onload' => $loadcode,}));
2880: } else {
2881: $r->print(&header($js));
2882: }
1.191 raeburn 2883: } else {
1.202 raeburn 2884: $r->print(&header(&add_script(&verify_user_display())));
1.191 raeburn 2885: }
1.202 raeburn 2886: $r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users",
1.224 raeburn 2887: 'Course_View_Class_List'));
1.202 raeburn 2888: &Apache::lonuserutils::print_userlist($r,undef,$permission,$context,
2889: $formname,$totcodes,$codetitles,$idlist,$idlist_titles);
2890: $r->print(&Apache::loncommon::end_page());
1.191 raeburn 2891: }
1.213 raeburn 2892: } elsif ($env{'form.action'} eq 'drop' && $permission->{'cusr'}) {
2893: $r->print(&header());
2894: &Apache::lonhtmlcommon::add_breadcrumb
2895: ({href=>'/adm/createuser?action=drop',
2896: text=>"Drop Students"});
2897: if (!exists($env{'form.state'})) {
2898: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Drop Students',
2899: 'Course_Drop_Student'));
2900:
2901: &Apache::lonuserutils::print_drop_menu($r,$context,$permission);
2902: } elsif ($env{'form.state'} eq 'done') {
2903: &Apache::lonhtmlcommon::add_breadcrumb
2904: ({href=>'/adm/createuser?action=drop',
2905: text=>"Result"});
2906: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Drop Students',
2907: 'Course_Drop_Student'));
2908: &Apache::lonuserutils::update_user_list($r,$context,undef,
2909: $env{'form.action'});
2910: }
2911: $r->print(&Apache::loncommon::end_page());
1.202 raeburn 2912: } elsif ($env{'form.action'} eq 'dateselect') {
2913: if ($permission->{'cusr'}) {
2914: $r->print(&header(undef,undef,{'no_nav_bar' => 1}).
1.221 raeburn 2915: &Apache::lonuserutils::date_section_selector($context,
2916: $permission).
1.202 raeburn 2917: &Apache::loncommon::end_page());
2918: } else {
2919: $r->print(&header().
2920: '<span class="LC_error">'.&mt('You do not have permission to modify dates or sections for users').'</span>'.
2921: &Apache::loncommon::end_page());
2922: }
1.190 raeburn 2923: } else {
2924: $r->print(&header());
1.202 raeburn 2925: $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management'));
1.207 raeburn 2926: $r->print(&print_main_menu($permission,$context));
1.190 raeburn 2927: $r->print(&Apache::loncommon::end_page());
2928: }
2929: return OK;
2930: }
2931:
2932: sub header {
1.202 raeburn 2933: my ($jscript,$loaditems,$args) = @_;
1.190 raeburn 2934: my $start_page;
2935: if (ref($loaditems) eq 'HASH') {
1.202 raeburn 2936: $start_page=&Apache::loncommon::start_page('User Management',$jscript,{'add_entries' => $loaditems});
1.190 raeburn 2937: } else {
1.202 raeburn 2938: $start_page=&Apache::loncommon::start_page('User Management',$jscript,$args);
1.190 raeburn 2939: }
2940: return $start_page;
2941: }
1.2 www 2942:
1.191 raeburn 2943: sub add_script {
2944: my ($js) = @_;
2945: return '<script type="text/javascript">'."\n".$js."\n".'</script>';
2946: }
2947:
1.202 raeburn 2948: sub verify_user_display {
2949: my $output = <<"END";
2950:
2951: function display_update() {
2952: document.studentform.action.value = 'listusers';
2953: document.studentform.phase.value = 'display';
2954: document.studentform.submit();
2955: }
2956:
2957: END
2958: return $output;
2959:
2960: }
2961:
1.190 raeburn 2962: ###############################################################
2963: ###############################################################
2964: # Menu Phase One
2965: sub print_main_menu {
1.208 raeburn 2966: my ($permission,$context) = @_;
2967: my %links = (
2968: domain => {
2969: upload => 'Upload a File of Users',
1.221 raeburn 2970: singleuser => 'Add/Modify a Single User',
1.208 raeburn 2971: listusers => 'Manage Multiple Users',
2972: },
2973: author => {
2974: upload => 'Upload a File of Co-authors',
1.221 raeburn 2975: singleuser => 'Add/Modify a Single Co-author',
1.208 raeburn 2976: listusers => 'Display Co-authors and Manage Multiple Users',
2977: },
2978: course => {
2979: upload => 'Upload a File of Course Users',
1.221 raeburn 2980: singleuser => 'Add/Modify a Single Course User',
1.208 raeburn 2981: listusers => 'Display Class Lists and Manage Multiple Users',
2982: },
2983: );
1.190 raeburn 2984: my @menu =
2985: (
1.208 raeburn 2986: { text => $links{$context}{'upload'},
1.224 raeburn 2987: help => 'Course_Create_Class_List',
1.190 raeburn 2988: action => 'upload',
2989: permission => $permission->{'cusr'},
2990: },
1.208 raeburn 2991: { text => $links{$context}{'singleuser'},
1.224 raeburn 2992: help => 'Course_Change_Privileges',
1.190 raeburn 2993: action => 'singleuser',
2994: permission => $permission->{'cusr'},
2995: },
1.208 raeburn 2996: { text => $links{$context}{'listusers'},
1.224 raeburn 2997: help => 'Course_View_Class_List',
1.191 raeburn 2998: action => 'listusers',
1.208 raeburn 2999: permission => ($permission->{'view'} || $permission->{'cusr'}),
1.190 raeburn 3000: },
3001: );
1.208 raeburn 3002: if ($context eq 'domain' || $context eq 'course') {
3003: my $customlink = { text => 'Edit Custom Roles',
1.224 raeburn 3004: help => 'Course_Editing_Custom_Roles',
1.208 raeburn 3005: action => 'custom',
3006: permission => $permission->{'custom'},
3007: };
3008: push(@menu,$customlink);
3009: }
3010: if ($context eq 'course') {
1.213 raeburn 3011: my ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity();
3012: my @courselinks =
1.208 raeburn 3013: (
1.213 raeburn 3014: { text => 'Enroll a Single Student',
1.224 raeburn 3015: help => 'Course_Add_Student',
1.213 raeburn 3016: action => 'singlestudent',
3017: permission => $permission->{'cusr'},
3018: },
3019: { text => 'Drop Students',
3020: help => 'Course_Drop_Student',
3021: action => 'drop',
3022: permission => $permission->{'cusr'},
3023: });
3024: if (!exists($permission->{'cusr_section'})) {
3025: push(@courselinks,
3026: { text => 'Automated Student Enrollment Manager',
1.228 ! raeburn 3027: help => 'Course_Automated_Enrollment',
1.208 raeburn 3028: permission => (&Apache::lonnet::auto_run($cnum,$cdom)
3029: && $permission->{'cusr'}),
3030: url => '/adm/populate',
1.213 raeburn 3031: });
3032: }
3033: push(@courselinks,
1.208 raeburn 3034: { text => 'Manage Course Groups',
3035: help => 'Course_Manage_Group',
3036: permission => $permission->{'grp_manage'},
3037: url => '/adm/coursegroups?refpage=cusr',
1.213 raeburn 3038: });
1.208 raeburn 3039: push(@menu,@courselinks);
3040: }
1.190 raeburn 3041: my $menu_html = '';
3042: foreach my $menu_item (@menu) {
3043: next if (! $menu_item->{'permission'});
3044: $menu_html.='<p>';
3045: $menu_html.='<font size="+1">';
3046: if (exists($menu_item->{'url'})) {
3047: $menu_html.=qq{<a href="$menu_item->{'url'}">};
3048: } else {
3049: $menu_html.=
3050: qq{<a href="/adm/createuser?action=$menu_item->{'action'}">};
3051: }
3052: $menu_html.= &mt($menu_item->{'text'}).'</a></font>';
3053: if (exists($menu_item->{'help'})) {
3054: $menu_html.=
3055: &Apache::loncommon::help_open_topic($menu_item->{'help'});
3056: }
3057: $menu_html.='</p>';
3058: }
3059: return $menu_html;
3060: }
3061:
1.189 albertel 3062: sub restore_prev_selections {
3063: my %saveable_parameters = ('srchby' => 'scalar',
3064: 'srchin' => 'scalar',
3065: 'srchtype' => 'scalar',
3066: );
3067: &Apache::loncommon::store_settings('user','user_picker',
3068: \%saveable_parameters);
3069: &Apache::loncommon::restore_settings('user','user_picker',
3070: \%saveable_parameters);
3071: }
3072:
1.27 matthew 3073: #-------------------------------------------------- functions for &phase_two
1.160 raeburn 3074: sub user_search_result {
1.221 raeburn 3075: my ($context,$srch) = @_;
1.160 raeburn 3076: my %allhomes;
3077: my %inst_matches;
3078: my %srch_results;
1.181 raeburn 3079: my ($response,$currstate,$forcenewuser,$dirsrchres);
1.183 raeburn 3080: $srch->{'srchterm'} =~ s/\s+/ /g;
1.176 raeburn 3081: if ($srch->{'srchby'} !~ /^(uname|lastname|lastfirst)$/) {
1.160 raeburn 3082: $response = &mt('Invalid search.');
3083: }
3084: if ($srch->{'srchin'} !~ /^(crs|dom|alc|instd)$/) {
3085: $response = &mt('Invalid search.');
3086: }
1.177 raeburn 3087: if ($srch->{'srchtype'} !~ /^(exact|contains|begins)$/) {
1.160 raeburn 3088: $response = &mt('Invalid search.');
3089: }
3090: if ($srch->{'srchterm'} eq '') {
3091: $response = &mt('You must enter a search term.');
3092: }
1.183 raeburn 3093: if ($srch->{'srchterm'} =~ /^\s+$/) {
3094: $response = &mt('Your search term must contain more than just spaces.');
3095: }
1.160 raeburn 3096: if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'instd')) {
3097: if (($srch->{'srchdomain'} eq '') ||
1.163 albertel 3098: ! (&Apache::lonnet::domain($srch->{'srchdomain'}))) {
1.160 raeburn 3099: $response = &mt('You must specify a valid domain when searching in a domain or institutional directory.')
3100: }
3101: }
3102: if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'crs') ||
3103: ($srch->{'srchin'} eq 'alc')) {
1.176 raeburn 3104: if ($srch->{'srchby'} eq 'uname') {
3105: if ($srch->{'srchterm'} !~ /^$match_username$/) {
3106: $response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @');
3107: }
1.160 raeburn 3108: }
3109: }
1.180 raeburn 3110: if ($response ne '') {
3111: $response = '<span class="LC_warning">'.$response.'</span>';
3112: }
1.160 raeburn 3113: if ($srch->{'srchin'} eq 'instd') {
3114: my $instd_chk = &directorysrch_check($srch);
3115: if ($instd_chk ne 'ok') {
1.180 raeburn 3116: $response = '<span class="LC_warning">'.$instd_chk.'</span>'.
3117: '<br />'.&mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').'<br /><br />';
1.160 raeburn 3118: }
3119: }
3120: if ($response ne '') {
1.180 raeburn 3121: return ($currstate,$response);
1.160 raeburn 3122: }
3123: if ($srch->{'srchby'} eq 'uname') {
3124: if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'crs')) {
3125: if ($env{'form.forcenew'}) {
3126: if ($srch->{'srchdomain'} ne $env{'request.role.domain'}) {
3127: my $uhome=&Apache::lonnet::homeserver($srch->{'srchterm'},$srch->{'srchdomain'});
3128: if ($uhome eq 'no_host') {
3129: my $domdesc = &Apache::lonnet::domain($env{'request.role.domain'},'description');
1.180 raeburn 3130: my $showdom = &display_domain_info($env{'request.role.domain'});
3131: $response = &mt('New users can only be created in the domain to which your current role belongs - [_1].',$showdom);
1.160 raeburn 3132: } else {
1.179 raeburn 3133: $currstate = 'modify';
1.160 raeburn 3134: }
3135: } else {
1.179 raeburn 3136: $currstate = 'modify';
1.160 raeburn 3137: }
3138: } else {
3139: if ($srch->{'srchin'} eq 'dom') {
1.162 raeburn 3140: if ($srch->{'srchtype'} eq 'exact') {
3141: my $uhome=&Apache::lonnet::homeserver($srch->{'srchterm'},$srch->{'srchdomain'});
3142: if ($uhome eq 'no_host') {
1.179 raeburn 3143: ($currstate,$response,$forcenewuser) =
1.221 raeburn 3144: &build_search_response($context,$srch,%srch_results);
1.162 raeburn 3145: } else {
1.179 raeburn 3146: $currstate = 'modify';
1.162 raeburn 3147: }
3148: } else {
3149: %srch_results = &Apache::lonnet::usersearch($srch);
1.179 raeburn 3150: ($currstate,$response,$forcenewuser) =
1.221 raeburn 3151: &build_search_response($context,$srch,%srch_results);
1.160 raeburn 3152: }
3153: } else {
1.167 albertel 3154: my $courseusers = &get_courseusers();
1.162 raeburn 3155: if ($srch->{'srchtype'} eq 'exact') {
1.167 albertel 3156: if (exists($courseusers->{$srch->{'srchterm'}.':'.$srch->{'srchdomain'}})) {
1.179 raeburn 3157: $currstate = 'modify';
1.162 raeburn 3158: } else {
1.179 raeburn 3159: ($currstate,$response,$forcenewuser) =
1.221 raeburn 3160: &build_search_response($context,$srch,%srch_results);
1.162 raeburn 3161: }
1.160 raeburn 3162: } else {
1.167 albertel 3163: foreach my $user (keys(%$courseusers)) {
1.162 raeburn 3164: my ($cuname,$cudomain) = split(/:/,$user);
3165: if ($cudomain eq $srch->{'srchdomain'}) {
1.177 raeburn 3166: my $matched = 0;
3167: if ($srch->{'srchtype'} eq 'begins') {
3168: if ($cuname =~ /^\Q$srch->{'srchterm'}\E/i) {
3169: $matched = 1;
3170: }
3171: } else {
3172: if ($cuname =~ /\Q$srch->{'srchterm'}\E/i) {
3173: $matched = 1;
3174: }
3175: }
3176: if ($matched) {
1.167 albertel 3177: $srch_results{$user} =
3178: {&Apache::lonnet::get('environment',
3179: ['firstname',
3180: 'lastname',
1.194 albertel 3181: 'permanentemail'],
3182: $cudomain,$cuname)};
1.162 raeburn 3183: }
3184: }
3185: }
1.179 raeburn 3186: ($currstate,$response,$forcenewuser) =
1.221 raeburn 3187: &build_search_response($context,$srch,%srch_results);
1.160 raeburn 3188: }
3189: }
3190: }
3191: } elsif ($srch->{'srchin'} eq 'alc') {
1.179 raeburn 3192: $currstate = 'query';
1.160 raeburn 3193: } elsif ($srch->{'srchin'} eq 'instd') {
1.181 raeburn 3194: ($dirsrchres,%srch_results) = &Apache::lonnet::inst_directory_query($srch);
3195: if ($dirsrchres eq 'ok') {
3196: ($currstate,$response,$forcenewuser) =
1.221 raeburn 3197: &build_search_response($context,$srch,%srch_results);
1.181 raeburn 3198: } else {
3199: my $showdom = &display_domain_info($srch->{'srchdomain'});
3200: $response = '<span class="LC_warning">'.
3201: &mt('Institutional directory search is not available in domain: [_1]',$showdom).
3202: '</span><br />'.
3203: &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').
3204: '<br /><br />';
3205: }
1.160 raeburn 3206: }
3207: } else {
3208: if ($srch->{'srchin'} eq 'dom') {
3209: %srch_results = &Apache::lonnet::usersearch($srch);
1.179 raeburn 3210: ($currstate,$response,$forcenewuser) =
1.221 raeburn 3211: &build_search_response($context,$srch,%srch_results);
1.160 raeburn 3212: } elsif ($srch->{'srchin'} eq 'crs') {
1.167 albertel 3213: my $courseusers = &get_courseusers();
3214: foreach my $user (keys(%$courseusers)) {
1.160 raeburn 3215: my ($uname,$udom) = split(/:/,$user);
3216: my %names = &Apache::loncommon::getnames($uname,$udom);
3217: my %emails = &Apache::loncommon::getemails($uname,$udom);
3218: if ($srch->{'srchby'} eq 'lastname') {
3219: if ((($srch->{'srchtype'} eq 'exact') &&
3220: ($names{'lastname'} eq $srch->{'srchterm'})) ||
1.177 raeburn 3221: (($srch->{'srchtype'} eq 'begins') &&
3222: ($names{'lastname'} =~ /^\Q$srch->{'srchterm'}\E/i)) ||
1.160 raeburn 3223: (($srch->{'srchtype'} eq 'contains') &&
3224: ($names{'lastname'} =~ /\Q$srch->{'srchterm'}\E/i))) {
3225: $srch_results{$user} = {firstname => $names{'firstname'},
3226: lastname => $names{'lastname'},
3227: permanentemail => $emails{'permanentemail'},
3228: };
3229: }
3230: } elsif ($srch->{'srchby'} eq 'lastfirst') {
3231: my ($srchlast,$srchfirst) = split(/,/,$srch->{'srchterm'});
1.177 raeburn 3232: $srchlast =~ s/\s+$//;
3233: $srchfirst =~ s/^\s+//;
1.160 raeburn 3234: if ($srch->{'srchtype'} eq 'exact') {
3235: if (($names{'lastname'} eq $srchlast) &&
3236: ($names{'firstname'} eq $srchfirst)) {
3237: $srch_results{$user} = {firstname => $names{'firstname'},
3238: lastname => $names{'lastname'},
3239: permanentemail => $emails{'permanentemail'},
3240:
3241: };
3242: }
1.177 raeburn 3243: } elsif ($srch->{'srchtype'} eq 'begins') {
3244: if (($names{'lastname'} =~ /^\Q$srchlast\E/i) &&
3245: ($names{'firstname'} =~ /^\Q$srchfirst\E/i)) {
3246: $srch_results{$user} = {firstname => $names{'firstname'},
3247: lastname => $names{'lastname'},
3248: permanentemail => $emails{'permanentemail'},
3249: };
3250: }
3251: } else {
1.160 raeburn 3252: if (($names{'lastname'} =~ /\Q$srchlast\E/i) &&
3253: ($names{'firstname'} =~ /\Q$srchfirst\E/i)) {
3254: $srch_results{$user} = {firstname => $names{'firstname'},
3255: lastname => $names{'lastname'},
3256: permanentemail => $emails{'permanentemail'},
3257: };
3258: }
3259: }
3260: }
3261: }
1.179 raeburn 3262: ($currstate,$response,$forcenewuser) =
1.221 raeburn 3263: &build_search_response($context,$srch,%srch_results);
1.160 raeburn 3264: } elsif ($srch->{'srchin'} eq 'alc') {
1.179 raeburn 3265: $currstate = 'query';
1.160 raeburn 3266: } elsif ($srch->{'srchin'} eq 'instd') {
1.181 raeburn 3267: ($dirsrchres,%srch_results) = &Apache::lonnet::inst_directory_query($srch);
3268: if ($dirsrchres eq 'ok') {
3269: ($currstate,$response,$forcenewuser) =
1.221 raeburn 3270: &build_search_response($context,$srch,%srch_results);
1.181 raeburn 3271: } else {
3272: my $showdom = &display_domain_info($srch->{'srchdomain'}); $response = '<span class="LC_warning">'.
3273: &mt('Institutional directory search is not available in domain: [_1]',$showdom).
3274: '</span><br />'.
3275: &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').
3276: '<br /><br />';
3277: }
1.160 raeburn 3278: }
3279: }
1.179 raeburn 3280: return ($currstate,$response,$forcenewuser,\%srch_results);
1.160 raeburn 3281: }
3282:
3283: sub directorysrch_check {
3284: my ($srch) = @_;
3285: my $can_search = 0;
3286: my $response;
3287: my %dom_inst_srch = &Apache::lonnet::get_dom('configuration',
3288: ['directorysrch'],$srch->{'srchdomain'});
1.180 raeburn 3289: my $showdom = &display_domain_info($srch->{'srchdomain'});
1.160 raeburn 3290: if (ref($dom_inst_srch{'directorysrch'}) eq 'HASH') {
3291: if (!$dom_inst_srch{'directorysrch'}{'available'}) {
1.180 raeburn 3292: return &mt('Institutional directory search is not available in domain: [_1]',$showdom);
1.160 raeburn 3293: }
3294: if ($dom_inst_srch{'directorysrch'}{'localonly'}) {
3295: if ($env{'request.role.domain'} ne $srch->{'srchdomain'}) {
1.180 raeburn 3296: return &mt('Institutional directory search in domain: [_1] is only allowed for users with a current role in the domain.',$showdom);
1.160 raeburn 3297: }
3298: my @usertypes = split(/:/,$env{'environment.inststatus'});
3299: if (!@usertypes) {
3300: push(@usertypes,'default');
3301: }
3302: if (ref($dom_inst_srch{'directorysrch'}{'cansearch'}) eq 'ARRAY') {
3303: foreach my $type (@usertypes) {
3304: if (grep(/^\Q$type\E$/,@{$dom_inst_srch{'directorysrch'}{'cansearch'}})) {
3305: $can_search = 1;
3306: last;
3307: }
3308: }
3309: }
3310: if (!$can_search) {
3311: my ($insttypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($srch->{'srchdomain'});
3312: my @longtypes;
3313: foreach my $item (@usertypes) {
3314: push (@longtypes,$insttypes->{$item});
3315: }
3316: my $insttype_str = join(', ',@longtypes);
1.180 raeburn 3317: return &mt('Institutional directory search in domain: [_1] is not available to your user type: ',$showdom).$insttype_str;
1.160 raeburn 3318: }
3319: } else {
3320: $can_search = 1;
3321: }
3322: } else {
1.180 raeburn 3323: return &mt('Institutional directory search has not been configured for domain: [_1]',$showdom);
1.160 raeburn 3324: }
3325: my %longtext = &Apache::lonlocal::texthash (
1.167 albertel 3326: uname => 'username',
1.160 raeburn 3327: lastfirst => 'last name, first name',
1.167 albertel 3328: lastname => 'last name',
1.172 raeburn 3329: contains => 'contains',
1.178 raeburn 3330: exact => 'as exact match to',
3331: begins => 'begins with',
1.160 raeburn 3332: );
3333: if ($can_search) {
3334: if (ref($dom_inst_srch{'directorysrch'}{'searchby'}) eq 'ARRAY') {
3335: if (!grep(/^\Q$srch->{'srchby'}\E$/,@{$dom_inst_srch{'directorysrch'}{'searchby'}})) {
1.180 raeburn 3336: return &mt('Institutional directory search in domain: [_1] is not available for searching by "[_2]"',$showdom,$longtext{$srch->{'srchby'}});
1.160 raeburn 3337: }
3338: } else {
1.180 raeburn 3339: return &mt('Institutional directory search in domain: [_1] is not available.', $showdom);
1.160 raeburn 3340: }
3341: }
3342: if ($can_search) {
1.178 raeburn 3343: if (ref($dom_inst_srch{'directorysrch'}{'searchtypes'}) eq 'ARRAY') {
3344: if (grep(/^\Q$srch->{'srchtype'}\E/,@{$dom_inst_srch{'directorysrch'}{'searchtypes'}})) {
3345: return 'ok';
3346: } else {
1.180 raeburn 3347: return &mt('Institutional directory search in domain [_1] is not available for the requested search type: "[_2]"',$showdom,$longtext{$srch->{'srchtype'}});
1.178 raeburn 3348: }
3349: } else {
3350: if ((($dom_inst_srch{'directorysrch'}{'searchtypes'} eq 'specify') &&
3351: ($srch->{'srchtype'} eq 'exact' || $srch->{'srchtype'} eq 'contains')) ||
3352: ($dom_inst_srch{'directorysrch'}{'searchtypes'} eq $srch->{'srchtype'})) {
3353: return 'ok';
3354: } else {
1.180 raeburn 3355: return &mt('Institutional directory search in domain [_1] is not available for the requested search type: "[_2]"',$showdom,$longtext{$srch->{'srchtype'}});
1.178 raeburn 3356: }
1.160 raeburn 3357: }
3358: }
3359: }
3360:
3361: sub get_courseusers {
3362: my %advhash;
1.167 albertel 3363: my $classlist = &Apache::loncoursedata::get_classlist();
1.160 raeburn 3364: my %coursepersonnel=&Apache::lonnet::get_course_adv_roles();
3365: foreach my $role (sort(keys(%coursepersonnel))) {
3366: foreach my $user (split(/\,/,$coursepersonnel{$role})) {
1.167 albertel 3367: if (!exists($classlist->{$user})) {
3368: $classlist->{$user} = [];
3369: }
1.160 raeburn 3370: }
3371: }
1.167 albertel 3372: return $classlist;
1.160 raeburn 3373: }
3374:
3375: sub build_search_response {
1.221 raeburn 3376: my ($context,$srch,%srch_results) = @_;
1.179 raeburn 3377: my ($currstate,$response,$forcenewuser);
1.160 raeburn 3378: my %names = (
3379: 'uname' => 'username',
3380: 'lastname' => 'last name',
3381: 'lastfirst' => 'last name, first name',
3382: 'crs' => 'this course',
1.180 raeburn 3383: 'dom' => 'LON-CAPA domain: ',
3384: 'instd' => 'the institutional directory for domain: ',
1.160 raeburn 3385: );
3386:
3387: my %single = (
1.180 raeburn 3388: begins => 'A match',
1.160 raeburn 3389: contains => 'A match',
1.180 raeburn 3390: exact => 'An exact match',
1.160 raeburn 3391: );
3392: my %nomatch = (
1.180 raeburn 3393: begins => 'No match',
1.160 raeburn 3394: contains => 'No match',
1.180 raeburn 3395: exact => 'No exact match',
1.160 raeburn 3396: );
3397: if (keys(%srch_results) > 1) {
1.179 raeburn 3398: $currstate = 'select';
1.160 raeburn 3399: } else {
3400: if (keys(%srch_results) == 1) {
1.179 raeburn 3401: $currstate = 'modify';
1.180 raeburn 3402: $response = &mt("$single{$srch->{'srchtype'}} was found for the $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'});
3403: if ($srch->{'srchin'} eq 'dom' || $srch->{'srchin'} eq 'instd') {
3404: $response .= &display_domain_info($srch->{'srchdomain'});
3405: }
1.160 raeburn 3406: } else {
1.180 raeburn 3407: $response = '<span class="LC_warning">'.&mt("$nomatch{$srch->{'srchtype'}} found for the $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}",$srch->{'srchterm'});
3408: if ($srch->{'srchin'} eq 'dom' || $srch->{'srchin'} eq 'instd') {
3409: $response .= &display_domain_info($srch->{'srchdomain'});
3410: }
3411: $response .= '</span>';
1.160 raeburn 3412: if ($srch->{'srchin'} ne 'alc') {
3413: $forcenewuser = 1;
3414: my $cansrchinst = 0;
3415: if ($srch->{'srchdomain'}) {
3416: my %domconfig = &Apache::lonnet::get_dom('configuration',['directorysrch'],$srch->{'srchdomain'});
3417: if (ref($domconfig{'directorysrch'}) eq 'HASH') {
3418: if ($domconfig{'directorysrch'}{'available'}) {
3419: $cansrchinst = 1;
3420: }
3421: }
3422: }
1.180 raeburn 3423: if ((($srch->{'srchby'} eq 'lastfirst') ||
3424: ($srch->{'srchby'} eq 'lastname')) &&
3425: ($srch->{'srchin'} eq 'dom')) {
3426: if ($cansrchinst) {
3427: $response .= '<br />'.&mt('You may want to broaden your search to a search of the institutional directory for the domain.');
1.160 raeburn 3428: }
3429: }
1.180 raeburn 3430: if ($srch->{'srchin'} eq 'crs') {
3431: $response .= '<br />'.&mt('You may want to broaden your search to the selected LON-CAPA domain.');
3432: }
3433: }
3434: if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $env{'request.role.domain'})) {
1.221 raeburn 3435: my $cancreate =
3436: &Apache::lonuserutils::can_create_user($env{'request.role.domain'},$context);
3437: if ($cancreate) {
3438: my $showdom = &display_domain_info($env{'request.role.domain'});
1.182 raeburn 3439: $response .= '<br /><br />'.&mt("<b>To add a new user</b> (you can only create new users in your current role's domain - <span class=\"LC_cusr_emph\">[_1]</span>):",$env{'request.role.domain'}).'<ul><li>'.&mt("Set 'Domain/institution to search' to: <span class=\"LC_cusr_emph\">[_1]</span>",$showdom).'<li>'.&mt("Set 'Search criteria' to: <span class=\"LC_cusr_emph\">'username is ...... in selected LON-CAPA domain'").'</span></li><li>'.&mt('Provide the proposed username').'</li><li>'.&mt('Search').'</li></ul><br />';
1.221 raeburn 3440: } else {
3441: my $helplink = ' href="javascript:helpMenu('."'display'".')"';
3442: $response .= '<br /><br />'.&mt("You are not authorized to create new users in your current role's domain - <span class=\"LC_cusr_emph\">[_1]</span>.",$env{'request.role.domain'}).'<br />'.&mt('Contact the <a[_1]>helpdesk</a> if you need to create a new user.',$helplink).'<br /><br />';
3443: }
1.160 raeburn 3444: }
3445: }
3446: }
1.179 raeburn 3447: return ($currstate,$response,$forcenewuser);
1.160 raeburn 3448: }
3449:
1.180 raeburn 3450: sub display_domain_info {
3451: my ($dom) = @_;
3452: my $output = $dom;
3453: if ($dom ne '') {
3454: my $domdesc = &Apache::lonnet::domain($dom,'description');
3455: if ($domdesc ne '') {
3456: $output .= ' <span class="LC_cusr_emph">('.$domdesc.')</span>';
3457: }
3458: }
3459: return $output;
3460: }
3461:
1.160 raeburn 3462: sub crumb_utilities {
3463: my %elements = (
3464: crtuser => {
3465: srchterm => 'text',
1.172 raeburn 3466: srchin => 'selectbox',
1.160 raeburn 3467: srchby => 'selectbox',
3468: srchtype => 'selectbox',
3469: srchdomain => 'selectbox',
3470: },
1.207 raeburn 3471: crtusername => {
3472: srchterm => 'text',
3473: srchdomain => 'selectbox',
3474: },
1.160 raeburn 3475: docustom => {
3476: rolename => 'selectbox',
3477: newrolename => 'textbox',
3478: },
1.179 raeburn 3479: studentform => {
3480: srchterm => 'text',
3481: srchin => 'selectbox',
3482: srchby => 'selectbox',
3483: srchtype => 'selectbox',
3484: srchdomain => 'selectbox',
3485: },
1.160 raeburn 3486: );
3487:
3488: my $jsback .= qq|
3489: function backPage(formname,prevphase,prevstate) {
1.211 raeburn 3490: if (typeof prevphase == 'undefined') {
3491: formname.phase.value = '';
3492: }
3493: else {
3494: formname.phase.value = prevphase;
3495: }
3496: if (typeof prevstate == 'undefined') {
3497: formname.currstate.value = '';
3498: }
3499: else {
3500: formname.currstate.value = prevstate;
3501: }
1.160 raeburn 3502: formname.submit();
3503: }
3504: |;
3505: return ($jsback,\%elements);
3506: }
3507:
1.26 matthew 3508: sub course_level_table {
1.89 raeburn 3509: my (%inccourses) = @_;
1.26 matthew 3510: my $table = '';
1.62 www 3511: # Custom Roles?
3512:
1.190 raeburn 3513: my %customroles=&Apache::lonuserutils::my_custom_roles();
1.89 raeburn 3514: my %lt=&Apache::lonlocal::texthash(
3515: 'exs' => "Existing sections",
3516: 'new' => "Define new section",
3517: 'ssd' => "Set Start Date",
3518: 'sed' => "Set End Date",
1.131 raeburn 3519: 'crl' => "Course Level",
1.89 raeburn 3520: 'act' => "Activate",
3521: 'rol' => "Role",
3522: 'ext' => "Extent",
1.113 raeburn 3523: 'grs' => "Section",
1.89 raeburn 3524: 'sta' => "Start",
3525: 'end' => "End"
3526: );
1.62 www 3527:
1.135 raeburn 3528: foreach my $protectedcourse (sort( keys(%inccourses))) {
3529: my $thiscourse=$protectedcourse;
1.26 matthew 3530: $thiscourse=~s:_:/:g;
3531: my %coursedata=&Apache::lonnet::coursedescription($thiscourse);
3532: my $area=$coursedata{'description'};
1.119 raeburn 3533: my $type=$coursedata{'type'};
1.135 raeburn 3534: if (!defined($area)) { $area=&mt('Unavailable course').': '.$protectedcourse; }
1.89 raeburn 3535: my ($domain,$cnum)=split(/\//,$thiscourse);
1.115 albertel 3536: my %sections_count;
1.101 albertel 3537: if (defined($env{'request.course.id'})) {
3538: if ($env{'request.course.id'} eq $domain.'_'.$cnum) {
1.115 albertel 3539: %sections_count =
3540: &Apache::loncommon::get_sections($domain,$cnum);
1.92 raeburn 3541: }
3542: }
1.213 raeburn 3543: my @roles = &Apache::lonuserutils::roles_by_context('course');
3544: foreach my $role (@roles) {
1.221 raeburn 3545: my $plrole=&Apache::lonnet::plaintext($role);
1.135 raeburn 3546: if (&Apache::lonnet::allowed('c'.$role,$thiscourse)) {
1.221 raeburn 3547: $table .= &course_level_row($protectedcourse,$role,$area,$domain,
3548: $plrole,\%sections_count,\%lt);
3549: } elsif ($env{'request.course.sec'} ne '') {
3550: if (&Apache::lonnet::allowed('c'.$role,$thiscourse.'/'.
3551: $env{'request.course.sec'})) {
3552: $table .= &course_level_row($protectedcourse,$role,$area,$domain,
3553: $plrole,\%sections_count,\%lt);
1.26 matthew 3554: }
3555: }
3556: }
1.221 raeburn 3557: if (&Apache::lonnet::allowed('ccr',$thiscourse)) {
3558: foreach my $cust (sort keys %customroles) {
3559: my $role = 'cr_cr_'.$env{'user.domain'}.'_'.$env{'user.name'}.'_'.$cust;
3560: $table .= &course_level_row($protectedcourse,$role,$area,$domain,
3561: $cust,\%sections_count,\%lt);
3562: }
1.62 www 3563: }
1.26 matthew 3564: }
3565: return '' if ($table eq ''); # return nothing if there is nothing
3566: # in the table
1.188 raeburn 3567: my $result;
3568: if (!$env{'request.course.id'}) {
3569: $result = '<h4>'.$lt{'crl'}.'</h4>'."\n";
3570: }
3571: $result .=
1.136 raeburn 3572: &Apache::loncommon::start_data_table().
3573: &Apache::loncommon::start_data_table_header_row().
3574: '<th>'.$lt{'act'}.'</th><th>'.$lt{'rol'}.'</th><th>'.$lt{'ext'}.'</th>
3575: <th>'.$lt{'grs'}.'</th><th>'.$lt{'sta'}.'</th><th>'.$lt{'end'}.'</th>'.
3576: &Apache::loncommon::end_data_table_header_row().
3577: $table.
3578: &Apache::loncommon::end_data_table();
1.26 matthew 3579: return $result;
3580: }
1.88 raeburn 3581:
1.221 raeburn 3582: sub course_level_row {
3583: my ($protectedcourse,$role,$area,$domain,$plrole,$sections_count,$lt) = @_;
1.222 raeburn 3584: my $row = &Apache::loncommon::start_data_table_row().
3585: ' <td><input type="checkbox" name="act_'.
3586: $protectedcourse.'_'.$role.'" /></td>'."\n".
3587: ' <td>'.$plrole.'</td>'."\n".
3588: ' <td>'.$area.'<br />Domain: '.$domain.'</td>'."\n";
1.221 raeburn 3589: if ($role eq 'cc') {
1.222 raeburn 3590: $row .= '<td> </td>';
1.221 raeburn 3591: } elsif ($env{'request.course.sec'} ne '') {
1.222 raeburn 3592: $row .= ' <td><input type="hidden" value="'.
3593: $env{'request.course.sec'}.'" '.
3594: 'name="sec_'.$protectedcourse.'_'.$role.'" />'.
3595: $env{'request.course.sec'}.'</td>';
1.221 raeburn 3596: } else {
3597: if (ref($sections_count) eq 'HASH') {
3598: my $currsec =
3599: &Apache::lonuserutils::course_sections($sections_count,
3600: $protectedcourse.'_'.$role);
1.222 raeburn 3601: $row .= '<td><table class="LC_createuser">'."\n".
3602: '<tr class="LC_section_row">'."\n".
3603: ' <td valign="top">'.$lt->{'exs'}.'<br />'.
3604: $currsec.'</td>'."\n".
3605: ' <td> </td>'."\n".
3606: ' <td valign="top"> '.$lt->{'new'}.'<br />'.
1.221 raeburn 3607: '<input type="text" name="newsec_'.$protectedcourse.'_'.$role.
3608: '" value="" />'.
3609: '<input type="hidden" '.
3610: 'name="sec_'.$protectedcourse.'_'.$role.'" /></td>'."\n".
1.222 raeburn 3611: '</tr></table></td>'."\n";
1.221 raeburn 3612: } else {
1.222 raeburn 3613: $row .= '<td><input type="text" size="10" '.
3614: 'name="sec_'.$protectedcourse.'_'.$role.'" /></td>'."\n";
1.221 raeburn 3615: }
3616: }
1.222 raeburn 3617: $row .= <<ENDTIMEENTRY;
3618: <td><input type="hidden" name="start_$protectedcourse\_$role" value="" />
1.221 raeburn 3619: <a href=
3620: "javascript:pjump('date_start','Start Date $plrole',document.cu.start_$protectedcourse\_$role.value,'start_$protectedcourse\_$role','cu.pres','dateset')">$lt->{'ssd'}</a></td>
1.222 raeburn 3621: <td><input type="hidden" name="end_$protectedcourse\_$role" value="" />
1.221 raeburn 3622: <a href=
3623: "javascript:pjump('date_end','End Date $plrole',document.cu.end_$protectedcourse\_$role.value,'end_$protectedcourse\_$role','cu.pres','dateset')">$lt->{'sed'}</a></td>
3624: ENDTIMEENTRY
1.222 raeburn 3625: $row .= &Apache::loncommon::end_data_table_row();
3626: return $row;
1.221 raeburn 3627: }
3628:
1.88 raeburn 3629: sub course_level_dc {
3630: my ($dcdom) = @_;
1.190 raeburn 3631: my %customroles=&Apache::lonuserutils::my_custom_roles();
1.213 raeburn 3632: my @roles = &Apache::lonuserutils::roles_by_context('course');
1.88 raeburn 3633: my $hiddenitems = '<input type="hidden" name="dcdomain" value="'.$dcdom.'" />'.
3634: '<input type="hidden" name="origdom" value="'.$dcdom.'" />'.
1.133 raeburn 3635: '<input type="hidden" name="dccourse" value="" />';
1.88 raeburn 3636: my $courseform='<b>'.&Apache::loncommon::selectcourse_link
1.131 raeburn 3637: ('cu','dccourse','dcdomain','coursedesc',undef,undef,'Course').'</b>';
3638: my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu');
1.88 raeburn 3639: my %lt=&Apache::lonlocal::texthash(
3640: 'rol' => "Role",
1.113 raeburn 3641: 'grs' => "Section",
1.88 raeburn 3642: 'exs' => "Existing sections",
3643: 'new' => "Define new section",
3644: 'sta' => "Start",
3645: 'end' => "End",
3646: 'ssd' => "Set Start Date",
3647: 'sed' => "Set End Date"
3648: );
1.131 raeburn 3649: my $header = '<h4>'.&mt('Course Level').'</h4>'.
1.136 raeburn 3650: &Apache::loncommon::start_data_table().
3651: &Apache::loncommon::start_data_table_header_row().
1.143 raeburn 3652: '<th>'.$courseform.'</th><th>'.$lt{'rol'}.'</th><th>'.$lt{'grs'}.'</th><th>'.$lt{'sta'}.'</th><th>'.$lt{'end'}.'</th>'.
1.136 raeburn 3653: &Apache::loncommon::end_data_table_header_row();
1.143 raeburn 3654: my $otheritems = &Apache::loncommon::start_data_table_row()."\n".
1.131 raeburn 3655: '<td><input type="text" name="coursedesc" value="" onFocus="this.blur();opencrsbrowser('."'cu','dccourse','dcdomain','coursedesc',''".')" /></td>'."\n".
1.88 raeburn 3656: '<td><select name="role">'."\n";
1.213 raeburn 3657: foreach my $role (@roles) {
1.135 raeburn 3658: my $plrole=&Apache::lonnet::plaintext($role);
3659: $otheritems .= ' <option value="'.$role.'">'.$plrole;
1.88 raeburn 3660: }
3661: if ( keys %customroles > 0) {
1.135 raeburn 3662: foreach my $cust (sort keys %customroles) {
1.101 albertel 3663: my $custrole='cr_cr_'.$env{'user.domain'}.
1.135 raeburn 3664: '_'.$env{'user.name'}.'_'.$cust;
3665: $otheritems .= ' <option value="'.$custrole.'">'.$cust;
1.88 raeburn 3666: }
3667: }
3668: $otheritems .= '</select></td><td>'.
3669: '<table border="0" cellspacing="0" cellpadding="0">'.
3670: '<tr><td valign="top"><b>'.$lt{'exs'}.'</b><br /><select name="currsec">'.
3671: ' <option value=""><--'.&mt('Pick course first').'</select></td>'.
3672: '<td> </td>'.
3673: '<td valign="top"> <b>'.$lt{'new'}.'</b><br />'.
1.113 raeburn 3674: '<input type="text" name="newsec" value="" />'.
1.221 raeburn 3675: '<input type="hidden" name="sections" value="" />'.
1.113 raeburn 3676: '<input type="hidden" name="groups" value="" /></td>'.
1.88 raeburn 3677: '</tr></table></td>';
3678: $otheritems .= <<ENDTIMEENTRY;
1.169 albertel 3679: <td><input type="hidden" name="start" value='' />
1.88 raeburn 3680: <a href=
3681: "javascript:pjump('date_start','Start Date',document.cu.start.value,'start','cu.pres','dateset')">$lt{'ssd'}</a></td>
1.169 albertel 3682: <td><input type="hidden" name="end" value='' />
1.88 raeburn 3683: <a href=
3684: "javascript:pjump('date_end','End Date',document.cu.end.value,'end','cu.pres','dateset')">$lt{'sed'}</a></td>
3685: ENDTIMEENTRY
1.136 raeburn 3686: $otheritems .= &Apache::loncommon::end_data_table_row().
3687: &Apache::loncommon::end_data_table()."\n";
1.88 raeburn 3688: return $cb_jscript.$header.$hiddenitems.$otheritems;
3689: }
3690:
1.27 matthew 3691: #---------------------------------------------- end functions for &phase_two
1.29 matthew 3692:
3693: #--------------------------------- functions for &phase_two and &phase_three
3694:
3695: #--------------------------end of functions for &phase_two and &phase_three
1.1 www 3696:
3697: 1;
3698: __END__
1.2 www 3699:
3700:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>