diff --git a/Makefile b/Makefile
index 3efcf32e..c38beb6e 100644
--- a/Makefile
+++ b/Makefile
@@ -38,7 +38,7 @@ OBJS = swad_account.o swad_action.o swad_announcement.o swad_assignment.o swad_a
swad_layout.o swad_link.o swad_logo.o \
swad_mail.o swad_main.o swad_mark.o swad_menu.o swad_message.o \
swad_network.o swad_nickname.o swad_notice.o swad_notification.o \
- swad_pagination.o swad_parameter.o swad_password.o swad_photo.o swad_place.o swad_plugin.o swad_preference.o \
+ swad_pagination.o swad_parameter.o swad_password.o swad_photo.o swad_place.o swad_plugin.o swad_preference.o swad_privacy.o \
swad_QR.o \
swad_record.o swad_role.o swad_RSS.o \
swad_scope.o swad_search.o swad_session.o swad_setup.o swad_statistic.o swad_string.o swad_survey.o swad_syllabus.o \
diff --git a/swad_account.c b/swad_account.c
index f67b7e99..97e1c440 100644
--- a/swad_account.c
+++ b/swad_account.c
@@ -412,7 +412,7 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat)
{
extern const char *The_ThemeId[The_NUM_THEMES];
extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS];
- extern const char *Pri_VISIBILITYDB[Pri_NUM_OPTIONS_PRIVACY];
+ extern const char *Pri_VisibilityDB[Pri_NUM_OPTIONS_PRIVACY];
extern const char *Txt_STR_LANG_ID[Txt_NUM_LANGUAGES];
extern const char *Usr_StringsSexDB[Usr_NUM_SEXS];
char Query[2048];
@@ -449,7 +449,7 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat)
The_ThemeId[UsrDat->Prefs.Theme],
Ico_IconSetId[UsrDat->Prefs.IconSet],
Txt_STR_LANG_ID[UsrDat->Prefs.Language],
- Pri_VISIBILITYDB[UsrDat->PhotoVisibility],
+ Pri_VisibilityDB[UsrDat->PhotoVisibility],
UsrDat->CtyCod,
UsrDat->LocalAddress ,UsrDat->LocalPhone,
UsrDat->FamilyAddress,UsrDat->FamilyPhone,
diff --git a/swad_action.c b/swad_action.c
index 07637f69..041cbe7b 100644
--- a/swad_action.c
+++ b/swad_action.c
@@ -2595,7 +2595,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
/* ActRemMyPho */{ 428,-1,TabPrf,ActReqEdiRecCom ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,Pho_RemoveMyPhoto1 ,Pho_RemoveMyPhoto2 ,NULL},
/* ActChgPubPho */{ 774,-1,TabPrf,ActReqEdiRecCom ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Pho_ChangePhotoVisibility ,NULL},
- /* ActEdiPri */{1403,-1,TabPrf,ActReqEdiRecCom ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Rec_EditMyPrivacy ,NULL},
+ /* ActEdiPri */{1403,-1,TabPrf,ActReqEdiRecCom ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Pri_EditMyPrivacy ,NULL},
/* ActReqEdiMyIns */{1165,-1,TabPrf,ActReqEdiRecCom ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Rec_ShowFormMyInsCtrDpt ,NULL},
/* ActChgCtyMyIns */{1166,-1,TabPrf,ActReqEdiRecCom ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Rec_ChgCountryOfMyInstitution ,NULL},
diff --git a/swad_changelog.h b/swad_changelog.h
index ae589f8c..2400bb3b 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -103,11 +103,15 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
-#define Log_PLATFORM_VERSION "SWAD 14.78.3 (2015/03/06)"
+#define Log_PLATFORM_VERSION "SWAD 14.79 (2015/03/06)"
// Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h | tail -1
/*
+ Version 14.79: Mar 06, 2015 New module swad_privacy. (178678 lines)
+ 1 change necessary in Makefile:
+Add swad_privacy.o to list of object files
+
Version 14.78.3: Mar 06, 2015 Changes in messages about privacity. (178631 lines)
Version 14.78.2: Mar 06, 2015 New action to edit privacy options. (178630 lines)
Version 14.78.1: Mar 06, 2015 New link to privacy options (unfinished). (178595 lines)
diff --git a/swad_enrollment.c b/swad_enrollment.c
index 0b24d70e..9b7e7563 100644
--- a/swad_enrollment.c
+++ b/swad_enrollment.c
@@ -372,7 +372,7 @@ void Enr_UpdateUsrData (struct UsrData *UsrDat)
{
extern const char *The_ThemeId[The_NUM_THEMES];
extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS];
- extern const char *Pri_VISIBILITYDB[Pri_NUM_OPTIONS_PRIVACY];
+ extern const char *Pri_VisibilityDB[Pri_NUM_OPTIONS_PRIVACY];
extern const char *Txt_STR_LANG_ID[Txt_NUM_LANGUAGES];
extern const char *Usr_StringsSexDB[Usr_NUM_SEXS];
char Query[2048];
@@ -399,7 +399,7 @@ void Enr_UpdateUsrData (struct UsrData *UsrDat)
The_ThemeId[UsrDat->Prefs.Theme],
Ico_IconSetId[UsrDat->Prefs.IconSet],
Txt_STR_LANG_ID[UsrDat->Prefs.Language],
- Pri_VISIBILITYDB[UsrDat->PhotoVisibility],
+ Pri_VisibilityDB[UsrDat->PhotoVisibility],
UsrDat->CtyCod,
UsrDat->LocalAddress,UsrDat->LocalPhone,
UsrDat->FamilyAddress,UsrDat->FamilyPhone,UsrDat->OriginPlace,
diff --git a/swad_photo.c b/swad_photo.c
index 9be53072..ae7226c3 100644
--- a/swad_photo.c
+++ b/swad_photo.c
@@ -57,15 +57,6 @@ extern struct Globals Gbl;
/****************************** Public constants *****************************/
/*****************************************************************************/
-/***** Photo visibility (who can see user's photo) *****/
-const char *Pri_VISIBILITYDB[Pri_NUM_OPTIONS_PRIVACY] =
- {
- "user", // Pri_VISIBILITY_USER
- "course", // Pri_VISIBILITY_COURSE
- "system", // Pri_VISIBILITY_SYSTEM
- "world", // Pri_VISIBILITY_WORLD
- };
-
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
@@ -248,7 +239,7 @@ void Pho_ReqPhoto (const struct UsrData *UsrDat,bool PhotoExists,const char *Pho
/***** Forms to remove photo and make it public *****/
fprintf (Gbl.F.Out,"
");
Pho_PutLinkToRemoveUsrPhoto (UsrDat);
- Rec_PutLinkToChangeMyPrivacy (); // Put link (form) to change my privacy
+ Pri_PutLinkToChangeMyPrivacy (); // Put link (form) to change my privacy
fprintf (Gbl.F.Out,"
");
/* Show photo */
@@ -1018,106 +1009,23 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
fprintf (Gbl.F.Out," />");
}
-/*****************************************************************************/
-/************************** Select photo visibility **************************/
-/*****************************************************************************/
-
-void Pho_PutFormPhotoVisibility (void)
- {
- extern const char *The_ClassFormul[The_NUM_THEMES];
- extern const char *Txt_Photo;
- extern const char *Txt_PRIVACY_OPTIONS[Pri_NUM_OPTIONS_PRIVACY];
- Pri_VISIBILITY_t PhotoVisibility;
-
- /***** Select photo visibility *****/
- fprintf (Gbl.F.Out,""
- ""
- "%s:"
- " | "
- "",
- The_ClassFormul[Gbl.Prefs.Theme],Txt_Photo);
-
- /***** Form with list of options *****/
- Act_FormStart (ActChgPubPho);
- fprintf (Gbl.F.Out,""
- ""
- " | "
- "
");
- }
-
-/*****************************************************************************/
-/************************* Get icon set from string **************************/
-/*****************************************************************************/
-
-Pri_VISIBILITY_t Pho_GetPhotoVisibilityFromStr (const char *Str)
- {
- Pri_VISIBILITY_t PhotoVisibility;
-
- for (PhotoVisibility = (Pri_VISIBILITY_t) 0;
- PhotoVisibility < Pri_NUM_OPTIONS_PRIVACY;
- PhotoVisibility++)
- if (!strcasecmp (Str,Pri_VISIBILITYDB[PhotoVisibility]))
- return PhotoVisibility;
-
- return Pri_VISIBILITY_DEFAULT;
- }
-
-/*****************************************************************************/
-/************* Get parameter with photo visibility from form *****************/
-/*****************************************************************************/
-
-bool Pho_GetParamPhotoVisibility (void)
- {
- char UnsignedStr[10+1];
- unsigned UnsignedNum;
-
- Par_GetParToText ("PhotoVisibility",UnsignedStr,10);
- if (UnsignedStr[0])
- {
- if (sscanf (UnsignedStr,"%u",&UnsignedNum) != 1)
- Lay_ShowErrorAndExit ("Photo visibility is missing.");
- if (UnsignedNum >= Pri_NUM_OPTIONS_PRIVACY)
- Lay_ShowErrorAndExit ("Photo visibility is missing.");
- return (Pri_VISIBILITY_t) UnsignedNum;
- }
- return Pri_VISIBILITY_DEFAULT;
- }
-
/*****************************************************************************/
/************************** Change photo visibility **************************/
/*****************************************************************************/
void Pho_ChangePhotoVisibility (void)
{
+ extern const char *Pri_VisibilityDB[Pri_NUM_OPTIONS_PRIVACY];
extern const char *Txt_The_visibility_of_your_photo_has_changed;
char Query[128];
/***** Get param with public/private photo *****/
- Gbl.Usrs.Me.UsrDat.PhotoVisibility = Pho_GetParamPhotoVisibility ();
+ Gbl.Usrs.Me.UsrDat.PhotoVisibility = Pri_GetParamVisibility ();
/***** Store public/private photo in database *****/
sprintf (Query,"UPDATE usr_data SET PhotoVisibility='%s'"
" WHERE UsrCod='%ld'",
- Pri_VISIBILITYDB[Gbl.Usrs.Me.UsrDat.PhotoVisibility],
+ Pri_VisibilityDB[Gbl.Usrs.Me.UsrDat.PhotoVisibility],
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE (Query,"can not update your preference about photo visibility");
@@ -1125,7 +1033,7 @@ void Pho_ChangePhotoVisibility (void)
Lay_ShowAlert (Lay_SUCCESS,Txt_The_visibility_of_your_photo_has_changed);
/***** Show form again *****/
- Rec_EditMyPrivacy ();
+ Pri_EditMyPrivacy ();
}
/*****************************************************************************/
diff --git a/swad_photo.h b/swad_photo.h
index f8315c19..9ff46f8f 100644
--- a/swad_photo.h
+++ b/swad_photo.h
@@ -101,9 +101,6 @@ void Pho_UpdatePhotoName (struct UsrData *UsrDat);
void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
const char *ClassPhoto,bool Zoom);
-void Pho_PutFormPhotoVisibility (void);
-Pri_VISIBILITY_t Pho_GetPhotoVisibilityFromStr (const char *Str);
-bool Pho_GetParamPhotoVisibility (void);
void Pho_ChangePhotoVisibility (void);
void Pho_CalcPhotoDegree (void);
diff --git a/swad_privacy.h b/swad_privacy.h
index 4b9e451d..58b7f67e 100644
--- a/swad_privacy.h
+++ b/swad_privacy.h
@@ -1,4 +1,4 @@
-// swad_privacy.h: Users' photo and public profile visibility
+// swad_privacy.h: users' photo and public profile visibility
#ifndef _SWAD_PRI
#define _SWAD_PRI
@@ -40,7 +40,7 @@ typedef enum
Pri_VISIBILITY_COURSE = 1, // Visible by users sharing courses with me
Pri_VISIBILITY_SYSTEM = 2, // Visible by any user logged in platform
Pri_VISIBILITY_WORLD = 3, // Public, visible by all the people, even unlogged visitors
- } Pri_VISIBILITY_t;
+ } Pri_Visibility_t;
#define Pri_VISIBILITY_DEFAULT Pri_VISIBILITY_USER
@@ -48,4 +48,11 @@ typedef enum
/***************************** Public prototypes *****************************/
/*****************************************************************************/
+void Pri_PutLinkToChangeMyPrivacy (void);
+void Pri_EditMyPrivacy (void);
+
+void Pri_PutFormVisibility (Act_Action_t Action,Pri_Visibility_t CurrentVisibilityInDB);
+Pri_Visibility_t Pri_GetVisibilityFromStr (const char *Str);
+bool Pri_GetParamVisibility (void);
+
#endif
diff --git a/swad_record.c b/swad_record.c
index 2e020baa..6425ebb7 100644
--- a/swad_record.c
+++ b/swad_record.c
@@ -1901,7 +1901,7 @@ void Rec_ShowFormMyCommRecord (void)
Pho_PutLinkToChangeUsrPhoto (&Gbl.Usrs.Me.UsrDat); // Put link (form) to change my photo
Rec_PutLinkToChangeMyInsCtrDpt (); // Put link (form) to change my institution, centre, department...
Rec_PutLinkToChangeMySocialNetworks (); // Put link (form) to change my social networks
- Rec_PutLinkToChangeMyPrivacy (); // Put link (form) to change my privacy
+ Pri_PutLinkToChangeMyPrivacy (); // Put link (form) to change my privacy
/***** My record *****/
Act_FormStart (ActChgMyData);
@@ -3065,7 +3065,7 @@ void Rec_GetUsrExtraDataFromRecordForm (struct UsrData *UsrDat)
UsrDat->Sex = (Usr_Sex_t) UnsignedNum;
/***** Get whether photo is public from form *****/
- UsrDat->PhotoVisibility = Pho_GetParamPhotoVisibility ();
+ UsrDat->PhotoVisibility = Pri_GetParamVisibility ();
/***** Get country code *****/
Par_GetParToText ("OthCtyCod",LongStr,1+10);
@@ -3134,40 +3134,6 @@ static void Rec_PutLinkToChangeMySocialNetworks (void)
fprintf (Gbl.F.Out,"");
}
-/*****************************************************************************/
-/*************** Put a link to the action to edit my privacy *****************/
-/*****************************************************************************/
-
-void Rec_PutLinkToChangeMyPrivacy (void)
- {
- extern const char *The_ClassFormul[The_NUM_THEMES];
- extern const char *Txt_Privacy;
-
- /***** Link to edit my social networks *****/
- Act_FormStart (ActEdiPri);
- Act_LinkFormSubmit (Txt_Privacy,The_ClassFormul[Gbl.Prefs.Theme]);
- Lay_PutSendIcon ("padlock",Txt_Privacy,Txt_Privacy);
- fprintf (Gbl.F.Out,"");
- }
-
-/*****************************************************************************/
-/******************************* Edit my privacy *****************************/
-/*****************************************************************************/
-
-void Rec_EditMyPrivacy (void)
- {
- extern const char *Txt_Privacy;
-
- /***** Start table *****/
- Lay_StartRoundFrameTable10 (NULL,2,Txt_Privacy);
-
- /***** Select photo visibility *****/
- Pho_PutFormPhotoVisibility ();
-
- /***** End table *****/
- Lay_EndRoundFrameTable10 ();
- }
-
/*****************************************************************************/
/********* Show form to edit my institution, centre and department ***********/
/*****************************************************************************/
diff --git a/swad_record.h b/swad_record.h
index b17de249..3f541bbe 100644
--- a/swad_record.h
+++ b/swad_record.h
@@ -157,9 +157,6 @@ Rol_Role_t Rec_GetRoleFromRecordForm (void);
void Rec_GetUsrNameFromRecordForm (struct UsrData *UsrDat);
void Rec_GetUsrExtraDataFromRecordForm (struct UsrData *UsrDat);
-void Rec_PutLinkToChangeMyPrivacy (void);
-void Rec_EditMyPrivacy (void);
-
void Rec_ShowFormMyInsCtrDpt (void);
void Rec_ChgCountryOfMyInstitution (void);
void Rec_UpdateMyInstitution (void);
diff --git a/swad_user.c b/swad_user.c
index ad131a53..06a29efa 100644
--- a/swad_user.c
+++ b/swad_user.c
@@ -468,7 +468,7 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat)
/* Get rest of data */
strncpy (UsrDat->Photo,row[10],sizeof (UsrDat->Photo)-1);
- UsrDat->PhotoVisibility = Pho_GetPhotoVisibilityFromStr (row[11]);
+ UsrDat->PhotoVisibility = Pri_GetVisibilityFromStr (row[11]);
UsrDat->CtyCod = Str_ConvertStrCodToLongCod (row[12]);
UsrDat->InsCtyCod = Str_ConvertStrCodToLongCod (row[13]);
UsrDat->InsCod = Str_ConvertStrCodToLongCod (row[14]);
diff --git a/swad_user.h b/swad_user.h
index 6700b9ce..714b3b5d 100644
--- a/swad_user.h
+++ b/swad_user.h
@@ -127,7 +127,7 @@ struct UsrData
char Email [Cns_MAX_BYTES_STRING +1];
bool EmailConfirmed;
char Photo [Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64+1]; // Name of public link to photo
- Pri_VISIBILITY_t PhotoVisibility; // Who can see user's photo
+ Pri_Visibility_t PhotoVisibility; // Who can see user's photo
long CtyCod; // Country
char OriginPlace [Cns_MAX_BYTES_STRING+1];
struct Date Birthday;