Version 15.224

This commit is contained in:
Antonio Cañas Vargas 2016-06-12 19:55:33 +02:00
parent 9507e9f48b
commit 7abd6efbd5
6 changed files with 218 additions and 190 deletions

View File

@ -122,7 +122,6 @@
// TODO: Messages in msg_content_deleted older than a certain time should be deleted to ensure the protection of personal data // TODO: Messages in msg_content_deleted older than a certain time should be deleted to ensure the protection of personal data
// TODO: Request confirmation to remove user's photo // TODO: Request confirmation to remove user's photo
// TODO: FIX BUG: A teacher uploads a document in course documents zone, then he/she unregister from course, then he/she search for his/her documents, a document is shown in results but he/she can not view it // TODO: FIX BUG: A teacher uploads a document in course documents zone, then he/she unregister from course, then he/she search for his/her documents, a document is shown in results but he/she can not view it
// TODO: If a follower follows a user whose profile is no longer visible ==> put icon to unfollow in list of followed
// TODO: Modify WS function getUsers changing: userRole to indicate all users, and a new parameter filter (search string (name, @nickname, mail)) to restring number of users // TODO: Modify WS function getUsers changing: userRole to indicate all users, and a new parameter filter (search string (name, @nickname, mail)) to restring number of users
// TODO: Add a new WS function to count the nunmber of users to return in call to function getUsers // TODO: Add a new WS function to count the nunmber of users to return in call to function getUsers
@ -131,13 +130,15 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.223.3 (2016-06-12)" #define Log_PLATFORM_VERSION "SWAD 15.224 (2016-06-12)"
#define CSS_FILE "swad15.218.css" #define CSS_FILE "swad15.218.css"
#define JS_FILE "swad15.216.js" #define JS_FILE "swad15.216.js"
// Number of lines (includes comments but not blank lines) has been got with the following command: // 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 sql/swad*.sql | tail -1 // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
/* /*
Version 15.224: Jun 12, 2016 Now a user can unfollow users followed by him/her whose profile is not visible.
Code refactoring in list of follweing/followers. (202304 lines)
Version 15.223.3: Jun 12, 2016 Fixed layout of list of forums. (202282 lines) Version 15.223.3: Jun 12, 2016 Fixed layout of list of forums. (202282 lines)
Version 15.223.2: Jun 12, 2016 Fixed bug in results of search of students. (202277 lines) Version 15.223.2: Jun 12, 2016 Fixed bug in results of search of students. (202277 lines)
Version 15.223.1: Jun 12, 2016 Show only users to follow with first name and surname 1. (202276 lines) Version 15.223.1: Jun 12, 2016 Show only users to follow with first name and surname 1. (202276 lines)

View File

@ -72,6 +72,10 @@ static void Fol_ShowNumberOfFollowingOrFollowers (const struct UsrData *UsrDat,
unsigned NumUsrs, unsigned NumUsrs,
Act_Action_t Action, Act_Action_t Action,
const char *Title); const char *Title);
static void Fol_ListFollowingUsr (struct UsrData *UsrDat);
static void Fol_ListFollowersUsr (struct UsrData *UsrDat);
static void Fol_ShowFollowedOrFollower (const struct UsrData *UsrDat); static void Fol_ShowFollowedOrFollower (const struct UsrData *UsrDat);
/*****************************************************************************/ /*****************************************************************************/
@ -485,6 +489,24 @@ static void Fol_ShowNumberOfFollowingOrFollowers (const struct UsrData *UsrDat,
/*****************************************************************************/ /*****************************************************************************/
void Fol_ListFollowing (void) void Fol_ListFollowing (void)
{
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
/***** Get user to view user he/she follows *****/
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
{
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat))
Fol_ListFollowingUsr (&Gbl.Usrs.Other.UsrDat);
else
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
}
else // If user not specified, view my profile
Fol_ListFollowingUsr (&Gbl.Usrs.Me.UsrDat);
}
static void Fol_ListFollowingUsr (struct UsrData *UsrDat)
{ {
extern const char *Txt_Following; extern const char *Txt_Following;
extern const char *Txt_User_not_found_or_you_do_not_have_permission_; extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
@ -493,23 +515,20 @@ void Fol_ListFollowing (void)
MYSQL_ROW row; MYSQL_ROW row;
unsigned NumUsrs; unsigned NumUsrs;
unsigned NumUsr; unsigned NumUsr;
struct UsrData UsrDat; struct UsrData FollowingUsrDat;
/***** Get user to view user he/she follows *****/
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
{
/***** Show user's profile *****/ /***** Show user's profile *****/
if (Prf_ShowUserProfile ()) if (Prf_ShowUserProfile (UsrDat))
{ {
/***** Check if a user is a follower of another user *****/ /***** Check if a user is a follower of another user *****/
sprintf (Query,"SELECT FollowedCod FROM usr_follow" sprintf (Query,"SELECT FollowedCod FROM usr_follow"
" WHERE FollowerCod='%ld' ORDER BY FollowTime DESC", " WHERE FollowerCod='%ld' ORDER BY FollowTime DESC",
Gbl.Usrs.Other.UsrDat.UsrCod); UsrDat->UsrCod);
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get followed users"); NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get followed users");
if (NumUsrs) if (NumUsrs)
{ {
/***** Initialize structure with user's data *****/ /***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat); Usr_UsrDataConstructor (&FollowingUsrDat);
/***** Start listing *****/ /***** Start listing *****/
Lay_StartRoundFrameTable ("560px",2,Txt_Following); Lay_StartRoundFrameTable ("560px",2,Txt_Following);
@ -522,13 +541,13 @@ void Fol_ListFollowing (void)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get user's code (row[0]) */ /* Get user's code (row[0]) */
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]); FollowingUsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
/***** Show user *****/ /***** Show user *****/
if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == 0) if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == 0)
fprintf (Gbl.F.Out,"<tr>"); fprintf (Gbl.F.Out,"<tr>");
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&FollowingUsrDat))
Fol_ShowFollowedOrFollower (&UsrDat); Fol_ShowFollowedOrFollower (&FollowingUsrDat);
if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == (Fol_NUM_COLUMNS_FOLLOW-1) || if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == (Fol_NUM_COLUMNS_FOLLOW-1) ||
NumUsr == NumUsrs - 1) NumUsr == NumUsrs - 1)
fprintf (Gbl.F.Out,"</tr>"); fprintf (Gbl.F.Out,"</tr>");
@ -538,7 +557,7 @@ void Fol_ListFollowing (void)
Lay_EndRoundFrameTable (); Lay_EndRoundFrameTable ();
/***** Free memory used for user's data *****/ /***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat); Usr_UsrDataDestructor (&FollowingUsrDat);
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -547,15 +566,30 @@ void Fol_ListFollowing (void)
else else
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
} }
else
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
}
/*****************************************************************************/ /*****************************************************************************/
/******************************* List followers ******************************/ /******************************* List followers ******************************/
/*****************************************************************************/ /*****************************************************************************/
void Fol_ListFollowers (void) void Fol_ListFollowers (void)
{
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
/***** Get user to view user he/she follows *****/
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
{
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat))
Fol_ListFollowersUsr (&Gbl.Usrs.Other.UsrDat);
else
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
}
else // If user not specified, view my profile
Fol_ListFollowersUsr (&Gbl.Usrs.Me.UsrDat);
}
static void Fol_ListFollowersUsr (struct UsrData *UsrDat)
{ {
extern const char *Txt_Followers; extern const char *Txt_Followers;
extern const char *Txt_User_not_found_or_you_do_not_have_permission_; extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
@ -564,28 +598,20 @@ void Fol_ListFollowers (void)
MYSQL_ROW row; MYSQL_ROW row;
unsigned NumUsrs; unsigned NumUsrs;
unsigned NumUsr; unsigned NumUsr;
struct UsrData UsrDat; struct UsrData FollowerUsrDat;
/***** Get user to view user he/she follows *****/
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
if (Gbl.Usrs.Other.UsrDat.UsrCod <= 0) // If user not specified, view my profile
Gbl.Usrs.Other.UsrDat.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
/***** Check if user exists and get his data *****/
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat))
{
/***** Show user's profile *****/ /***** Show user's profile *****/
if (Prf_ShowUserProfile ()) if (Prf_ShowUserProfile (UsrDat))
{ {
/***** Check if a user is a follower of another user *****/ /***** Check if a user is a follower of another user *****/
sprintf (Query,"SELECT FollowerCod FROM usr_follow" sprintf (Query,"SELECT FollowerCod FROM usr_follow"
" WHERE FollowedCod='%ld' ORDER BY FollowTime DESC", " WHERE FollowedCod='%ld' ORDER BY FollowTime DESC",
Gbl.Usrs.Other.UsrDat.UsrCod); UsrDat->UsrCod);
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get followers"); NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get followers");
if (NumUsrs) if (NumUsrs)
{ {
/***** Initialize structure with user's data *****/ /***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat); Usr_UsrDataConstructor (&FollowerUsrDat);
/***** Start listing *****/ /***** Start listing *****/
Lay_StartRoundFrameTable ("560px",2,Txt_Followers); Lay_StartRoundFrameTable ("560px",2,Txt_Followers);
@ -598,13 +624,13 @@ void Fol_ListFollowers (void)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get user's code (row[0]) */ /* Get user's code (row[0]) */
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]); FollowerUsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
/***** Show user *****/ /***** Show user *****/
if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == 0) if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == 0)
fprintf (Gbl.F.Out,"<tr>"); fprintf (Gbl.F.Out,"<tr>");
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&FollowerUsrDat))
Fol_ShowFollowedOrFollower (&UsrDat); Fol_ShowFollowedOrFollower (&FollowerUsrDat);
if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == (Fol_NUM_COLUMNS_FOLLOW-1) || if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == (Fol_NUM_COLUMNS_FOLLOW-1) ||
NumUsr == NumUsrs - 1) NumUsr == NumUsrs - 1)
fprintf (Gbl.F.Out,"</tr>"); fprintf (Gbl.F.Out,"</tr>");
@ -614,14 +640,14 @@ void Fol_ListFollowers (void)
Lay_EndRoundFrameTable (); Lay_EndRoundFrameTable ();
/***** Free memory used for user's data *****/ /***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat); Usr_UsrDataDestructor (&FollowerUsrDat);
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
/***** If it's me, mark possible notification as seen *****/ /***** If it's me, mark possible notification as seen *****/
if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) if (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod)
Ntf_MarkNotifAsSeen (Ntf_EVENT_FOLLOWER, Ntf_MarkNotifAsSeen (Ntf_EVENT_FOLLOWER,
-1L,-1L, -1L,-1L,
Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Usrs.Me.UsrDat.UsrCod);
@ -629,9 +655,6 @@ void Fol_ListFollowers (void)
else else
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
} }
else
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
}
/*****************************************************************************/ /*****************************************************************************/
/************************* Show followed or follower *************************/ /************************* Show followed or follower *************************/
@ -647,32 +670,33 @@ static void Fol_ShowFollowedOrFollower (const struct UsrData *UsrDat)
char PhotoURL[PATH_MAX+1]; char PhotoURL[PATH_MAX+1];
bool Visible = Pri_ShowIsAllowed (UsrDat->ProfileVisibility,UsrDat->UsrCod); bool Visible = Pri_ShowIsAllowed (UsrDat->ProfileVisibility,UsrDat->UsrCod);
/***** Check if I can see the public profile *****/ /***** Show user's photo *****/
fprintf (Gbl.F.Out,"<td class=\"FOLLOW_USR_PHOTO\">"); fprintf (Gbl.F.Out,"<td class=\"FOLLOW_USR_PHOTO\">");
if (Visible) if (Visible)
{ {
/***** User's photo *****/
ShowPhoto = Pho_ShowUsrPhotoIsAllowed (UsrDat,PhotoURL); ShowPhoto = Pho_ShowUsrPhotoIsAllowed (UsrDat,PhotoURL);
Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL : Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL :
NULL, NULL,
"PHOTO60x80",Pho_ZOOM,false); "PHOTO60x80",Pho_ZOOM,false);
} }
fprintf (Gbl.F.Out,"</td>" fprintf (Gbl.F.Out,"</td>");
"<td class=\"FOLLOW_USR_NAME\">");
/***** Show user's name and icon to follow/unfollow *****/
fprintf (Gbl.F.Out,"<td class=\"FOLLOW_USR_NAME\">");
if (Visible) if (Visible)
{ {
/***** Put form to go to public profile *****/ /* Put form to go to public profile */
Act_FormStart (ActSeePubPrf); Act_FormStart (ActSeePubPrf);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Act_LinkFormSubmit (Txt_View_public_profile,"DAT"); Act_LinkFormSubmit (Txt_View_public_profile,"DAT");
Usr_RestrictLengthAndWriteName (UsrDat,10); Usr_RestrictLengthAndWriteName (UsrDat,10);
fprintf (Gbl.F.Out,"</a>"); fprintf (Gbl.F.Out,"</a>");
Act_FormEnd (); Act_FormEnd ();
}
if (!Gbl.Usrs.Me.Logged || // Not logged if (!Gbl.Usrs.Me.Logged || // Not logged
Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod) // It's me Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod) // It's me
/***** Inactive icon to follow / unfollow *****/ /* Inactive icon to follow/unfollow */
fprintf (Gbl.F.Out,"<div class=\"FOLLOW_USR_ICON ICON_HIDDEN\">" fprintf (Gbl.F.Out,"<div class=\"FOLLOW_USR_ICON ICON_HIDDEN\">"
"<img src=\"%s/usr64x64.gif\"" "<img src=\"%s/usr64x64.gif\""
" alt=\"\"" " alt=\"\""
@ -681,9 +705,10 @@ static void Fol_ShowFollowedOrFollower (const struct UsrData *UsrDat)
Gbl.Prefs.IconsURL); Gbl.Prefs.IconsURL);
else else
{ {
/***** Put form to follow / unfollow *****/ /* Put form to follow / unfollow */
if (Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod,UsrDat->UsrCod)) // I follow user if (Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod,UsrDat->UsrCod)) // I follow user
{ {
/* Form to unfollow */
Act_FormStart (ActUnfUsr); Act_FormStart (ActUnfUsr);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Act_LinkFormSubmit (Txt_Following_unfollow,NULL); Act_LinkFormSubmit (Txt_Following_unfollow,NULL);
@ -697,8 +722,9 @@ static void Fol_ShowFollowedOrFollower (const struct UsrData *UsrDat)
Txt_Unfollow,Txt_Following_unfollow); Txt_Unfollow,Txt_Following_unfollow);
Act_FormEnd (); Act_FormEnd ();
} }
else // I do not follow this user else if (Visible) // I do not follow this user and I can follow
{ {
/* Form to follow */
Act_FormStart (ActFolUsr); Act_FormStart (ActFolUsr);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Act_LinkFormSubmit (Txt_Follow,NULL); Act_LinkFormSubmit (Txt_Follow,NULL);
@ -713,8 +739,6 @@ static void Fol_ShowFollowedOrFollower (const struct UsrData *UsrDat)
Act_FormEnd (); Act_FormEnd ();
} }
} }
}
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>");
} }
@ -761,7 +785,7 @@ void Fol_FollowUsr (void)
} }
/***** Show user's profile again *****/ /***** Show user's profile again *****/
Error = !Prf_ShowUserProfile (); Error = !Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
} }
else else
Error = true; Error = true;
@ -778,7 +802,6 @@ void Fol_UnfollowUsr (void)
{ {
extern const char *Txt_User_not_found_or_you_do_not_have_permission_; extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
char Query[256]; char Query[256];
bool Error;
/***** Get user to be unfollowed *****/ /***** Get user to be unfollowed *****/
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
@ -796,12 +819,13 @@ void Fol_UnfollowUsr (void)
} }
/***** Show user's profile again *****/ /***** Show user's profile again *****/
Error = !Prf_ShowUserProfile (); if (!Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat)) // I can not view user's profile
/* 1) I followed a user when I had permission
2) User restricted permission, so now I can not view his/her profile
3) Now I can not view his/her profile ==> show users I follow */
Fol_ListFollowingUsr (&Gbl.Usrs.Me.UsrDat); // List user's I follow
} }
else else
Error = true;
if (Error)
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
} }

