Version19.108.8

This commit is contained in:
Antonio Cañas Vargas 2019-12-30 22:32:06 +01:00
parent 8cfbaf1b45
commit 90444b6e8e
23 changed files with 145 additions and 123 deletions

View File

@ -27,7 +27,7 @@
#define _GNU_SOURCE // For vasprintf #define _GNU_SOURCE // For vasprintf
#include <stdarg.h> // For va_start, va_end #include <stdarg.h> // For va_start, va_end
#include <stdio.h> // For fprintf, vasprintf #include <stdio.h> // For vasprintf
#include <stdlib.h> // For free #include <stdlib.h> // For free
#include "swad_global.h" #include "swad_global.h"

View File

@ -26,7 +26,6 @@
/*****************************************************************************/ /*****************************************************************************/
#include <stddef.h> // For NULL #include <stddef.h> // For NULL
#include <stdio.h> // For fprintf
#include <string.h> // For string functions #include <string.h> // For string functions
#include "swad_account.h" #include "swad_account.h"

View File

@ -28,7 +28,7 @@
#define _GNU_SOURCE // For vasprintf #define _GNU_SOURCE // For vasprintf
#include <stdarg.h> // For va_start, va_end #include <stdarg.h> // For va_start, va_end
#include <stddef.h> // For NULL #include <stddef.h> // For NULL
#include <stdio.h> // For FILE, fprintf, vasprintf #include <stdio.h> // For FILE, vasprintf
#include <stdlib.h> // For free #include <stdlib.h> // For free
#include <string.h> // For string functions #include <string.h> // For string functions

View File

@ -26,7 +26,6 @@
/*****************************************************************************/ /*****************************************************************************/
#include <stdbool.h> // For boolean type #include <stdbool.h> // For boolean type
#include <stdio.h> // For fprintf
#include <stdlib.h> // For malloc and free #include <stdlib.h> // For malloc and free
#include "swad_action.h" #include "swad_action.h"

View File

@ -25,8 +25,6 @@
/********************************* Headers ***********************************/ /********************************* Headers ***********************************/
/*****************************************************************************/ /*****************************************************************************/
#include <stdio.h> // For fprintf
#include "swad_button.h" #include "swad_button.h"
#include "swad_global.h" #include "swad_global.h"
#include "swad_HTML.h" #include "swad_HTML.h"

View File

@ -492,7 +492,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD: En OpenSWAD:
ps2pdf source.ps destination.pdf ps2pdf source.ps destination.pdf
*/ */
#define Log_PLATFORM_VERSION "SWAD 19.108.7 (2019-12-30)" #define Log_PLATFORM_VERSION "SWAD 19.108.8 (2019-12-30)"
#define CSS_FILE "swad19.101.5.css" #define CSS_FILE "swad19.101.5.css"
#define JS_FILE "swad19.91.1.js" #define JS_FILE "swad19.91.1.js"
/* /*
@ -500,8 +500,9 @@ ps2pdf source.ps destination.pdf
// TODO: Impedir la creación y edición de proyectos si no son editables. // TODO: Impedir la creación y edición de proyectos si no son editables.
// TODO: No se puede entrar con DNI '1' suponiendo que no tenga password ¿por qué? // TODO: No se puede entrar con DNI '1' suponiendo que no tenga password ¿por qué?
Version 19.10x: Dec 30, 2019 Map in country information. (? lines) Version 19.10x: Dec 31, 2019 Map in country information. (? lines)
Version 19.10x: Dec 30, 2019 Map in institution information. (? lines) Version 19.10x: Dec 31, 2019 Map in institution information. (? lines)
Version 19.108.8: Dec 30, 2019 Code refactoring related to printing messages. (249700 lines)
Version 19.108.7: Dec 30, 2019 Code refactoring related to printing messages. (249674 lines) Version 19.108.7: Dec 30, 2019 Code refactoring related to printing messages. (249674 lines)
Version 19.108.6: Dec 30, 2019 Code refactoring related to printing messages. (249717 lines) Version 19.108.6: Dec 30, 2019 Code refactoring related to printing messages. (249717 lines)
Version 19.108.5: Dec 30, 2019 Code refactoring related to printing messages. (249712 lines) Version 19.108.5: Dec 30, 2019 Code refactoring related to printing messages. (249712 lines)

View File

@ -25,10 +25,11 @@
/*********************************** Headers *********************************/ /*********************************** Headers *********************************/
/*****************************************************************************/ /*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <limits.h> // For maximum values #include <limits.h> // For maximum values
#include <linux/limits.h> // For PATH_MAX #include <linux/limits.h> // For PATH_MAX
#include <stddef.h> // For NULL #include <stddef.h> // For NULL
#include <stdio.h> // For fprintf #include <stdio.h> // For asprintf
#include <string.h> // For string functions #include <string.h> // For string functions
#include "swad_box.h" #include "swad_box.h"
@ -83,6 +84,7 @@ void Con_ShowConnectedUsrs (void)
{ {
extern const char *Hlp_USERS_Connected; extern const char *Hlp_USERS_Connected;
extern const char *Txt_Connected_users; extern const char *Txt_Connected_users;
char *Title;
/***** Contextual menu *****/ /***** Contextual menu *****/
if (Gbl.Usrs.Me.Logged) if (Gbl.Usrs.Me.Logged)
@ -98,12 +100,13 @@ void Con_ShowConnectedUsrs (void)
/***** Begin box *****/ /***** Begin box *****/
/* Current time */ /* Current time */
snprintf (Gbl.Title,sizeof (Gbl.Title), if (asprintf (&Title,"%s"
"%s" "<div id=\"connected_current_time\"></div>",
"<div id=\"connected_current_time\"></div>", Txt_Connected_users) < 0)
Txt_Connected_users); Lay_NotEnoughMemoryExit ();
Box_BoxBegin (NULL,Gbl.Title,Con_PutIconToUpdateConnected, Box_BoxBegin (NULL,Title,Con_PutIconToUpdateConnected,
Hlp_USERS_Connected,Box_NOT_CLOSABLE); Hlp_USERS_Connected,Box_NOT_CLOSABLE);
free (Title);
Dat_WriteLocalDateHMSFromUTC ("connected_current_time",Gbl.StartExecutionTimeUTC, Dat_WriteLocalDateHMSFromUTC ("connected_current_time",Gbl.StartExecutionTimeUTC,
Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA,
false,false,true,0x7); false,false,true,0x7);

