mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-20 15:35:42 +02:00
Version 16.1
This commit is contained in:
parent
abb8ffc460
commit
27a0ea16d4
|
@ -139,13 +139,14 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 16.0 (2016-09-22)"
|
#define Log_PLATFORM_VERSION "SWAD 16.1 (2016-09-22)"
|
||||||
#define CSS_FILE "swad15.229.css"
|
#define CSS_FILE "swad15.229.css"
|
||||||
#define JS_FILE "swad15.238.1.js"
|
#define JS_FILE "swad15.238.1.js"
|
||||||
|
|
||||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
||||||
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
|
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
|
||||||
/*
|
/*
|
||||||
|
Version 16.1: Sep 22, 2016 Temporary table with other user's courses. (204828 lines)
|
||||||
Version 16.0: Sep 22, 2016 Temporary table with my courses.
|
Version 16.0: Sep 22, 2016 Temporary table with my courses.
|
||||||
Added indexes to database. (204811 lines)
|
Added indexes to database. (204811 lines)
|
||||||
1 change necessary in database:
|
1 change necessary in database:
|
||||||
|
|
34
swad_user.c
34
swad_user.c
|
@ -863,7 +863,7 @@ unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,
|
||||||
if (mysql_query (&Gbl.mysql,Query))
|
if (mysql_query (&Gbl.mysql,Query))
|
||||||
DB_ExitOnMySQLError ("can not remove temporary tables");
|
DB_ExitOnMySQLError ("can not remove temporary tables");
|
||||||
|
|
||||||
/***** Create temporary table with all my courses for a role *****/
|
/***** Create temporary table with all user's courses for a role *****/
|
||||||
sprintf (Query,"CREATE TEMPORARY TABLE IF NOT EXISTS usr_courses_tmp"
|
sprintf (Query,"CREATE TEMPORARY TABLE IF NOT EXISTS usr_courses_tmp"
|
||||||
" (CrsCod INT NOT NULL,UNIQUE INDEX (CrsCod))"
|
" (CrsCod INT NOT NULL,UNIQUE INDEX (CrsCod))"
|
||||||
" ENGINE=MEMORY"
|
" ENGINE=MEMORY"
|
||||||
|
@ -912,14 +912,34 @@ bool Usr_CheckIfUsrSharesAnyOfMyCrs (long UsrCod)
|
||||||
bool Usr_CheckIfUsrSharesAnyOfMyCrsWithDifferentRole (long UsrCod)
|
bool Usr_CheckIfUsrSharesAnyOfMyCrsWithDifferentRole (long UsrCod)
|
||||||
{
|
{
|
||||||
char Query[512];
|
char Query[512];
|
||||||
|
bool UsrSharesAnyOfMyCrsWithDifferentRole;
|
||||||
|
|
||||||
|
/***** Remove temporary table if exists *****/
|
||||||
|
sprintf (Query,"DROP TEMPORARY TABLE IF EXISTS usr_courses_tmp");
|
||||||
|
if (mysql_query (&Gbl.mysql,Query))
|
||||||
|
DB_ExitOnMySQLError ("can not remove temporary tables");
|
||||||
|
|
||||||
|
/***** Create temporary table with all user's courses for a role *****/
|
||||||
|
sprintf (Query,"CREATE TEMPORARY TABLE IF NOT EXISTS usr_courses_tmp "
|
||||||
|
"(CrsCod INT NOT NULL,Role TINYINT NOT NULL,"
|
||||||
|
"UNIQUE INDEX(CrsCod),INDEX(Role)) ENGINE=MEMORY"
|
||||||
|
" SELECT CrsCod,Role FROM crs_usr WHERE UsrCod='%ld'",
|
||||||
|
UsrCod);
|
||||||
|
if (mysql_query (&Gbl.mysql,Query))
|
||||||
|
DB_ExitOnMySQLError ("can not create temporary table");
|
||||||
|
|
||||||
/***** Get if a user shares any course with me from database *****/
|
/***** Get if a user shares any course with me from database *****/
|
||||||
sprintf (Query,"SELECT COUNT(*) FROM my_courses_tmp,"
|
sprintf (Query,"SELECT COUNT(*) FROM my_courses_tmp,usr_courses_tmp"
|
||||||
"(SELECT CrsCod,Role FROM crs_usr WHERE UsrCod='%ld') AS usr_courses"
|
" WHERE my_courses_tmp.CrsCod=usr_courses_tmp.CrsCod"
|
||||||
" WHERE my_courses_tmp.CrsCod=usr_courses.CrsCod"
|
" AND my_courses_tmp.Role<>usr_courses_tmp.Role");
|
||||||
" AND my_courses_tmp.Role<>usr_courses.Role",
|
UsrSharesAnyOfMyCrsWithDifferentRole = (DB_QueryCOUNT (Query,"can not check if a user shares any course with you") != 0);
|
||||||
UsrCod);
|
|
||||||
return (DB_QueryCOUNT (Query,"can not check if a user shares any course with you") != 0);
|
/***** Remove temporary table if exists *****/
|
||||||
|
sprintf (Query,"DROP TEMPORARY TABLE IF EXISTS usr_courses_tmp");
|
||||||
|
if (mysql_query (&Gbl.mysql,Query))
|
||||||
|
DB_ExitOnMySQLError ("can not remove temporary tables");
|
||||||
|
|
||||||
|
return UsrSharesAnyOfMyCrsWithDifferentRole;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user