--- loncom/interface/loncommon.pm 2012/12/28 02:03:13 1.1075.2.24 +++ loncom/interface/loncommon.pm 2013/01/01 19:58:11 1.1075.2.25 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1075.2.24 2012/12/28 02:03:13 raeburn Exp $ +# $Id: loncommon.pm,v 1.1075.2.25 2013/01/01 19:58:11 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -67,6 +67,7 @@ use Apache::lonhtmlcommon(); use Apache::loncoursedata(); use Apache::lontexconvert(); use Apache::lonclonecourse(); +use Apache::lonuserutils(); use LONCAPA qw(:DEFAULT :match); use DateTime::TimeZone; use DateTime::Locale::Catalog; @@ -13296,6 +13297,26 @@ sub commit_studentrole { return $result; } +sub show_role_extent { + my ($scope,$context,$role) = @_; + $scope =~ s{^/}{}; + my @courseroles = &Apache::lonuserutils::roles_by_context('course',1); + push(@courseroles,'co'); + my @authorroles = &Apache::lonuserutils::roles_by_context('author'); + if (($context eq 'course') || (grep(/^\Q$role\E/,@courseroles))) { + $scope =~ s{/}{_}; + return ''.$env{'course.'.$scope.'.description'}.''; + } elsif (($context eq 'author') || (grep(/^\Q$role\E/,@authorroles))) { + my ($audom,$auname) = split(/\//,$scope); + return &mt('[_1] Author Space',''. + &Apache::loncommon::plainname($auname,$audom).''); + } else { + $scope =~ s{/$}{}; + return &mt('Domain: [_1]',''. + &Apache::lonnet::domain($scope,'description').''); + } +} + ############################################################ ############################################################