diff --git a/docs/upgrades/upgrade_5.4.4-5.5.0.sql b/docs/upgrades/upgrade_5.4.4-5.5.0.sql
index fca9bc8d9..2c9da088a 100644
--- a/docs/upgrades/upgrade_5.4.4-5.5.0.sql
+++ b/docs/upgrades/upgrade_5.4.4-5.5.0.sql
@@ -222,8 +222,27 @@ alter table forum add column archiveAfter int not null default 31536000;
alter table forum add column postsPerPage int not null default 30;
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1045,1,'WebGUI','Nested', 1066405110,'A label indicating the layout of a forum thread.');
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1046,1,'WebGUI','Archived', 1066406723,'A label indicating that the content has a status of archived.');
-
-
-
-
+create table replacements (replacementId int not null primary key, searchFor varchar(255), replaceWith text);
+update userProfileField set dataValues='{\n threaded=>WebGUI::International::get(511),\n flat=>WebGUI::International::get(510),\n nested=>WebGUI::International::get(1045)\n}\n' where fieldName='discussionLayout';
+insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1053,1,'WebGUI','Manage Replacements', 1066419031,'A heading for the replacement listings page.');
+insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1052,1,'WebGUI','Edit Replacement', 1066418983,'A heading for the edit replacement page. ');
+insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1051,1,'WebGUI','Replace With', 1066418940,'Prompt the admin to enter a string to replace the search for string with in the replacement text.');
+insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1050,1,'WebGUI','Search For', 1066418903,'Prompt the admin to enter a string to search for in the replacement text.');
+insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1049,1,'WebGUI','Replacement ID', 1066418840,'Show the admin what the unique identifier for this replacement is.');
+insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1048,1,'WebGUI','Manage replacements.', 1066418767,'A label for a link that lists all replacements.');
+insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1047,1,'WebGUI','Add a replacement.', 1066418669,'A label for a link that adds a new replacement (used in message boards).');
+insert into incrementer values ("replacementId","1000");
+INSERT INTO replacements VALUES (1,'[quote]','
');
+INSERT INTO replacements VALUES (2,'[/quote]','
');
+INSERT INTO replacements VALUES (3,'[image]','
');
+INSERT INTO replacements VALUES (5,'shit','crap');
+INSERT INTO replacements VALUES (6,'fuck','farg');
+INSERT INTO replacements VALUES (7,'asshole','icehole');
+INSERT INTO replacements VALUES (8,'nigger','guy');
+INSERT INTO replacements VALUES (9,'[b]','');
+INSERT INTO replacements VALUES (10,'[/b]','');
+INSERT INTO replacements VALUES (11,'[i]','');
+INSERT INTO replacements VALUES (12,'[/i]','');
+INSERT INTO replacements VALUES (0,NULL,NULL);
diff --git a/lib/WebGUI/Forum/UI.pm b/lib/WebGUI/Forum/UI.pm
index a4a8aa836..30c2cfbb0 100644
--- a/lib/WebGUI/Forum/UI.pm
+++ b/lib/WebGUI/Forum/UI.pm
@@ -422,9 +422,9 @@ sub getPostTemplateVars {
$var->{'post.message'} = ''.$var->{'post.message'}.'
';
}
if ($forum->get("allowReplacements")) {
- my $sth = WebGUI::SQL->read("select pattern,replaceWith from forumReplacement");
- while (my ($pattern,$replaceWith) = $sth->array) {
- $var->{'post.message'} =~ s/\Q$pattern/$replaceWith/g;
+ my $sth = WebGUI::SQL->read("select searchFor,replaceWith from replacements");
+ while (my ($searchFor,$replaceWith) = $sth->array) {
+ $var->{'post.message'} =~ s/\Q$searchFor/$replaceWith/gs;
}
$sth->finish;
}
diff --git a/lib/WebGUI/Operation.pm b/lib/WebGUI/Operation.pm
index 9258f2dcb..d990c9b3a 100644
--- a/lib/WebGUI/Operation.pm
+++ b/lib/WebGUI/Operation.pm
@@ -22,6 +22,7 @@ use WebGUI::Operation::International;
use WebGUI::Operation::Package;
use WebGUI::Operation::Page;
use WebGUI::Operation::ProfileSettings;
+use WebGUI::Operation::Replacements;
use WebGUI::Operation::Root;
use WebGUI::Operation::Scratch;
use WebGUI::Operation::Search;
diff --git a/lib/WebGUI/Operation/Replacements.pm b/lib/WebGUI/Operation/Replacements.pm
new file mode 100644
index 000000000..01199dca5
--- /dev/null
+++ b/lib/WebGUI/Operation/Replacements.pm
@@ -0,0 +1,103 @@
+package WebGUI::Operation::Replacements;
+
+#-------------------------------------------------------------------
+# WebGUI is Copyright 2001-2003 Plain Black LLC.
+#-------------------------------------------------------------------
+# Please read the legal notices (docs/legal.txt) and the license
+# (docs/license.txt) that came with this distribution before using
+# this software.
+#-------------------------------------------------------------------
+# http://www.plainblack.com info@plainblack.com
+#-------------------------------------------------------------------
+
+use Exporter;
+use strict;
+use WebGUI::Icon;
+use WebGUI::HTMLForm;
+use WebGUI::International;
+use WebGUI::Operation::Shared;
+use WebGUI::Session;
+use WebGUI::SQL;
+
+our @ISA = qw(Exporter);
+our @EXPORT = qw(&www_deleteReplacement &www_editReplacement &www_editReplacementSave &www_listReplacements);
+
+#-------------------------------------------------------------------
+sub _submenu {
+ my (%menu);
+ tie %menu, 'Tie::IxHash';
+ $menu{WebGUI::URL::page("op=editReplacement&replacementId=new")} = WebGUI::International::get(1047);
+ $menu{WebGUI::URL::page("op=listReplacements")} = WebGUI::International::get(1048);
+ $menu{WebGUI::URL::page('op=manageSettings')} = WebGUI::International::get(4);
+ return menuWrapper($_[0],\%menu);
+}
+
+
+#-------------------------------------------------------------------
+sub www_deleteReplacement {
+ return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
+ WebGUI::SQL->write("delete from replacements where replacementId=$session{form}{replacementId}");
+ return www_listReplacements();
+}
+
+#-------------------------------------------------------------------
+sub www_editReplacement {
+ return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
+ my $data = WebGUI::SQL->getRow("replacements","replacementId",$session{form}{replacementId});
+ my $f = WebGUI::HTMLForm->new;
+ $f->hidden(
+ -name=>"op",
+ -value=>"editReplacementSave"
+ );
+ $f->hidden(
+ -name=>"replacementId",
+ -value=>$session{form}{replacementId}
+ );
+ $f->readOnly(
+ -label=>WebGUI::International::get(1049),
+ -value=>$session{form}{replacementId}
+ );
+ $f->text(
+ -name=>"searchFor",
+ -label=>WebGUI::International::get(1050),
+ -value=>$data->{searchFor}
+ );
+ $f->textarea(
+ -label=>WebGUI::International::get(1051),
+ -name=>"replaceWith",
+ -value=>$data->{replaceWith}
+ );
+ $f->submit;
+ return _submenu("".WebGUI::International::get(1052)."
".$f->print);
+}
+
+#-------------------------------------------------------------------
+sub www_editReplacementSave {
+ return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
+ WebGUI::SQL->setRow("replacements","replacementId",{
+ replacementId=>$session{form}{replacementId},
+ searchFor=>$session{form}{searchFor},
+ replaceWith=>$session{form}{replaceWith}
+ });
+ return www_listReplacements();
+}
+
+#-------------------------------------------------------------------
+sub www_listReplacements {
+ return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
+ my $output = "".WebGUI::International::get(1053)."
";
+ $output .= '';
+ my $sth = WebGUI::SQL->read("select replacementId,searchFor from replacements order by searchFor");
+ while (my $data = $sth->hashRef) {
+ $output .= '| '.deleteIcon("op=deleteReplacement&replacementId=".$data->{replacementId})
+ .editIcon("op=editReplacement&replacementId=".$data->{replacementId}).' | ';
+ $output .= ''.$data->{searchFor}.' |
';
+ }
+ $sth->finish;
+ $output .= '
';
+ return _submenu($output);
+}
+
+
+
+1;
diff --git a/lib/WebGUI/Operation/Settings.pm b/lib/WebGUI/Operation/Settings.pm
index f3a19be90..e95827962 100644
--- a/lib/WebGUI/Operation/Settings.pm
+++ b/lib/WebGUI/Operation/Settings.pm
@@ -36,33 +36,6 @@ sub _submenu {
return menuWrapper($_[0],\%menu);
}
-#-------------------------------------------------------------------
-sub www_editUserSettings {
- return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
- my ($output, $f, $cmd, $html, $options);
- $output .= helpIcon(2);
- $output .= ''.WebGUI::International::get(117).'
';
- $f = WebGUI::HTMLForm->new;
- $f->hidden("op","saveSettings");
- $f->yesNo("anonymousRegistration",WebGUI::International::get(118),$session{setting}{anonymousRegistration});
- $f->text("runOnRegistration",WebGUI::International::get(559),$session{setting}{runOnRegistration});
- $f->yesNo("useKarma",WebGUI::International::get(539),$session{setting}{useKarma});
- $f->integer("karmaPerLogin",WebGUI::International::get(540),$session{setting}{karmaPerLogin});
- $f->interval("sessionTimeout",WebGUI::International::get(142),WebGUI::DateTime::secondsToInterval($session{setting}{sessionTimeout}));
- $f->yesNo("selfDeactivation",WebGUI::International::get(885),$session{setting}{selfDeactivation});
- $f->yesNo("encryptLogin",WebGUI::International::get(1006),$session{setting}{encryptLogin});
- foreach (@{$session{config}{authMethods}}) {
- $options->{$_} = $_;
- }
- $f->select("authMethod",$options,WebGUI::International::get(119),[$session{setting}{authMethod}]);
- foreach (@{$session{config}{authMethods}}) {
- $f->raw(WebGUI::Authentication::settingsForm($_));
- }
- $f->submit;
- $output .= $f->print;
- return _submenu($output);
-}
-
#-------------------------------------------------------------------
sub www_editCompanyInformation {
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
@@ -152,6 +125,33 @@ sub www_editMiscSettings {
return _submenu($output);
}
+#-------------------------------------------------------------------
+sub www_editUserSettings {
+ return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
+ my ($output, $f, $cmd, $html, $options);
+ $output .= helpIcon(2);
+ $output .= ''.WebGUI::International::get(117).'
';
+ $f = WebGUI::HTMLForm->new;
+ $f->hidden("op","saveSettings");
+ $f->yesNo("anonymousRegistration",WebGUI::International::get(118),$session{setting}{anonymousRegistration});
+ $f->text("runOnRegistration",WebGUI::International::get(559),$session{setting}{runOnRegistration});
+ $f->yesNo("useKarma",WebGUI::International::get(539),$session{setting}{useKarma});
+ $f->integer("karmaPerLogin",WebGUI::International::get(540),$session{setting}{karmaPerLogin});
+ $f->interval("sessionTimeout",WebGUI::International::get(142),WebGUI::DateTime::secondsToInterval($session{setting}{sessionTimeout}));
+ $f->yesNo("selfDeactivation",WebGUI::International::get(885),$session{setting}{selfDeactivation});
+ $f->yesNo("encryptLogin",WebGUI::International::get(1006),$session{setting}{encryptLogin});
+ foreach (@{$session{config}{authMethods}}) {
+ $options->{$_} = $_;
+ }
+ $f->select("authMethod",$options,WebGUI::International::get(119),[$session{setting}{authMethod}]);
+ foreach (@{$session{config}{authMethods}}) {
+ $f->raw(WebGUI::Authentication::settingsForm($_));
+ }
+ $f->submit;
+ $output .= $f->print;
+ return _submenu($output);
+}
+
#-------------------------------------------------------------------
sub www_manageSettings {
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
@@ -164,6 +164,7 @@ sub www_manageSettings {
$output .= ''.WebGUI::International::get(133).'';
$output .= ''.WebGUI::International::get(140).'';
$output .= ''.WebGUI::International::get(308).'';
+ $output .= ''.WebGUI::International::get(1048).'';
$output .= ''.WebGUI::International::get(117).'';
$output .= '';
return _submenu($output);