diff --git a/swad_changelog.h b/swad_changelog.h index fa12eee02..f60af462c 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -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); diff --git a/swad_connected.c b/swad_connected.c index f76a36d0f..08e4bb908 100644 --- a/swad_connected.c +++ b/swad_connected.c @@ -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: diff --git a/swad_file_browser.c b/swad_file_browser.c index 88061ac91..de66e021d 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -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 (), diff --git a/swad_forum.c b/swad_forum.c index a652fa4e5..e306a4c28 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -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); } diff --git a/swad_global.c b/swad_global.c index bdb614cb7..3f624eab3 100644 --- a/swad_global.c +++ b/swad_global.c @@ -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 diff --git a/swad_global.h b/swad_global.h index 3af288482..c67ffc588 100644 --- a/swad_global.h +++ b/swad_global.h @@ -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]; diff --git a/swad_message.c b/swad_message.c index 12078c426..d93bb739c 100644 --- a/swad_message.c +++ b/swad_message.c @@ -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) "%s:", Colspan,Txt_Other_recipients); else @@ -384,7 +386,8 @@ void Msg_WriteFormUsrsIDsOrNicksOtherRecipients (bool IsReply) "" "" "