View File

@ -25,8 +25,10 @@
/********************************* Headers ***********************************/ /********************************* Headers ***********************************/
/*****************************************************************************/ /*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdbool.h> // For boolean type #include <stdbool.h> // For boolean type
#include <stddef.h> // For NULL #include <stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <string.h> // For string functions #include <string.h> // For string functions
#include "swad_database.h" #include "swad_database.h"
@ -440,6 +442,7 @@ static void CrsCfg_Indicators (void)
extern const char *Txt_of_PART_OF_A_TOTAL; extern const char *Txt_of_PART_OF_A_TOTAL;
struct Ind_IndicatorsCrs Indicators; struct Ind_IndicatorsCrs Indicators;
int NumIndicatorsFromDB = Ind_GetNumIndicatorsCrsFromDB (Gbl.Hierarchy.Crs.CrsCod); int NumIndicatorsFromDB = Ind_GetNumIndicatorsCrsFromDB (Gbl.Hierarchy.Crs.CrsCod);
char *Title;
/***** Compute indicators ******/ /***** Compute indicators ******/
Ind_ComputeAndStoreIndicatorsCrs (Gbl.Hierarchy.Crs.CrsCod, Ind_ComputeAndStoreIndicatorsCrs (Gbl.Hierarchy.Crs.CrsCod,
@ -454,16 +457,17 @@ static void CrsCfg_Indicators (void)
/* Data */ /* Data */
HTM_TD_Begin ("class=\"LB\""); HTM_TD_Begin ("class=\"LB\"");
Frm_StartForm (ActReqStaCrs); Frm_StartForm (ActReqStaCrs);
snprintf (Gbl.Title,sizeof (Gbl.Title), if (asprintf (&Title,"%u %s %u",
"%u %s %u", Indicators.NumIndicators,
Indicators.NumIndicators, Txt_of_PART_OF_A_TOTAL,Ind_NUM_INDICATORS) < 0)
Txt_of_PART_OF_A_TOTAL,Ind_NUM_INDICATORS); Lay_NotEnoughMemoryExit ();
HTM_BUTTON_SUBMIT_Begin (Gbl.Title,"BT_LINK DAT",NULL); HTM_BUTTON_SUBMIT_Begin (Title,"BT_LINK DAT",NULL);
HTM_TxtF ("%s&nbsp;",Gbl.Title); HTM_TxtF ("%s&nbsp;",Title);
Ico_PutIcon ((Indicators.NumIndicators == Ind_NUM_INDICATORS) ? "check-circle.svg" : Ico_PutIcon ((Indicators.NumIndicators == Ind_NUM_INDICATORS) ? "check-circle.svg" :
"exclamation-triangle.svg", "exclamation-triangle.svg",
Gbl.Title,"ICO16x16"); Title,"ICO16x16");
HTM_BUTTON_End (); HTM_BUTTON_End ();
free (Title);
Frm_EndForm (); Frm_EndForm ();
HTM_TD_End (); HTM_TD_End ();

View File

@ -25,7 +25,6 @@
/********************************* Headers ***********************************/ /********************************* Headers ***********************************/
/*****************************************************************************/ /*****************************************************************************/
#include <stdio.h> // For fprintf
#include <string.h> // For string functions #include <string.h> // For string functions
#include <unistd.h> // For access, lstat, getpid, chdir, symlink #include <unistd.h> // For access, lstat, getpid, chdir, symlink

View File

@ -30,7 +30,7 @@
#include <mysql/mysql.h> // To access MySQL databases #include <mysql/mysql.h> // To access MySQL databases
#include <stdarg.h> // For va_start, va_end #include <stdarg.h> // For va_start, va_end
#include <stddef.h> // For NULL #include <stddef.h> // For NULL
#include <stdio.h> // For FILE, fprintf, vasprintf #include <stdio.h> // For FILE, vasprintf
#include <stdlib.h> // For free #include <stdlib.h> // For free
#include "swad_config.h" #include "swad_config.h"

View File

@ -28,7 +28,6 @@
#include <ctype.h> // For isprint, isspace, etc. #include <ctype.h> // For isprint, isspace, etc.
#include <stdbool.h> // For boolean type #include <stdbool.h> // For boolean type
#include <stddef.h> // For NULL #include <stddef.h> // For NULL
#include <stdio.h> // For fprintf, etc.
#include <stdlib.h> // For exit, system, calloc, free, etc. #include <stdlib.h> // For exit, system, calloc, free, etc.
#include <string.h> // For string functions #include <string.h> // For string functions
#include <mysql/mysql.h> // To access MySQL databases #include <mysql/mysql.h> // To access MySQL databases

View File

@ -202,7 +202,6 @@ struct Globals
time_t StartExecutionTimeUTC; time_t StartExecutionTimeUTC;
struct DateTime Now; struct DateTime Now;
struct Date Yesterday; struct Date Yesterday;
char Title[Lay_MAX_BYTES_TITLE + 1]; // String for the help message in a link
unsigned RowEvenOdd; // To alternate row colors in listings unsigned RowEvenOdd; // To alternate row colors in listings
char *ColorRows[2]; char *ColorRows[2];
const char *XMLPtr; const char *XMLPtr;

View File

@ -33,8 +33,6 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Lay_MAX_BYTES_TITLE (4096 - 1)
#define Lay_HIDE_BOTH_COLUMNS 0 // 00 #define Lay_HIDE_BOTH_COLUMNS 0 // 00
#define Lay_SHOW_RIGHT_COLUMN 1 // 01 #define Lay_SHOW_RIGHT_COLUMN 1 // 01
#define Lay_SHOW_LEFT_COLUMN 2 // 10 #define Lay_SHOW_LEFT_COLUMN 2 // 10

View File

@ -25,8 +25,6 @@
/********************************* Headers ***********************************/ /********************************* Headers ***********************************/
/*****************************************************************************/ /*****************************************************************************/
#include <stdio.h> // For fprintf, etc.
#include "swad_box.h" #include "swad_box.h"
#include "swad_database.h" #include "swad_database.h"
#include "swad_form.h" #include "swad_form.h"

View File

@ -95,7 +95,7 @@ static unsigned long Msg_GetSentOrReceivedMsgs (long UsrCod,
const char *FilterFromToSubquery, const char *FilterFromToSubquery,
MYSQL_RES **mysql_res); MYSQL_RES **mysql_res);
static char *Msg_WriteNumMsgs (unsigned NumUnreadMsgs); static void Msg_SetNumMsgsStr (char **NumMsgsStr,unsigned NumUnreadMsgs);
static void Msg_PutIconsListMsgs (void); static void Msg_PutIconsListMsgs (void);
static void Msg_PutHiddenParamsOneMsg (void); static void Msg_PutHiddenParamsOneMsg (void);
@ -1700,6 +1700,7 @@ static void Msg_ShowSentOrReceivedMessages (void)
MYSQL_ROW row; MYSQL_ROW row;
unsigned long NumRow; unsigned long NumRow;
unsigned long NumRows; unsigned long NumRows;
char *NumMsgsStr;
unsigned long NumMsg = 0; // Initialized to avoid warning unsigned long NumMsg = 0; // Initialized to avoid warning
unsigned NumUnreadMsgs = 0; // Initialized to avoid warning unsigned NumUnreadMsgs = 0; // Initialized to avoid warning
struct Pagination Pagination; struct Pagination Pagination;
@ -1755,8 +1756,10 @@ static void Msg_ShowSentOrReceivedMessages (void)
Gbl.Msg.NumMsgs = (unsigned) NumRows; Gbl.Msg.NumMsgs = (unsigned) NumRows;
/***** Begin box with messages *****/ /***** Begin box with messages *****/
Box_BoxBegin ("97%",Msg_WriteNumMsgs (NumUnreadMsgs),Msg_PutIconsListMsgs, Msg_SetNumMsgsStr (&NumMsgsStr,NumUnreadMsgs);
Box_BoxBegin ("97%",NumMsgsStr,Msg_PutIconsListMsgs,
Help[Gbl.Msg.TypeOfMessages],Box_NOT_CLOSABLE); Help[Gbl.Msg.TypeOfMessages],Box_NOT_CLOSABLE);
free (NumMsgsStr);
/***** Filter messages *****/ /***** Filter messages *****/
/* Begin box with filter */ /* Begin box with filter */
@ -2425,11 +2428,11 @@ unsigned Msg_GetNumMsgsReceived (Hie_Level_t Scope,Msg_Status_t MsgStatus)
} }
/*****************************************************************************/ /*****************************************************************************/
/********* Write number of messages and number of unread messages ************/ /***** Set string with number of messages and number of unread messages ******/
/*****************************************************************************/ /*****************************************************************************/
// Fill Gbl.Title // The string must be deallocated after calling this function
static char *Msg_WriteNumMsgs (unsigned NumUnreadMsgs) static void Msg_SetNumMsgsStr (char **NumMsgsStr,unsigned NumUnreadMsgs)
{ {
extern const char *Txt_message_received; extern const char *Txt_message_received;
extern const char *Txt_message_sent; extern const char *Txt_message_sent;
@ -2444,45 +2447,55 @@ static char *Msg_WriteNumMsgs (unsigned NumUnreadMsgs)
if (Gbl.Msg.NumMsgs == 1) if (Gbl.Msg.NumMsgs == 1)
{ {
if (NumUnreadMsgs) if (NumUnreadMsgs)
snprintf (Gbl.Title,sizeof (Gbl.Title), {
"1 %s, 1 %s", if (asprintf (NumMsgsStr,"1 %s, 1 %s",
Txt_message_received,Txt_unread_MESSAGE); Txt_message_received,Txt_unread_MESSAGE) < 0)
Lay_NotEnoughMemoryExit ();
}
else else
snprintf (Gbl.Title,sizeof (Gbl.Title), {
"1 %s", if (asprintf (NumMsgsStr,"1 %s",Txt_message_received) < 0)
Txt_message_received); Lay_NotEnoughMemoryExit ();
}
} }
else else
{ {
if (NumUnreadMsgs == 0) if (NumUnreadMsgs == 0)
snprintf (Gbl.Title,sizeof (Gbl.Title), {
"%u %s", if (asprintf (NumMsgsStr,"%u %s",
Gbl.Msg.NumMsgs,Txt_messages_received); Gbl.Msg.NumMsgs,Txt_messages_received) < 0)
Lay_NotEnoughMemoryExit ();
}
else if (NumUnreadMsgs == 1) else if (NumUnreadMsgs == 1)
snprintf (Gbl.Title,sizeof (Gbl.Title), {
"%u %s, 1 %s", if (asprintf (NumMsgsStr,"%u %s, 1 %s",
Gbl.Msg.NumMsgs,Txt_messages_received, Gbl.Msg.NumMsgs,Txt_messages_received,
Txt_unread_MESSAGE); Txt_unread_MESSAGE) < 0)
Lay_NotEnoughMemoryExit ();
}
else else
snprintf (Gbl.Title,sizeof (Gbl.Title), {
"%u %s, %u %s", if (asprintf (NumMsgsStr,"%u %s, %u %s",
Gbl.Msg.NumMsgs,Txt_messages_received, Gbl.Msg.NumMsgs,Txt_messages_received,
NumUnreadMsgs,Txt_unread_MESSAGES); NumUnreadMsgs,Txt_unread_MESSAGES) < 0)
Lay_NotEnoughMemoryExit ();
}
} }
break; break;
case Msg_MESSAGES_SENT: case Msg_MESSAGES_SENT:
if (Gbl.Msg.NumMsgs == 1) if (Gbl.Msg.NumMsgs == 1)
snprintf (Gbl.Title,sizeof (Gbl.Title), {
"1 %s", if (asprintf (NumMsgsStr,"1 %s",Txt_message_sent) < 0)
Txt_message_sent); Lay_NotEnoughMemoryExit ();
}
else else
snprintf (Gbl.Title,sizeof (Gbl.Title), {
"%u %s", if (asprintf (NumMsgsStr,"%u %s",
Gbl.Msg.NumMsgs,Txt_messages_sent); Gbl.Msg.NumMsgs,Txt_messages_sent) < 0)
Lay_NotEnoughMemoryExit ();
}
break; break;
} }
return Gbl.Title;
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -155,6 +155,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
extern const char *Txt_FORUM_Post_banned; extern const char *Txt_FORUM_Post_banned;
unsigned NumPage; unsigned NumPage;
char *ClassLink; char *ClassLink;
char *Title;
/***** Link to page 1, including a text *****/ /***** Link to page 1, including a text *****/
if (Subject) if (Subject)
@ -243,12 +244,12 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Usr_PutParamOtherUsrCodEncrypted (); Usr_PutParamOtherUsrCodEncrypted ();
break; break;
} }
snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Page_X_of_Y,
1,Pagination->NumPags);
if (asprintf (&ClassLink,"BT_LINK LT %s",ClassTxt) < 0) if (asprintf (&ClassLink,"BT_LINK LT %s",ClassTxt) < 0)
Lay_NotEnoughMemoryExit (); Lay_NotEnoughMemoryExit ();
HTM_BUTTON_SUBMIT_Begin (Gbl.Title,ClassLink,NULL); if (asprintf (&Title,Txt_Page_X_of_Y,1,Pagination->NumPags) < 0)
Lay_NotEnoughMemoryExit ();
HTM_BUTTON_SUBMIT_Begin (Title,ClassLink,NULL);
free (Title);
free (ClassLink); free (ClassLink);
} }
else else
@ -357,12 +358,12 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Usr_PutParamOtherUsrCodEncrypted (); Usr_PutParamOtherUsrCodEncrypted ();
break; break;
} }
snprintf (Gbl.Title,sizeof (Gbl.Title), if (asprintf (&Title,Txt_Page_X_of_Y,1,Pagination->NumPags) < 0)
Txt_Page_X_of_Y, Lay_NotEnoughMemoryExit ();
1,Pagination->NumPags); HTM_BUTTON_SUBMIT_Begin (Title,ClassLink,NULL);
HTM_BUTTON_SUBMIT_Begin (Gbl.Title,ClassLink,NULL);
HTM_Unsigned (1); HTM_Unsigned (1);
HTM_BUTTON_End (); HTM_BUTTON_End ();
free (Title);
Frm_EndForm (); Frm_EndForm ();
if (Pagination->LeftPage > 2) if (Pagination->LeftPage > 2)
{ {
@ -457,13 +458,13 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Usr_PutParamOtherUsrCodEncrypted (); Usr_PutParamOtherUsrCodEncrypted ();
break; break;
} }
snprintf (Gbl.Title,sizeof (Gbl.Title), if (asprintf (&Title,Txt_Page_X_of_Y,
Txt_Page_X_of_Y, Pagination->LeftPage,Pagination->NumPags) < 0)
Pagination->LeftPage, Lay_NotEnoughMemoryExit ();
Pagination->NumPags); HTM_BUTTON_SUBMIT_Begin (Title,ClassLink,NULL);
HTM_BUTTON_SUBMIT_Begin (Gbl.Title,ClassLink,NULL);
HTM_Unsigned (Pagination->LeftPage); HTM_Unsigned (Pagination->LeftPage);
HTM_BUTTON_End (); HTM_BUTTON_End ();
free (Title);
Frm_EndForm (); Frm_EndForm ();
if (Pagination->LeftPage < Pagination->StartPage - 1) if (Pagination->LeftPage < Pagination->StartPage - 1)
{ {
@ -478,12 +479,11 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
NumPage <= Pagination->EndPage; NumPage <= Pagination->EndPage;
NumPage++) NumPage++)
{ {
snprintf (Gbl.Title,sizeof (Gbl.Title), if (asprintf (&Title,Txt_Page_X_of_Y,NumPage,Pagination->NumPags) < 0)
Txt_Page_X_of_Y, Lay_NotEnoughMemoryExit ();
NumPage,Pagination->NumPags);
if (!LinkToPagCurrent && NumPage == Pagination->CurrentPage) if (!LinkToPagCurrent && NumPage == Pagination->CurrentPage)
{ {
HTM_SPAN_Begin ("title=\"%s\" class=\"PAG_CUR %s\"",Gbl.Title,ClassTxt); HTM_SPAN_Begin ("title=\"%s\" class=\"PAG_CUR %s\"",Title,ClassTxt);
HTM_Unsigned (NumPage); HTM_Unsigned (NumPage);
HTM_SPAN_End (); HTM_SPAN_End ();
} }
@ -570,11 +570,12 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Usr_PutParamOtherUsrCodEncrypted (); Usr_PutParamOtherUsrCodEncrypted ();
break; break;
} }
HTM_BUTTON_SUBMIT_Begin (Gbl.Title,ClassLink,NULL); HTM_BUTTON_SUBMIT_Begin (Title,ClassLink,NULL);
HTM_Unsigned (NumPage); HTM_Unsigned (NumPage);
HTM_BUTTON_End (); HTM_BUTTON_End ();
Frm_EndForm (); Frm_EndForm ();
} }
free (Title);
} }
/***** Posible link to page right *****/ /***** Posible link to page right *****/
@ -668,12 +669,13 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Usr_PutParamOtherUsrCodEncrypted (); Usr_PutParamOtherUsrCodEncrypted ();
break; break;
} }
snprintf (Gbl.Title,sizeof (Gbl.Title), if (asprintf (&Title,Txt_Page_X_of_Y,
Txt_Page_X_of_Y, Pagination->RightPage,Pagination->NumPags) < 0)
Pagination->RightPage,Pagination->NumPags); Lay_NotEnoughMemoryExit ();
HTM_BUTTON_SUBMIT_Begin (Gbl.Title,ClassLink,NULL); HTM_BUTTON_SUBMIT_Begin (Title,ClassLink,NULL);
HTM_Unsigned (Pagination->RightPage); HTM_Unsigned (Pagination->RightPage);
HTM_BUTTON_End (); HTM_BUTTON_End ();
free (Title);
Frm_EndForm (); Frm_EndForm ();
} }
@ -767,12 +769,13 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Usr_PutParamOtherUsrCodEncrypted (); Usr_PutParamOtherUsrCodEncrypted ();
break; break;
} }
snprintf (Gbl.Title,sizeof (Gbl.Title), if (asprintf (&Title,Txt_Page_X_of_Y,
Txt_Page_X_of_Y, Pagination->NumPags,Pagination->NumPags) < 0)
Pagination->NumPags,Pagination->NumPags); Lay_NotEnoughMemoryExit ();
HTM_BUTTON_SUBMIT_Begin (Gbl.Title,ClassLink,NULL); HTM_BUTTON_SUBMIT_Begin (Title,ClassLink,NULL);
HTM_Unsigned (Pagination->NumPags); HTM_Unsigned (Pagination->NumPags);
HTM_BUTTON_End (); HTM_BUTTON_End ();
free (Title);
Frm_EndForm (); Frm_EndForm ();
} }

