Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Slash::Tags::markViewed() and the code to call it

  • Loading branch information...
commit efd257ca0dc72246163a8751e0b1e74330680a66 1 parent 6b6be53
@jamiemccarthy jamiemccarthy authored
View
6 plugins/FireHose/firehose.pl
@@ -96,6 +96,12 @@ sub view {
if ($discussion) {
printComments( $firehose_reader->getDiscussion($discussion) );
}
+
+ my $plugins = $slashdb->getDescriptions('plugins');
+ if (!$user->{is_anon} && $plugins->{Tags}) {
+ my $tagsdb = getObject('Slash::Tags');
+ $tagsdb->markViewed($user->{uid}, $item->{globjid});
+ }
} else {
print getData('notavailable');
}
View
16 plugins/Tags/Tags.pm
@@ -113,6 +113,9 @@ sub createTag {
my $tag = $self->_setuptag($hr);
return 0 if !$tag;
+ # Anonymous users cannot tag.
+ return 0 if isAnon($tag->{uid});
+
# I'm not sure why a duplicate or opposite tag would ever be "OK"
# in the tags table, but for now let's keep our options open in
# case there's some reason we'd want "raw" tag inserting ability.
@@ -140,6 +143,8 @@ sub createTag {
# Because of the uid_globjid_tagnameid_inactivated index,
# this should, I believe, not even touch table data,
# so it should be very fast.
+ # XXX Might want to make it faster by doing this
+ # select before the insert above, esp. with tagViewed().
my $count = $self->sqlCount('tags',
"uid = $tag->{uid}
AND globjid = $tag->{globjid}
@@ -1639,6 +1644,17 @@ sub logSearch {
}
}
+sub markViewed {
+ my($self, $uid, $globjid) = @_;
+ my $constants = getCurrentStatic();
+ $self->createTag({
+ uid => $uid,
+ name => $constants->{tags_viewed_tagname} || 'viewed',
+ globjid => $globjid,
+ private => 1,
+ });
+}
+
#################################################################
sub DESTROY {
my($self) = @_;
View
1  plugins/Tags/mysql_dump.sql
@@ -35,6 +35,7 @@ INSERT INTO vars (name, value, description) VALUES ('tags_tagname_regex', '^\!?[
INSERT INTO vars (name, value, description) VALUES ('tags_upvote_tagname', 'nod', 'Tag for upvote');
INSERT INTO vars (name, value, description) VALUES ('tags_downvote_tagname', 'nix', 'Tag for downvote');
INSERT INTO vars (name, value, description) VALUES ('tags_negative_tagnames', 'nix,dupe,whocares', 'Negative tags (comma separated)');
+INSERT INTO vars (name, value, description) VALUES ('tags_viewed_tagname', 'viewed', 'Tagname to assign to stories and other items a user has viewed');
INSERT INTO ajax_ops VALUES (NULL, 'tags_get_user_story', 'Slash::Tags', 'ajaxGetUserStory', 'ajax_tags_write', 'createuse');
INSERT INTO ajax_ops VALUES (NULL, 'tags_get_user_urls', 'Slash::Tags', 'ajaxGetUserUrls', 'ajax_tags_write', 'createuse');
View
2  sql/mysql/upgrades
@@ -4659,3 +4659,5 @@ INSERT IGNORE INTO vars (name, value, description) VALUES ('tagbox_fhpopularity2
# 2007-07-17
UPDATE vars SET value = 'T_2_5_0_167' WHERE name = 'cvs_tag_currentcode';
+INSERT INTO vars (name, value, description) VALUES ('tags_viewed_tagname', 'viewed', 'Tagname to assign to stories and other items a user has viewed');
+
View
7 themes/slashcode/htdocs/article.pl
@@ -241,6 +241,13 @@ sub main {
print $message;
}
+ my $plugins = $slashdb->getDescriptions('plugins');
+ if (!$user->{is_anon} && $plugins->{Tags}) {
+ my $tagsdb = getObject('Slash::Tags');
+ $tagsdb->markViewed($user->{uid},
+ $reader->getGlobjidCreate('stories', $story->{stoid}));
+ }
+
footer();
if ($story) {
writeLog($story->{sid} || $sid);
Please sign in to comment.
Something went wrong with that request. Please try again.