3 class block_mnet_hosts
extends block_list
{
5 $this->title
= get_string('mnet_hosts','block_mnet_hosts') ;
6 $this->version
= 2007101509;
9 function has_config() {
13 function applicable_formats() {
14 if (has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM
), NULL, false)) {
15 return array('all' => true, 'mod' => false, 'tag' => false);
17 return array('site' => true);
21 function get_content() {
22 global $THEME, $CFG, $USER;
24 // only for logged in users!
25 if (!isloggedin() ||
isguest()) {
29 if (!is_enabled_auth('mnet')) {
30 // no need to query anything remote related
31 debugging( 'mnet authentication plugin is not enabled', DEBUG_ALL
);
35 // check for outgoing roaming permission first
36 if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM
), NULL, false)) {
40 if ($this->content
!== NULL) {
41 return $this->content
;
44 // TODO: Test this query - it's appropriate? It works?
45 // get the hosts and whether we are doing SSO with them
51 a.name as application,
54 {$CFG->prefix}mnet_host h,
55 {$CFG->prefix}mnet_application a,
56 {$CFG->prefix}mnet_host2service h2s_IDP,
57 {$CFG->prefix}mnet_service s_IDP,
58 {$CFG->prefix}mnet_host2service h2s_SP,
59 {$CFG->prefix}mnet_service s_SP
61 h.id != '{$CFG->mnet_localhost_id}' AND
62 h.id = h2s_IDP.hostid AND
64 h.applicationid = a.id AND
65 h2s_IDP.serviceid = s_IDP.id AND
66 s_IDP.name = 'sso_idp' AND
67 h2s_IDP.publish = '1' AND
68 h.id = h2s_SP.hostid AND
69 h2s_SP.serviceid = s_SP.id AND
70 s_SP.name = 'sso_idp' AND
76 $hosts = get_records_sql($sql);
78 $this->content
= new stdClass
;
79 $this->content
->items
= array();
80 $this->content
->icons
= array();
81 $this->content
->footer
= '';
84 foreach ($hosts as $host) {
85 $icon = '<img src="'.$CFG->pixpath
.'/i/'.$host->application
.'_host.gif"'.
86 ' class="icon" alt="'.get_string('server', 'block_mnet_hosts').'" />';
88 $this->content
->icons
[]=$icon;
89 if ($host->id
== $USER->mnethostid
) {
90 $this->content
->items
[]="<a title=\"" .s($host->name
).
91 "\" href=\"{$host->wwwroot}\">". s($host->name
) ."</a>";
93 $this->content
->items
[]="<a title=\"" .s($host->name
).
94 "\" href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$host->id}\">" . s($host->name
) ."</a>";
99 return $this->content
;