Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 127... Línea 127...
127
            $details['roleassignments'] = array(
127
            $details['roleassignments'] = array(
128
                'key' => \get_string('roleassignments'),
128
                'key' => \get_string('roleassignments'),
129
                'value' => join('<br />', $roledetails)
129
                'value' => join('<br />', $roledetails)
130
            );
130
            );
131
        }
131
        }
-
 
132
 
-
 
133
        $contactsdetails = self::get_contacts_by_role_details($course);
-
 
134
        if ($contactsdetails) {
-
 
135
            $details['coursecontact'] = $contactsdetails;
-
 
136
        }
-
 
137
 
132
        if ($course->can_review_enrolments()) {
138
        if ($course->can_review_enrolments()) {
133
            $enrolmentlines = array();
139
            $enrolmentlines = array();
134
            $instances = \enrol_get_instances($course->id, true);
140
            $instances = \enrol_get_instances($course->id, true);
135
            $plugins = \enrol_get_plugins(true);
141
            $plugins = \enrol_get_plugins(true);
136
            foreach ($instances as $instance) {
142
            foreach ($instances as $instance) {
Línea 162... Línea 168...
162
        }
168
        }
163
        return $details;
169
        return $details;
164
    }
170
    }
Línea 165... Línea 171...
165
 
171
 
-
 
172
    /**
-
 
173
     * Returns the course contact details, if any.
-
 
174
     *
-
 
175
     * @param \core_course_list_element $course
-
 
176
     * @return array|null Returns null if there are no contacts, otherwise an array of contact details.
-
 
177
     */
-
 
178
    private static function get_contacts_by_role_details(\core_course_list_element $course): ?array {
-
 
179
        if (!$course->can_access()) {
-
 
180
            return null;
-
 
181
        }
-
 
182
 
-
 
183
        $contactsbyrole = [];
-
 
184
        foreach ($course->get_course_contacts() as $contact) {
-
 
185
            $rolenames = array_map(
-
 
186
                fn($role) => $role->displayname,
-
 
187
                $contact['roles']
-
 
188
            );
-
 
189
            $contacturl = new \moodle_url('/user/view.php', ['id' => $contact['user']->id]);
-
 
190
            $coursecontact = \html_writer::link($contacturl, $contact['username']);
-
 
191
 
-
 
192
            foreach ($rolenames as $rolename) {
-
 
193
                if (!array_key_exists($rolename, $contactsbyrole)) {
-
 
194
                    $contactsbyrole[$rolename] = [];
-
 
195
                }
-
 
196
                $contactsbyrole[$rolename][] = $coursecontact;
-
 
197
            }
-
 
198
        }
-
 
199
        $contactsbyrolelist = [];
-
 
200
        foreach ($contactsbyrole as $rolename => $contacts) {
-
 
201
            $contactsbyrolelist[] = get_string(
-
 
202
                'contactsbyrolelist',
-
 
203
                'moodle',
-
 
204
                (object) [
-
 
205
                    'role' => $rolename,
-
 
206
                    'contacts' => implode(', ', $contacts),
-
 
207
                ]
-
 
208
            );
-
 
209
        }
-
 
210
 
-
 
211
        if (empty($contactsbyrolelist)) {
-
 
212
            return null;
-
 
213
        }
-
 
214
        return [
-
 
215
            'key' => \get_string('coursecontact', 'admin'),
-
 
216
            'value' => join('<br>', $contactsbyrolelist),
-
 
217
        ];
-
 
218
    }
-
 
219
 
166
    /**
220
    /**
167
     * Returns an array of actions that can be performed upon a category being shown in a list.
221
     * Returns an array of actions that can be performed upon a category being shown in a list.
168
     *
222
     *
169
     * @param \core_course_category $category
223
     * @param \core_course_category $category
170
     * @return array
224
     * @return array
Línea 177... Línea 231...
177
        $actions = array();
231
        $actions = array();
Línea 178... Línea 232...
178
 
232
 
179
        // View link.
233
        // View link.
180
        $actions['view'] = [
234
        $actions['view'] = [
181
            'url' => new \moodle_url('/course/index.php', ['categoryid' => $category->id]),
235
            'url' => new \moodle_url('/course/index.php', ['categoryid' => $category->id]),
182
            'icon' => null,
236
            'icon' => new \pix_icon('i/viewcategory', new \lang_string('view')),
183
            'string' => get_string('view')
237
            'string' => get_string('view')
Línea 184... Línea 238...
184
        ];
238
        ];
185
 
239