[LON-CAPA-cvs] cvs: modules /raeburn/register register.pm

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Sat, 19 Apr 2008 13:52:38 -0000


raeburn		Sat Apr 19 09:52:38 2008 EDT

  Modified files:              
    /modules/raeburn/register	register.pm 
  Log:
  - fix typo in SQL statement to retrieve nights.
  - &display_form_elements() takes additional argument - $context. (Used to allow registrations.pm to display a form row when editing the form for an event).   
  
  
Index: modules/raeburn/register/register.pm
diff -u modules/raeburn/register/register.pm:1.16 modules/raeburn/register/register.pm:1.17
--- modules/raeburn/register/register.pm:1.16	Tue Apr  1 22:46:42 2008
+++ modules/raeburn/register/register.pm	Sat Apr 19 09:52:36 2008
@@ -1,12 +1,12 @@
-########################################################## 
+##########################################################
 #
 # Session-based registration for conferences/workshops
 # Data read/written from MySQL database.
 #
-# $Id: register.pm,v 1.16 2008/04/02 02:46:42 raeburn Exp $
+# $Id: register.pm,v 1.17 2008/04/19 13:52:36 raeburn Exp $
 #
 # Stuart P Raeburn
-# 
+#
 ##########################################################
 package Apache::LON::register;
 
@@ -466,7 +466,7 @@
                 if ($$feeinfo{$iid}{reqd} eq 'Y') {
                     if ($$feeinfo{$iid}{'type'} eq 'accomm') {
                         my $quoted_type = $dbh->quote( $$feeinfo{$iid}{desc} );
-                        my $nights = $dbh->selectrow_array("SELECT nights FROM event_accommodation WHERE (user_id = $quoted_user AND $event_id = '$event_id' AND type = $quoted_type)");
+                        my $nights = $dbh->selectrow_array("SELECT nights FROM event_accommodation WHERE (user_id = $quoted_user AND event_id = '$event_id' AND type = $quoted_type)");
                         $total{$iid} = $nights;
                     } else {
                         if ($total{$iid} eq '' || $total{$iid} == 0) {
@@ -916,14 +916,18 @@
 }
 
 sub display_form_elements {
-    my ($r,$rowitems,$rowtitles,$form_elements,$userinfo) = @_;
-    $r->print(<<"END_OF_BLOCK");
+    my ($r,$rowitems,$rowtitles,$form_elements,$userinfo,$context) = @_;
+    if ($context eq 'edit') {
+        $r->print('<table class="LC_regform">');
+    } else {
+        $r->print(<<"END_OF_BLOCK");
     <table>
       <tr>
        <td>&nbsp;</td>
        <td>
         <table class="LC_regform">
 END_OF_BLOCK
+    }
     for (my $i=0; $i<@{$rowitems}; $i++) {
         my $leftcss = 'LC_leftinner';
         my $rightcss = 'LC_rightinner';
@@ -1032,13 +1036,17 @@
                     </td>
                    </tr>');
     }
-    $r->print(<<"ENDBLOCK");
+    if ($context eq 'edit') {
+        $r->print('</table>');
+    } else {
+        $r->print(<<"ENDBLOCK");
         </table>
         </td>
        </tr>
       </table>
       <br />
 ENDBLOCK
+    }
     return;
 }