diff --git a/swad_changelog.h b/swad_changelog.h index d367c0ba8..bd27d3c82 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -250,17 +250,20 @@ // TODO: Mover PROFILE.Briefcase a FILES.Briefcase en la ayuda de GitHub (aquí ya está cambiado) +// TODO: Los profesores no editores no deberían recibir notificaciones de solicitudes de inscripción. + /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 17.20 (2017-10-06)" +#define Log_PLATFORM_VERSION "SWAD 17.20.1 (2017-10-07)" #define CSS_FILE "swad17.0.css" #define JS_FILE "swad17.17.1.js" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1 /* + Version 17.20.1: Oct 07, 2017 Fixed bug in file browser clipboard. (? lines) Version 17.20: Oct 06, 2017 New file browser for project documents. Not finished. (232915 lines) 18 changes necessary in database: INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1698','es','N','Subir archivo a docs. proyecto (ant.)'); diff --git a/swad_file_browser.c b/swad_file_browser.c index 6b7c998fd..3c50d4696 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -7071,6 +7071,7 @@ static void Brw_WriteCurrentClipboard (void) Usr_UsrDataDestructor (&UsrDat); break; case Brw_ADMI_DOCUM_PRJ: + Prj_AllocMemProject (&Prj); Prj.PrjCod = Gbl.FileBrowser.Clipboard.Cod; Prj_GetDataOfProjectByCod (&Prj); Crs.CrsCod = Prj.CrsCod; @@ -7079,6 +7080,7 @@ static void Brw_WriteCurrentClipboard (void) Txt_project_documents, Txt_course,Crs.ShrtName, Txt_project,Prj.Title); + Prj_FreeMemProject (&Prj); break; case Brw_ADMI_MARKS_CRS: Crs.CrsCod = Gbl.FileBrowser.Clipboard.Cod; @@ -7896,7 +7898,7 @@ static void Brw_PasteClipboard (void) struct Degree Deg; struct Course Crs; struct GroupData GrpDat; - struct Project Prj; + long PrjCod; char PathOrg[PATH_MAX + 1]; struct Brw_NumObjects Pasted; long FirstFilCod = -1L; // First file code of the first file or link pasted. Important: initialize here to -1L @@ -7922,7 +7924,7 @@ static void Brw_PasteClipboard (void) (unsigned) Ins.InsCod, Gbl.FileBrowser.Clipboard.Path); else - Lay_ShowErrorAndExit ("The institution of copy source does not exist."); + Lay_ShowErrorAndExit ("The copy source does not exist."); break; case Brw_ADMI_DOCUM_CTR: case Brw_ADMI_SHARE_CTR: @@ -7934,7 +7936,7 @@ static void Brw_PasteClipboard (void) (unsigned) Ctr.CtrCod, Gbl.FileBrowser.Clipboard.Path); else - Lay_ShowErrorAndExit ("The centre of copy source does not exist."); + Lay_ShowErrorAndExit ("The copy source does not exist."); break; case Brw_ADMI_DOCUM_DEG: case Brw_ADMI_SHARE_DEG: @@ -7946,7 +7948,7 @@ static void Brw_PasteClipboard (void) (unsigned) Deg.DegCod, Gbl.FileBrowser.Clipboard.Path); else - Lay_ShowErrorAndExit ("The degree of copy source does not exist."); + Lay_ShowErrorAndExit ("The copy source does not exist."); break; case Brw_ADMI_DOCUM_CRS: case Brw_ADMI_TEACH_CRS: @@ -7958,7 +7960,7 @@ static void Brw_PasteClipboard (void) Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,Crs.CrsCod, Gbl.FileBrowser.Clipboard.Path); else - Lay_ShowErrorAndExit ("The course of copy source does not exist."); + Lay_ShowErrorAndExit ("The copy source does not exist."); break; case Brw_ADMI_DOCUM_GRP: case Brw_ADMI_TEACH_GRP: @@ -7973,7 +7975,7 @@ static void Brw_PasteClipboard (void) GrpDat.GrpCod, Gbl.FileBrowser.Clipboard.Path); else - Lay_ShowErrorAndExit ("The course of copy source does not exist."); + Lay_ShowErrorAndExit ("The copy source does not exist."); break; case Brw_ADMI_ASSIG_USR: case Brw_ADMI_WORKS_USR: @@ -7985,25 +7987,19 @@ static void Brw_PasteClipboard (void) Gbl.Usrs.Me.UsrDat.UsrCod, Gbl.FileBrowser.Clipboard.Path); else - Lay_ShowErrorAndExit ("The course of copy source does not exist."); + Lay_ShowErrorAndExit ("The copy source does not exist."); break; case Brw_ADMI_DOCUM_PRJ: - Prj.PrjCod = Gbl.FileBrowser.Clipboard.Cod; - Prj_GetDataOfProjectByCod (&Prj); - if (Prj.PrjCod > 0) - { - Crs.CrsCod = Prj.CrsCod; - if (Crs_GetDataOfCourseByCod (&Crs)) - sprintf (PathOrg,"%s/%s/%ld/%s/%02u/%ld/%s", - Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,Crs.CrsCod,Cfg_FOLDER_PRJ, - (unsigned) (Prj.PrjCod % 100), - Prj.PrjCod, - Gbl.FileBrowser.Clipboard.Path); - else - Lay_ShowErrorAndExit ("The course of copy source does not exist."); - } - else - Lay_ShowErrorAndExit ("The course of copy source does not exist."); + PrjCod = Gbl.FileBrowser.Clipboard.Cod; + Crs.CrsCod = Prj_GetCourseOfProject (PrjCod); + if (Crs_GetDataOfCourseByCod (&Crs)) + sprintf (PathOrg,"%s/%s/%ld/%s/%02u/%ld/%s", + Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,Crs.CrsCod,Cfg_FOLDER_PRJ, + (unsigned) (PrjCod % 100), + PrjCod, + Gbl.FileBrowser.Clipboard.Path); + else + Lay_ShowErrorAndExit ("The copy source does not exist."); break; case Brw_ADMI_BRIEF_USR: sprintf (PathOrg,"%s/%s", diff --git a/swad_project.c b/swad_project.c index 3a73ca9bc..fba3eedf9 100644 --- a/swad_project.c +++ b/swad_project.c @@ -148,9 +148,6 @@ static void Prj_EditOneProjectTxtArea (const char *Id, const char *Label,char *TxtField, unsigned NumRows); -static void Prj_AllocMemProject (struct Project *Prj); -static void Prj_FreeMemProject (struct Project *Prj); - static void Prj_CreateProject (struct Project *Prj); static void Prj_UpdateProject (struct Project *Prj); @@ -1786,7 +1783,7 @@ static bool Prj_GetIfIAmTutorInProject (long PrjCod) sprintf (Query,"SELECT COUNT(*) FROM prj_usr" " WHERE PrjCod=%ld AND RoleInProject=%u AND UsrCod=%ld", PrjCod,Prj_ROLE_TUT,Gbl.Usrs.Me.UsrDat.UsrCod); - return (bool) (DB_QueryCOUNT (Query,"can not get number of projects in course") != 0); + return (bool) (DB_QueryCOUNT (Query,"can not check if I am a tutor in a project") != 0); } /*****************************************************************************/ @@ -1945,6 +1942,37 @@ void Prj_GetListProjects (void) Gbl.Prjs.LstIsRead = true; } +/*****************************************************************************/ +/****************** Check if a project exists in a course ********************/ +/*****************************************************************************/ + +long Prj_GetCourseOfProject (long PrjCod) + { + char Query[128]; + MYSQL_RES *mysql_res; + MYSQL_ROW row; + long CrsCod = -1L; + + if (PrjCod > 0) + { + /***** Get course code from database *****/ + sprintf (Query,"SELECT CrsCod FROM projects WHERE PrjCod=%ld",PrjCod); + if (DB_QuerySELECT (Query,&mysql_res,"can not get project course")) // Project found... + { + /* Get row */ + row = mysql_fetch_row (mysql_res); + + /* Get code of the course (row[0]) */ + CrsCod = Str_ConvertStrCodToLongCod (row[0]); + } + + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); + } + + return CrsCod; + } + /*****************************************************************************/ /********************* Get project data using its code ***********************/ /*****************************************************************************/ @@ -2628,7 +2656,7 @@ static void Prj_EditOneProjectTxtArea (const char *Id, /*** Allocate memory for those parameters of a project with a lot of text ****/ /*****************************************************************************/ -static void Prj_AllocMemProject (struct Project *Prj) +void Prj_AllocMemProject (struct Project *Prj) { if ((Prj->Description = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store project."); @@ -2644,7 +2672,7 @@ static void Prj_AllocMemProject (struct Project *Prj) /****** Free memory of those parameters of a project with a lot of text ******/ /*****************************************************************************/ -static void Prj_FreeMemProject (struct Project *Prj) +void Prj_FreeMemProject (struct Project *Prj) { if (Prj->Description) { diff --git a/swad_project.h b/swad_project.h index 7ba571cb3..9593c178c 100644 --- a/swad_project.h +++ b/swad_project.h @@ -136,8 +136,12 @@ void Prj_PutHiddenParamPrjOrder (void); void Prj_RequestCreatePrj (void); void Prj_RequestEditPrj (void); +void Prj_AllocMemProject (struct Project *Prj); +void Prj_FreeMemProject (struct Project *Prj); + void Prj_GetListProjects (void); void Prj_GetDataOfProjectByCod (struct Project *Prj); +long Prj_GetCourseOfProject (long PrjCod); void Prj_FreeListProjects (void); void Prj_PutParamPrjCod (long PrjCod);