3 class block_mnet_hosts
extends block_list
{
5 $this->title
= get_string('mnet_hosts','block_mnet_hosts') ;
6 $this->version
= 2006112100;
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);
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 // check for outgoing roaming permission first
30 if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM
), NULL, false)) {
34 if ($this->content
!== NULL) {
35 return $this->content
;
38 // TODO: Test this query - it's appropriate? It works?
39 // get the hosts and whether we are doing SSO with them
45 a.name as application,
48 {$CFG->prefix}mnet_host h,
49 {$CFG->prefix}mnet_application a,
50 {$CFG->prefix}mnet_host2service h2s_IDP,
51 {$CFG->prefix}mnet_service s_IDP,
52 {$CFG->prefix}mnet_host2service h2s_SP,
53 {$CFG->prefix}mnet_service s_SP
55 h.id != '{$CFG->mnet_localhost_id}' AND
56 h.id = h2s_IDP.hostid AND
57 h.applicationid = a.id AND
58 h2s_IDP.serviceid = s_IDP.id AND
59 s_IDP.name = 'sso_idp' AND
60 h2s_IDP.publish = '1' AND
61 h.id = h2s_SP.hostid AND
62 h2s_SP.serviceid = s_SP.id AND
63 s_SP.name = 'sso_idp' AND
69 $hosts = get_records_sql($sql);
71 $this->content
= new stdClass
;
72 $this->content
->items
= array();
73 $this->content
->icons
= array();
74 $this->content
->footer
= '';
77 foreach ($hosts as $host) {
78 $icon = '<img src="'.$CFG->pixpath
.'/i/'.$host->application
.'_host.gif"'.
79 ' class="icon" alt="'.get_string('server', 'block_mnet_hosts').'" />';
81 $this->content
->icons
[]=$icon;
82 if ($host->id
== $USER->mnethostid
) {
83 $this->content
->items
[]="<a title=\"" .s($host->name
).
84 "\" href=\"{$host->wwwroot}\">". s($host->name
) ."</a>";
86 $this->content
->items
[]="<a title=\"" .s($host->name
).
87 "\" href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$host->id}\">" . s($host->name
) ."</a>";
92 return $this->content
;