Version18.109

This commit is contained in:
Antonio Cañas Vargas 2019-04-09 18:46:13 +02:00
parent bd32e62e06
commit 7f890b9068
5 changed files with 238 additions and 131 deletions

View File

@ -1723,14 +1723,14 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
/* ActChgLnkWWW */{ 752,-1,TabUnk,ActSeeLnk , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,Lnk_ChangeLinkWWW ,Lnk_ContEditAfterChgLnk ,NULL}, /* ActChgLnkWWW */{ 752,-1,TabUnk,ActSeeLnk , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,Lnk_ChangeLinkWWW ,Lnk_ContEditAfterChgLnk ,NULL},
/* ActEdiPlg */{ 778,-1,TabUnk,ActLstPlg , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Plg_EditPlugins ,NULL}, /* ActEdiPlg */{ 778,-1,TabUnk,ActLstPlg , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Plg_EditPlugins ,NULL},
/* ActNewPlg */{ 779,-1,TabUnk,ActLstPlg , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Plg_RecFormNewPlg ,NULL}, /* ActNewPlg */{ 779,-1,TabUnk,ActLstPlg , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,Plg_RecFormNewPlg ,Plg_ContEditAfterChgPlg ,NULL},
/* ActRemPlg */{ 889,-1,TabUnk,ActLstPlg , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Plg_RemovePlugin ,NULL}, /* ActRemPlg */{ 889,-1,TabUnk,ActLstPlg , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,Plg_RemovePlugin ,Plg_ContEditAfterChgPlg ,NULL},
/* ActRenPlg */{ 782,-1,TabUnk,ActLstPlg , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Plg_RenamePlugin ,NULL}, /* ActRenPlg */{ 782,-1,TabUnk,ActLstPlg , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,Plg_RenamePlugin ,Plg_ContEditAfterChgPlg ,NULL},
/* ActChgPlgDes */{ 888,-1,TabUnk,ActLstPlg , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Plg_ChangePlgDescription ,NULL}, /* ActChgPlgDes */{ 888,-1,TabUnk,ActLstPlg , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,Plg_ChangePlgDescription ,Plg_ContEditAfterChgPlg ,NULL},
/* ActChgPlgLog */{ 781,-1,TabUnk,ActLstPlg , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Plg_ChangePlgLogo ,NULL}, /* ActChgPlgLog */{ 781,-1,TabUnk,ActLstPlg , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,Plg_ChangePlgLogo ,Plg_ContEditAfterChgPlg ,NULL},
/* ActChgPlgAppKey */{ 986,-1,TabUnk,ActLstPlg , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Plg_ChangePlgAppKey ,NULL}, /* ActChgPlgAppKey */{ 986,-1,TabUnk,ActLstPlg , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,Plg_ChangePlgAppKey ,Plg_ContEditAfterChgPlg ,NULL},
/* ActChgPlgURL */{ 783,-1,TabUnk,ActLstPlg , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Plg_ChangePlgURL ,NULL}, /* ActChgPlgURL */{ 783,-1,TabUnk,ActLstPlg , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,Plg_ChangePlgURL ,Plg_ContEditAfterChgPlg ,NULL},
/* ActChgPlgIP */{ 780,-1,TabUnk,ActLstPlg , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Plg_ChangePlgIP ,NULL}, /* ActChgPlgIP */{ 780,-1,TabUnk,ActLstPlg , 0, 0, 0, 0, 0, 0,0x200,Act_CONT_NORM,Act_BRW_1ST_TAB,Plg_ChangePlgIP ,Plg_ContEditAfterChgPlg ,NULL},
// TabCty ****************************************************************** // TabCty ******************************************************************
// Actions in menu: // Actions in menu:

View File

