From 05cb59691378b28c8b76c2b532eb9279e0604d66 Mon Sep 17 00:00:00 2001 From: acanas Date: Thu, 2 Dec 2021 08:39:18 +0100 Subject: [PATCH] Version 21.66: Dec 02, 2021 New module swad_photo_shape for user photo shapes. --- Makefile | 7 +- sql/cambios.sql | 4 + sql/swad.sql | 6 +- swad_API.c | 13 +-- swad_account_database.c | 5 +- swad_action.c | 2 +- swad_attendance.c | 36 +++---- swad_autolink.c | 12 +-- swad_browser.c | 38 ++++---- swad_changelog.h | 8 +- swad_connected.c | 24 ++--- swad_database.c | 10 +- swad_enrolment.c | 12 +-- swad_exam_result.c | 12 +-- swad_figure.c | 52 +++++----- swad_figure.h | 2 +- swad_follow.c | 24 ++--- swad_forum.c | 12 +-- swad_global.h | 2 +- swad_language.c | 20 ++++ swad_language.h | 1 + swad_match_result.c | 12 +-- swad_message.c | 62 ++++++------ swad_parameter.c | 4 - swad_photo.c | 24 ++--- swad_photo_shape.c | 142 +++++++++++++++++++++++++++ swad_photo_shape.h | 51 ++++++++++ swad_profile.c | 12 +-- swad_project.c | 12 +-- swad_record.c | 12 +-- swad_setting.c | 110 +++------------------ swad_setting.h | 15 +-- swad_setting_database.c | 22 ++--- swad_setting_database.h | 6 +- swad_statistic.c | 12 +-- swad_test_print.c | 12 +-- swad_text.c | 168 ++++++++++++++++---------------- swad_theme.c | 4 +- swad_theme.h | 1 - swad_timeline_comment.c | 12 +-- swad_timeline_note.c | 12 +-- swad_timeline_user.c | 12 +-- swad_user.c | 209 ++++++++++++++++------------------------ swad_user.h | 3 +- swad_user_database.c | 2 +- 45 files changed, 655 insertions(+), 578 deletions(-) create mode 100644 swad_photo_shape.c create mode 100644 swad_photo_shape.h diff --git a/Makefile b/Makefile index 1cee1b05..71f9ef62 100644 --- a/Makefile +++ b/Makefile @@ -71,9 +71,10 @@ OBJS = swad_account.o swad_account_database.o swad_action.o swad_admin.o \ swad_notification.o swad_notification_database.o \ swad_pagination.o swad_parameter.o swad_password.o \ swad_password_database.o swad_photo.o swad_photo_database.o \ - swad_place.o swad_place_database.o swad_plugin.o swad_plugin_database.o \ - swad_privacy.o swad_profile.o swad_profile_database.o swad_program.o \ - swad_program_database.o swad_project.o swad_project_database.o \ + swad_photo_shape.o swad_place.o swad_place_database.o swad_plugin.o \ + swad_plugin_database.o swad_privacy.o swad_profile.o \ + swad_profile_database.o swad_program.o swad_program_database.o \ + swad_project.o swad_project_database.o \ swad_question.o swad_question_database.o swad_question_import.o \ swad_QR.o \ swad_record.o swad_record_database.o swad_report.o \ diff --git a/sql/cambios.sql b/sql/cambios.sql index 60de10b4..15370955 100644 --- a/sql/cambios.sql +++ b/sql/cambios.sql @@ -13599,6 +13599,10 @@ Llama a: +ALTER TABLE set_ip_settings ADD COLUMN PhotoShape TINYINT NOT NULL DEFAULT 0 AFTER SideCols; +UPDATE set_ip_settings SET PhotoShape=3; +ALTER TABLE usr_data ADD COLUMN PhotoShape TINYINT NOT NULL DEFAULT 0 AFTER SideCols,ADD INDEX (PhotoShape); +UPDATE usr_data SET PhotoShape=3; diff --git a/sql/swad.sql b/sql/swad.sql index 5d2e0c4e..06201b48 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -1291,7 +1291,7 @@ CREATE TABLE IF NOT EXISTS set_ip_settings ( IconSet CHAR(16) NOT NULL, Menu TINYINT NOT NULL DEFAULT 0, SideCols TINYINT NOT NULL, - UsrPhotos TINYINT NOT NULL DEFAULT 0, + PhotoShape TINYINT NOT NULL DEFAULT 0, PRIMARY KEY(IP), INDEX(UsrCod), INDEX(LastChange)); @@ -1626,7 +1626,7 @@ CREATE TABLE IF NOT EXISTS usr_data ( Comments TEXT NOT NULL, Menu TINYINT NOT NULL DEFAULT 0, SideCols TINYINT NOT NULL DEFAULT 3, - UsrPhotos TINYINT NOT NULL DEFAULT 0, + PhotoShape TINYINT NOT NULL DEFAULT 0, ThirdPartyCookies ENUM('N','Y') NOT NULL DEFAULT 'N', NotifNtfEvents INT NOT NULL DEFAULT 0, EmailNtfEvents INT NOT NULL DEFAULT 0, @@ -1647,7 +1647,7 @@ CREATE TABLE IF NOT EXISTS usr_data ( INDEX(CtrCod), INDEX(Menu), INDEX(SideCols), - INDEX(UsrPhotos), + INDEX(PhotoShape), INDEX(ThirdPartyCookies)); -- -- Table usr_duplicated: stores informs of users possibly duplicated diff --git a/swad_API.c b/swad_API.c index 26c8d4e6..14d83153 100644 --- a/swad_API.c +++ b/swad_API.c @@ -3088,10 +3088,8 @@ int swad__getNotifications (struct soap *soap, static int API_GetMyLanguage (struct soap *soap) { - extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES]; MYSQL_RES *mysql_res; MYSQL_ROW row; - Lan_Language_t Lan; bool UsrFound; /***** Get user's language *****/ @@ -3101,15 +3099,7 @@ static int API_GetMyLanguage (struct soap *soap) row = mysql_fetch_row (mysql_res); /* Get language (row[0]) */ - Gbl.Prefs.Language = Lan_LANGUAGE_UNKNOWN; - for (Lan = (Lan_Language_t) 1; - Lan <= (Lan_Language_t) (Lan_NUM_LANGUAGES - 1); - Lan++) - if (!strcasecmp (row[0],Lan_STR_LANG_ID[Lan])) - { - Gbl.Prefs.Language = Lan; - break; - } + Gbl.Prefs.Language = Lan_GetLanguageFromStr (row[0]); if (Gbl.Prefs.Language == Lan_LANGUAGE_UNKNOWN) // Language stored in database is unknown Gbl.Prefs.Language = Cfg_DEFAULT_LANGUAGE; } @@ -3593,7 +3583,6 @@ int swad__getTests (struct soap *soap, static int API_GetTstTags (struct soap *soap, long CrsCod,struct swad__getTestsOutput *getTestsOut) { - extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES]; MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned NumTags; diff --git a/swad_account_database.c b/swad_account_database.c index 7cbe68ba..b9598db1 100644 --- a/swad_account_database.c +++ b/swad_account_database.c @@ -30,6 +30,7 @@ #include "swad_calendar.h" #include "swad_database.h" #include "swad_global.h" +#include "swad_photo.h" /*****************************************************************************/ /************** External global variables from others modules ****************/ @@ -115,7 +116,7 @@ long Acc_DB_CreateNewUsr (const struct UsrData *UsrDat) "CtyCod," "LocalPhone,FamilyPhone," "Birthday,Comments," - "Menu,SideCols,UsrPhotos," + "Menu,SideCols,PhotoShape," "NotifNtfEvents,EmailNtfEvents)" " VALUES" " ('%s','%s'," @@ -149,7 +150,7 @@ long Acc_DB_CreateNewUsr (const struct UsrData *UsrDat) "", (unsigned) Mnu_MENU_DEFAULT, (unsigned) Cfg_DEFAULT_COLUMNS, - (unsigned) Set_USR_PHOTOS_DEFAULT); + (unsigned) Pho_SHAPE_DEFAULT); } /*****************************************************************************/ diff --git a/swad_action.c b/swad_action.c index 96ae8698..42d37393 100644 --- a/swad_action.c +++ b/swad_action.c @@ -1810,7 +1810,7 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = [ActChgCol ] = { 674,-1,TabUnk,ActReqEdiSet ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Set_ChangeSideCols ,Set_EditSettings ,NULL}, [ActChgIco ] = {1092,-1,TabUnk,ActReqEdiSet ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Ico_ChangeIconSet ,Set_EditSettings ,NULL}, [ActChgMnu ] = {1243,-1,TabUnk,ActReqEdiSet ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Mnu_ChangeMenu ,Set_EditSettings ,NULL}, - [ActChgUsrPho ] = {1917,-1,TabUnk,ActReqEdiSet ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Set_ChangeUsrPhotos ,Set_EditSettings ,NULL}, + [ActChgUsrPho ] = {1917,-1,TabUnk,ActReqEdiSet ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Pho_ChangePhotoShape ,Set_EditSettings ,NULL}, [ActChgPriPho ] = { 774,-1,TabUnk,ActReqEdiSet ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Pho_ChangePhotoVisibility ,NULL}, [ActChgBasPriPrf ] = {1404,-1,TabUnk,ActReqEdiSet ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Prf_ChangeBasicProfileVis ,NULL}, [ActChgExtPriPrf ] = {1765,-1,TabUnk,ActReqEdiSet ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Prf_ChangeExtendedProfileVis ,NULL}, diff --git a/swad_attendance.c b/swad_attendance.c index ea9dc6d6..5362cbb9 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -1680,12 +1680,12 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr, struct UsrData *UsrDat, struct Att_Event *Event) { - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC45x60", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE45x60", - [Set_USR_PHOTO_OVAL ] = "PHOTOO45x60", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR45x60", + [Pho_SHAPE_CIRCLE ] = "PHOTOC45x60", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE45x60", + [Pho_SHAPE_OVAL ] = "PHOTOO45x60", + [Pho_SHAPE_RECTANGLE] = "PHOTOR45x60", }; bool Present; char CommentStd[Cns_MAX_BYTES_TEXT + 1]; @@ -1757,7 +1757,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr, { HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); } @@ -2915,12 +2915,12 @@ static void Att_WriteTableHeadSeveralAttEvents (const struct Att_Events *Events) static void Att_WriteRowUsrSeveralAttEvents (const struct Att_Events *Events, unsigned NumUsr,struct UsrData *UsrDat) { - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC21x28", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE21x28", - [Set_USR_PHOTO_OVAL ] = "PHOTOO21x28", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR21x28", + [Pho_SHAPE_CIRCLE ] = "PHOTOC21x28", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE21x28", + [Pho_SHAPE_OVAL ] = "PHOTOO21x28", + [Pho_SHAPE_RECTANGLE] = "PHOTOR21x28", }; unsigned NumAttEvent; bool Present; @@ -2941,7 +2941,7 @@ static void Att_WriteRowUsrSeveralAttEvents (const struct Att_Events *Events, { HTM_TD_Begin ("class=\"LM COLOR%u\"",Gbl.RowEvenOdd); Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); } @@ -3076,12 +3076,12 @@ static void Att_ListAttEventsForAStd (const struct Att_Events *Events, { extern const char *Txt_Student_comment; extern const char *Txt_Teachers_comment; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC21x28", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE21x28", - [Set_USR_PHOTO_OVAL ] = "PHOTOO21x28", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR21x28", + [Pho_SHAPE_CIRCLE ] = "PHOTOC21x28", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE21x28", + [Pho_SHAPE_OVAL ] = "PHOTOO21x28", + [Pho_SHAPE_RECTANGLE] = "PHOTOR21x28", }; unsigned NumAttEvent; unsigned UniqueId; @@ -3106,7 +3106,7 @@ static void Att_ListAttEventsForAStd (const struct Att_Events *Events, /***** Show student's photo *****/ HTM_TD_Begin ("colspan=\"2\" class=\"RM COLOR%u\"",Gbl.RowEvenOdd); Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); diff --git a/swad_autolink.c b/swad_autolink.c index 8a7bbca9..4964097e 100644 --- a/swad_autolink.c +++ b/swad_autolink.c @@ -461,12 +461,12 @@ static ALn_LinkType_t ALn_CheckNickname (char **PtrSrc,char PrevCh, struct ALn_Link **LastLink) { extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES]; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC12x16", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE12x16", - [Set_USR_PHOTO_OVAL ] = "PHOTOO12x16", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR12x16", + [Pho_SHAPE_CIRCLE ] = "PHOTOC12x16", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE12x16", + [Pho_SHAPE_OVAL ] = "PHOTOO12x16", + [Pho_SHAPE_RECTANGLE] = "PHOTOR12x16", }; char Ch; size_t Length; @@ -568,7 +568,7 @@ static ALn_LinkType_t ALn_CheckNickname (char **PtrSrc,char PrevCh, ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&UsrDat,PhotoURL); Pho_BuildHTMLUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL : NULL, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, &CaptionStr, &ImgStr); if (asprintf (&(*Link)->NickAnchor[2].Str, diff --git a/swad_browser.c b/swad_browser.c index 91eb4476..87b48721 100644 --- a/swad_browser.c +++ b/swad_browser.c @@ -3229,18 +3229,18 @@ static void Brw_ShowDataOwnerAsgWrk (struct UsrData *UsrDat) [Rol_NET] = ActSeeRecOneTch, [Rol_TCH] = ActSeeRecOneTch, }; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC60x80", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE60x80", - [Set_USR_PHOTO_OVAL ] = "PHOTOO60x80", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR60x80", + [Pho_SHAPE_CIRCLE ] = "PHOTOC60x80", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE60x80", + [Pho_SHAPE_OVAL ] = "PHOTOO60x80", + [Pho_SHAPE_RECTANGLE] = "PHOTOR60x80", }; /***** Show user's photo *****/ HTM_TD_Begin ("class=\"OWNER_WORKS_PHOTO\""); Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); @@ -5453,12 +5453,12 @@ static void Brw_WriteFileSizeAndDate (struct FileMetadata *FileMetadata) static void Brw_WriteFileOrFolderPublisher (unsigned Level,long UsrCod) { extern const char *Txt_Unknown_or_without_photo; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC15x20B", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE15x20B", - [Set_USR_PHOTO_OVAL ] = "PHOTOO15x20B", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR15x20B", + [Pho_SHAPE_CIRCLE ] = "PHOTOC15x20B", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE15x20B", + [Pho_SHAPE_OVAL ] = "PHOTOO15x20B", + [Pho_SHAPE_RECTANGLE] = "PHOTOR15x20B", }; bool ShowUsr = false; struct UsrData UsrDat; @@ -5480,11 +5480,11 @@ static void Brw_WriteFileOrFolderPublisher (unsigned Level,long UsrCod) if (ShowUsr) /***** Show photo *****/ Pho_ShowUsrPhotoIfAllowed (&UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); else Ico_PutIcon ("usr_bl.jpg",Txt_Unknown_or_without_photo, - ClassPhoto[Gbl.Prefs.UsrPhotos]); + ClassPhoto[Gbl.Prefs.PhotoShape]); HTM_TD_End (); @@ -7845,12 +7845,12 @@ void Brw_ShowFileMetadata (void) extern const char *Txt_user[Usr_NUM_SEXS]; extern const char *Txt_users[Usr_NUM_SEXS]; extern const char *Txt_Save_file_properties; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC15x20", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE15x20", - [Set_USR_PHOTO_OVAL ] = "PHOTOO15x20", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR15x20", + [Pho_SHAPE_CIRCLE ] = "PHOTOC15x20", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE15x20", + [Pho_SHAPE_OVAL ] = "PHOTOO15x20", + [Pho_SHAPE_RECTANGLE] = "PHOTOR15x20", }; struct FileMetadata FileMetadata; struct UsrData PublisherUsrDat; @@ -8016,7 +8016,7 @@ void Brw_ShowFileMetadata (void) { /* Show photo */ Pho_ShowUsrPhotoIfAllowed (&PublisherUsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); /* Write name */ diff --git a/swad_changelog.h b/swad_changelog.h index f223f5fe..63abf2be 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -602,13 +602,19 @@ TODO: FIX BUG, URGENT! En las fechas como par TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo. */ -#define Log_PLATFORM_VERSION "SWAD 21.65.1 (2021-12-01)" +#define Log_PLATFORM_VERSION "SWAD 21.66 (2021-12-02)" #define CSS_FILE "swad21.65.1.css" #define JS_FILE "swad21.59.js" /* TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams + Version 21.66: Dec 02, 2021 New module swad_photo_shape for user photo shapes. (320876 lines) + Version 21.65.1: Dec 01, 2021 New shape of user photos. (320833 lines) + 2 changes necessary in database: +ALTER TABLE set_ip_settings CHANGE COLUMN UsrPhotos PhotoShape TINYINT NOT NULL DEFAULT 0; +ALTER TABLE usr_data CHANGE COLUMN UsrPhotos PhotoShape TINYINT NOT NULL DEFAULT 0; + Version 21.65.1: Dec 01, 2021 New shape of user photos. (320833 lines) 2 changes necessary in database: UPDATE set_ip_settings SET UsrPhotos=3 WHERE UsrPhotos=2; diff --git a/swad_connected.c b/swad_connected.c index e0ddcc00..a1756d81 100644 --- a/swad_connected.c +++ b/swad_connected.c @@ -556,12 +556,12 @@ static void Con_WriteRowConnectedUsrOnRightColumn (Rol_Role_t Role) [Rol_NET] = ActSeeRecOneTch, [Rol_TCH] = ActSeeRecOneTch, }; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC21x28", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE21x28", - [Set_USR_PHOTO_OVAL ] = "PHOTOO21x28", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR21x28", + [Pho_SHAPE_CIRCLE ] = "PHOTOC21x28", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE21x28", + [Pho_SHAPE_OVAL ] = "PHOTOO21x28", + [Pho_SHAPE_RECTANGLE] = "PHOTOR21x28", }; const char *ClassTxt; const char *ClassLink; @@ -595,7 +595,7 @@ static void Con_WriteRowConnectedUsrOnRightColumn (Rol_Role_t Role) /***** Show photo *****/ HTM_TD_Begin ("class=\"CON_PHOTO COLOR%u\"",Gbl.RowEvenOdd); Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, true); HTM_TD_End (); @@ -658,12 +658,12 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R [Rol_NET] = ActSeeRecOneTch, [Rol_TCH] = ActSeeRecOneTch, }; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC21x28", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE21x28", - [Set_USR_PHOTO_OVAL ] = "PHOTOO21x28", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR21x28", + [Pho_SHAPE_CIRCLE ] = "PHOTOC21x28", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE21x28", + [Pho_SHAPE_OVAL ] = "PHOTOO21x28", + [Pho_SHAPE_RECTANGLE] = "PHOTOR21x28", }; MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -712,7 +712,7 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R /***** Show photo *****/ HTM_TD_Begin ("class=\"CON_PHOTO COLOR%u\"",Gbl.RowEvenOdd); Pho_ShowUsrPhotoIfAllowed (&UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); diff --git a/swad_database.c b/swad_database.c index ef856374..ab38e872 100644 --- a/swad_database.c +++ b/swad_database.c @@ -2701,7 +2701,7 @@ mysql> DESCRIBE set_ip_settings; | IconSet | char(16) | NO | | NULL | | | Menu | tinyint | NO | | 0 | | | SideCols | tinyint | NO | | NULL | | -| UsrPhotos | tinyint | NO | | 0 | | +| PhotoShape | tinyint | NO | | 0 | | +----------------+----------+------+-----+---------+-------+ 10 rows in set (0,01 sec) */ @@ -2715,7 +2715,7 @@ mysql> DESCRIBE set_ip_settings; "IconSet CHAR(16) NOT NULL," // Ico_MAX_BYTES_ICON_SET_ID "Menu TINYINT NOT NULL DEFAULT 0," "SideCols TINYINT NOT NULL," - "UsrPhotos TINYINT NOT NULL DEFAULT 0," + "PhotoShape TINYINT NOT NULL DEFAULT 0," "PRIMARY KEY (IP)," "INDEX(UsrCod)," "INDEX(LastChange))"); @@ -3395,7 +3395,7 @@ mysql> DESCRIBE usr_data; | Comments | text | NO | | NULL | | | Menu | tinyint | NO | MUL | 0 | | | SideCols | tinyint | NO | MUL | 3 | | -| UsrPhotos | tinyint | NO | MUL | 0 | | +| PhotoShape | tinyint | NO | MUL | 0 | | | ThirdPartyCookies | enum('N','Y') | NO | MUL | N | | | NotifNtfEvents | int | NO | | 0 | | | EmailNtfEvents | int | NO | | 0 | | @@ -3435,7 +3435,7 @@ mysql> DESCRIBE usr_data; "Comments TEXT NOT NULL," // Cns_MAX_BYTES_TEXT "Menu TINYINT NOT NULL DEFAULT 0," "SideCols TINYINT NOT NULL DEFAULT 3," - "UsrPhotos TINYINT NOT NULL DEFAULT 0," + "PhotoShape TINYINT NOT NULL DEFAULT 0," "ThirdPartyCookies ENUM('N','Y') NOT NULL DEFAULT 'N'," "NotifNtfEvents INT NOT NULL DEFAULT 0," "EmailNtfEvents INT NOT NULL DEFAULT 0," @@ -3456,7 +3456,7 @@ mysql> DESCRIBE usr_data; "INDEX(CtrCod)," "INDEX(Menu)," "INDEX(SideCols)," - "INDEX(UsrPhotos)," + "INDEX(PhotoShape)," "INDEX(ThirdPartyCookies))"); /***** Table usr_duplicated *****/ diff --git a/swad_enrolment.c b/swad_enrolment.c index ae5ab051..4f68d0fe 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -2074,12 +2074,12 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) extern const char *Txt_Register; extern const char *Txt_Reject; extern const char *Txt_No_enrolment_requests; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC21x28", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE21x28", - [Set_USR_PHOTO_OVAL ] = "PHOTOO21x28", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR21x28", + [Pho_SHAPE_CIRCLE ] = "PHOTOC21x28", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE21x28", + [Pho_SHAPE_OVAL ] = "PHOTOO21x28", + [Pho_SHAPE_RECTANGLE] = "PHOTOR21x28", }; MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -2243,7 +2243,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) /***** User photo *****/ HTM_TD_Begin ("class=\"DAT CT\" style=\"width:22px;\""); Pho_ShowUsrPhotoIfAllowed (&UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); diff --git a/swad_exam_result.c b/swad_exam_result.c index e76cb24b..c7d033ed 100644 --- a/swad_exam_result.c +++ b/swad_exam_result.c @@ -1483,12 +1483,12 @@ static void ExaRes_ComputeValidPrintScore (struct ExaPrn_Print *Print) void ExaRes_ShowExamResultUser (struct UsrData *UsrDat) { extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC45x60", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE45x60", - [Set_USR_PHOTO_OVAL ] = "PHOTOO45x60", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR45x60", + [Pho_SHAPE_CIRCLE ] = "PHOTOC45x60", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE45x60", + [Pho_SHAPE_OVAL ] = "PHOTOO45x60", + [Pho_SHAPE_RECTANGLE] = "PHOTOR45x60", }; /***** Row begin *****/ @@ -1509,7 +1509,7 @@ void ExaRes_ShowExamResultUser (struct UsrData *UsrDat) HTM_TxtF (", %s",UsrDat->FrstName); HTM_BR (); Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); diff --git a/swad_figure.c b/swad_figure.c index 184a1ec6..a65e4d08 100644 --- a/swad_figure.c +++ b/swad_figure.c @@ -211,7 +211,7 @@ static void Fig_GetAndShowNumUsrsPerIconSet (void); static void Fig_GetAndShowNumUsrsPerMenu (void); static void Fig_GetAndShowNumUsrsPerTheme (void); static void Fig_GetAndShowNumUsrsPerSideColumns (void); -static void Fig_GetAndShowNumUsrsPerUserPhotos (void); +static void Fig_GetAndShowNumUsrsPerPhotoShape (void); /*****************************************************************************/ /************************** Show use of the platform *************************/ @@ -372,7 +372,7 @@ void Fig_ShowFigures (void) [Fig_MENUS ] = Fig_GetAndShowNumUsrsPerMenu, [Fig_THEMES ] = Fig_GetAndShowNumUsrsPerTheme, [Fig_SIDE_COLUMNS ] = Fig_GetAndShowNumUsrsPerSideColumns, - [Fig_USER_PHOTOS ] = Fig_GetAndShowNumUsrsPerUserPhotos, + [Fig_PHOTO_SHAPES ] = Fig_GetAndShowNumUsrsPerPhotoShape, [Fig_PRIVACY ] = Fig_GetAndShowNumUsrsPerPrivacy, [Fig_COOKIES ] = Fig_GetAndShowNumUsrsPerCookies, }; @@ -3974,28 +3974,28 @@ static void Fig_GetAndShowNumUsrsPerSideColumns (void) /****** Get and show number of users who have chosen a user photo shape ******/ /*****************************************************************************/ -static void Fig_GetAndShowNumUsrsPerUserPhotos (void) +static void Fig_GetAndShowNumUsrsPerPhotoShape (void) { extern const char *Hlp_ANALYTICS_Figures_columns; extern const char *Txt_FIGURE_TYPES[Fig_NUM_FIGURES]; extern const char *Txt_User_photos; extern const char *Txt_Number_of_users; extern const char *Txt_PERCENT_of_users; - extern const char *Txt_USER_PHOTOS[Set_NUM_USR_PHOTOS]; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + extern const char *Txt_PHOTO_SHAPES[Pho_NUM_SHAPES]; + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC15x20B", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE15x20B", - [Set_USR_PHOTO_OVAL ] = "PHOTOO15x20B", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR15x20B", + [Pho_SHAPE_CIRCLE ] = "PHOTOC15x20B", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE15x20B", + [Pho_SHAPE_OVAL ] = "PHOTOO15x20B", + [Pho_SHAPE_RECTANGLE] = "PHOTOR15x20B", }; - Set_UsrPhotos_t UsrPhotos; + Pho_Shape_t Shape; char *SubQuery; - unsigned NumUsrs[Set_NUM_USR_PHOTOS]; + unsigned NumUsrs[Pho_NUM_SHAPES]; unsigned NumUsrsTotal = 0; /***** Begin box and table *****/ - Box_BoxTableBegin (NULL,Txt_FIGURE_TYPES[Fig_USER_PHOTOS], + Box_BoxTableBegin (NULL,Txt_FIGURE_TYPES[Fig_PHOTO_SHAPES], NULL,NULL, Hlp_ANALYTICS_Figures_columns,Box_NOT_CLOSABLE,2); @@ -4007,39 +4007,39 @@ static void Fig_GetAndShowNumUsrsPerUserPhotos (void) HTM_TR_End (); /***** For each user photo shape... *****/ - for (UsrPhotos = (Set_UsrPhotos_t) 0; - UsrPhotos <= (Set_UsrPhotos_t) (Set_NUM_USR_PHOTOS - 1); - UsrPhotos++) + for (Shape = (Pho_Shape_t) 0; + Shape <= (Pho_Shape_t) (Pho_NUM_SHAPES - 1); + Shape++) { /* Get the number of users who have chosen this layout of columns from database */ - if (asprintf (&SubQuery,"usr_data.UsrPhotos=%u", - (unsigned) UsrPhotos) < 0) + if (asprintf (&SubQuery,"usr_data.PhotoShape=%u", + (unsigned) Shape) < 0) Err_NotEnoughMemoryExit (); - NumUsrs[UsrPhotos] = Usr_DB_GetNumUsrsWhoChoseAnOption (SubQuery); + NumUsrs[Shape] = Usr_DB_GetNumUsrsWhoChoseAnOption (SubQuery); free (SubQuery); /* Update total number of users */ - NumUsrsTotal += NumUsrs[UsrPhotos]; + NumUsrsTotal += NumUsrs[Shape]; } /***** Write number of users who have chosen this user photo shape *****/ - for (UsrPhotos = (Set_UsrPhotos_t) 0; - UsrPhotos <= (Set_UsrPhotos_t) (Set_NUM_USR_PHOTOS - 1); - UsrPhotos++) + for (Shape = (Pho_Shape_t) 0; + Shape <= (Pho_Shape_t) (Pho_NUM_SHAPES - 1); + Shape++) { HTM_TR_Begin (NULL); HTM_TD_Begin ("class=\"CM\""); - HTM_IMG (Cfg_URL_ICON_PUBLIC,"user.svg",Txt_USER_PHOTOS[UsrPhotos], - "class=\"%s\"",ClassPhoto[UsrPhotos]); + HTM_IMG (Cfg_URL_ICON_PUBLIC,"user.svg",Txt_PHOTO_SHAPES[Shape], + "class=\"%s\"",ClassPhoto[Shape]); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumUsrs[UsrPhotos]); + HTM_Unsigned (NumUsrs[Shape]); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[UsrPhotos] * 100.0 / + HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[Shape] * 100.0 / (double) NumUsrsTotal : 0.0); HTM_TD_End (); diff --git a/swad_figure.h b/swad_figure.h index 63b42b3c..63518938 100644 --- a/swad_figure.h +++ b/swad_figure.h @@ -65,7 +65,7 @@ typedef enum Fig_MENUS, // Number of users per menu Fig_THEMES, // Number of users per theme Fig_SIDE_COLUMNS, // Number of users per layout of columns - Fig_USER_PHOTOS, // Number of users per user photo shape + Fig_PHOTO_SHAPES, // Number of users per user photo shape Fig_PRIVACY, // Number of users per privacity Fig_COOKIES, // Number of users per acceptation of cookies } Fig_FigureType_t; diff --git a/swad_follow.c b/swad_follow.c index 22065cd9..2180dcb7 100644 --- a/swad_follow.c +++ b/swad_follow.c @@ -612,12 +612,12 @@ static void Fol_ListFollowersUsr (struct UsrData *UsrDat) static void Fol_ShowFollowedOrFollower (struct UsrData *UsrDat) { extern const char *Txt_Another_user_s_profile; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC60x80", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE60x80", - [Set_USR_PHOTO_OVAL ] = "PHOTOO60x80", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR60x80", + [Pho_SHAPE_CIRCLE ] = "PHOTOC60x80", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE60x80", + [Pho_SHAPE_OVAL ] = "PHOTOO60x80", + [Pho_SHAPE_RECTANGLE] = "PHOTOR60x80", }; bool Visible = Pri_ShowingIsAllowed (UsrDat->BaPrfVisibility,UsrDat); @@ -625,7 +625,7 @@ static void Fol_ShowFollowedOrFollower (struct UsrData *UsrDat) HTM_TD_Begin ("class=\"FOLLOW_PHOTO\""); if (Visible) Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); @@ -671,12 +671,12 @@ static void Fol_ShowFollowedOrFollower (struct UsrData *UsrDat) static void Fol_WriteRowUsrToFollowOnRightColumn (struct UsrData *UsrDat) { extern const char *Txt_Another_user_s_profile; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC21x28", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE21x28", - [Set_USR_PHOTO_OVAL ] = "PHOTOO21x28", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR21x28", + [Pho_SHAPE_CIRCLE ] = "PHOTOC21x28", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE21x28", + [Pho_SHAPE_OVAL ] = "PHOTOO21x28", + [Pho_SHAPE_RECTANGLE] = "PHOTOR21x28", }; bool Visible = Pri_ShowingIsAllowed (UsrDat->BaPrfVisibility,UsrDat); @@ -686,7 +686,7 @@ static void Fol_WriteRowUsrToFollowOnRightColumn (struct UsrData *UsrDat) HTM_TD_Begin ("class=\"CON_PHOTO COLOR%u\"",Gbl.RowEvenOdd); if (Visible) Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); diff --git a/swad_forum.c b/swad_forum.c index 0b0cb0ee..5c0accd6 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -2134,12 +2134,12 @@ static void For_ListForumThrs (struct For_Forums *Forums, extern const char *Txt_Thread_with_posts_from_you; extern const char *Txt_There_are_new_posts; extern const char *Txt_No_new_posts; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC15x20", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE15x20", - [Set_USR_PHOTO_OVAL ] = "PHOTOO15x20", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR15x20", + [Pho_SHAPE_CIRCLE ] = "PHOTOC15x20", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE15x20", + [Pho_SHAPE_OVAL ] = "PHOTOO15x20", + [Pho_SHAPE_RECTANGLE] = "PHOTOR15x20", }; unsigned NumThr; unsigned NumThrInScreen; // From 0 to Pag_ITEMS_PER_PAGE-1 @@ -2188,7 +2188,7 @@ static void For_ListForumThrs (struct For_Forums *Forums, Gbl.Usrs.Me.PhotoURL[0] ? NULL : "usr_bl.jpg", Txt_Thread_with_posts_from_you, - "class=\"%s\"",ClassPhoto[Gbl.Prefs.UsrPhotos]); + "class=\"%s\"",ClassPhoto[Gbl.Prefs.PhotoShape]); HTM_TD_End (); HTM_TD_Begin ("class=\"CONTEXT_COL %s\"",BgColor); diff --git a/swad_global.h b/swad_global.h index acbb67d4..896b8b6a 100644 --- a/swad_global.h +++ b/swad_global.h @@ -149,7 +149,7 @@ struct Globals Mnu_Menu_t Menu; The_Theme_t Theme; unsigned SideCols; - Set_UsrPhotos_t UsrPhotos; + Pho_Shape_t PhotoShape; char URLTheme[PATH_MAX + 1]; char URLIconSet[PATH_MAX + 1]; } Prefs; diff --git a/swad_language.c b/swad_language.c index c338016e..f945f08d 100644 --- a/swad_language.c +++ b/swad_language.c @@ -25,6 +25,8 @@ /********************************** Headers **********************************/ /*****************************************************************************/ +#include // For strcasecmp + #include "swad_box.h" #include "swad_database.h" #include "swad_figure.h" @@ -214,3 +216,21 @@ Lan_Language_t Lan_GetParamLanguage (void) Lan_NUM_LANGUAGES, (unsigned long) Txt_Current_CGI_SWAD_Language); } + +/*****************************************************************************/ +/************************** Get language from string *************************/ +/*****************************************************************************/ + +Lan_Language_t Lan_GetLanguageFromStr (const char *Str) + { + extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES]; + Lan_Language_t Lan; + + for (Lan = (Lan_Language_t) 1; + Lan <= (Lan_Language_t) Lan_NUM_LANGUAGES; + Lan++) + if (!strcasecmp (Str,Lan_STR_LANG_ID[Lan])) + return Lan; + + return Lan_LANGUAGE_UNKNOWN; + } diff --git a/swad_language.h b/swad_language.h index a74c723a..2118782a 100644 --- a/swad_language.h +++ b/swad_language.h @@ -61,5 +61,6 @@ void Lan_ChangeLanguage (void); void Lan_UpdateMyLanguageToCurrentLanguage (void); Lan_Language_t Lan_GetParamLanguage (void); +Lan_Language_t Lan_GetLanguageFromStr (const char *Str); #endif diff --git a/swad_match_result.c b/swad_match_result.c index 4e454e56..5e658ea7 100644 --- a/swad_match_result.c +++ b/swad_match_result.c @@ -1041,12 +1041,12 @@ void MchRes_ShowOneMchResult (void) extern const char *Txt_Score; extern const char *Txt_Grade; extern const char *Txt_Tags; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC45x60", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE45x60", - [Set_USR_PHOTO_OVAL ] = "PHOTOO45x60", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR45x60", + [Pho_SHAPE_CIRCLE ] = "PHOTOC45x60", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE45x60", + [Pho_SHAPE_OVAL ] = "PHOTOO45x60", + [Pho_SHAPE_RECTANGLE] = "PHOTOR45x60", }; struct Gam_Games Games; struct Gam_Game Game; @@ -1133,7 +1133,7 @@ void MchRes_ShowOneMchResult (void) HTM_TxtF (", %s",UsrDat->FrstName); HTM_BR (); Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); diff --git a/swad_message.c b/swad_message.c index 341d69f7..19c8f360 100644 --- a/swad_message.c +++ b/swad_message.c @@ -479,17 +479,17 @@ static void Msg_PutHiddenParamsSubjectAndContent (void) static void Msg_ShowOneUniqueRecipient (void) { - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC21x28", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE21x28", - [Set_USR_PHOTO_OVAL ] = "PHOTOO21x28", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR21x28", + [Pho_SHAPE_CIRCLE ] = "PHOTOC21x28", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE21x28", + [Pho_SHAPE_OVAL ] = "PHOTOO21x28", + [Pho_SHAPE_RECTANGLE] = "PHOTOR21x28", }; /***** Show user's photo *****/ Pho_ShowUsrPhotoIfAllowed (&Gbl.Usrs.Other.UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); /****** Write user's IDs ******/ @@ -2291,12 +2291,12 @@ static void Msg_WriteSentOrReceivedMsgSubject (struct Msg_Messages *Messages, void Msg_WriteMsgAuthor (struct UsrData *UsrDat,bool Enabled,const char *BgColor) { extern const char *Txt_Unknown_or_without_photo; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC30x40", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE30x40", - [Set_USR_PHOTO_OVAL ] = "PHOTOO30x40", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR30x40", + [Pho_SHAPE_CIRCLE ] = "PHOTOC30x40", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE30x40", + [Pho_SHAPE_OVAL ] = "PHOTOO30x40", + [Pho_SHAPE_RECTANGLE] = "PHOTOR30x40", }; bool WriteAuthor; @@ -2319,11 +2319,11 @@ void Msg_WriteMsgAuthor (struct UsrData *UsrDat,bool Enabled,const char *BgColor if (WriteAuthor) Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); else Ico_PutIcon ("usr_bl.jpg",Txt_Unknown_or_without_photo, - ClassPhoto[Gbl.Prefs.UsrPhotos]); + ClassPhoto[Gbl.Prefs.PhotoShape]); HTM_TD_End (); @@ -2459,12 +2459,12 @@ static void Msg_WriteMsgFrom (struct Msg_Messages *Messages, extern const char *Txt_MSG_Sent; extern const char *Txt_MSG_Sent_and_deleted; extern const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC21x28", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE21x28", - [Set_USR_PHOTO_OVAL ] = "PHOTOO21x28", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR21x28", + [Pho_SHAPE_CIRCLE ] = "PHOTOC21x28", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE21x28", + [Pho_SHAPE_OVAL ] = "PHOTOO21x28", + [Pho_SHAPE_RECTANGLE] = "PHOTOR21x28", }; HTM_TABLE_Begin (NULL); @@ -2482,7 +2482,7 @@ static void Msg_WriteMsgFrom (struct Msg_Messages *Messages, /***** Put user's photo *****/ HTM_TD_Begin ("class=\"CM\" style=\"width:30px;\""); Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); @@ -2535,12 +2535,12 @@ static void Msg_WriteMsgTo (struct Msg_Messages *Messages,long MsgCod) [Msg_RECEIVED] = ActSeeRcvMsg, [Msg_SENT ] = ActSeeSntMsg, }; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC21x28", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE21x28", - [Set_USR_PHOTO_OVAL ] = "PHOTOO21x28", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR21x28", + [Pho_SHAPE_CIRCLE ] = "PHOTOC21x28", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE21x28", + [Pho_SHAPE_OVAL ] = "PHOTOO21x28", + [Pho_SHAPE_RECTANGLE] = "PHOTOR21x28", }; MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -2623,7 +2623,7 @@ static void Msg_WriteMsgTo (struct Msg_Messages *Messages,long MsgCod) false); Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL : NULL, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); @@ -2879,12 +2879,12 @@ void Msg_ListBannedUsrs (void) extern const char *Txt_You_have_not_banned_any_sender; extern const char *Txt_Banned_users; extern const char *Txt_Sender_banned_click_to_unban_him; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC21x28", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE21x28", - [Set_USR_PHOTO_OVAL ] = "PHOTOO21x28", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR21x28", + [Pho_SHAPE_CIRCLE ] = "PHOTOC21x28", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE21x28", + [Pho_SHAPE_OVAL ] = "PHOTOO21x28", + [Pho_SHAPE_RECTANGLE] = "PHOTOR21x28", }; MYSQL_RES *mysql_res; unsigned NumUsr; @@ -2928,7 +2928,7 @@ void Msg_ListBannedUsrs (void) /* Show photo */ HTM_TD_Begin ("class=\"LM\" style=\"width:30px;\""); Pho_ShowUsrPhotoIfAllowed (&UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); diff --git a/swad_parameter.c b/swad_parameter.c index 067d37a2..a155df98 100644 --- a/swad_parameter.c +++ b/swad_parameter.c @@ -784,10 +784,6 @@ void Par_GetMainParams (void) if (!Gbl.Session.IsOpen) // When no session open (no logged user)... { - /***** Try to get settings changed from current IP *****/ - if (Gbl.Prefs.Theme == The_THEME_UNKNOWN) - Gbl.Prefs.Theme = The_THEME_DEFAULT; - /***** Set path of theme and path of icon set *****/ snprintf (URL,sizeof (URL),"%s/%s", Cfg_URL_ICON_THEMES_PUBLIC,The_ThemeId[Gbl.Prefs.Theme ]); diff --git a/swad_photo.c b/swad_photo.c index a2dc46ad..72dda8d7 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -421,12 +421,12 @@ void Pho_ReqRemoveMyPhoto (void) extern const char *Txt_Do_you_really_want_to_remove_your_photo; extern const char *Txt_Remove_photo; extern const char *Txt_The_photo_no_longer_exists; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOR186x248", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOR186x248", - [Set_USR_PHOTO_OVAL ] = "PHOTOR186x248", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR186x248", + [Pho_SHAPE_CIRCLE ] = "PHOTOR186x248", + [Pho_SHAPE_ELLIPSE ] = "PHOTOR186x248", + [Pho_SHAPE_OVAL ] = "PHOTOR186x248", + [Pho_SHAPE_RECTANGLE] = "PHOTOR186x248", }; /***** Show current photo and help message *****/ @@ -438,7 +438,7 @@ void Pho_ReqRemoveMyPhoto (void) /* Show current photo */ Pho_ShowUsrPhoto (&Gbl.Usrs.Me.UsrDat,Gbl.Usrs.Me.PhotoURL, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_NO_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_NO_ZOOM, false); /* End alert */ @@ -498,12 +498,12 @@ void Pho_ReqRemoveUsrPhoto (void) [Rol_INS_ADM] = ActRemOthPho, [Rol_SYS_ADM] = ActRemOthPho, }; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC186x248", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE186x248", - [Set_USR_PHOTO_OVAL ] = "PHOTOO186x248", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR186x248", + [Pho_SHAPE_CIRCLE ] = "PHOTOC186x248", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE186x248", + [Pho_SHAPE_OVAL ] = "PHOTOO186x248", + [Pho_SHAPE_RECTANGLE] = "PHOTOR186x248", }; char PhotoURL[PATH_MAX + 1]; @@ -527,7 +527,7 @@ void Pho_ReqRemoveUsrPhoto (void) /* Show current photo */ Pho_ShowUsrPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_NO_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_NO_ZOOM, false); /* End alert */ diff --git a/swad_photo_shape.c b/swad_photo_shape.c new file mode 100644 index 00000000..5ebe3240 --- /dev/null +++ b/swad_photo_shape.c @@ -0,0 +1,142 @@ +// swad_photo_shape.h: User photo shape + +/* + 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. + Copyright (C) 1999-2021 Antonio Cañas Vargas + + 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 . +*/ +/*****************************************************************************/ +/********************************* Headers ***********************************/ +/*****************************************************************************/ + +#include // For NULL + +#include "swad_action.h" +#include "swad_config.h" +#include "swad_figure.h" +#include "swad_form.h" +#include "swad_global.h" +#include "swad_photo_shape.h" +#include "swad_setting_database.h" + +/*****************************************************************************/ +/************** External global variables from others modules ****************/ +/*****************************************************************************/ + +extern struct Globals Gbl; + +/*****************************************************************************/ +/***************************** Private prototypes ****************************/ +/*****************************************************************************/ + +static void Pho_PutIconsPhotoShape (__attribute__((unused)) void *Args); + +/*****************************************************************************/ +/******************* Put icons to select user photo shape ********************/ +/*****************************************************************************/ + +void Pho_PutIconsToSelectPhotoShape (void) + { + extern const char *Hlp_PROFILE_Settings_user_photos; + extern const char *Txt_User_photos; + extern const char *Txt_PHOTO_SHAPES[Pho_NUM_SHAPES]; + static const char *ClassPhoto[Pho_NUM_SHAPES] = + { + [Pho_SHAPE_CIRCLE ] = "ICO_HIGHLIGHT PHOTOC15x20B", + [Pho_SHAPE_ELLIPSE ] = "ICO_HIGHLIGHT PHOTOE15x20B", + [Pho_SHAPE_OVAL ] = "ICO_HIGHLIGHT PHOTOO15x20B", + [Pho_SHAPE_RECTANGLE] = "ICO_HIGHLIGHT PHOTOR15x20B", + }; + Pho_Shape_t Shape; + + Box_BoxBegin (NULL,Txt_User_photos, + Pho_PutIconsPhotoShape,NULL, + Hlp_PROFILE_Settings_user_photos,Box_NOT_CLOSABLE); + Set_BeginSettingsHead (); + Set_BeginOneSettingSelector (); + for (Shape = (Pho_Shape_t) 0; + Shape <= (Pho_Shape_t) (Pho_NUM_SHAPES - 1); + Shape++) + { + HTM_DIV_Begin ("class=\"%s\"",Shape == Gbl.Prefs.PhotoShape ? "PREF_ON" : + "PREF_OFF"); + Frm_BeginForm (ActChgUsrPho); + Par_PutHiddenParamUnsigned (NULL,"PhotoShape",Shape); + HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"user.svg",Txt_PHOTO_SHAPES[Shape],ClassPhoto[Shape]); + Frm_EndForm (); + HTM_DIV_End (); + } + Set_EndOneSettingSelector (); + Set_EndSettingsHead (); + Box_BoxEnd (); + } + +/*****************************************************************************/ +/************** Put contextual icons in side-columns setting *****************/ +/*****************************************************************************/ + +static void Pho_PutIconsPhotoShape (__attribute__((unused)) void *Args) + { + /***** Put icon to show a figure *****/ + Fig_PutIconToShowFigure (Fig_PHOTO_SHAPES); + } + +/*****************************************************************************/ +/************************** Change user photo shape **************************/ +/*****************************************************************************/ + +void Pho_ChangePhotoShape (void) + { + /***** Get param with user photo shape *****/ + Gbl.Prefs.PhotoShape = Pho_GetParamPhotoShape (); + + /***** Store side colums in database *****/ + if (Gbl.Usrs.Me.Logged) + Set_DB_UpdateMySettingsAboutPhotoShape (); + + /***** Set settings from current IP *****/ + Set_SetSettingsFromIP (); + } + +/*****************************************************************************/ +/************** Get parameter used to change user photo shape ****************/ +/*****************************************************************************/ + +Pho_Shape_t Pho_GetParamPhotoShape (void) + { + return (Pho_Shape_t) Par_GetParToUnsignedLong ("PhotoShape", + (Pho_Shape_t) 0, + (Pho_Shape_t) (Pho_NUM_SHAPES - 1), + Pho_SHAPE_DEFAULT); + } + +/*****************************************************************************/ +/*********************** Get photo shape from string *************************/ +/*****************************************************************************/ + +Pho_Shape_t Pho_GetShapeFromStr (const char *Str) + { + unsigned UnsignedNum; + + if (sscanf (Str,"%u",&UnsignedNum) == 1) + if (UnsignedNum < Pho_NUM_SHAPES) + return (Pho_Shape_t) UnsignedNum; + + return Pho_SHAPE_DEFAULT; + } diff --git a/swad_photo_shape.h b/swad_photo_shape.h new file mode 100644 index 00000000..f882e01b --- /dev/null +++ b/swad_photo_shape.h @@ -0,0 +1,51 @@ +// swad_photo_shape.h: User photo shape + +#ifndef _SWAD_PHO_SHA +#define _SWAD_PHO_SHA +/* + SWAD (Shared Workspace At a Distance in Spanish), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2021 Antonio Cañas Vargas + + 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 . +*/ + +/*****************************************************************************/ +/************************* Public types and constants ************************/ +/*****************************************************************************/ + +// Related with user photo shape +#define Pho_NUM_SHAPES 4 +typedef enum + { + Pho_SHAPE_CIRCLE = 0, + Pho_SHAPE_ELLIPSE = 1, + Pho_SHAPE_OVAL = 2, + Pho_SHAPE_RECTANGLE = 3, + } Pho_Shape_t; +#define Pho_SHAPE_DEFAULT Pho_SHAPE_CIRCLE + +/*****************************************************************************/ +/***************************** Public prototypes *****************************/ +/*****************************************************************************/ + +void Pho_PutIconsToSelectPhotoShape (void); +void Pho_ChangePhotoShape (void); +Pho_Shape_t Pho_GetParamPhotoShape (void); +Pho_Shape_t Pho_GetShapeFromStr (const char *Str); + +#endif diff --git a/swad_profile.c b/swad_profile.c index 470c152b..17d98c84 100644 --- a/swad_profile.c +++ b/swad_profile.c @@ -1299,12 +1299,12 @@ void Prf_GetAndShowRankingClicksPerDay (void) static void Prf_ShowUsrInRanking (struct UsrData *UsrDat,unsigned Rank,bool ItsMe) { extern const char *Txt_Another_user_s_profile; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC30x40", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE30x40", - [Set_USR_PHOTO_OVAL ] = "PHOTOO30x48", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR30x40", + [Pho_SHAPE_CIRCLE ] = "PHOTOC30x40", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE30x40", + [Pho_SHAPE_OVAL ] = "PHOTOO30x48", + [Pho_SHAPE_RECTANGLE] = "PHOTOR30x40", }; bool Visible = Pri_ShowingIsAllowed (UsrDat->BaPrfVisibility,UsrDat); @@ -1320,7 +1320,7 @@ static void Prf_ShowUsrInRanking (struct UsrData *UsrDat,unsigned Rank,bool ItsM if (Visible) /***** User's photo *****/ Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); diff --git a/swad_project.c b/swad_project.c index 18ee6dbf..5762ba07 100644 --- a/swad_project.c +++ b/swad_project.c @@ -2028,12 +2028,12 @@ static void Prj_ShowOneProjectMembersWithARole (struct Prj_Projects *Projects, [Prj_ROLE_TUT] = ActReqAddTutPrj, // Tutor [Prj_ROLE_EVL] = ActReqAddEvlPrj, // Evaluator }; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC21x28", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE21x28", - [Set_USR_PHOTO_OVAL ] = "PHOTOO21x28", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR21x28", + [Pho_SHAPE_CIRCLE ] = "PHOTOC21x28", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE21x28", + [Pho_SHAPE_OVAL ] = "PHOTOO21x28", + [Pho_SHAPE_RECTANGLE] = "PHOTOR21x28", }; MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -2136,7 +2136,7 @@ static void Prj_ShowOneProjectMembersWithARole (struct Prj_Projects *Projects, /* Put user's photo */ HTM_TD_Begin ("class=\"PRJ_MEMBER_PHO\""); Pho_ShowUsrPhotoIfAllowed (&Gbl.Usrs.Other.UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); diff --git a/swad_record.c b/swad_record.c index 1ec86d81..19f9f594 100644 --- a/swad_record.c +++ b/swad_record.c @@ -2599,18 +2599,18 @@ static void Rec_ShowInstitutionInHead (struct Ins_Instit *Ins,bool PutFormLinks) static void Rec_ShowPhoto (struct UsrData *UsrDat) { - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOR186x248", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOR186x248", - [Set_USR_PHOTO_OVAL ] = "PHOTOR186x248", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR186x248", + [Pho_SHAPE_CIRCLE ] = "PHOTOR186x248", + [Pho_SHAPE_ELLIPSE ] = "PHOTOR186x248", + [Pho_SHAPE_OVAL ] = "PHOTOR186x248", + [Pho_SHAPE_RECTANGLE] = "PHOTOR186x248", }; /***** User's photo *****/ HTM_TD_Begin ("rowspan=\"3\" class=\"REC_C3_TOP CT\""); Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); } diff --git a/swad_setting.c b/swad_setting.c index 6e4f7ab7..7bf20afc 100644 --- a/swad_setting.c +++ b/swad_setting.c @@ -42,9 +42,10 @@ #include "swad_HTML.h" #include "swad_language.h" #include "swad_layout.h" -#include "swad_notification.h" #include "swad_menu.h" +#include "swad_notification.h" #include "swad_parameter.h" +#include "swad_photo.h" #include "swad_privacy.h" #include "swad_setting.h" #include "swad_setting_database.h" @@ -62,9 +63,6 @@ extern struct Globals Gbl; static void Set_PutIconsToSelectSideCols (void); static void Set_PutIconsSideColumns (__attribute__((unused)) void *Args); -static void Set_PutIconsToSelectUsrPhotos (void); -static void Set_PutIconsUsrPhotos (__attribute__((unused)) void *Args); - static void Set_GetAndUpdateUsrListType (void); static void Set_GetUsrListTypeFromForm (void); static void Set_GetMyUsrListTypeFromDB (void); @@ -126,7 +124,7 @@ void Set_EditSettings (void) HTM_DIV_End (); HTM_DIV_Begin ("class=\"FRAME_INLINE\""); - Set_PutIconsToSelectUsrPhotos (); // 8. User photos + Pho_PutIconsToSelectPhotoShape (); // 8. User photos HTM_DIV_End (); Box_BoxEnd (); @@ -176,22 +174,10 @@ void Set_GetSettingsFromIP (void) 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) - { - if (Gbl.Prefs.SideCols > Lay_SHOW_BOTH_COLUMNS) - Gbl.Prefs.SideCols = Cfg_DEFAULT_COLUMNS; - } - else - Gbl.Prefs.SideCols = Cfg_DEFAULT_COLUMNS; + Gbl.Prefs.SideCols = Set_GetSideColsFromStr (row[5]); /* Get user photo shape (row[6]) */ - if (sscanf (row[6],"%u",&Gbl.Prefs.UsrPhotos) == 1) - { - if (Gbl.Prefs.UsrPhotos >= Set_NUM_USR_PHOTOS) - Gbl.Prefs.UsrPhotos = Set_USR_PHOTOS_DEFAULT; - } - else - Gbl.Prefs.UsrPhotos = Set_USR_PHOTOS_DEFAULT; + Gbl.Prefs.PhotoShape = Pho_GetShapeFromStr (row[6]); } /***** Free structure that stores the query result *****/ @@ -205,12 +191,12 @@ void Set_GetSettingsFromIP (void) void Set_SetSettingsFromIP (void) { - /***** Update settings from current IP in database *****/ - Set_DB_UpdateSettingsFromIP (); + /***** Update IP settings for current IP in database *****/ + Set_DB_UpdateMyIPSettingsForCurrentIP (); - /***** If I am logged, update my settings in database for all my IP's *****/ + /***** If I am logged, update my IP settings in database for all my IP's *****/ if (Gbl.Usrs.Me.Logged) - Set_DB_UpdateMySettingsFromIP (); + Set_DB_UpdateMyIPSettingsForAllMyIPs (); } /*****************************************************************************/ @@ -289,82 +275,18 @@ unsigned Set_GetParamSideCols (void) } /*****************************************************************************/ -/******************* Put icons to select user photo shape ********************/ +/*************************** Get menu from string ****************************/ /*****************************************************************************/ -static void Set_PutIconsToSelectUsrPhotos (void) +unsigned Set_GetSideColsFromStr (const char *Str) { - extern const char *Hlp_PROFILE_Settings_user_photos; - extern const char *Txt_User_photos; - extern const char *Txt_USER_PHOTOS[Set_NUM_USR_PHOTOS]; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = - { - [Set_USR_PHOTO_CIRCLE ] = "ICO_HIGHLIGHT PHOTOC15x20B", - [Set_USR_PHOTO_ELLIPSE ] = "ICO_HIGHLIGHT PHOTOE15x20B", - [Set_USR_PHOTO_OVAL ] = "ICO_HIGHLIGHT PHOTOO15x20B", - [Set_USR_PHOTO_RECTANGLE] = "ICO_HIGHLIGHT PHOTOR15x20B", - }; - Set_UsrPhotos_t UsrPhotos; + unsigned UnsignedNum; - Box_BoxBegin (NULL,Txt_User_photos, - Set_PutIconsUsrPhotos,NULL, - Hlp_PROFILE_Settings_user_photos,Box_NOT_CLOSABLE); - Set_BeginSettingsHead (); - Set_BeginOneSettingSelector (); - for (UsrPhotos = (Set_UsrPhotos_t) 0; - UsrPhotos <= (Set_UsrPhotos_t) (Set_NUM_USR_PHOTOS - 1); - UsrPhotos++) - { - HTM_DIV_Begin ("class=\"%s\"",UsrPhotos == Gbl.Prefs.UsrPhotos ? "PREF_ON" : - "PREF_OFF"); - Frm_BeginForm (ActChgUsrPho); - Par_PutHiddenParamUnsigned (NULL,"UsrPhotos",UsrPhotos); - HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"user.svg",Txt_USER_PHOTOS[UsrPhotos],ClassPhoto[UsrPhotos]); - Frm_EndForm (); - HTM_DIV_End (); - } - Set_EndOneSettingSelector (); - Set_EndSettingsHead (); - Box_BoxEnd (); - } + if (sscanf (Str,"%u",&UnsignedNum) == 1) + if (UnsignedNum <= Lay_SHOW_BOTH_COLUMNS) + return UnsignedNum; -/*****************************************************************************/ -/************** Put contextual icons in side-columns setting *****************/ -/*****************************************************************************/ - -static void Set_PutIconsUsrPhotos (__attribute__((unused)) void *Args) - { - /***** Put icon to show a figure *****/ - Fig_PutIconToShowFigure (Fig_USER_PHOTOS); - } - -/*****************************************************************************/ -/************************** Change user photo shape **************************/ -/*****************************************************************************/ - -void Set_ChangeUsrPhotos (void) - { - /***** Get param with user photo shape *****/ - Gbl.Prefs.UsrPhotos = Set_GetParamUsrPhotos (); - - /***** Store side colums in database *****/ - if (Gbl.Usrs.Me.Logged) - Set_DB_UpdateMySettingsAboutUsrPhotos (); - - /***** Set settings from current IP *****/ - Set_SetSettingsFromIP (); - } - -/*****************************************************************************/ -/************** Get parameter used to change user photo shape ****************/ -/*****************************************************************************/ - -Set_UsrPhotos_t Set_GetParamUsrPhotos (void) - { - return (Set_UsrPhotos_t) Par_GetParToUnsignedLong ("UsrPhotos", - (Set_UsrPhotos_t) 0, - (Set_UsrPhotos_t) (Set_NUM_USR_PHOTOS - 1), - Set_USR_PHOTOS_DEFAULT); + return Cfg_DEFAULT_COLUMNS; } /*****************************************************************************/ diff --git a/swad_setting.h b/swad_setting.h index 5320f8d2..0afff215 100644 --- a/swad_setting.h +++ b/swad_setting.h @@ -33,17 +33,6 @@ /***************************** Public constants ******************************/ /*****************************************************************************/ -// Related with user photo shape -#define Set_NUM_USR_PHOTOS 4 -typedef enum - { - Set_USR_PHOTO_CIRCLE = 0, - Set_USR_PHOTO_ELLIPSE = 1, - Set_USR_PHOTO_OVAL = 2, - Set_USR_PHOTO_RECTANGLE = 3, - } Set_UsrPhotos_t; -#define Set_USR_PHOTOS_DEFAULT Set_USR_PHOTO_CIRCLE - // Related with type of list of users #define Set_NUM_USR_LIST_TYPES 3 typedef enum @@ -65,9 +54,7 @@ void Set_SetSettingsFromIP (void); void Set_ChangeSideCols (void); unsigned Set_GetParamSideCols (void); - -void Set_ChangeUsrPhotos (void); -Set_UsrPhotos_t Set_GetParamUsrPhotos (void); +unsigned Set_GetSideColsFromStr (const char *Str); //------------------------ My settings on users' list ------------------------- void Set_PutParamsPrefsAboutUsrList (void); diff --git a/swad_setting_database.c b/swad_setting_database.c index 0b8bbf76..60624ebc 100644 --- a/swad_setting_database.c +++ b/swad_setting_database.c @@ -149,13 +149,13 @@ void Set_DB_UpdateMySettingsAboutSideCols (void) /**************** Update user photo shape on user data table *****************/ /*****************************************************************************/ -void Set_DB_UpdateMySettingsAboutUsrPhotos (void) +void Set_DB_UpdateMySettingsAboutPhotoShape (void) { DB_QueryUPDATE ("can not update your setting about user photo shape", "UPDATE usr_data" - " SET UsrPhotos=%u" + " SET PhotoShape=%u" " WHERE UsrCod=%ld", - (unsigned) Gbl.Prefs.UsrPhotos, + (unsigned) Gbl.Prefs.PhotoShape, Gbl.Usrs.Me.UsrDat.UsrCod); } @@ -423,7 +423,7 @@ void Set_DB_RemAllUsrsFromCrsSettings (long CrsCod) /**************** Update settings from current IP in database ****************/ /*****************************************************************************/ -void Set_DB_UpdateSettingsFromIP (void) +void Set_DB_UpdateMyIPSettingsForCurrentIP (void) { extern const char *The_ThemeId[The_NUM_THEMES]; extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS]; @@ -431,7 +431,7 @@ void Set_DB_UpdateSettingsFromIP (void) DB_QueryREPLACE ("can not store settings from current IP address", "REPLACE INTO set_ip_settings" " (IP,UsrCod,LastChange," - "FirstDayOfWeek,DateFormat,Theme,IconSet,Menu,SideCols,UsrPhotos)" + "FirstDayOfWeek,DateFormat,Theme,IconSet,Menu,SideCols,PhotoShape)" " VALUES" " ('%s',%ld,NOW()," "%u,%u,'%s','%s',%u,%u,%u)", @@ -443,14 +443,14 @@ void Set_DB_UpdateSettingsFromIP (void) Ico_IconSetId[Gbl.Prefs.IconSet], (unsigned) Gbl.Prefs.Menu, Gbl.Prefs.SideCols, - (unsigned) Gbl.Prefs.UsrPhotos); + (unsigned) Gbl.Prefs.PhotoShape); } /*****************************************************************************/ -/*************** Update my settings from current IP in database **************/ +/**************** Update my settings from all IP in database *****************/ /*****************************************************************************/ -void Set_DB_UpdateMySettingsFromIP (void) +void Set_DB_UpdateMyIPSettingsForAllMyIPs (void) { extern const char *The_ThemeId[The_NUM_THEMES]; extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS]; @@ -463,7 +463,7 @@ void Set_DB_UpdateMySettingsFromIP (void) "IconSet='%s'," "Menu=%u," "SideCols=%u," - "UsrPhotos=%u" + "PhotoShape=%u" " WHERE UsrCod=%ld", Gbl.Prefs.FirstDayOfWeek, (unsigned) Gbl.Prefs.DateFormat, @@ -471,7 +471,7 @@ void Set_DB_UpdateMySettingsFromIP (void) Ico_IconSetId[Gbl.Prefs.IconSet], (unsigned) Gbl.Prefs.Menu, Gbl.Prefs.SideCols, - (unsigned) Gbl.Prefs.UsrPhotos, + (unsigned) Gbl.Prefs.PhotoShape, Gbl.Usrs.Me.UsrDat.UsrCod); } @@ -489,7 +489,7 @@ unsigned Set_DB_GetSettingsFromIP (MYSQL_RES **mysql_res) "IconSet," // row[3] "Menu," // row[4] "SideCols," // row[5] - "UsrPhotos" // row[6] + "PhotoShape" // row[6] " FROM set_ip_settings" " WHERE IP='%s'", Gbl.IP); diff --git a/swad_setting_database.h b/swad_setting_database.h index a760c98f..e20d9475 100644 --- a/swad_setting_database.h +++ b/swad_setting_database.h @@ -35,7 +35,7 @@ void Set_DB_UpdateMySettingsAboutIconSet (const char *IconSetId); void Set_DB_UpdateMySettingsAboutMenu (Mnu_Menu_t Menu); void Set_DB_UpdateMySettingsAboutTheme (const char *ThemeId); void Set_DB_UpdateMySettingsAboutSideCols (void); -void Set_DB_UpdateMySettingsAboutUsrPhotos (void); +void Set_DB_UpdateMySettingsAboutPhotoShape (void); void Set_DB_UpdateMySettingsAboutPhotoVisibility (void); void Set_DB_UpdateMySettingsAboutBasicProfile (void); void Set_DB_UpdateMySettingsAboutExtendedProfile (void); @@ -60,8 +60,8 @@ void Set_DB_RemUsrFromAllCrssSettings (long UsrCod); void Set_DB_RemAllUsrsFromCrsSettings (long CrsCod); //------------------- IP settings (when no user logged) ----------------------- -void Set_DB_UpdateSettingsFromIP (void); -void Set_DB_UpdateMySettingsFromIP (void); +void Set_DB_UpdateMyIPSettingsForCurrentIP (void); +void Set_DB_UpdateMyIPSettingsForAllMyIPs (void); unsigned Set_DB_GetSettingsFromIP (MYSQL_RES **mysql_res); diff --git a/swad_statistic.c b/swad_statistic.c index 90d92bc3..648a12e1 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -1306,12 +1306,12 @@ static void Sta_ShowNumHitsPerUsr (Sta_CountType_t CountType, extern const char *Txt_Role; extern const char *Txt_STAT_TYPE_COUNT_CAPS[Sta_NUM_COUNT_TYPES]; extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC15x20", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE15x20", - [Set_USR_PHOTO_OVAL ] = "PHOTOO15x20", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR15x20", + [Pho_SHAPE_CIRCLE ] = "PHOTOC15x20", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE15x20", + [Pho_SHAPE_OVAL ] = "PHOTOO15x20", + [Pho_SHAPE_RECTANGLE] = "PHOTOR15x20", }; MYSQL_ROW row; unsigned NumHit; @@ -1355,7 +1355,7 @@ static void Sta_ShowNumHitsPerUsr (Sta_CountType_t CountType, /* Show the photo */ HTM_TD_Begin ("class=\"CT COLOR%u\"",Gbl.RowEvenOdd); Pho_ShowUsrPhotoIfAllowed (&UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); diff --git a/swad_test_print.c b/swad_test_print.c index 83e7bab1..96e51dde 100644 --- a/swad_test_print.c +++ b/swad_test_print.c @@ -2156,12 +2156,12 @@ void TstPrn_ShowOnePrint (void) extern const char *Txt_Score; extern const char *Txt_Grade; extern const char *Txt_Tags; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC45x60", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE45x60", - [Set_USR_PHOTO_OVAL ] = "PHOTOO45x60", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR45x60", + [Pho_SHAPE_CIRCLE ] = "PHOTOC45x60", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE45x60", + [Pho_SHAPE_OVAL ] = "PHOTOO45x60", + [Pho_SHAPE_RECTANGLE] = "PHOTOR45x60", }; struct TstPrn_Print Print; Dat_StartEndTime_t StartEndTime; @@ -2224,7 +2224,7 @@ void TstPrn_ShowOnePrint (void) HTM_TxtF (", %s",Gbl.Usrs.Other.UsrDat.FrstName); HTM_BR (); Pho_ShowUsrPhotoIfAllowed (&Gbl.Usrs.Other.UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); diff --git a/swad_text.c b/swad_text.c index 0dc916c4..55c3e4de 100644 --- a/swad_text.c +++ b/swad_text.c @@ -30585,6 +30585,89 @@ const char *Txt_PHOTO_PROCESSING_CAPTIONS[3] = #endif }; +const char *Txt_PHOTO_SHAPES[Pho_NUM_SHAPES] = + { +#if L==1 // ca + "Cercle" +#elif L==2 // de + "Kreis" +#elif L==3 // en + "Circle" +#elif L==4 // es + "Círculo" +#elif L==5 // fr + "Cercle" +#elif L==6 // gn + "Círculo" // Okoteve traducción +#elif L==7 // it + "Cerchio" +#elif L==8 // pl + "Koło" +#elif L==9 // pt + "Círculo" +#endif + , +#if L==1 // ca + "El·lipse" +#elif L==2 // de + "Ellipse" +#elif L==3 // en + "Ellipse" +#elif L==4 // es + "Elipse" +#elif L==5 // fr + "Ellipse" +#elif L==6 // gn + "Elipse" // Okoteve traducción +#elif L==7 // it + "Ellisse" +#elif L==8 // pl + "Elipsa" +#elif L==9 // pt + "Elipse" +#endif + , +#if L==1 // ca + "Oval" +#elif L==2 // de + "Oval" +#elif L==3 // en + "Oval" +#elif L==4 // es + "Óvalo" +#elif L==5 // fr + "Ovale" +#elif L==6 // gn + "Óvalo" // Okoteve traducción +#elif L==7 // it + "Ovale" +#elif L==8 // pl + "Owalny" +#elif L==9 // pt + "Ovalo" +#endif + , +#if L==1 // ca + "Rectangle" +#elif L==2 // de + "Rechteck" +#elif L==3 // en + "Rectangle" +#elif L==4 // es + "Rectángulo" +#elif L==5 // fr + "Rectangle" +#elif L==6 // gn + "Rectángulo" // Okoteve traducción +#elif L==7 // it + "Rettangolo" +#elif L==8 // pl + "Prostokąt" +#elif L==9 // pt + "Retângulo" +#endif + }; + const char *Txt_Photo_removed = #if L==1 // ca "Fotografía eliminada."; // Necessita traduccio @@ -44592,7 +44675,7 @@ const char *Txt_FIGURE_TYPES[Fig_NUM_FIGURES] = "Colunas" #endif , - [Fig_USER_PHOTOS] = + [Fig_PHOTO_SHAPES] = #if L==1 // ca "Fotos d'usuaris" #elif L==2 // de @@ -55599,89 +55682,6 @@ const char *Txt_User_photos = "Fotos de utilizadores"; #endif -const char *Txt_USER_PHOTOS[Set_NUM_USR_PHOTOS] = - { -#if L==1 // ca - "Cercle" -#elif L==2 // de - "Kreis" -#elif L==3 // en - "Circle" -#elif L==4 // es - "Círculo" -#elif L==5 // fr - "Cercle" -#elif L==6 // gn - "Círculo" // Okoteve traducción -#elif L==7 // it - "Cerchio" -#elif L==8 // pl - "Koło" -#elif L==9 // pt - "Círculo" -#endif - , -#if L==1 // ca - "El·lipse" -#elif L==2 // de - "Ellipse" -#elif L==3 // en - "Ellipse" -#elif L==4 // es - "Elipse" -#elif L==5 // fr - "Ellipse" -#elif L==6 // gn - "Elipse" // Okoteve traducción -#elif L==7 // it - "Ellisse" -#elif L==8 // pl - "Elipsa" -#elif L==9 // pt - "Elipse" -#endif - , -#if L==1 // ca - "Oval" -#elif L==2 // de - "Oval" -#elif L==3 // en - "Oval" -#elif L==4 // es - "Óvalo" -#elif L==5 // fr - "Ovale" -#elif L==6 // gn - "Óvalo" // Okoteve traducción -#elif L==7 // it - "Ovale" -#elif L==8 // pl - "Owalny" -#elif L==9 // pt - "Ovalo" -#endif - , -#if L==1 // ca - "Rectangle" -#elif L==2 // de - "Rechteck" -#elif L==3 // en - "Rectangle" -#elif L==4 // es - "Rectángulo" -#elif L==5 // fr - "Rectangle" -#elif L==6 // gn - "Rectángulo" // Okoteve traducción -#elif L==7 // it - "Rettangolo" -#elif L==8 // pl - "Prostokąt" -#elif L==9 // pt - "Retângulo" -#endif - }; - const char *Txt_Users = #if L==1 // ca "Usuaris"; diff --git a/swad_theme.c b/swad_theme.c index 1a3fe6c1..aca125e2 100644 --- a/swad_theme.c +++ b/swad_theme.c @@ -393,7 +393,7 @@ The_Theme_t The_GetParamTheme (void) if (!strcmp (ThemeId,The_ThemeId[Theme])) return Theme; - return The_THEME_UNKNOWN; + return The_THEME_DEFAULT; } /*****************************************************************************/ @@ -410,5 +410,5 @@ The_Theme_t The_GetThemeFromStr (const char *Str) if (!strcasecmp (Str,The_ThemeId[Theme])) return Theme; - return The_THEME_UNKNOWN; + return The_THEME_DEFAULT; } diff --git a/swad_theme.h b/swad_theme.h index 746c3585..1aa51893 100644 --- a/swad_theme.h +++ b/swad_theme.h @@ -41,7 +41,6 @@ typedef enum The_THEME_BLUE = 3, The_THEME_YELLOW = 4, The_THEME_PINK = 5, - The_THEME_UNKNOWN = 6, } The_Theme_t; #define The_THEME_DEFAULT The_THEME_PINK diff --git a/swad_timeline_comment.c b/swad_timeline_comment.c index 2e20a8a9..e0d37963 100644 --- a/swad_timeline_comment.c +++ b/swad_timeline_comment.c @@ -184,12 +184,12 @@ void Tml_Com_PutPhotoAndFormToWriteNewComm (const struct Tml_Timeline *Timeline, static void Tml_Com_ShowAuthorPhoto (struct UsrData *UsrDat) { - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC30x40", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE30x40", - [Set_USR_PHOTO_OVAL ] = "PHOTOO30x40", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR30x40", + [Pho_SHAPE_CIRCLE ] = "PHOTOC30x40", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE30x40", + [Pho_SHAPE_OVAL ] = "PHOTOO30x40", + [Pho_SHAPE_RECTANGLE] = "PHOTOR30x40", }; /***** Show author's photo *****/ @@ -198,7 +198,7 @@ static void Tml_Com_ShowAuthorPhoto (struct UsrData *UsrDat) /* Author's photo */ Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, true); // Use unique id /* End container */ diff --git a/swad_timeline_note.c b/swad_timeline_note.c index 868e216d..887e257b 100644 --- a/swad_timeline_note.c +++ b/swad_timeline_note.c @@ -289,12 +289,12 @@ static void Tml_Not_WriteNote (const struct Tml_Timeline *Timeline, void Tml_Not_ShowAuthorPhoto (struct UsrData *UsrDat,bool FormUnique) { - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC45x60", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE45x60", - [Set_USR_PHOTO_OVAL ] = "PHOTOO45x60", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR45x60", + [Pho_SHAPE_CIRCLE ] = "PHOTOC45x60", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE45x60", + [Pho_SHAPE_OVAL ] = "PHOTOO45x60", + [Pho_SHAPE_RECTANGLE] = "PHOTOR45x60", }; /***** Begin container *****/ @@ -302,7 +302,7 @@ void Tml_Not_ShowAuthorPhoto (struct UsrData *UsrDat,bool FormUnique) /***** Photo *****/ Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, FormUnique); /***** End container *****/ diff --git a/swad_timeline_user.c b/swad_timeline_user.c index d84a6ef0..039b293c 100644 --- a/swad_timeline_user.c +++ b/swad_timeline_user.c @@ -179,12 +179,12 @@ static void Tml_Usr_ShowNumSharersOrFavers (unsigned NumUsrs) static void Tml_Usr_ListSharersOrFavers (MYSQL_RES **mysql_res, unsigned NumUsrs,unsigned NumFirstUsrs) { - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC12x16", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE12x16", - [Set_USR_PHOTO_OVAL ] = "PHOTOO12x16", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR12x16", + [Pho_SHAPE_CIRCLE ] = "PHOTOC12x16", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE12x16", + [Pho_SHAPE_OVAL ] = "PHOTOO12x16", + [Pho_SHAPE_RECTANGLE] = "PHOTOR12x16", }; unsigned NumUsr; struct UsrData UsrDat; @@ -218,7 +218,7 @@ static void Tml_Usr_ListSharersOrFavers (MYSQL_RES **mysql_res, /* User's photo */ Pho_ShowUsrPhotoIfAllowed (&UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, true); // Use unique id /* End container */ diff --git a/swad_user.c b/swad_user.c index dc457671..93ba3da5 100644 --- a/swad_user.c +++ b/swad_user.c @@ -333,14 +333,14 @@ void Usr_ResetUsrDataExceptUsrCodAndIDs (struct UsrData *UsrDat) UsrDat->Tch.Office[0] = '\0'; UsrDat->Tch.OfficePhone[0] = '\0'; - UsrDat->Prefs.Language = Lan_LANGUAGE_UNKNOWN; // Language unknown - UsrDat->Prefs.FirstDayOfWeek = Cal_FIRST_DAY_OF_WEEK_DEFAULT; // Default first day of week - UsrDat->Prefs.DateFormat = Dat_FORMAT_DEFAULT ; // Default date format - UsrDat->Prefs.Theme = The_THEME_DEFAULT; - UsrDat->Prefs.IconSet = Ico_ICON_SET_DEFAULT; - UsrDat->Prefs.Menu = Mnu_MENU_DEFAULT; - UsrDat->Prefs.SideCols = Cfg_DEFAULT_COLUMNS; - UsrDat->Prefs.UsrPhotos = Set_USR_PHOTOS_DEFAULT; + UsrDat->Prefs.Language = Lan_LANGUAGE_UNKNOWN; // Language unknown + UsrDat->Prefs.FirstDayOfWeek = Cal_FIRST_DAY_OF_WEEK_DEFAULT; // Default first day of week + UsrDat->Prefs.DateFormat = Dat_FORMAT_DEFAULT ; // Default date format + UsrDat->Prefs.Theme = The_THEME_DEFAULT; + UsrDat->Prefs.IconSet = Ico_ICON_SET_DEFAULT; + UsrDat->Prefs.Menu = Mnu_MENU_DEFAULT; + UsrDat->Prefs.SideCols = Cfg_DEFAULT_COLUMNS; + UsrDat->Prefs.PhotoShape = Pho_SHAPE_DEFAULT; UsrDat->Prefs.AcceptThirdPartyCookies = false; // By default, don't accept third party cookies UsrDat->NtfEvents.SendEmail = 0; // By default, don't notify anything } @@ -448,13 +448,8 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat, Usr_GetPrefs_t GetPrefs, Usr_GetRoleInCurrentCrs_t GetRoleInCurrentCrs) { - extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS]; - extern const char *The_ThemeId[The_NUM_THEMES]; - extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES]; MYSQL_RES *mysql_res; MYSQL_ROW row; - The_Theme_t Theme; - Ico_IconSet_t IconSet; Lan_Language_t Lan; /***** Get user's data from database *****/ @@ -543,15 +538,7 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat, if (GetPrefs == Usr_GET_PREFS) { /* Get language (row[23]) */ - UsrDat->Prefs.Language = Lan_LANGUAGE_UNKNOWN; // Language unknown - for (Lan = (Lan_Language_t) 1; - Lan <= (Lan_Language_t) Lan_NUM_LANGUAGES; - Lan++) - if (!strcasecmp (row[23],Lan_STR_LANG_ID[Lan])) - { - UsrDat->Prefs.Language = Lan; - break; - } + UsrDat->Prefs.Language = Lan_GetLanguageFromStr (row[23]); /* Get first day of week (row[24]) */ UsrDat->Prefs.FirstDayOfWeek = Cal_GetFirstDayOfWeekFromStr (row[24]); @@ -560,47 +547,19 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat, UsrDat->Prefs.DateFormat = Dat_GetDateFormatFromStr (row[25]); /* Get theme (row[26]) */ - UsrDat->Prefs.Theme = The_THEME_DEFAULT; - for (Theme = (The_Theme_t) 0; - Theme <= (The_Theme_t) (The_NUM_THEMES - 1); - Theme++) - if (!strcasecmp (row[26],The_ThemeId[Theme])) - { - UsrDat->Prefs.Theme = Theme; - break; - } + UsrDat->Prefs.Theme = The_GetThemeFromStr (row[26]); /* Get icon set (row[27]) */ - UsrDat->Prefs.IconSet = Ico_ICON_SET_DEFAULT; - for (IconSet = (Ico_IconSet_t) 0; - IconSet <= (Ico_IconSet_t) (Ico_NUM_ICON_SETS - 1); - IconSet++) - if (!strcasecmp (row[27],Ico_IconSetId[IconSet])) - { - UsrDat->Prefs.IconSet = IconSet; - break; - } + UsrDat->Prefs.IconSet = Ico_GetIconSetFromStr (row[27]); /* Get menu (row[28]) */ UsrDat->Prefs.Menu = Mnu_GetMenuFromStr (row[28]); /* Get if user wants to show side columns (row[29]) */ - if (sscanf (row[29],"%u",&UsrDat->Prefs.SideCols) == 1) - { - if (UsrDat->Prefs.SideCols > Lay_SHOW_BOTH_COLUMNS) - UsrDat->Prefs.SideCols = Cfg_DEFAULT_COLUMNS; - } - else - UsrDat->Prefs.SideCols = Cfg_DEFAULT_COLUMNS; + UsrDat->Prefs.SideCols = Set_GetSideColsFromStr (row[29]); /* Get user settings on user photo shape (row[30]) */ - if (sscanf (row[30],"%u",&UsrDat->Prefs.UsrPhotos) == 1) - { - if (UsrDat->Prefs.UsrPhotos >= Set_NUM_USR_PHOTOS) - UsrDat->Prefs.UsrPhotos = Set_USR_PHOTOS_DEFAULT; - } - else - UsrDat->Prefs.UsrPhotos = Set_USR_PHOTOS_DEFAULT; + UsrDat->Prefs.PhotoShape = Pho_GetShapeFromStr (row[30]); /* Get if user accepts third party cookies (row[31]) */ UsrDat->Prefs.AcceptThirdPartyCookies = (row[31][0] == 'Y'); @@ -1390,12 +1349,12 @@ void Usr_WriteLoggedUsrHead (void) extern const char *The_ClassUsr[The_NUM_THEMES]; extern const char *Txt_Role; extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC18x24", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE18x24", - [Set_USR_PHOTO_OVAL ] = "PHOTOO18x24", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR18x24", + [Pho_SHAPE_CIRCLE ] = "PHOTOC18x24", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE18x24", + [Pho_SHAPE_OVAL ] = "PHOTOO18x24", + [Pho_SHAPE_RECTANGLE] = "PHOTOR18x24", }; unsigned NumAvailableRoles = Rol_GetNumAvailableRoles (); @@ -1422,7 +1381,7 @@ void Usr_WriteLoggedUsrHead (void) /***** Show my photo *****/ Pho_ShowUsrPhotoIfAllowed (&Gbl.Usrs.Me.UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); /***** User's name *****/ @@ -1985,7 +1944,6 @@ static void Usr_SetMyPrefsAndRoles (void) { extern const char *The_ThemeId[The_NUM_THEMES]; extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS]; - char URL[PATH_MAX + 1]; bool GetRoleAndActionFromLastData; Act_Action_t LastSuperAction; bool JustAfterLogin = Gbl.Action.Act == ActLogIn || @@ -2002,18 +1960,15 @@ static void Usr_SetMyPrefsAndRoles (void) /***** Set settings from my settings *****/ Gbl.Prefs.FirstDayOfWeek = Gbl.Usrs.Me.UsrDat.Prefs.FirstDayOfWeek; Gbl.Prefs.DateFormat = Gbl.Usrs.Me.UsrDat.Prefs.DateFormat; + Gbl.Prefs.IconSet = Gbl.Usrs.Me.UsrDat.Prefs.IconSet; Gbl.Prefs.Menu = Gbl.Usrs.Me.UsrDat.Prefs.Menu; + Gbl.Prefs.Theme = Gbl.Usrs.Me.UsrDat.Prefs.Theme; Gbl.Prefs.SideCols = Gbl.Usrs.Me.UsrDat.Prefs.SideCols; - - Gbl.Prefs.Theme = Gbl.Usrs.Me.UsrDat.Prefs.Theme; - snprintf (URL,sizeof (URL),"%s/%s", - Cfg_URL_ICON_THEMES_PUBLIC,The_ThemeId[Gbl.Prefs.Theme]); - Str_Copy (Gbl.Prefs.URLTheme ,URL,sizeof (Gbl.Prefs.URLTheme ) - 1); - - Gbl.Prefs.IconSet = Gbl.Usrs.Me.UsrDat.Prefs.IconSet; - snprintf (URL,sizeof (URL),"%s/%s", + Gbl.Prefs.PhotoShape = Gbl.Usrs.Me.UsrDat.Prefs.PhotoShape; + snprintf (Gbl.Prefs.URLIconSet,sizeof (Gbl.Prefs.URLIconSet),"%s/%s", Cfg_URL_ICON_SETS_PUBLIC,Ico_IconSetId[Gbl.Prefs.IconSet]); - Str_Copy (Gbl.Prefs.URLIconSet,URL,sizeof (Gbl.Prefs.URLIconSet) - 1); + snprintf (Gbl.Prefs.URLTheme,sizeof (Gbl.Prefs.URLTheme),"%s/%s", + Cfg_URL_ICON_THEMES_PUBLIC,The_ThemeId[Gbl.Prefs.Theme]); /***** Construct the path to my directory *****/ Usr_ConstructPathUsr (Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Me.PathDir); @@ -2193,12 +2148,12 @@ void Usr_WriteRowUsrMainData (unsigned NumUsr,struct UsrData *UsrDat, { extern const char *Txt_Enrolment_confirmed; extern const char *Txt_Enrolment_not_confirmed; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC21x28", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE21x28", - [Set_USR_PHOTO_OVAL ] = "PHOTOO21x28", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR21x28", + [Pho_SHAPE_CIRCLE ] = "PHOTOC21x28", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE21x28", + [Pho_SHAPE_OVAL ] = "PHOTOO21x28", + [Pho_SHAPE_RECTANGLE] = "PHOTOR21x28", }; char BgColor[Usr_MAX_BYTES_BG_COLOR + 1]; bool UsrIsTheMsgSender = PutCheckBoxToSelectUsr && @@ -2254,7 +2209,7 @@ void Usr_WriteRowUsrMainData (unsigned NumUsr,struct UsrData *UsrDat, /***** Show user's photo *****/ HTM_TD_Begin ("class=\"CM %s\"",BgColor); Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); } @@ -2286,12 +2241,12 @@ void Usr_WriteRowUsrMainData (unsigned NumUsr,struct UsrData *UsrDat, static void Usr_WriteRowGstAllData (struct UsrData *UsrDat) { - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC21x28", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE21x28", - [Set_USR_PHOTO_OVAL ] = "PHOTOO21x28", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR21x28", + [Pho_SHAPE_CIRCLE ] = "PHOTOC21x28", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE21x28", + [Pho_SHAPE_OVAL ] = "PHOTOO21x28", + [Pho_SHAPE_RECTANGLE] = "PHOTOR21x28", }; struct Ins_Instit Ins; struct Ctr_Center Ctr; @@ -2305,7 +2260,7 @@ static void Usr_WriteRowGstAllData (struct UsrData *UsrDat) /***** Show guest's photo *****/ HTM_TD_Begin ("class=\"LM COLOR%u\"",Gbl.RowEvenOdd); Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_NO_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_NO_ZOOM, false); HTM_TD_End (); } @@ -2375,12 +2330,12 @@ static void Usr_WriteRowGstAllData (struct UsrData *UsrDat) static void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames) { - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC21x28", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE21x28", - [Set_USR_PHOTO_OVAL ] = "PHOTOO21x28", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR21x28", + [Pho_SHAPE_CIRCLE ] = "PHOTOC21x28", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE21x28", + [Pho_SHAPE_OVAL ] = "PHOTOO21x28", + [Pho_SHAPE_RECTANGLE] = "PHOTOR21x28", }; unsigned NumGrpTyp,NumField; MYSQL_RES *mysql_res; @@ -2398,7 +2353,7 @@ static void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames) /***** Show student's photo *****/ HTM_TD_Begin ("class=\"LM COLOR%u\"",Gbl.RowEvenOdd); Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_NO_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_NO_ZOOM, false); HTM_TD_End (); } @@ -2486,12 +2441,12 @@ static void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames) static void Usr_WriteRowTchAllData (struct UsrData *UsrDat) { - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC21x28", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE21x28", - [Set_USR_PHOTO_OVAL ] = "PHOTOO21x28", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR21x28", + [Pho_SHAPE_CIRCLE ] = "PHOTOC21x28", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE21x28", + [Pho_SHAPE_OVAL ] = "PHOTOO21x28", + [Pho_SHAPE_RECTANGLE] = "PHOTOR21x28", }; struct Ins_Instit Ins; struct Ctr_Center Ctr; @@ -2507,7 +2462,7 @@ static void Usr_WriteRowTchAllData (struct UsrData *UsrDat) /***** Show teacher's photo *****/ HTM_TD_Begin ("class=\"LM COLOR%u\"",Gbl.RowEvenOdd); Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_NO_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_NO_ZOOM, false); HTM_TD_End (); } @@ -2567,12 +2522,12 @@ static void Usr_WriteRowTchAllData (struct UsrData *UsrDat) static void Usr_WriteRowAdmData (unsigned NumUsr,struct UsrData *UsrDat) { - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC21x28", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE21x28", - [Set_USR_PHOTO_OVAL ] = "PHOTOO21x28", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR21x28", + [Pho_SHAPE_CIRCLE ] = "PHOTOC21x28", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE21x28", + [Pho_SHAPE_OVAL ] = "PHOTOO21x28", + [Pho_SHAPE_RECTANGLE] = "PHOTOR21x28", }; struct Ins_Instit Ins; @@ -2589,7 +2544,7 @@ static void Usr_WriteRowAdmData (unsigned NumUsr,struct UsrData *UsrDat) /***** Show administrator's photo *****/ HTM_TD_Begin ("class=\"LM COLOR%u\"",Gbl.RowEvenOdd); Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); } @@ -6141,20 +6096,20 @@ static void Usr_DrawClassPhoto (Usr_ClassPhotoType_t ClassPhotoType, struct SelectedUsrs *SelectedUsrs, bool PutCheckBoxToSelectUsr) { - static const char *ClassPhoto[Usr_NUM_CLASS_PHOTO_TYPE][Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Usr_NUM_CLASS_PHOTO_TYPE][Pho_NUM_SHAPES] = { - [Usr_CLASS_PHOTO_SEL ][Set_USR_PHOTO_CIRCLE ] = "PHOTOC21x28", - [Usr_CLASS_PHOTO_SEL ][Set_USR_PHOTO_ELLIPSE ] = "PHOTOE21x28", - [Usr_CLASS_PHOTO_SEL ][Set_USR_PHOTO_OVAL ] = "PHOTOO21x28", - [Usr_CLASS_PHOTO_SEL ][Set_USR_PHOTO_RECTANGLE] = "PHOTOR21x28", - [Usr_CLASS_PHOTO_SEL_SEE][Set_USR_PHOTO_CIRCLE ] = "PHOTOC45x60", - [Usr_CLASS_PHOTO_SEL_SEE][Set_USR_PHOTO_ELLIPSE ] = "PHOTOE45x60", - [Usr_CLASS_PHOTO_SEL_SEE][Set_USR_PHOTO_OVAL ] = "PHOTOO45x60", - [Usr_CLASS_PHOTO_SEL_SEE][Set_USR_PHOTO_RECTANGLE] = "PHOTOR45x60", - [Usr_CLASS_PHOTO_PRN ][Set_USR_PHOTO_CIRCLE ] = "PHOTOC45x60", - [Usr_CLASS_PHOTO_PRN ][Set_USR_PHOTO_ELLIPSE ] = "PHOTOE45x60", - [Usr_CLASS_PHOTO_PRN ][Set_USR_PHOTO_OVAL ] = "PHOTOO45x60", - [Usr_CLASS_PHOTO_PRN ][Set_USR_PHOTO_RECTANGLE] = "PHOTOR45x60", + [Usr_CLASS_PHOTO_SEL ][Pho_SHAPE_CIRCLE ] = "PHOTOC21x28", + [Usr_CLASS_PHOTO_SEL ][Pho_SHAPE_ELLIPSE ] = "PHOTOE21x28", + [Usr_CLASS_PHOTO_SEL ][Pho_SHAPE_OVAL ] = "PHOTOO21x28", + [Usr_CLASS_PHOTO_SEL ][Pho_SHAPE_RECTANGLE] = "PHOTOR21x28", + [Usr_CLASS_PHOTO_SEL_SEE][Pho_SHAPE_CIRCLE ] = "PHOTOC45x60", + [Usr_CLASS_PHOTO_SEL_SEE][Pho_SHAPE_ELLIPSE ] = "PHOTOE45x60", + [Usr_CLASS_PHOTO_SEL_SEE][Pho_SHAPE_OVAL ] = "PHOTOO45x60", + [Usr_CLASS_PHOTO_SEL_SEE][Pho_SHAPE_RECTANGLE] = "PHOTOR45x60", + [Usr_CLASS_PHOTO_PRN ][Pho_SHAPE_CIRCLE ] = "PHOTOC45x60", + [Usr_CLASS_PHOTO_PRN ][Pho_SHAPE_ELLIPSE ] = "PHOTOE45x60", + [Usr_CLASS_PHOTO_PRN ][Pho_SHAPE_OVAL ] = "PHOTOO45x60", + [Usr_CLASS_PHOTO_PRN ][Pho_SHAPE_RECTANGLE] = "PHOTOR45x60", }; unsigned NumUsr; bool TRIsOpen = false; @@ -6205,7 +6160,9 @@ static void Usr_DrawClassPhoto (Usr_ClassPhotoType_t ClassPhotoType, SelectedUsrs); /***** Show photo *****/ - Pho_ShowUsrPhotoIfAllowed (&UsrDat,ClassPhoto[ClassPhotoType][Gbl.Prefs.UsrPhotos],Pho_ZOOM,false); + Pho_ShowUsrPhotoIfAllowed (&UsrDat, + ClassPhoto[ClassPhotoType][Gbl.Prefs.PhotoShape],Pho_ZOOM, + false); /***** Photo foot *****/ HTM_DIV_Begin ("class=\"CLASSPHOTO_CAPTION\""); @@ -6374,12 +6331,12 @@ unsigned Usr_GetTotalNumberOfUsers (void) void Usr_WriteAuthor1Line (long UsrCod,bool Hidden) { - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC15x20", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE15x20", - [Set_USR_PHOTO_OVAL ] = "PHOTOO15x20", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR15x20", + [Pho_SHAPE_CIRCLE ] = "PHOTOC15x20", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE15x20", + [Pho_SHAPE_OVAL ] = "PHOTOO15x20", + [Pho_SHAPE_RECTANGLE] = "PHOTOR15x20", }; bool ShowPhoto = false; char PhotoURL[PATH_MAX + 1]; @@ -6398,7 +6355,7 @@ void Usr_WriteAuthor1Line (long UsrCod,bool Hidden) /***** Show photo *****/ Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL : NULL, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM,false); + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM,false); /***** Write name *****/ HTM_DIV_Begin ("class=\"AUTHOR_1_LINE %s\"",Hidden ? "AUTHOR_TXT_LIGHT" : @@ -6422,12 +6379,12 @@ void Usr_ShowTableCellWithUsrData (struct UsrData *UsrDat,unsigned NumRows) [Rol_NET] = ActSeeRecOneTch, [Rol_TCH] = ActSeeRecOneTch, }; - static const char *ClassPhoto[Set_NUM_USR_PHOTOS] = + static const char *ClassPhoto[Pho_NUM_SHAPES] = { - [Set_USR_PHOTO_CIRCLE ] = "PHOTOC45x60", - [Set_USR_PHOTO_ELLIPSE ] = "PHOTOE45x60", - [Set_USR_PHOTO_OVAL ] = "PHOTOO45x60", - [Set_USR_PHOTO_RECTANGLE] = "PHOTOR45x60", + [Pho_SHAPE_CIRCLE ] = "PHOTOC45x60", + [Pho_SHAPE_ELLIPSE ] = "PHOTOE45x60", + [Pho_SHAPE_OVAL ] = "PHOTOO45x60", + [Pho_SHAPE_RECTANGLE] = "PHOTOR45x60", }; /***** Show user's photo *****/ @@ -6437,7 +6394,7 @@ void Usr_ShowTableCellWithUsrData (struct UsrData *UsrDat,unsigned NumRows) else HTM_TD_Begin ("class=\"LT LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); Pho_ShowUsrPhotoIfAllowed (UsrDat, - ClassPhoto[Gbl.Prefs.UsrPhotos],Pho_ZOOM, + ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM, false); HTM_TD_End (); diff --git a/swad_user.h b/swad_user.h index 9bf9d3ed..9f86e267 100644 --- a/swad_user.h +++ b/swad_user.h @@ -40,6 +40,7 @@ #include "swad_menu.h" #include "swad_nickname.h" #include "swad_password.h" +#include "swad_photo_shape.h" #include "swad_privacy_visibility_type.h" #include "swad_role_type.h" #include "swad_scope.h" @@ -214,7 +215,7 @@ struct UsrData Ico_IconSet_t IconSet; Mnu_Menu_t Menu; unsigned SideCols; - Set_UsrPhotos_t UsrPhotos; + Pho_Shape_t PhotoShape; bool AcceptThirdPartyCookies; // User has accepted third party cookies } Prefs; }; diff --git a/swad_user_database.c b/swad_user_database.c index 199be7c9..67e24c8a 100644 --- a/swad_user_database.c +++ b/swad_user_database.c @@ -275,7 +275,7 @@ unsigned Usr_DB_GetUsrDataFromUsrCod (MYSQL_RES **mysql_res,long UsrCod, "IconSet," // row[27] "Menu," // row[28] "SideCols," // row[29] - "UsrPhotos," // row[30] + "PhotoShape," // row[30] "ThirdPartyCookies" // row[31] " FROM usr_data" " WHERE UsrCod=%ld",