version 1.1332, 2017/01/02 19:44:20
|
version 1.1333, 2017/01/05 18:44:41
|
Line 4490 sub get_my_roles {
|
Line 4490 sub get_my_roles {
|
return %returnhash; |
return %returnhash; |
} |
} |
|
|
|
sub get_all_adhocroles { |
|
my ($dom) = @_; |
|
my @roles_by_num = (); |
|
my %domdefaults = &get_domain_defaults($dom); |
|
my (%description,%access_in_dom,%access_info); |
|
if (ref($domdefaults{'adhocroles'}) eq 'HASH') { |
|
my $count = 0; |
|
my %domcurrent = %{$domdefaults{'adhocroles'}}; |
|
my %ordered; |
|
foreach my $role (sort(keys(%domcurrent))) { |
|
my ($order,$desc,$access_in_dom); |
|
if (ref($domcurrent{$role}) eq 'HASH') { |
|
$order = $domcurrent{$role}{'order'}; |
|
$desc = $domcurrent{$role}{'desc'}; |
|
$access_in_dom{$role} = $domcurrent{$role}{'access'}; |
|
$access_info{$role} = $domcurrent{$role}{$access_in_dom{$role}}; |
|
} |
|
if ($order eq '') { |
|
$order = $count; |
|
} |
|
$ordered{$order} = $role; |
|
if ($desc ne '') { |
|
$description{$role} = $desc; |
|
} else { |
|
$description{$role}= $role; |
|
} |
|
$count++; |
|
} |
|
foreach my $item (sort {$a <=> $b } (keys(%ordered))) { |
|
push(@roles_by_num,$ordered{$item}); |
|
} |
|
} |
|
return (\@roles_by_num,\%description,\%access_in_dom,\%access_info); |
|
} |
|
|
sub get_my_adhocroles { |
sub get_my_adhocroles { |
my ($cid) = @_; |
my ($cid,$checkreg) = @_; |
my (@possroles,%description); |
my ($cdom,$cnum,%info,@possroles,$description,$roles_by_num); |
if ($cid =~ /^($match_domain)_($match_courseid)$/) { |
if ($env{'request.course.id'} eq $cid) { |
my $cdom = $1; |
$cdom = $env{'course.'.$cid.'.domain'}; |
my $cnum = $2; |
$cnum = $env{'course.'.$cid.'.num'}; |
|
$info{'internal.coursecode'} = $env{'course.'.$cid.'.internal.coursecode'}; |
|
} elsif ($cid =~ /^($match_domain)_($match_courseid)$/) { |
|
$cdom = $1; |
|
$cnum = $2; |
|
%info = &Apache::lonnet::get('environment',['internal.coursecode'], |
|
$cdom,$cnum); |
|
} |
|
if (($info{'internal.coursecode'} ne '') && ($checkreg)) { |
|
my $user = $env{'user.name'}.':'.$env{'user.domain'}; |
|
my %rosterhash = &get('classlist',[$user],$cdom,$cnum); |
|
if ($rosterhash{$user} ne '') { |
|
my $type = (split(/:/,$rosterhash{$user}))[5]; |
|
return ([],{}) if ($type eq 'auto'); |
|
} |
|
} |
|
if (($cdom ne '') && ($cnum ne '')) { |
if ($env{"user.role.dh./$cdom/"}) { |
if ($env{"user.role.dh./$cdom/"}) { |
my $then=$env{'user.login.time'}; |
my $then=$env{'user.login.time'}; |
my $update=$env{'user.update.time'}; |
my $update=$env{'user.update.time'}; |
Line 4509 sub get_my_adhocroles {
|
Line 4560 sub get_my_adhocroles {
|
if ($tend && $tend <$limit) { $liverole = 0; } |
if ($tend && $tend <$limit) { $liverole = 0; } |
if ($liverole) { |
if ($liverole) { |
if (&homeserver($cnum,$cdom) ne 'no_host') { |
if (&homeserver($cnum,$cdom) ne 'no_host') { |
my %domdefaults = &get_domain_defaults($cdom); |
my ($accessref,$accessinfo,%access_in_dom); |
if (ref($domdefaults{'adhocroles'}) eq 'HASH') { |
($roles_by_num,$description,$accessref,$accessinfo) = &get_all_adhocroles($cdom); |
my $count = 0; |
if (ref($roles_by_num) eq 'ARRAY') { |
my %domcurrent = %{$domdefaults{'adhocroles'}}; |
if (@{$roles_by_num}) { |
my (%ordered,%access_in_dom); |
|
foreach my $role (sort(keys(%domcurrent))) { |
|
my ($order,$desc,$access_in_dom); |
|
if (ref($domcurrent{$role}) eq 'HASH') { |
|
$order = $domcurrent{$role}{'order'}; |
|
$desc = $domcurrent{$role}{'desc'}; |
|
$access_in_dom{$role} = $domcurrent{$role}{'access'}; |
|
} |
|
if ($order eq '') { |
|
$order = $count; |
|
} |
|
$ordered{$order} = $role; |
|
if ($desc ne '') { |
|
$description{$role} = $desc; |
|
} else { |
|
$description{$role}= $role; |
|
} |
|
$count++; |
|
} |
|
my @roles_by_num = (); |
|
foreach my $item (sort {$a <=> $b } (keys(%ordered))) { |
|
push(@roles_by_num,$ordered{$item}); |
|
} |
|
if (@roles_by_num) { |
|
my %settings; |
my %settings; |
if ($env{'request.course.id'} eq $cid) { |
if ($env{'request.course.id'} eq $cid) { |
foreach my $envkey (keys(%env)) { |
foreach my $envkey (keys(%env)) { |
Line 4556 sub get_my_adhocroles {
|
Line 4583 sub get_my_adhocroles {
|
@statuses = split(/,/,$env{'environment.inststatus'}); |
@statuses = split(/,/,$env{'environment.inststatus'}); |
} |
} |
my $user = $env{'user.name'}.':'.$env{'user.domain'}; |
my $user = $env{'user.name'}.':'.$env{'user.domain'}; |
foreach my $role (@roles_by_num) { |
if (ref($accessref) eq 'HASH') { |
|
%access_in_dom = %{$accessref}; |
|
} |
|
foreach my $role (@{$roles_by_num}) { |
my ($curraccess,@okstatus,@personnel); |
my ($curraccess,@okstatus,@personnel); |
if ($setincrs{$role}) { |
if ($setincrs{$role}) { |
($curraccess,my $rest) = split(/=/,$settings{'internal.adhoc.'.$role}); |
($curraccess,my $rest) = split(/=/,$settings{'internal.adhoc.'.$role}); |
Line 4567 sub get_my_adhocroles {
|
Line 4597 sub get_my_adhocroles {
|
} |
} |
} else { |
} else { |
$curraccess = $access_in_dom{$role}; |
$curraccess = $access_in_dom{$role}; |
if ($curraccess eq 'status') { |
if (ref($accessinfo) eq 'HASH') { |
if (ref($domcurrent{$role}{$curraccess}) eq 'ARRAY') { |
if ($curraccess eq 'status') { |
@okstatus = @{$domcurrent{$role}{$curraccess}}; |
if (ref($accessinfo->{$role}) eq 'ARRAY') { |
} |
@okstatus = @{$accessinfo->{$role}}; |
} elsif (($curraccess eq 'exc') || ($curraccess eq 'inc')) { |
} |
if (ref($domcurrent{$role}{$curraccess}) eq 'ARRAY') { |
} elsif (($curraccess eq 'exc') || ($curraccess eq 'inc')) { |
@personnel = @{$domcurrent{$role}{$curraccess}}; |
if (ref($accessinfo->{$role}) eq 'ARRAY') { |
|
@personnel = @{$accessinfo->{$role}}; |
|
} |
} |
} |
} |
} |
} |
} |
Line 4612 sub get_my_adhocroles {
|
Line 4644 sub get_my_adhocroles {
|
} |
} |
} |
} |
} |
} |
return (\@possroles,\%description); |
unless (ref($description) eq 'HASH') { |
|
if (ref($roles_by_num) eq 'ARRAY') { |
|
my %desc; |
|
map { $desc{$_} = $_; } (@{$roles_by_num}); |
|
$description = \%desc; |
|
} else { |
|
$description = {}; |
|
} |
|
} |
|
return (\@possroles,$description); |
} |
} |
|
|
# ----------------------------------------------------- Frontpage Announcements |
# ----------------------------------------------------- Frontpage Announcements |