[LON-CAPA-cvs] cvs: loncom /interface loncreateuser.pm
banghart
lon-capa-cvs-allow@mail.lon-capa.org
Mon, 11 Jun 2007 22:13:10 -0000
banghart Mon Jun 11 18:13:10 2007 EDT
Modified files:
/loncom/interface loncreateuser.pm
Log:
Bug 5143. Templates for custom roles.
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.153 loncom/interface/loncreateuser.pm:1.154
--- loncom/interface/loncreateuser.pm:1.153 Mon Jun 11 15:41:35 2007
+++ loncom/interface/loncreateuser.pm Mon Jun 11 18:13:07 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.153 2007/06/11 19:41:35 banghart Exp $
+# $Id: loncreateuser.pm,v 1.154 2007/06/11 22:13:07 banghart Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1664,10 +1664,14 @@
}
$full{$priv}=1;
}
-
+ my $button_code = "\n";
my $head_script = "\n";
$head_script .= '<script type="text/javascript">'."\n";
- $head_script .= &make_script_template('ta');
+ my @template_roles = ("cc","in","ta","ep","st");
+ foreach my $role (@template_roles) {
+ $head_script .= &make_script_template($role);
+ $button_code .= &make_button_code($role);
+ }
$head_script .= '</script>'."\n";
$r->print(&Apache::loncommon::start_page('Custom Role Editor',$head_script));
$r->print($body_top);
@@ -1677,7 +1681,9 @@
'dml' => "Domain Level",
'ssl' => "System Level");
$r->print('Select a Template<br />');
- $r->print('<form action=""><input type="button" onClick="set_ta()" value="TA" /></form>');
+ $r->print('<form action="">');
+ $r->print($button_code);
+ $r->print('</form>');
$r->print(<<ENDCCF);
<form name=form1 method="post">
<input type="hidden" name="phase" value="set_custom_roles" />
@@ -1704,7 +1710,7 @@
&Apache::loncommon::end_data_table_row());
}
$r->print(&Apache::loncommon::end_data_table().
- '<input type="submit" value="'.&mt('Define Role').'" /></form>'.
+ '<input type="reset" value="Reset"><input type="submit" value="'.&mt('Define Role').'" /></form>'.
&Apache::loncommon::end_page());
}
# --------------------------------------------------------
@@ -1722,7 +1728,7 @@
my ($priv,$restrict)=split(/\&/,$item);
$full_d{$priv}=1;
}
- foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
+ foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
my ($priv,$restrict)=split(/\&/,$item);
$full_s{$priv}=1;
}
@@ -1741,16 +1747,44 @@
$return_script .= "document.form1.$priv"."_c.checked = false;\n";
}
}
- my @role_d = split(/:/,$Apache::lonnet::pr{$role.':d'});
- foreach my $priv_item (@role_d) {
+ my %role_d;
+ @temp = split(/:/,$Apache::lonnet::pr{$role.':d'});
+ foreach my $priv(@temp) {
+ my ($priv_item, $dummy) = split(/\&/,$priv);
+ $role_d{$priv_item} = 1;
+ }
+ foreach my $priv_item (keys(%full_d)) {
my ($priv, $dummy) = split(/\&/,$priv_item);
- $return_script .= "document.form1.$priv"."_d.checked = true;\n";
+ if (exists($role_d{$priv})) {
+ $return_script .= "document.form1.$priv"."_d.checked = true;\n";
+ } else {
+ $return_script .= "document.form1.$priv"."_d.checked = false;\n";
+ }
+ }
+ my %role_s;
+ @temp = split(/:/,$Apache::lonnet::pr{$role.':s'});
+ foreach my $priv(@temp) {
+ my ($priv_item, $dummy) = split(/\&/,$priv);
+ $role_s{$priv_item} = 1;
+ }
+ foreach my $priv_item (keys(%full_s)) {
+ my ($priv, $dummy) = split(/\&/,$priv_item);
+ if (exists($role_s{$priv})) {
+ $return_script .= "document.form1.$priv"."_s.checked = true;\n";
+ } else {
+ $return_script .= "document.form1.$priv"."_s.checked = false;\n";
+ }
}
-
$return_script .= '}'."\n";
- return $return_script;
+ return ($return_script);
+}
+# ----------------------------------------------------------
+sub make_button_code {
+ my ($role) = @_;
+ my $label = &Apache::lonnet::plaintext($role);
+ my $button_code = '<input type="button" onClick="set_'.$role.'()" value="'.$label.'" />';
+ return ($button_code);
}
-
# ---------------------------------------------------------- Call to definerole
sub set_custom_role {
my ($r) = @_;