// swad_follow.c: user's followers and followed
/*
SWAD (Shared Workspace At a Distance),
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-2019 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 3 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 *********************************/
/*****************************************************************************/
#include // For boolean type
#include // For string functions
#include "swad_box.h"
#include "swad_database.h"
#include "swad_follow.h"
#include "swad_form.h"
#include "swad_global.h"
#include "swad_HTML.h"
#include "swad_notification.h"
#include "swad_privacy.h"
#include "swad_profile.h"
#include "swad_user.h"
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
#define Fol_NUM_COLUMNS_FOLLOW 3
#define Fol_FOLLOW_SECTION_ID "follow_section"
/*****************************************************************************/
/****************************** Internal types *******************************/
/*****************************************************************************/
typedef enum
{
Fol_SUGGEST_ONLY_USERS_WITH_PHOTO,
Fol_SUGGEST_ANY_USER,
} Fol_WhichUsersSuggestToFollowThem_t;
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/************************* Internal global variables *************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
static unsigned long Fol_GetUsrsToFollow (unsigned long MaxUsrsToShow,
Fol_WhichUsersSuggestToFollowThem_t WhichUsersSuggestToFollowThem,
MYSQL_RES **mysql_res);
static void Fol_PutIconsWhoToFollow (void);
static void Fol_PutIconToUpdateWhoToFollow (void);
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 (struct UsrData *UsrDat);
static void Fol_WriteRowUsrToFollowOnRightColumn (struct UsrData *UsrDat);
static void Fol_PutInactiveIconToFollowUnfollow (void);
static void Fol_PutIconToFollow (struct UsrData *UsrDat);
static void Fol_PutIconToUnfollow (struct UsrData *UsrDat);
static void Fol_RequestFollowUsrs (Act_Action_t NextAction);
static void Fol_RequestUnfollowUsrs (Act_Action_t NextAction);
static void Fol_GetFollowedFromSelectedUsrs (unsigned *NumFollowed,
unsigned *NumNotFollowed);
static void Fol_FollowUsr (struct UsrData *UsrDat);
static void Fol_UnfollowUsr (struct UsrData *UsrDat);
/*****************************************************************************/
/********************** Put link to show users to follow **********************/
/*****************************************************************************/
void Fol_PutLinkWhoToFollow (void)
{
extern const char *Txt_Who_to_follow;
Lay_PutContextualLinkIconText (ActSeeSocPrf,NULL,NULL,
"user-plus.svg",
Txt_Who_to_follow);
}
/*****************************************************************************/
/****************** Show several users to follow on main zone ****************/
/*****************************************************************************/
#define Fol_MAX_USRS_TO_FOLLOW_MAIN_ZONE (Fol_NUM_COLUMNS_FOLLOW * 3)
void Fol_SuggestUsrsToFollowMainZone (void)
{
extern const char *Hlp_START_Profiles_who_to_follow;
extern const char *Txt_Who_to_follow;
extern const char *Txt_No_user_to_whom_you_can_follow_Try_again_later;
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumUsrs;
unsigned long NumUsr;
struct UsrData UsrDat;
/***** Put links to request my public profile and another user's profile *****/
fprintf (Gbl.F.Out,"