Ejemplo n.º 1
0
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 &raquo;</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");
    ?>
 &raquo;" />
	</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 
}
Ejemplo n.º 2
0
function tdomf_show_form_options($form_id)
{
    global $wp_version;
    if (!tdomf_form_exists($form_id)) {
        ?>
    <div class="wrap"><font color="red"><?php 
        printf(__("Form id %d does not exist!", "tdomf"), $form_id);
        ?>
</font></div>
  <?php 
    } else {
        ?>
    
    <?php 
        $pages = tdomf_get_option_form(TDOMF_OPTION_CREATEDPAGES, $form_id);
        $updated_pages = false;
        if ($pages != false) {
            $updated_pages = array();
            foreach ($pages as $page_id) {
                if (get_permalink($page_id) != false) {
                    $updated_pages[] = $page_id;
                }
            }
            if (count($updated_pages) == 0) {
                $updated_pages = false;
            }
            tdomf_set_option_form(TDOMF_OPTION_CREATEDPAGES, $updated_pages, $form_id);
        }
        ?>

    
    <div class="wrap">
    
    <h2><?php 
        printf(__("Form %d Options", "tdomf"), $form_id);
        ?>
</h2>
    
    <?php 
        tdomf_forms_under_title_toolbar($form_id);
        ?>
     
          <?php 
        if ($updated_pages == false) {
            ?>
          
             <?php 
            $create_form_link = "admin.php?page=tdomf_show_form_options_menu&action=create_form_page&form={$form_id}";
            if (function_exists('wp_nonce_url')) {
                $create_form_link = wp_nonce_url($create_form_link, 'tdomf-create-form-page');
            }
            ?>
    <p><a href="<?php 
            echo $create_form_link;
            ?>
"><?php 
            _e("Create a page with this form automatically &raquo;", "tdomf");
            ?>
</a></p>
          <?php 
        }
        ?>
          
    <?php 
        if (tdomf_wp23()) {
            ?>
          <p><a href="admin.php?page=tdomf_show_form_menu&form=<?php 
            echo $form_id;
            ?>
"><?php 
            printf(__("Widgets for Form %d &raquo;", "tdomf"), $form_id);
            ?>
</a></p>
    <?php 
        }
        ?>
    
    <br/>
    
    <form method="post" action="admin.php?page=tdomf_show_form_options_menu&form=<?php 
        echo $form_id;
        ?>
">

    <input type="hidden" id="tdomf_form_id" name="tdomf_form_id" value="<?php 
        echo $form_id;
        ?>
" />
    <?php 
        if (function_exists('wp_nonce_field')) {
            wp_nonce_field('tdomf-options-save');
        }
        ?>
    
    <div id="form_options_tabs" class="tabs">
    <ul>
        <li><a href="#form_gen"><span><?php 
        _e('General', 'tdomf');
        ?>
</span></a></li>
        <li><a href="#form_access"><span><?php 
        _e('Access Control', 'tdomf');
        ?>
</span></a></li>
        <li><a href="#form_new"><span><?php 
        _e('Submitting', 'tdomf');
        ?>
</span></a></li>
        <li><a href="#form_edit"><span><?php 
        _e('Editing', 'tdomf');
        ?>
</span></a></li>
        <li><a href="#form_moderation"><span><?php 
        _e('Moderation', 'tdomf');
        ?>
</span></a></li>
        <li><a href="#form_throttling"><span><?php 
        _e('Throttling', 'tdomf');
        ?>
</span></a></li>
        <li><a href="#form_spam"><span><?php 
        _e('Spam Protection', 'tdomf');
        ?>
</span></a></li>
    </ul>

    <div id="form_gen">

<?php 
        $form_name = tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id);
        ?>
    <p>
        <label for="tdomf_form_name">
            <?php 
        _e("Form Name:", "tdomf");
        ?>
        </label>
        <input type="text" name="tdomf_form_name" id="tdomf_form_name" value="<?php 
        if ($form_name) {
            echo htmlentities(stripslashes($form_name), ENT_QUOTES, get_bloginfo('charset'));
        }
        ?>
" />
	</p>    
     
   <?php 
        $form_descp = tdomf_get_option_form(TDOMF_OPTION_DESCRIPTION, $form_id);
        ?>
   <p>
        <label for="tdomf_form_descp">   
            <?php 
        _e('Form Description', "tdomf");
        ?>
<br/>
        </label>
        <textarea cols="80" rows="3" name="tdomf_form_descp" id="tdomf_form_descp"><?php 
        if ($form_descp) {
            echo htmlentities(stripslashes($form_descp), ENT_NOQUOTES, get_bloginfo('charset'));
        }
        ?>
</textarea>
   </p>

    <script type="text/javascript">
         //<![CDATA[
        
          function tdomf_enable_use_type_posts() {
            var flag = document.getElementById("tdomf_use_type_posts").checked;
            var flag_edit = document.getElementById("tdomf_mode_edit").checked;
            var flag_new = document.getElementById("tdomf_mode_new").checked;
            if(flag_new) {
                document.getElementById("tdomf_def_cat").disabled = !flag;
            }
            if(flag_edit) {
                //document.getElementById("tdomf_edit_cat_only").disabled = !flag;
                document.getElementById("tdomf_edit_cats").disabled = !flag;
            }
          }
          
          function tdomf_enable_edit() {
            var flag = !document.getElementById("tdomf_mode_edit").checked;
            var flag_posts = document.getElementById("tdomf_use_type_posts").checked;
            
            // disable 'new' options
            
            var flag_posts = document.getElementById("tdomf_use_type_posts").checked;
            if(flag_posts) {
                document.getElementById("tdomf_def_cat").disabled = !flag;
            }
            document.getElementById("tdomf_queue_period").disabled = !flag;
            document.getElementById("tdomf_queue_on_all").disabled = !flag;

            // re-enable 'edit' options
            
            document.getElementById("tdomf_edit_tdomf_only").disabled = flag;
            if(flag_posts) {
                //document.getElementById("tdomf_edit_cat_only").disabled = flag;
                document.getElementById("tdomf_edit_cats").disabled = flag;
            }
            
            document.getElementById("tdomf_ajax_edit").disabled = flag;
            document.getElementById("tdomf_add_edit_link_none").disabled = flag;
            <?php 
        if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) {
            ?>
 
                document.getElementById("tdomf_add_edit_link_your_submissions").disabled = flag;
            <?php 
        }
        ?>
            document.getElementById("tdomf_add_edit_link_custom").disabled = flag;
            document.getElementById("tdomf_add_edit_link_custom_url").disabled = flag;
            
            document.getElementById("tdomf_auto_edit_link_none").disabled = flag;
            <?php 
        if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) {
            ?>
 
                document.getElementById("tdomf_auto_edit_link_your_submissions").disabled = flag;
            <?php 
        }
        ?>
            document.getElementById("tdomf_auto_edit_link_custom").disabled = flag;
            document.getElementById("tdomf_auto_edit_link_custom_url").disabled = flag;
            
            document.getElementById("tdomf_author_edit").disabled = flag;
            document.getElementById("tdomf_time_edit").disabled = flag;

            // enable / disable tabs
            
            <?php 
        if (version_compare($wp_version, "2.8-beta2", ">=")) {
            ?>
            var selected = jQuery("#form_options_tabs").data('selected.tabs');
            if(!flag) {
                jQuery("#form_options_tabs").tabs("enable",3);
                if(selected == 1) {
                    jQuery("#form_options_tabs").tabs("select",3);
                }
                jQuery("#form_options_tabs").tabs("disable",2);
            } else {
                jQuery("#form_options_tabs").tabs("enable",2);
                if(selected == 2) {
                    jQuery("#form_options_tabs").tabs("select",2);
                }
                jQuery("#form_options_tabs").tabs("disable",3);
            }
            <?php 
        } else {
            ?>
            var selected = jQuery("#form_options_tabs > ul").data('selected.tabs');                
            if(!flag) {
                jQuery("#form_options_tabs > ul").tabs("enable",3);
                if(selected == 1) {
                    jQuery("#form_options_tabs > ul").tabs("select",3);
                }
                jQuery("#form_options_tabs > ul").tabs("disable",2);
            } else {
                jQuery("#form_options_tabs > ul").tabs("enable",2);
                if(selected == 2) {
                    jQuery("#form_options_tabs > ul").tabs("select",2);
                }
                jQuery("#form_options_tabs > ul").tabs("disable",3);
            }
            <?php 
        }
        ?>
          }
          
          function tdomf_enable_new() {
            var flag = !document.getElementById("tdomf_mode_new").checked;
            
            // re-enable 'new' options
            
            var flag_posts = document.getElementById("tdomf_use_type_posts").checked;
            if(flag_posts) {
                document.getElementById("tdomf_def_cat").disabled = flag;
            }
            document.getElementById("tdomf_queue_period").disabled = flag;
            document.getElementById("tdomf_queue_on_all").disabled = flag;            
            
            // disable 'edit' options
            
            document.getElementById("tdomf_edit_tdomf_only").disabled = !flag;
            if(flag_posts) {
                //document.getElementById("tdomf_edit_cat_only").disabled = !flag;
                document.getElementById("tdomf_edit_cats").disabled = !flag;
            }
            
            document.getElementById("tdomf_ajax_edit").disabled = flag;
            document.getElementById("tdomf_add_edit_link_none").disabled = flag;
            <?php 
        if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) {
            ?>
 
                document.getElementById("tdomf_add_edit_link_your_submissions").disabled = flag;
            <?php 
        }
        ?>
            document.getElementById("tdomf_add_edit_link_custom").disabled = flag;
            document.getElementById("tdomf_add_edit_link_custom_url").disabled = flag;
            
            document.getElementById("tdomf_auto_edit_link_none").disabled = flag;
            <?php 
        if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) {
            ?>
 
                document.getElementById("tdomf_auto_edit_link_your_submissions").disabled = flag;
            <?php 
        }
        ?>
            document.getElementById("tdomf_auto_edit_link_custom").disabled = flag;
            document.getElementById("tdomf_auto_edit_link_custom_url").disabled = flag;
            
            document.getElementById("tdomf_author_edit").disabled = !flag;
            document.getElementById("tdomf_time_edit").disabled = !flag;
            
            // enable / disable tabs
            
            <?php 
        if (version_compare($wp_version, "2.8-beta2", ">=")) {
            ?>
            var selected = jQuery("#form_options_tabs").data('selected.tabs');
            if(!flag) {
                jQuery("#form_options_tabs").tabs("enable",2);
                if(selected == 2) {
                    jQuery("#form_options_tabs").tabs("select",2);
                }
                jQuery("#form_options_tabs").tabs("disable",3);
            } else {
                jQuery("#form_options_tabs").tabs("enable",3);
                if(selected == 1) {
                    jQuery("#form_options_tabs").tabs("select",3);
                }
                jQuery("#form_options_tabs").tabs("disable",2);
            }                
            <?php 
        } else {
            ?>
            var selected = jQuery("#form_options_tabs > ul").data('selected.tabs');
            if(!flag) {
                jQuery("#form_options_tabs > ul").tabs("enable",2);
                if(selected == 2) {
                    jQuery("#form_options_tabs > ul").tabs("select",2);
                }
                jQuery("#form_options_tabs > ul").tabs("disable",3);
            } else {
                jQuery("#form_options_tabs > ul").tabs("enable",3);
                if(selected == 1) {
                    jQuery("#form_options_tabs > ul").tabs("select",3);
                }
                jQuery("#form_options_tabs > ul").tabs("disable",2);
            }
            <?php 
        }
        ?>
          }
    //-->
    </script>
   
    <?php 
        $use_page = tdomf_get_option_form(TDOMF_OPTION_SUBMIT_PAGE, $form_id);
        ?>
    <?php 
        $edit_form = tdomf_get_option_form(TDOMF_OPTION_FORM_EDIT, $form_id);
        ?>
    
    
    <script type="text/javascript">
         //<![CDATA[
         jQuery(document).ready(function(){
         <?php 
        if (!$edit_form) {
            ?>
           <?php 
            if (version_compare($wp_version, "2.8-beta2", ">=")) {
                ?>
           jQuery("#form_options_tabs").tabs("disable",3);               
           <?php 
            } else {
                ?>
           jQuery("#form_options_tabs > ul").tabs("disable",3);
           <?php 
            }
            ?>
         <?php 
        } else {
            ?>
           <?php 
            if (version_compare($wp_version, "2.8-beta2", ">=")) {
                ?>
           jQuery("#form_options_tabs").tabs("disable",2);               
           <?php 
            } else {
                ?>
           jQuery("#form_options_tabs > ul").tabs("disable",2);
           <?php 
            }
            ?>
         <?php 
        }
        ?>
         });
    //-->
    </script>
    
	<p>
        <?php 
        _e('This form will be used to', 'tdomf');
        ?>
        <input type="radio" name="tdomf_mode" id="tdomf_mode_new" value="new" <?php 
        if (!$edit_form) {
            echo "checked";
        }
        ?>
 onChange="tdomf_enable_new();" ><?php 
        _e('submit new or', 'tdomf');
        ?>
        <input type="radio" name="tdomf_mode" id="tdomf_mode_edit" value="edit" <?php 
        if ($edit_form) {
            echo "checked";
        }
        ?>
 onChange="tdomf_enable_edit();" ><?php 
        _e('edit existing ', 'tdomf');
        ?>
        <input type="radio" name="tdomf_use_type" id="tdomf_use_type_posts" value="post" <?php 
        if (!$use_page) {
            echo "checked";
        }
        ?>
 onChange="tdomf_enable_use_type_posts();" ><?php 
        _e('Posts or', 'tdomf');
        ?>
        <input type="radio" name="tdomf_use_type" id="tdomf_use_type_pages" value="page" <?php 
        if ($use_page) {
            echo "checked";
        }
        ?>
 onChange="tdomf_enable_use_type_posts();" ><?php 
        _e('Pages', 'tdomf');
        ?>
    </p>   

     <p>
    </p>  
    
    <p>
        <?php 
        $on_preview = tdomf_get_option_form(TDOMF_OPTION_PREVIEW, $form_id);
        ?>
        <input type="checkbox" name="tdomf_preview" id="tdomf_preview"  <?php 
        if ($on_preview) {
            echo "checked";
        }
        ?>
 >
        <label for="tdomf_include_sub">
            <?php 
        _e("Enable Preview", "tdomf");
        ?>
        </label>
        <br/>
        
        <?php 
        if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) {
            ?>
            <?php 
            $inc_sub = tdomf_get_option_form(TDOMF_OPTION_INCLUDED_YOUR_SUBMISSIONS, $form_id);
            ?>
            <input type="checkbox" name="tdomf_include_sub" id="tdomf_include_sub" <?php 
            if ($inc_sub) {
                echo "checked";
            }
            ?>
 >
            <label for="tdomf_include_sub">
               <?php 
            _e("Include on 'Your Submissions' page", "tdomf");
            ?>
            </label>
            <br/>
        <?php 
        }
        ?>
        
        <?php 
        $ajax = tdomf_get_option_form(TDOMF_OPTION_AJAX, $form_id);
        ?>
        <input type="checkbox" name="tdomf_ajax" id="tdomf_ajax"  <?php 
        if ($ajax) {
            echo "checked";
        }
        ?>
 >
        <label for="tdomf_ajax">
            <?php 
        _e("Enable AJAX", "tdomf");
        ?>
        </label>
    </p>
        
    <?php 
        $from_email = tdomf_get_option_form(TDOMF_OPTION_FROM_EMAIL, $form_id);
        ?>
    <p>
        <label for="tdomf_from_email">
	        <?php 
        _e("'From Email' Address to use in notifications to users. Leave blank for Wordpress default.", "tdomf");
        ?>
<br/>
        </label>
        <input type="text" name="tdomf_from_email" id="tdomf_from_email" size="80" value="<?php 
        if ($from_email) {
            echo htmlentities($from_email, ENT_QUOTES, get_bloginfo('charset'));
        }
        ?>
" >
	</p>
  
    <?php 
        $widget_count = tdomf_get_option_form(TDOMF_OPTION_WIDGET_INSTANCES, $form_id);
        if ($widget_count == false) {
            $widget_count = 9;
        }
        ?>
	<p>
        <label for="tdomf_widget_count">
            <?php 
        _e("Number of multiple-instances Widgets to have on Form Widgets page:", "tdomf");
        ?>
        </label>
        <input type="text" name="tdomf_widget_count" id="tdomf_widget_count" size="3" value="<?php 
        echo htmlentities(strval($widget_count), ENT_QUOTES, get_bloginfo('charset'));
        ?>
" />
	</p>
    
    </div><!-- /form_gen -->
    
    <div id="form_access">
    
    <p><?php 
        _e("You can control access to the form based on user roles, capabilities or by specific users. You can chose \"Unregistered Users\" if you want anyone to be able to access the form, including visitors to your site that do not have user accounts. The old behaviour of TDO Mini Forms allowed any user with the ability to publish posts automatic access to the form. This behaviour can now be turned off or on as required.", "tdomf");
        ?>
</p>
   
	<?php 
        if (!isset($wp_roles)) {
            $wp_roles = new WP_Roles();
        }
        $roles = $wp_roles->role_objects;
        $access_roles = array();
        $publish_roles = array();
        foreach ($roles as $role) {
            if (!isset($role->capabilities['publish_posts'])) {
                if ($role->name != get_option('default_role')) {
                    array_push($access_roles, $role->name);
                } else {
                    $def_role = $role->name;
                }
            } else {
                array_push($publish_roles, $role->name);
            }
        }
        rsort($access_roles);
        rsort($publish_roles);
        $caps = tdomf_get_all_caps();
        $can_reg = get_option('users_can_register');
        ?>


          
          <script type="text/javascript">
         //<![CDATA[
          function tdomf_unreg_user() {
            var flag = document.getElementById("tdomf_special_access_anyone").checked;
            var flag2 = document.getElementById("tdomf_user_publish_override").checked;
            <?php 
        if (isset($def_role)) {
            ?>
            document.getElementById("tdomf_access_<?php 
            echo $def_role;
            ?>
").disabled = flag;
            document.getElementById("tdomf_access_<?php 
            echo $def_role;
            ?>
").checked = flag;
            <?php 
        }
        ?>
            <?php 
        foreach ($access_roles as $role) {
            ?>
            document.getElementById("tdomf_access_<?php 
            echo $role;
            ?>
").disabled = flag;
            document.getElementById("tdomf_access_<?php 
            echo $role;
            ?>
").checked = flag;
            <?php 
        }
        ?>
            <?php 
        foreach ($caps as $cap) {
            ?>
            document.getElementById("tdomf_access_caps_<?php 
            echo $cap;
            ?>
").disabled = flag;
            document.getElementById("tdomf_access_caps_<?php 
            echo $cap;
            ?>
").checked = flag;
            <?php 
        }
        ?>
            document.getElementById("tdomf_access_users_list").disabled = flag;
            if(flag) {
               document.getElementById("tdomf_access_users_list").value = "";
            }
            if(!flag2) {
            <?php 
        foreach ($publish_roles as $role) {
            ?>
            document.getElementById("tdomf_access_<?php 
            echo $role;
            ?>
").disabled = flag;
            document.getElementById("tdomf_access_<?php 
            echo $role;
            ?>
").checked = flag;
            <?php 
        }
        ?>
            }
           }
           <?php 
        if (isset($def_role) && $can_reg) {
            ?>
           function tdomf_def_role() {
              var flag = document.getElementById("tdomf_access_<?php 
            echo $def_role;
            ?>
").checked;
              var flag2 = document.getElementById("tdomf_user_publish_override").checked;
              <?php 
            foreach ($access_roles as $role) {
                ?>
               document.getElementById("tdomf_access_<?php 
                echo $role;
                ?>
").checked = flag;
              <?php 
            }
            ?>
                 if(!flag2) {
                 <?php 
            foreach ($publish_roles as $role) {
                ?>
                    document.getElementById("tdomf_access_<?php 
                echo $role;
                ?>
").checked = flag;
                 <?php 
            }
            ?>
                 }
              <?php 
            foreach ($caps as $cap) {
                ?>
             document.getElementById("tdomf_access_caps_<?php 
                echo $cap;
                ?>
").disabled = flag;
             document.getElementById("tdomf_access_caps_<?php 
                echo $cap;
                ?>
").checked = flag;
             <?php 
            }
            ?>
              <?php 
            foreach ($access_roles as $role) {
                ?>
              document.getElementById("tdomf_access_<?php 
                echo $role;
                ?>
").disabled = flag;
              <?php 
            }
            ?>
              if(!flag2) {
              <?php 
            foreach ($publish_roles as $role) {
                ?>
                 document.getElementById("tdomf_access_<?php 
                echo $role;
                ?>
").disabled = flag;
              <?php 
            }
            ?>
              }
             document.getElementById("tdomf_access_users_list").disabled = flag;
            if(flag) {
               document.getElementById("tdomf_access_users_list").value = "";
            }
           }
           <?php 
        }
        ?>
           
           function tdomf_publish_user() {
            var flag = document.getElementById("tdomf_user_publish_override").checked;
            <?php 
        if (isset($def_role) && $can_reg) {
            ?>
            var flag2 = document.getElementById("tdomf_access_<?php 
            echo $def_role;
            ?>
").checked;
            if(!flag2) {
            <?php 
        }
        ?>
                <?php 
        foreach ($publish_roles as $role) {
            ?>
                document.getElementById("tdomf_access_<?php 
            echo $role;
            ?>
").checked = flag;
                document.getElementById("tdomf_access_<?php 
            echo $role;
            ?>
").disabled = flag;
                <?php 
        }
        ?>

            <?php 
        if (isset($def_role) && $can_reg) {
            ?>
            }
            <?php 
        }
        ?>
           }
           //-->
           </script>

           <p>
           
          <label for="tdomf_special_access_anyone">
   <input value="tdomf_special_access_anyone" type="checkbox" name="tdomf_special_access_anyone" id="tdomf_special_access_anyone" <?php 
        if (tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE, $form_id) != false) {
            ?>
checked<?php 
        }
        ?>
 onClick="tdomf_unreg_user();" />
   <?php 
        _e("Unregistered Users (i.e. everyone)", "tdomf");
        ?>
           </label>
           
           <br/>

           <?php 
        $author_edit = tdomf_get_option_form(TDOMF_OPTION_ALLOW_AUTHOR, $form_id);
        ?>
           
           <input type="checkbox" name="tdomf_author_edit" id="tdomf_author_edit" <?php 
        if (!$edit_form) {
            echo 'disabled';
        }
        ?>
 <?php 
        if ($author_edit) {
            echo 'checked';
        }
        ?>
 />
          <label for="tdomf_author_edit">
          <?php 
        _e("Original Submitter (registered users only)", "tdomf");
        ?>
          </label>   
           
          <br/>
          
          <?php 
        $can_publish = tdomf_get_option_form(TDOMF_OPTION_ALLOW_PUBLISH, $form_id);
        ?>
          
          <input type="checkbox" 
                 name="tdomf_user_publish_override" id="tdomf_user_publish_override"
                 <?php 
        if ($can_publish) {
            ?>
 checked <?php 
        }
        ?>
                 onClick="tdomf_publish_user();" />
          <label for="tdomf_user_publish_override">
          <?php 
        _e("Users with rights to publish posts.", "tdomf");
        ?>
          </label>   

           </p>
          
           <div id="options_access_tabs" class="tabs">
              <ul>
                <li><a href="#access_roles"><span><?php 
        _e('Roles', 'tdomf');
        ?>
</span></a></li>
                <li><a href="#access_caps"><span><?php 
        _e('Capabilities', 'tdomf');
        ?>
</span></a></li>
                <li><a href="#access_users"><span><?php 
        _e('Specific Users', 'tdomf');
        ?>
</span></a></li>
              </ul>
           
           <div id="access_roles">
           <p><?php 
        _e('Select roles that can access the form. If you allow free user registration and pick the default role, this means that a user must just be logged in to access the form.', 'tdomf');
        ?>
</p>
           
           <p>
          <?php 
        if (isset($def_role)) {
            ?>
             <label for="tdomf_access_<?php 
            echo $def_role;
            ?>
">
             <input value="tdomf_access_<?php 
            echo $def_role;
            ?>
" type="checkbox"
                    name="tdomf_access_<?php 
            echo $def_role;
            ?>
" id="tdomf_access_<?php 
            echo $def_role;
            ?>
"  
                    <?php 
            if (isset($wp_roles->role_objects[$def_role]->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id])) {
                ?>
 checked <?php 
            }
            ?>
 
                    onClick="tdomf_def_role()" 
                    <?php 
            if (tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE, $form_id) != false) {
                ?>
 checked disabled <?php 
            }
            ?>
 />
             <?php 
            if (function_exists('translate_with_context')) {
                $role_name = translate_with_context($wp_roles->role_names[$def_role]);
            } else {
                $role_name = $wp_roles->role_names[$def_role];
            }
            ?>
             <?php 
            echo $role_name . " " . __("(newly registered users)");
            ?>
             </label><br/>
          <?php 
        }
        ?>

          <?php 
        foreach ($access_roles as $role) {
            ?>
             <label for="tdomf_access_<?php 
            echo $role;
            ?>
">
             <input value="tdomf_access_<?php 
            echo $role;
            ?>
" type="checkbox" 
                    name="tdomf_access_<?php 
            echo $role;
            ?>
" id="tdomf_access_<?php 
            echo $role;
            ?>
" 
                    <?php 
            if (isset($wp_roles->role_objects[$role]->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id])) {
                ?>
 checked <?php 
            }
            ?>
                    <?php 
            if (isset($def_role) && isset($wp_roles->role_objects[$def_role]->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id]) && $can_reg) {
                ?>
 checked disabled <?php 
            }
            ?>
                    <?php 
            if (tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE, $form_id) != false) {
                ?>
 checked disabled <?php 
            }
            ?>
 />
             <?php 
            if (function_exists('translate_with_context')) {
                echo translate_with_context($wp_roles->role_names[$role]);
            } else {
                echo $wp_roles->role_names[$role];
            }
            ?>
             </label><br/>
          <?php 
        }
        ?>
          
          <?php 
        foreach ($publish_roles as $role) {
            ?>
             <label for="tdomf_access_<?php 
            echo $role;
            ?>
">
             <input value="tdomf_access_<?php 
            echo $role;
            ?>
" type="checkbox" 
                    name="tdomf_access_<?php 
            echo $role;
            ?>
" id="tdomf_access_<?php 
            echo $role;
            ?>
"
                    <?php 
            if ($can_publish) {
                ?>
 checked disabled <?php 
            }
            ?>
                    <?php 
            if (isset($wp_roles->role_objects[$role]->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id])) {
                ?>
 checked <?php 
            }
            ?>
                    <?php 
            if (isset($def_role) && isset($wp_roles->role_objects[$def_role]->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id]) && $can_reg) {
                ?>
 checked disabled <?php 
            }
            ?>
                    <?php 
            if (tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE, $form_id) != false) {
                ?>
 checked disabled <?php 
            }
            ?>
 />
             <?php 
            if (function_exists('translate_with_context')) {
                printf(__('%s (can publish posts)', 'tdomf'), translate_with_context($wp_roles->role_names[$role]));
            } else {
                printf(__('%s (can publish posts)', 'tdomf'), $wp_roles->role_names[$role]);
            }
            ?>
             </label><br/>
          <?php 
        }
        ?>
          </p>
          </div> <!-- access_roles -->
           
          <div id="access_caps">
          <p><?php 
        _e('Capabilities are specific access rights. Roles are groupings of capabilities. Individual users can be given individual capabilities outside their assigned Role using external plugins. You can optionally select additional capabilities that give access to the form.', 'tdomf');
        ?>
</p>
          
          <?php 
        $access_caps = tdomf_get_option_form(TDOMF_OPTION_ALLOW_CAPS, $form_id);
        if ($access_caps == false) {
            $access_caps = array();
        }
        ?>
          
          <div id="access_caps_list"><p>
          <?php 
        foreach ($caps as $cap) {
            ?>
             <input value="tdomf_access_caps_<?php 
            echo $cap;
            ?>
" type="checkbox" 
                    name="tdomf_access_caps_<?php 
            echo $cap;
            ?>
" id="tdomf_access_caps_<?php 
            echo $cap;
            ?>
"
                    <?php 
            if (isset($def_role) && isset($wp_roles->role_objects[$def_role]->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id]) && $can_reg) {
                ?>
 checked disabled <?php 
            }
            ?>
                    <?php 
            if (in_array($cap, $access_caps)) {
                ?>
 checked <?php 
            }
            ?>
                    <?php 
            if (tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE, $form_id) != false) {
                ?>
 checked disabled <?php 
            }
            ?>
 />
             <label for="tdomf_access_caps_<?php 
            echo $cap;
            ?>
">
             <?php 
            if (function_exists('translate_with_context')) {
                echo translate_with_context($cap);
            } else {
                echo $cap;
            }
            ?>
             </label><br/>
          <?php 
        }
        ?>
          </p></div> <!-- access_caps_list -->
          
          </div> <!-- access_caps -->
          
          <div id="access_users">
          
          <?php 
        $allow_users = tdomf_get_option_form(TDOMF_OPTION_ALLOW_USERS, $form_id);
        $tdomf_access_users_list = "";
        if (is_array($allow_users)) {
            $tdomf_access_users_list = array();
            foreach ($allow_users as $allow_user) {
                $allow_user = get_userdata($allow_user);
                $tdomf_access_users_list[] = $allow_user->user_login;
            }
            sort($tdomf_access_users_list);
            $tdomf_access_users_list = join(' ', $tdomf_access_users_list);
        }
        ?>
          
          <p><?php 
        _e('You can specify additional specific users who can access the form. Just list their login names seperated by spaces in the box provide', 'tdomf');
        ?>
</p>
          
          <textarea cols="80" rows="3" 
                    name="tdomf_access_users_list" id="tdomf_access_users_list"
                    <?php 
        if (isset($def_role) && isset($wp_roles->role_objects[$def_role]->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id]) && $can_reg) {
            ?>
 checked disabled /></textarea>
                    <?php 
        } else {
            if (tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE, $form_id) != false) {
                ?>
 checked disabled /></textarea> 
                    <?php 
            } else {
                ?>
 /><?php 
                echo $tdomf_access_users_list;
                ?>
</textarea><?php 
            }
        }
        ?>
          
          </div> <!-- access_users -->
          
       </div> <!-- options_access_tabs -->
           
       <p>
       
          <?php 
        $allow_time = tdomf_get_option_form(TDOMF_OPTION_ALLOW_TIME, $form_id);
        if ($allow_time === false || $allow_time < 0) {
            $allow_time = "";
        }
        ?>
       
          <label for="tdomf_time_edit">
          <?php 
        _e('Allow post or page to be edited for ');
        ?>
          <input type="text" name="tdomf_time_edit" id="tdomf_time_edit" size="5" value="<?php 
        echo $allow_time;
        ?>
" <?php 
        if (!$edit_form) {
            ?>
disabled <?php 
        }
        ?>
 />
          <?php 
        _e(' Seconds (1 hour = 3600 seconds) after post is published.');
        ?>
          </label>

       </p>
    
    </div> <!-- form_access -->

    <div id="form_new">
    
    <?php 
        $def_cat = tdomf_get_option_form(TDOMF_DEFAULT_CATEGORY, $form_id);
        ?>
    <p>
       <label for="tdomf_def_cat">
	       <?php 
        _e("Default Category of new submissions", "tdomf");
        ?>
       </label>
	   <SELECT NAME="tdomf_def_cat" id="tdomf_def_cat" <?php 
        if ($use_page) {
            ?>
disabled<?php 
        }
        ?>
 >
	   <?php 
        $cats = get_categories("get=all");
        if (!empty($cats)) {
            foreach ($cats as $c) {
                if ($c->term_id == $def_cat) {
                    echo "<OPTION VALUE=\"{$c->term_id}\" selected>{$c->category_nicename}\n";
                } else {
                    echo "<OPTION VALUE=\"{$c->term_id}\">{$c->category_nicename}\n";
                }
            }
        }
        ?>
        </select>
    </p>
    
	<p>
	<?php 
        _e('You can set submissions from this form that are published/approved to be queued before appearing on the site. Just set the period of time between each post and TDOMF will schedule approved submissions from this form. A value of 0 or -1 disables this option. You can also choose to schedule posts after any post in the system or just TDOMF posts.', "tdomf");
        ?>
	</p>
    
    <?php 
        $tdomf_queue_on_all = tdomf_get_option_form(TDOMF_OPTION_QUEUE_ON_ALL, $form_id);
        ?>
        <input type="checkbox" name="tdomf_queue_on_all" id="tdomf_queue_on_all"  <?php 
        if ($tdomf_queue_on_all) {
            echo "checked";
        }
        ?>
 >
        <label for="tdomf_queue_on_all">
            <?php 
        _e("Queue after all posts (i.e. not just posts submitted to TDOMF)", "tdomf");
        ?>
        </label>
    
    <?php 
        $tdomf_queue_period = intval(tdomf_get_option_form(TDOMF_OPTION_QUEUE_PERIOD, $form_id));
        ?>
	<p>
	<input type="text" name="tdomf_queue_period" id="tdomf_queue_period" size="5" value="<?php 
        echo htmlentities($tdomf_queue_period, ENT_QUOTES, get_bloginfo('charset'));
        ?>
" />
    <?php 
        _e("Seconds (1 day = 86400 seconds)", "tdomf");
        ?>
	</p>
    
    </div> <!-- form_new -->
    
    <div id="form_edit">
    
       <p>
        <?php 
        $edit_restrict_tdomf = tdomf_get_option_form(TDOMF_OPTION_EDIT_RESTRICT_TDOMF, $form_id);
        ?>
        <input type="checkbox" name="tdomf_edit_tdomf_only" id="tdomf_edit_tdomf_only" <?php 
        if ($edit_restrict_tdomf) {
            ?>
checked<?php 
        }
        ?>
 >
        <label for="tdomf_edit_tdomf_only"><?php 
        _e("Restrict editing to posts or pages that were submitted by TDO Mini Forms", "tdomf");
        ?>
</label>
        
        <br/>

        <?php 
        $edit_restrict_cats = tdomf_get_option_form(TDOMF_OPTION_EDIT_RESTRICT_CATS, $form_id);
        if (!is_array($edit_restrict_cats)) {
            $edit_restrict_cats = "";
        } else {
            $edit_restrict_cats = join(",", $edit_restrict_cats);
        }
        ?>
        
                
        <?php 
        $edit_page_form = tdomf_get_option_form(TDOMF_OPTION_EDIT_PAGE_FORM, $form_id);
        ?>
        <input type="checkbox" name="tdomf_edit_page_form" id="tdomf_edit_page_form" <?php 
        if ($edit_page_form) {
            ?>
checked<?php 
        }
        ?>
 >
        <label for="tdomf_edit_tdomf_only"><?php 
        _e("Allow editing of pages (or posts) that contain TDO-Mini-Form forms", "tdomf");
        ?>
</label>
        
        <br/><br/>
        
               
        <label for="tdomf_edit_cats">
        <?php 
        _e("Restrict editing to posts in these categories only:", "tdomf");
        ?>
<br/>
        <small><?php 
        _e("(List category ids seperated by a comma)", "tdomf");
        ?>
<br/></small>
        </label>
        <input type="text" name="tdomf_edit_cats" id="tdomf_edit_cats" size="80" value="<?php 
        echo $edit_restrict_cats;
        ?>
" <?php 
        if ($use_page) {
            ?>
disabled<?php 
        }
        ?>
 />

        <br/><br/>
        
        <?php 
        $ajax_edit = tdomf_get_option_form(TDOMF_OPTION_AJAX_EDIT, $form_id);
        ?>
        <input type="checkbox" name="tdomf_ajax_edit" id="tdomf_ajax_edit" <?php 
        if ($ajax_edit) {
            ?>
checked<?php 
        }
        ?>
 >
        <label for="tdomf_ajax_edit"><?php 
        _e("Inline Editing (requires javascript in browser, will fall back to one of the options below)", "tdomf");
        ?>
</label>
        <br/>
        
        <?php 
        $add_edit_link = tdomf_get_option_form(TDOMF_OPTION_ADD_EDIT_LINK, $form_id);
        if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS) == false && $add_edit_link == 'your_submissions') {
            $add_edit_link = 'none';
        }
        if ($updated_pages == false && $auto_edit_link == 'page') {
            $add_edit_link = 'none';
        }
        ?>
        
        <input type="radio" name="tdomf_add_edit_link" id="tdomf_add_edit_link_none" value="none" <?php 
        if (!$add_edit_link || $add_edit_link == 'none') {
            ?>
checked<?php 
        }
        ?>
 >
        <label for="tdomf_add_edit_link_none">
            <?php 
        _e('Do not add a link to edit form at end of post', 'tdomf');
        ?>
        </label>
        <br/>
        <?php 
        if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) {
            ?>
            <input type="radio" name="tdomf_add_edit_link" id="tdomf_add_edit_link_your_submissions" value="your_submissions" <?php 
            if ($add_edit_link == 'your_submissions') {
                ?>
checked<?php 
            }
            ?>
>
            <label for="tdomf_add_edit_link_your_submissions">
                <?php 
            _e('Add a link to Form on Your Submissions at end of post', 'tdomf');
            ?>
            </label>
            <br/>
        <?php 
        }
        ?>
        <?php 
        if ($updated_pages != false) {
            ?>
            <input type="radio" name="tdomf_add_edit_link" id="tdomf_add_edit_link_page" value="page" <?php 
            if ($add_edit_link == 'page') {
                ?>
checked<?php 
            }
            ?>
>
            <label for="tdomf_add_edit_link_page">
                <?php 
            _e('Add a link to Page created for Form at end of post', 'tdomf');
            ?>
            </label>
            <br/>
        <?php 
        }
        ?>
        <input type="radio" name="tdomf_add_edit_link" id="tdomf_add_edit_link_custom" value="custom" 
            <?php 
        if ($add_edit_link !== false && $add_edit_link != 'none' && $add_edit_link != 'page' && $add_edit_link != 'your_submissions') {
            ?>
checked<?php 
        }
        ?>
>
        <label for="tdomf_add_edit_link_custom">
            <?php 
        _e('Add a link to a Custom URL at the end of post', 'tdomf');
        ?>
        </label>
        <br/>
        <input type="text" name="tdomf_add_edit_link_custom_url" id="tdomf_add_edit_link_custom_url" size="80" 
            <?php 
        if ($add_edit_link !== false && $add_edit_link != 'none' && $add_edit_link != 'page' && $add_edit_link != 'your_submissions') {
            ?>
value="<?php 
            echo $add_edit_link;
            ?>
" <?php 
        } else {
            ?>
value="http://" <?php 
        }
        ?>
/>

            <br/><br/>
        
        <p>
        <?php 
        _e('If your theme supports it, the edit link can be automatically updated to point to a TDOMF form instead of Wordpress\' backend. But TDOMF cannot change the permissions under which it shows. I.e. This edit link will appear according to Wordpress access rules and not the rules you set here.', 'tdomf');
        ?>
        </p>
        
        <?php 
        $auto_edit_link = tdomf_get_option_form(TDOMF_OPTION_AUTO_EDIT_LINK, $form_id);
        if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS) == false && $auto_edit_link == 'your_submissions') {
            $auto_edit_link = 'none';
        }
        if ($updated_pages == false && $auto_edit_link == 'page') {
            $auto_edit_link = 'none';
        }
        ?>
        
        <input type="radio" name="tdomf_auto_edit_link" id="tdomf_auto_edit_link_none" value="none" <?php 
        if (!$auto_edit_link || $auto_edit_link == 'none') {
            ?>
checked<?php 
        }
        ?>
