When the property changes, we need to go retroactively update the
global search flag of posts. They will be pulled or added to the index after
the next indexing run.
Patch by mark.
diffs (55 lines):
diff -r 6c29b8fbc9ab -r 608c256164b7 cgi-bin/DW/Hooks/SiteSearch.pm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/Hooks/SiteSearch.pm Sun Oct 18 01:48:22 2009 +0000
@@ -0,0 +1,36 @@
+#!/usr/bin/perl
+#
+# DW::Hooks::SiteSearch
+#
+# Hooks for Site Search functionality.
+#
+# Authors:
+# Mark Smith <[email protected]>
+#
+# Copyright (c) 2009 by Dreamwidth Studios, LLC.
+#
+# This program is free software; you may redistribute it and/or modify it under
+# the same terms as Perl itself. For a copy of the license, please reference
+# 'perldoc perlartistic' or 'perldoc perlgpl'.
+#
+
+package DW::Hooks::SiteSearch;
+
+use strict;
+
+LJ::register_hook( 'setprop', sub {
+ my %opts = @_;
+ return unless $opts{prop} eq 'opt_blockglobalsearch';
+
+ # ensure we can talk to our system
+ my $dbh = LJ::get_dbh( 'sphinx_search' )
+ or die "Unable to get sphinx_search database handle.\n";
+ $dbh->do( 'UPDATE posts_raw SET allow_global_search = ? WHERE journal_id =
?',
+ undef, $opts{value} eq 'Y' ? 0 : 1, $opts{u}->id );
+ die $dbh->errstr if $dbh->err;
+
+ # looks good
+ return 1;
+} );
+
+1;
diff -r 6c29b8fbc9ab -r 608c256164b7 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm Sat Oct 17 23:53:10 2009 +0000
+++ b/cgi-bin/LJ/User.pm Sun Oct 18 01:48:22 2009 +0000
@@ -6641,8 +6641,9 @@ sub set_userprop
my %multihomed; # { $propid => $value }
foreach $propname (keys %$hash) {
- LJ::run_hook("setprop", prop => $propname,
- u => $u, value => $value);
+ # call all hooks, since we don't look at the return values. we expect
anybody who
+ # uses this hook to do extra work a property needs when it is set.
+ LJ::run_hooks( 'setprop', prop => $propname, u => $u, value => $value
);
my $p = LJ::get_prop("user", $propname) or
die "Invalid userprop $propname passed to LJ::set_userprop.";
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog