Skip to content

Commit

Permalink
Merge branch 'develop' into feature/mobile-main-button
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-sychugov committed Nov 19, 2021
2 parents bca3a57 + 9ad5e54 commit 0e52607
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 39 deletions.
5 changes: 4 additions & 1 deletion build/build.backend.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@echo off

PUSHD %~dp0..
dotnet build ASC.Web.slnf /fl1 /flp1:LogFile=build/ASC.Web.log;Verbosity=Normal
@echo off
echo.
echo Install nodejs projects dependencies...
echo.
Expand All @@ -15,6 +16,8 @@ if %errorlevel% == 0 (

echo.

POPD

if "%1"=="nopause" goto start
pause
:start
21 changes: 15 additions & 6 deletions build/build.bat
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
@echo off

echo "##########################################################"
echo "######### Start build and deploy #######################"
echo "##########################################################"

echo.

PUSHD %~dp0
call runasadmin.bat "%~dpnx0"
if %errorlevel% == 0 (

call start\stop.bat
if %errorlevel% == 0 (

PUSHD %~dp0..
call start\stop.bat nopause

echo "FRONT-END (for start run command 'yarn start' inside the root folder)"
call build\build.frontend.bat
call build.frontend.bat nopause

echo "BACK-END"
call build\build.backend.bat
call build.backend.bat nopause

call start\start.bat nopause

start /b call build\start\start.bat
echo.

pause
)
13 changes: 11 additions & 2 deletions build/build.static.bat
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,24 @@ powershell -Command "(gc build\deploy\nginx\sites-enabled\onlyoffice-studio.conf

REM restart nginx
echo service nginx stop
call sc stop nginx
call sc stop nginx > nul

REM sleep 5 seconds
call ping 127.0.0.1 -n 6 > nul

echo service nginx start
call sc start nginx
call sc start nginx > nul

if NOT %errorlevel% == 0 (
echo Couldn't restarte Onlyoffice%%~nf service
)

)

echo.

POPD

if "%1"=="nopause" goto start
pause
:start
6 changes: 6 additions & 0 deletions build/buildAndDeploy.PERSONAL.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
echo "##########################################################"
echo "######### Start build and deploy Personal ##############"
echo "##########################################################"

echo.

PUSHD %~dp0
call runasadmin.bat "%~dpnx0"
if %errorlevel% == 0 (
Expand Down
18 changes: 12 additions & 6 deletions build/buildAndDeploy.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
@echo off
PUSHD %~dp0

echo "##########################################################"
echo "######### Start build and deploy #######################"
echo "##########################################################"

echo.

setlocal EnableDelayedExpansion

call runasadmin.bat "%~dpnx0"
Expand All @@ -8,15 +14,15 @@ if %errorlevel% == 0 (

call start\stop.bat nopause

PUSHD %~dp0..

echo "FRONT-END static"
call build\build.static.bat nopause
call build.static.bat nopause

echo "BACK-END"
call build\build.backend.bat nopause
call build.backend.bat nopause

call start\start.bat nopause

call build\start\start.bat nopause
echo.

pause
)
1 change: 0 additions & 1 deletion build/runasadmin.bat
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ if '%errorlevel%' NEQ '0' (
exit /B 1

:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------
33 changes: 33 additions & 0 deletions build/start/command.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
$PSversionMajor = $PSVersionTable.PSVersion | sort-object major | ForEach-Object {$_.major}
$PSversionMinor = $PSVersionTable.PSVersion | sort-object minor | ForEach-Object {$_.minor}

if ($PSversionMajor -lt 7 -or $PSversionMinor -lt 2) {
Write-Error "Powershell version must be greater than or equal to 7.2. Press Enter to exit."
Pause
exit
}

$WorkDir = "$(Split-Path -Parent $PSScriptRoot)\run";
$CommandName = "$($args[0])";

#Write-Output "Starting $($CommandName) services at time: $(Get-Date -Format HH:mm:ss)"
#Write-Output ""

Get-ChildItem -Path $WorkDir | ForEach-Object -ThrottleLimit 20 -Parallel {
$ServiceName = "Onlyoffice$([System.IO.Path]::GetFileNameWithoutExtension($_))";

switch ( $Using:CommandName )
{
"start" { Start-Service -InputObject $(Get-Service -Name "$ServiceName") }
"stop" { Stop-Service -InputObject $(Get-Service -Name "$ServiceName") }
"restart" { Restart-Service -InputObject $(Get-Service -Name "$ServiceName") }
}

if( $? )
{
Write-Output "$ServiceName $($Using:CommandName) service has been done"
}
}

#Write-Output ""
#Write-Output "End $($CommandName) services at time: $(Get-Date -Format HH:mm:ss)"
7 changes: 3 additions & 4 deletions build/start/restart.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
PUSHD %~dp0..
call runasadmin.bat "%~dpnx0"

POPD

if %errorlevel% == 0 (
for /R "run\" %%f in (*.bat) do (
call sc stop "Onlyoffice%%~nf"
call sc start "Onlyoffice%%~nf"
)
pwsh %~dp0/command.ps1 "restart"
)

echo.
Expand Down
6 changes: 3 additions & 3 deletions build/start/start.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
PUSHD %~dp0..
call runasadmin.bat "%~dpnx0"

POPD

if %errorlevel% == 0 (
for /R "run\" %%f in (*.bat) do (
call sc start "Onlyoffice%%~nf"
)
pwsh %~dp0/command.ps1 "start"
)

echo.
Expand Down
6 changes: 3 additions & 3 deletions build/start/stop.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
PUSHD %~dp0..
call runasadmin.bat "%~dpnx0"

POPD

if %errorlevel% == 0 (
for /R "run\" %%f in (*.bat) do (
call sc stop "Onlyoffice%%~nf"
)
pwsh %~dp0/command.ps1 "stop"
)