>
        <label for="tdomf_auto_edit_link_none">
            <?php 
        _e('Do not auto-modify \'Edit Post\' link', 'tdomf');
        ?>
        </label>
        <br/>
        <?php 
        if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) {
            ?>
            <input type="radio" name="tdomf_auto_edit_link" id="tdomf_auto_edit_link_your_submissions" value="your_submissions" <?php 
            if ($auto_edit_link == 'your_submissions') {
                ?>
checked<?php 
            }
            ?>
>
            <label for="tdomf_auto_edit_link_your_submissions">
                <?php 
            _e('Auto-modify \'Edit Post\' link (if avaliable in theme) to point to Form on Your Submissions', 'tdomf');
            ?>
            </label>
            <br/>
        <?php 
        }
        ?>
        <?php 
        if ($updated_pages != false) {
            ?>
            <input type="radio" name="tdomf_auto_edit_link" id="tdomf_auto_edit_link_page" value="page" <?php 
            if ($auto_edit_link == 'page') {
                ?>
checked<?php 
            }
            ?>
>
            <label for="tdomf_auto_edit_link_page">
                <?php 
            _e('Auto-modify \'Edit Post\' link (if avaliable in theme) to point to Page created for Form', 'tdomf');
            ?>
            </label>
            <br/>
        <?php 
        }
        ?>
        <input type="radio" name="tdomf_auto_edit_link" id="tdomf_auto_edit_link_custom" value="custom" 
            <?php 
        if ($auto_edit_link !== false && $auto_edit_link != 'none' && $auto_edit_link != 'page' && $auto_edit_link != 'your_submissions') {
            ?>
checked<?php 
        }
        ?>