View File

@ -25,7 +25,9 @@
/*********************************** Headers *********************************/ /*********************************** Headers *********************************/
/*****************************************************************************/ /*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stddef.h> // For NULL #include <stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <string.h> // For string functions #include <string.h> // For string functions
#include "swad_box.h" #include "swad_box.h"
@ -943,17 +945,16 @@ static void Prf_ShowRanking (unsigned long Rank,unsigned long NumUsrs)
{ {
extern const char *The_ClassFormLinkOutBox[The_NUM_THEMES]; extern const char *The_ClassFormLinkOutBox[The_NUM_THEMES];
extern const char *Txt_of_PART_OF_A_TOTAL; extern const char *Txt_of_PART_OF_A_TOTAL;
char *Title;
/***** Part of a total and end container *****/
snprintf (Gbl.Title,sizeof (Gbl.Title),
"#%lu %s %lu",
Rank,Txt_of_PART_OF_A_TOTAL,NumUsrs);
/***** Rank in form to go to ranking *****/ /***** Rank in form to go to ranking *****/
Frm_StartForm (ActSeeUseGbl); Frm_StartForm (ActSeeUseGbl);
Sco_PutParamScope ("ScopeSta",Hie_SYS); Sco_PutParamScope ("ScopeSta",Hie_SYS);
Par_PutHiddenParamUnsigned (NULL,"FigureType",(unsigned) Fig_USERS_RANKING); Par_PutHiddenParamUnsigned (NULL,"FigureType",(unsigned) Fig_USERS_RANKING);
HTM_BUTTON_SUBMIT_Begin (Gbl.Title,The_ClassFormLinkOutBox[Gbl.Prefs.Theme],NULL); if (asprintf (&Title,"#%lu %s %lu",Rank,Txt_of_PART_OF_A_TOTAL,NumUsrs) < 0)
Lay_NotEnoughMemoryExit ();
HTM_BUTTON_SUBMIT_Begin (Title,The_ClassFormLinkOutBox[Gbl.Prefs.Theme],NULL);
free (Title);
HTM_TxtF ("#%lu",Rank); HTM_TxtF ("#%lu",Rank);
HTM_BUTTON_End (); HTM_BUTTON_End ();
Frm_EndForm (); Frm_EndForm ();

