function tdomf_show_options_menu() { tdomf_handle_options_actions(); ?> <div class="wrap"> <h2><?php _e('General Options', 'tdomf'); ?> </h2> <br/> <form method="post" action="admin.php?page=tdomf_show_options_menu"> <?php if (function_exists('wp_nonce_field')) { wp_nonce_field('tdomf-options-save'); } ?> <div id="options_tabs" class="tabs"> <ul> <li><a href="#opt_general"><span><?php _e('General', 'tdomf'); ?> </span></a></li> <li><a href="#opt_new"><span><?php _e('Submissions', 'tdomf'); ?> </span></a></li> <li><a href="#opt_form"><span><?php _e('Form Session Management', 'tdomf'); ?> </span></a></li> <li><a href="#opt_spam"><span><?php _e('Spam Protection', 'tdomf'); ?> </span></a></li> <li><a href="#opt_ui"><span><?php _e('User Interface', 'tdomf'); ?> </span></a></li> <li><a href="#opt_debug"><span><?php _e('Debug', 'tdomf'); ?> </span></a></li> </ul> <div id="opt_general" class="tabs"> <p><?php _e("You <b>must</b> pick a default user to be used as the \"author\" of the post. This user cannot be able to publish or edit posts.", "tdomf"); ?> <br/><br/> <?php // update created users list (in case a user has been deleted) $created_users = get_option(TDOMF_OPTION_CREATEDUSERS); if ($created_users != false) { $updated_created_users = array(); foreach ($created_users as $created_user) { if (get_userdata($created_user)) { $updated_created_users[] = $created_user; } } update_option(TDOMF_OPTION_CREATEDUSERS, $updated_created_users); } ?> <?php $def_aut = get_option(TDOMF_DEFAULT_AUTHOR); $def_aut_bad = false; ?> <b><?php _e("Default Author", "tdomf"); ?> </b> <?php if (tdomf_get_all_users_count() < TDOMF_MAX_USERS_TO_DISPLAY) { ?> <select id="tdomf_def_user" name="tdomf_def_user"> <?php $users = tdomf_get_all_users(); $cnt_users = 0; foreach ($users as $user) { $status = get_usermeta($user->ID, TDOMF_KEY_STATUS); $user_obj = new WP_User($user->ID); if ($user->ID == $def_aut || !$user_obj->has_cap("publish_posts")) { $cnt_users++; ?> <option value="<?php echo $user->ID; ?> " <?php if ($user->ID == $def_aut) { ?> selected <?php } ?> ><?php if ($user_obj->has_cap("publish_posts")) { ?> <font color="red"><?php } echo $user->user_login; if (!empty($status) && $status == TDOMF_USER_STATUS_BANNED) { ?> (Banned User) <?php } if ($user_obj->has_cap("publish_posts")) { $def_aut_bad = true; ?> (Error) </font><?php } ?> </option> <?php } } ?> </select> <?php } else { $def_aut_username = ""; $cnt_users = 0; if ($def_aut != false) { $user_obj = new WP_User($def_aut); $cnt_users = 1; // at least if ($user_obj->has_cap("publish_posts")) { $def_aut_bad; } $def_aut_username = $user_obj->user_login; } ?> <input type="text" name="tdomf_def_user" id="tdomf_def_user" size="20" value="<?php echo htmlentities($def_aut_username, ENT_QUOTES, get_bloginfo('charset')); ?> " /> <?php } ?> <?php if ($def_aut_bad || $cnt_users <= 0) { ?> <?php $create_user_link = "admin.php?page=tdomf_show_options_menu&action=create_dummy_user"; if (function_exists('wp_nonce_url')) { $create_user_link = wp_nonce_url($create_user_link, 'tdomf-create-dummy-user'); } ?> <br/><br/> <a href="<?php echo $create_user_link; ?> ">Create a dummy user »</a> <?php } ?> </p> <p> <?php _e('You can have the user automatically changed to "trusted" after a configurable number of approved submissions and/or contributions. Setting it the value to 0, means that a registered user is automatically trusted. Setting it to -1, disables the feature. A trusted user can still be banned. This only counts for submitters or contributors who register with your blog and submit using a user account.', "tdomf"); ?> <?php printf(__('You can change a users status (to/from trusted or banned) using the <a href="%s">Manage</a> menu', "tdomf"), "admin.php?page=tdomf_show_manage_menu"); ?> </p> <p> <b><?php _e("Auto Trust Submitter Count", "tdomf"); ?> </b> <input type="text" name="tdomf_trust_count" id="tdomf_trust_count" size="3" value="<?php echo htmlentities(get_option(TDOMF_OPTION_TRUST_COUNT), ENT_QUOTES, get_bloginfo('charset')); ?> " /> </p> <p> <?php _e('When a user logs into Wordpress, they can access a "Your Submissions" page which contains a copy of the form. You can disable this page by disabling this option.', 'tdomf'); ?> </p> <?php $your_submissions = get_option(TDOMF_OPTION_YOUR_SUBMISSIONS); ?> </p> <b><?php _e("Enable 'Your Submissions' page ", "tdomf"); ?> </b> <input type="checkbox" name="tdomf_your_submissions" id="tdomf_your_submissions" <?php if ($your_submissions) { echo "checked"; } ?> > </p> </div> <!-- /opt_general --> <div id="opt_new" class="tabs"> <p> <?php _e("If an entry is submitted by a subscriber and is published using the normal wordpress interface, the author can be changed to the person who published it, not submitted. Select this option if you want this to be automatically corrected. This problem only occurs on blogs that have more than one user who can publish.", "tdomf"); ?> <br/><br/> <?php $fix_aut = get_option(TDOMF_AUTO_FIX_AUTHOR); ?> <b><?php _e("Auto-correct Author", "tdomf"); ?> </b> <input type="checkbox" name="tdomf_autocorrect_author" id="tdomf_autocorrect_author" <?php if ($fix_aut) { echo "checked"; } ?> > </p> <p> <?php _e('If your theme displays the author of a post, you can automatically have it display the submitter info instead, if avaliable. It is recommended to use the "Who Am I" widget to get the full benefit of this option. The default and classic themes in Wordpress do not display the author of a post.', "tdomf"); ?> </p> <?php $on_author_theme_hack = get_option(TDOMF_OPTION_AUTHOR_THEME_HACK); ?> </p> <b><?php _e("Use submitter info for author in your theme", "tdomf"); ?> </b> <input type="checkbox" name="tdomf_author_theme_hack" id="tdomf_author_theme_hack" <?php if ($on_author_theme_hack) { echo "checked"; } ?> > </p> <p> <?php _e('You can automatically add submitter info to the end of a post. This works on all themes.', "tdomf"); ?> </p> <?php $on_add_submitter = get_option(TDOMF_OPTION_ADD_SUBMITTER); ?> </p> <b><?php _e("Add submitter to end of post", "tdomf"); ?> </b> <input type="checkbox" name="tdomf_add_submitter" id="tdomf_add_submitter" <?php if ($on_add_submitter) { echo "checked"; } ?> > </p> </div><!-- /opt_new --> <div id="opt_form" class="tabs"> <h3><?php _e('Form Verification Options', "tdomf"); ?> </h3> <?php $tdomf_verify = get_option(TDOMF_OPTION_VERIFICATION_METHOD); ?> <p> <?php _e('You can use these options to set how a submission is verified as coming from a form created by TDOMF. You shouldn\'t need to modify these settings unless you are having a problem with "Bad Data" or invalid session keys', "tdomf"); ?> </p> <p> <input type="radio" name="tdomf_verify" value="default"<?php if ($tdomf_verify == "default" || $tdomf_verify == false) { ?> checked <?php } ?> > <?php _e('Use TDO-Mini-Forms internal Method', "tdomf"); ?> <br> <?php if (function_exists('wp_nonce_field')) { ?> <input type="radio" name="tdomf_verify" value="wordpress_nonce"<?php if ($tdomf_verify == "wordpress_nonce") { ?> checked <?php } ?> > <?php _e("Use Wordpress nonce Method", "tdomf"); ?> <br> <?php } ?> <input type="radio" name="tdomf_verify" value="none"<?php if ($tdomf_verify == "none") { ?> checked <?php } ?> > <?php if ($tdomf_verify == "none") { ?> <font color="red"><?php } ?> <?php _e("Disable Verification (not recommended)", "tdomf"); ?> <?php if ($tdomf_verify == "none") { ?> </font><?php } ?> </p> <h3><?php _e('Form Session Data', "tdomf"); ?> </h3> <?php $tdomf_form_data = get_option(TDOMF_OPTION_FORM_DATA_METHOD); ?> <p> <?php _e('The original and default method for moving data around for a form in use, uses <code>$_SESSION</code>. However this does not work on every platform, specifically if <code>register_globals</code> is enabled. The alternative method, using a database, should work in all cases as long as the user accepts the cookie. You shouldn\'t need to modify these settings unless you are having a problem with "Bad Data" or register_global.', "tdomf"); ?> </p> <p> <input type="radio" name="tdomf_form_data" value="session"<?php if ($tdomf_form_data == "session" || $tdomf_form_data == false) { ?> checked <?php } if (ini_get('register_globals')) { ?> disabled <?php } ?> > <?php if (ini_get('register_globals')) { ?> <del><?php } ?> <?php _e('Use <code>$_SESSION</code> to handle from session data (may not work on all host configurations)', "tdomf"); ?> <?php if (ini_get('register_globals')) { ?> </del><?php } ?> <br> <input type="radio" name="tdomf_form_data" value="db"<?php if ($tdomf_form_data == "db") { ?> checked <?php } ?> > <?php _e("Use database (and cookie) to store session data (should work in all cases)", "tdomf"); ?> <br> </p> </div> <!-- /opt_form --> <div id="opt_spam" class="tabs"> <p> <?php printf(__('You can enable spam protection for new submissions and edits. The online service Akismet is used to identify if a submission or contribution is spam or not. You can moderate spam from the <a href="%s">Moderation</a> screen. Some of these options can be overwritten on a per-form basis.', "tdomf"), "admin.php?page=tdomf_show_mod_posts_menu&show=spam&mode=list"); ?> </p> <?php tdomf_show_spam_options(); ?> </div> <!-- /opt_spam --> <div id="opt_ui" class="tabs"> <?php if (tdomf_wp25()) { ?> <p> <?php _e('You can limit or increase the max size of the control form of a widget in the Form Widget screen. A value of 0 disables this feature.', "tdomf"); ?> </p> <p> <b><?php _e("Max Widget Width", "tdomf"); ?> </b> <input type="text" name="widget_max_width" id="widget_max_width" size="3" value="<?php echo intval(get_option(TDOMF_OPTION_WIDGET_MAX_WIDTH)); ?> " /> </p> <p> <b><?php _e("Max Widget Height", "tdomf"); ?> </b> <input type="text" name="widget_max_height" id="widget_max_height" size="3" value="<?php echo intval(get_option(TDOMF_OPTION_WIDGET_MAX_HEIGHT)); ?> " /> </p> <?php } ?> <?php $tdomf_mod_show_links = get_option(TDOMF_OPTION_MOD_SHOW_LINKS); ?> <b><?php _e("Do not 'auto-hide' links on moderation screen", "tdomf"); ?> </b> <input type="checkbox" name="tdomf_mod_show_links" id="tdomf_mod_show_links" <?php if ($tdomf_mod_show_links) { echo "checked"; } ?> > </p> </div> <!-- /opt_ui --> <div id="opt_debug" class="tabs"> <p> <?php _e('You can disable the display of errors to the user when they use this form. This does not stop errors being reported to the log or enable forms to be submitted with "Bad Data"', 'tdomf'); ?> </p> <?php $disable_errors = get_option(TDOMF_OPTION_DISABLE_ERROR_MESSAGES); ?> </p> <b><?php _e("Disable error messages being show to user", "tdomf"); ?> </b> <input type="checkbox" name="tdomf_disable_errors" id="tdomf_disable_errors" <?php if ($disable_errors) { echo "checked"; } ?> > </p> <p> <?php _e('You can enable extra debugs messages to aid in debugging problems. If you enable "Error Messages" this will also turn on extra PHP error checking.', 'tdomf'); ?> </p> <?php $extra_log = get_option(TDOMF_OPTION_EXTRA_LOG_MESSAGES); ?> </p> <b><?php _e("Enable extra log messages ", "tdomf"); ?> </b> <input type="checkbox" name="tdomf_extra_log" id="tdomf_extra_log" <?php if ($extra_log) { echo "checked"; } ?> > </p> <p> <?php _e('Limit the number of lines in your tdomf log. A value of 0 disables the stored log.', "tdomf"); ?> </p> <p> <b><?php _e("Max Lines in Log", "tdomf"); ?> </b> <input type="text" name="tdomf_log_max_size" id="tdomf_log_max_size" size="4" value="<?php echo htmlentities(get_option(TDOMF_OPTION_LOG_MAX_SIZE), ENT_QUOTES, get_bloginfo('charset')); ?> " /> </p> </div> <!-- /opt_debug --> </div> <!-- /tabs --> <br/> <table border="0"><tr> <td> <input type="hidden" name="save_settings" value="0" /> <input type="submit" name="tdomf_save_button" id="tdomf_save_button" value="<?php _e("Save", "tdomf"); ?> »" /> </form> </td> <td> <form method="post" action="admin.php?page=tdomf_show_options_menu"> <input type="submit" name="refresh" value="Refresh" /> </form> </td> </tr></table> </div> <?php }
function tdomf_show_edit_post_panel() { global $post; // don't show on new post if ($post->ID > 0) { $can_edit = false; if (current_user_can('publish_posts')) { $can_edit = true; } $is_tdomf = false; $tdomf_flag = get_post_meta($post->ID, TDOMF_KEY_FLAG, true); if (!empty($tdomf_flag)) { $is_tdomf = true; } $locked = get_post_meta($post->ID, TDOMF_KEY_LOCK, true); $submitter_id = get_post_meta($post->ID, TDOMF_KEY_USER_ID, true); $submitter_ip = get_post_meta($post->ID, TDOMF_KEY_IP, true); $form_id = get_post_meta($post->ID, TDOMF_KEY_FORM_ID, true); $is_spam = get_option(TDOMF_OPTION_SPAM) && get_post_meta($post->ID, TDOMF_KEY_SPAM, true); // use JavaScript SACK library for AJAX wp_print_scripts(array('sack')); // I could stick this AJAX call into the Admin header, however, I don't want // it hanging around on every admin page and potentially being called // accidentially from some other TDOMF page ?> <script type="text/javascript"> //<![CDATA[ function tdomf_ajax_edit_post( flag, is_user, user, name, email, web, locked ) { var mysack = new sack( "<?php bloginfo('wpurl'); ?> /wp-admin/admin-ajax.php" ); mysack.execute = 1; mysack.method = 'POST'; mysack.setVar( "action", "tdomf_edit_post" ); mysack.setVar( "post_ID", "<?php echo $post->ID; ?> " ); mysack.setVar( "tdomf_flag", flag.checked ); mysack.setVar( "tdomf_locked", locked.checked ); if(is_user.checked) { mysack.setVar( "tdomf_user", user.value); } else { mysack.setVar( "tdomf_name", name.value ); mysack.setVar( "tdomf_email", email.value ); mysack.setVar( "tdomf_web", web.value ); } mysack.encVar( "cookie", document.cookie, false ); mysack.onError = function() { alert('<?php _e('AJAX error in looking up tdomf', 'tdomf'); ?> ' )}; mysack.runAJAX(); return true; } function tdomf_update_panel() { <?php if ($can_edit) { ?> var flag = document.getElementById("tdomf_flag").checked; if(flag) { //document.getElementById("tdomf_submitter").disabled = false; document.getElementById("tdomf_submitter_is_user").disabled = false; document.getElementById("tdomf_submitter_not_user").disabled = false; var is_user = document.getElementById("tdomf_submitter_is_user").checked; document.getElementById("tdomf_submitter_user").disabled = !is_user; document.getElementById("tdomf_submitter_name").disabled = is_user; document.getElementById("tdomf_submitter_email").disabled = is_user; document.getElementById("tdomf_submitter_web").disabled = is_user; } else { // disable everything //document.getElementById("tdomf_submitter").disabled = true; document.getElementById("tdomf_submitter_is_user").disabled = true; document.getElementById("tdomf_submitter_user").disabled = true; document.getElementById("tdomf_submitter_not_user").disabled = true; document.getElementById("tdomf_submitter_name").disabled = true; document.getElementById("tdomf_submitter_email").disabled = true; document.getElementById("tdomf_submitter_web").disabled = true; } <?php } else { ?> // nothing can be enabled //document.getElementById("tdomf_submitter").disabled = true; document.getElementById("tdomf_flag").disabled = true; document.getElementById("tdomf_submitter_is_user").disabled = true; document.getElementById("tdomf_submitter_user").disabled = true; document.getElementById("tdomf_submitter_not_user").disabled = true; document.getElementById("tdomf_submitter_name").disabled = true; document.getElementById("tdomf_submitter_email").disabled = true; document.getElementById("tdomf_submitter_web").disabled = true; <?php } ?> } //]]> </SCRIPT> <?php if (!function_exists('add_meta_box')) { ?> <fieldset class="dbx-box"> <h3 id="posttdomf" class="dbx-handle"><?php _e('TDO Mini Forms', "tdomf"); ?> </h3> <div class="dbx-content"> <?php } ?> <fieldset> <legend> <input id="tdomf_flag" type="checkbox" name="tdomf_flag" <?php if ($tdomf_flag) { ?> checked<?php } ?> <?php if (!$can_edit) { ?> disabled <?php } ?> onClick="tdomf_update_panel();" /> <label for="tdomf_flag"><?php _e("Include in TDO Mini Forms Moderation", "tdomf"); ?> </label> </legend> <br/> <input id="tdomf_locked" type="checkbox" name="tdomf_locked" <?php if ($tdomf_locked) { ?> checked<?php } ?> <?php if (!$can_edit) { ?> disabled <?php } ?> onClick="tdomf_update_panel();" /> <label for="tdomf_locked"><?php _e('Disable Editing by TDO Mini Form Forms', 'tdomf'); ?> </label> <br/><br/> <?php if (!empty($submitter_id) && $submitter_id == get_option(TDOMF_DEFAULT_AUTHOR)) { ?> <span style="color:red;font-size:larger;"><?php _e('The submitter of this post is set as the "default user"! Please correct!', 'tdomf'); ?> </span> <br/><br/> <?php } ?> <label for="tdomf_submitter_is_user" class="selectit"> <input id="tdomf_submitter_is_user" type="radio" name="tdomf_submitter" value="tdomf_submitter_is_user" <?php if (!empty($submitter_id)) { ?> checked<?php } ?> <?php if (!$can_edit || !$tdomf_flag) { ?> disabled <?php } ?> onChange="tdomf_update_panel();" /> <?php _e('Submitter is an existing user', 'tdomf'); ?> </label> <?php if (function_exists('add_meta_box')) { ?> <br/><br/> <?php } ?> <?php if (tdomf_get_all_users_count() < TDOMF_MAX_USERS_TO_DISPLAY) { ?> <select id="tdomf_submitter_user" name="tdomf_submitter_user" <?php if (!$can_edit || !$tdomf_flag || empty($submitter_id)) { ?> disabled <?php } ?> onChange="tdomf_update_panel();" > <?php $users = tdomf_get_all_users(); foreach ($users as $user) { $status = get_usermeta($user->ID, TDOMF_KEY_STATUS); if ($user->ID == $submitter_id || $user->ID != get_option(TDOMF_DEFAULT_AUTHOR)) { ?> <option value="<?php echo $user->ID; ?> " <?php if ($user->ID == $submitter_id) { ?> selected <?php } ?> ><?php echo $user->user_login; if ($user->ID == get_option(TDOMF_DEFAULT_AUTHOR)) { _e("(Default User)", "tdomf"); } if (!empty($status) && $status == TDOMF_USER_STATUS_BANNED) { _e("(Banned User)", "tdomf"); } ?> </option> <?php } } ?> </select> <?php } else { $submitter_username = ""; if (!empty($submitter_id)) { $user_obj = new WP_User($submitter_id); $submitter_username = $user_obj->user_login; } ?> <input type="text" name="tdomf_submitter_user" id="tdomf_submitter_user" size="20" value="<?php echo htmlentities($submitter_username, ENT_QUOTES, get_bloginfo('charset')); ?> " <?php if (!$can_edit || !$tdomf_flag) { ?> disabled <?php } ?> /> <?php } ?> <br/><br/> <label for="tdomf_submitter_not_user" class="selectit"> <input id="tdomf_submitter_not_user" type="radio" name="tdomf_submitter" value="tdomf_submitter_not_user" <?php if (empty($submitter_id)) { ?> checked<?php } ?> <?php if (!$can_edit || !$tdomf_flag) { ?> disabled <?php } ?> onChange="tdomf_update_panel();" /> <?php _e("Submitter does not have a user account", "tdomf"); ?> </label> <?php if (function_exists('add_meta_box')) { ?> <br/><br/> <?php } ?> <?php if (!function_exists('add_meta_box')) { ?> <label for="tdomf_submitter_name" class="selectit"><?php _e("Name", "tdomf"); ?> <?php } ?> <input type="textfield" value="<?php echo htmlentities(get_post_meta($post->ID, TDOMF_KEY_NAME, true), ENT_QUOTES, get_bloginfo('charset')); ?> " name="tdomf_submitter_name" id="tdomf_submitter_name" onClick="tdomf_update_panel();" <?php if (!$can_edit || !$tdomf_flag || !empty($submitter_id)) { ?> disabled <?php } ?> /> <?php if (function_exists('add_meta_box')) { ?> <label for="tdomf_submitter_name" class="selectit"><?php _e("Name", "tdomf"); ?> <?php } ?> </label> <?php if (function_exists('add_meta_box')) { ?> <br/><br/> <?php } ?> <?php if (!function_exists('add_meta_box')) { ?> <label for="tdomf_submitter_email" class="selectit"><?php _e("Email", "tdomf"); ?> <?php } ?> <input type="textfield" value="<?php echo htmlentities(get_post_meta($post->ID, TDOMF_KEY_EMAIL, true), ENT_QUOTES, get_bloginfo('charset')); ?> " name="tdomf_submitter_email" id="tdomf_submitter_email" onClick="tdomf_update_panel();" <?php if (!$can_edit || !$tdomf_flag || !empty($submitter_id)) { ?> disabled <?php } ?> /> <?php if (function_exists('add_meta_box')) { ?> <label for="tdomf_submitter_email" class="selectit"><?php _e("Email", "tdomf"); ?> <?php } ?> </label> <?php if (function_exists('add_meta_box')) { ?> <br/><br/> <?php } ?> <?php if (!function_exists('add_meta_box')) { ?> <label for="tdomf_submitter_web" class="selectit"><?php _e("Webpage", "tdomf"); ?> <?php } ?> <input type="textfield" value="<?php echo htmlentities(get_post_meta($post->ID, TDOMF_KEY_WEB, true), ENT_QUOTES, get_bloginfo('charset')); ?> " name="tdomf_submitter_web" id="tdomf_submitter_web" onClick="tdomf_update_panel();" <?php if (!$can_edit || !$tdomf_flag || !empty($submitter_id)) { ?> disabled <?php } ?> /> <?php if (function_exists('add_meta_box')) { ?> <label for="tdomf_submitter_web" class="selectit"><?php _e("Webpage", "tdomf"); ?> <?php } ?> </label> <br/><br/> <?php if ($is_spam) { ?> <span style="color:red;font-size:larger;"><?php _e("Akismet thinks this submission is spam!", 'tdomf'); ?> </span> <?php } ?> <?php if (!empty($submitter_ip)) { ?> <?php printf(__("This post was submitted from IP %s.", "tdomf"), $submitter_ip); ?> <?php } else { ?> <?php _e("No IP was recorded when this post was submitted.", "tdomf"); ?> <?php } ?> <?php if ($form_id != false && tdomf_form_exists($form_id)) { printf(__("Submitted from Form %d.", "tdomf"), $form_id); } ?> </fieldset> <p><input type="button" value="<?php _e("Update »", "tdomf"); ?> " onclick="tdomf_ajax_edit_post(this.form.tdomf_flag, tdomf_submitter_is_user, tdomf_submitter_user, tdomf_submitter_name, tdomf_submitter_email, tdomf_submitter_web, this.form.tdomf_locked);" /> <?php if (!function_exists('add_meta_box')) { ?> </div> </fieldset> <?php } ?> <?php } }