From a4b0e19b47e158183f29ad3a01f293e033c23919 Mon Sep 17 00:00:00 2001 From: Aleksei Miheev Date: Sun, 29 Jan 2012 22:01:07 +0400 Subject: [PATCH] Users can ignore each others' post now --- Sources/Display.php | 5 ++- Sources/Ignore.php | 49 +++++++++++++++++++++ Themes/default/Display.template.php | 66 ++++++++++++++++++++--------- index.php | 10 +++-- 4 files changed, 105 insertions(+), 25 deletions(-) create mode 100644 Sources/Ignore.php diff --git a/Sources/Display.php b/Sources/Display.php index db8c11a..cf18cfb 100644 --- a/Sources/Display.php +++ b/Sources/Display.php @@ -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')) { diff --git a/Sources/Ignore.php b/Sources/Ignore.php new file mode 100644 index 0000000..3ddfb68 --- /dev/null +++ b/Sources/Ignore.php @@ -0,0 +1,49 @@ + 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); +} diff --git a/Themes/default/Display.template.php b/Themes/default/Display.template.php index 68ffa9d..bd6d5f8 100644 --- a/Themes/default/Display.template.php +++ b/Themes/default/Display.template.php @@ -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'] = "Сообщение скрыто, потому что вы игнорируете этого пользователя
"; + $url = str_replace('#', ';noignore#', $message['href']); + $message['body'] .= 'Показать скрытые сообщения'; + } + echo ' '; @@ -236,10 +254,10 @@ function template_main() # echo ' # '; // 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()
'; // 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'], '
'; // 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 '
'; // 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() - '; @@ -449,7 +472,7 @@ function template_main()
', $message['subject'], '';/*--> + ', $message['subject'], '', !($message['id'] == $context['topic_first_message']) ? ' #'.$message['counter'] : '','';/*--> '; ', $message['subject'], '';*/ // If this is the first post, (#0) just say when it was posted - otherwise give the reply #. echo ' - '/*, !($message['id'] == $context['topic_first_message']) ? $txt['post_no']. $message['counter'] : '', ' ', $txt[30], ': '*/, $message['time'], ''; + ', /*!($message['id'] == $context['topic_first_message']) ? '#'.$message['counter'] : '', ' ',*/ $message['time'], ''; if ($message['id']==$context['topic_first_message']) { echo '
'; @@ -384,12 +402,20 @@ function template_main()
'; + if (! $ignore) + echo ' + Игнорировать'; + else + echo ' + Перестать игнорировать'; + + // 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 ' ', ($settings['use_image_buttons'] ? '' . $txt[145] . '' : $txt[145]), ''; // So... quick reply is off, but they *can* reply? - elseif ($context['can_reply']) + elseif (! $ignore && $context['can_reply']) echo ' ', ($settings['use_image_buttons'] ? '' . $txt[145] . '' : $txt[145]), ''; @@ -434,9 +460,6 @@ function template_main() echo '

', $nowplayingstring, ' ', $message['nowplaying'], ''; }*/ echo ''; - if ( 0 AND $message['id']==$context['topic_first_message']) { - echo '
'; - } echo '
'; // Assuming there are attachments... - if (!empty($message['attachment'])) + if (! $ignore && !empty($message['attachment'])) { echo '
@@ -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 ' « ', $txt[211], ': ', $message['modified']['time'], ' ', $txt[525], ' ', $message['modified']['name'], ' »'; - 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 = ''; @@ -495,7 +520,8 @@ function template_main() echo '
'; - + + 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 '
'; // 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 ' diff --git a/index.php b/index.php index 0fbd604..9e0ca15 100644 --- a/index.php +++ b/index.php @@ -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.