Version 15.44

This commit is contained in:
Antonio Cañas Vargas 2015-11-23 00:44:39 +01:00
parent dacad74685
commit 3bcbabd447
6 changed files with 136 additions and 62 deletions

View File

@ -104,24 +104,22 @@
// TODO: When a new assignment/attendance/survey is incorrect, the second time the form is shown, it should be filled with partial data, now is always empty // TODO: When a new assignment/attendance/survey is incorrect, the second time the form is shown, it should be filled with partial data, now is always empty
// TODO: Remove columns "first year, last year, optional, status" when listing degrees? // TODO: Remove columns "first year, last year, optional, status" when listing degrees?
// TODO: Show message indicating that mail could be in SPAM folder // TODO: Show message indicating that mail could be in SPAM folder
// TODO: List institution and centre admins
// TODO: List of degrees administrated by a degree admin should be ordered by name
/*****************************************************************************/ /*****************************************************************************/
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.43.2 (2015/11/22)" #define Log_PLATFORM_VERSION "SWAD 15.44 (2015/11/23)"
// 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.43.2: Nov 22, 2015 Minor changes in CSS. (187719 lines) Version 15.44: Nov 23, 2015 Changes in list of institution, centre and degree administrators. (187787 lines)
Version 15.43.1: Nov 22, 2015 New figure (statistic) about first day of week. (187722 lines) Version 15.43.1: Nov 22, 2015 New figure (statistic) about first day of week. (187722 lines)
1 change necessary in database: 1 change necessary in database:
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1485','es','N','Cambiar primer día semana en calendario'); INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1485','es','N','Cambiar primer día semana en calendario');
Version 15.43: Nov 21, 2015 New figure (statistic) about first day of week. (187693 lines) Version 15.43: Nov 21, 2015 Form in calendar to select first day of week. (187693 lines)
Version 15.42.4: Nov 21, 2015 Fixed bug when getting first day of week from IP preferences. (187535 lines) Version 15.42.4: Nov 21, 2015 Fixed bug when getting first day of week from IP preferences. (187535 lines)
Version 15.42.3: Nov 21, 2015 Stats of hits distributed by week depend on user's preference about first day of the week. (187528 lines) Version 15.42.3: Nov 21, 2015 Stats of hits distributed by week depend on user's preference about first day of the week. (187528 lines)
Version 15.42.2: Nov 21, 2015 Fixed bug in JavaScript code to draw months. (187524 lines) Version 15.42.2: Nov 21, 2015 Fixed bug in JavaScript code to draw months. (187524 lines)
@ -132,7 +130,7 @@ ALTER TABLE IP_prefs ADD COLUMN FirstDayOfWeek TINYINT NOT NULL DEFAULT 0 AFTER
ALTER TABLE usr_data ADD COLUMN FirstDayOfWeek TINYINT NOT NULL DEFAULT 0 AFTER Language,ADD INDEX (FirstDayOfWeek); ALTER TABLE usr_data ADD COLUMN FirstDayOfWeek TINYINT NOT NULL DEFAULT 0 AFTER Language,ADD INDEX (FirstDayOfWeek);
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1484','es','N','Cambiar primer día de semana'); INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1484','es','N','Cambiar primer día de semana');
Version 15.41: Nov 21, 2015 Javascript code to draw a month with sunday as the first day of a week. (187316 lines) Version 15.41: Nov 21, 2015 JavaScript code to draw a month with sunday as the first day of a week. (187316 lines)
Version 15.40.8: Nov 20, 2015 Password is requested only one time when creating a new account. (187309 lines) Version 15.40.8: Nov 20, 2015 Password is requested only one time when creating a new account. (187309 lines)
Version 15.40.7: Nov 20, 2015 New help button to register students in courses without them. (187319 lines) Version 15.40.7: Nov 20, 2015 New help button to register students in courses without them. (187319 lines)
Version 15.40.6: Nov 20, 2015 New button to register students in courses without them. Version 15.40.6: Nov 20, 2015 New button to register students in courses without them.

View File

@ -3895,31 +3895,51 @@ bool Deg_CheckIfYearIsValidInDeg (unsigned Year,struct Degree *Deg)
} }
/*****************************************************************************/ /*****************************************************************************/
/********** Write the degrees administrated by an administrator **************/ /***** Write institutions, centres and degrees administrated by an admin *****/
/*****************************************************************************/ /*****************************************************************************/
void Deg_GetAndWriteDegreesAdminBy (long UsrCod,unsigned ColSpan) void Deg_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan)
{ {
extern const char *Txt_Go_to_X; extern const char *Txt_Go_to_X;
extern const char *Txt_all_degrees; extern const char *Txt_all_degrees;
char Query[512]; char Query[2048];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned long NumRow,NumRows; unsigned NumRow;
unsigned NumRows;
struct Institution Ins;
struct Centre Ctr;
struct Degree Deg; struct Degree Deg;
/***** Get degrees admin by a user from database *****/ /***** Get institutions, centres, degrees admin by user from database *****/
sprintf (Query,"(SELECT -1 AS DegCod,'' AS FullName" sprintf (Query,"(SELECT '%u' AS Scope,'-1' AS Cod,'' AS FullName"
" FROM admin" " FROM admin"
" WHERE UsrCod='%ld' AND Scope='Sys')" " WHERE UsrCod='%ld'"
" AND Scope='Sys')"
" UNION " " UNION "
"(SELECT DegCod,degrees.FullName" "(SELECT '%u' AS Scope,admin.Cod,institutions.FullName"
" FROM admin,institutions"
" WHERE admin.UsrCod='%ld'"
" AND admin.Scope='Ins'"
" AND admin.Cod=institutions.InsCod)"
" UNION "
"(SELECT '%u' AS Scope,admin.Cod,centres.FullName"
" FROM admin,centres"
" WHERE admin.UsrCod='%ld'"
" AND admin.Scope='Ctr'"
" AND admin.Cod=centres.CtrCod)"
" UNION "
"(SELECT '%u' AS Scope,admin.Cod,degrees.FullName"
" FROM admin,degrees" " FROM admin,degrees"
" WHERE admin.UsrCod='%ld' AND admin.Scope='Deg'" " WHERE admin.UsrCod='%ld'"
" AND admin.Scope='Deg'"
" AND admin.Cod=degrees.DegCod)" " AND admin.Cod=degrees.DegCod)"
" ORDER BY FullName", " ORDER BY Scope,FullName",
UsrCod,UsrCod); (unsigned) Sco_SCOPE_SYS,UsrCod,
if ((NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get degrees admin by a user"))) // If degrees found for this administrator (unsigned) Sco_SCOPE_INS,UsrCod,
(unsigned) Sco_SCOPE_CTR,UsrCod,
(unsigned) Sco_SCOPE_DEG,UsrCod);
if ((NumRows = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get institutions, centres, degrees admin by a user")))
/***** Get the list of degrees *****/ /***** Get the list of degrees *****/
for (NumRow = 1; for (NumRow = 1;
NumRow <= NumRows; NumRow <= NumRows;
@ -3936,34 +3956,67 @@ void Deg_GetAndWriteDegreesAdminBy (long UsrCod,unsigned ColSpan)
NumRow == NumRows ? "subend" : NumRow == NumRows ? "subend" :
"submid"); "submid");
/***** Write degree *****/ /***** Write institution, centre, degree *****/
fprintf (Gbl.F.Out,"<td colspan=\"%u\"" fprintf (Gbl.F.Out,"<td colspan=\"%u\""
" class=\"DAT_SMALL_NOBR LEFT_TOP COLOR%u\">", " class=\"DAT_SMALL_NOBR LEFT_TOP COLOR%u\">",
ColSpan - 1,Gbl.RowEvenOdd); ColSpan - 1,Gbl.RowEvenOdd);
/* Get next degree */ /* Get next institution, centre, degree */
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
Deg.DegCod = Str_ConvertStrCodToLongCod (row[0]);
if (Deg.DegCod > 0) /* Get scope */
{ switch (Sco_GetScopeFromUnsignedStr (row[0]))
/* Get data of degree */ {
Deg_GetDataOfDegreeByCod (&Deg); case Sco_SCOPE_SYS: // System
fprintf (Gbl.F.Out,"<img src=\"%s/swad16x16.gif\""
/* Write degree logo and degree short name */ " alt=\"%s\" title=\"%s\""
Deg_DrawDegreeLogoAndNameWithLink (&Deg,ActSeeDegInf, " class=\"ICON16x16\" />"
"DAT_SMALL_NOBR","LEFT_TOP"); "&nbsp;%s",
}
else
fprintf (Gbl.F.Out,"<img src=\"%s/swad16x16.gif\""
" alt=\"%s\" title=\"%s\""
" class=\"ICON16x16\" />"
" %s",
Gbl.Prefs.IconsURL, Gbl.Prefs.IconsURL,
Txt_all_degrees, Txt_all_degrees,
Txt_all_degrees, Txt_all_degrees,
Txt_all_degrees); Txt_all_degrees);
break;
case Sco_SCOPE_INS: // Institution
Ins.InsCod = Str_ConvertStrCodToLongCod (row[1]);
if (Ins.InsCod > 0)
{
/* Get data of institution */
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_MINIMAL_DATA);
/* Write institution logo and name */
Ins_DrawInstitutionLogoAndNameWithLink (&Ins,ActSeeInsInf,
"DAT_SMALL_NOBR","LEFT_TOP");
}
break;
case Sco_SCOPE_CTR: // Centre
Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[1]);
if (Ctr.CtrCod > 0)
{
/* Get data of centre */
Ctr_GetDataOfCentreByCod (&Ctr);
/* Write centre logo and name */
Ctr_DrawCentreLogoAndNameWithLink (&Ctr,ActSeeCtrInf,
"DAT_SMALL_NOBR","LEFT_TOP");
}
break;
case Sco_SCOPE_DEG: // Degree
Deg.DegCod = Str_ConvertStrCodToLongCod (row[1]);
if (Deg.DegCod > 0)
{
/* Get data of degree */
Deg_GetDataOfDegreeByCod (&Deg);
/* Write degree logo and name */
Deg_DrawDegreeLogoAndNameWithLink (&Deg,ActSeeDegInf,
"DAT_SMALL_NOBR","LEFT_TOP");
}
break;
default: // There are no administrators in other scopes
Lay_ShowErrorAndExit ("Wrong scope.");
break;
}
fprintf (Gbl.F.Out,"</td>" fprintf (Gbl.F.Out,"</td>"
"</tr>"); "</tr>");
} }

View File

@ -165,7 +165,7 @@ unsigned Deg_GetNumDegsWithUsrs (Rol_Role_t Role,const char *SubQuery);
bool Deg_CheckIfYearIsValidInDeg (unsigned Year,struct Degree *Deg); bool Deg_CheckIfYearIsValidInDeg (unsigned Year,struct Degree *Deg);
void Deg_GetAndWriteDegreesAdminBy (long UsrCod,unsigned ColSpan); void Deg_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan);
unsigned Deg_ListDegsFound (const char *Query); unsigned Deg_ListDegsFound (const char *Query);

View File

@ -25,6 +25,8 @@
/*********************************** Headers *********************************/ /*********************************** Headers *********************************/
/*****************************************************************************/ /*****************************************************************************/
#include <string.h> // For string functions
#include "swad_config.h" #include "swad_config.h"
#include "swad_global.h" #include "swad_global.h"
#include "swad_parameter.h" #include "swad_parameter.h"
@ -37,7 +39,7 @@
const char *Sco_ScopeAdminDB[Sco_NUM_SCOPES] = const char *Sco_ScopeAdminDB[Sco_NUM_SCOPES] =
{ {
NULL, // Sco_SCOPE_UNK NULL, // Sco_SCOPE_UNK
NULL, // Sco_SCOPE_SYS, "Sys", // Sco_SCOPE_SYS,
NULL, // Sco_SCOPE_CTY, NULL, // Sco_SCOPE_CTY,
"Ins", // Sco_SCOPE_INS, "Ins", // Sco_SCOPE_INS,
"Ctr", // Sco_SCOPE_CTR, "Ctr", // Sco_SCOPE_CTR,
@ -190,30 +192,26 @@ void Sco_PutParamScope (Sco_Scope_t Scope)
void Sco_GetScope (void) void Sco_GetScope (void)
{ {
char UnsignedStr[10+1]; char UnsignedStr[10+1];
unsigned UnsignedNum;
Gbl.Scope.Current = Gbl.Scope.Default;
/***** Get parameter location range if exists *****/ /***** Get parameter location range if exists *****/
Par_GetParToText ("Scope",UnsignedStr,10); Par_GetParToText ("Scope",UnsignedStr,10);
if (sscanf (UnsignedStr,"%u",&UnsignedNum) == 1) if ((Gbl.Scope.Current = Sco_GetScopeFromUnsignedStr (UnsignedStr)) == Sco_SCOPE_UNK)
if (UnsignedNum < Sco_NUM_SCOPES) Gbl.Scope.Current = Gbl.Scope.Default;
Gbl.Scope.Current = (Sco_Scope_t) UnsignedNum;
/***** Avoid impossible scopes *****/ /***** Avoid impossible scopes *****/
if (Gbl.Scope.Current == Sco_SCOPE_CRS && Gbl.CurrentCrs.Crs.CrsCod <= 0) if (Gbl.Scope.Current == Sco_SCOPE_CRS && Gbl.CurrentCrs.Crs.CrsCod <= 0)
Gbl.Scope.Current = Sco_SCOPE_DEG; Gbl.Scope.Current = Sco_SCOPE_DEG;
if (Gbl.Scope.Current == Sco_SCOPE_DEG && Gbl.CurrentDeg.Deg.DegCod <= 0) if (Gbl.Scope.Current == Sco_SCOPE_DEG && Gbl.CurrentDeg.Deg.DegCod <= 0)
Gbl.Scope.Current = Sco_SCOPE_CTR; Gbl.Scope.Current = Sco_SCOPE_CTR;
if (Gbl.Scope.Current == Sco_SCOPE_CTR && Gbl.CurrentCtr.Ctr.CtrCod <= 0) if (Gbl.Scope.Current == Sco_SCOPE_CTR && Gbl.CurrentCtr.Ctr.CtrCod <= 0)
Gbl.Scope.Current = Sco_SCOPE_INS; Gbl.Scope.Current = Sco_SCOPE_INS;
if (Gbl.Scope.Current == Sco_SCOPE_INS && Gbl.CurrentIns.Ins.InsCod <= 0) if (Gbl.Scope.Current == Sco_SCOPE_INS && Gbl.CurrentIns.Ins.InsCod <= 0)
Gbl.Scope.Current = Sco_SCOPE_CTY; Gbl.Scope.Current = Sco_SCOPE_CTY;
if (Gbl.Scope.Current == Sco_SCOPE_CTY && Gbl.CurrentCty.Cty.CtyCod <= 0) if (Gbl.Scope.Current == Sco_SCOPE_CTY && Gbl.CurrentCty.Cty.CtyCod <= 0)
Gbl.Scope.Current = Sco_SCOPE_SYS; Gbl.Scope.Current = Sco_SCOPE_SYS;
/***** Avoid forbidden scopes *****/ /***** Avoid forbidden scopes *****/
@ -294,3 +292,18 @@ void Sco_SetScopesForListingStudents (void)
break; break;
} }
} }
/*****************************************************************************/
/*************************** Get scope from string ***************************/
/*****************************************************************************/
Sco_Scope_t Sco_GetScopeFromUnsignedStr (const char *UnsignedStr)
{
unsigned UnsignedNum;
if (sscanf (UnsignedStr,"%u",&UnsignedNum) == 1)
if (UnsignedNum < Sco_NUM_SCOPES)
return (Sco_Scope_t) UnsignedNum;
return Sco_SCOPE_UNK;
}

View File

@ -60,4 +60,6 @@ void Sco_GetScope (void);
void Sco_SetScopesForListingGuests (void); void Sco_SetScopesForListingGuests (void);
void Sco_SetScopesForListingStudents (void); void Sco_SetScopesForListingStudents (void);
Sco_Scope_t Sco_GetScopeFromUnsignedStr (const char *UnsignedStr);
#endif #endif

View File

@ -3285,7 +3285,7 @@ void Usr_WriteRowAdmData (unsigned NumUsr,struct UsrData *UsrDat)
fprintf (Gbl.F.Out,"</tr>"); fprintf (Gbl.F.Out,"</tr>");
/***** Write degrees which are administrated by this administrator *****/ /***** Write degrees which are administrated by this administrator *****/
Deg_GetAndWriteDegreesAdminBy (UsrDat->UsrCod, Deg_GetAndWriteInsCtrDegAdminBy (UsrDat->UsrCod,
Gbl.Usrs.Listing.WithPhotos ? Usr_NUM_MAIN_FIELDS_DATA_ADM : Gbl.Usrs.Listing.WithPhotos ? Usr_NUM_MAIN_FIELDS_DATA_ADM :
Usr_NUM_MAIN_FIELDS_DATA_ADM-1); Usr_NUM_MAIN_FIELDS_DATA_ADM-1);
@ -4153,24 +4153,35 @@ static void Usr_GetAdmsLst (Sco_Scope_t Scope)
case Sco_SCOPE_SYS: case Sco_SCOPE_SYS:
strcpy (Query,"SELECT DISTINCT admin.UsrCod,'Y',usr_data.Sex" strcpy (Query,"SELECT DISTINCT admin.UsrCod,'Y',usr_data.Sex"
" FROM admin,usr_data" " FROM admin,usr_data"
" WHERE (admin.Scope='Deg'" " WHERE admin.UsrCod=usr_data.UsrCod"
" OR admin.Scope='Sys')"
" AND admin.UsrCod=usr_data.UsrCod "
" ORDER BY " " ORDER BY "
"usr_data.Surname1," "usr_data.Surname1,"
"usr_data.Surname2," "usr_data.Surname2,"
"usr_data.FirstName," "usr_data.FirstName,"
"usr_data.UsrCod"); "usr_data.UsrCod");
break; break;
case Sco_SCOPE_CTY:
sprintf (Query,"SELECT DISTINCT admin.UsrCod,'Y',usr_data.Sex"
" FROM institutions,centres,degrees,admin,usr_data"
" WHERE institutions.CtyCod='%ld'"
" AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=admin.Cod"
" AND admin.UsrCod=usr_data.UsrCod"
" ORDER BY "
"usr_data.Surname1,"
"usr_data.Surname2,"
"usr_data.FirstName,"
"usr_data.UsrCod",
Gbl.CurrentCty.Cty.CtyCod);
break;
case Sco_SCOPE_INS: case Sco_SCOPE_INS:
sprintf (Query,"SELECT DISTINCT admin.UsrCod,'Y',usr_data.Sex" sprintf (Query,"SELECT DISTINCT admin.UsrCod,'Y',usr_data.Sex"
" FROM centres,degrees,admin,usr_data" " FROM centres,degrees,admin,usr_data"
" WHERE ((centres.InsCod='%ld'" " WHERE centres.InsCod='%ld'"
" AND centres.CtrCod=degrees.CtrCod" " AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=admin.Cod" " AND degrees.DegCod=admin.Cod"
" AND admin.Scope='Deg')" " AND admin.UsrCod=usr_data.UsrCod"
" OR admin.Scope='Sys')"
" AND admin.UsrCod=usr_data.UsrCod "
" ORDER BY " " ORDER BY "
"usr_data.Surname1," "usr_data.Surname1,"
"usr_data.Surname2," "usr_data.Surname2,"
@ -4181,11 +4192,9 @@ static void Usr_GetAdmsLst (Sco_Scope_t Scope)
case Sco_SCOPE_CTR: case Sco_SCOPE_CTR:
sprintf (Query,"SELECT DISTINCT admin.UsrCod,'Y',usr_data.Sex" sprintf (Query,"SELECT DISTINCT admin.UsrCod,'Y',usr_data.Sex"
" FROM degrees,admin,usr_data" " FROM degrees,admin,usr_data"
" WHERE ((degrees.CtrCod='%ld'" " WHERE degrees.CtrCod='%ld'"
" AND degrees.DegCod=admin.Cod" " AND degrees.DegCod=admin.Cod"
" AND admin.Scope='Deg')" " AND admin.UsrCod=usr_data.UsrCod"
" OR admin.Scope='Sys')"
" AND admin.UsrCod=usr_data.UsrCod "
" ORDER BY " " ORDER BY "
"usr_data.Surname1," "usr_data.Surname1,"
"usr_data.Surname2," "usr_data.Surname2,"
@ -4196,9 +4205,8 @@ static void Usr_GetAdmsLst (Sco_Scope_t Scope)
case Sco_SCOPE_DEG: case Sco_SCOPE_DEG:
sprintf (Query,"SELECT DISTINCT admin.UsrCod,'Y',usr_data.Sex" sprintf (Query,"SELECT DISTINCT admin.UsrCod,'Y',usr_data.Sex"
" FROM admin,usr_data" " FROM admin,usr_data"
" WHERE ((admin.Scope='Deg' AND admin.Cod='%ld')" " WHERE admin.Cod='%ld'"
" OR admin.Scope='Sys')" " AND admin.UsrCod=usr_data.UsrCod"
" AND admin.UsrCod=usr_data.UsrCod "
" ORDER BY " " ORDER BY "
"usr_data.Surname1," "usr_data.Surname1,"
"usr_data.Surname2," "usr_data.Surname2,"