11
11
12
12
namespace Claroline \ForumBundle \Manager ;
13
13
14
+ use Claroline \CoreBundle \Entity \Resource \ResourceNode ;
14
15
use Claroline \CoreBundle \Entity \User ;
15
16
use Claroline \CoreBundle \Library \Resource \ResourceCollection ;
16
17
use Claroline \CoreBundle \Manager \MailManager ;
18
+ use Claroline \CoreBundle \Manager \MaskManager ;
19
+ use Claroline \CoreBundle \Manager \RightsManager ;
17
20
use Claroline \CoreBundle \Pager \PagerFactory ;
18
21
use Claroline \CoreBundle \Persistence \ObjectManager ;
19
22
use Claroline \ForumBundle \Entity \Category ;
@@ -67,6 +70,8 @@ class Manager
67
70
private $ mailManager ;
68
71
private $ container ;
69
72
private $ sc ;
73
+ private $ maskManager ;
74
+ private $ rightsManager ;
70
75
71
76
/**
72
77
* Constructor.
@@ -80,7 +85,9 @@ class Manager
80
85
* "router" = @DI\Inject("router"),
81
86
* "mailManager" = @DI\Inject("claroline.manager.mail_manager"),
82
87
* "container" = @DI\Inject("service_container"),
83
- * "sc" = @DI\Inject("security.context")
88
+ * "sc" = @DI\Inject("security.context"),
89
+ * "maskManager" = @DI\Inject("claroline.manager.mask_manager"),
90
+ * "rightsManager" = @DI\Inject("claroline.manager.rights_manager")
84
91
* })
85
92
*/
86
93
public function __construct (
@@ -92,7 +99,9 @@ public function __construct(
92
99
RouterInterface $ router ,
93
100
MailManager $ mailManager ,
94
101
ContainerInterface $ container ,
95
- SecurityContextInterface $ sc
102
+ SecurityContextInterface $ sc ,
103
+ MaskManager $ maskManager ,
104
+ RightsManager $ rightsManager
96
105
)
97
106
{
98
107
$ this ->om = $ om ;
@@ -110,6 +119,8 @@ public function __construct(
110
119
$ this ->mailManager = $ mailManager ;
111
120
$ this ->container = $ container ;
112
121
$ this ->sc = $ sc ;
122
+ $ this ->maskManager = $ maskManager ;
123
+ $ this ->rightsManager = $ rightsManager ;
113
124
}
114
125
115
126
/**
@@ -627,4 +638,23 @@ private function removeNotification(Forum $forum, Notification $notification)
627
638
$ this ->dispatch (new UnsubscribeForumEvent ($ forum ));
628
639
$ this ->om ->endFlushSuite ();
629
640
}
641
+
642
+ public function createDefaultPostRights (ResourceNode $ node )
643
+ {
644
+ $ workspace = $ node ->getWorkspace ();
645
+ $ resourceType = $ node ->getResourceType ();
646
+ $ role = $ this ->roleRepo ->findOneBaseWorkspaceRole ('COLLABORATOR ' , $ workspace );
647
+
648
+ if (!is_null ($ role )) {
649
+ $ postDecoder = $ this ->maskManager ->getDecoder ($ resourceType , 'post ' );
650
+
651
+ if (!is_null ($ postDecoder )) {
652
+ $ rights = $ this ->rightsManager ->getOneByRoleAndResource ($ role , $ node );
653
+ $ value = $ postDecoder ->getValue ();
654
+ $ mask = $ rights ->getMask ();
655
+ $ permissions = $ mask | $ value ;
656
+ $ this ->rightsManager ->editPerms ($ permissions , $ role , $ node );
657
+ }
658
+ }
659
+ }
630
660
}
0 commit comments