[LON-CAPA-cvs] cvs: loncom /interface loncreateuser.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Sun, 19 Mar 2006 22:15:47 -0000
This is a MIME encoded message
--albertel1142806547
Content-Type: text/plain
albertel Sun Mar 19 17:15:47 2006 EDT
Modified files:
/loncom/interface loncreateuser.pm
Log:
- switch to start_page
--albertel1142806547
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20060319171547.txt"
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.109 loncom/interface/loncreateuser.pm:1.110
--- loncom/interface/loncreateuser.pm:1.109 Tue Sep 13 15:13:22 2005
+++ loncom/interface/loncreateuser.pm Sun Mar 19 17:15:46 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.109 2005/09/13 19:13:22 albertel Exp $
+# $Id: loncreateuser.pm,v 1.110 2006/03/19 22:15:46 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -116,13 +116,15 @@
# =================================================================== Phase one
sub print_username_entry_form {
- my $r=shift;
+ my ($r) = @_;
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 $start_page =
+ &Apache::loncommon::start_page('Create Users, Change User Privileges',
+ $selscript);
+
my $sellink=&Apache::loncommon::selectstudent_link
('crtuser','ccuname','ccdomain');
my %existingroles=&my_custom_roles();
@@ -137,15 +139,10 @@
'nr' => "Name of Role",
'cre' => "Custom Role Editor"
);
+ 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
-<head>
-<title>The LearningOnline Network with CAPA</title>
-$selscript
-</head>
-$bodytag
<form action="/adm/createuser" method="post" name="crtuser">
<input type="hidden" name="phase" value="get_user_info">
<h2>$lt{siur}$helpsiur</h2>
@@ -167,7 +164,92 @@
</form>
ENDCUSTOM
}
- $r->print('</body></html>');
+ $r->print(&Apache::loncommon::end_page());
+}
+
+
+sub user_modification_js {
+ my ($pjump_def, $dc_setcourse_code)=@_;
+ return <<END;
+<script type="text/javascript" language="Javascript">
+
+ function pclose() {
+ parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
+ "height=350,width=350,scrollbars=no,menubar=no");
+ parmwin.close();
+ }
+
+ $pjump_def
+ $dc_setcourse_code
+
+ function dateset() {
+ eval("document.cu."+document.cu.pres_marker.value+
+ ".value=document.cu.pres_value.value");
+ pclose();
+ }
+
+ function setSections() {
+ var re1 = /^currsec_/;
+ for (var i=0;i<document.cu.elements.length;i++) {
+ var str = document.cu.elements[i].name;
+ var checkcurr = str.match(re1);
+ if (checkcurr != null) {
+ var re2 = /^currsec_[a-zA-Z0-9]+_[a-zA-Z0-9]+_(\\w+)\$/;
+ if (document.cu.elements[i-1].checked == true) {
+ var re2 = /^currsec_[a-zA-Z0-9]+_[a-zA-Z0-9]+_(\\w+)\$/;
+ match = re2.exec(str);
+ var role = match[1];
+ if (role == 'cc') {
+ alert("Section designations do not apply to Course Coordinator roles.\\nA course coordinator role will be added with access to all sections.");
+ }
+ else {
+ var sections = '';
+ var numsec = 0;
+ var sections;
+ for (var j=0; j<document.cu.elements[i].length; j++) {
+ if (document.cu.elements[i].options[j].selected == true ) {
+ if (document.cu.elements[i].options[j].value != "") {
+ if (numsec == 0) {
+ if (document.cu.elements[i].options[j].value != "") {
+ sections = document.cu.elements[i].options[j].value;
+ numsec ++;
+ }
+ }
+ else {
+ sections = sections + "," + document.cu.elements[i].options[j].value
+ numsec ++;
+ }
+ }
+ }
+ }
+ if (numsec > 0) {
+ if (document.cu.elements[i+1].value != "" && document.cu.elements[i+1].value != null) {
+ sections = sections + "," + document.cu.elements[i+1].value;
+ }
+ }
+ else {
+ sections = document.cu.elements[i+1].value;
+ }
+ var newsecs = document.cu.elements[i+1].value;
+ if (newsecs != null && newsecs != "") {
+ var numsplit = newsecs.split(/,/g);
+ numsec = numsec + numsplit.length;
+ }
+ if ((role == 'st') && (numsec > 1)) {
+ alert("In each course, each user may only have one student role at a time. You had selected "+numsec+" sections.\\nPlease modify your selections so they include no more than one section.")
+ return;
+ }
+ else {
+ document.cu.elements[i+2].value = sections;
+ }
+ }
+ }
+ }
+ }
+ document.cu.submit();
+ }
+</script>
+END
}
# =================================================================== Phase two
@@ -274,93 +356,12 @@
}
ENDSCRIPT
}
- my $html=&Apache::lonxml::xmlbegin();
- my $dochead =<<"ENDDOCHEAD";
-$html
-<head>
-<title>The LearningOnline Network with CAPA</title>
-<script type="text/javascript" language="Javascript">
- function pclose() {
- parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
- "height=350,width=350,scrollbars=no,menubar=no");
- parmwin.close();
- }
-
- $pjump_def
- $dc_setcourse_code
+ my $js = &user_modification_js($pjump_def, $dc_setcourse_code);
+ my $start_page =
+ &Apache::loncommon::start_page('Create Users, Change User Privileges',
+ $js,{'add_entries' => $loaditem,});
- function dateset() {
- eval("document.cu."+document.cu.pres_marker.value+
- ".value=document.cu.pres_value.value");
- pclose();
- }
-
- function setSections() {
- var re1 = /^currsec_/;
- for (var i=0;i<document.cu.elements.length;i++) {
- var str = document.cu.elements[i].name;
- var checkcurr = str.match(re1);
- if (checkcurr != null) {
- var re2 = /^currsec_[a-zA-Z0-9]+_[a-zA-Z0-9]+_(\\w+)\$/;
- if (document.cu.elements[i-1].checked == true) {
- var re2 = /^currsec_[a-zA-Z0-9]+_[a-zA-Z0-9]+_(\\w+)\$/;
- match = re2.exec(str);
- var role = match[1];
- if (role == 'cc') {
- alert("Section designations do not apply to Course Coordinator roles.\\nA course coordinator role will be added with access to all sections.");
- }
- else {
- var sections = '';
- var numsec = 0;
- var sections;
- for (var j=0; j<document.cu.elements[i].length; j++) {
- if (document.cu.elements[i].options[j].selected == true ) {
- if (document.cu.elements[i].options[j].value != "") {
- if (numsec == 0) {
- if (document.cu.elements[i].options[j].value != "") {
- sections = document.cu.elements[i].options[j].value;
- numsec ++;
- }
- }
- else {
- sections = sections + "," + document.cu.elements[i].options[j].value
- numsec ++;
- }
- }
- }
- }
- if (numsec > 0) {
- if (document.cu.elements[i+1].value != "" && document.cu.elements[i+1].value != null) {
- sections = sections + "," + document.cu.elements[i+1].value;
- }
- }
- else {
- sections = document.cu.elements[i+1].value;
- }
- var newsecs = document.cu.elements[i+1].value;
- if (newsecs != null && newsecs != "") {
- var numsplit = newsecs.split(/,/g);
- numsec = numsec + numsplit.length;
- }
- if ((role == 'st') && (numsec > 1)) {
- alert("In each course, each user may only have one student role at a time. You had selected "+numsec+" sections.\\nPlease modify your selections so they include no more than one section.")
- return;
- }
- else {
- document.cu.elements[i+2].value = sections;
- }
- }
- }
- }
- }
- document.cu.submit();
- }
-</script>
-</head>
-ENDDOCHEAD
- $r->print(&Apache::loncommon::bodytag(
- 'Create Users, Change User Privileges',undef,$loaditem));
my $forminfo =<<"ENDFORMINFO";
<form action="/adm/createuser" method="post" name="cu">
<input type="hidden" name="phase" value="update_user_data">
@@ -402,7 +403,7 @@
my $genhelp=&Apache::loncommon::help_open_topic('Generation');
&initialize_authen_forms();
$r->print(<<ENDNEWUSER);
-$dochead
+$start_page
<h1>$lt{'cnu'}</h1>
$forminfo
<h2>$lt{'nu'} "$ccuname" $lt{'id'} $ccdomain</h2>
@@ -443,7 +444,7 @@
'gen' => "generation"
);
$r->print(<<ENDCHANGEUSER);
-$dochead
+$start_page
<h1>$lt{'cup'}</h1>
$forminfo
<h2>$lt{'usr'} "$ccuname" $lt{'id'} "$ccdomain"</h2>
@@ -863,7 +864,7 @@
$r->print(&course_level_table(%inccourses));
$r->print('<hr /><input type="button" value="'.&mt('Modify User').'" onClick="setSections()">'."\n");
}
- $r->print("</form></body></html>");
+ $r->print("</form>".&Apache::loncommon::end_page());
}
# ================================================================= Phase Three
@@ -873,22 +874,15 @@
$env{'form.ccdomain'});
# Error messages
my $error = '<font color="#ff0000">'.&mt('Error').':</font>';
- my $end = '</body></html>';
- # Print header
- my $html=&Apache::lonxml::xmlbegin();
- $r->print(<<ENDTHREEHEAD);
-$html
-<head>
-<title>The LearningOnline Network with CAPA</title>
-</head>
-ENDTHREEHEAD
+ my $end = &Apache::loncommon::end_page();
+
my $title;
if (exists($env{'form.makeuser'})) {
$title='Set Privileges for New User';
} else {
$title='Modify User Privileges';
}
- $r->print(&Apache::loncommon::bodytag($title));
+ $r->print(&Apache::loncommon::start_page($title));
# Check Inputs
if (! $env{'form.ccuname'} ) {
$r->print($error.&mt('No login name specified').'.'.$end);
@@ -1266,7 +1260,7 @@
# Flush the course logs so reverse user roles immediately updated
&Apache::lonnet::flushcourselogs();
$r->print('<p><a href="/adm/createuser">Create/Modify Another User</a></p>');
- $r->print('</body></html>');
+ $r->print(&Apache::loncommon::end_page());
}
sub commit_customrole {
@@ -1402,14 +1396,14 @@
return;
}
- $r->print(&Apache::loncommon::bodytag(
- 'Create Users, Change User Privileges').'<h2>');
+ $r->print(&Apache::loncommon::start_page('Custom Role Editor'));
my $syspriv='';
my $dompriv='';
my $coursepriv='';
my ($rdummy,$roledef)=
&Apache::lonnet::get('roles',["rolesdef_$rolename"]);
# ------------------------------------------------------- Does this role exist?
+ $r->print('<h2>');
if (($rdummy ne 'con_lost') && ($roledef ne '')) {
$r->print(&mt('Existing Role').' "');
# ------------------------------------------------- Get current role privileges
@@ -1481,12 +1475,13 @@
'</td></tr>');
}
$r->print(
- '<table><input type="submit" value="'.&mt('Define Role').'" /></form></body></html>');
+ '<table><input type="submit" value="'.&mt('Define Role').'" /></form>'.
+ &Apache::loncommon::end_page());
}
# ---------------------------------------------------------- Call to definerole
sub set_custom_role {
- my $r=shift;
+ my ($r) = @_;
my $rolename=$env{'form.rolename'};
@@ -1497,10 +1492,10 @@
return;
}
- $r->print(&Apache::loncommon::bodytag(
- 'Create Users, Change User Privileges').'<h2>');
+ $r->print(&Apache::loncommon::start_page('Save Custom Role').'<h2>');
my ($rdummy,$roledef)=
- &Apache::lonnet::get('roles',["rolesdef_$rolename"]);
+ &Apache::lonnet::get('roles',["rolesdef_$rolename"]);
+
# ------------------------------------------------------- Does this role exist?
if (($rdummy ne 'con_lost') && ($roledef ne '')) {
$r->print(&mt('Existing Role').' "');
@@ -1551,7 +1546,7 @@
$rolename));
}
$r->print('<p><a href="/adm/createuser">Create another role, or Create/Modify a user.</a></p>');
- $r->print('</body></html>');
+ $r->print(&Apache::loncommon::end_page());
}
# ================================================================ Main Handler
--albertel1142806547--