2021-09-29 19:39:37 +02:00
|
|
|
|
// swad_MFU.c: Most Frequently Used actions
|
2016-08-14 13:25:11 +02:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
|
|
|
|
This file is part of SWAD core.
|
2024-02-07 00:40:28 +01:00
|
|
|
|
Copyright (C) 1999-2024 Antonio Ca<EFBFBD>as Vargas
|
2016-08-14 13:25:11 +02:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General 3 License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************************** Headers *********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2018-10-23 23:05:16 +02:00
|
|
|
|
#include <mysql/mysql.h> // To access MySQL databases
|
|
|
|
|
#include <stdlib.h> // For malloc and free
|
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
|
2016-08-14 13:25:11 +02:00
|
|
|
|
#include "swad_action.h"
|
2022-11-06 18:11:10 +01:00
|
|
|
|
#include "swad_action_list.h"
|
2017-06-10 21:38:10 +02:00
|
|
|
|
#include "swad_box.h"
|
2016-08-14 13:25:11 +02:00
|
|
|
|
#include "swad_config.h"
|
|
|
|
|
#include "swad_database.h"
|
2021-04-26 15:27:27 +02:00
|
|
|
|
#include "swad_error.h"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2016-08-14 13:25:11 +02:00
|
|
|
|
#include "swad_global.h"
|
2019-10-23 20:07:56 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2016-08-14 13:25:11 +02:00
|
|
|
|
#include "swad_MFU.h"
|
2021-09-29 19:39:37 +02:00
|
|
|
|
#include "swad_MFU_database.h"
|
2016-08-14 13:25:11 +02:00
|
|
|
|
#include "swad_tab.h"
|
|
|
|
|
#include "swad_theme.h"
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private constants *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-08 14:12:33 +01:00
|
|
|
|
#define MFU_MAX_CHARS_TAB (128 - 1) // 127
|
|
|
|
|
#define MFU_MAX_BYTES_TAB ((MFU_MAX_CHARS_TAB + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
|
2017-03-07 19:55:29 +01:00
|
|
|
|
|
2017-03-08 14:12:33 +01:00
|
|
|
|
#define MFU_MAX_CHARS_MENU (128 - 1) // 127
|
|
|
|
|
#define MFU_MAX_BYTES_MENU ((MFU_MAX_CHARS_MENU + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
|
2017-01-15 18:02:52 +01:00
|
|
|
|
|
2016-08-14 13:25:11 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
2022-04-30 22:48:30 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void MFU_PutIconAndText (Act_Action_t Action,
|
|
|
|
|
const char MenuStr[MFU_MAX_BYTES_MENU + 1]);
|
|
|
|
|
|
2016-08-14 13:25:11 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Allocate list of most frequently used actions ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void MFU_AllocateMFUActions (struct MFU_ListMFUActions *ListMFUActions,unsigned MaxActionsShown)
|
|
|
|
|
{
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((ListMFUActions->Actions = malloc (MaxActionsShown *
|
|
|
|
|
sizeof (*ListMFUActions->Actions))) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_ShowErrorAndExit ("Can not allocate memory for list of most frequently used actions.");
|
2016-08-14 13:25:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Free list of most frequently used actions ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void MFU_FreeMFUActions (struct MFU_ListMFUActions *ListMFUActions)
|
|
|
|
|
{
|
|
|
|
|
if (ListMFUActions->Actions != NULL)
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (ListMFUActions->Actions);
|
2016-08-14 13:25:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Get and write most frequently used actions ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// ListMFUActions->Actions must have space for MaxActionsShown actions
|
|
|
|
|
|
|
|
|
|
void MFU_GetMFUActions (struct MFU_ListMFUActions *ListMFUActions,unsigned MaxActionsShown)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
2021-04-16 13:51:12 +02:00
|
|
|
|
unsigned NumActions;
|
|
|
|
|
unsigned NumAction;
|
2016-08-14 13:25:11 +02:00
|
|
|
|
long ActCod;
|
|
|
|
|
Act_Action_t Action;
|
|
|
|
|
|
|
|
|
|
/***** Get most frequently used actions *****/
|
2021-09-29 19:39:37 +02:00
|
|
|
|
NumActions = MFU_DB_GetMFUActionsOrderByScore (&mysql_res);
|
2016-08-14 13:25:11 +02:00
|
|
|
|
|
|
|
|
|
/***** Write list of frequently used actions *****/
|
2021-04-16 13:51:12 +02:00
|
|
|
|
for (NumAction = 0, ListMFUActions->NumActions = 0;
|
|
|
|
|
NumAction < NumActions && ListMFUActions->NumActions < MaxActionsShown;
|
|
|
|
|
NumAction++)
|
2016-08-14 13:25:11 +02:00
|
|
|
|
{
|
2021-04-05 23:45:24 +02:00
|
|
|
|
/* Get action code */
|
|
|
|
|
ActCod = DB_GetNextCode (mysql_res);
|
2024-03-19 18:39:35 +01:00
|
|
|
|
if ((Action = Act_GetActionFromActCod (ActCod)) != ActUnk)
|
|
|
|
|
if (Act_GetIndexInMenu (Action) >= 0) // MFU actions must be only actions shown on menu (database could contain wrong action numbers)
|
2024-04-19 12:00:30 +02:00
|
|
|
|
if (Act_CheckIfICanExecuteAction (Action) == Usr_CAN)
|
2024-03-19 18:39:35 +01:00
|
|
|
|
ListMFUActions->Actions[ListMFUActions->NumActions++] = Action;
|
2016-08-14 13:25:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Get my last action in the current tab ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
Act_Action_t MFU_GetMyLastActionInCurrentTab (void)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
unsigned NumActions;
|
|
|
|
|
unsigned NumAct;
|
|
|
|
|
long ActCod;
|
|
|
|
|
Act_Action_t Action;
|
|
|
|
|
Act_Action_t MoreRecentActionInCurrentTab = ActUnk;
|
|
|
|
|
|
|
|
|
|
if (Gbl.Usrs.Me.UsrDat.UsrCod > 0)
|
|
|
|
|
{
|
|
|
|
|
/***** Get my most frequently used actions *****/
|
2021-09-29 19:39:37 +02:00
|
|
|
|
NumActions = MFU_DB_GetMFUActionsOrderByLastClick (&mysql_res);
|
2016-08-14 13:25:11 +02:00
|
|
|
|
|
|
|
|
|
/***** Loop over list of frequently used actions *****/
|
|
|
|
|
for (NumAct = 0;
|
|
|
|
|
NumAct < NumActions;
|
|
|
|
|
NumAct++)
|
|
|
|
|
{
|
2021-04-05 23:45:24 +02:00
|
|
|
|
/* Get action code */
|
|
|
|
|
ActCod = DB_GetNextCode (mysql_res);
|
2022-11-06 18:11:10 +01:00
|
|
|
|
if (ActCod >= 0 && ActCod <= ActLst_MAX_ACTION_COD)
|
|
|
|
|
if ((Action = Act_GetActionFromActCod (ActCod)) >= 0)
|
2024-03-19 18:39:35 +01:00
|
|
|
|
if (Act_GetTab (Action) == Gbl.Action.Tab)
|
2024-04-19 12:00:30 +02:00
|
|
|
|
if (Act_CheckIfICanExecuteAction (Action) == Usr_CAN)
|
2016-08-14 13:25:11 +02:00
|
|
|
|
{
|
|
|
|
|
MoreRecentActionInCurrentTab = Action;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return MoreRecentActionInCurrentTab;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Show a list of my most frequently used actions ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void MFU_ShowMyMFUActions (void)
|
|
|
|
|
{
|
|
|
|
|
struct MFU_ListMFUActions ListMFUActions;
|
|
|
|
|
|
|
|
|
|
MFU_AllocateMFUActions (&ListMFUActions,10);
|
|
|
|
|
|
|
|
|
|
MFU_GetMFUActions (&ListMFUActions,10);
|
|
|
|
|
MFU_WriteBigMFUActions (&ListMFUActions);
|
|
|
|
|
|
|
|
|
|
MFU_FreeMFUActions (&ListMFUActions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Write list of most frequently used actions ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void MFU_WriteBigMFUActions (struct MFU_ListMFUActions *ListMFUActions)
|
|
|
|
|
{
|
2017-12-19 18:41:19 +01:00
|
|
|
|
extern const char *Hlp_ANALYTICS_Frequent;
|
2016-11-10 21:16:23 +01:00
|
|
|
|
extern const char *Txt_My_frequent_actions;
|
2016-08-14 13:25:11 +02:00
|
|
|
|
unsigned NumAct;
|
|
|
|
|
Act_Action_t Action;
|
|
|
|
|
const char *Title;
|
2017-03-07 19:55:29 +01:00
|
|
|
|
char TabStr[MFU_MAX_BYTES_TAB + 1];
|
|
|
|
|
char MenuStr[MFU_MAX_BYTES_MENU + 1];
|
|
|
|
|
char TabMenuStr[MFU_MAX_BYTES_TAB + 6 + MFU_MAX_BYTES_MENU + 1];
|
2016-08-14 13:25:11 +02:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2024-01-29 09:45:28 +01:00
|
|
|
|
Box_BoxBegin (Txt_My_frequent_actions,NULL,NULL,
|
2017-12-19 18:41:19 +01:00
|
|
|
|
Hlp_ANALYTICS_Frequent,Box_NOT_CLOSABLE);
|
2016-08-14 13:25:11 +02:00
|
|
|
|
|
2021-06-29 15:25:42 +02:00
|
|
|
|
/***** Begin container *****/
|
|
|
|
|
HTM_DIV_Begin ("id=\"MFU_actions_big\"");
|
|
|
|
|
|
|
|
|
|
/***** Begin list of frequently used actions *****/
|
|
|
|
|
HTM_UL_Begin ("class=\"LIST_LEFT\"");
|
|
|
|
|
|
|
|
|
|
for (NumAct = 0;
|
|
|
|
|
NumAct < ListMFUActions->NumActions;
|
|
|
|
|
NumAct++)
|
|
|
|
|
{
|
|
|
|
|
Action = ListMFUActions->Actions[NumAct];
|
|
|
|
|
|
|
|
|
|
if ((Title = Act_GetTitleAction (Action)) != NULL)
|
|
|
|
|
{
|
|
|
|
|
/* Action string */
|
2024-03-19 18:39:35 +01:00
|
|
|
|
Str_Copy (TabStr,Tab_GetTxt (Act_GetTab (Action)),
|
2021-06-29 15:25:42 +02:00
|
|
|
|
sizeof (TabStr) - 1);
|
|
|
|
|
Str_Copy (MenuStr,Title,sizeof (MenuStr) - 1);
|
|
|
|
|
snprintf (TabMenuStr,sizeof (TabMenuStr),"%s > %s",TabStr,MenuStr);
|
|
|
|
|
|
|
|
|
|
/* Icon and text */
|
|
|
|
|
HTM_LI_Begin ("class=\"ICO_HIGHLIGHT\"");
|
|
|
|
|
Frm_BeginForm (Action);
|
2022-04-01 01:06:44 +02:00
|
|
|
|
HTM_BUTTON_Submit_Begin (TabMenuStr,
|
|
|
|
|
"class=\"BT_LINK FORM_IN_%s NOWRAP\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2022-04-30 22:48:30 +02:00
|
|
|
|
MFU_PutIconAndText (Action,MenuStr);
|
2021-06-29 15:25:42 +02:00
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_LI_End ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** End list of frequently used actions *****/
|
|
|
|
|
HTM_UL_End ();
|
|
|
|
|
|
|
|
|
|
/***** End container *****/
|
|
|
|
|
HTM_DIV_End ();
|
2016-08-14 13:25:11 +02:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2016-08-14 13:25:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Get and write most frequently used actions ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void MFU_WriteSmallMFUActions (struct MFU_ListMFUActions *ListMFUActions)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Frequent_ACTIONS;
|
|
|
|
|
unsigned NumAct;
|
|
|
|
|
Act_Action_t Action;
|
|
|
|
|
const char *Title;
|
2017-03-07 19:55:29 +01:00
|
|
|
|
char TabStr[MFU_MAX_BYTES_TAB + 1];
|
|
|
|
|
char MenuStr[MFU_MAX_BYTES_MENU + 1];
|
|
|
|
|
char TabMenuStr[MFU_MAX_BYTES_TAB + 6 + MFU_MAX_BYTES_MENU + 1];
|
2016-08-14 13:25:11 +02:00
|
|
|
|
|
2023-05-05 10:40:56 +02:00
|
|
|
|
/***** Begin fieldset *****/
|
2023-05-23 10:13:14 +02:00
|
|
|
|
HTM_FIELDSET_Begin ("id=\"MFU_actions\" class=\"MFU_%s\"",The_GetSuffix ());
|
2023-05-05 10:40:56 +02:00
|
|
|
|
HTM_LEGEND (Txt_Frequent_ACTIONS);
|
2021-06-29 15:25:42 +02:00
|
|
|
|
|
2023-05-05 17:15:58 +02:00
|
|
|
|
/***** List of frequently used actions *****/
|
2021-06-29 15:25:42 +02:00
|
|
|
|
HTM_UL_Begin (NULL);
|
|
|
|
|
|
|
|
|
|
for (NumAct = 0;
|
|
|
|
|
NumAct < ListMFUActions->NumActions;
|
|
|
|
|
NumAct++)
|
|
|
|
|
{
|
|
|
|
|
Action = ListMFUActions->Actions[NumAct];
|
|
|
|
|
|
|
|
|
|
if ((Title = Act_GetTitleAction (Action)) != NULL)
|
|
|
|
|
{
|
|
|
|
|
/* Action string */
|
2024-03-19 18:39:35 +01:00
|
|
|
|
Str_Copy (TabStr,Tab_GetTxt (Act_GetTab (Action)),
|
2021-06-29 15:25:42 +02:00
|
|
|
|
sizeof (TabStr) - 1);
|
|
|
|
|
Str_Copy (MenuStr,Title,sizeof (MenuStr) - 1);
|
|
|
|
|
snprintf (TabMenuStr,sizeof (TabMenuStr),"%s > %s",TabStr,MenuStr);
|
|
|
|
|
|
|
|
|
|
/* Icon and text */
|
|
|
|
|
HTM_LI_Begin ("class=\"ICO_HIGHLIGHT\"");
|
|
|
|
|
Frm_BeginForm (Action);
|
2022-04-01 01:06:44 +02:00
|
|
|
|
HTM_BUTTON_Submit_Begin (TabMenuStr,"class=\"BT_LINK\"");
|
2023-05-23 10:13:14 +02:00
|
|
|
|
MFU_PutIconAndText (Action,MenuStr);
|
2021-06-29 15:25:42 +02:00
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_LI_End ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HTM_UL_End ();
|
2016-08-14 13:25:11 +02:00
|
|
|
|
|
2023-05-05 17:15:58 +02:00
|
|
|
|
/***** Link to view more frequently used actions *****/
|
|
|
|
|
Lay_PutContextualLinkOnlyIcon (ActMFUAct,NULL,
|
|
|
|
|
NULL,NULL,
|
|
|
|
|
"ellipsis-h.svg",Ico_BLACK);
|
2023-05-05 10:40:56 +02:00
|
|
|
|
|
|
|
|
|
/***** End fieldset *****/
|
|
|
|
|
HTM_FIELDSET_End ();
|
2016-08-14 13:25:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-30 22:48:30 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Put action icon and text ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void MFU_PutIconAndText (Act_Action_t Action,
|
|
|
|
|
const char MenuStr[MFU_MAX_BYTES_MENU + 1])
|
|
|
|
|
{
|
|
|
|
|
extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS];
|
|
|
|
|
static const Ico_Color_t Color[Ico_NUM_ICON_SETS] =
|
|
|
|
|
{
|
|
|
|
|
[Ico_ICON_SET_AWESOME] = Ico_BLACK,
|
|
|
|
|
[Ico_ICON_SET_NUVOLA ] = Ico_UNCHANGED,
|
|
|
|
|
};
|
|
|
|
|
char URLIconSet[PATH_MAX + 1];
|
|
|
|
|
|
|
|
|
|
snprintf (URLIconSet,sizeof (URLIconSet),"%s/%s",
|
|
|
|
|
Cfg_URL_ICON_SETS_PUBLIC,Ico_IconSetId[Gbl.Prefs.IconSet]);
|
|
|
|
|
if (Color[Gbl.Prefs.IconSet] == Ico_UNCHANGED)
|
2024-03-14 21:58:26 +01:00
|
|
|
|
HTM_IMG (URLIconSet,Act_GetIconFromAction (Action),MenuStr,
|
2022-04-30 22:48:30 +02:00
|
|
|
|
NULL);
|
|
|
|
|
else
|
2024-03-14 21:58:26 +01:00
|
|
|
|
HTM_IMG (URLIconSet,Act_GetIconFromAction (Action),MenuStr,
|
2022-04-30 22:48:30 +02:00
|
|
|
|
"class=\"ICO_%s_%s\"",
|
|
|
|
|
Ico_GetPreffix (Color[Gbl.Prefs.IconSet]),
|
|
|
|
|
The_GetSuffix ());
|
2024-01-26 10:26:19 +01:00
|
|
|
|
HTM_NBSPTxt (MenuStr);
|
2022-04-30 22:48:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-14 13:25:11 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Update most frequently used actions ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void MFU_UpdateMFUActions (void)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2019-11-11 00:15:44 +01:00
|
|
|
|
double Score;
|
2018-04-24 13:21:53 +02:00
|
|
|
|
long ActCod;
|
|
|
|
|
Act_Action_t SuperAction;
|
2016-08-14 13:25:11 +02:00
|
|
|
|
|
|
|
|
|
/***** In some cases, don't register action *****/
|
|
|
|
|
if (!Gbl.Usrs.Me.Logged)
|
|
|
|
|
return;
|
2018-04-24 13:21:53 +02:00
|
|
|
|
if (Act_GetIndexInMenu (Gbl.Action.Act) < 0)
|
2016-08-14 13:25:11 +02:00
|
|
|
|
return;
|
2018-04-24 13:21:53 +02:00
|
|
|
|
SuperAction = Act_GetSuperAction (Gbl.Action.Act);
|
|
|
|
|
if (SuperAction == ActMFUAct)
|
2016-08-14 13:25:11 +02:00
|
|
|
|
return;
|
|
|
|
|
|
2018-04-24 13:21:53 +02:00
|
|
|
|
ActCod = Act_GetActCod (SuperAction);
|
|
|
|
|
|
2016-08-14 13:25:11 +02:00
|
|
|
|
Str_SetDecimalPointToUS (); // To get the decimal point as a dot
|
|
|
|
|
|
|
|
|
|
/***** Get current score *****/
|
2021-09-29 19:39:37 +02:00
|
|
|
|
if (MFU_DB_GetScoreForCurrentAction (&mysql_res,ActCod))
|
2016-08-14 13:25:11 +02:00
|
|
|
|
{
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2019-11-11 00:15:44 +01:00
|
|
|
|
if (sscanf (row[0],"%lf",&Score) != 1)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_ShowErrorAndExit ("Error when getting score for current action.");
|
2016-08-14 13:25:11 +02:00
|
|
|
|
Score *= MFU_INCREASE_FACTOR;
|
|
|
|
|
if (Score > MFU_MAX_SCORE)
|
|
|
|
|
Score = MFU_MAX_SCORE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Score = MFU_MIN_SCORE; // Initial score for a new action not present in MFU table
|
|
|
|
|
|
|
|
|
|
/* Free structure that stores the query result */
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Update score for the current action *****/
|
2021-09-29 19:39:37 +02:00
|
|
|
|
MFU_DB_UpdateScoreForCurrentAction (ActCod,Score);
|
2016-08-14 13:25:11 +02:00
|
|
|
|
|
|
|
|
|
/***** Update score for other actions *****/
|
2021-09-29 19:39:37 +02:00
|
|
|
|
MFU_DB_UpdateScoreForOtherActions (ActCod);
|
2016-08-14 13:25:11 +02:00
|
|
|
|
|
|
|
|
|
Str_SetDecimalPointToLocal (); // Return to local system
|
|
|
|
|
}
|