示例#1
0
function cimy_delete_users_info($fields_id)
{
    global $wpdb, $wpdb_data_table;
    if (!cimy_check_admin('edit_users')) {
        return;
    }
    $sql = "DELETE FROM " . $wpdb_data_table . " WHERE " . $fields_id;
    $wpdb->query($sql);
}
function cimy_show_options($results, $embedded)
{
    global $wpdb, $wpdb_wp_fields_table, $wpdb_fields_table, $wpdb_data_table, $max_length_fieldset_value, $cimy_uef_name, $cimy_uef_url, $cimy_project_url, $cimy_uef_version, $cimy_uef_domain, $cimy_top_menu, $max_length_extra_fields_title, $cuef_upload_path, $cuef_plugin_dir;
    if (!cimy_check_admin('manage_options')) {
        return;
    }
    // save options engine
    if (isset($_POST['cimy_options']) && isset($cimy_top_menu)) {
        $results = cimy_save_options();
    }
    $options = cimy_get_options();
    wp_print_scripts("cimy_uef_upload_file");
    $warning_msg = $wpdb->escape(__("Please upload an image with one of the following extensions", $cimy_uef_domain));
    if ($options) {
        if (!is_dir($cuef_upload_path) && is_writable(WP_CONTENT_DIR)) {
            if (defined("FS_CHMOD_DIR")) {
                @mkdir($cuef_upload_path, FS_CHMOD_DIR);
            } else {
                @mkdir($cuef_upload_path, 0777);
            }
        }
        $options['fieldset_title'] = esc_attr($options['fieldset_title']);
        $welcome_email = $options['welcome_email'];
        isset($options['recaptcha_public_key']) ? $recaptcha_public_key = $options['recaptcha_public_key'] : ($recaptcha_public_key = '');
        isset($options['recaptcha_private_key']) ? $recaptcha_private_key = $options['recaptcha_private_key'] : ($recaptcha_private_key = '');
        $db_options = true;
    } else {
        $db_options = false;
        $options['fieldset_title'] = "";
        $welcome_email = '';
        $recaptcha_public_key = '';
        $recaptcha_private_key = '';
    }
    if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb_wp_fields_table}'") == $wpdb_wp_fields_table) {
        $sql = "SELECT id, COUNT(*) FROM " . $wpdb_wp_fields_table . " GROUP BY id";
        $db_wp_fields = $wpdb->query($sql);
    } else {
        $db_wp_fields = -1;
    }
    if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb_fields_table}'") == $wpdb_fields_table) {
        $sql = "SELECT id, COUNT(*) FROM " . $wpdb_fields_table . " GROUP BY id";
        $db_extra_fields = $wpdb->query($sql);
    } else {
        $db_extra_fields = -1;
    }
    if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb_data_table}'") == $wpdb_data_table) {
        $db_users_data = true;
    } else {
        $db_users_data = false;
    }
    $ret = array();
    $ret['db_options'] = $db_options;
    $ret['db_extra_fields'] = $db_extra_fields;
    $ret['db_wp_fields'] = count($options['wp_hidden_fields']);
    $ret['db_users_data'] = $db_users_data;
    if (isset($cimy_top_menu) && $embedded) {
        return $ret;
    }
    $update_db_label = $wpdb->escape(__("This operation will create/update all missing tables/options, do you want to proceed?", $cimy_uef_domain));
    ?>
	
	<div class="wrap" id="options">
	<?php 
    if (function_exists("screen_icon")) {
        screen_icon("options-general");
    }
    ?>
	<h2><?php 
    _e("Options");
    if (!isset($cimy_top_menu)) {
        ?>
 - <a href="#addfield"><?php 
        _e("Add a new Field", $cimy_uef_domain);
        ?>
</a> - <a href="#extrafields"><?php 
        _e("Extra Fields", $cimy_uef_domain);
        ?>
</a><?php 
    }
    ?>
