Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Read-All PMs?

Is there any way to implement a read-all PMs button on Vanillaforums? I have gotten complaints from users about that and have been wondering this for a while now. Thanks in advance.

Comments

  • Unauthorized.

  • hgtonighthgtonight ∞ · New Moderator
    edited January 2015
    public function messagesController_markAllRead_create($Sender) {
      $UserID = $this->Request->Get('userid', Gdn::Session()->UserID);
      if ($UserID != Gdn::Session()->UserID) {
        if (!C('Conversations.Moderation.Allow', FALSE)) {
          throw PermissionException();
        }
        $Sender->Permission('Conversations.Moderation.Manage');
      }
    
      $Sender->ConversationModel->MarkAllRead($UserID);
    
      redirect("/messages/all?userid=$UserID");
    }
    
    public function conversationModel_markAllRead_create($Sender) {
      $UserID = val(0,$Sender->EventArguments, FALSE);
    
      if(is_numeric($UserID)) {
        // Update the the read conversation count for the user.
        $Sender->SQL->Update('UserConversation uc')
             ->Set('uc.CountReadMessages', 'c.CountMessages', FALSE)
             ->Set('uc.DateLastViewed', Gdn_Format::ToDateTime())
             ->Set('uc.LastMessageID', 'c.LastMessageID', FALSE)
             ->Where('uc.UserID', $UserID)
             ->Put();
    
        $Usermodel = new UserModel();
        $Usermodel->SetField($UserID, 'CountUnreadConversations', 0);
      }
    }
    

    Slap that in a plugin and spit out a link to http://forums.example.com/messages/markallread

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

Sign In or Register to comment.