Needs review
Project:
Subsites
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Jan 2012 at 10:27 UTC
Updated:
4 May 2015 at 03:29 UTC
Jump to comment: Most recent
When submitting the form found at 'admin/build/subsites/1/content/pages' the current CSS of the subsite is deleted.
I used the following code to resolve the problem:
Change
function subsites_content_pages_form_submit($form, &$form_state) {
$old_subsite = subsites_get($form_state['values']['sid']);
subsites_edit($form_state['values']['sid'], $old_subsite->name, $form_state['values']['pages'], $form_state['values']['visibility'], $old_subsite->css, $old_subsite->theme, $old_subsite->weight, $old_subsite->status, $old_subsite->header, $old_subsite->headerlink);
$form_state['redirect'] = 'admin/build/subsites/'. $form_state['values']['sid'] .'/content/pages';
drupal_set_message(t('subsites configuration changes saved.'));
}
To:
function subsites_content_pages_form_submit($form, &$form_state) {
$old_subsite = subsites_get($form_state['values']['sid']);
subsites_edit($form_state['values']['sid'], $old_subsite->name, $form_state['values']['pages'], $form_state['values']['visibility'], NULL, $old_subsite->theme, $old_subsite->weight, $old_subsite->status, $old_subsite->header, $old_subsite->headerlink);
$form_state['redirect'] = 'admin/build/subsites/'. $form_state['values']['sid'] .'/content/pages';
drupal_set_message(t('subsites configuration changes saved.'));
}
and change:
function subsites_edit($sid, $name, $pages, $visibility, $css, $theme, $weight, $status, $header, $headerlink) {
// update db
db_query("UPDATE {subsites} SET name = '%s', pages = '%s', visibility = %d, theme = '%s', weight = %d, status = %d, header = '%s', headerlink = '%s' WHERE sid = %d", $name, $pages, $visibility, $theme, $weight, $status, $header, $headerlink, $sid);
// update menu item weight
db_query("UPDATE {menu_links} SET weight = %d WHERE link_path = '%s'", $weight, 'admin/build/subsites/'. $sid);
// save css
file_check_directory(file_create_path('subsites'), FILE_CREATE_DIRECTORY);
file_check_directory(file_create_path('subsites/'. $sid), FILE_CREATE_DIRECTORY);
file_save_data($css, subsites_get_css_path($sid), FILE_EXISTS_REPLACE);
}to
function subsites_edit($sid, $name, $pages, $visibility, $css, $theme, $weight, $status, $header, $headerlink) {
// update db
db_query("UPDATE {subsites} SET name = '%s', pages = '%s', visibility = %d, theme = '%s', weight = %d, status = %d, header = '%s', headerlink = '%s' WHERE sid = %d", $name, $pages, $visibility, $theme, $weight, $status, $header, $headerlink, $sid);
// update menu item weight
db_query("UPDATE {menu_links} SET weight = %d WHERE link_path = '%s'", $weight, 'admin/build/subsites/'. $sid);
// save css
if($css != NULL):
file_check_directory(file_create_path('subsites'), FILE_CREATE_DIRECTORY);
file_check_directory(file_create_path('subsites/'. $sid), FILE_CREATE_DIRECTORY);
file_save_data($css, subsites_get_css_path($sid), FILE_EXISTS_REPLACE);
endif;
}
Comments
Comment #1
chunty commentedRunning this update bust my site as the subsites table did not have either the "header" or a "headerlink" column so I had to use:
Not sure if this down to a version issue or something but I am running 6.x-1.x-dev
Comment #2
gisleThis suggestion (it is not even a patch) has never been properly reviewed by the community. Changing status.