From 4de0ee76b1d3fcf4a10b44d17f00e3aedc4ad3c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Tue, 13 Dec 2016 14:54:00 +0100 Subject: [PATCH] Version 16.100.1 --- swad_changelog.h | 3 ++- swad_user.c | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index c07cababf..650a022d2 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -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. diff --git a/swad_user.c b/swad_user.c index 17b855fb7..cca67348e 100644 --- a/swad_user.c +++ b/swad_user.c @@ -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");