migrated wiki form to formslib
[moodle.git] / blocks / mnet_hosts / block_mnet_hosts.php
CommitLineData
6e6b8c85 1<?PHP //$Id$
2
3class block_mnet_hosts extends block_list {
4 function init() {
5 $this->title = get_string('mnet_hosts','block_mnet_hosts') ;
6 $this->version = 2006112100;
7 }
8
9 function has_config() {
10 return false;
11 }
12
13 function get_content() {
14 global $THEME, $CFG, $USER;
15
16 // check for outgoing roaming permission first
17 if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
18 return '';
19 }
20
21 if ($this->content !== NULL) {
22 return $this->content;
23 }
24
25 // TODO: Test this query - it's appropriate? It works?
26 // get the hosts and whether we are doing SSO with them
27 $sql = "
28 SELECT DISTINCT
29 h.id,
30 h.name
31 FROM
32 {$CFG->prefix}mnet_host h,
33 {$CFG->prefix}mnet_host2service h2s_IDP,
34 {$CFG->prefix}mnet_service s_IDP,
35 {$CFG->prefix}mnet_host2service h2s_SP,
36 {$CFG->prefix}mnet_service s_SP
37 WHERE
38 h.id != '{$CFG->mnet_localhost_id}' AND
39 h.id = h2s_IDP.hostid AND
40 h2s_IDP.serviceid = s_IDP.id AND
41 s_IDP.name = 'sso_idp' AND
42 h2s_IDP.publish = '1' AND
43 h.id = h2s_SP.hostid AND
44 h2s_SP.serviceid = s_SP.id AND
45 s_SP.name = 'sso_idp' AND
46 h2s_SP.publish = '1'";
47
48 $hosts = get_records_sql($sql);
49
50 $this->content = new stdClass;
51 $this->content->items = array();
52 $this->content->icons = array();
53 $this->content->footer = '';
54
5e142a17 55 $icon = "<img src=\"$CFG->pixpath/i/mnethost.gif\"".
0d905d9f 56 " class=\"icon\" alt=\"".get_string('server', 'block_mnet_hosts')."\" />";
6e6b8c85 57
d72fd695 58 if ($hosts) {
59 foreach ($hosts as $host) {
60 $this->content->icons[]=$icon;
61 $this->content->items[]="<a title=\"" .s($host->name).
62 "\" href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$host->id}\">" . s($host->name) ."</a>";
63 }
6e6b8c85 64 }
65
66 return $this->content;
67 }
68}
69
d72fd695 70?>