diff --git a/util/gmail-imap-import.php b/util/gmail-imap-import.php index 7d762d4..f1ed355 100644 --- a/util/gmail-imap-import.php +++ b/util/gmail-imap-import.php @@ -3,12 +3,14 @@ ini_set("session.save_path", "/tmp"); $webuidir = ""; +$email = ""; $daemonize = 0; $opts = 'hd::'; $lopts = array( - 'webui:' + 'webui:', + 'email:' ); @@ -21,11 +23,15 @@ echo("\nError: must provide path to WebUI directory\n\n"); exit; } - + if(isset($options['d'])) { $daemonize = 1; } + if(isset($options['email'])) { + $email = $options['email']; + } + } else { display_help(); @@ -80,20 +86,24 @@ } } else { - poll_imap_accounts(); + poll_imap_accounts($email); } -function poll_imap_accounts() { +function poll_imap_accounts($email = '') { $db = Registry::get('db'); $ug = new ModelUserGoogle(); $g = new ModelGoogleGoogle(); - $query = $db->query("SELECT email FROM " . TABLE_GOOGLE); + if($email) { + $query = $db->query("SELECT email FROM " . TABLE_GOOGLE . " WHERE email=?", array($email)); + } else { + $query = $db->query("SELECT email FROM " . TABLE_GOOGLE); + } if(isset($query->rows)) { foreach($query->rows as $q) { @@ -110,8 +120,9 @@ echo("\nUsage: $phpself --webui [PATH] [OPTIONS...]\n\n"); echo("\t--webui=\"[REQUIRED: path to the Piler WebUI Directory]\"\n\n"); echo("options:\n"); - echo("\t-d Daemonize the imap polling\n"); - echo("\t-h Prints this help screen and exits\n"); + echo("\t--email: Email address to poll. Leave it empty to poll all email addresses\n"); + echo("\t-d: Daemonize the imap polling\n"); + echo("\t-h: Prints this help screen and exits\n"); }