>
        <label for="tdomf_auto_edit_link_custom">
            <?php 
        _e('Auto-modify \'Edit Post\' link (if avaliable in theme) to point to a custom URL', 'tdomf');
        ?>
        </label>
        <br/>
        <input type="text" name="tdomf_auto_edit_link_custom_url" id="tdomf_auto_edit_link_custom_url" size="80"
            <?php 
        if ($auto_edit_link !== false && $auto_edit_link != 'none' && $auto_edit_link != 'page' && $auto_edit_link != 'your_submissions') {
            ?>
value="<?php 
            echo $auto_edit_link;
            ?>
" <?php 
        } else {
            ?>
value="http://" <?php 
        }
        ?>
/>

        <br/>
        
       </p>
    
    </div> <!-- form_edit -->
    
    <div id="form_moderation">

    <?php 
        $on_mod = tdomf_get_option_form(TDOMF_OPTION_MODERATION, $form_id);
        ?>
	
    <p>
        <input type="checkbox" name="tdomf_moderation" id="tdomf_moderation"  	<?php 
        if ($on_mod) {
            echo "checked";
        }
        ?>
 >
        <label for="tdomf_moderation">
            <?php 
        _e("Enable Moderation", "tdomf");
        ?>
        </label>
    </p>
    
    <p>
    
    <?php 
        $user_publish_auto = tdomf_get_option_form(TDOMF_OPTION_PUBLISH_NO_MOD, $form_id);
        ?>
    <input type="checkbox" name="tdomf_user_publish_auto" id="tdomf_user_publish_auto" <?php 
        if ($user_publish_auto) {
            ?>
 checked <?php 
        }
        ?>
 />
    <label for="tdomf_user_publish_auto">
        <?php 
        _e("Users with publish rights will have their posts automatically published", "tdomf");
        ?>
