"
""
"%u"
" | ",
NumRequests - NumReq);
/***** Link to course *****/
Crs_GetDataOfCourseByCod (&Crs);
Deg.DegCod = Crs.DegCod;
Deg_GetDataOfDegreeByCod (&Deg);
fprintf (Gbl.F.Out,"");
Act_FormGoToStart (ActSeeCrsInf);
Crs_PutParamCrsCod (Crs.CrsCod);
sprintf (Gbl.Title,Txt_Go_to_X,Crs.FullName);
Act_LinkFormSubmit (Gbl.Title,"DAT");
fprintf (Gbl.F.Out,"%s > %s"
"",
Deg.ShortName,Crs.ShortName);
Act_FormEnd ();
fprintf (Gbl.F.Out," | ");
/***** Number of teachers in the course *****/
fprintf (Gbl.F.Out,""
"%u"
" | ",
Crs.NumTchs);
/***** User photo *****/
fprintf (Gbl.F.Out,"");
ShowPhoto = Pho_ShowUsrPhotoIsAllowed (&UsrDat,PhotoURL);
Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL :
NULL,
"PHOTO18x24",Pho_ZOOM);
fprintf (Gbl.F.Out," | ");
/***** User name *****/
fprintf (Gbl.F.Out,"");
Usr_RestrictLengthAndWriteName (&UsrDat,20);
/***** Requested role (row[3]) *****/
DesiredRole = Rol_ConvertUnsignedStrToRole (row[3]);
fprintf (Gbl.F.Out," | "
"%s"
" | ",
Txt_ROLES_SINGUL_abc[DesiredRole][UsrDat.Sex]);
/***** Request time (row[4]) *****/
Msg_WriteMsgDate (row[4],"DAT");
/***** Button to confirm the request *****/
fprintf (Gbl.F.Out,"");
Act_FormStart (ActReqMdfUsr);
Crs_PutParamCrsCod (Crs.CrsCod);
Usr_PutParamUsrCodEncrypted (UsrDat.EncryptedUsrCod);
Lay_PutCreateButton (Txt_Register);
Act_FormEnd ();
fprintf (Gbl.F.Out," | ");
/***** Button to reject the request *****/
fprintf (Gbl.F.Out,"");
Act_FormStart (ActReqRejSignUp);
Crs_PutParamCrsCod (Crs.CrsCod);
Usr_PutParamUsrCodEncrypted (UsrDat.EncryptedUsrCod);
Lay_PutConfirmButton (Txt_Reject);
Act_FormEnd ();
fprintf (Gbl.F.Out," | "
"
");
/***** Mark possible notification as seen *****/
Ntf_SetNotifAsSeen (Ntf_EVENT_ENROLLMENT_REQUEST,
ReqCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
}
else // User does not exists or user already belongs to course ==> remove pair from crs_usr_requests table
Enr_RemoveEnrollmentRequest (Crs.CrsCod,UsrDat.UsrCod);
}
/* End of table */
Lay_EndRoundFrameTable10 ();
/* Free memory used for user's data */
Usr_UsrDataDestructor (&UsrDat);
}
else // There are no requests
Lay_ShowAlert (Lay_INFO,Txt_No_enrollment_requests);
}
/*****************************************************************************/
/******************** Remove a request for inscription ***********************/
/*****************************************************************************/
static void Enr_RemoveEnrollmentRequest (long CrsCod,long UsrCod)
{
char Query[256];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
long ReqCod;
/***** Mark possible notifications as removed
Important: do this before removing the request *****/
/* Request request code (returns 0 or 1 rows) */
sprintf (Query,"SELECT ReqCod FROM crs_usr_requests"
" WHERE CrsCod='%ld' AND UsrCod='%ld'",
CrsCod,UsrCod);
if (DB_QuerySELECT (Query,&mysql_res,"can not get request code")) // Request exists
{
/* Get request code */
row = mysql_fetch_row (mysql_res);
ReqCod = Str_ConvertStrCodToLongCod (row[0]);
/* Mark possible notifications as removed */
Ntf_SetNotifAsRemoved (Ntf_EVENT_ENROLLMENT_REQUEST,ReqCod);
}
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res);
/***** Remove enrollment request *****/
sprintf (Query,"DELETE FROM crs_usr_requests"
" WHERE CrsCod='%ld' AND UsrCod='%ld'",
CrsCod,UsrCod);
DB_QueryDELETE (Query,"can not remove a request for enrollment");
}
/*****************************************************************************/
/********************** Write a form to admin one user ***********************/
/*****************************************************************************/
static void Enr_PutLinkToAdminOneUsr (void)
{
extern const char *Txt_Admin_one_user;
Act_PutContextualLink (ActReqMdfOneUsr,NULL,
"configtest",Txt_Admin_one_user);
}
/*****************************************************************************/
/******************* Write a form to admin several users *********************/
/*****************************************************************************/
static void Enr_PutLinkToAdminSeveralUsrs (void)
{
extern const char *Txt_Admin_several_users;
Act_PutContextualLink (ActReqMdfSevUsr,NULL,
"configtest",Txt_Admin_several_users);
}
/*****************************************************************************/
/************** Form to request the user's ID of another user ****************/
/*****************************************************************************/
void Enr_ReqRegRemUsr (void)
{
extern const char *Txt_You_dont_have_permission_to_perform_this_action;
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol__GUEST_:
case Rol_VISITOR:
case Rol_STUDENT:
Enr_AskIfRegRemMe ();
break;
case Rol_TEACHER:
if (Gbl.CurrentCrs.Crs.CrsCod > 0)
Enr_ReqAnotherUsrIDToRegisterRemove ();
else
Enr_AskIfRegRemMe ();
break;
case Rol_DEG_ADM:
if (Gbl.CurrentDeg.Deg.DegCod > 0)
Enr_ReqAnotherUsrIDToRegisterRemove ();
else
Enr_AskIfRegRemMe ();
break;
case Rol_CTR_ADM:
if (Gbl.CurrentCtr.Ctr.CtrCod > 0)
Enr_ReqAnotherUsrIDToRegisterRemove ();
else
Enr_AskIfRegRemMe ();
break;
case Rol_INS_ADM:
if (Gbl.CurrentIns.Ins.InsCod > 0)
Enr_ReqAnotherUsrIDToRegisterRemove ();
else
Enr_AskIfRegRemMe ();
break;
case Rol_SYS_ADM:
Enr_ReqAnotherUsrIDToRegisterRemove ();
break;
default:
Lay_ShowAlert (Lay_ERROR,Txt_You_dont_have_permission_to_perform_this_action);
break;
}
}
/*****************************************************************************/
/****** Write a form to request another user's ID, @nickname or e-mail *******/
/*****************************************************************************/
static void Enr_ReqAnotherUsrIDToRegisterRemove (void)
{
extern const char *Txt_Admin_one_user;
/***** Put contextual links *****/
if (Gbl.CurrentCrs.Crs.CrsCod > 0 ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
{
fprintf (Gbl.F.Out,"");
}
/***** Start frame *****/
Lay_StartRoundFrameTable10 (NULL,2,Txt_Admin_one_user);
fprintf (Gbl.F.Out,"");
Act_FormStart (ActRemUsrCrs);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Pwd_AskForConfirmationOnDangerousAction ();
Lay_PutRemoveButton (ItsMe ? Txt_Remove_me_from_this_course :
Txt_Remove_user_from_this_course);
Act_FormEnd ();
fprintf (Gbl.F.Out,"
");
}
else
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
}
/*****************************************************************************/
/************************ Remove a user from a course ************************/
/*****************************************************************************/
static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,struct Course *Crs,
Enr_RemoveUsrWorks_t RemoveUsrWorks,Cns_QuietOrVerbose_t QuietOrVerbose)
{
extern const char *Txt_THE_USER_X_has_been_removed_from_the_course_Y;
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
char Query[1024];
if (Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod,Crs->CrsCod)) // User belongs to the course
{
/***** Remove user from all the attendance events in course *****/
Att_RemoveUsrFromCrsAttEvents (UsrDat->UsrCod,Crs->CrsCod);
/***** Remove user from all the groups in course *****/
Grp_RemUsrFromAllGrpsInCrs (UsrDat,Crs,QuietOrVerbose);
/***** Remove user's status about reading of course information *****/
Inf_RemoveUsrFromCrsInfoRead (UsrDat->UsrCod,Crs->CrsCod);
/***** Remove works zone of this user in course *****/
if (RemoveUsrWorks == Enr_REMOVE_WORKS)
Brw_RemoveUsrWorksInCrs (UsrDat,Crs,QuietOrVerbose);
/***** Remove fields of this user in its course record *****/
Rec_RemoveFieldsCrsRecordInCrs (UsrDat->UsrCod,Crs,QuietOrVerbose);
/***** Remove some information about files in course and groups *****/
Brw_RemoveSomeInfoAboutCrsUsrFilesFromDB (UsrDat->UsrCod,Crs->CrsCod);
/***** Remove exams made by user in course *****/
Tst_RemoveExamsMadeByUsrInCrs (UsrDat->UsrCod,Crs->CrsCod);
/***** Set all the notifications for this user in this course as removed,
except notifications about new messages *****/
Ntf_SetNotifInCrsAsRemoved (Crs->CrsCod,UsrDat->UsrCod);
/***** Remove user from the table of courses-users *****/
sprintf (Query,"DELETE FROM crs_usr"
" WHERE CrsCod='%ld' AND UsrCod='%ld'",
Crs->CrsCod,UsrDat->UsrCod);
DB_QueryDELETE (Query,"can not remove a user from a course");
if (QuietOrVerbose == Cns_VERBOSE)
{
sprintf (Gbl.Message,Txt_THE_USER_X_has_been_removed_from_the_course_Y,
UsrDat->FullName,Crs->FullName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
}
}
else // User does not belong to course
if (QuietOrVerbose == Cns_VERBOSE)
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
}
/*****************************************************************************/
/** Ask if really wanted to remove an administrator from current institution */
/*****************************************************************************/
static void Enr_AskIfRemAdm (bool ItsMe,Sco_Scope_t Scope,const char *InsCtrDegName)
{
extern const char *Txt_Do_you_really_want_to_be_removed_as_an_administrator_of_X;
extern const char *Txt_Do_you_really_want_to_remove_the_following_user_as_an_administrator_of_X;
extern const char *Txt_Remove_me_as_an_administrator;
extern const char *Txt_Remove_user_as_an_administrator;
static const Act_Action_t Enr_ActRemAdm[Sco_NUM_SCOPES] =
{
ActUnk, // Sco_SCOPE_UNK
ActUnk, // Sco_SCOPE_SYS,
ActUnk, // Sco_SCOPE_CTY,
ActRemAdmIns, // Sco_SCOPE_INS,
ActRemAdmCtr, // Sco_SCOPE_CTR,
ActRemAdmDeg, // Sco_SCOPE_DEG,
ActUnk, // Sco_SCOPE_CRS,
};
if (Usr_ChkIfUsrCodExists (Gbl.Usrs.Other.UsrDat.UsrCod))
{
sprintf (Gbl.Message,
ItsMe ? Txt_Do_you_really_want_to_be_removed_as_an_administrator_of_X :
Txt_Do_you_really_want_to_remove_the_following_user_as_an_administrator_of_X,
InsCtrDegName);
Lay_ShowAlert (Lay_INFO,Gbl.Message);
Rec_ShowCommonRecordUnmodifiable (&Gbl.Usrs.Other.UsrDat);
Act_FormStart (Enr_ActRemAdm[Scope]);
Usr_PutParamOtherUsrCodEncrypted ();
Lay_PutRemoveButton (ItsMe ? Txt_Remove_me_as_an_administrator :
Txt_Remove_user_as_an_administrator);
Act_FormEnd ();
}
else
Lay_ShowErrorAndExit ("User doesn't exist.");
}
/*****************************************************************************/
/**** Remove an administrator from current institution, centre or degree *****/
/*****************************************************************************/
static void Enr_EffectivelyRemAdm (struct UsrData *UsrDat,Sco_Scope_t Scope,
long Cod,const char *InsCtrDegName)
{
extern const char *Sco_ScopeAdminDB[Sco_NUM_SCOPES];
extern const char *Txt_THE_USER_X_has_been_removed_as_administrator_of_Y;
extern const char *Txt_THE_USER_X_is_not_an_administrator_of_Y;
char Query[1024];
if (Usr_CheckIfUsrIsAdm (UsrDat->UsrCod,Scope,Cod)) // User is administrator of current institution/centre/degree
{
/***** Remove user from the table of admins *****/
sprintf (Query,"DELETE FROM admin"
" WHERE UsrCod='%ld' AND Scope='%s' AND Cod='%ld'",
UsrDat->UsrCod,Sco_ScopeAdminDB[Scope],Cod);
DB_QueryDELETE (Query,"can not remove an administrator");
sprintf (Gbl.Message,Txt_THE_USER_X_has_been_removed_as_administrator_of_Y,
UsrDat->FullName,InsCtrDegName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
}
else // User is not an administrator of the current institution/centre/degree
{
sprintf (Gbl.Message,Txt_THE_USER_X_is_not_an_administrator_of_Y,
UsrDat->FullName,InsCtrDegName);
Lay_ShowAlert (Lay_ERROR,Gbl.Message);
}
}