updated google model

This commit is contained in:
SJ 2014-04-18 21:28:53 +02:00
parent 1be641087e
commit 4e6946feca

View File

@ -46,12 +46,13 @@ class ModelGoogleGoogle extends Model {
} }
} }
// Save all Messages from selected folder // Save all Messages from selected folder
private function saveMessages($email) { private function saveMessages($email) {
$last_msg_id = -1; $last_msg_id = -1;
$from = 1; $from = 1;
$downloaded = 0; $count = 0;
$storage = $this->storage; $storage = $this->storage;
$from = $this->get_last_message_id_by_unique_id($email, $storage) + 1; $from = $this->get_last_message_id_by_unique_id($email, $storage) + 1;
@ -86,7 +87,7 @@ class ModelGoogleGoogle extends Model {
rename(DIR_TMP . "/" . $tmpname, DIR_IMAP . "/" . $tmpname); rename(DIR_TMP . "/" . $tmpname, DIR_IMAP . "/" . $tmpname);
$downloaded++; $count++;
} }
//print "k: $k\n"; //print "k: $k\n";
} }
@ -97,13 +98,14 @@ class ModelGoogleGoogle extends Model {
} }
syslog(LOG_INFO, "downloaded $downloaded messages for $email"); syslog(LOG_INFO, "downloaded $count messages for $email");
return $count;
} }
public function download_users_emails($email, $accessToken) { public function download_users_emails($email, $accessToken) {
$count = 0;
if(!$email || !$accessToken) { return 0; } if(!$email || !$accessToken) { return 0; }
@ -119,14 +121,15 @@ class ModelGoogleGoogle extends Model {
foreach ($folders as $localName => $folder) { foreach ($folders as $localName => $folder) {
if ($folder->isSelectable()) { if($folder->isSelectable()) {
$this->storage->selectFolder($folder); $this->storage->selectFolder($folder);
$this->saveMessages($email); $count += $this->saveMessages($email);
} }
} }
} }
return $count;
} }