[LON-CAPA-cvs] cvs: loncom /interface lonpickcourse.pm

raeburn raeburn at source.lon-capa.org
Tue Jan 3 12:47:58 EST 2017


raeburn		Tue Jan  3 17:47:58 2017 EDT

  Modified files:              
    /loncom/interface	lonpickcourse.pm 
  Log:
  - Remove early version of &get_my_adhocroles() subroutine within this module;
    (the one in lonnet.pm is used instead).
  
  
Index: loncom/interface/lonpickcourse.pm
diff -u loncom/interface/lonpickcourse.pm:1.123 loncom/interface/lonpickcourse.pm:1.124
--- loncom/interface/lonpickcourse.pm:1.123	Mon Jan  2 19:44:06 2017
+++ loncom/interface/lonpickcourse.pm	Tue Jan  3 17:47:57 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Pick a course
 #
-# $Id: lonpickcourse.pm,v 1.123 2017/01/02 19:44:06 raeburn Exp $
+# $Id: lonpickcourse.pm,v 1.124 2017/01/03 17:47:57 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1030,136 +1030,6 @@
     return $rolechooser.&Apache::lonhtmlcommon::scripttag($output);
 }
 
-sub get_my_adhocroles {
-    my (@okroles,%description);
-    if ($env{'form.cid'} =~ /^($match_domain)_($match_courseid)$/) {
-        my $cdom = $1;
-        my $cnum = $2;
-        if ($env{"user.role.dh./$cdom/"}) {
-            my $then=$env{'user.login.time'};
-            my $update=$env{'user.update.time'};
-            my $liverole = 1;
-            my ($tstart,$tend)=split(/\./,$env{'user.role.dh./'.$cdom});
-            my $limit = $update;
-            if ($env{'request.role'} eq 'dh./'.$cdom.'/') {
-                $limit = $then;
-            }
-            if ($tstart && $tstart>$limit) { $liverole = 0; }
-            if ($tend   && $tend  <$limit) { $liverole = 0; }
-            if ($liverole) {
-                if (&Apache::lonnet::homeserver($cnum,$cdom) ne 'no_host') {
-                    my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
-                    if (ref($domdefaults{'adhocroles'}) eq 'HASH') {
-                        my $count = 0;
-                        my %domcurrent = %{$domdefaults{'adhocroles'}};
-                        my (%ordered,%access_in_dom);
-                        foreach my $role (sort(keys(%{$domdefaults{'adhocroles'}}))) {
-                            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 = &Apache::lonnet::dump('environment',$cdom,$cnum,'internal\.adhoc');
-                            my %setincrs;
-                            if ($settings{'internal.adhocaccess'}) {
-                                map { $setincrs{$_} = 1; } split(/,/,$settings{'internal.adhocaccess'});
-                            }
-                            my @statuses;
-                            if ($env{'environment.inststatus'}) {
-                                @statuses = split(/,/,$env{'environment.inststatus'});
-                            }
-                            my $user = $env{'user.name'}.':'.$env{'user.domain'};
-                            foreach my $role (@roles_by_num) {
-                                my ($curraccess, at okstatus, at personnel);
-                                if ($setincrs{$role}) {
-                                    ($curraccess,my $rest) = split(/=/,$settings{'internal.adhoc.'.$role});
-                                    if ($curraccess eq 'none') {
-                                        next;
-                                    } elsif ($curraccess eq 'all') {
-                                        push(@okroles,$role);
-                                    } elsif ($curraccess eq 'status') {
-                                        @okstatus = split(/\&/,$rest);
-                                    } elsif (($curraccess eq 'exc') || ($curraccess eq 'inc')) {
-                                        @personnel = split(/\&/,$rest);
-                                    }
-                                } else {
-                                    $curraccess = $access_in_dom{$role};
-                                    if ($curraccess eq 'status') {
-                                        if (ref($domcurrent{$role}{$curraccess}) eq 'ARRAY') {
-                                            @okstatus = @{$domcurrent{$role}{$curraccess}};
-                                        }
-                                    } elsif (($curraccess eq 'exc') || ($curraccess eq 'inc')) {
-                                        if (ref($domcurrent{$role}{$curraccess}) eq 'ARRAY') {
-                                            @personnel = @{$domcurrent{$role}{$curraccess}};
-                                        }
-                                    }
-                                }
-                                if ($curraccess eq 'none') {
-                                    next;
-                                } elsif ($curraccess eq 'all') {
-                                    push(@okroles,$role);
-                                } elsif ($curraccess eq 'status') {
-                                    if (@okstatus) {
-                                        if (!@statuses) {
-                                            if (grep(/^default$/, at okstatus)) {
-                                                push(@okroles,$role);
-                                            }
-                                        } else {
-                                            foreach my $status (@okstatus) {
-                                                if (grep(/^\Q$status\E$/, at statuses)) {
-                                                    push(@okroles,$role);
-                                                    last;
-                                                }
-                                            }
-                                        }
-                                    }
-                                } elsif (($curraccess eq 'exc') || ($curraccess eq 'inc')) {
-                                    if (grep(/^\Q$user\E$/, at personnel)) {
-                                        if ($curraccess eq 'exc') {
-                                            push(@okroles,$role);
-                                        }
-                                    } elsif ($curraccess eq 'inc') {
-                                        push(@okroles,$role);
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    my $response = [];
-    if (@okroles) {
-        foreach my $role (@okroles) {
-            push(@{$response},
-                              { name => $role,
-                                desc => $description{$role},
-                              });
-        }
-    }
-    my $json = JSON::DWIW->to_json({roles => $response});
-    return $json;
-}
-
 1;
 __END__
 




More information about the LON-CAPA-cvs mailing list