Version 16.178

This commit is contained in:
Antonio Cañas Vargas 2017-04-16 13:45:11 +02:00
parent ecd3fa399f
commit 7508be0542
4 changed files with 259 additions and 281 deletions

View File

@ -2585,7 +2585,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
// TabSoc ******************************************************************
/* ActSeeSocTmlGbl */{1490, 0,TabSoc,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_ShowTimelineGbl1 ,Soc_ShowTimelineGbl2 ,"soc64x64.png" },
/* ActSeeSocPrf */{1520, 1,TabSoc,ActSeeSocPrf ,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Prf_SeeSocialProfiles ,"prf64x64.gif" },
/* ActSeeFor */{ 95, 2,TabSoc,ActSeeFor ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,For_ShowForumList ,"forum64x64.gif" },
/* ActSeeFor */{ 95, 2,TabSoc,ActSeeFor ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,For_ShowForumThrs ,"forum64x64.gif" },
/* ActSeeChtRms */{ 51, 3,TabSoc,ActSeeChtRms ,0x1FC,0x1FC,0x1FC,0x1FC,0x1FC,0x1FC,0x1FC,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Cht_ShowChatRooms ,"chat64x64.gif" },
/* ActRcvSocPstGbl */{1492,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_DATA,Act_THIS_WINDOW,Soc_ShowTimelineGbl1 ,Soc_ReceiveSocialPostGbl ,NULL},

View File

@ -208,17 +208,20 @@
// TODO: Comprobar que, para detectar el número de filas de cabecera y pie automáticamente en los archivos de calificaciones, SWAD mira no sólo que parezcan un ID, sino que coincida con alguno de los DNI de la asignatura (por ejemplo en el caso de los DNI alemanes formados por varias letras)
// TODO: Changes in timetable (hours end in 24h).
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 16.177.4 (2017-04-14)"
#define Log_PLATFORM_VERSION "SWAD 16.178 (2017-04-16)"
#define CSS_FILE "swad16.177.css"
#define JS_FILE "swad16.144.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 16.178: Apr 16, 2017 Code refactoring in forums (217595 lines)
Version 16.177.4: Apr 14, 2017 Changes in layout of forums. (217611 lines)
Version 16.177.3: Apr 14, 2017 Highlight current thread in forums. (217609 lines)
Version 16.177.2: Apr 14, 2017 Code refactoring in forums. (217604 lines)

View File

