swad-core/swad_record.c

4355 lines
156 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.
2019-01-07 21:52:19 +01:00
Copyright (C) 1999-2019 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>
2018-10-16 01:36:13 +02:00
#include "swad_account.h"
2014-12-01 23:55:08 +01:00
#include "swad_action.h"
2017-06-10 21:38:10 +02:00
#include "swad_box.h"
2014-12-01 23:55:08 +01:00
#include "swad_config.h"
#include "swad_database.h"
2017-03-30 11:20:06 +02:00
#include "swad_enrolment.h"
2015-03-18 01:06:43 +01:00
#include "swad_follow.h"
2018-11-09 20:47:39 +01:00
#include "swad_form.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"
2016-12-09 13:59:33 +01:00
#include "swad_privacy.h"
2014-12-01 23:55:08 +01:00
#include "swad_QR.h"
#include "swad_record.h"
2016-12-13 13:32:19 +01:00
#include "swad_role.h"
2019-03-26 11:53:21 +01:00
#include "swad_setting.h"
2017-06-11 20:09:59 +02:00
#include "swad_table.h"
2014-12-01 23:55:08 +01:00
#include "swad_user.h"
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/***************************** 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
2018-10-08 12:37:29 +02:00
#define Rec_MY_INS_CTR_DPT_ID "my_ins_ctr_dpt_section"
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
static void Rec_WriteHeadingRecordFields (void);
2017-04-28 11:38:21 +02:00
static void Rec_PutParamFielCod (void);
2017-03-08 01:21:21 +01:00
static void Rec_GetFieldByCod (long FieldCod,char Name[Rec_MAX_BYTES_NAME_FIELD + 1],
2017-01-15 22:58:26 +01:00
unsigned *NumLines,Rec_VisibilityRecordFields_t *Visibility);
2014-12-01 23:55:08 +01:00
2017-05-09 20:56:02 +02:00
static void Rec_ListRecordsGsts (Rec_SharedRecordViewType_t TypeOfView);
2015-03-05 18:58:59 +01:00
static void Rec_ShowRecordOneStdCrs (void);
2016-11-18 00:17:53 +01:00
static void Rec_ListRecordsStds (Rec_SharedRecordViewType_t ShaTypeOfView,
Rec_CourseRecordViewType_t CrsTypeOfView);
2017-05-09 20:56:02 +02:00
2015-03-05 18:58:59 +01:00
static void Rec_ShowRecordOneTchCrs (void);
2017-05-09 20:56:02 +02:00
static void Rec_ListRecordsTchs (Rec_SharedRecordViewType_t TypeOfView);
2015-03-05 18:58:59 +01:00
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);
2016-11-27 17:30:10 +01:00
static void Rec_WriteFormShowOfficeHoursOneTch (bool ShowOfficeHours);
static void Rec_WriteFormShowOfficeHoursSeveralTchs (bool ShowOfficeHours);
static void Rec_PutParamsShowOfficeHoursOneTch (void);
static void Rec_PutParamsShowOfficeHoursSeveralTchs (void);
2014-12-01 23:55:08 +01:00
static bool Rec_GetParamShowOfficeHours (void);
2016-11-18 00:17:53 +01:00
static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
struct UsrData *UsrDat,const char *Anchor);
2015-03-30 13:59:32 +02:00
static void Rec_ShowMyCrsRecordUpdated (void);
2017-05-22 14:52:11 +02:00
static bool Rec_CheckIfICanEditField (Rec_VisibilityRecordFields_t Visibility);
2016-04-22 12:24:02 +02:00
2016-05-05 14:20:38 +02:00
static void Rec_PutIconsCommands (void);
2019-02-11 22:15:18 +01:00
static void Rec_PutParamsMyTsts (void);
static void Rec_PutParamsStdTsts (void);
2016-05-05 14:20:38 +02:00
static void Rec_PutParamsWorks (void);
static void Rec_PutParamsStudent (void);
static void Rec_PutParamsMsgUsr (void);
2016-10-28 10:03:37 +02:00
static void Rec_ShowInstitutionInHead (struct Instit *Ins,bool PutFormLinks);
2016-04-22 12:39:36 +02:00
static void Rec_ShowPhoto (struct UsrData *UsrDat);
2016-04-22 12:44:56 +02:00
static void Rec_ShowFullName (struct UsrData *UsrDat);
2016-04-22 19:50:59 +02:00
static void Rec_ShowNickname (struct UsrData *UsrDat,bool PutFormLinks);
2016-04-23 13:58:20 +02:00
static void Rec_ShowCountryInHead (struct UsrData *UsrDat,bool ShowData);
2016-04-22 20:00:26 +02:00
static void Rec_ShowWebsAndSocialNets (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView);
2016-04-23 13:30:59 +02:00
static void Rec_ShowEmail (struct UsrData *UsrDat,const char *ClassForm);
2017-05-10 10:09:19 +02:00
static void Rec_ShowUsrIDs (struct UsrData *UsrDat,const char *ClassForm,
const char *Anchor);
2016-04-23 13:23:09 +02:00
static void Rec_ShowRole (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView,
2016-04-23 13:23:09 +02:00
const char *ClassForm);
2016-04-23 13:37:43 +02:00
static void Rec_ShowSurname1 (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView,
2017-01-25 18:48:41 +01:00
bool ICanEdit,
2016-04-23 13:37:43 +02:00
const char *ClassForm);
2016-04-23 13:45:03 +02:00
static void Rec_ShowSurname2 (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ICanEdit,
2016-04-23 13:45:03 +02:00
const char *ClassForm);
2016-04-23 13:49:38 +02:00
static void Rec_ShowFirstName (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView,
2017-01-25 18:48:41 +01:00
bool ICanEdit,
2016-04-23 13:49:38 +02:00
const char *ClassForm);
2016-04-23 13:58:20 +02:00
static void Rec_ShowCountry (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView,
2016-04-23 13:58:20 +02:00
const char *ClassForm);
2016-04-23 14:03:56 +02:00
static void Rec_ShowOriginPlace (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:03:56 +02:00
const char *ClassForm);
2016-04-23 14:06:49 +02:00
static void Rec_ShowDateOfBirth (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:06:49 +02:00
const char *ClassForm);
2016-04-23 14:12:52 +02:00
static void Rec_ShowLocalAddress (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:12:52 +02:00
const char *ClassForm);
2016-04-23 14:18:09 +02:00
static void Rec_ShowLocalPhone (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:18:09 +02:00
const char *ClassForm);
2016-04-23 14:31:57 +02:00
static void Rec_ShowFamilyAddress (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:31:57 +02:00
const char *ClassForm);
2016-04-23 14:36:02 +02:00
static void Rec_ShowFamilyPhone (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:36:02 +02:00
const char *ClassForm);
2016-04-23 14:43:53 +02:00
static void Rec_ShowComments (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:43:53 +02:00
const char *ClassForm);
2018-10-08 01:07:15 +02:00
static void Rec_ShowTeacherRows (struct UsrData *UsrDat,
struct Instit *Ins,
bool ShowData,const char *ClassForm);
2016-10-28 10:03:37 +02:00
static void Rec_ShowInstitution (struct Instit *Ins,
2016-04-23 14:51:12 +02:00
bool ShowData,const char *ClassForm);
2016-04-23 15:00:07 +02:00
static void Rec_ShowCentre (struct UsrData *UsrDat,
bool ShowData,const char *ClassForm);
2016-04-23 15:08:32 +02:00
static void Rec_ShowDepartment (struct UsrData *UsrDat,
bool ShowData,const char *ClassForm);
2016-04-23 15:15:06 +02:00
static void Rec_ShowOffice (struct UsrData *UsrDat,
bool ShowData,const char *ClassForm);
2016-04-23 15:20:37 +02:00
static void Rec_ShowOfficePhone (struct UsrData *UsrDat,
bool ShowData,const char *ClassForm);
2016-04-22 12:24:02 +02:00
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);
2018-10-08 12:37:29 +02:00
2018-10-09 22:51:12 +02:00
static void Rec_ShowFormMyInsCtrDpt (bool IAmATeacher);
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/*************** Create, edit and remove fields of records *******************/
/*****************************************************************************/
void Rec_ReqEditRecordFields (void)
{
2017-03-20 11:30:19 +01:00
extern const char *Hlp_USERS_Students_course_record_card;
2014-12-01 23:55:08 +01:00
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 *****/
2019-04-04 10:45:15 +02:00
if (Gbl.Crs.Records.LstFields.Num) // Fields found...
2014-12-01 23:55:08 +01:00
{
2017-06-12 14:16:33 +02:00
/* Start box and table */
2017-06-10 21:38:10 +02:00
Box_StartBoxTable (NULL,Txt_Record_fields,NULL,
2017-06-12 15:03:29 +02:00
Hlp_USERS_Students_course_record_card,Box_NOT_CLOSABLE,2);
2017-06-12 14:16:33 +02:00
2014-12-01 23:55:08 +01:00
Rec_ListFieldsRecordsForEdition ();
2017-06-12 14:16:33 +02:00
/* End table and box */
2017-06-10 21:38:10 +02:00
Box_EndBoxTable ();
2014-12-01 23:55:08 +01:00
}
else // No fields of records found for current course in the database
2019-02-16 18:25:41 +01:00
Ale_ShowAlert (Ale_INFO,Txt_There_are_no_record_fields_in_the_course_X,
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.FullName);
2014-12-01 23:55:08 +01:00
/***** 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)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRow;
unsigned Vis;
2019-04-04 10:45:15 +02:00
if (++Gbl.Crs.Records.LstFields.NestedCalls > 1) // If the list is already created, don't do anything
2014-12-01 23:55:08 +01:00
return;
2018-11-01 19:23:52 +01:00
/***** Get fields of records in a course from database *****/
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.LstFields.Num =
2018-11-01 19:23:52 +01:00
(unsigned) DB_QuerySELECT (&mysql_res,"can not get fields of records"
" in a course",
"SELECT FieldCod,FieldName,NumLines,Visibility"
" FROM crs_record_fields"
" WHERE CrsCod=%ld ORDER BY FieldName",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod);
2014-12-01 23:55:08 +01:00
/***** Get the fields of records *****/
2019-04-04 10:45:15 +02:00
if (Gbl.Crs.Records.LstFields.Num)
2014-12-01 23:55:08 +01:00
{
/***** Create a list of fields *****/
2019-04-04 10:45:15 +02:00
if ((Gbl.Crs.Records.LstFields.Lst = (struct RecordField *) calloc (Gbl.Crs.Records.LstFields.Num,sizeof (struct RecordField))) == NULL)
2018-10-18 20:06:54 +02:00
Lay_NotEnoughMemoryExit ();
2014-12-01 23:55:08 +01:00
/***** Get the fields *****/
for (NumRow = 0;
2019-04-04 10:45:15 +02:00
NumRow < Gbl.Crs.Records.LstFields.Num;
2014-12-01 23:55:08 +01:00
NumRow++)
{
/* Get next field */
row = mysql_fetch_row (mysql_res);
/* Get the code of field (row[0]) */
2019-04-04 10:45:15 +02:00
if ((Gbl.Crs.Records.LstFields.Lst[NumRow].FieldCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Wrong code of field.");
/* Name of the field (row[1]) */
2019-04-04 10:45:15 +02:00
Str_Copy (Gbl.Crs.Records.LstFields.Lst[NumRow].Name,row[1],
2017-03-08 01:21:21 +01:00
Rec_MAX_BYTES_NAME_FIELD);
2014-12-01 23:55:08 +01:00
/* Number of lines (row[2]) */
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.LstFields.Lst[NumRow].NumLines = Rec_ConvertToNumLinesField (row[2]);
2014-12-01 23:55:08 +01:00
/* 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)
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.LstFields.Lst[NumRow].Visibility = (Rec_VisibilityRecordFields_t) Vis;
2014-12-01 23:55:08 +01:00
else
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.LstFields.Lst[NumRow].Visibility = Rec_VISIBILITY_DEFAULT;
2014-12-01 23:55:08 +01:00
}
}
/***** 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;
2019-04-04 10:45:15 +02:00
NumField < Gbl.Crs.Records.LstFields.Num;
2014-12-01 23:55:08 +01:00
NumField++)
{
fprintf (Gbl.F.Out,"<tr>");
/* Write icon to remove the field */
2017-04-28 11:38:21 +02:00
fprintf (Gbl.F.Out,"<td class=\"BM\">");
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActReqRemFie);
2019-04-04 10:45:15 +02:00
Par_PutHiddenParamLong ("FieldCod",Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod);
2017-06-11 19:13:28 +02:00
Ico_PutIconRemove ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2015-03-13 00:16:02 +01:00
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\">");
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActRenFie);
2019-04-04 10:45:15 +02:00
Par_PutHiddenParamLong ("FieldCod",Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod);
2014-12-01 23:55:08 +01:00
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();\" />",
2017-03-08 01:21:21 +01:00
Rec_MAX_CHARS_NAME_FIELD,
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.LstFields.Lst[NumField].Name,
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2015-03-13 00:16:02 +01:00
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\">");
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActChgRowFie);
2019-04-04 10:45:15 +02:00
Par_PutHiddenParamLong ("FieldCod",Gbl.Crs.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();\" />",
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.LstFields.Lst[NumField].NumLines,
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2015-03-13 00:16:02 +01:00
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\">");
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActChgVisFie);
2019-04-04 10:45:15 +02:00
Par_PutHiddenParamLong ("FieldCod",Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod);
2014-12-01 23:55:08 +01:00
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);
2019-04-04 10:45:15 +02:00
if (Gbl.Crs.Records.LstFields.Lst[NumField].Visibility == Vis)
2014-12-01 23:55:08 +01:00
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>");
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2015-03-13 00:16:02 +01:00
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)
{
2017-03-20 11:30:19 +01:00
extern const char *Hlp_USERS_Students_course_record_card;
2014-12-01 23:55:08 +01:00
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 *****/
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActNewFie);
2014-12-01 23:55:08 +01:00
2017-06-12 14:16:33 +02:00
/***** Start box and table *****/
2017-06-10 21:38:10 +02:00
Box_StartBoxTable (NULL,Txt_New_record_field,NULL,
2017-06-12 15:03:29 +02:00
Hlp_USERS_Students_course_record_card,Box_NOT_CLOSABLE,2);
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\">");
2017-06-11 19:13:28 +02:00
Ico_PutIconRemovalNotAllowed ();
2015-07-22 19:20:30 +02:00
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\""
2016-11-19 20:09:52 +01:00
" style=\"width:500px;\" maxlength=\"%u\" value=\"%s\""
" required=\"required\" />"
2014-12-01 23:55:08 +01:00
"</td>",
2019-04-04 10:45:15 +02:00
Rec_MAX_CHARS_NAME_FIELD,Gbl.Crs.Records.Field.Name);
2014-12-01 23:55:08 +01:00
/***** 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\""
2016-11-19 20:09:52 +01:00
" size=\"2\" maxlength=\"2\" value=\"%u\""
" required=\"required\" />"
2014-12-01 23:55:08 +01:00
"</td>",
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.Field.NumLines);
2014-12-01 23:55:08 +01:00
/***** 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);
2019-04-04 10:45:15 +02:00
if (Gbl.Crs.Records.Field.Visibility == Vis)
2014-12-01 23:55:08 +01:00
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>");
2017-06-12 14:16:33 +02:00
/***** End table, send button and end box *****/
2017-06-11 19:02:40 +02:00
Box_EndBoxTableWithButton (Btn_CREATE_BUTTON,Txt_Create_record_field);
2015-03-24 17:47:26 +01:00
2015-04-11 23:46:21 +02:00
/***** End form *****/
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
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;
/***** Get parameters from the form *****/
/* Get the name of the field */
2019-04-04 10:45:15 +02:00
Par_GetParToText ("FieldName",Gbl.Crs.Records.Field.Name,
2017-03-11 18:59:13 +01:00
Rec_MAX_BYTES_NAME_FIELD);
2014-12-01 23:55:08 +01:00
/* Get the number of lines */
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.Field.NumLines = (unsigned)
2017-01-29 21:41:08 +01:00
Par_GetParToUnsignedLong ("NumLines",
Rec_MIN_LINES_IN_EDITION_FIELD,
Rec_MAX_LINES_IN_EDITION_FIELD,
Rec_DEF_LINES_IN_EDITION_FIELD);
2014-12-01 23:55:08 +01:00
/* Get the field visibility by students */
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.Field.Visibility = (Rec_VisibilityRecordFields_t)
2017-01-29 21:41:08 +01:00
Par_GetParToUnsignedLong ("Visibility",
0,
Rec_NUM_TYPES_VISIBILITY - 1,
(unsigned long) Rec_VISIBILITY_DEFAULT);
2014-12-01 23:55:08 +01:00
2019-04-04 10:45:15 +02:00
if (Gbl.Crs.Records.Field.Name[0]) // If there's a name
2014-12-01 23:55:08 +01:00
{
/***** If the field already was in the database... *****/
2019-04-04 10:45:15 +02:00
if (Rec_CheckIfRecordFieldIsRepeated (Gbl.Crs.Records.Field.Name))
2019-02-16 18:25:41 +01:00
Ale_ShowAlert (Ale_ERROR,Txt_The_record_field_X_already_exists,
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.Field.Name);
2014-12-01 23:55:08 +01:00
else // Add the new field to the database
Rec_CreateRecordField ();
}
else // If there is not name
2019-02-16 18:25:41 +01:00
Ale_ShowAlert (Ale_ERROR,Txt_You_must_specify_the_name_of_the_new_record_field);
2014-12-01 23:55:08 +01:00
/***** 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)
2017-01-29 12:42:19 +01:00
return Rec_DEF_LINES_IN_EDITION_FIELD;
2014-12-01 23:55:08 +01:00
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)
{
2018-11-01 19:23:52 +01:00
/***** Get fields of records in current course from database *****/
return DB_QuerySELECT (mysql_res,"can not get fields of records"
" in a course",
"SELECT FieldCod,FieldName,Visibility"
" FROM crs_record_fields"
" WHERE CrsCod=%ld ORDER BY FieldName",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod);
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;
/***** Create the new field *****/
2018-11-02 19:37:11 +01:00
DB_QueryINSERT ("can not create field of record",
"INSERT INTO crs_record_fields"
" (CrsCod,FieldName,NumLines,Visibility)"
" VALUES"
" (%ld,'%s',%u,%u)",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod,
Gbl.Crs.Records.Field.Name,
Gbl.Crs.Records.Field.NumLines,
(unsigned) Gbl.Crs.Records.Field.Visibility);
2014-12-01 23:55:08 +01:00
2014-12-27 19:43:01 +01:00
/***** Write message of success *****/
2019-02-17 01:14:55 +01:00
Ale_ShowAlert (Ale_SUCCESS,Txt_Created_new_record_field_X,
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.Field.Name);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/**************** Request the removing of a field of records *****************/
/*****************************************************************************/
void Rec_ReqRemField (void)
{
unsigned NumRecords;
/***** Get the code of field *****/
2019-04-04 10:45:15 +02:00
if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Code of field is missing.");
/***** Check if exists any record with that field filled *****/
2019-04-04 10:45:15 +02:00
if ((NumRecords = Rec_CountNumRecordsInCurrCrsWithField (Gbl.Crs.Records.Field.FieldCod))) // There are records with that field filled
2014-12-01 23:55:08 +01:00
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)
{
/***** Get the code of the field *****/
2017-01-28 20:32:50 +01:00
return Par_GetParToLong ("FieldCod");
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/*************** Get the number of records with a field filled ***************/
/*****************************************************************************/
unsigned Rec_CountNumRecordsInCurrCrsWithField (long FieldCod)
{
/***** Get number of cards with a given field in a course from database *****/
2018-11-03 20:52:00 +01:00
return
(unsigned) DB_QueryCOUNT ("can not get number of records"
" with a given field not empty in a course",
"SELECT COUNT(*) FROM crs_records"
" WHERE FieldCod=%ld",
FieldCod);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******* Request confirmation for the removing of a field with records *******/
/*****************************************************************************/
void Rec_AskConfirmRemFieldWithRecords (unsigned NumRecords)
{
2019-02-17 01:14:55 +01:00
extern const char *Txt_Do_you_really_want_to_remove_the_field_X_from_the_records_of_Y_Z_;
2014-12-01 23:55:08 +01:00
extern const char *Txt_Remove_record_field;
/***** Get from the database the name of the field *****/
2019-04-04 10:45:15 +02:00
Rec_GetFieldByCod (Gbl.Crs.Records.Field.FieldCod,
Gbl.Crs.Records.Field.Name,
&Gbl.Crs.Records.Field.NumLines,
&Gbl.Crs.Records.Field.Visibility);
2014-12-01 23:55:08 +01:00
2017-04-28 11:38:21 +02:00
/***** Show question and button to remove my photo *****/
2019-02-17 01:14:55 +01:00
Ale_ShowAlertAndButton (ActRemFie,NULL,NULL,Rec_PutParamFielCod,
Btn_REMOVE_BUTTON,Txt_Remove_record_field,
Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_field_X_from_the_records_of_Y_Z_,
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.Field.Name,Gbl.Hierarchy.Crs.FullName,
2019-02-17 01:14:55 +01:00
NumRecords);
2017-04-28 11:38:21 +02:00
/***** List record fields again *****/
Rec_ReqEditRecordFields ();
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;
/***** Get from the database the name of the field *****/
2019-04-04 10:45:15 +02:00
Rec_GetFieldByCod (Gbl.Crs.Records.Field.FieldCod,
Gbl.Crs.Records.Field.Name,
&Gbl.Crs.Records.Field.NumLines,
&Gbl.Crs.Records.Field.Visibility);
2014-12-01 23:55:08 +01:00
/***** Remove field from all records *****/
2018-11-02 22:00:31 +01:00
DB_QueryDELETE ("can not remove field from all students' records",
"DELETE FROM crs_records WHERE FieldCod=%ld",
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.Field.FieldCod);
2014-12-01 23:55:08 +01:00
/***** Remove the field *****/
2018-11-02 22:00:31 +01:00
DB_QueryDELETE ("can not remove field of record",
"DELETE FROM crs_record_fields WHERE FieldCod=%ld",
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.Field.FieldCod);
2014-12-01 23:55:08 +01:00
/***** Write message to show the change made *****/
2019-02-16 18:25:41 +01:00
Ale_ShowAlert (Ale_SUCCESS,Txt_Record_field_X_removed,
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.Field.Name);
2014-12-01 23:55:08 +01:00
/***** Show the form again *****/
Rec_ReqEditRecordFields ();
}
2017-04-28 11:38:21 +02:00
/*****************************************************************************/
/********************** Put parameter with field code ************************/
/*****************************************************************************/
static void Rec_PutParamFielCod (void)
{
2019-04-04 10:45:15 +02:00
Par_PutHiddenParamLong ("FieldCod",Gbl.Crs.Records.Field.FieldCod);
2017-04-28 11:38:21 +02:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/************** Get the data of a field of records from its code *************/
/*****************************************************************************/
2017-03-08 01:21:21 +01:00
static void Rec_GetFieldByCod (long FieldCod,char Name[Rec_MAX_BYTES_NAME_FIELD + 1],
2017-01-15 22:58:26 +01:00
unsigned *NumLines,Rec_VisibilityRecordFields_t *Visibility)
2014-12-01 23:55:08 +01:00
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRows;
unsigned Vis;
/***** Get a field of a record in a course from database *****/
2018-11-01 19:23:52 +01:00
NumRows = DB_QuerySELECT (&mysql_res,"can not get a field of a record"
" in a course",
"SELECT FieldName,NumLines,Visibility"
" FROM crs_record_fields"
" WHERE CrsCod=%ld AND FieldCod=%ld",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod,FieldCod);
2014-12-01 23:55:08 +01:00
/***** 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 */
2017-01-17 03:10:43 +01:00
Str_Copy (Name,row[0],
2017-03-08 01:21:21 +01:00
Rec_MAX_BYTES_NAME_FIELD);
2014-12-01 23:55:08 +01:00
/* 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
2017-01-29 12:42:19 +01:00
*Visibility = Rec_VISIBILITY_DEFAULT;
2014-12-01 23:55:08 +01:00
/***** 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 *****/
2019-04-04 10:45:15 +02:00
if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1)
2014-12-01 23:55:08 +01:00
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;
2017-03-08 01:21:21 +01:00
char NewFieldName[Rec_MAX_BYTES_NAME_FIELD + 1];
2014-12-01 23:55:08 +01:00
/***** Get parameters of the form *****/
/* Get the code of the field */
2019-04-04 10:45:15 +02:00
if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Code of field is missing.");
/* Get the new group name */
2017-03-08 01:21:21 +01:00
Par_GetParToText ("FieldName",NewFieldName,Rec_MAX_BYTES_NAME_FIELD);
2014-12-01 23:55:08 +01:00
2019-01-02 15:10:51 +01:00
/***** Get from the database the old field name *****/
2019-04-04 10:45:15 +02:00
Rec_GetFieldByCod (Gbl.Crs.Records.Field.FieldCod,
Gbl.Crs.Records.Field.Name,
&Gbl.Crs.Records.Field.NumLines,
&Gbl.Crs.Records.Field.Visibility);
2014-12-01 23:55:08 +01:00
/***** Check if new name is empty *****/
if (!NewFieldName[0])
2019-02-16 18:25:41 +01:00
Ale_ShowAlert (Ale_ERROR,Txt_You_can_not_leave_the_name_of_the_field_X_empty,
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.Field.Name);
2014-12-01 23:55:08 +01:00
else
{
/***** Check if the name of the olde field match the new one
(this happens when return is pressed without changes) *****/
2019-04-04 10:45:15 +02:00
if (strcmp (Gbl.Crs.Records.Field.Name,NewFieldName)) // Different names
2014-12-01 23:55:08 +01:00
{
/***** If the group ya estaba in the database... *****/
if (Rec_CheckIfRecordFieldIsRepeated (NewFieldName))
2019-02-16 18:25:41 +01:00
Ale_ShowAlert (Ale_ERROR,Txt_The_record_field_X_already_exists,
NewFieldName);
2014-12-01 23:55:08 +01:00
else
{
/* Update the table of fields changing then old name by the new one */
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not update name of field of record",
"UPDATE crs_record_fields SET FieldName='%s'"
" WHERE FieldCod=%ld",
2019-04-04 10:45:15 +02:00
NewFieldName,Gbl.Crs.Records.Field.FieldCod);
2014-12-01 23:55:08 +01:00
/***** Write message to show the change made *****/
2019-02-16 18:25:41 +01:00
Ale_ShowAlert (Ale_SUCCESS,Txt_The_record_field_X_has_been_renamed_as_Y,
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.Field.Name,NewFieldName);
2014-12-01 23:55:08 +01:00
}
}
else // The same name
2019-02-16 18:25:41 +01:00
Ale_ShowAlert (Ale_INFO,Txt_The_name_of_the_field_X_has_not_changed,
NewFieldName);
2014-12-01 23:55:08 +01:00
}
/***** Show the form again *****/
2019-04-04 10:45:15 +02:00
Str_Copy (Gbl.Crs.Records.Field.Name,NewFieldName,
2017-03-08 01:21:21 +01:00
Rec_MAX_BYTES_NAME_FIELD);
2014-12-01 23:55:08 +01:00
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;
unsigned NewNumLines;
/***** Get parameters of the form *****/
/* Get the code of field */
2019-04-04 10:45:15 +02:00
if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Code of field is missing.");
/* Get the new number of lines */
2017-01-29 21:41:08 +01:00
NewNumLines = (unsigned)
Par_GetParToUnsignedLong ("NumLines",
Rec_MIN_LINES_IN_EDITION_FIELD,
Rec_MAX_LINES_IN_EDITION_FIELD,
Rec_DEF_LINES_IN_EDITION_FIELD);
2014-12-01 23:55:08 +01:00
/* Get from the database the number of lines of the field */
2019-04-04 10:45:15 +02:00
Rec_GetFieldByCod (Gbl.Crs.Records.Field.FieldCod,Gbl.Crs.Records.Field.Name,&Gbl.Crs.Records.Field.NumLines,&Gbl.Crs.Records.Field.Visibility);
2014-12-01 23:55:08 +01:00
2019-01-02 15:10:51 +01:00
/***** Check if the old number of rows matches the new one
2014-12-01 23:55:08 +01:00
(this happens when return is pressed without changes) *****/
2019-04-04 10:45:15 +02:00
if (Gbl.Crs.Records.Field.NumLines == NewNumLines)
2019-02-16 18:25:41 +01:00
Ale_ShowAlert (Ale_INFO,Txt_The_number_of_editing_lines_in_the_record_field_X_has_not_changed,
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.Field.Name);
2014-12-01 23:55:08 +01:00
else
{
/***** Update of the table of fields changing the old maximum of students by the new one *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not update the number of lines of a record field",
"UPDATE crs_record_fields SET NumLines=%u"
" WHERE FieldCod=%ld",
2019-04-04 10:45:15 +02:00
NewNumLines,Gbl.Crs.Records.Field.FieldCod);
2014-12-01 23:55:08 +01:00
/***** Write message to show the change made *****/
2019-02-16 18:25:41 +01:00
Ale_ShowAlert (Ale_SUCCESS,Txt_From_now_on_the_number_of_editing_lines_of_the_field_X_is_Y,
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.Field.Name,NewNumLines);
2014-12-01 23:55:08 +01:00
}
/***** Show the form again *****/
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.Field.NumLines = NewNumLines;
2014-12-01 23:55:08 +01:00
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];
Rec_VisibilityRecordFields_t NewVisibility;
/***** Get parameters of the form *****/
/* Get the code of field */
2019-04-04 10:45:15 +02:00
if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Code of field is missing.");
/* Get the new visibility of the field */
2017-01-29 12:42:19 +01:00
NewVisibility = (Rec_VisibilityRecordFields_t)
2017-01-29 21:41:08 +01:00
Par_GetParToUnsignedLong ("Visibility",
0,
Rec_NUM_TYPES_VISIBILITY - 1,
(unsigned long) Rec_VISIBILITY_DEFAULT);
2014-12-01 23:55:08 +01:00
/* Get from the database the visibility of the field */
2019-04-04 10:45:15 +02:00
Rec_GetFieldByCod (Gbl.Crs.Records.Field.FieldCod,Gbl.Crs.Records.Field.Name,&Gbl.Crs.Records.Field.NumLines,&Gbl.Crs.Records.Field.Visibility);
2014-12-01 23:55:08 +01:00
/***** Check if the old visibility matches the new one
2019-01-02 15:10:51 +01:00
(this happens when return is pressed without changes) *****/
2019-04-04 10:45:15 +02:00
if (Gbl.Crs.Records.Field.Visibility == NewVisibility)
2019-02-16 18:25:41 +01:00
Ale_ShowAlert (Ale_INFO,Txt_The_visibility_of_the_record_field_X_has_not_changed,
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.Field.Name);
2014-12-01 23:55:08 +01:00
else
{
/***** Update of the table of fields changing the old visibility by the new *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not update the visibility of a record field",
"UPDATE crs_record_fields SET Visibility=%u"
" WHERE FieldCod=%ld",
(unsigned) NewVisibility,
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.Field.FieldCod);
2014-12-01 23:55:08 +01:00
/***** Write message to show the change made *****/
2019-02-16 18:25:41 +01:00
Ale_ShowAlert (Ale_SUCCESS,Txt_RECORD_FIELD_VISIBILITY_MSG[NewVisibility],
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.Field.Name);
2014-12-01 23:55:08 +01:00
}
/***** Show the form again *****/
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.Field.Visibility = NewVisibility;
2014-12-01 23:55:08 +01:00
Rec_ReqEditRecordFields ();
}
/*****************************************************************************/
/********************** Liberar list of fields of records ********************/
/*****************************************************************************/
void Rec_FreeListFields (void)
{
2019-04-04 10:45:15 +02:00
if (Gbl.Crs.Records.LstFields.NestedCalls > 0)
if (--Gbl.Crs.Records.LstFields.NestedCalls == 0)
if (Gbl.Crs.Records.LstFields.Lst)
2014-12-01 23:55:08 +01:00
{
2019-04-04 10:45:15 +02:00
free ((void *) Gbl.Crs.Records.LstFields.Lst);
Gbl.Crs.Records.LstFields.Lst = NULL;
Gbl.Crs.Records.LstFields.Num = 0;
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
/******************* Put a link to list official students ********************/
/*****************************************************************************/
void Rec_PutLinkToEditRecordFields (void)
{
extern const char *Txt_Edit_record_fields;
/***** Link to edit record fields *****/
2019-01-12 03:00:59 +01:00
Lay_PutContextualLinkIconText (ActEdiRecFie,NULL,NULL,
"pen.svg",
Txt_Edit_record_fields);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/*********************** Draw records of several guests **********************/
/*****************************************************************************/
2017-05-09 20:56:02 +02:00
void Rec_ListRecordsGstsShow (void)
{
2019-03-11 13:33:34 +01:00
Gbl.Action.Original = ActSeeRecSevGst; // Used to know where to go when confirming ID
2017-05-09 20:56:02 +02:00
Rec_ListRecordsGsts (Rec_SHA_RECORD_LIST);
}
void Rec_ListRecordsGstsPrint (void)
{
2019-03-11 00:51:54 +01:00
/***** List records ready to be printed *****/
2017-05-09 20:56:02 +02:00
Rec_ListRecordsGsts (Rec_SHA_RECORD_PRINT);
}
static void Rec_ListRecordsGsts (Rec_SharedRecordViewType_t TypeOfView)
2014-12-01 23:55:08 +01:00
{
2017-05-10 09:39:38 +02:00
unsigned NumUsr = 0;
2014-12-01 23:55:08 +01:00
const char *Ptr;
struct UsrData UsrDat;
2017-05-25 13:43:54 +02:00
char RecordSectionId[32];
2014-12-01 23:55:08 +01:00
2019-03-11 13:33:34 +01:00
/***** Get list of selected users if not already got *****/
Usr_GetListsSelectedUsrsCods ();
2014-12-01 23:55:08 +01:00
/***** 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) *****/
2017-05-09 20:56:02 +02:00
if (TypeOfView == Rec_SHA_RECORD_PRINT)
2014-12-01 23:55:08 +01:00
Rec_GetParamRecordsPerPage ();
2017-05-09 20:56:02 +02:00
if (TypeOfView == Rec_SHA_RECORD_LIST) // Listing several records
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 */
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActPrnRecSevGst);
2019-03-11 13:33:34 +01:00
Usr_PutHiddenParUsrCodAll (ActPrnRecSevGst,Gbl.Usrs.Selected.List[Rol_UNK]);
2014-12-01 23:55:08 +01:00
Rec_ShowLinkToPrintPreviewOfRecords ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
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);
UsrDat.Accepted = false; // Guests have no courses,...
// ...so they have not accepted...
// ...inscription in any course
/***** List the records *****/
2019-03-11 13:33:34 +01:00
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
2014-12-01 23:55:08 +01:00
while (*Ptr)
{
2017-03-13 14:22:36 +01:00
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
2014-12-01 23:55:08 +01:00
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
2019-03-19 13:22:14 +01:00
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) // Get from the database the data of the student
2014-12-01 23:55:08 +01:00
{
2017-05-10 09:39:38 +02:00
/* Start container for this user */
2018-10-18 02:02:32 +02:00
snprintf (RecordSectionId,sizeof (RecordSectionId),
"record_%u",
NumUsr);
2017-05-25 13:43:54 +02:00
Lay_StartSection (RecordSectionId);
fprintf (Gbl.F.Out,"<div class=\"REC_USR\"");
2016-01-17 15:10:54 +01:00
if (Gbl.Action.Act == ActPrnRecSevGst &&
2017-05-10 09:39:38 +02:00
NumUsr != 0 &&
(NumUsr % Gbl.Usrs.Listing.RecsPerPag) == 0)
fprintf (Gbl.F.Out," style=\"page-break-before:always;\"");
fprintf (Gbl.F.Out,">");
2014-12-01 23:55:08 +01:00
2017-05-10 10:09:19 +02:00
/* Show optional alert */
if (UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod) // Selected user
2019-03-09 20:12:44 +01:00
Ale_ShowAlerts (NULL);
2017-05-10 10:09:19 +02:00
2016-11-18 01:07:00 +01:00
/* Shared record */
2018-10-08 18:41:56 +02:00
fprintf (Gbl.F.Out,"<div class=\"REC_LEFT\">");
2017-05-25 13:43:54 +02:00
Rec_ShowSharedUsrRecord (TypeOfView,&UsrDat,RecordSectionId);
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
2017-05-10 09:39:38 +02:00
/* End container for this user */
2017-05-25 13:43:54 +02:00
fprintf (Gbl.F.Out,"</div>");
Lay_EndSection ();
2014-12-01 23:55:08 +01:00
2017-05-10 09:39:38 +02:00
NumUsr++;
2014-12-01 23:55:08 +01:00
}
}
2019-03-11 13:33:34 +01:00
2014-12-01 23:55:08 +01:00
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
2019-03-11 13:33:34 +01:00
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
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 ************/
/*****************************************************************************/
2019-01-10 15:26:33 +01:00
void Rec_GetUsrAndShowRecOneStdCrs (void)
2015-03-05 01:55:46 +01:00
{
/***** Get the selected student *****/
2016-01-25 14:40:57 +01:00
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
2015-03-05 01:55:46 +01:00
2019-03-19 13:22:14 +01:00
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS)) // Get from the database the data of the student
2016-12-09 13:59:33 +01:00
if (Usr_CheckIfICanViewRecordStd (&Gbl.Usrs.Other.UsrDat))
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
{
2018-10-10 14:03:06 +02:00
bool ItsMe;
2017-03-30 11:20:06 +02:00
/***** Get if student has accepted enrolment in current course *****/
2017-06-09 15:04:02 +02:00
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
2015-03-05 01:55:46 +01:00
2017-05-10 10:09:19 +02:00
/***** Assign users listing type depending on current action *****/
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_STUDENTS;
2017-05-10 10:09:19 +02:00
/***** Get list of fields of records in current course *****/
Rec_GetListRecordFieldsInCurrentCrs ();
2017-05-09 10:32:54 +02:00
/***** Put 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
2017-05-09 10:32:54 +02:00
/* Link to edit record fields */
2017-06-04 18:18:54 +02:00
if (Gbl.Usrs.Me.Role.Logged == Rol_TCH)
2014-12-01 23:55:08 +01:00
Rec_PutLinkToEditRecordFields ();
2017-05-09 10:32:54 +02:00
/* Link to print view */
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActPrnRecSevStd);
2014-12-01 23:55:08 +01:00
Usr_PutHiddenParUsrCodAll (ActPrnRecSevStd,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Rec_ShowLinkToPrintPreviewOfRecords ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
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
2017-05-10 10:09:19 +02:00
/***** Show optional alert (result of editing data in course record) *****/
2019-03-09 20:12:44 +01:00
Ale_ShowAlerts (NULL);
2017-05-09 10:32:54 +02:00
2017-05-10 10:09:19 +02:00
/***** Start container for this user *****/
2017-05-25 13:43:54 +02:00
fprintf (Gbl.F.Out,"<div class=\"REC_USR\">");
2017-05-10 10:09:19 +02:00
2016-11-18 01:07:00 +01:00
/***** Shared record *****/
2018-10-08 18:41:56 +02:00
fprintf (Gbl.F.Out,"<div class=\"REC_LEFT\">");
2017-05-09 20:56:02 +02:00
Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Other.UsrDat,NULL);
2017-05-25 13:43:54 +02:00
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
2015-03-29 22:36:21 +02:00
/***** Record of the student in the course *****/
2019-04-04 10:45:15 +02:00
if (Gbl.Crs.Records.LstFields.Num) // There are fields in the record
2015-03-29 22:36:21 +02:00
{
2018-10-10 14:03:06 +02:00
switch (Gbl.Usrs.Me.Role.Logged)
{
case Rol_STD:
2018-10-10 23:56:42 +02:00
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
2018-10-10 14:03:06 +02:00
if (ItsMe)
{
fprintf (Gbl.F.Out,"<div class=\"REC_RIGHT\">");
Rec_ShowCrsRecord (Rec_CRS_MY_RECORD_AS_STUDENT_FORM,&Gbl.Usrs.Other.UsrDat,NULL);
fprintf (Gbl.F.Out,"</div>");
}
break;
case Rol_NET:
case Rol_TCH:
case Rol_SYS_ADM:
fprintf (Gbl.F.Out,"<div class=\"REC_RIGHT\">");
Rec_ShowCrsRecord (Rec_CRS_LIST_ONE_RECORD,&Gbl.Usrs.Other.UsrDat,NULL);
fprintf (Gbl.F.Out,"</div>");
break;
default:
break;
}
2015-03-29 22:36:21 +02:00
}
2017-05-10 10:09:19 +02:00
/***** End container for this user *****/
2017-05-25 13:43:54 +02:00
fprintf (Gbl.F.Out,"</div>");
2017-05-10 10:09:19 +02:00
/***** Free list of fields of records *****/
2015-03-29 22:36:21 +02:00
Rec_FreeListFields ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************** Draw records of several students ***********************/
/*****************************************************************************/
2017-05-09 20:56:02 +02:00
void Rec_ListRecordsStdsShow (void)
2015-10-03 21:10:47 +02:00
{
2019-03-11 13:33:34 +01:00
Gbl.Action.Original = ActSeeRecSevStd; // Used to know where to go when confirming ID...
2017-05-10 10:09:19 +02:00
// ...or changing course record
2016-11-18 00:17:53 +01:00
Rec_ListRecordsStds (Rec_SHA_RECORD_LIST,
2017-05-08 20:48:27 +02:00
Rec_CRS_LIST_SEVERAL_RECORDS);
2015-10-03 21:10:47 +02:00
}
2017-05-09 20:56:02 +02:00
void Rec_ListRecordsStdsPrint (void)
2015-10-03 21:10:47 +02:00
{
2019-03-11 00:51:54 +01:00
/***** List records ready to be printed *****/
2016-11-18 00:17:53 +01:00
Rec_ListRecordsStds (Rec_SHA_RECORD_PRINT,
2017-05-08 20:48:27 +02:00
Rec_CRS_PRINT_SEVERAL_RECORDS);
2015-10-03 21:10:47 +02:00
}
2016-11-18 00:17:53 +01:00
static void Rec_ListRecordsStds (Rec_SharedRecordViewType_t ShaTypeOfView,
Rec_CourseRecordViewType_t CrsTypeOfView)
2014-12-01 23:55:08 +01:00
{
2015-10-03 21:10:47 +02:00
unsigned NumUsr = 0;
2014-12-01 23:55:08 +01:00
const char *Ptr;
struct UsrData UsrDat;
2018-10-10 23:56:42 +02:00
bool ItsMe;
2017-05-25 13:43:54 +02:00
char RecordSectionId[32];
2014-12-01 23:55:08 +01:00
2019-03-11 13:33:34 +01:00
/***** Get list of selected users if not already got *****/
Usr_GetListsSelectedUsrsCods ();
2017-05-10 10:09:19 +02:00
/***** Assign users listing type depending on current action *****/
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_STUDENTS;
/***** Get parameter with number of user records per page (only for printing) *****/
2016-11-18 00:17:53 +01:00
if (ShaTypeOfView == Rec_SHA_RECORD_PRINT)
2014-12-01 23:55:08 +01:00
Rec_GetParamRecordsPerPage ();
/***** Get list of fields of records in current course *****/
Rec_GetListRecordFieldsInCurrentCrs ();
2016-11-18 00:17:53 +01:00
if (ShaTypeOfView == Rec_SHA_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 */
2017-06-04 18:18:54 +02:00
if (Gbl.Usrs.Me.Role.Logged == Rol_TCH)
2014-12-01 23:55:08 +01:00
Rec_PutLinkToEditRecordFields ();
/* Link to print view */
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActPrnRecSevStd);
2019-03-11 13:33:34 +01:00
Usr_PutHiddenParUsrCodAll (ActPrnRecSevStd,Gbl.Usrs.Selected.List[Rol_UNK]);
2014-12-01 23:55:08 +01:00
Rec_ShowLinkToPrintPreviewOfRecords ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
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 *****/
2019-03-11 13:33:34 +01:00
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
2014-12-01 23:55:08 +01:00
while (*Ptr)
{
2017-03-13 14:22:36 +01:00
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
2014-12-01 23:55:08 +01:00
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
2019-03-19 13:22:14 +01:00
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) // Get from the database the data of the student
2017-06-09 15:04:02 +02:00
if (Usr_CheckIfUsrBelongsToCurrentCrs (&UsrDat))
2014-12-01 23:55:08 +01:00
{
2017-05-10 09:39:38 +02:00
/* Check if this user has accepted
2015-10-03 21:10:47 +02:00
his/her inscription in the current course */
2017-06-09 15:04:02 +02:00
UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat);
2014-12-01 23:55:08 +01:00
2017-05-10 09:39:38 +02:00
/* Start container for this user */
2018-10-18 02:02:32 +02:00
snprintf (RecordSectionId,sizeof (RecordSectionId),
"record_%u",
NumUsr);
2017-05-25 13:43:54 +02:00
Lay_StartSection (RecordSectionId);
fprintf (Gbl.F.Out,"<div class=\"REC_USR\"");
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)
2017-05-09 12:29:25 +02:00
fprintf (Gbl.F.Out," style=\"page-break-before:always;\"");
fprintf (Gbl.F.Out,">");
2014-12-01 23:55:08 +01:00
2017-05-09 12:29:25 +02:00
/* Show optional alert */
if (UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod) // Selected user
2019-03-09 20:12:44 +01:00
Ale_ShowAlerts (NULL);
2017-05-08 20:13:27 +02:00
2016-11-18 01:07:00 +01:00
/* Shared record */
2018-10-08 18:41:56 +02:00
fprintf (Gbl.F.Out,"<div class=\"REC_LEFT\">");
2017-05-25 13:43:54 +02:00
Rec_ShowSharedUsrRecord (ShaTypeOfView,&UsrDat,RecordSectionId);
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
/* Record of the student in the course */
2019-04-04 10:45:15 +02:00
if (Gbl.Crs.Records.LstFields.Num) // There are fields in the record
2018-10-10 23:56:42 +02:00
{
ItsMe = Usr_ItsMe (UsrDat.UsrCod);
2017-06-04 18:18:54 +02:00
if ( Gbl.Usrs.Me.Role.Logged == Rol_NET ||
Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
2018-10-10 23:56:42 +02:00
(Gbl.Usrs.Me.Role.Logged == Rol_STD && // I am student in this course...
ItsMe)) // ...and it's me
2017-05-09 12:29:25 +02:00
{
2018-10-08 18:41:56 +02:00
fprintf (Gbl.F.Out,"<div class=\"REC_RIGHT\">");
2017-05-25 13:43:54 +02:00
Rec_ShowCrsRecord (CrsTypeOfView,&UsrDat,RecordSectionId);
fprintf (Gbl.F.Out,"</div>");
2017-05-09 12:29:25 +02:00
}
2018-10-10 23:56:42 +02:00
}
2017-05-09 12:29:25 +02:00
2017-05-10 09:39:38 +02:00
/* End container for this user */
2017-05-25 13:43:54 +02:00
fprintf (Gbl.F.Out,"</div>");
Lay_EndSection ();
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 *****/
2016-11-18 00:17:53 +01:00
Rec_FreeListFields ();
2019-03-11 13:33:34 +01:00
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
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 ************/
/*****************************************************************************/
2019-01-10 15:26:33 +01:00
void Rec_GetUsrAndShowRecOneTchCrs (void)
2015-03-05 01:55:46 +01:00
{
/***** 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 *****/
2019-03-19 13:22:14 +01:00
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS)) // Get from the database the data of the teacher
2016-12-09 13:59:33 +01:00
if (Usr_CheckIfICanViewRecordTch (&Gbl.Usrs.Other.UsrDat))
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
{
2016-11-18 10:08:01 +01:00
extern const char *Hlp_USERS_Teachers_timetable;
2015-01-02 12:57:26 +01:00
extern const char *Txt_TIMETABLE_TYPES[TT_NUM_TIMETABLE_TYPES];
2017-01-28 15:58:46 +01:00
char Width[10 + 2 + 1];
2016-11-27 17:30:10 +01:00
bool ShowOfficeHours;
2015-12-01 01:09:55 +01:00
/***** Width for office hours *****/
2018-10-18 02:02:32 +02:00
snprintf (Width,sizeof (Width),
"%upx",
Rec_RECORD_WIDTH);
2014-12-01 23:55:08 +01:00
2017-03-30 11:20:06 +02:00
/***** Get if teacher has accepted enrolment in current course *****/
2017-06-09 15:04:02 +02:00
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
2015-03-05 01:55:46 +01:00
2017-05-10 10:09:19 +02:00
/***** Assign users listing type depending on current action *****/
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_TEACHERS;
2016-11-27 17:30:10 +01:00
/***** Get if I want to see teachers' office hours in teachers' records *****/
ShowOfficeHours = Rec_GetParamShowOfficeHours ();
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? */
2016-11-27 17:30:10 +01:00
Rec_WriteFormShowOfficeHoursOneTch (ShowOfficeHours);
2014-12-01 23:55:08 +01:00
2015-04-02 14:22:21 +02:00
/* Link to print view */
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActPrnRecSevTch);
2014-12-01 23:55:08 +01:00
Usr_PutHiddenParUsrCodAll (ActPrnRecSevTch,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Par_PutHiddenParamChar ("ParamOfficeHours",'Y');
2019-03-07 22:15:47 +01:00
Par_PutHiddenParamChar ("ShowOfficeHours",ShowOfficeHours ? 'Y' :
'N');
2014-12-01 23:55:08 +01:00
Rec_ShowLinkToPrintPreviewOfRecords ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
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
2017-05-10 10:09:19 +02:00
/***** Start container for this user *****/
2017-05-25 13:43:54 +02:00
fprintf (Gbl.F.Out,"<div class=\"REC_USR\">");
2014-12-01 23:55:08 +01:00
2017-05-10 10:09:19 +02:00
/***** Shared record *****/
2018-10-08 18:41:56 +02:00
fprintf (Gbl.F.Out,"<div class=\"REC_LEFT\">");
2017-05-09 20:56:02 +02:00
Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Other.UsrDat,NULL);
2017-05-25 13:43:54 +02:00
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
2017-05-10 10:09:19 +02:00
/***** Office hours *****/
2016-11-27 17:30:10 +01:00
if (ShowOfficeHours)
{
2018-10-08 18:41:56 +02:00
fprintf (Gbl.F.Out,"<div class=\"REC_RIGHT\">");
2017-04-24 13:00:59 +02:00
Gbl.TimeTable.Type = TT_TUTORING_TIMETABLE;
2017-06-10 21:38:10 +02:00
Box_StartBox (Width,Txt_TIMETABLE_TYPES[Gbl.TimeTable.Type],NULL,
2017-06-12 15:03:29 +02:00
Hlp_USERS_Teachers_timetable,Box_NOT_CLOSABLE);
2016-11-27 17:30:10 +01:00
TT_ShowTimeTable (Gbl.Usrs.Other.UsrDat.UsrCod);
2017-06-10 21:38:10 +02:00
Box_EndBox ();
2017-05-25 13:43:54 +02:00
fprintf (Gbl.F.Out,"</div>");
2016-11-27 17:30:10 +01:00
}
2014-12-01 23:55:08 +01:00
2017-05-10 10:09:19 +02:00
/***** Start container for this user *****/
2017-05-25 13:43:54 +02:00
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************** Draw records of several teachers ***********************/
/*****************************************************************************/
2017-05-09 20:56:02 +02:00
void Rec_ListRecordsTchsShow (void)
{
2019-03-11 13:33:34 +01:00
Gbl.Action.Original = ActSeeRecSevTch; // Used to know where to go when confirming ID
2017-05-09 20:56:02 +02:00
Rec_ListRecordsTchs (Rec_SHA_RECORD_LIST);
}
void Rec_ListRecordsTchsPrint (void)
{
2019-03-11 00:51:54 +01:00
/***** List records ready to be printed *****/
2017-05-09 20:56:02 +02:00
Rec_ListRecordsTchs (Rec_SHA_RECORD_PRINT);
}
static void Rec_ListRecordsTchs (Rec_SharedRecordViewType_t TypeOfView)
2014-12-01 23:55:08 +01:00
{
2016-11-18 10:08:01 +01:00
extern const char *Hlp_USERS_Teachers_timetable;
2015-01-02 12:57:26 +01:00
extern const char *Txt_TIMETABLE_TYPES[TT_NUM_TIMETABLE_TYPES];
2017-05-10 09:39:38 +02:00
unsigned NumUsr = 0;
2014-12-01 23:55:08 +01:00
const char *Ptr;
struct UsrData UsrDat;
2017-05-25 13:43:54 +02:00
char RecordSectionId[32];
2014-12-01 23:55:08 +01:00
bool ShowOfficeHours;
2017-01-28 15:58:46 +01:00
char Width[10 + 2 + 1];
2015-12-01 01:09:55 +01:00
2019-03-11 13:33:34 +01:00
/***** Get list of selected users if not already got *****/
Usr_GetListsSelectedUsrsCods ();
2015-12-01 01:09:55 +01:00
/***** Width for office hours *****/
2018-10-18 02:02:32 +02:00
snprintf (Width,sizeof (Width),
"%upx",
Rec_RECORD_WIDTH);
2014-12-01 23:55:08 +01:00
2017-05-10 10:09:19 +02:00
/***** Assign users listing type depending on current action *****/
2014-12-01 23:55:08 +01:00
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 ();
2019-03-11 13:33:34 +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? */
2016-11-27 17:30:10 +01:00
Rec_WriteFormShowOfficeHoursSeveralTchs (ShowOfficeHours);
2014-12-01 23:55:08 +01:00
/* Link to print view */
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActPrnRecSevTch);
2019-03-11 13:33:34 +01:00
Usr_PutHiddenParUsrCodAll (ActPrnRecSevTch,Gbl.Usrs.Selected.List[Rol_UNK]);
2014-12-01 23:55:08 +01:00
Par_PutHiddenParamChar ("ParamOfficeHours",'Y');
Par_PutHiddenParamChar ("ShowOfficeHours",
ShowOfficeHours ? 'Y' :
'N');
Rec_ShowLinkToPrintPreviewOfRecords ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
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 *****/
2019-03-11 13:33:34 +01:00
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
2014-12-01 23:55:08 +01:00
while (*Ptr)
{
2017-03-13 14:22:36 +01:00
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
2014-12-01 23:55:08 +01:00
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
2019-03-19 13:22:14 +01:00
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) // Get from the database the data of the student
2017-06-09 15:04:02 +02:00
if (Usr_CheckIfUsrBelongsToCurrentCrs (&UsrDat))
2014-12-01 23:55:08 +01:00
{
2017-05-10 09:39:38 +02:00
/* Check if this user has accepted
his/her inscription in the current course */
2017-06-09 15:04:02 +02:00
UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat);
2014-12-01 23:55:08 +01:00
2017-05-10 09:39:38 +02:00
/* Start container for this user */
2018-10-18 02:02:32 +02:00
snprintf (RecordSectionId,sizeof (RecordSectionId),
"record_%u",
NumUsr);
2017-05-25 13:43:54 +02:00
Lay_StartSection (RecordSectionId);
fprintf (Gbl.F.Out,"<div class=\"REC_USR\"");
2016-01-17 15:10:54 +01:00
if (Gbl.Action.Act == ActPrnRecSevTch &&
2017-05-10 09:39:38 +02:00
NumUsr != 0 &&
(NumUsr % Gbl.Usrs.Listing.RecsPerPag) == 0)
fprintf (Gbl.F.Out," style=\"page-break-before:always;\"");
fprintf (Gbl.F.Out,">");
2014-12-01 23:55:08 +01:00
2017-05-10 10:09:19 +02:00
/* Show optional alert */
if (UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod) // Selected user
2019-03-09 20:12:44 +01:00
Ale_ShowAlerts (NULL);
2017-05-10 10:09:19 +02:00
/* Shared record */
2018-10-08 18:41:56 +02:00
fprintf (Gbl.F.Out,"<div class=\"REC_LEFT\">");
2017-05-25 13:43:54 +02:00
Rec_ShowSharedUsrRecord (TypeOfView,&UsrDat,RecordSectionId);
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
/* Office hours */
if (ShowOfficeHours)
{
2018-10-08 18:41:56 +02:00
fprintf (Gbl.F.Out,"<div class=\"REC_RIGHT\">");
2017-04-24 13:00:59 +02:00
Gbl.TimeTable.Type = TT_TUTORING_TIMETABLE;
2017-06-12 15:03:29 +02:00
Box_StartBox (Width,Txt_TIMETABLE_TYPES[Gbl.TimeTable.Type],NULL,
Hlp_USERS_Teachers_timetable,Box_NOT_CLOSABLE);
2016-03-18 14:07:21 +01:00
TT_ShowTimeTable (UsrDat.UsrCod);
2017-06-10 21:38:10 +02:00
Box_EndBox ();
2017-05-25 13:43:54 +02:00
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
}
2017-05-10 09:39:38 +02:00
/* End container for this user */
2017-05-25 13:43:54 +02:00
fprintf (Gbl.F.Out,"</div>");
Lay_EndSection ();
2014-12-01 23:55:08 +01:00
2017-05-10 09:39:38 +02:00
NumUsr++;
2014-12-01 23:55:08 +01:00
}
}
2019-03-07 22:15:47 +01:00
2014-12-01 23:55:08 +01:00
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
2019-03-11 13:33:34 +01:00
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
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
{
2019-02-22 21:47:50 +01:00
extern const char *The_ClassFormOutBoxBold[The_NUM_THEMES];
extern const char *The_ClassFormInBox[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;
2019-02-22 21:47:50 +01:00
Frm_LinkFormSubmit (Txt_Print,The_ClassFormOutBoxBold[Gbl.Prefs.Theme],NULL);
2019-01-12 19:46:33 +01:00
Ico_PutIconTextLink ("print.svg",
Txt_Print);
2015-12-13 18:32:37 +01:00
fprintf (Gbl.F.Out,"</a>"
2016-12-27 16:45:37 +01:00
"<label class=\"%s\">"
"(<select name=\"RecsPerPag\">",
2019-02-22 21:47:50 +01:00
The_ClassFormInBox[Gbl.Prefs.Theme]);
2017-01-29 12:42:19 +01:00
for (i = Rec_MIN_RECORDS_PER_PAGE;
i <= Rec_MAX_RECORDS_PER_PAGE;
2014-12-01 23:55:08 +01:00
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);
}
2016-12-27 16:45:37 +01:00
fprintf (Gbl.F.Out,"</select> %s)"
"</label>",
2016-12-20 02:18:50 +01:00
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)
{
2017-01-29 21:41:08 +01:00
Gbl.Usrs.Listing.RecsPerPag = (unsigned)
Par_GetParToUnsignedLong ("RecsPerPag",
Rec_MIN_RECORDS_PER_PAGE,
Rec_MAX_RECORDS_PER_PAGE,
Rec_DEF_RECORDS_PER_PAGE);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2016-11-27 17:30:10 +01:00
/*********** Write a form to select whether show all office hours ************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-11-27 17:30:10 +01:00
static void Rec_WriteFormShowOfficeHoursOneTch (bool ShowOfficeHours)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_Show_office_hours;
2016-11-27 17:30:10 +01:00
Lay_PutContextualCheckbox (ActSeeRecOneTch,Rec_PutParamsShowOfficeHoursOneTch,
2017-05-22 12:23:08 +02:00
"ShowOfficeHours",
ShowOfficeHours,false,
2016-11-27 17:30:10 +01:00
Txt_Show_office_hours,
Txt_Show_office_hours);
}
static void Rec_WriteFormShowOfficeHoursSeveralTchs (bool ShowOfficeHours)
{
extern const char *Txt_Show_office_hours;
2019-03-11 13:33:34 +01:00
Lay_PutContextualCheckbox (ActSeeRecSevTch,Rec_PutParamsShowOfficeHoursSeveralTchs,
2017-05-22 12:23:08 +02:00
"ShowOfficeHours",
ShowOfficeHours,false,
2016-11-27 17:30:10 +01:00
Txt_Show_office_hours,
Txt_Show_office_hours);
}
static void Rec_PutParamsShowOfficeHoursOneTch (void)
{
2017-05-08 19:54:05 +02:00
Usr_PutParamOtherUsrCodEncrypted ();
2014-12-01 23:55:08 +01:00
Par_PutHiddenParamChar ("ParamOfficeHours",'Y');
2016-11-27 17:30:10 +01:00
}
2014-12-01 23:55:08 +01:00
2016-11-27 17:30:10 +01:00
static void Rec_PutParamsShowOfficeHoursSeveralTchs (void)
{
2019-03-11 13:33:34 +01:00
Usr_PutHiddenParUsrCodAll (ActSeeRecSevTch,Gbl.Usrs.Selected.List[Rol_UNK]);
2016-11-27 17:30:10 +01:00
Par_PutHiddenParamChar ("ParamOfficeHours",'Y');
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)
{
2017-01-28 20:32:50 +01:00
if (Par_GetParToBool ("ParamOfficeHours"))
return Par_GetParToBool ("ShowOfficeHours");
2014-12-01 23:55:08 +01:00
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;
2017-05-09 20:56:02 +02:00
long OriginalActCod;
2014-12-01 23:55:08 +01:00
2017-05-09 20:56:02 +02:00
/***** Get where we came from *****/
OriginalActCod = Par_GetParToLong ("OriginalActCod");
Gbl.Action.Original = Act_GetActionFromActCod (OriginalActCod);
2017-05-09 10:32:54 +02: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 ();
2019-03-19 13:22:14 +01:00
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS);
2014-12-01 23:55:08 +01:00
/***** 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);
2019-03-09 20:12:44 +01:00
Ale_CreateAlert (Ale_SUCCESS,NULL,
Txt_Student_record_card_in_this_course_has_been_updated);
2017-05-09 10:32:54 +02:00
/***** Show one or multiple records *****/
2017-05-09 20:56:02 +02:00
switch (Gbl.Action.Original)
{
2019-03-11 13:33:34 +01:00
case ActSeeRecSevStd:
2017-05-09 20:56:02 +02:00
/* Show multiple records again (including the updated one) */
Rec_ListRecordsStdsShow ();
break;
default:
/* Show only the updated record of one student */
Rec_ShowRecordOneStdCrs ();
break;
}
2014-12-01 23:55:08 +01:00
/***** Free memory used for some fields *****/
Rec_FreeMemFieldsRecordsCrs ();
}
/*****************************************************************************/
2016-11-18 01:07:00 +01:00
/************************* Show shared record card ***************************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
// Show form or only data depending on TypeOfView
2016-11-18 00:17:53 +01:00
static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
struct UsrData *UsrDat,const char *Anchor)
2014-12-01 23:55:08 +01:00
{
2016-11-18 00:17:53 +01:00
extern const char *Hlp_USERS_Students_course_record_card;
2019-02-22 21:47:50 +01:00
extern const char *The_ClassFormInBox[The_NUM_THEMES];
2014-12-01 23:55:08 +01:00
extern const char *Txt_RECORD_FIELD_VISIBILITY_RECORD[Rec_NUM_TYPES_VISIBILITY];
2019-02-18 18:27:45 +01:00
extern const char *Txt_Save_changes;
2016-11-18 00:17:53 +01:00
const char *Rec_RecordHelp[Rec_COURSE_NUM_VIEW_TYPES] =
{
Hlp_USERS_Students_course_record_card, // Rec_CRS_MY_RECORD_AS_STUDENT_FORM
Hlp_USERS_Students_course_record_card, // Rec_CRS_MY_RECORD_AS_STUDENT_CHECK
2017-05-08 20:48:27 +02:00
Hlp_USERS_Students_course_record_card, // Rec_CRS_LIST_ONE_RECORD
Hlp_USERS_Students_course_record_card, // Rec_CRS_LIST_SEVERAL_RECORDS
NULL, // Rec_CRS_PRINT_ONE_RECORD
NULL, // Rec_CRS_PRINT_SEVERAL_RECORDS
// Rec_CRS_RECORD_PRINT
2016-11-18 00:17:53 +01:00
};
2017-01-28 15:58:46 +01:00
char StrRecordWidth[10 + 1];
2015-07-17 13:06:32 +02:00
bool ItsMe;
2017-01-25 18:48:41 +01:00
bool ICanEdit = false;
2014-12-01 23:55:08 +01:00
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;
2017-01-25 18:48:41 +01:00
bool ICanEditThisField;
2017-01-15 22:58:26 +01:00
char Text[Cns_MAX_BYTES_TEXT + 1];
2014-12-01 23:55:08 +01:00
2017-06-04 18:18:54 +02:00
switch (Gbl.Usrs.Me.Role.Logged)
2015-07-17 13:06:32 +02:00
{
2017-05-24 01:43:00 +02:00
case Rol_STD: // I am a student
2018-10-10 23:56:42 +02:00
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
2018-10-10 14:03:06 +02:00
if (ItsMe)
2015-07-17 13:06:32 +02:00
{
2017-05-24 01:43:00 +02:00
switch (TypeOfView)
{
case Rec_CRS_LIST_ONE_RECORD:
case Rec_CRS_LIST_SEVERAL_RECORDS:
// When listing records, I can see only my record as student
TypeOfView = Rec_CRS_MY_RECORD_AS_STUDENT_FORM;
break;
case Rec_CRS_MY_RECORD_AS_STUDENT_FORM:
case Rec_CRS_MY_RECORD_AS_STUDENT_CHECK:
case Rec_CRS_PRINT_ONE_RECORD:
case Rec_CRS_PRINT_SEVERAL_RECORDS:
break;
default:
2019-02-16 20:44:31 +01:00
Lay_NoPermissionExit ();
2017-05-24 01:43:00 +02:00
break;
}
if (TypeOfView == Rec_CRS_MY_RECORD_AS_STUDENT_FORM)
/* Check if I can edit any of the record fields */
for (NumField = 0;
2019-04-04 10:45:15 +02:00
NumField < Gbl.Crs.Records.LstFields.Num;
2017-05-24 01:43:00 +02:00
NumField++)
2019-04-04 10:45:15 +02:00
if (Gbl.Crs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
2017-05-24 01:43:00 +02:00
{
ICanEdit = true;
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActRcvRecCrs);
2017-05-24 01:43:00 +02:00
break;
}
}
2018-10-10 23:56:42 +02:00
else // Not me ==> I am a student trying to do something forbidden
2019-02-16 20:44:31 +01:00
Lay_NoPermissionExit ();
2014-12-01 23:55:08 +01:00
break;
2017-05-24 01:43:00 +02:00
case Rol_NET:
2017-05-08 20:48:27 +02:00
break;
2017-05-24 01:43:00 +02:00
case Rol_TCH:
case Rol_SYS_ADM:
if (TypeOfView == Rec_CRS_LIST_ONE_RECORD ||
TypeOfView == Rec_CRS_LIST_SEVERAL_RECORDS)
{
ICanEdit = true;
2018-11-09 20:47:39 +01:00
Frm_StartFormAnchor (ActRcvRecOthUsr,Anchor);
2017-05-24 01:43:00 +02:00
Par_PutHiddenParamLong ("OriginalActCod",
2019-03-11 13:33:34 +01:00
Act_GetActCod (ActSeeRecSevStd)); // Original action, used to know where we came from
2017-05-24 01:43:00 +02:00
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
if (TypeOfView == Rec_CRS_LIST_SEVERAL_RECORDS)
2019-03-11 13:33:34 +01:00
Usr_PutHiddenParUsrCodAll (ActRcvRecOthUsr,Gbl.Usrs.Selected.List[Rol_UNK]);
2017-05-24 01:43:00 +02:00
}
2014-12-01 23:55:08 +01:00
break;
default:
2017-05-24 01:43:00 +02:00
Lay_ShowErrorAndExit ("Wrong role.");
}
2014-12-01 23:55:08 +01:00
2017-06-12 14:16:33 +02:00
/***** Start box and table *****/
2018-10-18 02:02:32 +02:00
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
"%upx",
Rec_RECORD_WIDTH);
2017-06-10 21:38:10 +02:00
Box_StartBoxTable (StrRecordWidth,NULL,NULL,
2017-06-12 15:03:29 +02:00
Rec_RecordHelp[TypeOfView],Box_NOT_CLOSABLE,2);
2014-12-01 23:55:08 +01:00
2017-06-12 14:16:33 +02:00
/***** Write heading *****/
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"<tr>"
2017-05-01 12:36:24 +02:00
"<td colspan=\"2\" class=\"LEFT_TOP\">");
2017-06-11 20:09:59 +02:00
Tbl_StartTableWide (0);
2017-05-01 12:36:24 +02:00
fprintf (Gbl.F.Out,"<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);
2019-04-03 20:57:04 +02:00
Log_DrawLogo (Hie_DEG,Gbl.Hierarchy.Deg.DegCod,
Gbl.Hierarchy.Deg.ShrtName,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>",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Deg.FullName,Gbl.Hierarchy.Crs.FullName,
2014-12-01 23:55:08 +01:00
UsrDat->FullName);
2017-06-11 20:09:59 +02:00
Tbl_EndTable ();
2017-05-01 12:36:24 +02:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
/***** Fields of the record that depends on the course *****/
for (NumField = 0, Gbl.RowEvenOdd = 0;
2019-04-04 10:45:15 +02:00
NumField < Gbl.Crs.Records.LstFields.Num;
2014-12-01 23:55:08 +01:00
NumField++, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd)
2015-07-17 13:06:32 +02:00
{
2016-11-18 00:17:53 +01:00
ShowField = !(TypeOfView == Rec_CRS_MY_RECORD_AS_STUDENT_FORM ||
TypeOfView == Rec_CRS_MY_RECORD_AS_STUDENT_CHECK) ||
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.LstFields.Lst[NumField].Visibility != Rec_HIDDEN_FIELD;
2015-07-17 13:06:32 +02:00
// If the field must be shown...
if (ShowField)
2014-12-01 23:55:08 +01:00
{
2017-05-24 01:43:00 +02:00
/* Can I edit this field? */
2017-06-04 18:18:54 +02:00
switch (Gbl.Usrs.Me.Role.Logged)
2017-05-24 01:43:00 +02:00
{
case Rol_STD:
ICanEditThisField = (TypeOfView == Rec_CRS_MY_RECORD_AS_STUDENT_FORM &&
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD);
2017-05-24 01:43:00 +02:00
break;
case Rol_TCH:
case Rol_SYS_ADM:
ICanEditThisField = (TypeOfView == Rec_CRS_LIST_ONE_RECORD ||
TypeOfView == Rec_CRS_LIST_SEVERAL_RECORDS);
break;
default:
ICanEditThisField = false;
break;
}
2014-12-01 23:55:08 +01:00
/* Name of the field */
fprintf (Gbl.F.Out,"<tr>"
2017-05-09 11:39:08 +02:00
"<td class=\"REC_C1_BOT %s RIGHT_TOP COLOR%u\">"
2014-12-24 19:11:42 +01:00
"%s:",
2019-02-22 21:47:50 +01:00
ICanEditThisField ? The_ClassFormInBox[Gbl.Prefs.Theme] :
2017-01-25 18:48:41 +01:00
"REC_DAT_SMALL",
2017-05-09 11:39:08 +02:00
Gbl.RowEvenOdd,
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.LstFields.Lst[NumField].Name);
2017-05-08 20:48:27 +02:00
if (TypeOfView == Rec_CRS_LIST_ONE_RECORD ||
TypeOfView == Rec_CRS_LIST_SEVERAL_RECORDS)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"<span class=\"DAT_SMALL\"> (%s)</span>",
2019-04-04 10:45:15 +02:00
Txt_RECORD_FIELD_VISIBILITY_RECORD[Gbl.Crs.Records.LstFields.Lst[NumField].Visibility]);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>");
2017-05-24 01:43:00 +02:00
/* Get the text of the field */
2019-04-04 10:45:15 +02:00
if (Rec_GetFieldFromCrsRecord (UsrDat->UsrCod,Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod,&mysql_res))
2014-12-01 23:55:08 +01:00
{
ThisFieldHasText = true;
row = mysql_fetch_row (mysql_res);
}
else
ThisFieldHasText = false;
2017-05-24 01:43:00 +02:00
/* Write form, text, or nothing depending on
the user's role and the visibility of the field */
2017-05-09 11:39:08 +02:00
fprintf (Gbl.F.Out,"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_TOP COLOR%u\">",
Gbl.RowEvenOdd);
2017-01-25 18:48:41 +01:00
if (ICanEditThisField) // Show with form
2014-12-01 23:55:08 +01:00
{
fprintf (Gbl.F.Out,"<textarea name=\"Field%ld\" rows=\"%u\""
2017-05-09 11:39:08 +02:00
" class=\"REC_C2_BOT_INPUT\">",
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod,
Gbl.Crs.Records.LstFields.Lst[NumField].NumLines);
2014-12-01 23:55:08 +01:00
if (ThisFieldHasText)
fprintf (Gbl.F.Out,"%s",row[0]);
fprintf (Gbl.F.Out,"</textarea>");
}
2017-05-24 01:43:00 +02:00
else // Show without form
2014-12-01 23:55:08 +01:00
{
if (ThisFieldHasText)
{
2017-01-17 03:10:43 +01:00
Str_Copy (Text,row[0],
Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
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>");
2017-05-24 01:43:00 +02:00
/* Free structure that stores the query result */
2014-12-01 23:55:08 +01:00
DB_FreeMySQLResult (&mysql_res);
}
2015-07-17 13:06:32 +02:00
}
2014-12-01 23:55:08 +01:00
2017-06-12 14:16:33 +02:00
/***** End box *****/
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2014-12-01 23:55:08 +01:00
{
2017-06-12 14:16:33 +02:00
/* End table, send button and end box */
2019-02-18 18:27:45 +01:00
Box_EndBoxTableWithButton (Btn_CONFIRM_BUTTON,Txt_Save_changes);
2017-06-12 14:16:33 +02:00
/* End form */
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2014-12-01 23:55:08 +01:00
}
2015-04-11 23:46:21 +02:00
else
2017-06-12 14:16:33 +02:00
/* End table and box */
2017-06-10 21:38:10 +02:00
Box_EndBoxTable ();
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)
{
/***** Get the text of a field of a record from database *****/
2018-11-01 19:23:52 +01:00
return DB_QuerySELECT (mysql_res,"can not get the text"
" of a field of a record",
"SELECT Txt FROM crs_records"
" WHERE FieldCod=%ld AND UsrCod=%ld",
FieldCod,UsrCod);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/****************** Get the fields of the record from form *******************/
/*****************************************************************************/
void Rec_GetFieldsCrsRecordFromForm (void)
{
unsigned NumField;
2017-01-28 15:58:46 +01:00
char FieldParamName[5 + 10 + 1];
2014-12-01 23:55:08 +01:00
for (NumField = 0;
2019-04-04 10:45:15 +02:00
NumField < Gbl.Crs.Records.LstFields.Num;
2014-12-01 23:55:08 +01:00
NumField++)
2019-04-04 10:45:15 +02:00
if (Rec_CheckIfICanEditField (Gbl.Crs.Records.LstFields.Lst[NumField].Visibility))
2014-12-01 23:55:08 +01:00
{
2019-02-18 19:35:52 +01:00
/* Get text from the form */
2018-10-18 02:02:32 +02:00
snprintf (FieldParamName,sizeof (FieldParamName),
"Field%ld",
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod);
Par_GetParToHTML (FieldParamName,Gbl.Crs.Records.LstFields.Lst[NumField].Text,Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
/*************************** Update record of a user *************************/
/*****************************************************************************/
void Rec_UpdateCrsRecord (long UsrCod)
{
unsigned NumField;
MYSQL_RES *mysql_res;
bool FieldAlreadyExists;
for (NumField = 0;
2019-04-04 10:45:15 +02:00
NumField < Gbl.Crs.Records.LstFields.Num;
2014-12-01 23:55:08 +01:00
NumField++)
2019-04-04 10:45:15 +02:00
if (Rec_CheckIfICanEditField (Gbl.Crs.Records.LstFields.Lst[NumField].Visibility))
2014-12-01 23:55:08 +01:00
{
/***** Check if already exists this field for this user in database *****/
2019-04-04 10:45:15 +02:00
FieldAlreadyExists = (Rec_GetFieldFromCrsRecord (UsrCod,Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod,&mysql_res) != 0);
2014-12-01 23:55:08 +01:00
DB_FreeMySQLResult (&mysql_res);
if (FieldAlreadyExists)
{
2019-04-04 10:45:15 +02:00
if (Gbl.Crs.Records.LstFields.Lst[NumField].Text[0])
2014-12-01 23:55:08 +01:00
/***** Update text of the field of record course *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not update field of record",
"UPDATE crs_records SET Txt='%s'"
" WHERE UsrCod=%ld AND FieldCod=%ld",
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.LstFields.Lst[NumField].Text,
2018-11-03 12:16:40 +01:00
UsrCod,
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod);
2014-12-01 23:55:08 +01:00
else
/***** Remove text of the field of record course *****/
2018-11-02 22:00:31 +01:00
DB_QueryDELETE ("can not remove field of record",
"DELETE FROM crs_records"
" WHERE UsrCod=%ld AND FieldCod=%ld",
UsrCod,
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod);
2014-12-01 23:55:08 +01:00
}
2019-04-04 10:45:15 +02:00
else if (Gbl.Crs.Records.LstFields.Lst[NumField].Text[0])
2014-12-01 23:55:08 +01:00
/***** Insert text field of record course *****/
2018-11-02 19:37:11 +01:00
DB_QueryINSERT ("can not create field of record",
"INSERT INTO crs_records"
" (FieldCod,UsrCod,Txt)"
" VALUES"
" (%ld,%ld,'%s')",
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod,
2018-11-02 19:37:11 +01:00
UsrCod,
2019-04-04 10:45:15 +02:00
Gbl.Crs.Records.LstFields.Lst[NumField].Text);
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
/************ Remove fields of record of a user in current course ************/
/*****************************************************************************/
2017-06-04 15:11:41 +02:00
void Rec_RemoveFieldsCrsRecordInCrs (long UsrCod,struct Course *Crs)
2014-12-01 23:55:08 +01:00
{
/***** Remove text of the field of record course *****/
2018-11-02 22:00:31 +01:00
DB_QueryDELETE ("can not remove user's record in a course",
"DELETE FROM crs_records"
" WHERE UsrCod=%ld AND FieldCod IN"
" (SELECT FieldCod FROM crs_record_fields WHERE CrsCod=%ld)",
UsrCod,Crs->CrsCod);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************* Remove fields of record of a user in all courses **************/
/*****************************************************************************/
2017-06-04 15:11:41 +02:00
void Rec_RemoveFieldsCrsRecordAll (long UsrCod)
2014-12-01 23:55:08 +01:00
{
/***** Remove text of the field of record course *****/
2018-11-02 22:00:31 +01:00
DB_QueryDELETE ("can not remove user's records in all courses",
"DELETE FROM crs_records WHERE UsrCod=%ld",
UsrCod);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/*************** 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;
2019-02-16 18:25:41 +01:00
/***** Write success message *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_Your_record_card_in_this_course_has_been_updated);
2014-12-01 23:55:08 +01:00
2016-11-18 01:07:00 +01:00
/***** Shared record *****/
2017-05-09 20:56:02 +02:00
Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Me.UsrDat,NULL);
2015-03-30 14:51:32 +02:00
/***** Show updated user's record *****/
2016-11-18 00:17:53 +01:00
Rec_ShowCrsRecord (Rec_CRS_MY_RECORD_AS_STUDENT_CHECK,&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;
2019-04-04 10:45:15 +02:00
NumField < Gbl.Crs.Records.LstFields.Num;
2014-12-01 23:55:08 +01:00
NumField++)
2019-04-04 10:45:15 +02:00
if (Rec_CheckIfICanEditField (Gbl.Crs.Records.LstFields.Lst[NumField].Visibility))
2014-12-01 23:55:08 +01:00
/* Allocate memory for the texts of the fields */
2019-04-04 10:45:15 +02:00
if ((Gbl.Crs.Records.LstFields.Lst[NumField].Text = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
2018-10-18 20:06:54 +02:00
Lay_NotEnoughMemoryExit ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/**** Free memory used by the texts of the field of the record in course *****/
/*****************************************************************************/
void Rec_FreeMemFieldsRecordsCrs (void)
{
unsigned NumField;
for (NumField = 0;
2019-04-04 10:45:15 +02:00
NumField < Gbl.Crs.Records.LstFields.Num;
2014-12-01 23:55:08 +01:00
NumField++)
2019-04-04 10:45:15 +02:00
if (Rec_CheckIfICanEditField (Gbl.Crs.Records.LstFields.Lst[NumField].Visibility))
2014-12-01 23:55:08 +01:00
/* Free memory of the text of the field */
2019-04-04 10:45:15 +02:00
if (Gbl.Crs.Records.LstFields.Lst[NumField].Text)
2014-12-01 23:55:08 +01:00
{
2019-04-04 10:45:15 +02:00
free ((void *) Gbl.Crs.Records.LstFields.Lst[NumField].Text);
Gbl.Crs.Records.LstFields.Lst[NumField].Text = NULL;
2014-12-01 23:55:08 +01:00
}
}
2017-05-22 14:52:11 +02:00
/*****************************************************************************/
/* Check if I can edit a field depending on my role and the field visibility */
/*****************************************************************************/
static bool Rec_CheckIfICanEditField (Rec_VisibilityRecordFields_t Visibility)
{
// Non-editing teachers can not edit fields
2017-06-04 18:18:54 +02:00
return Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
(Gbl.Usrs.Me.Role.Logged == Rol_STD &&
2017-05-22 14:52:11 +02:00
Visibility == Rec_EDITABLE_FIELD);
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-11-18 01:07:00 +01:00
/*********** Show form to sign up and edit my shared record card *************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2017-05-30 02:17:33 +02:00
void Rec_ShowFormSignUpInCrsWithMySharedRecord (void)
2014-12-01 23:55:08 +01:00
{
/***** Show the form *****/
2017-05-30 02:17:33 +02:00
Rec_ShowSharedUsrRecord (Rec_SHA_SIGN_UP_IN_CRS_FORM,&Gbl.Usrs.Me.UsrDat,NULL);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/*************** Show form to edit the record of a new user ******************/
/*****************************************************************************/
2017-01-27 12:57:31 +01:00
void Rec_ShowFormOtherNewSharedRecord (struct UsrData *UsrDat,Rol_Role_t DefaultRole)
2014-12-01 23:55:08 +01:00
{
/***** Show the form *****/
2017-06-04 14:22:04 +02:00
/* In this case UsrDat->Roles.InCurrentCrsDB
2017-01-27 12:57:31 +01:00
is not the current role in current course.
Instead it is initialized with the preferred role. */
2019-04-03 20:57:04 +02:00
UsrDat->Roles.InCurrentCrs.Role = (Gbl.Hierarchy.Level == Hie_CRS) ? DefaultRole : // Course selected
Rol_UNK; // No course selected
2017-06-23 15:12:49 +02:00
UsrDat->Roles.InCurrentCrs.Valid = true;
2017-05-09 20:56:02 +02:00
Rec_ShowSharedUsrRecord (Rec_SHA_OTHER_NEW_USR_FORM,UsrDat,NULL);
2014-12-01 23:55:08 +01:00
}
2019-03-09 22:01:06 +01:00
/*****************************************************************************/
/********* Show other existing user's shared record to be edited *************/
/*****************************************************************************/
void Rec_ShowOtherSharedRecordEditable (void)
{
/***** User's record *****/
Rec_ShowSharedUsrRecord (Rec_SHA_OTHER_EXISTING_USR_FORM,
&Gbl.Usrs.Other.UsrDat,NULL);
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/*********************** Show my record after update *************************/
/*****************************************************************************/
2016-11-18 01:07:00 +01:00
void Rec_ShowMySharedRecordUpd (void)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_Your_personal_data_have_been_updated;
/***** Write alert *****/
2019-02-16 18:25:41 +01:00
Ale_ShowAlert (Ale_SUCCESS,Txt_Your_personal_data_have_been_updated);
2014-12-01 23:55:08 +01:00
2018-10-09 00:06:30 +02:00
/***** Show my record and other data *****/
2018-10-09 13:41:55 +02:00
Rec_ShowMySharedRecordAndMore ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********************** Show user's record for check *************************/
/*****************************************************************************/
2016-11-18 01:07:00 +01:00
void Rec_ShowSharedRecordUnmodifiable (struct UsrData *UsrDat)
2014-12-01 23:55:08 +01:00
{
/***** Get password, user type and user's data from database *****/
2019-03-19 13:22:14 +01:00
Usr_GetAllUsrDataFromUsrCod (UsrDat,Usr_DONT_GET_PREFS);
2017-06-09 15:04:02 +02:00
UsrDat->Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (UsrDat);
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\">");
2017-05-09 20:56:02 +02:00
Rec_ShowSharedUsrRecord (Rec_SHA_OTHER_USR_CHECK,UsrDat,NULL);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</div>");
}
2018-10-09 01:04:47 +02:00
/*****************************************************************************/
/************** Show public shared record card of another user ***************/
/*****************************************************************************/
void Rec_ShowPublicSharedRecordOtherUsr (void)
{
Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_PUBLIC,&Gbl.Usrs.Other.UsrDat,NULL);
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-11-18 01:07:00 +01:00
/************************** Show shared record card **************************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
// Show form or only data depending on TypeOfView
2016-11-18 00:17:53 +01:00
void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView,
2017-05-09 20:56:02 +02:00
struct UsrData *UsrDat,const char *Anchor)
2014-12-01 23:55:08 +01:00
{
2017-03-02 21:18:52 +01:00
extern const char *Hlp_USERS_SignUp;
2016-11-13 13:31:39 +01:00
extern const char *Hlp_PROFILE_Record;
2019-03-12 21:25:55 +01:00
extern const char *Hlp_START_Profiles_view_public_profile;
2016-11-20 20:03:47 +01:00
extern const char *Hlp_USERS_Guests;
2016-11-18 00:17:53 +01:00
extern const char *Hlp_USERS_Students_shared_record_card;
2016-11-18 10:08:01 +01:00
extern const char *Hlp_USERS_Teachers_shared_record_card;
2019-02-22 21:47:50 +01:00
extern const char *The_ClassFormInBox[The_NUM_THEMES];
2017-05-30 02:17:33 +02:00
extern const char *Txt_Sign_up;
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;
2016-11-18 00:17:53 +01:00
const char *Rec_RecordHelp[Rec_SHARED_NUM_VIEW_TYPES] =
{
2017-05-30 02:17:33 +02:00
Hlp_USERS_SignUp, // Rec_SHA_SIGN_UP_IN_CRS_FORM
2016-11-18 00:17:53 +01:00
2016-12-09 14:54:19 +01:00
Hlp_PROFILE_Record, // Rec_SHA_MY_RECORD_FORM
2016-11-18 00:17:53 +01:00
2016-12-09 14:54:19 +01:00
NULL, // Rec_SHA_OTHER_EXISTING_USR_FORM
NULL, // Rec_SHA_OTHER_NEW_USR_FORM
NULL, // Rec_SHA_OTHER_USR_CHECK
2016-11-18 00:17:53 +01:00
2016-12-09 14:54:19 +01:00
NULL, // Rec_SHA_RECORD_LIST
NULL, // Rec_SHA_RECORD_PRINT
2019-03-12 21:25:55 +01:00
Hlp_START_Profiles_view_public_profile, // Rec_SHA_RECORD_PUBLIC
2016-11-18 00:17:53 +01:00
};
const char *Rec_RecordListHelp[Rol_NUM_ROLES] =
{
2017-05-18 19:13:41 +02:00
NULL, // Rol_UNK
Hlp_USERS_Guests, // Rol_GST
NULL, // Rol_USR
Hlp_USERS_Students_shared_record_card, // Rol_STD
2017-05-22 14:52:11 +02:00
Hlp_USERS_Teachers_shared_record_card, // Rol_NET
2017-05-18 19:13:41 +02:00
Hlp_USERS_Teachers_shared_record_card, // Rol_TCH
2016-11-18 00:17:53 +01:00
NULL, // Rol_DEG_ADM
NULL, // Rol_CTR_ADM
NULL, // Rol_INS_ADM
NULL, // Rol_SYS_ADM
};
2017-01-28 15:58:46 +01:00
char StrRecordWidth[10 + 1];
2015-12-16 00:16:32 +01:00
const char *ClassForm = "REC_DAT";
2016-12-13 13:32:19 +01:00
bool ItsMe;
2017-05-22 14:52:11 +02:00
bool IAmLoggedAsTeacherOrSysAdm;
2016-12-13 13:32:19 +01:00
bool CountryForm;
2017-01-25 18:48:41 +01:00
bool ICanEdit;
2015-03-24 10:11:17 +01:00
bool PutFormLinks; // Put links (forms) inside record card
2016-12-13 13:32:19 +01:00
bool ShowData;
bool ShowIDRows;
bool ShowAddressRows;
2017-05-22 14:52:11 +02:00
bool StudentInCurrentCrs;
bool TeacherInCurrentCrs;
2016-12-13 13:32:19 +01:00
bool ShowTeacherRows;
2016-10-28 10:03:37 +02:00
struct Instit Ins;
2017-05-22 14:52:11 +02:00
Act_Action_t NextAction;
2014-12-01 23:55:08 +01:00
2016-04-22 12:44:56 +02:00
/***** Initializations *****/
2018-10-10 23:56:42 +02:00
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
2017-06-04 18:18:54 +02:00
IAmLoggedAsTeacherOrSysAdm = (Gbl.Usrs.Me.Role.Logged == Rol_NET || // My current role is non-editing teacher
Gbl.Usrs.Me.Role.Logged == Rol_TCH || // My current role is teacher
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM); // My current role is system admin
2016-12-13 13:32:19 +01:00
CountryForm = (TypeOfView == Rec_SHA_MY_RECORD_FORM);
ShowData = (ItsMe ||
2017-06-04 18:18:54 +02:00
Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM ||
2016-12-13 13:32:19 +01:00
UsrDat->Accepted);
ShowIDRows = (TypeOfView != Rec_SHA_RECORD_PUBLIC);
2017-05-22 14:52:11 +02:00
2017-06-08 15:32:33 +02:00
StudentInCurrentCrs = UsrDat->Roles.InCurrentCrs.Role == Rol_STD;
TeacherInCurrentCrs = UsrDat->Roles.InCurrentCrs.Role == Rol_NET ||
UsrDat->Roles.InCurrentCrs.Role == Rol_TCH;
2017-05-22 14:52:11 +02:00
2016-12-13 13:32:19 +01:00
ShowAddressRows = (TypeOfView == Rec_SHA_MY_RECORD_FORM ||
((TypeOfView == Rec_SHA_RECORD_LIST ||
TypeOfView == Rec_SHA_RECORD_PRINT) &&
2017-05-22 14:52:11 +02:00
IAmLoggedAsTeacherOrSysAdm &&
StudentInCurrentCrs)); // He/she is a student in the current course
2016-12-13 13:32:19 +01:00
Rol_GetRolesInAllCrssIfNotYetGot (UsrDat); // Get user's roles if not got
2018-10-09 00:06:30 +02:00
ShowTeacherRows = (TypeOfView == Rec_SHA_RECORD_LIST ||
TypeOfView == Rec_SHA_RECORD_PRINT) &&
TeacherInCurrentCrs; // He/she is a teacher in the current course
2016-12-13 13:32:19 +01:00
2017-01-25 18:35:42 +01:00
/* Data form = I can edit fields like surnames and name */
switch (TypeOfView)
{
case Rec_SHA_MY_RECORD_FORM:
case Rec_SHA_OTHER_NEW_USR_FORM:
2017-01-25 18:48:41 +01:00
ICanEdit = true;
2017-01-25 18:35:42 +01:00
break;
case Rec_SHA_OTHER_EXISTING_USR_FORM:
2017-01-27 10:42:20 +01:00
ICanEdit = Usr_ICanChangeOtherUsrData (UsrDat);
2017-01-25 18:35:42 +01:00
break;
2017-05-30 02:17:33 +02:00
default: // In other options, I can not edit user's data
2017-01-25 18:48:41 +01:00
ICanEdit = false;
2017-01-25 18:35:42 +01:00
break;
}
/* Class for labels */
2014-12-01 23:55:08 +01:00
switch (TypeOfView)
{
2017-05-30 02:17:33 +02:00
case Rec_SHA_SIGN_UP_IN_CRS_FORM:
2016-11-18 00:17:53 +01:00
case Rec_SHA_MY_RECORD_FORM:
case Rec_SHA_OTHER_NEW_USR_FORM:
case Rec_SHA_OTHER_EXISTING_USR_FORM:
2019-02-22 21:47:50 +01:00
ClassForm = The_ClassFormInBox[Gbl.Prefs.Theme];
2014-12-01 23:55:08 +01:00
break;
2016-11-18 00:17:53 +01:00
case Rec_SHA_OTHER_USR_CHECK:
case Rec_SHA_RECORD_LIST:
case Rec_SHA_RECORD_PUBLIC:
case Rec_SHA_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
2017-06-08 15:32:33 +02:00
Rec_RecordHelp[Rec_SHA_RECORD_LIST] = Rec_RecordListHelp[UsrDat->Roles.InCurrentCrs.Role];
2016-11-18 00:17:53 +01:00
2016-01-14 10:31:09 +01:00
PutFormLinks = !Gbl.Form.Inside && // Only if not inside another form
2018-04-24 13:21:53 +02:00
Act_GetBrowserTab (Gbl.Action.Act) == Act_BRW_1ST_TAB; // Only in main browser tab
2015-03-24 10:11:17 +01:00
2016-04-22 12:44:56 +02:00
Ins.InsCod = UsrDat->InsCod;
if (Ins.InsCod > 0)
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
2017-06-12 14:16:33 +02:00
/***** Start box and table *****/
2015-12-13 17:49:53 +01:00
sprintf (StrRecordWidth,"%upx",Rec_RECORD_WIDTH);
2016-05-05 14:20:38 +02:00
Gbl.Record.UsrDat = UsrDat;
Gbl.Record.TypeOfView = TypeOfView;
2017-06-10 21:38:10 +02:00
Box_StartBoxTable (StrRecordWidth,NULL,
2017-06-11 22:26:40 +02:00
TypeOfView == Rec_SHA_OTHER_NEW_USR_FORM ? NULL : // New user ==> don't put icons
Rec_PutIconsCommands,
2017-06-12 15:03:29 +02:00
Rec_RecordHelp[TypeOfView],Box_NOT_CLOSABLE,2);
2014-12-01 23:55:08 +01:00
2016-04-22 12:39:36 +02:00
/***** Institution and user's photo *****/
2016-04-22 12:24:02 +02:00
fprintf (Gbl.F.Out,"<tr>");
2016-04-23 14:51:12 +02:00
Rec_ShowInstitutionInHead (&Ins,PutFormLinks);
2016-04-22 12:39:36 +02:00
Rec_ShowPhoto (UsrDat);
fprintf (Gbl.F.Out,"</tr>");
2014-12-01 23:55:08 +01:00
2017-06-09 15:04:02 +02:00
/***** Full name *****/
2016-04-22 12:39:36 +02:00
fprintf (Gbl.F.Out,"<tr>");
2016-04-22 12:44:56 +02:00
Rec_ShowFullName (UsrDat);
fprintf (Gbl.F.Out,"</tr>");
2014-12-01 23:55:08 +01:00
/***** User's nickname *****/
2017-03-05 17:12:00 +01:00
fprintf (Gbl.F.Out,"<tr>");
2016-04-22 19:50:59 +02:00
Rec_ShowNickname (UsrDat,PutFormLinks);
2017-03-05 17:12:00 +01:00
fprintf (Gbl.F.Out,"</tr>");
2015-03-05 21:42:02 +01:00
2016-04-22 20:00:26 +02:00
/***** User's country, web and social networks *****/
2016-04-22 19:55:41 +02:00
fprintf (Gbl.F.Out,"<tr>");
2016-04-23 13:58:20 +02:00
Rec_ShowCountryInHead (UsrDat,ShowData);
2016-04-22 20:00:26 +02:00
Rec_ShowWebsAndSocialNets (UsrDat,TypeOfView);
fprintf (Gbl.F.Out,"</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\">");
2017-05-09 20:56:02 +02:00
/***** Show email and user's IDs *****/
2016-04-23 19:34:29 +02:00
if (ShowIDRows)
{
2017-06-11 20:09:59 +02:00
Tbl_StartTableWide (2);
2017-05-09 20:56:02 +02:00
/* Show email */
2016-04-23 19:34:29 +02:00
Rec_ShowEmail (UsrDat,ClassForm);
2017-05-09 20:56:02 +02:00
/* Show user's IDs */
2017-05-10 10:09:19 +02:00
Rec_ShowUsrIDs (UsrDat,ClassForm,Anchor);
2017-05-09 20:56:02 +02:00
2017-06-11 20:09:59 +02:00
Tbl_EndTable ();
2016-04-23 19:34:29 +02:00
}
/***** Start form *****/
2015-03-29 21:43:33 +02:00
switch (TypeOfView)
{
2017-05-30 02:17:33 +02:00
case Rec_SHA_SIGN_UP_IN_CRS_FORM:
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActSignUp);
2017-05-30 02:17:33 +02:00
break;
2016-11-18 00:17:53 +01:00
case Rec_SHA_MY_RECORD_FORM:
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActChgMyData);
2015-03-29 21:43:33 +02:00
break;
2017-05-30 02:17:33 +02:00
case Rec_SHA_OTHER_EXISTING_USR_FORM:
switch (Gbl.Action.Act)
2017-05-22 14:52:11 +02:00
{
2017-05-30 02:17:33 +02:00
case ActReqMdfStd:
NextAction = ActUpdStd;
2017-05-22 14:52:11 +02:00
break;
case ActReqMdfNET:
2017-05-30 02:17:33 +02:00
NextAction = ActUpdNET;
2017-05-22 14:52:11 +02:00
break;
case ActReqMdfTch:
2017-05-30 02:17:33 +02:00
NextAction = ActUpdTch;
2017-05-22 14:52:11 +02:00
break;
default:
2017-05-30 02:17:33 +02:00
NextAction = ActUpdOth;
2017-05-22 14:52:11 +02:00
break;
}
2018-11-09 20:47:39 +01:00
Frm_StartForm (NextAction);
2017-05-30 02:17:33 +02:00
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); // Existing user
2015-03-29 21:43:33 +02:00
break;
2017-05-30 02:17:33 +02:00
case Rec_SHA_OTHER_NEW_USR_FORM:
switch (Gbl.Action.Act)
2017-05-22 14:52:11 +02:00
{
2017-05-30 02:17:33 +02:00
case ActReqMdfStd:
NextAction = ActCreStd;
2017-05-22 14:52:11 +02:00
break;
2017-05-30 02:17:33 +02:00
case ActReqMdfNET:
NextAction = ActCreNET;
2017-05-22 14:52:11 +02:00
break;
2017-05-30 02:17:33 +02:00
case ActReqMdfTch:
NextAction = ActCreTch;
2017-05-22 14:52:11 +02:00
break;
2017-05-30 02:17:33 +02:00
default:
NextAction = ActCreOth;
2017-05-22 14:52:11 +02:00
break;
}
2018-11-09 20:47:39 +01:00
Frm_StartForm (NextAction);
2017-05-30 02:17:33 +02:00
ID_PutParamOtherUsrIDPlain (); // New user
2015-03-29 21:43:33 +02:00
break;
default:
break;
}
2015-03-29 15:03:35 +02:00
2017-06-11 20:09:59 +02:00
Tbl_StartTableWide (2);
2015-03-29 13:57:24 +02:00
if (ShowIDRows)
2015-03-05 23:18:43 +01:00
{
2016-04-23 13:58:20 +02:00
/***** Role or sex *****/
2016-04-23 13:23:09 +02:00
Rec_ShowRole (UsrDat,TypeOfView,ClassForm);
2015-03-29 13:57:24 +02:00
/***** Name *****/
2017-01-25 18:48:41 +01:00
Rec_ShowSurname1 (UsrDat,TypeOfView,ICanEdit,ClassForm);
Rec_ShowSurname2 (UsrDat,ICanEdit,ClassForm);
Rec_ShowFirstName (UsrDat,TypeOfView,ICanEdit,ClassForm);
2015-03-29 13:57:24 +02:00
2016-04-23 13:58:20 +02:00
/***** Country *****/
2015-03-29 13:57:24 +02:00
if (CountryForm)
2016-04-23 13:58:20 +02:00
Rec_ShowCountry (UsrDat,TypeOfView,ClassForm);
2015-03-05 23:18:43 +01:00
}
2015-03-29 13:57:24 +02:00
2018-10-08 01:07:15 +02:00
/***** Address rows *****/
2015-03-29 13:57:24 +02:00
if (ShowAddressRows)
2015-03-25 16:25:50 +01:00
{
2016-04-23 14:03:56 +02:00
/***** Origin place *****/
2017-01-25 18:48:41 +01:00
Rec_ShowOriginPlace (UsrDat,ShowData,ICanEdit,ClassForm);
2015-03-29 13:57:24 +02:00
2016-04-23 14:06:49 +02:00
/***** Date of birth *****/
2017-01-25 18:48:41 +01:00
Rec_ShowDateOfBirth (UsrDat,ShowData,ICanEdit,ClassForm);
2014-12-01 23:55:08 +01:00
2016-04-23 14:12:52 +02:00
/***** Local address *****/
2017-01-25 18:48:41 +01:00
Rec_ShowLocalAddress (UsrDat,ShowData,ICanEdit,ClassForm);
2014-12-01 23:55:08 +01:00
2016-04-23 14:18:09 +02:00
/***** Local phone *****/
2017-01-25 18:48:41 +01:00
Rec_ShowLocalPhone (UsrDat,ShowData,ICanEdit,ClassForm);
2014-12-01 23:55:08 +01:00
2016-04-23 14:31:57 +02:00
/***** Family address *****/
2017-01-25 18:48:41 +01:00
Rec_ShowFamilyAddress (UsrDat,ShowData,ICanEdit,ClassForm);
2014-12-01 23:55:08 +01:00
2016-04-23 14:36:02 +02:00
/***** Family phone *****/
2017-01-25 18:48:41 +01:00
Rec_ShowFamilyPhone (UsrDat,ShowData,ICanEdit,ClassForm);
2014-12-01 23:55:08 +01:00
2016-04-23 14:43:53 +02:00
/***** User's comments *****/
2017-01-25 18:48:41 +01:00
Rec_ShowComments (UsrDat,ShowData,ICanEdit,ClassForm);
2015-03-29 13:57:24 +02:00
}
2014-12-01 23:55:08 +01:00
2018-10-08 01:07:15 +02:00
/***** Teacher's rows *****/
2018-10-08 12:37:29 +02:00
if (ShowTeacherRows)
2018-10-08 01:07:15 +02:00
Rec_ShowTeacherRows (UsrDat,&Ins,ShowData,ClassForm);
2016-04-23 16:37:16 +02:00
2017-06-11 20:09:59 +02:00
Tbl_EndTable ();
2015-03-29 13:57:24 +02:00
2016-04-23 19:34:29 +02:00
/***** Button and end form *****/
2015-03-29 21:43:33 +02:00
switch (TypeOfView)
{
2017-05-30 02:17:33 +02:00
case Rec_SHA_SIGN_UP_IN_CRS_FORM:
2017-06-11 19:02:40 +02:00
Btn_PutConfirmButton (Txt_Sign_up);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2017-05-30 02:17:33 +02:00
break;
2016-11-18 00:17:53 +01:00
case Rec_SHA_MY_RECORD_FORM:
2017-06-11 19:02:40 +02:00
Btn_PutConfirmButton (Txt_Save_changes);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2015-03-29 21:43:33 +02:00
break;
2016-11-18 00:17:53 +01:00
case Rec_SHA_OTHER_NEW_USR_FORM:
2019-04-04 10:45:15 +02:00
if (Gbl.Crs.Grps.NumGrps) // This course has groups?
2015-03-29 21:43:33 +02:00
Grp_ShowLstGrpsToChgOtherUsrsGrps (UsrDat->UsrCod);
2017-06-11 19:02:40 +02:00
Btn_PutConfirmButton (Txt_Register);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2015-03-29 21:43:33 +02:00
break;
2016-11-18 00:17:53 +01:00
case Rec_SHA_OTHER_EXISTING_USR_FORM:
2015-03-29 21:43:33 +02:00
/***** Show list of groups to register/remove me/user *****/
2019-04-04 10:45:15 +02:00
if (Gbl.Crs.Grps.NumGrps) // This course has groups?
2015-03-29 21:43:33 +02:00
{
if (ItsMe)
{
// Don't show groups if I don't belong to course
if (Gbl.Usrs.Me.IBelongToCurrentCrs)
2017-05-22 12:23:08 +02:00
Grp_ShowLstGrpsToChgMyGrps ();
2015-03-29 21:43:33 +02:00
}
2018-10-10 23:56:42 +02:00
else // Not me
2015-03-29 21:43:33 +02:00
Grp_ShowLstGrpsToChgOtherUsrsGrps (UsrDat->UsrCod);
}
/***** Which action, register or removing? *****/
if (Enr_PutActionsRegRemOneUsr (ItsMe))
2017-06-11 19:02:40 +02:00
Btn_PutConfirmButton (Txt_Confirm);
2015-03-29 21:43:33 +02:00
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2015-03-29 21:43:33 +02:00
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>");
}
2017-06-12 14:16:33 +02:00
/***** End table and box *****/
2017-06-10 21:38:10 +02:00
Box_EndBoxTable ();
2016-05-05 14:20:38 +02:00
}
/*****************************************************************************/
/*********** Show commands (icon to make actions) in record card *************/
/*****************************************************************************/
static void Rec_PutIconsCommands (void)
{
2016-05-05 14:32:58 +02:00
extern const char *Txt_Edit_my_personal_data;
2017-02-17 01:59:58 +01:00
extern const char *Txt_My_public_profile;
extern const char *Txt_Another_user_s_profile;
2016-05-05 14:20:38 +02:00
extern const char *Txt_View_record_for_this_course;
2016-12-09 13:59:33 +01:00
extern const char *Txt_View_record_and_office_hours;
2017-01-20 09:26:35 +01:00
extern const char *Txt_Show_agenda;
2017-01-31 00:25:10 +01:00
extern const char *Txt_Administer_user;
2016-05-05 14:20:38 +02:00
extern const char *Txt_Write_a_message;
2016-11-24 22:08:04 +01:00
extern const char *Txt_View_homework;
2016-11-21 13:15:08 +01:00
extern const char *Txt_View_test_results;
2016-11-18 00:49:16 +01:00
extern const char *Txt_View_attendance;
2016-05-05 14:20:38 +02:00
extern const char *Txt_Following_unfollow;
extern const char *Txt_Follow;
2018-10-10 23:56:42 +02:00
bool ItsMe = Usr_ItsMe (Gbl.Record.UsrDat->UsrCod);
2016-12-09 14:17:32 +01:00
bool ICanViewUsrProfile;
2019-03-12 10:47:40 +01:00
bool RecipientHasBannedMe;
2017-05-22 14:52:11 +02:00
Act_Action_t NextAction;
2016-05-05 14:20:38 +02:00
2018-04-24 13:21:53 +02:00
if (!Gbl.Form.Inside && // Only if not inside another form
Act_GetBrowserTab (Gbl.Action.Act) == Act_BRW_1ST_TAB && // Only in main browser tab
Gbl.Usrs.Me.Logged) // Only if I am logged
2016-05-05 14:20:38 +02:00
{
2019-03-22 15:21:46 +01:00
ICanViewUsrProfile = Pri_ShowingIsAllowed (Gbl.Record.UsrDat->BaPrfVisibility,
2017-02-17 01:59:58 +01:00
Gbl.Record.UsrDat);
2016-12-09 14:17:32 +01:00
2016-12-09 13:59:33 +01:00
/***** Start container *****/
2016-11-14 10:05:41 +01:00
fprintf (Gbl.F.Out,"<div class=\"FRAME_ICO\">");
2016-05-05 14:20:38 +02:00
if (ItsMe)
2017-02-17 06:32:57 +01:00
/***** Button to edit my record card *****/
2019-01-12 03:00:59 +01:00
Lay_PutContextualLinkOnlyIcon (ActReqEdiRecSha,NULL,NULL,
"pen.svg",
Txt_Edit_my_personal_data);
2017-02-17 06:32:57 +01:00
if (ICanViewUsrProfile)
/***** Button to view user's profile *****/
2019-01-12 03:00:59 +01:00
Lay_PutContextualLinkOnlyIcon (ActSeeOthPubPrf,NULL,
Rec_PutParamUsrCodEncrypted,
"user.svg",
ItsMe ? Txt_My_public_profile :
Txt_Another_user_s_profile);
2016-12-09 14:17:32 +01:00
2016-12-09 13:59:33 +01:00
/***** Button to view user's record card *****/
if (Usr_CheckIfICanViewRecordStd (Gbl.Record.UsrDat))
/* View student's records: common record card and course record card */
2019-01-12 03:00:59 +01:00
Lay_PutContextualLinkOnlyIcon (ActSeeRecOneStd,NULL,
Rec_PutParamUsrCodEncrypted,
"card.svg",
Txt_View_record_for_this_course);
2016-12-09 13:59:33 +01:00
else if (Usr_CheckIfICanViewRecordTch (Gbl.Record.UsrDat))
2019-01-12 03:00:59 +01:00
Lay_PutContextualLinkOnlyIcon (ActSeeRecOneTch,NULL,
Rec_PutParamUsrCodEncrypted,
"card.svg",
Txt_View_record_and_office_hours);
2016-05-05 14:20:38 +02:00
2016-12-09 13:59:33 +01:00
/***** Button to view user's agenda *****/
2016-12-07 10:16:39 +01:00
if (ItsMe)
2019-01-12 03:00:59 +01:00
Lay_PutContextualLinkOnlyIcon (ActSeeMyAgd,NULL,NULL,
"calendar.svg",
Txt_Show_agenda);
2016-12-09 13:59:33 +01:00
else if (Usr_CheckIfICanViewUsrAgenda (Gbl.Record.UsrDat))
2019-01-12 03:00:59 +01:00
Lay_PutContextualLinkOnlyIcon (ActSeeUsrAgd,NULL,
Rec_PutParamUsrCodEncrypted,
"calendar.svg",
Txt_Show_agenda);
2016-12-01 20:24:14 +01:00
2016-05-05 14:20:38 +02:00
/***** Button to admin user *****/
if (ItsMe ||
2019-04-03 20:57:04 +02:00
Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
Gbl.Usrs.Me.Role.Logged == Rol_DEG_ADM ||
Gbl.Usrs.Me.Role.Logged == Rol_CTR_ADM ||
Gbl.Usrs.Me.Role.Logged == Rol_INS_ADM ||
2017-06-04 18:18:54 +02:00
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)
2017-05-22 14:52:11 +02:00
{
2017-06-08 15:32:33 +02:00
switch (Gbl.Record.UsrDat->Roles.InCurrentCrs.Role)
2017-05-22 14:52:11 +02:00
{
case Rol_STD:
NextAction = ActReqMdfStd;
break;
case Rol_NET:
NextAction = ActReqMdfNET;
break;
case Rol_TCH:
NextAction = ActReqMdfTch;
break;
default: // Guest, user or admin
NextAction = ActReqMdfOth;
break;
}
2019-01-12 03:00:59 +01:00
Lay_PutContextualLinkOnlyIcon (NextAction,NULL,
Rec_PutParamUsrCodEncrypted,
"user-cog.svg",
Txt_Administer_user);
2017-05-22 14:52:11 +02:00
}
2016-05-05 14:20:38 +02:00
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected
2016-05-05 14:20:38 +02:00
{
2017-10-05 22:29:33 +02:00
if (Gbl.Record.UsrDat->Roles.InCurrentCrs.Role == Rol_STD) // He/she is a student in current course
{
/***** Button to view student's test exams *****/
if (Usr_CheckIfICanViewTst (Gbl.Record.UsrDat))
{
if (ItsMe)
2019-02-11 22:15:18 +01:00
Lay_PutContextualLinkOnlyIcon (ActSeeMyTstRes,NULL,
Rec_PutParamsMyTsts,
2019-01-12 03:00:59 +01:00
"check.svg",
Txt_View_test_results);
2018-10-10 23:56:42 +02:00
else // Not me
2019-01-12 03:00:59 +01:00
Lay_PutContextualLinkOnlyIcon (ActSeeUsrTstRes,NULL,
2019-02-11 22:15:18 +01:00
Rec_PutParamsStdTsts,
2019-01-12 03:00:59 +01:00
"check.svg",
Txt_View_test_results);
2017-10-05 22:29:33 +02:00
}
/***** Button to view student's assignments and works *****/
if (Usr_CheckIfICanViewAsgWrk (Gbl.Record.UsrDat))
{
if (ItsMe)
2019-01-12 03:00:59 +01:00
Lay_PutContextualLinkOnlyIcon (ActAdmAsgWrkUsr,NULL,NULL,
"folder-open.svg",
Txt_View_homework);
else // Not me, I am not a student in current course
Lay_PutContextualLinkOnlyIcon (ActAdmAsgWrkCrs,NULL,
Rec_PutParamsWorks,
"folder-open.svg",
Txt_View_homework);
2017-10-05 22:29:33 +02:00
}
/***** Button to view student's attendance *****/
if (Usr_CheckIfICanViewAtt (Gbl.Record.UsrDat))
2017-06-08 15:32:33 +02:00
{
if (ItsMe)
2019-01-12 03:00:59 +01:00
Lay_PutContextualLinkOnlyIcon (ActSeeLstMyAtt,NULL,NULL,
"calendar-check.svg",
Txt_View_attendance);
2018-10-10 23:56:42 +02:00
else // Not me
2019-01-12 03:00:59 +01:00
Lay_PutContextualLinkOnlyIcon (ActSeeLstStdAtt,NULL,
Rec_PutParamsStudent,
"calendar-check.svg",
Txt_View_attendance);
2017-06-08 15:32:33 +02:00
}
2017-10-05 22:29:33 +02:00
}
2017-06-08 15:32:33 +02:00
}
2017-03-01 12:59:49 +01:00
2018-10-18 08:56:00 +02:00
/***** Button to print QR code *****/
QR_PutLinkToPrintQRCode (ActPrnUsrQR,Rec_PutParamUsrCodEncrypted);
2016-05-05 14:20:38 +02:00
/***** Button to send a message *****/
2019-03-12 10:47:40 +01:00
RecipientHasBannedMe = Msg_CheckIfUsrIsBanned (Gbl.Usrs.Me.UsrDat.UsrCod, // From:
Gbl.Record.UsrDat->UsrCod); // To:
if (!RecipientHasBannedMe)
Lay_PutContextualLinkOnlyIcon (ActReqMsgUsr,NULL,Rec_PutParamsMsgUsr,
"envelope.svg",
Txt_Write_a_message);
2016-05-05 14:20:38 +02:00
/***** Button to follow / unfollow *****/
2018-10-10 23:56:42 +02:00
if (!ItsMe) // Not me
2016-05-05 14:20:38 +02:00
{
2016-09-28 13:12:11 +02:00
if (Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Record.UsrDat->UsrCod))
// I follow user
2019-01-12 03:00:59 +01:00
Lay_PutContextualLinkOnlyIcon (ActUnfUsr,NULL,
Rec_PutParamUsrCodEncrypted,
"user-check.svg",
Txt_Following_unfollow); // Put button to unfollow, even if I can not view user's profile
2016-12-09 14:17:32 +01:00
else if (ICanViewUsrProfile)
2019-01-12 03:00:59 +01:00
Lay_PutContextualLinkOnlyIcon (ActFolUsr,NULL,
Rec_PutParamUsrCodEncrypted,
"user-plus.svg",
Txt_Follow); // Put button to follow
2016-05-05 14:20:38 +02:00
}
2018-10-07 18:07:01 +02:00
/***** Button to change user's photo *****/
2018-10-16 01:36:13 +02:00
Pho_PutIconToChangeUsrPhoto ();
/***** Button to change user's account *****/
Acc_PutIconToChangeUsrAccount ();
2018-10-07 18:07:01 +02:00
2016-12-09 13:59:33 +01:00
/***** End container *****/
2016-05-05 14:20:38 +02:00
fprintf (Gbl.F.Out,"</div>");
}
}
2018-10-07 18:07:01 +02:00
void Rec_PutParamUsrCodEncrypted (void)
2016-05-05 14:20:38 +02:00
{
Usr_PutParamUsrCodEncrypted (Gbl.Record.UsrDat->EncryptedUsrCod);
}
2019-02-11 22:15:18 +01:00
static void Rec_PutParamsMyTsts (void)
{
Dat_SetIniEndDates ();
Dat_WriteParamsIniEndDates ();
}
static void Rec_PutParamsStdTsts (void)
{
Rec_PutParamsStudent ();
Dat_SetIniEndDates ();
Dat_WriteParamsIniEndDates ();
}
2016-05-05 14:20:38 +02:00
static void Rec_PutParamsWorks (void)
{
Rec_PutParamsStudent ();
Par_PutHiddenParamChar ("FullTree",'Y'); // By default, show all files
}
static void Rec_PutParamsStudent (void)
{
Par_PutHiddenParamString ("UsrCodStd",Gbl.Record.UsrDat->EncryptedUsrCod);
Grp_PutParamAllGroups ();
}
static void Rec_PutParamsMsgUsr (void)
{
Rec_PutParamUsrCodEncrypted ();
Grp_PutParamAllGroups ();
Par_PutHiddenParamChar ("ShowOnlyOneRecipient",'Y');
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 *********************/
/*****************************************************************************/
2016-10-28 10:03:37 +02:00
static void Rec_ShowInstitutionInHead (struct Instit *Ins,bool PutFormLinks)
2016-04-22 12:24:02 +02:00
{
2016-04-22 12:39:36 +02:00
/***** Institution logo *****/
2016-05-05 14:32:58 +02:00
fprintf (Gbl.F.Out,"<td rowspan=\"4\" class=\"REC_C1_TOP CENTER_MIDDLE\">");
2016-04-22 12:24:02 +02:00
if (Ins->InsCod > 0)
{
/* Form to go to the institution */
if (PutFormLinks)
{
2018-11-09 20:47:39 +01:00
Frm_StartFormGoTo (ActSeeInsInf);
2016-04-22 12:24:02 +02:00
Ins_PutParamInsCod (Ins->InsCod);
2018-11-09 20:47:39 +01:00
Frm_LinkFormSubmit (Ins->FullName,NULL,NULL);
2016-04-22 12:24:02 +02:00
}
2019-04-03 20:57:04 +02:00
Log_DrawLogo (Hie_INS,Ins->InsCod,Ins->ShrtName,
2016-04-22 12:24:02 +02:00
Rec_INSTITUTION_LOGO_SIZE,NULL,true);
if (PutFormLinks)
{
fprintf (Gbl.F.Out,"</a>");
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-04-22 12:24:02 +02:00
}
}
2016-04-22 12:39:36 +02:00
fprintf (Gbl.F.Out,"</td>");
/***** Institution name *****/
2016-04-23 19:34:29 +02:00
fprintf (Gbl.F.Out,"<td class=\"REC_C2_TOP REC_HEAD LEFT_MIDDLE\">");
2016-04-22 12:24:02 +02:00
if (Ins->InsCod > 0)
{
/* Form to go to the institution */
if (PutFormLinks)
{
2018-11-09 20:47:39 +01:00
Frm_StartFormGoTo (ActSeeInsInf);
2016-04-22 12:24:02 +02:00
Ins_PutParamInsCod (Ins->InsCod);
2018-11-09 20:47:39 +01:00
Frm_LinkFormSubmit (Ins->FullName,"REC_HEAD",NULL);
2016-04-22 12:24:02 +02:00
}
fprintf (Gbl.F.Out,"%s",Ins->FullName);
if (PutFormLinks)
{
fprintf (Gbl.F.Out,"</a>");
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-04-22 12:24:02 +02:00
}
}
fprintf (Gbl.F.Out,"</td>");
}
2016-04-22 12:39:36 +02:00
/*****************************************************************************/
/********************** Show user's photo in record card *********************/
/*****************************************************************************/
static void Rec_ShowPhoto (struct UsrData *UsrDat)
{
2017-01-28 15:58:46 +01:00
char PhotoURL[PATH_MAX + 1];
bool ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL);
2016-04-22 12:39:36 +02:00
/***** User's photo *****/
2016-04-23 19:34:29 +02:00
fprintf (Gbl.F.Out,"<td rowspan=\"3\" class=\"REC_C3_TOP CENTER_TOP\">");
2016-04-22 12:39:36 +02:00
Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL :
NULL,
2019-03-07 22:15:47 +01:00
"PHOTO186x248",Pho_ZOOM,false);
2016-04-22 12:39:36 +02:00
fprintf (Gbl.F.Out,"</td>");
}
2016-04-22 12:44:56 +02:00
/*****************************************************************************/
/*************************** Show user's full name ***************************/
/*****************************************************************************/
static void Rec_ShowFullName (struct UsrData *UsrDat)
{
2017-03-05 17:12:00 +01:00
fprintf (Gbl.F.Out,"<td class=\"REC_C2_MID LEFT_TOP\">"
"<div class=\"REC_NAME\">");
2016-04-22 12:44:56 +02:00
/***** First name *****/
2017-03-05 17:12:00 +01:00
fprintf (Gbl.F.Out,"%s<br />",UsrDat->FirstName);
2016-04-22 12:44:56 +02:00
/***** Surname 1 *****/
2017-03-05 17:12:00 +01:00
fprintf (Gbl.F.Out,"%s<br />",UsrDat->Surname1);
2016-04-22 12:44:56 +02:00
/***** Surname 2 *****/
2017-03-05 17:12:00 +01:00
fprintf (Gbl.F.Out,"%s",UsrDat->Surname2);
2016-04-22 12:44:56 +02:00
2017-03-05 17:12:00 +01:00
fprintf (Gbl.F.Out,"</div>"
"</td>");
2016-04-22 12:44:56 +02:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-04-22 19:55:41 +02:00
/*************************** Show user's nickname ****************************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-04-22 19:50:59 +02:00
static void Rec_ShowNickname (struct UsrData *UsrDat,bool PutFormLinks)
{
2017-02-17 01:59:58 +01:00
extern const char *Txt_My_public_profile;
extern const char *Txt_Another_user_s_profile;
bool ItsMe;
2016-04-22 19:50:59 +02:00
2017-03-05 17:12:00 +01:00
fprintf (Gbl.F.Out,"<td class=\"REC_C2_MID LEFT_BOTTOM\">"
2016-04-23 19:34:29 +02:00
"<div class=\"REC_NICK\">");
2016-04-22 19:50:59 +02:00
if (UsrDat->Nickname[0])
{
if (PutFormLinks)
{
/* Put form to go to public profile */
2018-10-10 23:56:42 +02:00
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActSeeOthPubPrf);
2017-02-17 06:32:57 +01:00
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
2018-11-09 20:47:39 +01:00
Frm_LinkFormSubmit (ItsMe ? Txt_My_public_profile :
2017-02-17 06:32:57 +01:00
Txt_Another_user_s_profile,
"REC_NICK",NULL);
2016-04-22 19:50:59 +02:00
}
fprintf (Gbl.F.Out,"@%s",UsrDat->Nickname);
if (PutFormLinks)
{
fprintf (Gbl.F.Out,"</a>");
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-04-22 19:50:59 +02:00
}
}
fprintf (Gbl.F.Out,"</div>"
2017-03-05 17:12:00 +01:00
"</td>");
2016-04-22 19:50:59 +02:00
}
2016-04-22 19:55:41 +02:00
/*****************************************************************************/
/**************************** Show user's country ****************************/
/*****************************************************************************/
2016-04-23 13:58:20 +02:00
static void Rec_ShowCountryInHead (struct UsrData *UsrDat,bool ShowData)
2016-04-22 19:55:41 +02:00
{
2016-04-23 19:34:29 +02:00
fprintf (Gbl.F.Out,"<td class=\"REC_C2_MID REC_DAT_BOLD LEFT_TOP\">");
2016-04-22 19:55:41 +02:00
if (ShowData && UsrDat->CtyCod > 0)
/* Link to see country information */
2017-03-01 14:53:18 +01:00
Cty_WriteCountryName (UsrDat->CtyCod,
"REC_DAT_BOLD"); // Put link to country
2016-04-22 19:55:41 +02:00
fprintf (Gbl.F.Out,"</td>");
}
2016-04-22 20:00:26 +02:00
/*****************************************************************************/
/******************* Show user's webs and social networks ********************/
/*****************************************************************************/
static void Rec_ShowWebsAndSocialNets (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView)
2016-04-22 20:00:26 +02:00
{
2016-04-23 19:34:29 +02:00
fprintf (Gbl.F.Out,"<td class=\"REC_C3_MID CENTER_TOP\">");
2016-11-18 00:17:53 +01:00
if (TypeOfView != Rec_SHA_RECORD_PRINT)
2016-04-22 20:00:26 +02:00
Net_ShowWebsAndSocialNets (UsrDat);
fprintf (Gbl.F.Out,"</td>");
}
2016-04-22 20:31:10 +02:00
/*****************************************************************************/
2016-11-16 23:19:52 +01:00
/***************************** Show user's email *****************************/
2016-04-22 20:31:10 +02:00
/*****************************************************************************/
2016-04-23 13:30:59 +02:00
static void Rec_ShowEmail (struct UsrData *UsrDat,const char *ClassForm)
2016-04-22 20:31:10 +02:00
{
extern const char *Txt_Email;
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE %s\">"
2016-04-22 20:31:10 +02:00
"%s:"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Email);
2016-04-22 20:31:10 +02:00
if (UsrDat->Email[0])
{
2017-03-05 17:23:10 +01:00
fprintf (Gbl.F.Out,"<div class=\"REC_EMAIL\">"); // Limited width
2017-01-27 15:21:01 +01:00
if (Mai_ICanSeeOtherUsrEmail (UsrDat))
2017-03-05 17:23:10 +01:00
fprintf (Gbl.F.Out,"<a href=\"mailto:%s\" class=\"REC_DAT_BOLD\">"
"%s"
"</a>",
UsrDat->Email,
2016-04-22 20:31:10 +02:00
UsrDat->Email);
else
fprintf (Gbl.F.Out,"********");
2017-03-05 17:23:10 +01:00
fprintf (Gbl.F.Out,"</div>");
2016-04-22 20:31:10 +02:00
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-22 20:47:11 +02:00
/*****************************************************************************/
/******************************* Show user's IDs *****************************/
/*****************************************************************************/
2017-05-10 10:09:19 +02:00
static void Rec_ShowUsrIDs (struct UsrData *UsrDat,const char *ClassForm,
const char *Anchor)
2016-04-22 20:47:11 +02:00
{
extern const char *Txt_ID;
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_TOP %s\">"
2016-04-22 20:47:11 +02:00
"%s:"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_TOP\">",
ClassForm,Txt_ID);
2017-05-09 20:56:02 +02:00
ID_WriteUsrIDs (UsrDat,Anchor);
2016-04-22 20:47:11 +02:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 13:23:09 +02:00
/*****************************************************************************/
/************************** Show user's role / sex ***************************/
/*****************************************************************************/
static void Rec_ShowRole (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView,
2016-04-23 13:23:09 +02:00
const char *ClassForm)
{
2018-12-08 16:43:13 +01:00
extern const char *Usr_StringsSexIcons[Usr_NUM_SEXS];
2016-04-23 13:23:09 +02:00
extern const char *Txt_Role;
extern const char *Txt_Sex;
extern const char *Txt_SEX_SINGULAR_Abc[Usr_NUM_SEXS];
extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
2017-05-30 02:17:33 +02:00
bool RoleForm = (TypeOfView == Rec_SHA_SIGN_UP_IN_CRS_FORM ||
TypeOfView == Rec_SHA_OTHER_EXISTING_USR_FORM ||
TypeOfView == Rec_SHA_OTHER_NEW_USR_FORM);
2016-11-18 00:17:53 +01:00
bool SexForm = (TypeOfView == Rec_SHA_MY_RECORD_FORM);
2017-05-30 02:17:33 +02:00
Rol_Role_t DefaultRoleInForm;
2016-04-23 13:23:09 +02:00
Rol_Role_t Role;
Usr_Sex_t Sex;
if (RoleForm)
{
2017-05-30 02:17:33 +02:00
/***** Form to select a role *****/
2016-12-13 13:32:19 +01:00
/* Get user's roles if not got */
Rol_GetRolesInAllCrssIfNotYetGot (UsrDat);
2016-04-23 13:23:09 +02:00
fprintf (Gbl.F.Out,"<tr>"
2016-12-27 16:45:37 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
"<label for=\"Role\" class=\"%s\">%s:</label>"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Role);
2016-04-23 13:23:09 +02:00
switch (TypeOfView)
{
2017-05-30 02:17:33 +02:00
case Rec_SHA_SIGN_UP_IN_CRS_FORM: // I want to apply for enrolment
/***** Set default role *****/
2019-04-04 10:45:15 +02:00
if (UsrDat->UsrCod == Gbl.Hierarchy.Crs.RequesterUsrCod || // Creator of the course
2019-03-07 22:15:47 +01:00
(UsrDat->Roles.InCrss & (1 << Rol_TCH))) // Teacher in other courses
2017-05-30 02:17:33 +02:00
DefaultRoleInForm = Rol_TCH; // Request sign up as a teacher
2017-06-08 15:32:33 +02:00
else if ((UsrDat->Roles.InCrss & (1 << Rol_NET))) // Non-editing teacher in other courses
2017-05-30 02:17:33 +02:00
DefaultRoleInForm = Rol_NET; // Request sign up as a non-editing teacher
2017-05-22 14:52:11 +02:00
else
2017-05-30 02:17:33 +02:00
DefaultRoleInForm = Rol_STD; // Request sign up as a student
/***** Selector of role *****/
2016-12-27 16:45:37 +01:00
fprintf (Gbl.F.Out,"<select id=\"Role\" name=\"Role\">");
2017-05-18 19:13:41 +02:00
for (Role = Rol_STD;
Role <= Rol_TCH;
2016-04-23 13:23:09 +02:00
Role++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",(unsigned) Role);
2017-05-30 02:17:33 +02:00
if (Role == DefaultRoleInForm)
2016-04-23 13:23:09 +02:00
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;
2016-11-18 00:17:53 +01:00
case Rec_SHA_OTHER_EXISTING_USR_FORM: // The other user already exists in the platform
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected
2016-04-23 13:23:09 +02:00
{
2017-05-30 02:17:33 +02:00
/***** Set default role *****/
2017-06-08 15:32:33 +02:00
switch (UsrDat->Roles.InCurrentCrs.Role)
2016-04-23 13:23:09 +02:00
{
2017-05-30 02:17:33 +02:00
case Rol_STD: // Student in current course
case Rol_NET: // Non-editing teacher in current course
case Rol_TCH: // Teacher in current course
2017-06-08 15:32:33 +02:00
DefaultRoleInForm = UsrDat->Roles.InCurrentCrs.Role;
2018-10-04 21:57:25 +02:00
break;
2017-05-30 02:17:33 +02:00
default: // User does not belong to current course
/* If there is a request of this user, default role is the requested role */
DefaultRoleInForm = Rol_GetRequestedRole (UsrDat->UsrCod);
switch (DefaultRoleInForm)
{
case Rol_STD: // Role requested: student
case Rol_NET: // Role requested: non-editing teacher
case Rol_TCH: // Role requested: teacher
break;
default: // No role requested
switch (Gbl.Action.Act)
{
case ActReqMdfStd:
DefaultRoleInForm = Rol_STD;
break;
case ActReqMdfNET:
DefaultRoleInForm = Rol_NET;
break;
case ActReqMdfTch:
DefaultRoleInForm = Rol_TCH;
break;
default:
2017-06-08 15:32:33 +02:00
if ((UsrDat->Roles.InCrss & (1 << Rol_TCH))) // Teacher in other courses
2017-05-30 02:17:33 +02:00
DefaultRoleInForm = Rol_TCH;
2017-06-08 15:32:33 +02:00
else if ((UsrDat->Roles.InCrss & (1 << Rol_NET))) // Non-editing teacher in other courses
2017-05-30 02:17:33 +02:00
DefaultRoleInForm = Rol_NET;
else
DefaultRoleInForm = Rol_STD;
break;
}
break;
}
break;
2016-04-23 13:23:09 +02:00
}
2017-05-30 02:17:33 +02:00
/***** Selector of role *****/
fprintf (Gbl.F.Out,"<select id=\"Role\" name=\"Role\">");
2017-06-04 18:18:54 +02:00
switch (Gbl.Usrs.Me.Role.Logged)
2016-04-23 13:23:09 +02:00
{
2017-05-18 19:13:41 +02:00
case Rol_GST:
case Rol_USR:
case Rol_STD:
2017-05-22 14:52:11 +02:00
case Rol_NET:
2016-12-27 16:45:37 +01:00
fprintf (Gbl.F.Out,"<option value=\"%u\""
" selected=\"selected\""
" disabled=\"disabled\">"
"%s</option>",
2017-06-04 18:18:54 +02:00
(unsigned) Gbl.Usrs.Me.Role.Logged,
Txt_ROLES_SINGUL_Abc[Gbl.Usrs.Me.Role.Logged][UsrDat->Sex]);
2016-04-23 13:23:09 +02:00
break;
2017-05-18 19:13:41 +02:00
case Rol_TCH:
2016-04-23 13:23:09 +02:00
case Rol_DEG_ADM:
case Rol_CTR_ADM:
case Rol_INS_ADM:
case Rol_SYS_ADM:
2017-05-18 19:13:41 +02:00
for (Role = Rol_STD;
Role <= Rol_TCH;
2016-04-23 13:23:09 +02:00
Role++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",(unsigned) Role);
2017-05-30 02:17:33 +02:00
if (Role == DefaultRoleInForm)
2016-04-23 13:23:09 +02:00
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_ROLES_SINGUL_Abc[Role][UsrDat->Sex]);
}
break;
default: // The rest of users can not register other users
break;
}
2017-05-30 02:17:33 +02:00
fprintf (Gbl.F.Out,"</select>");
2016-04-23 13:23:09 +02:00
}
2017-05-30 02:17:33 +02:00
else // No course selected
2016-04-23 13:23:09 +02:00
{
2017-05-30 02:17:33 +02:00
/***** Set default role *****/
2017-06-08 15:32:33 +02:00
DefaultRoleInForm = (UsrDat->Roles.InCrss & ((1 << Rol_STD) |
2019-03-07 22:15:47 +01:00
(1 << Rol_NET) |
(1 << Rol_TCH))) ? Rol_USR : // If user belongs to any course
Rol_GST; // If user don't belong to any course
2017-05-30 02:17:33 +02:00
/***** Selector of role *****/
fprintf (Gbl.F.Out,"<select id=\"Role\" name=\"Role\">"
"<option value=\"%u\" selected=\"selected\""
" disabled=\"disabled\">%s</option>"
"</select>",
(unsigned) DefaultRoleInForm,
Txt_ROLES_SINGUL_Abc[DefaultRoleInForm][UsrDat->Sex]);
2016-04-23 13:23:09 +02:00
}
break;
2017-05-30 02:17:33 +02:00
case Rec_SHA_OTHER_NEW_USR_FORM: // The user does not exist in platform
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected
2017-06-04 18:18:54 +02:00
switch (Gbl.Usrs.Me.Role.Logged)
2016-04-23 13:23:09 +02:00
{
2017-05-18 19:13:41 +02:00
case Rol_TCH:
2017-01-27 12:57:31 +01:00
case Rol_DEG_ADM:
2016-04-23 13:23:09 +02:00
case Rol_CTR_ADM:
case Rol_INS_ADM:
case Rol_SYS_ADM:
2017-05-30 02:17:33 +02:00
/***** Set default role *****/
switch (Gbl.Action.Act)
{
case ActReqMdfStd:
DefaultRoleInForm = Rol_STD;
break;
case ActReqMdfNET:
DefaultRoleInForm = Rol_NET;
break;
case ActReqMdfTch:
DefaultRoleInForm = Rol_TCH;
break;
default:
DefaultRoleInForm = Rol_STD;
break;
}
/***** Selector of role *****/
fprintf (Gbl.F.Out,"<select id=\"Role\" name=\"Role\">");
2017-05-18 19:13:41 +02:00
for (Role = Rol_STD;
Role <= Rol_TCH;
2017-01-27 12:57:31 +01:00
Role++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",(unsigned) Role);
2017-05-30 02:17:33 +02:00
if (Role == DefaultRoleInForm)
2017-01-27 12:57:31 +01:00
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_ROLES_SINGUL_Abc[Role][Usr_SEX_UNKNOWN]);
}
2017-05-30 02:17:33 +02:00
fprintf (Gbl.F.Out,"</select>");
2016-04-23 13:23:09 +02:00
break;
default: // The rest of users can not register other users
break;
}
2017-05-30 02:17:33 +02:00
else // No course selected
2017-06-04 18:18:54 +02:00
switch (Gbl.Usrs.Me.Role.Logged)
2016-04-23 13:23:09 +02:00
{
case Rol_SYS_ADM:
2017-05-30 02:17:33 +02:00
/***** Selector of role *****/
fprintf (Gbl.F.Out,"<select id=\"Role\" name=\"Role\">"
"<option value=\"%u\""
" selected=\"selected\">%s</option>"
"</select>",
2017-05-18 19:13:41 +02:00
(unsigned) Rol_GST,Txt_ROLES_SINGUL_Abc[Rol_GST][Usr_SEX_UNKNOWN]);
2016-04-23 13:23:09 +02:00
break;
default: // The rest of users can not register other users
break;
}
break;
default:
break;
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
else if (SexForm)
{
2017-05-30 02:17:33 +02:00
/***** Form to select a sex *****/
2016-04-23 13:23:09 +02:00
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE %s\">"
2016-04-23 13:23:09 +02:00
"%s*:</td>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C2_BOT LEFT_MIDDLE\">",
2016-04-23 19:34:29 +02:00
ClassForm,Txt_Sex);
2016-04-23 13:23:09 +02:00
for (Sex = Usr_SEX_FEMALE;
Sex <= Usr_SEX_MALE;
Sex++)
{
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<label class=\"REC_DAT_BOLD\">"
"<input type=\"radio\" name=\"Sex\" value=\"%u\"",
(unsigned) Sex);
2016-04-23 13:23:09 +02:00
if (Sex == Gbl.Usrs.Me.UsrDat.Sex)
fprintf (Gbl.F.Out," checked=\"checked\"");
2016-11-18 21:00:55 +01:00
fprintf (Gbl.F.Out," required=\"required\" />"
2018-12-08 16:43:13 +01:00
"%s %s"
2016-12-25 20:51:53 +01:00
"</label>",
2018-12-08 16:43:13 +01:00
Usr_StringsSexIcons[Sex],Txt_SEX_SINGULAR_Abc[Sex]);
2016-04-23 13:23:09 +02:00
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
else // RoleForm == false, SexForm == false
2017-05-30 02:17:33 +02:00
/***** No form, only text *****/
2016-04-23 13:23:09 +02:00
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE %s\">"
2016-04-23 13:23:09 +02:00
"%s:"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">"
2016-04-23 13:23:09 +02:00
"%s"
"</td>"
"</tr>",
2016-04-23 19:34:29 +02:00
ClassForm,
2018-10-09 00:06:30 +02:00
Txt_Role,
Txt_ROLES_SINGUL_Abc[UsrDat->Roles.InCurrentCrs.Role][UsrDat->Sex]);
2016-04-23 13:23:09 +02:00
}
2016-04-23 13:37:43 +02:00
/*****************************************************************************/
/*************************** Show user's surname 1 ***************************/
/*****************************************************************************/
static void Rec_ShowSurname1 (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView,
2017-01-25 18:48:41 +01:00
bool ICanEdit,
2016-04-23 13:37:43 +02:00
const char *ClassForm)
{
extern const char *Txt_Surname_1;
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
"<label for=\"Surname1\" class=\"%s\">"
2016-04-23 13:37:43 +02:00
"%s",
2016-04-23 19:34:29 +02:00
ClassForm,Txt_Surname_1);
2016-11-18 00:17:53 +01:00
if (TypeOfView == Rec_SHA_MY_RECORD_FORM)
2016-04-23 13:37:43 +02:00
fprintf (Gbl.F.Out,"*");
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,":"
"</label>"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">");
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2017-01-27 15:21:01 +01:00
{
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"text\""
" id=\"Surname1\" name=\"Surname1\""
2016-04-23 13:37:43 +02:00
" maxlength=\"%u\" value=\"%s\""
2017-01-27 15:21:01 +01:00
" class=\"REC_C2_BOT_INPUT\"",
2017-03-07 19:55:29 +01:00
Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME,
2016-04-23 19:34:29 +02:00
UsrDat->Surname1);
2017-01-27 15:21:01 +01:00
if (TypeOfView == Rec_SHA_MY_RECORD_FORM)
fprintf (Gbl.F.Out," required=\"required\"");
fprintf (Gbl.F.Out," />");
}
2016-04-23 13:37:43 +02:00
else if (UsrDat->Surname1[0])
fprintf (Gbl.F.Out,"<strong>%s</strong>",UsrDat->Surname1);
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 13:45:03 +02:00
/*****************************************************************************/
2016-04-23 13:49:38 +02:00
/*************************** Show user's surname 2 ***************************/
2016-04-23 13:45:03 +02:00
/*****************************************************************************/
static void Rec_ShowSurname2 (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ICanEdit,
2016-04-23 13:45:03 +02:00
const char *ClassForm)
{
extern const char *Txt_Surname_2;
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
"<label for=\"Surname2\" class=\"%s\">"
2016-04-23 13:45:03 +02:00
"%s:"
2016-12-25 20:51:53 +01:00
"</label>"
2016-04-23 13:45:03 +02:00
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Surname_2);
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"text\""
" id=\"Surname2\" name=\"Surname2\""
2016-04-23 13:45:03 +02:00
" maxlength=\"%u\" value=\"%s\""
2016-04-23 19:34:29 +02:00
" class=\"REC_C2_BOT_INPUT\" />",
2017-03-07 19:55:29 +01:00
Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME,
2016-04-23 19:34:29 +02:00
UsrDat->Surname2);
2016-04-23 13:45:03 +02:00
else if (UsrDat->Surname2[0])
fprintf (Gbl.F.Out,"<strong>%s</strong>",UsrDat->Surname2);
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 13:49:38 +02:00
/*****************************************************************************/
/************************** Show user's first name ***************************/
/*****************************************************************************/
static void Rec_ShowFirstName (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView,
2017-01-25 18:48:41 +01:00
bool ICanEdit,
2016-04-23 13:49:38 +02:00
const char *ClassForm)
{
extern const char *Txt_First_name;
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
"<label for=\"FirstName\" class=\"%s\">"
2016-04-23 13:49:38 +02:00
"%s",
2016-04-23 19:34:29 +02:00
ClassForm,Txt_First_name);
2016-11-18 00:17:53 +01:00
if (TypeOfView == Rec_SHA_MY_RECORD_FORM)
2016-04-23 13:49:38 +02:00
fprintf (Gbl.F.Out,"*");
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,":"
"</label>"
"</td>"
2016-04-23 19:34:29 +02:00
"<td colspan=\"2\""
" class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">");
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2017-01-27 15:21:01 +01:00
{
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"text\""
" id=\"FirstName\" name=\"FirstName\""
2016-11-18 21:00:55 +01:00
" maxlength=\"%u\" value=\"%s\""
2017-01-27 15:21:01 +01:00
" class=\"REC_C2_BOT_INPUT\"",
2017-03-07 19:55:29 +01:00
Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME,
2016-04-23 19:34:29 +02:00
UsrDat->FirstName);
2017-01-27 15:21:01 +01:00
if (TypeOfView == Rec_SHA_MY_RECORD_FORM)
fprintf (Gbl.F.Out," required=\"required\"");
fprintf (Gbl.F.Out," />");
}
2016-04-23 13:49:38 +02:00
else if (UsrDat->FirstName[0])
fprintf (Gbl.F.Out,"<strong>%s</strong>",UsrDat->FirstName);
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 13:58:20 +02:00
/*****************************************************************************/
/**************************** Show user's country ****************************/
/*****************************************************************************/
static void Rec_ShowCountry (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView,
2016-04-23 13:58:20 +02:00
const char *ClassForm)
{
extern const char *Txt_Country;
extern const char *Txt_Another_country;
unsigned NumCty;
/***** If list of countries is empty, try to get it *****/
2019-04-04 10:45:15 +02:00
if (!Gbl.Hierarchy.Sys.Ctys.Num)
2016-04-23 13:58:20 +02:00
{
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Sys.Ctys.SelectedOrder = Cty_ORDER_BY_COUNTRY;
2016-04-23 13:58:20 +02:00
Cty_GetListCountries (Cty_GET_BASIC_DATA);
}
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
2016-12-27 16:45:37 +01:00
"<label for=\"OthCtyCod\" class=\"%s\">%s",
2016-04-23 19:34:29 +02:00
ClassForm,Txt_Country);
2016-11-18 00:17:53 +01:00
if (TypeOfView == Rec_SHA_MY_RECORD_FORM)
2016-04-23 13:58:20 +02:00
fprintf (Gbl.F.Out,"*");
2016-12-27 16:45:37 +01:00
fprintf (Gbl.F.Out,":</label>"
2016-12-25 20:51:53 +01:00
"</td>"
2016-04-23 19:34:29 +02:00
"<td colspan=\"2\""
2016-12-25 20:51:53 +01:00
" class=\"REC_C2_BOT LEFT_MIDDLE\">");
2016-04-23 13:58:20 +02:00
/***** Selector of country *****/
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<select id=\"OthCtyCod\" name=\"OthCtyCod\""
" class=\"REC_C2_BOT_INPUT\" required=\"required\">"
2016-11-18 21:00:55 +01:00
"<option value=\"\">%s</option>"
2016-04-23 13:58:20 +02:00
"<option value=\"0\"",
Txt_Country);
if (UsrDat->CtyCod == 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",Txt_Another_country);
for (NumCty = 0;
2019-04-04 10:45:15 +02:00
NumCty < Gbl.Hierarchy.Sys.Ctys.Num;
2016-04-23 13:58:20 +02:00
NumCty++)
{
fprintf (Gbl.F.Out,"<option value=\"%ld\"",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Sys.Ctys.Lst[NumCty].CtyCod);
if (Gbl.Hierarchy.Sys.Ctys.Lst[NumCty].CtyCod == UsrDat->CtyCod)
2016-04-23 13:58:20 +02:00
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Sys.Ctys.Lst[NumCty].Name[Gbl.Prefs.Language]);
2016-04-23 13:58:20 +02:00
}
fprintf (Gbl.F.Out,"</select>"
"</td>"
"</tr>");
}
2016-04-23 14:03:56 +02:00
/*****************************************************************************/
2016-04-23 14:12:52 +02:00
/************************ Show user's place of origin ************************/
2016-04-23 14:03:56 +02:00
/*****************************************************************************/
static void Rec_ShowOriginPlace (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:03:56 +02:00
const char *ClassForm)
{
extern const char *Txt_Place_of_origin;
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
"<label for=\"OriginPlace\" class=\"%s\">"
2016-04-23 14:03:56 +02:00
"%s:"
2016-12-25 20:51:53 +01:00
"</label>"
2016-04-23 14:03:56 +02:00
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Place_of_origin);
2016-04-23 14:03:56 +02:00
if (ShowData)
{
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"text\""
" id=\"OriginPlace\" name=\"OriginPlace\""
2016-04-23 14:03:56 +02:00
" maxlength=\"%u\" value=\"%s\""
2016-04-23 19:34:29 +02:00
" class=\"REC_C2_BOT_INPUT\" />",
2017-03-08 14:12:33 +01:00
Usr_MAX_CHARS_ADDRESS,
2016-04-23 19:34:29 +02:00
UsrDat->OriginPlace);
2016-04-23 14:03:56 +02:00
else if (UsrDat->OriginPlace[0])
fprintf (Gbl.F.Out,"%s",UsrDat->OriginPlace);
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 14:06:49 +02:00
/*****************************************************************************/
2016-04-23 14:12:52 +02:00
/************************ Show user's date of birth **************************/
2016-04-23 14:06:49 +02:00
/*****************************************************************************/
static void Rec_ShowDateOfBirth (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:06:49 +02:00
const char *ClassForm)
{
extern const char *Txt_Date_of_birth;
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE %s\">"
2016-04-23 14:06:49 +02:00
"%s:"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Date_of_birth);
2016-04-23 14:06:49 +02:00
if (ShowData)
{
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2016-04-23 14:06:49 +02:00
Dat_WriteFormDate (Gbl.Now.Date.Year - Rec_USR_MAX_AGE,
Gbl.Now.Date.Year - Rec_USR_MIN_AGE,
"Birth",
&(UsrDat->Birthday),
false,false);
else if (UsrDat->StrBirthday[0])
fprintf (Gbl.F.Out,"%s",UsrDat->StrBirthday);
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 14:12:52 +02:00
/*****************************************************************************/
/************************ Show user's local address **************************/
/*****************************************************************************/
static void Rec_ShowLocalAddress (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:12:52 +02:00
const char *ClassForm)
{
extern const char *Txt_Local_address;
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
"<label for=\"LocalAddress\" class=\"%s\">"
2016-04-23 14:12:52 +02:00
"%s:"
2016-12-25 20:51:53 +01:00
"</label>"
2016-04-23 14:12:52 +02:00
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Local_address);
2016-04-23 14:12:52 +02:00
if (ShowData)
{
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"text\""
" id=\"LocalAddress\" name=\"LocalAddress\""
2016-04-23 14:12:52 +02:00
" maxlength=\"%u\" value=\"%s\""
2016-04-23 19:34:29 +02:00
" class=\"REC_C2_BOT_INPUT\" />",
2017-03-08 14:12:33 +01:00
Usr_MAX_CHARS_ADDRESS,
2016-04-23 19:34:29 +02:00
UsrDat->LocalAddress);
2016-04-23 14:12:52 +02:00
else if (UsrDat->LocalAddress[0])
fprintf (Gbl.F.Out,"%s",UsrDat->LocalAddress);
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 14:18:09 +02:00
/*****************************************************************************/
/************************* Show user's local phone ***************************/
/*****************************************************************************/
static void Rec_ShowLocalPhone (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:18:09 +02:00
const char *ClassForm)
{
extern const char *Txt_Phone;
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
"<label for=\"LocalPhone\" class=\"%s\">"
2016-04-23 14:18:09 +02:00
"%s:"
2016-12-25 20:51:53 +01:00
"</label>"
2016-04-23 14:18:09 +02:00
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Phone);
2016-04-23 14:18:09 +02:00
if (ShowData)
{
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"tel\""
" id=\"LocalPhone\" name=\"LocalPhone\""
2016-04-23 14:18:09 +02:00
" maxlength=\"%u\" value=\"%s\""
2016-04-23 19:34:29 +02:00
" class=\"REC_C2_BOT_INPUT\" />",
2017-03-08 01:21:21 +01:00
Usr_MAX_CHARS_PHONE,
2016-04-23 19:34:29 +02:00
UsrDat->LocalPhone);
2016-04-23 14:18:09 +02:00
else if (UsrDat->LocalPhone[0])
2016-12-19 02:22:04 +01:00
fprintf (Gbl.F.Out,"<a href=\"tel:%s\" class=\"REC_DAT_BOLD\">%s</a>",
UsrDat->LocalPhone,
UsrDat->LocalPhone);
2016-04-23 14:18:09 +02:00
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 14:31:57 +02:00
/*****************************************************************************/
/*********************** Show user's family address **************************/
/*****************************************************************************/
static void Rec_ShowFamilyAddress (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:31:57 +02:00
const char *ClassForm)
{
extern const char *Txt_Family_address;
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
"<label for=\"FamilyAddress\" class=\"%s\">"
2016-04-23 14:31:57 +02:00
"%s:"
2016-12-25 20:51:53 +01:00
"</label>"
2016-04-23 14:31:57 +02:00
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Family_address);
2016-04-23 14:31:57 +02:00
if (ShowData)
{
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"text\""
" id=\"FamilyAddress\" name=\"FamilyAddress\""
2016-04-23 14:31:57 +02:00
" maxlength=\"%u\" value=\"%s\""
2016-04-23 19:34:29 +02:00
" class=\"REC_C2_BOT_INPUT\" />",
2017-03-08 14:12:33 +01:00
Usr_MAX_CHARS_ADDRESS,
2016-04-23 19:34:29 +02:00
UsrDat->FamilyAddress);
2016-04-23 14:31:57 +02:00
else if (UsrDat->FamilyAddress[0])
fprintf (Gbl.F.Out,"%s",UsrDat->FamilyAddress);
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 14:36:02 +02:00
/*****************************************************************************/
/************************ Show user's family phone ***************************/
/*****************************************************************************/
static void Rec_ShowFamilyPhone (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:36:02 +02:00
const char *ClassForm)
{
extern const char *Txt_Phone;
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
"<label for=\"FamilyPhone\" class=\"%s\">"
2016-04-23 14:36:02 +02:00
"%s:"
2016-12-25 20:51:53 +01:00
"</label>"
2016-04-23 14:36:02 +02:00
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Phone);
2016-04-23 14:36:02 +02:00
if (ShowData)
{
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"tel\""
" id=\"FamilyPhone\" name=\"FamilyPhone\""
2016-04-23 14:36:02 +02:00
" maxlength=\"%u\" value=\"%s\""
2016-04-23 19:34:29 +02:00
" class=\"REC_C2_BOT_INPUT\" />",
2017-03-08 01:21:21 +01:00
Usr_MAX_CHARS_PHONE,
2016-04-23 19:34:29 +02:00
UsrDat->FamilyPhone);
2016-04-23 14:36:02 +02:00
else if (UsrDat->FamilyPhone[0])
2016-12-19 02:22:04 +01:00
fprintf (Gbl.F.Out,"<a href=\"tel:%s\" class=\"REC_DAT_BOLD\">%s</a>",
UsrDat->FamilyPhone,
UsrDat->FamilyPhone);
2016-04-23 14:36:02 +02:00
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 14:43:53 +02:00
/*****************************************************************************/
2016-04-23 14:51:12 +02:00
/************************** Show user's comments *****************************/
2016-04-23 14:43:53 +02:00
/*****************************************************************************/
static void Rec_ShowComments (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:43:53 +02:00
const char *ClassForm)
{
extern const char *Txt_USER_comments;
fprintf (Gbl.F.Out,"<tr>"
2016-12-27 14:04:47 +01:00
"<td class=\"REC_C1_BOT RIGHT_TOP\">"
"<label for=\"Comments\" class=\"%s\">%s:</label>"
2016-04-23 14:43:53 +02:00
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_TOP\">",
ClassForm,Txt_USER_comments);
2016-04-23 14:43:53 +02:00
if (ShowData)
{
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2016-12-27 14:04:47 +01:00
fprintf (Gbl.F.Out,"<textarea id=\"Comments\" name=\"Comments\""
" rows=\"4\" class=\"REC_C2_BOT_INPUT\">"
2016-04-23 14:43:53 +02:00
"%s"
"</textarea>",
UsrDat->Comments);
else if (UsrDat->Comments[0])
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, // Convert from HTML to rigorous HTML
UsrDat->Comments,Cns_MAX_BYTES_TEXT,false);
fprintf (Gbl.F.Out,"%s",UsrDat->Comments);
}
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 14:51:12 +02:00
/*****************************************************************************/
/************************** Show user's institution **************************/
/*****************************************************************************/
2018-10-08 01:07:15 +02:00
static void Rec_ShowTeacherRows (struct UsrData *UsrDat,
struct Instit *Ins,
bool ShowData,const char *ClassForm)
{
/***** Institution *****/
Rec_ShowInstitution (Ins,ShowData,ClassForm);
/***** Centre *****/
Rec_ShowCentre (UsrDat,ShowData,ClassForm);
/***** Department *****/
Rec_ShowDepartment (UsrDat,ShowData,ClassForm);
/***** Office *****/
Rec_ShowOffice (UsrDat,ShowData,ClassForm);
/***** Office phone *****/
Rec_ShowOfficePhone (UsrDat,ShowData,ClassForm);
}
/*****************************************************************************/
/************************** Show user's institution **************************/
/*****************************************************************************/
2016-10-28 10:03:37 +02:00
static void Rec_ShowInstitution (struct Instit *Ins,
2016-04-23 14:51:12 +02:00
bool ShowData,const char *ClassForm)
{
extern const char *Txt_Institution;
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE %s\">"
2016-04-23 14:51:12 +02:00
"%s:"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Institution);
2016-04-23 14:51:12 +02:00
if (ShowData)
if (Ins->InsCod > 0)
{
if (Ins->WWW[0])
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
" class=\"REC_DAT_BOLD\">",
Ins->WWW);
fprintf (Gbl.F.Out,"%s",Ins->FullName);
if (Ins->WWW[0])
fprintf (Gbl.F.Out,"</a>");
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 15:00:07 +02:00
/*****************************************************************************/
/*************************** Show user's centre ******************************/
/*****************************************************************************/
static void Rec_ShowCentre (struct UsrData *UsrDat,
bool ShowData,const char *ClassForm)
{
extern const char *Txt_Centre;
struct Centre Ctr;
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE %s\">"
2016-04-23 15:00:07 +02:00
"%s:"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Centre);
2016-04-23 15:00:07 +02:00
if (ShowData)
{
if (UsrDat->Tch.CtrCod > 0)
{
Ctr.CtrCod = UsrDat->Tch.CtrCod;
Ctr_GetDataOfCentreByCod (&Ctr);
if (Ctr.WWW[0])
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
" class=\"REC_DAT_BOLD\">",
Ctr.WWW);
fprintf (Gbl.F.Out,"%s",Ctr.FullName);
if (Ctr.WWW[0])
fprintf (Gbl.F.Out,"</a>");
}
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 15:08:32 +02:00
/*****************************************************************************/
/************************* Show user's department ****************************/
/*****************************************************************************/
static void Rec_ShowDepartment (struct UsrData *UsrDat,
bool ShowData,const char *ClassForm)
{
extern const char *Txt_Department;
struct Department Dpt;
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE %s\">"
2016-04-23 15:08:32 +02:00
"%s:"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Department);
2016-04-23 15:08:32 +02:00
if (ShowData)
{
if (UsrDat->Tch.DptCod > 0)
{
Dpt.DptCod = UsrDat->Tch.DptCod;
Dpt_GetDataOfDepartmentByCod (&Dpt);
if (Dpt.WWW[0])
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
" class=\"REC_DAT_BOLD\">",
Dpt.WWW);
fprintf (Gbl.F.Out,"%s",Dpt.FullName);
if (Dpt.WWW[0])
fprintf (Gbl.F.Out,"</a>");
}
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 15:15:06 +02:00
/*****************************************************************************/
/*************************** Show user's office ******************************/
/*****************************************************************************/
static void Rec_ShowOffice (struct UsrData *UsrDat,
bool ShowData,const char *ClassForm)
{
extern const char *Txt_Office;
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE %s\">"
2016-04-23 15:15:06 +02:00
"%s:"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Office);
2016-04-23 15:15:06 +02:00
if (ShowData)
fprintf (Gbl.F.Out,"%s",UsrDat->Tch.Office);
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 15:20:37 +02:00
/*****************************************************************************/
/*************************** Show user's office phone ******************************/
/*****************************************************************************/
static void Rec_ShowOfficePhone (struct UsrData *UsrDat,
bool ShowData,const char *ClassForm)
{
extern const char *Txt_Phone;
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE %s\">"
2016-04-23 15:20:37 +02:00
"%s:"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Phone);
2016-04-23 15:20:37 +02:00
if (ShowData)
2016-12-19 02:22:04 +01:00
fprintf (Gbl.F.Out,"<a href=\"tel:%s\" class=\"REC_DAT_BOLD\">%s</a>",
UsrDat->Tch.OfficePhone,
UsrDat->Tch.OfficePhone);
2016-04-23 15:20:37 +02:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-22 19:50:59 +02:00
/*****************************************************************************/
/*********************** Write a link to netiquette rules ********************/
/*****************************************************************************/
2014-12-01 23:55:08 +01:00
static void Rec_WriteLinkToDataProtectionClause (void)
{
extern const char *Txt_DATA_PROTECTION_CLAUSE;
2016-11-13 20:54:06 +01:00
fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">"
2019-03-20 01:36:36 +01:00
"<a class=\"TIT\" href=\"%s/\" target=\"_blank\">%s</a>"
2016-11-13 20:54:06 +01:00
"</div>",
2019-03-20 01:36:36 +01:00
Cfg_URL_DATA_PROTECTION_PUBLIC,
2014-12-01 23:55:08 +01:00
Txt_DATA_PROTECTION_CLAUSE);
}
/*****************************************************************************/
/**************** 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)
{
Rol_Role_t Role;
2017-05-22 14:52:11 +02:00
bool RoleOK;
2014-12-01 23:55:08 +01:00
/***** Get role as a parameter from form *****/
2017-01-29 21:41:08 +01:00
Role = (Rol_Role_t)
Par_GetParToUnsignedLong ("Role",
0,
Rol_NUM_ROLES - 1,
2017-05-18 19:13:41 +02:00
(unsigned long) Rol_UNK);
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 */
2017-05-22 14:52:11 +02:00
RoleOK = false;
2017-06-04 18:18:54 +02:00
switch (Gbl.Usrs.Me.Role.Logged)
2014-12-01 23:55:08 +01:00
{
2017-05-18 19:13:41 +02:00
case Rol_STD: // I am logged as student
2017-05-22 14:52:11 +02:00
case Rol_NET: // I am logged as non-editing teacher
/* A student or a non-editing teacher can only change his/her data, but not his/her role */
2017-06-04 18:18:54 +02:00
Role = Gbl.Usrs.Me.Role.Logged;
RoleOK = true;
2014-12-01 23:55:08 +01:00
break;
2017-05-18 19:13:41 +02:00
case Rol_TCH: // I am logged as teacher
2017-01-19 18:32:28 +01:00
case Rol_DEG_ADM: // I am logged as degree admin
case Rol_CTR_ADM: // I am logged as centre admin
case Rol_INS_ADM: // I am logged as institution admin
2017-05-18 19:13:41 +02:00
if (Role == Rol_STD ||
2017-05-22 14:52:11 +02:00
Role == Rol_NET ||
2017-05-18 19:13:41 +02:00
Role == Rol_TCH)
2015-09-16 22:13:00 +02:00
RoleOK = true;
break;
case Rol_SYS_ADM:
2017-05-18 19:13:41 +02:00
if ( Role == Rol_STD ||
2017-05-22 14:52:11 +02:00
Role == Rol_NET ||
2017-05-18 19:13:41 +02:00
Role == Rol_TCH ||
2019-04-04 10:45:15 +02:00
(Role == Rol_GST && Gbl.Hierarchy.Crs.CrsCod <= 0))
2015-09-16 22:13:00 +02:00
RoleOK = true;
break;
2014-12-01 23:55:08 +01:00
default:
break;
}
2015-09-16 22:13:00 +02:00
if (!RoleOK)
2017-06-04 18:18:54 +02:00
Lay_ShowErrorAndExit ("Wrong role.");
2014-12-01 23:55:08 +01:00
return Role;
}
/*****************************************************************************/
2016-11-18 01:07:00 +01:00
/*************** Get data fields of shared record from form ******************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
void Rec_GetUsrNameFromRecordForm (struct UsrData *UsrDat)
{
2017-03-07 19:55:29 +01:00
char Surname1 [Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1]; // Temporary surname 1
char FirstName[Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1]; // Temporary first name
2014-12-01 23:55:08 +01:00
2017-01-26 11:08:19 +01:00
/***** Get surname 1 *****/
2017-03-07 19:55:29 +01:00
Par_GetParToText ("Surname1",Surname1,
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
2017-01-26 11:08:19 +01:00
Str_ConvertToTitleType (Surname1);
// Surname 1 is mandatory, so avoid overwriting surname 1 with empty string
if (Surname1[0]) // New surname 1 not empty
2017-03-07 19:55:29 +01:00
Str_Copy (UsrDat->Surname1,Surname1,
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
2017-01-26 11:08:19 +01:00
/***** Get surname 2 *****/
2017-03-07 19:55:29 +01:00
Par_GetParToText ("Surname2",UsrDat->Surname2,
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
2014-12-01 23:55:08 +01:00
Str_ConvertToTitleType (UsrDat->Surname2);
2017-01-26 11:08:19 +01:00
/***** Get first name *****/
2017-03-07 19:55:29 +01:00
Par_GetParToText ("FirstName",FirstName,
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
2017-01-26 11:08:19 +01:00
Str_ConvertToTitleType (FirstName);
// First name is mandatory, so avoid overwriting first name with empty string
if (Surname1[0]) // New first name not empty
2017-03-07 19:55:29 +01:00
Str_Copy (UsrDat->FirstName,FirstName,
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
2014-12-01 23:55:08 +01:00
2017-01-26 11:08:19 +01:00
/***** Build full name *****/
2014-12-01 23:55:08 +01:00
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
{
/***** Get sex from form *****/
2017-01-29 21:41:08 +01:00
UsrDat->Sex = (Usr_Sex_t)
Par_GetParToUnsignedLong ("Sex",
(unsigned long) Usr_SEX_FEMALE,
(unsigned long) Usr_SEX_MALE,
(unsigned long) Usr_SEX_UNKNOWN);
2014-12-01 23:55:08 +01:00
/***** Get country code *****/
2017-01-28 20:32:50 +01:00
UsrDat->CtyCod = Par_GetParToLong ("OthCtyCod");
2014-12-01 23:55:08 +01:00
2017-03-08 14:12:33 +01:00
Par_GetParToText ("OriginPlace",UsrDat->OriginPlace,Usr_MAX_BYTES_ADDRESS);
2014-12-01 23:55:08 +01:00
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);
2017-03-08 14:12:33 +01:00
Par_GetParToText ("LocalAddress",UsrDat->LocalAddress,Usr_MAX_BYTES_ADDRESS);
2014-12-01 23:55:08 +01:00
Par_GetParToText ("LocalPhone",UsrDat->LocalPhone,Usr_MAX_BYTES_PHONE);
2017-03-08 14:12:33 +01:00
Par_GetParToText ("FamilyAddress",UsrDat->FamilyAddress,Usr_MAX_BYTES_ADDRESS);
2014-12-01 23:55:08 +01:00
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);
}
/*****************************************************************************/
2018-10-08 12:37:29 +02:00
/**** Show my shared record and a form to edit my institution, centre... *****/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2018-10-09 13:41:55 +02:00
void Rec_ShowMySharedRecordAndMore (void)
2014-12-01 23:55:08 +01:00
{
2018-10-09 22:51:12 +02:00
extern const char *Txt_Please_fill_in_your_record_card_including_your_name;
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_country_nationality;
extern const char *Txt_Please_select_the_country_of_your_institution;
2019-02-18 20:05:07 +01:00
extern const char *Txt_Please_select_your_institution;
extern const char *Txt_Please_select_your_centre;
extern const char *Txt_Please_select_your_department;
2018-10-09 22:51:12 +02:00
bool IAmATeacher;
/***** Get my roles if not yet got *****/
Rol_GetRolesInAllCrssIfNotYetGot (&Gbl.Usrs.Me.UsrDat);
/***** Check if I am a teacher *****/
IAmATeacher = (Gbl.Usrs.Me.UsrDat.Roles.InCrss & ((1 << Rol_NET) | // I am a non-editing teacher...
(1 << Rol_TCH))); // ...or a teacher in any course
/***** If user has no name and surname, sex... *****/
if (!Gbl.Usrs.Me.UsrDat.FirstName[0] ||
!Gbl.Usrs.Me.UsrDat.Surname1[0]) // 1. No name
2019-02-16 18:25:41 +01:00
Ale_ShowAlert (Ale_WARNING,Txt_Please_fill_in_your_record_card_including_your_name);
2018-10-09 22:51:12 +02:00
else if (Gbl.Usrs.Me.UsrDat.Sex == Usr_SEX_UNKNOWN) // 2. No sex
2019-02-16 18:25:41 +01:00
Ale_ShowAlert (Ale_WARNING,Txt_Please_fill_in_your_record_card_including_your_sex);
2018-10-09 22:51:12 +02:00
else if (Gbl.Usrs.Me.UsrDat.CtyCod < 0) // 3. No country
2019-02-16 18:25:41 +01:00
Ale_ShowAlert (Ale_WARNING,Txt_Please_fill_in_your_record_card_including_your_country_nationality);
2018-10-09 22:51:12 +02:00
else if (Gbl.Usrs.Me.UsrDat.InsCtyCod < 0) // 4. No institution country
2019-02-16 18:25:41 +01:00
Ale_ShowAlert (Ale_WARNING,Txt_Please_select_the_country_of_your_institution);
2018-10-09 22:51:12 +02:00
else if (Gbl.Usrs.Me.UsrDat.InsCod < 0) // 5. No institution
2019-02-18 20:05:07 +01:00
Ale_ShowAlert (Ale_WARNING,Txt_Please_select_your_institution);
2018-10-09 22:51:12 +02:00
else if (IAmATeacher)
{
if (Gbl.Usrs.Me.UsrDat.Tch.CtrCod < 0) // 6. No centre
2019-02-18 20:05:07 +01:00
Ale_ShowAlert (Ale_WARNING,Txt_Please_select_your_centre);
2018-10-09 22:51:12 +02:00
else if (Gbl.Usrs.Me.UsrDat.Tch.DptCod < 0) // 7. No deparment
2019-02-18 20:05:07 +01:00
Ale_ShowAlert (Ale_WARNING,Txt_Please_select_your_department);
2018-10-09 22:51:12 +02:00
}
/***** Start container *****/
2018-10-08 18:41:56 +02:00
fprintf (Gbl.F.Out,"<div class=\"REC_USR\">");
2018-10-09 13:00:21 +02:00
/***** Left part *****/
2018-10-08 18:41:56 +02:00
fprintf (Gbl.F.Out,"<div class=\"REC_LEFT\">");
2018-10-09 13:00:21 +02:00
/* My shared record card */
2018-10-09 22:51:12 +02:00
Rec_ShowSharedUsrRecord (Rec_SHA_MY_RECORD_FORM,&Gbl.Usrs.Me.UsrDat,NULL);
2018-10-09 13:00:21 +02:00
2018-10-08 18:41:56 +02:00
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
2018-10-08 18:41:56 +02:00
/***** Right part *****/
/* Start container for right part */
fprintf (Gbl.F.Out,"<div class=\"REC_RIGHT\">");
2018-10-09 22:51:12 +02:00
/* My institution, centre and department */
Rec_ShowFormMyInsCtrDpt (IAmATeacher);
2018-10-08 18:41:56 +02:00
/* My webs / social networks */
Net_ShowFormMyWebsAndSocialNets ();
/* End container for right part */
fprintf (Gbl.F.Out,"</div>");
2018-10-09 22:51:12 +02:00
/***** End container *****/
2018-10-08 18:41:56 +02:00
fprintf (Gbl.F.Out,"</div>");
2018-10-08 12:37:29 +02:00
/***** Data protection clause *****/
Rec_WriteLinkToDataProtectionClause ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********* Show form to edit my institution, centre and department ***********/
/*****************************************************************************/
2018-10-09 22:51:12 +02:00
static void Rec_ShowFormMyInsCtrDpt (bool IAmATeacher)
2014-12-01 23:55:08 +01:00
{
2016-11-13 13:40:52 +01:00
extern const char *Hlp_PROFILE_Institution;
2019-02-22 21:47:50 +01:00
extern const char *The_ClassFormInBox[The_NUM_THEMES];
2014-12-01 23:55:08 +01:00
extern const char *Txt_Institution_centre_and_department;
extern const char *Txt_Institution;
2018-10-08 23:04:05 +02:00
extern const char *Txt_Country;
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_Office;
extern const char *Txt_Phone;
2019-02-22 21:47:50 +01:00
const char *ClassForm = The_ClassFormInBox[Gbl.Prefs.Theme];
2014-12-01 23:55:08 +01:00
unsigned NumCty;
unsigned NumIns;
unsigned NumCtr;
2018-10-08 14:11:21 +02:00
char StrRecordWidth[10 + 1];
2016-12-13 13:32:19 +01:00
2018-10-08 12:37:29 +02:00
/***** Start section *****/
Lay_StartSection (Rec_MY_INS_CTR_DPT_ID);
2017-06-12 14:16:33 +02:00
/***** Start box and table *****/
2018-10-08 14:11:21 +02:00
sprintf (StrRecordWidth,"%upx",Rec_RECORD_WIDTH);
Box_StartBoxTable (StrRecordWidth,
IAmATeacher ? Txt_Institution_centre_and_department :
Txt_Institution,
2017-06-11 22:26:40 +02:00
NULL,
2017-06-12 15:03:29 +02:00
Hlp_PROFILE_Institution,Box_NOT_CLOSABLE,2);
2014-12-01 23:55:08 +01:00
/***** Country *****/
2016-11-14 10:05:41 +01:00
fprintf (Gbl.F.Out,"<tr>"
2018-10-08 14:11:21 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
2018-10-10 08:59:26 +02:00
"<label for=\"OthCtyCod\" class=\"%s\">%s*:</label>"
2015-07-28 00:16:09 +02:00
"</td>"
2018-10-08 14:11:21 +02:00
"<td class=\"REC_C2_BOT LEFT_MIDDLE\">",
2018-10-08 23:04:05 +02:00
ClassForm,Txt_Country);
2014-12-01 23:55:08 +01:00
/* If list of countries is empty, try to get it */
2019-04-04 10:45:15 +02:00
if (!Gbl.Hierarchy.Sys.Ctys.Num)
2014-12-01 23:55:08 +01:00
{
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Sys.Ctys.SelectedOrder = 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 */
2018-11-09 20:47:39 +01:00
Frm_StartFormAnchor (ActChgCtyMyIns,Rec_MY_INS_CTR_DPT_ID);
2016-12-25 21:30:22 +01:00
fprintf (Gbl.F.Out,"<select id=\"OthCtyCod\" name=\"OthCtyCod\""
2018-10-08 14:11:21 +02:00
" class=\"REC_C2_BOT_INPUT\""
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;
2019-04-04 10:45:15 +02:00
NumCty < Gbl.Hierarchy.Sys.Ctys.Num;
2014-12-01 23:55:08 +01:00
NumCty++)
{
fprintf (Gbl.F.Out,"<option value=\"%ld\"",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Sys.Ctys.Lst[NumCty].CtyCod);
if (Gbl.Hierarchy.Sys.Ctys.Lst[NumCty].CtyCod == Gbl.Usrs.Me.UsrDat.InsCtyCod)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Sys.Ctys.Lst[NumCty].Name[Gbl.Prefs.Language]);
2014-12-01 23:55:08 +01:00
}
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</select>");
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Institution *****/
fprintf (Gbl.F.Out,"<tr>"
2018-10-08 14:11:21 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
2018-10-10 08:59:26 +02:00
"<label for=\"OthInsCod\" class=\"%s\">%s*:</label>"
2015-07-28 00:16:09 +02:00
"</td>"
2018-10-08 14:11:21 +02:00
"<td class=\"REC_C2_BOT LEFT_MIDDLE\">",
ClassForm,Txt_Institution);
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 */
2018-11-09 20:47:39 +01:00
Frm_StartFormAnchor (ActChgMyIns,Rec_MY_INS_CTR_DPT_ID);
2016-12-25 21:30:22 +01:00
fprintf (Gbl.F.Out,"<select id=\"OthInsCod\" name=\"OthInsCod\""
2018-10-08 14:11:21 +02:00
" class=\"REC_C2_BOT_INPUT\""
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;
2019-04-04 10:45:15 +02:00
NumIns < Gbl.Hierarchy.Cty.Inss.Num;
2014-12-01 23:55:08 +01:00
NumIns++)
{
fprintf (Gbl.F.Out,"<option value=\"%ld\"",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Cty.Inss.Lst[NumIns].InsCod);
if (Gbl.Hierarchy.Cty.Inss.Lst[NumIns].InsCod == Gbl.Usrs.Me.UsrDat.InsCod)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Cty.Inss.Lst[NumIns].FullName);
2014-12-01 23:55:08 +01:00
}
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</select>");
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
2017-05-31 23:08:19 +02:00
if (IAmATeacher)
2014-12-01 23:55:08 +01:00
{
/***** Centre *****/
fprintf (Gbl.F.Out,"<tr>"
2018-10-08 14:11:21 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
2018-10-10 08:59:26 +02:00
"<label for=\"OthCtrCod\" class=\"%s\">%s*:</label>"
2015-07-28 00:16:09 +02:00
"</td>"
2018-10-08 14:11:21 +02:00
"<td class=\"REC_C2_BOT LEFT_MIDDLE\">",
ClassForm,Txt_Centre);
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 */
2018-11-09 20:47:39 +01:00
Frm_StartFormAnchor (ActChgMyCtr,Rec_MY_INS_CTR_DPT_ID);
2016-12-25 21:30:22 +01:00
fprintf (Gbl.F.Out,"<select id=\"OthCtrCod\" name=\"OthCtrCod\""
2018-10-08 14:11:21 +02:00
" class=\"REC_C2_BOT_INPUT\""
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;
2019-04-04 10:45:15 +02:00
NumCtr < Gbl.Hierarchy.Ins.Ctrs.Num;
2014-12-01 23:55:08 +01:00
NumCtr++)
{
fprintf (Gbl.F.Out,"<option value=\"%ld\"",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Ins.Ctrs.Lst[NumCtr].CtrCod);
if (Gbl.Hierarchy.Ins.Ctrs.Lst[NumCtr].CtrCod == Gbl.Usrs.Me.UsrDat.Tch.CtrCod)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Ins.Ctrs.Lst[NumCtr].FullName);
2014-12-01 23:55:08 +01:00
}
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</select>");
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Department *****/
fprintf (Gbl.F.Out,"<tr>"
2018-10-08 14:11:21 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
2018-10-10 08:59:26 +02:00
"<label for=\"%s\" class=\"%s\">%s*:</label>"
2015-07-28 00:16:09 +02:00
"</td>"
2018-10-08 14:11:21 +02:00
"<td class=\"REC_C2_BOT LEFT_MIDDLE\">",
Dpt_PARAM_DPT_COD_NAME,ClassForm,Txt_Department);
2018-11-09 20:47:39 +01:00
Frm_StartFormAnchor (ActChgMyDpt,Rec_MY_INS_CTR_DPT_ID);
2017-10-10 10:46:35 +02:00
Dpt_WriteSelectorDepartment (Gbl.Usrs.Me.UsrDat.InsCod, // Departments in my institution
Gbl.Usrs.Me.UsrDat.Tch.DptCod, // Selected department
2018-10-08 14:11:21 +02:00
"REC_C2_BOT_INPUT", // Selector class
2017-10-10 10:46:35 +02:00
-1L, // First option
"", // Text when no department selected
true); // Submit on change
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Office *****/
fprintf (Gbl.F.Out,"<tr>"
2018-10-08 14:11:21 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
2016-12-25 20:51:53 +01:00
"<label for=\"Office\" class=\"%s\">"
2015-07-28 00:16:09 +02:00
"%s:"
2016-12-25 20:51:53 +01:00
"</label>"
2015-07-28 00:16:09 +02:00
"</td>"
2018-10-08 14:11:21 +02:00
"<td class=\"REC_C2_BOT LEFT_MIDDLE\">",
ClassForm,Txt_Office);
2018-11-09 20:47:39 +01:00
Frm_StartFormAnchor (ActChgMyOff,Rec_MY_INS_CTR_DPT_ID);
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"text\" id=\"Office\" name=\"Office\""
2015-09-23 14:31:47 +02:00
" maxlength=\"%u\" value=\"%s\""
2018-10-08 14:11:21 +02:00
" class=\"REC_C2_BOT_INPUT\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\" />",
2017-03-08 14:12:33 +01:00
Usr_MAX_CHARS_ADDRESS,
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Me.UsrDat.Tch.Office,
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
/***** Phone *****/
fprintf (Gbl.F.Out,"<tr>"
2018-10-08 14:11:21 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
2016-12-25 20:51:53 +01:00
"<label for=\"OfficePhone\" class=\"%s\">"
2015-07-28 00:16:09 +02:00
"%s:"
2016-12-25 20:51:53 +01:00
"</label>"
2015-07-28 00:16:09 +02:00
"</td>"
2018-10-08 14:11:21 +02:00
"<td class=\"REC_C2_BOT LEFT_MIDDLE\">",
ClassForm,Txt_Phone);
2018-11-09 20:47:39 +01:00
Frm_StartFormAnchor (ActChgMyOffPho,Rec_MY_INS_CTR_DPT_ID);
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"tel\""
" id=\"OfficePhone\" name=\"OfficePhone\""
2015-09-06 19:51:06 +02:00
" maxlength=\"%u\" value=\"%s\""
2018-10-08 14:11:21 +02:00
" class=\"REC_C2_BOT_INPUT\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\" />",
2017-03-08 01:21:21 +01:00
Usr_MAX_CHARS_PHONE,
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Me.UsrDat.Tch.OfficePhone,
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
}
2017-06-12 14:16:33 +02:00
/***** End table and box *****/
2017-06-10 21:38:10 +02:00
Box_EndBoxTable ();
2018-10-08 12:37:29 +02:00
/***** End section *****/
Lay_EndSection ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******** Receive form data to change the country of my institution **********/
/*****************************************************************************/
void Rec_ChgCountryOfMyInstitution (void)
{
2017-05-31 22:51:40 +02:00
unsigned NumInss;
2016-10-23 19:40:14 +02:00
/***** Get country code of my institution *****/
2017-05-31 21:05:59 +02:00
Gbl.Usrs.Me.UsrDat.InsCtyCod = Cty_GetAndCheckParamOtherCtyCod (0);
2014-12-01 23:55:08 +01:00
2017-05-31 22:51:40 +02:00
/***** When country changes, the institution, centre and department must be reset *****/
NumInss = Ins_GetNumInssInCty (Gbl.Usrs.Me.UsrDat.InsCtyCod);
if (NumInss)
{
Gbl.Usrs.Me.UsrDat.InsCod = -1L;
Gbl.Usrs.Me.UsrDat.Tch.CtrCod = -1L;
Gbl.Usrs.Me.UsrDat.Tch.DptCod = -1L;
}
else // Country has no institutions
{
Gbl.Usrs.Me.UsrDat.InsCod = 0; // Another institution
Gbl.Usrs.Me.UsrDat.Tch.CtrCod = 0; // Another centre
Gbl.Usrs.Me.UsrDat.Tch.DptCod = 0; // Another department
}
2014-12-01 23:55:08 +01:00
/***** Update institution, centre and department *****/
2014-12-12 18:50:36 +01:00
Enr_UpdateInstitutionCentreDepartment ();
2014-12-01 23:55:08 +01:00
/***** Show form again *****/
2018-10-09 13:41:55 +02:00
Rec_ShowMySharedRecordAndMore ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/**************** Receive form data to change my institution *****************/
/*****************************************************************************/
void Rec_UpdateMyInstitution (void)
{
2016-10-28 10:03:37 +02:00
struct Instit Ins;
2017-05-31 22:51:40 +02:00
unsigned NumCtrs;
unsigned NumDpts;
2014-12-01 23:55:08 +01:00
/***** Get my institution *****/
/* Get institution code */
2017-05-31 21:05:59 +02:00
Ins.InsCod = Ins_GetAndCheckParamOtherInsCod (0); // 0 (another institution) is allowed here
2014-12-01 23:55:08 +01:00
/* Get country of institution */
2016-10-23 19:40:14 +02:00
if (Ins.InsCod > 0)
{
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
if (Gbl.Usrs.Me.UsrDat.InsCtyCod != Ins.CtyCod)
Gbl.Usrs.Me.UsrDat.InsCtyCod = Ins.CtyCod;
}
2014-12-01 23:55:08 +01:00
2017-05-31 22:51:40 +02:00
/* Set institution code */
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Me.UsrDat.InsCod = Ins.InsCod;
2017-05-31 22:51:40 +02:00
/***** When institution changes, the centre and department must be reset *****/
NumCtrs = Ctr_GetNumCtrsInIns (Gbl.Usrs.Me.UsrDat.InsCod);
NumDpts = Dpt_GetNumDptsInIns (Gbl.Usrs.Me.UsrDat.InsCod);
Gbl.Usrs.Me.UsrDat.Tch.CtrCod = (NumCtrs ? -1L : 0);
Gbl.Usrs.Me.UsrDat.Tch.DptCod = (NumDpts ? -1L : 0);
/***** Update institution, centre and department *****/
2014-12-12 18:50:36 +01:00
Enr_UpdateInstitutionCentreDepartment ();
2014-12-01 23:55:08 +01:00
/***** Show form again *****/
2018-10-09 13:41:55 +02:00
Rec_ShowMySharedRecordAndMore ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************* Receive form data to change my centre *******************/
/*****************************************************************************/
void Rec_UpdateMyCentre (void)
{
struct Centre Ctr;
/***** Get my centre *****/
/* Get centre code */
2017-05-31 21:05:59 +02:00
Ctr.CtrCod = Ctr_GetAndCheckParamOtherCtrCod (0); // 0 (another centre) is allowed here
2014-12-01 23:55:08 +01:00
/* Get institution of centre */
2016-10-23 19:40:14 +02:00
if (Ctr.CtrCod > 0)
2014-12-01 23:55:08 +01:00
{
2016-10-23 19:40:14 +02:00
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;
}
2014-12-01 23:55:08 +01:00
}
2017-05-31 22:51:40 +02:00
/* Set centre code */
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Me.UsrDat.Tch.CtrCod = Ctr.CtrCod;
2017-05-31 22:51:40 +02:00
/***** Update institution, centre and department *****/
2014-12-12 18:50:36 +01:00
Enr_UpdateInstitutionCentreDepartment ();
2014-12-01 23:55:08 +01:00
/***** Show form again *****/
2018-10-09 13:41:55 +02:00
Rec_ShowMySharedRecordAndMore ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/***************** Receive form data to change my department *****************/
/*****************************************************************************/
void Rec_UpdateMyDepartment (void)
{
struct Department Dpt;
/***** Get my department *****/
/* Get department code */
2017-05-31 21:05:59 +02:00
Dpt.DptCod = Dpt_GetAndCheckParamDptCod (0); // 0 (another department) is allowed here
2014-12-01 23:55:08 +01:00
/* Get institution of department */
2016-10-23 19:40:14 +02:00
if (Dpt.DptCod > 0)
2014-12-01 23:55:08 +01:00
{
2016-10-23 19:40:14 +02:00
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;
}
2014-12-01 23:55:08 +01:00
}
/***** 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 *****/
2018-10-09 13:41:55 +02:00
Rec_ShowMySharedRecordAndMore ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************* Receive form data to change my office *******************/
/*****************************************************************************/
void Rec_UpdateMyOffice (void)
{
/***** Get my office *****/
2017-03-08 14:12:33 +01:00
Par_GetParToText ("Office",Gbl.Usrs.Me.UsrDat.Tch.Office,Usr_MAX_BYTES_ADDRESS);
2014-12-01 23:55:08 +01:00
/***** Update office *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not update office",
"UPDATE usr_data SET Office='%s' WHERE UsrCod=%ld",
Gbl.Usrs.Me.UsrDat.Tch.Office,
Gbl.Usrs.Me.UsrDat.UsrCod);
2014-12-01 23:55:08 +01:00
/***** Show form again *****/
2018-10-09 13:41:55 +02:00
Rec_ShowMySharedRecordAndMore ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/**************** Receive form data to change my office phone ****************/
/*****************************************************************************/
void Rec_UpdateMyOfficePhone (void)
{
/***** Get my office *****/
Par_GetParToText ("OfficePhone",Gbl.Usrs.Me.UsrDat.Tch.OfficePhone,Usr_MAX_BYTES_PHONE);
/***** Update office phone *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not update office phone",
"UPDATE usr_data SET OfficePhone='%s' WHERE UsrCod=%ld",
Gbl.Usrs.Me.UsrDat.Tch.OfficePhone,
Gbl.Usrs.Me.UsrDat.UsrCod);
2014-12-01 23:55:08 +01:00
/***** Show form again *****/
2018-10-09 13:41:55 +02:00
Rec_ShowMySharedRecordAndMore ();
2014-12-01 23:55:08 +01:00
}