Ticket #4642: 4642.2.diff
File 4642.2.diff, 1.9 KB (added by , 17 years ago) |
---|
-
wp-mail.php
27 27 $content_transfer_encoding = ''; 28 28 $boundary = ''; 29 29 $bodysignal = 0; 30 $post_author = 1; 31 $author_found = false; 30 32 $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); 31 33 foreach ($message as $line) : 32 34 if (strlen($line) < 3) $bodysignal = 1; … … 72 74 echo "Author = {$author} <p>"; 73 75 $author = $wpdb->escape($author); 74 76 $result = $wpdb->get_row("SELECT ID FROM $wpdb->users WHERE user_email='$author' LIMIT 1"); 75 if (!$result) 77 if (!$result) { 76 78 $post_author = 1; 77 else 79 $author_found = false; 80 } else { 78 81 $post_author = $result->ID; 79 } else 82 $author_found = true; 83 } 84 } else { 80 85 $post_author = 1; 86 $author_found = false; 87 } 81 88 } 82 89 83 90 if (preg_match('/Date: /i', $line)) { // of the form '20 Mar 2002 20:32:37' … … 111 118 } 112 119 endforeach; 113 120 121 // Set $post_status based on $author_found and on author's publish_posts capability 122 if ($author_found) { 123 $user = new WP_User($post_author); 124 if ($user->has_cap('publish_posts')) 125 $post_status = 'publish'; 126 else 127 $post_status = 'pending'; 128 } else { 129 // Author not found in DB, set status to pending. Author already set to admin. 130 $post_status = 'pending'; 131 } 132 114 133 $subject = trim($subject); 115 134 116 135 if ($content_type == 'multipart/alternative') { … … 144 163 145 164 $post_category = $post_categories; 146 165 147 // or maybe we should leave the choice to email drafts? propose a way148 $post_status = 'publish';149 150 166 $post_data = compact('post_content','post_title','post_date','post_date_gmt','post_author','post_category', 'post_status'); 151 167 $post_data = add_magic_quotes($post_data); 152 168