$info) { $types[$type] = $info->name; } $form['nodes'] = array( '#type' => 'fieldset', '#title' => t('Nodes'), '#collapsible' => TRUE, '#collapsed' => FALSE, ); $form['nodes']['ut_basic_node_types'] = array( '#type' => 'checkboxes', '#title' => t('Counted node types'), '#description' => t('Only the checked node types will be counted'), '#options' => $types, '#default_value' => variable_get('ut_basic_node_types', array()), ); $form['comments'] = array( '#type' => 'fieldset', '#title' => t('Comments'), '#collapsible' => TRUE, '#collapsed' => FALSE, ); $form['comments']['ut_basic_comment_types'] = array( '#type' => 'checkboxes', '#title' => t('Counted node type comments'), '#description' => t('Only comments on the checked node types will be counted'), '#options' => $types, '#default_value' => variable_get('ut_basic_comment_types', array()), ); $form['recalculate'] = array( '#type' => 'fieldset', '#title' => t('Recalculate'), '#description' => t('This will clear all user post counts and recalculate them based on the types selected above. Titles will be automatically recalculated when the above type options are changed.'), ); $form['recalculate']['recalculate_posts'] = array( '#type' => 'submit', '#value' => t('Recalculate all user post counts'), ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), ); return $form; } /** * Submit handler for ut_basic_settings_form. */ function ut_basic_settings_form_submit($form, &$form_state) { if ($form_state['values']['op'] == t('Recalculate all user post counts')) { ut_basic_update_all_post_counts(); $form_state['redirect'] = FALSE; return; } $old_comment = variable_get('ut_basic_comment_types', array()); $old_node = variable_get('ut_basic_node_types', array()); variable_set('ut_basic_comment_types', $form_state['values']['ut_basic_comment_types']); variable_set('ut_basic_node_types', $form_state['values']['ut_basic_node_types']); if (!array_diff($old_comment, $form_state['values']['ut_basic_comment_types']) || !array_diff($old_node, $form_state['values']['ut_basic_node_types'])) { ut_basic_update_all_post_counts(); } }