From 6b4f6a11e903a35ad7b3a922a4eb4da08d1fd0c0 Mon Sep 17 00:00:00 2001
From: Donal McMullan <donal@catalyst.net.nz>
Date: Thu, 13 Sep 2007 20:47:56 +1200
Subject: [PATCH] Add fields to mnet_host table for theme info

---
 lib/db/upgrade.php |   19 +++++++++++++++++++
 version.php        |    2 +-
 2 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php
index 75f8ffc..025e27c 100644
--- a/lib/db/upgrade.php
+++ b/lib/db/upgrade.php
@@ -697,6 +697,25 @@ function xmldb_main_upgrade($oldversion=0) {
         set_field('user', 'mnethostid', $CFG->mnet_localhost_id, 'username', 'guest');
     }
 
+    if ($oldversion < 2007091300) {
+        //
+        // MNET stuff for roaming theme
+        //
+        $table = new XMLDBTable('mnet_host');
+
+        $field = new XMLDBField('force_theme');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '0', 'last_log_id');
+
+        // Launch add field theme
+        $result = $result && add_field($table, $field);
+
+        $field = new XMLDBField('theme');
+        $field->setAttributes(XMLDB_TYPE_CHAR, '100', null, null, null, null, null, null, 'force_theme');
+
+        // Launch add field force_theme
+        $result = $result && add_field($table, $field);
+    }
+
     return $result;
 
 }
diff --git a/version.php b/version.php
index 26df5e9..cee6af9 100644
--- a/version.php
+++ b/version.php
@@ -6,7 +6,7 @@
 // This is compared against the values stored in the database to determine
 // whether upgrades should be performed (see lib/db/*.php)
 
-   $version = 2007021520;   // YYYYMMDD   = date of the 1.8 branch (don't change)
+   $version = 2007091300;   // YYYYMMDD   = date of the 1.8 branch (don't change)
                             //         X  = release number 1.8.[0,1,2,3...]
                             //          Y = micro-increments between releases
 
-- 
1.5.3


From bf44b1e7cd3a0ba0abf75d02aeb539788c76d6ac Mon Sep 17 00:00:00 2001
From: Donal McMullan <donal@catalyst.net.nz>
Date: Thu, 13 Sep 2007 22:46:43 +1200
Subject: [PATCH] Add an extra tab to the mnet config pages for 'themes'

---
 admin/mnet/mnet_review.html          |    1 +
 admin/mnet/mnet_review_allhosts.html |    1 +
 admin/mnet/mnet_services.html        |    1 +
 admin/mnet/mnet_services.php         |    1 +
 admin/mnet/peers.php                 |    1 +
 5 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/admin/mnet/mnet_review.html b/admin/mnet/mnet_review.html
