list mails, read mails
[cacert-mgr.git] / manager / application / controllers / MailController.php
1 <?php
2 /**
3 * @author markus
4 * $Id: IndexController.php 6 2009-11-18 14:52:50Z markus $
5 */
6
7 require_once(LIBRARY_PATH . '/imap/imapConnection.php');
8
9 class MailController extends Zend_Controller_Action
10 {
11
12 public function init()
13 {
14 /* Initialize action controller here */
15 }
16
17 public function indexAction()
18 {
19 $config = Zend_Registry::get('config');
20 $imap_config = $config->imap;
21 $imap = imapConnection::getInstance('cacert', $imap_config);
22 $imap->imapSwitchMbox('INBOX');
23
24 $ck = $imap->imapCheck();
25
26 $headers = array();
27 for ($i=0; $i < $ck->Nmsgs; $i++) {
28 $header = $imap->imapHeader($i+1);
29 $header->uid = $imap->imapUID($i+1);
30 $header->detailslink = $this->view->url(array('controller' => 'mail', 'action' => 'read', 'uid' => $header->uid), 'default', true);
31 $headers[] = $header;
32 }
33
34 $this->view->headers = $headers;
35 }
36
37 public function readAction()
38 {
39 $config = Zend_Registry::get('config');
40 $imap_config = $config->imap;
41 $imap = imapConnection::getInstance('cacert', $imap_config);
42 $imap->imapSwitchMbox('INBOX');
43
44 $uid = $this->getRequest()->getParam('uid');
45
46 $body = $imap->imapBodyByUID($uid);
47
48 $this->view->mail_body = $body;
49 }
50 }