View File

@ -2275,7 +2275,7 @@ static void Prj_ReqAddUsrs (Prj_RoleInProject_t RoleInProject)
[Prj_ROLE_TUT] = ActAddTutPrj, // Tutor [Prj_ROLE_TUT] = ActAddTutPrj, // Tutor
[Prj_ROLE_EVL] = ActAddEvlPrj, // Evaluator [Prj_ROLE_EVL] = ActAddEvlPrj, // Evaluator
}; };
char TxtButton[Lay_MAX_BYTES_TITLE + 1]; char *TxtButton;
/***** Get parameters *****/ /***** Get parameters *****/
Prj_GetParams (); Prj_GetParams ();
@ -2283,15 +2283,16 @@ static void Prj_ReqAddUsrs (Prj_RoleInProject_t RoleInProject)
Lay_ShowErrorAndExit ("Code of project is missing."); Lay_ShowErrorAndExit ("Code of project is missing.");
/***** Put form to select users *****/ /***** Put form to select users *****/
snprintf (TxtButton,sizeof (TxtButton), if (asprintf (&TxtButton,Txt_Add_USERS,
Txt_Add_USERS, Txt_PROJECT_ROLES_PLURAL_abc[RoleInProject]) < 0)
Txt_PROJECT_ROLES_PLURAL_abc[RoleInProject]); Lay_NotEnoughMemoryExit ();
Usr_PutFormToSelectUsrsToGoToAct (&Prj_MembersToAdd, Usr_PutFormToSelectUsrsToGoToAct (&Prj_MembersToAdd,
ActionAddUsr[RoleInProject],Prj_PutCurrentParams, ActionAddUsr[RoleInProject],Prj_PutCurrentParams,
TxtButton, TxtButton,
Hlp_ASSESSMENT_Projects_add_user, Hlp_ASSESSMENT_Projects_add_user,
TxtButton, TxtButton,
false); // Do not put form with date range false); // Do not put form with date range
free (TxtButton);
/***** Put a form to create/edit project *****/ /***** Put a form to create/edit project *****/
Prj_RequestCreatOrEditPrj (Gbl.Prjs.PrjCod); Prj_RequestCreatOrEditPrj (Gbl.Prjs.PrjCod);

View File

@ -25,7 +25,6 @@
/*********************************** Headers *********************************/ /*********************************** Headers *********************************/
/*****************************************************************************/ /*****************************************************************************/
#include <stdio.h> // For fprintf...
#include <string.h> // For string functions... #include <string.h> // For string functions...
#include "swad_box.h" #include "swad_box.h"

View File

@ -27,7 +27,6 @@
#include <stdbool.h> // For boolean type #include <stdbool.h> // For boolean type
#include <stddef.h> // For NULL #include <stddef.h> // For NULL
#include <stdio.h> // For fprintf, etc.
#include <string.h> #include <string.h>
#include "swad_box.h" #include "swad_box.h"

View File

@ -2606,6 +2606,7 @@ static void Svy_ShowFormEditOneQst (long SvyCod,struct SurveyQuestion *SvyQst,
MYSQL_ROW row; MYSQL_ROW row;
unsigned NumAns; unsigned NumAns;
unsigned NumAnswers = 0; unsigned NumAnswers = 0;
char *Title;
Svy_AnswerType_t AnsType; Svy_AnswerType_t AnsType;
if (Gbl.Action.Act == ActEdiOneSvyQst) // If no receiving the question, but editing a new or existing question if (Gbl.Action.Act == ActEdiOneSvyQst) // If no receiving the question, but editing a new or existing question
@ -2664,11 +2665,11 @@ static void Svy_ShowFormEditOneQst (long SvyCod,struct SurveyQuestion *SvyQst,
Svy_CurrentSvyCod = SvyCod; Svy_CurrentSvyCod = SvyCod;
Svy_CurrentQstCod = SvyQst->QstCod; Svy_CurrentQstCod = SvyQst->QstCod;
snprintf (Gbl.Title,sizeof (Gbl.Title), if (asprintf (&Title,"%s %u",Txt_Question,SvyQst->QstInd + 1) < 0) // Question index may be 0, 1, 2, 3,...
"%s %u", Lay_NotEnoughMemoryExit ();
Txt_Question,SvyQst->QstInd + 1); // Question index may be 0, 1, 2, 3,... Box_BoxBegin (NULL,Title,Svy_PutIconToRemoveOneQst,
Box_BoxBegin (NULL,Gbl.Title,Svy_PutIconToRemoveOneQst,
NULL,Box_NOT_CLOSABLE); NULL,Box_NOT_CLOSABLE);
free (Title);
} }
else else
Box_BoxBegin (NULL,Txt_New_question,NULL, Box_BoxBegin (NULL,Txt_New_question,NULL,
@ -3473,18 +3474,23 @@ static void Svy_DrawBarNumUsrs (unsigned NumUsrs,unsigned MaxUsrs)
{ {
extern const char *Txt_of_PART_OF_A_TOTAL; extern const char *Txt_of_PART_OF_A_TOTAL;
unsigned BarWidth = 0; unsigned BarWidth = 0;
char *Title;
/***** String with the number of users *****/ /***** Build string with the number of users *****/
if (MaxUsrs) if (MaxUsrs)
snprintf (Gbl.Title,sizeof (Gbl.Title), {
"%u&nbsp;(%u%%&nbsp;%s&nbsp;%u)", if (asprintf (&Title,"%u&nbsp;(%u%%&nbsp;%s&nbsp;%u)",
NumUsrs, NumUsrs,
(unsigned) ((((double) NumUsrs * 100.0) / (double) MaxUsrs) + 0.5), (unsigned) ((((double) NumUsrs * 100.0) / (double) MaxUsrs) + 0.5),
Txt_of_PART_OF_A_TOTAL,MaxUsrs); Txt_of_PART_OF_A_TOTAL,MaxUsrs) < 0)
Lay_NotEnoughMemoryExit ();
}
else else
snprintf (Gbl.Title,sizeof (Gbl.Title), {
"0&nbsp;(0%%&nbsp;%s&nbsp;%u)", if (asprintf (&Title,"0&nbsp;(0%%&nbsp;%s&nbsp;%u)",
Txt_of_PART_OF_A_TOTAL,MaxUsrs); Txt_of_PART_OF_A_TOTAL,MaxUsrs) < 0)
Lay_NotEnoughMemoryExit ();
}
HTM_TD_Begin ("class=\"DAT LT\" style=\"width:%upx;\"",Svy_MAX_BAR_WIDTH + 125); HTM_TD_Begin ("class=\"DAT LT\" style=\"width:%upx;\"",Svy_MAX_BAR_WIDTH + 125);
@ -3494,11 +3500,14 @@ static void Svy_DrawBarNumUsrs (unsigned NumUsrs,unsigned MaxUsrs)
(double) MaxUsrs) + 0.5); (double) MaxUsrs) + 0.5);
if (BarWidth < 2) if (BarWidth < 2)
BarWidth = 2; BarWidth = 2;
HTM_IMG (Cfg_URL_ICON_PUBLIC,"o1x1.png",Gbl.Title, HTM_IMG (Cfg_URL_ICON_PUBLIC,"o1x1.png",Title,
"class=\"LT\" style=\"width:%upx; height:20px;\"",BarWidth); "class=\"LT\" style=\"width:%upx; height:20px;\"",BarWidth);
/***** Write the number of users *****/ /***** Write the number of users *****/
HTM_TxtF ("&nbsp;%s",Gbl.Title); HTM_TxtF ("&nbsp;%s",Title);
/***** Free string with the number of users *****/
free (Title);
HTM_TD_End (); HTM_TD_End ();
} }

