Exemple #1
0
function cimy_manage_db($command)
{
    global $wpdb, $wpdb_data_table, $wpdb_wp_fields_table, $wpdb_fields_table, $cimy_uef_options, $cimy_uef_version, $cimy_uef_domain;
    if (!cimy_check_admin('activate_plugins')) {
        return;
    }
    $options = array('extra_fields_title' => __("Extra Fields", $cimy_uef_domain), 'users_per_page' => 50, 'aue_hidden_fields' => array('website', 'posts', 'email'), 'wp_hidden_fields' => array(), 'fieldset_title' => '', 'captcha' => 'none');
    switch ($command) {
        case 'new_options':
            $options['version'] = $cimy_uef_version;
            cimy_set_options($options);
            break;
        case 'default_options':
            $old_options = cimy_get_options();
            if (isset($old_options['version'])) {
                $options['version'] = $old_options['version'];
            } else {
                $options['version'] = $cimy_uef_version;
            }
            cimy_set_options($options);
            break;
        case 'drop_options':
            if (is_multisite()) {
                delete_site_option($cimy_uef_options);
            } else {
                delete_option($cimy_uef_options);
            }
            break;
        case 'empty_wp_fields':
            if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb_wp_fields_table}'") == $wpdb_wp_fields_table) {
                $sql = "TRUNCATE TABLE " . $wpdb_wp_fields_table;
                $wpdb->query($sql);
            }
            break;
        case 'empty_extra_fields':
            if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb_fields_table}'") == $wpdb_fields_table) {
                $sql = "TRUNCATE TABLE " . $wpdb_fields_table;
                $wpdb->query($sql);
            }
            break;
        case 'empty_data':
            if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb_data_table}'") == $wpdb_data_table) {
                $sql = "TRUNCATE TABLE " . $wpdb_data_table;
                $wpdb->query($sql);
            }
            break;
        case 'drop_wp_fields':
            if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb_wp_fields_table}'") == $wpdb_wp_fields_table) {
                $sql = "DROP TABLE " . $wpdb_wp_fields_table;
                $wpdb->query($sql);
            }
            break;
        case 'drop_extra_fields':
            if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb_fields_table}'") == $wpdb_fields_table) {
                $sql = "DROP TABLE " . $wpdb_fields_table;
                $wpdb->query($sql);
            }
            break;
        case 'drop_data':
            if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb_data_table}'") == $wpdb_data_table) {
                $sql = "DROP TABLE " . $wpdb_data_table;
                $wpdb->query($sql);
            }
            break;
    }
}
Exemple #2
0
function cimy_manage_db($command)
{
    global $wpdb, $wpdb_data_table, $wpdb_wp_fields_table, $wpdb_fields_table, $cimy_uef_options, $cimy_uef_version, $cimy_uef_domain;
    if (!cimy_check_admin('activate_plugins')) {
        return;
    }
    $welcome_email = sprintf(__('Username: %s'), "USERNAME") . "\r\n";
    $welcome_email .= sprintf(__('Password: %s'), "PASSWORD") . "\r\n";
    $welcome_email .= "LOGINLINK" . "\r\n";
    $options = array('extra_fields_title' => __("Extra Fields", $cimy_uef_domain), 'users_per_page' => 50, 'aue_hidden_fields' => array('website', 'posts', 'email'), 'wp_hidden_fields' => array('username'), 'fieldset_title' => '', 'registration-logo' => '', 'captcha' => 'none', 'welcome_email' => $welcome_email, 'confirm_form' => false, 'confirm_email' => false, 'password_meter' => false, 'mail_include_fields' => false, 'redirect_to' => '', 'file_fields' => array('show_in_reg' => 0, 'show_in_profile' => 0, 'show_in_aeu' => 0, 'show_in_blog' => 0, 'show_in_search' => 0), 'image_fields' => array('show_in_reg' => 0, 'show_in_profile' => 0, 'show_in_aeu' => 0, 'show_in_blog' => 0, 'show_in_search' => 0), 'tinymce_fields' => array('show_in_reg' => 0, 'show_in_profile' => 0, 'show_in_aeu' => 0, 'show_in_blog' => 0, 'show_in_search' => 0));
    switch ($command) {
        case 'new_options':
            $options['version'] = $cimy_uef_version;
            cimy_set_options($options);
            break;
        case 'default_options':
            $old_options = cimy_get_options();
            if (isset($old_options['version'])) {
                $options['version'] = $old_options['version'];
            } else {
                $options['version'] = $cimy_uef_version;
            }
            cimy_set_options($options);
            break;
        case 'drop_options':
            if (is_multisite()) {
                delete_site_option($cimy_uef_options);
            } else {
                delete_option($cimy_uef_options);
            }
            break;
        case 'empty_wp_fields':
            if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb_wp_fields_table}'") == $wpdb_wp_fields_table) {
                $sql = "TRUNCATE TABLE " . $wpdb_wp_fields_table;
                $wpdb->query($sql);
            }
            break;
        case 'empty_extra_fields':
            if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb_fields_table}'") == $wpdb_fields_table) {
                $sql = "TRUNCATE TABLE " . $wpdb_fields_table;
                $wpdb->query($sql);
            }
            break;
        case 'empty_data':
            if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb_data_table}'") == $wpdb_data_table) {
                $sql = "TRUNCATE TABLE " . $wpdb_data_table;
                $wpdb->query($sql);
            }
            break;
        case 'drop_wp_fields':
            if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb_wp_fields_table}'") == $wpdb_wp_fields_table) {
                $sql = "DROP TABLE " . $wpdb_wp_fields_table;
                $wpdb->query($sql);
            }
            break;
        case 'drop_extra_fields':
            if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb_fields_table}'") == $wpdb_fields_table) {
                $sql = "DROP TABLE " . $wpdb_fields_table;
                $wpdb->query($sql);
            }
            break;
        case 'drop_data':
            if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb_data_table}'") == $wpdb_data_table) {
                $sql = "DROP TABLE " . $wpdb_data_table;
                $wpdb->query($sql);
            }
            break;
    }
}
function cimy_save_options()
{
    global $wpdb, $cimy_uef_version, $wpdb_wp_fields_table, $max_length_fieldset_value, $cimy_uef_domain, $wp_hidden_fields, $max_length_extra_fields_title;
    if (!cimy_check_admin('manage_options')) {
        return;
    }
    if (isset($_POST['force_activation'])) {
        cimy_plugin_install();
        return;
    }
    if (!check_admin_referer('cimy_uef_options', 'cimy_uef_optionsnonce')) {
        return;
    }
    $results = array();
    $do_not_save_options = false;
    $options = cimy_get_options();
    $old_wp_hidden_fields = $options['wp_hidden_fields'];
    $options['aue_hidden_fields'] = array();
    $options['wp_hidden_fields'] = array();
    $options['welcome_email'] = stripslashes($_POST['welcome_email']);
    $options['extra_fields_title'] = stripslashes($_POST['extra_fields_title']);
    $options['extra_fields_title'] = substr($options['extra_fields_title'], 0, $max_length_extra_fields_title);
    $options['fieldset_title'] = stripslashes($_POST['fieldset_title']);
    $options['fieldset_title'] = substr($options['fieldset_title'], 0, $max_length_fieldset_value);
    $old_reg_log = $options['registration-logo'];
    $registration_logo = cimy_manage_upload("registration_logo", "", array(), empty($old_reg_log) ? false : basename($old_reg_log), isset($_POST['registration_logo_del']), "registration-logo");
    if (!empty($registration_logo) || isset($_POST['registration_logo_del'])) {
        $options['registration-logo'] = $registration_logo;
    }
    if (isset($_POST['db_wp_fields_check'])) {
        switch ($_POST['db_wp_fields']) {
            case 'empty':
                cimy_manage_db('empty_wp_fields');
                $results['empty_wp_fields'] = __("WordPress Fields table emptied", $cimy_uef_domain);
                break;
            case 'delete':
                cimy_manage_db('drop_wp_fields');
                $results['empty_wp_fields'] = __("WordPress Fields table deleted", $cimy_uef_domain);
                break;
        }
    }
    if (isset($_POST['db_extra_fields_check'])) {
        switch ($_POST['db_extra_fields']) {
            case 'empty':
                cimy_manage_db('empty_extra_fields');
                $results['empty_extra_fields'] = __("Extra Fields table emptied", $cimy_uef_domain);
                break;
            case 'delete':
                cimy_manage_db('drop_extra_fields');
                $results['empty_extra_fields'] = __("Extra Fields table deleted", $cimy_uef_domain);
                break;
        }
    }
    if (isset($_POST['db_data_check'])) {
        switch ($_POST['db_data']) {
            case 'empty':
                cimy_manage_db('empty_data');
                $results['empty_data'] = __("Users Data table emptied", $cimy_uef_domain);
                break;
            case 'delete':
                cimy_manage_db('drop_data');
                $results['empty_data'] = __("Users Data table deleted", $cimy_uef_domain);
                break;
        }
    }
    if (isset($_POST['db_options_check'])) {
        switch ($_POST['db_options']) {
            case 'default':
                cimy_manage_db('default_options');
                $do_not_save_options = true;
                $results['results'] = __("Options set to default values", $cimy_uef_domain);
                break;
            case 'delete':
                cimy_manage_db('drop_options');
                $do_not_save_options = true;
                $results['results'] = __("Options deleted", $cimy_uef_domain);
                break;
        }
    }
    if (isset($_POST['do_not_save_options'])) {
        $do_not_save_options = true;
    }
    if (isset($_POST['hide_username'])) {
        array_push($options['aue_hidden_fields'], 'username');
    }
    if (isset($_POST['hide_name'])) {
        array_push($options['aue_hidden_fields'], 'name');
    }
    if (isset($_POST['hide_posts'])) {
        array_push($options['aue_hidden_fields'], 'posts');
    }
    if (isset($_POST['hide_email'])) {
        array_push($options['aue_hidden_fields'], 'email');
    }
    if (isset($_POST['hide_website'])) {
        array_push($options['aue_hidden_fields'], 'website');
    }
    if (isset($_POST['hide_role'])) {
        array_push($options['aue_hidden_fields'], 'role');
    }
    $tot_wp_hidden_fields = count($old_wp_hidden_fields);
    $action = "add";
    isset($_POST['confirm_email']) ? $options['confirm_email'] = true : ($options['confirm_email'] = false);
    isset($_POST['confirm_form']) ? $options['confirm_form'] = true : ($options['confirm_form'] = false);
    if ($options['confirm_email']) {
        cimy_force_signup_table_creation();
    }
    isset($_POST['redirect_to']) ? $options['redirect_to'] = $_POST['redirect_to'] : ($options['redirect_to'] = "");
    isset($_POST['mail_include_fields']) ? $options['mail_include_fields'] = true : ($options['mail_include_fields'] = false);
    if (isset($_POST['captcha'])) {
        $options['captcha'] = $_POST['captcha'];
    }
    if (isset($_POST['recaptcha_public_key'])) {
        $options['recaptcha_public_key'] = trim($_POST['recaptcha_public_key']);
    }
    if (isset($_POST['recaptcha_private_key'])) {
        $options['recaptcha_private_key'] = trim($_POST['recaptcha_private_key']);
    }
    if (!isset($results['empty_wp_fields'])) {
        if (isset($_POST['show_wp_password'])) {
            array_push($options['wp_hidden_fields'], 'password');
            if (!in_array("password", $old_wp_hidden_fields)) {
                $data = $wp_hidden_fields['password'];
                $data['num_fields'] = $tot_wp_hidden_fields;
                $tot_wp_hidden_fields++;
                cimy_save_field($action, $wpdb_wp_fields_table, $data);
            }
            if (isset($_POST['show_wp_password2'])) {
                array_push($options['wp_hidden_fields'], 'password2');
                if (!in_array("password2", $old_wp_hidden_fields)) {
                    $data = $wp_hidden_fields['password2'];
                    $data['num_fields'] = $tot_wp_hidden_fields;
                    $tot_wp_hidden_fields++;
                    cimy_save_field($action, $wpdb_wp_fields_table, $data);
                }
            }
            isset($_POST['show_wp_password_meter']) ? $options['password_meter'] = true : ($options['password_meter'] = false);
        } else {
            $options['password_meter'] = false;
        }
        $db_wp_fields_independent = array("firstname", "lastname", "nickname", "website", "aim", "yahoo", "jgt", "bio-info");
        foreach ($db_wp_fields_independent as $wp_field_independent) {
            if (isset($_POST['show_wp_' . $wp_field_independent])) {
                array_push($options['wp_hidden_fields'], $wp_field_independent);
                if (!in_array($wp_field_independent, $old_wp_hidden_fields)) {
                    $data = $wp_hidden_fields[$wp_field_independent];
                    $data['num_fields'] = $tot_wp_hidden_fields;
                    $tot_wp_hidden_fields++;
                    cimy_save_field($action, $wpdb_wp_fields_table, $data);
                }
            }
        }
    }
    $all_wp_fields = get_cimyFields(true);
    $sql = "DELETE FROM " . $wpdb_wp_fields_table . " WHERE ";
    $k = -1;
    $j = -1;
    $msg = "";
    $not_del_old = "";
    $not_del_sql = "";
    foreach ($all_wp_fields as $wp_field) {
        $f_name = strtolower($wp_field['NAME']);
        $f_order = intval($wp_field['F_ORDER']);
        if (!in_array($f_name, $options['wp_hidden_fields'])) {
            if (in_array($f_name, $old_wp_hidden_fields)) {
                if ($k > -1) {
                    $sql .= " OR ";
                    $msg .= ", ";
                } else {
                    $k = $f_order;
                    $j = $f_order;
                }
                $sql .= "F_ORDER=" . $f_order;
                $msg .= $f_order;
            }
        } else {
            if ($j > -1) {
                if ($not_del_old != "") {
                    $not_del_old .= ", ";
                }
                $not_del_sql .= " WHEN " . $f_order . " THEN " . $j . " ";
                $not_del_old .= $f_order;
                $j++;
            }
        }
    }
    // if at least one field was selected
    if ($k > -1) {
        // $sql WILL BE: DELETE FROM <table> WHERE F_ORDER=<value1> [OR F_ORDER=<value2> ...]
        $wpdb->query($sql);
        if ($not_del_sql != "") {
            $not_del_sql = "UPDATE " . $wpdb_wp_fields_table . " SET F_ORDER=CASE F_ORDER" . $not_del_sql . "ELSE F_ORDER END WHERE F_ORDER IN(" . $not_del_old . ")";
            // $not_del_sql WILL BE: UPDATE <table> SET F_ORDER=CASE F_ORDER WHEN <oldvalue1> THEN <newvalue1> [WHEN ... THEN ...] ELSE F_ORDER END WHERE F_ORDER IN(<oldvalue1> [, <oldvalue2>...])
            $wpdb->query($not_del_sql);
        }
    }
    if (!$do_not_save_options) {
        cimy_set_options($options);
        $results['results'] = __("Options changed", $cimy_uef_domain);
    }
    return $results;
}
function cimy_admin_users_list_page()
{
    global $wpdb, $wp_roles, $wpdb_data_table, $cimy_uef_options, $cuef_upload_path, $cimy_uef_domain;
    if (!cimy_check_admin('edit_users')) {
        return;
    }
    $options = cimy_get_options();
    if (isset($_POST["cimy_uef_users_per_page"])) {
        $users_per_page = $_POST["cimy_uef_users_per_page"];
        $options["users_per_page"] = $users_per_page;
        cimy_set_options($options);
    } else {
        $users_per_page = $options["users_per_page"];
    }
    $dropdown_first_item = '--- ' . __("select", $cimy_uef_domain) . ' ---';
    $extra_fields = get_cimyFields();
    if (isset($_POST["submit_new_values"])) {
        foreach ($_POST["users"] as $user_id) {
            foreach ($_POST["ef_write_type"] as $ef_name => $ef_type) {
                if (!isset($_POST["ef_write_sel"][$ef_name])) {
                    continue;
                }
                if (isset($_POST["ef_write"][$ef_name])) {
                    $ef_value = $_POST["ef_write"][$ef_name];
                    // if it is selected the "--- select ---" item then skip this check
                    if (($ef_type == "dropdown" || $ef_type == "dropdown-multi") && $ef_value == $dropdown_first_item) {
                        continue;
                    }
                    set_cimyFieldValue($user_id, $ef_name, $ef_value);
                } else {
                    if ($ef_type == "checkbox") {
                        $ef_value = "NO";
                        set_cimyFieldValue($user_id, $ef_name, "");
                    }
                }
            }
        }
    }
    // yes stupid WP_User_Search doesn't support custom $users_per_page support, lets add it!
    class Cimy_User_Search extends WP_User_Search
    {
        function Cimy_User_Search($search_term = '', $page = '', $role = '', $users_per_page = 50)
        {
            $this->search_term = $search_term;
            $this->raw_page = '' == $page ? false : (int) $page;
            $this->page = (int) ('' == $page) ? 1 : $page;
            $this->role = $role;
            $this->users_per_page = intval($users_per_page);
            $this->prepare_query();
            $this->query();
            $this->prepare_vars_for_template_usage();
            // paging will be done after Cimy search has filtered out items
            //$this->do_paging();
        }
        function page_links()
        {
            echo str_replace("?", "?page=au_extended&amp;", $this->paging_text);
        }
    }
    // Query the users
    $wp_user_search = new Cimy_User_Search($_POST['usersearch'], $_GET['userspage'], $_GET['role'], $users_per_page);
    $search_result = $wp_user_search->get_results();
    // search into extra field engine
    $i = 0;
    foreach ($search_result as $userid) {
        foreach ($extra_fields as $ef) {
            $ef_id = $ef["ID"];
            $ef_type = $ef["TYPE"];
            $ef_name = $ef["NAME"];
            $ef_search = "";
            if (isset($_POST["ef_search"][$ef_name])) {
                $ef_search = $_POST["ef_search"][$ef_name];
            }
            if ($ef_search != "") {
                $remove = false;
                $ef_value = $wpdb->get_var("SELECT VALUE FROM " . $wpdb_data_table . " WHERE USER_ID=" . $userid . " AND FIELD_ID=" . $ef_id);
                if ($ef_type == "text" || $ef_type == "textarea" || $ef_type == "textarea-rich" || $ef_type == "picture" || $ef_type == "picture-url" || $ef_type == "file") {
                    if (stristr($ef_value, $ef_search) === FALSE) {
                        $remove = true;
                    }
                } else {
                    if ($ef_type == "checkbox") {
                        if ($ef_search == "1" and $ef_value != "YES") {
                            $remove = true;
                        }
                    } else {
                        if ($ef_type == "radio") {
                            if ($ef_search == $ef_id and $ef_value != "selected") {
                                $remove = true;
                            }
                        } else {
                            if ($ef_type == "dropdown") {
                                // if it is selected the "--- select ---" item then skip this check
                                if ($ef_search == $dropdown_first_item) {
                                    continue;
                                }
                                if ($ef_search != $ef_value) {
                                    $remove = true;
                                }
                            } else {
                                if ($ef_type == "dropdown-multi") {
                                    // if it is selected the "--- select ---" item then remove it
                                    if ($ef_search[0] == $dropdown_first_item) {
                                        unset($ef_search[0]);
                                    }
                                    if (count(array_diff($ef_search, explode(",", $ef_value))) != 0) {
                                        $remove = true;
                                    }
                                }
                            }
                        }
                    }
                }
                if ($remove) {
                    unset($wp_user_search->results[$i]);
                    $wp_user_search->total_users_for_query--;
                    break;
                }
            }
        }
        $i++;
    }
    $wp_user_search->paging_text = "";
    // oh yeah baby, now it's time for paging!
    $wp_user_search->do_paging();
    ?>
	<div class="wrap">
	
	<?php 
    if (function_exists("screen_icon")) {
        screen_icon("users");
    }
    ?>
	<?php 
    if ($wp_user_search->is_search()) {
        ?>
	<h2><?php 
        printf(__('Users Matching "%s"'), wp_specialchars($wp_user_search->search_term));
        ?>
</h2>
	<?php 
    } else {
        ?>
	<h2><?php 
        if (is_multisite()) {
            _e("Users Extended List", $cimy_uef_domain);
        } else {
            _e("Authors &amp; Users Extended List", $cimy_uef_domain);
        }
        ?>
</h2>
	<?php 
    }
    ?>
	<form id="posts-filter" action="" method="post">
	<ul class="subsubsub">
	<?php 
    $role_links = array();
    $avail_roles = array();
    $users_of_blog = get_users_of_blog();
    $total_users = count($users_of_blog);
    //var_dump($users_of_blog);
    foreach ((array) $users_of_blog as $b_user) {
        $b_roles = unserialize($b_user->meta_value);
        foreach ((array) $b_roles as $b_role => $val) {
            if (!isset($avail_roles[$b_role])) {
                $avail_roles[$b_role] = 0;
            }
            $avail_roles[$b_role]++;
        }
    }
    unset($users_of_blog);
    $current_role = false;
    $class = empty($_GET['role']) ? ' class="current"' : '';
    $role_links[] = "<li><a href='users.php?page=au_extended'{$class}>" . sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users'), number_format_i18n($total_users)) . '</a>';
    foreach ($wp_roles->get_names() as $this_role => $name) {
        if (!isset($avail_roles[$this_role])) {
            continue;
        }
        $class = '';
        if ($this_role == $_GET['role']) {
            $current_role = $_GET['role'];
            $class = ' class="current"';
        }
        $name = translate_user_role($name);
        $name = sprintf(__('%1$s <span class="count">(%2$s)</span>'), $name, $avail_roles[$this_role]);
        $tmp_link = esc_url(add_query_arg('role', $this_role));
        $role_links[] = "<li><a href=\"{$tmp_link}\"{$class}>" . $name . '</a>';
    }
    echo implode(' |</li>', $role_links) . '</li>';
    unset($role_links);
    ?>
	</ul>

	<p id="post-search" class="search-box">
	<input type="text" class="search-input" id="post-search-input" name="usersearch" value="<?php 
    echo esc_attr($wp_user_search->search_term);
    ?>
" />
	<input type="submit" value="<?php 
    _e('Search Users');
    ?>
" class="button" />
	</p>
	
	<div class="tablenav">
		<?php 
    if ($wp_user_search->results_are_paged()) {
        ?>
			<div class="tablenav-pages"><?php 
        $wp_user_search->page_links();
        ?>
</div>
		<?php 
    }
    ?>
	
		<br class="clear" />
	
	<br class="clear" />
	<?php 
    if (is_wp_error($wp_user_search->search_errors)) {
        ?>
		<div class="error">
			<ul>
			<?php 
        foreach ($wp_user_search->search_errors->get_error_messages() as $message) {
            echo "<li>{$message}</li>";
        }
        ?>
			</ul>
		</div>
	
	<?php 
    }
    ?>
	

	<?php 
    if ($wp_user_search->get_results()) {
        ?>
		<?php 
        if ($wp_user_search->is_search()) {
            ?>
			<p><a href="users.php?page=au_extended"><?php 
            _e('&laquo; Back to All Users');
            ?>
</a></p>
		<?php 
        }
        wp_print_scripts('admin-forms');
        ?>
		<div class="alignleft actions">
			<?php 
        _e("Users per page", $cimy_uef_domain);
        ?>
 
			<select name="cimy_uef_users_per_page">
			<?php 
        $users_per_page_list = array(10, 50, 100, 500, 1000, 5000);
        foreach ($users_per_page_list as $item) {
            echo "<option";
            if ($item == $users_per_page) {
                echo ' selected="selected"';
            }
            echo ">" . $item . "</option>";
        }
        ?>
			</select>
			<input class="button" type="submit" name="submit" value="<?php 
        _e("Apply");
        ?>
" />
		</div>
	</div>

		<table class="widefat" cellpadding="3" cellspacing="3" width="100%">
		<?php 
        $thead_str = '<tr class="thead">';
        $thead_str .= '<th id="cb" scope="col" class="manage-column column-cb check-column" style=""><input type="checkbox" /> </th>';
        $tfoot_str = '<tr class="thead">';
        $tfoot_str .= '<th scope="col" class="manage-column column-cb check-column" style=""><input type="checkbox" /> </th>';
        if (!in_array("username", $options['aue_hidden_fields'])) {
            $thead_str .= '<th id="username" scope="col" class="manage-column column-username" style="">' . __("Username") . '</th>';
            $tfoot_str .= '<th scope="col" class="manage-column column-username" style="">' . __("Username") . '</th>';
        }
        if (!in_array("name", $options['aue_hidden_fields'])) {
            $thead_str .= '<th id="name" scope="col" class="manage-column column-name" style="">' . __("Name") . '</th>';
            $tfoot_str .= '<th scope="col" class="manage-column column-name" style="">' . __("Name") . '</th>';
        }
        if (!in_array("email", $options['aue_hidden_fields'])) {
            $thead_str .= '<th id="email" scope="col" class="manage-column column-email" style="">' . __("E-mail") . '</th>';
            $tfoot_str .= '<th scope="col" class="manage-column column-email" style="">' . __("E-mail") . '</th>';
        }
        if (!in_array("role", $options['aue_hidden_fields'])) {
            $thead_str .= '<th id="role" scope="col" class="manage-column column-role" style="">' . __("Role") . '</th>';
            $tfoot_str .= '<th scope="col" class="manage-column column-role" style="">' . __("Role") . '</th>';
        }
        if (!in_array("website", $options['aue_hidden_fields'])) {
            $thead_str .= '<th scope="col" class="manage-column" style="">' . __("Website") . '</th>';
            $tfoot_str .= '<th scope="col" class="manage-column" style="">' . __("Website") . '</th>';
        }
        if (!in_array("posts", $options['aue_hidden_fields'])) {
            $thead_str .= '<th id="posts" scope="col" class="manage-column column-posts num" style="">' . __("Posts") . '</th>';
            $tfoot_str .= '<th scope="col" class="manage-column column-posts num" style="">' . __("Posts") . '</th>';
        }
        $i = 0;
        $write_inputs = array();
        $write_input_checkbox = array();
        if (count($extra_fields) > 0) {
            foreach ($extra_fields as $thisField) {
                $rules = $thisField['RULES'];
                if ($rules['show_in_aeu']) {
                    $i++;
                    $label = $thisField['LABEL'];
                    $id = $thisField['ID'];
                    $name = $thisField['NAME'];
                    $type = $thisField['TYPE'];
                    if ($type == "avatar") {
                        continue;
                    }
                    $search_input = "";
                    $search_value = "";
                    if (!empty($_POST["ef_search"][$name])) {
                        if ($type == "dropdown-multi") {
                            $search_value = esc_attr(stripslashes(implode(",", $_POST["ef_search"][$name])));
                        } else {
                            $search_value = esc_attr(stripslashes($_POST["ef_search"][$name]));
                        }
                    }
                    $thead_str .= "<th scope=\"col\" class=\"manage-column\" style=\"\">";
                    $tfoot_str .= "<th scope=\"col\" class=\"manage-column\" style=\"\">";
                    switch ($type) {
                        case "dropdown":
                            $ret = cimy_dropDownOptions($label, $search_value);
                            $ret2 = str_ireplace(' selected="selected"', '', $ret['html']);
                            $label = $ret['label'];
                            $search_input = '<select name="ef_search[' . $name . ']"><option>' . $dropdown_first_item . '</option>' . $ret['html'] . '</select>';
                            $write_input[$i] = '<td>' . $label . '</td><td><select name="ef_write[' . $name . ']"><option>' . $dropdown_first_item . '</option>' . $ret2 . '</select>';
                            break;
                        case "dropdown-multi":
                            $ret = cimy_dropDownOptions($label, $search_value);
                            $ret2 = str_ireplace(' selected="selected"', '', $ret['html']);
                            $label = $ret['label'];
                            $search_input = '<select name="ef_search[' . $name . '][]" multiple="multiple" style="height: 6em;"><option>' . $dropdown_first_item . '</option>' . $ret['html'] . '</select>';
                            $write_input[$i] = '<td>' . $label . '</td><td><select name="ef_write[' . $name . '][]" multiple="multiple" style="height: 6em;"><option>' . $dropdown_first_item . '</option>' . $ret2 . '</select>';
                            break;
                        case "text":
                        case "textarea":
                        case "textarea-rich":
                        case "picture-url":
                            $search_input = '<input type="text" name="ef_search[' . $name . ']" value="' . $search_value . '" size="6" />';
                            $write_input[$i] = '<td>' . $label . '</td><td><input type="text" name="ef_write[' . $name . ']" value="" size="40" />';
                            break;
                        case "picture":
                        case "file":
                            $search_input = '<input type="text" name="ef_search[' . $name . ']" value="' . $search_value . '" size="6" />';
                            break;
                        case "checkbox":
                            if ($search_value != "") {
                                $checkbox_selected = ' checked="checked"';
                            } else {
                                $checkbox_selected = "";
                            }
                            $search_input = '<input type="checkbox" name="ef_search[' . $name . ']" value="1"' . $checkbox_selected . ' />';
                            $write_input[$i] = '<td>' . $label . '</td><td><input type="checkbox" name="ef_write[' . $name . ']" value="1" />';
                            break;
                        case "radio":
                            if ($search_value == $id) {
                                $radio_selected = ' checked="checked"';
                            } else {
                                $radio_selected = "";
                            }
                            $search_input = '<input type="radio" name="ef_search[' . $name . ']" value="' . $id . '"' . $radio_selected . ' />';
                            $write_input[$i] = '<td>' . $label . '</td><td><input type="radio" name="ef_write[' . $name . ']" value="' . $label . '" />';
                            break;
                    }
                    if (isset($write_input[$i])) {
                        if (empty($write_input_checkbox[$name])) {
                            $write_input[$i] = '<td><input type="checkbox" name="ef_write_sel[' . $name . ']" value="1" /></td>' . $write_input[$i];
                            $write_input_checkbox[$name] = true;
                        } else {
                            $write_input[$i] = '<td>&nbsp;</td>' . $write_input[$i];
                        }
                        $write_input[$i] .= '<input type="hidden" name="ef_write_type[' . $name . ']" value="' . $type . '" /></td>';
                    }
                    $thead_str .= "{$label}<br />{$search_input}</th>";
                    $tfoot_str .= "{$label}</th>";
                }
            }
        }
        $thead_str .= '</tr>';
        $tfoot_str .= '</tr>';
        ?>
		<thead>
			<?php 
        echo $thead_str;
        ?>
		</thead>
		<tfoot>
			<?php 
        echo $tfoot_str;
        ?>
		</tfoot>
		<?php 
        $style = '';
        foreach ($wp_user_search->get_results() as $userid) {
            $user_object = new WP_User($userid);
            $roles = $user_object->roles;
            $role = array_shift($roles);
            $email = $user_object->user_email;
            $url = $user_object->user_url;
            $short_url = str_replace('http://', '', $url);
            $short_url = str_replace('www.', '', $short_url);
            if ('/' == substr($short_url, -1)) {
                $short_url = substr($short_url, 0, -1);
            }
            if (strlen($short_url) > 35) {
                $short_url = substr($short_url, 0, 32) . '...';
            }
            $style = 'class="alternate"' == $style ? '' : 'class="alternate"';
            $numposts = count_user_posts($user_object->ID);
            if (0 < $numposts) {
                $numposts = "<a href='edit.php?author={$user_object->ID}' title='" . __('View posts by this author') . "'>{$numposts}</a>";
            }
            echo "\n\t\t\t<tr {$style}>\n\t\t\t\n\t\t\t<th scope='row' class='check-column'><input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='{$role}' value='{$user_object->ID}' /></th>";
            if (!in_array("username", $options['aue_hidden_fields'])) {
                // produce username clickable
                if (current_user_can('edit_user', $user_object->ID)) {
                    $current_user = wp_get_current_user();
                    if ($current_user->ID == $user_object->ID) {
                        $edit = 'profile.php';
                    } else {
                        $edit = esc_url(add_query_arg('wp_http_referer', urlencode(esc_url(stripslashes($_SERVER['REQUEST_URI']))), "user-edit.php?user_id={$user_object->ID}"));
                    }
                    $edit = "<a href=\"{$edit}\">{$user_object->user_login}</a>";
                } else {
                    $edit = $user_object->user_login;
                }
                $avatar = get_avatar($user_object->user_email, 32);
                echo "<td class=\"username column-username\"><strong>{$avatar} {$edit}</strong></td>";
            }
            if (!in_array("name", $options['aue_hidden_fields'])) {
                echo "<td class=\"name column-name\"><label for='user_{$user_object->ID}'>{$user_object->first_name} {$user_object->last_name}</label></td>";
            }
            if (!in_array("email", $options['aue_hidden_fields'])) {
                echo "<td class=\"email column-email\"><a href='mailto:{$email}' title='" . sprintf(__('e-mail: %s'), $email) . "'>{$email}</a></td>";
            }
            if (!in_array("role", $options['aue_hidden_fields'])) {
                $role_name = translate_user_role($wp_roles->role_names[$role]);
                echo "<td class=\"role column-role\">";
                echo $role_name;
                echo '</td>';
            }
            if (!in_array("website", $options['aue_hidden_fields'])) {
                echo "<td ><a href='{$url}' title='website: {$url}'>{$short_url}</a></td>";
            }
            if (!in_array("posts", $options['aue_hidden_fields'])) {
                echo "<td class=\"posts column-posts num\">{$numposts}</td>";
            }
            // print all the content of extra fields if there are some
            if (count($extra_fields) > 0) {
                foreach ($extra_fields as $thisField) {
                    $field_id = $thisField['ID'];
                    // if user has not yet fields in the data table then create them
                    cimy_insert_ExtraFields_if_not_exist($user_object->ID, $field_id);
                }
                // retrieve extra fields data from DB
                $ef_db = $wpdb->get_results("SELECT FIELD_ID, VALUE FROM " . $wpdb_data_table . " WHERE USER_ID = " . $user_object->ID, ARRAY_A);
                foreach ($extra_fields as $thisField) {
                    $rules = $thisField['RULES'];
                    $type = $thisField['TYPE'];
                    $value = $thisField['VALUE'];
                    if ($type == "avatar") {
                        continue;
                    }
                    if ($rules['show_in_aeu']) {
                        $field_id = $thisField['ID'];
                        foreach ($ef_db as $d_field) {
                            if ($d_field['FIELD_ID'] == $field_id) {
                                $field = cimy_uef_sanitize_content($d_field['VALUE']);
                                //$field = esc_attr($d_field['VALUE']);
                            }
                        }
                        echo "<td>";
                        if ($type == "picture-url") {
                            if ($field == "") {
                                $field = $value;
                            }
                            if ($field != "") {
                                if (intval($rules['equal_to'])) {
                                    echo '<a target="_blank" href="' . $field . '">';
                                    echo '<img src="' . $field . '" alt="picture"' . $size . ' width="' . intval($rules['equal_to']) . '" height="*" />';
                                    echo "</a>";
                                } else {
                                    echo '<img src="' . $field . '" alt="picture" />';
                                }
                                echo "<br />";
                                echo "\n\t\t";
                            }
                        } else {
                            if ($type == "picture") {
                                if ($field == "") {
                                    $field = $value;
                                }
                                if ($field != "") {
                                    //$profileuser = get_user_to_edit($user_object->ID);
                                    //$user_login = $profileuser->user_login;
                                    $user_login = $user_object->user_login;
                                    $value_thumb = cimy_get_thumb_path($field);
                                    $file_thumb = $cuef_upload_path . $user_login . "/" . cimy_get_thumb_path(basename($field));
                                    $file_on_server = $cuef_upload_path . $user_login . "/" . basename($field);
                                    echo "\n\t\t";
                                    if (is_file($file_thumb)) {
                                        echo '<a target="_blank" href="' . $field . '"><img src="' . $value_thumb . '" alt="picture" /></a><br />';
                                        echo "\n\t\t";
                                    } else {
                                        if (is_file($file_on_server)) {
                                            echo '<img src="' . $field . '" alt="picture" /><br />';
                                            echo "\n\t\t";
                                        }
                                    }
                                }
                            } else {
                                if ($type == "file") {
                                    echo '<a target="_blank" href="' . $field . '">';
                                    echo basename($field);
                                    echo '</a>';
                                } else {
                                    if ($type == "registration-date") {
                                        if (isset($rules['equal_to'])) {
                                            $registration_date = cimy_get_formatted_date($field, $rules['equal_to']);
                                        } else {
                                            $registration_date = cimy_get_formatted_date($field);
                                        }
                                        echo $registration_date;
                                    } else {
                                        echo $field;
                                    }
                                }
                            }
                        }
                        echo "&nbsp;" . "</td>";
                    }
                }
            }
            echo '</tr>';
        }
        ?>
		</table>
				
		<div class="tablenav">
		
			<?php 
        if ($wp_user_search->results_are_paged()) {
            ?>
				<div class="tablenav-pages"><?php 
            $wp_user_search->page_links();
            ?>
</div>
			<?php 
        }
        ?>
		
			<br class="clear" />
		</div>
	
	<?php 
    }
    ?>

	<?php 
    if (!empty($write_input)) {
        ?>
	<h2><?php 
        _e("Update selected users", $cimy_uef_domain);
        ?>
</h2>
	<table class="widefat" cellpadding="3" cellspacing="3">
	<thead>
		<tr class="thead">
			<th class="manage-column column-name" style="" width="10px">&nbsp;</th><th class="manage-column column-name" style="" width="200px"><?php 
        _e("Extra Fields", $cimy_uef_domain);
        ?>
</th><th class="manage-column column-name" style=""><?php 
        _e("Value");
        ?>
</th>
		</tr>
	</thead>
	<tfoot>
		<tr class="thead">
			<th class="manage-column column-name" style="" width="10px">&nbsp;</th><th class="manage-column column-name" style="" width="200px"><?php 
        _e("Extra Fields", $cimy_uef_domain);
        ?>
</th><th class="manage-column column-name" style=""><?php 
        _e("Value");
        ?>
</th>
		</tr>
	</tfoot>
	<tbody>
	<?php 
        foreach ($write_input as $input) {
            echo '<tr>' . $input . '</tr>';
        }
        ?>
	</tbody>
	</table>
	<br />
	<input class="button" type="submit" name="submit_new_values" value="<?php 
        _e("Update");
        ?>
" />
	<?php 
    }
    ?>

	</form>
	
	</div>
	
	<?php 
}