Skip to content

Commit

Permalink
Version 16.41.5
Browse files Browse the repository at this point in the history
  • Loading branch information
acanas committed Oct 23, 2016
1 parent 229bef3 commit 931e585
Show file tree
Hide file tree
Showing 15 changed files with 162 additions and 87 deletions.
34 changes: 22 additions & 12 deletions swad_centre.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ static void Ctr_ListCentresForEdition (void);
static bool Ctr_CheckIfICanEdit (struct Centre *Ctr);
static Ctr_StatusTxt_t Ctr_GetStatusTxtFromStatusBits (Ctr_Status_t Status);
static Ctr_Status_t Ctr_GetStatusBitsFromStatusTxt (Ctr_StatusTxt_t StatusTxt);

static void Ctr_PutParamOtherCtrCod (long CtrCod);
static long Ctr_GetParamOtherCtrCod (void);

static void Ctr_UpdateCtrInsDB (long CtrCod,long InsCod);
static void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShortOrFullName_t ShortOrFullName);
static bool Ctr_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name,long CtrCod,long InsCod);
Expand Down Expand Up @@ -1607,19 +1610,26 @@ static void Ctr_PutParamOtherCtrCod (long CtrCod)
/****************** Get parameter with code of other centre ******************/
/*****************************************************************************/

long Ctr_GetParamOtherCtrCod (void)
long Ctr_GetAndCheckParamOtherCtrCod (void)
{
char LongStr[1+10+1];
long CtrCod;

/***** Get parameter with code of centre *****/
Par_GetParToText ("OthCtrCod",LongStr,1+10);
if ((CtrCod = Str_ConvertStrCodToLongCod (LongStr)) <= 0)
/***** Get and check parameter with code of centre *****/
if ((CtrCod = Ctr_GetParamOtherCtrCod ()) < 0)
Lay_ShowErrorAndExit ("Code of centre is missing.");

return CtrCod;
}

static long Ctr_GetParamOtherCtrCod (void)
{
char LongStr[1+10+1];

/***** Get parameter with code of centre *****/
Par_GetParToText ("OthCtrCod",LongStr,1+10);
return Str_ConvertStrCodToLongCod (LongStr);
}

/*****************************************************************************/
/******************************* Remove a centre *****************************/
/*****************************************************************************/
Expand All @@ -1633,7 +1643,7 @@ void Ctr_RemoveCentre (void)
char PathCtr[PATH_MAX+1];

/***** Get centre code *****/
Ctr.CtrCod = Ctr_GetParamOtherCtrCod ();
Ctr.CtrCod = Ctr_GetAndCheckParamOtherCtrCod ();

/***** Get data of the centre from database *****/
Ctr_GetDataOfCentreByCod (&Ctr);
Expand Down Expand Up @@ -1681,7 +1691,7 @@ void Ctr_ChangeCtrInsInConfig (void)
struct Institution NewIns;

/***** Get parameter with institution code *****/
NewIns.InsCod = Ins_GetParamOtherInsCod ();
NewIns.InsCod = Ins_GetAndCheckParamOtherInsCod ();

/***** Check if institution has changed *****/
if (NewIns.InsCod != Gbl.CurrentCtr.Ctr.InsCod)
Expand Down Expand Up @@ -1763,7 +1773,7 @@ void Ctr_ChangeCentrePlace (void)

/***** Get parameters from form *****/
/* Get centre code */
Ctr->CtrCod = Ctr_GetParamOtherCtrCod ();
Ctr->CtrCod = Ctr_GetAndCheckParamOtherCtrCod ();

/* Get parameter with centre code */
NewPlcCod = Plc_GetParamPlcCod ();
Expand Down Expand Up @@ -1793,7 +1803,7 @@ void Ctr_ChangeCentrePlace (void)

void Ctr_RenameCentreShort (void)
{
Gbl.Ctrs.EditingCtr.CtrCod = Ctr_GetParamOtherCtrCod ();
Gbl.Ctrs.EditingCtr.CtrCod = Ctr_GetAndCheckParamOtherCtrCod ();
Ctr_RenameCentre (&Gbl.Ctrs.EditingCtr,Cns_SHORT_NAME);
}

Expand All @@ -1808,7 +1818,7 @@ void Ctr_RenameCentreShortInConfig (void)

void Ctr_RenameCentreFull (void)
{
Gbl.Ctrs.EditingCtr.CtrCod = Ctr_GetParamOtherCtrCod ();
Gbl.Ctrs.EditingCtr.CtrCod = Ctr_GetAndCheckParamOtherCtrCod ();
Ctr_RenameCentre (&Gbl.Ctrs.EditingCtr,Cns_FULL_NAME);
}

Expand Down Expand Up @@ -1928,7 +1938,7 @@ void Ctr_ChangeCtrWWW (void)

/***** Get parameters from form *****/
/* Get the code of the centre */
Ctr->CtrCod = Ctr_GetParamOtherCtrCod ();
Ctr->CtrCod = Ctr_GetAndCheckParamOtherCtrCod ();

/* Get the new WWW for the centre */
Par_GetParToText ("WWW",NewWWW,Cns_MAX_LENGTH_WWW);
Expand Down Expand Up @@ -2016,7 +2026,7 @@ void Ctr_ChangeCtrStatus (void)

/***** Get parameters from form *****/
/* Get centre code */
Ctr->CtrCod = Ctr_GetParamOtherCtrCod ();
Ctr->CtrCod = Ctr_GetAndCheckParamOtherCtrCod ();

/* Get parameter with status */
Par_GetParToText ("Status",UnsignedNum,1);
Expand Down
2 changes: 1 addition & 1 deletion swad_centre.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void Ctr_GetShortNameOfCentreByCod (struct Centre *Ctr);
void Ctr_FreeListCentres (void);
void Ctr_WriteSelectorOfCentre (void);
void Ctr_PutParamCtrCod (long CtrCod);
long Ctr_GetParamOtherCtrCod (void);
long Ctr_GetAndCheckParamOtherCtrCod (void);
void Ctr_RemoveCentre (void);
void Ctr_ChangeCtrInsInConfig (void);
void Ctr_ContEditAfterChgCtrInConfig (void);
Expand Down
5 changes: 3 additions & 2 deletions swad_changelog.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,15 @@
/****************************** Public constants *****************************/
/*****************************************************************************/

#define Log_PLATFORM_VERSION "SWAD 16.41.4 (2016-10-23)"
#define Log_PLATFORM_VERSION "SWAD 16.41.5 (2016-10-23)"
#define CSS_FILE "swad16.32.1.css"
#define JS_FILE "swad15.238.1.js"

// 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
/*
Version 16.41.4: Oct 23, 2016 Code refactoring in centres. (205398 lines)
Version 16.41.5: Oct 23, 2016 Code refactoring in countries, institutions, centres, degrees and courses. (205456 lines)
Version 16.41.4: Oct 23, 2016 Code refactoring in institutions. (205398 lines)
Version 16.41.3: Oct 23, 2016 Code refactoring in centres. (205408 lines)
Version 16.41.2: Oct 23, 2016 Code refactoring in degrees. (205430 lines)
Version 16.41.1: Oct 23, 2016 Code refactoring in courses. (205443 lines)
Expand Down
24 changes: 17 additions & 7 deletions swad_country.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ static void Cty_GetMapAttribution (long CtyCod,char **MapAttribution);
static void Cty_FreeMapAttribution (char **MapAttribution);
static void Cty_ListCountriesForEdition (void);
static void Cty_PutParamOtherCtyCod (long CtyCod);
static long Cty_GetParamOtherCtyCod (void);

static bool Cty_CheckIfNumericCountryCodeExists (long CtyCod);
static bool Cty_CheckIfAlpha2CountryCodeExists (const char Alpha2[2+1]);
static bool Cty_CheckIfCountryNameExists (Txt_Language_t Language,const char *Name,long CtyCod);
Expand Down Expand Up @@ -1527,7 +1529,18 @@ static void Cty_PutParamOtherCtyCod (long CtyCod)
/******************* Get parameter with code of country **********************/
/*****************************************************************************/

