'IMAPDash Email Module', 'url' => '', 'author' => '', 'authorurl' => '', 'version' => '0.1', 'description' => '', 'license' => 'Apache License 2.0', ); } public function action_admin_footer() { $url = URL::get('ajax', 'context=check_gmail'); $css_url = $this->get_url(); echo << var GmailChecker = { callback: function() { clearTimeout(GmailChecker.timeout); $.get( '$url', function( result ) { if (result) { $('#gmail-checker').html(result); $('#gmail-checker').show('slow'); setTimeout("$('#gmail-checker').hide('slow')", 60000); $('#gmail-checker').click(function(){ $(this).hide('slow'); }); } } ); GmailChecker.timeout = setTimeout('GmailChecker.callback()', 150000); }, timeout: 0 } $(document).ready(function(){ $('#gmail-checker').hide(); GmailChecker.timeout = setTimeout('GmailChecker.callback()', 3); });
JS; } public function action_ajax_check_gmail() { $user = "email"; //Options::get('gmail_checker_username'); $pass = "password"; //Options::get('gmail_checker_password'); $count = $this->get_new_mail_count($user, $pass); if($count) { echo '' . sprintf(_n('%d
New E-Mail', '%d
New E-Mails', $count), $count) . '
'; } } private function get_new_mail_count( $user, $pass ) { if ( $mbox = imap_open(self::IMAP_URL, $user, $pass) ) { $status = imap_status($mbox, self::IMAP_URL, SA_UIDNEXT); $count = 0; if ($last = Options::get('gmail_checker_uidlast')) { $msgs = imap_fetch_overview($mbox, "$last:$status->uidnext", FT_UID); Options::set('gmail_checker_uidlast', $status->uidnext); foreach ($msgs as $msg) { if (!$msg->seen) { $count++; } } } else { Options::set('gmail_checker_uidlast', $status->uidnext); } imap_close($mbox); return $count; } else { throw new Exception(_t('Could not connect to server', 'gmail_checker')); } } } ?>