mirror of https://github.com/acanas/swad-core.git
Version 22.6: Sep 17, 2022 Changes in edition of program items.
This commit is contained in:
parent
adb3e3179a
commit
4bc73f6552
|
@ -5336,7 +5336,9 @@ void Brw_WriteFileNameInCrsProgram (long FilCod,bool PutFormToDownload)
|
|||
{
|
||||
Frm_BeginForm (Brw_ActDowFile[Brw_SHOW_DOC_CRS]);
|
||||
Brw_PutImplicitParamsFileBrowser (&FileMetadata.FilFolLnk);
|
||||
HTM_BUTTON_Submit_Begin (Txt_Download,"class=\"LM BT_LINK PRG_RSC_%s\"",The_GetSuffix ());
|
||||
HTM_BUTTON_Submit_Begin (Txt_Download,
|
||||
"class=\"LM BT_LINK PRG_RSC_%s\"",
|
||||
The_GetSuffix ());
|
||||
}
|
||||
|
||||
/***** Write filename *****/
|
||||
|
@ -9146,22 +9148,22 @@ void Brw_GetFileMetadataByCod (struct FileMetadata *FileMetadata)
|
|||
/*****************************************************************************/
|
||||
/******************** Get summary and content of a file **********************/
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
void Brw_GetFileNameFromFilCod (long FilCod,char FileName[NAME_MAX + 1])
|
||||
|
||||
void Brw_GetFileNameFromFilCod (long FilCod,char *FileName,size_t FileNameSize)
|
||||
{
|
||||
struct FileMetadata FileMetadata;
|
||||
|
||||
***** Return nothing on error *****
|
||||
/***** Return nothing on error *****/
|
||||
FileName[0] = '\0'; // Return nothing on error
|
||||
|
||||
***** Get file metadata *****
|
||||
/***** Get file metadata *****/
|
||||
FileMetadata.FilCod = FilCod;
|
||||
Brw_GetFileMetadataByCod (&FileMetadata);
|
||||
|
||||
***** Copy file name into summary string *****
|
||||
Str_Copy (FileName,FileMetadata.FilFolLnk.Name,NAME_MAX);
|
||||
/***** Copy file name into summary string *****/
|
||||
Str_Copy (FileName,FileMetadata.FilFolLnk.Name,FileNameSize);
|
||||
}
|
||||
*/
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Get file type, size and date *************************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -233,7 +233,7 @@ void Brw_GetLinkToDownloadFile (const char *PathInTree,const char *FileName,char
|
|||
void Brw_ChgFileMetadata (void);
|
||||
void Brw_GetFileMetadataByPath (struct FileMetadata *FileMetadata);
|
||||
void Brw_GetFileMetadataByCod (struct FileMetadata *FileMetadata);
|
||||
// void Brw_GetFileNameFromFilCod (long FilCod,char FileName[NAME_MAX + 1]);
|
||||
void Brw_GetFileNameFromFilCod (long FilCod,char *FileName,size_t FileNameSize);
|
||||
bool Brw_GetFileTypeSizeAndDate (struct FileMetadata *FileMetadata);
|
||||
void Brw_GetAndUpdateFileViews (struct FileMetadata *FileMetadata);
|
||||
void Brw_UpdateMyFileViews (long FilCod);
|
||||
|
|
|
@ -606,10 +606,11 @@ TODO: Fix bug: error al enviar un mensaje a dos recipientes, error on duplicate
|
|||
|
||||
TODO: Attach pdf files in multimedia.
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 22.5 (2022-09-16)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 22.6 (2022-09-17)"
|
||||
#define CSS_FILE "swad22.5.css"
|
||||
#define JS_FILE "swad21.100.js"
|
||||
/*
|
||||
Version 22.6: Sep 17, 2022 Changes in edition of program items. (330065 lines)
|
||||
Version 22.5: Sep 16, 2022 Link to download document in program. (330018 lines)
|
||||
Version 22.4.2: Sep 16, 2022 Changes in edition of program items. (329982 lines)
|
||||
Version 22.4.1: Sep 15, 2022 Changes in edition of program items. (329955 lines)
|
||||
|
|
|
@ -130,7 +130,7 @@ typedef enum
|
|||
Prg_RECEIVE_ITEM, // Receive item data after create/edit
|
||||
|
||||
Prg_EDIT_RESOURCES, // List resources of a selected item for edition
|
||||
Prg_SHOW_CLIPBOARD, // Show clipboard in a resource to select a link
|
||||
Prg_EDIT_RESOURCE_LINK, // Show clipboard in a resource to select a link
|
||||
Prg_CHANGE_RESOURCE_LINK, // Change resource link
|
||||
Prg_END_EDIT_RES, // List resources of a selected item after edition
|
||||
} Prg_ListingType_t;
|
||||
|
|
|
@ -656,16 +656,16 @@ void Prg_DB_UpdateRscInd (long RscCod,int RscInd)
|
|||
/************* Update the link of a resource given its code *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Prg_DB_UpdateRscLink (long RscCod,PrgRsc_Type_t Type,long Cod)
|
||||
void Prg_DB_UpdateRscLink (const struct Prg_Item *Item)
|
||||
{
|
||||
DB_QueryUPDATE ("can not update link of resource",
|
||||
"UPDATE prg_resources"
|
||||
" SET Type='%s',"
|
||||
"Cod=%ld"
|
||||
" WHERE RscCod=%ld",
|
||||
Prg_ResourceTypesDB[Type],
|
||||
Cod,
|
||||
RscCod);
|
||||
Prg_ResourceTypesDB[Item->Resource.Link.Type],
|
||||
Item->Resource.Link.Cod,
|
||||
Item->Resource.Hierarchy.RscCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -707,7 +707,7 @@ unsigned Prg_DB_GetClipboard (MYSQL_RES **mysql_res)
|
|||
/*************************** Remove link from clipboard **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Prg_DB_RemoveLinkFromClipboard (PrgRsc_Type_t Type,long Cod)
|
||||
void Prg_DB_RemoveLinkFromClipboard (struct Prg_Link *Link)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove link from clipboard",
|
||||
"DELETE FROM prg_clipboards"
|
||||
|
@ -717,6 +717,6 @@ void Prg_DB_RemoveLinkFromClipboard (PrgRsc_Type_t Type,long Cod)
|
|||
" AND Cod=%ld",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Prg_ResourceTypesDB[Type],
|
||||
Cod);
|
||||
Prg_ResourceTypesDB[Link->Type],
|
||||
Link->Cod);
|
||||
}
|
||||
|
|
|
@ -75,10 +75,10 @@ void Prg_DB_HideOrUnhideResource (long RscCod,bool Hide);
|
|||
|
||||
void Prg_DB_LockTableResources (void);
|
||||
void Prg_DB_UpdateRscInd (long RscCod,int RscInd);
|
||||
void Prg_DB_UpdateRscLink (long RscCod,PrgRsc_Type_t Type,long Cod);
|
||||
void Prg_DB_UpdateRscLink (const struct Prg_Item *Item);
|
||||
|
||||
void Prg_DB_CopyToClipboard (PrgRsc_Type_t Type,long Cod);
|
||||
unsigned Prg_DB_GetClipboard (MYSQL_RES **mysql_res);
|
||||
void Prg_DB_RemoveLinkFromClipboard (PrgRsc_Type_t Type,long Cod);
|
||||
void Prg_DB_RemoveLinkFromClipboard (struct Prg_Link *Link);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -94,14 +94,12 @@ static void PrgRsc_GetDataOfResource (struct Prg_Item *Item,
|
|||
MYSQL_RES **mysql_res);
|
||||
static void PrgRsc_WriteRowViewResource (unsigned NumRsc,
|
||||
const struct Prg_Item *Item);
|
||||
static void PrgRsc_WriteRowEditResource (Prg_ListingType_t ListingType,
|
||||
unsigned NumRsc,unsigned NumResources,
|
||||
static void PrgRsc_WriteRowEditResource (unsigned NumRsc,unsigned NumResources,
|
||||
struct Prg_Item *Item,
|
||||
long SelectedRscCod);
|
||||
static void PrgRsc_WriteRowNewResource (Prg_ListingType_t ListingType,
|
||||
unsigned NumResources,
|
||||
bool EditLink);
|
||||
static void PrgRsc_WriteRowNewResource (unsigned NumResources,
|
||||
struct Prg_Item *Item,
|
||||
long SelectedRscCod);
|
||||
bool EditLink);
|
||||
static void PrgRsc_PutFormsToRemEditOneResource (struct Prg_Item *Item,
|
||||
unsigned NumRsc,
|
||||
unsigned NumResources);
|
||||
|
@ -173,6 +171,7 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType,
|
|||
unsigned NumRsc;
|
||||
unsigned NumResources;
|
||||
struct Prg_Item Item;
|
||||
bool EditLink;
|
||||
static bool GetHiddenResources[Prg_NUM_LISTING_TYPES] =
|
||||
{
|
||||
[Prg_PRINT ] = false,
|
||||
|
@ -184,7 +183,7 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType,
|
|||
[Prg_END_EDIT_ITEM ] = false,
|
||||
[Prg_RECEIVE_ITEM ] = false,
|
||||
[Prg_EDIT_RESOURCES ] = true,
|
||||
[Prg_SHOW_CLIPBOARD ] = true,
|
||||
[Prg_EDIT_RESOURCE_LINK ] = true,
|
||||
[Prg_CHANGE_RESOURCE_LINK] = true,
|
||||
[Prg_END_EDIT_RES ] = false,
|
||||
};
|
||||
|
@ -199,7 +198,7 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType,
|
|||
[Prg_END_EDIT_ITEM ] = true,
|
||||
[Prg_RECEIVE_ITEM ] = true,
|
||||
[Prg_EDIT_RESOURCES ] = true,
|
||||
[Prg_SHOW_CLIPBOARD ] = true,
|
||||
[Prg_EDIT_RESOURCE_LINK ] = true,
|
||||
[Prg_CHANGE_RESOURCE_LINK] = true,
|
||||
[Prg_END_EDIT_RES ] = true,
|
||||
};
|
||||
|
@ -214,7 +213,7 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType,
|
|||
[Prg_END_EDIT_ITEM ] = false,
|
||||
[Prg_RECEIVE_ITEM ] = false,
|
||||
[Prg_EDIT_RESOURCES ] = true,
|
||||
[Prg_SHOW_CLIPBOARD ] = true,
|
||||
[Prg_EDIT_RESOURCE_LINK ] = true,
|
||||
[Prg_CHANGE_RESOURCE_LINK] = true,
|
||||
[Prg_END_EDIT_RES ] = true,
|
||||
};
|
||||
|
@ -229,7 +228,7 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType,
|
|||
[Prg_END_EDIT_ITEM ] = PrgRsc_PutIconsEditResources,
|
||||
[Prg_RECEIVE_ITEM ] = PrgRsc_PutIconsEditResources,
|
||||
[Prg_EDIT_RESOURCES ] = PrgRsc_PutIconsViewResources,
|
||||
[Prg_SHOW_CLIPBOARD ] = PrgRsc_PutIconsViewResources,
|
||||
[Prg_EDIT_RESOURCE_LINK ] = PrgRsc_PutIconsViewResources,
|
||||
[Prg_CHANGE_RESOURCE_LINK] = PrgRsc_PutIconsViewResources,
|
||||
[Prg_END_EDIT_RES ] = PrgRsc_PutIconsEditResources,
|
||||
};
|
||||
|
@ -284,11 +283,12 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType,
|
|||
switch (ListingType)
|
||||
{
|
||||
case Prg_EDIT_RESOURCES:
|
||||
case Prg_SHOW_CLIPBOARD:
|
||||
case Prg_EDIT_RESOURCE_LINK:
|
||||
case Prg_CHANGE_RESOURCE_LINK:
|
||||
PrgRsc_WriteRowEditResource (ListingType,
|
||||
NumRsc,NumResources,
|
||||
&Item,SelectedRscCod);
|
||||
EditLink = (ListingType == Prg_EDIT_RESOURCE_LINK &&
|
||||
Item.Resource.Hierarchy.RscCod == SelectedRscCod);
|
||||
PrgRsc_WriteRowEditResource (NumRsc,NumResources,&Item,
|
||||
EditLink);
|
||||
break;
|
||||
default:
|
||||
PrgRsc_WriteRowViewResource (NumRsc,&Item);
|
||||
|
@ -300,12 +300,13 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType,
|
|||
switch (ListingType)
|
||||
{
|
||||
case Prg_EDIT_RESOURCES:
|
||||
case Prg_SHOW_CLIPBOARD:
|
||||
case Prg_EDIT_RESOURCE_LINK:
|
||||
case Prg_CHANGE_RESOURCE_LINK:
|
||||
Prg_ResetItem (&Item);
|
||||
Item.Hierarchy.ItmCod = ItmCod;
|
||||
PrgRsc_WriteRowNewResource (ListingType,NumResources,
|
||||
&Item,SelectedRscCod);
|
||||
EditLink = (ListingType == Prg_EDIT_RESOURCE_LINK &&
|
||||
Item.Resource.Hierarchy.RscCod == SelectedRscCod);
|
||||
PrgRsc_WriteRowNewResource (NumResources,&Item,EditLink);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -451,10 +452,9 @@ static void PrgRsc_WriteRowViewResource (unsigned NumRsc,
|
|||
/************************** Edit one item resource ***************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void PrgRsc_WriteRowEditResource (Prg_ListingType_t ListingType,
|
||||
unsigned NumRsc,unsigned NumResources,
|
||||
static void PrgRsc_WriteRowEditResource (unsigned NumRsc,unsigned NumResources,
|
||||
struct Prg_Item *Item,
|
||||
long SelectedRscCod)
|
||||
bool EditLink)
|
||||
{
|
||||
extern const char *Prg_ResourceTypesDB[PrgRsc_NUM_TYPES];
|
||||
|
||||
|
@ -463,7 +463,7 @@ static void PrgRsc_WriteRowEditResource (Prg_ListingType_t ListingType,
|
|||
|
||||
/***** Forms to remove/edit this item resource *****/
|
||||
HTM_TD_Begin ("class=\"PRG_COL1 LT %s\"",The_GetColorRows1 (1));
|
||||
PrgRsc_PutFormsToRemEditOneResource (Item,NumRsc,NumResources);
|
||||
PrgRsc_PutFormsToRemEditOneResource (Item,NumRsc,NumResources);
|
||||
HTM_TD_End ();
|
||||
|
||||
/***** Resource number *****/
|
||||
|
@ -486,14 +486,13 @@ static void PrgRsc_WriteRowEditResource (Prg_ListingType_t ListingType,
|
|||
|
||||
HTM_BR ();
|
||||
|
||||
/* Link / clipboard */
|
||||
if (ListingType == Prg_SHOW_CLIPBOARD &&
|
||||
Item->Resource.Hierarchy.RscCod == SelectedRscCod)
|
||||
/* Edit link showing clipboard / Show current link */
|
||||
if (EditLink)
|
||||
/* Show clipboard to change resource link */
|
||||
PrgRsc_ShowClipboard (Item);
|
||||
else
|
||||
{
|
||||
/* Link */
|
||||
/* Show current link */
|
||||
Ico_PutIconOn (Prg_ResourceTypesLogos[Item->Resource.Link.Type],Ico_BLACK,
|
||||
Prg_ResourceTypesDB[Item->Resource.Link.Type]);
|
||||
PrgRsc_WriteLinkName (&Item->Resource.Link,
|
||||
|
@ -510,10 +509,9 @@ static void PrgRsc_WriteRowEditResource (Prg_ListingType_t ListingType,
|
|||
/************************* Edit a new item resource **************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void PrgRsc_WriteRowNewResource (Prg_ListingType_t ListingType,
|
||||
unsigned NumResources,
|
||||
static void PrgRsc_WriteRowNewResource (unsigned NumResources,
|
||||
struct Prg_Item *Item,
|
||||
long SelectedRscCod)
|
||||
bool EditLink)
|
||||
{
|
||||
extern const char *Prg_ResourceTypesDB[PrgRsc_NUM_TYPES];
|
||||
|
||||
|
@ -545,10 +543,8 @@ static void PrgRsc_WriteRowNewResource (Prg_ListingType_t ListingType,
|
|||
The_GetSuffix ());
|
||||
Frm_EndForm ();
|
||||
|
||||
|
||||
/* Link / clipboard */
|
||||
if (ListingType == Prg_SHOW_CLIPBOARD &&
|
||||
Item->Resource.Hierarchy.RscCod == SelectedRscCod)
|
||||
/* Edit link showing clipboard? */
|
||||
if (EditLink)
|
||||
{
|
||||
HTM_BR ();
|
||||
|
||||
|
@ -910,7 +906,7 @@ void PrgRsc_ShowClipboardToChgLink (void)
|
|||
Err_WrongResourceExit ();
|
||||
|
||||
/***** Show current program items, if any *****/
|
||||
Prg_ShowAllItems (Prg_SHOW_CLIPBOARD,Item.Hierarchy.ItmCod,Item.Resource.Hierarchy.RscCod);
|
||||
Prg_ShowAllItems (Prg_EDIT_RESOURCE_LINK,Item.Hierarchy.ItmCod,Item.Resource.Hierarchy.RscCod);
|
||||
|
||||
/***** Free list of program items *****/
|
||||
Prg_FreeListItems ();
|
||||
|
@ -934,7 +930,11 @@ static void PrgRsc_ShowClipboard (struct Prg_Item *Item)
|
|||
|
||||
/***** Begin form *****/
|
||||
Frm_BeginFormAnchor (ActChgLnkPrgRsc,PrgRsc_RESOURCE_SECTION_ID);
|
||||
Prg_PutParamRscCod (&Item->Resource.Hierarchy.RscCod);
|
||||
if (Item->Resource.Hierarchy.RscCod > 0)
|
||||
Prg_PutParamRscCod (&Item->Resource.Hierarchy.RscCod);
|
||||
else
|
||||
/* No resource selected, so it's a new resource at the end of the item */
|
||||
Prg_PutParamItmCod (&Item->Hierarchy.ItmCod);
|
||||
|
||||
/***** Begin list *****/
|
||||
HTM_UL_Begin ("class=\"PRG_CLIPBOARD\"");
|
||||
|
@ -1032,6 +1032,46 @@ static void PrgRsc_WriteLinkName (const struct Prg_Link *Link,bool PutForm)
|
|||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Get the title for a new resource from link title */
|
||||
/*****************************************************************************/
|
||||
|
||||
static void PrgRsc_GetResourceTitleFromLink (struct Prg_Item *Item)
|
||||
{
|
||||
/***** Reset title *****/
|
||||
Item->Resource.Title[0] = '\0';
|
||||
|
||||
/***** Trivial check: code should be > 0 *****/
|
||||
if (Item->Resource.Link.Cod <= 0)
|
||||
return;
|
||||
|
||||
switch (Item->Resource.Link.Type)
|
||||
{
|
||||
case PrgRsc_NONE:
|
||||
break;
|
||||
case PrgRsc_ASSIGNMENT:
|
||||
case PrgRsc_CALL_FOR_EXAM:
|
||||
case PrgRsc_EXAM:
|
||||
case PrgRsc_GAME:
|
||||
case PrgRsc_SURVEY:
|
||||
Ale_ShowAlert (Ale_ERROR,"Not implemented!");
|
||||
break;
|
||||
case PrgRsc_DOCUMENT:
|
||||
Brw_GetFileNameFromFilCod (Item->Resource.Link.Cod,
|
||||
Item->Resource.Title,
|
||||
sizeof (Item->Resource.Title) - 1);
|
||||
break;
|
||||
case PrgRsc_MARKS:
|
||||
case PrgRsc_ATTENDANCE_EVENT:
|
||||
case PrgRsc_FORUM_THREAD:
|
||||
Ale_ShowAlert (Ale_ERROR,"Not implemented!");
|
||||
break;
|
||||
default:
|
||||
Err_WrongTypeExit ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Show clipboard to change resource link ********************/
|
||||
/*****************************************************************************/
|
||||
|
@ -1042,7 +1082,6 @@ void PrgRsc_ChangeLink (void)
|
|||
struct Prg_Item Item;
|
||||
char TypeCod[3 + 1 + Cns_MAX_DECIMAL_DIGITS_LONG + 1];
|
||||
char TypeStr[3 + 1];
|
||||
PrgRsc_Type_t Type;
|
||||
long Cod;
|
||||
|
||||
/***** Get list of program items *****/
|
||||
|
@ -1058,17 +1097,29 @@ void PrgRsc_ChangeLink (void)
|
|||
Par_GetParToText ("Link",TypeCod,sizeof (TypeCod) - 1);
|
||||
if (sscanf (TypeCod,"%3s_%ld",TypeStr,&Cod) == 2)
|
||||
{
|
||||
Type = PrgRsc_GetTypeFromString (TypeStr);
|
||||
Item.Resource.Link.Type = PrgRsc_GetTypeFromString (TypeStr);
|
||||
Item.Resource.Link.Cod = Cod;
|
||||
|
||||
/***** Is it an existing resource? *****/
|
||||
if (Item.Resource.Hierarchy.RscCod <= 0)
|
||||
{
|
||||
/* No resource selected, so it's a new resource at the end of the item */
|
||||
/* Get the new title for the new resource from link title */
|
||||
PrgRsc_GetResourceTitleFromLink (&Item);
|
||||
|
||||
/***** Create resource *****/
|
||||
Item.Resource.Hierarchy.RscCod = Prg_DB_CreateResource (&Item);
|
||||
}
|
||||
|
||||
/***** Update resource link *****/
|
||||
Prg_DB_UpdateRscLink (Item.Resource.Hierarchy.RscCod,Type,Cod);
|
||||
Prg_DB_UpdateRscLink (&Item);
|
||||
|
||||
/***** Remove link from clipboard *****/
|
||||
Prg_DB_RemoveLinkFromClipboard (Type,Cod);
|
||||
Prg_DB_RemoveLinkFromClipboard (&Item.Resource.Link);
|
||||
}
|
||||
|
||||
/***** Show current program items, if any *****/
|
||||
Prg_ShowAllItems (Prg_SHOW_CLIPBOARD,Item.Hierarchy.ItmCod,Item.Resource.Hierarchy.RscCod);
|
||||
Prg_ShowAllItems (Prg_EDIT_RESOURCE_LINK,Item.Hierarchy.ItmCod,Item.Resource.Hierarchy.RscCod);
|
||||
|
||||
/***** Free list of program items *****/
|
||||
Prg_FreeListItems ();
|
||||
|
|
Loading…
Reference in New Issue