Version 14.79

This commit is contained in:
Antonio Cañas Vargas 2015-03-06 22:36:29 +01:00
parent 79675f03ce
commit ba95e29ea9
12 changed files with 29 additions and 150 deletions

View File

@ -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 \

View File

@ -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,

View File

@ -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},

View File

@ -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)

View File

@ -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,

View File

@ -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,"<div style=\"text-align:center;\">");
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,"</div>");
/* 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,"<tr>"
"<td class=\"%s\" style=\"text-align:right;"
" vertical-align:middle;\">"
"%s:"
"</td>"
"<td style=\"text-align:left; vertical-align:middle;\">",
The_ClassFormul[Gbl.Prefs.Theme],Txt_Photo);
/***** Form with list of options *****/
Act_FormStart (ActChgPubPho);
fprintf (Gbl.F.Out,"<ul style=\"list-style-type:none;"
" padding:0; margin:10px auto;\">");
for (PhotoVisibility = (Pri_VISIBILITY_t) 0;
PhotoVisibility < Pri_NUM_OPTIONS_PRIVACY;
PhotoVisibility++)
{
fprintf (Gbl.F.Out,"<li class=\"DAT\">"
"<input type=\"radio\" name=\"WhichForum\" value=\"%u\"",
(unsigned) PhotoVisibility);
if (PhotoVisibility == Gbl.Usrs.Me.UsrDat.PhotoVisibility)
fprintf (Gbl.F.Out," checked=\"checked\"");
fprintf (Gbl.F.Out," onclick=\"javascript:document.getElementById('%s').submit();\" />"
"%s"
"</li>",
Gbl.FormId,Txt_PRIVACY_OPTIONS[PhotoVisibility]);
}
/***** End of list and form *****/
fprintf (Gbl.F.Out,"</ul>"
"</form>"
"</td>"
"</tr>");
}
/*****************************************************************************/
/************************* 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 ();
}
/*****************************************************************************/

View File

@ -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);

View File

@ -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

View File

@ -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,"</form>");
}
/*****************************************************************************/
/*************** 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,"</form>");
}
/*****************************************************************************/
/******************************* 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 ***********/
/*****************************************************************************/

View File

@ -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);

View File

@ -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]);

View File

@ -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;