rework spamblock action buttons

anchor workaround and restored event order, should fix 
This commit is contained in:
onli 2013-07-21 01:00:15 +02:00
parent fac1558de3
commit b2bcd08c99
4 changed files with 24 additions and 10 deletions
include/admin
plugins/serendipity_event_spamblock
templates/2k11/admin

@ -278,6 +278,12 @@ $sql = serendipity_db_query("SELECT c.*, e.title FROM {$serendipity['dbPrefix']}
WHERE 1 = 1 " . ($c_type !== null ? " AND c.type = '$c_type' " : '') . $and
. (!serendipity_checkPermission('adminEntriesMaintainOthers') ? 'AND e.authorid = ' . (int)$serendipity['authorid'] : '') . "
ORDER BY c.id DESC $limit");
ob_start();
# This event has to get send here so the spamblock-plugin can block an author now and the comment_page show that on this pageload
serendipity_plugin_api::hook_event('backend_comments_top', $sql);
$data['backend_comments_top'] = ob_get_contents();
ob_end_clean();
$data['commentsPerPage'] = $commentsPerPage;
$data['totalComments'] = $totalComments;

@ -1397,26 +1397,27 @@ var $filter_defaults;
case 'backend_view_comment':
$author_is_filtered = $this->checkFilter('authors', $eventData['author']);
$clink1 = 'clink1' . $eventData['id'];
$clink2 = 'clink2' . $eventData['id'];
$clink = 'comment_' . $eventData['id'];
$randomString = '&random=' . substr(sha1(rand()), 0, 10); # the random string will force browser to reload the page,
# so the server knows who to block/unblock when clicking again on the same link,
# see http://stackoverflow.com/a/2573986/2508518, http://stackoverflow.com/a/14043346/2508518
$akismet_apikey = $this->get_config('akismet');
$akismet = $this->get_config('akismet_filter');
if (!empty($akismet_apikey)) {
$eventData['action_more'] .= ' <a id="' . $clink1 . '" class="icon_link" title="' . PLUGIN_EVENT_SPAMBLOCK_SPAM . '" href="serendipity_admin.php?serendipity[adminModule]=comments&amp;serendipity[spamIsSpam]=' . $eventData['id'] . $addData . '#' . $clink1 . '"><span class="icon-lock"></span> ' . PLUGIN_EVENT_SPAMBLOCK_SPAM . '</a>';
$eventData['action_more'] .= ' <a id="' . $clink1 . '" class="icon_link" title="' . PLUGIN_EVENT_SPAMBLOCK_NOT_SPAM . '" href="serendipity_admin.php?serendipity[adminModule]=comments&amp;serendipity[spamNotSpam]=' . $eventData['id'] . $addData . '#' . $clink1 . '"><span class="icon-lock-open"></span> ' . PLUGIN_EVENT_SPAMBLOCK_NOT_SPAM . '</a>';
$eventData['action_more'] .= ' <a class="icon_link" title="' . PLUGIN_EVENT_SPAMBLOCK_SPAM . '" href="serendipity_admin.php?serendipity[adminModule]=comments&amp;serendipity[spamIsSpam]=' . $eventData['id'] . $addData . '#' . $clink . '"><span class="icon-lock"></span> ' . PLUGIN_EVENT_SPAMBLOCK_SPAM . '</a>';
$eventData['action_more'] .= ' <a" class="icon_link" title="' . PLUGIN_EVENT_SPAMBLOCK_NOT_SPAM . '" href="serendipity_admin.php?serendipity[adminModule]=comments&amp;serendipity[spamNotSpam]=' . $eventData['id'] . $addData . '#' . $clink . '"><span class="icon-lock-open"></span> ' . PLUGIN_EVENT_SPAMBLOCK_NOT_SPAM . '</a>';
}
$eventData['action_author'] .= ' <a id="' . $clink1 . '" class="icon_link" title="' . ($author_is_filtered ? PLUGIN_EVENT_SPAMBLOCK_REMOVE_AUTHOR : PLUGIN_EVENT_SPAMBLOCK_ADD_AUTHOR) . '" href="serendipity_admin.php?serendipity[adminModule]=comments&amp;serendipity[spamBlockAuthor]=' . $eventData['id'] . $addData . '#' . $clink1 . '"><span class="icon-lock' . ($author_is_filtered ? '-open' : '') .'"></span><span class="visuallyhidden"> ' . ($author_is_filtered ? PLUGIN_EVENT_SPAMBLOCK_REMOVE_AUTHOR : PLUGIN_EVENT_SPAMBLOCK_ADD_AUTHOR) . '</span></a>';
$eventData['action_author'] .= ' <a class="icon_link" title="' . ($author_is_filtered ? PLUGIN_EVENT_SPAMBLOCK_REMOVE_AUTHOR : PLUGIN_EVENT_SPAMBLOCK_ADD_AUTHOR) . '" href="serendipity_admin.php?serendipity[adminModule]=comments&amp;serendipity[spamBlockAuthor]=' . $eventData['id'] . $addData . $randomString . '#' . $clink . '"><span class="icon-lock' . ($author_is_filtered ? '-open' : '') .'"></span><span class="visuallyhidden"> ' . ($author_is_filtered ? PLUGIN_EVENT_SPAMBLOCK_REMOVE_AUTHOR : PLUGIN_EVENT_SPAMBLOCK_ADD_AUTHOR) . '</span></a>';
if (!empty($eventData['url'])) {
$url_is_filtered = $this->checkFilter('urls', $eventData['url']);
$eventData['action_url'] .= ' <a id="' . $clink2 . '" class="icon_link" title="' . ($url_is_filtered ? PLUGIN_EVENT_SPAMBLOCK_REMOVE_URL : PLUGIN_EVENT_SPAMBLOCK_ADD_URL) . '" href="serendipity_admin.php?serendipity[adminModule]=comments&amp;serendipity[spamBlockURL]=' . $eventData['id'] . $addData . '#' . $clink2 . '"><span class="icon-lock' . ($url_is_filtered ? '-open' : '') .'"></span><span class="visuallyhidden"> ' . ($url_is_filtered ? PLUGIN_EVENT_SPAMBLOCK_REMOVE_URL : PLUGIN_EVENT_SPAMBLOCK_ADD_URL) . '</span></a>';
$eventData['action_url'] .= ' <a class="icon_link" title="' . ($url_is_filtered ? PLUGIN_EVENT_SPAMBLOCK_REMOVE_URL : PLUGIN_EVENT_SPAMBLOCK_ADD_URL) . '" href="serendipity_admin.php?serendipity[adminModule]=comments&amp;serendipity[spamBlockURL]=' . $eventData['id'] . $addData . $randomString . '#' . $clink . '"><span class="icon-lock' . ($url_is_filtered ? '-open' : '') .'"></span><span class="visuallyhidden"> ' . ($url_is_filtered ? PLUGIN_EVENT_SPAMBLOCK_REMOVE_URL : PLUGIN_EVENT_SPAMBLOCK_ADD_URL) . '</span></a>';
}
if (!empty($eventData['email'])) {
$email_is_filtered = $this->checkFilter('emails', $eventData['email']);
$eventData['action_email'] .= ' <a id="' . $clink2 . '" class="icon_link" title="' . ($email_is_filtered ? PLUGIN_EVENT_SPAMBLOCK_REMOVE_EMAIL : PLUGIN_EVENT_SPAMBLOCK_ADD_EMAIL) . '" href="serendipity_admin.php?serendipity[adminModule]=comments&amp;serendipity[spamBlockEmail]=' . $eventData['id'] . $addData . '#' . $clink2 . '"><span class="icon-lock' . ($email_is_filtered ? '-open' : '') .'"></span><span class="visuallyhidden"> ' . ($email_is_filtered ? PLUGIN_EVENT_SPAMBLOCK_REMOVE_EMAIL : PLUGIN_EVENT_SPAMBLOCK_ADD_EMAIL) . '</span></a>';
$eventData['action_email'] .= ' <a class="icon_link" title="' . ($email_is_filtered ? PLUGIN_EVENT_SPAMBLOCK_REMOVE_EMAIL : PLUGIN_EVENT_SPAMBLOCK_ADD_EMAIL) . '" href="serendipity_admin.php?serendipity[adminModule]=comments&amp;serendipity[spamBlockEmail]=' . $eventData['id'] . $addData . $randomString . '#' . $clink . '"><span class="icon-lock' . ($email_is_filtered ? '-open' : '') .'"></span><span class="visuallyhidden"> ' . ($email_is_filtered ? PLUGIN_EVENT_SPAMBLOCK_REMOVE_EMAIL : PLUGIN_EVENT_SPAMBLOCK_ADD_EMAIL) . '</span></a>';
}
return true;

@ -14,7 +14,7 @@
<ul class="filters_toolbar plainList">
<li><a class="button_link" href="#filter_comments" title="Show filters"><span class="icon-filter"></span><span class="visuallyhidden"> Show filters</span></a></li> {* i18n *}
<li><div class="backend_comments">{serendipity_hookPlugin hookAll=true hook="backend_comments_top" addData=$sql}</div></li> {* Does this ever emit anything but the 'Configure Anti-Spam' stuff? *}
<li><div class="backend_comments">{$backend_comments_top}</div></li>
</ul>
<fieldset id="filter_comments" class="additional_info">

@ -1000,12 +1000,17 @@ var AccessifyHTML5 = function (defaults, more_fixes) {
$('.comments_pane .pagination').clone().prependTo('.comments_pane');
$('.entries_pane .pagination').clone().prependTo('.entries_pane');
// close comment reply on button click
if ($('body').has('#comment_replied').size() > 0) {
$('#comment_replied').click(function() {
serendipity.closeCommentPopup();
});
}
// reopen detail element after spamblock action
if ($('body').has('#serendipity_comments_list').size() > 0 && window.location.hash && $('body').has('#' + window.location.hash.replace('#', '')).size() > 0) {
$('#' + window.location.hash.replace('#', '')).find(".toggle_info").click();
}
// Equal Heights
$(window).load(function() {
@ -1016,3 +1021,5 @@ var AccessifyHTML5 = function (defaults, more_fixes) {
}
});
})(jQuery);