Index: admin/tdomf-edit-form.php
===================================================================
--- admin/tdomf-edit-form.php	(revision 169181)
+++ admin/tdomf-edit-form.php	(working copy)
@@ -1,31 +1,32 @@
-<?php
-if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('TDOMF: You are not allowed to call this page directly.'); }
-
-/////////////////////////////////////////////////////////////
-// Code for the tdomf edit form menu (with drag and drop!) //
-/////////////////////////////////////////////////////////////
-
-// Hacked the drag and drop from the widget admin menu in WP2.2!
-
-// Only load edit scripts as needed!
-//
-function tdomf_load_edit_form_scripts() {
-  // Need these scripts for drag and drop but only on this page, not every page!
-  wp_enqueue_script( 'interface' );
-}
-add_action("load-".sanitize_title(__('TDO Mini Forms', 'tdomf'))."_page_tdomf_show_form_menu","tdomf_load_edit_form_scripts");
-
-
-// Stuff to do in the header of the page
-//
-function tdomf_form_admin_head() {
-   global $tdomf_form_widgets, $tdomf_form_widgets_control;
-   $form_id = tdomf_edit_form_form_id();
-   $mode = tdomf_generate_default_form_mode($form_id);
-   do_action('tdomf_control_form_start',$form_id,$mode);
-   $widgets = tdomf_filter_widgets($mode,$tdomf_form_widgets);
-   $widgets_control = tdomf_filter_widgets($mode,$tdomf_form_widgets_control);
-   if(preg_match('/tdomf_show_form_menu/',$_SERVER[REQUEST_URI])) {
+<<<<<<< .mine
+<?php
+if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('TDOMF: You are not allowed to call this page directly.'); }
+
+/////////////////////////////////////////////////////////////
+// Code for the tdomf edit form menu (with drag and drop!) //
+/////////////////////////////////////////////////////////////
+
+// Hacked the drag and drop from the widget admin menu in WP2.2!
+
+// Only load edit scripts as needed!
+//
+function tdomf_load_edit_form_scripts() {
+  // Need these scripts for drag and drop but only on this page, not every page!
+  wp_enqueue_script( 'interface' );
+}
+add_action("load-".sanitize_title(__('TDO Mini Forms', 'tdomf'))."_page_tdomf_show_form_menu","tdomf_load_edit_form_scripts");
+
+
+// Stuff to do in the header of the page
+//
+function tdomf_form_admin_head() {
+   global $tdomf_form_widgets, $tdomf_form_widgets_control;
+   $form_id = tdomf_edit_form_form_id();
+   $mode = tdomf_generate_default_form_mode($form_id);
+   do_action('tdomf_control_form_start',$form_id,$mode);
+   $widgets = tdomf_filter_widgets($mode,$tdomf_form_widgets);
+   $widgets_control = tdomf_filter_widgets($mode,$tdomf_form_widgets_control);
+   if(preg_match('/tdomf_show_form_menu/',$_SERVER['REQUEST_URI'])) {
 ?>
    <?php if(tdomf_wp23() && function_exists('wp_admin_css')) {
             wp_admin_css( 'css/widgets' ); 
@@ -620,3 +621,4 @@
 }
 
 ?>
+>>>>>>> .r169181
\ No newline at end of file
Index: admin/tdomf-edit-post-panel.php
===================================================================
--- admin/tdomf-edit-post-panel.php	(revision 169181)
+++ admin/tdomf-edit-post-panel.php	(working copy)
@@ -1,38 +1,38 @@
-<?php
-if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('TDOMF: You are not allowed to call this page directly.'); }
-
-////////////////////////////////////////////////////
-// Code for the tdomf edit panel on the post page //
-////////////////////////////////////////////////////
-
-# @TODO: nonce support
-
-// Grab a list of user ids of all users, to use in the drop-down menu
-//
-function tdomf_get_all_users() {
-    global $wpdb;
-    $query = "SELECT * ";
-    $query .= "FROM $wpdb->users ";
-    $query .= "ORDER BY ID DESC";
-    return $wpdb->get_results( $query );
-}
-
-// Grab a list of user ids of all users, to use in the drop-down menu
-//
-function tdomf_get_all_users_count() {
-    global $wpdb;
-    $query = "SELECT count(ID) ";
-    $query .= "FROM $wpdb->users ";
-    $query .= "ORDER BY ID DESC";
-    return intval($wpdb->get_var( $query ));
-}
-
-// Add the sidebar panel
-//
+<?php
+if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('TDOMF: You are not allowed to call this page directly.'); }
+
+////////////////////////////////////////////////////
+// Code for the tdomf edit panel on the post page //
+////////////////////////////////////////////////////
+
+# @TODO: nonce support
+
+// Grab a list of user ids of all users, to use in the drop-down menu
+//
+function tdomf_get_all_users() {
+    global $wpdb;
+    $query = "SELECT * ";
+    $query .= "FROM $wpdb->users ";
+    $query .= "ORDER BY ID DESC";
+    return $wpdb->get_results( $query );
+}
+
+// Grab a list of user ids of all users, to use in the drop-down menu
+//
+function tdomf_get_all_users_count() {
+    global $wpdb;
+    $query = "SELECT count(ID) ";
+    $query .= "FROM $wpdb->users ";
+    $query .= "ORDER BY ID DESC";
+    return intval($wpdb->get_var( $query ));
+}
+
+// Add the sidebar panel
+//
 function tdomf_edit_post_panel_admin_head() {
   global $post;
   // don't show on new post/page
-  if($post->ID > 0) {
+  if(is_object($post) && $post->ID > 0) {
       $edit_count = tdomf_get_edits(array('post_id' => $post->ID, 'count' => true));
       // Wordpress 2.5 introduced add_meta_box
       if(function_exists('add_meta_box')) {
@@ -143,286 +143,286 @@
 }
 
 
-//
-// Show the Edit Post Panel
-//
-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; ?><?php if($user->ID == get_option(TDOMF_DEFAULT_AUTHOR)) { _e("(Default User)","tdomf"); } ?><?php 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 &raquo;","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
-}
-}
-
-// Add a handler for the AJAX
-//
-add_action('wp_ajax_tdomf_edit_post', 'tdomf_save_post');
-//
-// Handler for AJAX
-//
-function tdomf_save_post() {
-    $post_id = (int) $_POST['post_ID'];
-    
-    if($_POST['tdomf_locked'] == "false") {
-        delete_post_meta($post_id, TDOMF_KEY_LOCK);
-        tdomf_log_message("Post $post_id is now set to unlocked. Post can be edited by valid TDO Mini Form forms.");
-    } else {
-        tdomf_log_message("Post $post_id is now set to locked. Post cannot be edited by any TDO Mini Form forms.");
-        delete_post_meta($post_id, TDOMF_KEY_LOCK);
-        add_post_meta($post_id, TDOMF_KEY_LOCK, true, true);
-    }
-    
-    if($_POST['tdomf_flag'] == "false") {
-      delete_post_meta($post_id, TDOMF_KEY_FLAG);
-      tdomf_log_message("Removed post $post_id from TDOMF");
-      die("alert('".sprintf(__('TDOMF: Post %d is no longer managed by TDOMF!','tdomf'),$post_id)."')");
-    } else {
-      add_post_meta($post_id, TDOMF_KEY_FLAG, true, true);
-      if(isset($_POST["tdomf_user"])) {
-          $user_id = $_POST["tdomf_user"];
-          if(!empty($user_id) && !is_numeric($user_id)) {
-              if(($userdata = get_userdatabylogin($user_id)) != false) {
-                  $user_id = $userdata->ID;
-              } else { 
-                  die("alert('".sprintf(__("TDOMF: The user %s is not a valid user and cannot be used for Submitter","tdomf"),$user_id)."')");
-              }
-          }
-         delete_post_meta($post_id, TDOMF_KEY_USER_ID);
-         add_post_meta($post_id, TDOMF_KEY_USER_ID, $user_id, true);
-         tdomf_log_message("Submitter info for post $post_id added");
-         die("alert('".sprintf(__('TDOMF: TDO Mini Forms info for post %d updated','tdomf'),$post_id)."')");
-      } else {
-        // do this so that we *know* that submitter user is not used
-        delete_post_meta($post_id, TDOMF_KEY_USER_ID);
-        $name = $_POST["tdomf_name"];
-        delete_post_meta($post_id, TDOMF_KEY_NAME);
-        add_post_meta($post_id, TDOMF_KEY_NAME, $name, true);
-        $email = $_POST["tdomf_email"];
-        delete_post_meta($post_id, TDOMF_KEY_EMAIL);
-        add_post_meta($post_id, TDOMF_KEY_EMAIL, $email, true);
-        $web = $_POST["tdomf_web"];
-        delete_post_meta($post_id, TDOMF_KEY_WEB);
-        add_post_meta($post_id, TDOMF_KEY_WEB, $web, true);
-        tdomf_log_message("Submitter info for post $post_id added");
-        die("alert('".sprintf(__('TDOMF: TDO Mini Forms info for post %d updated','tdomf'),$post_id)."')");
-      }
-  }
-  tdomf_log_message("Error captured in EditPostPanel:tdomf_save_post");
-  die("alert('<?php _e('TDOMF: Error! Incomplete information provided!','tdomf'); ?>')");
-}
-
-?>
+//
+// Show the Edit Post Panel
+//
+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; ?><?php if($user->ID == get_option(TDOMF_DEFAULT_AUTHOR)) { _e("(Default User)","tdomf"); } ?><?php 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 &raquo;","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
+}
+}
+
+// Add a handler for the AJAX
+//
+add_action('wp_ajax_tdomf_edit_post', 'tdomf_save_post');
+//
+// Handler for AJAX
+//
+function tdomf_save_post() {
+    $post_id = (int) $_POST['post_ID'];
+    
+    if($_POST['tdomf_locked'] == "false") {
+        delete_post_meta($post_id, TDOMF_KEY_LOCK);
+        tdomf_log_message("Post $post_id is now set to unlocked. Post can be edited by valid TDO Mini Form forms.");
+    } else {
+        tdomf_log_message("Post $post_id is now set to locked. Post cannot be edited by any TDO Mini Form forms.");
+        delete_post_meta($post_id, TDOMF_KEY_LOCK);
+        add_post_meta($post_id, TDOMF_KEY_LOCK, true, true);
+    }
+    
+    if($_POST['tdomf_flag'] == "false") {
+      delete_post_meta($post_id, TDOMF_KEY_FLAG);
+      tdomf_log_message("Removed post $post_id from TDOMF");
+      die("alert('".sprintf(__('TDOMF: Post %d is no longer managed by TDOMF!','tdomf'),$post_id)."')");
+    } else {
+      add_post_meta($post_id, TDOMF_KEY_FLAG, true, true);
+      if(isset($_POST["tdomf_user"])) {
+          $user_id = $_POST["tdomf_user"];
+          if(!empty($user_id) && !is_numeric($user_id)) {
+              if(($userdata = get_userdatabylogin($user_id)) != false) {
+                  $user_id = $userdata->ID;
+              } else { 
+                  die("alert('".sprintf(__("TDOMF: The user %s is not a valid user and cannot be used for Submitter","tdomf"),$user_id)."')");
+              }
+          }
+         delete_post_meta($post_id, TDOMF_KEY_USER_ID);
+         add_post_meta($post_id, TDOMF_KEY_USER_ID, $user_id, true);
+         tdomf_log_message("Submitter info for post $post_id added");
+         die("alert('".sprintf(__('TDOMF: TDO Mini Forms info for post %d updated','tdomf'),$post_id)."')");
+      } else {
+        // do this so that we *know* that submitter user is not used
+        delete_post_meta($post_id, TDOMF_KEY_USER_ID);
+        $name = $_POST["tdomf_name"];
+        delete_post_meta($post_id, TDOMF_KEY_NAME);
+        add_post_meta($post_id, TDOMF_KEY_NAME, $name, true);
+        $email = $_POST["tdomf_email"];
+        delete_post_meta($post_id, TDOMF_KEY_EMAIL);
+        add_post_meta($post_id, TDOMF_KEY_EMAIL, $email, true);
+        $web = $_POST["tdomf_web"];
+        delete_post_meta($post_id, TDOMF_KEY_WEB);
+        add_post_meta($post_id, TDOMF_KEY_WEB, $web, true);
+        tdomf_log_message("Submitter info for post $post_id added");
+        die("alert('".sprintf(__('TDOMF: TDO Mini Forms info for post %d updated','tdomf'),$post_id)."')");
+      }
+  }
+  tdomf_log_message("Error captured in EditPostPanel:tdomf_save_post");
+  die("alert('<?php _e('TDOMF: Error! Incomplete information provided!','tdomf'); ?>')");
+}
+
+?>
Index: admin/tdomf-form-options.php
===================================================================
--- admin/tdomf-form-options.php	(revision 169181)
+++ admin/tdomf-form-options.php	(working copy)
@@ -1,1585 +1,1585 @@
-<?php
-if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('TDOMF: You are not allowed to call this page directly.'); }
-
-/*define('SCRIPT_DEBUG', true);*/
-
-function tdomf_load_form_options_admin_scripts() {
-    /* for tabs */
-    wp_enqueue_script( 'jquery-ui-tabs' );
-}
-add_action("load-".sanitize_title(__('TDO Mini Forms', 'tdomf'))."_page_tdomf_show_form_options_menu","tdomf_load_form_options_admin_scripts");
-
-function tdomf_form_options_admin_head() {
-    global $wp_version;
-    /* add style options and start tabs for options page */
-    if(preg_match('/tdomf_show_form_options_menu/',$_SERVER[REQUEST_URI])) { ?>
-           
-           <style>
-            .ui-tabs-nav {
-                /*resets*/margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none;
-                float: left;
-                position: relative;
-                z-index: 1;
-                border-right: 1px solid #d3d3d3;
-                bottom: -1px;
-            }
-            .ui-tabs-nav li {
-                /*resets*/margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none;
-                float: left;
-                border: 1px solid #d3d3d3;
-                border-right: none;
-            }
-            .ui-tabs-nav li a {
-                /*resets*/margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none;
-                float: left;
-                font-weight: bold;
-                text-decoration: none;
-                padding: .5em 1.7em;
-                color: #555555;
-                background: #e6e6e6;
-            }
-            .ui-tabs-nav li a:hover {
-                background: #dadada;
-                color: #212121;
-            }
-            .ui-tabs-nav li.ui-tabs-selected {
-                border-bottom-color: #ffffff;
-            }
-            .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs-nav li.ui-tabs-selected a:hover {
-                background: #ffffff;
-                color: #222222;
-            }
-            .ui-tabs-panel {
-                /*resets*/margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none;
-                clear:left;
-                border: 1px solid #d3d3d3;
-                background: #ffffff;
-                color: #222222;
-                padding: 1.5em 1.7em;	
-            }
-            .ui-tabs-hide {
-                display: none;
-            }
-            .ui-tabs-nav li.ui-tabs-disabled a, .ui-tabs-nav li.ui-tabs-disabled a:hover, li.ui-state-disabled {
-                color: grey;
-                background: lightgrey;
-                text-decoration:line-through;
-            }
-            #access_caps_list {
-             overflow: scroll;
-             height: 200px;
-            }
-            
-            </style>
-           
-           <script>
-           jQuery(document).ready(function(){
-               <?php if(version_compare($wp_version,"2.8-beta2",">=")) { ?>
-                   jQuery("#form_options_tabs").tabs();
-                   jQuery("#options_access_tabs").tabs();
-               <?php } else { ?>
-                   jQuery("#form_options_tabs > ul").tabs();
-                   jQuery("#options_access_tabs > ul").tabs();
-               <?php } ?>
-           });
-           </script>
-           
-    <?php }
-}
-add_action( 'admin_head', 'tdomf_form_options_admin_head' );
-
-  /**
-   * get an array with all capabilities
-   * copied from role-manager 2 plugin
-   */
-function tdomf_get_all_caps() {
-    global $wp_roles;
-    
-    // Get Role List
-    foreach($wp_roles->role_objects as $key => $role) {
-      foreach($role->capabilities as $cap => $grant) {
-        $capnames[$cap] = $cap;
-        //$this->debug('grant', ($role->capabilities));
-      }
-    }
-    
-    $capnames = apply_filters('capabilities_list', $capnames);
-    if(!is_array($capnames)) $capnames = array();
-    $capnames = array_unique($capnames);
-    sort($capnames);
-
-    //Filter out the level_x caps, they're obsolete
-    $capnames = array_diff($capnames, array('level_0', 'level_1', 'level_2', 'level_3', 'level_4', 'level_5',
-        'level_6', 'level_7', 'level_8', 'level_9', 'level_10'));
-    
-    //Filter out roles
-      foreach ($wp_roles->get_names() as $role) {
-        $key = array_search($role, $capnames);
-        if ($key !== false && $key !== null) { //array_search() returns null if not found in 4.1
-          unset($capnames[$key]);
-        }
-      }
-      
-      // this cap is used seperately 
-      unset($capnames['publish_post']);
-      
-      // filter out tdomf caps that were added
-      foreach($capnames as $key => $cap) {
-          if(substr($cap,TDOMF_CAPABILITY_CAN_SEE_FORM,strlen(TDOMF_CAPABILITY_CAN_SEE_FORM)) == TDOMF_CAPABILITY_CAN_SEE_FORM) {
-              unset($capnames[$key]);
-          }
-      }
-      
-    return $capnames;
-  }
-
-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\">
-                     <tr><td>Only %s submissions/contributions per</td>
-                     <td>%s</td>
-                     <td>%s(optionally) per %s Seconds (1 hour = 3600 seconds)</td>
-                     <td>%s</td>
-                     </tr>
-                     </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 }
-}
-
-function tdomf_forms_top_toolbar($form_id_in=false, $current='tdomf_show_form_options_menu') {
-    $form_ids = tdomf_get_form_ids();
-    $pages = tdomf_get_option_form(TDOMF_OPTION_CREATEDPAGES,$form_id_in);
-    if(tdomf_wp23()) { ?>
-        <div class="wrap">
-    
-    <?php if(!empty($form_ids)) {
-            foreach($form_ids as $form_id) { ?>
-              <?php if($form_id->form_id == $form_id_in) { ?>
-                <b>
-              <?php } else { ?>
-                <a href="admin.php?page=tdomf_show_form_options_menu&form=<?php echo $form_id->form_id; ?>">
-              <?php } ?>
-              <?php printf(__("Form %d","tdomf"),$form_id->form_id); ?><?php if($form_id->form_id == $form_id_in) { ?></b><?php } else {?></a><?php } ?>
-                 |
-            <?php }
-          }
-    ?>
-    
-    <?php if(function_exists('wp_nonce_url')) { ?>
-   <a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_form_options_menu&new", 'tdomf-new-form'); ?>">
-          <?php _e("New Form &raquo;","tdomf"); ?></a>
-    <?php } else { ?>
-      <a href="admin.php?page=tdomf_show_form_options_menu&new"><?php _e("New Form &raquo;","tdomf"); ?></a>
-    <?php } ?>
-    </div> <!-- wrap -->
-
-    <div class="wrap">
-    <?php if(function_exists('wp_nonce_url')) { ?>
-       <a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_form_options_menu&delete=$form_id", 'tdomf-delete-form-'.$form_id); ?>">
-          <?php _e("Delete","tdomf"); ?></a> |
-       <a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_form_options_menu&copy=$form_id&form=$form_id", 'tdomf-copy-form-'.$form_id); ?>">
-          <?php _e("Copy","tdomf"); ?></a> | 
-    <?php } else { ?>
-       <a href="admin.php?page=tdomf_show_form_options_menu&delete=<?php echo $form_id; ?>"><?php _e("Delete","tdomf"); ?></a> |
-       <a href="admin.php?page=tdomf_show_form_options_menu&copy=<?php echo $form_id; ?>"><?php _e("Copy","tdomf"); ?></a> | 
-    <?php } ?>
-    <?php if($pages != false) { ?>
-      <a href="<?php echo get_permalink($pages[0]); ?>" title="<?php _e("Live on your blog!","tdomf"); ?>" ><?php _e("View &raquo;","tdomf"); ?></a> |
-    <?php } ?>
-    <?php if(tdomf_get_option_form(TDOMF_OPTION_INCLUDED_YOUR_SUBMISSIONS,$form_id) && get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) { ?>
-        <?php if(current_user_can('edit_users')) { ?>
-                <a href="users.php?page=tdomf_your_submissions#tdomf_form<?php echo $form_id; ?>" title="<?php _e("Included on the 'Your Submissions' page!",'tdomf'); ?>" >
-        <?php } else { ?>
-                <a href="profile.php?page=tdomf_your_submissions#tdomf_form<?php echo $form_id; ?>" title="<?php _e("Included on the 'Your Submissions' page!",'tdomf'); ?>" >
-          <?php } ?>
-      <?php _e("View &raquo;","tdomf"); ?></a>
-    <?php } ?>
-    </div> <!-- wrap -->
-    
-    <?php 
-    } else if(tdomf_wp27()) { /* do nothing */
-    } else if(tdomf_wp25()) { /* do nothing */ }
-}
-
-function tdomf_forms_under_title_toolbar($form_id_in=false, $current='tdomf_show_form_options_menu') {
-    $form_ids = tdomf_get_form_ids();
-    $pages = tdomf_get_option_form(TDOMF_OPTION_CREATEDPAGES,$form_id_in);
-    if(tdomf_wp23()) { /* do nothing */
-    } else if(tdomf_wp27()) { ?>
-
-        <ul class="subsubsub"> 
-            <li> <a <?php if($current == 'tdomf_show_form_options_menu') { ?>class="current" <?php } ?>href="admin.php?page=tdomf_show_form_options_menu&form=<?php echo $form_id_in; ?>"><?php printf(__("Options","tdomf"),$form_id_in); ?></a> |</li>
-            <li> <a <?php if($current == 'tdomf_show_form_menu') { ?>class="current" <?php } ?>href="admin.php?page=tdomf_show_form_menu&form=<?php echo $form_id_in; ?>"><?php printf(__("Create","tdomf"),$form_id_in); ?></a> |</li>
-            <li> <a <?php if($current == 'tdomf_show_form_hacker' && !isset($_REQUEST['text'])) { ?>class="current" <?php } ?>href="admin.php?page=tdomf_show_form_hacker&form=<?php echo $form_id_in; ?>"><?php printf(__("Hack","tdomf"),$form_id_in); ?></a> |</li>
-            <li> <a <?php if($current == 'tdomf_show_form_hacker' &&  isset($_REQUEST['text'])) { ?>class="current" <?php } ?>href="admin.php?page=tdomf_show_form_hacker&text&form=<?php echo $form_id_in; ?>"><?php printf(__("Messages","tdomf"),$form_id_in); ?></a> |</li>
-            <li> <a <?php if($current == 'tdomf_show_form_export_menu') { ?>class="current" <?php } ?>href="admin.php?page=tdomf_show_form_export_menu&form=<?php echo $form_id_in; ?>"><?php printf(__("Export","tdomf"),$form_id_in); ?></a> |</li>
-            <?php if($pages != false && is_array($pages)) { ?>          
-                <li><a href="<?php echo get_permalink($pages[0]); ?>" title="<?php echo htmlentities(_e("Live on your blog!","tdomf"),ENT_QUOTES); ?>" ><?php _e("View Page &raquo;","tdomf"); ?></a> |</li>
-            <?php } ?>
-            <?php if(tdomf_get_option_form(TDOMF_OPTION_INCLUDED_YOUR_SUBMISSIONS,$form_id_in) && get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) { ?>
-                <li><a href="users.php?page=tdomf_your_submissions#tdomf_form<?php echo $form_id_in; ?>" title="<?php _e("Included on the 'Your Submissions' page!",'tdomf'); ?>" >
-                <?php _e("View on 'Your Submissions' &raquo;","tdomf"); ?></a> |</li>
-            <?php } ?>
-        </ul> 
-          
-      <div class="tablenav">
-      
-          <div class="alignleft">
-            <a class="button" title="<?php echo htmlentities(__('Create a new form','tdomf'),ENT_QUOTES); ?>" href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_form_options_menu&new", 'tdomf-new-form'); ?>">
-            <?php _e("New","tdomf"); ?></a>
-    
-            <a class="button" title="<?php echo htmlentities(__('Delete this form','tdomf'),ENT_QUOTES); ?>" href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_form_options_menu&delete=$form_id_in", 'tdomf-delete-form-'.$form_id_in); ?>">
-            <?php _e("Delete","tdomf"); ?></a>
-       
-            <a class="button" title="<?php echo htmlentities(__('Make a copy of this form','tdomf'),ENT_QUOTES); ?>" href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_form_options_menu&copy=$form_id_in&form=$form_id_in", 'tdomf-copy-form-'.$form_id_in); ?>">
-            <?php _e("Copy","tdomf"); ?></a>
-          </div> <!-- alignleft -->
-      
-          <?php if(!empty($form_ids)) { ?>
-          
-              <div class="alignright actions">
-                <div class="tablenav-pages"><span class="displaying-num"><?php _e("Forms:",'tdomf'); ?></span>
-                    <?php foreach($form_ids as $form_id) { ?>
-                        <?php if($form_id->form_id == $form_id_in) { ?>
-                            <span class='page-numbers current'><?php printf($form_id_in); ?></span> 
-                        <?php } else { $form_name = tdomf_get_option_form(TDOMF_OPTION_NAME,$form_id->form_id); ?>
-                            <a class='page-numbers' title='<?php echo htmlentities($form_name,ENT_QUOTES); ?>' href="admin.php?page=<?php echo $current; ?>&form=<?php echo $form_id->form_id; ?>">
-                            <?php printf($form_id->form_id); ?></a>
-                        <?php } ?>
-                    <?php } ?>
-                </div> <!-- alignleft actions -->
-          <?php } ?>      
-     </div> <!-- tablenav -->
-      
-         
-     </div> <!-- wrap -->
-     <div class="wrap">
-     
-    <?php } else if(tdomf_wp25()) { ?>
-        
-    <ul class="subsubsub">
-       <?php if(!empty($form_ids)) {
-            foreach($form_ids as $form_id) { ?>
-                <li><a href="admin.php?page=tdomf_show_form_options_menu&form=<?php echo $form_id->form_id; ?>"<?php if($form_id->form_id == $form_id_in) { ?> class="current" <?php } ?>>
-                <?php printf(__("Form %d","tdomf"),$form_id->form_id); ?></a> |</li>
-            <?php }
-          } ?>
-        <?php if(function_exists('wp_nonce_url')) { ?>
-        <li><a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_form_options_menu&new", 'tdomf-new-form'); ?>">
-          <?php _e("New Form &raquo;","tdomf"); ?></a></li>
-    <?php } else { ?>
-      <li><a href="admin.php?page=tdomf_show_form_options_menu&new"><?php _e("New Form &raquo;","tdomf"); ?></a></li>
-    <?php } ?>
-   </ul>
-    
-    <ul class="subsubsub">
-    <?php if(function_exists('wp_nonce_url')) { ?>
-       <li><a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_form_options_menu&delete=$form_id", 'tdomf-delete-form-'.$form_id); ?>">
-          <?php _e("Delete","tdomf"); ?></a> |</li>
-       <li><a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_form_options_menu&copy=$form_id&form=$form_id", 'tdomf-copy-form-'.$form_id); ?>">
-          <?php _e("Copy","tdomf"); ?></a> |</li> 
-    <?php } else { ?>
-       <li><a href="admin.php?page=tdomf_show_form_options_menu&delete=<?php echo $form_id; ?>"><?php _e("Delete","tdomf"); ?></a> |</li>
-       <li><a href="admin.php?page=tdomf_show_form_options_menu&copy=<?php echo $form_id; ?>"><?php _e("Copy","tdomf"); ?></a> |</li> 
-    <?php } ?>
-    <?php if($pages != false) { ?>
-      <li><a href="<?php echo get_permalink($pages[0]); ?>" title="<?php _e("Live on your blog!","tdomf"); ?>" ><?php _e("View Page &raquo;","tdomf"); ?></a> |</li>
-    <?php } ?>
-    <?php if(tdomf_get_option_form(TDOMF_OPTION_INCLUDED_YOUR_SUBMISSIONS,$form_id) && get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) { ?>
-      <li><a href="users.php?page=tdomf_your_submissions#tdomf_form<?php echo $form_id; ?>" title="<?php _e("Included on the 'Your Submissions' page!",'tdomf'); ?>" >
-      <?php _e("View on 'Your Submissions' &raquo;","tdomf"); ?></a> |</li>
-    <?php } ?>
-     <li><a href="admin.php?page=tdomf_show_form_menu&form=<?php echo $form_id; ?>"><?php printf(__("Widgets &raquo;","tdomf"),$form_id); ?></a> |</li>
-     <li><a href="admin.php?page=tdomf_show_form_hacker&form=<?php echo $form_id; ?>"><?php printf(__("Hack Form &raquo;","tdomf"),$form_id); ?></a></li>
-    </ul>
-    <?php }
-}
-
-// Display the menu to configure options for this plugin
-//
-function tdomf_show_form_options_menu() {
-  global $wpdb, $wp_roles;
-
-  $form_id = tdomf_get_first_form_id();
-  $new_form_id = tdomf_handle_form_options_actions();
-  if($new_form_id != false) {
-      $form_id = $new_form_id;
-  } else if(isset($_REQUEST['form'])) {
-      $form_id = intval($_REQUEST['form']);
-  }
-
-  tdomf_forms_top_toolbar(intval($form_id));
-  tdomf_show_form_options(intval($form_id));
-}
-
-
-// Create a page with the form embedded
-//
-function tdomf_create_form_page($form_id = 1) {
-   global $current_user;
-
-   if(tdomf_form_exists($form_id)){
-     
-     $form_name = tdomf_get_option_form(TDOMF_OPTION_NAME,$form_id);
-     if($form_name == false || empty($form_name)) {
-       $form_name = __("Submit A Post","tdomf");
-     }
-     
-     $post = array (
-       "post_content"   => "[tdomf_form$form_id]",
-       "post_title"     => $form_name,
-       "post_author"    => $current_user->ID,
-       "post_status"    => 'publish',
-       "post_type"      => "page"
-     );
-     $post_ID = wp_insert_post($post);
-  
-     $pages = tdomf_get_option_form(TDOMF_OPTION_CREATEDPAGES,$form_id);
-     if($pages == false) {
-       $pages = array( $post_ID );
-     } else {
-       $pages = array_merge( $pages, array( $post_ID ) );
-     }
-     tdomf_set_option_form(TDOMF_OPTION_CREATEDPAGES,$pages,$form_id);
-     
-     return $post_ID;
-   }
-   
-   return false;
-}
-
-// Handle actions for this form
-//
-function tdomf_handle_form_options_actions() {
-   global $wpdb, $wp_roles;
-
-   $message = "";
-   $retValue = false;
-   
-  if(!isset($wp_roles)) {
-  	$wp_roles = new WP_Roles();
-  }
-  $roles = $wp_roles->role_objects;
-  $caps = tdomf_get_all_caps();
-  
-  $remove_throttle_rule = false;
-  $rule_id = 0;
-  if(isset($_REQUEST['tdomf_form_id'])) {
-      $form_id = intval($_REQUEST['tdomf_form_id']);
-      $rules = tdomf_get_option_form(TDOMF_OPTION_THROTTLE_RULES,$form_id);
-      if(is_array($rules)) {
-          foreach($rules as $id => $r) {
-              if(isset($_REQUEST["tdomf_remove_throttle_rule_$id"])) {
-                  $remove_throttle_rule = true;
-                  $rule_id = $id;
-                  break;
-              }
-          }
-      }
-  }
-  
-  if($remove_throttle_rule) {
-      check_admin_referer('tdomf-options-save');
-      
-      unset($rules[$rule_id]);
-      tdomf_set_option_form(TDOMF_OPTION_THROTTLE_RULES,$rules,$form_id);
-      
-      $message .= "Throttle rule removed!<br/>";
-      tdomf_log_message("Removed throttle rule");
-      
-  } else if(isset($_REQUEST['tdomf_add_throttle_rule'])) {
-     
-     check_admin_referer('tdomf-options-save');
-
-     $form_id = intval($_REQUEST['tdomf_form_id']);
-     
-     $rule = array();
-     $rule['sub_type'] = $_REQUEST['tdomf_throttle_rule_sub_type'];
-     $rule['count'] = $_REQUEST['tdomf_throttle_rule_count'];
-     $rule['type'] = $_REQUEST['tdomf_throttle_rule_user_type'];
-     $rule['opt1'] = isset($_REQUEST['tdomf_throttle_rule_opt1']);
-     $rule['time'] = intval($_REQUEST['tdomf_throttle_rule_time']);
-                            
-     $rules = tdomf_get_option_form(TDOMF_OPTION_THROTTLE_RULES,$form_id);
-     if(!is_array($rules)) { $rules = array(); }
-     $rules[] = $rule;
-     tdomf_set_option_form(TDOMF_OPTION_THROTTLE_RULES,$rules,$form_id);
-     
-     $message .= "Throttle rule added!<br/>";
-     tdomf_log_message("Added a new throttle rule: " . var_export($rule,true));
-  
-  } else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'create_form_page') {
-     check_admin_referer('tdomf-create-form-page');
-     $form_id = intval($_REQUEST['form']);
-     $page_id = tdomf_create_form_page($form_id);
-     $message = sprintf(__("A page with the form has been created. <a href='%s'>View page &raquo;</a><br/>","tdomf"),get_permalink($page_id));
-  } else if(isset($_REQUEST['save_settings']) && isset($_REQUEST['tdomf_form_id'])) {
-    
-      check_admin_referer('tdomf-options-save');
-    
-      $form_id = intval($_REQUEST['tdomf_form_id']);
-     
-      // Edit or Submit
-      
-      $edit_form = false;
-      if(isset($_REQUEST['tdomf_mode']) && $_REQUEST['tdomf_mode'] == "edit") {
-          $edit_form = true;
-      }
-      tdomf_set_option_form(TDOMF_OPTION_FORM_EDIT,$edit_form,$form_id);
-      
-      // Allow pages with forms to be editted
-      
-      $edit_page_form = isset($_REQUEST['tdomf_edit_page_form']);
-      tdomf_set_option_form(TDOMF_OPTION_EDIT_PAGE_FORM,$edit_page_form,$form_id);
-      
-      // Allow authors to edit
-      
-      $author_edit = false;
-      if(isset($_REQUEST['tdomf_author_edit'])) {
-          $author_edit = true;
-      }
-      tdomf_set_option_form(TDOMF_OPTION_ALLOW_AUTHOR,$author_edit,$form_id);
-      
-      // Edit post within X seconds of being published
-      
-      $time_edit = false;
-      if(isset($_REQUEST['tdomf_time_edit'])) {
-          $time_edit = intval($_REQUEST['tdomf_time_edit']);
-          if($time_edit <= 0){ $time_edit = false; }
-      }
-      tdomf_set_option_form(TDOMF_OPTION_ALLOW_TIME,$time_edit,$form_id);
-      
-      // Who can access the form?
-
-      if(isset($_REQUEST['tdomf_special_access_anyone']) && tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE,$form_id) == false) {
-         tdomf_set_option_form(TDOMF_OPTION_ALLOW_EVERYONE,true,$form_id);
-
-         foreach($roles as $role) {
-     	    // remove cap as it's not needed
-		    if(isset($role->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM.'_'.$form_id])){
-   				$role->remove_cap(TDOMF_CAPABILITY_CAN_SEE_FORM.'_'.$form_id);
-		    }
- 	  	}
-        
-        tdomf_set_option_form(TDOMF_OPTION_ALLOW_CAPS,array(),$form_id);
-        
-      } else if(!isset($_REQUEST['tdomf_special_access_anyone'])){
-          
-         tdomf_set_option_form(TDOMF_OPTION_ALLOW_EVERYONE,false,$form_id);
-         
-         // add cap to right roles
-         foreach($roles as $role) {
-		    if(isset($_REQUEST["tdomf_access_".$role->name])){
-				$role->add_cap(TDOMF_CAPABILITY_CAN_SEE_FORM.'_'.$form_id);
-		    } else if(isset($role->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM.'_'.$form_id])){
-   				$role->remove_cap(TDOMF_CAPABILITY_CAN_SEE_FORM.'_'.$form_id);
-		    }
- 	  	}
-        
-        // list caps that can access form
-        $allow_caps = array();
-        foreach($caps as $cap) {
-            if(isset($_REQUEST['tdomf_access_caps_'.$cap])){
-                $allow_caps[] = $cap; 
-            }
-        }
-        tdomf_set_option_form(TDOMF_OPTION_ALLOW_CAPS,$allow_caps,$form_id);
-        
-        // convert user names to ids
-        $allow_users = array();
-        if(isset($_REQUEST['tdomf_access_users_list'])) {
-           $user_names = trim($_REQUEST['tdomf_access_users_list']);
-           if(!empty($user_names)) {
-               $user_names = split(' ',$user_names);
-               foreach($user_names as $user_name) {
-                   if(!empty($user_name)) {
-                       if(($userdata = get_userdatabylogin($user_name)) != false) {
-                           $allow_users[] = $userdata->ID;
-                       } else {
-                           $message .= "<font color='red'>".sprintf(__("$user_name is not a valid user name. Ignoring.<br/>","tdomf"),$form_id)."</font>";
-                           tdomf_log_message("User login $user_name is not recognised by wordpress. Ignoring.",TDOMF_LOG_BAD);
-                       }
-                   }
-               }
-           }
-        }
-        tdomf_set_option_form(TDOMF_OPTION_ALLOW_USERS,$allow_users,$form_id);
-      }
- 
-      tdomf_set_option_form(TDOMF_OPTION_ALLOW_PUBLISH,isset($_REQUEST['tdomf_user_publish_override']),$form_id);
-      
-      // Who gets notified?
-
-      $notify_roles = "";
-	  foreach($roles as $role) {
-		if(isset($_REQUEST["tdomf_notify_".$role->name])){
-			$notify_roles .= $role->name.";";
-	    }
-      }
-      if(!empty($notify_roles)) {
-        tdomf_set_option_form(TDOMF_NOTIFY_ROLES,$notify_roles,$form_id);
-      } else {
-        tdomf_set_option_form(TDOMF_NOTIFY_ROLES,false,$form_id);
-      }
-      
-      $save = true;
-      $tdomf_admin_emails = $_POST['tdomf_admin_emails'];
-      $emails = split(',',$tdomf_admin_emails);
-      foreach($emails as $email) {
-          if(!empty($email)) {
-              if(!tdomf_check_email_address($email)) {
-                  $message .= "<font color='red'>".sprintf(__("The email %s is not valid! Please update 'Who Gets Notified' with valid email addresses.","tdomf"),$email)."</font><br/>";
-                  $save = false;
-                  break;
-              }
-          }
-      }
-      if($save) { tdomf_set_option_form(TDOMF_OPTION_ADMIN_EMAILS,$tdomf_admin_emails,$form_id); }
-      
-      // Default Category
-
-      $def_cat = $_POST['tdomf_def_cat'];
-      tdomf_set_option_form(TDOMF_DEFAULT_CATEGORY,$def_cat,$form_id);
-
-      // Restrict editing to posts submitted by tdomf
-      
-      $edit_restrict_tdomf = isset($_REQUEST['tdomf_edit_tdomf_only']);
-      tdomf_set_option_form(TDOMF_OPTION_EDIT_RESTRICT_TDOMF,$edit_restrict_tdomf,$form_id);
-      
-      $edit_restrict_cats = explode(',',trim($_REQUEST['tdomf_edit_cats']));
-      if(!empty($edit_restrict_cats)) {
-          $cats = array();
-          foreach($edit_restrict_cats as $cat) {
-              $cat = intval(trim($cat));
-              if($cat > 0) { $cats[] = $cat; }
-          }
-          $edit_restrict_cats = $cats;
-      } else {
-          $edit_restrict_cats = array();
-      }
-      tdomf_set_option_form(TDOMF_OPTION_EDIT_RESTRICT_CATS,$edit_restrict_cats,$form_id);
-            
-      // add edit link
-      
-      $add_edit_link = $_REQUEST['tdomf_add_edit_link'];
-      if($add_edit_link == 'custom') { 
-          $add_edit_link = $_REQUEST['tdomf_add_edit_link_custom_url'];
-      }
-      tdomf_set_option_form(TDOMF_OPTION_ADD_EDIT_LINK,$add_edit_link,$form_id);
-           
-      $ajax_edit = isset($_REQUEST['tdomf_ajax_edit']);
-      tdomf_set_option_form(TDOMF_OPTION_AJAX_EDIT,$ajax_edit,$form_id);
-      
-      // auto modify edit link
-      
-      $auto_edit_link = $_REQUEST['tdomf_auto_edit_link'];
-      if($auto_edit_link == 'custom') { 
-          $auto_edit_link = $_REQUEST['tdomf_auto_edit_link_custom_url'];
-      }
-      tdomf_set_option_form(TDOMF_OPTION_AUTO_EDIT_LINK,$auto_edit_link,$form_id);
-      
-       //Turn On/Off Moderation
-
-      $mod = false;
-      if(isset($_POST['tdomf_moderation'])) { $mod = true; }
-      tdomf_set_option_form(TDOMF_OPTION_MODERATION,$mod,$form_id);
-
-      $tdomf_redirect = isset($_POST['tdomf_redirect']);
-      tdomf_set_option_form(TDOMF_OPTION_REDIRECT,$tdomf_redirect,$form_id);
-      
-      //Preview
-
-      $preview = false;
-      if(isset($_POST['tdomf_preview'])) { $preview = true; }
-      tdomf_set_option_form(TDOMF_OPTION_PREVIEW,$preview,$form_id);
-
-      //From email
-
-      if(trim($_POST['tdomf_from_email']) == "") {
-       	tdomf_set_option_form(TDOMF_OPTION_FROM_EMAIL,false,$form_id);
-       } else {
-        tdomf_set_option_form(TDOMF_OPTION_FROM_EMAIL,$_POST['tdomf_from_email'],$form_id);
-       }
-
-       // Form name
-       
-       if(trim($_POST['tdomf_form_name']) == "") {
-        tdomf_set_option_form(TDOMF_OPTION_NAME,"",$form_id);
-       } else {
-        tdomf_set_option_form(TDOMF_OPTION_NAME,strip_tags($_POST['tdomf_form_name']),$form_id);
-       }
-       
-       // Form description
-       
-       if(trim($_POST['tdomf_form_descp']) == "") {
-       	tdomf_set_option_form(TDOMF_OPTION_DESCRIPTION,false,$form_id);
-       } else {
-        tdomf_set_option_form(TDOMF_OPTION_DESCRIPTION,$_POST['tdomf_form_descp'],$form_id);
-       }
-       
-       // Include on "your submissions" page
-       //
-       $include = false;
-      if(isset($_POST['tdomf_include_sub'])) { $include = true; }
-      tdomf_set_option_form(TDOMF_OPTION_INCLUDED_YOUR_SUBMISSIONS,$include,$form_id);
-       
-      if(get_option(TDOMF_OPTION_YOUR_SUBMISSIONS) && $include) {
-        $message .= sprintf(__("Saved Options for Form %d. <a href='%s'>See your form &raquo</a>","tdomf"),$form_id,"users.php?page=tdomf_your_submissions#tdomf_form%d")."<br/>";
-      } else {
-        $message .= sprintf(__("Saved Options for Form %d.","tdomf"),$form_id)."<br/>";
-      }
-      
-      // widget count
-      //
-      $widget_count = 10;
-      if(isset($_POST['tdomf_widget_count'])) { $widget_count = intval($_POST['tdomf_widget_count']); }
-      if($widget_count < 1){ $widget_count = 1; }
-      tdomf_set_option_form(TDOMF_OPTION_WIDGET_INSTANCES,$widget_count,$form_id);
-      
-      //Submit page instead of post
-      //
-      $use_page = false;
-      if(isset($_POST['tdomf_use_type']) && $_POST['tdomf_use_type'] == 'page') { $use_page = true; }
-      tdomf_set_option_form(TDOMF_OPTION_SUBMIT_PAGE,$use_page,$form_id);
-
-      // Queue period
-      //
-      $tdomf_queue_period = intval($_POST['tdomf_queue_period']);
-      tdomf_set_option_form(TDOMF_OPTION_QUEUE_PERIOD,$tdomf_queue_period,$form_id);
-      
-      // Queue on all 
-      //
-      $tdomf_queue_on_all = isset($_POST['tdomf_queue_on_all']);
-      tdomf_set_option_form(TDOMF_OPTION_QUEUE_ON_ALL,$tdomf_queue_on_all,$form_id);
-      
-      // ajax
-      //
-      $tdomf_ajax = isset($_POST['tdomf_ajax']);
-      tdomf_set_option_form(TDOMF_OPTION_AJAX,$tdomf_ajax,$form_id);
-      
-      // Send moderation email even for published posts
-      //
-      $tdomf_mod_email_on_pub = isset($_POST['tdomf_mod_email_on_pub']);
-      tdomf_set_option_form(TDOMF_OPTION_MOD_EMAIL_ON_PUB,$tdomf_mod_email_on_pub,$form_id);
-      
-      // Admin users auto-publish?
-      //
-      $tdomf_publish_no_mod = isset($_POST['tdomf_user_publish_auto']);
-      tdomf_set_option_form(TDOMF_OPTION_PUBLISH_NO_MOD,$tdomf_publish_no_mod,$form_id);
-      
-      // Spam
-      //
-      $message .= tdomf_handle_spam_options_actions($form_id);
-      
-      tdomf_log_message("Options Saved for Form ID $form_id");
-       
-  } else if(isset($_REQUEST['delete'])) {
-      
-    $form_id = intval($_REQUEST['delete']);
-    
-    check_admin_referer('tdomf-delete-form-'.$form_id);
-    
-    if(tdomf_form_exists($form_id)) {
-      $count_forms = count(tdomf_get_form_ids());
-      if($count_forms > 1) {
-        if(tdomf_delete_form($form_id)) {
-           $message .= sprintf(__("Form %d deleted.<br/>","tdomf"),$form_id);
-        } else {
-          $message .= sprintf(__("Could not delete Form %d!<br/>","tdomf"),$form_id);
-        }
-      } else {
-        $message .= sprintf(__("You cannot delete the last form! There must be at least one form in the system.<br/>","tdomf"),$form_id);
-      }
-    } else {
-      $message .= sprintf(__("Form %d is not valid!<br/>","tdomf"),$form_id);
-    }
-  } else if(isset($_REQUEST['copy'])) {
-    
-    $form_id = intval($_REQUEST['copy']);
-    
-    check_admin_referer('tdomf-copy-form-'.$form_id);
-    
-    $copy_form_id = tdomf_copy_form($form_id);
-   
-    if($copy_form_id != 0) {
-      $message .= sprintf(__("Form %d copied with id %d.<br/>","tdomf"),$form_id,$copy_form_id);
-      $retValue = $copy_form_id;
-    } else {
-      $message .= sprintf(__("Failed to copy Form %d!<br/>","tdomf"),$form_id);
-    }
-        
-  } else if(isset($_REQUEST['new'])) {
-    
-    check_admin_referer('tdomf-new-form');
-    
-    $form_id = tdomf_create_form(__('New Form','tdomf'),array());
-   
-    if($form_id != 0) {
-      $message .= sprintf(__("New form created with %d.<br/>","tdomf"),$form_id);
-      $retValue = $form_id;
-    } else {
-      $message .= __("Failed to create new Form!<br/>","tdomf");
-    }
-  }
-
-   // Warnings
-
-   $message .= tdomf_get_error_messages(false);
-
-   if(!empty($message)) { ?>
-   <div id="message" class="updated fade"><p><?php echo $message; ?></p></div>
-   <?php }
-   
-   return $retValue;
-}
-
-?>
+<?php
+if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('TDOMF: You are not allowed to call this page directly.'); }
+
+/*define('SCRIPT_DEBUG', true);*/
+
+function tdomf_load_form_options_admin_scripts() {
+    /* for tabs */
+    wp_enqueue_script( 'jquery-ui-tabs' );
+}
+add_action("load-".sanitize_title(__('TDO Mini Forms', 'tdomf'))."_page_tdomf_show_form_options_menu","tdomf_load_form_options_admin_scripts");
+
+function tdomf_form_options_admin_head() {
+    global $wp_version;
+    /* add style options and start tabs for options page */
+    if(preg_match('/tdomf_show_form_options_menu/',$_SERVER['REQUEST_URI'])) { ?>
+           
+           <style>
+            .ui-tabs-nav {
+                /*resets*/margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none;
+                float: left;
+                position: relative;
+                z-index: 1;
+                border-right: 1px solid #d3d3d3;
+                bottom: -1px;
+            }
+            .ui-tabs-nav li {
+                /*resets*/margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none;
+                float: left;
+                border: 1px solid #d3d3d3;
+                border-right: none;
+            }
+            .ui-tabs-nav li a {
+                /*resets*/margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none;
+                float: left;
+                font-weight: bold;
+                text-decoration: none;
+                padding: .5em 1.7em;
+                color: #555555;
+                background: #e6e6e6;
+            }
+            .ui-tabs-nav li a:hover {
+                background: #dadada;
+                color: #212121;
+            }
+            .ui-tabs-nav li.ui-tabs-selected {
+                border-bottom-color: #ffffff;
+            }
+            .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs-nav li.ui-tabs-selected a:hover {
+                background: #ffffff;
+                color: #222222;
+            }
+            .ui-tabs-panel {
+                /*resets*/margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none;
+                clear:left;
+                border: 1px solid #d3d3d3;
+                background: #ffffff;
+                color: #222222;
+                padding: 1.5em 1.7em;	
+            }
+            .ui-tabs-hide {
+                display: none;
+            }
+            .ui-tabs-nav li.ui-tabs-disabled a, .ui-tabs-nav li.ui-tabs-disabled a:hover, li.ui-state-disabled {
+                color: grey;
+                background: lightgrey;
+                text-decoration:line-through;
+            }
+            #access_caps_list {
+             overflow: scroll;
+             height: 200px;
+            }
+            
+            </style>
+           
+           <script>
+           jQuery(document).ready(function(){
+               <?php if(version_compare($wp_version,"2.8-beta2",">=")) { ?>
+                   jQuery("#form_options_tabs").tabs();
+                   jQuery("#options_access_tabs").tabs();
+               <?php } else { ?>
+                   jQuery("#form_options_tabs > ul").tabs();
+                   jQuery("#options_access_tabs > ul").tabs();
+               <?php } ?>
+           });
+           </script>
+           
+    <?php }
+}
+add_action( 'admin_head', 'tdomf_form_options_admin_head' );
+
+  /**
+   * get an array with all capabilities
+   * copied from role-manager 2 plugin
+   */
+function tdomf_get_all_caps() {
+    global $wp_roles;
+    
+    // Get Role List
+    foreach($wp_roles->role_objects as $key => $role) {
+      foreach($role->capabilities as $cap => $grant) {
+        $capnames[$cap] = $cap;
+        //$this->debug('grant', ($role->capabilities));
+      }
+    }
+    
+    $capnames = apply_filters('capabilities_list', $capnames);
+    if(!is_array($capnames)) $capnames = array();
+    $capnames = array_unique($capnames);
+    sort($capnames);
+
+    //Filter out the level_x caps, they're obsolete
+    $capnames = array_diff($capnames, array('level_0', 'level_1', 'level_2', 'level_3', 'level_4', 'level_5',
+        'level_6', 'level_7', 'level_8', 'level_9', 'level_10'));
+    
+    //Filter out roles
+      foreach ($wp_roles->get_names() as $role) {
+        $key = array_search($role, $capnames);
+        if ($key !== false && $key !== null) { //array_search() returns null if not found in 4.1
+          unset($capnames[$key]);
+        }
+      }
+      
+      // this cap is used seperately 
+      unset($capnames['publish_post']);
+      
+      // filter out tdomf caps that were added
+      foreach($capnames as $key => $cap) {
+          if(substr($cap,TDOMF_CAPABILITY_CAN_SEE_FORM,strlen(TDOMF_CAPABILITY_CAN_SEE_FORM)) == TDOMF_CAPABILITY_CAN_SEE_FORM) {
+              unset($capnames[$key]);
+          }
+      }
+      
+    return $capnames;
+  }
+
+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\">
+                     <tr><td>Only %s submissions/contributions per</td>
+                     <td>%s</td>
+                     <td>%s(optionally) per %s Seconds (1 hour = 3600 seconds)</td>
+                     <td>%s</td>
+                     </tr>
+                     </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 }
+}
+
+function tdomf_forms_top_toolbar($form_id_in=false, $current='tdomf_show_form_options_menu') {
+    $form_ids = tdomf_get_form_ids();
+    $pages = tdomf_get_option_form(TDOMF_OPTION_CREATEDPAGES,$form_id_in);
+    if(tdomf_wp23()) { ?>
+        <div class="wrap">
+    
+    <?php if(!empty($form_ids)) {
+            foreach($form_ids as $form_id) { ?>
+              <?php if($form_id->form_id == $form_id_in) { ?>
+                <b>
+              <?php } else { ?>
+                <a href="admin.php?page=tdomf_show_form_options_menu&form=<?php echo $form_id->form_id; ?>">
+              <?php } ?>
+              <?php printf(__("Form %d","tdomf"),$form_id->form_id); ?><?php if($form_id->form_id == $form_id_in) { ?></b><?php } else {?></a><?php } ?>
+                 |
+            <?php }
+          }
+    ?>
+    
+    <?php if(function_exists('wp_nonce_url')) { ?>
+   <a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_form_options_menu&new", 'tdomf-new-form'); ?>">
+          <?php _e("New Form &raquo;","tdomf"); ?></a>
+    <?php } else { ?>
+      <a href="admin.php?page=tdomf_show_form_options_menu&new"><?php _e("New Form &raquo;","tdomf"); ?></a>
+    <?php } ?>
+    </div> <!-- wrap -->
+
+    <div class="wrap">
+    <?php if(function_exists('wp_nonce_url')) { ?>
+       <a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_form_options_menu&delete=$form_id", 'tdomf-delete-form-'.$form_id); ?>">
+          <?php _e("Delete","tdomf"); ?></a> |
+       <a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_form_options_menu&copy=$form_id&form=$form_id", 'tdomf-copy-form-'.$form_id); ?>">
+          <?php _e("Copy","tdomf"); ?></a> | 
+    <?php } else { ?>
+       <a href="admin.php?page=tdomf_show_form_options_menu&delete=<?php echo $form_id; ?>"><?php _e("Delete","tdomf"); ?></a> |
+       <a href="admin.php?page=tdomf_show_form_options_menu&copy=<?php echo $form_id; ?>"><?php _e("Copy","tdomf"); ?></a> | 
+    <?php } ?>
+    <?php if($pages != false) { ?>
+      <a href="<?php echo get_permalink($pages[0]); ?>" title="<?php _e("Live on your blog!","tdomf"); ?>" ><?php _e("View &raquo;","tdomf"); ?></a> |
+    <?php } ?>
+    <?php if(tdomf_get_option_form(TDOMF_OPTION_INCLUDED_YOUR_SUBMISSIONS,$form_id) && get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) { ?>
+        <?php if(current_user_can('edit_users')) { ?>
+                <a href="users.php?page=tdomf_your_submissions#tdomf_form<?php echo $form_id; ?>" title="<?php _e("Included on the 'Your Submissions' page!",'tdomf'); ?>" >
+        <?php } else { ?>
+                <a href="profile.php?page=tdomf_your_submissions#tdomf_form<?php echo $form_id; ?>" title="<?php _e("Included on the 'Your Submissions' page!",'tdomf'); ?>" >
+          <?php } ?>
+      <?php _e("View &raquo;","tdomf"); ?></a>
+    <?php } ?>
+    </div> <!-- wrap -->
+    
+    <?php 
+    } else if(tdomf_wp27()) { /* do nothing */
+    } else if(tdomf_wp25()) { /* do nothing */ }
+}
+
+function tdomf_forms_under_title_toolbar($form_id_in=false, $current='tdomf_show_form_options_menu') {
+    $form_ids = tdomf_get_form_ids();
+    $pages = tdomf_get_option_form(TDOMF_OPTION_CREATEDPAGES,$form_id_in);
+    if(tdomf_wp23()) { /* do nothing */
+    } else if(tdomf_wp27()) { ?>
+
+        <ul class="subsubsub"> 
+            <li> <a <?php if($current == 'tdomf_show_form_options_menu') { ?>class="current" <?php } ?>href="admin.php?page=tdomf_show_form_options_menu&form=<?php echo $form_id_in; ?>"><?php printf(__("Options","tdomf"),$form_id_in); ?></a> |</li>
+            <li> <a <?php if($current == 'tdomf_show_form_menu') { ?>class="current" <?php } ?>href="admin.php?page=tdomf_show_form_menu&form=<?php echo $form_id_in; ?>"><?php printf(__("Create","tdomf"),$form_id_in); ?></a> |</li>
+            <li> <a <?php if($current == 'tdomf_show_form_hacker' && !isset($_REQUEST['text'])) { ?>class="current" <?php } ?>href="admin.php?page=tdomf_show_form_hacker&form=<?php echo $form_id_in; ?>"><?php printf(__("Hack","tdomf"),$form_id_in); ?></a> |</li>
+            <li> <a <?php if($current == 'tdomf_show_form_hacker' &&  isset($_REQUEST['text'])) { ?>class="current" <?php } ?>href="admin.php?page=tdomf_show_form_hacker&text&form=<?php echo $form_id_in; ?>"><?php printf(__("Messages","tdomf"),$form_id_in); ?></a> |</li>
+            <li> <a <?php if($current == 'tdomf_show_form_export_menu') { ?>class="current" <?php } ?>href="admin.php?page=tdomf_show_form_export_menu&form=<?php echo $form_id_in; ?>"><?php printf(__("Export","tdomf"),$form_id_in); ?></a> |</li>
+            <?php if($pages != false && is_array($pages)) { ?>          
+                <li><a href="<?php echo get_permalink($pages[0]); ?>" title="<?php echo htmlentities(_e("Live on your blog!","tdomf"),ENT_QUOTES); ?>" ><?php _e("View Page &raquo;","tdomf"); ?></a> |</li>
+            <?php } ?>
+            <?php if(tdomf_get_option_form(TDOMF_OPTION_INCLUDED_YOUR_SUBMISSIONS,$form_id_in) && get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) { ?>
+                <li><a href="users.php?page=tdomf_your_submissions#tdomf_form<?php echo $form_id_in; ?>" title="<?php _e("Included on the 'Your Submissions' page!",'tdomf'); ?>" >
+                <?php _e("View on 'Your Submissions' &raquo;","tdomf"); ?></a> |</li>
+            <?php } ?>
+        </ul> 
+          
+      <div class="tablenav">
+      
+          <div class="alignleft">
+            <a class="button" title="<?php echo htmlentities(__('Create a new form','tdomf'),ENT_QUOTES); ?>" href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_form_options_menu&new", 'tdomf-new-form'); ?>">
+            <?php _e("New","tdomf"); ?></a>
+    
+            <a class="button" title="<?php echo htmlentities(__('Delete this form','tdomf'),ENT_QUOTES); ?>" href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_form_options_menu&delete=$form_id_in", 'tdomf-delete-form-'.$form_id_in); ?>">
+            <?php _e("Delete","tdomf"); ?></a>
+       
+            <a class="button" title="<?php echo htmlentities(__('Make a copy of this form','tdomf'),ENT_QUOTES); ?>" href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_form_options_menu&copy=$form_id_in&form=$form_id_in", 'tdomf-copy-form-'.$form_id_in); ?>">
+            <?php _e("Copy","tdomf"); ?></a>
+          </div> <!-- alignleft -->
+      
+          <?php if(!empty($form_ids)) { ?>
+          
+              <div class="alignright actions">
+                <div class="tablenav-pages"><span class="displaying-num"><?php _e("Forms:",'tdomf'); ?></span>
+                    <?php foreach($form_ids as $form_id) { ?>
+                        <?php if($form_id->form_id == $form_id_in) { ?>
+                            <span class='page-numbers current'><?php printf($form_id_in); ?></span> 
+                        <?php } else { $form_name = tdomf_get_option_form(TDOMF_OPTION_NAME,$form_id->form_id); ?>
+                            <a class='page-numbers' title='<?php echo htmlentities($form_name,ENT_QUOTES); ?>' href="admin.php?page=<?php echo $current; ?>&form=<?php echo $form_id->form_id; ?>">
+                            <?php printf($form_id->form_id); ?></a>
+                        <?php } ?>
+                    <?php } ?>
+                </div> <!-- alignleft actions -->
+          <?php } ?>      
+     </div> <!-- tablenav -->
+      
+         
+     </div> <!-- wrap -->
+     <div class="wrap">
+     
+    <?php } else if(tdomf_wp25()) { ?>
+        
+    <ul class="subsubsub">
+       <?php if(!empty($form_ids)) {
+            foreach($form_ids as $form_id) { ?>
+                <li><a href="admin.php?page=tdomf_show_form_options_menu&form=<?php echo $form_id->form_id; ?>"<?php if($form_id->form_id == $form_id_in) { ?> class="current" <?php } ?>>
+                <?php printf(__("Form %d","tdomf"),$form_id->form_id); ?></a> |</li>
+            <?php }
+          } ?>
+        <?php if(function_exists('wp_nonce_url')) { ?>
+        <li><a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_form_options_menu&new", 'tdomf-new-form'); ?>">
+          <?php _e("New Form &raquo;","tdomf"); ?></a></li>
+    <?php } else { ?>
+      <li><a href="admin.php?page=tdomf_show_form_options_menu&new"><?php _e("New Form &raquo;","tdomf"); ?></a></li>
+    <?php } ?>
+   </ul>
+    
+    <ul class="subsubsub">
+    <?php if(function_exists('wp_nonce_url')) { ?>
+       <li><a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_form_options_menu&delete=$form_id", 'tdomf-delete-form-'.$form_id); ?>">
+          <?php _e("Delete","tdomf"); ?></a> |</li>
+       <li><a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_form_options_menu&copy=$form_id&form=$form_id", 'tdomf-copy-form-'.$form_id); ?>">
+          <?php _e("Copy","tdomf"); ?></a> |</li> 
+    <?php } else { ?>
+       <li><a href="admin.php?page=tdomf_show_form_options_menu&delete=<?php echo $form_id; ?>"><?php _e("Delete","tdomf"); ?></a> |</li>
+       <li><a href="admin.php?page=tdomf_show_form_options_menu&copy=<?php echo $form_id; ?>"><?php _e("Copy","tdomf"); ?></a> |</li> 
+    <?php } ?>
+    <?php if($pages != false) { ?>
+      <li><a href="<?php echo get_permalink($pages[0]); ?>" title="<?php _e("Live on your blog!","tdomf"); ?>" ><?php _e("View Page &raquo;","tdomf"); ?></a> |</li>
+    <?php } ?>
+    <?php if(tdomf_get_option_form(TDOMF_OPTION_INCLUDED_YOUR_SUBMISSIONS,$form_id) && get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) { ?>
+      <li><a href="users.php?page=tdomf_your_submissions#tdomf_form<?php echo $form_id; ?>" title="<?php _e("Included on the 'Your Submissions' page!",'tdomf'); ?>" >
+      <?php _e("View on 'Your Submissions' &raquo;","tdomf"); ?></a> |</li>
+    <?php } ?>
+     <li><a href="admin.php?page=tdomf_show_form_menu&form=<?php echo $form_id; ?>"><?php printf(__("Widgets &raquo;","tdomf"),$form_id); ?></a> |</li>
+     <li><a href="admin.php?page=tdomf_show_form_hacker&form=<?php echo $form_id; ?>"><?php printf(__("Hack Form &raquo;","tdomf"),$form_id); ?></a></li>
+    </ul>
+    <?php }
+}
+
+// Display the menu to configure options for this plugin
+//
+function tdomf_show_form_options_menu() {
+  global $wpdb, $wp_roles;
+
+  $form_id = tdomf_get_first_form_id();
+  $new_form_id = tdomf_handle_form_options_actions();
+  if($new_form_id != false) {
+      $form_id = $new_form_id;
+  } else if(isset($_REQUEST['form'])) {
+      $form_id = intval($_REQUEST['form']);
+  }
+
+  tdomf_forms_top_toolbar(intval($form_id));
+  tdomf_show_form_options(intval($form_id));
+}
+
+
+// Create a page with the form embedded
+//
+function tdomf_create_form_page($form_id = 1) {
+   global $current_user;
+
+   if(tdomf_form_exists($form_id)){
+     
+     $form_name = tdomf_get_option_form(TDOMF_OPTION_NAME,$form_id);
+     if($form_name == false || empty($form_name)) {
+       $form_name = __("Submit A Post","tdomf");
+     }
+     
+     $post = array (
+       "post_content"   => "[tdomf_form$form_id]",
+       "post_title"     => $form_name,
+       "post_author"    => $current_user->ID,
+       "post_status"    => 'publish',
+       "post_type"      => "page"
+     );
+     $post_ID = wp_insert_post($post);
+  
+     $pages = tdomf_get_option_form(TDOMF_OPTION_CREATEDPAGES,$form_id);
+     if($pages == false) {
+       $pages = array( $post_ID );
+     } else {
+       $pages = array_merge( $pages, array( $post_ID ) );
+     }
+     tdomf_set_option_form(TDOMF_OPTION_CREATEDPAGES,$pages,$form_id);
+     
+     return $post_ID;
+   }
+   
+   return false;
+}
+
+// Handle actions for this form
+//
+function tdomf_handle_form_options_actions() {
+   global $wpdb, $wp_roles;
+
+   $message = "";
+   $retValue = false;
+   
+  if(!isset($wp_roles)) {
+  	$wp_roles = new WP_Roles();
+  }
+  $roles = $wp_roles->role_objects;
+  $caps = tdomf_get_all_caps();
+  
+  $remove_throttle_rule = false;
+  $rule_id = 0;
+  if(isset($_REQUEST['tdomf_form_id'])) {
+      $form_id = intval($_REQUEST['tdomf_form_id']);
+      $rules = tdomf_get_option_form(TDOMF_OPTION_THROTTLE_RULES,$form_id);
+      if(is_array($rules)) {
+          foreach($rules as $id => $r) {
+              if(isset($_REQUEST["tdomf_remove_throttle_rule_$id"])) {
+                  $remove_throttle_rule = true;
+                  $rule_id = $id;
+                  break;
+              }
+          }
+      }
+  }
+  
+  if($remove_throttle_rule) {
+      check_admin_referer('tdomf-options-save');
+      
+      unset($rules[$rule_id]);
+      tdomf_set_option_form(TDOMF_OPTION_THROTTLE_RULES,$rules,$form_id);
+      
+      $message .= "Throttle rule removed!<br/>";
+      tdomf_log_message("Removed throttle rule");
+      
+  } else if(isset($_REQUEST['tdomf_add_throttle_rule'])) {
+     
+     check_admin_referer('tdomf-options-save');
+
+     $form_id = intval($_REQUEST['tdomf_form_id']);
+     
+     $rule = array();
+     $rule['sub_type'] = $_REQUEST['tdomf_throttle_rule_sub_type'];
+     $rule['count'] = $_REQUEST['tdomf_throttle_rule_count'];
+     $rule['type'] = $_REQUEST['tdomf_throttle_rule_user_type'];
+     $rule['opt1'] = isset($_REQUEST['tdomf_throttle_rule_opt1']);
+     $rule['time'] = intval($_REQUEST['tdomf_throttle_rule_time']);
+                            
+     $rules = tdomf_get_option_form(TDOMF_OPTION_THROTTLE_RULES,$form_id);
+     if(!is_array($rules)) { $rules = array(); }
+     $rules[] = $rule;
+     tdomf_set_option_form(TDOMF_OPTION_THROTTLE_RULES,$rules,$form_id);
+     
+     $message .= "Throttle rule added!<br/>";
+     tdomf_log_message("Added a new throttle rule: " . var_export($rule,true));
+  
+  } else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'create_form_page') {
+     check_admin_referer('tdomf-create-form-page');
+     $form_id = intval($_REQUEST['form']);
+     $page_id = tdomf_create_form_page($form_id);
+     $message = sprintf(__("A page with the form has been created. <a href='%s'>View page &raquo;</a><br/>","tdomf"),get_permalink($page_id));
+  } else if(isset($_REQUEST['save_settings']) && isset($_REQUEST['tdomf_form_id'])) {
+    
+      check_admin_referer('tdomf-options-save');
+    
+      $form_id = intval($_REQUEST['tdomf_form_id']);
+     
+      // Edit or Submit
+      
+      $edit_form = false;
+      if(isset($_REQUEST['tdomf_mode']) && $_REQUEST['tdomf_mode'] == "edit") {
+          $edit_form = true;
+      }
+      tdomf_set_option_form(TDOMF_OPTION_FORM_EDIT,$edit_form,$form_id);
+      
+      // Allow pages with forms to be editted
+      
+      $edit_page_form = isset($_REQUEST['tdomf_edit_page_form']);
+      tdomf_set_option_form(TDOMF_OPTION_EDIT_PAGE_FORM,$edit_page_form,$form_id);
+      
+      // Allow authors to edit
+      
+      $author_edit = false;
+      if(isset($_REQUEST['tdomf_author_edit'])) {
+          $author_edit = true;
+      }
+      tdomf_set_option_form(TDOMF_OPTION_ALLOW_AUTHOR,$author_edit,$form_id);
+      
+      // Edit post within X seconds of being published
+      
+      $time_edit = false;
+      if(isset($_REQUEST['tdomf_time_edit'])) {
+          $time_edit = intval($_REQUEST['tdomf_time_edit']);
+          if($time_edit <= 0){ $time_edit = false; }
+      }
+      tdomf_set_option_form(TDOMF_OPTION_ALLOW_TIME,$time_edit,$form_id);
+      
+      // Who can access the form?
+
+      if(isset($_REQUEST['tdomf_special_access_anyone']) && tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE,$form_id) == false) {
+         tdomf_set_option_form(TDOMF_OPTION_ALLOW_EVERYONE,true,$form_id);
+
+         foreach($roles as $role) {
+     	    // remove cap as it's not needed
+		    if(isset($role->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM.'_'.$form_id])){
+   				$role->remove_cap(TDOMF_CAPABILITY_CAN_SEE_FORM.'_'.$form_id);
+		    }
+ 	  	}
+        
+        tdomf_set_option_form(TDOMF_OPTION_ALLOW_CAPS,array(),$form_id);
+        
+      } else if(!isset($_REQUEST['tdomf_special_access_anyone'])){
+          
+         tdomf_set_option_form(TDOMF_OPTION_ALLOW_EVERYONE,false,$form_id);
+         
+         // add cap to right roles
+         foreach($roles as $role) {
+		    if(isset($_REQUEST["tdomf_access_".$role->name])){
+				$role->add_cap(TDOMF_CAPABILITY_CAN_SEE_FORM.'_'.$form_id);
+		    } else if(isset($role->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM.'_'.$form_id])){
+   				$role->remove_cap(TDOMF_CAPABILITY_CAN_SEE_FORM.'_'.$form_id);
+		    }
+ 	  	}
+        
+        // list caps that can access form
+        $allow_caps = array();
+        foreach($caps as $cap) {
+            if(isset($_REQUEST['tdomf_access_caps_'.$cap])){
+                $allow_caps[] = $cap; 
+            }
+        }
+        tdomf_set_option_form(TDOMF_OPTION_ALLOW_CAPS,$allow_caps,$form_id);
+        
+        // convert user names to ids
+        $allow_users = array();
+        if(isset($_REQUEST['tdomf_access_users_list'])) {
+           $user_names = trim($_REQUEST['tdomf_access_users_list']);
+           if(!empty($user_names)) {
+               $user_names = split(' ',$user_names);
+               foreach($user_names as $user_name) {
+                   if(!empty($user_name)) {
+                       if(($userdata = get_userdatabylogin($user_name)) != false) {
+                           $allow_users[] = $userdata->ID;
+                       } else {
+                           $message .= "<font color='red'>".sprintf(__("$user_name is not a valid user name. Ignoring.<br/>","tdomf"),$form_id)."</font>";
+                           tdomf_log_message("User login $user_name is not recognised by wordpress. Ignoring.",TDOMF_LOG_BAD);
+                       }
+                   }
+               }
+           }
+        }
+        tdomf_set_option_form(TDOMF_OPTION_ALLOW_USERS,$allow_users,$form_id);
+      }
+ 
+      tdomf_set_option_form(TDOMF_OPTION_ALLOW_PUBLISH,isset($_REQUEST['tdomf_user_publish_override']),$form_id);
+      
+      // Who gets notified?
+
+      $notify_roles = "";
+	  foreach($roles as $role) {
+		if(isset($_REQUEST["tdomf_notify_".$role->name])){
+			$notify_roles .= $role->name.";";
+	    }
+      }
+      if(!empty($notify_roles)) {
+        tdomf_set_option_form(TDOMF_NOTIFY_ROLES,$notify_roles,$form_id);
+      } else {
+        tdomf_set_option_form(TDOMF_NOTIFY_ROLES,false,$form_id);
+      }
+      
+      $save = true;
+      $tdomf_admin_emails = $_POST['tdomf_admin_emails'];
+      $emails = split(',',$tdomf_admin_emails);
+      foreach($emails as $email) {
+          if(!empty($email)) {
+              if(!tdomf_check_email_address($email)) {
+                  $message .= "<font color='red'>".sprintf(__("The email %s is not valid! Please update 'Who Gets Notified' with valid email addresses.","tdomf"),$email)."</font><br/>";
+                  $save = false;
+                  break;
+              }
+          }
+      }
+      if($save) { tdomf_set_option_form(TDOMF_OPTION_ADMIN_EMAILS,$tdomf_admin_emails,$form_id); }
+      
+      // Default Category
+
+      $def_cat = $_POST['tdomf_def_cat'];
+      tdomf_set_option_form(TDOMF_DEFAULT_CATEGORY,$def_cat,$form_id);
+
+      // Restrict editing to posts submitted by tdomf
+      
+      $edit_restrict_tdomf = isset($_REQUEST['tdomf_edit_tdomf_only']);
+      tdomf_set_option_form(TDOMF_OPTION_EDIT_RESTRICT_TDOMF,$edit_restrict_tdomf,$form_id);
+      
+      $edit_restrict_cats = explode(',',trim($_REQUEST['tdomf_edit_cats']));
+      if(!empty($edit_restrict_cats)) {
+          $cats = array();
+          foreach($edit_restrict_cats as $cat) {
+              $cat = intval(trim($cat));
+              if($cat > 0) { $cats[] = $cat; }
+          }
+          $edit_restrict_cats = $cats;
+      } else {
+          $edit_restrict_cats = array();
+      }
+      tdomf_set_option_form(TDOMF_OPTION_EDIT_RESTRICT_CATS,$edit_restrict_cats,$form_id);
+            
+      // add edit link
+      
+      $add_edit_link = $_REQUEST['tdomf_add_edit_link'];
+      if($add_edit_link == 'custom') { 
+          $add_edit_link = $_REQUEST['tdomf_add_edit_link_custom_url'];
+      }
+      tdomf_set_option_form(TDOMF_OPTION_ADD_EDIT_LINK,$add_edit_link,$form_id);
+           
+      $ajax_edit = isset($_REQUEST['tdomf_ajax_edit']);
+      tdomf_set_option_form(TDOMF_OPTION_AJAX_EDIT,$ajax_edit,$form_id);
+      
+      // auto modify edit link
+      
+      $auto_edit_link = $_REQUEST['tdomf_auto_edit_link'];
+      if($auto_edit_link == 'custom') { 
+          $auto_edit_link = $_REQUEST['tdomf_auto_edit_link_custom_url'];
+      }
+      tdomf_set_option_form(TDOMF_OPTION_AUTO_EDIT_LINK,$auto_edit_link,$form_id);
+      
+       //Turn On/Off Moderation
+
+      $mod = false;
+      if(isset($_POST['tdomf_moderation'])) { $mod = true; }
+      tdomf_set_option_form(TDOMF_OPTION_MODERATION,$mod,$form_id);
+
+      $tdomf_redirect = isset($_POST['tdomf_redirect']);
+      tdomf_set_option_form(TDOMF_OPTION_REDIRECT,$tdomf_redirect,$form_id);
+      
+      //Preview
+
+      $preview = false;
+      if(isset($_POST['tdomf_preview'])) { $preview = true; }
+      tdomf_set_option_form(TDOMF_OPTION_PREVIEW,$preview,$form_id);
+
+      //From email
+
+      if(trim($_POST['tdomf_from_email']) == "") {
+       	tdomf_set_option_form(TDOMF_OPTION_FROM_EMAIL,false,$form_id);
+       } else {
+        tdomf_set_option_form(TDOMF_OPTION_FROM_EMAIL,$_POST['tdomf_from_email'],$form_id);
+       }
+
+       // Form name
+       
+       if(trim($_POST['tdomf_form_name']) == "") {
+        tdomf_set_option_form(TDOMF_OPTION_NAME,"",$form_id);
+       } else {
+        tdomf_set_option_form(TDOMF_OPTION_NAME,strip_tags($_POST['tdomf_form_name']),$form_id);
+       }
+       
+       // Form description
+       
+       if(trim($_POST['tdomf_form_descp']) == "") {
+       	tdomf_set_option_form(TDOMF_OPTION_DESCRIPTION,false,$form_id);
+       } else {
+        tdomf_set_option_form(TDOMF_OPTION_DESCRIPTION,$_POST['tdomf_form_descp'],$form_id);
+       }
+       
+       // Include on "your submissions" page
+       //
+       $include = false;
+      if(isset($_POST['tdomf_include_sub'])) { $include = true; }
+      tdomf_set_option_form(TDOMF_OPTION_INCLUDED_YOUR_SUBMISSIONS,$include,$form_id);
+       
+      if(get_option(TDOMF_OPTION_YOUR_SUBMISSIONS) && $include) {
+        $message .= sprintf(__("Saved Options for Form %d. <a href='%s'>See your form &raquo</a>","tdomf"),$form_id,"users.php?page=tdomf_your_submissions#tdomf_form%d")."<br/>";
+      } else {
+        $message .= sprintf(__("Saved Options for Form %d.","tdomf"),$form_id)."<br/>";
+      }
+      
+      // widget count
+      //
+      $widget_count = 10;
+      if(isset($_POST['tdomf_widget_count'])) { $widget_count = intval($_POST['tdomf_widget_count']); }
+      if($widget_count < 1){ $widget_count = 1; }
+      tdomf_set_option_form(TDOMF_OPTION_WIDGET_INSTANCES,$widget_count,$form_id);
+      
+      //Submit page instead of post
+      //
+      $use_page = false;
+      if(isset($_POST['tdomf_use_type']) && $_POST['tdomf_use_type'] == 'page') { $use_page = true; }
+      tdomf_set_option_form(TDOMF_OPTION_SUBMIT_PAGE,$use_page,$form_id);
+
+      // Queue period
+      //
+      $tdomf_queue_period = intval($_POST['tdomf_queue_period']);
+      tdomf_set_option_form(TDOMF_OPTION_QUEUE_PERIOD,$tdomf_queue_period,$form_id);
+      
+      // Queue on all 
+      //
+      $tdomf_queue_on_all = isset($_POST['tdomf_queue_on_all']);
+      tdomf_set_option_form(TDOMF_OPTION_QUEUE_ON_ALL,$tdomf_queue_on_all,$form_id);
+      
+      // ajax
+      //
+      $tdomf_ajax = isset($_POST['tdomf_ajax']);
+      tdomf_set_option_form(TDOMF_OPTION_AJAX,$tdomf_ajax,$form_id);
+      
+      // Send moderation email even for published posts
+      //
+      $tdomf_mod_email_on_pub = isset($_POST['tdomf_mod_email_on_pub']);
+      tdomf_set_option_form(TDOMF_OPTION_MOD_EMAIL_ON_PUB,$tdomf_mod_email_on_pub,$form_id);
+      
+      // Admin users auto-publish?
+      //
+      $tdomf_publish_no_mod = isset($_POST['tdomf_user_publish_auto']);
+      tdomf_set_option_form(TDOMF_OPTION_PUBLISH_NO_MOD,$tdomf_publish_no_mod,$form_id);
+      
+      // Spam
+      //
+      $message .= tdomf_handle_spam_options_actions($form_id);
+      
+      tdomf_log_message("Options Saved for Form ID $form_id");
+       
+  } else if(isset($_REQUEST['delete'])) {
+      
+    $form_id = intval($_REQUEST['delete']);
+    
+    check_admin_referer('tdomf-delete-form-'.$form_id);
+    
+    if(tdomf_form_exists($form_id)) {
+      $count_forms = count(tdomf_get_form_ids());
+      if($count_forms > 1) {
+        if(tdomf_delete_form($form_id)) {
+           $message .= sprintf(__("Form %d deleted.<br/>","tdomf"),$form_id);
+        } else {
+          $message .= sprintf(__("Could not delete Form %d!<br/>","tdomf"),$form_id);
+        }
+      } else {
+        $message .= sprintf(__("You cannot delete the last form! There must be at least one form in the system.<br/>","tdomf"),$form_id);
+      }
+    } else {
+      $message .= sprintf(__("Form %d is not valid!<br/>","tdomf"),$form_id);
+    }
+  } else if(isset($_REQUEST['copy'])) {
+    
+    $form_id = intval($_REQUEST['copy']);
+    
+    check_admin_referer('tdomf-copy-form-'.$form_id);
+    
+    $copy_form_id = tdomf_copy_form($form_id);
+   
+    if($copy_form_id != 0) {
+      $message .= sprintf(__("Form %d copied with id %d.<br/>","tdomf"),$form_id,$copy_form_id);
+      $retValue = $copy_form_id;
+    } else {
+      $message .= sprintf(__("Failed to copy Form %d!<br/>","tdomf"),$form_id);
+    }
+        
+  } else if(isset($_REQUEST['new'])) {
+    
+    check_admin_referer('tdomf-new-form');
+    
+    $form_id = tdomf_create_form(__('New Form','tdomf'),array());
+   
+    if($form_id != 0) {
+      $message .= sprintf(__("New form created with %d.<br/>","tdomf"),$form_id);
+      $retValue = $form_id;
+    } else {
+      $message .= __("Failed to create new Form!<br/>","tdomf");
+    }
+  }
+
+   // Warnings
+
+   $message .= tdomf_get_error_messages(false);
+
+   if(!empty($message)) { ?>
+   <div id="message" class="updated fade"><p><?php echo $message; ?></p></div>
+   <?php }
+   
+   return $retValue;
+}
+
+?>
Index: admin/tdomf-log.php
===================================================================
--- admin/tdomf-log.php	(revision 169181)
+++ admin/tdomf-log.php	(working copy)
@@ -1,62 +1,62 @@
-<?php
-if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('TDOMF: You are not allowed to call this page directly.'); }
-
-////////////////////
-// Log Admin Page //
-////////////////////
-
-// Handle post actions
-//
-function tdomf_log_handle_actions() {
-   if(isset($_REQUEST['action'])) {
-      $action = $_REQUEST['action'];
-      if($action == "clear") {
-         check_admin_referer('tdomf-log-empty');
-         tdomf_clear_log(); ?>
-         <div id="message" class="updated fade"><p>
-         <?php _e("Log cleared."); ?>
-         </p></div>
-      <?php
-      }
-   }
-}
-
-// Display the log!
-//
-function tdomf_show_log_menu() {
-
-  tdomf_log_handle_actions();
-
-  ?>
-
-  <div class="wrap">
-
-    <h2><?php _e('Latest Activity', 'tdomf') ?></h2>
-
-    <table border="0"><tr>
-
-    <td>
-    <form method="post" action="<?php echo $_SERVER[REQUEST_URI]; ?>">
-    <input type="submit" name="refresh" value="Refresh" />
-    </form>
-    </td>
-
-    <td>
-    <form method="post" action="<?php echo $_SERVER[REQUEST_URI]; ?>">
-    <input type="hidden" name="action" value="clear" />
-    <input type="submit" name="clear" value="Empty Log" />
-    <?php if(function_exists('wp_nonce_field')){ wp_nonce_field('tdomf-log-empty'); } ?>
-    </form>
-    </td>
-
-    </tr></table>
-
-    <br/>
-    
-    <div style="overflow: auto; height: 500px;"> <?php echo tdomf_get_log(0); ?> </div>
-
-</div>
-
-<?php
-}
-?>
+<?php
+if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('TDOMF: You are not allowed to call this page directly.'); }
+
+////////////////////
+// Log Admin Page //
+////////////////////
+
+// Handle post actions
+//
+function tdomf_log_handle_actions() {
+   if(isset($_REQUEST['action'])) {
+      $action = $_REQUEST['action'];
+      if($action == "clear") {
+         check_admin_referer('tdomf-log-empty');
+         tdomf_clear_log(); ?>
+         <div id="message" class="updated fade"><p>
+         <?php _e("Log cleared."); ?>
+         </p></div>
+      <?php
+      }
+   }
+}
+
+// Display the log!
+//
+function tdomf_show_log_menu() {
+
+  tdomf_log_handle_actions();
+
+  ?>
+
+  <div class="wrap">
+
+    <h2><?php _e('Latest Activity', 'tdomf') ?></h2>
+
+    <table border="0"><tr>
+
+    <td>
+    <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
+    <input type="submit" name="refresh" value="Refresh" />
+    </form>
+    </td>
+
+    <td>
+    <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
+    <input type="hidden" name="action" value="clear" />
+    <input type="submit" name="clear" value="Empty Log" />
+    <?php if(function_exists('wp_nonce_field')){ wp_nonce_field('tdomf-log-empty'); } ?>
+    </form>
+    </td>
+
+    </tr></table>
+
+    <br/>
+    
+    <div style="overflow: auto; height: 500px;"> <?php echo tdomf_get_log(0); ?> </div>
+
+</div>
+
+<?php
+}
+?>
Index: admin/tdomf-options.php
===================================================================
--- admin/tdomf-options.php	(revision 169181)
+++ admin/tdomf-options.php	(working copy)
@@ -1,16 +1,16 @@
-<?php
-if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('TDOMF: You are not allowed to call this page directly.'); }
-
-function tdomf_load_options_admin_scripts() {
-    /* for tabs */
-    wp_enqueue_script( 'jquery-ui-tabs' );
-}
-add_action("load-".sanitize_title(__('TDO Mini Forms', 'tdomf'))."_page_tdomf_show_options_menu","tdomf_load_options_admin_scripts");
-
+<?php
+if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('TDOMF: You are not allowed to call this page directly.'); }
+
+function tdomf_load_options_admin_scripts() {
+    /* for tabs */
+    wp_enqueue_script( 'jquery-ui-tabs' );
+}
+add_action("load-".sanitize_title(__('TDO Mini Forms', 'tdomf'))."_page_tdomf_show_options_menu","tdomf_load_options_admin_scripts");
+
 function tdomf_options_admin_head() {
     global $wp_version;
     /* add style options and start tabs for options page */
-    if(preg_match('/tdomf_show_options_menu/',$_SERVER[REQUEST_URI])) { ?>
+    if(preg_match('/tdomf_show_options_menu/',$_SERVER['REQUEST_URI'])) { ?>
            
            <style>
             .ui-tabs-nav {
@@ -86,977 +86,977 @@
     <?php }
 }
 add_action( 'admin_head', 'tdomf_options_admin_head' );
-
-function tdomf_handle_spam_options_actions($form_id = false){
-    $message = '';
-    
-    if($form_id) {
-        
-        $tdomf_spam_overwrite = isset($_POST['tdomf_spam_overwrite']);
-        tdomf_set_option_form(TDOMF_OPTION_SPAM_OVERWRITE,$tdomf_spam_overwrite,$form_id);
-        
-        if($tdomf_spam_overwrite) {
-           
-            $tdomf_spam = isset($_POST['tdomf_spam']);
-            tdomf_set_option_form(TDOMF_OPTION_SPAM,$tdomf_spam,$form_id);
-            
-            /*
-            if($tdomf_spam) {
-                $tdomf_spam_akismet_key = $_POST['tdomf_spam_akismet_key'];
-                $tdomf_spam_akismet_key_prev = get_option(TDOMF_OPTION_SPAM_AKISMET_KEY,$form_id);
-                if(tdomf_get_option_form(TDOMF_OPTION_SPAM_AKISMET_KEY_PREV,$form_id) == false || $tdomf_spam_akismet_key_prev != $tdomf_spam_akismet_key) {
-                    if(TDOMF_DEBUG_FAKE_SPAM || (!empty($tdomf_spam_akismet_key) && tdomf_akismet_key_verify($tdomf_spam_akismet_key))){
-                       tdomf_set_option_form(TDOMF_OPTION_SPAM_AKISMET_KEY,$tdomf_spam_akismet_key,$form_id);
-                       tdomf_set_option_form(TDOMF_OPTION_SPAM_AKISMET_KEY_PREV,$tdomf_spam_akismet_key_prev,$form_id);
-                    } else {
-                      $message .= "<font color='red'>".sprintf(__("The key: %s has not been recognised by akismet. Spam protection has been disabled.","tdomf"),$tdomf_spam_akismet_key)."</font><br/>";
-                      tdomf_set_option_form(TDOMF_OPTION_SPAM,false,$form_id);
-                      // reset overwrite
-                      $tdomf_spam = false;
-                      tdomf_set_option_form(TDOMF_OPTION_SPAM_OVERWRITE,false,$form_id);
-                    }
-                }
-            }
-            */
-            
-            if($tdomf_spam) {
-                
-                /*
-                $tdomf_spam_notify = $_POST['tdomf_spam_notify'];
-                tdomf_set_option_form(TDOMF_OPTION_SPAM_NOTIFY,$tdomf_spam_notify,$form_id);
-            
-                $tdomf_spam_auto_delete = $_POST['tdomf_spam_auto_delete'];
-                if($tdomf_spam_auto_delete == "month") {
-                    tdomf_set_option_form(TDOMF_OPTION_SPAM_AUTO_DELETE,true,$form_id);
-                    tdomf_set_option_form(TDOMF_OPTION_SPAM_AUTO_DELETE_NOW,false,$form_id);
-                } else if($tdomf_spam_auto_delete == "now") {
-                    tdomf_set_option_form(TDOMF_OPTION_SPAM_AUTO_DELETE,false,$form_id);
-                    tdomf_set_option_form(TDOMF_OPTION_SPAM_AUTO_DELETE_NOW,true,$form_id);
-                } else {
-                    tdomf_set_option_form(TDOMF_OPTION_SPAM_AUTO_DELETE,false,$form_id);
-                    tdomf_set_option_form(TDOMF_OPTION_SPAM_AUTO_DELETE_NOW,false,$form_id);
-                }
-                */
-                
-                $tdomf_nospam_author = isset($_POST['tdomf_nospam_author']);
-                tdomf_set_option_form(TDOMF_OPTION_NOSPAM_AUTHOR,$tdomf_nospam_author,$form_id);
-                $tdomf_nospam_trusted = isset($_POST['tdomf_nospam_trusted']);
-                tdomf_set_option_form(TDOMF_OPTION_NOSPAM_TRUSTED,$tdomf_nospam_trusted,$form_id);
-                $tdomf_nospam_publish = isset($_POST['tdomf_nospam_publish']);
-                tdomf_set_option_form(TDOMF_OPTION_NOSPAM_PUBLISH,$tdomf_nospam_publish,$form_id);
-                $tdomf_nospam_user = isset($_POST['tdomf_nospam_user']);
-                tdomf_set_option_form(TDOMF_OPTION_NOSPAM_USER,$tdomf_nospam_user,$form_id);
-            }
-        
-        }
-    } else {
-        $tdomf_spam = isset($_POST['tdomf_spam']);
-        update_option(TDOMF_OPTION_SPAM,$tdomf_spam);
-        
-        // allow the akismet key to be set independantly of the tdomf_spam option
-        // because tdomf_spam is disabled if you don't have a key
-        
-        $tdomf_spam_akismet_key = $_POST['tdomf_spam_akismet_key'];
-        $tdomf_spam_akismet_key_prev = get_option(TDOMF_OPTION_SPAM_AKISMET_KEY);
-        if(get_option(TDOMF_OPTION_SPAM_AKISMET_KEY_PREV) == false || $tdomf_spam_akismet_key_prev != $tdomf_spam_akismet_key) {
-            if(TDOMF_DEBUG_FAKE_SPAM || (!empty($tdomf_spam_akismet_key) && tdomf_akismet_key_verify($tdomf_spam_akismet_key))){
-               update_option(TDOMF_OPTION_SPAM_AKISMET_KEY,$tdomf_spam_akismet_key);
-               update_option(TDOMF_OPTION_SPAM_AKISMET_KEY_PREV,$tdomf_spam_akismet_key_prev);
-            } else {
-              $message .= "<font color='red'>".sprintf(__("The key: %s has not been recognised by akismet. Spam protection has been disabled.","tdomf"),$tdomf_spam_akismet_key)."</font><br/>";
-              update_option(TDOMF_OPTION_SPAM,false);
-              $tdomf_spam = false;
-            }
-        }
-        
-        if($tdomf_spam) {
-            
-            $tdomf_spam_notify = $_POST['tdomf_spam_notify'];
-            update_option(TDOMF_OPTION_SPAM_NOTIFY,$tdomf_spam_notify);
-        
-            $tdomf_spam_auto_delete = $_POST['tdomf_spam_auto_delete'];
-            if($tdomf_spam_auto_delete == "month") {
-                update_option(TDOMF_OPTION_SPAM_AUTO_DELETE,true);
-                update_option(TDOMF_OPTION_SPAM_AUTO_DELETE_NOW,false);
-            } else if($tdomf_spam_auto_delete == "now") {
-                update_option(TDOMF_OPTION_SPAM_AUTO_DELETE,false);
-                update_option(TDOMF_OPTION_SPAM_AUTO_DELETE_NOW,true);
-            } else {
-                update_option(TDOMF_OPTION_SPAM_AUTO_DELETE,false);
-                update_option(TDOMF_OPTION_SPAM_AUTO_DELETE_NOW,false);
-            }
-            
-            $tdomf_nospam_author = isset($_POST['tdomf_nospam_author']);
-            update_option(TDOMF_OPTION_NOSPAM_AUTHOR,$tdomf_nospam_author);
-            $tdomf_nospam_trusted = isset($_POST['tdomf_nospam_trusted']);
-            update_option(TDOMF_OPTION_NOSPAM_TRUSTED,$tdomf_nospam_trusted );
-            $tdomf_nospam_publish = isset($_POST['tdomf_nospam_publish']);
-            update_option(TDOMF_OPTION_NOSPAM_PUBLISH,$tdomf_nospam_publish);
-            $tdomf_nospam_user = isset($_POST['tdomf_nospam_user']);
-            update_option(TDOMF_OPTION_NOSPAM_USER,$tdomf_nospam_user);
-        }
-    }
-    
-    return $message;
-}
-
-function tdomf_show_spam_options($form_id = false){
-  
-  $spam_enabled = true;
-  $tdomf_spam_global = get_option(TDOMF_OPTION_SPAM);
-  $tdomf_spam_akismet_key_global = get_option(TDOMF_OPTION_SPAM_AKISMET_KEY);
-  if(!$tdomf_spam_global || !$tdomf_spam_akismet_key_global || empty($tdomf_spam_akismet_key_global)) {
-      $spam_enabled = false;
-  }
-
-  $tdomf_spam_overwrite = false;
-  if($form_id != false && tdomf_get_option_form(TDOMF_OPTION_SPAM_OVERWRITE,$form_id)) {
-      $tdomf_spam_overwrite = true;
-  }
-  
-  if($tdomf_spam_overwrite) {
-      $tdomf_spam = tdomf_get_option_form(TDOMF_OPTION_SPAM,$form_id);
-      $tdomf_spam_akismet_key = tdomf_get_option_form(TDOMF_OPTION_SPAM_AKISMET_KEY,$form_id);
-      if($tdomf_spam_akismet_key == false || empty($tdomf_spam_akismet_key)) {
-        $tdomf_spam_akismet_key = get_option(TDOMF_OPTION_SPAM_AKISMET_KEY);
-        if($tdomf_spam_akismet_key == false || empty($tdomf_spam_akismet_key)) {
-            $tdomf_spam_akismet_key = get_option('wordpress_api_key');
-        }
-      }
-      $tdomf_spam_notify = tdomf_get_option_form(TDOMF_OPTION_SPAM_NOTIFY,$form_id);
-      $tdomf_spam_auto_delete = tdomf_get_option_form(TDOMF_OPTION_SPAM_AUTO_DELETE,$form_id); 
-      $tdomf_spam_auto_delete_now = tdomf_get_option_form(TDOMF_OPTION_SPAM_AUTO_DELETE_NOW,$form_id);
-      $tdomf_nospam_user = tdomf_get_option_form(TDOMF_OPTION_NOSPAM_USER,$form_id);
-      $tdomf_nospam_author = tdomf_get_option_form(TDOMF_OPTION_NOSPAM_AUTHOR,$form_id);
-      $tdomf_nospam_trusted = tdomf_get_option_form(TDOMF_OPTION_NOSPAM_TRUSTED,$form_id);
-      $tdomf_nospam_publish = tdomf_get_option_form(TDOMF_OPTION_NOSPAM_PUBLISH,$form_id);
-  } else {
-      $tdomf_spam = get_option(TDOMF_OPTION_SPAM);
-      $tdomf_spam_akismet_key = get_option(TDOMF_OPTION_SPAM_AKISMET_KEY);
-      if($tdomf_spam_akismet_key == false || empty($tdomf_spam_akismet_key)) {
-        $tdomf_spam_akismet_key = get_option('wordpress_api_key');
-      }
-      $tdomf_spam_notify = get_option(TDOMF_OPTION_SPAM_NOTIFY);
-      $tdomf_spam_auto_delete = get_option(TDOMF_OPTION_SPAM_AUTO_DELETE); 
-      $tdomf_spam_auto_delete_now = get_option(TDOMF_OPTION_SPAM_AUTO_DELETE_NOW);
-      $tdomf_nospam_user = get_option(TDOMF_OPTION_NOSPAM_USER);
-      $tdomf_nospam_author = get_option(TDOMF_OPTION_NOSPAM_AUTHOR);
-      $tdomf_nospam_trusted = get_option(TDOMF_OPTION_NOSPAM_TRUSTED);
-      $tdomf_nospam_publish = get_option(TDOMF_OPTION_NOSPAM_PUBLISH);
-  }
-  
-  ?>
-  
-  <?php if($form_id && !$tdomf_spam_global) { ?>
-      <p><?php _e('Spam protection has been disabled. It can be re-enabled on the general options page','tdomf'); ?></p>
-  <?php } else if ($form_id && (!$tdomf_spam_akismet_key_global || empty($tdomf_spam_akismet_key_global))) { ?>
-      <p><?php _e('There is no valid Akismet key set. You must set a valid Akismet key on the general options page','tdomf'); ?></p>
-  <?php } ?>
-
-  <script type="text/javascript">
- //<![CDATA[      
-  function tdomf_enable_spam_options() {
-    var flag = document.getElementById("tdomf_spam").checked;
-    <?php if(!$form_id) { ?>
-    /*document.getElementById("tdomf_spam_akismet_key").disabled = !flag;*/
-    document.getElementById("tdomf_spam_notify_live").disabled = !flag;
-    document.getElementById("tdomf_spam_notify_none").disabled = !flag;
-    document.getElementById("tdomf_spam_auto_delete_manual").disabled = !flag;
-    document.getElementById("tdomf_spam_auto_delete_month").disabled = !flag;
-    /*document.getElementById("tdomf_spam_auto_delete_now").disabled = !flag;*/
-    <?php } ?>
-    document.getElementById("tdomf_nospam_author").disabled = !flag;
-    document.getElementById("tdomf_nospam_trusted").disabled = !flag;
-    document.getElementById("tdomf_nospam_publish").disabled = !flag;
-    document.getElementById("tdomf_nospam_user").disabled = !flag;
-  }
- <?php if($form_id) { ?> 
-  function tdomf_enable_spam_overwrite() {
-    var flag = document.getElementById("tdomf_spam_overwrite").checked;
-    document.getElementById("tdomf_spam").disabled = !flag;
-    if(flag) {
-        tdomf_enable_spam_options();
-    } else {
-        document.getElementById("tdomf_nospam_author").disabled = !flag;
-        document.getElementById("tdomf_nospam_trusted").disabled = !flag;
-        document.getElementById("tdomf_nospam_publish").disabled = !flag;
-        document.getElementById("tdomf_nospam_user").disabled = !flag;
-    }
-  }
-  <?php } ?>
-  //-->
-  </script>
-  
-  <?php if($form_id) { ?>
-  <p>
-  <b><?php _e("Overwrite Global Spam Settings"); ?></b>
-    <input type="checkbox" name="tdomf_spam_overwrite" id="tdomf_spam_overwrite"  
-           <?php if($tdomf_spam_overwrite) echo "checked"; ?> 
-           <?php if(!$spam_enabled) { echo "disabled"; } else { ?>
-           onChange="tdomf_enable_spam_overwrite();" <?php } ?> >
-  </p>
-  
-  <p>
-  
-  <b><?php _e("Enable Spam Protection ","tdomf"); ?></b>
-    <input type="checkbox" name="tdomf_spam" id="tdomf_spam"  
-        <?php if($tdomf_spam) echo "checked"; ?>
-        <?php if(!$spam_enabled) { echo "disabled"; } else { ?>
-        onChange="tdomf_enable_spam_options();" <?php } ?> >
-  </p>
- 
-  <?php } ?>
-  
-  <?php if(!$form_id) { ?>
-
-  <b><?php _e("Enable Spam Protection ","tdomf"); ?></b>
-    <input type="checkbox" name="tdomf_spam" id="tdomf_spam"  
-        <?php if($tdomf_spam) echo "checked"; ?>
-        <?php if(empty($tdomf_spam_akismet_key)) { echo "disabled"; } else { ?>
-        onChange="tdomf_enable_spam_options();" <?php } ?> >
-  </p>
-      
-  <p>
-  <b><?php _e("Your Akismet Key","tdomf"); ?></b>
-    <input type="text" name="tdomf_spam_akismet_key" id="tdomf_spam_akismet_key" size="8" value="<?php echo $tdomf_spam_akismet_key; ?>" />
-  </p>
-  
-  <p>
-  <input type="radio" name="tdomf_spam_notify" id="tdomf_spam_notify_live" value="live"<?php if($tdomf_spam_notify == "live"){ ?> checked <?php } ?>>
-  <?php _e("Recieve normal moderation emails for suspected spam submissions","tdomf"); ?>
-  <br/>
-  
-  <input type="radio" name="tdomf_spam_notify" id="tdomf_spam_notify_none" value="none"<?php if($tdomf_spam_notify == "none" || $tdomf_spam_notify == false){ ?> checked <?php } ?>>
-  <?php _e("Recieve no notification of spam submissions","tdomf"); ?>
-  <br/>
-  </p>
- 
-  <p>
-  <input type="radio" name="tdomf_spam_auto_delete" id="tdomf_spam_auto_delete_manual" value="manual"<?php if(!$tdomf_spam_auto_delete_now && !$tdomf_spam_auto_delete) { ?> checked <?php } ?>>
-  <?php _e("Manually manage spam","tdomf"); ?>
-  <br/>         
-  <input type="radio" name="tdomf_spam_auto_delete" id="tdomf_spam_auto_delete_month" value="month"<?php if($tdomf_spam_auto_delete){ ?> checked <?php } ?>>
-  <?php _e("Automatically Delete Spam older than a month ","tdomf"); ?>
-  <!-- <br/>
-  <input type="radio" name="tdomf_spam_auto_delete" value="now" id="tdomf_spam_auto_delete_now" <?php if($tdomf_spam_auto_delete_now) { ?> checked <?php } ?>>
-  <?php _e("Automatically Delete Spam when found","tdomf"); ?> --> 
-  </p>         
-  
-  <?php } ?>
-  
-  <p>
-  <input type="checkbox" name="tdomf_nospam_user" id="tdomf_nospam_user" 
-        <?php if($tdomf_nospam_user) { ?> checked <?php } ?>
-        <?php if(!$spam_enabled) { ?> disabled <?php } ?>>
-  <?php _e("Do not check for spam if contributer or submitter is a registered user","tdomf"); ?>
-  <br/>
-  <input type="checkbox" name="tdomf_nospam_author" id="tdomf_nospam_author" 
-        <?php if($tdomf_nospam_author) { ?> checked <?php } ?>
-        <?php if(!$spam_enabled) { ?> disabled <?php } ?>>
-  <?php _e("Do not check for spam if contributer is author or submitter (registered users only)","tdomf"); ?>
-  <br/>
-  <input type="checkbox" name="tdomf_nospam_trusted" id="tdomf_nospam_trusted"
-        <?php if($tdomf_nospam_trusted) { ?> checked <?php } ?>
-        <?php if(!$spam_enabled) { ?> disabled <?php } ?>>
-  <?php _e("Do not check for spam if contributer or submitter is a trusted user","tdomf"); ?>
-  <br/>
-  <input type="checkbox" name="tdomf_nospam_publish" id="tdomf_nospam_publish"
-        <?php if($tdomf_nospam_publish) { ?> checked <?php } ?>
-        <?php if(!$spam_enabled) { ?> disabled <?php } ?>>
-  <?php _e("Do not check for spam if contributer or submitter is a user with publish capabilities","tdomf"); ?>
-  </p>
-
-  <?php if($spam_enabled) { ?>
-  <script type="text/javascript">
- //<![CDATA[          
-  tdomf_enable_spam_options();
-  <?php if($form_id) { ?>
-  tdomf_enable_spam_overwrite();
-  <?php } ?>
-  //-->
-  </script>
-  <?php } ?>
-<?php }
-
-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 }?><?php echo $user->user_login; ?><?php if(!empty($status) && $status == TDOMF_USER_STATUS_BANNED) { ?> (Banned User) <?php } ?><?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 } ?><?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
-}
-
-// Generate a dummy user
-//
-function tdomf_create_dummy_user() {
-   $rand_username = "tdomf_".tdomf_random_string(5);
-   $rand_password = tdomf_random_string(8);
-   tdomf_log_message("Attempting to create dummy user $rand_username");
-   $user_id = wp_create_user($rand_username,$rand_password);
-   $user = new WP_User($user_id);
-   if($user->has_cap("publish_posts")) {
-      $user->remove_cap("publish_posts");
-   }
-
-   $users = get_option(TDOMF_OPTION_CREATEDUSERS);
-   if($users == false) {
-     $users = array( $user_id );
-     add_option(TDOMF_OPTION_CREATEDUSERS,$users);
-   } else {
-     $users = array_merge( $users, array( $user_id ) );
-     update_option(TDOMF_OPTION_CREATEDUSERS,$users);
-   }
-   
-   update_option(TDOMF_DEFAULT_AUTHOR,$user_id);
-   tdomf_log_message("Dummy user created for default author, user id = $user_id");
-   return $user_id;
-}
-
-// Create a random string!
-// Taken from http://www.tutorialized.com/view/tutorial/PHP-Random-String-Generator/13903
-//
-function tdomf_random_string($length)
-{
-    // Error check input
-    //
-    if($length > 32) { $length = 32; }
-    if($length <= 0) { $length = 1; }
-  
-    // Generate random 32 charecter string
-    $string = md5(time());
-
-    // Position Limiting
-    $highest_startpoint = 32-$length;
-
-    // Take a random starting point in the randomly
-    // Generated String, not going any higher then $highest_startpoint
-    $tdomf_random_string = substr($string,rand(0,$highest_startpoint),$length);
-
-    return $tdomf_random_string;
-
-}
-
-// Handle actions for this form
-//
-function tdomf_handle_options_actions() {
-   global $wpdb, $wp_roles;
-
-   $message = "";
-   $retValue = false;
-   
-  if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'create_dummy_user') {
-     check_admin_referer('tdomf-create-dummy-user');
-     tdomf_create_dummy_user();
-     $message = "Dummy user created for Default Author!<br/>";
-  } else if(isset($_REQUEST['save_settings']) && !isset($_REQUEST['tdomf_form_id'])) {
-
-      check_admin_referer('tdomf-options-save');
-
-      // Default Author
-
-      $def_aut = $_POST['tdomf_def_user'];
-      if(!empty($def_aut) && !is_numeric($def_aut)) {
-          if(($userdata = get_userdatabylogin($def_aut)) != false) {
-              $def_aut = $userdata->ID;
-          } else { 
-              $message .= "<font color='red'>".sprintf(__("The user %s is not a valid user and cannot be used for Default Author","tdomf"),$def_aut)."</font><br/>";
-              $def_aut = false;              
-          }
-      }
-      update_option(TDOMF_DEFAULT_AUTHOR,$def_aut);
-
-      // Author and Submitter fix
-
-      $fix_aut = false;
-      if(isset($_POST['tdomf_autocorrect_author'])) { $fix_aut = true; }
-      update_option(TDOMF_AUTO_FIX_AUTHOR,$fix_aut);
-
-      //Auto Trust Submitter Count
-
-      $cnt = -1;
-      if(isset($_POST['tdomf_trust_count']) 
-       && !empty($_POST['tdomf_trust_count']) 
-       && is_numeric($_POST['tdomf_trust_count'])){ 
-         $cnt = intval($_POST['tdomf_trust_count']);
-      }
-      update_option(TDOMF_OPTION_TRUST_COUNT,$cnt);
-
-      //Author theme hack
-
-      $author_theme_hack = false;
-      if(isset($_POST['tdomf_author_theme_hack'])) { $author_theme_hack = true; }
-      update_option(TDOMF_OPTION_AUTHOR_THEME_HACK,$author_theme_hack);
-
-      //Add submitter info
-
-      $add_submitter = false;
-      if(isset($_POST['tdomf_add_submitter'])) { $add_submitter = true; }
-      update_option(TDOMF_OPTION_ADD_SUBMITTER,$add_submitter);
-
-      //disable errors
-      
-      $disable_errors = false;
-      if(isset($_POST['tdomf_disable_errors'])) { $disable_errors = true; }
-      update_option(TDOMF_OPTION_DISABLE_ERROR_MESSAGES,$disable_errors);
-      
-      // extra log messages
-      
-      $extra_log = false;
-      if(isset($_POST['tdomf_extra_log'])) { $extra_log = true; }
-      update_option(TDOMF_OPTION_EXTRA_LOG_MESSAGES,$extra_log);
-      
-      // your submissions
-      
-      $your_submissions = false;
-      if(isset($_POST['tdomf_your_submissions'])) { $your_submissions = true; }
-      update_option(TDOMF_OPTION_YOUR_SUBMISSIONS,$your_submissions);
-
-      // default widget max sizes
-      
-      if(tdomf_wp25()) {
-        
-        $widget_max_width = intval($_POST['widget_max_width']);
-        update_option(TDOMF_OPTION_WIDGET_MAX_WIDTH,$widget_max_width);
-        
-        $widget_max_height = intval($_POST['widget_max_height']);
-        update_option(TDOMF_OPTION_WIDGET_MAX_HEIGHT,$widget_max_height);
-        
-      }
-      
-      // verification method
-      
-      $tdomf_verify = $_POST['tdomf_verify'];
-      update_option(TDOMF_OPTION_VERIFICATION_METHOD,$tdomf_verify);
-      
-      $tdomf_form_data = $_POST['tdomf_form_data'];
-      update_option(TDOMF_OPTION_FORM_DATA_METHOD,$tdomf_form_data);
-      
-      // Show links on moderation screen
-      
-      $tdomf_mod_show_links = isset($_POST['tdomf_mod_show_links']);
-      update_option(TDOMF_OPTION_MOD_SHOW_LINKS,$tdomf_mod_show_links);
-      
-      
-      // spam options
-      
-      $message .= tdomf_handle_spam_options_actions();
-           
-
-      // log options
-      
-      $tdomf_log_max_size = intval($_POST['tdomf_log_max_size']);
-      update_option(TDOMF_OPTION_LOG_MAX_SIZE,$tdomf_log_max_size);
-      
-      $message .= "Options Saved!<br/>";
-      tdomf_log_message("Options Saved");
-      
-  } 
-  
-   // Warnings
-
-   $message .= tdomf_get_error_messages(false);
-
-   if(!empty($message)) { ?>
-   <div id="message" class="updated fade"><p><?php echo $message; ?></p></div>
-   <?php }
-   
-   return $retValue;
-}
-
-// Check for error messages with options and return a message
-//
-function tdomf_get_error_messages($show_links=true, $form_id=0) {
-  global $wpdb, $wp_roles;
-  if(!isset($wp_roles)) {
-  	$wp_roles = new WP_Roles();
-  }
-  $roles = $wp_roles->role_objects;
-  $message = "";
-  
-  #if(ini_get('register_globals') && !TDOMF_HIDE_REGISTER_GLOBAL_ERROR){
-  #  $message .= "<font color=\"red\"><strong>".__("ERROR: <em>register_globals</em> is enabled. This is a security risk and also prevents TDO Mini Forms from working.")."</strong></font>";
-  #}
-  
-  if(version_compare("5.0.0",phpversion(),">"))
-  {
-    $message .= sprintf(__("Warning: You are currently using PHP version %s. It is strongly recommended to use PHP5 with TDO Mini Forms.","tdomf"),phpversion());
-    $message .= "<br/>";
-  }
-  
-  if(get_option(TDOMF_OPTION_VERIFICATION_METHOD) == 'none') {
-    $message .= __("Warning: Form input verification is disabled. This is a potential security risk.","tdomf");
-    $message .= "<br/>";
-  }
-  
-  # Revisions disabled => editing won't work well
-  
-  if ( !constant('WP_POST_REVISIONS') ) {
-      $form_ids = tdomf_get_form_ids();
-      foreach($form_ids as $a_form_id) {
-          if(tdomf_get_option_form(TDOMF_OPTION_FORM_EDIT,$a_form_id->form_id)) {
-              $message .= __("Error: Post Revisioning is disabled, post editing will not work correctly!","tdomf");
-              $message .= "<br/>";
-              break;
-          }
-      }
-  }
-  
-    if(isset($_REQUEST['form']) || $form_id != 0) {
-        if($form_id == 0)
-        {
-            $form_id = intval($_REQUEST['form']);
-        }
-        
-        // permissions error
-        
-        if(tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE,$form_id) == false) {
-            
-            $caps = tdomf_get_option_form(TDOMF_OPTION_ALLOW_CAPS,$form_id);
-            if(is_array($caps) && empty($caps)) { $caps = false; } 
-            $users = tdomf_get_option_form(TDOMF_OPTION_ALLOW_USERS,$form_id);
-            if(is_array($users) && empty($users)) { $users = false; }
-            $publish = tdomf_get_option_form(TDOMF_OPTION_ALLOW_PUBLISH,$form_id);
-            
-            $role_count = 0;
-            $role_publish_count = 0;
-            foreach($roles as $role) {
-                if(isset($role->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM.'_'.$form_id])){
-                    $role_count++;
-                    if(isset($role->capabilities['publish_posts'])) {
-                        $role_publish_count++;
-                    }
-                }
-            }
-            
-            // if nothing set
-            
-            if($role_count == 0 && $caps == false && $users == false && $publish == false) {
-                if($show_links) {
-                    $message .= "<font color=\"red\">".sprintf(__("<b>Warning</b>: No-one has been configured to be able to access the form! <a href=\"%s\">Configure on Options Page &raquo;</a>","tdomf"),get_bloginfo('wpurl')."/wp-admin/admin.php?page=tdomf_show_form_options_menu&form=$form_id")."</font><br/>";
-                } else {
-                    $message .= "<font color=\"red\">".__("<b>Warning</b>: No-one has been configured to be able to access the form!", "tdomf")."</font><br/>";
-                }
-                tdomf_log_message("No-one has been configured to access this form ($form_id)",TDOMF_LOG_BAD);
-            } 
-            
-            // if only publish set
-
-            else if($caps == false && $users == false && $role_count == $role_publish_count && $publish == false ) {
-    
-                if($show_links) {
-                    $message .= "<font color=\"red\">".sprintf(__("<b>Warning</b>: Only users who can <i>already publish posts</i>, can see the form! <a href=\"%s\">Configure on Options Page &raquo;</a>","tdomf"),get_bloginfo('wpurl')."/wp-admin/admin.php?page=tdomf_show_form_options_menu&form=$form_id")."</font><br/>";
-                } else {
-                    $message .= "<font color=\"red\">".__("<b>Warning</b>: Only users who can <i>already publish posts</i>, can see this form!", "tdomf")."</font><br/>";
-                }
-                tdomf_log_message("Only users who can already publish can access the form ($form_id)",TDOMF_LOG_BAD);
-            }
-        }
-   
-        // form hacker modified
-        
-        $mode = tdomf_generate_default_form_mode($form_id) . '-hack';
-        
-        $curr_unmod_prev = trim(tdomf_preview_form(array('tdomf_form_id' => $form_id),$mode));
-        $org_unmod_prev = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_PREVIEW_HACK_ORIGINAL,$form_id));
-        $hacked_prev = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_PREVIEW_HACK,$form_id));
-        if($hacked_prev != false && $curr_unmod_prev != $org_unmod_prev) {
-            $message .= "<font color=\"red\">";
-            $diffs = "admin.php?page=tdomf_show_form_hacker&form=$form_id&mode=$mode&diff&form2=cur&form1=org&type=preview";
-            $form_hacker = "admin.php?page=tdomf_show_form_hacker&form=$form_id";
-            $dismiss = wp_nonce_url("admin.php?page=tdomf_show_form_hacker&form=$form_id&dismiss&type=preview",'tdomf-form-hacker');
-            $message .= sprintf(__("<b>Warning</b>: Form configuration has been changed that affect the preview output but Form Hacker has not been updated! <a href='%s'>Diff &raquo;</a> | <a href='%s'>Hack Form &raquo;</a> | <a href='%s'>Dismiss</a>","tdomf"),$diffs,$form_hacker,$dismiss);
-            $message .= "</font><br/>";
-        }
-        
-        $curr_unmod_form = trim(tdomf_generate_form($form_id,$mode));
-        $org_unmod_form = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_HACK_ORIGINAL,$form_id));
-        $hacked_form = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_HACK,$form_id));
-        if($hacked_form != false && $curr_unmod_form != $org_unmod_form) {
-            $message .= "<font color=\"red\">";
-            $diffs = "admin.php?page=tdomf_show_form_hacker&form=$form_id&mode=$mode&diff&form2=cur&form1=org";
-            $form_hacker = "admin.php?page=tdomf_show_form_hacker&form=$form_id";
-            $dismiss = wp_nonce_url("admin.php?page=tdomf_show_form_hacker&form=$form_id&dismiss",'tdomf-form-hacker');
-            $message .= sprintf(__("<b>Warning</b>: Form configuration has been changed that affect the generated form but Form Hacker has not been updated! <a href='%s'>Diff &raquo;</a> | <a href='%s'>Hack Form &raquo;</a> | <a href='%s'>Dismiss</a>","tdomf"),$diffs,$form_hacker,$dismiss);
-            $message .= "</font><br/>";
-        }
-        
-        // widget errors
-        
-        global $tdomf_form_widgets_admin_errors;
-        $mode = "new-post";        
-        if(tdomf_get_option_form(TDOMF_OPTION_SUBMIT_PAGE,$form_id)) {
-            $mode = "new-page";
-        }
-        $uri = "admin.php?page=tdomf_show_form_menu&form=".$form_id;
-        do_action('tdomf_control_form_start',$form_id,$mode);
-        $widget_order = tdomf_get_widget_order($form_id);
-        $widgets = tdomf_filter_widgets($mode, $tdomf_form_widgets_admin_errors);
-        foreach($widget_order as $w) {
-              if(isset($widgets[$w])) {
-                  $widget_message = call_user_func($widgets[$w]['cb'],$form_id,$widgets[$w]['params']);
-                  if(!empty($widget_message)) {
-                      $message .= "<font color=\"red\">" . $widget_message . sprintf(__(" <a href='%s'>Fix &raquo;</a>","tdomf"),$uri)."</font><br/>";
-                  }
-              }
-          }
-          
-         // @todo check that key is unique in custom fields
-    }
-        
-    if(get_option(TDOMF_OPTION_EXTRA_LOG_MESSAGES) && !get_option(TDOMF_OPTION_DISABLE_ERROR_MESSAGES)) {
-         $message .= "<font color=\"red\">";
-         if($show_links) {
-             $message .= sprintf(__("<b>Warning:</b> You have enabled 'Extra Debug Messages' and disabled 'Disable Error Messages'. This invokes a special mode where all PHP errors are turned on. This can lead to unexpected problems and could be considered a security leak! <a href=\"%s\">Change on the Options Page &raquo;</a>", "tdomf"),get_bloginfo('wpurl')."/wp-admin/admin.php?page=tdomf_show_options_menu");
-         } else {
-             $message .= __("<b>Warning:</b> You have enabled 'Extra Debug Messages' and disabled 'Disable Error Messages'. This invokes a special mode where all PHP errors are turned on. This can lead to unexpected problems and could be considered a security leak! This should only be used for debugging purposes.","tdomf");
-         }
-         $message .= "</font><br/>";
-    }
-    
-       $create_user_link = get_bloginfo('wpurl')."/wp-admin/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');
-    }
-	  if(get_option(TDOMF_DEFAULT_AUTHOR) == false) {
-	 	  $message .= "<font color=\"red\">".sprintf(__("<b>Error</b>: No default author set! <a href=\"%s\">Create dummy user for default author automatically &raquo;</a>","tdomf"),$create_user_link)."</font><br/>";
-	 	  tdomf_log_message("Option Default Author not set!",TDOMF_LOG_BAD);
- 	  } else {
-          
-    $def_aut = new WP_User(get_option(TDOMF_DEFAULT_AUTHOR));
-    if(empty($def_aut->data->ID)) {
-        // User does not exist! Deleting option
-        delete_option(TDOMF_DEFAULT_AUTHOR);
-        $message .= "<font color=\"red\">".sprintf(__("<b>Error</b>: Current Default Author does not exist! <a href=\"%s\">Create dummy user for default author automatically &raquo;</a>","tdomf"),$create_user_link)."</font><br/>";
-	 	    tdomf_log_message("Current Default Author does not exist! Deleting option.",TDOMF_LOG_BAD);
-      }      
- 	  	if($def_aut->has_cap("publish_posts")) {
-	 	  $message .= "<font color=\"red\">".sprintf(__("<b>Error</b>: Default author can publish posts. Default author should not be able to publish posts! <a href=\"%s\">Create a dummy user for default author automatically &raquo;</a>","tdomf"),$create_user_link)."</font><br/>";
-	 	  tdomf_log_message("Option Default Author is set to an author who can publish posts.",TDOMF_LOG_BAD);
- 	  	}
-    }
-    
-    if(function_exists('wp_get_http'))
-    {
-        $post_uri = TDOMF_URLPATH.'tdomf-form-post.php';
-        $headers = wp_get_http($post_uri,false,1);
-        if($headers != false && $headers["response"] != '200')
-        {
-             $message .= "<font color=\"red\">";
-             $message .= sprintf(__("<b>Error</b>: Got a %d error when checking <a href=\"%s\">%s</a>! This will prevent posts from being submitted. The permissions may be wrong on the tdo-mini-forms folder.","tdomf"),$headers["response"], $post_uri, $post_uri);
-             $message .= "</font><br/>";
-             tdomf_log_message("Did not receive a 200 response when checking $post_uri:<pre>".var_export($headers,true)."</pre>",TDOMF_LOG_ERROR);
-        }
-
-        $ajax_uri = TDOMF_URLPATH.'tdomf-form-ajax.php';
-        $headers = wp_get_http($ajax_uri,false,1);
-        if($headers != false && $headers["response"] != '200')
-        {
-             $message .= "<font color=\"red\">";
-             $message .= sprintf(__("<b>Error</b>: Got a %d error when checking <a href=\"%s\">%s</a>! This will prevent forms that use AJAX from submitting posts. The permissions may be wrong on the tdo-mini-forms folder.","tdomf"),$headers["response"], $ajax_uri, $ajax_uri);
-             $message .= "</font><br/>";
-             tdomf_log_message("Did not receive a 200 response when checking $ajax_uri:<pre>".var_export($headers,true)."</pre>",TDOMF_LOG_ERROR);
-        }
-        
-        $css_uri = TDOMF_URLPATH.'tdomf-style-form.css';
-        $headers = wp_get_http($css_uri,false,1);
-        if($headers != false && $headers["response"] != '200')
-        {
-             $message .= "<font color=\"red\">";
-             $message .= sprintf(__("<b>Error</b>: Got a %d error when checking <a href=\"%s\">%s</a>! This will make your forms, by default, look very ugly. The permissions may be wrong on the tdo-mini-forms folder.","tdomf"),$headers["response"], $css_uri, $css_uri);
-             $message .= "</font><br/>";
-             tdomf_log_message("Did not receive a 200 response when checking $css_uri:<pre>".var_export($headers,true)."</pre>",TDOMF_LOG_ERROR);
-        }
-    }
-    
-    return $message;
-}
-
-?>
+
+function tdomf_handle_spam_options_actions($form_id = false){
+    $message = '';
+    
+    if($form_id) {
+        
+        $tdomf_spam_overwrite = isset($_POST['tdomf_spam_overwrite']);
+        tdomf_set_option_form(TDOMF_OPTION_SPAM_OVERWRITE,$tdomf_spam_overwrite,$form_id);
+        
+        if($tdomf_spam_overwrite) {
+           
+            $tdomf_spam = isset($_POST['tdomf_spam']);
+            tdomf_set_option_form(TDOMF_OPTION_SPAM,$tdomf_spam,$form_id);
+            
+            /*
+            if($tdomf_spam) {
+                $tdomf_spam_akismet_key = $_POST['tdomf_spam_akismet_key'];
+                $tdomf_spam_akismet_key_prev = get_option(TDOMF_OPTION_SPAM_AKISMET_KEY,$form_id);
+                if(tdomf_get_option_form(TDOMF_OPTION_SPAM_AKISMET_KEY_PREV,$form_id) == false || $tdomf_spam_akismet_key_prev != $tdomf_spam_akismet_key) {
+                    if(TDOMF_DEBUG_FAKE_SPAM || (!empty($tdomf_spam_akismet_key) && tdomf_akismet_key_verify($tdomf_spam_akismet_key))){
+                       tdomf_set_option_form(TDOMF_OPTION_SPAM_AKISMET_KEY,$tdomf_spam_akismet_key,$form_id);
+                       tdomf_set_option_form(TDOMF_OPTION_SPAM_AKISMET_KEY_PREV,$tdomf_spam_akismet_key_prev,$form_id);
+                    } else {
+                      $message .= "<font color='red'>".sprintf(__("The key: %s has not been recognised by akismet. Spam protection has been disabled.","tdomf"),$tdomf_spam_akismet_key)."</font><br/>";
+                      tdomf_set_option_form(TDOMF_OPTION_SPAM,false,$form_id);
+                      // reset overwrite
+                      $tdomf_spam = false;
+                      tdomf_set_option_form(TDOMF_OPTION_SPAM_OVERWRITE,false,$form_id);
+                    }
+                }
+            }
+            */
+            
+            if($tdomf_spam) {
+                
+                /*
+                $tdomf_spam_notify = $_POST['tdomf_spam_notify'];
+                tdomf_set_option_form(TDOMF_OPTION_SPAM_NOTIFY,$tdomf_spam_notify,$form_id);
+            
+                $tdomf_spam_auto_delete = $_POST['tdomf_spam_auto_delete'];
+                if($tdomf_spam_auto_delete == "month") {
+                    tdomf_set_option_form(TDOMF_OPTION_SPAM_AUTO_DELETE,true,$form_id);
+                    tdomf_set_option_form(TDOMF_OPTION_SPAM_AUTO_DELETE_NOW,false,$form_id);
+                } else if($tdomf_spam_auto_delete == "now") {
+                    tdomf_set_option_form(TDOMF_OPTION_SPAM_AUTO_DELETE,false,$form_id);
+                    tdomf_set_option_form(TDOMF_OPTION_SPAM_AUTO_DELETE_NOW,true,$form_id);
+                } else {
+                    tdomf_set_option_form(TDOMF_OPTION_SPAM_AUTO_DELETE,false,$form_id);
+                    tdomf_set_option_form(TDOMF_OPTION_SPAM_AUTO_DELETE_NOW,false,$form_id);
+                }
+                */
+                
+                $tdomf_nospam_author = isset($_POST['tdomf_nospam_author']);
+                tdomf_set_option_form(TDOMF_OPTION_NOSPAM_AUTHOR,$tdomf_nospam_author,$form_id);
+                $tdomf_nospam_trusted = isset($_POST['tdomf_nospam_trusted']);
+                tdomf_set_option_form(TDOMF_OPTION_NOSPAM_TRUSTED,$tdomf_nospam_trusted,$form_id);
+                $tdomf_nospam_publish = isset($_POST['tdomf_nospam_publish']);
+                tdomf_set_option_form(TDOMF_OPTION_NOSPAM_PUBLISH,$tdomf_nospam_publish,$form_id);
+                $tdomf_nospam_user = isset($_POST['tdomf_nospam_user']);
+                tdomf_set_option_form(TDOMF_OPTION_NOSPAM_USER,$tdomf_nospam_user,$form_id);
+            }
+        
+        }
+    } else {
+        $tdomf_spam = isset($_POST['tdomf_spam']);
+        update_option(TDOMF_OPTION_SPAM,$tdomf_spam);
+        
+        // allow the akismet key to be set independantly of the tdomf_spam option
+        // because tdomf_spam is disabled if you don't have a key
+        
+        $tdomf_spam_akismet_key = $_POST['tdomf_spam_akismet_key'];
+        $tdomf_spam_akismet_key_prev = get_option(TDOMF_OPTION_SPAM_AKISMET_KEY);
+        if(get_option(TDOMF_OPTION_SPAM_AKISMET_KEY_PREV) == false || $tdomf_spam_akismet_key_prev != $tdomf_spam_akismet_key) {
+            if(TDOMF_DEBUG_FAKE_SPAM || (!empty($tdomf_spam_akismet_key) && tdomf_akismet_key_verify($tdomf_spam_akismet_key))){
+               update_option(TDOMF_OPTION_SPAM_AKISMET_KEY,$tdomf_spam_akismet_key);
+               update_option(TDOMF_OPTION_SPAM_AKISMET_KEY_PREV,$tdomf_spam_akismet_key_prev);
+            } else {
+              $message .= "<font color='red'>".sprintf(__("The key: %s has not been recognised by akismet. Spam protection has been disabled.","tdomf"),$tdomf_spam_akismet_key)."</font><br/>";
+              update_option(TDOMF_OPTION_SPAM,false);
+              $tdomf_spam = false;
+            }
+        }
+        
+        if($tdomf_spam) {
+            
+            $tdomf_spam_notify = $_POST['tdomf_spam_notify'];
+            update_option(TDOMF_OPTION_SPAM_NOTIFY,$tdomf_spam_notify);
+        
+            $tdomf_spam_auto_delete = $_POST['tdomf_spam_auto_delete'];
+            if($tdomf_spam_auto_delete == "month") {
+                update_option(TDOMF_OPTION_SPAM_AUTO_DELETE,true);
+                update_option(TDOMF_OPTION_SPAM_AUTO_DELETE_NOW,false);
+            } else if($tdomf_spam_auto_delete == "now") {
+                update_option(TDOMF_OPTION_SPAM_AUTO_DELETE,false);
+                update_option(TDOMF_OPTION_SPAM_AUTO_DELETE_NOW,true);
+            } else {
+                update_option(TDOMF_OPTION_SPAM_AUTO_DELETE,false);
+                update_option(TDOMF_OPTION_SPAM_AUTO_DELETE_NOW,false);
+            }
+            
+            $tdomf_nospam_author = isset($_POST['tdomf_nospam_author']);
+            update_option(TDOMF_OPTION_NOSPAM_AUTHOR,$tdomf_nospam_author);
+            $tdomf_nospam_trusted = isset($_POST['tdomf_nospam_trusted']);
+            update_option(TDOMF_OPTION_NOSPAM_TRUSTED,$tdomf_nospam_trusted );
+            $tdomf_nospam_publish = isset($_POST['tdomf_nospam_publish']);
+            update_option(TDOMF_OPTION_NOSPAM_PUBLISH,$tdomf_nospam_publish);
+            $tdomf_nospam_user = isset($_POST['tdomf_nospam_user']);
+            update_option(TDOMF_OPTION_NOSPAM_USER,$tdomf_nospam_user);
+        }
+    }
+    
+    return $message;
+}
+
+function tdomf_show_spam_options($form_id = false){
+  
+  $spam_enabled = true;
+  $tdomf_spam_global = get_option(TDOMF_OPTION_SPAM);
+  $tdomf_spam_akismet_key_global = get_option(TDOMF_OPTION_SPAM_AKISMET_KEY);
+  if(!$tdomf_spam_global || !$tdomf_spam_akismet_key_global || empty($tdomf_spam_akismet_key_global)) {
+      $spam_enabled = false;
+  }
+
+  $tdomf_spam_overwrite = false;
+  if($form_id != false && tdomf_get_option_form(TDOMF_OPTION_SPAM_OVERWRITE,$form_id)) {
+      $tdomf_spam_overwrite = true;
+  }
+  
+  if($tdomf_spam_overwrite) {
+      $tdomf_spam = tdomf_get_option_form(TDOMF_OPTION_SPAM,$form_id);
+      $tdomf_spam_akismet_key = tdomf_get_option_form(TDOMF_OPTION_SPAM_AKISMET_KEY,$form_id);
+      if($tdomf_spam_akismet_key == false || empty($tdomf_spam_akismet_key)) {
+        $tdomf_spam_akismet_key = get_option(TDOMF_OPTION_SPAM_AKISMET_KEY);
+        if($tdomf_spam_akismet_key == false || empty($tdomf_spam_akismet_key)) {
+            $tdomf_spam_akismet_key = get_option('wordpress_api_key');
+        }
+      }
+      $tdomf_spam_notify = tdomf_get_option_form(TDOMF_OPTION_SPAM_NOTIFY,$form_id);
+      $tdomf_spam_auto_delete = tdomf_get_option_form(TDOMF_OPTION_SPAM_AUTO_DELETE,$form_id); 
+      $tdomf_spam_auto_delete_now = tdomf_get_option_form(TDOMF_OPTION_SPAM_AUTO_DELETE_NOW,$form_id);
+      $tdomf_nospam_user = tdomf_get_option_form(TDOMF_OPTION_NOSPAM_USER,$form_id);
+      $tdomf_nospam_author = tdomf_get_option_form(TDOMF_OPTION_NOSPAM_AUTHOR,$form_id);
+      $tdomf_nospam_trusted = tdomf_get_option_form(TDOMF_OPTION_NOSPAM_TRUSTED,$form_id);
+      $tdomf_nospam_publish = tdomf_get_option_form(TDOMF_OPTION_NOSPAM_PUBLISH,$form_id);
+  } else {
+      $tdomf_spam = get_option(TDOMF_OPTION_SPAM);
+      $tdomf_spam_akismet_key = get_option(TDOMF_OPTION_SPAM_AKISMET_KEY);
+      if($tdomf_spam_akismet_key == false || empty($tdomf_spam_akismet_key)) {
+        $tdomf_spam_akismet_key = get_option('wordpress_api_key');
+      }
+      $tdomf_spam_notify = get_option(TDOMF_OPTION_SPAM_NOTIFY);
+      $tdomf_spam_auto_delete = get_option(TDOMF_OPTION_SPAM_AUTO_DELETE); 
+      $tdomf_spam_auto_delete_now = get_option(TDOMF_OPTION_SPAM_AUTO_DELETE_NOW);
+      $tdomf_nospam_user = get_option(TDOMF_OPTION_NOSPAM_USER);
+      $tdomf_nospam_author = get_option(TDOMF_OPTION_NOSPAM_AUTHOR);
+      $tdomf_nospam_trusted = get_option(TDOMF_OPTION_NOSPAM_TRUSTED);
+      $tdomf_nospam_publish = get_option(TDOMF_OPTION_NOSPAM_PUBLISH);
+  }
+  
+  ?>
+  
+  <?php if($form_id && !$tdomf_spam_global) { ?>
+      <p><?php _e('Spam protection has been disabled. It can be re-enabled on the general options page','tdomf'); ?></p>
+  <?php } else if ($form_id && (!$tdomf_spam_akismet_key_global || empty($tdomf_spam_akismet_key_global))) { ?>
+      <p><?php _e('There is no valid Akismet key set. You must set a valid Akismet key on the general options page','tdomf'); ?></p>
+  <?php } ?>
+
+  <script type="text/javascript">
+ //<![CDATA[      
+  function tdomf_enable_spam_options() {
+    var flag = document.getElementById("tdomf_spam").checked;
+    <?php if(!$form_id) { ?>
+    /*document.getElementById("tdomf_spam_akismet_key").disabled = !flag;*/
+    document.getElementById("tdomf_spam_notify_live").disabled = !flag;
+    document.getElementById("tdomf_spam_notify_none").disabled = !flag;
+    document.getElementById("tdomf_spam_auto_delete_manual").disabled = !flag;
+    document.getElementById("tdomf_spam_auto_delete_month").disabled = !flag;
+    /*document.getElementById("tdomf_spam_auto_delete_now").disabled = !flag;*/
+    <?php } ?>
+    document.getElementById("tdomf_nospam_author").disabled = !flag;
+    document.getElementById("tdomf_nospam_trusted").disabled = !flag;
+    document.getElementById("tdomf_nospam_publish").disabled = !flag;
+    document.getElementById("tdomf_nospam_user").disabled = !flag;
+  }
+ <?php if($form_id) { ?> 
+  function tdomf_enable_spam_overwrite() {
+    var flag = document.getElementById("tdomf_spam_overwrite").checked;
+    document.getElementById("tdomf_spam").disabled = !flag;
+    if(flag) {
+        tdomf_enable_spam_options();
+    } else {
+        document.getElementById("tdomf_nospam_author").disabled = !flag;
+        document.getElementById("tdomf_nospam_trusted").disabled = !flag;
+        document.getElementById("tdomf_nospam_publish").disabled = !flag;
+        document.getElementById("tdomf_nospam_user").disabled = !flag;
+    }
+  }
+  <?php } ?>
+  //-->
+  </script>
+  
+  <?php if($form_id) { ?>
+  <p>
+  <b><?php _e("Overwrite Global Spam Settings"); ?></b>
+    <input type="checkbox" name="tdomf_spam_overwrite" id="tdomf_spam_overwrite"  
+           <?php if($tdomf_spam_overwrite) echo "checked"; ?> 
+           <?php if(!$spam_enabled) { echo "disabled"; } else { ?>
+           onChange="tdomf_enable_spam_overwrite();" <?php } ?> >
+  </p>
+  
+  <p>
+  
+  <b><?php _e("Enable Spam Protection ","tdomf"); ?></b>
+    <input type="checkbox" name="tdomf_spam" id="tdomf_spam"  
+        <?php if($tdomf_spam) echo "checked"; ?>
+        <?php if(!$spam_enabled) { echo "disabled"; } else { ?>
+        onChange="tdomf_enable_spam_options();" <?php } ?> >
+  </p>
+ 
+  <?php } ?>
+  
+  <?php if(!$form_id) { ?>
+
+  <b><?php _e("Enable Spam Protection ","tdomf"); ?></b>
+    <input type="checkbox" name="tdomf_spam" id="tdomf_spam"  
+        <?php if($tdomf_spam) echo "checked"; ?>
+        <?php if(empty($tdomf_spam_akismet_key)) { echo "disabled"; } else { ?>
+        onChange="tdomf_enable_spam_options();" <?php } ?> >
+  </p>
+      
+  <p>
+  <b><?php _e("Your Akismet Key","tdomf"); ?></b>
+    <input type="text" name="tdomf_spam_akismet_key" id="tdomf_spam_akismet_key" size="8" value="<?php echo $tdomf_spam_akismet_key; ?>" />
+  </p>
+  
+  <p>
+  <input type="radio" name="tdomf_spam_notify" id="tdomf_spam_notify_live" value="live"<?php if($tdomf_spam_notify == "live"){ ?> checked <?php } ?>>
+  <?php _e("Recieve normal moderation emails for suspected spam submissions","tdomf"); ?>
+  <br/>
+  
+  <input type="radio" name="tdomf_spam_notify" id="tdomf_spam_notify_none" value="none"<?php if($tdomf_spam_notify == "none" || $tdomf_spam_notify == false){ ?> checked <?php } ?>>
+  <?php _e("Recieve no notification of spam submissions","tdomf"); ?>
+  <br/>
+  </p>
+ 
+  <p>
+  <input type="radio" name="tdomf_spam_auto_delete" id="tdomf_spam_auto_delete_manual" value="manual"<?php if(!$tdomf_spam_auto_delete_now && !$tdomf_spam_auto_delete) { ?> checked <?php } ?>>
+  <?php _e("Manually manage spam","tdomf"); ?>
+  <br/>         
+  <input type="radio" name="tdomf_spam_auto_delete" id="tdomf_spam_auto_delete_month" value="month"<?php if($tdomf_spam_auto_delete){ ?> checked <?php } ?>>
+  <?php _e("Automatically Delete Spam older than a month ","tdomf"); ?>
+  <!-- <br/>
+  <input type="radio" name="tdomf_spam_auto_delete" value="now" id="tdomf_spam_auto_delete_now" <?php if($tdomf_spam_auto_delete_now) { ?> checked <?php } ?>>
+  <?php _e("Automatically Delete Spam when found","tdomf"); ?> --> 
+  </p>         
+  
+  <?php } ?>
+  
+  <p>
+  <input type="checkbox" name="tdomf_nospam_user" id="tdomf_nospam_user" 
+        <?php if($tdomf_nospam_user) { ?> checked <?php } ?>
+        <?php if(!$spam_enabled) { ?> disabled <?php } ?>>
+  <?php _e("Do not check for spam if contributer or submitter is a registered user","tdomf"); ?>
+  <br/>
+  <input type="checkbox" name="tdomf_nospam_author" id="tdomf_nospam_author" 
+        <?php if($tdomf_nospam_author) { ?> checked <?php } ?>
+        <?php if(!$spam_enabled) { ?> disabled <?php } ?>>
+  <?php _e("Do not check for spam if contributer is author or submitter (registered users only)","tdomf"); ?>
+  <br/>
+  <input type="checkbox" name="tdomf_nospam_trusted" id="tdomf_nospam_trusted"
+        <?php if($tdomf_nospam_trusted) { ?> checked <?php } ?>
+        <?php if(!$spam_enabled) { ?> disabled <?php } ?>>
+  <?php _e("Do not check for spam if contributer or submitter is a trusted user","tdomf"); ?>
+  <br/>
+  <input type="checkbox" name="tdomf_nospam_publish" id="tdomf_nospam_publish"
+        <?php if($tdomf_nospam_publish) { ?> checked <?php } ?>
+        <?php if(!$spam_enabled) { ?> disabled <?php } ?>>
+  <?php _e("Do not check for spam if contributer or submitter is a user with publish capabilities","tdomf"); ?>
+  </p>
+
+  <?php if($spam_enabled) { ?>
+  <script type="text/javascript">
+ //<![CDATA[          
+  tdomf_enable_spam_options();
+  <?php if($form_id) { ?>
+  tdomf_enable_spam_overwrite();
+  <?php } ?>
+  //-->
+  </script>
+  <?php } ?>
+<?php }
+
+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 }?><?php echo $user->user_login; ?><?php if(!empty($status) && $status == TDOMF_USER_STATUS_BANNED) { ?> (Banned User) <?php } ?><?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 } ?><?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
+}
+
+// Generate a dummy user
+//
+function tdomf_create_dummy_user() {
+   $rand_username = "tdomf_".tdomf_random_string(5);
+   $rand_password = tdomf_random_string(8);
+   tdomf_log_message("Attempting to create dummy user $rand_username");
+   $user_id = wp_create_user($rand_username,$rand_password);
+   $user = new WP_User($user_id);
+   if($user->has_cap("publish_posts")) {
+      $user->remove_cap("publish_posts");
+   }
+
+   $users = get_option(TDOMF_OPTION_CREATEDUSERS);
+   if($users == false) {
+     $users = array( $user_id );
+     add_option(TDOMF_OPTION_CREATEDUSERS,$users);
+   } else {
+     $users = array_merge( $users, array( $user_id ) );
+     update_option(TDOMF_OPTION_CREATEDUSERS,$users);
+   }
+   
+   update_option(TDOMF_DEFAULT_AUTHOR,$user_id);
+   tdomf_log_message("Dummy user created for default author, user id = $user_id");
+   return $user_id;
+}
+
+// Create a random string!
+// Taken from http://www.tutorialized.com/view/tutorial/PHP-Random-String-Generator/13903
+//
+function tdomf_random_string($length)
+{
+    // Error check input
+    //
+    if($length > 32) { $length = 32; }
+    if($length <= 0) { $length = 1; }
+  
+    // Generate random 32 charecter string
+    $string = md5(time());
+
+    // Position Limiting
+    $highest_startpoint = 32-$length;
+
+    // Take a random starting point in the randomly
+    // Generated String, not going any higher then $highest_startpoint
+    $tdomf_random_string = substr($string,rand(0,$highest_startpoint),$length);
+
+    return $tdomf_random_string;
+
+}
+
+// Handle actions for this form
+//
+function tdomf_handle_options_actions() {
+   global $wpdb, $wp_roles;
+
+   $message = "";
+   $retValue = false;
+   
+  if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'create_dummy_user') {
+     check_admin_referer('tdomf-create-dummy-user');
+     tdomf_create_dummy_user();
+     $message = "Dummy user created for Default Author!<br/>";
+  } else if(isset($_REQUEST['save_settings']) && !isset($_REQUEST['tdomf_form_id'])) {
+
+      check_admin_referer('tdomf-options-save');
+
+      // Default Author
+
+      $def_aut = $_POST['tdomf_def_user'];
+      if(!empty($def_aut) && !is_numeric($def_aut)) {
+          if(($userdata = get_userdatabylogin($def_aut)) != false) {
+              $def_aut = $userdata->ID;
+          } else { 
+              $message .= "<font color='red'>".sprintf(__("The user %s is not a valid user and cannot be used for Default Author","tdomf"),$def_aut)."</font><br/>";
+              $def_aut = false;              
+          }
+      }
+      update_option(TDOMF_DEFAULT_AUTHOR,$def_aut);
+
+      // Author and Submitter fix
+
+      $fix_aut = false;
+      if(isset($_POST['tdomf_autocorrect_author'])) { $fix_aut = true; }
+      update_option(TDOMF_AUTO_FIX_AUTHOR,$fix_aut);
+
+      //Auto Trust Submitter Count
+
+      $cnt = -1;
+      if(isset($_POST['tdomf_trust_count']) 
+       && !empty($_POST['tdomf_trust_count']) 
+       && is_numeric($_POST['tdomf_trust_count'])){ 
+         $cnt = intval($_POST['tdomf_trust_count']);
+      }
+      update_option(TDOMF_OPTION_TRUST_COUNT,$cnt);
+
+      //Author theme hack
+
+      $author_theme_hack = false;
+      if(isset($_POST['tdomf_author_theme_hack'])) { $author_theme_hack = true; }
+      update_option(TDOMF_OPTION_AUTHOR_THEME_HACK,$author_theme_hack);
+
+      //Add submitter info
+
+      $add_submitter = false;
+      if(isset($_POST['tdomf_add_submitter'])) { $add_submitter = true; }
+      update_option(TDOMF_OPTION_ADD_SUBMITTER,$add_submitter);
+
+      //disable errors
+      
+      $disable_errors = false;
+      if(isset($_POST['tdomf_disable_errors'])) { $disable_errors = true; }
+      update_option(TDOMF_OPTION_DISABLE_ERROR_MESSAGES,$disable_errors);
+      
+      // extra log messages
+      
+      $extra_log = false;
+      if(isset($_POST['tdomf_extra_log'])) { $extra_log = true; }
+      update_option(TDOMF_OPTION_EXTRA_LOG_MESSAGES,$extra_log);
+      
+      // your submissions
+      
+      $your_submissions = false;
+      if(isset($_POST['tdomf_your_submissions'])) { $your_submissions = true; }
+      update_option(TDOMF_OPTION_YOUR_SUBMISSIONS,$your_submissions);
+
+      // default widget max sizes
+      
+      if(tdomf_wp25()) {
+        
+        $widget_max_width = intval($_POST['widget_max_width']);
+        update_option(TDOMF_OPTION_WIDGET_MAX_WIDTH,$widget_max_width);
+        
+        $widget_max_height = intval($_POST['widget_max_height']);
+        update_option(TDOMF_OPTION_WIDGET_MAX_HEIGHT,$widget_max_height);
+        
+      }
+      
+      // verification method
+      
+      $tdomf_verify = $_POST['tdomf_verify'];
+      update_option(TDOMF_OPTION_VERIFICATION_METHOD,$tdomf_verify);
+      
+      $tdomf_form_data = $_POST['tdomf_form_data'];
+      update_option(TDOMF_OPTION_FORM_DATA_METHOD,$tdomf_form_data);
+      
+      // Show links on moderation screen
+      
+      $tdomf_mod_show_links = isset($_POST['tdomf_mod_show_links']);
+      update_option(TDOMF_OPTION_MOD_SHOW_LINKS,$tdomf_mod_show_links);
+      
+      
+      // spam options
+      
+      $message .= tdomf_handle_spam_options_actions();
+           
+
+      // log options
+      
+      $tdomf_log_max_size = intval($_POST['tdomf_log_max_size']);
+      update_option(TDOMF_OPTION_LOG_MAX_SIZE,$tdomf_log_max_size);
+      
+      $message .= "Options Saved!<br/>";
+      tdomf_log_message("Options Saved");
+      
+  } 
+  
+   // Warnings
+
+   $message .= tdomf_get_error_messages(false);
+
+   if(!empty($message)) { ?>
+   <div id="message" class="updated fade"><p><?php echo $message; ?></p></div>
+   <?php }
+   
+   return $retValue;
+}
+
+// Check for error messages with options and return a message
+//
+function tdomf_get_error_messages($show_links=true, $form_id=0) {
+  global $wpdb, $wp_roles;
+  if(!isset($wp_roles)) {
+  	$wp_roles = new WP_Roles();
+  }
+  $roles = $wp_roles->role_objects;
+  $message = "";
+  
+  #if(ini_get('register_globals') && !TDOMF_HIDE_REGISTER_GLOBAL_ERROR){
+  #  $message .= "<font color=\"red\"><strong>".__("ERROR: <em>register_globals</em> is enabled. This is a security risk and also prevents TDO Mini Forms from working.")."</strong></font>";
+  #}
+  
+  if(version_compare("5.0.0",phpversion(),">"))
+  {
+    $message .= sprintf(__("Warning: You are currently using PHP version %s. It is strongly recommended to use PHP5 with TDO Mini Forms.","tdomf"),phpversion());
+    $message .= "<br/>";
+  }
+  
+  if(get_option(TDOMF_OPTION_VERIFICATION_METHOD) == 'none') {
+    $message .= __("Warning: Form input verification is disabled. This is a potential security risk.","tdomf");
+    $message .= "<br/>";
+  }
+  
+  # Revisions disabled => editing won't work well
+  
+  if ( !constant('WP_POST_REVISIONS') ) {
+      $form_ids = tdomf_get_form_ids();
+      foreach($form_ids as $a_form_id) {
+          if(tdomf_get_option_form(TDOMF_OPTION_FORM_EDIT,$a_form_id->form_id)) {
+              $message .= __("Error: Post Revisioning is disabled, post editing will not work correctly!","tdomf");
+              $message .= "<br/>";
+              break;
+          }
+      }
+  }
+  
+    if(isset($_REQUEST['form']) || $form_id != 0) {
+        if($form_id == 0)
+        {
+            $form_id = intval($_REQUEST['form']);
+        }
+        
+        // permissions error
+        
+        if(tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE,$form_id) == false) {
+            
+            $caps = tdomf_get_option_form(TDOMF_OPTION_ALLOW_CAPS,$form_id);
+            if(is_array($caps) && empty($caps)) { $caps = false; } 
+            $users = tdomf_get_option_form(TDOMF_OPTION_ALLOW_USERS,$form_id);
+            if(is_array($users) && empty($users)) { $users = false; }
+            $publish = tdomf_get_option_form(TDOMF_OPTION_ALLOW_PUBLISH,$form_id);
+            
+            $role_count = 0;
+            $role_publish_count = 0;
+            foreach($roles as $role) {
+                if(isset($role->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM.'_'.$form_id])){
+                    $role_count++;
+                    if(isset($role->capabilities['publish_posts'])) {
+                        $role_publish_count++;
+                    }
+                }
+            }
+            
+            // if nothing set
+            
+            if($role_count == 0 && $caps == false && $users == false && $publish == false) {
+                if($show_links) {
+                    $message .= "<font color=\"red\">".sprintf(__("<b>Warning</b>: No-one has been configured to be able to access the form! <a href=\"%s\">Configure on Options Page &raquo;</a>","tdomf"),get_bloginfo('wpurl')."/wp-admin/admin.php?page=tdomf_show_form_options_menu&form=$form_id")."</font><br/>";
+                } else {
+                    $message .= "<font color=\"red\">".__("<b>Warning</b>: No-one has been configured to be able to access the form!", "tdomf")."</font><br/>";
+                }
+                tdomf_log_message("No-one has been configured to access this form ($form_id)",TDOMF_LOG_BAD);
+            } 
+            
+            // if only publish set
+
+            else if($caps == false && $users == false && $role_count == $role_publish_count && $publish == false ) {
+    
+                if($show_links) {
+                    $message .= "<font color=\"red\">".sprintf(__("<b>Warning</b>: Only users who can <i>already publish posts</i>, can see the form! <a href=\"%s\">Configure on Options Page &raquo;</a>","tdomf"),get_bloginfo('wpurl')."/wp-admin/admin.php?page=tdomf_show_form_options_menu&form=$form_id")."</font><br/>";
+                } else {
+                    $message .= "<font color=\"red\">".__("<b>Warning</b>: Only users who can <i>already publish posts</i>, can see this form!", "tdomf")."</font><br/>";
+                }
+                tdomf_log_message("Only users who can already publish can access the form ($form_id)",TDOMF_LOG_BAD);
+            }
+        }
+   
+        // form hacker modified
+        
+        $mode = tdomf_generate_default_form_mode($form_id) . '-hack';
+        
+        $curr_unmod_prev = trim(tdomf_preview_form(array('tdomf_form_id' => $form_id),$mode));
+        $org_unmod_prev = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_PREVIEW_HACK_ORIGINAL,$form_id));
+        $hacked_prev = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_PREVIEW_HACK,$form_id));
+        if($hacked_prev != false && $curr_unmod_prev != $org_unmod_prev) {
+            $message .= "<font color=\"red\">";
+            $diffs = "admin.php?page=tdomf_show_form_hacker&form=$form_id&mode=$mode&diff&form2=cur&form1=org&type=preview";
+            $form_hacker = "admin.php?page=tdomf_show_form_hacker&form=$form_id";
+            $dismiss = wp_nonce_url("admin.php?page=tdomf_show_form_hacker&form=$form_id&dismiss&type=preview",'tdomf-form-hacker');
+            $message .= sprintf(__("<b>Warning</b>: Form configuration has been changed that affect the preview output but Form Hacker has not been updated! <a href='%s'>Diff &raquo;</a> | <a href='%s'>Hack Form &raquo;</a> | <a href='%s'>Dismiss</a>","tdomf"),$diffs,$form_hacker,$dismiss);
+            $message .= "</font><br/>";
+        }
+        
+        $curr_unmod_form = trim(tdomf_generate_form($form_id,$mode));
+        $org_unmod_form = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_HACK_ORIGINAL,$form_id));
+        $hacked_form = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_HACK,$form_id));
+        if($hacked_form != false && $curr_unmod_form != $org_unmod_form) {
+            $message .= "<font color=\"red\">";
+            $diffs = "admin.php?page=tdomf_show_form_hacker&form=$form_id&mode=$mode&diff&form2=cur&form1=org";
+            $form_hacker = "admin.php?page=tdomf_show_form_hacker&form=$form_id";
+            $dismiss = wp_nonce_url("admin.php?page=tdomf_show_form_hacker&form=$form_id&dismiss",'tdomf-form-hacker');
+            $message .= sprintf(__("<b>Warning</b>: Form configuration has been changed that affect the generated form but Form Hacker has not been updated! <a href='%s'>Diff &raquo;</a> | <a href='%s'>Hack Form &raquo;</a> | <a href='%s'>Dismiss</a>","tdomf"),$diffs,$form_hacker,$dismiss);
+            $message .= "</font><br/>";
+        }
+        
+        // widget errors
+        
+        global $tdomf_form_widgets_admin_errors;
+        $mode = "new-post";        
+        if(tdomf_get_option_form(TDOMF_OPTION_SUBMIT_PAGE,$form_id)) {
+            $mode = "new-page";
+        }
+        $uri = "admin.php?page=tdomf_show_form_menu&form=".$form_id;
+        do_action('tdomf_control_form_start',$form_id,$mode);
+        $widget_order = tdomf_get_widget_order($form_id);
+        $widgets = tdomf_filter_widgets($mode, $tdomf_form_widgets_admin_errors);
+        foreach($widget_order as $w) {
+              if(isset($widgets[$w])) {
+                  $widget_message = call_user_func($widgets[$w]['cb'],$form_id,$widgets[$w]['params']);
+                  if(!empty($widget_message)) {
+                      $message .= "<font color=\"red\">" . $widget_message . sprintf(__(" <a href='%s'>Fix &raquo;</a>","tdomf"),$uri)."</font><br/>";
+                  }
+              }
+          }
+          
+         // @todo check that key is unique in custom fields
+    }
+        
+    if(get_option(TDOMF_OPTION_EXTRA_LOG_MESSAGES) && !get_option(TDOMF_OPTION_DISABLE_ERROR_MESSAGES)) {
+         $message .= "<font color=\"red\">";
+         if($show_links) {
+             $message .= sprintf(__("<b>Warning:</b> You have enabled 'Extra Debug Messages' and disabled 'Disable Error Messages'. This invokes a special mode where all PHP errors are turned on. This can lead to unexpected problems and could be considered a security leak! <a href=\"%s\">Change on the Options Page &raquo;</a>", "tdomf"),get_bloginfo('wpurl')."/wp-admin/admin.php?page=tdomf_show_options_menu");
+         } else {
+             $message .= __("<b>Warning:</b> You have enabled 'Extra Debug Messages' and disabled 'Disable Error Messages'. This invokes a special mode where all PHP errors are turned on. This can lead to unexpected problems and could be considered a security leak! This should only be used for debugging purposes.","tdomf");
+         }
+         $message .= "</font><br/>";
+    }
+    
+       $create_user_link = get_bloginfo('wpurl')."/wp-admin/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');
+    }
+	  if(get_option(TDOMF_DEFAULT_AUTHOR) == false) {
+	 	  $message .= "<font color=\"red\">".sprintf(__("<b>Error</b>: No default author set! <a href=\"%s\">Create dummy user for default author automatically &raquo;</a>","tdomf"),$create_user_link)."</font><br/>";
+	 	  tdomf_log_message("Option Default Author not set!",TDOMF_LOG_BAD);
+ 	  } else {
+          
+    $def_aut = new WP_User(get_option(TDOMF_DEFAULT_AUTHOR));
+    if(empty($def_aut->data->ID)) {
+        // User does not exist! Deleting option
+        delete_option(TDOMF_DEFAULT_AUTHOR);
+        $message .= "<font color=\"red\">".sprintf(__("<b>Error</b>: Current Default Author does not exist! <a href=\"%s\">Create dummy user for default author automatically &raquo;</a>","tdomf"),$create_user_link)."</font><br/>";
+	 	    tdomf_log_message("Current Default Author does not exist! Deleting option.",TDOMF_LOG_BAD);
+      }      
+ 	  	if($def_aut->has_cap("publish_posts")) {
+	 	  $message .= "<font color=\"red\">".sprintf(__("<b>Error</b>: Default author can publish posts. Default author should not be able to publish posts! <a href=\"%s\">Create a dummy user for default author automatically &raquo;</a>","tdomf"),$create_user_link)."</font><br/>";
+	 	  tdomf_log_message("Option Default Author is set to an author who can publish posts.",TDOMF_LOG_BAD);
+ 	  	}
+    }
+    
+    if(function_exists('wp_get_http'))
+    {
+        $post_uri = TDOMF_URLPATH.'tdomf-form-post.php';
+        $headers = wp_get_http($post_uri,false,1);
+        if($headers != false && $headers["response"] != '200')
+        {
+             $message .= "<font color=\"red\">";
+             $message .= sprintf(__("<b>Error</b>: Got a %d error when checking <a href=\"%s\">%s</a>! This will prevent posts from being submitted. The permissions may be wrong on the tdo-mini-forms folder.","tdomf"),$headers["response"], $post_uri, $post_uri);
+             $message .= "</font><br/>";
+             tdomf_log_message("Did not receive a 200 response when checking $post_uri:<pre>".var_export($headers,true)."</pre>",TDOMF_LOG_ERROR);
+        }
+
+        $ajax_uri = TDOMF_URLPATH.'tdomf-form-ajax.php';
+        $headers = wp_get_http($ajax_uri,false,1);
+        if($headers != false && $headers["response"] != '200')
+        {
+             $message .= "<font color=\"red\">";
+             $message .= sprintf(__("<b>Error</b>: Got a %d error when checking <a href=\"%s\">%s</a>! This will prevent forms that use AJAX from submitting posts. The permissions may be wrong on the tdo-mini-forms folder.","tdomf"),$headers["response"], $ajax_uri, $ajax_uri);
+             $message .= "</font><br/>";
+             tdomf_log_message("Did not receive a 200 response when checking $ajax_uri:<pre>".var_export($headers,true)."</pre>",TDOMF_LOG_ERROR);
+        }
+        
+        $css_uri = TDOMF_URLPATH.'tdomf-style-form.css';
+        $headers = wp_get_http($css_uri,false,1);
+        if($headers != false && $headers["response"] != '200')
+        {
+             $message .= "<font color=\"red\">";
+             $message .= sprintf(__("<b>Error</b>: Got a %d error when checking <a href=\"%s\">%s</a>! This will make your forms, by default, look very ugly. The permissions may be wrong on the tdo-mini-forms folder.","tdomf"),$headers["response"], $css_uri, $css_uri);
+             $message .= "</font><br/>";
+             tdomf_log_message("Did not receive a 200 response when checking $css_uri:<pre>".var_export($headers,true)."</pre>",TDOMF_LOG_ERROR);
+        }
+    }
+    
+    return $message;
+}
+
+?>
Index: admin/tdomf-overview.php
===================================================================
--- admin/tdomf-overview.php	(revision 169181)
+++ admin/tdomf-overview.php	(working copy)
@@ -1,364 +1,364 @@
-<?php
-if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('TDOMF: You are not allowed to call this page directly.'); }
-
-/////////////////////////
-// Admin Overview Page //
-/////////////////////////
-
-function tdomf_overview_admin_head() {
-   global $wp_version;
-   if(tdomf_wp25() && preg_match('/page=tdo-mini-forms/',$_SERVER[REQUEST_URI])) {
-   ?>
-   <style type="text/css">
-      #zeitgeist {
-	background: #eee;
-	border: 1px solid #c5c5c5;
-	float: right;
-	font-size: 90%;
-	margin-bottom: .5em;
-	margin-left: 1em;
-	margin-top: .5em;
-	padding: 1em;
-	width: 40%;
-      }
-      #zeitgeist h2, fieldset legend a {
-	background: none;
-}
-
-/** html*/ 
-#zeitgeist h2 {
-	padding-top: 10px;
-  width: 100%;
-}
-
-#zeitgeist h3 {
-	border-bottom: 1px solid #ccc;
-	font-size: 16px;
-	margin: 1em 0 0;
-}
-
-#zeitgeist h3 cite {
-	font-size: 12px;
-	font-style: normal;
-}
-
-#zeitgeist li, #zeitgeist p {
-	margin: .2em 0;
-}
-
-#zeitgeist ul {
-	margin: 0 0 .3em .6em;
-	padding: 0 0 0 .6em;
-}
-   </style>
-   <?php
-   }
-}
-add_action( 'admin_head', 'tdomf_overview_admin_head' );
-
-// Return a count of posts from unregistered users
-//
-function tdomf_get_unregistered_users_posts_count() {
-  global $wpdb;
-  // This function doesn't work yet...
-  $def_aut = get_option(TDOMF_DEFAULT_AUTHOR);
-  if($def_aut != false) {
-  	$query = "SELECT count(ID) ";
-    $query .= "FROM $wpdb->posts ";
-    $query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) ";
-    $query .= "WHERE meta_key = '".TDOMF_KEY_FLAG."' ";
-    $query .= "WHERE post_author = '$def_aut' ";
-    $query .= "OR post_author = '0' ";
-    return intval($wpdb->get_var( $query ));
-  }
-  return 0;
-}
-
-// Show the page
-//
-function tdomf_overview_menu()  {
-	global $wpdb,$wp_roles;
-
-    // Initilise the plugin for the first time here. This gets called when you click the TDOMF button in the menu.
-    // Doing it here means you can delete all the options!
-    tdomf_init();
-
-	// get feed_messages
-	require_once(ABSPATH . WPINC . '/rss.php');
-  
-  if(!isset($wp_roles)) {
-  	$wp_roles = new WP_Roles();
-  }
-  $roles = $wp_roles->role_objects;
-
-?>
-  <div class="wrap">
-    <h2><?php _e('Welcome to TDO Mini Forms', 'tdomf') ?></h2>
-
-    <div id="zeitgeist">
-
-        <?php $features = tdomf_new_features(); 
-              if($features) { ?>
-                <h2><?php printf(__("New Features in %s for you","tdomf"),TDOMF_VERSION); ?></h2>
-                <?php echo $features; ?>
-        <?php } ?>
-    
-    	  <h2><?php _e('Latest Activity', 'tdomf') ?></h2>
-        
-    	  <h3><?php _e('Log', 'tdomf') ?><?php if(current_user_can('manage_options')) { ?><a href="admin.php?page=tdomf_show_log_menu" title="Full Log...">&raquo;</a><?php } ?></h3>
-
-    	  <p><?php echo tdomf_get_log(5); ?></p>
-
-        <?php if(tdomf_is_moderation_in_use()) { ?>
-
-          <?php $posts = tdomf_get_unmoderated_posts(0,10);
-          if(!empty($posts)) { ?>
-            
-        	  <h3><?php _e('Latest Submissions', 'tdomf'); ?><?php if(current_user_can('edit_others_posts')) { ?><a href="admin.php?page=tdomf_show_mod_posts_menu&f=0" title="<?php _e("Moderate Submissions...","tdomf"); ?>">&raquo;</a><?php } ?></h3>
-
-          <ul>
-
-              
-                <?php foreach($posts as $p) { 
-                       echo tdomf_get_post_list_line($p); 
-                    } } ?>
-    	  </ul>
-
-    	  <?php } ?>
-
-          <?php if(get_option(TDOMF_OPTION_SPAM)) { ?>
-              <?php $spam_count = tdomf_get_spam_posts_count(); 
-              if($spam_count > 0) { ?>
-                  <h3><?php printf(__('There are %d spam submissions','tdomf'),$spam_count); ?><?php if(current_user_can('edit_others_posts')) { ?><a href="admin.php?page=tdomf_show_mod_posts_menu&f=3" title="<?php _e("Moderate Spam...","tdomf"); ?>">&raquo;</a><?php } ?></h3>
-              <?php } ?>
-          <?php } ?>
-          
-          <?php $posts = tdomf_get_published_posts(0,10);
-                if(!empty($posts)) { ?>
-
-    	  <h3><?php _e('Latest Approved Submissions', 'tdomf'); ?><?php if(current_user_can('edit_others_posts')) { ?><a href="admin.php?page=tdomf_show_mod_posts_menu&f=1" title="Moderate Posts...">&raquo;</a><?php } ?></h3>
-
-    	  <ul>
-                  
-                  
-              <?php	foreach($posts as $p) { 
-                       echo tdomf_get_post_list_line($p); 
-                    } 
-                } ?>
-    	  </ul>
-
-          
-
-    	  <h3><?php _e('Stats', 'tdomf'); ?></h3>
-
-          <?php $stat_sub_ever  = get_option(TDOMF_STAT_SUBMITTED);
-                $stat_edit_ever = get_option(TDOMF_STAT_EDITED);
-                $stat_unmod     = tdomf_get_unmoderated_posts_count();
-                $stat_edit_unmod  = tdomf_get_edits(array('state' => 'unapproved', 'count' => true, 'unique_post_ids' => true));
-                $stat_sub_cur   = tdomf_get_submitted_posts_count();
-                $stat_edit_cur  = tdomf_get_edits(array('count' => true, 'unique_post_ids' => true));
-                $stat_mod       = $stat_sub_cur - $stat_unmod;
-                $stat_edit_mod  = tdomf_get_edits(array('state' => 'approved', 'count' => true, 'unique_post_ids' => true)); 
-                $stat_spam      = get_option(TDOMF_STAT_SPAM); ?>
-
-          <?php if(get_option(TDOMF_OPTION_SPAM)) { ?>
-              <p><?php printf(__("You are using version %s (build %d) of the TDO Mini Forms plugin. There has been %d posts (or pages) submitted, %d edits submitted, %d posts approved and %d edits approved. %d spam submissions have been caught by Akismet","tdomf"),TDOMF_VERSION,get_option(TDOMF_VERSION_CURRENT),$stat_sub_ever,$stat_edit_ever,$stat_mod,$stat_edit_mod,$stat_spam); ?>
-          <?php } else { ?>
-              <p><?php printf(__("You are using version %s (build %d) of the TDO Mini Forms plugin. There has been %d posts (or pages) submitted, %d edits submitted, %d posts approved and %d edits approved.","tdomf"),TDOMF_VERSION,get_option(TDOMF_VERSION_CURRENT),$stat_sub_ever,$stat_edit_ever,$stat_mod,$stat_edit_mod); ?>
-          <?php } ?>
-        
-        <?php $rss = fetch_rss('http://thedeadone.net/forum/?cat=6&feed=rss');
-               if ( isset($rss->items) && 0 != count($rss->items) ) {
-                 $rss->items = array_slice($rss->items, 0, 5); 
-                 echo "<h3>".__('Latest Support Forum Topics','tdomf')."</h3><ul>";
-                 foreach ($rss->items as $item) { ?>
-                 <li><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a></li>
-        <?php    }
-                 echo "</ul>";
-              } ?>
-        
-    </div>
-
-    <?php echo "<p>".$message = tdomf_get_error_messages()."</p>";  ?>
-
-    <table style="margin:0px;padding:0px">
-      <tr>
-        <td>
-          <form action="https://www.paypal.com/cgi-bin/webscr" method="post" >
-          <input type="hidden" name="cmd" value="_s-xclick">
-          <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" style="border:0px;" >
-          <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
-          <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIIWQYJKoZIhvcNAQcEoIIISjCCCEYCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYBuEC47mJwumB8/XIQIyehLoyT5ueMyjGzjeTnWxYcjdY3rAgkJteuOvqnnYNG7R8x9g2NVIJYHleMRt7OWrwQKY3PRAU29Mlotfg0T4k4N9ZU2mCD/hLDXEGE0SiP3RNCSWWSU3b+3gcnFrk3Tfv+j97HXg6IgT87o7HHQxpQIcTELMAkGBSsOAwIaBQAwggHVBgkqhkiG9w0BBwEwFAYIKoZIhvcNAwcECCKhj3P2B/ixgIIBsKfdpYC59PyYwHpGqFfrO/qUglhIaUTp/L9Bz0a2txlpgxzrPqAlQp8+MkKkB8SKt9hXe4hPX4Kv5WsNiYzFeJImsg2PjCBmUTJVQaSBcznf58UUezjUFC0kouic5DzxRPm57ABeoth3aHVexw5M+PYPxmhB87xlohxUt3L7/mo270G5LXlB3kDR9IpbMEYZTw8mNa3DcMVGfv6pM7GKAy/wBEb6bShA4VRiVWchoPSHEEs+YVknSo9rQAdFbLXCwUMUS6NJbHG4pq8It/7IEDgpcVnrRSKjclnluPG73i/Clyq36VfhejOu0WK77G90Z6Y4eOtP4UDyXuMJH/OypHLaPT4dclpH8ps/odGJ018+mjdV6CNqHukuchdQgx+wEPCyP8qaHLBMAThsPbD4hnc3Ezc8END2f49HTAQlT0aFIktnVqkF5hMj2ERdVVqYly6S9qgvtnHROQilFVUpQnWjfWbAQGhLqEWNvv0/h1Pm6tgkXW3EUqVvJF2tyWiP40IMla3g93vhLpYcR2SnUlw6zqVgMHuYH21VgkLSi2y6FSEkjgeG49FGgLq5fvqog6CCA4cwggODMIIC7KADAgECAgEAMA0GCSqGSIb3DQEBBQUAMIGOMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbTAeFw0wNDAyMTMxMDEzMTVaFw0zNTAyMTMxMDEzMTVaMIGOMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwUdO3fxEzEtcnI7ZKZL412XvZPugoni7i7D7prCe0AtaHTc97CYgm7NsAtJyxNLixmhLV8pyIEaiHXWAh8fPKW+R017+EmXrr9EaquPmsVvTywAAE1PMNOKqo2kl4Gxiz9zZqIajOm1fZGWcGS0f5JQ2kBqNbvbg2/Za+GJ/qwUCAwEAAaOB7jCB6zAdBgNVHQ4EFgQUlp98u8ZvF71ZP1LXChvsENZklGswgbsGA1UdIwSBszCBsIAUlp98u8ZvF71ZP1LXChvsENZklGuhgZSkgZEwgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAgV86VpqAWuXvX6Oro4qJ1tYVIT5DgWpE692Ag422H7yRIr/9j/iKG4Thia/Oflx4TdL+IFJBAyPK9v6zZNZtBgPBynXb048hsP16l2vi0k5Q2JKiPDsEfBhGI+HnxLXEaUWAcVfCsQFvd2A1sxRr67ip5y2wwBelUecP3AjJ+YcxggGaMIIBlgIBATCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTA3MDkyNjE0MzQwM1owIwYJKoZIhvcNAQkEMRYEFClTuUrBDEQ7H6sAZIN8yB9qKifJMA0GCSqGSIb3DQEBAQUABIGAGr+klEj8FgUscdaxj/kalFxvuQnSznQDFmsPvJZfwa7Wur3EnF75m7+qvQOeFSZ56a3aXjSELI9ej1vXXz8mjZqUQYEeFLqvulKl3KVHS32KprXTj5iqp3TapPbeoSsMggxVxJ1HjmakNJm3UwhqlEIoc0qjf1wHPIIWSBJcAug=-----END PKCS7-----
-">
-          </form>
-        </td><td>
-          <?php printf(__("[<a href='%s'>My Amazon Wishlist</a>]","tdomf"),"http://www.amazon.co.uk/gp/registry/23S7OL9W6Q4JT"); ?>
-        </td>
-        <td>
-          <?php printf(__("[<a href='%s'>Rate TDO-Mini-Forms on Wordpress.org!</a>]","tdomf"),"http://wordpress.org/extend/plugins/tdo-mini-forms/#rate-response"); ?>
-        </td>
-      </tr>
-    </table>
-    
-    <p><?php _e("Use these links to get started:","tdomf"); ?></p>
-
-    <ul>
-      <li><a href="admin.php?page=tdomf_show_options_menu"><?php _e("Configure TDO Mini Forms","tdomf"); ?></a></li>
-      <li><a href="admin.php?page=tdomf_show_form_menu"><?php _e("Form Widgets","tdomf"); ?></a></li>
-      <?php if(get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) { ?>
-          <?php if(current_user_can('edit_users')) { ?>
-                <li><a href="users.php?page=tdomf_your_submissions"><?php _e("Your Submissions Page","tdomf"); ?></a></li>
-          <?php } else { ?>
-                <li><a href="profile.php?page=tdomf_your_submissions"><?php _e("Your Submissions Page","tdomf"); ?></a></li>
-          <?php } ?>
-      <?php } ?>
-      <?php if(current_user_can('manage_options')) { ?>
-      <li><a href="<?php echo TDOMF_URLPATH; ?>tdomf-phpinfo.php"><?php _e("phpinfo()","tdomf"); ?></a></li>
-      <li><a href="admin.php?page=<?php echo TDOMF_FOLDER.DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR; ?>tdomf-info.php"><?php _e("tdomfinfo()","tdomf"); ?></a></li>
-      <?php } ?>
-    </ul>
-
-<p><?php _e('Need help with TDO Mini Forms? Please see the <a href="http://thedeadone.net/forum">support forums on thedeadone.net</a> or the <a href="http://wordpress.org/tags/tdo-mini-forms">support forums on wordpress.org</a>.',"tdomf"); ?></p>
-
-    <h3><?php _e('Welcome', 'tdomf') ?></h3>
-
-    <p>
-    <?php _e("TDO Mini Forms plugin allows you to provide a form to your readers and users so that they can submit posts to your blog, even if they don't have rights to do so. You can control what type of users, such as unregistered users and subscribers, can access and use the form. Posts are submitted as draft so that you can approve them before they are published. (You can optionally turn this off so that submissions are automatically published). As of version 0.7, you can now also customise the form using widgets.","tdomf"); ?>
-    </p>
-        
-    <div id="devnews">
-    <h3><?php _e('Latest TDO Mini Forms News!',  'tdomf') ?></h3>
-
-    <?php
-      $rss = fetch_rss('http://thedeadone.net/tag/tdomf/feed');
-
-      if ( isset($rss->items) && 0 != count($rss->items) )
-      {
-        $rss->items = array_slice($rss->items, 0, 4);
-        foreach ($rss->items as $item)
-        {
-        ?>
-          <h4><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a> &#8212; <?php echo human_time_diff(strtotime($item['pubdate'], time())); ?></h4>
-          <p><?php echo '<strong>'.date("F, jS", strtotime($item['pubdate'])).'</strong> - '.$item['description']; ?></p>
-        <?php
-        }
-      }
-      else
-      {
-        ?>
-        <p><?php printf(__('Newsfeed could not be loaded.  Check the <a href="%s">thedeadone.net</a> to check for updates.', 'tdomf'), 'http://thedeadone.net/index.php?tag=tdomf') ?></p>
-        <?php
-      }
-    ?>
-    </div>
-    <br style="clear: both" />
-   </div>
-    <?php
-}
-
-function tdomf_get_post_list_line($p) {
-  $form_id = get_post_meta($p->ID, TDOMF_KEY_FORM_ID, true);
-  $submitter = get_post_meta($p->ID, TDOMF_KEY_NAME, true);
-  if($form_id == false || !tdomf_form_exists($form_id)) {
-    if($submitter == false || empty($submitter)) {
-      return "<li>".sprintf(__("<a href=\"%s\">\"%s\"</a>","tdomf"),get_permalink($p->ID),$p->post_title)."</li>";
-    } else {
-       return "<li>".sprintf(__("<a href=\"%s\">\"%s\"</a> submitted by %s","tdomf"),get_permalink($p->ID),$p->post_title,$submitter)."</li>";
-    }
-  } else if($submitter == false || empty($submitter)) {
-    return "<li>".sprintf(__("<a href=\"%s\">\"%s\"</a> using form %d","tdomf"),get_permalink($p->ID),$p->post_title, $form_id)."</li>";
-  }
-  return "<li>".sprintf(__("<a href=\"%s\">\"%s\"</a> submitted by %s using form %d","tdomf"),get_permalink($p->ID),$p->post_title,$submitter,$form_id)."</li>";
-}
-
-function tdomf_dashboard_status() {
-
-    $published_sub_count = tdomf_get_published_posts_count();
-    $approved_edits_count = tdomf_get_edits(array('state' => 'approved', 'count' => true));  
-    $scheduled_sub_count = tdomf_get_queued_posts_count();
-    $spam_edits_count = tdomf_get_edits(array('state' => 'spam', 'count' => true, 'unique_post_ids' => true));
-    $pending_edits_count = tdomf_get_edits(array('state' => 'unapproved', 'count' => true, 'unique_post_ids' => true));
-    $pending_sub_count = tdomf_get_unmoderated_posts_count();
-    $spam_sub_count = tdomf_get_spam_posts_count();
-            
-    echo '<tr>';
-
-    $num = number_format_i18n($published_sub_count);
-    $text = __ngettext( 'Approved Submission', 'Approved Submissions', $published_sub_count );
-    $url = tdomf_get_mod_posts_url(array('show' => 'all'));
-    echo '<td class="b b_approved"><a href="' . $url .'">' . $num . '</a></td>';
-    echo '<td class="first t posts"><a class="approved" href="' . $url .'">' . $text . '</a></td>';
-
-    $num = number_format_i18n($approved_edits_count);
-    $text = __ngettext( 'Approved Contribution', 'Approved Contributions', $approved_edits_count );
-    $url = tdomf_get_mod_posts_url(array('show' => 'approved_edits'));
-    echo '<td class="b b_approved"><a href="' . $url .'">' . $num . '</a></td>';
-    echo '<td class="first t posts"><a class="approved" href="' . $url .'">' . $text . '</a></td>';
-    
-    echo '</tr><tr>';
-   
-    if($scheduled_sub_count > 0) {
-        $num = number_format_i18n($scheduled_sub_count);
-        $text = __ngettext( 'Scheduled Submission', 'Scheduled Submissions', $scheduled_sub_count );
-        $url = tdomf_get_mod_posts_url(array('show' => 'scheduled'));
-        echo '<td class="b posts"><a href="' . $url .'">' . $num . '</a></td>';
-        echo '<td class="first t posts"><a href="' . $url .'">' . $text . '</a></td>';
-        echo '</tr><tr>';
-    }
-    
-    if(get_option(TDOMF_OPTION_SPAM) && ($spam_edits_count > 0 || $spam_sub_count > 0)) {
-
-        $num = number_format_i18n($pending_sub_count);
-        $text = __ngettext( 'Pending Submission', 'Pending Submissions', $pending_sub_count );
-        $url = tdomf_get_mod_posts_url(array('show' => 'pending_submissions'));
-        echo '<td class="b b-waiting"><a class="waiting" href="' . $url .'"><span class=\'pending-count\'>' . $num . '</span></a></td>';
-        echo '<td class="first t"><a class="waiting" href="' . $url .'">' . $text . '</a></td>';
-       
-        $num = number_format_i18n($spam_sub_count);
-        $text = __ngettext( 'Spam Submission', 'Spam Submissions', $spam_sub_count );
-        $url = tdomf_get_mod_posts_url(array('show' => 'spam_submissions'));
-        echo '<td class="b b-spam"><a class="waiting" href="' . $url .'"><span class=\'spam-count\'>' . $num . '</span></a></td>';
-        echo '<td class="last t"><a class="spam" href="' . $url .'">' . $text . '</a></td>';
-    
-        echo '</tr><tr>';
-        
-        $num = number_format_i18n($pending_edits_count);
-        $text = __ngettext( 'Pending Contribution', 'Pending Contributions', $pending_edits_count );
-        echo '<td class="b b-waiting"><a class="waiting" href="' . $url .'"><span class=\'pending-count\'>' . $num . '</span></a></td>';
-        echo '<td class="first t"><a class="waiting" href="' . $url .'">' . $text . '</a></td>';
-    
-        $num = number_format_i18n($spam_edits_count);
-        $text = __ngettext( 'Spam Contribution', 'Spam Contributions', $spam_edits_count );
-        $url = tdomf_get_mod_posts_url(array('show' => 'spam_edits'));
-        echo '<td class="b b-waiting"><a class="waiting" href="' . $url .'"><span class=\'pending-count\'>' . $num . '</span></a></td>';
-        echo '<td class="first t"><a class="waiting" href="' . $url .'">' . $text . '</a></td>';
-    } else {
-        $num = number_format_i18n($pending_sub_count);
-        $url = tdomf_get_mod_posts_url(array('show' => 'pending_submissions'));
-        $text = __ngettext( 'Pending Submission', 'Pending Submissions', $pending_sub_count );
-        echo '<td class="b b-waiting"><a class="waiting" href="' . $url .'"><span class=\'pending-count\'>' . $num . '</span></a></td>';
-        echo '<td class="first t"><a class="waiting" href="' . $url .'">' . $text . '</a></td>';
-
-        $num = number_format_i18n($pending_edits_count);
-        $url = tdomf_get_mod_posts_url(array('show' => 'pending_edits'));
-        $text = __ngettext( 'Pending Contribution', 'Pending Contributions', $pending_edits_count );
-        echo '<td class="b b-waiting"><a class="waiting" href="' . $url .'"><span class=\'pending-count\'>' . $num . '</span></a></td>';
-        echo '<td class="last t"><a class="waiting" href="' . $url .'">' . $text . '</a></td>';
-
-    }
-    
-    echo '</tr>';
-}
-add_action('right_now_table_end','tdomf_dashboard_status');
-
-function tdomf_overview_please_upgrade() {
-    $ver_cur = get_option(TDOMF_VERSION_CURRENT);
-    if($ver_cur != false && $ver_cur != TDOMF_BUILD) { ?>
-        <div id="message" class="updated" ><p>
-        <?php printf(__('You\'ve recently upgraded TDO Mini Forms. To finalise the upgrade process, <a href="%s">please visit the overview page</a>. Thank you.','tdomf'),"admin.php?page=tdo-mini-forms"); ?>
-        </p></div>
-    <?php }
-}
-add_action( 'admin_notices', 'tdomf_overview_please_upgrade' );
-
+<?php
+if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('TDOMF: You are not allowed to call this page directly.'); }
+
+/////////////////////////
+// Admin Overview Page //
+/////////////////////////
+
+function tdomf_overview_admin_head() {
+   global $wp_version;
+   if(tdomf_wp25() && preg_match('/page=tdo-mini-forms/',$_SERVER['REQUEST_URI'])) {
+   ?>
+   <style type="text/css">
+      #zeitgeist {
+	background: #eee;
+	border: 1px solid #c5c5c5;
+	float: right;
+	font-size: 90%;
+	margin-bottom: .5em;
+	margin-left: 1em;
+	margin-top: .5em;
+	padding: 1em;
+	width: 40%;
+      }
+      #zeitgeist h2, fieldset legend a {
+	background: none;
+}
+
+/** html*/ 
+#zeitgeist h2 {
+	padding-top: 10px;
+  width: 100%;
+}
+
+#zeitgeist h3 {
+	border-bottom: 1px solid #ccc;
+	font-size: 16px;
+	margin: 1em 0 0;
+}
+
+#zeitgeist h3 cite {
+	font-size: 12px;
+	font-style: normal;
+}
+
+#zeitgeist li, #zeitgeist p {
+	margin: .2em 0;
+}
+
+#zeitgeist ul {
+	margin: 0 0 .3em .6em;
+	padding: 0 0 0 .6em;
+}
+   </style>
+   <?php
+   }
+}
+add_action( 'admin_head', 'tdomf_overview_admin_head' );
+
+// Return a count of posts from unregistered users
+//
+function tdomf_get_unregistered_users_posts_count() {
+  global $wpdb;
+  // This function doesn't work yet...
+  $def_aut = get_option(TDOMF_DEFAULT_AUTHOR);
+  if($def_aut != false) {
+  	$query = "SELECT count(ID) ";
+    $query .= "FROM $wpdb->posts ";
+    $query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) ";
+    $query .= "WHERE meta_key = '".TDOMF_KEY_FLAG."' ";
+    $query .= "WHERE post_author = '$def_aut' ";
+    $query .= "OR post_author = '0' ";
+    return intval($wpdb->get_var( $query ));
+  }
+  return 0;
+}
+
+// Show the page
+//
+function tdomf_overview_menu()  {
+	global $wpdb,$wp_roles;
+
+    // Initilise the plugin for the first time here. This gets called when you click the TDOMF button in the menu.
+    // Doing it here means you can delete all the options!
+    tdomf_init();
+
+	// get feed_messages
+	require_once(ABSPATH . WPINC . '/rss.php');
+  
+  if(!isset($wp_roles)) {
+  	$wp_roles = new WP_Roles();
+  }
+  $roles = $wp_roles->role_objects;
+
+?>
+  <div class="wrap">
+    <h2><?php _e('Welcome to TDO Mini Forms', 'tdomf') ?></h2>
+
+    <div id="zeitgeist">
+
+        <?php $features = tdomf_new_features(); 
+              if($features) { ?>
+                <h2><?php printf(__("New Features in %s for you","tdomf"),TDOMF_VERSION); ?></h2>
+                <?php echo $features; ?>
+        <?php } ?>
+    
+    	  <h2><?php _e('Latest Activity', 'tdomf') ?></h2>
+        
+    	  <h3><?php _e('Log', 'tdomf') ?><?php if(current_user_can('manage_options')) { ?><a href="admin.php?page=tdomf_show_log_menu" title="Full Log...">&raquo;</a><?php } ?></h3>
+
+    	  <p><?php echo tdomf_get_log(5); ?></p>
+
+        <?php if(tdomf_is_moderation_in_use()) { ?>
+
+          <?php $posts = tdomf_get_unmoderated_posts(0,10);
+          if(!empty($posts)) { ?>
+            
+        	  <h3><?php _e('Latest Submissions', 'tdomf'); ?><?php if(current_user_can('edit_others_posts')) { ?><a href="admin.php?page=tdomf_show_mod_posts_menu&f=0" title="<?php _e("Moderate Submissions...","tdomf"); ?>">&raquo;</a><?php } ?></h3>
+
+          <ul>
+
+              
+                <?php foreach($posts as $p) { 
+                       echo tdomf_get_post_list_line($p); 
+                    } } ?>
+    	  </ul>
+
+    	  <?php } ?>
+
+          <?php if(get_option(TDOMF_OPTION_SPAM)) { ?>
+              <?php $spam_count = tdomf_get_spam_posts_count(); 
+              if($spam_count > 0) { ?>
+                  <h3><?php printf(__('There are %d spam submissions','tdomf'),$spam_count); ?><?php if(current_user_can('edit_others_posts')) { ?><a href="admin.php?page=tdomf_show_mod_posts_menu&f=3" title="<?php _e("Moderate Spam...","tdomf"); ?>">&raquo;</a><?php } ?></h3>
+              <?php } ?>
+          <?php } ?>
+          
+          <?php $posts = tdomf_get_published_posts(0,10);
+                if(!empty($posts)) { ?>
+
+    	  <h3><?php _e('Latest Approved Submissions', 'tdomf'); ?><?php if(current_user_can('edit_others_posts')) { ?><a href="admin.php?page=tdomf_show_mod_posts_menu&f=1" title="Moderate Posts...">&raquo;</a><?php } ?></h3>
+
+    	  <ul>
+                  
+                  
+              <?php	foreach($posts as $p) { 
+                       echo tdomf_get_post_list_line($p); 
+                    } 
+                } ?>
+    	  </ul>
+
+          
+
+    	  <h3><?php _e('Stats', 'tdomf'); ?></h3>
+
+          <?php $stat_sub_ever  = get_option(TDOMF_STAT_SUBMITTED);
+                $stat_edit_ever = get_option(TDOMF_STAT_EDITED);
+                $stat_unmod     = tdomf_get_unmoderated_posts_count();
+                $stat_edit_unmod  = tdomf_get_edits(array('state' => 'unapproved', 'count' => true, 'unique_post_ids' => true));
+                $stat_sub_cur   = tdomf_get_submitted_posts_count();
+                $stat_edit_cur  = tdomf_get_edits(array('count' => true, 'unique_post_ids' => true));
+                $stat_mod       = $stat_sub_cur - $stat_unmod;
+                $stat_edit_mod  = tdomf_get_edits(array('state' => 'approved', 'count' => true, 'unique_post_ids' => true)); 
+                $stat_spam      = get_option(TDOMF_STAT_SPAM); ?>
+
+          <?php if(get_option(TDOMF_OPTION_SPAM)) { ?>
+              <p><?php printf(__("You are using version %s (build %d) of the TDO Mini Forms plugin. There has been %d posts (or pages) submitted, %d edits submitted, %d posts approved and %d edits approved. %d spam submissions have been caught by Akismet","tdomf"),TDOMF_VERSION,get_option(TDOMF_VERSION_CURRENT),$stat_sub_ever,$stat_edit_ever,$stat_mod,$stat_edit_mod,$stat_spam); ?>
+          <?php } else { ?>
+              <p><?php printf(__("You are using version %s (build %d) of the TDO Mini Forms plugin. There has been %d posts (or pages) submitted, %d edits submitted, %d posts approved and %d edits approved.","tdomf"),TDOMF_VERSION,get_option(TDOMF_VERSION_CURRENT),$stat_sub_ever,$stat_edit_ever,$stat_mod,$stat_edit_mod); ?>
+          <?php } ?>
+        
+        <?php $rss = fetch_rss('http://thedeadone.net/forum/?cat=6&feed=rss');
+               if ( isset($rss->items) && 0 != count($rss->items) ) {
+                 $rss->items = array_slice($rss->items, 0, 5); 
+                 echo "<h3>".__('Latest Support Forum Topics','tdomf')."</h3><ul>";
+                 foreach ($rss->items as $item) { ?>
+                 <li><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a></li>
+        <?php    }
+                 echo "</ul>";
+              } ?>
+        
+    </div>
+
+    <?php echo "<p>".$message = tdomf_get_error_messages()."</p>";  ?>
+
+    <table style="margin:0px;padding:0px">
+      <tr>
+        <td>
+          <form action="https://www.paypal.com/cgi-bin/webscr" method="post" >
+          <input type="hidden" name="cmd" value="_s-xclick">
+          <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" style="border:0px;" >
+          <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
+          <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIIWQYJKoZIhvcNAQcEoIIISjCCCEYCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYBuEC47mJwumB8/XIQIyehLoyT5ueMyjGzjeTnWxYcjdY3rAgkJteuOvqnnYNG7R8x9g2NVIJYHleMRt7OWrwQKY3PRAU29Mlotfg0T4k4N9ZU2mCD/hLDXEGE0SiP3RNCSWWSU3b+3gcnFrk3Tfv+j97HXg6IgT87o7HHQxpQIcTELMAkGBSsOAwIaBQAwggHVBgkqhkiG9w0BBwEwFAYIKoZIhvcNAwcECCKhj3P2B/ixgIIBsKfdpYC59PyYwHpGqFfrO/qUglhIaUTp/L9Bz0a2txlpgxzrPqAlQp8+MkKkB8SKt9hXe4hPX4Kv5WsNiYzFeJImsg2PjCBmUTJVQaSBcznf58UUezjUFC0kouic5DzxRPm57ABeoth3aHVexw5M+PYPxmhB87xlohxUt3L7/mo270G5LXlB3kDR9IpbMEYZTw8mNa3DcMVGfv6pM7GKAy/wBEb6bShA4VRiVWchoPSHEEs+YVknSo9rQAdFbLXCwUMUS6NJbHG4pq8It/7IEDgpcVnrRSKjclnluPG73i/Clyq36VfhejOu0WK77G90Z6Y4eOtP4UDyXuMJH/OypHLaPT4dclpH8ps/odGJ018+mjdV6CNqHukuchdQgx+wEPCyP8qaHLBMAThsPbD4hnc3Ezc8END2f49HTAQlT0aFIktnVqkF5hMj2ERdVVqYly6S9qgvtnHROQilFVUpQnWjfWbAQGhLqEWNvv0/h1Pm6tgkXW3EUqVvJF2tyWiP40IMla3g93vhLpYcR2SnUlw6zqVgMHuYH21VgkLSi2y6FSEkjgeG49FGgLq5fvqog6CCA4cwggODMIIC7KADAgECAgEAMA0GCSqGSIb3DQEBBQUAMIGOMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbTAeFw0wNDAyMTMxMDEzMTVaFw0zNTAyMTMxMDEzMTVaMIGOMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwUdO3fxEzEtcnI7ZKZL412XvZPugoni7i7D7prCe0AtaHTc97CYgm7NsAtJyxNLixmhLV8pyIEaiHXWAh8fPKW+R017+EmXrr9EaquPmsVvTywAAE1PMNOKqo2kl4Gxiz9zZqIajOm1fZGWcGS0f5JQ2kBqNbvbg2/Za+GJ/qwUCAwEAAaOB7jCB6zAdBgNVHQ4EFgQUlp98u8ZvF71ZP1LXChvsENZklGswgbsGA1UdIwSBszCBsIAUlp98u8ZvF71ZP1LXChvsENZklGuhgZSkgZEwgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAgV86VpqAWuXvX6Oro4qJ1tYVIT5DgWpE692Ag422H7yRIr/9j/iKG4Thia/Oflx4TdL+IFJBAyPK9v6zZNZtBgPBynXb048hsP16l2vi0k5Q2JKiPDsEfBhGI+HnxLXEaUWAcVfCsQFvd2A1sxRr67ip5y2wwBelUecP3AjJ+YcxggGaMIIBlgIBATCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTA3MDkyNjE0MzQwM1owIwYJKoZIhvcNAQkEMRYEFClTuUrBDEQ7H6sAZIN8yB9qKifJMA0GCSqGSIb3DQEBAQUABIGAGr+klEj8FgUscdaxj/kalFxvuQnSznQDFmsPvJZfwa7Wur3EnF75m7+qvQOeFSZ56a3aXjSELI9ej1vXXz8mjZqUQYEeFLqvulKl3KVHS32KprXTj5iqp3TapPbeoSsMggxVxJ1HjmakNJm3UwhqlEIoc0qjf1wHPIIWSBJcAug=-----END PKCS7-----
+">
+          </form>
+        </td><td>
+          <?php printf(__("[<a href='%s'>My Amazon Wishlist</a>]","tdomf"),"http://www.amazon.co.uk/gp/registry/23S7OL9W6Q4JT"); ?>
+        </td>
+        <td>
+          <?php printf(__("[<a href='%s'>Rate TDO-Mini-Forms on Wordpress.org!</a>]","tdomf"),"http://wordpress.org/extend/plugins/tdo-mini-forms/#rate-response"); ?>
+        </td>
+      </tr>
+    </table>
+    
+    <p><?php _e("Use these links to get started:","tdomf"); ?></p>
+
+    <ul>
+      <li><a href="admin.php?page=tdomf_show_options_menu"><?php _e("Configure TDO Mini Forms","tdomf"); ?></a></li>
+      <li><a href="admin.php?page=tdomf_show_form_menu"><?php _e("Form Widgets","tdomf"); ?></a></li>
+      <?php if(get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) { ?>
+          <?php if(current_user_can('edit_users')) { ?>
+                <li><a href="users.php?page=tdomf_your_submissions"><?php _e("Your Submissions Page","tdomf"); ?></a></li>
+          <?php } else { ?>
+                <li><a href="profile.php?page=tdomf_your_submissions"><?php _e("Your Submissions Page","tdomf"); ?></a></li>
+          <?php } ?>
+      <?php } ?>
+      <?php if(current_user_can('manage_options')) { ?>
+      <li><a href="<?php echo TDOMF_URLPATH; ?>tdomf-phpinfo.php"><?php _e("phpinfo()","tdomf"); ?></a></li>
+      <li><a href="admin.php?page=<?php echo TDOMF_FOLDER.DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR; ?>tdomf-info.php"><?php _e("tdomfinfo()","tdomf"); ?></a></li>
+      <?php } ?>
+    </ul>
+
+<p><?php _e('Need help with TDO Mini Forms? Please see the <a href="http://thedeadone.net/forum">support forums on thedeadone.net</a> or the <a href="http://wordpress.org/tags/tdo-mini-forms">support forums on wordpress.org</a>.',"tdomf"); ?></p>
+
+    <h3><?php _e('Welcome', 'tdomf') ?></h3>
+
+    <p>
+    <?php _e("TDO Mini Forms plugin allows you to provide a form to your readers and users so that they can submit posts to your blog, even if they don't have rights to do so. You can control what type of users, such as unregistered users and subscribers, can access and use the form. Posts are submitted as draft so that you can approve them before they are published. (You can optionally turn this off so that submissions are automatically published). As of version 0.7, you can now also customise the form using widgets.","tdomf"); ?>
+    </p>
+        
+    <div id="devnews">
+    <h3><?php _e('Latest TDO Mini Forms News!',  'tdomf') ?></h3>
+
+    <?php
+      $rss = fetch_rss('http://thedeadone.net/tag/tdomf/feed');
+
+      if ( isset($rss->items) && 0 != count($rss->items) )
+      {
+        $rss->items = array_slice($rss->items, 0, 4);
+        foreach ($rss->items as $item)
+        {
+        ?>
+          <h4><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a> &#8212; <?php echo human_time_diff(strtotime($item['pubdate'], time())); ?></h4>
+          <p><?php echo '<strong>'.date("F, jS", strtotime($item['pubdate'])).'</strong> - '.$item['description']; ?></p>
+        <?php
+        }
+      }
+      else
+      {
+        ?>
+        <p><?php printf(__('Newsfeed could not be loaded.  Check the <a href="%s">thedeadone.net</a> to check for updates.', 'tdomf'), 'http://thedeadone.net/index.php?tag=tdomf') ?></p>
+        <?php
+      }
+    ?>
+    </div>
+    <br style="clear: both" />
+   </div>
+    <?php
+}
+
+function tdomf_get_post_list_line($p) {
+  $form_id = get_post_meta($p->ID, TDOMF_KEY_FORM_ID, true);
+  $submitter = get_post_meta($p->ID, TDOMF_KEY_NAME, true);
+  if($form_id == false || !tdomf_form_exists($form_id)) {
+    if($submitter == false || empty($submitter)) {
+      return "<li>".sprintf(__("<a href=\"%s\">\"%s\"</a>","tdomf"),get_permalink($p->ID),$p->post_title)."</li>";
+    } else {
+       return "<li>".sprintf(__("<a href=\"%s\">\"%s\"</a> submitted by %s","tdomf"),get_permalink($p->ID),$p->post_title,$submitter)."</li>";
+    }
+  } else if($submitter == false || empty($submitter)) {
+    return "<li>".sprintf(__("<a href=\"%s\">\"%s\"</a> using form %d","tdomf"),get_permalink($p->ID),$p->post_title, $form_id)."</li>";
+  }
+  return "<li>".sprintf(__("<a href=\"%s\">\"%s\"</a> submitted by %s using form %d","tdomf"),get_permalink($p->ID),$p->post_title,$submitter,$form_id)."</li>";
+}
+
+function tdomf_dashboard_status() {
+
+    $published_sub_count = tdomf_get_published_posts_count();
+    $approved_edits_count = tdomf_get_edits(array('state' => 'approved', 'count' => true));  
+    $scheduled_sub_count = tdomf_get_queued_posts_count();
+    $spam_edits_count = tdomf_get_edits(array('state' => 'spam', 'count' => true, 'unique_post_ids' => true));
+    $pending_edits_count = tdomf_get_edits(array('state' => 'unapproved', 'count' => true, 'unique_post_ids' => true));
+    $pending_sub_count = tdomf_get_unmoderated_posts_count();
+    $spam_sub_count = tdomf_get_spam_posts_count();
+            
+    echo '<tr>';
+
+    $num = number_format_i18n($published_sub_count);
+    $text = __ngettext( 'Approved Submission', 'Approved Submissions', $published_sub_count );
+    $url = tdomf_get_mod_posts_url(array('show' => 'all'));
+    echo '<td class="b b_approved"><a href="' . $url .'">' . $num . '</a></td>';
+    echo '<td class="first t posts"><a class="approved" href="' . $url .'">' . $text . '</a></td>';
+
+    $num = number_format_i18n($approved_edits_count);
+    $text = __ngettext( 'Approved Contribution', 'Approved Contributions', $approved_edits_count );
+    $url = tdomf_get_mod_posts_url(array('show' => 'approved_edits'));
+    echo '<td class="b b_approved"><a href="' . $url .'">' . $num . '</a></td>';
+    echo '<td class="first t posts"><a class="approved" href="' . $url .'">' . $text . '</a></td>';
+    
+    echo '</tr><tr>';
+   
+    if($scheduled_sub_count > 0) {
+        $num = number_format_i18n($scheduled_sub_count);
+        $text = __ngettext( 'Scheduled Submission', 'Scheduled Submissions', $scheduled_sub_count );
+        $url = tdomf_get_mod_posts_url(array('show' => 'scheduled'));
+        echo '<td class="b posts"><a href="' . $url .'">' . $num . '</a></td>';
+        echo '<td class="first t posts"><a href="' . $url .'">' . $text . '</a></td>';
+        echo '</tr><tr>';
+    }
+    
+    if(get_option(TDOMF_OPTION_SPAM) && ($spam_edits_count > 0 || $spam_sub_count > 0)) {
+
+        $num = number_format_i18n($pending_sub_count);
+        $text = __ngettext( 'Pending Submission', 'Pending Submissions', $pending_sub_count );
+        $url = tdomf_get_mod_posts_url(array('show' => 'pending_submissions'));
+        echo '<td class="b b-waiting"><a class="waiting" href="' . $url .'"><span class=\'pending-count\'>' . $num . '</span></a></td>';
+        echo '<td class="first t"><a class="waiting" href="' . $url .'">' . $text . '</a></td>';
+       
+        $num = number_format_i18n($spam_sub_count);
+        $text = __ngettext( 'Spam Submission', 'Spam Submissions', $spam_sub_count );
+        $url = tdomf_get_mod_posts_url(array('show' => 'spam_submissions'));
+        echo '<td class="b b-spam"><a class="waiting" href="' . $url .'"><span class=\'spam-count\'>' . $num . '</span></a></td>';
+        echo '<td class="last t"><a class="spam" href="' . $url .'">' . $text . '</a></td>';
+    
+        echo '</tr><tr>';
+        
+        $num = number_format_i18n($pending_edits_count);
+        $text = __ngettext( 'Pending Contribution', 'Pending Contributions', $pending_edits_count );
+        echo '<td class="b b-waiting"><a class="waiting" href="' . $url .'"><span class=\'pending-count\'>' . $num . '</span></a></td>';
+        echo '<td class="first t"><a class="waiting" href="' . $url .'">' . $text . '</a></td>';
+    
+        $num = number_format_i18n($spam_edits_count);
+        $text = __ngettext( 'Spam Contribution', 'Spam Contributions', $spam_edits_count );
+        $url = tdomf_get_mod_posts_url(array('show' => 'spam_edits'));
+        echo '<td class="b b-waiting"><a class="waiting" href="' . $url .'"><span class=\'pending-count\'>' . $num . '</span></a></td>';
+        echo '<td class="first t"><a class="waiting" href="' . $url .'">' . $text . '</a></td>';
+    } else {
+        $num = number_format_i18n($pending_sub_count);
+        $url = tdomf_get_mod_posts_url(array('show' => 'pending_submissions'));
+        $text = __ngettext( 'Pending Submission', 'Pending Submissions', $pending_sub_count );
+        echo '<td class="b b-waiting"><a class="waiting" href="' . $url .'"><span class=\'pending-count\'>' . $num . '</span></a></td>';
+        echo '<td class="first t"><a class="waiting" href="' . $url .'">' . $text . '</a></td>';
+
+        $num = number_format_i18n($pending_edits_count);
+        $url = tdomf_get_mod_posts_url(array('show' => 'pending_edits'));
+        $text = __ngettext( 'Pending Contribution', 'Pending Contributions', $pending_edits_count );
+        echo '<td class="b b-waiting"><a class="waiting" href="' . $url .'"><span class=\'pending-count\'>' . $num . '</span></a></td>';
+        echo '<td class="last t"><a class="waiting" href="' . $url .'">' . $text . '</a></td>';
+
+    }
+    
+    echo '</tr>';
+}
+add_action('right_now_table_end','tdomf_dashboard_status');
+
+function tdomf_overview_please_upgrade() {
+    $ver_cur = get_option(TDOMF_VERSION_CURRENT);
+    if($ver_cur != false && $ver_cur != TDOMF_BUILD) { ?>
+        <div id="message" class="updated" ><p>
+        <?php printf(__('You\'ve recently upgraded TDO Mini Forms. To finalise the upgrade process, <a href="%s">please visit the overview page</a>. Thank you.','tdomf'),"admin.php?page=tdo-mini-forms"); ?>
+        </p></div>
+    <?php }
+}
+add_action( 'admin_notices', 'tdomf_overview_please_upgrade' );
+
 ?>
\ No newline at end of file
Index: admin/tdomf-uninstall.php
===================================================================
--- admin/tdomf-uninstall.php	(revision 169181)
+++ admin/tdomf-uninstall.php	(working copy)
@@ -1,53 +1,53 @@
-<?php
-if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('TDOMF: You are not allowed to call this page directly.'); }
-
-///////////////////
-// Uinstall Page //
-///////////////////
-
-// grab a list of all posts
-//
-function tdomf_get_all_posts() {
-  global $wpdb;
-	$query = "SELECT ID ";
-	$query .= "FROM $wpdb->posts ";
-	$query .= "ORDER BY ID DESC";
-	return $wpdb->get_results( $query );
-}
-
-/////////////////////////////////
-// Delete pre-configured options
-//
-function tdomf_reset_options() {
-  global $wpdb, $wp_roles, $table_prefix;
-   
-  echo "<span style='width:200px;'>";
-  _e("Deleting Options... ","tdomf");
-  echo "</span>";
-  
-  // This includes v0.6 options!
-  //
-  delete_option(TDOMF_ACCESS_LEVEL);
-  delete_option(TDOMF_NOTIFY_LEVEL);
-  delete_option(TDOMF_ACCESS_ROLES);
-  delete_option(TDOMF_NOTIFY_ROLES);
-  delete_option(TDOMF_DEFAULT_CATEGORY);
-  delete_option(TDOMF_DEFAULT_AUTHOR);
-  delete_option(TDOMF_AUTO_FIX_AUTHOR);
-  delete_option(TDOMF_BANNED_IPS);
-  delete_option(TDOMF_VERSION_CURRENT);
-  delete_option(TDOMF_OPTION_MODERATION);
-  delete_option(TDOMF_OPTION_TRUST_COUNT);
-  delete_option(TDOMF_OPTION_ALLOW_EVERYONE);
-  delete_option(TDOMF_OPTION_AJAX);
-  delete_option(TDOMF_OPTION_PREVIEW);
-  delete_option(TDOMF_OPTION_FROM_EMAIL);
-  delete_option(TDOMF_OPTION_AUTHOR_THEME_HACK);
-  delete_option(TDOMF_OPTION_ADD_SUBMITTER);
-  delete_option(TDOMF_OPTION_FORM_ORDER);  
-  delete_option(TDOMF_STAT_SUBMITTED);
-  delete_option(TDOMF_OPTION_DISABLE_ERROR_MESSAGES);
-  delete_option(TDOMF_OPTION_EXTRA_LOG_MESSAGES);
+<?php
+if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('TDOMF: You are not allowed to call this page directly.'); }
+
+///////////////////
+// Uinstall Page //
+///////////////////
+
+// grab a list of all posts
+//
+function tdomf_get_all_posts() {
+  global $wpdb;
+	$query = "SELECT ID ";
+	$query .= "FROM $wpdb->posts ";
+	$query .= "ORDER BY ID DESC";
+	return $wpdb->get_results( $query );
+}
+
+/////////////////////////////////
+// Delete pre-configured options
+//
+function tdomf_reset_options() {
+  global $wpdb, $wp_roles, $table_prefix;
+   
+  echo "<span style='width:200px;'>";
+  _e("Deleting Options... ","tdomf");
+  echo "</span>";
+  
+  // This includes v0.6 options!
+  //
+  delete_option(TDOMF_ACCESS_LEVEL);
+  delete_option(TDOMF_NOTIFY_LEVEL);
+  delete_option(TDOMF_ACCESS_ROLES);
+  delete_option(TDOMF_NOTIFY_ROLES);
+  delete_option(TDOMF_DEFAULT_CATEGORY);
+  delete_option(TDOMF_DEFAULT_AUTHOR);
+  delete_option(TDOMF_AUTO_FIX_AUTHOR);
+  delete_option(TDOMF_BANNED_IPS);
+  delete_option(TDOMF_VERSION_CURRENT);
+  delete_option(TDOMF_OPTION_MODERATION);
+  delete_option(TDOMF_OPTION_TRUST_COUNT);
+  delete_option(TDOMF_OPTION_ALLOW_EVERYONE);
+  delete_option(TDOMF_OPTION_AJAX);
+  delete_option(TDOMF_OPTION_PREVIEW);
+  delete_option(TDOMF_OPTION_FROM_EMAIL);
+  delete_option(TDOMF_OPTION_AUTHOR_THEME_HACK);
+  delete_option(TDOMF_OPTION_ADD_SUBMITTER);
+  delete_option(TDOMF_OPTION_FORM_ORDER);  
+  delete_option(TDOMF_STAT_SUBMITTED);
+  delete_option(TDOMF_OPTION_DISABLE_ERROR_MESSAGES);
+  delete_option(TDOMF_OPTION_EXTRA_LOG_MESSAGES);
   delete_option(TDOMF_OPTION_YOUR_SUBMISSIONS);
   delete_option(TDOMF_OPTION_NAME);
   delete_option(TDOMF_OPTION_DESCRIPTION);
@@ -58,249 +58,249 @@
   delete_option(TDOMF_LOG);
   delete_option(TDOMF_OPTION_WIDGET_MAX_WIDTH);
   delete_option(TDOMF_OPTION_WIDGET_MAX_LENGTH);
-  delete_option(TDOMF_OPTION_WIDGET_MAX_WIDTH);
+  delete_option(TDOMF_OPTION_WIDGET_MAX_HEIGHT);
   delete_option(TDOMF_OPTION_VERIFICATION_METHOD);
   delete_option(TDOMF_OPTION_FORM_DATA_METHOD);
   delete_option(TDOMF_VERSION_LAST);
-  
-  echo "<span style='color:green;'>";
-  _e("DONE","tdomf");  
-  echo "</span><br/>";
-  
-  echo "<span style='width:200px;'>";
-  _e("Resetting role capabilities... ","tdomf");
-  echo "</span>";
-  if(!isset($wp_roles)) {
-    $wp_roles = new WP_Roles();
-  }
-  $roles = $wp_roles->role_objects;
-  $form_ids = tdomf_get_form_ids();
-  foreach($roles as $role) {
-     if(isset($role->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM.'_1'])){
-       $role->remove_cap(TDOMF_CAPABILITY_CAN_SEE_FORM.'_1');
-     }
-     foreach($form_ids as $f) {
-       if(isset($role->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM.'_'.$f->form_id])){
-          $role->remove_cap(TDOMF_CAPABILITY_CAN_SEE_FORM.'_'.$f->form_id);
-       }
-     }
-  }
-  
-  echo "<span style='color:green;'>";
-  _e("DONE","tdomf"); 
-  echo "</span><br/>";
-  
-  echo "<span style='width:200px;'>";
-  _e("Deleting Widget Options (or at least the ones I can find!)... ","tdomf");
-  echo "</span>";
-  // Danger will robinson! If the table prefix is "tdomf_", you may end up
-  // deleting critical Wordpress core options!
-  if($table_prefix != "tdomf_") {
-    $alloptions = wp_load_alloptions();
-    foreach($alloptions as $id => $val) {
-      if(preg_match('#^tdomf_.+#',$id)) {
-        delete_option($id);
-        echo "<!-- $id -->";
-      }
-    }
-    echo "<span style='color:green;'>";
-    _e("DONE","tdomf");
-  } else {
-    echo "<span style='color:red;'>";
-    _e("FAIL","tdomf");
-  }
-  echo "</span><br/>";
-  
-  echo "<span style='width:200px;'>";
-  _e("Deleting Database Tables... ","tdomf");
-  echo "</span>";
-  tdomf_db_delete_tables();
-  echo "<span style='color:green;'>";
-    _e("DONE","tdomf");
-  echo "</span><br/>";
-  
-}
-
-function tdomf_full_uninstall() {
-  
-  // Delete Posts
-  //
-   echo "<span style='width:200px;'>";
-  _e("Removing posts submitted or managed by TDO Mini Forms (this may take a few minutes depending on the number of posts)... ","tdomf");
-  echo "</span>";
-  $posts = tdomf_get_all_posts();
-  foreach($posts as $post) {
-    delete_option(TDOMF_NOTIFY.$post->ID);
-    $tdomf_flag = get_post_meta($post->ID, TDOMF_KEY_FLAG, true);
-    if(!empty($tdomf_flag)){
-       wp_delete_post($post->ID);
-    }
-  }
-  echo "<span style='color:green;'>";
-  _e("DONE","tdomf"); 
-  echo "</span><br/>";
-  
-  // Delete Created Users
-  //
-   echo "<span style='width:200px;'>";
-  _e("Attempting to delete any users created by TDOMF... ","tdomf");
-  echo "</span>";
-  $users = get_option(TDOMF_OPTION_CREATEDUSERS);
-  if($users != false) {
-    foreach($users as $u) {
-      wp_delete_user($u);
-    }
-  }
-  echo "<span style='color:green;'>";
-  _e("DONE","tdomf"); 
-  echo "</span><br/>";
-  
-  // Strip existing Users
-  //
-   echo "<span style='width:200px;'>";
-  _e("Removing info from remaining users (this may take a few minutes depending on number of users)... ","tdomf");
-  echo "</span>";
-  $users = tdomf_get_all_users();
-  foreach($users as $user) {
-    delete_usermeta($user->ID, TDOMF_KEY_FLAG);
-    delete_usermeta($user->ID, TDOMF_KEY_STATUS);
-  }
-  echo "<span style='color:green;'>";
-  _e("DONE","tdomf"); 
-  echo "</span><br/>";
-  
-  // Delete Forms
-  //
-  $form_ids = tdomf_get_form_ids();
-  foreach($form_ids as $f) {
-    echo "<span style='width:200px;'>";
-    printf(__("Deleting Form %d... ","tdomf"),$f->form_id);
-    echo "</span>";
-    if(tdomf_delete_form($f->form_id)) {
-      echo "<span style='color:green;'>";
-     _e("DONE","tdomf");
-    } else {
-      echo "<span style='color:red;'>";
-     _e("FAIL","tdomf");
-    }
-    echo "</span><br/>";
-  }
-  
-  // Delete Options
-  //
-  tdomf_reset_options();
-}
-
-// Uninstall everything else!
-//
-function tdomf_uninstall() {
-  tdomf_reset_options();
-  
-  echo "<span style='width:200px;'>";
-  _e("Removing info from all users (this may take a few minutes depending on number of users)... ","tdomf");
-  echo "</span>";
-  $users = tdomf_get_all_users();
-  foreach($users as $user) {
-    delete_usermeta($user->ID, TDOMF_KEY_FLAG);
-    delete_usermeta($user->ID, TDOMF_KEY_STATUS);
-  }
-  echo "<span style='color:green;'>";
-  _e("DONE","tdomf"); 
-  echo "</span><br/>";
-  
-  // This includes v0.6 options!
-  //
-  echo "<span style='width:200px;'>";
-  _e("Removing info from all posts (this may take a few minutes depending on number of posts)... ","tdomf");
-  echo "</span>";
-  $posts = tdomf_get_all_posts();
-  foreach($posts as $post) {
-    delete_option(TDOMF_NOTIFY.$post->ID);
-    delete_post_meta($post->ID, TDOMF_KEY_NOTIFY_EMAIL);
-    delete_post_meta($post->ID, TDOMF_KEY_FLAG);
-    delete_post_meta($post->ID, TDOMF_KEY_NAME);
-    delete_post_meta($post->ID, TDOMF_KEY_EMAIL);
-    delete_post_meta($post->ID, TDOMF_KEY_WEB);
-    delete_post_meta($post->ID, TDOMF_KEY_IP);
-    delete_post_meta($post->ID, TDOMF_KEY_USER_ID);
-    delete_post_meta($post->ID, TDOMF_KEY_USER_NAME);
-    delete_post_meta($post->ID, TDOMF_KEY_LOCK);
-  }
-  echo "<span style='color:green;'>";
-  _e("DONE","tdomf"); 
-  echo "</span><br/>";
-}
-
-// Display a help page
-//
-function tdomf_show_uninstall_menu() {
-  ?>
-
-  <div class="wrap">
-
-    <h2><?php _e('Uninstall TDO Mini Forms', 'tdomf') ?></h2>
-
-    <?php $plugin_name = TDOMF_FOLDER.'/tdomf.php';
-          $deactivate_url = wp_nonce_url("plugins.php?action=deactivate&plugin=$plugin_name","deactivate-plugin_$plugin_name"); ?>
-                    
-    <?php if(isset($_REQUEST['action'])) {
-            $action = $_REQUEST['action']; ?>
-            <p>
-    <?php   if($action == "reset_options") {
-              check_admin_referer('tdomf-reset-options');
-              tdomf_reset_options();
-              ?>
-              <p><a href='<?php echo $deactivate_url; ?>' title='Deactivate TDO Mini Forms' class="delete">
-              <?php _e("Final step to complete uninstall: Deactivate TDO Mini Forms Plugin","tdomf"); ?></a></p>
-              <?php
-            } else if($action == "uninstall") {
-              check_admin_referer('tdomf-uninstall');
-              tdomf_uninstall();
-              ?>
-              <p><a href='<?php echo $deactivate_url; ?>' title='Deactivate TDO Mini Forms' class="delete">
-              <?php _e("Final step to complete uninstall: Deactivate TDO Mini Forms Plugin","tdomf"); ?></a></p>
-              <?php
-            } else if($action == "uninstall-all-1") {
-              check_admin_referer('tdomf-uninstall-all-1');
-              ?>
-              <p><?php _e("You are about to do some potentially critical things to Wordpress. Please only proceed if you happy with the risks.","tdomf"); ?></p>
-              <p><a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_uninstall_menu&action=uninstall-all-2",'tdomf-uninstall-all-2'); ?>" class='delete' ><?php _e("Are you really really sure you want to proceed?","tdomf"); ?></a></p>
-              <?php
-            } else if($action == "uninstall-all-2") {
-              check_admin_referer('tdomf-uninstall-all-2');
-              tdomf_full_uninstall();
-              ?>
-              <p><a href='<?php echo $deactivate_url; ?>' title='Deactivate TDO Mini Forms' class="delete">
-              <?php _e("Final step to complete uninstall: Deactivate TDO Mini Forms Plugin","tdomf"); ?></a></p>
-              <?php
-            } ?>
-            </p>  
-    <?php } else { ?>
-            
-            <p><?php _e("From here you can uninstall and remove some or all of TDO Mini Form's options and information.","tdomf"); ?></p>
-            </div>
-            
-            <div class="wrap">
-            <p><?php _e("You can simply remove just the settings/options. This will preserve submitter information on posts and users if you re-enable TDO Mini Forms later.","tdomf"); ?></p>
-            <a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_uninstall_menu&action=reset_options",'tdomf-reset-options'); ?>" class='delete' ><?php _e("Remove Options","tdomf"); ?></a><br/>
-            </div>
-            
-            <div class="wrap">
-            <p><?php _e("This removes <i>nearly everything</i>. Any posts submitted, users created or pages created are not removed. However submitted posts are stripped of any information about TDO Mini Forms. If you re-enable TDO Mini Forms, posts previousily submitted will not turn up as submitted posts any more.","tdomf"); ?></p>
-            <a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_uninstall_menu&action=uninstall",'tdomf-uninstall'); ?>" class='delete' ><?php _e("Uninstall Nearly Everything!","tdomf"); ?></a>
-            </div>
-            
-            <div class="wrap">
-            <p><?php _e("This removes <b>everything</b>. It is advised to backup your database before proceeding as posts, pages and users will be deleted. All posts submitted by users using TDO Mini Forms will be deleted. Any users created by TDO Mini forms will be deleted. Any pages created by TDO Mini Forms will be deleted. All options and settings will be completely removed. It'll be like you never used TDO Mini Forms!","tdomf"); ?></p>
-            <a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_uninstall_menu&action=uninstall-all-1",'tdomf-uninstall-all-1'); ?>" class='delete' ><?php _e("Uninstall Everything!!!!","tdomf"); ?></a>
-            </div>
-            
-    <?php } ?>
-    
-    <br/>
-
-</div>
-
-<?php
-}
-?>
+  
+  echo "<span style='color:green;'>";
+  _e("DONE","tdomf");  
+  echo "</span><br/>";
+  
+  echo "<span style='width:200px;'>";
+  _e("Resetting role capabilities... ","tdomf");
+  echo "</span>";
+  if(!isset($wp_roles)) {
+    $wp_roles = new WP_Roles();
+  }
+  $roles = $wp_roles->role_objects;
+  $form_ids = tdomf_get_form_ids();
+  foreach($roles as $role) {
+     if(isset($role->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM.'_1'])){
+       $role->remove_cap(TDOMF_CAPABILITY_CAN_SEE_FORM.'_1');
+     }
+     foreach($form_ids as $f) {
+       if(isset($role->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM.'_'.$f->form_id])){
+          $role->remove_cap(TDOMF_CAPABILITY_CAN_SEE_FORM.'_'.$f->form_id);
+       }
+     }
+  }
+  
+  echo "<span style='color:green;'>";
+  _e("DONE","tdomf"); 
+  echo "</span><br/>";
+  
+  echo "<span style='width:200px;'>";
+  _e("Deleting Widget Options (or at least the ones I can find!)... ","tdomf");
+  echo "</span>";
+  // Danger will robinson! If the table prefix is "tdomf_", you may end up
+  // deleting critical Wordpress core options!
+  if($table_prefix != "tdomf_") {
+    $alloptions = wp_load_alloptions();
+    foreach($alloptions as $id => $val) {
+      if(preg_match('#^tdomf_.+#',$id)) {
+        delete_option($id);
+        echo "<!-- $id -->";
+      }
+    }
+    echo "<span style='color:green;'>";
+    _e("DONE","tdomf");
+  } else {
+    echo "<span style='color:red;'>";
+    _e("FAIL","tdomf");
+  }
+  echo "</span><br/>";
+  
+  echo "<span style='width:200px;'>";
+  _e("Deleting Database Tables... ","tdomf");
+  echo "</span>";
+  tdomf_db_delete_tables();
+  echo "<span style='color:green;'>";
+    _e("DONE","tdomf");
+  echo "</span><br/>";
+  
+}
+
+function tdomf_full_uninstall() {
+  
+  // Delete Posts
+  //
+   echo "<span style='width:200px;'>";
+  _e("Removing posts submitted or managed by TDO Mini Forms (this may take a few minutes depending on the number of posts)... ","tdomf");
+  echo "</span>";
+  $posts = tdomf_get_all_posts();
+  foreach($posts as $post) {
+    delete_option(TDOMF_NOTIFY.$post->ID);
+    $tdomf_flag = get_post_meta($post->ID, TDOMF_KEY_FLAG, true);
+    if(!empty($tdomf_flag)){
+       wp_delete_post($post->ID);
+    }
+  }
+  echo "<span style='color:green;'>";
+  _e("DONE","tdomf"); 
+  echo "</span><br/>";
+  
+  // Delete Created Users
+  //
+   echo "<span style='width:200px;'>";
+  _e("Attempting to delete any users created by TDOMF... ","tdomf");
+  echo "</span>";
+  $users = get_option(TDOMF_OPTION_CREATEDUSERS);
+  if($users != false) {
+    foreach($users as $u) {
+      wp_delete_user($u);
+    }
+  }
+  echo "<span style='color:green;'>";
+  _e("DONE","tdomf"); 
+  echo "</span><br/>";
+  
+  // Strip existing Users
+  //
+   echo "<span style='width:200px;'>";
+  _e("Removing info from remaining users (this may take a few minutes depending on number of users)... ","tdomf");
+  echo "</span>";
+  $users = tdomf_get_all_users();
+  foreach($users as $user) {
+    delete_usermeta($user->ID, TDOMF_KEY_FLAG);
+    delete_usermeta($user->ID, TDOMF_KEY_STATUS);
+  }
+  echo "<span style='color:green;'>";
+  _e("DONE","tdomf"); 
+  echo "</span><br/>";
+  
+  // Delete Forms
+  //
+  $form_ids = tdomf_get_form_ids();
+  foreach($form_ids as $f) {
+    echo "<span style='width:200px;'>";
+    printf(__("Deleting Form %d... ","tdomf"),$f->form_id);
+    echo "</span>";
+    if(tdomf_delete_form($f->form_id)) {
+      echo "<span style='color:green;'>";
+     _e("DONE","tdomf");
+    } else {
+      echo "<span style='color:red;'>";
+     _e("FAIL","tdomf");
+    }
+    echo "</span><br/>";
+  }
+  
+  // Delete Options
+  //
+  tdomf_reset_options();
+}
+
+// Uninstall everything else!
+//
+function tdomf_uninstall() {
+  tdomf_reset_options();
+  
+  echo "<span style='width:200px;'>";
+  _e("Removing info from all users (this may take a few minutes depending on number of users)... ","tdomf");
+  echo "</span>";
+  $users = tdomf_get_all_users();
+  foreach($users as $user) {
+    delete_usermeta($user->ID, TDOMF_KEY_FLAG);
+    delete_usermeta($user->ID, TDOMF_KEY_STATUS);
+  }
+  echo "<span style='color:green;'>";
+  _e("DONE","tdomf"); 
+  echo "</span><br/>";
+  
+  // This includes v0.6 options!
+  //
+  echo "<span style='width:200px;'>";
+  _e("Removing info from all posts (this may take a few minutes depending on number of posts)... ","tdomf");
+  echo "</span>";
+  $posts = tdomf_get_all_posts();
+  foreach($posts as $post) {
+    delete_option(TDOMF_NOTIFY.$post->ID);
+    delete_post_meta($post->ID, TDOMF_KEY_NOTIFY_EMAIL);
+    delete_post_meta($post->ID, TDOMF_KEY_FLAG);
+    delete_post_meta($post->ID, TDOMF_KEY_NAME);
+    delete_post_meta($post->ID, TDOMF_KEY_EMAIL);
+    delete_post_meta($post->ID, TDOMF_KEY_WEB);
+    delete_post_meta($post->ID, TDOMF_KEY_IP);
+    delete_post_meta($post->ID, TDOMF_KEY_USER_ID);
+    delete_post_meta($post->ID, TDOMF_KEY_USER_NAME);
+    delete_post_meta($post->ID, TDOMF_KEY_LOCK);
+  }
+  echo "<span style='color:green;'>";
+  _e("DONE","tdomf"); 
+  echo "</span><br/>";
+}
+
+// Display a help page
+//
+function tdomf_show_uninstall_menu() {
+  ?>
+
+  <div class="wrap">
+
+    <h2><?php _e('Uninstall TDO Mini Forms', 'tdomf') ?></h2>
+
+    <?php $plugin_name = TDOMF_FOLDER.'/tdomf.php';
+          $deactivate_url = wp_nonce_url("plugins.php?action=deactivate&plugin=$plugin_name","deactivate-plugin_$plugin_name"); ?>
+                    
+    <?php if(isset($_REQUEST['action'])) {
+            $action = $_REQUEST['action']; ?>
+            <p>
+    <?php   if($action == "reset_options") {
+              check_admin_referer('tdomf-reset-options');
+              tdomf_reset_options();
+              ?>
+              <p><a href='<?php echo $deactivate_url; ?>' title='Deactivate TDO Mini Forms' class="delete">
+              <?php _e("Final step to complete uninstall: Deactivate TDO Mini Forms Plugin","tdomf"); ?></a></p>
+              <?php
+            } else if($action == "uninstall") {
+              check_admin_referer('tdomf-uninstall');
+              tdomf_uninstall();
+              ?>
+              <p><a href='<?php echo $deactivate_url; ?>' title='Deactivate TDO Mini Forms' class="delete">
+              <?php _e("Final step to complete uninstall: Deactivate TDO Mini Forms Plugin","tdomf"); ?></a></p>
+              <?php
+            } else if($action == "uninstall-all-1") {
+              check_admin_referer('tdomf-uninstall-all-1');
+              ?>
+              <p><?php _e("You are about to do some potentially critical things to Wordpress. Please only proceed if you happy with the risks.","tdomf"); ?></p>
+              <p><a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_uninstall_menu&action=uninstall-all-2",'tdomf-uninstall-all-2'); ?>" class='delete' ><?php _e("Are you really really sure you want to proceed?","tdomf"); ?></a></p>
+              <?php
+            } else if($action == "uninstall-all-2") {
+              check_admin_referer('tdomf-uninstall-all-2');
+              tdomf_full_uninstall();
+              ?>
+              <p><a href='<?php echo $deactivate_url; ?>' title='Deactivate TDO Mini Forms' class="delete">
+              <?php _e("Final step to complete uninstall: Deactivate TDO Mini Forms Plugin","tdomf"); ?></a></p>
+              <?php
+            } ?>
+            </p>  
+    <?php } else { ?>
+            
+            <p><?php _e("From here you can uninstall and remove some or all of TDO Mini Form's options and information.","tdomf"); ?></p>
+            </div>
+            
+            <div class="wrap">
+            <p><?php _e("You can simply remove just the settings/options. This will preserve submitter information on posts and users if you re-enable TDO Mini Forms later.","tdomf"); ?></p>
+            <a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_uninstall_menu&action=reset_options",'tdomf-reset-options'); ?>" class='delete' ><?php _e("Remove Options","tdomf"); ?></a><br/>
+            </div>
+            
+            <div class="wrap">
+            <p><?php _e("This removes <i>nearly everything</i>. Any posts submitted, users created or pages created are not removed. However submitted posts are stripped of any information about TDO Mini Forms. If you re-enable TDO Mini Forms, posts previousily submitted will not turn up as submitted posts any more.","tdomf"); ?></p>
+            <a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_uninstall_menu&action=uninstall",'tdomf-uninstall'); ?>" class='delete' ><?php _e("Uninstall Nearly Everything!","tdomf"); ?></a>
+            </div>
+            
+            <div class="wrap">
+            <p><?php _e("This removes <b>everything</b>. It is advised to backup your database before proceeding as posts, pages and users will be deleted. All posts submitted by users using TDO Mini Forms will be deleted. Any users created by TDO Mini forms will be deleted. Any pages created by TDO Mini Forms will be deleted. All options and settings will be completely removed. It'll be like you never used TDO Mini Forms!","tdomf"); ?></p>
+            <a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_uninstall_menu&action=uninstall-all-1",'tdomf-uninstall-all-1'); ?>" class='delete' ><?php _e("Uninstall Everything!!!!","tdomf"); ?></a>
+            </div>
+            
+    <?php } ?>
+    
+    <br/>
+
+</div>
+
+<?php
+}
+?>
\ No newline at end of file
Index: admin/tdomf-your-submissions.php
===================================================================
--- admin/tdomf-your-submissions.php	(revision 169181)
+++ admin/tdomf-your-submissions.php	(working copy)
@@ -1,80 +1,80 @@
-<?php
-if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('TDOMF: You are not allowed to call this page directly.'); }
-
-/////////////////////////////////
-// User "Your Submission" page //
-/////////////////////////////////
-
-// Grab a list of published submitted posts for user
-//
-function tdomf_get_user_published_posts($user_id = 0, $offset = 0, $limit = 0) {
-  /*global $wpdb;
-	$query = "SELECT ID, post_title, meta_value, post_status, post_modified_gmt, post_modified, post_date, post_date_gmt ";
-	$query .= "FROM $wpdb->posts ";
-	$query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) ";
-   $query .= "WHERE meta_key = '".TDOMF_KEY_USER_ID."' ";
-   $query .= "AND post_status = 'publish' ";
-   $query .= "AND meta_value = '$user_id' ";
-   	$query .= "ORDER BY ID DESC ";
-   if($limit > 0) {
-         $query .= "LIMIT $limit ";
-      }
-      if($offset > 0) {
-         $query .= "OFFSET $offset ";
-   }
-	return $wpdb->get_results( $query );*/
-    return tdomf_get_posts(array('limit' => $limit,
-                                 'offset' => $offset,
-                                 'user_id' => $user_id,
-                                 'post_status' => array('publish')));
-}
-
-function tdomf_get_user_scheduled_posts($user_id = 0, $offset = 0, $limit = 0) {
-  /*global $wpdb;
-	$query = "SELECT ID, post_title, meta_value, post_status, post_modified_gmt, post_modified, post_date, post_date_gmt ";
-	$query .= "FROM $wpdb->posts ";
-	$query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) ";
-   $query .= "WHERE meta_key = '".TDOMF_KEY_USER_ID."' ";
-   $query .= "AND post_status = 'future' ";
-   $query .= "AND meta_value = '$user_id' ";
-   	$query .= "ORDER BY ID DESC ";
-   if($limit > 0) {
-         $query .= "LIMIT $limit ";
-      }
-      if($offset > 0) {
-         $query .= "OFFSET $offset ";
-   }
-	return $wpdb->get_results( $query );*/
-    return tdomf_get_posts(array('limit' => $limit,
-                                 'offset' => $offset,
-                                 'post_status' => array('future'),
-                                 'user_id' => $user_id ));
-}
-
-// Grab a list of unmoderated submitted posts for user
-//
-function tdomf_get_user_draft_posts($user_id = 0, $offset = 0, $limit = 0) {
-  /*global $wpdb;
-	$query = "SELECT ID, post_title, meta_value, post_status  ";
-	$query .= "FROM $wpdb->posts ";
-	$query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) ";
-   $query .= "WHERE meta_key = '".TDOMF_KEY_USER_ID."' ";
-   $query .= "AND post_status = 'draft' ";
-   $query .= "AND meta_value = '$user_id' ";
-   	$query .= "ORDER BY ID DESC ";
-   if($limit > 0) {
-         $query .= "LIMIT $limit ";
-      }
-      if($offset > 0) {
-         $query .= "OFFSET $offset ";
-   }
-	return $wpdb->get_results( $query );*/
-    return tdomf_get_posts(array('limit' => $limit,
-                                 'offset' => $offset,
-                                 'user_id' => $user_id,
-                                 'post_status' => array('draft')));
-}
-
+<?php
+if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('TDOMF: You are not allowed to call this page directly.'); }
+
+/////////////////////////////////
+// User "Your Submission" page //
+/////////////////////////////////
+
+// Grab a list of published submitted posts for user
+//
+function tdomf_get_user_published_posts($user_id = 0, $offset = 0, $limit = 0) {
+  /*global $wpdb;
+	$query = "SELECT ID, post_title, meta_value, post_status, post_modified_gmt, post_modified, post_date, post_date_gmt ";
+	$query .= "FROM $wpdb->posts ";
+	$query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) ";
+   $query .= "WHERE meta_key = '".TDOMF_KEY_USER_ID."' ";
+   $query .= "AND post_status = 'publish' ";
+   $query .= "AND meta_value = '$user_id' ";
+   	$query .= "ORDER BY ID DESC ";
+   if($limit > 0) {
+         $query .= "LIMIT $limit ";
+      }
+      if($offset > 0) {
+         $query .= "OFFSET $offset ";
+   }
+	return $wpdb->get_results( $query );*/
+    return tdomf_get_posts(array('limit' => $limit,
+                                 'offset' => $offset,
+                                 'user_id' => $user_id,
+                                 'post_status' => array('publish')));
+}
+
+function tdomf_get_user_scheduled_posts($user_id = 0, $offset = 0, $limit = 0) {
+  /*global $wpdb;
+	$query = "SELECT ID, post_title, meta_value, post_status, post_modified_gmt, post_modified, post_date, post_date_gmt ";
+	$query .= "FROM $wpdb->posts ";
+	$query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) ";
+   $query .= "WHERE meta_key = '".TDOMF_KEY_USER_ID."' ";
+   $query .= "AND post_status = 'future' ";
+   $query .= "AND meta_value = '$user_id' ";
+   	$query .= "ORDER BY ID DESC ";
+   if($limit > 0) {
+         $query .= "LIMIT $limit ";
+      }
+      if($offset > 0) {
+         $query .= "OFFSET $offset ";
+   }
+	return $wpdb->get_results( $query );*/
+    return tdomf_get_posts(array('limit' => $limit,
+                                 'offset' => $offset,
+                                 'post_status' => array('future'),
+                                 'user_id' => $user_id ));
+}
+
+// Grab a list of unmoderated submitted posts for user
+//
+function tdomf_get_user_draft_posts($user_id = 0, $offset = 0, $limit = 0) {
+  /*global $wpdb;
+	$query = "SELECT ID, post_title, meta_value, post_status  ";
+	$query .= "FROM $wpdb->posts ";
+	$query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) ";
+   $query .= "WHERE meta_key = '".TDOMF_KEY_USER_ID."' ";
+   $query .= "AND post_status = 'draft' ";
+   $query .= "AND meta_value = '$user_id' ";
+   	$query .= "ORDER BY ID DESC ";
+   if($limit > 0) {
+         $query .= "LIMIT $limit ";
+      }
+      if($offset > 0) {
+         $query .= "OFFSET $offset ";
+   }
+	return $wpdb->get_results( $query );*/
+    return tdomf_get_posts(array('limit' => $limit,
+                                 'offset' => $offset,
+                                 'user_id' => $user_id,
+                                 'post_status' => array('draft')));
+}
+
 function tdomf_get_post_time( $d = 'U', $gmt = false, $post ) { // returns timestamp
 	if ( $gmt )
 		$time = $post->post_date_gmt;
@@ -88,7 +88,7 @@
 // include form style sheet on page
 //
 function tdomf_show_your_submissions_admin_head() {
-   if(preg_match('/page=tdomf_your_submissions/',$_SERVER[REQUEST_URI])) {
+   if(preg_match('/page=tdomf_your_submissions/',$_SERVER['REQUEST_URI'])) {
    ?>
    <link rel="stylesheet" href="<?php echo TDOMF_URLPATH; ?>tdomf-style-form.css" type="text/css" media="screen" />
    <?php
@@ -96,207 +96,207 @@
 }
 add_action( 'admin_head', 'tdomf_show_your_submissions_admin_head' );
 
-// Show the page!
-//
-function tdomf_show_your_submissions_menu() {
-  global $current_user;
-
-  // how many of the recently published/approved entries to see
-  //
-  $limit = 10;
-  
-  get_currentuserinfo();
-  
-  $tdomf_flag = get_usermeta($current_user->ID,TDOMF_KEY_FLAG);
-  $sub_total = tdomf_get_users_submitted_posts_count($current_user->ID);
-  $app_total = tdomf_get_users_published_posts_count($current_user->ID);
-  $user_status = get_usermeta($current_user->ID,TDOMF_KEY_STATUS);
-  $app_posts = tdomf_get_user_published_posts($current_user->ID,0,$limit);
-  $mod_posts = tdomf_get_user_draft_posts($current_user->ID);
-  $mod_total = count($mod_posts);
-  $fut_posts = tdomf_get_user_scheduled_posts($current_user->ID);
-  $fut_total = count($fut_posts);
-  $unapp_edits = tdomf_get_edits(array('state' => 'unapproved', 'unique_post_ids' => true, 'user_id' => $current_user->ID));
-  $app_edits = tdomf_get_edits(array('state' => 'approved', 'unique_post_ids' => true, 'user_id' => $current_user->ID, 'limit' => $limit));
-  
-  ?>
-
-  <div class="wrap">
-    <h2><?php _e('Your Submissions', 'tdomf') ?></h2>
-    
-    <?php if(in_array($_REQUEST['REMOTE_ADDR'],tdomf_get_ips_banned())) { ?>
-      <?php printf(__("You are logged on from the banned IP %s. If this is in error please contact the <a href='mailto:%s'>admins</a>.","tdomf"),$_REQUEST['REMOTE_ADDR'],get_bloginfo('admin_email')); ?>
-    <?php } else if($user_status == TDOMF_USER_STATUS_BANNED) { ?>
-      <?php printf(__("You are banned from using this functionality on this site. If this is in error please contact the <a href='mailto:%s'>admins</a>.","tdomf"),get_bloginfo('admin_email')); ?>
-    <?php } else { ?>
-
-      <p>
-      <?php if($user_status == TDOMF_USER_STATUS_TRUSTED) { ?>
-        <?php printf(__("Good to see you again <b>%s</b>! ","tdomf"),$current_user->display_name); ?>
-      <?php } else if($tdomf_flag) { ?>
-        <?php printf(__("Welcome back <b>%s</b>!","tdomf"),$current_user->display_name); ?>
-      <?php } else { ?>
-        <?php printf(__("Welcome <b>%s</b>.","tdomf"),$current_user->display_name); ?>
-      <?php } ?>
-      </p>
-      
-      <p><?php printf(__("From here you can submit posts to the %s using the form below and check on the status of your submissions.","tdomf"),get_bloginfo()); ?></p>
-      
-      <?php if(current_user_can('edit_others_posts') || current_user_can('manage_options')) { ?>
-      <ul>
-      <?php if(current_user_can('manage_options')) { ?>
-      <li><a href="admin.php?page=tdomf_show_options_menu"><?php _e("Configure Options","tdomf"); ?></a></li>
-      <li><a href="admin.php?page=tdomf_show_form_menu"><?php _e("Modify Form","tdomf"); ?></a></li>
-      <?php } ?>
-      <li><a href="admin.php?page=tdomf_show_mod_posts_menu"><?php _e("Moderate Submissions","tdomf"); ?></a></li>
-      </ul>
-      <?php } ?>
-
-    <?php if($tdomf_flag && ($sub_total > 0 || $app_total > 0)) { ?>
-        
-        <?php if($fut_total > 0) { ?>
-            <h3><?php printf(__('Your Next %d Scheduled Submissions','tdomf'),$fut_total); ?></h3>
-            <ul>
-         <?php foreach($fut_posts as $p) { ?>
-          <li>
-          <?php $t_time = get_the_time(__('Y/m/d g:i:s A'));
-                $m_time = $p->post_date;
-                $time = tdomf_get_post_time('G', true, $p);
-                if ( ( abs(time() - $time) ) < 86400 ) {
-                    $h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
-                } else {
-                    $h_time = mysql2date(__('Y/m/d'), $m_time);
-                } ?>
-                <?php printf(__("<a href='%s'>%s</a> will be published %s","tdomf"),get_permalink($p->ID),$p->post_title,"<abbr title='$t_time'>$h_time</abbr>"); ?>
-          </li>
-         <?php } ?>
-    	  </ul>
-        <?php } ?>
-        
-       <?php if($app_total > 0) { ?>
-         <h3><?php printf(__('Your Last %d Published Submissions','tdomf'),($app_total < 5) ? $app_total : 5 ); ?></h3>
-         <ul>
-         <?php foreach($app_posts as $p) { ?>
-          <li>
-          <?php $t_time = get_the_time(__('Y/m/d g:i:s A'));
-                $m_time = $p->post_date;
-                $time = tdomf_get_post_time('G', true, $p);
-                if ( ( abs(time() - $time) ) < 86400 ) {
-                    $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
-                } else {
-                    $h_time = mysql2date(__('Y/m/d'), $m_time);
-                } ?>
-                <?php printf(__("<a href='%s'>%s</a> approved %s","tdomf"),get_permalink($p->ID),$p->post_title,"<abbr title='$t_time'>$h_time</abbr>"); ?>
-          </li>
-         <?php } ?>
-    	  </ul>
-       <?php } ?>
-       
-       <?php if(($mod_total)> 0) { ?>
-         <h3><?php _e('Your Sumissions awaiting Moderation','tdomf'); ?></h3>
-         <ul>
-         <?php foreach($mod_posts as $p) { ?>
-          <li>"<?php echo $p->post_title; ?>"</li>
-         <?php } ?>
-    	  </ul>
-       <?php } ?>
-    <?php } ?>      
-      
-    <?php if(!empty($app_edits)) {
-            $num = number_format_i18n(count($app_edits));
-            $text = __ngettext( 'Your Last Approved Contribution', 'Your Last %d Approved Contributions', count($app_edits) );
-            ?>
-        <h3><?php printf($text, count($app_edits)); ?></h3>
-        <ul>
-        <?php foreach($app_edits as $app_edit) { ?>
-            <li>
-            <?php $edit = tdomf_get_edits(array('state' => 'approved', 'post_id' =>$app_edit->post_id, 'user_id' => $current_user->ID, 'limit' => 1));
-                  $edit = $edit[0];
-                  $t_time = get_the_time(__('Y/m/d g:i:s A'));
-                  $h_time = mysql2date(__('Y/m/d'), $edit->date);
-                  $post = get_post($app_edit->post_id);
-                  printf(__("<a href='%s'>%s</a> edited %s","tdomf"),get_permalink($app_edit->post_id),$post->post_title,"<abbr title='$t_time'>$h_time</abbr>"); ?>
-            </li>
-        <?php } ?>
-        </ul>
-    <?php } ?>
-    
-    <?php if(!empty($unapp_edits)) {
-            $num = number_format_i18n(count($unapp_edits));
-            $text = __ngettext( 'Your Contribution awaiting Moderation', 'Your Contributions awaiting Moderation', count($unapp_edits) );
-            ?>
-        <h3><?php printf($text, count($unapp_edits)); ?></h3>
-        <ul>
-        <?php foreach($unapp_edits as $unapp_edit) { ?>
-            <li>
-            <?php $edit = tdomf_get_edits(array('state' => 'unapproved', 'post_id' =>$unapp_edit->post_id, 'user_id' => $current_user->ID, 'limit' => 1));
-                  $edit = $edit[0];
-                  $t_time = get_the_time(__('Y/m/d g:i:s A'));
-                  $h_time = mysql2date(__('Y/m/d'), $edit->date);
-                  $post = get_post($unapp_edit->post_id);
-                  printf(__("<a href='%s'>%s</a> edited %s","tdomf"),get_permalink($unapp_edit->post_id),$post->post_title,"<abbr title='$t_time'>$h_time</abbr>"); ?>
-            </li>
-        <?php } ?>
-        </ul>
-    <?php } ?>
-    
-     </div>
-      
-     <!-- Form formatting -->     
-     <style>
-     .tdomf_form {
-     }
-     .tdomf_form fieldset legend {
-       #border-bottom: 1px dotted black;
-       font-weight: bold;
-       padding: 0px;
-       margin: 0px;
-       padding-bottom: 10px;
-     }
-     .tdomf_form_preview {
-       border: 1px dotted black;
-       padding: 5px;
-       margin: 5px;
-       margin-bottom: 20px;
-     }
-     .tdomf_form_preview p {
-       margin-left: 15px;
-     }
-     .tdomf_form .required {
-       color: red;
-     }
-     .tdomf_form fieldset {
-       margin-bottom: 10px;
-       border: 0;
-     }
-     </style>
-      
-    <?php $form_ids = tdomf_get_form_ids(); 
-          if(!empty($form_ids)) {
-            foreach($form_ids as $form_id) { 
-              if(tdomf_get_option_form(TDOMF_OPTION_INCLUDED_YOUR_SUBMISSIONS,$form_id->form_id)) {
-                  $edit = tdomf_get_option_form(TDOMF_OPTION_FORM_EDIT,$form_id->form_id); 
-                  $post_id = false;
-                  if(isset($_REQUEST['tdomf_post_id'])) { $post_id = intval($_REQUEST['tdomf_post_id']); }
-                  $good = true;
-                  if($edit && tdomf_check_permissions_form($form_id->form_id, $post_id) != NULL) {
-                      $good = false;
-                  }
-                  if($good) { ?>
-     <div class="wrap">
-        <h2><?php echo tdomf_get_option_form(TDOMF_OPTION_NAME,$form_id->form_id); ?></h2>
-        <p><?php echo tdomf_get_option_form(TDOMF_OPTION_DESCRIPTION,$form_id->form_id); ?></p>
-        <?php echo tdomf_generate_form($form_id->form_id); ?>
-        <br/><br/>
-     </div>
-          <?php } } }
-          }?>
-    <?php } ?>
-    
-  </div>
-
-  <p><center><?php _e('Powered by the <a href="http://thedeadone.net/software/tdo-mini-forms-wordpress-plugin/">TDO Mini Forms Plugin.','tdomf'); ?></a></center></p>
-  
-<?php
-}
-?>
+// Show the page!
+//
+function tdomf_show_your_submissions_menu() {
+  global $current_user;
+
+  // how many of the recently published/approved entries to see
+  //
+  $limit = 10;
+  
+  get_currentuserinfo();
+  
+  $tdomf_flag = get_usermeta($current_user->ID,TDOMF_KEY_FLAG);
+  $sub_total = tdomf_get_users_submitted_posts_count($current_user->ID);
+  $app_total = tdomf_get_users_published_posts_count($current_user->ID);
+  $user_status = get_usermeta($current_user->ID,TDOMF_KEY_STATUS);
+  $app_posts = tdomf_get_user_published_posts($current_user->ID,0,$limit);
+  $mod_posts = tdomf_get_user_draft_posts($current_user->ID);
+  $mod_total = count($mod_posts);
+  $fut_posts = tdomf_get_user_scheduled_posts($current_user->ID);
+  $fut_total = count($fut_posts);
+  $unapp_edits = tdomf_get_edits(array('state' => 'unapproved', 'unique_post_ids' => true, 'user_id' => $current_user->ID));
+  $app_edits = tdomf_get_edits(array('state' => 'approved', 'unique_post_ids' => true, 'user_id' => $current_user->ID, 'limit' => $limit));
+  
+  ?>
+
+  <div class="wrap">
+    <h2><?php _e('Your Submissions', 'tdomf') ?></h2>
+    
+    <?php if(in_array($_REQUEST['REMOTE_ADDR'],tdomf_get_ips_banned())) { ?>
+      <?php printf(__("You are logged on from the banned IP %s. If this is in error please contact the <a href='mailto:%s'>admins</a>.","tdomf"),$_REQUEST['REMOTE_ADDR'],get_bloginfo('admin_email')); ?>
+    <?php } else if($user_status == TDOMF_USER_STATUS_BANNED) { ?>
+      <?php printf(__("You are banned from using this functionality on this site. If this is in error please contact the <a href='mailto:%s'>admins</a>.","tdomf"),get_bloginfo('admin_email')); ?>
+    <?php } else { ?>
+
+      <p>
+      <?php if($user_status == TDOMF_USER_STATUS_TRUSTED) { ?>
+        <?php printf(__("Good to see you again <b>%s</b>! ","tdomf"),$current_user->display_name); ?>
+      <?php } else if($tdomf_flag) { ?>
+        <?php printf(__("Welcome back <b>%s</b>!","tdomf"),$current_user->display_name); ?>
+      <?php } else { ?>
+        <?php printf(__("Welcome <b>%s</b>.","tdomf"),$current_user->display_name); ?>
+      <?php } ?>
+      </p>
+      
+      <p><?php printf(__("From here you can submit posts to the %s using the form below and check on the status of your submissions.","tdomf"),get_bloginfo()); ?></p>
+      
+      <?php if(current_user_can('edit_others_posts') || current_user_can('manage_options')) { ?>
+      <ul>
+      <?php if(current_user_can('manage_options')) { ?>
+      <li><a href="admin.php?page=tdomf_show_options_menu"><?php _e("Configure Options","tdomf"); ?></a></li>
+      <li><a href="admin.php?page=tdomf_show_form_menu"><?php _e("Modify Form","tdomf"); ?></a></li>
+      <?php } ?>
+      <li><a href="admin.php?page=tdomf_show_mod_posts_menu"><?php _e("Moderate Submissions","tdomf"); ?></a></li>
+      </ul>
+      <?php } ?>
+
+    <?php if($tdomf_flag && ($sub_total > 0 || $app_total > 0)) { ?>
+        
+        <?php if($fut_total > 0) { ?>
+            <h3><?php printf(__('Your Next %d Scheduled Submissions','tdomf'),$fut_total); ?></h3>
+            <ul>
+         <?php foreach($fut_posts as $p) { ?>
+          <li>
+          <?php $t_time = get_the_time(__('Y/m/d g:i:s A'));
+                $m_time = $p->post_date;
+                $time = tdomf_get_post_time('G', true, $p);
+                if ( ( abs(time() - $time) ) < 86400 ) {
+                    $h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
+                } else {
+                    $h_time = mysql2date(__('Y/m/d'), $m_time);
+                } ?>
+                <?php printf(__("<a href='%s'>%s</a> will be published %s","tdomf"),get_permalink($p->ID),$p->post_title,"<abbr title='$t_time'>$h_time</abbr>"); ?>
+          </li>
+         <?php } ?>
+    	  </ul>
+        <?php } ?>
+        
+       <?php if($app_total > 0) { ?>
+         <h3><?php printf(__('Your Last %d Published Submissions','tdomf'),($app_total < 5) ? $app_total : 5 ); ?></h3>
+         <ul>
+         <?php foreach($app_posts as $p) { ?>
+          <li>
+          <?php $t_time = get_the_time(__('Y/m/d g:i:s A'));
+                $m_time = $p->post_date;
+                $time = tdomf_get_post_time('G', true, $p);
+                if ( ( abs(time() - $time) ) < 86400 ) {
+                    $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
+                } else {
+                    $h_time = mysql2date(__('Y/m/d'), $m_time);
+                } ?>
+                <?php printf(__("<a href='%s'>%s</a> approved %s","tdomf"),get_permalink($p->ID),$p->post_title,"<abbr title='$t_time'>$h_time</abbr>"); ?>
+          </li>
+         <?php } ?>
+    	  </ul>
+       <?php } ?>
+       
+       <?php if(($mod_total)> 0) { ?>
+         <h3><?php _e('Your Sumissions awaiting Moderation','tdomf'); ?></h3>
+         <ul>
+         <?php foreach($mod_posts as $p) { ?>
+          <li>"<?php echo $p->post_title; ?>"</li>
+         <?php } ?>
+    	  </ul>
+       <?php } ?>
+    <?php } ?>      
+      
+    <?php if(!empty($app_edits)) {
+            $num = number_format_i18n(count($app_edits));
+            $text = __ngettext( 'Your Last Approved Contribution', 'Your Last %d Approved Contributions', count($app_edits) );
+            ?>
+        <h3><?php printf($text, count($app_edits)); ?></h3>
+        <ul>
+        <?php foreach($app_edits as $app_edit) { ?>
+            <li>
+            <?php $edit = tdomf_get_edits(array('state' => 'approved', 'post_id' =>$app_edit->post_id, 'user_id' => $current_user->ID, 'limit' => 1));
+                  $edit = $edit[0];
+                  $t_time = get_the_time(__('Y/m/d g:i:s A'));
+                  $h_time = mysql2date(__('Y/m/d'), $edit->date);
+                  $post = get_post($app_edit->post_id);
+                  printf(__("<a href='%s'>%s</a> edited %s","tdomf"),get_permalink($app_edit->post_id),$post->post_title,"<abbr title='$t_time'>$h_time</abbr>"); ?>
+            </li>
+        <?php } ?>
+        </ul>
+    <?php } ?>
+    
+    <?php if(!empty($unapp_edits)) {
+            $num = number_format_i18n(count($unapp_edits));
+            $text = __ngettext( 'Your Contribution awaiting Moderation', 'Your Contributions awaiting Moderation', count($unapp_edits) );
+            ?>
+        <h3><?php printf($text, count($unapp_edits)); ?></h3>
+        <ul>
+        <?php foreach($unapp_edits as $unapp_edit) { ?>
+            <li>
+            <?php $edit = tdomf_get_edits(array('state' => 'unapproved', 'post_id' =>$unapp_edit->post_id, 'user_id' => $current_user->ID, 'limit' => 1));
+                  $edit = $edit[0];
+                  $t_time = get_the_time(__('Y/m/d g:i:s A'));
+                  $h_time = mysql2date(__('Y/m/d'), $edit->date);
+                  $post = get_post($unapp_edit->post_id);
+                  printf(__("<a href='%s'>%s</a> edited %s","tdomf"),get_permalink($unapp_edit->post_id),$post->post_title,"<abbr title='$t_time'>$h_time</abbr>"); ?>
+            </li>
+        <?php } ?>
+        </ul>
+    <?php } ?>
+    
+     </div>
+      
+     <!-- Form formatting -->     
+     <style>
+     .tdomf_form {
+     }
+     .tdomf_form fieldset legend {
+       #border-bottom: 1px dotted black;
+       font-weight: bold;
+       padding: 0px;
+       margin: 0px;
+       padding-bottom: 10px;
+     }
+     .tdomf_form_preview {
+       border: 1px dotted black;
+       padding: 5px;
+       margin: 5px;
+       margin-bottom: 20px;
+     }
+     .tdomf_form_preview p {
+       margin-left: 15px;
+     }
+     .tdomf_form .required {
+       color: red;
+     }
+     .tdomf_form fieldset {
+       margin-bottom: 10px;
+       border: 0;
+     }
+     </style>
+      
+    <?php $form_ids = tdomf_get_form_ids(); 
+          if(!empty($form_ids)) {
+            foreach($form_ids as $form_id) { 
+              if(tdomf_get_option_form(TDOMF_OPTION_INCLUDED_YOUR_SUBMISSIONS,$form_id->form_id)) {
+                  $edit = tdomf_get_option_form(TDOMF_OPTION_FORM_EDIT,$form_id->form_id); 
+                  $post_id = false;
+                  if(isset($_REQUEST['tdomf_post_id'])) { $post_id = intval($_REQUEST['tdomf_post_id']); }
+                  $good = true;
+                  if($edit && tdomf_check_permissions_form($form_id->form_id, $post_id) != NULL) {
+                      $good = false;
+                  }
+                  if($good) { ?>
+     <div class="wrap">
+        <h2><?php echo tdomf_get_option_form(TDOMF_OPTION_NAME,$form_id->form_id); ?></h2>
+        <p><?php echo tdomf_get_option_form(TDOMF_OPTION_DESCRIPTION,$form_id->form_id); ?></p>
+        <?php echo tdomf_generate_form($form_id->form_id); ?>
+        <br/><br/>
+     </div>
+          <?php } } }
+          }?>
+    <?php } ?>
+    
+  </div>
+
+  <p><center><?php _e('Powered by the <a href="http://thedeadone.net/software/tdo-mini-forms-wordpress-plugin/">TDO Mini Forms Plugin.','tdomf'); ?></a></center></p>
+  
+<?php
+}
+?>
Index: tdomf.php
===================================================================
--- tdomf.php	(revision 169181)
+++ tdomf.php	(working copy)
@@ -1,390 +1,390 @@
-<?php
-/*
-Plugin Name: TDO Mini Forms
-Plugin URI: http://thedeadone.net/download/tdo-mini-forms-wordpress-plugin/
-Description: This plugin allows you to add custom posting forms to your website that allows your readers (including non-registered) to submit posts.
-Version: 0.13.5
-Author: Mark Cunningham
-Author URI: http://thedeadone.net
-*/
-
-/*  Copyright 2006-2007  Mark Cunningham  (email : tdomf@thedeadone.net)
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-////////////////////////////////////////////////////////////////////////////////
-// Version History
-//
-// See readme.txt
-//
-// v0.13.5
-// - Previous recent versions prevented people from enabling spam. The code was
-//     written in such a way that the spam protection had to be enabled before
-//     spam protection could be enabled!
-// - Replaced the usage of $_REQUEST with $_POST in form hacker. Not sure if
-//     it'll have any impact on the form-hacker-reset problem but it should
-//     be safer
-// - Have tested and fixed extra slashes being added on WP 2.8.x builds with and
-//     without magic quotes turned on. 
-// - Refactored Custom Field, Content, Excerpt widgets and created a common
-//     textfield and textarea (as part of the fix for magic quotes). This allows
-//     me to add new features to multiple widgets at a time. 
-//
-////////////////////////////////////////////////////////////////////////////////
-
-/*
-////////////////////////////////////////////////////////////////////////////////
-Work Queue:
-
-Bugs
-====
-   - 'gmt_offset' not calcualted in %%SUBMISSIONDATE%%
-   - not working with vbbridge - http://thedeadone.net/forum/?p=2805#comment-4296
-   - image capatcha must update after failed "submit"
-   - Possible incompatibility with Google XML Sitemaps plugin - http://thedeadone.net/forum/?p=1923
-   - Bug in GeoMashup - http://thedeadone.net/forum/?p=2062#comment-4070
-   - Bug TwitterTools not working with TDOMF publish - http://thedeadone.net/forum/?p=1916#comment-3972
-   - Sanatized file upload filenames/paths - http://thedeadone.net/blog/v0127-of-tdo-mini-forms-just-released/comment-page-1/#comment-181601
-   - diacritc marks reset form hacker: http://thedeadone.net/forum/?p=1888#topic-1888
-   - Bug: Illegal characters in file names: http://thedeadone.net/forum/?p=1544#topic-1544
-   - Bug: Weird "From" email for post moderation emails: http://thedeadone.net/forum/?p=71
-   - Bug: No image preview when using attachment options: http://thedeadone.net/forum/?p=1498#comment-3485
-   - Bug: slashes: http://thedeadone.net/forum/?p=1444#comment-3331 (but it might be related to AJAX!)
-   - Bug: Widget configuration panels not showing up: http://thedeadone.net/forum/?p=1379
-   - Investigate: no sidebars in widget configuration in IE.7
-   - Investigate: tinymce conflict with AJAX form
-   - Investigate: upload-link error:
-       http://wordpress.org/support/topic/186919#post-838957
-
-TODO
-====
-   - Allow options to format the "submitted by" text and also disabling for registered users
-   - Quicktag like options for form hacker
-   - Investigate: Copy widgets to other forms
-   - Allow Error, StyleSheet and Validation Form Hacking
-   - Allow only the Form or the Preview to be "hacked" in the Form Hacker
-   - Add Error Warning for custom field widgets when non-unique keys used
-   - Investigate: Auto bring up the conf panel for widgets on the "fix" links
-
-Feature Requests
-================
-   - delete spam straight away (TDOMF_OPTION_SPAM_AUTO_DELETE_NOW already setup, just not implemented)
-   - parent category - http://thedeadone.net/forum/?p=3205#comment-4524
-   - display less information and perhaps some sort of funky JS to order columns - http://thedeadone.net/forum/?p=3526#comment-4514
-   - category names instead of ids - http://thedeadone.net/forum/?p=3171#topic-3171
-   - widget class have functions to allow message customisation
-   - "delete all spam"
-   - "recheck for spam"
-   - Most pages private... - http://thedeadone.net/forum/?p=224#comment-4221
-   - Requred option in category field
-   - Related posts! http://thedeadone.net/forum/?p=1904#comment-3937
-   - Entry in FAQ: Widget Changes not showing up
-   - Investigate: Integeration with NextGen
-   - Template: List of submitters
-   - Code: Tags as checkboxes - http://thedeadone.net/forum/?p=1377
-   - Some simple javascript to track number of chars/words typed so far in textarea: http://thedeadone.net/forum/?p=1321
-   - Study: http://wordpress.org/extend/plugins/download-monitor/ integration
-
-Other
-=====
-   - Code to add a email hook on publish - http://thedeadone.net/forum/?p=3195#comment-4519
-   - http://thedeadone.net/forum/?p=2100#comment-4278 (alternative input?)   
-
-
-*/
-
-/*
-Magic Quotes for 0.13.5:
-
-Wordpress 2.8.2
-+++++++++++++++
-
-Magic Quotes: ON
-================
-Widget Screen    : OK
-Form Hacker      : OK
-
-[AJAX: On]         Title | Content | Excerpt | CF: TextArea | CF: TextField
---------------------------------------------------------------------------          
-New-Post-Preview : OK    | OK      | OK      | OK           | OK
-New-Post-Submit  : OK    | OK      | OK      | OK           | OK
-Edit-Post-Preview: OK    | OK      | N/A     | N/A          | N/A
-Edit-Post-Submit : OK    | OK      | N/A     | N/A          | N/A
-
-[AJAX: Off]        Title | Content | Excerpt | CF: TextArea | CF: TextField
---------------------------------------------------------------------------
-New-Post-Preview : OK    | OK      | OK      | OK           | OK
-New-Post-Submit  : OK    | OK      | OK      | OK           | OK
-Edit-Post-Preview: OK    | OK      | N/A     | N/A          | N/A
-Edit-Post-Submit : OK    | OK      | N/A     | N/A          | N/A
-
-Magic Quotes: OFF
-=================
-Widget Screen    : OK
-Form Hacker      : OK
-
-[AJAX: On]         Title | Content | Excerpt | CF: TextArea | CF: TextField
---------------------------------------------------------------------------          
-New-Post-Preview : OK    | OK      | OK      | OK           | OK
-New-Post-Submit  : OK    | OK      | OK      | OK           | OK
-Edit-Post-Preview: OK    | OK      | N/A     | N/A          | N/A
-Edit-Post-Submit : OK    | OK      | N/A     | N/A          | N/A
-
-[AJAX: Off]        Title | Content | Excerpt | CF: TextArea | CF: TextField
---------------------------------------------------------------------------
-New-Post-Preview : OK    | OK      | OK      | OK           | OK
-New-Post-Submit  : OK    | OK      | OK      | OK           | OK
-Edit-Post-Preview: OK    | OK      | N/A     | N/A          | N/A
-Edit-Post-Submit : OK    | OK      | N/A     | N/A          | N/A
-
-*/
-
-/*
-////////////////////////////////////////////////////////////////////////////////
-Notes:
- - Potential nice hack: query.php @ line 1479
-   $this->posts = apply_filters('the_posts', $this->posts);
-     1. is single/page [should include category and index?]
-     2. what post?
-     3. is it tdomf, draft/unmoderation, not spam, viewer is submitter
-     4. add to array
-     This will allow users see their submitted posts, however comments should
-     be disabled as they cannot be used in preview mode
- - What Clickable links in your posts? http://thedeadone.net/forum/?p=500#comment-1598
-*/
-
- /*
-////////////////////////////////////////////////////////////////////////////////
-TODO for future versions
-
-Known Bugs
-- Upload Link error
-- TinyMCE integration problem with AJAX
-
-New Features
-- Option to redirect all comment notifications on submitted posts to the admin (globally or per form)
-- Allow moderators append a message to the approved/rejected notification (allows communication between submitter and moderator)
-- Widget Manager Menu
-  * Info about loaded widgets
-  * Disable loading of specific widgets
-- Style Sheet Editor
-  * Preview
-  * Select from pre-configured Styles
-  * Submit new style to include in TDOMF
-- Email verification of non-registered users
-- Manage Downloads page
-- Authors of posts should be able to see "previews" of post
-- Get input during validation of form (for capatchas)
-- Option to use "Post ready for review" instead of draft for unapproved submitted posts
-- Turn Forms into multiple steps
-- Shortcode Support
-
-New Form Options
-- Force Preview before submission
-- Hide Form on Preview
-- Forms can be used to submit links, emails, etc.
-- Select Form Style/include Custom CSS
-
-New Widgets
-- Widget to allow user to enter a date to post the submission (as in future post)
-- Widget to allow submitter to copy the submission to another email
-- Widget that inputs only title
-  * or that allows formatting of title by
-  * user-input
-  * custom field
-  * username/submitter
-  * date submitted (requires date/time format)
-  * PHP code
-- Login/Register/Who Am I Widget
-
-Existing Widget Improvements
-- Any widget with a size or length field should be customisable.
-- Textfield Class (support numeric, date, email, webpage, etc.)
-- Textarea Class
-- Copy Widget to another Form
-- Individual save
-- Upload Files
-  * Multiple Instances
-  * Thumbnail size
-  * Limit size of image by w/h
-  * Image cropping
-  * Title field for file links/attachment pages
-  * Nicer integration: background uploading using iframe
-  * Prevent submission until files uploaded
-  * Progress bar
-- Content
-  * TinyMCE Integration
-  * Allow users to define their own quicktags
-  * Mechanism to allow sumitter to select where the link/image for upload should go
-  * Default Value
-- Custom Field: Textarea
-  * TinyMCE Integration
-  * Allow users to define their own quicktags
-  * Mechanism to allow sumitter to select where the link/image for upload should go
-  * Default Value
-- Custom Field
-  * Radio Groups
-  * Multiple Checkboxes (grid-layout)
-- Custom Field: Textfield
-  * Numeric
-  * Date
-- Custom Field: Select
-  * Required support
-- Tags
-  * Select from existing tag list or tag cloud
-  * Select from only a specified set of tags
-- 1 Question Captcha
-  * Random questions for Captcha
-- Category
-  * Co-operate with "Set Category from GET variables" Widget
-- Notify Me
-  * Option to always notify submitter
-- Image Captcha
-  * Do not reload image on every preview (would be resolved by a seperate validation step)
-- Text
-  * Option to not use the form formatting (i.e. no "<fieldset>" tags before and after)
-  * Option to have the text popup (would require a HTML space for the link)
-- Set Category from GET variables
-  * Add options (or at least information) for this widget
-  * Co-operate with "Categories" Widget
-- Who Am I
-  * Integration with WP-OpenID?
-  * Allow login as part of form submit
-- Categories
-  * Categories displayed but unselectable
-
-Template Tags
-- Log
-- Moderation Queue
-- Approved Posts
-- File Info
-- Country codes on submitter's IP
-- Image Tags
-
-Misc
-- Documentation on creating your own widgets
-
-////////////////////////////////////////////////////////////////////////////////
-*/
-
-///////////////////////////////////////////////////
-// Defines and other global vars for this Plugin //
-///////////////////////////////////////////////////
-
-// Older versions of PHP may not define DIRECTORY_SEPARATOR so define it here,
-// just in case.
-if(!defined('DIRECTORY_SEPARATOR')) {
-  define('DIRECTORY_SEPARATOR','/');
-}
-
-// Build Number (must be a integer)
-define("TDOMF_BUILD", "51");
-// Version Number (can be text)
-define("TDOMF_VERSION", "0.13.4");
-
-///////////////////////////////////////
-// 0.1 to 0.5 Settings (no longer used)
-//
-define("TDOMF_ACCESS_LEVEL", "tdomf_access_level");
-define("TDOMF_NOTIFY_LEVEL", "tdomf_notify_level");
-
-///////////////////////////////////////
-// 0.6 Settings (no longer used)
-//
-define('TDOMF_NOTIFY','tdomf_notify');
-define("TDOMF_ITEMS_PER_PAGE", 30);
-define("TDOMF_POSTS_INDEX",    0);
-define("TDOMF_USERS_INDEX",    1);
-define("TDOMF_IPS_INDEX",      2);
-define("TDOMF_OPTIONS_INDEX",  3);
-
-/////////////////
-// 0.6 Settings
-//
-define("TDOMF_ACCESS_ROLES", "tdomf_access_roles");
-define("TDOMF_NOTIFY_ROLES", "tdomf_notify_roles");
-define("TDOMF_DEFAULT_CATEGORY", "tdomf_default_category");
-define("TDOMF_DEFAULT_AUTHOR", "tdomf_default_author");
-define("TDOMF_AUTO_FIX_AUTHOR", "tdomf_auto_fix_author");
-define("TDOMF_BANNED_IPS", "tdomf_banned_ips");
-//
-// These keys are used to store info about a post, on the post.
-// Keys with underscore prefix (i.e. "_") are hidden from the general user. Keys
-// without can be modified and displayed using Wordpress normal features such as
-// template tags and custom fields editor.
-//
-define("TDOMF_KEY_FLAG","_tdomf_flag");
-define("TDOMF_KEY_NAME","Author Name");
-define("TDOMF_KEY_EMAIL","Author Email");
-define("TDOMF_KEY_WEB","Author Webpage");
-define("TDOMF_KEY_IP","_tdomf_original_poster_ip");
-define("TDOMF_KEY_USER_ID","_tdomf_original_poster_id");
-define("TDOMF_KEY_USER_NAME","Original Submitter Username");
-//
-// This key is very important. It determines if a user is trusted or banned..
-//
-define("TDOMF_KEY_STATUS","_tdomf_status");
-
-
-/////////////////
-// 0.7 Settings
-//
-define('TDOMF_FOLDER', dirname(plugin_basename(__FILE__)));
-define('TDOMF_FULLPATH', WP_PLUGIN_DIR.DIRECTORY_SEPARATOR.TDOMF_FOLDER.DIRECTORY_SEPARATOR);
-#define('TDOMF_FULLPATH', ABSPATH.PLUGINDIR.DIRECTORY_SEPARATOR.TDOMF_FOLDER.DIRECTORY_SEPARATOR);
-define('TDOMF_URLPATH', get_option('siteurl').'/wp-content/plugins/'.TDOMF_FOLDER.'/');
-define('TDOMF_WIDGET_PATH',TDOMF_FULLPATH.'widgets/');
-define('TDOMF_VERSION_CURRENT', "tdomf_version_current");
-define('TDOMF_LOG', "tdomf_log");
-define('TDOMF_OPTION_MODERATION', "tdomf_enable_moderation");
-define('TDOMF_OPTION_TRUST_COUNT', "tdomf_trust_count");
-define('TDOMF_OPTION_ALLOW_EVERYONE', "tdomf_allow_everyone");
-define('TDOMF_OPTION_AJAX', "tdomf_ajax");
-define('TDOMF_OPTION_PREVIEW', "tdomf_preview");
-define('TDOMF_OPTION_FROM_EMAIL', "tdomf_from_email");
-define('TDOMF_OPTION_AUTHOR_THEME_HACK', "tdomf_author_submitter");
-define('TDOMF_OPTION_FORM_ORDER', "tdomf_form_order");
-define('TDOMF_OPTION_ADD_SUBMITTER', "tdomf_add_submitter_info");
-define('TDOMF_CAPABILITY_CAN_SEE_FORM', "tdomf_can_see_form");
-define('TDOMF_STAT_SUBMITTED', "tdomf_stat_submitted");
-define('TDOMF_USER_STATUS_OK', "Normal");
-define('TDOMF_USER_STATUS_BANNED', "Banned");
-define('TDOMF_USER_STATUS_TRUSTED', "Trusted");
-define('TDOMF_KEY_NOTIFY_EMAIL', "_tdomf_notify_email");
-
-/////////////////
-// 0.8 Settings
-//
-define('TDOMF_UPLOAD_PERMS',0777);
-define('TDOMF_UPLOAD_TIMEOUT',(60 * 60)); // 1 hour
-define('TDOMF_KEY_DOWNLOAD_COUNT',"_tdomf_download_count_");
-define('TDOMF_KEY_DOWNLOAD_TYPE',"_tdomf_download_type_");
-define('TDOMF_KEY_DOWNLOAD_PATH',"_tdomf_download_path_");
-define('TDOMF_KEY_DOWNLOAD_NAME',"_tdomf_download_name_");
-define('TDOMF_KEY_DOWNLOAD_CMD_OUTPUT',"_tdomf_download_cmd_output_");
-
-/////////////////
-// 0.9 Settings
-//
-define('TDOMF_KEY_DOWNLOAD_THUMB',"_tdomf_download_thumb_");
-define('TDOMF_OPTION_DISABLE_ERROR_MESSAGES',"tdomf_disable_error_messages");
-define('TDOMF_OPTION_EXTRA_LOG_MESSAGES',"tdomf_extra_log_messages");
-define('TDOMF_OPTION_YOUR_SUBMISSIONS',"tdomf_your_submissions");
-define('TDOMF_WIDGET_URLPATH',TDOMF_URLPATH.'widgets/');
-
+<?php
+/*
+Plugin Name: TDO Mini Forms
+Plugin URI: http://thedeadone.net/download/tdo-mini-forms-wordpress-plugin/
+Description: This plugin allows you to add custom posting forms to your website that allows your readers (including non-registered) to submit posts.
+Version: 0.13.5
+Author: Mark Cunningham
+Author URI: http://thedeadone.net
+*/
+
+/*  Copyright 2006-2007  Mark Cunningham  (email : tdomf@thedeadone.net)
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+////////////////////////////////////////////////////////////////////////////////
+// Version History
+//
+// See readme.txt
+//
+// v0.13.5
+// - Previous recent versions prevented people from enabling spam. The code was
+//     written in such a way that the spam protection had to be enabled before
+//     spam protection could be enabled!
+// - Replaced the usage of $_REQUEST with $_POST in form hacker. Not sure if
+//     it'll have any impact on the form-hacker-reset problem but it should
+//     be safer
+// - Have tested and fixed extra slashes being added on WP 2.8.x builds with and
+//     without magic quotes turned on. 
+// - Refactored Custom Field, Content, Excerpt widgets and created a common
+//     textfield and textarea (as part of the fix for magic quotes). This allows
+//     me to add new features to multiple widgets at a time. 
+//
+////////////////////////////////////////////////////////////////////////////////
+
+/*
+////////////////////////////////////////////////////////////////////////////////
+Work Queue:
+
+Bugs
+====
+   - 'gmt_offset' not calcualted in %%SUBMISSIONDATE%%
+   - not working with vbbridge - http://thedeadone.net/forum/?p=2805#comment-4296
+   - image capatcha must update after failed "submit"
+   - Possible incompatibility with Google XML Sitemaps plugin - http://thedeadone.net/forum/?p=1923
+   - Bug in GeoMashup - http://thedeadone.net/forum/?p=2062#comment-4070
+   - Bug TwitterTools not working with TDOMF publish - http://thedeadone.net/forum/?p=1916#comment-3972
+   - Sanatized file upload filenames/paths - http://thedeadone.net/blog/v0127-of-tdo-mini-forms-just-released/comment-page-1/#comment-181601
+   - diacritc marks reset form hacker: http://thedeadone.net/forum/?p=1888#topic-1888
+   - Bug: Illegal characters in file names: http://thedeadone.net/forum/?p=1544#topic-1544
+   - Bug: Weird "From" email for post moderation emails: http://thedeadone.net/forum/?p=71
+   - Bug: No image preview when using attachment options: http://thedeadone.net/forum/?p=1498#comment-3485
+   - Bug: slashes: http://thedeadone.net/forum/?p=1444#comment-3331 (but it might be related to AJAX!)
+   - Bug: Widget configuration panels not showing up: http://thedeadone.net/forum/?p=1379
+   - Investigate: no sidebars in widget configuration in IE.7
+   - Investigate: tinymce conflict with AJAX form
+   - Investigate: upload-link error:
+       http://wordpress.org/support/topic/186919#post-838957
+
+TODO
+====
+   - Allow options to format the "submitted by" text and also disabling for registered users
+   - Quicktag like options for form hacker
+   - Investigate: Copy widgets to other forms
+   - Allow Error, StyleSheet and Validation Form Hacking
+   - Allow only the Form or the Preview to be "hacked" in the Form Hacker
+   - Add Error Warning for custom field widgets when non-unique keys used
+   - Investigate: Auto bring up the conf panel for widgets on the "fix" links
+
+Feature Requests
+================
+   - delete spam straight away (TDOMF_OPTION_SPAM_AUTO_DELETE_NOW already setup, just not implemented)
+   - parent category - http://thedeadone.net/forum/?p=3205#comment-4524
+   - display less information and perhaps some sort of funky JS to order columns - http://thedeadone.net/forum/?p=3526#comment-4514
+   - category names instead of ids - http://thedeadone.net/forum/?p=3171#topic-3171
+   - widget class have functions to allow message customisation
+   - "delete all spam"
+   - "recheck for spam"
+   - Most pages private... - http://thedeadone.net/forum/?p=224#comment-4221
+   - Requred option in category field
+   - Related posts! http://thedeadone.net/forum/?p=1904#comment-3937
+   - Entry in FAQ: Widget Changes not showing up
+   - Investigate: Integeration with NextGen
+   - Template: List of submitters
+   - Code: Tags as checkboxes - http://thedeadone.net/forum/?p=1377
+   - Some simple javascript to track number of chars/words typed so far in textarea: http://thedeadone.net/forum/?p=1321
+   - Study: http://wordpress.org/extend/plugins/download-monitor/ integration
+
+Other
+=====
+   - Code to add a email hook on publish - http://thedeadone.net/forum/?p=3195#comment-4519
+   - http://thedeadone.net/forum/?p=2100#comment-4278 (alternative input?)   
+
+
+*/
+
+/*
+Magic Quotes for 0.13.5:
+
+Wordpress 2.8.2
++++++++++++++++
+
+Magic Quotes: ON
+================
+Widget Screen    : OK
+Form Hacker      : OK
+
+[AJAX: On]         Title | Content | Excerpt | CF: TextArea | CF: TextField
+--------------------------------------------------------------------------          
+New-Post-Preview : OK    | OK      | OK      | OK           | OK
+New-Post-Submit  : OK    | OK      | OK      | OK           | OK
+Edit-Post-Preview: OK    | OK      | N/A     | N/A          | N/A
+Edit-Post-Submit : OK    | OK      | N/A     | N/A          | N/A
+
+[AJAX: Off]        Title | Content | Excerpt | CF: TextArea | CF: TextField
+--------------------------------------------------------------------------
+New-Post-Preview : OK    | OK      | OK      | OK           | OK
+New-Post-Submit  : OK    | OK      | OK      | OK           | OK
+Edit-Post-Preview: OK    | OK      | N/A     | N/A          | N/A
+Edit-Post-Submit : OK    | OK      | N/A     | N/A          | N/A
+
+Magic Quotes: OFF
+=================
+Widget Screen    : OK
+Form Hacker      : OK
+
+[AJAX: On]         Title | Content | Excerpt | CF: TextArea | CF: TextField
+--------------------------------------------------------------------------          
+New-Post-Preview : OK    | OK      | OK      | OK           | OK
+New-Post-Submit  : OK    | OK      | OK      | OK           | OK
+Edit-Post-Preview: OK    | OK      | N/A     | N/A          | N/A
+Edit-Post-Submit : OK    | OK      | N/A     | N/A          | N/A
+
+[AJAX: Off]        Title | Content | Excerpt | CF: TextArea | CF: TextField
+--------------------------------------------------------------------------
+New-Post-Preview : OK    | OK      | OK      | OK           | OK
+New-Post-Submit  : OK    | OK      | OK      | OK           | OK
+Edit-Post-Preview: OK    | OK      | N/A     | N/A          | N/A
+Edit-Post-Submit : OK    | OK      | N/A     | N/A          | N/A
+
+*/
+
+/*
+////////////////////////////////////////////////////////////////////////////////
+Notes:
+ - Potential nice hack: query.php @ line 1479
+   $this->posts = apply_filters('the_posts', $this->posts);
+     1. is single/page [should include category and index?]
+     2. what post?
+     3. is it tdomf, draft/unmoderation, not spam, viewer is submitter
+     4. add to array
+     This will allow users see their submitted posts, however comments should
+     be disabled as they cannot be used in preview mode
+ - What Clickable links in your posts? http://thedeadone.net/forum/?p=500#comment-1598
+*/
+
+ /*
+////////////////////////////////////////////////////////////////////////////////
+TODO for future versions
+
+Known Bugs
+- Upload Link error
+- TinyMCE integration problem with AJAX
+
+New Features
+- Option to redirect all comment notifications on submitted posts to the admin (globally or per form)
+- Allow moderators append a message to the approved/rejected notification (allows communication between submitter and moderator)
+- Widget Manager Menu
+  * Info about loaded widgets
+  * Disable loading of specific widgets
+- Style Sheet Editor
+  * Preview
+  * Select from pre-configured Styles
+  * Submit new style to include in TDOMF
+- Email verification of non-registered users
+- Manage Downloads page
+- Authors of posts should be able to see "previews" of post
+- Get input during validation of form (for capatchas)
+- Option to use "Post ready for review" instead of draft for unapproved submitted posts
+- Turn Forms into multiple steps
+- Shortcode Support
+
+New Form Options
+- Force Preview before submission
+- Hide Form on Preview
+- Forms can be used to submit links, emails, etc.
+- Select Form Style/include Custom CSS
+
+New Widgets
+- Widget to allow user to enter a date to post the submission (as in future post)
+- Widget to allow submitter to copy the submission to another email
+- Widget that inputs only title
+  * or that allows formatting of title by
+  * user-input
+  * custom field
+  * username/submitter
+  * date submitted (requires date/time format)
+  * PHP code
+- Login/Register/Who Am I Widget
+
+Existing Widget Improvements
+- Any widget with a size or length field should be customisable.
+- Textfield Class (support numeric, date, email, webpage, etc.)
+- Textarea Class
+- Copy Widget to another Form
+- Individual save
+- Upload Files
+  * Multiple Instances
+  * Thumbnail size
+  * Limit size of image by w/h
+  * Image cropping
+  * Title field for file links/attachment pages
+  * Nicer integration: background uploading using iframe
+  * Prevent submission until files uploaded
+  * Progress bar
+- Content
+  * TinyMCE Integration
+  * Allow users to define their own quicktags
+  * Mechanism to allow sumitter to select where the link/image for upload should go
+  * Default Value
+- Custom Field: Textarea
+  * TinyMCE Integration
+  * Allow users to define their own quicktags
+  * Mechanism to allow sumitter to select where the link/image for upload should go
+  * Default Value
+- Custom Field
+  * Radio Groups
+  * Multiple Checkboxes (grid-layout)
+- Custom Field: Textfield
+  * Numeric
+  * Date
+- Custom Field: Select
+  * Required support
+- Tags
+  * Select from existing tag list or tag cloud
+  * Select from only a specified set of tags
+- 1 Question Captcha
+  * Random questions for Captcha
+- Category
+  * Co-operate with "Set Category from GET variables" Widget
+- Notify Me
+  * Option to always notify submitter
+- Image Captcha
+  * Do not reload image on every preview (would be resolved by a seperate validation step)
+- Text
+  * Option to not use the form formatting (i.e. no "<fieldset>" tags before and after)
+  * Option to have the text popup (would require a HTML space for the link)
+- Set Category from GET variables
+  * Add options (or at least information) for this widget
+  * Co-operate with "Categories" Widget
+- Who Am I
+  * Integration with WP-OpenID?
+  * Allow login as part of form submit
+- Categories
+  * Categories displayed but unselectable
+
+Template Tags
+- Log
+- Moderation Queue
+- Approved Posts
+- File Info
+- Country codes on submitter's IP
+- Image Tags
+
+Misc
+- Documentation on creating your own widgets
+
+////////////////////////////////////////////////////////////////////////////////
+*/
+
+///////////////////////////////////////////////////
+// Defines and other global vars for this Plugin //
+///////////////////////////////////////////////////
+
+// Older versions of PHP may not define DIRECTORY_SEPARATOR so define it here,
+// just in case.
+if(!defined('DIRECTORY_SEPARATOR')) {
+  define('DIRECTORY_SEPARATOR','/');
+}
+
+// Build Number (must be a integer)
+define("TDOMF_BUILD", "51");
+// Version Number (can be text)
+define("TDOMF_VERSION", "0.13.4");
+
+///////////////////////////////////////
+// 0.1 to 0.5 Settings (no longer used)
+//
+define("TDOMF_ACCESS_LEVEL", "tdomf_access_level");
+define("TDOMF_NOTIFY_LEVEL", "tdomf_notify_level");
+
+///////////////////////////////////////
+// 0.6 Settings (no longer used)
+//
+define('TDOMF_NOTIFY','tdomf_notify');
+define("TDOMF_ITEMS_PER_PAGE", 30);
+define("TDOMF_POSTS_INDEX",    0);
+define("TDOMF_USERS_INDEX",    1);
+define("TDOMF_IPS_INDEX",      2);
+define("TDOMF_OPTIONS_INDEX",  3);
+
+/////////////////
+// 0.6 Settings
+//
+define("TDOMF_ACCESS_ROLES", "tdomf_access_roles");
+define("TDOMF_NOTIFY_ROLES", "tdomf_notify_roles");
+define("TDOMF_DEFAULT_CATEGORY", "tdomf_default_category");
+define("TDOMF_DEFAULT_AUTHOR", "tdomf_default_author");
+define("TDOMF_AUTO_FIX_AUTHOR", "tdomf_auto_fix_author");
+define("TDOMF_BANNED_IPS", "tdomf_banned_ips");
+//
+// These keys are used to store info about a post, on the post.
+// Keys with underscore prefix (i.e. "_") are hidden from the general user. Keys
+// without can be modified and displayed using Wordpress normal features such as
+// template tags and custom fields editor.
+//
+define("TDOMF_KEY_FLAG","_tdomf_flag");
+define("TDOMF_KEY_NAME","Author Name");
+define("TDOMF_KEY_EMAIL","Author Email");
+define("TDOMF_KEY_WEB","Author Webpage");
+define("TDOMF_KEY_IP","_tdomf_original_poster_ip");
+define("TDOMF_KEY_USER_ID","_tdomf_original_poster_id");
+define("TDOMF_KEY_USER_NAME","Original Submitter Username");
+//
+// This key is very important. It determines if a user is trusted or banned..
+//
+define("TDOMF_KEY_STATUS","_tdomf_status");
+
+
+/////////////////
+// 0.7 Settings
+//
+define('TDOMF_FOLDER', dirname(plugin_basename(__FILE__)));
+define('TDOMF_FULLPATH', WP_PLUGIN_DIR.DIRECTORY_SEPARATOR.TDOMF_FOLDER.DIRECTORY_SEPARATOR);
+#define('TDOMF_FULLPATH', ABSPATH.PLUGINDIR.DIRECTORY_SEPARATOR.TDOMF_FOLDER.DIRECTORY_SEPARATOR);
+define('TDOMF_URLPATH', get_option('siteurl').'/wp-content/plugins/'.TDOMF_FOLDER.'/');
+define('TDOMF_WIDGET_PATH',TDOMF_FULLPATH.'widgets/');
+define('TDOMF_VERSION_CURRENT', "tdomf_version_current");
+define('TDOMF_LOG', "tdomf_log");
+define('TDOMF_OPTION_MODERATION', "tdomf_enable_moderation");
+define('TDOMF_OPTION_TRUST_COUNT', "tdomf_trust_count");
+define('TDOMF_OPTION_ALLOW_EVERYONE', "tdomf_allow_everyone");
+define('TDOMF_OPTION_AJAX', "tdomf_ajax");
+define('TDOMF_OPTION_PREVIEW', "tdomf_preview");
+define('TDOMF_OPTION_FROM_EMAIL', "tdomf_from_email");
+define('TDOMF_OPTION_AUTHOR_THEME_HACK', "tdomf_author_submitter");
+define('TDOMF_OPTION_FORM_ORDER', "tdomf_form_order");
+define('TDOMF_OPTION_ADD_SUBMITTER', "tdomf_add_submitter_info");
+define('TDOMF_CAPABILITY_CAN_SEE_FORM', "tdomf_can_see_form");
+define('TDOMF_STAT_SUBMITTED', "tdomf_stat_submitted");
+define('TDOMF_USER_STATUS_OK', "Normal");
+define('TDOMF_USER_STATUS_BANNED', "Banned");
+define('TDOMF_USER_STATUS_TRUSTED', "Trusted");
+define('TDOMF_KEY_NOTIFY_EMAIL', "_tdomf_notify_email");
+
+/////////////////
+// 0.8 Settings
+//
+define('TDOMF_UPLOAD_PERMS',0777);
+define('TDOMF_UPLOAD_TIMEOUT',(60 * 60)); // 1 hour
+define('TDOMF_KEY_DOWNLOAD_COUNT',"_tdomf_download_count_");
+define('TDOMF_KEY_DOWNLOAD_TYPE',"_tdomf_download_type_");
+define('TDOMF_KEY_DOWNLOAD_PATH',"_tdomf_download_path_");
+define('TDOMF_KEY_DOWNLOAD_NAME',"_tdomf_download_name_");
+define('TDOMF_KEY_DOWNLOAD_CMD_OUTPUT',"_tdomf_download_cmd_output_");
+
+/////////////////
+// 0.9 Settings
+//
+define('TDOMF_KEY_DOWNLOAD_THUMB',"_tdomf_download_thumb_");
+define('TDOMF_OPTION_DISABLE_ERROR_MESSAGES',"tdomf_disable_error_messages");
+define('TDOMF_OPTION_EXTRA_LOG_MESSAGES',"tdomf_extra_log_messages");
+define('TDOMF_OPTION_YOUR_SUBMISSIONS',"tdomf_your_submissions");
+define('TDOMF_WIDGET_URLPATH',TDOMF_URLPATH.'widgets/');
+
 ////////////////
 // 0.10 Settings
 //
@@ -411,7 +411,7 @@
 define("TDOMF_HIDE_REGISTER_GLOBAL_ERROR", false);
 
 define('TDOMF_OPTION_WIDGET_MAX_WIDTH',"tdomf_form_widget_max_width");
-define('TDOMF_OPTION_WIDGET_MAX_LENGTH',"tdomf_form_widget_max_length");
+define('TDOMF_OPTION_WIDGET_MAX_HEIGHT',"tdomf_form_widget_max_height");
 
 //////////////////
 // 0.10.3 Settings
@@ -552,280 +552,280 @@
 define('TDOMF_KEY_FIELDS', "_tdomf_fields");
 define('TDOMF_KEY_CUSTOM_FIELDS', "_tdomf_custom_fields");
 
-//////////////////////////////////////////////////
-// loading text domain for language translation
-//
-load_plugin_textdomain('tdomf',PLUGINDIR.DIRECTORY_SEPARATOR.TDOMF_FOLDER);
-
-/////////////////////////////////////////
-// Loading "hacks" here before pluggable
-//
-require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-hacks.php');
-
-//////////////////////////////////////////////////////////////////////////
-// A potential fix for WordpressMU (WordpressMU is officially unsupported)
-//
-require_once(ABSPATH . 'wp-includes/pluggable.php');
-
-// Is this a Wordpress < 2.5 install?
-//
-function tdomf_wp23() {
-  global $wp_db_version;
-  #if($wp_db_verison <= 6124)
-  #  return true;
-  return !tdomf_wp25();
-}
-
-// Is this a Wordpress >= 2.5 install?
-//
-function tdomf_wp25() {
-  global $wp_db_version;
-  if($wp_db_version >= 7558) {
-    return true;
-  }
-  return false;
-}
-
-// Is this a Wordpress >= 2.7
-//
-function tdomf_wp27() {
-  global $wp_version;
-  return version_compare($wp_version,"2.7-beta3",">=");
-}
-
-///////////////////////////////////
-// Configure Backend Admin Menus //
-///////////////////////////////////
-
-add_action('admin_menu', 'tdomf_add_menus');
-function tdomf_add_menus()
-{
-    $unmod_count  = tdomf_get_unmoderated_posts_count();
-    $unmod_count += tdomf_get_edits(array('state' => 'unapproved', 'count' => true, 'unique_post_ids' => true));
-
-    /*if(tdomf_wp25() && $unmod_count > 0) {
-        add_menu_page(__('TDO Mini Forms', 'tdomf'), sprintf(__("TDO Mini Forms <span id='awaiting-mod' class='count-%d'><span class='comment-count'>%d</span></span>", 'tdomf'), $unmod_count, $unmod_count), 'edit_others_posts', TDOMF_FOLDER, 'tdomf_overview_menu');
-    } else {*/
-        add_menu_page(__('TDO Mini Forms', 'tdomf'), __('TDO Mini Forms', 'tdomf'), 'edit_others_posts', TDOMF_FOLDER, 'tdomf_overview_menu');
-    /*}*/
-
-    // Options
-    add_submenu_page( TDOMF_FOLDER , __('Options', 'tdomf'), __('Options', 'tdomf'), 'manage_options', 'tdomf_show_options_menu', 'tdomf_show_options_menu');
-    //
-    // Form Options
-    add_submenu_page( TDOMF_FOLDER , __('Form Options', 'tdomf'), __('Form Options', 'tdomf'), 'manage_options', 'tdomf_show_form_options_menu', 'tdomf_show_form_options_menu');
-    //
-    // Form Widgets
-    add_submenu_page( TDOMF_FOLDER , __('Form Creator', 'tdomf'), __('Form Creator', 'tdomf'), 'manage_options', 'tdomf_show_form_menu', 'tdomf_show_form_menu');
-    //
-    // Form Hacker
-    add_submenu_page( TDOMF_FOLDER , __('Form Hacker', 'tdomf'), __('Form Hacker', 'tdomf'), 'manage_options', 'tdomf_show_form_hacker', 'tdomf_show_form_hacker');
-    //
-    // Form Export
-    add_submenu_page( TDOMF_FOLDER , __('Form Export', 'tdomf'), __('Form Export', 'tdomf'), 'manage_options', 'tdomf_show_form_export_menu', 'tdomf_show_form_export_menu');
-    //
-    // Moderation Queue
-    if(tdomf_is_moderation_in_use()) {
-      add_submenu_page( TDOMF_FOLDER , __('Moderation', 'tdomf'), sprintf(__('Moderation (%d)', 'tdomf'), $unmod_count), 'edit_others_posts', 'tdomf_show_mod_posts_menu', 'tdomf_show_mod_posts_menu');
-    }
-    else {
-      add_submenu_page( TDOMF_FOLDER , __('Moderation', 'tdomf'), __('Moderation', 'tdomf'), 'edit_others_posts', 'tdomf_show_mod_posts_menu', 'tdomf_show_mod_posts_menu');
-    }
-    //
-    // Manage Submitters
-    add_submenu_page( TDOMF_FOLDER , __('Users and IPs', 'tdomf'), __('Users and IPs', 'tdomf'), 'edit_others_posts', 'tdomf_show_manage_menu', 'tdomf_show_manage_menu');
-    //
-    // Log
-    add_submenu_page( TDOMF_FOLDER , __('Log', 'tdomf'), __('Log', 'tdomf'), 'manage_options', 'tdomf_show_log_menu', 'tdomf_show_log_menu');
-    //
-    // Uninstall
-    add_submenu_page( TDOMF_FOLDER , __('Uninstall', 'tdomf'), __('Uninstall', 'tdomf'), 'manage_options', 'tdomf_show_uninstall_menu', 'tdomf_show_uninstall_menu');
-
-    //
-    // Your submissions
-    if(get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) {
-      add_submenu_page('profile.php', 'Your Submissions', 'Your Submissions', 0, 'tdomf_your_submissions', 'tdomf_show_your_submissions_menu');
-    }
-}
-
-//////////////////////////////////
-// Load the rest of the plugin! //
-//////////////////////////////////
-
-require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-log-functions.php');
-require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-widget-functions.php');
-require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-template-functions.php');
-require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-spam.php');
-require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-form.php');
-require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-notify.php');
-require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-upload-functions.php');
-require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-theme-widgets.php');
-require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-db.php');
-require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-msgs.php');
-require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-widget-classes.php');
-require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-overview.php');
-require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-edit-post-panel.php');
-require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-form-options.php');
-require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-form-export.php');
-require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-options.php');
-require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-edit-form.php');
-require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-log.php');
-require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-moderation.php');
-require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-manage.php');
-require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-your-submissions.php');
-require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-uninstall.php');
-require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-form-hacker.php');
-require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-export.php');
-
-/////////////////////////
-// What's new since... //
-/////////////////////////
-
-function tdomf_new_features() {
-  $last_version = get_option(TDOMF_VERSION_LAST);
-  $features = "";
-
-  if($last_version == false) { return false; }
-
-  // 29 = 0.10.4
-  if($last_version <= 29) {
-
-    $link = get_bloginfo('wpurl')."/wp-admin/admin.php?page=tdomf_show_options_menu#spam";
-    $features .= "<li>".sprintf(__('<a href="%s">Integration with Akismet for SPAM protection</a>','tdomf'),$link)."</li>";
-
-    $link = get_bloginfo('wpurl')."/wp-admin/admin.php?page=tdomf_show_options_menu&form=".tdomf_get_first_form_id()."#queue";
-    $features .= "<li>".sprintf(__('<a href="%s">Automatically schedule approved posts!</a>','tdomf'),$link)."</li>";
-
-    $link = get_bloginfo('wpurl')."/wp-admin/admin.php?page=tdomf_show_options_menu&form=".tdomf_get_first_form_id()."#throttle";
-    $features .= "<li>".sprintf(__('<a href="%s">Add submission throttling rules to your form!</a>','tdomf'),$link)."</li>";
-
-    if(current_user_can('manage_options')) {
-        $link = "admin.php?page=".TDOMF_FOLDER.DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."tdomf-info.php&text";
-        $link2 = "admin.php?page=".TDOMF_FOLDER.DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."tdomf-info.php&html";
-        $features .= "<li>".sprintf(__('View tdomfinfo() in <a href="%s">text</a> and <a href="%s">html-code</a>. Useful for copying and pasting!',"tdomf"),$link,$link2)."</li>";
-    }
-
-    $link = get_bloginfo('wpurl')."/wp-admin/admin.php?page=tdomf_show_options_menu&form=".tdomf_get_first_form_id()."#import";
-    $features .= "<li>".sprintf(__('<a href="%s">Import and export individual form settings</a>','tdomf'),$link)."</li>";
-
-    $link = get_bloginfo('wpurl')."/wp-admin/widgets.php";
-    $features .= "<li>".sprintf(__('New widget for your theme: <a href="%s">Top Submitters</a>','tdomf'),$link)."</li>";
-  }
-  // 30 = 0.11b
-  // 31 = 0.11
-  // 32 = 0.11.1 (bug fixes)
-  if($last_version <= 32) {
-
-      $link = get_bloginfo('wpurl')."/wp-admin/admin.php?page=tdomf_show_options_menu&form=".tdomf_get_first_form_id()."#ajax";
-      $features .= "<li>".sprintf(__('<a href="%s">AJAX support for forms!</a>','tdomf'),$link)."</li>";
-
-      $link = get_bloginfo('wpurl')."/wp-admin/admin.php?page=tdomf_show_form_hacker";
-      $features .= "<li>".sprintf(__('<a href="%s">Hack the appearance of your form!</a>','tdomf'),$link)."</li>";
-
-      $link = get_bloginfo('wpurl')."/wp-admin/admin.phppage=tdomf_show_form_menu&form=".tdomf_get_first_form_id();
-      $features .= "<li>".sprintf(__('<a href="%s">Text widget updated to support macros and php code</a>','tdomf'),$link)."</li>";
-
-      $link = get_bloginfo('wpurl')."/wp-admin/admin.phppage=tdomf_show_form_menu&form=".tdomf_get_first_form_id();
-      $features .= "<li>".sprintf(__('<a href="%s">Categories widget can now be displayed as checkboxes or radio buttons</a>','tdomf'),$link)."</li>";
-
-      $link = get_bloginfo('wpurl')."/wp-admin/admin.phppage=tdomf_show_form_menu&form=".tdomf_get_first_form_id();
-      $features .= "<li>".sprintf(__('<a href="%s">New Widget: Append. Allows you add text to a submitted post. It can even run PHP code.</a>','tdomf'),$link)."</li>";
-
-      $features .= "<li>".__('New Template Tags: tdomf_get_the_submitter_email and tdomf_the_submitter_email','tdomf')."</li>";
-  }
-  // 33 = 0.12b
-  // 34 = 0.12
-  // 40 = 0.12.3
-  if($last_version < 40) {
-      $features .= "<li>".__("Auto Respond Email widget for your form","tdomf")."</li>";
-      $features .= "<li>".__("Ban User and IP links directly from the moderation email","tdomf")."</li>";
-      $features .= "<li>".__("The moderation emails that are sent for admins can now be left turned on even if moderation is turned off","tdomf")."</li>";
-  }
-  // 41 = 0.12.4
-  if($last_version < 41) {
-      $features .= "<li>".__("Improved Error Reporting","tdomf")."</li>";
-      $features .= "<li>".__("Form toolbar on all form pages (Widgets and Form Hacker)","tdomf")."</li>";
-      $features .= "<li>".__("Include option implemented for Categories widget","tdomf")."</li>";
-      $features .= "<li>".__("Import/Export restored and improved","tdomf")."</li>";
-      $features .= "<li>".__("Default Generated Forms are now W3C compliant","tdomf")."</li>";
-      $features .= "<li>".__("Comment Notification from Submitted Posts no longer go to the Submitter unless they can modify the comments","tdomf")."</li>";
-  }
-  // 43 = 0.12.5
-  if($last_version < 43) {
-      $features .= "<li>".__("Excerpt Widget","tdomf")."</li>";
-      $features .= "<li>".__("Comments Management Widget","tdomf")."</li>";
-      $features .= "<li>".__("Include option implemented for Categories widget (fixed)","tdomf")."</li>";
-      $features .= "<li>".__("Order by and Sort options for Categories widget","tdomf")."</li>";
-      $features .= "<li>".__("Integration with Subscribe to Comments plugin via widget","tdomf")."</li>";
-      $features .= "<li>".__("Publish now button","tdomf")."</li>";
-      $features .= "<li>".__("Specify Email Addresses instead of Roles to recieve Moderation notifications","tdomf")."</li>";
-      $features .= "<li>".__('Default tags, required and enable/disable user adding tags options for Tags widget','tdomf').'</li>';
-  }
-  // 44 = pre-0.13 release
-  if($last_version < 44) {
-      $features .= "<li>".__("More powerful form access configuration. Now you can select by capability and user as well as role!","tdomf")."</li>";
-      $features .= "<li>".__("2.7 Wordpress Compatibility","tdomf")."</li>";
-      $features .= "<li>".__("Can now turn off auto-publishing of users with publishing rights","tdomf")."</li>";
-      $features .= "<li>".__("New Permalink Widget","tdomf")."</li>";
-      $features .= "<li>".__("New GeoMashup Integration Widget","tdomf")."</li>";
-  }
-  // 46 = 0.12.7
-  if($last_version < 46) {
-      $features .= "<li>".__("Auto Respond Email widget can now provide a link to flag posts using a Custom Field","tdomf")."</li>";
-  }
-  // 47 = 0.13
-  if($last_version < 47) {
-      $features .= "<li>".__("<b>You can now created forms to edit posts and pages!</b>","tdomf")."</li>";
-  }
-  // 48 = 0.13.1
-  // 49 = 0.13.2
-  if($last_version < 49) {
-      $features .= "<li>".__("<b>More Spam Checking options added. Can now be configured per form!</b>","tdomf")."</li>";
-  }
-  // 50 = 0.13.3
-  if($last_version < 50) {
-      $features .= "<li>".__("<b>Filter by user, ip and form on moderations screen</b>","tdomf")."</li>";
-      $features .= "<li>".__("<b>Enable syntax code highlighting on Form Hacker and messages</b>","tdomf")."</li>";
-      $features .= "<li>".__("<b>Special revision page for comparing revisions created by TDOMF</b>","tdomf")."</li>";
-  }
-  // 51 = 0.13.4
-  
-  if(!empty($features)) {
-    return "<ul>".$features."</ul>";
-  }
-
-  return false;
-}
-
-/////////////////////////
-// Start/Init/Upgrade //
-////////////////////////
-
-function tdomf_init(){
-
-  // Pre 0.7 or a fresh install!
-  if(get_option(TDOMF_VERSION_CURRENT) == false)
-  {
-    add_option(TDOMF_VERSION_CURRENT,TDOMF_BUILD);
-
-    // Some defaults for new options!
-    add_option(TDOMF_OPTION_MODERATION,true);
-    add_option(TDOMF_OPTION_PREVIEW,true);
-    add_option(TDOMF_OPTION_TRUST_COUNT,-1);
-    add_option(TDOMF_OPTION_YOUR_SUBMISSIONS,true);
+//////////////////////////////////////////////////
+// loading text domain for language translation
+//
+load_plugin_textdomain('tdomf',PLUGINDIR.DIRECTORY_SEPARATOR.TDOMF_FOLDER);
+
+/////////////////////////////////////////
+// Loading "hacks" here before pluggable
+//
+require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-hacks.php');
+
+//////////////////////////////////////////////////////////////////////////
+// A potential fix for WordpressMU (WordpressMU is officially unsupported)
+//
+require_once(ABSPATH . 'wp-includes/pluggable.php');
+
+// Is this a Wordpress < 2.5 install?
+//
+function tdomf_wp23() {
+  global $wp_db_version;
+  #if($wp_db_verison <= 6124)
+  #  return true;
+  return !tdomf_wp25();
+}
+
+// Is this a Wordpress >= 2.5 install?
+//
+function tdomf_wp25() {
+  global $wp_db_version;
+  if($wp_db_version >= 7558) {
+    return true;
+  }
+  return false;
+}
+
+// Is this a Wordpress >= 2.7
+//
+function tdomf_wp27() {
+  global $wp_version;
+  return version_compare($wp_version,"2.7-beta3",">=");
+}
+
+///////////////////////////////////
+// Configure Backend Admin Menus //
+///////////////////////////////////
+
+add_action('admin_menu', 'tdomf_add_menus');
+function tdomf_add_menus()
+{
+    $unmod_count  = tdomf_get_unmoderated_posts_count();
+    $unmod_count += tdomf_get_edits(array('state' => 'unapproved', 'count' => true, 'unique_post_ids' => true));
+
+    /*if(tdomf_wp25() && $unmod_count > 0) {
+        add_menu_page(__('TDO Mini Forms', 'tdomf'), sprintf(__("TDO Mini Forms <span id='awaiting-mod' class='count-%d'><span class='comment-count'>%d</span></span>", 'tdomf'), $unmod_count, $unmod_count), 'edit_others_posts', TDOMF_FOLDER, 'tdomf_overview_menu');
+    } else {*/
+        add_menu_page(__('TDO Mini Forms', 'tdomf'), __('TDO Mini Forms', 'tdomf'), 'edit_others_posts', TDOMF_FOLDER, 'tdomf_overview_menu');
+    /*}*/
+
+    // Options
+    add_submenu_page( TDOMF_FOLDER , __('Options', 'tdomf'), __('Options', 'tdomf'), 'manage_options', 'tdomf_show_options_menu', 'tdomf_show_options_menu');
+    //
+    // Form Options
+    add_submenu_page( TDOMF_FOLDER , __('Form Options', 'tdomf'), __('Form Options', 'tdomf'), 'manage_options', 'tdomf_show_form_options_menu', 'tdomf_show_form_options_menu');
+    //
+    // Form Widgets
+    add_submenu_page( TDOMF_FOLDER , __('Form Creator', 'tdomf'), __('Form Creator', 'tdomf'), 'manage_options', 'tdomf_show_form_menu', 'tdomf_show_form_menu');
+    //
+    // Form Hacker
+    add_submenu_page( TDOMF_FOLDER , __('Form Hacker', 'tdomf'), __('Form Hacker', 'tdomf'), 'manage_options', 'tdomf_show_form_hacker', 'tdomf_show_form_hacker');
+    //
+    // Form Export
+    add_submenu_page( TDOMF_FOLDER , __('Form Export', 'tdomf'), __('Form Export', 'tdomf'), 'manage_options', 'tdomf_show_form_export_menu', 'tdomf_show_form_export_menu');
+    //
+    // Moderation Queue
+    if(tdomf_is_moderation_in_use()) {
+      add_submenu_page( TDOMF_FOLDER , __('Moderation', 'tdomf'), sprintf(__('Moderation (%d)', 'tdomf'), $unmod_count), 'edit_others_posts', 'tdomf_show_mod_posts_menu', 'tdomf_show_mod_posts_menu');
+    }
+    else {
+      add_submenu_page( TDOMF_FOLDER , __('Moderation', 'tdomf'), __('Moderation', 'tdomf'), 'edit_others_posts', 'tdomf_show_mod_posts_menu', 'tdomf_show_mod_posts_menu');
+    }
+    //
+    // Manage Submitters
+    add_submenu_page( TDOMF_FOLDER , __('Users and IPs', 'tdomf'), __('Users and IPs', 'tdomf'), 'edit_others_posts', 'tdomf_show_manage_menu', 'tdomf_show_manage_menu');
+    //
+    // Log
+    add_submenu_page( TDOMF_FOLDER , __('Log', 'tdomf'), __('Log', 'tdomf'), 'manage_options', 'tdomf_show_log_menu', 'tdomf_show_log_menu');
+    //
+    // Uninstall
+    add_submenu_page( TDOMF_FOLDER , __('Uninstall', 'tdomf'), __('Uninstall', 'tdomf'), 'manage_options', 'tdomf_show_uninstall_menu', 'tdomf_show_uninstall_menu');
+
+    //
+    // Your submissions
+    if(get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) {
+      add_submenu_page('profile.php', 'Your Submissions', 'Your Submissions', 0, 'tdomf_your_submissions', 'tdomf_show_your_submissions_menu');
+    }
+}
+
+//////////////////////////////////
+// Load the rest of the plugin! //
+//////////////////////////////////
+
+require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-log-functions.php');
+require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-widget-functions.php');
+require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-template-functions.php');
+require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-spam.php');
+require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-form.php');
+require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-notify.php');
+require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-upload-functions.php');
+require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-theme-widgets.php');
+require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-db.php');
+require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-msgs.php');
+require_once(TDOMF_FULLPATH.'include'.DIRECTORY_SEPARATOR.'tdomf-widget-classes.php');
+require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-overview.php');
+require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-edit-post-panel.php');
+require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-form-options.php');
+require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-form-export.php');
+require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-options.php');
+require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-edit-form.php');
+require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-log.php');
+require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-moderation.php');
+require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-manage.php');
+require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-your-submissions.php');
+require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-uninstall.php');
+require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-form-hacker.php');
+require_once(TDOMF_FULLPATH.'admin'.DIRECTORY_SEPARATOR.'tdomf-export.php');
+
+/////////////////////////
+// What's new since... //
+/////////////////////////
+
+function tdomf_new_features() {
+  $last_version = get_option(TDOMF_VERSION_LAST);
+  $features = "";
+
+  if($last_version == false) { return false; }
+
+  // 29 = 0.10.4
+  if($last_version <= 29) {
+
+    $link = get_bloginfo('wpurl')."/wp-admin/admin.php?page=tdomf_show_options_menu#spam";
+    $features .= "<li>".sprintf(__('<a href="%s">Integration with Akismet for SPAM protection</a>','tdomf'),$link)."</li>";
+
+    $link = get_bloginfo('wpurl')."/wp-admin/admin.php?page=tdomf_show_options_menu&form=".tdomf_get_first_form_id()."#queue";
+    $features .= "<li>".sprintf(__('<a href="%s">Automatically schedule approved posts!</a>','tdomf'),$link)."</li>";
+
+    $link = get_bloginfo('wpurl')."/wp-admin/admin.php?page=tdomf_show_options_menu&form=".tdomf_get_first_form_id()."#throttle";
+    $features .= "<li>".sprintf(__('<a href="%s">Add submission throttling rules to your form!</a>','tdomf'),$link)."</li>";
+
+    if(current_user_can('manage_options')) {
+        $link = "admin.php?page=".TDOMF_FOLDER.DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."tdomf-info.php&text";
+        $link2 = "admin.php?page=".TDOMF_FOLDER.DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."tdomf-info.php&html";
+        $features .= "<li>".sprintf(__('View tdomfinfo() in <a href="%s">text</a> and <a href="%s">html-code</a>. Useful for copying and pasting!',"tdomf"),$link,$link2)."</li>";
+    }
+
+    $link = get_bloginfo('wpurl')."/wp-admin/admin.php?page=tdomf_show_options_menu&form=".tdomf_get_first_form_id()."#import";
+    $features .= "<li>".sprintf(__('<a href="%s">Import and export individual form settings</a>','tdomf'),$link)."</li>";
+
+    $link = get_bloginfo('wpurl')."/wp-admin/widgets.php";
+    $features .= "<li>".sprintf(__('New widget for your theme: <a href="%s">Top Submitters</a>','tdomf'),$link)."</li>";
+  }
+  // 30 = 0.11b
+  // 31 = 0.11
+  // 32 = 0.11.1 (bug fixes)
+  if($last_version <= 32) {
+
+      $link = get_bloginfo('wpurl')."/wp-admin/admin.php?page=tdomf_show_options_menu&form=".tdomf_get_first_form_id()."#ajax";
+      $features .= "<li>".sprintf(__('<a href="%s">AJAX support for forms!</a>','tdomf'),$link)."</li>";
+
+      $link = get_bloginfo('wpurl')."/wp-admin/admin.php?page=tdomf_show_form_hacker";
+      $features .= "<li>".sprintf(__('<a href="%s">Hack the appearance of your form!</a>','tdomf'),$link)."</li>";
+
+      $link = get_bloginfo('wpurl')."/wp-admin/admin.phppage=tdomf_show_form_menu&form=".tdomf_get_first_form_id();
+      $features .= "<li>".sprintf(__('<a href="%s">Text widget updated to support macros and php code</a>','tdomf'),$link)."</li>";
+
+      $link = get_bloginfo('wpurl')."/wp-admin/admin.phppage=tdomf_show_form_menu&form=".tdomf_get_first_form_id();
+      $features .= "<li>".sprintf(__('<a href="%s">Categories widget can now be displayed as checkboxes or radio buttons</a>','tdomf'),$link)."</li>";
+
+      $link = get_bloginfo('wpurl')."/wp-admin/admin.phppage=tdomf_show_form_menu&form=".tdomf_get_first_form_id();
+      $features .= "<li>".sprintf(__('<a href="%s">New Widget: Append. Allows you add text to a submitted post. It can even run PHP code.</a>','tdomf'),$link)."</li>";
+
+      $features .= "<li>".__('New Template Tags: tdomf_get_the_submitter_email and tdomf_the_submitter_email','tdomf')."</li>";
+  }
+  // 33 = 0.12b
+  // 34 = 0.12
+  // 40 = 0.12.3
+  if($last_version < 40) {
+      $features .= "<li>".__("Auto Respond Email widget for your form","tdomf")."</li>";
+      $features .= "<li>".__("Ban User and IP links directly from the moderation email","tdomf")."</li>";
+      $features .= "<li>".__("The moderation emails that are sent for admins can now be left turned on even if moderation is turned off","tdomf")."</li>";
+  }
+  // 41 = 0.12.4
+  if($last_version < 41) {
+      $features .= "<li>".__("Improved Error Reporting","tdomf")."</li>";
+      $features .= "<li>".__("Form toolbar on all form pages (Widgets and Form Hacker)","tdomf")."</li>";
+      $features .= "<li>".__("Include option implemented for Categories widget","tdomf")."</li>";
+      $features .= "<li>".__("Import/Export restored and improved","tdomf")."</li>";
+      $features .= "<li>".__("Default Generated Forms are now W3C compliant","tdomf")."</li>";
+      $features .= "<li>".__("Comment Notification from Submitted Posts no longer go to the Submitter unless they can modify the comments","tdomf")."</li>";
+  }
+  // 43 = 0.12.5
+  if($last_version < 43) {
+      $features .= "<li>".__("Excerpt Widget","tdomf")."</li>";
+      $features .= "<li>".__("Comments Management Widget","tdomf")."</li>";
+      $features .= "<li>".__("Include option implemented for Categories widget (fixed)","tdomf")."</li>";
+      $features .= "<li>".__("Order by and Sort options for Categories widget","tdomf")."</li>";
+      $features .= "<li>".__("Integration with Subscribe to Comments plugin via widget","tdomf")."</li>";
+      $features .= "<li>".__("Publish now button","tdomf")."</li>";
+      $features .= "<li>".__("Specify Email Addresses instead of Roles to recieve Moderation notifications","tdomf")."</li>";
+      $features .= "<li>".__('Default tags, required and enable/disable user adding tags options for Tags widget','tdomf').'</li>';
+  }
+  // 44 = pre-0.13 release
+  if($last_version < 44) {
+      $features .= "<li>".__("More powerful form access configuration. Now you can select by capability and user as well as role!","tdomf")."</li>";
+      $features .= "<li>".__("2.7 Wordpress Compatibility","tdomf")."</li>";
+      $features .= "<li>".__("Can now turn off auto-publishing of users with publishing rights","tdomf")."</li>";
+      $features .= "<li>".__("New Permalink Widget","tdomf")."</li>";
+      $features .= "<li>".__("New GeoMashup Integration Widget","tdomf")."</li>";
+  }
+  // 46 = 0.12.7
+  if($last_version < 46) {
+      $features .= "<li>".__("Auto Respond Email widget can now provide a link to flag posts using a Custom Field","tdomf")."</li>";
+  }
+  // 47 = 0.13
+  if($last_version < 47) {
+      $features .= "<li>".__("<b>You can now created forms to edit posts and pages!</b>","tdomf")."</li>";
+  }
+  // 48 = 0.13.1
+  // 49 = 0.13.2
+  if($last_version < 49) {
+      $features .= "<li>".__("<b>More Spam Checking options added. Can now be configured per form!</b>","tdomf")."</li>";
+  }
+  // 50 = 0.13.3
+  if($last_version < 50) {
+      $features .= "<li>".__("<b>Filter by user, ip and form on moderations screen</b>","tdomf")."</li>";
+      $features .= "<li>".__("<b>Enable syntax code highlighting on Form Hacker and messages</b>","tdomf")."</li>";
+      $features .= "<li>".__("<b>Special revision page for comparing revisions created by TDOMF</b>","tdomf")."</li>";
+  }
+  // 51 = 0.13.4
+  
+  if(!empty($features)) {
+    return "<ul>".$features."</ul>";
+  }
+
+  return false;
+}
+
+/////////////////////////
+// Start/Init/Upgrade //
+////////////////////////
+
+function tdomf_init(){
+
+  // Pre 0.7 or a fresh install!
+  if(get_option(TDOMF_VERSION_CURRENT) == false)
+  {
+    add_option(TDOMF_VERSION_CURRENT,TDOMF_BUILD);
+
+    // Some defaults for new options!
+    add_option(TDOMF_OPTION_MODERATION,true);
+    add_option(TDOMF_OPTION_PREVIEW,true);
+    add_option(TDOMF_OPTION_TRUST_COUNT,-1);
+    add_option(TDOMF_OPTION_YOUR_SUBMISSIONS,true);
     add_option(TDOMF_OPTION_WIDGET_MAX_WIDTH,500);
-    add_option(TDOMF_OPTION_WIDGET_MAX_LENGTH,400);
-  }
-
-  // Pre 0.9.3 (beta)/16
-  if(intval(get_option(TDOMF_VERSION_CURRENT)) < 16) {
-    add_option(TDOMF_OPTION_YOUR_SUBMISSIONS,true);
-  }
-
+    add_option(TDOMF_OPTION_WIDGET_MAX_HEIGHT,400);
+  }
+
+  // Pre 0.9.3 (beta)/16
+  if(intval(get_option(TDOMF_VERSION_CURRENT)) < 16) {
+    add_option(TDOMF_OPTION_YOUR_SUBMISSIONS,true);
+  }
+
   // Pre WP 2.5/0.10.2
   if(intval(get_option(TDOMF_VERSION_CURRENT)) < 26) {
     add_option(TDOMF_OPTION_WIDGET_MAX_WIDTH,500);
-    add_option(TDOMF_OPTION_WIDGET_MAX_LENGTH,400);
+    add_option(TDOMF_OPTION_WIDGET_MAX_HEIGHT,400);
   }
 
   if(get_option(TDOMF_OPTION_VERIFICATION_METHOD) == false) {
@@ -852,14 +852,14 @@
       }
   }
 
-  // Update build number
-  if(get_option(TDOMF_VERSION_CURRENT) != TDOMF_BUILD) {
-    update_option(TDOMF_VERSION_LAST,get_option(TDOMF_VERSION_CURRENT));
-    update_option(TDOMF_VERSION_CURRENT,TDOMF_BUILD);
-  }
-}
-
-tdomf_db_create_tables();
-tdomf_load_widgets();
-
-?>
+  // Update build number
+  if(get_option(TDOMF_VERSION_CURRENT) != TDOMF_BUILD) {
+    update_option(TDOMF_VERSION_LAST,get_option(TDOMF_VERSION_CURRENT));
+    update_option(TDOMF_VERSION_CURRENT,TDOMF_BUILD);
+  }
+}
+
+tdomf_db_create_tables();
+tdomf_load_widgets();
+
+?>
