170 {
171 $client_ini = $environment->
getResource(
Setup\Environment::RESOURCE_CLIENT_INI);
172 $db = $environment->
getResource(Environment::RESOURCE_DATABASE);
173
174 $role_folder_id = (
int) $client_ini->readVariable(
"system",
"ROLE_FOLDER_ID");
175
176 $learning_progress_permissions = [];
177 if ($this->has_learning_progress) {
178 $learning_progress_permissions = array_filter([
181
182 ]);
183 }
184
185 foreach ($this->initial_permission_definition as $role_type => $roles) {
186 foreach ($roles as $role_title => $definition) {
187 if (
188 $this->used_for_authoring &&
189 array_key_exists('ignore_for_authoring_objects', $definition) &&
190 $definition['ignore_for_authoring_objects']
191 ) {
192 continue;
193 }
194
195 if (array_key_exists('id', $definition) && is_numeric($definition['id'])) {
196
197 $query = "SELECT obj_id FROM object_data WHERE type = %s AND obj_id = %s";
198 $query_types = ['text', 'integer'];
199 $query_values = [$role_type, $definition['id']];
200 } else {
201 $query = "SELECT obj_id FROM object_data WHERE type = %s AND title = %s";
202 $query_types = ['text', 'text'];
203 $query_values = [$role_type, $role_title];
204 }
205
206 $res = $db->queryF($query, $query_types, $query_values);
207 if (1 == $db->numRows(
$res)) {
208 $row = $db->fetchAssoc(
$res);
209 $role_id = (
int) $row[
'obj_id'];
210
211 $operation_ids = [];
212
213 if (array_key_exists('object', $definition) && is_array($definition['object'])) {
214 $operation_ids = array_merge($operation_ids, $definition['object']);
215 }
216
217 if (array_key_exists('lp', $definition) && $definition['lp']) {
218 $operation_ids = array_merge($operation_ids, $learning_progress_permissions);
219 }
220
221 foreach (array_filter(array_map('intval', $operation_ids)) as $ops_id) {
222 if ($ops_id == self::RBAC_OP_COPY) {
224 }
225
226 $db->replace(
227 'rbac_templates',
228 [
229 'rol_id' => ['integer', $role_id],
230 'type' => ['text', $this->object_type],
231 'ops_id' => ['integer', $ops_id],
232 'parent' => ['integer', $role_folder_id]
233 ],
234 []
235 );
236 }
237
238 if (array_key_exists('create', $definition) && is_array($definition['create'])) {
239 foreach ($definition['create'] as $container_object_type) {
241 if ($ops_id == self::RBAC_OP_COPY) {
243 }
244
245 $db->replace(
246 'rbac_templates',
247 [
248 'rol_id' => ['integer', $role_id],
249 'type' => ['text', $container_object_type],
250 'ops_id' => ['integer', $ops_id],
251 'parent' => ['integer', $role_folder_id]
252 ],
253 []
254 );
255 }
256 }
257 }
258 }
259 }
260 }
261
262
263 return $environment;
264 }
static _getCustomRBACOperationId(string $operation, ?\ilDBInterface $ilDB=null)
An environment holds resources to be used in the setup process.
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.