View File

@ -31,7 +31,7 @@
#include <mysql/mysql.h> // To access MySQL databases #include <mysql/mysql.h> // To access MySQL databases
#include <stdbool.h> // For boolean type #include <stdbool.h> // For boolean type
#include <stddef.h> // For NULL #include <stddef.h> // For NULL
#include <stdio.h> // For fprintf, asprintf, etc. #include <stdio.h> // For asprintf
#include <stdlib.h> // For exit, system, malloc, free, etc #include <stdlib.h> // For exit, system, malloc, free, etc
#include <string.h> // For string functions #include <string.h> // For string functions
#include <sys/stat.h> // For mkdir #include <sys/stat.h> // For mkdir
@ -5085,6 +5085,7 @@ static void Tst_PutFormEditOneQst (char Stem[Cns_MAX_BYTES_TEXT + 1],
bool DisplayRightColumn; bool DisplayRightColumn;
char StrTagTxt[6 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; char StrTagTxt[6 + Cns_MAX_DECIMAL_DIGITS_UINT + 1];
char StrInteger[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; char StrInteger[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
char *Title;
/***** Begin box *****/ /***** Begin box *****/
if (Gbl.Test.QstCod > 0) // The question already has assigned a code if (Gbl.Test.QstCod > 0) // The question already has assigned a code
@ -5361,29 +5362,29 @@ static void Tst_PutFormEditOneQst (char Stem[Cns_MAX_BYTES_TEXT + 1],
HTM_TxtF ("%c)",'a' + (char) NumOpt); HTM_TxtF ("%c)",'a' + (char) NumOpt);
/* Icon to expand (show the answer) */ /* Icon to expand (show the answer) */
snprintf (Gbl.Title,sizeof (Gbl.Title),
"%s %c)",
Txt_Expand,'a' + (char) NumOpt);
HTM_A_Begin ("href=\"\" id=\"exp_%u\"%s" HTM_A_Begin ("href=\"\" id=\"exp_%u\"%s"
" onclick=\"toggleAnswer('%u');return false;\"", " onclick=\"toggleAnswer('%u');return false;\"",
NumOpt, NumOpt,
DisplayRightColumn ? " style=\"display:none;\"" : // Answer does have content ==> Hide icon DisplayRightColumn ? " style=\"display:none;\"" : // Answer does have content ==> Hide icon
"", "",
NumOpt); NumOpt);
Ico_PutIcon ("caret-right.svg",Gbl.Title,"ICO16x16"); if (asprintf (&Title,"%s %c)",Txt_Expand,'a' + (char) NumOpt) < 0)
Lay_NotEnoughMemoryExit ();
Ico_PutIcon ("caret-right.svg",Title,"ICO16x16");
free (Title);
HTM_A_End (); HTM_A_End ();
/* Icon to contract (hide the answer) */ /* Icon to contract (hide the answer) */
snprintf (Gbl.Title,sizeof (Gbl.Title),
"%s %c)",
Txt_Contract,'a' + (char) NumOpt);
HTM_A_Begin ("href=\"\" id=\"con_%u\"%s" HTM_A_Begin ("href=\"\" id=\"con_%u\"%s"
" onclick=\"toggleAnswer(%u);return false;\"", " onclick=\"toggleAnswer(%u);return false;\"",
NumOpt, NumOpt,
DisplayRightColumn ? "" : DisplayRightColumn ? "" :
" style=\"display:none;\"", // Answer does not have content ==> Hide icon " style=\"display:none;\"", // Answer does not have content ==> Hide icon
NumOpt); NumOpt);
Ico_PutIcon ("caret-down.svg",Gbl.Title,"ICO16x16"); if (asprintf (&Title,"%s %c)",Txt_Contract,'a' + (char) NumOpt) < 0)
Lay_NotEnoughMemoryExit ();
Ico_PutIcon ("caret-down.svg",Title,"ICO16x16");
free (Title);
HTM_A_End (); HTM_A_End ();
HTM_TD_End (); HTM_TD_End ();

View File

@ -25,7 +25,6 @@
/********************************** Headers **********************************/ /********************************** Headers **********************************/
/*****************************************************************************/ /*****************************************************************************/
#include <stdio.h> // For fprintf, etc.
#include <string.h> #include <string.h>
#include "swad_box.h" #include "swad_box.h"