Ticket #4642: 4642.diff
File 4642.diff, 2.4 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; … … 60 62 $subject = $subject[0]; 61 63 } 62 64 63 // Set the author using the email address ( Toor Reply-To, the last used)65 // Set the author using the email address (From or Reply-To, the last used) 64 66 // otherwise use the site admin 65 67 if (preg_match('/From: /', $line) | preg_match('/Reply-To: /', $line)) { 66 68 $author=trim($line); 67 if ( ereg("([a-zA-Z0-9 \_\-\.]+@[\a-zA-z0-9\_\-\.]+)", $author , $regs) ) {69 if ( ereg("([a-zA-Z0-9_.-]+@[a-zA-Z0-9_.-]+)", $author , $regs) ) { 68 70 $author = $regs[1]; 69 71 echo "Author = {$author} <p>"; 70 72 $author = $wpdb->escape($author); 71 73 $result = $wpdb->get_row("SELECT ID FROM $wpdb->users WHERE user_email='$author' LIMIT 1"); 72 if (!$result) 74 if (!$result) { 73 75 $post_author = 1; 74 else 76 $author_found = false; 77 } else { 75 78 $post_author = $result->ID; 76 } else 79 $author_found = true; 80 } 81 } else { 77 82 $post_author = 1; 83 $author_found = false; 84 } 78 85 } 79 86 80 87 if (preg_match('/Date: /i', $line)) { // of the form '20 Mar 2002 20:32:37' … … 108 115 } 109 116 endforeach; 110 117 118 // Set $post_status based on $author_found and on author's publish_posts capability 119 if ($author_found) { 120 $user = new WP_User($post_author); 121 if ($user->has_cap('publish_posts')) 122 $post_status = 'publish'; 123 else 124 $post_status = 'pending'; 125 } else { 126 // Author not found in DB, set status to pending. Author already set to admin. 127 $post_status = 'pending'; 128 } 129 111 130 $subject = trim($subject); 112 131 113 132 if ($content_type == 'multipart/alternative') { … … 141 160 142 161 $post_category = $post_categories; 143 162 144 // or maybe we should leave the choice to email drafts? propose a way145 $post_status = 'publish';146 147 163 $post_data = compact('post_content','post_title','post_date','post_date_gmt','post_author','post_category', 'post_status'); 148 164 $post_data = add_magic_quotes($post_data); 149 165