View File

@ -229,6 +229,10 @@ Pri_Visibility_t Pri_GetParamVisibility (const char *ParamName)
bool Pri_ShowIsAllowed (Pri_Visibility_t Visibility,long OtherUsrCod) bool Pri_ShowIsAllowed (Pri_Visibility_t Visibility,long OtherUsrCod)
{ {
/***** It's me? I always can see my things *****/
if (OtherUsrCod == Gbl.Usrs.Me.UsrDat.UsrCod)
return true;
/***** System admins always can see others' profiles *****/ /***** System admins always can see others' profiles *****/
if (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM) if (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
return true; return true;
@ -237,11 +241,8 @@ bool Pri_ShowIsAllowed (Pri_Visibility_t Visibility,long OtherUsrCod)
switch (Visibility) switch (Visibility)
{ {
case Pri_VISIBILITY_UNKNOWN: case Pri_VISIBILITY_UNKNOWN:
return (Gbl.Usrs.Me.UsrDat.UsrCod == OtherUsrCod); // It's me? I always can see my things return false; // It's not me
case Pri_VISIBILITY_USER: // Only visible by me and my teachers if I am a student or me and my students if I am a teacher case Pri_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 (Gbl.Usrs.Me.UsrDat.UsrCod == OtherUsrCod) // It's me, I always can see my things
return true;
else
return Usr_CheckIfUsrSharesAnyOfMyCrsWithDifferentRole (OtherUsrCod); // Both users share the same course but whit different role return Usr_CheckIfUsrSharesAnyOfMyCrsWithDifferentRole (OtherUsrCod); // Both users share the same course but whit different role
case Pri_VISIBILITY_COURSE: // Visible by users sharing courses with me case Pri_VISIBILITY_COURSE: // Visible by users sharing courses with me
return Usr_CheckIfUsrSharesAnyOfMyCrs (OtherUsrCod); // Both users share the same course return Usr_CheckIfUsrSharesAnyOfMyCrs (OtherUsrCod); // Both users share the same course

View File

@ -216,7 +216,7 @@ void Prf_GetUsrDatAndShowUserProfile (void)
/***** Show profile and timeline *****/ /***** Show profile and timeline *****/
if (!Error) if (!Error)
/* Show profile */ /* Show profile */
Error = !Prf_ShowUserProfile (); Error = !Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
if (Error) if (Error)
{ {
@ -250,17 +250,19 @@ void Prf_GetUsrDatAndShowUserProfile (void)
/*****************************************************************************/ /*****************************************************************************/
// Return false on error // Return false on error
bool Prf_ShowUserProfile (void) bool Prf_ShowUserProfile (struct UsrData *UsrDat)
{ {
unsigned NumFollowing; unsigned NumFollowing;
unsigned NumFollowers; unsigned NumFollowers;
bool UsrFollowsMe; bool UsrFollowsMe;
bool IFollowUsr; bool IFollowUsr;
bool ItsMe = (Gbl.Usrs.Me.Logged &&
UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
/***** Contextual links *****/ /***** Contextual links *****/
if (Gbl.Usrs.Me.Logged) if (Gbl.Usrs.Me.Logged)
{ {
if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me if (ItsMe) // It's me
{ {
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">"); fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
Rec_PutLinkToChangeMyInsCtrDpt (); // Put link (form) to change my institution, centre, department... Rec_PutLinkToChangeMyInsCtrDpt (); // Put link (form) to change my institution, centre, department...
@ -275,40 +277,40 @@ bool Prf_ShowUserProfile (void)
} }
/***** Check if I can see the public profile *****/ /***** Check if I can see the public profile *****/
if (Pri_ShowIsAllowed (Gbl.Usrs.Other.UsrDat.ProfileVisibility, if (Pri_ShowIsAllowed (UsrDat->ProfileVisibility,UsrDat->UsrCod))
Gbl.Usrs.Other.UsrDat.UsrCod))
{ {
if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected if (!ItsMe && // If not it's me...
Gbl.CurrentCrs.Crs.CrsCod > 0) // ...and a course is selected
{ {
/* Get user's role in current course */ /* Get user's role in current course */
Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB = Rol_GetRoleInCrs (Gbl.CurrentCrs.Crs.CrsCod,Gbl.Usrs.Other.UsrDat.UsrCod); UsrDat->RoleInCurrentCrsDB = Rol_GetRoleInCrs (Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod);
/* Get if user has accepted enrollment in current course */ /* Get if user has accepted enrollment in current course */
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod, UsrDat->Accepted = Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod,
Gbl.CurrentCrs.Crs.CrsCod, Gbl.CurrentCrs.Crs.CrsCod,
true); true);
} }
/***** Common record *****/ /***** Common record *****/
Rec_ShowSharedUsrRecord (Rec_RECORD_PUBLIC,&Gbl.Usrs.Other.UsrDat); Rec_ShowSharedUsrRecord (Rec_RECORD_PUBLIC,UsrDat);
/***** Show details of user's profile *****/ /***** Show details of user's profile *****/
Prf_ShowDetailsUserProfile (&Gbl.Usrs.Other.UsrDat); Prf_ShowDetailsUserProfile (UsrDat);
/***** Count following and followers *****/ /***** Count following and followers *****/
NumFollowing = Fol_GetNumFollowing (Gbl.Usrs.Other.UsrDat.UsrCod); NumFollowing = Fol_GetNumFollowing (UsrDat->UsrCod);
NumFollowers = Fol_GetNumFollowers (Gbl.Usrs.Other.UsrDat.UsrCod); NumFollowers = Fol_GetNumFollowers (UsrDat->UsrCod);
UsrFollowsMe = false; UsrFollowsMe = false;
if (NumFollowing) if (NumFollowing)
UsrFollowsMe = Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Other.UsrDat.UsrCod, UsrFollowsMe = Fol_CheckUsrIsFollowerOf (UsrDat->UsrCod,
Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Usrs.Me.UsrDat.UsrCod);
IFollowUsr = false; IFollowUsr = false;
if (NumFollowers) if (NumFollowers)
IFollowUsr = Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod, IFollowUsr = Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Other.UsrDat.UsrCod); UsrDat->UsrCod);
/***** Show following and followers *****/ /***** Show following and followers *****/
Fol_ShowFollowingAndFollowers (&Gbl.Usrs.Other.UsrDat, Fol_ShowFollowingAndFollowers (UsrDat,
NumFollowing,NumFollowers, NumFollowing,NumFollowers,
UsrFollowsMe,IFollowUsr); UsrFollowsMe,IFollowUsr);

View File

@ -46,7 +46,7 @@ void Prf_PutLinkRequestUserProfile (void);
void Prf_RequestUserProfile (void); void Prf_RequestUserProfile (void);
void Prf_GetUsrDatAndShowUserProfile (void); void Prf_GetUsrDatAndShowUserProfile (void);
bool Prf_ShowUserProfile (void); bool Prf_ShowUserProfile (struct UsrData *UsrDat);
void Prf_ChangeProfileVisibility (void); void Prf_ChangeProfileVisibility (void);
void Prf_CalculateFirstClickTime (void); void Prf_CalculateFirstClickTime (void);
void Prf_CalculateNumClicks (void); void Prf_CalculateNumClicks (void);

View File

@ -2060,7 +2060,7 @@ void Soc_ReceiveSocialPostUsr (void)
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
/***** Show user's profile *****/ /***** Show user's profile *****/
Prf_ShowUserProfile (); Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
/***** Start section *****/ /***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">"); fprintf (Gbl.F.Out,"<section id=\"timeline\">");
@ -2813,7 +2813,7 @@ void Soc_ReceiveCommentUsr (void)
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
/***** Show user's profile *****/ /***** Show user's profile *****/
Prf_ShowUserProfile (); Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
/***** Start section *****/ /***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">"); fprintf (Gbl.F.Out,"<section id=\"timeline\">");
@ -2939,7 +2939,7 @@ void Soc_ShareSocialNoteUsr (void)
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
/***** Show user's profile *****/ /***** Show user's profile *****/
Prf_ShowUserProfile (); Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
/***** Start section *****/ /***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">"); fprintf (Gbl.F.Out,"<section id=\"timeline\">");
@ -3017,7 +3017,7 @@ void Soc_FavSocialNoteUsr (void)
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
/***** Show user's profile *****/ /***** Show user's profile *****/
Prf_ShowUserProfile (); Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
/***** Start section *****/ /***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">"); fprintf (Gbl.F.Out,"<section id=\"timeline\">");
@ -3101,7 +3101,7 @@ void Soc_FavSocialCommentUsr (void)
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
/***** Show user's profile *****/ /***** Show user's profile *****/
Prf_ShowUserProfile (); Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
/***** Start section *****/ /***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">"); fprintf (Gbl.F.Out,"<section id=\"timeline\">");
@ -3223,7 +3223,7 @@ void Soc_UnshareSocialNoteUsr (void)
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
/***** Show user's profile *****/ /***** Show user's profile *****/
Prf_ShowUserProfile (); Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
/***** Start section *****/ /***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">"); fprintf (Gbl.F.Out,"<section id=\"timeline\">");
@ -3311,7 +3311,7 @@ void Soc_UnfavSocialNoteUsr (void)
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
/***** Show user's profile *****/ /***** Show user's profile *****/
Prf_ShowUserProfile (); Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
/***** Start section *****/ /***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">"); fprintf (Gbl.F.Out,"<section id=\"timeline\">");
@ -3395,7 +3395,7 @@ void Soc_UnfavSocialCommentUsr (void)
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
/***** Show user's profile *****/ /***** Show user's profile *****/
Prf_ShowUserProfile (); Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
/***** Start section *****/ /***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">"); fprintf (Gbl.F.Out,"<section id=\"timeline\">");
@ -3478,7 +3478,7 @@ void Soc_RequestRemSocialNoteUsr (void)
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
/***** Show user's profile *****/ /***** Show user's profile *****/
Prf_ShowUserProfile (); Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
/***** Start section *****/ /***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">"); fprintf (Gbl.F.Out,"<section id=\"timeline\">");
@ -3558,7 +3558,7 @@ void Soc_RemoveSocialNoteUsr (void)
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
/***** Show user's profile *****/ /***** Show user's profile *****/
Prf_ShowUserProfile (); Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
/***** Start section *****/ /***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">"); fprintf (Gbl.F.Out,"<section id=\"timeline\">");
@ -3805,7 +3805,7 @@ void Soc_RequestRemSocialComUsr (void)
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
/***** Show user's profile *****/ /***** Show user's profile *****/
Prf_ShowUserProfile (); Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
/***** Start section *****/ /***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">"); fprintf (Gbl.F.Out,"<section id=\"timeline\">");
@ -3890,7 +3890,7 @@ void Soc_RemoveSocialComUsr (void)
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
/***** Show user's profile *****/ /***** Show user's profile *****/
Prf_ShowUserProfile (); Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
/***** Start section *****/ /***** Start section *****/
fprintf (Gbl.F.Out,"<section id=\"timeline\">"); fprintf (Gbl.F.Out,"<section id=\"timeline\">");