version 1.284, 2016/12/05 00:51:53
|
version 1.285, 2017/01/02 19:44:06
|
Line 687 sub process_changes {
|
Line 687 sub process_changes {
|
} elsif ($action eq 'requestauthor') { |
} elsif ($action eq 'requestauthor') { |
$output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig); |
$output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig); |
} elsif ($action eq 'helpsettings') { |
} elsif ($action eq 'helpsettings') { |
$output = &modify_helpsettings($r,$dom,$confname,%domconfig); |
$output = &modify_helpsettings($r,$dom,$confname,$lastactref,%domconfig); |
} elsif ($action eq 'coursedefaults') { |
} elsif ($action eq 'coursedefaults') { |
$output = &modify_coursedefaults($dom,$lastactref,%domconfig); |
$output = &modify_coursedefaults($dom,$lastactref,%domconfig); |
} elsif ($action eq 'selfenrollment') { |
} elsif ($action eq 'selfenrollment') { |
Line 3045 sub print_contacts {
|
Line 3045 sub print_contacts {
|
sub print_helpsettings { |
sub print_helpsettings { |
my ($position,$dom,$settings,$rowtotal) = @_; |
my ($position,$dom,$settings,$rowtotal) = @_; |
my $confname = $dom.'-domainconfig'; |
my $confname = $dom.'-domainconfig'; |
|
my $formname = 'display'; |
my ($datatable,$itemcount); |
my ($datatable,$itemcount); |
if ($position eq 'top') { |
if ($position eq 'top') { |
$itemcount = 1; |
$itemcount = 1; |
Line 3060 sub print_helpsettings {
|
Line 3061 sub print_helpsettings {
|
} else { |
} else { |
my $css_class; |
my $css_class; |
my %existing=&Apache::lonnet::dump('roles',$dom,$confname,'rolesdef_'); |
my %existing=&Apache::lonnet::dump('roles',$dom,$confname,'rolesdef_'); |
my %customroles; |
my (%customroles,%ordered,%current); |
foreach my $key (keys(%existing)) { |
if (ref($settings->{'adhoc'}) eq 'HASH') { |
|
%current = %{$settings->{'adhoc'}}; |
|
} |
|
my $count = 0; |
|
foreach my $key (sort(keys(%existing))) { |
if ($key=~/^rolesdef\_(\w+)$/) { |
if ($key=~/^rolesdef\_(\w+)$/) { |
my $rolename = $1; |
my $rolename = $1; |
my %privs; |
my (%privs,$order); |
($privs{'system'},$privs{'domain'},$privs{'course'}) = split(/\_/,$existing{$key}); |
($privs{'system'},$privs{'domain'},$privs{'course'}) = split(/\_/,$existing{$key}); |
$customroles{$rolename} = \%privs; |
$customroles{$rolename} = \%privs; |
|
if (ref($current{$rolename}) eq 'HASH') { |
|
$order = $current{$rolename}{'order'}; |
|
} |
|
if ($order eq '') { |
|
$order = $count; |
|
} |
|
$ordered{$order} = $rolename; |
|
$count++; |
} |
} |
} |
} |
my $count = 0; |
my $maxnum = scalar(keys(%ordered)); |
|
my @roles_by_num = (); |
|
foreach my $item (sort {$a <=> $b } (keys(%ordered))) { |
|
push(@roles_by_num,$item); |
|
} |
|
my $context = 'domprefs'; |
|
my $crstype = 'Course'; |
|
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); |
|
my @accesstypes = ('all','none'); |
|
my ($numstatustypes,@jsarray); |
|
if (ref($types) eq 'ARRAY') { |
|
if (@{$types} > 0) { |
|
$numstatustypes = scalar(@{$types}); |
|
push(@accesstypes,'status'); |
|
@jsarray = ('bystatus'); |
|
} |
|
} |
|
my %domhelpdesk = &Apache::lonnet::get_active_domroles($dom,['dh']); |
|
if (keys(%domhelpdesk)) { |
|
push(@accesstypes,('inc','exc')); |
|
push(@jsarray,('notinc','notexc')); |
|
} |
|
my $hiddenstr = join("','",@jsarray); |
|
$datatable .= &helpsettings_javascript(\@roles_by_num,$maxnum,$hiddenstr,$formname); |
my $context = 'domprefs'; |
my $context = 'domprefs'; |
my $crstype = 'Course'; |
my $crstype = 'Course'; |
foreach my $role (sort(keys(%customroles))) { |
my $prefix = 'helproles_'; |
my $prefix = 'custhelp'.$count; |
my $add_class = 'LC_hidden'; |
|
foreach my $num (@roles_by_num) { |
|
my $role = $ordered{$num}; |
|
my ($desc,$access,@statuses); |
|
if (ref($current{$role}) eq 'HASH') { |
|
$desc = $current{$role}{'desc'}; |
|
$access = $current{$role}{'access'}; |
|
if (ref($current{$role}{'insttypes'}) eq 'ARRAY') { |
|
@statuses = @{$current{$role}{'insttypes'}}; |
|
} |
|
} |
|
if ($desc eq '') { |
|
$desc = $role; |
|
} |
|
my $identifier = 'custhelp'.$num; |
my %full=(); |
my %full=(); |
my %levels= ( |
my %levels= ( |
course => {}, |
course => {}, |
Line 3088 sub print_helpsettings {
|
Line 3138 sub print_helpsettings {
|
&Apache::lonuserutils::custom_role_privs($customroles{$role},\%full,\%levels,\%levelscurrent); |
&Apache::lonuserutils::custom_role_privs($customroles{$role},\%full,\%levels,\%levelscurrent); |
my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype); |
my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype); |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$datatable .= '<tr '.$css_class.'><td><label>'. |
my $chgstr = ' onchange="javascript:reorderHelpRoles(this.form,'."'helproles_".$num."_pos'".');"'; |
'<input type="checkbox" name="modifycusthelp" value="'.$count.'" />'. |
$datatable .= '<tr '.$css_class.'><td valign="top"><b>'.$role.'</b><br />'. |
'<input type="hidden" name="custhelprole'.$count.'" value="'.$role.'" />'. |
'<select name="helproles_'.$num.'_pos"'.$chgstr.'>'; |
&mt('Modify').'</label></td>'. |
for (my $k=0; $k<=$maxnum; $k++) { |
'<td>'.&mt('Existing helpdesk role:').' '. |
my $vpos = $k+1; |
'<b>'.$role.'</b><br />'. |
my $selstr; |
&Apache::lonuserutils::custom_role_header($context,$crstype, |
if ($k == $num) { |
\@templateroles,$prefix). |
$selstr = ' selected="selected" '; |
|
} |
|
$datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>'; |
|
} |
|
$datatable .= '</select>'.(' 'x2). |
|
'<input type="hidden" name="helproles_'.$num.'" value="'.$role.'" />'. |
|
'</td>'. |
|
'<td><fieldset><legend>'.&mt('Role name').'</legend>'. |
|
&mt('Name shown to users:'). |
|
'<input type="text" name="helproles_'.$num.'_desc" value="'.$desc.'" />'. |
|
'</fieldset>'. |
|
&helpdeskroles_access($dom,$prefix,$num,$add_class,$current{$role},\@accesstypes, |
|
$othertitle,$usertypes,$types,\%domhelpdesk). |
|
'<fieldset>'. |
|
'<legend>'.&mt('Role privileges').&adhocbutton($prefix,$num,'privs','show').'</legend>'. |
&Apache::lonuserutils::custom_role_table($crstype,\%full,\%levels, |
&Apache::lonuserutils::custom_role_table($crstype,\%full,\%levels, |
\%levelscurrent,$prefix). |
\%levelscurrent,$identifier, |
'<br /></td>'; |
'LC_hidden',$prefix.$num.'_privs'). |
$count ++; |
'</fieldset></td>'; |
$itemcount ++; |
$itemcount ++; |
} |
} |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
Line 3113 sub print_helpsettings {
|
Line 3177 sub print_helpsettings {
|
); |
); |
&Apache::lonuserutils::custom_role_privs(\%privs,\%full,\%levels,\%levelscurrent); |
&Apache::lonuserutils::custom_role_privs(\%privs,\%full,\%levels,\%levelscurrent); |
my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype); |
my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype); |
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak"><label>'. |
my $chgstr = ' onchange="javascript:reorderHelpRoles(this.form,'."'helproles_".$count."_pos'".');"'; |
|
$datatable .= '<tr '.$css_class.'><td valign="top"><span class="LC_nobreak"><label>'. |
|
'<input type="hidden" name="helproles_maxnum" value="'.$maxnum.'" />'."\n". |
|
'<select name="helproles_'.$count.'_pos"'.$chgstr.'>'; |
|
for (my $k=0; $k<$maxnum+1; $k++) { |
|
my $vpos = $k+1; |
|
my $selstr; |
|
if ($k == $maxnum) { |
|
$selstr = ' selected="selected" '; |
|
} |
|
$datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>'; |
|
} |
|
$datatable .= '</select> '."\n". |
'<input type="checkbox" name="newcusthelp" value="'.$count.'" />'. &mt('Add'). |
'<input type="checkbox" name="newcusthelp" value="'.$count.'" />'. &mt('Add'). |
'</label></span></td>'. |
'</label></span></td>'. |
'<td><span class="LC_nobreak">'. |
'<td><fieldset><legend>'.&mt('Role name').'</legend>'. |
'<b>'.&mt('Name of new helpdesk role:').'</b> '. |
'<span class="LC_nobreak">'. |
'<input type="text" size="20" name="newcusthelpname" value="" />'. |
&mt('Internal name:'). |
'</span><br />'. |
'<input type="text" size="10" name="custhelpname'.$count.'" value="" />'. |
|
'</span>'.(' 'x4). |
|
'<span class="LC_nobreak">'. |
|
&mt('Name shown to users:'). |
|
'<input type="text" size="20" name="helproles_'.$count.'_desc" value="" />'. |
|
'</span></fieldset>'. |
|
&helpdeskroles_access($dom,$prefix,$count,'',undef,\@accesstypes,$othertitle, |
|
$usertypes,$types,\%domhelpdesk). |
|
'<fieldset><legend>'.&mt('Role privileges').'</legend>'. |
&Apache::lonuserutils::custom_role_header($context,$crstype, |
&Apache::lonuserutils::custom_role_header($context,$crstype, |
\@templateroles,$newcust). |
\@templateroles,$newcust). |
&Apache::lonuserutils::custom_role_table('Course',\%full,\%levels, |
&Apache::lonuserutils::custom_role_table('Course',\%full,\%levels, |
\%levelscurrent,$newcust). |
\%levelscurrent,$newcust). |
'<br /><br />'. |
'</fieldset></td></tr>'; |
'</td></tr>'; |
|
$count ++; |
$count ++; |
$$rowtotal += $count; |
$$rowtotal += $count; |
} |
} |
return $datatable; |
return $datatable; |
} |
} |
|
|
|
sub adhocbutton { |
|
my ($prefix,$num,$field,$visibility) = @_; |
|
my %lt = &Apache::lonlocal::texthash( |
|
show => 'Show details', |
|
hide => 'Hide details', |
|
); |
|
return '<span style="text-decoration:line-through; font-weight: normal;">'.(' 'x10). |
|
'</span>'.(' 'x2).'<input type="button" id="'.$prefix.$num.'_'.$field.'_vis"'. |
|
' value="'.$lt{$visibility}.'" style="height:20px;" '. |
|
'onclick="toggleHelpdeskItem('."'$num','$field'".');" />'.(' 'x2); |
|
} |
|
|
|
sub helpsettings_javascript { |
|
my ($roles_by_num,$total,$hiddenstr,$formname) = @_; |
|
return unless(ref($roles_by_num) eq 'ARRAY'); |
|
my %html_js_lt = &Apache::lonlocal::texthash( |
|
show => 'Show details', |
|
hide => 'Hide details', |
|
); |
|
&html_escape(\%html_js_lt); |
|
my $jstext = ' var helproles = Array('."'".join("','",@{$roles_by_num})."'".');'."\n"; |
|
return <<"ENDSCRIPT"; |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
|
|
function reorderHelpRoles(form,item) { |
|
var changedVal; |
|
$jstext |
|
var newpos = 'helproles_${total}_pos'; |
|
var maxh = 1 + $total; |
|
var current = new Array(); |
|
var newitemVal = form.elements[newpos].options[form.elements[newpos].selectedIndex].value; |
|
if (item == newpos) { |
|
changedVal = newitemVal; |
|
} else { |
|
changedVal = form.elements[item].options[form.elements[item].selectedIndex].value; |
|
current[newitemVal] = newpos; |
|
} |
|
for (var i=0; i<helproles.length; i++) { |
|
var elementName = 'helproles_'+helproles[i]+'_pos'; |
|
if (elementName != item) { |
|
if (form.elements[elementName]) { |
|
var currVal = form.elements[elementName].options[form.elements[elementName].selectedIndex].value; |
|
current[currVal] = elementName; |
|
} |
|
} |
|
} |
|
var oldVal; |
|
for (var j=0; j<maxh; j++) { |
|
if (current[j] == undefined) { |
|
oldVal = j; |
|
} |
|
} |
|
if (oldVal < changedVal) { |
|
for (var k=oldVal+1; k<=changedVal ; k++) { |
|
var elementName = current[k]; |
|
form.elements[elementName].selectedIndex = form.elements[elementName].selectedIndex - 1; |
|
} |
|
} else { |
|
for (var k=changedVal; k<oldVal; k++) { |
|
var elementName = current[k]; |
|
form.elements[elementName].selectedIndex = form.elements[elementName].selectedIndex + 1; |
|
} |
|
} |
|
return; |
|
} |
|
|
|
function helpdeskAccess(num) { |
|
var curraccess = null; |
|
if (document.$formname.elements['helproles_'+num+'_access'].length) { |
|
for (var i=0; i<document.$formname.elements['helproles_'+num+'_access'].length; i++) { |
|
if (document.$formname.elements['helproles_'+num+'_access'][i].checked) { |
|
curraccess = document.$formname.elements['helproles_'+num+'_access'][i].value; |
|
} |
|
} |
|
} |
|
var shown = Array(); |
|
var hidden = Array(); |
|
if (curraccess == 'none') { |
|
hidden = Array('$hiddenstr'); |
|
} else { |
|
if (curraccess == 'status') { |
|
shown = Array('bystatus'); |
|
hidden = Array('notinc','notexc'); |
|
} else { |
|
if (curraccess == 'exc') { |
|
shown = Array('notexc'); |
|
hidden = Array('notinc','bystatus'); |
|
} |
|
if (curraccess == 'inc') { |
|
shown = Array('notinc'); |
|
hidden = Array('notexc','bystatus'); |
|
} |
|
if (curraccess == 'all') { |
|
hidden = Array('notinc','notexc','bystatus'); |
|
} |
|
} |
|
} |
|
if (hidden.length > 0) { |
|
for (var i=0; i<hidden.length; i++) { |
|
if (document.getElementById('helproles_'+num+'_'+hidden[i])) { |
|
document.getElementById('helproles_'+num+'_'+hidden[i]).style.display = 'none'; |
|
} |
|
} |
|
} |
|
if (shown.length > 0) { |
|
for (var i=0; i<shown.length; i++) { |
|
if (document.getElementById('helproles_'+num+'_'+shown[i])) { |
|
if (shown[i] == 'privs') { |
|
document.getElementById('helproles_'+num+'_'+shown[i]).style.display = 'block'; |
|
} else { |
|
document.getElementById('helproles_'+num+'_'+shown[i]).style.display = 'inline-block'; |
|
} |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
function toggleHelpdeskItem(num,field) { |
|
if (document.getElementById('helproles_'+num+'_'+field)) { |
|
if (document.getElementById('helproles_'+num+'_'+field).className.match(/(?:^|\\s)LC_hidden(?!\\S)/)) { |
|
document.getElementById('helproles_'+num+'_'+field).className = |
|
document.getElementById('helproles_'+num+'_'+field).className.replace(/(?:^|\\s)LC_hidden(?!\\S)/g ,''); |
|
if (document.getElementById('helproles_'+num+'_'+field+'_vis')) { |
|
document.getElementById('helproles_'+num+'_'+field+'_vis').value = '$html_js_lt{hide}'; |
|
} |
|
} else { |
|
document.getElementById('helproles_'+num+'_'+field).className += ' LC_hidden'; |
|
if (document.getElementById('helproles_'+num+'_'+field+'_vis')) { |
|
document.getElementById('helproles_'+num+'_'+field+'_vis').value = '$html_js_lt{show}'; |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
// ]]> |
|
</script> |
|
|
|
ENDSCRIPT |
|
} |
|
|
|
sub helpdeskroles_access { |
|
my ($dom,$prefix,$num,$add_class,$current,$accesstypes,$othertitle, |
|
$usertypes,$types,$domhelpdesk) = @_; |
|
return unless ((ref($accesstypes) eq 'ARRAY') && (ref($domhelpdesk) eq 'HASH')); |
|
my %lt = &Apache::lonlocal::texthash( |
|
'rou' => 'Role usage', |
|
'whi' => 'Which helpdesk personnel may use this role?', |
|
'all' => 'All', |
|
'none' => 'None', |
|
'status' => 'Determined based on institutional status', |
|
'inc' => 'Include all, but exclude specific personnel', |
|
'exc' => 'Exclude all, but include specific personnel', |
|
); |
|
my %usecheck = ( |
|
all => ' checked="checked"', |
|
); |
|
my %displaydiv = ( |
|
status => 'none', |
|
inc => 'none', |
|
exc => 'none', |
|
priv => 'block', |
|
); |
|
my $output; |
|
if (ref($current) eq 'HASH') { |
|
if (($current->{'access'} ne '') && ($current->{'access'} ne 'all')) { |
|
if (grep(/^\Q$current->{access}\E$/,@{$accesstypes})) { |
|
$usecheck{$current->{access}} = $usecheck{'all'}; |
|
delete($usecheck{'all'}); |
|
if ($current->{access} =~ /^(status|inc|exc)$/) { |
|
my $access = $1; |
|
$displaydiv{$access} = 'inline'; |
|
} elsif ($current->{access} eq 'none') { |
|
$displaydiv{'priv'} = 'none'; |
|
} |
|
} |
|
} |
|
} |
|
$output = '<fieldset id="'.$prefix.$num.'_usage"><legend>'.$lt{'rou'}.'</legend>'. |
|
'<p>'.$lt{'whi'}.'</p>'; |
|
foreach my $access (@{$accesstypes}) { |
|
$output .= '<p><label><input type="radio" name="'.$prefix.$num.'_access" value="'.$access.'" '.$usecheck{$access}. |
|
' onclick="helpdeskAccess('."'$num'".');" />'. |
|
$lt{$access}.'</label>'; |
|
if ($access eq 'status') { |
|
$output .= '<div id="'.$prefix.$num.'_bystatus" style="display:'.$displaydiv{$access}.'">'. |
|
&Apache::lonuserutils::adhoc_status_types($dom,$prefix,$num,$current->{$access}, |
|
$othertitle,$usertypes,$types). |
|
'</div>'; |
|
} elsif (($access eq 'inc') && (keys(%{$domhelpdesk}) > 0)) { |
|
$output .= '<div id="'.$prefix.$num.'_notinc" style="display:'.$displaydiv{$access}.'">'. |
|
&Apache::lonuserutils::adhoc_staff($access,$prefix,$num,$current->{$access},$domhelpdesk). |
|
'</div>'; |
|
} elsif (($access eq 'exc') && (keys(%{$domhelpdesk}) > 0)) { |
|
$output .= '<div id="'.$prefix.$num.'_notexc" style="display:'.$displaydiv{$access}.'">'. |
|
&Apache::lonuserutils::adhoc_staff($access,$prefix,$num,$current->{$access},$domhelpdesk). |
|
'</div>'; |
|
} |
|
$output .= '</p>'; |
|
} |
|
$output .= '</fieldset>'; |
|
return $output; |
|
} |
|
|
sub radiobutton_prefs { |
sub radiobutton_prefs { |
my ($settings,$toggles,$defaultchecked,$choices,$itemcount,$onclick, |
my ($settings,$toggles,$defaultchecked,$choices,$itemcount,$onclick, |
$additional,$align) = @_; |
$additional,$align) = @_; |
Line 8367 sub modify_quotas {
|
Line 8656 sub modify_quotas {
|
} |
} |
if ($env{'form.validationdc'}) { |
if ($env{'form.validationdc'}) { |
my $newval = $env{'form.validationdc'}; |
my $newval = $env{'form.validationdc'}; |
my %domcoords = &get_active_dcs($dom); |
my %domcoords = &Apache::lonnet::get_active_domroles($dom,['dc']); |
if (exists($domcoords{$newval})) { |
if (exists($domcoords{$newval})) { |
$confhash{'validation'}{'dc'} = $newval; |
$confhash{'validation'}{'dc'} = $newval; |
} |
} |
Line 9624 sub modify_autocreate {
|
Line 9913 sub modify_autocreate {
|
$newvals{$item} = 0 if ($newvals{$item} eq ''); |
$newvals{$item} = 0 if ($newvals{$item} eq ''); |
} |
} |
$newvals{'xmldc'} = $env{'form.autocreate_xmldc'}; |
$newvals{'xmldc'} = $env{'form.autocreate_xmldc'}; |
my %domcoords = &get_active_dcs($dom); |
my %domcoords = &Apache::lonnet::get_active_domroles($dom,['dc']); |
unless (exists($domcoords{$newvals{'xmldc'}})) { |
unless (exists($domcoords{$newvals{'xmldc'}})) { |
$newvals{'xmldc'} = ''; |
$newvals{'xmldc'} = ''; |
} |
} |
Line 11810 sub modify_serverstatuses {
|
Line 12099 sub modify_serverstatuses {
|
} |
} |
|
|
sub modify_helpsettings { |
sub modify_helpsettings { |
my ($r,$dom,$confname,%domconfig) = @_; |
my ($r,$dom,$confname,$lastactref,%domconfig) = @_; |
my ($resulttext,$errors,%changes,%helphash); |
my ($resulttext,$errors,%changes,%helphash); |
my %defaultchecked = ('submitbugs' => 'on'); |
my %defaultchecked = ('submitbugs' => 'on'); |
my @offon = ('off','on'); |
my @offon = ('off','on'); |
my @toggles = ('submitbugs'); |
my @toggles = ('submitbugs'); |
my %current = ('submitbugs' => ''); |
my %current = ('submitbugs' => '', |
|
'adhoc' => {}, |
|
); |
if (ref($domconfig{'helpsettings'}) eq 'HASH') { |
if (ref($domconfig{'helpsettings'}) eq 'HASH') { |
%current = %{$domconfig{'helpsettings'}}; |
%current = %{$domconfig{'helpsettings'}}; |
} |
} |
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); |
foreach my $item (@toggles) { |
foreach my $item (@toggles) { |
if ($defaultchecked{$item} eq 'on') { |
if ($defaultchecked{$item} eq 'on') { |
if ($current{$item} eq '') { |
if ($current{$item} eq '') { |
Line 11841 sub modify_helpsettings {
|
Line 12133 sub modify_helpsettings {
|
$helphash{'helpsettings'}{$item} = $env{'form.'.$item}; |
$helphash{'helpsettings'}{$item} = $env{'form.'.$item}; |
} |
} |
} |
} |
|
my $maxnum = $env{'form.helproles_maxnum'}; |
my @modify = &Apache::loncommon::get_env_multiple('form.modifycusthelp'); |
|
my $confname = $dom.'-domainconfig'; |
my $confname = $dom.'-domainconfig'; |
my %existing=&Apache::lonnet::dump('roles',$dom,$confname,'rolesdef_'); |
my %existing=&Apache::lonnet::dump('roles',$dom,$confname,'rolesdef_'); |
if (@modify) { |
my (@allpos,%newsettings,%changedprivs,$newrole); |
foreach my $num (@modify) { |
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); |
my $rolename = $env{'form.custhelprole'.$num}; |
my @accesstypes = ('all','none','status','inc','exc'); |
if ($rolename ne '') { |
my %domhelpdesk = &Apache::lonnet::get_active_domroles($dom,['dh']); |
if (exists($existing{'rolesdef_'.$rolename})) { |
my %lt = &Apache::lonlocal::texthash( |
my $prefix = 'custhelp'.$num; |
s => 'system', |
my %newprivs = &Apache::lonuserutils::custom_role_update($rolename,$prefix); |
d => 'domain', |
my %currprivs; |
order => 'Display order', |
($currprivs{'s'},$currprivs{'d'},$currprivs{'c'}) = |
access => 'Role usage', |
split(/\_/,$existing{'rolesdef_'.$rolename}); |
all => 'All', |
foreach my $level ('c','d','s') { |
none => 'None', |
if ($newprivs{$level} ne $currprivs{$level}) { |
status => 'Determined based on institutional status', |
$changes{'customrole'}{$rolename} = 1; |
inc => 'Include all, but exclude specific personnel', |
my $result = &Apache::lonnet::definerole($rolename,$newprivs{'s'},$newprivs{'d'}, |
exc => 'Exclude all, but include specific personnel', |
$newprivs{'c'},$confname,$dom); |
); |
last; |
for (my $num=0; $num<=$maxnum; $num++) { |
|
my ($prefix,$identifier,$rolename,%curr); |
|
if ($num == $maxnum) { |
|
next unless ($env{'form.newcusthelp'} == $maxnum); |
|
$identifier = 'custhelp'.$num; |
|
$prefix = 'helproles_'.$num; |
|
$rolename = $env{'form.custhelpname'.$num}; |
|
$rolename=~s/[^A-Za-z0-9]//gs; |
|
next if ($rolename eq ''); |
|
next if (exists($existing{'rolesdef_'.$rolename})); |
|
my %newprivs = &Apache::lonuserutils::custom_role_update($rolename,$identifier); |
|
my $result = &Apache::lonnet::definerole($rolename,$newprivs{'s'},$newprivs{'d'}, |
|
$newprivs{'c'},$confname,$dom); |
|
if ($result ne 'ok') { |
|
$errors .= '<li><span class="LC_error">'. |
|
&mt('An error occurred storing the new custom role: [_1]', |
|
$result).'</span></li>'; |
|
next; |
|
} else { |
|
$changedprivs{$rolename} = \%newprivs; |
|
$newrole = $rolename; |
|
} |
|
} else { |
|
$prefix = 'helproles_'.$num; |
|
$rolename = $env{'form.'.$prefix}; |
|
next if ($rolename eq ''); |
|
next unless (exists($existing{'rolesdef_'.$rolename})); |
|
$identifier = 'custhelp'.$num; |
|
my %newprivs = &Apache::lonuserutils::custom_role_update($rolename,$identifier); |
|
my %currprivs; |
|
($currprivs{'s'},$currprivs{'d'},$currprivs{'c'}) = |
|
split(/\_/,$existing{'rolesdef_'.$rolename}); |
|
foreach my $level ('c','d','s') { |
|
if ($newprivs{$level} ne $currprivs{$level}) { |
|
my $result = &Apache::lonnet::definerole($rolename,$newprivs{'s'},$newprivs{'d'}, |
|
$newprivs{'c'},$confname,$dom); |
|
if ($result ne 'ok') { |
|
$errors .= '<li><span class="LC_error">'. |
|
&mt('An error occurred storing privileges for existing role [_1]: [_2]', |
|
$rolename,$result).'</span></li>'; |
|
} else { |
|
$changedprivs{$rolename} = \%newprivs; |
|
} |
|
last; |
|
} |
|
} |
|
if (ref($current{'adhoc'}) eq 'HASH') { |
|
if (ref($current{'adhoc'}{$rolename}) eq 'HASH') { |
|
%curr = %{$current{'adhoc'}{$rolename}}; |
|
} |
|
} |
|
} |
|
my $newpos = $env{'form.'.$prefix.'_pos'}; |
|
$newpos =~ s/\D+//g; |
|
$allpos[$newpos] = $rolename; |
|
my $newdesc = $env{'form.'.$prefix.'_desc'}; |
|
$helphash{'helpsettings'}{'adhoc'}{$rolename}{'desc'} = $newdesc; |
|
if ($curr{'desc'}) { |
|
if ($curr{'desc'} ne $newdesc) { |
|
$changes{'customrole'}{$rolename}{'desc'} = 1; |
|
$newsettings{$rolename}{'desc'} = $newdesc; |
|
} |
|
} elsif ($newdesc ne '') { |
|
$changes{'customrole'}{$rolename}{'desc'} = 1; |
|
$newsettings{$rolename}{'desc'} = $newdesc; |
|
} |
|
my $access = $env{'form.'.$prefix.'_access'}; |
|
if (grep(/^\Q$access\E$/,@accesstypes)) { |
|
$helphash{'helpsettings'}{'adhoc'}{$rolename}{'access'} = $access; |
|
if ($access eq 'status') { |
|
my @statuses = &Apache::loncommon::get_env_multiple('form.'.$prefix.'_status'); |
|
if (scalar(@statuses) == 0) { |
|
$helphash{'helpsettings'}{'adhoc'}{$rolename}{'access'} = 'none'; |
|
} else { |
|
my (@shownstatus,$numtypes); |
|
$helphash{'helpsettings'}{'adhoc'}{$rolename}{$access} = []; |
|
if (ref($types) eq 'ARRAY') { |
|
$numtypes = scalar(@{$types}); |
|
foreach my $type (sort(@statuses)) { |
|
if ($type eq 'default') { |
|
push(@{$helphash{'helpsettings'}{'adhoc'}{$rolename}{$access}},$type); |
|
} elsif (grep(/^\Q$type\E$/,@{$types})) { |
|
push(@{$helphash{'helpsettings'}{'adhoc'}{$rolename}{$access}},$type); |
|
push(@shownstatus,$usertypes->{$type}); |
|
} |
} |
} |
} |
} |
|
if (grep(/^default$/,@statuses)) { |
|
push(@shownstatus,$othertitle); |
|
} |
|
if (scalar(@shownstatus) == 1+$numtypes) { |
|
$helphash{'helpsettings'}{'adhoc'}{$rolename}{'access'} = 'all'; |
|
delete($helphash{'helpsettings'}{'adhoc'}{$rolename}{'status'}); |
|
} else { |
|
$newsettings{$rolename}{'status'} = join(' '.&mt('or').' ',@shownstatus); |
|
if (ref($curr{'status'}) eq 'ARRAY') { |
|
my @diffs = &Apache::loncommon::compare_arrays($helphash{'helpsettings'}{'adhoc'}{$rolename}{$access},$curr{$access}); |
|
if (@diffs) { |
|
$changes{'customrole'}{$rolename}{$access} = 1; |
|
} |
|
} elsif (@{$helphash{'helpsettings'}{'adhoc'}{$rolename}{$access}}) { |
|
$changes{'customrole'}{$rolename}{$access} = 1; |
|
} |
|
} |
|
} |
|
} elsif (($access eq 'inc') || ($access eq 'exc')) { |
|
my @personnel = &Apache::loncommon::get_env_multiple('form.'.$prefix.'_staff_'.$access); |
|
my @newspecstaff; |
|
$helphash{'helpsettings'}{'adhoc'}{$rolename}{$access} = []; |
|
foreach my $person (sort(@personnel)) { |
|
if ($domhelpdesk{$person}) { |
|
push(@{$helphash{'helpsettings'}{'adhoc'}{$rolename}{$access}},$person); |
|
} |
} |
} |
|
if (ref($curr{$access}) eq 'ARRAY') { |
|
my @diffs = &Apache::loncommon::compare_arrays($helphash{'helpsettings'}{'adhoc'}{$rolename}{$access},$curr{$access}); |
|
if (@diffs) { |
|
$changes{'customrole'}{$rolename}{$access} = 1; |
|
} |
|
} elsif (@{$helphash{'helpsettings'}{'adhoc'}{$rolename}{$access}}) { |
|
$changes{'customrole'}{$rolename}{$access} = 1; |
|
} |
|
foreach my $person (@{$helphash{'helpsettings'}{'adhoc'}{$rolename}{$access}}) { |
|
my ($uname,$udom) = split(/:/,$person); |
|
push(@newspecstaff,&Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$udom,'lastname'),$uname,$udom)); |
|
} |
|
$newsettings{$rolename}{$access} = join(', ',sort(@newspecstaff)); |
} |
} |
|
} else { |
|
$helphash{'helpsettings'}{'adhoc'}{$rolename}{'access'}= 'all'; |
|
} |
|
unless ($curr{'access'} eq $access) { |
|
$changes{'customrole'}{$rolename}{'access'} = 1; |
|
$newsettings{$rolename}{'access'} = $lt{$helphash{'helpsettings'}{'adhoc'}{$rolename}{'access'}}; |
} |
} |
} |
} |
if ($env{'form.newcusthelp'} ne '') { |
if (@allpos > 0) { |
my $prefix = 'custhelp'.$env{'form.newcusthelp'}; |
my $idx = 0; |
my $rolename = $env{'form.newcusthelpname'}; |
foreach my $rolename (@allpos) { |
$rolename=~s/[^A-Za-z0-9]//gs; |
if ($rolename ne '') { |
if ($rolename ne '') { |
$helphash{'helpsettings'}{'adhoc'}{$rolename}{'order'} = $idx; |
unless(exists($existing{'rolesdef_'.$rolename})) { |
if (ref($current{'adhoc'}) eq 'HASH') { |
my %newprivs = &Apache::lonuserutils::custom_role_update($rolename,$prefix); |
if (ref($current{'adhoc'}{$rolename}) eq 'HASH') { |
my $result = &Apache::lonnet::definerole($rolename,$newprivs{'s'},$newprivs{'d'}, |
if ($current{'adhoc'}{$rolename}{'order'} ne $idx) { |
$newprivs{'c'},$confname,$dom); |
$changes{'customrole'}{$rolename}{'order'} = 1; |
if ($result eq 'ok') { |
$newsettings{$rolename}{'order'} = $idx+1; |
$changes{'newcustomrole'} = $rolename; |
} |
} else { |
} |
$errors .= '<li><span class="LC_error">'. |
|
&mt('An error occurred storing the new custom role: [_1]', |
|
$result).'</span></li>'; |
|
} |
} |
|
$idx ++; |
} |
} |
} |
} |
} |
} |
|
|
my $putresult; |
my $putresult; |
if (keys(%changes) > 0) { |
if (keys(%changes) > 0) { |
$putresult = &Apache::lonnet::put_dom('configuration',\%helphash,$dom); |
$putresult = &Apache::lonnet::put_dom('configuration',\%helphash,$dom); |
if ($putresult eq 'ok') { |
if ($putresult eq 'ok') { |
$resulttext = &mt('Changes made:').'<ul>'; |
if (ref($helphash{'helpsettings'}) eq 'HASH') { |
|
$domdefaults{'submitbugs'} = $helphash{'helpsettings'}{'submitbugs'}; |
|
if (ref($helphash{'helpsettings'}{'adhoc'}) eq 'HASH') { |
|
$domdefaults{'adhocroles'} = $helphash{'helpsettings'}{'adhoc'}; |
|
} |
|
} |
|
my $cachetime = 24*60*60; |
|
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime); |
|
if (ref($lastactref) eq 'HASH') { |
|
$lastactref->{'domdefaults'} = 1; |
|
} |
|
} else { |
|
$errors .= '<li><span class="LC_error">'. |
|
&mt('An error occurred storing the settings: [_1]', |
|
$putresult).'</span></li>'; |
|
} |
|
} |
|
if ((keys(%changes) && ($putresult eq 'ok')) || (keys(%changedprivs))) { |
|
$resulttext = &mt('Changes made:').'<ul>'; |
|
my (%shownprivs,@levelorder); |
|
@levelorder = ('c','d','s'); |
|
if ((keys(%changes)) && ($putresult eq 'ok')) { |
foreach my $item (sort(keys(%changes))) { |
foreach my $item (sort(keys(%changes))) { |
if ($item eq 'submitbugs') { |
if ($item eq 'submitbugs') { |
$resulttext .= '<li>'.&mt('Display link to: [_1] set to "'.$offon[$env{'form.'.$item}].'".', |
$resulttext .= '<li>'.&mt('Display link to: [_1] set to "'.$offon[$env{'form.'.$item}].'".', |
Line 11899 sub modify_helpsettings {
|
Line 12337 sub modify_helpsettings {
|
&mt('LON-CAPA bug tracker'),600,500)).'</li>'; |
&mt('LON-CAPA bug tracker'),600,500)).'</li>'; |
} elsif ($item eq 'customrole') { |
} elsif ($item eq 'customrole') { |
if (ref($changes{'customrole'}) eq 'HASH') { |
if (ref($changes{'customrole'}) eq 'HASH') { |
|
my @keyorder = ('order','desc','access','status','exc','inc'); |
|
my %keytext = &Apache::lonlocal::texthash( |
|
order => 'Order', |
|
desc => 'Role description', |
|
access => 'Role usage', |
|
status => 'Allowed instituional types', |
|
exc => 'Allowed personnel', |
|
inc => 'Disallowed personnel', |
|
); |
foreach my $role (sort(keys(%{$changes{'customrole'}}))) { |
foreach my $role (sort(keys(%{$changes{'customrole'}}))) { |
$resulttext .= '<li>'.&mt('Existing custom role modified: [_1]', |
if (ref($changes{'customrole'}{$role}) eq 'HASH') { |
$role).'</li>'; |
if ($role eq $newrole) { |
|
$resulttext .= '<li>'.&mt('New custom role added: [_1]', |
|
$role).'<ul>'; |
|
} else { |
|
$resulttext .= '<li>'.&mt('Existing custom role modified: [_1]', |
|
$role).'<ul>'; |
|
} |
|
foreach my $key (@keyorder) { |
|
if ($changes{'customrole'}{$role}{$key}) { |
|
$resulttext .= '<li>'.&mt("[_1] set to: [_2]", |
|
$keytext{$key},$newsettings{$role}{$key}). |
|
'</li>'; |
|
} |
|
} |
|
if (ref($changedprivs{$role}) eq 'HASH') { |
|
$shownprivs{$role} = 1; |
|
$resulttext .= '<li>'.&mt('Privileges set to :').'<ul>'; |
|
foreach my $level (@levelorder) { |
|
foreach my $item (split(/\:/,$changedprivs{$role}{$level})) { |
|
next if ($item eq ''); |
|
my ($priv) = split(/\&/,$item,2); |
|
if (&Apache::lonnet::plaintext($priv)) { |
|
$resulttext .= '<li>'.&Apache::lonnet::plaintext($priv); |
|
unless ($level eq 'c') { |
|
$resulttext .= ' ('.$lt{$level}.')'; |
|
} |
|
$resulttext .= '</li>'; |
|
} |
|
} |
|
} |
|
$resulttext .= '</ul>'; |
|
} |
|
$resulttext .= '</ul></li>'; |
|
} |
} |
} |
} |
} |
} elsif ($item eq 'newcustomrole') { |
|
$resulttext .= '<li>'.&mt('New custom role added: [_1]', |
|
$changes{'newcustomrole'}).'</li>'; |
|
} |
} |
} |
} |
$resulttext .= '</ul>'; |
|
} else { |
|
$resulttext = &mt('No changes made to help settings'); |
|
$errors .= '<li><span class="LC_error">'. |
|
&mt('An error occurred storing the settings: [_1]', |
|
$putresult).'</span></li>'; |
|
} |
} |
|
if (keys(%changedprivs)) { |
|
foreach my $role (sort(keys(%changedprivs))) { |
|
unless ($shownprivs{$role}) { |
|
$resulttext .= '<li>'.&mt('Existing custom role modified: [_1]', |
|
$role).'<ul>'. |
|
'<li>'.&mt('Privileges set to :').'<ul>'; |
|
foreach my $level (@levelorder) { |
|
foreach my $item (split(/\:/,$changedprivs{$role}{$level})) { |
|
next if ($item eq ''); |
|
my ($priv) = split(/\&/,$item,2); |
|
if (&Apache::lonnet::plaintext($priv)) { |
|
$resulttext .= '<li>'.&Apache::lonnet::plaintext($priv); |
|
unless ($level eq 'c') { |
|
$resulttext .= ' ('.$lt{$level}.')'; |
|
} |
|
$resulttext .= '</li>'; |
|
} |
|
} |
|
} |
|
$resulttext .= '</ul></li></ul></li>'; |
|
} |
|
} |
|
} |
|
$resulttext .= '</ul>'; |
|
} else { |
|
$resulttext = &mt('No changes made to help settings'); |
} |
} |
if ($errors) { |
if ($errors) { |
$resulttext .= '<br />'.&mt('The following errors occurred: ').'<ul>'. |
$resulttext .= '<br />'.&mt('The following errors occurred: ').'<ul>'. |
$errors.'</ul>'; |
$errors.'</ul>'; |
} |
} |
return $resulttext; |
return $resulttext; |
} |
} |
Line 13454 sub recurse_cat_deletes {
|
Line 13951 sub recurse_cat_deletes {
|
return; |
return; |
} |
} |
|
|
sub get_active_dcs { |
|
my ($dom) = @_; |
|
my $now = time; |
|
my %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc'],$now,$now); |
|
my %domcoords; |
|
my $numdcs = 0; |
|
foreach my $server (keys(%dompersonnel)) { |
|
foreach my $user (sort(keys(%{$dompersonnel{$server}}))) { |
|
my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user); |
|
$domcoords{$uname.':'.$udom} = $dompersonnel{$server}{$user}; |
|
} |
|
} |
|
return %domcoords; |
|
} |
|
|
|
sub active_dc_picker { |
sub active_dc_picker { |
my ($dom,$numinrow,$inputtype,$name,%currhash) = @_; |
my ($dom,$numinrow,$inputtype,$name,%currhash) = @_; |
my %domcoords = &get_active_dcs($dom); |
my %domcoords = &get_active_dcs($dom); |