mirror of https://github.com/acanas/swad-core.git
Version 15.224
This commit is contained in:
parent
9507e9f48b
commit
7abd6efbd5
|
@ -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: 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: 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: Add a new WS function to count the nunmber of users to return in call to function getUsers
|
||||
|
@ -131,13 +130,15 @@
|
|||
/****************************** 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 JS_FILE "swad15.216.js"
|
||||
|
||||
// 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
|
||||
/*
|
||||
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.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)
|
||||
|
|
330
swad_follow.c
330
swad_follow.c
|
@ -72,6 +72,10 @@ static void Fol_ShowNumberOfFollowingOrFollowers (const struct UsrData *UsrDat,
|
|||
unsigned NumUsrs,
|
||||
Act_Action_t Action,
|
||||
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);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -485,6 +489,24 @@ static void Fol_ShowNumberOfFollowingOrFollowers (const struct UsrData *UsrDat,
|
|||
/*****************************************************************************/
|
||||
|
||||
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_User_not_found_or_you_do_not_have_permission_;
|
||||
|
@ -493,59 +515,53 @@ void Fol_ListFollowing (void)
|
|||
MYSQL_ROW row;
|
||||
unsigned NumUsrs;
|
||||
unsigned NumUsr;
|
||||
struct UsrData UsrDat;
|
||||
struct UsrData FollowingUsrDat;
|
||||
|
||||
/***** Get user to view user he/she follows *****/
|
||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||
/***** Show user's profile *****/
|
||||
if (Prf_ShowUserProfile (UsrDat))
|
||||
{
|
||||
/***** Show user's profile *****/
|
||||
if (Prf_ShowUserProfile ())
|
||||
/***** Check if a user is a follower of another user *****/
|
||||
sprintf (Query,"SELECT FollowedCod FROM usr_follow"
|
||||
" WHERE FollowerCod='%ld' ORDER BY FollowTime DESC",
|
||||
UsrDat->UsrCod);
|
||||
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get followed users");
|
||||
if (NumUsrs)
|
||||
{
|
||||
/***** Check if a user is a follower of another user *****/
|
||||
sprintf (Query,"SELECT FollowedCod FROM usr_follow"
|
||||
" WHERE FollowerCod='%ld' ORDER BY FollowTime DESC",
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get followed users");
|
||||
if (NumUsrs)
|
||||
/***** Initialize structure with user's data *****/
|
||||
Usr_UsrDataConstructor (&FollowingUsrDat);
|
||||
|
||||
/***** Start listing *****/
|
||||
Lay_StartRoundFrameTable ("560px",2,Txt_Following);
|
||||
|
||||
for (NumUsr = 0;
|
||||
NumUsr < NumUsrs;
|
||||
NumUsr++)
|
||||
{
|
||||
/***** Initialize structure with user's data *****/
|
||||
Usr_UsrDataConstructor (&UsrDat);
|
||||
/***** Get user *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/***** Start listing *****/
|
||||
Lay_StartRoundFrameTable ("560px",2,Txt_Following);
|
||||
/* Get user's code (row[0]) */
|
||||
FollowingUsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
|
||||
for (NumUsr = 0;
|
||||
NumUsr < NumUsrs;
|
||||
NumUsr++)
|
||||
{
|
||||
/***** Get user *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get user's code (row[0]) */
|
||||
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
|
||||
/***** Show user *****/
|
||||
if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == 0)
|
||||
fprintf (Gbl.F.Out,"<tr>");
|
||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat))
|
||||
Fol_ShowFollowedOrFollower (&UsrDat);
|
||||
if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == (Fol_NUM_COLUMNS_FOLLOW-1) ||
|
||||
NumUsr == NumUsrs - 1)
|
||||
fprintf (Gbl.F.Out,"</tr>");
|
||||
}
|
||||
|
||||
/***** End listing *****/
|
||||
Lay_EndRoundFrameTable ();
|
||||
|
||||
/***** Free memory used for user's data *****/
|
||||
Usr_UsrDataDestructor (&UsrDat);
|
||||
/***** Show user *****/
|
||||
if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == 0)
|
||||
fprintf (Gbl.F.Out,"<tr>");
|
||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&FollowingUsrDat))
|
||||
Fol_ShowFollowedOrFollower (&FollowingUsrDat);
|
||||
if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == (Fol_NUM_COLUMNS_FOLLOW-1) ||
|
||||
NumUsr == NumUsrs - 1)
|
||||
fprintf (Gbl.F.Out,"</tr>");
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
/***** End listing *****/
|
||||
Lay_EndRoundFrameTable ();
|
||||
|
||||
/***** Free memory used for user's data *****/
|
||||
Usr_UsrDataDestructor (&FollowingUsrDat);
|
||||
}
|
||||
else
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
else
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
|
@ -556,6 +572,24 @@ void Fol_ListFollowing (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_User_not_found_or_you_do_not_have_permission_;
|
||||
|
@ -564,70 +598,59 @@ void Fol_ListFollowers (void)
|
|||
MYSQL_ROW row;
|
||||
unsigned NumUsrs;
|
||||
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 *****/
|
||||
if (Prf_ShowUserProfile (UsrDat))
|
||||
{
|
||||
/***** Show user's profile *****/
|
||||
if (Prf_ShowUserProfile ())
|
||||
/***** Check if a user is a follower of another user *****/
|
||||
sprintf (Query,"SELECT FollowerCod FROM usr_follow"
|
||||
" WHERE FollowedCod='%ld' ORDER BY FollowTime DESC",
|
||||
UsrDat->UsrCod);
|
||||
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get followers");
|
||||
if (NumUsrs)
|
||||
{
|
||||
/***** Check if a user is a follower of another user *****/
|
||||
sprintf (Query,"SELECT FollowerCod FROM usr_follow"
|
||||
" WHERE FollowedCod='%ld' ORDER BY FollowTime DESC",
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get followers");
|
||||
if (NumUsrs)
|
||||
/***** Initialize structure with user's data *****/
|
||||
Usr_UsrDataConstructor (&FollowerUsrDat);
|
||||
|
||||
/***** Start listing *****/
|
||||
Lay_StartRoundFrameTable ("560px",2,Txt_Followers);
|
||||
|
||||
for (NumUsr = 0;
|
||||
NumUsr < NumUsrs;
|
||||
NumUsr++)
|
||||
{
|
||||
/***** Initialize structure with user's data *****/
|
||||
Usr_UsrDataConstructor (&UsrDat);
|
||||
/***** Get user and number of clicks *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/***** Start listing *****/
|
||||
Lay_StartRoundFrameTable ("560px",2,Txt_Followers);
|
||||
/* Get user's code (row[0]) */
|
||||
FollowerUsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
|
||||
for (NumUsr = 0;
|
||||
NumUsr < NumUsrs;
|
||||
NumUsr++)
|
||||
{
|
||||
/***** Get user and number of clicks *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get user's code (row[0]) */
|
||||
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
|
||||
/***** Show user *****/
|
||||
if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == 0)
|
||||
fprintf (Gbl.F.Out,"<tr>");
|
||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat))
|
||||
Fol_ShowFollowedOrFollower (&UsrDat);
|
||||
if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == (Fol_NUM_COLUMNS_FOLLOW-1) ||
|
||||
NumUsr == NumUsrs - 1)
|
||||
fprintf (Gbl.F.Out,"</tr>");
|
||||
}
|
||||
|
||||
/***** End listing *****/
|
||||
Lay_EndRoundFrameTable ();
|
||||
|
||||
/***** Free memory used for user's data *****/
|
||||
Usr_UsrDataDestructor (&UsrDat);
|
||||
/***** Show user *****/
|
||||
if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == 0)
|
||||
fprintf (Gbl.F.Out,"<tr>");
|
||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&FollowerUsrDat))
|
||||
Fol_ShowFollowedOrFollower (&FollowerUsrDat);
|
||||
if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == (Fol_NUM_COLUMNS_FOLLOW-1) ||
|
||||
NumUsr == NumUsrs - 1)
|
||||
fprintf (Gbl.F.Out,"</tr>");
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
/***** End listing *****/
|
||||
Lay_EndRoundFrameTable ();
|
||||
|
||||
/***** If it's me, mark possible notification as seen *****/
|
||||
if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod)
|
||||
Ntf_MarkNotifAsSeen (Ntf_EVENT_FOLLOWER,
|
||||
-1L,-1L,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
/***** Free memory used for user's data *****/
|
||||
Usr_UsrDataDestructor (&FollowerUsrDat);
|
||||
}
|
||||
else
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
/***** If it's me, mark possible notification as seen *****/
|
||||
if (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod)
|
||||
Ntf_MarkNotifAsSeen (Ntf_EVENT_FOLLOWER,
|
||||
-1L,-1L,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
else
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
|
@ -647,74 +670,75 @@ static void Fol_ShowFollowedOrFollower (const struct UsrData *UsrDat)
|
|||
char PhotoURL[PATH_MAX+1];
|
||||
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\">");
|
||||
if (Visible)
|
||||
{
|
||||
/***** User's photo *****/
|
||||
ShowPhoto = Pho_ShowUsrPhotoIsAllowed (UsrDat,PhotoURL);
|
||||
Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL :
|
||||
NULL,
|
||||
"PHOTO60x80",Pho_ZOOM,false);
|
||||
}
|
||||
fprintf (Gbl.F.Out,"</td>"
|
||||
"<td class=\"FOLLOW_USR_NAME\">");
|
||||
fprintf (Gbl.F.Out,"</td>");
|
||||
|
||||
/***** Show user's name and icon to follow/unfollow *****/
|
||||
fprintf (Gbl.F.Out,"<td class=\"FOLLOW_USR_NAME\">");
|
||||
if (Visible)
|
||||
{
|
||||
/***** Put form to go to public profile *****/
|
||||
/* Put form to go to public profile */
|
||||
Act_FormStart (ActSeePubPrf);
|
||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
||||
Act_LinkFormSubmit (Txt_View_public_profile,"DAT");
|
||||
Usr_RestrictLengthAndWriteName (UsrDat,10);
|
||||
fprintf (Gbl.F.Out,"</a>");
|
||||
Act_FormEnd ();
|
||||
|
||||
if (!Gbl.Usrs.Me.Logged || // Not logged
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod) // It's me
|
||||
/***** Inactive icon to follow / unfollow *****/
|
||||
fprintf (Gbl.F.Out,"<div class=\"FOLLOW_USR_ICON ICON_HIDDEN\">"
|
||||
"<img src=\"%s/usr64x64.gif\""
|
||||
" alt=\"\""
|
||||
" class=\"ICON25x25\" />"
|
||||
"</div>",
|
||||
Gbl.Prefs.IconsURL);
|
||||
else
|
||||
{
|
||||
/***** Put form to follow / unfollow *****/
|
||||
if (Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod,UsrDat->UsrCod)) // I follow user
|
||||
{
|
||||
Act_FormStart (ActUnfUsr);
|
||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
||||
Act_LinkFormSubmit (Txt_Following_unfollow,NULL);
|
||||
fprintf (Gbl.F.Out,"<div class=\"FOLLOW_USR_ICON ICON_HIGHLIGHT\">"
|
||||
"<img src=\"%s/following64x64.png\""
|
||||
" alt=\"%s\" title=\"%s\""
|
||||
" class=\"ICON25x25\" />"
|
||||
"</div>"
|
||||
"</a>",
|
||||
Gbl.Prefs.IconsURL,
|
||||
Txt_Unfollow,Txt_Following_unfollow);
|
||||
Act_FormEnd ();
|
||||
}
|
||||
else // I do not follow this user
|
||||
{
|
||||
Act_FormStart (ActFolUsr);
|
||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
||||
Act_LinkFormSubmit (Txt_Follow,NULL);
|
||||
fprintf (Gbl.F.Out,"<div class=\"FOLLOW_USR_ICON ICON_HIGHLIGHT\">"
|
||||
"<img src=\"%s/follow64x64.png\""
|
||||
" alt=\"%s\" title=\"%s\""
|
||||
" class=\"ICON25x25\" />"
|
||||
"</div>"
|
||||
"</a>",
|
||||
Gbl.Prefs.IconsURL,
|
||||
Txt_Follow,Txt_Follow);
|
||||
Act_FormEnd ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!Gbl.Usrs.Me.Logged || // Not logged
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod) // It's me
|
||||
/* Inactive icon to follow/unfollow */
|
||||
fprintf (Gbl.F.Out,"<div class=\"FOLLOW_USR_ICON ICON_HIDDEN\">"
|
||||
"<img src=\"%s/usr64x64.gif\""
|
||||
" alt=\"\""
|
||||
" class=\"ICON25x25\" />"
|
||||
"</div>",
|
||||
Gbl.Prefs.IconsURL);
|
||||
else
|
||||
{
|
||||
/* Put form to follow / unfollow */
|
||||
if (Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod,UsrDat->UsrCod)) // I follow user
|
||||
{
|
||||
/* Form to unfollow */
|
||||
Act_FormStart (ActUnfUsr);
|
||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
||||
Act_LinkFormSubmit (Txt_Following_unfollow,NULL);
|
||||
fprintf (Gbl.F.Out,"<div class=\"FOLLOW_USR_ICON ICON_HIGHLIGHT\">"
|
||||
"<img src=\"%s/following64x64.png\""
|
||||
" alt=\"%s\" title=\"%s\""
|
||||
" class=\"ICON25x25\" />"
|
||||
"</div>"
|
||||
"</a>",
|
||||
Gbl.Prefs.IconsURL,
|
||||
Txt_Unfollow,Txt_Following_unfollow);
|
||||
Act_FormEnd ();
|
||||
}
|
||||
else if (Visible) // I do not follow this user and I can follow
|
||||
{
|
||||
/* Form to follow */
|
||||
Act_FormStart (ActFolUsr);
|
||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
||||
Act_LinkFormSubmit (Txt_Follow,NULL);
|
||||
fprintf (Gbl.F.Out,"<div class=\"FOLLOW_USR_ICON ICON_HIGHLIGHT\">"
|
||||
"<img src=\"%s/follow64x64.png\""
|
||||
" alt=\"%s\" title=\"%s\""
|
||||
" class=\"ICON25x25\" />"
|
||||
"</div>"
|
||||
"</a>",
|
||||
Gbl.Prefs.IconsURL,
|
||||
Txt_Follow,Txt_Follow);
|
||||
Act_FormEnd ();
|
||||
}
|
||||
}
|
||||
fprintf (Gbl.F.Out,"</td>");
|
||||
}
|
||||
|
||||
|
@ -761,7 +785,7 @@ void Fol_FollowUsr (void)
|
|||
}
|
||||
|
||||
/***** Show user's profile again *****/
|
||||
Error = !Prf_ShowUserProfile ();
|
||||
Error = !Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
|
||||
}
|
||||
else
|
||||
Error = true;
|
||||
|
@ -778,7 +802,6 @@ void Fol_UnfollowUsr (void)
|
|||
{
|
||||
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
||||
char Query[256];
|
||||
bool Error;
|
||||
|
||||
/***** Get user to be unfollowed *****/
|
||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||
|
@ -796,12 +819,13 @@ void Fol_UnfollowUsr (void)
|
|||
}
|
||||
|
||||
/***** 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
|
||||
Error = true;
|
||||
|
||||
if (Error)
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
}
|
||||
|
||||
|
|
|
@ -229,6 +229,10 @@ Pri_Visibility_t Pri_GetParamVisibility (const char *ParamName)
|
|||
|
||||
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 *****/
|
||||
if (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
|
||||
return true;
|
||||
|
@ -237,12 +241,9 @@ bool Pri_ShowIsAllowed (Pri_Visibility_t Visibility,long OtherUsrCod)
|
|||
switch (Visibility)
|
||||
{
|
||||
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
|
||||
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
|
||||
return Usr_CheckIfUsrSharesAnyOfMyCrs (OtherUsrCod); // Both users share the same course
|
||||
case Pri_VISIBILITY_SYSTEM: // Visible by any user logged in platform
|
||||
|
|
|
@ -216,7 +216,7 @@ void Prf_GetUsrDatAndShowUserProfile (void)
|
|||
/***** Show profile and timeline *****/
|
||||
if (!Error)
|
||||
/* Show profile */
|
||||
Error = !Prf_ShowUserProfile ();
|
||||
Error = !Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
if (Error)
|
||||
{
|
||||
|
@ -250,17 +250,19 @@ void Prf_GetUsrDatAndShowUserProfile (void)
|
|||
/*****************************************************************************/
|
||||
// Return false on error
|
||||
|
||||
bool Prf_ShowUserProfile (void)
|
||||
bool Prf_ShowUserProfile (struct UsrData *UsrDat)
|
||||
{
|
||||
unsigned NumFollowing;
|
||||
unsigned NumFollowers;
|
||||
bool UsrFollowsMe;
|
||||
bool IFollowUsr;
|
||||
bool ItsMe = (Gbl.Usrs.Me.Logged &&
|
||||
UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
|
||||
/***** Contextual links *****/
|
||||
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\">");
|
||||
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 *****/
|
||||
if (Pri_ShowIsAllowed (Gbl.Usrs.Other.UsrDat.ProfileVisibility,
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod))
|
||||
if (Pri_ShowIsAllowed (UsrDat->ProfileVisibility,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 */
|
||||
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 */
|
||||
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
Gbl.CurrentCrs.Crs.CrsCod,
|
||||
true);
|
||||
UsrDat->Accepted = Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod,
|
||||
Gbl.CurrentCrs.Crs.CrsCod,
|
||||
true);
|
||||
}
|
||||
|
||||
/***** Common record *****/
|
||||
Rec_ShowSharedUsrRecord (Rec_RECORD_PUBLIC,&Gbl.Usrs.Other.UsrDat);
|
||||
Rec_ShowSharedUsrRecord (Rec_RECORD_PUBLIC,UsrDat);
|
||||
|
||||
/***** Show details of user's profile *****/
|
||||
Prf_ShowDetailsUserProfile (&Gbl.Usrs.Other.UsrDat);
|
||||
Prf_ShowDetailsUserProfile (UsrDat);
|
||||
|
||||
/***** Count following and followers *****/
|
||||
NumFollowing = Fol_GetNumFollowing (Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
NumFollowers = Fol_GetNumFollowers (Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
NumFollowing = Fol_GetNumFollowing (UsrDat->UsrCod);
|
||||
NumFollowers = Fol_GetNumFollowers (UsrDat->UsrCod);
|
||||
UsrFollowsMe = false;
|
||||
if (NumFollowing)
|
||||
UsrFollowsMe = Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
UsrFollowsMe = Fol_CheckUsrIsFollowerOf (UsrDat->UsrCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
IFollowUsr = false;
|
||||
if (NumFollowers)
|
||||
IFollowUsr = Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
UsrDat->UsrCod);
|
||||
|
||||
/***** Show following and followers *****/
|
||||
Fol_ShowFollowingAndFollowers (&Gbl.Usrs.Other.UsrDat,
|
||||
Fol_ShowFollowingAndFollowers (UsrDat,
|
||||
NumFollowing,NumFollowers,
|
||||
UsrFollowsMe,IFollowUsr);
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ void Prf_PutLinkRequestUserProfile (void);
|
|||
void Prf_RequestUserProfile (void);
|
||||
void Prf_GetUsrDatAndShowUserProfile (void);
|
||||
|
||||
bool Prf_ShowUserProfile (void);
|
||||
bool Prf_ShowUserProfile (struct UsrData *UsrDat);
|
||||
void Prf_ChangeProfileVisibility (void);
|
||||
void Prf_CalculateFirstClickTime (void);
|
||||
void Prf_CalculateNumClicks (void);
|
||||
|
|
|
@ -2060,7 +2060,7 @@ void Soc_ReceiveSocialPostUsr (void)
|
|||
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
|
||||
|
||||
/***** Show user's profile *****/
|
||||
Prf_ShowUserProfile ();
|
||||
Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
/***** Start section *****/
|
||||
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
|
||||
|
@ -2813,7 +2813,7 @@ void Soc_ReceiveCommentUsr (void)
|
|||
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
|
||||
|
||||
/***** Show user's profile *****/
|
||||
Prf_ShowUserProfile ();
|
||||
Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
/***** Start section *****/
|
||||
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
|
||||
|
@ -2939,7 +2939,7 @@ void Soc_ShareSocialNoteUsr (void)
|
|||
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
|
||||
|
||||
/***** Show user's profile *****/
|
||||
Prf_ShowUserProfile ();
|
||||
Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
/***** Start section *****/
|
||||
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
|
||||
|
@ -3017,7 +3017,7 @@ void Soc_FavSocialNoteUsr (void)
|
|||
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
|
||||
|
||||
/***** Show user's profile *****/
|
||||
Prf_ShowUserProfile ();
|
||||
Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
/***** Start section *****/
|
||||
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
|
||||
|
@ -3101,7 +3101,7 @@ void Soc_FavSocialCommentUsr (void)
|
|||
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
|
||||
|
||||
/***** Show user's profile *****/
|
||||
Prf_ShowUserProfile ();
|
||||
Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
/***** Start section *****/
|
||||
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
|
||||
|
@ -3223,7 +3223,7 @@ void Soc_UnshareSocialNoteUsr (void)
|
|||
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
|
||||
|
||||
/***** Show user's profile *****/
|
||||
Prf_ShowUserProfile ();
|
||||
Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
/***** Start section *****/
|
||||
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
|
||||
|
@ -3311,7 +3311,7 @@ void Soc_UnfavSocialNoteUsr (void)
|
|||
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
|
||||
|
||||
/***** Show user's profile *****/
|
||||
Prf_ShowUserProfile ();
|
||||
Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
/***** Start section *****/
|
||||
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
|
||||
|
@ -3395,7 +3395,7 @@ void Soc_UnfavSocialCommentUsr (void)
|
|||
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
|
||||
|
||||
/***** Show user's profile *****/
|
||||
Prf_ShowUserProfile ();
|
||||
Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
/***** Start section *****/
|
||||
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
|
||||
|
@ -3478,7 +3478,7 @@ void Soc_RequestRemSocialNoteUsr (void)
|
|||
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
|
||||
|
||||
/***** Show user's profile *****/
|
||||
Prf_ShowUserProfile ();
|
||||
Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
/***** Start section *****/
|
||||
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
|
||||
|
@ -3558,7 +3558,7 @@ void Soc_RemoveSocialNoteUsr (void)
|
|||
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
|
||||
|
||||
/***** Show user's profile *****/
|
||||
Prf_ShowUserProfile ();
|
||||
Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
/***** Start section *****/
|
||||
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
|
||||
|
@ -3805,7 +3805,7 @@ void Soc_RequestRemSocialComUsr (void)
|
|||
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
|
||||
|
||||
/***** Show user's profile *****/
|
||||
Prf_ShowUserProfile ();
|
||||
Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
/***** Start section *****/
|
||||
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
|
||||
|
@ -3890,7 +3890,7 @@ void Soc_RemoveSocialComUsr (void)
|
|||
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
|
||||
|
||||
/***** Show user's profile *****/
|
||||
Prf_ShowUserProfile ();
|
||||
Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
/***** Start section *****/
|
||||
fprintf (Gbl.F.Out,"<section id=\"timeline\">");
|
||||
|
|
Loading…
Reference in New Issue