model('user/google'); $loader->model('google/google'); openlog("piler-gmail-import", LOG_PID, LOG_MAIL); if($daemonize == 1) { while(1) { syslog(LOG_INFO, "started another imap poll"); poll_imap_accounts(); sleep(300); } } else { poll_imap_accounts(); } function poll_imap_accounts() { $db = Registry::get('db'); $ug = new ModelUserGoogle(); $g = new ModelGoogleGoogle(); $query = $db->query("SELECT email FROM " . TABLE_GOOGLE); if(isset($query->rows)) { foreach($query->rows as $q) { $access_token = $ug->refresh_access_token($q['email']); $g->download_users_emails($q['email'], $access_token); } } } ?>