Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 12... Línea 12...
12
// GNU General Public License for more details.
12
// GNU General Public License for more details.
13
//
13
//
14
// You should have received a copy of the GNU General Public License
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea -... Línea 16...
-
 
16
 
-
 
17
use core\output\html_writer;
-
 
18
use core\user;
16
 
19
 
17
/**
20
/**
18
 * Mentees block.
21
 * Mentees block.
19
 *
22
 *
20
 * @package    block_mentees
23
 * @package    block_mentees
Línea 39... Línea 42...
39
    function instance_allow_multiple() {
42
    function instance_allow_multiple() {
40
        return true;
43
        return true;
41
    }
44
    }
Línea 42... Línea 45...
42
 
45
 
43
    function get_content() {
46
    function get_content() {
Línea 44... Línea 47...
44
        global $CFG, $USER, $DB;
47
        global $USER, $DB;
45
 
48
 
46
        if ($this->content !== NULL) {
49
        if ($this->content !== NULL) {
Línea 47... Línea 50...
47
            return $this->content;
50
            return $this->content;
Línea 48... Línea 51...
48
        }
51
        }
49
 
52
 
50
        $this->content = new stdClass();
53
        $this->content = new stdClass();
-
 
54
 
-
 
55
        // get all the mentees, i.e. users you have a direct assignment to
-
 
56
        $userfieldsapi = \core_user\fields::for_name();
51
 
57
        $userfieldssql = $userfieldsapi->get_sql('u', false, '', '', false);
52
        // get all the mentees, i.e. users you have a direct assignment to
58
 
53
        $userfieldsapi = \core_user\fields::for_name();
59
        [$usersort] = users_order_by_sql('u', null, $this->context, $userfieldssql->mappings);
54
        $allusernames = $userfieldsapi->get_sql('u', false, '', '', false)->selects;
60
 
55
        if ($usercontexts = $DB->get_records_sql("SELECT c.instanceid, c.instanceid, $allusernames
61
        if ($users = $DB->get_records_sql("SELECT u.id, $userfieldssql->selects
56
                                                    FROM {role_assignments} ra, {context} c, {user} u
62
                                                    FROM {role_assignments} ra, {context} c, {user} u
-
 
63
                                                   WHERE ra.userid = ?
Línea 57... Línea 64...
57
                                                   WHERE ra.userid = ?
64
                                                         AND ra.contextid = c.id
58
                                                         AND ra.contextid = c.id
65
                                                         AND c.instanceid = u.id
-
 
66
                                                         AND c.contextlevel = ?
-
 
67
                                                   ORDER BY $usersort", [$USER->id, CONTEXT_USER])) {
59
                                                         AND c.instanceid = u.id
68
 
60
                                                         AND c.contextlevel = ".CONTEXT_USER, array($USER->id))) {
69
            $this->content->text = '<ul>';
61
 
70
            foreach ($users as $user) {
62
            $this->content->text = '<ul>';
71
                $userprofileurl = user::get_profile_url($user);
Línea 63... Línea 72...
63
            foreach ($usercontexts as $usercontext) {
72
                $userfullname = user::get_fullname($user, $this->context);