Version 15.120.2

This commit is contained in:
Antonio Cañas Vargas 2016-01-19 01:31:35 +01:00
parent 36b060b29a
commit 5c072bc4d1
3 changed files with 46 additions and 93 deletions

View File

@ -122,13 +122,14 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.120.1 (2016-01-19)" #define Log_PLATFORM_VERSION "SWAD 15.120.2 (2016-01-19)"
#define CSS_FILE "swad15.117.css" #define CSS_FILE "swad15.120.2.css"
#define JS_FILE "swad15.118.4.js" #define JS_FILE "swad15.118.4.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.120.2: Jan 19, 2016 Code optimization on sharers or favers. (193491 lines)
Version 15.120.1: Jan 19, 2016 Show number of users who marked a social note as favourite. (193533 lines) Version 15.120.1: Jan 19, 2016 Show number of users who marked a social note as favourite. (193533 lines)
Version 15.120: Jan 19, 2016 Mark/unmark social notes as favourites. (193475 lines) Version 15.120: Jan 19, 2016 Mark/unmark social notes as favourites. (193475 lines)
Version 15.119: Jan 18, 2016 New table to mark social notes as favourites. (193036 lines) Version 15.119: Jan 18, 2016 New table to mark social notes as favourites. (193036 lines)

View File

@ -312,6 +312,7 @@ static void Soc_UpdateNumTimesANoteHasBeenFav (struct SocialNote *SocNot);
static void Soc_ShowUsrsWhoHaveSharedSocialNote (const struct SocialNote *SocNot); static void Soc_ShowUsrsWhoHaveSharedSocialNote (const struct SocialNote *SocNot);
static void Soc_ShowUsrsWhoHaveMarkedSocialNoteAsFav (const struct SocialNote *SocNot); static void Soc_ShowUsrsWhoHaveMarkedSocialNoteAsFav (const struct SocialNote *SocNot);
static void Soc_ShowSharersOrFavers (unsigned NumUsrs,const char *Query);
static void Soc_GetDataOfSocialNoteByCod (struct SocialNote *SocNot); static void Soc_GetDataOfSocialNoteByCod (struct SocialNote *SocNot);
static void Soc_GetDataOfSocialCommentByCod (struct SocialComment *SocCom); static void Soc_GetDataOfSocialCommentByCod (struct SocialComment *SocCom);
@ -3414,96 +3415,55 @@ static void Soc_UpdateNumTimesANoteHasBeenFav (struct SocialNote *SocNot)
/*****************************************************************************/ /*****************************************************************************/
/**************** Show users who have shared this social note ****************/ /**************** Show users who have shared this social note ****************/
/*****************************************************************************/ /*****************************************************************************/
// All forms in this function and nested functions must have unique identifiers
static void Soc_ShowUsrsWhoHaveSharedSocialNote (const struct SocialNote *SocNot) static void Soc_ShowUsrsWhoHaveSharedSocialNote (const struct SocialNote *SocNot)
{ {
char Query[256]; char Query[256];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumUsrs;
unsigned NumUsr;
unsigned NumUsrsShown = 0;
struct UsrData UsrDat;
bool ShowPhoto;
char PhotoURL[PATH_MAX+1];
/***** Show number of users who have shared this social note *****/ /***** Get users who have shared this note *****/
fprintf (Gbl.F.Out,"<span class=\"SOCIAL_NUM_SHARES_FAVS\"> %u</span>", sprintf (Query,"SELECT PublisherCod"
SocNot->NumShared); " FROM social_pubs"
" WHERE NotCod='%ld'"
if (SocNot->NumShared) " AND PublisherCod<>'%ld'"
{ " AND PubType='%u'"
/***** Get list of publishers from database (only the first) *****/ " ORDER BY PubCod LIMIT %u",
sprintf (Query,"SELECT PublisherCod" SocNot->NotCod,
" FROM social_pubs" SocNot->UsrCod,
" WHERE NotCod='%ld'" (unsigned) Soc_PUB_SHARED_NOTE,
" AND PublisherCod<>'%ld'" Soc_MAX_SHARERS_FAVERS_SHOWN);
" AND PubType='%u'" Soc_ShowSharersOrFavers (SocNot->NumShared,Query);
" ORDER BY PubCod LIMIT %u",
SocNot->NotCod,
SocNot->UsrCod,
(unsigned) Soc_PUB_SHARED_NOTE,
Soc_MAX_SHARERS_FAVERS_SHOWN);
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get users who shared a social note");
if (NumUsrs)
{
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
/***** List users *****/
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]);
/***** Get user's data and show user's photo *****/
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat))
{
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_SHARER\">");
ShowPhoto = Pho_ShowUsrPhotoIsAllowed (&UsrDat,PhotoURL);
Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL :
NULL,
"PHOTO18x24",Pho_ZOOM,true); // Use unique id
fprintf (Gbl.F.Out,"</div>");
NumUsrsShown++;
}
}
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
}
if (SocNot->NumShared > NumUsrsShown)
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_SHARER\">"
"<img src=\"%s/ellipsis32x32.gif\""
" alt=\"%u\" title=\"%u\""
" class=\"ICON20x20\" />"
"</div>",
Gbl.Prefs.IconsURL,
SocNot->NumShared - NumUsrsShown,
SocNot->NumShared - NumUsrsShown);
}
} }
/*****************************************************************************/
/********* Show users who have marked this social note as favourite **********/
/*****************************************************************************/
static void Soc_ShowUsrsWhoHaveMarkedSocialNoteAsFav (const struct SocialNote *SocNot)
{
char Query[256];
/***** Get users who have mark this note as favourite *****/
sprintf (Query,"SELECT UsrCod"
" FROM social_notes_fav"
" WHERE NotCod='%ld'"
" AND UsrCod<>'%ld'" // Extra check
" ORDER BY TimeFav LIMIT %u",
SocNot->NotCod,
SocNot->UsrCod,
Soc_MAX_SHARERS_FAVERS_SHOWN);
Soc_ShowSharersOrFavers (SocNot->NumFavs,Query);
}
/*****************************************************************************/ /*****************************************************************************/
/********* Show users who have marked this social note as favourite **********/ /********* Show users who have marked this social note as favourite **********/
/*****************************************************************************/ /*****************************************************************************/
// All forms in this function and nested functions must have unique identifiers // All forms in this function and nested functions must have unique identifiers
static void Soc_ShowUsrsWhoHaveMarkedSocialNoteAsFav (const struct SocialNote *SocNot) static void Soc_ShowSharersOrFavers (unsigned NumUsrs,const char *Query)
{ {
char Query[256];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned NumUsrs; unsigned NumFirstUsrs;
unsigned NumUsr; unsigned NumUsr;
unsigned NumUsrsShown = 0; unsigned NumUsrsShown = 0;
struct UsrData UsrDat; struct UsrData UsrDat;
@ -3512,28 +3472,20 @@ static void Soc_ShowUsrsWhoHaveMarkedSocialNoteAsFav (const struct SocialNote *S
/***** Show number of users who have marked this social note as favourite *****/ /***** Show number of users who have marked this social note as favourite *****/
fprintf (Gbl.F.Out,"<span class=\"SOCIAL_NUM_SHARES_FAVS\"> %u</span>", fprintf (Gbl.F.Out,"<span class=\"SOCIAL_NUM_SHARES_FAVS\"> %u</span>",
SocNot->NumFavs); NumUsrs);
if (SocNot->NumFavs) if (NumUsrs)
{ {
/***** Get list of publishers from database (only the first) *****/ /***** Get list of users from database *****/
sprintf (Query,"SELECT UsrCod" NumFirstUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get users");
" FROM social_notes_fav" if (NumFirstUsrs)
" WHERE NotCod='%ld'"
" AND UsrCod<>'%ld'" // Extra check
" ORDER BY TimeFav LIMIT %u",
SocNot->NotCod,
SocNot->UsrCod,
Soc_MAX_SHARERS_FAVERS_SHOWN);
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get users who fav a social note");
if (NumUsrs)
{ {
/***** Initialize structure with user's data *****/ /***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat); Usr_UsrDataConstructor (&UsrDat);
/***** List users *****/ /***** List users *****/
for (NumUsr = 0; for (NumUsr = 0;
NumUsr < NumUsrs; NumUsr < NumFirstUsrs;
NumUsr++) NumUsr++)
{ {
/***** Get user *****/ /***** Get user *****/
@ -3560,15 +3512,15 @@ static void Soc_ShowUsrsWhoHaveMarkedSocialNoteAsFav (const struct SocialNote *S
Usr_UsrDataDestructor (&UsrDat); Usr_UsrDataDestructor (&UsrDat);
} }
if (SocNot->NumFavs > NumUsrsShown) if (NumUsrs > NumUsrsShown)
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_SHARER\">" fprintf (Gbl.F.Out,"<div class=\"SOCIAL_SHARER\">"
"<img src=\"%s/ellipsis32x32.gif\"" "<img src=\"%s/ellipsis32x32.gif\""
" alt=\"%u\" title=\"%u\"" " alt=\"%u\" title=\"%u\""
" class=\"ICON20x20\" />" " class=\"ICON20x20\" />"
"</div>", "</div>",
Gbl.Prefs.IconsURL, Gbl.Prefs.IconsURL,
SocNot->NumFavs - NumUsrsShown, NumUsrs - NumUsrsShown,
SocNot->NumFavs - NumUsrsShown); NumUsrs - NumUsrsShown);
} }
} }