<br/>
    </label>
    
    <?php 
        $redirect = tdomf_get_option_form(TDOMF_OPTION_REDIRECT, $form_id);
        ?>
    <input type="checkbox" name="tdomf_redirect" id="tdomf_redirect" <?php 
        if ($redirect) {
            echo "checked";
        }
        ?>
 >
    <label for="tdomf_redirect">
        <?php 
        _e("If automatically published, redirect to Published Post", "tdomf");
        ?>
<br/>
    </label>
    
    <?php 
        $mod_email_on_pub = tdomf_get_option_form(TDOMF_OPTION_MOD_EMAIL_ON_PUB, $form_id);
        ?>
    <input type="checkbox" name="tdomf_mod_email_on_pub" id="tdomf_mod_email_on_pub" <?php 
        if ($mod_email_on_pub) {
            echo "checked";
        }
        ?>
 >
    <label for="tdomf_mod_email_on_pub">
        <?php 
        _e("Send Moderation Email even for automatically Published Post", "tdomf");
        ?>
<br/>
    </label>
    
	</p>

    <p>
    <b><?php 
        _e('Send Moderation Email Notification to:', 'tdomf');
        ?>
</b><br/><br/>

	 <?php 
        $notify_roles = tdomf_get_option_form(TDOMF_NOTIFY_ROLES, $form_id);
        if ($notify_roles != false) {
            $notify_roles = explode(';', $notify_roles);
        }
        $admin_emails = tdomf_get_option_form(TDOMF_OPTION_ADMIN_EMAILS, $form_id);
        ?>

	 <?php 
        foreach ($roles as $role) {
            if (isset($role->capabilities['edit_others_posts']) && isset($role->capabilities['publish_posts'])) {
                ?>
		     <input value="tdomf_notify_<?php 
                echo $role->name;
                ?>
" type="checkbox" name="tdomf_notify_<?php 
                echo $role->name;
                ?>
" id="tdomf_notify_<?php 
                echo $role->name;
                ?>
" <?php 
                if ($notify_roles != false && in_array($role->name, $notify_roles)) {
                    ?>
checked<?php 
                }
                ?>
 />
             <label for="tdomf_notify_<?php 
                echo $role->name;
                ?>
">
          <?php 
                if (function_exists('translate_with_context')) {
                    echo translate_with_context($wp_roles->role_names[$role->name]);
                } else {
                    echo $wp_roles->role_names[$role->name];
                }
                ?>
          <br/>
		     </label>
		     <?php 
            }
        }
        ?>
         <br/>

    <?php 
        _e("Specific Email Addresses (seperate with spaces)", "tdomf");
        ?>
