Tracker #MDL-9353 - Paypal cost of course not visible in course settings.
[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
052ba1f5 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);
16 } else {
1de58621 17 return array('site' => true);
052ba1f5 18 }
19 }
20
6e6b8c85 21 function get_content() {
22 global $THEME, $CFG, $USER;
23
f3203630 24 // only for logged in users!
25 if (!isloggedin() || isguest()) {
26 return false;
27 }
28
6e6b8c85 29 // check for outgoing roaming permission first
052ba1f5 30 if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM), NULL, false)) {
6e6b8c85 31 return '';
32 }
33
34 if ($this->content !== NULL) {
35 return $this->content;
36 }
37
38 // TODO: Test this query - it's appropriate? It works?
39 // get the hosts and whether we are doing SSO with them
40 $sql = "
41 SELECT DISTINCT
42 h.id,
43 h.name
44 FROM
45 {$CFG->prefix}mnet_host h,
46 {$CFG->prefix}mnet_host2service h2s_IDP,
47 {$CFG->prefix}mnet_service s_IDP,
48 {$CFG->prefix}mnet_host2service h2s_SP,
49 {$CFG->prefix}mnet_service s_SP
50 WHERE
51 h.id != '{$CFG->mnet_localhost_id}' AND
52 h.id = h2s_IDP.hostid AND
53 h2s_IDP.serviceid = s_IDP.id AND
54 s_IDP.name = 'sso_idp' AND
55 h2s_IDP.publish = '1' AND
56 h.id = h2s_SP.hostid AND
57 h2s_SP.serviceid = s_SP.id AND
58 s_SP.name = 'sso_idp' AND
59 h2s_SP.publish = '1'";
60
61 $hosts = get_records_sql($sql);
62
63 $this->content = new stdClass;
64 $this->content->items = array();
65 $this->content->icons = array();
66 $this->content->footer = '';
67
5e142a17 68 $icon = "<img src=\"$CFG->pixpath/i/mnethost.gif\"".
0d905d9f 69 " class=\"icon\" alt=\"".get_string('server', 'block_mnet_hosts')."\" />";
6e6b8c85 70
d72fd695 71 if ($hosts) {
72 foreach ($hosts as $host) {
73 $this->content->icons[]=$icon;
74 $this->content->items[]="<a title=\"" .s($host->name).
75 "\" href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$host->id}\">" . s($host->name) ."</a>";
76 }
6e6b8c85 77 }
78
79 return $this->content;
80 }
81}
82
052ba1f5 83?>