2016-07-07 00:21:10 +02:00
|
|
|
|
// swad_agenda.c: user's agenda (personal organizer)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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.
|
2018-04-24 13:21:53 +02:00
|
|
|
|
Copyright (C) 1999-2018 Antonio Ca<EFBFBD>as Vargas
|
2016-07-07 00:21:10 +02:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General 3 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/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/********************************* Headers ***********************************/
|
2016-07-07 00:21:10 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-11-30 22:49:48 +01:00
|
|
|
|
#include <linux/limits.h> // For PATH_MAX
|
|
|
|
|
#include <linux/stddef.h> // For NULL
|
|
|
|
|
#include <stdlib.h> // For calloc
|
|
|
|
|
#include <string.h> // For string functions
|
2016-07-07 00:21:10 +02:00
|
|
|
|
|
2016-11-30 22:49:48 +01:00
|
|
|
|
#include "swad_agenda.h"
|
2017-06-10 21:38:10 +02:00
|
|
|
|
#include "swad_box.h"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
#include "swad_database.h"
|
|
|
|
|
#include "swad_global.h"
|
|
|
|
|
#include "swad_group.h"
|
|
|
|
|
#include "swad_notification.h"
|
|
|
|
|
#include "swad_pagination.h"
|
|
|
|
|
#include "swad_parameter.h"
|
|
|
|
|
#include "swad_photo.h"
|
2016-12-09 14:50:21 +01:00
|
|
|
|
#include "swad_privacy.h"
|
2016-12-05 09:50:35 +01:00
|
|
|
|
#include "swad_QR.h"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
#include "swad_string.h"
|
2017-06-11 20:09:59 +02:00
|
|
|
|
#include "swad_table.h"
|
2016-07-07 00:21:10 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/************** External global variables from others modules ****************/
|
2016-07-07 00:21:10 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-11-30 22:49:48 +01:00
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
2016-07-07 00:21:10 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private constants *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-21 14:36:22 +01:00
|
|
|
|
static const char *ParamPast__FutureName = "Past__Future";
|
|
|
|
|
static const char *ParamPrivatPublicName = "PrivatPublic";
|
|
|
|
|
static const char *ParamHiddenVisiblName = "HiddenVisibl";
|
|
|
|
|
|
2016-07-07 00:21:10 +02:00
|
|
|
|
/*****************************************************************************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/******************************* Private types *******************************/
|
2016-07-07 00:21:10 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-21 14:52:07 +01:00
|
|
|
|
#define Agd_NUM_AGENDA_TYPES 4
|
2016-12-02 00:24:16 +01:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
2017-03-21 14:52:07 +01:00
|
|
|
|
Agd_MY_AGENDA_TODAY,
|
|
|
|
|
Agd_MY_AGENDA,
|
|
|
|
|
Agd_ANOTHER_AGENDA_TODAY,
|
|
|
|
|
Agd_ANOTHER_AGENDA,
|
2016-12-02 00:24:16 +01:00
|
|
|
|
} Agd_AgendaType_t;
|
|
|
|
|
|
2016-07-07 00:21:10 +02:00
|
|
|
|
/*****************************************************************************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/***************************** Private variables *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-07-07 00:21:10 +02:00
|
|
|
|
/*****************************************************************************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-21 14:36:22 +01:00
|
|
|
|
static void Agd_ShowFormToSelPast__FutureEvents (void);
|
|
|
|
|
static void Agd_ShowFormToSelPrivatPublicEvents (void);
|
|
|
|
|
static void Agd_ShowFormToSelHiddenVisiblEvents (void);
|
|
|
|
|
|
|
|
|
|
static void Agd_PutHiddenParamPast__FutureEvents (unsigned Past__FutureEvents);
|
|
|
|
|
static void Agd_PutHiddenParamPrivatPublicEvents (unsigned PrivatPublicEvents);
|
|
|
|
|
static void Agd_PutHiddenParamHiddenVisiblEvents (unsigned HiddenVisiblEvents);
|
|
|
|
|
static void Agd_GetParamsPast__FutureEvents (void);
|
|
|
|
|
static void Agd_GetParamsPrivatPublicEvents (void);
|
|
|
|
|
static void Agd_GetParamsHiddenVisiblEvents (void);
|
2017-03-21 00:57:11 +01:00
|
|
|
|
|
2016-12-02 00:24:16 +01:00
|
|
|
|
static void Agd_ShowEvents (Agd_AgendaType_t AgendaType);
|
2016-12-06 21:08:28 +01:00
|
|
|
|
static void Agd_ShowEventsToday (Agd_AgendaType_t AgendaType);
|
2016-12-06 03:10:06 +01:00
|
|
|
|
static void Agd_WriteHeaderListEvents (Agd_AgendaType_t AgendaType);
|
2016-12-02 00:24:16 +01:00
|
|
|
|
|
2016-12-06 21:08:28 +01:00
|
|
|
|
static void Agd_PutIconsMyFullAgenda (void);
|
|
|
|
|
static void Agd_PutIconsMyPublicAgenda (void);
|
2016-12-01 00:53:50 +01:00
|
|
|
|
static void Agd_PutIconToCreateNewEvent (void);
|
2016-12-06 21:08:28 +01:00
|
|
|
|
static void Agd_PutIconToViewEditMyFullAgenda (void);
|
2016-12-05 03:16:25 +01:00
|
|
|
|
static void Agd_PutIconToShowQR (void);
|
2016-12-09 14:50:21 +01:00
|
|
|
|
static void Agd_PutIconsOtherPublicAgenda (void);
|
2016-12-06 21:08:28 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
static void Agd_PutButtonToCreateNewEvent (void);
|
2016-12-02 00:24:16 +01:00
|
|
|
|
static void Agd_ShowOneEvent (Agd_AgendaType_t AgendaType,long AgdCod);
|
2017-01-29 12:42:19 +01:00
|
|
|
|
static void Agd_GetParamEventOrder (void);
|
2016-12-01 00:53:50 +01:00
|
|
|
|
|
2016-12-03 19:22:06 +01:00
|
|
|
|
static void Agd_PutFormsToRemEditOneEvent (struct AgendaEvent *AgdEvent);
|
2017-03-21 14:36:22 +01:00
|
|
|
|
|
2017-04-13 20:09:22 +02:00
|
|
|
|
static void Agd_PutCurrentParamsMyAgenda (void);
|
2017-03-21 14:36:22 +01:00
|
|
|
|
static void Agd_GetParams (Agd_AgendaType_t AgendaType);
|
|
|
|
|
|
2016-12-02 00:24:16 +01:00
|
|
|
|
static void Agd_GetListEvents (Agd_AgendaType_t AgendaType);
|
|
|
|
|
static void Agd_GetDataOfEventByCod (struct AgendaEvent *AgdEvent);
|
2017-01-17 03:10:43 +01:00
|
|
|
|
static void Agd_GetEventTxtFromDB (struct AgendaEvent *AgdEvent,
|
|
|
|
|
char Txt[Cns_MAX_BYTES_TEXT + 1]);
|
2016-12-01 00:53:50 +01:00
|
|
|
|
static void Agd_CreateEvent (struct AgendaEvent *AgdEvent,const char *Txt);
|
|
|
|
|
static void Agd_UpdateEvent (struct AgendaEvent *AgdEvent,const char *Txt);
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-04 04:22:36 +01:00
|
|
|
|
/********** Put form to log in and then show another user's agenda ***********/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-04 04:22:36 +01:00
|
|
|
|
void Agd_PutFormLogInToShowUsrAgenda (void)
|
2016-12-04 03:50:25 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Form to log in *****/
|
2016-12-05 13:26:12 +01:00
|
|
|
|
Usr_WriteFormLogin (ActLogInUsrAgd,Agd_PutParamAgd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Agd_PutParamAgd (void)
|
|
|
|
|
{
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char Nickname[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
2016-12-05 13:26:12 +01:00
|
|
|
|
|
|
|
|
|
sprintf (Nickname,"@%s",Gbl.Usrs.Other.UsrDat.Nickname);
|
|
|
|
|
Par_PutHiddenParamString ("agd",Nickname);
|
2016-12-04 04:22:36 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-06 21:26:02 +01:00
|
|
|
|
/******************************* Show my agenda ******************************/
|
2016-12-04 04:22:36 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-06 21:26:02 +01:00
|
|
|
|
void Agd_ShowMyAgenda (void)
|
2016-12-04 04:22:36 +01:00
|
|
|
|
{
|
2016-12-06 21:26:02 +01:00
|
|
|
|
extern const char *Hlp_PROFILE_Agenda;
|
|
|
|
|
extern const char *Txt_My_agenda;
|
|
|
|
|
|
2017-03-21 14:36:22 +01:00
|
|
|
|
/***** Get parameters *****/
|
2017-03-21 14:52:07 +01:00
|
|
|
|
Agd_GetParams (Agd_MY_AGENDA);
|
2017-03-21 14:36:22 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Start box *****/
|
2017-06-11 22:26:40 +02:00
|
|
|
|
Box_StartBox ("100%",Txt_My_agenda,Agd_PutIconsMyFullAgenda,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_PROFILE_Agenda,Box_NOT_CLOSABLE);
|
2016-12-06 21:26:02 +01:00
|
|
|
|
|
2017-03-21 00:57:11 +01:00
|
|
|
|
/***** Put forms to choice which events to show *****/
|
2017-03-21 14:36:22 +01:00
|
|
|
|
Agd_ShowFormToSelPast__FutureEvents ();
|
|
|
|
|
Agd_ShowFormToSelPrivatPublicEvents ();
|
|
|
|
|
Agd_ShowFormToSelHiddenVisiblEvents ();
|
2017-03-21 00:57:11 +01:00
|
|
|
|
|
2016-12-06 21:26:02 +01:00
|
|
|
|
/***** Show the current events in the user's agenda *****/
|
2017-03-21 14:52:07 +01:00
|
|
|
|
Agd_ShowEventsToday (Agd_MY_AGENDA_TODAY);
|
2016-12-06 21:26:02 +01:00
|
|
|
|
|
|
|
|
|
/***** Show all my events *****/
|
2017-03-21 14:52:07 +01:00
|
|
|
|
Agd_ShowEvents (Agd_MY_AGENDA);
|
2016-12-06 21:26:02 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_EndBox ();
|
2016-12-06 21:26:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-21 00:57:11 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Show form to select past / future events ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-21 14:36:22 +01:00
|
|
|
|
static void Agd_ShowFormToSelPast__FutureEvents (void)
|
2017-03-21 00:57:11 +01:00
|
|
|
|
{
|
2017-03-21 14:36:22 +01:00
|
|
|
|
extern const char *Txt_AGENDA_PAST___FUTURE_EVENTS[2];
|
|
|
|
|
Agd_Past__FutureEvents_t PstFut;
|
2017-03-21 00:57:11 +01:00
|
|
|
|
static const char *Image[2] =
|
|
|
|
|
{
|
2017-03-21 14:36:22 +01:00
|
|
|
|
"past64x64.png", // Agd_PAST___EVENTS
|
2017-03-21 01:35:36 +01:00
|
|
|
|
"future64x64.png", // Agd_FUTURE_EVENTS
|
2017-03-21 00:57:11 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"PREF_CONTAINER\">");
|
2017-03-21 14:36:22 +01:00
|
|
|
|
for (PstFut = Agd_PAST___EVENTS;
|
2017-03-21 00:57:11 +01:00
|
|
|
|
PstFut <= Agd_FUTURE_EVENTS;
|
|
|
|
|
PstFut++)
|
|
|
|
|
{
|
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"%s\">",
|
2017-03-21 14:36:22 +01:00
|
|
|
|
(Gbl.Agenda.Past__FutureEvents & (1 << PstFut)) ? "PREF_ON" :
|
|
|
|
|
"PREF_OFF");
|
2017-03-21 00:57:11 +01:00
|
|
|
|
Act_FormStart (ActSeeMyAgd);
|
2017-04-13 20:09:22 +02:00
|
|
|
|
Agd_PutParamsMyAgenda (Gbl.Agenda.Past__FutureEvents ^ (1 << PstFut), // Toggle
|
|
|
|
|
Gbl.Agenda.PrivatPublicEvents,
|
|
|
|
|
Gbl.Agenda.HiddenVisiblEvents,
|
|
|
|
|
Gbl.Agenda.CurrentPage,
|
|
|
|
|
-1L);
|
2017-03-21 00:57:11 +01:00
|
|
|
|
|
|
|
|
|
fprintf (Gbl.F.Out,"<input type=\"image\" src=\"%s/%s\""
|
|
|
|
|
" alt=\"%s\" title=\"%s\" class=\"ICO25x25\""
|
|
|
|
|
" style=\"margin:0 auto;\" />",
|
|
|
|
|
Gbl.Prefs.IconsURL,
|
|
|
|
|
Image[PstFut],
|
2017-03-21 14:36:22 +01:00
|
|
|
|
Txt_AGENDA_PAST___FUTURE_EVENTS[PstFut],
|
|
|
|
|
Txt_AGENDA_PAST___FUTURE_EVENTS[PstFut]);
|
2017-03-21 00:57:11 +01:00
|
|
|
|
Act_FormEnd ();
|
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
|
|
|
|
}
|
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Show form to select private / public events ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-21 14:36:22 +01:00
|
|
|
|
static void Agd_ShowFormToSelPrivatPublicEvents (void)
|
2017-03-21 00:57:11 +01:00
|
|
|
|
{
|
2017-03-21 14:36:22 +01:00
|
|
|
|
extern const char *Txt_AGENDA_PRIVAT_PUBLIC_EVENTS[2];
|
|
|
|
|
Agd_PrivatPublicEvents_t PrvPub;
|
2017-03-21 00:57:11 +01:00
|
|
|
|
static const char *Image[2] =
|
|
|
|
|
{
|
2017-03-21 14:36:22 +01:00
|
|
|
|
"lock-on64x64.png", // Agd_PRIVAT_EVENTS
|
2017-03-21 00:57:11 +01:00
|
|
|
|
"unlock-on64x64.png", // Agd_PUBLIC_EVENTS
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"PREF_CONTAINER\">");
|
2017-03-21 14:36:22 +01:00
|
|
|
|
for (PrvPub = Agd_PRIVAT_EVENTS;
|
|
|
|
|
PrvPub <= Agd_PUBLIC_EVENTS;
|
2017-03-21 00:57:11 +01:00
|
|
|
|
PrvPub++)
|
|
|
|
|
{
|
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"%s\">",
|
2017-03-21 14:36:22 +01:00
|
|
|
|
(Gbl.Agenda.PrivatPublicEvents & (1 << PrvPub)) ? "PREF_ON" :
|
|
|
|
|
"PREF_OFF");
|
2017-03-21 00:57:11 +01:00
|
|
|
|
Act_FormStart (ActSeeMyAgd);
|
2017-04-13 20:09:22 +02:00
|
|
|
|
Agd_PutParamsMyAgenda (Gbl.Agenda.Past__FutureEvents,
|
|
|
|
|
Gbl.Agenda.PrivatPublicEvents ^ (1 << PrvPub), // Toggle
|
|
|
|
|
Gbl.Agenda.HiddenVisiblEvents,
|
|
|
|
|
Gbl.Agenda.CurrentPage,
|
|
|
|
|
-1L);
|
2017-03-21 00:57:11 +01:00
|
|
|
|
|
|
|
|
|
fprintf (Gbl.F.Out,"<input type=\"image\" src=\"%s/%s\""
|
|
|
|
|
" alt=\"%s\" title=\"%s\" class=\"ICO25x25\""
|
|
|
|
|
" style=\"margin:0 auto;\" />",
|
|
|
|
|
Gbl.Prefs.IconsURL,
|
|
|
|
|
Image[PrvPub],
|
2017-03-21 14:36:22 +01:00
|
|
|
|
Txt_AGENDA_PRIVAT_PUBLIC_EVENTS[PrvPub],
|
|
|
|
|
Txt_AGENDA_PRIVAT_PUBLIC_EVENTS[PrvPub]);
|
2017-03-21 00:57:11 +01:00
|
|
|
|
Act_FormEnd ();
|
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
|
|
|
|
}
|
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Show form to select hidden / visible events *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-21 14:36:22 +01:00
|
|
|
|
static void Agd_ShowFormToSelHiddenVisiblEvents (void)
|
2017-03-21 00:57:11 +01:00
|
|
|
|
{
|
2017-03-21 14:36:22 +01:00
|
|
|
|
extern const char *Txt_AGENDA_HIDDEN_VISIBL_EVENTS[2];
|
|
|
|
|
Agd_HiddenVisiblEvents_t HidVis;
|
2017-03-21 00:57:11 +01:00
|
|
|
|
static const char *Image[2] =
|
|
|
|
|
{
|
|
|
|
|
"eye-slash-on64x64.png", // Agd_HIDDEN_EVENTS
|
2017-03-21 14:36:22 +01:00
|
|
|
|
"eye-on64x64.png", // Agd_VISIBL_EVENTS
|
2017-03-21 00:57:11 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"PREF_CONTAINER\">");
|
2017-03-21 14:36:22 +01:00
|
|
|
|
for (HidVis = Agd_HIDDEN_EVENTS;
|
|
|
|
|
HidVis <= Agd_VISIBL_EVENTS;
|
2017-03-21 00:57:11 +01:00
|
|
|
|
HidVis++)
|
|
|
|
|
{
|
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"%s\">",
|
2017-03-21 14:36:22 +01:00
|
|
|
|
(Gbl.Agenda.HiddenVisiblEvents & (1 << HidVis)) ? "PREF_ON" :
|
|
|
|
|
"PREF_OFF");
|
2017-03-21 00:57:11 +01:00
|
|
|
|
Act_FormStart (ActSeeMyAgd);
|
2017-04-13 20:09:22 +02:00
|
|
|
|
Agd_PutParamsMyAgenda (Gbl.Agenda.Past__FutureEvents,
|
|
|
|
|
Gbl.Agenda.PrivatPublicEvents,
|
|
|
|
|
Gbl.Agenda.HiddenVisiblEvents ^ (1 << HidVis), // Toggle
|
|
|
|
|
Gbl.Agenda.CurrentPage,
|
|
|
|
|
-1L);
|
2017-03-21 00:57:11 +01:00
|
|
|
|
|
|
|
|
|
fprintf (Gbl.F.Out,"<input type=\"image\" src=\"%s/%s\""
|
|
|
|
|
" alt=\"%s\" title=\"%s\" class=\"ICO25x25\""
|
|
|
|
|
" style=\"margin:0 auto;\" />",
|
|
|
|
|
Gbl.Prefs.IconsURL,
|
|
|
|
|
Image[HidVis],
|
2017-03-21 14:36:22 +01:00
|
|
|
|
Txt_AGENDA_HIDDEN_VISIBL_EVENTS[HidVis],
|
|
|
|
|
Txt_AGENDA_HIDDEN_VISIBL_EVENTS[HidVis]);
|
2017-03-21 00:57:11 +01:00
|
|
|
|
Act_FormEnd ();
|
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
|
|
|
|
}
|
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-03-21 14:36:22 +01:00
|
|
|
|
/************************ Put hidden params for events ***********************/
|
2017-03-21 00:57:11 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-21 14:36:22 +01:00
|
|
|
|
static void Agd_PutHiddenParamPast__FutureEvents (unsigned Past__FutureEvents)
|
2017-03-21 00:57:11 +01:00
|
|
|
|
{
|
2017-03-21 14:36:22 +01:00
|
|
|
|
Par_PutHiddenParamUnsigned (ParamPast__FutureName,Past__FutureEvents);
|
2017-03-21 00:57:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-21 14:36:22 +01:00
|
|
|
|
static void Agd_PutHiddenParamPrivatPublicEvents (unsigned PrivatPublicEvents)
|
2017-03-21 00:57:11 +01:00
|
|
|
|
{
|
2017-03-21 14:36:22 +01:00
|
|
|
|
Par_PutHiddenParamUnsigned (ParamPrivatPublicName,PrivatPublicEvents);
|
|
|
|
|
}
|
2017-03-21 00:57:11 +01:00
|
|
|
|
|
2017-03-21 14:36:22 +01:00
|
|
|
|
static void Agd_PutHiddenParamHiddenVisiblEvents (unsigned HiddenVisiblEvents)
|
|
|
|
|
{
|
|
|
|
|
Par_PutHiddenParamUnsigned (ParamHiddenVisiblName,HiddenVisiblEvents);
|
2017-03-21 00:57:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-03-21 14:36:22 +01:00
|
|
|
|
/************************ Get hidden params for events ***********************/
|
2017-03-21 00:57:11 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-21 14:36:22 +01:00
|
|
|
|
static void Agd_GetParamsPast__FutureEvents (void)
|
2017-03-21 00:57:11 +01:00
|
|
|
|
{
|
2017-03-21 14:36:22 +01:00
|
|
|
|
Gbl.Agenda.Past__FutureEvents = (unsigned) Par_GetParToUnsignedLong (ParamPast__FutureName,
|
|
|
|
|
0,
|
|
|
|
|
(1 << Agd_PAST___EVENTS) |
|
|
|
|
|
(1 << Agd_FUTURE_EVENTS),
|
|
|
|
|
Agd_DEFAULT_PAST___EVENTS |
|
|
|
|
|
Agd_DEFAULT_FUTURE_EVENTS);
|
|
|
|
|
}
|
2017-03-21 00:57:11 +01:00
|
|
|
|
|
2017-03-21 14:36:22 +01:00
|
|
|
|
static void Agd_GetParamsPrivatPublicEvents (void)
|
|
|
|
|
{
|
|
|
|
|
Gbl.Agenda.PrivatPublicEvents = (unsigned) Par_GetParToUnsignedLong (ParamPrivatPublicName,
|
|
|
|
|
0,
|
|
|
|
|
(1 << Agd_PRIVAT_EVENTS) |
|
|
|
|
|
(1 << Agd_PUBLIC_EVENTS),
|
|
|
|
|
Agd_DEFAULT_PRIVAT_EVENTS |
|
|
|
|
|
Agd_DEFAULT_PUBLIC_EVENTS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Agd_GetParamsHiddenVisiblEvents (void)
|
|
|
|
|
{
|
|
|
|
|
Gbl.Agenda.HiddenVisiblEvents = (unsigned) Par_GetParToUnsignedLong (ParamHiddenVisiblName,
|
|
|
|
|
0,
|
|
|
|
|
(1 << Agd_HIDDEN_EVENTS) |
|
|
|
|
|
(1 << Agd_VISIBL_EVENTS),
|
|
|
|
|
Agd_DEFAULT_HIDDEN_EVENTS |
|
|
|
|
|
Agd_DEFAULT_VISIBL_EVENTS);
|
2017-03-21 00:57:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-04 03:50:25 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Show another user's agenda *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-02 00:24:16 +01:00
|
|
|
|
void Agd_ShowUsrAgenda (void)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2016-12-07 10:16:39 +01:00
|
|
|
|
extern const char *Hlp_PROFILE_Agenda_public_agenda;
|
2016-12-06 03:10:06 +01:00
|
|
|
|
extern const char *Txt_Public_agenda_USER;
|
2016-12-02 00:24:16 +01:00
|
|
|
|
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
2016-12-06 03:10:06 +01:00
|
|
|
|
bool ItsMe;
|
2016-12-09 13:59:33 +01:00
|
|
|
|
bool Error = true;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-02 00:24:16 +01:00
|
|
|
|
/***** Get user *****/
|
|
|
|
|
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
2016-12-09 13:59:33 +01:00
|
|
|
|
if (Usr_CheckIfICanViewUsrAgenda (&Gbl.Usrs.Other.UsrDat))
|
|
|
|
|
{
|
|
|
|
|
Error = false;
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Start box *****/
|
2016-12-09 13:59:33 +01:00
|
|
|
|
sprintf (Gbl.Title,Txt_Public_agenda_USER,Gbl.Usrs.Other.UsrDat.FullName);
|
|
|
|
|
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_StartBox ("100%",Gbl.Title,
|
2017-06-11 22:26:40 +02:00
|
|
|
|
ItsMe ? Agd_PutIconsMyPublicAgenda :
|
|
|
|
|
Agd_PutIconsOtherPublicAgenda,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_PROFILE_Agenda_public_agenda,Box_NOT_CLOSABLE);
|
2016-12-09 13:59:33 +01:00
|
|
|
|
|
|
|
|
|
/***** Show the current events in the user's agenda *****/
|
2017-03-21 14:52:07 +01:00
|
|
|
|
Agd_ShowEventsToday (Agd_ANOTHER_AGENDA_TODAY);
|
2016-12-09 13:59:33 +01:00
|
|
|
|
|
|
|
|
|
/***** Show all the visible events in the user's agenda *****/
|
2017-03-21 14:52:07 +01:00
|
|
|
|
Agd_ShowEvents (Agd_ANOTHER_AGENDA);
|
2016-12-09 13:59:33 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_EndBox ();
|
2016-12-09 13:59:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Error)
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-07 00:21:10 +02:00
|
|
|
|
/*****************************************************************************/
|
2016-12-06 21:26:02 +01:00
|
|
|
|
/***************** Show another user's agenda after log in *******************/
|
2016-12-06 21:08:28 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-06 21:26:02 +01:00
|
|
|
|
void Agd_ShowOtherAgendaAfterLogIn (void)
|
2016-12-06 21:08:28 +01:00
|
|
|
|
{
|
2016-12-07 10:16:39 +01:00
|
|
|
|
extern const char *Hlp_PROFILE_Agenda_public_agenda;
|
2016-12-06 21:26:02 +01:00
|
|
|
|
extern const unsigned Txt_Current_CGI_SWAD_Language;
|
2016-12-06 21:08:28 +01:00
|
|
|
|
extern const char *Txt_Public_agenda_USER;
|
2016-12-06 21:26:02 +01:00
|
|
|
|
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
extern const char *Txt_Switching_to_LANGUAGE[1 + Txt_NUM_LANGUAGES];
|
2016-12-06 21:26:02 +01:00
|
|
|
|
bool ItsMe;
|
2016-12-06 21:08:28 +01:00
|
|
|
|
|
2016-12-06 21:26:02 +01:00
|
|
|
|
if (Gbl.Usrs.Me.Logged)
|
|
|
|
|
{
|
|
|
|
|
if (Gbl.Usrs.Me.UsrDat.Prefs.Language == Txt_Current_CGI_SWAD_Language)
|
|
|
|
|
{
|
|
|
|
|
/***** Get user *****/
|
|
|
|
|
/* If nickname is correct, user code is already got from nickname */
|
|
|
|
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // Existing user
|
|
|
|
|
{
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Start box *****/
|
2016-12-06 21:26:02 +01:00
|
|
|
|
sprintf (Gbl.Title,Txt_Public_agenda_USER,Gbl.Usrs.Other.UsrDat.FullName);
|
|
|
|
|
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_StartBox ("100%",Gbl.Title,
|
2017-06-11 22:26:40 +02:00
|
|
|
|
ItsMe ? Agd_PutIconToViewEditMyFullAgenda :
|
|
|
|
|
Agd_PutIconsOtherPublicAgenda,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_PROFILE_Agenda_public_agenda,Box_NOT_CLOSABLE);
|
2016-12-06 03:10:06 +01:00
|
|
|
|
|
2016-12-06 21:26:02 +01:00
|
|
|
|
/***** Show the current events in the user's agenda *****/
|
2017-03-21 14:52:07 +01:00
|
|
|
|
Agd_ShowEventsToday (Agd_ANOTHER_AGENDA_TODAY);
|
2016-12-06 03:10:06 +01:00
|
|
|
|
|
2016-12-06 21:26:02 +01:00
|
|
|
|
/***** Show all the visible events in the user's agenda *****/
|
2017-03-21 14:52:07 +01:00
|
|
|
|
Agd_ShowEvents (Agd_ANOTHER_AGENDA);
|
2016-12-06 03:10:06 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_EndBox ();
|
2016-12-06 21:26:02 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
|
2016-12-06 21:26:02 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
/* The current language is not my preferred language
|
|
|
|
|
==> change automatically to my language */
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_Switching_to_LANGUAGE[Gbl.Usrs.Me.UsrDat.Prefs.Language]);
|
2016-12-06 21:26:02 +01:00
|
|
|
|
}
|
2016-12-02 00:24:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Show events in agenda ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Agd_ShowEvents (Agd_AgendaType_t AgendaType)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2016-12-01 00:53:50 +01:00
|
|
|
|
extern const char *Hlp_PROFILE_Agenda;
|
2016-12-03 23:48:03 +01:00
|
|
|
|
extern const char *Txt_Public_agenda_USER;
|
2016-12-02 00:24:16 +01:00
|
|
|
|
extern const char *Txt_My_agenda;
|
2016-12-01 00:53:50 +01:00
|
|
|
|
extern const char *Txt_No_events;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
struct Pagination Pagination;
|
2016-12-02 00:24:16 +01:00
|
|
|
|
unsigned NumEvent;
|
|
|
|
|
Pag_WhatPaginate_t WhatPaginate[Agd_NUM_AGENDA_TYPES] =
|
|
|
|
|
{
|
2017-03-21 14:52:07 +01:00
|
|
|
|
Pag_MY_AGENDA, // Agd_MY_AGENDA_TODAY, not used
|
|
|
|
|
Pag_MY_AGENDA, // Agd_MY_AGENDA
|
|
|
|
|
Pag_ANOTHER_AGENDA, // Agd_ANOTHER_AGENDA_TODAY, not used
|
|
|
|
|
Pag_ANOTHER_AGENDA, // Agd_ANOTHER_AGENDA
|
2016-12-02 00:24:16 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
2017-03-21 14:36:22 +01:00
|
|
|
|
Agd_GetParams (AgendaType);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get list of events *****/
|
2016-12-02 00:24:16 +01:00
|
|
|
|
Agd_GetListEvents (AgendaType);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Compute variables related to pagination *****/
|
2016-12-02 00:24:16 +01:00
|
|
|
|
Pagination.NumItems = Gbl.Agenda.Num;
|
2017-04-13 20:09:22 +02:00
|
|
|
|
Pagination.CurrentPage = (int) Gbl.Agenda.CurrentPage;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Pag_CalculatePagination (&Pagination);
|
2017-04-13 20:09:22 +02:00
|
|
|
|
Gbl.Agenda.CurrentPage = (unsigned) Pagination.CurrentPage;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Write links to pages *****/
|
|
|
|
|
if (Pagination.MoreThanOnePage)
|
2017-04-17 11:57:55 +02:00
|
|
|
|
Pag_WriteLinksToPagesCentered (WhatPaginate[AgendaType],
|
|
|
|
|
0,
|
|
|
|
|
&Pagination);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-02 00:24:16 +01:00
|
|
|
|
if (Gbl.Agenda.Num)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2016-12-06 03:10:06 +01:00
|
|
|
|
/***** Start table *****/
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_StartTableWideMargin (2);
|
2016-12-06 03:10:06 +01:00
|
|
|
|
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/***** Table head *****/
|
2016-12-06 03:10:06 +01:00
|
|
|
|
Agd_WriteHeaderListEvents (AgendaType);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Write all the events *****/
|
2016-12-02 00:24:16 +01:00
|
|
|
|
for (NumEvent = Pagination.FirstItemVisible;
|
|
|
|
|
NumEvent <= Pagination.LastItemVisible;
|
|
|
|
|
NumEvent++)
|
|
|
|
|
Agd_ShowOneEvent (AgendaType,Gbl.Agenda.LstAgdCods[NumEvent - 1]);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** End table *****/
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_EndTable ();
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
2016-12-06 03:10:06 +01:00
|
|
|
|
else
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_No_events);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-06 03:10:06 +01:00
|
|
|
|
/***** Write again links to pages *****/
|
|
|
|
|
if (Pagination.MoreThanOnePage)
|
2017-04-17 11:57:55 +02:00
|
|
|
|
Pag_WriteLinksToPagesCentered (WhatPaginate[AgendaType],
|
|
|
|
|
0,
|
|
|
|
|
&Pagination);
|
2016-12-06 03:10:06 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Button to create a new event *****/
|
2017-03-21 14:52:07 +01:00
|
|
|
|
if (AgendaType == Agd_MY_AGENDA)
|
2016-12-01 00:53:50 +01:00
|
|
|
|
Agd_PutButtonToCreateNewEvent ();
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-06 03:10:06 +01:00
|
|
|
|
/***** Free list of events *****/
|
|
|
|
|
Agd_FreeListEvents ();
|
|
|
|
|
}
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-06 03:10:06 +01:00
|
|
|
|
/*****************************************************************************/
|
2016-12-06 21:08:28 +01:00
|
|
|
|
/************************ Show today events in agenda ************************/
|
2016-12-06 03:10:06 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-06 21:08:28 +01:00
|
|
|
|
static void Agd_ShowEventsToday (Agd_AgendaType_t AgendaType)
|
2016-12-06 03:10:06 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Hlp_PROFILE_Agenda;
|
2016-12-07 10:16:39 +01:00
|
|
|
|
extern const char *Hlp_PROFILE_Agenda_public_agenda;
|
2016-12-06 18:04:12 +01:00
|
|
|
|
extern const char *Txt_Today;
|
2016-12-06 03:10:06 +01:00
|
|
|
|
extern const char *Txt_Public_agenda_USER;
|
|
|
|
|
extern const char *Txt_My_agenda;
|
|
|
|
|
extern const char *Txt_No_events;
|
|
|
|
|
unsigned NumEvent;
|
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
2017-03-21 14:36:22 +01:00
|
|
|
|
Agd_GetParams (AgendaType);
|
2016-12-06 03:10:06 +01:00
|
|
|
|
|
|
|
|
|
/***** Get list of events *****/
|
|
|
|
|
Agd_GetListEvents (AgendaType);
|
|
|
|
|
|
|
|
|
|
if (Gbl.Agenda.Num)
|
|
|
|
|
{
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Start box and table *****/
|
2016-12-06 19:14:58 +01:00
|
|
|
|
switch (AgendaType)
|
|
|
|
|
{
|
2017-03-21 14:52:07 +01:00
|
|
|
|
case Agd_MY_AGENDA_TODAY:
|
2017-06-11 22:26:40 +02:00
|
|
|
|
Box_StartBoxTableShadow (NULL,Txt_Today,NULL,
|
|
|
|
|
Hlp_PROFILE_Agenda,
|
|
|
|
|
2);
|
2016-12-06 19:14:58 +01:00
|
|
|
|
break;
|
2017-03-21 14:52:07 +01:00
|
|
|
|
case Agd_ANOTHER_AGENDA_TODAY:
|
2017-06-11 22:26:40 +02:00
|
|
|
|
Box_StartBoxTableShadow (NULL,Txt_Today,NULL,
|
|
|
|
|
Hlp_PROFILE_Agenda_public_agenda,
|
|
|
|
|
2);
|
2016-12-06 21:26:02 +01:00
|
|
|
|
break;
|
2016-12-06 21:08:28 +01:00
|
|
|
|
default:
|
2016-12-06 19:14:58 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
2016-12-06 03:10:06 +01:00
|
|
|
|
|
|
|
|
|
/***** Table head *****/
|
|
|
|
|
Agd_WriteHeaderListEvents (AgendaType);
|
|
|
|
|
|
|
|
|
|
/***** Write all the events *****/
|
|
|
|
|
for (NumEvent = 0;
|
|
|
|
|
NumEvent < Gbl.Agenda.Num;
|
|
|
|
|
NumEvent++)
|
|
|
|
|
Agd_ShowOneEvent (AgendaType,Gbl.Agenda.LstAgdCods[NumEvent]);
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End table and box *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_EndBoxTable ();
|
2016-12-06 03:10:06 +01:00
|
|
|
|
}
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Free list of events *****/
|
|
|
|
|
Agd_FreeListEvents ();
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-05 23:13:58 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Put contextual icon to view/edit my agenda ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-06 03:10:06 +01:00
|
|
|
|
static void Agd_WriteHeaderListEvents (Agd_AgendaType_t AgendaType)
|
|
|
|
|
{
|
2016-12-15 00:39:52 +01:00
|
|
|
|
extern const char *Txt_START_END_TIME_HELP[2];
|
|
|
|
|
extern const char *Txt_START_END_TIME[Dat_NUM_START_END_TIME];
|
2016-12-06 03:10:06 +01:00
|
|
|
|
extern const char *Txt_Event;
|
|
|
|
|
extern const char *Txt_Location;
|
|
|
|
|
Agd_Order_t Order;
|
|
|
|
|
|
|
|
|
|
/***** Table head *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>");
|
|
|
|
|
for (Order = Agd_ORDER_BY_START_DATE;
|
|
|
|
|
Order <= Agd_ORDER_BY_END_DATE;
|
|
|
|
|
Order++)
|
|
|
|
|
{
|
|
|
|
|
fprintf (Gbl.F.Out,"<th class=\"LEFT_MIDDLE\">");
|
|
|
|
|
switch (AgendaType)
|
|
|
|
|
{
|
2017-03-21 14:52:07 +01:00
|
|
|
|
case Agd_MY_AGENDA_TODAY:
|
|
|
|
|
case Agd_MY_AGENDA:
|
2016-12-06 03:10:06 +01:00
|
|
|
|
Act_FormStart (ActSeeMyAgd);
|
2017-04-13 20:09:22 +02:00
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_MY_AGENDA,Gbl.Agenda.CurrentPage);
|
2016-12-06 03:10:06 +01:00
|
|
|
|
break;
|
2017-03-21 14:52:07 +01:00
|
|
|
|
case Agd_ANOTHER_AGENDA_TODAY:
|
|
|
|
|
case Agd_ANOTHER_AGENDA:
|
2016-12-06 21:26:02 +01:00
|
|
|
|
Act_FormStart (ActSeeUsrAgd);
|
|
|
|
|
Usr_PutParamOtherUsrCodEncrypted ();
|
2017-04-13 20:09:22 +02:00
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_ANOTHER_AGENDA,Gbl.Agenda.CurrentPage);
|
2016-12-06 21:26:02 +01:00
|
|
|
|
break;
|
2016-12-06 03:10:06 +01:00
|
|
|
|
}
|
|
|
|
|
Par_PutHiddenParamUnsigned ("Order",(unsigned) Order);
|
2016-12-15 00:39:52 +01:00
|
|
|
|
Act_LinkFormSubmit (Txt_START_END_TIME_HELP[Order],"TIT_TBL",NULL);
|
2017-01-29 12:42:19 +01:00
|
|
|
|
if (Order == Gbl.Agenda.SelectedOrder)
|
2016-12-06 03:10:06 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<u>");
|
2016-12-15 00:39:52 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"%s",Txt_START_END_TIME[Order]);
|
2017-01-29 12:42:19 +01:00
|
|
|
|
if (Order == Gbl.Agenda.SelectedOrder)
|
2016-12-06 03:10:06 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</u>");
|
|
|
|
|
fprintf (Gbl.F.Out,"</a>");
|
|
|
|
|
Act_FormEnd ();
|
|
|
|
|
fprintf (Gbl.F.Out,"</th>");
|
|
|
|
|
}
|
|
|
|
|
fprintf (Gbl.F.Out,"<th class=\"LEFT_MIDDLE\">"
|
|
|
|
|
"%s"
|
|
|
|
|
"</th>"
|
|
|
|
|
"<th class=\"LEFT_MIDDLE\">"
|
|
|
|
|
"%s"
|
|
|
|
|
"</th>"
|
|
|
|
|
"</tr>",
|
|
|
|
|
Txt_Event,
|
|
|
|
|
Txt_Location);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-06 21:08:28 +01:00
|
|
|
|
/********************** Put contextual icons in agenda ***********************/
|
2016-12-06 03:10:06 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-06 21:08:28 +01:00
|
|
|
|
static void Agd_PutIconsMyFullAgenda (void)
|
2016-12-05 23:13:58 +01:00
|
|
|
|
{
|
2016-12-06 21:08:28 +01:00
|
|
|
|
/***** Put icon to create a new event *****/
|
|
|
|
|
Agd_PutIconToCreateNewEvent ();
|
2016-12-05 23:13:58 +01:00
|
|
|
|
|
2016-12-06 21:08:28 +01:00
|
|
|
|
/***** Put icon to show QR code *****/
|
|
|
|
|
Agd_PutIconToShowQR ();
|
|
|
|
|
}
|
2016-12-05 03:16:25 +01:00
|
|
|
|
|
2016-12-06 21:08:28 +01:00
|
|
|
|
static void Agd_PutIconsMyPublicAgenda (void)
|
2016-12-05 03:16:25 +01:00
|
|
|
|
{
|
2016-12-06 21:08:28 +01:00
|
|
|
|
/***** Put icon to view/edit my full agenda *****/
|
|
|
|
|
Agd_PutIconToViewEditMyFullAgenda ();
|
2016-12-05 03:16:25 +01:00
|
|
|
|
|
|
|
|
|
/***** Put icon to show QR code *****/
|
|
|
|
|
Agd_PutIconToShowQR ();
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
static void Agd_PutIconToCreateNewEvent (void)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_New_event;
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Put form to create a new event *****/
|
2017-03-21 14:36:22 +01:00
|
|
|
|
Gbl.Agenda.AgdCodToEdit = -1L;
|
2017-04-17 19:03:21 +02:00
|
|
|
|
Lay_PutContextualLink (ActFrmNewEvtMyAgd,NULL,Agd_PutCurrentParamsMyAgenda,
|
2016-11-30 22:49:48 +01:00
|
|
|
|
"plus64x64.png",
|
|
|
|
|
Txt_New_event,NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-06 21:08:28 +01:00
|
|
|
|
static void Agd_PutIconToViewEditMyFullAgenda (void)
|
|
|
|
|
{
|
2017-06-11 19:13:28 +02:00
|
|
|
|
Ico_PutContextualIconToEdit (ActSeeMyAgd,NULL);
|
2016-12-06 21:08:28 +01:00
|
|
|
|
}
|
2016-12-05 03:16:25 +01:00
|
|
|
|
|
|
|
|
|
static void Agd_PutIconToShowQR (void)
|
|
|
|
|
{
|
2017-03-07 01:56:41 +01:00
|
|
|
|
char URL[Cns_MAX_BYTES_WWW + 1];
|
2017-01-28 15:58:46 +01:00
|
|
|
|
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
|
2016-12-05 09:50:35 +01:00
|
|
|
|
|
|
|
|
|
sprintf (URL,"%s/%s?agd=@%s",
|
|
|
|
|
Cfg_URL_SWAD_CGI,
|
|
|
|
|
Txt_STR_LANG_ID[Gbl.Prefs.Language],
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.Nickname);
|
|
|
|
|
Gbl.QR.Str = URL;
|
2017-03-01 18:53:51 +01:00
|
|
|
|
QR_PutLinkToPrintQRCode (ActPrnAgdQR);
|
2016-12-05 03:16:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-09 14:50:21 +01:00
|
|
|
|
static void Agd_PutIconsOtherPublicAgenda (void)
|
|
|
|
|
{
|
2017-02-17 01:59:58 +01:00
|
|
|
|
extern const char *Txt_Another_user_s_profile;
|
2016-12-09 14:50:21 +01:00
|
|
|
|
extern const char *Txt_View_record_for_this_course;
|
|
|
|
|
extern const char *Txt_View_record_and_office_hours;
|
|
|
|
|
|
|
|
|
|
/***** Button to view user's public profile *****/
|
2017-01-28 15:58:46 +01:00
|
|
|
|
if (Pri_ShowingIsAllowed (Gbl.Usrs.Other.UsrDat.ProfileVisibility,
|
2017-02-17 01:59:58 +01:00
|
|
|
|
&Gbl.Usrs.Other.UsrDat))
|
2017-04-17 19:03:21 +02:00
|
|
|
|
Lay_PutContextualLink (ActSeeOthPubPrf,NULL,
|
|
|
|
|
Usr_PutParamOtherUsrCodEncrypted,
|
2017-09-17 23:37:03 +02:00
|
|
|
|
"usr64x64.png",
|
2017-02-17 01:59:58 +01:00
|
|
|
|
Txt_Another_user_s_profile,NULL,
|
2016-12-09 14:50:21 +01:00
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
/***** Button to view user's record card *****/
|
|
|
|
|
if (Usr_CheckIfICanViewRecordStd (&Gbl.Usrs.Other.UsrDat))
|
|
|
|
|
/* View student's records: common record card and course record card */
|
2017-04-17 19:03:21 +02:00
|
|
|
|
Lay_PutContextualLink (ActSeeRecOneStd,NULL,
|
|
|
|
|
Usr_PutParamOtherUsrCodEncrypted,
|
2016-12-09 14:50:21 +01:00
|
|
|
|
"card64x64.gif",
|
|
|
|
|
Txt_View_record_for_this_course,NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
else if (Usr_CheckIfICanViewRecordTch (&Gbl.Usrs.Other.UsrDat))
|
2017-04-17 19:03:21 +02:00
|
|
|
|
Lay_PutContextualLink (ActSeeRecOneTch,NULL,
|
2016-12-09 14:50:21 +01:00
|
|
|
|
Usr_PutParamOtherUsrCodEncrypted,
|
|
|
|
|
"card64x64.gif",
|
|
|
|
|
Txt_View_record_and_office_hours,NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/********************* Put button to create a new event **********************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
static void Agd_PutButtonToCreateNewEvent (void)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_New_event;
|
|
|
|
|
|
2016-12-01 01:39:06 +01:00
|
|
|
|
Act_FormStart (ActFrmNewEvtMyAgd);
|
2017-04-13 20:09:22 +02:00
|
|
|
|
Agd_PutParamsMyAgenda (Gbl.Agenda.Past__FutureEvents,
|
|
|
|
|
Gbl.Agenda.PrivatPublicEvents,
|
|
|
|
|
Gbl.Agenda.HiddenVisiblEvents,
|
|
|
|
|
Gbl.Agenda.CurrentPage,
|
|
|
|
|
-1L);
|
2017-06-11 19:02:40 +02:00
|
|
|
|
Btn_PutConfirmButton (Txt_New_event);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Act_FormEnd ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/******************************* Show one event ******************************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-02 00:24:16 +01:00
|
|
|
|
static void Agd_ShowOneEvent (Agd_AgendaType_t AgendaType,long AgdCod)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2016-12-02 10:45:53 +01:00
|
|
|
|
extern const char *Dat_TimeStatusClassVisible[Dat_NUM_TIME_STATUS];
|
|
|
|
|
extern const char *Dat_TimeStatusClassHidden[Dat_NUM_TIME_STATUS];
|
2016-11-30 22:49:48 +01:00
|
|
|
|
extern const char *Txt_Today;
|
|
|
|
|
static unsigned UniqueId = 0;
|
2016-12-01 00:53:50 +01:00
|
|
|
|
struct AgendaEvent AgdEvent;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char Txt[Cns_MAX_BYTES_TEXT + 1];
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get data of this event *****/
|
|
|
|
|
AgdEvent.AgdCod = AgdCod;
|
2016-12-02 00:24:16 +01:00
|
|
|
|
switch (AgendaType)
|
|
|
|
|
{
|
2017-03-21 14:52:07 +01:00
|
|
|
|
case Agd_MY_AGENDA_TODAY:
|
|
|
|
|
case Agd_MY_AGENDA:
|
2016-12-02 00:24:16 +01:00
|
|
|
|
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
|
|
|
|
break;
|
2017-03-21 14:52:07 +01:00
|
|
|
|
case Agd_ANOTHER_AGENDA_TODAY:
|
|
|
|
|
case Agd_ANOTHER_AGENDA:
|
2016-12-06 21:26:02 +01:00
|
|
|
|
AgdEvent.UsrCod = Gbl.Usrs.Other.UsrDat.UsrCod;
|
|
|
|
|
break;
|
2016-12-02 00:24:16 +01:00
|
|
|
|
}
|
2016-12-01 00:53:50 +01:00
|
|
|
|
Agd_GetDataOfEventByCod (&AgdEvent);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Write first row of data of this event *****/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/* Start date/time */
|
|
|
|
|
UniqueId++;
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2016-12-12 23:10:11 +01:00
|
|
|
|
"<td id=\"agd_date_start_%u\" class=\"%s LEFT_BOTTOM COLOR%u\">"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
"<script type=\"text/javascript\">"
|
2017-05-04 17:06:26 +02:00
|
|
|
|
"writeLocalDateHMSFromUTC('agd_date_start_%u',%ld,"
|
2017-05-05 09:41:56 +02:00
|
|
|
|
"%u,'<br />','%s',true,true,0x6);"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
"</script>"
|
|
|
|
|
"</td>",
|
|
|
|
|
UniqueId,
|
2016-12-03 19:22:06 +01:00
|
|
|
|
AgdEvent.Hidden ? Dat_TimeStatusClassHidden[AgdEvent.TimeStatus] :
|
|
|
|
|
Dat_TimeStatusClassVisible[AgdEvent.TimeStatus],
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Gbl.RowEvenOdd,
|
2017-05-04 17:06:26 +02:00
|
|
|
|
UniqueId,AgdEvent.TimeUTC[Agd_START_TIME],
|
|
|
|
|
(unsigned) Gbl.Prefs.DateFormat,Txt_Today);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/* End date/time */
|
|
|
|
|
UniqueId++;
|
2016-12-12 23:10:11 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<td id=\"agd_date_end_%u\" class=\"%s LEFT_BOTTOM COLOR%u\">"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
"<script type=\"text/javascript\">"
|
2017-05-04 17:06:26 +02:00
|
|
|
|
"writeLocalDateHMSFromUTC('agd_date_end_%u',%ld,"
|
2017-05-05 09:41:56 +02:00
|
|
|
|
"%u,'<br />','%s',false,true,0x6);"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
"</script>"
|
|
|
|
|
"</td>",
|
|
|
|
|
UniqueId,
|
2016-12-03 19:22:06 +01:00
|
|
|
|
AgdEvent.Hidden ? Dat_TimeStatusClassHidden[AgdEvent.TimeStatus] :
|
|
|
|
|
Dat_TimeStatusClassVisible[AgdEvent.TimeStatus],
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Gbl.RowEvenOdd,
|
2016-12-12 19:29:16 +01:00
|
|
|
|
UniqueId,AgdEvent.TimeUTC[Agd_END_TIME],
|
2017-05-04 17:06:26 +02:00
|
|
|
|
(unsigned) Gbl.Prefs.DateFormat,Txt_Today);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-11-30 22:59:02 +01:00
|
|
|
|
/* Event */
|
2016-11-30 22:49:48 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"LEFT_TOP COLOR%u\">"
|
2016-11-30 22:59:02 +01:00
|
|
|
|
"<div class=\"%s\">%s</div>"
|
|
|
|
|
"</td>",
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Gbl.RowEvenOdd,
|
2016-12-03 19:22:06 +01:00
|
|
|
|
AgdEvent.Hidden ? "ASG_TITLE_LIGHT" :
|
|
|
|
|
"ASG_TITLE",
|
2016-12-01 00:53:50 +01:00
|
|
|
|
AgdEvent.Event);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-12 19:29:16 +01:00
|
|
|
|
/* Location */
|
2016-11-30 22:49:48 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"LEFT_TOP COLOR%u\">"
|
2016-11-30 22:59:02 +01:00
|
|
|
|
"<div class=\"%s\">%s</div>"
|
|
|
|
|
"</td>"
|
|
|
|
|
"</tr>",
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Gbl.RowEvenOdd,
|
2016-12-03 19:22:06 +01:00
|
|
|
|
AgdEvent.Hidden ? "ASG_TITLE_LIGHT" :
|
|
|
|
|
"ASG_TITLE",
|
2016-12-01 00:53:50 +01:00
|
|
|
|
AgdEvent.Location);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Write second row of data of this event *****/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
|
|
|
|
"<td colspan=\"2\" class=\"LEFT_TOP COLOR%u\">",
|
|
|
|
|
Gbl.RowEvenOdd);
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/* Forms to remove/edit this event */
|
2016-12-06 19:14:58 +01:00
|
|
|
|
switch (AgendaType)
|
|
|
|
|
{
|
2017-03-21 14:52:07 +01:00
|
|
|
|
case Agd_MY_AGENDA_TODAY:
|
|
|
|
|
case Agd_MY_AGENDA:
|
2016-12-06 19:14:58 +01:00
|
|
|
|
Agd_PutFormsToRemEditOneEvent (&AgdEvent);
|
|
|
|
|
break;
|
2016-12-06 21:08:28 +01:00
|
|
|
|
default:
|
|
|
|
|
break;
|
2016-12-06 19:14:58 +01:00
|
|
|
|
}
|
2016-12-02 00:24:16 +01:00
|
|
|
|
|
2016-11-30 22:49:48 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>");
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/* Text of the event */
|
2016-12-02 00:24:16 +01:00
|
|
|
|
Agd_GetEventTxtFromDB (&AgdEvent,Txt);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
|
|
|
|
Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to recpectful HTML
|
|
|
|
|
Str_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links
|
2016-12-12 23:10:11 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<td colspan=\"2\" class=\"LEFT_TOP COLOR%u\">"
|
2017-10-24 11:26:01 +02:00
|
|
|
|
"<div class=\"PAR %s\">%s</div>"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
"</td>"
|
|
|
|
|
"</tr>",
|
2016-12-12 23:10:11 +01:00
|
|
|
|
Gbl.RowEvenOdd,
|
2016-12-03 19:22:06 +01:00
|
|
|
|
AgdEvent.Hidden ? "DAT_LIGHT" :
|
|
|
|
|
"DAT",
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Txt);
|
|
|
|
|
|
|
|
|
|
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/******************* Put a link (form) to edit one event *********************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-03 19:22:06 +01:00
|
|
|
|
static void Agd_PutFormsToRemEditOneEvent (struct AgendaEvent *AgdEvent)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2016-12-01 19:28:52 +01:00
|
|
|
|
extern const char *Txt_Event_private_click_to_make_it_visible_to_the_users_of_your_courses;
|
|
|
|
|
extern const char *Txt_Event_visible_to_the_users_of_your_courses_click_to_make_it_private;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-03 19:22:06 +01:00
|
|
|
|
Gbl.Agenda.AgdCodToEdit = AgdEvent->AgdCod; // Used as parameter in contextual links
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Put form to remove event *****/
|
2017-06-11 19:13:28 +02:00
|
|
|
|
Ico_PutContextualIconToRemove (ActReqRemEvtMyAgd,Agd_PutCurrentParamsMyAgenda);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-03 19:22:06 +01:00
|
|
|
|
/***** Put form to hide/show event *****/
|
|
|
|
|
if (AgdEvent->Hidden)
|
2017-06-11 19:13:28 +02:00
|
|
|
|
Ico_PutContextualIconToUnhide (ActShoEvtMyAgd,Agd_PutCurrentParamsMyAgenda);
|
2016-12-03 19:22:06 +01:00
|
|
|
|
else
|
2017-06-11 19:13:28 +02:00
|
|
|
|
Ico_PutContextualIconToHide (ActHidEvtMyAgd,Agd_PutCurrentParamsMyAgenda);
|
2016-12-03 19:22:06 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Put form to edit event *****/
|
2017-06-11 19:13:28 +02:00
|
|
|
|
Ico_PutContextualIconToEdit (ActEdiOneEvtMyAgd,Agd_PutCurrentParamsMyAgenda);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-03 19:22:06 +01:00
|
|
|
|
/***** Put form to make event public/private *****/
|
2016-12-06 19:50:32 +01:00
|
|
|
|
if (AgdEvent->Public)
|
2017-04-17 19:03:21 +02:00
|
|
|
|
Lay_PutContextualLink (ActPrvEvtMyAgd,NULL,Agd_PutCurrentParamsMyAgenda,
|
2016-12-06 19:50:32 +01:00
|
|
|
|
"unlock-on64x64.png",
|
|
|
|
|
Txt_Event_visible_to_the_users_of_your_courses_click_to_make_it_private,NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
else
|
2017-04-17 19:03:21 +02:00
|
|
|
|
Lay_PutContextualLink (ActPubEvtMyAgd,NULL,Agd_PutCurrentParamsMyAgenda,
|
2016-12-06 19:50:32 +01:00
|
|
|
|
"lock-on64x64.png",
|
|
|
|
|
Txt_Event_private_click_to_make_it_visible_to_the_users_of_your_courses,NULL,
|
|
|
|
|
NULL);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-04-13 20:09:22 +02:00
|
|
|
|
/****************** Parameters passed in my agenda forms *********************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-04-13 20:09:22 +02:00
|
|
|
|
static void Agd_PutCurrentParamsMyAgenda (void)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2017-04-13 20:09:22 +02:00
|
|
|
|
Agd_PutParamsMyAgenda (Gbl.Agenda.Past__FutureEvents,
|
|
|
|
|
Gbl.Agenda.PrivatPublicEvents,
|
|
|
|
|
Gbl.Agenda.HiddenVisiblEvents,
|
|
|
|
|
Gbl.Agenda.CurrentPage,
|
|
|
|
|
Gbl.Agenda.AgdCodToEdit);
|
2017-03-21 14:36:22 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The following function is called
|
|
|
|
|
when one or more parameters must be passed explicitely.
|
|
|
|
|
Each parameter is passed only if its value is distinct to default. */
|
|
|
|
|
|
2017-04-13 20:09:22 +02:00
|
|
|
|
void Agd_PutParamsMyAgenda (unsigned Past__FutureEvents,
|
|
|
|
|
unsigned PrivatPublicEvents,
|
|
|
|
|
unsigned HiddenVisiblEvents,
|
|
|
|
|
unsigned NumPage,
|
|
|
|
|
long AgdCodToEdit)
|
2017-03-21 14:36:22 +01:00
|
|
|
|
{
|
|
|
|
|
if (Past__FutureEvents != (Agd_DEFAULT_PAST___EVENTS |
|
|
|
|
|
Agd_DEFAULT_FUTURE_EVENTS))
|
|
|
|
|
Agd_PutHiddenParamPast__FutureEvents (Past__FutureEvents);
|
|
|
|
|
|
|
|
|
|
if (PrivatPublicEvents != (Agd_DEFAULT_PRIVAT_EVENTS |
|
|
|
|
|
Agd_DEFAULT_PUBLIC_EVENTS))
|
|
|
|
|
Agd_PutHiddenParamPrivatPublicEvents (PrivatPublicEvents);
|
|
|
|
|
|
|
|
|
|
if (HiddenVisiblEvents != (Agd_DEFAULT_HIDDEN_EVENTS |
|
|
|
|
|
Agd_DEFAULT_VISIBL_EVENTS))
|
|
|
|
|
Agd_PutHiddenParamHiddenVisiblEvents (HiddenVisiblEvents);
|
|
|
|
|
|
2017-04-13 20:09:22 +02:00
|
|
|
|
if (Gbl.Agenda.SelectedOrder != Agd_ORDER_DEFAULT)
|
|
|
|
|
Par_PutHiddenParamUnsigned ("Order",(unsigned) Gbl.Agenda.SelectedOrder);
|
|
|
|
|
|
|
|
|
|
if (NumPage > 1)
|
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_MY_AGENDA,NumPage);
|
2017-03-21 14:36:22 +01:00
|
|
|
|
|
|
|
|
|
if (AgdCodToEdit > 0)
|
|
|
|
|
Par_PutHiddenParamLong ("AgdCod",AgdCodToEdit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** Get parameter with the type or order in list of events ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Agd_GetParams (Agd_AgendaType_t AgendaType)
|
|
|
|
|
{
|
|
|
|
|
Pag_WhatPaginate_t WhatPaginate[Agd_NUM_AGENDA_TYPES] =
|
|
|
|
|
{
|
2017-03-21 14:52:07 +01:00
|
|
|
|
Pag_MY_AGENDA, // Agd_MY_AGENDA_TODAY, not used
|
|
|
|
|
Pag_MY_AGENDA, // Agd_MY_AGENDA
|
|
|
|
|
Pag_ANOTHER_AGENDA, // Agd_ANOTHER_AGENDA_TODAY, not used
|
|
|
|
|
Pag_ANOTHER_AGENDA, // Agd_ANOTHER_AGENDA
|
2017-03-21 14:36:22 +01:00
|
|
|
|
};
|
|
|
|
|
|
2017-03-21 14:52:07 +01:00
|
|
|
|
if (AgendaType == Agd_MY_AGENDA)
|
2017-03-21 14:36:22 +01:00
|
|
|
|
{
|
|
|
|
|
Agd_GetParamsPast__FutureEvents ();
|
|
|
|
|
Agd_GetParamsPrivatPublicEvents ();
|
|
|
|
|
Agd_GetParamsHiddenVisiblEvents ();
|
|
|
|
|
}
|
|
|
|
|
Agd_GetParamEventOrder ();
|
2017-04-13 20:09:22 +02:00
|
|
|
|
Gbl.Agenda.CurrentPage = Pag_GetParamPagNum (WhatPaginate[AgendaType]);
|
2017-03-21 14:36:22 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****** Put a hidden parameter with the type of order in list of events ******/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Agd_PutHiddenParamEventsOrder (void)
|
|
|
|
|
{
|
|
|
|
|
if (Gbl.Agenda.SelectedOrder != Agd_ORDER_DEFAULT)
|
|
|
|
|
Par_PutHiddenParamUnsigned ("Order",(unsigned) Gbl.Agenda.SelectedOrder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** Get parameter with the type or order in list of events ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Agd_GetParamEventOrder (void)
|
|
|
|
|
{
|
|
|
|
|
static bool AlreadyGot = false;
|
|
|
|
|
|
|
|
|
|
if (!AlreadyGot)
|
|
|
|
|
{
|
|
|
|
|
Gbl.Agenda.SelectedOrder = (Agd_Order_t)
|
|
|
|
|
Par_GetParToUnsignedLong ("Order",
|
|
|
|
|
0,
|
|
|
|
|
Agd_NUM_ORDERS - 1,
|
|
|
|
|
(unsigned long) Agd_ORDER_DEFAULT);
|
|
|
|
|
AlreadyGot = true;
|
|
|
|
|
}
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-02 00:24:16 +01:00
|
|
|
|
/************************* Get list of agenda events *************************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-22 01:14:48 +01:00
|
|
|
|
#define Agd_MAX_BYTES_SUBQUERY 128
|
|
|
|
|
|
2016-12-02 00:24:16 +01:00
|
|
|
|
static void Agd_GetListEvents (Agd_AgendaType_t AgendaType)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2017-03-22 01:14:48 +01:00
|
|
|
|
char UsrSubQuery[Agd_MAX_BYTES_SUBQUERY];
|
|
|
|
|
char Past__FutureEventsSubQuery[Agd_MAX_BYTES_SUBQUERY];
|
|
|
|
|
char PrivatPublicEventsSubQuery[Agd_MAX_BYTES_SUBQUERY];
|
|
|
|
|
char HiddenVisiblEventsSubQuery[Agd_MAX_BYTES_SUBQUERY];
|
|
|
|
|
char OrderBySubQuery[Agd_MAX_BYTES_SUBQUERY];
|
|
|
|
|
char Query[128 + Agd_MAX_BYTES_SUBQUERY * 5];
|
2016-11-30 22:49:48 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned long NumRows;
|
2016-12-02 00:24:16 +01:00
|
|
|
|
unsigned NumEvent;
|
2017-03-22 01:14:48 +01:00
|
|
|
|
bool DoQuery = true;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2017-03-22 01:14:48 +01:00
|
|
|
|
/***** Initialize list of events *****/
|
|
|
|
|
Agd_FreeListEvents ();
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get list of events from database *****/
|
2017-03-22 01:14:48 +01:00
|
|
|
|
/* Build events subqueries */
|
2016-12-02 00:24:16 +01:00
|
|
|
|
switch (AgendaType)
|
|
|
|
|
{
|
2017-03-21 14:52:07 +01:00
|
|
|
|
case Agd_MY_AGENDA_TODAY:
|
|
|
|
|
case Agd_MY_AGENDA:
|
2017-03-22 01:14:48 +01:00
|
|
|
|
if (Gbl.Agenda.Past__FutureEvents == 0 ||
|
|
|
|
|
Gbl.Agenda.PrivatPublicEvents == 0 ||
|
|
|
|
|
Gbl.Agenda.HiddenVisiblEvents == 0) // All selectors are off
|
|
|
|
|
DoQuery = false; // Nothing to get from database
|
|
|
|
|
else
|
2017-03-21 16:45:26 +01:00
|
|
|
|
{
|
2017-03-24 01:09:27 +01:00
|
|
|
|
sprintf (UsrSubQuery,"UsrCod=%ld",Gbl.Usrs.Me.UsrDat.UsrCod);
|
2017-03-22 01:14:48 +01:00
|
|
|
|
if (AgendaType == Agd_MY_AGENDA_TODAY)
|
|
|
|
|
Str_Copy (Past__FutureEventsSubQuery,
|
|
|
|
|
" AND DATE(StartTime)<=CURDATE()"
|
|
|
|
|
" AND DATE(EndTime)>=CURDATE()",
|
|
|
|
|
Agd_MAX_BYTES_SUBQUERY); // Today events
|
|
|
|
|
else
|
|
|
|
|
switch (Gbl.Agenda.Past__FutureEvents)
|
|
|
|
|
{
|
|
|
|
|
case (1 << Agd_PAST___EVENTS):
|
|
|
|
|
Str_Copy (Past__FutureEventsSubQuery,
|
|
|
|
|
" AND DATE(StartTime)<=CURDATE()",
|
|
|
|
|
Agd_MAX_BYTES_SUBQUERY); // Past and today events
|
|
|
|
|
break;
|
|
|
|
|
case (1 << Agd_FUTURE_EVENTS):
|
|
|
|
|
Str_Copy (Past__FutureEventsSubQuery,
|
|
|
|
|
" AND DATE(EndTime)>=CURDATE()",
|
|
|
|
|
Agd_MAX_BYTES_SUBQUERY); // Today and future events
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Past__FutureEventsSubQuery[0] = '\0'; // All events
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
switch (Gbl.Agenda.PrivatPublicEvents)
|
|
|
|
|
{
|
|
|
|
|
case (1 << Agd_PRIVAT_EVENTS):
|
|
|
|
|
Str_Copy (PrivatPublicEventsSubQuery," AND Public='N'",
|
|
|
|
|
Agd_MAX_BYTES_SUBQUERY); // Private events
|
|
|
|
|
break;
|
|
|
|
|
case (1 << Agd_PUBLIC_EVENTS):
|
|
|
|
|
Str_Copy (PrivatPublicEventsSubQuery," AND Public='Y'",
|
|
|
|
|
Agd_MAX_BYTES_SUBQUERY); // Public events
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
PrivatPublicEventsSubQuery[0] = '\0'; // All events
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
switch (Gbl.Agenda.HiddenVisiblEvents)
|
|
|
|
|
{
|
|
|
|
|
case (1 << Agd_HIDDEN_EVENTS):
|
|
|
|
|
Str_Copy (HiddenVisiblEventsSubQuery," AND Hidden='Y'",
|
|
|
|
|
Agd_MAX_BYTES_SUBQUERY); // Hidden events
|
|
|
|
|
break;
|
|
|
|
|
case (1 << Agd_VISIBL_EVENTS):
|
|
|
|
|
Str_Copy (HiddenVisiblEventsSubQuery," AND Hidden='N'",
|
|
|
|
|
Agd_MAX_BYTES_SUBQUERY); // Visible events
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
HiddenVisiblEventsSubQuery[0] = '\0'; // All events
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-03-21 16:45:26 +01:00
|
|
|
|
}
|
2016-12-06 21:26:02 +01:00
|
|
|
|
break;
|
2017-03-21 14:52:07 +01:00
|
|
|
|
case Agd_ANOTHER_AGENDA_TODAY:
|
|
|
|
|
case Agd_ANOTHER_AGENDA:
|
2017-03-24 01:09:27 +01:00
|
|
|
|
sprintf (UsrSubQuery,"UsrCod=%ld",Gbl.Usrs.Other.UsrDat.UsrCod);
|
2017-03-22 01:14:48 +01:00
|
|
|
|
if (AgendaType == Agd_ANOTHER_AGENDA_TODAY)
|
|
|
|
|
Str_Copy (Past__FutureEventsSubQuery,
|
|
|
|
|
" AND DATE(StartTime)<=CURDATE()"
|
|
|
|
|
" AND DATE(EndTime)>=CURDATE()",
|
|
|
|
|
Agd_MAX_BYTES_SUBQUERY); // Today events
|
|
|
|
|
else
|
|
|
|
|
Str_Copy (Past__FutureEventsSubQuery,
|
|
|
|
|
" AND DATE(EndTime)>=CURDATE()",
|
|
|
|
|
Agd_MAX_BYTES_SUBQUERY); // Today and future events
|
|
|
|
|
Str_Copy (PrivatPublicEventsSubQuery," AND Public='Y'",
|
|
|
|
|
Agd_MAX_BYTES_SUBQUERY); // Public events
|
|
|
|
|
Str_Copy (HiddenVisiblEventsSubQuery," AND Hidden='N'",
|
|
|
|
|
Agd_MAX_BYTES_SUBQUERY); // Visible events
|
2016-12-02 00:24:16 +01:00
|
|
|
|
}
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2017-03-22 01:14:48 +01:00
|
|
|
|
if (DoQuery)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2017-03-22 01:14:48 +01:00
|
|
|
|
/* Build order subquery */
|
|
|
|
|
switch (Gbl.Agenda.SelectedOrder)
|
|
|
|
|
{
|
|
|
|
|
case Agd_ORDER_BY_START_DATE:
|
|
|
|
|
Str_Copy (OrderBySubQuery,"StartTime,"
|
|
|
|
|
"EndTime,"
|
|
|
|
|
"Event,"
|
|
|
|
|
"Location",
|
|
|
|
|
Agd_MAX_BYTES_SUBQUERY);
|
|
|
|
|
break;
|
|
|
|
|
case Agd_ORDER_BY_END_DATE:
|
|
|
|
|
Str_Copy (OrderBySubQuery,"EndTime,"
|
|
|
|
|
"StartTime,"
|
|
|
|
|
"Event,"
|
|
|
|
|
"Location",
|
|
|
|
|
Agd_MAX_BYTES_SUBQUERY);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2017-03-22 01:14:48 +01:00
|
|
|
|
/* Build full query */
|
|
|
|
|
sprintf (Query,"SELECT AgdCod FROM agendas"
|
|
|
|
|
" WHERE %s%s%s%s"
|
|
|
|
|
" ORDER BY %s",
|
|
|
|
|
UsrSubQuery,
|
|
|
|
|
Past__FutureEventsSubQuery,
|
|
|
|
|
PrivatPublicEventsSubQuery,
|
|
|
|
|
HiddenVisiblEventsSubQuery,
|
|
|
|
|
OrderBySubQuery);
|
|
|
|
|
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get agenda events");
|
|
|
|
|
|
|
|
|
|
if (NumRows) // Events found...
|
|
|
|
|
{
|
|
|
|
|
Gbl.Agenda.Num = (unsigned) NumRows;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2017-03-22 01:14:48 +01:00
|
|
|
|
/***** Create list of events *****/
|
|
|
|
|
if ((Gbl.Agenda.LstAgdCods = (long *) calloc (NumRows,sizeof (long))) == NULL)
|
|
|
|
|
Lay_ShowErrorAndExit ("Not enough memory to store list of agenda events.");
|
|
|
|
|
|
|
|
|
|
/***** Get the events codes *****/
|
|
|
|
|
for (NumEvent = 0;
|
|
|
|
|
NumEvent < Gbl.Agenda.Num;
|
|
|
|
|
NumEvent++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next event code */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
if ((Gbl.Agenda.LstAgdCods[NumEvent] = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
|
|
|
|
Lay_ShowErrorAndExit ("Error: wrong event code.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2016-12-02 00:24:16 +01:00
|
|
|
|
Gbl.Agenda.Num = 0;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-02 00:24:16 +01:00
|
|
|
|
Gbl.Agenda.LstIsRead = true;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/*********************** Get event data using its code ***********************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-02 00:24:16 +01:00
|
|
|
|
static void Agd_GetDataOfEventByCod (struct AgendaEvent *AgdEvent)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2016-12-03 19:22:06 +01:00
|
|
|
|
char Query[512];
|
2016-12-09 00:44:15 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Build query *****/
|
2016-12-09 00:44:15 +01:00
|
|
|
|
sprintf (Query,"SELECT AgdCod,Public,Hidden,"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
"UNIX_TIMESTAMP(StartTime),"
|
|
|
|
|
"UNIX_TIMESTAMP(EndTime),"
|
2016-12-02 10:45:53 +01:00
|
|
|
|
"NOW()>EndTime," // Past event?
|
|
|
|
|
"NOW()<StartTime," // Future event?
|
2016-12-01 01:39:06 +01:00
|
|
|
|
"Event,Location"
|
|
|
|
|
" FROM agendas"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE AgdCod=%ld AND UsrCod=%ld",
|
2016-12-02 00:24:16 +01:00
|
|
|
|
AgdEvent->AgdCod,AgdEvent->UsrCod);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get data of event from database *****/
|
2016-12-09 00:44:15 +01:00
|
|
|
|
if (DB_QuerySELECT (Query,&mysql_res,"can not get agenda event data")) // Event found...
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2016-12-02 10:45:53 +01:00
|
|
|
|
/* Get row:
|
|
|
|
|
row[0] AgdCod
|
2016-12-09 00:44:15 +01:00
|
|
|
|
row[1] Public
|
|
|
|
|
row[2] Hidden
|
|
|
|
|
row[3] UNIX_TIMESTAMP(StartTime)
|
|
|
|
|
row[4] UNIX_TIMESTAMP(EndTime)
|
|
|
|
|
row[5] NOW()>EndTime // Past event?
|
|
|
|
|
row[6] NOW()<StartTime // Future event?
|
|
|
|
|
row[7] Event
|
|
|
|
|
row[8] Location
|
2016-12-02 10:45:53 +01:00
|
|
|
|
*/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/* Get code of the event (row[0]) */
|
|
|
|
|
AgdEvent->AgdCod = Str_ConvertStrCodToLongCod (row[0]);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-09 00:44:15 +01:00
|
|
|
|
/* Get whether the event is public or not (row[1]) */
|
|
|
|
|
AgdEvent->Public = (row[1][0] == 'Y');
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-09 00:44:15 +01:00
|
|
|
|
/* Get whether the event is hidden or not (row[2]) */
|
|
|
|
|
AgdEvent->Hidden = (row[2][0] == 'Y');
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-09 00:44:15 +01:00
|
|
|
|
/* Get start date (row[3] holds the start UTC time) */
|
|
|
|
|
AgdEvent->TimeUTC[Agd_START_TIME] = Dat_GetUNIXTimeFromStr (row[3]);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-09 00:44:15 +01:00
|
|
|
|
/* Get end date (row[4] holds the end UTC time) */
|
|
|
|
|
AgdEvent->TimeUTC[Agd_END_TIME ] = Dat_GetUNIXTimeFromStr (row[4]);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-09 00:44:15 +01:00
|
|
|
|
/* Get whether the event is past, present or future (row(5), row[6]) */
|
|
|
|
|
AgdEvent->TimeStatus = ((row[5][0] == '1') ? Dat_PAST :
|
|
|
|
|
((row[6][0] == '1') ? Dat_FUTURE :
|
2016-12-03 19:22:06 +01:00
|
|
|
|
Dat_PRESENT));
|
2016-12-02 10:45:53 +01:00
|
|
|
|
|
2016-12-09 00:44:15 +01:00
|
|
|
|
/* Get the event (row[7]) */
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (AgdEvent->Event,row[7],
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Agd_MAX_BYTES_EVENT);
|
2016-12-03 19:22:06 +01:00
|
|
|
|
|
2016-12-09 00:44:15 +01:00
|
|
|
|
/* Get the event (row[8]) */
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (AgdEvent->Location,row[8],
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Agd_MAX_BYTES_LOCATION);
|
2016-12-09 00:44:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/***** Clear all event data *****/
|
|
|
|
|
AgdEvent->AgdCod = -1L;
|
|
|
|
|
AgdEvent->Public = false;
|
|
|
|
|
AgdEvent->Hidden = false;
|
|
|
|
|
AgdEvent->TimeUTC[Agd_START_TIME] =
|
|
|
|
|
AgdEvent->TimeUTC[Agd_END_TIME ] = (time_t) 0;
|
|
|
|
|
AgdEvent->TimeStatus = Dat_FUTURE;
|
|
|
|
|
AgdEvent->Event[0] = '\0';
|
|
|
|
|
AgdEvent->Location[0] = '\0';
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-07 00:21:10 +02:00
|
|
|
|
/*****************************************************************************/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/*************************** Free list of events *****************************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
void Agd_FreeListEvents (void)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2016-12-02 00:24:16 +01:00
|
|
|
|
if (Gbl.Agenda.LstIsRead && Gbl.Agenda.LstAgdCods)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Free memory used by the list of events *****/
|
2016-12-02 00:24:16 +01:00
|
|
|
|
free ((void *) Gbl.Agenda.LstAgdCods);
|
|
|
|
|
Gbl.Agenda.LstAgdCods = NULL;
|
|
|
|
|
Gbl.Agenda.Num = 0;
|
|
|
|
|
Gbl.Agenda.LstIsRead = false;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/*********************** Get event text from database ************************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-01-17 03:10:43 +01:00
|
|
|
|
static void Agd_GetEventTxtFromDB (struct AgendaEvent *AgdEvent,
|
|
|
|
|
char Txt[Cns_MAX_BYTES_TEXT + 1])
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
|
|
|
|
char Query[512];
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned long NumRows;
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get text of event from database *****/
|
2016-12-01 01:39:06 +01:00
|
|
|
|
sprintf (Query,"SELECT Txt FROM agendas"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE AgdCod=%ld AND UsrCod=%ld",
|
2016-12-02 00:24:16 +01:00
|
|
|
|
AgdEvent->AgdCod,AgdEvent->UsrCod);
|
2016-12-01 00:53:50 +01:00
|
|
|
|
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get event text");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** The result of the query must have one row or none *****/
|
|
|
|
|
if (NumRows == 1)
|
|
|
|
|
{
|
|
|
|
|
/* Get info text */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (Txt,row[0],
|
|
|
|
|
Cns_MAX_BYTES_TEXT);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Txt[0] = '\0';
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
if (NumRows > 1)
|
2016-12-01 00:53:50 +01:00
|
|
|
|
Lay_ShowErrorAndExit ("Error when getting event text.");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/******************** Get parameter with code of event ***********************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
long Agd_GetParamAgdCod (void)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2017-01-28 20:32:50 +01:00
|
|
|
|
/***** Get code of event *****/
|
|
|
|
|
return Par_GetParToLong ("AgdCod");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/************** Ask for confirmation of removing of an event *****************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
void Agd_AskRemEvent (void)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2016-12-01 00:53:50 +01:00
|
|
|
|
extern const char *Txt_Do_you_really_want_to_remove_the_event_X;
|
|
|
|
|
extern const char *Txt_Remove_event;
|
|
|
|
|
struct AgendaEvent AgdEvent;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
2017-03-21 14:52:07 +01:00
|
|
|
|
Agd_GetParams (Agd_MY_AGENDA);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get event code *****/
|
|
|
|
|
if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L)
|
|
|
|
|
Lay_ShowErrorAndExit ("Code of event is missing.");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get data of the event from database *****/
|
2016-12-02 00:24:16 +01:00
|
|
|
|
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
2016-12-01 00:53:50 +01:00
|
|
|
|
Agd_GetDataOfEventByCod (&AgdEvent);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2017-04-28 10:44:28 +02:00
|
|
|
|
/***** Show question and button to remove event *****/
|
2017-05-11 21:53:37 +02:00
|
|
|
|
Gbl.Agenda.AgdCodToEdit = AgdEvent.AgdCod;
|
2017-05-10 10:25:01 +02:00
|
|
|
|
sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_event_X,
|
2017-04-28 10:44:28 +02:00
|
|
|
|
AgdEvent.Event);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlertAndButton (Ale_QUESTION,Gbl.Alert.Txt,
|
2017-05-25 14:25:22 +02:00
|
|
|
|
ActRemEvtMyAgd,NULL,NULL,
|
|
|
|
|
Agd_PutCurrentParamsMyAgenda,
|
2017-06-11 19:02:40 +02:00
|
|
|
|
Btn_REMOVE_BUTTON,Txt_Remove_event);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Show events again *****/
|
2016-12-02 00:24:16 +01:00
|
|
|
|
Agd_ShowMyAgenda ();
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/****************************** Remove an event ******************************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
void Agd_RemoveEvent (void)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2016-12-01 01:39:06 +01:00
|
|
|
|
extern const char *Txt_Event_X_removed;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
char Query[512];
|
2016-12-01 00:53:50 +01:00
|
|
|
|
struct AgendaEvent AgdEvent;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get event code *****/
|
|
|
|
|
if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L)
|
|
|
|
|
Lay_ShowErrorAndExit ("Code of event is missing.");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get data of the event from database *****/
|
2016-12-02 00:24:16 +01:00
|
|
|
|
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
2016-12-09 00:44:15 +01:00
|
|
|
|
Agd_GetDataOfEventByCod (&AgdEvent);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Remove event *****/
|
2016-12-01 01:39:06 +01:00
|
|
|
|
sprintf (Query,"DELETE FROM agendas"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE AgdCod=%ld AND UsrCod=%ld",
|
2016-12-09 00:44:15 +01:00
|
|
|
|
AgdEvent.AgdCod,AgdEvent.UsrCod);
|
2016-12-01 00:53:50 +01:00
|
|
|
|
DB_QueryDELETE (Query,"can not remove event");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2017-05-10 10:25:01 +02:00
|
|
|
|
sprintf (Gbl.Alert.Txt,Txt_Event_X_removed,AgdEvent.Event);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Show events again *****/
|
2016-12-02 00:24:16 +01:00
|
|
|
|
Agd_ShowMyAgenda ();
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-03 19:22:06 +01:00
|
|
|
|
/********************************* Hide event ********************************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-03 19:22:06 +01:00
|
|
|
|
void Agd_HideEvent (void)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2016-12-03 19:22:06 +01:00
|
|
|
|
extern const char *Txt_Event_X_is_now_hidden;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
char Query[512];
|
2016-12-01 00:53:50 +01:00
|
|
|
|
struct AgendaEvent AgdEvent;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get event code *****/
|
|
|
|
|
if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L)
|
|
|
|
|
Lay_ShowErrorAndExit ("Code of event is missing.");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get data of the event from database *****/
|
2016-12-02 00:24:16 +01:00
|
|
|
|
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
2016-12-01 00:53:50 +01:00
|
|
|
|
Agd_GetDataOfEventByCod (&AgdEvent);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-03 17:34:07 +01:00
|
|
|
|
/***** Set event private *****/
|
2016-12-03 19:22:06 +01:00
|
|
|
|
sprintf (Query,"UPDATE agendas SET Hidden='Y'"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE AgdCod=%ld AND UsrCod=%ld",
|
2016-12-09 00:44:15 +01:00
|
|
|
|
AgdEvent.AgdCod,AgdEvent.UsrCod);
|
2016-12-03 19:22:06 +01:00
|
|
|
|
DB_QueryUPDATE (Query,"can not hide event");
|
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2017-05-10 10:25:01 +02:00
|
|
|
|
sprintf (Gbl.Alert.Txt,Txt_Event_X_is_now_hidden,AgdEvent.Event);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
|
2016-12-03 19:22:06 +01:00
|
|
|
|
|
|
|
|
|
/***** Show events again *****/
|
|
|
|
|
Agd_ShowMyAgenda ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-06 19:14:58 +01:00
|
|
|
|
/****************************** Unhide event *********************************/
|
2016-12-03 19:22:06 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-06 19:14:58 +01:00
|
|
|
|
void Agd_UnhideEvent (void)
|
2016-12-03 19:22:06 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Event_X_is_now_visible;
|
|
|
|
|
char Query[256];
|
|
|
|
|
struct AgendaEvent AgdEvent;
|
|
|
|
|
|
|
|
|
|
/***** Get event code *****/
|
|
|
|
|
if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L)
|
|
|
|
|
Lay_ShowErrorAndExit ("Code of event is missing.");
|
|
|
|
|
|
|
|
|
|
/***** Get data of the event from database *****/
|
|
|
|
|
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
|
|
|
|
Agd_GetDataOfEventByCod (&AgdEvent);
|
|
|
|
|
|
|
|
|
|
/***** Set event public *****/
|
|
|
|
|
sprintf (Query,"UPDATE agendas SET Hidden='N'"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE AgdCod=%ld AND UsrCod=%ld",
|
2016-12-09 00:44:15 +01:00
|
|
|
|
AgdEvent.AgdCod,AgdEvent.UsrCod);
|
2016-12-03 19:22:06 +01:00
|
|
|
|
DB_QueryUPDATE (Query,"can not show event");
|
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2017-05-10 10:25:01 +02:00
|
|
|
|
sprintf (Gbl.Alert.Txt,Txt_Event_X_is_now_visible,
|
2016-12-03 19:22:06 +01:00
|
|
|
|
AgdEvent.Event);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
|
2016-12-03 19:22:06 +01:00
|
|
|
|
|
|
|
|
|
/***** Show events again *****/
|
|
|
|
|
Agd_ShowMyAgenda ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Make event private ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Agd_MakeEventPrivate (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Event_X_is_now_private;
|
|
|
|
|
char Query[512];
|
|
|
|
|
struct AgendaEvent AgdEvent;
|
|
|
|
|
|
|
|
|
|
/***** Get event code *****/
|
|
|
|
|
if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L)
|
|
|
|
|
Lay_ShowErrorAndExit ("Code of event is missing.");
|
|
|
|
|
|
|
|
|
|
/***** Get data of the event from database *****/
|
|
|
|
|
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
|
|
|
|
Agd_GetDataOfEventByCod (&AgdEvent);
|
|
|
|
|
|
|
|
|
|
/***** Make event private *****/
|
2016-12-03 17:34:07 +01:00
|
|
|
|
sprintf (Query,"UPDATE agendas SET Public='N'"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE AgdCod=%ld AND UsrCod=%ld",
|
2016-12-09 00:44:15 +01:00
|
|
|
|
AgdEvent.AgdCod,AgdEvent.UsrCod);
|
2016-12-03 19:22:06 +01:00
|
|
|
|
DB_QueryUPDATE (Query,"can not make event private");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2017-05-10 10:25:01 +02:00
|
|
|
|
sprintf (Gbl.Alert.Txt,Txt_Event_X_is_now_private,AgdEvent.Event);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Show events again *****/
|
2016-12-02 00:24:16 +01:00
|
|
|
|
Agd_ShowMyAgenda ();
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-03 19:22:06 +01:00
|
|
|
|
/******** Make event public (make it visible to users of my courses) *********/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-03 19:22:06 +01:00
|
|
|
|
void Agd_MakeEventPublic (void)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2016-12-01 19:28:52 +01:00
|
|
|
|
extern const char *Txt_Event_X_is_now_visible_to_users_of_your_courses;
|
2016-12-01 16:49:12 +01:00
|
|
|
|
char Query[256];
|
2016-12-01 00:53:50 +01:00
|
|
|
|
struct AgendaEvent AgdEvent;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get event code *****/
|
|
|
|
|
if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L)
|
|
|
|
|
Lay_ShowErrorAndExit ("Code of event is missing.");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get data of the event from database *****/
|
2016-12-02 00:24:16 +01:00
|
|
|
|
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
2016-12-01 00:53:50 +01:00
|
|
|
|
Agd_GetDataOfEventByCod (&AgdEvent);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-03 19:22:06 +01:00
|
|
|
|
/***** Make event public *****/
|
2016-12-03 17:34:07 +01:00
|
|
|
|
sprintf (Query,"UPDATE agendas SET Public='Y'"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE AgdCod=%ld AND UsrCod=%ld",
|
2016-12-09 00:44:15 +01:00
|
|
|
|
AgdEvent.AgdCod,AgdEvent.UsrCod);
|
2016-12-03 19:22:06 +01:00
|
|
|
|
DB_QueryUPDATE (Query,"can not make event public");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2017-05-10 10:25:01 +02:00
|
|
|
|
sprintf (Gbl.Alert.Txt,Txt_Event_X_is_now_visible_to_users_of_your_courses,
|
2016-12-01 16:49:12 +01:00
|
|
|
|
AgdEvent.Event);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Show events again *****/
|
2016-12-02 00:24:16 +01:00
|
|
|
|
Agd_ShowMyAgenda ();
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-07 00:21:10 +02:00
|
|
|
|
/*****************************************************************************/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/******************** Put a form to create a new event ***********************/
|
2016-07-07 00:21:10 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
void Agd_RequestCreatOrEditEvent (void)
|
2016-07-07 00:21:10 +02:00
|
|
|
|
{
|
2016-12-01 00:53:50 +01:00
|
|
|
|
extern const char *Hlp_PROFILE_Agenda_new_event;
|
|
|
|
|
extern const char *Hlp_PROFILE_Agenda_edit_event;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
extern const char *The_ClassForm[The_NUM_THEMES];
|
|
|
|
|
extern const char *Txt_New_event;
|
2016-12-01 00:53:50 +01:00
|
|
|
|
extern const char *Txt_Edit_event;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
extern const char *Txt_Location;
|
|
|
|
|
extern const char *Txt_Event;
|
|
|
|
|
extern const char *Txt_Description;
|
|
|
|
|
extern const char *Txt_Create_event;
|
|
|
|
|
extern const char *Txt_Save;
|
2016-12-01 00:53:50 +01:00
|
|
|
|
struct AgendaEvent AgdEvent;
|
|
|
|
|
bool ItsANewEvent;
|
2017-01-17 03:10:43 +01:00
|
|
|
|
char Txt[Cns_MAX_BYTES_TEXT + 1];
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
2017-03-21 14:52:07 +01:00
|
|
|
|
Agd_GetParams (Agd_MY_AGENDA);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get the code of the event *****/
|
|
|
|
|
ItsANewEvent = ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get from the database the data of the event *****/
|
2016-12-09 00:44:15 +01:00
|
|
|
|
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
2016-12-01 00:53:50 +01:00
|
|
|
|
if (ItsANewEvent)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/* Initialize to empty event */
|
|
|
|
|
AgdEvent.AgdCod = -1L;
|
2016-12-02 10:45:53 +01:00
|
|
|
|
AgdEvent.TimeUTC[Agd_START_TIME] = Gbl.StartExecutionTimeUTC;
|
|
|
|
|
AgdEvent.TimeUTC[Agd_END_TIME ] = Gbl.StartExecutionTimeUTC + (2 * 60 * 60); // +2 hours
|
|
|
|
|
AgdEvent.TimeStatus = Dat_FUTURE;
|
2016-12-01 00:53:50 +01:00
|
|
|
|
AgdEvent.Event[0] = '\0';
|
|
|
|
|
AgdEvent.Location[0] = '\0';
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/* Get data of the event from database */
|
|
|
|
|
Agd_GetDataOfEventByCod (&AgdEvent);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/* Get text of the event from database */
|
2016-12-02 00:24:16 +01:00
|
|
|
|
Agd_GetEventTxtFromDB (&AgdEvent,Txt);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Start form *****/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
if (ItsANewEvent)
|
2017-03-21 14:36:22 +01:00
|
|
|
|
{
|
2016-12-01 01:39:06 +01:00
|
|
|
|
Act_FormStart (ActNewEvtMyAgd);
|
2017-03-21 14:36:22 +01:00
|
|
|
|
Gbl.Agenda.AgdCodToEdit = -1L;
|
|
|
|
|
}
|
2016-11-30 22:49:48 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
2016-12-01 01:39:06 +01:00
|
|
|
|
Act_FormStart (ActChgEvtMyAgd);
|
2017-03-21 14:36:22 +01:00
|
|
|
|
Gbl.Agenda.AgdCodToEdit = AgdEvent.AgdCod;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
2017-04-13 20:09:22 +02:00
|
|
|
|
Agd_PutCurrentParamsMyAgenda ();
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Start box and table *****/
|
2017-06-11 22:26:40 +02:00
|
|
|
|
if (ItsANewEvent)
|
|
|
|
|
Box_StartBoxTable (NULL,Txt_New_event,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_PROFILE_Agenda_new_event,Box_NOT_CLOSABLE,2);
|
2017-06-11 22:26:40 +02:00
|
|
|
|
else
|
|
|
|
|
Box_StartBoxTable (NULL,Txt_Edit_event,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_PROFILE_Agenda_edit_event,Box_NOT_CLOSABLE,2);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Event *****/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2016-12-20 21:46:59 +01:00
|
|
|
|
"<td class=\"RIGHT_MIDDLE\">"
|
|
|
|
|
"<label for=\"Event\" class=\"%s\">%s:</label>"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
"</td>"
|
|
|
|
|
"<td class=\"LEFT_MIDDLE\">"
|
2016-12-20 21:46:59 +01:00
|
|
|
|
"<input type=\"text\" id=\"Event\" name=\"Event\""
|
2016-11-30 22:49:48 +01:00
|
|
|
|
" size=\"45\" maxlength=\"%u\" value=\"%s\""
|
|
|
|
|
" required=\"required\" />"
|
|
|
|
|
"</td>"
|
|
|
|
|
"</tr>",
|
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],
|
2016-12-01 00:53:50 +01:00
|
|
|
|
Txt_Event,
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Agd_MAX_CHARS_EVENT,AgdEvent.Event);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Location *****/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2016-12-20 21:46:59 +01:00
|
|
|
|
"<td class=\"RIGHT_MIDDLE\">"
|
|
|
|
|
"<label for=\"Location\" class=\"%s\">%s:</label>"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
"</td>"
|
|
|
|
|
"<td class=\"LEFT_MIDDLE\">"
|
2016-12-20 21:46:59 +01:00
|
|
|
|
"<input type=\"text\" id=\"Location\" name=\"Location\""
|
2016-11-30 22:49:48 +01:00
|
|
|
|
" size=\"45\" maxlength=\"%u\" value=\"%s\""
|
|
|
|
|
" required=\"required\" />"
|
|
|
|
|
"</td>"
|
|
|
|
|
"</tr>",
|
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],
|
2016-12-01 00:53:50 +01:00
|
|
|
|
Txt_Location,
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Agd_MAX_CHARS_LOCATION,AgdEvent.Location);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Start and end dates *****/
|
2016-12-03 20:08:01 +01:00
|
|
|
|
Dat_PutFormStartEndClientLocalDateTimes (AgdEvent.TimeUTC,
|
|
|
|
|
Dat_FORM_SECONDS_OFF);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Text *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2016-12-20 21:46:59 +01:00
|
|
|
|
"<td class=\"RIGHT_TOP\">"
|
|
|
|
|
"<label for=\"Txt\" class=\"%s\">%s:</label>"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
"</td>"
|
|
|
|
|
"<td class=\"LEFT_TOP\">"
|
2016-12-20 21:46:59 +01:00
|
|
|
|
"<textarea id=\"Txt\" name=\"Txt\""
|
|
|
|
|
" cols=\"60\" rows=\"10\">",
|
2016-11-30 22:49:48 +01:00
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],
|
|
|
|
|
Txt_Description);
|
2016-12-01 00:53:50 +01:00
|
|
|
|
if (!ItsANewEvent)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"%s",Txt);
|
|
|
|
|
fprintf (Gbl.F.Out,"</textarea>"
|
|
|
|
|
"</td>"
|
|
|
|
|
"</tr>");
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End table, send button and end box *****/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
if (ItsANewEvent)
|
2017-06-11 19:02:40 +02:00
|
|
|
|
Box_EndBoxTableWithButton (Btn_CREATE_BUTTON,Txt_Create_event);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
else
|
2017-06-11 19:02:40 +02:00
|
|
|
|
Box_EndBoxTableWithButton (Btn_CONFIRM_BUTTON,Txt_Save);
|
2017-06-12 14:16:33 +02:00
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Act_FormEnd ();
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Show current events, if any *****/
|
2016-12-06 03:10:06 +01:00
|
|
|
|
Agd_ShowMyAgenda ();
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/********************* Receive form to create a new event ********************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
void Agd_RecFormEvent (void)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2016-12-01 00:53:50 +01:00
|
|
|
|
extern const char *Txt_You_must_specify_the_title_of_the_event;
|
|
|
|
|
extern const char *Txt_Created_new_event_X;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
extern const char *Txt_The_event_has_been_modified;
|
2016-12-09 00:44:15 +01:00
|
|
|
|
struct AgendaEvent AgdEvent;
|
2016-12-01 00:53:50 +01:00
|
|
|
|
bool ItsANewEvent;
|
|
|
|
|
bool NewEventIsCorrect = true;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char Txt[Cns_MAX_BYTES_TEXT + 1];
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-09 18:22:25 +01:00
|
|
|
|
/***** Set author of the event *****/
|
|
|
|
|
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get the code of the event *****/
|
2016-12-09 00:44:15 +01:00
|
|
|
|
ItsANewEvent = ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Get start/end date-times *****/
|
2016-12-09 00:44:15 +01:00
|
|
|
|
AgdEvent.TimeUTC[Agd_START_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC");
|
|
|
|
|
AgdEvent.TimeUTC[Agd_END_TIME ] = Dat_GetTimeUTCFromForm ("EndTimeUTC" );
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get event *****/
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Par_GetParToText ("Location",AgdEvent.Location,Agd_MAX_BYTES_LOCATION);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Get event *****/
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Par_GetParToText ("Event",AgdEvent.Event,Agd_MAX_BYTES_EVENT);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Get text *****/
|
|
|
|
|
Par_GetParToHTML ("Txt",Txt,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous)
|
|
|
|
|
|
|
|
|
|
/***** Adjust dates *****/
|
2016-12-09 00:44:15 +01:00
|
|
|
|
if (AgdEvent.TimeUTC[Agd_START_TIME] == 0)
|
|
|
|
|
AgdEvent.TimeUTC[Agd_START_TIME] = Gbl.StartExecutionTimeUTC;
|
|
|
|
|
if (AgdEvent.TimeUTC[Agd_END_TIME] == 0)
|
2017-01-28 15:58:46 +01:00
|
|
|
|
AgdEvent.TimeUTC[Agd_END_TIME] = AgdEvent.TimeUTC[Agd_START_TIME] + 2 * 60 * 60; // +2 hours
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Check if event is correct *****/
|
2016-12-09 00:44:15 +01:00
|
|
|
|
if (!AgdEvent.Location[0]) // If there is no event
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2016-12-01 00:53:50 +01:00
|
|
|
|
NewEventIsCorrect = false;
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_title_of_the_event);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Check if event is correct *****/
|
2017-03-22 01:39:43 +01:00
|
|
|
|
if (!AgdEvent.Event[0]) // If there is no event
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2016-12-01 00:53:50 +01:00
|
|
|
|
NewEventIsCorrect = false;
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_title_of_the_event);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Create a new event or update an existing one *****/
|
|
|
|
|
if (NewEventIsCorrect)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2016-12-01 00:53:50 +01:00
|
|
|
|
if (ItsANewEvent)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2016-12-09 00:44:15 +01:00
|
|
|
|
Agd_CreateEvent (&AgdEvent,Txt); // Add new event to database
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Write success message *****/
|
2017-05-10 10:25:01 +02:00
|
|
|
|
sprintf (Gbl.Alert.Txt,Txt_Created_new_event_X,AgdEvent.Event);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-12-09 00:44:15 +01:00
|
|
|
|
Agd_UpdateEvent (&AgdEvent,Txt);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Write success message *****/
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_event_has_been_modified);
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free memory for list of selected groups */
|
|
|
|
|
Grp_FreeListCodSelectedGrps ();
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Show events again *****/
|
2016-12-02 00:24:16 +01:00
|
|
|
|
Agd_ShowMyAgenda ();
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
// TODO: The form should be filled with partial data, now is always empty
|
2016-12-01 00:53:50 +01:00
|
|
|
|
Agd_RequestCreatOrEditEvent ();
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/************************** Create a new event *******************************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
static void Agd_CreateEvent (struct AgendaEvent *AgdEvent,const char *Txt)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2017-03-09 01:33:09 +01:00
|
|
|
|
char Query[1024 +
|
|
|
|
|
Agd_MAX_BYTES_EVENT +
|
|
|
|
|
Agd_MAX_BYTES_LOCATION +
|
|
|
|
|
Cns_MAX_BYTES_TEXT];
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Create a new event *****/
|
2016-12-01 01:39:06 +01:00
|
|
|
|
sprintf (Query,"INSERT INTO agendas"
|
|
|
|
|
" (UsrCod,StartTime,EndTime,Event,Location,Txt)"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
" VALUES"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" (%ld,FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
"'%s','%s','%s')",
|
2016-12-09 00:44:15 +01:00
|
|
|
|
AgdEvent->UsrCod,
|
2016-12-02 10:45:53 +01:00
|
|
|
|
AgdEvent->TimeUTC[Agd_START_TIME],
|
|
|
|
|
AgdEvent->TimeUTC[Agd_END_TIME ],
|
2016-12-01 00:53:50 +01:00
|
|
|
|
AgdEvent->Event,
|
2016-12-01 01:39:06 +01:00
|
|
|
|
AgdEvent->Location,
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Txt);
|
2016-12-01 00:53:50 +01:00
|
|
|
|
AgdEvent->AgdCod = DB_QueryINSERTandReturnCode (Query,"can not create new event");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/************************ Update an existing event ***************************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
static void Agd_UpdateEvent (struct AgendaEvent *AgdEvent,const char *Txt)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
2017-03-09 01:33:09 +01:00
|
|
|
|
char Query[1024 +
|
|
|
|
|
Agd_MAX_BYTES_EVENT +
|
|
|
|
|
Agd_MAX_BYTES_LOCATION +
|
|
|
|
|
Cns_MAX_BYTES_TEXT];
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Update the data of the event *****/
|
2016-12-01 01:39:06 +01:00
|
|
|
|
sprintf (Query,"UPDATE agendas SET "
|
2017-03-24 01:09:27 +01:00
|
|
|
|
"StartTime=FROM_UNIXTIME(%ld),"
|
|
|
|
|
"EndTime=FROM_UNIXTIME(%ld),"
|
2016-12-01 01:39:06 +01:00
|
|
|
|
"Event='%s',Location='%s',Txt='%s'"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE AgdCod=%ld AND UsrCod=%ld",
|
2016-12-02 10:45:53 +01:00
|
|
|
|
AgdEvent->TimeUTC[Agd_START_TIME],
|
|
|
|
|
AgdEvent->TimeUTC[Agd_END_TIME ],
|
2016-12-01 01:39:06 +01:00
|
|
|
|
AgdEvent->Event,AgdEvent->Location,Txt,
|
2016-12-09 00:44:15 +01:00
|
|
|
|
AgdEvent->AgdCod,AgdEvent->UsrCod);
|
2016-12-01 00:53:50 +01:00
|
|
|
|
DB_QueryUPDATE (Query,"can not update event");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/********************** Remove all the events of a user **********************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
void Agd_RemoveUsrEvents (long UsrCod)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
|
|
|
|
char Query[128];
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Remove events *****/
|
2017-03-24 01:09:27 +01:00
|
|
|
|
sprintf (Query,"DELETE FROM agendas WHERE UsrCod=%ld",UsrCod);
|
2016-12-01 00:53:50 +01:00
|
|
|
|
DB_QueryDELETE (Query,"can not remove all the events of a user");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/********************* Get number of events from a user **********************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
unsigned Agd_GetNumEventsFromUsr (long UsrCod)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
|
|
|
|
char Query[128];
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get number of events in a course from database *****/
|
2017-03-24 01:09:27 +01:00
|
|
|
|
sprintf (Query,"SELECT COUNT(*) FROM agendas WHERE UsrCod=%ld",
|
2016-11-30 22:49:48 +01:00
|
|
|
|
UsrCod);
|
2016-12-01 00:53:50 +01:00
|
|
|
|
return (unsigned) DB_QueryCOUNT (Query,"can not get number of events from user");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/********************** Get number of users with events **********************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
// Returns the number of users with events in a given scope
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
unsigned Agd_GetNumUsrsWithEvents (Sco_Scope_t Scope)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
|
|
|
|
char Query[1024];
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumUsrs;
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get number of courses with events from database *****/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
switch (Scope)
|
|
|
|
|
{
|
|
|
|
|
case Sco_SCOPE_SYS:
|
|
|
|
|
sprintf (Query,"SELECT COUNT(DISTINCT UsrCod)"
|
2016-12-01 01:39:06 +01:00
|
|
|
|
" FROM agendas"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE UsrCod>0");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
break;
|
|
|
|
|
case Sco_SCOPE_CTY:
|
2016-12-01 01:39:06 +01:00
|
|
|
|
sprintf (Query,"SELECT COUNT(DISTINCT agendas.UsrCod)"
|
|
|
|
|
" FROM institutions,centres,degrees,courses,crs_usr,agendas"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE institutions.CtyCod=%ld"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
" AND institutions.InsCod=centres.InsCod"
|
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.Status=0"
|
|
|
|
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
2016-12-01 01:39:06 +01:00
|
|
|
|
" AND crs_usr.UsrCod=agendas.UsrCod",
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Gbl.CurrentCty.Cty.CtyCod);
|
|
|
|
|
break;
|
|
|
|
|
case Sco_SCOPE_INS:
|
2016-12-01 01:39:06 +01:00
|
|
|
|
sprintf (Query,"SELECT COUNT(DISTINCT agendas.UsrCod)"
|
|
|
|
|
" FROM centres,degrees,courses,crs_usr,agendas"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE centres.InsCod=%ld"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.Status=0"
|
|
|
|
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
2016-12-01 01:39:06 +01:00
|
|
|
|
" AND crs_usr.UsrCod=agendas.UsrCod",
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Gbl.CurrentIns.Ins.InsCod);
|
|
|
|
|
break;
|
|
|
|
|
case Sco_SCOPE_CTR:
|
2016-12-01 01:39:06 +01:00
|
|
|
|
sprintf (Query,"SELECT COUNT(DISTINCT agendas.UsrCod)"
|
|
|
|
|
" FROM degrees,courses,crs_usr,agendas"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE degrees.CtrCod=%ld"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.Status=0"
|
|
|
|
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
2016-12-01 01:39:06 +01:00
|
|
|
|
" AND crs_usr.UsrCod=agendas.UsrCod",
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Gbl.CurrentCtr.Ctr.CtrCod);
|
|
|
|
|
break;
|
|
|
|
|
case Sco_SCOPE_DEG:
|
2016-12-01 01:39:06 +01:00
|
|
|
|
sprintf (Query,"SELECT COUNT(DISTINCT agendas.UsrCod)"
|
|
|
|
|
" FROM courses,crs_usr,agendas"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE courses.DegCod=%ld"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
" AND courses.Status=0"
|
|
|
|
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
2016-12-01 01:39:06 +01:00
|
|
|
|
" AND crs_usr.UsrCod=agendas.UsrCod",
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Gbl.CurrentDeg.Deg.DegCod);
|
|
|
|
|
break;
|
|
|
|
|
case Sco_SCOPE_CRS:
|
2016-12-01 01:39:06 +01:00
|
|
|
|
sprintf (Query,"SELECT COUNT(DISTINCT agendas.UsrCod)"
|
|
|
|
|
" FROM crs_usr,agendas"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE crs_usr.CrsCod=%ld"
|
2016-12-01 01:39:06 +01:00
|
|
|
|
" AND crs_usr.UsrCod=agendas.UsrCod",
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Gbl.CurrentCrs.Crs.CrsCod);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong scope.");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2016-12-01 00:53:50 +01:00
|
|
|
|
DB_QuerySELECT (Query,&mysql_res,"can not get number of users with events");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Get number of users *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
if (sscanf (row[0],"%u",&NumUsrs) != 1)
|
2016-12-01 00:53:50 +01:00
|
|
|
|
Lay_ShowErrorAndExit ("Error when getting number of users with events.");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return NumUsrs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/*************************** Get number of events ****************************/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
/*****************************************************************************/
|
2016-12-01 00:53:50 +01:00
|
|
|
|
// Returns the number of events in a given scope
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
unsigned Agd_GetNumEvents (Sco_Scope_t Scope)
|
2016-11-30 22:49:48 +01:00
|
|
|
|
{
|
|
|
|
|
char Query[1024];
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2016-12-01 00:53:50 +01:00
|
|
|
|
unsigned NumEvents;
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get number of events from database *****/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
switch (Scope)
|
|
|
|
|
{
|
|
|
|
|
case Sco_SCOPE_SYS:
|
|
|
|
|
sprintf (Query,"SELECT COUNT(*)"
|
2016-12-01 01:39:06 +01:00
|
|
|
|
" FROM agendas"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE UsrCod>0");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
break;
|
|
|
|
|
case Sco_SCOPE_CTY:
|
|
|
|
|
sprintf (Query,"SELECT COUNT(*)"
|
2016-12-01 01:39:06 +01:00
|
|
|
|
" FROM institutions,centres,degrees,courses,crs_usr,agendas"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE institutions.CtyCod=%ld"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
" AND institutions.InsCod=centres.InsCod"
|
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
2016-12-01 01:39:06 +01:00
|
|
|
|
" AND crs_usr.UsrCod=agendas.UsrCod",
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Gbl.CurrentCty.Cty.CtyCod);
|
|
|
|
|
break;
|
|
|
|
|
case Sco_SCOPE_INS:
|
|
|
|
|
sprintf (Query,"SELECT COUNT(*)"
|
2016-12-01 01:39:06 +01:00
|
|
|
|
" FROM centres,degrees,courses,crs_usr,agendas"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE centres.InsCod=%ld"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
2016-12-01 01:39:06 +01:00
|
|
|
|
" AND crs_usr.UsrCod=agendas.UsrCod",
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Gbl.CurrentIns.Ins.InsCod);
|
|
|
|
|
break;
|
|
|
|
|
case Sco_SCOPE_CTR:
|
|
|
|
|
sprintf (Query,"SELECT COUNT(*)"
|
2016-12-01 01:39:06 +01:00
|
|
|
|
" FROM degrees,courses,crs_usr,agendas"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE degrees.CtrCod=%ld"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
2016-12-01 01:39:06 +01:00
|
|
|
|
" AND crs_usr.UsrCod=agendas.UsrCod",
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Gbl.CurrentCtr.Ctr.CtrCod);
|
|
|
|
|
break;
|
|
|
|
|
case Sco_SCOPE_DEG:
|
|
|
|
|
sprintf (Query,"SELECT COUNT(*)"
|
2016-12-01 01:39:06 +01:00
|
|
|
|
" FROM courses,crs_usr,agendas"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE courses.DegCod=%ld"
|
2016-11-30 22:49:48 +01:00
|
|
|
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
2016-12-01 01:39:06 +01:00
|
|
|
|
" AND crs_usr.UsrCod=agendas.UsrCod",
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Gbl.CurrentDeg.Deg.DegCod);
|
|
|
|
|
break;
|
|
|
|
|
case Sco_SCOPE_CRS:
|
|
|
|
|
sprintf (Query,"SELECT COUNT(*)"
|
2016-12-01 01:39:06 +01:00
|
|
|
|
" FROM crs_usr,agendas"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE crs_usr.CrsCod=%ld"
|
2016-12-01 01:39:06 +01:00
|
|
|
|
" AND crs_usr.UsrCod=agendas.UsrCod",
|
2016-11-30 22:49:48 +01:00
|
|
|
|
Gbl.CurrentCrs.Crs.CrsCod);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong scope.");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2016-12-01 00:53:50 +01:00
|
|
|
|
DB_QuerySELECT (Query,&mysql_res,"can not get number of events");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
/***** Get number of events *****/
|
2016-11-30 22:49:48 +01:00
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2016-12-01 00:53:50 +01:00
|
|
|
|
if (sscanf (row[0],"%u",&NumEvents) != 1)
|
|
|
|
|
Lay_ShowErrorAndExit ("Error when getting number of events.");
|
2016-11-30 22:49:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
2016-12-01 00:53:50 +01:00
|
|
|
|
return NumEvents;
|
2016-07-07 00:21:10 +02:00
|
|
|
|
}
|
2016-12-07 00:41:36 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Show an agenda QR code ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Agd_PrintAgdQRCode (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Where_s_USER;
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Start box *****/
|
2016-12-07 00:41:36 +01:00
|
|
|
|
sprintf (Gbl.Title,Txt_Where_s_USER,Gbl.Usrs.Me.UsrDat.FullName);
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_StartBox (NULL,Gbl.Title,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
NULL,Box_NOT_CLOSABLE);
|
2016-12-07 00:41:36 +01:00
|
|
|
|
|
|
|
|
|
/***** Print QR code ****/
|
|
|
|
|
QR_PrintQRCode ();
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_EndBox ();
|
2016-12-07 00:41:36 +01:00
|
|
|
|
}
|