--- loncom/interface/loncreateuser.pm 2005/06/23 21:56:12 1.106
+++ loncom/interface/loncreateuser.pm 2007/08/15 16:25:14 1.172
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.106 2005/06/23 21:56:12 www Exp $
+# $Id: loncreateuser.pm,v 1.172 2007/08/15 16:25:14 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -64,6 +64,8 @@ use Apache::Constants qw(:common :http);
use Apache::lonnet;
use Apache::loncommon;
use Apache::lonlocal;
+use Apache::longroup;
+use LONCAPA qw(:DEFAULT :match);
my $loginscript; # piece of javascript used in two separate instances
my $generalrule;
@@ -96,8 +98,8 @@ sub initialize_authen_forms {
sub my_custom_roles {
my %returnhash=();
my %rolehash=&Apache::lonnet::dump('roles');
- foreach (keys %rolehash) {
- if ($_=~/^rolesdef\_(\w+)$/) {
+ foreach my $key (keys %rolehash) {
+ if ($key=~/^rolesdef\_(\w+)$/) {
$returnhash{$1}=$1;
}
}
@@ -113,77 +115,300 @@ sub authorpriv {
return 1;
}
+# ====================================================
+
+sub portfolio_quota {
+ my ($ccuname,$ccdomain) = @_;
+ my %lt = &Apache::lonlocal::texthash(
+ 'disk' => "Disk space allocated to user's portfolio files",
+ 'cuqu' => "Current quota",
+ 'cust' => "Custom quota",
+ 'defa' => "Default",
+ 'chqu' => "Change quota",
+ );
+ my ($currquota,$quotatype,$inststatus,$defquota) =
+ &Apache::loncommon::get_user_quota($ccuname,$ccdomain);
+ my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($ccdomain);
+ my ($longinsttype,$showquota,$custom_on,$custom_off,$defaultinfo);
+ if ($inststatus ne '') {
+ if ($usertypes->{$inststatus} ne '') {
+ $longinsttype = $usertypes->{$inststatus};
+ }
+ }
+ $custom_on = ' ';
+ $custom_off = ' checked="checked" ';
+ my $quota_javascript = <<"END_SCRIPT";
+
+END_SCRIPT
+ if ($quotatype eq 'custom') {
+ $custom_on = $custom_off;
+ $custom_off = ' ';
+ $showquota = $currquota;
+ if ($longinsttype eq '') {
+ $defaultinfo = &mt('For this user, the default quota would be [_1]
+ Mb.',$defquota);
+ } else {
+ $defaultinfo = &mt("For this user, the default quota would be [_1]
+ Mb, as determined by the user's institutional
+ affiliation ([_2]).",$defquota,$longinsttype);
+ }
+ } else {
+ if ($longinsttype eq '') {
+ $defaultinfo = &mt('For this user, the default quota is [_1]
+ Mb.',$defquota);
+ } else {
+ $defaultinfo = &mt("For this user, the default quota of [_1]
+ Mb, is determined by the user's institutional
+ affiliation ([_2]).",$defquota,$longinsttype);
+ }
+ }
+ my $output = $quota_javascript.
+ '
'.$lt{'disk'}.'
'.
+ $lt{'cuqu'}.': '.$currquota.' Mb. '.
+ $defaultinfo.'
'.$lt{'chqu'}.
+ ': '.
+ ' '.
+ ' Mb';
+ return $output;
+}
+
# =================================================================== Phase one
sub print_username_entry_form {
- my $r=shift;
+ my ($r,$response,$srch,$forcenewuser) = @_;
my $defdom=$env{'request.role.domain'};
- my @domains = &Apache::loncommon::get_domains();
- my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
- my $html=&Apache::lonxml::xmlbegin();
- my $bodytag =&Apache::loncommon::bodytag('Create Users, Change User Privileges').&Apache::loncommon::help_open_menu('',undef,undef,'',282,'Instructor Interface');
- my $selscript=&Apache::loncommon::studentbrowser_javascript();
- my $sellink=&Apache::loncommon::selectstudent_link
- ('crtuser','ccuname','ccdomain');
+ my $formtoset = 'crtuser';
+ if (exists($env{'form.startrolename'})) {
+ $formtoset = 'docustom';
+ $env{'form.rolename'} = $env{'form.startrolename'};
+ }
+
+ my ($jsback,$elements) = &crumb_utilities();
+
+ my $jscript = &Apache::loncommon::studentbrowser_javascript()."\n".
+ ''."\n";
+
+ my %loaditems = (
+ 'onload' => "javascript:setFormElements(document.$formtoset)",
+ );
+ my $start_page =
+ &Apache::loncommon::start_page('Create Users, Change User Privileges',
+ $jscript,{'add_entries' => \%loaditems,});
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:backPage(document.crtuser)",
+ text=>"User modify/custom role edit",
+ faq=>282,bug=>'Instructor Interface',});
+
+ my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management');
my %existingroles=&my_custom_roles();
my $choice=&Apache::loncommon::select_form('make new role','rolename',
('make new role' => 'Generate new role ...',%existingroles));
my %lt=&Apache::lonlocal::texthash(
- 'siur' => "Set Individual User Roles",
+ 'srch' => "User Search",
+ or => "or",
+ 'siur' => "Set Individual User Roles",
'usr' => "Username",
'dom' => "Domain",
- 'usrr' => "User Roles",
'ecrp' => "Edit Custom Role Privileges",
'nr' => "Name of Role",
- 'cre' => "Custom Role Editor"
+ 'cre' => "Custom Role Editor",
+ 'mod' => "to add/modify roles",
);
+ my $help = &Apache::loncommon::help_open_menu(undef,undef,282,'Instructor Interface');
my $helpsiur=&Apache::loncommon::help_open_topic('Course_Change_Privileges');
my $helpecpr=&Apache::loncommon::help_open_topic('Course_Editing_Custom_Roles');
- $r->print(<<"ENDDOCUMENT");
-$html
-
-The LearningOnline Network with CAPA
-$selscript
-
-$bodytag
-
-ENDDOCUMENT
- if (&Apache::lonnet::allowed('mcr','/')) {
- $r->print(<$lt{'srch'} $sellink $lt{'mod'}
+$response");
+ $r->print(&entry_form($defdom,$srch,$forcenewuser));
+ if (&Apache::lonnet::allowed('mcr','/')) {
+ $r->print(<
-
+
$lt{'ecrp'}$helpecpr
$lt{'nr'}: $choice
-