@ -299,6 +299,9 @@ static void For_PutParamWhichForum (void);
static void For_PutParamForumOrder (void);
static void For_PutFormWhichForums (void);
static void For_PutParamsForumInsDegCrs (void);
static void For_ShowForumList (void);
static void For_WriteLinksToGblForums (bool IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS]);
static void For_WriteLinksToPlatformForums (bool IsLastForum,
bool IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS]);
@ -325,7 +328,6 @@ static unsigned For_GetNumOfPostsInThrNewerThan (long ThrCod,const char *Time);
static void For_ShowForumThreadsHighlightingOneThread (long ThrCodHighlighted);
static void For_ShowForumLevel2 (long ThrCod);
static void For_WriteFormForumPst (bool IsReply,long ThrCod,const char *Subject);
static void For_UpdateNumUsrsNotifiedByEMailAboutPost (long PstCod,unsigned NumUsrsToBeNotifiedByEMail);
@ -339,6 +341,8 @@ static void For_ListForumThrs (long ThrCods[Pag_ITEMS_PER_PAGE],
static void For_GetThrData (struct ForumThread *Thr);
static void For_GetParamsForum (void);
static void For_SetForumType (void);
static void For_RestrictAccess (void);
static long For_GetParamThrCod (void);
static void For_PutHiddenParamPstCod (long PstCod);
static long For_GetParamPstCod (void);
@ -350,14 +354,12 @@ static long For_GetParamPstCod (void);
void For_EnbPst (void)
{
extern const char *Txt_Post_unbanned;
long PstCod,ThrCod;
long PstCod;
long ThrCod;
/***** Get order type, degree and course of the forum *****/
/***** Get parameters related to forum *****/
For_GetParamsForum ();
/***** Set forum type *****/
For_SetForumTypeAndRestrictAccess ();
/***** Get the post code to unban *****/
PstCod = For_GetParamPstCod ();
@ -369,7 +371,7 @@ void For_EnbPst (void)
Lay_ShowAlert (Lay_SUCCESS,Txt_Post_unbanned);
/***** Show the posts again *****/
For_ShowForumLevel2 (ThrCod);
For_ShowThreadPosts (ThrCod);
}
/*****************************************************************************/
@ -381,12 +383,9 @@ void For_DisPst (void)
extern const char *Txt_Post_banned;
long PstCod,ThrCod;
/***** Get order type, degree and course of the forum *****/
/***** Get parameters related to forum *****/
For_GetParamsForum ();
/***** Set forum type *****/
For_SetForumTypeAndRestrictAccess ();
/***** Get the post code to ban *****/
PstCod = For_GetParamPstCod ();
@ -404,7 +403,7 @@ void For_DisPst (void)
Lay_ShowErrorAndExit ("The post to be banned no longer exists.");
/***** Show the posts again *****/
For_ShowForumLevel2 (ThrCod);
For_ShowThreadPosts (ThrCod);
}
/*****************************************************************************/
@ -995,6 +994,9 @@ static void For_ShowThreadPosts (long ThrCod)
bool ICanModerateForum = false;
bool ICanMoveThreads = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); // If I have permission to move threads...
/***** Show threads *****/
For_ShowForumThreadsHighlightingOneThread (ThrCod);
/***** Get data of the thread *****/
Thr.ThrCod = ThrCod;
For_GetThrData (&Thr);
@ -1555,181 +1557,11 @@ static void For_PutParamsForumInsDegCrs (void)
Par_PutHiddenParamLong ("ForInsCod",Gbl.Forum.Ins.InsCod);
}
/*****************************************************************************/
/***************************** Set the type of forum *************************/
/*****************************************************************************/
void For_SetForumTypeAndRestrictAccess (void)
{
extern const char *Txt_You_dont_have_permission_to_access_to_this_forum;
bool ICanSeeForum = false;
switch (Gbl.Action.Act)
{
case ActSeeForSWAUsr: case ActSeePstForSWAUsr:
case ActRcvThrForSWAUsr: case ActRcvRepForSWAUsr:
case ActReqDelThrSWAUsr: case ActDelThrForSWAUsr:
case ActCutThrForSWAUsr: case ActPasThrForSWAUsr:
case ActDelPstForSWAUsr:
case ActEnbPstForSWAUsr: case ActDisPstForSWAUsr:
Gbl.Forum.Type = For_FORUM_SWAD_USRS;
Gbl.Forum.Level = 1;
break;
case ActSeeForSWATch: case ActSeePstForSWATch:
case ActRcvThrForSWATch: case ActRcvRepForSWATch:
case ActReqDelThrSWATch: case ActDelThrForSWATch:
case ActCutThrForSWATch: case ActPasThrForSWATch:
case ActDelPstForSWATch:
case ActEnbPstForSWATch: case ActDisPstForSWATch:
Gbl.Forum.Type = For_FORUM_SWAD_TCHS;
Gbl.Forum.Level = 1;
break;
case ActSeeForGenUsr: case ActSeePstForGenUsr:
case ActRcvThrForGenUsr: case ActRcvRepForGenUsr:
case ActReqDelThrGenUsr: case ActDelThrForGenUsr:
case ActCutThrForGenUsr: case ActPasThrForGenUsr:
case ActDelPstForGenUsr:
case ActEnbPstForGenUsr: case ActDisPstForGenUsr:
Gbl.Forum.Type = For_FORUM_GLOBAL_USRS;
Gbl.Forum.Level = 1;
break;
case ActSeeForGenTch: case ActSeePstForGenTch:
case ActRcvThrForGenTch: case ActRcvRepForGenTch:
case ActReqDelThrGenTch: case ActDelThrForGenTch:
case ActCutThrForGenTch: case ActPasThrForGenTch:
case ActDelPstForGenTch:
case ActEnbPstForGenTch: case ActDisPstForGenTch:
Gbl.Forum.Type = For_FORUM_GLOBAL_TCHS;
Gbl.Forum.Level = 1;
break;
case ActSeeForInsUsr: case ActSeePstForInsUsr:
case ActRcvThrForInsUsr: case ActRcvRepForInsUsr:
case ActReqDelThrInsUsr: case ActDelThrForInsUsr:
case ActCutThrForInsUsr: case ActPasThrForInsUsr:
case ActDelPstForInsUsr:
case ActEnbPstForInsUsr: case ActDisPstForInsUsr:
Gbl.Forum.Type = For_FORUM_INSTIT_USRS;
Gbl.Forum.Level = 1;
break;
case ActSeeForInsTch: case ActSeePstForInsTch:
case ActRcvThrForInsTch: case ActRcvRepForInsTch:
case ActReqDelThrInsTch: case ActDelThrForInsTch:
case ActCutThrForInsTch: case ActPasThrForInsTch:
case ActDelPstForInsTch:
case ActEnbPstForInsTch: case ActDisPstForInsTch:
Gbl.Forum.Type = For_FORUM_INSTIT_TCHS;
Gbl.Forum.Level = 1;
break;
case ActSeeForCtrUsr: case ActSeePstForCtrUsr:
case ActRcvThrForCtrUsr: case ActRcvRepForCtrUsr:
case ActReqDelThrCtrUsr: case ActDelThrForCtrUsr:
case ActCutThrForCtrUsr: case ActPasThrForCtrUsr:
case ActDelPstForCtrUsr:
case ActEnbPstForCtrUsr: case ActDisPstForCtrUsr:
Gbl.Forum.Type = For_FORUM_CENTRE_USRS;
Gbl.Forum.Level = 1;
break;
case ActSeeForCtrTch: case ActSeePstForCtrTch:
case ActRcvThrForCtrTch: case ActRcvRepForCtrTch:
case ActReqDelThrCtrTch: case ActDelThrForCtrTch:
case ActCutThrForCtrTch: case ActPasThrForCtrTch:
case ActDelPstForCtrTch:
case ActEnbPstForCtrTch: case ActDisPstForCtrTch:
Gbl.Forum.Type = For_FORUM_CENTRE_TCHS;
Gbl.Forum.Level = 1;
break;
case ActSeeForDegUsr: case ActSeePstForDegUsr:
case ActRcvThrForDegUsr: case ActRcvRepForDegUsr:
case ActReqDelThrDegUsr: case ActDelThrForDegUsr:
case ActCutThrForDegUsr: case ActPasThrForDegUsr:
case ActDelPstForDegUsr:
case ActEnbPstForDegUsr: case ActDisPstForDegUsr:
Gbl.Forum.Type = For_FORUM_DEGREE_USRS;
Gbl.Forum.Level = 2;
break;
case ActSeeForDegTch: case ActSeePstForDegTch:
case ActRcvThrForDegTch: case ActRcvRepForDegTch:
case ActReqDelThrDegTch: case ActDelThrForDegTch:
case ActCutThrForDegTch: case ActPasThrForDegTch:
case ActDelPstForDegTch:
case ActEnbPstForDegTch: case ActDisPstForDegTch:
Gbl.Forum.Type = For_FORUM_DEGREE_TCHS;
Gbl.Forum.Level = 2;
break;
case ActSeeForCrsUsr: case ActSeePstForCrsUsr:
case ActRcvThrForCrsUsr: case ActRcvRepForCrsUsr:
case ActReqDelThrCrsUsr: case ActDelThrForCrsUsr:
case ActCutThrForCrsUsr: case ActPasThrForCrsUsr:
case ActDelPstForCrsUsr:
case ActEnbPstForCrsUsr: case ActDisPstForCrsUsr:
Gbl.Forum.Type = For_FORUM_COURSE_USRS;
Gbl.Forum.Level = 3;
break;
case ActSeeForCrsTch: case ActSeePstForCrsTch:
case ActRcvThrForCrsTch: case ActRcvRepForCrsTch:
case ActReqDelThrCrsTch: case ActDelThrForCrsTch:
case ActCutThrForCrsTch: case ActPasThrForCrsTch:
case ActDelPstForCrsTch:
case ActEnbPstForCrsTch: case ActDisPstForCrsTch:
Gbl.Forum.Type = For_FORUM_COURSE_TCHS;
Gbl.Forum.Level = 3;
break;
}
/***** Restrict access *****/
switch (Gbl.Forum.Type)
{
case For_FORUM_COURSE_USRS:
ICanSeeForum = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
Rol_GetMyRoleInCrs (Gbl.Forum.Crs.CrsCod) >= Rol_STUDENT);
break;
case For_FORUM_COURSE_TCHS:
ICanSeeForum = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
Rol_GetMyRoleInCrs (Gbl.Forum.Crs.CrsCod) >= Rol_TEACHER);
break;
case For_FORUM_DEGREE_USRS:
ICanSeeForum = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
Rol_GetMyMaxRoleInDeg (Gbl.Forum.Deg.DegCod) >= Rol_STUDENT);
break;
case For_FORUM_DEGREE_TCHS:
ICanSeeForum = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
Rol_GetMyMaxRoleInDeg (Gbl.Forum.Deg.DegCod) >= Rol_TEACHER);
break;
case For_FORUM_CENTRE_USRS:
ICanSeeForum = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
Rol_GetMyMaxRoleInCtr (Gbl.Forum.Ctr.CtrCod) >= Rol_STUDENT);
break;
case For_FORUM_CENTRE_TCHS:
ICanSeeForum = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
Rol_GetMyMaxRoleInCtr (Gbl.Forum.Ctr.CtrCod) >= Rol_TEACHER);
break;
case For_FORUM_INSTIT_USRS:
ICanSeeForum = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
Rol_GetMyMaxRoleInIns (Gbl.Forum.Ins.InsCod) >= Rol_STUDENT);
break;
case For_FORUM_INSTIT_TCHS:
ICanSeeForum = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
Rol_GetMyMaxRoleInIns (Gbl.Forum.Ins.InsCod) >= Rol_TEACHER);
break;
case For_FORUM_GLOBAL_USRS:
case For_FORUM_SWAD_USRS:
ICanSeeForum = true;
break;
case For_FORUM_GLOBAL_TCHS:
case For_FORUM_SWAD_TCHS:
Rol_GetRolesInAllCrssIfNotYetGot (&Gbl.Usrs.Me.UsrDat);
ICanSeeForum = (Gbl.Usrs.Me.UsrDat.Roles >= (1 << Rol_TEACHER));
break;
}
if (!ICanSeeForum)
Lay_ShowErrorAndExit (Txt_You_dont_have_permission_to_access_to_this_forum);
}
/*****************************************************************************/
/************************** Show list of available forums ********************/
/*****************************************************************************/
void For_ShowForumList (void)
static void For_ShowForumList (void)
{
extern const char *Hlp_SOCIAL_Forums;
extern const char *Txt_Forums;
@ -1751,9 +1583,6 @@ void For_ShowForumList (void)
if (ICanMoveThreads)
Gbl.Forum.ThreadToMove = For_GetThrInMyClipboard ();
/***** Get order type, degree and course of the forum *****/
For_GetParamsForum ();
/***** Fill the list with the institutions I belong to *****/
Usr_GetMyInstits ();
@ -2567,9 +2396,17 @@ static unsigned For_GetNumOfPostsInThrNewerThan (long ThrCod,const char *Time)
void For_ShowForumThrs (void)
{
/***** Get parameters related to forum *****/
For_GetParamsForum ();
/***** Show forum threads with no one highlighted *****/
For_ShowForumThreadsHighlightingOneThread (-1L);
}
/*****************************************************************************/
/********** Show available threads of a forum highlighting a thread **********/
/*****************************************************************************/
static void For_ShowForumThreadsHighlightingOneThread (long ThrCodHighlighted)
{
extern const char *Hlp_SOCIAL_Forums;
@ -2599,12 +2436,6 @@ static void For_ShowForumThreadsHighlightingOneThread (long ThrCodHighlighted)
if (ICanMoveThreads)
Gbl.Forum.ThreadToMove = For_GetThrInMyClipboard ();
/***** Get order type, degree and course of the forum *****/
For_GetParamsForum ();
/***** Set forum type *****/
For_SetForumTypeAndRestrictAccess ();
/***** Show list of available forums *****/
For_ShowForumList ();
@ -3718,14 +3549,14 @@ void For_ShowThrPsts (void)
{
long ThrCod;
/***** Get order type, degree and course of the forum *****/
/***** Get parameters related to forum *****/
For_GetParamsForum ();
/***** Get the identifier of the thread that user want to show *****/
ThrCod = For_GetParamThrCod ();
/***** Show the posts of that thread *****/
For_ShowForumLevel2 (ThrCod);
For_ShowThreadPosts (ThrCod);
}
/*****************************************************************************/
@ -3734,56 +3565,233 @@ void For_ShowThrPsts (void)
static void For_GetParamsForum (void)
{
static bool AlreadyGot = false;
/***** Set forum type *****/
For_SetForumType ();
if (!AlreadyGot)
/***** Get which forums I want to see *****/
Gbl.Forum.WhichForums = (For_WhichForums_t)
Par_GetParToUnsignedLong ("WhichForum",
0,
For_NUM_WHICH_FORUMS - 1,
(unsigned long) For_DEFAULT_WHICH_FORUMS);
/***** Get order type *****/
Gbl.Forum.SelectedOrder = (For_Order_t)
Par_GetParToUnsignedLong ("Order",
0,
For_NUM_ORDERS - 1,
(unsigned long) For_DEFAULT_ORDER);
/***** Get parameter with code of course *****/
Gbl.Forum.Crs.CrsCod = Par_GetParToLong ("ForCrsCod");
Crs_GetDataOfCourseByCod (&Gbl.Forum.Crs);
if (Gbl.Forum.Crs.CrsCod > 0)
Gbl.Forum.Cod = Gbl.Forum.Crs.CrsCod;
else
{
/***** Get which forums I want to see *****/
Gbl.Forum.WhichForums = (For_WhichForums_t)
Par_GetParToUnsignedLong ("WhichForum",
0,
For_NUM_WHICH_FORUMS - 1,
(unsigned long) For_DEFAULT_WHICH_FORUMS);
/***** Get order type *****/
Gbl.Forum.SelectedOrder = (For_Order_t)
Par_GetParToUnsignedLong ("Order",
0,
For_NUM_ORDERS - 1,
(unsigned long) For_DEFAULT_ORDER);
/***** Get parameter with code of course *****/
Gbl.Forum.Crs.CrsCod = Par_GetParToLong ("ForCrsCod");
Crs_GetDataOfCourseByCod (&Gbl.Forum.Crs);
if (Gbl.Forum.Crs.CrsCod > 0)
Gbl.Forum.Cod = Gbl.Forum.Crs.CrsCod;
/***** Get parameter with code of degree *****/
Gbl.Forum.Deg.DegCod = Par_GetParToLong ("ForDegCod");
Deg_GetDataOfDegreeByCod (&Gbl.Forum.Deg);
if (Gbl.Forum.Deg.DegCod > 0)
Gbl.Forum.Cod = Gbl.Forum.Deg.DegCod;
else
{
/***** Get parameter with code of degree *****/
Gbl.Forum.Deg.DegCod = Par_GetParToLong ("ForDegCod");
Deg_GetDataOfDegreeByCod (&Gbl.Forum.Deg);
if (Gbl.Forum.Deg.DegCod > 0)
Gbl.Forum.Cod = Gbl.Forum.Deg.DegCod;
/***** Get parameter with code of institution *****/
Gbl.Forum.Ctr.CtrCod = Par_GetParToLong ("ForCtrCod");
Ctr_GetDataOfCentreByCod (&Gbl.Forum.Ctr);
if (Gbl.Forum.Ctr.CtrCod > 0)
Gbl.Forum.Cod = Gbl.Forum.Ctr.CtrCod;
else
{
/***** Get parameter with code of institution *****/
Gbl.Forum.Ctr.CtrCod = Par_GetParToLong ("ForCtrCod");
Ctr_GetDataOfCentreByCod (&Gbl.Forum.Ctr);
if (Gbl.Forum.Ctr.CtrCod > 0)
Gbl.Forum.Cod = Gbl.Forum.Ctr.CtrCod;
else
{
/***** Get parameter with code of institution *****/
Gbl.Forum.Ins.InsCod = Par_GetParToLong ("ForInsCod");
Ins_GetDataOfInstitutionByCod (&Gbl.Forum.Ins,Ins_GET_BASIC_DATA);
if (Gbl.Forum.Ins.InsCod > 0)
Gbl.Forum.Cod = Gbl.Forum.Ins.InsCod;
}
Gbl.Forum.Ins.InsCod = Par_GetParToLong ("ForInsCod");
Ins_GetDataOfInstitutionByCod (&Gbl.Forum.Ins,Ins_GET_BASIC_DATA);
if (Gbl.Forum.Ins.InsCod > 0)
Gbl.Forum.Cod = Gbl.Forum.Ins.InsCod;
}
}
AlreadyGot = true;
}
/***** Restrict access to forum *****/
For_RestrictAccess ();
}
/*****************************************************************************/
/***************************** Set the type of forum *************************/
/*****************************************************************************/
static void For_SetForumType (void)
{
switch (Gbl.Action.Act)
{
case ActSeeFor:
case ActSeeForGenUsr: case ActSeePstForGenUsr:
case ActRcvThrForGenUsr: case ActRcvRepForGenUsr:
case ActReqDelThrGenUsr: case ActDelThrForGenUsr:
case ActCutThrForGenUsr: case ActPasThrForGenUsr:
case ActDelPstForGenUsr:
case ActEnbPstForGenUsr: case ActDisPstForGenUsr:
Gbl.Forum.Type = For_FORUM_GLOBAL_USRS;
Gbl.Forum.Level = 1;
break;
case ActSeeForGenTch: case ActSeePstForGenTch:
case ActRcvThrForGenTch: case ActRcvRepForGenTch:
case ActReqDelThrGenTch: case ActDelThrForGenTch:
case ActCutThrForGenTch: case ActPasThrForGenTch:
case ActDelPstForGenTch:
case ActEnbPstForGenTch: case ActDisPstForGenTch:
Gbl.Forum.Type = For_FORUM_GLOBAL_TCHS;
Gbl.Forum.Level = 1;
break;
case ActSeeForSWAUsr: case ActSeePstForSWAUsr:
case ActRcvThrForSWAUsr: case ActRcvRepForSWAUsr:
case ActReqDelThrSWAUsr: case ActDelThrForSWAUsr:
case ActCutThrForSWAUsr: case ActPasThrForSWAUsr:
case ActDelPstForSWAUsr:
case ActEnbPstForSWAUsr: case ActDisPstForSWAUsr:
Gbl.Forum.Type = For_FORUM_SWAD_USRS;
Gbl.Forum.Level = 1;
break;
case ActSeeForSWATch: case ActSeePstForSWATch:
case ActRcvThrForSWATch: case ActRcvRepForSWATch:
case ActReqDelThrSWATch: case ActDelThrForSWATch:
case ActCutThrForSWATch: case ActPasThrForSWATch:
case ActDelPstForSWATch:
case ActEnbPstForSWATch: case ActDisPstForSWATch:
Gbl.Forum.Type = For_FORUM_SWAD_TCHS;
Gbl.Forum.Level = 1;
break;
case ActSeeForInsUsr: case ActSeePstForInsUsr:
case ActRcvThrForInsUsr: case ActRcvRepForInsUsr:
case ActReqDelThrInsUsr: case ActDelThrForInsUsr:
case ActCutThrForInsUsr: case ActPasThrForInsUsr:
case ActDelPstForInsUsr:
case ActEnbPstForInsUsr: case ActDisPstForInsUsr:
Gbl.Forum.Type = For_FORUM_INSTIT_USRS;
Gbl.Forum.Level = 1;
break;
case ActSeeForInsTch: case ActSeePstForInsTch:
case ActRcvThrForInsTch: case ActRcvRepForInsTch:
case ActReqDelThrInsTch: case ActDelThrForInsTch:
case ActCutThrForInsTch: case ActPasThrForInsTch:
case ActDelPstForInsTch:
case ActEnbPstForInsTch: case ActDisPstForInsTch:
Gbl.Forum.Type = For_FORUM_INSTIT_TCHS;
Gbl.Forum.Level = 1;
break;
case ActSeeForCtrUsr: case ActSeePstForCtrUsr:
case ActRcvThrForCtrUsr: case ActRcvRepForCtrUsr:
case ActReqDelThrCtrUsr: case ActDelThrForCtrUsr:
case ActCutThrForCtrUsr: case ActPasThrForCtrUsr:
case ActDelPstForCtrUsr:
case ActEnbPstForCtrUsr: case ActDisPstForCtrUsr:
Gbl.Forum.Type = For_FORUM_CENTRE_USRS;
Gbl.Forum.Level = 1;
break;
case ActSeeForCtrTch: case ActSeePstForCtrTch:
case ActRcvThrForCtrTch: case ActRcvRepForCtrTch:
case ActReqDelThrCtrTch: case ActDelThrForCtrTch:
case ActCutThrForCtrTch: case ActPasThrForCtrTch:
case ActDelPstForCtrTch:
case ActEnbPstForCtrTch: case ActDisPstForCtrTch:
Gbl.Forum.Type = For_FORUM_CENTRE_TCHS;
Gbl.Forum.Level = 1;
break;
case ActSeeForDegUsr: case ActSeePstForDegUsr:
case ActRcvThrForDegUsr: case ActRcvRepForDegUsr:
case ActReqDelThrDegUsr: case ActDelThrForDegUsr:
case ActCutThrForDegUsr: case ActPasThrForDegUsr:
case ActDelPstForDegUsr:
case ActEnbPstForDegUsr: case ActDisPstForDegUsr:
Gbl.Forum.Type = For_FORUM_DEGREE_USRS;
Gbl.Forum.Level = 2;
break;
case ActSeeForDegTch: case ActSeePstForDegTch:
case ActRcvThrForDegTch: case ActRcvRepForDegTch:
case ActReqDelThrDegTch: case ActDelThrForDegTch:
case ActCutThrForDegTch: case ActPasThrForDegTch:
case ActDelPstForDegTch:
case ActEnbPstForDegTch: case ActDisPstForDegTch:
Gbl.Forum.Type = For_FORUM_DEGREE_TCHS;
Gbl.Forum.Level = 2;
break;
case ActSeeForCrsUsr: case ActSeePstForCrsUsr:
case ActRcvThrForCrsUsr: case ActRcvRepForCrsUsr:
case ActReqDelThrCrsUsr: case ActDelThrForCrsUsr:
case ActCutThrForCrsUsr: case ActPasThrForCrsUsr:
case ActDelPstForCrsUsr:
case ActEnbPstForCrsUsr: case ActDisPstForCrsUsr:
Gbl.Forum.Type = For_FORUM_COURSE_USRS;
Gbl.Forum.Level = 3;
break;
case ActSeeForCrsTch: case ActSeePstForCrsTch:
case ActRcvThrForCrsTch: case ActRcvRepForCrsTch:
case ActReqDelThrCrsTch: case ActDelThrForCrsTch:
case ActCutThrForCrsTch: case ActPasThrForCrsTch:
case ActDelPstForCrsTch:
case ActEnbPstForCrsTch: case ActDisPstForCrsTch:
Gbl.Forum.Type = For_FORUM_COURSE_TCHS;
Gbl.Forum.Level = 3;
break;
}
}
/*****************************************************************************/
/************************** Restrict access to forum *************************/
/*****************************************************************************/
static void For_RestrictAccess (void)
{
extern const char *Txt_You_dont_have_permission_to_access_to_this_forum;
bool ICanSeeForum = false;
/***** Restrict access *****/
switch (Gbl.Forum.Type)
{
case For_FORUM_COURSE_USRS:
ICanSeeForum = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
Rol_GetMyRoleInCrs (Gbl.Forum.Crs.CrsCod) >= Rol_STUDENT);
break;
case For_FORUM_COURSE_TCHS:
ICanSeeForum = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
Rol_GetMyRoleInCrs (Gbl.Forum.Crs.CrsCod) >= Rol_TEACHER);
break;
case For_FORUM_DEGREE_USRS:
ICanSeeForum = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
Rol_GetMyMaxRoleInDeg (Gbl.Forum.Deg.DegCod) >= Rol_STUDENT);
break;
case For_FORUM_DEGREE_TCHS:
ICanSeeForum = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
Rol_GetMyMaxRoleInDeg (Gbl.Forum.Deg.DegCod) >= Rol_TEACHER);
break;
case For_FORUM_CENTRE_USRS:
ICanSeeForum = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
Rol_GetMyMaxRoleInCtr (Gbl.Forum.Ctr.CtrCod) >= Rol_STUDENT);
break;
case For_FORUM_CENTRE_TCHS:
ICanSeeForum = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
Rol_GetMyMaxRoleInCtr (Gbl.Forum.Ctr.CtrCod) >= Rol_TEACHER);
break;
case For_FORUM_INSTIT_USRS:
ICanSeeForum = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
Rol_GetMyMaxRoleInIns (Gbl.Forum.Ins.InsCod) >= Rol_STUDENT);
break;
case For_FORUM_INSTIT_TCHS:
ICanSeeForum = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
Rol_GetMyMaxRoleInIns (Gbl.Forum.Ins.InsCod) >= Rol_TEACHER);
break;
case For_FORUM_GLOBAL_USRS:
case For_FORUM_SWAD_USRS:
ICanSeeForum = true;
break;
case For_FORUM_GLOBAL_TCHS:
case For_FORUM_SWAD_TCHS:
Rol_GetRolesInAllCrssIfNotYetGot (&Gbl.Usrs.Me.UsrDat);
ICanSeeForum = (Gbl.Usrs.Me.UsrDat.Roles >= (1 << Rol_TEACHER));
break;
}
if (!ICanSeeForum)
Lay_ShowErrorAndExit (Txt_You_dont_have_permission_to_access_to_this_forum);
}
/*****************************************************************************/
@ -3834,19 +3842,6 @@ static long For_GetParamPstCod (void)
return PstCod;
}
/*****************************************************************************/
/******************** Show posts of a thread of the forum ********************/
/*****************************************************************************/
static void For_ShowForumLevel2 (long ThrCod)
{
/***** Show threads *****/
For_ShowForumThreadsHighlightingOneThread (ThrCod);
/***** Show the posts of this thread *****/
For_ShowThreadPosts (ThrCod);
}
/*****************************************************************************/
/********************** Show an area to write a message **********************/
/*****************************************************************************/
@ -3949,12 +3944,9 @@ void For_RecForumPst (void)
char Content[Cns_MAX_BYTES_LONG_TEXT + 1];
struct Image Image;
/***** Get order type, degree and course of the forum *****/
/***** Get parameters related to forum *****/
For_GetParamsForum ();
/***** Set forum type *****/
For_SetForumTypeAndRestrictAccess ();
/***** Get the code of the thread y the número of page *****/
if (Gbl.Action.Act == ActRcvRepForCrsUsr || Gbl.Action.Act == ActRcvRepForCrsTch ||
Gbl.Action.Act == ActRcvRepForDegUsr || Gbl.Action.Act == ActRcvRepForDegTch ||
@ -4056,7 +4048,7 @@ void For_RecForumPst (void)
}
/***** Show again the posts of this thread of the forum *****/
For_ShowForumLevel2 (ThrCod);
For_ShowThreadPosts (ThrCod);
}
/*****************************************************************************/
@ -4090,17 +4082,13 @@ void For_DelPst (void)
struct Image Image;
bool ThreadDeleted = false;
/***** Get parameters *****/
/* Get the code of the message to remove */
PstCod = For_GetParamPstCod ();
/* Get order type, degree and course of the forum */
/***** Get parameters related to forum *****/
For_GetParamsForum ();
/* Set forum type */
For_SetForumTypeAndRestrictAccess ();
/***** Get the code of the message to remove *****/
PstCod = For_GetParamPstCod ();
/* Get the thread number */
/***** Get the thread number *****/
ThrCod = For_GetParamThrCod ();
/***** Initialize image *****/
@ -4156,7 +4144,7 @@ void For_DelPst (void)
Lay_ShowAlert (Lay_SUCCESS,Txt_Post_removed);
/* Show the remaining posts */
For_ShowForumLevel2 (ThrCod);
For_ShowThreadPosts (ThrCod);
}
}
@ -4172,12 +4160,9 @@ void For_ReqDelThr (void)
long ThrCod;
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
/***** Get order type, degree and course of the forum *****/
/***** Get parameters related to forum *****/
For_GetParamsForum ();
/***** Initialize the type of forum *****/
For_SetForumTypeAndRestrictAccess ();
/***** Get the identifier of the thread to remove *****/
ThrCod = For_GetParamThrCod ();
@ -4210,12 +4195,9 @@ void For_DelThr (void)
long ThrCod = -1L;
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
/***** Get order type, degree and course of the forum *****/
/***** Get parameters related to forum *****/
For_GetParamsForum ();
/***** Set forum type *****/
For_SetForumTypeAndRestrictAccess ();
if (PermissionThreadDeletion[Gbl.Forum.Type] & (1 << Gbl.Usrs.Me.LoggedRole)) // If I have permission to remove thread in this forum...
{
/***** Get code of thread to delete *****/
@ -4255,12 +4237,9 @@ void For_CutThr (void)
long ThrCod;
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
/***** Get order type, degree and course of the forum *****/
/***** Get parameters related to forum *****/
For_GetParamsForum ();
/***** Set forum type *****/
For_SetForumTypeAndRestrictAccess ();
/***** Get code of thread to cut *****/
ThrCod = For_GetParamThrCod ();
@ -4295,12 +4274,9 @@ void For_PasteThr (void)
long ThrCod;
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
/***** Get order type, degree and course of the forum *****/
/***** Get parameters related to forum *****/
For_GetParamsForum ();
/***** Set forum type *****/
For_SetForumTypeAndRestrictAccess ();
/***** Get code of thread to paste *****/
ThrCod = For_GetParamThrCod ();

View File

@ -107,8 +107,7 @@ void For_GetSummaryAndContentForumPst (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1
long PstCod,bool GetContent);
void For_PutAllHiddenParamsForum (void);
void For_SetForumTypeAndRestrictAccess (void);
void For_ShowForumList (void);
void For_SetForumName (For_ForumType_t ForumType,
struct Instit *Ins,
struct Centre *Ctr,