diff --git a/swad_changelog.h b/swad_changelog.h index c41054046..18a73c435 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -448,10 +448,11 @@ En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 18.116.2 (2019-04-20)" +#define Log_PLATFORM_VERSION "SWAD 18.116.3 (2019-04-20)" #define CSS_FILE "swad18.112.1.css" #define JS_FILE "swad18.114.js" /* + Version 18.116.3: Apr 20, 2019 Changed the behaviour of hiding/showing a project. (243105 lines) Version 18.116.2: Apr 20, 2019 Code refactoring in announcements and notices. (243124 lines) Version 18.116.1: Apr 20, 2019 Code refactoring in edition of banners. (243246 lines) Version 18.116: Apr 19, 2019 Code refactoring related to actions and AJAX. (243246 lines) diff --git a/swad_project.c b/swad_project.c index 35c9fad63..f94d32958 100644 --- a/swad_project.c +++ b/swad_project.c @@ -144,6 +144,8 @@ static void Prj_PutIconsToLockUnlockAllProjects (void); static void Prj_ShowOneProject (unsigned NumIndex,struct Project *Prj, Prj_ProjectView_t ProjectView); +static void Prj_SetAnchorStr (long PrjCod,char **Anchor); +static void Prj_FreeAnchorStr (char *Anchor); static void Prj_PutIconToToggleProject (unsigned UniqueId, const char *Icon,const char *Text); static void Prj_ShowTableAllProjectsOneRow (struct Project *Prj); @@ -184,6 +186,7 @@ static void Prj_RemUsrFromPrj (Prj_RoleInProject_t RoleInProject); static void Prj_GetParamPrjOrder (void); static void Prj_PutFormsToRemEditOnePrj (const struct Project *Prj, + const char *Anchor, bool ICanViewProjectFiles); static bool Prj_CheckIfICanEditProject (const struct Project *Prj); @@ -972,9 +975,13 @@ static void Prj_ShowOneProject (unsigned NumIndex,struct Project *Prj, extern const char *Txt_Description; extern const char *Txt_Required_knowledge; extern const char *Txt_Required_materials; + char *Anchor = NULL; static unsigned UniqueId = 0; bool ICanViewProjectFiles = Prj_CheckIfICanViewProjectFiles (Prj_GetMyRolesInProject (Prj->PrjCod)); + /***** Set anchor string *****/ + Prj_SetAnchorStr (Prj->PrjCod,&Anchor); + /***** Write first row of data of this project *****/ fprintf (Gbl.F.Out,""); @@ -982,12 +989,13 @@ static void Prj_ShowOneProject (unsigned NumIndex,struct Project *Prj, switch (ProjectView) { case Prj_LIST_PROJECTS: - fprintf (Gbl.F.Out,"", + fprintf (Gbl.F.Out,"", Prj->Hidden == Prj_HIDDEN ? "DATE_BLUE_LIGHT" : "DATE_BLUE", Gbl.RowEvenOdd); - if (NumIndex > 0) - fprintf (Gbl.F.Out,"
%u
",NumIndex); + Lay_StartArticle (Anchor); + fprintf (Gbl.F.Out,"%u",NumIndex); + Lay_EndArticle (); fprintf (Gbl.F.Out,""); break; default: @@ -1003,7 +1011,7 @@ static void Prj_ShowOneProject (unsigned NumIndex,struct Project *Prj, if (ProjectView == Prj_LIST_PROJECTS) fprintf (Gbl.F.Out," COLOR%u",Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"\">"); - Prj_PutFormsToRemEditOnePrj (Prj,ICanViewProjectFiles); + Prj_PutFormsToRemEditOnePrj (Prj,Anchor,ICanViewProjectFiles); fprintf (Gbl.F.Out,""); break; default: @@ -1238,9 +1246,37 @@ static void Prj_ShowOneProject (unsigned NumIndex,struct Project *Prj, /* Link to view more info about the project */ Prj_ShowOneProjectURL (Prj,ProjectView,"prj_url_",UniqueId); + /***** Free anchor string *****/ + Prj_FreeAnchorStr (Anchor); + Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; } +/*****************************************************************************/ +/****************** Build/free anchor string for a project *******************/ +/*****************************************************************************/ + +static void Prj_SetAnchorStr (long PrjCod,char **Anchor) + { + if (PrjCod > 0) + { + if (asprintf (Anchor,"prj_%ld", + PrjCod) < 0) + Lay_NotEnoughMemoryExit (); + } + else + *Anchor = NULL; + } + +static void Prj_FreeAnchorStr (char *Anchor) + { + if (Anchor) + { + free ((void *) Anchor); + Anchor = NULL; + } + } + /*****************************************************************************/ /********** Put an icon to toggle on/off some fields of a project ************/ /*****************************************************************************/ @@ -2238,6 +2274,7 @@ void Prj_PutHiddenParamPrjOrder (void) /*****************************************************************************/ static void Prj_PutFormsToRemEditOnePrj (const struct Project *Prj, + const char *Anchor, bool ICanViewProjectFiles) { Gbl.Prjs.PrjCod = Prj->PrjCod; // Used as parameter in contextual links @@ -2251,10 +2288,10 @@ static void Prj_PutFormsToRemEditOnePrj (const struct Project *Prj, switch (Prj->Hidden) { case Prj_HIDDEN: - Ico_PutContextualIconToUnhide (ActShoPrj,NULL,Prj_PutCurrentParams); + Ico_PutContextualIconToUnhide (ActShoPrj,Anchor,Prj_PutCurrentParams); break; case Prj_VISIBL: - Ico_PutContextualIconToHide (ActHidPrj,NULL,Prj_PutCurrentParams); + Ico_PutContextualIconToHide (ActHidPrj,Anchor,Prj_PutCurrentParams); break; } @@ -2907,7 +2944,6 @@ void Prj_RemoveProject (void) void Prj_HideProject (void) { - extern const char *Txt_Project_X_is_now_hidden; struct Project Prj; /***** Allocate memory for the project *****/ @@ -2922,17 +2958,11 @@ void Prj_HideProject (void) Prj_GetDataOfProjectByCod (&Prj); if (Prj_CheckIfICanEditProject (&Prj)) - { /***** Hide project *****/ DB_QueryUPDATE ("can not hide project", "UPDATE projects SET Hidden='Y'" " WHERE PrjCod=%ld AND CrsCod=%ld", Prj.PrjCod,Gbl.Hierarchy.Crs.CrsCod); - - /***** Write message to show the change made *****/ - Ale_ShowAlert (Ale_SUCCESS,Txt_Project_X_is_now_hidden, - Prj.Title); - } else Lay_NoPermissionExit (); @@ -2949,7 +2979,6 @@ void Prj_HideProject (void) void Prj_ShowProject (void) { - extern const char *Txt_Project_X_is_now_visible; struct Project Prj; /***** Allocate memory for the project *****/ @@ -2964,17 +2993,11 @@ void Prj_ShowProject (void) Prj_GetDataOfProjectByCod (&Prj); if (Prj_CheckIfICanEditProject (&Prj)) - { /***** Show project *****/ DB_QueryUPDATE ("can not show project", "UPDATE projects SET Hidden='N'" " WHERE PrjCod=%ld AND CrsCod=%ld", Prj.PrjCod,Gbl.Hierarchy.Crs.CrsCod); - - /***** Write message to show the change made *****/ - Ale_ShowAlert (Ale_SUCCESS,Txt_Project_X_is_now_visible, - Prj.Title); - } else Lay_NoPermissionExit (); diff --git a/swad_text.c b/swad_text.c index ee2e3e11a..d37c401b0 100644 --- a/swad_text.c +++ b/swad_text.c @@ -29884,48 +29884,6 @@ const char *Txt_Project_files = "Arquivos do projeto"; #endif -const char *Txt_Project_X_is_now_hidden = // Warning: it is very important to include %s in the following sentences -#if L==1 // ca - "El projecte %s ara està ocult."; -#elif L==2 // de - "Die Projekt %s ist jetzt ausgeblendet."; -#elif L==3 // en - "Project %s is now hidden."; -#elif L==4 // es - "El proyecto %s ahora está oculto."; -#elif L==5 // fr - "Le project %s est maintenant caché."; -#elif L==6 // gn - "El proyecto %s ahora está oculto."; // Okoteve traducción -#elif L==7 // it - "Il progetto %s è ora nascosto."; -#elif L==8 // pl - "Projekt %s jest ukryte."; -#elif L==9 // pt - "O projeto %s é agora oculto."; -#endif - -const char *Txt_Project_X_is_now_visible = // Warning: it is very important to include %s in the following sentences -#if L==1 // ca - "El projecte %s ara està visible."; -#elif L==2 // de - "Die Projekt %s ist jetzt sichtbar."; -#elif L==3 // en - "Project %s is now visible."; -#elif L==4 // es - "El proyecto %s ahora está visible."; -#elif L==5 // fr - "Le project %s est maintenant visible."; -#elif L==6 // gn - "El proyecto %s ahora está visible."; // Okoteve traducción -#elif L==7 // it - "Il progetto %s è ora nascosto."; -#elif L==8 // pl - "Projekt %s jest teraz widoczne."; -#elif L==9 // pt - "O projeto %s é agora visível."; -#endif - const char *Txt_PROJECT_ORDER[Prj_NUM_ORDERS] = { // Prj_ORDER_START_TIME