mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-16 13:44:06 +02:00
Version 15.243
This commit is contained in:
parent
438d952b5d
commit
1c8dfbd2ed
|
@ -702,16 +702,6 @@
|
||||||
<code>DirectoryIndex index.html index.htm index.php</code><br />
|
<code>DirectoryIndex index.html index.htm index.php</code><br />
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
|
||||||
Optionally, if we want to redirect from http://... to https://...
|
|
||||||
we should add the following lines at the end of the
|
|
||||||
<code>Section 3: Virtual Hosts</code>:<br />
|
|
||||||
<code><VirtualHost _default_:*><br />
|
|
||||||
Redirect permanent / https://openswad.org/<br />
|
|
||||||
</VirtualHost></code><br />
|
|
||||||
(replace https://openswad.org/ by our https address).
|
|
||||||
</li>
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
<td width="50%" valign="top">
|
<td width="50%" valign="top">
|
||||||
|
@ -851,6 +841,40 @@
|
||||||
</table>
|
</table>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Optionally, if we want to redirect from http://... to https://...
|
||||||
|
we should add some lines to configuration files:
|
||||||
|
|
||||||
|
<table width="100%">
|
||||||
|
<tr>
|
||||||
|
<th>CentOS 6.5</th>
|
||||||
|
<th>Ubuntu 14.04</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td width="50%" valign="top">
|
||||||
|
Edit the file <code>/etc/httpd/conf/httpd.conf</code>,
|
||||||
|
add the following lines at the end of the
|
||||||
|
<code>Section 3: Virtual Hosts</code> section:<br />
|
||||||
|
<code><VirtualHost _default_:*><br />
|
||||||
|
Redirect permanent / https://openswad.org/<br />
|
||||||
|
</VirtualHost></code><br />
|
||||||
|
(replace https://openswad.org/ by your https address),
|
||||||
|
and save it.
|
||||||
|
</td>
|
||||||
|
<td width="50%" valign="top">
|
||||||
|
Edit the file <code>/etc/apache2/sites-available/000-default.conf</code>,
|
||||||
|
add the following line into the
|
||||||
|
<code><VirtualHost *:80></code> section:<br />
|
||||||
|
<code>Redirect permanent / https://openswad.org/</code><br />
|
||||||
|
(replace https://openswad.org/ by your https address),
|
||||||
|
and save it.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Restart the Apache web server with the changes just made:
|
Restart the Apache web server with the changes just made:
|
||||||
<table width="100%">
|
<table width="100%">
|
||||||
|
|
|
@ -138,13 +138,15 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 15.242.6 (2016-07-15)"
|
#define Log_PLATFORM_VERSION "SWAD 15.243 (2016-07-20)"
|
||||||
#define CSS_FILE "swad15.229.css"
|
#define CSS_FILE "swad15.229.css"
|
||||||
#define JS_FILE "swad15.238.1.js"
|
#define JS_FILE "swad15.238.1.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.243: Jul 20, 2016 Fixed bug in web service (getNotifications).
|
||||||
|
Code refactoring in web service. (203956 lines)
|
||||||
Version 15.242.6: Jul 15, 2016 Fixed bug in creation of database table tst_config. (203850 lines)
|
Version 15.242.6: Jul 15, 2016 Fixed bug in creation of database table tst_config. (203850 lines)
|
||||||
Version 15.242.5: Jul 15, 2016 Fixed bug in user's registration. (203849 lines)
|
Version 15.242.5: Jul 15, 2016 Fixed bug in user's registration. (203849 lines)
|
||||||
Version 15.242.4: Jul 15, 2016 Fixed bug in creation of database table file_browser_size. (203847 lines)
|
Version 15.242.4: Jul 15, 2016 Fixed bug in creation of database table file_browser_size. (203847 lines)
|
||||||
|
|
|
@ -28,10 +28,10 @@
|
||||||
/** Uncomment one of the following installations of SWAD or create your own **/
|
/** Uncomment one of the following installations of SWAD or create your own **/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
//#define LOCALHOST_UBUNTU // Comment this line if not applicable
|
#define LOCALHOST_UBUNTU // Comment this line if not applicable
|
||||||
//#define OPENSWAD_ORG // Comment this line if not applicable
|
//#define OPENSWAD_ORG // Comment this line if not applicable
|
||||||
//#define SWAD_UGR_ES // Comment this line if not applicable
|
//#define SWAD_UGR_ES // Comment this line if not applicable
|
||||||
#define SWADBERRY_UGR_ES // Comment this line if not applicable
|
//#define SWADBERRY_UGR_ES // Comment this line if not applicable
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/********************************* Headers ***********************************/
|
/********************************* Headers ***********************************/
|
||||||
|
|
|
@ -623,8 +623,9 @@ static bool Tst_CheckIfNextTstAllowed (void)
|
||||||
long NumSecondsFromNowToNextAccTst = -1L; // Access allowed when this number <= 0
|
long NumSecondsFromNowToNextAccTst = -1L; // Access allowed when this number <= 0
|
||||||
time_t TimeNextTestUTC = (time_t) 0;
|
time_t TimeNextTestUTC = (time_t) 0;
|
||||||
|
|
||||||
/***** Superusers are allowed to do all tests they want *****/
|
/***** Teachers and superusers are allowed to do all tests they want *****/
|
||||||
if (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
|
if (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER ||
|
||||||
|
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/***** Get date of next allowed access to test from database *****/
|
/***** Get date of next allowed access to test from database *****/
|
||||||
|
|
|
@ -206,7 +206,7 @@ static int Svc_CheckCourseAndGroupCodes (long CrsCod,long GrpCod);
|
||||||
static int Svc_GenerateNewWSKey (long UsrCod,char *WSKey);
|
static int Svc_GenerateNewWSKey (long UsrCod,char *WSKey);
|
||||||
static int Svc_RemoveOldWSKeys (void);
|
static int Svc_RemoveOldWSKeys (void);
|
||||||
static int Svc_GetCurrentDegCodFromCurrentCrsCod (void);
|
static int Svc_GetCurrentDegCodFromCurrentCrsCod (void);
|
||||||
static int Svc_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod);
|
static bool Svc_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod);
|
||||||
|
|
||||||
static int Svc_CheckParamsNewAccount (char *NewNicknameWithArroba, // Input
|
static int Svc_CheckParamsNewAccount (char *NewNicknameWithArroba, // Input
|
||||||
char *NewNicknameWithoutArroba, // Output
|
char *NewNicknameWithoutArroba, // Output
|
||||||
|
@ -552,14 +552,18 @@ static int Svc_GetCurrentDegCodFromCurrentCrsCod (void)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************ Get user's data from database giving a user's code *************/
|
/************ Get user's data from database giving a user's code *************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// UsrDat->UsrCod must contain an existing user's code
|
// Return false if UsrDat->UsrCod does not exist ini database
|
||||||
|
|
||||||
static int Svc_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod)
|
static bool Svc_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod)
|
||||||
{
|
{
|
||||||
char Query[512];
|
char Query[512];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
|
/***** Check if user's code is valid *****/
|
||||||
|
if (UsrDat->UsrCod <= 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
/***** Get some user's data *****/
|
/***** Get some user's data *****/
|
||||||
/* Query database */
|
/* Query database */
|
||||||
sprintf (Query,"SELECT Surname1,Surname2,FirstName,Photo,DATE_FORMAT(Birthday,'%%Y%%m%%d')"
|
sprintf (Query,"SELECT Surname1,Surname2,FirstName,Photo,DATE_FORMAT(Birthday,'%%Y%%m%%d')"
|
||||||
|
@ -568,20 +572,17 @@ static int Svc_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod)
|
||||||
|
|
||||||
/* Check number of rows in result */
|
/* Check number of rows in result */
|
||||||
if (DB_QuerySELECT (Query,&mysql_res,"can not get user's data") != 1)
|
if (DB_QuerySELECT (Query,&mysql_res,"can not get user's data") != 1)
|
||||||
return soap_receiver_fault (Gbl.soap,
|
return false;
|
||||||
"Can not get user's data from database",
|
|
||||||
"User does not exist in database");
|
|
||||||
|
|
||||||
/* Read some user's data */
|
/* Read some user's data */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get user's name */
|
/* Get user's name */
|
||||||
strncpy (UsrDat->Surname1 ,row[0],sizeof (UsrDat->Surname1 )-1);
|
strncpy (UsrDat->Surname1 ,row[0],sizeof (UsrDat->Surname1 )-1);
|
||||||
strncpy (UsrDat->Surname2 ,row[1],sizeof (UsrDat->Surname2 )-1);
|
|
||||||
strncpy (UsrDat->FirstName,row[2],sizeof (UsrDat->FirstName)-1);
|
|
||||||
|
|
||||||
UsrDat->Surname1 [sizeof (UsrDat->Surname1 )-1] = '\0';
|
UsrDat->Surname1 [sizeof (UsrDat->Surname1 )-1] = '\0';
|
||||||
|
strncpy (UsrDat->Surname2 ,row[1],sizeof (UsrDat->Surname2 )-1);
|
||||||
UsrDat->Surname2 [sizeof (UsrDat->Surname2 )-1] = '\0';
|
UsrDat->Surname2 [sizeof (UsrDat->Surname2 )-1] = '\0';
|
||||||
|
strncpy (UsrDat->FirstName,row[2],sizeof (UsrDat->FirstName)-1);
|
||||||
UsrDat->FirstName[sizeof (UsrDat->FirstName)-1] = '\0';
|
UsrDat->FirstName[sizeof (UsrDat->FirstName)-1] = '\0';
|
||||||
|
|
||||||
/* Get user's photo */
|
/* Get user's photo */
|
||||||
|
@ -609,27 +610,51 @@ static int Svc_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod)
|
||||||
/***** Get user's role *****/
|
/***** Get user's role *****/
|
||||||
/* Query database */
|
/* Query database */
|
||||||
if (CrsCod > 0)
|
if (CrsCod > 0)
|
||||||
|
{
|
||||||
|
/* Get the role in the given course */
|
||||||
sprintf (Query,"SELECT Role FROM crs_usr"
|
sprintf (Query,"SELECT Role FROM crs_usr"
|
||||||
" WHERE CrsCod='%ld' AND UsrCod='%ld'",
|
" WHERE CrsCod='%ld' AND UsrCod='%ld'",
|
||||||
CrsCod,UsrDat->UsrCod);
|
CrsCod,UsrDat->UsrCod);
|
||||||
|
if (DB_QuerySELECT (Query,&mysql_res,"can not get user's role")) // User belongs to course
|
||||||
|
{
|
||||||
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
if (row[0])
|
||||||
|
{
|
||||||
|
if (sscanf (row[0],"%u",&UsrDat->RoleInCurrentCrsDB) != 1)
|
||||||
|
UsrDat->RoleInCurrentCrsDB = Rol_UNKNOWN;
|
||||||
|
}
|
||||||
|
else // Impossible
|
||||||
|
UsrDat->RoleInCurrentCrsDB = Rol_UNKNOWN;
|
||||||
|
}
|
||||||
|
else // User does not belong to course
|
||||||
|
UsrDat->RoleInCurrentCrsDB = Rol_VISITOR;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
/* Get the maximum role in any course */
|
||||||
sprintf (Query,"SELECT MAX(Role)"
|
sprintf (Query,"SELECT MAX(Role)"
|
||||||
" FROM crs_usr WHERE UsrCod='%ld'",
|
" FROM crs_usr WHERE UsrCod='%ld'",
|
||||||
UsrDat->UsrCod);
|
UsrDat->UsrCod);
|
||||||
if (DB_QuerySELECT (Query,&mysql_res,"can not get user's role") == 1)
|
if (DB_QuerySELECT (Query,&mysql_res,"can not get user's role") == 1)
|
||||||
{
|
{
|
||||||
/* Read the maximum role */
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
if (row[0])
|
||||||
|
{
|
||||||
if (sscanf (row[0],"%u",&UsrDat->RoleInCurrentCrsDB) != 1)
|
if (sscanf (row[0],"%u",&UsrDat->RoleInCurrentCrsDB) != 1)
|
||||||
UsrDat->RoleInCurrentCrsDB = Rol_UNKNOWN;
|
UsrDat->RoleInCurrentCrsDB = Rol_UNKNOWN;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
// MAX(Role) == NULL if user does not belong to any course
|
||||||
UsrDat->RoleInCurrentCrsDB = Rol__GUEST_;
|
UsrDat->RoleInCurrentCrsDB = Rol__GUEST_;
|
||||||
|
}
|
||||||
|
else // Impossible
|
||||||
|
UsrDat->RoleInCurrentCrsDB = Rol__GUEST_;
|
||||||
|
}
|
||||||
|
|
||||||
/* Free structure that stores the query result */
|
/* Free structure that stores the query result */
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
return SOAP_OK;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -652,6 +677,7 @@ int swad__createAccount (struct soap *soap,
|
||||||
int Result;
|
int Result;
|
||||||
int ReturnCode;
|
int ReturnCode;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_createAccount;
|
Gbl.WebService.Function = Svc_createAccount;
|
||||||
|
|
||||||
|
@ -775,7 +801,9 @@ int swad__loginByUserPasswordKey (struct soap *soap,
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumRows;
|
unsigned NumRows;
|
||||||
char PhotoURL[PATH_MAX+1];
|
char PhotoURL[PATH_MAX+1];
|
||||||
|
bool UsrFound;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_loginByUserPasswordKey;
|
Gbl.WebService.Function = Svc_loginByUserPasswordKey;
|
||||||
|
|
||||||
|
@ -853,14 +881,23 @@ int swad__loginByUserPasswordKey (struct soap *soap,
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Get user's data from database *****/
|
/***** Get user's data from database *****/
|
||||||
if ((NumRows = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get user's data"))) // User found in table of users' data
|
if ((NumRows = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get user's data")) == 1) // User found in table of users' data
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/***** Get user code (row[0]) *****/
|
/***** Get user code (row[0]) *****/
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
Gbl.Usrs.Me.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
|
|
||||||
if (Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,-1L) == SOAP_OK) // Get some user's data from database
|
/***** Get user's data *****/
|
||||||
|
UsrFound = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,-1L); // Get some user's data from database
|
||||||
|
}
|
||||||
|
else
|
||||||
|
UsrFound = false;
|
||||||
|
|
||||||
|
/***** Free structure that stores the query result *****/
|
||||||
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
|
if (UsrFound)
|
||||||
{
|
{
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
@ -888,6 +925,10 @@ int swad__loginByUserPasswordKey (struct soap *soap,
|
||||||
loginByUserPasswordKeyOut->userBirthday[4+2+2] = '\0';
|
loginByUserPasswordKeyOut->userBirthday[4+2+2] = '\0';
|
||||||
|
|
||||||
loginByUserPasswordKeyOut->userRole = Svc_RolRole_to_SvcRole[Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB];
|
loginByUserPasswordKeyOut->userRole = Svc_RolRole_to_SvcRole[Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB];
|
||||||
|
|
||||||
|
/***** Generate a key used in subsequents calls to other web services *****/
|
||||||
|
return Svc_GenerateNewWSKey ((long) loginByUserPasswordKeyOut->userCode,
|
||||||
|
loginByUserPasswordKeyOut->wsKey);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -898,21 +939,12 @@ int swad__loginByUserPasswordKey (struct soap *soap,
|
||||||
loginByUserPasswordKeyOut->userFirstname = NULL;
|
loginByUserPasswordKeyOut->userFirstname = NULL;
|
||||||
loginByUserPasswordKeyOut->userPhoto = NULL;
|
loginByUserPasswordKeyOut->userPhoto = NULL;
|
||||||
loginByUserPasswordKeyOut->userRole = 0;
|
loginByUserPasswordKeyOut->userRole = 0;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
|
|
||||||
if (NumRows == 1)
|
|
||||||
/***** Generate a key used in subsequents calls to other web services *****/
|
|
||||||
return Svc_GenerateNewWSKey ((long) loginByUserPasswordKeyOut->userCode,
|
|
||||||
loginByUserPasswordKeyOut->wsKey);
|
|
||||||
else
|
|
||||||
return soap_receiver_fault (Gbl.soap,
|
return soap_receiver_fault (Gbl.soap,
|
||||||
"Bad log in",
|
"Bad log in",
|
||||||
"User's ID or nickname don't exist or password is wrong");
|
"User's ID or nickname don't exist or password is wrong");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************************** Login user by session ****************************/
|
/************************** Login user by session ****************************/
|
||||||
|
@ -928,7 +960,9 @@ int swad__loginBySessionKey (struct soap *soap,
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumRows;
|
unsigned NumRows;
|
||||||
char PhotoURL[PATH_MAX+1];
|
char PhotoURL[PATH_MAX+1];
|
||||||
|
bool UsrFound;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_loginBySessionKey;
|
Gbl.WebService.Function = Svc_loginBySessionKey;
|
||||||
|
|
||||||
|
@ -982,7 +1016,7 @@ int swad__loginBySessionKey (struct soap *soap,
|
||||||
/***** Query data of the session from database *****/
|
/***** Query data of the session from database *****/
|
||||||
sprintf (Query,"SELECT UsrCod,DegCod,CrsCod FROM sessions"
|
sprintf (Query,"SELECT UsrCod,DegCod,CrsCod FROM sessions"
|
||||||
" WHERE SessionId='%s'",sessionID);
|
" WHERE SessionId='%s'",sessionID);
|
||||||
if ((NumRows = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get session data"))) // Session found in table of sessions
|
if ((NumRows = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get session data")) == 1) // Session found in table of sessions
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
|
@ -995,7 +1029,26 @@ int swad__loginBySessionKey (struct soap *soap,
|
||||||
|
|
||||||
/***** Get user code (row[0]) *****/
|
/***** Get user code (row[0]) *****/
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
Gbl.Usrs.Me.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
if (Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod) == SOAP_OK) // Get some user's data from database
|
UsrFound = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod); // Get some user's data from database
|
||||||
|
|
||||||
|
/***** Get degree (row[1]) *****/
|
||||||
|
Gbl.CurrentDeg.Deg.DegCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||||
|
Deg_GetDataOfDegreeByCod (&Gbl.CurrentDeg.Deg);
|
||||||
|
loginBySessionKeyOut->degreeCode = (int) Gbl.CurrentDeg.Deg.DegCod;
|
||||||
|
strncpy (loginBySessionKeyOut->degreeName,Gbl.CurrentDeg.Deg.FullName,255);
|
||||||
|
loginBySessionKeyOut->degreeName[255] = '\0';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
UsrFound = false;
|
||||||
|
|
||||||
|
/***** Free structure that stores the query result *****/
|
||||||
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
|
/***** Get degree of current course *****/
|
||||||
|
if ((ReturnCode = Svc_GetCurrentDegCodFromCurrentCrsCod ()) != SOAP_OK)
|
||||||
|
return ReturnCode;
|
||||||
|
|
||||||
|
if (UsrFound)
|
||||||
{
|
{
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
@ -1023,6 +1076,10 @@ int swad__loginBySessionKey (struct soap *soap,
|
||||||
loginBySessionKeyOut->userBirthday[4+2+2] = '\0';
|
loginBySessionKeyOut->userBirthday[4+2+2] = '\0';
|
||||||
|
|
||||||
loginBySessionKeyOut->userRole = Svc_RolRole_to_SvcRole[Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB];
|
loginBySessionKeyOut->userRole = Svc_RolRole_to_SvcRole[Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB];
|
||||||
|
|
||||||
|
/***** Generate a key used in subsequents calls to other web services *****/
|
||||||
|
return Svc_GenerateNewWSKey ((long) loginBySessionKeyOut->userCode,
|
||||||
|
loginBySessionKeyOut->wsKey);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1033,32 +1090,12 @@ int swad__loginBySessionKey (struct soap *soap,
|
||||||
loginBySessionKeyOut->userFirstname = NULL;
|
loginBySessionKeyOut->userFirstname = NULL;
|
||||||
loginBySessionKeyOut->userPhoto = NULL;
|
loginBySessionKeyOut->userPhoto = NULL;
|
||||||
loginBySessionKeyOut->userRole = 0;
|
loginBySessionKeyOut->userRole = 0;
|
||||||
}
|
|
||||||
|
|
||||||
/***** Get degree (row[1]) *****/
|
|
||||||
Gbl.CurrentDeg.Deg.DegCod = Str_ConvertStrCodToLongCod (row[1]);
|
|
||||||
Deg_GetDataOfDegreeByCod (&Gbl.CurrentDeg.Deg);
|
|
||||||
loginBySessionKeyOut->degreeCode = (int) Gbl.CurrentDeg.Deg.DegCod;
|
|
||||||
strncpy (loginBySessionKeyOut->degreeName,Gbl.CurrentDeg.Deg.FullName,255);
|
|
||||||
loginBySessionKeyOut->degreeName[255] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
|
|
||||||
/***** Get degree of current course *****/
|
|
||||||
if ((ReturnCode = Svc_GetCurrentDegCodFromCurrentCrsCod ()) != SOAP_OK)
|
|
||||||
return ReturnCode;
|
|
||||||
|
|
||||||
if (NumRows == 1)
|
|
||||||
/***** Generate a key used in subsequents calls to other web services *****/
|
|
||||||
return Svc_GenerateNewWSKey ((long) loginBySessionKeyOut->userCode,
|
|
||||||
loginBySessionKeyOut->wsKey);
|
|
||||||
else
|
|
||||||
return soap_receiver_fault (Gbl.soap,
|
return soap_receiver_fault (Gbl.soap,
|
||||||
"Bad session identifier",
|
"Bad session identifier",
|
||||||
"Session identifier does not exist in database");
|
"Session identifier does not exist in database");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*********************** Send a new password by e-mail ***********************/
|
/*********************** Send a new password by e-mail ***********************/
|
||||||
|
@ -1076,6 +1113,7 @@ int swad__getNewPassword (struct soap *soap,
|
||||||
unsigned NumRows;
|
unsigned NumRows;
|
||||||
char NewRandomPlainPassword[Pwd_MAX_LENGTH_PLAIN_PASSWORD+1];
|
char NewRandomPlainPassword[Pwd_MAX_LENGTH_PLAIN_PASSWORD+1];
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_getNewPassword;
|
Gbl.WebService.Function = Svc_getNewPassword;
|
||||||
|
|
||||||
|
@ -1167,6 +1205,7 @@ int swad__getCourses (struct soap *soap,
|
||||||
unsigned NumRow,NumRows;
|
unsigned NumRow,NumRows;
|
||||||
Rol_Role_t Role;
|
Rol_Role_t Role;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_getCourses;
|
Gbl.WebService.Function = Svc_getCourses;
|
||||||
|
|
||||||
|
@ -1179,8 +1218,10 @@ int swad__getCourses (struct soap *soap,
|
||||||
"Web service key does not exist in database");
|
"Web service key does not exist in database");
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,-1L)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,-1L))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -1268,6 +1309,7 @@ int swad__getCourseInfo (struct soap *soap,
|
||||||
"URL", // Inf_INFO_SRC_URL
|
"URL", // Inf_INFO_SRC_URL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_getCourseInfo;
|
Gbl.WebService.Function = Svc_getCourseInfo;
|
||||||
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
||||||
|
@ -1285,8 +1327,10 @@ int swad__getCourseInfo (struct soap *soap,
|
||||||
return ReturnCode;
|
return ReturnCode;
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -1366,6 +1410,7 @@ int swad__getUsers (struct soap *soap,
|
||||||
int ReturnCode;
|
int ReturnCode;
|
||||||
Rol_Role_t Role;
|
Rol_Role_t Role;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_getUsers;
|
Gbl.WebService.Function = Svc_getUsers;
|
||||||
Gbl.CurrentCrs.Crs.CrsCod = (courseCode > 0) ? (long) courseCode :
|
Gbl.CurrentCrs.Crs.CrsCod = (courseCode > 0) ? (long) courseCode :
|
||||||
|
@ -1384,8 +1429,10 @@ int swad__getUsers (struct soap *soap,
|
||||||
return ReturnCode;
|
return ReturnCode;
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -1440,6 +1487,7 @@ int swad__findUsers (struct soap *soap,
|
||||||
Rol_Role_t Role;
|
Rol_Role_t Role;
|
||||||
bool FilterTooShort = false;
|
bool FilterTooShort = false;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_findUsers;
|
Gbl.WebService.Function = Svc_findUsers;
|
||||||
Gbl.CurrentCrs.Crs.CrsCod = (courseCode > 0) ? (long) courseCode :
|
Gbl.CurrentCrs.Crs.CrsCod = (courseCode > 0) ? (long) courseCode :
|
||||||
|
@ -1459,8 +1507,10 @@ int swad__findUsers (struct soap *soap,
|
||||||
return ReturnCode;
|
return ReturnCode;
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -1596,6 +1646,7 @@ int swad__getGroupTypes (struct soap *soap,
|
||||||
unsigned NumRow,NumRows;
|
unsigned NumRow,NumRows;
|
||||||
long OpenTime;
|
long OpenTime;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_getGroupTypes;
|
Gbl.WebService.Function = Svc_getGroupTypes;
|
||||||
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
||||||
|
@ -1619,8 +1670,10 @@ int swad__getGroupTypes (struct soap *soap,
|
||||||
"Course code must be a integer greater than 0");
|
"Course code must be a integer greater than 0");
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -1701,6 +1754,7 @@ int swad__getGroups (struct soap *soap,
|
||||||
long GrpCod;
|
long GrpCod;
|
||||||
unsigned MaxStudents;
|
unsigned MaxStudents;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_getGroups;
|
Gbl.WebService.Function = Svc_getGroups;
|
||||||
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
||||||
|
@ -1724,8 +1778,10 @@ int swad__getGroups (struct soap *soap,
|
||||||
"Course code must be a integer greater than 0");
|
"Course code must be a integer greater than 0");
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -1828,6 +1884,7 @@ int swad__sendMyGroups (struct soap *soap,
|
||||||
long GrpCod;
|
long GrpCod;
|
||||||
unsigned MaxStudents;
|
unsigned MaxStudents;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_sendMyGroups;
|
Gbl.WebService.Function = Svc_sendMyGroups;
|
||||||
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
||||||
|
@ -1847,8 +1904,10 @@ int swad__sendMyGroups (struct soap *soap,
|
||||||
"Course code must be a integer greater than 0");
|
"Course code must be a integer greater than 0");
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -2033,6 +2092,7 @@ int swad__getAttendanceEvents (struct soap *soap,
|
||||||
long EndTime;
|
long EndTime;
|
||||||
size_t Length;
|
size_t Length;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_getAttendanceEvents;
|
Gbl.WebService.Function = Svc_getAttendanceEvents;
|
||||||
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
||||||
|
@ -2052,8 +2112,10 @@ int swad__getAttendanceEvents (struct soap *soap,
|
||||||
"Course code must be a integer greater than 0");
|
"Course code must be a integer greater than 0");
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -2093,7 +2155,7 @@ int swad__getAttendanceEvents (struct soap *soap,
|
||||||
|
|
||||||
/* Get user's code of the user who created the event (row[1]) */
|
/* Get user's code of the user who created the event (row[1]) */
|
||||||
Gbl.Usrs.Other.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[1]);
|
Gbl.Usrs.Other.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||||
if (Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Gbl.CurrentCrs.Crs.CrsCod) == SOAP_OK) // Get some user's data from database
|
if (Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) // Get some user's data from database
|
||||||
{
|
{
|
||||||
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname1);
|
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname1);
|
||||||
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname1 = (char *) soap_malloc (Gbl.soap,Length + 1);
|
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname1 = (char *) soap_malloc (Gbl.soap,Length + 1);
|
||||||
|
@ -2221,6 +2283,7 @@ int swad__sendAttendanceEvent (struct soap *soap,
|
||||||
struct AttendanceEvent Att;
|
struct AttendanceEvent Att;
|
||||||
bool ItsANewAttEvent;
|
bool ItsANewAttEvent;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_sendAttendanceEvent;
|
Gbl.WebService.Function = Svc_sendAttendanceEvent;
|
||||||
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
||||||
|
@ -2240,8 +2303,10 @@ int swad__sendAttendanceEvent (struct soap *soap,
|
||||||
"Course code must be a integer greater than 0");
|
"Course code must be a integer greater than 0");
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -2366,6 +2431,7 @@ int swad__getAttendanceUsers (struct soap *soap,
|
||||||
char PhotoURL[PATH_MAX+1];
|
char PhotoURL[PATH_MAX+1];
|
||||||
size_t Length;
|
size_t Length;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_getAttendanceUsers;
|
Gbl.WebService.Function = Svc_getAttendanceUsers;
|
||||||
|
|
||||||
|
@ -2383,8 +2449,10 @@ int swad__getAttendanceUsers (struct soap *soap,
|
||||||
Gbl.CurrentCrs.Crs.CrsCod = Att.CrsCod;
|
Gbl.CurrentCrs.Crs.CrsCod = Att.CrsCod;
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -2458,7 +2526,7 @@ int swad__getAttendanceUsers (struct soap *soap,
|
||||||
getAttendanceUsersOut->usersArray.__ptr[NumRow].userCode = (int) Gbl.Usrs.Other.UsrDat.UsrCod;
|
getAttendanceUsersOut->usersArray.__ptr[NumRow].userCode = (int) Gbl.Usrs.Other.UsrDat.UsrCod;
|
||||||
|
|
||||||
/* Get user's data */
|
/* Get user's data */
|
||||||
if (Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,-1L) == SOAP_OK) // Get some user's data from database
|
if (Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,-1L)) // Get some user's data from database
|
||||||
{
|
{
|
||||||
Length = strlen (Gbl.Usrs.Other.UsrDat.Nickname);
|
Length = strlen (Gbl.Usrs.Other.UsrDat.Nickname);
|
||||||
getAttendanceUsersOut->usersArray.__ptr[NumRow].userNickname = (char *) soap_malloc (Gbl.soap,Length + 1);
|
getAttendanceUsersOut->usersArray.__ptr[NumRow].userNickname = (char *) soap_malloc (Gbl.soap,Length + 1);
|
||||||
|
@ -2525,6 +2593,7 @@ int swad__sendAttendanceUsers (struct soap *soap,
|
||||||
char SubQuery[256];
|
char SubQuery[256];
|
||||||
char *Query = NULL; // Initialized to avoid warning
|
char *Query = NULL; // Initialized to avoid warning
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_sendAttendanceUsers;
|
Gbl.WebService.Function = Svc_sendAttendanceUsers;
|
||||||
|
|
||||||
|
@ -2547,8 +2616,10 @@ int swad__sendAttendanceUsers (struct soap *soap,
|
||||||
Gbl.CurrentCrs.Crs.CrsCod = Att.CrsCod;
|
Gbl.CurrentCrs.Crs.CrsCod = Att.CrsCod;
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -2643,8 +2714,8 @@ int swad__getNotifications (struct soap *soap,
|
||||||
char Query[512];
|
char Query[512];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumRows;
|
unsigned NumNotifications;
|
||||||
unsigned NumRow;
|
unsigned NumNotif;
|
||||||
long NtfCod;
|
long NtfCod;
|
||||||
Ntf_NotifyEvent_t NotifyEvent;
|
Ntf_NotifyEvent_t NotifyEvent;
|
||||||
long EventTime;
|
long EventTime;
|
||||||
|
@ -2659,6 +2730,7 @@ int swad__getNotifications (struct soap *soap,
|
||||||
char *ContentStr;
|
char *ContentStr;
|
||||||
Ntf_Status_t Status;
|
Ntf_Status_t Status;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_getNotifications;
|
Gbl.WebService.Function = Svc_getNotifications;
|
||||||
|
|
||||||
|
@ -2671,8 +2743,10 @@ int swad__getNotifications (struct soap *soap,
|
||||||
"Web service key does not exist in database");
|
"Web service key does not exist in database");
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,-1L)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,-1L))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -2680,11 +2754,6 @@ int swad__getNotifications (struct soap *soap,
|
||||||
if ((ReturnCode = Svc_GetMyLanguage ()) != SOAP_OK)
|
if ((ReturnCode = Svc_GetMyLanguage ()) != SOAP_OK)
|
||||||
return ReturnCode;
|
return ReturnCode;
|
||||||
|
|
||||||
if ((SummaryStr = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL)
|
|
||||||
return soap_receiver_fault (Gbl.soap,
|
|
||||||
"Not enough memory",
|
|
||||||
"Not enough memory to store the summary of the notification");
|
|
||||||
|
|
||||||
/***** Get my notifications from database *****/
|
/***** Get my notifications from database *****/
|
||||||
sprintf (Query,"SELECT NtfCod,NotifyEvent,UNIX_TIMESTAMP(TimeNotif),"
|
sprintf (Query,"SELECT NtfCod,NotifyEvent,UNIX_TIMESTAMP(TimeNotif),"
|
||||||
"FromUsrCod,InsCod,CtrCod,DegCod,CrsCod,Cod,Status"
|
"FromUsrCod,InsCod,CtrCod,DegCod,CrsCod,Cod,Status"
|
||||||
|
@ -2692,40 +2761,41 @@ int swad__getNotifications (struct soap *soap,
|
||||||
" WHERE ToUsrCod='%ld' AND TimeNotif>=FROM_UNIXTIME('%ld')"
|
" WHERE ToUsrCod='%ld' AND TimeNotif>=FROM_UNIXTIME('%ld')"
|
||||||
" ORDER BY TimeNotif DESC",
|
" ORDER BY TimeNotif DESC",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,beginTime);
|
Gbl.Usrs.Me.UsrDat.UsrCod,beginTime);
|
||||||
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get user's notifications");
|
NumNotifications = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get user's notifications");
|
||||||
|
if (NumNotifications) // Notifications found
|
||||||
getNotificationsOut->numNotifications = (int) NumRows;
|
|
||||||
getNotificationsOut->notificationsArray.__size = (int) NumRows;
|
|
||||||
|
|
||||||
if (NumRows == 0)
|
|
||||||
getNotificationsOut->notificationsArray.__ptr = NULL;
|
|
||||||
else // Notifications found
|
|
||||||
{
|
{
|
||||||
|
/* Allocate memory for summary string */
|
||||||
|
if ((SummaryStr = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL)
|
||||||
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Not enough memory",
|
||||||
|
"Not enough memory to store the summary of the notification");
|
||||||
|
|
||||||
|
getNotificationsOut->numNotifications = (int) NumNotifications;
|
||||||
|
getNotificationsOut->notificationsArray.__size = (int) NumNotifications;
|
||||||
getNotificationsOut->notificationsArray.__ptr = soap_malloc (Gbl.soap,(getNotificationsOut->notificationsArray.__size) * sizeof (*(getNotificationsOut->notificationsArray.__ptr)));
|
getNotificationsOut->notificationsArray.__ptr = soap_malloc (Gbl.soap,(getNotificationsOut->notificationsArray.__size) * sizeof (*(getNotificationsOut->notificationsArray.__ptr)));
|
||||||
|
|
||||||
for (NumRow = 0;
|
for (NumNotif = 0;
|
||||||
NumRow < NumRows;
|
NumNotif < NumNotifications;
|
||||||
NumRow++)
|
NumNotif++)
|
||||||
{
|
{
|
||||||
/* Get next notification */
|
/* Get next notification */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get unique notification code (row[0]) */
|
/* Get unique notification code (row[0]) */
|
||||||
NtfCod = Str_ConvertStrCodToLongCod (row[0]);
|
NtfCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].notifCode = (int) NtfCod;
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].notifCode = (int) NtfCod;
|
||||||
|
|
||||||
/* Get notification event type (row[1]) */
|
/* Get notification event type (row[1]) */
|
||||||
NotifyEvent = Ntf_GetNotifyEventFromDB ((const char *) row[1]);
|
NotifyEvent = Ntf_GetNotifyEventFromDB ((const char *) row[1]);
|
||||||
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].eventType = (char *) soap_malloc (Gbl.soap,256);
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].eventType = (char *) soap_malloc (Gbl.soap,256);
|
strncpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].eventType,Ntf_WSNotifyEvents[NotifyEvent],255);
|
||||||
strncpy (getNotificationsOut->notificationsArray.__ptr[NumRow].eventType,Ntf_WSNotifyEvents[NotifyEvent],255);
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].eventType[255] = '\0';
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].eventType[255] = '\0';
|
|
||||||
|
|
||||||
/* Get time of the event (row[2]) */
|
/* Get time of the event (row[2]) */
|
||||||
EventTime = 0L;
|
EventTime = 0L;
|
||||||
if (row[2])
|
if (row[2])
|
||||||
sscanf (row[2],"%ld",&EventTime);
|
sscanf (row[2],"%ld",&EventTime);
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].eventTime = EventTime;
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].eventTime = EventTime;
|
||||||
|
|
||||||
/* Get course (row[7]) */
|
/* Get course (row[7]) */
|
||||||
Crs.CrsCod = Str_ConvertStrCodToLongCod (row[7]);
|
Crs.CrsCod = Str_ConvertStrCodToLongCod (row[7]);
|
||||||
|
@ -2733,36 +2803,37 @@ int swad__getNotifications (struct soap *soap,
|
||||||
|
|
||||||
/* Get user's code of the user who caused the event (row[3]) */
|
/* Get user's code of the user who caused the event (row[3]) */
|
||||||
Gbl.Usrs.Other.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[3]);
|
Gbl.Usrs.Other.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[3]);
|
||||||
if (Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Crs.CrsCod) == SOAP_OK) // Get some user's data from database
|
|
||||||
|
if (Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Crs.CrsCod)) // Get some user's data from database
|
||||||
{
|
{
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].userNickname = (char *) soap_malloc (Gbl.soap,Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA+1);
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].userNickname = (char *) soap_malloc (Gbl.soap,Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA+1);
|
||||||
strncpy (getNotificationsOut->notificationsArray.__ptr[NumRow].userNickname,Gbl.Usrs.Other.UsrDat.Nickname,Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA);
|
strncpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userNickname,Gbl.Usrs.Other.UsrDat.Nickname,Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA);
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].userNickname[Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA] = '\0';
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].userNickname[Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA] = '\0';
|
||||||
|
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].userSurname1 = (char *) soap_malloc (Gbl.soap,256);
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname1 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME_SPEC_CHAR+1);
|
||||||
strncpy (getNotificationsOut->notificationsArray.__ptr[NumRow].userSurname1,Gbl.Usrs.Other.UsrDat.Surname1,255);
|
strncpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname1,Gbl.Usrs.Other.UsrDat.Surname1,Usr_MAX_BYTES_NAME_SPEC_CHAR);
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].userSurname1[255] = '\0';
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname1[Usr_MAX_BYTES_NAME_SPEC_CHAR] = '\0';
|
||||||
|
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].userSurname2 = (char *) soap_malloc (Gbl.soap,256);
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname2 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME_SPEC_CHAR+1);
|
||||||
strncpy (getNotificationsOut->notificationsArray.__ptr[NumRow].userSurname2,Gbl.Usrs.Other.UsrDat.Surname2,255);
|
strncpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname2,Gbl.Usrs.Other.UsrDat.Surname2,Usr_MAX_BYTES_NAME_SPEC_CHAR);
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].userSurname2[255] = '\0';
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname2[Usr_MAX_BYTES_NAME_SPEC_CHAR] = '\0';
|
||||||
|
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].userFirstname = (char *) soap_malloc (Gbl.soap,256);
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME_SPEC_CHAR+1);
|
||||||
strncpy (getNotificationsOut->notificationsArray.__ptr[NumRow].userFirstname,Gbl.Usrs.Other.UsrDat.FirstName,255);
|
strncpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname,Gbl.Usrs.Other.UsrDat.FirstName,Usr_MAX_BYTES_NAME_SPEC_CHAR);
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].userFirstname[255] = '\0';
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname[Usr_MAX_BYTES_NAME_SPEC_CHAR] = '\0';
|
||||||
|
|
||||||
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].userPhoto = (char *) soap_malloc (Gbl.soap,PATH_MAX+1);
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto = (char *) soap_malloc (Gbl.soap,PATH_MAX+1);
|
||||||
strncpy (getNotificationsOut->notificationsArray.__ptr[NumRow].userPhoto,PhotoURL,PATH_MAX);
|
strncpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto,PhotoURL,PATH_MAX);
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].userPhoto[PATH_MAX] = '\0';
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto[PATH_MAX] = '\0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].userNickname = NULL;
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].userNickname = NULL;
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].userSurname1 = NULL;
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname1 = NULL;
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].userSurname2 = NULL;
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname2 = NULL;
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].userFirstname = NULL;
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname = NULL;
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].userPhoto = NULL;
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get institution (row[4]) */
|
/* Get institution (row[4]) */
|
||||||
|
@ -2779,10 +2850,10 @@ int swad__getNotifications (struct soap *soap,
|
||||||
|
|
||||||
/* Get message/post/... code (row[8]) */
|
/* Get message/post/... code (row[8]) */
|
||||||
Cod = Str_ConvertStrCodToLongCod (row[8]);
|
Cod = Str_ConvertStrCodToLongCod (row[8]);
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].eventCode = (int) Cod;
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].eventCode = (int) Cod;
|
||||||
|
|
||||||
/* Set location */
|
/* Set location */
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].location = (char *) soap_malloc (Gbl.soap,1024);
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].location = (char *) soap_malloc (Gbl.soap,1024);
|
||||||
|
|
||||||
if (NotifyEvent == Ntf_EVENT_FORUM_POST_COURSE ||
|
if (NotifyEvent == Ntf_EVENT_FORUM_POST_COURSE ||
|
||||||
NotifyEvent == Ntf_EVENT_FORUM_REPLY)
|
NotifyEvent == Ntf_EVENT_FORUM_REPLY)
|
||||||
|
@ -2793,28 +2864,28 @@ int swad__getNotifications (struct soap *soap,
|
||||||
&Deg,
|
&Deg,
|
||||||
&Crs,
|
&Crs,
|
||||||
ForumName,Gbl.Prefs.Language,false); // Set forum name in recipient's language
|
ForumName,Gbl.Prefs.Language,false); // Set forum name in recipient's language
|
||||||
sprintf (getNotificationsOut->notificationsArray.__ptr[NumRow].location,"%s: %s",
|
sprintf (getNotificationsOut->notificationsArray.__ptr[NumNotif].location,"%s: %s",
|
||||||
Txt_Forum,ForumName);
|
Txt_Forum,ForumName);
|
||||||
}
|
}
|
||||||
else if (Crs.CrsCod > 0)
|
else if (Crs.CrsCod > 0)
|
||||||
sprintf (getNotificationsOut->notificationsArray.__ptr[NumRow].location,"%s: %s",
|
sprintf (getNotificationsOut->notificationsArray.__ptr[NumNotif].location,"%s: %s",
|
||||||
Txt_Course,Crs.ShortName);
|
Txt_Course,Crs.ShortName);
|
||||||
else if (Deg.DegCod > 0)
|
else if (Deg.DegCod > 0)
|
||||||
sprintf (getNotificationsOut->notificationsArray.__ptr[NumRow].location,"%s: %s",
|
sprintf (getNotificationsOut->notificationsArray.__ptr[NumNotif].location,"%s: %s",
|
||||||
Txt_Degree,Deg.ShortName);
|
Txt_Degree,Deg.ShortName);
|
||||||
else if (Ctr.CtrCod > 0)
|
else if (Ctr.CtrCod > 0)
|
||||||
sprintf (getNotificationsOut->notificationsArray.__ptr[NumRow].location,"%s: %s",
|
sprintf (getNotificationsOut->notificationsArray.__ptr[NumNotif].location,"%s: %s",
|
||||||
Txt_Centre,Ctr.ShortName);
|
Txt_Centre,Ctr.ShortName);
|
||||||
else if (Ins.InsCod > 0)
|
else if (Ins.InsCod > 0)
|
||||||
sprintf (getNotificationsOut->notificationsArray.__ptr[NumRow].location,"%s: %s",
|
sprintf (getNotificationsOut->notificationsArray.__ptr[NumNotif].location,"%s: %s",
|
||||||
Txt_Institution,Ins.ShortName);
|
Txt_Institution,Ins.ShortName);
|
||||||
else
|
else
|
||||||
strcpy (getNotificationsOut->notificationsArray.__ptr[NumRow].location,"-");
|
strcpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].location,"-");
|
||||||
|
|
||||||
/* Get status (row[9]) */
|
/* Get status (row[9]) */
|
||||||
if (sscanf (row[9],"%u",&Status) != 1)
|
if (sscanf (row[9],"%u",&Status) != 1)
|
||||||
Status = (Ntf_Status_t) 0;
|
Status = (Ntf_Status_t) 0;
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].status = (int) Status;
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].status = (int) Status;
|
||||||
|
|
||||||
/* Get summary and content */
|
/* Get summary and content */
|
||||||
ContentStr = NULL;
|
ContentStr = NULL;
|
||||||
|
@ -2822,32 +2893,38 @@ int swad__getNotifications (struct soap *soap,
|
||||||
Cod,Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod,
|
Cod,Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Cfg_MAX_CHARS_NOTIF_SUMMARY_WEB_SERVICE,true);
|
Cfg_MAX_CHARS_NOTIF_SUMMARY_WEB_SERVICE,true);
|
||||||
|
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].summary = (char *) soap_malloc (Gbl.soap,strlen (SummaryStr)+1);
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].summary = (char *) soap_malloc (Gbl.soap,strlen (SummaryStr)+1);
|
||||||
strcpy (getNotificationsOut->notificationsArray.__ptr[NumRow].summary,SummaryStr);
|
strcpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].summary,SummaryStr);
|
||||||
|
|
||||||
if (ContentStr != NULL)
|
if (ContentStr == NULL)
|
||||||
{
|
{
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].content = (char *) soap_malloc (Gbl.soap,strlen (ContentStr)+1);
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].content = (char *) soap_malloc (Gbl.soap,1);
|
||||||
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].content[0] = '\0';
|
||||||
strcpy (getNotificationsOut->notificationsArray.__ptr[NumRow].content,ContentStr);
|
|
||||||
|
|
||||||
free ((void *) ContentStr);
|
|
||||||
ContentStr = NULL;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].content = (char *) soap_malloc (Gbl.soap,1);
|
getNotificationsOut->notificationsArray.__ptr[NumNotif].content = (char *) soap_malloc (Gbl.soap,strlen (ContentStr)+1);
|
||||||
getNotificationsOut->notificationsArray.__ptr[NumRow].content[0] = '\0';
|
strcpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].content,ContentStr);
|
||||||
|
|
||||||
|
/* Free memory used by content string */
|
||||||
|
free ((void *) ContentStr);
|
||||||
|
ContentStr = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Free memory used by summary string */
|
||||||
|
free ((void *) SummaryStr);
|
||||||
|
}
|
||||||
|
else // No notifications found
|
||||||
|
{
|
||||||
|
getNotificationsOut->numNotifications = 0;
|
||||||
|
getNotificationsOut->notificationsArray.__size = 0;
|
||||||
|
getNotificationsOut->notificationsArray.__ptr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
/***** Free summary *****/
|
|
||||||
free ((void *) SummaryStr);
|
|
||||||
|
|
||||||
return SOAP_OK;
|
return SOAP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2910,6 +2987,7 @@ int swad__markNotificationsAsRead (struct soap *soap,
|
||||||
long NtfCod;
|
long NtfCod;
|
||||||
char Query[512];
|
char Query[512];
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_markNotificationsAsRead;
|
Gbl.WebService.Function = Svc_markNotificationsAsRead;
|
||||||
|
|
||||||
|
@ -2922,8 +3000,10 @@ int swad__markNotificationsAsRead (struct soap *soap,
|
||||||
"Web service key does not exist in database");
|
"Web service key does not exist in database");
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,-1L)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,-1L))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -2978,6 +3058,7 @@ int swad__sendMessage (struct soap *soap,
|
||||||
const char *Ptr;
|
const char *Ptr;
|
||||||
bool NotifyByEmail;
|
bool NotifyByEmail;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_sendMessage;
|
Gbl.WebService.Function = Svc_sendMessage;
|
||||||
|
|
||||||
|
@ -2990,8 +3071,10 @@ int swad__sendMessage (struct soap *soap,
|
||||||
"Web service key does not exist in database");
|
"Web service key does not exist in database");
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,-1L)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,-1L))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -3221,6 +3304,7 @@ int swad__sendNotice (struct soap *soap,
|
||||||
char Query[512+Cns_MAX_BYTES_TEXT];
|
char Query[512+Cns_MAX_BYTES_TEXT];
|
||||||
long NotCod;
|
long NotCod;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_sendNotice;
|
Gbl.WebService.Function = Svc_sendNotice;
|
||||||
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
||||||
|
@ -3234,8 +3318,10 @@ int swad__sendNotice (struct soap *soap,
|
||||||
"Web service key does not exist in database");
|
"Web service key does not exist in database");
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -3284,6 +3370,7 @@ int swad__getTestConfig (struct soap *soap,
|
||||||
extern const char *Tst_FeedbackXML[Tst_NUM_TYPES_FEEDBACK];
|
extern const char *Tst_FeedbackXML[Tst_NUM_TYPES_FEEDBACK];
|
||||||
int ReturnCode;
|
int ReturnCode;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_getTestConfig;
|
Gbl.WebService.Function = Svc_getTestConfig;
|
||||||
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
||||||
|
@ -3297,8 +3384,10 @@ int swad__getTestConfig (struct soap *soap,
|
||||||
"Web service key does not exist in database");
|
"Web service key does not exist in database");
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -3413,6 +3502,7 @@ int swad__getTests (struct soap *soap,
|
||||||
{
|
{
|
||||||
int ReturnCode;
|
int ReturnCode;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_getTests;
|
Gbl.WebService.Function = Svc_getTests;
|
||||||
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
||||||
|
@ -3426,8 +3516,10 @@ int swad__getTests (struct soap *soap,
|
||||||
"Web service key does not exist in database");
|
"Web service key does not exist in database");
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -3807,6 +3899,7 @@ int swad__getTrivialQuestion (struct soap *soap,
|
||||||
Tst_AnswerType_t AnswerType;
|
Tst_AnswerType_t AnswerType;
|
||||||
unsigned Index;
|
unsigned Index;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_getTrivialQuestion;
|
Gbl.WebService.Function = Svc_getTrivialQuestion;
|
||||||
|
|
||||||
|
@ -3819,8 +3912,10 @@ int swad__getTrivialQuestion (struct soap *soap,
|
||||||
"Web service key does not exist in database");
|
"Web service key does not exist in database");
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -4045,6 +4140,7 @@ int swad__getDirectoryTree (struct soap *soap,
|
||||||
unsigned long FileSize;
|
unsigned long FileSize;
|
||||||
unsigned long NumBytesRead;
|
unsigned long NumBytesRead;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_getDirectoryTree;
|
Gbl.WebService.Function = Svc_getDirectoryTree;
|
||||||
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
Gbl.CurrentCrs.Crs.CrsCod = (long) courseCode;
|
||||||
|
@ -4058,8 +4154,10 @@ int swad__getDirectoryTree (struct soap *soap,
|
||||||
"Bad web service key",
|
"Bad web service key",
|
||||||
"Web service key does not exist in database");
|
"Web service key does not exist in database");
|
||||||
|
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -4322,6 +4420,7 @@ int swad__getFile (struct soap *soap,
|
||||||
char URL[PATH_MAX+1];
|
char URL[PATH_MAX+1];
|
||||||
char PhotoURL[PATH_MAX+1];
|
char PhotoURL[PATH_MAX+1];
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_getFile;
|
Gbl.WebService.Function = Svc_getFile;
|
||||||
|
|
||||||
|
@ -4371,8 +4470,10 @@ int swad__getFile (struct soap *soap,
|
||||||
&Gbl.CurrentCrs.Grps.GrpCod);
|
&Gbl.CurrentCrs.Grps.GrpCod);
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
@ -4476,6 +4577,7 @@ int swad__getMarks (struct soap *soap,
|
||||||
char SummaryStr[NAME_MAX+1]; // Really not used
|
char SummaryStr[NAME_MAX+1]; // Really not used
|
||||||
char *ContentStr;
|
char *ContentStr;
|
||||||
|
|
||||||
|
/***** Initializations *****/
|
||||||
Gbl.soap = soap;
|
Gbl.soap = soap;
|
||||||
Gbl.WebService.Function = Svc_getMarks;
|
Gbl.WebService.Function = Svc_getMarks;
|
||||||
getMarksOut->content = NULL;
|
getMarksOut->content = NULL;
|
||||||
|
@ -4513,8 +4615,10 @@ int swad__getMarks (struct soap *soap,
|
||||||
return ReturnCode;
|
return ReturnCode;
|
||||||
|
|
||||||
/***** Get some of my data *****/
|
/***** Get some of my data *****/
|
||||||
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) != SOAP_OK)
|
if (!Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod))
|
||||||
return ReturnCode;
|
return soap_receiver_fault (Gbl.soap,
|
||||||
|
"Can not get user's data from database",
|
||||||
|
"User does not exist in database");
|
||||||
Gbl.Usrs.Me.Logged = true;
|
Gbl.Usrs.Me.Logged = true;
|
||||||
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user