[Cpan-forum-commit] rev 18 - in trunk: lib/CPAN lib/CPAN/Forum
templates
svn at pti.co.il
svn at pti.co.il
Sat Jan 15 19:29:09 IST 2005
Author: gabor
Date: 2005-01-15 19:29:09 +0200 (Sat, 15 Jan 2005)
New Revision: 18
Modified:
trunk/lib/CPAN/Forum.pm
trunk/lib/CPAN/Forum/Posts.pm
trunk/templates/editor.tmpl
Log:
check subject length during preview, max it to 50 chars
Modified: trunk/lib/CPAN/Forum/Posts.pm
===================================================================
--- trunk/lib/CPAN/Forum/Posts.pm 2005-01-15 16:35:54 UTC (rev 17)
+++ trunk/lib/CPAN/Forum/Posts.pm 2005-01-15 17:29:09 UTC (rev 18)
@@ -13,7 +13,7 @@
__PACKAGE__->set_sql(count_thread => "SELECT count(*) FROM __TABLE__ WHERE thread=%s");
__PACKAGE__->set_sql(count_where => "SELECT count(*) FROM __TABLE__ WHERE %s='%s'");
__PACKAGE__->set_sql(count_like => "SELECT count(*) FROM __TABLE__ WHERE %s LIKE '%s'");
-__PACKAGE__->add_constraint('subject_too_long', subject => sub { length $_[0] <= 70 and $_[0] !~ /</});
+#__PACKAGE__->add_constraint('subject_too_long', subject => sub { length $_[0] <= 70 and $_[0] !~ /</});
#__PACKAGE__->add_constraint('text_format', text => \&check_text_format);
sub retrieve_latest {
Modified: trunk/lib/CPAN/Forum.pm
===================================================================
--- trunk/lib/CPAN/Forum.pm 2005-01-15 16:35:54 UTC (rev 17)
+++ trunk/lib/CPAN/Forum.pm 2005-01-15 17:29:09 UTC (rev 18)
@@ -1144,8 +1144,13 @@
push @errors, "no_group";
}
}
- push @errors, "no_subject" if not $q->param("new_subject");
- push @errors, "no_text" if not $q->param("new_text");
+
+ my $new_subject = $q->param("new_subject");
+ my $new_text = $q->param("new_text");
+
+ push @errors, "no_subject" if not $new_subject;
+ push @errors, "no_text" if not $new_text;
+ push @errors, "subject_too_long" if $new_subject and length($new_subject) > 50;
return $self->posts(\@errors) if @errors;
@@ -1153,7 +1158,6 @@
# We will save the message only if the Submit button was pressed.
# When the editor first displayed and every time if an error was caught this button will be hidden.
- my $new_text = $q->param("new_text");
eval {
_posting_process($new_text) ;
};
@@ -1189,7 +1193,7 @@
#warn "PG:" . $post->gid;
};
if ($@) {
- push @errors, "subject_too_long" if $@ =~ /subject_too_long/;
+ #push @errors, "subject_too_long" if $@ =~ /subject_too_long/;
#warn $CPAN::Forum::Post::lasterror if $@ =~ /text_format/;
if (not @errors) {
warn "UNKNOWN_ERROR: $@";
Modified: trunk/templates/editor.tmpl
===================================================================
--- trunk/templates/editor.tmpl 2005-01-15 16:35:54 UTC (rev 17)
+++ trunk/templates/editor.tmpl 2005-01-15 17:29:09 UTC (rev 18)
@@ -5,7 +5,7 @@
<TMPL_IF no_text>No text provided<br /></TMPL_IF>
<TMPL_IF bad_group>Bad distribution name<br /></TMPL_IF>
<TMPL_IF bad_data>Bad data<br /></TMPL_IF>
- <TMPL_IF subject_too_long>Subject must be up to 70 characters.<br /></TMPL_IF>
+ <TMPL_IF subject_too_long>Subject must be up to 50 characters.<br /></TMPL_IF>
<TMPL_IF text_format>Text format is not correct.<br /></TMPL_IF>
<TMPL_IF bad_thing>Bad thing<br /></TMPL_IF>
More information about the Cpan-forum-commit
mailing list