+
+
+
+
+
+
+ "[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!
";
+ 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!
";
+ 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.
View page »","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 .= "
".sprintf(__("$user_name is not a valid user name. Ignoring.
","tdomf"),$form_id)."";
+ 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 .= "
".sprintf(__("The email %s is not valid! Please update 'Who Gets Notified' with valid email addresses.","tdomf"),$email)."";
+ $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.
See your form »","tdomf"),$form_id,"users.php?page=tdomf_your_submissions#tdomf_form%d")."
";
+ } else {
+ $message .= sprintf(__("Saved Options for Form %d.","tdomf"),$form_id)."
";
+ }
+
+ // 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.
","tdomf"),$form_id);
+ } else {
+ $message .= sprintf(__("Could not delete Form %d!
","tdomf"),$form_id);
+ }
+ } else {
+ $message .= sprintf(__("You cannot delete the last form! There must be at least one form in the system.
","tdomf"),$form_id);
+ }
+ } else {
+ $message .= sprintf(__("Form %d is not valid!
","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.
","tdomf"),$form_id,$copy_form_id);
+ $retValue = $copy_form_id;
+ } else {
+ $message .= sprintf(__("Failed to copy Form %d!
","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.
","tdomf"),$form_id);
+ $retValue = $form_id;
+ } else {
+ $message .= __("Failed to create new Form!
","tdomf");
+ }
+ }
+
+ // Warnings
+
+ $message .= tdomf_get_error_messages(false);
+
+ if(!empty($message)) { ?>
+
+
Index: admin/tdomf-log.php
===================================================================
--- admin/tdomf-log.php (revision 169181)
+++ admin/tdomf-log.php (working copy)
@@ -1,62 +1,62 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
Index: admin/tdomf-options.php
===================================================================
--- admin/tdomf-options.php (revision 169181)
+++ admin/tdomf-options.php (working copy)
@@ -1,16 +1,16 @@
-
+ if(preg_match('/tdomf_show_options_menu/',$_SERVER['REQUEST_URI'])) { ?>
- 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;
-
-?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 0) { ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- '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); ?>
-
-
-
-
-
-
-
- items) && 0 != count($rss->items) ) {
- $rss->items = array_slice($rss->items, 0, 5);
- echo "
".__('Latest Support Forum Topics','tdomf')."
";
- foreach ($rss->items as $item) { ?>
- - '>
- ";
- } ?>
-
-
-
- ".$message = tdomf_get_error_messages().""; ?>
-
-
-
- |
-
- |
- My Amazon Wishlist]","tdomf"),"http://www.amazon.co.uk/gp/registry/23S7OL9W6Q4JT"); ?>
- |
-
- Rate TDO-Mini-Forms on Wordpress.org!]","tdomf"),"http://wordpress.org/extend/plugins/tdo-mini-forms/#rate-response"); ?>
- |
-
-
-
-
-
-
-
-
support forums on thedeadone.net or the support forums on wordpress.org.',"tdomf"); ?>
-
-
-
-
-
-
-
-
-
-
- items) && 0 != count($rss->items) )
- {
- $rss->items = array_slice($rss->items, 0, 4);
- foreach ($rss->items as $item)
- {
- ?>
-
-
'.date("F, jS", strtotime($item['pubdate'])).' - '.$item['description']; ?>
-
-
thedeadone.net to check for updates.', 'tdomf'), 'http://thedeadone.net/index.php?tag=tdomf') ?>
-
-
-
-
- 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 "
".sprintf(__("\"%s\"","tdomf"),get_permalink($p->ID),$p->post_title)."";
- } else {
- return "
".sprintf(__("\"%s\" submitted by %s","tdomf"),get_permalink($p->ID),$p->post_title,$submitter)."";
- }
- } else if($submitter == false || empty($submitter)) {
- return "
".sprintf(__("\"%s\" using form %d","tdomf"),get_permalink($p->ID),$p->post_title, $form_id)."";
- }
- return "
".sprintf(__("\"%s\" submitted by %s using form %d","tdomf"),get_permalink($p->ID),$p->post_title,$submitter,$form_id)."";
-}
-
-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 '
';
-
- $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 '| ' . $num . ' | ';
- echo '' . $text . ' | ';
-
- $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 '' . $num . ' | ';
- echo '' . $text . ' | ';
-
- echo '
';
-
- 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 '| ' . $num . ' | ';
- echo '' . $text . ' | ';
- echo '
';
- }
-
- 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 '| ' . $num . ' | ';
- echo '' . $text . ' | ';
-
- $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 '' . $num . ' | ';
- echo '' . $text . ' | ';
-
- echo '
';
-
- $num = number_format_i18n($pending_edits_count);
- $text = __ngettext( 'Pending Contribution', 'Pending Contributions', $pending_edits_count );
- echo '| ' . $num . ' | ';
- echo '' . $text . ' | ';
-
- $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 '' . $num . ' | ';
- echo '' . $text . ' | ';
- } 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 '' . $num . ' | ';
- echo '' . $text . ' | ';
-
- $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 '' . $num . ' | ';
- echo '' . $text . ' | ';
-
- }
-
- echo '
';
-}
-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) { ?>
-
- please visit the overview page. Thank you.','tdomf'),"admin.php?page=tdo-mini-forms"); ?>
-
-
+
+ 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;
+
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0) { ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ '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); ?>
+
+
+
+
+
+
+
+ items) && 0 != count($rss->items) ) {
+ $rss->items = array_slice($rss->items, 0, 5);
+ echo "
".__('Latest Support Forum Topics','tdomf')."
";
+ foreach ($rss->items as $item) { ?>
+ - '>
+ ";
+ } ?>
+
+
+
+ ".$message = tdomf_get_error_messages().""; ?>
+
+
+
+ |
+
+ |
+ My Amazon Wishlist]","tdomf"),"http://www.amazon.co.uk/gp/registry/23S7OL9W6Q4JT"); ?>
+ |
+
+ Rate TDO-Mini-Forms on Wordpress.org!]","tdomf"),"http://wordpress.org/extend/plugins/tdo-mini-forms/#rate-response"); ?>
+ |
+
+
+
+
+
+
+
+
support forums on thedeadone.net or the support forums on wordpress.org.',"tdomf"); ?>
+
+
+
+
+
+
+
+
+
+
+ items) && 0 != count($rss->items) )
+ {
+ $rss->items = array_slice($rss->items, 0, 4);
+ foreach ($rss->items as $item)
+ {
+ ?>
+
+
'.date("F, jS", strtotime($item['pubdate'])).' - '.$item['description']; ?>
+
+
thedeadone.net to check for updates.', 'tdomf'), 'http://thedeadone.net/index.php?tag=tdomf') ?>
+
+
+
+
+ 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 "
".sprintf(__("\"%s\"","tdomf"),get_permalink($p->ID),$p->post_title)."";
+ } else {
+ return "
".sprintf(__("\"%s\" submitted by %s","tdomf"),get_permalink($p->ID),$p->post_title,$submitter)."";
+ }
+ } else if($submitter == false || empty($submitter)) {
+ return "
".sprintf(__("\"%s\" using form %d","tdomf"),get_permalink($p->ID),$p->post_title, $form_id)."";
+ }
+ return "
".sprintf(__("\"%s\" submitted by %s using form %d","tdomf"),get_permalink($p->ID),$p->post_title,$submitter,$form_id)."";
+}
+
+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 '
';
+
+ $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 '| ' . $num . ' | ';
+ echo '' . $text . ' | ';
+
+ $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 '' . $num . ' | ';
+ echo '' . $text . ' | ';
+
+ echo '
';
+
+ 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 '| ' . $num . ' | ';
+ echo '' . $text . ' | ';
+ echo '
';
+ }
+
+ 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 '| ' . $num . ' | ';
+ echo '' . $text . ' | ';
+
+ $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 '' . $num . ' | ';
+ echo '' . $text . ' | ';
+
+ echo '
';
+
+ $num = number_format_i18n($pending_edits_count);
+ $text = __ngettext( 'Pending Contribution', 'Pending Contributions', $pending_edits_count );
+ echo '| ' . $num . ' | ';
+ echo '' . $text . ' | ';
+
+ $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 '' . $num . ' | ';
+ echo '' . $text . ' | ';
+ } 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 '' . $num . ' | ';
+ echo '' . $text . ' | ';
+
+ $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 '' . $num . ' | ';
+ echo '' . $text . ' | ';
+
+ }
+
+ echo '
';
+}
+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) { ?>
+
+ please visit the overview page. Thank you.','tdomf'),"admin.php?page=tdo-mini-forms"); ?>
+
+
\ 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 @@
-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 "
";
- _e("Deleting Options... ","tdomf");
- echo "";
-
- // 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);
+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 "
";
+ _e("Deleting Options... ","tdomf");
+ echo "";
+
+ // 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 "
";
- _e("DONE","tdomf");
- echo "";
-
- echo "
";
- _e("Resetting role capabilities... ","tdomf");
- echo "";
- 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 "
";
- _e("DONE","tdomf");
- echo "";
-
- echo "
";
- _e("Deleting Widget Options (or at least the ones I can find!)... ","tdomf");
- echo "";
- // 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 "";
- }
- }
- echo "
";
- _e("DONE","tdomf");
- } else {
- echo "";
- _e("FAIL","tdomf");
- }
- echo "
";
-
- echo "";
- _e("Deleting Database Tables... ","tdomf");
- echo "";
- tdomf_db_delete_tables();
- echo "";
- _e("DONE","tdomf");
- echo "
";
-
-}
-
-function tdomf_full_uninstall() {
-
- // Delete Posts
- //
- echo "";
- _e("Removing posts submitted or managed by TDO Mini Forms (this may take a few minutes depending on the number of posts)... ","tdomf");
- echo "";
- $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 "";
- _e("DONE","tdomf");
- echo "
";
-
- // Delete Created Users
- //
- echo "";
- _e("Attempting to delete any users created by TDOMF... ","tdomf");
- echo "";
- $users = get_option(TDOMF_OPTION_CREATEDUSERS);
- if($users != false) {
- foreach($users as $u) {
- wp_delete_user($u);
- }
- }
- echo "";
- _e("DONE","tdomf");
- echo "
";
-
- // Strip existing Users
- //
- echo "";
- _e("Removing info from remaining users (this may take a few minutes depending on number of users)... ","tdomf");
- echo "";
- $users = tdomf_get_all_users();
- foreach($users as $user) {
- delete_usermeta($user->ID, TDOMF_KEY_FLAG);
- delete_usermeta($user->ID, TDOMF_KEY_STATUS);
- }
- echo "";
- _e("DONE","tdomf");
- echo "
";
-
- // Delete Forms
- //
- $form_ids = tdomf_get_form_ids();
- foreach($form_ids as $f) {
- echo "";
- printf(__("Deleting Form %d... ","tdomf"),$f->form_id);
- echo "";
- if(tdomf_delete_form($f->form_id)) {
- echo "";
- _e("DONE","tdomf");
- } else {
- echo "";
- _e("FAIL","tdomf");
- }
- echo "
";
- }
-
- // Delete Options
- //
- tdomf_reset_options();
-}
-
-// Uninstall everything else!
-//
-function tdomf_uninstall() {
- tdomf_reset_options();
-
- echo "";
- _e("Removing info from all users (this may take a few minutes depending on number of users)... ","tdomf");
- echo "";
- $users = tdomf_get_all_users();
- foreach($users as $user) {
- delete_usermeta($user->ID, TDOMF_KEY_FLAG);
- delete_usermeta($user->ID, TDOMF_KEY_STATUS);
- }
- echo "";
- _e("DONE","tdomf");
- echo "
";
-
- // This includes v0.6 options!
- //
- echo "";
- _e("Removing info from all posts (this may take a few minutes depending on number of posts)... ","tdomf");
- echo "";
- $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 "";
- _e("DONE","tdomf");
- echo "
";
-}
-
-// Display a help page
-//
-function tdomf_show_uninstall_menu() {
- ?>
-
-
-
-
-
-
-
nearly everything. 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"); ?>
-
" class='delete' >
-
-
-
-
everything. 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"); ?>
-
" class='delete' >
-
-
-
-
-
-
-
-
-
+
+ echo "