index 52d99f6..76ee1bc 100644
--- a/admin/mnet/mnet_review.html
+++ b/admin/mnet/mnet_review.html
@@ -10,6 +10,7 @@ admin_externalpage_print_header($adminroot);
 if (isset($mnet_peer->id) && $mnet_peer->id > 0) {
     $tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&amp;hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
     $tabs[] = new tabobject('mnetservices', 'mnet_services.php?step=list&amp;hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
+    $tabs[] = new tabobject('mnetthemes', 'mnet_themes.php?step=list&amp;hostid='.$mnet_peer->id, $strmnetthemes, $strmnetthemes, false);
     $tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false);
 } else {
     $tabs[] = new tabobject('mnetdetails', '#', $strmnetedithost, $strmnetedithost, false);
diff --git a/admin/mnet/mnet_review_allhosts.html b/admin/mnet/mnet_review_allhosts.html
index b5bb001..7ea3726 100644
--- a/admin/mnet/mnet_review_allhosts.html
+++ b/admin/mnet/mnet_review_allhosts.html
@@ -3,6 +3,7 @@ admin_externalpage_print_header($adminroot);
 
 $tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&amp;hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
 $tabs[] = new tabobject('mnetservices', 'mnet_services.php?step=list&amp;hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
+$tabs[] = new tabobject('mnetthemes', 'mnet_themes.php?step=list&amp;hostid='.$mnet_peer->id, $strmnetthemes, $strmnetthemes, false);
 print_tabs(array($tabs), 'mnetdetails');
 
 print_simple_box_start("center", "");
diff --git a/admin/mnet/mnet_services.html b/admin/mnet/mnet_services.html
index f308cd6..dc9d8e4 100644
--- a/admin/mnet/mnet_services.html
+++ b/admin/mnet/mnet_services.html
@@ -9,6 +9,7 @@ $logurl = $CFG->wwwroot.
 
 $tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&amp;hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
 $tabs[] = new tabobject('mnetservices', 'mnet_services.php?step=list&amp;hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
+$tabs[] = new tabobject('mnetthemes', 'mnet_themes.php?step=list&amp;hostid='.$mnet_peer->id, $strmnetthemes, $strmnetthemes, false);
 if ($mnet_peer->id != $CFG->mnet_all_hosts_id) $tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false);
 print_tabs(array($tabs), 'mnetservices');
 print_simple_box_start("center", "");
diff --git a/admin/mnet/mnet_services.php b/admin/mnet/mnet_services.php
index bed8c3c..2a8471c 100644
--- a/admin/mnet/mnet_services.php
+++ b/admin/mnet/mnet_services.php
@@ -34,6 +34,7 @@
     $strconfiguration    = get_string('configuration');
     $strmnetsettings     = get_string('mnetsettings', 'mnet');
     $strmnetservices     = get_string('mnetservices', 'mnet');
+    $strmnetthemes       = get_string('mnetthemes', 'mnet');
     $strmnetlog          = get_string('mnetlog', 'mnet');
     $strmnetedithost     = get_string('reviewhostdetails', 'mnet');
     $strmneteditservices = get_string('reviewhostservices', 'mnet');
diff --git a/admin/mnet/peers.php b/admin/mnet/peers.php
index eee628d..112f551 100644
--- a/admin/mnet/peers.php
+++ b/admin/mnet/peers.php
@@ -41,6 +41,7 @@ $hostid = optional_param('hostid', NULL, PARAM_INT);
 $strmnetservices   = get_string('mnetservices', 'mnet');
 $strmnetlog        = get_string('mnetlog', 'mnet');
 $strmnetedithost   = get_string('reviewhostdetails', 'mnet');
+$strmnetthemes     = get_string('mnetthemes', 'mnet');
 
 if (!isset($CFG->mnet_dispatcher_mode)) set_config('mnet_dispatcher_mode', 'off');
 
-- 
1.5.3


From 40f84d758882e6a6bb6f8537c2e0b6bfd78c9cd6 Mon Sep 17 00:00:00 2001
From: Donal McMullan <donal@catalyst.net.nz>
Date: Thu, 13 Sep 2007 22:47:14 +1200
Subject: [PATCH] New strings for mnet theme transfers

---
 lang/en_utf8/mnet.php |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/lang/en_utf8/mnet.php b/lang/en_utf8/mnet.php
index 5558041..65afd76 100644
--- a/lang/en_utf8/mnet.php
+++ b/lang/en_utf8/mnet.php
@@ -9,6 +9,7 @@ $string['yourpeers']                    = 'Your Peers';
 $string['settings']                     = 'Settings';
 $string['hostsettings']                 = 'Host Settings';
 $string['mnetpeers']                    = 'Peers';
+$string['themesavederror']              = 'An error occurred: Theme change not saved';
 $string['mnetservices']                 = 'Moodle network services';
 $string['trustedhosts']                 = 'XML-RPC hosts';
 $string['trustedhostsexplain']          = '<p>The trusted hosts mechanism allows specific machines to
@@ -117,6 +118,7 @@ $string['verifysignature-error']        = 'The signature verification failed. An
 $string['verifysignature-invalid']      = 'The signature verification failed. It appears that this payload was not signed by you.';
 $string['mnetsettings']                 = 'Moodle network settings';
 $string['mnetservices']                 = 'Services';
+$string['mnetthemes']                   = 'Themes';
 $string['mnetlog']                      = 'Logs';
 
 $string['issubscribed']                 = 'The $a Moodle is subscribing to this service on your host.';
-- 
1.5.3


From 361563b1ce8b628ce57a7a5478f04d7713449a63 Mon Sep 17 00:00:00 2001
From: Donal McMullan <donal@catalyst.net.nz>
Date: Thu, 13 Sep 2007 22:47:41 +1200
Subject: [PATCH] Add theme fields to the mnet_peer object

---
 mnet/peer.php |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/mnet/peer.php b/mnet/peer.php
index 3058116..4d004c0 100644
--- a/mnet/peer.php
+++ b/mnet/peer.php
@@ -18,6 +18,8 @@ class mnet_peer {
     var $public_key_expires = 0;
     var $last_connect_time  = 0;
     var $last_log_id        = 0;
+    var $force_theme        = 0;
+    var $theme              = '';
     var $keypair            = array();
     var $error              = array();
 
@@ -67,6 +69,9 @@ class mnet_peer {
             $this->public_key_expires   = $this->check_common_name($this->public_key);
             $this->last_connect_time    = 0;
             $this->last_log_id          = 0;
+            $this->force_theme          = 0;
+            $this->theme                = '';
+            
             if ($this->public_key_expires == false) {
                 $this->public_key == '';
                 return false;
@@ -155,6 +160,8 @@ class mnet_peer {
         $obj->deleted               = $this->deleted;
         $obj->last_connect_time     = $this->last_connect_time;
         $obj->last_log_id           = $this->last_log_id;
+        $obj->force_theme           = $this->force_theme;
+        $obj->theme                 = $this->theme;
 
         if (isset($this->id) && $this->id > 0) {
             $obj->id = $this->id;
@@ -231,6 +238,8 @@ class mnet_peer {
         $this->public_key_expires   = $hostinfo->public_key_expires;
         $this->last_connect_time    = $hostinfo->last_connect_time;
         $this->last_log_id          = $hostinfo->last_log_id;
+        $this->force_theme          = $hostinfo->force_theme;
+        $this->theme                = $hostinfo->theme;
     }
 
     function get_public_key() {
-- 
1.5.3


From e0ca539e0914f5ca48f05e9385f81da83b700a1b Mon Sep 17 00:00:00 2001
From: Donal McMullan <donal@catalyst.net.nz>
Date: Thu, 13 Sep 2007 22:48:34 +1200
Subject: [PATCH] New pages for admin of mnet themes

---
 admin/mnet/mnet_themes.html |  128 +++++++++++++++++++++++++++++++++++++++++++
 admin/mnet/mnet_themes.php  |   79 ++++++++++++++++++++++++++
 2 files changed, 207 insertions(+), 0 deletions(-)
 create mode 100644 admin/mnet/mnet_themes.html
 create mode 100644 admin/mnet/mnet_themes.php

diff --git a/admin/mnet/mnet_themes.html b/admin/mnet/mnet_themes.html
new file mode 100644
index 0000000..6e83a23
--- /dev/null
+++ b/admin/mnet/mnet_themes.html
@@ -0,0 +1,128 @@
+<?php
+admin_externalpage_print_header($adminroot);
+
+$logurl = $CFG->wwwroot.
+          '/course/report/log/index.php?chooselog=1&amp;showusers=1&amp;showcourses=1&amp;host_course='.$mnet_peer->id.
+          '%2F1&amp;user='.'0'.
+          '&amp;date=0'.
+          '&amp;modid=&amp;modaction=0&amp;logformat=showashtml';
+
+$tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&amp;hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
+$tabs[] = new tabobject('mnetservices', 'mnet_services.php?step=list&amp;hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
+$tabs[] = new tabobject('mnetthemes', 'mnet_themes.php?step=list&amp;hostid='.$mnet_peer->id, $strmnetthemes, $strmnetthemes, false);
+if ($mnet_peer->id != $CFG->mnet_all_hosts_id) $tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false);
+print_tabs(array($tabs), 'mnetthemes');
+print_simple_box_start("center", "");
+
+    print_heading($strthemes);
+
+
+
+    $themes = get_list_of_plugins("theme");
+    $sesskey = !empty($USER->id) ? $USER->sesskey : '';
+
+    echo "<table style=\"margin-left:auto;margin-right:auto;\" cellpadding=\"7\" cellspacing=\"5\">";
+
+    if (count($report)) {
+        echo '<tr>';
+        echo '<td align="center" colspan="2">';
+        echo '<span class="'.$report[1].'">'.$report[0].'</span>';
+        echo '</td>';
+        echo '</tr>';
+    }
+
+    if (!$USER->screenreader) {
+        echo "<tr class=\"generaltableheader\"><th scope=\"col\">$strtheme</th>";
+        echo "<th scope=\"col\">$strinfo</th></tr>";
+    }
+
+    echo "<tr>";
+    echo '<td align="center"><span class="informationbox">Choose this option to use your site\'s default theme: <strong>'.$CFG->theme.'</strong>.</span></td>';
+    if ($mnet_peer->theme == '') {
+        echo '<td valign="top" style="border-style:solid; border-width:1px; border-color=#555555">';
+    } else {
+        echo '<td valign="top">';
+    }
+    echo '<p style="font-size:1.5em;font-style:bold;">Site Theme</p>';
+    $options = null;
+    $options['choose'] = 'ZoqZoqZ';
+    $options['sesskey'] = $sesskey;
+    $options['hostid'] = $mnet_peer->id;
+    print_single_button('mnet_themes.php', $options, $strchoose);
+    echo '</td>';
+    echo "</tr>";
+
+    foreach ($themes as $theme) {
+
+        unset($THEME);
+
+        if (!file_exists($CFG->themedir.'/'.$theme.'/config.php')) {   // bad folder
+            continue;
+        }
+
+        include($CFG->themedir.'/'.$theme.'/config.php');
+
+        $readme = '';
+        $screenshot = '';
+        $screenshotpath = '';
+
+        if (file_exists($CFG->themedir.'/'.$theme.'/README.html')) {
+            $readme =  '<li>'.
+            link_to_popup_window($CFG->themewww .'/'. $theme .'/README.html', $theme, $strinfo, 400, 500, '', 'none', true).'</li>';
+        } else if (file_exists($CFG->themedir.'/'.$theme.'/README.txt')) {
+            $readme =  '<li>'.
+            link_to_popup_window($CFG->themewww .'/'. $theme .'/README.txt', $theme, $strinfo, 400, 500, '', 'none', true).'</li>';
+        }
+        if (file_exists("$theme/screenshot.png")) {
+            $screenshotpath = "$theme/screenshot.png";
+        } else if (file_exists("$theme/screenshot.jpg")) {
+            $screenshotpath = "$theme/screenshot.jpg";
+        }
+
+        echo "<tr>";
+             
+        // no point showing this if user is using screen reader
+        if (!$USER->screenreader) {
+            echo "<td align=\"center\">";
+            if ($screenshotpath) {
+                $screenshot = '<li><a href='.$CFG->wwwroot .'/theme/'. $theme.'/screenshot.jpg">'.$strscreenshot.'</a></li>';
+                echo "<object type=\"text/html\" data=\"$screenshotpath\" height=\"200\" width=\"400\">$theme</object></td>";
+            } else {
+                echo '<object type="text/html" data="'.$CFG->wwwroot.'/theme/preview.php?preview='.$theme.'" height="200" width="400">'.$theme.'</object></td>';
+            }
+        }
+
+        if ($mnet_peer->theme == $theme) {
+            echo '<td valign="top" style="border-style:solid; border-width:1px; border-color=#555555">';
+        } else {
+            echo '<td valign="top">';
+        }
+
+        if (isset($THEME->sheets)) {
+            echo '<p style="font-size:1.5em;font-style:bold;">'.$theme.'</p>';
+        } else {
+            echo '<p style="font-size:1.5em;font-style:bold;color:red;">'.$theme.' (Moodle 1.4)</p>';
+        }
+          
+        if ($screenshot or $readme) {
+            echo '<ul>';      
+            if (!$USER->screenreader) {
+                echo '<li><a href="'.$CFG->wwwroot.'/theme/preview.php?preview='.$theme.'">'.$strpreview.'</a></li>';
+            }
+            echo $screenshot.$readme;
+            echo '</ul>';
+        }
+
+        $options = null;
+        $options['choose'] = $theme;
+        $options['sesskey'] = $sesskey;
+        $options['hostid'] = $mnet_peer->id;
+        print_single_button('mnet_themes.php', $options, $strchoose);
+        echo '</td>';
+        echo "</tr>";
+    }
+    echo "</table>";
+
+print_simple_box_end();
+admin_externalpage_print_footer($adminroot);
+?>
diff --git a/admin/mnet/mnet_themes.php b/admin/mnet/mnet_themes.php
new file mode 100644
index 0000000..a7edc08
--- /dev/null
+++ b/admin/mnet/mnet_themes.php
@@ -0,0 +1,79 @@
+<?php
+    // Allows the admin to configure services for remote hosts
+
+    require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
+    require_once($CFG->libdir.'/adminlib.php');
+    include_once($CFG->dirroot.'/mnet/lib.php');
+error_reporting(E_ALL);
+ini_set('display_errors', true);
+    require_login();
+    $adminroot = admin_get_root();
+    admin_externalpage_setup('mnetpeers', $adminroot);
+
+    $context = get_context_instance(CONTEXT_SYSTEM);
+
+    require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
+
+    if (!$site = get_site()) {
+        print_error('nosite', '', '', NULL, true);
+    }
+
+/// Initialize variables.
+
+    $hostid = required_param('hostid', PARAM_INT);
+
+    $stradministration   = get_string('administration');
+    $strconfiguration    = get_string('configuration');
+
+    $strmnetedithost   = get_string('reviewhostdetails', 'mnet');
+    $strmnetsettings     = get_string('mnetsettings', 'mnet');
+    $strmnetservices     = get_string('mnetservices', 'mnet');
+    $strmnetthemes       = get_string('mnetthemes', 'mnet');
+    $strmnetlog          = get_string('mnetlog', 'mnet');
+
+
+    $mnet_peer = new mnet_peer();
+    if (is_int($hostid)) {
+        $mnet_peer->set_id($hostid);
+    }
+
+    $choose = optional_param("choose",'',PARAM_FILE);   // set this theme as default
+    $stradministration = get_string("administration");
+    $strconfiguration = get_string("configuration");
+    $strthemes = get_string("themes");
+    $strpreview = get_string("preview");
+    $strchoose = get_string("choose");
+    $strinfo = get_string("info");
+    $strtheme = get_string("theme");
+    $strthemesaved = get_string("themesaved");
+    $strscreenshot = get_string("screenshot");
+    $stroldtheme = get_string("oldtheme");
+    $report = array();
+
+    if ($choose) {
+        if (confirm_sesskey()) {
+            if ($choose == 'ZoqZoqZ') {
+                $mnet_peer->force_theme = 1;
+                $mnet_peer->theme = '';
+                if ($mnet_peer->commit()) {
+                    $report = array(get_string('themesaved'), 'informationbox');
+                } else {
+                    $report = array(get_string('themesavederror', 'mnet'), 'errorbox');
+                }
+            } elseif (!is_dir($CFG->themedir .'/'. $choose) || !file_exists($CFG->themedir .'/'. $choose .'/config.php')) {
+                        echo 'CHOOSE -'.$choose.' '. $CFG->themedir .'/'. $choose .'/config.php' ;
+                $report = array('This theme is not installed!'.'3', 'errorbox');
+            } else {
+                $mnet_peer->force_theme = 1;
+                $mnet_peer->theme = addslashes($choose);
+                if ($mnet_peer->commit()) {
+                    $report = array(get_string('themesaved').'1', 'informationbox');
+                } else {
+                    $report = array(get_string('themesavederror', 'mnet').'2', 'errorbox');
+                }
+            }
+        }
+    }
+
+    include('./mnet_themes.html');
+?>
-- 
1.5.3


From 8a5a81c22bd6cb774d8b49e8e7dca9aebabb6e90 Mon Sep 17 00:00:00 2001
From: Donal McMullan <donal@catalyst.net.nz>
Date: Thu, 13 Sep 2007 23:46:16 +1200
Subject: [PATCH] Make it clearer what the unlikely-name thing is

---
 admin/mnet/mnet_themes.html |    2 +-
 admin/mnet/mnet_themes.php  |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/admin/mnet/mnet_themes.html b/admin/mnet/mnet_themes.html
index 6e83a23..ed75057 100644
--- a/admin/mnet/mnet_themes.html
+++ b/admin/mnet/mnet_themes.html
@@ -45,7 +45,7 @@ print_simple_box_start("center", "");
     }
     echo '<p style="font-size:1.5em;font-style:bold;">Site Theme</p>';
     $options = null;
-    $options['choose'] = 'ZoqZoqZ';
+    $options['choose'] = $unlikely_name;// Something unlikely to ever be a theme name... initially $unlikely_name = 'ZoqZoqZ';
     $options['sesskey'] = $sesskey;
     $options['hostid'] = $mnet_peer->id;
     print_single_button('mnet_themes.php', $options, $strchoose);
diff --git a/admin/mnet/mnet_themes.php b/admin/mnet/mnet_themes.php
index a7edc08..b82c179 100644
--- a/admin/mnet/mnet_themes.php
+++ b/admin/mnet/mnet_themes.php
@@ -49,10 +49,11 @@ ini_set('display_errors', true);
     $strscreenshot = get_string("screenshot");
     $stroldtheme = get_string("oldtheme");
     $report = array();
+    $unlikely_name = 'ZoqZoqZ'; // Something unlikely to ever be a theme name
 
     if ($choose) {
         if (confirm_sesskey()) {
-            if ($choose == 'ZoqZoqZ') {
+            if ($choose == $unlikely_name) {
                 $mnet_peer->force_theme = 1;
                 $mnet_peer->theme = '';
                 if ($mnet_peer->commit()) {
-- 
1.5.3


From 0d1848fa9927d08fe04c2b9b5d4b501152a0f504 Mon Sep 17 00:00:00 2001
From: Donal McMullan <donal@catalyst.net.nz>
Date: Thu, 13 Sep 2007 23:48:55 +1200
Subject: [PATCH] Display the user's mnet theme

---
 lib/weblib.php |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/lib/weblib.php b/lib/weblib.php
index 47927cd..0e7de14 100644
--- a/lib/weblib.php
+++ b/lib/weblib.php
@@ -2489,12 +2489,20 @@ function current_theme() {
     } else if (!empty($SESSION->theme)) {    // Session theme can override other settings
         return $SESSION->theme;
 
-    } else if (!empty($CFG->allowuserthemes) and !empty($USER->theme)) {    // User theme can override site theme
+    } else if (!empty($CFG->allowuserthemes) and !empty($USER->theme) and $USER->mnethostid == $CFG->mnet_localhost_id) {    // User theme can override site theme
         return $USER->theme;
 
-    } else {
-        return $CFG->theme;
+    } else if ($USER->mnethostid != $CFG->mnet_localhost_id) {    // Remote-site theme can override site theme
+        require_once($CFG->dirroot.'/mnet/peer.php');
+        $mnet_peer = new mnet_peer();
+        $mnet_peer->set_id($USER->mnethostid);
+        if($mnet_peer->force_theme == 1 && $mnet_peer->theme != '') {
+            return $mnet_peer->theme;
+        }
     }
+
+    return $CFG->theme;
+
 }
 
 
-- 
1.5.3


From 387e2f03e6a1a5f8fdb5f45c64d19d6dd6363ca9 Mon Sep 17 00:00:00 2001
From: donal <donal@tibook.local>
Date: Thu, 27 Sep 2007 13:40:21 +1200
Subject: [PATCH] Add new fields to lib/db/install.xml for mnet_host:force_theme and mnet_host:theme

---
 lib/db/install.xml |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lib/db/install.xml b/lib/db/install.xml
index 367f0b9..e597df3 100644
--- a/lib/db/install.xml
+++ b/lib/db/install.xml
@@ -1046,7 +1046,9 @@
         <FIELD NAME="transport" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="public_key_expires" NEXT="portno"/>
         <FIELD NAME="portno" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="transport" NEXT="last_connect_time"/>
         <FIELD NAME="last_connect_time" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="portno" NEXT="last_log_id"/>
-        <FIELD NAME="last_log_id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="last_connect_time"/>
+        <FIELD NAME="last_log_id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="last_connect_time" NEXT="force_theme"/>
+        <FIELD NAME="force_theme" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="enroltype" NEXT="theme"/>
+        <FIELD NAME="theme" TYPE="char" LENGTH="100" NOTNULL="true" UNSIGNED="true" DEFAULT="" SEQUENCE="false" ENUM="false" PREVIOUS="force_theme"/>
       </FIELDS>
       <KEYS>
         <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the mnet_host table"/>
-- 
1.5.3

