diff --git a/swad_changelog.h b/swad_changelog.h
index ba6103014..c3e499a62 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -125,20 +125,19 @@
// TODO: Modify WS function getUsers changing: userRole to indicate all users, and a new parameter filter (search string (name, @nickname, mail)) to restring number of users
// TODO: Add a new WS function to count the nunmber of users to return in call to function getUsers
-// TODO: Search should be restricted by default to the smaller (down in hierarchy) scope
-
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
-#define Log_PLATFORM_VERSION "SWAD 15.231.1 (2016-06-24)"
+#define Log_PLATFORM_VERSION "SWAD 15.231.2 (2016-06-24)"
#define CSS_FILE "swad15.229.css"
#define JS_FILE "swad15.226.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 15.231.1: Jun 24, 2015 All users can search guests. (? lines)
+ Version 15.231.2: Jun 24, 2015 Search is restricted by default to the smaller (down in hierarchy) scope. (203475 lines)
+ Version 15.231.1: Jun 24, 2015 All users can search guests. (203429 lines)
Version 15.231: Jun 24, 2015 Speed up in search of users by using temporary tables. (203427 lines)
Version 15.230.4: Jun 23, 2015 Optimization in search of users. (203369 lines)
Version 15.230.3: Jun 23, 2015 Optimization in search of users. (203378 lines)
diff --git a/swad_layout.c b/swad_layout.c
index 4a8a9ba27..7c280967f 100644
--- a/swad_layout.c
+++ b/swad_layout.c
@@ -815,18 +815,7 @@ static void Lay_WritePageTopHeading (void)
/* End form to go to home page */
Act_FormEnd ();
- fprintf (Gbl.F.Out,"
");
- Act_FormStart ( Gbl.CurrentCrs.Crs.CrsCod > 0 ? ActCrsSch :
- (Gbl.CurrentDeg.Deg.DegCod > 0 ? ActDegSch :
- (Gbl.CurrentCtr.Ctr.CtrCod > 0 ? ActCtrSch :
- (Gbl.CurrentIns.Ins.InsCod > 0 ? ActInsSch :
- (Gbl.CurrentCty.Cty.CtyCod > 0 ? ActCtySch :
- ActSysSch)))));
- Sco_PutParamScope (Sco_SCOPE_SYS);
- Sch_PutInputStringToSearch ("head_search_text");
- Sch_PutMagnifyingGlassButton ("search-white64x64.png");
- Act_FormEnd ();
- fprintf (Gbl.F.Out,"
"); // head_row_1_search
+ Sch_PutFormToSearchInPageTopHeading ();
fprintf (Gbl.F.Out,""); // head_row_1_left
diff --git a/swad_scope.c b/swad_scope.c
index fa72fc5e9..dd282a604 100644
--- a/swad_scope.c
+++ b/swad_scope.c
@@ -191,32 +191,36 @@ void Sco_PutParamScope (Sco_Scope_t Scope)
void Sco_GetScope (void)
{
+ static bool AlreadyGotScope = false;
char UnsignedStr[10+1];
- /***** Get parameter location range if exists *****/
- Par_GetParToText ("Scope",UnsignedStr,10);
- if ((Gbl.Scope.Current = Sco_GetScopeFromUnsignedStr (UnsignedStr)) == Sco_SCOPE_UNK)
- Gbl.Scope.Current = Gbl.Scope.Default;
+ if (!AlreadyGotScope)
+ {
+ /***** Get parameter location range if exists *****/
+ Par_GetParToText ("Scope",UnsignedStr,10);
+ if ((Gbl.Scope.Current = Sco_GetScopeFromUnsignedStr (UnsignedStr)) == Sco_SCOPE_UNK)
+ Gbl.Scope.Current = Gbl.Scope.Default;
- /***** Avoid impossible scopes *****/
- if (Gbl.Scope.Current == Sco_SCOPE_CRS && Gbl.CurrentCrs.Crs.CrsCod <= 0)
- Gbl.Scope.Current = Sco_SCOPE_DEG;
+ /***** Avoid impossible scopes *****/
+ if (Gbl.Scope.Current == Sco_SCOPE_CRS && Gbl.CurrentCrs.Crs.CrsCod <= 0)
+ Gbl.Scope.Current = Sco_SCOPE_DEG;
- if (Gbl.Scope.Current == Sco_SCOPE_DEG && Gbl.CurrentDeg.Deg.DegCod <= 0)
- Gbl.Scope.Current = Sco_SCOPE_CTR;
+ if (Gbl.Scope.Current == Sco_SCOPE_DEG && Gbl.CurrentDeg.Deg.DegCod <= 0)
+ Gbl.Scope.Current = Sco_SCOPE_CTR;
- if (Gbl.Scope.Current == Sco_SCOPE_CTR && Gbl.CurrentCtr.Ctr.CtrCod <= 0)
- Gbl.Scope.Current = Sco_SCOPE_INS;
+ if (Gbl.Scope.Current == Sco_SCOPE_CTR && Gbl.CurrentCtr.Ctr.CtrCod <= 0)
+ Gbl.Scope.Current = Sco_SCOPE_INS;
- if (Gbl.Scope.Current == Sco_SCOPE_INS && Gbl.CurrentIns.Ins.InsCod <= 0)
- Gbl.Scope.Current = Sco_SCOPE_CTY;
+ if (Gbl.Scope.Current == Sco_SCOPE_INS && Gbl.CurrentIns.Ins.InsCod <= 0)
+ Gbl.Scope.Current = Sco_SCOPE_CTY;
- if (Gbl.Scope.Current == Sco_SCOPE_CTY && Gbl.CurrentCty.Cty.CtyCod <= 0)
- Gbl.Scope.Current = Sco_SCOPE_SYS;
+ if (Gbl.Scope.Current == Sco_SCOPE_CTY && Gbl.CurrentCty.Cty.CtyCod <= 0)
+ Gbl.Scope.Current = Sco_SCOPE_SYS;
- /***** Avoid forbidden scopes *****/
- if ((Gbl.Scope.Allowed & (1 << Gbl.Scope.Current)) == 0)
- Gbl.Scope.Current = Sco_SCOPE_UNK;
+ /***** Avoid forbidden scopes *****/
+ if ((Gbl.Scope.Allowed & (1 << Gbl.Scope.Current)) == 0)
+ Gbl.Scope.Current = Sco_SCOPE_UNK;
+ }
}
/*****************************************************************************/
diff --git a/swad_search.c b/swad_search.c
index d12781a72..20518d560 100644
--- a/swad_search.c
+++ b/swad_search.c
@@ -235,7 +235,8 @@ static void Sch_PutFormToSearchWithWhatToSearchAndScope (Act_Action_t Action,Sco
Act_FormStart (Action);
Lay_StartRoundFrame (NULL,Txt_Search,NULL);
- /***** Scope (whole platform, current centre, current degree or current course) *****/
+ /***** Scope (whole platform, current country, current institution,
+ current centre, current degree or current course) *****/
fprintf (Gbl.F.Out,""
"
%s: ",
The_ClassForm[Gbl.Prefs.Theme],Txt_Scope);
@@ -306,6 +307,60 @@ static bool Sch_CheckIfIHavePermissionToSearch (Sch_WhatToSearch_t WhatToSearch)
return (Permissions[WhatToSearch] & (1 << Gbl.Usrs.Me.LoggedRole));
}
+/*****************************************************************************/
+/**************** Put a form to search in page top heading *******************/
+/*****************************************************************************/
+
+void Sch_PutFormToSearchInPageTopHeading (void)
+ {
+ Act_Action_t ActionSearch;
+
+ fprintf (Gbl.F.Out,"
");
+ Gbl.Scope.Allowed = 1 << Sco_SCOPE_SYS |
+ 1 << Sco_SCOPE_CTY |
+ 1 << Sco_SCOPE_INS |
+ 1 << Sco_SCOPE_CTR |
+ 1 << Sco_SCOPE_DEG |
+ 1 << Sco_SCOPE_CRS;
+ if (Gbl.CurrentCrs.Crs.CrsCod > 0)
+ {
+ ActionSearch = ActCrsSch;
+ Gbl.Scope.Default = Sco_SCOPE_CRS;
+ }
+ else if (Gbl.CurrentDeg.Deg.DegCod > 0)
+ {
+ ActionSearch = ActDegSch;
+ Gbl.Scope.Default = Sco_SCOPE_DEG;
+ }
+ else if (Gbl.CurrentCtr.Ctr.CtrCod > 0)
+ {
+ ActionSearch = ActCtrSch;
+ Gbl.Scope.Default = Sco_SCOPE_CTR;
+ }
+ else if (Gbl.CurrentIns.Ins.InsCod > 0)
+ {
+ ActionSearch = ActInsSch;
+ Gbl.Scope.Default = Sco_SCOPE_INS;
+ }
+ else if (Gbl.CurrentCty.Cty.CtyCod > 0)
+ {
+ ActionSearch = ActCtySch;
+ Gbl.Scope.Default = Sco_SCOPE_CTY;
+ }
+ else
+ {
+ ActionSearch = ActSysSch;
+ Gbl.Scope.Default = Sco_SCOPE_SYS;
+ }
+ Act_FormStart (ActionSearch);
+ Sco_GetScope ();
+ Sco_PutParamScope (Gbl.Scope.Current);
+ Sch_PutInputStringToSearch ("head_search_text");
+ Sch_PutMagnifyingGlassButton ("search-white64x64.png");
+ Act_FormEnd ();
+ fprintf (Gbl.F.Out,"
"); // head_row_1_search
+ }
+
/*****************************************************************************/
/********************* Put string to search inside form **********************/
/*****************************************************************************/
diff --git a/swad_search.h b/swad_search.h
index 3dd99d2da..0e4dea348 100644
--- a/swad_search.h
+++ b/swad_search.h
@@ -63,6 +63,9 @@ void Sch_ReqInsSearch (void);
void Sch_ReqCtrSearch (void);
void Sch_ReqDegSearch (void);
void Sch_ReqCrsSearch (void);
+
+void Sch_PutFormToSearchInPageTopHeading (void);
+
void Sch_PutInputStringToSearch (const char *IdInputText);
void Sch_PutMagnifyingGlassButton (const char *Icon);
void Sch_GetParamWhatToSearch (void);