Version 18.3.9

This commit is contained in:
Antonio Cañas Vargas 2018-10-10 23:56:42 +02:00
parent 43f6a24a45
commit 8f0f23c30c
29 changed files with 215 additions and 151 deletions

View File

@ -401,7 +401,7 @@ void ID_WriteUsrIDs (struct UsrData *UsrDat,const char *Anchor)
bool ID_ICanSeeOtherUsrIDs (const struct UsrData *UsrDat)
{
bool ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
if (ItsMe)
return true;
@ -505,7 +505,7 @@ void ID_PutLinkToChangeUsrIDs (void)
{
extern const char *Txt_Change_IDs;
Act_Action_t NextAction;
bool ItsMe = (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
/***** Link for changing the password *****/
if (ItsMe)
@ -561,7 +561,7 @@ void ID_ShowFormOthIDs (void)
/***** Form with the user's ID *****/
Tbl_StartTableWide (2);
ItsMe = (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
ID_ShowFormChangeUsrID (&Gbl.Usrs.Other.UsrDat,ItsMe);
Tbl_EndTable ();
@ -750,7 +750,7 @@ void ID_RemoveOtherUsrID (void)
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
{
/***** Remove user's ID *****/
ItsMe = (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
ID_RemoveUsrID (&Gbl.Usrs.Other.UsrDat,ItsMe);
/***** Update list of IDs *****/
@ -868,7 +868,7 @@ void ID_NewOtherUsrID (void)
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
{
/***** New user's ID *****/
ItsMe = (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
ID_NewUsrID (&Gbl.Usrs.Other.UsrDat,ItsMe);
/***** Update list of IDs *****/
@ -999,6 +999,7 @@ void ID_ConfirmOtherUsrID (void)
long OriginalActCod;
char UsrID[ID_MAX_BYTES_USR_ID + 1];
bool ICanConfirm;
bool ItsMe;
bool Found;
unsigned NumID;
unsigned NumIDFound = 0; // Initialized to avoid warning
@ -1013,9 +1014,12 @@ void ID_ConfirmOtherUsrID (void)
/***** Get other user's code from form and get user's data *****/
ICanConfirm = false;
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
if (Gbl.Usrs.Other.UsrDat.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // Not me
{
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
if (!ItsMe) // Not me
if (ID_ICanSeeOtherUsrIDs (&Gbl.Usrs.Other.UsrDat))
ICanConfirm = true;
}
if (ICanConfirm)
{

View File

@ -900,7 +900,7 @@ void Acc_GetUsrCodAndRemUsrGbl (void)
void Acc_ReqRemAccountOrRemAccount (Acc_ReqOrRemUsr_t RequestOrRemove)
{
bool ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
switch (RequestOrRemove)
{
@ -927,8 +927,7 @@ void Acc_ReqRemAccountOrRemAccount (Acc_ReqOrRemUsr_t RequestOrRemove)
bool Acc_CheckIfICanEliminateAccount (long UsrCod)
{
bool ItsMe = (Gbl.Usrs.Me.Logged &&
UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (UsrCod);
// A user logged as superuser can eliminate any user except her/him
// Other users only can eliminate themselves
@ -936,7 +935,7 @@ bool Acc_CheckIfICanEliminateAccount (long UsrCod)
(Gbl.Usrs.Me.Role.Available & (1 << Rol_SYS_ADM)) == 0) // I can not be system admin
||
(!ItsMe && // It's not me
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)); // I am logged as system admin
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)); // I am logged as system admin
}
/*****************************************************************************/

View File

@ -365,7 +365,7 @@ void Agd_ShowUsrAgenda (void)
/***** Start box *****/
sprintf (Gbl.Title,Txt_Public_agenda_USER,Gbl.Usrs.Other.UsrDat.FullName);
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
Box_StartBox ("100%",Gbl.Title,
ItsMe ? Agd_PutIconsMyPublicAgenda :
Agd_PutIconsOtherPublicAgenda,
@ -408,7 +408,7 @@ void Agd_ShowOtherAgendaAfterLogIn (void)
{
/***** Start box *****/
sprintf (Gbl.Title,Txt_Public_agenda_USER,Gbl.Usrs.Other.UsrDat.FullName);
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
Box_StartBox ("100%",Gbl.Title,
ItsMe ? Agd_PutIconToViewEditMyFullAgenda :
Agd_PutIconsOtherPublicAgenda,

View File

@ -2037,6 +2037,7 @@ static void Att_WriteRowStdToCallTheRoll (unsigned NumStd,
bool ShowPhoto;
char CommentStd[Cns_MAX_BYTES_TEXT + 1];
char CommentTch[Cns_MAX_BYTES_TEXT + 1];
bool ItsMe;
bool ICanChangeStdAttendance;
bool ICanEditStdComment;
bool ICanEditTchComment;
@ -2046,7 +2047,8 @@ static void Att_WriteRowStdToCallTheRoll (unsigned NumStd,
{
case Rol_STD:
// A student can see only her/his attendance
if (UsrDat->UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod)
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
if (!ItsMe)
Lay_ShowErrorAndExit ("Wrong call.");
ICanChangeStdAttendance = false;
ICanEditStdComment = Att->Open; // Attendance event is open
@ -2253,7 +2255,8 @@ void Att_RegisterMeAsStdInAttEvent (void)
if (Att.Open)
{
/***** Get comments for this student *****/
Present = Att_CheckIfUsrIsPresentInAttEventAndGetComments (Att.AttCod,Gbl.Usrs.Me.UsrDat.UsrCod,CommentStd,CommentTch);
Present = Att_CheckIfUsrIsPresentInAttEventAndGetComments (Att.AttCod,Gbl.Usrs.Me.UsrDat.UsrCod,
CommentStd,CommentTch);
sprintf (CommentParamName,"CommentStd%ld",Gbl.Usrs.Me.UsrDat.UsrCod);
Par_GetParToHTML (CommentParamName,CommentStd,Cns_MAX_BYTES_TEXT);

View File

@ -355,10 +355,11 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 18.3.8 (2018-10-10)"
#define Log_PLATFORM_VERSION "SWAD 18.3.9 (2018-10-11)"
#define CSS_FILE "swad18.3.css"
#define JS_FILE "swad17.17.1.js"
/*
Version 18.3.9: Oct 11, 2018 Code refactoring related with checking if I am the logged user. (235046 lines)
Version 18.3.8: Oct 10, 2018 Code refactoring related with checking if I am the logged user. (234984 lines)
Version 18.3.7: Oct 10, 2018 Fixed bug in icon in breadcrumb to go to user's courses. (234947 lines)
Version 18.3.6: Oct 09, 2018 Change in layout of user's record card. (234937 lines)

View File

@ -961,14 +961,13 @@ static void Con_WriteRowConnectedUsrOnRightColumn (Rol_Role_t Role)
const char *Font = (Gbl.Usrs.Connected.Lst[Gbl.Usrs.Connected.NumUsr].ThisCrs ? "CON_CRS" :
"CON_NO_CRS");
long UsrCod;
struct UsrData OtherUsrDat;
struct UsrData *UsrDat;
bool ItsMe;
struct UsrData *UsrDat;
struct UsrData OtherUsrDat;
/***** Get user's code from list *****/
UsrCod = Gbl.Usrs.Connected.Lst[Gbl.Usrs.Connected.NumUsr].UsrCod;
ItsMe = (Gbl.Usrs.Me.Logged &&
UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod); // It's me
ItsMe = Usr_ItsMe (UsrCod);
if (ItsMe)
UsrDat = &Gbl.Usrs.Me.UsrDat;

View File

@ -86,7 +86,7 @@ void Dup_ReportUsrAsPossibleDuplicate (void)
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
{
/* Check if it's allowed to me to report users as possible duplicatedr */
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
if (!ItsMe && Gbl.Usrs.Me.Role.Logged >= Rol_TCH)
{
/***** Insert possible duplicate into database *****/

View File

@ -151,7 +151,8 @@ static void Enr_AskIfRemoveUsrFromCrs (struct UsrData *UsrDat);
static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,struct Course *Crs,
Enr_RemoveUsrWorks_t RemoveUsrWorks,Cns_QuietOrVerbose_t QuietOrVerbose);
static void Enr_AskIfRemAdm (bool ItsMe,Sco_Scope_t Scope,const char *InsCtrDegName);
static void Enr_AskIfRemAdm (bool ItsMe,Sco_Scope_t Scope,
const char *InsCtrDegName);
static void Enr_EffectivelyRemAdm (struct UsrData *UsrDat,Sco_Scope_t Scope,
long Cod,const char *InsCtrDegName);
@ -308,6 +309,7 @@ static void Enr_NotifyAfterEnrolment (struct UsrData *UsrDat,Rol_Role_t NewRole)
bool CreateNotif;
bool NotifyByEmail;
Ntf_NotifyEvent_t NotifyEvent;
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
/***** Check if user's role is allowed *****/
switch (NewRole)
@ -336,8 +338,7 @@ static void Enr_NotifyAfterEnrolment (struct UsrData *UsrDat,Rol_Role_t NewRole)
/***** Create new notification ******/
CreateNotif = (UsrDat->Prefs.NotifNtfEvents & (1 << NotifyEvent));
NotifyByEmail = CreateNotif &&
(UsrDat->UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) &&
NotifyByEmail = CreateNotif && !ItsMe &&
(UsrDat->Prefs.EmailNtfEvents & (1 << NotifyEvent));
if (CreateNotif)
Ntf_StoreNotifyEventToOneUser (NotifyEvent,UsrDat,-1L,
@ -3527,7 +3528,7 @@ static bool Enr_CheckIfICanRemUsrFromCrs (void)
{
case Rol_STD:
case Rol_NET:
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
return ItsMe; // A student or non-editing teacher can remove herself/himself
case Rol_TCH:
case Rol_DEG_ADM:
@ -3619,7 +3620,7 @@ static void Enr_ReqRemOrRemAdm (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr,Sco_Scope_t
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
{
/* Check if it's forbidden to remove an administrator */
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
ICanRemove = (ItsMe ||
(Scope == Sco_SCOPE_DEG && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) ||
(Scope == Sco_SCOPE_CTR && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) ||
@ -3878,7 +3879,7 @@ void Enr_ModifyUsr1 (void)
/***** Get user from form *****/
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
{
ItsMe = (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
/***** Get the action to do *****/
Gbl.Usrs.RegRemAction = (Enr_RegRemOneUsrAction_t)
@ -4103,7 +4104,7 @@ static void Enr_AskIfRemoveUsrFromCrs (struct UsrData *UsrDat)
if (Usr_CheckIfUsrBelongsToCurrentCrs (UsrDat))
{
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
/***** Show question and button to remove user as administrator *****/
/* Start alert */
@ -4157,7 +4158,7 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,struct Course *
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];
bool ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
if (Usr_CheckIfUsrBelongsToCurrentCrs (UsrDat))
{
@ -4242,7 +4243,8 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,struct Course *
/** Ask if really wanted to remove an administrator from current institution */
/*****************************************************************************/
static void Enr_AskIfRemAdm (bool ItsMe,Sco_Scope_t Scope,const char *InsCtrDegName)
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;

View File

@ -7223,7 +7223,8 @@ void Brw_RemSubtreeInFileBrowser (void)
Brw_RemoveChildrenOfFolderFromDB (Gbl.FileBrowser.Priv.FullPathInTree);
/* Remove affected clipboards */
Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type,Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Other.UsrDat.UsrCod);
Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type,
Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Other.UsrDat.UsrCod);
/* Remove affected expanded folders */
Brw_RemoveAffectedExpandedFolders (Gbl.FileBrowser.Priv.FullPathInTree);
@ -8266,7 +8267,8 @@ void Brw_PasteIntoFileBrowser (void)
Brw_PasteClipboard ();
/***** Remove the affected clipboards *****/
Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type,Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Other.UsrDat.UsrCod);
Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type,
Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Other.UsrDat.UsrCod);
}
else
/***** Write message ******/
@ -9085,7 +9087,9 @@ void Brw_RecFolderFileBrowser (void)
else
{
/* Remove affected clipboards */
Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type,Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Other.UsrDat.UsrCod);
Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type,
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Other.UsrDat.UsrCod);
/* Add path where new file is created to table of expanded folders */
Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (Gbl.FileBrowser.Priv.FullPathInTree);
@ -9397,7 +9401,9 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType)
else
{
/* Remove affected clipboards */
Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type,Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Other.UsrDat.UsrCod);
Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type,
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Other.UsrDat.UsrCod);
/* Add path where new file is created to table of expanded folders */
Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (Gbl.FileBrowser.Priv.FullPathInTree);
@ -9581,7 +9587,9 @@ void Brw_RecLinkFileBrowser (void)
else
{
/* Remove affected clipboards */
Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type,Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Other.UsrDat.UsrCod);
Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type,
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Other.UsrDat.UsrCod);
/* Add path where new file is created to table of expanded folders */
Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (Gbl.FileBrowser.Priv.FullPathInTree);
@ -9744,7 +9752,9 @@ void Brw_SetDocumentAsVisible (void)
Brw_ChangeFileOrFolderHiddenInDB (Gbl.FileBrowser.Priv.FullPathInTree,false);
/***** Remove the affected clipboards *****/
Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type,Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Other.UsrDat.UsrCod);
Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type,
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Other.UsrDat.UsrCod);
/***** Write message of confirmation *****/
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.Type,
@ -9779,7 +9789,9 @@ void Brw_SetDocumentAsHidden (void)
Brw_ChangeFileOrFolderHiddenInDB (Gbl.FileBrowser.Priv.FullPathInTree,true);
/***** Remove the affected clipboards *****/
Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type,Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Other.UsrDat.UsrCod);
Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type,
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Other.UsrDat.UsrCod);
/***** Write confirmation message *****/
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.Type,

View File

@ -496,7 +496,7 @@ void Fol_ShowFollowingAndFollowers (const struct UsrData *UsrDat,
extern const char *Txt_Following_unfollow;
extern const char *Txt_Unfollow;
extern const char *Txt_Follow;
bool ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
/***** Start section *****/
Lay_StartSection (Fol_FOLLOW_SECTION_ID);
@ -531,7 +531,7 @@ void Fol_ShowFollowingAndFollowers (const struct UsrData *UsrDat,
/* I follow user? */
fprintf (Gbl.F.Out,"<div id=\"follow_usr\">");
if (Gbl.Usrs.Me.Logged && !ItsMe) // It's another logged user
if (!ItsMe) // Not me
{
if (IFollowUsr) // I follow this user
{
@ -755,6 +755,7 @@ static void Fol_ListFollowersUsr (struct UsrData *UsrDat)
unsigned NumUsrs;
unsigned NumUsr;
struct UsrData FollowerUsrDat;
bool ItsMe;
/***** Show user's profile *****/
if (Prf_ShowUserProfile (UsrDat))
@ -804,7 +805,8 @@ static void Fol_ListFollowersUsr (struct UsrData *UsrDat)
DB_FreeMySQLResult (&mysql_res);
/***** If it's me, mark possible notification as seen *****/
if (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod)
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
if (ItsMe)
Ntf_MarkNotifAsSeen (Ntf_EVENT_FOLLOWER,
-1L,-1L,
Gbl.Usrs.Me.UsrDat.UsrCod);
@ -823,7 +825,7 @@ static void Fol_ShowFollowedOrFollower (struct UsrData *UsrDat)
bool ShowPhoto;
char PhotoURL[PATH_MAX + 1];
bool Visible = Pri_ShowingIsAllowed (UsrDat->ProfileVisibility,UsrDat);
bool ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod);
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
/***** Show user's photo *****/
fprintf (Gbl.F.Out,"<td class=\"FOLLOW_PHOTO\">");
@ -851,7 +853,7 @@ static void Fol_ShowFollowedOrFollower (struct UsrData *UsrDat)
Act_FormEnd ();
}
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod);
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
if (!Gbl.Usrs.Me.Logged || // Not logged
ItsMe) // It's me
/* Inactive icon to follow/unfollow */
@ -879,7 +881,7 @@ static void Fol_WriteRowUsrToFollowOnRightColumn (struct UsrData *UsrDat)
bool ShowPhoto;
char PhotoURL[PATH_MAX + 1];
bool Visible = Pri_ShowingIsAllowed (UsrDat->ProfileVisibility,UsrDat);
bool ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod);
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
/***** Show user's photo *****/
fprintf (Gbl.F.Out,"<tr>"

View File

@ -1191,6 +1191,7 @@ static void For_ShowAForumPost (unsigned PstNum,long PstCod,
char Content[Cns_MAX_BYTES_LONG_TEXT + 1];
struct Image Image;
bool Enabled;
bool ItsMe;
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
@ -1298,24 +1299,28 @@ static void For_ShowAForumPost (unsigned PstNum,long PstCod,
}
/***** Form to remove post *****/
if (LastPst && Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat.UsrCod)
// Post can be removed if post is the last (without answers) and it's mine
if (LastPst)
{
if (PstNum == 1) // First and unique post in thread
Act_FormStartAnchor (For_ActionsDelPstFor[Gbl.Forum.ForumSelected.Type],
For_FORUM_THREADS_SECTION_ID);
else // Last of several posts in thread
Act_FormStartAnchor (For_ActionsDelPstFor[Gbl.Forum.ForumSelected.Type],
For_FORUM_POSTS_SECTION_ID);
For_PutAllHiddenParamsForum (Gbl.Forum.CurrentPageThrs, // Page of threads = current
Gbl.Forum.CurrentPagePsts, // Page of posts = current
Gbl.Forum.ForumSet,
Gbl.Forum.ThreadsOrder,
Gbl.Forum.ForumSelected.Location,
Gbl.Forum.ForumSelected.ThrCod,
PstCod);
Ico_PutIconRemove ();
Act_FormEnd ();
ItsMe = Usr_ItsMe (UsrDat.UsrCod);
if (ItsMe)
{
// Post can be removed if post is the last (without answers) and it's mine
if (PstNum == 1) // First and unique post in thread
Act_FormStartAnchor (For_ActionsDelPstFor[Gbl.Forum.ForumSelected.Type],
For_FORUM_THREADS_SECTION_ID);
else // Last of several posts in thread
Act_FormStartAnchor (For_ActionsDelPstFor[Gbl.Forum.ForumSelected.Type],
For_FORUM_POSTS_SECTION_ID);
For_PutAllHiddenParamsForum (Gbl.Forum.CurrentPageThrs, // Page of threads = current
Gbl.Forum.CurrentPagePsts, // Page of posts = current
Gbl.Forum.ForumSet,
Gbl.Forum.ThreadsOrder,
Gbl.Forum.ForumSelected.Location,
Gbl.Forum.ForumSelected.ThrCod,
PstCod);
Ico_PutIconRemove ();
Act_FormEnd ();
}
}
fprintf (Gbl.F.Out,"</td>");
@ -4069,6 +4074,7 @@ void For_RemovePost (void)
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
char OriginalContent[Cns_MAX_BYTES_LONG_TEXT + 1];
struct Image Image;
bool ItsMe;
bool ThreadDeleted = false;
/***** Get parameters related to forum *****/
@ -4087,7 +4093,8 @@ void For_RemovePost (void)
Lay_ShowErrorAndExit ("The post to remove no longer exists.");
/* Check if I am the author of the message */
if (Gbl.Usrs.Me.UsrDat.UsrCod != UsrDat.UsrCod)
ItsMe = Usr_ItsMe (UsrDat.UsrCod);
if (!ItsMe)
Lay_ShowErrorAndExit ("You can not remove post because you aren't the author.");
/* Check if the message is the last message in the thread */

View File

@ -1182,7 +1182,7 @@ unsigned Grp_RemoveUsrFromGroups (struct UsrData *UsrDat,struct ListCodGrps *Lst
void Grp_RemUsrFromAllGrpsInCrs (long UsrCod,long CrsCod)
{
char Query[512];
bool ItsMe = (UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (UsrCod);
/***** Remove user from all the groups of the course *****/
sprintf (Query,"DELETE FROM crs_grp_usr"
@ -1206,7 +1206,7 @@ void Grp_RemUsrFromAllGrpsInCrs (long UsrCod,long CrsCod)
void Grp_RemUsrFromAllGrps (long UsrCod)
{
char Query[128];
bool ItsMe = (UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (UsrCod);
/***** Remove user from all groups *****/
sprintf (Query,"DELETE FROM crs_grp_usr WHERE UsrCod=%ld",
@ -1226,7 +1226,7 @@ void Grp_RemUsrFromAllGrps (long UsrCod)
static void Grp_RemoveUsrFromGroup (long UsrCod,long GrpCod)
{
char Query[256];
bool ItsMe = (UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (UsrCod);
/***** Remove user from group *****/
sprintf (Query,"DELETE FROM crs_grp_usr"
@ -3325,7 +3325,7 @@ bool Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (const struct UsrData *UsrDat)
return false;
/***** 5. Fast check: It's me? *****/
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod);
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
if (ItsMe)
return true;

View File

@ -1137,7 +1137,7 @@ void Mai_PutLinkToChangeOtherUsrEmails (void)
{
extern const char *Txt_Change_email;
Act_Action_t NextAction;
bool ItsMe = (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
/***** Link for changing the password *****/
if (ItsMe)
@ -1193,7 +1193,7 @@ void Mai_ShowFormOthEmail (void)
/***** Form with the user's email *****/
Tbl_StartTableCenter (2);
ItsMe = (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
Mai_ShowFormChangeUsrEmail (&Gbl.Usrs.Other.UsrDat,ItsMe);
Tbl_EndTable ();
@ -1498,7 +1498,7 @@ void Mai_NewOtherUsrEmail (void)
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
{
/***** New user's ID *****/
ItsMe = (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
Mai_NewUsrEmail (&Gbl.Usrs.Other.UsrDat,ItsMe);
/***** Show user's record *****/
@ -1889,7 +1889,7 @@ void Mai_WriteFootNoteEMail (Txt_Language_t Language)
bool Mai_ICanSeeOtherUsrEmail (const struct UsrData *UsrDat)
{
bool ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
if (ItsMe)
return true;

View File

@ -1453,7 +1453,8 @@ static void Msg_SetReceivedMsgAsReplied (long MsgCod)
char Query[512];
/***** Update received message by setting Replied field to true *****/
sprintf (Query,"UPDATE msg_rcv SET Replied='Y' WHERE MsgCod=%ld AND UsrCod=%ld",
sprintf (Query,"UPDATE msg_rcv SET Replied='Y'"
" WHERE MsgCod=%ld AND UsrCod=%ld",
MsgCod,Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE (Query,"can not update a received message");
}

View File

@ -373,7 +373,7 @@ void Nck_UpdateNick (void)
sprintf (Gbl.Alert.Txt,Txt_The_nickname_X_matches_the_one_you_had_previously_registered,
NewNicknameWithoutArroba);
}
else if (strcasecmp (Gbl.Usrs.Me.UsrDat.Nickname,NewNicknameWithoutArroba)) // My nickname does not match, not even case insensitive, the new nickname
else if (strcasecmp (Gbl.Usrs.Me.UsrDat.Nickname,NewNicknameWithoutArroba)) // My nickname does not match, not even case insensitive, the new nickname
{
/***** Check if the new nickname matches any of my old nicknames *****/
sprintf (Query,"SELECT COUNT(*) FROM usr_nicknames"
@ -385,7 +385,7 @@ void Nck_UpdateNick (void)
sprintf (Query,"SELECT COUNT(*) FROM usr_nicknames"
" WHERE Nickname='%s' AND UsrCod<>%ld",
NewNicknameWithoutArroba,Gbl.Usrs.Me.UsrDat.UsrCod);
if (DB_QueryCOUNT (Query,"can not check if nickname already existed")) // A nickname of another user is the same that my nickname
if (DB_QueryCOUNT (Query,"can not check if nickname already existed")) // A nickname of another user is the same that my nickname
{
Error = true;
sprintf (Gbl.Alert.Txt,Txt_The_nickname_X_had_been_registered_by_another_user,

View File

@ -2079,7 +2079,8 @@ static unsigned Ntf_GetNumberOfAllMyUnseenNtfs (void)
/***** Get number of places with a name from database *****/
sprintf (Query,"SELECT COUNT(*) FROM notif"
" WHERE ToUsrCod=%ld AND (Status & %u)=0",
Gbl.Usrs.Me.UsrDat.UsrCod,(unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED));
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED));
return DB_QueryCOUNT (Query,"can not get number of unseen notifications");
}

View File

@ -918,7 +918,7 @@ void Pwd_PutLinkToChangeOtherUsrPassword (void)
{
extern const char *Txt_Change_password;
Act_Action_t NextAction;
bool ItsMe = (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
/***** Link for changing the password *****/
if (ItsMe)

View File

@ -135,7 +135,7 @@ static void Pho_ComputePhotoSize (int NumStds,int NumStdsWithPhoto,unsigned *Pho
bool Pho_ICanChangeOtherUsrPhoto (const struct UsrData *UsrDat)
{
bool ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
if (ItsMe)
return true;
@ -172,7 +172,7 @@ void Pho_PutLinkToChangeOtherUsrPhoto (void)
char PhotoURL[PATH_MAX + 1];
const char *TitleText;
Act_Action_t NextAction;
bool ItsMe = (Gbl.Record.UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (Gbl.Record.UsrDat->UsrCod);
/***** Link for changing / uploading the photo *****/
if (ItsMe)
@ -300,7 +300,7 @@ static void Pho_ReqPhoto (const struct UsrData *UsrDat)
extern const char *Txt_You_can_send_a_file_with_an_image_in_JPEG_format_;
extern const char *Txt_File_with_the_photo;
extern const char *Txt_Upload_photo;
bool ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
Act_Action_t NextAction;
/***** Start box *****/
@ -366,7 +366,7 @@ void Pho_SendPhotoUsr (void)
if (Pho_ICanChangeOtherUsrPhoto (&Gbl.Usrs.Other.UsrDat)) // If I have permission to change user's photo...
{
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
ItsMe = (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
if (ItsMe)
/***** Form to send my photo *****/
Pho_ReqMyPhoto ();
@ -969,7 +969,8 @@ unsigned Pho_UpdateMyClicksWithoutPhoto (void)
/* Update number of clicks */
if (NumClicks <= Pho_MAX_CLICKS_WITHOUT_PHOTO)
{
sprintf (Query,"UPDATE clicks_without_photo SET NumClicks=NumClicks+1 WHERE UsrCod=%ld",
sprintf (Query,"UPDATE clicks_without_photo"
" SET NumClicks=NumClicks+1 WHERE UsrCod=%ld",
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE (Query,"can not update number of clicks without photo");
NumClicks++;

View File

@ -233,7 +233,7 @@ Pri_Visibility_t Pri_GetParamVisibility (const char *ParamName)
bool Pri_ShowingIsAllowed (Pri_Visibility_t Visibility,struct UsrData *UsrDat)
{
bool ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
/***** I always can see my things *****/
if (ItsMe)

View File

@ -207,6 +207,7 @@ void Prf_RequestUserProfile (void)
void Prf_GetUsrDatAndShowUserProfile (void)
{
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
bool ItsMe;
bool ProfileShown = false;
/***** Get user's data *****/
@ -240,7 +241,8 @@ void Prf_GetUsrDatAndShowUserProfile (void)
}
/***** If it's not me, mark possible notification as seen *****/
if (Gbl.Usrs.Other.UsrDat.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // Not me
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
if (!ItsMe) // Not me
Ntf_MarkNotifAsSeen (Ntf_EVENT_FOLLOWER,
Gbl.Usrs.Other.UsrDat.UsrCod,-1L,
Gbl.Usrs.Me.UsrDat.UsrCod);
@ -257,8 +259,7 @@ bool Prf_ShowUserProfile (struct UsrData *UsrDat)
unsigned NumFollowers;
bool UsrFollowsMe;
bool IFollowUsr;
bool ItsMe = (Gbl.Usrs.Me.Logged &&
UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
/***** Check if I can see the public profile *****/
if (Pri_ShowingIsAllowed (UsrDat->ProfileVisibility,UsrDat))
@ -268,10 +269,10 @@ bool Prf_ShowUserProfile (struct UsrData *UsrDat)
{
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
if (ItsMe) // It's me
if (ItsMe)
/* Put link to show another user's profile */
Prf_PutLinkRequestAnotherUserProfile ();
else // Not me
else // Not me
/* Put link to show my public profile */
Prf_PutLinkMyPublicProfile ();
@ -282,7 +283,7 @@ bool Prf_ShowUserProfile (struct UsrData *UsrDat)
}
/***** Shared record card *****/
if (!ItsMe && // If not it's me...
if (!ItsMe && // If not me...
Gbl.CurrentCrs.Crs.CrsCod > 0) // ...and a course is selected
{
/* Get user's role in current course */

View File

@ -1976,7 +1976,7 @@ static void Prj_AddUsrToProject (Prj_RoleInProject_t RoleInProject)
DB_QueryREPLACE (Query,"can not add user to project");
/***** Flush cache *****/
ItsMe = (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
if (ItsMe)
Prj_FlushCacheMyRoleInProject ();
@ -2050,7 +2050,7 @@ static void Prj_ReqRemUsrFromPrj (Prj_RoleInProject_t RoleInProject)
{
if (Prj_CheckIfICanEditProject (Prj.PrjCod))
{
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
/***** Show question and button to remove user as administrator *****/
/* Start alert */
@ -2141,7 +2141,7 @@ static void Prj_RemUsrFromPrj (Prj_RoleInProject_t RoleInProject)
DB_QueryDELETE (Query,"can not remove a user from a project");
/***** Flush cache *****/
ItsMe = (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
if (ItsMe)
Prj_FlushCacheMyRoleInProject ();
@ -3460,7 +3460,7 @@ void Prj_RemoveUsrFromProjects (long UsrCod)
DB_QueryDELETE (Query,"can not remove user from projects");
/***** Flush cache *****/
ItsMe = (UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (UsrCod);
if (ItsMe)
Prj_FlushCacheMyRoleInProject ();
}

View File

@ -1152,7 +1152,7 @@ static void Rec_ShowRecordOneStdCrs (void)
switch (Gbl.Usrs.Me.Role.Logged)
{
case Rol_STD:
ItsMe = (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
if (ItsMe)
{
fprintf (Gbl.F.Out,"<div class=\"REC_RIGHT\">");
@ -1204,6 +1204,7 @@ static void Rec_ListRecordsStds (Rec_SharedRecordViewType_t ShaTypeOfView,
unsigned NumUsr = 0;
const char *Ptr;
struct UsrData UsrDat;
bool ItsMe;
char RecordSectionId[32];
/***** Assign users listing type depending on current action *****/
@ -1281,16 +1282,19 @@ static void Rec_ListRecordsStds (Rec_SharedRecordViewType_t ShaTypeOfView,
/* Record of the student in the course */
if (Gbl.CurrentCrs.Records.LstFields.Num) // There are fields in the record
{
ItsMe = Usr_ItsMe (UsrDat.UsrCod);
if ( Gbl.Usrs.Me.Role.Logged == Rol_NET ||
Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
(Gbl.Usrs.Me.Role.Logged == Rol_STD && // I am student in this course...
UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod)) // ...and it's me
(Gbl.Usrs.Me.Role.Logged == Rol_STD && // I am student in this course...
ItsMe)) // ...and it's me
{
fprintf (Gbl.F.Out,"<div class=\"REC_RIGHT\">");
Rec_ShowCrsRecord (CrsTypeOfView,&UsrDat,RecordSectionId);
fprintf (Gbl.F.Out,"</div>");
}
}
/* End container for this user */
fprintf (Gbl.F.Out,"</div>");
@ -1732,7 +1736,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
switch (Gbl.Usrs.Me.Role.Logged)
{
case Rol_STD: // I am a student
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod); // It's me
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
if (ItsMe)
{
switch (TypeOfView)
@ -1764,7 +1768,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
break;
}
}
else // It's not me ==> I am a student trying to do something forbidden
else // Not me ==> I am a student trying to do something forbidden
Lay_ShowErrorAndExit (Txt_You_dont_have_permission_to_perform_this_action);
break;
case Rol_NET:
@ -2227,7 +2231,7 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView,
Act_Action_t NextAction;
/***** Initializations *****/
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod);
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
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
@ -2470,7 +2474,7 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView,
if (Gbl.Usrs.Me.IBelongToCurrentCrs)
Grp_ShowLstGrpsToChgMyGrps ();
}
else
else // Not me
Grp_ShowLstGrpsToChgOtherUsrsGrps (UsrDat->UsrCod);
}
@ -2512,7 +2516,7 @@ static void Rec_PutIconsCommands (void)
extern const char *Txt_View_attendance;
extern const char *Txt_Following_unfollow;
extern const char *Txt_Follow;
bool ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Record.UsrDat->UsrCod);
bool ItsMe = Usr_ItsMe (Gbl.Record.UsrDat->UsrCod);
bool ICanViewUsrProfile;
Act_Action_t NextAction;
@ -2610,7 +2614,7 @@ static void Rec_PutIconsCommands (void)
"exam64x64.png",
Txt_View_test_results,NULL,
NULL);
else
else // Not me
Lay_PutContextualLink (ActSeeUsrTstRes,NULL,Rec_PutParamsStudent,
"exam64x64.png",
Txt_View_test_results,NULL,
@ -2625,7 +2629,7 @@ static void Rec_PutIconsCommands (void)
"folder64x64.gif",
Txt_View_homework,NULL,
NULL);
else // I am not a student in current course
else // Not me // I am not a student in current course
Lay_PutContextualLink (ActAdmAsgWrkCrs,NULL,Rec_PutParamsWorks,
"folder64x64.gif",
Txt_View_homework,NULL,
@ -2640,7 +2644,7 @@ static void Rec_PutIconsCommands (void)
"rollcall64x64.png",
Txt_View_attendance,NULL,
NULL);
else
else // Not me
Lay_PutContextualLink (ActSeeLstStdAtt,NULL,Rec_PutParamsStudent,
"rollcall64x64.png",
Txt_View_attendance,NULL,
@ -2662,7 +2666,7 @@ static void Rec_PutIconsCommands (void)
NULL);
/***** Button to follow / unfollow *****/
if (!ItsMe)
if (!ItsMe) // Not me
{
if (Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Record.UsrDat->UsrCod))
@ -2814,8 +2818,7 @@ static void Rec_ShowNickname (struct UsrData *UsrDat,bool PutFormLinks)
if (PutFormLinks)
{
/* Put form to go to public profile */
ItsMe = (Gbl.Usrs.Me.Logged &&
UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
Act_FormStart (ActSeeOthPubPrf);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Act_LinkFormSubmit (ItsMe ? Txt_My_public_profile :

View File

@ -781,7 +781,8 @@ static void Rep_WriteSectionHitsPerAction (struct Rep_Report *Report)
sprintf (Query,"SELECT SQL_NO_CACHE ActCod,COUNT(*) AS N FROM log_full"
" WHERE ClickTime>=FROM_UNIXTIME(%ld) AND UsrCod=%ld"
" GROUP BY ActCod ORDER BY N DESC LIMIT %u",
(long) Report->UsrFigures.FirstClickTimeUTC,Gbl.Usrs.Me.UsrDat.UsrCod,
(long) Report->UsrFigures.FirstClickTimeUTC,
Gbl.Usrs.Me.UsrDat.UsrCod,
Rep_MAX_ACTIONS);
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get clicks");

View File

@ -917,7 +917,7 @@ static void Soc_ShowTimeline (const char *Query,const char *Title,
struct SocialPublishing SocPub;
struct SocialNote SocNot;
bool GlobalTimeline = (Gbl.Usrs.Other.UsrDat.UsrCod <= 0);
bool ItsMe = (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
/***** Get publishings from database *****/
NumPubsGot = DB_QuerySELECT (Query,&mysql_res,"can not get timeline");
@ -1258,6 +1258,7 @@ static void Soc_WriteSocialNote (const struct SocialNote *SocNot,
extern const char *Txt_Centre;
extern const char *Txt_Institution;
struct UsrData UsrDat;
bool ItsMe;
bool IAmTheAuthor = false;
bool IAmASharerOfThisSocNot = false;
bool IAmAFaverOfThisSocNot = false;
@ -1316,7 +1317,8 @@ static void Soc_WriteSocialNote (const struct SocialNote *SocNot,
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat);
if (Gbl.Usrs.Me.Logged)
{
IAmTheAuthor = (UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (UsrDat.UsrCod);
IAmTheAuthor = ItsMe;
if (!IAmTheAuthor)
{
IAmASharerOfThisSocNot = Soc_CheckIfNoteIsSharedByUsr (SocNot->NotCod,
@ -1539,8 +1541,7 @@ static void Soc_WriteTopMessage (Soc_TopMessage_t TopMessage,long UsrCod)
extern const char *Txt_Another_user_s_profile;
extern const char *Txt_SOCIAL_NOTE_TOP_MESSAGES[Soc_NUM_TOP_MESSAGES];
struct UsrData UsrDat;
bool ItsMe = (Gbl.Usrs.Me.Logged &&
UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (UsrCod);
if (TopMessage != Soc_TOP_MESSAGE_NONE)
{
@ -1581,8 +1582,7 @@ static void Soc_WriteAuthorNote (const struct UsrData *UsrDat)
{
extern const char *Txt_My_public_profile;
extern const char *Txt_Another_user_s_profile;
bool ItsMe = (Gbl.Usrs.Me.Logged &&
UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_RIGHT_AUTHOR\">");
@ -2523,6 +2523,7 @@ static void Soc_WriteSocialComment (struct SocialComment *SocCom,
extern const char *Txt_Centre;
extern const char *Txt_Institution;
struct UsrData UsrDat;
bool ItsMe;
bool IAmTheAuthor;
bool IAmAFaverOfThisSocCom = false;
bool ShowPhoto = false;
@ -2558,8 +2559,8 @@ static void Soc_WriteSocialComment (struct SocialComment *SocCom,
Usr_UsrDataConstructor (&UsrDat);
UsrDat.UsrCod = SocCom->UsrCod;
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat);
IAmTheAuthor = (Gbl.Usrs.Me.Logged &&
UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (UsrDat.UsrCod);
IAmTheAuthor = ItsMe;
if (!IAmTheAuthor)
IAmAFaverOfThisSocCom = Soc_CheckIfCommIsFavedByUsr (SocCom->PubCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
@ -2630,8 +2631,7 @@ static void Soc_WriteAuthorComment (struct UsrData *UsrDat)
{
extern const char *Txt_My_public_profile;
extern const char *Txt_Another_user_s_profile;
bool ItsMe = (Gbl.Usrs.Me.Logged &&
UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_COMMENT_RIGHT_AUTHOR\">");
@ -3101,6 +3101,7 @@ static long Soc_ShareSocialNote (void)
extern const char *Txt_The_original_post_no_longer_exists;
struct SocialNote SocNot;
struct SocialPublishing SocPub;
bool ItsMe;
long OriginalPubCod;
/***** Get data of social note *****/
@ -3109,8 +3110,8 @@ static long Soc_ShareSocialNote (void)
if (SocNot.NotCod > 0)
{
if (Gbl.Usrs.Me.Logged &&
SocNot.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // I am not the author
ItsMe = Usr_ItsMe (SocNot.UsrCod);
if (Gbl.Usrs.Me.Logged && !ItsMe) // I am not the author
if (!Soc_CheckIfNoteIsSharedByUsr (SocNot.NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // Not yet shared by me
{
@ -3179,6 +3180,7 @@ static long Soc_FavSocialNote (void)
extern const char *Txt_The_original_post_no_longer_exists;
char Query[256];
struct SocialNote SocNot;
bool ItsMe;
long OriginalPubCod;
/***** Get data of social note *****/
@ -3187,8 +3189,8 @@ static long Soc_FavSocialNote (void)
if (SocNot.NotCod > 0)
{
if (Gbl.Usrs.Me.Logged &&
SocNot.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // I am not the author
ItsMe = Usr_ItsMe (SocNot.UsrCod);
if (Gbl.Usrs.Me.Logged && !ItsMe) // I am not the author
if (!Soc_CheckIfNoteIsFavedByUsr (SocNot.NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the note
{
@ -3264,6 +3266,7 @@ static long Soc_FavSocialComment (void)
{
extern const char *Txt_The_comment_no_longer_exists;
struct SocialComment SocCom;
bool ItsMe;
char Query[256];
/***** Initialize image *****/
@ -3275,8 +3278,8 @@ static long Soc_FavSocialComment (void)
if (SocCom.PubCod > 0)
{
if (Gbl.Usrs.Me.Logged &&
SocCom.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // I am not the author
ItsMe = Usr_ItsMe (SocCom.UsrCod);
if (Gbl.Usrs.Me.Logged && !ItsMe) // I am not the author
if (!Soc_CheckIfCommIsFavedByUsr (SocCom.PubCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the comment
{
@ -3390,6 +3393,7 @@ static long Soc_UnshareSocialNote (void)
char Query[256];
struct SocialNote SocNot;
long OriginalPubCod;
bool ItsMe;
/***** Get data of social note *****/
SocNot.NotCod = Soc_GetParamNotCod ();
@ -3397,9 +3401,9 @@ static long Soc_UnshareSocialNote (void)
if (SocNot.NotCod > 0)
{
ItsMe = Usr_ItsMe (SocNot.UsrCod);
if (SocNot.NumShared &&
Gbl.Usrs.Me.Logged &&
SocNot.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // I am not the author
Gbl.Usrs.Me.Logged && !ItsMe) // I am not the author
if (Soc_CheckIfNoteIsSharedByUsr (SocNot.NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I am a sharer
{
@ -3478,6 +3482,7 @@ static long Soc_UnfavSocialNote (void)
struct SocialNote SocNot;
char Query[256];
long OriginalPubCod;
bool ItsMe;
/***** Get data of social note *****/
SocNot.NotCod = Soc_GetParamNotCod ();
@ -3485,9 +3490,9 @@ static long Soc_UnfavSocialNote (void)
if (SocNot.NotCod > 0)
{
ItsMe = Usr_ItsMe (SocNot.UsrCod);
if (SocNot.NumFavs &&
Gbl.Usrs.Me.Logged &&
SocNot.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // I am not the author
Gbl.Usrs.Me.Logged && !ItsMe) // I am not the author
if (Soc_CheckIfNoteIsFavedByUsr (SocNot.NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the note
{
@ -3560,6 +3565,7 @@ static long Soc_UnfavSocialComment (void)
{
extern const char *Txt_The_comment_no_longer_exists;
struct SocialComment SocCom;
bool ItsMe;
char Query[256];
/***** Initialize image *****/
@ -3571,9 +3577,9 @@ static long Soc_UnfavSocialComment (void)
if (SocCom.PubCod > 0)
{
ItsMe = Usr_ItsMe (SocCom.UsrCod);
if (SocCom.NumFavs &&
Gbl.Usrs.Me.Logged &&
SocCom.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // I am not the author
Gbl.Usrs.Me.Logged && !ItsMe) // I am not the author
if (Soc_CheckIfCommIsFavedByUsr (SocCom.PubCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the comment
{
@ -3645,6 +3651,7 @@ static void Soc_RequestRemovalSocialNote (void)
extern const char *Txt_Do_you_really_want_to_remove_the_following_post;
extern const char *Txt_Remove;
struct SocialNote SocNot;
bool ItsMe;
/***** Get data of social note *****/
SocNot.NotCod = Soc_GetParamNotCod ();
@ -3652,8 +3659,8 @@ static void Soc_RequestRemovalSocialNote (void)
if (SocNot.NotCod > 0)
{
if (Gbl.Usrs.Me.Logged &&
SocNot.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // I am the author of this note
ItsMe = Usr_ItsMe (SocNot.UsrCod);
if (ItsMe) // I am the author of this note
{
/***** Show question and button to remove social note *****/
/* Start alert */
@ -3732,6 +3739,7 @@ static void Soc_RemoveSocialNote (void)
extern const char *Txt_The_original_post_no_longer_exists;
extern const char *Txt_Post_removed;
struct SocialNote SocNot;
bool ItsMe;
/***** Get data of social note *****/
SocNot.NotCod = Soc_GetParamNotCod ();
@ -3739,8 +3747,8 @@ static void Soc_RemoveSocialNote (void)
if (SocNot.NotCod > 0)
{
if (Gbl.Usrs.Me.Logged &&
SocNot.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // I am the author of this note
ItsMe = Usr_ItsMe (SocNot.UsrCod);
if (ItsMe) // I am the author of this note
{
if (SocNot.NoteType == Soc_NOTE_SOCIAL_POST)
/***** Remove image file associated to social post *****/
@ -3980,6 +3988,7 @@ static void Soc_RequestRemovalSocialComment (void)
extern const char *Txt_Do_you_really_want_to_remove_the_following_comment;
extern const char *Txt_Remove;
struct SocialComment SocCom;
bool ItsMe;
/***** Initialize image *****/
Img_ImageConstructor (&SocCom.Image);
@ -3990,8 +3999,8 @@ static void Soc_RequestRemovalSocialComment (void)
if (SocCom.PubCod > 0)
{
if (Gbl.Usrs.Me.Logged &&
SocCom.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // I am the author of this comment
ItsMe = Usr_ItsMe (SocCom.UsrCod);
if (ItsMe) // I am the author of this comment
{
/***** Show question and button to remove social comment *****/
/* Start alert */
@ -4073,6 +4082,7 @@ static void Soc_RemoveSocialComment (void)
extern const char *Txt_The_comment_no_longer_exists;
extern const char *Txt_Comment_removed;
struct SocialComment SocCom;
bool ItsMe;
/***** Initialize image *****/
Img_ImageConstructor (&SocCom.Image);
@ -4083,8 +4093,8 @@ static void Soc_RemoveSocialComment (void)
if (SocCom.PubCod > 0)
{
if (Gbl.Usrs.Me.Logged &&
SocCom.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // I am the author of this comment
ItsMe = Usr_ItsMe (SocCom.UsrCod);
if (ItsMe) // I am the author of this comment
{
/***** Remove image file associated to social post *****/
Soc_RemoveImgFileFromSocialComment (SocCom.PubCod);
@ -4931,6 +4941,7 @@ static void Str_AnalyzeTxtAndStoreNotifyEventToMentionedUsrs (long PubCod,const
size_t Length; // Length of the nickname
} Nickname;
struct UsrData UsrDat;
bool ItsMe;
bool CreateNotif;
bool NotifyByEmail;
@ -4972,7 +4983,9 @@ static void Str_AnalyzeTxtAndStoreNotifyEventToMentionedUsrs (long PubCod,const
strncpy (UsrDat.Nickname,Nickname.PtrStart,Nickname.Length);
if ((UsrDat.UsrCod = Nck_GetUsrCodFromNickname (UsrDat.Nickname)) > 0)
if (UsrDat.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // It's not me
{
ItsMe = Usr_ItsMe (UsrDat.UsrCod);
if (!ItsMe) // Not me
{
/* Get user's data */
Usr_GetAllUsrDataFromUsrCod (&UsrDat);
@ -4987,6 +5000,7 @@ static void Str_AnalyzeTxtAndStoreNotifyEventToMentionedUsrs (long PubCod,const
0));
}
}
}
}
}
/* The next char is not the start of a nickname */

View File

@ -412,7 +412,7 @@ void Sta_LogAccess (const char *Comments)
}
/***** Increment my number of clicks *****/
if (Gbl.Usrs.Me.UsrDat.UsrCod > 0)
if (Gbl.Usrs.Me.Logged)
Prf_IncrementNumClicksUsr (Gbl.Usrs.Me.UsrDat.UsrCod);
}

View File

@ -7714,7 +7714,7 @@ static void Tst_ShowTestResults (struct UsrData *UsrDat)
double ScoreInThisTest;
double TotalScoreOfAllTests = 0.0;
unsigned NumExamsVisibleByTchs = 0;
bool ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
bool ICanViewTest;
bool ICanViewScore;
time_t TimeUTC;
@ -8117,7 +8117,7 @@ void Tst_ShowOneTestResult (void)
Gbl.Test.Config.Feedback = Tst_FEEDBACK_FULL_FEEDBACK; // Initialize feedback to maximum
/***** Check if I can view this test result *****/
ItsMe = (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
switch (Gbl.Usrs.Me.Role.Logged)
{
case Rol_STD:

View File

@ -408,6 +408,16 @@ void Usr_FreeListUsrCods (struct ListUsrCods *ListUsrCods)
}
}
/*****************************************************************************/
/************************ Check if I am a given user *************************/
/*****************************************************************************/
bool Usr_ItsMe (long UsrCod)
{
return Gbl.Usrs.Me.Logged &&
(UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
}
/*****************************************************************************/
/******** Get user's code from database using encrypted user's code **********/
/*****************************************************************************/
@ -854,7 +864,7 @@ bool Usr_CheckIfUsrIsSuperuser (long UsrCod)
bool Usr_ICanChangeOtherUsrData (const struct UsrData *UsrDat)
{
bool ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
if (ItsMe)
return true;
@ -888,7 +898,7 @@ bool Usr_ICanChangeOtherUsrData (const struct UsrData *UsrDat)
bool Usr_ICanEditOtherUsr (const struct UsrData *UsrDat)
{
bool ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
if (ItsMe)
return true;
@ -1095,7 +1105,7 @@ bool Usr_CheckIfICanViewRecordStd (const struct UsrData *UsrDat)
return false;
/***** 7. Fast check: It's me? *****/
ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
if (ItsMe)
return true;
@ -1156,7 +1166,7 @@ bool Usr_CheckIfICanViewRecordTch (struct UsrData *UsrDat)
}
/***** 4. Fast check: It's me? *****/
ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
if (ItsMe)
return true;
@ -1197,7 +1207,7 @@ bool Usr_CheckIfICanViewTst (const struct UsrData *UsrDat)
return false;
/***** 6. Fast check: It's me? *****/
ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
if (ItsMe)
return true;
@ -1251,7 +1261,7 @@ bool Usr_CheckIfICanViewAsgWrk (const struct UsrData *UsrDat)
return false;
/***** 7. Fast check: It's me? *****/
ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
if (ItsMe)
return true;
@ -1300,7 +1310,7 @@ bool Usr_CheckIfICanViewAtt (const struct UsrData *UsrDat)
return false;
/***** 7. Fast check: It's me? *****/
ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
if (ItsMe)
return true;
@ -1329,7 +1339,7 @@ bool Usr_CheckIfICanViewUsrAgenda (struct UsrData *UsrDat)
return false;
/***** 2. Fast check: It's me? *****/
ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
if (ItsMe)
return true;
@ -1365,7 +1375,7 @@ bool Usr_CheckIfUsrSharesAnyOfMyCrs (struct UsrData *UsrDat)
return false;
/***** 3. Fast check: It's me? *****/
ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
if (ItsMe)
return true;
@ -3701,7 +3711,7 @@ static void Usr_WriteRowTchAllData (struct UsrData *UsrDat)
char PhotoURL[PATH_MAX + 1];
bool ShowPhoto;
struct Instit Ins;
bool ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod);
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
bool ShowData = (ItsMe || UsrDat->Accepted ||
Gbl.Usrs.Me.Role.Logged == Rol_DEG_ADM ||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
@ -7244,7 +7254,7 @@ static void Usr_UpdateMyColsClassPhotoInDB (void)
{
char Query[256];
if (Gbl.Usrs.Me.UsrDat.UsrCod > 0 && Gbl.CurrentCrs.Crs.CrsCod > 0)
if (Gbl.Usrs.Me.Logged && Gbl.CurrentCrs.Crs.CrsCod > 0)
{
/***** Update number of colums in class photo for current course *****/
sprintf (Query,"UPDATE crs_usr SET ColsClassPhoto=%u"
@ -7346,7 +7356,7 @@ static void Usr_UpdateMyPrefAboutListWithPhotosPhotoInDB (void)
{
char Query[256];
if (Gbl.Usrs.Me.UsrDat.UsrCod > 0 && Gbl.CurrentCrs.Crs.CrsCod > 0)
if (Gbl.Usrs.Me.Logged && Gbl.CurrentCrs.Crs.CrsCod > 0)
{
/***** Update number of colums in class photo for current course *****/
sprintf (Query,"UPDATE crs_usr SET ListWithPhotos='%c'"

View File

@ -235,6 +235,7 @@ void Usr_UsrDataDestructor (struct UsrData *UsrDat);
void Usr_GetAllUsrDataFromUsrCod (struct UsrData *UsrDat);
void Usr_AllocateListUsrCods (struct ListUsrCods *ListUsrCods);
void Usr_FreeListUsrCods (struct ListUsrCods *ListUsrCods);
bool Usr_ItsMe (long UsrCod);
void Usr_GetUsrCodFromEncryptedUsrCod (struct UsrData *UsrDat);
void Usr_GetEncryptedUsrCodFromUsrCod (struct UsrData *UsrDat); // TODO: Remove this funcion, it's not used
void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat);

View File

@ -3180,6 +3180,7 @@ int swad__sendMessage (struct soap *soap,
bool FirstNickname = true;
bool ThereAreNicknames = false;
const char *Ptr;
bool ItsMe;
bool NotifyByEmail;
/***** Initializations *****/
@ -3339,7 +3340,8 @@ int swad__sendMessage (struct soap *soap,
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat))
{
/* This received message must be notified by email? */
NotifyByEmail = ((Gbl.Usrs.Other.UsrDat.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) &&
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
NotifyByEmail = (!ItsMe &&
(Gbl.Usrs.Other.UsrDat.Prefs.EmailNtfEvents & (1 << Ntf_EVENT_MESSAGE)));
/* Send message to this user */