authdata['authed_permissions'];
$action = $this->getRequest()->getActionName();
$this->view->leftNav('' . I18n::_('View own Mails') . '', Zend_View_Helper_Placeholder_Container_Abstract::SET, 1);
if ($session->authdata['authed_role'] == 'Admin') {
$this->view->leftNav('' . I18n::_('View all Mails') . '', Zend_View_Helper_Placeholder_Container_Abstract::SET, 2);
}
$emails = new CAcert_User_Emails();
$this->addresses = $emails->getEmailAddressesByLogin($session->authdata['authed_username']);
}
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 (!in_array($header->toaddress, $this->addresses))
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');
$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);
$header->deletelink = $this->view->url(array('controller' => 'mail', 'action' => 'delete', '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;
}
/**
* 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' && !in_array($header->to, $this->addresses)) {
$this->view->message = I18n::_('This message does not belong to you');
}
else {
$imap->imapDelete($uid);
$imap->imapExpunge();
$this->view->message = I18n::_('Message deleted');
}
}
}
}