本文整理汇总了PHP中Chat类的典型用法代码示例。如果您正苦于以下问题:PHP Chat类的具体用法?PHP Chat怎么用?PHP Chat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Chat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onLogoutSuccess
/**
* @param Request $request
* @return null|RedirectResponse
*/
public function onLogoutSuccess(Request $request)
{
// Chamilo logout
$request->getSession()->remove('_locale');
$request->getSession()->remove('_locale_user');
if (api_is_global_chat_enabled()) {
$chat = new \Chat();
$chat->setUserStatus(0);
}
$userId = $this->storage->getToken()->getUser()->getId();
$tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql = "SELECT login_id, login_date\n FROM {$tbl_track_login}\n WHERE login_user_id = {$userId}\n ORDER BY login_date DESC\n LIMIT 0,1";
$row = Database::query($sql);
$loginId = null;
if (Database::num_rows($row) > 0) {
$loginId = Database::result($row, 0, "login_id");
}
$loginAs = $this->checker->isGranted('ROLE_PREVIOUS_ADMIN');
if (!$loginAs) {
$current_date = api_get_utc_datetime();
$sql = "UPDATE {$tbl_track_login}\n SET logout_date='" . $current_date . "'\n \t\t WHERE login_id='{$loginId}'";
Database::query($sql);
}
$online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$query = "DELETE FROM " . $online_table . " WHERE login_user_id = {$userId}";
Database::query($query);
require_once api_get_path(SYS_PATH) . 'main/chat/chat_functions.lib.php';
exit_of_chat($userId);
$login = $this->router->generate('home');
$response = new RedirectResponse($login);
return $response;
}
示例2: getSpecific
public function getSpecific()
{
$username = Input::get('username');
$chat = new Chat();
$result = $chat->getChat($username);
return json_encode($result);
}
示例3: render_chat
function render_chat($league_id){
require_once(APPPATH.'controllers/chat.php');
$chat = new Chat();
$chat->index($league_id);
}
示例4: getChatMessages
/**
* @param \Chat\Bundle\CommonBundle\Entity\Chat $chat
* @param array $hashList
* @return array
*/
public function getChatMessages(Chat $chat, $hashList = array())
{
$messages = $this->_em->getConnection()->fetchAll('
SELECT
cm.id,
cm.hash,
cm.content,
cm.createAt,
m.username,
m.textColor,
m.backgroundColor
FROM
`chat_message` cm
LEFT JOIN
`chat_member` m ON m.id = cm.member_id
WHERE
cm.`chat_id` = :chat_id
AND cm.hash NOT IN (' . implode(',', $hashList) . ')
ORDER BY
cm.create_at ASC
', array('chat_id' => $chat->getId()));
foreach ($messages as $key => $value) {
$createAt = new \DateTime($value['create_at']);
$value['create_at'] = $createAt->format('m.d.y g:i a');
$messages[$key] = $value;
}
return $messages;
}
示例5: get_ticket
public function get_ticket()
{
//获取 component_verify_ticket 每十分钟微信服务本服务器请求一次
$wechat = new Chat($this->config);
$data = $wechat->request();
// print_r($data);die;
if (isset($data['InfoType'])) {
if ($data['InfoType'] == 'component_verify_ticket') {
if (isset($data['ComponentVerifyTicket']) && $data['ComponentVerifyTicket']) {
if ($config = D('Config')->where("`name`='wx_componentverifyticket'")->find()) {
D('Config')->where("`name`='wx_componentverifyticket'")->data(array('value' => $data['ComponentVerifyTicket']))->save();
} else {
D('Config')->data(array('name' => 'wx_componentverifyticket', 'value' => $data['ComponentVerifyTicket'], 'type' => 'type=text', 'gid' => 0, 'tab_id' => 0))->add();
}
S(C('now_city') . 'config', null);
exit('success');
}
} elseif ($data['InfoType'] == 'unauthorized') {
if (isset($data['AuthorizerAppid']) && $data['AuthorizerAppid']) {
D('Weixin_bind')->where("`authorizer_appid`='{$data['AuthorizerAppid']}'")->delete();
exit('success');
}
}
}
}
示例6: onDisconnected
function onDisconnected()
{
// We reset the Chat view
$c = new Chat();
$c->ajaxGet();
$this->refreshRooms();
Notification::append(null, $this->__('chatrooms.disconnected'));
}
示例7: save
function save($id = FALSE)
{
if ($_POST) {
$chat = new Chat($id);
$_POST['user_id'] = $this->session->userdata('id');
$chat->from_array($_POST);
$chat->save();
set_notify('success', lang('save_data_complete'));
}
redirect('chats/admin/chats');
}
示例8: 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;
}
}
示例9: editorFileManager
/**
* @Route("/editor/filemanager", name="editor_filemanager")
* @Method({"GET"})
*/
public function editorFileManager(Request $request)
{
\Chat::setDisableChat();
$courseId = $request->get('course_id');
$sessionId = $request->get('session_id');
return $this->render('@ChamiloCore/default/javascript/editor/ckeditor/elfinder.html.twig', ['course_id' => $courseId, 'session_id' => $sessionId]);
}
示例10: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Chat::create([]);
}
}
示例11: sc_chat_shortcode_offline
/**
* Chat offline shortcode
*
* @access public
* @return string
*/
function sc_chat_shortcode_offline($atts, $content = '')
{
// Check if all OPs offline
if (!Chat::check_if_any_op_online()) {
return $content;
}
}
示例12: getInstance
/**
* 单例方法
*/
public static function getInstance()
{
if (!self::$server instanceof Chat) {
self::$server = new self();
}
return self::$server;
}
示例13: setIsSystem
public function setIsSystem($isSystem = ChatMessageManager::IS_SYSTEM_YES)
{
if (!in_array($isSystem, Chat::getConstsArray('IS_SYSTEM'))) {
throw new InvalidArgumentException("Invalid \$isSystem specified");
}
$this->qb->andWhere($this->qb->expr()->equal(new Field("is_system", "chat_msg"), $isSystem));
return $this;
}
示例14: loadModelById
public function loadModelById($id)
{
$model = Chat::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
} else {
return $model;
}
}
示例15: getChatByID
public static function getChatByID($chatID)
{
include 'connect.php';
$sql = "SELECT * FROM chats WHERE id = {$chatID}";
//echo $sql;
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
mysql_close();
if ($row) {
$chat = new Chat();
$chat->setChatID($row['id']);
$chat->setUser1($row['user1']);
$chat->setUser2($row['user2']);
return $chat;
} else {
return false;
}
}