summaryrefslogtreecommitdiffstats
path: root/wp-mail.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2008-04-04 16:44:15 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2008-04-04 16:44:15 +0000
commit7740e89de3e1bc0cc636120e3ca8ab9e97e4d3cc (patch)
treec6fd23b598f3994eddb18cb1c0f2e8d95ff054fa /wp-mail.php
parentf650f48c048bfbbb2ae702b6425d87e39358d748 (diff)
downloadwordpress-mu-7740e89de3e1bc0cc636120e3ca8ab9e97e4d3cc.tar.gz
wordpress-mu-7740e89de3e1bc0cc636120e3ca8ab9e97e4d3cc.tar.xz
wordpress-mu-7740e89de3e1bc0cc636120e3ca8ab9e97e4d3cc.zip
Merged with WordPress 2.5, unstable, only for testing
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1218 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-mail.php')
-rw-r--r--wp-mail.php44
1 files changed, 32 insertions, 12 deletions
diff --git a/wp-mail.php b/wp-mail.php
index ab9ae84..9e767fb 100644
--- a/wp-mail.php
+++ b/wp-mail.php
@@ -14,9 +14,14 @@ $pop3 = new POP3();
if (!$pop3->connect(get_option('mailserver_url'), get_option('mailserver_port')))
wp_die(wp_specialchars($pop3->ERROR));
-$count = $pop3->login(get_option('mailserver_login'), get_option('mailserver_pass'));
-if (0 == $count) wp_die(__('There doesn&#8217;t seem to be any new mail.'));
+if (!$pop3->user(get_option('mailserver_login')))
+ wp_die(wp_specialchars($pop3->ERROR));
+$count = $pop3->pass(get_option('mailserver_pass'));
+if (false === $count)
+ wp_die(wp_specialchars($pop3->ERROR));
+if (0 == $count)
+ echo "<p>There doesn't seem to be any new mail.</p>\n"; // will fall-through to end of for loop
for ($i=1; $i <= $count; $i++) :
@@ -27,6 +32,8 @@ for ($i=1; $i <= $count; $i++) :
$content_transfer_encoding = '';
$boundary = '';
$bodysignal = 0;
+ $post_author = 1;
+ $author_found = false;
$dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
foreach ($message as $line) :
if (strlen($line) < 3) $bodysignal = 1;
@@ -70,14 +77,18 @@ for ($i=1; $i <= $count; $i++) :
$author = sanitize_email($author);
if ( is_email($author) ) {
echo "Author = {$author} <p>";
- $author = $wpdb->escape($author);
- $result = $wpdb->get_row("SELECT ID FROM $wpdb->users WHERE user_email='$author' LIMIT 1");
- if (!$result)
+ $userdata = get_user_by_email($author);
+ if (!$userdata) {
$post_author = 1;
- else
- $post_author = $result->ID;
- } else
+ $author_found = false;
+ } else {
+ $post_author = $userdata->ID;
+ $author_found = true;
+ }
+ } else {
$post_author = 1;
+ $author_found = false;
+ }
}
if (preg_match('/Date: /i', $line)) { // of the form '20 Mar 2002 20:32:37'
@@ -111,6 +122,18 @@ for ($i=1; $i <= $count; $i++) :
}
endforeach;
+ // Set $post_status based on $author_found and on author's publish_posts capability
+ if ($author_found) {
+ $user = new WP_User($post_author);
+ if ($user->has_cap('publish_posts'))
+ $post_status = 'publish';
+ else
+ $post_status = 'pending';
+ } else {
+ // Author not found in DB, set status to pending. Author already set to admin.
+ $post_status = 'pending';
+ }
+
$subject = trim($subject);
if ($content_type == 'multipart/alternative') {
@@ -141,14 +164,11 @@ for ($i=1; $i <= $count; $i++) :
$post_category = $post_categories;
- // or maybe we should leave the choice to email drafts? propose a way
- $post_status = 'publish';
-
$post_data = compact('post_content','post_title','post_date','post_date_gmt','post_author','post_category', 'post_status');
$post_data = add_magic_quotes($post_data);
$post_ID = wp_insert_post($post_data);
- if ( is_wp_error( $post_ID ) )
+ if ( is_wp_error( $post_ID ) )
echo "\n" . $post_ID->get_error_message();
if (!$post_ID) {