Committer: janineBug ID: 62369
On entries that are posted to custom friends groups, show (only to the journal owner/poster) a special
custom groups icon and a list of groups that the entry is posted to. Only supported in S2.
U trunk/bin/upgrading/s2layers/core1.s2
U trunk/cgi-bin/LJ/S2/DayPage.pm
U trunk/cgi-bin/LJ/S2/EntryPage.pm
U trunk/cgi-bin/LJ/S2/FriendsPage.pm
U trunk/cgi-bin/LJ/S2/RecentPage.pm
U trunk/cgi-bin/LJ/S2.pm
A trunk/htdocs/img/icon_groups.gif
Modified: trunk/bin/upgrading/s2layers/core1.s2
===================================================================
--- trunk/bin/upgrading/s2layers/core1.s2 2008-02-11 23:25:31 UTC (rev 13545)
+++ trunk/bin/upgrading/s2layers/core1.s2 2008-02-12 00:12:07 UTC (rev 13546)
@@ -1084,6 +1084,11 @@
}
set text_meta_location = "Current Location";
+property string text_meta_groups {
+ des = "Text for 'Custom Friends Groups'";
+}
+set text_meta_groups = "Custom Friends Groups";
+
property string text_post_comment {
des = "Link text to leave a comment";
example = "Leave a comment";
@@ -1542,15 +1547,20 @@
set text_website_default_name = "My Website";
property string text_icon_alt_protected {
- des = "Alternative text for icons of protected entries";
+ des = "Alternative text for icons of friends-only entries";
noui = 1;
}
property string text_icon_alt_private {
- des = "Alternative text for icons of protected entries";
+ des = "Alternative text for icons of private entries";
noui = 1;
}
+property string text_icon_alt_groups {
+ des = "Alternative text for icons of custom friends group entries";
+ noui = 1;
+}
set text_icon_alt_protected = "[protected post]";
set text_icon_alt_private = "[private post]";
+set text_icon_alt_groups = "[custom friends groups post]";
property bool use_shared_pic {
des = "Use community userpics instead of poster's userpic.";
@@ -1846,6 +1856,9 @@
elseif ($which == "location") {
return $*text_meta_location;
}
+ elseif ($which == "groups") {
+ return $*text_meta_groups;
+ }
else {
return $which;
}
Modified: trunk/cgi-bin/LJ/S2/DayPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/DayPage.pm 2008-02-11 23:25:31 UTC (rev 13545)
+++ trunk/cgi-bin/LJ/S2/DayPage.pm 2008-02-12 00:12:07 UTC (rev 13546)
@@ -73,7 +73,7 @@
# load the log items
my $dateformat = "%Y %m %d %H %i %s %w"; # yyyy mm dd hh mm ss day_of_week
- my $sth = $dbcr->prepare("SELECT jitemid AS itemid, posterid, security, " .
+ my $sth = $dbcr->prepare("SELECT jitemid AS itemid, posterid, security, allowmask, " .
"DATE_FORMAT(eventtime, \"$dateformat\") AS 'alldatepart', anum, ".
"DATE_FORMAT(logtime, \"$dateformat\") AS 'system_alldatepart' ".
"FROM log2 " .
@@ -112,8 +112,8 @@
ENTRY:
foreach my $item (@items)
{
- my ($posterid, $itemid, $security, $alldatepart, $anum) =
- map { $item->{$_} } qw(posterid itemid security alldatepart anum);
+ my ($posterid, $itemid, $security, $allowmask, $alldatepart, $anum) =
+ map { $item->{$_} } qw(posterid itemid security allowmask alldatepart anum);
my $replycount = $logprops{$itemid}->{'replycount'};
my $subject = $logtext->{$itemid}->[0];
@@ -198,6 +198,7 @@
'dateparts' => $alldatepart,
'system_dateparts' => $item->{system_alldatepart},
'security' => $security,
+ 'allowmask' => $allowmask,
'props' => $logprops{$itemid},
'itemid' => $ditemid,
'journal' => $userlite_journal,
Modified: trunk/cgi-bin/LJ/S2/EntryPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/EntryPage.pm 2008-02-11 23:25:31 UTC (rev 13545)
+++ trunk/cgi-bin/LJ/S2/EntryPage.pm 2008-02-12 00:12:07 UTC (rev 13546)
@@ -478,6 +478,7 @@
'dateparts' => LJ::alldatepart_s2($entry->eventtime_mysql),
'system_dateparts' => LJ::alldatepart_s2($entry->logtime_mysql),
'security' => $entry->security,
+ 'allowmask' => $entry->allowmask,
'props' => $entry->props,
'itemid' => $ditemid,
'comments' => $comments,
Modified: trunk/cgi-bin/LJ/S2/FriendsPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/FriendsPage.pm 2008-02-11 23:25:31 UTC (rev 13545)
+++ trunk/cgi-bin/LJ/S2/FriendsPage.pm 2008-02-12 00:12:07 UTC (rev 13546)
@@ -181,8 +181,8 @@
ENTRY:
foreach my $item (@items)
{
- my ($friendid, $posterid, $itemid, $security, $alldatepart) =
- map { $item->{$_} } qw(ownerid posterid itemid security alldatepart);
+ my ($friendid, $posterid, $itemid, $security, $allowmask, $alldatepart) =
+ map { $item->{$_} } qw(ownerid posterid itemid security allowmask alldatepart);
my $fr = $friends{$friendid};
$p->{'friends'}->{$fr->{'user'}} ||= Friend($fr);
@@ -305,6 +305,7 @@
'dateparts' => $alldatepart,
'system_dateparts' => $item->{'system_alldatepart'},
'security' => $security,
+ 'allowmask' => $allowmask,
'props' => $logprops{$datakey},
'itemid' => $ditemid,
'journal' => $userlite_journal,
Modified: trunk/cgi-bin/LJ/S2/RecentPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/RecentPage.pm 2008-02-11 23:25:31 UTC (rev 13545)
+++ trunk/cgi-bin/LJ/S2/RecentPage.pm 2008-02-12 00:12:07 UTC (rev 13546)
@@ -133,8 +133,8 @@
ENTRY:
foreach my $item (@items)
{
- my ($posterid, $itemid, $security, $alldatepart) =
- map { $item->{$_} } qw(posterid itemid security alldatepart);
+ my ($posterid, $itemid, $security, $allowmask, $alldatepart) =
+ map { $item->{$_} } qw(posterid itemid security allowmask alldatepart);
my $replycount = $logprops{$itemid}->{'replycount'};
my $subject = $logtext->{$itemid}->[0];
@@ -230,6 +230,7 @@
'dateparts' => $alldatepart,
'system_dateparts' => $item->{system_alldatepart},
'security' => $security,
+ 'allowmask' => $allowmask,
'props' => $logprops{$itemid},
'itemid' => $ditemid,
'journal' => $userlite_journal,
Modified: trunk/cgi-bin/LJ/S2.pm
===================================================================
--- trunk/cgi-bin/LJ/S2.pm 2008-02-11 23:25:31 UTC (rev 13545)
+++ trunk/cgi-bin/LJ/S2.pm 2008-02-12 00:12:07 UTC (rev 13546)
@@ -1825,6 +1825,9 @@
$e->{$_} = $arg->{$_};
}
+ my $remote = LJ::get_remote();
+ my $poster = $e->{poster}->{_u};
+
$e->{'tags'} ||= [];
$e->{'time'} = DateTime_parts($arg->{'dateparts'});
$e->{'system_time'} = DateTime_parts($arg->{'system_dateparts'});
@@ -1844,8 +1847,13 @@
if ($arg->{'security'} eq "public") {
# do nothing.
} elsif ($arg->{'security'} eq "usemask") {
- $e->{'security'} = "protected";
- $e->{'security_icon'} = Image_std("security-protected");
+ if ($arg->{'allowmask'} > 1 && $poster && $poster->equals($remote)) {
+ $e->{'security'} = "custom";
+ $e->{'security_icon'} = Image_std("security-groups");
+ } else {
+ $e->{'security'} = "protected";
+ $e->{'security_icon'} = Image_std("security-protected");
+ }
} elsif ($arg->{'security'} eq "private") {
$e->{'security'} = "private";
$e->{'security_icon'} = Image_std("security-private");
@@ -1877,6 +1885,27 @@
$e->{'metadata'}->{'location'} = $loc->as_html_current if $loc;
}
+ # custom friend groups
+ if ($arg->{allowmask} > 1 && $poster && $poster->equals($remote)) {
+ my $groups = LJ::get_friend_group($poster);
+
+ # if the poster has friend groups, add the ones to which this entry is filtered to the metadata
+ if (keys %$groups) {
+ my @friendgroups = ();
+
+ foreach my $groupid (keys %$groups) {
+ next unless $arg->{allowmask} & 1 << $groupid;
+
+ my $name = LJ::ehtml($groups->{$groupid}->{groupname});
+ my $url = LJ::eurl($poster->journal_base . "/security/group:$name");
+
+ push @friendgroups, "
$name";
+ }
+
+ $e->{metadata}->{groups} = join(', ', @friendgroups);
+ }
+ }
+
# TODO: Populate this field more intelligently later, but for now this will
# hopefully disuade people from hardcoding logic like this into their S2
# layers when they do weird parsing/manipulation of the text member in
@@ -2040,6 +2069,7 @@
$LJ::S2::RES_CACHE = {
'security-protected' => Image("$LJ::IMGPREFIX/icon_protected.gif", 14, 15, $ctx->[S2::PROPS]->{'text_icon_alt_protected'}),
'security-private' => Image("$LJ::IMGPREFIX/icon_private.gif", 16, 16, $ctx->[S2::PROPS]->{'text_icon_alt_private'}),
+ 'security-groups' => Image("$LJ::IMGPREFIX/icon_groups.gif", 19, 16, $ctx->[S2::PROPS]->{'text_icon_alt_groups'}),
};
}
return $LJ::S2::RES_CACHE->{$name};
Added: trunk/htdocs/img/icon_groups.gif
===================================================================
(Binary files differ)
Property changes on: trunk/htdocs/img/icon_groups.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream