Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allowing moderators to remove bad tags from the UGC articles

  • Loading branch information...
commit ba72648d6dfb0afbe7e7f265a8c4d8b8dd917de9 1 parent 66c8058
Octavian Costache okvivi authored
BIN  java/lib/boilerpipe-1.2.0.jar
View
Binary file not shown
BIN  java/lib/nekohtml-1.9.13.jar
View
Binary file not shown
BIN  java/lib/xerces-2.9.1.jar
View
Binary file not shown
44 www/hooks/remove_tag_from_article.php
View
@@ -0,0 +1,44 @@
+<?php
+// Certain power users have the possibility to remove people from being
+// associated with news articles, for cases where the associations are simply
+// wrong, which sometimes happens.
+//
+// This file is the hook for the JS call from the website to remove that
+// association.
+
+require_once('../secret/db_user.php');
+require_once('../_top.php');
+
+// Load wp-config so that we can use the fact that the user is logged in.
+require_once('../hp-includes/user_utils.php');
+require_once('../wp-config.php');
+
+
+/**
+ * Remove an association between a person and an article.
+ */
+function deleteTag($articleId, $personId) {
+ $sql = "
+ DELETE FROM news_people
+ WHERE
+ idperson = {$personId} AND
+ idarticle = {$articleId}";
+ mysql_query($sql);
+}
+
+
+// current_user is a variable set by Wordpress.
+$uid = is_user_logged_in() ? $current_user->ID : 0;
+if ($uid == 0) die("You're not logged in");
+if (getUserLevel($uid) == 0) die("Not enough privileges");
+
+// Sanitize the inputs a little bit.
+$articleId = (int)$_GET['article_id'];
+$personId = (int)$_GET['person_id'];
+
+deleteTag($articleId, $personId);
+
+echo "Done";
+
+require_once('../_bottom.php');
+?>
19 www/js/politica.js
View
@@ -136,6 +136,25 @@ hpol.showAllNewsMentions = function(newsId, totalMentions) {
}
};
+/* ------------------------------------------------------ */
+/* Some functions for moderators */
+
+/**
+ * Tries to remove a person tag from a certain article.
+ * @param articleId
+ * @param personId
+ * @param index
+ */
+hpol.removeArticleTag = function(articleId, personId, index) {
+ // Now call the server hook to add the person to the db.
+ var url = '/hooks/remove_tag_from_article.php?' +
+ 'article_id=' + articleId +
+ '&person_id=' + personId;
+
+ sendPayload_(url, function(response) {
+ $('#mention_' + articleId + "_" + index).html(response);
+ });
+};
/* ------------------------------------------------------ */
9 www/pages/misc/community.php
View
@@ -8,6 +8,15 @@
$t = new Smarty();
+// current_user is a variable set by Wordpress.
+$uid = is_user_logged_in() ? $current_user->ID : 0;
+if (getUserLevel($uid) > 0) {
+ $t->assign('is_moderator', true);
+} else {
+ $t->assign('is_moderator', false);
+}
+
+
if (isSet($_GET['id'])) {
$linkId = (int)$_GET['id'];
4 www/templates/news_list_mentions_block.tpl
View
@@ -11,6 +11,10 @@
<a href="?name={$people[x].name}">
{$people[x].display_name}
</a>
+ {if $is_moderator}
+ <span style="margin-left: 5px; cursor:pointer;"
+ onclick="hpol.removeArticleTag({$news_id}, {$people[x].idperson}, {$smarty.section.x.index})">x</span>
+ {/if}
</div>
{if $smarty.section.x.index==5}
3  www/templates/news_list_ugc.tpl
View
@@ -43,7 +43,8 @@
{include file="news_list_mentions_block.tpl"
people=$news[n].people
news_id=$news[n].id
- above_six=$news[n].above_six}
+ above_six=$news[n].above_six
+ is_moderator=$is_moderator}
<div class="ugc_link_status">
{$news[n].human_time_diff} ago
Please sign in to comment.
Something went wrong with that request. Please try again.