Version 21.55.2: Nov 10, 2021 Code refactoring in switch statements (until swad_button.c).

This commit is contained in:
acanas 2021-11-10 00:39:09 +01:00
parent 641208b357
commit fe8168dcf8
19 changed files with 160 additions and 180 deletions

View File

@ -1108,34 +1108,30 @@ static void Acc_RemoveUsrBriefcase (struct UsrData *UsrDat)
void Acc_PutIconToChangeUsrAccount (void) void Acc_PutIconToChangeUsrAccount (void)
{ {
extern const char *Txt_Change_account; extern const char *Txt_Change_account;
Act_Action_t NextAction; static const Act_Action_t NextAction[Rol_NUM_ROLES] =
bool ItsMe = Usr_ItsMe (Gbl.Record.UsrDat->UsrCod); {
[Rol_UNK ] = ActFrmAccOth,
[Rol_GST ] = ActFrmAccOth,
[Rol_USR ] = ActFrmAccOth,
[Rol_STD ] = ActFrmAccStd,
[Rol_NET ] = ActFrmAccTch,
[Rol_TCH ] = ActFrmAccTch,
[Rol_DEG_ADM] = ActFrmAccOth,
[Rol_CTR_ADM] = ActFrmAccOth,
[Rol_INS_ADM] = ActFrmAccOth,
[Rol_SYS_ADM] = ActFrmAccOth,
};
/***** Link for changing the account *****/ /***** Link for changing the account *****/
if (ItsMe) if (Usr_ItsMe (Gbl.Record.UsrDat->UsrCod))
Lay_PutContextualLinkOnlyIcon (ActFrmMyAcc,NULL, Lay_PutContextualLinkOnlyIcon (ActFrmMyAcc,NULL,
NULL,NULL, NULL,NULL,
"at.svg", "at.svg",
Txt_Change_account); Txt_Change_account);
else // Not me else // Not me
if (Usr_ICanEditOtherUsr (Gbl.Record.UsrDat)) if (Usr_ICanEditOtherUsr (Gbl.Record.UsrDat))
{ Lay_PutContextualLinkOnlyIcon (NextAction[Gbl.Record.UsrDat->Roles.InCurrentCrs],NULL,
switch (Gbl.Record.UsrDat->Roles.InCurrentCrs)
{
case Rol_STD:
NextAction = ActFrmAccStd;
break;
case Rol_NET:
case Rol_TCH:
NextAction = ActFrmAccTch;
break;
default: // Guest, user or admin
NextAction = ActFrmAccOth;
break;
}
Lay_PutContextualLinkOnlyIcon (NextAction,NULL,
Rec_PutParamUsrCodEncrypted,NULL, Rec_PutParamUsrCodEncrypted,NULL,
"at.svg", "at.svg",
Txt_Change_account); Txt_Change_account);
}
} }

View File