</h2>
	<table class="form-table">
		<tr>
			<th scope="row" width="40%">
				<strong><a href="<?php 
    echo $cimy_project_url;
    ?>
"><?php 
    _e("Support the Cimy Project", $cimy_uef_domain);
    ?>
</a></strong>
			</th>
			<td width="60%">
				<form style="text-align: left;" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input name="cmd" type="hidden" value="_s-xclick" />
				<input name="hosted_button_id" type="hidden" value="8774924" />
				<input alt="PayPal - The safer, easier way to pay online." name="submit" src="https://www.paypal.com/en_US/GB/i/btn/btn_donateCC_LG.gif" type="image" />
				<img src="https://www.paypal.com/it_IT/i/scr/pixel.gif" border="0" alt="" width="1" height="1" />
				</form>
				<?php 
    _e("This plug-in is the results of hours of development to add new features, support new WordPress versions and fix bugs, please donate money if saved you from spending all these hours!", $cimy_uef_domain);
    ?>
			</td>
		</tr>
	</table>
<?php 
    // print successes if there are some
    if (count($results) > 0) {
        ?>
		<div class="updated">
		<h3><?php 
        _e("SUCCESSFUL", $cimy_uef_domain);
        ?>
</h3>
		<ul>
			<?php 
        foreach ($results as $result) {
            echo "<li>" . $result . "</li>";
        }
        ?>
		</ul>
		<br />
		</div>
	<?php 
    }
    ?>
<form method="post" action="#options" id="cimy_uef_options">
	<?php 
    wp_nonce_field('cimy_uef_options', 'cimy_uef_optionsnonce', false);
    ?>
	<p class="submit" style="border-width: 0px;"><input class="button-primary" type="submit" name="Submit" value="<?php 
    _e('Save Changes');
    ?>
" /></p>
	<h3><?php 
    _e("General");
    ?>
</h3>
	<table class="form-table">
		<tr>
			<th scope="row" width="40%">
				<strong><a href="<?php 
    echo $cimy_uef_url;
    ?>
"><?php 
    echo $cimy_uef_name;
    ?>
