Index: site_user_list.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/site_user_list/Attic/site_user_list.module,v retrieving revision 1.1.2.6.2.1 diff -u -r1.1.2.6.2.1 site_user_list.module --- site_user_list.module 29 Mar 2007 18:06:39 -0000 1.1.2.6.2.1 +++ site_user_list.module 11 Apr 2007 11:54:43 -0000 @@ -32,7 +32,7 @@ ), array( 'path' => 'site_user_list', - 'title' => t('Site user list'), + 'title' => t(variable_get('site_list_title','Site user list')), 'callback' => 'site_user_list_show', 'access' => user_access('view site user list'), 'type' => MENU_NORMAL_ITEM, @@ -65,6 +65,28 @@ function site_user_list_admin_settings_form() { $form = array(); + $form['ui_options'] = array( + '#type' => 'fieldset', + '#title' => 'List Options' + ); + + $form['ui_options']['site_list_title'] = array( + '#type' => 'textfield', + '#title' => t('Page & Menu Title'), + '#default_value' => variable_get('site_list_title', 'Site user list'), + ); + $form['ui_options']['enable_display_option'] = array( + '#type' => 'checkbox', + '#title' => t('Enable Display Options fiedlset'), + '#default_value' => variable_get('enable_display_option', 1), + ); + + $form['ui_options']['enable_search_option'] = array( + '#type' => 'checkbox', + '#title' => t('Enable Search Options fiedlset'), + '#default_value' => variable_get('enable_search_option', 1), + ); + $form['query_type_fs'] = array( '#type' => 'fieldset', ); @@ -187,6 +209,12 @@ variable_set('site_user_list_allowed_fields', $allowed); variable_set('site_user_list_default_fields', $default); variable_set('site_user_list_field_names', $fvals['fields_holder']); + + variable_set('enable_display_option', $fvals['enable_display_option']); + variable_set('enable_search_option', $fvals['enable_search_option']); + variable_set('site_list_title', $fvals['site_list_title']); + // Clear cache_menu so changes to title will be reflected in menu name + cache_clear_all('*', 'cache_menu', true); variable_set('site_user_list_query_type', $fvals['query_type']); variable_set('site_user_list_select_from', 'site_user_list_' . $fvals['query_type']); @@ -264,13 +292,13 @@ $type = variable_get('site_user_list_query_type', 'view'); $name = variable_get('site_user_list_select_from', 'site_user_list_view'); if ($type == 'view') { - db_query("CREATE OR REPLACE VIEW {$name} AS " . $internal_sql); + db_query("CREATE OR REPLACE VIEW \{$name} AS " . $internal_sql); } elseif ($type == 'table') { - if (db_table_exists("{$name}")) { - db_query("DROP TABLE {$name}"); + if (db_table_exists("\{$name}")) { + db_query("DROP TABLE \{$name}"); } - db_query("CREATE TABLE {$name} AS " . $internal_sql); + db_query("CREATE TABLE \{$name} AS " . $internal_sql); } } @@ -320,8 +348,8 @@ // the default comes from the settings, but it overridden by what the 'display_columns' // variable (which comes from the display options form) is set to. $display_request = array_filter(variable_get('site_user_list_default_fields', array('name' => 1, 'mail' => 1))); - if ($_REQUEST['edit']['display_columns']) { - $display_request = array_filter($_REQUEST['edit']['display_columns']); + if ($_REQUEST['display_columns']) { + $display_request = array_filter($_REQUEST['display_columns']); } // allowed_display is an array that will be used for the display options bit of the form. @@ -361,8 +389,8 @@ // now, get the search parameters $search_restrictions = array(); - if ($_REQUEST['edit']['search_form']) { - $search_restrictions = $_REQUEST['edit']['search_form']; + if ($_REQUEST['search_form']) { + $search_restrictions = $_REQUEST['search_form']; } // get the joins and wheres to put into the query @@ -394,7 +422,7 @@ // build the query $select_from = variable_get('site_user_list_select_from', 'site_user_list_view'); $sql = 'SELECT DISTINCT cd.uid as uid_key, ' . implode(', ', $select_columns) . ' ' - . "FROM {$select_from} as cd " + . "FROM \{$select_from} as cd " . implode(' ', $sql_options['joins']) . ' ' . 'WHERE cd.uid not in (' . implode(", ", $users_to_exclude) . ')' . (count($sql_options['where']) ? " and " . implode(" and ", $sql_options['where']) @@ -424,65 +452,73 @@ ); } - $form['root'] = array( - '#type' => 'fieldset', - '#title' => '', - '#collapsible' => false, - ); - - $form['root']['display_form'] = array( - '#type' => 'fieldset', - '#title' => 'Display Options', - '#collapsible' => true, - '#collapsed' => true, - '#attributes' => array('class' => 'site-user-list-checkboxes-form'), - ); - $form['root']['display_form']['display_columns'] = array( - '#type' => 'checkboxes', - '#options' => $allowed_display, - '#default_value' => $fields_to_show, - ); - $form['root']['display_form'][] = array( - '#type' => 'submit', - '#value' => 'Update display', - '#prefix' => "

\n", - '#suffix' => "

\n", - ); - - $form['root']['search_form'] = array( - '#type' => 'fieldset', - '#title' => 'Search Options', - '#collapsible' => true, - '#collapsed' => (count($search_info) ? false : true), - '#tree' => true, - ); - $form['root']['search_form'][] = array( - '#type' => 'markup', - '#value' => '

Display users where:

', - ); - - // get the additional search forms using the hook we've defined - // the hook should return an array like: - // array('module_name' => array('key' => form fieldset to be imported, 'form' => a form-style array with a fieldset named as the key)) - $search_forms = module_invoke_all('site_user_list_search_form', $search_restrictions); - $form['root']['search_form'][$search_forms['site_user_list']['key']] = $search_forms['site_user_list']['form'][$search_forms['site_user_list']['key']]; - foreach ($search_forms as $module => $additions) { - if ($module != 'site_user_list') { + $enable_display_option = variable_get('enable_display_option',1); + $enable_search_option = variable_get('enable_search_option',1); + if ($enable_search_option || $enable_display_option) { + $form['root'] = array( + '#type' => 'fieldset', + '#title' => '', + '#collapsible' => false, + ); + + if ($enable_display_option) { + $form['root']['display_form'] = array( + '#type' => 'fieldset', + '#title' => 'Display Options', + '#collapsible' => true, + '#collapsed' => true, + '#attributes' => array('class' => 'site-user-list-checkboxes-form'), + ); + $form['root']['display_form']['display_columns'] = array( + '#type' => 'checkboxes', + '#options' => $allowed_display, + '#default_value' => $fields_to_show, + ); + $form['root']['display_form'][] = array( + '#type' => 'submit', + '#value' => 'Update display', + '#prefix' => "

\n", + '#suffix' => "

\n", + ); + } + + if ($enable_search_option) { + $form['root']['search_form'] = array( + '#type' => 'fieldset', + '#title' => 'Search Options', + '#collapsible' => true, + '#collapsed' => (count($search_info) ? false : true), + '#tree' => true, + ); $form['root']['search_form'][] = array( '#type' => 'markup', - '#value' => '

and

', + '#value' => '

Display users where:

', + ); + + // get the additional search forms using the hook we've defined + // the hook should return an array like: + // array('module_name' => array('key' => form fieldset to be imported, 'form' => a form-style array with a fieldset named as the key)) + $search_forms = module_invoke_all('site_user_list_search_form', $search_restrictions); + $form['root']['search_form'][$search_forms['site_user_list']['key']] = $search_forms['site_user_list']['form'][$search_forms['site_user_list']['key']]; + foreach ($search_forms as $module => $additions) { + if ($module != 'site_user_list') { + $form['root']['search_form'][] = array( + '#type' => 'markup', + '#value' => '

and

', + ); + $form['root']['search_form'][$additions['key']] = $additions['form'][$additions['key']]; + } + } + + $form['root']['search_form'][] = array( + '#type' => 'submit', + '#value' => 'Find Users', + '#prefix' => "

\n", + '#suffix' => "

\n", ); - $form['root']['search_form'][$additions['key']] = $additions['form'][$additions['key']]; } } - $form['root']['search_form'][] = array( - '#type' => 'submit', - '#value' => 'Find Users', - '#prefix' => "

\n", - '#suffix' => "

\n", - ); - $form['results_display'] = array( '#type' => 'fieldset', '#title' => 'Contacts',