From 1a0d0c99c39054ee42508fede5a87ade5f2bcdca Mon Sep 17 00:00:00 2001 From: Markus Warg Date: Wed, 7 Jul 2010 09:41:44 +0200 Subject: [PATCH] add view own mails, view all mails (admin role required) add email delete --- manager/.settings/org.eclipse.php.core.prefs | 2 +- .../controllers/MailController.php | 77 ++++++++++++++++++ .../views/scripts/mail/delete.phtml | 12 +++ .../application/views/scripts/mail/full.phtml | 37 +++++++++ .../views/scripts/mail/index.phtml | 37 +++++---- manager/public/css/mail.css | 24 ++++++ manager/public/img/delete_icon.jpg | Bin 0 -> 13842 bytes manager/public/js/mail_redirect.js | 8 ++ 8 files changed, 182 insertions(+), 15 deletions(-) create mode 100644 manager/application/views/scripts/mail/delete.phtml create mode 100644 manager/application/views/scripts/mail/full.phtml create mode 100644 manager/public/img/delete_icon.jpg create mode 100644 manager/public/js/mail_redirect.js diff --git a/manager/.settings/org.eclipse.php.core.prefs b/manager/.settings/org.eclipse.php.core.prefs index cbc9cef..d2d74b0 100644 --- a/manager/.settings/org.eclipse.php.core.prefs +++ b/manager/.settings/org.eclipse.php.core.prefs @@ -1,4 +1,4 @@ -#Wed Mar 31 11:13:35 CEST 2010 +#Thu Apr 22 14:01:49 CEST 2010 eclipse.preferences.version=1 include_path=0;/ca-mgr (mawaunix)\u00055;org.zend.php.framework.CONTAINER phpVersion=php5 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('' . 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); + } } 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'); + } + } + } } diff --git a/manager/application/views/scripts/mail/delete.phtml b/manager/application/views/scripts/mail/delete.phtml new file mode 100644 index 0000000..d01cec8 --- /dev/null +++ b/manager/application/views/scripts/mail/delete.phtml @@ -0,0 +1,12 @@ +headLink()->appendStylesheet('/css/mail.css'); +$this->headScript()->appendFile('/js/mail_redirect.js'); +?> +

+message; +print ''; diff --git a/manager/application/views/scripts/mail/full.phtml b/manager/application/views/scripts/mail/full.phtml new file mode 100644 index 0000000..ba1986b --- /dev/null +++ b/manager/application/views/scripts/mail/full.phtml @@ -0,0 +1,37 @@ +headLink()->appendStylesheet('/css/mail.css'); +?> +

+headers) == 0) { + print I18n::_('You currently have no mail.'); +} +else { +?> + + + + + + + + + +headers as $header) { + print " \n"; + print " "; + print " "; + print " "; + print " "; + print " "; + print " "; + print " \n"; + } +} +?> +
detailslink . "\">" . $header->fromaddress . "" . $header->toaddress . "" . $header->subject . "" . $header->date . "" . $header->Size . "deletelink . "\">
diff --git a/manager/application/views/scripts/mail/index.phtml b/manager/application/views/scripts/mail/index.phtml index faf6bd4..85288e4 100644 --- a/manager/application/views/scripts/mail/index.phtml +++ b/manager/application/views/scripts/mail/index.phtml @@ -5,24 +5,33 @@ */ $this->headLink()->appendStylesheet('/css/mail.css'); ?> -

+

+headers) == 0) { + print I18n::_('You currently have no mail.'); +} +else { +?> - - - - - + + + + + + headers as $header) { - print " \n"; - print " "; - print " "; - print " "; - print " "; - print " "; - print " \n"; + foreach ($this->headers as $header) { + print " \n"; + print " "; + print " "; + print " "; + print " "; + print " "; + print " "; + print " \n"; + } } ?>
detailslink . "\">" . $header->fromaddress . "" . $header->toaddress . "" . $header->subject . "" . $header->date . "" . $header->Size . "
detailslink . "\">" . $header->fromaddress . "" . $header->toaddress . "" . $header->subject . "" . $header->date . "" . $header->Size . "deletelink . "\">
diff --git a/manager/public/css/mail.css b/manager/public/css/mail.css index 6cd0274..4ce23f5 100644 --- a/manager/public/css/mail.css +++ b/manager/public/css/mail.css @@ -15,6 +15,25 @@ padding: 3px; } +#content .col1 { + width: 170px; +} +#content .col2 { + width: 170px; +} +#content .col3 { + width: 165px; +} +#content .col4 { + width: 170px; +} +#content .col5 { + width: 50px; +} +#content .col6 { + width: 30px; +} + #content a { text-decoration: none; color: #000000; @@ -23,3 +42,8 @@ #content a:hover { color: #777777; } + +#content a.delete { + background-color: #ffffff; + color: white; +} diff --git a/manager/public/img/delete_icon.jpg b/manager/public/img/delete_icon.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f6ce52e4af910031e682b19ad1ed5ff342753a9e GIT binary patch literal 13842 zcmeG@cUV-%_H*y{rNh!umyRGTEPau>RB?mSu|${M3#`EIxAvrRYOqnB-v-wHvG>KF!D^LQi zr>8&9lgsn+W_$VYd;)l$-cSkv(t4y@xAkaO{d((3U9cg+2>=x#b?{QP`+@ZB?g!$e z-4AG!4t)_1w5x9POhp40P#qI)kpu zVCWj@Fm;Sf4Rm!4Of5`IOifHIjC6_Aanlt3m?L^RI(qtghWh%3EPZ`_7M|&|G$KZS zr-Jq)z=#eEfgTC51E>)~GD6yK!fqq&$BIoxm$(y z>p+)8v}puF!L>7o=Jb73w4(N~->ToNpJ0WYt?y}^`f)*uZLclU%4V%?n>2s_sESwX z8ck*fU!8v>r}nosf_Y|lN}8Ve4_|!u&U=w;L)*B!cf{p)rR^a6J*Qk2AH3}S-euR+ zzQaZ?3=YcQv8DEW#;bM^qkJ@}A>{TqcSGNBUYl-PH67mJ>$6Mal@;E% zswX{*za;H5_i)|qhi-N3n9*wM1@Y-4pBBA4+^D0ntqo62%VylBI^-2e1;VgoR(eXzId7Rk|;BX9A=0{ z4<=EDYX;8atkH)_tRXl7B_v-HJh6b2l?5qzFo!c9CZq$iVdbhW441$UgLx;9FM)CI z#t?PBg=GNbaE1J2BHhQypCq;aUubySxQSpwJ1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