</a></strong>
			</th>
			<td width="60%">v<?php 
    echo $options['version'];
    if ($cimy_uef_version != $options['version']) {
        ?>
 (<?php 
        _e("installed is", $cimy_uef_domain);
        ?>
 v<?php 
        echo $cimy_uef_version;
        ?>
)<?php 
    }
    if (!$db_options) {
        ?>
<br /><h4><?php 
        _e("OPTIONS DELETED!", $cimy_uef_domain);
        ?>
</h4>
					<input type="hidden" name="do_not_save_options" value="1" />

					<p class="submit" style="border-width: 0px;"><input class="button-primary" type="submit" name="force_activation" value="<?php 
        _e("Fix the problem", $cimy_uef_domain);
        ?>
" onclick="return confirm('<?php 
        echo $update_db_label;
        ?>
');" /></p><?php 
    } else {
        if ($cimy_uef_version != $options['version']) {
            ?>
<br /><h4><?php 
            _e("VERSIONS MISMATCH! This because you haven't de-activated and re-activated the plug-in after the update! This could give problems...", $cimy_uef_domain);
            ?>
</h4>

					<p class="submit" style="border-width: 0px;"><input class="button-primary" type="submit" name="force_activation" value="<?php 
            _e("Fix the problem", $cimy_uef_domain);
            ?>
" onclick="return confirm('<?php 
            echo $update_db_label;
            ?>
');" /></p><?php 
        }
    }
    ?>
			</td>
		</tr>
		<tr>
			<th scope="row"><?php 
    _e("Picture/Avatar upload", $cimy_uef_domain);
    ?>
</th>
			<td>
			<?php 
    if (is_writable($cuef_upload_path)) {
        echo "<em>" . $cuef_upload_path . "</em><br />" . __("is created and writable", $cimy_uef_domain);
    } else {
        echo "<em>" . $cuef_upload_path . "</em><br />" . __("is NOT created or webserver does NOT have permission to write on it", $cimy_uef_domain);
    }
    ?>
			</td>
		</tr>
		<tr>
			<th scope="row">
				<input type="checkbox" name="mail_include_fields" value="1"<?php 
    checked(true, $options['mail_include_fields'], true);
    ?>
 />
				<?php 
    _e("Show all fields in the welcome email", $cimy_uef_domain);
    ?>
			</th>
			<td>
			<?php 
    _e("the email sent to the admin and to the user upon registration will have all fields", $cimy_uef_domain);
    ?>
			</td>
		</tr>
<?php 
    if (!is_multisite()) {
        ?>
		<tr>
			<th scope="row">
				<input type="checkbox" name="confirm_email" value="1"<?php 
        checked(true, $options['confirm_email'], true);
        ?>
 />
				<?php 
        _e("Enable email confirmation", $cimy_uef_domain);
        ?>
			</th>
			<td>
			<?php 
        _e("user that registers should confirm its email address via a link click", $cimy_uef_domain);
        echo "<br />";
        _e("<strong>note:</strong> this option turned on will automatically disable (only during the registration) all upload fields: file, picture, avatar", $cimy_uef_domain);
        ?>
			</td>
		</tr>
		<tr>
			<th scope="row">
				<input type="checkbox" name="confirm_form" value="1"<?php 
        checked(true, $options['confirm_form'], true);
        ?>
 />
				<?php 
        _e("Enable form confirmation", $cimy_uef_domain);
        ?>
			</th>
			<td>
			<?php 
        _e("a summary of the registration form will be presented to the user", $cimy_uef_domain);
        ?>
			</td>
		</tr>
		<tr>
			<th scope="row">
				<?php 
        _e("Customize welcome email sent to the new user", $cimy_uef_domain);
        ?>
			</th>
			<td>
				<textarea name="welcome_email" rows="6" cols="50"><?php 
        echo esc_html($welcome_email);
        ?>
</textarea><br />
				<?php 
        _e("if you change or remove the placeholders then the email won't have the correct information", $cimy_uef_domain);
        ?>
			</td>
		</tr>
		<tr>
			<th scope="row">
				<input type="checkbox" name="redirect_to" value="source"<?php 
        checked("source", $options['redirect_to'], true);
        ?>
 />
				<?php 
        _e("Redirect to the source", $cimy_uef_domain);
        ?>
			</th>
			<td>
			<?php 
        _e("after the registration or confirmation the user will be redirected to the address where was exactly before clicking on the registration link", $cimy_uef_domain);
        ?>
			</td>
		</tr>
<?php 
    }
    ?>
		<tr>
			<th scope="row">
				<input type="radio" name="captcha" value="none"<?php 
    checked("none", $options['captcha'], true);
    ?>
 />
				<?php 
    _e('No captcha', $cimy_uef_domain);
    ?>
</a>
			</th>
			<td>
			</td>
		</tr>
		<tr>
			<th scope="row">
				<input type="radio" name="captcha" value="recaptcha"<?php 
    checked("recaptcha", $options['captcha'], true);
    ?>
 />
				<?php 
    _e('Enable <a href="http://www.google.com/recaptcha" target="_blank">reCAPTCHA</a>', $cimy_uef_domain);
    ?>
</a>
			</th>
			<td>
			<?php 
    _e("Public KEY", $cimy_uef_domain);
    ?>
				<input type="text" name="recaptcha_public_key" value="<?php 
    echo esc_attr($recaptcha_public_key);
    ?>
" size="40" /><br />
			<?php 
    _e("Private KEY", $cimy_uef_domain);
    ?>
				<input type="text" name="recaptcha_private_key" value="<?php 
    echo esc_attr($recaptcha_private_key);
    ?>
" size="40" />
			</td>
		</tr>
		<tr>
			<th scope="row">
				<input type="radio" name="captcha" value="securimage"<?php 
    checked("securimage", $options['captcha'], true);
    ?>
 />
				<?php 
    _e('Enable <a href="http://www.phpcaptcha.org/" target="_blank">Securimage Captcha</a>', $cimy_uef_domain);
    ?>
</a>
			</th>
			<td>
				<?php 
    _e('This captcha is probably weaker, but is easier for users', $cimy_uef_domain);
    ?>
				<?php 
    if (!is_file($cuef_plugin_dir . '/securimage/securimage.php')) {
        echo "<br />";
        printf(__('<strong>WARNING: to activate this captcha download <a href="http://www.phpcaptcha.org/latest.zip" target="_blank">this package</a> and unpack it under %s</strong>', $cimy_uef_domain), $cuef_plugin_dir . '/recaptcha/');
    }
    ?>
			</td>
		</tr>
<?php 
    if (!is_multisite()) {
        ?>
		<tr>
			<th scope="row"><?php 
        _e("Change login/registration page logo", $cimy_uef_domain);
        ?>
</th>
			<td>
				<?php 
        if (!empty($options["registration-logo"])) {
            ?>
<input type="hidden" name="registration_logo_oldfile" value="<?php 
            echo basename($options["registration-logo"]);
            ?>
" />
				<?php 
            echo esc_html(basename($options["registration-logo"])) . '<br />';
            ?>
				<input type="checkbox" name="registration_logo_del" value="1" />
				<?php 
            echo " " . __("Delete the picture", $cimy_uef_domain);
            ?>
<br /><br /><?php 
        }
        ?>

				<input type="file" id="registration_logo" name="registration_logo" onchange="uploadFile('cimy_uef_options', 'registration_logo', '<?php 
        echo $warning_msg;
        ?>
', Array('gif', 'png', 'jpg', 'jpeg', 'tiff'))" />
				<?php 
        _e("Maximum recommended logo width is 328px, but any height should work.", $cimy_uef_domain);
        ?>
			</td>
		</tr>
<?php 
    }
    ?>
	</table>
	<br />
	<h3><?php 
    _e("Database", $cimy_uef_domain);
    ?>
</h3>
	<table class="form-table">
		<tr>
			<th scope="row" width="40%"><input type="checkbox" name="db_options_check" value="1" /> Cimy User Extra Fields <?php 
    _e("Options");
    ?>
</th>
			<td width="60%">
				<?php 
    if ($db_options) {
        ?>
					<select name="db_options">
						<option value="none">- <?php 
        _e("select action", $cimy_uef_domain);
        ?>
 -</option>
						<option value="default"><?php 
        _e("Default values", $cimy_uef_domain);
        ?>
</option>
						<option value="delete"><?php 
        _e("Delete");
        ?>
</option>
					</select><?php 
    } else {
        echo "<strong>" . __("NOT PRESENT", $cimy_uef_domain) . "</strong>";
    }
    ?>
			</td>
		</tr>
		<tr>
			<th scope="row"><input type="checkbox" name="db_wp_fields_check" value="1" /> <?php 
    _e("WordPress Fields table", $cimy_uef_domain);
    ?>
</th>
			<td>
				<?php 
    if ($db_wp_fields >= 0) {
        ?>
					<select name="db_wp_fields">
						<option value="none">- <?php 
        _e("select action", $cimy_uef_domain);
        ?>
 -</option>
						<option value="empty"><?php 
        _e("Empty", $cimy_uef_domain);
        ?>
</option>
						<option value="delete"><?php 
        _e("Delete");
        ?>
</option>
					</select><?php 
    } else {
        echo "<strong>" . __("NOT PRESENT", $cimy_uef_domain) . "</strong>";
    }
    ?>
			</td>
		</tr>
		<tr>
			<th scope="row"><input type="checkbox" name="db_extra_fields_check" value="1" /> <?php 
    _e("Extra Fields table", $cimy_uef_domain);
    ?>
</th>
			<td>
				<?php 
    if ($db_extra_fields >= 0) {
        ?>
					<select name="db_extra_fields">
						<option value="none">- <?php 
        _e("select action", $cimy_uef_domain);
        ?>
 -</option>
						<option value="empty"><?php 
        _e("Empty", $cimy_uef_domain);
        ?>
</option>
						<option value="delete"><?php 
        _e("Delete");
        ?>
</option>
					</select><?php 
    } else {
        echo "<strong>" . __("NOT PRESENT", $cimy_uef_domain) . "</strong>";
    }
    ?>
			</td>
		</tr>
		<tr>
			<th scope="row"><input type="checkbox" name="db_data_check" value="1" /> <?php 
    _e("Users Data table", $cimy_uef_domain);
    ?>
</th>
			<td>
				<?php 
    if ($db_users_data) {
        ?>
					<select name="db_data">
						<option value="none">- <?php 
        _e("select action", $cimy_uef_domain);
        ?>
 -</option>
						<option value="empty"><?php 
        _e("Empty", $cimy_uef_domain);
        ?>
</option>
						<option value="delete"><?php 
        _e("Delete");
        ?>
</option>
					</select> <?php 
        _e("all data inserted by users in all and only extra fields", $cimy_uef_domain);
    } else {
        echo "<strong>" . __("NOT PRESENT", $cimy_uef_domain) . "</strong>";
    }
    ?>
			</td>
		</tr>
		<tr>
			<th scope="row"><input type="checkbox" name="force_activation" value="1" /> <?php 
    _e("Force tables creation", $cimy_uef_domain);
    ?>
</th>
			<td>
			<?php 
    _e("equivalent to de-activate and activate the plug-in; no other operation will be performed", $cimy_uef_domain);
    ?>
			</td>
		</tr>
	</table>
	<br />
	<h3><?php 
    _e("User Profile", $cimy_uef_domain);
    ?>
</h3>
	<table class="form-table">
		<tr>
			<th scope="row" width="40%"><?php 
    _e("Extra Fields section title", $cimy_uef_domain);
    ?>
</th>
			<td width="60%"><input type="text" name="extra_fields_title" value="<?php 
    echo esc_attr($options['extra_fields_title']);
    ?>
" size="35" maxlength="<?php 
    echo $max_length_extra_fields_title;
    ?>
" /></td>
		</tr>
		<tr>
			<th scope="row"><?php 
    _e("Fieldset's titles, separates with comma", $cimy_uef_domain);
    ?>
<br /><?php 
    _e("example: title1,title2,title3", $cimy_uef_domain);
    ?>
</th>
			<td><input type="text" name="fieldset_title" value="<?php 
    echo esc_attr($options['fieldset_title']);
    ?>
" size="35" maxlength="<?php 
    echo $max_length_fieldset_value;
    ?>
" /> <?php 
    _e("<strong>note:</strong> if you change order or remove fieldsets you may need to set all extra fields' fieldset assigment again", $cimy_uef_domain);
    ?>
</td>
		</tr>

	</table>
	<br />
	<h3><?php 
    _e("Authors &amp; Users Extended", $cimy_uef_domain);
    ?>
</h3>
	<table class="form-table">
		<tr>
			<th scope="row" width="40%">
				<input type="checkbox" name="hide_username" value="1"<?php 
    checked(true, in_array('username', $options['aue_hidden_fields']), true);
    ?>
 /> <?php 
    _e("Hide username field", $cimy_uef_domain);
    ?>
			</th>
			<td width="60%"></td>
		</tr>
		<tr>
			<th>
				<input type="checkbox" name="hide_name" value="1"<?php 
    checked(true, in_array('name', $options['aue_hidden_fields']), true);
    ?>
 /> <?php 
    _e("Hide name field", $cimy_uef_domain);
    ?>
			</th>
			<td></td>
		</tr>
		<tr>
			<th scope="row"><input type="checkbox" name="hide_email" value="1"<?php 
    checked(true, in_array('email', $options['aue_hidden_fields']), true);
    ?>
 /> <?php 
    _e("Hide email field", $cimy_uef_domain);
    ?>
</th>
			<td></td>
		</tr>
		<tr>
			<th scope="row"><input type="checkbox" name="hide_role" value="1"<?php 
    checked(true, in_array('role', $options['aue_hidden_fields']), true);
    ?>
 /> <?php 
    _e("Hide role field", $cimy_uef_domain);
    ?>
</th>
			<td></td>
		</tr>
		<tr>
			<th scope="row"><input type="checkbox" name="hide_website" value="1"<?php 
    checked(true, in_array('website', $options['aue_hidden_fields']), true);
    ?>
 /> <?php 
    _e("Hide website field", $cimy_uef_domain);
    ?>
</th>
			<td></td>
		</tr>
		<tr>
			<th><input type="checkbox" name="hide_posts" value="1"<?php 
    checked(true, in_array('posts', $options['aue_hidden_fields']), true);
    ?>
 /> <?php 
    _e("Hide n. posts field", $cimy_uef_domain);
    ?>
</th>
			<td></td>
		</tr>
	</table>
	<br />
	<h3><?php 
    _e("WordPress hidden fields", $cimy_uef_domain);
    ?>
</h3>
	<table class="form-table">
		<tr>
			<th scope="row" width="40%"><input type="checkbox" name="show_wp_password" value="1"<?php 
    checked(true, in_array('password', $options['wp_hidden_fields']), true);
    disabled(true, $db_wp_fields < 0, true);
    ?>
 /> <?php 
    _e("Show password", $cimy_uef_domain);
    ?>
</th>
			<td width="60%"></td>
		</tr>
		<tr>
			<th>&nbsp;&nbsp;&nbsp;<input type="checkbox" name="show_wp_password2" value="1"<?php 
    checked(true, in_array('password2', $options['wp_hidden_fields']), true);
    disabled(true, $db_wp_fields < 0, true);
    ?>
 /> <?php 
    _e("Show confirmation password", $cimy_uef_domain);
    ?>
</th>
			<td></td>
		</tr>
		<tr>
			<th>&nbsp;&nbsp;&nbsp;<input type="checkbox" name="show_wp_password_meter" value="1"<?php 
    checked(true, $options['password_meter'], true);
    disabled(true, $db_wp_fields < 0, true);
    ?>
 /> <?php 
    _e("Show password strength meter", $cimy_uef_domain);
    ?>
</th>
			<td></td>
		</tr>
		<tr>
			<th><input type="checkbox" name="show_wp_firstname" value="1"<?php 
    checked(true, in_array('firstname', $options['wp_hidden_fields']), true);
    disabled(true, $db_wp_fields < 0, true);
    ?>
 /> <?php 
    _e("Show first name", $cimy_uef_domain);
    ?>
</th>
			<td></td>
		</tr>
		<tr>
			<th><input type="checkbox" name="show_wp_lastname" value="1"<?php 
    checked(true, in_array('lastname', $options['wp_hidden_fields']), true);
    disabled(true, $db_wp_fields < 0, true);
    ?>
 /> <?php 
    _e("Show last name", $cimy_uef_domain);
    ?>
</th>
			<td></td>
		</tr>
		<tr>
			<th><input type="checkbox" name="show_wp_nickname" value="1"<?php 
    checked(true, in_array('nickname', $options['wp_hidden_fields']), true);
    disabled(true, $db_wp_fields < 0, true);
    ?>
 /> <?php 
    _e("Show nickname", $cimy_uef_domain);
    ?>
</th>
			<td></td>
		</tr>
		<tr>
			<th scope="row"><input type="checkbox" name="show_wp_website" value="1"<?php 
    checked(true, in_array('website', $options['wp_hidden_fields']), true);
    disabled(true, $db_wp_fields < 0, true);
    ?>
 /> <?php 
    _e("Show website", $cimy_uef_domain);
    ?>
</th>
			<td></td>
		</tr>
		<tr>
			<th scope="row"><input type="checkbox" name="show_wp_aim" value="1"<?php 
    checked(true, in_array('aim', $options['wp_hidden_fields']), true);
    disabled(true, $db_wp_fields < 0, true);
    ?>
 /> <?php 
    _e("Show AIM", $cimy_uef_domain);
    ?>
</th>
			<td></td>
		</tr>
		<tr>
			<th scope="row"><input type="checkbox" name="show_wp_yahoo" value="1"<?php 
    checked(true, in_array('yahoo', $options['wp_hidden_fields']), true);
    disabled(true, $db_wp_fields < 0, true);
    ?>
 /> <?php 
    _e("Show Yahoo IM", $cimy_uef_domain);
    ?>
</th>
			<td></td>
		</tr>
		<tr>
			<th scope="row"><input type="checkbox" name="show_wp_jgt" value="1"<?php 
    checked(true, in_array('jgt', $options['wp_hidden_fields']), true);
    disabled(true, $db_wp_fields < 0, true);
    ?>
 /> <?php 
    _e("Show Jabber / Google Talk", $cimy_uef_domain);
    ?>
</th>
			<td></td>
		</tr>
		<tr>
			<th scope="row"><input type="checkbox" name="show_wp_bio-info" value="1"<?php 
    checked(true, in_array('bio-info', $options['wp_hidden_fields']), true);
    disabled(true, $db_wp_fields < 0, true);
    ?>
 /> <?php 
    _e("Show Biographical Info", $cimy_uef_domain);
    ?>
</th>
			<td></td>
		</tr>
	</table>
	<input type="hidden" name="cimy_options" value="1" />
	<p class="submit"><input class="button-primary" type="submit" name="Submit" value="<?php 
    _e('Save Changes');
    ?>
" /></p>
	</form>
	</div>
	<br />
	<?php 
    return $ret;
}
function cimy_fieldsetOptions($selected = 0, $order = "", $select_all = false)
{
    global $cimy_uef_domain;
    if (!cimy_check_admin('manage_options')) {
        return;
    }
    $options = cimy_get_options();
    $i = 0;
    $html = "<select name=\"fieldset[" . $order . "]\">\n";
    if (empty($options['fieldset_title']) && !$select_all) {
        $html .= "\t<option value=\"{$i}\" selected=\"selected\">" . __("no fieldset", $cimy_uef_domain) . "</option>\n";
    } else {
        if ($select_all) {
            $html .= "\t<option value=\"-1\"" . selected(-1, $selected, false) . ">" . __("All") . "</option>\n";
        }
        if (!empty($options['fieldset_title'])) {
            $fieldset_titles = explode(',', $options['fieldset_title']);
            foreach ($fieldset_titles as $fieldset) {
                $html .= "\t<option value=\"{$i}\"" . selected($i, $selected, false) . ">" . esc_html($fieldset) . "</option>\n";
                $i++;
            }
        }
    }
    $html .= "</select>";
    return $html;
}
示例#4
0
function cimy_fieldsetOptions($selected = 0, $order = "")
{
    global $cimy_uef_domain;
    if (!cimy_check_admin('manage_options')) {
        return;
    }
    $options = cimy_get_options();
    $i = 0;
    $html = "<select name=\"fieldset[" . $order . "]\">\n";
    if ($options['fieldset_title'] == "") {
        $html .= "\t<option value=\"{$i}\" selected=\"selected\">" . __("no fieldset", $cimy_uef_domain) . "</option>\n";
    } else {
        $fieldset_titles = explode(',', $options['fieldset_title']);
        foreach ($fieldset_titles as $fieldset) {
            if ($i == $selected) {
                $selected_txt = " selected=\"selected\"";
            } else {
                $selected_txt = "";
            }
            $html .= "\t<option value=\"{$i}\"" . $selected_txt . ">" . $fieldset . "</option>\n";
            $i++;
        }
    }
    $html .= "</select>";
    return $html;
}
function cimy_admin_menu_custom()
{
    global $cimy_uef_name, $cimy_uef_domain, $cimy_top_menu, $cimy_uef_plugins_dir;
    if (!cimy_check_admin('manage_options')) {
        return;
    }
    if (isset($cimy_top_menu) && !is_multisite()) {
        add_submenu_page('cimy_series.php', $cimy_uef_name . ": " . __("Options"), "UEF: " . __("Options"), 'manage_options', "user_extra_fields_options", 'cimy_show_options_notembedded');
        add_submenu_page('cimy_series.php', $cimy_uef_name . ": " . __("Fields", $cimy_uef_domain), "UEF: " . __("Fields", $cimy_uef_domain), 'manage_options', "user_extra_fields", 'cimy_admin_define_extra_fields');
        add_submenu_page('profile.php', __('Authors &amp; Users Extended', $cimy_uef_domain), __('A&amp;U Extended', $cimy_uef_domain), 'manage_options', "au_extended", 'cimy_admin_users_list_page');
    } else {
        if (is_multisite() && $cimy_uef_plugins_dir == "mu-plugins") {
            add_submenu_page('wpmu-admin.php', __("Users Extended", $cimy_uef_domain), __("Users Extended", $cimy_uef_domain), 'manage_options', "users_extended", 'cimy_admin_users_list_page');
            add_submenu_page('wpmu-admin.php', $cimy_uef_name, $cimy_uef_name, 'manage_options', "user_extra_fields", 'cimy_admin_define_extra_fields');
        } else {
            add_options_page($cimy_uef_name, $cimy_uef_name, 'manage_options', "user_extra_fields", 'cimy_admin_define_extra_fields');
            add_submenu_page('profile.php', __('Authors &amp; Users Extended', $cimy_uef_domain), __('A&amp;U Extended', $cimy_uef_domain), 'manage_options', "au_extended", 'cimy_admin_users_list_page');
        }
    }
}
示例#6
0
function cimy_save_field($action, $table, $data)
{
    global $wpdb, $wpdb_wp_fields_table;
    if (!cimy_check_admin("manage_options")) {
        return;
    }
    if ($table == $wpdb_wp_fields_table) {
        $wp_fields = true;
        $fieldset_sql = "";
    } else {
        $fieldset = intval($data['fieldset']);
        $fieldset_sql = ", fieldset=" . $fieldset;
    }
    $name = $wpdb->escape($data['name']);
    $value = $wpdb->escape($data['value']);
    $desc = $wpdb->escape($data['desc']);
    if ($wp_fields) {
        $label = $wpdb->escape(__($data['label']));
    } else {
        $label = $wpdb->escape($data['label']);
    }
    $type = $wpdb->escape($data['type']);
    $store_rule = $wpdb->escape(serialize($data['store_rule']));
    $field_order = $wpdb->escape($data['field_order']);
    $num_fields = $wpdb->escape($data['num_fields']);
    if ($action == "add") {
        $sql = "INSERT INTO " . $table . " ";
    } else {
        if ($action == "edit") {
            $sql = "UPDATE " . $table . " ";
        }
    }
    $sql .= "SET name='" . $name . "', value='" . $value . "', description='" . $desc . "', label='" . $label . "', type='" . $type . "', rules='" . $store_rule . "'" . $fieldset_sql;
    if ($action == "add") {
        $sql .= ", F_ORDER=" . ($num_fields + 1);
    } else {
        if ($action == "edit") {
            $sql .= " WHERE F_ORDER=" . $field_order;
        }
    }
    $wpdb->query($sql);
}