2021-09-30 23:17:41 +02:00
|
|
|
|
// swad_notice_database.c: notices (yellow notes) operations with database
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
|
|
|
|
This file is part of SWAD core.
|
2024-02-07 00:40:28 +01:00
|
|
|
|
Copyright (C) 1999-2024 Antonio Ca<EFBFBD>as Vargas
|
2021-09-30 23:17:41 +02:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************************* Headers ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "swad_database.h"
|
|
|
|
|
#include "swad_error.h"
|
|
|
|
|
#include "swad_global.h"
|
|
|
|
|
#include "swad_notice.h"
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Insert a notice in the table of notices *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Return the code of the new inserted notice
|
|
|
|
|
|
|
|
|
|
long Not_DB_InsertNotice (const char *Content)
|
|
|
|
|
{
|
|
|
|
|
return
|
|
|
|
|
DB_QueryINSERTandReturnCode ("can not create notice",
|
|
|
|
|
"INSERT INTO not_notices"
|
|
|
|
|
" (CrsCod,UsrCod,CreatTime,Content,Status)"
|
|
|
|
|
" VALUES"
|
|
|
|
|
" (%ld,%ld,NOW(),'%s',%u)",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod,
|
2021-09-30 23:17:41 +02:00
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
|
|
|
Content,
|
|
|
|
|
(unsigned) Not_ACTIVE_NOTICE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Mark as active/hidden a notice ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Not_DB_ChangeNoticeStatus (long NotCod,Not_Status_t Status)
|
|
|
|
|
{
|
|
|
|
|
DB_QueryUPDATE ("can not reveal notice",
|
|
|
|
|
"UPDATE not_notices"
|
|
|
|
|
" SET Status=%u"
|
|
|
|
|
" WHERE NotCod=%ld"
|
|
|
|
|
" AND CrsCod=%ld",
|
|
|
|
|
(unsigned) Status,
|
|
|
|
|
NotCod,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2021-09-30 23:17:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Copy notice to table of deleted notices ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Not_DB_CopyNoticeToDeleted (long NotCod)
|
|
|
|
|
{
|
|
|
|
|
DB_QueryINSERT ("can not remove notice",
|
|
|
|
|
"INSERT IGNORE INTO not_deleted"
|
|
|
|
|
" (NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif)"
|
|
|
|
|
" SELECT NotCod,"
|
|
|
|
|
"CrsCod,"
|
|
|
|
|
"UsrCod,"
|
|
|
|
|
"CreatTime,"
|
|
|
|
|
"Content,"
|
|
|
|
|
"NumNotif"
|
|
|
|
|
" FROM not_notices"
|
|
|
|
|
" WHERE NotCod=%ld"
|
|
|
|
|
" AND CrsCod=%ld", // Extra check
|
|
|
|
|
NotCod,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2021-09-30 23:17:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********** Update number of users notified in table of notices *************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Not_DB_UpdateNumUsrsNotifiedByEMailAboutNotice (long NotCod,
|
|
|
|
|
unsigned NumUsrsToBeNotifiedByEMail)
|
|
|
|
|
{
|
|
|
|
|
DB_QueryUPDATE ("can not update the number of notifications of a notice",
|
|
|
|
|
"UPDATE not_notices"
|
|
|
|
|
" SET NumNotif=%u"
|
|
|
|
|
" WHERE NotCod=%ld",
|
|
|
|
|
NumUsrsToBeNotifiedByEMail,
|
|
|
|
|
NotCod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Get data of a notice ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-23 09:35:20 +01:00
|
|
|
|
unsigned Not_DB_GetNoticeData (MYSQL_RES **mysql_res,long NotCod)
|
2021-09-30 23:17:41 +02:00
|
|
|
|
{
|
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get notice from database",
|
2023-03-23 18:06:03 +01:00
|
|
|
|
"SELECT NotCod," // row[0]
|
|
|
|
|
"UNIX_TIMESTAMP(CreatTime) AS F," // row[1]
|
|
|
|
|
"UsrCod," // row[2]
|
|
|
|
|
"Content," // row[3]
|
|
|
|
|
"Status" // row[4]
|
2021-09-30 23:17:41 +02:00
|
|
|
|
" FROM not_notices"
|
|
|
|
|
" WHERE NotCod=%ld"
|
|
|
|
|
" AND CrsCod=%ld", // Extra check
|
|
|
|
|
NotCod,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2021-09-30 23:17:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Get content of message from database ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Not_DB_ContentNotice (MYSQL_RES **mysql_res,long NotCod)
|
|
|
|
|
{
|
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get content of notice",
|
|
|
|
|
"SELECT Content" // row[0]
|
|
|
|
|
" FROM not_notices"
|
|
|
|
|
" WHERE NotCod=%ld",
|
|
|
|
|
NotCod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Get all notices *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Not_DB_GetAllNotices (MYSQL_RES **mysql_res)
|
|
|
|
|
{
|
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get notices from database",
|
|
|
|
|
"SELECT NotCod," // row[0]
|
|
|
|
|
"UNIX_TIMESTAMP(CreatTime) AS F," // row[1]
|
|
|
|
|
"UsrCod," // row[2]
|
|
|
|
|
"Content," // row[3]
|
|
|
|
|
"Status" // row[4]
|
|
|
|
|
" FROM not_notices"
|
|
|
|
|
" WHERE CrsCod=%ld"
|
|
|
|
|
" ORDER BY CreatTime DESC",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2021-09-30 23:17:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Get active notices ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-10-13 23:34:10 +02:00
|
|
|
|
unsigned Not_DB_GetActiveNotices (MYSQL_RES **mysql_res,long CrsCod)
|
2021-09-30 23:17:41 +02:00
|
|
|
|
{
|
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get notices from database",
|
2021-10-13 23:34:10 +02:00
|
|
|
|
"SELECT NotCod," // row[0]
|
|
|
|
|
"UNIX_TIMESTAMP(CreatTime)," // row[1]
|
|
|
|
|
"UsrCod," // row[2]
|
|
|
|
|
"Content," // row[3]
|
|
|
|
|
"Status" // row[4]
|
2021-09-30 23:17:41 +02:00
|
|
|
|
" FROM not_notices"
|
|
|
|
|
" WHERE CrsCod=%ld"
|
|
|
|
|
" AND Status=%u"
|
|
|
|
|
" ORDER BY CreatTime DESC",
|
2021-10-13 23:34:10 +02:00
|
|
|
|
CrsCod,
|
2021-09-30 23:17:41 +02:00
|
|
|
|
(unsigned) Not_ACTIVE_NOTICE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Get number of notices ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Not_DB_GetNumNotices (MYSQL_RES **mysql_res,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Hie_Level_t Level,Not_Status_t Status)
|
2021-09-30 23:17:41 +02:00
|
|
|
|
{
|
2023-07-11 19:12:24 +02:00
|
|
|
|
switch (Level)
|
2021-09-30 23:17:41 +02:00
|
|
|
|
{
|
2023-09-22 14:47:56 +02:00
|
|
|
|
case Hie_SYS:
|
2021-09-30 23:17:41 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get number of notices",
|
|
|
|
|
"SELECT COUNT(*)," // row[0]
|
|
|
|
|
"SUM(NumNotif)" // row[1]
|
|
|
|
|
" FROM not_notices"
|
|
|
|
|
" WHERE Status=%u",
|
|
|
|
|
Status);
|
2023-09-22 14:47:56 +02:00
|
|
|
|
case Hie_CTY:
|
2021-09-30 23:17:41 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get number of notices",
|
|
|
|
|
"SELECT COUNT(*)," // row[0]
|
|
|
|
|
"SUM(not_notices.NumNotif)" // row[1]
|
|
|
|
|
" FROM ins_instits,"
|
|
|
|
|
"ctr_centers,"
|
|
|
|
|
"deg_degrees,"
|
|
|
|
|
"crs_courses,"
|
|
|
|
|
"not_notices"
|
|
|
|
|
" WHERE ins_instits.CtyCod=%ld"
|
|
|
|
|
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
|
|
|
|
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
|
|
|
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
|
|
|
|
" AND crs_courses.CrsCod=not_notices.CrsCod"
|
|
|
|
|
" AND not_notices.Status=%u",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CTY].HieCod,
|
2021-09-30 23:17:41 +02:00
|
|
|
|
Status);
|
2023-09-22 14:47:56 +02:00
|
|
|
|
case Hie_INS:
|
2021-09-30 23:17:41 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get number of notices",
|
|
|
|
|
"SELECT COUNT(*)," // row[0]
|
|
|
|
|
"SUM(not_notices.NumNotif)" // row[1]
|
|
|
|
|
" FROM ctr_centers,"
|
|
|
|
|
"deg_degrees,"
|
|
|
|
|
"crs_courses,"
|
|
|
|
|
"not_notices"
|
|
|
|
|
" WHERE ctr_centers.InsCod=%ld"
|
|
|
|
|
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
|
|
|
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
|
|
|
|
" AND crs_courses.CrsCod=not_notices.CrsCod"
|
|
|
|
|
" AND not_notices.Status=%u",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_INS].HieCod,
|
2021-09-30 23:17:41 +02:00
|
|
|
|
Status);
|
2023-09-22 14:47:56 +02:00
|
|
|
|
case Hie_CTR:
|
2021-09-30 23:17:41 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get number of notices",
|
|
|
|
|
"SELECT COUNT(*)," // row[0]
|
|
|
|
|
"SUM(not_notices.NumNotif)" // row[1]
|
|
|
|
|
" FROM deg_degrees,"
|
|
|
|
|
"crs_courses,"
|
|
|
|
|
"not_notices"
|
|
|
|
|
" WHERE deg_degrees.CtrCod=%ld"
|
|
|
|
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
|
|
|
|
" AND crs_courses.CrsCod=not_notices.CrsCod"
|
|
|
|
|
" AND not_notices.Status=%u",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CTR].HieCod,
|
2021-09-30 23:17:41 +02:00
|
|
|
|
Status);
|
2023-09-22 14:47:56 +02:00
|
|
|
|
case Hie_DEG:
|
2021-09-30 23:17:41 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get number of notices",
|
|
|
|
|
"SELECT COUNT(*)," // row[0]
|
|
|
|
|
"SUM(not_notices.NumNotif)" // row[1]
|
|
|
|
|
" FROM crs_courses,"
|
|
|
|
|
"not_notices"
|
|
|
|
|
" WHERE crs_courses.DegCod=%ld"
|
|
|
|
|
" AND crs_courses.CrsCod=not_notices.CrsCod"
|
|
|
|
|
" AND not_notices.Status=%u",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_DEG].HieCod,
|
2021-09-30 23:17:41 +02:00
|
|
|
|
Status);
|
2023-09-22 14:47:56 +02:00
|
|
|
|
case Hie_CRS:
|
2021-09-30 23:17:41 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get number of notices",
|
|
|
|
|
"SELECT COUNT(*)," // row[0]
|
|
|
|
|
"SUM(NumNotif)" // row[1]
|
|
|
|
|
" FROM not_notices"
|
|
|
|
|
" WHERE CrsCod=%ld"
|
|
|
|
|
" AND Status=%u",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod,
|
2021-09-30 23:17:41 +02:00
|
|
|
|
Status);
|
|
|
|
|
default:
|
2023-07-11 19:12:24 +02:00
|
|
|
|
Err_WrongHierarchyLevelExit ();
|
2021-09-30 23:17:41 +02:00
|
|
|
|
return 0; // Not reached
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Get number of deleted notices ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Not_DB_GetNumNoticesDeleted (MYSQL_RES **mysql_res,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Hie_Level_t Level)
|
2021-09-30 23:17:41 +02:00
|
|
|
|
{
|
2023-07-11 19:12:24 +02:00
|
|
|
|
switch (Level)
|
2021-09-30 23:17:41 +02:00
|
|
|
|
{
|
2023-09-22 14:47:56 +02:00
|
|
|
|
case Hie_SYS:
|
2021-09-30 23:17:41 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get number of deleted notices",
|
|
|
|
|
"SELECT COUNT(*)," // row[0]
|
|
|
|
|
"SUM(NumNotif)" // row[1]
|
|
|
|
|
" FROM not_deleted");
|
2023-09-22 14:47:56 +02:00
|
|
|
|
case Hie_CTY:
|
2021-09-30 23:17:41 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get number of deleted notices",
|
|
|
|
|
"SELECT COUNT(*)," // row[0]
|
|
|
|
|
"SUM(not_deleted.NumNotif)" // row[1]
|
|
|
|
|
" FROM ins_instits,"
|
|
|
|
|
"ctr_centers,"
|
|
|
|
|
"deg_degrees,"
|
|
|
|
|
"crs_courses,"
|
|
|
|
|
"not_deleted"
|
|
|
|
|
" WHERE ins_instits.CtyCod=%ld"
|
|
|
|
|
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
|
|
|
|
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
|
|
|
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
|
|
|
|
" AND crs_courses.CrsCod=not_deleted.CrsCod",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CTY].HieCod);
|
|
|
|
|
case Hie_INS:
|
2021-09-30 23:17:41 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get number of deleted notices",
|
|
|
|
|
"SELECT COUNT(*)," // row[0]
|
|
|
|
|
"SUM(not_deleted.NumNotif)" // row[1]
|
|
|
|
|
" FROM ctr_centers,"
|
|
|
|
|
"deg_degrees,"
|
|
|
|
|
"crs_courses,"
|
|
|
|
|
"not_deleted"
|
|
|
|
|
" WHERE ctr_centers.InsCod=%ld"
|
|
|
|
|
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
|
|
|
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
|
|
|
|
" AND crs_courses.CrsCod=not_deleted.CrsCod",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_INS].HieCod);
|
|
|
|
|
case Hie_CTR:
|
2021-09-30 23:17:41 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get number of deleted notices",
|
|
|
|
|
"SELECT COUNT(*)," // row[0]
|
|
|
|
|
"SUM(not_deleted.NumNotif)" // row[1]
|
|
|
|
|
" FROM deg_degrees,"
|
|
|
|
|
"crs_courses,"
|
|
|
|
|
"not_deleted"
|
|
|
|
|
" WHERE deg_degrees.CtrCod=%ld"
|
|
|
|
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
|
|
|
|
" AND crs_courses.CrsCod=not_deleted.CrsCod",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CTR].HieCod);
|
|
|
|
|
case Hie_DEG:
|
2021-09-30 23:17:41 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get number of deleted notices",
|
|
|
|
|
"SELECT COUNT(*)," // row[0]
|
|
|
|
|
"SUM(not_deleted.NumNotif)" // row[1]
|
|
|
|
|
" FROM crs_courses,"
|
|
|
|
|
"not_deleted"
|
|
|
|
|
" WHERE crs_courses.DegCod=%ld"
|
|
|
|
|
" AND crs_courses.CrsCod=not_deleted.CrsCod",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_DEG].HieCod);
|
|
|
|
|
case Hie_CRS:
|
2021-09-30 23:17:41 +02:00
|
|
|
|
return (unsigned)
|
|
|
|
|
DB_QuerySELECT (mysql_res,"can not get number of deleted notices",
|
|
|
|
|
"SELECT COUNT(*)," // row[0]
|
|
|
|
|
"SUM(NumNotif)" // row[1]
|
|
|
|
|
" FROM not_deleted"
|
|
|
|
|
" WHERE CrsCod=%ld",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2021-09-30 23:17:41 +02:00
|
|
|
|
default:
|
2023-07-11 19:12:24 +02:00
|
|
|
|
Err_WrongHierarchyLevelExit ();
|
2021-09-30 23:17:41 +02:00
|
|
|
|
return 0; // Not reached
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************** Remove notice ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Not_DB_RemoveNotice (long NotCod)
|
|
|
|
|
{
|
|
|
|
|
DB_QueryDELETE ("can not remove notice",
|
|
|
|
|
"DELETE FROM not_notices"
|
|
|
|
|
" WHERE NotCod=%ld"
|
|
|
|
|
" AND CrsCod=%ld", // Extra check
|
|
|
|
|
NotCod,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].HieCod);
|
2021-09-30 23:17:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Remove notices in a course ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2024-02-09 00:22:59 +01:00
|
|
|
|
void Not_DB_RemoveCrsNotices (long HieCod)
|
2021-09-30 23:17:41 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Copy all notices from the course to table of deleted notices *****/
|
|
|
|
|
DB_QueryINSERT ("can not remove notices in a course",
|
|
|
|
|
"INSERT INTO not_deleted"
|
|
|
|
|
" (NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif)"
|
|
|
|
|
" SELECT NotCod,"
|
|
|
|
|
"CrsCod,"
|
|
|
|
|
"UsrCod,"
|
|
|
|
|
"CreatTime,"
|
|
|
|
|
"Content,"
|
|
|
|
|
"NumNotif"
|
|
|
|
|
" FROM not_notices"
|
|
|
|
|
" WHERE CrsCod=%ld",
|
2024-02-09 00:22:59 +01:00
|
|
|
|
HieCod);
|
2021-09-30 23:17:41 +02:00
|
|
|
|
|
|
|
|
|
/***** Remove all notices from the course *****/
|
|
|
|
|
DB_QueryDELETE ("can not remove notices in a course",
|
|
|
|
|
"DELETE FROM not_notices"
|
|
|
|
|
" WHERE CrsCod=%ld",
|
2024-02-09 00:22:59 +01:00
|
|
|
|
HieCod);
|
2021-09-30 23:17:41 +02:00
|
|
|
|
}
|