Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
243
Issues
243
List
Boards
Labels
Service Desk
Milestones
Merge Requests
31
Merge Requests
31
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
34aca270
Commit
34aca270
authored
15 minutes ago
by
Brian Hatchet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Linting
parent
aec1e324
epic/permissions-open-channels
1 merge request
!307
WIP: Epic/permissions open channels
Pipeline
#79271154
passed with stages
in 11 minutes and 10 seconds
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
23 additions
and
15 deletions
+23
-15
ChannelMode.php
Common/ChannelMode.php
+3
-2
EntityPermissions.php
Core/Permissions/Entities/EntityPermissions.php
+3
-2
Manager.php
Core/Permissions/Entities/Manager.php
+2
-2
Manager.php
Core/Permissions/Manager.php
+1
-1
Permissions.php
Core/Permissions/Permissions.php
+2
-1
Provider.php
Core/Permissions/Provider.php
+1
-0
Roles.php
Core/Permissions/Roles/Roles.php
+1
-1
PermissionsSpec.php
Spec/Core/Permissions/PermissionsSpec.php
+2
-1
UserSpec.php
Spec/Entities/UserSpec.php
+8
-5
No files found.
Common/ChannelMode.php
View file @
34aca270
<?php
namespace
Minds\Common
;
use
ReflectionClass
;
use
ReflectionClass
;
abstract
class
ChannelMode
{
...
...
@@ -16,6 +17,6 @@ abstract class ChannelMode
final
public
static
function
isValid
(
$value
)
:
bool
{
return
in_array
(
$value
,
static
::
toArray
());
return
in_array
(
$value
,
static
::
toArray
()
,
true
);
}
}
This diff is collapsed.
Click to expand it.
Core/Permissions/Entities/EntityPermissions.php
View file @
34aca270
...
...
@@ -4,12 +4,13 @@ namespace Minds\Core\Permissions\Entities;
use
Minds\Traits\MagicAttributes
;
/**
/**
* Class Permissions
* @method Permissions setAllowComments(bool $allowComments)
* @method bool getAllowComments();
*/
class
EntityPermissions
{
class
EntityPermissions
{
use
MagicAttributes
;
/** @var bool AllowComments */
...
...
This diff is collapsed.
Click to expand it.
Core/Permissions/Entities/Manager.php
View file @
34aca270
...
...
@@ -30,10 +30,10 @@ class Manager
$this
->
save
=
$save
?:
new
Save
();
//Mockable, else instantiate a new one on save.
}
/**
/**
* Save permissions for an entity and propegate it to linked objects
* @param mixed $entity a minds entity that implements the save function
* @param Permissions $permissions the flag to apply to the entity
* @param Permissions $permissions the flag to apply to the entity
*/
public
function
save
(
$entity
,
EntityPermissions
$permissions
)
{
...
...
This diff is collapsed.
Click to expand it.
Core/Permissions/Manager.php
View file @
34aca270
...
...
@@ -25,7 +25,7 @@ class Manager
* Permissions contains the user's role per entity, channel and group
* @param array $opts
* - user_guid: long, the user's guid for calculating permissions
* - guids: array long, the list of entities to permit
* - guids: array long, the list of entities to permit
* @return Permissions A map of channels, groups and entities with the user's role for each
*/
public
function
getList
(
array
$opts
=
[])
...
...
This diff is collapsed.
Click to expand it.
Core/Permissions/Permissions.php
View file @
34aca270
...
...
@@ -33,7 +33,8 @@ class Permissions implements \JsonSerializable
/** @var EntitiesBuilder */
private
$entitiesBuilder
;
public
function
setUser
(
User
$user
)
{
public
function
setUser
(
User
$user
)
{
throw
new
ImmutableException
(
'User can only be set in the constructor'
);
}
...
...
This diff is collapsed.
Click to expand it.
Core/Permissions/Provider.php
View file @
34aca270
...
...
@@ -5,6 +5,7 @@ namespace Minds\Core\Permissions;
use
Minds\Core\Di\Provider
as
DiProvider
;
use
Minds\Core\Permissions\Entities
;
use
Minds\Core\Permissions\Manager
;
class
Provider
extends
DiProvider
{
public
function
register
()
...
...
This diff is collapsed.
Click to expand it.
Core/Permissions/Roles/Roles.php
View file @
34aca270
...
...
@@ -60,5 +60,5 @@ class Roles extends Rbac
$this
->
addRole
(
new
GroupNonSubscriberRole
());
$this
->
addRole
(
new
GroupOwnerRole
());
$this
->
addRole
(
new
GroupSubscriberRole
());
}
}
}
This diff is collapsed.
Click to expand it.
Spec/Core/Permissions/PermissionsSpec.php
View file @
34aca270
...
...
@@ -58,7 +58,8 @@ class PermissionsSpec extends ObjectBehavior
$this
->
shouldHaveType
(
Permissions
::
class
);
}
public
function
it_should_except_when_setting_a_user
()
{
public
function
it_should_except_when_setting_a_user
()
{
$this
->
shouldThrow
(
new
ImmutableException
(
'User can only be set in the constructor'
))
->
duringSetUser
(
$this
->
user
);
}
...
...
This diff is collapsed.
Click to expand it.
Spec/Entities/UserSpec.php
View file @
34aca270
...
...
@@ -53,18 +53,21 @@ class UserSpec extends ObjectBehavior
$this
->
isOnchainBooster
()
->
shouldReturn
(
false
);
}
function
it_should_have_a_default_mode_of_open
()
{
public
function
it_should_have_a_default_mode_of_open
()
{
$this
->
getMode
()
->
shouldEqual
(
ChannelMode
::
OPEN
);
}
function
it_should_assign_channel_modes
()
{
$this
->
setMode
(
ChannelMode
::
CLOSED
);
public
function
it_should_assign_channel_modes
()
{
$this
->
setMode
(
ChannelMode
::
CLOSED
);
$this
->
getMode
()
->
shouldEqual
(
ChannelMode
::
CLOSED
);
$this
->
setMode
(
ChannelMode
::
MODERATED
);
$this
->
setMode
(
ChannelMode
::
MODERATED
);
$this
->
getMode
()
->
shouldEqual
(
ChannelMode
::
MODERATED
);
}
function
it_should_export_values
()
{
public
function
it_should_export_values
()
{
$export
=
$this
->
export
()
->
getWrappedObject
();
expect
(
$export
[
'mode'
])
->
shouldEqual
(
ChannelMode
::
OPEN
);
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment