Commit dfc4f306 authored by Brian Hatchet's avatar Brian Hatchet :speech_balloon:

Moderated channel permissions

1 merge request!335WIP: Feat/permissions on entities 737
Pipeline #83865256 passed with stages
in 10 minutes and 24 seconds
......@@ -7,5 +7,6 @@ class ClosedChannelNonSubscriberRole extends BaseRole
public function __construct()
{
parent::__construct(Roles::ROLE_CLOSED_CHANNEL_NON_SUBSCRIBER);
//No permissions for closed channel non subscribers
}
}
......@@ -7,5 +7,13 @@ class ClosedChannelSubscriberRole extends BaseRole
public function __construct()
{
parent::__construct(Roles::ROLE_CLOSED_CHANNEL_SUBSCRIBER);
$this->addPermission(Roles::FLAG_CREATE_POST);
$this->addPermission(Roles::FLAG_VIEW);
$this->addPermission(Roles::FLAG_VOTE);
$this->addPermission(Roles::FLAG_CREATE_COMMENT);
$this->addPermission(Roles::FLAG_REMIND);
$this->addPermission(Roles::FLAG_WIRE);
$this->addPermission(Roles::FLAG_MESSAGE);
$this->addPermission(Roles::FLAG_INVITE);
}
}
......@@ -7,5 +7,6 @@ class ModeratedChannelNonSubscriberRole extends BaseRole
public function __construct()
{
parent::__construct(Roles::ROLE_MODERATED_CHANNEL_NON_SUBSCRIBER);
$this->addPermission(Roles::FLAG_VIEW);
}
}
......@@ -7,5 +7,13 @@ class ModeratedChannelSubscriberRole extends BaseRole
public function __construct()
{
parent::__construct(Roles::ROLE_MODERATED_CHANNEL_SUBSCRIBER);
$this->addPermission(Roles::FLAG_CREATE_POST);
$this->addPermission(Roles::FLAG_VIEW);
$this->addPermission(Roles::FLAG_VOTE);
$this->addPermission(Roles::FLAG_CREATE_COMMENT);
$this->addPermission(Roles::FLAG_REMIND);
$this->addPermission(Roles::FLAG_WIRE);
$this->addPermission(Roles::FLAG_MESSAGE);
$this->addPermission(Roles::FLAG_INVITE);
}
}
......@@ -7,7 +7,6 @@ class OpenChannelNonSubscriberRole extends BaseRole
public function __construct()
{
parent::__construct(Roles::ROLE_OPEN_CHANNEL_NON_SUBSCRIBER);
$this->addPermission(Roles::FLAG_CREATE_POST);
$this->addPermission(Roles::FLAG_SUBSCRIBE);
$this->addPermission(Roles::FLAG_VIEW);
$this->addPermission(Roles::FLAG_VOTE);
......
......@@ -101,7 +101,7 @@ class RolesSpec extends ObjectBehavior
{
$role = $this->getRole(Roles::ROLE_OPEN_CHANNEL_NON_SUBSCRIBER);
$role->hasPermission(Roles::FLAG_APPOINT_ADMIN)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_CREATE_POST)->shouldEqual(true);
$role->hasPermission(Roles::FLAG_CREATE_POST)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_EDIT_CHANNEL)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_EDIT_POST)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_DELETE_CHANNEL)->shouldEqual(false);
......@@ -152,4 +152,116 @@ class RolesSpec extends ObjectBehavior
$role->hasPermission(Roles::FLAG_JOIN)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_JOIN_GATHERING)->shouldEqual(false);
}
public function it_should_have_closed_channel_non_subscriber()
{
$role = $this->getRole(Roles::ROLE_CLOSED_CHANNEL_NON_SUBSCRIBER);
$role->hasPermission(Roles::FLAG_APPOINT_ADMIN)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_CREATE_POST)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_EDIT_CHANNEL)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_EDIT_POST)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_DELETE_CHANNEL)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_DELETE_POST)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_APPOINT_MODERATOR)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_APPROVE_SUBSCRIBER)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_SUBSCRIBE)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_VIEW)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_VOTE)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_CREATE_COMMENT)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_EDIT_COMMENT)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_DELETE_COMMENT)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_REMIND)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_WIRE)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_MESSAGE)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_INVITE)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_CREATE_GROUP)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_EDIT_GROUP)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_DELETE_GROUP)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_JOIN)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_JOIN_GATHERING)->shouldEqual(false);
}
public function it_should_have_closed_channel_subscriber_permissions()
{
$role = $this->getRole(Roles::ROLE_CLOSED_CHANNEL_SUBSCRIBER);
$role->hasPermission(Roles::FLAG_APPOINT_ADMIN)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_CREATE_POST)->shouldEqual(true);
$role->hasPermission(Roles::FLAG_EDIT_CHANNEL)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_EDIT_POST)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_DELETE_CHANNEL)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_DELETE_POST)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_APPOINT_MODERATOR)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_APPROVE_SUBSCRIBER)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_SUBSCRIBE)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_VIEW)->shouldEqual(true);
$role->hasPermission(Roles::FLAG_VOTE)->shouldEqual(true);
$role->hasPermission(Roles::FLAG_CREATE_COMMENT)->shouldEqual(true);
$role->hasPermission(Roles::FLAG_EDIT_COMMENT)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_DELETE_COMMENT)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_REMIND)->shouldEqual(true);
$role->hasPermission(Roles::FLAG_WIRE)->shouldEqual(true);
$role->hasPermission(Roles::FLAG_MESSAGE)->shouldEqual(true);
$role->hasPermission(Roles::FLAG_INVITE)->shouldEqual(true);
$role->hasPermission(Roles::FLAG_CREATE_GROUP)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_EDIT_GROUP)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_DELETE_GROUP)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_JOIN)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_JOIN_GATHERING)->shouldEqual(false);
}
public function it_should_have_moderated_channel_non_subscriber_permissions()
{
$role = $this->getRole(Roles::ROLE_MODERATED_CHANNEL_NON_SUBSCRIBER);
$role->hasPermission(Roles::FLAG_APPOINT_ADMIN)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_CREATE_POST)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_EDIT_CHANNEL)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_EDIT_POST)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_DELETE_CHANNEL)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_DELETE_POST)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_APPOINT_MODERATOR)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_APPROVE_SUBSCRIBER)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_SUBSCRIBE)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_VIEW)->shouldEqual(true);
$role->hasPermission(Roles::FLAG_VOTE)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_CREATE_COMMENT)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_EDIT_COMMENT)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_DELETE_COMMENT)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_REMIND)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_WIRE)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_MESSAGE)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_INVITE)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_CREATE_GROUP)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_EDIT_GROUP)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_DELETE_GROUP)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_JOIN)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_JOIN_GATHERING)->shouldEqual(false);
}
public function it_should_have_moderated_channel_subscriber_permissions()
{
$role = $this->getRole(Roles::ROLE_MODERATED_CHANNEL_SUBSCRIBER);
$role->hasPermission(Roles::FLAG_APPOINT_ADMIN)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_CREATE_POST)->shouldEqual(true);
$role->hasPermission(Roles::FLAG_EDIT_CHANNEL)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_EDIT_POST)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_DELETE_CHANNEL)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_DELETE_POST)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_APPOINT_MODERATOR)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_APPROVE_SUBSCRIBER)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_SUBSCRIBE)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_VIEW)->shouldEqual(true);
$role->hasPermission(Roles::FLAG_VOTE)->shouldEqual(true);
$role->hasPermission(Roles::FLAG_CREATE_COMMENT)->shouldEqual(true);
$role->hasPermission(Roles::FLAG_EDIT_COMMENT)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_DELETE_COMMENT)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_REMIND)->shouldEqual(true);
$role->hasPermission(Roles::FLAG_WIRE)->shouldEqual(true);
$role->hasPermission(Roles::FLAG_MESSAGE)->shouldEqual(true);
$role->hasPermission(Roles::FLAG_INVITE)->shouldEqual(true);
$role->hasPermission(Roles::FLAG_CREATE_GROUP)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_EDIT_GROUP)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_DELETE_GROUP)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_JOIN)->shouldEqual(false);
$role->hasPermission(Roles::FLAG_JOIN_GATHERING)->shouldEqual(false);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment