swad-core/swad_browser_database.h

114 lines
5.7 KiB
C
Raw Normal View History

// swad_browser_database.h: file browsers operations with database
#ifndef _SWAD_BROWSER_DATABASE
#define _SWAD_BROWSER_DATABASE
/*
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-2021 Antonio Ca<EFBFBD>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 ***********************************/
/*****************************************************************************/
// #include <linux/limits.h> // For PATH_MAX
#include <mysql/mysql.h> // To access MySQL databases
#include "swad_browser.h"
// #include "swad_course.h"
// #include "swad_group.h"
// #include "swad_notification.h"
/*****************************************************************************/
/************************ Public types and constants *************************/
/*****************************************************************************/
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Public prototypes *****************************/
/*****************************************************************************/
//---------------------------------- Files ------------------------------------
long Brw_DB_GetFilCodByPath (const char *Path,bool OnlyIfPublic);
unsigned Brw_DB_GetFileMetadataByPath (MYSQL_RES **mysql_res,const char *Path);
unsigned Brw_DB_GetFileMetadataByCod (MYSQL_RES **mysql_res,long FilCod);
unsigned Brw_DB_GetNumFilesUsr (long UsrCod);
void Brw_DB_RemoveInsFiles (long InsCod);
void Brw_DB_RemoveCtrFiles (long CtrCod);
void Brw_DB_RemoveDegFiles (long DegCod);
void Brw_DB_RemoveCrsFiles (long CrsCod);
void Brw_DB_RemoveGrpFiles (long GrpCod);
void Brw_DB_RemovePrjFiles (long PrjCod);
void Brw_DB_RemoveSomeInfoAboutCrsUsrFiles (long UsrCod,long CrsCod);
void Brw_DB_RemoveWrkFiles (long CrsCod,long UsrCod);
void Brw_DB_RemoveUsrFiles (long UsrCod);
//------------------------------ Public files ---------------------------------
bool Brw_DB_GetIfFolderHasPublicFiles (const char Path[PATH_MAX + 1]);
unsigned Brw_DB_GetNumPublicFilesUsr (long UsrCod);
unsigned Brw_DB_GetNumberOfPublicFiles (MYSQL_RES **mysql_res,Brw_License_t License);
//------------------------------- Assignments ---------------------------------
unsigned Brw_DB_GetFoldersAssignments (MYSQL_RES **mysql_res,long ZoneUsrCod);
//--------------------- My last access to file browsers -----------------------
void Brw_DB_UpdateDateMyLastAccFileBrowser (void);
unsigned Brw_DB_GetDateMyLastAccFileBrowser (MYSQL_RES **mysql_res);
unsigned Brw_DB_GetGrpLastAccFileBrowser (MYSQL_RES **mysql_res,const char *FieldNameDB);
//-------------------------------- File views ---------------------------------
void Brw_DB_UpdateFileViews (unsigned NumViews,long FilCod);
unsigned Brw_DB_GetFileViewsFromMe (MYSQL_RES **mysql_res,long FilCod);
unsigned Brw_DB_GetFileViewsFromLoggedUsrs (MYSQL_RES **mysql_res,long FilCod);
unsigned Brw_DB_GetFileViewsFromNonLoggedUsrs (long FilCod);
unsigned Brw_DB_GetNumFileViewsUsr (long UsrCod);
//------------------------------- Hidden files --------------------------------
unsigned Brw_DB_CheckIfFileOrFolderIsSetAsHiddenUsingPath (MYSQL_RES **mysql_res,
const char *Path);
bool Brw_DB_CheckIfFileOrFolderIsSetAsHiddenUsingMetadata (const struct FileMetadata *FileMetadata);
//---------------------------- Expanded folders -------------------------------
void Brw_DB_InsertFolderInExpandedFolders (const char Path[PATH_MAX + 1]);
void Brw_DB_UpdateClickTimeOfThisFileBrowserInExpandedFolders (void);
bool Brw_DB_GetIfExpandedFolder (const char Path[PATH_MAX + 1]);
void Brw_DB_RemoveFolderFromExpandedFolders (const char Path[PATH_MAX + 1]);
void Brw_DB_RemoveAffectedExpandedFolders (const char Path[PATH_MAX + 1]);
void Brw_DB_RenameAffectedExpandedFolders (Brw_FileBrowser_t FileBrowser,
long MyUsrCod,long WorksUsrCod,
const char *OldPath,const char *NewPath);
//------------------------------- Cliboards -----------------------------------
void Brw_DB_AddPathToClipboards (void);
void Brw_DB_UpdatePathInClipboard (void);
unsigned Brw_DB_GetMyClipboard (MYSQL_RES **mysql_res);
void Brw_DB_RemoveExpiredClipboards (void);
void Brw_DB_RemoveAffectedClipboards (Brw_FileBrowser_t FileBrowser,
long MyUsrCod,long WorksUsrCod);
//-------------------------- Size of file zones -------------------------------
void Brw_DB_StoreSizeOfFileZone (void);
void Brw_DB_GetSizeOfFileBrowser (MYSQL_RES **mysql_res,
Brw_FileBrowser_t FileBrowser);
#endif