mirror of https://github.com/acanas/swad-core.git
Version 18.8.4
This commit is contained in:
parent
234cdf47be
commit
bbb97b7ccb
|
@ -355,10 +355,11 @@ En OpenSWAD:
|
|||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.8.3 (2018-10-25)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.8.4 (2018-10-25)"
|
||||
#define CSS_FILE "swad18.4.css"
|
||||
#define JS_FILE "swad17.17.1.js"
|
||||
/*
|
||||
Version 18.8.4: Oct 25, 2018 Some asprintf for database queries changed by internal function. (237916 lines)
|
||||
Version 18.8.3: Oct 25, 2018 Some asprintf for database queries changed by internal function. (237968 lines)
|
||||
Version 18.8.2: Oct 25, 2018 Changes in alerts.
|
||||
Fixed bug in account creation. (238051 lines)
|
||||
|
|
|
@ -2454,7 +2454,6 @@ void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan)
|
|||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
extern const char *Txt_all_degrees;
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumRow;
|
||||
|
@ -2464,36 +2463,35 @@ void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan)
|
|||
struct Degree Deg;
|
||||
|
||||
/***** Get institutions, centres, degrees admin by user from database *****/
|
||||
if (asprintf (&Query,"(SELECT %u AS S,-1 AS Cod,'' AS FullName"
|
||||
" FROM admin"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND Scope='%s')"
|
||||
" UNION "
|
||||
"(SELECT %u AS S,admin.Cod,institutions.FullName"
|
||||
" FROM admin,institutions"
|
||||
" WHERE admin.UsrCod=%ld"
|
||||
" AND admin.Scope='%s'"
|
||||
" AND admin.Cod=institutions.InsCod)"
|
||||
" UNION "
|
||||
"(SELECT %u AS S,admin.Cod,centres.FullName"
|
||||
" FROM admin,centres"
|
||||
" WHERE admin.UsrCod=%ld"
|
||||
" AND admin.Scope='%s'"
|
||||
" AND admin.Cod=centres.CtrCod)"
|
||||
" UNION "
|
||||
"(SELECT %u AS S,admin.Cod,degrees.FullName"
|
||||
" FROM admin,degrees"
|
||||
" WHERE admin.UsrCod=%ld"
|
||||
" AND admin.Scope='%s'"
|
||||
" AND admin.Cod=degrees.DegCod)"
|
||||
" ORDER BY S,FullName",
|
||||
(unsigned) Sco_SCOPE_SYS,UsrCod,Sco_ScopeDB[Sco_SCOPE_SYS],
|
||||
(unsigned) Sco_SCOPE_INS,UsrCod,Sco_ScopeDB[Sco_SCOPE_INS],
|
||||
(unsigned) Sco_SCOPE_CTR,UsrCod,Sco_ScopeDB[Sco_SCOPE_CTR],
|
||||
(unsigned) Sco_SCOPE_DEG,UsrCod,Sco_ScopeDB[Sco_SCOPE_DEG]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
DB_BuildQuery ("(SELECT %u AS S,-1 AS Cod,'' AS FullName"
|
||||
" FROM admin"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND Scope='%s')"
|
||||
" UNION "
|
||||
"(SELECT %u AS S,admin.Cod,institutions.FullName"
|
||||
" FROM admin,institutions"
|
||||
" WHERE admin.UsrCod=%ld"
|
||||
" AND admin.Scope='%s'"
|
||||
" AND admin.Cod=institutions.InsCod)"
|
||||
" UNION "
|
||||
"(SELECT %u AS S,admin.Cod,centres.FullName"
|
||||
" FROM admin,centres"
|
||||
" WHERE admin.UsrCod=%ld"
|
||||
" AND admin.Scope='%s'"
|
||||
" AND admin.Cod=centres.CtrCod)"
|
||||
" UNION "
|
||||
"(SELECT %u AS S,admin.Cod,degrees.FullName"
|
||||
" FROM admin,degrees"
|
||||
" WHERE admin.UsrCod=%ld"
|
||||
" AND admin.Scope='%s'"
|
||||
" AND admin.Cod=degrees.DegCod)"
|
||||
" ORDER BY S,FullName",
|
||||
(unsigned) Sco_SCOPE_SYS,UsrCod,Sco_ScopeDB[Sco_SCOPE_SYS],
|
||||
(unsigned) Sco_SCOPE_INS,UsrCod,Sco_ScopeDB[Sco_SCOPE_INS],
|
||||
(unsigned) Sco_SCOPE_CTR,UsrCod,Sco_ScopeDB[Sco_SCOPE_CTR],
|
||||
(unsigned) Sco_SCOPE_DEG,UsrCod,Sco_ScopeDB[Sco_SCOPE_DEG]);
|
||||
|
||||
if ((NumRows = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get institutions, centres, degrees admin by a user")))
|
||||
if ((NumRows = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get institutions, centres, degrees admin by a user")))
|
||||
/***** Get the list of degrees *****/
|
||||
for (NumRow = 1;
|
||||
NumRow <= NumRows;
|
||||
|
@ -2584,7 +2582,7 @@ void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan)
|
|||
/*****************************************************************************/
|
||||
// Returns number of degrees found
|
||||
|
||||
unsigned Deg_ListDegsFound (const char *Query)
|
||||
unsigned Deg_ListDegsFound (void)
|
||||
{
|
||||
extern const char *Txt_degree;
|
||||
extern const char *Txt_degrees;
|
||||
|
@ -2595,7 +2593,7 @@ unsigned Deg_ListDegsFound (const char *Query)
|
|||
struct Degree Deg;
|
||||
|
||||
/***** Query database *****/
|
||||
if ((NumDegs = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get degrees")))
|
||||
if ((NumDegs = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get degrees")))
|
||||
{
|
||||
/***** Start box and table *****/
|
||||
/* Number of degrees found */
|
||||
|
|
|
@ -143,6 +143,6 @@ unsigned Deg_GetNumDegsInCtr (long CtrCod);
|
|||
unsigned Deg_GetNumDegsWithCrss (const char *SubQuery);
|
||||
unsigned Deg_GetNumDegsWithUsrs (Rol_Role_t Role,const char *SubQuery);
|
||||
|
||||
unsigned Deg_ListDegsFound (const char *Query);
|
||||
unsigned Deg_ListDegsFound (void);
|
||||
|
||||
#endif
|
||||
|
|
80
swad_exam.c
80
swad_exam.c
|
@ -549,7 +549,6 @@ static void Exa_ListExamAnnouncements (Exa_TypeViewExamAnnouncement_t TypeViewEx
|
|||
extern const char *Txt_All_announcements_of_exams;
|
||||
extern const char *Txt_Announcements_of_exams;
|
||||
extern const char *Txt_No_announcements_of_exams_of_X;
|
||||
char *Query;
|
||||
char SubQueryStatus[64];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
|
@ -570,14 +569,13 @@ static void Exa_ListExamAnnouncements (Exa_TypeViewExamAnnouncement_t TypeViewEx
|
|||
if (Gbl.ExamAnns.HighlightExaCod > 0)
|
||||
{
|
||||
/***** Get one exam announcement from database *****/
|
||||
if (asprintf (&Query,"SELECT ExaCod"
|
||||
" FROM exam_announcements"
|
||||
" WHERE ExaCod=%ld"
|
||||
" AND CrsCod=%ld AND %s",
|
||||
Gbl.ExamAnns.HighlightExaCod,
|
||||
Gbl.CurrentCrs.Crs.CrsCod,SubQueryStatus) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
NumExaAnns = DB_QuerySELECT_free (Query,&mysql_res,"can not get exam announcements in this course for listing");
|
||||
DB_BuildQuery ("SELECT ExaCod"
|
||||
" FROM exam_announcements"
|
||||
" WHERE ExaCod=%ld"
|
||||
" AND CrsCod=%ld AND %s",
|
||||
Gbl.ExamAnns.HighlightExaCod,
|
||||
Gbl.CurrentCrs.Crs.CrsCod,SubQueryStatus);
|
||||
NumExaAnns = DB_QuerySELECT_new (&mysql_res,"can not get exam announcements in this course for listing");
|
||||
|
||||
/***** List the existing exam announcements *****/
|
||||
for (NumExaAnn = 0;
|
||||
|
@ -609,16 +607,15 @@ static void Exa_ListExamAnnouncements (Exa_TypeViewExamAnnouncement_t TypeViewEx
|
|||
{
|
||||
/***** Get exam announcements (the most recent first)
|
||||
in current course for a date from database *****/
|
||||
if (asprintf (&Query,"SELECT ExaCod"
|
||||
" FROM exam_announcements"
|
||||
" WHERE CrsCod=%ld AND %s"
|
||||
" AND DATE(ExamDate)='%s'"
|
||||
" ORDER BY ExamDate DESC",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,SubQueryStatus,
|
||||
Gbl.ExamAnns.HighlightDate) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
NumExaAnns = DB_QuerySELECT_free (Query,&mysql_res,"can not get exam announcements"
|
||||
" in this course for listing");
|
||||
DB_BuildQuery ("SELECT ExaCod"
|
||||
" FROM exam_announcements"
|
||||
" WHERE CrsCod=%ld AND %s"
|
||||
" AND DATE(ExamDate)='%s'"
|
||||
" ORDER BY ExamDate DESC",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,SubQueryStatus,
|
||||
Gbl.ExamAnns.HighlightDate);
|
||||
NumExaAnns = DB_QuerySELECT_new (&mysql_res,"can not get exam announcements"
|
||||
" in this course for listing");
|
||||
|
||||
/***** List the existing exam announcements *****/
|
||||
for (NumExaAnn = 0;
|
||||
|
@ -647,14 +644,13 @@ static void Exa_ListExamAnnouncements (Exa_TypeViewExamAnnouncement_t TypeViewEx
|
|||
|
||||
/***** Get exam announcements (the most recent first)
|
||||
in current course from database *****/
|
||||
if (asprintf (&Query,"SELECT ExaCod"
|
||||
" FROM exam_announcements"
|
||||
" WHERE CrsCod=%ld AND %s"
|
||||
" ORDER BY ExamDate DESC",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,SubQueryStatus) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
NumExaAnns = DB_QuerySELECT_free (Query,&mysql_res,"can not get exam announcements"
|
||||
" in this course for listing");
|
||||
DB_BuildQuery ("SELECT ExaCod"
|
||||
" FROM exam_announcements"
|
||||
" WHERE CrsCod=%ld AND %s"
|
||||
" ORDER BY ExamDate DESC",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,SubQueryStatus);
|
||||
NumExaAnns = DB_QuerySELECT_new (&mysql_res,"can not get exam announcements"
|
||||
" in this course for listing");
|
||||
|
||||
/***** Start box *****/
|
||||
Box_StartBox (NULL,
|
||||
|
@ -824,7 +820,6 @@ static void Exa_ModifyExamAnnouncementInDB (void)
|
|||
|
||||
void Exa_CreateListDatesOfExamAnnouncements (void)
|
||||
{
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumExaAnn;
|
||||
|
@ -835,14 +830,13 @@ void Exa_CreateListDatesOfExamAnnouncements (void)
|
|||
/***** Get exam dates (no matter in what order)
|
||||
of visible exam announcements
|
||||
in current course from database *****/
|
||||
if (asprintf (&Query,"SELECT DISTINCT(DATE(ExamDate))"
|
||||
" FROM exam_announcements"
|
||||
" WHERE CrsCod=%ld AND Status=%u",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,
|
||||
(unsigned) Exa_VISIBLE_EXAM_ANNOUNCEMENT) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
NumExaAnns = DB_QuerySELECT_free (Query,&mysql_res,"can not get exam announcements"
|
||||
" in this course");
|
||||
DB_BuildQuery ("SELECT DISTINCT(DATE(ExamDate))"
|
||||
" FROM exam_announcements"
|
||||
" WHERE CrsCod=%ld AND Status=%u",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,
|
||||
(unsigned) Exa_VISIBLE_EXAM_ANNOUNCEMENT);
|
||||
NumExaAnns = DB_QuerySELECT_new (&mysql_res,"can not get exam announcements"
|
||||
" in this course");
|
||||
|
||||
/***** The result of the query may be empty *****/
|
||||
Gbl.ExamAnns.Lst = NULL;
|
||||
|
@ -898,7 +892,6 @@ void Exa_FreeListExamAnnouncements (void)
|
|||
|
||||
static void Exa_GetDataExamAnnouncementFromDB (void)
|
||||
{
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumExaAnns;
|
||||
|
@ -908,13 +901,12 @@ static void Exa_GetDataExamAnnouncementFromDB (void)
|
|||
unsigned Second;
|
||||
|
||||
/***** Get data of an exam announcement from database *****/
|
||||
if (asprintf (&Query,"SELECT CrsCod,Status,CrsFullName,Year,ExamSession,"
|
||||
"CallDate,ExamDate,Duration,Place,ExamMode,"
|
||||
"Structure,DocRequired,MatRequired,MatAllowed,OtherInfo"
|
||||
" FROM exam_announcements WHERE ExaCod=%ld",
|
||||
Gbl.ExamAnns.ExaDat.ExaCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
NumExaAnns = DB_QuerySELECT_free (Query,&mysql_res,"can not get data of an exam announcement");
|
||||
DB_BuildQuery ("SELECT CrsCod,Status,CrsFullName,Year,ExamSession,"
|
||||
"CallDate,ExamDate,Duration,Place,ExamMode,"
|
||||
"Structure,DocRequired,MatRequired,MatAllowed,OtherInfo"
|
||||
" FROM exam_announcements WHERE ExaCod=%ld",
|
||||
Gbl.ExamAnns.ExaDat.ExaCod);
|
||||
NumExaAnns = DB_QuerySELECT_new (&mysql_res,"can not get data of an exam announcement");
|
||||
|
||||
/***** The result of the query must have one row *****/
|
||||
if (NumExaAnns != 1)
|
||||
|
|
|
@ -2955,7 +2955,6 @@ static void Brw_SetPathFileBrowser (void)
|
|||
|
||||
bool Brw_CheckIfExistsFolderAssigmentForAnyUsr (const char *FolderName)
|
||||
{
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumUsrs;
|
||||
|
@ -2965,10 +2964,9 @@ bool Brw_CheckIfExistsFolderAssigmentForAnyUsr (const char *FolderName)
|
|||
bool FolderExists = false;
|
||||
|
||||
/***** Get all the users belonging to current course from database *****/
|
||||
if (asprintf (&Query,"SELECT UsrCod FROM crs_usr WHERE CrsCod=%ld",
|
||||
Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
NumUsrs = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get users from current course");
|
||||
DB_BuildQuery ("SELECT UsrCod FROM crs_usr WHERE CrsCod=%ld",
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
NumUsrs = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get users from current course");
|
||||
|
||||
/***** Check folders *****/
|
||||
for (NumUsr = 0;
|
||||
|
@ -3007,7 +3005,6 @@ bool Brw_CheckIfExistsFolderAssigmentForAnyUsr (const char *FolderName)
|
|||
|
||||
static void Brw_CreateFoldersAssignmentsIfNotExist (long ZoneUsrCod)
|
||||
{
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
|
@ -3015,15 +3012,14 @@ static void Brw_CreateFoldersAssignmentsIfNotExist (long ZoneUsrCod)
|
|||
char PathFolderAsg[PATH_MAX + 1 + PATH_MAX + 1];
|
||||
|
||||
/***** Get assignment folders from database *****/
|
||||
if (asprintf (&Query,"SELECT Folder FROM assignments"
|
||||
" WHERE CrsCod=%ld AND Hidden='N' AND Folder<>''"
|
||||
" AND (AsgCod NOT IN (SELECT AsgCod FROM asg_grp) OR"
|
||||
" AsgCod IN (SELECT asg_grp.AsgCod FROM asg_grp,crs_grp_usr"
|
||||
" WHERE crs_grp_usr.UsrCod=%ld"
|
||||
" AND asg_grp.GrpCod=crs_grp_usr.GrpCod))",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,ZoneUsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get folders of assignments");
|
||||
DB_BuildQuery ("SELECT Folder FROM assignments"
|
||||
" WHERE CrsCod=%ld AND Hidden='N' AND Folder<>''"
|
||||
" AND (AsgCod NOT IN (SELECT AsgCod FROM asg_grp) OR"
|
||||
" AsgCod IN (SELECT asg_grp.AsgCod FROM asg_grp,crs_grp_usr"
|
||||
" WHERE crs_grp_usr.UsrCod=%ld"
|
||||
" AND asg_grp.GrpCod=crs_grp_usr.GrpCod))",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,ZoneUsrCod);
|
||||
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get folders of assignments");
|
||||
|
||||
/***** Create one folder for each assignment *****/
|
||||
for (NumRow = 0;
|
||||
|
@ -3058,7 +3054,6 @@ bool Brw_UpdateFoldersAssigmentsIfExistForAllUsrs (const char *OldFolderName,con
|
|||
extern const char *Txt_Users;
|
||||
extern const char *Txt_Folders_renamed;
|
||||
extern const char *Txt_Folders_not_renamed;
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumUsrs;
|
||||
|
@ -3073,10 +3068,9 @@ bool Brw_UpdateFoldersAssigmentsIfExistForAllUsrs (const char *OldFolderName,con
|
|||
unsigned NumUsrsSuccess = 0;
|
||||
|
||||
/***** Get all the users belonging to current course from database *****/
|
||||
if (asprintf (&Query,"SELECT UsrCod FROM crs_usr WHERE CrsCod=%ld",
|
||||
Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
NumUsrs = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get users from current course");
|
||||
DB_BuildQuery ("SELECT UsrCod FROM crs_usr WHERE CrsCod=%ld",
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
NumUsrs = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get users from current course");
|
||||
|
||||
/***** Check if there exist folders with the new name *****/
|
||||
for (NumUsr = 0;
|
||||
|
@ -3191,7 +3185,6 @@ bool Brw_UpdateFoldersAssigmentsIfExistForAllUsrs (const char *OldFolderName,con
|
|||
|
||||
void Brw_RemoveFoldersAssignmentsIfExistForAllUsrs (const char *FolderName)
|
||||
{
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumUsrs;
|
||||
|
@ -3200,10 +3193,9 @@ void Brw_RemoveFoldersAssignmentsIfExistForAllUsrs (const char *FolderName)
|
|||
char PathFolder[PATH_MAX * 2 + 128];
|
||||
|
||||
/***** Get all the users belonging to current course from database *****/
|
||||
if (asprintf (&Query,"SELECT UsrCod FROM crs_usr WHERE CrsCod=%ld",
|
||||
Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
NumUsrs = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get users from current course");
|
||||
DB_BuildQuery ("SELECT UsrCod FROM crs_usr WHERE CrsCod=%ld",
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
NumUsrs = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get users from current course");
|
||||
|
||||
/***** Remove folders *****/
|
||||
for (NumUsr = 0;
|
||||
|
@ -5613,13 +5605,12 @@ static void Brw_GetAndUpdateDateLastAccFileBrowser (void)
|
|||
default:
|
||||
return;
|
||||
}
|
||||
if (asprintf (&Query,"SELECT UNIX_TIMESTAMP(LastClick) FROM file_browser_last"
|
||||
" WHERE UsrCod=%ld AND FileBrowser=%u AND Cod=%ld",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
(unsigned) Brw_FileBrowserForDB_file_browser_last[Gbl.FileBrowser.Type],
|
||||
Cod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get date-time of last access to a file browser");
|
||||
DB_BuildQuery ("SELECT UNIX_TIMESTAMP(LastClick) FROM file_browser_last"
|
||||
" WHERE UsrCod=%ld AND FileBrowser=%u AND Cod=%ld",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
(unsigned) Brw_FileBrowserForDB_file_browser_last[Gbl.FileBrowser.Type],
|
||||
Cod);
|
||||
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get date-time of last access to a file browser");
|
||||
|
||||
if (NumRows == 0) // May be an administrator not belonging to this course
|
||||
Gbl.Usrs.Me.TimeLastAccToThisFileBrowser = LONG_MAX; // Initialize to a big value in order to show files as old
|
||||
|
@ -5656,20 +5647,18 @@ static void Brw_GetAndUpdateDateLastAccFileBrowser (void)
|
|||
|
||||
static long Brw_GetGrpLastAccZone (const char *FieldNameDB)
|
||||
{
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
long GrpCod = -1L;
|
||||
|
||||
/***** Get the group of my last access to a common zone from database *****/
|
||||
if (asprintf (&Query,"SELECT %s FROM crs_usr"
|
||||
" WHERE CrsCod=%ld AND UsrCod=%ld",
|
||||
FieldNameDB,
|
||||
Gbl.CurrentCrs.Crs.CrsCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get the group of your last access to a file browser");
|
||||
DB_BuildQuery ("SELECT %s FROM crs_usr"
|
||||
" WHERE CrsCod=%ld AND UsrCod=%ld",
|
||||
FieldNameDB,
|
||||
Gbl.CurrentCrs.Crs.CrsCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get the group of your last access to a file browser");
|
||||
|
||||
if (NumRows == 0) // May be an administrator not belonging to this course
|
||||
GrpCod = -1L;
|
||||
|
@ -7755,7 +7744,6 @@ static void Brw_WriteCurrentClipboard (void)
|
|||
|
||||
static bool Brw_GetMyClipboard (void)
|
||||
{
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
char PathUntilFileName[PATH_MAX + 1];
|
||||
|
@ -7772,11 +7760,10 @@ static bool Brw_GetMyClipboard (void)
|
|||
Gbl.FileBrowser.Clipboard.Level = 0;
|
||||
|
||||
/***** Get my current clipboard from database *****/
|
||||
if (asprintf (&Query,"SELECT FileBrowser,Cod,WorksUsrCod,FileType,Path"
|
||||
" FROM clipboard WHERE UsrCod=%ld",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
NumRows = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get source of copy from clipboard");
|
||||
DB_BuildQuery ("SELECT FileBrowser,Cod,WorksUsrCod,FileType,Path"
|
||||
" FROM clipboard WHERE UsrCod=%ld",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
NumRows = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get source of copy from clipboard");
|
||||
|
||||
if (NumRows == 1)
|
||||
{
|
||||
|
@ -10164,20 +10151,18 @@ bool Brw_CheckIfFileOrFolderIsSetAsHiddenInDB (Brw_FileType_t FileType,const cha
|
|||
{
|
||||
long Cod = Brw_GetCodForFiles ();
|
||||
long ZoneUsrCod = Brw_GetZoneUsrCodForFiles ();
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
bool IsHidden = false;
|
||||
|
||||
/***** Get if a file or folder is hidden from database *****/
|
||||
if (asprintf (&Query,"SELECT Hidden FROM files"
|
||||
" WHERE FileBrowser=%u AND Cod=%ld AND ZoneUsrCod=%ld"
|
||||
" AND Path='%s'",
|
||||
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
|
||||
Cod,ZoneUsrCod,
|
||||
Path) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not check if a file is hidden"))
|
||||
DB_BuildQuery ("SELECT Hidden FROM files"
|
||||
" WHERE FileBrowser=%u AND Cod=%ld AND ZoneUsrCod=%ld"
|
||||
" AND Path='%s'",
|
||||
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
|
||||
Cod,ZoneUsrCod,
|
||||
Path);
|
||||
if (DB_QuerySELECT_new (&mysql_res,"can not check if a file is hidden"))
|
||||
{
|
||||
/* Get row */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -11172,22 +11157,20 @@ long Brw_GetFilCodByPath (const char *Path,bool OnlyIfPublic)
|
|||
{
|
||||
long Cod = Brw_GetCodForFiles ();
|
||||
long ZoneUsrCod = Brw_GetZoneUsrCodForFiles ();
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
long FilCod;
|
||||
|
||||
/***** Get code of a file from database *****/
|
||||
if (asprintf (&Query,"SELECT FilCod FROM files"
|
||||
" WHERE FileBrowser=%u AND Cod=%ld AND ZoneUsrCod=%ld"
|
||||
" AND Path='%s'%s",
|
||||
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
|
||||
Cod,ZoneUsrCod,
|
||||
Path,
|
||||
OnlyIfPublic ? " AND Public='Y'" :
|
||||
"") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get file code"))
|
||||
DB_BuildQuery ("SELECT FilCod FROM files"
|
||||
" WHERE FileBrowser=%u AND Cod=%ld AND ZoneUsrCod=%ld"
|
||||
" AND Path='%s'%s",
|
||||
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
|
||||
Cod,ZoneUsrCod,
|
||||
Path,
|
||||
OnlyIfPublic ? " AND Public='Y'" :
|
||||
"");
|
||||
if (DB_QuerySELECT_new (&mysql_res,"can not get file code"))
|
||||
{
|
||||
/* Get row */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -11214,22 +11197,20 @@ void Brw_GetFileMetadataByPath (struct FileMetadata *FileMetadata)
|
|||
{
|
||||
long Cod = Brw_GetCodForFiles ();
|
||||
long ZoneUsrCod = Brw_GetZoneUsrCodForFiles ();
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned UnsignedNum;
|
||||
|
||||
/***** Get metadata of a file from database *****/
|
||||
if (asprintf (&Query,"SELECT FilCod,FileBrowser,Cod,ZoneUsrCod,"
|
||||
"PublisherUsrCod,FileType,Path,Hidden,Public,License"
|
||||
" FROM files"
|
||||
" WHERE FileBrowser=%u AND Cod=%ld AND ZoneUsrCod=%ld"
|
||||
" AND Path='%s'",
|
||||
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
|
||||
Cod,ZoneUsrCod,
|
||||
Gbl.FileBrowser.Priv.FullPathInTree) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get file metadata"))
|
||||
DB_BuildQuery ("SELECT FilCod,FileBrowser,Cod,ZoneUsrCod,"
|
||||
"PublisherUsrCod,FileType,Path,Hidden,Public,License"
|
||||
" FROM files"
|
||||
" WHERE FileBrowser=%u AND Cod=%ld AND ZoneUsrCod=%ld"
|
||||
" AND Path='%s'",
|
||||
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
|
||||
Cod,ZoneUsrCod,
|
||||
Gbl.FileBrowser.Priv.FullPathInTree);
|
||||
if (DB_QuerySELECT_new (&mysql_res,"can not get file metadata"))
|
||||
{
|
||||
/* Get row */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -11348,19 +11329,17 @@ void Brw_GetFileMetadataByPath (struct FileMetadata *FileMetadata)
|
|||
|
||||
void Brw_GetFileMetadataByCod (struct FileMetadata *FileMetadata)
|
||||
{
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned UnsignedNum;
|
||||
|
||||
/***** Get metadata of a file from database *****/
|
||||
if (asprintf (&Query,"SELECT FilCod,FileBrowser,Cod,ZoneUsrCod,"
|
||||
"PublisherUsrCod,FileType,Path,Hidden,Public,License"
|
||||
" FROM files"
|
||||
" WHERE FilCod=%ld",
|
||||
FileMetadata->FilCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get file metadata"))
|
||||
DB_BuildQuery ("SELECT FilCod,FileBrowser,Cod,ZoneUsrCod,"
|
||||
"PublisherUsrCod,FileType,Path,Hidden,Public,License"
|
||||
" FROM files"
|
||||
" WHERE FilCod=%ld",
|
||||
FileMetadata->FilCod);
|
||||
if (DB_QuerySELECT_new (&mysql_res,"can not get file metadata"))
|
||||
{
|
||||
/* Get row */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -11568,16 +11547,14 @@ void Brw_UpdateMyFileViews (long FilCod)
|
|||
|
||||
unsigned long Brw_GetNumFileViewsUsr (long UsrCod)
|
||||
{
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long FileViews;
|
||||
|
||||
/***** Get number of filw views *****/
|
||||
if (asprintf (&Query,"SELECT SUM(NumViews) FROM file_view WHERE UsrCod=%ld",
|
||||
UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get number of file views"))
|
||||
DB_BuildQuery ("SELECT SUM(NumViews) FROM file_view WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
if (DB_QuerySELECT_new (&mysql_res,"can not get number of file views"))
|
||||
{
|
||||
/* Get number of file views */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -11608,17 +11585,15 @@ unsigned long Brw_GetNumFileViewsUsr (long UsrCod)
|
|||
*/
|
||||
static void Brw_GetFileViewsFromLoggedUsrs (struct FileMetadata *FileMetadata)
|
||||
{
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
|
||||
/***** Get number total of views from logged users *****/
|
||||
if (asprintf (&Query,"SELECT COUNT(DISTINCT UsrCod),SUM(NumViews)"
|
||||
" FROM file_view"
|
||||
" WHERE FilCod=%ld AND UsrCod>0",
|
||||
FileMetadata->FilCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get number of views of a file from logged users"))
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT UsrCod),SUM(NumViews)"
|
||||
" FROM file_view"
|
||||
" WHERE FilCod=%ld AND UsrCod>0",
|
||||
FileMetadata->FilCod);
|
||||
if (DB_QuerySELECT_new (&mysql_res,"can not get number of views of a file from logged users"))
|
||||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
|
@ -11651,16 +11626,14 @@ static void Brw_GetFileViewsFromLoggedUsrs (struct FileMetadata *FileMetadata)
|
|||
*/
|
||||
static void Brw_GetFileViewsFromNonLoggedUsrs (struct FileMetadata *FileMetadata)
|
||||
{
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
|
||||
/***** Get number of public views *****/
|
||||
if (asprintf (&Query,"SELECT SUM(NumViews) FROM file_view"
|
||||
" WHERE FilCod=%ld AND UsrCod<=0",
|
||||
FileMetadata->FilCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get number of public views of a file"))
|
||||
DB_BuildQuery ("SELECT SUM(NumViews) FROM file_view"
|
||||
" WHERE FilCod=%ld AND UsrCod<=0",
|
||||
FileMetadata->FilCod);
|
||||
if (DB_QuerySELECT_new (&mysql_res,"can not get number of public views of a file"))
|
||||
{
|
||||
/* Get number of public views */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -11685,18 +11658,15 @@ static void Brw_GetFileViewsFromNonLoggedUsrs (struct FileMetadata *FileMetadata
|
|||
|
||||
static unsigned Brw_GetFileViewsFromMe (long FilCod)
|
||||
{
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumMyViews;
|
||||
|
||||
/***** Get number of my views *****/
|
||||
if (asprintf (&Query,"SELECT NumViews FROM file_view"
|
||||
" WHERE FilCod=%ld AND UsrCod=%ld",
|
||||
FilCod,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
|
||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get my number of views of a file"))
|
||||
DB_BuildQuery ("SELECT NumViews FROM file_view"
|
||||
" WHERE FilCod=%ld AND UsrCod=%ld",
|
||||
FilCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
if (DB_QuerySELECT_new (&mysql_res,"can not get my number of views of a file"))
|
||||
{
|
||||
/* Get number of my views */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -12501,7 +12471,6 @@ static bool Brw_CheckIfICanModifyPrjAssFileOrFolder (void)
|
|||
|
||||
static long Brw_GetPublisherOfSubtree (void)
|
||||
{
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
|
@ -12510,15 +12479,14 @@ static long Brw_GetPublisherOfSubtree (void)
|
|||
|
||||
/***** Get all the distinct publishers of files starting by
|
||||
Gbl.FileBrowser.Priv.FullPathInTree from database *****/
|
||||
if (asprintf (&Query,"SELECT DISTINCT(PublisherUsrCod) FROM files"
|
||||
" WHERE FileBrowser=%u AND Cod=%ld"
|
||||
" AND (Path='%s' OR Path LIKE '%s/%%')",
|
||||
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
|
||||
Cod,
|
||||
Gbl.FileBrowser.Priv.FullPathInTree,
|
||||
Gbl.FileBrowser.Priv.FullPathInTree) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get publishers of files");
|
||||
DB_BuildQuery ("SELECT DISTINCT(PublisherUsrCod) FROM files"
|
||||
" WHERE FileBrowser=%u AND Cod=%ld"
|
||||
" AND (Path='%s' OR Path LIKE '%s/%%')",
|
||||
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
|
||||
Cod,
|
||||
Gbl.FileBrowser.Priv.FullPathInTree,
|
||||
Gbl.FileBrowser.Priv.FullPathInTree);
|
||||
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get publishers of files");
|
||||
|
||||
/***** Check all common files that are equal to Gbl.FileBrowser.Priv.FullPathInTree
|
||||
or that are under the folder Gbl.FileBrowser.Priv.FullPathInTree *****/
|
||||
|
@ -12713,8 +12681,7 @@ void Brw_GetSummaryAndContentOfFile (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
/*****************************************************************************/
|
||||
// Returns the number of documents found
|
||||
|
||||
unsigned Brw_ListDocsFound (const char *Query,
|
||||
const char *TitleSingular,const char *TitlePlural)
|
||||
unsigned Brw_ListDocsFound (const char *TitleSingular,const char *TitlePlural)
|
||||
{
|
||||
extern const char *Txt_Institution;
|
||||
extern const char *Txt_Centre;
|
||||
|
@ -12732,7 +12699,7 @@ unsigned Brw_ListDocsFound (const char *Query,
|
|||
unsigned NumDocsHidden;
|
||||
|
||||
/***** Query database *****/
|
||||
if ((NumDocs = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get files")))
|
||||
if ((NumDocs = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get files")))
|
||||
{
|
||||
/***** Start box and table *****/
|
||||
/* Number of documents found */
|
||||
|
|
|
@ -259,8 +259,7 @@ void Brw_GetSummaryAndContentOfFile (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
char **ContentStr,
|
||||
long FilCod,bool GetContent);
|
||||
|
||||
unsigned Brw_ListDocsFound (const char *Query,
|
||||
const char *TitleSingular,const char *TitlePlural);
|
||||
unsigned Brw_ListDocsFound (const char *TitleSingular,const char *TitlePlural);
|
||||
|
||||
void Brw_AskRemoveOldFiles (void);
|
||||
void Brw_RemoveOldFilesBriefcase (void);
|
||||
|
|
554
swad_search.c
554
swad_search.c
|
@ -721,7 +721,6 @@ static unsigned Sch_SearchCentresInDB (const char *RangeQuery)
|
|||
static unsigned Sch_SearchDegreesInDB (const char *RangeQuery)
|
||||
{
|
||||
char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1];
|
||||
char *Query;
|
||||
|
||||
/***** Check scope *****/
|
||||
if (Gbl.Scope.Current != Sco_SCOPE_CRS)
|
||||
|
@ -731,17 +730,16 @@ static unsigned Sch_SearchDegreesInDB (const char *RangeQuery)
|
|||
if (Sch_BuildSearchQuery (SearchQuery,"degrees.FullName",NULL,NULL))
|
||||
{
|
||||
/***** Query database and list degrees found *****/
|
||||
if (asprintf (&Query,"SELECT degrees.DegCod"
|
||||
" FROM degrees,centres,institutions,countries"
|
||||
" WHERE %s"
|
||||
" AND degrees.CtrCod=centres.CtrCod"
|
||||
" AND centres.InsCod=institutions.InsCod"
|
||||
" AND institutions.CtyCod=countries.CtyCod"
|
||||
"%s"
|
||||
" ORDER BY degrees.FullName,institutions.FullName",
|
||||
SearchQuery,RangeQuery) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
return Deg_ListDegsFound (Query);
|
||||
DB_BuildQuery ("SELECT degrees.DegCod"
|
||||
" FROM degrees,centres,institutions,countries"
|
||||
" WHERE %s"
|
||||
" AND degrees.CtrCod=centres.CtrCod"
|
||||
" AND centres.InsCod=institutions.InsCod"
|
||||
" AND institutions.CtyCod=countries.CtyCod"
|
||||
"%s"
|
||||
" ORDER BY degrees.FullName,institutions.FullName",
|
||||
SearchQuery,RangeQuery);
|
||||
return Deg_ListDegsFound ();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -817,7 +815,6 @@ static unsigned Sch_SearchOpenDocumentsInDB (const char *RangeQuery)
|
|||
extern const char *Txt_open_document;
|
||||
extern const char *Txt_open_documents;
|
||||
char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1];
|
||||
char *Query;
|
||||
|
||||
/***** Check user's permission *****/
|
||||
if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_OPEN_DOCUMENTS))
|
||||
|
@ -826,95 +823,93 @@ static unsigned Sch_SearchOpenDocumentsInDB (const char *RangeQuery)
|
|||
"_latin1 "," COLLATE latin1_general_ci"))
|
||||
{
|
||||
/***** Build the query *****/
|
||||
if (asprintf (&Query,"SELECT * FROM "
|
||||
"("
|
||||
"SELECT files.FilCod," // Institution
|
||||
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
||||
"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,courses,degrees,centres,institutions,countries"
|
||||
" WHERE files.Public='Y' AND %s"
|
||||
" AND files.FileBrowser IN (%u,%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,courses,degrees,centres,institutions,countries"
|
||||
" WHERE files.Public='Y' AND %s"
|
||||
" AND files.FileBrowser IN (%u,%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,courses,degrees,centres,institutions,countries"
|
||||
" WHERE files.Public='Y' AND %s"
|
||||
" AND files.FileBrowser IN (%u,%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"
|
||||
" WHERE files.Public='Y' AND %s"
|
||||
" AND files.FileBrowser IN (%u,%u)"
|
||||
" AND files.Cod=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,
|
||||
(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) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
DB_BuildQuery ("SELECT * FROM "
|
||||
"("
|
||||
"SELECT files.FilCod," // Institution
|
||||
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
||||
"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,courses,degrees,centres,institutions,countries"
|
||||
" WHERE files.Public='Y' AND %s"
|
||||
" AND files.FileBrowser IN (%u,%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,courses,degrees,centres,institutions,countries"
|
||||
" WHERE files.Public='Y' AND %s"
|
||||
" AND files.FileBrowser IN (%u,%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,courses,degrees,centres,institutions,countries"
|
||||
" WHERE files.Public='Y' AND %s"
|
||||
" AND files.FileBrowser IN (%u,%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"
|
||||
" WHERE files.Public='Y' AND %s"
|
||||
" AND files.FileBrowser IN (%u,%u)"
|
||||
" AND files.Cod=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,
|
||||
(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);
|
||||
|
||||
/***** Query database and list documents found *****/
|
||||
/* if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM)
|
||||
Lay_ShowAlert (Lay_INFO,Query); */
|
||||
return Brw_ListDocsFound (Query,
|
||||
Txt_open_document,
|
||||
return Brw_ListDocsFound (Txt_open_document,
|
||||
Txt_open_documents);
|
||||
}
|
||||
|
||||
|
@ -929,8 +924,8 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
|
|||
{
|
||||
extern const char *Txt_document_in_my_courses;
|
||||
extern const char *Txt_documents_in_my_courses;
|
||||
char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1];
|
||||
char *Query;
|
||||
char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1];
|
||||
unsigned NumDocs;
|
||||
|
||||
/***** Check user's permission *****/
|
||||
|
@ -978,65 +973,63 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
|
|||
DB_Query_free (Query,"can not create temporary table");
|
||||
|
||||
/***** Build the query *****/
|
||||
if (asprintf (&Query,"SELECT * FROM "
|
||||
"("
|
||||
"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,"
|
||||
"-1 AS GrpCod"
|
||||
" FROM files,courses,degrees,centres,institutions,countries"
|
||||
" WHERE files.FilCod IN (SELECT FilCod FROM my_files_crs) AND %s"
|
||||
" AND files.FileBrowser IN (%u,%u,%u,%u)"
|
||||
" AND files.Cod=courses.CrsCod"
|
||||
" AND courses.DegCod=degrees.DegCod"
|
||||
" AND degrees.CtrCod=centres.CtrCod"
|
||||
" AND centres.InsCod=institutions.InsCod"
|
||||
" AND institutions.CtyCod=countries.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
"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,%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,
|
||||
(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) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
DB_BuildQuery ("SELECT * FROM "
|
||||
"("
|
||||
"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,"
|
||||
"-1 AS GrpCod"
|
||||
" FROM files,courses,degrees,centres,institutions,countries"
|
||||
" WHERE files.FilCod IN (SELECT FilCod FROM my_files_crs) AND %s"
|
||||
" AND files.FileBrowser IN (%u,%u,%u,%u)"
|
||||
" AND files.Cod=courses.CrsCod"
|
||||
" AND courses.DegCod=degrees.DegCod"
|
||||
" AND degrees.CtrCod=centres.CtrCod"
|
||||
" AND centres.InsCod=institutions.InsCod"
|
||||
" AND institutions.CtyCod=countries.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
"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,%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,
|
||||
(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 and list documents found *****/
|
||||
/* if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM)
|
||||
Lay_ShowAlert (Lay_INFO,Query); */
|
||||
NumDocs = Brw_ListDocsFound (Query,
|
||||
Txt_document_in_my_courses,
|
||||
Lay_ShowAlert (Lay_INFO,Gbl.DB.QueryPtr); */
|
||||
NumDocs = Brw_ListDocsFound (Txt_document_in_my_courses,
|
||||
Txt_documents_in_my_courses);
|
||||
|
||||
/***** Drop temporary table *****/
|
||||
|
@ -1059,7 +1052,6 @@ static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery)
|
|||
extern const char *Txt_document_from_me;
|
||||
extern const char *Txt_documents_from_me;
|
||||
char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1];
|
||||
char *Query;
|
||||
|
||||
/***** Check user's permission *****/
|
||||
if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_MY_DOCUMENTS))
|
||||
|
@ -1068,135 +1060,133 @@ static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery)
|
|||
"_latin1 "," COLLATE latin1_general_ci"))
|
||||
{
|
||||
/***** Build the query *****/
|
||||
if (asprintf (&Query,"SELECT * FROM "
|
||||
"("
|
||||
"SELECT files.FilCod," // Institution
|
||||
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
||||
"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,courses,degrees,centres,institutions,countries"
|
||||
" WHERE files.PublisherUsrCod=%ld AND %s"
|
||||
" AND files.FileBrowser IN (%u,%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,courses,degrees,centres,institutions,countries"
|
||||
" WHERE files.PublisherUsrCod=%ld AND %s"
|
||||
" AND files.FileBrowser IN (%u,%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 CrsCod,'' AS CrsShortName,"
|
||||
"-1 AS GrpCod"
|
||||
" FROM files,courses,degrees,centres,institutions,countries"
|
||||
" WHERE files.PublisherUsrCod=%ld AND %s"
|
||||
" AND files.FileBrowser IN (%u,%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 AS GrpCod"
|
||||
" FROM files,courses,degrees,centres,institutions,countries"
|
||||
" WHERE files.PublisherUsrCod=%ld AND %s"
|
||||
" AND files.FileBrowser IN (%u,%u,%u,%u)"
|
||||
" AND files.Cod=courses.CrsCod"
|
||||
" AND courses.DegCod=degrees.DegCod"
|
||||
" AND degrees.CtrCod=centres.CtrCod"
|
||||
" AND centres.InsCod=institutions.InsCod"
|
||||
" AND institutions.CtyCod=countries.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
"SELECT files.FilCod," // Group
|
||||
"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.PublisherUsrCod=%ld AND %s"
|
||||
" AND files.FileBrowser IN (%u,%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"
|
||||
" UNION "
|
||||
"SELECT files.FilCod," // Briefcase
|
||||
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
||||
"-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"
|
||||
" WHERE files.PublisherUsrCod=%ld AND %s"
|
||||
" AND 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) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
DB_BuildQuery ("SELECT * FROM "
|
||||
"("
|
||||
"SELECT files.FilCod," // Institution
|
||||
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
||||
"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,courses,degrees,centres,institutions,countries"
|
||||
" WHERE files.PublisherUsrCod=%ld AND %s"
|
||||
" AND files.FileBrowser IN (%u,%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,courses,degrees,centres,institutions,countries"
|
||||
" WHERE files.PublisherUsrCod=%ld AND %s"
|
||||
" AND files.FileBrowser IN (%u,%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 CrsCod,'' AS CrsShortName,"
|
||||
"-1 AS GrpCod"
|
||||
" FROM files,courses,degrees,centres,institutions,countries"
|
||||
" WHERE files.PublisherUsrCod=%ld AND %s"
|
||||
" AND files.FileBrowser IN (%u,%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 AS GrpCod"
|
||||
" FROM files,courses,degrees,centres,institutions,countries"
|
||||
" WHERE files.PublisherUsrCod=%ld AND %s"
|
||||
" AND files.FileBrowser IN (%u,%u,%u,%u)"
|
||||
" AND files.Cod=courses.CrsCod"
|
||||
" AND courses.DegCod=degrees.DegCod"
|
||||
" AND degrees.CtrCod=centres.CtrCod"
|
||||
" AND centres.InsCod=institutions.InsCod"
|
||||
" AND institutions.CtyCod=countries.CtyCod"
|
||||
"%s"
|
||||
" UNION "
|
||||
"SELECT files.FilCod," // Group
|
||||
"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.PublisherUsrCod=%ld AND %s"
|
||||
" AND files.FileBrowser IN (%u,%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"
|
||||
" UNION "
|
||||
"SELECT files.FilCod," // Briefcase
|
||||
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
|
||||
"-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"
|
||||
" WHERE files.PublisherUsrCod=%ld AND %s"
|
||||
" AND 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 and list documents found *****/
|
||||
/* if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM)
|
||||
Lay_ShowAlert (Lay_INFO,Query); */
|
||||
return Brw_ListDocsFound (Query,
|
||||
Txt_document_from_me,
|
||||
Lay_ShowAlert (Lay_INFO,Gbl.DB.QueryPtr); */
|
||||
return Brw_ListDocsFound (Txt_document_from_me,
|
||||
Txt_documents_from_me);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue