mirror of https://github.com/acanas/swad-core.git
Version18.67
This commit is contained in:
parent
5291756181
commit
dee9c6310a
|
@ -1967,6 +1967,15 @@ a:hover img.CENTRE_PHOTO_SHOW
|
|||
overflow:hidden;
|
||||
text-overflow:ellipsis;
|
||||
}
|
||||
.ZOOM_DEG
|
||||
{
|
||||
display:inline-block;
|
||||
margin:0 auto;
|
||||
padding:0 0 0 20px;
|
||||
background-size:16px 16px;
|
||||
background-repeat:no-repeat;
|
||||
background-position:left center;
|
||||
}
|
||||
|
||||
.NO_BR {white-space:nowrap;}
|
||||
|
|
@ -12667,3 +12667,26 @@ UPDATE usr_figures SET NumMsgSnt=0 WHERE NumMsgSnt<0;
|
|||
|
||||
UPDATE usr_figures,(SELECT UsrCod,SUM(NumViews) AS NumFileViews FROM file_view WHERE UsrCod>0 GROUP BY UsrCod) AS viewers SET usr_figures.NumFileViews=viewers.NumFileViews WHERE usr_figures.NumFileViews<0 AND usr_figures.UsrCod=viewers.UsrCod;
|
||||
UPDATE usr_figures SET NumFileViews=0 WHERE NumFileViews<0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------
|
||||
|
||||
|
||||
SELECT degrees.ShortName,main_degree.MaxRole
|
||||
FROM degrees,
|
||||
(SELECT courses.DegCod AS DegCod,MAX(crs_usr.Role) AS MaxRole,COUNT(*) AS N
|
||||
FROM crs_usr,courses
|
||||
WHERE crs_usr.UsrCod=1
|
||||
AND crs_usr.CrsCod=courses.CrsCod
|
||||
GROUP BY courses.DegCod
|
||||
ORDER BY N DESC LIMIT 1)
|
||||
AS main_degree
|
||||
WHERE degrees.DegCod=main_degree.DegCod;
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -409,6 +409,10 @@ Antonio
|
|||
|
||||
// TODO: Actualizar ayuda en GitHub, por ejemplo Preferencias ahora es Ajustes.
|
||||
|
||||
// TODO: Change in usability of Announcements of exams, suggested by Javier Fernández Baldomero.
|
||||
|
||||
// TODO: "Se podría poner un botón para seguir a todos los relacionados contigo en las asignaturas, en lugar de tener que agregarlos uno a uno" Suggested by José María girao Miras.
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -428,10 +432,11 @@ En OpenSWAD:
|
|||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.66.6 (2019-03-07)"
|
||||
#define CSS_FILE "swad18.66.3.css"
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.67 (2019-03-07)"
|
||||
#define CSS_FILE "swad18.67.css"
|
||||
#define JS_FILE "swad18.64.js"
|
||||
/*
|
||||
Version 18.67: Mar 07, 2019 Nickname shown in photo zoom. (238927 lines)
|
||||
Version 18.66.6: Mar 07, 2019 Number of days printed as months or years in user's figures. (238846 lines)
|
||||
Version 18.66.5: Mar 06, 2019 Code refactoring in user's figures. (238739 lines)
|
||||
Version 18.66.4: Mar 06, 2019 Code refactoring in user's figures. (238678 lines)
|
||||
|
|
|
@ -801,9 +801,9 @@ struct Globals
|
|||
struct
|
||||
{
|
||||
long InsCod;
|
||||
char FullName[Hie_MAX_BYTES_FULL_NAME + 1];
|
||||
char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1];
|
||||
char CtyName[Hie_MAX_BYTES_FULL_NAME + 1];
|
||||
} InstitutionFullNameAndCty;
|
||||
} InstitutionShrtNameAndCty;
|
||||
struct
|
||||
{
|
||||
long UsrCod;
|
||||
|
|
|
@ -82,7 +82,7 @@ static void Ins_GetParamInsOrder (void);
|
|||
static void Ins_PutIconsEditingInstitutions (void);
|
||||
static void Ins_PutIconToViewInstitutions (void);
|
||||
|
||||
static void Ins_GetFullNameAndCtyOfInstitution (struct Instit *Ins,
|
||||
static void Ins_GetShrtNameAndCtyOfInstitution (struct Instit *Ins,
|
||||
char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]);
|
||||
|
||||
static void Ins_ListInstitutionsForEdition (void);
|
||||
|
@ -1129,12 +1129,12 @@ void Ins_WriteInstitutionNameAndCty (long InsCod)
|
|||
struct Instit Ins;
|
||||
char CtyName[Hie_MAX_BYTES_FULL_NAME + 1];
|
||||
|
||||
/***** Get institution full name *****/
|
||||
/***** Get institution short name and country name *****/
|
||||
Ins.InsCod = InsCod;
|
||||
Ins_GetFullNameAndCtyOfInstitution (&Ins,CtyName);
|
||||
Ins_GetShrtNameAndCtyOfInstitution (&Ins,CtyName);
|
||||
|
||||
/***** Write institution full name *****/
|
||||
fprintf (Gbl.F.Out,"%s<br />%s",Ins.FullName,CtyName);
|
||||
/***** Write institution short name and country name *****/
|
||||
fprintf (Gbl.F.Out,"%s (%s)",Ins.ShrtName,CtyName);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1281,12 +1281,12 @@ void Ins_GetShortNameOfInstitution (struct Instit *Ins)
|
|||
|
||||
void Ins_FlushCacheFullNameAndCtyOfInstitution (void)
|
||||
{
|
||||
Gbl.Cache.InstitutionFullNameAndCty.InsCod = -1L;
|
||||
Gbl.Cache.InstitutionFullNameAndCty.FullName[0] = '\0';
|
||||
Gbl.Cache.InstitutionFullNameAndCty.CtyName[0] = '\0';
|
||||
Gbl.Cache.InstitutionShrtNameAndCty.InsCod = -1L;
|
||||
Gbl.Cache.InstitutionShrtNameAndCty.ShrtName[0] = '\0';
|
||||
Gbl.Cache.InstitutionShrtNameAndCty.CtyName[0] = '\0';
|
||||
}
|
||||
|
||||
static void Ins_GetFullNameAndCtyOfInstitution (struct Instit *Ins,
|
||||
static void Ins_GetShrtNameAndCtyOfInstitution (struct Instit *Ins,
|
||||
char CtyName[Hie_MAX_BYTES_FULL_NAME + 1])
|
||||
{
|
||||
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
||||
|
@ -1296,27 +1296,27 @@ static void Ins_GetFullNameAndCtyOfInstitution (struct Instit *Ins,
|
|||
/***** 1. Fast check: Trivial case *****/
|
||||
if (Ins->InsCod <= 0)
|
||||
{
|
||||
Ins->FullName[0] = '\0'; // Empty name
|
||||
Ins->ShrtName[0] = '\0'; // Empty name
|
||||
CtyName[0] = '\0'; // Empty name
|
||||
return;
|
||||
}
|
||||
|
||||
/***** 2. Fast check: If cached... *****/
|
||||
if (Ins->InsCod == Gbl.Cache.InstitutionFullNameAndCty.InsCod)
|
||||
if (Ins->InsCod == Gbl.Cache.InstitutionShrtNameAndCty.InsCod)
|
||||
{
|
||||
Str_Copy (Ins->FullName,Gbl.Cache.InstitutionFullNameAndCty.FullName,
|
||||
Hie_MAX_BYTES_FULL_NAME);
|
||||
Str_Copy (CtyName,Gbl.Cache.InstitutionFullNameAndCty.CtyName,
|
||||
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtNameAndCty.ShrtName,
|
||||
Hie_MAX_BYTES_SHRT_NAME);
|
||||
Str_Copy (CtyName,Gbl.Cache.InstitutionShrtNameAndCty.CtyName,
|
||||
Hie_MAX_BYTES_FULL_NAME);
|
||||
return;
|
||||
}
|
||||
|
||||
/***** 3. Slow: get full name and country of institution from database *****/
|
||||
Gbl.Cache.InstitutionFullNameAndCty.InsCod = Ins->InsCod;
|
||||
/***** 3. Slow: get short name and country of institution from database *****/
|
||||
Gbl.Cache.InstitutionShrtNameAndCty.InsCod = Ins->InsCod;
|
||||
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get the full name"
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get short name and country"
|
||||
" of an institution",
|
||||
"SELECT institutions.FullName,countries.Name_%s"
|
||||
"SELECT institutions.ShortName,countries.Name_%s"
|
||||
" FROM institutions,countries"
|
||||
" WHERE institutions.InsCod=%ld"
|
||||
" AND institutions.CtyCod=countries.CtyCod",
|
||||
|
@ -1325,26 +1325,26 @@ static void Ins_GetFullNameAndCtyOfInstitution (struct Instit *Ins,
|
|||
/* Get row */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get the full name of this institution (row[0]) */
|
||||
Str_Copy (Gbl.Cache.InstitutionFullNameAndCty.FullName,row[0],
|
||||
Hie_MAX_BYTES_FULL_NAME);
|
||||
/* Get the short name of this institution (row[0]) */
|
||||
Str_Copy (Gbl.Cache.InstitutionShrtNameAndCty.ShrtName,row[0],
|
||||
Hie_MAX_BYTES_SHRT_NAME);
|
||||
|
||||
/* Get the name of the country (row[1]) */
|
||||
Str_Copy (Gbl.Cache.InstitutionFullNameAndCty.CtyName,row[1],
|
||||
Str_Copy (Gbl.Cache.InstitutionShrtNameAndCty.CtyName,row[1],
|
||||
Hie_MAX_BYTES_FULL_NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
Gbl.Cache.InstitutionFullNameAndCty.FullName[0] = '\0';
|
||||
Gbl.Cache.InstitutionFullNameAndCty.CtyName[0] = '\0';
|
||||
Gbl.Cache.InstitutionShrtNameAndCty.ShrtName[0] = '\0';
|
||||
Gbl.Cache.InstitutionShrtNameAndCty.CtyName[0] = '\0';
|
||||
}
|
||||
|
||||
/* Free structure that stores the query result */
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
Str_Copy (Ins->FullName,Gbl.Cache.InstitutionFullNameAndCty.FullName,
|
||||
Hie_MAX_BYTES_FULL_NAME);
|
||||
Str_Copy (CtyName,Gbl.Cache.InstitutionFullNameAndCty.CtyName,
|
||||
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtNameAndCty.ShrtName,
|
||||
Hie_MAX_BYTES_SHRT_NAME);
|
||||
Str_Copy (CtyName,Gbl.Cache.InstitutionShrtNameAndCty.CtyName,
|
||||
Hie_MAX_BYTES_FULL_NAME);
|
||||
}
|
||||
|
||||
|
|
48
swad_photo.c
48
swad_photo.c
|
@ -1184,6 +1184,7 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
|
|||
const char *ClassPhoto,Pho_Zoom_t Zoom,
|
||||
bool FormUnique)
|
||||
{
|
||||
extern const char *Rol_Icons[Rol_NUM_ROLES];
|
||||
extern const char *Txt_Following;
|
||||
extern const char *Txt_Followers;
|
||||
unsigned NumFollowing;
|
||||
|
@ -1195,6 +1196,8 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
|
|||
bool PutZoomCode = (Zoom == Pho_ZOOM) && // Make zoom
|
||||
BrowserTabIs1stTab; // Only in main browser tab
|
||||
char IdCaption[Frm_MAX_BYTES_ID + 1];
|
||||
char MainDegreeShrtName[Hie_MAX_BYTES_SHRT_NAME + 1];
|
||||
Rol_Role_t MaxRole; // Maximum user's role in his/her main degree
|
||||
|
||||
/***** Start form to go to public profile *****/
|
||||
if (PutLinkToPublicProfile)
|
||||
|
@ -1221,10 +1224,18 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
|
|||
IdCaption);
|
||||
|
||||
/* First name and surnames */
|
||||
fprintf (Gbl.F.Out,"<div class=\"ZOOM_TXT_LINE DAT_N\">"); // Limited width
|
||||
fprintf (Gbl.F.Out,"<div class=\"ZOOM_TXT_LINE DAT_N_BOLD\">"); // Limited width
|
||||
Usr_WriteFirstNameBRSurnames (UsrDat);
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
|
||||
/* Nickname */
|
||||
if (UsrDat->Nickname[0])
|
||||
fprintf (Gbl.F.Out,"<div class=\"ZOOM_TXT_LINE DAT_SMALL_N\">"
|
||||
"@%s"
|
||||
"</div>",
|
||||
UsrDat->Nickname);
|
||||
|
||||
|
||||
/* Institution full name and institution country */
|
||||
if (UsrDat->InsCod > 0)
|
||||
{
|
||||
|
@ -1237,20 +1248,35 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
|
|||
{
|
||||
fprintf (Gbl.F.Out,"<div class=\"ZOOM_TXT_LINE DAT_SMALL\">");
|
||||
Cty_WriteCountryName (UsrDat->CtyCod,
|
||||
NULL); // Don't put link to country
|
||||
NULL); // Don't put link to country
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
}
|
||||
|
||||
/* Main degree (in which the user has more courses) short name */
|
||||
Usr_GetMainDeg (UsrDat->UsrCod,MainDegreeShrtName,&MaxRole);
|
||||
if (MainDegreeShrtName[0])
|
||||
fprintf (Gbl.F.Out,"<div class=\"ZOOM_TXT_LINE DAT_SMALL\">"
|
||||
"<div class=\"ZOOM_DEG\""
|
||||
" style=\"background-image:url('%s/%s');\">"
|
||||
"%s"
|
||||
"</div>"
|
||||
"</div>",
|
||||
Gbl.Prefs.URLIcons,Rol_Icons[MaxRole],
|
||||
MainDegreeShrtName);
|
||||
|
||||
/* Following and followers */
|
||||
Fol_GetNumFollow (UsrDat->UsrCod,&NumFollowing,&NumFollowers);
|
||||
fprintf (Gbl.F.Out,"<div class=\"ZOOM_TXT_LINE\">"
|
||||
"<span class=\"DAT_N_BOLD\">%u</span>"
|
||||
"<span class=\"DAT_SMALL\"> %s </span>"
|
||||
"<span class=\"DAT_N_BOLD\">%u</span>"
|
||||
"<span class=\"DAT_SMALL\"> %s</span>"
|
||||
"</div>",
|
||||
NumFollowing,Txt_Following,
|
||||
NumFollowers,Txt_Followers);
|
||||
if (UsrDat->Nickname[0]) // Get social data only if nickname is retrieved (in some actions)
|
||||
{
|
||||
Fol_GetNumFollow (UsrDat->UsrCod,&NumFollowing,&NumFollowers);
|
||||
fprintf (Gbl.F.Out,"<div class=\"ZOOM_TXT_LINE\">"
|
||||
"<span class=\"DAT_N_BOLD\">%u</span>"
|
||||
"<span class=\"DAT_SMALL\"> %s </span>"
|
||||
"<span class=\"DAT_N_BOLD\">%u</span>"
|
||||
"<span class=\"DAT_SMALL\"> %s</span>"
|
||||
"</div>",
|
||||
NumFollowing,Txt_Following,
|
||||
NumFollowers,Txt_Followers);
|
||||
}
|
||||
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
}
|
||||
|
|
51
swad_user.c
51
swad_user.c
|
@ -2355,6 +2355,57 @@ unsigned long Usr_GetCrssFromUsr (long UsrCod,long DegCod,MYSQL_RES **mysql_res)
|
|||
UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********* Get the degree in which a user is enroled in more courses *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Usr_GetMainDeg (long UsrCod,
|
||||
char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1],
|
||||
Rol_Role_t *MaxRole)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
|
||||
/***** Get a random student from current course from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get user's main degree",
|
||||
"SELECT degrees.ShortName," // row[0]
|
||||
"main_degree.MaxRole" // row[1]
|
||||
" FROM degrees,"
|
||||
|
||||
// The second table contain only one row with the main degree
|
||||
" (SELECT courses.DegCod AS DegCod,"
|
||||
"MAX(crs_usr.Role) AS MaxRole,"
|
||||
"COUNT(*) AS N"
|
||||
" FROM crs_usr,courses"
|
||||
" WHERE crs_usr.UsrCod=%ld"
|
||||
" AND crs_usr.CrsCod=courses.CrsCod"
|
||||
" GROUP BY courses.DegCod"
|
||||
" ORDER BY N DESC" // Ordered by number of courses in which user is enroled
|
||||
" LIMIT 1)" // We need only the main degree
|
||||
" AS main_degree"
|
||||
|
||||
" WHERE degrees.DegCod=main_degree.DegCod",
|
||||
UsrCod))
|
||||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get degree name (row[0]) */
|
||||
Str_Copy (ShrtName,row[0],
|
||||
Hie_MAX_BYTES_SHRT_NAME);
|
||||
|
||||
/* Get maximum role (row[1]) */
|
||||
*MaxRole = Rol_ConvertUnsignedStrToRole (row[1]);
|
||||
}
|
||||
else // User is not enroled in any course
|
||||
{
|
||||
ShrtName[0] = '\0';
|
||||
*MaxRole = Rol_UNK;
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******** Check if a user exists with a given encrypted user's code **********/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -133,7 +133,7 @@ struct UsrData
|
|||
{
|
||||
struct
|
||||
{
|
||||
bool Valid; // Role is not valid (for examples, it has not been trtriev
|
||||
bool Valid; // Role is valid (is already filled)?
|
||||
Rol_Role_t Role;
|
||||
} InCurrentCrs; // Role in current course (Rol_UNK is no course selected)
|
||||
int InCrss; // Roles in all his/her courses
|
||||
|
@ -310,6 +310,9 @@ unsigned long Usr_GetInssFromUsr (long UsrCod,long CtyCod,MYSQL_RES **mysql_res)
|
|||
unsigned long Usr_GetCtrsFromUsr (long UsrCod,long InsCod,MYSQL_RES **mysql_res);
|
||||
unsigned long Usr_GetDegsFromUsr (long UsrCod,long CtrCod,MYSQL_RES **mysql_res);
|
||||
unsigned long Usr_GetCrssFromUsr (long UsrCod,long DegCod,MYSQL_RES **mysql_res);
|
||||
void Usr_GetMainDeg (long UsrCod,
|
||||
char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1],
|
||||
Rol_Role_t *MaxRole);
|
||||
|
||||
bool Usr_ChkIfEncryptedUsrCodExists (const char EncryptedUsrCod[Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue