summaryrefslogtreecommitdiff
path: root/manager/application/controllers/MailController.php
diff options
context:
space:
mode:
authorMichael Tänzer <neo@nhng.de>2010-08-03 21:31:41 +0200
committerMichael Tänzer <neo@nhng.de>2010-08-03 21:31:41 +0200
commit5d25f6837871beae4067ce9a58e5fe664b3715e4 (patch)
treebb31261bf7c15b6314eb8a2944f49db8e8b4bfcf /manager/application/controllers/MailController.php
parentbe39a06a110df826ced9fa6bd03e79ccd17f695c (diff)
parent1a0d0c99c39054ee42508fede5a87ade5f2bcdca (diff)
downloadcacert-mgr-5d25f6837871beae4067ce9a58e5fe664b3715e4.tar.gz
cacert-mgr-5d25f6837871beae4067ce9a58e5fe664b3715e4.tar.xz
cacert-mgr-5d25f6837871beae4067ce9a58e5fe664b3715e4.zip
Merge branch 'master' of ssh://git-cacert.it-sls.de/var/cache/git/cacert-mgr
Diffstat (limited to 'manager/application/controllers/MailController.php')
-rw-r--r--manager/application/controllers/MailController.php77
1 files changed, 77 insertions, 0 deletions
diff --git a/manager/application/controllers/MailController.php b/manager/application/controllers/MailController.php
index 5ee84d4..1ba73e2 100644
--- a/manager/application/controllers/MailController.php
+++ b/manager/application/controllers/MailController.php
@@ -12,11 +12,53 @@ class MailController extends Zend_Controller_Action
public function init()
{
/* Initialize action controller here */
+ $session = Zend_Registry::get('session');
+ $auth = $session->authdata['authed_permissions'];
+
+ $action = $this->getRequest()->getActionName();
+
+ $this->view->leftNav('<a href="' .
+ $this->view->url(array('controller' => 'mail', 'action' => 'index'), 'default', true) .
+ '"' . (($action == 'index')?' class="active"':'') . '>' . I18n::_('View own Mails') . '</a>', Zend_View_Helper_Placeholder_Container_Abstract::SET, 1);
+ if ($session->authdata['authed_role'] == 'Admin') {
+ $this->view->leftNav('<a href="' .
+ $this->view->url(array('controller' => 'mail', 'action' => 'full'), 'default', true) .
+ '"' . (($action == 'full')?' class="active"':'') . '>' . I18n::_('View all Mails') . '</a>', Zend_View_Helper_Placeholder_Container_Abstract::SET, 2);
+ }
}
public function indexAction()
{
$config = Zend_Registry::get('config');
+ $session = Zend_Registry::get('session');
+
+ $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);
+
+ // skip all emails that do not belong to the user
+ if ($header->toaddress != $session->authdata['authed_username'])
+ continue;
+
+ $header->uid = $imap->imapUID($i+1);
+ $header->detailslink = $this->view->url(array('controller' => 'mail', 'action' => 'read', 'uid' => $header->uid), 'default', true);
+ $header->deletelink = $this->view->url(array('controller' => 'mail', 'action' => 'delete', 'uid' => $header->uid), 'default', true);
+ $headers[] = $header;
+ }
+
+ $this->view->headers = $headers;
+ }
+
+ public function fullAction()
+ {
+ $config = Zend_Registry::get('config');
+
$imap_config = $config->imap;
$imap = imapConnection::getInstance('cacert', $imap_config);
$imap->imapSwitchMbox('INBOX');
@@ -28,6 +70,7 @@ class MailController extends Zend_Controller_Action
$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);
+ $header->deletelink = $this->view->url(array('controller' => 'mail', 'action' => 'delete', 'uid' => $header->uid), 'default', true);
$headers[] = $header;
}
@@ -47,4 +90,38 @@ class MailController extends Zend_Controller_Action
$this->view->mail_body = $body;
}
+
+ /**
+ * delete message with unique id
+ */
+ public function deleteAction()
+ {
+ $config = Zend_Registry::get('config');
+ $uid = $this->getRequest()->getParam('uid', -1);
+ $this->view->returnto = $_SERVER['HTTP_REFERER'];
+
+ if ($uid == -1) {
+ $this->view->message = I18n::_('You did not select an email for deletion');
+ }
+ elseif ($this->view->returnto == '') {
+ $this->view->message = I18n::_('Please use the delete icons in the mail inventory to delete mails');
+ }
+ else {
+ $imap_config = $config->imap;
+ $imap = imapConnection::getInstance('cacert', $imap_config);
+ $imap->imapSwitchMbox('INBOX');
+
+ $header = $imap->imapFetchOverview($uid);
+
+ $session = Zend_Registry::get('session');
+ if ($session->authdata['authed_role'] != 'Admin' && $header->to != $session->authdata['authed_username']) {
+ $this->view->message = I18n::_('This message does not belong to you');
+ }
+ else {
+ $imap->imapDelete($uid);
+ $imap->imapExpunge();
+ $this->view->message = I18n::_('Message deleted');
+ }
+ }
+ }
}