mirror of https://github.com/acanas/swad-core.git
Version19.142
This commit is contained in:
parent
49c9c2abad
commit
fefffb2ea3
|
@ -1605,9 +1605,6 @@ a:hover img.CENTRE_PHOTO_SHOW
|
||||||
{
|
{
|
||||||
/* from {outline:thick solid #4d88a1;}
|
/* from {outline:thick solid #4d88a1;}
|
||||||
to {outline:thick solid transparent;} */
|
to {outline:thick solid transparent;} */
|
||||||
/*
|
|
||||||
from {text-shadow:0px 1px #008000;}
|
|
||||||
to {text-shadow:0px 1px transparent;} */
|
|
||||||
from {opacity:0;}
|
from {opacity:0;}
|
||||||
to {opacity:1;}
|
to {opacity:1;}
|
||||||
}
|
}
|
||||||
|
|
44
swad_HTML.c
44
swad_HTML.c
|
@ -84,6 +84,8 @@ static unsigned HTM_U_NestingLevel = 0;
|
||||||
|
|
||||||
static void HTM_TABLE_BeginWithoutAttr (void);
|
static void HTM_TABLE_BeginWithoutAttr (void);
|
||||||
|
|
||||||
|
static void HTM_TBODY_BeginWithoutAttr (void);
|
||||||
|
|
||||||
static void HTM_TR_BeginWithoutAttr (void);
|
static void HTM_TR_BeginWithoutAttr (void);
|
||||||
|
|
||||||
static void HTM_TH_BeginWithoutAttr (void);
|
static void HTM_TH_BeginWithoutAttr (void);
|
||||||
|
@ -232,6 +234,48 @@ void HTM_TABLE_End (void)
|
||||||
HTM_TABLE_NestingLevel--;
|
HTM_TABLE_NestingLevel--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********************************* Table body ********************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void HTM_TBODY_Begin (const char *fmt,...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
int NumBytesPrinted;
|
||||||
|
char *Attr;
|
||||||
|
|
||||||
|
if (fmt)
|
||||||
|
{
|
||||||
|
if (fmt[0])
|
||||||
|
{
|
||||||
|
va_start (ap,fmt);
|
||||||
|
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||||
|
va_end (ap);
|
||||||
|
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||||
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
|
/***** Print HTML *****/
|
||||||
|
HTM_TxtF ("<tbody %s>",Attr);
|
||||||
|
|
||||||
|
free (Attr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
HTM_TBODY_BeginWithoutAttr ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
HTM_TBODY_BeginWithoutAttr ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void HTM_TBODY_BeginWithoutAttr (void)
|
||||||
|
{
|
||||||
|
HTM_Txt ("<tbody>");
|
||||||
|
}
|
||||||
|
|
||||||
|
void HTM_TBODY_End (void)
|
||||||
|
{
|
||||||
|
HTM_Txt ("</tbody>");
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/**************************** Start/end table row ****************************/
|
/**************************** Start/end table row ****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -58,6 +58,9 @@ void HTM_TABLE_BeginWideMarginPadding (unsigned CellPadding);
|
||||||
void HTM_TABLE_BeginWideMargin (void);
|
void HTM_TABLE_BeginWideMargin (void);
|
||||||
void HTM_TABLE_End (void);
|
void HTM_TABLE_End (void);
|
||||||
|
|
||||||
|
void HTM_TBODY_Begin (const char *fmt,...);
|
||||||
|
void HTM_TBODY_End (void);
|
||||||
|
|
||||||
void HTM_TR_Begin (const char *fmt,...);
|
void HTM_TR_Begin (const char *fmt,...);
|
||||||
void HTM_TR_End (void);
|
void HTM_TR_End (void);
|
||||||
|
|
||||||
|
|
|
@ -497,7 +497,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
|
||||||
En OpenSWAD:
|
En OpenSWAD:
|
||||||
ps2pdf source.ps destination.pdf
|
ps2pdf source.ps destination.pdf
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 19.141.7 (2020-03-04)"
|
#define Log_PLATFORM_VERSION "SWAD 19.142 (2020-03-04)"
|
||||||
#define CSS_FILE "swad19.141.6.css"
|
#define CSS_FILE "swad19.141.6.css"
|
||||||
#define JS_FILE "swad19.91.1.js"
|
#define JS_FILE "swad19.91.1.js"
|
||||||
/*
|
/*
|
||||||
|
@ -525,7 +525,9 @@ Param
|
||||||
// TODO: Si el alumno ha marcado "Permitir que los profesores...", entonces pedir confirmación al pulsar el botón azul, para evitar que se envíe por error antes de tiempo
|
// TODO: Si el alumno ha marcado "Permitir que los profesores...", entonces pedir confirmación al pulsar el botón azul, para evitar que se envíe por error antes de tiempo
|
||||||
// TODO: Oresti Baños: cambiar ojos por candados en descriptores para prohibir/permitir y dejar los ojos para poder elegir descriptores
|
// TODO: Oresti Baños: cambiar ojos por candados en descriptores para prohibir/permitir y dejar los ojos para poder elegir descriptores
|
||||||
// TODO: Hide/show items should hide/show subtrees
|
// TODO: Hide/show items should hide/show subtrees
|
||||||
|
// TODO: When creating/changing a item ==> highlight only that item ==> pass subtree to Prg_ShowAllItems
|
||||||
|
|
||||||
|
Version 19.142: Mar 04, 2020 Highlighted subtree of course program. (282277 lines)
|
||||||
Version 19.141.7: Mar 04, 2020 Create item at the end of course program. (282202 lines)
|
Version 19.141.7: Mar 04, 2020 Create item at the end of course program. (282202 lines)
|
||||||
Version 19.141.6: Mar 04, 2020 Changes in edition of course program. (282230 lines)
|
Version 19.141.6: Mar 04, 2020 Changes in edition of course program. (282230 lines)
|
||||||
Version 19.141.5: Mar 03, 2020 Fixed bug in edition of course program. (282224 lines)
|
Version 19.141.5: Mar 03, 2020 Fixed bug in edition of course program. (282224 lines)
|
||||||
|
|
174
swad_program.c
174
swad_program.c
|
@ -67,6 +67,12 @@ typedef enum
|
||||||
Prg_PUT_FORM_CHANGE_ITEM,
|
Prg_PUT_FORM_CHANGE_ITEM,
|
||||||
} Prg_CreateOrChangeItem_t;
|
} Prg_CreateOrChangeItem_t;
|
||||||
|
|
||||||
|
struct Subtree
|
||||||
|
{
|
||||||
|
unsigned Begin;
|
||||||
|
unsigned End;
|
||||||
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************************** Private variables *****************************/
|
/***************************** Private variables *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -89,7 +95,7 @@ static void Prg_PutIconsListItems (void);
|
||||||
static void Prg_PutIconToCreateNewItem (void);
|
static void Prg_PutIconToCreateNewItem (void);
|
||||||
static void Prg_PutButtonToCreateNewItem (void);
|
static void Prg_PutButtonToCreateNewItem (void);
|
||||||
static void Prg_ShowOneItem (unsigned NumItem,const struct ProgramItem *Item,
|
static void Prg_ShowOneItem (unsigned NumItem,const struct ProgramItem *Item,
|
||||||
long HighlightItmCod,bool PrintView);
|
const struct Subtree *ToHighlight,bool PrintView);
|
||||||
static void Prg_ShowItemForm (Prg_CreateOrChangeItem_t CreateOrChangeItem,
|
static void Prg_ShowItemForm (Prg_CreateOrChangeItem_t CreateOrChangeItem,
|
||||||
long ParamItmCod,unsigned FormLevel);
|
long ParamItmCod,unsigned FormLevel);
|
||||||
|
|
||||||
|
@ -122,8 +128,9 @@ static void Prg_GetPrgItemTxtFromDB (long ItmCod,char Txt[Cns_MAX_BYTES_TEXT + 1
|
||||||
static void Prg_PutParamItmCod (long ItmCod);
|
static void Prg_PutParamItmCod (long ItmCod);
|
||||||
static long Prg_GetParamItmCod (void);
|
static long Prg_GetParamItmCod (void);
|
||||||
|
|
||||||
static unsigned Prg_GetNumItemFromItmCod (unsigned ItmCod);
|
static unsigned Prg_GetNumItemFromItmCod (long ItmCod);
|
||||||
|
|
||||||
|
static void Prg_GetSubtree (unsigned NumItem,struct Subtree *Subtree);
|
||||||
static unsigned Prg_GetMaxItemLevel (void);
|
static unsigned Prg_GetMaxItemLevel (void);
|
||||||
static int Prg_GetPrevBrother (int NumItem);
|
static int Prg_GetPrevBrother (int NumItem);
|
||||||
static int Prg_GetNextBrother (int NumItem);
|
static int Prg_GetNextBrother (int NumItem);
|
||||||
|
@ -170,6 +177,7 @@ static void Prg_ShowAllItems (Prg_CreateOrChangeItem_t CreateOrChangeItem,
|
||||||
{
|
{
|
||||||
extern const char *Hlp_COURSE_Program;
|
extern const char *Hlp_COURSE_Program;
|
||||||
extern const char *Txt_Course_program;
|
extern const char *Txt_Course_program;
|
||||||
|
struct Subtree ToHighlight;
|
||||||
unsigned NumItem;
|
unsigned NumItem;
|
||||||
struct ProgramItem Item;
|
struct ProgramItem Item;
|
||||||
|
|
||||||
|
@ -178,6 +186,19 @@ static void Prg_ShowAllItems (Prg_CreateOrChangeItem_t CreateOrChangeItem,
|
||||||
Prg_MaxLevel = Prg_GetMaxItemLevel ();
|
Prg_MaxLevel = Prg_GetMaxItemLevel ();
|
||||||
Prg_CreateNumbers (Prg_MaxLevel);
|
Prg_CreateNumbers (Prg_MaxLevel);
|
||||||
|
|
||||||
|
/***** Calculate which items must be highlighted *****/
|
||||||
|
if (HighlightItmCod > 0) // Item(s) must be highlighted
|
||||||
|
{
|
||||||
|
/* Highlight subtree */
|
||||||
|
NumItem = Prg_GetNumItemFromItmCod (HighlightItmCod);
|
||||||
|
Prg_GetSubtree (NumItem,&ToHighlight);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ToHighlight.Begin =
|
||||||
|
ToHighlight.End = Gbl.Prg.Num; // Don't highlight any item
|
||||||
|
}
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
Box_BoxBegin ("100%",Txt_Course_program,Prg_PutIconsListItems,
|
Box_BoxBegin ("100%",Txt_Course_program,Prg_PutIconsListItems,
|
||||||
Hlp_COURSE_Program,Box_NOT_CLOSABLE);
|
Hlp_COURSE_Program,Box_NOT_CLOSABLE);
|
||||||
|
@ -196,7 +217,7 @@ static void Prg_ShowAllItems (Prg_CreateOrChangeItem_t CreateOrChangeItem,
|
||||||
|
|
||||||
/* Show item */
|
/* Show item */
|
||||||
Prg_ShowOneItem (NumItem,&Item,
|
Prg_ShowOneItem (NumItem,&Item,
|
||||||
HighlightItmCod,
|
&ToHighlight,
|
||||||
false); // Not print view
|
false); // Not print view
|
||||||
|
|
||||||
/* Show form to create/change item */
|
/* Show form to create/change item */
|
||||||
|
@ -296,9 +317,10 @@ static void Prg_PutButtonToCreateNewItem (void)
|
||||||
#define Prg_WIDTH_NUM_ITEM 20
|
#define Prg_WIDTH_NUM_ITEM 20
|
||||||
|
|
||||||
static void Prg_ShowOneItem (unsigned NumItem,const struct ProgramItem *Item,
|
static void Prg_ShowOneItem (unsigned NumItem,const struct ProgramItem *Item,
|
||||||
long HighlightItmCod,bool PrintView)
|
const struct Subtree *ToHighlight,bool PrintView)
|
||||||
{
|
{
|
||||||
static unsigned UniqueId = 0;
|
static unsigned UniqueId = 0;
|
||||||
|
static bool FirstTBodyOpen = false;
|
||||||
char *Id;
|
char *Id;
|
||||||
unsigned ColSpan;
|
unsigned ColSpan;
|
||||||
unsigned NumCol;
|
unsigned NumCol;
|
||||||
|
@ -308,11 +330,27 @@ static void Prg_ShowOneItem (unsigned NumItem,const struct ProgramItem *Item,
|
||||||
/***** Increase number of item *****/
|
/***** Increase number of item *****/
|
||||||
Prg_IncreaseNumItem (Item->Hierarchy.Level);
|
Prg_IncreaseNumItem (Item->Hierarchy.Level);
|
||||||
|
|
||||||
|
/***** In general, the table is divided into three bodys:
|
||||||
|
1. Rows before highlighted: <tbody></tbody>
|
||||||
|
2. Rows highlighted: <tbody id="highlighted_item"></tbody>
|
||||||
|
3. Rows after highlighted: <tbody></tbody> */
|
||||||
|
if (Item->Hierarchy.Index == ToHighlight->Begin) // Begin of the highlighted subtree
|
||||||
|
{
|
||||||
|
if (FirstTBodyOpen)
|
||||||
|
{
|
||||||
|
HTM_TBODY_End (); // 1st tbody end
|
||||||
|
FirstTBodyOpen = false;
|
||||||
|
}
|
||||||
|
HTM_TBODY_Begin ("id=\"highlighted_item\" class=\"PRG_HIGHLIGHTED_ITEM\""); // Highlighted tbody start
|
||||||
|
}
|
||||||
|
else if (NumItem == 0) // First item
|
||||||
|
{
|
||||||
|
HTM_TBODY_Begin (NULL); // 1st tbody start
|
||||||
|
FirstTBodyOpen = true;
|
||||||
|
}
|
||||||
|
|
||||||
/***** Start row *****/
|
/***** Start row *****/
|
||||||
if (Item->Hierarchy.ItmCod == HighlightItmCod)
|
HTM_TR_Begin (NULL);
|
||||||
HTM_TR_Begin ("class=\"PRG_HIGHLIGHTED_ITEM\"");
|
|
||||||
else
|
|
||||||
HTM_TR_Begin (NULL);
|
|
||||||
|
|
||||||
/***** Forms to remove/edit this program item *****/
|
/***** Forms to remove/edit this program item *****/
|
||||||
if (!PrintView)
|
if (!PrintView)
|
||||||
|
@ -349,8 +387,6 @@ static void Prg_ShowOneItem (unsigned NumItem,const struct ProgramItem *Item,
|
||||||
else
|
else
|
||||||
HTM_TD_Begin ("colspan=\"%u\" class=\"LT COLOR%u\"",
|
HTM_TD_Begin ("colspan=\"%u\" class=\"LT COLOR%u\"",
|
||||||
ColSpan,Gbl.RowEvenOdd);
|
ColSpan,Gbl.RowEvenOdd);
|
||||||
if (Item->Hierarchy.ItmCod == HighlightItmCod)
|
|
||||||
HTM_SECTION_Begin ("highlighted_item");
|
|
||||||
|
|
||||||
/* Title */
|
/* Title */
|
||||||
HTM_DIV_Begin ("class=\"%s\"",
|
HTM_DIV_Begin ("class=\"%s\"",
|
||||||
|
@ -370,8 +406,6 @@ static void Prg_ShowOneItem (unsigned NumItem,const struct ProgramItem *Item,
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
|
|
||||||
/* End title and text */
|
/* End title and text */
|
||||||
if (Item->Hierarchy.ItmCod == HighlightItmCod)
|
|
||||||
HTM_SECTION_End ();
|
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Start/end date/time *****/
|
/***** Start/end date/time *****/
|
||||||
|
@ -407,6 +441,16 @@ static void Prg_ShowOneItem (unsigned NumItem,const struct ProgramItem *Item,
|
||||||
|
|
||||||
/***** End row *****/
|
/***** End row *****/
|
||||||
HTM_TR_End ();
|
HTM_TR_End ();
|
||||||
|
|
||||||
|
/***** End tbodies *****/
|
||||||
|
if (Item->Hierarchy.Index == ToHighlight->End) // End of the highlighted subtree
|
||||||
|
{
|
||||||
|
HTM_TBODY_End (); // Highlighted tbody end
|
||||||
|
if (NumItem < Gbl.Prg.Num - 1) // Not the last item
|
||||||
|
HTM_TBODY_Begin (NULL); // 3rd tbody begin
|
||||||
|
}
|
||||||
|
else if (NumItem == Gbl.Prg.Num - 1) // Last item
|
||||||
|
HTM_TBODY_End (); // 3rd tbody end
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1037,7 +1081,7 @@ static long Prg_GetParamItmCod (void)
|
||||||
/**************** Get number of item in list from item code ******************/
|
/**************** Get number of item in list from item code ******************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static unsigned Prg_GetNumItemFromItmCod (unsigned ItmCod)
|
static unsigned Prg_GetNumItemFromItmCod (long ItmCod)
|
||||||
{
|
{
|
||||||
unsigned NumItem;
|
unsigned NumItem;
|
||||||
|
|
||||||
|
@ -1088,8 +1132,7 @@ void Prg_RemovePrgItem (void)
|
||||||
extern const char *Txt_Item_X_removed;
|
extern const char *Txt_Item_X_removed;
|
||||||
struct ProgramItem Item;
|
struct ProgramItem Item;
|
||||||
unsigned NumItem;
|
unsigned NumItem;
|
||||||
unsigned BeginIndex;
|
struct Subtree ToRemove;
|
||||||
unsigned EndIndex;
|
|
||||||
|
|
||||||
/***** Get program item code *****/
|
/***** Get program item code *****/
|
||||||
if ((Item.Hierarchy.ItmCod = Prg_GetParamItmCod ()) == -1L)
|
if ((Item.Hierarchy.ItmCod = Prg_GetParamItmCod ()) == -1L)
|
||||||
|
@ -1103,8 +1146,7 @@ void Prg_RemovePrgItem (void)
|
||||||
NumItem = Prg_GetNumItemFromItmCod (Item.Hierarchy.ItmCod);
|
NumItem = Prg_GetNumItemFromItmCod (Item.Hierarchy.ItmCod);
|
||||||
|
|
||||||
/***** Indexes of items *****/
|
/***** Indexes of items *****/
|
||||||
BeginIndex = Gbl.Prg.LstItems[NumItem].Index;
|
Prg_GetSubtree (NumItem,&ToRemove);
|
||||||
EndIndex = Gbl.Prg.LstItems[Prg_GetLastChild (NumItem)].Index;
|
|
||||||
|
|
||||||
/***** Remove program items *****/
|
/***** Remove program items *****/
|
||||||
DB_QueryDELETE ("can not remove program item",
|
DB_QueryDELETE ("can not remove program item",
|
||||||
|
@ -1112,7 +1154,7 @@ void Prg_RemovePrgItem (void)
|
||||||
" WHERE CrsCod=%ld AND"
|
" WHERE CrsCod=%ld AND"
|
||||||
" ItmInd>=%u AND ItmInd<=%u",
|
" ItmInd>=%u AND ItmInd<=%u",
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
BeginIndex,EndIndex);
|
ToRemove.Begin,ToRemove.End);
|
||||||
|
|
||||||
/***** Write message to show the change made *****/
|
/***** Write message to show the change made *****/
|
||||||
Ale_ShowAlert (Ale_SUCCESS,Txt_Item_X_removed,Item.Title);
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Item_X_removed,Item.Title);
|
||||||
|
@ -1296,6 +1338,25 @@ void Prg_MoveRightPrgItem (void)
|
||||||
Prg_ShowCourseProgramHighlightingItem (ItmCod);
|
Prg_ShowCourseProgramHighlightingItem (ItmCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/****** Get subtree begin and end from number of item in course program ******/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void Prg_GetSubtree (unsigned NumItem,struct Subtree *Subtree)
|
||||||
|
{
|
||||||
|
/***** List of items must be filled *****/
|
||||||
|
if (!Gbl.Prg.LstIsRead || Gbl.Prg.LstItems == NULL)
|
||||||
|
Lay_ShowErrorAndExit ("Wrong list of items.");
|
||||||
|
|
||||||
|
/***** Number of item must be in the correct range *****/
|
||||||
|
if (NumItem >= Gbl.Prg.Num)
|
||||||
|
Lay_ShowErrorAndExit ("Wrong item number.");
|
||||||
|
|
||||||
|
/***** Compute range *****/
|
||||||
|
Subtree->Begin = Gbl.Prg.LstItems[NumItem ].Index;
|
||||||
|
Subtree->End = Gbl.Prg.LstItems[Prg_GetLastChild (NumItem)].Index;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************* Get maximum level in a course program *******************/
|
/******************* Get maximum level in a course program *******************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1411,14 +1472,12 @@ static unsigned Prg_GetLastChild (int NumItem)
|
||||||
static void Prg_MoveItemAndChildrenLeft (unsigned NumItem)
|
static void Prg_MoveItemAndChildrenLeft (unsigned NumItem)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Movement_not_allowed;
|
extern const char *Txt_Movement_not_allowed;
|
||||||
unsigned BeginIndex;
|
struct Subtree ToMoveLeft;
|
||||||
unsigned EndIndex;
|
|
||||||
|
|
||||||
if (Prg_CheckIfMoveLeftIsAllowed (NumItem))
|
if (Prg_CheckIfMoveLeftIsAllowed (NumItem))
|
||||||
{
|
{
|
||||||
/* Indexes of items */
|
/* Indexes of items */
|
||||||
BeginIndex = Gbl.Prg.LstItems[NumItem].Index;
|
Prg_GetSubtree (NumItem,&ToMoveLeft);
|
||||||
EndIndex = Gbl.Prg.LstItems[Prg_GetLastChild (NumItem)].Index;
|
|
||||||
|
|
||||||
/* Move item and its children to left or right */
|
/* Move item and its children to left or right */
|
||||||
DB_QueryUPDATE ("can not move items",
|
DB_QueryUPDATE ("can not move items",
|
||||||
|
@ -1426,7 +1485,7 @@ static void Prg_MoveItemAndChildrenLeft (unsigned NumItem)
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" AND ItmInd>=%u AND ItmInd<=%u",
|
" AND ItmInd>=%u AND ItmInd<=%u",
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
BeginIndex,EndIndex);
|
ToMoveLeft.Begin,ToMoveLeft.End);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Ale_ShowAlert (Ale_WARNING,Txt_Movement_not_allowed);
|
Ale_ShowAlert (Ale_WARNING,Txt_Movement_not_allowed);
|
||||||
|
@ -1439,14 +1498,12 @@ static void Prg_MoveItemAndChildrenLeft (unsigned NumItem)
|
||||||
static void Prg_MoveItemAndChildrenRight (unsigned NumItem)
|
static void Prg_MoveItemAndChildrenRight (unsigned NumItem)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Movement_not_allowed;
|
extern const char *Txt_Movement_not_allowed;
|
||||||
unsigned BeginIndex;
|
struct Subtree ToMoveRight;
|
||||||
unsigned EndIndex;
|
|
||||||
|
|
||||||
if (Prg_CheckIfMoveRightIsAllowed (NumItem))
|
if (Prg_CheckIfMoveRightIsAllowed (NumItem))
|
||||||
{
|
{
|
||||||
/* Indexes of items */
|
/* Indexes of items */
|
||||||
BeginIndex = Gbl.Prg.LstItems[NumItem].Index;
|
Prg_GetSubtree (NumItem,&ToMoveRight);
|
||||||
EndIndex = Gbl.Prg.LstItems[Prg_GetLastChild (NumItem)].Index;
|
|
||||||
|
|
||||||
/* Move item and its children to left or right */
|
/* Move item and its children to left or right */
|
||||||
DB_QueryUPDATE ("can not move items",
|
DB_QueryUPDATE ("can not move items",
|
||||||
|
@ -1454,7 +1511,7 @@ static void Prg_MoveItemAndChildrenRight (unsigned NumItem)
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" AND ItmInd>=%u AND ItmInd<=%u",
|
" AND ItmInd>=%u AND ItmInd<=%u",
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
BeginIndex,EndIndex);
|
ToMoveRight.Begin,ToMoveRight.End);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Ale_ShowAlert (Ale_WARNING,Txt_Movement_not_allowed);
|
Ale_ShowAlert (Ale_WARNING,Txt_Movement_not_allowed);
|
||||||
|
@ -1467,31 +1524,18 @@ static void Prg_MoveItemAndChildrenRight (unsigned NumItem)
|
||||||
static void Prg_ExchangeItems (int NumItemTop,int NumItemBottom)
|
static void Prg_ExchangeItems (int NumItemTop,int NumItemBottom)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Movement_not_allowed;
|
extern const char *Txt_Movement_not_allowed;
|
||||||
struct
|
struct Subtree Top;
|
||||||
{
|
struct Subtree Bottom;
|
||||||
unsigned Begin;
|
unsigned DiffBegin;
|
||||||
unsigned End;
|
unsigned DiffEnd;
|
||||||
} TopIndex, BottomIndex, Diff;
|
|
||||||
|
|
||||||
if (NumItemTop >= 0 &&
|
if (NumItemTop >= 0 &&
|
||||||
NumItemBottom >= 0)
|
NumItemBottom >= 0)
|
||||||
{
|
{
|
||||||
TopIndex.Begin = Gbl.Prg.LstItems[NumItemTop ].Index;
|
Prg_GetSubtree (NumItemTop ,&Top );
|
||||||
TopIndex.End = Gbl.Prg.LstItems[Prg_GetLastChild (NumItemTop )].Index;
|
Prg_GetSubtree (NumItemBottom,&Bottom);
|
||||||
BottomIndex.Begin = Gbl.Prg.LstItems[NumItemBottom ].Index;
|
DiffBegin = Bottom.Begin - Top.Begin;
|
||||||
BottomIndex.End = Gbl.Prg.LstItems[Prg_GetLastChild (NumItemBottom)].Index;
|
DiffEnd = Bottom.End - Top.End;
|
||||||
Diff.Begin = BottomIndex.Begin - TopIndex.Begin;
|
|
||||||
Diff.End = BottomIndex.End - TopIndex.End;
|
|
||||||
|
|
||||||
Ale_ShowAlert (Ale_INFO,"TopIndex.Begin = %u<br />"
|
|
||||||
"TopIndex.End = %u<br />"
|
|
||||||
"BottomIndex.Begin = %u<br />"
|
|
||||||
"BottomIndex.End = %u",
|
|
||||||
TopIndex.Begin,
|
|
||||||
TopIndex.End,
|
|
||||||
BottomIndex.Begin,
|
|
||||||
BottomIndex.End);
|
|
||||||
|
|
||||||
|
|
||||||
/***** Lock table to make the move atomic *****/
|
/***** Lock table to make the move atomic *****/
|
||||||
DB_Query ("can not lock tables to move program item",
|
DB_Query ("can not lock tables to move program item",
|
||||||
|
@ -1503,24 +1547,24 @@ static void Prg_ExchangeItems (int NumItemTop,int NumItemBottom)
|
||||||
// ...this implementation works even with non continuous indexes
|
// ...this implementation works even with non continuous indexes
|
||||||
/*
|
/*
|
||||||
Example:
|
Example:
|
||||||
TopIndex.Begin = 5
|
Top.Begin = 5
|
||||||
= 10
|
= 10
|
||||||
TopIndex.End = 17
|
Top.End = 17
|
||||||
BottomIndex.Begin = 28
|
Bottom.Begin = 28
|
||||||
BottomIndex.End = 49
|
Bottom.End = 49
|
||||||
|
|
||||||
Diff.Begin = 28 - 5 = 23;
|
DiffBegin = 28 - 5 = 23;
|
||||||
Diff.End = 49 - 17 = 32;
|
DiffEnd = 49 - 17 = 32;
|
||||||
|
|
||||||
Step 1 Step 2 Step 3 (Equivalent to)
|
Step 1 Step 2 Step 3 (Equivalent to)
|
||||||
+------+------+ +------+------+ +------+------+ +------+------+ +------+------+
|
+------+------+ +------+------+ +------+------+ +------+------+ +------+------+
|
||||||
|ItmInd|ItmCod| |ItmInd|ItmCod| |ItmInd|ItmCod| |ItmInd|ItmCod| |ItmInd|ItmCod|
|
|ItmInd|ItmCod| |ItmInd|ItmCod| |ItmInd|ItmCod| |ItmInd|ItmCod| |ItmInd|ItmCod|
|
||||||
+------+------+ +------+------+ +------+------+ +------+------+ +------+------+
|
+------+------+ +------+------+ +------+------+ +------+------+ +------+------+
|
||||||
TopIndex.Begin: 5| 218|-->|--> -5| 218|-->|--> 37| 218| | 37| 218| | 5| 221|
|
Top.Begin: | 5| 218|-->|--> -5| 218|-->|--> 37| 218| | 37| 218| | 5| 221|
|
||||||
| 10| 219|-->|-->-10| 219|-->|--> 42| 219| | 42| 219| | 26| 222|
|
| 10| 219|-->|-->-10| 219|-->|--> 42| 219| | 42| 219| | 26| 222|
|
||||||
TopIndex.End: | 17| 220|-->|-->-17| 220|-->|--> 49| 220| | 49| 220| | 37| 218|
|
Top.End: | 17| 220|-->|-->-17| 220|-->|--> 49| 220| | 49| 220| | 37| 218|
|
||||||
BottomIndex.Begin: 28| 221|-->|-->-28| 221| | -28| 221|-->|--> 5| 221| | 42| 219|
|
Bottom.Begin: | 28| 221|-->|-->-28| 221| | -28| 221|-->|--> 5| 221| | 42| 219|
|
||||||
BottomIndex.End: 49| 222|-->|-->-49| 222| | -49| 222|-->|--> 26| 222| | 49| 220|
|
Bottom.End: | 49| 222|-->|-->-49| 222| | -49| 222|-->|--> 26| 222| | 49| 220|
|
||||||
+------+------+ +------+------+ +------+------+ +------+------+ +------+------+
|
+------+------+ +------+------+ +------+------+ +------+------+ +------+------+
|
||||||
*/
|
*/
|
||||||
/* Step 1: Change all indexes involved to negative,
|
/* Step 1: Change all indexes involved to negative,
|
||||||
|
@ -1530,25 +1574,25 @@ BottomIndex.End: 49| 222|-->|-->-49| 222| | -49| 222|-->|--> 26| 2
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" AND ItmInd>=%u AND ItmInd<=%u",
|
" AND ItmInd>=%u AND ItmInd<=%u",
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
TopIndex.Begin,BottomIndex.End);
|
Top.Begin,Bottom.End); // All indexes in both parts
|
||||||
|
|
||||||
/* Step 2: Increase top indexes */
|
/* Step 2: Increase top indexes */
|
||||||
DB_QueryUPDATE ("can not exchange indexes of items",
|
DB_QueryUPDATE ("can not exchange indexes of items",
|
||||||
"UPDATE prg_items SET ItmInd=-ItmInd+%u"
|
"UPDATE prg_items SET ItmInd=-ItmInd+%u"
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" AND ItmInd>=-%u AND ItmInd<=-%u",
|
" AND ItmInd>=-%u AND ItmInd<=-%u",
|
||||||
Diff.End,
|
DiffEnd,
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
TopIndex.End,TopIndex.Begin); // All indexes in top part
|
Top.End,Top.Begin); // All indexes in top part
|
||||||
|
|
||||||
/* Step 3: Decrease bottom indexes */
|
/* Step 3: Decrease bottom indexes */
|
||||||
DB_QueryUPDATE ("can not exchange indexes of items",
|
DB_QueryUPDATE ("can not exchange indexes of items",
|
||||||
"UPDATE prg_items SET ItmInd=-ItmInd-%u"
|
"UPDATE prg_items SET ItmInd=-ItmInd-%u"
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" AND ItmInd>=-%u AND ItmInd<=-%u",
|
" AND ItmInd>=-%u AND ItmInd<=-%u",
|
||||||
Diff.Begin,
|
DiffBegin,
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
BottomIndex.End,BottomIndex.Begin); // All indexes in bottom part
|
Bottom.End,Bottom.Begin); // All indexes in bottom part
|
||||||
|
|
||||||
/***** Unlock table *****/
|
/***** Unlock table *****/
|
||||||
Gbl.DB.LockedTables = false; // Set to false before the following unlock...
|
Gbl.DB.LockedTables = false; // Set to false before the following unlock...
|
||||||
|
|
Loading…
Reference in New Issue