swad-core/swad_record.c

3752 lines
136 KiB
C
Raw Normal View History

2014-12-01 23:55:08 +01:00
// swad_record.c: users' record cards
/*
SWAD (Shared Workspace At a Distance),
is a web platform developed at the University of Granada (Spain),
and used to support university teaching.
This file is part of SWAD core.
2016-01-01 20:19:43 +01:00
Copyright (C) 1999-2016 Antonio Ca<EFBFBD>as Vargas
2014-12-01 23:55:08 +01:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/********************************* Headers ***********************************/
/*****************************************************************************/
#include <linux/limits.h> // For PATH_MAX
#include <linux/stddef.h> // For NULL
#include <stdlib.h> // For calloc
#include <string.h>
#include "swad_action.h"
#include "swad_config.h"
#include "swad_database.h"
2014-12-12 18:50:36 +01:00
#include "swad_enrollment.h"
2015-03-18 01:06:43 +01:00
#include "swad_follow.h"
2014-12-01 23:55:08 +01:00
#include "swad_global.h"
#include "swad_ID.h"
2015-01-17 20:06:25 +01:00
#include "swad_logo.h"
2014-12-01 23:55:08 +01:00
#include "swad_network.h"
#include "swad_parameter.h"
#include "swad_photo.h"
#include "swad_preference.h"
#include "swad_QR.h"
#include "swad_record.h"
#include "swad_user.h"
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
2015-03-24 10:11:17 +01:00
extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS];
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
2015-12-13 13:53:00 +01:00
#define Rec_INSTITUTION_LOGO_SIZE 64
#define Rec_DEGREE_LOGO_SIZE 64
2015-12-22 09:38:32 +01:00
2016-04-22 12:24:02 +02:00
#define Rec_USR_MIN_AGE 12 // years old
2015-12-22 09:38:32 +01:00
#define Rec_USR_MAX_AGE 120 // years old
2014-12-01 23:55:08 +01:00
#define Rec_SHOW_OFFICE_HOURS_DEFAULT true
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
static void Rec_WriteHeadingRecordFields (void);
static void Rec_GetFieldByCod (long FieldCod,char *Name,unsigned *NumLines,Rec_VisibilityRecordFields_t *Visibility);
2015-03-05 18:58:59 +01:00
static void Rec_ShowRecordOneStdCrs (void);
2015-10-03 21:10:47 +02:00
static void Rec_ListRecordsStds (Rec_RecordViewType_t TypeOfView);
2015-03-05 18:58:59 +01:00
static void Rec_ShowRecordOneTchCrs (void);
2015-10-03 21:10:47 +02:00
static void Rec_ShowLinkToPrintPreviewOfRecords (void);
2014-12-01 23:55:08 +01:00
static void Rec_GetParamRecordsPerPage (void);
static void Rec_WriteFormShowOfficeHours (bool ShowOfficeHours,const char *ListUsrCods);
static bool Rec_GetParamShowOfficeHours (void);
2015-10-03 21:10:47 +02:00
static void Rec_ShowCrsRecord (Rec_RecordViewType_t TypeOfView,struct UsrData *UsrDat,
const char *Anchor);
2015-03-30 13:59:32 +02:00
static void Rec_ShowMyCrsRecordUpdated (void);
2016-04-22 12:24:02 +02:00
static void Rec_ShowInstitution (struct Institution *Ins,bool PutFormLinks);
2014-12-01 23:55:08 +01:00
static void Rec_WriteLinkToDataProtectionClause (void);
2015-12-07 23:13:08 +01:00
static void Rec_GetUsrExtraDataFromRecordForm (struct UsrData *UsrDat);
2014-12-01 23:55:08 +01:00
static void Rec_GetUsrCommentsFromForm (struct UsrData *UsrDat);
/*****************************************************************************/
/*************** Create, edit and remove fields of records *******************/
/*****************************************************************************/
void Rec_ReqEditRecordFields (void)
{
extern const char *Txt_There_are_no_record_fields_in_the_course_X;
2015-03-24 17:47:26 +01:00
extern const char *Txt_Record_fields;
2014-12-01 23:55:08 +01:00
/***** Get list of fields of records in current course *****/
Rec_GetListRecordFieldsInCurrentCrs ();
/***** List the current fields of records for edit them *****/
if (Gbl.CurrentCrs.Records.LstFields.Num) // Fields found...
{
2015-04-12 18:01:06 +02:00
Lay_StartRoundFrameTable (NULL,2,Txt_Record_fields);
2014-12-01 23:55:08 +01:00
Rec_ListFieldsRecordsForEdition ();
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ();
2014-12-01 23:55:08 +01:00
}
else // No fields of records found for current course in the database
{
sprintf (Gbl.Message,Txt_There_are_no_record_fields_in_the_course_X,
Gbl.CurrentCrs.Crs.FullName);
Lay_ShowAlert (Lay_INFO,Gbl.Message);
}
/***** Put a form to create a new record field *****/
Rec_ShowFormCreateRecordField ();
/* Free list of fields of records */
Rec_FreeListFields ();
}
/*****************************************************************************/
/****** Create a list with the fields of records from current course *********/
/*****************************************************************************/
void Rec_GetListRecordFieldsInCurrentCrs (void)
{
char Query[1024];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRow;
unsigned Vis;
if (++Gbl.CurrentCrs.Records.LstFields.NestedCalls > 1) // If the list is already created, don't do anything
return;
/***** Get fields of cards of a course from database *****/
sprintf (Query,"SELECT FieldCod,FieldName,NumLines,Visibility"
" FROM crs_record_fields"
" WHERE CrsCod='%ld' ORDER BY FieldName",
Gbl.CurrentCrs.Crs.CrsCod);
Gbl.CurrentCrs.Records.LstFields.Num = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get fields of cards of a course");
/***** Get the fields of records *****/
if (Gbl.CurrentCrs.Records.LstFields.Num)
{
/***** Create a list of fields *****/
if ((Gbl.CurrentCrs.Records.LstFields.Lst = (struct RecordField *) calloc (Gbl.CurrentCrs.Records.LstFields.Num,sizeof (struct RecordField))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store fields of records in current course.");
/***** Get the fields *****/
for (NumRow = 0;
NumRow < Gbl.CurrentCrs.Records.LstFields.Num;
NumRow++)
{
/* Get next field */
row = mysql_fetch_row (mysql_res);
/* Get the code of field (row[0]) */
if ((Gbl.CurrentCrs.Records.LstFields.Lst[NumRow].FieldCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
Lay_ShowErrorAndExit ("Wrong code of field.");
/* Name of the field (row[1]) */
strncpy (Gbl.CurrentCrs.Records.LstFields.Lst[NumRow].Name,row[1],Rec_MAX_LENGTH_NAME_FIELD);
/* Number of lines (row[2]) */
Gbl.CurrentCrs.Records.LstFields.Lst[NumRow].NumLines = Rec_ConvertToNumLinesField (row[2]);
/* Visible or editable by students? (row[3]) */
if (sscanf (row[3],"%u",&Vis) != 1)
Lay_ShowErrorAndExit ("Error when getting field of record in current course.");
if (Vis < Rec_NUM_TYPES_VISIBILITY)
Gbl.CurrentCrs.Records.LstFields.Lst[NumRow].Visibility = (Rec_VisibilityRecordFields_t) Vis;
else
Gbl.CurrentCrs.Records.LstFields.Lst[NumRow].Visibility = Rec_HIDDEN_FIELD;
}
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
/********* List the fields of records already present in database ************/
/*****************************************************************************/
void Rec_ListFieldsRecordsForEdition (void)
{
extern const char *Txt_RECORD_FIELD_VISIBILITY_MENU[Rec_NUM_TYPES_VISIBILITY];
unsigned NumField;
Rec_VisibilityRecordFields_t Vis;
/***** Write heading *****/
Rec_WriteHeadingRecordFields ();
/***** List the fields *****/
for (NumField = 0;
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
NumField++)
{
fprintf (Gbl.F.Out,"<tr>");
/* Write icon to remove the field */
2015-09-03 00:59:03 +02:00
fprintf (Gbl.F.Out,"<td class=\"BM%u\">",Gbl.RowEvenOdd);
2014-12-01 23:55:08 +01:00
Act_FormStart (ActReqRemFie);
Par_PutHiddenParamLong ("FieldCod",Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
2015-07-22 19:59:28 +02:00
Lay_PutIconRemove ();
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>");
2014-12-01 23:55:08 +01:00
/* Name of the field */
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">");
2014-12-01 23:55:08 +01:00
Act_FormStart (ActRenFie);
Par_PutHiddenParamLong ("FieldCod",Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"FieldName\""
2015-09-28 18:28:29 +02:00
" style=\"width:500px;\" maxlength=\"%u\" value=\"%s\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\" />",
2014-12-01 23:55:08 +01:00
Rec_MAX_LENGTH_NAME_FIELD,
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Name,
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>");
2014-12-01 23:55:08 +01:00
/* Number of lines in the form */
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">");
2014-12-01 23:55:08 +01:00
Act_FormStart (ActChgRowFie);
Par_PutHiddenParamLong ("FieldCod",Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
2015-10-23 01:31:08 +02:00
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"NumLines\""
" size=\"2\" maxlength=\"2\" value=\"%u\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\" />",
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].NumLines,
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>");
2014-12-01 23:55:08 +01:00
/* Visibility of a field */
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">");
2014-12-01 23:55:08 +01:00
Act_FormStart (ActChgVisFie);
Par_PutHiddenParamLong ("FieldCod",Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
fprintf (Gbl.F.Out,"<select name=\"Visibility\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\">",
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2014-12-01 23:55:08 +01:00
for (Vis = (Rec_VisibilityRecordFields_t) 0;
Vis < (Rec_VisibilityRecordFields_t) Rec_NUM_TYPES_VISIBILITY;
Vis++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",(unsigned) Vis);
if (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Vis)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_RECORD_FIELD_VISIBILITY_MENU[Vis]);
}
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</select>");
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
}
}
/*****************************************************************************/
/******************* Show form to create a new record field ******************/
/*****************************************************************************/
void Rec_ShowFormCreateRecordField (void)
{
extern const char *Txt_New_record_field;
extern const char *Txt_RECORD_FIELD_VISIBILITY_MENU[Rec_NUM_TYPES_VISIBILITY];
extern const char *Txt_Create_record_field;
Rec_VisibilityRecordFields_t Vis;
/***** Start form *****/
Act_FormStart (ActNewFie);
/***** Start of frame *****/
2015-04-12 18:01:06 +02:00
Lay_StartRoundFrameTable (NULL,0,Txt_New_record_field);
2014-12-01 23:55:08 +01:00
/***** Write heading *****/
Rec_WriteHeadingRecordFields ();
/***** Write disabled icon to remove the field *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-22 19:20:30 +02:00
"<td class=\"BM\">");
Lay_PutIconRemovalNotAllowed ();
fprintf (Gbl.F.Out,"</td>");
2014-12-01 23:55:08 +01:00
/***** Field name *****/
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">"
2014-12-01 23:55:08 +01:00
"<input type=\"text\" name=\"FieldName\""
2015-09-28 18:28:29 +02:00
" style=\"width:500px;\" maxlength=\"%u\" value=\"%s\" />"
2014-12-01 23:55:08 +01:00
"</td>",
Rec_MAX_LENGTH_NAME_FIELD,Gbl.CurrentCrs.Records.Field.Name);
/***** Number of lines in form ******/
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
2015-10-23 01:31:08 +02:00
"<input type=\"text\" name=\"NumLines\""
" size=\"2\" maxlength=\"2\" value=\"%u\" />"
2014-12-01 23:55:08 +01:00
"</td>",
Gbl.CurrentCrs.Records.Field.NumLines);
/***** Visibility to students *****/
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
2014-12-01 23:55:08 +01:00
"<select name=\"Visibility\">");
for (Vis = (Rec_VisibilityRecordFields_t) 0;
Vis < (Rec_VisibilityRecordFields_t) Rec_NUM_TYPES_VISIBILITY;
Vis++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",(unsigned) Vis);
if (Gbl.CurrentCrs.Records.Field.Visibility == Vis)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_RECORD_FIELD_VISIBILITY_MENU[Vis]);
}
fprintf (Gbl.F.Out,"</select>"
"</td>"
"</tr>");
2015-04-11 23:46:21 +02:00
/***** Send button and end frame *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTableWithButton (Lay_CREATE_BUTTON,Txt_Create_record_field);
2015-03-24 17:47:26 +01:00
2015-04-11 23:46:21 +02:00
/***** End form *****/
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************************** Write heading of groups **************************/
/*****************************************************************************/
static void Rec_WriteHeadingRecordFields (void)
{
extern const char *Txt_Field_BR_name;
extern const char *Txt_No_of_BR_lines;
extern const char *Txt_Visible_by_BR_the_student;
fprintf (Gbl.F.Out,"<tr>"
2014-12-27 00:28:19 +01:00
"<th></th>"
2015-09-06 20:02:14 +02:00
"<th class=\"CENTER_MIDDLE\">"
2014-12-27 00:28:19 +01:00
"%s"
"</th>"
2015-09-06 20:02:14 +02:00
"<th class=\"CENTER_MIDDLE\">"
2014-12-27 00:28:19 +01:00
"%s"
"</th>"
2015-09-06 20:02:14 +02:00
"<th class=\"CENTER_MIDDLE\">"
2014-12-27 00:28:19 +01:00
"%s"
"</th>"
2014-12-01 23:55:08 +01:00
"</tr>",
Txt_Field_BR_name,
Txt_No_of_BR_lines,
Txt_Visible_by_BR_the_student);
}
/*****************************************************************************/
/*************** Receive data from a form of record fields *******************/
/*****************************************************************************/
void Rec_ReceiveFormField (void)
{
extern const char *Txt_The_record_field_X_already_exists;
extern const char *Txt_You_must_specify_the_name_of_the_new_record_field;
char UnsignedStr[10+1];
unsigned Vis;
/***** Get parameters from the form *****/
/* Get the name of the field */
Par_GetParToText ("FieldName",Gbl.CurrentCrs.Records.Field.Name,Rec_MAX_LENGTH_NAME_FIELD);
/* Get the number of lines */
Par_GetParToText ("NumLines",UnsignedStr,10);
Gbl.CurrentCrs.Records.Field.NumLines = Rec_ConvertToNumLinesField (UnsignedStr);
/* Get the field visibility by students */
Par_GetParToText ("Visibility",UnsignedStr,10);
if (sscanf (UnsignedStr,"%u",&Vis) != 1)
Lay_ShowErrorAndExit ("Visibility is missing.");
if (Vis < Rec_NUM_TYPES_VISIBILITY)
Gbl.CurrentCrs.Records.Field.Visibility = (Rec_VisibilityRecordFields_t) Vis;
else
Gbl.CurrentCrs.Records.Field.Visibility = Rec_HIDDEN_FIELD;
if (Gbl.CurrentCrs.Records.Field.Name[0]) // If there's a name
{
/***** If the field already was in the database... *****/
if (Rec_CheckIfRecordFieldIsRepeated (Gbl.CurrentCrs.Records.Field.Name))
{
sprintf (Gbl.Message,Txt_The_record_field_X_already_exists,
Gbl.CurrentCrs.Records.Field.Name);
Lay_ShowAlert (Lay_ERROR,Gbl.Message);
}
else // Add the new field to the database
Rec_CreateRecordField ();
}
else // If there is not name
Lay_ShowAlert (Lay_ERROR,Txt_You_must_specify_the_name_of_the_new_record_field);
/***** Show the form again *****/
Rec_ReqEditRecordFields ();
}
/*****************************************************************************/
/********* Get number of lines of the form to edit a record field ************/
/*****************************************************************************/
unsigned Rec_ConvertToNumLinesField (const char *StrNumLines)
{
int NumLines;
if (sscanf (StrNumLines,"%d",&NumLines) != 1)
return Rec_MIN_LINES_IN_EDITION_FIELD;
else if (NumLines < Rec_MIN_LINES_IN_EDITION_FIELD)
return Rec_MIN_LINES_IN_EDITION_FIELD;
else if (NumLines > Rec_MAX_LINES_IN_EDITION_FIELD)
return Rec_MAX_LINES_IN_EDITION_FIELD;
return (unsigned) NumLines;
}
/*****************************************************************************/
/* Check if the name of the field of record equals any of the existing ones **/
/*****************************************************************************/
bool Rec_CheckIfRecordFieldIsRepeated (const char *FieldName)
{
bool FieldIsRepeated = false;
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRow,NumRows;
/* Query database */
if ((NumRows = Rec_GetAllFieldsInCurrCrs (&mysql_res)) > 0) // If se han encontrado groups...
/* Compare with all the tipos of group from the database */
for (NumRow = 0;
NumRow < NumRows;
NumRow++)
{
/* Get next type of group */
row = mysql_fetch_row (mysql_res);
/* The name of the field is in row[1] */
if (!strcasecmp (FieldName,row[1]))
{
FieldIsRepeated = true;
break;
}
}
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res);
return FieldIsRepeated;
}
/*****************************************************************************/
/******* Get the fields of records already present in current course *********/
/*****************************************************************************/
unsigned long Rec_GetAllFieldsInCurrCrs (MYSQL_RES **mysql_res)
{
char Query[512];
/***** Get fields of cards of current course from database *****/
2014-12-27 19:43:01 +01:00
sprintf (Query,"SELECT FieldCod,FieldName,Visibility"
" FROM crs_record_fields"
" WHERE CrsCod='%ld' ORDER BY FieldName",
Gbl.CurrentCrs.Crs.CrsCod);
return DB_QuerySELECT (Query,mysql_res,
"can not get fields of cards of a course");
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************************* Create a field of record **************************/
/*****************************************************************************/
void Rec_CreateRecordField (void)
{
extern const char *Txt_Created_new_record_field_X;
char Query[1024];
/***** Create the new field *****/
2014-12-27 13:49:17 +01:00
sprintf (Query,"INSERT INTO crs_record_fields"
" (CrsCod,FieldName,NumLines,Visibility)"
" VALUES ('%ld','%s','%u','%u')",
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Crs.CrsCod,
2014-12-27 13:49:17 +01:00
Gbl.CurrentCrs.Records.Field.Name,
Gbl.CurrentCrs.Records.Field.NumLines,
(unsigned) Gbl.CurrentCrs.Records.Field.Visibility);
2014-12-01 23:55:08 +01:00
DB_QueryINSERT (Query,"can not create field of record");
2014-12-27 19:43:01 +01:00
/***** Write message of success *****/
2014-12-01 23:55:08 +01:00
sprintf (Gbl.Message,Txt_Created_new_record_field_X,
Gbl.CurrentCrs.Records.Field.Name);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
}
/*****************************************************************************/
/**************** Request the removing of a field of records *****************/
/*****************************************************************************/
void Rec_ReqRemField (void)
{
unsigned NumRecords;
/***** Get the code of field *****/
if ((Gbl.CurrentCrs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1)
Lay_ShowErrorAndExit ("Code of field is missing.");
/***** Check if exists any record with that field filled *****/
if ((NumRecords = Rec_CountNumRecordsInCurrCrsWithField (Gbl.CurrentCrs.Records.Field.FieldCod))) // There are records with that field filled
Rec_AskConfirmRemFieldWithRecords (NumRecords);
else // There are no records with that field filled
Rec_RemoveFieldFromDB ();
}
/*****************************************************************************/
/************ Get a parameter with a code of field of records ****************/
/*****************************************************************************/
long Rec_GetFieldCod (void)
{
char LongStr[1+10+1];
/***** Get the code of the field *****/
Par_GetParToText ("FieldCod",LongStr,1+10);
return Str_ConvertStrCodToLongCod (LongStr);
}
/*****************************************************************************/
/*************** Get the number of records with a field filled ***************/
/*****************************************************************************/
unsigned Rec_CountNumRecordsInCurrCrsWithField (long FieldCod)
{
2015-03-18 01:06:43 +01:00
char Query[128];
2014-12-01 23:55:08 +01:00
/***** Get number of cards with a given field in a course from database *****/
2015-03-18 01:06:43 +01:00
sprintf (Query,"SELECT COUNT(*) FROM crs_records WHERE FieldCod='%ld'",
FieldCod);
2014-12-01 23:55:08 +01:00
return (unsigned) DB_QueryCOUNT (Query,"can not get number of cards with a given field not empty in a course");
}
/*****************************************************************************/
/******* Request confirmation for the removing of a field with records *******/
/*****************************************************************************/
void Rec_AskConfirmRemFieldWithRecords (unsigned NumRecords)
{
extern const char *Txt_Do_you_really_want_to_remove_the_field_X_from_the_records_of_X;
extern const char *Txt_this_field_is_filled_in_the_record_of_one_student;
extern const char *Txt_this_field_is_filled_in_the_records_of_X_students;
extern const char *Txt_Remove_record_field;
char Message_part2[512];
/***** Get from the database the name of the field *****/
Rec_GetFieldByCod (Gbl.CurrentCrs.Records.Field.FieldCod,Gbl.CurrentCrs.Records.Field.Name,&Gbl.CurrentCrs.Records.Field.NumLines,&Gbl.CurrentCrs.Records.Field.Visibility);
/***** Write mensaje to ask confirmation of deletion *****/
sprintf (Gbl.Message,Txt_Do_you_really_want_to_remove_the_field_X_from_the_records_of_X,
Gbl.CurrentCrs.Records.Field.Name,Gbl.CurrentCrs.Crs.FullName);
if (NumRecords == 1)
strcat (Gbl.Message,Txt_this_field_is_filled_in_the_record_of_one_student);
else
{
sprintf (Message_part2,Txt_this_field_is_filled_in_the_records_of_X_students,
NumRecords);
strcat (Gbl.Message,Message_part2);
}
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
/***** Button to confirm removing *****/
Act_FormStart (ActRemFie);
Par_PutHiddenParamLong ("FieldCod",Gbl.CurrentCrs.Records.Field.FieldCod);
2015-03-24 17:47:26 +01:00
Lay_PutRemoveButton (Txt_Remove_record_field);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************** Remove from the database a field of records ******************/
/*****************************************************************************/
void Rec_RemoveFieldFromDB (void)
{
extern const char *Txt_Record_field_X_removed;
char Query[512];
/***** Get from the database the name of the field *****/
Rec_GetFieldByCod (Gbl.CurrentCrs.Records.Field.FieldCod,Gbl.CurrentCrs.Records.Field.Name,&Gbl.CurrentCrs.Records.Field.NumLines,&Gbl.CurrentCrs.Records.Field.Visibility);
/***** Remove field from all records *****/
sprintf (Query,"DELETE FROM crs_records WHERE FieldCod='%ld'",
Gbl.CurrentCrs.Records.Field.FieldCod);
DB_QueryDELETE (Query,"can not remove field from all students' records");
/***** Remove the field *****/
sprintf (Query,"DELETE FROM crs_record_fields WHERE FieldCod='%ld'",
Gbl.CurrentCrs.Records.Field.FieldCod);
DB_QueryDELETE (Query,"can not remove field of record");
/***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_Record_field_X_removed,
Gbl.CurrentCrs.Records.Field.Name);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
/***** Show the form again *****/
Rec_ReqEditRecordFields ();
}
/*****************************************************************************/
/************** Get the data of a field of records from its code *************/
/*****************************************************************************/
static void Rec_GetFieldByCod (long FieldCod,char *Name,unsigned *NumLines,Rec_VisibilityRecordFields_t *Visibility)
{
char Query[512];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRows;
unsigned Vis;
/***** Get a field of a record in a course from database *****/
sprintf (Query,"SELECT FieldName,NumLines,Visibility FROM crs_record_fields"
" WHERE CrsCod='%ld' AND FieldCod='%ld'",Gbl.CurrentCrs.Crs.CrsCod,FieldCod);
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get a field of a record in a course");
/***** Count number of rows in result *****/
if (NumRows != 1)
Lay_ShowErrorAndExit ("Error when getting a field of a record in a course.");
/***** Get the field *****/
row = mysql_fetch_row (mysql_res);
/* Name of the field */
strcpy (Name,row[0]);
/* Number of lines of the field (row[1]) */
*NumLines = Rec_ConvertToNumLinesField (row[1]);
/* Visible or editable by students? (row[2]) */
if (sscanf (row[2],"%u",&Vis) != 1)
Lay_ShowErrorAndExit ("Error when getting a field of a record in a course.");
if (Vis < Rec_NUM_TYPES_VISIBILITY)
*Visibility = (Rec_VisibilityRecordFields_t) Vis;
else
*Visibility = Rec_HIDDEN_FIELD;
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
/************************* Remove a field of records *************************/
/*****************************************************************************/
void Rec_RemoveField (void)
{
/***** Get the code of the field *****/
if ((Gbl.CurrentCrs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1)
Lay_ShowErrorAndExit ("Code of field is missing.");
/***** Borrarlo from the database *****/
Rec_RemoveFieldFromDB ();
}
/*****************************************************************************/
/************************** Rename a field of records ************************/
/*****************************************************************************/
void Rec_RenameField (void)
{
extern const char *Txt_You_can_not_leave_the_name_of_the_field_X_empty;
extern const char *Txt_The_record_field_X_already_exists;
extern const char *Txt_The_record_field_X_has_been_renamed_as_Y;
extern const char *Txt_The_name_of_the_field_X_has_not_changed;
char Query[1024];
char NewFieldName[Rec_MAX_LENGTH_NAME_FIELD+1];
/***** Get parameters of the form *****/
/* Get the code of the field */
if ((Gbl.CurrentCrs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1)
Lay_ShowErrorAndExit ("Code of field is missing.");
/* Get the new group name */
Par_GetParToText ("FieldName",NewFieldName,Rec_MAX_LENGTH_NAME_FIELD);
/***** Get from the database the antiguo group name *****/
Rec_GetFieldByCod (Gbl.CurrentCrs.Records.Field.FieldCod,Gbl.CurrentCrs.Records.Field.Name,&Gbl.CurrentCrs.Records.Field.NumLines,&Gbl.CurrentCrs.Records.Field.Visibility);
/***** Check if new name is empty *****/
if (!NewFieldName[0])
{
sprintf (Gbl.Message,Txt_You_can_not_leave_the_name_of_the_field_X_empty,
Gbl.CurrentCrs.Records.Field.Name);
Lay_ShowAlert (Lay_ERROR,Gbl.Message);
}
else
{
/***** Check if the name of the olde field match the new one
(this happens when return is pressed without changes) *****/
if (strcmp (Gbl.CurrentCrs.Records.Field.Name,NewFieldName)) // Different names
{
/***** If the group ya estaba in the database... *****/
if (Rec_CheckIfRecordFieldIsRepeated (NewFieldName))
{
sprintf (Gbl.Message,Txt_The_record_field_X_already_exists,
NewFieldName);
Lay_ShowAlert (Lay_ERROR,Gbl.Message);
}
else
{
/* Update the table of fields changing then old name by the new one */
sprintf (Query,"UPDATE crs_record_fields SET FieldName='%s' WHERE FieldCod='%ld'",
NewFieldName,Gbl.CurrentCrs.Records.Field.FieldCod);
DB_QueryUPDATE (Query,"can not update name of field of record");
/***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_The_record_field_X_has_been_renamed_as_Y,
Gbl.CurrentCrs.Records.Field.Name,NewFieldName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
}
}
else // The same name
{
sprintf (Gbl.Message,Txt_The_name_of_the_field_X_has_not_changed,
NewFieldName);
Lay_ShowAlert (Lay_INFO,Gbl.Message);
}
}
/***** Show the form again *****/
strcpy (Gbl.CurrentCrs.Records.Field.Name,NewFieldName);
Rec_ReqEditRecordFields ();
}
/*****************************************************************************/
/********* Change number of lines of the form of a field of records **********/
/*****************************************************************************/
void Rec_ChangeLinesField (void)
{
extern const char *Txt_The_number_of_editing_lines_in_the_record_field_X_has_not_changed;
extern const char *Txt_From_now_on_the_number_of_editing_lines_of_the_field_X_is_Y;
char Query[1024];
char UnsignedStr[10+1];
unsigned NewNumLines;
/***** Get parameters of the form *****/
/* Get the code of field */
if ((Gbl.CurrentCrs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1)
Lay_ShowErrorAndExit ("Code of field is missing.");
/* Get the new number of lines */
Par_GetParToText ("NumLines",UnsignedStr,10);
NewNumLines = Rec_ConvertToNumLinesField (UnsignedStr);
/* Get from the database the number of lines of the field */
Rec_GetFieldByCod (Gbl.CurrentCrs.Records.Field.FieldCod,Gbl.CurrentCrs.Records.Field.Name,&Gbl.CurrentCrs.Records.Field.NumLines,&Gbl.CurrentCrs.Records.Field.Visibility);
/***** Check if the old number of rows antiguo match the new one
(this happens when return is pressed without changes) *****/
if (Gbl.CurrentCrs.Records.Field.NumLines == NewNumLines)
{
sprintf (Gbl.Message,Txt_The_number_of_editing_lines_in_the_record_field_X_has_not_changed,
Gbl.CurrentCrs.Records.Field.Name);
Lay_ShowAlert (Lay_INFO,Gbl.Message);
}
else
{
/***** Update of the table of fields changing the old maximum of students by the new one *****/
sprintf (Query,"UPDATE crs_record_fields SET NumLines='%u' WHERE FieldCod='%ld'",
NewNumLines,Gbl.CurrentCrs.Records.Field.FieldCod);
DB_QueryUPDATE (Query,"can not update the number of lines of a field of record");
/***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_From_now_on_the_number_of_editing_lines_of_the_field_X_is_Y,
Gbl.CurrentCrs.Records.Field.Name,NewNumLines);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
}
/***** Show the form again *****/
Gbl.CurrentCrs.Records.Field.NumLines = NewNumLines;
Rec_ReqEditRecordFields ();
}
/*****************************************************************************/
/************ Change wisibility by students of a field of records ************/
/*****************************************************************************/
void Rec_ChangeVisibilityField (void)
{
extern const char *Txt_The_visibility_of_the_record_field_X_has_not_changed;
extern const char *Txt_RECORD_FIELD_VISIBILITY_MSG[Rec_NUM_TYPES_VISIBILITY];
char Query[1024];
char UnsignedStr[10+1];
unsigned Vis;
Rec_VisibilityRecordFields_t NewVisibility;
/***** Get parameters of the form *****/
/* Get the code of field */
if ((Gbl.CurrentCrs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1)
Lay_ShowErrorAndExit ("Code of field is missing.");
/* Get the new visibility of the field */
Par_GetParToText ("Visibility",UnsignedStr,10);
if (sscanf (UnsignedStr,"%u",&Vis) != 1)
Lay_ShowErrorAndExit ("Visibility of field is missing.");
if (Vis < Rec_NUM_TYPES_VISIBILITY)
NewVisibility = (Rec_VisibilityRecordFields_t) Vis;
else
NewVisibility = Rec_HIDDEN_FIELD;
/* Get from the database the visibility of the field */
Rec_GetFieldByCod (Gbl.CurrentCrs.Records.Field.FieldCod,Gbl.CurrentCrs.Records.Field.Name,&Gbl.CurrentCrs.Records.Field.NumLines,&Gbl.CurrentCrs.Records.Field.Visibility);
/***** Check if the old visibility matches the new one
(this happens whe return is pressed without changes in the form) *****/
if (Gbl.CurrentCrs.Records.Field.Visibility == NewVisibility)
{
sprintf (Gbl.Message,Txt_The_visibility_of_the_record_field_X_has_not_changed,
Gbl.CurrentCrs.Records.Field.Name);
Lay_ShowAlert (Lay_INFO,Gbl.Message);
}
else
{
/***** Update of the table of fields changing the old visibility by the new *****/
sprintf (Query,"UPDATE crs_record_fields SET Visibility='%u' WHERE FieldCod='%ld'",
(unsigned) NewVisibility,Gbl.CurrentCrs.Records.Field.FieldCod);
DB_QueryUPDATE (Query,"can not update the visibility of a field of record");
/***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_RECORD_FIELD_VISIBILITY_MSG[NewVisibility],
Gbl.CurrentCrs.Records.Field.Name);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
}
/***** Show the form again *****/
Gbl.CurrentCrs.Records.Field.Visibility = NewVisibility;
Rec_ReqEditRecordFields ();
}
/*****************************************************************************/
/********************** Liberar list of fields of records ********************/
/*****************************************************************************/
void Rec_FreeListFields (void)
{
if (Gbl.CurrentCrs.Records.LstFields.NestedCalls > 0)
if (--Gbl.CurrentCrs.Records.LstFields.NestedCalls == 0)
if (Gbl.CurrentCrs.Records.LstFields.Lst)
{
free ((void *) Gbl.CurrentCrs.Records.LstFields.Lst);
Gbl.CurrentCrs.Records.LstFields.Lst = NULL;
Gbl.CurrentCrs.Records.LstFields.Num = 0;
}
}
/*****************************************************************************/
/******************* Put a link to list official students ********************/
/*****************************************************************************/
void Rec_PutLinkToEditRecordFields (void)
{
extern const char *Txt_Edit_record_fields;
/***** Link to edit record fields *****/
2015-12-13 19:02:06 +01:00
Lay_PutContextualLink (ActEdiRecFie,NULL,"edit64x64.png",
Txt_Edit_record_fields,Txt_Edit_record_fields);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/*********************** Draw records of several guests **********************/
/*****************************************************************************/
2015-09-17 16:54:02 +02:00
void Rec_ListRecordsGsts (void)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_You_must_select_one_ore_more_users;
unsigned NumUsrs = 0;
const char *Ptr;
2016-01-17 15:10:54 +01:00
Rec_RecordViewType_t TypeOfView = (Gbl.Action.Act == ActSeeRecSevGst) ? Rec_RECORD_LIST :
2014-12-01 23:55:08 +01:00
Rec_RECORD_PRINT;
struct UsrData UsrDat;
/***** Assign users listing type depending on current action *****/
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_GUESTS;
/***** Get parameter with number of user records per page (only for printing) *****/
2016-01-17 15:10:54 +01:00
if (Gbl.Action.Act == ActPrnRecSevGst)
2014-12-01 23:55:08 +01:00
Rec_GetParamRecordsPerPage ();
/***** Get list of selected users *****/
2015-09-30 23:10:15 +02:00
Usr_GetListsSelectedUsrs ();
2014-12-01 23:55:08 +01:00
/* Check the number of students to show */
2015-09-30 23:10:15 +02:00
if (!Usr_CountNumUsrsInListOfSelectedUsrs ()) // If no students selected...
2014-12-01 23:55:08 +01:00
{ // ...write warning notice
Lay_ShowAlert (Lay_WARNING,Txt_You_must_select_one_ore_more_users);
Usr_SeeGuests (); // ...show again the form
return;
}
2016-01-17 15:10:54 +01:00
if (Gbl.Action.Act == ActSeeRecSevGst)
2014-12-01 23:55:08 +01:00
{
2015-04-02 14:22:21 +02:00
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
2014-12-01 23:55:08 +01:00
/* Link to print view */
2015-09-17 16:54:02 +02:00
Act_FormStart (ActPrnRecSevGst);
Usr_PutHiddenParUsrCodAll (ActPrnRecSevGst,Gbl.Usrs.Select.All);
2014-12-01 23:55:08 +01:00
Rec_ShowLinkToPrintPreviewOfRecords ();
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
}
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
UsrDat.Accepted = false; // Guests have no courses,...
// ...so they have not accepted...
// ...inscription in any course
/***** List the records *****/
Ptr = Gbl.Usrs.Select.All;
while (*Ptr)
{
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student
{
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\""
2015-09-28 18:28:29 +02:00
" style=\"margin-bottom:12px;");
2016-01-17 15:10:54 +01:00
if (Gbl.Action.Act == ActPrnRecSevGst &&
2014-12-01 23:55:08 +01:00
NumUsrs != 0 &&
(NumUsrs % Gbl.Usrs.Listing.RecsPerPag) == 0)
fprintf (Gbl.F.Out,"page-break-before:always;");
fprintf (Gbl.F.Out,"\">");
/* Common record */
2015-03-05 21:42:02 +01:00
Rec_ShowSharedUsrRecord (TypeOfView,&UsrDat);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</div>");
NumUsrs++;
}
}
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
/***** Free list of fields of records *****/
if (Gbl.Usrs.Listing.RecsUsrs == Rec_RECORD_USERS_STUDENTS)
Rec_FreeListFields ();
/***** Free memory used for by the list of users *****/
2015-09-30 23:10:15 +02:00
Usr_FreeListsSelectedUsrCods ();
2014-12-01 23:55:08 +01:00
}
2015-03-05 01:55:46 +01:00
/*****************************************************************************/
/********** Get user's data and draw record of one unique student ************/
/*****************************************************************************/
void Rec_GetUsrAndShowRecordOneStdCrs (void)
{
/***** Get the selected student *****/
2016-01-25 14:40:57 +01:00
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
2015-03-05 01:55:46 +01:00
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // Get from the database the data of the student
if ((Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB =
Rol_GetRoleInCrs (Gbl.CurrentCrs.Crs.CrsCod,
2015-04-07 21:44:24 +02:00
Gbl.Usrs.Other.UsrDat.UsrCod)) == Rol_STUDENT)
2015-03-05 01:55:46 +01:00
Rec_ShowRecordOneStdCrs ();
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/******************** Draw record of one unique student **********************/
/*****************************************************************************/
2015-03-05 18:58:59 +01:00
static void Rec_ShowRecordOneStdCrs (void)
2014-12-01 23:55:08 +01:00
{
2015-03-05 01:55:46 +01:00
/***** Get if student has accepted enrollment in current course *****/
2015-09-17 11:21:49 +02:00
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
true);
2015-03-05 01:55:46 +01:00
2014-12-01 23:55:08 +01:00
/***** Asign users listing type depending on current action *****/
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_STUDENTS;
2015-04-02 14:22:21 +02:00
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
2014-12-01 23:55:08 +01:00
/***** Link to edit record fields *****/
2015-04-07 21:44:24 +02:00
if (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER)
2014-12-01 23:55:08 +01:00
Rec_PutLinkToEditRecordFields ();
/***** Link to print view *****/
Act_FormStart (ActPrnRecSevStd);
Usr_PutHiddenParUsrCodAll (ActPrnRecSevStd,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Rec_ShowLinkToPrintPreviewOfRecords ();
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2014-12-01 23:55:08 +01:00
2015-03-29 22:36:21 +02:00
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
2015-03-29 22:36:21 +02:00
/***** Common record *****/
2015-03-05 21:42:02 +01:00
Rec_ShowSharedUsrRecord (Rec_RECORD_LIST,&Gbl.Usrs.Other.UsrDat);
2014-12-01 23:55:08 +01:00
2015-03-29 22:36:21 +02:00
/***** Record of the student in the course *****/
/* Get list of fields of records in current course */
Rec_GetListRecordFieldsInCurrentCrs ();
2014-12-01 23:55:08 +01:00
2015-03-29 22:36:21 +02:00
if (Gbl.CurrentCrs.Records.LstFields.Num) // There are fields in the record
{
2015-04-07 21:44:24 +02:00
if (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
2015-10-03 21:10:47 +02:00
Rec_ShowCrsRecord (Rec_RECORD_LIST,&Gbl.Usrs.Other.UsrDat,NULL);
else if (Gbl.Usrs.Me.LoggedRole == Rol_STUDENT &&
Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod) // It's me
Rec_ShowCrsRecord (Rec_FORM_MY_COURSE_RECORD_AS_STUDENT,&Gbl.Usrs.Other.UsrDat,NULL);
2015-03-29 22:36:21 +02:00
}
/* Free list of fields of records */
Rec_FreeListFields ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************** Draw records of several students ***********************/
/*****************************************************************************/
2015-10-03 21:10:47 +02:00
void Rec_ListRecordsStdsForEdit (void)
{
Rec_ListRecordsStds (Rec_RECORD_LIST);
}
void Rec_ListRecordsStdsForPrint (void)
{
Rec_ListRecordsStds (Rec_RECORD_PRINT);
}
static void Rec_ListRecordsStds (Rec_RecordViewType_t TypeOfView)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_You_must_select_one_ore_more_students;
2015-10-03 21:10:47 +02:00
unsigned NumUsr = 0;
2014-12-01 23:55:08 +01:00
const char *Ptr;
2015-10-03 21:10:47 +02:00
char Anchor[32];
2014-12-01 23:55:08 +01:00
struct UsrData UsrDat;
/***** Asign users listing type depending on current action *****/
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_STUDENTS;
/***** Get parameter with number of user records per page (only for printing) *****/
2015-10-03 21:10:47 +02:00
if (TypeOfView == Rec_RECORD_PRINT)
2014-12-01 23:55:08 +01:00
Rec_GetParamRecordsPerPage ();
/***** Get list of selected students *****/
2015-09-30 23:10:15 +02:00
Usr_GetListsSelectedUsrs ();
2014-12-01 23:55:08 +01:00
/* Check the number of students to show */
2015-09-30 23:10:15 +02:00
if (!Usr_CountNumUsrsInListOfSelectedUsrs ()) // If no students selected...
2014-12-01 23:55:08 +01:00
{ // ...write warning notice
Lay_ShowAlert (Lay_WARNING,Txt_You_must_select_one_ore_more_students);
Usr_SeeStudents (); // ...show again the form
return;
}
/***** Get list of fields of records in current course *****/
Rec_GetListRecordFieldsInCurrentCrs ();
2015-10-03 21:10:47 +02:00
if (TypeOfView == Rec_RECORD_LIST)
2014-12-01 23:55:08 +01:00
{
2015-04-02 14:22:21 +02:00
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
2014-12-01 23:55:08 +01:00
/* Link to edit record fields */
2015-04-07 21:44:24 +02:00
if (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER)
2014-12-01 23:55:08 +01:00
Rec_PutLinkToEditRecordFields ();
/* Link to print view */
Act_FormStart (ActPrnRecSevStd);
Usr_PutHiddenParUsrCodAll (ActPrnRecSevStd,Gbl.Usrs.Select.All);
Rec_ShowLinkToPrintPreviewOfRecords ();
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
}
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
/***** List the records *****/
Ptr = Gbl.Usrs.Select.All;
while (*Ptr)
{
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student
2015-09-17 11:21:49 +02:00
if (Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
false))
2014-12-01 23:55:08 +01:00
{
2015-10-03 21:10:47 +02:00
/* Check if this student has accepted
his/her inscription in the current course */
2015-09-17 11:21:49 +02:00
UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
true);
2014-12-01 23:55:08 +01:00
2015-10-03 21:10:47 +02:00
/* Start records of this student */
sprintf (Anchor,"record_%u",NumUsr);
fprintf (Gbl.F.Out,"<section id=\"%s\""
" class=\"CENTER_MIDDLE\""
" style=\"margin-bottom:12px;",
Anchor);
2016-01-17 15:10:54 +01:00
if (Gbl.Action.Act == ActPrnRecSevStd &&
2015-10-03 21:10:47 +02:00
NumUsr != 0 &&
(NumUsr % Gbl.Usrs.Listing.RecsPerPag) == 0)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"page-break-before:always;");
fprintf (Gbl.F.Out,"\">");
/* Common record */
2015-03-05 21:42:02 +01:00
Rec_ShowSharedUsrRecord (TypeOfView,&UsrDat);
2014-12-01 23:55:08 +01:00
/* Record of the student in the course */
2015-07-17 13:06:32 +02:00
if (Gbl.CurrentCrs.Records.LstFields.Num) // There are fields in the record
2015-10-03 21:10:47 +02:00
if ( Gbl.Usrs.Me.LoggedRole == Rol_TEACHER ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
(Gbl.Usrs.Me.LoggedRole == Rol_STUDENT && // I am student in this course...
Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat.UsrCod)) // ...and it's me
Rec_ShowCrsRecord (TypeOfView,&UsrDat,Anchor);
2014-12-01 23:55:08 +01:00
2015-10-03 21:10:47 +02:00
fprintf (Gbl.F.Out,"</section>");
2014-12-01 23:55:08 +01:00
2015-10-03 21:10:47 +02:00
NumUsr++;
2014-12-01 23:55:08 +01:00
}
}
2015-09-17 11:21:49 +02:00
2014-12-01 23:55:08 +01:00
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
/***** Free list of fields of records *****/
2015-10-03 21:10:47 +02:00
// if (Gbl.Usrs.Listing.RecsUsrs == Rec_RECORD_USERS_STUDENTS)
2014-12-01 23:55:08 +01:00
Rec_FreeListFields ();
/***** Free memory used for by the list of users *****/
2015-09-30 23:10:15 +02:00
Usr_FreeListsSelectedUsrCods ();
2014-12-01 23:55:08 +01:00
}
2015-03-05 01:55:46 +01:00
/*****************************************************************************/
/********** Get user's data and draw record of one unique teacher ************/
/*****************************************************************************/
void Rec_GetUsrAndShowRecordOneTchCrs (void)
{
/***** Get the selected teacher *****/
2016-01-25 14:40:57 +01:00
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
2015-03-05 01:55:46 +01:00
/***** Show the record *****/
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // Get from the database the data of the teacher
if ((Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB =
Rol_GetRoleInCrs (Gbl.CurrentCrs.Crs.CrsCod,
2015-04-07 21:44:24 +02:00
Gbl.Usrs.Other.UsrDat.UsrCod)) == Rol_TEACHER)
2015-03-05 01:55:46 +01:00
Rec_ShowRecordOneTchCrs ();
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/******************** Draw record of one unique teacher **********************/
/*****************************************************************************/
2015-03-05 18:58:59 +01:00
static void Rec_ShowRecordOneTchCrs (void)
2014-12-01 23:55:08 +01:00
{
2015-01-02 12:57:26 +01:00
extern const char *Txt_TIMETABLE_TYPES[TT_NUM_TIMETABLE_TYPES];
2015-12-01 01:09:55 +01:00
char Width[10+2+1];
/***** Width for office hours *****/
2015-12-13 17:49:53 +01:00
sprintf (Width,"%upx",Rec_RECORD_WIDTH);
2014-12-01 23:55:08 +01:00
2015-03-05 01:55:46 +01:00
/***** Get if teacher has accepted enrollment in current course *****/
2015-09-17 11:21:49 +02:00
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
true);
2015-03-05 01:55:46 +01:00
2014-12-01 23:55:08 +01:00
/***** Asign users listing type depending on current action *****/
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_TEACHERS;
2015-04-02 14:22:21 +02:00
/***** Show contextual menu *****/
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
2014-12-01 23:55:08 +01:00
2015-04-02 14:22:21 +02:00
/* Show office hours? */
2014-12-01 23:55:08 +01:00
Rec_WriteFormShowOfficeHours (true,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
2015-04-02 14:22:21 +02:00
/* Link to print view */
2014-12-01 23:55:08 +01:00
Act_FormStart (ActPrnRecSevTch);
Usr_PutHiddenParUsrCodAll (ActPrnRecSevTch,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Par_PutHiddenParamChar ("ParamOfficeHours",'Y');
Par_PutHiddenParamChar ("ShowOfficeHours",'Y');
Rec_ShowLinkToPrintPreviewOfRecords ();
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2015-04-02 14:22:21 +02:00
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\""
2015-09-28 18:28:29 +02:00
" style=\"margin-bottom:12px;\">");
2014-12-01 23:55:08 +01:00
2015-03-05 01:55:46 +01:00
/* Common record */
2015-03-05 21:42:02 +01:00
Rec_ShowSharedUsrRecord (Rec_RECORD_LIST,&Gbl.Usrs.Other.UsrDat);
2014-12-01 23:55:08 +01:00
2015-03-05 01:55:46 +01:00
/* Office hours */
2016-03-18 14:07:21 +01:00
Gbl.TimeTable.Type = TT_TUTOR_TIMETABLE;
Lay_StartRoundFrame (Width,Txt_TIMETABLE_TYPES[Gbl.TimeTable.Type],NULL);
TT_ShowTimeTable (Gbl.Usrs.Other.UsrDat.UsrCod);
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrame ();
2014-12-01 23:55:08 +01:00
2015-03-05 01:55:46 +01:00
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************** Draw records of several teachers ***********************/
/*****************************************************************************/
2015-09-17 16:54:02 +02:00
void Rec_ListRecordsTchs (void)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_You_must_select_one_ore_more_teachers;
2015-01-02 12:57:26 +01:00
extern const char *Txt_TIMETABLE_TYPES[TT_NUM_TIMETABLE_TYPES];
2014-12-01 23:55:08 +01:00
unsigned NumUsrs = 0;
const char *Ptr;
2016-01-17 15:10:54 +01:00
Rec_RecordViewType_t TypeOfView = (Gbl.Action.Act == ActSeeRecSevTch) ? Rec_RECORD_LIST :
2014-12-01 23:55:08 +01:00
Rec_RECORD_PRINT;
struct UsrData UsrDat;
bool ShowOfficeHours;
2015-12-01 01:09:55 +01:00
char Width[10+2+1];
/***** Width for office hours *****/
2015-12-13 17:49:53 +01:00
sprintf (Width,"%upx",Rec_RECORD_WIDTH);
2014-12-01 23:55:08 +01:00
/***** Asign users listing type depending on current action *****/
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_TEACHERS;
/***** Get if I want to see teachers' office hours in teachers' records *****/
ShowOfficeHours = Rec_GetParamShowOfficeHours ();
/***** Get parameter with number of user records per page (only for printing) *****/
2016-01-17 15:10:54 +01:00
if (Gbl.Action.Act == ActPrnRecSevTch)
2014-12-01 23:55:08 +01:00
Rec_GetParamRecordsPerPage ();
/***** Get list of selected teachers *****/
2015-09-30 23:10:15 +02:00
Usr_GetListsSelectedUsrs ();
2014-12-01 23:55:08 +01:00
/* Check the number of teachers to show */
2015-09-30 23:10:15 +02:00
if (!Usr_CountNumUsrsInListOfSelectedUsrs ()) // If no teachers selected...
2014-12-01 23:55:08 +01:00
{ // ...write warning notice
Lay_ShowAlert (Lay_WARNING,Txt_You_must_select_one_ore_more_teachers);
Usr_SeeTeachers (); // ...show again the form
return;
}
2016-01-17 15:10:54 +01:00
if (Gbl.Action.Act == ActSeeRecSevTch)
2014-12-01 23:55:08 +01:00
{
2015-04-02 14:22:21 +02:00
/***** Show contextual menu *****/
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
2014-12-01 23:55:08 +01:00
/* Show office hours? */
Rec_WriteFormShowOfficeHours (ShowOfficeHours,Gbl.Usrs.Select.All);
/* Link to print view */
Act_FormStart (ActPrnRecSevTch);
Usr_PutHiddenParUsrCodAll (ActPrnRecSevTch,Gbl.Usrs.Select.All);
Par_PutHiddenParamChar ("ParamOfficeHours",'Y');
Par_PutHiddenParamChar ("ShowOfficeHours",
ShowOfficeHours ? 'Y' :
'N');
Rec_ShowLinkToPrintPreviewOfRecords ();
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2015-04-02 14:22:21 +02:00
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
}
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
/***** List the records *****/
Ptr = Gbl.Usrs.Select.All;
while (*Ptr)
{
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student
2015-09-17 11:21:49 +02:00
if (Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
false))
2014-12-01 23:55:08 +01:00
{
2015-09-17 11:21:49 +02:00
UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
true);
2014-12-01 23:55:08 +01:00
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\""
2015-09-28 18:28:29 +02:00
" style=\"margin-bottom:12px;");
2016-01-17 15:10:54 +01:00
if (Gbl.Action.Act == ActPrnRecSevTch &&
2014-12-01 23:55:08 +01:00
NumUsrs != 0 &&
(NumUsrs % Gbl.Usrs.Listing.RecsPerPag) == 0)
fprintf (Gbl.F.Out,"page-break-before:always;");
fprintf (Gbl.F.Out,"\">");
/* Common record */
2015-03-05 21:42:02 +01:00
Rec_ShowSharedUsrRecord (TypeOfView,&UsrDat);
2014-12-01 23:55:08 +01:00
/* Office hours */
if (ShowOfficeHours)
{
2016-03-18 14:07:21 +01:00
Gbl.TimeTable.Type = TT_TUTOR_TIMETABLE;
Lay_StartRoundFrame (Width,Txt_TIMETABLE_TYPES[Gbl.TimeTable.Type],NULL);
TT_ShowTimeTable (UsrDat.UsrCod);
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrame ();
2014-12-01 23:55:08 +01:00
}
fprintf (Gbl.F.Out,"</div>");
NumUsrs++;
}
}
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
/***** Free memory used for by the list of users *****/
2015-09-30 23:10:15 +02:00
Usr_FreeListsSelectedUsrCods ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/*************** Show a link to print preview of users' records **************/
/*****************************************************************************/
2015-10-03 21:10:47 +02:00
static void Rec_ShowLinkToPrintPreviewOfRecords (void)
2014-12-01 23:55:08 +01:00
{
2015-07-27 21:25:45 +02:00
extern const char *The_ClassFormBold[The_NUM_THEMES];
2015-07-28 00:16:09 +02:00
extern const char *The_ClassForm[The_NUM_THEMES];
2015-01-28 01:14:14 +01:00
extern const char *Txt_Print;
2014-12-01 23:55:08 +01:00
extern const char *Txt_record_cards_per_page;
unsigned i;
2015-07-27 21:25:45 +02:00
Act_LinkFormSubmit (Txt_Print,The_ClassFormBold[Gbl.Prefs.Theme]);
2015-12-08 22:20:44 +01:00
Lay_PutIconWithText ("print64x64.png",Txt_Print,Txt_Print);
2015-12-13 18:32:37 +01:00
fprintf (Gbl.F.Out,"</a>"
"<span class=\"%s\">(</span>"
2014-12-01 23:55:08 +01:00
"<select name=\"RecsPerPag\">",
2015-07-28 00:16:09 +02:00
The_ClassForm[Gbl.Prefs.Theme]);
2014-12-01 23:55:08 +01:00
for (i = 1;
i <= 10;
i++)
{
fprintf (Gbl.F.Out,"<option");
if (i == Gbl.Usrs.Listing.RecsPerPag)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%u</option>",i);
}
fprintf (Gbl.F.Out,"</select>"
"<span class=\"%s\"> %s)</span>",
2015-07-28 00:16:09 +02:00
The_ClassForm[Gbl.Prefs.Theme],Txt_record_cards_per_page);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/** Get parameter with number of user records per page (only for printing) ***/
/*****************************************************************************/
static void Rec_GetParamRecordsPerPage (void)
{
char UnsignedStr[10+1];
Par_GetParToText ("RecsPerPag",UnsignedStr,10);
if (sscanf (UnsignedStr,"%u",&Gbl.Usrs.Listing.RecsPerPag) != 1)
Lay_ShowErrorAndExit ("Number of rows per page is missing.");
}
/*****************************************************************************/
/************** Write a form to select whether show full tree ****************/
/*****************************************************************************/
static void Rec_WriteFormShowOfficeHours (bool ShowOfficeHours,const char *ListUsrCods)
{
2015-07-28 00:16:09 +02:00
extern const char *The_ClassForm[The_NUM_THEMES];
2014-12-01 23:55:08 +01:00
extern const char *Txt_Show_office_hours;
/***** Start form *****/
Act_FormStart (ActSeeRecSevTch);
Usr_PutHiddenParUsrCodAll (ActSeeRecSevTch,ListUsrCods);
Par_PutHiddenParamChar ("ParamOfficeHours",'Y');
/***** End form *****/
2015-09-28 18:28:29 +02:00
fprintf (Gbl.F.Out,"<div style=\"margin:0 6px; display:inline;\">"
2015-04-02 14:22:21 +02:00
"<input type=\"checkbox\" name=\"ShowOfficeHours\" value=\"Y\"");
2014-12-01 23:55:08 +01:00
if (ShowOfficeHours)
fprintf (Gbl.F.Out," checked=\"checked\"");
2015-09-05 11:48:44 +02:00
fprintf (Gbl.F.Out," class=\"LEFT_MIDDLE\""
2015-10-22 14:49:48 +02:00
" onclick=\"document.getElementById('%s').submit();\" />"
2015-12-26 21:46:56 +01:00
"<img src=\"%s/clock64x64.gif\""
2015-07-22 13:49:39 +02:00
" alt=\"%s\" title=\"%s\""
2015-12-13 12:51:41 +01:00
" class=\"ICON20x20\" />"
2015-04-02 14:22:21 +02:00
"<span class=\"%s\">&nbsp;%s</span>"
"</div>",
2016-01-14 10:31:09 +01:00
Gbl.Form.Id,
2014-12-01 23:55:08 +01:00
Gbl.Prefs.IconsURL,
Txt_Show_office_hours,
2015-07-22 13:49:39 +02:00
Txt_Show_office_hours,
2015-07-28 00:16:09 +02:00
The_ClassForm[Gbl.Prefs.Theme],
2014-12-01 23:55:08 +01:00
Txt_Show_office_hours);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********** Get parameter to show (or not) teachers' office hours ************/
/*****************************************************************************/
// Returns true if office hours must be shown
static bool Rec_GetParamShowOfficeHours (void)
{
char YN[1+1];
Par_GetParToText ("ParamOfficeHours",YN,1);
if (Str_ConvertToUpperLetter (YN[0]) == 'Y')
{
Par_GetParToText ("ShowOfficeHours",YN,1);
return (Str_ConvertToUpperLetter (YN[0]) == 'Y');
}
return Rec_SHOW_OFFICE_HOURS_DEFAULT;
}
/*****************************************************************************/
/*************** Update my record in the course and show it ******************/
/*****************************************************************************/
void Rec_UpdateAndShowMyCrsRecord (void)
{
/***** Get list of fields of records in current course *****/
Rec_GetListRecordFieldsInCurrentCrs ();
/***** Allocate memory for the texts of the fields *****/
Rec_AllocMemFieldsRecordsCrs ();
/***** Get data of the record from the form *****/
Rec_GetFieldsCrsRecordFromForm ();
/***** Update the record *****/
Rec_UpdateCrsRecord (Gbl.Usrs.Me.UsrDat.UsrCod);
/***** Show updated record *****/
Rec_ShowMyCrsRecordUpdated ();
/***** Free memory used for some fields *****/
Rec_FreeMemFieldsRecordsCrs ();
}
/*****************************************************************************/
2015-10-03 21:10:47 +02:00
/***** Update record in the course of one student and show records again *****/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
void Rec_UpdateAndShowOtherCrsRecord (void)
{
2015-10-03 21:10:47 +02:00
extern const char *Txt_Student_record_card_in_this_course_has_been_updated;
2014-12-01 23:55:08 +01:00
2015-10-03 21:10:47 +02:00
/***** Get the user whose record we want to modify *****/
2016-01-25 14:40:57 +01:00
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
2014-12-01 23:55:08 +01:00
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat);
/***** Get list of fields of records in current course *****/
Rec_GetListRecordFieldsInCurrentCrs ();
/***** Allocate memory for the texts of the fields *****/
Rec_AllocMemFieldsRecordsCrs ();
/***** Get data of the record from the form *****/
Rec_GetFieldsCrsRecordFromForm ();
/***** Update the record *****/
Rec_UpdateCrsRecord (Gbl.Usrs.Other.UsrDat.UsrCod);
2015-10-03 21:10:47 +02:00
/***** Show records again (including the updated one) *****/
Lay_ShowAlert (Lay_SUCCESS,Txt_Student_record_card_in_this_course_has_been_updated);
Rec_ListRecordsStdsForEdit ();
2014-12-01 23:55:08 +01:00
/***** Free memory used for some fields *****/
Rec_FreeMemFieldsRecordsCrs ();
}
/*****************************************************************************/
/**************************** Show record common *****************************/
/*****************************************************************************/
// Show form or only data depending on TypeOfView
2015-10-03 21:10:47 +02:00
static void Rec_ShowCrsRecord (Rec_RecordViewType_t TypeOfView,struct UsrData *UsrDat,
const char *Anchor)
2014-12-01 23:55:08 +01:00
{
2015-07-28 00:16:09 +02:00
extern const char *The_ClassForm[The_NUM_THEMES];
2015-07-17 13:06:32 +02:00
extern const char *Txt_You_dont_have_permission_to_perform_this_action;
2014-12-01 23:55:08 +01:00
extern const char *Txt_RECORD_FIELD_VISIBILITY_RECORD[Rec_NUM_TYPES_VISIBILITY];
2015-03-24 17:47:26 +01:00
extern const char *Txt_Save;
2014-12-01 23:55:08 +01:00
char StrRecordWidth[10+1];
2015-09-24 18:02:21 +02:00
unsigned FrameWidth = 15;
unsigned Col1Width = 210;
2014-12-01 23:55:08 +01:00
unsigned Col2Width;
2015-07-17 13:06:32 +02:00
bool ItsMe;
2014-12-01 23:55:08 +01:00
bool DataForm = false;
unsigned NumField;
MYSQL_RES *mysql_res;
MYSQL_ROW row = NULL; // Initialized to avoid warning
2015-07-17 13:06:32 +02:00
bool ShowField;
2014-12-01 23:55:08 +01:00
bool ThisFieldHasText;
bool ICanEdit;
char Text[Cns_MAX_BYTES_TEXT+1];
2015-07-17 13:06:32 +02:00
if (Gbl.Usrs.Me.LoggedRole == Rol_STUDENT) // I am a student
{
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod); // It's me
if (ItsMe) // It's me
switch (TypeOfView)
{
case Rec_RECORD_LIST:
// When listing several records,
// only my record in course in allowed
// ==> show form to edit my record as student
TypeOfView = Rec_FORM_MY_COURSE_RECORD_AS_STUDENT;
break;
case Rec_FORM_MY_COURSE_RECORD_AS_STUDENT:
case Rec_CHECK_MY_COURSE_RECORD_AS_STUDENT:
case Rec_RECORD_PRINT:
break;
default:
Lay_ShowErrorAndExit (Txt_You_dont_have_permission_to_perform_this_action);
break;
}
else // It's not me ==> i am a student trying to do something forbidden
Lay_ShowErrorAndExit (Txt_You_dont_have_permission_to_perform_this_action);
}
2014-12-01 23:55:08 +01:00
switch (TypeOfView)
{
2015-07-17 13:06:32 +02:00
case Rec_FORM_MY_COURSE_RECORD_AS_STUDENT:
2014-12-01 23:55:08 +01:00
for (NumField = 0;
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
NumField++)
if (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
{
DataForm = true;
Act_FormStart (ActRcvRecCrs);
break;
}
2015-03-18 19:52:07 +01:00
FrameWidth = 10;
2014-12-01 23:55:08 +01:00
break;
2015-07-17 13:06:32 +02:00
case Rec_CHECK_MY_COURSE_RECORD_AS_STUDENT:
2015-03-18 19:52:07 +01:00
FrameWidth = 10;
2014-12-01 23:55:08 +01:00
break;
case Rec_RECORD_LIST:
DataForm = true;
2015-10-03 21:10:47 +02:00
Act_FormStartAnchor (ActRcvRecOthUsr,Anchor);
Usr_PutHiddenParUsrCodAll (ActRcvRecOthUsr,Gbl.Usrs.Select.All);
2015-04-02 18:39:49 +02:00
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
2015-03-18 19:52:07 +01:00
FrameWidth = 10;
2014-12-01 23:55:08 +01:00
break;
case Rec_RECORD_PRINT:
2015-03-18 19:52:07 +01:00
FrameWidth = 1;
2014-12-01 23:55:08 +01:00
break;
default:
break;
}
2015-12-13 17:49:53 +01:00
Col2Width = Rec_RECORD_WIDTH - FrameWidth * 2 - Col1Width;
2014-12-01 23:55:08 +01:00
2014-12-08 17:35:48 +01:00
/***** Start frame *****/
2015-12-13 17:49:53 +01:00
sprintf (StrRecordWidth,"%upx",Rec_RECORD_WIDTH);
2015-04-12 18:01:06 +02:00
Lay_StartRoundFrameTable (StrRecordWidth,2,NULL);
2014-12-01 23:55:08 +01:00
/***** Header *****/
fprintf (Gbl.F.Out,"<tr>"
2015-08-24 11:25:20 +02:00
"<td colspan=\"2\" class=\"LEFT_TOP\">"
2014-12-22 01:31:23 +01:00
"<table style=\"width:100%%;\">"
2014-12-01 23:55:08 +01:00
"<tr>"
2015-09-24 18:02:21 +02:00
"<td class=\"LEFT_MIDDLE\" style=\"width:%upx;\">",
2014-12-01 23:55:08 +01:00
Rec_DEGREE_LOGO_SIZE);
2015-02-01 20:17:24 +01:00
Log_DrawLogo (Sco_SCOPE_DEG,Gbl.CurrentDeg.Deg.DegCod,
2015-01-18 11:46:39 +01:00
Gbl.CurrentDeg.Deg.ShortName,Rec_DEGREE_LOGO_SIZE,NULL,true);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_HEAD CENTER_MIDDLE\">"
2014-12-01 23:55:08 +01:00
"%s<br />%s<br />%s"
"</td>"
"</tr>"
"</table>"
"</td>"
"</tr>",
Gbl.CurrentDeg.Deg.FullName,Gbl.CurrentCrs.Crs.FullName,
UsrDat->FullName);
/***** Fields of the record that depends on the course *****/
for (NumField = 0, Gbl.RowEvenOdd = 0;
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
NumField++, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd)
2015-07-17 13:06:32 +02:00
{
ShowField = !(TypeOfView == Rec_FORM_MY_COURSE_RECORD_AS_STUDENT ||
TypeOfView == Rec_CHECK_MY_COURSE_RECORD_AS_STUDENT) ||
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility != Rec_HIDDEN_FIELD;
// If the field must be shown...
if (ShowField)
2014-12-01 23:55:08 +01:00
{
ICanEdit = TypeOfView == Rec_RECORD_LIST ||
2015-07-17 13:06:32 +02:00
(TypeOfView == Rec_FORM_MY_COURSE_RECORD_AS_STUDENT &&
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD);
/* Name of the field */
fprintf (Gbl.F.Out,"<tr>"
2015-12-13 17:49:53 +01:00
"<td class=\"%s RIGHT_TOP COLOR%u\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2014-12-24 19:11:42 +01:00
"%s:",
2015-07-28 00:16:09 +02:00
ICanEdit ? The_ClassForm[Gbl.Prefs.Theme] :
2015-12-13 13:53:00 +01:00
"REC_DAT_SMALL",
2015-09-24 18:02:21 +02:00
Gbl.RowEvenOdd,Col1Width,
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Name);
if (TypeOfView == Rec_RECORD_LIST)
fprintf (Gbl.F.Out,"<span class=\"DAT_SMALL\"> (%s)</span>",
Txt_RECORD_FIELD_VISIBILITY_RECORD[Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility]);
fprintf (Gbl.F.Out,"</td>");
/***** Get the text of the field *****/
if (Rec_GetFieldFromCrsRecord (UsrDat->UsrCod,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod,&mysql_res))
{
ThisFieldHasText = true;
row = mysql_fetch_row (mysql_res);
}
else
ThisFieldHasText = false;
2015-12-13 17:49:53 +01:00
/***** Write form, text, or nothing depending on
the user's role and the visibility of the field *****/
fprintf (Gbl.F.Out,"<td class=\"REC_DAT_BOLD LEFT_TOP COLOR%u\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
Gbl.RowEvenOdd,Col2Width);
2014-12-01 23:55:08 +01:00
if (ICanEdit) // Show with form
{
fprintf (Gbl.F.Out,"<textarea name=\"Field%ld\" rows=\"%u\""
2015-09-28 18:28:29 +02:00
" style=\"width:450px;\">",
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod,
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].NumLines);
if (ThisFieldHasText)
fprintf (Gbl.F.Out,"%s",row[0]);
fprintf (Gbl.F.Out,"</textarea>");
}
else // Show without form
{
if (ThisFieldHasText)
{
strcpy (Text,row[0]);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Text,Cns_MAX_BYTES_TEXT,false);
fprintf (Gbl.F.Out,"%s",Text);
}
else
fprintf (Gbl.F.Out,"-");
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
2015-07-17 13:06:32 +02:00
}
2014-12-01 23:55:08 +01:00
2015-04-11 23:46:21 +02:00
/***** Button to save changes and end frame *****/
2014-12-01 23:55:08 +01:00
if (DataForm)
{
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTableWithButton (Lay_CONFIRM_BUTTON,Txt_Save);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2014-12-01 23:55:08 +01:00
}
2015-04-11 23:46:21 +02:00
else
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************** Get the text of a field of a record of course ****************/
/*****************************************************************************/
unsigned long Rec_GetFieldFromCrsRecord (long UsrCod,long FieldCod,MYSQL_RES **mysql_res)
{
char Query[512];
/***** Get the text of a field of a record from database *****/
sprintf (Query,"SELECT Txt FROM crs_records"
" WHERE FieldCod='%ld' AND UsrCod='%ld'",
FieldCod,UsrCod);
return DB_QuerySELECT (Query,mysql_res,"can not get the text of a field of a record.");
}
/*****************************************************************************/
/****************** Get the fields of the record from form *******************/
/*****************************************************************************/
void Rec_GetFieldsCrsRecordFromForm (void)
{
unsigned NumField;
char FieldParamName[5+10+1];
for (NumField = 0;
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
NumField++)
2015-04-07 21:44:24 +02:00
if (Gbl.Usrs.Me.LoggedRole > Rol_STUDENT ||
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
{
/* Get text of the form */
sprintf (FieldParamName,"Field%ld",Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
Par_GetParToHTML (FieldParamName,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text,Cns_MAX_BYTES_TEXT);
}
}
/*****************************************************************************/
/*************************** Update record of a user *************************/
/*****************************************************************************/
void Rec_UpdateCrsRecord (long UsrCod)
{
unsigned NumField;
char Query[256+Cns_MAX_BYTES_TEXT];
MYSQL_RES *mysql_res;
bool FieldAlreadyExists;
for (NumField = 0;
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
NumField++)
2015-04-07 21:44:24 +02:00
if (Gbl.Usrs.Me.LoggedRole > Rol_STUDENT ||
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
{
/***** Check if already exists this field for this user in database *****/
FieldAlreadyExists = (Rec_GetFieldFromCrsRecord (UsrCod,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod,&mysql_res) != 0);
DB_FreeMySQLResult (&mysql_res);
if (FieldAlreadyExists)
{
if (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text[0])
{
/***** Update text of the field of record course *****/
sprintf (Query,"UPDATE crs_records SET Txt='%s'"
" WHERE UsrCod='%ld' AND FieldCod='%ld'",
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text,UsrCod,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
DB_QueryUPDATE (Query,"can not update field of record");
}
else
{
/***** Remove text of the field of record course *****/
sprintf (Query,"DELETE FROM crs_records"
" WHERE UsrCod='%ld' AND FieldCod='%ld'",
UsrCod,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
DB_QueryDELETE (Query,"can not remove field of record");
}
}
else if (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text[0])
{
/***** Insert text field of record course *****/
sprintf (Query,"INSERT INTO crs_records (FieldCod,UsrCod,Txt)"
" VALUES ('%ld','%ld','%s')",
2014-12-27 13:49:17 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod,
UsrCod,
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text);
2014-12-01 23:55:08 +01:00
DB_QueryINSERT (Query,"can not create field of record");
}
}
}
/*****************************************************************************/
/************ Remove fields of record of a user in current course ************/
/*****************************************************************************/
void Rec_RemoveFieldsCrsRecordInCrs (long UsrCod,struct Course *Crs,Cns_QuietOrVerbose_t QuietOrVerbose)
{
extern const char *Txt_User_record_card_in_the_course_X_has_been_removed;
char Query[512];
/***** Remove text of the field of record course *****/
sprintf (Query,"DELETE FROM crs_records WHERE UsrCod='%ld' AND FieldCod IN"
" (SELECT FieldCod FROM crs_record_fields WHERE CrsCod='%ld')",
UsrCod,Crs->CrsCod);
DB_QueryDELETE (Query,"can not remove user's record in a course");
/***** Write mensaje *****/
if (QuietOrVerbose == Cns_VERBOSE)
{
sprintf (Gbl.Message,Txt_User_record_card_in_the_course_X_has_been_removed,
Crs->FullName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
}
}
/*****************************************************************************/
/************* Remove fields of record of a user in all courses **************/
/*****************************************************************************/
void Rec_RemoveFieldsCrsRecordAll (long UsrCod,Cns_QuietOrVerbose_t QuietOrVerbose)
{
extern const char *Txt_User_record_cards_in_all_courses_have_been_removed;
char Query[128];
/***** Remove text of the field of record course *****/
sprintf (Query,"DELETE FROM crs_records WHERE UsrCod='%ld'",UsrCod);
DB_QueryDELETE (Query,"can not remove user's records in all courses");
/***** Write mensaje *****/
if (QuietOrVerbose == Cns_VERBOSE)
Lay_ShowAlert (Lay_SUCCESS,Txt_User_record_cards_in_all_courses_have_been_removed);
}
/*****************************************************************************/
/*************** Show my record in the course already updated ****************/
/*****************************************************************************/
2015-03-30 13:59:32 +02:00
static void Rec_ShowMyCrsRecordUpdated (void)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_Your_record_card_in_this_course_has_been_updated;
2015-03-30 14:51:32 +02:00
/***** Write mensaje of success *****/
2014-12-01 23:55:08 +01:00
Lay_ShowAlert (Lay_SUCCESS,Txt_Your_record_card_in_this_course_has_been_updated);
2015-03-30 14:51:32 +02:00
/***** Common record *****/
Rec_ShowSharedUsrRecord (Rec_RECORD_LIST,&Gbl.Usrs.Me.UsrDat);
/***** Show updated user's record *****/
2015-10-03 21:10:47 +02:00
Rec_ShowCrsRecord (Rec_CHECK_MY_COURSE_RECORD_AS_STUDENT,&Gbl.Usrs.Me.UsrDat,NULL);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/***** Allocate memory for the text of the field of the record in course *****/
/*****************************************************************************/
void Rec_AllocMemFieldsRecordsCrs (void)
{
unsigned NumField;
for (NumField = 0;
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
NumField++)
2015-04-07 21:44:24 +02:00
if (Gbl.Usrs.Me.LoggedRole > Rol_STUDENT ||
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
/* Allocate memory for the texts of the fields */
if ((Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store records of the course.");
}
/*****************************************************************************/
/**** Free memory used by the texts of the field of the record in course *****/
/*****************************************************************************/
void Rec_FreeMemFieldsRecordsCrs (void)
{
unsigned NumField;
for (NumField = 0;
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
NumField++)
2015-04-07 21:44:24 +02:00
if (Gbl.Usrs.Me.LoggedRole > Rol_STUDENT ||
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
/* Free memory of the text of the field */
if (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text)
{
free ((void *) Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text);
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text = NULL;
}
}
/*****************************************************************************/
/************ Show form to sign up and edit my common record *****************/
/*****************************************************************************/
void Rec_ShowFormSignUpWithMyCommonRecord (void)
{
extern const char *Txt_Sign_up;
/***** Show the form *****/
Act_FormStart (ActSignUp);
2015-03-05 21:42:02 +01:00
Rec_ShowSharedUsrRecord (Rec_FORM_SIGN_UP,&Gbl.Usrs.Me.UsrDat);
2015-03-24 17:47:26 +01:00
Lay_PutConfirmButton (Txt_Sign_up);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************* Show form to edit my common record **********************/
/*****************************************************************************/
void Rec_ShowFormMyCommRecord (void)
{
2015-03-28 18:34:08 +01:00
extern const char *Txt_Please_fill_in_your_record_card_including_your_country_nationality;
extern const char *Txt_Please_fill_in_your_record_card_including_your_sex;
extern const char *Txt_Please_fill_in_your_record_card_including_your_name;
2014-12-01 23:55:08 +01:00
/***** If user has no sex, name and surname... *****/
2015-03-28 18:34:08 +01:00
if (Gbl.Usrs.Me.UsrDat.CtyCod < 0)
Lay_ShowAlert (Lay_WARNING,Txt_Please_fill_in_your_record_card_including_your_country_nationality);
else if (Gbl.Usrs.Me.UsrDat.Sex == Usr_SEX_UNKNOWN)
Lay_ShowAlert (Lay_WARNING,Txt_Please_fill_in_your_record_card_including_your_sex);
else if (!Gbl.Usrs.Me.UsrDat.FirstName[0] ||
!Gbl.Usrs.Me.UsrDat.Surname1[0])
Lay_ShowAlert (Lay_WARNING,Txt_Please_fill_in_your_record_card_including_your_name);
2014-12-01 23:55:08 +01:00
2016-01-04 16:45:43 +01:00
/***** Contextual links *****/
2015-04-02 14:22:21 +02:00
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
2014-12-01 23:55:08 +01:00
Rec_PutLinkToChangeMyInsCtrDpt (); // Put link (form) to change my institution, centre, department...
2016-01-04 16:45:43 +01:00
Net_PutLinkToChangeMySocialNetworks (); // Put link (form) to change my social networks
2015-04-02 18:39:49 +02:00
Pho_PutLinkToChangeMyPhoto (); // Put link (form) to change my photo
2015-03-06 22:36:29 +01:00
Pri_PutLinkToChangeMyPrivacy (); // Put link (form) to change my privacy
2015-04-02 13:38:05 +02:00
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
/***** My record *****/
2015-03-05 21:42:02 +01:00
Rec_ShowSharedUsrRecord (Rec_FORM_MY_COMMON_RECORD,&Gbl.Usrs.Me.UsrDat);
2014-12-01 23:55:08 +01:00
Rec_WriteLinkToDataProtectionClause ();
}
/*****************************************************************************/
/*************** Show form to edit the record of a new user ******************/
/*****************************************************************************/
void Rec_ShowFormOtherNewCommonRecord (struct UsrData *UsrDat)
{
/***** Show the form *****/
2015-03-05 21:42:02 +01:00
Rec_ShowSharedUsrRecord (Rec_FORM_NEW_RECORD_OTHER_NEW_USR,UsrDat);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/*********************** Show my record after update *************************/
/*****************************************************************************/
void Rec_ShowMyCommonRecordUpd (void)
{
extern const char *Txt_Your_personal_data_have_been_updated;
/***** Write alert *****/
Lay_ShowAlert (Lay_SUCCESS,Txt_Your_personal_data_have_been_updated);
/***** Show my record for checking *****/
2015-03-05 21:42:02 +01:00
Rec_ShowSharedUsrRecord (Rec_MY_COMMON_RECORD_CHECK,&Gbl.Usrs.Me.UsrDat);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********************** Show user's record for check *************************/
/*****************************************************************************/
void Rec_ShowCommonRecordUnmodifiable (struct UsrData *UsrDat)
{
/***** Get password, user type and user's data from database *****/
Usr_GetAllUsrDataFromUsrCod (UsrDat);
2015-09-17 11:21:49 +02:00
UsrDat->Accepted = Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
true);
2014-12-01 23:55:08 +01:00
/***** Show user's record *****/
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">");
2015-07-17 13:06:32 +02:00
Rec_ShowSharedUsrRecord (Rec_CHECK_OTHER_USR_COMMON_RECORD,UsrDat);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</div>");
}
/*****************************************************************************/
/**************************** Show record common *****************************/
/*****************************************************************************/
// Show form or only data depending on TypeOfView
2015-03-05 21:42:02 +01:00
void Rec_ShowSharedUsrRecord (Rec_RecordViewType_t TypeOfView,
struct UsrData *UsrDat)
2014-12-01 23:55:08 +01:00
{
2015-03-24 10:11:17 +01:00
extern const char *Usr_StringsSexDB[Usr_NUM_SEXS];
2015-07-28 00:16:09 +02:00
extern const char *The_ClassForm[The_NUM_THEMES];
2015-03-29 22:36:21 +02:00
extern const char *Txt_Edit_my_personal_data;
2015-03-29 15:03:35 +02:00
extern const char *Txt_Edit;
2015-03-30 14:37:44 +02:00
extern const char *Txt_View_record_for_this_course;
2014-12-01 23:55:08 +01:00
extern const char *Txt_Admin_user;
extern const char *Txt_ID;
2015-03-18 02:11:23 +01:00
extern const char *Txt_Write_a_message;
2015-03-02 19:06:43 +01:00
extern const char *Txt_View_works;
2015-03-02 19:53:19 +01:00
extern const char *Txt_See_exams;
2015-03-02 20:58:26 +01:00
extern const char *Txt_Attendance;
2015-12-29 19:40:38 +01:00
extern const char *Txt_Following_unfollow;
2015-03-18 02:11:23 +01:00
extern const char *Txt_Unfollow;
extern const char *Txt_Follow;
2015-03-13 00:16:02 +01:00
extern const char *Txt_View_public_profile;
2014-12-01 23:55:08 +01:00
extern const char *Txt_Email;
extern const char *Txt_Sex;
extern const char *Txt_Role;
extern const char *Txt_SEX_SINGULAR_Abc[Usr_NUM_SEXS];
2015-03-12 14:45:40 +01:00
extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
2014-12-01 23:55:08 +01:00
extern const char *Txt_Surname_1;
extern const char *Txt_Surname_2;
extern const char *Txt_First_name;
2015-03-29 13:57:24 +02:00
extern const char *Txt_Country;
2014-12-01 23:55:08 +01:00
extern const char *Txt_Another_country;
extern const char *Txt_Place_of_origin;
extern const char *Txt_Date_of_birth;
extern const char *Txt_Institution;
extern const char *Txt_Centre;
extern const char *Txt_Department;
extern const char *Txt_Office;
extern const char *Txt_Phone;
extern const char *Txt_Local_address;
extern const char *Txt_Family_address;
extern const char *Txt_USER_comments;
2015-03-29 14:09:23 +02:00
extern const char *Txt_Save_changes;
2015-03-29 21:43:33 +02:00
extern const char *Txt_Register;
extern const char *Txt_Confirm;
2014-12-01 23:55:08 +01:00
char StrRecordWidth[10+1];
2015-12-16 00:16:32 +01:00
const char *ClassForm = "REC_DAT";
2015-12-13 13:53:00 +01:00
char Name[Usr_MAX_BYTES_NAME+1]; // To shorten length of FirstName, Surname1, Surname2
2014-12-01 23:55:08 +01:00
char PhotoURL[PATH_MAX+1];
bool ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod);
2015-04-07 21:44:24 +02:00
bool IAmLoggedAsStudent = (Gbl.Usrs.Me.LoggedRole == Rol_STUDENT); // My current role is student
bool IAmLoggedAsTeacher = (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER); // My current role is teacher
bool IAmLoggedAsSysAdm = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); // My current role is superuser
bool HeIsTeacherInAnyCourse = (UsrDat->Roles & (1 << Rol_TEACHER)); // He/she already is a teacher in any course
bool HeBelongsToCurrentCrs = (UsrDat->RoleInCurrentCrsDB == Rol_STUDENT ||
UsrDat->RoleInCurrentCrsDB == Rol_TEACHER);
2015-12-07 23:13:08 +01:00
bool CountryForm = (TypeOfView == Rec_FORM_MY_COMMON_RECORD);
bool RoleForm = (TypeOfView == Rec_FORM_SIGN_UP ||
TypeOfView == Rec_FORM_NEW_RECORD_OTHER_NEW_USR ||
TypeOfView == Rec_FORM_MODIFY_RECORD_OTHER_EXISTING_USR);
2015-09-16 22:13:00 +02:00
bool SexForm = (TypeOfView == Rec_FORM_MY_COMMON_RECORD);
bool DataForm = (TypeOfView == Rec_FORM_MY_COMMON_RECORD ||
2015-03-02 20:58:26 +01:00
TypeOfView == Rec_FORM_NEW_RECORD_OTHER_NEW_USR ||
2015-09-12 14:12:40 +02:00
(TypeOfView == Rec_FORM_MODIFY_RECORD_OTHER_EXISTING_USR &&
2015-09-16 22:13:00 +02:00
Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM));
2015-03-24 10:11:17 +01:00
bool PutFormLinks; // Put links (forms) inside record card
2015-09-16 22:13:00 +02:00
bool ShowEmail = (ItsMe ||
Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM ||
DataForm ||
TypeOfView == Rec_FORM_MY_COMMON_RECORD ||
TypeOfView == Rec_MY_COMMON_RECORD_CHECK ||
TypeOfView == Rec_FORM_MY_COURSE_RECORD_AS_STUDENT ||
TypeOfView == Rec_CHECK_MY_COURSE_RECORD_AS_STUDENT ||
(UsrDat->Accepted &&
(TypeOfView == Rec_CHECK_OTHER_USR_COMMON_RECORD ||
((TypeOfView == Rec_RECORD_LIST ||
TypeOfView == Rec_RECORD_PRINT) &&
(IAmLoggedAsTeacher || Gbl.Usrs.Listing.RecsUsrs == Rec_RECORD_USERS_TEACHERS)))));
bool ShowID = (ItsMe ||
Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM ||
DataForm ||
TypeOfView == Rec_FORM_MY_COMMON_RECORD ||
TypeOfView == Rec_MY_COMMON_RECORD_CHECK ||
TypeOfView == Rec_FORM_MY_COURSE_RECORD_AS_STUDENT ||
TypeOfView == Rec_CHECK_MY_COURSE_RECORD_AS_STUDENT ||
(UsrDat->Accepted &&
((TypeOfView == Rec_CHECK_OTHER_USR_COMMON_RECORD &&
!(IAmLoggedAsTeacher && HeIsTeacherInAnyCourse)) || // A teacher can not see another teacher's ID
((TypeOfView == Rec_RECORD_LIST ||
TypeOfView == Rec_RECORD_PRINT) &&
IAmLoggedAsTeacher && Gbl.Usrs.Listing.RecsUsrs == Rec_RECORD_USERS_STUDENTS))));
bool ShowData = (ItsMe ||
2015-09-12 14:12:40 +02:00
Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM ||
2015-09-16 22:13:00 +02:00
UsrDat->Accepted);
bool ShowIDRows = (TypeOfView != Rec_RECORD_PUBLIC);
bool ShowAddressRows = (TypeOfView == Rec_FORM_MY_COMMON_RECORD ||
TypeOfView == Rec_MY_COMMON_RECORD_CHECK ||
TypeOfView == Rec_FORM_MY_COURSE_RECORD_AS_STUDENT ||
TypeOfView == Rec_CHECK_MY_COURSE_RECORD_AS_STUDENT ||
((TypeOfView == Rec_RECORD_LIST ||
TypeOfView == Rec_RECORD_PRINT) &&
(IAmLoggedAsTeacher || IAmLoggedAsSysAdm) &&
UsrDat->RoleInCurrentCrsDB == Rol_STUDENT));
2015-03-05 23:18:43 +01:00
bool ShowTeacherRows = (((TypeOfView == Rec_FORM_MY_COMMON_RECORD ||
TypeOfView == Rec_MY_COMMON_RECORD_CHECK ||
2015-07-17 13:06:32 +02:00
TypeOfView == Rec_FORM_MY_COURSE_RECORD_AS_STUDENT ||
TypeOfView == Rec_CHECK_MY_COURSE_RECORD_AS_STUDENT) &&
2015-09-12 14:12:40 +02:00
(UsrDat->Roles & (1 << Rol_TEACHER))) || // He/she (me, really) is a teacher in any course
2015-03-05 23:18:43 +01:00
((TypeOfView == Rec_RECORD_LIST ||
TypeOfView == Rec_RECORD_PRINT) &&
2015-04-07 21:44:24 +02:00
UsrDat->RoleInCurrentCrsDB == Rol_TEACHER)); // He/she is a teacher in the current course
2014-12-01 23:55:08 +01:00
Usr_Sex_t Sex;
Rol_Role_t Role;
Rol_Role_t DefaultRoleInCurrentCrs;
bool ShowPhoto;
unsigned NumCty;
struct Institution Ins;
struct Centre Ctr;
struct Department Dpt;
switch (TypeOfView)
{
case Rec_FORM_SIGN_UP:
2015-03-05 21:42:02 +01:00
case Rec_FORM_MY_COMMON_RECORD:
2015-07-17 13:06:32 +02:00
case Rec_FORM_MY_COURSE_RECORD_AS_STUDENT:
2014-12-01 23:55:08 +01:00
case Rec_FORM_NEW_RECORD_OTHER_NEW_USR:
case Rec_FORM_MODIFY_RECORD_OTHER_EXISTING_USR:
2015-07-28 00:16:09 +02:00
ClassForm = The_ClassForm[Gbl.Prefs.Theme];
2014-12-01 23:55:08 +01:00
break;
2015-03-05 21:42:02 +01:00
case Rec_MY_COMMON_RECORD_CHECK:
2015-07-17 13:06:32 +02:00
case Rec_CHECK_MY_COURSE_RECORD_AS_STUDENT:
case Rec_CHECK_OTHER_USR_COMMON_RECORD:
2014-12-01 23:55:08 +01:00
case Rec_RECORD_LIST:
2015-03-05 23:18:43 +01:00
case Rec_RECORD_PUBLIC:
2014-12-01 23:55:08 +01:00
case Rec_RECORD_PRINT:
2015-12-13 17:49:53 +01:00
ClassForm = "REC_DAT";
2014-12-01 23:55:08 +01:00
break;
2015-03-29 21:43:33 +02:00
}
2014-12-01 23:55:08 +01:00
2016-01-14 10:31:09 +01:00
PutFormLinks = !Gbl.Form.Inside && // Only if not inside another form
2016-01-17 15:10:54 +01:00
Act_Actions[Gbl.Action.Act].BrowserWindow == Act_MAIN_WINDOW; // Only in main window
2015-03-24 10:11:17 +01:00
2014-12-08 17:35:48 +01:00
/***** Start frame *****/
2015-12-13 17:49:53 +01:00
sprintf (StrRecordWidth,"%upx",Rec_RECORD_WIDTH);
2015-04-12 18:01:06 +02:00
Lay_StartRoundFrameTable (StrRecordWidth,2,NULL);
2014-12-01 23:55:08 +01:00
/***** Institution *****/
2016-04-22 12:24:02 +02:00
fprintf (Gbl.F.Out,"<tr>");
Ins.InsCod = UsrDat->InsCod;
if (Ins.InsCod > 0)
2015-12-09 19:51:17 +01:00
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
2016-04-22 12:24:02 +02:00
Rec_ShowInstitution (&Ins,PutFormLinks);
2015-03-18 19:52:07 +01:00
/***** Photo *****/
ShowPhoto = Pho_ShowUsrPhotoIsAllowed (UsrDat,PhotoURL);
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<td rowspan=\"3\" class=\"CENTER_TOP\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
Rec_C3_TOP);
2015-03-18 19:52:07 +01:00
Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL :
NULL,
2016-01-14 10:31:09 +01:00
"PHOTO186x248",Pho_NO_ZOOM,false);
2015-03-18 19:52:07 +01:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
/***** Commands *****/
fprintf (Gbl.F.Out,"<tr>"
2015-08-24 11:25:20 +02:00
"<td rowspan=\"3\" class=\"LEFT_TOP\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
Rec_C1_TOP);
2014-12-01 23:55:08 +01:00
2015-03-24 10:11:17 +01:00
if (PutFormLinks && Gbl.Usrs.Me.Logged)
2014-12-01 23:55:08 +01:00
{
2015-12-13 13:53:00 +01:00
fprintf (Gbl.F.Out,"<div class=\"REC_SHORTCUTS\">");
2014-12-01 23:55:08 +01:00
2015-03-29 15:03:35 +02:00
/***** Button to edit my record card *****/
2015-03-29 22:36:21 +02:00
if (ItsMe)
2015-03-29 15:03:35 +02:00
{
Act_FormStart (ActReqEdiRecCom);
2015-03-29 22:36:21 +02:00
Act_LinkFormSubmit (Txt_Edit_my_personal_data,NULL);
2015-07-22 13:49:39 +02:00
fprintf (Gbl.F.Out,"<div class=\"ICON_HIGHLIGHT\""
" style=\"display:inline;\" >"
2015-12-08 22:20:44 +01:00
"<img src=\"%s/edit64x64.png\""
2015-07-22 13:49:39 +02:00
" alt=\"%s\" title=\"%s\""
2015-12-13 12:51:41 +01:00
" class=\"ICON20x20\" />"
2015-03-29 15:03:35 +02:00
"</div>"
"</a>",
Gbl.Prefs.IconsURL,
2015-12-29 19:40:38 +01:00
Txt_Edit,Txt_Edit);
2015-03-29 15:03:35 +02:00
Act_FormEnd ();
}
/***** Button to view user's record card in course when:
- a course is selected && the user belongs to it &&
- I can view user's record card in course *****/
2015-03-29 22:36:21 +02:00
if (HeBelongsToCurrentCrs &&
2015-03-13 00:16:02 +01:00
(IAmLoggedAsStudent ||
IAmLoggedAsTeacher ||
IAmLoggedAsSysAdm))
{
2015-09-12 14:12:40 +02:00
Act_FormStart (UsrDat->RoleInCurrentCrsDB == Rol_STUDENT ? ActSeeRecOneStd :
ActSeeRecOneTch);
2015-04-02 18:39:49 +02:00
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
2015-03-30 14:37:44 +02:00
Act_LinkFormSubmit (Txt_View_record_for_this_course,NULL);
2015-07-22 13:49:39 +02:00
fprintf (Gbl.F.Out,"<div class=\"ICON_HIGHLIGHT\""
" style=\"display:inline;\" >"
2015-12-12 19:47:10 +01:00
"<img src=\"%s/card64x64.gif\""
2015-07-22 13:49:39 +02:00
" alt=\"%s\" title=\"%s\""
2015-12-13 12:51:41 +01:00
" class=\"ICON20x20\" />"
2015-03-13 00:16:02 +01:00
"</div>"
"</a>",
Gbl.Prefs.IconsURL,
2015-07-22 13:49:39 +02:00
Txt_View_record_for_this_course,
2015-03-30 14:37:44 +02:00
Txt_View_record_for_this_course);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
}
2015-03-02 20:58:26 +01:00
/***** Button to admin user *****/
2015-03-05 21:42:02 +01:00
if (ItsMe ||
2015-04-07 21:44:24 +02:00
(Gbl.CurrentCrs.Crs.CrsCod > 0 && Gbl.Usrs.Me.LoggedRole == Rol_TEACHER) ||
(Gbl.CurrentDeg.Deg.DegCod > 0 && Gbl.Usrs.Me.LoggedRole == Rol_DEG_ADM) ||
(Gbl.CurrentCtr.Ctr.CtrCod > 0 && Gbl.Usrs.Me.LoggedRole == Rol_CTR_ADM) ||
(Gbl.CurrentIns.Ins.InsCod > 0 && Gbl.Usrs.Me.LoggedRole == Rol_INS_ADM) ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
2015-03-02 20:58:26 +01:00
{
2015-09-17 17:49:46 +02:00
Act_FormStart ( UsrDat->RoleInCurrentCrsDB == Rol_STUDENT ? ActReqMdfStd :
(UsrDat->RoleInCurrentCrsDB == Rol_TEACHER ? ActReqMdfTch :
ActReqMdfOth));
2015-04-02 18:39:49 +02:00
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
2015-03-02 20:58:26 +01:00
Act_LinkFormSubmit (Txt_Admin_user,NULL);
2015-07-22 13:49:39 +02:00
fprintf (Gbl.F.Out,"<div class=\"ICON_HIGHLIGHT\""
" style=\"display:inline;\" >"
2015-12-12 19:47:10 +01:00
"<img src=\"%s/config64x64.gif\""
2015-07-22 13:49:39 +02:00
" alt=\"%s\" title=\"%s\""
2015-12-13 12:51:41 +01:00
" class=\"ICON20x20\" />"
2015-03-02 20:58:26 +01:00
"</div>"
2015-03-13 00:16:02 +01:00
"</a>",
2015-03-02 20:58:26 +01:00
Gbl.Prefs.IconsURL,
2015-12-29 19:40:38 +01:00
Txt_Admin_user,Txt_Admin_user);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2015-03-02 20:58:26 +01:00
}
2015-12-07 23:56:03 +01:00
if (Gbl.CurrentCrs.Crs.CrsCod > 0 && // A course is selected
2015-04-07 21:44:24 +02:00
UsrDat->RoleInCurrentCrsDB == Rol_STUDENT && // He/she is a student in the current course
2015-03-13 00:16:02 +01:00
(ItsMe || IAmLoggedAsTeacher || IAmLoggedAsSysAdm)) // I can view
2015-03-02 20:58:26 +01:00
{
/***** Button to view user's assignments and works *****/
if (ItsMe) // I am a student
Act_FormStart (ActAdmAsgWrkUsr);
else // I am a teacher or superuser
{
Act_FormStart (ActAdmAsgWrkCrs);
Par_PutHiddenParamString ("UsrCodStd",UsrDat->EncryptedUsrCod);
}
Grp_PutParamAllGroups ();
Par_PutHiddenParamChar ("FullTree",'Y'); // By default, show all files
2015-12-13 17:49:53 +01:00
Act_LinkFormSubmit (Txt_View_works,"REC_DAT_BOLD");
2015-07-22 13:49:39 +02:00
fprintf (Gbl.F.Out,"<div class=\"ICON_HIGHLIGHT\""
" style=\"display:inline;\" >"
2015-12-12 19:47:10 +01:00
"<img src=\"%s/folder64x64.gif\""
2015-07-22 13:49:39 +02:00
" alt=\"%s\" title=\"%s\""
2015-12-13 12:51:41 +01:00
" class=\"ICON20x20\" />"
2015-03-02 20:58:26 +01:00
"</div>"
2015-03-13 00:16:02 +01:00
"</a>",
2015-03-02 20:58:26 +01:00
Gbl.Prefs.IconsURL,
2015-12-29 19:40:38 +01:00
Txt_View_works,Txt_View_works);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2015-03-02 20:58:26 +01:00
/***** Button to view user's test exams *****/
if (ItsMe)
Act_FormStart (ActSeeMyTstExa);
else
{
Act_FormStart (ActSeeUsrTstExa);
Par_PutHiddenParamString ("UsrCodStd",UsrDat->EncryptedUsrCod);
}
Grp_PutParamAllGroups ();
2015-12-13 17:49:53 +01:00
Act_LinkFormSubmit (Txt_See_exams,"REC_DAT_BOLD");
2015-07-22 13:49:39 +02:00
fprintf (Gbl.F.Out,"<div class=\"ICON_HIGHLIGHT\""
" style=\"display:inline;\" >"
2015-12-12 19:47:10 +01:00
"<img src=\"%s/file64x64.gif\""
2015-07-22 13:49:39 +02:00
" alt=\"%s\" title=\"%s\""
2015-12-13 12:51:41 +01:00
" class=\"ICON20x20\" />"
2015-03-02 20:58:26 +01:00
"</div>"
2015-03-13 00:16:02 +01:00
"</a>",
2015-03-02 20:58:26 +01:00
Gbl.Prefs.IconsURL,
2015-12-29 19:40:38 +01:00
Txt_See_exams,Txt_See_exams);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2015-03-02 20:58:26 +01:00
/***** Button to view user's attendance *****/
2015-12-07 23:56:03 +01:00
if (IAmLoggedAsStudent ||
IAmLoggedAsTeacher ||
IAmLoggedAsSysAdm)
2015-03-02 20:58:26 +01:00
{
2015-12-07 23:56:03 +01:00
if (IAmLoggedAsStudent)
// As student, I can see my attendance
Act_FormStart (ActSeeLstMyAtt);
else // IAmLoggedAsTeacher || IAmLoggedAsSysAdm
{
// As teacher, I can see attendance of the student
Act_FormStart (ActSeeLstStdAtt);
Par_PutHiddenParamString ("UsrCodStd",UsrDat->EncryptedUsrCod);
Grp_PutParamAllGroups ();
}
2015-12-13 17:49:53 +01:00
Act_LinkFormSubmit (Txt_Attendance,"REC_DAT_BOLD");
2015-07-22 13:49:39 +02:00
fprintf (Gbl.F.Out,"<div class=\"ICON_HIGHLIGHT\""
" style=\"display:inline;\" >"
2015-12-12 19:47:10 +01:00
"<img src=\"%s/rollcall64x64.gif\""
2015-07-22 13:49:39 +02:00
" alt=\"%s\" title=\"%s\""
2015-12-13 12:51:41 +01:00
" class=\"ICON20x20\" />"
2015-03-02 20:58:26 +01:00
"</div>"
2015-03-13 00:16:02 +01:00
"</a>",
2015-03-02 20:58:26 +01:00
Gbl.Prefs.IconsURL,
2015-12-29 19:40:38 +01:00
Txt_Attendance,Txt_Attendance);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2015-03-02 20:58:26 +01:00
}
}
/***** Button to send a message *****/
2014-12-01 23:55:08 +01:00
Act_FormStart (ActReqMsgUsr);
Grp_PutParamAllGroups ();
2015-12-24 00:31:45 +01:00
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
2015-12-22 14:00:36 +01:00
Par_PutHiddenParamChar ("ShowOnlyOneRecipient",'Y');
2015-12-13 17:49:53 +01:00
Act_LinkFormSubmit (Txt_Write_a_message,"REC_DAT_BOLD");
2015-07-22 13:49:39 +02:00
fprintf (Gbl.F.Out,"<div class=\"ICON_HIGHLIGHT\""
" style=\"display:inline;\" >"
2015-12-12 02:01:20 +01:00
"<img src=\"%s/msg64x64.gif\""
2015-07-22 13:49:39 +02:00
" alt=\"%s\" title=\"%s\""
2015-12-13 12:51:41 +01:00
" class=\"ICON20x20\" />"
2014-12-01 23:55:08 +01:00
"</div>"
2015-03-13 00:16:02 +01:00
"</a>",
2014-12-01 23:55:08 +01:00
Gbl.Prefs.IconsURL,
2015-12-29 19:40:38 +01:00
Txt_Write_a_message,Txt_Write_a_message);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2015-03-02 19:53:19 +01:00
2015-03-18 01:06:43 +01:00
/***** Button to follow / unfollow *****/
2015-03-19 12:47:05 +01:00
if (TypeOfView == Rec_RECORD_PUBLIC &&
!ItsMe)
2015-03-19 12:32:45 +01:00
{
2015-12-29 19:40:38 +01:00
if (Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod,UsrDat->UsrCod)) // I follow user
2015-03-18 01:06:43 +01:00
{
2015-03-19 12:32:45 +01:00
Act_FormStart (ActUnfUsr);
2015-04-02 18:39:49 +02:00
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
2015-12-29 19:40:38 +01:00
Act_LinkFormSubmit (Txt_Following_unfollow,"REC_DAT_BOLD");
2015-07-22 13:49:39 +02:00
fprintf (Gbl.F.Out,"<div class=\"ICON_HIGHLIGHT\""
" style=\"display:inline;\" >"
2015-12-29 19:40:38 +01:00
"<img src=\"%s/following64x64.png\""
2015-07-22 13:49:39 +02:00
" alt=\"%s\" title=\"%s\""
2015-12-13 12:51:41 +01:00
" class=\"ICON20x20\" />"
2015-03-19 12:32:45 +01:00
"</div>"
"</a>",
Gbl.Prefs.IconsURL,
2015-12-29 19:40:38 +01:00
Txt_Unfollow,Txt_Following_unfollow);
2015-03-19 12:32:45 +01:00
Act_FormEnd ();
2015-03-18 01:06:43 +01:00
}
2015-12-29 19:40:38 +01:00
else // I do not follow user
2015-03-19 12:32:45 +01:00
{
Act_FormStart (ActFolUsr);
2015-04-02 18:39:49 +02:00
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
2015-12-13 17:49:53 +01:00
Act_LinkFormSubmit (Txt_Follow,"REC_DAT_BOLD");
2015-07-22 13:49:39 +02:00
fprintf (Gbl.F.Out,"<div class=\"ICON_HIGHLIGHT\""
" style=\"display:inline;\" >"
2015-12-29 19:40:38 +01:00
"<img src=\"%s/follow64x64.png\""
2015-07-22 13:49:39 +02:00
" alt=\"%s\" title=\"%s\""
2015-12-13 12:51:41 +01:00
" class=\"ICON20x20\" />"
2015-03-19 12:32:45 +01:00
"</div>"
"</a>",
Gbl.Prefs.IconsURL,
2015-12-29 19:40:38 +01:00
Txt_Follow,Txt_Follow);
2015-03-19 12:32:45 +01:00
Act_FormEnd ();
}
}
2015-03-18 01:06:43 +01:00
2015-03-02 20:58:26 +01:00
fprintf (Gbl.F.Out,"</div>");
2015-03-02 19:06:43 +01:00
}
2015-03-18 19:52:07 +01:00
fprintf (Gbl.F.Out,"</td>");
2015-03-02 19:06:43 +01:00
2014-12-01 23:55:08 +01:00
/***** Full name *****/
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<td class=\"REC_NAME LEFT_TOP\""
2015-12-13 13:53:00 +01:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
Rec_C2_TOP);
2015-12-13 13:53:00 +01:00
/* First name */
strncpy (Name,UsrDat->FirstName,Usr_MAX_BYTES_NAME);
Name[Usr_MAX_BYTES_NAME] = '\0';
Str_LimitLengthHTMLStr (Name,20);
fprintf (Gbl.F.Out,"%s<br />",Name);
/* Surname 1 */
strncpy (Name,UsrDat->Surname1,Usr_MAX_BYTES_NAME);
Name[Usr_MAX_BYTES_NAME] = '\0';
Str_LimitLengthHTMLStr (Name,20);
fprintf (Gbl.F.Out,"%s<br />",Name);
/* Surname 2 */
strncpy (Name,UsrDat->Surname2,Usr_MAX_BYTES_NAME);
Name[Usr_MAX_BYTES_NAME] = '\0';
Str_LimitLengthHTMLStr (Name,20);
fprintf (Gbl.F.Out,"%s",Name);
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
/***** User's nickname *****/
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<td class=\"REC_NAME LEFT_BOTTOM\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-18 21:53:56 +01:00
"<div class=\"REC_NICK\">",
2015-12-13 17:49:53 +01:00
Rec_C2_TOP);
2014-12-01 23:55:08 +01:00
if (UsrDat->Nickname[0])
{
2015-03-24 10:11:17 +01:00
if (PutFormLinks)
2014-12-01 23:55:08 +01:00
{
2015-03-05 21:42:02 +01:00
/* Put form to go to public profile */
Act_FormStart (ActSeePubPrf);
2015-04-02 18:39:49 +02:00
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
2015-03-17 10:42:06 +01:00
Act_LinkFormSubmit (Txt_View_public_profile,"REC_NICK");
2014-12-01 23:55:08 +01:00
}
2015-03-03 21:15:52 +01:00
fprintf (Gbl.F.Out,"@%s",UsrDat->Nickname);
2015-03-24 10:11:17 +01:00
if (PutFormLinks)
2015-03-13 00:16:02 +01:00
{
fprintf (Gbl.F.Out,"</a>");
Act_FormEnd ();
2015-03-03 21:15:52 +01:00
2015-04-02 18:39:49 +02:00
/* Link to QR code */
2015-12-13 20:46:46 +01:00
QR_PutLinkToPrintQRCode (UsrDat->Nickname,false);
2015-04-02 18:39:49 +02:00
}
2014-12-01 23:55:08 +01:00
}
2015-03-18 19:52:07 +01:00
fprintf (Gbl.F.Out,"</div>"
"</td>"
"</tr>");
2015-03-05 21:42:02 +01:00
2015-03-18 21:00:03 +01:00
/***** Country *****/
2015-03-18 19:52:07 +01:00
fprintf (Gbl.F.Out,"<tr>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_TOP\" style=\"width:%upx;\">",
Rec_C2_TOP);
2015-03-29 13:57:24 +02:00
if (ShowData && UsrDat->CtyCod > 0)
2015-12-08 00:25:56 +01:00
/* Link to see country information */
2015-12-13 17:49:53 +01:00
Cty_WriteCountryName (UsrDat->CtyCod,"REC_DAT_BOLD");
2015-03-18 21:00:03 +01:00
fprintf (Gbl.F.Out,"</td>");
/***** User's web and social networks *****/
2015-09-24 18:02:21 +02:00
fprintf (Gbl.F.Out,"<td class=\"CENTER_TOP\" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
Rec_C3_TOP);
2015-12-13 17:12:48 +01:00
if (TypeOfView != Rec_RECORD_PRINT)
Net_ShowWebsAndSocialNets (UsrDat);
2015-09-06 19:51:06 +02:00
fprintf (Gbl.F.Out,"</td>"
2015-03-05 21:42:02 +01:00
"</tr>");
2014-12-01 23:55:08 +01:00
2015-03-29 13:57:24 +02:00
if (ShowIDRows ||
ShowAddressRows ||
ShowTeacherRows)
2014-12-01 23:55:08 +01:00
{
fprintf (Gbl.F.Out,"<tr>"
2015-03-29 15:03:35 +02:00
"<td colspan=\"3\">");
2015-03-29 21:43:33 +02:00
switch (TypeOfView)
{
case Rec_FORM_MY_COMMON_RECORD:
Act_FormStart (ActChgMyData);
break;
case Rec_FORM_NEW_RECORD_OTHER_NEW_USR:
2016-01-17 15:10:54 +01:00
Act_FormStart ( Gbl.Action.Act == ActReqMdfStd ? ActCreStd :
(Gbl.Action.Act == ActReqMdfTch ? ActCreTch :
2015-09-17 16:54:02 +02:00
ActCreOth));
2015-03-29 21:43:33 +02:00
ID_PutParamOtherUsrIDPlain (); // New user
break;
case Rec_FORM_MODIFY_RECORD_OTHER_EXISTING_USR:
2015-09-17 16:54:02 +02:00
Act_FormStart ( UsrDat->RoleInCurrentCrsDB == Rol_STUDENT ? ActUpdStd :
(UsrDat->RoleInCurrentCrsDB == Rol_TEACHER ? ActUpdTch :
ActUpdOth));
2015-04-02 18:39:49 +02:00
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); // Existing user
2015-03-29 21:43:33 +02:00
break;
default:
break;
}
2015-03-29 15:03:35 +02:00
fprintf (Gbl.F.Out,"<table style=\"width:100%%\">");
2015-03-29 13:57:24 +02:00
if (ShowIDRows)
2015-03-05 23:18:43 +01:00
{
2015-03-29 13:57:24 +02:00
/***** User's e-mail *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s:"
"</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,Txt_Email,
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
if (UsrDat->Email[0])
2015-03-05 23:18:43 +01:00
{
2015-03-29 13:57:24 +02:00
if (ShowEmail)
{
fprintf (Gbl.F.Out,"<a href=\"mailto:%s\"",
UsrDat->Email);
Str_LimitLengthHTMLStr (UsrDat->Email,36);
2015-12-13 17:49:53 +01:00
fprintf (Gbl.F.Out," class=\"REC_DAT_BOLD\">%s</a>",
UsrDat->Email);
2015-03-29 13:57:24 +02:00
}
else
fprintf (Gbl.F.Out,"********");
2015-03-05 23:18:43 +01:00
}
2015-03-29 13:57:24 +02:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2015-03-05 23:18:43 +01:00
2015-03-29 13:57:24 +02:00
/***** User's ID *****/
2015-03-05 23:18:43 +01:00
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_TOP\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s:"
"</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_TOP\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,Txt_ID,
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
ID_WriteUsrIDs (UsrDat,ShowID);
fprintf (Gbl.F.Out,"</td>"
"</tr>");
/***** User's role or sex *****/
if (RoleForm)
2015-03-05 23:18:43 +01:00
{
2015-03-29 13:57:24 +02:00
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s:</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,
2015-03-29 13:57:24 +02:00
Txt_Role,
2015-12-13 17:49:53 +01:00
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
switch (TypeOfView)
{
case Rec_FORM_SIGN_UP: // I want to apply for enrollment
2016-03-24 21:25:19 +01:00
DefaultRoleInCurrentCrs = ((UsrDat->Roles & (1 << Rol_TEACHER)) || // I am teacher in other courses
UsrDat->UsrCod == Gbl.CurrentCrs.Crs.RequesterUsrCod) ? // I am the creator of the course
Rol_TEACHER :
Rol_STUDENT;
2015-03-29 13:57:24 +02:00
fprintf (Gbl.F.Out,"<select name=\"Role\">");
2015-04-07 21:44:24 +02:00
for (Role = Rol_STUDENT;
Role <= Rol_TEACHER;
2015-03-29 13:57:24 +02:00
Role++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",(unsigned) Role);
if (Role == DefaultRoleInCurrentCrs)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_ROLES_SINGUL_Abc[Role][UsrDat->Sex]);
}
fprintf (Gbl.F.Out,"</select>");
break;
case Rec_FORM_MODIFY_RECORD_OTHER_EXISTING_USR: // The other user already exists in the platform
fprintf (Gbl.F.Out,"<select name=\"Role\">");
2015-09-16 22:13:00 +02:00
if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected
2015-03-29 13:57:24 +02:00
{
2015-09-16 22:13:00 +02:00
if (UsrDat->RoleInCurrentCrsDB < Rol_STUDENT) // The other user does not belong to current course
{
/* If there is a request of this user, default role is the requested role */
if ((DefaultRoleInCurrentCrs = Rol_GetRequestedRole (UsrDat->UsrCod)) == Rol_UNKNOWN)
DefaultRoleInCurrentCrs = (UsrDat->Roles & (1 << Rol_TEACHER)) ? Rol_TEACHER :
Rol_STUDENT;
}
else
DefaultRoleInCurrentCrs = UsrDat->RoleInCurrentCrsDB;
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol__GUEST_:
case Rol_VISITOR:
case Rol_STUDENT:
fprintf (Gbl.F.Out,"<option value=\"%u\" selected=\"selected\" disabled=\"disabled\">%s</option>",
(unsigned) Gbl.Usrs.Me.LoggedRole,
Txt_ROLES_SINGUL_Abc[Gbl.Usrs.Me.LoggedRole][UsrDat->Sex]);
break;
case Rol_TEACHER:
for (Role = Rol_STUDENT;
Role <= Rol_TEACHER;
Role++)
if (Role == Rol_STUDENT ||
(UsrDat->Roles & (1 << Role))) // A teacher can not upgrade a student (in all other courses) to teacher
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",(unsigned) Role);
if (Role == DefaultRoleInCurrentCrs)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_ROLES_SINGUL_Abc[Role][UsrDat->Sex]);
}
break;
case Rol_DEG_ADM:
case Rol_CTR_ADM:
case Rol_INS_ADM:
case Rol_SYS_ADM:
for (Role = Rol_STUDENT;
Role <= Rol_TEACHER;
Role++)
2015-03-29 13:57:24 +02:00
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",(unsigned) Role);
if (Role == DefaultRoleInCurrentCrs)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_ROLES_SINGUL_Abc[Role][UsrDat->Sex]);
}
2015-09-16 22:13:00 +02:00
break;
default: // The rest of users can not register other users
break;
}
}
else // No course selected
{
DefaultRoleInCurrentCrs = (UsrDat->Roles & ((1 << Rol_STUDENT) |
(1 << Rol_TEACHER))) ? Rol_VISITOR :
Rol__GUEST_;
fprintf (Gbl.F.Out,"<option value=\"%u\" selected=\"selected\" disabled=\"disabled\">%s</option>",
(unsigned) DefaultRoleInCurrentCrs,
Txt_ROLES_SINGUL_Abc[DefaultRoleInCurrentCrs][UsrDat->Sex]);
2015-03-29 13:57:24 +02:00
}
fprintf (Gbl.F.Out,"</select>");
break;
case Rec_FORM_NEW_RECORD_OTHER_NEW_USR: // The other user does not exist in platform
fprintf (Gbl.F.Out,"<select name=\"Role\">");
2015-09-16 22:13:00 +02:00
if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol_TEACHER: // A teacher only can create students
fprintf (Gbl.F.Out,"<option value=\"%u\" selected=\"selected\">%s</option>",
(unsigned) Rol_STUDENT,Txt_ROLES_SINGUL_Abc[Rol_STUDENT][Usr_SEX_UNKNOWN]);
break;
case Rol_DEG_ADM: // An administrator can create students and teachers in a course
case Rol_CTR_ADM:
case Rol_INS_ADM:
case Rol_SYS_ADM:
fprintf (Gbl.F.Out,"<option value=\"%u\" selected=\"selected\">%s</option>"
"<option value=\"%u\">%s</option>",
(unsigned) Rol_STUDENT,Txt_ROLES_SINGUL_Abc[Rol_STUDENT][Usr_SEX_UNKNOWN],
(unsigned) Rol_TEACHER,Txt_ROLES_SINGUL_Abc[Rol_TEACHER][Usr_SEX_UNKNOWN]);
break;
default: // The rest of users can not register other users
break;
}
else // No course selected
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol_SYS_ADM:
fprintf (Gbl.F.Out,"<option value=\"%u\" selected=\"selected\">%s</option>",
(unsigned) Rol__GUEST_,Txt_ROLES_SINGUL_Abc[Rol__GUEST_][Usr_SEX_UNKNOWN]);
break;
default: // The rest of users can not register other users
break;
}
2015-03-29 13:57:24 +02:00
fprintf (Gbl.F.Out,"</select>");
break;
default:
break;
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2015-03-05 23:18:43 +01:00
}
2015-03-29 13:57:24 +02:00
else if (SexForm)
{
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s*:</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,
2015-03-29 13:57:24 +02:00
Txt_Sex,
2015-12-13 17:49:53 +01:00
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
for (Sex = Usr_SEX_FEMALE;
Sex <= Usr_SEX_MALE;
Sex++)
{
fprintf (Gbl.F.Out,"<input type=\"radio\" name=\"Sex\" value=\"%u\"",(unsigned) Sex);
if (Sex == Gbl.Usrs.Me.UsrDat.Sex)
fprintf (Gbl.F.Out," checked=\"checked\"");
fprintf (Gbl.F.Out," />"
2015-07-22 13:49:39 +02:00
"<img src=\"%s/%s16x16.gif\""
" alt=\"%s\" title=\"%s\""
2015-12-13 12:51:41 +01:00
" class=\"ICON20x20\" />"
2015-08-24 11:25:20 +02:00
"%s",
2015-03-29 13:57:24 +02:00
Gbl.Prefs.IconsURL,Usr_StringsSexDB[Sex],
Txt_SEX_SINGULAR_Abc[Sex],
2015-07-22 13:49:39 +02:00
Txt_SEX_SINGULAR_Abc[Sex],
2015-03-29 13:57:24 +02:00
Txt_SEX_SINGULAR_Abc[Sex]);
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
else // RoleForm == false, SexForm == false
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s:"
"</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s"
"</td>"
"</tr>",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,
2015-03-29 13:57:24 +02:00
TypeOfView == Rec_MY_COMMON_RECORD_CHECK ? Txt_Sex :
Txt_Role,
2015-12-13 17:49:53 +01:00
Rec_C2_BOTTOM,
2015-03-29 13:57:24 +02:00
TypeOfView == Rec_MY_COMMON_RECORD_CHECK ? Txt_SEX_SINGULAR_Abc[UsrDat->Sex] :
Txt_ROLES_SINGUL_Abc[UsrDat->RoleInCurrentCrsDB][UsrDat->Sex]);
/***** Name *****/
/* Surname 1 */
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,Txt_Surname_1);
2015-03-29 13:57:24 +02:00
if (TypeOfView == Rec_FORM_MY_COMMON_RECORD)
fprintf (Gbl.F.Out,"*");
fprintf (Gbl.F.Out,":</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
if (DataForm)
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"Surname1\""
2015-09-06 19:51:06 +02:00
" maxlength=\"%u\" value=\"%s\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\" />",
2015-03-29 13:57:24 +02:00
Usr_MAX_LENGTH_USR_NAME_OR_SURNAME,
2015-09-06 19:51:06 +02:00
UsrDat->Surname1,
2015-12-13 17:49:53 +01:00
Rec_C2_BOTTOM - 20);
2015-03-29 13:57:24 +02:00
else if (UsrDat->Surname1[0])
fprintf (Gbl.F.Out,"<strong>%s</strong>",UsrDat->Surname1);
fprintf (Gbl.F.Out,"</td>"
"</tr>");
/* Surname 2 */
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s:"
"</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,
2015-03-29 13:57:24 +02:00
Txt_Surname_2,
2015-12-13 17:49:53 +01:00
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
if (DataForm)
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"Surname2\""
2015-09-06 19:51:06 +02:00
" maxlength=\"%u\" value=\"%s\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\" />",
2015-03-29 13:57:24 +02:00
Usr_MAX_LENGTH_USR_NAME_OR_SURNAME,
2015-09-06 19:51:06 +02:00
UsrDat->Surname2,
2015-12-13 17:49:53 +01:00
Rec_C2_BOTTOM - 20);
2015-03-29 13:57:24 +02:00
else if (UsrDat->Surname2[0])
fprintf (Gbl.F.Out,"<strong>%s</strong>",
UsrDat->Surname2);
2015-03-05 23:18:43 +01:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2015-03-29 13:57:24 +02:00
/* First name */
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,Txt_First_name);
2015-03-29 13:57:24 +02:00
if (TypeOfView == Rec_FORM_MY_COMMON_RECORD)
fprintf (Gbl.F.Out,"*");
fprintf (Gbl.F.Out,":</td>"
2015-12-13 17:49:53 +01:00
"<td colspan=\"2\" class=\"REC_DAT_BOLD LEFT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
if (DataForm)
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"FirstName\""
2015-09-06 19:51:06 +02:00
" maxlength=\"%u\" value=\"%s\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\" />",
2015-03-29 13:57:24 +02:00
Usr_MAX_LENGTH_USR_NAME_OR_SURNAME,
2015-09-06 19:51:06 +02:00
UsrDat->FirstName,
2015-12-13 17:49:53 +01:00
Rec_C2_BOTTOM - 20);
2015-03-29 13:57:24 +02:00
else if (UsrDat->FirstName[0])
fprintf (Gbl.F.Out,"<strong>%s</strong>",UsrDat->FirstName);
fprintf (Gbl.F.Out,"</td>"
"</tr>");
/* Country */
if (CountryForm)
{
/* If list of countries is empty, try to get it */
if (!Gbl.Ctys.Num)
{
Gbl.Ctys.SelectedOrderType = Cty_ORDER_BY_COUNTRY;
2015-12-09 19:51:17 +01:00
Cty_GetListCountries (Cty_GET_BASIC_DATA);
2015-03-29 13:57:24 +02:00
}
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,Txt_Country);
2015-03-29 13:57:24 +02:00
if (TypeOfView == Rec_FORM_MY_COMMON_RECORD)
fprintf (Gbl.F.Out,"*");
fprintf (Gbl.F.Out,":</td>"
2015-12-13 17:49:53 +01:00
"<td colspan=\"2\" class=\"REC_DAT_BOLD LEFT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
/* Selector of country */
2015-09-06 19:51:06 +02:00
fprintf (Gbl.F.Out,"<select name=\"OthCtyCod\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"<option value=\"-1\">%s</option>"
"<option value=\"0\"",
2015-12-13 17:49:53 +01:00
Rec_C2_BOTTOM - 20,
2015-03-29 13:57:24 +02:00
Txt_Country);
if (UsrDat->CtyCod == 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",Txt_Another_country);
for (NumCty = 0;
NumCty < Gbl.Ctys.Num;
NumCty++)
{
fprintf (Gbl.F.Out,"<option value=\"%ld\"",
Gbl.Ctys.Lst[NumCty].CtyCod);
if (Gbl.Ctys.Lst[NumCty].CtyCod == UsrDat->CtyCod)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Gbl.Ctys.Lst[NumCty].Name[Gbl.Prefs.Language]);
}
2015-12-07 23:56:03 +01:00
fprintf (Gbl.F.Out,"</select>"
"</td>"
2015-03-29 13:57:24 +02:00
"</tr>");
}
2015-03-05 23:18:43 +01:00
}
2015-03-29 13:57:24 +02:00
if (ShowAddressRows)
2015-03-25 16:25:50 +01:00
{
2015-03-29 13:57:24 +02:00
/* Origin place */
2015-03-25 16:25:50 +01:00
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s:"
"</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,Txt_Place_of_origin,
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
if (ShowData)
2015-03-25 16:25:50 +01:00
{
2015-03-29 13:57:24 +02:00
if (DataForm)
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"OriginPlace\""
2015-09-06 19:51:06 +02:00
" maxlength=\"%u\" value=\"%s\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\" />",
2015-03-29 13:57:24 +02:00
Cns_MAX_LENGTH_STRING,
2015-09-06 19:51:06 +02:00
UsrDat->OriginPlace,
2015-12-13 17:49:53 +01:00
Rec_C2_BOTTOM - 20);
2015-03-29 13:57:24 +02:00
else if (UsrDat->OriginPlace[0])
fprintf (Gbl.F.Out,"%s",UsrDat->OriginPlace);
2015-03-25 16:25:50 +01:00
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2015-03-29 13:57:24 +02:00
/* Date of birth */
2015-03-05 23:18:43 +01:00
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-05 23:18:43 +01:00
"%s:"
"</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,Txt_Date_of_birth,
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
if (ShowData)
{
if (DataForm)
2015-12-22 09:38:32 +01:00
Dat_WriteFormDate (Gbl.Now.Date.Year - Rec_USR_MAX_AGE,
Gbl.Now.Date.Year - Rec_USR_MIN_AGE,
2015-10-23 01:06:32 +02:00
"Birth",
2015-03-29 13:57:24 +02:00
&(UsrDat->Birthday),
false,false);
else if (UsrDat->StrBirthday[0])
fprintf (Gbl.F.Out,"%s",UsrDat->StrBirthday);
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
2015-03-29 13:57:24 +02:00
/* Local address */
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s:"
"</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,Txt_Local_address,
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
if (ShowData)
{
if (DataForm)
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"LocalAddress\""
2015-09-06 19:51:06 +02:00
" maxlength=\"%u\" value=\"%s\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\" />",
2015-03-29 13:57:24 +02:00
Cns_MAX_LENGTH_STRING,
2015-09-06 19:51:06 +02:00
UsrDat->LocalAddress,
2015-12-13 17:49:53 +01:00
Rec_C2_BOTTOM - 20);
2015-03-29 13:57:24 +02:00
else if (UsrDat->LocalAddress[0])
fprintf (Gbl.F.Out,"%s",UsrDat->LocalAddress);
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
2015-03-29 13:57:24 +02:00
/* Local phone */
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s:"
"</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,Txt_Phone,
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
if (ShowData)
{
if (DataForm)
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"LocalPhone\""
2015-09-06 19:51:06 +02:00
" maxlength=\"%u\" value=\"%s\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\" />",
2015-03-29 13:57:24 +02:00
Usr_MAX_LENGTH_PHONE,
2015-09-06 19:51:06 +02:00
UsrDat->LocalPhone,
2015-12-13 17:49:53 +01:00
Rec_C2_BOTTOM - 20);
2015-03-29 13:57:24 +02:00
else if (UsrDat->LocalPhone[0])
fprintf (Gbl.F.Out,"%s",UsrDat->LocalPhone);
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
2015-03-29 13:57:24 +02:00
/* Family address */
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s:"
"</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,Txt_Family_address,
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
if (ShowData)
{
if (DataForm)
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"FamilyAddress\""
2015-09-06 19:51:06 +02:00
" maxlength=\"%u\" value=\"%s\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\" />",
2015-03-29 13:57:24 +02:00
Cns_MAX_LENGTH_STRING,
2015-09-06 19:51:06 +02:00
UsrDat->FamilyAddress,
2015-12-13 17:49:53 +01:00
Rec_C2_BOTTOM - 20);
2015-03-29 13:57:24 +02:00
else if (UsrDat->FamilyAddress[0])
fprintf (Gbl.F.Out,"%s",UsrDat->FamilyAddress);
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
2015-03-29 13:57:24 +02:00
/* Family phone */
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s:"
"</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,Txt_Phone,
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
if (ShowData)
{
if (DataForm)
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"FamilyPhone\""
2015-09-06 19:51:06 +02:00
" maxlength=\"%u\" value=\"%s\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\" />",
2015-03-29 13:57:24 +02:00
Usr_MAX_LENGTH_PHONE,
2015-09-06 19:51:06 +02:00
UsrDat->FamilyPhone,
2015-12-13 17:49:53 +01:00
Rec_C2_BOTTOM - 20);
2015-03-29 13:57:24 +02:00
else if (UsrDat->FamilyPhone[0])
fprintf (Gbl.F.Out,"%s",UsrDat->FamilyPhone);
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
2015-03-29 13:57:24 +02:00
/* Common comments for all the courses */
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_TOP\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s:"
"</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_TOP\""
" style=\"width:%upx;\">",
ClassForm,Rec_C1_BOTTOM,Txt_USER_comments,
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
if (ShowData)
{
if (DataForm)
2015-12-13 13:53:00 +01:00
fprintf (Gbl.F.Out,"<textarea name=\"Comments\" rows=\"4\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-08-24 11:25:20 +02:00
"%s"
"</textarea>",
2015-12-13 17:49:53 +01:00
Rec_C2_BOTTOM - 20,
2015-03-29 13:57:24 +02:00
UsrDat->Comments);
else if (UsrDat->Comments[0])
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
UsrDat->Comments,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML
fprintf (Gbl.F.Out,"%s",UsrDat->Comments);
}
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2014-12-01 23:55:08 +01:00
2015-03-29 13:57:24 +02:00
/***** Institution, centre, department, office, etc. *****/
if (ShowTeacherRows)
2014-12-01 23:55:08 +01:00
{
2015-03-29 13:57:24 +02:00
/* Institution */
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s:"
"</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,Txt_Institution,
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
if (ShowData)
2014-12-01 23:55:08 +01:00
{
2015-03-29 13:57:24 +02:00
if (UsrDat->InsCod > 0)
{
if (Ins.WWW[0])
2015-12-13 17:49:53 +01:00
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
" class=\"REC_DAT_BOLD\">",
Ins.WWW);
2015-03-29 13:57:24 +02:00
fprintf (Gbl.F.Out,"%s",Ins.FullName);
if (Ins.WWW[0])
fprintf (Gbl.F.Out,"</a>");
}
2014-12-01 23:55:08 +01:00
}
2015-03-29 13:57:24 +02:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
2015-03-29 13:57:24 +02:00
/* Centre */
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s:"
"</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,Txt_Centre,
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
if (ShowData)
{
if (UsrDat->Tch.CtrCod > 0)
{
Ctr.CtrCod = UsrDat->Tch.CtrCod;
Ctr_GetDataOfCentreByCod (&Ctr);
if (Ctr.WWW[0])
2015-12-13 17:49:53 +01:00
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
" class=\"REC_DAT_BOLD\">",
Ctr.WWW);
2015-03-29 13:57:24 +02:00
fprintf (Gbl.F.Out,"%s",Ctr.FullName);
if (Ctr.WWW[0])
fprintf (Gbl.F.Out,"</a>");
}
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
2015-03-29 13:57:24 +02:00
/* Department */
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s:"
"</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,Txt_Department,
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
if (ShowData)
{
if (UsrDat->Tch.DptCod > 0)
{
Dpt.DptCod = UsrDat->Tch.DptCod;
Dpt_GetDataOfDepartmentByCod (&Dpt);
if (Dpt.WWW[0])
2015-12-13 17:49:53 +01:00
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
" class=\"REC_DAT_BOLD\">",
Dpt.WWW);
2015-03-29 13:57:24 +02:00
fprintf (Gbl.F.Out,"%s",Dpt.FullName);
if (Dpt.WWW[0])
fprintf (Gbl.F.Out,"</a>");
}
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
2015-03-29 13:57:24 +02:00
/* Office */
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s:"
"</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,Txt_Office,
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
if (ShowData)
fprintf (Gbl.F.Out,"%s",UsrDat->Tch.Office);
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
2015-03-29 13:57:24 +02:00
/* Phone */
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">"
2015-03-29 13:57:24 +02:00
"%s:"
"</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
2015-09-24 18:02:21 +02:00
" style=\"width:%upx;\">",
2015-12-13 17:49:53 +01:00
ClassForm,Rec_C1_BOTTOM,Txt_Phone,
Rec_C2_BOTTOM);
2015-03-29 13:57:24 +02:00
if (ShowData)
fprintf (Gbl.F.Out,"%s",UsrDat->Tch.OfficePhone);
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2015-03-29 15:03:35 +02:00
fprintf (Gbl.F.Out,"</table>");
2015-03-29 13:57:24 +02:00
2015-03-29 21:43:33 +02:00
switch (TypeOfView)
{
case Rec_FORM_MY_COMMON_RECORD:
Lay_PutConfirmButton (Txt_Save_changes);
Act_FormEnd ();
break;
case Rec_FORM_NEW_RECORD_OTHER_NEW_USR:
if (Gbl.CurrentCrs.Grps.NumGrps) // This course has groups?
Grp_ShowLstGrpsToChgOtherUsrsGrps (UsrDat->UsrCod);
Lay_PutConfirmButton (Txt_Register);
Act_FormEnd ();
break;
case Rec_FORM_MODIFY_RECORD_OTHER_EXISTING_USR:
/***** Show list of groups to register/remove me/user *****/
if (Gbl.CurrentCrs.Grps.NumGrps) // This course has groups?
{
if (ItsMe)
{
// Don't show groups if I don't belong to course
if (Gbl.Usrs.Me.IBelongToCurrentCrs)
2015-04-07 21:44:24 +02:00
Grp_ShowLstGrpsToChgMyGrps ((Gbl.Usrs.Me.LoggedRole == Rol_STUDENT));
2015-03-29 21:43:33 +02:00
}
else
Grp_ShowLstGrpsToChgOtherUsrsGrps (UsrDat->UsrCod);
}
/***** Which action, register or removing? *****/
if (Enr_PutActionsRegRemOneUsr (ItsMe))
Lay_PutConfirmButton (Txt_Confirm);
Act_FormEnd ();
break;
default:
break;
}
2014-12-01 23:55:08 +01:00
2015-03-29 14:09:23 +02:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2014-12-08 17:35:48 +01:00
/***** End frame *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ();
2015-03-05 23:18:43 +01:00
}
2014-12-01 23:55:08 +01:00
2016-04-22 12:24:02 +02:00
/*****************************************************************************/
/*********************** Show institution in record card *********************/
/*****************************************************************************/
static void Rec_ShowInstitution (struct Institution *Ins,bool PutFormLinks)
{
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\""
" style=\"width:%upx; height:%upx;\">",
Rec_C1_TOP,Rec_C1_TOP);
if (Ins->InsCod > 0)
{
/* Form to go to the institution */
if (PutFormLinks)
{
Act_FormGoToStart (ActSeeInsInf);
Ins_PutParamInsCod (Ins->InsCod);
Act_LinkFormSubmit (Ins->FullName,NULL);
}
Log_DrawLogo (Sco_SCOPE_INS,Ins->InsCod,Ins->ShortName,
Rec_INSTITUTION_LOGO_SIZE,NULL,true);
if (PutFormLinks)
{
fprintf (Gbl.F.Out,"</a>");
Act_FormEnd ();
}
}
fprintf (Gbl.F.Out,"</td>"
"<td class=\"REC_HEAD LEFT_MIDDLE\""
" style=\"width:%upx; height:%upx;\">",
Rec_C2_TOP,Rec_C1_TOP);
if (Ins->InsCod > 0)
{
/* Form to go to the institution */
if (PutFormLinks)
{
Act_FormGoToStart (ActSeeInsInf);
Ins_PutParamInsCod (Ins->InsCod);
Act_LinkFormSubmit (Ins->FullName,"REC_HEAD");
}
fprintf (Gbl.F.Out,"%s",Ins->FullName);
if (PutFormLinks)
{
fprintf (Gbl.F.Out,"</a>");
Act_FormEnd ();
}
}
fprintf (Gbl.F.Out,"</td>");
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/*********************** Write a link to netiquette rules ********************/
/*****************************************************************************/
static void Rec_WriteLinkToDataProtectionClause (void)
{
extern const char *Txt_DATA_PROTECTION_CLAUSE;
char Title[1024];
2015-08-24 11:25:20 +02:00
sprintf (Title,"<div class=\"CENTER_MIDDLE\">"
2015-04-02 13:38:05 +02:00
"<a href=\"%s/%s/\" target=\"_blank\">%s</a>"
"</div>",
2016-03-15 23:11:14 +01:00
Cfg_HTTPS_URL_SWAD_PUBLIC,Cfg_DATA_PROTECTION_FOLDER,
2014-12-01 23:55:08 +01:00
Txt_DATA_PROTECTION_CLAUSE);
Lay_WriteTitle (Title);
}
/*****************************************************************************/
/**************** Update and show data from identified user ******************/
/*****************************************************************************/
void Rec_UpdateMyRecord (void)
{
/***** Get my data from record form *****/
Rec_GetUsrNameFromRecordForm (&Gbl.Usrs.Me.UsrDat);
Rec_GetUsrExtraDataFromRecordForm (&Gbl.Usrs.Me.UsrDat);
/***** Update my data in database *****/
2014-12-12 18:50:36 +01:00
Enr_UpdateUsrData (&Gbl.Usrs.Me.UsrDat);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/**** Get and check future user's role in current course from record form ****/
/*****************************************************************************/
Rol_Role_t Rec_GetRoleFromRecordForm (void)
{
char UnsignedStr[10+1];
Rol_Role_t Role;
2015-09-16 22:13:00 +02:00
bool RoleOK = false;
2014-12-01 23:55:08 +01:00
/***** Get role as a parameter from form *****/
Par_GetParToText ("Role",UnsignedStr,10);
2014-12-12 20:25:00 +01:00
Role = Rol_ConvertUnsignedStrToRole (UnsignedStr);
2014-12-01 23:55:08 +01:00
/***** Check if I can register a user
with the received role in current course *****/
/* Check for other possible errors */
switch (Gbl.Usrs.Me.LoggedRole)
{
2015-04-07 21:44:24 +02:00
case Rol_STUDENT: // I am logged as student
2014-12-01 23:55:08 +01:00
/* A student can only change his/her data, but not his/her role */
2015-09-16 22:13:00 +02:00
if (Role == Rol_STUDENT)
RoleOK = true;
2014-12-01 23:55:08 +01:00
break;
2015-04-07 21:44:24 +02:00
case Rol_TEACHER: // I am logged as teacher
2014-12-01 23:55:08 +01:00
/* A teacher can only register another user as teacher
if the other is already teacher in any course.
That is, a teacher can not upgrade a student
(in all other courses) to teacher */
2015-09-16 22:13:00 +02:00
if ( Role == Rol_STUDENT ||
(Role == Rol_TEACHER && // He/she will be a teacher in current course
(Gbl.Usrs.Other.UsrDat.Roles & (1 << Rol_TEACHER)))) // He/she was a teacher in some courses
RoleOK = true;
2014-12-01 23:55:08 +01:00
break;
2015-09-16 22:13:00 +02:00
case Rol_DEG_ADM: // I am logged as admin
case Rol_CTR_ADM:
case Rol_INS_ADM:
if (Role == Rol_STUDENT ||
Role == Rol_TEACHER)
RoleOK = true;
break;
case Rol_SYS_ADM:
if ( Role == Rol_STUDENT ||
Role == Rol_TEACHER ||
(Role == Rol__GUEST_ && Gbl.CurrentCrs.Crs.CrsCod <= 0))
RoleOK = true;
break;
2014-12-01 23:55:08 +01:00
default:
break;
}
2015-09-16 22:13:00 +02:00
if (!RoleOK)
Lay_ShowErrorAndExit ("Wrong user's role.");
2014-12-01 23:55:08 +01:00
return Role;
}
/*****************************************************************************/
/*************** Get data fields of common record from form ******************/
/*****************************************************************************/
void Rec_GetUsrNameFromRecordForm (struct UsrData *UsrDat)
{
Par_GetParToText ("Surname1",UsrDat->Surname1,Usr_MAX_BYTES_NAME);
Str_ConvertToTitleType (UsrDat->Surname1);
Par_GetParToText ("Surname2",UsrDat->Surname2,Usr_MAX_BYTES_NAME);
Str_ConvertToTitleType (UsrDat->Surname2);
Par_GetParToText ("FirstName",UsrDat->FirstName,Usr_MAX_BYTES_NAME);
Str_ConvertToTitleType (UsrDat->FirstName);
Usr_BuildFullName (UsrDat);
}
2015-12-07 23:13:08 +01:00
static void Rec_GetUsrExtraDataFromRecordForm (struct UsrData *UsrDat)
2014-12-01 23:55:08 +01:00
{
char UnsignedStr[10+1];
char LongStr[1+10+1];
unsigned UnsignedNum;
/***** Get sex from form *****/
Par_GetParToText ("Sex",UnsignedStr,10);
UsrDat->Sex = Usr_SEX_UNKNOWN;
if (sscanf (UnsignedStr,"%u",&UnsignedNum) == 1)
if (UnsignedNum <= Usr_SEX_MALE)
UsrDat->Sex = (Usr_Sex_t) UnsignedNum;
/***** Get country code *****/
Par_GetParToText ("OthCtyCod",LongStr,1+10);
UsrDat->CtyCod = Str_ConvertStrCodToLongCod (LongStr);
Par_GetParToText ("OriginPlace",UsrDat->OriginPlace,Cns_MAX_BYTES_STRING);
Str_ConvertToTitleType (UsrDat->OriginPlace);
2015-10-23 01:06:32 +02:00
Dat_GetDateFromForm ("BirthDay","BirthMonth","BirthYear",
&(UsrDat->Birthday.Day ),
&(UsrDat->Birthday.Month),
&(UsrDat->Birthday.Year ));
2014-12-01 23:55:08 +01:00
Dat_ConvDateToDateStr (&(UsrDat->Birthday),UsrDat->StrBirthday);
Par_GetParToText ("LocalAddress",UsrDat->LocalAddress,Cns_MAX_BYTES_STRING);
Par_GetParToText ("LocalPhone",UsrDat->LocalPhone,Usr_MAX_BYTES_PHONE);
Par_GetParToText ("FamilyAddress",UsrDat->FamilyAddress,Cns_MAX_BYTES_STRING);
Par_GetParToText ("FamilyPhone",UsrDat->FamilyPhone,Usr_MAX_BYTES_PHONE);
Rec_GetUsrCommentsFromForm (UsrDat);
}
/*****************************************************************************/
/********** Get the comments of the record of a user from the form ***********/
/*****************************************************************************/
static void Rec_GetUsrCommentsFromForm (struct UsrData *UsrDat)
{
/***** Check if memory is allocated for comments *****/
if (!UsrDat->Comments)
Lay_ShowErrorAndExit ("Can not read comments of a user.");
/***** Get the parameter with the comments *****/
Par_GetParToHTML ("Comments",UsrDat->Comments,Cns_MAX_BYTES_TEXT);
}
/*****************************************************************************/
/*** Put a link to the action to edit my institution, centre, department... **/
/*****************************************************************************/
2016-01-04 16:45:43 +01:00
void Rec_PutLinkToChangeMyInsCtrDpt (void)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_Edit_my_institution;
/***** Link to edit my institution, centre, department... *****/
2015-12-13 19:02:06 +01:00
Lay_PutContextualLink (ActReqEdiMyIns,NULL,"ins64x64.gif",
Txt_Edit_my_institution,Txt_Edit_my_institution);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********* Show form to edit my institution, centre and department ***********/
/*****************************************************************************/
2015-09-24 18:02:21 +02:00
#define COL2_WIDTH 600
2014-12-01 23:55:08 +01:00
void Rec_ShowFormMyInsCtrDpt (void)
{
2015-07-28 00:16:09 +02:00
extern const char *The_ClassForm[The_NUM_THEMES];
2015-03-28 18:34:08 +01:00
extern const char *Txt_Please_fill_in_your_institution;
extern const char *Txt_Please_fill_in_your_centre_and_department;
2014-12-01 23:55:08 +01:00
extern const char *Txt_Institution_centre_and_department;
extern const char *Txt_Institution;
2015-12-09 19:51:17 +01:00
extern const char *Txt_Country_of_the_institution;
2014-12-01 23:55:08 +01:00
extern const char *Txt_Another_institution;
extern const char *Txt_Centre;
extern const char *Txt_Another_centre;
extern const char *Txt_Department;
extern const char *Txt_Another_department;
extern const char *Txt_Office;
extern const char *Txt_Phone;
2015-07-28 00:16:09 +02:00
const char *ClassForm = The_ClassForm[Gbl.Prefs.Theme];
2014-12-01 23:55:08 +01:00
unsigned NumCty;
unsigned NumIns;
unsigned NumCtr;
unsigned NumDpt;
2015-04-07 21:44:24 +02:00
bool IAmTeacher = (Gbl.Usrs.Me.UsrDat.Roles & (1 << Rol_TEACHER));
2014-12-01 23:55:08 +01:00
/***** If there is no institution, centre or department *****/
if (Gbl.Usrs.Me.UsrDat.InsCtyCod < 0 ||
Gbl.Usrs.Me.UsrDat.InsCod < 0)
2015-03-28 18:34:08 +01:00
Lay_ShowAlert (Lay_WARNING,Txt_Please_fill_in_your_institution);
2015-04-07 21:44:24 +02:00
else if ((Gbl.Usrs.Me.UsrDat.Roles & (1 << Rol_TEACHER)) &&
2014-12-01 23:55:08 +01:00
(Gbl.Usrs.Me.UsrDat.Tch.CtrCod < 0 ||
Gbl.Usrs.Me.UsrDat.Tch.DptCod < 0))
2015-03-28 18:34:08 +01:00
Lay_ShowAlert (Lay_WARNING,Txt_Please_fill_in_your_centre_and_department);
2014-12-01 23:55:08 +01:00
/***** Start table *****/
2015-10-06 01:19:21 +02:00
Lay_StartRoundFrameTable ("800px",2,
2015-04-12 18:01:06 +02:00
IAmTeacher ? Txt_Institution_centre_and_department :
Txt_Institution);
2014-12-01 23:55:08 +01:00
/***** Country *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
"%s:"
"</td>"
2015-09-24 18:02:21 +02:00
"<td class=\"LEFT_MIDDLE\" style=\"width:%upx;\">",
2015-12-09 19:51:17 +01:00
ClassForm,Txt_Country_of_the_institution,
2015-09-24 18:02:21 +02:00
COL2_WIDTH);
2014-12-01 23:55:08 +01:00
/* If list of countries is empty, try to get it */
if (!Gbl.Ctys.Num)
{
Gbl.Ctys.SelectedOrderType = Cty_ORDER_BY_COUNTRY;
2015-12-09 19:51:17 +01:00
Cty_GetListCountries (Cty_GET_BASIC_DATA);
2014-12-01 23:55:08 +01:00
}
/* Start form to select the country of my institution */
Act_FormGoToStart (ActChgCtyMyIns);
2015-09-28 18:28:29 +02:00
fprintf (Gbl.F.Out,"<select name=\"OthCtyCod\" style=\"width:500px;\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\">"
2014-12-01 23:55:08 +01:00
"<option value=\"-1\"",
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2014-12-01 23:55:08 +01:00
if (Gbl.Usrs.Me.UsrDat.InsCtyCod <= 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out," disabled=\"disabled\"></option>");
for (NumCty = 0;
NumCty < Gbl.Ctys.Num;
NumCty++)
{
fprintf (Gbl.F.Out,"<option value=\"%ld\"",
Gbl.Ctys.Lst[NumCty].CtyCod);
if (Gbl.Ctys.Lst[NumCty].CtyCod == Gbl.Usrs.Me.UsrDat.InsCtyCod)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Gbl.Ctys.Lst[NumCty].Name[Gbl.Prefs.Language]);
}
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</select>");
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Institution *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
"%s:"
"</td>"
2015-09-24 18:02:21 +02:00
"<td class=\"LEFT_MIDDLE\" style=\"width:%upx;\">",
2015-07-27 19:42:24 +02:00
ClassForm,Txt_Institution,
2015-09-24 18:02:21 +02:00
COL2_WIDTH);
2014-12-01 23:55:08 +01:00
/* Get list of institutions in this country */
Ins_FreeListInstitutions ();
if (Gbl.Usrs.Me.UsrDat.InsCtyCod > 0)
2015-12-09 19:51:17 +01:00
Ins_GetListInstitutions (Gbl.Usrs.Me.UsrDat.InsCtyCod,Ins_GET_BASIC_DATA);
2014-12-01 23:55:08 +01:00
/* Start form to select institution */
Act_FormGoToStart (ActChgMyIns);
2015-09-28 18:28:29 +02:00
fprintf (Gbl.F.Out,"<select name=\"OthInsCod\" style=\"width:500px;\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\">"
2014-12-01 23:55:08 +01:00
"<option value=\"-1\"",
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2014-12-01 23:55:08 +01:00
if (Gbl.Usrs.Me.UsrDat.InsCod < 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out," disabled=\"disabled\"></option>"
"<option value=\"0\"");
if (Gbl.Usrs.Me.UsrDat.InsCod == 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_Another_institution);
for (NumIns = 0;
NumIns < Gbl.Inss.Num;
NumIns++)
{
fprintf (Gbl.F.Out,"<option value=\"%ld\"",
Gbl.Inss.Lst[NumIns].InsCod);
if (Gbl.Inss.Lst[NumIns].InsCod == Gbl.Usrs.Me.UsrDat.InsCod)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Gbl.Inss.Lst[NumIns].FullName);
}
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</select>");
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
if (IAmTeacher)
{
/***** Centre *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
"%s:"
"</td>"
2015-09-24 18:02:21 +02:00
"<td class=\"LEFT_MIDDLE\" style=\"width:%upx;\">",
2015-07-27 19:42:24 +02:00
ClassForm,Txt_Centre,
2015-09-24 18:02:21 +02:00
COL2_WIDTH);
2014-12-01 23:55:08 +01:00
/* Get list of centres in this institution */
Ctr_FreeListCentres ();
if (Gbl.Usrs.Me.UsrDat.InsCod > 0)
Ctr_GetListCentres (Gbl.Usrs.Me.UsrDat.InsCod);
/* Start form to select centre */
Act_FormGoToStart (ActChgMyCtr);
2015-09-28 18:28:29 +02:00
fprintf (Gbl.F.Out,"<select name=\"OthCtrCod\" style=\"width:500px;\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\">"
2014-12-01 23:55:08 +01:00
"<option value=\"-1\"",
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2014-12-01 23:55:08 +01:00
if (Gbl.Usrs.Me.UsrDat.Tch.CtrCod < 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out," disabled=\"disabled\"></option>"
"<option value=\"0\"");
if (Gbl.Usrs.Me.UsrDat.Tch.CtrCod == 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_Another_centre);
for (NumCtr = 0;
NumCtr < Gbl.Ctrs.Num;
NumCtr++)
{
fprintf (Gbl.F.Out,"<option value=\"%ld\"",
Gbl.Ctrs.Lst[NumCtr].CtrCod);
if (Gbl.Ctrs.Lst[NumCtr].CtrCod == Gbl.Usrs.Me.UsrDat.Tch.CtrCod)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Gbl.Ctrs.Lst[NumCtr].FullName);
}
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</select>");
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Department *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
"%s:"
"</td>"
2015-09-24 18:02:21 +02:00
"<td class=\"LEFT_MIDDLE\" style=\"width:%upx;\">",
2015-07-27 19:42:24 +02:00
ClassForm,Txt_Department,
2015-09-24 18:02:21 +02:00
COL2_WIDTH);
2014-12-01 23:55:08 +01:00
/* Get list of departments in this institution */
Dpt_FreeListDepartments ();
if (Gbl.Usrs.Me.UsrDat.InsCod > 0)
Dpt_GetListDepartments (Gbl.Usrs.Me.UsrDat.InsCod);
/* Start form to select department */
Act_FormGoToStart (ActChgMyDpt);
2015-09-28 18:28:29 +02:00
fprintf (Gbl.F.Out,"<select name=\"DptCod\" style=\"width:500px;\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\">"
2014-12-01 23:55:08 +01:00
"<option value=\"-1\"",
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2014-12-01 23:55:08 +01:00
if (Gbl.Usrs.Me.UsrDat.Tch.DptCod < 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out," disabled=\"disabled\"></option>"
"<option value=\"0\"");
if (Gbl.Usrs.Me.UsrDat.Tch.DptCod == 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_Another_department);
for (NumDpt = 0;
NumDpt < Gbl.Dpts.Num;
NumDpt++)
{
fprintf (Gbl.F.Out,"<option value=\"%ld\"",
Gbl.Dpts.Lst[NumDpt].DptCod);
if (Gbl.Dpts.Lst[NumDpt].DptCod == Gbl.Usrs.Me.UsrDat.Tch.DptCod)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Gbl.Dpts.Lst[NumDpt].FullName);
}
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</select>");
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Office *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
"%s:"
"</td>"
2015-09-24 18:02:21 +02:00
"<td class=\"LEFT_MIDDLE\" style=\"width:%upx;\">",
2015-07-27 19:42:24 +02:00
ClassForm,Txt_Office,
2015-09-24 18:02:21 +02:00
COL2_WIDTH);
2014-12-01 23:55:08 +01:00
Act_FormGoToStart (ActChgMyOff);
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"Office\""
2015-09-23 14:31:47 +02:00
" maxlength=\"%u\" value=\"%s\""
2015-09-28 18:28:29 +02:00
" style=\"width:500px;\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\" />",
2014-12-01 23:55:08 +01:00
Cns_MAX_LENGTH_STRING,
Gbl.Usrs.Me.UsrDat.Tch.Office,
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
/***** Phone *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-28 00:16:09 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
"%s:"
"</td>"
2015-09-24 18:02:21 +02:00
"<td class=\"LEFT_MIDDLE\" style=\"width:%upx;\">",
2015-07-27 19:42:24 +02:00
ClassForm,Txt_Phone,
2015-09-24 18:02:21 +02:00
COL2_WIDTH);
2014-12-01 23:55:08 +01:00
Act_FormGoToStart (ActChgMyOffPho);
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"OfficePhone\""
2015-09-06 19:51:06 +02:00
" maxlength=\"%u\" value=\"%s\""
2015-09-28 18:28:29 +02:00
" style=\"width:500px;\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\" />",
2014-12-01 23:55:08 +01:00
Usr_MAX_LENGTH_PHONE,
Gbl.Usrs.Me.UsrDat.Tch.OfficePhone,
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
}
/***** End table *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******** Receive form data to change the country of my institution **********/
/*****************************************************************************/
void Rec_ChgCountryOfMyInstitution (void)
{
/***** Get country of my institution *****/
/* Get country code */
if ((Gbl.Usrs.Me.UsrDat.InsCtyCod = Cty_GetParamOtherCtyCod ()) < 0)
Lay_ShowErrorAndExit ("Code of institution country is missing.");
/***** Update institution, centre and department *****/
// When country changes, the institution, centre and department must be reset
Gbl.Usrs.Me.UsrDat.InsCod = -1L;
Gbl.Usrs.Me.UsrDat.Tch.CtrCod = -1L;
Gbl.Usrs.Me.UsrDat.Tch.DptCod = -1L;
2014-12-12 18:50:36 +01:00
Enr_UpdateInstitutionCentreDepartment ();
2014-12-01 23:55:08 +01:00
/***** Show form again *****/
Rec_ShowFormMyInsCtrDpt ();
}
/*****************************************************************************/
/**************** Receive form data to change my institution *****************/
/*****************************************************************************/
void Rec_UpdateMyInstitution (void)
{
struct Institution Ins;
/***** Get my institution *****/
/* Get institution code */
if ((Ins.InsCod = Ins_GetParamOtherInsCod ()) < 0)
Lay_ShowErrorAndExit ("Code of institution is missing.");
/* Get country of institution */
if (Ins.InsCod > 0)
{
2015-12-09 19:51:17 +01:00
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
2014-12-01 23:55:08 +01:00
if (Gbl.Usrs.Me.UsrDat.InsCtyCod != Ins.CtyCod)
Gbl.Usrs.Me.UsrDat.InsCtyCod = Ins.CtyCod;
}
/***** Update institution, centre and department *****/
Gbl.Usrs.Me.UsrDat.InsCod = Ins.InsCod;
Gbl.Usrs.Me.UsrDat.Tch.CtrCod = -1L;
Gbl.Usrs.Me.UsrDat.Tch.DptCod = -1L;
2014-12-12 18:50:36 +01:00
Enr_UpdateInstitutionCentreDepartment ();
2014-12-01 23:55:08 +01:00
/***** Show form again *****/
Rec_ShowFormMyInsCtrDpt ();
}
/*****************************************************************************/
/******************* Receive form data to change my centre *******************/
/*****************************************************************************/
void Rec_UpdateMyCentre (void)
{
struct Centre Ctr;
/***** Get my centre *****/
/* Get centre code */
if ((Ctr.CtrCod = Ctr_GetParamOtherCtrCod ()) < 0)
Lay_ShowErrorAndExit ("Code of centre is missing.");
/* Get institution of centre */
if (Ctr.CtrCod > 0)
{
Ctr_GetDataOfCentreByCod (&Ctr);
if (Gbl.Usrs.Me.UsrDat.InsCod != Ctr.InsCod)
{
Gbl.Usrs.Me.UsrDat.InsCod = Ctr.InsCod;
Gbl.Usrs.Me.UsrDat.Tch.DptCod = -1L;
}
}
/***** Update institution, centre and department *****/
Gbl.Usrs.Me.UsrDat.Tch.CtrCod = Ctr.CtrCod;
2014-12-12 18:50:36 +01:00
Enr_UpdateInstitutionCentreDepartment ();
2014-12-01 23:55:08 +01:00
/***** Show form again *****/
Rec_ShowFormMyInsCtrDpt ();
}
/*****************************************************************************/
/***************** Receive form data to change my department *****************/
/*****************************************************************************/
void Rec_UpdateMyDepartment (void)
{
struct Department Dpt;
/***** Get my department *****/
/* Get department code */
if ((Dpt.DptCod = Dpt_GetParamDptCod ()) < 0)
Lay_ShowErrorAndExit ("Code of department is missing.");
/* Get institution of department */
if (Dpt.DptCod > 0)
{
Dpt_GetDataOfDepartmentByCod (&Dpt);
if (Gbl.Usrs.Me.UsrDat.InsCod != Dpt.InsCod)
{
Gbl.Usrs.Me.UsrDat.InsCod = Dpt.InsCod;
Gbl.Usrs.Me.UsrDat.Tch.CtrCod = -1L;
}
}
/***** Update institution, centre and department *****/
Gbl.Usrs.Me.UsrDat.Tch.DptCod = Dpt.DptCod;
2014-12-12 18:50:36 +01:00
Enr_UpdateInstitutionCentreDepartment ();
2014-12-01 23:55:08 +01:00
/***** Show form again *****/
Rec_ShowFormMyInsCtrDpt ();
}
/*****************************************************************************/
/******************* Receive form data to change my office *******************/
/*****************************************************************************/
void Rec_UpdateMyOffice (void)
{
char Query[128+Cns_MAX_BYTES_STRING];
/***** Get my office *****/
Par_GetParToText ("Office",Gbl.Usrs.Me.UsrDat.Tch.Office,Cns_MAX_BYTES_STRING);
/***** Update office *****/
2015-11-21 20:23:28 +01:00
sprintf (Query,"UPDATE usr_data SET Office='%s'"
2014-12-01 23:55:08 +01:00
" WHERE UsrCod='%ld'",
Gbl.Usrs.Me.UsrDat.Tch.Office,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE (Query,"can not update office");
/***** Show form again *****/
Rec_ShowFormMyInsCtrDpt ();
}
/*****************************************************************************/
/**************** Receive form data to change my office phone ****************/
/*****************************************************************************/
void Rec_UpdateMyOfficePhone (void)
{
char Query[128+Usr_MAX_BYTES_PHONE];
/***** Get my office *****/
Par_GetParToText ("OfficePhone",Gbl.Usrs.Me.UsrDat.Tch.OfficePhone,Usr_MAX_BYTES_PHONE);
/***** Update office phone *****/
2015-11-21 20:23:28 +01:00
sprintf (Query,"UPDATE usr_data SET OfficePhone='%s'"
2014-12-01 23:55:08 +01:00
" WHERE UsrCod='%ld'",
Gbl.Usrs.Me.UsrDat.Tch.OfficePhone,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE (Query,"can not update office phone");
/***** Show form again *****/
Rec_ShowFormMyInsCtrDpt ();
}