Version 21.53.1: Nov 07, 2021 Queries moved to module swad_room_database.

This commit is contained in:
acanas 2021-11-07 00:01:42 +01:00
parent 6d51efdb13
commit cdc0433c05
7 changed files with 45 additions and 91 deletions

View File

@ -121,6 +121,7 @@ cp -f /home/acanas/swad/swad/swad /var/www/cgi-bin/
#include "swad_password.h"
#include "swad_question_database.h"
#include "swad_role.h"
#include "swad_room_database.h"
#include "swad_search.h"
#include "swad_test_config.h"
#include "swad_test_visibility.h"
@ -6057,28 +6058,7 @@ int swad__getLastLocation (struct soap *soap,
The other user does not have to share any course with me,
but at least some course of each one has to share center.
*/
if (DB_QueryEXISTS ("can not check if you can see user location",
"SELECT EXISTS"
"(SELECT *"
" FROM (SELECT DISTINCT "
"deg_degrees.CtrCod"
" FROM crs_users,"
"crs_courses,"
"deg_degrees"
" WHERE crs_users.UsrCod=%ld"
" AND crs_users.CrsCod=crs_courses.CrsCod"
" AND crs_courses.DegCod=deg_degrees.DegCod) AS C1," // centers of my courses
"(SELECT DISTINCT "
"deg_degrees.CtrCod"
" FROM crs_users,"
"crs_courses,"
"deg_degrees"
" WHERE crs_users.UsrCod=%d"
" AND crs_users.CrsCod=crs_courses.CrsCod"
" AND crs_courses.DegCod=deg_degrees.DegCod) AS C2" // centers of user's courses
" WHERE C1.CtrCod=C2.CtrCod)",
Gbl.Usrs.Me.UsrDat.UsrCod,
userCode))
if (Roo_DB_CheckIfICanSeeUsrLocation ((long) userCode))
{
/***** Get list of locations *****/
NumLocs = (unsigned)

View File

@ -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 21.53 (2021-11-06)"
#define Log_PLATFORM_VERSION "SWAD 21.53.1 (2021-11-07)"
#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 21.53.1: Nov 07, 2021 Queries moved to module swad_room_database. (321879 lines)
Version 21.53: Nov 06, 2021 Queries moved to module swad_user_database and other modules. (321926 lines)
Version 21.52.3: Nov 06, 2021 Queries moved to module swad_user_database. (321894 lines)
Version 21.52.2: Nov 06, 2021 Query refactoring related to SELECT DISTINCT and UNION. (321899 lines)

View File

@ -43,8 +43,6 @@
/************** External global variables from others modules ****************/
/*****************************************************************************/
// extern struct Globals Gbl;
/*****************************************************************************/
/************************* Private global variables **************************/
/*****************************************************************************/

View File

@ -26,12 +26,15 @@
/*****************************************************************************/
#include "swad_database.h"
#include "swad_global.h"
#include "swad_room.h"
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
@ -329,6 +332,43 @@ unsigned Roo_DB_GetMACAddresses (MYSQL_RES **mysql_res,long RooCod)
RooCod);
}
/*****************************************************************************/
/********************** Check if I can see user's location *******************/
/*****************************************************************************/
bool Roo_DB_CheckIfICanSeeUsrLocation (long UsrCod)
{
/*
I can only consult the location of another user
if the intersection of the centers of our courses is not empty.
The other user does not have to share any course with me,
but at least some course of each one has to share center.
*/
return
DB_QueryEXISTS ("can not check if you can see user location",
"SELECT EXISTS"
"(SELECT *"
" FROM (SELECT DISTINCT "
"deg_degrees.CtrCod"
" FROM crs_users,"
"crs_courses,"
"deg_degrees"
" WHERE crs_users.UsrCod=%ld"
" AND crs_users.CrsCod=crs_courses.CrsCod"
" AND crs_courses.DegCod=deg_degrees.DegCod) AS C1," // centers of my courses
"(SELECT DISTINCT "
"deg_degrees.CtrCod"
" FROM crs_users,"
"crs_courses,"
"deg_degrees"
" WHERE crs_users.UsrCod=%ld"
" AND crs_users.CrsCod=crs_courses.CrsCod"
" AND crs_courses.DegCod=deg_degrees.DegCod) AS C2" // centers of user's courses
" WHERE C1.CtrCod=C2.CtrCod)",
Gbl.Usrs.Me.UsrDat.UsrCod,
UsrCod);
}
/*****************************************************************************/
/********************************* Remove room *******************************/
/*****************************************************************************/

