mirror of https://github.com/acanas/swad-core.git
Version 16.92
This commit is contained in:
parent
438a192895
commit
db9ac7fb0e
|
@ -60,6 +60,7 @@
|
|||
#include "swad_password.h"
|
||||
#include "swad_photo.h"
|
||||
#include "swad_preference.h"
|
||||
#include "swad_privacy.h"
|
||||
#include "swad_profile.h"
|
||||
#include "swad_QR.h"
|
||||
#include "swad_report.h"
|
||||
|
@ -2352,7 +2353,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
|||
/* ActLstTchAll */{ 578,-1,TabUnk,ActLstTch ,0x1F0,0x1F0,0x1E0,Act_CONT_NORM,Act_BLNK_WINDOW,NULL ,Usr_ListAllDataTchs ,NULL},
|
||||
|
||||
/* ActSeeRecOneStd */{1174,-1,TabUnk,ActLstStd ,0x118,0x100,0x000,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rec_GetUsrAndShowRecordOneStdCrs,NULL},
|
||||
/* ActSeeRecOneTch */{1175,-1,TabUnk,ActLstTch ,0x1FE,0x1FE,0x000,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rec_GetUsrAndShowRecordOneTchCrs,NULL},
|
||||
/* ActSeeRecOneTch */{1175,-1,TabUnk,ActLstTch ,0x1FC,0x1FC,0x1FC,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rec_GetUsrAndShowRecordOneTchCrs,NULL},
|
||||
|
||||
/* ActSeeRecSevGst */{1187,-1,TabUnk,ActLstOth ,0x100,0x100,0x100,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rec_ListRecordsGsts ,NULL},
|
||||
/* ActSeeRecSevStd */{ 89,-1,TabUnk,ActLstStd ,0x118,0x100,0x000,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rec_ListRecordsStdsForEdit ,NULL},
|
||||
|
|
|
@ -175,28 +175,33 @@ void Agd_ShowUsrAgenda (void)
|
|||
extern const char *Txt_Public_agenda_USER;
|
||||
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
||||
bool ItsMe;
|
||||
bool Error = true;
|
||||
|
||||
/***** Get user *****/
|
||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||
{
|
||||
/***** Start frame *****/
|
||||
sprintf (Gbl.Title,Txt_Public_agenda_USER,Gbl.Usrs.Other.UsrDat.FullName);
|
||||
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
Lay_StartRoundFrame ("100%",Gbl.Title,
|
||||
ItsMe ? Agd_PutIconToViewEditMyFullAgenda :
|
||||
NULL,
|
||||
Hlp_PROFILE_Agenda_public_agenda);
|
||||
if (Usr_CheckIfICanViewUsrAgenda (&Gbl.Usrs.Other.UsrDat))
|
||||
{
|
||||
Error = false;
|
||||
|
||||
/***** Show the current events in the user's agenda *****/
|
||||
Agd_ShowEventsToday (Agd_OTHER_PUBLIC_AGENDA_TODAY);
|
||||
/***** Start frame *****/
|
||||
sprintf (Gbl.Title,Txt_Public_agenda_USER,Gbl.Usrs.Other.UsrDat.FullName);
|
||||
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
Lay_StartRoundFrame ("100%",Gbl.Title,
|
||||
ItsMe ? Agd_PutIconToViewEditMyFullAgenda :
|
||||
NULL,
|
||||
Hlp_PROFILE_Agenda_public_agenda);
|
||||
|
||||
/***** Show all the visible events in the user's agenda *****/
|
||||
Agd_ShowEvents (Agd_OTHER_PUBLIC_AGENDA);
|
||||
/***** Show the current events in the user's agenda *****/
|
||||
Agd_ShowEventsToday (Agd_OTHER_PUBLIC_AGENDA_TODAY);
|
||||
|
||||
/***** End frame *****/
|
||||
Lay_EndRoundFrame ();
|
||||
}
|
||||
else
|
||||
/***** Show all the visible events in the user's agenda *****/
|
||||
Agd_ShowEvents (Agd_OTHER_PUBLIC_AGENDA);
|
||||
|
||||
/***** End frame *****/
|
||||
Lay_EndRoundFrame ();
|
||||
}
|
||||
|
||||
if (Error)
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
}
|
||||
|
||||
|
|
|
@ -185,13 +185,15 @@
|
|||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 16.91.6 (2016-12-09)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 16.92 (2016-12-09)"
|
||||
#define CSS_FILE "swad16.86.5.css"
|
||||
#define JS_FILE "swad16.90.2.js"
|
||||
|
||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
||||
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
|
||||
/*
|
||||
Version 16.92: Dec 09, 2016 Teachers' record cards can be viewed by users sharing courses with them even if no course is selected.
|
||||
Code refactoring in user's record card. (210269 lines)
|
||||
Version 16.91.6: Dec 09, 2016 Code refactoring in agenda. (210128 lines)
|
||||
Version 16.91.5: Dec 08, 2016 Removed author in agenda events. (210148 lines)
|
||||
Version 16.91.4: Dec 07, 2016 Default ordering in agendas is start date. (210189 lines)
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "swad_follow.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_notification.h"
|
||||
#include "swad_privacy.h"
|
||||
#include "swad_profile.h"
|
||||
#include "swad_user.h"
|
||||
|
||||
|
@ -683,7 +684,7 @@ static void Fol_ShowFollowedOrFollower (const struct UsrData *UsrDat)
|
|||
extern const char *Txt_Follow;
|
||||
bool ShowPhoto;
|
||||
char PhotoURL[PATH_MAX+1];
|
||||
bool Visible = Pri_ShowIsAllowed (UsrDat->ProfileVisibility,UsrDat->UsrCod);
|
||||
bool Visible = Pri_ShowIsAllowed (UsrDat->ProfileVisibility,UsrDat);
|
||||
|
||||
/***** Show user's photo *****/
|
||||
fprintf (Gbl.F.Out,"<td class=\"FOLLOW_USR_PHOTO\">");
|
||||
|
@ -773,7 +774,7 @@ void Fol_FollowUsr (void)
|
|||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||
{
|
||||
// Follow only if I can view his/her public profile
|
||||
if (Pri_ShowIsAllowed (Gbl.Usrs.Other.UsrDat.ProfileVisibility,Gbl.Usrs.Other.UsrDat.UsrCod))
|
||||
if (Pri_ShowIsAllowed (Gbl.Usrs.Other.UsrDat.ProfileVisibility,&Gbl.Usrs.Other.UsrDat))
|
||||
// Follow only if I do not follow him/her
|
||||
if (!Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod))
|
||||
|
|
|
@ -955,7 +955,7 @@ bool Pho_ShowUsrPhotoIsAllowed (const struct UsrData *UsrDat,char *PhotoURL)
|
|||
bool ICanSeePhoto;
|
||||
|
||||
/***** Check if I can see the other's photo *****/
|
||||
ICanSeePhoto = Pri_ShowIsAllowed (UsrDat->PhotoVisibility,UsrDat->UsrCod);
|
||||
ICanSeePhoto = Pri_ShowIsAllowed (UsrDat->PhotoVisibility,UsrDat);
|
||||
|
||||
/***** Photo is shown if I can see it, and it exists *****/
|
||||
return ICanSeePhoto ? Pho_BuildLinkToPhoto (UsrDat,PhotoURL) :
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "swad_menu.h"
|
||||
#include "swad_parameter.h"
|
||||
#include "swad_preference.h"
|
||||
#include "swad_privacy.h"
|
||||
#include "swad_text.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -246,10 +246,10 @@ Pri_Visibility_t Pri_GetParamVisibility (const char *ParamName)
|
|||
/*****************************************************************************/
|
||||
// Returns true if it can be shown and false if not.
|
||||
|
||||
bool Pri_ShowIsAllowed (Pri_Visibility_t Visibility,long OtherUsrCod)
|
||||
bool Pri_ShowIsAllowed (Pri_Visibility_t Visibility,const struct UsrData *UsrDat)
|
||||
{
|
||||
/***** It's me? I always can see my things *****/
|
||||
if (OtherUsrCod == Gbl.Usrs.Me.UsrDat.UsrCod)
|
||||
if (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod)
|
||||
return true;
|
||||
|
||||
/***** System admins always can see others' profiles *****/
|
||||
|
@ -262,13 +262,9 @@ bool Pri_ShowIsAllowed (Pri_Visibility_t Visibility,long OtherUsrCod)
|
|||
case Pri_VISIBILITY_UNKNOWN:
|
||||
return false; // It's not me
|
||||
case Pri_VISIBILITY_USER: // Only visible by me and my teachers if I am a student or me and my students if I am a teacher
|
||||
if (Gbl.Usrs.Me.Logged)
|
||||
return Usr_CheckIfUsrSharesAnyOfMyCrsWithDifferentRole (OtherUsrCod); // Both users share the same course but whit different role
|
||||
return false;
|
||||
return Usr_CheckIfUsrSharesAnyOfMyCrsWithDifferentRole (UsrDat->UsrCod); // Both users share the same course but whit different role
|
||||
case Pri_VISIBILITY_COURSE: // Visible by users sharing courses with me
|
||||
if (Gbl.Usrs.Me.Logged)
|
||||
return Usr_CheckIfUsrSharesAnyOfMyCrs (OtherUsrCod); // Both users share the same course
|
||||
return false;
|
||||
return Usr_CheckIfUsrSharesAnyOfMyCrs (UsrDat); // Both users share the same course
|
||||
case Pri_VISIBILITY_SYSTEM: // Visible by any user logged in platform
|
||||
return Gbl.Usrs.Me.Logged;
|
||||
case Pri_VISIBILITY_WORLD: // Public, visible by everyone, even unlogged visitors
|
||||
|
|
|
@ -27,22 +27,14 @@
|
|||
/********************************* Headers ***********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "swad_privacy_visibility_type.h"
|
||||
#include "swad_user.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************* Public types and constants ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/***** Visibility (who can see user's photo / public profile) *****/
|
||||
#define Pri_NUM_OPTIONS_PRIVACY 5
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Pri_VISIBILITY_UNKNOWN = 0, // Only visible by me and my teachers if I am a student or my students if I am a teacher
|
||||
Pri_VISIBILITY_USER = 1, // Only visible by me and my teachers if I am a student or my students if I am a teacher
|
||||
Pri_VISIBILITY_COURSE = 2, // Visible by users sharing courses with me
|
||||
Pri_VISIBILITY_SYSTEM = 3, // Visible by any user logged in platform
|
||||
Pri_VISIBILITY_WORLD = 4, // Public, visible by all the people, even unlogged visitors
|
||||
} Pri_Visibility_t;
|
||||
|
||||
#define Pri_PHOTO_VISIBILITY_DEFAULT Pri_VISIBILITY_SYSTEM
|
||||
#define Pri_PROFILE_VISIBILITY_DEFAULT Pri_VISIBILITY_SYSTEM
|
||||
|
||||
|
@ -56,6 +48,6 @@ void Pri_EditMyPrivacy (void);
|
|||
Pri_Visibility_t Pri_GetVisibilityFromStr (const char *Str);
|
||||
Pri_Visibility_t Pri_GetParamVisibility (const char *ParamName);
|
||||
|
||||
bool Pri_ShowIsAllowed (Pri_Visibility_t Visibility,long OtherUsrCod);
|
||||
bool Pri_ShowIsAllowed (Pri_Visibility_t Visibility,const struct UsrData *UsrDat);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
// swad_privacy_visibility_type.h: definition of privacy visibility type
|
||||
|
||||
#ifndef _SWAD_PRI_VIS_T
|
||||
#define _SWAD_PRI_VIS_T
|
||||
/*
|
||||
SWAD (Shared Workspace At a Distance in Spanish),
|
||||
is a web platform developed at the University of Granada (Spain),
|
||||
and used to support university teaching.
|
||||
|
||||
This file is part of SWAD core.
|
||||
Copyright (C) 1999-2016 Antonio Cañas Vargas
|
||||
|
||||
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 ***********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************* Public types and constants ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/***** Visibility (who can see user's photo / public profile) *****/
|
||||
#define Pri_NUM_OPTIONS_PRIVACY 5
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Pri_VISIBILITY_UNKNOWN = 0, // Only visible by me and my teachers if I am a student or my students if I am a teacher
|
||||
Pri_VISIBILITY_USER = 1, // Only visible by me and my teachers if I am a student or my students if I am a teacher
|
||||
Pri_VISIBILITY_COURSE = 2, // Visible by users sharing courses with me
|
||||
Pri_VISIBILITY_SYSTEM = 3, // Visible by any user logged in platform
|
||||
Pri_VISIBILITY_WORLD = 4, // Public, visible by all the people, even unlogged visitors
|
||||
} Pri_Visibility_t;
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Public prototypes *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
|
@ -268,7 +268,7 @@ bool Prf_ShowUserProfile (struct UsrData *UsrDat)
|
|||
}
|
||||
|
||||
/***** Check if I can see the public profile *****/
|
||||
if (Pri_ShowIsAllowed (UsrDat->ProfileVisibility,UsrDat->UsrCod))
|
||||
if (Pri_ShowIsAllowed (UsrDat->ProfileVisibility,UsrDat))
|
||||
{
|
||||
if (!ItsMe && // If not it's me...
|
||||
Gbl.CurrentCrs.Crs.CrsCod > 0) // ...and a course is selected
|
||||
|
@ -1485,7 +1485,7 @@ void Prf_ShowUsrInRanking (const struct UsrData *UsrDat,unsigned Rank)
|
|||
extern const char *Txt_View_public_profile;
|
||||
bool ShowPhoto;
|
||||
char PhotoURL[PATH_MAX+1];
|
||||
bool Visible = Pri_ShowIsAllowed (UsrDat->ProfileVisibility,UsrDat->UsrCod);
|
||||
bool Visible = Pri_ShowIsAllowed (UsrDat->ProfileVisibility,UsrDat);
|
||||
|
||||
fprintf (Gbl.F.Out,"<td class=\"RANK RIGHT_MIDDLE COLOR%u\""
|
||||
" style=\"height:50px;\">"
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "swad_parameter.h"
|
||||
#include "swad_photo.h"
|
||||
#include "swad_preference.h"
|
||||
#include "swad_privacy.h"
|
||||
#include "swad_QR.h"
|
||||
#include "swad_record.h"
|
||||
#include "swad_user.h"
|
||||
|
@ -1030,9 +1031,7 @@ void Rec_GetUsrAndShowRecordOneStdCrs (void)
|
|||
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
|
||||
|
||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // Get from the database the data of the student
|
||||
if ((Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB =
|
||||
Rol_GetRoleInCrs (Gbl.CurrentCrs.Crs.CrsCod,
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod)) == Rol_STUDENT)
|
||||
if (Usr_CheckIfICanViewRecordStd (&Gbl.Usrs.Other.UsrDat))
|
||||
Rec_ShowRecordOneStdCrs ();
|
||||
}
|
||||
|
||||
|
@ -1217,9 +1216,7 @@ void Rec_GetUsrAndShowRecordOneTchCrs (void)
|
|||
|
||||
/***** Show the record *****/
|
||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // Get from the database the data of the teacher
|
||||
if ((Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB =
|
||||
Rol_GetRoleInCrs (Gbl.CurrentCrs.Crs.CrsCod,
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod)) == Rol_TEACHER)
|
||||
if (Usr_CheckIfICanViewRecordTch (&Gbl.Usrs.Other.UsrDat))
|
||||
Rec_ShowRecordOneTchCrs ();
|
||||
}
|
||||
|
||||
|
@ -2306,6 +2303,7 @@ static void Rec_PutIconsCommands (void)
|
|||
extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS];
|
||||
extern const char *Txt_Edit_my_personal_data;
|
||||
extern const char *Txt_View_record_for_this_course;
|
||||
extern const char *Txt_View_record_and_office_hours;
|
||||
extern const char *Txt_View_agenda;
|
||||
extern const char *Txt_Admin_user;
|
||||
extern const char *Txt_Write_a_message;
|
||||
|
@ -2318,16 +2316,12 @@ static void Rec_PutIconsCommands (void)
|
|||
bool IAmLoggedAsStudent = (Gbl.Usrs.Me.LoggedRole == Rol_STUDENT); // My current role is student
|
||||
bool IAmLoggedAsTeacher = (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER); // My current role is teacher
|
||||
bool IAmLoggedAsSysAdm = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); // My current role is superuser
|
||||
bool IBelongToCurrentCrs = (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_STUDENT ||
|
||||
Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_TEACHER);
|
||||
bool HeBelongsToCurrentCrs = (Gbl.Record.UsrDat->RoleInCurrentCrsDB == Rol_STUDENT ||
|
||||
Gbl.Record.UsrDat->RoleInCurrentCrsDB == Rol_TEACHER);
|
||||
bool ICanViewAgenda;
|
||||
|
||||
if (!Gbl.Form.Inside && // Only if not inside another form
|
||||
Act_Actions[Gbl.Action.Act].BrowserWindow == Act_THIS_WINDOW && // Only in main window
|
||||
Gbl.Usrs.Me.Logged) // Only if I am logged
|
||||
{
|
||||
/***** Start container *****/
|
||||
fprintf (Gbl.F.Out,"<div class=\"FRAME_ICO\">");
|
||||
|
||||
/***** Button to edit my record card *****/
|
||||
|
@ -2337,39 +2331,34 @@ static void Rec_PutIconsCommands (void)
|
|||
Txt_Edit_my_personal_data,NULL,
|
||||
NULL);
|
||||
|
||||
/***** Button to view user's record card in course when:
|
||||
- a course is selected && the user belongs to it &&
|
||||
- I can view user's record card in course *****/
|
||||
if (HeBelongsToCurrentCrs && (IBelongToCurrentCrs || IAmLoggedAsSysAdm))
|
||||
Lay_PutContextualLink (Gbl.Record.UsrDat->RoleInCurrentCrsDB == Rol_STUDENT ? ActSeeRecOneStd :
|
||||
ActSeeRecOneTch,
|
||||
/***** Button to view user's record card *****/
|
||||
if (Usr_CheckIfICanViewRecordStd (Gbl.Record.UsrDat))
|
||||
/* View student's records: common record card and course record card */
|
||||
Lay_PutContextualLink (ActSeeRecOneStd,
|
||||
Rec_PutParamUsrCodEncrypted,
|
||||
"card64x64.gif",
|
||||
Txt_View_record_for_this_course,NULL,
|
||||
NULL);
|
||||
else if (Usr_CheckIfICanViewRecordTch (Gbl.Record.UsrDat))
|
||||
Lay_PutContextualLink (ActSeeRecOneTch,
|
||||
Rec_PutParamUsrCodEncrypted,
|
||||
"card64x64.gif",
|
||||
Txt_View_record_for_this_course,NULL,
|
||||
NULL);
|
||||
Txt_View_record_and_office_hours,NULL,
|
||||
NULL);
|
||||
|
||||
/***** Button to view user's agenda
|
||||
when I share any course with him/her *****/
|
||||
/***** Button to view user's agenda *****/
|
||||
if (ItsMe)
|
||||
Lay_PutContextualLink (ActSeeMyAgd,
|
||||
NULL,
|
||||
"date64x64.gif",
|
||||
Txt_View_agenda,NULL,
|
||||
NULL);
|
||||
else // Not me
|
||||
{
|
||||
if (!(ICanViewAgenda = (IBelongToCurrentCrs &&
|
||||
HeBelongsToCurrentCrs) || // Course selected and we both belong to it
|
||||
IAmLoggedAsSysAdm)) // I am system admin
|
||||
// The following slow check is made only if the previous fails
|
||||
ICanViewAgenda = Usr_CheckIfUsrSharesAnyOfMyCrs (Gbl.Record.UsrDat->UsrCod);
|
||||
if (ICanViewAgenda)
|
||||
Lay_PutContextualLink (ActSeeUsrAgd,
|
||||
Rec_PutParamUsrCodEncrypted,
|
||||
"date64x64.gif",
|
||||
Txt_View_agenda,NULL,
|
||||
NULL);
|
||||
}
|
||||
else if (Usr_CheckIfICanViewUsrAgenda (Gbl.Record.UsrDat))
|
||||
Lay_PutContextualLink (ActSeeUsrAgd,
|
||||
Rec_PutParamUsrCodEncrypted,
|
||||
"date64x64.gif",
|
||||
Txt_View_agenda,NULL,
|
||||
NULL);
|
||||
|
||||
/***** Button to admin user *****/
|
||||
if (ItsMe ||
|
||||
|
@ -2386,7 +2375,7 @@ static void Rec_PutIconsCommands (void)
|
|||
Txt_Admin_user,NULL,
|
||||
NULL);
|
||||
|
||||
if (Gbl.CurrentCrs.Crs.CrsCod > 0 && // A course is selected
|
||||
if (Gbl.CurrentCrs.Crs.CrsCod > 0 && // A course is selected
|
||||
Gbl.Record.UsrDat->RoleInCurrentCrsDB == Rol_STUDENT && // He/she is a student in the current course
|
||||
(ItsMe || IAmLoggedAsTeacher || IAmLoggedAsSysAdm)) // I can view
|
||||
{
|
||||
|
@ -2448,7 +2437,7 @@ static void Rec_PutIconsCommands (void)
|
|||
else
|
||||
// I do not follow user
|
||||
if (Pri_ShowIsAllowed (Gbl.Record.UsrDat->ProfileVisibility,
|
||||
Gbl.Record.UsrDat->UsrCod))
|
||||
Gbl.Record.UsrDat))
|
||||
// I can view user's profile
|
||||
Lay_PutContextualLink (ActFolUsr,Rec_PutParamUsrCodEncrypted,
|
||||
"follow64x64.png",
|
||||
|
@ -2456,6 +2445,7 @@ static void Rec_PutIconsCommands (void)
|
|||
NULL); // Put button to follow
|
||||
}
|
||||
|
||||
/***** End container *****/
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
}
|
||||
}
|
||||
|
|
23
swad_text.c
23
swad_text.c
|
@ -50381,6 +50381,27 @@ const char *Txt_View_public_profile =
|
|||
"Ver perfil público";
|
||||
#endif
|
||||
|
||||
const char *Txt_View_record_and_office_hours =
|
||||
#if L==1
|
||||
"Veure fitxa i horari de tutories";
|
||||
#elif L==2
|
||||
"Anzeigen profil und Geschäftszeiten";
|
||||
#elif L==3
|
||||
"View record and office hours";
|
||||
#elif L==4
|
||||
"Ver ficha y horario de tutorías";
|
||||
#elif L==5
|
||||
"Voir carte et heures de tuteur";
|
||||
#elif L==6
|
||||
"Ver ficha y horario de tutorías"; // Okoteve traducción
|
||||
#elif L==7
|
||||
"Vedi scheda e orario di tutoraggi";
|
||||
#elif L==8
|
||||
"Zobacz rekord i godziny pracy";
|
||||
#elif L==9
|
||||
"Ver cartão e horário de tutor";
|
||||
#endif
|
||||
|
||||
const char *Txt_View_record_for_this_course =
|
||||
#if L==1
|
||||
"Veure fitxa en aquesta assignatura";
|
||||
|
@ -50399,7 +50420,7 @@ const char *Txt_View_record_for_this_course =
|
|||
#elif L==8
|
||||
"Zobacz rekord na ten kurs";
|
||||
#elif L==9
|
||||
"Meu cartão em disciplina";
|
||||
"Ver cartão em disciplina";
|
||||
#endif
|
||||
|
||||
const char *Txt_View_survey =
|
||||
|
|
120
swad_user.c
120
swad_user.c
|
@ -54,6 +54,7 @@
|
|||
#include "swad_parameter.h"
|
||||
#include "swad_password.h"
|
||||
#include "swad_preference.h"
|
||||
#include "swad_privacy.h"
|
||||
#include "swad_QR.h"
|
||||
#include "swad_record.h"
|
||||
#include "swad_tab.h"
|
||||
|
@ -895,20 +896,127 @@ unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,
|
|||
return NumUsrs;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Check if I can view the record card of a student ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
bool Usr_CheckIfICanViewRecordStd (const struct UsrData *UsrDat)
|
||||
{
|
||||
bool HeIsAStudentInCurrentCrs = UsrDat->RoleInCurrentCrsDB == Rol_STUDENT;
|
||||
bool IBelongToCurrentCrs = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_STUDENT ||
|
||||
Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_TEACHER;
|
||||
bool IAmLoggedAsSysAdm = Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM;
|
||||
|
||||
return HeIsAStudentInCurrentCrs && // Course is selected and user is student in it
|
||||
(IBelongToCurrentCrs || // I am student or teacher in current course
|
||||
IAmLoggedAsSysAdm); // I am logged as system admin
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Check if I can view the record card of a teacher ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
bool Usr_CheckIfICanViewRecordTch (const struct UsrData *UsrDat)
|
||||
{
|
||||
/***** 1. Fast check: Is he/she a teacher in any course? *****/
|
||||
if (!(UsrDat->Roles & (1 << Rol_TEACHER)))
|
||||
return false;
|
||||
|
||||
/***** 2. Fast check: Am I logged? *****/
|
||||
if (!Gbl.Usrs.Me.Logged)
|
||||
return false;
|
||||
|
||||
/***** 3. Fast check: It's me? *****/
|
||||
if (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod)
|
||||
return true;
|
||||
|
||||
/***** 4. Fast check: Am I logged as system admin? *****/
|
||||
if (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
|
||||
return true;
|
||||
|
||||
/***** 5. Slow check: Get if user shares any course with me from database *****/
|
||||
return Usr_CheckIfUsrSharesAnyOfMyCrs (UsrDat);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Check if I can view a user's agenda *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
bool Usr_CheckIfICanViewUsrAgenda (const struct UsrData *UsrDat)
|
||||
{
|
||||
/***** 1. Fast check: Am I logged? *****/
|
||||
if (!Gbl.Usrs.Me.Logged)
|
||||
return false;
|
||||
|
||||
/***** 2. Fast check: It's me? *****/
|
||||
if (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod)
|
||||
return true;
|
||||
|
||||
/***** 3. Fast check: Am I logged as system admin? *****/
|
||||
if (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
|
||||
return true;
|
||||
|
||||
/***** 4. Slow check: Get if user shares any course with me from database *****/
|
||||
return Usr_CheckIfUsrSharesAnyOfMyCrs (UsrDat);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Check if a user belongs to any of my courses ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
bool Usr_CheckIfUsrSharesAnyOfMyCrs (long UsrCod)
|
||||
bool Usr_CheckIfUsrSharesAnyOfMyCrs (const struct UsrData *UsrDat)
|
||||
{
|
||||
char Query[256];
|
||||
bool IBelongToCurrentCrs;
|
||||
bool HeBelongsToCurrentCrs;
|
||||
static struct
|
||||
{
|
||||
long UsrCodChecked;
|
||||
bool UsrSharesAnyOfMyCrs;
|
||||
} Cached =
|
||||
{
|
||||
-1L,
|
||||
false
|
||||
}; // A cache. If this function is called consecutive times
|
||||
// with the same user, only the first time is slow
|
||||
|
||||
/***** Get if a user shares any course with me from database *****/
|
||||
/***** 1. Fast check: Am I logged? *****/
|
||||
if (!Gbl.Usrs.Me.Logged)
|
||||
return false;
|
||||
|
||||
/***** 2. Fast check: It is a valid user code? *****/
|
||||
if (UsrDat->UsrCod <= 0)
|
||||
return false;
|
||||
|
||||
/***** 3. Fast check: It's me? *****/
|
||||
if (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod)
|
||||
return true;
|
||||
|
||||
/***** 4. Fast check: Does he/she belong to any course? *****/
|
||||
if (!(UsrDat->Roles & (1 << Rol_STUDENT ||
|
||||
1 << Rol_TEACHER)))
|
||||
return false;
|
||||
|
||||
/***** 5. Fast check: Is course selected and we both belong to it? *****/
|
||||
IBelongToCurrentCrs = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_STUDENT ||
|
||||
Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_TEACHER;
|
||||
HeBelongsToCurrentCrs = UsrDat->RoleInCurrentCrsDB == Rol_STUDENT ||
|
||||
UsrDat->RoleInCurrentCrsDB == Rol_TEACHER;
|
||||
if (IBelongToCurrentCrs && HeBelongsToCurrentCrs) // Course selected and we both belong to it
|
||||
return true;
|
||||
|
||||
/***** 6. Fast check: Is already calculated if user shares any course with me? *****/
|
||||
if (UsrDat->UsrCod == Cached.UsrCodChecked)
|
||||
return Cached.UsrSharesAnyOfMyCrs;
|
||||
|
||||
/***** 5. Slow check: Get if user shares any course with me from database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM crs_usr"
|
||||
" WHERE UsrCod='%ld'"
|
||||
" AND CrsCod IN (SELECT CrsCod FROM my_courses_tmp)",
|
||||
UsrCod);
|
||||
return (DB_QueryCOUNT (Query,"can not check if a user shares any course with you") != 0);
|
||||
UsrDat->UsrCod);
|
||||
Cached.UsrSharesAnyOfMyCrs = DB_QueryCOUNT (Query,"can not check if a user shares any course with you") != 0;
|
||||
Cached.UsrCodChecked = UsrDat->UsrCod;
|
||||
return Cached.UsrSharesAnyOfMyCrs;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -920,6 +1028,10 @@ bool Usr_CheckIfUsrSharesAnyOfMyCrsWithDifferentRole (long UsrCod)
|
|||
char Query[512];
|
||||
bool UsrSharesAnyOfMyCrsWithDifferentRole;
|
||||
|
||||
/***** 1. Fast check: Am I logged? *****/
|
||||
if (!Gbl.Usrs.Me.Logged)
|
||||
return false;
|
||||
|
||||
/***** Remove temporary table if exists *****/
|
||||
sprintf (Query,"DROP TEMPORARY TABLE IF EXISTS usr_courses_tmp");
|
||||
if (mysql_query (&Gbl.mysql,Query))
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "swad_layout.h"
|
||||
#include "swad_menu.h"
|
||||
#include "swad_nickname.h"
|
||||
#include "swad_privacy.h"
|
||||
#include "swad_privacy_visibility_type.h"
|
||||
#include "swad_role.h"
|
||||
#include "swad_scope.h"
|
||||
#include "swad_search.h"
|
||||
|
@ -232,7 +232,11 @@ unsigned Usr_GetNumCrssOfUsrWithARoleNotAccepted (long UsrCod,Rol_Role_t Role);
|
|||
|
||||
unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,
|
||||
Rol_Role_t OthersRole);
|
||||
bool Usr_CheckIfUsrSharesAnyOfMyCrs (long UsrCod);
|
||||
|
||||
bool Usr_CheckIfICanViewRecordStd (const struct UsrData *UsrDat);
|
||||
bool Usr_CheckIfICanViewRecordTch (const struct UsrData *UsrDat);
|
||||
bool Usr_CheckIfICanViewUsrAgenda (const struct UsrData *UsrDat);
|
||||
bool Usr_CheckIfUsrSharesAnyOfMyCrs (const struct UsrData *UsrDat);
|
||||
bool Usr_CheckIfUsrSharesAnyOfMyCrsWithDifferentRole (long UsrCod);
|
||||
|
||||
void Usr_GetMyCountrs (void);
|
||||
|
|
Loading…
Reference in New Issue