long Cty_GetParamOtherCtyCod (void)
long Cty_GetAndCheckParamOtherCtyCod (void)
{
long CtyCod;

/***** Get and check parameter with code of country *****/
if ((CtyCod = Cty_GetParamOtherCtyCod ()) < 0)
Lay_ShowErrorAndExit ("Code of country is missing.");

return CtyCod;
}

static long Cty_GetParamOtherCtyCod (void)
{
char LongStr[1+10+1];

Expand All @@ -1548,8 +1561,7 @@ void Cty_RemoveCountry (void)
struct Country Cty;

/***** Get country code *****/
if ((Cty.CtyCod = Cty_GetParamOtherCtyCod ()) < 0)
Lay_ShowErrorAndExit ("Code of country is missing.");
Cty.CtyCod = Cty_GetAndCheckParamOtherCtyCod ();

/***** Get data of the country from database *****/
Cty_GetDataOfCountryByCod (&Cty,Cty_GET_EXTRA_DATA);
Expand Down Expand Up @@ -1596,8 +1608,7 @@ void Cty_RenameCountry (void)

/***** Get parameters from form *****/
/* Get the code of the country */
if ((Cty->CtyCod = Cty_GetParamOtherCtyCod ()) < 0)
Lay_ShowErrorAndExit ("Code of country is missing.");
Cty->CtyCod = Cty_GetAndCheckParamOtherCtyCod ();

/* Get the lenguage */
Language = Pre_GetParamLanguage ();
Expand Down Expand Up @@ -1715,8 +1726,7 @@ void Cty_ChangeCtyWWW (void)

/***** Get parameters from form *****/
/* Get the code of the country */
if ((Cty->CtyCod = Cty_GetParamOtherCtyCod ()) < 0)
Lay_ShowErrorAndExit ("Code of country is missing.");
Cty->CtyCod = Cty_GetAndCheckParamOtherCtyCod ();

/* Get the lenguage */
Language = Pre_GetParamLanguage ();
Expand Down
2 changes: 1 addition & 1 deletion swad_country.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void Cty_WriteCountryName (long CtyCod,const char *Class);
bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraData);
void Cty_GetCountryName (long CtyCod,char CtyName[Cty_MAX_BYTES_COUNTRY_NAME+1]);
void Cty_PutParamCtyCod (long CtyCod);
long Cty_GetParamOtherCtyCod (void);
long Cty_GetAndCheckParamOtherCtyCod (void);
void Cty_RemoveCountry (void);
void Cty_RenameCountry (void);
void Cty_ChangeCtyWWW (void);
Expand Down
32 changes: 20 additions & 12 deletions swad_course.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ static void Crs_PutLinkToSearchCourses (void);
static void Sch_PutLinkToSearchCoursesParams (void);

static void Crs_PutParamOtherCrsCod (long CrsCod);
static long Crs_GetAndCheckParamOtherCrsCod (void);
static long Crs_GetParamOtherCrsCod (void);

static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnAccepted);
Expand Down Expand Up @@ -1979,7 +1980,7 @@ void Crs_RemoveCourse (void)
struct Course Crs;

/***** Get course code *****/
Crs.CrsCod = Crs_GetParamOtherCrsCod ();
Crs.CrsCod = Crs_GetAndCheckParamOtherCrsCod ();

/***** Get data of the course from database *****/
Crs_GetDataOfCourseByCod (&Crs);
Expand Down Expand Up @@ -2372,7 +2373,7 @@ void Crs_ChangeInsCrsCod (void)

/***** Get parameters from form *****/
/* Get course code */
Crs->CrsCod = Crs_GetParamOtherCrsCod ();
Crs->CrsCod = Crs_GetAndCheckParamOtherCrsCod ();

/* Get institutional code */
Par_GetParToText ("InsCrsCod",NewInstitutionalCrsCod,Crs_LENGTH_INSTITUTIONAL_CRS_COD);
Expand Down Expand Up @@ -2412,7 +2413,7 @@ void Crs_ChangeCrsDegInConfig (void)
struct Degree NewDeg;

