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


PHP Chat::set_user_status方法代码示例

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


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

示例1: logout

 /**
  * @return void  Directly redirects the user or leaves him where he is, but doesn't return anything
  * @param int $userId
  * @param bool $logout_redirect
  * @author Fernando P. García <fernando@develcuy.com>
  */
 public static function logout($user_id = null, $logout_redirect = false)
 {
     global $extAuthSource;
     // Database table definition
     $tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
     if (empty($user_id)) {
         $user_id = api_get_user_id();
     }
     $user_id = intval($user_id);
     // Changing global chat status to offline
     if (api_is_global_chat_enabled()) {
         $chat = new Chat();
         $chat->set_user_status(0);
     }
     // selecting the last login of the user
     $sql_last_connection = "SELECT login_id, login_date FROM {$tbl_track_login}\n                              WHERE login_user_id='{$user_id}' ORDER BY login_date DESC LIMIT 0,1";
     $q_last_connection = Database::query($sql_last_connection);
     $i_id_last_connection = null;
     if (Database::num_rows($q_last_connection) > 0) {
         $i_id_last_connection = Database::result($q_last_connection, 0, "login_id");
     }
     if (!isset($_SESSION['login_as']) && !empty($i_id_last_connection)) {
         $current_date = api_get_utc_datetime();
         $s_sql_update_logout_date = "UPDATE {$tbl_track_login} SET logout_date='" . $current_date . "' WHERE login_id = '{$i_id_last_connection}'";
         Database::query($s_sql_update_logout_date);
     }
     Online::loginDelete($user_id);
     //from inc/lib/online.inc.php - removes the "online" status
     //the following code enables the use of an external logout function.
     //example: define a $extAuthSource['ldap']['logout']="file.php" in configuration.php
     // then a function called ldap_logout() inside that file
     // (using *authent_name*_logout as the function name) and the following code
     // will find and execute it
     $uinfo = api_get_user_info($user_id);
     if (isset($uinfo['auth_source']) && $uinfo['auth_source'] != PLATFORM_AUTH_SOURCE && is_array($extAuthSource)) {
         if (is_array($extAuthSource[$uinfo['auth_source']])) {
             $subarray = $extAuthSource[$uinfo['auth_source']];
             if (!empty($subarray['logout']) && file_exists($subarray['logout'])) {
                 require_once $subarray['logout'];
                 $logout_function = $uinfo['auth_source'] . '_logout';
                 if (function_exists($logout_function)) {
                     $logout_function($uinfo);
                 }
             }
         }
     }
     require_once api_get_path(SYS_PATH) . 'main/chat/chat_functions.lib.php';
     exit_of_chat($user_id);
     if ($logout_redirect) {
         header("Location: index.php");
         exit;
     }
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:59,代码来源:online.inc.php

示例2: isset

}
if (api_get_setting('allow_global_chat') == 'false') {
    exit;
}
$to_user_id = isset($_GET['to']) ? $_GET['to'] : null;
$message = isset($_GET['message']) ? $_GET['message'] : null;
if (!isset($_SESSION['chatHistory'])) {
    $_SESSION['chatHistory'] = array();
}
if (!isset($_SESSION['openChatBoxes'])) {
    $_SESSION['openChatBoxes'] = array();
}
$chat = new Chat();
if ($chat->is_chat_blocked_by_exercises()) {
    // Disconnect the user
    $chat->set_user_status(0);
    exit;
}
switch ($action) {
    case 'chatheartbeat':
        $chat->heartbeat();
        break;
    case 'closechat':
        $chat->close();
        break;
    case 'sendchat':
        $chat->send(api_get_user_id(), $to_user_id, $message);
        break;
    case 'startchatsession':
        $chat->start_session();
        break;
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:chat.ajax.php


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