Modificar Block People para diferencia por grupos

Re: Modificar Block People para diferencia por grupos

de Pablo Ask Ask -
Número de respuestas: 1

Bueno creo que lo tengo, estoy haciendo comprobaciones pero lo dejo por aquí por si alguien lo necesita o ve algún fallo. La versión que estoy usando es v3.5-r3 (2018080300) . El archivo modificado es el block_people.php 

Añadir el código en negrita.

foreach ($teachers as $teacher) {

            // If users should only be listed once.

            $groupspablo = groups_get_my_groups();//PABLO

            foreach ($groupspablo as $groupabl) //PABLO

           {//PABLO

           if (groups_is_member($groupabl->groupid, $teacher->id)) //PABLO

            {//PABLO

          if (!$multipleroles) {

                // Continue if we have already shown this user.

                if (isset($displayedteachers[$teacher->id])) {

                    continue;

                }

                // Remember that we have shown this user.

                $displayedteachers[$teacher->id] = 1;

 

                // Otherwise.

            } else {

                // Continue if we have already shown this user.

                if (isset($displayedteachers[$teacher->id][$teacher->roleid])) {

                    continue;

                }

                // Remember that we have shown this user and his role.

                $displayedteachers[$teacher->id][$teacher->roleid] = 1;

            }

 

            // If we have to process a new role.

            if ($teacherrole != $teacher->roleid) {

                // End previous role list if necessary.

                if ($teacherrole != null) {

                    $this->content->text .= html_writer::end_tag('ul');

                }

 

                // Write heading and open new role list.

                $teacherrole = $teacher->roleid;

                $this->content->text .= html_writer::tag('h3', $rolenames[$teacherrole]);

                $this->content->text .= html_writer::start_tag('ul');

            }

 

            // Start output teacher.

            $this->content->text .= html_writer::start_tag('li');

 

            // Create user object for picture output.

            $user = new stdClass();

            $user->id = $teacher->id;

            $user->lastname = $teacher->lastname;

            $user->firstname = $teacher->firstname;

            $user->lastnamephonetic = $teacher->lastnamephonetic;

            $user->firstnamephonetic = $teacher->firstnamephonetic;

            $user->middlename = $teacher->middlename;

            $user->alternatename = $teacher->alternatename;

            $user->picture = $teacher->picture;

            $user->imagealt = $teacher->imagealt;

            $user->email = $teacher->email;

 

            // Teacher image.

            $this->content->text .= html_writer::start_tag('div', array('class' => 'image'));

            if (has_capability('moodle/user:viewdetails', $currentcontext)) {

                $this->content->text .= $OUTPUT->user_picture($user,

                        array('size' => 30, 'link' => true, 'courseid' => $COURSE->id, 'includefullname' => false));

            } else {

                $this->content->text .= $OUTPUT->user_picture($user,

                        array('size' => 30, 'link' => false, 'courseid' => $COURSE->id, 'includefullname' => false));

            }

            $this->content->text .= html_writer::end_tag('div');

 

            // Teacher details.

            $this->content->text .= html_writer::start_tag('div', array('class' => 'details'));

            $this->content->text .= html_writer::start_tag('div', array('class' => 'name'));

            $this->content->text .= fullname($teacher);

            $this->content->text .= html_writer::end_tag('div');

            $this->content->text .= html_writer::start_tag('div', array('class' => 'icons'));

            if ($CFG->messaging && has_capability('moodle/site:sendmessage', $currentcontext) && $teacher->id != $USER->id) {

                $this->content->text .= html_writer::start_tag('a',

                        array('href'  => new moodle_url('/message/index.php', array('id' => $teacher->id)),

                              'title' => get_string('sendmessageto', 'core_message', fullname($teacher))));

                $this->content->text .= $OUTPUT->pix_icon('t/email',

                        get_string('sendmessageto', 'core_message', fullname($teacher)), 'moodle');

                $this->content->text .= html_writer::end_tag('a');

            }

            $this->content->text .= html_writer::end_tag('div');

            $this->content->text .= html_writer::end_tag('div');

 

            // End output teacher.

            $this->content->text .= html_writer::end_tag('li');

            }//PABLO if

            }//PABLO foreach

        }


En respuesta a Pablo Ask Ask

Re: Modificar Block People para diferencia por grupos

de Juan Carlos Molina -

Hola, 

lo primero que haría yo es duplicar el bloque que viene con el core y customizaría el mío nuevo. No recomiendo parchear el código que viene con el paquete. 


Además de eso que yo sepa no hay ninguna variable global que te devuelva el grupo al que pertenece un usuario. 

Saludos, 

JC