mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-05 00:05:23 +02:00
Version 21.32.2: Oct 13, 2021 Queries moved from RSS to other modules.
This commit is contained in:
parent
f2cc9b600f
commit
14bf9acd64
63
swad_RSS.c
63
swad_RSS.c
|
@ -29,12 +29,13 @@
|
||||||
#include <stddef.h> // For NULL
|
#include <stddef.h> // For NULL
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "swad_call_for_exam.h"
|
#include "swad_call_for_exam_database.h"
|
||||||
#include "swad_changelog.h"
|
#include "swad_changelog.h"
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
#include "swad_error.h"
|
#include "swad_error.h"
|
||||||
#include "swad_global.h"
|
#include "swad_global.h"
|
||||||
#include "swad_notice.h"
|
#include "swad_notice.h"
|
||||||
|
#include "swad_notice_database.h"
|
||||||
#include "swad_RSS.h"
|
#include "swad_RSS.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -78,8 +79,8 @@ void RSS_UpdateRSSFileForACrs (struct Crs_Course *Crs)
|
||||||
Err_ShowErrorAndExit ("Can not create RSS file.");
|
Err_ShowErrorAndExit ("Can not create RSS file.");
|
||||||
|
|
||||||
/***** Write RSS header *****/
|
/***** Write RSS header *****/
|
||||||
fprintf (FileRSS,"<?xml version=\"1.0\" encoding=\"windows-1252\"?>\n");
|
fprintf (FileRSS,"<?xml version=\"1.0\" encoding=\"windows-1252\"?>\n"
|
||||||
fprintf (FileRSS,"<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n");
|
"<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n");
|
||||||
|
|
||||||
/***** Write channel header *****/
|
/***** Write channel header *****/
|
||||||
fprintf (FileRSS,"<channel>\n");
|
fprintf (FileRSS,"<channel>\n");
|
||||||
|
@ -107,9 +108,9 @@ void RSS_UpdateRSSFileForACrs (struct Crs_Course *Crs)
|
||||||
Cfg_PLATFORM_SHORT_NAME,Crs->ShrtName);
|
Cfg_PLATFORM_SHORT_NAME,Crs->ShrtName);
|
||||||
fprintf (FileRSS,"<link>%s/?crs=%ld</link>\n",
|
fprintf (FileRSS,"<link>%s/?crs=%ld</link>\n",
|
||||||
Cfg_URL_SWAD_CGI,Crs->CrsCod);
|
Cfg_URL_SWAD_CGI,Crs->CrsCod);
|
||||||
fprintf (FileRSS,"<width>112</width>\n");
|
fprintf (FileRSS,"<width>112</width>\n"
|
||||||
fprintf (FileRSS,"<height>32</height>\n");
|
"<height>32</height>\n"
|
||||||
fprintf (FileRSS,"</image>\n");
|
"</image>\n");
|
||||||
|
|
||||||
// All date-times in RSS conform to the Date and Time Specification of RFC 822, with the exception that the year may be expressed with two characters or four characters (four preferred)
|
// All date-times in RSS conform to the Date and Time Specification of RFC 822, with the exception that the year may be expressed with two characters or four characters (four preferred)
|
||||||
fprintf (FileRSS,"<pubDate>");
|
fprintf (FileRSS,"<pubDate>");
|
||||||
|
@ -159,22 +160,8 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Crs_Course *Crs)
|
||||||
unsigned NumNot;
|
unsigned NumNot;
|
||||||
char Content[Cns_MAX_BYTES_TEXT + 1];
|
char Content[Cns_MAX_BYTES_TEXT + 1];
|
||||||
|
|
||||||
/***** Get active notices in course *****/
|
/***** Write items with active notices *****/
|
||||||
NumNotices = (unsigned)
|
if ((NumNotices = Not_DB_GetActiveNotices (&mysql_res,Crs->CrsCod)))
|
||||||
DB_QuerySELECT (&mysql_res,"can not get notices from database",
|
|
||||||
"SELECT NotCod," // row[0]
|
|
||||||
"UNIX_TIMESTAMP(CreatTime) AS T," // row[1]
|
|
||||||
"UsrCod," // row[2]
|
|
||||||
"Content" // row[3]
|
|
||||||
" FROM not_notices"
|
|
||||||
" WHERE CrsCod=%ld"
|
|
||||||
" AND Status=%u"
|
|
||||||
" ORDER BY T DESC",
|
|
||||||
Crs->CrsCod,
|
|
||||||
(unsigned) Not_ACTIVE_NOTICE);
|
|
||||||
|
|
||||||
/***** Write items with notices *****/
|
|
||||||
if (NumNotices)
|
|
||||||
{
|
{
|
||||||
Usr_UsrDataConstructor (&UsrDat);
|
Usr_UsrDataConstructor (&UsrDat);
|
||||||
|
|
||||||
|
@ -185,16 +172,16 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Crs_Course *Crs)
|
||||||
/***** Get data of the notice *****/
|
/***** Get data of the notice *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get notice code */
|
/* Get notice code (row[0]) */
|
||||||
if (sscanf (row[0],"%ld",&NotCod) != 1)
|
if (sscanf (row[0],"%ld",&NotCod) != 1)
|
||||||
Err_WrongNoticeExit ();
|
Err_WrongNoticeExit ();
|
||||||
|
|
||||||
/* Get UTC date-time of publication */
|
/* Get UTC date-time of publication (row[1]) */
|
||||||
CreatTimeUTC = 0L;
|
CreatTimeUTC = 0L;
|
||||||
if (row[1])
|
if (row[1])
|
||||||
sscanf (row[1],"%ld",&CreatTimeUTC);
|
sscanf (row[1],"%ld",&CreatTimeUTC);
|
||||||
|
|
||||||
/* Get author */
|
/* Get author (row[2]) */
|
||||||
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[2]);
|
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[2]);
|
||||||
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat, // Get author's data from database
|
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat, // Get author's data from database
|
||||||
Usr_DONT_GET_PREFS,
|
Usr_DONT_GET_PREFS,
|
||||||
|
@ -263,22 +250,8 @@ static void RSS_WriteCallsForExams (FILE *FileRSS,struct Crs_Course *Crs)
|
||||||
|
|
||||||
if (Gbl.DB.DatabaseIsOpen)
|
if (Gbl.DB.DatabaseIsOpen)
|
||||||
{
|
{
|
||||||
/***** Get exam announcements (only future exams) in current course from database *****/
|
/***** Write exam announcements (only future exams) in current course *****/
|
||||||
NumExams = (unsigned)
|
if ((NumExams = Cfe_DB_GetFutureCallsForExamsInCurrentCrs (&mysql_res)))
|
||||||
DB_QuerySELECT (&mysql_res,"can not get calls for exams",
|
|
||||||
"SELECT ExaCod," // row[0]
|
|
||||||
"UNIX_TIMESTAMP(CallDate) AS T," // row[1]
|
|
||||||
"DATE_FORMAT(ExamDate,'%%d/%%m/%%Y %%H:%%i')" // row[2]
|
|
||||||
" FROM cfe_exams"
|
|
||||||
" WHERE CrsCod=%ld"
|
|
||||||
" AND Status=%u"
|
|
||||||
" AND ExamDate>=NOW()"
|
|
||||||
" ORDER BY T",
|
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
|
||||||
(unsigned) Cfe_VISIBLE_CALL_FOR_EXAM);
|
|
||||||
|
|
||||||
/***** Write items with notices *****/
|
|
||||||
if (NumExams)
|
|
||||||
{
|
{
|
||||||
Usr_UsrDataConstructor (&UsrDat);
|
Usr_UsrDataConstructor (&UsrDat);
|
||||||
|
|
||||||
|
@ -289,11 +262,11 @@ static void RSS_WriteCallsForExams (FILE *FileRSS,struct Crs_Course *Crs)
|
||||||
/***** Get data of the call for exam *****/
|
/***** Get data of the call for exam *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get call for exam code */
|
/* Get call for exam code (row[0]) */
|
||||||
if (sscanf (row[0],"%ld",&ExaCod) != 1)
|
if (sscanf (row[0],"%ld",&ExaCod) != 1)
|
||||||
Err_WrongCallForExamExit ();
|
Err_WrongCallForExamExit ();
|
||||||
|
|
||||||
/* Get UTC date-time of publication */
|
/* Get UTC date-time of publication (row[1]) */
|
||||||
CallTimeUTC = 0L;
|
CallTimeUTC = 0L;
|
||||||
if (row[1])
|
if (row[1])
|
||||||
sscanf (row[1],"%ld",&CallTimeUTC);
|
sscanf (row[1],"%ld",&CallTimeUTC);
|
||||||
|
@ -308,8 +281,8 @@ static void RSS_WriteCallsForExams (FILE *FileRSS,struct Crs_Course *Crs)
|
||||||
fprintf (FileRSS,"<link>%s/?crs=%ld</link>\n",
|
fprintf (FileRSS,"<link>%s/?crs=%ld</link>\n",
|
||||||
Cfg_URL_SWAD_CGI,Crs->CrsCod);
|
Cfg_URL_SWAD_CGI,Crs->CrsCod);
|
||||||
|
|
||||||
/* Write full content of the exam announcement */
|
/* Write full content of the exam announcement (row[2]) */
|
||||||
fprintf (FileRSS,"<description><![CDATA[<p><em>Fecha examen: %s</em></p>]]></description>\n",
|
fprintf (FileRSS,"<description><![CDATA[<p><em>Fecha examen: %s</em></p>]]></description>\n", // TODO: Need translation!
|
||||||
row[2]);
|
row[2]);
|
||||||
|
|
||||||
/* Write unique string for this item */
|
/* Write unique string for this item */
|
||||||
|
|
|
@ -143,6 +143,29 @@ unsigned Cfe_DB_GetVisibleCallsForExamsInCurrentCrs (MYSQL_RES **mysql_res)
|
||||||
(unsigned) Cfe_VISIBLE_CALL_FOR_EXAM);
|
(unsigned) Cfe_VISIBLE_CALL_FOR_EXAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******* Get exam announcements (only future exams) in current course ********/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Cfe_DB_GetFutureCallsForExamsInCurrentCrs (MYSQL_RES **mysql_res)
|
||||||
|
{
|
||||||
|
/***** Get exam dates (ordered from older to more recent)
|
||||||
|
of future visible calls for exams
|
||||||
|
in current course from database *****/
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get calls for exams",
|
||||||
|
"SELECT ExaCod," // row[0]
|
||||||
|
"UNIX_TIMESTAMP(CallDate)," // row[1]
|
||||||
|
"DATE_FORMAT(ExamDate,'%%d/%%m/%%Y %%H:%%i')" // row[2]
|
||||||
|
" FROM cfe_exams"
|
||||||
|
" WHERE CrsCod=%ld"
|
||||||
|
" AND Status=%u"
|
||||||
|
" AND ExamDate>=NOW()"
|
||||||
|
" ORDER BY ExamDate",
|
||||||
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
|
(unsigned) Cfe_VISIBLE_CALL_FOR_EXAM);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************** Get data of a call for exam from database *****************/
|
/***************** Get data of a call for exam from database *****************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -41,6 +41,7 @@ long Cfe_DB_CreateCallForExam (const struct Cfe_CallForExam *CallForExam);
|
||||||
|
|
||||||
unsigned Cfe_DB_GetCallsForExamsInCurrentCrs (MYSQL_RES **mysql_res,bool ICanEdit);
|
unsigned Cfe_DB_GetCallsForExamsInCurrentCrs (MYSQL_RES **mysql_res,bool ICanEdit);
|
||||||
unsigned Cfe_DB_GetVisibleCallsForExamsInCurrentCrs (MYSQL_RES **mysql_res);
|
unsigned Cfe_DB_GetVisibleCallsForExamsInCurrentCrs (MYSQL_RES **mysql_res);
|
||||||
|
unsigned Cfe_DB_GetFutureCallsForExamsInCurrentCrs (MYSQL_RES **mysql_res);
|
||||||
unsigned Cfe_DB_GetDataCallForExam (MYSQL_RES **mysql_res,long ExaCod);
|
unsigned Cfe_DB_GetDataCallForExam (MYSQL_RES **mysql_res,long ExaCod);
|
||||||
|
|
||||||
void Cfe_DB_ModifyCallForExam (const struct Cfe_CallForExam *CallForExam,
|
void Cfe_DB_ModifyCallForExam (const struct Cfe_CallForExam *CallForExam,
|
||||||
|
|
|
@ -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.32.1 (2021-10-13)"
|
#define Log_PLATFORM_VERSION "SWAD 21.32.2 (2021-10-13)"
|
||||||
#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.32.2: Oct 13, 2021 Queries moved from RSS to other modules. (319785 lines)
|
||||||
Version 21.32.1: Oct 13, 2021 Queries moved to module swad_role_database. (319787 lines)
|
Version 21.32.1: Oct 13, 2021 Queries moved to module swad_role_database. (319787 lines)
|
||||||
Version 21.32: Oct 13, 2021 New module swad_role_database for database queries related to user roles. (319611 lines)
|
Version 21.32: Oct 13, 2021 New module swad_role_database for database queries related to user roles. (319611 lines)
|
||||||
Version 21.31.2: Oct 13, 2021 Queries moved to module swad_log_database. (319542 lines)
|
Version 21.31.2: Oct 13, 2021 Queries moved to module swad_log_database. (319542 lines)
|
||||||
|
|
|
@ -333,7 +333,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,long HighlightNotCod)
|
||||||
switch (TypeNoticesListing)
|
switch (TypeNoticesListing)
|
||||||
{
|
{
|
||||||
case Not_LIST_BRIEF_NOTICES:
|
case Not_LIST_BRIEF_NOTICES:
|
||||||
NumNotices = Not_DB_GetActiveNotices (&mysql_res);
|
NumNotices = Not_DB_GetActiveNotices (&mysql_res,Gbl.Hierarchy.Crs.CrsCod);
|
||||||
break;
|
break;
|
||||||
case Not_LIST_FULL_NOTICES:
|
case Not_LIST_FULL_NOTICES:
|
||||||
NumNotices = Not_DB_GetAllNotices (&mysql_res);
|
NumNotices = Not_DB_GetAllNotices (&mysql_res);
|
||||||
|
|
|
@ -172,20 +172,20 @@ unsigned Not_DB_GetAllNotices (MYSQL_RES **mysql_res)
|
||||||
/***************************** Get active notices ****************************/
|
/***************************** Get active notices ****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Not_DB_GetActiveNotices (MYSQL_RES **mysql_res)
|
unsigned Not_DB_GetActiveNotices (MYSQL_RES **mysql_res,long CrsCod)
|
||||||
{
|
{
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QuerySELECT (mysql_res,"can not get notices from database",
|
DB_QuerySELECT (mysql_res,"can not get notices from database",
|
||||||
"SELECT NotCod," // row[0]
|
"SELECT NotCod," // row[0]
|
||||||
"UNIX_TIMESTAMP(CreatTime) AS F," // row[1]
|
"UNIX_TIMESTAMP(CreatTime)," // row[1]
|
||||||
"UsrCod," // row[2]
|
"UsrCod," // row[2]
|
||||||
"Content," // row[3]
|
"Content," // row[3]
|
||||||
"Status" // row[4]
|
"Status" // row[4]
|
||||||
" FROM not_notices"
|
" FROM not_notices"
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" AND Status=%u"
|
" AND Status=%u"
|
||||||
" ORDER BY CreatTime DESC",
|
" ORDER BY CreatTime DESC",
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
CrsCod,
|
||||||
(unsigned) Not_ACTIVE_NOTICE);
|
(unsigned) Not_ACTIVE_NOTICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ void Not_DB_UpdateNumUsrsNotifiedByEMailAboutNotice (long NotCod,
|
||||||
unsigned Not_DB_GetDataOfNotice (MYSQL_RES **mysql_res,long NotCod);
|
unsigned Not_DB_GetDataOfNotice (MYSQL_RES **mysql_res,long NotCod);
|
||||||
unsigned Not_DB_ContentNotice (MYSQL_RES **mysql_res,long NotCod);
|
unsigned Not_DB_ContentNotice (MYSQL_RES **mysql_res,long NotCod);
|
||||||
unsigned Not_DB_GetAllNotices (MYSQL_RES **mysql_res);
|
unsigned Not_DB_GetAllNotices (MYSQL_RES **mysql_res);
|
||||||
unsigned Not_DB_GetActiveNotices (MYSQL_RES **mysql_res);
|
unsigned Not_DB_GetActiveNotices (MYSQL_RES **mysql_res,long CrsCod);
|
||||||
unsigned Not_DB_GetNumNotices (MYSQL_RES **mysql_res,
|
unsigned Not_DB_GetNumNotices (MYSQL_RES **mysql_res,
|
||||||
HieLvl_Level_t Scope,Not_Status_t Status);
|
HieLvl_Level_t Scope,Not_Status_t Status);
|
||||||
unsigned Not_DB_GetNumNoticesDeleted (MYSQL_RES **mysql_res,
|
unsigned Not_DB_GetNumNoticesDeleted (MYSQL_RES **mysql_res,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user