mirror of https://github.com/acanas/swad-core.git
Version 17.20.7
This commit is contained in:
parent
9b0831dceb
commit
041faac9ea
|
@ -256,13 +256,14 @@
|
|||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 17.20.6 (2017-10-07)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 17.20.7 (2017-10-07)"
|
||||
#define CSS_FILE "swad17.0.css"
|
||||
#define JS_FILE "swad17.17.1.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 17.20.7: Oct 07, 2017 Only publishers can remove subtrees in project documents. (233105 lines)
|
||||
Version 17.20.6: Oct 07, 2017 Fixed bug in project documents. (233027 lines)
|
||||
Version 17.20.5: Oct 07, 2017 Title of project is now a link to show the project and its documents. (233024 lines)
|
||||
Version 17.20.4: Oct 07, 2017 Changes in layout of project. (232972 lines)
|
||||
|
|
|
@ -1675,6 +1675,7 @@ static bool Brw_CheckIfICanEditFileOrFolder (unsigned Level);
|
|||
static bool Brw_CheckIfICanCreateIntoFolder (unsigned Level);
|
||||
static bool Brw_CheckIfICanModifySharedFileOrFolder (void);
|
||||
static bool Brw_CheckIfICanModifyPrivateFileOrFolder (void);
|
||||
static bool Brw_CheckIfICanModifyProjectFileOrFolder (void);
|
||||
static long Brw_GetPublisherOfSubtree (void);
|
||||
|
||||
static void Brw_WriteRowDocData (unsigned *NumDocsNotHidden,MYSQL_ROW row);
|
||||
|
@ -5515,9 +5516,11 @@ static bool Brw_WriteRowFileBrowser (unsigned Level,const char *RowId,
|
|||
Gbl.FileBrowser.Asg.AsgCod = -1L;
|
||||
|
||||
/***** Get the name of the file to show *****/
|
||||
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.Type,Level,
|
||||
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.Type,
|
||||
Level,
|
||||
Gbl.FileBrowser.FileType,
|
||||
FileName,FileNameToShow);
|
||||
FileName,
|
||||
FileNameToShow);
|
||||
|
||||
/***** Start this row *****/
|
||||
fprintf (Gbl.F.Out,"<tr id=\"file_browser_%u_%s\"",
|
||||
|
@ -6679,9 +6682,11 @@ void Brw_AskRemFileFromTree (void)
|
|||
if (Brw_CheckIfICanEditFileOrFolder (Gbl.FileBrowser.Level)) // Can I remove this file?
|
||||
{
|
||||
/***** Show question and button to remove file/link *****/
|
||||
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.FileType,Gbl.FileBrowser.Level,
|
||||
Gbl.FileBrowser.FileType,
|
||||
Gbl.FileBrowser.FilFolLnkName,FileNameToShow);
|
||||
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.FileType,
|
||||
Gbl.FileBrowser.Level,
|
||||
Gbl.FileBrowser.FileType,
|
||||
Gbl.FileBrowser.FilFolLnkName,
|
||||
FileNameToShow);
|
||||
sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_FILE_OR_LINK_X,
|
||||
FileNameToShow);
|
||||
Ale_ShowAlertAndButton (Ale_QUESTION,Gbl.Alert.Txt,
|
||||
|
@ -7158,9 +7163,10 @@ static void Brw_WriteCurrentClipboard (void)
|
|||
{
|
||||
// Not the root folder
|
||||
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.Clipboard.FileBrowser,
|
||||
Gbl.FileBrowser.Clipboard.Level,
|
||||
Gbl.FileBrowser.Clipboard.FileType,
|
||||
Gbl.FileBrowser.Clipboard.FileName,FileNameToShow);
|
||||
Gbl.FileBrowser.Clipboard.Level,
|
||||
Gbl.FileBrowser.Clipboard.FileType,
|
||||
Gbl.FileBrowser.Clipboard.FileName,
|
||||
FileNameToShow);
|
||||
|
||||
sprintf (Gbl.Alert.Txt,"%s: %s, %s <strong>%s</strong>.",
|
||||
Txt_Copy_source,TxtClipboardZone,
|
||||
|
@ -8384,9 +8390,11 @@ void Brw_ShowFormFileBrowser (void)
|
|||
if (Brw_CheckIfICanCreateIntoFolder (Gbl.FileBrowser.Level))
|
||||
{
|
||||
/***** Name of the folder to be shown ****/
|
||||
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.Type,Gbl.FileBrowser.Level,
|
||||
Gbl.FileBrowser.FileType,
|
||||
Gbl.FileBrowser.FilFolLnkName,FileNameToShow);
|
||||
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.Type,
|
||||
Gbl.FileBrowser.Level,
|
||||
Gbl.FileBrowser.FileType,
|
||||
Gbl.FileBrowser.FilFolLnkName,
|
||||
FileNameToShow);
|
||||
|
||||
/***** 1. Form to create a new folder *****/
|
||||
Brw_PutFormToCreateAFolder (FileNameToShow);
|
||||
|
@ -8727,9 +8735,11 @@ void Brw_RecFolderFileBrowser (void)
|
|||
PathCompleteInTreeIncludingFolder,false,Brw_LICENSE_DEFAULT);
|
||||
|
||||
/* The folder has been created sucessfully */
|
||||
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.Type,Gbl.FileBrowser.Level,
|
||||
Brw_IS_FOLDER,
|
||||
Gbl.FileBrowser.FilFolLnkName,FileNameToShow);
|
||||
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.Type,
|
||||
Gbl.FileBrowser.Level,
|
||||
Brw_IS_FOLDER,
|
||||
Gbl.FileBrowser.FilFolLnkName,
|
||||
FileNameToShow);
|
||||
sprintf (Gbl.Alert.Txt,Txt_The_folder_X_has_been_created_inside_the_folder_Y,
|
||||
Gbl.FileBrowser.NewFilFolLnkName,FileNameToShow);
|
||||
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
|
||||
|
@ -9029,9 +9039,11 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType)
|
|||
/* Show message of confirmation */
|
||||
if (UploadType == Brw_CLASSIC_UPLOAD)
|
||||
{
|
||||
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.Type,Gbl.FileBrowser.Level,
|
||||
Brw_IS_FOLDER,
|
||||
Gbl.FileBrowser.FilFolLnkName,FileNameToShow);
|
||||
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.Type,
|
||||
Gbl.FileBrowser.Level,
|
||||
Brw_IS_FOLDER,
|
||||
Gbl.FileBrowser.FilFolLnkName,
|
||||
FileNameToShow);
|
||||
sprintf (Gbl.Alert.Txt,Txt_The_file_X_has_been_placed_inside_the_folder_Y,
|
||||
Gbl.FileBrowser.NewFilFolLnkName,
|
||||
FileNameToShow);
|
||||
|
@ -9205,9 +9217,11 @@ void Brw_RecLinkFileBrowser (void)
|
|||
PathCompleteInTreeIncludingFile,false,Brw_LICENSE_DEFAULT);
|
||||
|
||||
/* Show message of confirmation */
|
||||
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.Type,Gbl.FileBrowser.Level,
|
||||
Brw_IS_FOLDER,
|
||||
Gbl.FileBrowser.FilFolLnkName,FileNameToShow);
|
||||
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.Type,
|
||||
Gbl.FileBrowser.Level,
|
||||
Brw_IS_FOLDER,
|
||||
Gbl.FileBrowser.FilFolLnkName,
|
||||
FileNameToShow);
|
||||
sprintf (Gbl.Alert.Txt,Txt_The_link_X_has_been_placed_inside_the_folder_Y,
|
||||
FileName,FileNameToShow);
|
||||
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
|
||||
|
@ -9356,9 +9370,11 @@ void Brw_SetDocumentAsVisible (void)
|
|||
Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type,Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
|
||||
/***** Write message of confirmation *****/
|
||||
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.Type,Gbl.FileBrowser.Level,
|
||||
Gbl.FileBrowser.FileType,
|
||||
Gbl.FileBrowser.FilFolLnkName,FileNameToShow);
|
||||
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.Type,
|
||||
Gbl.FileBrowser.Level,
|
||||
Gbl.FileBrowser.FileType,
|
||||
Gbl.FileBrowser.FilFolLnkName,
|
||||
FileNameToShow);
|
||||
sprintf (Gbl.Alert.Txt,Txt_FILE_FOLDER_OR_LINK_X_is_now_visible,
|
||||
FileNameToShow);
|
||||
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
|
||||
|
@ -9389,9 +9405,11 @@ void Brw_SetDocumentAsHidden (void)
|
|||
Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type,Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
|
||||
/***** Write confirmation message *****/
|
||||
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.Type,Gbl.FileBrowser.Level,
|
||||
Gbl.FileBrowser.FileType,
|
||||
Gbl.FileBrowser.FilFolLnkName,FileNameToShow);
|
||||
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.Type,
|
||||
Gbl.FileBrowser.Level,
|
||||
Gbl.FileBrowser.FileType,
|
||||
Gbl.FileBrowser.FilFolLnkName,
|
||||
FileNameToShow);
|
||||
sprintf (Gbl.Alert.Txt,Txt_FILE_FOLDER_OR_LINK_X_is_now_hidden,FileNameToShow);
|
||||
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
|
||||
|
||||
|
@ -11423,6 +11441,9 @@ static bool Brw_CheckIfICanEditFileOrFolder (unsigned Level)
|
|||
break;
|
||||
}
|
||||
return false;
|
||||
case Brw_ADMI_DOCUM_PRJ:
|
||||
// Check if I am the publisher of the file/folder
|
||||
return Brw_CheckIfICanModifyProjectFileOrFolder ();
|
||||
default:
|
||||
return Brw_FileBrowserIsEditable[Gbl.FileBrowser.Type];
|
||||
}
|
||||
|
@ -11550,6 +11571,42 @@ static bool Brw_CheckIfICanModifyPrivateFileOrFolder (void)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/********** Check if I have permission to modify a file or folder ************/
|
||||
/********** in the current project documents zone ************/
|
||||
/*****************************************************************************/
|
||||
// Returns true if I can remove or rename Gbl.FileBrowser.Priv.FullPathInTree, and false if I have not permission
|
||||
// I can remove or rename a file if I am the publisher
|
||||
// I can remove or rename a folder if I am the unique publisher of all the files and folders in the subtree starting there
|
||||
|
||||
static bool Brw_CheckIfICanModifyProjectFileOrFolder (void)
|
||||
{
|
||||
Prj_RoleInProject_t MyRoleInProject;
|
||||
|
||||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
{
|
||||
case Rol_STD: // If I am a student or a non-editing teacher...
|
||||
case Rol_NET: // ...I can modify the file/folder if I am the publisher
|
||||
case Rol_TCH:
|
||||
MyRoleInProject = Prj_GetMyRoleInProject (Gbl.CurrentCrs.Prjs.PrjCod);
|
||||
switch (MyRoleInProject)
|
||||
{
|
||||
case Prj_ROLE_UNK: // I am not a member
|
||||
return false;
|
||||
case Prj_ROLE_STD:
|
||||
case Prj_ROLE_TUT:
|
||||
case Prj_ROLE_EVA:
|
||||
return (Gbl.Usrs.Me.UsrDat.UsrCod == Brw_GetPublisherOfSubtree ()); // Am I the publisher of subtree?
|
||||
}
|
||||
return false;
|
||||
case Rol_SYS_ADM:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ Get the publisher of a subtree *********************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -1419,6 +1419,34 @@ static unsigned Prj_GetUsrsInPrj (long PrjCod,Prj_RoleInProject_t RoleInProject,
|
|||
"can not get users in project");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************** Get my role in a project *************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
Prj_RoleInProject_t Prj_GetMyRoleInProject (long PrjCod)
|
||||
{
|
||||
char Query[128];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned UnsignedNum;
|
||||
Prj_RoleInProject_t RoleInProject = Prj_ROLE_UNK;
|
||||
|
||||
/***** Get my role in project from database *****/
|
||||
sprintf (Query,"SELECT RoleInProject FROM prj_usr WHERE PrjCod=%ld",PrjCod);
|
||||
if (DB_QuerySELECT (Query,&mysql_res,"can not get my role in project"))
|
||||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if (sscanf (row[0],"%u",&UnsignedNum) == 1)
|
||||
if (UnsignedNum < Prj_NUM_ROLES_IN_PROJECT)
|
||||
RoleInProject = (Prj_RoleInProject_t) UnsignedNum;
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
return RoleInProject;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Request another user's ID, @nickname or email to add user to project ****/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -115,6 +115,8 @@ void Prj_ShowOneUniqueProject (struct Project *Prj);
|
|||
|
||||
void Prj_PrintOneProject (void);
|
||||
|
||||
Prj_RoleInProject_t Prj_GetMyRoleInProject (long PrjCod);
|
||||
|
||||
void Prj_ReqAddStd (void);
|
||||
void Prj_ReqAddTut (void);
|
||||
void Prj_ReqAddEva (void);
|
||||
|
|
Loading…
Reference in New Issue