diff -u ./domain_theme.admin.inc ../domain_theme_patched/domain_theme.admin.inc --- ./domain_theme.admin.inc 2008-11-26 01:53:33.000000000 -0500 +++ ../domain_theme_patched/domain_theme.admin.inc 2008-11-26 01:49:07.000000000 -0500 @@ -58,6 +58,12 @@ else { $form['status']['#disabled'] = TRUE; } + + if($form[$key] && $form[$key]['operations']) { + $form[$key]['operations']= array( + '#value' => l(t('configure'), 'admin/build/domain/theme/' . $_domain['domain_id'] . '/settings/' . $key), + ); + } } // Use our own submit buttons. $unset = array('buttons', '#submit'); @@ -80,6 +86,17 @@ '#value' => t('Set domain theme'), ); } + + if ($form_id == 'system_theme_settings') { + global $_domain; + // Which domain are we editing? + $form['domain_id'] = array( + '#type' => 'value', + '#value' => $_domain['domain_id'], + ); + $form['#submit']=array(); + $form['#submit'][] = 'domain_theme_settings_submit'; + } } /** @@ -155,3 +172,54 @@ } return $output; } + +/** + * The domain theme page callback router. + * + * @param $domain + * The $domain object created by domain_lookup(). + */ +function domain_theme_settings($domain) { + if (isset($domain['domain_id'])) { + // Ensure we are on the proper domain. + domain_goto($domain); + + // Load the system form file. + include_once(drupal_get_path('module', 'system') . '/system.admin.inc'); + + drupal_set_title(t('!site : Domain theme settings', array('!site' => $domain['sitename']))); + + $data = db_fetch_array(db_query("SELECT theme FROM {domain_theme} WHERE domain_id = %d", $domain['domain_id'])); + if (!empty($data)) { + return drupal_get_form('system_theme_settings', $data['theme']); + } + else { + return drupal_get_form('system_theme_settings'); + } + } + else { + return t('Invalid domain request.'); + } +} + +/** + * Process domain_theme_settings form submissions. + */ +function domain_theme_settings_submit($form, &$form_state) { + $values = $form_state['values']; + $key = $values['var']; + $id = $values['domain_id']; + + if ($values['op'] == t('Reset to defaults')) { + db_query("UPDATE {domain_theme} SET settings = NULL WHERE domain_id = %d", $id); + drupal_set_message(t('The configuration options have been reset to their default values.')); + } + else { + // Exclude unnecessary elements before saving. + unset($values['var'], $values['submit'], $values['reset'], $values['form_id'], $values['op'], $values['form_build_id'], $values['form_token'],$values['domain_id']); + $settings = serialize($values); + db_query("UPDATE {domain_theme} SET settings = %b WHERE domain_id = %d", $settings, $id); + + drupal_set_message(t('The configuration options have been saved.')); + } +} diff -u ./domain_theme.module ../domain_theme_patched/domain_theme.module --- ./domain_theme.module 2008-11-26 01:53:33.000000000 -0500 +++ ../domain_theme_patched/domain_theme.module 2008-11-25 23:44:31.000000000 -0500 @@ -21,12 +21,16 @@ */ function domain_theme_init() { // Assign the theme selected, based on the active domain. - global $_domain, $custom_theme; + global $_domain, $custom_theme, $conf; $default_theme = variable_get('theme_default', 'garland'); $theme = domain_theme_lookup($_domain['domain_id']); // The above returns -1 on failure. if ($theme != -1) { $custom_theme = $theme['theme']; + if ($theme['settings']) { + $settings = unserialize($theme['settings']); + $conf['theme_' . $custom_theme . '_settings'] = $settings; + } } } @@ -52,6 +56,14 @@ 'page arguments' => array(4), 'file' => 'domain_theme.admin.inc', ); + $items['admin/build/domain/theme/%domain/settings'] = array( + 'title' => 'Configure domain theme settings', + 'type' => MENU_CALLBACK, + 'access arguments' => array('administer domains'), + 'page callback' => 'domain_theme_settings', + 'page arguments' => array(4), + 'file' => 'domain_theme.admin.inc', + ); return $items; }