[LON-CAPA-cvs] cvs: loncom /interface loncoursegroups.pm longroup.pm lonsimplepage.pm

raeburn raeburn@source.lon-capa.org
Tue, 23 Feb 2010 14:18:12 -0000


raeburn		Tue Feb 23 14:18:12 2010 EDT

  Modified files:              
    /loncom/interface	loncoursegroups.pm longroup.pm lonsimplepage.pm 
  Log:
  - New routine in longroup.pm: &get_group_link() to get link to group homepage.
    - supports situations where group homepage has encrypted url.
  
  
Index: loncom/interface/loncoursegroups.pm
diff -u loncom/interface/loncoursegroups.pm:1.109 loncom/interface/loncoursegroups.pm:1.110
--- loncom/interface/loncoursegroups.pm:1.109	Wed Jan 27 13:08:01 2010
+++ loncom/interface/loncoursegroups.pm	Tue Feb 23 14:18:12 2010
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncoursegroups.pm,v 1.109 2010/01/27 13:08:01 wenzelju Exp $
+# $Id: loncoursegroups.pm,v 1.110 2010/02/23 14:18:12 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -170,7 +170,7 @@
     my %actionlinks = (
       modify => '<a href="/adm/coursegroups?action=modify&refpage='.
                          $env{'form.refpage'}.'&state=pick_task&groupname=',
-      view => '<a href="/adm/'.$cdom.'/'.$cnum.'/',
+      view => '<a href="',
       delete => '<a href="/adm/coursegroups?action=delete&refpage='.
                          $env{'form.refpage'}.'&state=verify&groupname=',
       reenable => '<a href="/adm/coursegroups?action=reenable&refpage='.
@@ -221,6 +221,14 @@
                                                           $status);
 
         if (%curr_groups) {
+            my $navmap=Apache::lonnavmaps::navmap->new();
+            if (!defined($navmap)) {
+                $r->print('<div class="LC_error">'.
+                          &mt('An error occurred retrieving information about resources in the course.').'<br />'.
+                          &mt('It is recommended that you [_1]re-initialize the course[_2] and then return to this page.','<a href="/adm/roles?selectrole=1&newrole='.$env{'request.role'}.'&orgurl=%2fadm%2fcoursegroups">','</a>').
+                          '</div>');
+                return;
+            }
             if ($manage_permission) {
                 if ($action ne 'reenable') {
                     $r->print('<br /><a href="/adm/coursegroups?action=create&amp;refpage='.$env{'form.refpage'}.'">'.$lt{'crng'}.'</a>');
@@ -324,7 +332,8 @@
                         $action eq 'reenable') {
                         $link .= $group;
                     } else {
-                        $link .= $group.'/smppg?ref=grouplist';
+                        $link .= 
+                            &Apache::longroup::get_group_link($cdom,$cnum,$group,$navmap).'&amp;ref=grouplist';
                         if (exists($env{'form.refpage'})) {
                             $link .= '&amp;refpage='.$env{'form.refpage'};
                         }
@@ -386,12 +395,23 @@
             $r->print('<br /><br />');
             my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
             if (%curr_groups) {
+                my $navmap=Apache::lonnavmaps::navmap->new();
+                if (!defined($navmap)) {
+                    $r->print('<div class="LC_error">'.
+                              &mt('An error occurred retrieving information about resources in the course.').'<br />'.
+                              &mt('It is recommended that you [_1]re-initialize the course[_2] and then return to this page.','<a href="/adm/roles?selectrole=1&newrole='.$env{'request.role'}.'&orgurl=%2fadm%2fcoursegroups">','</a>').
+                              '</div>');
+                    return;
+                }
                 foreach my $group (@coursegroups) {
                     my %group_info =  &Apache::longroup::get_group_settings(
                                         $curr_groups{$group});
                     my $description = &unescape(
                                         $group_info{description});
-                    $r->print('<font size="+1"><a href="/adm/'.$cdom.'/'.$cnum.'/'.$group.'/smppg?ref=grouplist">'.$group,'</a><font><br /><small>'.$description.'</small><br /><br />');
+                    my $link = 
+                        &Apache::longroup::get_group_link($cdom,$cnum,$group,$navmap).
+                        '&amp;ref=grouplist';
+                    $r->print('<span style="font-size: larger"><a href="'.$link.'">'.$group,'</a></span><br /><small>'.$description.'</small><br /><br />');
                 }
             }
         } else {
Index: loncom/interface/longroup.pm
diff -u loncom/interface/longroup.pm:1.23 loncom/interface/longroup.pm:1.24
--- loncom/interface/longroup.pm:1.23	Sat Jan 30 18:19:16 2010
+++ loncom/interface/longroup.pm	Tue Feb 23 14:18:12 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # accessor routines used to provide information about course groups 
 #
-# $Id: longroup.pm,v 1.23 2010/01/30 18:19:16 raeburn Exp $
+# $Id: longroup.pm,v 1.24 2010/02/23 14:18:12 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -688,5 +688,19 @@
 
 ###############################################
 
+sub get_group_link {
+    my ($cdom,$cnum,$group,$navmap) = @_;
+    if (ref($navmap)) {
+        my $symb = 'uploaded/'.$cdom.'/'.$cnum.'/group_folder_'.$group.'.sequence___1___adm/'.$cdom.'/'.$cnum.'/'.$group.'/smppg';
+        my $res = $navmap->getBySymb($symb);
+        my $link = $res->link();
+        $link .= (($link=~/\?/)?'&amp;':'?').'symb='.$res->shown_symb();
+        return $link;
+    }
+    return;
+}
+
+###############################################
+
 1;
 
Index: loncom/interface/lonsimplepage.pm
diff -u loncom/interface/lonsimplepage.pm:1.93 loncom/interface/lonsimplepage.pm:1.94
--- loncom/interface/lonsimplepage.pm:1.93	Sun Jan 31 06:03:55 2010
+++ loncom/interface/lonsimplepage.pm	Tue Feb 23 14:18:12 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Simple Page Editor
 #
-# $Id: lonsimplepage.pm,v 1.93 2010/01/31 06:03:55 faziophi Exp $
+# $Id: lonsimplepage.pm,v 1.94 2010/02/23 14:18:12 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -39,6 +39,7 @@
 use Apache::lonprintout;
 use Apache::lonxml;
 use Apache::longroup;
+use Apache::lonnavmaps();
 use HTML::Entities();
 use LONCAPA;
 
@@ -257,19 +258,28 @@
     if ($target ne 'tex') {
         if ($allowed || $privileged) {
             my $functions=&Apache::lonhtmlcommon::start_funclist();
+            my $url = $r->uri;
+            if ($group ne '') {
+                my $navmap=Apache::lonnavmaps::navmap->new();
+                if (ref($navmap)) {
+                    $url = &Apache::longroup::get_group_link($dom,$crs,$group,$navmap);
+                }
+            }
             if ($allowed) {
+                $url .= (($url=~/\?/)?'&amp;':'?').'forcestudent=1';
                 $functions.=&Apache::lonhtmlcommon::add_item_funclist(
-                                '<a href="'.$r->uri.'?forcestudent=1">'
+                                '<a href="'.$url.'">'
                                .&mt('Show Student View').'</a>'
                                .&Apache::loncommon::help_open_topic(
                                     'Uploaded_Templates_PublicView'));
             } elsif ($privileged) {
                 my $edittext = &mt('Edit');
-                    if ($group ne '') {
+                $url .= (($url=~/\?/)?'&amp;':'?').'forceedit=edit'.$refarg;
+                if ($group ne '') {
                     $edittext = &mt('Edit Group Homepage');
                 }
                 $functions.=&Apache::lonhtmlcommon::add_item_funclist(
-                                '<a href="'.$r->uri.'?forceedit=edit'.$refarg.'">'
+                                '<a href="'.$url.'">'
                                .$edittext.'</a>');
                 if ($group ne '') {
                     if ($group_edit_perm) {