[LON-CAPA-cvs] cvs: loncom /interface loncoursequeueadmin.pm loncreatecourse.pm lonrequestcourse.pm
raeburn
raeburn@source.lon-capa.org
Thu, 27 Aug 2009 00:06:18 -0000
This is a MIME encoded message
--raeburn1251331578
Content-Type: text/plain
raeburn Thu Aug 27 00:06:18 2009 EDT
Modified files:
/loncom/interface lonrequestcourse.pm loncreatecourse.pm
loncoursequeueadmin.pm
Log:
- Domain Coordinators approving requests can view details of request in a pop-up window.
--raeburn1251331578
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20090827000618.txt"
Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.25 loncom/interface/lonrequestcourse.pm:1.26
--- loncom/interface/lonrequestcourse.pm:1.25 Tue Aug 25 14:59:53 2009
+++ loncom/interface/lonrequestcourse.pm Thu Aug 27 00:06:18 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.25 2009/08/25 14:59:53 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.26 2009/08/27 00:06:18 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -122,13 +122,42 @@
return OK;
}
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','showdom','cnum']);
&Apache::lonhtmlcommon::clear_breadcrumbs();
my $dom = &get_course_dom();
my $action = $env{'form.action'};
my $state = $env{'form.state'};
my %stored;
my $jscript;
- if ((defined($state)) && (defined($action))) {
+ my ($uname,$udom,$result,$warning);
+ if ($action eq 'display') {
+ if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) {
+ my $namespace = 'courserequestqueue';
+ if ($env{'form.cnum'} ne '') {
+ my $cnum = $env{'form.cnum'};
+ my $reqkey = $cnum.'_approval';
+ my $namespace = 'courserequestqueue';
+ my $domconfig = &Apache::lonnet::get_domainconfiguser($dom);
+ my %queued =
+ &Apache::lonnet::get($namespace,[$reqkey],$dom,$domconfig);
+ if (ref($queued{$reqkey}) eq 'HASH') {
+ $uname = $queued{$reqkey}{'ownername'};
+ $udom = $queued{$reqkey}{'ownerdom'};
+ if (($udom =~ /^$match_domain$/) && ($uname =~ /^$match_username$/)) {
+ $result = &retrieve_settings($dom,$cnum,$udom,$uname);
+ } else {
+ $warning = &mt('Invalid username or domain for course requestor');
+ }
+ } else {
+ $warning = &mt('No information was found for this course request.');
+ }
+ } else {
+ $warning = &mt('No course request ID provided.');
+ }
+ } else {
+ $warning = &mt('You do not have rights to view course request information.');
+ }
+ } elsif ((defined($state)) && (defined($action))) {
if (($action eq 'view') && ($state eq 'details')) {
if ((defined($env{'form.showdom'})) && (defined($env{'form.cnum'}))) {
my $result = &retrieve_settings($env{'form.showdom'},$env{'form.cnum'});
@@ -154,6 +183,7 @@
my $loaditems = &onload_action($action,$state);
my %states;
+ $states{'display'} = ['details'];
$states{'view'} = ['pick_request','details','cancel','removal'];
$states{'log'} = ['filter','display'];
$states{'new'} = ['courseinfo','enrollment','personnel','review','process'];
@@ -245,10 +275,21 @@
}
} elsif ($action eq 'view') {
if ($state eq 'crstype') {
- &print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb);
+ &print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb);
+ } else {
+ &request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
+ $loaditems,$crumb);
+ }
+ } elsif ($action eq 'display') {
+ if ($warning ne '') {
+ my $args = { only_body => 1 };
+ $r->print(&header('Course Requests','','',$args).$crumb.
+ '<h3>'.&mt('Course Request Details').'</h3>'.
+ '<div class="LC_warning">'.$warning.'</div>'.
+ &close_popup_form());
} else {
- &request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
- $loaditems,$crumb);
+ &request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
+ $loaditems,$crumb,$uname,$udom);
}
} elsif ($action eq 'log') {
&print_request_logs($jscript,$loaditems,$crumb);
@@ -259,18 +300,24 @@
}
sub header {
- my ($bodytitle,$jscript,$loaditems,$jsextra) = @_;
+ my ($bodytitle,$jscript,$loaditems,$jsextra,$args) = @_;
if ($jscript) {
$jscript = '<script type="text/javascript">'."\n".
'// <![CDATA['."\n".
$jscript."\n".'// ]]>'."\n".'</script>'."\n";
}
if ($loaditems) {
- $loaditems = {'add_entries' => $loaditems,};
- return &Apache::loncommon::start_page($bodytitle,$jscript.$jsextra,$loaditems);
- } else {
- return &Apache::loncommon::start_page($bodytitle,$jscript.$jsextra);
+ if (ref($args) eq 'HASH') {
+ my %loadhash = (
+ 'add_entries' => $loaditems,
+ );
+ my %arghash = (%loadhash,%{$args});
+ $args = \%arghash;
+ } else {
+ $args = {'add_entries' => $loaditems,};
+ }
}
+ return &Apache::loncommon::start_page($bodytitle,$jscript.$jsextra,$args);
}
sub form_elements {
@@ -601,7 +648,7 @@
}
sub request_administration {
- my ($r,$action,$state,$page,$states,$dom,$jscript,$loaditems,$crumb) = @_;
+ my ($r,$action,$state,$page,$states,$dom,$jscript,$loaditems,$crumb,$uname,$udom) = @_;
my $js;
if (($action eq 'new') || (($action eq 'view') && ($state eq 'pick_request'))) {
$js = <<END;
@@ -661,7 +708,7 @@
\%cat_order,\@code_order);
}
$r->print('<h3>'.&mt('Course Request Details').'</h3><div>'."\n".$form."\n".
- &print_review($formname,$dom,\@codetitles,\%cat_titles,\%cat_order,
+ &print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
\@code_order)."\n".
'<input name="origcnum" value="'.$origcnum.'" type="hidden" />'."\n");
my @excluded = &get_excluded_elements($dom,$states,'new','review');
@@ -734,6 +781,18 @@
}
$r->print('</form>');
}
+ } elsif ($action eq 'display') {
+ my $formname = 'requestcrs';
+ my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk);
+ if ($env{'form.crstype'} eq 'official') {
+ &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
+ \%cat_order,\@code_order);
+ }
+ $r->print(&header('Course Request','','','',{ 'only_body' => 1}).
+ $crumb."\n".'<h3>'.&mt('Course Request Details').'</h3>'.
+ &print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
+ \@code_order,$uname,$udom)."\n".'</div>'.
+ &close_popup_form());
} elsif ($action eq 'log') {
$r->print(&coursereq_log('View request log',$jscript,$loaditems).$crumb);
}
@@ -741,6 +800,15 @@
return;
}
+sub close_popup_form {
+ my $close= &mt('Close Window');
+ return << "END";
+<p><form name="displayreq" action="" method="post">
+<input type="button" name="closeme" value="$close" onclick="javascript:self.close();" />
+</form></p>
+END
+}
+
sub print_request_form {
my ($r,$action,$state,$page,$states,$dom) = @_;
my $formname = 'requestcrs';
@@ -841,8 +909,7 @@
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
\%cat_order,\@code_order);
$r->print('<p>'.&mt('Review the details of the course request before submission.').'</p>'.
- &print_review($formname,$dom,\@codetitles,\%cat_titles,\%cat_order,
- \@code_order).
+ &print_review($dom,\@codetitles,\%cat_titles,\%cat_order,\@code_order).
'<input type="hidden" name="cnum" value="'.$cnum.'" />');
$navtxt{'next'} = &mt('Submit course request');
} elsif ($state eq 'process') {
@@ -1350,13 +1417,16 @@
}
sub print_review {
- my ($formname,$dom,$codetitles,$cat_titles,$cat_order,$code_order) = @_;
+ my ($dom,$codetitles,$cat_titles,$cat_order,$code_order,$uname,$udom) = @_;
my ($types,$typename) = &course_types();
my ($owner,$ownername,$owneremail);
- $owner = $env{'user.name'}.':'.$env{'user.domain'};
- $ownername = &Apache::loncommon::plainname($env{'user.name'},
- $env{'user.domain'},'first');
- my %emails = &Apache::loncommon::getemails();
+ if ($uname eq '' || $udom eq '') {
+ $uname = $env{'user.name'};
+ $udom = $env{'user.domain'};
+ }
+ $owner = $uname.':'.$udom;
+ $ownername = &Apache::loncommon::plainname($uname,$udom,'first');
+ my %emails = &Apache::loncommon::getemails($uname,$udom);
foreach my $email ('permanentemail','critnotification','notification') {
$owneremail = $emails{$email};
last if ($owneremail ne '');
@@ -1589,7 +1659,7 @@
'<table class="LC_innerpickbox"><tr>'.$personnel_headers.'</tr>'."\n".
$personnel_values.'</table>'."\n".
&Apache::lonhtmlcommon::row_closure(1).
- &Apache::lonhtmlcommon::end_pick_box();
+ &Apache::lonhtmlcommon::end_pick_box().'</div>';
return $output;
}
@@ -2327,11 +2397,14 @@
}
sub retrieve_settings {
- my ($dom,$cnum) = @_;
- my ($result,%reqinfo) = &get_request_settings($dom,$cnum);
+ my ($dom,$cnum,$udom,$uname) = @_;
+ if ($udom eq '' || $uname eq '') {
+ $udom = $env{'user.domain'};
+ $uname = $env{'user.name'};
+ }
+ my ($result,%reqinfo) = &get_request_settings($dom,$cnum,$udom,$uname);
if ($result eq 'ok') {
- if (($env{'user.name'} eq $reqinfo{'owner'}) &&
- ($env{'user.domain'} eq $reqinfo{'domain'})) {
+ if (($udom eq $reqinfo{'domain'}) && ($uname eq $reqinfo{'owner'})) {
$env{'form.chome'} = $reqinfo{'coursehome'};
$env{'form.cdescr'} = $reqinfo{'cdescr'};
$env{'form.crstype'} = $reqinfo{'crstype'};
@@ -2433,12 +2506,11 @@
}
sub get_request_settings {
- my ($dom,$cnum) = @_;
+ my ($dom,$cnum,$udom,$uname) = @_;
my $requestkey = $dom.'_'.$cnum;
my ($result,%reqinfo);
if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
- my %history = &Apache::lonnet::restore($requestkey,'courserequests',
- $env{'user.domain'},$env{'user.name'});
+ my %history = &Apache::lonnet::restore($requestkey,'courserequests',$udom,$uname);
my $disposition = $history{'disposition'};
if (($disposition eq 'approval') || ($disposition eq 'pending')) {
if (ref($history{'details'}) eq 'HASH') {
Index: loncom/interface/loncreatecourse.pm
diff -u loncom/interface/loncreatecourse.pm:1.125 loncom/interface/loncreatecourse.pm:1.126
--- loncom/interface/loncreatecourse.pm:1.125 Sat Aug 15 14:01:04 2009
+++ loncom/interface/loncreatecourse.pm Thu Aug 27 00:06:18 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Create a course
#
-# $Id: loncreatecourse.pm,v 1.125 2009/08/15 14:01:04 raeburn Exp $
+# $Id: loncreatecourse.pm,v 1.126 2009/08/27 00:06:18 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -902,6 +902,26 @@
}
+sub courserequestbrowser_javascript {
+ return <<"ENDREQBRW";
+<script type="text/javascript">
+// <![CDATA[
+var steditbrowser;
+function opencoursereqdisplay(cdom,cnum) {
+ var url = '/adm/requestcourse?action=display';
+ url += '&showdom='+cdom+'&cnum='+cnum;
+ var title = 'Course_Request_Browser';
+ var options = 'scrollbars=1,resizable=1,menubar=0';
+ options += ',width=700,height=600';
+ var stdeditbrowser = open(url,title,options,'1');
+ stdeditbrowser.focus();
+}
+// ]]>
+</script>
+ENDREQBRW
+}
+
+
# ===================================================================== Handler
sub handler {
my $r = shift;
@@ -962,13 +982,15 @@
({href=>"/adm/createcourse?phase=$env{'form.phase'}",
text=>&mt('[_1] Display Request Queue',),
faq=>9,bug=>'Dom Coord Interface',});
- my $start_page=&Apache::loncommon::start_page('Display Requests');
+ my $js = &courserequestbrowser_javascript();
+ my $start_page=&Apache::loncommon::start_page('Display Requests',$js);
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Display Requests','Course_Request',undef,'Course_Request');
$r->print($start_page.$crumbs."\n".'<div>'.
&Apache::loncoursequeueadmin::display_queued_requests(
'domain',$env{'request.role.domain'}).'</div>'.
&Apache::loncommon::end_page());
} elsif ($env{'form.phase'} eq 'requestchange') {
+
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"/adm/createcourse?phase=requestdisplay",
text=>&mt('[_1] Display Request Queue',),
Index: loncom/interface/loncoursequeueadmin.pm
diff -u loncom/interface/loncoursequeueadmin.pm:1.6 loncom/interface/loncoursequeueadmin.pm:1.7
--- loncom/interface/loncoursequeueadmin.pm:1.6 Mon Aug 24 20:08:36 2009
+++ loncom/interface/loncoursequeueadmin.pm Thu Aug 27 00:06:18 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Utilities to administer domain course requests and course self-enroll requests
#
-# $Id: loncoursequeueadmin.pm,v 1.6 2009/08/24 20:08:36 raeburn Exp $
+# $Id: loncoursequeueadmin.pm,v 1.7 2009/08/27 00:06:18 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -293,8 +293,8 @@
} else {
my ($cnum,$ownername,$ownerdom,$type,$cdesc)=split(/:/,$request,5);
- $detailslink='<a href="javascript::opencoursereqdisplay('.
- "'$dom".'_'."$cnum'".');">'.$cdesc.'</a>';
+ $detailslink='<a href="javascript:opencoursereqdisplay('.
+ "'$dom','$cnum'".');">'.$cdesc.'</a>';
$crstype = $type;
if (defined($crstypes{$type})) {
$crstype = $crstypes{$type};
--raeburn1251331578--