<?php
admin_externalpage_print_header();

$currenttab = 'mnetservices';
require_once($CFG->dirroot .'/admin/mnet/tabs.php');

print_simple_box_start("center", "");

?>

<form method="post" action="mnet_services.php">
<div>
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
<input type="hidden" name="step" value="<?php echo $mnet_peer->nextstep; ?>" />
<input type="hidden" name="hostid" value="<?php echo ($mnet_peer->id)?  $mnet_peer->id : '0' ; ?>" />
<table cellpadding="9" cellspacing="0" >
<?php 
    foreach($myservices as $name => $versions) {
    $version = current($versions);
    $langmodule = ($version['parent_type'] == 'mod' ? '' : ($version['parent_type'] . '_')) . $version['parent'];
?>
<tr>
    <td align="left" valign="top" colspan="2">
    <h3><?php echo get_string($name.'_name', $langmodule , $mnet_peer->name); ?></h3>
    <?php echo get_string($name.'_description', $langmodule, $mnet_peer->name); ?>
<?php
        $breakstring = '';
        foreach($versions as $version){
            if (count($versions) > 1) {
                $versionstring = '('.get_string('version','mnet') .' '.$version['apiversion'].')';
            } else {
                $versionstring = '';
            }
    
            echo $breakstring;
?>
    <input type="hidden" name="exists[<?php echo  $version['serviceid']; ?>]" value="1" />
    <input type="checkbox" name="publish[<?php echo $version['serviceid']; ?>]" <?php echo (!empty($version['I_publish']))? 'checked="checked" ': '' ; ?>/>
<?php 
            print_string('publish','mnet');
            echo $versionstring; 
            if (!empty($version['hostsubscribes'])) { 
                echo '<a href="#" title="'.get_string('issubscribed','mnet', $mnet_peer->name).'">&radic;</a> '; 
            }
            if (!empty($version['allhosts_publish'])) { 
                print_string("enabled_for_all",'mnet',!empty($version['I_publish']));
            } 
            echo '<br />';
?>
    <input type="checkbox" name="subscribe[<?php echo $version['serviceid']; ?>]" <?php echo (!empty($version['I_subscribe']))? 'checked="checked" ': '' ; ?>/>
<?php 
            print_string('subscribe','mnet');
            echo $versionstring; 
            if (!empty($version['hostpublishes'])) { 
                echo '<a href="#" title="'.get_string('ispublished','mnet', $mnet_peer->name).'">&radic;</a> ';
            } 
            if (!empty($version['allhosts_subscribe'])) {
                print_string("enabled_for_all",'mnet',!empty($version['I_subscribe']));
            }
            
            echo '<br />';  
            $breakstring = '. . . . . . . . . . . . . . . . . . . . . . . . <br>';
        } // end foreach
?>
    </td>
</tr>
<?php
    } // end foreach
?>
<tr>
    <td align="left" valign="top" colspan="2">
    <div id="pubTreeLoc"></div>
    </td>
</tr>
<tr>
    <td align="left" valign="top" colspan="2">
    <div id="subTreeLoc"></div>
    </td>
</tr>
<tr>
    <td colspan="2"><input type="submit" value="<?php print_string("savechanges") ?>" /></td>
</tr>
<tr>
    <td align="left" valign="top" colspan="2">
    <div id="formElements"><input type="hidden" name="outer" value="4" /></div>
    </td>
</tr>
</table>
</div>
</form>
<?php
print_simple_box_end();
admin_externalpage_print_footer();
?>
