Пример #1
0
<?php

/**
 * OhYesChat
 * @website Link: https://github.com/lianglee/OhYesChat
 * @Package Ohyes
 * @subpackage Chat
 * @author Liang Lee
 * @copyright All right reserved Liang Lee 2014.
 * @ide The Code is Generated by Liang Lee php IDE.
 */
$from = get_user_by_username(get_input('msgfrom'));
$to = get_user_by_username(get_input('msgto'));
$var['to'] = $to;
$var['from'] = $from;
$var['messages'] = array_reverse(OhYesChat::getMessages($from->guid, $to->guid));
echo elgg_view('ohyes/chat/track', $var);
Пример #2
0
/**
 * OhYesChat Page Setup;
 *  URLs take the form of
 *  Boot:       ohyeschat/boot/ohyeschat.boot.js
 *  Notifications:    ohyeschat/notif
 *  Freinds:   ohyeschat/friends
 *  New tab : ohyeschat/newtab
 *  actions:       {
 *      Send Message:        oyeschat/action/send
 *      Refresh the tab:       ohyeschat/action/refresh
 *      Remove the tab :    ohyeschat/action/removetab/<id of tab>
 *
 * Title is ignored
 *
 *
 * @param array $page
 * @return bool
 */
function ohyeschat_page_handler($page)
{
    $plugin = elgg_get_plugins_path() . 'OhYesChat/';
    if (!isset($page[0])) {
        if (elgg_is_admin_logged_in()) {
            $page[0] = 'admin';
        } else {
            forward();
        }
    }
    $user = elgg_get_logged_in_user_entity();
    if (empty($user->username)) {
        return false;
    }
    switch ($page[0]) {
        case 'admin':
            if (elgg_is_admin_logged_in()) {
                if (empty($page[1])) {
                    include_once "{$plugin}pages/admin/dashboard.php";
                } else {
                    if ($page[1] == 'track') {
                        include_once "{$plugin}pages/admin/trackuser.php";
                    }
                    if ($page[1] == 'getuser') {
                        include_once "{$plugin}pages/admin/getuser.php";
                    }
                }
            }
            break;
        case 'smilies':
            echo elgg_view('ohyes/chat/smiles/similes', array('tab' => get_input('uid')));
            break;
        case 'messages':
            $user = $page[1];
            if (!empty($user)) {
                $var['user'] = get_user_by_username($user);
                $var['owner'] = elgg_get_logged_in_user_entity()->guid;
                $var['messages'] = array_reverse(OhYesChat::getMessages($var['user']->guid, $var['owner']));
                $params['content'] = elgg_view('ohyes/chat/expend', $var);
                $body = elgg_view_layout('one_sidebar', $params);
                echo elgg_view_page($params['title'], $body);
            }
            break;
        case 'boot':
            if ($page[1] == 'ohyeschat.boot.js') {
                header('Content-Type: text/javascript');
                echo elgg_view('js/ohyes/chat');
            }
            break;
        case 'notif':
            header('Content-Type: application/json');
            $messages = elgg_view('ohyes/chat/messages');
            if (empty($messages)) {
                $messages = '<p style="padding:10px;">' . elgg_echo('ohyes:chat:no:message') . '</p>';
            }
            echo json_encode(array('messages' => $messages, 'count' => ''));
            break;
        case 'friends':
            header('Content-Type: application/json');
            echo json_encode(array('friends' => elgg_view('ohyes/chat/friends', array('entity' => elgg_get_logged_in_user_entity()))));
            break;
        case 'newtab':
            header('Content-Type: application/json');
            if (empty($page[1])) {
                exit;
            } else {
                if (!in_array($page[1], $_SESSION['ohyes_chat'])) {
                    $_SESSION['ohyes_chat'][] = $page[1];
                }
            }
            $login = elgg_get_logged_in_user_entity()->guid;
            $friend = get_user($page[1]);
            $messages = OhYesChat::getMessages($login, $page[1]);
            foreach (array_reverse($messages) as $umessages) {
                $icon = elgg_view("icon/default", array('entity' => get_user($umessages->sender), 'size' => 'small'));
                $user_msgs[] = elgg_view('ohyes/chat/message-item', array('icon' => $icon, 'message' => OhYesChat::replaceIcon($umessages->message), 'sender' => $umessages->sender));
            }
            $tab = elgg_view('ohyes/chat/selectfriend', array('friend' => $friend));
            $messages = implode('', $user_msgs);
            echo json_encode(array('tab' => $tab, 'messages' => $messages));
            global $CONFIG;
            update_data("UPDATE {$CONFIG->dbprefix}ohyes_chat \n\t\t\t\t\t\t SET view='1' WHERE(sender='{$page['1']}' \n\t\t\t             AND reciever='{$login}');");
            break;
        case 'action':
            if (empty($page[1]) || !in_array($page[1], OhYesChat::actions())) {
                exit;
            }
            if ($page[1] == 'send') {
                require_once "{$plugin}actions/send.php";
            }
            if ($page[1] == 'refresh') {
                exit;
                //removed in 1.1 release; $arsalanshah;
            }
            if ($page[1] == 'removetab') {
                $uid = array_search($page[2], $_SESSION['ohyes_chat']);
                unset($_SESSION['ohyes_chat'][$uid]);
                echo 'removed';
            }
            break;
        case 'mobile':
            if (elgg_is_active_plugin('OhYesChat_Mobile') && OhYesChat::FromMobile()) {
                elgg_trigger_plugin_hook('ohyeschat', 'mobile', $page);
            } else {
                forward();
            }
            break;
        default:
            return false;
    }
    return true;
}
Пример #3
0
echo $vars['friend']['guid'];
?>
" class="data">
<?php 
/**
 * OhYesChat
 * @website Link: https://informatikon.com
 * @package Informatikon.Elgg
 * @subpackage Chat
 * @author $arsalanshah.informatikon
 * @copyright All right reserved Informatikon Technologies 2014.
 * @ide The Code is Generated by Liang Lee php IDE.
 */
if ($vars['xhr'] == 'false') {
    $login = elgg_get_logged_in_user_entity()->guid;
    $messages = OhYesChat::getMessages($login, $vars['friend']->guid);
    foreach (array_reverse($messages) as $umessages) {
        if ($umessages->sender == elgg_get_logged_in_user_entity()->guid) {
            $icon = '';
        } else {
            $icon = elgg_view("icon/default", array('entity' => get_user($umessages->sender), 'size' => 'small'));
        }
        $user_msgs[] = elgg_view('ohyes/chat/message-item', array('icon' => $icon, 'message' => OhYesChat::replaceIcon($umessages->message), 'sender' => $umessages->sender));
    }
    echo implode('', $user_msgs);
}
?>
                      
              </div>   
          </div>
         <div class="inner" onClick="OhYesChat.TabOpen('<?php