コード例 #1
0
 /**
  * Dodaje do whitelist wiele numerow telefonow
  *
  * Format parsowanego bloku tekstu:
  * XXAAABBBCCC OPIS-KOMENTARZ
  * XXAAABBBCCC OPIS-KOMENTARZ
  * XXAAABBBCCC OPIS-KOMENTARZ
  *
  * @return void
  */
 public function addmanyAction()
 {
     $form = new Logic_Ws_Sms_Blacklist_Form_Many();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             try {
                 $validator = new Logic_Validate_NumberMobilePhone();
                 $values = $form->getValues();
                 $report = '';
                 $numbers = explode("\n", $values['params']);
                 foreach ($numbers as $val) {
                     $number = '';
                     $comment = '';
                     $val = trim($val);
                     if ($val == '') {
                         continue;
                     }
                     if (stripos($val, ' ')) {
                         $number = substr($val, 0, stripos($val, ' '));
                         $comment = substr($val, stripos($val, ' '));
                     } else {
                         $number = $val;
                     }
                     $report .= ' ' . $number . ' - ';
                     if (!$validator->isValid($number)) {
                         $report .= "nie poprawny format numeru;";
                         continue;
                     }
                     if ($this->_model->fetchRow($this->_model->select()->where('phone_number = ?', $number))) {
                         $report .= "obecny na liście;";
                         continue;
                     }
                     $this->_model->insert(array('phone_number' => trim($number), 'number_comment' => trim($comment)));
                     $report .= "dodany poprawnie;";
                 }
                 $this->_helper->messenger->success($report);
                 $this->_helper->redirector('index');
                 return;
             } catch (Logic_Ws_Exception $e) {
                 $this->_helper->messenger->error($e->getMessage());
             } catch (Logic_Exception $e) {
                 $this->_helper->messenger->error();
             }
         }
     }
     $this->view->form = $form;
 }
コード例 #2
0
ファイル: Package.php プロジェクト: knatorski/SMS
 /**
  * Sprawdza poprawność wczytywanych numerów telefonów
  * @param type $phoneNumber
  * @return boolean
  * 
  */
 protected function _checkPhoneNumber($phoneNumber)
 {
     $digitsValidator = new Logic_Validate_NumberMobilePhone();
     if (false === $digitsValidator->isValid($phoneNumber)) {
         return "{$phoneNumber} nie jest poprawnym numerem telefonu.";
     }
     return true;
 }