echo.
Expand Down
33 changes: 20 additions & 13 deletions products/ASC.Files/Core/Core/Security/FileSecurity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ public IEnumerable<Guid> WhoCanRead<T>(FileEntry<T> entry)

private IEnumerable<Guid> WhoCan<T>(FileEntry<T> entry, FilesSecurityActions action)
{
var shares = GetShares(entry);
var copyshares = GetShares(entry);
IEnumerable<FileShareRecord> shares = copyshares.ToList();

FileShareRecord defaultShareRecord;

Expand Down Expand Up @@ -318,7 +319,7 @@ private IEnumerable<Guid> WhoCan<T>(FileEntry<T> entry, FilesSecurityActions act
return new[] { x.Subject };
})
.Distinct()
.Where(x => Can(entry, x, action))
.Where(x => Can(entry, x, action, copyshares))
.ToList();
}

Expand All @@ -342,9 +343,9 @@ public IEnumerable<Folder<T>> FilterEdit<T>(IEnumerable<Folder<T>> entries)
return Filter(entries.Cast<FileEntry<T>>(), FilesSecurityActions.Edit, AuthContext.CurrentAccount.ID).Cast<Folder<T>>();
}

private bool Can<T>(FileEntry<T> entry, Guid userId, FilesSecurityActions action)
private bool Can<T>(FileEntry<T> entry, Guid userId, FilesSecurityActions action, IEnumerable<FileShareRecord> shares = null)
{
return Filter(new[] { entry }, action, userId).Any();
return Filter(new[] { entry }, action, userId, shares).Any();
}

private List<Tuple<FileEntry<T>, bool>> Can<T>(IEnumerable<FileEntry<T>> entry, Guid userId, FilesSecurityActions action)
Expand All @@ -353,7 +354,7 @@ private bool Can<T>(FileEntry<T> entry, Guid userId, FilesSecurityActions action
return entry.Select(r => new Tuple<FileEntry<T>, bool>(r, filtres.Any(a => a.ID.Equals(r.ID)))).ToList();
}

private IEnumerable<FileEntry<T>> Filter<T>(IEnumerable<FileEntry<T>> entries, FilesSecurityActions action, Guid userId)
private IEnumerable<FileEntry<T>> Filter<T>(IEnumerable<FileEntry<T>> entries, FilesSecurityActions action, Guid userId, IEnumerable<FileShareRecord> shares = null)
{
if (entries == null || !entries.Any()) return Enumerable.Empty<FileEntry<T>>();

Expand Down Expand Up @@ -383,8 +384,7 @@ private IEnumerable<FileEntry<T>> Filter<T>(IEnumerable<FileEntry<T>> entries, F

if (entries.Any(filter))
{
var subjects = GetUserSubjects(userId);
List<FileShareRecord> shares = null;
List<Guid> subjects = null;
foreach (var e in entries.Where(filter))
{
if (!AuthManager.GetAccountByID(TenantManager.GetCurrentTenant().TenantId, userId).IsAuthenticated && userId != FileConstant.ShareLinkId)
Expand Down Expand Up @@ -514,12 +514,19 @@ private IEnumerable<FileEntry<T>> Filter<T>(IEnumerable<FileEntry<T>> entries, F
// administrator in Common has all right
result.Add(e);
continue;
}
}

if (shares == null)
{
shares = GetShares(entries).Join(subjects, r => r.Subject, s => s, (r, s) => r).ToList();
// shares ordered by level
if (subjects == null)
{
subjects = GetUserSubjects(userId);
if (shares == null)
{
shares = GetShares(entries);
// shares ordered by level
}
shares = shares
.Join(subjects, r => r.Subject, s => s, (r, s) => r)
.ToList();
}

FileShareRecord ace;
Expand Down Expand Up @@ -705,7 +712,7 @@ public List<FileEntry> GetSharesForMe(FilterType filterType, bool subjectGroup,
var records = securityDao.GetShares(subjects);

var result = new List<FileEntry>();
result.AddRange(GetSharesForMe<int>(records.Where(r=> r.EntryId.GetType() == typeof(int)), subjects, filterType, subjectGroup, subjectID, searchText, searchInContent, withSubfolders));
result.AddRange(GetSharesForMe<int>(records.Where(r => r.EntryId.GetType() == typeof(int)), subjects, filterType, subjectGroup, subjectID, searchText, searchInContent, withSubfolders));
result.AddRange(GetSharesForMe<string>(records.Where(r => r.EntryId.GetType() == typeof(string)), subjects, filterType, subjectGroup, subjectID, searchText, searchInContent, withSubfolders));
return result;
}
Expand Down

0 comments on commit 0e52607

Please sign in to comment.