version 1.152, 2007/06/07 23:11:05
|
version 1.153, 2007/06/11 19:41:35
|
Line 1611 sub custom_role_editor {
|
Line 1611 sub custom_role_editor {
|
&print_username_entry_form($r); |
&print_username_entry_form($r); |
return; |
return; |
} |
} |
my $head_script = "\n"; |
# ------------------------------------------------------- What can be assigned? |
$head_script .= '<script type="text/javascript">'."\n"; |
my %full=(); |
$head_script .= 'function set_ta() {'."\n"; |
my %courselevel=(); |
my @ta_c = split(/:/,$Apache::lonnet::pr{'ta:c'}); |
my %courselevelcurrent=(); |
foreach my $priv_item (@ta_c) { |
|
my ($priv, $dummy) = split(/\&/,$priv_item); |
|
$head_script .= "document.form1.$priv"."_c.checked = true;\n"; |
|
} |
|
my @ta_d = split(/:/,$Apache::lonnet::pr{'ta:d'}); |
|
foreach my $priv_item (@ta_d) { |
|
my ($priv, $dummy) = split(/\&/,$priv_item); |
|
$head_script .= "document.form1.$priv"."_d.checked = true;\n"; |
|
} |
|
|
|
$head_script .= '}'."\n"; |
|
$head_script .= '</script>'."\n"; |
|
$r->print(&Apache::loncommon::start_page('Custom Role Editor',$head_script)); |
|
my $syspriv=''; |
my $syspriv=''; |
my $dompriv=''; |
my $dompriv=''; |
my $coursepriv=''; |
my $coursepriv=''; |
|
my $body_top; |
my ($disp_dummy,$disp_roles) = &Apache::lonnet::get('roles',["st"]); |
my ($disp_dummy,$disp_roles) = &Apache::lonnet::get('roles',["st"]); |
my ($rdummy,$roledef)= |
my ($rdummy,$roledef)= |
&Apache::lonnet::get('roles',["rolesdef_$rolename"]); |
&Apache::lonnet::get('roles',["rolesdef_$rolename"]); |
# ------------------------------------------------------- Does this role exist? |
# ------------------------------------------------------- Does this role exist? |
$r->print('<h2>'); |
$body_top .= '<h2>'; |
if (($rdummy ne 'con_lost') && ($roledef ne '')) { |
if (($rdummy ne 'con_lost') && ($roledef ne '')) { |
$r->print(&mt('Existing Role').' "'); |
$body_top .= &mt('Existing Role').' "'; |
# ------------------------------------------------- Get current role privileges |
# ------------------------------------------------- Get current role privileges |
($syspriv,$dompriv,$coursepriv)=split(/\_/,$roledef); |
($syspriv,$dompriv,$coursepriv)=split(/\_/,$roledef); |
} else { |
} else { |
$r->print(&mt('New Role').' "'); |
$body_top .= &mt('New Role').' "'; |
$roledef=''; |
$roledef=''; |
} |
} |
$r->print($rolename.'"</h2>'); |
$body_top .= $rolename.'"</h2>'; |
# ------------------------------------------------------- What can be assigned? |
|
my %full=(); |
|
my %courselevel=(); |
|
my %courselevelcurrent=(); |
|
my @roles = ("ta:c","ta:d","ta:s"); |
|
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) { |
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) { |
|
|
my ($priv,$restrict)=split(/\&/,$item); |
my ($priv,$restrict)=split(/\&/,$item); |
if (!$restrict) { $restrict='F'; } |
if (!$restrict) { $restrict='F'; } |
$courselevel{$priv}=$restrict; |
$courselevel{$priv}=$restrict; |
Line 1682 sub custom_role_editor {
|
Line 1664 sub custom_role_editor {
|
} |
} |
$full{$priv}=1; |
$full{$priv}=1; |
} |
} |
|
|
|
my $head_script = "\n"; |
|
$head_script .= '<script type="text/javascript">'."\n"; |
|
$head_script .= &make_script_template('ta'); |
|
$head_script .= '</script>'."\n"; |
|
$r->print(&Apache::loncommon::start_page('Custom Role Editor',$head_script)); |
|
$r->print($body_top); |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'prv' => "Privilege", |
'prv' => "Privilege", |
'crl' => "Course Level", |
'crl' => "Course Level", |
Line 1718 ENDCCF
|
Line 1707 ENDCCF
|
'<input type="submit" value="'.&mt('Define Role').'" /></form>'. |
'<input type="submit" value="'.&mt('Define Role').'" /></form>'. |
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
} |
} |
|
# -------------------------------------------------------- |
|
sub make_script_template { |
|
my ($role) = @_; |
|
my %full_c=(); |
|
my %full_d=(); |
|
my %full_s=(); |
|
my $return_script; |
|
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) { |
|
my ($priv,$restrict)=split(/\&/,$item); |
|
$full_c{$priv}=1; |
|
} |
|
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) { |
|
my ($priv,$restrict)=split(/\&/,$item); |
|
$full_d{$priv}=1; |
|
} |
|
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) { |
|
my ($priv,$restrict)=split(/\&/,$item); |
|
$full_s{$priv}=1; |
|
} |
|
$return_script .= 'function set_'.$role.'() {'."\n"; |
|
my @temp = split(/:/,$Apache::lonnet::pr{$role.':c'}); |
|
my %role_c; |
|
foreach my $priv(@temp) { |
|
my ($priv_item, $dummy) = split(/\&/,$priv); |
|
$role_c{$priv_item} = 1; |
|
} |
|
foreach my $priv_item (keys(%full_c)) { |
|
my ($priv, $dummy) = split(/\&/,$priv_item); |
|
if (exists($role_c{$priv})) { |
|
$return_script .= "document.form1.$priv"."_c.checked = true;\n"; |
|
} else { |
|
$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 ($priv, $dummy) = split(/\&/,$priv_item); |
|
$return_script .= "document.form1.$priv"."_d.checked = true;\n"; |
|
} |
|
|
|
$return_script .= '}'."\n"; |
|
return $return_script; |
|
} |
|
|
# ---------------------------------------------------------- Call to definerole |
# ---------------------------------------------------------- Call to definerole |
sub set_custom_role { |
sub set_custom_role { |