Allow OpenID accounts to join communities.
Patch by foxfirefey.
diffs (199 lines):
diff -r dd38e7d6301b -r bce79d7b087a bin/upgrading/en.dat
--- a/bin/upgrading/en.dat Sun Jul 26 19:00:24 2009 +0000
+++ b/bin/upgrading/en.dat Sun Jul 26 19:02:20 2009 +0000
@@ -743,6 +743,8 @@ edges.join.error.targetnotvisible=The co
edges.join.error.targetnotvisible=The community must be visible.
edges.join.error.usernotpersonal=Your account must be a personal account.
+
+edges.join.error.usernotindividual=Your account must be a personal or identity
account.
edges.join.error.usernotvisible=Your account must be visible.
diff -r dd38e7d6301b -r bce79d7b087a cgi-bin/DW/Logic/UserLinkBar.pm
--- a/cgi-bin/DW/Logic/UserLinkBar.pm Sun Jul 26 19:00:24 2009 +0000
+++ b/cgi-bin/DW/Logic/UserLinkBar.pm Sun Jul 26 19:02:20 2009 +0000
@@ -156,12 +156,10 @@ sub manage_membership {
};
# if they're not allowed to join at this moment (many reasons)
- if ($comm_settings[0] eq 'closed' || !$remote ||
$remote->is_identity || !$u->is_visible) {
+ if ($comm_settings[0] eq 'closed' || !$remote || !$u->is_visible) {
$link->{title_ml} = $comm_settings[0] eq 'closed' ?
'userlinkbar.joincomm.title.closed' :
'userlinkbar.joincomm.title.loggedout';
- $link->{title_ml} = 'userlinkbar.joincomm.title.cantjoin'
- if $remote && $remote->is_identity;
$link->{image} = 'community_join_disabled.png';
$link->{class} = "join_disabled";
diff -r dd38e7d6301b -r bce79d7b087a cgi-bin/DW/User/Edges/CommMembership.pm
--- a/cgi-bin/DW/User/Edges/CommMembership.pm Sun Jul 26 19:00:24 2009 +0000
+++ b/cgi-bin/DW/User/Edges/CommMembership.pm Sun Jul 26 19:02:20 2009 +0000
@@ -86,9 +86,9 @@ sub member_of {
$from_u = LJ::want_user( $from_u ) or return 0;
$to_u = LJ::want_user( $to_u ) or return 0;
- # person->comm
+ # individual->comm
return 0
- unless $from_u->is_person &&
+ unless $from_u->is_individual &&
$to_u->is_community;
# check it
@@ -104,7 +104,7 @@ sub member_of_userids {
$u = LJ::want_user( $u ) or return ();
return ()
- unless $u->is_person;
+ unless $u->is_individual;
return @{ LJ::load_rel_target_cache( $u, 'E' ) || [] };
}
@@ -138,9 +138,9 @@ sub can_join {
# if the user is a maintainer, skip every other check
return 1 if $tu && $u->can_manage( $tu );
- # the user must be a personal account
- unless ( $u->is_personal ) {
- $$errref = LJ::Lang::ml( 'edges.join.error.usernotpersonal' );
+ # the user must be a personal account or identity account
+ unless ( $u->is_individual ) {
+ $$errref = LJ::Lang::ml( 'edges.join.error.usernotindividual' );
return 0;
}
diff -r dd38e7d6301b -r bce79d7b087a cgi-bin/communitylib.pl
--- a/cgi-bin/communitylib.pl Sun Jul 26 19:00:24 2009 +0000
+++ b/cgi-bin/communitylib.pl Sun Jul 26 19:02:20 2009 +0000
@@ -293,8 +293,8 @@ sub leave_community {
my $u = LJ::want_user($uuid);
my $cu = LJ::want_user($ucid);
$defriend = $defriend ? 1 : 0;
- return LJ::error('comm_not_found') unless $u && $cu;
- return LJ::error('comm_not_comm') unless $cu->{journaltype} =~ /[CS]/;
+ return LJ::error( 'comm_not_found' ) unless $u && $cu;
+ return LJ::error( 'comm_not_comm' ) unless $cu->is_community;
# remove community membership
return undef
@@ -329,8 +329,8 @@ sub join_community {
my $u = LJ::want_user($uuid);
my $cu = LJ::want_user($ucid);
$watch = $watch ? 1 : 0;
- return LJ::error('comm_not_found') unless $u && $cu;
- return LJ::error('comm_not_comm') unless $cu->{journaltype} eq 'C';
+ return LJ::error( 'comm_not_found' ) unless $u && $cu;
+ return LJ::error( 'comm_not_comm' ) unless $cu->is_community;
# try to join the community, and return if it didn't work
$u->add_edge( $cu, member => {
@@ -340,13 +340,17 @@ sub join_community {
# add edges that effect this relationship... if the user sent a fourth
# argument, use that as a bool. else, load commrow and use the postlevel.
my $addpostacc = 0;
- if (defined $canpost) {
- $addpostacc = $canpost ? 1 : 0;
- } else {
- my $crow = LJ::get_community_row($cu);
- $addpostacc = $crow->{postlevel} eq 'members' ? 1 : 0;
+ # only person users can post
+ if ( $u->is_personal ) {
+ if ( defined $canpost ) {
+ $addpostacc = $canpost ? 1 : 0;
+ } else {
+ my $crow = LJ::get_community_row( $cu );
+ $addpostacc = $crow->{postlevel} eq 'members' ? 1 : 0;
+ }
}
- LJ::set_rel($cu->{userid}, $u->{userid}, 'P') if $addpostacc;
+
+ LJ::set_rel( $cu->{userid}, $u->{userid}, 'P' ) if $addpostacc;
# user should watch comm?
return 1 unless $watch;
diff -r dd38e7d6301b -r bce79d7b087a cgi-bin/weblib.pl
--- a/cgi-bin/weblib.pl Sun Jul 26 19:00:24 2009 +0000
+++ b/cgi-bin/weblib.pl Sun Jul 26 19:02:20 2009 +0000
@@ -2684,13 +2684,8 @@ sub control_strip
if ($haspostingaccess) {
$ret .= "$links{post_to_community} ";
}
- unless ($remote->is_identity) {
- if ($isclosedcommunity) {
- $ret .= "This is a closed community ";
- } else {
- $ret .= "$links{join_community} ";
- }
- }
+ $ret .= $isclosedcommunity ? "This is a closed
community " :
+ "$links{join_community} ";
$ret .= $links{unwatch_community};
$ret .= " " . $links{track_community};
} elsif ($memberof) {
@@ -2705,13 +2700,8 @@ sub control_strip
if ($haspostingaccess) {
$ret .= "$links{post_to_community} ";
}
- unless ($remote->is_identity) {
- if ($isclosedcommunity) {
- $ret .= "This is a closed community ";
- } else {
- $ret .= "$links{join_community} ";
- }
- }
+ $ret .= $isclosedcommunity ? "This is a closed
community " :
+ "$links{join_community} ";
$ret .= $links{watch_community};
$ret .= " " . $links{track_community};
}
diff -r dd38e7d6301b -r bce79d7b087a htdocs/community/join.bml
--- a/htdocs/community/join.bml Sun Jul 26 19:00:24 2009 +0000
+++ b/htdocs/community/join.bml Sun Jul 26 19:02:20 2009 +0000
@@ -19,7 +19,7 @@ body<=
# make sure a community doesn't join a community
return "<?h1 $ML{'Error'} h1?><?p $ML{'.label.commlogged'} p?>"
- unless $remote->{'journaltype'} eq "P";
+ unless $remote->is_individual;
# get info about the community
@@ -29,11 +29,13 @@ body<=
return "<?h1 $ML{'Error'} h1?><?p $ML{'.label.errorcomminfo'} p?>"
unless $cu;
+ # can only join communities, not other journal types
return "<?h1 $ML{'Error'} h1?><?p $ML{'.label.notcomm'} p?>"
- unless $cu->{journaltype} eq "C";
+ unless $cu->is_community;
+ # makes sure this community accepts new members
return "<?h1 $ML{'Error'} h1?><?p $ML{'.label.locked'} p?>"
- if $cu->{statusvis} eq "L";
+ if $cu->is_locked;
# ensure this user isn't banned
return "<?h1 $ML{'Sorry'} h1?><?p $ML{'.label.banned'} p?>"
diff -r dd38e7d6301b -r bce79d7b087a htdocs/js/contextualhover.js
--- a/htdocs/js/contextualhover.js Sun Jul 26 19:00:24 2009 +0000
+++ b/htdocs/js/contextualhover.js Sun Jul 26 19:02:20 2009 +0000
@@ -321,7 +321,7 @@ ContextualPopup.renderPopup = function (
}
// member of community
- if (data.is_logged_in && data.is_comm && !data.self_is_identity) {
+ if (data.is_logged_in && data.is_comm) {
var membership = document.createElement("span");
if (!data.is_closed_membership || data.is_member) {
@@ -463,7 +463,7 @@ ContextualPopup.renderPopup = function (
}
// add a bar between stuff if we have community actions
- if ((data.is_logged_in && data.is_comm && !data.self_is_identity) ||
(message && (trust || watch)))
+ if ((data.is_logged_in && data.is_comm) || (message && (trust ||
watch)))
content.appendChild(document.createElement("br"));
if (trust)
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog