[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm loncreateuser.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Sun, 06 Jan 2008 04:38:57 -0000
This is a MIME encoded message
--raeburn1199594337
Content-Type: text/plain
raeburn Sat Jan 5 23:38:57 2008 EDT
Modified files:
/loncom/interface loncreateuser.pm loncommon.pm
Log:
- "Select User" link moved to work with direct username entry form.
- Wording changes, customized to "Add single user" or "Enroll single student"
- Eliminate phrase-splitting, to facilitate localization
- Consistent word use in breadcrumbs via &singleuser_breadcrumb()
- Institutional searches disallowed for usertype (include 'Other') as searcher's type, if no type in searcher's %env.
- new CSS span: LC_cusr_subheading
--raeburn1199594337
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20080105233857.txt"
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.228 loncom/interface/loncreateuser.pm:1.229
--- loncom/interface/loncreateuser.pm:1.228 Wed Jan 2 04:16:59 2008
+++ loncom/interface/loncreateuser.pm Sat Jan 5 23:38:57 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.228 2008/01/02 09:16:59 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.229 2008/01/06 04:38:57 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -220,6 +220,7 @@
my %loaditems = (
'onload' => "javascript:setFormElements(document.$formtoset)",
);
+ my %breadcrumb_text = &singleuser_breadcrumb();
my $start_page =
&Apache::loncommon::start_page('User Management',
$jscript,{'add_entries' => \%loaditems,});
@@ -230,7 +231,7 @@
} else {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:backPage(document.crtuser)",
- text=>"Single user search",
+ text=>$breadcrumb_text{'search'},
faq=>282,bug=>'Instructor Interface',});
}
my $helpitem = 'Course_Change_Privileges';
@@ -245,21 +246,14 @@
my $choice=&Apache::loncommon::select_form('make new role','rolename',
('make new role' => 'Generate new role ...',%existingroles));
my %lt=&Apache::lonlocal::texthash(
- 'srch' => "User Search",
- or => "or",
+ 'srst' => 'Search for a user and enroll as a student',
+ 'srad' => 'Search for a user and modify/add user information or roles',
'usr' => "Username",
'dom' => "Domain",
'ecrp' => "Edit Custom Role Privileges",
'nr' => "Name of Role",
'cre' => "Custom Role Editor",
- 'mod' => "to modify user information or add/modify roles",
- 'enrl' => "to enroll one student",
);
- my $help = &Apache::loncommon::help_open_menu(undef,undef,282,'Instructor Interface');
- my $sellink=&Apache::loncommon::selectstudent_link('crtuser','srchterm','srchdomain');
- if ($sellink) {
- $sellink = "$lt{'or'} ".$sellink;
- }
$r->print($start_page."\n".$crumbs);
if ($env{'form.action'} eq 'custom') {
if (&Apache::lonnet::allowed('mcr','/')) {
@@ -274,12 +268,12 @@
ENDCUSTOM
}
} else {
- my $actiontext = $lt{'mod'};
+ my $actiontext = $lt{'srad'};
if ($env{'form.action'} eq 'singlestudent') {
- $actiontext = $lt{'enrl'};
+ $actiontext = $lt{'srst'};
}
$r->print("
-<h3>$lt{'srch'} $sellink $actiontext</h3>");
+<h3>$actiontext</h3>");
if ($env{'form.origform'} ne 'crtusername') {
$r->print("\n".$response);
}
@@ -291,7 +285,7 @@
sub entry_form {
my ($dom,$srch,$forcenewuser,$context,$responsemsg) = @_;
my %domconf = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom);
- my $usertype;
+ my ($usertype,$inexact);
if (ref($srch) eq 'HASH') {
if (($srch->{'srchin'} eq 'dom') &&
($srch->{'srchby'} eq 'uname') &&
@@ -301,6 +295,8 @@
my ($rules,$ruleorder) =
&Apache::lonnet::inst_userrules($srch->{'srchdomain'},'username');
$usertype = &Apache::lonuserutils::check_usertype($srch->{'srchdomain'},$srch->{'srchterm'},$rules);
+ } else {
+ $inexact = 1;
}
}
my $cancreate =
@@ -309,6 +305,11 @@
&Apache::loncommon::user_picker($dom,$srch,$forcenewuser,
'document.crtuser',$cancreate,$usertype);
my $srchbutton = &mt('Search');
+ if ($env{'form.action'} eq 'singlestudent') {
+ $srchbutton = &mt('Search and Enroll');
+ } elsif ($cancreate && $responsemsg ne '' && $inexact) {
+ $srchbutton = &mt('Search or Add New User');
+ }
my $output = <<"ENDBLOCK";
<form action="/adm/createuser" method="post" name="crtuser">
<input type="hidden" name="action" value="$env{'form.action'}" />
@@ -317,16 +318,39 @@
<input name="userrole" type="button" value="$srchbutton" onclick="javascript:validateEntry(document.crtuser)" />
</form>
ENDBLOCK
- if ($cancreate && $env{'form.phase'} eq '') {
+ if ($env{'form.phase'} eq '') {
my $defdom=$env{'request.role.domain'};
my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');
my %lt=&Apache::lonlocal::texthash(
+ 'enro' => 'Enroll one student',
+ 'admo' => 'Add/modify a single user',
+ 'crea' => 'create new user if required',
+ 'uskn' => "username is known",
'crnu' => 'Create a new user',
'usr' => 'Username',
'dom' => 'in domain',
- 'cra' => 'Create user',
+ 'enrl' => 'Enroll',
+ 'cram' => 'Create/Modify user',
);
+ my $sellink=&Apache::loncommon::selectstudent_link('crtusername','srchterm','srchdomain');
+ my ($title,$buttontext,$showresponse);
+ if ($env{'form.action'} eq 'singlestudent') {
+ $title = $lt{'enro'};
+ $buttontext = $lt{'enrl'};
+ } else {
+ $title = $lt{'admo'};
+ $buttontext = $lt{'cram'};
+ }
+ if ($cancreate) {
+ $title .= ' <span class="LC_cusr_subheading">('.$lt{'crea'}.')</span>';
+ } else {
+ $title .= ' <span class="LC_cusr_subheading">('.$lt{'uskn'}.')</span>';
+ }
+ if ($env{'form.origform'} eq 'crtusername') {
+ $showresponse = $responsemsg;
+ }
$output .= <<"ENDDOCUMENT";
+<br />
<form action="/adm/createuser" method="post" name="crtusername">
<input type="hidden" name="action" value="$env{'form.action'}" />
<input type="hidden" name="phase" value="createnewuser" />
@@ -335,14 +359,15 @@
<input type="hidden" name="srchin" value="dom" />
<input type="hidden" name="forcenewuser" value="1" />
<input type="hidden" name="origform" value="crtusername" />
-<h3>$lt{crnu}</h3>
-$responsemsg
+<h3>$title</h3>
+$showresponse
<table>
<tr>
<td>$lt{'usr'}:</td>
<td><input type="text" size="15" name="srchterm" /></td>
<td> $lt{'dom'}:</td><td>$domform</td>
- <td> <input name="userrole" type="submit" value="$lt{'cra'}" /></td>
+ <td> $sellink </td>
+ <td> <input name="userrole" type="submit" value="$buttontext" /></td>
</tr>
</table>
</form>
@@ -380,7 +405,7 @@
# =================================================================== Phase two
sub print_user_selection_page {
- my ($r,$response,$srch,$srch_results,$operation,$srcharray,$context) = @_;
+ my ($r,$response,$srch,$srch_results,$srcharray,$context) = @_;
my @fields = ('username','domain','lastname','firstname','permanentemail');
my $sortby = $env{'form.sortby'};
@@ -415,27 +440,22 @@
'permanentemail' => "permanent e-mail",
);
$r->print(&Apache::loncommon::start_page('User Management',$jscript));
- if ($operation eq 'createuser') {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:backPage(document.usersrchform,'','')",
- text=>"Create/modify user",
- faq=>282,bug=>'Instructor Interface',},
- {href=>"javascript:backPage(document.usersrchform,'get_user_info','select')",
- text=>"Select User",
- faq=>282,bug=>'Instructor Interface',});
+
+ my %breadcrumb_text = &singleuser_breadcrumb();
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:backPage(document.usersrchform,'','')",
+ text=>$breadcrumb_text{'search'},
+ faq=>282,bug=>'Instructor Interface',},
+ {href=>"javascript:backPage(document.usersrchform,'get_user_info','select')",
+ text=>$breadcrumb_text{'userpicked'},
+ faq=>282,bug=>'Instructor Interface',});
+ if ($env{'form.action'} eq 'singleuser') {
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
'Course_Change_Privileges'));
$r->print("<b>$lt{'usrch'}</b><br />");
$r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context));
$r->print('<h3>'.$lt{'usel'}.'</h3>');
- } elsif ($operation eq 'enrollstudent') {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:backPage(document.usersrchform,'','')",
- text=>"Create/modify student",
- faq=>282,bug=>'Instructor Interface',},
- {href=>"javascript:backPage(document.usersrchform,'get_user_info','select')",
- text=>"Select Student",
- faq=>282,bug=>'Instructor Interface',});
+ } elsif ($env{'form.action'} eq 'singlestudent') {
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
'Course_Add_Student'));
$r->print($jscript."<b>$lt{'stusrch'}</b><br />");
@@ -842,7 +862,7 @@
$breadcrumb_text{'userpicked'} = 'Select a user',
$breadcrumb_text{'modify'} = 'Set section/dates',
} else {
- $breadcrumb_text{'search'} = 'Create/modify user';
+ $breadcrumb_text{'search'} = 'Create/modify a user';
$breadcrumb_text{'userpicked'} = 'Select a user',
$breadcrumb_text{'modify'} = 'Set user role',
}
@@ -2768,7 +2788,6 @@
foreach my $item (@search) {
$srch->{$item} = $env{'form.'.$item};
}
-
if (($phase eq 'get_user_info') || ($phase eq 'userpicked') ||
($phase eq 'createnewuser')) {
if ($env{'form.phase'} eq 'createnewuser') {
@@ -2791,14 +2810,8 @@
$currstate = $env{'form.currstate'};
}
if ($currstate eq 'select') {
- my $operation;
- if ($env{'form.action'} eq 'singleuser') {
- $operation = 'createuser';
- } elsif ($env{'form.action'} eq 'singlestudent') {
- $operation = 'enrollstudent';
- }
&print_user_selection_page($r,$response,$srch,$results,
- $operation,\@search,$context);
+ \@search,$context);
} elsif ($currstate eq 'modify') {
my ($ccuname,$ccdomain);
if (($srch->{'srchby'} eq 'uname') &&
@@ -2820,6 +2833,7 @@
} elsif ($currstate eq 'query') {
&print_user_query_page($r,'createuser');
} else {
+ $env{'form.phase'} = '';
&print_username_entry_form($r,$context,$response,$srch,
$forcenewuser);
}
@@ -3311,11 +3325,15 @@
my ($insttypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($srch->{'srchdomain'});
my @longtypes;
foreach my $item (@usertypes) {
- push (@longtypes,$insttypes->{$item});
+ if (defined($insttypes->{$item})) {
+ push (@longtypes,$insttypes->{$item});
+ } elsif ($item eq 'default') {
+ push (@longtypes,&mt('other'));
+ }
}
my $insttype_str = join(', ',@longtypes);
return &mt('Institutional directory search in domain: [_1] is not available to your user type: ',$showdom).$insttype_str;
- }
+ }
} else {
$can_search = 1;
}
@@ -3436,7 +3454,7 @@
&Apache::lonuserutils::can_create_user($env{'request.role.domain'},$context);
if ($cancreate) {
my $showdom = &display_domain_info($env{'request.role.domain'});
- $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 />';
+ $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 />';
} else {
my $helplink = ' href="javascript:helpMenu('."'display'".')"';
$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 />';
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.632 loncom/interface/loncommon.pm:1.633
--- loncom/interface/loncommon.pm:1.632 Fri Jan 4 13:08:11 2008
+++ loncom/interface/loncommon.pm Sat Jan 5 23:38:57 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.632 2008/01/04 18:08:11 raeburn Exp $
+# $Id: loncommon.pm,v 1.633 2008/01/06 04:38:57 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -4979,6 +4979,11 @@
font-style: italic;
}
+span.LC_cusr_subheading {
+ font-weight: normal;
+ font-size: 85%;
+}
+
table.LC_docs_documents {
background: #BBBBBB;
border-width: 0px;
--raeburn1199594337--