2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_preference.c: user's preferences
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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.
|
2019-01-07 21:52:19 +01:00
|
|
|
|
Copyright (C) 1999-2019 Antonio Ca<EFBFBD>as Vargas
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General Public 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-24 10:45:28 +02:00
|
|
|
|
#define _GNU_SOURCE // For asprintf
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <linux/stddef.h> // For NULL
|
2015-10-16 02:24:29 +02:00
|
|
|
|
#include <stdbool.h> // For boolean type
|
2018-10-24 10:45:28 +02:00
|
|
|
|
#include <stdio.h> // For asprintf, fprintf, etc.
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2017-06-10 21:38:10 +02:00
|
|
|
|
#include "swad_box.h"
|
2015-11-21 20:23:28 +01:00
|
|
|
|
#include "swad_calendar.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_config.h"
|
|
|
|
|
#include "swad_database.h"
|
2017-05-04 02:19:23 +02:00
|
|
|
|
#include "swad_date.h"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_global.h"
|
2017-05-07 18:06:34 +02:00
|
|
|
|
#include "swad_language.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_layout.h"
|
|
|
|
|
#include "swad_notification.h"
|
2015-01-02 01:19:27 +01:00
|
|
|
|
#include "swad_menu.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_parameter.h"
|
|
|
|
|
#include "swad_preference.h"
|
2016-12-09 13:59:33 +01:00
|
|
|
|
#include "swad_privacy.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** External global variables from others modules ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Private constants ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Private prototypes ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
static void Pre_PutIconsToSelectSideCols (void);
|
2016-11-07 13:49:39 +01:00
|
|
|
|
static void Pre_PutIconsSideColumns (void);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
static void Pre_UpdateSideColsOnUsrDataTable (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Edit preferences ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
void Pre_EditPrefs (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-05-07 17:26:46 +02:00
|
|
|
|
extern const char *Hlp_PROFILE_Preferences_internationalization;
|
|
|
|
|
extern const char *Hlp_PROFILE_Preferences_design;
|
2017-05-05 13:42:59 +02:00
|
|
|
|
extern const char *Txt_Internationalization;
|
|
|
|
|
extern const char *Txt_Design;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-05-05 13:42:59 +02:00
|
|
|
|
/***** Internationalization: language, first day of week, date format *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_StartBox (NULL,Txt_Internationalization,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_PROFILE_Preferences_internationalization,Box_NOT_CLOSABLE);
|
2017-05-05 13:42:59 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"FRAME_INLINE\">");
|
2017-05-07 18:06:34 +02:00
|
|
|
|
Lan_PutBoxToSelectLanguage (); // 1. Language
|
2017-05-05 13:42:59 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"</div>"
|
2016-12-24 13:24:31 +01:00
|
|
|
|
"<div class=\"FRAME_INLINE\">");
|
2017-05-04 02:19:23 +02:00
|
|
|
|
Cal_PutIconsToSelectFirstDayOfWeek (); // 2. First day of week
|
2016-12-24 13:08:32 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</div>"
|
2016-12-24 13:24:31 +01:00
|
|
|
|
"<div class=\"FRAME_INLINE\">");
|
2017-05-07 18:06:34 +02:00
|
|
|
|
Dat_PutBoxToSelectDateFormat (); // 3. Date format
|
2017-05-05 13:42:59 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_EndBox ();
|
2017-05-04 02:19:23 +02:00
|
|
|
|
|
2017-05-05 13:42:59 +02:00
|
|
|
|
/***** Design: icon set, menu, theme, side columns *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_StartBox (NULL,Txt_Design,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_PROFILE_Preferences_design,Box_NOT_CLOSABLE);
|
2017-05-05 13:42:59 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"FRAME_INLINE\">");
|
2017-05-04 02:19:23 +02:00
|
|
|
|
Ico_PutIconsToSelectIconSet (); // 4. Icon set
|
2016-12-24 13:08:32 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</div>"
|
2016-12-24 13:24:31 +01:00
|
|
|
|
"<div class=\"FRAME_INLINE\">");
|
2017-05-04 02:19:23 +02:00
|
|
|
|
Mnu_PutIconsToSelectMenu (); // 5. Menu
|
2016-12-24 13:08:32 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</div>"
|
2017-05-05 13:42:59 +02:00
|
|
|
|
"<div class=\"FRAME_INLINE\">");
|
2017-05-04 02:19:23 +02:00
|
|
|
|
The_PutIconsToSelectTheme (); // 6. Theme
|
2016-12-24 13:08:32 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</div>"
|
2016-12-24 13:24:31 +01:00
|
|
|
|
"<div class=\"FRAME_INLINE\">");
|
2017-05-04 02:19:23 +02:00
|
|
|
|
Pre_PutIconsToSelectSideCols (); // 7. Side columns
|
2017-05-05 13:42:59 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_EndBox ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (Gbl.Usrs.Me.Logged)
|
|
|
|
|
{
|
2015-12-24 19:30:45 +01:00
|
|
|
|
/***** Form to set my preferences on privacy *****/
|
|
|
|
|
Pri_EditMyPrivacy ();
|
|
|
|
|
|
2016-11-16 23:19:52 +01:00
|
|
|
|
/***** Automatic email to notify of new events *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Ntf_PutFormChangeNotifSentByEMail ();
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-07 12:37:00 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Get preferences changed from current IP *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
void Pre_GetPrefsFromIP (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
unsigned long NumRows;
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
|
|
|
|
if (Gbl.IP[0])
|
|
|
|
|
{
|
|
|
|
|
/***** Get preferences from database *****/
|
2018-11-01 19:23:52 +01:00
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get preferences",
|
|
|
|
|
"SELECT FirstDayOfWeek,DateFormat,Theme,IconSet,Menu,SideCols"
|
|
|
|
|
" FROM IP_prefs WHERE IP='%s'",
|
|
|
|
|
Gbl.IP);
|
|
|
|
|
if (NumRows)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
if (NumRows != 1)
|
|
|
|
|
Lay_ShowErrorAndExit ("Internal error while getting preferences.");
|
|
|
|
|
|
|
|
|
|
/***** Get preferences from database *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
2015-11-21 21:54:25 +01:00
|
|
|
|
/* Get first day of week (row[0]) */
|
2017-05-04 11:03:44 +02:00
|
|
|
|
Gbl.Prefs.FirstDayOfWeek = Cal_GetFirstDayOfWeekFromStr (row[0]);
|
2015-11-21 21:54:25 +01:00
|
|
|
|
|
2017-05-04 11:03:44 +02:00
|
|
|
|
/* Get date format (row[1]) */
|
|
|
|
|
Gbl.Prefs.DateFormat = Dat_GetDateFormatFromStr (row[1]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-05-04 11:03:44 +02:00
|
|
|
|
/* Get theme (row[2]) */
|
|
|
|
|
Gbl.Prefs.Theme = The_GetThemeFromStr (row[2]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-05-04 11:03:44 +02:00
|
|
|
|
/* Get icon set (row[3]) */
|
|
|
|
|
Gbl.Prefs.IconSet = Ico_GetIconSetFromStr (row[3]);
|
2015-01-02 01:19:27 +01:00
|
|
|
|
|
2017-05-04 11:03:44 +02:00
|
|
|
|
/* Get menu (row[4]) */
|
|
|
|
|
Gbl.Prefs.Menu = Mnu_GetMenuFromStr (row[4]);
|
|
|
|
|
|
|
|
|
|
/* Get if user wants to show side columns (row[5]) */
|
|
|
|
|
if (sscanf (row[5],"%u",&Gbl.Prefs.SideCols) == 1)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2014-12-27 13:09:29 +01:00
|
|
|
|
if (Gbl.Prefs.SideCols > Lay_SHOW_BOTH_COLUMNS)
|
2014-12-27 13:49:17 +01:00
|
|
|
|
Gbl.Prefs.SideCols = Cfg_DEFAULT_COLUMNS;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2014-12-27 13:09:29 +01:00
|
|
|
|
Gbl.Prefs.SideCols = Cfg_DEFAULT_COLUMNS;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Set preferences from current IP ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
void Pre_SetPrefsFromIP (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *The_ThemeId[The_NUM_THEMES];
|
|
|
|
|
extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS];
|
|
|
|
|
|
|
|
|
|
/***** Update preferences from current IP in database *****/
|
2018-11-02 16:39:35 +01:00
|
|
|
|
DB_QueryREPLACE ("can not store preferences from current IP address",
|
|
|
|
|
"REPLACE INTO IP_prefs"
|
|
|
|
|
" (IP,UsrCod,LastChange,"
|
|
|
|
|
"FirstDayOfWeek,DateFormat,Theme,IconSet,Menu,SideCols)"
|
|
|
|
|
" VALUES"
|
|
|
|
|
" ('%s',%ld,NOW(),"
|
|
|
|
|
"%u,%u,'%s','%s',%u,%u)",
|
|
|
|
|
Gbl.IP,Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
|
|
|
Gbl.Prefs.FirstDayOfWeek,
|
|
|
|
|
(unsigned) Gbl.Prefs.DateFormat,
|
|
|
|
|
The_ThemeId[Gbl.Prefs.Theme],
|
|
|
|
|
Ico_IconSetId[Gbl.Prefs.IconSet],
|
|
|
|
|
(unsigned) Gbl.Prefs.Menu,
|
|
|
|
|
Gbl.Prefs.SideCols);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** If a user is logged, update its preferences in database for all its IP's *****/
|
|
|
|
|
if (Gbl.Usrs.Me.Logged)
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not update your preferences",
|
|
|
|
|
"UPDATE IP_prefs"
|
|
|
|
|
" SET FirstDayOfWeek=%u,DateFormat=%u,"
|
|
|
|
|
"Theme='%s',IconSet='%s',Menu=%u,SideCols=%u"
|
|
|
|
|
" WHERE UsrCod=%ld",
|
|
|
|
|
Gbl.Prefs.FirstDayOfWeek,
|
|
|
|
|
(unsigned) Gbl.Prefs.DateFormat,
|
|
|
|
|
The_ThemeId[Gbl.Prefs.Theme],
|
|
|
|
|
Ico_IconSetId[Gbl.Prefs.IconSet],
|
|
|
|
|
(unsigned) Gbl.Prefs.Menu,
|
|
|
|
|
Gbl.Prefs.SideCols,
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Remove old preferences from IP **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
void Pre_RemoveOldPrefsFromIP (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Remove old preferences *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove old preferences",
|
|
|
|
|
"DELETE LOW_PRIORITY FROM IP_prefs"
|
|
|
|
|
" WHERE LastChange<FROM_UNIXTIME(UNIX_TIMESTAMP()-'%lu')",
|
|
|
|
|
Cfg_TIME_TO_DELETE_IP_PREFS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Put icons to select the layout of the side columns *************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
static void Pre_PutIconsToSelectSideCols (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-11-13 01:21:35 +01:00
|
|
|
|
extern const char *Hlp_PROFILE_Preferences_columns;
|
2015-01-01 15:50:45 +01:00
|
|
|
|
extern const char *Txt_Columns;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_LAYOUT_SIDE_COLUMNS[4];
|
2015-01-01 15:50:45 +01:00
|
|
|
|
unsigned SideCols;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_StartBox (NULL,Txt_Columns,Pre_PutIconsSideColumns,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_PROFILE_Preferences_columns,Box_NOT_CLOSABLE);
|
2016-12-23 22:19:03 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"PREF_CONTAINER\">");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
for (SideCols = 0;
|
2014-12-27 13:09:29 +01:00
|
|
|
|
SideCols <= Lay_SHOW_BOTH_COLUMNS;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
SideCols++)
|
|
|
|
|
{
|
2016-12-23 22:19:03 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"%s\">",
|
2015-11-22 00:52:55 +01:00
|
|
|
|
SideCols == Gbl.Prefs.SideCols ? "PREF_ON" :
|
|
|
|
|
"PREF_OFF");
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActChgCol);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Par_PutHiddenParamUnsigned ("SideCols",SideCols);
|
|
|
|
|
fprintf (Gbl.F.Out,"<input type=\"image\" src=\"%s/layout%u%u_32x20.gif\""
|
2017-09-10 23:24:23 +02:00
|
|
|
|
" alt=\"%s\" title=\"%s\" class=\"ICO40x25\" />",
|
2019-01-09 01:41:54 +01:00
|
|
|
|
Gbl.Prefs.URLIcons,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
SideCols >> 1,SideCols & 1,
|
|
|
|
|
Txt_LAYOUT_SIDE_COLUMNS[SideCols],
|
|
|
|
|
Txt_LAYOUT_SIDE_COLUMNS[SideCols]);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2016-12-23 22:19:03 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2016-12-23 22:19:03 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_EndBox ();
|
2016-11-07 13:49:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Put contextual icons in side-columns preference ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Pre_PutIconsSideColumns (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Put icon to show a figure *****/
|
|
|
|
|
Gbl.Stat.FigureType = Sta_SIDE_COLUMNS;
|
|
|
|
|
Sta_PutIconToShowFigure ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Change layout of side columns ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
void Pre_ChangeSideCols (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get param side-columns *****/
|
2015-03-14 17:39:04 +01:00
|
|
|
|
Gbl.Prefs.SideCols = Pre_GetParamSideCols ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Store side colums in database *****/
|
|
|
|
|
if (Gbl.Usrs.Me.Logged)
|
2015-03-14 17:39:04 +01:00
|
|
|
|
Pre_UpdateSideColsOnUsrDataTable ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Set preferences from current IP *****/
|
2015-03-14 17:39:04 +01:00
|
|
|
|
Pre_SetPrefsFromIP ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Hide left side column ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
void Pre_HideLeftCol (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2014-12-27 13:09:29 +01:00
|
|
|
|
Gbl.Prefs.SideCols &= ~Lay_SHOW_LEFT_COLUMN; // And with 1...101 to hide left column
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Gbl.Usrs.Me.Logged)
|
2015-03-14 17:39:04 +01:00
|
|
|
|
Pre_UpdateSideColsOnUsrDataTable ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Set preferences from current IP *****/
|
2015-03-14 17:39:04 +01:00
|
|
|
|
Pre_SetPrefsFromIP ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Hide right side column **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
void Pre_HideRightCol (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2014-12-27 13:09:29 +01:00
|
|
|
|
Gbl.Prefs.SideCols &= ~Lay_SHOW_RIGHT_COLUMN; // And with 1...110 to hide right column
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Gbl.Usrs.Me.Logged)
|
2015-03-14 17:39:04 +01:00
|
|
|
|
Pre_UpdateSideColsOnUsrDataTable ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Set preferences from current IP *****/
|
2015-03-14 17:39:04 +01:00
|
|
|
|
Pre_SetPrefsFromIP ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Show left side column **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
void Pre_ShowLeftCol (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2014-12-27 13:09:29 +01:00
|
|
|
|
Gbl.Prefs.SideCols |= Lay_SHOW_LEFT_COLUMN; // Or with 10 to show left column
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Gbl.Usrs.Me.Logged)
|
2015-03-14 17:39:04 +01:00
|
|
|
|
Pre_UpdateSideColsOnUsrDataTable ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Set preferences from current IP *****/
|
2015-03-14 17:39:04 +01:00
|
|
|
|
Pre_SetPrefsFromIP ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Show right side column *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
void Pre_ShowRightCol (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2014-12-27 13:09:29 +01:00
|
|
|
|
Gbl.Prefs.SideCols |= Lay_SHOW_RIGHT_COLUMN; // Or with 01 to show right column
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Gbl.Usrs.Me.Logged)
|
2015-03-14 17:39:04 +01:00
|
|
|
|
Pre_UpdateSideColsOnUsrDataTable ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Set preferences from current IP *****/
|
2015-03-14 17:39:04 +01:00
|
|
|
|
Pre_SetPrefsFromIP ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Update layout of side colums on user data table **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
static void Pre_UpdateSideColsOnUsrDataTable (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not update your preference about side columns",
|
|
|
|
|
"UPDATE usr_data SET SideCols=%u"
|
|
|
|
|
" WHERE UsrCod=%ld",
|
|
|
|
|
Gbl.Prefs.SideCols,Gbl.Usrs.Me.UsrDat.UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Get parameter used to show/hide side columns *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
unsigned Pre_GetParamSideCols (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-01-29 21:41:08 +01:00
|
|
|
|
return (unsigned) Par_GetParToUnsignedLong ("SideCols",
|
|
|
|
|
0,
|
|
|
|
|
Lay_SHOW_BOTH_COLUMNS,
|
|
|
|
|
Cfg_DEFAULT_COLUMNS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|