--- loncom/interface/loncommon.pm 2005/11/15 15:52:51 1.290 +++ loncom/interface/loncommon.pm 2005/11/15 22:03:05 1.294 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.290 2005/11/15 15:52:51 albertel Exp $ +# $Id: loncommon.pm,v 1.294 2005/11/15 22:03:05 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -380,7 +380,7 @@ sub coursebrowser_javascript { return (< var stdeditbrowser; - function opencrsbrowser(formname,uname,udom,desc,extra_element) { + function opencrsbrowser(formname,uname,udom,desc,extra_element,multflag) { var url = '/adm/pickcourse?'; var filter; if (filter != null) { @@ -403,6 +403,9 @@ sub coursebrowser_javascript { url += '&domainfilter='+extra_element; } } + if (multflag !=null && multflag != '') { + url += '&multiple='+multflag; + } var title = 'Course_Browser'; var options = 'scrollbars=1,resizable=1,menubar=0'; options += ',width=700,height=600'; @@ -414,9 +417,9 @@ ENDSTDBRW } sub selectcourse_link { - my ($form,$unameele,$udomele,$desc,$extra_element)=@_; + my ($form,$unameele,$udomele,$desc,$extra_element,$multflag)=@_; return "".&mt('Select Course').""; + '","'.$udomele.'","'.$desc.'","'.$extra_element.'","'.$multflag.'");'."'>".&mt('Select Course').""; } sub check_uncheck_jscript { @@ -3082,6 +3085,83 @@ sub get_sections { ############################################### =pod + +=item get_group_settings + +Uses TokeParser to extract group information from the +XML used to describe course groups. + +Input: +Scalar containing XML (as retrieved from &lonnet::get_coursegroups). + +Output: +Hash containing group information as key=values for (a), and +hash of hashes for (b) + +Keys (in two categories): +(a) groupname, creator, creation, modified, startdate,enddate. +Corresponding values are name of the group, creator of the group +(username:domain), UNIX time for date group was created, and +settings were last modified, and default start and end access +times for group members. + +(b) functions returned in hash of hashes. +Outer hash key is functions. +Inner hash keys are chat,discussion,email,files,homepage,roster. +Corresponding values are either on or off, depending on +whther this type of functionality is available for the group. + +=cut + +############################################### + +sub get_group_settings { + my ($groupinfo)=@_; + my $parser=HTML::TokeParser->new(\$groupinfo); + my $token; + my $tool = ''; + my %content=(); + while ($token=$parser->get_token) { + if ($token->[0] eq 'S') { + my $entry=$token->[1]; + if ($entry eq 'functions') { + %{$content{$entry}} = (); + $tool = $entry; + } else { + my $value=$parser->get_text('/'.$entry); + if ($entry eq 'name') { + if ($tool eq 'functions') { + my $function = $token->[2]{id}; + $content{$tool}{$function} = $value; + } + } elsif ($entry eq 'groupname') { + $content{$entry}=&Apache::lonnet::unescape($value); + } else { + $content{$entry}=$value; + } + } + } elsif ($token->[0] eq 'E') { + if ($token->[1] eq 'functions') { + $tool = ''; + } + } + } + return %content; +} + +sub check_group_access { + my ($group) = @_; + my $access = 1; + my $now = time; + my ($start,$end) = split(/\./,$env{'user.role.gr/'.$env{'request.course,id'}.'/'.$group}); + if (($end!=0) && ($end<$now)) { $access = 0; } + if (($start!=0) && ($start>$now)) { $access=0; } + return $access; +} + +############################################### + +=pod =item get_course_users @@ -3128,7 +3208,7 @@ sub get_course_users { my $now = time; foreach my $student (keys(%{$classlist})) { my $match = 0; - if (ref($sections) eq 'ARRAY') && (@{$sections} > 0) { + if ((ref($sections) eq 'ARRAY') && (@{$sections} > 0)) { unless(grep(/^\Q$$classlist{$student}[$idx{section}]\E$/, @{$sections})) { next; @@ -3207,8 +3287,8 @@ sub get_user_info { my ($udom,$uname,$idx,$userdata) = @_; $$userdata{$uname.':'.$udom}[$$idx{fullname}] = &plainname($uname,$udom,'lastname'); - $$userdata{$uname.':'.$udom}[$$idx{uname}] = $uname - $$userdata{$uname.':'.$udom}[$$idx{uname}] = $udom + $$userdata{$uname.':'.$udom}[$$idx{uname}] = $uname; + $$userdata{$uname.':'.$udom}[$$idx{uname}] = $udom; return; } @@ -3350,6 +3430,7 @@ sub no_cache { sub content_type { my ($r,$type,$charset) = @_; + &no_cache($r); if ($env{'browser.mathml'} && $type eq 'text/html') { $type='text/xml'; } unless ($charset) { $charset=&Apache::lonlocal::current_encoding;