");
Frm_StartForm (ActMFUAct);
Frm_LinkFormSubmit (Txt_My_frequent_actions,NULL,NULL);
fprintf (Gbl.F.Out," %s"
"",
Txt_Frequent_ACTIONS);
Frm_EndForm ();
/***** Write list of frequently used actions *****/
fprintf (Gbl.F.Out,"
");
for (NumAct = 0;
NumAct < ListMFUActions->NumActions;
NumAct++)
{
Action = ListMFUActions->Actions[NumAct];
if ((Title = Act_GetTitleAction (Action)) != NULL)
{
/* Action string */
Str_Copy (TabStr,Txt_TABS_TXT[Act_GetTab (Act_GetSuperAction (Action))],
MFU_MAX_BYTES_TAB);
Str_Copy (MenuStr,Title,
MFU_MAX_BYTES_MENU);
snprintf (TabMenuStr,sizeof (TabMenuStr),
"%s > %s",
TabStr,MenuStr);
/* Icon and text */
fprintf (Gbl.F.Out,"- ");
Frm_StartForm (Action);
Frm_LinkFormSubmit (TabMenuStr,NULL,NULL);
fprintf (Gbl.F.Out,"",
Gbl.Prefs.URLIconSet,
Act_GetIcon (Action),
MenuStr);
fprintf (Gbl.F.Out," %s",MenuStr);
Frm_EndForm ();
fprintf (Gbl.F.Out,"
");
}
}
fprintf (Gbl.F.Out,"
");
/***** End div *****/
fprintf (Gbl.F.Out,"
");
}
/*****************************************************************************/
/******************** Update most frequently used actions ********************/
/*****************************************************************************/
#define MFU_MIN_SCORE 0.5
#define MFU_MAX_SCORE 100.0
#define MFU_INCREASE_FACTOR 1.2
#define MFU_DECREASE_FACTOR 0.99
void MFU_UpdateMFUActions (void)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
float Score;
long ActCod;
Act_Action_t SuperAction;
/***** In some cases, don't register action *****/
if (!Gbl.Usrs.Me.Logged)
return;
if (Act_GetIndexInMenu (Gbl.Action.Act) < 0)
return;
SuperAction = Act_GetSuperAction (Gbl.Action.Act);
if (SuperAction == ActMFUAct)
return;
ActCod = Act_GetActCod (SuperAction);
Str_SetDecimalPointToUS (); // To get the decimal point as a dot
/***** Get current score *****/
if (DB_QuerySELECT (&mysql_res,"can not get score for current action",
"SELECT Score FROM actions_MFU"
" WHERE UsrCod=%ld AND ActCod=%ld",
Gbl.Usrs.Me.UsrDat.UsrCod,ActCod))
{
row = mysql_fetch_row (mysql_res);
if (sscanf (row[0],"%f",&Score) != 1)
Lay_ShowErrorAndExit ("Error when getting score for current action.");
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 *****/
DB_QueryREPLACE ("can not update most frequently used actions",
"REPLACE INTO actions_MFU"
" (UsrCod,ActCod,Score,LastClick)"
" VALUES"
" (%ld,%ld,'%f',NOW())",
Gbl.Usrs.Me.UsrDat.UsrCod,ActCod,Score);
/***** Update score for other actions *****/
DB_QueryUPDATE ("can not update most frequently used actions",
"UPDATE actions_MFU SET Score=GREATEST(Score*'%f','%f')"
" WHERE UsrCod=%ld AND ActCod<>%ld",
MFU_DECREASE_FACTOR,MFU_MIN_SCORE,
Gbl.Usrs.Me.UsrDat.UsrCod,ActCod);
Str_SetDecimalPointToLocal (); // Return to local system
}