mirror of https://github.com/acanas/swad-core.git
Version 14.62.1
This commit is contained in:
parent
b67123091a
commit
13c0639822
|
@ -44,6 +44,7 @@
|
|||
// 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 | tail -1
|
||||
/*
|
||||
Version 14.62.1: Jan 20, 2015 See/admin documents of degree, centre and institution (not finished). (175371 lines)
|
||||
Version 14.62: Jan 20, 2015 See/admin documents of degree, centre and institution (not finished). (175296 lines)
|
||||
3 changes necessary in database:
|
||||
ALTER TABLE expanded_folders ADD COLUMN InsCod INT NOT NULL DEFAULT -1 AFTER FileBrowser, ADD INDEX (InsCod);
|
||||
|
|
|
@ -488,7 +488,8 @@ static void Con_ComputeConnectedUsrsOfTypeBelongingToCurrentCrs (Rol_Role_t Role
|
|||
}
|
||||
|
||||
/***** List connected users belonging to this course *****/
|
||||
if (Gbl.Usrs.Me.IHaveAccessToCurrentCrs) // If I belongs to this course or I am superuser
|
||||
if (Gbl.Usrs.Me.IBelongToCurrentCrs ||
|
||||
Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER)
|
||||
Con_ComputeConnectedUsrsWithARoleCurrentCrsOneByOne (Role);
|
||||
}
|
||||
|
||||
|
@ -530,7 +531,8 @@ static void Con_ShowConnectedUsrsWithARoleBelongingToCurrentLocationOnMainZone (
|
|||
return;
|
||||
break;
|
||||
case Sco_SCOPE_COURSE: // Show connected users in the current course
|
||||
if (!Gbl.Usrs.Me.IHaveAccessToCurrentCrs)
|
||||
if (!(Gbl.Usrs.Me.IBelongToCurrentCrs ||
|
||||
Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER))
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
|
@ -598,7 +600,8 @@ static void Con_ShowConnectedUsrsWithARoleBelongingToCurrentLocationOnRightColum
|
|||
return;
|
||||
break;
|
||||
case Sco_SCOPE_COURSE: // Show connected users in the current course
|
||||
if (!Gbl.Usrs.Me.IHaveAccessToCurrentCrs)
|
||||
if (!(Gbl.Usrs.Me.IBelongToCurrentCrs ||
|
||||
Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER))
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -1845,8 +1845,30 @@ void Brw_GetParAndInitFileBrowser (void)
|
|||
/***** Get whether to show full tree *****/
|
||||
// If I belong to the current course or I am superuser, or file browser is briefcase ==> get whether show full tree from form
|
||||
// Else ==> show full tree (only public files)
|
||||
Gbl.FileBrowser.ShowOnlyPublicFiles = (Gbl.FileBrowser.Type != Brw_FILE_BRW_BRIEFCASE_USR &&
|
||||
!Gbl.Usrs.Me.IHaveAccessToCurrentCrs);
|
||||
Gbl.FileBrowser.ShowOnlyPublicFiles = false;
|
||||
if (Gbl.Usrs.Me.LoggedRole != Rol_ROLE_SUPERUSER)
|
||||
switch (Gbl.FileBrowser.Type)
|
||||
{
|
||||
case Brw_FILE_BRW_SEE_DOCUMENTS_INS:
|
||||
case Brw_FILE_BRW_ADMIN_DOCUMENTS_INS:
|
||||
Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrentIns;
|
||||
break;
|
||||
case Brw_FILE_BRW_SEE_DOCUMENTS_CTR:
|
||||
case Brw_FILE_BRW_ADMIN_DOCUMENTS_CTR:
|
||||
Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrentCtr;
|
||||
break;
|
||||
case Brw_FILE_BRW_SEE_DOCUMENTS_DEG:
|
||||
case Brw_FILE_BRW_ADMIN_DOCUMENTS_DEG:
|
||||
Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrentDeg;
|
||||
break;
|
||||
case Brw_FILE_BRW_SEE_DOCUMENTS_CRS:
|
||||
case Brw_FILE_BRW_ADMIN_DOCUMENTS_CRS:
|
||||
case Brw_FILE_BRW_COMMON_CRS:
|
||||
Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrentCrs;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Gbl.FileBrowser.FullTree = Gbl.FileBrowser.ShowOnlyPublicFiles ? true :
|
||||
Brw_GetFullTreeFromForm ();
|
||||
|
||||
|
@ -3004,11 +3026,11 @@ static void Brw_ShowFileBrowser (void)
|
|||
Brw_TitleOfFileBrowser[Brw_FILE_BRW_ASSIGNMENTS_USR ] = Txt_Assignments_zone; // Brw_FILE_BRW_ASSIGNMENTS_USR
|
||||
Brw_TitleOfFileBrowser[Brw_FILE_BRW_ASSIGNMENTS_CRS ] = Txt_Assignments_zone; // Brw_FILE_BRW_ASSIGNMENTS_CRS
|
||||
Brw_TitleOfFileBrowser[Brw_FILE_BRW_SEE_DOCUMENTS_DEG ] = Txt_Documents_zone; // Brw_FILE_BRW_SEE_DOCUMENTS_DEG // TODO: Set the correct text
|
||||
Brw_TitleOfFileBrowser[Brw_FILE_BRW_ADMIN_DOCUMENTS_DEG] = Txt_Documents_zone; // Brw_FILE_BRW_ADMIN_DOCUMENTS_DEG // TODO: Set the correct text
|
||||
Brw_TitleOfFileBrowser[Brw_FILE_BRW_ADMIN_DOCUMENTS_DEG] = Txt_Documents_management_zone; // Brw_FILE_BRW_ADMIN_DOCUMENTS_DEG // TODO: Set the correct text
|
||||
Brw_TitleOfFileBrowser[Brw_FILE_BRW_SEE_DOCUMENTS_CTR ] = Txt_Documents_zone; // Brw_FILE_BRW_SEE_DOCUMENTS_CTR // TODO: Set the correct text
|
||||
Brw_TitleOfFileBrowser[Brw_FILE_BRW_ADMIN_DOCUMENTS_CTR] = Txt_Documents_zone; // Brw_FILE_BRW_ADMIN_DOCUMENTS_CTR // TODO: Set the correct text
|
||||
Brw_TitleOfFileBrowser[Brw_FILE_BRW_ADMIN_DOCUMENTS_CTR] = Txt_Documents_management_zone; // Brw_FILE_BRW_ADMIN_DOCUMENTS_CTR // TODO: Set the correct text
|
||||
Brw_TitleOfFileBrowser[Brw_FILE_BRW_SEE_DOCUMENTS_INS ] = Txt_Documents_zone; // Brw_FILE_BRW_SEE_DOCUMENTS_INS // TODO: Set the correct text
|
||||
Brw_TitleOfFileBrowser[Brw_FILE_BRW_ADMIN_DOCUMENTS_INS] = Txt_Documents_zone; // Brw_FILE_BRW_ADMIN_DOCUMENTS_INS // TODO: Set the correct text
|
||||
Brw_TitleOfFileBrowser[Brw_FILE_BRW_ADMIN_DOCUMENTS_INS] = Txt_Documents_management_zone; // Brw_FILE_BRW_ADMIN_DOCUMENTS_INS // TODO: Set the correct text
|
||||
|
||||
/***** Check if the maximum quota has been exceeded *****/
|
||||
if (Brw_FileBrowserIsEditable[Gbl.FileBrowser.Type])
|
||||
|
@ -4040,11 +4062,11 @@ static bool Brw_WriteRowFileBrowser (unsigned Level,
|
|||
|
||||
/***** Get file metadata *****/
|
||||
Brw_GetFileMetadataByPath (&FileMetadata);
|
||||
Brw_GetFileSizeAndDate (&FileMetadata);
|
||||
if (FileMetadata.FilCod <= 0) // No entry for this file in database table of files
|
||||
/* Add entry to the table of files/folders */
|
||||
FileMetadata.FilCod = Brw_AddPathToDB (-1L,FileMetadata.FileType,
|
||||
Gbl.FileBrowser.Priv.FullPathInTree,false,Brw_LICENSE_DEFAULT);
|
||||
Brw_GetFileSizeAndDate (&FileMetadata);
|
||||
|
||||
/***** Is this row public or private? *****/
|
||||
if (SeeDocsZone || AdminDocsZone || CommonZone)
|
||||
|
@ -8063,9 +8085,13 @@ bool Brw_CheckIfFileOrFolderIsSetAsHiddenInDB (Brw_FileType_t FileType,const cha
|
|||
|
||||
/***** Get if a file or folder is hidden from database *****/
|
||||
sprintf (Query,"SELECT Hidden FROM files"
|
||||
" WHERE CrsCod='%ld' AND GrpCod='%ld' AND ZoneUsrCod='%ld'"
|
||||
" WHERE InsCod='%ld' AND CtrCod='%ld' AND DegCod='%ld'"
|
||||
" AND CrsCod='%ld' AND GrpCod='%ld' AND ZoneUsrCod='%ld'"
|
||||
" AND FileBrowser='%u'"
|
||||
" AND Path='%s'",
|
||||
Brw_GetInsCod (),
|
||||
Brw_GetCtrCod (),
|
||||
Brw_GetDegCod (),
|
||||
Brw_GetCrsCod (),
|
||||
Brw_GetGrpCod (),
|
||||
Brw_GetZoneUsrCod (),
|
||||
|
@ -8105,8 +8131,8 @@ bool Brw_CheckIfFileOrFolderIsHidden (struct FileMetadata *FileMetadata)
|
|||
2) the argument Path begins by 'x/', where x is a path stored in database
|
||||
*/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM files"
|
||||
" WHERE InsCod='%ld' AND CtrCod='%ld' AND DegCod='%ld' AND CrsCod='%ld'"
|
||||
" AND GrpCod='%ld' AND ZoneUsrCod='%ld'"
|
||||
" WHERE InsCod='%ld' AND CtrCod='%ld' AND DegCod='%ld'"
|
||||
" AND CrsCod='%ld' AND GrpCod='%ld' AND ZoneUsrCod='%ld'"
|
||||
" AND FileBrowser='%u' AND Hidden='Y'"
|
||||
" AND (Path='%s' OR LOCATE(CONCAT(Path,'/'),'%s')=1)",
|
||||
FileMetadata->InsCod,
|
||||
|
@ -8233,6 +8259,9 @@ void Brw_ShowFileMetadata (void)
|
|||
Act_FormStart (Brw_ActRecDatFile[Gbl.FileBrowser.Type]);
|
||||
switch (Gbl.FileBrowser.Type)
|
||||
{
|
||||
case Brw_FILE_BRW_ADMIN_DOCUMENTS_INS:
|
||||
case Brw_FILE_BRW_ADMIN_DOCUMENTS_CTR:
|
||||
case Brw_FILE_BRW_ADMIN_DOCUMENTS_DEG:
|
||||
case Brw_FILE_BRW_ADMIN_DOCUMENTS_CRS:
|
||||
case Brw_FILE_BRW_COMMON_CRS:
|
||||
ICanChangePublic = true;
|
||||
|
@ -9518,8 +9547,12 @@ static bool Brw_GetIfFolderHasPublicFiles (const char *Path)
|
|||
|
||||
/***** Get if a file or folder is public from database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM files"
|
||||
" WHERE CrsCod='%ld' AND GrpCod='%ld' AND ZoneUsrCod='%ld'"
|
||||
" WHERE InsCod='%ld' AND CtrCod='%ld' AND DegCod='%ld'"
|
||||
" AND CrsCod='%ld' AND GrpCod='%ld' AND ZoneUsrCod='%ld'"
|
||||
" AND FileBrowser='%u' AND Path LIKE '%s/%%' AND Public='Y'",
|
||||
Brw_GetInsCod (),
|
||||
Brw_GetCtrCod (),
|
||||
Brw_GetDegCod (),
|
||||
Brw_GetCrsCod (),
|
||||
Brw_GetGrpCod (),
|
||||
Brw_GetZoneUsrCod (),
|
||||
|
@ -9761,10 +9794,13 @@ long Brw_AddPathToDB (long PublisherUsrCod,Brw_FileType_t FileType,
|
|||
char Query[512+PATH_MAX];
|
||||
|
||||
/***** Add path to the database *****/
|
||||
sprintf (Query,"INSERT INTO files (CrsCod,GrpCod,ZoneUsrCod,FileBrowser,"
|
||||
sprintf (Query,"INSERT INTO files (InsCod,CtrCod,DegCod,CrsCod,GrpCod,ZoneUsrCod,FileBrowser,"
|
||||
"PublisherUsrCod,FileType,Path,Hidden,Public,License)"
|
||||
" VALUES ('%ld','%ld','%ld','%u',"
|
||||
" VALUES ('%ld','%ld','%ld','%ld','%ld','%ld','%u',"
|
||||
"'%ld','%u','%s','N','%c','%u')",
|
||||
Brw_GetInsCod (),
|
||||
Brw_GetCtrCod (),
|
||||
Brw_GetDegCod (),
|
||||
Brw_GetCrsCod (),
|
||||
Brw_GetGrpCod (),
|
||||
Brw_GetZoneUsrCod (),
|
||||
|
|
|
@ -1645,7 +1645,8 @@ void For_ShowForumList (void)
|
|||
if (ICanSeeDegForum)
|
||||
/***** Links to forums of current degree *****/
|
||||
if (For_WriteLinksToDegForums (Gbl.CurrentDeg.Deg.DegCod,true,IsLastItemInLevel) > 0)
|
||||
if (Gbl.Usrs.Me.IHaveAccessToCurrentCrs)
|
||||
if (Gbl.Usrs.Me.IBelongToCurrentCrs ||
|
||||
Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER)
|
||||
/***** Links to forums of current degree *****/
|
||||
For_WriteLinksToCrsForums (Gbl.CurrentCrs.Crs.CrsCod,true,IsLastItemInLevel);
|
||||
}
|
||||
|
|
|
@ -159,8 +159,10 @@ void Gbl_InitializeGlobals (void)
|
|||
Gbl.Usrs.Me.LoggedRole =
|
||||
Gbl.Usrs.Me.LoggedRoleBeforeCloseSession =
|
||||
Gbl.Usrs.Me.MaxRole = Rol_ROLE_UNKNOWN;
|
||||
Gbl.Usrs.Me.IBelongToCurrentIns = false;
|
||||
Gbl.Usrs.Me.IBelongToCurrentCtr = false;
|
||||
Gbl.Usrs.Me.IBelongToCurrentDeg = false;
|
||||
Gbl.Usrs.Me.IBelongToCurrentCrs = false;
|
||||
Gbl.Usrs.Me.IHaveAccessToCurrentCrs = false;
|
||||
Gbl.Usrs.Me.MyPhotoExists = false;
|
||||
Gbl.Usrs.Me.NumAccWithoutPhoto = 0;
|
||||
Gbl.Usrs.Me.TimeLastAccToThisFileBrowser = LONG_MAX; // Initialized to a big value, so by default files are not shown as recent or new
|
||||
|
|
|
@ -278,8 +278,10 @@ struct Globals
|
|||
char PendingPassword[Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64+1];
|
||||
char PathDir[PATH_MAX+1];
|
||||
bool Logged;
|
||||
bool IBelongToCurrentIns;
|
||||
bool IBelongToCurrentCtr;
|
||||
bool IBelongToCurrentDeg;
|
||||
bool IBelongToCurrentCrs;
|
||||
bool IHaveAccessToCurrentCrs;
|
||||
bool MyPhotoExists;
|
||||
unsigned NumAccWithoutPhoto;
|
||||
char PhotoURL[PATH_MAX+1];
|
||||
|
|
|
@ -269,7 +269,8 @@ static void Msg_PutFormMsgUsrs (const char *Content)
|
|||
Usr_GetParamOtherUsrCodEncrypted ();
|
||||
|
||||
/***** Get list of users belonging to the current course *****/
|
||||
if (Gbl.Usrs.Me.IHaveAccessToCurrentCrs) // If there is a course selected and I belong to it
|
||||
if (Gbl.Usrs.Me.IBelongToCurrentCrs || // If there is a course selected and I belong to it
|
||||
Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER)
|
||||
{
|
||||
/***** Get and update type of list, number of columns in class photo
|
||||
and preference about view photos *****/
|
||||
|
@ -372,7 +373,8 @@ void Msg_WriteFormUsrsIDsOrNicksOtherRecipients (bool IsReply)
|
|||
"<td class=\"TIT_TBL\" style=\"text-align:left;"
|
||||
" background-color:%s;\"",
|
||||
VERY_LIGHT_BLUE);
|
||||
if (Gbl.Usrs.Me.IHaveAccessToCurrentCrs)
|
||||
if (Gbl.Usrs.Me.IBelongToCurrentCrs || // If there is a course selected and I belong to it
|
||||
Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER)
|
||||
fprintf (Gbl.F.Out," colspan=\"%u\">%s:",
|
||||
Colspan,Txt_Other_recipients);
|
||||
else
|
||||
|
@ -384,7 +386,8 @@ void Msg_WriteFormUsrsIDsOrNicksOtherRecipients (bool IsReply)
|
|||
"<tr>"
|
||||
"<td",
|
||||
Txt_nicks_emails_or_IDs_separated_by_commas);
|
||||
if (Gbl.Usrs.Me.IHaveAccessToCurrentCrs)
|
||||
if (Gbl.Usrs.Me.IBelongToCurrentCrs || // If there is a course selected and I belong to it
|
||||
Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER)
|
||||
fprintf (Gbl.F.Out," colspan=\"%u\"",Colspan);
|
||||
fprintf (Gbl.F.Out," style=\"text-align:left;\">"
|
||||
"<textarea name=\"OtherRecipients\" cols=\"72\" rows=\"2\">");
|
||||
|
|
|
@ -131,8 +131,10 @@ void Ses_CloseSession (void)
|
|||
/***** Now, user is not logged in *****/
|
||||
Gbl.Usrs.Me.LoggedRoleBeforeCloseSession = Gbl.Usrs.Me.LoggedRole;
|
||||
Gbl.Usrs.Me.Logged = false;
|
||||
Gbl.Usrs.Me.IBelongToCurrentIns = false;
|
||||
Gbl.Usrs.Me.IBelongToCurrentCtr = false;
|
||||
Gbl.Usrs.Me.IBelongToCurrentDeg = false;
|
||||
Gbl.Usrs.Me.IBelongToCurrentCrs = false;
|
||||
Gbl.Usrs.Me.IHaveAccessToCurrentCrs = false;
|
||||
Gbl.Usrs.Me.LoggedRole = Rol_ROLE_UNKNOWN; // Don't uncomment this line. Don't change the role to unknown. Keep user's role in order to log the access
|
||||
Gbl.Usrs.Me.MyCourses.Filled = false;
|
||||
Gbl.Usrs.Me.MyCourses.Num = 0;
|
||||
|
|
47
swad_user.c
47
swad_user.c
|
@ -2247,6 +2247,43 @@ static void Usr_SetUsrRoleAndPrefs (void)
|
|||
/***** Check if I belong to current course *****/
|
||||
if (Gbl.CurrentCrs.Crs.CrsCod > 0)
|
||||
Gbl.Usrs.Me.IBelongToCurrentCrs = Usr_CheckIfIBelongToCrs (Gbl.CurrentCrs.Crs.CrsCod);
|
||||
else
|
||||
Gbl.Usrs.Me.IBelongToCurrentCrs = false;
|
||||
if (Gbl.Usrs.Me.IBelongToCurrentCrs)
|
||||
Gbl.Usrs.Me.UsrDat.Accepted = Usr_GetIfUserHasAcceptedEnrollmentInCurrentCrs (Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
|
||||
/***** Check if I belong to current degree *****/
|
||||
if (Gbl.CurrentDeg.Deg.DegCod > 0)
|
||||
{
|
||||
if (Gbl.Usrs.Me.IBelongToCurrentCrs)
|
||||
Gbl.Usrs.Me.IBelongToCurrentDeg = true;
|
||||
else
|
||||
Gbl.Usrs.Me.IBelongToCurrentDeg = Usr_CheckIfIBelongToDeg (Gbl.CurrentDeg.Deg.DegCod);
|
||||
}
|
||||
else
|
||||
Gbl.Usrs.Me.IBelongToCurrentDeg = false;
|
||||
|
||||
/***** Check if I belong to current centre *****/
|
||||
if (Gbl.CurrentCtr.Ctr.CtrCod > 0)
|
||||
{
|
||||
if (Gbl.Usrs.Me.IBelongToCurrentDeg)
|
||||
Gbl.Usrs.Me.IBelongToCurrentCtr = true;
|
||||
else
|
||||
Gbl.Usrs.Me.IBelongToCurrentCtr = Usr_CheckIfIBelongToCtr (Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
}
|
||||
else
|
||||
Gbl.Usrs.Me.IBelongToCurrentCtr = false;
|
||||
|
||||
/***** Check if I belong to current institution *****/
|
||||
if (Gbl.CurrentIns.Ins.InsCod > 0)
|
||||
{
|
||||
if (Gbl.Usrs.Me.IBelongToCurrentCtr)
|
||||
Gbl.Usrs.Me.IBelongToCurrentIns = true;
|
||||
else
|
||||
Gbl.Usrs.Me.IBelongToCurrentIns = Usr_CheckIfIBelongToIns (Gbl.CurrentIns.Ins.InsCod);
|
||||
}
|
||||
else
|
||||
Gbl.Usrs.Me.IBelongToCurrentIns = false;
|
||||
|
||||
/***** Build my list of available roles for current course *****/
|
||||
if (Gbl.CurrentCrs.Crs.CrsCod > 0)
|
||||
|
@ -2281,16 +2318,6 @@ static void Usr_SetUsrRoleAndPrefs (void)
|
|||
Gbl.Usrs.Me.LoggedRole++)
|
||||
if (Gbl.Usrs.Me.AvailableRoles & (1 << Gbl.Usrs.Me.LoggedRole))
|
||||
break;
|
||||
|
||||
/***** Set other variables related with my user's type *****/
|
||||
if (Gbl.CurrentCrs.Crs.CrsCod > 0)
|
||||
{
|
||||
Gbl.Usrs.Me.IHaveAccessToCurrentCrs = ((Gbl.Usrs.Me.IBelongToCurrentCrs && (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_STUDENT ||
|
||||
Gbl.Usrs.Me.LoggedRole == Rol_ROLE_TEACHER)) ||
|
||||
Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER);
|
||||
if (Gbl.Usrs.Me.IBelongToCurrentCrs)
|
||||
Gbl.Usrs.Me.UsrDat.Accepted = Usr_GetIfUserHasAcceptedEnrollmentInCurrentCrs (Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
Loading…
Reference in New Issue