mirror of https://github.com/acanas/swad-core.git
Version 23.75: Apr 13, 2024 Code refactoring related to closed/open.
This commit is contained in:
parent
c9a75eb0ad
commit
b785e884ba
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 826 B |
|
@ -2351,8 +2351,8 @@ int swad__getAttendanceEvents (struct soap *soap,
|
|||
|
||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].startTime = (int) Event.TimeUTC[Dat_STR_TIME];
|
||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].endTime = (int) Event.TimeUTC[Dat_END_TIME];
|
||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].commentsTeachersVisible = Event.Open == CloOpe_OPEN ? 1 :
|
||||
0;
|
||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].commentsTeachersVisible = (Event.ClosedOrOpen == CloOpe_OPEN) ? 1 :
|
||||
0;
|
||||
Length = strlen (Event.Title);
|
||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].title =
|
||||
soap_malloc (soap,Length + 1);
|
||||
|
|
|
@ -471,11 +471,10 @@ static void Asg_ShowAssignmentRow (struct Asg_Assignments *Assignments,
|
|||
Asg_OneOrMultiple_t OneOrMultiple,
|
||||
Vie_ViewType_t ViewType)
|
||||
{
|
||||
extern const char *Txt_Actions[ActLst_NUM_ACTIONS];
|
||||
extern const char *HidVis_DateGreenClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_DateRedClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *CloOpe_Class[CloOpe_NUM_CLOSED_OPEN][HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_TitleClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_DataClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *Txt_Actions[ActLst_NUM_ACTIONS];
|
||||
char *Anchor = NULL;
|
||||
static unsigned UniqueId = 0;
|
||||
char *Id;
|
||||
|
@ -511,16 +510,14 @@ static void Asg_ShowAssignmentRow (struct Asg_Assignments *Assignments,
|
|||
case Vie_VIEW:
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s %s\"",
|
||||
Id,
|
||||
Assignments->Asg.Open == CloOpe_OPEN ? HidVis_DateGreenClass[Assignments->Asg.HiddenOrVisible] :
|
||||
HidVis_DateRedClass[Assignments->Asg.HiddenOrVisible],
|
||||
CloOpe_Class[Assignments->Asg.ClosedOrOpen][Assignments->Asg.HiddenOrVisible],
|
||||
The_GetSuffix (),
|
||||
The_GetColorRows ());
|
||||
break;
|
||||
case Vie_PRINT:
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s\"",
|
||||
Id,
|
||||
Assignments->Asg.Open == CloOpe_OPEN ? HidVis_DateGreenClass[Assignments->Asg.HiddenOrVisible] :
|
||||
HidVis_DateRedClass[Assignments->Asg.HiddenOrVisible],
|
||||
CloOpe_Class[Assignments->Asg.ClosedOrOpen][Assignments->Asg.HiddenOrVisible],
|
||||
The_GetSuffix ());
|
||||
break;
|
||||
default:
|
||||
|
@ -659,7 +656,7 @@ static void Asg_WriteAssignmentFolder (struct Asg_Assignment *Asg,
|
|||
extern const char *Txt_Folder;
|
||||
Act_Action_t NextAction;
|
||||
bool ICanSendFiles = Asg->HiddenOrVisible == HidVis_VISIBLE && // It's visible (not hidden)
|
||||
Asg->Open == CloOpe_OPEN && // It's open (inside dates)
|
||||
Asg->ClosedOrOpen == CloOpe_OPEN && // It's open (inside dates)
|
||||
Asg->IBelongToCrsOrGrps; // I belong to course or groups
|
||||
|
||||
/***** Folder icon *****/
|
||||
|
@ -933,8 +930,7 @@ static void Asg_GetAssignmentDataFromRow (MYSQL_RES **mysql_res,
|
|||
Asg->TimeUTC[Dat_END_TIME] = Dat_GetUNIXTimeFromStr (row[4]);
|
||||
|
||||
/* Get whether the assignment is open or closed (row(5)) */
|
||||
Asg->Open = (row[5][0] == '1') ? CloOpe_OPEN :
|
||||
CloOpe_CLOSED;
|
||||
Asg->ClosedOrOpen = CloOpe_GetClosedOrOpenFrom01 (row[5][0]);
|
||||
|
||||
/* Get the title (row[6]) and the folder (row[7]) of the assignment */
|
||||
Str_Copy (Asg->Title ,row[6],sizeof (Asg->Title ) - 1);
|
||||
|
@ -962,7 +958,7 @@ static void Asg_ResetAssignment (struct Asg_Assignment *Asg)
|
|||
Asg->UsrCod = -1L;
|
||||
Asg->TimeUTC[Dat_STR_TIME] =
|
||||
Asg->TimeUTC[Dat_END_TIME] = (time_t) 0;
|
||||
Asg->Open = CloOpe_CLOSED;
|
||||
Asg->ClosedOrOpen = CloOpe_CLOSED;
|
||||
Asg->Title[0] = '\0';
|
||||
Asg->SendWork = Asg_DO_NOT_SEND_WORK;
|
||||
Asg->Folder[0] = '\0';
|
||||
|
@ -1185,7 +1181,7 @@ void Asg_ReqCreatOrEditAsg (void)
|
|||
Assignments.Asg.AsgCod = -1L;
|
||||
Assignments.Asg.TimeUTC[Dat_STR_TIME] = Dat_GetStartExecutionTimeUTC ();
|
||||
Assignments.Asg.TimeUTC[Dat_END_TIME] = Assignments.Asg.TimeUTC[Dat_STR_TIME] + (2 * 60 * 60); // +2 hours
|
||||
Assignments.Asg.Open = CloOpe_OPEN;
|
||||
Assignments.Asg.ClosedOrOpen = CloOpe_OPEN;
|
||||
Assignments.Asg.Title[0] = '\0';
|
||||
Assignments.Asg.SendWork = Asg_DO_NOT_SEND_WORK;
|
||||
Assignments.Asg.Folder[0] = '\0';
|
||||
|
@ -1657,15 +1653,18 @@ static bool Asg_CheckIfIBelongToCrsOrGrpsThisAssignment (long AsgCod)
|
|||
void Asg_WriteDatesAssignment (const struct Asg_Assignment *Asg)
|
||||
{
|
||||
extern const char *Txt_unknown_assignment;
|
||||
static const char *DateClass[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = "ASG_LST_DATE_RED",
|
||||
[CloOpe_OPEN ] = "ASG_LST_DATE_GREEN",
|
||||
};
|
||||
static unsigned UniqueId = 0;
|
||||
char *Id;
|
||||
|
||||
/***** Begin table cell *****/
|
||||
HTM_TD_Begin ("colspan=\"2\" class=\"RM %s_%s %s\"",
|
||||
Asg->Open == CloOpe_OPEN ? "ASG_LST_DATE_GREEN" :
|
||||
"ASG_LST_DATE_RED",
|
||||
The_GetSuffix (),
|
||||
The_GetColorRows ());
|
||||
DateClass[Asg->ClosedOrOpen],The_GetSuffix (),
|
||||
The_GetColorRows ());
|
||||
|
||||
if (Asg->AsgCod > 0)
|
||||
{
|
||||
|
@ -1707,6 +1706,12 @@ void Asg_WriteDatesAssignment (const struct Asg_Assignment *Asg)
|
|||
|
||||
Usr_ICan_t Asg_CheckIfICanCreateIntoAssigment (const struct Asg_Assignment *Asg)
|
||||
{
|
||||
static Usr_ICan_t CloOpe_ICanCreate[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = Usr_I_CAN_NOT,
|
||||
[CloOpe_OPEN ] = Usr_I_CAN,
|
||||
};
|
||||
|
||||
/***** Trivial check 1: assignment is valid *****/
|
||||
if (Asg->AsgCod <= 0)
|
||||
return Usr_I_CAN_NOT;
|
||||
|
@ -1723,13 +1728,12 @@ Usr_ICan_t Asg_CheckIfICanCreateIntoAssigment (const struct Asg_Assignment *Asg)
|
|||
/***** Check 4: Depending on my role in this course... *****/
|
||||
switch (Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs)
|
||||
{
|
||||
case Rol_STD: // Students...
|
||||
case Rol_NET: // ...and non-editing teachers...
|
||||
// ...can create inside open assignments
|
||||
return (Asg->Open == CloOpe_OPEN) ? Usr_I_CAN :
|
||||
Usr_I_CAN_NOT;
|
||||
case Rol_TCH: // Teachers...
|
||||
return Usr_I_CAN; // ...can create inside open or closed assignments
|
||||
case Rol_STD: // Students...
|
||||
case Rol_NET: // ...and non-editing teachers...
|
||||
// ...can create only inside open assignments
|
||||
return CloOpe_ICanCreate[Asg->ClosedOrOpen];
|
||||
case Rol_TCH: // Teachers...
|
||||
return Usr_I_CAN; // ...can create inside any assignment
|
||||
default:
|
||||
return Usr_I_CAN_NOT;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ struct Asg_Assignment
|
|||
HidVis_HiddenOrVisible_t HiddenOrVisible;
|
||||
long UsrCod;
|
||||
time_t TimeUTC[Dat_NUM_START_END_TIME];
|
||||
CloOpe_ClosedOrOpen_t Open;
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen;
|
||||
char Title[Asg_MAX_BYTES_ASSIGNMENT_TITLE + 1];
|
||||
Asg_SendWork_t SendWork;
|
||||
char Folder[Brw_MAX_BYTES_FOLDER + 1];
|
||||
|
|
|
@ -430,11 +430,10 @@ static void Att_PutParsToListUsrsAttendance (void *Events)
|
|||
static void Att_ShowOneEventRow (struct Att_Events *Events,
|
||||
bool ShowOnlyThisAttEventComplete)
|
||||
{
|
||||
extern const char *Txt_View_event;
|
||||
extern const char *HidVis_DateGreenClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_DateRedClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *CloOpe_Class[CloOpe_NUM_CLOSED_OPEN][HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_TitleClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_DataClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *Txt_View_event;
|
||||
char *Anchor = NULL;
|
||||
static unsigned UniqueId = 0;
|
||||
char *Id;
|
||||
|
@ -467,16 +466,13 @@ static void Att_ShowOneEventRow (struct Att_Events *Events,
|
|||
if (ShowOnlyThisAttEventComplete)
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s\"",
|
||||
Id,
|
||||
Events->Event.Open == CloOpe_OPEN ? HidVis_DateGreenClass[Events->Event.HiddenOrVisible] :
|
||||
HidVis_DateRedClass[Events->Event.HiddenOrVisible],
|
||||
CloOpe_Class[Events->Event.ClosedOrOpen][Events->Event.HiddenOrVisible],
|
||||
The_GetSuffix ());
|
||||
else
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s %s\"",
|
||||
Id,
|
||||
Events->Event.Open == CloOpe_OPEN ? HidVis_DateGreenClass[Events->Event.HiddenOrVisible] :
|
||||
HidVis_DateRedClass[Events->Event.HiddenOrVisible],
|
||||
The_GetSuffix (),
|
||||
The_GetColorRows ());
|
||||
CloOpe_Class[Events->Event.ClosedOrOpen][Events->Event.HiddenOrVisible],
|
||||
The_GetSuffix (),The_GetColorRows ());
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Events->Event.TimeUTC[StartEndTime],
|
||||
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
||||
true,true,true,0x7);
|
||||
|
@ -746,7 +742,7 @@ static void Att_ResetEvent (struct Att_Event *Event)
|
|||
Event->UsrCod = -1L;
|
||||
Event->TimeUTC[Dat_STR_TIME] =
|
||||
Event->TimeUTC[Dat_END_TIME] = (time_t) 0;
|
||||
Event->Open = CloOpe_CLOSED;
|
||||
Event->ClosedOrOpen = CloOpe_CLOSED;
|
||||
Event->CommentTchVisible = false;
|
||||
Event->Title[0] = '\0';
|
||||
}
|
||||
|
@ -772,8 +768,7 @@ void Att_GetEventDataFromRow (MYSQL_ROW row,struct Att_Event *Event)
|
|||
Event->TimeUTC[Dat_END_TIME] = Dat_GetUNIXTimeFromStr (row[5]);
|
||||
|
||||
/***** Get whether the attendance event is open or closed (row(6)) *****/
|
||||
Event->Open = (row[6][0] == '1') ? CloOpe_OPEN :
|
||||
CloOpe_CLOSED;
|
||||
Event->ClosedOrOpen = CloOpe_GetClosedOrOpenFrom01 (row[6][0]);
|
||||
|
||||
/***** Get whether the attendance event is visible or not (row[7]) *****/
|
||||
Event->CommentTchVisible = (row[7][0] == 'Y');
|
||||
|
@ -953,7 +948,7 @@ void Att_ReqCreatOrEditEvent (void)
|
|||
Events.Event.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
||||
Events.Event.TimeUTC[Dat_STR_TIME] = Dat_GetStartExecutionTimeUTC ();
|
||||
Events.Event.TimeUTC[Dat_END_TIME] = Events.Event.TimeUTC[Dat_STR_TIME] + (2 * 60 * 60); // +2 hours
|
||||
Events.Event.Open = CloOpe_OPEN;
|
||||
Events.Event.ClosedOrOpen = CloOpe_OPEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1487,7 +1482,7 @@ static void Att_ListEventOnlyMeAsStudent (struct Att_Event *Event)
|
|||
Hlp_USERS_Attendance,Box_NOT_CLOSABLE);
|
||||
|
||||
/***** Begin form *****/
|
||||
if (Event->Open == CloOpe_OPEN)
|
||||
if (Event->ClosedOrOpen == CloOpe_OPEN)
|
||||
{
|
||||
Frm_BeginForm (ActRecAttMe);
|
||||
ParCod_PutPar (ParCod_Att,Event->AttCod);
|
||||
|
@ -1516,7 +1511,7 @@ static void Att_ListEventOnlyMeAsStudent (struct Att_Event *Event)
|
|||
HTM_TABLE_End ();
|
||||
|
||||
/* Send button */
|
||||
if (Event->Open == CloOpe_OPEN)
|
||||
if (Event->ClosedOrOpen == CloOpe_OPEN)
|
||||
{
|
||||
Btn_PutConfirmButton (Txt_Save_changes);
|
||||
Frm_EndForm ();
|
||||
|
@ -1669,8 +1664,8 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
|
|||
if (Usr_ItsMe (UsrDat->UsrCod) == Usr_OTHER)
|
||||
Err_ShowErrorAndExit ("Wrong call.");
|
||||
ICanChangeStdAttendance = Usr_I_CAN_NOT;
|
||||
ICanEditStdComment = (Event->Open == CloOpe_OPEN) ? Usr_I_CAN : // Attendance event is open
|
||||
Usr_I_CAN_NOT;
|
||||
ICanEditStdComment = (Event->ClosedOrOpen == CloOpe_OPEN) ? Usr_I_CAN : // Attendance event is open
|
||||
Usr_I_CAN_NOT;
|
||||
ICanEditTchComment = Usr_I_CAN_NOT;
|
||||
break;
|
||||
case Rol_TCH:
|
||||
|
@ -1912,7 +1907,7 @@ void Att_RegisterMeAsStdInEvent (void)
|
|||
Events.Event.AttCod = ParCod_GetAndCheckPar (ParCod_Att);
|
||||
Att_GetEventDataByCodAndCheckCrs (&Events.Event); // This checks that event belong to current course
|
||||
|
||||
if (Events.Event.Open == CloOpe_OPEN)
|
||||
if (Events.Event.ClosedOrOpen == CloOpe_OPEN)
|
||||
{
|
||||
/***** Get comments for this student *****/
|
||||
Present = Att_CheckIfUsrIsPresentInEventAndGetComments (Events.Event.AttCod,Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
|
|
|
@ -54,7 +54,7 @@ struct Att_Event
|
|||
HidVis_HiddenOrVisible_t HiddenOrVisible;
|
||||
long UsrCod;
|
||||
time_t TimeUTC[Dat_NUM_START_END_TIME];
|
||||
CloOpe_ClosedOrOpen_t Open;
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen;
|
||||
bool CommentTchVisible;
|
||||
char Title[Att_MAX_BYTES_ATTENDANCE_EVENT_TITLE + 1];
|
||||
|
||||
|
|
141
swad_browser.c
141
swad_browser.c
|
@ -89,9 +89,10 @@
|
|||
extern struct Globals Gbl;
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************* Private types *******************************/
|
||||
/**********n********************* Private types *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Brw_NUM_ICON_TREE 3
|
||||
typedef enum
|
||||
{
|
||||
Brw_ICON_TREE_NOTHING, // No icon to expand/contract a subtree
|
||||
|
@ -1161,9 +1162,11 @@ static void Brw_PutIconFolder (unsigned Level,
|
|||
const char *FileBrowserId,const char *RowId,
|
||||
Brw_IconTree_t IconSubtree);
|
||||
static void Brw_PutIconFolderWithoutPlus (const char *FileBrowserId,const char *RowId,
|
||||
CloOpe_ClosedOrOpen_t Open,HidVis_HiddenOrVisible_t HiddenOrVisible);
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen,
|
||||
HidVis_HiddenOrVisible_t HiddenOrVisible);
|
||||
static void Brw_PutIconFolderWithPlus (const char *FileBrowserId,const char *RowId,
|
||||
CloOpe_ClosedOrOpen_t Open,HidVis_HiddenOrVisible_t HiddenOrVisible);
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen,
|
||||
HidVis_HiddenOrVisible_t HiddenOrVisible);
|
||||
|
||||
static void Brw_PutIconNewFileOrFolder (void);
|
||||
static void Brw_PutIconFileWithLinkToViewMetadata (const struct Brw_FileMetadata *FileMetadata);
|
||||
|
@ -2113,7 +2116,7 @@ static void Brw_GetDataCurrentGrp (void)
|
|||
Str_Copy (Gbl.Crs.Grps.GrpName,GrpDat.GrpName,
|
||||
sizeof (Gbl.Crs.Grps.GrpName) - 1);
|
||||
Gbl.Crs.Grps.MaxStudents = GrpDat.MaxStudents;
|
||||
Gbl.Crs.Grps.Open = GrpDat.Open;
|
||||
Gbl.Crs.Grps.ClosedOrOpen = GrpDat.ClosedOrOpen;
|
||||
Gbl.Crs.Grps.FileZones = GrpDat.FileZones;
|
||||
Gbl.Crs.Grps.GrpTyp.MultipleEnrolment = GrpDat.MultipleEnrolment;
|
||||
}
|
||||
|
@ -4475,74 +4478,35 @@ static void Brw_PutIconFolder (unsigned Level,
|
|||
const char *FileBrowserId,const char *RowId,
|
||||
Brw_IconTree_t IconSubtree)
|
||||
{
|
||||
static void (*Brw_PutIconFolder[Usr_NUM_I_CAN]) (const char *FileBrowserId,const char *RowId,
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen,
|
||||
HidVis_HiddenOrVisible_t HiddenOrVisible) =
|
||||
{
|
||||
[Usr_I_CAN_NOT] = Brw_PutIconFolderWithoutPlus,
|
||||
[Usr_I_CAN ] = Brw_PutIconFolderWithPlus,
|
||||
};
|
||||
static HidVis_HiddenOrVisible_t HiddenOrVisible[Brw_NUM_ICON_TREE][CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[Brw_ICON_TREE_NOTHING ][CloOpe_CLOSED] = HidVis_HIDDEN,
|
||||
[Brw_ICON_TREE_NOTHING ][CloOpe_OPEN ] = HidVis_VISIBLE,
|
||||
[Brw_ICON_TREE_EXPAND ][CloOpe_CLOSED] = HidVis_VISIBLE,
|
||||
[Brw_ICON_TREE_EXPAND ][CloOpe_OPEN ] = HidVis_HIDDEN,
|
||||
[Brw_ICON_TREE_CONTRACT][CloOpe_CLOSED] = HidVis_HIDDEN,
|
||||
[Brw_ICON_TREE_CONTRACT][CloOpe_OPEN ] = HidVis_VISIBLE,
|
||||
};
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen;
|
||||
Usr_ICan_t ICanCreateIntoFolder = Brw_CheckIfICanCreateIntoFolder (Level);
|
||||
|
||||
/***** Begin cell *****/
|
||||
HTM_TD_Begin ("class=\"BM %s\"",The_GetColorRows ());
|
||||
|
||||
/***** Put icon to create a new file or folder *****/
|
||||
switch (Brw_CheckIfICanCreateIntoFolder (Level)) // I can create a new file or folder
|
||||
{
|
||||
case Usr_I_CAN:
|
||||
switch (IconSubtree)
|
||||
{
|
||||
case Brw_ICON_TREE_EXPAND:
|
||||
/* Visible icon with folder closed */
|
||||
Brw_PutIconFolderWithPlus (FileBrowserId,RowId,
|
||||
CloOpe_CLOSED, // Closed
|
||||
HidVis_VISIBLE); // Visible
|
||||
|
||||
/* Hidden icon with folder open */
|
||||
Brw_PutIconFolderWithPlus (FileBrowserId,RowId,
|
||||
CloOpe_OPEN, // Open
|
||||
HidVis_HIDDEN); // Hidden
|
||||
break;
|
||||
case Brw_ICON_TREE_CONTRACT:
|
||||
/* Hidden icon with folder closed */
|
||||
Brw_PutIconFolderWithPlus (FileBrowserId,RowId,
|
||||
CloOpe_CLOSED, // Closed
|
||||
HidVis_HIDDEN); // Hidden
|
||||
|
||||
/* Visible icon with folder open */
|
||||
Brw_PutIconFolderWithPlus (FileBrowserId,RowId,
|
||||
CloOpe_OPEN, // Open
|
||||
HidVis_VISIBLE); // Visible
|
||||
break;
|
||||
case Brw_ICON_TREE_NOTHING:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Usr_I_CAN_NOT:
|
||||
default:
|
||||
switch (IconSubtree)
|
||||
{
|
||||
case Brw_ICON_TREE_EXPAND:
|
||||
/* Visible icon with folder closed */
|
||||
Brw_PutIconFolderWithoutPlus (FileBrowserId,RowId,
|
||||
CloOpe_CLOSED, // Closed
|
||||
HidVis_VISIBLE);
|
||||
|
||||
/* Hidden icon with folder open */
|
||||
Brw_PutIconFolderWithoutPlus (FileBrowserId,RowId,
|
||||
CloOpe_OPEN, // Open
|
||||
HidVis_HIDDEN);
|
||||
break;
|
||||
case Brw_ICON_TREE_CONTRACT:
|
||||
/* Hidden icon with folder closed */
|
||||
Brw_PutIconFolderWithoutPlus (FileBrowserId,RowId,
|
||||
CloOpe_CLOSED, // Closed
|
||||
HidVis_HIDDEN);
|
||||
|
||||
/* Visible icon with folder open */
|
||||
Brw_PutIconFolderWithoutPlus (FileBrowserId,RowId,
|
||||
CloOpe_OPEN, // Open
|
||||
HidVis_VISIBLE);
|
||||
break;
|
||||
case Brw_ICON_TREE_NOTHING:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
/* Put two folder icons: · 1st closed (hidden or visible)
|
||||
· 2nd open (hidden or visible) */
|
||||
for (ClosedOrOpen = CloOpe_CLOSED;
|
||||
ClosedOrOpen <= CloOpe_OPEN;
|
||||
ClosedOrOpen++)
|
||||
Brw_PutIconFolder[ICanCreateIntoFolder] (FileBrowserId,RowId,ClosedOrOpen,
|
||||
HiddenOrVisible[IconSubtree][ClosedOrOpen]);
|
||||
|
||||
/***** End cell *****/
|
||||
HTM_TD_End ();
|
||||
|
@ -4553,24 +4517,26 @@ static void Brw_PutIconFolder (unsigned Level,
|
|||
/*****************************************************************************/
|
||||
|
||||
static void Brw_PutIconFolderWithoutPlus (const char *FileBrowserId,const char *RowId,
|
||||
CloOpe_ClosedOrOpen_t Open,HidVis_HiddenOrVisible_t HiddenOrVisible)
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen,
|
||||
HidVis_HiddenOrVisible_t HiddenOrVisible)
|
||||
{
|
||||
extern const char *Txt_Folder;
|
||||
extern const char *CloOpe_Txt[CloOpe_NUM_CLOSED_OPEN];
|
||||
extern const char *HidVis_ShownStyle[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *Txt_Folder;
|
||||
static const char *CloOpe_Icon[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = "folder-closed-yellow.png",
|
||||
[CloOpe_OPEN ] = "folder-open-yellow.png",
|
||||
};
|
||||
|
||||
/***** Begin container *****/
|
||||
HTM_DIV_Begin ("id=\"folder_%s_%s_%s\" class=\"%s\"%s",
|
||||
Open == CloOpe_OPEN ? "open" :
|
||||
"closed",
|
||||
FileBrowserId,RowId,
|
||||
The_GetColorRows (),
|
||||
HidVis_ShownStyle[HiddenOrVisible]);
|
||||
CloOpe_Txt[ClosedOrOpen],FileBrowserId,RowId,
|
||||
The_GetColorRows (),HidVis_ShownStyle[HiddenOrVisible]);
|
||||
|
||||
/***** Icon *****/
|
||||
Ico_PutIcon (Open == CloOpe_OPEN ? "folder-open-yellow.png" :
|
||||
"folder-yellow.png",
|
||||
Ico_UNCHANGED,
|
||||
Txt_Folder,"CONTEXT_OPT CONTEXT_ICO16x16");
|
||||
Ico_PutIcon (CloOpe_Icon[ClosedOrOpen],Ico_UNCHANGED,Txt_Folder,
|
||||
"CONTEXT_OPT CONTEXT_ICO16x16");
|
||||
|
||||
/***** End container *****/
|
||||
HTM_DIV_End ();
|
||||
|
@ -4581,22 +4547,21 @@ static void Brw_PutIconFolderWithoutPlus (const char *FileBrowserId,const char *
|
|||
/*****************************************************************************/
|
||||
|
||||
static void Brw_PutIconFolderWithPlus (const char *FileBrowserId,const char *RowId,
|
||||
CloOpe_ClosedOrOpen_t Open,HidVis_HiddenOrVisible_t HiddenOrVisible)
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen,
|
||||
HidVis_HiddenOrVisible_t HiddenOrVisible)
|
||||
{
|
||||
extern const char *CloOpe_Txt[CloOpe_NUM_CLOSED_OPEN];
|
||||
extern const char *HidVis_ShownStyle[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
|
||||
/***** Begin container *****/
|
||||
HTM_DIV_Begin ("id=\"folder_%s_%s_%s\" class=\"%s\"%s",
|
||||
Open == CloOpe_OPEN ? "open" :
|
||||
"closed",
|
||||
FileBrowserId,RowId,
|
||||
The_GetColorRows (),
|
||||
HidVis_ShownStyle[HiddenOrVisible]);
|
||||
CloOpe_Txt[ClosedOrOpen],FileBrowserId,RowId,
|
||||
The_GetColorRows (),HidVis_ShownStyle[HiddenOrVisible]);
|
||||
|
||||
/***** Form and icon *****/
|
||||
Ico_PutContextualIconToCreateInFolder (Brw_ActFormCreate[Gbl.FileBrowser.Type],
|
||||
Brw_PutImplicitParsFileBrowser,&Gbl.FileBrowser.FilFolLnk,
|
||||
Open);
|
||||
ClosedOrOpen);
|
||||
|
||||
/***** End container *****/
|
||||
HTM_DIV_End ();
|
||||
|
@ -9478,7 +9443,7 @@ static void Brw_WriteRowDocData (unsigned *NumDocsNotHidden,MYSQL_ROW row)
|
|||
Frm_DONT_PUT_FORM); // Don't put link to view metadata
|
||||
break;
|
||||
case Brw_IS_FOLDER:
|
||||
Ico_PutIcon ("folder-yellow.png",Ico_UNCHANGED,
|
||||
Ico_PutIcon ("folder-closed-yellow.png",Ico_UNCHANGED,
|
||||
Txt_Folder,"CONTEXT_ICO16x16");
|
||||
break;
|
||||
case Brw_IS_LINK:
|
||||
|
|
|
@ -327,7 +327,7 @@ static void CtrCfg_Map (const struct Map_Coordinates *Coord)
|
|||
/* Add popup */
|
||||
Map_AddPopup (Gbl.Hierarchy.Node[Hie_CTR].ShrtName,
|
||||
Gbl.Hierarchy.Node[Hie_INS].ShrtName,
|
||||
CloOpe_OPEN); // Open
|
||||
CloOpe_OPEN);
|
||||
|
||||
HTM_SCRIPT_End ();
|
||||
}
|
||||
|
|
|
@ -633,10 +633,15 @@ Me sale este error, no s
|
|||
"can npt create received message (duplicated entry '243218-2160773' for key 'UsrCod_MsgCod')
|
||||
*/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 23.74 (2024-04-07)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 23.75 (2024-04-13)"
|
||||
#define CSS_FILE "swad23.67.2.css"
|
||||
#define JS_FILE "swad23.53.6.js"
|
||||
/*
|
||||
Version 23.75: Apr 13, 2024 Code refactoring related to closed/open. (335484 lines)
|
||||
Copy the following icons to icon public directory:
|
||||
sudo cp icon/folder-closed-yellow.png /var/www/html/swad/icon/
|
||||
sudo cp icon/folder-closed-yellow-plus.png /var/www/html/swad/icon/
|
||||
|
||||
Version 23.74: Apr 07, 2024 New type CloOpe_ClosedOrOpen_t. (335553 lines)
|
||||
Version 23.73: Apr 06, 2024 Code refactoring related to new type Usr_ICan_t. (335399 lines)
|
||||
Version 23.72.2: Apr 02, 2024 Code refactoring related to new type Usr_ICan_t. (334970 lines)
|
||||
|
|
|
@ -26,76 +26,41 @@
|
|||
/*****************************************************************************/
|
||||
|
||||
#include "swad_closed_open.h"
|
||||
#include "swad_hidden_visible.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Open in database fields */
|
||||
const char CloOpe_YN[CloOpe_NUM_CLOSED_OPEN] =
|
||||
const char *CloOpe_Txt[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = 'Y',
|
||||
[CloOpe_OPEN ] = 'N',
|
||||
[CloOpe_CLOSED] = "closed",
|
||||
[CloOpe_OPEN ] = "open",
|
||||
};
|
||||
/*
|
||||
const char *CloOpe_DateGreenClass[CloOpe_NUM_CLOSED_OPEN] =
|
||||
|
||||
const char *CloOpe_Class[CloOpe_NUM_CLOSED_OPEN][HidVis_NUM_HIDDEN_VISIBLE] =
|
||||
{
|
||||
[CloOpe_CLOSED] = "DATE_GREEN_LIGHT",
|
||||
[CloOpe_OPEN ] = "DATE_GREEN",
|
||||
[CloOpe_CLOSED][HidVis_HIDDEN ] = "DATE_RED_LIGHT",
|
||||
[CloOpe_CLOSED][HidVis_VISIBLE] = "DATE_RED",
|
||||
[CloOpe_OPEN ][HidVis_HIDDEN ] = "DATE_GREEN_LIGHT",
|
||||
[CloOpe_OPEN ][HidVis_VISIBLE] = "DATE_GREEN",
|
||||
};
|
||||
const char *CloOpe_DateRedClass[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = "DATE_RED_LIGHT",
|
||||
[CloOpe_OPEN ] = "DATE_RED",
|
||||
};
|
||||
const char *CloOpe_DateBlueClass[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED ] = "DATE_BLUE_LIGHT",
|
||||
[CloOpe_OPEN] = "DATE_BLUE",
|
||||
};
|
||||
const char *CloOpe_TitleClass[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = "ASG_TITLE_LIGHT",
|
||||
[CloOpe_OPEN ] = "ASG_TITLE",
|
||||
};
|
||||
const char *CloOpe_GroupClass[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = "ASG_GRP_LIGHT",
|
||||
[CloOpe_OPEN ] = "ASG_GRP",
|
||||
};
|
||||
const char *CloOpe_LabelClass[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = "ASG_LABEL_LIGHT",
|
||||
[CloOpe_OPEN ] = "ASG_LABEL",
|
||||
};
|
||||
const char *CloOpe_DataClass[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = "DAT_LIGHT",
|
||||
[CloOpe_OPEN ] = "DAT",
|
||||
};
|
||||
const char *CloOpe_MsgClass[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = "MSG_AUT_LIGHT",
|
||||
[CloOpe_OPEN ] = "MSG_AUT",
|
||||
};
|
||||
const char *CloOpe_PrgClass[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = " PRG_HIDDEN",
|
||||
[CloOpe_OPEN ] = "",
|
||||
};
|
||||
const char *CloOpe_ShownStyle[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = " style=\"display:none;\"",
|
||||
[CloOpe_OPEN ] = "",
|
||||
};
|
||||
*/
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************** Get if closed or open from a character *******************/
|
||||
/************** Get if closed or open from a '0'/'1' character ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
CloOpe_ClosedOrOpen_t CloOpe_GetClosedOrOpen (char Ch)
|
||||
CloOpe_ClosedOrOpen_t CloOpe_GetClosedOrOpenFrom01 (char Ch)
|
||||
{
|
||||
return (Ch == '1') ? CloOpe_OPEN :
|
||||
CloOpe_CLOSED;
|
||||
}
|
||||
/*****************************************************************************/
|
||||
/************** Get if closed or open from a 'Y'/'N' character ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
CloOpe_ClosedOrOpen_t CloOpe_GetClosedOrOpenFromYN (char Ch)
|
||||
{
|
||||
return (Ch == 'Y') ? CloOpe_OPEN :
|
||||
CloOpe_CLOSED;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ typedef enum
|
|||
/****************************** Public prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
CloOpe_ClosedOrOpen_t CloOpe_GetClosedOrOpen (char c);
|
||||
CloOpe_ClosedOrOpen_t CloOpe_GetClosedOrOpenFrom01 (char Ch);
|
||||
CloOpe_ClosedOrOpen_t CloOpe_GetClosedOrOpenFromYN (char Ch);
|
||||
|
||||
#endif
|
||||
|
|
16
swad_exam.c
16
swad_exam.c
|
@ -445,13 +445,12 @@ void Exa_ShowOnlyOneExamEnd (void)
|
|||
|
||||
static void Exa_ShowOneExam (struct Exa_Exams *Exams,bool ShowOnlyThisExam)
|
||||
{
|
||||
extern const char *CloOpe_Class[CloOpe_NUM_CLOSED_OPEN][HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *Txt_View_exam;
|
||||
extern const char *Txt_Sets_of_questions;
|
||||
extern const char *Txt_Maximum_grade;
|
||||
extern const char *Txt_Result_visibility;
|
||||
extern const char *Txt_Sessions;
|
||||
extern const char *HidVis_DateGreenClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_DateRedClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_TitleClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_GroupClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_DataClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
|
@ -459,7 +458,8 @@ static void Exa_ShowOneExam (struct Exa_Exams *Exams,bool ShowOnlyThisExam)
|
|||
static unsigned UniqueId = 0;
|
||||
char *Id;
|
||||
Dat_StartEndTime_t StartEndTime;
|
||||
const char *DateClass;
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen = Exams->Exam.NumOpenSess ? CloOpe_OPEN :
|
||||
CloOpe_CLOSED;
|
||||
char Txt[Cns_MAX_BYTES_TEXT + 1];
|
||||
|
||||
/***** Build anchor string *****/
|
||||
|
@ -490,14 +490,16 @@ static void Exa_ShowOneExam (struct Exa_Exams *Exams,bool ShowOnlyThisExam)
|
|||
if (asprintf (&Id,"exa_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
DateClass = Exams->Exam.NumOpenSess ? HidVis_DateGreenClass[Exams->Exam.HiddenOrVisible] :
|
||||
HidVis_DateRedClass[Exams->Exam.HiddenOrVisible];
|
||||
if (ShowOnlyThisExam)
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s\"",
|
||||
Id,DateClass,The_GetSuffix ());
|
||||
Id,
|
||||
CloOpe_Class[ClosedOrOpen][Exams->Exam.HiddenOrVisible],
|
||||
The_GetSuffix ());
|
||||
else
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s %s\"",
|
||||
Id,DateClass,The_GetSuffix (),The_GetColorRows ());
|
||||
Id,
|
||||
CloOpe_Class[ClosedOrOpen][Exams->Exam.HiddenOrVisible],
|
||||
The_GetSuffix (),The_GetColorRows ());
|
||||
if (Exams->Exam.TimeUTC[Dat_STR_TIME])
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Exams->Exam.TimeUTC[StartEndTime],
|
||||
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
||||
|
|
|
@ -127,7 +127,7 @@ void ExaSes_ResetSession (struct ExaSes_Session *Session)
|
|||
Session->TimeUTC[StartEndTime] = (time_t) 0;
|
||||
Session->Title[0] = '\0';
|
||||
Session->HiddenOrVisible = HidVis_VISIBLE;
|
||||
Session->Open = CloOpe_CLOSED;
|
||||
Session->ClosedOrOpen = CloOpe_CLOSED;
|
||||
Session->ShowUsrResults = false;
|
||||
};
|
||||
|
||||
|
@ -459,23 +459,20 @@ static void ExaSes_ListOneOrMoreSessionsAuthor (const struct ExaSes_Session *Ses
|
|||
static void ExaSes_ListOneOrMoreSessionsTimes (const struct ExaSes_Session *Session,
|
||||
unsigned UniqueId)
|
||||
{
|
||||
extern const char *HidVis_DateGreenClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_DateRedClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *CloOpe_Class[CloOpe_NUM_CLOSED_OPEN][HidVis_NUM_HIDDEN_VISIBLE];
|
||||
Dat_StartEndTime_t StartEndTime;
|
||||
const char *DateClass;
|
||||
char *Id;
|
||||
|
||||
for (StartEndTime = (Dat_StartEndTime_t) 0;
|
||||
StartEndTime <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1);
|
||||
StartEndTime++)
|
||||
{
|
||||
DateClass = Session->Open == CloOpe_OPEN ? HidVis_DateGreenClass[Session->HiddenOrVisible] :
|
||||
HidVis_DateRedClass[Session->HiddenOrVisible];
|
||||
|
||||
if (asprintf (&Id,"exa_time_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s %s\"",
|
||||
Id,DateClass,The_GetSuffix (),The_GetColorRows ());
|
||||
Id,
|
||||
CloOpe_Class[Session->ClosedOrOpen][Session->HiddenOrVisible],
|
||||
The_GetSuffix (),The_GetColorRows ());
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Session->TimeUTC[StartEndTime],
|
||||
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
||||
true,true,true,0x6);
|
||||
|
@ -751,8 +748,7 @@ static void ExaSes_GetSessionDataFromRow (MYSQL_RES *mysql_res,
|
|||
Session->TimeUTC[StartEndTime] = Dat_GetUNIXTimeFromStr (row[4 + StartEndTime]);
|
||||
|
||||
/* Get whether the session is open or closed (row(6)) */
|
||||
Session->Open = (row[6][0] == '1') ? CloOpe_OPEN :
|
||||
CloOpe_CLOSED;
|
||||
Session->ClosedOrOpen = CloOpe_GetClosedOrOpenFrom01 (row[6][0]);
|
||||
|
||||
/* Get the title of the session (row[7]) */
|
||||
if (row[7])
|
||||
|
@ -1219,7 +1215,7 @@ Usr_ICan_t ExaSes_CheckIfICanAnswerThisSession (const struct Exa_Exam *Exam,
|
|||
2. Hidden or closed sessions are not accesible *****/
|
||||
if (Exam->HiddenOrVisible == HidVis_HIDDEN ||
|
||||
Session->HiddenOrVisible == HidVis_HIDDEN ||
|
||||
Session->Open == CloOpe_CLOSED)
|
||||
Session->ClosedOrOpen == CloOpe_CLOSED)
|
||||
return Usr_I_CAN_NOT;
|
||||
|
||||
/***** Exam is visible, session is visible and open ==>
|
||||
|
|
|
@ -148,8 +148,8 @@ struct ExaSes_Session
|
|||
time_t TimeUTC[Dat_NUM_START_END_TIME];
|
||||
char Title[ExaSes_MAX_BYTES_TITLE + 1];
|
||||
HidVis_HiddenOrVisible_t HiddenOrVisible;
|
||||
CloOpe_ClosedOrOpen_t Open; // If now is between start and end dates
|
||||
bool ShowUsrResults; // Show exam with results of all questions for the student
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen; // If now is between start and end dates
|
||||
bool ShowUsrResults; // Show exam with results of all questions for the student
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
17
swad_game.c
17
swad_game.c
|
@ -505,13 +505,12 @@ void Gam_ShowOnlyOneGameEnd (void)
|
|||
static void Gam_ShowGameMainData (struct Gam_Games *Games,
|
||||
bool ShowOnlyThisGame)
|
||||
{
|
||||
extern const char *CloOpe_Class[CloOpe_NUM_CLOSED_OPEN][HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *Txt_View_game;
|
||||
extern const char *Txt_Number_of_questions;
|
||||
extern const char *Txt_Maximum_grade;
|
||||
extern const char *Txt_Result_visibility;
|
||||
extern const char *Txt_Matches;
|
||||
extern const char *HidVis_DateGreenClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_DateRedClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_TitleClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_GroupClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_DataClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
|
@ -519,7 +518,8 @@ static void Gam_ShowGameMainData (struct Gam_Games *Games,
|
|||
static unsigned UniqueId = 0;
|
||||
char *Id;
|
||||
Dat_StartEndTime_t StartEndTime;
|
||||
const char *DateClass;
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen = (Games->Game.NumUnfinishedMchs) ? CloOpe_OPEN :
|
||||
CloOpe_CLOSED;
|
||||
char Txt[Cns_MAX_BYTES_TEXT + 1];
|
||||
|
||||
/***** Set anchor string *****/
|
||||
|
@ -549,14 +549,17 @@ static void Gam_ShowGameMainData (struct Gam_Games *Games,
|
|||
{
|
||||
if (asprintf (&Id,"gam_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
|
||||
Err_NotEnoughMemoryExit ();
|
||||
DateClass = Games->Game.NumUnfinishedMchs ? HidVis_DateGreenClass[Games->Game.HiddenOrVisible] :
|
||||
HidVis_DateRedClass[Games->Game.HiddenOrVisible];
|
||||
|
||||
if (ShowOnlyThisGame)
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s\"",
|
||||
Id,DateClass,The_GetSuffix ());
|
||||
Id,
|
||||
CloOpe_Class[ClosedOrOpen][Games->Game.HiddenOrVisible],
|
||||
The_GetSuffix ());
|
||||
else
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s %s\"",
|
||||
Id,DateClass,The_GetSuffix (),The_GetColorRows ());
|
||||
Id,
|
||||
CloOpe_Class[ClosedOrOpen][Games->Game.HiddenOrVisible],
|
||||
The_GetSuffix (),The_GetColorRows ());
|
||||
if (Games->Game.TimeUTC[Dat_STR_TIME])
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Games->Game.TimeUTC[StartEndTime],
|
||||
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
||||
|
|
|
@ -174,7 +174,7 @@ void Gbl_InitializeGlobals (void)
|
|||
Gbl.Crs.Grps.GrpName[0] = '\0';
|
||||
Gbl.Crs.Grps.RooCod = -1L; // -1L stands for no room assigned
|
||||
Gbl.Crs.Grps.MaxStudents = Grp_NUM_STUDENTS_NOT_LIMITED;
|
||||
Gbl.Crs.Grps.Open = CloOpe_CLOSED;
|
||||
Gbl.Crs.Grps.ClosedOrOpen = CloOpe_CLOSED;
|
||||
Gbl.Crs.Grps.LstGrpsSel.GrpCods = NULL;
|
||||
Gbl.Crs.Grps.LstGrpsSel.NumGrps = 0;
|
||||
Gbl.Crs.Grps.LstGrpsSel.NestedCalls = 0;
|
||||
|
|
77
swad_group.c
77
swad_group.c
|
@ -778,7 +778,7 @@ bool Grp_ChangeMyGrpsAtomically (struct ListCodGrps *LstGrpsIWant)
|
|||
NumGrpThisType < GrpTyp->NumGrps && !ITryToLeaveAClosedGroup;
|
||||
NumGrpThisType++)
|
||||
if ((GrpTyp->LstGrps[NumGrpThisType]).GrpCod == LstGrpsIBelong.GrpCods[NumGrpIBelong])
|
||||
if ((GrpTyp->LstGrps[NumGrpThisType]).Open == CloOpe_CLOSED)
|
||||
if ((GrpTyp->LstGrps[NumGrpThisType]).ClosedOrOpen == CloOpe_CLOSED)
|
||||
ITryToLeaveAClosedGroup = true;
|
||||
}
|
||||
}
|
||||
|
@ -814,7 +814,7 @@ bool Grp_ChangeMyGrpsAtomically (struct ListCodGrps *LstGrpsIWant)
|
|||
if ((GrpTyp->LstGrps[NumGrpThisType]).GrpCod == LstGrpsIWant->GrpCods[NumGrpIWant])
|
||||
{
|
||||
/* Check if the group is closed */
|
||||
if ((GrpTyp->LstGrps[NumGrpThisType]).Open == CloOpe_CLOSED)
|
||||
if ((GrpTyp->LstGrps[NumGrpThisType]).ClosedOrOpen == CloOpe_CLOSED)
|
||||
ITryToRegisterInAClosedGroup = true;
|
||||
/* Check if the group is full */
|
||||
else if ((GrpTyp->LstGrps[NumGrpThisType]).NumUsrs[Rol_STD] >=
|
||||
|
@ -1389,6 +1389,21 @@ static void Grp_ListGroupsForEdition (const struct Roo_Rooms *Rooms)
|
|||
{
|
||||
extern const char *Txt_No_assigned_room;
|
||||
extern const char *Txt_Another_room;
|
||||
static Act_Action_t NextAction[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = ActOpeGrp,
|
||||
[CloOpe_OPEN ] = ActCloGrp,
|
||||
};
|
||||
static const char *Icon[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = "lock.svg",
|
||||
[CloOpe_OPEN ] = "unlock.svg",
|
||||
};
|
||||
static Ico_Color_t Color[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = Ico_RED,
|
||||
[CloOpe_OPEN ] = Ico_GREEN,
|
||||
};
|
||||
unsigned NumGrpTyp1;
|
||||
const struct GroupType *GrpTyp1;
|
||||
unsigned NumGrpTyp2;
|
||||
|
@ -1428,16 +1443,12 @@ static void Grp_ListGroupsForEdition (const struct Roo_Rooms *Rooms)
|
|||
|
||||
/***** Icon to open/close group *****/
|
||||
HTM_TD_Begin ("class=\"BM\"");
|
||||
Frm_BeginFormAnchor (Grp->Open == CloOpe_OPEN ? ActCloGrp :
|
||||
ActOpeGrp,
|
||||
Frm_BeginFormAnchor (NextAction[Grp->ClosedOrOpen],
|
||||
Grp_GROUPS_SECTION_ID);
|
||||
ParCod_PutPar (ParCod_Grp,Grp->GrpCod);
|
||||
Ico_PutIconLink (Grp->Open == CloOpe_OPEN ? "unlock.svg" :
|
||||
"lock.svg",
|
||||
Grp->Open == CloOpe_OPEN ? Ico_GREEN :
|
||||
Ico_RED,
|
||||
Grp->Open == CloOpe_OPEN ? ActCloGrp :
|
||||
ActOpeGrp);
|
||||
Ico_PutIconLink (Icon[Grp->ClosedOrOpen],
|
||||
Color[Grp->ClosedOrOpen],
|
||||
NextAction[Grp->ClosedOrOpen]);
|
||||
Frm_EndForm ();
|
||||
HTM_TD_End ();
|
||||
|
||||
|
@ -1863,7 +1874,7 @@ static Usr_ICan_t Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp,
|
|||
NumGrpThisType++)
|
||||
{
|
||||
Grp = &(GrpTyp->LstGrps[NumGrpThisType]);
|
||||
if (Grp->Open == CloOpe_OPEN) // If group is open
|
||||
if (Grp->ClosedOrOpen == CloOpe_OPEN) // If group is open
|
||||
{
|
||||
IBelongToThisGroup = Grp_CheckIfGrpIsInList (Grp->GrpCod,&LstGrpsIBelong);
|
||||
if (IBelongToThisGroup) // I belong to this group
|
||||
|
@ -1882,7 +1893,7 @@ static Usr_ICan_t Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp,
|
|||
NumGrpThisType++)
|
||||
{
|
||||
Grp = &(GrpTyp->LstGrps[NumGrpThisType]);
|
||||
if (Grp->Open == CloOpe_CLOSED) // If group is closed
|
||||
if (Grp->ClosedOrOpen == CloOpe_CLOSED) // If group is closed
|
||||
{
|
||||
IBelongToThisGroup = Grp_CheckIfGrpIsInList (Grp->GrpCod,&LstGrpsIBelong);
|
||||
if (IBelongToThisGroup) // I belong to this group
|
||||
|
@ -1900,7 +1911,7 @@ static Usr_ICan_t Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp,
|
|||
NumGrpThisType++)
|
||||
{
|
||||
Grp = &(GrpTyp->LstGrps[NumGrpThisType]);
|
||||
if (Grp->Open == CloOpe_OPEN && // If group is open...
|
||||
if (Grp->ClosedOrOpen == CloOpe_OPEN && // If group is open...
|
||||
Grp->NumUsrs[Rol_STD] < Grp->MaxStudents) // ...and not full
|
||||
{
|
||||
IBelongToThisGroup = Grp_CheckIfGrpIsInList (Grp->GrpCod,&LstGrpsIBelong);
|
||||
|
@ -1933,7 +1944,7 @@ static Usr_ICan_t Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp,
|
|||
case Usr_I_CAN:
|
||||
ICanChangeMySelectionForThisGrp = Usr_I_CAN;
|
||||
if (Gbl.Usrs.Me.Role.Logged == Rol_STD)
|
||||
switch (Grp->Open)
|
||||
switch (Grp->ClosedOrOpen)
|
||||
{
|
||||
case CloOpe_OPEN: // If group is open
|
||||
if (!IBelongToThisGroup && // I don't belong to group
|
||||
|
@ -2336,18 +2347,28 @@ static void Grp_WriteRowGrp (struct Group *Grp,Lay_Highlight_t Highlight)
|
|||
[Lay_NO_HIGHLIGHT] = "",
|
||||
[Lay_HIGHLIGHT ] = " BG_HIGHLIGHT",
|
||||
};
|
||||
static const char **TitleFormat[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = &Txt_Group_X_closed,
|
||||
[CloOpe_OPEN ] = &Txt_Group_X_open,
|
||||
};
|
||||
static const char *Icon[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = "lock.svg",
|
||||
[CloOpe_OPEN ] = "unlock.svg",
|
||||
};
|
||||
static Ico_Color_t Color[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = Ico_RED,
|
||||
[CloOpe_OPEN ] = Ico_GREEN,
|
||||
};
|
||||
|
||||
|
||||
/***** Write icon to show if group is open or closed *****/
|
||||
HTM_TD_Begin ("class=\"BM%s\"",HighlightClass[Highlight]);
|
||||
if (asprintf (&Title,Grp->Open == CloOpe_OPEN ? Txt_Group_X_open :
|
||||
Txt_Group_X_closed,
|
||||
Grp->GrpName) < 0)
|
||||
if (asprintf (&Title,*TitleFormat[Grp->ClosedOrOpen],Grp->GrpName) < 0)
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Ico_PutIconOff (Grp->Open == CloOpe_OPEN ? "unlock.svg" :
|
||||
"lock.svg",
|
||||
Grp->Open == CloOpe_OPEN ? Ico_GREEN :
|
||||
Ico_RED,
|
||||
Title);
|
||||
Ico_PutIconOff (Icon[Grp->ClosedOrOpen],Color[Grp->ClosedOrOpen],Title);
|
||||
free (Title);
|
||||
HTM_TD_End ();
|
||||
|
||||
|
@ -2848,8 +2869,7 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
|
|||
|
||||
/* Get whether group is open ('Y') or closed ('N') (row[5]),
|
||||
and whether group have file zones ('Y') or not ('N') (row[6]) */
|
||||
Grp->Open = (row[5][0] == 'Y') ? CloOpe_OPEN :
|
||||
CloOpe_CLOSED;
|
||||
Grp->ClosedOrOpen = CloOpe_GetClosedOrOpenFromYN (row[5][0]);
|
||||
Grp->FileZones = (row[6][0] == 'Y');
|
||||
}
|
||||
}
|
||||
|
@ -2962,7 +2982,7 @@ void Grp_GetGroupDataByCod (struct GroupData *GrpDat)
|
|||
GrpDat->Room.ShrtName[0] = '\0';
|
||||
GrpDat->MaxStudents = 0;
|
||||
GrpDat->Vacant = 0;
|
||||
GrpDat->Open = CloOpe_CLOSED;
|
||||
GrpDat->ClosedOrOpen = CloOpe_CLOSED;
|
||||
GrpDat->FileZones = false;
|
||||
GrpDat->MultipleEnrolment = false;
|
||||
|
||||
|
@ -3006,8 +3026,7 @@ void Grp_GetGroupDataByCod (struct GroupData *GrpDat)
|
|||
|
||||
/* Get whether group is open or closed (row[8]),
|
||||
and whether group has file zones (row[9]) */
|
||||
GrpDat->Open = (row[8][0] == 'Y') ? CloOpe_OPEN :
|
||||
CloOpe_CLOSED;
|
||||
GrpDat->ClosedOrOpen = CloOpe_GetClosedOrOpenFromYN (row[8][0]);
|
||||
GrpDat->FileZones = (row[9][0] == 'Y');
|
||||
}
|
||||
|
||||
|
@ -3602,7 +3621,7 @@ void Grp_OpenGroup (void)
|
|||
GrpDat.GrpName);
|
||||
|
||||
/***** Show the form again *****/
|
||||
Gbl.Crs.Grps.Open = CloOpe_OPEN;
|
||||
Gbl.Crs.Grps.ClosedOrOpen = CloOpe_OPEN;
|
||||
Grp_ReqEditGroupsInternal (Ale_INFO,NULL,
|
||||
Ale_SUCCESS,AlertTxt);
|
||||
}
|
||||
|
@ -3632,7 +3651,7 @@ void Grp_CloseGroup (void)
|
|||
GrpDat.GrpName);
|
||||
|
||||
/***** Show the form again *****/
|
||||
Gbl.Crs.Grps.Open = CloOpe_CLOSED;
|
||||
Gbl.Crs.Grps.ClosedOrOpen = CloOpe_CLOSED;
|
||||
Grp_ReqEditGroupsInternal (Ale_INFO,NULL,
|
||||
Ale_SUCCESS,AlertTxt);
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ struct GroupData
|
|||
} Room;
|
||||
unsigned MaxStudents;
|
||||
int Vacant;
|
||||
CloOpe_ClosedOrOpen_t Open; // Group is open?
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen; // Group is closed or open?
|
||||
bool FileZones; // Group has file zones?
|
||||
bool MultipleEnrolment;
|
||||
};
|
||||
|
@ -87,7 +87,7 @@ struct Group
|
|||
} Room;
|
||||
unsigned NumUsrs[Rol_NUM_ROLES]; // Number of users in the group
|
||||
unsigned MaxStudents; // Maximum number of students in the group
|
||||
CloOpe_ClosedOrOpen_t Open; // Group is open?
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen; // Group is closed or open?
|
||||
bool FileZones; // Group has file zones?
|
||||
bool ShowFileZone; // Show file zone of this group?
|
||||
};
|
||||
|
@ -152,7 +152,7 @@ struct Grp_Groups
|
|||
char GrpName[Grp_MAX_BYTES_GROUP_NAME + 1];
|
||||
long RooCod;
|
||||
unsigned MaxStudents;
|
||||
CloOpe_ClosedOrOpen_t Open;
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen;
|
||||
bool FileZones;
|
||||
bool AllGrps; // All groups selected?
|
||||
struct ListCodGrps LstGrpsSel;
|
||||
|
|
|
@ -38,16 +38,6 @@ const char HidVis_YN[HidVis_NUM_HIDDEN_VISIBLE] =
|
|||
[HidVis_VISIBLE] = 'N',
|
||||
};
|
||||
|
||||
const char *HidVis_DateGreenClass[HidVis_NUM_HIDDEN_VISIBLE] =
|
||||
{
|
||||
[HidVis_HIDDEN ] = "DATE_GREEN_LIGHT",
|
||||
[HidVis_VISIBLE] = "DATE_GREEN",
|
||||
};
|
||||
const char *HidVis_DateRedClass[HidVis_NUM_HIDDEN_VISIBLE] =
|
||||
{
|
||||
[HidVis_HIDDEN ] = "DATE_RED_LIGHT",
|
||||
[HidVis_VISIBLE] = "DATE_RED",
|
||||
};
|
||||
const char *HidVis_DateBlueClass[HidVis_NUM_HIDDEN_VISIBLE] =
|
||||
{
|
||||
[HidVis_HIDDEN ] = "DATE_BLUE_LIGHT",
|
||||
|
@ -98,4 +88,3 @@ HidVis_HiddenOrVisible_t HidVid_GetHiddenOrVisible (char Ch)
|
|||
return (Ch == 'Y') ? HidVis_HIDDEN :
|
||||
HidVis_VISIBLE;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,6 @@ typedef enum
|
|||
/****************************** Public prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
HidVis_HiddenOrVisible_t HidVid_GetHiddenOrVisible (char c);
|
||||
HidVis_HiddenOrVisible_t HidVid_GetHiddenOrVisible (char Ch);
|
||||
|
||||
#endif
|
||||
|
|
69
swad_icon.c
69
swad_icon.c
|
@ -250,64 +250,56 @@ Ico_IconSet_t Ico_GetIconSetFromStr (const char *Str)
|
|||
void Ico_PutContextualIconToAdd (Act_Action_t NextAction,const char *Anchor,
|
||||
void (*FuncPars) (void *Args),void *Args)
|
||||
{
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,
|
||||
FuncPars,Args,
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,FuncPars,Args,
|
||||
"plus.svg",Ico_BLACK);
|
||||
}
|
||||
|
||||
void Ico_PutContextualIconToRemove (Act_Action_t NextAction,const char *Anchor,
|
||||
void (*FuncPars) (void *Args),void *Args)
|
||||
{
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,
|
||||
FuncPars,Args,
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,FuncPars,Args,
|
||||
"trash.svg",Ico_RED);
|
||||
}
|
||||
|
||||
void Ico_PutContextualIconToReset (Act_Action_t NextAction,const char *Anchor,
|
||||
void (*FuncPars) (void *Args),void *Args)
|
||||
{
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,
|
||||
FuncPars,Args,
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,FuncPars,Args,
|
||||
"recycle.svg",Ico_RED);
|
||||
}
|
||||
|
||||
void Ico_PutContextualIconToUpdate (Act_Action_t NextAction,const char *Anchor,
|
||||
void (*FuncPars) (void *Args),void *Args)
|
||||
{
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,
|
||||
FuncPars,Args,
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,FuncPars,Args,
|
||||
"recycle.svg",Ico_BLACK);
|
||||
}
|
||||
|
||||
void Ico_PutContextualIconToEdit (Act_Action_t NextAction,const char *Anchor,
|
||||
void (*FuncPars) (void *Args),void *Args)
|
||||
{
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,
|
||||
FuncPars,Args,
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,FuncPars,Args,
|
||||
"pen.svg",Ico_BLACK);
|
||||
}
|
||||
|
||||
void Ico_PutContextualIconToViewFiles (Act_Action_t NextAction,
|
||||
void (*FuncPars) (void *Args),void *Args)
|
||||
{
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,NULL,
|
||||
FuncPars,Args,
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,NULL,FuncPars,Args,
|
||||
"folder-open.svg",Ico_BLACK);
|
||||
}
|
||||
|
||||
void Ico_PutContextualIconToView (Act_Action_t NextAction,const char *Anchor,
|
||||
void (*FuncPars) (void *Args),void *Args)
|
||||
{
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,
|
||||
FuncPars,Args,
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,FuncPars,Args,
|
||||
"list.svg",Ico_BLACK);
|
||||
}
|
||||
|
||||
void Ico_PutContextualIconToConfigure (Act_Action_t NextAction,const char *Anchor,
|
||||
void (*FuncPars) (void *Args),void *Args)
|
||||
{
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,
|
||||
FuncPars,Args,
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,FuncPars,Args,
|
||||
"cog.svg",Ico_BLACK);
|
||||
}
|
||||
|
||||
|
@ -325,91 +317,84 @@ void Ico_PutContextualIconToHideUnhide (Act_Action_t NextAction[HidVis_NUM_HIDDE
|
|||
void Ico_PutContextualIconToExpand (Act_Action_t NextAction,const char *Anchor,
|
||||
void (*FuncPars) (void *Args),void *Args)
|
||||
{
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,
|
||||
FuncPars,Args,
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,FuncPars,Args,
|
||||
"caret-right.svg",Ico_BLACK);
|
||||
}
|
||||
|
||||
void Ico_PutContextualIconToContract (Act_Action_t NextAction,const char *Anchor,
|
||||
void (*FuncPars) (void *Args),void *Args)
|
||||
{
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,
|
||||
FuncPars,Args,
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,FuncPars,Args,
|
||||
"caret-down.svg",Ico_BLACK);
|
||||
}
|
||||
|
||||
void Ico_PutContextualIconToPrint (Act_Action_t NextAction,
|
||||
void (*FuncPars) (void *Args),void *Args)
|
||||
{
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,NULL,
|
||||
FuncPars,Args,
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,NULL,FuncPars,Args,
|
||||
"print.svg",Ico_BLACK);
|
||||
}
|
||||
|
||||
void Ico_PutContextualIconToGetLink (Act_Action_t NextAction,const char *Anchor,
|
||||
void (*FuncPars) (void *Args),void *Args)
|
||||
{
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,
|
||||
FuncPars,Args,
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,FuncPars,Args,
|
||||
"link.svg",Ico_BLACK);
|
||||
}
|
||||
|
||||
void Ico_PutContextualIconToCopy (Act_Action_t NextAction,
|
||||
void (*FuncPars) (void *Args),void *Args)
|
||||
{
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,NULL,
|
||||
FuncPars,Args,
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,NULL,FuncPars,Args,
|
||||
"copy.svg",Ico_BLACK);
|
||||
}
|
||||
|
||||
void Ico_PutContextualIconToViewClipboard (Act_Action_t NextAction,const char *Anchor,
|
||||
void (*FuncPars) (void *Args),void *Args)
|
||||
{
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,
|
||||
FuncPars,Args,
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,FuncPars,Args,
|
||||
"clipboard.svg",Ico_BLACK);
|
||||
}
|
||||
|
||||
void Ico_PutContextualIconToPaste (Act_Action_t NextAction,
|
||||
void (*FuncPars) (void *Args),void *Args)
|
||||
{
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,NULL,
|
||||
FuncPars,Args,
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,NULL,FuncPars,Args,
|
||||
"paste.svg",Ico_BLACK);
|
||||
}
|
||||
|
||||
void Ico_PutContextualIconToCreateInFolder (Act_Action_t NextAction,
|
||||
void (*FuncPars) (void *Args),void *Args,
|
||||
CloOpe_ClosedOrOpen_t Open)
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen)
|
||||
{
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,NULL,
|
||||
FuncPars,Args,
|
||||
Open == CloOpe_OPEN ? "folder-open-yellow-plus.png" :
|
||||
"folder-yellow-plus.png",
|
||||
Ico_UNCHANGED);
|
||||
static const char *CloOpe_Icon[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = "folder-closed-yellow-plus.png",
|
||||
[CloOpe_OPEN ] = "folder-open-yellow-plus.png",
|
||||
};
|
||||
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,NULL,FuncPars,Args,
|
||||
CloOpe_Icon[ClosedOrOpen],Ico_UNCHANGED);
|
||||
}
|
||||
|
||||
void Ico_PutContextualIconToShowResults (Act_Action_t NextAction,const char *Anchor,
|
||||
void (*FuncPars) (void *Args),void *Args)
|
||||
{
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,
|
||||
FuncPars,Args,
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,Anchor,FuncPars,Args,
|
||||
"trophy.svg",Ico_BLACK);
|
||||
}
|
||||
|
||||
void Ico_PutContextualIconToShowAttendanceList (Act_Action_t NextAction,
|
||||
void (*FuncPars) (void *Args),void *Args)
|
||||
{
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,NULL,
|
||||
FuncPars,Args,
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,NULL,FuncPars,Args,
|
||||
"tasks.svg",Ico_BLACK);
|
||||
}
|
||||
|
||||
void Ico_PutContextualIconToZIP (Act_Action_t NextAction,
|
||||
void (*FuncPars) (void *Args),void *Args)
|
||||
{
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,NULL,
|
||||
FuncPars,Args,
|
||||
Lay_PutContextualLinkOnlyIcon (NextAction,NULL,FuncPars,Args,
|
||||
"download.svg",Ico_BLACK);
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ void Ico_PutContextualIconToPaste (Act_Action_t NextAction,
|
|||
void (*FuncPars) (void *Args),void *Args);
|
||||
void Ico_PutContextualIconToCreateInFolder (Act_Action_t NextAction,
|
||||
void (*FuncPars) (void *Args),void *Args,
|
||||
CloOpe_ClosedOrOpen_t Open);
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen);
|
||||
void Ico_PutContextualIconToShowResults (Act_Action_t NextAction,const char *Anchor,
|
||||
void (*FuncPars) (void *Args),void *Args);
|
||||
void Ico_PutContextualIconToShowAttendanceList (Act_Action_t NextAction,
|
||||
|
|
|
@ -131,7 +131,8 @@ void Map_AddMarker (const struct Map_Coordinates *Coord)
|
|||
/************************* Add a marker to our map ***************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Map_AddPopup (const char *Title,const char *Subtitle,CloOpe_ClosedOrOpen_t Open)
|
||||
void Map_AddPopup (const char *Title,const char *Subtitle,
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen)
|
||||
{
|
||||
/* The bindPopup method attaches a popup with the specified HTML content
|
||||
to your marker so the popup appears when you click on the object,
|
||||
|
@ -140,7 +141,7 @@ void Map_AddPopup (const char *Title,const char *Subtitle,CloOpe_ClosedOrOpen_t
|
|||
HTM_TxtF ("\t"
|
||||
"marker.bindPopup(\"<strong>%s</strong><br />%s\")",
|
||||
Title,Subtitle);
|
||||
if (Open == CloOpe_OPEN)
|
||||
if (ClosedOrOpen == CloOpe_OPEN)
|
||||
HTM_Txt (".openPopup()");
|
||||
HTM_Txt (";\n");
|
||||
}
|
||||
|
|
|
@ -52,7 +52,8 @@ void Map_CreateMap (const char *ContainerId,
|
|||
const struct Map_Coordinates *Coord,unsigned Zoom);
|
||||
void Map_AddTileLayer (void);
|
||||
void Map_AddMarker (const struct Map_Coordinates *Coord);
|
||||
void Map_AddPopup (const char *Title,const char *Subtitle,CloOpe_ClosedOrOpen_t Open);
|
||||
void Map_AddPopup (const char *Title,const char *Subtitle,
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen);
|
||||
void Map_GetCoordAndZoom (struct Map_Coordinates *Coord,unsigned *Zoom,
|
||||
const char *Query);
|
||||
double Map_GetLatitudeFromStr (char *Str);
|
||||
|
|
133
swad_message.c
133
swad_message.c
|
@ -154,7 +154,8 @@ static void Msg_GetMsgContent (long MsgCod,
|
|||
|
||||
static void Msg_WriteSentOrReceivedMsgSubject (struct Msg_Messages *Messages,
|
||||
long MsgCod,const char *Subject,
|
||||
CloOpe_ClosedOrOpen_t Open,bool Expanded);
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen,
|
||||
bool Expanded);
|
||||
|
||||
static bool Msg_WriteCrsOrgMsg (long CrsCod);
|
||||
|
||||
|
@ -2006,8 +2007,44 @@ static void Msg_ShowASentOrReceivedMessage (struct Msg_Messages *Messages,
|
|||
[Msg_RECEIVED] = ActDelRcvMsg,
|
||||
[Msg_SENT ] = ActDelSntMsg,
|
||||
};
|
||||
static const char *Class[Msg_NUM_TYPES_OF_MSGS][CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[Msg_RECEIVED][CloOpe_CLOSED] = "MSG_BG_NEW",
|
||||
[Msg_RECEIVED][CloOpe_OPEN ] = "MSG_BG",
|
||||
[Msg_SENT ][CloOpe_CLOSED] = "MSG_BG",
|
||||
[Msg_SENT ][CloOpe_OPEN ] = "MSG_BG",
|
||||
};
|
||||
static struct
|
||||
{
|
||||
const char *Icon;
|
||||
const char **Title;
|
||||
} Icons[Msg_NUM_TYPES_OF_MSGS][CloOpe_NUM_CLOSED_OPEN][2] =
|
||||
{
|
||||
[Msg_RECEIVED][CloOpe_CLOSED][false] = {"envelope.svg" ,&Txt_MSG_Unopened },
|
||||
[Msg_RECEIVED][CloOpe_CLOSED][true ] = {"envelope.svg" ,&Txt_MSG_Unopened },
|
||||
[Msg_RECEIVED][CloOpe_OPEN ][false] = {"envelope-open-text.svg",&Txt_MSG_Not_replied},
|
||||
[Msg_RECEIVED][CloOpe_OPEN ][true ] = {"reply.svg" ,&Txt_MSG_Replied },
|
||||
[Msg_SENT ][CloOpe_CLOSED][false] = {"share.svg" ,&Txt_MSG_Sent },
|
||||
[Msg_SENT ][CloOpe_CLOSED][true ] = {"share.svg" ,&Txt_MSG_Sent },
|
||||
[Msg_SENT ][CloOpe_OPEN ][false] = {"share.svg" ,&Txt_MSG_Sent },
|
||||
[Msg_SENT ][CloOpe_OPEN ][true ] = {"share.svg" ,&Txt_MSG_Sent },
|
||||
};
|
||||
static const char *ClassAuthor[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = "MSG_AUT_NEW",
|
||||
[CloOpe_OPEN ] = "MSG_AUT",
|
||||
};
|
||||
static const char *ClassDateTime[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = "MSG_TIT_NEW",
|
||||
[CloOpe_OPEN ] = "MSG_TIT",
|
||||
};
|
||||
static const char *ClassBg[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = "MSG_BG_NEW",
|
||||
[CloOpe_OPEN ] = "MSG_BG",
|
||||
};
|
||||
struct Usr_Data UsrDat;
|
||||
const char *Title = NULL; // Initialized to avoid warning
|
||||
bool FromThisCrs = false; // Initialized to avoid warning
|
||||
time_t CreatTimeUTC; // Creation time of a message
|
||||
long CrsCod;
|
||||
|
@ -2015,7 +2052,7 @@ static void Msg_ShowASentOrReceivedMessage (struct Msg_Messages *Messages,
|
|||
char Content[Cns_MAX_BYTES_LONG_TEXT + 1];
|
||||
struct Med_Media Media;
|
||||
bool Deleted;
|
||||
CloOpe_ClosedOrOpen_t Open = CloOpe_OPEN;
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen = CloOpe_OPEN;
|
||||
bool Replied = false; // Initialized to avoid warning
|
||||
bool Expanded = false;
|
||||
|
||||
|
@ -2027,45 +2064,29 @@ static void Msg_ShowASentOrReceivedMessage (struct Msg_Messages *Messages,
|
|||
switch (Messages->TypeOfMessages)
|
||||
{
|
||||
case Msg_RECEIVED:
|
||||
Msg_DB_GetStatusOfRcvMsg (MsgCod,&Open,&Replied,&Expanded);
|
||||
Msg_DB_GetStatusOfRcvMsg (MsgCod,&ClosedOrOpen,&Replied,&Expanded);
|
||||
break;
|
||||
case Msg_SENT:
|
||||
Expanded = Msg_DB_GetStatusOfSntMsg (MsgCod);
|
||||
break;
|
||||
default:
|
||||
Err_WrongMessageExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
/***** Put an icon with message status *****/
|
||||
switch (Messages->TypeOfMessages)
|
||||
{
|
||||
case Msg_RECEIVED:
|
||||
Title = (Open == CloOpe_OPEN ? (Replied ? Txt_MSG_Replied :
|
||||
Txt_MSG_Not_replied) :
|
||||
Txt_MSG_Unopened);
|
||||
break;
|
||||
case Msg_SENT:
|
||||
Title = Txt_MSG_Sent;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
/***** Icons *****/
|
||||
HTM_TD_Begin ("class=\"CONTEXT_COL %s_%s\"",
|
||||
Messages->TypeOfMessages == Msg_RECEIVED ? (Open == CloOpe_OPEN ? "MSG_BG" :
|
||||
"MSG_BG_NEW") :
|
||||
"MSG_BG",
|
||||
Class[Messages->TypeOfMessages][ClosedOrOpen],
|
||||
The_GetSuffix ());
|
||||
|
||||
/* Type of message icon (envelope, reply...) */
|
||||
Ico_PutIcon (Messages->TypeOfMessages == Msg_RECEIVED ? (Open == CloOpe_OPEN ? (Replied ? "reply.svg" :
|
||||
"envelope-open-text.svg") :
|
||||
"envelope.svg") :
|
||||
"share.svg",
|
||||
Ico_BLACK,Title,"ICO16x16");
|
||||
Ico_PutIcon (Icons[Messages->TypeOfMessages][ClosedOrOpen][Replied].Icon,
|
||||
Ico_BLACK,
|
||||
*Icons[Messages->TypeOfMessages][ClosedOrOpen][Replied].Title,
|
||||
"ICO16x16");
|
||||
|
||||
HTM_BR ();
|
||||
|
||||
|
@ -2076,14 +2097,12 @@ static void Msg_ShowASentOrReceivedMessage (struct Msg_Messages *Messages,
|
|||
HTM_TD_End ();
|
||||
|
||||
/***** Number *****/
|
||||
Msg_WriteMsgNumber (MsgNum,Open == CloOpe_CLOSED);
|
||||
Msg_WriteMsgNumber (MsgNum,ClosedOrOpen == CloOpe_CLOSED);
|
||||
|
||||
/***** Author *****/
|
||||
HTM_TD_Begin ("class=\"LT %s_%s %s_%s\"",
|
||||
Open == CloOpe_OPEN ? "MSG_AUT" :
|
||||
"MSG_AUT_NEW",The_GetSuffix (),
|
||||
Open == CloOpe_OPEN ? "MSG_BG" :
|
||||
"MSG_BG_NEW",The_GetSuffix ());
|
||||
ClassAuthor[ClosedOrOpen],The_GetSuffix (),
|
||||
ClassBg[ClosedOrOpen],The_GetSuffix ());
|
||||
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,
|
||||
Usr_DONT_GET_PREFS,
|
||||
Usr_DONT_GET_ROLE_IN_CRS);
|
||||
|
@ -2091,14 +2110,12 @@ static void Msg_ShowASentOrReceivedMessage (struct Msg_Messages *Messages,
|
|||
HTM_TD_End ();
|
||||
|
||||
/***** Subject *****/
|
||||
Msg_WriteSentOrReceivedMsgSubject (Messages,MsgCod,Subject,Open,Expanded);
|
||||
Msg_WriteSentOrReceivedMsgSubject (Messages,MsgCod,Subject,ClosedOrOpen,Expanded);
|
||||
|
||||
/***** Date-time *****/
|
||||
Msg_WriteMsgDate (CreatTimeUTC,
|
||||
Open == CloOpe_OPEN ? "MSG_TIT" :
|
||||
"MSG_TIT_NEW",
|
||||
Open == CloOpe_OPEN ? "MSG_BG" :
|
||||
"MSG_BG_NEW");
|
||||
ClassDateTime[ClosedOrOpen],
|
||||
ClassBg[ClosedOrOpen]);
|
||||
|
||||
HTM_TR_End ();
|
||||
|
||||
|
@ -2249,30 +2266,48 @@ void Msg_WriteMsgNumber (unsigned long MsgNum,bool NewMsg)
|
|||
|
||||
static void Msg_WriteSentOrReceivedMsgSubject (struct Msg_Messages *Messages,
|
||||
long MsgCod,const char *Subject,
|
||||
CloOpe_ClosedOrOpen_t Open,bool Expanded)
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen,
|
||||
bool Expanded)
|
||||
{
|
||||
extern const char *Txt_Hide_message;
|
||||
extern const char *Txt_See_message;
|
||||
extern const char *Txt_Hide_message;
|
||||
extern const char *Txt_no_subject;
|
||||
static const char *ClassSubject[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = "MSG_TIT_NEW",
|
||||
[CloOpe_OPEN ] = "MSG_TIT",
|
||||
};
|
||||
static const char *ClassBg[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = "MSG_BG_NEW",
|
||||
[CloOpe_OPEN ] = "MSG_BG",
|
||||
};
|
||||
static Act_Action_t Action[Msg_NUM_TYPES_OF_MSGS][2] =
|
||||
{
|
||||
[Msg_WRITING ][false] = ActUnk,
|
||||
[Msg_WRITING ][true ] = ActUnk,
|
||||
[Msg_RECEIVED][false] = ActExpRcvMsg,
|
||||
[Msg_RECEIVED][true ] = ActConRcvMsg,
|
||||
[Msg_SENT ][false] = ActExpSntMsg,
|
||||
[Msg_SENT ][true ] = ActConSntMsg,
|
||||
};
|
||||
static const char **Title[2] =
|
||||
{
|
||||
[false] = &Txt_See_message,
|
||||
[true ] = &Txt_Hide_message,
|
||||
};
|
||||
|
||||
/***** Begin cell *****/
|
||||
HTM_TD_Begin ("class=\"LT %s_%s %s_%s\"",
|
||||
Open == CloOpe_OPEN ? "MSG_TIT" :
|
||||
"MSG_TIT_NEW",The_GetSuffix (),
|
||||
Open == CloOpe_OPEN ? "MSG_BG" :
|
||||
"MSG_BG_NEW" ,The_GetSuffix ());
|
||||
ClassSubject[ClosedOrOpen],The_GetSuffix (),
|
||||
ClassBg[ClosedOrOpen],The_GetSuffix ());
|
||||
|
||||
/***** Begin form to expand/contract the message *****/
|
||||
Frm_BeginForm (Messages->TypeOfMessages == Msg_RECEIVED ? (Expanded ? ActConRcvMsg :
|
||||
ActExpRcvMsg) :
|
||||
(Expanded ? ActConSntMsg :
|
||||
ActExpSntMsg));
|
||||
Frm_BeginForm (Action[Messages->TypeOfMessages][Expanded]);
|
||||
Messages->MsgCod = MsgCod; // Message to be contracted/expanded
|
||||
Msg_PutParsOneMsg (Messages);
|
||||
|
||||
HTM_BUTTON_Submit_Begin (Expanded ? Txt_Hide_message :
|
||||
Txt_See_message,
|
||||
"class=\"LT BT_LINK\"");
|
||||
HTM_BUTTON_Submit_Begin (*Title[Expanded],"class=\"LT BT_LINK\"");
|
||||
|
||||
/***** Write subject *****/
|
||||
if (Subject[0])
|
||||
|
|
|
@ -726,8 +726,8 @@ bool Msg_DB_GetStatusOfSntMsg (long MsgCod)
|
|||
/********* Get if a received message has been open/replied/expanded **********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Msg_DB_GetStatusOfRcvMsg (long MsgCod,
|
||||
CloOpe_ClosedOrOpen_t *Open,bool *Replied,bool *Expanded)
|
||||
void Msg_DB_GetStatusOfRcvMsg (long MsgCod,CloOpe_ClosedOrOpen_t *ClosedOrOpen,
|
||||
bool *Replied,bool *Expanded)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
|
@ -751,10 +751,9 @@ void Msg_DB_GetStatusOfRcvMsg (long MsgCod,
|
|||
/***** Get if message has been read by me (row[0]),
|
||||
if message has been replied (row[1]), and
|
||||
if message is expanded (row[2]) *****/
|
||||
*Open = (row[0][0] == 'Y') ? CloOpe_OPEN :
|
||||
CloOpe_CLOSED;
|
||||
*Replied = (row[1][0] == 'Y');
|
||||
*Expanded = (row[2][0] == 'Y');
|
||||
*ClosedOrOpen = CloOpe_GetClosedOrOpenFromYN (row[0][0]);
|
||||
*Replied = (row[1][0] == 'Y');
|
||||
*Expanded = (row[2][0] == 'Y');
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
|
|
@ -69,8 +69,8 @@ void Msg_DB_GetMsgSubject (long MsgCod,char Subject[Cns_MAX_BYTES_SUBJECT + 1]);
|
|||
unsigned Msg_DB_GetMsgContent (MYSQL_RES **mysql_res,long MsgCod);
|
||||
unsigned Msg_DB_GetMsgSntData (MYSQL_RES **mysql_res,long MsgCod,bool *Deleted);
|
||||
bool Msg_DB_GetStatusOfSntMsg (long MsgCod);
|
||||
void Msg_DB_GetStatusOfRcvMsg (long MsgCod,
|
||||
CloOpe_ClosedOrOpen_t *Open,bool *Replied,bool *Expanded);
|
||||
void Msg_DB_GetStatusOfRcvMsg (long MsgCod,CloOpe_ClosedOrOpen_t *Open,
|
||||
bool *Replied,bool *Expanded);
|
||||
bool Msg_DB_CheckIfSntMsgIsDeleted (long MsgCod);
|
||||
bool Msg_DB_CheckIfRcvMsgIsDeletedForAllItsRecipients (long MsgCod);
|
||||
long Msg_DB_GetSender (long MsgCod);
|
||||
|
|
|
@ -415,6 +415,7 @@ static void Prg_WriteRowItem (Prg_ListingType_t ListingType,
|
|||
long SelectedItmCod,
|
||||
long SelectedRscCod)
|
||||
{
|
||||
extern const char *CloOpe_Class[CloOpe_NUM_CLOSED_OPEN][HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_PrgClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
static unsigned UniqueId = 0;
|
||||
static Vie_ViewType_t ViewingOrEditingProgram[Prg_NUM_LISTING_TYPES] =
|
||||
|
@ -557,9 +558,7 @@ static void Prg_WriteRowItem (Prg_ListingType_t ListingType,
|
|||
Err_NotEnoughMemoryExit ();
|
||||
HTM_DIV_Begin ("id=\"%s\" class=\"%s_%s%s\"",
|
||||
Id,
|
||||
Item->Open == CloOpe_OPEN ? "DATE_GREEN" :
|
||||
"DATE_RED",
|
||||
The_GetSuffix (),
|
||||
CloOpe_Class[Item->ClosedOrOpen][HidVis_VISIBLE],The_GetSuffix (),
|
||||
HidVis_PrgClass[HiddenOrVisible]);
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Item->TimeUTC[StartEndTime],
|
||||
Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA,
|
||||
|
@ -1223,8 +1222,7 @@ static void Prg_GetItemDataFromRow (MYSQL_RES **mysql_res,
|
|||
Item->TimeUTC[Dat_END_TIME] = Dat_GetUNIXTimeFromStr (row[6]);
|
||||
|
||||
/* Get whether the program item is open or closed (row(7)) */
|
||||
Item->Open = (row[7][0] == '1') ? CloOpe_OPEN :
|
||||
CloOpe_CLOSED;
|
||||
Item->ClosedOrOpen = CloOpe_GetClosedOrOpenFrom01 (row[7][0]);
|
||||
|
||||
/* Get the title of the program item (row[8]) */
|
||||
Str_Copy (Item->Title,row[8],sizeof (Item->Title) - 1);
|
||||
|
@ -1266,7 +1264,7 @@ void Prg_ResetItem (struct Prg_Item *Item)
|
|||
Item->UsrCod = -1L;
|
||||
Item->TimeUTC[Dat_STR_TIME] =
|
||||
Item->TimeUTC[Dat_END_TIME] = (time_t) 0;
|
||||
Item->Open = CloOpe_CLOSED;
|
||||
Item->ClosedOrOpen = CloOpe_CLOSED;
|
||||
Item->Title[0] = '\0';
|
||||
Prg_ResetResource (Item);
|
||||
}
|
||||
|
@ -1895,7 +1893,7 @@ static void Prg_ShowFormToCreateItem (long ParentItmCod)
|
|||
Prg_ResetItem (&Item);
|
||||
Item.TimeUTC[Dat_STR_TIME] = Dat_GetStartExecutionTimeUTC ();
|
||||
Item.TimeUTC[Dat_END_TIME] = Item.TimeUTC[Dat_STR_TIME] + (2 * 60 * 60); // +2 hours
|
||||
Item.Open = CloOpe_OPEN;
|
||||
Item.ClosedOrOpen = CloOpe_OPEN;
|
||||
|
||||
/***** Show pending alerts */
|
||||
Ale_ShowAlerts (NULL);
|
||||
|
|
|
@ -62,7 +62,7 @@ struct Prg_Item
|
|||
unsigned NumItem;
|
||||
long UsrCod;
|
||||
time_t TimeUTC[Dat_NUM_START_END_TIME];
|
||||
CloOpe_ClosedOrOpen_t Open;
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen;
|
||||
char Title[Prg_MAX_BYTES_PROGRAM_ITEM_TITLE + 1];
|
||||
struct
|
||||
{
|
||||
|
|
161
swad_survey.c
161
swad_survey.c
|
@ -389,8 +389,7 @@ void Svy_SeeOneSurvey (void)
|
|||
static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys,
|
||||
bool ShowOnlyThisSvyComplete)
|
||||
{
|
||||
extern const char *HidVis_DateGreenClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_DateRedClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *CloOpe_Class[CloOpe_NUM_CLOSED_OPEN][HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_TitleClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_GroupClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_DataClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
|
@ -450,16 +449,13 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys,
|
|||
if (ShowOnlyThisSvyComplete)
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s\"",
|
||||
Id,
|
||||
Surveys->Svy.Status.Open == CloOpe_OPEN ? HidVis_DateGreenClass[Surveys->Svy.Status.HiddenOrVisible] :
|
||||
HidVis_DateRedClass[Surveys->Svy.Status.HiddenOrVisible],
|
||||
CloOpe_Class[Surveys->Svy.Status.ClosedOrOpen][Surveys->Svy.Status.HiddenOrVisible],
|
||||
The_GetSuffix ());
|
||||
else
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s %s\"",
|
||||
Id,
|
||||
Surveys->Svy.Status.Open == CloOpe_OPEN ? HidVis_DateGreenClass[Surveys->Svy.Status.HiddenOrVisible] :
|
||||
HidVis_DateRedClass[Surveys->Svy.Status.HiddenOrVisible],
|
||||
The_GetSuffix (),
|
||||
The_GetColorRows ());
|
||||
CloOpe_Class[Surveys->Svy.Status.ClosedOrOpen][Surveys->Svy.Status.HiddenOrVisible],
|
||||
The_GetSuffix (),The_GetColorRows ());
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Surveys->Svy.TimeUTC[Dat_STR_TIME],
|
||||
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
||||
true,true,true,0x7);
|
||||
|
@ -472,14 +468,12 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys,
|
|||
if (ShowOnlyThisSvyComplete)
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s\"",
|
||||
Id,
|
||||
Surveys->Svy.Status.Open == CloOpe_OPEN ? HidVis_DateGreenClass[Surveys->Svy.Status.HiddenOrVisible] :
|
||||
HidVis_DateRedClass[Surveys->Svy.Status.HiddenOrVisible],
|
||||
CloOpe_Class[Surveys->Svy.Status.ClosedOrOpen][Surveys->Svy.Status.HiddenOrVisible],
|
||||
The_GetSuffix ());
|
||||
else
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s %s\"",
|
||||
Id,
|
||||
Surveys->Svy.Status.Open == CloOpe_OPEN ? HidVis_DateGreenClass[Surveys->Svy.Status.HiddenOrVisible] :
|
||||
HidVis_DateRedClass[Surveys->Svy.Status.HiddenOrVisible],
|
||||
CloOpe_Class[Surveys->Svy.Status.ClosedOrOpen][Surveys->Svy.Status.HiddenOrVisible],
|
||||
The_GetSuffix (),
|
||||
The_GetColorRows ());
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Surveys->Svy.TimeUTC[Dat_END_TIME],
|
||||
|
@ -695,6 +689,7 @@ static void Svy_WriteAuthor (struct Svy_Survey *Svy)
|
|||
|
||||
static void Svy_WriteStatus (struct Svy_Survey *Svy)
|
||||
{
|
||||
extern const char *CloOpe_Class[CloOpe_NUM_CLOSED_OPEN][HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *Txt_Hidden_survey;
|
||||
extern const char *Txt_Visible_survey;
|
||||
extern const char *Txt_Closed_survey;
|
||||
|
@ -705,104 +700,79 @@ static void Svy_WriteStatus (struct Svy_Survey *Svy)
|
|||
extern const char *Txt_SURVEY_You_dont_belong_to_the_scope_of_the_survey;
|
||||
extern const char *Txt_SURVEY_You_have_already_answered;
|
||||
extern const char *Txt_SURVEY_You_have_not_answered;
|
||||
extern const char *HidVis_DateGreenClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
extern const char *HidVis_DateRedClass[HidVis_NUM_HIDDEN_VISIBLE];
|
||||
static struct
|
||||
static const char *HiddenOrVisibleClass[HidVis_NUM_HIDDEN_VISIBLE] =
|
||||
{
|
||||
const char **Class;
|
||||
const char **Txt;
|
||||
} HiddenOrVisible[HidVis_NUM_HIDDEN_VISIBLE] =
|
||||
{
|
||||
[HidVis_HIDDEN ] =
|
||||
{
|
||||
.Class = &HidVis_DateRedClass [HidVis_HIDDEN ],
|
||||
.Txt = &Txt_Hidden_survey
|
||||
},
|
||||
[HidVis_VISIBLE] =
|
||||
{
|
||||
.Class = &HidVis_DateGreenClass[HidVis_VISIBLE],
|
||||
.Txt = &Txt_Visible_survey
|
||||
}
|
||||
[HidVis_HIDDEN ] = "DATE_RED_LIGHT",
|
||||
[HidVis_VISIBLE] = "DATE_GREEN",
|
||||
};
|
||||
static const char **HiddenOrVisibleTxt[HidVis_NUM_HIDDEN_VISIBLE] =
|
||||
{
|
||||
[HidVis_HIDDEN ] = &Txt_Hidden_survey,
|
||||
[HidVis_VISIBLE] = &Txt_Visible_survey,
|
||||
};
|
||||
static const char **ClosedOrOpenTxt[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = &Txt_Closed_survey,
|
||||
[CloOpe_OPEN ] = &Txt_Open_survey,
|
||||
};
|
||||
static const char **ClosedOrOpenDependingOnMyRoleTxt[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = &Txt_SURVEY_Type_of_user_not_allowed,
|
||||
[CloOpe_OPEN ] = &Txt_SURVEY_Type_of_user_allowed,
|
||||
};
|
||||
static const char **ClosedOrOpenDependingOnScopeTxt[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = &Txt_SURVEY_You_dont_belong_to_the_scope_of_the_survey,
|
||||
[CloOpe_OPEN ] = &Txt_SURVEY_You_belong_to_the_scope_of_the_survey,
|
||||
};
|
||||
static const char **ClosedOrOpenDependingOnAlreadyAnsweredTxt[CloOpe_NUM_CLOSED_OPEN] =
|
||||
{
|
||||
[CloOpe_CLOSED] = &Txt_SURVEY_You_have_already_answered,
|
||||
[CloOpe_OPEN ] = &Txt_SURVEY_You_have_not_answered,
|
||||
};
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpenDependingOnMyRole = Svy->Status.IAmLoggedWithAValidRoleToAnswer ? CloOpe_OPEN :
|
||||
CloOpe_CLOSED;
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpenDependingOnScope = Svy->Status.IBelongToScope ? CloOpe_OPEN :
|
||||
CloOpe_CLOSED;
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpenDependingOnAlreadyAnswered = Svy->Status.IHaveAnswered ? CloOpe_CLOSED :
|
||||
CloOpe_OPEN;
|
||||
|
||||
/***** Begin list with items of status *****/
|
||||
HTM_UL_Begin (NULL);
|
||||
|
||||
/* Write whether survey is visible or hidden */
|
||||
HTM_LI_Begin ("class=\"%s_%s\"",
|
||||
*HiddenOrVisible[Svy->Status.HiddenOrVisible].Class,
|
||||
HiddenOrVisibleClass[Svy->Status.HiddenOrVisible],
|
||||
The_GetSuffix ());
|
||||
HTM_Txt (*HiddenOrVisible[Svy->Status.HiddenOrVisible].Txt);
|
||||
HTM_Txt (*HiddenOrVisibleTxt[Svy->Status.HiddenOrVisible]);
|
||||
HTM_LI_End ();
|
||||
|
||||
/* Write whether survey is open or closed */
|
||||
switch (Svy->Status.Open)
|
||||
{
|
||||
case CloOpe_OPEN:
|
||||
HTM_LI_Begin ("class=\"%s_%s\"",
|
||||
HidVis_DateGreenClass[Svy->Status.HiddenOrVisible],
|
||||
The_GetSuffix ());
|
||||
HTM_Txt (Txt_Open_survey);
|
||||
break;
|
||||
case CloOpe_CLOSED:
|
||||
default:
|
||||
HTM_LI_Begin ("class=\"%s_%s\"",
|
||||
HidVis_DateRedClass[Svy->Status.HiddenOrVisible],
|
||||
The_GetSuffix ());
|
||||
HTM_Txt (Txt_Closed_survey);
|
||||
break;
|
||||
}
|
||||
HTM_LI_Begin ("class=\"%s_%s\"",
|
||||
CloOpe_Class[Svy->Status.ClosedOrOpen][Svy->Status.HiddenOrVisible],
|
||||
The_GetSuffix ());
|
||||
HTM_Txt (*ClosedOrOpenTxt[Svy->Status.ClosedOrOpen]);
|
||||
HTM_LI_End ();
|
||||
|
||||
/* Write whether survey can be answered by me or not depending on user type */
|
||||
if (Svy->Status.IAmLoggedWithAValidRoleToAnswer)
|
||||
{
|
||||
HTM_LI_Begin ("class=\"%s_%s\"",
|
||||
HidVis_DateGreenClass[Svy->Status.HiddenOrVisible],
|
||||
The_GetSuffix ());
|
||||
HTM_Txt (Txt_SURVEY_Type_of_user_allowed);
|
||||
}
|
||||
else
|
||||
{
|
||||
HTM_LI_Begin ("class=\"%s_%s\"",
|
||||
HidVis_DateRedClass[Svy->Status.HiddenOrVisible],
|
||||
The_GetSuffix ());
|
||||
HTM_Txt (Txt_SURVEY_Type_of_user_not_allowed);
|
||||
}
|
||||
/* Write whether survey can be answered by me or not depending on my role */
|
||||
HTM_LI_Begin ("class=\"%s_%s\"",
|
||||
CloOpe_Class[ClosedOrOpenDependingOnMyRole][Svy->Status.HiddenOrVisible],
|
||||
The_GetSuffix ());
|
||||
HTM_Txt (*ClosedOrOpenDependingOnMyRoleTxt[ClosedOrOpenDependingOnMyRole]);
|
||||
HTM_LI_End ();
|
||||
|
||||
/* Write whether survey can be answered by me or not depending on groups */
|
||||
if (Svy->Status.IBelongToScope)
|
||||
{
|
||||
HTM_LI_Begin ("class=\"%s_%s\"",
|
||||
HidVis_DateGreenClass[Svy->Status.HiddenOrVisible],
|
||||
The_GetSuffix ());
|
||||
HTM_Txt (Txt_SURVEY_You_belong_to_the_scope_of_the_survey);
|
||||
}
|
||||
else
|
||||
{
|
||||
HTM_LI_Begin ("class=\"%s_%s\"",
|
||||
HidVis_DateRedClass[Svy->Status.HiddenOrVisible],
|
||||
The_GetSuffix ());
|
||||
HTM_Txt (Txt_SURVEY_You_dont_belong_to_the_scope_of_the_survey);
|
||||
}
|
||||
HTM_LI_Begin ("class=\"%s_%s\"",
|
||||
CloOpe_Class[ClosedOrOpenDependingOnScope][Svy->Status.HiddenOrVisible],
|
||||
The_GetSuffix ());
|
||||
HTM_Txt (*ClosedOrOpenDependingOnScopeTxt[ClosedOrOpenDependingOnScope]);
|
||||
HTM_LI_End ();
|
||||
|
||||
/* Write whether survey has been already answered by me or not */
|
||||
if (Svy->Status.IHaveAnswered)
|
||||
{
|
||||
HTM_LI_Begin ("class=\"%s_%s\"",
|
||||
HidVis_DateGreenClass[Svy->Status.HiddenOrVisible],
|
||||
The_GetSuffix ());
|
||||
HTM_Txt (Txt_SURVEY_You_have_already_answered);
|
||||
}
|
||||
else
|
||||
{
|
||||
HTM_LI_Begin ("class=\"%s_%s\"",
|
||||
HidVis_DateRedClass[Svy->Status.HiddenOrVisible],
|
||||
The_GetSuffix ());
|
||||
HTM_Txt (Txt_SURVEY_You_have_not_answered);
|
||||
}
|
||||
HTM_LI_Begin ("class=\"%s_%s\"",
|
||||
CloOpe_Class[ClosedOrOpenDependingOnAlreadyAnswered][Svy->Status.HiddenOrVisible],
|
||||
The_GetSuffix ());
|
||||
HTM_Txt (*ClosedOrOpenDependingOnAlreadyAnsweredTxt[ClosedOrOpenDependingOnAlreadyAnswered]);
|
||||
HTM_LI_End ();
|
||||
|
||||
/***** End list with items of status *****/
|
||||
|
@ -1136,8 +1106,7 @@ void Svy_GetSurveyDataByCod (struct Svy_Survey *Svy)
|
|||
Svy->TimeUTC[Dat_END_TIME] = Dat_GetUNIXTimeFromStr (row[7]);
|
||||
|
||||
/* Get whether the survey is open or closed (row(8)) */
|
||||
Svy->Status.Open = (row[8][0] == '1') ? CloOpe_OPEN :
|
||||
CloOpe_CLOSED;
|
||||
Svy->Status.ClosedOrOpen = CloOpe_GetClosedOrOpenFrom01 (row[8][0]);
|
||||
|
||||
/* Get the title of the survey (row[9]) */
|
||||
Str_Copy (Svy->Title,row[9],sizeof (Svy->Title) - 1);
|
||||
|
@ -1176,7 +1145,7 @@ void Svy_GetSurveyDataByCod (struct Svy_Survey *Svy)
|
|||
/* Can I answer survey? */
|
||||
Svy->Status.ICanAnswer = ( Svy->NumQsts != 0) &&
|
||||
Svy->Status.HiddenOrVisible == HidVis_VISIBLE &&
|
||||
Svy->Status.Open == CloOpe_OPEN &&
|
||||
Svy->Status.ClosedOrOpen == CloOpe_OPEN &&
|
||||
Svy->Status.IAmLoggedWithAValidRoleToAnswer &&
|
||||
Svy->Status.IBelongToScope &&
|
||||
!Svy->Status.IHaveAnswered;
|
||||
|
@ -1194,7 +1163,7 @@ void Svy_GetSurveyDataByCod (struct Svy_Survey *Svy)
|
|||
Svy->Level == Hie_SYS) &&
|
||||
(Svy->NumQsts != 0) &&
|
||||
Svy->Status.HiddenOrVisible == HidVis_VISIBLE &&
|
||||
Svy->Status.Open == CloOpe_OPEN &&
|
||||
Svy->Status.ClosedOrOpen == CloOpe_OPEN &&
|
||||
Svy->Status.IAmLoggedWithAValidRoleToAnswer &&
|
||||
Svy->Status.IBelongToScope &&
|
||||
Svy->Status.IHaveAnswered;
|
||||
|
@ -1283,7 +1252,7 @@ void Svy_GetSurveyDataByCod (struct Svy_Survey *Svy)
|
|||
Svy->NumQsts = 0;
|
||||
Svy->NumUsrs = 0;
|
||||
Svy->Status.HiddenOrVisible = HidVis_VISIBLE;
|
||||
Svy->Status.Open = CloOpe_CLOSED;
|
||||
Svy->Status.ClosedOrOpen = CloOpe_CLOSED;
|
||||
Svy->Status.IAmLoggedWithAValidRoleToAnswer = false;
|
||||
Svy->Status.IBelongToScope = false;
|
||||
Svy->Status.IHaveAnswered = false;
|
||||
|
@ -1608,7 +1577,7 @@ void Svy_ReqCreatOrEditSvy (void)
|
|||
Surveys.Svy.NumQsts = 0;
|
||||
Surveys.Svy.NumUsrs = 0;
|
||||
Surveys.Svy.Status.HiddenOrVisible = HidVis_VISIBLE;
|
||||
Surveys.Svy.Status.Open = CloOpe_OPEN;
|
||||
Surveys.Svy.Status.ClosedOrOpen = CloOpe_OPEN;
|
||||
Surveys.Svy.Status.IAmLoggedWithAValidRoleToAnswer = false;
|
||||
Surveys.Svy.Status.IBelongToScope = false;
|
||||
Surveys.Svy.Status.IHaveAnswered = false;
|
||||
|
|
|
@ -54,7 +54,7 @@ struct Svy_Survey
|
|||
struct
|
||||
{
|
||||
HidVis_HiddenOrVisible_t HiddenOrVisible; // Survey is hidden or visible?
|
||||
CloOpe_ClosedOrOpen_t Open; // Start date <= now <= end date
|
||||
CloOpe_ClosedOrOpen_t ClosedOrOpen; // Start date <= now <= end date
|
||||
bool IAmLoggedWithAValidRoleToAnswer; // I am logged with a valid role to answer this survey
|
||||
bool IBelongToScope; // I belong to the scope of this survey
|
||||
bool IHaveAnswered; // I have already answered this survey
|
||||
|
|
Loading…
Reference in New Issue