BuddyDev

Search

Integrate Wise Cha Pro in BuddyPress/bp-notifications

Tagged: 

  • Participant
    Level: Initiated
    Posts: 5
    marcin on #24116

    You are the best specialist buddypress and other plugins.
    Thanks.
    I want to ask two questions:
    I have two possibilities in the plugin:
    1) E-mail Notifications: Notify the administrator when a message is posted in the chat. E-mail notifications: Configure notifications sent to admin;
    2) Notifications signaling new users, new users, absent users or mentioned users. It can be found in the browser.
    Question one:
    What to do, that the letters were sent not to the administrator, but to the recipient of the message?
    Second question:
    How to integrate the function: Notifications signaling new users, new users, absent users or referred users. It can be found in the browser, with a function
    BuddyPress/bp-notifications?
    Please download the free plugin wise-chat-pro link:
    http://discuse.com/music-video-collection/
    or from the website: discuse.com

  • Keymaster
    (BuddyDev Team)
    Posts: 24636
    Brajesh Singh on #24130

    Hi marcin ,
    Welcome to BuddyDev.

    I am sorry, I haven’t used wisepro chat, so I am not familiar with what they offer out of the box. I can still assist but I need to know a few things:-

    1. I believe, They should have this option out of the box. Have you asked them about it? If they do not support it, I will assist you(will check the code feasibility).

    2. Please clarify what you want to achieve here. I am sorry but I could not understand it. Please help me understand it better.

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 5
    marcin on #24137

    Hi Brajesh Singh,

    I have a theme BuddyBoss. It is integrated into the plugin Buddypress/bp-notifications.
    Chat is not integrated in Buddypress/bp-notifications.
    How to integrate chat in buddypress/bp-notifications?

    Chat Features:
    BuddyPress integration: Integrate Wise Chat Pro into BuddyPress groups, friends.

    Subject and Chat added on site: Discuse.com

    Thanks

  • Participant
    Level: Initiated
    Posts: 5
    marcin on #24138

    I can send you a plugin:
    wise-chat-pro.
    Please let me know your email.

  • Participant
    Level: Initiated
    Posts: 5
    marcin on #24140

    I asked them about it.
    They are not familiar with buddypress.
    Only you can help.

    I publish copies from files:
    File: wise-chat-pro/src/integrations/WiseChatBuddyPressGroupExtension.php
    /**
    * Wise Chat BuddyPress group.
    *
    * @author Kainex <contact@kaine.pl>
    */
    class WiseChatBuddyPressGroupExtension extends BP_Group_Extension {
    const DEFAULT_NAV_ITEM_POSITION = 40;
    const DEFAULT_NAV_ITEM_NAME = ‘Chat’;

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

    public function __construct() {
    $this->options = WiseChatOptions::getInstance();

    $args = array(
    ‘slug’ => ‘chat’,
    ‘name’ => $this->localize(‘message_bp_manage_tab_name’, ‘Chat’),
    ‘nav_item_name’ => self::DEFAULT_NAV_ITEM_NAME,
    ‘nav_item_position’ => self::DEFAULT_NAV_ITEM_POSITION,
    );

    $id = groups_get_groupmeta($this->get_group_id(), ‘bp_wisechat_id’);
    $isEnabled = groups_get_groupmeta($this->get_group_id(), ‘bp_wisechat_enabled’) == true;
    $navItemPosition = intval(groups_get_groupmeta($this->get_group_id(), ‘bp_wisechat_nav_item_position’));
    $navItemName = groups_get_groupmeta($this->get_group_id(), ‘bp_wisechat_nav_item_name’);
    if (!$isEnabled) {
    $args[‘show_tab’] = ‘noone’;
    }
    if ($navItemPosition > 0) {
    $args[‘nav_item_position’] = $navItemPosition;
    }
    if (strlen($navItemName) > 0) {
    $args[‘nav_item_name’] = $navItemName;
    }
    if (strlen($id) === 0) {
    $id = ‘bp-chat-‘.$this->get_group_id().’-‘.substr(md5($this->get_group_id().time()), 0, 6);
    groups_update_groupmeta($this->get_group_id(), ‘bp_wisechat_id’, $id);
    }

    parent::init($args);
    }

    public function display($groupId = null) {
    $groupId = bp_get_group_id();
    $isEnabled = groups_get_groupmeta($groupId, ‘bp_wisechat_enabled’) == true;
    $id = groups_get_groupmeta($this->get_group_id(), ‘bp_wisechat_id’);
    $attributes = groups_get_groupmeta($groupId, ‘bp_wisechat_attributes’);
    $parsedAttributes = strlen($attributes) > 0 ? shortcode_parse_atts($attributes) : array();

    if ($isEnabled) {
    if (function_exists(‘wise_chat’)) {
    $parsedAttributes[‘channel’] = $id;

    $wiseChat = WiseChatContainer::get(‘WiseChat’);
    echo $wiseChat->getRenderedShortcode($parsedAttributes);
    $wiseChat->registerResources();
    }
    }
    }

    public function settings_screen($groupId = null ) {
    $isEnabled = groups_get_groupmeta($groupId, ‘bp_wisechat_enabled’);
    $navItemPosition = intval(groups_get_groupmeta($groupId, ‘bp_wisechat_nav_item_position’));
    $navItemName = groups_get_groupmeta($groupId, ‘bp_wisechat_nav_item_name’);
    $isPermissionModDeleteMessagesGranted = groups_get_groupmeta($groupId, ‘bp_wisechat_permissions_mod_delete_messages’);
    $isPermissionModBanUsersGranted = groups_get_groupmeta($groupId, ‘bp_wisechat_permissions_mod_ban_users’);
    $isPermissionAdminDeleteMessagesGranted = groups_get_groupmeta($groupId, ‘bp_wisechat_permissions_admin_delete_messages’);
    $isPermissionAdminBanUsersGranted = groups_get_groupmeta($groupId, ‘bp_wisechat_permissions_admin_ban_users’);
    $attributes = groups_get_groupmeta($groupId, ‘bp_wisechat_attributes’);
    if ($navItemPosition == 0) {
    $navItemPosition = self::DEFAULT_NAV_ITEM_POSITION;
    }
    if (strlen($navItemName) === 0) {
    $navItemName = self::DEFAULT_NAV_ITEM_NAME;
    }
    ?>
    <label for=”bp_wisechat_enabled”><?php echo $this->localize(‘message_bp_manage_enable_chat’, ‘Enable Chat’); ?></label>
    <input type=”checkbox” value=”1″ tabindex=”0″ id=”bp_wisechat_enabled” name=”bp_wisechat_enabled” <?php echo $isEnabled ? ‘checked’: ”; ?> />
    <br />
    <label for=”bp_wisechat_nav_item_position”><?php echo $this->localize(‘message_bp_manage_tab_position’, ‘Tab Position’); ?></label>
    <input name=”bp_wisechat_nav_item_position” id=”bp_wisechat_nav_item_position” value=”<?php echo $navItemPosition; ?>” aria-required=”true” type=”number” style=”width: 80px;” />
    <br />
    <label for=”bp_wisechat_nav_item_name”><?php echo $this->localize(‘message_bp_manage_tab_label’, ‘Tab Label’); ?></label>
    <input name=”bp_wisechat_nav_item_name” id=”bp_wisechat_nav_item_name” value=”<?php echo $navItemName; ?>” aria-required=”true” type=”text” />
    <br />
    <label for=”bp_wisechat_nav_item_name”><?php echo $this->localize(‘message_bp_manage_permissions’, ‘Permissions’); ?></label>
    <p>
    <label for=”bp_wisechat_permissions_mod_delete_messages”>
    <input type=”checkbox” value=”1″ tabindex=”0″ id=”bp_wisechat_permissions_mod_delete_messages” name=”bp_wisechat_permissions_mod_delete_messages” <?php echo $isPermissionModDeleteMessagesGranted ? ‘checked’: ”; ?> />
    <?php echo $this->localize(‘message_bp_manage_permissions_mods_delete’, ‘Allow mods to delete messages’); ?>
    </label>
    <label for=”bp_wisechat_permissions_mod_ban_users”>
    <input type=”checkbox” value=”1″ tabindex=”0″ id=”bp_wisechat_permissions_mod_ban_users” name=”bp_wisechat_permissions_mod_ban_users” <?php echo $isPermissionModBanUsersGranted ? ‘checked’: ”; ?> />
    <?php echo $this->localize(‘message_bp_manage_permissions_mods_ban’, ‘Allow mods to ban users’); ?>
    </label>

    <label for=”bp_wisechat_permissions_admin_delete_messages”>
    <input type=”checkbox” value=”1″ tabindex=”0″ id=”bp_wisechat_permissions_admin_delete_messages” name=”bp_wisechat_permissions_admin_delete_messages” <?php echo $isPermissionAdminDeleteMessagesGranted ? ‘checked’: ”; ?> />
    <?php echo $this->localize(‘message_bp_manage_permissions_admins_delete’, ‘Allow admins to delete messages’); ?>
    </label>
    <label for=”bp_wisechat_permissions_admin_ban_users”>
    <input type=”checkbox” value=”1″ tabindex=”0″ id=”bp_wisechat_permissions_admin_ban_users” name=”bp_wisechat_permissions_admin_ban_users” <?php echo $isPermissionAdminBanUsersGranted ? ‘checked’: ”; ?> />
    <?php echo $this->localize(‘message_bp_manage_permissions_admins_ban’, ‘Allow admins to ban users’); ?>
    </label>
    <small>
    <?php echo $this->localize(‘message_bp_manage_notice’, ‘Notice:’); ?>
    <?php echo $this->localize(‘message_bp_manage_notice_text’, ‘These permissions will work only with enabled admin actions in Wise Chat Pro settings’); ?>
    </small>
    </p>
    <label for=”bp_wisechat_attributes”><?php echo $this->localize(‘message_bp_manage_shortcode’, ‘Wise Chat Pro detailed parameters (shortcode syntax required)’); ?></label>
    <textarea name=”bp_wisechat_attributes” id=”bp_wisechat_attributes” aria-required=”true”><?php echo $attributes; ?></textarea>
    <small><?php echo $this->localize(‘message_bp_manage_shortcode_example’, ‘Example:’); ?> window_title=”The Chat” show_users=”1″</small>
    <br />
    <br />
    <p style=”float: right;”>

    options->getBaseDir() ?>/gfx/misc/powered-by-wise-chat-pro.png” alt=”Wise Chat Pro plugin for WordPress” />

    </p>
    <br style=”clear: both;” />
    <?php
    }

    public function settings_screen_save($groupId = null) {
    $this->saveBooleanGroupMeta($groupId, ‘bp_wisechat_enabled’, false);
    $this->saveIntegerGroupMeta($groupId, ‘bp_wisechat_nav_item_position’, self::DEFAULT_NAV_ITEM_POSITION);
    $this->saveStringGroupMeta($groupId, ‘bp_wisechat_nav_item_name’, self::DEFAULT_NAV_ITEM_NAME);
    $this->saveBooleanGroupMeta($groupId, ‘bp_wisechat_permissions_mod_delete_messages’, false);
    $this->saveBooleanGroupMeta($groupId, ‘bp_wisechat_permissions_mod_ban_users’, false);
    $this->saveBooleanGroupMeta($groupId, ‘bp_wisechat_permissions_admin_delete_messages’, false);
    $this->saveBooleanGroupMeta($groupId, ‘bp_wisechat_permissions_admin_ban_users’, false);
    $this->saveLongStringGroupMeta($groupId, ‘bp_wisechat_attributes’, ”);
    }

    private function localize($key, $default) {
    return $this->options->getEncodedOption($key, $default);
    }

    private function saveBooleanGroupMeta($groupId, $postKey, $default) {
    groups_update_groupmeta($groupId, $postKey, array_key_exists($postKey, $_POST) && $_POST[$postKey] == ‘1’ ? true : $default);
    }

    private function saveIntegerGroupMeta($groupId, $postKey, $default) {
    groups_update_groupmeta(
    $groupId, $postKey,
    array_key_exists($postKey, $_POST) && intval($_POST[$postKey]) > 0
    ? intval($_POST[$postKey])
    : $default
    );
    }

    private function saveStringGroupMeta($groupId, $postKey, $default) {
    groups_update_groupmeta(
    $groupId, $postKey,
    array_key_exists($postKey, $_POST) && strlen($_POST[$postKey]) > 0
    ? htmlentities($_POST[$postKey], ENT_QUOTES, ‘UTF-8’)
    : $default
    );
    }

    private function saveLongStringGroupMeta($groupId, $postKey, $default) {
    groups_update_groupmeta(
    $groupId, $postKey,
    array_key_exists($postKey, $_POST) && strlen($_POST[$postKey]) > 0
    ? htmlentities($_POST[$postKey], ENT_NOQUOTES, ‘UTF-8’)
    : $default
    );
    }

    }
    _______________________________________________________________________________
    File: wise-chat-pro/ wise-chat-core.php
    function wise_chat_bp_init() {
    $options = WiseChatOptions::getInstance();
    if ($options->isOptionEnabled(‘enable_buddypress’, false) && (bp_is_active( ‘groups’ ) || class_exists(‘BP_Group_Extension’, false))) {
    WiseChatContainer::load(‘integrations/buddypress/WiseChatBuddyPressGroupExtension’);
    bp_register_group_extension(‘WiseChatBuddyPressGroupExtension’);
    }
    }
    add_action(‘bp_include’, ‘wise_chat_bp_init’);

  • Keymaster
    (BuddyDev Team)
    Posts: 24636
    Brajesh Singh on #24148

    Hi,
    I have received the plugin from your initial link.
    Please allow me 1-2 days to take a look at it and assist you.

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 5
    marcin on #24245

    Hi Brajesh Singh,

    Addition:
    wise-chat-pro/src/WiseChat.php
    /**
    * @return string
    */
    private function getCheckSum() {
    $checkSumData = is_array($this->shortCodeOptions) ? $this->shortCodeOptions : array();
    $checkSumData[‘_sid’] = session_id();
    $checkSumData[‘_sn’] = session_name();
    $checkSumData[‘ts’] = time();
    if ($this->options->isOptionEnabled(‘enable_buddypress’, false) && function_exists(“bp_is_group”) && bp_is_group()) {
    $checkSumData[‘_bpg’] = bp_get_group_id();
    }

    return base64_encode(WiseChatCrypt::encrypt(serialize($checkSumData)));
    }

  • Participant
    Level: Initiated
    Posts: 5
    marcin on #24246

    Addition:
    wise-chat-pro/src/services/ChatUserService.php
    /**
    * Checks if the first given user can communicate with the second user.
    *
    * @param WiseChatUser $user
    * @param WiseChatUser $associatedUser
    * @return bool
    */
    public function isUsersConnectionAvailable($user, $associatedUser) {
    if (!$this->options->isOptionEnabled(‘enable_buddypress’, false)) {
    return true;
    }
    if (!$this->options->isOptionEnabled(‘users_list_bp_users_only’, false)) {
    return true;
    }

    if ($user === null || $associatedUser === null) {
    return false;
    }

    if (!($user->getWordPressId() > 0) || !($associatedUser->getWordPressId() > 0)) {
    return false;
    }

    if ($user->getWordPressId() == $associatedUser->getWordPressId()) {
    return true;
    }

    if (function_exists(‘friends_check_friendship’)) {
    return friends_check_friendship($user->getWordPressId(), $associatedUser->getWordPressId());
    }

    return false;
    }

You must be logged in to reply to this topic.

This topic is: not resolved