Version 14.67

This commit is contained in:
Antonio Cañas Vargas 2015-01-25 00:58:21 +01:00
parent d07472ae74
commit 2296f89ac1
8 changed files with 374 additions and 423 deletions

View File

@ -489,13 +489,9 @@ CREATE TABLE IF NOT EXISTS file_view (
-- --
CREATE TABLE IF NOT EXISTS files ( CREATE TABLE IF NOT EXISTS files (
FilCod INT NOT NULL AUTO_INCREMENT, FilCod INT NOT NULL AUTO_INCREMENT,
InsCod INT NOT NULL DEFAULT -1,
CtrCod INT NOT NULL DEFAULT -1,
DegCod INT NOT NULL DEFAULT -1,
CrsCod INT NOT NULL DEFAULT -1,
GrpCod INT NOT NULL DEFAULT -1,
ZoneUsrCod INT NOT NULL DEFAULT -1,
FileBrowser TINYINT NOT NULL, FileBrowser TINYINT NOT NULL,
Cod INT NOT NULL DEFAULT -1,
ZoneUsrCod INT NOT NULL DEFAULT -1,
PublisherUsrCod INT NOT NULL, PublisherUsrCod INT NOT NULL,
FileType TINYINT NOT NULL DEFAULT 0, FileType TINYINT NOT NULL DEFAULT 0,
Path TEXT COLLATE latin1_bin NOT NULL, Path TEXT COLLATE latin1_bin NOT NULL,
@ -503,7 +499,8 @@ CREATE TABLE IF NOT EXISTS files (
Public ENUM('N','Y') NOT NULL DEFAULT 'N', Public ENUM('N','Y') NOT NULL DEFAULT 'N',
License TINYINT NOT NULL DEFAULT 0, License TINYINT NOT NULL DEFAULT 0,
UNIQUE INDEX(FilCod), UNIQUE INDEX(FilCod),
INDEX(InsCod,CtrCod,DegCod,CrsCod,GrpCod,ZoneUsrCod,FileBrowser), INDEX(FileBrowser,Cod,ZoneUsrCod),
INDEX(ZoneUsrCod),
INDEX(PublisherUsrCod)); INDEX(PublisherUsrCod));
-- --
-- Table forum_disabled_post: stores the forum post that have been disabled -- Table forum_disabled_post: stores the forum post that have been disabled

View File

@ -39,11 +39,30 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 14.66.1 (2015/01/24)" #define Log_PLATFORM_VERSION "SWAD 14.67 (2015/01/25)"
// Number of lines (includes comments but not blank lines) has been got with the following command: // 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 // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h | tail -1
/* /*
Version 14.67: Jan 25, 2015 Changes in files table. (175369 lines)
16 changes necessary in database:
ALTER TABLE files ADD COLUMN ZoneUsrCod2 INT NOT NULL DEFAULT -1 AFTER FileBrowser;
UPDATE files SET ZoneUsrCod2=ZoneUsrCod;
ALTER TABLE files DROP COLUMN ZoneUsrCod;
ALTER TABLE files CHANGE COLUMN ZoneUsrCod2 ZoneUsrCod INT NOT NULL DEFAULT -1;
ALTER TABLE files ADD COLUMN Cod INT NOT NULL DEFAULT -1 AFTER FileBrowser, ADD INDEX (FileBrowser,Cod,ZoneUsrCod);
CREATE INDEX ZoneUsrCod ON files (ZoneUsrCod);
UPDATE files SET Cod=InsCod WHERE InsCod>'0';
UPDATE files SET Cod=CtrCod WHERE CtrCod>'0';
UPDATE files SET Cod=DegCod WHERE DegCod>'0';
UPDATE files SET Cod=CrsCod WHERE CrsCod>'0';
UPDATE files SET Cod=GrpCod WHERE GrpCod>'0';
ALTER TABLE files DROP COLUMN InsCod;
ALTER TABLE files DROP COLUMN CtrCod;
ALTER TABLE files DROP COLUMN DegCod;
ALTER TABLE files DROP COLUMN CrsCod;
ALTER TABLE files DROP COLUMN GrpCod;
Version 14.66.1: Jan 24, 2015 Fixed bug in clipboard. (175404 lines) Version 14.66.1: Jan 24, 2015 Fixed bug in clipboard. (175404 lines)
Version 14.66: Jan 24, 2015 Changes in clipboard table. (175401 lines) Version 14.66: Jan 24, 2015 Changes in clipboard table. (175401 lines)
13 changes necessary in database: 13 changes necessary in database:

View File

@ -1039,13 +1039,9 @@ mysql> DESCRIBE files;
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+-----------------+---------------+------+-----+---------+----------------+ +-----------------+---------------+------+-----+---------+----------------+
| FilCod | int(11) | NO | PRI | NULL | auto_increment | | FilCod | int(11) | NO | PRI | NULL | auto_increment |
| InsCod | int(11) | NO | MUL | -1 | | | FileBrowser | tinyint(4) | NO | MUL | NULL | |
| CtrCod | int(11) | NO | | -1 | | | Cod | int(11) | NO | | -1 | |
| DegCod | int(11) | NO | | -1 | | | ZoneUsrCod | int(11) | NO | MUL | -1 | |
| CrsCod | int(11) | NO | | -1 | |
| GrpCod | int(11) | NO | | -1 | |
| ZoneUsrCod | int(11) | NO | | -1 | |
| FileBrowser | tinyint(4) | NO | | NULL | |
| PublisherUsrCod | int(11) | NO | MUL | NULL | | | PublisherUsrCod | int(11) | NO | MUL | NULL | |
| FileType | tinyint(4) | NO | | 0 | | | FileType | tinyint(4) | NO | | 0 | |
| Path | text | NO | | NULL | | | Path | text | NO | | NULL | |
@ -1053,24 +1049,23 @@ mysql> DESCRIBE files;
| Public | enum('N','Y') | NO | | N | | | Public | enum('N','Y') | NO | | N | |
| License | tinyint(4) | NO | | 0 | | | License | tinyint(4) | NO | | 0 | |
+-----------------+---------------+------+-----+---------+----------------+ +-----------------+---------------+------+-----+---------+----------------+
14 rows in set (0.00 sec) 10 rows in set (0.00 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS files (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS files ("
"FilCod INT NOT NULL AUTO_INCREMENT," "FilCod INT NOT NULL AUTO_INCREMENT,"
"InsCod INT NOT NULL DEFAULT -1,"
"CtrCod INT NOT NULL DEFAULT -1,"
"DegCod INT NOT NULL DEFAULT -1,"
"CrsCod INT NOT NULL DEFAULT -1,"
"GrpCod INT NOT NULL DEFAULT -1,"
"ZoneUsrCod INT NOT NULL DEFAULT -1,"
"FileBrowser TINYINT NOT NULL," "FileBrowser TINYINT NOT NULL,"
"Cod INT NOT NULL DEFAULT -1,"
"ZoneUsrCod INT NOT NULL DEFAULT -1,"
"PublisherUsrCod INT NOT NULL," "PublisherUsrCod INT NOT NULL,"
"FileType TINYINT NOT NULL DEFAULT 0" "FileType TINYINT NOT NULL DEFAULT 0"
"Path TEXT COLLATE latin1_bin NOT NULL," "Path TEXT COLLATE latin1_bin NOT NULL,"
"Hidden ENUM('N','Y') NOT NULL DEFAULT 'N'," "Hidden ENUM('N','Y') NOT NULL DEFAULT 'N',"
"Public ENUM('N','Y') NOT NULL DEFAULT 'N'," "Public ENUM('N','Y') NOT NULL DEFAULT 'N',"
"License TINYINT NOT NULL DEFAULT 0," "License TINYINT NOT NULL DEFAULT 0,"
"UNIQUE INDEX(FilCod),INDEX(InsCod,CtrCod,DegCod,CrsCod,GrpCod,ZoneUsrCod,FileBrowser),INDEX(PublisherUsrCod))"); "UNIQUE INDEX(FilCod),"
"INDEX(FileBrowser,Cod,ZoneUsrCod),"
"INDEX(ZoneUsrCod),"
"INDEX(PublisherUsrCod))");
/***** Table forum_disabled_post *****/ /***** Table forum_disabled_post *****/
/* /*

File diff suppressed because it is too large Load Diff

View File

@ -97,13 +97,9 @@ typedef enum // Don't change these values! They are stored in database as number
struct FileMetadata struct FileMetadata
{ {
long FilCod; long FilCod;
long InsCod;
long CtrCod;
long DegCod;
long CrsCod;
long GrpCod;
long ZoneUsrCod;
Brw_FileBrowser_t FileBrowser; Brw_FileBrowser_t FileBrowser;
long Cod; // Code of institution, centre, degree, course or group
long ZoneUsrCod;
long PublisherUsrCod; long PublisherUsrCod;
char Path[PATH_MAX+1]; char Path[PATH_MAX+1];
bool IsHidden; bool IsHidden;
@ -179,6 +175,9 @@ void Brw_GetFileMetadataByCod (struct FileMetadata *FileMetadata);
bool Brw_GetFileSizeAndDate (struct FileMetadata *FileMetadata); bool Brw_GetFileSizeAndDate (struct FileMetadata *FileMetadata);
void Brw_GetAndUpdateFileViews (struct FileMetadata *FileMetadata); void Brw_GetAndUpdateFileViews (struct FileMetadata *FileMetadata);
void Brw_UpdateMyFileViews (long FilCod); void Brw_UpdateMyFileViews (long FilCod);
void Brw_GetCrsGrpFromFileMetadata (struct FileMetadata *FileMetadata,long *CrsCod,long *GrpCod);
long Brw_AddPathToDB (long PublisherUsrCod,Brw_FileType_t FileType, long Brw_AddPathToDB (long PublisherUsrCod,Brw_FileType_t FileType,
const char *Path,bool IsPublic,Brw_License_t License); const char *Path,bool IsPublic,Brw_License_t License);

View File

@ -621,8 +621,7 @@ static void Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent,
{ {
FileMetadata.FilCod = Cod; FileMetadata.FilCod = Cod;
Brw_GetFileMetadataByCod (&FileMetadata); Brw_GetFileMetadataByCod (&FileMetadata);
CrsCod = FileMetadata.CrsCod; Brw_GetCrsGrpFromFileMetadata (&FileMetadata,&CrsCod,&GrpCod);
GrpCod = FileMetadata.GrpCod;
Str_SplitFullPathIntoPathAndFileName (FileMetadata.Path, Str_SplitFullPathIntoPathAndFileName (FileMetadata.Path,
PathUntilFileName, PathUntilFileName,
FileName); FileName);
@ -844,9 +843,8 @@ void Ntf_SetNotifInCrsAsRemoved (long CrsCod,long ToUsrCod)
/************ Set possible notifications of one file as removed **************/ /************ Set possible notifications of one file as removed **************/
/*****************************************************************************/ /*****************************************************************************/
void Ntf_SetNotifOneFileAsRemoved (long CrsCod,long GrpCod, void Ntf_SetNotifOneFileAsRemoved (Brw_FileBrowser_t FileBrowser,
Brw_FileBrowser_t FileBrowser, long Cod,const char *Path)
const char *Path)
{ {
char Query[512]; char Query[512];
char SubQuery[256]; char SubQuery[256];
@ -881,8 +879,8 @@ void Ntf_SetNotifOneFileAsRemoved (long CrsCod,long GrpCod,
case Brw_FILE_BRW_ADMIN_MARKS_CRS: case Brw_FILE_BRW_ADMIN_MARKS_CRS:
case Brw_FILE_BRW_ADMIN_MARKS_GRP: case Brw_FILE_BRW_ADMIN_MARKS_GRP:
sprintf (SubQuery,"SELECT FilCod FROM files" sprintf (SubQuery,"SELECT FilCod FROM files"
" WHERE CrsCod='%ld' AND GrpCod='%ld' AND Path='%s'", " WHERE FileBrowser='%u' AND Cod='%ld' AND Path='%s'",
CrsCod,GrpCod,Path); (unsigned) FileBrowser,Cod,Path);
break; break;
default: default:
break; break;
@ -898,9 +896,8 @@ void Ntf_SetNotifOneFileAsRemoved (long CrsCod,long GrpCod,
/************** Set possible notifications of marks as removed ***************/ /************** Set possible notifications of marks as removed ***************/
/*****************************************************************************/ /*****************************************************************************/
void Ntf_SetNotifChildrenOfFolderAsRemoved (long CrsCod,long GrpCod, void Ntf_SetNotifChildrenOfFolderAsRemoved (Brw_FileBrowser_t FileBrowser,
Brw_FileBrowser_t FileBrowser, long Cod,const char *Path)
const char *Path)
{ {
char Query[512]; char Query[512];
char SubQuery[256]; char SubQuery[256];
@ -935,8 +932,8 @@ void Ntf_SetNotifChildrenOfFolderAsRemoved (long CrsCod,long GrpCod,
case Brw_FILE_BRW_ADMIN_MARKS_CRS: case Brw_FILE_BRW_ADMIN_MARKS_CRS:
case Brw_FILE_BRW_ADMIN_MARKS_GRP: case Brw_FILE_BRW_ADMIN_MARKS_GRP:
sprintf (SubQuery,"SELECT FilCod FROM files" sprintf (SubQuery,"SELECT FilCod FROM files"
" WHERE CrsCod='%ld' AND GrpCod='%ld' AND Path LIKE '%s/%%'", " WHERE FileBrowser='%u' AND Cod='%ld' AND Path LIKE '%s/%%'",
CrsCod,GrpCod,Path); (unsigned) FileBrowser,Cod,Path);
break; break;
default: default:
break; break;
@ -952,7 +949,7 @@ void Ntf_SetNotifChildrenOfFolderAsRemoved (long CrsCod,long GrpCod,
/******* Set all possible notifications of files in a group as removed *******/ /******* Set all possible notifications of files in a group as removed *******/
/*****************************************************************************/ /*****************************************************************************/
void Ntf_SetNotifFilesInGroupAsRemoved (long CrsCod,long GrpCod) void Ntf_SetNotifFilesInGroupAsRemoved (long GrpCod)
{ {
char Query[512]; char Query[512];
@ -960,12 +957,15 @@ void Ntf_SetNotifFilesInGroupAsRemoved (long CrsCod,long GrpCod)
sprintf (Query,"UPDATE notif SET Status=(Status | %u)" sprintf (Query,"UPDATE notif SET Status=(Status | %u)"
" WHERE NotifyEvent IN ('%u','%u','%u') AND Cod IN" " WHERE NotifyEvent IN ('%u','%u','%u') AND Cod IN"
" (SELECT FilCod FROM files" " (SELECT FilCod FROM files"
" WHERE CrsCod='%ld' AND GrpCod='%ld')", " WHERE FileBrowser IN ('%u','%u','%u') AND Cod='%ld')",
(unsigned) Ntf_STATUS_BIT_REMOVED, (unsigned) Ntf_STATUS_BIT_REMOVED,
(unsigned) Ntf_EVENT_DOCUMENT_FILE, (unsigned) Ntf_EVENT_DOCUMENT_FILE,
(unsigned) Ntf_EVENT_SHARED_FILE, (unsigned) Ntf_EVENT_SHARED_FILE,
(unsigned) Ntf_EVENT_MARKS_FILE, (unsigned) Ntf_EVENT_MARKS_FILE,
CrsCod,GrpCod); (unsigned) Brw_FILE_BRW_ADMIN_DOCUMENTS_GRP,
(unsigned) Brw_FILE_BRW_COMMON_GRP,
(unsigned) Brw_FILE_BRW_ADMIN_MARKS_GRP,
GrpCod);
DB_QueryUPDATE (Query,"can not set notification(s) as removed"); DB_QueryUPDATE (Query,"can not set notification(s) as removed");
} }

View File

@ -98,13 +98,11 @@ void Ntf_SetNotifAsSeen (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod);
void Ntf_SetNotifAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod); void Ntf_SetNotifAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod);
void Ntf_SetNotifToOneUsrAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod); void Ntf_SetNotifToOneUsrAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod);
void Ntf_SetNotifInCrsAsRemoved (long CrsCod,long ToUsrCod); void Ntf_SetNotifInCrsAsRemoved (long CrsCod,long ToUsrCod);
void Ntf_SetNotifOneFileAsRemoved (long CrsCod,long GrpCod, void Ntf_SetNotifOneFileAsRemoved (Brw_FileBrowser_t FileBrowser,
Brw_FileBrowser_t FileBrowser, long Cod,const char *Path);
const char *Path); void Ntf_SetNotifChildrenOfFolderAsRemoved (Brw_FileBrowser_t FileBrowser,
void Ntf_SetNotifChildrenOfFolderAsRemoved (long CrsCod,long GrpCod, long Cod,const char *Path);
Brw_FileBrowser_t FileBrowser, void Ntf_SetNotifFilesInGroupAsRemoved (long GrpCod);
const char *Path);
void Ntf_SetNotifFilesInGroupAsRemoved (long CrsCod,long GrpCod);
unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod); unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod);
void Ntf_StoreNotifyEventToOneUser (Ntf_NotifyEvent_t NotifyEvent, void Ntf_StoreNotifyEventToOneUser (Ntf_NotifyEvent_t NotifyEvent,
struct UsrData *UsrDat, struct UsrData *UsrDat,

View File

@ -3867,8 +3867,9 @@ int swad__getFile (struct soap *soap,
"The file requested does not exists"); "The file requested does not exists");
/***** Set course and group codes *****/ /***** Set course and group codes *****/
Gbl.CurrentCrs.Crs.CrsCod = FileMetadata.CrsCod; Brw_GetCrsGrpFromFileMetadata (&FileMetadata,
Gbl.CurrentCrs.Grps.GrpCod = FileMetadata.GrpCod; &Gbl.CurrentCrs.Crs.CrsCod,
&Gbl.CurrentCrs.Grps.GrpCod);
/***** Get some of my data *****/ /***** Get some of my data *****/
if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) != SOAP_OK) if ((ReturnCode = Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Me.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) != SOAP_OK)
@ -4002,14 +4003,10 @@ int swad__getMarks (struct soap *soap,
"Bad file code", "Bad file code",
"You can not get marks from this file"); "You can not get marks from this file");
if (FileMetadata.FileBrowser != Brw_FILE_BRW_ADMIN_MARKS_CRS && /***** Set course and group codes *****/
FileMetadata.GrpCod > 0) Brw_GetCrsGrpFromFileMetadata (&FileMetadata,
return soap_receiver_fault (Gbl.soap, &Gbl.CurrentCrs.Crs.CrsCod,
"Bad file code", &Gbl.CurrentCrs.Grps.GrpCod);
"You can not get marks from this file");
Gbl.CurrentCrs.Crs.CrsCod = FileMetadata.CrsCod;
Gbl.CurrentCrs.Grps.GrpCod = FileMetadata.GrpCod;
/***** Check course and group codes *****/ /***** Check course and group codes *****/
if ((ReturnCode = Svc_CheckCourseAndGroupCodes (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Grps.GrpCod)) != SOAP_OK) if ((ReturnCode = Svc_CheckCourseAndGroupCodes (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Grps.GrpCod)) != SOAP_OK)