</b>
	<input type="text" name="tdomf_admin_emails" id="tdomf_admin_emails" size="80" value="<?php 
        if ($admin_emails) {
            echo htmlentities(stripslashes($admin_emails), ENT_QUOTES, get_bloginfo('charset'));
        }
        ?>
" />
         
	 </p>

    
    </div> <!-- form_moderation -->
    
    <div id="form_throttling">

	<p>
	<?php 
        _e('You can add rules to throttle input based on registered user accounts and/or IP addresses. Make sure you save any form configuration changes to your form before adding or removing any throttling rules.', "tdomf");
        ?>
	</p>
   
    <?php 
        printf(__("<table border=\"0\">\n                     <tr><td>Only %s submissions/contributions per</td>\n                     <td>%s</td>\n                     <td>%s(optionally) per %s Seconds (1 hour = 3600 seconds)</td>\n                     <td>%s</td>\n                     </tr>\n                     </table>", "tdomf"), '<input type="text" name="tdomf_throttle_rule_count" id="tdomf_throttle_rule_count" size="3" value="10" /> 
                      <select id="tdomf_throttle_rule_sub_type" name="tdomf_throttle_rule_sub_type" >
                      <option value="unapproved" selected />' . __("unapproved", "tdomf") . '
                      <option value="any" />' . __("any", "tdomf") . '
                      </select>', '<input type="radio" name="tdomf_throttle_rule_user_type" id="tdomf_throttle_rule_user_type" value="user" />' . __("registered user", "tdomf") . '<br/>
                      <input type="radio" name="tdomf_throttle_rule_user_type" id="tdomf_throttle_rule_user_type" value="ip" checked />' . __("IP", "tdomf"), '<input type="checkbox" name="tdomf_throttle_rule_opt1" id="tdomf_throttle_rule_opt1" checked >', '<input type="text" name="tdomf_throttle_rule_time" id="tdomf_throttle_rule_time" size="3" value="3600" />', '<input type="submit" name="tdomf_add_throttle_rule" id="tdomf_add_throttle_rule" value="' . __("Add", "tdomf") . ' &raquo;">');
        ?>

    <?php 
        $throttle_rules = tdomf_get_option_form(TDOMF_OPTION_THROTTLE_RULES, $form_id);
        if (is_array($throttle_rules) && !empty($throttle_rules)) {
            ?>
    
    <p><b><?php 
            _e("Current Throttle Rules", "tdomf");
            ?>
</b>
    <ul>
    <?php 
            foreach ($throttle_rules as $id => $throttle_rule) {
                $option_string = "";
                if ($throttle_rule['opt1']) {
                    $option_string = sprintf(__("per %s Seconds", "tdomf"), $throttle_rule['time']);
                }
                ?>
        <li>
        <?php 
                printf(__("(%d) Only %d %s submissions/contributions per %s %s", "tdomf"), $id, $throttle_rule['count'], $throttle_rule['sub_type'], $throttle_rule['type'], $option_string);
                ?>
        <input type="submit" name="tdomf_remove_throttle_rule_<?php 
                echo $id;
                ?>
" id="tdomf_remove_throttle_rule_<?php 
                echo $id;
                ?>
" value="<?php 
                _e("Remove", "tdomf");
                ?>
 &raquo;">
        </li>
    <?php 
            }
            ?>
    </ul>
    </p>
    
          <?php 
        } else {
            ?>
              <p><b><?php 
            _e("No Throttling Rules currently set.", "tdomf");
            ?>
</b></p>
          <?php 
        }
        ?>
        
    </div> <!-- form_throttling -->
    
    <div id="form_spam">
    
    <?php 
        tdomf_show_spam_options($form_id);
        ?>
    
    </div> <!-- form_spam -->
    
    <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");
        ?>
 &raquo;" />
	</form>
    </td>

    <td>
    <form method="post" action="admin.php?page=tdomf_show_form_options_menu&form=<?php 
        echo $form_id;
        ?>
">
    <input type="submit" name="refresh" value="Refresh" />
    </form>
    </td>

    </tr></table>

    </div> <!-- wrap -->
    
  <?php 
    }
}