@ -464,10 +464,11 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf ps2pdf source.ps destination.pdf
*/ */
#define Log_PLATFORM_VERSION "SWAD 18.108 (2019-04-09)" #define Log_PLATFORM_VERSION "SWAD 18.109 (2019-04-09)"
#define CSS_FILE "swad18.92.css" #define CSS_FILE "swad18.92.css"
#define JS_FILE "swad18.92.js" #define JS_FILE "swad18.92.js"
/* /*
Version 18.109: Apr 09, 2019 Code refactoring in edition of plugins. (242423 lines)
Version 18.108: Apr 09, 2019 Code refactoring in edition of links. (242336 lines) Version 18.108: Apr 09, 2019 Code refactoring in edition of links. (242336 lines)
Version 18.107: Apr 09, 2019 Code refactoring in edition of banners. (242275 lines) Version 18.107: Apr 09, 2019 Code refactoring in edition of banners. (242275 lines)
Version 18.106: Apr 09, 2019 Code refactoring in edition of mail domains. (242208 lines) Version 18.106: Apr 09, 2019 Code refactoring in edition of mail domains. (242208 lines)

View File

@ -271,7 +271,6 @@ struct Globals
{ {
unsigned Num; // Number of plugins unsigned Num; // Number of plugins
struct Plugin *Lst; // List of plugins struct Plugin *Lst; // List of plugins
struct Plugin EditingPlg;
} Plugins; } Plugins;
struct struct
{ {

View File

@ -45,6 +45,7 @@ TODO: Check if web service is called from an authorized IP.
#include "swad_parameter.h" #include "swad_parameter.h"
#include "swad_plugin.h" #include "swad_plugin.h"
#include "swad_session.h" #include "swad_session.h"
#include "swad_table.h"
#include "swad_web_service.h" #include "swad_web_service.h"
/*****************************************************************************/ /*****************************************************************************/
@ -57,11 +58,22 @@ extern struct Globals Gbl;
/***************************** Private constants *****************************/ /***************************** Private constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
/*****************************************************************************/
/******************************* Private types *******************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private variables *****************************/
/*****************************************************************************/
static struct Plugin *Plg_EditingPlg = NULL; // Static variable to keep the plugin being edited
/*****************************************************************************/ /*****************************************************************************/
/***************************** Private prototypes ****************************/ /***************************** Private prototypes ****************************/
/*****************************************************************************/ /*****************************************************************************/
static void Plg_PutIconToEditPlugins (void); static void Plg_PutIconToEditPlugins (void);
static void Plg_EditPluginsInternal (void);
static void Plg_ListPluginsForEdition (void); static void Plg_ListPluginsForEdition (void);
static void Plg_PutParamPlgCod (long PlgCod); static void Plg_PutParamPlgCod (long PlgCod);
static void Plg_GetListPlugins (void); static void Plg_GetListPlugins (void);
@ -70,6 +82,9 @@ static void Plg_PutHeadPlugins (void);
static bool Plg_CheckIfPluginNameExists (const char *Name,long PlgCod); static bool Plg_CheckIfPluginNameExists (const char *Name,long PlgCod);
static void Plg_CreatePlugin (struct Plugin *Plg); static void Plg_CreatePlugin (struct Plugin *Plg);
static void Plg_EditingPluginConstructor (void);
static void Plg_EditingPluginDestructor (void);
/*****************************************************************************/ /*****************************************************************************/
/************************** List available plugins ***************************/ /************************** List available plugins ***************************/
/*****************************************************************************/ /*****************************************************************************/
@ -164,9 +179,27 @@ static void Plg_PutIconToEditPlugins (void)
void Plg_EditPlugins (void) void Plg_EditPlugins (void)
{ {
/***** Plugin constructor *****/
Plg_EditingPluginConstructor ();
/***** Edit plugins *****/
Plg_EditPluginsInternal ();
/***** Plugin destructor *****/
Plg_EditingPluginDestructor ();
}
static void Plg_EditPluginsInternal (void)
{
extern const char *Txt_Plugins;
/***** Get list of plugins *****/ /***** Get list of plugins *****/
Plg_GetListPlugins (); Plg_GetListPlugins ();
/***** Start box *****/
Box_StartBox (NULL,Txt_Plugins,NULL,
NULL,Box_NOT_CLOSABLE);
/***** Put a form to create a new plugin *****/ /***** Put a form to create a new plugin *****/
Plg_PutFormToCreatePlugin (); Plg_PutFormToCreatePlugin ();
@ -174,6 +207,9 @@ void Plg_EditPlugins (void)
if (Gbl.Plugins.Num) if (Gbl.Plugins.Num)
Plg_ListPluginsForEdition (); Plg_ListPluginsForEdition ();
/***** End box *****/
Box_EndBox ();
/***** Free list of plugins *****/ /***** Free list of plugins *****/
Plg_FreeListPlugins (); Plg_FreeListPlugins ();
} }
@ -342,15 +378,11 @@ void Plg_FreeListPlugins (void)
static void Plg_ListPluginsForEdition (void) static void Plg_ListPluginsForEdition (void)
{ {
extern const char *Txt_Plugins;
unsigned NumPlg; unsigned NumPlg;
struct Plugin *Plg; struct Plugin *Plg;
/***** Start box and table *****/
Box_StartBoxTable (NULL,Txt_Plugins,NULL,
NULL,Box_NOT_CLOSABLE,2);
/***** Write heading *****/ /***** Write heading *****/
Tbl_StartTableWide (2);
Plg_PutHeadPlugins (); Plg_PutHeadPlugins ();
/***** Write all the plugins *****/ /***** Write all the plugins *****/
@ -456,8 +488,8 @@ static void Plg_ListPluginsForEdition (void)
"</tr>"); "</tr>");
} }
/***** End table and box *****/ /***** End table *****/
Box_EndBoxTable (); Tbl_EndTable ();
} }
/*****************************************************************************/ /*****************************************************************************/
@ -486,26 +518,26 @@ long Plg_GetParamPlgCod (void)
void Plg_RemovePlugin (void) void Plg_RemovePlugin (void)
{ {
extern const char *Txt_Plugin_X_removed; extern const char *Txt_Plugin_X_removed;
struct Plugin Plg;
/***** Plugin constructor *****/
Plg_EditingPluginConstructor ();
/***** Get plugin code *****/ /***** Get plugin code *****/
if ((Plg.PlgCod = Plg_GetParamPlgCod ()) == -1L) if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) == -1L)
Lay_ShowErrorAndExit ("Code of plugin is missing."); Lay_ShowErrorAndExit ("Code of plugin is missing.");
/***** Get data of the plugin from database *****/ /***** Get data of the plugin from database *****/
Plg_GetDataOfPluginByCod (&Plg); Plg_GetDataOfPluginByCod (Plg_EditingPlg);
/***** Remove plugin *****/ /***** Remove plugin *****/
DB_QueryDELETE ("can not remove a plugin", DB_QueryDELETE ("can not remove a plugin",
"DELETE FROM plugins WHERE PlgCod=%ld", "DELETE FROM plugins WHERE PlgCod=%ld",
Plg.PlgCod); Plg_EditingPlg->PlgCod);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_Plugin_X_removed, Ale_CreateAlert (Ale_SUCCESS,NULL,
Plg.Name); Txt_Plugin_X_removed,
Plg_EditingPlg->Name);
/***** Show the form again *****/
Plg_EditPlugins ();
} }
/*****************************************************************************/ /*****************************************************************************/
@ -518,57 +550,60 @@ void Plg_RenamePlugin (void)
extern const char *Txt_The_plugin_X_already_exists; extern const char *Txt_The_plugin_X_already_exists;
extern const char *Txt_The_plugin_X_has_been_renamed_as_Y; extern const char *Txt_The_plugin_X_has_been_renamed_as_Y;
extern const char *Txt_The_name_of_the_plugin_X_has_not_changed; extern const char *Txt_The_name_of_the_plugin_X_has_not_changed;
struct Plugin *Plg;
char NewPlgName[Plg_MAX_BYTES_PLUGIN_NAME + 1]; char NewPlgName[Plg_MAX_BYTES_PLUGIN_NAME + 1];
Plg = &Gbl.Plugins.EditingPlg; /***** Plugin constructor *****/
Plg_EditingPluginConstructor ();
/***** Get parameters from form *****/ /***** Get parameters from form *****/
/* Get the code of the plugin */ /* Get the code of the plugin */
if ((Plg->PlgCod = Plg_GetParamPlgCod ()) == -1L) if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) == -1L)
Lay_ShowErrorAndExit ("Code of plugin is missing."); Lay_ShowErrorAndExit ("Code of plugin is missing.");
/* Get the new name for the plugin */ /* Get the new name for the plugin */
Par_GetParToText ("Name",NewPlgName,Plg_MAX_BYTES_PLUGIN_NAME); Par_GetParToText ("Name",NewPlgName,Plg_MAX_BYTES_PLUGIN_NAME);
/***** Get from the database the old name of the plugin *****/ /***** Get plugin data from the database *****/
Plg_GetDataOfPluginByCod (Plg); Plg_GetDataOfPluginByCod (Plg_EditingPlg);
/***** Check if new name is empty *****/ /***** Check if new name is empty *****/
if (!NewPlgName[0]) if (!NewPlgName[0])
Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_leave_the_name_of_the_plugin_X_empty, Ale_CreateAlert (Ale_WARNING,NULL,
Plg->Name); Txt_You_can_not_leave_the_name_of_the_plugin_X_empty,
Plg_EditingPlg->Name);
else else
{ {
/***** Check if old and new names are the same /***** Check if old and new names are the same
(this happens when return is pressed without changes) *****/ (this happens when return is pressed without changes) *****/
if (strcmp (Plg->Name,NewPlgName)) // Different names if (strcmp (Plg_EditingPlg->Name,NewPlgName)) // Different names
{ {
/***** If plugin was in database... *****/ /***** If plugin was in database... *****/
if (Plg_CheckIfPluginNameExists (NewPlgName,Plg->PlgCod)) if (Plg_CheckIfPluginNameExists (NewPlgName,Plg_EditingPlg->PlgCod))
Ale_ShowAlert (Ale_WARNING,Txt_The_plugin_X_already_exists, Ale_CreateAlert (Ale_WARNING,NULL,
NewPlgName); Txt_The_plugin_X_already_exists,
NewPlgName);
else else
{ {
/* Update the table changing old name by new name */ /* Update the table changing old name by new name */
DB_QueryUPDATE ("can not update the name of a plugin", DB_QueryUPDATE ("can not update the name of a plugin",
"UPDATE plugins SET Name='%s' WHERE PlgCod=%ld", "UPDATE plugins SET Name='%s' WHERE PlgCod=%ld",
NewPlgName,Plg->PlgCod); NewPlgName,Plg_EditingPlg->PlgCod);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_The_plugin_X_has_been_renamed_as_Y, Ale_CreateAlert (Ale_SUCCESS,NULL,
Plg->Name,NewPlgName); Txt_The_plugin_X_has_been_renamed_as_Y,
Plg_EditingPlg->Name,NewPlgName);
} }
} }
else // The same name else // The same name
Ale_ShowAlert (Ale_INFO,Txt_The_name_of_the_plugin_X_has_not_changed, Ale_CreateAlert (Ale_INFO,NULL,
Plg->Name); Txt_The_name_of_the_plugin_X_has_not_changed,
Plg_EditingPlg->Name);
} }
/***** Show the form again *****/ /***** Update name *****/
Str_Copy (Plg->Name,NewPlgName, Str_Copy (Plg_EditingPlg->Name,NewPlgName,
Plg_MAX_BYTES_PLUGIN_NAME); Plg_MAX_BYTES_PLUGIN_NAME);
Plg_EditPlugins ();
} }
/*****************************************************************************/ /*****************************************************************************/
@ -593,38 +628,42 @@ void Plg_ChangePlgDescription (void)
{ {
extern const char *Txt_The_new_description_is_X; extern const char *Txt_The_new_description_is_X;
extern const char *Txt_You_can_not_leave_the_description_empty; extern const char *Txt_You_can_not_leave_the_description_empty;
struct Plugin *Plg;
char NewDescription[Plg_MAX_BYTES_PLUGIN_DESCRIPTION + 1]; char NewDescription[Plg_MAX_BYTES_PLUGIN_DESCRIPTION + 1];
Plg = &Gbl.Plugins.EditingPlg; /***** Plugin constructor *****/
Plg_EditingPluginConstructor ();
/***** Get parameters from form *****/ /***** Get parameters from form *****/
/* Get the code of the plugin */ /* Get the code of the plugin */
if ((Plg->PlgCod = Plg_GetParamPlgCod ()) == -1L) if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) == -1L)
Lay_ShowErrorAndExit ("Code of plugin is missing."); Lay_ShowErrorAndExit ("Code of plugin is missing.");
/* Get the new description for the plugin */ /* Get the new description for the plugin */
Par_GetParToText ("Description",NewDescription,Plg_MAX_BYTES_PLUGIN_DESCRIPTION); Par_GetParToText ("Description",NewDescription,Plg_MAX_BYTES_PLUGIN_DESCRIPTION);
/***** Get plugin data from the database *****/
Plg_GetDataOfPluginByCod (Plg_EditingPlg);
/***** Check if new description is empty *****/ /***** Check if new description is empty *****/
if (NewDescription[0]) if (NewDescription[0])
{ {
/* Update the table changing old description by new description */ /* Update the table changing old description by new description */
DB_QueryUPDATE ("can not update the description of a plugin", DB_QueryUPDATE ("can not update the description of a plugin",
"UPDATE plugins SET Description='%s' WHERE PlgCod=%ld", "UPDATE plugins SET Description='%s' WHERE PlgCod=%ld",
NewDescription,Plg->PlgCod); NewDescription,Plg_EditingPlg->PlgCod);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_The_new_description_is_X, Ale_CreateAlert (Ale_SUCCESS,NULL,
NewDescription); Txt_The_new_description_is_X,
NewDescription);
} }
else else
Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_leave_the_description_empty); Ale_CreateAlert (Ale_WARNING,NULL,
Txt_You_can_not_leave_the_description_empty);
/***** Show the form again *****/ /***** Update description *****/
Str_Copy (Plg->Description,NewDescription, Str_Copy (Plg_EditingPlg->Description,NewDescription,
Plg_MAX_BYTES_PLUGIN_DESCRIPTION); Plg_MAX_BYTES_PLUGIN_DESCRIPTION);
Plg_EditPlugins ();
} }
/*****************************************************************************/ /*****************************************************************************/
@ -635,38 +674,42 @@ void Plg_ChangePlgLogo (void)
{ {
extern const char *Txt_The_new_logo_is_X; extern const char *Txt_The_new_logo_is_X;
extern const char *Txt_You_can_not_leave_the_logo_empty; extern const char *Txt_You_can_not_leave_the_logo_empty;
struct Plugin *Plg;
char NewLogo[Plg_MAX_BYTES_PLUGIN_LOGO + 1]; char NewLogo[Plg_MAX_BYTES_PLUGIN_LOGO + 1];
Plg = &Gbl.Plugins.EditingPlg; /***** Plugin constructor *****/
Plg_EditingPluginConstructor ();
/***** Get parameters from form *****/ /***** Get parameters from form *****/
/* Get the code of the plugin */ /* Get the code of the plugin */
if ((Plg->PlgCod = Plg_GetParamPlgCod ()) == -1L) if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) == -1L)
Lay_ShowErrorAndExit ("Code of plugin is missing."); Lay_ShowErrorAndExit ("Code of plugin is missing.");
/* Get the new logo for the plugin */ /* Get the new logo for the plugin */
Par_GetParToText ("Logo",NewLogo,Plg_MAX_BYTES_PLUGIN_LOGO); Par_GetParToText ("Logo",NewLogo,Plg_MAX_BYTES_PLUGIN_LOGO);
/***** Get plugin data from the database *****/
Plg_GetDataOfPluginByCod (Plg_EditingPlg);
/***** Check if new logo is empty *****/ /***** Check if new logo is empty *****/
if (NewLogo[0]) if (NewLogo[0])
{ {
/* Update the table changing old logo by new logo */ /* Update the table changing old logo by new logo */
DB_QueryUPDATE ("can not update the logo of a plugin", DB_QueryUPDATE ("can not update the logo of a plugin",
"UPDATE plugins SET Logo='%s' WHERE PlgCod=%ld", "UPDATE plugins SET Logo='%s' WHERE PlgCod=%ld",
NewLogo,Plg->PlgCod); NewLogo,Plg_EditingPlg->PlgCod);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_The_new_logo_is_X, Ale_CreateAlert (Ale_SUCCESS,NULL,
NewLogo); Txt_The_new_logo_is_X,
NewLogo);
} }
else else
Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_leave_the_logo_empty); Ale_CreateAlert (Ale_WARNING,NULL,
Txt_You_can_not_leave_the_logo_empty);
/***** Show the form again *****/ /***** Update logo *****/
Str_Copy (Plg->Logo,NewLogo, Str_Copy (Plg_EditingPlg->Logo,NewLogo,
Plg_MAX_BYTES_PLUGIN_LOGO); Plg_MAX_BYTES_PLUGIN_LOGO);
Plg_EditPlugins ();
} }
/*****************************************************************************/ /*****************************************************************************/
@ -675,40 +718,44 @@ void Plg_ChangePlgLogo (void)
void Plg_ChangePlgAppKey (void) void Plg_ChangePlgAppKey (void)
{ {
extern const char *Txt_The_new_logo_is_X; // TODO: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! extern const char *Txt_The_new_logo_is_X; // TODO: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
extern const char *Txt_You_can_not_leave_the_logo_empty;// TODO: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! extern const char *Txt_You_can_not_leave_the_logo_empty; // TODO: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
struct Plugin *Plg;
char NewAppKey[Plg_MAX_BYTES_PLUGIN_APP_KEY + 1]; char NewAppKey[Plg_MAX_BYTES_PLUGIN_APP_KEY + 1];
Plg = &Gbl.Plugins.EditingPlg; /***** Plugin constructor *****/
Plg_EditingPluginConstructor ();
/***** Get parameters from form *****/ /***** Get parameters from form *****/
/* Get the code of the plugin */ /* Get the code of the plugin */
if ((Plg->PlgCod = Plg_GetParamPlgCod ()) == -1L) if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) == -1L)
Lay_ShowErrorAndExit ("Code of plugin is missing."); Lay_ShowErrorAndExit ("Code of plugin is missing.");
/* Get the new logo for the plugin */ /* Get the new logo for the plugin */
Par_GetParToText ("AppKey",NewAppKey,Plg_MAX_BYTES_PLUGIN_APP_KEY); Par_GetParToText ("AppKey",NewAppKey,Plg_MAX_BYTES_PLUGIN_APP_KEY);
/***** Get plugin data from the database *****/
Plg_GetDataOfPluginByCod (Plg_EditingPlg);
/***** Check if new logo is empty *****/ /***** Check if new logo is empty *****/
if (NewAppKey[0]) if (NewAppKey[0])
{ {
/* Update the table changing old application key by new application key */ /* Update the table changing old application key by new application key */
DB_QueryUPDATE ("can not update the application key of a plugin", DB_QueryUPDATE ("can not update the application key of a plugin",
"UPDATE plugins SET AppKey='%s' WHERE PlgCod=%ld", "UPDATE plugins SET AppKey='%s' WHERE PlgCod=%ld",
NewAppKey,Plg->PlgCod); NewAppKey,Plg_EditingPlg->PlgCod);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_The_new_logo_is_X, // TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Ale_CreateAlert (Ale_SUCCESS,NULL,
NewAppKey); Txt_The_new_logo_is_X, // TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
NewAppKey);
} }
else else
Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_leave_the_logo_empty); // TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Ale_CreateAlert (Ale_WARNING,NULL,
Txt_You_can_not_leave_the_logo_empty); // TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/***** Show the form again *****/ /***** Update app key *****/
Str_Copy (Plg->AppKey,NewAppKey, Str_Copy (Plg_EditingPlg->AppKey,NewAppKey,
Plg_MAX_BYTES_PLUGIN_APP_KEY); Plg_MAX_BYTES_PLUGIN_APP_KEY);
Plg_EditPlugins ();
} }
/*****************************************************************************/ /*****************************************************************************/
@ -719,38 +766,42 @@ void Plg_ChangePlgURL (void)
{ {
extern const char *Txt_The_new_URL_is_X; extern const char *Txt_The_new_URL_is_X;
extern const char *Txt_You_can_not_leave_the_URL_empty; extern const char *Txt_You_can_not_leave_the_URL_empty;
struct Plugin *Plg;
char NewURL[Cns_MAX_BYTES_WWW + 1]; char NewURL[Cns_MAX_BYTES_WWW + 1];
Plg = &Gbl.Plugins.EditingPlg; /***** Plugin constructor *****/
Plg_EditingPluginConstructor ();
/***** Get parameters from form *****/ /***** Get parameters from form *****/
/* Get the code of the plugin */ /* Get the code of the plugin */
if ((Plg->PlgCod = Plg_GetParamPlgCod ()) == -1L) if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) == -1L)
Lay_ShowErrorAndExit ("Code of plugin is missing."); Lay_ShowErrorAndExit ("Code of plugin is missing.");
/* Get the new URL for the plugin */ /* Get the new URL for the plugin */
Par_GetParToText ("URL",NewURL,Cns_MAX_BYTES_WWW); Par_GetParToText ("URL",NewURL,Cns_MAX_BYTES_WWW);
/***** Get plugin data from the database *****/
Plg_GetDataOfPluginByCod (Plg_EditingPlg);
/***** Check if new URL is empty *****/ /***** Check if new URL is empty *****/
if (NewURL[0]) if (NewURL[0])
{ {
/* Update the table changing old WWW by new WWW */ /* Update the table changing old WWW by new WWW */
DB_QueryUPDATE ("can not update the URL of a plugin", DB_QueryUPDATE ("can not update the URL of a plugin",
"UPDATE plugins SET URL='%s' WHERE PlgCod=%ld", "UPDATE plugins SET URL='%s' WHERE PlgCod=%ld",
NewURL,Plg->PlgCod); NewURL,Plg_EditingPlg->PlgCod);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_The_new_URL_is_X, Ale_CreateAlert (Ale_SUCCESS,NULL,
NewURL); Txt_The_new_URL_is_X,
NewURL);
} }
else else
Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_leave_the_URL_empty); Ale_CreateAlert (Ale_WARNING,NULL,
Txt_You_can_not_leave_the_URL_empty);
/***** Show the form again *****/ /***** Update URL *****/
Str_Copy (Plg->URL,NewURL, Str_Copy (Plg_EditingPlg->URL,NewURL,
Cns_MAX_BYTES_WWW); Cns_MAX_BYTES_WWW);
Plg_EditPlugins ();
} }
/*****************************************************************************/ /*****************************************************************************/
@ -761,38 +812,58 @@ void Plg_ChangePlgIP (void)
{ {
extern const char *Txt_The_new_IP_address_is_X; extern const char *Txt_The_new_IP_address_is_X;
extern const char *Txt_You_can_not_leave_the_IP_address_empty; extern const char *Txt_You_can_not_leave_the_IP_address_empty;
struct Plugin *Plg;
char NewIP[Cns_MAX_BYTES_IP + 1]; char NewIP[Cns_MAX_BYTES_IP + 1];
Plg = &Gbl.Plugins.EditingPlg; /***** Plugin constructor *****/
Plg_EditingPluginConstructor ();
/***** Get parameters from form *****/ /***** Get parameters from form *****/
/* Get the code of the plugin */ /* Get the code of the plugin */
if ((Plg->PlgCod = Plg_GetParamPlgCod ()) == -1L) if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) == -1L)
Lay_ShowErrorAndExit ("Code of plugin is missing."); Lay_ShowErrorAndExit ("Code of plugin is missing.");
/* Get the new IP for the plugin */ /* Get the new IP for the plugin */
Par_GetParToText ("IP",NewIP,Cns_MAX_BYTES_IP); Par_GetParToText ("IP",NewIP,Cns_MAX_BYTES_IP);
/***** Get plugin data from the database *****/
Plg_GetDataOfPluginByCod (Plg_EditingPlg);
/***** Check if new IP is empty *****/ /***** Check if new IP is empty *****/
if (NewIP[0]) if (NewIP[0])
{ {
/* Update the table changing old IP by new IP */ /* Update the table changing old IP by new IP */
DB_QueryUPDATE ("can not update the IP address of a plugin", DB_QueryUPDATE ("can not update the IP address of a plugin",
"UPDATE plugins SET IP='%s' WHERE PlgCod=%ld", "UPDATE plugins SET IP='%s' WHERE PlgCod=%ld",
NewIP,Plg->PlgCod); NewIP,Plg_EditingPlg->PlgCod);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_The_new_IP_address_is_X, Ale_CreateAlert (Ale_SUCCESS,NULL,
NewIP); Txt_The_new_IP_address_is_X,
NewIP);
} }
else else
Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_leave_the_IP_address_empty); Ale_CreateAlert (Ale_WARNING,NULL,
Txt_You_can_not_leave_the_IP_address_empty);
/***** Update IP *****/
Str_Copy (Plg_EditingPlg->IP,NewIP,
Cns_MAX_BYTES_IP);
}
/*****************************************************************************/
/********* Show alerts after changing a plugin and continue editing **********/
/*****************************************************************************/
void Plg_ContEditAfterChgPlg (void)
{
/***** Write message to show the change made *****/
Ale_ShowAlerts (NULL);
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (Plg->IP,NewIP, Plg_EditPluginsInternal ();
Cns_MAX_BYTES_IP);
Plg_EditPlugins (); /***** Plugin destructor *****/
Plg_EditingPluginDestructor ();
} }
/*****************************************************************************/ /*****************************************************************************/
@ -809,9 +880,6 @@ static void Plg_PutFormToCreatePlugin (void)
extern const char *Txt_URL; extern const char *Txt_URL;
extern const char *Txt_IP; extern const char *Txt_IP;
extern const char *Txt_Create_plugin; extern const char *Txt_Create_plugin;
struct Plugin *Plg;
Plg = &Gbl.Plugins.EditingPlg;
/***** Start form *****/ /***** Start form *****/
Frm_StartForm (ActNewPlg); Frm_StartForm (ActNewPlg);
@ -854,7 +922,7 @@ static void Plg_PutFormToCreatePlugin (void)
" size=\"10\" maxlength=\"%u\" value=\"%s\"" " size=\"10\" maxlength=\"%u\" value=\"%s\""
" required=\"required\" />" " required=\"required\" />"
"</td>", "</td>",
Plg_MAX_CHARS_PLUGIN_NAME,Plg->Name); Plg_MAX_CHARS_PLUGIN_NAME,Plg_EditingPlg->Name);
/***** Plugin description *****/ /***** Plugin description *****/
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">" fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
@ -862,7 +930,7 @@ static void Plg_PutFormToCreatePlugin (void)
" size=\"30\" maxlength=\"%u\" value=\"%s\"" " size=\"30\" maxlength=\"%u\" value=\"%s\""
" required=\"required\" />" " required=\"required\" />"
"</td>", "</td>",
Plg_MAX_CHARS_PLUGIN_DESCRIPTION,Plg->Description); Plg_MAX_CHARS_PLUGIN_DESCRIPTION,Plg_EditingPlg->Description);
/***** Plugin logo *****/ /***** Plugin logo *****/
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">" fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
@ -870,7 +938,7 @@ static void Plg_PutFormToCreatePlugin (void)
" size=\"4\" maxlength=\"%u\" value=\"%s\"" " size=\"4\" maxlength=\"%u\" value=\"%s\""
" required=\"required\" />" " required=\"required\" />"
"</td>", "</td>",
Plg_MAX_CHARS_PLUGIN_LOGO,Plg->Logo); Plg_MAX_CHARS_PLUGIN_LOGO,Plg_EditingPlg->Logo);
/***** Plugin application key *****/ /***** Plugin application key *****/
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">" fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
@ -878,7 +946,7 @@ static void Plg_PutFormToCreatePlugin (void)
" size=\"16\" maxlength=\"%u\" value=\"%s\"" " size=\"16\" maxlength=\"%u\" value=\"%s\""
" required=\"required\" />" " required=\"required\" />"
"</td>", "</td>",
Plg_MAX_CHARS_PLUGIN_APP_KEY,Plg->AppKey); Plg_MAX_CHARS_PLUGIN_APP_KEY,Plg_EditingPlg->AppKey);
/***** Plugin URL *****/ /***** Plugin URL *****/
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">" fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
@ -886,7 +954,7 @@ static void Plg_PutFormToCreatePlugin (void)
" size=\"15\" maxlength=\"%u\" value=\"%s\"" " size=\"15\" maxlength=\"%u\" value=\"%s\""
" required=\"required\" />" " required=\"required\" />"
"</td>", "</td>",
Cns_MAX_CHARS_WWW,Plg->URL); Cns_MAX_CHARS_WWW,Plg_EditingPlg->URL);
/***** Plugin IP address *****/ /***** Plugin IP address *****/
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">" fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
@ -895,7 +963,7 @@ static void Plg_PutFormToCreatePlugin (void)
" required=\"required\" />" " required=\"required\" />"
"</td>" "</td>"
"</tr>", "</tr>",
Cns_MAX_CHARS_IP,Plg->IP); Cns_MAX_CHARS_IP,Plg_EditingPlg->IP);
/***** End table, send button and end box *****/ /***** End table, send button and end box *****/
Box_EndBoxTableWithButton (Btn_CREATE_BUTTON,Txt_Create_plugin); Box_EndBoxTableWithButton (Btn_CREATE_BUTTON,Txt_Create_plugin);
@ -959,50 +1027,59 @@ static void Plg_PutHeadPlugins (void)
void Plg_RecFormNewPlg (void) void Plg_RecFormNewPlg (void)
{ {
extern const char *Txt_The_plugin_X_already_exists; extern const char *Txt_The_plugin_X_already_exists;
extern const char *Txt_Created_new_plugin_X;
extern const char *Txt_You_must_specify_the_logo_the_application_key_the_URL_and_the_IP_address_of_the_new_plugin; extern const char *Txt_You_must_specify_the_logo_the_application_key_the_URL_and_the_IP_address_of_the_new_plugin;
extern const char *Txt_You_must_specify_the_name_and_the_description_of_the_new_plugin; extern const char *Txt_You_must_specify_the_name_and_the_description_of_the_new_plugin;
struct Plugin *Plg;
Plg = &Gbl.Plugins.EditingPlg; /***** Plugin constructor *****/
Plg_EditingPluginConstructor ();
/***** Get parameters from form *****/ /***** Get parameters from form *****/
/* Get plugin name */ /* Get plugin name */
Par_GetParToText ("Name",Plg->Name,Plg_MAX_BYTES_PLUGIN_NAME); Par_GetParToText ("Name",Plg_EditingPlg->Name,Plg_MAX_BYTES_PLUGIN_NAME);
/* Get plugin description */ /* Get plugin description */
Par_GetParToText ("Description",Plg->Description,Plg_MAX_BYTES_PLUGIN_DESCRIPTION); Par_GetParToText ("Description",Plg_EditingPlg->Description,Plg_MAX_BYTES_PLUGIN_DESCRIPTION);
/* Get plugin logo */ /* Get plugin logo */
Par_GetParToText ("Logo",Plg->Logo,Plg_MAX_BYTES_PLUGIN_LOGO); Par_GetParToText ("Logo",Plg_EditingPlg->Logo,Plg_MAX_BYTES_PLUGIN_LOGO);
/* Get plugin application key */ /* Get plugin application key */
Par_GetParToText ("AppKey",Plg->AppKey,Plg_MAX_BYTES_PLUGIN_APP_KEY); Par_GetParToText ("AppKey",Plg_EditingPlg->AppKey,Plg_MAX_BYTES_PLUGIN_APP_KEY);
/* Get plugin URL */ /* Get plugin URL */
Par_GetParToText ("URL",Plg->URL,Cns_MAX_BYTES_WWW); Par_GetParToText ("URL",Plg_EditingPlg->URL,Cns_MAX_BYTES_WWW);
/* Get plugin IP address */ /* Get plugin IP address */
Par_GetParToText ("IP",Plg->IP,Cns_MAX_BYTES_IP); Par_GetParToText ("IP",Plg_EditingPlg->IP,Cns_MAX_BYTES_IP);
if (Plg->Name[0]) // If there's a plugin name if (Plg_EditingPlg->Name[0]) // If there's a plugin name
{ {
if (Plg->Logo[0] && Plg->AppKey[0] && Plg->URL[0] && Plg->IP[0]) if (Plg_EditingPlg->Logo[0] &&
Plg_EditingPlg->AppKey[0] &&
Plg_EditingPlg->URL[0] &&
Plg_EditingPlg->IP[0])
{ {
/***** If name of plugin was in database... *****/ /***** If name of plugin was in database... *****/
if (Plg_CheckIfPluginNameExists (Plg->Name,-1L)) if (Plg_CheckIfPluginNameExists (Plg_EditingPlg->Name,-1L))
Ale_ShowAlert (Ale_WARNING,Txt_The_plugin_X_already_exists, Ale_CreateAlert (Ale_WARNING,NULL,
Plg->Name); Txt_The_plugin_X_already_exists,
Plg_EditingPlg->Name);
else // Add new plugin to database else // Add new plugin to database
Plg_CreatePlugin (Plg); {
Plg_CreatePlugin (Plg_EditingPlg);
Ale_CreateAlert (Ale_SUCCESS,NULL,
Txt_Created_new_plugin_X,
Plg_EditingPlg->Name);
}
} }
else // If there is not a logo, a URL or a IP else // If there is not a logo, a URL or a IP
Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_logo_the_application_key_the_URL_and_the_IP_address_of_the_new_plugin); Ale_CreateAlert (Ale_WARNING,NULL,
Txt_You_must_specify_the_logo_the_application_key_the_URL_and_the_IP_address_of_the_new_plugin);
} }
else // If there is not a plugin name else // If there is not a plugin name
Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_name_and_the_description_of_the_new_plugin); Ale_CreateAlert (Ale_WARNING,NULL,
Txt_You_must_specify_the_name_and_the_description_of_the_new_plugin);
/***** Show the form again *****/
Plg_EditPlugins ();
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1011,8 +1088,6 @@ void Plg_RecFormNewPlg (void)
static void Plg_CreatePlugin (struct Plugin *Plg) static void Plg_CreatePlugin (struct Plugin *Plg)
{ {
extern const char *Txt_Created_new_plugin_X;
/***** Create a new plugin *****/ /***** Create a new plugin *****/
DB_QueryINSERT ("can not create plugin", DB_QueryINSERT ("can not create plugin",
"INSERT INTO plugins" "INSERT INTO plugins"
@ -1023,10 +1098,6 @@ static void Plg_CreatePlugin (struct Plugin *Plg)
"'%s','%s','%s')", "'%s','%s','%s')",
Plg->Name,Plg->Description,Plg->Logo, Plg->Name,Plg->Description,Plg->Logo,
Plg->AppKey,Plg->URL,Plg->IP); Plg->AppKey,Plg->URL,Plg->IP);
/***** Write success message *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_Created_new_plugin_X,
Plg->Name);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1041,3 +1112,37 @@ void Plg_WebService (void)
/***** All the output is made, so don't write anymore *****/ /***** All the output is made, so don't write anymore *****/
Gbl.Layout.DivsEndWritten = Gbl.Layout.HTMLEndWritten = true; Gbl.Layout.DivsEndWritten = Gbl.Layout.HTMLEndWritten = true;
} }
/*****************************************************************************/
/************************ Plugin constructor/destructor **********************/
/*****************************************************************************/
static void Plg_EditingPluginConstructor (void)
{
/***** Pointer must be NULL *****/
if (Plg_EditingPlg != NULL)
Lay_ShowErrorAndExit ("Error initializing plugin.");
/***** Allocate memory for plugin *****/
if ((Plg_EditingPlg = (struct Plugin *) malloc (sizeof (struct Plugin))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for plugin.");
/***** Reset plugin *****/
Plg_EditingPlg->PlgCod = -1L;
Plg_EditingPlg->Name[0] = '\0';
Plg_EditingPlg->Description[0] = '\0';
Plg_EditingPlg->Logo[0] = '\0';
Plg_EditingPlg->AppKey[0] = '\0';
Plg_EditingPlg->URL[0] = '\0';
Plg_EditingPlg->IP[0] = '\0';
}
static void Plg_EditingPluginDestructor (void)
{
/***** Free memory used for plugin *****/
if (Plg_EditingPlg != NULL)
{
free ((void *) Plg_EditingPlg);
Plg_EditingPlg = NULL;
}
}

View File

@ -74,6 +74,8 @@ void Plg_ChangePlgLogo (void);
void Plg_ChangePlgAppKey (void); void Plg_ChangePlgAppKey (void);
void Plg_ChangePlgURL (void); void Plg_ChangePlgURL (void);
void Plg_ChangePlgIP (void); void Plg_ChangePlgIP (void);
void Plg_ContEditAfterChgPlg (void);
void Plg_RecFormNewPlg (void); void Plg_RecFormNewPlg (void);
void Plg_WebService (void); void Plg_WebService (void);