mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-01 14:25:27 +02:00
Version 15.233.1
This commit is contained in:
parent
0a3a973e9d
commit
59a2a0661a
|
@ -130,13 +130,14 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 15.233 (2016-06-27)"
|
#define Log_PLATFORM_VERSION "SWAD 15.233.1 (2016-06-27)"
|
||||||
#define CSS_FILE "swad15.229.css"
|
#define CSS_FILE "swad15.229.css"
|
||||||
#define JS_FILE "swad15.226.js"
|
#define JS_FILE "swad15.226.js"
|
||||||
|
|
||||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
// 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
|
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
|
||||||
/*
|
/*
|
||||||
|
Version 15.233.1: Jun 27, 2015 New restrictions in length of search string. (203117 lines)
|
||||||
Version 15.233: Jun 27, 2015 Simplified search for users with a role. Now all users can be found. (203103 lines)
|
Version 15.233: Jun 27, 2015 Simplified search for users with a role. Now all users can be found. (203103 lines)
|
||||||
Version 15.232.1: Jun 27, 2015 Fixed bug in search of any user (acceptation of enrollment was wrong). (203702 lines)
|
Version 15.232.1: Jun 27, 2015 Fixed bug in search of any user (acceptation of enrollment was wrong). (203702 lines)
|
||||||
Version 15.232: Jun 27, 2015 Search any user, independently on role. (203657 lines)
|
Version 15.232: Jun 27, 2015 Search any user, independently on role. (203657 lines)
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#define Sch_MAX_WORDS_IN_SEARCH 10
|
#define Sch_MAX_WORDS_IN_SEARCH 10
|
||||||
#define Sch_MAX_LENGTH_SEARCH_WORD 255
|
#define Sch_MAX_LENGTH_SEARCH_WORD 255
|
||||||
#define Sch_MIN_LENGTH_LONGEST_WORD 3
|
#define Sch_MIN_LENGTH_LONGEST_WORD 3
|
||||||
|
#define Sch_MIN_LENGTH_TOTAL 7 // "A An Ann" is not valid; "A An Ann Anna" is valid
|
||||||
#define Sch_MAX_LENGTH_SEARCH_QUERY (10*Sch_MAX_LENGTH_STRING_TO_FIND)
|
#define Sch_MAX_LENGTH_SEARCH_QUERY (10*Sch_MAX_LENGTH_STRING_TO_FIND)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -801,9 +802,10 @@ static unsigned Sch_SearchUsrsInDB (Rol_Role_t Role)
|
||||||
char SearchQuery[Sch_MAX_LENGTH_SEARCH_QUERY+1];
|
char SearchQuery[Sch_MAX_LENGTH_SEARCH_QUERY+1];
|
||||||
|
|
||||||
/***** Check user's permission *****/
|
/***** Check user's permission *****/
|
||||||
if (Sch_CheckIfIHavePermissionToSearch ( Role == Rol_TEACHER ? Sch_SEARCH_TEACHERS :
|
if (Sch_CheckIfIHavePermissionToSearch ( Role == Rol_UNKNOWN ? Sch_SEARCH_USERS :
|
||||||
|
(Role == Rol_TEACHER ? Sch_SEARCH_TEACHERS :
|
||||||
(Role == Rol_STUDENT ? Sch_SEARCH_STUDENTS :
|
(Role == Rol_STUDENT ? Sch_SEARCH_STUDENTS :
|
||||||
Sch_SEARCH_GUESTS)))
|
Sch_SEARCH_GUESTS))))
|
||||||
/***** Split user string into words *****/
|
/***** Split user string into words *****/
|
||||||
if (Sch_BuildSearchQuery (SearchQuery,
|
if (Sch_BuildSearchQuery (SearchQuery,
|
||||||
"CONCAT_WS(' ',usr_data.FirstName,usr_data.Surname1,usr_data.Surname2)",
|
"CONCAT_WS(' ',usr_data.FirstName,usr_data.Surname1,usr_data.Surname2)",
|
||||||
|
@ -1216,13 +1218,15 @@ static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery)
|
||||||
static bool Sch_BuildSearchQuery (char *SearchQuery,const char *FieldName,
|
static bool Sch_BuildSearchQuery (char *SearchQuery,const char *FieldName,
|
||||||
const char *CharSet,const char *Collate)
|
const char *CharSet,const char *Collate)
|
||||||
{
|
{
|
||||||
extern const char *Txt_The_search_term_must_be_longer;
|
extern const char *Txt_The_search_text_must_be_longer;
|
||||||
static bool WarningMessageWritten = false;
|
static bool WarningMessageWritten = false;
|
||||||
const char *Ptr;
|
const char *Ptr;
|
||||||
unsigned NumWords;
|
unsigned NumWords;
|
||||||
|
unsigned NumWord;
|
||||||
size_t LengthWord;
|
size_t LengthWord;
|
||||||
|
size_t LengthTotal = 0;
|
||||||
size_t MaxLengthWord = 0;
|
size_t MaxLengthWord = 0;
|
||||||
char SearchWord[Sch_MAX_LENGTH_SEARCH_WORD+1];
|
char SearchWords[Sch_MAX_WORDS_IN_SEARCH][Sch_MAX_LENGTH_SEARCH_WORD+1];
|
||||||
bool SearchWordIsValid = true;
|
bool SearchWordIsValid = true;
|
||||||
|
|
||||||
SearchQuery[0] = '\0';
|
SearchQuery[0] = '\0';
|
||||||
|
@ -1232,7 +1236,7 @@ static bool Sch_BuildSearchQuery (char *SearchQuery,const char *FieldName,
|
||||||
NumWords++)
|
NumWords++)
|
||||||
{
|
{
|
||||||
/* Get next word */
|
/* Get next word */
|
||||||
Str_GetNextStringUntilSpace (&Ptr,SearchWord,Sch_MAX_LENGTH_SEARCH_WORD);
|
Str_GetNextStringUntilSpace (&Ptr,SearchWords[NumWords],Sch_MAX_LENGTH_SEARCH_WORD);
|
||||||
|
|
||||||
/* Is this word valid? */
|
/* Is this word valid? */
|
||||||
switch (Gbl.Search.WhatToSearch)
|
switch (Gbl.Search.WhatToSearch)
|
||||||
|
@ -1240,17 +1244,25 @@ static bool Sch_BuildSearchQuery (char *SearchQuery,const char *FieldName,
|
||||||
case Sch_SEARCH_OPEN_DOCUMENTS:
|
case Sch_SEARCH_OPEN_DOCUMENTS:
|
||||||
case Sch_SEARCH_DOCUM_IN_MY_COURSES:
|
case Sch_SEARCH_DOCUM_IN_MY_COURSES:
|
||||||
case Sch_SEARCH_MY_DOCUMENTS:
|
case Sch_SEARCH_MY_DOCUMENTS:
|
||||||
SearchWordIsValid = Str_ConvertFilFolLnkNameToValid (SearchWord);
|
SearchWordIsValid = Str_ConvertFilFolLnkNameToValid (SearchWords[NumWords]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SearchWordIsValid = true;
|
SearchWordIsValid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check if this word is repeated (case insensitive) */
|
||||||
|
for (NumWord = 0;
|
||||||
|
SearchWordIsValid && NumWord < NumWords;
|
||||||
|
NumWord++)
|
||||||
|
if (!strcasecmp (SearchWords[NumWord],SearchWords[NumWords]))
|
||||||
|
SearchWordIsValid = false;
|
||||||
|
|
||||||
/* Concatenate word to search string */
|
/* Concatenate word to search string */
|
||||||
if (SearchWordIsValid)
|
if (SearchWordIsValid)
|
||||||
{
|
{
|
||||||
LengthWord = strlen (SearchWord);
|
LengthWord = strlen (SearchWords[NumWords]);
|
||||||
|
LengthTotal += LengthWord;
|
||||||
if (LengthWord > MaxLengthWord)
|
if (LengthWord > MaxLengthWord)
|
||||||
MaxLengthWord = LengthWord;
|
MaxLengthWord = LengthWord;
|
||||||
if (strlen (SearchQuery) + LengthWord + 512 > Sch_MAX_LENGTH_SEARCH_QUERY) // Prevent string overflow
|
if (strlen (SearchQuery) + LengthWord + 512 > Sch_MAX_LENGTH_SEARCH_QUERY) // Prevent string overflow
|
||||||
|
@ -1263,7 +1275,7 @@ static bool Sch_BuildSearchQuery (char *SearchQuery,const char *FieldName,
|
||||||
if (CharSet[0])
|
if (CharSet[0])
|
||||||
strcat (SearchQuery,CharSet);
|
strcat (SearchQuery,CharSet);
|
||||||
strcat (SearchQuery,"'%");
|
strcat (SearchQuery,"'%");
|
||||||
strcat (SearchQuery,SearchWord);
|
strcat (SearchQuery,SearchWords[NumWords]);
|
||||||
strcat (SearchQuery,"%'");
|
strcat (SearchQuery,"%'");
|
||||||
if (Collate)
|
if (Collate)
|
||||||
if (Collate[0])
|
if (Collate[0])
|
||||||
|
@ -1272,17 +1284,19 @@ static bool Sch_BuildSearchQuery (char *SearchQuery,const char *FieldName,
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** If search string valid? *****/
|
/***** If search string valid? *****/
|
||||||
if (MaxLengthWord >= Sch_MIN_LENGTH_LONGEST_WORD)
|
if (LengthTotal < Sch_MIN_LENGTH_TOTAL ||
|
||||||
return true;
|
MaxLengthWord < Sch_MIN_LENGTH_LONGEST_WORD)
|
||||||
else // Too short
|
|
||||||
{
|
{
|
||||||
|
// Too short
|
||||||
if (!WarningMessageWritten) // To avoid repetitions
|
if (!WarningMessageWritten) // To avoid repetitions
|
||||||
{
|
{
|
||||||
Lay_ShowAlert (Lay_WARNING,Txt_The_search_term_must_be_longer);
|
Lay_ShowAlert (Lay_WARNING,Txt_The_search_text_must_be_longer);
|
||||||
WarningMessageWritten = true;
|
WarningMessageWritten = true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
20
swad_text.c
20
swad_text.c
|
@ -44544,25 +44544,25 @@ const char *Txt_The_X_students_who_belonged_to_the_course_Y_have_been_removed_fr
|
||||||
"The %u students who belonged to the course <strong>%s</strong> have been removed from it."; // Necessita de tradução
|
"The %u students who belonged to the course <strong>%s</strong> have been removed from it."; // Necessita de tradução
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *Txt_The_search_term_must_be_longer =
|
const char *Txt_The_search_text_must_be_longer =
|
||||||
#if L==1
|
#if L==1
|
||||||
"La palabra a buscar debe ser más larga."; // Necessita traduccio
|
"El text a cercar ha de ser més llarg.";
|
||||||
#elif L==2
|
#elif L==2
|
||||||
"The search term must be longer."; // Need Übersetzung
|
"Der Suchtext muss länger sein.";
|
||||||
#elif L==3
|
#elif L==3
|
||||||
"The search term must be longer.";
|
"The search text must be longer.";
|
||||||
#elif L==4
|
#elif L==4
|
||||||
"La palabra a buscar debe ser más larga.";
|
"El texto a buscar debe ser más largo.";
|
||||||
#elif L==5
|
#elif L==5
|
||||||
"The search term must be longer."; // Besoin de traduction
|
"Le texte de recherche doit être plus longue.";
|
||||||
#elif L==6
|
#elif L==6
|
||||||
"La palabra a buscar debe ser más larga."; // Okoteve traducción
|
"El texto a buscar debe ser más largo."; // Okoteve traducción
|
||||||
#elif L==7
|
#elif L==7
|
||||||
"The search term must be longer."; // Bisogno di traduzione
|
"Il testo di ricerca deve essere più lungo.";
|
||||||
#elif L==8
|
#elif L==8
|
||||||
"The search term must be longer."; // Potrzebujesz tlumaczenie
|
"Tekst wyszukiwania powinien być dłuższy.";
|
||||||
#elif L==9
|
#elif L==9
|
||||||
"The search term must be longer."; // Necessita de tradução
|
"O texto de pesquisa deve ser mais longo.";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *Txt_The_session_has_been_closed = // Closed by user
|
const char *Txt_The_session_has_been_closed = // Closed by user
|
||||||
|
|
Loading…
Reference in New Issue
Block a user