View File

@ -53,6 +53,7 @@ bool Roo_DB_CheckIfRoomNameExists (long CtrCod,long RooCod,
const char *FieldName,const char *Name);
unsigned Roo_DB_GetDataOfRoomByCod (MYSQL_RES **mysql_res,long RooCod);
unsigned Roo_DB_GetMACAddresses (MYSQL_RES **mysql_res,long RooCod);
bool Roo_DB_CheckIfICanSeeUsrLocation (long UsrCod);
void Roo_DB_RemoveRoom (long RooCod);
void Roo_DB_RemoveMACAddress (long RooCod,unsigned long long MACnum);

View File

@ -25,60 +25,9 @@
/*********************************** Headers *********************************/
/*****************************************************************************/
// #define _GNU_SOURCE // For asprintf
// #include <ctype.h> // For isalnum, isdigit, etc.
// #include <limits.h> // For maximum values
// #include <linux/limits.h> // For PATH_MAX
// #include <stddef.h> // For NULL
// #include <stdio.h> // For asprintf
// #include <stdlib.h> // For exit, system, malloc, free, rand, etc.
// #include <string.h> // For string functions
// #include <sys/wait.h> // For the macro WEXITSTATUS
// #include <unistd.h> // For access, lstat, getpid, chdir, symlink, unlink
// #include "swad_account.h"
// #include "swad_agenda.h"
// #include "swad_announcement.h"
// #include "swad_box.h"
// #include "swad_calendar.h"
// #include "swad_config.h"
// #include "swad_connected_database.h"
// #include "swad_course.h"
#include "swad_database.h"
// #include "swad_department.h"
// #include "swad_duplicate.h"
// #include "swad_enrolment.h"
#include "swad_error.h"
// #include "swad_figure.h"
// #include "swad_figure_cache.h"
// #include "swad_follow.h"
// #include "swad_form.h"
#include "swad_global.h"
// #include "swad_group.h"
// #include "swad_help.h"
// #include "swad_hierarchy.h"
// #include "swad_hierarchy_level.h"
// #include "swad_HTML.h"
// #include "swad_ID.h"
// #include "swad_language.h"
// #include "swad_mail_database.h"
// #include "swad_message.h"
// #include "swad_MFU.h"
// #include "swad_nickname.h"
// #include "swad_nickname_database.h"
// #include "swad_notification.h"
// #include "swad_parameter.h"
// #include "swad_password.h"
// #include "swad_photo.h"
// #include "swad_privacy.h"
// #include "swad_QR.h"
// #include "swad_record.h"
// #include "swad_record_database.h"
// #include "swad_role.h"
// #include "swad_session_database.h"
// #include "swad_setting.h"
// #include "swad_tab.h"
// #include "swad_user.h"
#include "swad_user_database.h"
/*****************************************************************************/

View File

@ -31,23 +31,8 @@
#include <stdbool.h> // For boolean type
#include <sys/types.h> // For time_t
// #include "swad_action.h"
// #include "swad_constant.h"
// #include "swad_country.h"
#include "swad_cryptography.h"
// #include "swad_date.h"
// #include "swad_degree.h"
// #include "swad_icon.h"
// #include "swad_layout.h"
// #include "swad_menu.h"
// #include "swad_nickname.h"
// #include "swad_password.h"
// #include "swad_privacy_visibility_type.h"
// #include "swad_role_type.h"
// #include "swad_scope.h"
#include "swad_search.h"
// #include "swad_string.h"
// #include "swad_theme.h"
/*****************************************************************************/
/****************************** Public constants *****************************/