From 6e6b8c85169ed2f858ae6a530504167e23f92015 Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Thu, 4 Jan 2007 03:23:48 +0000 Subject: [PATCH] mnet: new mnet_hosts block --- blocks/mnet_hosts/block_mnet_hosts.php | 68 +++++++++++++++++++++++++ lang/en_utf8/block_mnet_hosts.php | 5 ++ pix/i/mnethost.png | Bin 0 -> 840 bytes 3 files changed, 73 insertions(+) create mode 100644 blocks/mnet_hosts/block_mnet_hosts.php create mode 100644 lang/en_utf8/block_mnet_hosts.php create mode 100644 pix/i/mnethost.png diff --git a/blocks/mnet_hosts/block_mnet_hosts.php b/blocks/mnet_hosts/block_mnet_hosts.php new file mode 100644 index 0000000000..6c41687d3e --- /dev/null +++ b/blocks/mnet_hosts/block_mnet_hosts.php @@ -0,0 +1,68 @@ +title = get_string('mnet_hosts','block_mnet_hosts') ; + $this->version = 2006112100; + } + + function has_config() { + return false; + } + + function get_content() { + global $THEME, $CFG, $USER; + + // check for outgoing roaming permission first + if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + return ''; + } + + if ($this->content !== NULL) { + return $this->content; + } + + // TODO: Test this query - it's appropriate? It works? + // get the hosts and whether we are doing SSO with them + $sql = " + SELECT DISTINCT + h.id, + h.name + FROM + {$CFG->prefix}mnet_host h, + {$CFG->prefix}mnet_host2service h2s_IDP, + {$CFG->prefix}mnet_service s_IDP, + {$CFG->prefix}mnet_host2service h2s_SP, + {$CFG->prefix}mnet_service s_SP + WHERE + h.id != '{$CFG->mnet_localhost_id}' AND + h.id = h2s_IDP.hostid AND + h2s_IDP.serviceid = s_IDP.id AND + s_IDP.name = 'sso_idp' AND + h2s_IDP.publish = '1' AND + h.id = h2s_SP.hostid AND + h2s_SP.serviceid = s_SP.id AND + s_SP.name = 'sso_idp' AND + h2s_SP.publish = '1'"; + + $hosts = get_records_sql($sql); + + $this->content = new stdClass; + $this->content->items = array(); + $this->content->icons = array(); + $this->content->footer = ''; + + $icon = "pixpath/i/mnethost.png\"". + " height=\"16\" width=\"16\" alt=\"".get_string('server', 'block_mnet_hosts')."\" />"; + + foreach ($hosts as $host) { + $this->content->icons[]=$icon; + $this->content->items[]="name). + "\" href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$host->id}\">" . s($host->name) .""; + } + + return $this->content; + } +} + +?> diff --git a/lang/en_utf8/block_mnet_hosts.php b/lang/en_utf8/block_mnet_hosts.php new file mode 100644 index 0000000000..969dd6c08a --- /dev/null +++ b/lang/en_utf8/block_mnet_hosts.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/pix/i/mnethost.png b/pix/i/mnethost.png new file mode 100644 index 0000000000000000000000000000000000000000..0e8b2406dcbea7d8cde9c14f72dbc0e008b9331f GIT binary patch literal 840 zcmV-O1GoH%P)+_`e4e?p-P z-AWp=DAjWSK z_+iU(e?uaz2RuqyjB!}&aIU7VYwFsc75MW6AO^TO1Dkcl(*1otxsyR&v6p*#B4VH- zdU}+86)e0cGy_Ys)?`(2k>F}j@W;NUUwS@$C*}LKzi74$&9I`b zYK*NJn2?^0>AM)|UJ21C%X_nuhXcn~Ki5RVF%DFdyh`YkkVh$L;<*%A#=T<7l@|?) zLhKEPn)jze=9;j&Yq)~t^~jI~hGwm)ONX%zr440Syu5(Ze)sO|7dt!KE5o7YN@#i8 zKWDx^;2&&&lao5jG8@OSkD}<+b^ZkaSF~e~ SrzCLz0000