afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
afuna ([personal profile] afuna) wrote in [site community profile] changelog2009-03-04 04:26 pm

[dw-free] FAQ variables not expanded consistently in FAQ titles (questions)

[commit: http://hg.dwscoalition.org/dw-free/rev/170e6692a0ee]

http://bugs.dwscoalition.org/show_bug.cgi?id=115

Clean up htdocs/admin/faq/faqedit.bml. No functional change.

Patch by [personal profile] pauamma.

Files modified:
  • htdocs/admin/faq/faqedit.bml
--------------------------------------------------------------------------------
diff -r 0d3e89efccea -r 170e6692a0ee htdocs/admin/faq/faqedit.bml
--- a/htdocs/admin/faq/faqedit.bml	Wed Mar 04 16:00:11 2009 +0000
+++ b/htdocs/admin/faq/faqedit.bml	Wed Mar 04 16:25:16 2009 +0000
@@ -3,156 +3,123 @@ _info?><?page
 _info?><?page
 title=><?_code return $FORM{'id'} ? "Edit FAQ Item #$FORM{'id'}" : "Add to FAQ"; _code?>
 body<=
+<center>
+<a href="./"><b>(Back to FAQ Index)</b></a>
+</center>
 
-<CENTER>
-<A HREF="./"><B>(Back to FAQ Index)</B></A>
-</CENTER>
+<form action="faqedit_do.bml" method="post">
+<?_code
+    $id = $FORM{'id'} + 0;
+    $ret = "";
 
+    my $dbh = LJ::get_db_writer();
 
-<FORM ACTION="faqedit_do.bml" METHOD=POST>
-<?_code
+    my $remote = LJ::get_remote();
+    my %ac_edit;
+    my %ac_add;
+    LJ::remote_has_priv( $remote, "faqadd", \%ac_add );
 
- $id = $FORM{'id'} + 0;
- $ret = "";
+    if ( $id ) {
+        LJ::remote_has_priv( $remote, "faqedit", \%ac_edit );
+        my $sth = $dbh->prepare( "SELECT question, summary, answer, faqcat, sortorder FROM faq WHERE faqid=$id" );
+        $sth->execute;
+        ($question, $summary, $answer, $faqcat, $sortorder) = $sth->fetchrow_array or
+            return "<b>Error:</b> FAQ #$id does not exist.";
 
- my $dbh = LJ::get_db_writer();
+        unless ( $ac_edit{'*'} || $ac_edit{$faqcat} ) {
+            if ( %ac_edit ) {
+                return "<b>Error: </b> You do not have access to edit a FAQ question in the \"$faqcat\" category.";
+            } else {
+                return "<b>Error: </b> You do not have access to edit the FAQ.";
+            }
+        }
+    } else {
+        return "<b>Error: </b> You do not have access to add to the FAQ."
+            unless %ac_add;
+    }
 
- my $remote = LJ::get_remote();
- my %ac_edit;
- my %ac_add;
- LJ::remote_has_priv($remote, "faqadd", \%ac_add);
+    $sortorder += 0;
+    $sortorder ||= 50;
 
- if ($id)
- {
-     LJ::remote_has_priv($remote, "faqedit", \%ac_edit);
-     my $sth = $dbh->prepare("SELECT question, summary, answer, faqcat, sortorder FROM faq WHERE faqid=$id");
-     $sth->execute;
-     ($question, $summary, $answer, $faqcat, $sortorder) = $sth->fetchrow_array or
-         return "<b>Error:</b> FAQ #$id does not exist.";
+    $ret .= LJ::form_auth();
+    $ret .= LJ::html_hidden( 'id', $id );
+    $ret .= "<p>Category: ";
 
-     unless ($ac_edit{'*'} || $ac_edit{$faqcat}) {
-         if (%ac_edit) {
-             return "<B>Error: </B> You do not have access to edit a FAQ question in the \"$faqcat\" category.";
-         } else {
-             return "<B>Error: </B> You do not have access to edit the FAQ.";
-         }
-     }
- }
- else
- {
-     unless (%ac_add) {
-         return "<B>Error: </B> You do not have access to add to the FAQ.";
-     }
- }
+    my $sth = $dbh->prepare( "SELECT faqcat, faqcatname FROM faqcat ORDER BY catorder" );
+    $sth->execute;
+    my @cats;
+    push @cats, '', '';
+    my $faqd = LJ::Lang::get_dom( "faq" );
 
+    while ( ($fc, $fcname) = $sth->fetchrow_array )
+    {
+        if ( $id ) {
+            next unless $ac_add{'*'} || $ac_add{$fc} || ($fc eq $faqcat);
+        } else {
+            next unless $ac_add{'*'} || $ac_add{$fc};
+        }
 
- $sortorder += 0;
- $sortorder ||= 50;
+        push @cats, $fc, $fcname;
+    }
 
- $ret .= LJ::form_auth();
- $ret .= LJ::html_hidden('id', $id);
- $ret .= "<p>Category: ";
+    $ret .= LJ::html_select( { name => 'faqcat', selected => $faqcat }, @cats );
 
- my $sth = $dbh->prepare("SELECT faqcat, faqcatname FROM faqcat ORDER BY catorder");
- $sth->execute;
- my @cats;
- push @cats, '';push @cats, '';
- my $faqd = LJ::Lang::get_dom("faq");
+    $ret .= "&nbsp;SortOrder: ";
+    $ret .= LJ::html_text( { name => 'sortorder', value => $sortorder,
+                             size => 5, maxlength => 4 } );
 
- while (($fc, $fcname) = $sth->fetchrow_array)
- {
-     if ($id) {
-         next unless ($ac_add{'*'} || $ac_add{$fc} || ($fc eq $faqcat));
-     } else {
-         next unless ($ac_add{'*'} || $ac_add{$fc});
-     }
+    $ret .= "<br><i>(sort order is how to sort within the category.  categories themselves are also sorted.)</i></p>";
 
-     push @cats, $fc;
-     push @cats, $fcname;
- }
+    $ret .= "<?h1 Question h1?> <?p (as brief as possible, do not span multiple lines) p?><p>";
 
- $ret .= LJ::html_select({
-     'name'     => 'faqcat',
-     'selected' => $faqcat,},
-                         @cats);
+    $ret .= LJ::html_textarea( { name => 'q', value => $question,
+                                 rows => 2, cols => 70, wrap => 'soft' } );
+    $ret .= "<br /><i>(erase question to delete FAQ entry)</i></p>";
+ 
+    if ( $faqd && $id != 0 ) {
+        $ret .= "<p><b>Select modification level for question:</b> ";
+        $ret .= LJ::html_select( { name => "sev_question", selected => 0 },
+                                 0 => "Typo/etc (no notify)",
+                                 1 => "Minor (notify translators)",
+                                 2 => "Major (require translation updates)");
+        $ret .= "</p>";
+    }
 
- $ret .= "&nbsp;SortOrder: ";
- $ret .= LJ::html_text({
-     'name'      => 'sortorder',
-     'value'     => $sortorder,
-     'size'      => 5,
-     'maxlength' => 4,
- });
+    $ret .= "<?h1 Summary h1?> <?p (should be a shortish paragraph, urls are automatically linked, same markup as journal entries, no lj-cut) p?><p>";
 
- $ret .= "<br><i>(sort order is how to sort within the category.  categories themselves are also sorted.)</i></p>";
+    $ret .= LJ::html_textarea( { name => 's', value => $summary,
+                                 rows => '10', cols => '70', wrap => 'soft' } );
+    $ret .= "</p>";
 
- $ret .= "<?h1 Question h1?> <?p (as brief as possible, do not span multiple lines) p?><p>";
+    if ( $faqd && $id != 0 ) {
+        $ret .= "<p><b>Select modification level for summary:</b> ";
+        $ret .= LJ::html_select( { name => "sev_summary", selected => 0 },
+                                 0 => "Typo/etc (no notify)",
+                                 1 => "Minor (notify translators)",
+                                 2 => "Major (require translation updates)" );
+        $ret .= "</p>";
+    }
 
- $ret .= LJ::html_textarea({
-     'name'  => 'q',
-     'value' => $question,
-     'rows'  => 2,
-     'cols'  => 70,
-     'wrap'  => 'soft'
-     });
- $ret .= "<br /><i>(erase question to delete FAQ entry)</i></p>";
- 
- if ($faqd && $id != 0) {
-     $ret .= "<p><b>Select modification level for question:</b> ";
-     $ret .= LJ::html_select({ 'name' => "sev_question", "selected" => 0 },
-                             0 => "Typo/etc (no notify)",
-                             1 => "Minor (notify translators)",
-                             2 => "Major (require translation updates)");
-     $ret .= "</p>";
- }
+    $ret .= "<?h1 Answer h1?> <?p (long as you want, urls are automatically linked, same markup as journal entries, no lj-cut) p?><p>";
 
- $ret .= "<?h1 Summary h1?> <?p (should be a shortish paragraph, urls are automatically linked, same markup as journal entries, no lj-cut) p?><p>";
+    $ret .= LJ::html_textarea( { name => 'a', value => $answer,
+                                 rows => '15', cols => '70', wrap => 'soft' } );
+    $ret .= "</p>";
 
- $ret .= LJ::html_textarea({
-     'name'  => 's',
-     'value' => $summary,
-     'rows'  => '10',
-     'cols'  => '70',
-     'wrap'  => 'soft'
-     });
- $ret .= "</p>";
+    if ( $faqd && $id != 0 ) {
+        $ret .= "<p><b>Select modification level for answer:</b> ";
+        $ret .= LJ::html_select( { name => "sev_answer", selected => 0 },
+                                 0 => "Typo/etc (no notify)",
+                                 1 => "Minor (notify translators)",
+                                 2 => "Major (require translation updates)" );
+        $ret .= "</p>";
+    }
 
- if ($faqd && $id != 0) {
-     $ret .= "<p><b>Select modification level for summary:</b> ";
-     $ret .= LJ::html_select({ 'name' => "sev_summary", "selected" => 0 },
-                             0 => "Typo/etc (no notify)",
-                             1 => "Minor (notify translators)",
-                             2 => "Major (require translation updates)");
-     $ret .= "</p>";
- }
+    $ret .= "<p>" . LJ::html_submit( '', 'Add/Edit FAQ Item' ) . "</p>";
+    return $ret;
+_code?>
 
- $ret .= "<?h1 Answer h1?> <?p (long as you want, urls are automatically linked, same markup as journal entries, no lj-cut) p?><p>";
-
- $ret .= LJ::html_textarea({
-     'name'  => 'a',
-     'value' => $answer,
-     'rows'  => '15',
-     'cols'  => '70',
-     'wrap'  => 'soft'
-     });
- $ret .= "</p>";
-
- if ($faqd && $id != 0) {
-     $ret .= "<p><b>Select modification level for answer:</b> ";
-     $ret .= LJ::html_select({ 'name' => "sev_answer", "selected" => 0 },
-                             0 => "Typo/etc (no notify)",
-                             1 => "Minor (notify translators)",
-                             2 => "Major (require translation updates)");
-     $ret .= "</p>";
- }
-
-
- $ret .= "<p>" . LJ::html_submit('', 'Add/Edit FAQ Item') . "</p>";
- return $ret;
-
- _code?>
-
-</FORM>
+</form>
 
 <=body
 page?><?_c <LJDEP>
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org