summaryrefslogtreecommitdiff
path: root/manager
diff options
context:
space:
mode:
authorMarkus Warg <mw@it-sls.de>2010-04-14 16:29:09 +0200
committerMarkus Warg <mw@it-sls.de>2010-04-14 16:29:09 +0200
commit2597013887cfb5b2a9c7b0210b4deb0a0276e595 (patch)
tree53fb36b4d7d7900063a6e62c9ab160a5808d5185 /manager
parentae053ad0371d46f529a26c2a18953189620b88e4 (diff)
downloadcacert-mgr-2597013887cfb5b2a9c7b0210b4deb0a0276e595.tar.gz
cacert-mgr-2597013887cfb5b2a9c7b0210b4deb0a0276e595.tar.xz
cacert-mgr-2597013887cfb5b2a9c7b0210b4deb0a0276e595.zip
list mails, read mails
fix smaller issues in imap class mail controller list contents of mailbox read mails
Diffstat (limited to 'manager')
-rw-r--r--manager/application/controllers/MailController.php30
-rw-r--r--manager/application/views/scripts/mail/index.phtml21
-rw-r--r--manager/application/views/scripts/mail/read.phtml10
-rw-r--r--manager/library/imap/imapConnection.php26
-rw-r--r--manager/public/css/mail.css25
5 files changed, 98 insertions, 14 deletions
diff --git a/manager/application/controllers/MailController.php b/manager/application/controllers/MailController.php
index afe902b..5ee84d4 100644
--- a/manager/application/controllers/MailController.php
+++ b/manager/application/controllers/MailController.php
@@ -16,9 +16,35 @@ class MailController extends Zend_Controller_Action
public function indexAction()
{
- // action body
+ $config = Zend_Registry::get('config');
+ $imap_config = $config->imap;
+ $imap = imapConnection::getInstance('cacert', $imap_config);
+ $imap->imapSwitchMbox('INBOX');
+
+ $ck = $imap->imapCheck();
+
+ $headers = array();
+ for ($i=0; $i < $ck->Nmsgs; $i++) {
+ $header = $imap->imapHeader($i+1);
+ $header->uid = $imap->imapUID($i+1);
+ $header->detailslink = $this->view->url(array('controller' => 'mail', 'action' => 'read', 'uid' => $header->uid), 'default', true);
+ $headers[] = $header;
+ }
+
+ $this->view->headers = $headers;
}
+ public function readAction()
+ {
+ $config = Zend_Registry::get('config');
+ $imap_config = $config->imap;
+ $imap = imapConnection::getInstance('cacert', $imap_config);
+ $imap->imapSwitchMbox('INBOX');
+
+ $uid = $this->getRequest()->getParam('uid');
-}
+ $body = $imap->imapBodyByUID($uid);
+ $this->view->mail_body = $body;
+ }
+}
diff --git a/manager/application/views/scripts/mail/index.phtml b/manager/application/views/scripts/mail/index.phtml
index 4cbadc3..faf6bd4 100644
--- a/manager/application/views/scripts/mail/index.phtml
+++ b/manager/application/views/scripts/mail/index.phtml
@@ -3,5 +3,26 @@
* @author markus
* $Id: index.phtml 25 2009-12-02 15:43:21Z markus $
*/
+$this->headLink()->appendStylesheet('/css/mail.css');
?>
<H1><?php print I18n::_('Mail'); ?></H1>
+<table>
+ <tr>
+ <th><?php print I18n::_('From');?></th>
+ <th><?php print I18n::_('To');?></th>
+ <th><?php print I18n::_('Subject');?></th>
+ <th><?php print I18n::_('Date');?></th>
+ <th><?php print I18n::_('Size');?></th>
+ </tr>
+<?php
+foreach ($this->headers as $header) {
+ print " <tr>\n";
+ print " <td><a href=\"" . $header->detailslink . "\">" . $header->fromaddress . "</a></td>";
+ print " <td>" . $header->toaddress . "</td>";
+ print " <td>" . $header->subject . "</td>";
+ print " <td>" . $header->date . "</td>";
+ print " <td>" . $header->Size . "</td>";
+ print " </tr>\n";
+}
+?>
+</table>
diff --git a/manager/application/views/scripts/mail/read.phtml b/manager/application/views/scripts/mail/read.phtml
new file mode 100644
index 0000000..1d64d5e
--- /dev/null
+++ b/manager/application/views/scripts/mail/read.phtml
@@ -0,0 +1,10 @@
+<?php
+/**
+ * @author markus
+ * $Id: index.phtml 25 2009-12-02 15:43:21Z markus $
+ */
+$this->headLink()->appendStylesheet('/css/mail.css');
+?>
+<H1><?php print I18n::_('Read Mail'); ?></H1>
+<?php
+print_r($this->mail_body); \ No newline at end of file
diff --git a/manager/library/imap/imapConnection.php b/manager/library/imap/imapConnection.php
index f78dc3d..1528a76 100644
--- a/manager/library/imap/imapConnection.php
+++ b/manager/library/imap/imapConnection.php
@@ -407,8 +407,8 @@ class imapConnection {
if ($ret === false) {
if ($reconnect === true) {
$this->imap = $this->imapOpen($this->server.$this->mbox,
- $this->config->getValue('username'),
- $this->config->getValue('password'),
+ $this->config->username,
+ $this->config->password,
OP_HALFOPEN);
$ret = imap_ping($this->imap);
@@ -471,26 +471,26 @@ class imapConnection {
* @param $instanceName
* @param $config
*/
- protected function __construct($instanceName,$config) {
+ protected function __construct($instanceName, $config) {
$this->instanceName = $instanceName;
$this->config = $config;
- if (!$this->config->hasValue('mailhost')) {
+ if (!isset($this->config->mailhost)) {
throw new IMAPException(__METHOD__ . ' config attribute missing: "mailhost"');
}
- if (!$this->config->hasValue('username')) {
+ if (!isset($this->config->username)) {
throw new IMAPException(__METHOD__ . ' config attribute missing: "username"');
}
- if (!$this->config->hasValue('password')) {
+ if (!isset($this->config->password)) {
throw new IMAPException(__METHOD__ . ' config attribute missing: "password"');
}
- if (!$this->config->hasValue('port')) {
+ if (!isset($this->config->port)) {
throw new IMAPException(__METHOD__ . ' config attribute missing: "port"');
}
- $this->server = '{'.$this->config->getValue('mailhost').':'.$this->config->getValue('port').'/imap';
- if( $this->config->hasValue('use_tls') &&
- $this->config->getValue('use_tls') == true ) {
+ $this->server = '{'.$this->config->mailhost.':'.$this->config->port.'/imap';
+ if( isset($this->config->use_tls) &&
+ $this->config->use_tls != 0 ) {
$this->server .= '/tls';
}
$this->server .= '/novalidate-cert}';
@@ -502,8 +502,8 @@ class imapConnection {
$this->imap = null;
$this->imap = $this->imapOpen($this->server.$mbox,
- $this->config->getValue('username'),
- $this->config->getValue('password'),
+ $this->config->username,
+ $this->config->password,
OP_HALFOPEN);
if ($this->imap === false) {
@@ -535,9 +535,11 @@ class imapConnection {
return $instance;
}
+ /*
if (!$config instanceof Config) {
throw new IMAPException(__METHOD__ . ' no config');
}
+ */
$object = new imapConnection($instanceName, $config);
diff --git a/manager/public/css/mail.css b/manager/public/css/mail.css
new file mode 100644
index 0000000..6cd0274
--- /dev/null
+++ b/manager/public/css/mail.css
@@ -0,0 +1,25 @@
+@CHARSET "UTF-8";
+
+#content table {
+ border: 1px solid black;
+ border-collapse: collapse;
+}
+
+#content th {
+ border: 1px solid black;
+ padding: 3px;
+}
+
+#content td {
+ border: 1px solid black;
+ padding: 3px;
+}
+
+#content a {
+ text-decoration: none;
+ color: #000000;
+}
+
+#content a:hover {
+ color: #777777;
+}