Exemplo n.º 1
0
function userpro_msg_profile_buttons($user_id)
{
    global $userpro_msg;
    $res = null;
    if ($userpro_msg->can_chat_with($user_id)) {
        $res = '<a href="#" class="userpro-button chat userpro-init-chat" data-chat_with="' . $user_id . '" data-chat_from="' . get_current_user_id() . '"><i class="userpro-icon-comment"></i>' . __('Send Message', 'userpro-msg');
        $res .= '</a>';
    } else {
        if (userpro_is_logged_in() && $user_id == get_current_user_id()) {
            $res = "";
            $broadcast_status = userpro_msg_get_option('broadcast_enabled');
            if ($broadcast_status == 1) {
                $allowed = 0;
                $allowed_roles = userpro_msg_get_option('roles_that_can_broadcast');
                $allowed_roles = explode(',', $allowed_roles);
                foreach ($allowed_roles as $allowed_role) {
                    if (current_user_can($allowed_role)) {
                        $allowed = 1;
                    }
                }
                if ($allowed == 1) {
                    $res .= '<a href="#" class="userpro-button chat userpro-broadcast-msg" data-user_id="' . $user_id . '"><i class="userpro-icon-globe"></i>' . __('Broadcast Message', 'userpro-msg');
                    $res .= '</a> ';
                }
            }
            $res .= '<a href="#" class="userpro-button secondary userpro-show-chat userpro-tip" data-user_id="' . $user_id . '" title="' . $userpro_msg->new_chats_notifier($user_id) . '"><i class="userpro-icon-comments"></i>' . __('My Messages', 'userpro-msg');
            if ($userpro_msg->new_chats_notifier_count($user_id) > 0) {
                $res .= '<span>' . $userpro_msg->new_chats_notifier_count($user_id) . '</span>';
            }
            $res .= '</a>';
        }
    }
    echo $res;
}
Exemplo n.º 2
0
function userpro_start_chat()
{
    global $userpro, $userpro_msg;
    $output = '';
    extract($_POST);
    if (!userpro_is_logged_in() || $chat_from != get_current_user_id()) {
        die;
    }
    if (!$userpro_msg->can_chat_with($chat_with)) {
        die;
    }
    /* Create folders to store conversations */
    $userpro_msg->do_chat_dir($chat_from, $chat_with, $mode = 'sent');
    $userpro_msg->do_chat_dir($chat_with, $chat_from, $mode = 'inbox');
    if (userpro_msg_get_option('default_msg') == 1) {
        $chat_body = $chat_body . "<br><br><br><p style=font-size:10px;color:gray;>" . stripslashes(esc_attr(userpro_msg_get_option('default_msg_text'))) . "</p>";
    }
    $userpro_msg->write_chat($chat_from, $chat_with, $chat_body, $mode = 'sent');
    $userpro_msg->write_chat($chat_with, $chat_from, $chat_body, $mode = 'inbox');
    $userpro_msg->email_user($chat_with, $chat_from, $chat_body);
    $userpro_msg->remove_unread_chat($chat_from, $chat_with);
    /* Status for browser */
    $output['message'] = '<div class="userpro-msg-notice">' . __('Your message has been sent successfully.', 'userpro-msg') . '</div>';
    ob_start();
    require_once userpro_msg_path . 'templates/conversation.php';
    $output['html'] = ob_get_contents();
    ob_end_clean();
    $output = json_encode($output);
    if (is_array($output)) {
        print_r($output);
    } else {
        echo $output;
    }
    die;
}
Exemplo n.º 3
0
 function can_chat_with($user_id)
 {
     global $userpro_social;
     $global_privacy = userpro_msg_get_option('msg_privacy');
     if ($user_id != get_current_user_id() && userpro_is_logged_in()) {
         if ($global_privacy == 'none') {
             return false;
         }
         if ($global_privacy == 'public') {
             return true;
         } else {
             if ($global_privacy == 'mutual' && $userpro_social->mutual_follow(get_current_user_id(), $user_id)) {
                 return true;
             }
         }
     } else {
         return false;
     }
 }
Exemplo n.º 4
0
			</select>
			<span class="description"><?php 
_e('This will enable the feature of broadcasting message to all the users.', 'userpro-msg');
?>
</span>
		</td>
	</tr>

	<tr valign="top">
		<th scope="row"><label for="roles_that_can_broadcast"><?php 
_e('Allow these roles to broadcast messages', 'userpro-msg');
?>
</label></th>
		<td>
			<input type="text" name="roles_that_can_broadcast" id="roles_that_can_broadcast" value="<?php 
echo userpro_msg_get_option('roles_that_can_broadcast');
?>
" class="regular-text" />
			<span class="description"><?php 
_e('The users belonging to above roles will be able to broadcast messages to all other users on the site. By default no one can broadcast message.', 'userpro-msg');
?>
</span>
		</td>
	</tr>
	
</table>
<!--Code end-->

<p class="submit">
	<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php 
_e('Save Changes', 'userpro-msg');
Exemplo n.º 5
0
<div class="userpro-notifier userpro-notifier-<?php 
echo userpro_msg_get_option('msg_notification');
?>
">

	<a href="#" class="userpro-notifier-link userpro-show-chat" data-user_id="<?php 
echo $user_id;
?>
">
		<span class="count"><i class="userpro-icon-comment"></i><?php 
echo $userpro_msg->new_chats_notifier($user_id);
?>
</span>
	</a>

</div>

<span class="userpro-notifier-thumbs userpro-notifier-thumbs-<?php 
echo userpro_msg_get_option('msg_notification');
?>
"><?php 
echo $userpro_msg->new_chats_user_thumbs($user_id);
?>
</span>