Add list of subscription filters when you subscribe to someone.
Patch by yvi.
diffs (127 lines):
diff -r 0f75400b09e0 -r 8669cb208a92 cgi-bin/DW/User/ContentFilters/Filter.pm
--- a/cgi-bin/DW/User/ContentFilters/Filter.pm Fri Oct 16 20:19:27 2009 +0000
+++ b/cgi-bin/DW/User/ContentFilters/Filter.pm Sat Oct 17 00:24:32 2009 +0000
@@ -123,6 +123,24 @@ sub add_row {
return 1;
}
+# method for deleting a row from the filter. available arguments: userid
+# this method deletes the complete row from the filter
+#
+# $filter->delete_row( userid ) # userid to remove from the filter
+#
+#
+sub delete_row {
+ my ( $self, $userid ) = @_;
+
+ # check if user is already in this content filter
+ return 0 unless $self->contains_userid( $userid );
+
+ # delete row from filter
+ delete( $self->data->{$userid} );
+ $self->_save;
+
+ return 1;
+}
# make sure that our data is loaded up
sub data {
diff -r 0f75400b09e0 -r 8669cb208a92 htdocs/manage/circle/add.bml
--- a/htdocs/manage/circle/add.bml Fri Oct 16 20:19:27 2009 +0000
+++ b/htdocs/manage/circle/add.bml Sat Oct 17 00:24:32 2009 +0000
@@ -83,6 +83,16 @@
bgcolor => $bg,
nonotify => $watched_nonotify ? 1 : 0,
} );
+ # add to content filters
+ my @content_filters = $remote->content_filters;
+ my $filter_id;
+ foreach my $filter ( @content_filters ) {
+ $filter_id = $filter->id;
+ # add to filter if box was checked and user is not already in
filter
+ $filter->add_row( userid => $u->userid ) if
$POST{"content_$filter_id"} && !$filter->contains_userid( $u->userid );
+ # remove from filter if box was not checked and user is in
filter
+ $filter->delete_row( $u->userid ) if
!$POST{"content_$filter_id"} && $filter->contains_userid( $u->userid );
+ }
} else {
$remote->remove_edge( $u, watch => {
nonotify => $watched_nonotify ? 0 : 1,
@@ -185,14 +195,13 @@
}
my @trust_groups = $remote->trust_groups;
+ my @content_filters = $remote->content_filters;
- ## let them pick friend groups
- # FIXME: Add support for reading groups once those exist
+ # let them pick access and content filters to put the user in
my $err;
- if ( $remote->can_trust( $u ) && @trust_groups ) {
-
- ## extra add and cancel buttons
+ if ( $remote->can_trust( $u ) && @trust_groups || $remote->can_watch( $u )
&& @content_filters ) {
+ # extra add and cancel buttons
$body .= "<br /><br />";
if ($u->is_visible) {
my $btn = ( $watched || $trusted ) ? $ML{'.btn.modify'} :
BML::ml( '.btn.add', { user => $u->display_name } );
@@ -207,22 +216,43 @@
document.write(\"<input type='button' value='$cancel_btn'
onclick='history.go(-1); return false;'>\");
\n // -->\n ";
$body .= '</script>';
+ }
+ # trust group buttons
+ if ( $remote->can_trust( $u ) && @trust_groups ) {
+ $body .= "<div style='float: left; width: 49%'>";
$body .= "<?p <br />";
- $body .= "$ML{'.groups.text1'} " . LJ::help_icon('customgroups',
' ') . "p?>\n";
- $body .= "<blockquote>\n";
+ $body .= "$ML{'.groups.text1'} p?>\n";
foreach my $group ( @trust_groups ) {
my $g = $group->{groupnum};
my $ck = ( $remote->trustmask( $u ) & (1 << $g) );
-
$body .= LJ::html_check( { name => "bit_$g",
id => "fg:bit_$g",
selected => $ck,
label => $group->{groupname} } );
$body .= "<br />\n";
}
- $body .= "</blockquote>";
+ $body .= "</div>";
}
+
+ # content filter buttons
+ if ( $remote->can_watch( $u ) && @content_filters ) {
+ $body .= "<div style='float: left; width: 49%'><?p <br />";
+ $body .= "$ML{'.groups.reading'} p?>\n";
+ my @sorted_content_filters = sort { $a->{sortorder} <=>
$b->{sortorder} } @content_filters;
+ foreach my $filter ( @sorted_content_filters ) {
+ my $ck = ( $filter->contains_userid( $u->userid ) );
+ my $fid = $filter->id;
+ $body .= LJ::html_check( { name => "content_$fid",
+ id => "content_$fid",
+ selected => $ck,
+ label => $filter->{name} } );
+ $body .= "<br />\n";
+ }
+ $body .= "</div>";
+ }
+
+ $body .= "<div style='clear: left;'></div>";
## let them pick the colors
my $color_text = "<?p <table><tr><td
valign=\"top\"><i>$ML{'.optional'}:</i> ".
diff -r 0f75400b09e0 -r 8669cb208a92 htdocs/manage/circle/add.bml.text
--- a/htdocs/manage/circle/add.bml.text Fri Oct 16 20:19:27 2009 +0000
+++ b/htdocs/manage/circle/add.bml.text Sat Oct 17 00:24:32 2009 +0000
@@ -86,6 +86,8 @@
.groups.text1=<i>Optional:</i> Include in one or more access filters.
<strong>You must grant access to the user by selecting the first box above in
order to add them to any access filters.</strong>
+.groups.reading=<i>Optional:</i> Include in one or more subscription filters.
<strong>You must subscribe to the user by selecting the second box above in
order to add them to any subscription filters.</strong>
+
.optional=Optional
.remove.header=Success
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog