当前位置: 首页>>代码示例>>PHP>>正文


PHP Chat::send_contact_from方法代码示例

本文整理汇总了PHP中Chat::send_contact_from方法的典型用法代码示例。如果您正苦于以下问题:PHP Chat::send_contact_from方法的具体用法?PHP Chat::send_contact_from怎么用?PHP Chat::send_contact_from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Chat的用法示例。


在下文中一共展示了Chat::send_contact_from方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sc_chat_ajax_callback

/**
 * Ajax Callback
 *
 * @access public
 * @return void
 */
function sc_chat_ajax_callback()
{
    $response = array();
    try {
        // Handling the supported actions:
        switch ($_GET['mode']) {
            case 'login':
                $response = Chat::login(@$_POST['f_chat_user_name'], @$_POST['f_chat_user_email'], $_POST['f_chat_is_admin']);
                break;
            case 'send_contact_from':
                $response = Chat::send_contact_from($_POST);
                break;
            case 'is_user_logged_in':
                $response = Chat::is_user_logged_in();
                break;
            case 'logout':
                $response = Chat::logout();
                break;
            case 'online':
                $response = Chat::online();
                break;
            case 'offline':
                $response = Chat::offline();
                break;
            case 'send_chat_msg':
                $response = Chat::send_chat_msg($_POST);
                break;
            case 'get_online_users':
                $response = Chat::get_online_users();
                break;
            case 'get_chat_lines':
                $response = Chat::get_chat_lines($_GET['last_log_ID'], $_GET['sender']);
                break;
            case 'user_info':
                $response = Chat::user_info($_GET['ID']);
                break;
            default:
                throw new Exception('Wrong action');
        }
    } catch (Exception $e) {
        $response['error'] = $e->getMessage();
    }
    // Response output
    header("Content-Type: application/json");
    echo json_encode($response);
    exit;
}
开发者ID:k2jysy,项目名称:mergeshop,代码行数:53,代码来源:fn.init.php

示例2: send_chat_msg

 /**
  * Send chat message
  *
  * @access public
  * @return array
  */
 public static function send_chat_msg($params)
 {
     // Get user data from session
     $chat_user_name = $_SESSION['sc_chat']['chat_user_name'];
     $chat_user_gravatar = $_SESSION['sc_chat']['chat_user_gravatar'];
     $chat_user_email = $_SESSION['sc_chat']['chat_user_email'];
     // First check if any OP is online
     if (!Chat::check_if_any_op_online()) {
         // Logout user
         Chat::logout();
         // Prepare email data for last message
         $data = array('f_chat_user_name' => $chat_user_name, 'f_chat_user_email' => $chat_user_email, 'f_chat_user_question' => $params['chat_line'], 'prefix' => '(!) ' . strtoupper(__('User has been sent this message after you disconnected from chat', 'sc_chat')) . ": \r\n\r\n");
         // Send email now
         $email = Chat::send_contact_from($data);
         if (!empty($email['error'])) {
             throw new Exception($email['error']);
         } else {
             throw new Exception(__("We are offline now. However, your message has been sent to us by email. We will contact you as soon as possible", 'sc_chat'));
         }
     }
     if (empty($chat_user_name)) {
         throw new Exception(__('You are not logged in', 'sc_chat'));
     }
     if (empty($params['chat_line'])) {
         throw new Exception(__("You haven't entered a chat message", 'sc_chat'));
     }
     // If receiver ID empty, make it __OP__
     if (current_user_can('chat_with_users') and !empty($params['receiver_ID'])) {
         $receiver_ID = sanitize_key($params['receiver_ID']);
     } else {
         $receiver_ID = '__OP__';
     }
     // sent by visitor
     // Prepare chat line data
     $chat = new Chat_line(array('author' => $chat_user_name, 'gravatar' => $chat_user_gravatar, 'visitor_ID' => !empty($params['visitor_ID']) ? $params['visitor_ID'] : null, 'receiver_ID' => $receiver_ID, 'email' => $chat_user_email, 'chat_line' => Chat::sanitize_chat_line($params['chat_line'])));
     // Save chat message
     $insert_ID = $chat->save();
     return array('status' => 1, 'insert_ID' => $insert_ID);
 }
开发者ID:k2jysy,项目名称:mergeshop,代码行数:45,代码来源:class.chat.php


注:本文中的Chat::send_contact_from方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。