コード例 #1
0
 /**
  * sucht nach einer bereits vorhandenen Instanz, wird keine gefunden,
  * dann wird eine neue Instanz angelegt.
  * Man kann die Config-Variable weglassen, wenn man sicher ist, dass
  * bereits eine Instanz mit dem gewünschten instanceName existiert,
  * existiert aber keiner, dann liefert getInstance eine Exception.
  *
  * @param $instance
  * @param $config
  * @return imapConnection
  */
 public static function getInstance($instanceName, $config = null)
 {
     if (!self::$instances) {
         self::$instances = array();
     }
     foreach (self::$instances as $instance) {
         if ($instance->getInstanceName() == $instanceName) {
             return $instance;
         }
     }
     /*
     if (!$config instanceof Config) {
     	throw new IMAPException(__METHOD__ . ' no config');
     }
     */
     $object = new imapConnection($instanceName, $config);
     self::$instances[] = $object;
     return $object;
 }
コード例 #2
0
 /**
  * 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');
         }
     }
 }