[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface lonmenu.pm

raeburn raeburn at source.lon-capa.org
Mon Jan 30 14:06:47 EST 2017


raeburn		Mon Jan 30 19:06:47 2017 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonmenu.pm 
  Log:
  - For 2.11
    - Backport 1.466.
  
  
-------------- next part --------------
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.369.2.68 loncom/interface/lonmenu.pm:1.369.2.69
--- loncom/interface/lonmenu.pm:1.369.2.68	Sun Jan 22 17:10:28 2017
+++ loncom/interface/lonmenu.pm	Mon Jan 30 19:06:46 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.369.2.68 2017/01/22 17:10:28 raeburn Exp $
+# $Id: lonmenu.pm,v 1.369.2.69 2017/01/30 19:06:46 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2601,78 +2601,85 @@
             (ref($courseprivs) eq 'HASH') && (ref($roledesc) eq 'HASH')) {
         return;
     }
-    if ($env{"user.role.dh./$cdom/"}) {
-        my ($start,$end)=split(/\./,$env{"user.role.dh./$cdom/"});
-        my $now = time;
-        if (!($start && ($now<$start)) && !($end && ($now>$end))) {
-            my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($cdom.'_'.$cnum);
-            my %available;
-            if (ref($possroles) eq 'ARRAY') {
-                map { $available{$_} = 1; } @{$possroles};
-            }
-            my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
-            if (ref($domdefaults{'adhocroles'}) eq 'HASH') {
-                if (keys(%{$domdefaults{'adhocroles'}})) {
-                    my $numsec = 1;
-                    my @sections;
-                    my ($allseclist,$cached) =
-                        &Apache::lonnet::is_cached_new('courseseclist',$cdom.'_'.$cnum);
-                    if (defined($cached)) {
-                        if ($allseclist ne '') {
-                            @sections = split(/,/,$allseclist);
-                            $numsec += scalar(@sections);
-                        }
-                    } else {
-                        my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum);
-                        @sections = sort(keys(%sections_count));
+    my $is_helpdesk = 0;
+    my $now = time;
+    foreach my $role ('dh','da') {
+        if ($env{"user.role.$role./$cdom/"}) {
+            my ($start,$end)=split(/\./,$env{"user.role.$role./$cdom/"});
+            if (!($start && ($now<$start)) && !($end && ($now>$end))) {
+                $is_helpdesk = 1;
+                last;
+            }
+        }
+    }
+    if ($is_helpdesk) {
+        my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($cdom.'_'.$cnum);
+        my %available;
+        if (ref($possroles) eq 'ARRAY') {
+            map { $available{$_} = 1; } @{$possroles};
+        }
+        my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
+        if (ref($domdefaults{'adhocroles'}) eq 'HASH') {
+            if (keys(%{$domdefaults{'adhocroles'}})) {
+                my $numsec = 1;
+                my @sections;
+                my ($allseclist,$cached) =
+                    &Apache::lonnet::is_cached_new('courseseclist',$cdom.'_'.$cnum);
+                if (defined($cached)) {
+                    if ($allseclist ne '') {
+                        @sections = split(/,/,$allseclist);
                         $numsec += scalar(@sections);
-                        $allseclist = join(',', at sections);
-                        &Apache::lonnet::do_cache_new('courseseclist',$cdom.'_'.$cnum,$allseclist);
                     }
-                    my (%adhoc,$gotprivs);
-                    my $prefix = "cr/$cdom/$cdom".'-domainconfig';
-                    foreach my $role (keys(%{$domdefaults{'adhocroles'}})) {
-                        next if (($role eq '') || ($role =~ /\W/));
-                        $seccount->{"$prefix/$role"} = $numsec;
-                        $roledesc->{"$prefix/$role"} = $description->{$role};  
-                        if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0)) {
-                            if (exists($env{"user.priv.$prefix/$role./$cdom/$cnum./"})) {
-                                $courseprivs->{"$prefix/$role./$cdom/$cnum./"} =
-                                    $env{"user.priv.$prefix/$role./$cdom/$cnum./"};
-                                $courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/"} =
-                                    $env{"user.priv.$prefix/$role./$cdom/$cnum./$cdom/"};
-                                $courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/$cnum"} =
-                                    $env{"user.priv.$prefix/$role./$cdom/$cnum./$cdom/$cnum"};
-                            } else {
-                                unless ($gotprivs) {
-                                    my ($adhocroles,$privscached) =
-                                        &Apache::lonnet::is_cached_new('adhocroles',$cdom);
-                                    if ((defined($privscached)) && (ref($adhocroles) eq 'HASH')) {
-                                        %adhoc = %{$adhocroles};
-                                    } else {
-                                        my $confname = &Apache::lonnet::get_domainconfiguser($cdom);
-                                        my %roledefs = &Apache::lonnet::dump('roles',$cdom,$confname,'rolesdef_');
-                                        foreach my $key (keys(%roledefs)) {
-                                            (undef,my $rolename) = split(/_/,$key);
-                                            if ($rolename ne '') {
-                                                my ($systempriv,$domainpriv,$coursepriv) = split(/\_/,$roledefs{$key});
-                                                $coursepriv = &Apache::lonnet::course_adhocrole_privs($rolename,$cdom,$cnum,$coursepriv);
-                                                $adhoc{$rolename} = join('_',($systempriv,$domainpriv,$coursepriv));
-                                            }
+                } else {
+                    my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum);
+                    @sections = sort(keys(%sections_count));
+                    $numsec += scalar(@sections);
+                    $allseclist = join(',', at sections);
+                    &Apache::lonnet::do_cache_new('courseseclist',$cdom.'_'.$cnum,$allseclist);
+                }
+                my (%adhoc,$gotprivs);
+                my $prefix = "cr/$cdom/$cdom".'-domainconfig';
+                foreach my $role (keys(%{$domdefaults{'adhocroles'}})) {
+                    next if (($role eq '') || ($role =~ /\W/));
+                    $seccount->{"$prefix/$role"} = $numsec;
+                    $roledesc->{"$prefix/$role"} = $description->{$role};  
+                    if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0)) {
+                        if (exists($env{"user.priv.$prefix/$role./$cdom/$cnum./"})) {
+                            $courseprivs->{"$prefix/$role./$cdom/$cnum./"} =
+                                $env{"user.priv.$prefix/$role./$cdom/$cnum./"};
+                            $courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/"} =
+                                $env{"user.priv.$prefix/$role./$cdom/$cnum./$cdom/"};
+                            $courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/$cnum"} =
+                                $env{"user.priv.$prefix/$role./$cdom/$cnum./$cdom/$cnum"};
+                        } else {
+                            unless ($gotprivs) {
+                                my ($adhocroles,$privscached) =
+                                    &Apache::lonnet::is_cached_new('adhocroles',$cdom);
+                                if ((defined($privscached)) && (ref($adhocroles) eq 'HASH')) {
+                                    %adhoc = %{$adhocroles};
+                                } else {
+                                    my $confname = &Apache::lonnet::get_domainconfiguser($cdom);
+                                    my %roledefs = &Apache::lonnet::dump('roles',$cdom,$confname,'rolesdef_');
+                                    foreach my $key (keys(%roledefs)) {
+                                        (undef,my $rolename) = split(/_/,$key);
+                                        if ($rolename ne '') {
+                                            my ($systempriv,$domainpriv,$coursepriv) = split(/\_/,$roledefs{$key});
+                                            $coursepriv = &Apache::lonnet::course_adhocrole_privs($rolename,$cdom,$cnum,$coursepriv);
+                                            $adhoc{$rolename} = join('_',($systempriv,$domainpriv,$coursepriv));
                                         }
-                                        &Apache::lonnet::do_cache_new('adhocroles',$cdom,\%adhoc);
                                     }
-                                    $gotprivs = 1;
+                                    &Apache::lonnet::do_cache_new('adhocroles',$cdom,\%adhoc);
                                 }
-                                ($courseprivs->{"$prefix/$role./$cdom/$cnum./"},
-                                 $courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/"},
-                                 $courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/$cnum"}) =
-                                     split(/\_/,$adhoc{$role});
+                                $gotprivs = 1;
                             }
+                            ($courseprivs->{"$prefix/$role./$cdom/$cnum./"},
+                             $courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/"},
+                             $courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/$cnum"}) =
+                                 split(/\_/,$adhoc{$role});
                         }
-                        if ($available{$role}) {
-                            $courseroles->{"$prefix/$role"} = \@sections;
-                        }
+                    }
+                    if ($available{$role}) {
+                        $courseroles->{"$prefix/$role"} = \@sections;
                     }
                 }
             }


More information about the LON-CAPA-cvs mailing list