version 1.406.2.20.2.5, 2024/02/29 21:43:33
|
version 1.406.2.20.2.6, 2024/08/24 15:09:55
|
Line 70 use Apache::lonlocal;
|
Line 70 use Apache::lonlocal;
|
use Apache::longroup; |
use Apache::longroup; |
use Apache::lonuserutils; |
use Apache::lonuserutils; |
use Apache::loncoursequeueadmin; |
use Apache::loncoursequeueadmin; |
|
use Apache::lonviewcoauthors; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
use HTML::Entities; |
use HTML::Entities; |
|
|
Line 241 function toggleCustom(form,item,name) {
|
Line 242 function toggleCustom(form,item,name) {
|
if (radioname) { |
if (radioname) { |
if (radioname.length > 0) { |
if (radioname.length > 0) { |
var setvis; |
var setvis; |
var RegExp = /^customtext_(aboutme|blog|portfolio|timezone|webdav)\$/; |
var RegExp = /^customtext_(aboutme|blog|portfolio|portaccess|timezone|webdav|archive)\$/; |
for (var i=0; i<radioname.length; i++) { |
for (var i=0; i<radioname.length; i++) { |
if (radioname[i].checked == true) { |
if (radioname[i].checked == true) { |
if (radioname[i].value == 1) { |
if (radioname[i].value == 1) { |
Line 273 END_SCRIPT
|
Line 274 END_SCRIPT
|
sub build_tools_display { |
sub build_tools_display { |
my ($ccuname,$ccdomain,$context) = @_; |
my ($ccuname,$ccdomain,$context) = @_; |
my (@usertools,%userenv,$output,@options,%validations,%reqtitles,%reqdisplay, |
my (@usertools,%userenv,$output,@options,%validations,%reqtitles,%reqdisplay, |
$colspan,$isadv,%domconfig,@defaulteditors,@customeditors); |
$colspan,$isadv,%domconfig,@defaulteditors,@customeditors,@custommanagers, |
|
@possmanagers); |
my %lt = &Apache::lonlocal::texthash ( |
my %lt = &Apache::lonlocal::texthash ( |
'blog' => "Personal User Blog", |
'blog' => "Personal User Blog", |
'aboutme' => "Personal Information Page", |
'aboutme' => "Personal Information Page", |
'webdav' => "WebDAV access to Authoring Spaces (https)", |
'webdav' => "WebDAV access to Authoring Spaces (https)", |
'editors' => "Available Editors", |
'editors' => "Available Editors", |
|
'managers' => "Co-authors who can add/revoke roles", |
|
'archive' => "Managers can download tar.gz file of Authoring Space", |
'portfolio' => "Personal User Portfolio", |
'portfolio' => "Personal User Portfolio", |
|
'portaccess' => "Portfolio Shareable", |
'timezone' => "Can set Time Zone", |
'timezone' => "Can set Time Zone", |
'avai' => "Available", |
'avai' => "Available", |
'cusa' => "availability", |
'cusa' => "availability", |
Line 319 sub build_tools_display {
|
Line 324 sub build_tools_display {
|
%domconfig = |
%domconfig = |
&Apache::lonnet::get_dom('configuration',['quotas','authordefaults'],$ccdomain); |
&Apache::lonnet::get_dom('configuration',['quotas','authordefaults'],$ccdomain); |
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,'tools.webdav', |
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,'tools.webdav', |
'authoreditors'); |
'authoreditors','authormanagers', |
@usertools = ('webdav','editors'); |
'authorarchive','domcoord.author'); |
|
@usertools = ('webdav','editors','managers','archive'); |
$colspan = ' colspan="2"'; |
$colspan = ' colspan="2"'; |
} else { |
} else { |
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, |
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, |
'tools.aboutme','tools.portfolio','tools.blog', |
'tools.aboutme','tools.portfolio','tools.blog', |
'tools.timezone'); |
'tools.timezone','tools.portaccess'); |
@usertools = ('aboutme','blog','portfolio','timezone'); |
@usertools = ('aboutme','blog','portfolio','portaccess','timezone'); |
$colspan = ' colspan="2"'; |
$colspan = ' colspan="2"'; |
} |
} |
foreach my $item (@usertools) { |
foreach my $item (@usertools) { |
Line 334 sub build_tools_display {
|
Line 340 sub build_tools_display {
|
$currdisp,$custdisp,$custradio,$onclick,$customsty,$editorsty); |
$currdisp,$custdisp,$custradio,$onclick,$customsty,$editorsty); |
$cust_off = 'checked="checked" '; |
$cust_off = 'checked="checked" '; |
$tool_on = 'checked="checked" '; |
$tool_on = 'checked="checked" '; |
unless (($context eq 'authordefaults') && ($item ne 'webdav')) { |
unless (($context eq 'authordefaults') || ($item eq 'webdav')) { |
$curr_access = |
$curr_access = |
&Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef, |
&Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef, |
$context,\%userenv,'', |
$context,\%userenv,'', |
Line 346 sub build_tools_display {
|
Line 352 sub build_tools_display {
|
$cust_off = ''; |
$cust_off = ''; |
} |
} |
} elsif ($context eq 'authordefaults') { |
} elsif ($context eq 'authordefaults') { |
if ($item eq 'editors') { |
if (($item eq 'editors') || ($item eq 'archive')) { |
if ($userenv{'author'.$item} ne '') { |
if ($userenv{'author'.$item} ne '') { |
$cust_on = ' checked="checked" '; |
$cust_on = ' checked="checked" '; |
$cust_off = ''; |
$cust_off = ''; |
|
if ($item eq 'archive') { |
|
$curr_access = $userenv{'author'.$item}; |
|
} |
|
} elsif ($item eq 'archive') { |
|
$curr_access = 0; |
|
if (ref($domconfig{'authordefaults'}) eq 'HASH') { |
|
$curr_access = $domconfig{'authordefaults'}{'archive'}; |
|
} |
} |
} |
} elsif ($item eq 'webdav') { |
} elsif ($item eq 'webdav') { |
if ($userenv{'tools.'.$item} ne '') { |
if ($userenv{'tools.'.$item} ne '') { |
Line 408 sub build_tools_display {
|
Line 422 sub build_tools_display {
|
} |
} |
$editorsty = ' style="display:block;"'; |
$editorsty = ' style="display:block;"'; |
} |
} |
|
} elsif ($item eq 'managers') { |
|
my %ca_roles = &Apache::lonnet::get_my_roles($ccuname,$ccdomain,undef, |
|
['active','future'],['ca']); |
|
if (keys(%ca_roles)) { |
|
foreach my $entry (sort(keys(%ca_roles))) { |
|
if ($entry =~ /^($match_username\:$match_domain):ca$/) { |
|
my $user = $1; |
|
unless ($user eq "$ccuname:$ccdomain") { |
|
push(@possmanagers,$user); |
|
} |
|
} |
|
} |
|
} |
|
if ($userenv{'author'.$item} eq '') { |
|
$custom_access = &mt('Currently author manages co-author roles'); |
|
} else { |
|
if (keys(%ca_roles)) { |
|
foreach my $user (split(/,/,$userenv{'author'.$item})) { |
|
if ($user =~ /^($match_username):($match_domain)$/) { |
|
if (exists($ca_roles{$user.':ca'})) { |
|
unless ($user eq "$ccuname:$ccdomain") { |
|
push(@custommanagers,$user); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if (@custommanagers) { |
|
$custom_access = &mt('Co-authors who manage co-author roles: [_1]', |
|
join(', ',@custommanagers)); |
|
} else { |
|
$custom_access = &mt('Currently author manages co-author roles'); |
|
} |
|
} |
} else { |
} else { |
my $current = $userenv{$context.'.'.$item}; |
my $current = $userenv{$context.'.'.$item}; |
if ($item eq 'webdav') { |
if ($item eq 'webdav') { |
$current = $userenv{'tools.webdav'}; |
$current = $userenv{'tools.webdav'}; |
|
} elsif ($item eq 'archive') { |
|
$current = $userenv{'author'.$item}; |
} |
} |
if ($current eq '') { |
if ($current eq '') { |
$custom_access = |
$custom_access = |
Line 548 sub build_tools_display {
|
Line 598 sub build_tools_display {
|
$output .= '</fieldset></td>'. |
$output .= '</fieldset></td>'. |
&Apache::loncommon::end_data_table_row()."\n"; |
&Apache::loncommon::end_data_table_row()."\n"; |
} |
} |
|
} elsif ($item eq 'managers') { |
|
$output .= '<td'.$colspan.'>'.$custom_access.'</td>'."\n". |
|
&Apache::loncommon::end_data_table_row()."\n"; |
|
unless ((&Apache::lonnet::allowed('udp',$ccdomain)) || |
|
(($userenv{'domcoord.author'} eq 'blocked') && |
|
(($env{'user.name'} ne $ccuname) || ($env{'user.domain'} ne $ccdomain)))) { |
|
$output .= |
|
&Apache::loncommon::start_data_table_row()."\n". |
|
'<td'.$colspan.'>'; |
|
if (@possmanagers) { |
|
$output .= &mt('Select manager(s)').': '; |
|
foreach my $user (@possmanagers) { |
|
my $checked; |
|
if (grep(/^\Q$user\E$/,@custommanagers)) { |
|
$checked = ' checked="checked"'; |
|
} |
|
$output .= '<span style="LC_nobreak"><label>'. |
|
'<input type="checkbox" name="custommanagers" '. |
|
'value="'.&HTML::Entities::encode($user,'\'<>"&').'"'.$checked.' />'. |
|
$user.'</label></span> '; |
|
} |
|
} else { |
|
$output .= &mt('No co-author roles assignable as manager'); |
|
} |
|
$output .= '</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
|
} |
} else { |
} else { |
$currdisp = ($curr_access?&mt('Yes'):&mt('No')); |
$currdisp = ($curr_access?&mt('Yes'):&mt('No')); |
my $name = $context.'_'.$item; |
my $name = $context.'_'.$item; |
Line 560 sub build_tools_display {
|
Line 637 sub build_tools_display {
|
$custradio = '<span id="customtext_'.$item.'"'.$customsty.' class="LC_nobreak">'. |
$custradio = '<span id="customtext_'.$item.'"'.$customsty.' class="LC_nobreak">'. |
'--'.$lt{'cusa'}.': '.$custdisp.'</span>'; |
'--'.$lt{'cusa'}.': '.$custdisp.'</span>'; |
} |
} |
unless ($item eq 'editors') { |
unless (($item eq 'editors') || ($item eq 'managers')) { |
$output .= ' <td'.$colspan.'>'.$custom_access.(' 'x4). |
$output .= ' <td'.$colspan.'>'.$custom_access.(' 'x4). |
$lt{'avai'}.': '.$currdisp.'</td>'."\n". |
$lt{'avai'}.': '.$currdisp.'</td>'."\n". |
&Apache::loncommon::end_data_table_row()."\n"; |
&Apache::loncommon::end_data_table_row()."\n"; |
Line 1439 sub print_user_modification_page {
|
Line 1516 sub print_user_modification_page {
|
unless ($isauthor) { |
unless ($isauthor) { |
push(@toggles,'requestauthor'); |
push(@toggles,'requestauthor'); |
} |
} |
push(@toggles,('webdav','editors')); |
push(@toggles,('webdav','editors','archive')); |
} |
} |
if (&Apache::lonnet::allowed('mut',$ccdomain)) { |
if (&Apache::lonnet::allowed('mut',$ccdomain)) { |
push(@toggles,('aboutme','blog','portfolio','timezone')); |
push(@toggles,('aboutme','blog','portfolio','portaccess','timezone')); |
} |
} |
if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) { |
if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) { |
push(@toggles,('official','unofficial','community','textbook')); |
push(@toggles,('official','unofficial','community','textbook')); |
Line 1965 sub display_existing_roles {
|
Line 2042 sub display_existing_roles {
|
next unless (($rnum eq $env{'course.'.$env{'request.course.id'}.'.num'}) |
next unless (($rnum eq $env{'course.'.$env{'request.course.id'}.'.num'}) |
&& ($rdom eq $env{'course.'.$env{'request.course.id'}.'.domain'})); |
&& ($rdom eq $env{'course.'.$env{'request.course.id'}.'.domain'})); |
} elsif ($context eq 'author') { |
} elsif ($context eq 'author') { |
next unless (($rnum eq $env{'user.name'}) && ($rdom eq $env{'request.role.domain'})); |
if ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)$}) { |
|
my ($audom,$auname) = ($1,$2); |
|
next unless (($rnum eq $auname) && ($rdom eq $audom)); |
|
} else { |
|
next unless (($rnum eq $env{'user.name'}) && ($rdom eq $env{'request.role.domain'})); |
|
} |
} |
} |
my ($newkey,$newvalue,$newrole); |
my ($newkey,$newvalue,$newrole); |
$newkey = '/'.$rdom.'/'.$rnum; |
$newkey = '/'.$rdom.'/'.$rnum; |
Line 2125 sub display_existing_roles {
|
Line 2207 sub display_existing_roles {
|
$area=~m{/($match_domain)/($match_username)}; |
$area=~m{/($match_domain)/($match_username)}; |
if (&Apache::lonuserutils::authorpriv($2,$1)) { |
if (&Apache::lonuserutils::authorpriv($2,$1)) { |
$allowed=1; |
$allowed=1; |
|
} elsif (&Apache::lonuserutils::coauthorpriv($2,$1)) { |
|
$allowed=1; |
} else { |
} else { |
$allowed=0; |
$allowed=0; |
} |
} |
Line 2227 sub display_existing_roles {
|
Line 2311 sub display_existing_roles {
|
} |
} |
} elsif ($env{'request.role'} =~ /^au\./) { |
} elsif ($env{'request.role'} =~ /^au\./) { |
$contextrole = &mt('Existing Co-Author Roles in your Authoring Space'); |
$contextrole = &mt('Existing Co-Author Roles in your Authoring Space'); |
|
} elsif ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)/$}) { |
|
$contextrole = &mt('Existing Co-Author Roles in [_1] Authoring Space', |
|
'<i>'.$1.'_'.$2.'</i>'); |
} else { |
} else { |
if ($showall) { |
if ($showall) { |
$contextrole = &mt('Existing Roles in this Domain'); |
$contextrole = &mt('Existing Roles in this Domain'); |
Line 2268 sub new_coauthor_roles {
|
Line 2355 sub new_coauthor_roles {
|
# |
# |
# Co-Author |
# Co-Author |
# |
# |
if (&Apache::lonuserutils::authorpriv($env{'user.name'}, |
my ($cuname,$cudom); |
$env{'request.role.domain'}) && |
if (($env{'request.role'} eq "au./$env{'user.domain'}/") || |
($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain)) { |
($env{'request.role'} eq "dc./$env{'user.domain'}/")) { |
|
$cuname=$env{'user.name'}; |
|
$cudom=$env{'request.role.domain'}; |
# No sense in assigning co-author role to yourself |
# No sense in assigning co-author role to yourself |
$addrolesdisplay = 1; |
if ((&Apache::lonuserutils::authorpriv($cuname,$cudom)) && |
my $cuname=$env{'user.name'}; |
($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain)) { |
my $cudom=$env{'request.role.domain'}; |
$addrolesdisplay = 1; |
|
} |
|
} elsif ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)$}) { |
|
($cudom,$cuname) = ($1,$2); |
|
if ((&Apache::lonuserutils::coauthorpriv($cuname,$cudom)) && |
|
($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain) && |
|
($cudom ne $ccdomain || $cuname ne $ccuname)) { |
|
$addrolesdisplay = 1; |
|
} |
|
} |
|
if ($addrolesdisplay) { |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'cs' => "Authoring Space", |
'cs' => "Authoring Space", |
'act' => "Activate", |
'act' => "Activate", |
Line 2329 sub new_coauthor_roles {
|
Line 2428 sub new_coauthor_roles {
|
($env{'user.domain'} eq $ccdomain)) { |
($env{'user.domain'} eq $ccdomain)) { |
$r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Authoring Space is not permitted')); |
$r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Authoring Space is not permitted')); |
} |
} |
|
} elsif ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)$}) { |
|
if (!(&Apache::lonuserutils::coauthorpriv($2,$1))) { |
|
$r->print('<span class="LC_error">'. |
|
&mt('You do not have privileges to assign co-author roles.'). |
|
'</span>'); |
|
} elsif (($env{'user.name'} eq $ccuname) && |
|
($env{'user.domain'} eq $ccdomain)) { |
|
$r->print(&mt('Assigning yourself a co-author or assistant co-author role in an author area in Authoring Space in which you already have a co-author role is not permitted')); |
|
} elsif (($cudom eq $ccdomain) && ($cuname eq $ccuname)) { |
|
$r->print(&mt("Assigning a co-author or assistant co-author role to an Authoring Space's author is not permitted")); |
|
} |
} |
} |
return $addrolesdisplay;; |
return $addrolesdisplay;; |
} |
} |
Line 2601 sub modify_login_block {
|
Line 2711 sub modify_login_block {
|
} |
} |
|
|
sub personal_data_display { |
sub personal_data_display { |
my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray,$now, |
my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$readonly,$rolesarray,$now, |
$captchaform,$emailusername,$usertype,$usernameset,$condition,$excluded,$showsubmit) = @_; |
$captchaform,$emailusername,$usertype,$usernameset,$condition,$excluded,$showsubmit) = @_; |
my ($output,%userenv,%canmodify,%canmodify_status); |
my ($output,%userenv,%canmodify,%canmodify_status,$disabled); |
my @userinfo = ('firstname','middlename','lastname','generation', |
my @userinfo = ('firstname','middlename','lastname','generation', |
'permanentemail','id'); |
'permanentemail','id'); |
my $rowcount = 0; |
my $rowcount = 0; |
Line 2672 sub personal_data_display {
|
Line 2782 sub personal_data_display {
|
%canmodify = &selfcreate_canmodify($context,$ccdomain,\@userinfo, |
%canmodify = &selfcreate_canmodify($context,$ccdomain,\@userinfo, |
$inst_results,$rolesarray); |
$inst_results,$rolesarray); |
} |
} |
|
} elsif ($readonly) { |
|
$disabled = ' disabled="disabled"'; |
} |
} |
|
|
my $genhelp=&Apache::loncommon::help_open_topic('Generation'); |
my $genhelp=&Apache::loncommon::help_open_topic('Generation'); |
Line 2759 sub personal_data_display {
|
Line 2871 sub personal_data_display {
|
$hiderow = 1; |
$hiderow = 1; |
} |
} |
} else { |
} else { |
$row .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />'; |
$row .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value=""'.$disabled.' />'; |
} |
} |
} |
} |
} else { |
} else { |
Line 2775 sub personal_data_display {
|
Line 2887 sub personal_data_display {
|
$hiderow = 1; |
$hiderow = 1; |
} |
} |
} else { |
} else { |
$row .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />'; |
$row .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value=""'.$disabled.' />'; |
} |
} |
} |
} |
} else { |
} else { |
Line 3069 sub update_user_data {
|
Line 3181 sub update_user_data {
|
|
|
my (%alerts,%rulematch,%inst_results,%curr_rules); |
my (%alerts,%rulematch,%inst_results,%curr_rules); |
my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id'); |
my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id'); |
my @usertools = ('aboutme','blog','portfolio','timezone'); |
my @usertools = ('aboutme','blog','portfolio','portaccess','timezone'); |
my @requestcourses = ('official','unofficial','community','textbook'); |
my @requestcourses = ('official','unofficial','community','textbook'); |
my @requestauthor = ('requestauthor'); |
my @requestauthor = ('requestauthor'); |
my @authordefaults = ('webdav','editors'); |
my @authordefaults = ('webdav','editors','archive'); |
my ($othertitle,$usertypes,$types) = |
my ($othertitle,$usertypes,$types) = |
&Apache::loncommon::sorted_inst_types($env{'form.ccdomain'}); |
&Apache::loncommon::sorted_inst_types($env{'form.ccdomain'}); |
my %canmodify_status = |
my %canmodify_status = |
Line 3202 sub update_user_data {
|
Line 3314 sub update_user_data {
|
if ($env{'form.customwebdav'} == 1) { |
if ($env{'form.customwebdav'} == 1) { |
$newcustom{'webdav'} = $env{'form.authordefaults_webdav'}; |
$newcustom{'webdav'} = $env{'form.authordefaults_webdav'}; |
$changed{'webdav'} = &tool_admin('webdav',$newcustom{'webdav'}, |
$changed{'webdav'} = &tool_admin('webdav',$newcustom{'webdav'}, |
\%changeHash,'authordefaults'); |
\%changeHash,'authordefaults'); |
|
} |
|
if ($env{'form.customarchive'} == 1) { |
|
$newcustom{'archive'} = $env{'form.authordefaults_archive'}; |
|
$changed{'archive'} = &tool_admin('archive',$newcustom{'archive'}, |
|
\%changeHash,'authordefaults'); |
|
|
} |
} |
} |
} |
if ($canmodify_status{'inststatus'}) { |
if ($canmodify_status{'inststatus'}) { |
Line 3270 sub update_user_data {
|
Line 3388 sub update_user_data {
|
('environment',['firstname','middlename','lastname','generation', |
('environment',['firstname','middlename','lastname','generation', |
'id','permanentemail','portfolioquota','authorquota','inststatus', |
'id','permanentemail','portfolioquota','authorquota','inststatus', |
'tools.aboutme','tools.blog','tools.webdav', |
'tools.aboutme','tools.blog','tools.webdav', |
'tools.portfolio','tools.timezone', |
'tools.portfolio','tools.timezone','tools.portaccess', |
'authoreditors','requestauthor', |
'authormanagers','authoreditors','authorarchive','requestauthor', |
'requestcourses.official','requestcourses.unofficial', |
'requestcourses.official','requestcourses.unofficial', |
'requestcourses.community','requestcourses.textbook', |
'requestcourses.community','requestcourses.textbook', |
'reqcrsotherdom.official','reqcrsotherdom.unofficial', |
'reqcrsotherdom.official','reqcrsotherdom.unofficial', |
'reqcrsotherdom.community','reqcrsotherdom.textbook'], |
'reqcrsotherdom.community','reqcrsotherdom.textbook', |
|
'domcoord.author'], |
$env{'form.ccdomain'},$env{'form.ccuname'}); |
$env{'form.ccdomain'},$env{'form.ccuname'}); |
my ($tmp) = keys(%userenv); |
my ($tmp) = keys(%userenv); |
if ($tmp =~ /^(con_lost|error)/i) { |
if ($tmp =~ /^(con_lost|error)/i) { |
%userenv = (); |
%userenv = (); |
} |
} |
|
unless (($userenv{'domcoord.author'} eq 'blocked') && |
|
(($env{'user.name'} ne $env{'form.ccuname'}) || |
|
($env{'user.domain'} ne $env{'form.ccdomain'}))) { |
|
push(@authordefaults,'managers'); |
|
} |
my $no_forceid_alert; |
my $no_forceid_alert; |
# Check to see if user information can be changed |
# Check to see if user information can be changed |
my %domconfig = |
my %domconfig = |
Line 3565 sub update_user_data {
|
Line 3689 sub update_user_data {
|
if ((keys(%namechanged) > 0) || (keys(%changed) > 0)) { |
if ((keys(%namechanged) > 0) || (keys(%changed) > 0)) { |
my ($chgresult,$namechgresult); |
my ($chgresult,$namechgresult); |
if (keys(%changed) > 0) { |
if (keys(%changed) > 0) { |
$chgresult = |
$chgresult = |
&Apache::lonnet::put('environment',\%changeHash, |
&Apache::lonnet::put('environment',\%changeHash, |
$env{'form.ccdomain'},$env{'form.ccuname'}); |
$env{'form.ccdomain'},$env{'form.ccuname'}); |
if ($chgresult eq 'ok') { |
if ($chgresult eq 'ok') { |
|
my ($ca_mgr_del,%ca_mgr_add); |
|
if ($changed{'managers'}) { |
|
my (@adds,@dels); |
|
if ($changeHash{'authormanagers'} eq '') { |
|
@dels = split(/,/,$userenv{'authormanagers'}); |
|
} elsif ($userenv{'authormanagers'} eq '') { |
|
@adds = split(/,/,$changeHash{'authormanagers'}); |
|
} else { |
|
my @old = split(/,/,$userenv{'authormanagers'}); |
|
my @new = split(/,/,$changeHash{'authormanagers'}); |
|
my @diffs = &Apache::loncommon::compare_arrays(\@old,\@new); |
|
if (@diffs) { |
|
foreach my $user (@diffs) { |
|
if (grep(/^\Q$user\E$/,@old)) { |
|
push(@dels,$user); |
|
} elsif (grep(/^\Q$user\E$/,@new)) { |
|
push(@adds,$user); |
|
} |
|
} |
|
} |
|
} |
|
my $key = "internal.manager./$env{'form.ccdomain'}/$env{'form.ccuname'}"; |
|
if (@dels) { |
|
foreach my $user (@dels) { |
|
if ($user =~ /^($match_username):($match_domain)$/) { |
|
&Apache::lonnet::del('environment',[$key],$2,$1); |
|
} |
|
} |
|
my $curruser = $env{'user.name'}.':'.$env{'user.domain'}; |
|
if (grep(/^\Q$curruser\E$/,@dels)) { |
|
$ca_mgr_del = $key; |
|
} |
|
} |
|
if (@adds) { |
|
foreach my $user (@adds) { |
|
if ($user =~ /^($match_username):($match_domain)$/) { |
|
&Apache::lonnet::put('environment',{$key => 1},$2,$1); |
|
} |
|
} |
|
my $curruser = $env{'user.name'}.':'.$env{'user.domain'}; |
|
if (grep(/^\Q$curruser\E$/,@adds)) { |
|
$ca_mgr_add{$key} = 1; |
|
} |
|
} |
|
} |
if (($env{'user.name'} eq $env{'form.ccuname'}) && |
if (($env{'user.name'} eq $env{'form.ccuname'}) && |
($env{'user.domain'} eq $env{'form.ccdomain'})) { |
($env{'user.domain'} eq $env{'form.ccdomain'})) { |
my (%newenvhash,$got_domdefs,%domdefaults,$got_userenv, |
my (%newenvhash,$got_domdefs,%domdefaults,$got_userenv, |
Line 3634 sub update_user_data {
|
Line 3803 sub update_user_data {
|
$newenvhash{'environment.editors'} = 'edit,xml'; |
$newenvhash{'environment.editors'} = 'edit,xml'; |
} |
} |
} |
} |
|
} elsif ($key eq 'archive') { |
|
$newenvhash{'environment.author.'.$key} = |
|
$changeHash{'author.'.$key}; |
|
if ($changeHash{'author.'.$key} ne '') { |
|
$newenvhash{'environment.canarchive'} = |
|
$changeHash{'author.'.$key}; |
|
} else { |
|
unless ($got_domdefs) { |
|
%domdefaults = |
|
&Apache::lonnet::get_domain_defaults($env{'user.domain'}); |
|
$got_domdefs = 1; |
|
} |
|
$newenvhash{'environment.canarchive'} = |
|
$domdefaults{'archive'}; |
|
} |
} elsif ($key ne 'quota') { |
} elsif ($key ne 'quota') { |
$newenvhash{'environment.tools.'.$key} = |
$newenvhash{'environment.tools.'.$key} = |
$changeHash{'tools.'.$key}; |
$changeHash{'tools.'.$key}; |
Line 3661 sub update_user_data {
|
Line 3845 sub update_user_data {
|
if (keys(%newenvhash)) { |
if (keys(%newenvhash)) { |
&Apache::lonnet::appenv(\%newenvhash); |
&Apache::lonnet::appenv(\%newenvhash); |
} |
} |
|
} else { |
|
if ($ca_mgr_del) { |
|
&Apache::lonnet::delenv($ca_mgr_del); |
|
} |
|
if (keys(%ca_mgr_add)) { |
|
&Apache::lonnet::appenv(\%ca_mgr_add); |
|
} |
} |
} |
if ($changed{'aboutme'}) { |
if ($changed{'aboutme'}) { |
&Apache::loncommon::devalidate_aboutme_cache($env{'form.ccuname'}, |
&Apache::loncommon::devalidate_aboutme_cache($env{'form.ccuname'}, |
Line 3835 sub display_userinfo {
|
Line 4026 sub display_userinfo {
|
'webdav' => 'WebDAV Availability', |
'webdav' => 'WebDAV Availability', |
'aboutme' => 'Personal Information Page Availability', |
'aboutme' => 'Personal Information Page Availability', |
'portfolio' => 'Portfolio Availability', |
'portfolio' => 'Portfolio Availability', |
|
'portaccess' => 'Portfolio Shareable', |
'timezone' => 'Can set own Time Zone', |
'timezone' => 'Can set own Time Zone', |
'official' => 'Can Request Official Courses', |
'official' => 'Can Request Official Courses', |
'unofficial' => 'Can Request Unofficial Courses', |
'unofficial' => 'Can Request Unofficial Courses', |
Line 3845 sub display_userinfo {
|
Line 4037 sub display_userinfo {
|
'prvs' => 'Previous Value:', |
'prvs' => 'Previous Value:', |
'chto' => 'Changed To:', |
'chto' => 'Changed To:', |
'editors' => "Available Editors in Authoring Space", |
'editors' => "Available Editors in Authoring Space", |
|
'managers' => "Co-authors who can add/revoke roles", |
|
'archive' => "Managers can download tar.gz file of Authoring Space", |
'edit' => 'Standard editor (Edit)', |
'edit' => 'Standard editor (Edit)', |
'xml' => 'Text editor (EditXML)', |
'xml' => 'Text editor (EditXML)', |
'daxe' => 'Daxe editor (Daxe)', |
'daxe' => 'Daxe editor (Daxe)', |
Line 3878 sub display_userinfo {
|
Line 4072 sub display_userinfo {
|
if ($entry eq 'requestauthor') { |
if ($entry eq 'requestauthor') { |
@items = ($entry); |
@items = ($entry); |
} elsif ($entry eq 'authordefaults') { |
} elsif ($entry eq 'authordefaults') { |
@items = ('webdav','editors'); |
@items = ('webdav','managers','editors','archive'); |
} else { |
} else { |
@items = @{$requestcourses}; |
@items = @{$requestcourses}; |
} |
} |
Line 3886 sub display_userinfo {
|
Line 4080 sub display_userinfo {
|
if (($newsetting->{$item} ne $oldsetting->{$item}) || |
if (($newsetting->{$item} ne $oldsetting->{$item}) || |
($newsettingtext->{$item} ne $oldsettingtext->{$item})) { |
($newsettingtext->{$item} ne $oldsettingtext->{$item})) { |
$r->print(&Apache::loncommon::start_data_table_row()."\n"); |
$r->print(&Apache::loncommon::start_data_table_row()."\n"); |
$r->print("<td>$lt{$item}</td>\n"); |
$r->print("<td>$lt{$item}</td><td>\n"); |
$r->print("<td>".$oldsetting->{$item}); |
unless ($item eq 'managers') { |
|
$r->print($oldsetting->{$item}); |
|
} |
if ($oldsettingtext->{$item}) { |
if ($oldsettingtext->{$item}) { |
if ($oldsetting->{$item}) { |
if ($oldsetting->{$item}) { |
$r->print(' -- '); |
unless ($item eq 'managers') { |
|
$r->print(' -- '); |
|
} |
} |
} |
$r->print($oldsettingtext->{$item}); |
$r->print($oldsettingtext->{$item}); |
} |
} |
$r->print("</td>\n"); |
$r->print("</td>\n<td>"); |
$r->print("<td>".$newsetting->{$item}); |
unless ($item eq 'managers') { |
|
$r->print($newsetting->{$item}); |
|
} |
if ($newsettingtext->{$item}) { |
if ($newsettingtext->{$item}) { |
if ($newsetting->{$item}) { |
if ($newsetting->{$item}) { |
$r->print(' -- '); |
unless ($item eq 'managers') { |
|
$r->print(' -- '); |
|
} |
} |
} |
$r->print($newsettingtext->{$item}); |
$r->print($newsettingtext->{$item}); |
} |
} |
Line 4096 sub tool_changes {
|
Line 4298 sub tool_changes {
|
$newval = join(',',(sort(@editors))); |
$newval = join(',',(sort(@editors))); |
} |
} |
} |
} |
|
} elsif ($tool eq 'managers') { |
|
$envkey = 'authormanagers'; |
|
my @possibles = &Apache::loncommon::get_env_multiple('form.custommanagers'); |
|
if (@possibles) { |
|
my %ca_roles = &Apache::lonnet::get_my_roles($env{'form.ccuname'},$env{'form.ccdomain'}, |
|
undef,['active','future'],['ca']); |
|
if (keys(%ca_roles)) { |
|
my @custommanagers; |
|
foreach my $user (@possibles) { |
|
if ($user =~ /^($match_username):($match_domain)$/) { |
|
if (exists($ca_roles{$user.':ca'})) { |
|
unless ($user eq $env{'form.ccuname'}.':'.$env{'form.ccdomain'}) { |
|
push(@custommanagers,$user); |
|
} |
|
} |
|
} |
|
} |
|
if (@custommanagers) { |
|
$newval = join(',',sort(@custommanagers)); |
|
} |
|
} |
|
} |
} elsif ($tool eq 'webdav') { |
} elsif ($tool eq 'webdav') { |
$envkey = 'tools.webdav'; |
$envkey = 'tools.webdav'; |
$newval = $env{'form.'.$context.'_'.$tool}; |
$newval = $env{'form.'.$context.'_'.$tool}; |
|
} elsif ($tool eq 'archive') { |
|
$envkey = 'authorarchive'; |
|
$newval = $env{'form.'.$context.'_'.$tool}; |
} |
} |
} else { |
} else { |
$newval = $env{'form.'.$context.'_'.$tool}; |
$newval = $env{'form.'.$context.'_'.$tool}; |
Line 4119 sub tool_changes {
|
Line 4346 sub tool_changes {
|
$oldaccesstext->{$tool} = &mt("availability set to 'off'"); |
$oldaccesstext->{$tool} = &mt("availability set to 'off'"); |
} |
} |
} elsif ($context eq 'authordefaults') { |
} elsif ($context eq 'authordefaults') { |
if ($tool eq 'editors') { |
if ($tool eq 'managers') { |
|
if ($userenv->{$envkey} eq '') { |
|
$oldaccesstext->{$tool} = &mt('Only author may manage co-author roles'); |
|
} else { |
|
my $managers = $userenv->{$envkey}; |
|
$managers =~ s/,/, /g; |
|
$oldaccesstext->{$tool} = $managers; |
|
} |
|
} elsif ($tool eq 'editors') { |
$oldaccesstext->{$tool} = &mt('can use: [_1]', |
$oldaccesstext->{$tool} = &mt('can use: [_1]', |
join(', ', map { $tooldesc{$_} } split(/,/,$userenv->{$envkey}))); |
join(', ', map { $tooldesc{$_} } split(/,/,$userenv->{$envkey}))); |
} elsif ($tool eq 'webdav') { |
} elsif (($tool eq 'webdav') || ($tool eq 'archive')) { |
if ($userenv->{$envkey}) { |
if ($userenv->{$envkey}) { |
$oldaccesstext->{$tool} = &mt("availability set to 'on'"); |
$oldaccesstext->{$tool} = &mt("availability set to 'on'"); |
} else { |
} else { |
Line 4137 sub tool_changes {
|
Line 4372 sub tool_changes {
|
} |
} |
} |
} |
$changeHash->{$envkey} = $userenv->{$envkey}; |
$changeHash->{$envkey} = $userenv->{$envkey}; |
if ($env{'form.custom'.$tool} == 1) { |
if (($env{'form.custom'.$tool} == 1) || |
|
(($context eq 'authordefaults') && ($tool eq 'managers') && ($newval ne ''))) { |
if ($newval ne $userenv->{$envkey}) { |
if ($newval ne $userenv->{$envkey}) { |
$changed->{$tool} = &tool_admin($tool,$newval,$changeHash, |
$changed->{$tool} = &tool_admin($tool,$newval,$changeHash, |
$context); |
$context); |
Line 4159 sub tool_changes {
|
Line 4395 sub tool_changes {
|
if ($tool eq 'editors') { |
if ($tool eq 'editors') { |
$newaccesstext->{$tool} = &mt('can use: [_1]', |
$newaccesstext->{$tool} = &mt('can use: [_1]', |
join(', ', map { $tooldesc{$_} } split(/,/,$changeHash->{$envkey}))); |
join(', ', map { $tooldesc{$_} } split(/,/,$changeHash->{$envkey}))); |
} elsif ($tool eq 'webdav') { |
} elsif ($tool eq 'managers') { |
|
if ($changeHash->{$envkey} eq '') { |
|
$newaccesstext->{$tool} = &mt('Only author may manage co-author roles'); |
|
} else { |
|
my $managers = $changeHash->{$envkey}; |
|
$managers =~ s/,/, /g; |
|
$newaccesstext->{$tool} = $managers; |
|
} |
|
} elsif (($tool eq 'webdav') || ($tool eq 'archive')) { |
if ($newval) { |
if ($newval) { |
$newaccesstext->{$tool} = &mt("availability set to 'on'"); |
$newaccesstext->{$tool} = &mt("availability set to 'on'"); |
} else { |
} else { |
Line 4191 sub tool_changes {
|
Line 4435 sub tool_changes {
|
if ($tool eq 'editors') { |
if ($tool eq 'editors') { |
$newaccesstext->{$tool} = &mt('can use: [_1]', |
$newaccesstext->{$tool} = &mt('can use: [_1]', |
join(', ', map { $tooldesc{$_} } split(/,/,$userenv->{$envkey}))); |
join(', ', map { $tooldesc{$_} } split(/,/,$userenv->{$envkey}))); |
} elsif ($tool eq 'webdav') { |
} elsif ($tool eq 'managers') { |
|
if ($userenv->{$envkey} eq '') { |
|
$newaccesstext->{$tool} = &mt('Only author may manage co-author roles'); |
|
} else { |
|
my $managers = $userenv->{$envkey}; |
|
$managers =~ s/,/, /g; |
|
$newaccesstext->{$tool} = $managers; |
|
} |
|
} elsif (($tool eq 'webdav') || ($tool eq 'archive')) { |
if ($userenv->{$envkey}) { |
if ($userenv->{$envkey}) { |
$newaccesstext->{$tool} = &mt("availability set to 'on'"); |
$newaccesstext->{$tool} = &mt("availability set to 'on'"); |
} else { |
} else { |
Line 4232 sub tool_changes {
|
Line 4484 sub tool_changes {
|
if ($tool eq 'editors') { |
if ($tool eq 'editors') { |
$newaccesstext->{$tool} = &mt('can use: [_1]', |
$newaccesstext->{$tool} = &mt('can use: [_1]', |
join(', ', map { $tooldesc{$_} } split(/,/,$newval))); |
join(', ', map { $tooldesc{$_} } split(/,/,$newval))); |
} elsif ($tool eq 'webdav') { |
} elsif ($tool eq 'managers') { |
if ($userenv->{$envkey}) { |
if ($newval eq '') { |
|
$newaccesstext->{$tool} = &mt('Only author may manage co-author roles'); |
|
} else { |
|
my $managers = $newval; |
|
$managers =~ s/,/, /g; |
|
$newaccesstext->{$tool} = $managers; |
|
} |
|
} elsif (($tool eq 'webdav') || ($tool eq 'archive')) { |
|
if ($newval) { |
$newaccesstext->{$tool} = &mt("availability set to 'on'"); |
$newaccesstext->{$tool} = &mt("availability set to 'on'"); |
} else { |
} else { |
$newaccesstext->{$tool} = &mt("availability set to 'off'"); |
$newaccesstext->{$tool} = &mt("availability set to 'off'"); |
Line 4250 sub tool_changes {
|
Line 4510 sub tool_changes {
|
} |
} |
} else { |
} else { |
$oldaccess->{$tool} = &mt('default'); |
$oldaccess->{$tool} = &mt('default'); |
if ($env{'form.custom'.$tool} == 1) { |
if (($env{'form.custom'.$tool} == 1) || |
|
(($context eq 'authordefaults') && ($tool eq 'managers') && ($newval ne ''))) { |
$changed->{$tool} = &tool_admin($tool,$newval,$changeHash, |
$changed->{$tool} = &tool_admin($tool,$newval,$changeHash, |
$context); |
$context); |
if ($changed->{$tool}) { |
if ($changed->{$tool}) { |
Line 4268 sub tool_changes {
|
Line 4529 sub tool_changes {
|
$newaccesstext->{$tool} = &mt("availability set to 'off'"); |
$newaccesstext->{$tool} = &mt("availability set to 'off'"); |
} |
} |
} elsif ($context eq 'authordefaults') { |
} elsif ($context eq 'authordefaults') { |
if ($tool eq 'editors') { |
if ($tool eq 'managers') { |
|
if ($newval eq '') { |
|
$newaccesstext->{$tool} = &mt('Only author may manage co-author roles'); |
|
} else { |
|
my $managers = $newval; |
|
$managers =~ s/,/, /g; |
|
$newaccesstext->{$tool} = $managers; |
|
} |
|
} elsif ($tool eq 'editors') { |
$newaccesstext->{$tool} = &mt('can use: [_1]', |
$newaccesstext->{$tool} = &mt('can use: [_1]', |
join(', ', map { $tooldesc{$_} } split(/,/,$newval))); |
join(', ', map { $tooldesc{$_} } split(/,/,$newval))); |
} elsif ($tool eq 'webdav') { |
} elsif (($tool eq 'webdav') || ($tool eq 'archive')) { |
if ($newval) { |
if ($newval) { |
$newaccesstext->{$tool} = &mt("availability set to 'on'"); |
$newaccesstext->{$tool} = &mt("availability set to 'on'"); |
} else { |
} else { |
Line 4786 sub tool_admin {
|
Line 5055 sub tool_admin {
|
$toolchanged = 1; |
$toolchanged = 1; |
if ($tool eq 'requestauthor') { |
if ($tool eq 'requestauthor') { |
$changeHash->{$context} = $settool; |
$changeHash->{$context} = $settool; |
} elsif ($tool eq 'editors') { |
} elsif (($tool eq 'managers') || ($tool eq 'editors') || ($tool eq 'archive')) { |
$changeHash->{'author'.$tool} = $settool; |
$changeHash->{'author'.$tool} = $settool; |
} elsif ($tool eq 'webdav') { |
} elsif ($tool eq 'webdav') { |
$changeHash->{'tools.'.$tool} = $settool; |
$changeHash->{'tools.'.$tool} = $settool; |
Line 5032 sub set_custom_role {
|
Line 5301 sub set_custom_role {
|
); |
); |
} |
} |
|
|
|
sub display_coauthor_managers { |
|
my ($permission) = @_; |
|
my $output; |
|
if ((ref($permission) eq 'HASH') && ($permission->{'author'})) { |
|
$output = '<form action="/adm/createuser" method="post" name="camanagers">'. |
|
'<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n". |
|
'<p>'; |
|
my (@possmanagers,@custommanagers); |
|
my %userenv = |
|
&Apache::lonnet::userenvironment($env{'user.domain'}, |
|
$env{'user.name'}, |
|
'authormanagers'); |
|
my %ca_roles = &Apache::lonnet::get_my_roles(undef,undef,undef, |
|
['active','future'],['ca']); |
|
if (keys(%ca_roles)) { |
|
foreach my $entry (sort(keys(%ca_roles))) { |
|
if ($entry =~ /^($match_username\:$match_domain):ca$/) { |
|
my $user = $1; |
|
unless ($user eq $env{'user.name'}.':'.$env{'user.domain'}) { |
|
push(@possmanagers,$user); |
|
} |
|
} |
|
} |
|
} |
|
if ($userenv{'authormanagers'} eq '') { |
|
$output .= &mt('Currently author manages co-author roles'); |
|
} else { |
|
if (keys(%ca_roles)) { |
|
foreach my $user (split(/,/,$userenv{'authormanagers'})) { |
|
if ($user =~ /^($match_username)\:($match_domain)$/) { |
|
if (exists($ca_roles{$user.':ca'})) { |
|
unless ($user eq $env{'user.name'}.':'.$env{'user.domain'}) { |
|
push(@custommanagers,$user); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if (@custommanagers) { |
|
$output .= &mt('Co-authors with active or future roles who currently manage co-author roles: [_1]', |
|
'<br />'.join(', ',map { &Apache::loncommon::plainname(split(':',$_))." ($_)"; } @custommanagers)); |
|
} else { |
|
$output .= &mt('Currently author manages co-author roles'); |
|
} |
|
} |
|
$output .= "</p>\n"; |
|
if (@possmanagers) { |
|
$output .= '<p>'.&mt('If checked, can manage').': '; |
|
foreach my $user (@possmanagers) { |
|
my $checked; |
|
if (grep(/^\Q$user\E$/,@custommanagers)) { |
|
$checked = ' checked="checked"'; |
|
} |
|
$output .= '<span style="LC_nobreak"><label>'. |
|
'<input type="checkbox" name="custommanagers" '. |
|
'value="'.&HTML::Entities::encode($user,'\'<>"&').'"'.$checked.' />'. |
|
&Apache::loncommon::plainname(split(/:/,$user))." ($user)".'</label></span> '."\n"; |
|
} |
|
$output .= '<input type="hidden" name="state" value="process" /></p>'."\n". |
|
'<p><input type="submit" value="'.&mt('Save changes').'" /></p>'."\n"; |
|
} else { |
|
$output .= '<p>'.&mt('No co-author roles assignable as manager').'</p>'; |
|
} |
|
$output .= '</form>'; |
|
} else { |
|
$output = '<span class="LC_warning">'. |
|
&mt('You do not have permission to perform this action'). |
|
'</span>'; |
|
} |
|
return $output; |
|
} |
|
|
|
sub update_coauthor_managers { |
|
my ($permission) = @_; |
|
my $output; |
|
if ((ref($permission) eq 'HASH') && ($permission->{'author'})) { |
|
my ($current,$newval,@possibles,@managers); |
|
my %userenv = |
|
&Apache::lonnet::userenvironment($env{'user.domain'}, |
|
$env{'user.name'}, |
|
'authormanagers'); |
|
$current = $userenv{'authormanagers'}; |
|
@possibles = &Apache::loncommon::get_env_multiple('form.custommanagers'); |
|
if (@possibles) { |
|
my %ca_roles = &Apache::lonnet::get_my_roles(undef,undef,undef, |
|
['active','future'],['ca']); |
|
if (keys(%ca_roles)) { |
|
foreach my $user (@possibles) { |
|
if ($user =~ /^($match_username):($match_domain)$/) { |
|
if (exists($ca_roles{$user.':ca'})) { |
|
unless ($user eq $env{'user.name'}.':'.$env{'user.domain'}) { |
|
push(@managers,$user); |
|
} |
|
} |
|
} |
|
} |
|
if (@managers) { |
|
$newval = join(',',sort(@managers)); |
|
} |
|
} |
|
} |
|
if ($current eq $newval) { |
|
$output = &mt('No changes made to management of co-author roles'); |
|
} else { |
|
my $chgresult = |
|
&Apache::lonnet::put('environment',{'authormanagers' => $newval}, |
|
$env{'user.domain'},$env{'user.name'}); |
|
if ($chgresult eq 'ok') { |
|
&Apache::lonnet::appenv({'environment.authormanagers' => $newval}); |
|
my (@adds,@dels); |
|
if ($newval eq '') { |
|
@dels = split(/,/,$current); |
|
} elsif ($current eq '') { |
|
@adds = @managers; |
|
} else { |
|
my @old = split(/,/,$current); |
|
my @diffs = &Apache::loncommon::compare_arrays(\@old,\@managers); |
|
if (@diffs) { |
|
foreach my $user (@diffs) { |
|
if (grep(/^\Q$user\E$/,@old)) { |
|
push(@dels,$user); |
|
} elsif (grep(/^\Q$user\E$/,@managers)) { |
|
push(@adds,$user); |
|
} |
|
} |
|
} |
|
} |
|
my $key = "internal.manager./$env{'user.domain'}/$env{'user.name'}"; |
|
if (@dels) { |
|
foreach my $user (@dels) { |
|
if ($user =~ /^($match_username):($match_domain)$/) { |
|
&Apache::lonnet::del('environment',[$key],$2,$1); |
|
} |
|
} |
|
} |
|
if (@adds) { |
|
foreach my $user (@adds) { |
|
if ($user =~ /^($match_username):($match_domain)$/) { |
|
&Apache::lonnet::put('environment',{$key => 1},$2,$1); |
|
} |
|
} |
|
} |
|
if ($newval eq '') { |
|
$output = &mt('Management of co-authors set to be author-only'); |
|
} else { |
|
$output .= &mt('Co-authors who can manage co-author roles set to: [_1]', |
|
'<br />'.join(', ',map { &Apache::loncommon::plainname(split(':',$_))." ($_)"; } @managers)); |
|
} |
|
} |
|
} |
|
} else { |
|
$output = '<span class="LC_warning">'. |
|
&mt('You do not have permission to perform this action'). |
|
'</span>'; |
|
} |
|
return $output; |
|
} |
|
|
# ================================================================ Main Handler |
# ================================================================ Main Handler |
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
Line 5047 sub handler {
|
Line 5474 sub handler {
|
$crstype = &Apache::loncommon::course_type(); |
$crstype = &Apache::loncommon::course_type(); |
} elsif ($env{'request.role'} =~ /^au\./) { |
} elsif ($env{'request.role'} =~ /^au\./) { |
$context = 'author'; |
$context = 'author'; |
|
} elsif ($env{'request.role'} =~ m{^(ca|aa)\./$match_domain/$match_username$}) { |
|
$context = 'coauthor'; |
} else { |
} else { |
$context = 'domain'; |
$context = 'domain'; |
} |
} |
|
|
my ($permission,$allowed) = |
my ($permission,$allowed) = |
&Apache::lonuserutils::get_permission($context,$crstype); |
&Apache::lonuserutils::get_permission($context,$crstype); |
|
if (($context eq 'coauthor') && ($allowed)) { |
|
$context = 'author'; |
|
} |
|
|
if ($allowed) { |
if ($allowed) { |
my @allhelp; |
my @allhelp; |
Line 5090 sub handler {
|
Line 5522 sub handler {
|
} elsif ($context eq 'author') { |
} elsif ($context eq 'author') { |
push(@allhelp,('Author_Change_Privileges','Author_Create_Coauthor_List', |
push(@allhelp,('Author_Change_Privileges','Author_Create_Coauthor_List', |
'Author_View_Coauthor_List','Author_User_Logs')); |
'Author_View_Coauthor_List','Author_User_Logs')); |
|
} elsif ($context eq 'coauthor') { |
|
if ($permission->{'cusr'}) { |
|
push(@allhelp,('Author_Change_Privileges','Author_Create_Coauthor_List', |
|
'Author_View_Coauthor_List','Author_User_Logs')); |
|
} elsif ($permission->{'view'}) { |
|
push(@allhelp,'Author_View_Coauthor_List'); |
|
} |
} else { |
} else { |
if ($permission->{'cusr'}) { |
if ($permission->{'cusr'}) { |
push(@allhelp,'Domain_Change_Privileges'); |
push(@allhelp,'Domain_Change_Privileges'); |
Line 5116 sub handler {
|
Line 5555 sub handler {
|
|
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
['action','state','callingform','roletype','showrole','bulkaction','popup','phase', |
['action','state','callingform','roletype','showrole','bulkaction','popup','phase', |
'username','domain','srchterm','srchdomain','srchin','srchby','srchtype','queue']); |
'username','domain','srchterm','srchdomain','srchin','srchby','srchtype','queue', |
|
'forceedit']); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
my $args; |
my $args; |
my $brcrum = []; |
my $brcrum = []; |
Line 5131 sub handler {
|
Line 5571 sub handler {
|
if ($context eq 'course') { |
if ($context eq 'course') { |
$r->internal_redirect('/adm/viewclasslist'); |
$r->internal_redirect('/adm/viewclasslist'); |
return OK; |
return OK; |
|
} elsif ($context eq 'coauthor') { |
|
$r->internal_redirect('/adm/viewcoauthors'); |
|
return OK; |
} |
} |
$env{'user.error.msg'}= |
$env{'user.error.msg'}= |
"/adm/createuser:cst:0:0:Cannot create/modify user data ". |
"/adm/createuser:cst:0:0:Cannot create/modify user data ". |
Line 5725 sub handler {
|
Line 6168 sub handler {
|
$r->print(&header(undef,{'no_nav_bar' => 1}). |
$r->print(&header(undef,{'no_nav_bar' => 1}). |
'<span class="LC_error">'.&mt('You do not have permission to view helpdesk access').'</span>'); |
'<span class="LC_error">'.&mt('You do not have permission to view helpdesk access').'</span>'); |
} |
} |
|
} elsif ($env{'form.action'} eq 'camanagers') { |
|
if (($permission->{cusr}) && ($context eq 'author')) { |
|
push(@{$brcrum}, |
|
{href => '/adm/createuser?action=camanagers', |
|
text => 'Co-author Managers', |
|
help => 'Author_Manage_Coauthors'}); |
|
if ($env{'form.state'} eq 'process') { |
|
push(@{$brcrum}, |
|
{href => '/adm/createuser?action=camanagers', |
|
text => 'Result', |
|
help => 'Author_Manage_Coauthors'}); |
|
} |
|
$args = { bread_crumbs => $brcrum }; |
|
$r->print(&header(undef,$args)); |
|
my $coursedesc = $env{'course.'.$cid.'.description'}; |
|
if (!exists($env{'form.state'})) { |
|
$r->print('<h3>'.&mt('Co-author Management').'</h3>'."\n". |
|
&display_coauthor_managers($permission)); |
|
} elsif ($env{'form.state'} eq 'process') { |
|
$r->print('<h3>'.&mt('Co-author Management Update Result').'</h3>'."\n". |
|
&update_coauthor_managers($permission)); |
|
} |
|
} |
|
} elsif (($env{'form.action'} eq 'calist') && ($context eq 'author')) { |
|
if ($permission->{'cusr'}) { |
|
my ($role,$audom,$auname,$canview,$canedit) = |
|
&Apache::lonviewcoauthors::get_allowable(); |
|
if (($canedit) && ($env{'form.forceedit'})) { |
|
&Apache::lonviewcoauthors::get_editor_crumbs($brcrum,'/adm/createuser'); |
|
my $args = { 'bread_crumbs' => $brcrum }; |
|
$r->print(&Apache::loncommon::start_page('Configure co-author listing',undef, |
|
$args). |
|
&Apache::lonviewcoauthors::edit_settings($audom,$auname,$role, |
|
'/adm/createuser')); |
|
} else { |
|
push(@{$brcrum}, |
|
{href => '/adm/createuser?action=calist', |
|
text => 'Coauthor-viewable list', |
|
help => 'Author_List_Coauthors'}); |
|
my $args = { 'bread_crumbs' => $brcrum }; |
|
$r->print(&Apache::loncommon::start_page('Coauthor-viewable list',undef, |
|
$args)); |
|
my %viewsettings = |
|
&Apache::lonviewcoauthors::retrieve_view_settings($auname,$audom,$role); |
|
if ($viewsettings{'show'} eq 'none') { |
|
$r->print('<h3>'.&mt('Coauthor-viewable listing').'</h3>'. |
|
'<p class="LC_info">'. |
|
&mt('Listing of co-authors not enabled for this Authoring Space'). |
|
'</p>'); |
|
} else { |
|
&Apache::lonviewcoauthors::print_coauthors($r,$auname,$audom,$role, |
|
'/adm/createuser',\%viewsettings); |
|
} |
|
} |
|
} else { |
|
$r->internal_redirect('/adm/viewcoauthors'); |
|
return OK; |
|
} |
} else { |
} else { |
$bread_crumbs_component = 'User Management'; |
$bread_crumbs_component = 'User Management'; |
$args = { bread_crumbs => $brcrum, |
$args = { bread_crumbs => $brcrum, |
Line 5831 function updateCols(caller) {
|
Line 6332 function updateCols(caller) {
|
document.getElementById('showcolstart').checked = false; |
document.getElementById('showcolstart').checked = false; |
document.getElementById('showcolend').checked = false; |
document.getElementById('showcolend').checked = false; |
} |
} |
|
if (context == 'author') { |
|
if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Expired') { |
|
document.getElementById('showcolmanager').checked = false; |
|
document.getElementById('showcolmanager').disabled = 'disabled'; |
|
} else if (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value != 'aa') { |
|
document.getElementById('showcolmanager').checked = true; |
|
document.getElementById('showcolmanager').disabled = ''; |
|
} |
|
} |
} |
} |
} |
} |
if (caller == 'output') { |
if (caller == 'output') { |
Line 5916 function updateCols(caller) {
|
Line 6426 function updateCols(caller) {
|
} |
} |
} |
} |
} |
} |
|
if (context == 'author') { |
|
if (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'aa') { |
|
document.getElementById('showcolmanager').checked = false; |
|
document.getElementById('showcolmanager').disabled = 'disabled'; |
|
} else if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value != 'Expired') { |
|
document.getElementById('showcolmanager').checked = true; |
|
document.getElementById('showcolmanager').disabled = ''; |
|
} |
|
} |
} |
} |
return; |
return; |
} |
} |
Line 6216 sub print_main_menu {
|
Line 6735 sub print_main_menu {
|
permission => $permission->{'cusr'}, |
permission => $permission->{'cusr'}, |
linktitle => 'View change log.', |
linktitle => 'View change log.', |
}, |
}, |
|
{ |
|
linktext => 'Co-author Managers', |
|
icon => 'camanager.png', |
|
#help => 'Coauthor_Management', |
|
url => '/adm/createuser?action=camanagers', |
|
permission => $permission->{'author'}, |
|
linktitle => 'Assign/Revoke right to manage co-author roles', |
|
}, |
|
{ |
|
linktext => 'Configure Co-author Listing', |
|
icon => 'coauthors.png', |
|
#help => 'Coauthor_Settings', |
|
url => '/adm/createuser?action=calist&forceedit=1', |
|
permission => ($permission->{'cusr'}), |
|
linktitle => 'Set availability of coauthor-viewable user listing', |
|
}, |
); |
); |
} |
} |
return Apache::lonhtmlcommon::generate_menu(@menu); |
return Apache::lonhtmlcommon::generate_menu(@menu); |
Line 7151 sub print_userchangelogs_display {
|
Line 7686 sub print_userchangelogs_display {
|
&Apache::loncommon::restore_course_settings('roles_log', |
&Apache::loncommon::restore_course_settings('roles_log', |
\%saveable_parameters); |
\%saveable_parameters); |
} elsif ($context eq 'author') { |
} elsif ($context eq 'author') { |
$domain = $env{'user.domain'}; |
$domain = $env{'user.domain'}; |
if ($env{'request.role'} =~ m{^au\./\Q$domain\E/$}) { |
if ($env{'request.role'} =~ m{^au\./\Q$domain\E/$}) { |
$username = $env{'user.name'}; |
$username = $env{'user.name'}; |
|
} elsif ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)$}) { |
|
($domain,$username) = ($1,$2); |
} else { |
} else { |
undef($domain); |
undef($domain); |
} |
} |
Line 7830 sub role_display_filter {
|
Line 8367 sub role_display_filter {
|
} elsif ($context eq 'domain') { |
} elsif ($context eq 'domain') { |
@posscontexts = ('any','domain','requestauthor','domconfig','server'); |
@posscontexts = ('any','domain','requestauthor','domconfig','server'); |
} else { |
} else { |
@posscontexts = ('any','author','domain'); |
@posscontexts = ('any','author','coauthor','domain'); |
} |
} |
foreach my $chgtype (@posscontexts) { |
foreach my $chgtype (@posscontexts) { |
my $selstr = ''; |
my $selstr = ''; |
Line 7901 sub rolechg_contexts {
|
Line 8438 sub rolechg_contexts {
|
any => 'Any', |
any => 'Any', |
domain => 'User Management in domain', |
domain => 'User Management in domain', |
author => 'User Management by author', |
author => 'User Management by author', |
|
coauthor => 'User Management by coauthor', |
); |
); |
} |
} |
return %lt; |
return %lt; |