mirror of
https://github.com/acanas/swad-core.git
synced 2024-09-20 00:02:42 +02:00
Version 20.78: May 19, 2021 New module swad_chat_database for database queries related to chat.
This commit is contained in:
parent
dbfbac03e3
commit
5e0df18bd8
6
Makefile
6
Makefile
|
@ -33,9 +33,9 @@ OBJS = swad_account.o swad_account_database.o swad_action.o swad_agenda.o \
|
|||
swad_banner.o swad_banner_database.o swad_box.o swad_building.o \
|
||||
swad_button.o \
|
||||
swad_calendar.o swad_call_for_exam.o swad_center.o \
|
||||
swad_center_config.o swad_chat.o swad_config.o swad_connected.o \
|
||||
swad_cookie.o swad_country.o swad_country_config.o swad_course.o \
|
||||
swad_course_config.o swad_cryptography.o \
|
||||
swad_center_config.o swad_chat.o swad_chat_database.o swad_config.o \
|
||||
swad_connected.o swad_cookie.o swad_country.o swad_country_config.o \
|
||||
swad_course.o swad_course_config.o swad_cryptography.o \
|
||||
swad_database.o swad_date.o swad_degree.o swad_degree_config.o \
|
||||
swad_degree_type.o swad_department.o swad_duplicate.o \
|
||||
swad_enrolment.o swad_error.o swad_exam.o swad_exam_log.o \
|
||||
|
|
|
@ -25,24 +25,11 @@
|
|||
/********************************* Headers ***********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
// #include <stddef.h> // For NULL
|
||||
// #include <stdlib.h> // For calloc
|
||||
// #include <string.h> // For string functions
|
||||
|
||||
#include "swad_banner.h"
|
||||
#include "swad_banner_database.h"
|
||||
// #include "swad_box.h"
|
||||
// #include "swad_constant.h"
|
||||
#include "swad_config.h"
|
||||
#include "swad_database.h"
|
||||
// #include "swad_error.h"
|
||||
// #include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
// #include "swad_HTML.h"
|
||||
// #include "swad_language.h"
|
||||
// #include "swad_link.h"
|
||||
// #include "swad_parameter.h"
|
||||
// #include "swad_photo.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** External global variables from others modules ****************/
|
||||
|
|
|
@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
|
|||
|
||||
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.77 (2021-05-18)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.78 (2021-05-19)"
|
||||
#define CSS_FILE "swad20.45.css"
|
||||
#define JS_FILE "swad20.69.1.js"
|
||||
/*
|
||||
TODO: Rename CENTRE to CENTER in help wiki.
|
||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||
|
||||
Version 20.78: May 19, 2021 New module swad_chat_database for database queries related to chat. (311327 lines)
|
||||
Version 20.77: May 18, 2021 New module swad_banner_database for database queries related to banners. (311249 lines)
|
||||
Version 20.76: May 11, 2021 New module swad_atendance_database for database queries related to attendance events. (311109 lines)
|
||||
Version 20.75: May 11, 2021 New module swad_assignment_database for database queries related to assignments. (310858 lines)
|
||||
|
|
52
swad_chat.c
52
swad_chat.c
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "swad_box.h"
|
||||
#include "swad_chat.h"
|
||||
#include "swad_chat_database.h"
|
||||
#include "swad_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
|
@ -70,7 +71,6 @@ extern struct Globals Gbl;
|
|||
static void Cht_WriteLinkToChat1 (const char *RoomCode,const char *RoomShrtName,const char *RoomFullName,
|
||||
unsigned Level,bool IsLastItemInLevel[1 + Cht_CHAT_MAX_LEVELS]);
|
||||
static void Cht_WriteLinkToChat2 (const char *RoomCode,const char *RoomFullName);
|
||||
static unsigned Cht_GetNumUsrsInChatRoom (const char *RoomCode);
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************** List available whiteboard/chat rooms *********************/
|
||||
|
@ -128,6 +128,8 @@ void Cht_ShowListOfAvailableChatRooms (void)
|
|||
Box_BoxBegin (NULL,Txt_Chat_rooms,
|
||||
NULL,NULL,
|
||||
NULL,Box_NOT_CLOSABLE);
|
||||
|
||||
/***** Begin list *****/
|
||||
HTM_UL_Begin ("class=\"LIST_TREE\"");
|
||||
|
||||
/***** Title of top level *****/
|
||||
|
@ -223,8 +225,10 @@ void Cht_ShowListOfAvailableChatRooms (void)
|
|||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
|
||||
/***** End box *****/
|
||||
/***** End list *****/
|
||||
HTM_UL_End ();
|
||||
|
||||
/***** End box *****/
|
||||
Box_BoxEnd ();
|
||||
}
|
||||
|
||||
|
@ -243,14 +247,7 @@ void Cht_ShowListOfChatRoomsWithUsrs (void)
|
|||
unsigned NumRoom;
|
||||
|
||||
/***** Get chat rooms with connected users from database *****/
|
||||
NumRooms = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get chat rooms with connected users",
|
||||
"SELECT RoomCode," // row[0]
|
||||
"NumUsrs" // row[1]
|
||||
" FROM cht_rooms"
|
||||
" WHERE NumUsrs>0"
|
||||
" ORDER BY NumUsrs DESC,"
|
||||
"RoomCode");
|
||||
NumRooms = Cht_DB_GetListOfChatRoomsWithUsrs (&mysql_res);
|
||||
if (NumRooms) // If not empty chat rooms found
|
||||
{
|
||||
/***** Begin box and table *****/
|
||||
|
@ -260,10 +257,8 @@ void Cht_ShowListOfChatRoomsWithUsrs (void)
|
|||
|
||||
/***** Write heading *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
HTM_TH (1,1,"CM LIGHT_BLUE",Txt_CHAT_Room_code);
|
||||
HTM_TH (1,1,"LM LIGHT_BLUE",Txt_Number_of_users);
|
||||
|
||||
HTM_TR_End ();
|
||||
|
||||
/***** Loop over chat rooms *****/
|
||||
|
@ -304,11 +299,17 @@ static void Cht_WriteLinkToChat1 (const char *RoomCode,const char *RoomShrtName,
|
|||
{
|
||||
extern const char *The_ClassFormLinkInBox[The_NUM_THEMES];
|
||||
|
||||
/***** Begin list item *****/
|
||||
HTM_LI_Begin (NULL);
|
||||
|
||||
Lay_IndentDependingOnLevel (Level,IsLastItemInLevel);
|
||||
|
||||
/***** Begin form *****/
|
||||
Frm_BeginForm (ActCht);
|
||||
|
||||
Cht_WriteParamsRoomCodeAndNames (RoomCode,RoomShrtName,RoomFullName);
|
||||
|
||||
/* Begin button */
|
||||
HTM_BUTTON_SUBMIT_Begin (RoomFullName,The_ClassFormLinkInBox[Gbl.Prefs.Theme],NULL);
|
||||
}
|
||||
|
||||
|
@ -316,20 +317,30 @@ static void Cht_WriteLinkToChat2 (const char *RoomCode,const char *RoomFullName)
|
|||
{
|
||||
extern const char *Txt_connected_PLURAL;
|
||||
extern const char *Txt_connected_SINGULAR;
|
||||
unsigned NumUsrsInRoom = Cht_GetNumUsrsInChatRoom (RoomCode);
|
||||
unsigned NumUsrsInRoom = Cht_DB_GetNumUsrsInChatRoom (RoomCode);
|
||||
|
||||
/* Begin strong if room has users */
|
||||
if (NumUsrsInRoom)
|
||||
HTM_STRONG_Begin ();
|
||||
|
||||
/* Room name and users */
|
||||
HTM_TxtF (" %s",RoomFullName);
|
||||
if (NumUsrsInRoom > 1)
|
||||
HTM_TxtF (" [%d %s]",NumUsrsInRoom,Txt_connected_PLURAL);
|
||||
else if (NumUsrsInRoom == 1)
|
||||
HTM_TxtF (" [1 %s]",Txt_connected_SINGULAR);
|
||||
|
||||
/* End strong if room has users */
|
||||
if (NumUsrsInRoom)
|
||||
HTM_STRONG_End ();
|
||||
|
||||
/* End button */
|
||||
HTM_BUTTON_End ();
|
||||
|
||||
/***** End form *****/
|
||||
Frm_EndForm ();
|
||||
|
||||
/***** End list item *****/
|
||||
HTM_LI_End ();
|
||||
}
|
||||
|
||||
|
@ -344,21 +355,6 @@ void Cht_WriteParamsRoomCodeAndNames (const char *RoomCode,const char *RoomShrtN
|
|||
Par_PutHiddenParamString (NULL,"RoomFullName",RoomFullName);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Get number of users connected to a chat room ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static unsigned Cht_GetNumUsrsInChatRoom (const char *RoomCode)
|
||||
{
|
||||
/***** Get number of users connected to chat rooms from database *****/
|
||||
return DB_QuerySELECTUnsigned ("can not get number of users"
|
||||
" connected to a chat room",
|
||||
"SELECT NumUsrs"
|
||||
" FROM cht_rooms"
|
||||
" WHERE RoomCode='%s'",
|
||||
RoomCode);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************* Enter a chat room ***************************/
|
||||
/*****************************************************************************/
|
||||
|
|
Loading…
Reference in New Issue
Block a user