"
"");
Act_FormStart (Action);
Act_LinkFormSubmit (TabMenuStr,The_ClassFormNoWrap[Gbl.Prefs.Theme]);
fprintf (Gbl.F.Out,"",
Gbl.Prefs.PathIconSet,Cfg_ICON_ACTION,
Act_Actions[Action].Icon,
MenuStr,TabMenuStr);
fprintf (Gbl.F.Out," %s",TabMenuStr);
Act_FormEnd ();
fprintf (Gbl.F.Out," | "
"
");
}
}
/***** Table end *****/
Lay_EndRoundFrameTable ();
}
/*****************************************************************************/
/*************** Get and write most frequently used actions ******************/
/*****************************************************************************/
void Act_WriteSmallMFUActions (struct Act_ListMFUActions *ListMFUActions)
{
extern const char *Txt_Frequent_actions;
extern const char *Txt_Frequent_ACTIONS;
extern const char *Txt_TABS_FULL_TXT[Tab_NUM_TABS];
extern const char *Txt_MENU_TITLE[Tab_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB];
unsigned NumAct;
Act_Action_t Action;
const char *Title;
char TabStr[128+1];
char MenuStr[128+1];
char TabMenuStr[128+6+128+1];
/***** Start frame and link *****/
fprintf (Gbl.F.Out,"");
Act_FormStart (ActMFUAct);
Act_LinkFormSubmit (Txt_Frequent_actions,"MFU_ACT");
fprintf (Gbl.F.Out," %s"
"",
Txt_Frequent_ACTIONS);
Act_FormEnd ();
/***** 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 */
strncpy (TabStr,Txt_TABS_FULL_TXT[Act_Actions[Action].Tab],128);
TabStr[128] = '\0';
strncpy (MenuStr,Title,128);
MenuStr[128] = '\0';
sprintf (TabMenuStr,"%s > %s",TabStr,MenuStr);
/* Icon and text */
fprintf (Gbl.F.Out,"- ");
Act_FormStart (Action);
Act_LinkFormSubmit (Title,NULL);
fprintf (Gbl.F.Out,"",
Gbl.Prefs.PathIconSet,Cfg_ICON_ACTION,
Act_Actions[Action].Icon,
MenuStr,TabMenuStr);
fprintf (Gbl.F.Out," %s",MenuStr);
Act_FormEnd ();
fprintf (Gbl.F.Out,"
");
}
}
fprintf (Gbl.F.Out,"
");
/***** End frame *****/
fprintf (Gbl.F.Out,"
");
}
/*****************************************************************************/
/******************** Update most frequently used actions ********************/
/*****************************************************************************/
#define Act_MIN_SCORE 0.5
#define Act_MAX_SCORE 100.0
#define Act_INCREASE_FACTOR 1.2
#define Act_DECREASE_FACTOR 0.99
void Act_UpdateMFUActions (void)
{
char Query[1024];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
float Score;
/***** In some cases, don't register action *****/
if (!Gbl.Usrs.Me.Logged)
return;
if (Act_Actions[Act_Actions[Gbl.Action.Act].SuperAction].IndexInMenu < 0)
return;
if (Act_Actions[Gbl.Action.Act].SuperAction == ActMFUAct)
return;
setlocale (LC_NUMERIC,"en_US.utf8"); // To get the decimal point
/***** Get current score *****/
sprintf (Query,"SELECT Score FROM actions_MFU"
" WHERE UsrCod='%ld' AND ActCod='%ld'",
Gbl.Usrs.Me.UsrDat.UsrCod,
Act_Actions[Act_Actions[Gbl.Action.Act].SuperAction].ActCod);
if (DB_QuerySELECT (Query,&mysql_res,"can not get score for current action"))
{
row = mysql_fetch_row (mysql_res);
if (sscanf (row[0],"%f",&Score) != 1)
Lay_ShowErrorAndExit ("Error when getting score for current action.");
Score *= Act_INCREASE_FACTOR;
if (Score > Act_MAX_SCORE)
Score = Act_MAX_SCORE;
}
else
Score = Act_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 *****/
sprintf (Query,"REPLACE INTO actions_MFU"
" (UsrCod,ActCod,Score,LastClick)"
" VALUES ('%ld','%ld','%f',NOW())",
Gbl.Usrs.Me.UsrDat.UsrCod,
Act_Actions[Act_Actions[Gbl.Action.Act].SuperAction].ActCod,
Score);
DB_QueryREPLACE (Query,"can not update most frequently used actions");
/***** Update score for other actions *****/
sprintf (Query,"UPDATE actions_MFU SET Score=GREATEST(Score*'%f','%f')"
" WHERE UsrCod='%ld' AND ActCod<>'%ld'",
Act_DECREASE_FACTOR,Act_MIN_SCORE,
Gbl.Usrs.Me.UsrDat.UsrCod,
Act_Actions[Act_Actions[Gbl.Action.Act].SuperAction].ActCod);
DB_QueryUPDATE (Query,"can not update most frequently used actions");
setlocale (LC_NUMERIC,"es_ES.utf8");
}