Users can ignore each others' post now

This commit is contained in:
Aleksei Miheev
2012-01-29 22:01:07 +04:00
parent 9c97a2292a
commit a4b0e19b47
4 changed files with 105 additions and 25 deletions

View File

@@ -63,7 +63,7 @@ if (!defined('SMF'))
// The central part of the board - topic display.
function Display()
{
global $scripturl, $txt, $db_prefix, $modSettings, $context, $settings, $options, $sourcedir;
global $scripturl, $txt, $db_prefix, $modSettings, $context, $settings, $options, $sourcedir, $mongodb;
global $user_info, $ID_MEMBER, $board_info, $topic, $board, $attachments, $messages_request;
// What are you gonna display if these are empty?!
@@ -76,6 +76,9 @@ function Display()
else
loadTemplate('Display');
$ignores = $mongodb->rock->ignorelists->findOne(array('user' => (int) $ID_MEMBER), array ("ignores" => 1));
$ignores == NULL ? $context['ignore_list'] = array() : $context['ignore_list'] = $ignores['ignores'];
// Find the previous or next topic. Make a fuss if there are no more.
if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next'))
{

49
Sources/Ignore.php Normal file
View File

@@ -0,0 +1,49 @@
<?php
/******************************************************************************
* Ignore.php *
******************************************************************************/
if (!defined('SMF'))
die('Hacking attempt...');
function ignore()
{
global $topic, $txt, $db_prefix, $context, $scripturl, $sourcedir, $ID_MEMBER, $mongodb;
// We need at least a topic... go away if you don't have one.
if (empty($topic))
fatal_lang_error(472, false);
foreach (array('member', 'msg') as $var) isset($_GET[$var]) ? $_GET[$var] = (int) $_GET[$var] : $_GET[$var] = 0;
$ignoree_id = $_GET['member'];
$msg = $_GET['msg'];
if ($ID_MEMBER > 0 && $ignoree_id > 0)
$mongodb->rock->ignorelists->update(
array ('user' => (int) $ID_MEMBER),
array ('$addToSet' => array ('ignores' => $ignoree_id)),
array ('upsert' => true));
// Back to the topic!
redirectexit('topic=' . $topic . '.msg'.$msg."#msg".$msg);
}
function unignore()
{
global $topic, $txt, $db_prefix, $context, $scripturl, $sourcedir, $ID_MEMBER, $mongodb;
// We need at least a topic... go away if you don't have one.
if (empty($topic))
fatal_lang_error(472, false);
foreach (array('member', 'msg') as $var) isset($_GET[$var]) ? $_GET[$var] = (int) $_GET[$var] : $_GET[$var] = 0;
$ignoree_id = $_GET['member'];
$msg = $_GET['msg'];
if ($ID_MEMBER > 0 && $ignoree_id > 0)
$mongodb->rock->ignorelists->update(
array ('user' => (int) $ID_MEMBER),
array ('$pull' => array ('ignores' => $ignoree_id)));
// Back to the topic!
redirectexit('topic=' . $topic . '.msg'.$msg."#msg".$msg);
}

View File

@@ -6,7 +6,7 @@ function template_main()
// banner count
$banner_count = 0;
global $context, $settings, $options, $txt, $scripturl, $modSettings;
global $ID_MEMBER, $context, $settings, $options, $txt, $scripturl, $modSettings;
// Show the anchor for the top and for the first message. If the first message is new, say so.
echo '
@@ -214,7 +214,25 @@ function template_main()
// Get all the messages...
while ($message = $context['get_message']())
{
{
#if ($ID_MEMBER == 6190) {var_dump ($message['member']);}
# Skip ignored messages
$ignore = false;
if (
$message['member']['group'] != 'Moderator' &&
$message['member']['group'] != 'Модератор' &&
$ID_MEMBER != $message['member']['id'] &&
'6190' != $message['member']['id'] &&
in_array ($message['member']['id'], $context['ignore_list']) &&
! isset($_GET['noignore'])
) {
$ignore = true;
$message['member']['name'] = 'XXXXXXXXX';
$message['body'] = "Сообщение скрыто, потому что вы игнорируете этого пользователя<br />";
$url = str_replace('#', ';noignore#', $message['href']);
$message['body'] .= '<a href="'.$url.'">Показать скрытые сообщения</a>';
}
echo '
<tr><td style="padding: 1px 1px 0 1px;">';
@@ -236,10 +254,10 @@ function template_main()
# echo '
# <td valign="top" width="16%" rowspan="2" style="overflow: hidden; border-right: solid 1px #000000;">';
// Show the member's gender icon?
if (!empty($settings['show_gender']) && $message['member']['gender']['image'] != '')
if (! $ignore && !empty($settings['show_gender']) && $message['member']['gender']['image'] != '')
echo '
',$message['member']['gender']['image'];
if (empty($context['user']['is_guest'])) {
if (! $ignore && empty($context['user']['is_guest'])) {
$_special_color="";
if(isset($message['member']['group']) && $message['member']['group'] != '' && isset($message['member']['group_color']))
$_special_color='style="color: '.$message['member']['group_color'].';"';
@@ -254,18 +272,18 @@ function template_main()
<div class="smalltext">';
// Show the member's custom title, if they have one.
if (isset($message['member']['title']) && $message['member']['title'] != '')
if (! $ignore && isset($message['member']['title']) && $message['member']['title'] != '')
echo '
', $message['member']['title'], '<br />';
// Show the member's primary group (like 'Administrator') if they have one.
if (isset($message['member']['group']) && $message['member']['group'] != '')
if (! $ignore && isset($message['member']['group']) && $message['member']['group'] != '')
echo '
', $message['member']['group'];
echo '<br />';
// Don't show these things for guests.
if (!$message['member']['is_guest'] /*&& !$context['user']['is_guest']*/)
if (! $ignore && !$message['member']['is_guest'] /*&& !$context['user']['is_guest']*/)
{
// Show the post group if and only if they have no other group or the option is on, and they are in a post group.
/* if ((empty($settings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '')
@@ -369,13 +387,13 @@ function template_main()
</td>
<td valign="top" width="85%" height="100%">
<table width="100%" border="0"><tr>
<td align="left" valign="middle"><a href="', $message['href'], '" title="Ссылка на это сообщение"><img src="', $settings['images_url'], '/' , $context['user']['language'] , '/link.png" alt="', $message['subject'], '" border="0" /></a>';/*<td>-->
<td align="left" valign="middle"><a class="karma" href="', $message['href'], '" title="Ссылка на это сообщение"><img style="vertical-align: middle;" src="', $settings['images_url'], '/' , $context['user']['language'] , '/link.png" alt="', $message['subject'], '" border="0" />', !($message['id'] == $context['topic_first_message']) ? ' #'.$message['counter'] : '','</a>';/*<td>-->
<td align="left" valign="middle">';
<b><a href="', $message['href'], '" class="nav">', $message['subject'], '</a></b>';*/
// If this is the first post, (#0) just say when it was posted - otherwise give the reply #.
echo '
<span class="smalltext">'/*, !($message['id'] == $context['topic_first_message']) ? $txt['post_no']. $message['counter'] : '', ' ', $txt[30], ': '*/, $message['time'], '</span>';
<span class="smalltext">', /*!($message['id'] == $context['topic_first_message']) ? '#'.$message['counter'] : '', ' ',*/ $message['time'], '</span>';
if ($message['id']==$context['topic_first_message']) {
echo '<script type="text/javascript" src="//yandex.st/share/share.js" charset="utf-8"></script><div class="yashare-auto-init" data-yashareL10n="ru" data-yashareType="button" data-yashareQuickServices="yaru,vkontakte,facebook,twitter,odnoklassniki,moimir,lj"></div>';
@@ -384,12 +402,20 @@ function template_main()
</td>
<td class="buttons" align="right" valign="bottom" height="20" nowrap="nowrap" style="font-size: smaller;">';
if (! $ignore)
echo '
<a title="Игнорировать" href="', $scripturl, '?action=ignore;member=', $message['member']['id'] , ';msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/ignore.png" alt="Игнорировать" border="0" /></a>';
else
echo '
<a title="Перестать игнорировать" href="', $scripturl, '?action=unignore;member=', $message['member']['id'] , ';msg=', $message['id'], ';topic=', $context['current_topic'], '"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/ignore.png" alt="Перестать игнорировать" border="0" /></a>';
// So... quick reply is off, but they *can* reply?
// Can they reply? Have they turned on quick reply?
if ($context['can_reply'] && !empty($options['display_quick_reply']))
if (! $ignore && $context['can_reply'] && !empty($options['display_quick_reply']))
echo '
<a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';num_replies=', $context['num_replies'], ';sesc=', $context['session_id'], '" onclick="if (!currentSwap) doQuote(', $message['id'], '); else window.location.href = this.href; return false;" title="' . $txt[145] . '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/quote.png" alt="' . $txt[145] . '" border="0" />' : $txt[145]), '</a>';
// So... quick reply is off, but they *can* reply?
elseif ($context['can_reply'])
elseif (! $ignore && $context['can_reply'])
echo '
<a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';num_replies=', $context['num_replies'], ';sesc=', $context['session_id'], '" title="' . $txt[145] . '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/quote.png" alt="' . $txt[145] . '" border="0" />' : $txt[145]), '</a>';
@@ -434,9 +460,6 @@ function template_main()
echo '<br /><br />', $nowplayingstring, '&nbsp;<b>', $message['nowplaying'], '</b>';
}*/
echo '</div>';
if ( 0 AND $message['id']==$context['topic_first_message']) {
echo '<script type="text/javascript" src="//yandex.st/share/share.js" charset="utf-8"></script><div class="yashare-auto-init" data-yashareL10n="ru" data-yashareType="button" data-yashareQuickServices="yaru,vkontakte,facebook,twitter,odnoklassniki,moimir,lj"></div>';
}
echo '
</td>
</tr>';
@@ -449,7 +472,7 @@ function template_main()
<td align="left" colspan="2" class="smalltext" width="100%">';
// Assuming there are attachments...
if (!empty($message['attachment']))
if (! $ignore && !empty($message['attachment']))
{
echo '
<hr width="100%" size="1" class="hrcolor" />
@@ -478,10 +501,12 @@ function template_main()
// Show "? Last Edit: Time by Person ?" if this post was edited.
// Going to add edit history link here. This comment is just a
// marker. Also I'm learning to work with branches
if ($settings['show_modify'] && !empty($message['modified']['name']))
if (! $ignore && $settings['show_modify'] && !empty($message['modified']['name']))
echo '
&#171; <i>', $txt[211], ': ', $message['modified']['time'], ' ', $txt[525], ' ', $message['modified']['name'], '</i> &#187;';
if($modSettings['nowplayingEnabled'] && $message['nowplaying'] != '' && !$context['user']['is_guest'])
// Show Now Playing if available
if(! $ignore && $modSettings['nowplayingEnabled'] && $message['nowplaying'] != '' && !$context['user']['is_guest'])
{
if(isset($modSettings['nowplaying_image']) && $modSettings['nowplaying_image'] != '')
$nowplayingstring = '<img src="'. $settings['images_url'] . '/'. $modSettings['nowplaying_image'] . '" alt="" border="0" />';
@@ -495,7 +520,8 @@ function template_main()
echo '
</td>
<td align="right" valign="bottom" class="smalltext">';
if (! $ignore) {
// put to site
if($context['user']['is_admin'] OR $context['user']['name'] == 'Yeah_baby')
echo'
@@ -529,13 +555,13 @@ function template_main()
else
echo '
'/*, $txt[511]*/;
}
echo '
</td>
</tr></table>';
// Show the member's signature?
if (/*empty($context['user']['is_guest']) &&*/
if (! $ignore && /*empty($context['user']['is_guest']) &&*/
!empty($message['member']['signature']) &&
empty($options['show_no_signatures']))
echo '

View File

@@ -252,9 +252,9 @@ function smf_main()
'modifycat' => array('ManageBoards.php', 'ModifyCat'),
'modifykarma' => array('Karma.php', 'ModifyKarma'),
'viewkarma' => array('Viewkarma.php', 'ViewKarma'),
'ownkarma' => array('Viewkarma.php', 'OwnKarma'),
'otherkarma' => array('Viewkarma.php', 'OtherKarma'),
'viewkarma' => array('Viewkarma.php', 'ViewKarma'),
'ownkarma' => array('Viewkarma.php', 'OwnKarma'),
'otherkarma' => array('Viewkarma.php', 'OtherKarma'),
'modifyModSettings' => array('ModSettings.php', 'ModifyModSettings'),
'modifyModSettings2' => array('ModSettings.php', 'ModifyModSettings2'),
'modlog' => array('Modlog.php', 'ViewModlog'),
@@ -331,7 +331,9 @@ function smf_main()
'.xml' => array('News.php', 'ShowXmlFeed'),
'page' => array('Page.php', 'main'),
'postHistory' => array('Display.php', 'PostHistory'),
'moresmilies' => array('MoreSmilies.php', 'main'),
'moresmilies' => array('MoreSmilies.php', 'main'),
'ignore' => array ('Ignore.php', 'ignore'),
'unignore' => array ('Ignore.php', 'unignore'),
);
// Get the function and file to include - if it's not there, do the board index.