Version 16.100.1

This commit is contained in:
Antonio Cañas Vargas 2016-12-13 14:54:00 +01:00
parent d9562dc2ab
commit 4de0ee76b1
2 changed files with 15 additions and 5 deletions

View File

@ -187,13 +187,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 16.100 (2016-12-13)"
#define Log_PLATFORM_VERSION "SWAD 16.100.1 (2016-12-13)"
#define CSS_FILE "swad16.97.css"
#define JS_FILE "swad16.99.js"
// 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
/*
Version 16.100.1: Dec 13, 2016 Fixed bugs checking if users share courses. (210828 lines)
Version 16.100: Dec 13, 2016 Changes in layout of list of attendance events.
Code refactoring related with roles. (210820 lines)
Version 16.99.1: Dec 13, 2016 Changes in translation of start and end.

View File

@ -1016,6 +1016,10 @@ bool Usr_CheckIfUsrSharesAnyOfMyCrs (struct UsrData *UsrDat)
return false;
/***** 7. Slow check: Get if user shares any course with me from database *****/
/* Fill the list with the courses I belong to (if not already filled) */
Usr_GetMyCourses ();
/* Check if user shares any course with me */
sprintf (Query,"SELECT COUNT(*) FROM crs_usr"
" WHERE UsrCod='%ld'"
" AND CrsCod IN (SELECT CrsCod FROM my_courses_tmp)",
@ -1038,12 +1042,17 @@ bool Usr_CheckIfUsrSharesAnyOfMyCrsWithDifferentRole (long UsrCod)
if (!Gbl.Usrs.Me.Logged)
return false;
/***** Remove temporary table if exists *****/
/***** 2. Slow check: Get if user shares any course with me
with a different role, from database *****/
/* Fill the list with the courses I belong to (if not already filled) */
Usr_GetMyCourses ();
/* 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 *****/
/* 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,Role)) ENGINE=MEMORY"
@ -1052,13 +1061,13 @@ bool Usr_CheckIfUsrSharesAnyOfMyCrsWithDifferentRole (long 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,usr_courses_tmp"
" WHERE my_courses_tmp.CrsCod=usr_courses_tmp.CrsCod"
" AND my_courses_tmp.Role<>usr_courses_tmp.Role");
UsrSharesAnyOfMyCrsWithDifferentRole = (DB_QueryCOUNT (Query,"can not check if a user shares any course with you") != 0);
/***** Remove temporary table if exists *****/
/* 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");