From ffe019a50a6433d9f0117a51dea13656b15d5ecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 21 Sep 2017 01:33:23 +0200 Subject: [PATCH] Version 17.5 --- swad_changelog.h | 3 ++- swad_project.c | 57 +++++++++++++++++++++++++++++++++++++++++--- swad_text.c | 62 +++++++++++++++++------------------------------- 3 files changed, 78 insertions(+), 44 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index bc0e59516..df2261633 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -252,13 +252,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 17.4.3 (2017-09-21)" +#define Log_PLATFORM_VERSION "SWAD 17.5 (2017-09-21)" #define CSS_FILE "swad17.0.css" #define JS_FILE "swad16.206.3.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 17.5: Sep 21, 2017 Users can be added to a project. (230250 lines) Version 17.4.3: Sep 21, 2017 Changes in listing and edition of projects. (230222 lines) Version 17.4.2: Sep 20, 2017 Changes in listing and edition of projects. (230203 lines) Version 17.4.1: Sep 20, 2017 Changes adding users to a project. Not finished. (230141 lines) diff --git a/swad_project.c b/swad_project.c index 652d5bd86..607190cd7 100644 --- a/swad_project.c +++ b/swad_project.c @@ -743,12 +743,63 @@ void Prj_AddRev (void) static void Prj_AddUsrToProject (Prj_RoleInProject_t RoleInProject) { + extern const char *Txt_THE_USER_X_has_been_enroled_in_the_project; + extern const char *Txt_THE_USER_X_already_exists_in_Y_but_is_not_yet_enroled_in_the_course_Z; + extern const char *Txt_User_not_found_or_you_do_not_have_permission_; + long PrjCod; + struct ListUsrCods ListUsrCods; + unsigned NumUsr; + char Query[512]; + /***** Get project code *****/ - if ((Gbl.Prjs.PrjCodToEdit = Prj_GetParamPrjCod ()) == -1L) + if ((PrjCod = Prj_GetParamPrjCod ()) == -1L) Lay_ShowErrorAndExit ("Code of project is missing."); - if (RoleInProject != Prj_ROLE_UNK) // TODO: Remove - Ale_ShowAlert (Ale_WARNING,"Not yet implemented."); + /***** Use user's ID to identify the user(s) to be enroled /removed *****/ + Usr_GetParamOtherUsrIDNickOrEMailAndGetUsrCods (&ListUsrCods); + + if (ListUsrCods.NumUsrs) // User(s) found with the ID + { + /***** For each user found... *****/ + for (NumUsr = 0; + NumUsr < ListUsrCods.NumUsrs; + NumUsr++) + { + /* Get user's data */ + Gbl.Usrs.Other.UsrDat.UsrCod = ListUsrCods.Lst[NumUsr]; + Usr_GetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat); + + /* Check if this user belongs to the current course */ + if (Usr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Other.UsrDat)) + { + /***** Add user to project *****/ + sprintf (Query,"REPLACE INTO prj_usr" + " (PrjCod,RoleInProject,UsrCod)" + " VALUES" + " (%ld,%u,%ld)", + PrjCod,(unsigned) RoleInProject,Gbl.Usrs.Other.UsrDat.UsrCod); + DB_QueryREPLACE (Query,"can not add user to project"); + + sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_has_been_enroled_in_the_project, + Gbl.Usrs.Other.UsrDat.FullName); + Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); + } + else // User does not belong to the current course + { + sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_already_exists_in_Y_but_is_not_yet_enroled_in_the_course_Z, + Gbl.Usrs.Other.UsrDat.FullName,Cfg_PLATFORM_SHORT_NAME,Gbl.CurrentCrs.Crs.FullName); + Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); + } + } + + /***** Free list of users' codes *****/ + Usr_FreeListUsrCods (&ListUsrCods); + } + else // No users found + Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); + + /***** Put form to edit project again *****/ + Prj_RequestCreatOrEditPrj (PrjCod); } /*****************************************************************************/ diff --git a/swad_text.c b/swad_text.c index 51698f37b..fc43a0d57 100644 --- a/swad_text.c +++ b/swad_text.c @@ -47504,6 +47504,27 @@ const char *Txt_THE_USER_X_already_exists_in_Y_but_is_not_yet_enroled_in_the_cou " in the course %s."; // Necessita de tradução #endif +const char *Txt_THE_USER_X_has_been_enroled_in_the_project = // Warning: it is very important to include %s in the following sentences +#if L==1 + "%s ha estat afegit/da al projecte."; +#elif L==2 + "%s hat sich im Projekt eingeschrieben."; +#elif L==3 + "%s has been enroled in the project."; +#elif L==4 + "%s ha sido añadido/a al proyecto."; +#elif L==5 + "%s a été inscrit dans le projet."; +#elif L==6 + "%s ha sido añadido/a al proyecto."; // Okoteve traducción +#elif L==7 + "%s è stato registrato/a nel progetto."; +#elif L==8 + "%s został zapisany do projektu."; +#elif L==9 + "%s foi matriculado/a no projeto."; +#endif + const char *Txt_THE_USER_X_has_been_enroled_as_administrator_of_Y = // Warning: it is very important to include two %s in the following sentences #if L==1 "%s ha sido inscrito/a" @@ -47539,7 +47560,7 @@ const char *Txt_THE_USER_X_has_been_enroled_in_the_course_Y = // Warning: it is "%s ha estat afegit/da" " a l'assignatura %s."; #elif L==2 - "%s hat sich im" + "%s hat sich" " im Kurs %s eingeschrieben."; #elif L==3 "%s has been enroled" @@ -48575,45 +48596,6 @@ const char *Txt_There_is_no_user_with_ID_nick_or_email_X = // Warning: it is ver " with ID, nick or email %s."; // Necessita de tradução #endif -const char *Txt_There_is_no_user_with_ID_nick_or_e_mail_X_in_the_course_Y = // Warning: it is very important to include two %s in the following sentences -#if L==1 - "No existe ningún usuario" - " con ID (DNI/cédula), apodo o correo %s" - " en la asignatura %s."; // Necessita traduccio -#elif L==2 - "There is no user" - " with ID, nick or email %s" - " in the course %s."; // Übersetzung notwendig -#elif L==3 - "There is no user" - " with ID, nick or email %s" - " in the course %s."; -#elif L==4 - "No existe ningún usuario" - " con ID (DNI/cédula), apodo o correo %s" - " en la asignatura %s."; -#elif L==5 - "There is no user" - " with ID, nick or email %s" - " in the course %s."; // Besoin de traduction -#elif L==6 - "No existe ningún usuario" - " con ID (DNI/cédula), apodo o correo %s" - " en la asignatura %s."; // Okoteve traducción -#elif L==7 - "Non c'è alcun utente" - " con ID, nome utente o email %s" - " nel corso %s."; -#elif L==8 - "There is no user" - " with ID, nick or email %s" - " in the course %s."; // Potrzebujesz tlumaczenie -#elif L==9 - "There is no user" - " with ID, nick or email %s" - " in the course %s."; // Necessita de tradução -#endif - const char *Txt_There_is_no_user_with_nickname_X = // Warning: it is very important to include %s in the following sentences #if L==1 "No existe ningún usuario"