version 1.149, 2007/05/29 17:48:44
|
version 1.152, 2007/06/07 23:11:05
|
Line 751 END
|
Line 751 END
|
$row.=' '; |
$row.=' '; |
} |
} |
my $plaintext=''; |
my $plaintext=''; |
unless ($croletitle) { |
if (!$croletitle) { |
$plaintext=&Apache::lonnet::plaintext($role_code,$class) |
$plaintext=&Apache::lonnet::plaintext($role_code,$class) |
} else { |
} else { |
$plaintext= |
$plaintext= |
Line 1574 sub build_roles {
|
Line 1574 sub build_roles {
|
} else { |
} else { |
foreach my $sec (@secnums) { |
foreach my $sec (@secnums) { |
$sec =~ ~s/\W//g; |
$sec =~ ~s/\W//g; |
unless ($sec eq "") { |
if (!($sec eq "")) { |
if (exists($$sections{$sec})) { |
if (exists($$sections{$sec})) { |
$$sections{$sec} ++; |
$$sections{$sec} ++; |
} else { |
} else { |
Line 1607 sub custom_role_editor {
|
Line 1607 sub custom_role_editor {
|
|
|
$rolename=~s/[^A-Za-z0-9]//gs; |
$rolename=~s/[^A-Za-z0-9]//gs; |
|
|
unless ($rolename) { |
if (!$rolename) { |
&print_username_entry_form($r); |
&print_username_entry_form($r); |
return; |
return; |
} |
} |
|
my $head_script = "\n"; |
$r->print(&Apache::loncommon::start_page('Custom Role Editor')); |
$head_script .= '<script type="text/javascript">'."\n"; |
|
$head_script .= 'function set_ta() {'."\n"; |
|
my @ta_c = split(/:/,$Apache::lonnet::pr{'ta:c'}); |
|
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 ($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? |
Line 1633 sub custom_role_editor {
|
Line 1649 sub custom_role_editor {
|
my %full=(); |
my %full=(); |
my %courselevel=(); |
my %courselevel=(); |
my %courselevelcurrent=(); |
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); |
unless ($restrict) { $restrict='F'; } |
if (!$restrict) { $restrict='F'; } |
$courselevel{$priv}=$restrict; |
$courselevel{$priv}=$restrict; |
if ($coursepriv=~/\:$priv/) { |
if ($coursepriv=~/\:$priv/) { |
$courselevelcurrent{$priv}=1; |
$courselevelcurrent{$priv}=1; |
Line 1646 sub custom_role_editor {
|
Line 1664 sub custom_role_editor {
|
my %domainlevelcurrent=(); |
my %domainlevelcurrent=(); |
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) { |
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) { |
my ($priv,$restrict)=split(/\&/,$item); |
my ($priv,$restrict)=split(/\&/,$item); |
unless ($restrict) { $restrict='F'; } |
if (!$restrict) { $restrict='F'; } |
$domainlevel{$priv}=$restrict; |
$domainlevel{$priv}=$restrict; |
if ($dompriv=~/\:$priv/) { |
if ($dompriv=~/\:$priv/) { |
$domainlevelcurrent{$priv}=1; |
$domainlevelcurrent{$priv}=1; |
Line 1657 sub custom_role_editor {
|
Line 1675 sub custom_role_editor {
|
my %systemlevelcurrent=(); |
my %systemlevelcurrent=(); |
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) { |
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) { |
my ($priv,$restrict)=split(/\&/,$item); |
my ($priv,$restrict)=split(/\&/,$item); |
unless ($restrict) { $restrict='F'; } |
if (!$restrict) { $restrict='F'; } |
$systemlevel{$priv}=$restrict; |
$systemlevel{$priv}=$restrict; |
if ($syspriv=~/\:$priv/) { |
if ($syspriv=~/\:$priv/) { |
$systemlevelcurrent{$priv}=1; |
$systemlevelcurrent{$priv}=1; |
Line 1668 sub custom_role_editor {
|
Line 1686 sub custom_role_editor {
|
'prv' => "Privilege", |
'prv' => "Privilege", |
'crl' => "Course Level", |
'crl' => "Course Level", |
'dml' => "Domain Level", |
'dml' => "Domain Level", |
'ssl' => "System 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(<<ENDCCF); |
$r->print(<<ENDCCF); |
<form method="post"> |
<form name=form1 method="post"> |
<input type="hidden" name="phase" value="set_custom_roles" /> |
<input type="hidden" name="phase" value="set_custom_roles" /> |
<input type="hidden" name="rolename" value="$rolename" /> |
<input type="hidden" name="rolename" value="$rolename" /> |
ENDCCF |
ENDCCF |
Line 1684 ENDCCF
|
Line 1703 ENDCCF
|
my $privtext = &Apache::lonnet::plaintext($priv); |
my $privtext = &Apache::lonnet::plaintext($priv); |
$r->print(&Apache::loncommon::start_data_table_row(). |
$r->print(&Apache::loncommon::start_data_table_row(). |
'<td>'.$privtext.'</td><td>'. |
'<td>'.$privtext.'</td><td>'. |
($courselevel{$priv}?'<input type="checkbox" name="'.$priv.':c" '. |
($courselevel{$priv}?'<input type="checkbox" name="'.$priv.'_c" '. |
($courselevelcurrent{$priv}?'checked="1"':'').' />':' '). |
($courselevelcurrent{$priv}?'checked="1"':'').' />':' '). |
'</td><td>'. |
'</td><td>'. |
($domainlevel{$priv}?'<input type="checkbox" name="'.$priv.':d" '. |
($domainlevel{$priv}?'<input type="checkbox" name="'.$priv.'_d" '. |
($domainlevelcurrent{$priv}?'checked="1"':'').' />':' '). |
($domainlevelcurrent{$priv}?'checked="1"':'').' />':' '). |
'</td><td>'. |
'</td><td>'. |
($systemlevel{$priv}?'<input type="checkbox" name="'.$priv.':s" '. |
($systemlevel{$priv}?'<input type="checkbox" name="'.$priv.'_s" '. |
($systemlevelcurrent{$priv}?'checked="1"':'').' />':' '). |
($systemlevelcurrent{$priv}?'checked="1"':'').' />':' '). |
'</td>'. |
'</td>'. |
&Apache::loncommon::end_data_table_row()); |
&Apache::loncommon::end_data_table_row()); |
Line 1708 sub set_custom_role {
|
Line 1727 sub set_custom_role {
|
|
|
$rolename=~s/[^A-Za-z0-9]//gs; |
$rolename=~s/[^A-Za-z0-9]//gs; |
|
|
unless ($rolename) { |
if (!$rolename) { |
&print_username_entry_form($r); |
&print_username_entry_form($r); |
return; |
return; |
} |
} |
Line 1732 sub set_custom_role {
|
Line 1751 sub set_custom_role {
|
|
|
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); |
unless ($restrict) { $restrict=''; } |
if (!$restrict) { $restrict=''; } |
if ($env{'form.'.$priv.':c'}) { |
if ($env{'form.'.$priv.'_c'}) { |
$courole.=':'.$item; |
$courole.=':'.$item; |
} |
} |
} |
} |
|
|
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) { |
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) { |
my ($priv,$restrict)=split(/\&/,$item); |
my ($priv,$restrict)=split(/\&/,$item); |
unless ($restrict) { $restrict=''; } |
if (!$restrict) { $restrict=''; } |
if ($env{'form.'.$priv.':d'}) { |
if ($env{'form.'.$priv.'_d'}) { |
$domrole.=':'.$item; |
$domrole.=':'.$item; |
} |
} |
} |
} |
|
|
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) { |
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) { |
my ($priv,$restrict)=split(/\&/,$item); |
my ($priv,$restrict)=split(/\&/,$item); |
unless ($restrict) { $restrict=''; } |
if (!$restrict) { $restrict=''; } |
if ($env{'form.'.$priv.':s'}) { |
if ($env{'form.'.$priv.'_s'}) { |
$sysrole.=':'.$item; |
$sysrole.=':'.$item; |
} |
} |
} |
} |
Line 1788 sub handler {
|
Line 1807 sub handler {
|
(&Apache::lonnet::allowed('mau',$env{'request.role.domain'}))) { |
(&Apache::lonnet::allowed('mau',$env{'request.role.domain'}))) { |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
unless ($env{'form.phase'}) { |
if (!$env{'form.phase'}) { |
&print_username_entry_form($r); |
&print_username_entry_form($r); |
} |
} |
if ($env{'form.phase'} eq 'get_user_info') { |
if ($env{'form.phase'} eq 'get_user_info') { |