[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonpickuser.pm
raeburn
raeburn@source.lon-capa.org
Wed, 05 Jan 2011 18:39:38 -0000
raeburn Wed Jan 5 18:39:38 2011 EDT
Modified files:
/loncom/interface lonpickuser.pm loncommon.pm
Log:
- Additional arg - $context - for loncommon::user_picker().
- Required domain for new user when requesting course creation is course's domain
instead of domain of current role.
Index: loncom/interface/lonpickuser.pm
diff -u loncom/interface/lonpickuser.pm:1.4 loncom/interface/lonpickuser.pm:1.5
--- loncom/interface/lonpickuser.pm:1.4 Sun Sep 6 19:09:54 2009
+++ loncom/interface/lonpickuser.pm Wed Jan 5 18:39:38 2011
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Search for a user
#
-# $Id: lonpickuser.pm,v 1.4 2009/09/06 19:09:54 raeburn Exp $
+# $Id: lonpickuser.pm,v 1.5 2011/01/05 18:39:38 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -203,10 +203,12 @@
($srch{'srchtype'} eq 'exact') &&
($srch{'srchdomain'} ne '') &&
($srch{'srchterm'} ne '')) {
+ my (%curr_rules,%got_rules);
my ($rules,$ruleorder) =
&Apache::lonnet::inst_userrules($srch{'srchdomain'},'username');
$usertype = &Apache::lonuserutils::check_usertype($srch{'srchdomain'},
- $srch{'srchterm'},$rules);
+ $srch{'srchterm'},$rules,
+ \%curr_rules,\%got_rules);
}
my $dom = $env{'form.coursedom'};
@@ -215,7 +217,8 @@
&Apache::lonuserutils::can_create_user($dom,$context,$usertype);
my $userpicker =
&Apache::loncommon::user_picker($dom,\%srch,$forcenewuser,
- 'document.userpicker',$cancreate,$usertype);
+ 'document.userpicker',$cancreate,
+ $usertype,$context);
my $srchbutton = &mt('Search');
my $headertext = &mt('Search for a user to add to course personnel');
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.993 loncom/interface/loncommon.pm:1.994
--- loncom/interface/loncommon.pm:1.993 Mon Jan 3 14:19:38 2011
+++ loncom/interface/loncommon.pm Wed Jan 5 18:39:38 2011
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.993 2011/01/03 14:19:38 raeburn Exp $
+# $Id: loncommon.pm,v 1.994 2011/01/05 18:39:38 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -7676,7 +7676,7 @@
}
sub user_picker {
- my ($dom,$srch,$forcenewuser,$caller,$cancreate,$usertype) = @_;
+ my ($dom,$srch,$forcenewuser,$caller,$cancreate,$usertype,$context) = @_;
my $currdom = $dom;
my %curr_selected = (
srchin => 'dom',
@@ -7767,10 +7767,15 @@
$srchtypesel .= "\n </select>\n";
my ($newuserscript,$new_user_create);
-
+ my $context_dom = $env{'request.role.domain'};
+ if ($context eq 'requestcrs') {
+ if ($env{'form.coursedom'} ne '') {
+ $context_dom = $env{'form.coursedom'};
+ }
+ }
if ($forcenewuser) {
if (ref($srch) eq 'HASH') {
- if ($srch->{'srchby'} eq 'uname' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchin'} eq 'dom' && $srch->{'srchdomain'} eq $env{'request.role.domain'}) {
+ if ($srch->{'srchby'} eq 'uname' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchin'} eq 'dom' && $srch->{'srchdomain'} eq $context_dom) {
if ($cancreate) {
$new_user_create = '<p> <input type="submit" name="forcenew" value="'.&HTML::Entities::encode(&mt('Make new user "[_1]"',$srchterm),'<>&"').'" onclick="javascript:setSearch(\'1\','.$caller.');" /> </p>';
} else {
@@ -7809,7 +7814,7 @@
}
}
for (var i=0; i<callingForm.srchdomain.length; i++) {
- if (callingForm.srchdomain.options[i].value == '$env{'request.role.domain'}') {
+ if (callingForm.srchdomain.options[i].value == '$context_dom') {
callingForm.srchdomain.selectedIndex = i;
}
}