예제 #1
0
 /**
  * Dodaje do whitelist wiele adresow email
  *
  * Format parsowanego bloku tekstu:
  * EMAIL OPIS-KOMENTARZ
  * EMAIL OPIS-KOMENTARZ
  * EMAIL OPIS-KOMENTARZ
  *
  * @return void
  */
 public function addmanyAction()
 {
     $form = new Logic_Ws_Mail_RecipientDeveloper_Form_Many();
     $recipientModel = new MailRecipient();
     if ($this->getRequest()->isPost()) {
         if ($form->isCancelled($this->getRequest()->getPost())) {
             $this->_helper->redirector('index', null, null);
             return;
         } elseif ($form->isValid($this->getRequest()->getPost())) {
             $db = $this->_model->getDefaultAdapter();
             $db->beginTransaction();
             try {
                 $values = $form->getValues();
                 $report = '';
                 $numbers = explode("\n", $values['params']);
                 foreach ($numbers as $val) {
                     $mail = '';
                     $comment = '';
                     $val = trim($val);
                     if ($val == '') {
                         continue;
                     }
                     if (stripos($val, ' ')) {
                         $mail = substr($val, 0, stripos($val, ' '));
                         $comment = substr($val, stripos($val, ' '));
                     } else {
                         $mail = $val;
                     }
                     $report .= ' ' . $mail . ' - ';
                     $email = $this->_recpient->check($mail);
                     if ($email === NULL) {
                         $report .= $this->_recpient->getError() . ";";
                     } else {
                         $this->_model->addRecipientDeveloper(array('mail_recipient_id' => $email, 'email_comment' => $comment));
                         $report .= "dodany poprawnie;";
                     }
                     $this->_recpient->clearData();
                 }
                 $db->commit();
                 $this->_helper->messenger->success($report);
             } catch (Logic_Exception $e) {
                 $db->rollBack();
                 $this->_helper->messenger->error($e->getMessage());
             }
             $this->_helper->redirector('index');
             return;
         }
     }
     $this->view->form = $form;
 }