");
Not_SetNotCodToEdit (NotCod); // To be used as parameter
Lay_PutContextualLinkOnlyIcon (ActSeeOneNot,Anchor,Not_PutParams,
"ellipsis-h.svg",
Txt_See_full_notice);
HTM_DIV_End ();
}
else
{
fprintf (Gbl.F.Out,"
",TextClass[Status]);
fprintf (Gbl.F.Out,"%s",Content);
HTM_DIV_End ();
}
/***** Write the author *****/
fprintf (Gbl.F.Out,"
", // Limited width
AuthorClass[Status]);
Usr_UsrDataConstructor (&UsrDat);
UsrDat.UsrCod = UsrCod;
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) // Get from the database the data of the autor
Usr_WriteFirstNameBRSurnames (&UsrDat);
Usr_UsrDataDestructor (&UsrDat);
HTM_DIV_End ();
/***** End yellow note *****/
HTM_DIV_End ();
/***** End article for this notice *****/
if (TypeNoticesListing == Not_LIST_FULL_NOTICES)
{
if (Highlight)
HTM_DIV_End ();
Lay_EndArticle ();
}
/***** Free anchor string *****/
Frm_FreeAnchorStr (Anchor);
}
/*****************************************************************************/
/******************* Get summary and content for a notice ********************/
/*****************************************************************************/
void Not_GetSummaryAndContentNotice (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
char **ContentStr,
long NotCod,bool GetContent)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
size_t Length;
SummaryStr[0] = '\0'; // Return nothing on error
// This function may be called inside a web service, so don't report error
/***** Get subject of message from database *****/
if (DB_QuerySELECT (&mysql_res,"can not get content of notice",
"SELECT Content FROM notices WHERE NotCod=%ld",
NotCod) == 1) // Result should have a unique row
{
/***** Get sumary / content *****/
row = mysql_fetch_row (mysql_res);
/***** Copy summary *****/
// TODO: Do only direct copy when a Subject of type VARCHAR(255) is available
if (strlen (row[0]) > Ntf_MAX_BYTES_SUMMARY)
{
strncpy (SummaryStr,row[0],
Ntf_MAX_BYTES_SUMMARY);
SummaryStr[Ntf_MAX_BYTES_SUMMARY] = '\0';
}
else
Str_Copy (SummaryStr,row[0],
Ntf_MAX_BYTES_SUMMARY);
/***** Copy content *****/
if (GetContent)
{
Length = strlen (row[0]);
if ((*ContentStr = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
Str_Copy (*ContentStr,row[0],
Length);
}
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
/*************************** Get number of notices ***************************/
/*****************************************************************************/
// Returns the number of (active or obsolete) notices
// sent from this location (all the platform, current degree or current course)
unsigned Not_GetNumNotices (Hie_Level_t Scope,Not_Status_t Status,unsigned *NumNotif)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumNotices;
/***** Get number of notices from database *****/
switch (Scope)
{
case Hie_SYS:
DB_QuerySELECT (&mysql_res,"can not get number of notices",
"SELECT COUNT(*),SUM(NumNotif)"
" FROM notices"
" WHERE Status=%u",
Status);
break;
case Hie_CTY:
DB_QuerySELECT (&mysql_res,"can not get number of notices",
"SELECT COUNT(*),SUM(notices.NumNotif)"
" FROM institutions,centres,degrees,courses,notices"
" WHERE institutions.CtyCod=%ld"
" AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=notices.CrsCod"
" AND notices.Status=%u",
Gbl.Hierarchy.Cty.CtyCod,
Status);
break;
case Hie_INS:
DB_QuerySELECT (&mysql_res,"can not get number of notices",
"SELECT COUNT(*),SUM(notices.NumNotif)"
" FROM centres,degrees,courses,notices"
" WHERE centres.InsCod=%ld"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=notices.CrsCod"
" AND notices.Status=%u",
Gbl.Hierarchy.Ins.InsCod,
Status);
break;
case Hie_CTR:
DB_QuerySELECT (&mysql_res,"can not get number of notices",
"SELECT COUNT(*),SUM(notices.NumNotif)"
" FROM degrees,courses,notices"
" WHERE degrees.CtrCod=%ld"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=notices.CrsCod"
" AND notices.Status=%u",
Gbl.Hierarchy.Ctr.CtrCod,
Status);
break;
case Hie_DEG:
DB_QuerySELECT (&mysql_res,"can not get number of notices",
"SELECT COUNT(*),SUM(notices.NumNotif)"
" FROM courses,notices"
" WHERE courses.DegCod=%ld"
" AND courses.CrsCod=notices.CrsCod"
" AND notices.Status=%u",
Gbl.Hierarchy.Deg.DegCod,
Status);
break;
case Hie_CRS:
DB_QuerySELECT (&mysql_res,"can not get number of notices",
"SELECT COUNT(*),SUM(NumNotif)"
" FROM notices"
" WHERE CrsCod=%ld"
" AND Status=%u",
Gbl.Hierarchy.Crs.CrsCod,
Status);
break;
default:
Lay_WrongScopeExit ();
break;
}
/***** Get number of notices *****/
row = mysql_fetch_row (mysql_res);
if (sscanf (row[0],"%u",&NumNotices) != 1)
Lay_ShowErrorAndExit ("Error when getting number of notices.");
/***** Get number of notifications by email *****/
if (row[1])
{
if (sscanf (row[1],"%u",NumNotif) != 1)
Lay_ShowErrorAndExit ("Error when getting number of notifications of notices.");
}
else
*NumNotif = 0;
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
return NumNotices;
}
/*****************************************************************************/
/************************ Get number of deleted notices **********************/
/*****************************************************************************/
// Returns the number of deleted notices
// sent from this location (all the platform, current degree or current course)
unsigned Not_GetNumNoticesDeleted (Hie_Level_t Scope,unsigned *NumNotif)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumNotices;
/***** Get number of notices from database *****/
switch (Scope)
{
case Hie_SYS:
DB_QuerySELECT (&mysql_res,"can not get number of deleted notices",
"SELECT COUNT(*),SUM(NumNotif)"
" FROM notices_deleted");
break;
case Hie_CTY:
DB_QuerySELECT (&mysql_res,"can not get number of deleted notices",
"SELECT COUNT(*),SUM(notices_deleted.NumNotif)"
" FROM institutions,centres,degrees,courses,notices_deleted"
" WHERE institutions.CtyCod=%ld"
" AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=notices_deleted.CrsCod",
Gbl.Hierarchy.Cty.CtyCod);
break;
case Hie_INS:
DB_QuerySELECT (&mysql_res,"can not get number of deleted notices",
"SELECT COUNT(*),SUM(notices_deleted.NumNotif)"
" FROM centres,degrees,courses,notices_deleted"
" WHERE centres.InsCod=%ld"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=notices_deleted.CrsCod",
Gbl.Hierarchy.Ins.InsCod);
break;
case Hie_CTR:
DB_QuerySELECT (&mysql_res,"can not get number of deleted notices",
"SELECT COUNT(*),SUM(notices_deleted.NumNotif)"
" FROM degrees,courses,notices_deleted"
" WHERE degrees.CtrCod=%ld"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=notices_deleted.CrsCod",
Gbl.Hierarchy.Ctr.CtrCod);
break;
case Hie_DEG:
DB_QuerySELECT (&mysql_res,"can not get number of deleted notices",
"SELECT COUNT(*),SUM(notices_deleted.NumNotif)"
" FROM courses,notices_deleted"
" WHERE courses.DegCod=%ld"
" AND courses.CrsCod=notices_deleted.CrsCod",
Gbl.Hierarchy.Deg.DegCod);
break;
case Hie_CRS:
DB_QuerySELECT (&mysql_res,"can not get number of deleted notices",
"SELECT COUNT(*),SUM(NumNotif)"
" FROM notices_deleted"
" WHERE CrsCod=%ld",
Gbl.Hierarchy.Crs.CrsCod);
break;
default:
Lay_WrongScopeExit ();
break;
}
/***** Get number of notices *****/
row = mysql_fetch_row (mysql_res);
if (sscanf (row[0],"%u",&NumNotices) != 1)
Lay_ShowErrorAndExit ("Error when getting number of deleted notices.");
/***** Get number of notifications by email *****/
if (row[1])
{
if (sscanf (row[1],"%u",NumNotif) != 1)
Lay_ShowErrorAndExit ("Error when getting number of notifications of deleted notices.");
}
else
*NumNotif = 0;
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
return NumNotices;
}
/*****************************************************************************/
/*************** Put parameter with the code of a notice *********************/
/*****************************************************************************/
static void Not_PutParams (void)
{
Not_PutHiddenParamNotCod (Not_GetNotCodToEdit ());
}
/*****************************************************************************/
/*************** Put parameter with the code of a notice *********************/
/*****************************************************************************/
void Not_PutHiddenParamNotCod (long NotCod)
{
Par_PutHiddenParamLong ("NotCod",NotCod);
}
/*****************************************************************************/
/*************** Get parameter with the code of a notice *********************/
/*****************************************************************************/
static long Not_GetParamNotCod (void)
{
/***** Get notice code *****/
return Par_GetParToLong ("NotCod");
}
/*****************************************************************************/
/********** Set/get code of a notice to be removed/enable/disable ************/
/*****************************************************************************/
static void Not_SetNotCodToEdit (long NotCod)
{
Gbl.Crs.Notices.NotCod = NotCod;
}
static long Not_GetNotCodToEdit (void)
{
return Gbl.Crs.Notices.NotCod;
}