Annotation of loncom/interface/loncreateuser.pm, revision 1.227
1.20 harris41 1: # The LearningOnline Network with CAPA
1.1 www 2: # Create a user
3: #
1.227 ! raeburn 4: # $Id: loncreateuser.pm,v 1.226 2007/12/31 02:28:12 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 $helpcrt=&Apache::loncommon::help_open_topic('Course_Change_Privileges');
324: my %lt=&Apache::lonlocal::texthash(
325: 'crnu' => 'Create a new user',
326: 'usr' => 'Username',
327: 'dom' => 'in domain',
328: 'cra' => 'Create user',
329: );
330: $output .= <<"ENDDOCUMENT";
331: <form action="/adm/createuser" method="post" name="crtusername">
332: <input type="hidden" name="action" value="$env{'form.action'}" />
333: <input type="hidden" name="phase" value="createnewuser" />
334: <input type="hidden" name="srchtype" value="exact" />
335: <input type="hidden" name="srchby" value="username" />
336: <input type="hidden" name="srchin" value="dom" />
337: <input type="hidden" name="forcenewuser" value="1" />
338: <input type="hidden" name="origform" value="crtusername" />
339: <h3>$lt{crnu}$helpcrt</h3>
1.214 raeburn 340: $responsemsg
1.207 raeburn 341: <table>
342: <tr>
343: <td>$lt{'usr'}:</td>
344: <td><input type="text" size="15" name="srchterm" /></td>
345: <td> $lt{'dom'}:</td><td>$domform</td>
346: <td> <input name="userrole" type="submit" value="$lt{'cra'}" /></td>
347: </tr>
348: </table>
349: </form>
1.160 raeburn 350: ENDDOCUMENT
1.207 raeburn 351: }
1.160 raeburn 352: return $output;
353: }
1.110 albertel 354:
355: sub user_modification_js {
1.113 raeburn 356: my ($pjump_def,$dc_setcourse_code,$nondc_setsection_code,$groupslist)=@_;
357:
1.110 albertel 358: return <<END;
359: <script type="text/javascript" language="Javascript">
360:
361: function pclose() {
362: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
363: "height=350,width=350,scrollbars=no,menubar=no");
364: parmwin.close();
365: }
366:
367: $pjump_def
368: $dc_setcourse_code
369:
370: function dateset() {
371: eval("document.cu."+document.cu.pres_marker.value+
372: ".value=document.cu.pres_value.value");
373: pclose();
374: }
375:
1.113 raeburn 376: $nondc_setsection_code
377:
1.110 albertel 378: </script>
379: END
1.2 www 380: }
381:
382: # =================================================================== Phase two
1.160 raeburn 383: sub print_user_selection_page {
1.207 raeburn 384: my ($r,$response,$srch,$srch_results,$operation,$srcharray,$context) = @_;
1.160 raeburn 385: my @fields = ('username','domain','lastname','firstname','permanentemail');
386: my $sortby = $env{'form.sortby'};
387:
388: if (!grep(/^\Q$sortby\E$/,@fields)) {
389: $sortby = 'lastname';
390: }
391:
392: my ($jsback,$elements) = &crumb_utilities();
393:
394: my $jscript = (<<ENDSCRIPT);
395: <script type="text/javascript">
396: function pickuser(uname,udom) {
397: document.usersrchform.seluname.value=uname;
398: document.usersrchform.seludom.value=udom;
399: document.usersrchform.phase.value="userpicked";
400: document.usersrchform.submit();
401: }
402:
403: $jsback
404: </script>
405: ENDSCRIPT
406:
407: my %lt=&Apache::lonlocal::texthash(
1.179 raeburn 408: 'usrch' => "User Search to add/modify roles",
409: 'stusrch' => "User Search to enroll student",
410: 'usel' => "Select a user to add/modify roles",
411: 'stusel' => "Select a user to enroll as a student",
1.160 raeburn 412: 'username' => "username",
413: 'domain' => "domain",
414: 'lastname' => "last name",
415: 'firstname' => "first name",
416: 'permanentemail' => "permanent e-mail",
417: );
1.214 raeburn 418: $r->print(&Apache::loncommon::start_page('User Management',$jscript));
1.190 raeburn 419: if ($operation eq 'createuser') {
1.179 raeburn 420: &Apache::lonhtmlcommon::add_breadcrumb
421: ({href=>"javascript:backPage(document.usersrchform,'','')",
1.190 raeburn 422: text=>"Create/modify user",
1.179 raeburn 423: faq=>282,bug=>'Instructor Interface',},
424: {href=>"javascript:backPage(document.usersrchform,'get_user_info','select')",
425: text=>"Select User",
426: faq=>282,bug=>'Instructor Interface',});
1.224 raeburn 427: $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
428: 'Course_Change_Privileges'));
1.179 raeburn 429: $r->print("<b>$lt{'usrch'}</b><br />");
1.207 raeburn 430: $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context));
1.179 raeburn 431: $r->print('<h3>'.$lt{'usel'}.'</h3>');
1.214 raeburn 432: } elsif ($operation eq 'enrollstudent') {
433: &Apache::lonhtmlcommon::add_breadcrumb
434: ({href=>"javascript:backPage(document.usersrchform,'','')",
435: text=>"Create/modify student",
436: faq=>282,bug=>'Instructor Interface',},
437: {href=>"javascript:backPage(document.usersrchform,'get_user_info','select')",
438: text=>"Select Student",
439: faq=>282,bug=>'Instructor Interface',});
1.224 raeburn 440: $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
441: 'Course_Add_Student'));
1.179 raeburn 442: $r->print($jscript."<b>$lt{'stusrch'}</b><br />");
1.214 raeburn 443: $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context));
1.179 raeburn 444: $r->print('</form><h3>'.$lt{'stusel'}.'</h3>');
445: }
1.160 raeburn 446: $r->print('<form name="usersrchform" method="post">'.
447: &Apache::loncommon::start_data_table()."\n".
448: &Apache::loncommon::start_data_table_header_row()."\n".
449: ' <th> </th>'."\n");
450: foreach my $field (@fields) {
451: $r->print(' <th><a href="javascript:document.usersrchform.sortby.value='.
452: "'".$field."'".';document.usersrchform.submit();">'.
453: $lt{$field}.'</a></th>'."\n");
454: }
455: $r->print(&Apache::loncommon::end_data_table_header_row());
456:
457: my @sorted_users = sort {
1.167 albertel 458: lc($srch_results->{$a}->{$sortby}) cmp lc($srch_results->{$b}->{$sortby})
1.160 raeburn 459: ||
1.167 albertel 460: lc($srch_results->{$a}->{lastname}) cmp lc($srch_results->{$b}->{lastname})
1.160 raeburn 461: ||
462: lc($srch_results->{$a}->{firstname}) cmp lc($srch_results->{$b}->{firstname})
1.167 albertel 463: ||
464: lc($a) cmp lc($b)
1.160 raeburn 465: } (keys(%$srch_results));
466:
467: foreach my $user (@sorted_users) {
468: my ($uname,$udom) = split(/:/,$user);
469: $r->print(&Apache::loncommon::start_data_table_row().
470: '<td><input type="button" name="seluser" value="'.&mt('Select').'" onclick="javascript:pickuser('."'".$uname."'".','."'".$udom."'".')" /></td>'.
471: '<td><tt>'.$uname.'</tt></td>'.
472: '<td><tt>'.$udom.'</tt></td>');
473: foreach my $field ('lastname','firstname','permanentemail') {
474: $r->print('<td>'.$srch_results->{$user}->{$field}.'</td>');
475: }
476: $r->print(&Apache::loncommon::end_data_table_row());
477: }
478: $r->print(&Apache::loncommon::end_data_table().'<br /><br />');
1.179 raeburn 479: if (ref($srcharray) eq 'ARRAY') {
480: foreach my $item (@{$srcharray}) {
481: $r->print('<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n");
482: }
483: }
1.160 raeburn 484: $r->print(' <input type="hidden" name="sortby" value="'.$sortby.'" />'."\n".
485: ' <input type="hidden" name="seluname" value="" />'."\n".
486: ' <input type="hidden" name="seludom" value="" />'."\n".
1.179 raeburn 487: ' <input type="hidden" name="currstate" value="select" />'."\n".
1.190 raeburn 488: ' <input type="hidden" name="phase" value="get_user_info" />'."\n".
1.214 raeburn 489: ' <input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n");
490: $r->print($response.'</form>'.&Apache::loncommon::end_page());
1.160 raeburn 491: }
492:
493: sub print_user_query_page {
1.179 raeburn 494: my ($r,$caller) = @_;
1.160 raeburn 495: # FIXME - this is for a network-wide name search (similar to catalog search)
496: # To use frames with similar behavior to catalog/portfolio search.
497: # To be implemented.
498: return;
499: }
500:
1.42 matthew 501: sub print_user_modification_page {
1.215 raeburn 502: my ($r,$ccuname,$ccdomain,$srch,$response,$context,$permission) = @_;
1.185 raeburn 503: if (($ccuname eq '') || ($ccdomain eq '')) {
1.215 raeburn 504: my $usermsg = &mt('No username and/or domain provided.');
505: $env{'form.phase'} = '';
1.207 raeburn 506: &print_username_entry_form($r,$context,$usermsg);
1.58 www 507: return;
508: }
1.213 raeburn 509: my ($form,$formname);
510: if ($env{'form.action'} eq 'singlestudent') {
511: $form = 'document.enrollstudent';
512: $formname = 'enrollstudent';
513: } else {
514: $form = 'document.cu';
515: $formname = 'cu';
516: }
1.188 raeburn 517: my %abv_auth = &auth_abbrev();
1.227 ! raeburn 518: my (%rulematch,%inst_results,$newuser,%alerts,%curr_rules,%got_rules);
1.185 raeburn 519: my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
520: if ($uhome eq 'no_host') {
1.215 raeburn 521: my $usertype;
522: my ($rules,$ruleorder) =
523: &Apache::lonnet::inst_userrules($ccdomain,'username');
524: $usertype =
525: &Apache::lonuserutils::check_usertype($ccdomain,$ccuname,$rules);
526: my $cancreate =
527: &Apache::lonuserutils::can_create_user($ccdomain,$context,
528: $usertype);
529: if (!$cancreate) {
530: my $helplink = ' href="javascript:helpMenu('."'display'".')"';
531: my %usertypetext = (
532: official => 'institutional',
533: unofficial => 'non-institutional',
534: );
535: my $response;
536: if ($env{'form.origform'} eq 'crtusername') {
537: $response = '<span class="LC_warning">'.&mt('No match was found for the username ([_1]) in LON-CAPA domain: [_2]',$ccuname,$ccdomain).
538: '</span><br />';
539: }
540: $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 />';
541: $env{'form.phase'} = '';
542: &print_username_entry_form($r,$context,$response);
543: return;
544: }
1.188 raeburn 545: $newuser = 1;
1.193 raeburn 546: my $checkhash;
547: my $checks = { 'username' => 1 };
1.196 raeburn 548: $checkhash->{$ccuname.':'.$ccdomain} = { 'newuser' => $newuser };
1.193 raeburn 549: &Apache::loncommon::user_rule_check($checkhash,$checks,
1.196 raeburn 550: \%alerts,\%rulematch,\%inst_results,\%curr_rules,\%got_rules);
551: if (ref($alerts{'username'}) eq 'HASH') {
552: if (ref($alerts{'username'}{$ccdomain}) eq 'HASH') {
553: my $domdesc =
1.193 raeburn 554: &Apache::lonnet::domain($ccdomain,'description');
1.196 raeburn 555: if ($alerts{'username'}{$ccdomain}{$ccuname}) {
556: my $userchkmsg;
557: if (ref($curr_rules{$ccdomain}) eq 'HASH') {
558: $userchkmsg =
559: &Apache::loncommon::instrule_disallow_msg('username',
1.193 raeburn 560: $domdesc,1).
561: &Apache::loncommon::user_rule_formats($ccdomain,
562: $domdesc,$curr_rules{$ccdomain}{'username'},
563: 'username');
1.196 raeburn 564: }
1.215 raeburn 565: $env{'form.phase'} = '';
1.207 raeburn 566: &print_username_entry_form($r,$context,$userchkmsg);
1.196 raeburn 567: return;
1.215 raeburn 568: }
1.193 raeburn 569: }
1.185 raeburn 570: }
1.187 raeburn 571: } else {
1.188 raeburn 572: $newuser = 0;
1.185 raeburn 573: }
1.160 raeburn 574: if ($response) {
1.215 raeburn 575: $response = '<br />'.$response;
1.160 raeburn 576: }
1.149 raeburn 577:
1.52 matthew 578: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.88 raeburn 579: my $dc_setcourse_code = '';
1.119 raeburn 580: my $nondc_setsection_code = '';
1.112 albertel 581: my %loaditem;
1.114 albertel 582:
1.216 raeburn 583: my $groupslist = &Apache::lonuserutils::get_groupslist();
1.88 raeburn 584:
1.216 raeburn 585: my $js = &validation_javascript($context,$ccdomain,$pjump_def,
586: $groupslist,$newuser,$formname,\%loaditem);
1.110 albertel 587: my $start_page =
1.190 raeburn 588: &Apache::loncommon::start_page('User Management',
1.112 albertel 589: $js,{'add_entries' => \%loaditem,});
1.216 raeburn 590: my %breadcrumb_text = &singleuser_breadcrumb();
1.160 raeburn 591: &Apache::lonhtmlcommon::add_breadcrumb
1.216 raeburn 592: ({href=>"javascript:backPage($form)",
593: text=>$breadcrumb_text{'search'},
1.160 raeburn 594: faq=>282,bug=>'Instructor Interface',});
595:
596: if ($env{'form.phase'} eq 'userpicked') {
597: &Apache::lonhtmlcommon::add_breadcrumb
1.216 raeburn 598: ({href=>"javascript:backPage($form,'get_user_info','select')",
599: text=>$breadcrumb_text{'userpicked'},
1.160 raeburn 600: faq=>282,bug=>'Instructor Interface',});
601: }
602: &Apache::lonhtmlcommon::add_breadcrumb
1.216 raeburn 603: ({href=>"javascript:backPage($form,'$env{'form.phase'}','modify')",
604: text=>$breadcrumb_text{'modify'},
1.160 raeburn 605: faq=>282,bug=>'Instructor Interface',});
1.224 raeburn 606: my $helpitem = 'Course_Change_Privileges';
607: if ($env{'form.action'} eq 'singlestudent') {
608: $helpitem = 'Course_Add_Student';
609: }
610: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management',
611: $helpitem);
1.3 www 612:
1.25 matthew 613: my $forminfo =<<"ENDFORMINFO";
1.216 raeburn 614: <form action="/adm/createuser" method="post" name="$formname">
1.190 raeburn 615: <input type="hidden" name="phase" value="update_user_data" />
1.188 raeburn 616: <input type="hidden" name="ccuname" value="$ccuname" />
617: <input type="hidden" name="ccdomain" value="$ccdomain" />
1.157 albertel 618: <input type="hidden" name="pres_value" value="" />
619: <input type="hidden" name="pres_type" value="" />
620: <input type="hidden" name="pres_marker" value="" />
1.25 matthew 621: ENDFORMINFO
1.2 www 622: my %inccourses;
1.135 raeburn 623: foreach my $key (keys(%env)) {
1.139 albertel 624: if ($key=~/^user\.priv\.cm\.\/($match_domain)\/($match_username)/) {
1.2 www 625: $inccourses{$1.'_'.$2}=1;
626: }
1.24 matthew 627: }
1.216 raeburn 628: if ($newuser) {
1.134 raeburn 629: my $portfolioform;
630: if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
631: # Current user has quota modification privileges
1.188 raeburn 632: $portfolioform = '<br />'.&portfolio_quota($ccuname,$ccdomain);
1.134 raeburn 633: }
1.227 ! raeburn 634: &initialize_authen_forms($ccdomain,$formname);
1.188 raeburn 635: my %lt=&Apache::lonlocal::texthash(
636: 'cnu' => 'Create New User',
1.213 raeburn 637: 'ast' => 'as a student',
1.188 raeburn 638: 'ind' => 'in domain',
639: 'lg' => 'Login Data',
1.190 raeburn 640: 'hs' => "Home Server",
1.188 raeburn 641: );
1.185 raeburn 642: $r->print(<<ENDTITLE);
1.110 albertel 643: $start_page
1.160 raeburn 644: $crumbs
645: $response
1.25 matthew 646: $forminfo
1.31 matthew 647: <script type="text/javascript" language="Javascript">
1.20 harris41 648: $loginscript
1.31 matthew 649: </script>
1.20 harris41 650: <input type='hidden' name='makeuser' value='1' />
1.216 raeburn 651: <h2>$lt{'cnu'} "$ccuname" $lt{'ind'} $ccdomain
1.185 raeburn 652: ENDTITLE
1.213 raeburn 653: if ($env{'form.action'} eq 'singlestudent') {
654: $r->print(' ('.$lt{'ast'}.')');
655: }
656: $r->print('</h2>'."\n".'<div class="LC_left_float">');
1.206 raeburn 657: my $personal_table =
1.210 raeburn 658: &personal_data_display($ccuname,$ccdomain,$newuser,$context,
659: $inst_results{$ccuname.':'.$ccdomain});
1.206 raeburn 660: $r->print($personal_table);
1.187 raeburn 661: my ($home_server_pick,$numlib) =
662: &Apache::loncommon::home_server_form_item($ccdomain,'hserver',
663: 'default','hide');
664: if ($numlib > 1) {
665: $r->print("
1.185 raeburn 666: <br />
1.187 raeburn 667: $lt{'hs'}: $home_server_pick
668: <br />");
669: } else {
670: $r->print($home_server_pick);
671: }
1.188 raeburn 672: $r->print('</div>'."\n".'<div class="LC_left_float"><h3>'.
673: $lt{'lg'}.'</h3>');
1.185 raeburn 674: my ($fixedauth,$varauth,$authmsg);
1.193 raeburn 675: if (ref($rulematch{$ccuname.':'.$ccdomain}) eq 'HASH') {
676: my $matchedrule = $rulematch{$ccuname.':'.$ccdomain}{'username'};
677: my ($rules,$ruleorder) =
678: &Apache::lonnet::inst_userrules($ccdomain,'username');
1.185 raeburn 679: if (ref($rules) eq 'HASH') {
1.193 raeburn 680: if (ref($rules->{$matchedrule}) eq 'HASH') {
681: my $authtype = $rules->{$matchedrule}{'authtype'};
1.185 raeburn 682: if ($authtype !~ /^(krb4|krb5|int|fsys|loc)$/) {
1.190 raeburn 683: $r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc));
1.185 raeburn 684: } else {
1.193 raeburn 685: my $authparm = $rules->{$matchedrule}{'authparm'};
1.185 raeburn 686: if ($authtype =~ /^krb(4|5)$/) {
687: my $ver = $1;
688: if ($authparm ne '') {
689: $fixedauth = <<"KERB";
690: <input type="hidden" name="login" value="krb" />
691: <input type="hidden" name="krbver" value="$ver" />
692: <input type="hidden" name="krbarg" value="$authparm" />
693: KERB
1.193 raeburn 694: $authmsg = $rules->{$matchedrule}{'authmsg'};
1.185 raeburn 695: }
696: } else {
697: $fixedauth =
698: '<input type="hidden" name="login" value="'.$authtype.'" />'."\n";
1.193 raeburn 699: if ($rules->{$matchedrule}{'authparmfixed'}) {
1.185 raeburn 700: $fixedauth .=
701: '<input type="hidden" name="'.$authtype.'arg" value="'.$authparm.'" />'."\n";
702: } else {
703: $varauth =
704: '<input type="text" name="'.$authtype.'arg" value="" />'."\n";
705: }
706: }
707: }
708: } else {
1.190 raeburn 709: $r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc));
1.185 raeburn 710: }
711: }
712: if ($authmsg) {
713: $r->print(<<ENDAUTH);
714: $fixedauth
715: $authmsg
716: $varauth
717: ENDAUTH
718: }
719: } else {
1.190 raeburn 720: $r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc));
1.187 raeburn 721: }
1.215 raeburn 722: $r->print($portfolioform);
723: if ($env{'form.action'} eq 'singlestudent') {
724: $r->print(&date_sections_select($context,$newuser,$formname,
725: $permission));
726: }
727: $r->print('</div><div class="LC_clear_float_footer"></div>');
1.216 raeburn 728: } else { # user already exists
1.79 albertel 729: my %lt=&Apache::lonlocal::texthash(
1.191 raeburn 730: 'cup' => "Modify existing user: ",
1.213 raeburn 731: 'ens' => "Enroll one student: ",
1.72 sakharuk 732: 'id' => "in domain",
733: );
1.26 matthew 734: $r->print(<<ENDCHANGEUSER);
1.110 albertel 735: $start_page
1.160 raeburn 736: $crumbs
1.25 matthew 737: $forminfo
1.213 raeburn 738: <h2>
1.26 matthew 739: ENDCHANGEUSER
1.213 raeburn 740: if ($env{'form.action'} eq 'singlestudent') {
741: $r->print($lt{'ens'});
742: } else {
743: $r->print($lt{'cup'});
744: }
745: $r->print(' "'.$ccuname.'" '.$lt{'id'}.' "'.$ccdomain.'"</h2>'.
746: "\n".'<div class="LC_left_float">');
1.206 raeburn 747: my ($personal_table,$showforceid) =
1.210 raeburn 748: &personal_data_display($ccuname,$ccdomain,$newuser,$context,
749: $inst_results{$ccuname.':'.$ccdomain});
1.206 raeburn 750: $r->print($personal_table);
751: if ($showforceid) {
1.203 raeburn 752: $r->print(&Apache::lonuserutils::forceid_change($context));
1.199 raeburn 753: }
754: $r->print('</div>');
1.227 ! raeburn 755: my $user_auth_text = &user_authentication($ccuname,$ccdomain,$formname);
1.188 raeburn 756: my $user_quota_text;
757: if (&Apache::lonnet::allowed('mpq',$ccdomain)) {
758: # Current user has quota modification privileges
759: $user_quota_text = &portfolio_quota($ccuname,$ccdomain);
760: } elsif (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
761: # Get the user's portfolio information
762: my %portq = &Apache::lonnet::get('environment',['portfolioquota'],
763: $ccdomain,$ccuname);
764:
765: my %lt=&Apache::lonlocal::texthash(
766: 'dska' => "Disk space allocated to user's portfolio files",
767: 'youd' => "You do not have privileges to modify the portfolio quota for this user.",
768: 'ichr' => "If a change is required, contact a domain coordinator for the domain",
769: );
770: $user_quota_text = <<ENDNOPORTPRIV;
771: <h3>$lt{'dska'}</h3>
772: $lt{'youd'} $lt{'ichr'}: $ccdomain
773: ENDNOPORTPRIV
774: }
775: if ($user_auth_text ne '') {
776: $r->print('<div class="LC_left_float">'.$user_auth_text);
777: if ($user_quota_text ne '') {
778: $r->print($user_quota_text);
779: }
1.213 raeburn 780: if ($env{'form.action'} eq 'singlestudent') {
781: $r->print(&date_sections_select($context,$newuser,$formname));
782: }
1.188 raeburn 783: } elsif ($user_quota_text ne '') {
1.213 raeburn 784: $r->print('<div class="LC_left_float">'.$user_quota_text);
785: if ($env{'form.action'} eq 'singlestudent') {
786: $r->print(&date_sections_select($context,$newuser,$formname));
787: }
788: } else {
789: if ($env{'form.action'} eq 'singlestudent') {
790: $r->print('<div class="LC_left_float">'.
791: &date_sections_select($context,$newuser,$formname));
792: }
1.188 raeburn 793: }
1.213 raeburn 794: $r->print('</div><div class="LC_clear_float_footer"></div>');
1.217 raeburn 795: if ($env{'form.action'} ne 'singlestudent') {
796: &display_existing_roles($r,$ccuname,$ccdomain,\%inccourses);
797: }
1.25 matthew 798: } ## End of new user/old user logic
1.218 raeburn 799:
800: if ($env{'form.action'} eq 'singlestudent') {
801: $r->print('<br /><input type="button" value="'.&mt('Enroll Student').'" onClick="setSections(this.form)" />'."\n");
802: } else {
803: $r->print('<h3>'.&mt('Add Roles').'</h3>');
804: my $addrolesdisplay = 0;
805: if ($context eq 'domain' || $context eq 'author') {
806: $addrolesdisplay = &new_coauthor_roles($r,$ccuname,$ccdomain);
807: }
808: if ($context eq 'domain') {
809: my $add_domainroles = &new_domain_roles($r);
810: if (!$addrolesdisplay) {
811: $addrolesdisplay = $add_domainroles;
1.2 www 812: }
1.218 raeburn 813: $r->print(&course_level_dc($env{'request.role.domain'},'Course'));
814: $r->print('<br /><input type="button" value="'.&mt('Modify User').'" onClick="setCourse()" />'."\n");
815: } elsif ($context eq 'author') {
816: if ($addrolesdisplay) {
817: $r->print('<br /><input type="button" value="'.&mt('Modify User').'"');
818: if ($newuser) {
1.227 ! raeburn 819: $r->print(' onClick="auth_check()" \>'."\n");
1.218 raeburn 820: } else {
821: $r->print('onClick="this.form.submit()" \>'."\n");
822: }
1.188 raeburn 823: } else {
1.218 raeburn 824: $r->print('<br /><a href="javascript:backPage(document.cu)">'.
825: &mt('Back to previous page').'</a>');
1.188 raeburn 826: }
827: } else {
1.218 raeburn 828: $r->print(&course_level_table(%inccourses));
829: $r->print('<br /><input type="button" value="'.&mt('Modify User').'" onClick="setSections(this.form)" />'."\n");
1.188 raeburn 830: }
1.88 raeburn 831: }
1.188 raeburn 832: $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate','ccuname','ccdomain']));
1.179 raeburn 833: $r->print('<input type="hidden" name="currstate" value="" />');
1.160 raeburn 834: $r->print('<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />');
1.110 albertel 835: $r->print("</form>".&Apache::loncommon::end_page());
1.218 raeburn 836: return;
1.2 www 837: }
1.1 www 838:
1.213 raeburn 839: sub singleuser_breadcrumb {
840: my %breadcrumb_text;
841: if ($env{'form.action'} eq 'singlestudent') {
842: $breadcrumb_text{'search'} = 'Enroll a student';
843: $breadcrumb_text{'userpicked'} = 'Select a user',
844: $breadcrumb_text{'modify'} = 'Set section/dates',
845: } else {
846: $breadcrumb_text{'search'} = 'Create/modify user';
847: $breadcrumb_text{'userpicked'} = 'Select a user',
848: $breadcrumb_text{'modify'} = 'Set user role',
849: }
850: return %breadcrumb_text;
851: }
852:
853: sub date_sections_select {
854: my ($context,$newuser,$formname,$permission) = @_;
855: my $cid = $env{'request.course.id'};
856: my ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity($cid);
857: my $date_table = '<h3>'.&mt('Starting and Ending Dates').'</h3>'."\n".
858: &Apache::lonuserutils::date_setting_table(undef,undef,$context,
859: undef,$formname,$permission);
860: my $rowtitle = 'Section';
861: my $secbox = '<h3>'.&mt('Section').'</h3>'."\n".
862: &Apache::lonuserutils::section_picker($cdom,$cnum,'st',$rowtitle,
863: $permission);
864: my $output = $date_table.$secbox;
865: return $output;
866: }
867:
1.216 raeburn 868: sub validation_javascript {
869: my ($context,$ccdomain,$pjump_def,$groupslist,$newuser,$formname,
870: $loaditem) = @_;
871: my $dc_setcourse_code = '';
872: my $nondc_setsection_code = '';
873: if ($context eq 'domain') {
874: my $dcdom = $env{'request.role.domain'};
875: $loaditem->{'onload'} = "document.cu.coursedesc.value='';";
1.227 ! raeburn 876: $dc_setcourse_code =
! 877: &Apache::lonuserutils::dc_setcourse_js('cu','singleuser',$context);
1.216 raeburn 878: } else {
1.227 ! raeburn 879: my $checkauth;
! 880: if (($newuser) || (&Apache::lonnet::allowed('mau',$ccdomain))) {
! 881: $checkauth = 1;
! 882: }
! 883: if ($context eq 'course') {
! 884: $nondc_setsection_code =
! 885: &Apache::lonuserutils::setsections_javascript($formname,$groupslist,
! 886: undef,$checkauth);
! 887: }
! 888: if ($checkauth) {
! 889: $nondc_setsection_code .=
! 890: &Apache::lonuserutils::verify_authen($formname,$context);
! 891: }
1.216 raeburn 892: }
893: my $js = &user_modification_js($pjump_def,$dc_setcourse_code,
894: $nondc_setsection_code,$groupslist);
895: my ($jsback,$elements) = &crumb_utilities();
896: $js .= "\n".
1.227 ! raeburn 897: '<script type="text/javascript">'."\n".$jsback."\n".'</script>';
1.216 raeburn 898: return $js;
899: }
900:
1.217 raeburn 901: sub display_existing_roles {
902: my ($r,$ccuname,$ccdomain,$inccourses) = @_;
903: my %rolesdump=&Apache::lonnet::dump('roles',$ccdomain,$ccuname);
904: # Build up table of user roles to allow revocation and re-enabling of roles.
905: my ($tmp) = keys(%rolesdump);
906: if ($tmp !~ /^(con_lost|error)/i) {
907: my $now=time;
908: my %lt=&Apache::lonlocal::texthash(
909: 'rer' => "Existing Roles",
910: 'rev' => "Revoke",
911: 'del' => "Delete",
912: 'ren' => "Re-Enable",
913: 'rol' => "Role",
914: 'ext' => "Extent",
915: 'sta' => "Start",
916: 'end' => "End",
917: );
918: my (%roletext,%sortrole,%roleclass,%rolepriv);
919: foreach my $area (sort { my $a1=join('_',(split('_',$a))[1,0]);
920: my $b1=join('_',(split('_',$b))[1,0]);
921: return $a1 cmp $b1;
922: } keys(%rolesdump)) {
923: next if ($area =~ /^rolesdef/);
924: my $envkey=$area;
925: my $role = $rolesdump{$area};
926: my $thisrole=$area;
927: $area =~ s/\_\w\w$//;
928: my ($role_code,$role_end_time,$role_start_time) =
929: split(/_/,$role);
930: # Is this a custom role? Get role owner and title.
931: my ($croleudom,$croleuname,$croletitle)=
932: ($role_code=~m{^cr/($match_domain)/($match_username)/(\w+)$});
933: my $allowed=0;
934: my $delallowed=0;
935: my $sortkey=$role_code;
936: my $class='Unknown';
937: if ($area =~ m{^/($match_domain)/($match_courseid)} ) {
938: $class='Course';
939: my ($coursedom,$coursedir) = ($1,$2);
940: $sortkey.="\0$coursedom";
941: # $1.'_'.$2 is the course id (eg. 103_12345abcef103l3).
942: my %coursedata=
943: &Apache::lonnet::coursedescription($1.'_'.$2);
944: my $carea;
945: if (defined($coursedata{'description'})) {
946: $carea=$coursedata{'description'}.
947: '<br />'.&mt('Domain').': '.$coursedom.(' 'x8).
948: &Apache::loncommon::syllabuswrapper('Syllabus',$coursedir,$coursedom);
949: $sortkey.="\0".$coursedata{'description'};
950: $class=$coursedata{'type'};
951: } else {
952: $carea=&mt('Unavailable course').': '.$area;
953: $sortkey.="\0".&mt('Unavailable course').': '.$area;
954: }
955: $sortkey.="\0$coursedir";
956: $inccourses->{$1.'_'.$2}=1;
957: if ((&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2)) ||
958: (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
959: $allowed=1;
960: }
961: if ((&Apache::lonnet::allowed('dro',$1)) ||
962: (&Apache::lonnet::allowed('dro',$ccdomain))) {
963: $delallowed=1;
964: }
965: # - custom role. Needs more info, too
966: if ($croletitle) {
967: if (&Apache::lonnet::allowed('ccr',$1.'/'.$2)) {
968: $allowed=1;
969: $thisrole.='.'.$role_code;
970: }
971: }
972: # Compute the background color based on $area
973: if ($area=~m{^/($match_domain)/($match_courseid)/(\w+)}) {
974: $carea.='<br />Section: '.$3;
975: $sortkey.="\0$3";
976: if (!$allowed) {
977: if ($env{'request.course.sec'} eq $3) {
978: if (&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2.'/'.$3)) {
979: $allowed = 1;
980: }
981: }
982: }
983: }
984: $area=$carea;
985: } else {
986: $sortkey.="\0".$area;
987: # Determine if current user is able to revoke privileges
988: if ($area=~m{^/($match_domain)/}) {
989: if ((&Apache::lonnet::allowed('c'.$role_code,$1)) ||
990: (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
991: $allowed=1;
992: }
993: if (((&Apache::lonnet::allowed('dro',$1)) ||
994: (&Apache::lonnet::allowed('dro',$ccdomain))) &&
995: ($role_code ne 'dc')) {
996: $delallowed=1;
997: }
998: } else {
999: if (&Apache::lonnet::allowed('c'.$role_code,'/')) {
1000: $allowed=1;
1001: }
1002: }
1003: if ($role_code eq 'ca' || $role_code eq 'au') {
1004: $class='Construction Space';
1005: } elsif ($role_code eq 'su') {
1006: $class='System';
1007: } else {
1008: $class='Domain';
1009: }
1010: }
1011: if (($role_code eq 'ca') || ($role_code eq 'aa')) {
1012: $area=~m{/($match_domain)/($match_username)};
1013: if (&Apache::lonuserutils::authorpriv($2,$1)) {
1014: $allowed=1;
1015: } else {
1016: $allowed=0;
1017: }
1018: }
1019: my $row = '';
1020: $row.= '<td>';
1021: my $active=1;
1022: $active=0 if (($role_end_time) && ($now>$role_end_time));
1023: if (($active) && ($allowed)) {
1024: $row.= '<input type="checkbox" name="rev:'.$thisrole.'" />';
1025: } else {
1026: if ($active) {
1027: $row.=' ';
1028: } else {
1029: $row.=&mt('expired or revoked');
1030: }
1031: }
1032: $row.='</td><td>';
1033: if ($allowed && !$active) {
1034: $row.= '<input type="checkbox" name="ren:'.$thisrole.'" />';
1035: } else {
1036: $row.=' ';
1037: }
1038: $row.='</td><td>';
1039: if ($delallowed) {
1040: $row.= '<input type="checkbox" name="del:'.$thisrole.'" />';
1041: } else {
1042: $row.=' ';
1043: }
1044: my $plaintext='';
1045: if (!$croletitle) {
1046: $plaintext=&Apache::lonnet::plaintext($role_code,$class)
1047: } else {
1048: $plaintext=
1049: "Customrole '$croletitle'<br />defined by $croleuname\@$croleudom";
1050: }
1051: $row.= '</td><td>'.$plaintext.
1052: '</td><td>'.$area.
1053: '</td><td>'.($role_start_time?localtime($role_start_time)
1054: : ' ' ).
1055: '</td><td>'.($role_end_time ?localtime($role_end_time)
1056: : ' ' )
1057: ."</td>";
1058: $sortrole{$sortkey}=$envkey;
1059: $roletext{$envkey}=$row;
1060: $roleclass{$envkey}=$class;
1061: $rolepriv{$envkey}=$allowed;
1062: #$r->print($row);
1063: } # end of foreach (table building loop)
1064: my $rolesdisplay = 0;
1065: my %output = ();
1066: foreach my $type ('Construction Space','Course','Group','Domain','System','Unknown') {
1067: $output{$type} = '';
1068: foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
1069: if ( ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/ ) && ($rolepriv{$sortrole{$which}}) ) {
1070: $output{$type}.=
1071: &Apache::loncommon::start_data_table_row().
1072: $roletext{$sortrole{$which}}.
1073: &Apache::loncommon::end_data_table_row();
1074: }
1075: }
1076: unless($output{$type} eq '') {
1077: $output{$type} = '<tr class="LC_info_row">'.
1078: "<td align='center' colspan='7'>".&mt($type)."</td></tr>".
1079: $output{$type};
1080: $rolesdisplay = 1;
1081: }
1082: }
1083: if ($rolesdisplay == 1) {
1084: $r->print('
1085: <h3>'.$lt{'rer'}.'</h3>'.
1086: &Apache::loncommon::start_data_table("LC_createuser").
1087: &Apache::loncommon::start_data_table_header_row().
1088: '<th>'.$lt{'rev'}.'</th><th>'.$lt{'ren'}.'</th><th>'.$lt{'del'}.
1089: '</th><th>'.$lt{'rol'}.'</th><th>'.$lt{'ext'}.
1090: '</th><th>'.$lt{'sta'}.'</th><th>'.$lt{'end'}.'</th>'.
1091: &Apache::loncommon::end_data_table_header_row());
1092: foreach my $type ('Construction Space','Course','Group','Domain','System','Unknown') {
1093: if ($output{$type}) {
1094: $r->print($output{$type}."\n");
1095: }
1096: }
1097: $r->print(&Apache::loncommon::end_data_table());
1098: }
1099: } # End of check for keys in rolesdump
1100: return;
1101: }
1102:
1.218 raeburn 1103: sub new_coauthor_roles {
1104: my ($r,$ccuname,$ccdomain) = @_;
1105: my $addrolesdisplay = 0;
1106: #
1107: # Co-Author
1108: #
1109: if (&Apache::lonuserutils::authorpriv($env{'user.name'},
1110: $env{'request.role.domain'}) &&
1111: ($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain)) {
1112: # No sense in assigning co-author role to yourself
1113: $addrolesdisplay = 1;
1114: my $cuname=$env{'user.name'};
1115: my $cudom=$env{'request.role.domain'};
1116: my %lt=&Apache::lonlocal::texthash(
1117: 'cs' => "Construction Space",
1118: 'act' => "Activate",
1119: 'rol' => "Role",
1120: 'ext' => "Extent",
1121: 'sta' => "Start",
1122: 'end' => "End",
1123: 'cau' => "Co-Author",
1124: 'caa' => "Assistant Co-Author",
1125: 'ssd' => "Set Start Date",
1126: 'sed' => "Set End Date"
1127: );
1128: $r->print('<h4>'.$lt{'cs'}.'</h4>'."\n".
1129: &Apache::loncommon::start_data_table()."\n".
1130: &Apache::loncommon::start_data_table_header_row()."\n".
1131: '<th>'.$lt{'act'}.'</th><th>'.$lt{'rol'}.'</th>'.
1132: '<th>'.$lt{'ext'}.'</th><th>'.$lt{'sta'}.'</th>'.
1133: '<th>'.$lt{'end'}.'</th>'."\n".
1134: &Apache::loncommon::end_data_table_header_row()."\n".
1135: &Apache::loncommon::start_data_table_row().'
1136: <td>
1137: <input type=checkbox name="act_'.$cudom.'_'.$cuname.'_ca" />
1138: </td>
1139: <td>'.$lt{'cau'}.'</td>
1140: <td>'.$cudom.'_'.$cuname.'</td>
1141: <td><input type="hidden" name="start_'.$cudom.'_'.$cuname.'_ca" value="" />
1142: <a href=
1143: "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>
1144: <td><input type="hidden" name="end_'.$cudom.'_'.$cuname.'_ca" value="" />
1145: <a href=
1146: "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".
1147: &Apache::loncommon::end_data_table_row()."\n".
1148: &Apache::loncommon::start_data_table_row()."\n".
1149: '<td><input type=checkbox name="act_'.$cudom.'_'.$cuname.'_aa" /></td>
1150: <td>'.$lt{'caa'}.'</td>
1151: <td>'.$cudom.'_'.$cuname.'</td>
1152: <td><input type="hidden" name="start_'.$cudom.'_'.$cuname.'_aa" value="" />
1153: <a href=
1154: "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>
1155: <td><input type="hidden" name="end_'.$cudom.'_'.$cuname.'_aa" value="" />
1156: <a href=
1157: "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".
1158: &Apache::loncommon::end_data_table_row()."\n".
1159: &Apache::loncommon::end_data_table());
1160: } elsif ($env{'request.role'} =~ /^au\./) {
1161: if (!(&Apache::lonuserutils::authorpriv($env{'user.name'},
1162: $env{'request.role.domain'}))) {
1163: $r->print('<span class="LC_error">'.
1164: &mt('You do not have privileges to assign co-author roles.').
1165: '</span>');
1166: } elsif (($env{'user.name'} eq $ccuname) &&
1167: ($env{'user.domain'} eq $ccdomain)) {
1168: $r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Construction Space is not permitted'));
1169: }
1170: }
1171: return $addrolesdisplay;;
1172: }
1173:
1174: sub new_domain_roles {
1175: my ($r) = @_;
1176: my $addrolesdisplay = 0;
1177: #
1178: # Domain level
1179: #
1180: my $num_domain_level = 0;
1181: my $domaintext =
1182: '<h4>'.&mt('Domain Level').'</h4>'.
1183: &Apache::loncommon::start_data_table().
1184: &Apache::loncommon::start_data_table_header_row().
1185: '<th>'.&mt('Activate').'</th><th>'.&mt('Role').'</th><th>'.
1186: &mt('Extent').'</th>'.
1187: '<th>'.&mt('Start').'</th><th>'.&mt('End').'</th>'.
1188: &Apache::loncommon::end_data_table_header_row();
1189: foreach my $thisdomain (sort(&Apache::lonnet::all_domains())) {
1190: foreach my $role ('dc','li','dg','au','sc') {
1191: if (&Apache::lonnet::allowed('c'.$role,$thisdomain)) {
1192: my $plrole=&Apache::lonnet::plaintext($role);
1193: my %lt=&Apache::lonlocal::texthash(
1194: 'ssd' => "Set Start Date",
1195: 'sed' => "Set End Date"
1196: );
1197: $num_domain_level ++;
1198: $domaintext .=
1199: &Apache::loncommon::start_data_table_row().
1200: '<td><input type=checkbox name="act_'.$thisdomain.'_'.$role.'" /></td>
1201: <td>'.$plrole.'</td>
1202: <td>'.$thisdomain.'</td>
1203: <td><input type="hidden" name="start_'.$thisdomain.'_'.$role.'" value="" />
1204: <a href=
1205: "javascript:pjump('."'date_start','Start Date $plrole',document.cu.start_$thisdomain\_$role.value,'start_$thisdomain\_$role','cu.pres','dateset'".')">'.$lt{'ssd'}.'</a></td>
1206: <td><input type="hidden" name="end_'.$thisdomain.'_'.$role.'" value="" />
1207: <a href=
1208: "javascript:pjump('."'date_end','End Date $plrole',document.cu.end_$thisdomain\_$role.value,'end_$thisdomain\_$role','cu.pres','dateset'".')">'.$lt{'sed'}.'</a></td>'.
1209: &Apache::loncommon::end_data_table_row();
1210: }
1211: }
1212: }
1213: $domaintext.= &Apache::loncommon::end_data_table();
1214: if ($num_domain_level > 0) {
1215: $r->print($domaintext);
1216: $addrolesdisplay = 1;
1217: }
1218: return $addrolesdisplay;
1219: }
1220:
1.188 raeburn 1221: sub user_authentication {
1.227 ! raeburn 1222: my ($ccuname,$ccdomain,$formname) = @_;
1.188 raeburn 1223: my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain);
1.227 ! raeburn 1224: my $outcome;
1.188 raeburn 1225: # Check for a bad authentication type
1226: if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth):/) {
1227: # bad authentication scheme
1228: my %lt=&Apache::lonlocal::texthash(
1229: 'err' => "ERROR",
1230: 'uuas' => "This user has an unrecognized authentication scheme",
1231: 'adcs' => "Please alert a domain coordinator of this situation",
1232: 'sldb' => "Please specify login data below",
1233: 'ld' => "Login Data"
1234: );
1235: if (&Apache::lonnet::allowed('mau',$ccdomain)) {
1.227 ! raeburn 1236: &initialize_authen_forms($ccdomain,$formname);
! 1237:
1.190 raeburn 1238: my $choices = &Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc);
1.188 raeburn 1239: $outcome = <<ENDBADAUTH;
1240: <script type="text/javascript" language="Javascript">
1241: $loginscript
1242: </script>
1243: <span class="LC_error">$lt{'err'}:
1244: $lt{'uuas'} ($currentauth). $lt{'sldb'}.</span>
1245: <h3>$lt{'ld'}</h3>
1246: $choices
1247: ENDBADAUTH
1248: } else {
1249: # This user is not allowed to modify the user's
1250: # authentication scheme, so just notify them of the problem
1251: $outcome = <<ENDBADAUTH;
1252: <span class="LC_error"> $lt{'err'}:
1253: $lt{'uuas'} ($currentauth). $lt{'adcs'}.
1254: </span>
1255: ENDBADAUTH
1256: }
1257: } else { # Authentication type is valid
1.227 ! raeburn 1258: &initialize_authen_forms($ccdomain,$formname,$currentauth,'modifyuser');
1.205 raeburn 1259: my ($authformcurrent,$can_modify,@authform_others) =
1.188 raeburn 1260: &modify_login_block($ccdomain,$currentauth);
1261: if (&Apache::lonnet::allowed('mau',$ccdomain)) {
1262: # Current user has login modification privileges
1263: my %lt=&Apache::lonlocal::texthash (
1264: 'ld' => "Login Data",
1265: 'ccld' => "Change Current Login Data",
1266: 'enld' => "Enter New Login Data"
1267: );
1268: $outcome =
1269: '<script type="text/javascript" language="Javascript">'."\n".
1270: $loginscript."\n".
1271: '</script>'."\n".
1272: '<h3>'.$lt{'ld'}.'</h3>'.
1273: &Apache::loncommon::start_data_table().
1.205 raeburn 1274: &Apache::loncommon::start_data_table_row().
1.188 raeburn 1275: '<td>'.$authformnop;
1276: if ($can_modify) {
1277: $outcome .= '</td>'."\n".
1278: &Apache::loncommon::end_data_table_row().
1279: &Apache::loncommon::start_data_table_row().
1280: '<td>'.$authformcurrent.'</td>'.
1281: &Apache::loncommon::end_data_table_row()."\n";
1282: } else {
1.200 raeburn 1283: $outcome .= ' ('.$authformcurrent.')</td>'.
1284: &Apache::loncommon::end_data_table_row()."\n";
1.188 raeburn 1285: }
1.205 raeburn 1286: foreach my $item (@authform_others) {
1287: $outcome .= &Apache::loncommon::start_data_table_row().
1288: '<td>'.$item.'</td>'.
1289: &Apache::loncommon::end_data_table_row()."\n";
1.188 raeburn 1290: }
1.205 raeburn 1291: $outcome .= &Apache::loncommon::end_data_table();
1.188 raeburn 1292: } else {
1293: if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) {
1294: my %lt=&Apache::lonlocal::texthash(
1295: 'ccld' => "Change Current Login Data",
1296: 'yodo' => "You do not have privileges to modify the authentication configuration for this user.",
1297: 'ifch' => "If a change is required, contact a domain coordinator for the domain",
1298: );
1299: $outcome .= <<ENDNOPRIV;
1300: <h3>$lt{'ccld'}</h3>
1301: $lt{'yodo'} $lt{'ifch'}: $ccdomain
1302: ENDNOPRIV
1303: }
1304: }
1305: } ## End of "check for bad authentication type" logic
1306: return $outcome;
1307: }
1308:
1.187 raeburn 1309: sub modify_login_block {
1310: my ($dom,$currentauth) = @_;
1311: my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom);
1312: my ($authnum,%can_assign) =
1313: &Apache::loncommon::get_assignable_auth($dom);
1.205 raeburn 1314: my ($authformcurrent,@authform_others,$show_override_msg);
1.187 raeburn 1315: if ($currentauth=~/^krb(4|5):/) {
1316: $authformcurrent=$authformkrb;
1317: if ($can_assign{'int'}) {
1.205 raeburn 1318: push(@authform_others,$authformint);
1.187 raeburn 1319: }
1320: if ($can_assign{'loc'}) {
1.205 raeburn 1321: push(@authform_others,$authformloc);
1.187 raeburn 1322: }
1323: if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) {
1324: $show_override_msg = 1;
1325: }
1326: } elsif ($currentauth=~/^internal:/) {
1327: $authformcurrent=$authformint;
1328: if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) {
1.205 raeburn 1329: push(@authform_others,$authformkrb);
1.187 raeburn 1330: }
1331: if ($can_assign{'loc'}) {
1.205 raeburn 1332: push(@authform_others,$authformloc);
1.187 raeburn 1333: }
1334: if ($can_assign{'int'}) {
1335: $show_override_msg = 1;
1336: }
1337: } elsif ($currentauth=~/^unix:/) {
1338: $authformcurrent=$authformfsys;
1339: if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) {
1.205 raeburn 1340: push(@authform_others,$authformkrb);
1.187 raeburn 1341: }
1342: if ($can_assign{'int'}) {
1.205 raeburn 1343: push(@authform_others,$authformint);
1.187 raeburn 1344: }
1345: if ($can_assign{'loc'}) {
1.205 raeburn 1346: push(@authform_others,$authformloc);
1.187 raeburn 1347: }
1348: if ($can_assign{'fsys'}) {
1349: $show_override_msg = 1;
1350: }
1351: } elsif ($currentauth=~/^localauth:/) {
1352: $authformcurrent=$authformloc;
1353: if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) {
1.205 raeburn 1354: push(@authform_others,$authformkrb);
1.187 raeburn 1355: }
1356: if ($can_assign{'int'}) {
1.205 raeburn 1357: push(@authform_others,$authformint);
1.187 raeburn 1358: }
1359: if ($can_assign{'loc'}) {
1360: $show_override_msg = 1;
1361: }
1362: }
1363: if ($show_override_msg) {
1.205 raeburn 1364: $authformcurrent = '<table><tr><td colspan="3">'.$authformcurrent.
1365: '</td></tr>'."\n".
1366: '<tr><td> </td>'.
1367: '<td><b>'.&mt('Currently in use').'</b></td>'.
1368: '<td align="right"><span class="LC_cusr_emph">'.
1.187 raeburn 1369: &mt('will override current values').
1.205 raeburn 1370: '</span></td></tr></table>';
1.187 raeburn 1371: }
1.205 raeburn 1372: return ($authformcurrent,$show_override_msg,@authform_others);
1.187 raeburn 1373: }
1374:
1.188 raeburn 1375: sub personal_data_display {
1.210 raeburn 1376: my ($ccuname,$ccdomain,$newuser,$context,$inst_results) = @_;
1.219 raeburn 1377: my ($output,$showforceid,%userenv,%canmodify);
1378: my @userinfo = ('firstname','middlename','lastname','generation',
1379: 'permanentemail','id');
1.188 raeburn 1380: if (!$newuser) {
1381: # Get the users information
1382: %userenv = &Apache::lonnet::get('environment',
1383: ['firstname','middlename','lastname','generation',
1384: 'permanentemail','id'],$ccdomain,$ccuname);
1.219 raeburn 1385: %canmodify =
1386: &Apache::lonuserutils::can_modify_userinfo($context,$ccdomain,
1387: \@userinfo);
1.188 raeburn 1388: }
1389: my %lt=&Apache::lonlocal::texthash(
1390: 'pd' => "Personal Data",
1391: 'firstname' => "First Name",
1392: 'middlename' => "Middle Name",
1393: 'lastname' => "Last Name",
1394: 'generation' => "Generation",
1395: 'permanentemail' => "Permanent e-mail address",
1396: 'id' => "ID/Student Number",
1397: 'lg' => "Login Data"
1398: );
1399: my %textboxsize = (
1400: firstname => '15',
1401: middlename => '15',
1402: lastname => '15',
1403: generation => '5',
1404: permanentemail => '25',
1405: id => '15',
1406: );
1407: my $genhelp=&Apache::loncommon::help_open_topic('Generation');
1408: $output = '<h3>'.$lt{'pd'}.'</h3>'.
1409: &Apache::lonhtmlcommon::start_pick_box();
1410: foreach my $item (@userinfo) {
1411: my $rowtitle = $lt{$item};
1412: if ($item eq 'generation') {
1413: $rowtitle = $genhelp.$rowtitle;
1414: }
1415: $output .= &Apache::lonhtmlcommon::row_title($rowtitle,undef,'LC_oddrow_value')."\n";
1416: if ($newuser) {
1.210 raeburn 1417: if (ref($inst_results) eq 'HASH') {
1418: if ($inst_results->{$item} ne '') {
1419: $output .= '<input type="hidden" name="c'.$item.'" value="'.$inst_results->{$item}.'" />'.$inst_results->{$item};
1420: } else {
1421: $output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />';
1422: }
1.188 raeburn 1423: } else {
1424: $output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />';
1425: }
1426: } else {
1.219 raeburn 1427: if ($canmodify{$item}) {
1.188 raeburn 1428: $output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="'.$userenv{$item}.'" />';
1429: } else {
1430: $output .= $userenv{$item};
1431: }
1.206 raeburn 1432: if ($item eq 'id') {
1.219 raeburn 1433: $showforceid = $canmodify{$item};
1434: }
1.188 raeburn 1435: }
1436: $output .= &Apache::lonhtmlcommon::row_closure(1);
1437: }
1438: $output .= &Apache::lonhtmlcommon::end_pick_box();
1.206 raeburn 1439: if (wantarray) {
1440: return ($output,$showforceid);
1441: } else {
1442: return $output;
1443: }
1.188 raeburn 1444: }
1445:
1.4 www 1446: # ================================================================= Phase Three
1.42 matthew 1447: sub update_user_data {
1.206 raeburn 1448: my ($r,$context) = @_;
1.101 albertel 1449: my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'},
1450: $env{'form.ccdomain'});
1.27 matthew 1451: # Error messages
1.188 raeburn 1452: my $error = '<span class="LC_error">'.&mt('Error').': ';
1.193 raeburn 1453: my $end = '</span><br /><br />';
1454: my $rtnlink = '<a href="javascript:backPage(document.userupdate,'.
1.188 raeburn 1455: "'$env{'form.prevphase'}','modify')".'" />'.
1.219 raeburn 1456: &mt('Return to previous page').'</a>'.
1457: &Apache::loncommon::end_page();
1458: my $now = time;
1.40 www 1459: my $title;
1.101 albertel 1460: if (exists($env{'form.makeuser'})) {
1.40 www 1461: $title='Set Privileges for New User';
1462: } else {
1463: $title='Modify User Privileges';
1464: }
1.213 raeburn 1465: my $newuser = 0;
1.160 raeburn 1466: my ($jsback,$elements) = &crumb_utilities();
1467: my $jscript = '<script type="text/javascript">'."\n".
1468: $jsback."\n".'</script>'."\n";
1.213 raeburn 1469: my %breadcrumb_text = &singleuser_breadcrumb();
1.160 raeburn 1470: $r->print(&Apache::loncommon::start_page($title,$jscript));
1471: &Apache::lonhtmlcommon::add_breadcrumb
1472: ({href=>"javascript:backPage(document.userupdate)",
1.213 raeburn 1473: text=>$breadcrumb_text{'search'},
1.160 raeburn 1474: faq=>282,bug=>'Instructor Interface',});
1475: if ($env{'form.prevphase'} eq 'userpicked') {
1476: &Apache::lonhtmlcommon::add_breadcrumb
1477: ({href=>"javascript:backPage(document.userupdate,'get_user_info','select')",
1.213 raeburn 1478: text=>$breadcrumb_text{'userpicked'},
1.160 raeburn 1479: faq=>282,bug=>'Instructor Interface',});
1480: }
1481: &Apache::lonhtmlcommon::add_breadcrumb
1482: ({href=>"javascript:backPage(document.userupdate,'$env{'form.prevphase'}','modify')",
1.219 raeburn 1483: text=>$breadcrumb_text{'modify'},
1.160 raeburn 1484: faq=>282,bug=>'Instructor Interface',},
1485: {href=>"/adm/createuser",
1486: text=>"Result",
1487: faq=>282,bug=>'Instructor Interface',});
1.224 raeburn 1488: my $helpitem = 'Course_Change_Privileges';
1489: if ($env{'form.action'} eq 'singlestudent') {
1490: $helpitem = 'Course_Add_Student';
1491: }
1492: $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
1493: $helpitem));
1.188 raeburn 1494: $r->print(&update_result_form($uhome));
1.27 matthew 1495: # Check Inputs
1.101 albertel 1496: if (! $env{'form.ccuname'} ) {
1.193 raeburn 1497: $r->print($error.&mt('No login name specified').'.'.$end.$rtnlink);
1.27 matthew 1498: return;
1499: }
1.138 albertel 1500: if ( $env{'form.ccuname'} ne
1501: &LONCAPA::clean_username($env{'form.ccuname'}) ) {
1.73 sakharuk 1502: $r->print($error.&mt('Invalid login name').'. '.
1.160 raeburn 1503: &mt('Only letters, numbers, periods, dashes, @, and underscores are valid').'.'.
1.193 raeburn 1504: $end.$rtnlink);
1.27 matthew 1505: return;
1506: }
1.101 albertel 1507: if (! $env{'form.ccdomain'} ) {
1.193 raeburn 1508: $r->print($error.&mt('No domain specified').'.'.$end.$rtnlink);
1.27 matthew 1509: return;
1510: }
1.138 albertel 1511: if ( $env{'form.ccdomain'} ne
1512: &LONCAPA::clean_domain($env{'form.ccdomain'}) ) {
1.73 sakharuk 1513: $r->print($error.&mt ('Invalid domain name').'. '.
1.138 albertel 1514: &mt('Only letters, numbers, periods, dashes, and underscores are valid').'.'.
1.193 raeburn 1515: $end.$rtnlink);
1.27 matthew 1516: return;
1517: }
1.219 raeburn 1518: if ($uhome eq 'no_host') {
1519: $newuser = 1;
1520: }
1.101 albertel 1521: if (! exists($env{'form.makeuser'})) {
1.29 matthew 1522: # Modifying an existing user, so check the validity of the name
1523: if ($uhome eq 'no_host') {
1.73 sakharuk 1524: $r->print($error.&mt('Unable to determine home server for ').
1.101 albertel 1525: $env{'form.ccuname'}.&mt(' in domain ').
1526: $env{'form.ccdomain'}.'.');
1.29 matthew 1527: return;
1528: }
1529: }
1.27 matthew 1530: # Determine authentication method and password for the user being modified
1531: my $amode='';
1532: my $genpwd='';
1.101 albertel 1533: if ($env{'form.login'} eq 'krb') {
1.41 albertel 1534: $amode='krb';
1.101 albertel 1535: $amode.=$env{'form.krbver'};
1536: $genpwd=$env{'form.krbarg'};
1537: } elsif ($env{'form.login'} eq 'int') {
1.27 matthew 1538: $amode='internal';
1.101 albertel 1539: $genpwd=$env{'form.intarg'};
1540: } elsif ($env{'form.login'} eq 'fsys') {
1.27 matthew 1541: $amode='unix';
1.101 albertel 1542: $genpwd=$env{'form.fsysarg'};
1543: } elsif ($env{'form.login'} eq 'loc') {
1.27 matthew 1544: $amode='localauth';
1.101 albertel 1545: $genpwd=$env{'form.locarg'};
1.27 matthew 1546: $genpwd=" " if (!$genpwd);
1.101 albertel 1547: } elsif (($env{'form.login'} eq 'nochange') ||
1548: ($env{'form.login'} eq '' )) {
1.34 matthew 1549: # There is no need to tell the user we did not change what they
1550: # did not ask us to change.
1.35 matthew 1551: # If they are creating a new user but have not specified login
1552: # information this will be caught below.
1.30 matthew 1553: } else {
1.193 raeburn 1554: $r->print($error.&mt('Invalid login mode or password').$end.$rtnlink);
1.30 matthew 1555: return;
1.27 matthew 1556: }
1.164 albertel 1557:
1.188 raeburn 1558: $r->print('<h3>'.&mt('User [_1] in domain [_2]',
1559: $env{'form.ccuname'}, $env{'form.ccdomain'}).'</h3>');
1.193 raeburn 1560: my (%alerts,%rulematch,%inst_results,%curr_rules);
1.101 albertel 1561: if ($env{'form.makeuser'}) {
1.164 albertel 1562: $r->print('<h3>'.&mt('Creating new account.').'</h3>');
1.27 matthew 1563: # Check for the authentication mode and password
1564: if (! $amode || ! $genpwd) {
1.193 raeburn 1565: $r->print($error.&mt('Invalid login mode or password').$end.$rtnlink);
1.27 matthew 1566: return;
1.18 albertel 1567: }
1.29 matthew 1568: # Determine desired host
1.101 albertel 1569: my $desiredhost = $env{'form.hserver'};
1.29 matthew 1570: if (lc($desiredhost) eq 'default') {
1571: $desiredhost = undef;
1572: } else {
1.147 albertel 1573: my %home_servers =
1574: &Apache::lonnet::get_servers($env{'form.ccdomain'},'library');
1.29 matthew 1575: if (! exists($home_servers{$desiredhost})) {
1.193 raeburn 1576: $r->print($error.&mt('Invalid home server specified').$end.$rtnlink);
1577: return;
1578: }
1579: }
1580: # Check ID format
1581: my %checkhash;
1582: my %checks = ('id' => 1);
1583: %{$checkhash{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}}} = (
1.219 raeburn 1584: 'newuser' => $newuser,
1.196 raeburn 1585: 'id' => $env{'form.cid'},
1.193 raeburn 1586: );
1.196 raeburn 1587: if ($env{'form.cid'} ne '') {
1588: &Apache::loncommon::user_rule_check(\%checkhash,\%checks,\%alerts,
1589: \%rulematch,\%inst_results,\%curr_rules);
1590: if (ref($alerts{'id'}) eq 'HASH') {
1591: if (ref($alerts{'id'}{$env{'form.ccdomain'}}) eq 'HASH') {
1592: my $domdesc =
1593: &Apache::lonnet::domain($env{'form.ccdomain'},'description');
1594: if ($alerts{'id'}{$env{'form.ccdomain'}}{$env{'form.cid'}}) {
1595: my $userchkmsg;
1596: if (ref($curr_rules{$env{'form.ccdomain'}}) eq 'HASH') {
1597: $userchkmsg =
1598: &Apache::loncommon::instrule_disallow_msg('id',
1599: $domdesc,1).
1600: &Apache::loncommon::user_rule_formats($env{'form.ccdomain'},
1601: $domdesc,$curr_rules{$env{'form.ccdomain'}}{'id'},'id');
1602: }
1603: $r->print($error.&mt('Invalid ID format').$end.
1604: $userchkmsg.$rtnlink);
1605: return;
1606: }
1607: }
1.29 matthew 1608: }
1609: }
1.27 matthew 1610: # Call modifyuser
1611: my $result = &Apache::lonnet::modifyuser
1.193 raeburn 1612: ($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cid'},
1.188 raeburn 1613: $amode,$genpwd,$env{'form.cfirstname'},
1614: $env{'form.cmiddlename'},$env{'form.clastname'},
1615: $env{'form.cgeneration'},undef,$desiredhost,
1616: $env{'form.cpermanentemail'});
1.77 www 1617: $r->print(&mt('Generating user').': '.$result);
1.219 raeburn 1618: $uhome = &Apache::lonnet::homeserver($env{'form.ccuname'},
1.101 albertel 1619: $env{'form.ccdomain'});
1.219 raeburn 1620: $r->print('<br />'.&mt('Home server').': '.$uhome.' '.
1621: &Apache::lonnet::hostname($uhome));
1.101 albertel 1622: } elsif (($env{'form.login'} ne 'nochange') &&
1623: ($env{'form.login'} ne '' )) {
1.27 matthew 1624: # Modify user privileges
1625: if (! $amode || ! $genpwd) {
1.193 raeburn 1626: $r->print($error.'Invalid login mode or password'.$end.$rtnlink);
1.27 matthew 1627: return;
1.20 harris41 1628: }
1.27 matthew 1629: # Only allow authentification modification if the person has authority
1.101 albertel 1630: if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
1.20 harris41 1631: $r->print('Modifying authentication: '.
1.31 matthew 1632: &Apache::lonnet::modifyuserauth(
1.101 albertel 1633: $env{'form.ccdomain'},$env{'form.ccuname'},
1.21 harris41 1634: $amode,$genpwd));
1.102 albertel 1635: $r->print('<br />'.&mt('Home server').': '.&Apache::lonnet::homeserver
1.101 albertel 1636: ($env{'form.ccuname'},$env{'form.ccdomain'}));
1.4 www 1637: } else {
1.27 matthew 1638: # Okay, this is a non-fatal error.
1.193 raeburn 1639: $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.'.$end);
1.27 matthew 1640: }
1.28 matthew 1641: }
1642: ##
1.213 raeburn 1643: my (@userroles,%userupdate,$cnum,$cdom,$namechanged);
1644: if ($context eq 'course') {
1645: ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity();
1646: }
1.101 albertel 1647: if (! $env{'form.makeuser'} ) {
1.28 matthew 1648: # Check for need to change
1649: my %userenv = &Apache::lonnet::get
1.134 raeburn 1650: ('environment',['firstname','middlename','lastname','generation',
1.196 raeburn 1651: 'id','permanentemail','portfolioquota','inststatus'],
1.160 raeburn 1652: $env{'form.ccdomain'},$env{'form.ccuname'});
1.28 matthew 1653: my ($tmp) = keys(%userenv);
1654: if ($tmp =~ /^(con_lost|error)/i) {
1655: %userenv = ();
1656: }
1.206 raeburn 1657: my $no_forceid_alert;
1658: # Check to see if user information can be changed
1659: my %domconfig =
1660: &Apache::lonnet::get_dom('configuration',['usermodification'],
1661: $env{'form.ccdomain'});
1.213 raeburn 1662: my @statuses = ('active','future');
1663: my %roles = &Apache::lonnet::get_my_roles($env{'form.ccuname'},$env{'form.ccdomain'},'userroles',\@statuses,undef,$env{'request.role.domain'});
1664: my ($auname,$audom);
1.220 raeburn 1665: if ($context eq 'author') {
1.206 raeburn 1666: $auname = $env{'user.name'};
1667: $audom = $env{'user.domain'};
1668: }
1669: foreach my $item (keys(%roles)) {
1.220 raeburn 1670: my ($rolenum,$roledom,$role) = split(/:/,$item,-1);
1.206 raeburn 1671: if ($context eq 'course') {
1672: if ($cnum ne '' && $cdom ne '') {
1673: if ($rolenum eq $cnum && $roledom eq $cdom) {
1674: if (!grep(/^\Q$role\E$/,@userroles)) {
1675: push(@userroles,$role);
1676: }
1677: }
1678: }
1679: } elsif ($context eq 'author') {
1680: if ($rolenum eq $auname && $roledom eq $audom) {
1681: if (!grep(/^\Q$role\E$/,@userroles)) {
1682: push(@userroles,$role);
1683: }
1684: }
1685: }
1686: }
1.220 raeburn 1687: if ($env{'form.action'} eq 'singlestudent') {
1688: if (!grep(/^st$/,@userroles)) {
1689: push(@userroles,'st');
1690: }
1691: } else {
1692: # Check for course or co-author roles being activated or re-enabled
1693: if ($context eq 'author' || $context eq 'course') {
1694: foreach my $key (keys(%env)) {
1695: if ($context eq 'author') {
1696: if ($key=~/^form\.act_\Q$audom\E_\Q$auname\E_([^_]+)/) {
1697: if (!grep(/^\Q$1\E$/,@userroles)) {
1698: push(@userroles,$1);
1699: }
1700: } elsif ($key =~/^form\.ren\:\Q$audom\E\/\Q$auname\E_([^_]+)/) {
1701: if (!grep(/^\Q$1\E$/,@userroles)) {
1702: push(@userroles,$1);
1703: }
1.206 raeburn 1704: }
1.220 raeburn 1705: } elsif ($context eq 'course') {
1706: if ($key=~/^form\.act_\Q$cdom\E_\Q$cnum\E_([^_]+)/) {
1707: if (!grep(/^\Q$1\E$/,@userroles)) {
1708: push(@userroles,$1);
1709: }
1710: } elsif ($key =~/^form\.ren\:\Q$cdom\E\/\Q$cnum\E(\/?\w*)_([^_]+)/) {
1711: if (!grep(/^\Q$1\E$/,@userroles)) {
1712: push(@userroles,$1);
1713: }
1.206 raeburn 1714: }
1715: }
1716: }
1717: }
1718: }
1719: #Check to see if we can change personal data for the user
1720: my (@mod_disallowed,@longroles);
1721: foreach my $role (@userroles) {
1722: if ($role eq 'cr') {
1723: push(@longroles,'Custom');
1724: } else {
1725: push(@longroles,&Apache::lonnet::plaintext($role));
1726: }
1727: }
1.219 raeburn 1728: my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
1729: my %canmodify = &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},\@userinfo,\@userroles);
1730: foreach my $item (@userinfo) {
1.28 matthew 1731: # Strip leading and trailing whitespace
1.203 raeburn 1732: $env{'form.c'.$item} =~ s/(\s+$|^\s+)//g;
1.219 raeburn 1733: if (!$canmodify{$item}) {
1.207 raeburn 1734: if (defined($env{'form.c'.$item})) {
1735: if ($env{'form.c'.$item} ne $userenv{$item}) {
1736: push(@mod_disallowed,$item);
1737: }
1.206 raeburn 1738: }
1739: $env{'form.c'.$item} = $userenv{$item};
1740: }
1.28 matthew 1741: }
1.196 raeburn 1742: # Check to see if we can change the ID/student number
1743: my $forceid = $env{'form.forceid'};
1744: my $recurseid = $env{'form.recurseid'};
1745: my (%alerts,%rulematch,%idinst_results,%curr_rules,%got_rules);
1.203 raeburn 1746: my %uidhash = &Apache::lonnet::idrget($env{'form.ccdomain'},
1747: $env{'form.ccuname'});
1748: if (($uidhash{$env{'form.ccuname'}}) &&
1749: ($uidhash{$env{'form.ccuname'}}!~/error\:/) &&
1750: (!$forceid)) {
1751: if ($env{'form.cid'} ne $uidhash{$env{'form.ccuname'}}) {
1752: $env{'form.cid'} = $userenv{'id'};
1.206 raeburn 1753: $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 1754: }
1755: }
1756: if ($env{'form.cid'} ne $userenv{'id'}) {
1.196 raeburn 1757: my $checkhash;
1758: my $checks = { 'id' => 1 };
1759: $checkhash->{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}} =
1760: { 'newuser' => $newuser,
1761: 'id' => $env{'form.cid'},
1762: };
1763: &Apache::loncommon::user_rule_check($checkhash,$checks,
1764: \%alerts,\%rulematch,\%idinst_results,\%curr_rules,\%got_rules);
1765: if (ref($alerts{'id'}) eq 'HASH') {
1766: if (ref($alerts{'id'}{$env{'form.ccdomain'}}) eq 'HASH') {
1.203 raeburn 1767: $env{'form.cid'} = $userenv{'id'};
1.196 raeburn 1768: }
1769: }
1770: }
1.213 raeburn 1771: my ($quotachanged,$oldportfolioquota,$newportfolioquota,
1.204 raeburn 1772: $inststatus,$oldisdefault,$newisdefault,$olddefquotatext,
1773: $newdefquotatext);
1.149 raeburn 1774: my ($defquota,$settingstatus) =
1775: &Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus);
1.220 raeburn 1776: my $showquota;
1777: if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
1778: $showquota = 1;
1779: }
1.134 raeburn 1780: my %changeHash;
1.204 raeburn 1781: $changeHash{'portfolioquota'} = $userenv{'portfolioquota'};
1.149 raeburn 1782: if ($userenv{'portfolioquota'} ne '') {
1.134 raeburn 1783: $oldportfolioquota = $userenv{'portfolioquota'};
1.149 raeburn 1784: if ($env{'form.customquota'} == 1) {
1785: if ($env{'form.portfolioquota'} eq '') {
1786: $newportfolioquota = 0;
1787: } else {
1788: $newportfolioquota = $env{'form.portfolioquota'};
1789: $newportfolioquota =~ s/[^\d\.]//g;
1790: }
1.204 raeburn 1791: if ($newportfolioquota != $oldportfolioquota) {
1.149 raeburn 1792: $quotachanged = "a_admin($newportfolioquota,\%changeHash);
1.134 raeburn 1793: }
1.149 raeburn 1794: } else {
1795: $quotachanged = "a_admin('',\%changeHash);
1796: $newportfolioquota = $defquota;
1.204 raeburn 1797: $newisdefault = 1;
1.134 raeburn 1798: }
1799: } else {
1.204 raeburn 1800: $oldisdefault = 1;
1.149 raeburn 1801: $oldportfolioquota = $defquota;
1802: if ($env{'form.customquota'} == 1) {
1803: if ($env{'form.portfolioquota'} eq '') {
1804: $newportfolioquota = 0;
1805: } else {
1806: $newportfolioquota = $env{'form.portfolioquota'};
1807: $newportfolioquota =~ s/[^\d\.]//g;
1808: }
1809: $quotachanged = "a_admin($newportfolioquota,\%changeHash);
1810: } else {
1811: $newportfolioquota = $defquota;
1.204 raeburn 1812: $newisdefault = 1;
1.149 raeburn 1813: }
1814: }
1.204 raeburn 1815: if ($oldisdefault) {
1816: $olddefquotatext = &get_defaultquota_text($settingstatus);
1817: }
1818: if ($newisdefault) {
1819: $newdefquotatext = &get_defaultquota_text($settingstatus);
1.134 raeburn 1820: }
1.206 raeburn 1821: if ($env{'form.cfirstname'} ne $userenv{'firstname'} ||
1822: $env{'form.cmiddlename'} ne $userenv{'middlename'} ||
1823: $env{'form.clastname'} ne $userenv{'lastname'} ||
1824: $env{'form.cgeneration'} ne $userenv{'generation'} ||
1825: $env{'form.cid'} ne $userenv{'id'} ||
1826: $env{'form.cpermanentemail'} ne $userenv{'permanentemail'} ) {
1.134 raeburn 1827: $namechanged = 1;
1828: }
1.204 raeburn 1829: if ($namechanged || $quotachanged) {
1.101 albertel 1830: $changeHash{'firstname'} = $env{'form.cfirstname'};
1831: $changeHash{'middlename'} = $env{'form.cmiddlename'};
1832: $changeHash{'lastname'} = $env{'form.clastname'};
1833: $changeHash{'generation'} = $env{'form.cgeneration'};
1.196 raeburn 1834: $changeHash{'id'} = $env{'form.cid'};
1.174 raeburn 1835: $changeHash{'permanentemail'} = $env{'form.cpermanentemail'};
1.204 raeburn 1836: my ($quotachgresult,$namechgresult);
1837: if ($quotachanged) {
1838: $quotachgresult =
1839: &Apache::lonnet::put('environment',\%changeHash,
1840: $env{'form.ccdomain'},$env{'form.ccuname'});
1841: }
1842: if ($namechanged) {
1843: # Make the change
1844: $namechgresult =
1845: &Apache::lonnet::modifyuser($env{'form.ccdomain'},
1846: $env{'form.ccuname'},$changeHash{'id'},undef,undef,
1847: $changeHash{'firstname'},$changeHash{'middlename'},
1848: $changeHash{'lastname'},$changeHash{'generation'},
1849: $changeHash{'id'},undef,$changeHash{'permanentemail'});
1.220 raeburn 1850: %userupdate = (
1851: lastname => $env{'form.clastname'},
1852: middlename => $env{'form.cmiddlename'},
1853: firstname => $env{'form.cfirstname'},
1854: generation => $env{'form.cgeneration'},
1855: id => $env{'form.cid'},
1856: );
1.204 raeburn 1857: }
1858: if (($namechanged && $namechgresult eq 'ok') ||
1859: ($quotachanged && $quotachgresult eq 'ok')) {
1.28 matthew 1860: # Tell the user we changed the name
1.73 sakharuk 1861: my %lt=&Apache::lonlocal::texthash(
1862: 'uic' => "User Information Changed",
1863: 'frst' => "first",
1864: 'mddl' => "middle",
1865: 'lst' => "last",
1866: 'gen' => "generation",
1.196 raeburn 1867: 'id' => "ID/Student number",
1.160 raeburn 1868: 'mail' => "permanent e-mail",
1.134 raeburn 1869: 'disk' => "disk space allocated to portfolio files",
1.73 sakharuk 1870: 'prvs' => "Previous",
1871: 'chto' => "Changed To"
1872: );
1.201 raeburn 1873: $r->print('<h4>'.$lt{'uic'}.'</h4>'.
1874: &Apache::loncommon::start_data_table().
1875: &Apache::loncommon::start_data_table_header_row());
1.28 matthew 1876: $r->print(<<"END");
1.201 raeburn 1877: <th> </th>
1.73 sakharuk 1878: <th>$lt{'frst'}</th>
1879: <th>$lt{'mddl'}</th>
1880: <th>$lt{'lst'}</th>
1.134 raeburn 1881: <th>$lt{'gen'}</th>
1.196 raeburn 1882: <th>$lt{'id'}</th>
1.173 raeburn 1883: <th>$lt{'mail'}</th>
1.201 raeburn 1884: END
1.220 raeburn 1885: if ($showquota) {
1886: $r->print("
1887: <th>$lt{'disk'}</th>\n");
1888: }
1.201 raeburn 1889: $r->print(&Apache::loncommon::end_data_table_header_row().
1890: &Apache::loncommon::start_data_table_row());
1891: $r->print(<<"END");
1892: <td><b>$lt{'prvs'}</b></td>
1.28 matthew 1893: <td>$userenv{'firstname'} </td>
1894: <td>$userenv{'middlename'} </td>
1895: <td>$userenv{'lastname'} </td>
1.134 raeburn 1896: <td>$userenv{'generation'} </td>
1.196 raeburn 1897: <td>$userenv{'id'}</td>
1.160 raeburn 1898: <td>$userenv{'permanentemail'} </td>
1.201 raeburn 1899: END
1.220 raeburn 1900: if ($showquota) {
1901: $r->print("
1902: <td>$oldportfolioquota Mb $olddefquotatext </td>\n");
1903: }
1.201 raeburn 1904: $r->print(&Apache::loncommon::end_data_table_row().
1905: &Apache::loncommon::start_data_table_row());
1906: $r->print(<<"END");
1907: <td><b>$lt{'chto'}</b></td>
1.101 albertel 1908: <td>$env{'form.cfirstname'} </td>
1909: <td>$env{'form.cmiddlename'} </td>
1910: <td>$env{'form.clastname'} </td>
1.134 raeburn 1911: <td>$env{'form.cgeneration'} </td>
1.196 raeburn 1912: <td>$env{'form.cid'} </td>
1.160 raeburn 1913: <td>$env{'form.cpermanentemail'} </td>
1.28 matthew 1914: END
1.220 raeburn 1915: if ($showquota) {
1916: $r->print("
1917: <td>$newportfolioquota Mb $newdefquotatext </td>\n");
1918: }
1.201 raeburn 1919: $r->print(&Apache::loncommon::end_data_table_row().
1.206 raeburn 1920: &Apache::loncommon::end_data_table().'<br />');
1.203 raeburn 1921: if ($env{'form.cid'} ne $userenv{'id'}) {
1922: &Apache::lonnet::idput($env{'form.ccdomain'},
1923: ($env{'form.ccuname'} => $env{'form.cid'}));
1924: if (($recurseid) &&
1925: (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) {
1926: my $idresult =
1927: &Apache::lonuserutils::propagate_id_change(
1928: $env{'form.ccuname'},$env{'form.ccdomain'},
1929: \%userupdate);
1930: $r->print('<br />'.$idresult.'<br />');
1931: }
1.196 raeburn 1932: }
1.149 raeburn 1933: if (($env{'form.ccdomain'} eq $env{'user.domain'}) &&
1934: ($env{'form.ccuname'} eq $env{'user.name'})) {
1935: my %newenvhash;
1936: foreach my $key (keys(%changeHash)) {
1937: $newenvhash{'environment.'.$key} = $changeHash{$key};
1938: }
1939: &Apache::lonnet::appenv(%newenvhash);
1940: }
1.28 matthew 1941: } else { # error occurred
1.188 raeburn 1942: $r->print('<span class="LC_error">'.&mt('Unable to successfully change environment for').' '.
1943: $env{'form.ccuname'}.' '.&mt('in domain').' '.
1.206 raeburn 1944: $env{'form.ccdomain'}.'</span><br />');
1.28 matthew 1945: }
1.101 albertel 1946: } else { # End of if ($env ... ) logic
1.204 raeburn 1947: # They did not want to change the users name or quota but we can
1948: # still tell them what the name and quota are
1.73 sakharuk 1949: my %lt=&Apache::lonlocal::texthash(
1.196 raeburn 1950: 'id' => "ID/Student number",
1.160 raeburn 1951: 'mail' => "Permanent e-mail",
1.134 raeburn 1952: 'disk' => "Disk space allocated to user's portfolio files",
1.73 sakharuk 1953: );
1.134 raeburn 1954: $r->print(<<"END");
1.196 raeburn 1955: <h4>$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'}
1.28 matthew 1956: END
1.204 raeburn 1957: if ($userenv{'permanentemail'} ne '') {
1958: $r->print('<br />['.$lt{'mail'}.': '.
1959: $userenv{'permanentemail'}.']');
1.134 raeburn 1960: }
1.220 raeburn 1961: if ($showquota) {
1962: $r->print('<br />['.$lt{'disk'}.': '.$oldportfolioquota.' Mb '.
1963: $olddefquotatext.']');
1964: }
1965: $r->print('</h4>');
1.28 matthew 1966: }
1.206 raeburn 1967: if (@mod_disallowed) {
1968: my ($rolestr,$contextname);
1969: if (@longroles > 0) {
1970: $rolestr = join(', ',@longroles);
1971: } else {
1972: $rolestr = &mt('No roles');
1973: }
1974: if ($context eq 'course') {
1975: $contextname = &mt('course');
1976: } elsif ($context eq 'author') {
1977: $contextname = &mt('co-author');
1978: }
1979: $r->print(&mt('The following fields were not updated: ').'<ul>');
1980: my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
1981: foreach my $field (@mod_disallowed) {
1982: $r->print('<li>'.$fieldtitles{$field}.'</li>'."\n");
1983: }
1.207 raeburn 1984: $r->print('</ul>');
1985: if (@mod_disallowed == 1) {
1986: $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));
1987: } else {
1988: $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));
1989: }
1990: $r->print('<span class="LC_cusr_emph">'.$rolestr.'</span><br />'.
1991: &mt('Contact your <a href="[_1]">helpdesk</a> for more information.',"javascript:helpMenu('display')").'<br />');
1.206 raeburn 1992: }
1993: $r->print($no_forceid_alert.
1994: &Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts, \%curr_rules));
1.4 www 1995: }
1.220 raeburn 1996: if ($env{'form.action'} eq 'singlestudent') {
1997: &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser);
1.226 raeburn 1998: $r->print('<p><a href="javascript:backPage(document.userupdate)">'. &mt('Enroll Another Student').'</a></p>');
1.220 raeburn 1999: } else {
1.225 raeburn 2000: my @rolechanges = &update_roles($r);
2001: if ($namechanged) {
1.220 raeburn 2002: if ($context eq 'course') {
2003: if (@userroles > 0) {
1.225 raeburn 2004: if ((@rolechanges == 0) ||
2005: (!(grep(/^st$/,@rolechanges)))) {
2006: if (grep(/^st$/,@userroles)) {
2007: my $classlistupdated =
2008: &Apache::lonuserutils::update_classlist($cdom,
1.220 raeburn 2009: $cnum,$env{'form.ccdomain'},
2010: $env{'form.ccuname'},\%userupdate);
1.225 raeburn 2011: }
1.220 raeburn 2012: }
2013: }
2014: }
2015: }
1.226 raeburn 2016: my $userinfo = &Apache::loncommon::plainname($env{'form.ccuname'},
2017: $env{'form.ccdomain'});
2018: $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 2019: }
2020: $r->print(&Apache::loncommon::end_page());
2021: }
2022:
2023: sub update_roles {
2024: my ($r) = @_;
1.4 www 2025: my $now=time;
1.225 raeburn 2026: my @rolechanges;
1.220 raeburn 2027: my %disallowed;
1.73 sakharuk 2028: $r->print('<h3>'.&mt('Modifying Roles').'</h3>');
1.135 raeburn 2029: foreach my $key (keys (%env)) {
2030: next if (! $env{$key});
1.190 raeburn 2031: next if ($key eq 'form.action');
1.27 matthew 2032: # Revoke roles
1.135 raeburn 2033: if ($key=~/^form\.rev/) {
2034: if ($key=~/^form\.rev\:([^\_]+)\_([^\_\.]+)$/) {
1.64 www 2035: # Revoke standard role
1.170 albertel 2036: my ($scope,$role) = ($1,$2);
2037: my $result =
2038: &Apache::lonnet::revokerole($env{'form.ccdomain'},
2039: $env{'form.ccuname'},
2040: $scope,$role);
2041: $r->print(&mt('Revoking [_1] in [_2]: [_3]',
2042: $role,$scope,'<b>'.$result.'</b>').'<br />');
2043: if ($role eq 'st') {
1.202 raeburn 2044: my $result =
1.198 raeburn 2045: &Apache::lonuserutils::classlist_drop($scope,
2046: $env{'form.ccuname'},$env{'form.ccdomain'},
1.202 raeburn 2047: $now);
1.170 albertel 2048: $r->print($result);
1.53 www 2049: }
1.225 raeburn 2050: if (!grep(/^\Q$role\E$/,@rolechanges)) {
2051: push(@rolechanges,$role);
2052: }
1.196 raeburn 2053: }
1.195 raeburn 2054: if ($key=~m{^form\.rev\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}s) {
1.64 www 2055: # Revoke custom role
1.113 raeburn 2056: $r->print(&mt('Revoking custom role:').
1.139 albertel 2057: ' '.$4.' by '.$3.':'.$2.' in '.$1.': <b>'.
1.101 albertel 2058: &Apache::lonnet::revokecustomrole($env{'form.ccdomain'},
2059: $env{'form.ccuname'},$1,$2,$3,$4).
1.102 albertel 2060: '</b><br />');
1.225 raeburn 2061: if (!grep(/^cr$/,@rolechanges)) {
2062: push(@rolechanges,'cr');
2063: }
1.64 www 2064: }
1.135 raeburn 2065: } elsif ($key=~/^form\.del/) {
2066: if ($key=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) {
1.116 raeburn 2067: # Delete standard role
1.170 albertel 2068: my ($scope,$role) = ($1,$2);
2069: my $result =
2070: &Apache::lonnet::assignrole($env{'form.ccdomain'},
2071: $env{'form.ccuname'},
2072: $scope,$role,$now,0,1);
2073: $r->print(&mt('Deleting [_1] in [_2]: [_3]',$role,$scope,
2074: '<b>'.$result.'</b>').'<br />');
2075: if ($role eq 'st') {
1.202 raeburn 2076: my $result =
1.198 raeburn 2077: &Apache::lonuserutils::classlist_drop($scope,
2078: $env{'form.ccuname'},$env{'form.ccdomain'},
1.202 raeburn 2079: $now);
1.170 albertel 2080: $r->print($result);
1.81 albertel 2081: }
1.225 raeburn 2082: if (!grep(/^\Q$role\E$/,@rolechanges)) {
2083: push(@rolechanges,$role);
2084: }
1.116 raeburn 2085: }
1.139 albertel 2086: if ($key=~m{^form\.del\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) {
1.116 raeburn 2087: my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
2088: # Delete custom role
1.170 albertel 2089: $r->print(&mt('Deleting custom role [_1] by [_2]:[_3] in [_4]',
1.116 raeburn 2090: $rolename,$rnam,$rdom,$url).': <b>'.
2091: &Apache::lonnet::assigncustomrole($env{'form.ccdomain'},
2092: $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
2093: 0,1).'</b><br />');
1.225 raeburn 2094: if (!grep(/^cr$/,@rolechanges)) {
2095: push(@rolechanges,'cr');
2096: }
1.116 raeburn 2097: }
1.135 raeburn 2098: } elsif ($key=~/^form\.ren/) {
1.101 albertel 2099: my $udom = $env{'form.ccdomain'};
2100: my $uname = $env{'form.ccuname'};
1.116 raeburn 2101: # Re-enable standard role
1.135 raeburn 2102: if ($key=~/^form\.ren\:([^\_]+)\_([^\_\.]+)$/) {
1.89 raeburn 2103: my $url = $1;
2104: my $role = $2;
2105: my $logmsg;
2106: my $output;
2107: if ($role eq 'st') {
1.141 albertel 2108: if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) {
1.129 albertel 2109: my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3);
1.220 raeburn 2110: if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) {
1.223 raeburn 2111: if ($result eq 'refused' && $logmsg) {
2112: $output = $logmsg;
2113: } else {
2114: $output = "Error: $result\n";
2115: }
1.89 raeburn 2116: } else {
2117: $output = &mt('Assigning').' '.$role.' in '.$url.
2118: &mt('starting').' '.localtime($now).
2119: ': <br />'.$logmsg.'<br />'.
2120: &mt('Add to classlist').': <b>ok</b><br />';
2121: }
2122: }
2123: } else {
1.101 albertel 2124: my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'},
2125: $env{'form.ccuname'},$url,$role,0,$now);
1.116 raeburn 2126: $output = &mt('Re-enabling [_1] in [_2]: <b>[_3]</b>',
1.89 raeburn 2127: $role,$url,$result).'<br />';
1.27 matthew 2128: }
1.89 raeburn 2129: $r->print($output);
1.225 raeburn 2130: if (!grep(/^\Q$role\E$/,@rolechanges)) {
2131: push(@rolechanges,$role);
2132: }
1.113 raeburn 2133: }
1.116 raeburn 2134: # Re-enable custom role
1.139 albertel 2135: if ($key=~m{^form\.ren\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) {
1.116 raeburn 2136: my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
2137: my $result = &Apache::lonnet::assigncustomrole(
2138: $env{'form.ccdomain'}, $env{'form.ccuname'},
2139: $url,$rdom,$rnam,$rolename,0,$now);
2140: $r->print(&mt('Re-enabling custom role [_1] by [_2]@[_3] in [_4] : <b>[_5]</b>',
2141: $rolename,$rnam,$rdom,$url,$result).'<br />');
1.225 raeburn 2142: if (!grep(/^cr$/,@rolechanges)) {
2143: push(@rolechanges,'cr');
2144: }
1.116 raeburn 2145: }
1.135 raeburn 2146: } elsif ($key=~/^form\.act/) {
1.101 albertel 2147: my $udom = $env{'form.ccdomain'};
2148: my $uname = $env{'form.ccuname'};
1.141 albertel 2149: if ($key=~/^form\.act\_($match_domain)\_($match_courseid)\_cr_cr_($match_domain)_($match_username)_([^\_]+)$/) {
1.65 www 2150: # Activate a custom role
1.83 albertel 2151: my ($one,$two,$three,$four,$five)=($1,$2,$3,$4,$5);
2152: my $url='/'.$one.'/'.$two;
2153: my $full=$one.'_'.$two.'_cr_cr_'.$three.'_'.$four.'_'.$five;
1.65 www 2154:
1.101 albertel 2155: my $start = ( $env{'form.start_'.$full} ?
2156: $env{'form.start_'.$full} :
1.88 raeburn 2157: $now );
1.101 albertel 2158: my $end = ( $env{'form.end_'.$full} ?
2159: $env{'form.end_'.$full} :
1.88 raeburn 2160: 0 );
2161:
2162: # split multiple sections
2163: my %sections = ();
1.101 albertel 2164: my $num_sections = &build_roles($env{'form.sec_'.$full},\%sections,$5);
1.88 raeburn 2165: if ($num_sections == 0) {
1.129 albertel 2166: $r->print(&Apache::loncommon::commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end));
1.88 raeburn 2167: } else {
1.114 albertel 2168: my %curr_groups =
1.117 raeburn 2169: &Apache::longroup::coursegroups($one,$two);
1.113 raeburn 2170: foreach my $sec (sort {$a cmp $b} keys %sections) {
2171: if (($sec eq 'none') || ($sec eq 'all') ||
2172: exists($curr_groups{$sec})) {
2173: $disallowed{$sec} = $url;
2174: next;
2175: }
2176: my $securl = $url.'/'.$sec;
1.129 albertel 2177: $r->print(&Apache::loncommon::commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end));
1.88 raeburn 2178: }
2179: }
1.225 raeburn 2180: if (!grep(/^cr$/,@rolechanges)) {
2181: push(@rolechanges,'cr');
2182: }
1.142 raeburn 2183: } elsif ($key=~/^form\.act\_($match_domain)\_($match_name)\_([^\_]+)$/) {
1.27 matthew 2184: # Activate roles for sections with 3 id numbers
2185: # set start, end times, and the url for the class
1.83 albertel 2186: my ($one,$two,$three)=($1,$2,$3);
1.101 albertel 2187: my $start = ( $env{'form.start_'.$one.'_'.$two.'_'.$three} ?
2188: $env{'form.start_'.$one.'_'.$two.'_'.$three} :
1.27 matthew 2189: $now );
1.101 albertel 2190: my $end = ( $env{'form.end_'.$one.'_'.$two.'_'.$three} ?
2191: $env{'form.end_'.$one.'_'.$two.'_'.$three} :
1.27 matthew 2192: 0 );
1.83 albertel 2193: my $url='/'.$one.'/'.$two;
1.88 raeburn 2194: my $type = 'three';
2195: # split multiple sections
2196: my %sections = ();
1.101 albertel 2197: my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);
1.88 raeburn 2198: if ($num_sections == 0) {
1.129 albertel 2199: $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
1.88 raeburn 2200: } else {
1.114 albertel 2201: my %curr_groups =
1.117 raeburn 2202: &Apache::longroup::coursegroups($one,$two);
1.88 raeburn 2203: my $emptysec = 0;
2204: foreach my $sec (sort {$a cmp $b} keys %sections) {
2205: $sec =~ s/\W//g;
1.113 raeburn 2206: if ($sec ne '') {
2207: if (($sec eq 'none') || ($sec eq 'all') ||
2208: exists($curr_groups{$sec})) {
2209: $disallowed{$sec} = $url;
2210: next;
2211: }
1.88 raeburn 2212: my $securl = $url.'/'.$sec;
1.129 albertel 2213: $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec));
1.88 raeburn 2214: } else {
2215: $emptysec = 1;
2216: }
2217: }
2218: if ($emptysec) {
1.129 albertel 2219: $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
1.88 raeburn 2220: }
1.225 raeburn 2221: }
2222: if (!grep(/^\Q$three\E$/,@rolechanges)) {
2223: push(@rolechanges,$three);
2224: }
1.135 raeburn 2225: } elsif ($key=~/^form\.act\_([^\_]+)\_([^\_]+)$/) {
1.27 matthew 2226: # Activate roles for sections with two id numbers
2227: # set start, end times, and the url for the class
1.101 albertel 2228: my $start = ( $env{'form.start_'.$1.'_'.$2} ?
2229: $env{'form.start_'.$1.'_'.$2} :
1.27 matthew 2230: $now );
1.101 albertel 2231: my $end = ( $env{'form.end_'.$1.'_'.$2} ?
2232: $env{'form.end_'.$1.'_'.$2} :
1.27 matthew 2233: 0 );
1.225 raeburn 2234: my $one = $1;
2235: my $two = $2;
2236: my $url='/'.$one.'/';
1.88 raeburn 2237: # split multiple sections
2238: my %sections = ();
1.225 raeburn 2239: my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two},\%sections,$two);
1.88 raeburn 2240: if ($num_sections == 0) {
1.225 raeburn 2241: $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,''));
1.88 raeburn 2242: } else {
2243: my $emptysec = 0;
2244: foreach my $sec (sort {$a cmp $b} keys %sections) {
2245: if ($sec ne '') {
2246: my $securl = $url.'/'.$sec;
1.225 raeburn 2247: $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$two,$start,$end,$one,undef,$sec));
1.88 raeburn 2248: } else {
2249: $emptysec = 1;
2250: }
2251: }
2252: if ($emptysec) {
1.225 raeburn 2253: $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,''));
1.88 raeburn 2254: }
2255: }
1.225 raeburn 2256: if (!grep(/^\Q$two\E$/,@rolechanges)) {
2257: push(@rolechanges,$two);
2258: }
1.64 www 2259: } else {
1.190 raeburn 2260: $r->print('<p><span class="LC_error">'.&mt('ERROR').': '.&mt('Unknown command').' <tt>'.$key.'</tt></span></p><br />');
1.64 www 2261: }
1.113 raeburn 2262: foreach my $key (sort(keys(%disallowed))) {
2263: if (($key eq 'none') || ($key eq 'all')) {
2264: $r->print('<p>'.&mt('[_1] may not be used as the name for a section, as it is a reserved word.',$key));
2265: } else {
2266: $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));
2267: }
2268: $r->print(' '.&mt('Please <a href="javascript:history.go(-1)">go back</a> and choose a different section name.').'</p><br />');
2269: }
2270: }
1.101 albertel 2271: } # End of foreach (keys(%env))
1.75 www 2272: # Flush the course logs so reverse user roles immediately updated
2273: &Apache::lonnet::flushcourselogs();
1.225 raeburn 2274: if (@rolechanges == 0) {
1.193 raeburn 2275: $r->print(&mt('No roles to modify'));
2276: }
1.225 raeburn 2277: return @rolechanges;
1.220 raeburn 2278: }
2279:
2280: sub enroll_single_student {
2281: my ($r,$uhome,$amode,$genpwd,$now,$newuser) = @_;
2282: $r->print('<h3>'.&mt('Enrolling Student').'</h3>');
2283:
2284: # Remove non alphanumeric values from section
2285: $env{'form.sections'}=~s/\W//g;
2286:
2287: # Clean out any old student roles the user has in this class.
2288: &Apache::lonuserutils::modifystudent($env{'form.ccdomain'},
2289: $env{'form.ccuname'},$env{'request.course.id'},undef,$uhome);
2290: my ($startdate,$enddate) = &Apache::lonuserutils::get_dates_from_form();
2291: my $enroll_result =
2292: &Apache::lonnet::modify_student_enrollment($env{'form.ccdomain'},
2293: $env{'form.ccuname'},$env{'form.cid'},$env{'form.cfirstname'},
2294: $env{'form.cmiddlename'},$env{'form.clastname'},
2295: $env{'form.generation'},$env{'form.sections'},$enddate,
2296: $startdate,'manual',undef,$env{'request.course.id'});
2297: if ($enroll_result =~ /^ok/) {
2298: $r->print(&mt('<b>[_1]</b> enrolled',$env{'form.ccuname'}.':'.$env{'form.ccdomain'}));
2299: if ($env{'form.sections'} ne '') {
2300: $r->print(' '.&mt('in section [_1]',$env{'form.sections'}));
2301: }
2302: my ($showstart,$showend);
2303: if ($startdate <= $now) {
2304: $showstart = &mt('Access starts immediately');
2305: } else {
2306: $showstart = &mt('Access starts: ').&Apache::lonlocal::locallocaltime($startdate);
2307: }
2308: if ($enddate == 0) {
2309: $showend = &mt('ends: no ending date');
2310: } else {
2311: $showend = &mt('ends: ').&Apache::lonlocal::locallocaltime($enddate);
2312: }
2313: $r->print('.<br />'.$showstart.'; '.$showend);
2314: if ($startdate <= $now && !$newuser) {
2315: $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>");
2316: }
2317: } else {
2318: $r->print(&mt('unable to enroll').": ".$enroll_result);
2319: }
2320: return;
1.188 raeburn 2321: }
2322:
1.204 raeburn 2323: sub get_defaultquota_text {
2324: my ($settingstatus) = @_;
2325: my $defquotatext;
2326: if ($settingstatus eq '') {
2327: $defquotatext = &mt('(default)');
2328: } else {
2329: my ($usertypes,$order) =
2330: &Apache::lonnet::retrieve_inst_usertypes($env{'form.ccdomain'});
2331: if ($usertypes->{$settingstatus} eq '') {
2332: $defquotatext = &mt('(default)');
2333: } else {
2334: $defquotatext = &mt('(default for [_1])',$usertypes->{$settingstatus});
2335: }
2336: }
2337: return $defquotatext;
2338: }
2339:
1.188 raeburn 2340: sub update_result_form {
2341: my ($uhome) = @_;
2342: my $outcome =
2343: '<form name="userupdate" method="post" />'."\n";
1.160 raeburn 2344: foreach my $item ('srchby','srchin','srchtype','srchterm','srchdomain','ccuname','ccdomain') {
1.188 raeburn 2345: $outcome .= '<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n";
1.160 raeburn 2346: }
1.207 raeburn 2347: if ($env{'form.origname'} ne '') {
2348: $outcome .= '<input type="hidden" name="origname" value="'.$env{'form.origname'}.'" />'."\n";
2349: }
1.160 raeburn 2350: foreach my $item ('sortby','seluname','seludom') {
2351: if (exists($env{'form.'.$item})) {
1.188 raeburn 2352: $outcome .= '<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n";
1.160 raeburn 2353: }
2354: }
1.188 raeburn 2355: if ($uhome eq 'no_host') {
2356: $outcome .= '<input type="hidden" name="forcenewuser" value="1" />'."\n";
2357: }
2358: $outcome .= '<input type="hidden" name="phase" value="" />'."\n".
2359: '<input type ="hidden" name="currstate" value="" />'."\n".
1.220 raeburn 2360: '<input type ="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".
1.188 raeburn 2361: '</form>';
2362: return $outcome;
1.4 www 2363: }
2364:
1.149 raeburn 2365: sub quota_admin {
2366: my ($setquota,$changeHash) = @_;
2367: my $quotachanged;
2368: if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
2369: # Current user has quota modification privileges
2370: $quotachanged = 1;
2371: $changeHash->{'portfolioquota'} = $setquota;
2372: }
2373: return $quotachanged;
2374: }
2375:
1.88 raeburn 2376: sub build_roles {
1.89 raeburn 2377: my ($sectionstr,$sections,$role) = @_;
1.88 raeburn 2378: my $num_sections = 0;
2379: if ($sectionstr=~ /,/) {
2380: my @secnums = split/,/,$sectionstr;
1.89 raeburn 2381: if ($role eq 'st') {
2382: $secnums[0] =~ s/\W//g;
2383: $$sections{$secnums[0]} = 1;
2384: $num_sections = 1;
2385: } else {
2386: foreach my $sec (@secnums) {
2387: $sec =~ ~s/\W//g;
1.150 banghart 2388: if (!($sec eq "")) {
1.89 raeburn 2389: if (exists($$sections{$sec})) {
2390: $$sections{$sec} ++;
2391: } else {
2392: $$sections{$sec} = 1;
2393: $num_sections ++;
2394: }
1.88 raeburn 2395: }
2396: }
2397: }
2398: } else {
2399: $sectionstr=~s/\W//g;
2400: unless ($sectionstr eq '') {
2401: $$sections{$sectionstr} = 1;
2402: $num_sections ++;
2403: }
2404: }
1.129 albertel 2405:
1.88 raeburn 2406: return $num_sections;
2407: }
2408:
1.58 www 2409: # ========================================================== Custom Role Editor
2410:
2411: sub custom_role_editor {
1.160 raeburn 2412: my ($r) = @_;
1.101 albertel 2413: my $rolename=$env{'form.rolename'};
1.58 www 2414:
1.59 www 2415: if ($rolename eq 'make new role') {
1.101 albertel 2416: $rolename=$env{'form.newrolename'};
1.59 www 2417: }
2418:
1.63 www 2419: $rolename=~s/[^A-Za-z0-9]//gs;
1.58 www 2420:
1.190 raeburn 2421: if (!$rolename || $env{'form.phase'} eq 'pickrole') {
1.58 www 2422: &print_username_entry_form($r);
2423: return;
2424: }
1.153 banghart 2425: # ------------------------------------------------------- What can be assigned?
2426: my %full=();
2427: my %courselevel=();
2428: my %courselevelcurrent=();
1.61 www 2429: my $syspriv='';
2430: my $dompriv='';
2431: my $coursepriv='';
1.153 banghart 2432: my $body_top;
1.150 banghart 2433: my ($disp_dummy,$disp_roles) = &Apache::lonnet::get('roles',["st"]);
1.59 www 2434: my ($rdummy,$roledef)=
2435: &Apache::lonnet::get('roles',["rolesdef_$rolename"]);
1.60 www 2436: # ------------------------------------------------------- Does this role exist?
1.153 banghart 2437: $body_top .= '<h2>';
1.59 www 2438: if (($rdummy ne 'con_lost') && ($roledef ne '')) {
1.153 banghart 2439: $body_top .= &mt('Existing Role').' "';
1.61 www 2440: # ------------------------------------------------- Get current role privileges
2441: ($syspriv,$dompriv,$coursepriv)=split(/\_/,$roledef);
1.59 www 2442: } else {
1.153 banghart 2443: $body_top .= &mt('New Role').' "';
1.59 www 2444: $roledef='';
2445: }
1.153 banghart 2446: $body_top .= $rolename.'"</h2>';
1.135 raeburn 2447: foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
2448: my ($priv,$restrict)=split(/\&/,$item);
1.150 banghart 2449: if (!$restrict) { $restrict='F'; }
1.60 www 2450: $courselevel{$priv}=$restrict;
1.61 www 2451: if ($coursepriv=~/\:$priv/) {
2452: $courselevelcurrent{$priv}=1;
2453: }
1.60 www 2454: $full{$priv}=1;
2455: }
2456: my %domainlevel=();
1.61 www 2457: my %domainlevelcurrent=();
1.135 raeburn 2458: foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
2459: my ($priv,$restrict)=split(/\&/,$item);
1.150 banghart 2460: if (!$restrict) { $restrict='F'; }
1.60 www 2461: $domainlevel{$priv}=$restrict;
1.61 www 2462: if ($dompriv=~/\:$priv/) {
2463: $domainlevelcurrent{$priv}=1;
2464: }
1.60 www 2465: $full{$priv}=1;
2466: }
1.61 www 2467: my %systemlevel=();
2468: my %systemlevelcurrent=();
1.135 raeburn 2469: foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
2470: my ($priv,$restrict)=split(/\&/,$item);
1.150 banghart 2471: if (!$restrict) { $restrict='F'; }
1.61 www 2472: $systemlevel{$priv}=$restrict;
2473: if ($syspriv=~/\:$priv/) {
2474: $systemlevelcurrent{$priv}=1;
2475: }
2476: $full{$priv}=1;
2477: }
1.160 raeburn 2478: my ($jsback,$elements) = &crumb_utilities();
1.154 banghart 2479: my $button_code = "\n";
1.153 banghart 2480: my $head_script = "\n";
2481: $head_script .= '<script type="text/javascript">'."\n";
1.154 banghart 2482: my @template_roles = ("cc","in","ta","ep","st");
2483: foreach my $role (@template_roles) {
2484: $head_script .= &make_script_template($role);
2485: $button_code .= &make_button_code($role);
2486: }
1.160 raeburn 2487: $head_script .= "\n".$jsback."\n".'</script>'."\n";
1.153 banghart 2488: $r->print(&Apache::loncommon::start_page('Custom Role Editor',$head_script));
1.160 raeburn 2489: &Apache::lonhtmlcommon::add_breadcrumb
1.190 raeburn 2490: ({href=>"javascript:backPage(document.form1,'pickrole','')",
2491: text=>"Pick custom role",
1.160 raeburn 2492: faq=>282,bug=>'Instructor Interface',},
2493: {href=>"javascript:backPage(document.form1,'','')",
2494: text=>"Edit custom role",
2495: faq=>282,bug=>'Instructor Interface',});
1.224 raeburn 2496: $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
2497: 'Course_Editing_Custom_Roles'));
1.160 raeburn 2498:
1.153 banghart 2499: $r->print($body_top);
1.73 sakharuk 2500: my %lt=&Apache::lonlocal::texthash(
2501: 'prv' => "Privilege",
1.131 raeburn 2502: 'crl' => "Course Level",
1.73 sakharuk 2503: 'dml' => "Domain Level",
1.150 banghart 2504: 'ssl' => "System Level");
1.152 banghart 2505: $r->print('Select a Template<br />');
1.154 banghart 2506: $r->print('<form action="">');
2507: $r->print($button_code);
2508: $r->print('</form>');
1.61 www 2509: $r->print(<<ENDCCF);
1.160 raeburn 2510: <form name="form1" method="post">
1.61 www 2511: <input type="hidden" name="phase" value="set_custom_roles" />
2512: <input type="hidden" name="rolename" value="$rolename" />
2513: ENDCCF
1.135 raeburn 2514: $r->print(&Apache::loncommon::start_data_table().
2515: &Apache::loncommon::start_data_table_header_row().
2516: '<th>'.$lt{'prv'}.'</th><th>'.$lt{'crl'}.'</th><th>'.$lt{'dml'}.
2517: '</th><th>'.$lt{'ssl'}.'</th>'.
2518: &Apache::loncommon::end_data_table_header_row());
1.119 raeburn 2519: foreach my $priv (sort keys %full) {
2520: my $privtext = &Apache::lonnet::plaintext($priv);
1.135 raeburn 2521: $r->print(&Apache::loncommon::start_data_table_row().
2522: '<td>'.$privtext.'</td><td>'.
1.150 banghart 2523: ($courselevel{$priv}?'<input type="checkbox" name="'.$priv.'_c" '.
1.119 raeburn 2524: ($courselevelcurrent{$priv}?'checked="1"':'').' />':' ').
1.61 www 2525: '</td><td>'.
1.150 banghart 2526: ($domainlevel{$priv}?'<input type="checkbox" name="'.$priv.'_d" '.
1.119 raeburn 2527: ($domainlevelcurrent{$priv}?'checked="1"':'').' />':' ').
1.61 www 2528: '</td><td>'.
1.150 banghart 2529: ($systemlevel{$priv}?'<input type="checkbox" name="'.$priv.'_s" '.
1.119 raeburn 2530: ($systemlevelcurrent{$priv}?'checked="1"':'').' />':' ').
1.135 raeburn 2531: '</td>'.
2532: &Apache::loncommon::end_data_table_row());
1.60 www 2533: }
1.135 raeburn 2534: $r->print(&Apache::loncommon::end_data_table().
1.190 raeburn 2535: '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'.
1.160 raeburn 2536: '<input type="hidden" name="startrolename" value="'.$env{'form.rolename'}.
1.179 raeburn 2537: '" />'."\n".'<input type="hidden" name="currstate" value="" />'."\n".
1.160 raeburn 2538: '<input type="reset" value="'.&mt("Reset").'" />'."\n".
2539: '<input type="submit" value="'.&mt('Define Role').'" /></form>'.
1.110 albertel 2540: &Apache::loncommon::end_page());
1.61 www 2541: }
1.153 banghart 2542: # --------------------------------------------------------
2543: sub make_script_template {
2544: my ($role) = @_;
2545: my %full_c=();
2546: my %full_d=();
2547: my %full_s=();
2548: my $return_script;
2549: foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
2550: my ($priv,$restrict)=split(/\&/,$item);
2551: $full_c{$priv}=1;
2552: }
2553: foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
2554: my ($priv,$restrict)=split(/\&/,$item);
2555: $full_d{$priv}=1;
2556: }
1.154 banghart 2557: foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
1.153 banghart 2558: my ($priv,$restrict)=split(/\&/,$item);
2559: $full_s{$priv}=1;
2560: }
2561: $return_script .= 'function set_'.$role.'() {'."\n";
2562: my @temp = split(/:/,$Apache::lonnet::pr{$role.':c'});
2563: my %role_c;
1.155 banghart 2564: foreach my $priv (@temp) {
1.153 banghart 2565: my ($priv_item, $dummy) = split(/\&/,$priv);
2566: $role_c{$priv_item} = 1;
2567: }
2568: foreach my $priv_item (keys(%full_c)) {
2569: my ($priv, $dummy) = split(/\&/,$priv_item);
2570: if (exists($role_c{$priv})) {
2571: $return_script .= "document.form1.$priv"."_c.checked = true;\n";
2572: } else {
2573: $return_script .= "document.form1.$priv"."_c.checked = false;\n";
2574: }
2575: }
1.154 banghart 2576: my %role_d;
2577: @temp = split(/:/,$Apache::lonnet::pr{$role.':d'});
2578: foreach my $priv(@temp) {
2579: my ($priv_item, $dummy) = split(/\&/,$priv);
2580: $role_d{$priv_item} = 1;
2581: }
2582: foreach my $priv_item (keys(%full_d)) {
2583: my ($priv, $dummy) = split(/\&/,$priv_item);
2584: if (exists($role_d{$priv})) {
2585: $return_script .= "document.form1.$priv"."_d.checked = true;\n";
2586: } else {
2587: $return_script .= "document.form1.$priv"."_d.checked = false;\n";
2588: }
2589: }
2590: my %role_s;
2591: @temp = split(/:/,$Apache::lonnet::pr{$role.':s'});
2592: foreach my $priv(@temp) {
2593: my ($priv_item, $dummy) = split(/\&/,$priv);
2594: $role_s{$priv_item} = 1;
2595: }
2596: foreach my $priv_item (keys(%full_s)) {
1.153 banghart 2597: my ($priv, $dummy) = split(/\&/,$priv_item);
1.154 banghart 2598: if (exists($role_s{$priv})) {
2599: $return_script .= "document.form1.$priv"."_s.checked = true;\n";
2600: } else {
2601: $return_script .= "document.form1.$priv"."_s.checked = false;\n";
2602: }
1.153 banghart 2603: }
2604: $return_script .= '}'."\n";
1.154 banghart 2605: return ($return_script);
2606: }
2607: # ----------------------------------------------------------
2608: sub make_button_code {
2609: my ($role) = @_;
2610: my $label = &Apache::lonnet::plaintext($role);
2611: my $button_code = '<input type="button" onClick="set_'.$role.'()" value="'.$label.'" />';
2612: return ($button_code);
1.153 banghart 2613: }
1.61 www 2614: # ---------------------------------------------------------- Call to definerole
2615: sub set_custom_role {
1.110 albertel 2616: my ($r) = @_;
1.101 albertel 2617: my $rolename=$env{'form.rolename'};
1.63 www 2618: $rolename=~s/[^A-Za-z0-9]//gs;
1.150 banghart 2619: if (!$rolename) {
1.190 raeburn 2620: &custom_role_editor($r);
1.61 www 2621: return;
2622: }
1.160 raeburn 2623: my ($jsback,$elements) = &crumb_utilities();
2624: my $jscript = '<script type="text/javascript">'.$jsback."\n".'</script>';
2625:
2626: $r->print(&Apache::loncommon::start_page('Save Custom Role'),$jscript);
2627: &Apache::lonhtmlcommon::add_breadcrumb
1.190 raeburn 2628: ({href=>"javascript:backPage(document.customresult,'pickrole','')",
2629: text=>"Pick custom role",
1.160 raeburn 2630: faq=>282,bug=>'Instructor Interface',},
2631: {href=>"javascript:backPage(document.customresult,'selected_custom_edit','')",
2632: text=>"Edit custom role",
2633: faq=>282,bug=>'Instructor Interface',},
2634: {href=>"javascript:backPage(document.customresult,'set_custom_roles','')",
2635: text=>"Result",
2636: faq=>282,bug=>'Instructor Interface',});
1.224 raeburn 2637: $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
2638: 'Course_Editing_Custom_Roles'));
1.160 raeburn 2639:
1.61 www 2640: my ($rdummy,$roledef)=
1.110 albertel 2641: &Apache::lonnet::get('roles',["rolesdef_$rolename"]);
2642:
1.61 www 2643: # ------------------------------------------------------- Does this role exist?
1.188 raeburn 2644: $r->print('<h3>');
1.61 www 2645: if (($rdummy ne 'con_lost') && ($roledef ne '')) {
1.73 sakharuk 2646: $r->print(&mt('Existing Role').' "');
1.61 www 2647: } else {
1.73 sakharuk 2648: $r->print(&mt('New Role').' "');
1.61 www 2649: $roledef='';
2650: }
1.188 raeburn 2651: $r->print($rolename.'"</h3>');
1.61 www 2652: # ------------------------------------------------------- What can be assigned?
2653: my $sysrole='';
2654: my $domrole='';
2655: my $courole='';
2656:
1.135 raeburn 2657: foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
2658: my ($priv,$restrict)=split(/\&/,$item);
1.150 banghart 2659: if (!$restrict) { $restrict=''; }
2660: if ($env{'form.'.$priv.'_c'}) {
1.135 raeburn 2661: $courole.=':'.$item;
1.61 www 2662: }
2663: }
2664:
1.135 raeburn 2665: foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
2666: my ($priv,$restrict)=split(/\&/,$item);
1.150 banghart 2667: if (!$restrict) { $restrict=''; }
2668: if ($env{'form.'.$priv.'_d'}) {
1.135 raeburn 2669: $domrole.=':'.$item;
1.61 www 2670: }
2671: }
2672:
1.135 raeburn 2673: foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
2674: my ($priv,$restrict)=split(/\&/,$item);
1.150 banghart 2675: if (!$restrict) { $restrict=''; }
2676: if ($env{'form.'.$priv.'_s'}) {
1.135 raeburn 2677: $sysrole.=':'.$item;
1.61 www 2678: }
2679: }
1.63 www 2680: $r->print('<br />Defining Role: '.
1.61 www 2681: &Apache::lonnet::definerole($rolename,$sysrole,$domrole,$courole));
1.101 albertel 2682: if ($env{'request.course.id'}) {
2683: my $url='/'.$env{'request.course.id'};
1.63 www 2684: $url=~s/\_/\//g;
1.73 sakharuk 2685: $r->print('<br />'.&mt('Assigning Role to Self').': '.
1.101 albertel 2686: &Apache::lonnet::assigncustomrole($env{'user.domain'},
2687: $env{'user.name'},
1.63 www 2688: $url,
1.101 albertel 2689: $env{'user.domain'},
2690: $env{'user.name'},
1.63 www 2691: $rolename));
2692: }
1.190 raeburn 2693: $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 2694: $r->print(&Apache::lonhtmlcommon::echo_form_input([]).'</form>');
1.110 albertel 2695: $r->print(&Apache::loncommon::end_page());
1.58 www 2696: }
2697:
1.2 www 2698: # ================================================================ Main Handler
2699: sub handler {
2700: my $r = shift;
2701: if ($r->header_only) {
1.68 www 2702: &Apache::loncommon::content_type($r,'text/html');
1.2 www 2703: $r->send_http_header;
2704: return OK;
2705: }
1.190 raeburn 2706: my $context;
2707: if ($env{'request.course.id'}) {
2708: $context = 'course';
2709: } elsif ($env{'request.role'} =~ /^au\./) {
1.206 raeburn 2710: $context = 'author';
1.190 raeburn 2711: } else {
2712: $context = 'domain';
2713: }
2714: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.202 raeburn 2715: ['action','state','callingform','roletype','showrole','bulkaction']);
1.190 raeburn 2716: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.202 raeburn 2717: if ($env{'form.action'} ne 'dateselect') {
2718: &Apache::lonhtmlcommon::add_breadcrumb
2719: ({href=>"/adm/createuser",
2720: text=>"User Management"});
2721: }
1.209 raeburn 2722: my ($permission,$allowed) =
2723: &Apache::lonuserutils::get_permission($context);
1.190 raeburn 2724: if (!$allowed) {
2725: $env{'user.error.msg'}=
2726: "/adm/createuser:cst:0:0:Cannot create/modify user data ".
2727: "or view user status.";
2728: return HTTP_NOT_ACCEPTABLE;
2729: }
2730:
2731: &Apache::loncommon::content_type($r,'text/html');
2732: $r->send_http_header;
2733:
2734: # Main switch on form.action and form.state, as appropriate
2735: if (! exists($env{'form.action'})) {
2736: $r->print(&header());
2737: $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management'));
1.208 raeburn 2738: $r->print(&print_main_menu($permission,$context));
1.190 raeburn 2739: $r->print(&Apache::loncommon::end_page());
2740: } elsif ($env{'form.action'} eq 'upload' && $permission->{'cusr'}) {
2741: $r->print(&header());
2742: &Apache::lonhtmlcommon::add_breadcrumb
2743: ({href=>'/adm/createuser?action=upload&state=',
2744: text=>"Upload Users List"});
2745: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Upload Users List',
1.224 raeburn 2746: 'Course_Create_Class_List'));
1.190 raeburn 2747: $r->print('<form name="studentform" method="post" '.
2748: 'enctype="multipart/form-data" '.
2749: ' action="/adm/createuser">'."\n");
2750: if (! exists($env{'form.state'})) {
2751: &Apache::lonuserutils::print_first_users_upload_form($r,$context);
2752: } elsif ($env{'form.state'} eq 'got_file') {
1.221 raeburn 2753: &Apache::lonuserutils::print_upload_manager_form($r,$context,
2754: $permission);
1.190 raeburn 2755: } elsif ($env{'form.state'} eq 'enrolling') {
2756: if ($env{'form.datatoken'}) {
1.221 raeburn 2757: &Apache::lonuserutils::upfile_drop_add($r,$context,$permission);
1.190 raeburn 2758: }
2759: } else {
2760: &Apache::lonuserutils::print_first_users_upload_form($r,$context);
2761: }
2762: $r->print('</form>'.&Apache::loncommon::end_page());
1.213 raeburn 2763: } elsif ((($env{'form.action'} eq 'singleuser') || ($env{'form.action'}
2764: eq 'singlestudent')) && ($permission->{'cusr'})) {
1.190 raeburn 2765: my $phase = $env{'form.phase'};
2766: my @search = ('srchterm','srchby','srchin','srchtype','srchdomain');
1.192 albertel 2767: &Apache::loncreateuser::restore_prev_selections();
2768: my $srch;
2769: foreach my $item (@search) {
2770: $srch->{$item} = $env{'form.'.$item};
2771: }
1.190 raeburn 2772:
1.207 raeburn 2773: if (($phase eq 'get_user_info') || ($phase eq 'userpicked') ||
2774: ($phase eq 'createnewuser')) {
2775: if ($env{'form.phase'} eq 'createnewuser') {
2776: my $response;
2777: if ($env{'form.srchterm'} !~ /^$match_username$/) {
2778: my $response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @');
1.221 raeburn 2779: $env{'form.phase'} = '';
1.207 raeburn 2780: &print_username_entry_form($r,$context,$response,$srch);
2781: } else {
2782: my $ccuname =&LONCAPA::clean_username($srch->{'srchterm'});
2783: my $ccdomain=&LONCAPA::clean_domain($srch->{'srchdomain'});
2784: &print_user_modification_page($r,$ccuname,$ccdomain,
1.221 raeburn 2785: $srch,$response,$context,
2786: $permission);
1.207 raeburn 2787: }
2788: } elsif ($env{'form.phase'} eq 'get_user_info') {
1.190 raeburn 2789: my ($currstate,$response,$forcenewuser,$results) =
1.221 raeburn 2790: &user_search_result($context,$srch);
1.190 raeburn 2791: if ($env{'form.currstate'} eq 'modify') {
2792: $currstate = $env{'form.currstate'};
2793: }
2794: if ($currstate eq 'select') {
1.214 raeburn 2795: my $operation;
2796: if ($env{'form.action'} eq 'singleuser') {
2797: $operation = 'createuser';
2798: } elsif ($env{'form.action'} eq 'singlestudent') {
2799: $operation = 'enrollstudent';
2800: }
1.190 raeburn 2801: &print_user_selection_page($r,$response,$srch,$results,
1.214 raeburn 2802: $operation,\@search,$context);
1.190 raeburn 2803: } elsif ($currstate eq 'modify') {
2804: my ($ccuname,$ccdomain);
2805: if (($srch->{'srchby'} eq 'uname') &&
2806: ($srch->{'srchtype'} eq 'exact')) {
2807: $ccuname = $srch->{'srchterm'};
2808: $ccdomain= $srch->{'srchdomain'};
2809: } else {
2810: my @matchedunames = keys(%{$results});
2811: ($ccuname,$ccdomain) = split(/:/,$matchedunames[0]);
2812: }
2813: $ccuname =&LONCAPA::clean_username($ccuname);
2814: $ccdomain=&LONCAPA::clean_domain($ccdomain);
2815: if ($env{'form.forcenewuser'}) {
2816: $response = '';
2817: }
2818: &print_user_modification_page($r,$ccuname,$ccdomain,
1.221 raeburn 2819: $srch,$response,$context,
2820: $permission);
1.190 raeburn 2821: } elsif ($currstate eq 'query') {
2822: &print_user_query_page($r,'createuser');
2823: } else {
1.207 raeburn 2824: &print_username_entry_form($r,$context,$response,$srch,
1.190 raeburn 2825: $forcenewuser);
2826: }
2827: } elsif ($env{'form.phase'} eq 'userpicked') {
2828: my $ccuname = &LONCAPA::clean_username($env{'form.seluname'});
2829: my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'});
1.196 raeburn 2830: &print_user_modification_page($r,$ccuname,$ccdomain,$srch,'',
1.221 raeburn 2831: $context,$permission);
1.190 raeburn 2832: }
2833: } elsif ($env{'form.phase'} eq 'update_user_data') {
1.206 raeburn 2834: &update_user_data($r,$context);
1.190 raeburn 2835: } else {
1.207 raeburn 2836: &print_username_entry_form($r,$context,undef,$srch);
1.190 raeburn 2837: }
2838: } elsif ($env{'form.action'} eq 'custom' && $permission->{'custom'}) {
2839: if ($env{'form.phase'} eq 'set_custom_roles') {
2840: &set_custom_role($r);
2841: } else {
2842: &custom_role_editor($r);
2843: }
1.207 raeburn 2844: } elsif (($env{'form.action'} eq 'listusers') &&
2845: ($permission->{'view'} || $permission->{'cusr'})) {
1.202 raeburn 2846: if ($env{'form.phase'} eq 'bulkchange') {
2847: &Apache::lonhtmlcommon::add_breadcrumb
1.221 raeburn 2848: ({href=>'/adm/createuser?action=listusers',
2849: text=>"List Users"},
2850: {href=>"/adm/createuser",
2851: text=>"Result"});
1.202 raeburn 2852: my $setting = $env{'form.roletype'};
2853: my $choice = $env{'form.bulkaction'};
2854: $r->print(&header());
1.221 raeburn 2855: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Update Users",
1.224 raeburn 2856: 'Course_View_Class_List'));
1.202 raeburn 2857: if ($permission->{'cusr'}) {
2858: &Apache::lonuserutils::update_user_list($r,$context,$setting,$choice);
1.221 raeburn 2859: $r->print(&Apache::loncommon::end_page());
2860: } else {
2861: $r->print(&mt('You are not authorized to make bulk changes to user roles'));
1.223 raeburn 2862: $r->print('<p><a href="/adm/createuser?action=listusers">'.&mt('Display User Lists').'</a>');
1.221 raeburn 2863: $r->print(&Apache::loncommon::end_page());
1.202 raeburn 2864: }
2865: } else {
2866: &Apache::lonhtmlcommon::add_breadcrumb
2867: ({href=>'/adm/createuser?action=listusers',
2868: text=>"List Users"});
2869: my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles);
2870: my $formname = 'studentform';
2871: if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
2872: ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles) =
2873: &Apache::lonuserutils::courses_selector($env{'request.role.domain'},
2874: $formname);
2875: $jscript .= &verify_user_display();
2876: my $js = &add_script($jscript).$cb_jscript;
2877: my $loadcode =
2878: &Apache::lonuserutils::course_selector_loadcode($formname);
2879: if ($loadcode ne '') {
2880: $r->print(&header($js,{'onload' => $loadcode,}));
2881: } else {
2882: $r->print(&header($js));
2883: }
1.191 raeburn 2884: } else {
1.202 raeburn 2885: $r->print(&header(&add_script(&verify_user_display())));
1.191 raeburn 2886: }
1.202 raeburn 2887: $r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users",
1.224 raeburn 2888: 'Course_View_Class_List'));
1.202 raeburn 2889: &Apache::lonuserutils::print_userlist($r,undef,$permission,$context,
2890: $formname,$totcodes,$codetitles,$idlist,$idlist_titles);
2891: $r->print(&Apache::loncommon::end_page());
1.191 raeburn 2892: }
1.213 raeburn 2893: } elsif ($env{'form.action'} eq 'drop' && $permission->{'cusr'}) {
2894: $r->print(&header());
2895: &Apache::lonhtmlcommon::add_breadcrumb
2896: ({href=>'/adm/createuser?action=drop',
2897: text=>"Drop Students"});
2898: if (!exists($env{'form.state'})) {
2899: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Drop Students',
2900: 'Course_Drop_Student'));
2901:
2902: &Apache::lonuserutils::print_drop_menu($r,$context,$permission);
2903: } elsif ($env{'form.state'} eq 'done') {
2904: &Apache::lonhtmlcommon::add_breadcrumb
2905: ({href=>'/adm/createuser?action=drop',
2906: text=>"Result"});
2907: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Drop Students',
2908: 'Course_Drop_Student'));
2909: &Apache::lonuserutils::update_user_list($r,$context,undef,
2910: $env{'form.action'});
2911: }
2912: $r->print(&Apache::loncommon::end_page());
1.202 raeburn 2913: } elsif ($env{'form.action'} eq 'dateselect') {
2914: if ($permission->{'cusr'}) {
2915: $r->print(&header(undef,undef,{'no_nav_bar' => 1}).
1.221 raeburn 2916: &Apache::lonuserutils::date_section_selector($context,
2917: $permission).
1.202 raeburn 2918: &Apache::loncommon::end_page());
2919: } else {
2920: $r->print(&header().
2921: '<span class="LC_error">'.&mt('You do not have permission to modify dates or sections for users').'</span>'.
2922: &Apache::loncommon::end_page());
2923: }
1.190 raeburn 2924: } else {
2925: $r->print(&header());
1.202 raeburn 2926: $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management'));
1.207 raeburn 2927: $r->print(&print_main_menu($permission,$context));
1.190 raeburn 2928: $r->print(&Apache::loncommon::end_page());
2929: }
2930: return OK;
2931: }
2932:
2933: sub header {
1.202 raeburn 2934: my ($jscript,$loaditems,$args) = @_;
1.190 raeburn 2935: my $start_page;
2936: if (ref($loaditems) eq 'HASH') {
1.202 raeburn 2937: $start_page=&Apache::loncommon::start_page('User Management',$jscript,{'add_entries' => $loaditems});
1.190 raeburn 2938: } else {
1.202 raeburn 2939: $start_page=&Apache::loncommon::start_page('User Management',$jscript,$args);
1.190 raeburn 2940: }
2941: return $start_page;
2942: }
1.2 www 2943:
1.191 raeburn 2944: sub add_script {
2945: my ($js) = @_;
2946: return '<script type="text/javascript">'."\n".$js."\n".'</script>';
2947: }
2948:
1.202 raeburn 2949: sub verify_user_display {
2950: my $output = <<"END";
2951:
2952: function display_update() {
2953: document.studentform.action.value = 'listusers';
2954: document.studentform.phase.value = 'display';
2955: document.studentform.submit();
2956: }
2957:
2958: END
2959: return $output;
2960:
2961: }
2962:
1.190 raeburn 2963: ###############################################################
2964: ###############################################################
2965: # Menu Phase One
2966: sub print_main_menu {
1.208 raeburn 2967: my ($permission,$context) = @_;
2968: my %links = (
2969: domain => {
2970: upload => 'Upload a File of Users',
1.221 raeburn 2971: singleuser => 'Add/Modify a Single User',
1.208 raeburn 2972: listusers => 'Manage Multiple Users',
2973: },
2974: author => {
2975: upload => 'Upload a File of Co-authors',
1.221 raeburn 2976: singleuser => 'Add/Modify a Single Co-author',
1.208 raeburn 2977: listusers => 'Display Co-authors and Manage Multiple Users',
2978: },
2979: course => {
2980: upload => 'Upload a File of Course Users',
1.221 raeburn 2981: singleuser => 'Add/Modify a Single Course User',
1.208 raeburn 2982: listusers => 'Display Class Lists and Manage Multiple Users',
2983: },
2984: );
1.190 raeburn 2985: my @menu =
2986: (
1.208 raeburn 2987: { text => $links{$context}{'upload'},
1.224 raeburn 2988: help => 'Course_Create_Class_List',
1.190 raeburn 2989: action => 'upload',
2990: permission => $permission->{'cusr'},
2991: },
1.208 raeburn 2992: { text => $links{$context}{'singleuser'},
1.224 raeburn 2993: help => 'Course_Change_Privileges',
1.190 raeburn 2994: action => 'singleuser',
2995: permission => $permission->{'cusr'},
2996: },
1.208 raeburn 2997: { text => $links{$context}{'listusers'},
1.224 raeburn 2998: help => 'Course_View_Class_List',
1.191 raeburn 2999: action => 'listusers',
1.208 raeburn 3000: permission => ($permission->{'view'} || $permission->{'cusr'}),
1.190 raeburn 3001: },
3002: );
1.208 raeburn 3003: if ($context eq 'domain' || $context eq 'course') {
3004: my $customlink = { text => 'Edit Custom Roles',
1.224 raeburn 3005: help => 'Course_Editing_Custom_Roles',
1.208 raeburn 3006: action => 'custom',
3007: permission => $permission->{'custom'},
3008: };
3009: push(@menu,$customlink);
3010: }
3011: if ($context eq 'course') {
1.213 raeburn 3012: my ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity();
3013: my @courselinks =
1.208 raeburn 3014: (
1.213 raeburn 3015: { text => 'Enroll a Single Student',
1.224 raeburn 3016: help => 'Course_Add_Student',
1.213 raeburn 3017: action => 'singlestudent',
3018: permission => $permission->{'cusr'},
3019: },
3020: { text => 'Drop Students',
3021: help => 'Course_Drop_Student',
3022: action => 'drop',
3023: permission => $permission->{'cusr'},
3024: });
3025: if (!exists($permission->{'cusr_section'})) {
3026: push(@courselinks,
3027: { text => 'Automated Student Enrollment Manager',
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>