? 303406-domain-theme.patch Index: domain_theme.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain_theme/domain_theme.admin.inc,v retrieving revision 1.2 diff -u -p -r1.2 domain_theme.admin.inc --- domain_theme.admin.inc 25 Mar 2009 17:46:34 -0000 1.2 +++ domain_theme.admin.inc 8 Apr 2009 17:42:43 -0000 @@ -68,6 +68,12 @@ function domain_theme_form_alter(&$form, 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'); @@ -90,6 +96,17 @@ function domain_theme_form_alter(&$form, '#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'; + } } /** @@ -165,3 +182,54 @@ function theme_domain_theme_reset($domai } 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.')); + } +} Index: domain_theme.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain_theme/domain_theme.module,v retrieving revision 1.13 diff -u -p -r1.13 domain_theme.module --- domain_theme.module 25 Mar 2009 17:46:34 -0000 1.13 +++ domain_theme.module 8 Apr 2009 17:42:43 -0000 @@ -21,7 +21,7 @@ */ function domain_theme_init() { // Assign the theme selected, based on the active domain. - global $_domain, $custom_theme; + global $_domain, $custom_theme, $conf; // If the theme has already been set (such as an admin theme), ignore. if (!empty($custom_theme)) { return; @@ -30,6 +30,10 @@ function domain_theme_init() { // 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; + } } } @@ -55,6 +59,14 @@ function domain_theme_menu() { '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; }