[dw-free] Allow community posting guidelines to be in the profile
[commit: http://hg.dwscoalition.org/dw-free/rev/2887bcdd4c14]
http://bugs.dwscoalition.org/show_bug.cgi?id=2154
Let the administrator choose whether the community posting guidelines are in
the profile, or whether they're in an entry, and show in the appropriate
places.
Patch by
purplecat.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=2154
Let the administrator choose whether the community posting guidelines are in
the profile, or whether they're in an entry, and show in the appropriate
places.
Patch by
Files modified:
- bin/upgrading/proplists.dat
- cgi-bin/LJ/Global/Defaults.pm
- cgi-bin/LJ/User.pm
- htdocs/community/join.bml
- htdocs/community/settings.bml
- htdocs/community/settings.bml.text
- htdocs/manage/circle/add.bml
--------------------------------------------------------------------------------
diff -r 58805386121f -r 2887bcdd4c14 bin/upgrading/proplists.dat
--- a/bin/upgrading/proplists.dat Mon Apr 16 17:46:10 2012 +0800
+++ b/bin/upgrading/proplists.dat Mon Apr 16 18:56:41 2012 +0800
@@ -1046,6 +1046,14 @@
multihomed: 0
prettyname: Community posting guidelines entry ID
+userproplist.posting_guidelines_location:
+ cldversion: 4
+ datatype: char
+ des: Where are the community posting guidelines? Blank=Nowhere, P=Profile, E=Entry
+ indexed: 0
+ multihomed: 0
+ prettyname: Where are the community posting guidelines?
+
userproplist.profile_collapsed_headers:
cldversion: 4
datatype: char
diff -r 58805386121f -r 2887bcdd4c14 cgi-bin/LJ/Global/Defaults.pm
--- a/cgi-bin/LJ/Global/Defaults.pm Mon Apr 16 17:46:10 2012 +0800
+++ b/cgi-bin/LJ/Global/Defaults.pm Mon Apr 16 18:56:41 2012 +0800
@@ -366,6 +366,9 @@
) unless defined %CAPTCHA_TYPES;
$DEFAULT_CAPTCHA_TYPE ||= "T";
+ # default location of community posting guidelines
+ $DEFAULT_POSTING_GUIDELINES_LOC ||= "N";
+
}
diff -r 58805386121f -r 2887bcdd4c14 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm Mon Apr 16 17:46:10 2012 +0800
+++ b/cgi-bin/LJ/User.pm Mon Apr 16 18:56:41 2012 +0800
@@ -2797,13 +2797,36 @@
return "" unless $u->is_community;
my $posting_guidelines = $u->posting_guidelines_entry;
+ if ( $u->posting_guidelines_location eq "P" ) {
+ return $u->profile_url;
+ } elsif ( $u->posting_guidelines_location eq "N") {
+ return "";
+ }
+
return "" unless $posting_guidelines;
return $u->journal_base . "/guidelines";
}
+# Where are a community's posting guidelines held? Blank=Nowhere, P=Profile, E=Entry
+sub posting_guidelines_location {
+ my ( $u, $value ) = @_;
+ if ( defined $value && $value=~ /[PE]/ ) {
+ $u->set_prop( posting_guidelines_location => $value );
+ return $value;
+ }
+ # We store the "N=Nowhere" option in the database as a blank empty entry to
+ # reduce space. N should be returned whenever a blank entry is encountered.
+ if ( defined $value && $value eq 'N' ) {
+ $u->set_prop( posting_guidelines_location => '' );
+ return $value;
+ }
+ $u->prop( 'posting_guidelines_location' ) || $LJ::DEFAULT_POSTING_GUIDELINES_LOC;
+}
+
+
sub profile_url {
- my ($u, %opts) = @_;
+ my ( $u, %opts ) = @_;
my $url;
if ( $u->is_identity ) {
@@ -4320,7 +4343,6 @@
return sort { $a->{user} cmp $b->{user} } @res;
}
-
# gets the relevant communities that the user is a member of
# used to suggest communities to a person who know the user
sub relevant_communities {
@@ -4428,7 +4450,6 @@
return $u->trusts( $target_u ) ? 1 : 0;
}
-
########################################################################
### 14. Adult Content Functions
diff -r 58805386121f -r 2887bcdd4c14 htdocs/community/join.bml
--- a/htdocs/community/join.bml Mon Apr 16 17:46:10 2012 +0800
+++ b/htdocs/community/join.bml Mon Apr 16 18:56:41 2012 +0800
@@ -135,7 +135,13 @@
my $post_url;
$post_url = $LJ::SITEROOT . "/update?usejournal=" . $cu->user
if $show_join_post_link && $remote->can_post_to( $cu );
- my $posting_guidelines_entry_url = $cu->posting_guidelines_url;
+ my $posting_guidelines_entry_url;
+ if ( $cu->posting_guidelines_location eq "E" ) {
+ $posting_guidelines_entry_url = $cu->posting_guidelines_url;
+ }
+ if ( $cu->posting_guidelines_location eq "P" ) {
+ $posting_guidelines_entry_url = $cu->profile_url;
+ }
$ret .= "<?h1 $ML{'.success'} h1?><?p " . BML::ml('.label.membernow6',
{ 'commname' => LJ::ljuser($cu) }) . " p?>";
diff -r 58805386121f -r 2887bcdd4c14 htdocs/community/settings.bml
--- a/htdocs/community/settings.bml Mon Apr 16 17:46:10 2012 +0800
+++ b/htdocs/community/settings.bml Mon Apr 16 18:56:41 2012 +0800
@@ -32,6 +32,7 @@
#left-column, #right-column { float: left; }
legend { font-size: 1.2em; font-weight: bold; }
p.input-wrapper { margin-left: 27px; text-indent: -27px; }
+ p.nested-input-wrapper { margin-left: 54px; text-indent: -27px; }
.action-box { clear: both; }
</style>
<=head
@@ -105,9 +106,13 @@
$errors{'username'} = $ML{'.error.alreadycomm'};
}
- # check the posting guidelines entry is valid
- $errors{'postingguidelinesentry'} = $ML{'.error.postingguidelinesentryinvalid'}
- unless $cu->posting_guidelines_entry( $POST{'postingguidelinesentry'} );
+ # check the posting guidelines entry is valid,
+ # but only check if entry is selected.
+ my $postingguidelines_loc = $cu->posting_guidelines_location( $POST{'postingguidelines'} );
+ if ( $postingguidelines_loc eq "E" ) {
+ $errors{'postingguidelinesentry'} = $ML{'.error.postingguidelinesentryinvalid'}
+ unless $cu->posting_guidelines_entry( $POST{'postingguidelinesentry'} );
+ }
# if we found errors, we'll redisplay the form below. otherwise,
# proceed.
@@ -163,7 +168,9 @@
$cu->set_prop( { nonmember_posting => $nonmember_posting,
moderated => $moderated } );
$cu->hide_join_post_link( $hidejoinpostlink );
- $cu->posting_guidelines_entry( $POST{'postingguidelinesentry'} );
+ if ( $postingguidelines_loc eq "E" ) {
+ $cu->posting_guidelines_entry( $POST{'postingguidelinesentry'} );
+ }
if ( LJ::is_enabled( 'adult_content' ) ) {
my $adult_content = $POST{'adult_content'};
@@ -215,6 +222,7 @@
'moderated'=>$POST{'moderated'} || 0,
'hide_join_post_link'=>$POST{'showjoinpostlink'} ? 0 : 1,
'posting_guidelines_entry'=>$POST{'postingguidelinesentry'} || '',
+ 'posting_guidelines_location'=>$POST{'postingguidelines'} || $LJ::DEFAULT_POSTING_GUIDELINES_LOC,
);
if ($mode eq 'modify') {
@@ -244,6 +252,7 @@
$info{'nonmember_posting'} = $c->{'nonmember_posting'} ? 1 : 0;
$info{'moderated'} = $c->{'moderated'} ? 1 : 0;
$info{'hide_join_post_link'} = $c->{'hide_join_post_link'} ? 1 : 0;
+ $info{'posting_guidelines_location'} = $c->posting_guidelines_location;
my $e = $c->get_posting_guidelines_entry;
$info{'posting_guidelines_entry'} = $e->url
if $e;
@@ -368,7 +377,31 @@
} );
$ret .= " <label for='showjoinpostlink'>$ML{'.label.showjoinpostlink'}</label></p>";
+ my $postingguidelines = $info{'posting_guidelines_location'};
+ $ret .= "<?p $ML{'.label.showwhatguidelines'} p?>";
$ret .= "<p class='input-wrapper'>";
+ $ret .= LJ::html_check({
+ type => 'radio', id => 'nopostingguidelines', name => 'postingguidelines',
+ value => 'N', selected => $postingguidelines eq "N" ? 1 : 0,
+ });
+ $ret .= " <label for='nopostingguidelines'>$ML{'.label.nopostingguidelines'}</label></p>";
+
+ $ret .= "<p class='input-wrapper'>";
+ $ret .= LJ::html_check({
+ type => 'radio', id => 'profilepostingguidelines', name => 'postingguidelines',
+ value => 'P', selected => $postingguidelines eq "P" ? 1 : 0,
+ });
+ $ret .= " <label for='postmembers'>$ML{'.label.profilepostingguidelines'}</label></p>";
+
+ $ret .= "<p class='input-wrapper'>";
+ $ret .= LJ::html_check({
+ type => 'radio', id => 'entrypostingguidelines', name => 'postingguidelines',
+ value => 'E', selected => $postingguidelines eq "E" ? 1 : 0,
+ });
+
+ $ret .= " <label for='postselect'>$ML{'.label.entrypostingguidelines'}</label></p>";
+
+ $ret .= "<p class='nested-input-wrapper'>";
$ret .= " <label for='postingguidelinesentry'>$ML{'.label.postingguidelinesentry'}</label> ";
$ret .= LJ::html_text( {
id => 'postingguidelinesentry', name => 'postingguidelinesentry', value => $info{'posting_guidelines_entry'}
diff -r 58805386121f -r 2887bcdd4c14 htdocs/community/settings.bml.text
--- a/htdocs/community/settings.bml.text Mon Apr 16 17:46:10 2012 +0800
+++ b/htdocs/community/settings.bml.text Mon Apr 16 18:56:41 2012 +0800
@@ -57,6 +57,8 @@
.label.community=Community:
+.label.entrypostingguidelines=<strong>In an entry:</strong><br />The community posting guidelines can be found in an entry (details below).
+
.label.guidelines=<a [[aopts]]>Community guidelines</a> - consistent link to your community guidelines entry
.label.howoperates=Choose the settings for your community journal. You can make changes to these settings at any time you want.
@@ -89,12 +91,18 @@
.label.postingaccessselect=<STRONG>Select Members</STRONG><br />Members' entries will only appear in the community if they're approved by the administrator or moderator.
-.label.postingguidelinesentry=URL or ID of your community's posting guidelines entry (leave blank if you don't want to link to an entry):
+.label.postingguidelinesentry=URL or ID of your community's posting guidelines entry (if used):
+
+.label.profilepostingguidelines=<strong>Community Profile</strong><br />The community profile contains the posting guidelines.
+
+.label.nopostingguidelines=<strong>Nowhere</strong><br />There should be no link to community posting guidelines.
.label.rellinks=Relevant links:
.label.showjoinpostlink=Post to community
+.label.showwhatguidelines=Where are the community posting guidelines?
+
.label.showwhatlinks=What links should be displayed to users when they join your community?
.label.successpagedisplay=Join Links
diff -r 58805386121f -r 2887bcdd4c14 htdocs/manage/circle/add.bml
--- a/htdocs/manage/circle/add.bml Mon Apr 16 17:46:10 2012 +0800
+++ b/htdocs/manage/circle/add.bml Mon Apr 16 18:56:41 2012 +0800
@@ -124,7 +124,12 @@
my $posting_guidelines_entry_url;
my $post_url;
if ( $u->is_community ) {
- $posting_guidelines_entry_url = $u->posting_guidelines_url;
+ if ( $u->posting_guidelines_location eq "E" ) {
+ $posting_guidelines_entry_url = $u->posting_guidelines_url;
+ }
+ if ( $u->posting_guidelines_location eq "P" ) {
+ $posting_guidelines_entry_url = $u->profile_url;
+ }
my $show_join_post_link = $u->hide_join_post_link ? 0 : 1;
$post_url = $LJ::SITEROOT . "/update?usejournal=" . $u->user
if $show_join_post_link && $remote->can_post_to( $u );
--------------------------------------------------------------------------------