/***** Get parameter with degree code *****/
NewDeg.DegCod = Deg_GetParamOtherDegCod ();
NewDeg.DegCod = Deg_GetAndCheckParamOtherDegCod ();

/***** Check if degree has changed *****/
if (NewDeg.DegCod != Gbl.CurrentCrs.Crs.DegCod)
Expand Down Expand Up @@ -2553,7 +2554,7 @@ void Crs_ChangeCrsYear (void)

/***** Get parameters from form *****/
/* Get course code */
Crs->CrsCod = Crs_GetParamOtherCrsCod ();
Crs->CrsCod = Crs_GetAndCheckParamOtherCrsCod ();

/* Get parameter with year */
Par_GetParToText ("OthCrsYear",YearStr,2);
Expand Down Expand Up @@ -2647,7 +2648,7 @@ void Crs_UpdateInstitutionalCrsCod (struct Course *Crs,const char *NewInstitutio

void Crs_RenameCourseShort (void)
{
Gbl.Degs.EditingCrs.CrsCod = Crs_GetParamOtherCrsCod ();
Gbl.Degs.EditingCrs.CrsCod = Crs_GetAndCheckParamOtherCrsCod ();
Crs_RenameCourse (&Gbl.Degs.EditingCrs,Cns_SHORT_NAME);
}

Expand All @@ -2662,7 +2663,7 @@ void Crs_RenameCourseShortInConfig (void)

void Crs_RenameCourseFull (void)
{
Gbl.Degs.EditingCrs.CrsCod = Crs_GetParamOtherCrsCod ();
Gbl.Degs.EditingCrs.CrsCod = Crs_GetAndCheckParamOtherCrsCod ();
Crs_RenameCourse (&Gbl.Degs.EditingCrs,Cns_FULL_NAME);
}

Expand Down Expand Up @@ -2779,7 +2780,7 @@ void Crs_ChangeCrsStatus (void)

/***** Get parameters from form *****/
/* Get course code */
Crs->CrsCod = Crs_GetParamOtherCrsCod ();
Crs->CrsCod = Crs_GetAndCheckParamOtherCrsCod ();

/* Get parameter with status */
Par_GetParToText ("Status",UnsignedNum,1);
Expand Down Expand Up @@ -2979,19 +2980,26 @@ static void Crs_PutParamOtherCrsCod (long CrsCod)
/********************* Get parameter with code of course *********************/
/*****************************************************************************/

static long Crs_GetParamOtherCrsCod (void)
static long Crs_GetAndCheckParamOtherCrsCod (void)
{
char LongStr[1+10+1];
long CrsCod;

/***** Get parameter with code of course *****/
Par_GetParToText ("OthCrsCod",LongStr,1+10);
if ((CrsCod = Str_ConvertStrCodToLongCod (LongStr)) <= 0)
/***** Get and check parameter with code of course *****/
if ((CrsCod = Crs_GetParamOtherCrsCod ()) < 0)
Lay_ShowErrorAndExit ("Code of course is missing.");

return CrsCod;
}

static long Crs_GetParamOtherCrsCod (void)
{
char LongStr[1+10+1];

/***** Get parameter with code of course *****/
Par_GetParToText ("OthCrsCod",LongStr,1+10);
return Str_ConvertStrCodToLongCod (LongStr);
}

/*****************************************************************************/
/************************** Write courses of a user **************************/
/*****************************************************************************/
Expand Down
30 changes: 19 additions & 11 deletions swad_degree.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ static void Deg_ListOneDegreeForSeeing (struct Degree *Deg,unsigned NumDeg);

static void Deg_RecFormRequestOrCreateDeg (unsigned Status);
static void Deg_PutParamOtherDegCod (long DegCod);
static long Deg_GetParamOtherDegCod (void);

static void Deg_GetDataOfDegreeFromRow (struct Degree *Deg,MYSQL_ROW row);
static void Deg_RenameDegree (struct Degree *Deg,Cns_ShortOrFullName_t ShortOrFullName);
Expand Down Expand Up @@ -1986,7 +1987,7 @@ void Deg_RemoveDegree (void)
struct Degree Deg;

/***** Get degree code *****/
Deg.DegCod = Deg_GetParamOtherDegCod ();
Deg.DegCod = Deg_GetAndCheckParamOtherDegCod ();

/***** Get data of degree *****/
Deg_GetDataOfDegreeByCod (&Deg);
Expand Down Expand Up @@ -2031,19 +2032,26 @@ static void Deg_PutParamOtherDegCod (long DegCod)
/********************* Get parameter with code of degree *********************/
/*****************************************************************************/

long Deg_GetParamOtherDegCod (void)
long Deg_GetAndCheckParamOtherDegCod (void)
{
char LongStr[1+10+1];
long DegCod;

/***** Get parameter with code of degree *****/
Par_GetParToText ("OthDegCod",LongStr,1+10);
if ((DegCod = Str_ConvertStrCodToLongCod (LongStr)) <= 0)
/***** Get and check parameter with code of degree *****/
if ((DegCod = Deg_GetParamOtherDegCod ()) < 0)
Lay_ShowErrorAndExit ("Code of degree is missing.");

return DegCod;
}

static long Deg_GetParamOtherDegCod (void)
{
char LongStr[1+10+1];

/***** Get parameter with code of degree *****/
Par_GetParToText ("OthDegCod",LongStr,1+10);
return Str_ConvertStrCodToLongCod (LongStr);
}

/*****************************************************************************/
/********************* Get data of a degree from its code ********************/
/*****************************************************************************/
Expand Down Expand Up @@ -2333,7 +2341,7 @@ void Deg_RemoveDegreeCompletely (long DegCod)

void Deg_RenameDegreeShort (void)
{
Gbl.Degs.EditingDeg.DegCod = Deg_GetParamOtherDegCod ();
Gbl.Degs.EditingDeg.DegCod = Deg_GetAndCheckParamOtherDegCod ();
Deg_RenameDegree (&Gbl.Degs.EditingDeg,Cns_SHORT_NAME);
}

Expand All @@ -2348,7 +2356,7 @@ void Deg_RenameDegreeShortInConfig (void)

void Deg_RenameDegreeFull (void)
{
Gbl.Degs.EditingDeg.DegCod = Deg_GetParamOtherDegCod ();
Gbl.Degs.EditingDeg.DegCod = Deg_GetAndCheckParamOtherDegCod ();
Deg_RenameDegree (&Gbl.Degs.EditingDeg,Cns_FULL_NAME);
}

Expand Down Expand Up @@ -2464,7 +2472,7 @@ void Deg_ChangeDegCtrInConfig (void)
struct Centre NewCtr;

/***** Get parameter with centre code *****/
NewCtr.CtrCod = Ctr_GetParamOtherCtrCod ();
NewCtr.CtrCod = Ctr_GetAndCheckParamOtherCtrCod ();

/***** Check if centre has changed *****/
if (NewCtr.CtrCod != Gbl.CurrentDeg.Deg.CtrCod)
Expand Down Expand Up @@ -2547,7 +2555,7 @@ void Deg_ChangeDegWWW (void)

/***** Get parameters from form *****/
/* Get the code of the degree */
Deg->DegCod = Deg_GetParamOtherDegCod ();
Deg->DegCod = Deg_GetAndCheckParamOtherDegCod ();

/* Get the new WWW for the degree */
Par_GetParToText ("WWW",NewWWW,Cns_MAX_LENGTH_WWW);
Expand Down Expand Up @@ -2635,7 +2643,7 @@ void Deg_ChangeDegStatus (void)

/***** Get parameters from form *****/
/* Get degree code */
Deg->DegCod = Deg_GetParamOtherDegCod ();
Deg->DegCod = Deg_GetAndCheckParamOtherDegCod ();

/* Get parameter with status */
Par_GetParToText ("Status",UnsignedNum,1);
Expand Down
Loading

0 comments on commit 931e585

Please sign in to comment.