mirror of https://github.com/acanas/swad-core.git
Version 14.69
This commit is contained in:
parent
391395edc8
commit
7c214165c6
|
@ -39,13 +39,14 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 14.68.2 (2015/01/25)"
|
#define Log_PLATFORM_VERSION "SWAD 14.69 (2015/01/26)"
|
||||||
|
|
||||||
// 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 | tail -1
|
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h | tail -1
|
||||||
/*
|
/*
|
||||||
Comprobar que se pueden buscar documentos abiertos en titulaciones, centros e instituciones
|
Comprobar que se pueden buscar documentos abiertos en titulaciones, centros e instituciones
|
||||||
|
|
||||||
|
Version 14.69: Jan 26, 2015 Changes in search of documents. (175818 lines)
|
||||||
Version 14.68.2: Jan 25, 2015 Fixed bugs in search of documents.
|
Version 14.68.2: Jan 25, 2015 Fixed bugs in search of documents.
|
||||||
Search of user's documents now extended to institution, centre and degree. (175644 lines)
|
Search of user's documents now extended to institution, centre and degree. (175644 lines)
|
||||||
Version 14.68.1: Jan 25, 2015 Changes in codes stores in expanded_folders table. (175618 lines)
|
Version 14.68.1: Jan 25, 2015 Changes in codes stores in expanded_folders table. (175618 lines)
|
||||||
|
|
|
@ -10413,6 +10413,8 @@ unsigned Brw_ListDocsFound (const char *Query,const char *Title)
|
||||||
{
|
{
|
||||||
extern const char *Txt_document;
|
extern const char *Txt_document;
|
||||||
extern const char *Txt_documents;
|
extern const char *Txt_documents;
|
||||||
|
extern const char *Txt_Institution;
|
||||||
|
extern const char *Txt_Centre;
|
||||||
extern const char *Txt_Degree;
|
extern const char *Txt_Degree;
|
||||||
extern const char *Txt_Course;
|
extern const char *Txt_Course;
|
||||||
extern const char *Txt_File_zone;
|
extern const char *Txt_File_zone;
|
||||||
|
@ -10435,7 +10437,7 @@ unsigned Brw_ListDocsFound (const char *Query,const char *Title)
|
||||||
|
|
||||||
/* Write header with number of documents found */
|
/* Write header with number of documents found */
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td colspan=\"5\" class=\"TIT_TBL\""
|
"<td colspan=\"7\" class=\"TIT_TBL\""
|
||||||
" style=\"text-align:center;\">");
|
" style=\"text-align:center;\">");
|
||||||
if (NumDocs == 1)
|
if (NumDocs == 1)
|
||||||
fprintf (Gbl.F.Out,"1 %s",Txt_document);
|
fprintf (Gbl.F.Out,"1 %s",Txt_document);
|
||||||
|
@ -10453,6 +10455,12 @@ unsigned Brw_ListDocsFound (const char *Query,const char *Title)
|
||||||
"<th class=\"TIT_TBL\" style=\"text-align:left;\">"
|
"<th class=\"TIT_TBL\" style=\"text-align:left;\">"
|
||||||
"%s"
|
"%s"
|
||||||
"</th>"
|
"</th>"
|
||||||
|
"<th class=\"TIT_TBL\" style=\"text-align:left;\">"
|
||||||
|
"%s"
|
||||||
|
"</th>"
|
||||||
|
"<th class=\"TIT_TBL\" style=\"text-align:left;\">"
|
||||||
|
"%s"
|
||||||
|
"</th>"
|
||||||
"<th class=\"TIT_TBL\" style=\"text-align:left;\">"
|
"<th class=\"TIT_TBL\" style=\"text-align:left;\">"
|
||||||
"%s"
|
"%s"
|
||||||
"</th>"
|
"</th>"
|
||||||
|
@ -10460,6 +10468,8 @@ unsigned Brw_ListDocsFound (const char *Query,const char *Title)
|
||||||
"%s"
|
"%s"
|
||||||
"</th>"
|
"</th>"
|
||||||
"</tr>",
|
"</tr>",
|
||||||
|
Txt_Institution,
|
||||||
|
Txt_Centre,
|
||||||
Txt_Degree,
|
Txt_Degree,
|
||||||
Txt_Course,
|
Txt_Course,
|
||||||
Txt_File_zone,
|
Txt_File_zone,
|
||||||
|
@ -10480,7 +10490,7 @@ unsigned Brw_ListDocsFound (const char *Query,const char *Title)
|
||||||
/***** Write footer *****/
|
/***** Write footer *****/
|
||||||
/* Number of documents not hidden found */
|
/* Number of documents not hidden found */
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td colspan=\"5\" class=\"TIT_TBL\""
|
"<td colspan=\"7\" class=\"TIT_TBL\""
|
||||||
" style=\"text-align:center;\">"
|
" style=\"text-align:center;\">"
|
||||||
"(");
|
"(");
|
||||||
NumDocsHidden = NumDocs - NumDocsNotHidden;
|
NumDocsHidden = NumDocs - NumDocsNotHidden;
|
||||||
|
@ -10516,29 +10526,63 @@ static void Brw_WriteRowDocData (unsigned *NumDocsNotHidden,MYSQL_ROW row)
|
||||||
extern const char *Txt_Private_storage_zone;
|
extern const char *Txt_Private_storage_zone;
|
||||||
extern const char *Txt_Go_to_X;
|
extern const char *Txt_Go_to_X;
|
||||||
struct FileMetadata FileMetadata;
|
struct FileMetadata FileMetadata;
|
||||||
|
long InsCod;
|
||||||
|
long CtrCod;
|
||||||
long DegCod;
|
long DegCod;
|
||||||
long CrsCod;
|
long CrsCod;
|
||||||
long GrpCod;
|
long GrpCod;
|
||||||
|
const char *InsShortName;
|
||||||
|
const char *CtrShortName;
|
||||||
|
const char *DegShortName;
|
||||||
|
const char *CrsShortName;
|
||||||
const char *BgColor;
|
const char *BgColor;
|
||||||
const char *Title;
|
const char *Title;
|
||||||
char PathUntilFileName[PATH_MAX+1];
|
char PathUntilFileName[PATH_MAX+1];
|
||||||
char FileName[NAME_MAX+1];
|
char FileName[NAME_MAX+1];
|
||||||
char FileNameToShow[NAME_MAX+1];
|
char FileNameToShow[NAME_MAX+1];
|
||||||
|
/*
|
||||||
|
row[ 0] = FilCod
|
||||||
|
row[ 1] = PathFromRoot
|
||||||
|
row[ 2] = InsCod
|
||||||
|
row[ 3] = InsShortName
|
||||||
|
row[ 4] = CtrCod
|
||||||
|
row[ 5] = CtrShortName
|
||||||
|
row[ 6] = DegCod
|
||||||
|
row[ 7] = DegShortName
|
||||||
|
row[ 8] = CrsCod
|
||||||
|
row[ 9] = CrsShortName
|
||||||
|
row[10] = GrpCod
|
||||||
|
*/
|
||||||
/***** Get file code (row[0]) and metadata *****/
|
/***** Get file code (row[0]) and metadata *****/
|
||||||
FileMetadata.FilCod = Str_ConvertStrCodToLongCod (row[0]);
|
FileMetadata.FilCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
Brw_GetFileMetadataByCod (&FileMetadata);
|
Brw_GetFileMetadataByCod (&FileMetadata);
|
||||||
|
|
||||||
if (!Brw_CheckIfFileOrFolderIsHidden (&FileMetadata))
|
if (!Brw_CheckIfFileOrFolderIsHidden (&FileMetadata))
|
||||||
{
|
{
|
||||||
|
/***** Get institution code (row[2]) *****/
|
||||||
|
InsCod = Str_ConvertStrCodToLongCod (row[2]);
|
||||||
|
InsShortName = row[3];
|
||||||
|
|
||||||
|
/***** Get centre code (row[4]) *****/
|
||||||
|
CtrCod = Str_ConvertStrCodToLongCod (row[4]);
|
||||||
|
CtrShortName = row[5];
|
||||||
|
|
||||||
|
/***** Get degree code (row[6]) *****/
|
||||||
|
DegCod = Str_ConvertStrCodToLongCod (row[6]);
|
||||||
|
DegShortName = row[7];
|
||||||
|
|
||||||
|
/***** Get course code (row[8]) *****/
|
||||||
|
CrsCod = Str_ConvertStrCodToLongCod (row[8]);
|
||||||
|
CrsShortName = row[9];
|
||||||
|
|
||||||
|
/***** Get group code (row[8]) *****/
|
||||||
|
GrpCod = Str_ConvertStrCodToLongCod (row[10]);
|
||||||
|
|
||||||
|
/***** Set row color *****/
|
||||||
BgColor = Gbl.ColorRows[Gbl.RowEvenOdd];
|
BgColor = Gbl.ColorRows[Gbl.RowEvenOdd];
|
||||||
Brw_GetCrsGrpFromFileMetadata (FileMetadata.FileBrowser,FileMetadata.Cod,&CrsCod,&GrpCod);
|
|
||||||
if (CrsCod > 0 && CrsCod == Gbl.CurrentCrs.Crs.CrsCod)
|
if (CrsCod > 0 && CrsCod == Gbl.CurrentCrs.Crs.CrsCod)
|
||||||
BgColor = VERY_LIGHT_BLUE;
|
BgColor = VERY_LIGHT_BLUE;
|
||||||
|
|
||||||
/***** Get degree code (row[2]) *****/
|
|
||||||
DegCod = Str_ConvertStrCodToLongCod (row[2]);
|
|
||||||
|
|
||||||
/***** Write number of document in this search *****/
|
/***** Write number of document in this search *****/
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td class=\"DAT\" style=\"text-align:right;"
|
"<td class=\"DAT\" style=\"text-align:right;"
|
||||||
|
@ -10547,7 +10591,43 @@ static void Brw_WriteRowDocData (unsigned *NumDocsNotHidden,MYSQL_ROW row)
|
||||||
"</td>",
|
"</td>",
|
||||||
BgColor,++(*NumDocsNotHidden));
|
BgColor,++(*NumDocsNotHidden));
|
||||||
|
|
||||||
/***** Write degree logo, degree short name (row[3]) and centre short name (row[4]) *****/
|
/***** Write institution logo, institution short name *****/
|
||||||
|
fprintf (Gbl.F.Out,"<td class=\"DAT\" style=\"text-align:left;"
|
||||||
|
" vertical-align:top; background-color:%s;\">",
|
||||||
|
BgColor);
|
||||||
|
if (InsCod > 0)
|
||||||
|
{
|
||||||
|
Act_FormGoToStart (ActSeeInsInf);
|
||||||
|
Deg_PutParamDegCod (InsCod);
|
||||||
|
sprintf (Gbl.Title,Txt_Go_to_X,InsShortName);
|
||||||
|
Act_LinkFormSubmit (Gbl.Title,"DAT");
|
||||||
|
Log_DrawLogo (Sco_SCOPE_INSTITUTION,InsCod,InsShortName,
|
||||||
|
16,"vertical-align:top;",true);
|
||||||
|
fprintf (Gbl.F.Out," %s</a>"
|
||||||
|
"</form>",
|
||||||
|
InsShortName);
|
||||||
|
}
|
||||||
|
fprintf (Gbl.F.Out,"</td>");
|
||||||
|
|
||||||
|
/***** Write centre logo, centre short name *****/
|
||||||
|
fprintf (Gbl.F.Out,"<td class=\"DAT\" style=\"text-align:left;"
|
||||||
|
" vertical-align:top; background-color:%s;\">",
|
||||||
|
BgColor);
|
||||||
|
if (CtrCod > 0)
|
||||||
|
{
|
||||||
|
Act_FormGoToStart (ActSeeCtrInf);
|
||||||
|
Deg_PutParamDegCod (CtrCod);
|
||||||
|
sprintf (Gbl.Title,Txt_Go_to_X,CtrShortName);
|
||||||
|
Act_LinkFormSubmit (Gbl.Title,"DAT");
|
||||||
|
Log_DrawLogo (Sco_SCOPE_CENTRE,CtrCod,CtrShortName,
|
||||||
|
16,"vertical-align:top;",true);
|
||||||
|
fprintf (Gbl.F.Out," %s</a>"
|
||||||
|
"</form>",
|
||||||
|
CtrShortName);
|
||||||
|
}
|
||||||
|
fprintf (Gbl.F.Out,"</td>");
|
||||||
|
|
||||||
|
/***** Write degree logo, degree short name *****/
|
||||||
fprintf (Gbl.F.Out,"<td class=\"DAT\" style=\"text-align:left;"
|
fprintf (Gbl.F.Out,"<td class=\"DAT\" style=\"text-align:left;"
|
||||||
" vertical-align:top; background-color:%s;\">",
|
" vertical-align:top; background-color:%s;\">",
|
||||||
BgColor);
|
BgColor);
|
||||||
|
@ -10555,17 +10635,17 @@ static void Brw_WriteRowDocData (unsigned *NumDocsNotHidden,MYSQL_ROW row)
|
||||||
{
|
{
|
||||||
Act_FormGoToStart (ActSeeDegInf);
|
Act_FormGoToStart (ActSeeDegInf);
|
||||||
Deg_PutParamDegCod (DegCod);
|
Deg_PutParamDegCod (DegCod);
|
||||||
sprintf (Gbl.Title,Txt_Go_to_X,row[5]);
|
sprintf (Gbl.Title,Txt_Go_to_X,DegShortName);
|
||||||
Act_LinkFormSubmit (Gbl.Title,"DAT");
|
Act_LinkFormSubmit (Gbl.Title,"DAT");
|
||||||
Log_DrawLogo (Sco_SCOPE_DEGREE,DegCod,row[4],
|
Log_DrawLogo (Sco_SCOPE_DEGREE,DegCod,DegShortName,
|
||||||
16,"vertical-align:top;",true);
|
16,"vertical-align:top;",true);
|
||||||
fprintf (Gbl.F.Out," %s (%s)</a>"
|
fprintf (Gbl.F.Out," %s</a>"
|
||||||
"</form>",
|
"</form>",
|
||||||
row[3],row[4]);
|
DegShortName);
|
||||||
}
|
}
|
||||||
fprintf (Gbl.F.Out,"</td>");
|
fprintf (Gbl.F.Out,"</td>");
|
||||||
|
|
||||||
/***** Write course short name (row[5]) *****/
|
/***** Write course short name *****/
|
||||||
fprintf (Gbl.F.Out,"<td class=\"DAT\" style=\"text-align:left;"
|
fprintf (Gbl.F.Out,"<td class=\"DAT\" style=\"text-align:left;"
|
||||||
" vertical-align:top; background-color:%s;\">",
|
" vertical-align:top; background-color:%s;\">",
|
||||||
BgColor);
|
BgColor);
|
||||||
|
@ -10573,11 +10653,11 @@ static void Brw_WriteRowDocData (unsigned *NumDocsNotHidden,MYSQL_ROW row)
|
||||||
{
|
{
|
||||||
Act_FormGoToStart (ActSeeCrsInf);
|
Act_FormGoToStart (ActSeeCrsInf);
|
||||||
Crs_PutParamCrsCod (CrsCod);
|
Crs_PutParamCrsCod (CrsCod);
|
||||||
sprintf (Gbl.Title,Txt_Go_to_X,row[5]);
|
sprintf (Gbl.Title,Txt_Go_to_X,CrsShortName);
|
||||||
Act_LinkFormSubmit (Gbl.Title,"DAT");
|
Act_LinkFormSubmit (Gbl.Title,"DAT");
|
||||||
fprintf (Gbl.F.Out,"%s</a>"
|
fprintf (Gbl.F.Out,"%s</a>"
|
||||||
"</form>",
|
"</form>",
|
||||||
row[5]);
|
CrsShortName);
|
||||||
}
|
}
|
||||||
fprintf (Gbl.F.Out,"</td>");
|
fprintf (Gbl.F.Out,"</td>");
|
||||||
|
|
||||||
|
|
190
swad_search.c
190
swad_search.c
|
@ -749,7 +749,7 @@ static unsigned Sch_SearchOpenDocumentsInDB (const char *RangeQuery)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Open_documents;
|
extern const char *Txt_Open_documents;
|
||||||
char SearchQuery[Sch_MAX_LENGTH_SEARCH_QUERY+1];
|
char SearchQuery[Sch_MAX_LENGTH_SEARCH_QUERY+1];
|
||||||
char Query[1024+Sch_MAX_LENGTH_SEARCH_QUERY*2];
|
char Query[(512+Sch_MAX_LENGTH_SEARCH_QUERY)*4];
|
||||||
|
|
||||||
/***** Check user's permission *****/
|
/***** Check user's permission *****/
|
||||||
if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_OPEN_DOCUMENTS))
|
if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_OPEN_DOCUMENTS))
|
||||||
|
@ -758,10 +758,60 @@ static unsigned Sch_SearchOpenDocumentsInDB (const char *RangeQuery)
|
||||||
"_latin1 "," COLLATE latin1_general_ci"))
|
"_latin1 "," COLLATE latin1_general_ci"))
|
||||||
{
|
{
|
||||||
/***** Build the query *****/
|
/***** Build the query *****/
|
||||||
sprintf (Query,"SELECT files.FilCod,"
|
sprintf (Query,"SELECT * FROM "
|
||||||
|
"("
|
||||||
|
"SELECT files.FilCod," // Institution
|
||||||
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
||||||
"degrees.DegCod,degrees.ShortName,"
|
"institutions.InsCod,institutions.ShortName AS InsShortName,"
|
||||||
"centres.ShortName,courses.ShortName"
|
"'-1' AS CtrCod,'' AS CtrShortName,"
|
||||||
|
"'-1' AS DegCod,'' AS DegShortName,"
|
||||||
|
"'-1' AS CrsCod,'' AS CrsShortName,"
|
||||||
|
"'-1' AS GrpCod"
|
||||||
|
" FROM files,degrees,centres,institutions,countries"
|
||||||
|
" WHERE files.Public='Y' AND %s"
|
||||||
|
" AND files.FileBrowser='%u'"
|
||||||
|
" AND files.Cod=institutions.InsCod"
|
||||||
|
" AND institutions.CtyCod=countries.CtyCod"
|
||||||
|
"%s"
|
||||||
|
" UNION "
|
||||||
|
"SELECT files.FilCod," // Centre
|
||||||
|
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
||||||
|
"institutions.InsCod,institutions.ShortName AS InsShortName,"
|
||||||
|
"centres.CtrCod,centres.ShortName AS CtrShortName,"
|
||||||
|
"'-1' AS DegCod,'' AS DegShortName,"
|
||||||
|
"'-1' AS CrsCod,'' AS CrsShortName,"
|
||||||
|
"'-1' AS GrpCod"
|
||||||
|
" FROM files,degrees,centres,institutions,countries"
|
||||||
|
" WHERE files.Public='Y' AND %s"
|
||||||
|
" AND files.FileBrowser='%u'"
|
||||||
|
" AND files.Cod=centres.CtrCod"
|
||||||
|
" AND centres.InsCod=institutions.InsCod"
|
||||||
|
" AND institutions.CtyCod=countries.CtyCod"
|
||||||
|
"%s"
|
||||||
|
" UNION "
|
||||||
|
"SELECT files.FilCod," // Degree
|
||||||
|
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
||||||
|
"institutions.InsCod,institutions.ShortName AS InsShortName,"
|
||||||
|
"centres.CtrCod,centres.ShortName AS CtrShortName,"
|
||||||
|
"degrees.DegCod,degrees.ShortName AS DegShortName,"
|
||||||
|
"'-1','' AS CrsShortName,"
|
||||||
|
"'-1'"
|
||||||
|
" FROM files,degrees,centres,institutions,countries"
|
||||||
|
" WHERE files.Public='Y' AND %s"
|
||||||
|
" AND files.FileBrowser='%u'"
|
||||||
|
" AND files.Cod=degrees.DegCod"
|
||||||
|
" AND degrees.CtrCod=centres.CtrCod"
|
||||||
|
" AND centres.InsCod=institutions.InsCod"
|
||||||
|
" AND institutions.CtyCod=countries.CtyCod"
|
||||||
|
"%s"
|
||||||
|
" UNION "
|
||||||
|
"SELECT files.FilCod," // Course
|
||||||
|
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
||||||
|
"institutions.InsCod,institutions.ShortName AS InsShortName,"
|
||||||
|
"centres.CtrCod,centres.ShortName AS CtrShortName,"
|
||||||
|
"degrees.DegCod,degrees.ShortName AS DegShortName,"
|
||||||
|
"courses.CrsCod,courses.ShortName AS CrsShortName,"
|
||||||
|
"'-1'"
|
||||||
" FROM files,courses,degrees,centres,institutions,countries"
|
" FROM files,courses,degrees,centres,institutions,countries"
|
||||||
" WHERE files.Public='Y' AND %s"
|
" WHERE files.Public='Y' AND %s"
|
||||||
" AND files.FileBrowser IN ('%u','%u')"
|
" AND files.FileBrowser IN ('%u','%u')"
|
||||||
|
@ -771,8 +821,18 @@ static unsigned Sch_SearchOpenDocumentsInDB (const char *RangeQuery)
|
||||||
" AND centres.InsCod=institutions.InsCod"
|
" AND centres.InsCod=institutions.InsCod"
|
||||||
" AND institutions.CtyCod=countries.CtyCod"
|
" AND institutions.CtyCod=countries.CtyCod"
|
||||||
"%s"
|
"%s"
|
||||||
" HAVING PathFromRoot<>''"
|
") AS selected_files"
|
||||||
" ORDER BY degrees.ShortName,courses.ShortName,PathFromRoot",
|
" WHERE PathFromRoot<>''"
|
||||||
|
" ORDER BY InsShortName,CtrShortName,DegShortName,CrsShortName,PathFromRoot",
|
||||||
|
SearchQuery,
|
||||||
|
(unsigned) Brw_FILE_BRW_ADMIN_DOCUMENTS_INS,
|
||||||
|
RangeQuery,
|
||||||
|
SearchQuery,
|
||||||
|
(unsigned) Brw_FILE_BRW_ADMIN_DOCUMENTS_CTR,
|
||||||
|
RangeQuery,
|
||||||
|
SearchQuery,
|
||||||
|
(unsigned) Brw_FILE_BRW_ADMIN_DOCUMENTS_DEG,
|
||||||
|
RangeQuery,
|
||||||
SearchQuery,
|
SearchQuery,
|
||||||
(unsigned) Brw_FILE_BRW_ADMIN_DOCUMENTS_CRS,
|
(unsigned) Brw_FILE_BRW_ADMIN_DOCUMENTS_CRS,
|
||||||
(unsigned) Brw_FILE_BRW_COMMON_CRS,
|
(unsigned) Brw_FILE_BRW_COMMON_CRS,
|
||||||
|
@ -795,7 +855,7 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Documents_in_my_courses;
|
extern const char *Txt_Documents_in_my_courses;
|
||||||
char SearchQuery[Sch_MAX_LENGTH_SEARCH_QUERY+1];
|
char SearchQuery[Sch_MAX_LENGTH_SEARCH_QUERY+1];
|
||||||
char Query[1024+Sch_MAX_LENGTH_SEARCH_QUERY*2];
|
char Query[(512+Sch_MAX_LENGTH_SEARCH_QUERY)*2];
|
||||||
unsigned NumDocs;
|
unsigned NumDocs;
|
||||||
|
|
||||||
/***** Check user's permission *****/
|
/***** Check user's permission *****/
|
||||||
|
@ -806,20 +866,22 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
|
||||||
{
|
{
|
||||||
/***** Create temporary table with codes of files in documents and shared areas accessible by me.
|
/***** Create temporary table with codes of files in documents and shared areas accessible by me.
|
||||||
It is necessary to speed up the second query *****/
|
It is necessary to speed up the second query *****/
|
||||||
sprintf (Query,"CREATE TEMPORARY TABLE my_files (FilCod INT NOT NULL,UNIQUE INDEX(FilCod)) ENGINE=MEMORY"
|
sprintf (Query,"CREATE TEMPORARY TABLE my_files_crs (FilCod INT NOT NULL,UNIQUE INDEX(FilCod)) ENGINE=MEMORY"
|
||||||
" SELECT files.FilCod FROM crs_usr,files"
|
" SELECT files.FilCod FROM crs_usr,files"
|
||||||
" WHERE crs_usr.UsrCod='%ld'"
|
" WHERE crs_usr.UsrCod='%ld'"
|
||||||
" AND crs_usr.CrsCod=files.Cod"
|
" AND crs_usr.CrsCod=files.Cod"
|
||||||
" AND files.FileBrowser IN ('%u','%u','%u')"
|
|
||||||
" UNION"
|
|
||||||
" SELECT files.FilCod FROM crs_grp_usr,files"
|
|
||||||
" WHERE crs_grp_usr.UsrCod='%ld'"
|
|
||||||
" AND crs_grp_usr.GrpCod=files.Cod"
|
|
||||||
" AND files.FileBrowser IN ('%u','%u','%u')",
|
" AND files.FileBrowser IN ('%u','%u','%u')",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
(unsigned) Brw_FILE_BRW_ADMIN_DOCUMENTS_CRS,
|
(unsigned) Brw_FILE_BRW_ADMIN_DOCUMENTS_CRS,
|
||||||
(unsigned) Brw_FILE_BRW_COMMON_CRS,
|
(unsigned) Brw_FILE_BRW_COMMON_CRS,
|
||||||
(unsigned) Brw_FILE_BRW_ADMIN_MARKS_CRS,
|
(unsigned) Brw_FILE_BRW_ADMIN_MARKS_CRS);
|
||||||
|
if (mysql_query (&Gbl.mysql,Query))
|
||||||
|
DB_ExitOnMySQLError ("can not create temporary table");
|
||||||
|
sprintf (Query,"CREATE TEMPORARY TABLE my_files_grp (FilCod INT NOT NULL,UNIQUE INDEX(FilCod)) ENGINE=MEMORY"
|
||||||
|
" SELECT files.FilCod FROM crs_grp_usr,files"
|
||||||
|
" WHERE crs_grp_usr.UsrCod='%ld'"
|
||||||
|
" AND crs_grp_usr.GrpCod=files.Cod"
|
||||||
|
" AND files.FileBrowser IN ('%u','%u','%u')",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
(unsigned) Brw_FILE_BRW_ADMIN_DOCUMENTS_GRP,
|
(unsigned) Brw_FILE_BRW_ADMIN_DOCUMENTS_GRP,
|
||||||
(unsigned) Brw_FILE_BRW_COMMON_GRP,
|
(unsigned) Brw_FILE_BRW_COMMON_GRP,
|
||||||
|
@ -830,33 +892,52 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
|
||||||
DB_ExitOnMySQLError ("can not create temporary table");
|
DB_ExitOnMySQLError ("can not create temporary table");
|
||||||
|
|
||||||
/***** Build the query *****/
|
/***** Build the query *****/
|
||||||
sprintf (Query,"SELECT files.FilCod,"
|
sprintf (Query,"SELECT * FROM "
|
||||||
|
"("
|
||||||
|
"SELECT files.FilCod,"
|
||||||
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
||||||
"degrees.DegCod,degrees.ShortName,"
|
"institutions.InsCod,institutions.ShortName AS InsShortName,"
|
||||||
"centres.ShortName,courses.ShortName"
|
"centres.CtrCod,centres.ShortName AS CtrShortName,"
|
||||||
" FROM files,crs_grp,crs_grp_types,courses,degrees,centres,institutions,countries"
|
"degrees.DegCod,degrees.ShortName AS DegShortName,"
|
||||||
" WHERE files.FilCod IN (SELECT FilCod FROM my_files) AND %s"
|
"courses.CrsCod,courses.ShortName AS CrsShortName,"
|
||||||
" AND "
|
"'-1' AS GrpCod"
|
||||||
"("
|
" FROM files,courses,degrees,centres,institutions,countries"
|
||||||
"(files.FileBrowser IN ('%u','%u','%u')"
|
" WHERE files.FilCod IN (SELECT FilCod FROM my_files_crs) AND %s"
|
||||||
" AND files.Cod=courses.CrsCod)"
|
" AND files.FileBrowser IN ('%u','%u','%u')"
|
||||||
" OR "
|
" AND files.Cod=courses.CrsCod"
|
||||||
"(files.FileBrowser IN ('%u','%u','%u')"
|
|
||||||
" AND files.Cod=crs_grp.GrpCod"
|
|
||||||
" AND crs_grp.GrpTypCod=crs_grp_types.GrpTypCod"
|
|
||||||
" AND crs_grp_types.CrsCod=courses.CrsCod)"
|
|
||||||
")"
|
|
||||||
" AND courses.DegCod=degrees.DegCod"
|
" AND courses.DegCod=degrees.DegCod"
|
||||||
" AND degrees.CtrCod=centres.CtrCod"
|
" AND degrees.CtrCod=centres.CtrCod"
|
||||||
" AND centres.InsCod=institutions.InsCod"
|
" AND centres.InsCod=institutions.InsCod"
|
||||||
" AND institutions.CtyCod=countries.CtyCod"
|
" AND institutions.CtyCod=countries.CtyCod"
|
||||||
"%s"
|
"%s"
|
||||||
" HAVING PathFromRoot<>''"
|
" UNION "
|
||||||
" ORDER BY degrees.ShortName,courses.ShortName,PathFromRoot",
|
"SELECT files.FilCod,"
|
||||||
|
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
||||||
|
"institutions.InsCod,institutions.ShortName AS InsShortName,"
|
||||||
|
"centres.CtrCod,centres.ShortName AS CtrShortName,"
|
||||||
|
"degrees.DegCod,degrees.ShortName AS DegShortName,"
|
||||||
|
"courses.CrsCod,courses.ShortName AS CrsShortName,"
|
||||||
|
"crs_grp.GrpCod"
|
||||||
|
" FROM files,crs_grp,crs_grp_types,courses,degrees,centres,institutions,countries"
|
||||||
|
" WHERE files.FilCod IN (SELECT FilCod FROM my_files_grp) AND %s"
|
||||||
|
" AND files.FileBrowser IN ('%u','%u','%u')"
|
||||||
|
" AND files.Cod=crs_grp.GrpCod"
|
||||||
|
" AND crs_grp.GrpTypCod=crs_grp_types.GrpTypCod"
|
||||||
|
" AND crs_grp_types.CrsCod=courses.CrsCod"
|
||||||
|
" AND courses.DegCod=degrees.DegCod"
|
||||||
|
" AND degrees.CtrCod=centres.CtrCod"
|
||||||
|
" AND centres.InsCod=institutions.InsCod"
|
||||||
|
" AND institutions.CtyCod=countries.CtyCod"
|
||||||
|
"%s"
|
||||||
|
") AS selected_files"
|
||||||
|
" WHERE PathFromRoot<>''"
|
||||||
|
" ORDER BY InsShortName,CtrShortName,DegShortName,CrsShortName,PathFromRoot",
|
||||||
SearchQuery,
|
SearchQuery,
|
||||||
(unsigned) Brw_FILE_BRW_ADMIN_DOCUMENTS_CRS,
|
(unsigned) Brw_FILE_BRW_ADMIN_DOCUMENTS_CRS,
|
||||||
(unsigned) Brw_FILE_BRW_COMMON_CRS,
|
(unsigned) Brw_FILE_BRW_COMMON_CRS,
|
||||||
(unsigned) Brw_FILE_BRW_ADMIN_MARKS_CRS,
|
(unsigned) Brw_FILE_BRW_ADMIN_MARKS_CRS,
|
||||||
|
RangeQuery,
|
||||||
|
SearchQuery,
|
||||||
(unsigned) Brw_FILE_BRW_ADMIN_DOCUMENTS_GRP,
|
(unsigned) Brw_FILE_BRW_ADMIN_DOCUMENTS_GRP,
|
||||||
(unsigned) Brw_FILE_BRW_COMMON_GRP,
|
(unsigned) Brw_FILE_BRW_COMMON_GRP,
|
||||||
(unsigned) Brw_FILE_BRW_ADMIN_MARKS_GRP,
|
(unsigned) Brw_FILE_BRW_ADMIN_MARKS_GRP,
|
||||||
|
@ -868,7 +949,7 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
|
||||||
NumDocs = Brw_ListDocsFound (Query,Txt_Documents_in_my_courses);
|
NumDocs = Brw_ListDocsFound (Query,Txt_Documents_in_my_courses);
|
||||||
|
|
||||||
/***** Drop temporary table *****/
|
/***** Drop temporary table *****/
|
||||||
sprintf (Query,"DROP TABLE IF EXISTS my_files");
|
sprintf (Query,"DROP TEMPORARY TABLE IF EXISTS my_files_crs,my_files_grp");
|
||||||
if (mysql_query (&Gbl.mysql,Query))
|
if (mysql_query (&Gbl.mysql,Query))
|
||||||
DB_ExitOnMySQLError ("can not remove temporary table");
|
DB_ExitOnMySQLError ("can not remove temporary table");
|
||||||
|
|
||||||
|
@ -899,33 +980,40 @@ static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery)
|
||||||
"("
|
"("
|
||||||
"SELECT files.FilCod," // Institution
|
"SELECT files.FilCod," // Institution
|
||||||
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
||||||
"'-1','' AS DegShortName,'','' AS CrsShortName"
|
"institutions.InsCod,institutions.ShortName AS InsShortName,"
|
||||||
|
"'-1' AS CtrCod,'' AS CtrShortName,"
|
||||||
|
"'-1' AS DegCod,'' AS DegShortName,"
|
||||||
|
"'-1' AS CrsCod,'' AS CrsShortName,"
|
||||||
|
"'-1' AS GrpCod"
|
||||||
" FROM files,degrees,centres,institutions,countries"
|
" FROM files,degrees,centres,institutions,countries"
|
||||||
" WHERE files.PublisherUsrCod='%ld' AND %s"
|
" WHERE files.PublisherUsrCod='%ld' AND %s"
|
||||||
" AND files.FileBrowser='%u'"
|
" AND files.FileBrowser='%u'"
|
||||||
" AND files.Cod=degrees.DegCod"
|
" AND files.Cod=institutions.InsCod"
|
||||||
" AND degrees.CtrCod=centres.CtrCod"
|
|
||||||
" AND centres.InsCod=institutions.InsCod"
|
|
||||||
" AND institutions.CtyCod=countries.CtyCod"
|
" AND institutions.CtyCod=countries.CtyCod"
|
||||||
"%s"
|
"%s"
|
||||||
" UNION "
|
" UNION "
|
||||||
"SELECT files.FilCod," // Centre
|
"SELECT files.FilCod," // Centre
|
||||||
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
||||||
"'-1','' AS DegShortName,"
|
"institutions.InsCod,institutions.ShortName AS InsShortName,"
|
||||||
"centres.ShortName,'' AS CrsShortName"
|
"centres.CtrCod,centres.ShortName AS CtrShortName,"
|
||||||
|
"'-1' AS DegCod,'' AS DegShortName,"
|
||||||
|
"'-1' AS CrsCod,'' AS CrsShortName,"
|
||||||
|
"'-1' AS GrpCod"
|
||||||
" FROM files,degrees,centres,institutions,countries"
|
" FROM files,degrees,centres,institutions,countries"
|
||||||
" WHERE files.PublisherUsrCod='%ld' AND %s"
|
" WHERE files.PublisherUsrCod='%ld' AND %s"
|
||||||
" AND files.FileBrowser='%u'"
|
" AND files.FileBrowser='%u'"
|
||||||
" AND files.Cod=degrees.DegCod"
|
" AND files.Cod=centres.CtrCod"
|
||||||
" AND degrees.CtrCod=centres.CtrCod"
|
|
||||||
" AND centres.InsCod=institutions.InsCod"
|
" AND centres.InsCod=institutions.InsCod"
|
||||||
" AND institutions.CtyCod=countries.CtyCod"
|
" AND institutions.CtyCod=countries.CtyCod"
|
||||||
"%s"
|
"%s"
|
||||||
" UNION "
|
" UNION "
|
||||||
"SELECT files.FilCod," // Degree
|
"SELECT files.FilCod," // Degree
|
||||||
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
||||||
|
"institutions.InsCod,institutions.ShortName AS InsShortName,"
|
||||||
|
"centres.CtrCod,centres.ShortName AS CtrShortName,"
|
||||||
"degrees.DegCod,degrees.ShortName AS DegShortName,"
|
"degrees.DegCod,degrees.ShortName AS DegShortName,"
|
||||||
"centres.ShortName,'' AS CrsShortName"
|
"'-1' AS CrsCod,'' AS CrsShortName,"
|
||||||
|
"'-1' AS GrpCod"
|
||||||
" FROM files,degrees,centres,institutions,countries"
|
" FROM files,degrees,centres,institutions,countries"
|
||||||
" WHERE files.PublisherUsrCod='%ld' AND %s"
|
" WHERE files.PublisherUsrCod='%ld' AND %s"
|
||||||
" AND files.FileBrowser='%u'"
|
" AND files.FileBrowser='%u'"
|
||||||
|
@ -937,8 +1025,11 @@ static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery)
|
||||||
" UNION "
|
" UNION "
|
||||||
"SELECT files.FilCod," // Course
|
"SELECT files.FilCod," // Course
|
||||||
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
||||||
|
"institutions.InsCod,institutions.ShortName AS InsShortName,"
|
||||||
|
"centres.CtrCod,centres.ShortName AS CtrShortName,"
|
||||||
"degrees.DegCod,degrees.ShortName AS DegShortName,"
|
"degrees.DegCod,degrees.ShortName AS DegShortName,"
|
||||||
"centres.ShortName,courses.ShortName AS CrsShortName"
|
"courses.CrsCod,courses.ShortName AS CrsShortName,"
|
||||||
|
"'-1' AS GrpCod"
|
||||||
" FROM files,courses,degrees,centres,institutions,countries"
|
" FROM files,courses,degrees,centres,institutions,countries"
|
||||||
" WHERE files.PublisherUsrCod='%ld' AND %s"
|
" WHERE files.PublisherUsrCod='%ld' AND %s"
|
||||||
" AND files.FileBrowser IN ('%u','%u','%u')"
|
" AND files.FileBrowser IN ('%u','%u','%u')"
|
||||||
|
@ -951,8 +1042,11 @@ static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery)
|
||||||
" UNION "
|
" UNION "
|
||||||
"SELECT files.FilCod," // Group
|
"SELECT files.FilCod," // Group
|
||||||
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
||||||
|
"institutions.InsCod,institutions.ShortName AS InsShortName,"
|
||||||
|
"centres.CtrCod,centres.ShortName AS CtrShortName,"
|
||||||
"degrees.DegCod,degrees.ShortName AS DegShortName,"
|
"degrees.DegCod,degrees.ShortName AS DegShortName,"
|
||||||
"centres.ShortName,courses.ShortName AS CrsShortName"
|
"courses.CrsCod,courses.ShortName AS CrsShortName,"
|
||||||
|
"crs_grp.GrpCod"
|
||||||
" FROM files,crs_grp,crs_grp_types,courses,degrees,centres,institutions,countries"
|
" FROM files,crs_grp,crs_grp_types,courses,degrees,centres,institutions,countries"
|
||||||
" WHERE files.PublisherUsrCod='%ld' AND %s"
|
" WHERE files.PublisherUsrCod='%ld' AND %s"
|
||||||
" AND files.FileBrowser IN ('%u','%u','%u')"
|
" AND files.FileBrowser IN ('%u','%u','%u')"
|
||||||
|
@ -967,13 +1061,17 @@ static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery)
|
||||||
" UNION "
|
" UNION "
|
||||||
"SELECT files.FilCod," // Briefcase
|
"SELECT files.FilCod," // Briefcase
|
||||||
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
||||||
"'-1','' AS DegShortName,'','' AS CrsShortName"
|
"'-1' AS InsCod,'' AS InsShortName,"
|
||||||
|
"'-1' AS CtrCod,'' AS CtrShortName,"
|
||||||
|
"'-1' AS DegCod,'' AS DegShortName,"
|
||||||
|
"'-1' AS CrsCod,'' AS CrsShortName,"
|
||||||
|
"'-1' AS GrpCod"
|
||||||
" FROM files"
|
" FROM files"
|
||||||
" WHERE files.PublisherUsrCod='%ld' AND %s"
|
" WHERE files.PublisherUsrCod='%ld' AND %s"
|
||||||
" AND files.FileBrowser='%u'"
|
" AND files.FileBrowser='%u'"
|
||||||
") AS my_files"
|
") AS selected_files"
|
||||||
" WHERE PathFromRoot<>''"
|
" WHERE PathFromRoot<>''"
|
||||||
" ORDER BY DegShortName,CrsShortName,PathFromRoot",
|
" ORDER BY InsShortName,CtrShortName,DegShortName,CrsShortName,PathFromRoot",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,SearchQuery,
|
Gbl.Usrs.Me.UsrDat.UsrCod,SearchQuery,
|
||||||
(unsigned) Brw_FILE_BRW_ADMIN_DOCUMENTS_INS,
|
(unsigned) Brw_FILE_BRW_ADMIN_DOCUMENTS_INS,
|
||||||
RangeQuery,
|
RangeQuery,
|
||||||
|
|
Loading…
Reference in New Issue