diff --git a/swad_changelog.h b/swad_changelog.h
index f29909f42..ad1a5e33b 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -35,11 +35,12 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
-#define Log_PLATFORM_VERSION "SWAD 14.38.6 (2014/12/17)"
+#define Log_PLATFORM_VERSION "SWAD 14.38.7 (2014/12/17)"
// 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.38.7 :Dic 17, 2014 Link to banned users is shown only if user has banned one or more users. (170792 lines)
Version 14.38.6 :Dic 17, 2014 Banned users option is integrated in received messages option. (170776 lines)
Version 14.38.5 :Dic 16, 2014 User's institution option is integrated in record card option. (170819 lines)
Version 14.38.4 :Dic 16, 2014 User's photo option is integrated in record card option. (170941 lines)
diff --git a/swad_message.c b/swad_message.c
index c932f0196..de1908305 100644
--- a/swad_message.c
+++ b/swad_message.c
@@ -69,6 +69,7 @@ extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS];
static void Msg_PutFormMsgUsrs (const char *Content);
static void Msg_ShowSentOrReceivedMessages (Msg_TypeOfMessages_t TypeOfMessages);
+static unsigned long Msg_GetNumUsrsBannedByMe (void);
static void Msg_PutLinkToViewBannedUsers(void);
static void Msg_ConstructQueryToSelectSentOrReceivedMsgs (char *Query,Msg_TypeOfMessages_t TypeOfMessages,long UsrCod,
long FilterCrsCod,const char *FilterFromToSubquery);
@@ -1459,9 +1460,12 @@ void Msg_ShowSntMsgs (void)
void Msg_ShowRecMsgs (void)
{
/***** Link to view banned users *****/
- fprintf (Gbl.F.Out,"
");
- Msg_PutLinkToViewBannedUsers ();
- fprintf (Gbl.F.Out,"
");
+ if (Msg_GetNumUsrsBannedByMe ())
+ {
+ fprintf (Gbl.F.Out,"");
+ Msg_PutLinkToViewBannedUsers ();
+ fprintf (Gbl.F.Out,"
");
+ }
/***** Show the received messages *****/
Msg_ShowSentOrReceivedMessages (Msg_MESSAGES_RECEIVED);
@@ -1601,6 +1605,20 @@ static void Msg_ShowSentOrReceivedMessages (Msg_TypeOfMessages_t TypeOfMessages)
DB_FreeMySQLResult (&mysql_res);
}
+/*****************************************************************************/
+/********************* Get number of user I have banned **********************/
+/*****************************************************************************/
+
+static unsigned long Msg_GetNumUsrsBannedByMe (void)
+ {
+ char Query[128];
+
+ /***** Get number of users I have banned *****/
+ sprintf (Query,"SELECT COUNT(*) FROM msg_banned WHERE ToUsrCod='%ld'",
+ Gbl.Usrs.Me.UsrDat.UsrCod);
+ return DB_QueryCOUNT (Query,"can not get number of users you have banned");
+ }
+
/*****************************************************************************/
/****************** Put a link (form) to view banned users *******************/
/*****************************************************************************/
@@ -3311,14 +3329,14 @@ static void Msg_UnbanSender (void)
}
/*****************************************************************************/
-/************************ Unban a sender of a message ************************/
+/**************** Chech if a user is banned by another user ******************/
/*****************************************************************************/
static bool Msg_CheckIfUsrIsBanned (long FromUsrCod,long ToUsrCod)
{
char Query[256];
- /***** Get if the message code is in table of sent messages not deleted *****/
+ /***** Get if FromUsrCod is banned by ToUsrCod *****/
sprintf (Query,"SELECT COUNT(*) FROM msg_banned"
" WHERE FromUsrCod='%ld' AND ToUsrCod='%ld'",
FromUsrCod,ToUsrCod);