Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)

  • woofy123
    Participant

    @woofy123

    @shanebp

    Hi, thanks for your reply before. I checked with the creators of the plugin and they say they can’t do it. so i decided to check by myself….the wise chat plugin redirects notifications to the email and the code for that is below….i don’t know coding and all that so i seriously need your help…what code do i put inplace of the email so that messages are reduirected to buddypress notifications? Please help..The code—–

    `<?php

    /**
    * WiseChat user notifications services.
    *
    * @author Kainex <contact@kaine.pl>
    */
    class WiseChatUserNotificationsService {

    /**
    * @var WiseChatUserNotificationsDAO
    */
    private $userNotificationsDAO;

    /**
    * @var WiseChatSentNotificationsDAO
    */
    private $sentNotificationsDAO;

    /**
    * @var WiseChatUsersDAO
    */
    private $usersDAO;

    /**
    * @var WiseChatChannelUsersDAO
    */
    private $channelUsersDAO;

    /**
    * @var WiseChatHttpRequestService
    */
    private $httpRequestService;

    /**
    * @var WiseChatOptions
    */
    private $options;

    public function __construct() {
    $this->options = WiseChatOptions::getInstance();
    $this->userNotificationsDAO = WiseChatContainer::getLazy(‘dao/WiseChatUserNotificationsDAO’);
    $this->sentNotificationsDAO = WiseChatContainer::getLazy(‘dao/WiseChatSentNotificationsDAO’);
    $this->usersDAO = WiseChatContainer::get(‘dao/user/WiseChatUsersDAO’);
    $this->channelUsersDAO = WiseChatContainer::get(‘dao/WiseChatChannelUsersDAO’);
    $this->httpRequestService = WiseChatContainer::getLazy(‘services/WiseChatHttpRequestService’);
    }

    /**
    * Sends all notifications for message.
    *
    * @param WiseChatMessage $message
    * @param WiseChatChannel $channel
    */
    public function send($message, $channel) {
    foreach ($this->userNotificationsDAO->getAll() as $notification) {
    $this->sendNotification($message, $channel, $notification);
    }
    }

    /**
    * Sends the notification.
    *
    * @param WiseChatMessage $message
    * @param WiseChatChannel $channel
    * @param WiseChatUserNotification $notification
    */
    private function sendNotification($message, $channel, $notification) {
    if ($notification->getType() == ’email’) {
    $this->sendEmailNotification($message, $channel, $notification);
    }
    }

    /**
    * Sends e-mail notification.
    *
    * @param WiseChatMessage $message
    * @param WiseChatChannel $channel
    * @param WiseChatUserNotification $notification
    */
    private function sendEmailNotification($message, $channel, $notification) {
    $timeRange = null; // seconds

    if ($notification->getFrequency() == ‘daily’) {
    $timeRange = 24 * 60 * 60;
    }
    if ($notification->getFrequency() == ‘hourly’) {
    $timeRange = 60 * 60;
    }
    if ($timeRange === null) {
    return;
    }

    if ($this->sentNotificationsDAO->wasNotificationSendForUser($notification->getId(), $channel->getId(), $message->getUserId(), $timeRange)) {
    return;
    }

    $recipientUser = $this->usersDAO->get($message->getRecipientId());
    if ($recipientUser === null) {
    return;
    }

    $channelUser = $this->channelUsersDAO->getActiveByUserIdAndChannelId($recipientUser->getId(), $channel->getId());
    if ($channelUser !== null) {
    return;
    }

    if ($recipientUser->getDataProperty(‘disableNotifications’) === true) {
    return;
    }

    if (!($recipientUser->getWordPressId() > 0)) {
    return;
    }

    $recipientWordPressUser = $this->usersDAO->getWpUserByID($recipientUser->getWordPressId());
    if ($recipientWordPressUser === null) {
    return;
    }

    $sentNotification = new WiseChatSentNotification();
    $sentNotification->setNotificationId($notification->getId());
    $sentNotification->setSentTime(time());
    $sentNotification->setChannelId($channel->getId());
    $sentNotification->setUserId($message->getUserId());
    $this->sentNotificationsDAO->save($sentNotification);

    // send the e-mail:
    $templateData = array(
    ‘${recipient}’ => $recipientWordPressUser->display_name,
    ‘${recipient-email}’ => $recipientWordPressUser->user_email,
    ‘${sender}’ => strip_tags($message->getUserName()),
    ‘${message}’ => $message->getText(),
    ‘${channel}’ => $message->getChannelName(),
    ‘${link}’ => $this->httpRequestService->getReferrerURL()
    );
    $emailSubject = str_replace(array_keys($templateData), array_values($templateData), $notification->getDetails()[‘subject’]);
    $emailBody = str_replace(array_keys($templateData), array_values($templateData), $notification->getDetails()[‘content’]);

    wp_mail($recipientWordPressUser->user_email, $emailSubject, $emailBody);
    }
    }


    woofy123
    Participant

    @woofy123

    @prashantvatsh

    Hi Prashant Sir,

    I didn’t know how to reach to you and so I had to reply to this thread.

    I am having a problem and I think you might be able to help me.

    I have this plugin called wise chat pro and it says they integrate buddypress and what I want to do is the following—

    1. When new messages arrive in the wise chat channel they appear in the users bp-profile under the bp-notifications
    2. whenever a user is mentioned in a chat—that also appears in the users bp-profile under the mentions column.

    So in short, how can I connect both plugins so that the new messages and the @mentions appear in the users bp profile under the notification nd mentions section.

    I’ve seen a lot of replies by you and one reply helped me show user profile on a blank page so I thought you could help me with this too..

    Thank you very much

Viewing 2 replies - 1 through 2 (of 2 total)
Skip to toolbar