mirror of https://github.com/acanas/swad-core.git
Version 21.33: Oct 15, 2021 Queries moved from search to other modules.
This commit is contained in:
parent
fe8f68723a
commit
f7ee3e7359
|
@ -1572,6 +1572,519 @@ unsigned Brw_DB_GetNumberOfPublicFiles (MYSQL_RES **mysql_res,Brw_License_t Lice
|
|||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Search open documents in database ********************/
|
||||
/*****************************************************************************/
|
||||
// Returns number of documents found
|
||||
|
||||
unsigned Brw_DB_SearchPublicFiles (MYSQL_RES **mysql_res,
|
||||
const char *RangeQuery,
|
||||
const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1])
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get files",
|
||||
"SELECT *"
|
||||
" FROM "
|
||||
// Institution
|
||||
"(SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"-1 AS CtrCod," // row[ 4]
|
||||
"'' AS CtrShortName," // row[ 5]
|
||||
"-1 AS DegCod," // row[ 6]
|
||||
"'' AS DegShortName," // row[ 7]
|
||||
"-1 AS CrsCod," // row[ 8]
|
||||
"'' AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.Public='Y'"
|
||||
" AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||
" AND brw_files.Cod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
// Center -------------------------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"ctr_centers.CtrCod," // row[ 4]
|
||||
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||
"-1 AS DegCod," // row[ 6]
|
||||
"'' AS DegShortName," // row[ 7]
|
||||
"-1 AS CrsCod," // row[ 8]
|
||||
"'' AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.Public='Y' AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||
" AND brw_files.Cod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
// Degree -------------------------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"ctr_centers.CtrCod," // row[ 4]
|
||||
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||
"deg_degrees.DegCod," // row[ 6]
|
||||
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||
"-1 AS CrsCod," // row[ 8]
|
||||
"'' AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.Public='Y' AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||
" AND brw_files.Cod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
// Course -------------------------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"ctr_centers.CtrCod," // row[ 4]
|
||||
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||
"deg_degrees.DegCod," // row[ 6]
|
||||
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||
"crs_courses.CrsCod," // row[ 8]
|
||||
"crs_courses.ShortName AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.Public='Y' AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||
" AND brw_files.Cod=crs_courses.CrsCod"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
") AS selected_files"
|
||||
" WHERE PathFromRoot<>''"
|
||||
" ORDER BY InsShortName,"
|
||||
"CtrShortName,"
|
||||
"DegShortName,"
|
||||
"CrsShortName,"
|
||||
"PathFromRoot",
|
||||
SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_INS,
|
||||
(unsigned) Brw_ADMI_SHR_INS,
|
||||
RangeQuery,
|
||||
SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_CTR,
|
||||
(unsigned) Brw_ADMI_SHR_CTR,
|
||||
RangeQuery,
|
||||
SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_DEG,
|
||||
(unsigned) Brw_ADMI_SHR_DEG,
|
||||
RangeQuery,
|
||||
SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_CRS,
|
||||
(unsigned) Brw_ADMI_SHR_CRS,
|
||||
RangeQuery);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************** Search documents in my courses in database *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Brw_DB_SearchFilesInMyCrss (MYSQL_RES **mysql_res,
|
||||
const char *RangeQuery,
|
||||
const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1])
|
||||
{
|
||||
unsigned NumFiles;
|
||||
|
||||
/***** Create temporary tables with codes of files in documents and shared areas accessible by me.
|
||||
It is necessary to speed up the second query *****/
|
||||
DB_Query ("can not remove temporary tables",
|
||||
"DROP TEMPORARY TABLE IF EXISTS my_files_crs,"
|
||||
"my_files_grp");
|
||||
|
||||
DB_Query ("can not create temporary table",
|
||||
"CREATE TEMPORARY TABLE my_files_crs"
|
||||
" (FilCod INT NOT NULL,"
|
||||
"UNIQUE INDEX(FilCod))"
|
||||
" ENGINE=MEMORY"
|
||||
" SELECT brw_files.FilCod"
|
||||
" FROM crs_users,"
|
||||
"brw_files"
|
||||
" WHERE crs_users.UsrCod=%ld"
|
||||
" AND crs_users.CrsCod=brw_files.Cod"
|
||||
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
(unsigned) Brw_ADMI_DOC_CRS,
|
||||
(unsigned) Brw_ADMI_TCH_CRS,
|
||||
(unsigned) Brw_ADMI_SHR_CRS,
|
||||
(unsigned) Brw_ADMI_MRK_CRS);
|
||||
|
||||
DB_Query ("can not create temporary table",
|
||||
"CREATE TEMPORARY TABLE my_files_grp"
|
||||
" (FilCod INT NOT NULL,"
|
||||
"UNIQUE INDEX(FilCod))"
|
||||
" ENGINE=MEMORY"
|
||||
" SELECT brw_files.FilCod"
|
||||
" FROM grp_users,"
|
||||
"brw_files"
|
||||
" WHERE grp_users.UsrCod=%ld"
|
||||
" AND grp_users.GrpCod=brw_files.Cod"
|
||||
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
(unsigned) Brw_ADMI_DOC_GRP,
|
||||
(unsigned) Brw_ADMI_TCH_GRP,
|
||||
(unsigned) Brw_ADMI_SHR_GRP,
|
||||
(unsigned) Brw_ADMI_MRK_GRP);
|
||||
|
||||
/***** Build the query *****/
|
||||
NumFiles = (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get files",
|
||||
"SELECT *"
|
||||
" FROM ("
|
||||
// Files in course zones ----------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',"
|
||||
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"ctr_centers.CtrCod," // row[ 4]
|
||||
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||
"deg_degrees.DegCod," // row[ 6]
|
||||
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||
"crs_courses.CrsCod," // row[ 8]
|
||||
"crs_courses.ShortName AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.FilCod IN"
|
||||
" (SELECT FilCod"
|
||||
" FROM my_files_crs)"
|
||||
" AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)"
|
||||
" AND brw_files.Cod=crs_courses.CrsCod"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
// Files in group zones -----------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',"
|
||||
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"ctr_centers.CtrCod," // row[ 4]
|
||||
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||
"deg_degrees.DegCod," // row[ 6]
|
||||
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||
"crs_courses.CrsCod," // row[ 8]
|
||||
"crs_courses.ShortName AS CrsShortName," // row[ 9]
|
||||
"grp_groups.GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"grp_groups,"
|
||||
"grp_types,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.FilCod IN"
|
||||
" (SELECT FilCod"
|
||||
" FROM my_files_grp)"
|
||||
" AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)"
|
||||
" AND brw_files.Cod=grp_groups.GrpCod"
|
||||
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod"
|
||||
" AND grp_types.CrsCod=crs_courses.CrsCod"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
") AS selected_files"
|
||||
" WHERE PathFromRoot<>''"
|
||||
" ORDER BY InsShortName,"
|
||||
"CtrShortName,"
|
||||
"DegShortName,"
|
||||
"CrsShortName,"
|
||||
"PathFromRoot",
|
||||
SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_CRS,
|
||||
(unsigned) Brw_ADMI_TCH_CRS,
|
||||
(unsigned) Brw_ADMI_SHR_CRS,
|
||||
(unsigned) Brw_ADMI_MRK_CRS,
|
||||
RangeQuery,
|
||||
SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_GRP,
|
||||
(unsigned) Brw_ADMI_TCH_GRP,
|
||||
(unsigned) Brw_ADMI_SHR_GRP,
|
||||
(unsigned) Brw_ADMI_MRK_GRP,
|
||||
RangeQuery);
|
||||
|
||||
/***** Drop temporary tables *****/
|
||||
DB_Query ("can not remove temporary table",
|
||||
"DROP TEMPORARY TABLE IF EXISTS my_files_crs,"
|
||||
"my_files_grp");
|
||||
|
||||
return NumFiles;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Search my documents in database **********************/
|
||||
/*****************************************************************************/
|
||||
// Returns number of documents found
|
||||
|
||||
unsigned Brw_DB_SearchMyFiles (MYSQL_RES **mysql_res,
|
||||
const char *RangeQuery,
|
||||
const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1])
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get files",
|
||||
"SELECT *"
|
||||
" FROM ("
|
||||
// Institution --------------------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',"
|
||||
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"-1 AS CtrCod," // row[ 4]
|
||||
"'' AS CtrShortName," // row[ 5]
|
||||
"-1 AS DegCod," // row[ 6]
|
||||
"'' AS DegShortName," // row[ 7]
|
||||
"-1 AS CrsCod," // row[ 8]
|
||||
"'' AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.PublisherUsrCod=%ld"
|
||||
" AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||
" AND brw_files.Cod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
// Center -------------------------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',"
|
||||
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"ctr_centers.CtrCod," // row[ 4]
|
||||
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||
"-1 AS DegCod," // row[ 6]
|
||||
"'' AS DegShortName," // row[ 7]
|
||||
"-1 AS CrsCod," // row[ 8]
|
||||
"'' AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.PublisherUsrCod=%ld AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||
" AND brw_files.Cod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
// Degree -------------------------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',"
|
||||
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"ctr_centers.CtrCod," // row[ 4]
|
||||
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||
"deg_degrees.DegCod," // row[ 6]
|
||||
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||
"-1 AS CrsCod," // row[ 8]
|
||||
"'' AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.PublisherUsrCod=%ld"
|
||||
" AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||
" AND brw_files.Cod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
// Course -------------------------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',"
|
||||
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"ctr_centers.CtrCod," // row[ 4]
|
||||
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||
"deg_degrees.DegCod," // row[ 6]
|
||||
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||
"crs_courses.CrsCod," // row[ 8]
|
||||
"crs_courses.ShortName AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.PublisherUsrCod=%ld"
|
||||
" AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)"
|
||||
" AND brw_files.Cod=crs_courses.CrsCod"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
// Group --------------------------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',"
|
||||
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"ctr_centers.CtrCod," // row[ 4]
|
||||
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||
"deg_degrees.DegCod," // row[ 6]
|
||||
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||
"crs_courses.CrsCod," // row[ 8]
|
||||
"crs_courses.ShortName AS CrsShortName," // row[ 9]
|
||||
"grp_groups.GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"grp_groups,"
|
||||
"grp_types,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.PublisherUsrCod=%ld"
|
||||
" AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)"
|
||||
" AND brw_files.Cod=grp_groups.GrpCod"
|
||||
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod"
|
||||
" AND grp_types.CrsCod=crs_courses.CrsCod"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
// Briefcase ----------------------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',"
|
||||
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"-1 AS InsCod," // row[ 2]
|
||||
"'' AS InsShortName," // row[ 3]
|
||||
"-1 AS CtrCod," // row[ 4]
|
||||
"'' AS CtrShortName," // row[ 5]
|
||||
"-1 AS DegCod," // row[ 6]
|
||||
"'' AS DegShortName," // row[ 7]
|
||||
"-1 AS CrsCod," // row[ 8]
|
||||
"'' AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files"
|
||||
" WHERE brw_files.PublisherUsrCod=%ld"
|
||||
" AND %s"
|
||||
" AND brw_files.FileBrowser=%u"
|
||||
") AS selected_files"
|
||||
" WHERE PathFromRoot<>''"
|
||||
" ORDER BY InsShortName,"
|
||||
"CtrShortName,"
|
||||
"DegShortName,"
|
||||
"CrsShortName,"
|
||||
"PathFromRoot",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_INS,
|
||||
(unsigned) Brw_ADMI_SHR_INS,
|
||||
RangeQuery,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_CTR,
|
||||
(unsigned) Brw_ADMI_SHR_CTR,
|
||||
RangeQuery,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_DEG,
|
||||
(unsigned) Brw_ADMI_SHR_DEG,
|
||||
RangeQuery,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_CRS,
|
||||
(unsigned) Brw_ADMI_TCH_CRS,
|
||||
(unsigned) Brw_ADMI_SHR_CRS,
|
||||
(unsigned) Brw_ADMI_MRK_CRS,
|
||||
RangeQuery,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_GRP,
|
||||
(unsigned) Brw_ADMI_TCH_GRP,
|
||||
(unsigned) Brw_ADMI_SHR_GRP,
|
||||
(unsigned) Brw_ADMI_MRK_GRP,
|
||||
RangeQuery,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
SearchQuery,
|
||||
(unsigned) Brw_ADMI_BRF_USR);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** Get folders of assignments **************************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <mysql/mysql.h> // To access MySQL databases
|
||||
|
||||
#include "swad_browser.h"
|
||||
#include "swad_search.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ Public types and constants *************************/
|
||||
|
@ -77,6 +78,15 @@ void Brw_DB_ChangeFilePublic (const struct FileMetadata *FileMetadata,
|
|||
bool Brw_DB_GetIfFolderHasPublicFiles (const char Path[PATH_MAX + 1]);
|
||||
unsigned Brw_DB_GetNumPublicFilesUsr (long UsrCod);
|
||||
unsigned Brw_DB_GetNumberOfPublicFiles (MYSQL_RES **mysql_res,Brw_License_t License);
|
||||
unsigned Brw_DB_SearchPublicFiles (MYSQL_RES **mysql_res,
|
||||
const char *RangeQuery,
|
||||
const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1]);
|
||||
unsigned Brw_DB_SearchFilesInMyCrss (MYSQL_RES **mysql_res,
|
||||
const char *RangeQuery,
|
||||
const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1]);
|
||||
unsigned Brw_DB_SearchMyFiles (MYSQL_RES **mysql_res,
|
||||
const char *RangeQuery,
|
||||
const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1]);
|
||||
|
||||
//------------------------------- Assignments ---------------------------------
|
||||
unsigned Brw_DB_GetFoldersAssignments (MYSQL_RES **mysql_res,long ZoneUsrCod);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "swad_error.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_hierarchy.h"
|
||||
#include "swad_search.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** External global variables from others modules ****************/
|
||||
|
@ -316,6 +317,31 @@ bool Ctr_DB_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name,
|
|||
CtrCod) != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************* Search centers in database ************************/
|
||||
/*****************************************************************************/
|
||||
// Returns number of centers found
|
||||
|
||||
unsigned Ctr_DB_SearchCtrs (MYSQL_RES **mysql_res,
|
||||
const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1],
|
||||
const char *RangeQuery)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get centers",
|
||||
"SELECT ctr_centers.CtrCod"
|
||||
" FROM ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE %s"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" ORDER BY ctr_centers.FullName,"
|
||||
"ins_instits.FullName",
|
||||
SearchQuery,
|
||||
RangeQuery);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Get number of centers in a country *********************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "swad_center.h"
|
||||
#include "swad_constant.h"
|
||||
#include "swad_media.h"
|
||||
#include "swad_search.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************** Public types and constants ***********************/
|
||||
|
@ -54,6 +55,11 @@ void Ctr_DB_GetShortNameOfCenterByCod (long CtrCod,char ShrtName[Cns_HIERARCHY_M
|
|||
unsigned Ctr_DB_GetPhotoAttribution (MYSQL_RES **mysql_res,long CtrCod);
|
||||
bool Ctr_DB_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name,
|
||||
long CtrCod,long InsCod);
|
||||
|
||||
unsigned Ctr_DB_SearchCtrs (MYSQL_RES **mysql_res,
|
||||
const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1],
|
||||
const char *RangeQuery);
|
||||
|
||||
unsigned Ctr_DB_GetNumCtrsInCty (long CtyCod);
|
||||
unsigned Ctr_DB_GetNumCtrsInIns (long InsCod);
|
||||
unsigned Ctr_DB_GetNumCtrsInPlc (long PlcCod);
|
||||
|
|
|
@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
|
|||
|
||||
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 21.32.3 (2021-10-14)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 21.33 (2021-10-15)"
|
||||
#define CSS_FILE "swad20.45.css"
|
||||
#define JS_FILE "swad20.69.1.js"
|
||||
/*
|
||||
TODO: Rename CENTRE to CENTER in help wiki.
|
||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||
|
||||
Version 21.33: Oct 15, 2021 Queries moved from search to other modules. (319942 lines)
|
||||
Version 21.32.3: Oct 14, 2021 Fixed bug in institutional links. (319792 lines)
|
||||
Version 21.32.2: Oct 13, 2021 Queries moved from RSS to other modules. (319785 lines)
|
||||
Version 21.32.1: Oct 13, 2021 Queries moved to module swad_role_database. (319787 lines)
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "swad_error.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_hierarchy.h"
|
||||
#include "swad_search.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** External global variables from others modules ****************/
|
||||
|
@ -416,6 +417,29 @@ bool Cty_DB_CheckIfCountryNameExists (Lan_Language_t Language,const char *Name,l
|
|||
CtyCod) != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ Search countries in database ***********************/
|
||||
/*****************************************************************************/
|
||||
// Returns number of countries found
|
||||
|
||||
unsigned Cty_DB_SearchCtys (MYSQL_RES **mysql_res,
|
||||
const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1],
|
||||
const char *RangeQuery)
|
||||
{
|
||||
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
||||
|
||||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get countries",
|
||||
"SELECT CtyCod"
|
||||
" FROM cty_countrs"
|
||||
" WHERE %s"
|
||||
"%s"
|
||||
" ORDER BY Name_%s",
|
||||
SearchQuery,
|
||||
RangeQuery,
|
||||
Lan_STR_LANG_ID[Gbl.Prefs.Language]);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Get average coordinates of centers in current country ***********/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "swad_country.h"
|
||||
#include "swad_map.h"
|
||||
#include "swad_media.h"
|
||||
#include "swad_search.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************** Public types and constants ***********************/
|
||||
|
@ -61,6 +62,10 @@ bool Cty_DB_CheckIfNumericCountryCodeExists (long CtyCod);
|
|||
bool Cty_DB_CheckIfAlpha2CountryCodeExists (const char Alpha2[2 + 1]);
|
||||
bool Cty_DB_CheckIfCountryNameExists (Lan_Language_t Language,const char *Name,long CtyCod);
|
||||
|
||||
unsigned Cty_DB_SearchCtys (MYSQL_RES **mysql_res,
|
||||
const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1],
|
||||
const char *RangeQuery);
|
||||
|
||||
void Cty_DB_GetCoordAndZoom (struct Map_Coordinates *Coord,unsigned *Zoom);
|
||||
unsigned Cty_DB_GetCtrsWithCoordsInCurrentCty (MYSQL_RES **mysql_res);
|
||||
unsigned Cty_DB_GetMapAttr (MYSQL_RES **mysql_res,long CtyCod);
|
||||
|
|
|
@ -284,6 +284,43 @@ unsigned Crs_DB_GetOldCrss (MYSQL_RES **mysql_res,unsigned long SecondsWithoutAc
|
|||
SecondsWithoutAccess);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************* Search courses in database ************************/
|
||||
/*****************************************************************************/
|
||||
// Returns number of courses found
|
||||
|
||||
unsigned Crs_DB_SearchCrss (MYSQL_RES **mysql_res,
|
||||
const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1],
|
||||
const char *RangeQuery)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get courses",
|
||||
"SELECT deg_degrees.DegCod," // row[0]
|
||||
"crs_courses.CrsCod," // row[1]
|
||||
"deg_degrees.ShortName," // row[2]
|
||||
"deg_degrees.FullName," // row[3]
|
||||
"crs_courses.Year," // row[4]
|
||||
"crs_courses.FullName," // row[5]
|
||||
"ctr_centers.ShortName" // row[6]
|
||||
" FROM crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE %s"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" ORDER BY crs_courses.FullName,"
|
||||
"ins_instits.FullName,"
|
||||
"deg_degrees.FullName,"
|
||||
"crs_courses.Year",
|
||||
SearchQuery,
|
||||
RangeQuery);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Get number of courses in a country *********************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -57,6 +57,10 @@ bool Crs_DB_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const char *N
|
|||
unsigned Crs_DB_GetCrssOfAUsr (MYSQL_RES **mysql_res,long UsrCod,Rol_Role_t Role);
|
||||
unsigned Crs_DB_GetOldCrss (MYSQL_RES **mysql_res,unsigned long SecondsWithoutAccess);
|
||||
|
||||
unsigned Crs_DB_SearchCrss (MYSQL_RES **mysql_res,
|
||||
const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1],
|
||||
const char *RangeQuery);
|
||||
|
||||
unsigned Crs_DB_GetNumCrssInCty (long CtyCod);
|
||||
unsigned Crs_DB_GetNumCrssInIns (long InsCod);
|
||||
unsigned Crs_DB_GetNumCrssInCtr (long CtrCod);
|
||||
|
|
|
@ -473,6 +473,33 @@ bool Deg_DB_CheckIfDegNameExistsInCtr (const char *FieldName,const char *Name,
|
|||
DegCod) != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************* Search degrees in database ************************/
|
||||
/*****************************************************************************/
|
||||
// Returns number of degrees found
|
||||
|
||||
unsigned Deg_DB_SearchDegs (MYSQL_RES **mysql_res,
|
||||
const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1],
|
||||
const char *RangeQuery)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get degrees",
|
||||
"SELECT deg_degrees.DegCod"
|
||||
" FROM deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE %s"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" ORDER BY deg_degrees.FullName,"
|
||||
"ins_instits.FullName",
|
||||
SearchQuery,
|
||||
RangeQuery);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Get current number of degrees with courses ****************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "swad_degree.h"
|
||||
#include "swad_degree_type.h"
|
||||
#include "swad_search.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Public constants ******************************/
|
||||
|
@ -64,6 +65,10 @@ unsigned Deg_DB_GetDegsWithStds (MYSQL_RES **mysql_res);
|
|||
bool Deg_DB_CheckIfDegNameExistsInCtr (const char *FieldName,const char *Name,
|
||||
long DegCod,long CtrCod);
|
||||
|
||||
unsigned Deg_DB_SearchDegs (MYSQL_RES **mysql_res,
|
||||
const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1],
|
||||
const char *RangeQuery);
|
||||
|
||||
unsigned Deg_DB_GetNumDegsWithCrss (HieLvl_Level_t Scope,long Cod);
|
||||
unsigned Deg_DB_GetNumDegsWithUsrs (Rol_Role_t Role,
|
||||
HieLvl_Level_t Scope,long Cod);
|
||||
|
|
|
@ -619,6 +619,32 @@ unsigned Ins_DB_GetInssOrderedByNumUsrsWhoClaimToBelongToThem (MYSQL_RES **mysql
|
|||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Search institutions in database **********************/
|
||||
/*****************************************************************************/
|
||||
// Returns number of institutions found
|
||||
|
||||
unsigned Ins_DB_SearchInss (MYSQL_RES **mysql_res,
|
||||
const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1],
|
||||
const char *RangeQuery)
|
||||
{
|
||||
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
||||
|
||||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get institutions",
|
||||
"SELECT ins_instits.InsCod"
|
||||
" FROM ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE %s"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" ORDER BY ins_instits.FullName,"
|
||||
"cty_countrs.Name_%s",
|
||||
SearchQuery,
|
||||
RangeQuery,
|
||||
Lan_STR_LANG_ID[Gbl.Prefs.Language]);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************** Get number of institutions in a country ********************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "swad_hierarchy_level.h"
|
||||
#include "swad_map.h"
|
||||
#include "swad_role_type.h"
|
||||
#include "swad_search.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ Public types and constants *************************/
|
||||
|
@ -67,6 +68,10 @@ unsigned Ins_DB_GetInssOrderedByNumCrss (MYSQL_RES **mysql_res);
|
|||
unsigned Ins_DB_GetInssOrderedByNumUsrsInCrss (MYSQL_RES **mysql_res);
|
||||
unsigned Ins_DB_GetInssOrderedByNumUsrsWhoClaimToBelongToThem (MYSQL_RES **mysql_res);
|
||||
|
||||
unsigned Ins_DB_SearchInss (MYSQL_RES **mysql_res,
|
||||
const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1],
|
||||
const char *RangeQuery);
|
||||
|
||||
unsigned Ins_DB_GetNumInssInCty (long CtyCod);
|
||||
|
||||
unsigned Ins_DB_GetNumInssWithCtrs (HieLvl_Level_t Scope,long Cod);
|
||||
|
|
614
swad_search.c
614
swad_search.c
|
@ -28,13 +28,20 @@
|
|||
#include <string.h> // For string functions...
|
||||
|
||||
#include "swad_box.h"
|
||||
#include "swad_browser_database.h"
|
||||
#include "swad_center_database.h"
|
||||
#include "swad_country_database.h"
|
||||
#include "swad_course_database.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_degree_database.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_hierarchy_level.h"
|
||||
#include "swad_HTML.h"
|
||||
#include "swad_institution_database.h"
|
||||
#include "swad_layout.h"
|
||||
#include "swad_parameter.h"
|
||||
#include "swad_user.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
|
@ -69,12 +76,15 @@ static void Sch_PutFormToSearchWithWhatToSearchAndScope (Act_Action_t Action,Hie
|
|||
static bool Sch_CheckIfIHavePermissionToSearch (Sch_WhatToSearch_t WhatToSearch);
|
||||
static void Sch_GetParamSearch (void);
|
||||
static void Sch_SearchInDB (void);
|
||||
static unsigned Sch_SearchCountriesInDB (const char *RangeQuery);
|
||||
static unsigned Sch_SearchInstitutionsInDB (const char *RangeQuery);
|
||||
|
||||
static unsigned Sch_SearchCountrsInDB (const char *RangeQuery);
|
||||
static unsigned Sch_SearchInstitsInDB (const char *RangeQuery);
|
||||
static unsigned Sch_SearchCentersInDB (const char *RangeQuery);
|
||||
static unsigned Sch_SearchDegreesInDB (const char *RangeQuery);
|
||||
static unsigned Sch_SearchCoursesInDB (const char *RangeQuery);
|
||||
|
||||
static unsigned Sch_SearchUsrsInDB (Rol_Role_t Role);
|
||||
|
||||
static unsigned Sch_SearchOpenDocumentsInDB (const char *RangeQuery);
|
||||
static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery);
|
||||
static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery);
|
||||
|
@ -230,12 +240,12 @@ void Sch_PutFormToSearchInPageTopHeading (void)
|
|||
{
|
||||
HTM_DIV_Begin ("id=\"head_row_1_search\"");
|
||||
|
||||
/***** Put form *****/
|
||||
Frm_BeginForm (ActSch);
|
||||
Sco_PutParamScope ("ScopeSch",HieLvl_SYS);
|
||||
Sch_PutInputStringToSearch ("head_search_text");
|
||||
Sch_PutMagnifyingGlassButton ("search-white.svg");
|
||||
Frm_EndForm ();
|
||||
/***** Put form *****/
|
||||
Frm_BeginForm (ActSch);
|
||||
Sco_PutParamScope ("ScopeSch",HieLvl_SYS);
|
||||
Sch_PutInputStringToSearch ("head_search_text");
|
||||
Sch_PutMagnifyingGlassButton ("search-white.svg");
|
||||
Frm_EndForm ();
|
||||
|
||||
HTM_DIV_End (); // head_row_1_search
|
||||
}
|
||||
|
@ -381,8 +391,8 @@ static void Sch_SearchInDB (void)
|
|||
switch (Gbl.Search.WhatToSearch)
|
||||
{
|
||||
case Sch_SEARCH_ALL:
|
||||
NumResults = Sch_SearchCountriesInDB (RangeQuery);
|
||||
NumResults += Sch_SearchInstitutionsInDB (RangeQuery);
|
||||
NumResults = Sch_SearchCountrsInDB (RangeQuery);
|
||||
NumResults += Sch_SearchInstitsInDB (RangeQuery);
|
||||
NumResults += Sch_SearchCentersInDB (RangeQuery);
|
||||
NumResults += Sch_SearchDegreesInDB (RangeQuery);
|
||||
NumResults += Sch_SearchCoursesInDB (RangeQuery);
|
||||
|
@ -394,10 +404,10 @@ static void Sch_SearchInDB (void)
|
|||
NumResults += Sch_SearchMyDocumentsInDB (RangeQuery);
|
||||
break;
|
||||
case Sch_SEARCH_COUNTRIES:
|
||||
NumResults = Sch_SearchCountriesInDB (RangeQuery);
|
||||
NumResults = Sch_SearchCountrsInDB (RangeQuery);
|
||||
break;
|
||||
case Sch_SEARCH_INSTITS:
|
||||
NumResults = Sch_SearchInstitutionsInDB (RangeQuery);
|
||||
NumResults = Sch_SearchInstitsInDB (RangeQuery);
|
||||
break;
|
||||
case Sch_SEARCH_CENTERS:
|
||||
NumResults = Sch_SearchCentersInDB (RangeQuery);
|
||||
|
@ -443,7 +453,7 @@ static void Sch_SearchInDB (void)
|
|||
/*****************************************************************************/
|
||||
// Returns number of countries found
|
||||
|
||||
static unsigned Sch_SearchCountriesInDB (const char *RangeQuery)
|
||||
static unsigned Sch_SearchCountrsInDB (const char *RangeQuery)
|
||||
{
|
||||
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
||||
char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1];
|
||||
|
@ -464,17 +474,8 @@ static unsigned Sch_SearchCountriesInDB (const char *RangeQuery)
|
|||
Lan_STR_LANG_ID[Gbl.Prefs.Language]);
|
||||
if (Sch_BuildSearchQuery (SearchQuery,FieldName,NULL,NULL))
|
||||
{
|
||||
/***** Query database and list institutions found *****/
|
||||
NumCtys = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get countries",
|
||||
"SELECT CtyCod"
|
||||
" FROM cty_countrs"
|
||||
" WHERE %s"
|
||||
"%s"
|
||||
" ORDER BY Name_%s",
|
||||
SearchQuery,
|
||||
RangeQuery,
|
||||
Lan_STR_LANG_ID[Gbl.Prefs.Language]);
|
||||
/***** Query database and list countries found *****/
|
||||
NumCtys = Cty_DB_SearchCtys (&mysql_res,SearchQuery,RangeQuery);
|
||||
Cty_ListCtysFound (&mysql_res,NumCtys);
|
||||
return NumCtys;
|
||||
}
|
||||
|
@ -488,7 +489,7 @@ static unsigned Sch_SearchCountriesInDB (const char *RangeQuery)
|
|||
/*****************************************************************************/
|
||||
// Returns number of institutions found
|
||||
|
||||
static unsigned Sch_SearchInstitutionsInDB (const char *RangeQuery)
|
||||
static unsigned Sch_SearchInstitsInDB (const char *RangeQuery)
|
||||
{
|
||||
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
||||
char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1];
|
||||
|
@ -505,19 +506,7 @@ static unsigned Sch_SearchInstitutionsInDB (const char *RangeQuery)
|
|||
if (Sch_BuildSearchQuery (SearchQuery,"ins_instits.FullName",NULL,NULL))
|
||||
{
|
||||
/***** Query database and list institutions found *****/
|
||||
NumInss = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||
"SELECT ins_instits.InsCod"
|
||||
" FROM ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE %s"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" ORDER BY ins_instits.FullName,"
|
||||
"cty_countrs.Name_%s",
|
||||
SearchQuery,
|
||||
RangeQuery,
|
||||
Lan_STR_LANG_ID[Gbl.Prefs.Language]);
|
||||
NumInss = Ins_DB_SearchInss (&mysql_res,SearchQuery,RangeQuery);
|
||||
Ins_ListInssFound (&mysql_res,NumInss);
|
||||
return NumInss;
|
||||
}
|
||||
|
@ -545,19 +534,7 @@ static unsigned Sch_SearchCentersInDB (const char *RangeQuery)
|
|||
if (Sch_BuildSearchQuery (SearchQuery,"ctr_centers.FullName",NULL,NULL))
|
||||
{
|
||||
/***** Query database and list centers found *****/
|
||||
NumCtrs = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get centers",
|
||||
"SELECT ctr_centers.CtrCod"
|
||||
" FROM ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE %s"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" ORDER BY ctr_centers.FullName,"
|
||||
"ins_instits.FullName",
|
||||
SearchQuery,RangeQuery);
|
||||
NumCtrs = Ctr_DB_SearchCtrs (&mysql_res,SearchQuery,RangeQuery);
|
||||
Ctr_ListCtrsFound (&mysql_res,NumCtrs);
|
||||
return NumCtrs;
|
||||
}
|
||||
|
@ -584,21 +561,7 @@ static unsigned Sch_SearchDegreesInDB (const char *RangeQuery)
|
|||
if (Sch_BuildSearchQuery (SearchQuery,"deg_degrees.FullName",NULL,NULL))
|
||||
{
|
||||
/***** Query database and list degrees found *****/
|
||||
NumDegs = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get degrees",
|
||||
"SELECT deg_degrees.DegCod"
|
||||
" FROM deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE %s"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" ORDER BY deg_degrees.FullName,"
|
||||
"ins_instits.FullName",
|
||||
SearchQuery,RangeQuery);
|
||||
NumDegs = Deg_DB_SearchDegs (&mysql_res,SearchQuery,RangeQuery);
|
||||
Deg_ListDegsFound (&mysql_res,NumDegs);
|
||||
return NumDegs;
|
||||
}
|
||||
|
@ -623,31 +586,7 @@ static unsigned Sch_SearchCoursesInDB (const char *RangeQuery)
|
|||
if (Sch_BuildSearchQuery (SearchQuery,"crs_courses.FullName",NULL,NULL))
|
||||
{
|
||||
/***** Query database and list courses found *****/
|
||||
NumCrss = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get courses",
|
||||
"SELECT deg_degrees.DegCod," // row[0]
|
||||
"crs_courses.CrsCod," // row[1]
|
||||
"deg_degrees.ShortName," // row[2]
|
||||
"deg_degrees.FullName," // row[3]
|
||||
"crs_courses.Year," // row[4]
|
||||
"crs_courses.FullName," // row[5]
|
||||
"ctr_centers.ShortName" // row[6]
|
||||
" FROM crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE %s"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" ORDER BY crs_courses.FullName,"
|
||||
"ins_instits.FullName,"
|
||||
"deg_degrees.FullName,"
|
||||
"crs_courses.Year",
|
||||
SearchQuery,RangeQuery);
|
||||
NumCrss = Crs_DB_SearchCrss (&mysql_res,SearchQuery,RangeQuery);
|
||||
Crs_ListCrssFound (&mysql_res,NumCrss);
|
||||
return NumCrss;
|
||||
}
|
||||
|
@ -703,139 +642,7 @@ static unsigned Sch_SearchOpenDocumentsInDB (const char *RangeQuery)
|
|||
"_latin1 "," COLLATE latin1_general_ci"))
|
||||
{
|
||||
/***** Query database *****/
|
||||
NumDocs = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get files",
|
||||
"SELECT *"
|
||||
" FROM "
|
||||
// Institution
|
||||
"(SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"-1 AS CtrCod," // row[ 4]
|
||||
"'' AS CtrShortName," // row[ 5]
|
||||
"-1 AS DegCod," // row[ 6]
|
||||
"'' AS DegShortName," // row[ 7]
|
||||
"-1 AS CrsCod," // row[ 8]
|
||||
"'' AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.Public='Y'"
|
||||
" AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||
" AND brw_files.Cod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
// Center -------------------------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"ctr_centers.CtrCod," // row[ 4]
|
||||
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||
"-1 AS DegCod," // row[ 6]
|
||||
"'' AS DegShortName," // row[ 7]
|
||||
"-1 AS CrsCod," // row[ 8]
|
||||
"'' AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.Public='Y' AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||
" AND brw_files.Cod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
// Degree -------------------------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"ctr_centers.CtrCod," // row[ 4]
|
||||
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||
"deg_degrees.DegCod," // row[ 6]
|
||||
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||
"-1 AS CrsCod," // row[ 8]
|
||||
"'' AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.Public='Y' AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||
" AND brw_files.Cod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
// Course -------------------------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"ctr_centers.CtrCod," // row[ 4]
|
||||
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||
"deg_degrees.DegCod," // row[ 6]
|
||||
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||
"crs_courses.CrsCod," // row[ 8]
|
||||
"crs_courses.ShortName AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.Public='Y' AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||
" AND brw_files.Cod=crs_courses.CrsCod"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
") AS selected_files"
|
||||
" WHERE PathFromRoot<>''"
|
||||
" ORDER BY InsShortName,"
|
||||
"CtrShortName,"
|
||||
"DegShortName,"
|
||||
"CrsShortName,"
|
||||
"PathFromRoot",
|
||||
SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_INS,
|
||||
(unsigned) Brw_ADMI_SHR_INS,
|
||||
RangeQuery,
|
||||
SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_CTR,
|
||||
(unsigned) Brw_ADMI_SHR_CTR,
|
||||
RangeQuery,
|
||||
SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_DEG,
|
||||
(unsigned) Brw_ADMI_SHR_DEG,
|
||||
RangeQuery,
|
||||
SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_CRS,
|
||||
(unsigned) Brw_ADMI_SHR_CRS,
|
||||
RangeQuery);
|
||||
NumDocs = Brw_DB_SearchPublicFiles (&mysql_res,RangeQuery,SearchQuery);
|
||||
|
||||
/***** List documents found *****/
|
||||
Brw_ListDocsFound (&mysql_res,NumDocs,
|
||||
|
@ -866,148 +673,14 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
|
|||
if (Sch_BuildSearchQuery (SearchQuery,"SUBSTRING_INDEX(brw_files.Path,'/',-1)",
|
||||
"_latin1 "," COLLATE latin1_general_ci"))
|
||||
{
|
||||
/***** Create temporary table with codes of files in documents and shared areas accessible by me.
|
||||
It is necessary to speed up the second query *****/
|
||||
DB_Query ("can not remove temporary table",
|
||||
"DROP TEMPORARY TABLE IF EXISTS my_files_crs,"
|
||||
"my_files_grp");
|
||||
|
||||
DB_Query ("can not create temporary table",
|
||||
"CREATE TEMPORARY TABLE my_files_crs"
|
||||
" (FilCod INT NOT NULL,"
|
||||
"UNIQUE INDEX(FilCod))"
|
||||
" ENGINE=MEMORY"
|
||||
" SELECT brw_files.FilCod"
|
||||
" FROM crs_users,"
|
||||
"brw_files"
|
||||
" WHERE crs_users.UsrCod=%ld"
|
||||
" AND crs_users.CrsCod=brw_files.Cod"
|
||||
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
(unsigned) Brw_ADMI_DOC_CRS,
|
||||
(unsigned) Brw_ADMI_TCH_CRS,
|
||||
(unsigned) Brw_ADMI_SHR_CRS,
|
||||
(unsigned) Brw_ADMI_MRK_CRS);
|
||||
|
||||
DB_Query ("can not create temporary table",
|
||||
"CREATE TEMPORARY TABLE my_files_grp"
|
||||
" (FilCod INT NOT NULL,"
|
||||
"UNIQUE INDEX(FilCod))"
|
||||
" ENGINE=MEMORY"
|
||||
" SELECT brw_files.FilCod"
|
||||
" FROM grp_users,"
|
||||
"brw_files"
|
||||
" WHERE grp_users.UsrCod=%ld"
|
||||
" AND grp_users.GrpCod=brw_files.Cod"
|
||||
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
(unsigned) Brw_ADMI_DOC_GRP,
|
||||
(unsigned) Brw_ADMI_TCH_GRP,
|
||||
(unsigned) Brw_ADMI_SHR_GRP,
|
||||
(unsigned) Brw_ADMI_MRK_GRP);
|
||||
|
||||
/***** Build the query *****/
|
||||
NumDocs = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get files",
|
||||
"SELECT *"
|
||||
" FROM ("
|
||||
// Files in course zones ----------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',"
|
||||
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"ctr_centers.CtrCod," // row[ 4]
|
||||
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||
"deg_degrees.DegCod," // row[ 6]
|
||||
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||
"crs_courses.CrsCod," // row[ 8]
|
||||
"crs_courses.ShortName AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.FilCod IN"
|
||||
" (SELECT FilCod"
|
||||
" FROM my_files_crs)"
|
||||
" AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)"
|
||||
" AND brw_files.Cod=crs_courses.CrsCod"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
// Files in group zones -----------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',"
|
||||
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"ctr_centers.CtrCod," // row[ 4]
|
||||
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||
"deg_degrees.DegCod," // row[ 6]
|
||||
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||
"crs_courses.CrsCod," // row[ 8]
|
||||
"crs_courses.ShortName AS CrsShortName," // row[ 9]
|
||||
"grp_groups.GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"grp_groups,"
|
||||
"grp_types,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.FilCod IN"
|
||||
" (SELECT FilCod"
|
||||
" FROM my_files_grp)"
|
||||
" AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)"
|
||||
" AND brw_files.Cod=grp_groups.GrpCod"
|
||||
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod"
|
||||
" AND grp_types.CrsCod=crs_courses.CrsCod"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
") AS selected_files"
|
||||
" WHERE PathFromRoot<>''"
|
||||
" ORDER BY InsShortName,"
|
||||
"CtrShortName,"
|
||||
"DegShortName,"
|
||||
"CrsShortName,"
|
||||
"PathFromRoot",
|
||||
SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_CRS,
|
||||
(unsigned) Brw_ADMI_TCH_CRS,
|
||||
(unsigned) Brw_ADMI_SHR_CRS,
|
||||
(unsigned) Brw_ADMI_MRK_CRS,
|
||||
RangeQuery,
|
||||
SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_GRP,
|
||||
(unsigned) Brw_ADMI_TCH_GRP,
|
||||
(unsigned) Brw_ADMI_SHR_GRP,
|
||||
(unsigned) Brw_ADMI_MRK_GRP,
|
||||
RangeQuery);
|
||||
/***** Query database *****/
|
||||
NumDocs = Brw_DB_SearchFilesInMyCrss (&mysql_res,RangeQuery,SearchQuery);
|
||||
|
||||
/***** List documents found *****/
|
||||
Brw_ListDocsFound (&mysql_res,NumDocs,
|
||||
Txt_document_in_my_courses,
|
||||
Txt_documents_in_my_courses);
|
||||
|
||||
/***** Drop temporary table *****/
|
||||
DB_Query ("can not remove temporary table",
|
||||
"DROP TEMPORARY TABLE IF EXISTS my_files_crs,"
|
||||
"my_files_grp");
|
||||
|
||||
return NumDocs;
|
||||
}
|
||||
|
||||
|
@ -1032,209 +705,8 @@ static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery)
|
|||
if (Sch_BuildSearchQuery (SearchQuery,"SUBSTRING_INDEX(brw_files.Path,'/',-1)",
|
||||
"_latin1 "," COLLATE latin1_general_ci"))
|
||||
{
|
||||
/***** Build the query *****/
|
||||
NumDocs = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get files",
|
||||
"SELECT *"
|
||||
" FROM ("
|
||||
// Institution --------------------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',"
|
||||
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"-1 AS CtrCod," // row[ 4]
|
||||
"'' AS CtrShortName," // row[ 5]
|
||||
"-1 AS DegCod," // row[ 6]
|
||||
"'' AS DegShortName," // row[ 7]
|
||||
"-1 AS CrsCod," // row[ 8]
|
||||
"'' AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.PublisherUsrCod=%ld"
|
||||
" AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||
" AND brw_files.Cod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
// Center -------------------------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',"
|
||||
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"ctr_centers.CtrCod," // row[ 4]
|
||||
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||
"-1 AS DegCod," // row[ 6]
|
||||
"'' AS DegShortName," // row[ 7]
|
||||
"-1 AS CrsCod," // row[ 8]
|
||||
"'' AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.PublisherUsrCod=%ld AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||
" AND brw_files.Cod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
// Degree -------------------------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',"
|
||||
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"ctr_centers.CtrCod," // row[ 4]
|
||||
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||
"deg_degrees.DegCod," // row[ 6]
|
||||
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||
"-1 AS CrsCod," // row[ 8]
|
||||
"'' AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.PublisherUsrCod=%ld"
|
||||
" AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||
" AND brw_files.Cod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
// Course -------------------------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',"
|
||||
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"ctr_centers.CtrCod," // row[ 4]
|
||||
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||
"deg_degrees.DegCod," // row[ 6]
|
||||
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||
"crs_courses.CrsCod," // row[ 8]
|
||||
"crs_courses.ShortName AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.PublisherUsrCod=%ld"
|
||||
" AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)"
|
||||
" AND brw_files.Cod=crs_courses.CrsCod"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
// Group --------------------------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',"
|
||||
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"ins_instits.InsCod," // row[ 2]
|
||||
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||
"ctr_centers.CtrCod," // row[ 4]
|
||||
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||
"deg_degrees.DegCod," // row[ 6]
|
||||
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||
"crs_courses.CrsCod," // row[ 8]
|
||||
"crs_courses.ShortName AS CrsShortName," // row[ 9]
|
||||
"grp_groups.GrpCod" // row[10]
|
||||
" FROM brw_files,"
|
||||
"grp_groups,"
|
||||
"grp_types,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.PublisherUsrCod=%ld"
|
||||
" AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)"
|
||||
" AND brw_files.Cod=grp_groups.GrpCod"
|
||||
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod"
|
||||
" AND grp_types.CrsCod=crs_courses.CrsCod"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
// Briefcase ----------------------------------
|
||||
"SELECT brw_files.FilCod," // row[ 0]
|
||||
"SUBSTRING(brw_files.Path,"
|
||||
"LOCATE('/',"
|
||||
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||
"-1 AS InsCod," // row[ 2]
|
||||
"'' AS InsShortName," // row[ 3]
|
||||
"-1 AS CtrCod," // row[ 4]
|
||||
"'' AS CtrShortName," // row[ 5]
|
||||
"-1 AS DegCod," // row[ 6]
|
||||
"'' AS DegShortName," // row[ 7]
|
||||
"-1 AS CrsCod," // row[ 8]
|
||||
"'' AS CrsShortName," // row[ 9]
|
||||
"-1 AS GrpCod" // row[10]
|
||||
" FROM brw_files"
|
||||
" WHERE brw_files.PublisherUsrCod=%ld"
|
||||
" AND %s"
|
||||
" AND brw_files.FileBrowser=%u"
|
||||
") AS selected_files"
|
||||
" WHERE PathFromRoot<>''"
|
||||
" ORDER BY InsShortName,"
|
||||
"CtrShortName,"
|
||||
"DegShortName,"
|
||||
"CrsShortName,"
|
||||
"PathFromRoot",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_INS,
|
||||
(unsigned) Brw_ADMI_SHR_INS,
|
||||
RangeQuery,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_CTR,
|
||||
(unsigned) Brw_ADMI_SHR_CTR,
|
||||
RangeQuery,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_DEG,
|
||||
(unsigned) Brw_ADMI_SHR_DEG,
|
||||
RangeQuery,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_CRS,
|
||||
(unsigned) Brw_ADMI_TCH_CRS,
|
||||
(unsigned) Brw_ADMI_SHR_CRS,
|
||||
(unsigned) Brw_ADMI_MRK_CRS,
|
||||
RangeQuery,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,SearchQuery,
|
||||
(unsigned) Brw_ADMI_DOC_GRP,
|
||||
(unsigned) Brw_ADMI_TCH_GRP,
|
||||
(unsigned) Brw_ADMI_SHR_GRP,
|
||||
(unsigned) Brw_ADMI_MRK_GRP,
|
||||
RangeQuery,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,SearchQuery,
|
||||
(unsigned) Brw_ADMI_BRF_USR);
|
||||
/***** Query database *****/
|
||||
NumDocs = Brw_DB_SearchMyFiles (&mysql_res,RangeQuery,SearchQuery);
|
||||
|
||||
/***** List documents found *****/
|
||||
Brw_ListDocsFound (&mysql_res,NumDocs,
|
||||
|
@ -1346,24 +818,12 @@ static void Sch_SaveLastSearchIntoSession (void)
|
|||
Gbl.Search.WhatToSearch = Sch_WHAT_TO_SEARCH_DEFAULT;
|
||||
|
||||
/***** Save last search in session *****/
|
||||
DB_QueryUPDATE ("can not update last search in session",
|
||||
"UPDATE ses_sessions"
|
||||
" SET WhatToSearch=%u,"
|
||||
"SearchStr='%s'"
|
||||
" WHERE SessionId='%s'",
|
||||
(unsigned) Gbl.Search.WhatToSearch,
|
||||
Gbl.Search.Str,
|
||||
Gbl.Session.Id);
|
||||
Ses_DB_SaveLastSearchIntoSession ();
|
||||
|
||||
/***** Update my last type of search *****/
|
||||
// WhatToSearch is stored in usr_last for next time I log in
|
||||
// In other existing sessions distinct to this, WhatToSearch will remain unchanged
|
||||
DB_QueryUPDATE ("can not update type of search in user's last data",
|
||||
"UPDATE usr_last"
|
||||
" SET WhatToSearch=%u"
|
||||
" WHERE UsrCod=%ld",
|
||||
(unsigned) Gbl.Search.WhatToSearch,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
Usr_DB_UpdateMyLastWhatToSearch ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// swad_search.c: edition of courses
|
||||
// swad_search.c: search for courses and teachers
|
||||
|
||||
#ifndef _SWAD_SCH
|
||||
#define _SWAD_SCH
|
||||
|
|
|
@ -596,3 +596,19 @@ unsigned Ses_DB_GetLastPageMsgFromSession (Pag_WhatPaginate_t WhatPaginate)
|
|||
Field[WhatPaginate],
|
||||
Gbl.Session.Id);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Save last search into session ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Ses_DB_SaveLastSearchIntoSession (void)
|
||||
{
|
||||
DB_QueryUPDATE ("can not update last search in session",
|
||||
"UPDATE ses_sessions"
|
||||
" SET WhatToSearch=%u,"
|
||||
"SearchStr='%s'"
|
||||
" WHERE SessionId='%s'",
|
||||
(unsigned) Gbl.Search.WhatToSearch,
|
||||
Gbl.Search.Str,
|
||||
Gbl.Session.Id);
|
||||
}
|
||||
|
|
|
@ -64,4 +64,6 @@ void Ses_RemovePublicDirsFromExpiredSessions (void);
|
|||
void Ses_DB_SaveLastPageMsgIntoSession (Pag_WhatPaginate_t WhatPaginate,unsigned NumPage);
|
||||
unsigned Ses_DB_GetLastPageMsgFromSession (Pag_WhatPaginate_t WhatPaginate);
|
||||
|
||||
void Ses_DB_SaveLastSearchIntoSession (void);
|
||||
|
||||
#endif
|
||||
|
|
16
swad_user.c
16
swad_user.c
|
@ -3617,6 +3617,22 @@ void Usr_UpdateMyLastData (void)
|
|||
Usr_InsertMyLastData ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Update my last type of search ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Usr_DB_UpdateMyLastWhatToSearch (void)
|
||||
{
|
||||
// WhatToSearch is stored in usr_last for next time I log in
|
||||
// In other existing sessions distinct to this, WhatToSearch will remain unchanged
|
||||
DB_QueryUPDATE ("can not update type of search in user's last data",
|
||||
"UPDATE usr_last"
|
||||
" SET WhatToSearch=%u"
|
||||
" WHERE UsrCod=%ld",
|
||||
(unsigned) Gbl.Search.WhatToSearch,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Create new entry for my last data in database ***************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -407,6 +407,7 @@ bool Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (struct UsrData *UsrDat,
|
|||
Usr_GetPrefs_t GetPrefs,
|
||||
Usr_GetRoleInCurrentCrs_t GetRoleInCurrentCrs);
|
||||
void Usr_UpdateMyLastData (void);
|
||||
void Usr_DB_UpdateMyLastWhatToSearch (void);
|
||||
void Usr_InsertMyLastCrsTabAndTime (void);
|
||||
|
||||
void Usr_DB_RemoveUsrLastData (long UsrCod);
|
||||
|
|
Loading…
Reference in New Issue