");
/* Show photo */
@@ -774,29 +789,27 @@ void Pho_RemoveUsrFromTableClicksWithoutPhoto (long UsrCod)
bool Pho_ShowUsrPhotoIsAllowed (struct UsrData *UsrDat,char *PhotoURL)
{
bool ICanSeePhoto = false;
+ bool ItsMe = Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod;
/***** Check if I can see the other's photo *****/
- if (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod || // It's me
- Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SYS_ADM)
- // I always can see my photo
- // A superuser always can see any user's photo
- ICanSeePhoto = true;
- else if (Gbl.Usrs.Me.MaxRole == Rol_ROLE_STUDENT ||
- Gbl.Usrs.Me.MaxRole == Rol_ROLE_TEACHER ||
- Gbl.Usrs.Me.LoggedRole >= Rol_ROLE_DEG_ADM)
+ switch (UsrDat->PhotoVisibility)
{
- // If the maximum role of both users is student
- if (Gbl.Usrs.Me.MaxRole == Rol_ROLE_STUDENT && // My maximum role is student
- (UsrDat->Roles & (1 << Rol_ROLE_STUDENT)) && // He/she is a student in some courses...
- !(UsrDat->Roles & (1 << Rol_ROLE_TEACHER))) // ...but he/she is not a teacher in any course
- // A student only can see the photo of another student if both photos are public
- ICanSeePhoto = (Gbl.Usrs.Me.MyPhotoExists && // I have photo...
- Gbl.Usrs.Me.UsrDat.PublicPhoto && // ...and my photo is public...
- UsrDat->PublicPhoto); // ...and the other student' photo is also public
- else if (UsrDat->PublicPhoto) // The photo of the other user is public
- ICanSeePhoto = true;
- else
- ICanSeePhoto = Usr_CheckIfUsrSharesAnyOfMyCrs (UsrDat->UsrCod); // Both users share the same course
+ case Pho_VISIBILITY_USER: // Only visible by me and my teachers if I am a student or me and my students if I am a teacher
+ if (ItsMe || // I always can see my photo
+ Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SYS_ADM) // A system admin always can see any user's photo
+ ICanSeePhoto = true;
+ else
+ ICanSeePhoto = Usr_CheckIfUsrSharesAnyOfMyCrsWithDifferentRole (UsrDat->UsrCod); // Both users share the same course but whit different role
+ break;
+ case Pho_VISIBILITY_COURSE: // Visible by users sharing courses with me
+ ICanSeePhoto = Usr_CheckIfUsrSharesAnyOfMyCrs (UsrDat->UsrCod); // Both users share the same course
+ break;
+ case Pho_VISIBILITY_SYSTEM: // Visible by any user logged in platform
+ ICanSeePhoto = Gbl.Usrs.Me.Logged;
+ break;
+ case Pho_VISIBILITY_WORLD: // Public, visible by all the people, even unlogged visitors
+ ICanSeePhoto = true;
+ break;
}
/***** Photo is shown if I can see it, and it exists *****/
@@ -1009,59 +1022,105 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
}
/*****************************************************************************/
-/*********************** Select public / private photo ***********************/
+/************************** Select photo visibility **************************/
/*****************************************************************************/
-static void Pho_PutFormPublicPhoto (void)
+static void Pho_PutFormPhotoVisibility (void)
{
- extern const char *The_ClassFormul[The_NUM_THEMES];
- extern const char *Txt_Public_photo;
-
/***** Start form *****/
Act_FormStart (ActChgPubPho);
- /***** Checkbox to select between public or private photo *****/
- fprintf (Gbl.F.Out,""
- "%s",
- Gbl.FormId,
- The_ClassFormul[Gbl.Prefs.Theme],Txt_Public_photo);
+ /***** Select photo visibility *****/
+ Pho_PutSelectorPhotoVisibility (true);
/***** End form *****/
fprintf (Gbl.F.Out,"");
}
/*****************************************************************************/
-/********** Get parameter with public / private photo from form **************/
+/************************** Select photo visibility **************************/
/*****************************************************************************/
-bool Pho_GetParamPublicPhoto (void)
+void Pho_PutSelectorPhotoVisibility (bool SendOnChange)
{
- char YN[1+1];
+ extern const char *Txt_PHOTO_VISIBILITY[Pho_NUM_VISIBILITIES];
+ Pho_Visibility_t PhotoVisibility;
- Par_GetParToText ("PublicPhoto",YN,1);
- return (Str_ConvertToUpperLetter (YN[0]) == 'Y');
+ /***** Select photo visibility *****/
+ fprintf (Gbl.F.Out,"");
}
/*****************************************************************************/
-/*********************** Change public / private photo ***********************/
+/************************* Get icon set from string **************************/
/*****************************************************************************/
-void Pho_ChangePublicPhoto (void)
+Pho_Visibility_t Pho_GetPhotoVisibilityFromStr (const char *Str)
{
- char Query[512];
+ Pho_Visibility_t PhotoVisibility;
+
+ for (PhotoVisibility = (Pho_Visibility_t) 0;
+ PhotoVisibility < Pho_NUM_VISIBILITIES;
+ PhotoVisibility++)
+ if (!strcasecmp (Str,Pho_VisibilityDB[PhotoVisibility]))
+ return PhotoVisibility;
+
+ return Pho_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 >= Pho_NUM_VISIBILITIES)
+ Lay_ShowErrorAndExit ("Photo visibility is missing.");
+ return (Pho_Visibility_t) UnsignedNum;
+ }
+ return Pho_VISIBILITY_DEFAULT;
+ }
+
+/*****************************************************************************/
+/************************** Change photo visibility **************************/
+/*****************************************************************************/
+
+void Pho_ChangePhotoVisibility (void)
+ {
+ char Query[128];
/***** Get param with public/private photo *****/
- Gbl.Usrs.Me.UsrDat.PublicPhoto = Pho_GetParamPublicPhoto ();
+ Gbl.Usrs.Me.UsrDat.PhotoVisibility = Pho_GetParamPhotoVisibility ();
/***** Store public/private photo in database *****/
- sprintf (Query,"UPDATE usr_data SET PublicPhoto='%c' WHERE UsrCod='%ld'",
- Gbl.Usrs.Me.UsrDat.PublicPhoto ? 'Y' :
- 'N',
+ sprintf (Query,"UPDATE usr_data SET PhotoVisibility='%s'"
+ " WHERE UsrCod='%ld'",
+ Pho_VisibilityDB[Gbl.Usrs.Me.UsrDat.PhotoVisibility],
Gbl.Usrs.Me.UsrDat.UsrCod);
- DB_QueryUPDATE (Query,"can not update your preference about public photo");
+ DB_QueryUPDATE (Query,"can not update your preference about photo visibility");
}
/*****************************************************************************/
@@ -1507,7 +1566,7 @@ static void Pho_PutSelectorForTypeOfAvg (void)
fprintf (Gbl.F.Out,"",Txt_AVERAGE_PHOTO_TYPES[TypeOfAvg]);
}
fprintf (Gbl.F.Out,""
""
@@ -1577,7 +1636,7 @@ static void Pho_PutSelectorForHowComputePhotoSize (void)
fprintf (Gbl.F.Out,"",Txt_STAT_DEGREE_PHOTO_SIZE[PhoSi]);
}
fprintf (Gbl.F.Out,""
""
@@ -1647,7 +1706,7 @@ static void Pho_PutSelectorForHowOrderDegrees (void)
fprintf (Gbl.F.Out,"",Txt_STAT_DEGREE_PHOTO_ORDER[Order]);
}
fprintf (Gbl.F.Out,""
""
diff --git a/swad_photo.h b/swad_photo.h
index e7ed0a40a..367a0af50 100644
--- a/swad_photo.h
+++ b/swad_photo.h
@@ -101,8 +101,10 @@ void Pho_UpdatePhotoName (struct UsrData *UsrDat);
void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
const char *ClassPhoto,bool Zoom);
-bool Pho_GetParamPublicPhoto (void);
-void Pho_ChangePublicPhoto (void);
+void Pho_PutSelectorPhotoVisibility (bool SendOnChange);
+Pho_Visibility_t Pho_GetPhotoVisibilityFromStr (const char *Str);
+bool Pho_GetParamPhotoVisibility (void);
+void Pho_ChangePhotoVisibility (void);
void Pho_CalcPhotoDegree (void);
void Pho_RemoveObsoleteStatDegrees (void);
diff --git a/swad_photo_visibility.h b/swad_photo_visibility.h
new file mode 100644
index 000000000..af931daba
--- /dev/null
+++ b/swad_photo_visibility.h
@@ -0,0 +1,51 @@
+// swad_photo_visibility.h: Users' photo visibility
+
+#ifndef _SWAD_PHO_VISIBILITY
+#define _SWAD_PHO_VISIBILITY
+/*
+ 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-2015 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 ***********************************/
+/*****************************************************************************/
+
+/*****************************************************************************/
+/************************* Public types and constants ************************/
+/*****************************************************************************/
+
+/***** Photo visibility (who can see user's photo) *****/
+#define Pho_NUM_VISIBILITIES 4
+
+typedef enum
+ {
+ Pho_VISIBILITY_USER = 0, // Only visible by me and my teachers if I am a student or my students if I am a teacher
+ Pho_VISIBILITY_COURSE = 1, // Visible by users sharing courses with me
+ Pho_VISIBILITY_SYSTEM = 2, // Visible by any user logged in platform
+ Pho_VISIBILITY_WORLD = 3, // Public, visible by all the people, even unlogged visitors
+ } Pho_Visibility_t;
+
+#define Pho_VISIBILITY_DEFAULT Pho_VISIBILITY_USER
+
+/*****************************************************************************/
+/***************************** Public prototypes *****************************/
+/*****************************************************************************/
+
+#endif
diff --git a/swad_record.c b/swad_record.c
index d4aafc338..fb3ac719e 100644
--- a/swad_record.c
+++ b/swad_record.c
@@ -2024,8 +2024,7 @@ void Rec_ShowSharedUsrRecord (Rec_RecordViewType_t TypeOfView,
extern const char *Txt_Surname_1;
extern const char *Txt_Surname_2;
extern const char *Txt_First_name;
- extern const char *Txt_Private_Photo;
- extern const char *Txt_Public_photo;
+ extern const char *Txt_PHOTO_VISIBILITY[Pho_NUM_VISIBILITIES];
extern const char *Txt_Country;
extern const char *Txt_Another_country;
extern const char *Txt_Place_of_origin;
@@ -2348,16 +2347,10 @@ void Rec_ShowSharedUsrRecord (Rec_RecordViewType_t TypeOfView,
{
fprintf (Gbl.F.Out," ");
if (TypeOfView == Rec_FORM_MY_COMMON_RECORD)
- {
- fprintf (Gbl.F.Out,"PublicPhoto)
- fprintf (Gbl.F.Out," checked=\"checked\"");
- fprintf (Gbl.F.Out," /> %s",Txt_Public_photo);
- }
+ /***** Select photo visibility *****/
+ Pho_PutSelectorPhotoVisibility (false);
else if (TypeOfView == Rec_MY_COMMON_RECORD_CHECK)
- fprintf (Gbl.F.Out,"%s",
- UsrDat->PublicPhoto ? Txt_Public_photo :
- Txt_Private_Photo);
+ fprintf (Gbl.F.Out,"%s",Txt_PHOTO_VISIBILITY[UsrDat->PhotoVisibility]);
}
fprintf (Gbl.F.Out,""
"");
@@ -3082,7 +3075,7 @@ void Rec_GetUsrExtraDataFromRecordForm (struct UsrData *UsrDat)
UsrDat->Sex = (Usr_Sex_t) UnsignedNum;
/***** Get whether photo is public from form *****/
- UsrDat->PublicPhoto = Pho_GetParamPublicPhoto ();
+ UsrDat->PhotoVisibility = Pho_GetParamPhotoVisibility ();
/***** Get country code *****/
Par_GetParToText ("OthCtyCod",LongStr,1+10);
diff --git a/swad_text.c b/swad_text.c
index 89fd1d2ed..13b5977e5 100644
--- a/swad_text.c
+++ b/swad_text.c
@@ -19341,9 +19341,9 @@ const char *Txt_MENU_SUBTITLE[Tab_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB] =
#elif L==1
"Profil"
#elif L==2
- "A user's profile"
+ "Public profile of a user"
#elif L==3
- "Perfil de un usuario"
+ "Perfil público de un usuario"
#elif L==4
"Profil"
#elif L==5
@@ -26240,6 +26240,89 @@ const char *Txt_Photo_removed =
"Photo removed."; // Necessita de tradução
#endif
+const char *Txt_PHOTO_VISIBILITY[Pho_NUM_VISIBILITIES] =
+ { // Pho_VISIBILITY_USER
+#if L==0
+ "Foto visible por mí y mis profesores / mis estudiantes" // Necessita traduccio
+#elif L==1
+ "Photo visible by me and my teachers / my students" // Need Übersetzung
+#elif L==2
+ "Photo visible by me and my teachers / my students"
+#elif L==3
+ "Foto visible por mí y mis profesores / mis estudiantes"
+#elif L==4
+ "Photo visible by me and my teachers / my students" // Besoin de traduction
+#elif L==5
+ "Foto visible por mí y mis profesores / mis estudiantes" // Okoteve traducción
+#elif L==6
+ "Photo visible by me and my teachers / my students" // Bisogno di traduzione
+#elif L==7
+ "Photo visible by me and my teachers / my students" // Potrzebujesz tlumaczenie
+#elif L==8
+ "Photo visible by me and my teachers / my students" // Necessita de tradução
+#endif
+ , // Pho_VISIBILITY_COURSE
+#if L==0
+ "Foto visible por usuarios de mis asignaturas" // Necessita traduccio
+#elif L==1
+ "Photo visible by users in my courses" // Need Übersetzung
+#elif L==2
+ "Photo visible by users in my courses"
+#elif L==3
+ "Foto visible por usuarios de mis asignaturas"
+#elif L==4
+ "Photo visible by users in my courses" // Besoin de traduction
+#elif L==5
+ "Foto visible por usuarios de mis asignaturas" // Okoteve traducción
+#elif L==6
+ "Photo visible by users in my courses" // Bisogno di traduzione
+#elif L==7
+ "Photo visible by users in my courses" // Potrzebujesz tlumaczenie
+#elif L==8
+ "Photo visible by users in my courses" // Necessita de tradução
+#endif
+ , // Pho_VISIBILITY_SYSTEM
+#if L==0
+ "Foto visible por cualquier usuario identificado" // Necessita traduccio
+#elif L==1
+ "Photo visible by any logged user" // Need Übersetzung
+#elif L==2
+ "Photo visible by any logged user"
+#elif L==3
+ "Foto visible por cualquier usuario identificado"
+#elif L==4
+ "Photo visible by any logged user" // Besoin de traduction
+#elif L==5
+ "Foto visible por cualquier usuario identificado" // Okoteve traducción
+#elif L==6
+ "Photo visible by any logged user" // Bisogno di traduzione
+#elif L==7
+ "Photo visible by any logged user" // Potrzebujesz tlumaczenie
+#elif L==8
+ "Photo visible by any logged user" // Necessita de tradução
+#endif
+ , // Pho_VISIBILITY_WORLD
+#if L==0
+ "Foto pública, visible por todo el mundo" // Necessita traduccio
+#elif L==1
+ "Public photo, visible by everyone" // Need Übersetzung
+#elif L==2
+ "Public photo, visible by everyone"
+#elif L==3
+ "Foto pública, visible por todo el mundo"
+#elif L==4
+ "Public photo, visible by everyone" // Besoin de traduction
+#elif L==5
+ "Foto pública, visible por todo el mundo" // Okoteve traducción
+#elif L==6
+ "Public photo, visible by everyone" // Bisogno di traduzione
+#elif L==7
+ "Public photo, visible by everyone" // Potrzebujesz tlumaczenie
+#elif L==8
+ "Public photo, visible by everyone" // Necessita de tradução
+#endif
+ };
+
const char *Txt_photos =
#if L==0
"fotos";
@@ -26944,27 +27027,6 @@ const char *Txt_posts =
"posts";
#endif
-const char *Txt_Public_photo =
-#if L==0
- "Foto pública";
-#elif L==1
- "Öffentliches Foto";
-#elif L==2
- "Public photo";
-#elif L==3
- "Foto pública";
-#elif L==4
- "Photo public";
-#elif L==5
- "Foto pública"; // Okoteve traducción
-#elif L==6
- "Foto pubblica";
-#elif L==7
- "Zdjęcie publiczne";
-#elif L==8
- "Foto pública";
-#endif
-
const char *Txt_Public_open_educational_resource_OER_for_everyone =
#if L==0
"Públic, recurs educatiu obert (OER) per a tothom";
@@ -44556,75 +44618,6 @@ const char *Txt_To_remove_an_institution_you_must_first_remove_all_centres_and_u
" all centres and users in the institution."; // Necessita de tradução
#endif
-const char *Txt_to_see_photos_of_others_you_have_to_allow_others_to_see_your_photo_you_can_do_it_in_X = // Warning: it is very important to include %s in the following sentences
-#if L==0
- "para ver las fotos de otros,"
- " tiene que permitir que otros vean la suya;"
- " puede hacerlo en %s"; // Necessita traduccio
-#elif L==1
- "to see photos of others,"
- " you have to allow others to see your photo;"
- " you can do it in %s"; // Need Übersetzung
-#elif L==2
- "to see photos of others,"
- " you have to allow others to see your photo;"
- " you can do it in %s";
-#elif L==3
- "para ver las fotos de otros,"
- " tiene que permitir que otros vean la suya;"
- " puede hacerlo en %s";
-#elif L==4
- "to see photos of others,"
- " you have to allow others to see your photo;"
- " you can do it in %s"; // Besoin de traduction
-#elif L==5
- "para ver las fotos de otros,"
- " tiene que permitir que otros vean la suya;"
- " puede hacerlo en %s"; // Okoteve traducción
-#elif L==6
- "per vedere le foto di altri,"
- " devi permettere agli altri di vedere la tua foto;"
- " puoi farlo in %s";
-#elif L==7
- "to see photos of others,"
- " you have to allow others to see your photo;"
- " you can do it in %s"; // Potrzebujesz tlumaczenie
-#elif L==8
- "to see photos of others,"
- " you have to allow others to see your photo;"
- " you can do it in %s"; // Necessita de tradução
-#endif
-
-const char *Txt_to_see_photos_of_others_you_have_to_send_your_photo_you_can_do_it_in_X = // Warning: it is very important to include %s in the following sentences
-#if L==0
- "para ver las fotos de otros, tiene que enviar la suya;"
- " puede hacerlo en %s"; // Necessita traduccio
-#elif L==1
- "to see photos of others, you have to send your photo;"
- " you can do it in %s"; // Need Übersetzung
-#elif L==2
- "to see photos of others, you have to send your photo;"
- " you can do it in %s";
-#elif L==3
- "para ver las fotos de otros, tiene que enviar la suya;"
- " puede hacerlo en %s";
-#elif L==4
- "to see photos of others, you have to send your photo;"
- " you can do it in %s"; // Besoin de traduction
-#elif L==5
- "para ver las fotos de otros, tiene que enviar la suya;"
- " puede hacerlo en %s"; // Okoteve traducción
-#elif L==6
- "per vedere le foto di altri, devi inviare la tua foto;"
- " puoi farlo in %s";
-#elif L==7
- "to see photos of others, you have to send your photo;"
- " you can do it in %s"; // Potrzebujesz tlumaczenie
-#elif L==8
- "to see photos of others, you have to send your photo;"
- " you can do it in %s"; // Necessita de tradução
-#endif
-
const char *Txt_To_use_chat_you_must_have_installed_the_software_X_and_add_Y_ = // Warning: it is very important to include three %s in the following sentences
#if L==0
"Per utilitzar el xat cal tenir instal lat el programari"
@@ -46765,25 +46758,25 @@ const char *Txt_View =
"Ver";
#endif
-const char *Txt_View_a_user_profile =
+const char *Txt_View_a_user_public_profile =
#if L==0
- "Veure el perfil d'un usuari";
+ "Veure el perfil públic d'un usuari";
#elif L==1
- "Benutzer-Profile anzeigen";
+ "Öffentliches Benutzer-Profile anzeigen";
#elif L==2
- "View a user's profile";
+ "View a user's public profile";
#elif L==3
- "Ver el perfil de un usuario";
+ "Ver el perfil público de un usuario";
#elif L==4
- "Voir le profil d'un utilisateur";
+ "Voir le profil public d'un utilisateur";
#elif L==5
- "Ver el perfil de un usuario"; // Okoteve traducción
+ "Ver el perfil público de un usuario"; // Okoteve traducción
#elif L==6
- "Mostra il profilo di un utente";
+ "Mostra il profilo pubblico di un utente";
#elif L==7
- "Zobacz profil użytkownika";
+ "Zobacz profil publiczny użytkownika";
#elif L==8
- "Ver o perfil de um utilizador";
+ "Ver o perfil público de um utilizador";
#endif
const char *Txt_View_all_recipients =
diff --git a/swad_user.c b/swad_user.c
index b4d33175a..13f46e152 100644
--- a/swad_user.c
+++ b/swad_user.c
@@ -238,7 +238,7 @@ void Usr_ResetUsrDataExceptUsrCodAndIDs (struct UsrData *UsrDat)
UsrDat->EmailConfirmed = false;
UsrDat->Photo[0] = '\0';
- UsrDat->PublicPhoto = false;
+ UsrDat->PhotoVisibility = Pho_VISIBILITY_DEFAULT;
UsrDat->CtyCod = -1L;
UsrDat->OriginPlace[0] = '\0';
@@ -383,13 +383,12 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat)
The_Theme_t Theme;
Ico_IconSet_t IconSet;
Txt_Language_t Lan;
- char YN[1+1];
- char StrBirthday[4+1+2+1+2+1];
unsigned UnsignedNum;
+ char StrBirthday[4+1+2+1+2+1];
/***** Get user's data from database *****/
sprintf (Query,"SELECT EncryptedUsrCod,Password,Surname1,Surname2,FirstName,Sex,"
- "Layout,Theme,IconSet,Language,Photo,PublicPhoto,"
+ "Layout,Theme,IconSet,Language,Photo,PhotoVisibility,"
"CtyCod,InsCtyCod,InsCod,DptCod,CtrCod,Office,OfficePhone,"
"LocalAddress,LocalPhone,FamilyAddress,FamilyPhone,OriginPlace,Birthday,Comments,"
"Menu,SideCols,NotifNtfEvents,EmailNtfEvents"
@@ -468,23 +467,22 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat)
}
/* Get rest of data */
- strncpy (UsrDat->Photo ,row[10],sizeof (UsrDat->Photo )-1);
- strncpy (YN ,row[11],1);
- UsrDat->PublicPhoto = (Str_ConvertToUpperLetter (YN[0]) == 'Y');
+ strncpy (UsrDat->Photo,row[10],sizeof (UsrDat->Photo)-1);
+ UsrDat->PhotoVisibility = Pho_GetPhotoVisibilityFromStr (row[11]);
UsrDat->CtyCod = Str_ConvertStrCodToLongCod (row[12]);
UsrDat->InsCtyCod = Str_ConvertStrCodToLongCod (row[13]);
UsrDat->InsCod = Str_ConvertStrCodToLongCod (row[14]);
UsrDat->Tch.DptCod = Str_ConvertStrCodToLongCod (row[15]);
UsrDat->Tch.CtrCod = Str_ConvertStrCodToLongCod (row[16]);
- strncpy (UsrDat->Tch.Office ,row[17],sizeof (UsrDat->Tch.Office )-1);
- strncpy (UsrDat->Tch.OfficePhone ,row[18],sizeof (UsrDat->Tch.OfficePhone )-1);
+ strncpy (UsrDat->Tch.Office ,row[17],sizeof (UsrDat->Tch.Office )-1);
+ strncpy (UsrDat->Tch.OfficePhone,row[18],sizeof (UsrDat->Tch.OfficePhone)-1);
- strncpy (UsrDat->LocalAddress ,row[19],sizeof (UsrDat->LocalAddress )-1);
- strncpy (UsrDat->LocalPhone ,row[20],sizeof (UsrDat->LocalPhone )-1);
- strncpy (UsrDat->FamilyAddress,row[21],sizeof (UsrDat->FamilyAddress)-1);
- strncpy (UsrDat->FamilyPhone ,row[22],sizeof (UsrDat->FamilyPhone )-1);
- strncpy (UsrDat->OriginPlace ,row[23],sizeof (UsrDat->OriginPlace )-1);
+ strncpy (UsrDat->LocalAddress ,row[19],sizeof (UsrDat->LocalAddress )-1);
+ strncpy (UsrDat->LocalPhone ,row[20],sizeof (UsrDat->LocalPhone )-1);
+ strncpy (UsrDat->FamilyAddress ,row[21],sizeof (UsrDat->FamilyAddress )-1);
+ strncpy (UsrDat->FamilyPhone ,row[22],sizeof (UsrDat->FamilyPhone )-1);
+ strncpy (UsrDat->OriginPlace ,row[23],sizeof (UsrDat->OriginPlace )-1);
strcpy (StrBirthday,
row[24] ? row[24] :
"0000-00-00");
@@ -735,11 +733,30 @@ bool Usr_CheckIfUsrSharesAnyOfMyCrs (long UsrCod)
/***** Get if a user shares any course with me from database *****/
sprintf (Query,"SELECT COUNT(*) FROM crs_usr WHERE UsrCod='%ld'"
- " AND CrsCod IN (SELECT CrsCod FROM crs_usr WHERE UsrCod='%ld')",
+ " AND CrsCod IN"
+ " (SELECT CrsCod FROM crs_usr WHERE UsrCod='%ld')",
UsrCod,Gbl.Usrs.Me.UsrDat.UsrCod);
return (DB_QueryCOUNT (Query,"can not check if a user shares any course with you") != 0);
}
+/*****************************************************************************/
+/*** Check if a user belongs to any of my courses but has a different role ***/
+/*****************************************************************************/
+
+bool Usr_CheckIfUsrSharesAnyOfMyCrsWithDifferentRole (long UsrCod)
+ {
+ char Query[512];
+
+ /***** Get if a user shares any course with me from database *****/
+ sprintf (Query,"SELECT COUNT(*) FROM"
+ "(SELECT CrsCod,Role FROM crs_usr WHERE UsrCod='%ld') AS my_courses,"
+ "(SELECT CrsCod,Role FROM crs_usr WHERE UsrCod='%ld') AS usr_courses"
+ " WHERE my_courses.CrsCod=usr_courses.CrsCod"
+ " AND my_courses.Role!=usr_courses.Role",
+ Gbl.Usrs.Me.UsrDat.UsrCod,UsrCod);
+ return (DB_QueryCOUNT (Query,"can not check if a user shares any course with you") != 0);
+ }
+
/*****************************************************************************/
/** Get all my institutions (those of my courses) and store them in a list ***/
/*****************************************************************************/
@@ -6800,19 +6817,11 @@ void Usr_SeeTchClassPhotoPrn (void)
static void Usr_DrawClassPhoto (Usr_ClassPhotoType_t ClassPhotoType,
Rol_Role_t RoleInClassPhoto)
{
- extern const char *Txt_to_see_photos_of_others_you_have_to_allow_others_to_see_your_photo_you_can_do_it_in_X;
- extern const char *Txt_to_see_photos_of_others_you_have_to_send_your_photo_you_can_do_it_in_X;
struct ListUsers *LstUsrs;
unsigned NumUsr;
bool TRIsOpen = false;
- bool IAmLoggedAsTeacherOrAbove = (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_TEACHER ||
- Gbl.Usrs.Me.LoggedRole == Rol_ROLE_DEG_ADM ||
- Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SYS_ADM);
- bool ICanSeePhotos = (IAmLoggedAsTeacherOrAbove ||
- (Gbl.Usrs.Me.MyPhotoExists &&
- Gbl.Usrs.Me.UsrDat.PublicPhoto));
bool PutCheckBoxToSelectUsr = (ClassPhotoType == Usr_CLASS_PHOTO_SEL ||
- ClassPhotoType == Usr_CLASS_PHOTO_SEL_SEE);
+ ClassPhotoType == Usr_CLASS_PHOTO_SEL_SEE);
bool PutOriginPlace = (RoleInClassPhoto == Rol_ROLE_STUDENT &&
(ClassPhotoType == Usr_CLASS_PHOTO_SEL_SEE ||
ClassPhotoType == Usr_CLASS_PHOTO_SEE ||
@@ -6824,7 +6833,6 @@ static void Usr_DrawClassPhoto (Usr_ClassPhotoType_t ClassPhotoType,
const char *ClassPhoto = "PHOTO18x24"; // Default photo size
int LengthUsrData = 10; // Maximum number of characters of user data
char PhotoURL[PATH_MAX+1];
- char BreadcrumbStr[512];
struct UsrData UsrDat;
/***** Show guests, students or teachers? *****/
@@ -6970,31 +6978,6 @@ static void Usr_DrawClassPhoto (Usr_ClassPhotoType_t ClassPhotoType,
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
-
- /***** Write message in case of the user can not view the photos of others *****/
- if (!ICanSeePhotos && RoleInClassPhoto == Rol_ROLE_STUDENT &&
- ClassPhotoType != Usr_CLASS_PHOTO_PRN)
- {
- fprintf (Gbl.F.Out,"