@ -357,7 +357,7 @@ unsigned Agd_DB_GetNumUsrsWithEvents (HieLvl_Level_t Scope)
"SELECT COUNT(DISTINCT UsrCod)" "SELECT COUNT(DISTINCT UsrCod)"
" FROM agd_agendas" " FROM agd_agendas"
" WHERE UsrCod>0"); " WHERE UsrCod>0");
case HieLvl_CTY: case HieLvl_CTY:
return (unsigned) return (unsigned)
DB_QueryCOUNT ("can not get number of users with events", DB_QueryCOUNT ("can not get number of users with events",
"SELECT COUNT(DISTINCT agd_agendas.UsrCod)" "SELECT COUNT(DISTINCT agd_agendas.UsrCod)"

View File

@ -515,7 +515,7 @@ unsigned Asg_DB_GetNumCoursesWithAssignments (HieLvl_Level_t Scope)
"SELECT COUNT(DISTINCT CrsCod)" "SELECT COUNT(DISTINCT CrsCod)"
" FROM asg_assignments" " FROM asg_assignments"
" WHERE CrsCod>0"); " WHERE CrsCod>0");
case HieLvl_CTY: case HieLvl_CTY:
return (unsigned) return (unsigned)
DB_QueryCOUNT ("can not get number of courses with assignments", DB_QueryCOUNT ("can not get number of courses with assignments",
"SELECT COUNT(DISTINCT asg_assignments.CrsCod)" "SELECT COUNT(DISTINCT asg_assignments.CrsCod)"

View File

@ -1682,7 +1682,6 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
bool Present; bool Present;
char CommentStd[Cns_MAX_BYTES_TEXT + 1]; char CommentStd[Cns_MAX_BYTES_TEXT + 1];
char CommentTch[Cns_MAX_BYTES_TEXT + 1]; char CommentTch[Cns_MAX_BYTES_TEXT + 1];
bool ItsMe;
bool ICanChangeStdAttendance; bool ICanChangeStdAttendance;
bool ICanEditStdComment; bool ICanEditStdComment;
bool ICanEditTchComment; bool ICanEditTchComment;
@ -1692,8 +1691,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
{ {
case Rol_STD: case Rol_STD:
// A student can see only her/his attendance // A student can see only her/his attendance
ItsMe = Usr_ItsMe (UsrDat->UsrCod); if (!Usr_ItsMe (UsrDat->UsrCod))
if (!ItsMe)
Err_ShowErrorAndExit ("Wrong call."); Err_ShowErrorAndExit ("Wrong call.");
ICanChangeStdAttendance = false; ICanChangeStdAttendance = false;
ICanEditStdComment = Event->Open; // Attendance event is open ICanEditStdComment = Event->Open; // Attendance event is open

View File

@ -3223,7 +3223,19 @@ static void Brw_GetSelectedGroupData (struct GroupData *GrpDat,bool AbortOnError
static void Brw_ShowDataOwnerAsgWrk (struct UsrData *UsrDat) static void Brw_ShowDataOwnerAsgWrk (struct UsrData *UsrDat)
{ {
extern const char *Txt_View_record_for_this_course; extern const char *Txt_View_record_for_this_course;
Act_Action_t NextAction; static const Act_Action_t NextAction[Rol_NUM_ROLES] =
{
[Rol_UNK ] = ActUnk,
[Rol_GST ] = ActUnk,
[Rol_USR ] = ActUnk,
[Rol_STD ] = ActSeeRecOneStd,
[Rol_NET ] = ActSeeRecOneTch,
[Rol_TCH ] = ActSeeRecOneTch,
[Rol_DEG_ADM] = ActUnk,
[Rol_CTR_ADM] = ActUnk,
[Rol_INS_ADM] = ActUnk,
[Rol_SYS_ADM] = ActUnk,
};
/***** Show user's photo *****/ /***** Show user's photo *****/
HTM_TD_Begin ("class=\"OWNER_WORKS_PHOTO\""); HTM_TD_Begin ("class=\"OWNER_WORKS_PHOTO\"");
@ -3235,21 +3247,10 @@ static void Brw_ShowDataOwnerAsgWrk (struct UsrData *UsrDat)
HTM_DIV_Begin ("class=\"OWNER_WORKS_DATA AUTHOR_TXT\""); HTM_DIV_Begin ("class=\"OWNER_WORKS_DATA AUTHOR_TXT\"");
switch (UsrDat->Roles.InCurrentCrs) if (NextAction[UsrDat->Roles.InCurrentCrs] == ActUnk)
{ Err_WrongRoleExit ();
case Rol_STD:
NextAction = ActSeeRecOneStd; Frm_BeginForm (NextAction[UsrDat->Roles.InCurrentCrs]);
break;
case Rol_NET:
case Rol_TCH:
NextAction = ActSeeRecOneTch;
break;
default:
NextAction = ActUnk;
Err_WrongRoleExit ();
break;
}
Frm_BeginForm (NextAction);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod); Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
/***** Show user's ID *****/ /***** Show user's ID *****/
@ -8356,24 +8357,24 @@ void Brw_DownloadFile (void)
case Brw_ADMI_DOC_CRS: case Brw_ADMI_DOC_CRS:
case Brw_ADMI_DOC_GRP: case Brw_ADMI_DOC_GRP:
Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_DOCUMENT_FILE, Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_DOCUMENT_FILE,
FileMetadata.FilCod); FileMetadata.FilCod);
break; break;
case Brw_ADMI_TCH_CRS: case Brw_ADMI_TCH_CRS:
case Brw_ADMI_TCH_GRP: case Brw_ADMI_TCH_GRP:
Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_TEACHERS_FILE, Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_TEACHERS_FILE,
FileMetadata.FilCod); FileMetadata.FilCod);
break; break;
case Brw_ADMI_SHR_CRS: case Brw_ADMI_SHR_CRS:
case Brw_ADMI_SHR_GRP: case Brw_ADMI_SHR_GRP:
Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_SHARED_FILE, Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_SHARED_FILE,
FileMetadata.FilCod); FileMetadata.FilCod);
break; break;
case Brw_SHOW_MRK_CRS: case Brw_SHOW_MRK_CRS:
case Brw_SHOW_MRK_GRP: case Brw_SHOW_MRK_GRP:
case Brw_ADMI_MRK_CRS: case Brw_ADMI_MRK_CRS:
case Brw_ADMI_MRK_GRP: case Brw_ADMI_MRK_GRP:
Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_MARKS_FILE, Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_MARKS_FILE,
FileMetadata.FilCod); FileMetadata.FilCod);
break; break;
default: default:
break; break;
@ -9485,14 +9486,11 @@ static bool Brw_CheckIfICanModifyPrivateFileOrFolder (void)
bool Brw_CheckIfICanViewProjectFiles (long PrjCod) bool Brw_CheckIfICanViewProjectFiles (long PrjCod)
{ {
unsigned MyRolesInProject;
switch (Gbl.Usrs.Me.Role.Logged) switch (Gbl.Usrs.Me.Role.Logged)
{ {
case Rol_STD: case Rol_STD:
case Rol_NET: case Rol_NET:
MyRolesInProject = Prj_GetMyRolesInProject (PrjCod); return (Prj_GetMyRolesInProject (PrjCod) != 0); // Am I a member?
return (MyRolesInProject != 0); // Am I a member?
case Rol_TCH: // Editing teachers in a course can access to all files case Rol_TCH: // Editing teachers in a course can access to all files
case Rol_SYS_ADM: case Rol_SYS_ADM:
return true; return true;
@ -9507,14 +9505,11 @@ bool Brw_CheckIfICanViewProjectFiles (long PrjCod)
static bool Brw_CheckIfICanViewProjectDocuments (long PrjCod) static bool Brw_CheckIfICanViewProjectDocuments (long PrjCod)
{ {
unsigned MyRolesInProject;
switch (Gbl.Usrs.Me.Role.Logged) switch (Gbl.Usrs.Me.Role.Logged)
{ {
case Rol_STD: case Rol_STD:
case Rol_NET: case Rol_NET:
MyRolesInProject = Prj_GetMyRolesInProject (PrjCod); return (Prj_GetMyRolesInProject (PrjCod) != 0); // Am I a member?
return (MyRolesInProject != 0); // Am I a member?
case Rol_TCH: // Editing teachers in a course can access to all files case Rol_TCH: // Editing teachers in a course can access to all files
case Rol_SYS_ADM: case Rol_SYS_ADM:
return true; return true;
@ -9530,15 +9525,12 @@ static bool Brw_CheckIfICanViewProjectDocuments (long PrjCod)
static bool Brw_CheckIfICanViewProjectAssessment (long PrjCod) static bool Brw_CheckIfICanViewProjectAssessment (long PrjCod)
{ {
unsigned MyRolesInProject;
switch (Gbl.Usrs.Me.Role.Logged) switch (Gbl.Usrs.Me.Role.Logged)
{ {
case Rol_STD: case Rol_STD:
case Rol_NET: case Rol_NET:
MyRolesInProject = Prj_GetMyRolesInProject (PrjCod); return ((Prj_GetMyRolesInProject (PrjCod) & (1 << Prj_ROLE_TUT | // Tutor...
return ((MyRolesInProject & (1 << Prj_ROLE_TUT | // Tutor... 1 << Prj_ROLE_EVL)) != 0); // ...or evaluator
1 << Prj_ROLE_EVL)) != 0); // ...or evaluator
case Rol_TCH: // Editing teachers in a course can access to all files case Rol_TCH: // Editing teachers in a course can access to all files
case Rol_SYS_ADM: case Rol_SYS_ADM:
return true; return true;
@ -9558,14 +9550,11 @@ static bool Brw_CheckIfICanViewProjectAssessment (long PrjCod)
static bool Brw_CheckIfICanModifyPrjDocFileOrFolder (void) static bool Brw_CheckIfICanModifyPrjDocFileOrFolder (void)
{ {
unsigned MyRolesInProject;
switch (Gbl.Usrs.Me.Role.Logged) switch (Gbl.Usrs.Me.Role.Logged)
{ {
case Rol_STD: case Rol_STD:
case Rol_NET: case Rol_NET:
MyRolesInProject = Prj_GetMyRolesInProject (Prj_GetPrjCod ()); if (Prj_GetMyRolesInProject (Prj_GetPrjCod ())) // I am a member
if (MyRolesInProject) // I am a member
return (Gbl.Usrs.Me.UsrDat.UsrCod == Brw_DB_GetPublisherOfSubtree (Gbl.FileBrowser.FilFolLnk.Full)); // Am I the publisher of subtree? return (Gbl.Usrs.Me.UsrDat.UsrCod == Brw_DB_GetPublisherOfSubtree (Gbl.FileBrowser.FilFolLnk.Full)); // Am I the publisher of subtree?
return false; return false;
case Rol_TCH: // Editing teachers in a course can access to all files case Rol_TCH: // Editing teachers in a course can access to all files
@ -9587,15 +9576,12 @@ static bool Brw_CheckIfICanModifyPrjDocFileOrFolder (void)
static bool Brw_CheckIfICanModifyPrjAssFileOrFolder (void) static bool Brw_CheckIfICanModifyPrjAssFileOrFolder (void)
{ {
unsigned MyRolesInProject;
switch (Gbl.Usrs.Me.Role.Logged) switch (Gbl.Usrs.Me.Role.Logged)
{ {
case Rol_STD: case Rol_STD:
case Rol_NET: case Rol_NET:
MyRolesInProject = Prj_GetMyRolesInProject (Prj_GetPrjCod ()); if ((Prj_GetMyRolesInProject (Prj_GetPrjCod ()) & (1 << Prj_ROLE_TUT | // Tutor...
if ((MyRolesInProject & (1 << Prj_ROLE_TUT | // Tutor... 1 << Prj_ROLE_EVL))) // ...or evaluator
1 << Prj_ROLE_EVL))) // ...or evaluator
return (Gbl.Usrs.Me.UsrDat.UsrCod == Brw_DB_GetPublisherOfSubtree (Gbl.FileBrowser.FilFolLnk.Full)); // Am I the publisher of subtree? return (Gbl.Usrs.Me.UsrDat.UsrCod == Brw_DB_GetPublisherOfSubtree (Gbl.FileBrowser.FilFolLnk.Full)); // Am I the publisher of subtree?
return false; return false;
case Rol_TCH: // Editing teachers in a course can access to all files case Rol_TCH: // Editing teachers in a course can access to all files

View File

@ -35,88 +35,80 @@
void Btn_PutButton (Btn_Button_t Button,const char *TxtButton) void Btn_PutButton (Btn_Button_t Button,const char *TxtButton)
{ {
static void (*Function[Btn_NUM_BUTTON_TYPES]) (const char *TxtButton) =
{
[Btn_NO_BUTTON ] = NULL,
[Btn_CREATE_BUTTON ] = Btn_PutCreateButton,
[Btn_CONFIRM_BUTTON] = Btn_PutConfirmButton,
[Btn_REMOVE_BUTTON ] = Btn_PutRemoveButton,
};
if (TxtButton) if (TxtButton)
if (TxtButton[0]) if (TxtButton[0])
switch (Button) if (Function[Button])
{ Function[Button] (TxtButton);
case Btn_NO_BUTTON:
break;
case Btn_CREATE_BUTTON:
Btn_PutCreateButton (TxtButton);
break;
case Btn_CONFIRM_BUTTON:
Btn_PutConfirmButton (TxtButton);
break;
case Btn_REMOVE_BUTTON:
Btn_PutRemoveButton (TxtButton);
break;
}
} }
void Btn_PutButtonInline (Btn_Button_t Button,const char *TxtButton) void Btn_PutButtonInline (Btn_Button_t Button,const char *TxtButton)
{ {
static void (*Function[Btn_NUM_BUTTON_TYPES]) (const char *TxtButton) =
{
[Btn_NO_BUTTON ] = NULL,
[Btn_CREATE_BUTTON ] = Btn_PutCreateButtonInline,
[Btn_CONFIRM_BUTTON] = Btn_PutConfirmButtonInline,
[Btn_REMOVE_BUTTON ] = Btn_PutRemoveButtonInline,
};
if (TxtButton) if (TxtButton)
if (TxtButton[0]) if (TxtButton[0])
switch (Button) if (Function[Button])
{ Function[Button] (TxtButton);
case Btn_NO_BUTTON:
break;
case Btn_CREATE_BUTTON:
Btn_PutCreateButtonInline (TxtButton);
break;
case Btn_CONFIRM_BUTTON:
Btn_PutConfirmButtonInline (TxtButton);
break;
case Btn_REMOVE_BUTTON:
Btn_PutRemoveButtonInline (TxtButton);
break;
}
} }
void Btn_PutCreateButton (const char *TxtButton) void Btn_PutCreateButton (const char *TxtButton)
{ {
HTM_DIV_Begin ("class=\"CM\""); HTM_DIV_Begin ("class=\"CM\"");
HTM_BUTTON_SUBMIT_Begin (NULL,"BT_SUBMIT BT_CREATE",NULL); HTM_BUTTON_SUBMIT_Begin (NULL,"BT_SUBMIT BT_CREATE",NULL);
HTM_Txt (TxtButton); HTM_Txt (TxtButton);
HTM_BUTTON_End (); HTM_BUTTON_End ();
HTM_DIV_End (); HTM_DIV_End ();
} }
void Btn_PutCreateButtonInline (const char *TxtButton) void Btn_PutCreateButtonInline (const char *TxtButton)
{ {
HTM_BUTTON_SUBMIT_Begin (NULL,"BT_SUBMIT_INLINE BT_CREATE",NULL); HTM_BUTTON_SUBMIT_Begin (NULL,"BT_SUBMIT_INLINE BT_CREATE",NULL);
HTM_Txt (TxtButton); HTM_Txt (TxtButton);
HTM_BUTTON_End (); HTM_BUTTON_End ();
} }
void Btn_PutConfirmButton (const char *TxtButton) void Btn_PutConfirmButton (const char *TxtButton)
{ {
HTM_DIV_Begin ("class=\"CM\""); HTM_DIV_Begin ("class=\"CM\"");
HTM_BUTTON_SUBMIT_Begin (NULL,"BT_SUBMIT BT_CONFIRM",NULL); HTM_BUTTON_SUBMIT_Begin (NULL,"BT_SUBMIT BT_CONFIRM",NULL);
HTM_Txt (TxtButton); HTM_Txt (TxtButton);
HTM_BUTTON_End (); HTM_BUTTON_End ();
HTM_DIV_End (); HTM_DIV_End ();
} }
void Btn_PutConfirmButtonInline (const char *TxtButton) void Btn_PutConfirmButtonInline (const char *TxtButton)
{ {
HTM_BUTTON_SUBMIT_Begin (NULL,"BT_SUBMIT_INLINE BT_CONFIRM",NULL); HTM_BUTTON_SUBMIT_Begin (NULL,"BT_SUBMIT_INLINE BT_CONFIRM",NULL);
HTM_Txt (TxtButton); HTM_Txt (TxtButton);
HTM_BUTTON_End (); HTM_BUTTON_End ();
} }
void Btn_PutRemoveButton (const char *TxtButton) void Btn_PutRemoveButton (const char *TxtButton)
{ {
HTM_DIV_Begin ("class=\"CM\""); HTM_DIV_Begin ("class=\"CM\"");
HTM_BUTTON_SUBMIT_Begin (NULL,"BT_SUBMIT BT_REMOVE",NULL); HTM_BUTTON_SUBMIT_Begin (NULL,"BT_SUBMIT BT_REMOVE",NULL);
HTM_Txt (TxtButton); HTM_Txt (TxtButton);
HTM_BUTTON_End (); HTM_BUTTON_End ();
HTM_DIV_End (); HTM_DIV_End ();
} }
void Btn_PutRemoveButtonInline (const char *TxtButton) void Btn_PutRemoveButtonInline (const char *TxtButton)
{ {
HTM_BUTTON_SUBMIT_Begin (NULL,"BT_SUBMIT_INLINE BT_REMOVE",NULL); HTM_BUTTON_SUBMIT_Begin (NULL,"BT_SUBMIT_INLINE BT_REMOVE",NULL);
HTM_Txt (TxtButton); HTM_Txt (TxtButton);
HTM_BUTTON_End (); HTM_BUTTON_End ();
} }

View File

@ -27,6 +27,7 @@
/********************************* Public types ******************************/ /********************************* Public types ******************************/
/*****************************************************************************/ /*****************************************************************************/
#define Btn_NUM_BUTTON_TYPES 4
typedef enum typedef enum
{ {
Btn_NO_BUTTON, Btn_NO_BUTTON,

View File

@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo. TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
*/ */
#define Log_PLATFORM_VERSION "SWAD 21.55.1 (2021-11-09)" #define Log_PLATFORM_VERSION "SWAD 21.55.2 (2021-11-10)"
#define CSS_FILE "swad20.45.css" #define CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.69.1.js" #define JS_FILE "swad20.69.1.js"
/* /*
TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
Version 21.55.2: Nov 10, 2021 Code refactoring in switch statements (until swad_button.c). (? lines)
Version 21.55.1: Nov 09, 2021 Removed unused comments. (319893 lines) Version 21.55.1: Nov 09, 2021 Removed unused comments. (319893 lines)
Version 21.55: Nov 09, 2021 New module swad_template. Removed unused comments. (320885 lines) Version 21.55: Nov 09, 2021 New module swad_template. Removed unused comments. (320885 lines)
Version 21.54.8: Nov 09, 2021 Queries moved from API module to database modules. (322179 lines) Version 21.54.8: Nov 09, 2021 Queries moved from API module to database modules. (322179 lines)

View File

@ -2234,7 +2234,7 @@ static void Fig_GetAndShowTimelineActivityStats (void)
extern const char *Txt_Total; extern const char *Txt_Total;
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
Tml_Not_NoteType_t NoteType; Tml_Not_Type_t NoteType;
unsigned NumNotes; unsigned NumNotes;
unsigned NumUsrs; unsigned NumUsrs;
unsigned NumUsrsTotal; unsigned NumUsrsTotal;
@ -2257,8 +2257,8 @@ static void Fig_GetAndShowTimelineActivityStats (void)
NumUsrsTotal = Usr_GetTotalNumberOfUsers (); NumUsrsTotal = Usr_GetTotalNumberOfUsers ();
/***** Get total number of timeline notes and users for each note type *****/ /***** Get total number of timeline notes and users for each note type *****/
for (NoteType = (Tml_Not_NoteType_t) 0; for (NoteType = (Tml_Not_Type_t) 0;
NoteType <= (Tml_Not_NoteType_t) (TL_NOT_NUM_NOTE_TYPES - 1); NoteType <= (Tml_Not_Type_t) (TL_NOT_NUM_NOTE_TYPES - 1);
NoteType++) NoteType++)
{ {
/***** Get number of timeline notes and users for this type *****/ /***** Get number of timeline notes and users for this type *****/

View File

@ -495,7 +495,7 @@ static unsigned Tml_ListRecentPubs (struct Tml_Timeline *Timeline,
Not.NotCod == NotCodToHighlight ? "TL_WIDTH TL_SEP TL_NEW_PUB" : Not.NotCod == NotCodToHighlight ? "TL_WIDTH TL_SEP TL_NEW_PUB" :
"TL_WIDTH TL_SEP"); "TL_WIDTH TL_SEP");
Tml_Not_CheckAndWriteNoteWithTopMsg (Timeline,&Not, Tml_Not_CheckAndWriteNoteWithTopMsg (Timeline,&Not,
Tml_Pub_GetTopMessage (Pub->PubType), Tml_Pub_GetTopMessage (Pub->Type),
Pub->PublisherCod); Pub->PublisherCod);
HTM_LI_End (); HTM_LI_End ();
} }

View File

@ -774,7 +774,7 @@ static long Tml_Com_ReceiveComm (void)
/* Insert into publications */ /* Insert into publications */
Pub.NotCod = Not.NotCod; Pub.NotCod = Not.NotCod;
Pub.PublisherCod = Gbl.Usrs.Me.UsrDat.UsrCod; Pub.PublisherCod = Gbl.Usrs.Me.UsrDat.UsrCod;
Pub.PubType = Tml_Pub_COMMENT_TO_NOTE; Pub.Type = Tml_Pub_COMMENT_TO_NOTE;
Tml_Pub_PublishPubInTimeline (&Pub); // Set Pub.PubCod Tml_Pub_PublishPubInTimeline (&Pub); // Set Pub.PubCod
/* Insert comment content in the database */ /* Insert comment content in the database */

View File

@ -50,7 +50,7 @@ static const char *Tml_DB_FieldFav[Tml_Usr_NUM_FAV_SHA] =
[Tml_Usr_FAV_UNF_COMM] = "PubCod", [Tml_Usr_FAV_UNF_COMM] = "PubCod",
[Tml_Usr_SHA_UNS_NOTE] = NULL, // Not used [Tml_Usr_SHA_UNS_NOTE] = NULL, // Not used
}; };
static Tml_Pub_PubType_t Tml_DB_PubTypeFav[Tml_Usr_NUM_FAV_SHA] = static Tml_Pub_Type_t Tml_DB_PubTypeFav[Tml_Usr_NUM_FAV_SHA] =
{ {
[Tml_Usr_FAV_UNF_NOTE] = Tml_Pub_ORIGINAL_NOTE, [Tml_Usr_FAV_UNF_NOTE] = Tml_Pub_ORIGINAL_NOTE,
[Tml_Usr_FAV_UNF_COMM] = Tml_Pub_COMMENT_TO_NOTE, [Tml_Usr_FAV_UNF_COMM] = Tml_Pub_COMMENT_TO_NOTE,
@ -144,7 +144,7 @@ long Tml_DB_GetPubCodOfOriginalNote (long NotCod)
/*****************************************************************************/ /*****************************************************************************/
// Returns code of note just created // Returns code of note just created
long Tml_DB_CreateNewNote (Tml_Not_NoteType_t NoteType,long Cod, long Tml_DB_CreateNewNote (Tml_Not_Type_t NoteType,long Cod,
long PublisherCod,long HieCod) long PublisherCod,long HieCod)
{ {
return return
@ -165,7 +165,7 @@ long Tml_DB_CreateNewNote (Tml_Not_NoteType_t NoteType,long Cod,
/************************* Mark a note as unavailable ************************/ /************************* Mark a note as unavailable ************************/
/*****************************************************************************/ /*****************************************************************************/
void Tml_DB_MarkNoteAsUnavailable (Tml_Not_NoteType_t NoteType,long Cod) void Tml_DB_MarkNoteAsUnavailable (Tml_Not_Type_t NoteType,long Cod)
{ {
DB_QueryUPDATE ("can not mark note as unavailable", DB_QueryUPDATE ("can not mark note as unavailable",
"UPDATE tml_notes" "UPDATE tml_notes"
@ -180,7 +180,7 @@ void Tml_DB_MarkNoteAsUnavailable (Tml_Not_NoteType_t NoteType,long Cod)
/***** Mark possible notes involving children of a folder as unavailable *****/ /***** Mark possible notes involving children of a folder as unavailable *****/
/*****************************************************************************/ /*****************************************************************************/
void Tml_DB_MarkNotesChildrenOfFolderAsUnavailable (Tml_Not_NoteType_t NoteType, void Tml_DB_MarkNotesChildrenOfFolderAsUnavailable (Tml_Not_Type_t NoteType,
Brw_FileBrowser_t FileBrowser, Brw_FileBrowser_t FileBrowser,
long Cod,const char *Path) long Cod,const char *Path)
{ {
@ -205,7 +205,7 @@ void Tml_DB_MarkNotesChildrenOfFolderAsUnavailable (Tml_Not_NoteType_t NoteType,
/*****************************************************************************/ /*****************************************************************************/
unsigned Tml_DB_GetNumNotesAndUsrsByType (MYSQL_RES **mysql_res, unsigned Tml_DB_GetNumNotesAndUsrsByType (MYSQL_RES **mysql_res,
Tml_Not_NoteType_t NoteType) Tml_Not_Type_t NoteType)
{ {
switch (Gbl.Scope.Current) switch (Gbl.Scope.Current)
{ {
@ -1097,7 +1097,7 @@ long Tml_DB_CreateNewPub (const struct Tml_Pub_Publication *Pub)
" (%ld,%ld,%u,NOW())", " (%ld,%ld,%u,NOW())",
Pub->NotCod, Pub->NotCod,
Pub->PublisherCod, Pub->PublisherCod,
(unsigned) Pub->PubType); (unsigned) Pub->Type);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -46,15 +46,15 @@ void Tml_DB_UpdateWho (Usr_Who_t Who);
/*********************************** Notes ***********************************/ /*********************************** Notes ***********************************/
unsigned Tml_DB_GetDataOfNoteByCod (long NotCod,MYSQL_RES **mysql_res); unsigned Tml_DB_GetDataOfNoteByCod (long NotCod,MYSQL_RES **mysql_res);
long Tml_DB_GetPubCodOfOriginalNote (long NotCod); long Tml_DB_GetPubCodOfOriginalNote (long NotCod);
long Tml_DB_CreateNewNote (Tml_Not_NoteType_t NoteType,long Cod, long Tml_DB_CreateNewNote (Tml_Not_Type_t NoteType,long Cod,
long PublisherCod,long HieCod); long PublisherCod,long HieCod);
void Tml_DB_MarkNoteAsUnavailable (Tml_Not_NoteType_t NoteType,long Cod); void Tml_DB_MarkNoteAsUnavailable (Tml_Not_Type_t NoteType,long Cod);
void Tml_DB_MarkNotesChildrenOfFolderAsUnavailable (Tml_Not_NoteType_t NoteType, void Tml_DB_MarkNotesChildrenOfFolderAsUnavailable (Tml_Not_Type_t NoteType,
Brw_FileBrowser_t FileBrowser, Brw_FileBrowser_t FileBrowser,
long Cod,const char *Path); long Cod,const char *Path);
unsigned Tml_DB_GetNumNotesAndUsrsByType (MYSQL_RES **mysql_res, unsigned Tml_DB_GetNumNotesAndUsrsByType (MYSQL_RES **mysql_res,
Tml_Not_NoteType_t NoteType); Tml_Not_Type_t NoteType);
unsigned Tml_DB_GetNumNotesAndUsrsTotal (MYSQL_RES **mysql_res); unsigned Tml_DB_GetNumNotesAndUsrsTotal (MYSQL_RES **mysql_res);
void Tml_DB_CreateTmpTableJustRetrievedNotes (void); void Tml_DB_CreateTmpTableJustRetrievedNotes (void);

View File

@ -98,7 +98,7 @@ static void Tml_Not_RemoveNoteMediaAndDBEntries (struct Tml_Not_Note *Not);
static void Tml_Not_GetDataOfNoteFromRow (MYSQL_ROW row,struct Tml_Not_Note *Not); static void Tml_Not_GetDataOfNoteFromRow (MYSQL_ROW row,struct Tml_Not_Note *Not);
static Tml_Not_NoteType_t Tml_Not_GetNoteTypeFromStr (const char *Str); static Tml_Not_Type_t Tml_Not_GetNoteTypeFromStr (const char *Str);
static void Tml_Not_ResetNote (struct Tml_Not_Note *Not); static void Tml_Not_ResetNote (struct Tml_Not_Note *Not);
@ -218,7 +218,7 @@ void Tml_Not_CheckAndWriteNoteWithTopMsg (const struct Tml_Timeline *Timeline,
/***** Trivial check: codes *****/ /***** Trivial check: codes *****/
if (Not->NotCod <= 0 || if (Not->NotCod <= 0 ||
Not->UsrCod <= 0 || Not->UsrCod <= 0 ||
Not->NoteType == TL_NOTE_UNKNOWN) Not->Type == TL_NOTE_UNKNOWN)
{ {
Ale_ShowAlert (Ale_ERROR,"Error in note."); Ale_ShowAlert (Ale_ERROR,"Error in note.");
return; return;
@ -370,7 +370,7 @@ void Tml_Not_WriteAuthorName (const struct UsrData *UsrDat,
static void Tml_Not_WriteContent (const struct Tml_Not_Note *Not) static void Tml_Not_WriteContent (const struct Tml_Not_Note *Not)
{ {
if (Not->NoteType == TL_NOTE_POST) // It's a post if (Not->Type == TL_NOTE_POST) // It's a post
Tml_Pst_GetAndWritePost (Not->Cod); Tml_Pst_GetAndWritePost (Not->Cod);
else // Not a post else // Not a post
Tml_Not_GetAndWriteNoPost (Not); Tml_Not_GetAndWriteNoPost (Not);
@ -428,7 +428,7 @@ static void Tml_Not_GetLocationInHierarchy (const struct Tml_Not_Note *Not,
Hie->Crs.CrsCod = -1L; Hie->Crs.CrsCod = -1L;
/***** Get location in hierarchy *****/ /***** Get location in hierarchy *****/
switch (Not->NoteType) switch (Not->Type)
{ {
case TL_NOTE_INS_DOC_PUB_FILE: case TL_NOTE_INS_DOC_PUB_FILE:
case TL_NOTE_INS_SHA_PUB_FILE: case TL_NOTE_INS_SHA_PUB_FILE:
@ -486,7 +486,7 @@ static void Tml_Not_WriteLocationInHierarchy (const struct Tml_Not_Note *Not,
HTM_DIV_Begin ("class=\"TL_LOC\""); HTM_DIV_Begin ("class=\"TL_LOC\"");
/***** Write location *****/ /***** Write location *****/
switch (Not->NoteType) switch (Not->Type)
{ {
case TL_NOTE_INS_DOC_PUB_FILE: case TL_NOTE_INS_DOC_PUB_FILE:
case TL_NOTE_INS_SHA_PUB_FILE: case TL_NOTE_INS_SHA_PUB_FILE:
@ -605,7 +605,7 @@ static void Tml_Not_PutFormGoToAction (const struct Tml_Not_Note *Not,
HTM_DIV_Begin ("class=\"TL_FORM_OFF\""); HTM_DIV_Begin ("class=\"TL_FORM_OFF\"");
/* Text ("not available") */ /* Text ("not available") */
HTM_Txt (Txt_TIMELINE_NOTE[Not->NoteType]); HTM_Txt (Txt_TIMELINE_NOTE[Not->Type]);
if (Not->Unavailable) if (Not->Unavailable)
HTM_TxtF ("&nbsp;(%s)",Txt_not_available); HTM_TxtF ("&nbsp;(%s)",Txt_not_available);
@ -618,39 +618,39 @@ static void Tml_Not_PutFormGoToAction (const struct Tml_Not_Note *Not,
HTM_DIV_Begin ("class=\"TL_FORM\""); HTM_DIV_Begin ("class=\"TL_FORM\"");
/***** Begin form with parameters depending on the type of note *****/ /***** Begin form with parameters depending on the type of note *****/
switch (Not->NoteType) switch (Not->Type)
{ {
case TL_NOTE_INS_DOC_PUB_FILE: case TL_NOTE_INS_DOC_PUB_FILE:
case TL_NOTE_INS_SHA_PUB_FILE: case TL_NOTE_INS_SHA_PUB_FILE:
Frm_BeginFormUnique (TL_DefaultActions[Not->NoteType]); Frm_BeginFormUnique (TL_DefaultActions[Not->Type]);
Brw_PutHiddenParamFilCod (Not->Cod); Brw_PutHiddenParamFilCod (Not->Cod);
if (Not->HieCod != Gbl.Hierarchy.Ins.InsCod) // Not the current institution if (Not->HieCod != Gbl.Hierarchy.Ins.InsCod) // Not the current institution
Ins_PutParamInsCod (Not->HieCod); // Go to another institution Ins_PutParamInsCod (Not->HieCod); // Go to another institution
break; break;
case TL_NOTE_CTR_DOC_PUB_FILE: case TL_NOTE_CTR_DOC_PUB_FILE:
case TL_NOTE_CTR_SHA_PUB_FILE: case TL_NOTE_CTR_SHA_PUB_FILE:
Frm_BeginFormUnique (TL_DefaultActions[Not->NoteType]); Frm_BeginFormUnique (TL_DefaultActions[Not->Type]);
Brw_PutHiddenParamFilCod (Not->Cod); Brw_PutHiddenParamFilCod (Not->Cod);
if (Not->HieCod != Gbl.Hierarchy.Ctr.CtrCod) // Not the current center if (Not->HieCod != Gbl.Hierarchy.Ctr.CtrCod) // Not the current center
Ctr_PutParamCtrCod (Not->HieCod); // Go to another center Ctr_PutParamCtrCod (Not->HieCod); // Go to another center
break; break;
case TL_NOTE_DEG_DOC_PUB_FILE: case TL_NOTE_DEG_DOC_PUB_FILE:
case TL_NOTE_DEG_SHA_PUB_FILE: case TL_NOTE_DEG_SHA_PUB_FILE:
Frm_BeginFormUnique (TL_DefaultActions[Not->NoteType]); Frm_BeginFormUnique (TL_DefaultActions[Not->Type]);
Brw_PutHiddenParamFilCod (Not->Cod); Brw_PutHiddenParamFilCod (Not->Cod);
if (Not->HieCod != Gbl.Hierarchy.Deg.DegCod) // Not the current degree if (Not->HieCod != Gbl.Hierarchy.Deg.DegCod) // Not the current degree
Deg_PutParamDegCod (Not->HieCod); // Go to another degree Deg_PutParamDegCod (Not->HieCod); // Go to another degree
break; break;
case TL_NOTE_CRS_DOC_PUB_FILE: case TL_NOTE_CRS_DOC_PUB_FILE:
case TL_NOTE_CRS_SHA_PUB_FILE: case TL_NOTE_CRS_SHA_PUB_FILE:
Frm_BeginFormUnique (TL_DefaultActions[Not->NoteType]); Frm_BeginFormUnique (TL_DefaultActions[Not->Type]);
Brw_PutHiddenParamFilCod (Not->Cod); Brw_PutHiddenParamFilCod (Not->Cod);
if (Not->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course if (Not->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course
Crs_PutParamCrsCod (Not->HieCod); // Go to another course Crs_PutParamCrsCod (Not->HieCod); // Go to another course
break; break;
case TL_NOTE_CALL_FOR_EXAM: case TL_NOTE_CALL_FOR_EXAM:
Frm_SetAnchorStr (Not->Cod,&Anchor); Frm_SetAnchorStr (Not->Cod,&Anchor);
Frm_BeginFormUniqueAnchor (TL_DefaultActions[Not->NoteType], Frm_BeginFormUniqueAnchor (TL_DefaultActions[Not->Type],
Anchor); // Locate on this specific exam Anchor); // Locate on this specific exam
Frm_FreeAnchorStr (Anchor); Frm_FreeAnchorStr (Anchor);
Cfe_PutHiddenParamExaCod (Not->Cod); Cfe_PutHiddenParamExaCod (Not->Cod);
@ -673,7 +673,7 @@ static void Tml_Not_PutFormGoToAction (const struct Tml_Not_Note *Not,
break; break;
case TL_NOTE_NOTICE: case TL_NOTE_NOTICE:
Frm_SetAnchorStr (Not->Cod,&Anchor); Frm_SetAnchorStr (Not->Cod,&Anchor);
Frm_BeginFormUniqueAnchor (TL_DefaultActions[Not->NoteType], Frm_BeginFormUniqueAnchor (TL_DefaultActions[Not->Type],
Anchor); Anchor);
Frm_FreeAnchorStr (Anchor); Frm_FreeAnchorStr (Anchor);
Not_PutHiddenParamNotCod (Not->Cod); Not_PutHiddenParamNotCod (Not->Cod);
@ -686,16 +686,16 @@ static void Tml_Not_PutFormGoToAction (const struct Tml_Not_Note *Not,
/***** Icon and link to go to action *****/ /***** Icon and link to go to action *****/
/* Begin button */ /* Begin button */
HTM_BUTTON_SUBMIT_Begin (Txt_TIMELINE_NOTE[Not->NoteType], HTM_BUTTON_SUBMIT_Begin (Txt_TIMELINE_NOTE[Not->Type],
Str_BuildStringStr ("BT_LINK %s ICO_HIGHLIGHT", Str_BuildStringStr ("BT_LINK %s ICO_HIGHLIGHT",
The_ClassFormInBoxBold[Gbl.Prefs.Theme]), The_ClassFormInBoxBold[Gbl.Prefs.Theme]),
NULL); NULL);
Str_FreeString (); Str_FreeString ();
/* Icon and text */ /* Icon and text */
Ico_PutIcon (TL_Icons[Not->NoteType], Ico_PutIcon (TL_Icons[Not->Type],
Txt_TIMELINE_NOTE[Not->NoteType],"CONTEXT_ICO_x16"); Txt_TIMELINE_NOTE[Not->Type],"CONTEXT_ICO_x16");
HTM_TxtF ("&nbsp;%s",Txt_TIMELINE_NOTE[Not->NoteType]); HTM_TxtF ("&nbsp;%s",Txt_TIMELINE_NOTE[Not->Type]);
/* End button */ /* End button */
HTM_BUTTON_End (); HTM_BUTTON_End ();
@ -717,7 +717,7 @@ void Tml_Not_GetNoteSummary (const struct Tml_Not_Note *Not,
{ {
SummaryStr[0] = '\0'; SummaryStr[0] = '\0';
switch (Not->NoteType) switch (Not->Type)
{ {
case TL_NOTE_UNKNOWN: case TL_NOTE_UNKNOWN:
break; break;
@ -878,14 +878,14 @@ static void Tml_Not_PutFormToRemoveNote (const struct Tml_Timeline *Timeline,
/***************** Store and publish a note into database ********************/ /***************** Store and publish a note into database ********************/
/*****************************************************************************/ /*****************************************************************************/
void Tml_Not_StoreAndPublishNote (Tml_Not_NoteType_t NoteType,long Cod) void Tml_Not_StoreAndPublishNote (Tml_Not_Type_t NoteType,long Cod)
{ {
struct Tml_Pub_Publication Pub; struct Tml_Pub_Publication Pub;
Tml_Not_StoreAndPublishNoteInternal (NoteType,Cod,&Pub); Tml_Not_StoreAndPublishNoteInternal (NoteType,Cod,&Pub);
} }
void Tml_Not_StoreAndPublishNoteInternal (Tml_Not_NoteType_t NoteType,long Cod, void Tml_Not_StoreAndPublishNoteInternal (Tml_Not_Type_t NoteType,long Cod,
struct Tml_Pub_Publication *Pub) struct Tml_Pub_Publication *Pub)
{ {
long HieCod; // Hierarchy code (institution/center/degree/course) long HieCod; // Hierarchy code (institution/center/degree/course)
@ -918,7 +918,7 @@ void Tml_Not_StoreAndPublishNoteInternal (Tml_Not_NoteType_t NoteType,long Cod,
/***** Publish note in timeline *****/ /***** Publish note in timeline *****/
Pub->PublisherCod = Gbl.Usrs.Me.UsrDat.UsrCod; Pub->PublisherCod = Gbl.Usrs.Me.UsrDat.UsrCod;
Pub->NotCod = Tml_DB_CreateNewNote (NoteType,Cod,Pub->PublisherCod,HieCod); Pub->NotCod = Tml_DB_CreateNewNote (NoteType,Cod,Pub->PublisherCod,HieCod);
Pub->PubType = Tml_Pub_ORIGINAL_NOTE; Pub->Type = Tml_Pub_ORIGINAL_NOTE;
Tml_Pub_PublishPubInTimeline (Pub); Tml_Pub_PublishPubInTimeline (Pub);
} }
@ -931,7 +931,7 @@ void Tml_Not_MarkNoteOneFileAsUnavailable (const char *Path)
extern const Brw_FileBrowser_t Brw_DB_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER]; extern const Brw_FileBrowser_t Brw_DB_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
Brw_FileBrowser_t FileBrowser = Brw_DB_FileBrowserForDB_files[Gbl.FileBrowser.Type]; Brw_FileBrowser_t FileBrowser = Brw_DB_FileBrowserForDB_files[Gbl.FileBrowser.Type];
long FilCod; long FilCod;
Tml_Not_NoteType_t NoteType; Tml_Not_Type_t NoteType;
switch (FileBrowser) switch (FileBrowser)
{ {
@ -993,7 +993,7 @@ void Tml_Not_MarkNotesChildrenOfFolderAsUnavailable (const char *Path)
{ {
extern const Brw_FileBrowser_t Brw_DB_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER]; extern const Brw_FileBrowser_t Brw_DB_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
Brw_FileBrowser_t FileBrowser = Brw_DB_FileBrowserForDB_files[Gbl.FileBrowser.Type]; Brw_FileBrowser_t FileBrowser = Brw_DB_FileBrowserForDB_files[Gbl.FileBrowser.Type];
Tml_Not_NoteType_t NoteType; Tml_Not_Type_t NoteType;
switch (FileBrowser) switch (FileBrowser)
{ {
@ -1268,7 +1268,7 @@ static void Tml_Not_RemoveNoteMediaAndDBEntries (struct Tml_Not_Note *Not)
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
/***** Remove media associated to post *****/ /***** Remove media associated to post *****/
if (Not->NoteType == TL_NOTE_POST) if (Not->Type == TL_NOTE_POST)
if ((MedCod = Tml_DB_GetMedCodFromPost (Not->Cod)) > 0) if ((MedCod = Tml_DB_GetMedCodFromPost (Not->Cod)) > 0)
Med_RemoveMedia (MedCod); Med_RemoveMedia (MedCod);
@ -1291,7 +1291,7 @@ static void Tml_Not_RemoveNoteMediaAndDBEntries (struct Tml_Not_Note *Not)
/***** Remove note *****/ /***** Remove note *****/
Tml_DB_RemoveNote (Not->NotCod); Tml_DB_RemoveNote (Not->NotCod);
if (Not->NoteType == TL_NOTE_POST) if (Not->Type == TL_NOTE_POST)
/***** Remove post *****/ /***** Remove post *****/
Tml_DB_RemovePost (Not->Cod); Tml_DB_RemovePost (Not->Cod);
} }
@ -1315,7 +1315,7 @@ static void Tml_Not_GetDataOfNoteFromRow (MYSQL_ROW row,struct Tml_Not_Note *Not
Not->NotCod = Str_ConvertStrCodToLongCod (row[0]); Not->NotCod = Str_ConvertStrCodToLongCod (row[0]);
/***** Get note type (row[1]) *****/ /***** Get note type (row[1]) *****/
Not->NoteType = Tml_Not_GetNoteTypeFromStr (row[1]); Not->Type = Tml_Not_GetNoteTypeFromStr (row[1]);
/***** Get file/post... code (row[2]) *****/ /***** Get file/post... code (row[2]) *****/
Not->Cod = Str_ConvertStrCodToLongCod (row[2]); Not->Cod = Str_ConvertStrCodToLongCod (row[2]);
@ -1344,13 +1344,13 @@ static void Tml_Not_GetDataOfNoteFromRow (MYSQL_ROW row,struct Tml_Not_Note *Not
/********* Get note type from string number coming from database *************/ /********* Get note type from string number coming from database *************/
/*****************************************************************************/ /*****************************************************************************/
static Tml_Not_NoteType_t Tml_Not_GetNoteTypeFromStr (const char *Str) static Tml_Not_Type_t Tml_Not_GetNoteTypeFromStr (const char *Str)
{ {
unsigned UnsignedNum; unsigned UnsignedNum;
if (sscanf (Str,"%u",&UnsignedNum) == 1) if (sscanf (Str,"%u",&UnsignedNum) == 1)
if (UnsignedNum < TL_NOT_NUM_NOTE_TYPES) if (UnsignedNum < TL_NOT_NUM_NOTE_TYPES)
return (Tml_Not_NoteType_t) UnsignedNum; return (Tml_Not_Type_t) UnsignedNum;
return TL_NOTE_UNKNOWN; return TL_NOTE_UNKNOWN;
} }
@ -1362,7 +1362,7 @@ static Tml_Not_NoteType_t Tml_Not_GetNoteTypeFromStr (const char *Str)
static void Tml_Not_ResetNote (struct Tml_Not_Note *Not) static void Tml_Not_ResetNote (struct Tml_Not_Note *Not)
{ {
Not->NotCod = -1L; Not->NotCod = -1L;
Not->NoteType = TL_NOTE_UNKNOWN; Not->Type = TL_NOTE_UNKNOWN;
Not->UsrCod = -1L; Not->UsrCod = -1L;
Not->HieCod = -1L; Not->HieCod = -1L;
Not->Cod = -1L; Not->Cod = -1L;

View File

@ -61,19 +61,25 @@ typedef enum
TL_NOTE_FORUM_POST = 11, // Post in global/swad forums TL_NOTE_FORUM_POST = 11, // Post in global/swad forums
/* Analytics tab */ /* Analytics tab */
/* Profile tab */ /* Profile tab */
} Tml_Not_NoteType_t; } Tml_Not_Type_t;
struct Tml_Not_Note struct Tml_Not_Note
{ {
long NotCod; // Unique code/identifier for each note long NotCod; // Unique code/identifier for each note
Tml_Not_NoteType_t NoteType; // Timeline post, public file, exam announcement, notice, forum post... Tml_Not_Type_t Type; // Timeline post, public file,
long UsrCod; // Publisher // call for exam, notice, forum post...
long HieCod; // Hierarchy code (institution/center/degree/course) long UsrCod; // Publisher
long Cod; // Code of file, forum post, notice, timeline post... long HieCod; // Hierarchy code
bool Unavailable; // File, forum post, notice,... unavailable (removed) // (institution/center/degree/course)
time_t DateTimeUTC; // Date-time of publication in UTC time long Cod; // Code of file, forum post,
unsigned NumShared; // Number of times (users) this note has been shared // notice, timeline post...
unsigned NumFavs; // Number of times (users) this note has been favourited bool Unavailable; // File, forum post, notice,...
// unavailable (removed)
time_t DateTimeUTC; // Date-time of publication in UTC time
unsigned NumShared; // Number of times (users)
// this note has been shared
unsigned NumFavs; // Number of times (users)
// this note has been favourited
}; };
/*****************************************************************************/ /*****************************************************************************/
@ -94,8 +100,8 @@ void Tml_Not_WriteAuthorName (const struct UsrData *UsrDat,
void Tml_Not_GetNoteSummary (const struct Tml_Not_Note *Not, void Tml_Not_GetNoteSummary (const struct Tml_Not_Note *Not,
char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1]); char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1]);
void Tml_Not_StoreAndPublishNote (Tml_Not_NoteType_t NoteType,long Cod); void Tml_Not_StoreAndPublishNote (Tml_Not_Type_t NoteType,long Cod);
void Tml_Not_StoreAndPublishNoteInternal (Tml_Not_NoteType_t NoteType,long Cod, void Tml_Not_StoreAndPublishNoteInternal (Tml_Not_Type_t NoteType,long Cod,
struct Tml_Pub_Publication *Pub); struct Tml_Pub_Publication *Pub);
void Tml_Not_MarkNoteOneFileAsUnavailable (const char *Path); void Tml_Not_MarkNoteOneFileAsUnavailable (const char *Path);
void Tml_Not_MarkNotesChildrenOfFolderAsUnavailable (const char *Path); void Tml_Not_MarkNotesChildrenOfFolderAsUnavailable (const char *Path);

View File

@ -101,7 +101,7 @@ void Tml_Ntf_GetNotifPublication (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
bool ContentCopied = false; bool ContentCopied = false;
/***** Return nothing on error *****/ /***** Return nothing on error *****/
Pub.PubType = Tml_Pub_UNKNOWN; Pub.Type = Tml_Pub_UNKNOWN;
SummaryStr[0] = '\0'; // Return nothing on error SummaryStr[0] = '\0'; // Return nothing on error
Content.Txt[0] = '\0'; Content.Txt[0] = '\0';
@ -114,7 +114,7 @@ void Tml_Ntf_GetNotifPublication (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
/***** Get summary and content *****/ /***** Get summary and content *****/
switch (Pub.PubType) switch (Pub.Type)
{ {
case Tml_Pub_UNKNOWN: case Tml_Pub_UNKNOWN:
break; break;
@ -124,7 +124,7 @@ void Tml_Ntf_GetNotifPublication (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
Not.NotCod = Pub.NotCod; Not.NotCod = Pub.NotCod;
Tml_Not_GetDataOfNoteByCod (&Not); Tml_Not_GetDataOfNoteByCod (&Not);
if (Not.NoteType == TL_NOTE_POST) if (Not.Type == TL_NOTE_POST)
{ {
/***** Get post from database *****/ /***** Get post from database *****/
if (Tml_DB_GetPostByCod (Not.Cod,&mysql_res) == 1) // Result should have a unique row if (Tml_DB_GetPostByCod (Not.Cod,&mysql_res) == 1) // Result should have a unique row

View File

@ -58,7 +58,7 @@ static void Tml_Pub_UpdateFirstLastPubCodesIntoSession (const struct Tml_Timelin
static struct Tml_Pub_Publication *Tml_Pub_SelectTheMostRecentPub (const struct Tml_Pub_SubQueries *SubQueries); static struct Tml_Pub_Publication *Tml_Pub_SelectTheMostRecentPub (const struct Tml_Pub_SubQueries *SubQueries);
static Tml_Pub_PubType_t Tml_Pub_GetPubTypeFromStr (const char *Str); static Tml_Pub_Type_t Tml_Pub_GetPubTypeFromStr (const char *Str);
/*****************************************************************************/ /*****************************************************************************/
/*************** Get list of pubications to show in timeline *****************/ /*************** Get list of pubications to show in timeline *****************/
@ -358,7 +358,7 @@ void Tml_Pub_InsertNewPubsInTimeline (struct Tml_Timeline *Timeline)
Not.NotCod); // ...from JavaScript... Not.NotCod); // ...from JavaScript...
// ...to avoid repeating notes // ...to avoid repeating notes
Tml_Not_CheckAndWriteNoteWithTopMsg (Timeline,&Not, Tml_Not_CheckAndWriteNoteWithTopMsg (Timeline,&Not,
Tml_Pub_GetTopMessage (Pub->PubType), Tml_Pub_GetTopMessage (Pub->Type),
Pub->PublisherCod); Pub->PublisherCod);
HTM_LI_End (); HTM_LI_End ();
} }
@ -386,7 +386,7 @@ void Tml_Pub_ShowOldPubsInTimeline (struct Tml_Timeline *Timeline)
/* Write note */ /* Write note */
HTM_LI_Begin ("class=\"TL_WIDTH TL_SEP\""); HTM_LI_Begin ("class=\"TL_WIDTH TL_SEP\"");
Tml_Not_CheckAndWriteNoteWithTopMsg (Timeline,&Not, Tml_Not_CheckAndWriteNoteWithTopMsg (Timeline,&Not,
Tml_Pub_GetTopMessage (Pub->PubType), Tml_Pub_GetTopMessage (Pub->Type),
Pub->PublisherCod); Pub->PublisherCod);
HTM_LI_End (); HTM_LI_End ();
} }
@ -396,7 +396,7 @@ void Tml_Pub_ShowOldPubsInTimeline (struct Tml_Timeline *Timeline)
/************* Get a top message given the type of publication ***************/ /************* Get a top message given the type of publication ***************/
/*****************************************************************************/ /*****************************************************************************/
Tml_TopMessage_t Tml_Pub_GetTopMessage (Tml_Pub_PubType_t PubType) Tml_TopMessage_t Tml_Pub_GetTopMessage (Tml_Pub_Type_t PubType)
{ {
static const Tml_TopMessage_t TopMessages[Tml_Pub_NUM_PUB_TYPES] = static const Tml_TopMessage_t TopMessages[Tml_Pub_NUM_PUB_TYPES] =
{ {
@ -523,21 +523,21 @@ void Tml_Pub_GetDataOfPubFromNextRow (MYSQL_RES *mysql_res,
Pub->PubCod = Str_ConvertStrCodToLongCod (row[0]); Pub->PubCod = Str_ConvertStrCodToLongCod (row[0]);
Pub->NotCod = Str_ConvertStrCodToLongCod (row[1]); Pub->NotCod = Str_ConvertStrCodToLongCod (row[1]);
Pub->PublisherCod = Str_ConvertStrCodToLongCod (row[2]); Pub->PublisherCod = Str_ConvertStrCodToLongCod (row[2]);
Pub->PubType = Tml_Pub_GetPubTypeFromStr (row[3]); Pub->Type = Tml_Pub_GetPubTypeFromStr (row[3]);
} }
/*****************************************************************************/ /*****************************************************************************/
/******* Get publication type from string number coming from database ********/ /******* Get publication type from string number coming from database ********/
/*****************************************************************************/ /*****************************************************************************/
static Tml_Pub_PubType_t Tml_Pub_GetPubTypeFromStr (const char *Str) static Tml_Pub_Type_t Tml_Pub_GetPubTypeFromStr (const char *Str)
{ {
unsigned UnsignedNum; unsigned UnsignedNum;
/***** Get publication type from string *****/ /***** Get publication type from string *****/
if (sscanf (Str,"%u",&UnsignedNum) == 1) if (sscanf (Str,"%u",&UnsignedNum) == 1)
if (UnsignedNum < Tml_Pub_NUM_PUB_TYPES) if (UnsignedNum < Tml_Pub_NUM_PUB_TYPES)
return (Tml_Pub_PubType_t) UnsignedNum; return (Tml_Pub_Type_t) UnsignedNum;
return Tml_Pub_UNKNOWN; return Tml_Pub_UNKNOWN;
} }

View File

@ -51,17 +51,17 @@
typedef enum typedef enum
{ {
Tml_Pub_UNKNOWN = 0, Tml_Pub_UNKNOWN = 0,
Tml_Pub_ORIGINAL_NOTE = 1, Tml_Pub_ORIGINAL_NOTE = 1,
Tml_Pub_SHARED_NOTE = 2, Tml_Pub_SHARED_NOTE = 2,
Tml_Pub_COMMENT_TO_NOTE = 3, Tml_Pub_COMMENT_TO_NOTE = 3,
} Tml_Pub_PubType_t; } Tml_Pub_Type_t;
struct Tml_Pub_Publication struct Tml_Pub_Publication
{ {
long PubCod; long PubCod; // Publication code
long NotCod; long NotCod; // Note code
long PublisherCod; // Sharer or writer of the publication long PublisherCod; // Sharer or writer of the publication
Tml_Pub_PubType_t PubType; Tml_Pub_Type_t Type; // Original note, shared note, comment
struct Tml_Pub_Publication *Next; // Used for chained list struct Tml_Pub_Publication *Next; // Used for chained list
}; };
@ -91,7 +91,7 @@ void Tml_Pub_FreeListPubs (struct Tml_Timeline *Timeline);
void Tml_Pub_InsertNewPubsInTimeline (struct Tml_Timeline *Timeline); void Tml_Pub_InsertNewPubsInTimeline (struct Tml_Timeline *Timeline);
void Tml_Pub_ShowOldPubsInTimeline (struct Tml_Timeline *Timeline); void Tml_Pub_ShowOldPubsInTimeline (struct Tml_Timeline *Timeline);
Tml_TopMessage_t Tml_Pub_GetTopMessage (Tml_Pub_PubType_t PubType); Tml_TopMessage_t Tml_Pub_GetTopMessage (Tml_Pub_Type_t PubType);
void Tml_Pub_PutLinkToViewNewPubs (void); void Tml_Pub_PutLinkToViewNewPubs (void);
void Tml_Pub_PutLinkToViewOldPubs (void); void Tml_Pub_PutLinkToViewOldPubs (void);

View File

@ -121,7 +121,7 @@ static void Tml_Sha_ShaNote (struct Tml_Not_Note *Not)
/***** Share (publish note in timeline) *****/ /***** Share (publish note in timeline) *****/
Pub.NotCod = Not->NotCod; Pub.NotCod = Not->NotCod;
Pub.PublisherCod = Gbl.Usrs.Me.UsrDat.UsrCod; Pub.PublisherCod = Gbl.Usrs.Me.UsrDat.UsrCod;
Pub.PubType = Tml_Pub_SHARED_NOTE; Pub.Type = Tml_Pub_SHARED_NOTE;
Tml_Pub_PublishPubInTimeline (&Pub); // Set Pub.PubCod Tml_Pub_PublishPubInTimeline (&Pub); // Set Pub.PubCod
/***** Update number of times this note is shared *****/ /***** Update number of times this note is shared *****/