mirror of https://github.com/acanas/swad-core.git
Version 22.2: Sep 13, 2022 Code refactoring in program resources.
This commit is contained in:
parent
89dcb04f11
commit
d25716a0a4
|
@ -606,10 +606,11 @@ TODO: Fix bug: error al enviar un mensaje a dos recipientes, error on duplicate
|
||||||
|
|
||||||
TODO: Attach pdf files in multimedia.
|
TODO: Attach pdf files in multimedia.
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 22.1 (2022-09-13)"
|
#define Log_PLATFORM_VERSION "SWAD 22.2 (2022-09-13)"
|
||||||
#define CSS_FILE "swad21.107.1.css"
|
#define CSS_FILE "swad21.107.1.css"
|
||||||
#define JS_FILE "swad21.100.js"
|
#define JS_FILE "swad21.100.js"
|
||||||
/*
|
/*
|
||||||
|
Version 22.2: Sep 13, 2022 Code refactoring in program resources. (329795 lines)
|
||||||
Version 22.1: Sep 13, 2022 Code refactoring in program resources. (329693 lines)
|
Version 22.1: Sep 13, 2022 Code refactoring in program resources. (329693 lines)
|
||||||
Version 22.0: Sep 12, 2022 New action to change resource link. Not implemented. (329606 lines)
|
Version 22.0: Sep 12, 2022 New action to change resource link. Not implemented. (329606 lines)
|
||||||
Version 21.117.1: Sep 12, 2022 Copy link to file into resource clipboard. (329561 lines)
|
Version 21.117.1: Sep 12, 2022 Copy link to file into resource clipboard. (329561 lines)
|
||||||
|
|
211
swad_program.c
211
swad_program.c
|
@ -148,7 +148,6 @@ static void Prg_GetDataOfItemByCod (struct Prg_Item *Item);
|
||||||
static void Prg_GetDataOfItem (struct Prg_Item *Item,
|
static void Prg_GetDataOfItem (struct Prg_Item *Item,
|
||||||
MYSQL_RES **mysql_res,
|
MYSQL_RES **mysql_res,
|
||||||
unsigned NumRows);
|
unsigned NumRows);
|
||||||
static void Prg_ResetItem (struct Prg_Item *Item);
|
|
||||||
|
|
||||||
static void Prg_HideOrUnhideItem (bool Hide);
|
static void Prg_HideOrUnhideItem (bool Hide);
|
||||||
|
|
||||||
|
@ -290,7 +289,7 @@ void Prg_ShowAllItems (Prg_ListingType_t ListingType,
|
||||||
Prg_GetDataOfItemByCod (&Item);
|
Prg_GetDataOfItemByCod (&Item);
|
||||||
|
|
||||||
/* Begin range to highlight? */
|
/* Begin range to highlight? */
|
||||||
if (Item.Hierarchy.Index == ToHighlight.Begin) // Begin of the highlighted range
|
if (Item.Hierarchy.ItmInd == ToHighlight.Begin) // Begin of the highlighted range
|
||||||
{
|
{
|
||||||
if (FirstTBodyOpen)
|
if (FirstTBodyOpen)
|
||||||
{
|
{
|
||||||
|
@ -326,7 +325,7 @@ void Prg_ShowAllItems (Prg_ListingType_t ListingType,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End range to highlight? */
|
/* End range to highlight? */
|
||||||
if (Item.Hierarchy.Index == ToHighlight.End) // End of the highlighted range
|
if (Item.Hierarchy.ItmInd == ToHighlight.End) // End of the highlighted range
|
||||||
{
|
{
|
||||||
HTM_TBODY_End (); // Highlighted tbody end
|
HTM_TBODY_End (); // Highlighted tbody end
|
||||||
if (NumItem < Prg_Gbl.List.NumItems - 1) // Not the last item
|
if (NumItem < Prg_Gbl.List.NumItems - 1) // Not the last item
|
||||||
|
@ -420,12 +419,12 @@ static void Prg_PutIconToViewProgram (void)
|
||||||
|
|
||||||
static void Prg_PutIconToCreateNewItem (void)
|
static void Prg_PutIconToCreateNewItem (void)
|
||||||
{
|
{
|
||||||
struct Prg_ItmRsc SelectedItmRsc;
|
struct Prg_ItmRscCodes SelectedItmRscCodes;
|
||||||
|
|
||||||
SelectedItmRsc.ItmCod = -1L;
|
SelectedItmRscCodes.ItmCod = -1L;
|
||||||
SelectedItmRsc.RscCod = -1L;
|
SelectedItmRscCodes.RscCod = -1L;
|
||||||
Ico_PutContextualIconToAdd (ActFrmNewPrgItm,Prg_ITEM_SECTION_ID,
|
Ico_PutContextualIconToAdd (ActFrmNewPrgItm,Prg_ITEM_SECTION_ID,
|
||||||
Prg_PutParams,&SelectedItmRsc);
|
Prg_PutParams,&SelectedItmRscCodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -435,12 +434,12 @@ static void Prg_PutIconToCreateNewItem (void)
|
||||||
static void Prg_PutButtonToCreateNewItem (void)
|
static void Prg_PutButtonToCreateNewItem (void)
|
||||||
{
|
{
|
||||||
extern const char *Txt_New_item;
|
extern const char *Txt_New_item;
|
||||||
struct Prg_ItmRsc SelectedItmRsc;
|
struct Prg_ItmRscCodes SelectedItmRscCodes;
|
||||||
|
|
||||||
SelectedItmRsc.ItmCod = -1L;
|
SelectedItmRscCodes.ItmCod = -1L;
|
||||||
SelectedItmRsc.RscCod = -1L;
|
SelectedItmRscCodes.RscCod = -1L;
|
||||||
Frm_BeginFormAnchor (ActFrmNewPrgItm,Prg_ITEM_SECTION_ID);
|
Frm_BeginFormAnchor (ActFrmNewPrgItm,Prg_ITEM_SECTION_ID);
|
||||||
Prg_PutParams (&SelectedItmRsc);
|
Prg_PutParams (&SelectedItmRscCodes);
|
||||||
Btn_PutConfirmButton (Txt_New_item);
|
Btn_PutConfirmButton (Txt_New_item);
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
}
|
}
|
||||||
|
@ -475,7 +474,7 @@ static void Prg_WriteRowItem (Prg_ListingType_t ListingType,
|
||||||
unsigned NumCol;
|
unsigned NumCol;
|
||||||
char *TitleClass;
|
char *TitleClass;
|
||||||
Dat_StartEndTime_t StartEndTime;
|
Dat_StartEndTime_t StartEndTime;
|
||||||
struct Prg_ItmRsc SelectedItmRsc;
|
struct Prg_ItmRscCodes SelectedItmRscCodes;
|
||||||
|
|
||||||
/***** Check if this item should be shown as hidden *****/
|
/***** Check if this item should be shown as hidden *****/
|
||||||
Prg_SetHiddenLevel (Item->Hierarchy.Level,Item->Hierarchy.Hidden);
|
Prg_SetHiddenLevel (Item->Hierarchy.Level,Item->Hierarchy.Hidden);
|
||||||
|
@ -612,9 +611,9 @@ static void Prg_WriteRowItem (Prg_ListingType_t ListingType,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* List of resources */
|
/* List of resources */
|
||||||
SelectedItmRsc.ItmCod = Item->Hierarchy.ItmCod;
|
SelectedItmRscCodes.ItmCod = Item->Hierarchy.ItmCod;
|
||||||
SelectedItmRsc.RscCod = SelectedRscCod;
|
SelectedItmRscCodes.RscCod = SelectedRscCod;
|
||||||
PrgRsc_ListItemResources (ListingType,&SelectedItmRsc);
|
PrgRsc_ListItemResources (ListingType,&SelectedItmRscCodes);
|
||||||
|
|
||||||
/* End text and resources */
|
/* End text and resources */
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
@ -886,24 +885,24 @@ static void Prg_PutFormsToRemEditOneItem (Prg_ListingType_t ListingType,
|
||||||
[true ] = ActUnhPrgItm, // Hidden ==> action to unhide
|
[true ] = ActUnhPrgItm, // Hidden ==> action to unhide
|
||||||
};
|
};
|
||||||
char StrItemIndex[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
|
char StrItemIndex[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
|
||||||
struct Prg_ItmRsc SelectedItmRsc;
|
struct Prg_ItmRscCodes SelectedItmRscCodes;
|
||||||
|
|
||||||
/***** Initialize item index string *****/
|
/***** Initialize item index string *****/
|
||||||
snprintf (StrItemIndex,sizeof (StrItemIndex),"%u",Item->Hierarchy.Index);
|
snprintf (StrItemIndex,sizeof (StrItemIndex),"%u",Item->Hierarchy.ItmInd);
|
||||||
|
|
||||||
SelectedItmRsc.ItmCod = Item->Hierarchy.ItmCod;
|
SelectedItmRscCodes.ItmCod = Item->Hierarchy.ItmCod;
|
||||||
SelectedItmRsc.RscCod = -1L;
|
SelectedItmRscCodes.RscCod = -1L;
|
||||||
switch (Gbl.Usrs.Me.Role.Logged)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
{
|
{
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
/***** Icon to remove program item *****/
|
/***** Icon to remove program item *****/
|
||||||
Ico_PutContextualIconToRemove (ActReqRemPrgItm,NULL,
|
Ico_PutContextualIconToRemove (ActReqRemPrgItm,NULL,
|
||||||
Prg_PutParams,&SelectedItmRsc);
|
Prg_PutParams,&SelectedItmRscCodes);
|
||||||
|
|
||||||
/***** Icon to hide/unhide program item *****/
|
/***** Icon to hide/unhide program item *****/
|
||||||
Ico_PutContextualIconToHideUnhide (ActionHideUnhide,"prg_highlighted",
|
Ico_PutContextualIconToHideUnhide (ActionHideUnhide,"prg_highlighted",
|
||||||
Prg_PutParams,&SelectedItmRsc,
|
Prg_PutParams,&SelectedItmRscCodes,
|
||||||
Item->Hierarchy.Hidden);
|
Item->Hierarchy.Hidden);
|
||||||
|
|
||||||
/***** Icon to edit program item *****/
|
/***** Icon to edit program item *****/
|
||||||
|
@ -911,24 +910,24 @@ static void Prg_PutFormsToRemEditOneItem (Prg_ListingType_t ListingType,
|
||||||
{
|
{
|
||||||
case Prg_FORM_EDIT_ITEM:
|
case Prg_FORM_EDIT_ITEM:
|
||||||
Ico_PutContextualIconToView (ActSeePrgItm,Prg_ITEM_SECTION_ID,
|
Ico_PutContextualIconToView (ActSeePrgItm,Prg_ITEM_SECTION_ID,
|
||||||
Prg_PutParams,&SelectedItmRsc);
|
Prg_PutParams,&SelectedItmRscCodes);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Ico_PutContextualIconToEdit (ActFrmChgPrgItm,Prg_ITEM_SECTION_ID,
|
Ico_PutContextualIconToEdit (ActFrmChgPrgItm,Prg_ITEM_SECTION_ID,
|
||||||
Prg_PutParams,&SelectedItmRsc);
|
Prg_PutParams,&SelectedItmRscCodes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Icon to add a new child item inside this item *****/
|
/***** Icon to add a new child item inside this item *****/
|
||||||
Ico_PutContextualIconToAdd (ActFrmNewPrgItm,Prg_ITEM_SECTION_ID,
|
Ico_PutContextualIconToAdd (ActFrmNewPrgItm,Prg_ITEM_SECTION_ID,
|
||||||
Prg_PutParams,&SelectedItmRsc);
|
Prg_PutParams,&SelectedItmRscCodes);
|
||||||
|
|
||||||
HTM_BR ();
|
HTM_BR ();
|
||||||
|
|
||||||
/***** Icon to move up the item *****/
|
/***** Icon to move up the item *****/
|
||||||
if (Prg_CheckIfMoveUpIsAllowed (NumItem))
|
if (Prg_CheckIfMoveUpIsAllowed (NumItem))
|
||||||
Lay_PutContextualLinkOnlyIcon (ActUp_PrgItm,"prg_highlighted",
|
Lay_PutContextualLinkOnlyIcon (ActUp_PrgItm,"prg_highlighted",
|
||||||
Prg_PutParams,&SelectedItmRsc,
|
Prg_PutParams,&SelectedItmRscCodes,
|
||||||
"arrow-up.svg",Ico_BLACK);
|
"arrow-up.svg",Ico_BLACK);
|
||||||
else
|
else
|
||||||
Ico_PutIconOff ("arrow-up.svg",Ico_BLACK,Txt_Movement_not_allowed);
|
Ico_PutIconOff ("arrow-up.svg",Ico_BLACK,Txt_Movement_not_allowed);
|
||||||
|
@ -936,7 +935,7 @@ static void Prg_PutFormsToRemEditOneItem (Prg_ListingType_t ListingType,
|
||||||
/***** Icon to move down the item *****/
|
/***** Icon to move down the item *****/
|
||||||
if (Prg_CheckIfMoveDownIsAllowed (NumItem))
|
if (Prg_CheckIfMoveDownIsAllowed (NumItem))
|
||||||
Lay_PutContextualLinkOnlyIcon (ActDwnPrgItm,"prg_highlighted",
|
Lay_PutContextualLinkOnlyIcon (ActDwnPrgItm,"prg_highlighted",
|
||||||
Prg_PutParams,&SelectedItmRsc,
|
Prg_PutParams,&SelectedItmRscCodes,
|
||||||
"arrow-down.svg",Ico_BLACK);
|
"arrow-down.svg",Ico_BLACK);
|
||||||
else
|
else
|
||||||
Ico_PutIconOff ("arrow-down.svg",Ico_BLACK,Txt_Movement_not_allowed);
|
Ico_PutIconOff ("arrow-down.svg",Ico_BLACK,Txt_Movement_not_allowed);
|
||||||
|
@ -944,7 +943,7 @@ static void Prg_PutFormsToRemEditOneItem (Prg_ListingType_t ListingType,
|
||||||
/***** Icon to move left item (increase level) *****/
|
/***** Icon to move left item (increase level) *****/
|
||||||
if (Prg_CheckIfMoveLeftIsAllowed (NumItem))
|
if (Prg_CheckIfMoveLeftIsAllowed (NumItem))
|
||||||
Lay_PutContextualLinkOnlyIcon (ActLftPrgItm,"prg_highlighted",
|
Lay_PutContextualLinkOnlyIcon (ActLftPrgItm,"prg_highlighted",
|
||||||
Prg_PutParams,&SelectedItmRsc,
|
Prg_PutParams,&SelectedItmRscCodes,
|
||||||
"arrow-left.svg",Ico_BLACK);
|
"arrow-left.svg",Ico_BLACK);
|
||||||
else
|
else
|
||||||
Ico_PutIconOff ("arrow-left.svg",Ico_BLACK,Txt_Movement_not_allowed);
|
Ico_PutIconOff ("arrow-left.svg",Ico_BLACK,Txt_Movement_not_allowed);
|
||||||
|
@ -952,7 +951,7 @@ static void Prg_PutFormsToRemEditOneItem (Prg_ListingType_t ListingType,
|
||||||
/***** Icon to move right item (indent, decrease level) *****/
|
/***** Icon to move right item (indent, decrease level) *****/
|
||||||
if (Prg_CheckIfMoveRightIsAllowed (NumItem))
|
if (Prg_CheckIfMoveRightIsAllowed (NumItem))
|
||||||
Lay_PutContextualLinkOnlyIcon (ActRgtPrgItm,"prg_highlighted",
|
Lay_PutContextualLinkOnlyIcon (ActRgtPrgItm,"prg_highlighted",
|
||||||
Prg_PutParams,&SelectedItmRsc,
|
Prg_PutParams,&SelectedItmRscCodes,
|
||||||
"arrow-right.svg",Ico_BLACK);
|
"arrow-right.svg",Ico_BLACK);
|
||||||
else
|
else
|
||||||
Ico_PutIconOff ("arrow-right.svg",Ico_BLACK,Txt_Movement_not_allowed);
|
Ico_PutIconOff ("arrow-right.svg",Ico_BLACK,Txt_Movement_not_allowed);
|
||||||
|
@ -1039,16 +1038,33 @@ static bool Prg_CheckIfMoveRightIsAllowed (unsigned NumItem)
|
||||||
/******************** Params used to edit a program item *********************/
|
/******************** Params used to edit a program item *********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Prg_PutParams (void *SelectedItmRsc)
|
void Prg_PutParams (void *ItmRscCodes)
|
||||||
{
|
{
|
||||||
if (SelectedItmRsc)
|
if (ItmRscCodes)
|
||||||
if (((struct Prg_ItmRsc *) SelectedItmRsc)->ItmCod > 0)
|
{
|
||||||
{
|
/* If a resource is present, put resource code.
|
||||||
Prg_PutParamItmCod (((struct Prg_ItmRsc *) SelectedItmRsc)->ItmCod);
|
If no resource present, but item is, put item code. */
|
||||||
|
if (((struct Prg_ItmRscCodes *) ItmRscCodes)->RscCod > 0)
|
||||||
|
PrgRsc_PutParamRscCod (((struct Prg_ItmRscCodes *) ItmRscCodes)->RscCod);
|
||||||
|
else if (((struct Prg_ItmRscCodes *) ItmRscCodes)->ItmCod > 0)
|
||||||
|
Prg_PutParamItmCod (((struct Prg_ItmRscCodes *) ItmRscCodes)->ItmCod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (((struct Prg_ItmRsc *) SelectedItmRsc)->RscCod > 0)
|
void Prg_GetParams (struct Prg_Item *Item)
|
||||||
PrgRsc_PutParamRscCod (((struct Prg_ItmRsc *) SelectedItmRsc)->RscCod);
|
{
|
||||||
}
|
/***** Try to get item resource *****/
|
||||||
|
Item->Resource.Hierarchy.RscCod = PrgRsc_GetParamRscCod ();
|
||||||
|
|
||||||
|
/***** Get data of the program item from database *****/
|
||||||
|
PrgRsc_GetDataOfResourceByCod (Item);
|
||||||
|
|
||||||
|
if (Item->Hierarchy.ItmCod <= 0) // No resource specified
|
||||||
|
/***** Try to get data of the program item from database *****/
|
||||||
|
Item->Hierarchy.ItmCod = Prg_GetParamItmCod ();
|
||||||
|
|
||||||
|
/***** Get data of the program item from database *****/
|
||||||
|
Prg_GetDataOfItemByCod (Item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1086,7 +1102,7 @@ void Prg_GetListItems (void)
|
||||||
|
|
||||||
/* Get index of the program item (row[1])
|
/* Get index of the program item (row[1])
|
||||||
and level of the program item (row[2]) */
|
and level of the program item (row[2]) */
|
||||||
Prg_Gbl.List.Items[NumItem].Index = Str_ConvertStrToUnsigned (row[1]);
|
Prg_Gbl.List.Items[NumItem].ItmInd = Str_ConvertStrToUnsigned (row[1]);
|
||||||
Prg_Gbl.List.Items[NumItem].Level = Str_ConvertStrToUnsigned (row[2]);
|
Prg_Gbl.List.Items[NumItem].Level = Str_ConvertStrToUnsigned (row[2]);
|
||||||
|
|
||||||
/* Get whether the program item is hidden or not (row[3]) */
|
/* Get whether the program item is hidden or not (row[3]) */
|
||||||
|
@ -1132,9 +1148,6 @@ static void Prg_GetDataOfItem (struct Prg_Item *Item,
|
||||||
{
|
{
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
/***** Clear all program item data *****/
|
|
||||||
Prg_ResetItem (Item);
|
|
||||||
|
|
||||||
/***** Get data of program item from database *****/
|
/***** Get data of program item from database *****/
|
||||||
if (NumRows) // Item found...
|
if (NumRows) // Item found...
|
||||||
{
|
{
|
||||||
|
@ -1157,7 +1170,7 @@ static void Prg_GetDataOfItem (struct Prg_Item *Item,
|
||||||
|
|
||||||
/* Get index of the program item (row[1])
|
/* Get index of the program item (row[1])
|
||||||
and level of the program item (row[2]) */
|
and level of the program item (row[2]) */
|
||||||
Item->Hierarchy.Index = Str_ConvertStrToUnsigned (row[1]);
|
Item->Hierarchy.ItmInd = Str_ConvertStrToUnsigned (row[1]);
|
||||||
Item->Hierarchy.Level = Str_ConvertStrToUnsigned (row[2]);
|
Item->Hierarchy.Level = Str_ConvertStrToUnsigned (row[2]);
|
||||||
|
|
||||||
/* Get whether the program item is hidden or not (row[3]) */
|
/* Get whether the program item is hidden or not (row[3]) */
|
||||||
|
@ -1177,28 +1190,14 @@ static void Prg_GetDataOfItem (struct Prg_Item *Item,
|
||||||
/* Get the title of the program item (row[8]) */
|
/* Get the title of the program item (row[8]) */
|
||||||
Str_Copy (Item->Title,row[8],sizeof (Item->Title) - 1);
|
Str_Copy (Item->Title,row[8],sizeof (Item->Title) - 1);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
/***** Clear all program item data *****/
|
||||||
|
Prg_ResetItem (Item);
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (mysql_res);
|
DB_FreeMySQLResult (mysql_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/************************ Clear all program item data ************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
static void Prg_ResetItem (struct Prg_Item *Item)
|
|
||||||
{
|
|
||||||
Item->Hierarchy.ItmCod = -1L;
|
|
||||||
Item->Hierarchy.Index = 0;
|
|
||||||
Item->Hierarchy.Level = 0;
|
|
||||||
Item->Hierarchy.Hidden = false;
|
|
||||||
Item->UsrCod = -1L;
|
|
||||||
Item->TimeUTC[Dat_STR_TIME] =
|
|
||||||
Item->TimeUTC[Dat_END_TIME] = (time_t) 0;
|
|
||||||
Item->Open = false;
|
|
||||||
Item->Title[0] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************************ Free list of program items *************************/
|
/************************ Free list of program items *************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1215,6 +1214,27 @@ void Prg_FreeListItems (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************************ Clear all program item data ************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Prg_ResetItem (struct Prg_Item *Item)
|
||||||
|
{
|
||||||
|
Item->Hierarchy.ItmCod = -1L;
|
||||||
|
Item->Hierarchy.ItmInd = 0;
|
||||||
|
Item->Hierarchy.Level = 0;
|
||||||
|
Item->Hierarchy.Hidden = false;
|
||||||
|
Item->UsrCod = -1L;
|
||||||
|
Item->TimeUTC[Dat_STR_TIME] =
|
||||||
|
Item->TimeUTC[Dat_END_TIME] = (time_t) 0;
|
||||||
|
Item->Open = false;
|
||||||
|
Item->Title[0] = '\0';
|
||||||
|
Item->Resource.Hierarchy.RscCod = -1L;
|
||||||
|
Item->Resource.Hierarchy.RscInd = 0;
|
||||||
|
Item->Resource.Hierarchy.Hidden = false;
|
||||||
|
Item->Resource.Title[0] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/**************** Write parameter with code of program item ******************/
|
/**************** Write parameter with code of program item ******************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1275,22 +1295,21 @@ void Prg_ReqRemItem (void)
|
||||||
extern const char *Txt_Do_you_really_want_to_remove_the_item_X;
|
extern const char *Txt_Do_you_really_want_to_remove_the_item_X;
|
||||||
extern const char *Txt_Remove_item;
|
extern const char *Txt_Remove_item;
|
||||||
struct Prg_Item Item;
|
struct Prg_Item Item;
|
||||||
struct Prg_ItmRsc SelectedItmRsc;
|
struct Prg_ItmRscCodes SelectedItmRscCodes;
|
||||||
|
|
||||||
/***** Get list of program items *****/
|
/***** Get list of program items *****/
|
||||||
Prg_GetListItems ();
|
Prg_GetListItems ();
|
||||||
|
|
||||||
/***** Get data of the program item from database *****/
|
/***** Get data of the program item from database *****/
|
||||||
Item.Hierarchy.ItmCod = Prg_GetParamItmCod ();
|
Prg_GetParams (&Item);
|
||||||
Prg_GetDataOfItemByCod (&Item);
|
|
||||||
if (Item.Hierarchy.ItmCod <= 0)
|
if (Item.Hierarchy.ItmCod <= 0)
|
||||||
Err_WrongItemExit ();
|
Err_WrongItemExit ();
|
||||||
|
|
||||||
/***** Show question and button to remove the program item *****/
|
/***** Show question and button to remove the program item *****/
|
||||||
SelectedItmRsc.ItmCod = Item.Hierarchy.ItmCod;
|
SelectedItmRscCodes.ItmCod = Item.Hierarchy.ItmCod;
|
||||||
SelectedItmRsc.RscCod = -1L;
|
SelectedItmRscCodes.RscCod = -1L;
|
||||||
Ale_ShowAlertAndButton (ActRemPrgItm,NULL,NULL,
|
Ale_ShowAlertAndButton (ActRemPrgItm,NULL,NULL,
|
||||||
Prg_PutParams,&SelectedItmRsc,
|
Prg_PutParams,&SelectedItmRscCodes,
|
||||||
Btn_REMOVE_BUTTON,Txt_Remove_item,
|
Btn_REMOVE_BUTTON,Txt_Remove_item,
|
||||||
Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_item_X,
|
Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_item_X,
|
||||||
Item.Title);
|
Item.Title);
|
||||||
|
@ -1316,8 +1335,7 @@ void Prg_RemoveItem (void)
|
||||||
Prg_GetListItems ();
|
Prg_GetListItems ();
|
||||||
|
|
||||||
/***** Get data of the program item from database *****/
|
/***** Get data of the program item from database *****/
|
||||||
Item.Hierarchy.ItmCod = Prg_GetParamItmCod ();
|
Prg_GetParams (&Item);
|
||||||
Prg_GetDataOfItemByCod (&Item);
|
|
||||||
if (Item.Hierarchy.ItmCod <= 0)
|
if (Item.Hierarchy.ItmCod <= 0)
|
||||||
Err_WrongItemExit ();
|
Err_WrongItemExit ();
|
||||||
|
|
||||||
|
@ -1364,8 +1382,7 @@ static void Prg_HideOrUnhideItem (bool Hide)
|
||||||
Prg_GetListItems ();
|
Prg_GetListItems ();
|
||||||
|
|
||||||
/***** Get data of the item from database *****/
|
/***** Get data of the item from database *****/
|
||||||
Item.Hierarchy.ItmCod = Prg_GetParamItmCod ();
|
Prg_GetParams (&Item);
|
||||||
Prg_GetDataOfItemByCod (&Item);
|
|
||||||
if (Item.Hierarchy.ItmCod <= 0)
|
if (Item.Hierarchy.ItmCod <= 0)
|
||||||
Err_WrongItemExit ();
|
Err_WrongItemExit ();
|
||||||
|
|
||||||
|
@ -1409,8 +1426,7 @@ static void Prg_MoveUpDownItem (Prg_MoveUpDown_t UpDown)
|
||||||
Prg_GetListItems ();
|
Prg_GetListItems ();
|
||||||
|
|
||||||
/***** Get data of the item from database *****/
|
/***** Get data of the item from database *****/
|
||||||
Item.Hierarchy.ItmCod = Prg_GetParamItmCod ();
|
Prg_GetParams (&Item);
|
||||||
Prg_GetDataOfItemByCod (&Item);
|
|
||||||
if (Item.Hierarchy.ItmCod <= 0)
|
if (Item.Hierarchy.ItmCod <= 0)
|
||||||
Err_WrongItemExit ();
|
Err_WrongItemExit ();
|
||||||
|
|
||||||
|
@ -1611,8 +1627,7 @@ static void Prg_MoveLeftRightItem (Prg_MoveLeftRight_t LeftRight)
|
||||||
Prg_GetListItems ();
|
Prg_GetListItems ();
|
||||||
|
|
||||||
/***** Get data of the item from database *****/
|
/***** Get data of the item from database *****/
|
||||||
Item.Hierarchy.ItmCod = Prg_GetParamItmCod ();
|
Prg_GetParams (&Item);
|
||||||
Prg_GetDataOfItemByCod (&Item);
|
|
||||||
if (Item.Hierarchy.ItmCod <= 0)
|
if (Item.Hierarchy.ItmCod <= 0)
|
||||||
Err_WrongItemExit ();
|
Err_WrongItemExit ();
|
||||||
|
|
||||||
|
@ -1660,7 +1675,7 @@ static void Prg_SetItemRangeOnlyItem (unsigned NumItem,struct Prg_ItemRange *Ite
|
||||||
|
|
||||||
/***** Range includes only this item *****/
|
/***** Range includes only this item *****/
|
||||||
ItemRange->Begin =
|
ItemRange->Begin =
|
||||||
ItemRange->End = Prg_Gbl.List.Items[NumItem].Index;
|
ItemRange->End = Prg_Gbl.List.Items[NumItem].ItmInd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Prg_SetItemRangeWithAllChildren (unsigned NumItem,struct Prg_ItemRange *ItemRange)
|
static void Prg_SetItemRangeWithAllChildren (unsigned NumItem,struct Prg_ItemRange *ItemRange)
|
||||||
|
@ -1674,8 +1689,8 @@ static void Prg_SetItemRangeWithAllChildren (unsigned NumItem,struct Prg_ItemRan
|
||||||
Err_WrongItemExit ();
|
Err_WrongItemExit ();
|
||||||
|
|
||||||
/***** Range includes this item and all its children *****/
|
/***** Range includes this item and all its children *****/
|
||||||
ItemRange->Begin = Prg_Gbl.List.Items[NumItem ].Index;
|
ItemRange->Begin = Prg_Gbl.List.Items[NumItem ].ItmInd;
|
||||||
ItemRange->End = Prg_Gbl.List.Items[Prg_GetLastChild (NumItem)].Index;
|
ItemRange->End = Prg_Gbl.List.Items[Prg_GetLastChild (NumItem)].ItmInd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1711,16 +1726,16 @@ static unsigned Prg_GetLastChild (int NumItem)
|
||||||
|
|
||||||
void Prg_ViewItemAfterEdit (void)
|
void Prg_ViewItemAfterEdit (void)
|
||||||
{
|
{
|
||||||
long ItmCod;
|
struct Prg_Item Item;
|
||||||
|
|
||||||
/***** Get list of program items *****/
|
/***** Get list of program items *****/
|
||||||
Prg_GetListItems ();
|
Prg_GetListItems ();
|
||||||
|
|
||||||
/***** Get the code of the program item *****/
|
/***** Get the code of the program item *****/
|
||||||
ItmCod = Prg_GetParamItmCod ();
|
Prg_GetParams (&Item);
|
||||||
|
|
||||||
/***** Show current program items, if any *****/
|
/***** Show current program items, if any *****/
|
||||||
Prg_ShowAllItems (Prg_END_EDIT_ITEM,ItmCod,-1L);
|
Prg_ShowAllItems (Prg_END_EDIT_ITEM,Item.Hierarchy.ItmCod,-1L);
|
||||||
|
|
||||||
/***** Free list of program items *****/
|
/***** Free list of program items *****/
|
||||||
Prg_FreeListItems ();
|
Prg_FreeListItems ();
|
||||||
|
@ -1732,16 +1747,16 @@ void Prg_ViewItemAfterEdit (void)
|
||||||
|
|
||||||
void Prg_RequestChangeItem (void)
|
void Prg_RequestChangeItem (void)
|
||||||
{
|
{
|
||||||
long ItmCod;
|
struct Prg_Item Item;
|
||||||
|
|
||||||
/***** Get list of program items *****/
|
/***** Get list of program items *****/
|
||||||
Prg_GetListItems ();
|
Prg_GetListItems ();
|
||||||
|
|
||||||
/***** Get the code of the program item *****/
|
/***** Get the code of the program item *****/
|
||||||
ItmCod = Prg_GetParamItmCod ();
|
Prg_GetParams (&Item);
|
||||||
|
|
||||||
/***** Show current program items, if any *****/
|
/***** Show current program items, if any *****/
|
||||||
Prg_ShowAllItems (Prg_FORM_EDIT_ITEM,ItmCod,-1L);
|
Prg_ShowAllItems (Prg_FORM_EDIT_ITEM,Item.Hierarchy.ItmCod,-1L);
|
||||||
|
|
||||||
/***** Free list of program items *****/
|
/***** Free list of program items *****/
|
||||||
Prg_FreeListItems ();
|
Prg_FreeListItems ();
|
||||||
|
@ -1753,18 +1768,18 @@ void Prg_RequestChangeItem (void)
|
||||||
|
|
||||||
void Prg_RequestCreateItem (void)
|
void Prg_RequestCreateItem (void)
|
||||||
{
|
{
|
||||||
long ParentItmCod;
|
struct Prg_Item Item;
|
||||||
|
|
||||||
/***** Get list of program items *****/
|
/***** Get list of program items *****/
|
||||||
Prg_GetListItems ();
|
Prg_GetListItems ();
|
||||||
|
|
||||||
/***** Get the code of the parent program item *****/
|
/***** Get the code of the parent program item *****/
|
||||||
ParentItmCod = Prg_GetParamItmCod ();
|
Prg_GetParams (&Item);
|
||||||
|
|
||||||
/***** Show current program items, if any *****/
|
/***** Show current program items, if any *****/
|
||||||
Prg_ShowAllItems (ParentItmCod > 0 ? Prg_FORM_NEW_CHILD_ITEM :
|
Prg_ShowAllItems (Item.Hierarchy.ItmCod > 0 ? Prg_FORM_NEW_CHILD_ITEM :
|
||||||
Prg_FORM_NEW_END_ITEM,
|
Prg_FORM_NEW_END_ITEM,
|
||||||
ParentItmCod,-1L);
|
Item.Hierarchy.ItmCod,-1L);
|
||||||
|
|
||||||
/***** Free list of program items *****/
|
/***** Free list of program items *****/
|
||||||
Prg_FreeListItems ();
|
Prg_FreeListItems ();
|
||||||
|
@ -1925,15 +1940,14 @@ static void Prg_ShowFormItem (const struct Prg_Item *Item,
|
||||||
|
|
||||||
void Prg_ReceiveFormChgItem (void)
|
void Prg_ReceiveFormChgItem (void)
|
||||||
{
|
{
|
||||||
struct Prg_Item Item; // Item data received from form
|
struct Prg_Item Item;
|
||||||
char Description[Cns_MAX_BYTES_TEXT + 1];
|
char Description[Cns_MAX_BYTES_TEXT + 1];
|
||||||
|
|
||||||
/***** Get list of program items *****/
|
/***** Get list of program items *****/
|
||||||
Prg_GetListItems ();
|
Prg_GetListItems ();
|
||||||
|
|
||||||
/***** Get data of the item from database *****/
|
/***** Get data of the item from database *****/
|
||||||
Item.Hierarchy.ItmCod = Prg_GetParamItmCod ();
|
Prg_GetParams (&Item);
|
||||||
Prg_GetDataOfItemByCod (&Item);
|
|
||||||
if (Item.Hierarchy.ItmCod <= 0)
|
if (Item.Hierarchy.ItmCod <= 0)
|
||||||
Err_WrongItemExit ();
|
Err_WrongItemExit ();
|
||||||
|
|
||||||
|
@ -1969,7 +1983,7 @@ void Prg_ReceiveFormChgItem (void)
|
||||||
|
|
||||||
void Prg_ReceiveFormNewItem (void)
|
void Prg_ReceiveFormNewItem (void)
|
||||||
{
|
{
|
||||||
struct Prg_Item ParentItem; // Parent item
|
struct Prg_Item Item; // Parent item
|
||||||
struct Prg_Item NewItem; // Item data received from form
|
struct Prg_Item NewItem; // Item data received from form
|
||||||
char Description[Cns_MAX_BYTES_TEXT + 1];
|
char Description[Cns_MAX_BYTES_TEXT + 1];
|
||||||
|
|
||||||
|
@ -1977,13 +1991,12 @@ void Prg_ReceiveFormNewItem (void)
|
||||||
Prg_GetListItems ();
|
Prg_GetListItems ();
|
||||||
|
|
||||||
/***** Get data of the program item from database *****/
|
/***** Get data of the program item from database *****/
|
||||||
ParentItem.Hierarchy.ItmCod = Prg_GetParamItmCod ();
|
Prg_GetParams (&Item);
|
||||||
Prg_GetDataOfItemByCod (&ParentItem);
|
|
||||||
// If item code <= 0 ==> this is the first item in the program
|
// If item code <= 0 ==> this is the first item in the program
|
||||||
|
|
||||||
/***** Set new item code *****/
|
/***** Set new item code *****/
|
||||||
NewItem.Hierarchy.ItmCod = -1L;
|
NewItem.Hierarchy.ItmCod = -1L;
|
||||||
NewItem.Hierarchy.Level = ParentItem.Hierarchy.Level + 1; // Create as child
|
NewItem.Hierarchy.Level = Item.Hierarchy.Level + 1; // Create as child
|
||||||
|
|
||||||
/***** Get start/end date-times *****/
|
/***** Get start/end date-times *****/
|
||||||
NewItem.TimeUTC[Dat_STR_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC");
|
NewItem.TimeUTC[Dat_STR_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC");
|
||||||
|
@ -2002,7 +2015,7 @@ void Prg_ReceiveFormNewItem (void)
|
||||||
NewItem.TimeUTC[Dat_END_TIME] = NewItem.TimeUTC[Dat_STR_TIME] + 2 * 60 * 60; // +2 hours
|
NewItem.TimeUTC[Dat_END_TIME] = NewItem.TimeUTC[Dat_STR_TIME] + 2 * 60 * 60; // +2 hours
|
||||||
|
|
||||||
/***** Create a new program item *****/
|
/***** Create a new program item *****/
|
||||||
Prg_InsertItem (&ParentItem,&NewItem,Description);
|
Prg_InsertItem (&Item,&NewItem,Description);
|
||||||
|
|
||||||
/* Update list of program items */
|
/* Update list of program items */
|
||||||
Prg_FreeListItems ();
|
Prg_FreeListItems ();
|
||||||
|
@ -2038,14 +2051,14 @@ static void Prg_InsertItem (const struct Prg_Item *ParentItem,
|
||||||
if (NumItemLastChild < Prg_Gbl.List.NumItems - 1)
|
if (NumItemLastChild < Prg_Gbl.List.NumItems - 1)
|
||||||
{
|
{
|
||||||
/***** New program item will be inserted after last child of parent *****/
|
/***** New program item will be inserted after last child of parent *****/
|
||||||
Item->Hierarchy.Index = Prg_Gbl.List.Items[NumItemLastChild + 1].Index;
|
Item->Hierarchy.ItmInd = Prg_Gbl.List.Items[NumItemLastChild + 1].ItmInd;
|
||||||
|
|
||||||
/***** Move down all indexes of after last child of parent *****/
|
/***** Move down all indexes of after last child of parent *****/
|
||||||
Prg_DB_MoveDownItems (Item->Hierarchy.Index);
|
Prg_DB_MoveDownItems (Item->Hierarchy.ItmInd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/***** New program item will be inserted at the end *****/
|
/***** New program item will be inserted at the end *****/
|
||||||
Item->Hierarchy.Index = Prg_Gbl.List.Items[Prg_Gbl.List.NumItems - 1].Index + 1;
|
Item->Hierarchy.ItmInd = Prg_Gbl.List.Items[Prg_Gbl.List.NumItems - 1].ItmInd + 1;
|
||||||
|
|
||||||
/***** Child ==> parent level + 1 *****/
|
/***** Child ==> parent level + 1 *****/
|
||||||
Item->Hierarchy.Level = ParentItem->Hierarchy.Level + 1;
|
Item->Hierarchy.Level = ParentItem->Hierarchy.Level + 1;
|
||||||
|
@ -2053,7 +2066,7 @@ static void Prg_InsertItem (const struct Prg_Item *ParentItem,
|
||||||
else // No parent specified
|
else // No parent specified
|
||||||
{
|
{
|
||||||
/***** New program item will be inserted at the end *****/
|
/***** New program item will be inserted at the end *****/
|
||||||
Item->Hierarchy.Index = Prg_Gbl.List.Items[Prg_Gbl.List.NumItems - 1].Index + 1;
|
Item->Hierarchy.ItmInd = Prg_Gbl.List.Items[Prg_Gbl.List.NumItems - 1].ItmInd + 1;
|
||||||
|
|
||||||
/***** First level *****/
|
/***** First level *****/
|
||||||
Item->Hierarchy.Level = 1;
|
Item->Hierarchy.Level = 1;
|
||||||
|
@ -2062,7 +2075,7 @@ static void Prg_InsertItem (const struct Prg_Item *ParentItem,
|
||||||
else // There are no items
|
else // There are no items
|
||||||
{
|
{
|
||||||
/***** New program item will be inserted as the first one *****/
|
/***** New program item will be inserted as the first one *****/
|
||||||
Item->Hierarchy.Index = 1;
|
Item->Hierarchy.ItmInd = 1;
|
||||||
|
|
||||||
/***** First level *****/
|
/***** First level *****/
|
||||||
Item->Hierarchy.Level = 1;
|
Item->Hierarchy.Level = 1;
|
||||||
|
|
|
@ -37,13 +37,29 @@
|
||||||
/************************** Public types and constants ***********************/
|
/************************** Public types and constants ***********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#define PrgRsc_MAX_CHARS_PROGRAM_RESOURCE_TITLE (128 - 1) // 127
|
||||||
|
#define PrgRsc_MAX_BYTES_PROGRAM_RESOURCE_TITLE ((PrgRsc_MAX_CHARS_PROGRAM_RESOURCE_TITLE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
|
||||||
|
|
||||||
|
struct Prg_ResourceHierarchy
|
||||||
|
{
|
||||||
|
long RscCod;
|
||||||
|
unsigned RscInd; // 1, 2, 3...
|
||||||
|
bool Hidden;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Prg_Resource
|
||||||
|
{
|
||||||
|
struct Prg_ResourceHierarchy Hierarchy;
|
||||||
|
char Title[PrgRsc_MAX_BYTES_PROGRAM_RESOURCE_TITLE + 1];
|
||||||
|
};
|
||||||
|
|
||||||
#define Prg_MAX_CHARS_PROGRAM_ITEM_TITLE (128 - 1) // 127
|
#define Prg_MAX_CHARS_PROGRAM_ITEM_TITLE (128 - 1) // 127
|
||||||
#define Prg_MAX_BYTES_PROGRAM_ITEM_TITLE ((Prg_MAX_CHARS_PROGRAM_ITEM_TITLE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
|
#define Prg_MAX_BYTES_PROGRAM_ITEM_TITLE ((Prg_MAX_CHARS_PROGRAM_ITEM_TITLE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
|
||||||
|
|
||||||
struct Prg_ItemHierarchy
|
struct Prg_ItemHierarchy
|
||||||
{
|
{
|
||||||
long ItmCod;
|
long ItmCod;
|
||||||
unsigned Index;
|
unsigned ItmInd; // 1, 2, 3...
|
||||||
unsigned Level;
|
unsigned Level;
|
||||||
bool Hidden;
|
bool Hidden;
|
||||||
};
|
};
|
||||||
|
@ -56,6 +72,7 @@ struct Prg_Item
|
||||||
time_t TimeUTC[Dat_NUM_START_END_TIME];
|
time_t TimeUTC[Dat_NUM_START_END_TIME];
|
||||||
bool Open;
|
bool Open;
|
||||||
char Title[Prg_MAX_BYTES_PROGRAM_ITEM_TITLE + 1];
|
char Title[Prg_MAX_BYTES_PROGRAM_ITEM_TITLE + 1];
|
||||||
|
struct Prg_Resource Resource;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Prg_ItemRange
|
struct Prg_ItemRange
|
||||||
|
@ -90,7 +107,7 @@ typedef enum
|
||||||
Prg_END_EDIT_RES, // List resources of a selected item after edition
|
Prg_END_EDIT_RES, // List resources of a selected item after edition
|
||||||
} Prg_ListingType_t;
|
} Prg_ListingType_t;
|
||||||
|
|
||||||
struct Prg_ItmRsc // Used in forms to pass an item and a resource as parameters
|
struct Prg_ItmRscCodes // Used in forms to pass an item and a resource as parameters
|
||||||
{
|
{
|
||||||
long ItmCod;
|
long ItmCod;
|
||||||
long RscCod;
|
long RscCod;
|
||||||
|
@ -107,10 +124,15 @@ void Prg_ShowAllItems (Prg_ListingType_t ListingType,
|
||||||
long SelectedItmCod,long SelectedRscCod);
|
long SelectedItmCod,long SelectedRscCod);
|
||||||
|
|
||||||
bool Prg_CheckIfICanEditProgram (void);
|
bool Prg_CheckIfICanEditProgram (void);
|
||||||
void Prg_PutParams (void *SelectedItmRsc);
|
|
||||||
|
void Prg_PutParams (void *ItmRsc);
|
||||||
|
void Prg_GetParams (struct Prg_Item *Item);
|
||||||
|
|
||||||
void Prg_GetListItems (void);
|
void Prg_GetListItems (void);
|
||||||
void Prg_FreeListItems (void);
|
void Prg_FreeListItems (void);
|
||||||
|
|
||||||
|
void Prg_ResetItem (struct Prg_Item *Item);
|
||||||
|
|
||||||
void Prg_PutParamItmCod (long ItmCod);
|
void Prg_PutParamItmCod (long ItmCod);
|
||||||
long Prg_GetParamItmCod (void);
|
long Prg_GetParamItmCod (void);
|
||||||
unsigned Prg_GetNumItemFromItmCod (long ItmCod);
|
unsigned Prg_GetNumItemFromItmCod (long ItmCod);
|
||||||
|
|
|
@ -79,7 +79,7 @@ long Prg_DB_InsertItem (const struct Prg_Item *Item,const char *Txt)
|
||||||
"FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),"
|
"FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),"
|
||||||
"'%s','%s')",
|
"'%s','%s')",
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
Item->Hierarchy.Index,
|
Item->Hierarchy.ItmInd,
|
||||||
Item->Hierarchy.Level,
|
Item->Hierarchy.Level,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Item->TimeUTC[Dat_STR_TIME],
|
Item->TimeUTC[Dat_STR_TIME],
|
||||||
|
@ -455,7 +455,7 @@ void Prg_DB_RemoveCrsItems (long CrsCod)
|
||||||
/************************** Create a new resource ****************************/
|
/************************** Create a new resource ****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
long Prg_DB_CreateResource (const struct PrgRsc_Resource *Resource)
|
long Prg_DB_CreateResource (const struct Prg_Item *Item)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
DB_QueryINSERTandReturnCode ("can not create new resource",
|
DB_QueryINSERTandReturnCode ("can not create new resource",
|
||||||
|
@ -464,16 +464,16 @@ long Prg_DB_CreateResource (const struct PrgRsc_Resource *Resource)
|
||||||
" SELECT %ld,COALESCE(MAX(t2.RscInd),0)+1,'N','%s'"
|
" SELECT %ld,COALESCE(MAX(t2.RscInd),0)+1,'N','%s'"
|
||||||
" FROM prg_resources AS t2"
|
" FROM prg_resources AS t2"
|
||||||
" WHERE t2.ItmCod=%ld",
|
" WHERE t2.ItmCod=%ld",
|
||||||
Resource->ItmCod,
|
Item->Hierarchy.ItmCod,
|
||||||
Resource->Title,
|
Item->Resource.Title,
|
||||||
Resource->ItmCod);
|
Item->Hierarchy.ItmCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/**************************** Update resource title **************************/
|
/**************************** Update resource title **************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Prg_DB_UpdateResourceTitle (long RscCod,long ItmCod,
|
void Prg_DB_UpdateResourceTitle (long ItmCod,long RscCod,
|
||||||
const char NewTitle[PrgRsc_MAX_BYTES_PROGRAM_RESOURCE_TITLE + 1])
|
const char NewTitle[PrgRsc_MAX_BYTES_PROGRAM_RESOURCE_TITLE + 1])
|
||||||
{
|
{
|
||||||
DB_QueryUPDATE ("can not update the title of a resource",
|
DB_QueryUPDATE ("can not update the title of a resource",
|
||||||
|
@ -617,7 +617,7 @@ long Prg_DB_GetRscCodFromRscInd (long ItmCod,unsigned RscInd)
|
||||||
/************************** Remove an item resource **************************/
|
/************************** Remove an item resource **************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Prg_DB_RemoveResource (const struct PrgRsc_Resource *Resource)
|
void Prg_DB_RemoveResource (const struct Prg_Item *Item)
|
||||||
{
|
{
|
||||||
DB_QueryDELETE ("can not remove item resource",
|
DB_QueryDELETE ("can not remove item resource",
|
||||||
"DELETE FROM prg_resources"
|
"DELETE FROM prg_resources"
|
||||||
|
@ -627,8 +627,8 @@ void Prg_DB_RemoveResource (const struct PrgRsc_Resource *Resource)
|
||||||
" AND prg_resources.ItmCod=%ld"
|
" AND prg_resources.ItmCod=%ld"
|
||||||
" AND prg_resources.ItmCod=prg_items.ItmCod"
|
" AND prg_resources.ItmCod=prg_items.ItmCod"
|
||||||
" AND prg_items.CrsCod=%ld", // Extra check
|
" AND prg_items.CrsCod=%ld", // Extra check
|
||||||
Resource->Rsc.Cod,
|
Item->Resource.Hierarchy.RscCod,
|
||||||
Resource->ItmCod,
|
Item->Hierarchy.ItmCod,
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,19 +672,6 @@ void Prg_DB_UpdateRscInd (long RscCod,int RscInd)
|
||||||
RscCod);
|
RscCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/**************** Get resources in the current course clipboard **************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*
|
|
||||||
mysql> SELECT * FROM prg_clipboards;
|
|
||||||
+--------+--------+------+-----+---------------------+
|
|
||||||
| UsrCod | CrsCod | Type | Cod | CopyTime |
|
|
||||||
+--------+--------+------+-----+---------------------+
|
|
||||||
| 1 | 1 | doc | 33 | 2022-09-12 12:08:25 |
|
|
||||||
| 1 | 1 | doc | 28 | 2022-09-12 12:08:31 |
|
|
||||||
+--------+--------+------+-----+---------------------+
|
|
||||||
2 rows in set (0,00 sec)
|
|
||||||
*/
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/********************** Copy link to resource into clipboard *****************/
|
/********************** Copy link to resource into clipboard *****************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -713,3 +700,54 @@ void Prg_DB_CopyToClipboard (PrgRsc_Type_t Type,long Cod)
|
||||||
Prg_ResourceTypesDB[Type],
|
Prg_ResourceTypesDB[Type],
|
||||||
Cod);
|
Cod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/**************** Get resources in the current course clipboard **************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*
|
||||||
|
mysql> SELECT * FROM prg_clipboards;
|
||||||
|
+--------+--------+------+-----+---------------------+
|
||||||
|
| UsrCod | CrsCod | Type | Cod | CopyTime |
|
||||||
|
+--------+--------+------+-----+---------------------+
|
||||||
|
| 1 | 1 | doc | 33 | 2022-09-12 12:08:25 |
|
||||||
|
| 1 | 1 | doc | 28 | 2022-09-12 12:08:31 |
|
||||||
|
+--------+--------+------+-----+---------------------+
|
||||||
|
2 rows in set (0,00 sec)
|
||||||
|
*/
|
||||||
|
|
||||||
|
unsigned Prg_DB_GetClipboard (MYSQL_RES **mysql_res)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get clipboard",
|
||||||
|
"SELECT Type," // row[0]
|
||||||
|
"Cod" // row[1]
|
||||||
|
" FROM prg_clipboards"
|
||||||
|
" WHERE UsrCod=%ld"
|
||||||
|
" AND CrsCod=%ld"
|
||||||
|
" ORDER BY CopyTime",
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********************** Get resource data from clipboard *********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void PrgRsc_GetDataOfLinkFromClipboard (struct PrgRsc_Link *Link,
|
||||||
|
MYSQL_RES **mysql_res)
|
||||||
|
{
|
||||||
|
MYSQL_ROW row;
|
||||||
|
|
||||||
|
/***** Get data of item resource from database *****/
|
||||||
|
/* Get row */
|
||||||
|
row = mysql_fetch_row (*mysql_res);
|
||||||
|
/*
|
||||||
|
Type row[0]
|
||||||
|
Cod row[1]
|
||||||
|
*/
|
||||||
|
/* Get type (row[0]) */
|
||||||
|
Link->Type = PrgRsc_GetTypeFromString (row[0]);
|
||||||
|
|
||||||
|
/* Get code (row[1]) */
|
||||||
|
Link->Cod = Str_ConvertStrCodToLongCod (row[1]);
|
||||||
|
}
|
||||||
|
|
|
@ -56,9 +56,9 @@ void Prg_DB_RemoveItemRange (const struct Prg_ItemRange *ToRemove);
|
||||||
void Prg_DB_RemoveCrsItems (long CrsCod);
|
void Prg_DB_RemoveCrsItems (long CrsCod);
|
||||||
|
|
||||||
//------------------------------ Resources ------------------------------------
|
//------------------------------ Resources ------------------------------------
|
||||||
long Prg_DB_CreateResource (const struct PrgRsc_Resource *Resource);
|
long Prg_DB_CreateResource (const struct Prg_Item *Item);
|
||||||
|
|
||||||
void Prg_DB_UpdateResourceTitle (long RscCod,long ItmCod,
|
void Prg_DB_UpdateResourceTitle (long ItmCod,long RscCod,
|
||||||
const char NewTitle[PrgRsc_MAX_BYTES_PROGRAM_RESOURCE_TITLE + 1]);
|
const char NewTitle[PrgRsc_MAX_BYTES_PROGRAM_RESOURCE_TITLE + 1]);
|
||||||
|
|
||||||
unsigned Prg_DB_GetListResources (MYSQL_RES **mysql_res,long ItmCod,
|
unsigned Prg_DB_GetListResources (MYSQL_RES **mysql_res,long ItmCod,
|
||||||
|
@ -70,7 +70,7 @@ unsigned Prg_DB_GetRscIndBefore (long ItmCod,unsigned RscInd);
|
||||||
unsigned Prg_DB_GetRscIndAfter (long ItmCod,unsigned RscInd);
|
unsigned Prg_DB_GetRscIndAfter (long ItmCod,unsigned RscInd);
|
||||||
long Prg_DB_GetRscCodFromRscInd (long ItmCod,unsigned RscInd);
|
long Prg_DB_GetRscCodFromRscInd (long ItmCod,unsigned RscInd);
|
||||||
|
|
||||||
void Prg_DB_RemoveResource (const struct PrgRsc_Resource *Resource);
|
void Prg_DB_RemoveResource (const struct Prg_Item *Item);
|
||||||
|
|
||||||
void Prg_DB_HideOrUnhideResource (long RscCod,bool Hide);
|
void Prg_DB_HideOrUnhideResource (long RscCod,bool Hide);
|
||||||
|
|
||||||
|
@ -79,4 +79,8 @@ void Prg_DB_UpdateRscInd (long RscCod,int RscInd);
|
||||||
|
|
||||||
void Prg_DB_CopyToClipboard (PrgRsc_Type_t Type,long Cod);
|
void Prg_DB_CopyToClipboard (PrgRsc_Type_t Type,long Cod);
|
||||||
|
|
||||||
|
unsigned Prg_DB_GetClipboard (MYSQL_RES **mysql_res);
|
||||||
|
void PrgRsc_GetDataOfLinkFromClipboard (struct PrgRsc_Link *Link,
|
||||||
|
MYSQL_RES **mysql_res);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
/********************************* Headers ***********************************/
|
/********************************* Headers ***********************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#include <string.h> // For string functions
|
||||||
|
|
||||||
#include "swad_error.h"
|
#include "swad_error.h"
|
||||||
#include "swad_form.h"
|
#include "swad_form.h"
|
||||||
#include "swad_global.h"
|
#include "swad_global.h"
|
||||||
|
@ -59,33 +61,33 @@ static const char *PrgRsc_RESOURCE_SECTION_ID = "rsc_section";
|
||||||
/***************************** Private prototypes ****************************/
|
/***************************** Private prototypes ****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void PrgRsc_PutIconsViewResources (void *ItmRsc);
|
static void PrgRsc_PutIconsViewResources (void *ItmRscCodes);
|
||||||
static void PrgRsc_PutIconsEditResources (void *ItmRsc);
|
static void PrgRsc_PutIconsEditResources (void *ItmRscCodes);
|
||||||
|
|
||||||
static void PrgRsc_GetDataOfResourceByCod (struct PrgRsc_Resource *Resource);
|
static void PrgRsc_GetDataOfResource (struct Prg_Item *Item,
|
||||||
static void PrgRsc_GetDataOfResource (struct PrgRsc_Resource *Resource,
|
|
||||||
MYSQL_RES **mysql_res);
|
MYSQL_RES **mysql_res);
|
||||||
static void PrgRsc_ResetResource (struct PrgRsc_Resource *Resource);
|
|
||||||
static void PrgRsc_WriteRowViewResource (unsigned NumRsc,
|
static void PrgRsc_WriteRowViewResource (unsigned NumRsc,
|
||||||
struct PrgRsc_Resource *Resource);
|
const struct Prg_Item *Item);
|
||||||
static void PrgRsc_WriteRowEditResource (Prg_ListingType_t ListingType,
|
static void PrgRsc_WriteRowEditResource (Prg_ListingType_t ListingType,
|
||||||
unsigned NumRsc,unsigned NumResources,
|
unsigned NumRsc,unsigned NumResources,
|
||||||
struct PrgRsc_Resource *Resource,
|
const struct Prg_Item *Item,
|
||||||
struct Prg_ItmRsc *SelectedItmRsc);
|
struct Prg_ItmRscCodes *SelectedItmRscCodes);
|
||||||
static void PrgRsc_WriteRowNewResource (Prg_ListingType_t ListingType,
|
static void PrgRsc_WriteRowNewResource (Prg_ListingType_t ListingType,
|
||||||
unsigned NumResources,
|
unsigned NumResources,
|
||||||
struct Prg_ItmRsc *SelectedItmRsc);
|
struct Prg_ItmRscCodes *SelectedItmRscCodes);
|
||||||
static void PrgRsc_PutFormsToRemEditOneResource (unsigned NumRsc,
|
static void PrgRsc_PutFormsToRemEditOneResource (unsigned NumRsc,
|
||||||
unsigned NumResources,
|
unsigned NumResources,
|
||||||
struct Prg_ItmRsc *ItmRsc,
|
struct Prg_ItmRscCodes *ItmRscCodes,
|
||||||
bool Hidden);
|
bool Hidden);
|
||||||
static long PrgRsc_GetParamRscCod (void);
|
|
||||||
|
|
||||||
static void PrgRsc_HideOrUnhideResource (bool Hide);
|
static void PrgRsc_HideOrUnhideResource (bool Hide);
|
||||||
|
|
||||||
static void PrgRsc_MoveUpDownResource (PrgRsc_MoveUpDown_t UpDown);
|
static void PrgRsc_MoveUpDownResource (PrgRsc_MoveUpDown_t UpDown);
|
||||||
static bool PrgRsc_ExchangeResources (const struct PrgRsc_Rsc *Rsc1,
|
static bool PrgRsc_ExchangeResources (const struct Prg_ResourceHierarchy *Rsc1,
|
||||||
const struct PrgRsc_Rsc *Rsc2);
|
const struct Prg_ResourceHierarchy *Rsc2);
|
||||||
|
|
||||||
|
static void PrgRsc_ShowClipboard (void);
|
||||||
|
static void PrgRsc_WriteRowViewLink (unsigned NumLink,
|
||||||
|
const struct PrgRsc_Link *Link);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************************** View resources *******************************/
|
/****************************** View resources *******************************/
|
||||||
|
@ -93,16 +95,16 @@ static bool PrgRsc_ExchangeResources (const struct PrgRsc_Rsc *Rsc1,
|
||||||
|
|
||||||
void PrgRsc_ViewResourcesAfterEdit (void)
|
void PrgRsc_ViewResourcesAfterEdit (void)
|
||||||
{
|
{
|
||||||
long ItmCod;
|
struct Prg_Item Item;
|
||||||
|
|
||||||
/***** Get list of program items *****/
|
/***** Get list of program items *****/
|
||||||
Prg_GetListItems ();
|
Prg_GetListItems ();
|
||||||
|
|
||||||
/***** Get the code of the program item *****/
|
/***** Get the code of the program item *****/
|
||||||
ItmCod = Prg_GetParamItmCod ();
|
Prg_GetParams (&Item);
|
||||||
|
|
||||||
/***** Show current program items, if any *****/
|
/***** Show current program items, if any *****/
|
||||||
Prg_ShowAllItems (Prg_END_EDIT_RES,ItmCod,-1L);
|
Prg_ShowAllItems (Prg_END_EDIT_RES,Item.Hierarchy.ItmCod,-1L);
|
||||||
|
|
||||||
/***** Free list of program items *****/
|
/***** Free list of program items *****/
|
||||||
Prg_FreeListItems ();
|
Prg_FreeListItems ();
|
||||||
|
@ -114,16 +116,16 @@ void PrgRsc_ViewResourcesAfterEdit (void)
|
||||||
|
|
||||||
void PrgRsc_EditResources (void)
|
void PrgRsc_EditResources (void)
|
||||||
{
|
{
|
||||||
long ItmCod;
|
struct Prg_Item Item;
|
||||||
|
|
||||||
/***** Get list of program items *****/
|
/***** Get list of program items *****/
|
||||||
Prg_GetListItems ();
|
Prg_GetListItems ();
|
||||||
|
|
||||||
/***** Get the code of the program item *****/
|
/***** Get the code of the program item *****/
|
||||||
ItmCod = Prg_GetParamItmCod ();
|
Prg_GetParams (&Item);
|
||||||
|
|
||||||
/***** Show current program items, if any *****/
|
/***** Show current program items, if any *****/
|
||||||
Prg_ShowAllItems (Prg_EDIT_RESOURCES,ItmCod,-1L);
|
Prg_ShowAllItems (Prg_EDIT_RESOURCES,Item.Hierarchy.ItmCod,-1L);
|
||||||
|
|
||||||
/***** Free list of program items *****/
|
/***** Free list of program items *****/
|
||||||
Prg_FreeListItems ();
|
Prg_FreeListItems ();
|
||||||
|
@ -134,7 +136,7 @@ void PrgRsc_EditResources (void)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void PrgRsc_ListItemResources (Prg_ListingType_t ListingType,
|
void PrgRsc_ListItemResources (Prg_ListingType_t ListingType,
|
||||||
struct Prg_ItmRsc *SelectedItmRsc)
|
struct Prg_ItmRscCodes *SelectedItmRscCodes)
|
||||||
{
|
{
|
||||||
extern const char *Hlp_COURSE_Program;
|
extern const char *Hlp_COURSE_Program;
|
||||||
extern const char *Txt_Remove_resource;
|
extern const char *Txt_Remove_resource;
|
||||||
|
@ -142,7 +144,7 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType,
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned NumRsc;
|
unsigned NumRsc;
|
||||||
unsigned NumResources;
|
unsigned NumResources;
|
||||||
struct PrgRsc_Resource Resource;
|
struct Prg_Item Item;
|
||||||
static bool GetHiddenResources[Prg_NUM_LISTING_TYPES] =
|
static bool GetHiddenResources[Prg_NUM_LISTING_TYPES] =
|
||||||
{
|
{
|
||||||
[Prg_PRINT ] = false,
|
[Prg_PRINT ] = false,
|
||||||
|
@ -205,11 +207,11 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType,
|
||||||
};
|
};
|
||||||
|
|
||||||
/***** Trivial check *****/
|
/***** Trivial check *****/
|
||||||
if (SelectedItmRsc->ItmCod <= 0)
|
if (SelectedItmRscCodes->ItmCod <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/***** Get list of item resources from database *****/
|
/***** Get list of item resources from database *****/
|
||||||
NumResources = Prg_DB_GetListResources (&mysql_res,SelectedItmRsc->ItmCod,
|
NumResources = Prg_DB_GetListResources (&mysql_res,SelectedItmRscCodes->ItmCod,
|
||||||
GetHiddenResources[ListingType]);
|
GetHiddenResources[ListingType]);
|
||||||
|
|
||||||
if (NumResources || ShowListWhenEmpty[ListingType])
|
if (NumResources || ShowListWhenEmpty[ListingType])
|
||||||
|
@ -225,7 +227,7 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType,
|
||||||
case ActReqRemPrgRsc:
|
case ActReqRemPrgRsc:
|
||||||
/* Alert with button to remove resource */
|
/* Alert with button to remove resource */
|
||||||
Ale_ShowLastAlertAndButton (ActRemPrgRsc,PrgRsc_RESOURCE_SECTION_ID,NULL,
|
Ale_ShowLastAlertAndButton (ActRemPrgRsc,PrgRsc_RESOURCE_SECTION_ID,NULL,
|
||||||
Prg_PutParams,SelectedItmRsc,
|
Prg_PutParams,SelectedItmRscCodes,
|
||||||
Btn_REMOVE_BUTTON,Txt_Remove_resource);
|
Btn_REMOVE_BUTTON,Txt_Remove_resource);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -235,7 +237,7 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType,
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
Box_BoxBegin ("100%",Txt_Resources,
|
Box_BoxBegin ("100%",Txt_Resources,
|
||||||
FunctionToDrawContextualIcons[ListingType],SelectedItmRsc,
|
FunctionToDrawContextualIcons[ListingType],SelectedItmRscCodes,
|
||||||
Hlp_COURSE_Program,Box_NOT_CLOSABLE);
|
Hlp_COURSE_Program,Box_NOT_CLOSABLE);
|
||||||
|
|
||||||
/***** Table *****/
|
/***** Table *****/
|
||||||
|
@ -243,12 +245,12 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType,
|
||||||
HTM_TBODY_Begin (NULL);
|
HTM_TBODY_Begin (NULL);
|
||||||
|
|
||||||
/***** Write all item resources *****/
|
/***** Write all item resources *****/
|
||||||
for (NumRsc = 0, The_ResetRowColor1 ();
|
for (NumRsc = 0, The_ResetRowColor1 (1);
|
||||||
NumRsc < NumResources;
|
NumRsc < NumResources;
|
||||||
NumRsc++, The_ChangeRowColor1 ())
|
NumRsc++, The_ChangeRowColor1 (1))
|
||||||
{
|
{
|
||||||
/* Get data of this item resource */
|
/* Get data of this item resource */
|
||||||
PrgRsc_GetDataOfResource (&Resource,&mysql_res);
|
PrgRsc_GetDataOfResource (&Item,&mysql_res);
|
||||||
|
|
||||||
/* Show item */
|
/* Show item */
|
||||||
switch (ListingType)
|
switch (ListingType)
|
||||||
|
@ -258,10 +260,10 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType,
|
||||||
case Prg_CHANGE_RESOURCE_LINK:
|
case Prg_CHANGE_RESOURCE_LINK:
|
||||||
PrgRsc_WriteRowEditResource (ListingType,
|
PrgRsc_WriteRowEditResource (ListingType,
|
||||||
NumRsc,NumResources,
|
NumRsc,NumResources,
|
||||||
&Resource,SelectedItmRsc);
|
&Item,SelectedItmRscCodes);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PrgRsc_WriteRowViewResource (NumRsc,&Resource);
|
PrgRsc_WriteRowViewResource (NumRsc,&Item);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -273,7 +275,7 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType,
|
||||||
case Prg_SHOW_CLIPBOARD:
|
case Prg_SHOW_CLIPBOARD:
|
||||||
case Prg_CHANGE_RESOURCE_LINK:
|
case Prg_CHANGE_RESOURCE_LINK:
|
||||||
PrgRsc_WriteRowNewResource (ListingType,NumResources,
|
PrgRsc_WriteRowNewResource (ListingType,NumResources,
|
||||||
SelectedItmRsc);
|
SelectedItmRscCodes);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -299,55 +301,55 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType,
|
||||||
/************** Put contextual icons in list of item resources ***************/
|
/************** Put contextual icons in list of item resources ***************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void PrgRsc_PutIconsViewResources (void *ItmRsc)
|
static void PrgRsc_PutIconsViewResources (void *ItmRscCodes)
|
||||||
{
|
{
|
||||||
/***** Put icon to create a new item resource *****/
|
/***** Put icon to create a new item resource *****/
|
||||||
if (ItmRsc)
|
if (ItmRscCodes)
|
||||||
if (((struct Prg_ItmRsc *) ItmRsc)->ItmCod > 0)
|
if (((struct Prg_ItmRscCodes *) ItmRscCodes)->ItmCod > 0)
|
||||||
if (Prg_CheckIfICanEditProgram ())
|
if (Prg_CheckIfICanEditProgram ())
|
||||||
Ico_PutContextualIconToView (ActFrmSeePrgRsc,PrgRsc_RESOURCE_SECTION_ID,
|
Ico_PutContextualIconToView (ActFrmSeePrgRsc,PrgRsc_RESOURCE_SECTION_ID,
|
||||||
Prg_PutParams,ItmRsc);
|
Prg_PutParams,ItmRscCodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PrgRsc_PutIconsEditResources (void *ItmRsc)
|
static void PrgRsc_PutIconsEditResources (void *ItmRscCodes)
|
||||||
{
|
{
|
||||||
/***** Put icon to create a new item resource *****/
|
/***** Put icon to create a new item resource *****/
|
||||||
if (ItmRsc)
|
if (ItmRscCodes)
|
||||||
if (((struct Prg_ItmRsc *) ItmRsc)->ItmCod > 0)
|
if (((struct Prg_ItmRscCodes *) ItmRscCodes)->ItmCod > 0)
|
||||||
if (Prg_CheckIfICanEditProgram ())
|
if (Prg_CheckIfICanEditProgram ())
|
||||||
Ico_PutContextualIconToEdit (ActFrmEdiPrgRsc,PrgRsc_RESOURCE_SECTION_ID,
|
Ico_PutContextualIconToEdit (ActFrmEdiPrgRsc,PrgRsc_RESOURCE_SECTION_ID,
|
||||||
Prg_PutParams,ItmRsc);
|
Prg_PutParams,ItmRscCodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************** Get item resource data using its code ********************/
|
/****************** Get item resource data using its code ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void PrgRsc_GetDataOfResourceByCod (struct PrgRsc_Resource *Resource)
|
void PrgRsc_GetDataOfResourceByCod (struct Prg_Item *Item)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
|
|
||||||
if (Resource->Rsc.Cod > 0)
|
if (Item->Resource.Hierarchy.RscCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get data of item resource *****/
|
/***** Get data of item resource *****/
|
||||||
if (Prg_DB_GetDataOfResourceByCod (&mysql_res,Resource->Rsc.Cod))
|
if (Prg_DB_GetDataOfResourceByCod (&mysql_res,Item->Resource.Hierarchy.RscCod))
|
||||||
PrgRsc_GetDataOfResource (Resource,&mysql_res);
|
PrgRsc_GetDataOfResource (Item,&mysql_res);
|
||||||
else
|
else
|
||||||
PrgRsc_ResetResource (Resource);
|
Prg_ResetItem (Item);
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/***** Clear all item resource data *****/
|
/***** Clear all item resource data *****/
|
||||||
PrgRsc_ResetResource (Resource);
|
Prg_ResetItem (Item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************************* Get item resource data ****************************/
|
/************************* Get item resource data ****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void PrgRsc_GetDataOfResource (struct PrgRsc_Resource *Resource,
|
static void PrgRsc_GetDataOfResource (struct Prg_Item *Item,
|
||||||
MYSQL_RES **mysql_res)
|
MYSQL_RES **mysql_res)
|
||||||
{
|
{
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
@ -363,30 +365,17 @@ static void PrgRsc_GetDataOfResource (struct PrgRsc_Resource *Resource,
|
||||||
Title row[4]
|
Title row[4]
|
||||||
*/
|
*/
|
||||||
/* Get code of the program item (row[0]) */
|
/* Get code of the program item (row[0]) */
|
||||||
Resource->ItmCod = Str_ConvertStrCodToLongCod (row[0]);
|
Item->Hierarchy.ItmCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
|
|
||||||
/* Get code and index of the item resource (row[1], row[2]) */
|
/* Get code and index of the item resource (row[1], row[2]) */
|
||||||
Resource->Rsc.Cod = Str_ConvertStrCodToLongCod (row[1]);
|
Item->Resource.Hierarchy.RscCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||||
Resource->Rsc.Ind = Str_ConvertStrToUnsigned (row[2]);
|
Item->Resource.Hierarchy.RscInd = Str_ConvertStrToUnsigned (row[2]);
|
||||||
|
|
||||||
/* Get whether the program item is hidden (row(3)) */
|
/* Get whether the program item is hidden (row(3)) */
|
||||||
Resource->Hidden = (row[3][0] == 'Y');
|
Item->Resource.Hierarchy.Hidden = (row[3][0] == 'Y');
|
||||||
|
|
||||||
/* Get the title of the item resource (row[4]) */
|
/* Get the title of the item resource (row[4]) */
|
||||||
Str_Copy (Resource->Title,row[4],sizeof (Resource->Title) - 1);
|
Str_Copy (Item->Resource.Title,row[4],sizeof (Item->Resource.Title) - 1);
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/************************ Clear all item resource data ***********************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
static void PrgRsc_ResetResource (struct PrgRsc_Resource *Resource)
|
|
||||||
{
|
|
||||||
Resource->ItmCod = -1L;
|
|
||||||
Resource->Rsc.Cod = -1L;
|
|
||||||
Resource->Rsc.Ind = 0;
|
|
||||||
Resource->Hidden = false;
|
|
||||||
Resource->Title[0] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -394,21 +383,21 @@ static void PrgRsc_ResetResource (struct PrgRsc_Resource *Resource)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void PrgRsc_WriteRowViewResource (unsigned NumRsc,
|
static void PrgRsc_WriteRowViewResource (unsigned NumRsc,
|
||||||
struct PrgRsc_Resource *Resource)
|
const struct Prg_Item *Item)
|
||||||
{
|
{
|
||||||
/***** Begin row *****/
|
/***** Begin row *****/
|
||||||
HTM_TR_Begin (NULL);
|
HTM_TR_Begin (NULL);
|
||||||
|
|
||||||
/***** Resource number *****/
|
/***** Resource number *****/
|
||||||
HTM_TD_Begin ("class=\"PRG_NUM PRG_RSC_%s RT %s\"",
|
HTM_TD_Begin ("class=\"PRG_NUM PRG_RSC_%s RT %s\"",
|
||||||
The_GetSuffix (),The_GetColorRows1 ());
|
The_GetSuffix (),The_GetColorRows1 (1));
|
||||||
HTM_Unsigned (NumRsc + 1);
|
HTM_Unsigned (NumRsc + 1);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Title *****/
|
/***** Title *****/
|
||||||
HTM_TD_Begin ("class=\"PRG_MAIN PRG_RSC_%s %s\"",
|
HTM_TD_Begin ("class=\"PRG_MAIN PRG_RSC_%s %s\"",
|
||||||
The_GetSuffix (),The_GetColorRows1 ());
|
The_GetSuffix (),The_GetColorRows1 (1));
|
||||||
HTM_Txt (Resource->Title);
|
HTM_Txt (Item->Resource.Title);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** End row *****/
|
/***** End row *****/
|
||||||
|
@ -421,58 +410,58 @@ static void PrgRsc_WriteRowViewResource (unsigned NumRsc,
|
||||||
|
|
||||||
static void PrgRsc_WriteRowEditResource (Prg_ListingType_t ListingType,
|
static void PrgRsc_WriteRowEditResource (Prg_ListingType_t ListingType,
|
||||||
unsigned NumRsc,unsigned NumResources,
|
unsigned NumRsc,unsigned NumResources,
|
||||||
struct PrgRsc_Resource *Resource,
|
const struct Prg_Item *Item,
|
||||||
struct Prg_ItmRsc *SelectedItmRsc)
|
struct Prg_ItmRscCodes *SelectedItmRscCodes)
|
||||||
{
|
{
|
||||||
struct Prg_ItmRsc ItmRsc;
|
struct Prg_ItmRscCodes ItmRscCodes;
|
||||||
|
|
||||||
ItmRsc.ItmCod = Resource->ItmCod;
|
ItmRscCodes.ItmCod = Item->Hierarchy.ItmCod;
|
||||||
ItmRsc.RscCod = Resource->Rsc.Cod;
|
ItmRscCodes.RscCod = Item->Resource.Hierarchy.RscCod;
|
||||||
|
|
||||||
/***** Begin row *****/
|
/***** Begin row *****/
|
||||||
HTM_TR_Begin (NULL);
|
HTM_TR_Begin (NULL);
|
||||||
|
|
||||||
/***** Forms to remove/edit this item resource *****/
|
/***** Forms to remove/edit this item resource *****/
|
||||||
HTM_TD_Begin ("class=\"PRG_COL1 LT %s\"",The_GetColorRows1 ());
|
HTM_TD_Begin ("class=\"PRG_COL1 LT %s\"",The_GetColorRows1 (1));
|
||||||
PrgRsc_PutFormsToRemEditOneResource (NumRsc,NumResources,
|
PrgRsc_PutFormsToRemEditOneResource (NumRsc,NumResources,
|
||||||
&ItmRsc,Resource->Hidden);
|
&ItmRscCodes,Item->Resource.Hierarchy.Hidden);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Resource number *****/
|
/***** Resource number *****/
|
||||||
HTM_TD_Begin ("class=\"PRG_NUM PRG_RSC_%s RT %s\"",
|
HTM_TD_Begin ("class=\"PRG_NUM PRG_RSC_%s RT %s\"",
|
||||||
The_GetSuffix (),The_GetColorRows1 ());
|
The_GetSuffix (),The_GetColorRows1 (1));
|
||||||
HTM_Unsigned (NumRsc + 1);
|
HTM_Unsigned (NumRsc + 1);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Title *****/
|
/***** Title *****/
|
||||||
HTM_TD_Begin ("class=\"PRG_MAIN LT %s\"",The_GetColorRows1 ());
|
HTM_TD_Begin ("class=\"PRG_MAIN LT %s\"",The_GetColorRows1 (1));
|
||||||
Frm_BeginFormAnchor (ActRenPrgRsc,PrgRsc_RESOURCE_SECTION_ID);
|
Frm_BeginFormAnchor (ActRenPrgRsc,PrgRsc_RESOURCE_SECTION_ID);
|
||||||
Prg_PutParams (&ItmRsc);
|
Prg_PutParams (&ItmRscCodes);
|
||||||
HTM_INPUT_TEXT ("Title",PrgRsc_MAX_CHARS_PROGRAM_RESOURCE_TITLE,Resource->Title,
|
HTM_INPUT_TEXT ("Title",PrgRsc_MAX_CHARS_PROGRAM_RESOURCE_TITLE,Item->Resource.Title,
|
||||||
HTM_SUBMIT_ON_CHANGE,
|
HTM_SUBMIT_ON_CHANGE,
|
||||||
"class=\"INPUT_FULL_NAME INPUT_%s\"",
|
"class=\"INPUT_FULL_NAME INPUT_%s\"",
|
||||||
The_GetSuffix ());
|
The_GetSuffix ());
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Link to resource *****/
|
/***** Icon to edit link *****/
|
||||||
HTM_TD_Begin ("class=\"PRG_MAIN LT %s\"",The_GetColorRows1 ());
|
HTM_TD_Begin ("class=\"PRG_MAIN LT %s\"",The_GetColorRows1 (1));
|
||||||
Ico_PutContextualIconToGetLink (ActChgLnkPrgRsc,PrgRsc_RESOURCE_SECTION_ID,
|
Ico_PutContextualIconToGetLink (ActChgLnkPrgRsc,PrgRsc_RESOURCE_SECTION_ID,
|
||||||
Prg_PutParams,&ItmRsc);
|
Prg_PutParams,&ItmRscCodes);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Show clipboard to change resource link *****/
|
/***** Link *****/
|
||||||
switch (ListingType)
|
HTM_TD_Begin ("class=\"PRG_MAIN LT %s\"",The_GetColorRows1 (1));
|
||||||
{
|
|
||||||
case Prg_SHOW_CLIPBOARD:
|
/* Current link */
|
||||||
HTM_TD_Begin ("class=\"PRG_MAIN LT %s\"",The_GetColorRows1 ());
|
// Ale_ShowAlert (Ale_INFO,"Current link.");
|
||||||
if (Resource->Rsc.Cod == SelectedItmRsc->RscCod)
|
|
||||||
Ale_ShowAlert (Ale_INFO,"Clipboard for existing resource");
|
/* Show clipboard to change resource link */
|
||||||
HTM_TD_End ();
|
if (ListingType == Prg_SHOW_CLIPBOARD &&
|
||||||
break;
|
Item->Resource.Hierarchy.RscCod == SelectedItmRscCodes->RscCod)
|
||||||
default:
|
PrgRsc_ShowClipboard ();
|
||||||
break;
|
|
||||||
}
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** End row *****/
|
/***** End row *****/
|
||||||
HTM_TR_End ();
|
HTM_TR_End ();
|
||||||
|
@ -484,30 +473,30 @@ static void PrgRsc_WriteRowEditResource (Prg_ListingType_t ListingType,
|
||||||
|
|
||||||
static void PrgRsc_WriteRowNewResource (Prg_ListingType_t ListingType,
|
static void PrgRsc_WriteRowNewResource (Prg_ListingType_t ListingType,
|
||||||
unsigned NumResources,
|
unsigned NumResources,
|
||||||
struct Prg_ItmRsc *SelectedItmRsc)
|
struct Prg_ItmRscCodes *SelectedItmRscCodes)
|
||||||
{
|
{
|
||||||
struct Prg_ItmRsc ItmRsc;
|
struct Prg_ItmRscCodes ItmRscCodes;
|
||||||
|
|
||||||
ItmRsc.ItmCod = SelectedItmRsc->ItmCod;
|
ItmRscCodes.ItmCod = SelectedItmRscCodes->ItmCod;
|
||||||
ItmRsc.RscCod = -1L;
|
ItmRscCodes.RscCod = -1L;
|
||||||
|
|
||||||
/***** Begin row *****/
|
/***** Begin row *****/
|
||||||
HTM_TR_Begin (NULL);
|
HTM_TR_Begin (NULL);
|
||||||
|
|
||||||
/***** Forms to remove/edit this item resource *****/
|
/***** Forms to remove/edit this item resource *****/
|
||||||
HTM_TD_Begin ("class=\"PRG_COL1 LT %s\"",The_GetColorRows1 ());
|
HTM_TD_Begin ("class=\"PRG_COL1 LT %s\"",The_GetColorRows1 (1));
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Resource number *****/
|
/***** Resource number *****/
|
||||||
HTM_TD_Begin ("class=\"PRG_NUM PRG_RSC_%s RT %s\"",
|
HTM_TD_Begin ("class=\"PRG_NUM PRG_RSC_%s RT %s\"",
|
||||||
The_GetSuffix (),The_GetColorRows1 ());
|
The_GetSuffix (),The_GetColorRows1 (1));
|
||||||
HTM_Unsigned (NumResources + 1);
|
HTM_Unsigned (NumResources + 1);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Title *****/
|
/***** Title *****/
|
||||||
HTM_TD_Begin ("class=\"PRG_MAIN LT %s\"",The_GetColorRows1 ());
|
HTM_TD_Begin ("class=\"PRG_MAIN LT %s\"",The_GetColorRows1 (1));
|
||||||
Frm_BeginFormAnchor (ActNewPrgRsc,PrgRsc_RESOURCE_SECTION_ID);
|
Frm_BeginFormAnchor (ActNewPrgRsc,PrgRsc_RESOURCE_SECTION_ID);
|
||||||
Prg_PutParams (&ItmRsc);
|
Prg_PutParams (&ItmRscCodes);
|
||||||
HTM_INPUT_TEXT ("Title",PrgRsc_MAX_CHARS_PROGRAM_RESOURCE_TITLE,"",
|
HTM_INPUT_TEXT ("Title",PrgRsc_MAX_CHARS_PROGRAM_RESOURCE_TITLE,"",
|
||||||
HTM_SUBMIT_ON_CHANGE,
|
HTM_SUBMIT_ON_CHANGE,
|
||||||
"placeholder=\"%s\""
|
"placeholder=\"%s\""
|
||||||
|
@ -517,24 +506,21 @@ static void PrgRsc_WriteRowNewResource (Prg_ListingType_t ListingType,
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Link to resource *****/
|
/***** Icon to edit link *****/
|
||||||
HTM_TD_Begin ("class=\"PRG_MAIN LT %s\"",The_GetColorRows1 ());
|
HTM_TD_Begin ("class=\"PRG_MAIN LT %s\"",The_GetColorRows1 (1));
|
||||||
Ico_PutContextualIconToGetLink (ActChgLnkPrgRsc,PrgRsc_RESOURCE_SECTION_ID,
|
Ico_PutContextualIconToGetLink (ActChgLnkPrgRsc,PrgRsc_RESOURCE_SECTION_ID,
|
||||||
Prg_PutParams,&ItmRsc);
|
Prg_PutParams,&ItmRscCodes);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Show clipboard to change resource link *****/
|
/***** Link *****/
|
||||||
switch (ListingType)
|
HTM_TD_Begin ("class=\"PRG_MAIN LT %s\"",The_GetColorRows1 (1));
|
||||||
{
|
|
||||||
case Prg_SHOW_CLIPBOARD:
|
/* Show clipboard to change resource link */
|
||||||
HTM_TD_Begin ("class=\"PRG_MAIN LT %s\"",The_GetColorRows1 ());
|
if (ListingType == Prg_SHOW_CLIPBOARD &&
|
||||||
if (ItmRsc.RscCod == SelectedItmRsc->RscCod)
|
SelectedItmRscCodes->RscCod <= 0) // No resource selected
|
||||||
Ale_ShowAlert (Ale_INFO,"Clipboard for new resource");
|
PrgRsc_ShowClipboard ();
|
||||||
HTM_TD_End ();
|
|
||||||
break;
|
HTM_TD_End ();
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** End row *****/
|
/***** End row *****/
|
||||||
HTM_TR_End ();
|
HTM_TR_End ();
|
||||||
|
@ -546,7 +532,7 @@ static void PrgRsc_WriteRowNewResource (Prg_ListingType_t ListingType,
|
||||||
|
|
||||||
static void PrgRsc_PutFormsToRemEditOneResource (unsigned NumRsc,
|
static void PrgRsc_PutFormsToRemEditOneResource (unsigned NumRsc,
|
||||||
unsigned NumResources,
|
unsigned NumResources,
|
||||||
struct Prg_ItmRsc *ItmRsc,
|
struct Prg_ItmRscCodes *ItmRscCodes,
|
||||||
bool Hidden)
|
bool Hidden)
|
||||||
{
|
{
|
||||||
static Act_Action_t ActionHideUnhide[2] =
|
static Act_Action_t ActionHideUnhide[2] =
|
||||||
|
@ -562,17 +548,17 @@ static void PrgRsc_PutFormsToRemEditOneResource (unsigned NumRsc,
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
/***** Icon to remove item resource *****/
|
/***** Icon to remove item resource *****/
|
||||||
Ico_PutContextualIconToRemove (ActReqRemPrgRsc,PrgRsc_RESOURCE_SECTION_ID,
|
Ico_PutContextualIconToRemove (ActReqRemPrgRsc,PrgRsc_RESOURCE_SECTION_ID,
|
||||||
Prg_PutParams,ItmRsc);
|
Prg_PutParams,ItmRscCodes);
|
||||||
|
|
||||||
/***** Icon to hide/unhide item resource *****/
|
/***** Icon to hide/unhide item resource *****/
|
||||||
Ico_PutContextualIconToHideUnhide (ActionHideUnhide,PrgRsc_RESOURCE_SECTION_ID,
|
Ico_PutContextualIconToHideUnhide (ActionHideUnhide,PrgRsc_RESOURCE_SECTION_ID,
|
||||||
Prg_PutParams,ItmRsc,
|
Prg_PutParams,ItmRscCodes,
|
||||||
Hidden);
|
Hidden);
|
||||||
|
|
||||||
/***** Icon to move up the item *****/
|
/***** Icon to move up the item *****/
|
||||||
if (NumRsc > 0)
|
if (NumRsc > 0)
|
||||||
Lay_PutContextualLinkOnlyIcon (ActUp_PrgRsc,PrgRsc_RESOURCE_SECTION_ID,
|
Lay_PutContextualLinkOnlyIcon (ActUp_PrgRsc,PrgRsc_RESOURCE_SECTION_ID,
|
||||||
Prg_PutParams,ItmRsc,
|
Prg_PutParams,ItmRscCodes,
|
||||||
"arrow-up.svg",Ico_BLACK);
|
"arrow-up.svg",Ico_BLACK);
|
||||||
else
|
else
|
||||||
Ico_PutIconOff ("arrow-up.svg",Ico_BLACK,Txt_Movement_not_allowed);
|
Ico_PutIconOff ("arrow-up.svg",Ico_BLACK,Txt_Movement_not_allowed);
|
||||||
|
@ -580,7 +566,7 @@ static void PrgRsc_PutFormsToRemEditOneResource (unsigned NumRsc,
|
||||||
/***** Put icon to move down the item *****/
|
/***** Put icon to move down the item *****/
|
||||||
if (NumRsc < NumResources - 1)
|
if (NumRsc < NumResources - 1)
|
||||||
Lay_PutContextualLinkOnlyIcon (ActDwnPrgRsc,PrgRsc_RESOURCE_SECTION_ID,
|
Lay_PutContextualLinkOnlyIcon (ActDwnPrgRsc,PrgRsc_RESOURCE_SECTION_ID,
|
||||||
Prg_PutParams,ItmRsc,
|
Prg_PutParams,ItmRscCodes,
|
||||||
"arrow-down.svg",Ico_BLACK);
|
"arrow-down.svg",Ico_BLACK);
|
||||||
else
|
else
|
||||||
Ico_PutIconOff ("arrow-down.svg",Ico_BLACK,Txt_Movement_not_allowed);
|
Ico_PutIconOff ("arrow-down.svg",Ico_BLACK,Txt_Movement_not_allowed);
|
||||||
|
@ -606,7 +592,7 @@ void PrgRsc_PutParamRscCod (long RscCod)
|
||||||
/***************** Get parameter with code of item resource ******************/
|
/***************** Get parameter with code of item resource ******************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static long PrgRsc_GetParamRscCod (void)
|
long PrgRsc_GetParamRscCod (void)
|
||||||
{
|
{
|
||||||
return Par_GetParToLong ("RscCod");
|
return Par_GetParToLong ("RscCod");
|
||||||
}
|
}
|
||||||
|
@ -617,23 +603,23 @@ static long PrgRsc_GetParamRscCod (void)
|
||||||
|
|
||||||
void PrgRsc_CreateResource (void)
|
void PrgRsc_CreateResource (void)
|
||||||
{
|
{
|
||||||
struct PrgRsc_Resource Resource;
|
struct Prg_Item Item;
|
||||||
|
|
||||||
/***** Get list of program items *****/
|
/***** Get list of program items *****/
|
||||||
Prg_GetListItems ();
|
Prg_GetListItems ();
|
||||||
|
|
||||||
/***** Get parameters *****/
|
/***** Get parameters *****/
|
||||||
/* Get the code of the program item */
|
/* Get the code of the program item */
|
||||||
Resource.ItmCod = Prg_GetParamItmCod ();
|
Prg_GetParams (&Item);
|
||||||
|
|
||||||
/* Get the new title for the new resource */
|
/* Get the new title for the new resource */
|
||||||
Par_GetParToText ("Title",Resource.Title,PrgRsc_MAX_BYTES_PROGRAM_RESOURCE_TITLE);
|
Par_GetParToText ("Title",Item.Resource.Title,PrgRsc_MAX_BYTES_PROGRAM_RESOURCE_TITLE);
|
||||||
|
|
||||||
/***** Create resource *****/
|
/***** Create resource *****/
|
||||||
Resource.Rsc.Cod = Prg_DB_CreateResource (&Resource);
|
Item.Resource.Hierarchy.RscCod = Prg_DB_CreateResource (&Item);
|
||||||
|
|
||||||
/***** Show current program items, if any *****/
|
/***** Show current program items, if any *****/
|
||||||
Prg_ShowAllItems (Prg_EDIT_RESOURCES,Resource.ItmCod,Resource.Rsc.Cod);
|
Prg_ShowAllItems (Prg_EDIT_RESOURCES,Item.Hierarchy.ItmCod,Item.Resource.Hierarchy.RscCod);
|
||||||
|
|
||||||
/***** Free list of program items *****/
|
/***** Free list of program items *****/
|
||||||
Prg_FreeListItems ();
|
Prg_FreeListItems ();
|
||||||
|
@ -645,16 +631,15 @@ void PrgRsc_CreateResource (void)
|
||||||
|
|
||||||
void PrgRsc_RenameResource (void)
|
void PrgRsc_RenameResource (void)
|
||||||
{
|
{
|
||||||
struct PrgRsc_Resource Resource;
|
struct Prg_Item Item;
|
||||||
char NewTitle[PrgRsc_MAX_BYTES_PROGRAM_RESOURCE_TITLE + 1];
|
char NewTitle[PrgRsc_MAX_BYTES_PROGRAM_RESOURCE_TITLE + 1];
|
||||||
|
|
||||||
/***** Get list of program items *****/
|
/***** Get list of program items *****/
|
||||||
Prg_GetListItems ();
|
Prg_GetListItems ();
|
||||||
|
|
||||||
/***** Get data of the item resource from database *****/
|
/***** Get data of the item resource from database *****/
|
||||||
Resource.Rsc.Cod = PrgRsc_GetParamRscCod ();
|
Prg_GetParams (&Item);
|
||||||
PrgRsc_GetDataOfResourceByCod (&Resource);
|
if (Item.Hierarchy.ItmCod <= 0)
|
||||||
if (Resource.ItmCod <= 0)
|
|
||||||
Err_WrongResourceExit ();
|
Err_WrongResourceExit ();
|
||||||
|
|
||||||
/***** Rename resource *****/
|
/***** Rename resource *****/
|
||||||
|
@ -662,10 +647,10 @@ void PrgRsc_RenameResource (void)
|
||||||
Par_GetParToText ("Title",NewTitle,PrgRsc_MAX_BYTES_PROGRAM_RESOURCE_TITLE);
|
Par_GetParToText ("Title",NewTitle,PrgRsc_MAX_BYTES_PROGRAM_RESOURCE_TITLE);
|
||||||
|
|
||||||
/* Update database changing old title by new title */
|
/* Update database changing old title by new title */
|
||||||
Prg_DB_UpdateResourceTitle (Resource.Rsc.Cod,Resource.ItmCod,NewTitle);
|
Prg_DB_UpdateResourceTitle (Item.Hierarchy.ItmCod,Item.Resource.Hierarchy.RscCod,NewTitle);
|
||||||
|
|
||||||
/***** Show current program items, if any *****/
|
/***** Show current program items, if any *****/
|
||||||
Prg_ShowAllItems (Prg_EDIT_RESOURCES,Resource.ItmCod,Resource.Rsc.Cod);
|
Prg_ShowAllItems (Prg_EDIT_RESOURCES,Item.Hierarchy.ItmCod,Item.Resource.Hierarchy.RscCod);
|
||||||
|
|
||||||
/***** Free list of program items *****/
|
/***** Free list of program items *****/
|
||||||
Prg_FreeListItems ();
|
Prg_FreeListItems ();
|
||||||
|
@ -678,24 +663,23 @@ void PrgRsc_RenameResource (void)
|
||||||
void PrgRsc_ReqRemResource (void)
|
void PrgRsc_ReqRemResource (void)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Do_you_really_want_to_remove_the_resource_X;
|
extern const char *Txt_Do_you_really_want_to_remove_the_resource_X;
|
||||||
struct PrgRsc_Resource Resource;
|
struct Prg_Item Item;
|
||||||
|
|
||||||
/***** Get list of program items *****/
|
/***** Get list of program items *****/
|
||||||
Prg_GetListItems ();
|
Prg_GetListItems ();
|
||||||
|
|
||||||
/***** Get data of the item resource from database *****/
|
/***** Get data of the item resource from database *****/
|
||||||
Resource.Rsc.Cod = PrgRsc_GetParamRscCod ();
|
Prg_GetParams (&Item);
|
||||||
PrgRsc_GetDataOfResourceByCod (&Resource);
|
if (Item.Hierarchy.ItmCod <= 0)
|
||||||
if (Resource.ItmCod <= 0)
|
|
||||||
Err_WrongResourceExit ();
|
Err_WrongResourceExit ();
|
||||||
|
|
||||||
/***** Create alert to remove the item resource *****/
|
/***** Create alert to remove the item resource *****/
|
||||||
Ale_CreateAlert (Ale_QUESTION,PrgRsc_RESOURCE_SECTION_ID,
|
Ale_CreateAlert (Ale_QUESTION,PrgRsc_RESOURCE_SECTION_ID,
|
||||||
Txt_Do_you_really_want_to_remove_the_resource_X,
|
Txt_Do_you_really_want_to_remove_the_resource_X,
|
||||||
Resource.Title);
|
Item.Resource.Title);
|
||||||
|
|
||||||
/***** Show current program items, if any *****/
|
/***** Show current program items, if any *****/
|
||||||
Prg_ShowAllItems (Prg_EDIT_RESOURCES,Resource.ItmCod,Resource.Rsc.Cod);
|
Prg_ShowAllItems (Prg_EDIT_RESOURCES,Item.Hierarchy.ItmCod,Item.Resource.Hierarchy.RscCod);
|
||||||
|
|
||||||
/***** Free list of program items *****/
|
/***** Free list of program items *****/
|
||||||
Prg_FreeListItems ();
|
Prg_FreeListItems ();
|
||||||
|
@ -708,26 +692,25 @@ void PrgRsc_ReqRemResource (void)
|
||||||
void PrgRsc_RemoveResource (void)
|
void PrgRsc_RemoveResource (void)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Resource_X_removed;
|
extern const char *Txt_Resource_X_removed;
|
||||||
struct PrgRsc_Resource Resource;
|
struct Prg_Item Item;
|
||||||
|
|
||||||
/***** Get list of program items *****/
|
/***** Get list of program items *****/
|
||||||
Prg_GetListItems ();
|
Prg_GetListItems ();
|
||||||
|
|
||||||
/***** Get data of the item resource from database *****/
|
/***** Get data of the item resource from database *****/
|
||||||
Resource.Rsc.Cod = PrgRsc_GetParamRscCod ();
|
Prg_GetParams (&Item);
|
||||||
PrgRsc_GetDataOfResourceByCod (&Resource);
|
if (Item.Hierarchy.ItmCod <= 0)
|
||||||
if (Resource.ItmCod <= 0)
|
|
||||||
Err_WrongResourceExit ();
|
Err_WrongResourceExit ();
|
||||||
|
|
||||||
/***** Remove resource *****/
|
/***** Remove resource *****/
|
||||||
Prg_DB_RemoveResource (&Resource);
|
Prg_DB_RemoveResource (&Item);
|
||||||
|
|
||||||
/***** Create alert to remove the item resource *****/
|
/***** Create alert to remove the item resource *****/
|
||||||
Ale_CreateAlert (Ale_SUCCESS,PrgRsc_RESOURCE_SECTION_ID,
|
Ale_CreateAlert (Ale_SUCCESS,PrgRsc_RESOURCE_SECTION_ID,
|
||||||
Txt_Resource_X_removed,Resource.Title);
|
Txt_Resource_X_removed,Item.Resource.Title);
|
||||||
|
|
||||||
/***** Show current program items, if any *****/
|
/***** Show current program items, if any *****/
|
||||||
Prg_ShowAllItems (Prg_EDIT_RESOURCES,Resource.ItmCod,Resource.Rsc.Cod);
|
Prg_ShowAllItems (Prg_EDIT_RESOURCES,Item.Hierarchy.ItmCod,Item.Resource.Hierarchy.RscCod);
|
||||||
|
|
||||||
/***** Free list of program items *****/
|
/***** Free list of program items *****/
|
||||||
Prg_FreeListItems ();
|
Prg_FreeListItems ();
|
||||||
|
@ -749,22 +732,21 @@ void PrgRsc_UnhideResource (void)
|
||||||
|
|
||||||
static void PrgRsc_HideOrUnhideResource (bool Hide)
|
static void PrgRsc_HideOrUnhideResource (bool Hide)
|
||||||
{
|
{
|
||||||
struct PrgRsc_Resource Resource;
|
struct Prg_Item Item;
|
||||||
|
|
||||||
/***** Get list of program items *****/
|
/***** Get list of program items *****/
|
||||||
Prg_GetListItems ();
|
Prg_GetListItems ();
|
||||||
|
|
||||||
/***** Get data of the item resource from database *****/
|
/***** Get data of the item resource from database *****/
|
||||||
Resource.Rsc.Cod = PrgRsc_GetParamRscCod ();
|
Prg_GetParams (&Item);
|
||||||
PrgRsc_GetDataOfResourceByCod (&Resource);
|
if (Item.Hierarchy.ItmCod <= 0)
|
||||||
if (Resource.ItmCod <= 0)
|
|
||||||
Err_WrongResourceExit ();
|
Err_WrongResourceExit ();
|
||||||
|
|
||||||
/***** Hide/unhide item resource *****/
|
/***** Hide/unhide item resource *****/
|
||||||
Prg_DB_HideOrUnhideResource (Resource.Rsc.Cod,Hide);
|
Prg_DB_HideOrUnhideResource (Item.Resource.Hierarchy.RscCod,Hide);
|
||||||
|
|
||||||
/***** Show current program items, if any *****/
|
/***** Show current program items, if any *****/
|
||||||
Prg_ShowAllItems (Prg_EDIT_RESOURCES,Resource.ItmCod,Resource.Rsc.Cod);
|
Prg_ShowAllItems (Prg_EDIT_RESOURCES,Item.Hierarchy.ItmCod,Item.Resource.Hierarchy.RscCod);
|
||||||
|
|
||||||
/***** Free list of program items *****/
|
/***** Free list of program items *****/
|
||||||
Prg_FreeListItems ();
|
Prg_FreeListItems ();
|
||||||
|
@ -787,8 +769,8 @@ void PrgRsc_MoveDownResource (void)
|
||||||
static void PrgRsc_MoveUpDownResource (PrgRsc_MoveUpDown_t UpDown)
|
static void PrgRsc_MoveUpDownResource (PrgRsc_MoveUpDown_t UpDown)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Movement_not_allowed;
|
extern const char *Txt_Movement_not_allowed;
|
||||||
struct PrgRsc_Resource Resource;
|
struct Prg_Item Item;
|
||||||
struct PrgRsc_Rsc Rsc2;
|
struct Prg_ResourceHierarchy Rsc2;
|
||||||
bool Success = false;
|
bool Success = false;
|
||||||
static unsigned (*GetOtherRscInd[PrgRsc_NUM_MOVEMENTS_UP_DOWN])(long ItmCod,unsigned RscInd) =
|
static unsigned (*GetOtherRscInd[PrgRsc_NUM_MOVEMENTS_UP_DOWN])(long ItmCod,unsigned RscInd) =
|
||||||
{
|
{
|
||||||
|
@ -800,25 +782,24 @@ static void PrgRsc_MoveUpDownResource (PrgRsc_MoveUpDown_t UpDown)
|
||||||
Prg_GetListItems ();
|
Prg_GetListItems ();
|
||||||
|
|
||||||
/***** Get data of the item resource from database *****/
|
/***** Get data of the item resource from database *****/
|
||||||
Resource.Rsc.Cod = PrgRsc_GetParamRscCod ();
|
Prg_GetParams (&Item);
|
||||||
PrgRsc_GetDataOfResourceByCod (&Resource);
|
if (Item.Hierarchy.ItmCod <= 0)
|
||||||
if (Resource.ItmCod <= 0)
|
|
||||||
Err_WrongResourceExit ();
|
Err_WrongResourceExit ();
|
||||||
|
|
||||||
/***** Move up/down resource *****/
|
/***** Move up/down resource *****/
|
||||||
if ((Rsc2.Ind = GetOtherRscInd[UpDown] (Resource.ItmCod,Resource.Rsc.Ind))) // 0 ==> movement not allowed
|
if ((Rsc2.RscInd = GetOtherRscInd[UpDown] (Item.Hierarchy.ItmCod,Item.Resource.Hierarchy.RscInd))) // 0 ==> movement not allowed
|
||||||
{
|
{
|
||||||
/* Get the other resource code */
|
/* Get the other resource code */
|
||||||
Rsc2.Cod = Prg_DB_GetRscCodFromRscInd (Resource.ItmCod,Rsc2.Ind);
|
Rsc2.RscCod = Prg_DB_GetRscCodFromRscInd (Item.Hierarchy.ItmCod,Rsc2.RscInd);
|
||||||
|
|
||||||
/* Exchange subtrees */
|
/* Exchange subtrees */
|
||||||
Success = PrgRsc_ExchangeResources (&Resource.Rsc,&Rsc2);
|
Success = PrgRsc_ExchangeResources (&Item.Resource.Hierarchy,&Rsc2);
|
||||||
}
|
}
|
||||||
if (!Success)
|
if (!Success)
|
||||||
Ale_ShowAlert (Ale_WARNING,Txt_Movement_not_allowed);
|
Ale_ShowAlert (Ale_WARNING,Txt_Movement_not_allowed);
|
||||||
|
|
||||||
/***** Show current program items, if any *****/
|
/***** Show current program items, if any *****/
|
||||||
Prg_ShowAllItems (Prg_EDIT_RESOURCES,Resource.ItmCod,Resource.Rsc.Cod);
|
Prg_ShowAllItems (Prg_EDIT_RESOURCES,Item.Hierarchy.ItmCod,Item.Resource.Hierarchy.RscCod);
|
||||||
|
|
||||||
/***** Free list of program items *****/
|
/***** Free list of program items *****/
|
||||||
Prg_FreeListItems ();
|
Prg_FreeListItems ();
|
||||||
|
@ -829,11 +810,11 @@ static void PrgRsc_MoveUpDownResource (PrgRsc_MoveUpDown_t UpDown)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Return true if success
|
// Return true if success
|
||||||
|
|
||||||
static bool PrgRsc_ExchangeResources (const struct PrgRsc_Rsc *Rsc1,
|
static bool PrgRsc_ExchangeResources (const struct Prg_ResourceHierarchy *Rsc1,
|
||||||
const struct PrgRsc_Rsc *Rsc2)
|
const struct Prg_ResourceHierarchy *Rsc2)
|
||||||
{
|
{
|
||||||
if (Rsc1->Ind > 0 && // Indexes should be in the range [1, 2,...]
|
if (Rsc1->RscInd > 0 && // Indexes should be in the range [1, 2,...]
|
||||||
Rsc2->Ind > 0)
|
Rsc2->RscInd > 0)
|
||||||
{
|
{
|
||||||
/***** Lock table to make the move atomic *****/
|
/***** Lock table to make the move atomic *****/
|
||||||
Prg_DB_LockTableResources ();
|
Prg_DB_LockTableResources ();
|
||||||
|
@ -842,11 +823,11 @@ static bool PrgRsc_ExchangeResources (const struct PrgRsc_Rsc *Rsc1,
|
||||||
// This implementation works with non continuous indexes
|
// This implementation works with non continuous indexes
|
||||||
/*
|
/*
|
||||||
Example:
|
Example:
|
||||||
Rsc1->Ind = 5
|
Rsc1->Index = 5
|
||||||
Rsc2->Ind = 17
|
Rsc2->Index = 17
|
||||||
Step 1 Step 2 Step 3 (Equivalent to)
|
Step 1 Step 2 Step 3 (Equivalent to)
|
||||||
+-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+
|
+-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+
|
||||||
|Rsc.Ind|Rsc.Cod| |Rsc.Ind|Rsc.Cod| |Rsc.Ind|Rsc.Cod| |Rsc.Ind|Rsc.Cod| |Rsc.Ind|Rsc.Cod|
|
| RscInd| RscCod| | RscInd| RscCod| | RscInd| RscCod| | RscInd| RscCod| | RscInd| RscCod|
|
||||||
+-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+
|
+-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+ +-------+-------+
|
||||||
| 5 | 218 | | 5 | 218 |-->|--> 17 | 218 | | 17 | 218 | | 5 | 240 |
|
| 5 | 218 | | 5 | 218 |-->|--> 17 | 218 | | 17 | 218 | | 5 | 240 |
|
||||||
| 17 | 240 |-->|-->-17 | 240 | | -17 | 240 |-->|--> 5 | 240 | | 17 | 218 |
|
| 17 | 240 |-->|-->-17 | 240 | | -17 | 240 |-->|--> 5 | 240 | | 17 | 218 |
|
||||||
|
@ -854,13 +835,13 @@ static bool PrgRsc_ExchangeResources (const struct PrgRsc_Rsc *Rsc1,
|
||||||
*/
|
*/
|
||||||
/* Step 1: Change second index to negative,
|
/* Step 1: Change second index to negative,
|
||||||
necessary to preserve unique index (ItmCod,RscInd) */
|
necessary to preserve unique index (ItmCod,RscInd) */
|
||||||
Prg_DB_UpdateRscInd (Rsc2->Cod,-(int) Rsc2->Ind);
|
Prg_DB_UpdateRscInd (Rsc2->RscCod,-(int) Rsc2->RscInd);
|
||||||
|
|
||||||
/* Step 2: Change first index */
|
/* Step 2: Change first index */
|
||||||
Prg_DB_UpdateRscInd (Rsc1->Cod, (int) Rsc2->Ind);
|
Prg_DB_UpdateRscInd (Rsc1->RscCod, (int) Rsc2->RscInd);
|
||||||
|
|
||||||
/* Step 3: Change second index */
|
/* Step 3: Change second index */
|
||||||
Prg_DB_UpdateRscInd (Rsc2->Cod, (int) Rsc1->Ind);
|
Prg_DB_UpdateRscInd (Rsc2->RscCod, (int) Rsc1->RscInd);
|
||||||
|
|
||||||
/***** Unlock table *****/
|
/***** Unlock table *****/
|
||||||
DB_UnlockTables ();
|
DB_UnlockTables ();
|
||||||
|
@ -877,26 +858,110 @@ static bool PrgRsc_ExchangeResources (const struct PrgRsc_Rsc *Rsc1,
|
||||||
|
|
||||||
void PrgRsc_ShowClipboardToChgLink (void)
|
void PrgRsc_ShowClipboardToChgLink (void)
|
||||||
{
|
{
|
||||||
struct PrgRsc_Resource Resource;
|
struct Prg_Item Item;
|
||||||
|
|
||||||
/***** Get list of program items *****/
|
/***** Get list of program items *****/
|
||||||
Prg_GetListItems ();
|
Prg_GetListItems ();
|
||||||
|
|
||||||
/***** Get data of the item resource from database *****/
|
/***** Get data of the item resource from database *****/
|
||||||
Resource.Rsc.Cod = PrgRsc_GetParamRscCod ();
|
Prg_GetParams (&Item);
|
||||||
if (Resource.Rsc.Cod > 0) // Resource selected ==> get item code from database using resource code
|
if (Item.Hierarchy.ItmCod <= 0)
|
||||||
PrgRsc_GetDataOfResourceByCod (&Resource);
|
|
||||||
else // No resource selected ==> get item code directly from parameter
|
|
||||||
{
|
|
||||||
PrgRsc_ResetResource (&Resource);
|
|
||||||
Resource.ItmCod = Prg_GetParamItmCod ();
|
|
||||||
}
|
|
||||||
if (Resource.ItmCod <= 0)
|
|
||||||
Err_WrongResourceExit ();
|
Err_WrongResourceExit ();
|
||||||
|
|
||||||
/***** Show current program items, if any *****/
|
/***** Show current program items, if any *****/
|
||||||
Prg_ShowAllItems (Prg_SHOW_CLIPBOARD,Resource.ItmCod,Resource.Rsc.Cod);
|
Prg_ShowAllItems (Prg_SHOW_CLIPBOARD,Item.Hierarchy.ItmCod,Item.Resource.Hierarchy.RscCod);
|
||||||
|
|
||||||
/***** Free list of program items *****/
|
/***** Free list of program items *****/
|
||||||
Prg_FreeListItems ();
|
Prg_FreeListItems ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void PrgRsc_ShowClipboard (void)
|
||||||
|
{
|
||||||
|
MYSQL_RES *mysql_res;
|
||||||
|
unsigned NumLink;
|
||||||
|
unsigned NumLinks;
|
||||||
|
struct PrgRsc_Link Link;
|
||||||
|
|
||||||
|
/***** Get list of item resources from database *****/
|
||||||
|
NumLinks = Prg_DB_GetClipboard (&mysql_res);
|
||||||
|
if (NumLinks)
|
||||||
|
{
|
||||||
|
/***** Table *****/
|
||||||
|
HTM_TABLE_BeginWideMarginPadding (2);
|
||||||
|
HTM_TBODY_Begin (NULL);
|
||||||
|
|
||||||
|
/***** Write all item resources *****/
|
||||||
|
for (NumLink = 0, The_ResetRowColor1 (2);
|
||||||
|
NumLink < NumLinks;
|
||||||
|
NumLink++, The_ChangeRowColor1 (2))
|
||||||
|
{
|
||||||
|
/* Get data of this link */
|
||||||
|
PrgRsc_GetDataOfLinkFromClipboard (&Link,&mysql_res);
|
||||||
|
|
||||||
|
/* Show link */
|
||||||
|
PrgRsc_WriteRowViewLink (NumLink,&Link);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** End table *****/
|
||||||
|
HTM_TBODY_End ();
|
||||||
|
HTM_TABLE_End ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Ale_ShowAlert (Ale_INFO,"Empty clipboard.");
|
||||||
|
|
||||||
|
/***** Free structure that stores the query result *****/
|
||||||
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********************** Convert from string to type **************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
PrgRsc_Type_t PrgRsc_GetTypeFromString (const char *Str)
|
||||||
|
{
|
||||||
|
extern const char *Prg_ResourceTypesDB[PrgRsc_NUM_TYPES];
|
||||||
|
PrgRsc_Type_t Type;
|
||||||
|
|
||||||
|
/***** Compare string with all string types *****/
|
||||||
|
for (Type = (PrgRsc_Type_t) 0;
|
||||||
|
Type <= (PrgRsc_Type_t) (PrgRsc_NUM_TYPES - 1);
|
||||||
|
Type++)
|
||||||
|
if (!strcmp (Prg_ResourceTypesDB[Type],Str))
|
||||||
|
return Type;
|
||||||
|
|
||||||
|
return PrgRsc_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************************ Show one link from clipboard ***********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void PrgRsc_WriteRowViewLink (unsigned NumLink,
|
||||||
|
const struct PrgRsc_Link *Link)
|
||||||
|
{
|
||||||
|
extern const char *Prg_ResourceTypesDB[PrgRsc_NUM_TYPES];
|
||||||
|
|
||||||
|
/***** Begin row *****/
|
||||||
|
HTM_TR_Begin (NULL);
|
||||||
|
|
||||||
|
/***** Link number *****/
|
||||||
|
HTM_TD_Begin ("class=\"PRG_NUM PRG_RSC_%s RT %s\"",
|
||||||
|
The_GetSuffix (),The_GetColorRows1 (2));
|
||||||
|
HTM_Unsigned (NumLink + 1);
|
||||||
|
HTM_TD_End ();
|
||||||
|
|
||||||
|
/***** Type *****/
|
||||||
|
HTM_TD_Begin ("class=\"PRG_MAIN PRG_RSC_%s %s\"",
|
||||||
|
The_GetSuffix (),The_GetColorRows1 (2));
|
||||||
|
HTM_Txt (Prg_ResourceTypesDB[Link->Type]);
|
||||||
|
HTM_TD_End ();
|
||||||
|
|
||||||
|
/***** Code *****/
|
||||||
|
HTM_TD_Begin ("class=\"PRG_MAIN PRG_RSC_%s %s\"",
|
||||||
|
The_GetSuffix (),The_GetColorRows1 (2));
|
||||||
|
HTM_Long (Link->Cod);
|
||||||
|
HTM_TD_End ();
|
||||||
|
|
||||||
|
/***** End row *****/
|
||||||
|
HTM_TR_End ();
|
||||||
|
}
|
||||||
|
|
|
@ -31,23 +31,6 @@
|
||||||
/************************** Public types and constants ***********************/
|
/************************** Public types and constants ***********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define PrgRsc_MAX_CHARS_PROGRAM_RESOURCE_TITLE (128 - 1) // 127
|
|
||||||
#define PrgRsc_MAX_BYTES_PROGRAM_RESOURCE_TITLE ((PrgRsc_MAX_CHARS_PROGRAM_RESOURCE_TITLE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
|
|
||||||
|
|
||||||
struct PrgRsc_Rsc
|
|
||||||
{
|
|
||||||
long Cod;
|
|
||||||
unsigned Ind; // 1, 2, 3...
|
|
||||||
};
|
|
||||||
|
|
||||||
struct PrgRsc_Resource
|
|
||||||
{
|
|
||||||
long ItmCod;
|
|
||||||
struct PrgRsc_Rsc Rsc;
|
|
||||||
bool Hidden;
|
|
||||||
char Title[PrgRsc_MAX_BYTES_PROGRAM_RESOURCE_TITLE + 1];
|
|
||||||
};
|
|
||||||
|
|
||||||
#define PrgRsc_NUM_TYPES 10
|
#define PrgRsc_NUM_TYPES 10
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
@ -71,6 +54,12 @@ typedef enum
|
||||||
PrgRsc_FORUM_THREAD,
|
PrgRsc_FORUM_THREAD,
|
||||||
} PrgRsc_Type_t;
|
} PrgRsc_Type_t;
|
||||||
|
|
||||||
|
struct PrgRsc_Link
|
||||||
|
{
|
||||||
|
PrgRsc_Type_t Type;
|
||||||
|
long Cod;
|
||||||
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************************** Public prototypes *****************************/
|
/***************************** Public prototypes *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -79,9 +68,12 @@ void PrgRsc_ViewResourcesAfterEdit (void);
|
||||||
void PrgRsc_EditResources (void);
|
void PrgRsc_EditResources (void);
|
||||||
|
|
||||||
void PrgRsc_ListItemResources (Prg_ListingType_t ListingType,
|
void PrgRsc_ListItemResources (Prg_ListingType_t ListingType,
|
||||||
struct Prg_ItmRsc *SelectedItmRsc);
|
struct Prg_ItmRscCodes *SelectedItmRscCodes);
|
||||||
|
|
||||||
|
void PrgRsc_GetDataOfResourceByCod (struct Prg_Item *Item);
|
||||||
|
|
||||||
void PrgRsc_PutParamRscCod (long RscCod);
|
void PrgRsc_PutParamRscCod (long RscCod);
|
||||||
|
long PrgRsc_GetParamRscCod (void);
|
||||||
|
|
||||||
void PrgRsc_CreateResource (void);
|
void PrgRsc_CreateResource (void);
|
||||||
|
|
||||||
|
@ -98,4 +90,6 @@ void PrgRsc_MoveDownResource (void);
|
||||||
|
|
||||||
void PrgRsc_ShowClipboardToChgLink (void);
|
void PrgRsc_ShowClipboardToChgLink (void);
|
||||||
|
|
||||||
|
PrgRsc_Type_t PrgRsc_GetTypeFromString (const char *Str);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
17
swad_theme.c
17
swad_theme.c
|
@ -206,10 +206,11 @@ const char *The_GetSuffix (void)
|
||||||
/******** Get background colors for rows depending on selected theme *********/
|
/******** Get background colors for rows depending on selected theme *********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static unsigned The_RowEvenOdd[2] = // To alternate row colors in listings
|
static unsigned The_RowEvenOdd[3] = // To alternate row colors in listings
|
||||||
{
|
{
|
||||||
0,
|
0,
|
||||||
0
|
0,
|
||||||
|
0,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *The_ClassColorRows[2][The_NUM_THEMES] =
|
static const char *The_ClassColorRows[2][The_NUM_THEMES] =
|
||||||
|
@ -236,9 +237,9 @@ const char *The_GetColorRows (void)
|
||||||
return The_ClassColorRows[The_RowEvenOdd[0]][Gbl.Prefs.Theme];
|
return The_ClassColorRows[The_RowEvenOdd[0]][Gbl.Prefs.Theme];
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *The_GetColorRows1 (void)
|
const char *The_GetColorRows1 (unsigned Level)
|
||||||
{
|
{
|
||||||
return The_ClassColorRows[The_RowEvenOdd[1]][Gbl.Prefs.Theme];
|
return The_ClassColorRows[The_RowEvenOdd[Level]][Gbl.Prefs.Theme];
|
||||||
}
|
}
|
||||||
|
|
||||||
void The_ResetRowColor (void)
|
void The_ResetRowColor (void)
|
||||||
|
@ -246,9 +247,9 @@ void The_ResetRowColor (void)
|
||||||
The_RowEvenOdd[0] = 0;
|
The_RowEvenOdd[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void The_ResetRowColor1 (void)
|
void The_ResetRowColor1 (unsigned Level)
|
||||||
{
|
{
|
||||||
The_RowEvenOdd[1] = 0;
|
The_RowEvenOdd[Level] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void The_ChangeRowColor (void)
|
void The_ChangeRowColor (void)
|
||||||
|
@ -256,9 +257,9 @@ void The_ChangeRowColor (void)
|
||||||
The_RowEvenOdd[0] = 1 - The_RowEvenOdd[0];
|
The_RowEvenOdd[0] = 1 - The_RowEvenOdd[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
void The_ChangeRowColor1 (void)
|
void The_ChangeRowColor1 (unsigned Level)
|
||||||
{
|
{
|
||||||
The_RowEvenOdd[1] = 1 - The_RowEvenOdd[1];
|
The_RowEvenOdd[Level] = 1 - The_RowEvenOdd[Level];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -57,13 +57,13 @@ The_Theme_t The_GetThemeFromStr (const char *Str);
|
||||||
const char *The_GetSuffix (void);
|
const char *The_GetSuffix (void);
|
||||||
|
|
||||||
const char *The_GetColorRows (void);
|
const char *The_GetColorRows (void);
|
||||||
const char *The_GetColorRows1 (void);
|
const char *The_GetColorRows1 (unsigned Level);
|
||||||
|
|
||||||
void The_ResetRowColor (void);
|
void The_ResetRowColor (void);
|
||||||
void The_ResetRowColor1 (void);
|
void The_ResetRowColor1 (unsigned Level);
|
||||||
|
|
||||||
void The_ChangeRowColor (void);
|
void The_ChangeRowColor (void);
|
||||||
void The_ChangeRowColor1 (void);
|
void The_ChangeRowColor1 (unsigned Level);
|
||||||
|
|
||||||
//-------------------------------- Figures ------------------------------------
|
//-------------------------------- Figures ------------------------------------
|
||||||
void The_GetAndShowNumUsrsPerTheme (void);
|
void The_GetAndShowNumUsrsPerTheme (void);
|
||||||
|
|
Loading…
Reference in New Issue