@@ -47,12 +47,12 @@ the enabled provider for that instance.
47
47
48
48
``` php
49
49
$communication = \core_communication\api::load_by_instance(
50
- context: $context,
51
- component: 'core_course',
52
- instancetype: 'coursecommunication',
53
- instanceid: $courseid,
54
- provider: 'communication_matrix',
55
- );
50
+ context: $context,
51
+ component: 'core_course',
52
+ instancetype: 'coursecommunication',
53
+ instanceid: $courseid,
54
+ provider: 'communication_matrix',
55
+ );
56
56
```
57
57
58
58
### Create and configure a room
@@ -61,10 +61,10 @@ $communication = \core_communication\api::load_by_instance(
61
61
62
62
``` php
63
63
public function create_and_configure_room(
64
- string $communicationroomname,
65
- ?\stored_file $avatar = null,
66
- ?\stdClass $instance = null,
67
- )
64
+ string $communicationroomname,
65
+ ?\stored_file $avatar = null,
66
+ ?\stdClass $instance = null,
67
+ );
68
68
```
69
69
70
70
This method takes the following parameters:
@@ -79,23 +79,27 @@ field named topic which sets the topic of the room, the instance object can be u
79
79
Please refer to [ Communication plugin] ( ../../plugintypes/communication/index.md ) documentation for more details.
80
80
81
81
``` php
82
- // First initialize the communication instance, provided the context is already initialized and the selected provider is available
82
+ // First initialize the communication instance,
83
+ // provided the context is already initialized
84
+ // and the selected provider is available
83
85
// though a form or other means.
84
86
$communication = \core_communication\api::load_by_instance(
85
- context: $context,
86
- component: 'core_course',
87
- instancetype: 'coursecommunication',
88
- instanceid: $course->id,
89
- provider: 'communication_matrix',
90
- );
91
-
92
- // Now call the create_and_configure_room() method to add an ad-hoc to create a room in the communication provider and configure it
93
- // with the required settings.
87
+ context: $context,
88
+ component: 'core_course',
89
+ instancetype: 'coursecommunication',
90
+ instanceid: $course->id,
91
+ provider: 'communication_matrix',
92
+ );
93
+
94
+ // Now call the create_and_configure_room() method
95
+ // to add an ad-hoc to create a room in the
96
+ // communication provider and configure it with the
97
+ // required settings.
94
98
$communication->create_and_configure_room(
95
- communicationroomname: $course->fullname,
96
- avatar: $courseimage ?: null,
97
- instance: $course,
98
- );
99
+ communicationroomname: $course->fullname,
100
+ avatar: $courseimage ?: null,
101
+ instance: $course,
102
+ );
99
103
```
100
104
101
105
### Update a room and its associated information
@@ -104,11 +108,11 @@ $communication->create_and_configure_room(
104
108
105
109
``` php
106
110
public function update_room(
107
- ?int $active = null,
108
- ?string $communicationroomname = null,
109
- ?\stored_file $avatar = null,
110
- ?\stdClass $instance = null,
111
- )
111
+ ?int $active = null,
112
+ ?string $communicationroomname = null,
113
+ ?\stored_file $avatar = null,
114
+ ?\stdClass $instance = null,
115
+ );
112
116
```
113
117
114
118
This method takes the following parameters:
@@ -121,21 +125,22 @@ This method takes the following parameters:
121
125
``` php
122
126
// First initialize the instance.
123
127
$communication = \core_communication\api::load_by_instance(
124
- context: $context,
125
- component: 'core_course',
126
- instancetype: 'coursecommunication',
127
- instanceid: $course->id,
128
- provider: 'communication_matrix',
129
- );
130
-
131
- // Now update the room with the required settings. The instance will be used by dynamic fields feature of the plugin to allow the plugin
132
- // to get the required information from the instance.
128
+ context: $context,
129
+ component: 'core_course',
130
+ instancetype: 'coursecommunication',
131
+ instanceid: $course->id,
132
+ provider: 'communication_matrix',
133
+ );
134
+
135
+ // Now update the room with the required settings.
136
+ // The instance will be used by dynamic fields feature of the plugin
137
+ // to allow the plugin to get the required information from the instance.
133
138
$communication->update_room(
134
- active: $active,
135
- communicationroomname: $communicationroomname,
136
- avatar: $courseimage ?: null,
137
- instance: $course,
138
- );
139
+ active: $active,
140
+ communicationroomname: $communicationroomname,
141
+ avatar: $courseimage ?: null,
142
+ instance: $course,
143
+ );
139
144
```
140
145
141
146
### Delete a room
@@ -156,9 +161,9 @@ the provider room is also stored in the communication_user table for user mappin
156
161
157
162
``` php
158
163
public function add_members_to_room(
159
- array $userids,
160
- bool $queue = true,
161
- )
164
+ array $userids,
165
+ bool $queue = true,
166
+ );
162
167
```
163
168
164
169
This method accepts the following parameters:
@@ -169,16 +174,16 @@ This method accepts the following parameters:
169
174
``` php
170
175
// First initialize the instance, provider is not required here, it will initialize the enabled instance.
171
176
$communication = \core_communication\api::load_by_instance(
172
- context: $context,
173
- component: 'core_course',
174
- instancetype: 'coursecommunication',
175
- instanceid: $course->id,
176
- );
177
+ context: $context,
178
+ component: 'core_course',
179
+ instancetype: 'coursecommunication',
180
+ instanceid: $course->id,
181
+ );
177
182
178
183
// Now add the members.
179
184
$communication->add_members_to_room(
180
- userids: $enrolledusers,
181
- );
185
+ userids: $enrolledusers,
186
+ );
182
187
```
183
188
184
189
### Update the membership of a room
@@ -188,9 +193,9 @@ The user mapping for each of the users are also reset to allow task to update th
188
193
189
194
``` php
190
195
public function update_room_membership(
191
- array $userids,
192
- bool $queue = true,
193
- )
196
+ array $userids,
197
+ bool $queue = true,
198
+ );
194
199
```
195
200
196
201
This method accepts the same parameters as the ` add_members_to_room() ` method and the usage is also the same.
@@ -202,9 +207,9 @@ The users are flagged as deleted in the communication_user table to allow the ta
202
207
203
208
``` php
204
209
public function remove_members_from_room(
205
- array $userids,
206
- bool $queue = true
207
- )
210
+ array $userids,
211
+ bool $queue = true
212
+ );
208
213
```
209
214
210
215
This method accepts the same parameters as the ` add_members_to_room() ` method and the usage is also the same.
@@ -225,9 +230,9 @@ It will also be required to use `set_data()` method in order to set the data to
225
230
226
231
``` php
227
232
public function form_definition(
228
- \MoodleQuickForm $mform,
229
- string $selectdefaultcommunication = processor::PROVIDER_NONE,
230
- )
233
+ \MoodleQuickForm $mform,
234
+ string $selectdefaultcommunication = processor::PROVIDER_NONE,
235
+ );
231
236
```
232
237
233
238
This method accepts the following parameters:
0 commit comments