mirror of https://github.com/acanas/swad-core.git
Version 15.233.1
This commit is contained in:
parent
0a3a973e9d
commit
59a2a0661a
|
@ -130,13 +130,14 @@
|
|||
/****************************** 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 JS_FILE "swad15.226.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 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.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)
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#define Sch_MAX_WORDS_IN_SEARCH 10
|
||||
#define Sch_MAX_LENGTH_SEARCH_WORD 255
|
||||
#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)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -801,9 +802,10 @@ static unsigned Sch_SearchUsrsInDB (Rol_Role_t Role)
|
|||
char SearchQuery[Sch_MAX_LENGTH_SEARCH_QUERY+1];
|
||||
|
||||
/***** 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 :
|
||||
Sch_SEARCH_GUESTS)))
|
||||
Sch_SEARCH_GUESTS))))
|
||||
/***** Split user string into words *****/
|
||||
if (Sch_BuildSearchQuery (SearchQuery,
|
||||
"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,
|
||||
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;
|
||||
const char *Ptr;
|
||||
unsigned NumWords;
|
||||
unsigned NumWord;
|
||||
size_t LengthWord;
|
||||
size_t LengthTotal = 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;
|
||||
|
||||
SearchQuery[0] = '\0';
|
||||
|
@ -1232,7 +1236,7 @@ static bool Sch_BuildSearchQuery (char *SearchQuery,const char *FieldName,
|
|||
NumWords++)
|
||||
{
|
||||
/* 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? */
|
||||
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_DOCUM_IN_MY_COURSES:
|
||||
case Sch_SEARCH_MY_DOCUMENTS:
|
||||
SearchWordIsValid = Str_ConvertFilFolLnkNameToValid (SearchWord);
|
||||
SearchWordIsValid = Str_ConvertFilFolLnkNameToValid (SearchWords[NumWords]);
|
||||
break;
|
||||
default:
|
||||
SearchWordIsValid = true;
|
||||
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 */
|
||||
if (SearchWordIsValid)
|
||||
{
|
||||
LengthWord = strlen (SearchWord);
|
||||
LengthWord = strlen (SearchWords[NumWords]);
|
||||
LengthTotal += LengthWord;
|
||||
if (LengthWord > MaxLengthWord)
|
||||
MaxLengthWord = LengthWord;
|
||||
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])
|
||||
strcat (SearchQuery,CharSet);
|
||||
strcat (SearchQuery,"'%");
|
||||
strcat (SearchQuery,SearchWord);
|
||||
strcat (SearchQuery,SearchWords[NumWords]);
|
||||
strcat (SearchQuery,"%'");
|
||||
if (Collate)
|
||||
if (Collate[0])
|
||||
|
@ -1272,17 +1284,19 @@ static bool Sch_BuildSearchQuery (char *SearchQuery,const char *FieldName,
|
|||
}
|
||||
|
||||
/***** If search string valid? *****/
|
||||
if (MaxLengthWord >= Sch_MIN_LENGTH_LONGEST_WORD)
|
||||
return true;
|
||||
else // Too short
|
||||
if (LengthTotal < Sch_MIN_LENGTH_TOTAL ||
|
||||
MaxLengthWord < Sch_MIN_LENGTH_LONGEST_WORD)
|
||||
{
|
||||
// Too short
|
||||
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;
|
||||
}
|
||||
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
|
||||
#endif
|
||||
|
||||
const char *Txt_The_search_term_must_be_longer =
|
||||
const char *Txt_The_search_text_must_be_longer =
|
||||
#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
|
||||
"The search term must be longer."; // Need Übersetzung
|
||||
"Der Suchtext muss länger sein.";
|
||||
#elif L==3
|
||||
"The search term must be longer.";
|
||||
"The search text must be longer.";
|
||||
#elif L==4
|
||||
"La palabra a buscar debe ser más larga.";
|
||||
"El texto a buscar debe ser más largo.";
|
||||
#elif L==5
|
||||
"The search term must be longer."; // Besoin de traduction
|
||||
"Le texte de recherche doit être plus longue.";
|
||||
#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
|
||||
"The search term must be longer."; // Bisogno di traduzione
|
||||
"Il testo di ricerca deve essere più lungo.";
|
||||
#elif L==8
|
||||
"The search term must be longer."; // Potrzebujesz tlumaczenie
|
||||
"Tekst wyszukiwania powinien być dłuższy.";
|
||||
#elif L==9
|
||||
"The search term must be longer."; // Necessita de tradução
|
||||
"O texto de pesquisa deve ser mais longo.";
|
||||
#endif
|
||||
|
||||
const char *Txt_The_session_has_been_closed = // Closed by user
|
||||
|
|
Loading…
Reference in New Issue